diff --git a/manifest-beta.json b/manifest-beta.json
index 1e0c7d83..c1ad0270 100644
--- a/manifest-beta.json
+++ b/manifest-beta.json
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
- "version": "2.15.3-beta-1",
+ "version": "2.15.3-beta-2",
"minAppVersion": "1.5.7",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
diff --git a/src/core/main.ts b/src/core/main.ts
index 6d9b9655..a90880d9 100644
--- a/src/core/main.ts
+++ b/src/core/main.ts
@@ -90,6 +90,7 @@ import { CommandManager } from "./managers/CommandManager";
import { EventManager } from "./managers/EventManager";
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
import en from "src/lang/locale/en";
+import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
declare const PLUGIN_VERSION:string;
declare const INITIAL_TIMESTAMP: number;
@@ -423,7 +424,21 @@ export default class ExcalidrawPlugin extends Plugin {
this.logStartupEvent("Switched to Excalidraw views");
try {
- if (this.settings.showReleaseNotes) {
+ let skipReleaseNotes = false;
+ if (this.settings.compareManifestToPluginVersion) {
+ if (this.manifest.version !== PLUGIN_VERSION) {
+ const versionMismatchPrompt = new VersionMismatchPrompt(this);
+ const result = await versionMismatchPrompt.start();
+ if(result) {
+ skipReleaseNotes = true;
+ this.manifest.version = PLUGIN_VERSION;
+ await this.app.setting.open();
+ this.app.setting.openTabById("community-plugins");
+ }
+ }
+ }
+
+ if (!skipReleaseNotes && 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") || !this.settings.previousRelease;
diff --git a/src/core/settings.ts b/src/core/settings.ts
index e7f1b75d..a757c731 100644
--- a/src/core/settings.ts
+++ b/src/core/settings.ts
@@ -181,6 +181,7 @@ export interface ExcalidrawSettings {
defaultTrayMode: boolean;
previousRelease: string;
showReleaseNotes: boolean;
+ compareManifestToPluginVersion: boolean;
showNewVersionNotification: boolean;
//mathjaxSourceURL: string;
latexBoilerplate: string;
@@ -294,7 +295,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
allowPinchZoom: false,
allowWheelZoom: false,
zoomToFitOnOpen: true,
- zoomToFitOnResize: true,
+ zoomToFitOnResize: false,
zoomToFitMaxLevel: 2,
zoomStep: 0.05,
zoomMin: 0.1,
@@ -365,6 +366,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
defaultTrayMode: true,
previousRelease: "0.0.0",
showReleaseNotes: true,
+ compareManifestToPluginVersion: true,
showNewVersionNotification: true,
//mathjaxSourceURL: "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js",
latexBoilerplate: "\\color{blue}",
@@ -726,6 +728,18 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
}),
);
+ new Setting(detailsEl)
+ .setName(t("WARN_ON_MANIFEST_MISMATCH_NAME"))
+ .setDesc(fragWithHTML(t("WARN_ON_MANIFEST_MISMATCH_DESC")))
+ .addToggle((toggle) =>
+ toggle
+ .setValue(this.plugin.settings.compareManifestToPluginVersion)
+ .onChange(async (value) => {
+ this.plugin.settings.compareManifestToPluginVersion = value;
+ this.applySettingsUpdate();
+ }),
+ );
+
new Setting(detailsEl)
.setName(t("NEWVERSION_NOTIFICATION_NAME"))
.setDesc(fragWithHTML(t("NEWVERSION_NOTIFICATION_DESC")))
diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts
index dc91808f..5743cbe3 100644
--- a/src/lang/locale/en.ts
+++ b/src/lang/locale/en.ts
@@ -234,6 +234,8 @@ export default {
RELEASE_NOTES_DESC:
"Toggle ON: Display release notes each time you update Excalidraw to a newer version.
" +
"Toggle OFF: Silent mode. You can still read release notes on GitHub.",
+ WARN_ON_MANIFEST_MISMATCH_NAME: "Warn about incomplete plugin updates",
+ WARN_ON_MANIFEST_MISMATCH_DESC: "Checks that the installed Excalidraw executable matches the version shown in Obsidian's plugin list. If they don't match (often after partial sync), you'll see a warning and can update. Disable to stop checking.",
NEWVERSION_NOTIFICATION_NAME: "Plugin update notification",
NEWVERSION_NOTIFICATION_DESC:
"Toggle ON: Show a notification when a new version of the plugin is available.
" +
@@ -1210,4 +1212,17 @@ export default {
//EmbeddableActionsMenu.tsx
BOOKMARK_PAGE: "Save current position in document",
CAPTURE_PAGE: "Capture current page as image",
+
+ //VersionMismatch.ts
+ //WARNING: Do not change the {VAL_RECORDED} and {VAL_ACTUAL} strings, they are replaced by the actual version values at runtime!
+ VERSION_MISMATCH_NOTICE: `The version recorded by Obsidian is {VAL_RECORDED}, but the installed Excalidraw code is {VAL_ACTUAL}.`,
+
+ VERSION_MISMATCH_HEADING: "Excalidraw version mismatch",
+ VERSION_MISMATCH_CAUSE: "This usually happens after a partial sync (e.g. Obsidian Sync Standard) where large files (main.js > 5MB) did not sync, so only manifest.json updated.",
+ VERSION_MISMATCH_OPTIONS: "Options:
1. Re-download the plugin (recommended).
2. Ignore for now.",
+ VERSION_MISMATCH_NOTE: "Note: Updating version info manually may affect tools that read manifest.json directly (e.g. Plugin Update Tracker, BRAT) until a full reinstall.",
+ VERSION_MISMATCH_DISABLE_NAME: "Disable future mismatch warnings",
+ VERSION_MISMATCH_DISABLE_DESC: "You can re-enable this under: Settings → Excalidraw → Basic → Warn about incomplete plugin updates.",
+ VERSION_MISMATCH_REDOWNLOAD: "Re-download plugin",
+ VERSION_MISMATCH_IGNORE: "Ignore",
};
diff --git a/src/shared/Dialogs/Messages.ts b/src/shared/Dialogs/Messages.ts
index a8fd50d8..c44406fb 100644
--- a/src/shared/Dialogs/Messages.ts
+++ b/src/shared/Dialogs/Messages.ts
@@ -19,7 +19,11 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
`,
"2.15.3":`
## Fixed
-- When adding a back-of-the-note card using the context menu, the card got placed at the absolute 0,0 position in the scene instead of the current pointer position. [#9949](https://github.com/excalidraw/excalidraw/issues/9949)
+- New back of the note cards are not visible until the drawing is saved. When adding a back-of-the-note card using the context menu, the card got placed at the absolute 0,0 position in the scene instead of the current pointer position. [#9949](https://github.com/excalidraw/excalidraw/issues/9949)
+- Drawings created 4 years ago don't open [#2479](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2479)
+
+## New
+- Added startup check that detects when Obsidian's recorded plugin version differs from the installed Excalidraw code (e.g. after partial sync of large files) and offers to update or ignore, with a setting to disable the check.
`,
"2.15.2":`
## Fixed:
diff --git a/src/shared/Dialogs/SelectCard.ts b/src/shared/Dialogs/SelectCard.ts
index 950b2389..a7628701 100644
--- a/src/shared/Dialogs/SelectCard.ts
+++ b/src/shared/Dialogs/SelectCard.ts
@@ -34,7 +34,7 @@ export class SelectCard extends FuzzySuggestModal {
this.close();
return;
}
- addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center);
+ addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center, {x: this.x, y: this.y});
this.close();
}
}
diff --git a/src/shared/Dialogs/VersionMismatch.ts b/src/shared/Dialogs/VersionMismatch.ts
new file mode 100644
index 00000000..dc8aab71
--- /dev/null
+++ b/src/shared/Dialogs/VersionMismatch.ts
@@ -0,0 +1,102 @@
+import { Modal, Setting } from "obsidian";
+import ExcalidrawPlugin from "src/core/main";
+import { t } from "src/lang/helpers";
+
+declare const PLUGIN_VERSION: string;
+
+/**
+ * A modal dialog that informs the user about a version mismatch between the version recorded by Obsidian and the actual version of the plugin executable.
+ * Explain that this can be the result of a partial sync, such as an Obsidian Sync Standard plan, which does not syncronize files larger than 5MB, and the plugin executable is larger.
+ * Explain that changing the plugin version information in Obsidian can lead to unexpected behavior in plugins suchs as the Plugin Update Tracker plugin or the BRAT plugin.
+ * The user has a toggle button to disable this check in the future. There is additional information that this can be reenabled in plugin settings.
+ * The user can click update obsidian version info to match the plugin version, and open Obsidian settings to redownload the plugin.
+ * The user can click ignore to dismiss the dialog.
+ */
+export class VersionMismatchPrompt extends Modal {
+ private resolvePromise: (value: any) => void;
+ public promise: Promise;
+ private resolved: boolean;
+ private isDirty: boolean = false;
+
+ public constructor(
+ private plugin: ExcalidrawPlugin,
+ ) {
+ super(plugin.app);
+ }
+
+ async start(): Promise {
+ this.promise = new Promise((resolve) => {
+ this.resolvePromise = resolve;
+ });
+ await this.plugin.loadSettings();
+ this.buildUI();
+ this.open();
+ return this.promise;
+ }
+
+ private buildUI() {
+ const { contentEl } = this;
+ contentEl.empty();
+ const recorded = this.plugin.manifest.version;
+ const actual = PLUGIN_VERSION;
+
+ contentEl.createEl("h2", { text: t("VERSION_MISMATCH_HEADING") });
+ const p1 = contentEl.createEl("p");
+ p1.innerHTML = t("VERSION_MISMATCH_NOTICE")
+ .replace("{VAL_RECORDED}", recorded)
+ .replace("{VAL_ACTUAL}", actual);
+
+ const p2 = contentEl.createEl("p");
+ p2.innerHTML = t("VERSION_MISMATCH_CAUSE");
+
+ const p3 = contentEl.createEl("p");
+ p3.innerHTML = t("VERSION_MISMATCH_OPTIONS");
+
+ const p4 = contentEl.createEl("p");
+ p4.innerHTML = t("VERSION_MISMATCH_NOTE");
+
+ new Setting(contentEl)
+ .setName(t("VERSION_MISMATCH_DISABLE_NAME"))
+ .setDesc(t("VERSION_MISMATCH_DISABLE_DESC"))
+ .addToggle(tg =>
+ tg.setValue(!this.plugin.settings.compareManifestToPluginVersion ? true : false)
+ .onChange(async (value) => {
+ this.plugin.settings.compareManifestToPluginVersion = !value; // invert because label is Disable ...
+ this.isDirty = true;
+ }),
+ );
+
+ // Buttons row
+ const buttonBar = contentEl.createDiv({ cls: "ex-version-mismatch-buttons" });
+
+ const redownloadBtn = buttonBar.createEl("button", { text: t("VERSION_MISMATCH_REDOWNLOAD") });
+ redownloadBtn.addEventListener("click", () => {
+ this.resolved = true; // triggers opening settings in caller
+ this.close();
+ });
+
+ const ignoreBtn = buttonBar.createEl("button", { text: t("VERSION_MISMATCH_IGNORE") });
+ ignoreBtn.addEventListener("click", () => {
+ this.resolved = false;
+ this.close();
+ });
+
+ buttonBar.style.display = "flex";
+ buttonBar.style.gap = "0.5rem";
+ buttonBar.style.marginTop = "1rem";
+ redownloadBtn.style.backgroundColor = "var(--interactive-accent)";
+ redownloadBtn.style.color = "var(--text-on-accent)";
+ }
+
+ async onClose() {
+ super.onClose();
+ if(this.isDirty) {
+ await this.plugin.saveSettings();
+ }
+ if (!this.resolved) {
+ this.resolvePromise && this.resolvePromise(false);
+ } else {
+ this.resolvePromise && this.resolvePromise(true);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/shared/ExcalidrawData.ts b/src/shared/ExcalidrawData.ts
index 218c69d8..8089e93a 100644
--- a/src/shared/ExcalidrawData.ts
+++ b/src/shared/ExcalidrawData.ts
@@ -581,6 +581,10 @@ export class ExcalidrawData {
el.containerId = null;
}
+ if (el.type === "text" && !el.originalText) {
+ el.originalText = el.rawText ?? el.text ?? "";
+ }
+
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/494
if (el.x === null) {
el.x = 0;
@@ -760,6 +764,27 @@ export class ExcalidrawData {
this.deletedElements = this.scene.elements.filter((el:ExcalidrawElement)=>el.isDeleted);
this.scene.elements = this.scene.elements.filter((el:ExcalidrawElement)=>!el.isDeleted);
+
+ //once off migration of legacy scenes
+ if(this.scene?.elements?.some((el:any)=>el.type==="iframe" && !el.customData)) {
+ const prompt = new MultiOptionConfirmationPrompt(
+ this.plugin,
+ "This file contains embedded frames " +
+ "which will be migrated to a newer version for compatibility with " +
+ "excalidraw.com.
🔄 If you're using Obsidian on " +
+ "multiple devices, you may proceed now, but please, before opening this " +
+ "file on your other devices, update Excalidraw on those as well.
🔍 More info is available "+
+ "here.
🌐 " +
+ "" +
+ "Translate.",
+ );
+ prompt.contentEl.focus();
+ const confirmation = await prompt.waitForClose
+ if(!confirmation) {
+ throw new Error(ERROR_IFRAME_CONVERSION_CANCELED);
+ }
+ }
+ this.initializeNonInitializedFields();
const timer = window.setTimeout(()=>{
const notice = new Notice(t("FONT_LOAD_SLOW"),15000);
@@ -802,27 +827,6 @@ export class ExcalidrawData {
delete this.scene.appState.gridColor.MajorGridFrequency;
}
- //once off migration of legacy scenes
- if(this.scene?.elements?.some((el:any)=>el.type==="iframe" && !el.customData)) {
- const prompt = new MultiOptionConfirmationPrompt(
- this.plugin,
- "This file contains embedded frames " +
- "which will be migrated to a newer version for compatibility with " +
- "excalidraw.com.
🔄 If you're using Obsidian on " +
- "multiple devices, you may proceed now, but please, before opening this " +
- "file on your other devices, update Excalidraw on those as well.
🔍 More info is available "+
- "here.
🌐 " +
- "" +
- "Translate.",
- );
- prompt.contentEl.focus();
- const confirmation = await prompt.waitForClose
- if(!confirmation) {
- throw new Error(ERROR_IFRAME_CONVERSION_CANCELED);
- }
- }
- this.initializeNonInitializedFields();
-
data = data.substring(0, sceneJSONandPOS.pos);
//The Markdown # Text Elements take priority over the JSON text elements. Assuming the scenario in which the
diff --git a/src/types/types.d.ts b/src/types/types.d.ts
index c5195956..045a9d1a 100644
--- a/src/types/types.d.ts
+++ b/src/types/types.d.ts
@@ -58,6 +58,7 @@ declare global {
declare module "obsidian" {
interface App {
internalPlugins: any;
+ setting: any;
isMobile(): boolean;
getObsidianUrl(file:TFile): string;
metadataTypeManager: {
diff --git a/src/utils/excalidrawViewUtils.ts b/src/utils/excalidrawViewUtils.ts
index 50101f59..7b33f6b6 100644
--- a/src/utils/excalidrawViewUtils.ts
+++ b/src/utils/excalidrawViewUtils.ts
@@ -234,6 +234,7 @@ export async function addBackOfTheNoteCard(
cardBody?: string,
embeddableCustomData?: EmbeddableMDCustomProps,
center: boolean = false,
+ position?: {x: number, y: number},
):Promise {
const data = view.data;
const header = getExcalidrawMarkdownHeaderSection(data);
@@ -263,7 +264,7 @@ export async function addBackOfTheNoteCard(
}
const ea = getEA(view) as ExcalidrawAutomate;
- let x,y = 0;
+ let {x,y} = position ?? ea.targetView.currentPosition;
if(center) {
const centerPos = ea.getViewCenterPosition();
if(centerPos) {
@@ -287,7 +288,7 @@ export async function addBackOfTheNoteCard(
window.setTimeout(()=>{
api.updateScene({appState: {activeEmbeddable: {element: el, state: "active"}}, captureUpdate: CaptureUpdateAction.NEVER,});
if(found) view.getEmbeddableLeafElementById(el.id)?.editNode?.();
- });
+ },200);
}
ea.destroy();
return el.id;