Merge remote-tracking branch 'origin/master'

This commit is contained in:
zadam 2022-07-19 23:32:21 +02:00
commit 61a0397963
4 changed files with 51 additions and 81 deletions

78
package-lock.json generated
View File

@ -1,17 +1,17 @@
{ {
"name": "trilium", "name": "trilium",
"version": "0.53.0-beta", "version": "0.53.2",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "trilium", "name": "trilium",
"version": "0.53.0-beta", "version": "0.53.2",
"hasInstallScript": true, "hasInstallScript": true,
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",
"dependencies": { "dependencies": {
"@electron/remote": "2.0.8", "@electron/remote": "2.0.8",
"@excalidraw/excalidraw": "0.11.0", "@excalidraw/excalidraw": "0.12.0",
"archiver": "5.3.1", "archiver": "5.3.1",
"async-mutex": "0.3.2", "async-mutex": "0.3.2",
"axios": "0.27.2", "axios": "0.27.2",
@ -51,8 +51,8 @@
"open": "8.4.0", "open": "8.4.0",
"portscanner": "2.2.0", "portscanner": "2.2.0",
"rand-token": "1.0.1", "rand-token": "1.0.1",
"react": "17.0.2", "react": "18.2.0",
"react-dom": "17.0.2", "react-dom": "18.2.0",
"request": "2.88.2", "request": "2.88.2",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",
@ -246,9 +246,9 @@
} }
}, },
"node_modules/@excalidraw/excalidraw": { "node_modules/@excalidraw/excalidraw": {
"version": "0.11.0", "version": "0.12.0",
"resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.11.0.tgz", "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.12.0.tgz",
"integrity": "sha512-wY0UdnN9JAcBKLzkGlVXiPSKgTO06YeeBhoIy/ezIiMJtfFtWBPjRjJROkdIGqnUmBz5L16MkuXE7b8j1b1ouw==", "integrity": "sha512-xMPmKmOEgKij43k5m6Koaevb+SBw6La7MT9UDY8Iq7nQCMhA1HQwcUURfSkZ3ERibdQmMsAGtjSLbkX7hrA3+A==",
"dependencies": { "dependencies": {
"dotenv": "10.0.0" "dotenv": "10.0.0"
}, },
@ -8524,28 +8524,26 @@
} }
}, },
"node_modules/react": { "node_modules/react": {
"version": "17.0.2", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0"
"object-assign": "^4.1.1"
}, },
"engines": { "engines": {
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/react-dom": { "node_modules/react-dom": {
"version": "17.0.2", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"object-assign": "^4.1.1", "scheduler": "^0.23.0"
"scheduler": "^0.20.2"
}, },
"peerDependencies": { "peerDependencies": {
"react": "17.0.2" "react": "^18.2.0"
} }
}, },
"node_modules/read-config-file": { "node_modules/read-config-file": {
@ -8937,12 +8935,11 @@
} }
}, },
"node_modules/scheduler": { "node_modules/scheduler": {
"version": "0.20.2", "version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"dependencies": { "dependencies": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0"
"object-assign": "^4.1.1"
} }
}, },
"node_modules/schema-utils": { "node_modules/schema-utils": {
@ -11025,9 +11022,9 @@
} }
}, },
"@excalidraw/excalidraw": { "@excalidraw/excalidraw": {
"version": "0.11.0", "version": "0.12.0",
"resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.11.0.tgz", "resolved": "https://registry.npmjs.org/@excalidraw/excalidraw/-/excalidraw-0.12.0.tgz",
"integrity": "sha512-wY0UdnN9JAcBKLzkGlVXiPSKgTO06YeeBhoIy/ezIiMJtfFtWBPjRjJROkdIGqnUmBz5L16MkuXE7b8j1b1ouw==", "integrity": "sha512-xMPmKmOEgKij43k5m6Koaevb+SBw6La7MT9UDY8Iq7nQCMhA1HQwcUURfSkZ3ERibdQmMsAGtjSLbkX7hrA3+A==",
"requires": { "requires": {
"dotenv": "10.0.0" "dotenv": "10.0.0"
} }
@ -17463,22 +17460,20 @@
} }
}, },
"react": { "react": {
"version": "17.0.2", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz",
"integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", "integrity": "sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0"
"object-assign": "^4.1.1"
} }
}, },
"react-dom": { "react-dom": {
"version": "17.0.2", "version": "18.2.0",
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz",
"integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", "integrity": "sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0",
"object-assign": "^4.1.1", "scheduler": "^0.23.0"
"scheduler": "^0.20.2"
} }
}, },
"read-config-file": { "read-config-file": {
@ -17804,12 +17799,11 @@
} }
}, },
"scheduler": { "scheduler": {
"version": "0.20.2", "version": "0.23.0",
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.0.tgz",
"integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", "integrity": "sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==",
"requires": { "requires": {
"loose-envify": "^1.1.0", "loose-envify": "^1.1.0"
"object-assign": "^4.1.1"
} }
}, },
"schema-utils": { "schema-utils": {

View File

@ -26,7 +26,7 @@
}, },
"dependencies": { "dependencies": {
"@electron/remote": "2.0.8", "@electron/remote": "2.0.8",
"@excalidraw/excalidraw": "0.11.0", "@excalidraw/excalidraw": "0.12.0",
"archiver": "5.3.1", "archiver": "5.3.1",
"async-mutex": "0.3.2", "async-mutex": "0.3.2",
"axios": "0.27.2", "axios": "0.27.2",
@ -66,8 +66,8 @@
"open": "8.4.0", "open": "8.4.0",
"portscanner": "2.2.0", "portscanner": "2.2.0",
"rand-token": "1.0.1", "rand-token": "1.0.1",
"react": "17.0.2", "react": "18.2.0",
"react-dom": "17.0.2", "react-dom": "18.2.0",
"request": "2.88.2", "request": "2.88.2",
"rimraf": "3.0.2", "rimraf": "3.0.2",
"sanitize-filename": "1.6.3", "sanitize-filename": "1.6.3",

View File

@ -45,8 +45,8 @@ const TPL = `
* *
* Functionality: * Functionality:
* We store the excalidraw assets (elements, appState, files) in the note. In addition to that, we * 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 * export the SVG from the canvas on every update. The SVG is also saved in the note. It is used when
* for displaying any canvas note inside of a text note as an image. * calling api/images and makes referencing very easy.
* *
* Paths not taken. * Paths not taken.
* - excalidraw-to-svg (node.js) could be used to avoid storing the svg in the backend. * - excalidraw-to-svg (node.js) could be used to avoid storing the svg in the backend.
@ -65,7 +65,6 @@ const TPL = `
* has. * has.
* *
* Known issues: * 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 * - the 3 excalidraw fonts should be included in the share and everywhere, so that it is shown
* when requiring svg. * when requiring svg.
* *
@ -85,8 +84,8 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
super(); super();
// constants // constants
this.SCENE_VERSION_INITIAL = -1; this.SCENE_VERSION_INITIAL = -1; // -1 indicates, that it is fresh. excalidraw scene version is always >0
this.SCENE_VERSION_ERROR = -2; this.SCENE_VERSION_ERROR = -2; // -2 indicates error
// config // config
this.DEBOUNCE_TIME_ONCHANGEHANDLER = 750; // ms this.DEBOUNCE_TIME_ONCHANGEHANDLER = 750; // ms
@ -103,6 +102,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
this.$widget; this.$widget;
this.reactHandlers; // used to control react state this.reactHandlers; // used to control react state
// binds
this.createExcalidrawReactApp = this.createExcalidrawReactApp.bind(this); this.createExcalidrawReactApp = this.createExcalidrawReactApp.bind(this);
this.onChangeHandler = this.onChangeHandler.bind(this); this.onChangeHandler = this.onChangeHandler.bind(this);
this.isNewSceneVersion = this.isNewSceneVersion.bind(this); this.isNewSceneVersion = this.isNewSceneVersion.bind(this);
@ -253,7 +253,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
* parallel svg export to combat bitrot and enable rendering image for note inclusion, * parallel svg export to combat bitrot and enable rendering image for note inclusion,
* preview and share. * preview and share.
*/ */
const svg = await window.Excalidraw.exportToSvg({ const svg = await window.ExcalidrawLib.exportToSvg({
elements, elements,
appState, appState,
exportPadding: 5, // 5 px padding exportPadding: 5, // 5 px padding
@ -262,11 +262,6 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
}); });
const svgString = svg.outerHTML; const svgString = svg.outerHTML;
/**
* workaround until https://github.com/excalidraw/excalidraw/pull/5065 is merged and published
*/
const svgSafeString = this.replaceExternalAssets(svgString);
const activeFiles = {}; const activeFiles = {};
elements.forEach((element) => { elements.forEach((element) => {
if (element.fileId) { if (element.fileId) {
@ -279,7 +274,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
elements, // excalidraw elements, // excalidraw
appState, // excalidraw appState, // excalidraw
files: activeFiles, // 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); return JSON.stringify(content);
@ -317,7 +312,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
createExcalidrawReactApp() { createExcalidrawReactApp() {
const React = window.React; const React = window.React;
const Excalidraw = window.Excalidraw; const { Excalidraw } = window.ExcalidrawLib;
const excalidrawRef = React.useRef(null); const excalidrawRef = React.useRef(null);
this.excalidrawRef = excalidrawRef; this.excalidrawRef = excalidrawRef;
@ -379,7 +374,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
className: "excalidraw-wrapper", className: "excalidraw-wrapper",
ref: excalidrawWrapperRef ref: excalidrawWrapperRef
}, },
React.createElement(Excalidraw.default, { React.createElement(Excalidraw, {
// this makes sure that 1) manual theme switch button is hidden 2) theme stays as it should after opening menu // this makes sure that 1) manual theme switch button is hidden 2) theme stays as it should after opening menu
theme: this.themeStyle, theme: this.themeStyle,
ref: excalidrawRef, ref: excalidrawRef,
@ -420,7 +415,7 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
getSceneVersion() { getSceneVersion() {
if (this.excalidrawRef) { if (this.excalidrawRef) {
const elements = this.excalidrawRef.current.getSceneElements(); const elements = this.excalidrawRef.current.getSceneElements();
return window.Excalidraw.getSceneVersion(elements); return window.ExcalidrawLib.getSceneVersion(elements);
} else { } else {
return this.SCENE_VERSION_ERROR; return this.SCENE_VERSION_ERROR;
} }
@ -429,20 +424,4 @@ export default class ExcalidrawTypeWidget extends TypeWidget {
updateSceneVersion() { updateSceneVersion() {
this.currentSceneVersion = this.getSceneVersion(); 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;
}
} }

View File

@ -37,9 +37,6 @@ const App = () => {
}; };
window.addEventListener("resize", onResize); 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); return () => window.removeEventListener("resize", onResize);
}, [excalidrawWrapperRef]); }, [excalidrawWrapperRef]);
@ -53,7 +50,7 @@ const App = () => {
className: "excalidraw-wrapper", className: "excalidraw-wrapper",
ref: excalidrawWrapperRef ref: excalidrawWrapperRef
}, },
React.createElement(Excalidraw.default, { React.createElement(ExcalidrawLib.Excalidraw, {
ref: excalidrawRef, ref: excalidrawRef,
width: dimensions.width, width: dimensions.width,
height: dimensions.height, height: dimensions.height,