From cc9d7828c7ee7755c1ef942519c43df32eae249f Mon Sep 17 00:00:00 2001 From: Zsolt Viczian Date: Wed, 3 Aug 2022 22:09:45 +0200 Subject: [PATCH] 1.7.10 --- manifest.json | 2 +- package.json | 2 +- src/ExcalidrawAutomate.ts | 3 ++- src/ExcalidrawView.ts | 23 ++++------------------- src/dialogs/Messages.ts | 11 +++++++++++ src/dialogs/ReleaseNotes.ts | 6 +++--- src/main.ts | 5 +++-- src/utils/Utils.ts | 17 ++++++++++++++++- versions.json | 2 +- yarn.lock | 8 ++++---- 10 files changed, 46 insertions(+), 33 deletions(-) diff --git a/manifest.json b/manifest.json index 0b1f16f..bf1c53c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.7.9", + "version": "1.7.10", "minAppVersion": "0.15.7", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/package.json b/package.json index a72572c..fd87f83 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "license": "MIT", "dependencies": { "@types/lz-string": "^1.3.34", - "@zsviczian/excalidraw": "0.12.0-obsidian-0", + "@zsviczian/excalidraw": "0.12.0-obsidian-3", "clsx": "^1.1.1", "lz-string": "^1.4.4", "monkey-around": "^2.3.0", diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index acc93d6..a89499e 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -27,6 +27,7 @@ import { errorlog, getPNG, getSVG, + isVersionNewerThanOther, scaleLoadedImage, wrapText, } from "./utils/Utils"; @@ -1620,7 +1621,7 @@ export class ExcalidrawAutomate implements ExcalidrawAutomateInterface { * @returns */ verifyMinimumPluginVersion(requiredVersion: string): boolean { - return PLUGIN_VERSION >= requiredVersion; + return PLUGIN_VERSION === requiredVersion || isVersionNewerThanOther(PLUGIN_VERSION,requiredVersion); }; /** diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index ea8b814..d2cdc0e 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -1942,24 +1942,6 @@ export default class ExcalidrawView extends TextFileView { excalidrawRef.current.readyPromise.then( (api: ExcalidrawImperativeAPI) => { this.excalidrawAPI = api; - // UpdateScene was added as a workaround here. In theory this is not required... however there was an odd error - // that I wasn't able to track down to its source - // https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/715 - // For some reason, if the drawing includes files (image attachments), then on Obsidian Mobile switching to markdown - // view and back resulted in Excalidraw loading an empty file even though initialData contained the required info - // this did not happen on a desktop - // In theory this updateScene here is harmless, since it simply reloads the drawing that is already loaded with - // initial data. - this.updateScene( - { - elements: initdata.elements, - appState: initdata.appState, - files: initdata.files, - commitToHistory: false - }, - true, - ) - // api.setLocalFont(this.plugin.settings.experimentalEnableFourthFont); this.loadSceneFiles(); this.updateContainerSize(null, true); @@ -2628,6 +2610,7 @@ export default class ExcalidrawView extends TextFileView { saveToActiveFile: false, }, }, + initState: initdata?.appState, initialData: initdata, detectScroll: true, onPointerUpdate: (p: any) => { @@ -3201,7 +3184,9 @@ export default class ExcalidrawView extends TextFileView { return React.createElement(React.Fragment, null, excalidrawDiv); }); - ReactDOM.render(reactElement, this.contentEl, () => {}); + const root = ReactDOM.createRoot(this.contentEl); + root.render(reactElement); + //ReactDOM.render(reactElement, this.contentEl, () => {}); } private updateContainerSize(containerId?: string, delay: boolean = false) { diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index c16d1ff..a6d709a 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,17 @@ I develop this plugin as a hobby, spending most of my free time doing this. If y
`, +"1.7.10": ` +# New from Excalidraw.com +- Improved handling of arrows and lines. ([#5501](https://github.com/excalidraw/excalidraw/pull/5501)) + +# Fixed +- When opening a document in view-mode or zen-mode the panel buttons no longer flash up for a moment before switching to the desired mode. ([#479](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/479)) +- The "blinding white screen" no longer flashes up while loading the scene if the scene is dark ([#241](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/241)) + +# Under the hood +- Finalized migration to React 18 (no longer showing an error about React 17 compatibility mode in console log) +`, "1.7.9": ` # New features and fixes from Excalidraw.com: - The right-click context menu is now scrollable on smaller screens ([#4030](https://github.com/excalidraw/excalidraw/pull/4030), [#5520](https://github.com/excalidraw/excalidraw/pull/5520)) diff --git a/src/dialogs/ReleaseNotes.ts b/src/dialogs/ReleaseNotes.ts index 215f3db..187c520 100644 --- a/src/dialogs/ReleaseNotes.ts +++ b/src/dialogs/ReleaseNotes.ts @@ -1,4 +1,5 @@ import { App, MarkdownRenderer, Modal } from "obsidian"; +import { isVersionNewerThanOther } from "src/utils/Utils"; import ExcalidrawPlugin from "../main"; import { FIRST_RUN, RELEASE_NOTES } from "./Messages"; @@ -11,7 +12,6 @@ export class ReleaseNotes extends Modal { constructor(app: App, plugin: ExcalidrawPlugin, version: string) { super(app); this.plugin = plugin; - //@ts-ignore this.version = version; } @@ -31,10 +31,10 @@ export class ReleaseNotes extends Modal { async createForm() { let prevRelease = this.plugin.settings.previousRelease; - prevRelease = this.version === prevRelease ? "0" : prevRelease; + prevRelease = this.version === prevRelease ? "0.0.0" : prevRelease; const message = this.version ? Object.keys(RELEASE_NOTES) - .filter((key) => key > prevRelease) + .filter((key) => key === "Intro" || isVersionNewerThanOther(key,prevRelease)) .map((key: string) => `# ${key}\n${RELEASE_NOTES[key]}`) .slice(0, 10) .join("\n\n---\n") diff --git a/src/main.ts b/src/main.ts index 6d4fb99..dd5e13b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -83,6 +83,7 @@ import { setLeftHandedMode, sleep, debug, + isVersionNewerThanOther, } from "./utils/Utils"; import { getAttachmentsFolderAndFilePath, getNewOrAdjacentLeaf, getParentOfClass, isObsidianThemeDark } from "./utils/ObsidianUtils"; //import { OneOffs } from "./OneOffs"; @@ -226,8 +227,8 @@ export default class ExcalidrawPlugin extends Plugin { 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.imageElementNotice; - - if (PLUGIN_VERSION > this.settings.previousRelease) { + + if (isVersionNewerThanOther(PLUGIN_VERSION, this.settings.previousRelease)) { new ReleaseNotes( this.app, this, diff --git a/src/utils/Utils.ts b/src/utils/Utils.ts index 9cef3d3..8e6c1cc 100644 --- a/src/utils/Utils.ts +++ b/src/utils/Utils.ts @@ -69,7 +69,7 @@ export const checkExcalidrawVersion = async (app: App) => { .filter((el: any) => el.version.match(/^\d+\.\d+\.\d+$/)) .sort((el1: any, el2: any) => el2.published - el1.published)[0].version; - if (latestVersion > PLUGIN_VERSION) { + 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}`, ); @@ -551,6 +551,21 @@ export const getPNGScale = (plugin: ExcalidrawPlugin, file: TFile): number => { return plugin.settings.pngExportScale; }; +export const isVersionNewerThanOther = (version: string, otherVersion: string): boolean => { + const v = version.match(/(\d*)\.(\d*)\.(\d*)/); + const o = otherVersion.match(/(\d*)\.(\d*)\.(\d*)/); + + return Boolean(v && v.length === 4 && o && o.length === 4 && + !(isNaN(parseInt(v[1])) || isNaN(parseInt(v[2])) || isNaN(parseInt(v[3]))) && + !(isNaN(parseInt(o[1])) || isNaN(parseInt(o[2])) || isNaN(parseInt(o[3]))) && + ( + parseInt(v[1])>parseInt(o[1]) || + (parseInt(v[1]) >= parseInt(o[1]) && parseInt(v[2]) > parseInt(o[2])) || + (parseInt(v[1]) >= parseInt(o[1]) && parseInt(v[2]) >= parseInt(o[2]) && parseInt(v[3]) > parseInt(o[3])) + ) + ) +} + export const errorlog = (data: {}) => { console.error({ plugin: "Excalidraw", ...data }); }; diff --git a/versions.json b/versions.json index 9875165..6a2800b 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "1.7.9": "0.15.7", + "1.7.10": "0.15.7", "1.7.8": "0.15.5", "1.7.7": "0.15.4", "1.7.6": "0.15.3", diff --git a/yarn.lock b/yarn.lock index 0d300cb..d437d14 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2216,10 +2216,10 @@ dependencies: "@zerollup/ts-helpers" "^1.7.18" -"@zsviczian/excalidraw@0.12.0-obsidian-0": - "integrity" "sha512-YPHQqLf2FCwQJvaatx4qE5ACFKHQEUlvIYZrOC5pmmz0govEm9oPtPgfz9PY6oPWRRDwLAngFLgO6/kRw9fODw==" - "resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.12.0-obsidian-0.tgz" - "version" "0.12.0-obsidian-0" +"@zsviczian/excalidraw@0.12.0-obsidian-3": + "integrity" "sha512-9rTc6BXIc3K6eWCtMNSXLoeDrVAvMkEbTuqL0NhZbbmV7y/FTWIgMvb1RR3v4nTHwGlXba7rP6khR5m/WJMS6w==" + "resolved" "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.12.0-obsidian-3.tgz" + "version" "0.12.0-obsidian-3" "abab@^2.0.3", "abab@^2.0.5": "integrity" "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q=="