diff --git a/manifest.json b/manifest.json index 444a70b..3a4b03c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.3.19", + "version": "1.3.20", "minAppVersion": "0.12.0", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index c300939..12ba348 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -326,7 +326,7 @@ export async function initExcalidrawAutomate(plugin: ExcalidrawPlugin) { currentItemLinearStrokeSharpness: template? template.appState.currentItemLinearStrokeSharpness : this.style.strokeSharpness, gridSize: template ? template.appState.gridSize : this.canvas.gridSize } - })) + },null,"\t")) ); }, async createSVG(templatePath?:string):Promise { diff --git a/src/ExcalidrawData.ts b/src/ExcalidrawData.ts index d87196c..95d0b06 100644 --- a/src/ExcalidrawData.ts +++ b/src/ExcalidrawData.ts @@ -51,7 +51,7 @@ export const REGEX_LINK = { export const REG_LINKINDEX_HYPERLINK = /^\w+:\/\//; -const DRAWING_REG = /\n%%\n# Drawing\n[^`]*(```json\n)(.*)\n[^`]*```[^%]*(%%)?/gm; //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/182 +const DRAWING_REG = /\n%%\n# Drawing\n[^`]*(```json\n)([\s\S]*?)```/gm; //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/182 const DRAWING_REG_FALLBACK = /\n# Drawing\n(```json\n)?(.*)(```)?(%%)?/gm; export function getJSON(data:string):[string,number] { let res = data.matchAll(DRAWING_REG); @@ -438,7 +438,7 @@ export class ExcalidrawData { for(const key of this.textElements.keys()){ outString += this.textElements.get(key).raw+' ^'+key+'\n\n'; } - return outString + this.plugin.getMarkdownDrawingSection(JSON.stringify(this.scene)); + return outString + this.plugin.getMarkdownDrawingSection(JSON.stringify(this.scene,null,"\t")); } public async syncElements(newScene:any):Promise { diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index a7d2314..a892cbf 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -96,8 +96,8 @@ export default class ExcalidrawView extends TextFileView { } const filepath = this.file.path.substring(0,this.file.path.lastIndexOf('.md')) + '.excalidraw'; const file = this.app.vault.getAbstractFileByPath(normalizePath(filepath)); - if(file && file instanceof TFile) this.app.vault.modify(file,JSON.stringify(scene)); - else this.app.vault.create(filepath,JSON.stringify(scene)); + if(file && file instanceof TFile) this.app.vault.modify(file,JSON.stringify(scene,null,"\t")); + else this.app.vault.create(filepath,JSON.stringify(scene,null,"\t")); } public saveSVG(scene?: any) { @@ -197,7 +197,7 @@ export default class ExcalidrawView extends TextFileView { if(this.plugin.settings.autoexportSVG) this.saveSVG(scene); if(this.plugin.settings.autoexportPNG) this.savePNG(scene); } - return JSON.stringify(scene); + return JSON.stringify(scene,null,"\t"); } return this.data; } @@ -487,12 +487,12 @@ export default class ExcalidrawView extends TextFileView { const folderpath = splitFolderAndFilename(this.file.path).folderpath; await checkAndCreateFolder(this.app.vault,folderpath); //create folder if it does not exist const fname = getNewUniqueFilepath(this.app.vault,filename,folderpath); - this.app.vault.create(fname,JSON.stringify(this.getScene())); + this.app.vault.create(fname,JSON.stringify(this.getScene(),null,"\t")); new Notice("Exported to " + fname,6000); }); return; } - download('data:text/plain;charset=utf-8',encodeURIComponent(JSON.stringify(this.getScene())), this.file.basename+'.excalidraw'); + download('data:text/plain;charset=utf-8',encodeURIComponent(JSON.stringify(this.getScene(),null,"\t")), this.file.basename+'.excalidraw'); }); }); } else { diff --git a/src/main.ts b/src/main.ts index cb9a1d1..86014e8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -113,6 +113,7 @@ export default class ExcalidrawPlugin extends Plugin { //inspiration taken from kanban: //https://github.com/mgmeyers/obsidian-kanban/blob/44118e25661bff9ebfe54f71ae33805dc88ffa53/src/main.ts#L267 this.registerMonkeyPatches(); + new Notice("Excalidraw was updated. Files opened with this version will not open with the older version. Please update plugin on all your devices.\n\nI will remove this message with next update.",8000); if(this.settings.loadCount<1) this.migrationNotice(); const electron:string = process.versions.electron; if(electron.startsWith("8.")) { @@ -1137,7 +1138,7 @@ export default class ExcalidrawPlugin extends Plugin { } outString += te.text+' ^'+id+'\n\n'; } - return outString + this.getMarkdownDrawingSection(JSON.stringify(JSON_parse(data))); + return outString + this.getMarkdownDrawingSection(JSON.stringify(JSON_parse(data),null,"\t")); } public async createDrawing(filename: string, onNewPane: boolean, foldername?: string, initData?:string):Promise { diff --git a/versions.json b/versions.json index 58d72b8..695ac87 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.3.19": "0.11.13" + "1.3.20": "0.11.13" }