diff --git a/manifest-beta.json b/manifest-beta.json index 92fcf10..b94e61e 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.6.3-beta-5", + "version": "2.6.3-beta-6", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index b0ebeea..611f41a 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -6,6 +6,8 @@ import { TAG_AUTOEXPORT, TAG_MDREADINGMODE, TAG_PDFEXPORT } from "src/constants/ import { labelALT, labelCTRL, labelMETA, labelSHIFT } from "src/utils/ModifierkeyHelper"; const CJK_FONTS = "CJK Fonts"; +declare const PLUGIN_VERSION:string; + // English export default { // main.ts @@ -959,4 +961,7 @@ FILENAME_HEAD: "Filename", IPM_GROUP_PAGES_DESC: "This will group all pages into a single group. This is recommended if you are locking the pages after import, because the group will be easier to unlock later rather than unlocking one by one.", IPM_SELECT_PDF: "Please select a PDF file", + //Utils.ts + UPDATE_AVAILABLE: `A newer version of Excalidraw is available in Community Plugins.\n\nYou are using ${PLUGIN_VERSION}.\nThe latest is`, + ERROR_PNG_TOO_LARGE: "Error exporting PNG - PNG too large, try a smaller resolution", }; diff --git a/src/main.ts b/src/main.ts index 398ef4f..fa4c329 100644 --- a/src/main.ts +++ b/src/main.ts @@ -416,9 +416,9 @@ export default class ExcalidrawPlugin extends Plugin { try { if (this.settings.showReleaseNotes) { //I am repurposing imageElementNotice, if the value is true, this means the plugin was just newly installed to Obsidian. - const obsidianJustInstalled = this.settings.previousRelease === "0.0.0" + const obsidianJustInstalled = (this.settings.previousRelease === "0.0.0") || !this.settings.previousRelease; - if (isVersionNewerThanOther(PLUGIN_VERSION, this.settings.previousRelease)) { + if (isVersionNewerThanOther(PLUGIN_VERSION, this.settings.previousRelease ?? "0.0.0")) { new ReleaseNotes( this.app, this, @@ -428,7 +428,7 @@ export default class ExcalidrawPlugin extends Plugin { } } catch (e) { new Notice("Error opening release notes", 6000); - console.log("Error opening release notes", e); + console.error("Error opening release notes", e); } //initialization that can happen after Excalidraw views are initialized @@ -437,57 +437,57 @@ export default class ExcalidrawPlugin extends Plugin { this.registerEventListeners(); } catch (e) { new Notice("Error registering event listeners", 6000); - console.log("Error registering event listeners", e); + console.error("Error registering event listeners", e); } try { this.runStartupScript(); } catch (e) { new Notice("Error running startup script", 6000); - console.log("Error running startup script", e); + console.error("Error running startup script", e); } try { this.editorHandler = new EditorHandler(this); this.editorHandler.setup(); } catch (e) { new Notice("Error setting up editor handler", 6000); - console.log("Error setting up editor handler", e); + console.error("Error setting up editor handler", e); } try { this.registerInstallCodeblockProcessor(); } catch (e) { new Notice("Error registering script install-codeblock processor", 6000); - console.log("Error registering script install-codeblock processor", e); + console.error("Error registering script install-codeblock processor", e); } try { this.experimentalFileTypeDisplayToggle(this.settings.experimentalFileType); } catch (e) { new Notice("Error setting up experimental file type display", 6000); - console.log("Error setting up experimental file type display", e); + console.error("Error setting up experimental file type display", e); } try { this.registerCommands(); } catch (e) { new Notice("Error registering commands", 6000); - console.log("Error registering commands", e); + console.error("Error registering commands", e); } try { this.registerEditorSuggest(new FieldSuggester(this)); } catch (e) { new Notice("Error registering editor suggester", 6000); - console.log("Error registering editor suggester", e); + console.error("Error registering editor suggester", e); } try { this.setPropertyTypes(); } catch (e) { new Notice("Error setting up property types", 6000); - console.log("Error setting up property types", e); + console.error("Error setting up property types", e); } try { this.taskbone = new Taskbone(this); } catch (e) { new Notice("Error setting up taskbone", 6000); - console.log("Error setting up taskbone", e); + console.error("Error setting up taskbone", e); } }); } diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 3991fc7..7f50dbb 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -31,6 +31,7 @@ import opentype from 'opentype.js'; import { runCompressionWorker } from "src/workers/compression-worker"; import Pool from "es6-promise-pool"; import { FileData } from "src/EmbeddedFileLoader"; +import { t } from "src/lang/helpers"; declare const PLUGIN_VERSION:string; declare var LZString: any; @@ -77,7 +78,7 @@ export async function checkExcalidrawVersion() { if (isVersionNewerThanOther(latestVersion,PLUGIN_VERSION)) { new Notice( - `A newer version of Excalidraw is available in Community Plugins.\n\nYou are using ${PLUGIN_VERSION}.\nThe latest is ${latestVersion}`, + t("UPDATE_AVAILABLE") + ` ${latestVersion}`, ); } } catch (e) { @@ -220,15 +221,6 @@ export async function getFontDataURL ( const split = dataURL.split(";base64,", 2); dataURL = `${split[0]};charset=utf-8;base64,${split[1]}`; fontDef = ` @font-face {font-family: "${fontName}";src: url("${dataURL}") format("${format}")}`; -/* const mimeType = f.extension.startsWith("woff") - ? "application/font-woff" - : "font/truetype"; - fontName = name ?? f.basename; - dataURL = await getDataURL(ab, mimeType); - fontDef = ` @font-face {font-family: "${fontName}";src: url("${dataURL}")}`; - //format("${f.extension === "ttf" ? "truetype" : f.extension}");}`; - const split = fontDef.split(";base64,", 2); - fontDef = `${split[0]};charset=utf-8;base64,${split[1]}`;*/ } return { fontDef, fontName, dataURL }; }; @@ -375,7 +367,7 @@ export async function getPNG ( }), }); } catch (error) { - new Notice("Error exporting PNG - PNG too large, try a smaller resolution"); + new Notice(t("ERROR_PNG_TOO_LARGE")); errorlog({ where: "Utils.getPNG", error }); return null; }