From 3e7aa3d7624196d4e5f642bf4e32503dca347bc9 Mon Sep 17 00:00:00 2001 From: Tom Free <7283497+thfrei@users.noreply.github.com> Date: Sun, 17 Jul 2022 14:09:58 +0200 Subject: [PATCH] remove obsolete code, update doc --- src/public/app/widgets/type_widgets/canvas.js | 28 ++----------------- src/share/canvas_share.js | 7 ++--- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/public/app/widgets/type_widgets/canvas.js b/src/public/app/widgets/type_widgets/canvas.js index 8be9a7569..b67b4e2dd 100644 --- a/src/public/app/widgets/type_widgets/canvas.js +++ b/src/public/app/widgets/type_widgets/canvas.js @@ -45,8 +45,8 @@ const TPL = ` * * Functionality: * We store the excalidraw assets (elements, appState, files) in the note. In addition to that, we - * export the SVG from the canvas on every update. The SVG is also saved in the note. It is used - * for displaying any canvas note inside of a text note as an image. + * export the SVG from the canvas on every update. The SVG is also saved in the note. It is used when + * calling api/images and makes referencing very easy. * * Paths not taken. * - excalidraw-to-svg (node.js) could be used to avoid storing the svg in the backend. @@ -65,7 +65,6 @@ const TPL = ` * has. * * Known issues: - * - v0.11.0 of excalidraw does not render freedraw backgrounds in the svg * - the 3 excalidraw fonts should be included in the share and everywhere, so that it is shown * when requiring svg. * @@ -262,11 +261,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget { }); const svgString = svg.outerHTML; - /** - * workaround until https://github.com/excalidraw/excalidraw/pull/5065 is merged and published - */ - const svgSafeString = this.replaceExternalAssets(svgString); - const activeFiles = {}; elements.forEach((element) => { if (element.fileId) { @@ -279,7 +273,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget { elements, // excalidraw appState, // excalidraw files: activeFiles, // excalidraw - svg: svgSafeString, // not needed for excalidraw, used for note_short, content, and image api + svg: svgString, // not needed for excalidraw, used for note_short, content, and image api }; return JSON.stringify(content); @@ -429,20 +423,4 @@ export default class ExcalidrawTypeWidget extends TypeWidget { updateSceneVersion() { this.currentSceneVersion = this.getSceneVersion(); } - - /** - * replaces exlicraw.com with own assets - * - * workaround until https://github.com/excalidraw/excalidraw/pull/5065 is merged and published - * needed for v0.11.0 - * - * @param {string} string - * @returns - */ - replaceExternalAssets = (string) => { - let result = string; - // exlidraw.com asset in react usage - result = result.replaceAll("https://excalidraw.com/", window.EXCALIDRAW_ASSET_PATH+"excalidraw-assets/"); - return result; - } } diff --git a/src/share/canvas_share.js b/src/share/canvas_share.js index 70da159a0..d781ba44c 100644 --- a/src/share/canvas_share.js +++ b/src/share/canvas_share.js @@ -37,10 +37,7 @@ const App = () => { }; window.addEventListener("resize", onResize); - // ensure that resize is also called for split creation and deletion - // not really the problem. problem is saved appState! - // self.$renderElement.addEventListener("resize", onResize); - + return () => window.removeEventListener("resize", onResize); }, [excalidrawWrapperRef]); @@ -53,7 +50,7 @@ const App = () => { className: "excalidraw-wrapper", ref: excalidrawWrapperRef }, - React.createElement(Excalidraw.default, { + React.createElement(ExcalidrawLib.Excalidraw, { ref: excalidrawRef, width: dimensions.width, height: dimensions.height,