This commit is contained in:
Zsolt Viczian
2022-08-03 22:09:45 +02:00
parent b67d70c519
commit cc9d7828c7
10 changed files with 46 additions and 33 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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);
};
/**

View File

@@ -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) {

View File

@@ -17,6 +17,17 @@ I develop this plugin as a hobby, spending most of my free time doing this. If y
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
`,
"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))

View File

@@ -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")

View File

@@ -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,

View File

@@ -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 });
};

View File

@@ -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",

View File

@@ -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=="