From 9c7f8cf5d8219d443ee694c7cbf52d0a15a94de1 Mon Sep 17 00:00:00 2001 From: Tom <7283497+thfrei@users.noreply.github.com> Date: Mon, 9 May 2022 16:17:37 +0200 Subject: [PATCH] extract errorSvg --- src/public/app/services/note_content_renderer.js | 5 +++-- .../type_widgets/canvas-note-utils/errorSvg.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/public/app/widgets/type_widgets/canvas-note-utils/errorSvg.js diff --git a/src/public/app/services/note_content_renderer.js b/src/public/app/services/note_content_renderer.js index 12c094cf4..a1d06ed92 100644 --- a/src/public/app/services/note_content_renderer.js +++ b/src/public/app/services/note_content_renderer.js @@ -7,6 +7,7 @@ import openService from "./open.js"; import froca from "./froca.js"; import utils from "./utils.js"; import linkService from "./link.js"; +import errorSvg from "../widgets/type_widgets/canvas-note-utils/errorSvg"; let idCounter = 1; @@ -149,9 +150,9 @@ async function getRenderedContent(note, options = {}) { const content = noteComplement.content || ""; try { - const errorSvg = `Error: note svg is undefined or empty`; + const placeHolderSVG = errorSvg; const data = JSON.parse(content) - const svg = data.svg || errorSvg; + const svg = data.svg || placeHolderSVG; /** * maxWidth: size down to 100% (full) width of container but do not enlarge! * height:auto to ensure that height scales with width diff --git a/src/public/app/widgets/type_widgets/canvas-note-utils/errorSvg.js b/src/public/app/widgets/type_widgets/canvas-note-utils/errorSvg.js new file mode 100644 index 000000000..80b40dae9 --- /dev/null +++ b/src/public/app/widgets/type_widgets/canvas-note-utils/errorSvg.js @@ -0,0 +1,11 @@ +/** + * used a placeholder, when svg parsing fails + */ +const erorrSvg = ` + + +Error: note svg is undefined or empty + +`; + +export default erorrSvg;