diff --git a/manifest-beta.json b/manifest-beta.json index 0dc749c..7c0e8f1 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.6.3", + "version": "2.6.4", "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 1c6dc71..0e490b7 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.6.3", + "version": "2.6.4", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index 5ac0176..d588b2b 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -2854,10 +2854,9 @@ export class ExcalidrawAutomate { } }; -export async function initExcalidrawAutomate( +export function initExcalidrawAutomate( plugin: ExcalidrawPlugin, -): Promise { - await initFonts(); +): ExcalidrawAutomate { const ea = new ExcalidrawAutomate(plugin); //@ts-ignore window.ExcalidrawAutomate = ea; @@ -2892,14 +2891,6 @@ function getFontFamily(id: number):string { return getFontFamilyString({fontFamily:id}) } -export async function initFonts():Promise { - /*await excalidrawLib.registerFontsInCSS(); - const fonts = excalidrawLib.getFontFamilies(); - for(let i=0;iel.type === "image" && el.crop && !el.isDeleted) .forEach((el: Mutable)=>{ const ef = this.getFile(el.fileId); + if(!ef.file) return; if(ef.file.extension !== "pdf") return; const pageRef = ef.linkParts.original.split("#")?.[1]; if(!pageRef || !pageRef.startsWith("page=") || pageRef.includes("rect")) return; diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index a2b07db..a05e9ed 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,10 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
Buy Me a Coffee at ko-fi.com
`, +"2.6.4":` +## Fixed +- Error saving when cropping images embedded from a URL (not from a file in the Vault) [#2096](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2096) +`, "2.6.3":`
diff --git a/src/main.ts b/src/main.ts index fa4c329..642cc17 100644 --- a/src/main.ts +++ b/src/main.ts @@ -365,53 +365,132 @@ export default class ExcalidrawPlugin extends Plugin { //Compatibility mode with .excalidraw files this.registerExtensions(["excalidraw"], VIEW_TYPE_EXCALIDRAW); - await this.loadSettings({reEnableAutosave:true}); - const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset; - if(!this.settings.onceOffCompressFlagReset) { - this.settings.compress = true; - this.settings.onceOffCompressFlagReset = true; - } - if(!this.settings.onceOffGPTVersionReset) { - if(this.settings.openAIDefaultVisionModel === "gpt-4-vision-preview") { - this.settings.openAIDefaultVisionModel = "gpt-4o"; + try { + await this.loadSettings({reEnableAutosave:true}); + const updateSettings = !this.settings.onceOffCompressFlagReset || !this.settings.onceOffGPTVersionReset; + if(!this.settings.onceOffCompressFlagReset) { + this.settings.compress = true; + this.settings.onceOffCompressFlagReset = true; } + if(!this.settings.onceOffGPTVersionReset) { + if(this.settings.openAIDefaultVisionModel === "gpt-4-vision-preview") { + this.settings.openAIDefaultVisionModel = "gpt-4o"; + } + } + if(updateSettings) { + await this.saveSettings(); + } + this.addSettingTab(new ExcalidrawSettingTab(this.app, this)); + } catch (e) { + new Notice("Error loading plugin settings", 6000); + console.error("Error loading plugin settings", e); + } + + try { + // need it her for ExcaliBrain + this.ea = initExcalidrawAutomate(this); + } catch (e) { + new Notice("Error initializing Excalidraw Automate", 6000); + console.error("Error initializing Excalidraw Automate", e); + } + + try { + //Licat: Are you registering your post processors in onLayoutReady? You should register them in onload instead + this.addMarkdownPostProcessor(); + } catch (e) { + new Notice("Error adding markdown post processor", 6000); + console.error("Error adding markdown post processor", e); } - if(updateSettings) { - await this.saveSettings(); - } - this.addSettingTab(new ExcalidrawSettingTab(this.app, this)); - this.ea = await initExcalidrawAutomate(this); - //Licat: Are you registering your post processors in onLayoutReady? You should register them in onload instead - this.addMarkdownPostProcessor(); - this.app.workspace.onLayoutReady(async () => { - unpackExcalidraw(); - excalidrawLib = window.eval.call(window,`(function() {${EXCALIDRAW_PACKAGE};return ExcalidrawLib;})()`); - this.packageMap.set(window,{react, reactDOM, excalidrawLib}); - updateExcalidrawLib(); - initCompressionWorker(); + try { + unpackExcalidraw(); + excalidrawLib = window.eval.call(window,`(function() {${EXCALIDRAW_PACKAGE};return ExcalidrawLib;})()`); + this.packageMap.set(window,{react, reactDOM, excalidrawLib}); + updateExcalidrawLib(); + } catch (e) { + new Notice("Error loading the Excalidraw package", 6000); + console.error("Error loading the Excalidraw package", e); + } + + try { + initCompressionWorker(); + } catch (e) { + new Notice("Error initializing compression worker", 6000); + console.error("Error initializing compression worker", e); + } + this.loadTimestamp = Date.now(); addIcon(ICON_NAME, EXCALIDRAW_ICON); addIcon(SCRIPTENGINE_ICON_NAME, SCRIPTENGINE_ICON); addIcon(EXPORT_IMG_ICON_NAME, EXPORT_IMG_ICON); - this.excalidrawConfig = new ExcalidrawConfig(this); - await loadMermaid(); - this.addThemeObserver(); + try { + this.excalidrawConfig = new ExcalidrawConfig(this); + } catch (e) { + new Notice("Error initializing Excalidraw config", 6000); + console.error("Error initializing Excalidraw config", e); + } - //inspiration taken from kanban: - //https://github.com/mgmeyers/obsidian-kanban/blob/44118e25661bff9ebfe54f71ae33805dc88ffa53/src/main.ts#L267 - this.registerMonkeyPatches(); + try { + await loadMermaid(); + } catch (e) { + new Notice("Error loading Mermaid", 6000); + console.error("Error loading Mermaid", e); + } - this.stylesManager = new StylesManager(this); - this.scriptEngine = new ScriptEngine(this); - await this.initializeFonts(); - imageCache.initializeDB(this); + try { + this.addThemeObserver(); + } catch (e) { + new Notice("Error adding theme observer", 6000); + console.error("Error adding theme observer", e); + } - this.isReady = true; - switchToExcalidraw(this.app); - this.switchToExcalidarwAfterLoad(); + try { + //inspiration taken from kanban: + //https://github.com/mgmeyers/obsidian-kanban/blob/44118e25661bff9ebfe54f71ae33805dc88ffa53/src/main.ts#L267 + this.registerMonkeyPatches(); + } catch (e) { + new Notice("Error registering monkey patches", 6000); + console.error("Error registering monkey patches", e); + } + + try { + this.stylesManager = new StylesManager(this); + } catch (e) { + new Notice("Error initializing styles manager", 6000); + console.error("Error initializing styles manager", e); + } + + try { + this.scriptEngine = new ScriptEngine(this); + } catch (e) { + new Notice("Error initializing script engine", 6000); + console.error("Error initializing script engine", e); + } + + try { + await this.initializeFonts(); + } catch (e) { + new Notice("Error initializing fonts", 6000); + console.error("Error initializing fonts", e); + } + + try { + imageCache.initializeDB(this); + } catch (e) { + new Notice("Error initializing image cache", 6000); + console.error("Error initializing image cache", e); + } + + try { + this.isReady = true; + switchToExcalidraw(this.app); + this.switchToExcalidarwAfterLoad(); + } catch (e) { + new Notice("Error switching views to Excalidraw", 6000); + console.error("Error switching views to Excalidraw", e); + } try { if (this.settings.showReleaseNotes) { @@ -431,20 +510,23 @@ export default class ExcalidrawPlugin extends Plugin { console.error("Error opening release notes", e); } + //--------------------------------------------------------------------- //initialization that can happen after Excalidraw views are initialized - + //--------------------------------------------------------------------- try { this.registerEventListeners(); } catch (e) { new Notice("Error registering event listeners", 6000); console.error("Error registering event listeners", e); } + try { this.runStartupScript(); } catch (e) { new Notice("Error running startup script", 6000); console.error("Error running startup script", e); } + try { this.editorHandler = new EditorHandler(this); this.editorHandler.setup(); @@ -452,6 +534,7 @@ export default class ExcalidrawPlugin extends Plugin { new Notice("Error setting up editor handler", 6000); console.error("Error setting up editor handler", e); } + try { this.registerInstallCodeblockProcessor(); } catch (e) { @@ -465,24 +548,28 @@ export default class ExcalidrawPlugin extends Plugin { new Notice("Error setting up experimental file type display", 6000); console.error("Error setting up experimental file type display", e); } + try { this.registerCommands(); } catch (e) { new Notice("Error registering commands", 6000); console.error("Error registering commands", e); } + try { this.registerEditorSuggest(new FieldSuggester(this)); } catch (e) { new Notice("Error registering editor suggester", 6000); console.error("Error registering editor suggester", e); } + try { this.setPropertyTypes(); } catch (e) { new Notice("Error setting up property types", 6000); console.error("Error setting up property types", e); } + try { this.taskbone = new Taskbone(this); } catch (e) {