diff --git a/dev.postprocess.config.js b/dev.postprocess.config.js deleted file mode 100644 index a390872..0000000 --- a/dev.postprocess.config.js +++ /dev/null @@ -1,36 +0,0 @@ -import fs from'fs'; -import LZString from 'lz-string'; - -const excalidraw_pkg = isProd - ? fs.readFileSync("./node_modules/@zsviczian/excalidraw/dist/excalidraw.production.min.js", "utf8") - : fs.readFileSync("./node_modules/@zsviczian/excalidraw/dist/excalidraw.development.js", "utf8"); -const react_pkg = isProd - ? fs.readFileSync("./node_modules/react/umd/react.production.min.js", "utf8") - : fs.readFileSync("./node_modules/react/umd/react.development.js", "utf8"); -const reactdom_pkg = isProd - ? fs.readFileSync("./node_modules/react-dom/umd/react-dom.production.min.js", "utf8") - : fs.readFileSync("./node_modules/react-dom/umd/react-dom.development.js", "utf8"); -const lzstring_pkg = fs.readFileSync("./node_modules/lz-string/libs/lz-string.min.js", "utf8") - -const packageString = lzstring_pkg+'const EXCALIDRAW_PACKAGES = "' + LZString.compressToBase64(react_pkg + reactdom_pkg + excalidraw_pkg) +'";var ExcalidrawPackageLoader=(d=document)=>{const excalidraw_id = "excalidraw-script";if(!d.getElementById(excalidraw_id)){const script=d.createElement("script");script.type="text/javascript";script.id=excalidraw_id;script.text=LZString.decompressFromBase64(EXCALIDRAW_PACKAGES);d.body.appendChild(script);}};ExcalidrawPackageLoader();'; - -const mainjs = fs.readFileSync("main.js", "utf8") - - -fs.writeFileSync( - "main2.js", - mainjs - .replace('(require("react"));','') - .replace('"use strict";','"use strict";' + packageString), - { - encoding: "utf8", - flag: "w", - mode: 0o666 - } -); - - -let config = { -}; - -export default config; \ No newline at end of file diff --git a/manifest-beta.json b/manifest-beta.json index 1107507..ea27ee3 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.4.2-rc-1", + "version": "2.4.2", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/manifest.json b/manifest.json index 9119efc..e63d03c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.4.1", + "version": "2.4.2", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/prod.postprocess.config.js b/prod.postprocess.config.js deleted file mode 100644 index 1095709..0000000 --- a/prod.postprocess.config.js +++ /dev/null @@ -1,32 +0,0 @@ -import fs from'fs'; -import LZString from 'lz-string'; - -const excalidraw_pkg = fs.readFileSync("./node_modules/@zsviczian/excalidraw/dist/excalidraw.production.min.js", "utf8"); -const react_pkg = fs.readFileSync("./node_modules/react/umd/react.production.min.js", "utf8"); -const reactdom_pkg = fs.readFileSync("./node_modules/react-dom/umd/react-dom.production.min.js", "utf8"); -const lzstring_pkg = fs.readFileSync("./node_modules/lz-string/libs/lz-string.min.js", "utf8"); -const mainjs = fs.readFileSync("main.js", "utf8") - -const packageString = lzstring_pkg+'const EXCALIDRAW_PACKAGES="' + LZString.compressToBase64(react_pkg + reactdom_pkg + excalidraw_pkg) +'";var ExcalidrawPackageLoader=(d=document)=>{if(!d.getElementById("excalidraw-script")){const script=d.createElement("script");script.type="text/javascript";script.id="excalidraw-script";script.text=LZString.decompressFromBase64(EXCALIDRAW_PACKAGES);d.body.appendChild(script);}};ExcalidrawPackageLoader();'; - -fs.writeFileSync( - "main2.js", - mainjs - .replace('(require("react"))','') - .replace('"use strict";','"use strict";' + packageString), - { - encoding: "utf8", - flag: "w", - mode: 0o666 - } -); - - -export default ({ - input: 'foo', - plugins: [], - output: [{ - file: 'foo.js', - format: 'es' - }] -}); \ No newline at end of file diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index a05434a..b44c3b0 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -427,7 +427,9 @@ export class ExcalidrawAutomate { * @returns */ public getAPI(view?:ExcalidrawView):ExcalidrawAutomate { - return new ExcalidrawAutomate(this.plugin, view); + const ea = new ExcalidrawAutomate(this.plugin, view); + this.plugin.eaInstances.push(ea); + return ea; } /** @@ -741,18 +743,18 @@ export class ExcalidrawAutomate { outString += Object.keys(this.imagesDict).length > 0 ? `\n## Embedded Files\n` - : ""; + : "\n"; Object.keys(this.imagesDict).forEach((key: FileId)=> { const item = this.imagesDict[key]; if(item.latex) { - outString += `${key}: $$${item.latex}$$\n`; + outString += `${key}: $$${item.latex}$$\n\n`; } else { if(item.file) { if(item.file instanceof TFile) { - outString += `${key}: [[${item.file.path}]]\n`; + outString += `${key}: [[${item.file.path}]]\n\n`; } else { - outString += `${key}: [[${item.file}]]\n`; + outString += `${key}: [[${item.file}]]\n\n`; } } else { const hyperlinkSplit = item.hyperlink.split("#"); @@ -760,15 +762,15 @@ export class ExcalidrawAutomate { if(file && file instanceof TFile) { const hasFileRef = hyperlinkSplit.length === 2 outString += hasFileRef - ? `${key}: [[${file.path}#${hyperlinkSplit[1]}]]\n` - : `${key}: [[${file.path}]]\n`; + ? `${key}: [[${file.path}#${hyperlinkSplit[1]}]]\n\n` + : `${key}: [[${file.path}]]\n\n`; } else { - outString += `${key}: ${item.hyperlink}\n`; + outString += `${key}: ${item.hyperlink}\n\n`; } } } }) - return outString + "\n%%\n"; + return outString + "%%\n"; } const filename = params?.filename diff --git a/src/ExcalidrawData.ts b/src/ExcalidrawData.ts index 208aa33..853e836 100644 --- a/src/ExcalidrawData.ts +++ b/src/ExcalidrawData.ts @@ -1434,12 +1434,11 @@ export class ExcalidrawData { if (this.elementLinks.size > 0 || textElementLinks.size > 0) { outString += `## Element Links\n`; for (const key of this.elementLinks.keys()) { - outString += `${key}: ${this.elementLinks.get(key)}\n`; + outString += `${key}: ${this.elementLinks.get(key)}\n\n`; } for (const key of textElementLinks.keys()) { - outString += `${key}: ${textElementLinks.get(key)}\n`; + outString += `${key}: ${textElementLinks.get(key)}\n\n`; } - outString += "\n"; } // deliberately not adding mermaids to here. It is enough to have the mermaidText in the image element's customData @@ -1449,7 +1448,7 @@ export class ExcalidrawData { : ""; if (this.equations.size > 0) { for (const key of this.equations.keys()) { - outString += `${key}: $$${this.equations.get(key).latex}$$\n`; + outString += `${key}: $$${this.equations.get(key).latex}$$\n\n`; } } if (this.files.size > 0) { @@ -1457,18 +1456,18 @@ export class ExcalidrawData { const PATHREG = /(^[^#\|]*)/; const ef = this.files.get(key); if(ef.isHyperLink || ef.isLocalLink) { - outString += `${key}: ${ef.hyperlink}\n`; + outString += `${key}: ${ef.hyperlink}\n\n`; } else { //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/829 const path = ef.file ? ef.linkParts.original.replace(PATHREG,this.app.metadataCache.fileToLinktext(ef.file,this.file.path)) : ef.linkParts.original; const colorMap = ef.colorMap ? " " + JSON.stringify(ef.colorMap) : ""; - outString += `${key}: [[${path}]]${colorMap}\n`; + outString += `${key}: [[${path}]]${colorMap}\n\n`; } } } - outString += this.equations.size > 0 || this.files.size > 0 ? "\n" : ""; + //outString += this.equations.size > 0 || this.files.size > 0 ? "\n" : ""; const sceneJSONstring = JSON.stringify({ type: this.scene.type, diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 827426d..f943680 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -931,6 +931,10 @@ export default class ExcalidrawView extends TextFileView { } async openLaTeXEditor(eqId: string) { + if(await this.excalidrawData.syncElements(this.getScene())) { + //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1994 + await this.forceSave(true); + } const el = this.getViewElements().find((el:ExcalidrawElement)=>el.id === eqId && el.type==="image") as ExcalidrawImageElement; if(!el) { return; diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 3091f55..bcb099a 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,23 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"2.4.2": ` +This release addresses critical issues for all Obsidian Mobile users. + +#### 😞 I made two mistakes... +- I expedited the 2.4.1 release to resolve a major bug, but in doing so, I skippes some of my usual rigorous testing +- I included a new feature in 2.4.1 fresh from Excalidraw.com because I believe it brings significant end user benefits and did not want to wait until October. However, a small part of this feature was designed for server-side execution on Excalidraw.com, not for local use on Obsidian Mobile. + +Despite the recent two (2.4.1 and 2.4.2) emergency bug-fix releases, this doesn't deviate from the [monthly release schedule](https://youtu.be/2poSS-Z91lY). The next feature update is still planned for early October. + +## Fixes: +- **Excalidraw rendering issues on Obsidian Mobile:** [#1995](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1995), [#1997](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1997) + - Nested Excalidraw drawings with text failed to render. + - Drawings in Markdown view didn't render if they contained text and were set to SVG Image or SVG Native (they worked with PNG). + - SVG export failed for drawings containing text. +- **LaTeX equation duplication:** After using ALT+Drag to duplicate a LaTeX equation, editing the duplicate modified the original instead. [#1984](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1994) +- **Unreadable Obsidian search results:** When drawings contained numerous Element Links and Embedded Files Links, search results became unreadable. This fix will apply to files saved after installing the update. [#1999](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1999) +`, "2.4.1": ` This release includes an important fix that can result in your drawing being overwritten by another drawing. Please update to this version as soon as possible. diff --git a/src/dialogs/SuggesterInfo.ts b/src/dialogs/SuggesterInfo.ts index 37304b9..cc324de 100644 --- a/src/dialogs/SuggesterInfo.ts +++ b/src/dialogs/SuggesterInfo.ts @@ -654,6 +654,12 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [ "the function will use ea.targetView.file", after: "", }, + { + field: "getAPI", + code: "public getAPI(view?:ExcalidrawView):ExcalidrawAutomate", + desc: "Returns a new instance of ExcalidrawAutomate.", + after: "", + }, { field: "getAttachmentFilepath", code: "async getAttachmentFilepath(filename: string): Promise