mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5ff8caa04f |
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "1.6.31",
|
||||
"version": "1.6.32",
|
||||
"minAppVersion": "0.12.16",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -409,6 +409,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
}
|
||||
}
|
||||
|
||||
private preventReloadResetTimer: NodeJS.Timeout = null;
|
||||
async save(preventReload: boolean = true, forcesave: boolean = false) {
|
||||
//debug({where:"save", preventReload, forcesave, semaphores:this.semaphores});
|
||||
if (this.semaphores.saving) {
|
||||
@@ -450,10 +451,23 @@ export default class ExcalidrawView extends TextFileView {
|
||||
//reload() is triggered indirectly when saving by the modifyEventHandler in main.ts
|
||||
//prevent reload is set here to override reload when not wanted: typically when the user is editing
|
||||
//and we do not want to interrupt the flow by reloading the drawing into the canvas.
|
||||
if(this.preventReloadResetTimer) {
|
||||
clearTimeout(this.preventReloadResetTimer);
|
||||
this.preventReloadResetTimer = null;
|
||||
}
|
||||
|
||||
this.semaphores.preventReload = preventReload;
|
||||
await super.save();
|
||||
this.lastSaveTimestamp = this.file.stat.mtime;
|
||||
this.clearDirty();
|
||||
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/629
|
||||
//there were odd cases when preventReload semaphore did not get cleared and consequently a synchronized image
|
||||
//did not update the open drawing
|
||||
if(preventReload) {
|
||||
const self = this;
|
||||
this.preventReloadResetTimer = setTimeout(()=>self.semaphores.preventReload = false,2000);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.semaphores.autosaving) {
|
||||
@@ -754,7 +768,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
latex: formula,
|
||||
isLoaded: false,
|
||||
});
|
||||
await this.save(true);
|
||||
await this.save(false);
|
||||
await updateEquation(
|
||||
formula,
|
||||
selectedImage.fileId,
|
||||
@@ -766,7 +780,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
});
|
||||
return;
|
||||
}
|
||||
await this.save(true); //in case pasted images haven't been saved yet
|
||||
await this.save(false); //in case pasted images haven't been saved yet
|
||||
if (this.excalidrawData.hasFile(selectedImage.fileId)) {
|
||||
if (ev.altKey) {
|
||||
const ef = this.excalidrawData.getFile(selectedImage.fileId);
|
||||
@@ -786,7 +800,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
return;
|
||||
}
|
||||
ef.resetImage(this.file.path, link);
|
||||
await this.save(true);
|
||||
await this.save(false);
|
||||
await this.loadSceneFiles();
|
||||
this.setDirty();
|
||||
});
|
||||
@@ -1042,7 +1056,8 @@ export default class ExcalidrawView extends TextFileView {
|
||||
warningUnknowSeriousError();
|
||||
return;
|
||||
}
|
||||
const editing = api.getAppState().editingElement !== null;
|
||||
const st = api.getAppState();
|
||||
const editing = st.editingElement !== null;
|
||||
//this will reset positioning of the cursor in case due to the popup keyboard,
|
||||
//or the command palette, or some other unexpected reason the onResize would not fire...
|
||||
this.refresh();
|
||||
@@ -1052,7 +1067,8 @@ export default class ExcalidrawView extends TextFileView {
|
||||
this.semaphores.dirty == this.file?.path &&
|
||||
this.plugin.settings.autosave &&
|
||||
!this.semaphores.forceSaving &&
|
||||
!editing
|
||||
!editing &&
|
||||
st.draggingElement === null //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/630
|
||||
) {
|
||||
this.autosaveTimer = null;
|
||||
this.semaphores.autosaving = true;
|
||||
@@ -1450,8 +1466,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!sceneElement) {
|
||||
} else if(!sceneElement) {
|
||||
manageMapChanges(incomingElement);
|
||||
|
||||
if(idx === 0) {
|
||||
@@ -1463,6 +1478,14 @@ export default class ExcalidrawView extends TextFileView {
|
||||
sceneElements.splice(parentLayer+1,0,incomingElement);
|
||||
sceneElementIds.splice(parentLayer+1,0,incomingElement.id);
|
||||
}
|
||||
} else if(sceneElement && incomingElement.type === "image") { //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/632
|
||||
if(inData.getFile(incomingElement.fileId)) {
|
||||
this.excalidrawData.setFile(
|
||||
incomingElement.fileId,
|
||||
inData.getFile(incomingElement.fileId)
|
||||
);
|
||||
reloadFiles = true;
|
||||
}
|
||||
}
|
||||
})
|
||||
this.previousSceneVersion = getSceneVersion(sceneElements);
|
||||
|
||||
@@ -6,7 +6,6 @@ import { FileId } from "@zsviczian/excalidraw/types/element/types";
|
||||
import { errorlog, getImageSize, log, sleep, svgToBase64 } from "./utils/Utils";
|
||||
import { fileid } from "./Constants";
|
||||
import html2canvas from "html2canvas";
|
||||
import { count } from "console";
|
||||
import { Notice } from "obsidian";
|
||||
|
||||
declare let window: any;
|
||||
|
||||
@@ -17,6 +17,12 @@ 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.6.32": `
|
||||
## Fixed
|
||||
- Filenames of embedded images and markdown documents did not get updated if the drawing was open in a work-pane while you changed the filename of the embedded file (image or markdown document) [632](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/632).
|
||||
- When you created a new text element and immediately dragged it, sometimes autosave interrupted the drag action and Excalidraw dropped the element you were dragging [630](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/630)
|
||||
- In some edge cases when you had the drawing open on your desktop and you also opened the same image on your tablet, Sync seemed to work in the background but the changes did not appear on the desktop until you closed and opened the drawing again. [629](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/629)
|
||||
- LaTeX support: Excalidraw must download a javascript library from one of the hosting sites for MathJax tex2svg. It seems that some people do not have access to the URL recommended in the first place by [MathJax](https://docs.mathjax.org/en/latest/web/start.html). If LaTeX formulas do not render correctly in Excalidraw, try changing the source server under Compatibility Settings in Excalidraw Plugin Settings. [628](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/628)`,
|
||||
"1.6.31": `
|
||||
Minor update:
|
||||
|
||||
|
||||
@@ -346,6 +346,10 @@ export default {
|
||||
"By enabling this feature drawings you create with the ribbon icon, the command palette actions, " +
|
||||
"and the file explorer are going to be all legacy *.excalidraw files. This setting will also turn off the reminder message " +
|
||||
"when you open a legacy file for editing.",
|
||||
MATHJAX_NAME: "MathJax (LaTeX) javascript library host",
|
||||
MATHJAX_DESC: "If you are using LaTeX equiations in Excalidraw then the plugin needs to load a javascript library for that. " +
|
||||
"Some users are unable to access certain host servers. If you are experiencing issues try changing the host here. You may need to "+
|
||||
"restart Obsidian after closing settings, for this change to take effect.",
|
||||
EXPERIMENTAL_HEAD: "Experimental features",
|
||||
EXPERIMENTAL_DESC:
|
||||
"Some of these setting will not take effect immediately, only when the File Explorer is refreshed, or Obsidian restarted.",
|
||||
|
||||
10
src/main.ts
10
src/main.ts
@@ -256,12 +256,17 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
});
|
||||
}
|
||||
|
||||
private loadMathJax() {
|
||||
public loadMathJax() {
|
||||
const self = this;
|
||||
this.app.workspace.onLayoutReady(async () => {
|
||||
//loading Obsidian MathJax as fallback
|
||||
await loadMathJax();
|
||||
try {
|
||||
if(self.mathjaxDiv) {
|
||||
document.body.removeChild(self.mathjaxDiv);
|
||||
self.mathjax = null;
|
||||
self.mathjaxLoaderFinished = false;
|
||||
}
|
||||
self.mathjaxDiv = document.body.createDiv();
|
||||
self.mathjaxDiv.title = "Excalidraw MathJax Support";
|
||||
self.mathjaxDiv.style.display = "none";
|
||||
@@ -273,7 +278,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
const script = doc.createElement("script");
|
||||
script.type = "text/javascript";
|
||||
script.onload = () => {
|
||||
debugger;
|
||||
const win = iframe.contentWindow;
|
||||
//@ts-ignore
|
||||
win.MathJax.startup.pagePromise.then(async () => {
|
||||
@@ -300,7 +304,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
self.mathjaxLoaderFinished = true;
|
||||
});
|
||||
};
|
||||
script.src = "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js";
|
||||
script.src = self.settings.mathjaxSourceURL; // "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js";
|
||||
//script.src = MATHJAX_DATAURL;
|
||||
doc.head.appendChild(script);
|
||||
} catch {
|
||||
|
||||
@@ -100,6 +100,7 @@ export interface ExcalidrawSettings {
|
||||
defaultTrayMode: boolean;
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
mathjaxSourceURL: string;
|
||||
}
|
||||
|
||||
export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
@@ -179,6 +180,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
defaultTrayMode: false,
|
||||
previousRelease: "1.6.13",
|
||||
showReleaseNotes: true,
|
||||
mathjaxSourceURL: "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js"
|
||||
};
|
||||
|
||||
const fragWithHTML = (html: string) =>
|
||||
@@ -188,6 +190,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
plugin: ExcalidrawPlugin;
|
||||
private requestEmbedUpdate: boolean = false;
|
||||
private requestReloadDrawings: boolean = false;
|
||||
private reloadMathJax: boolean = false;
|
||||
//private applyDebounceTimer: number = 0;
|
||||
|
||||
constructor(app: App, plugin: ExcalidrawPlugin) {
|
||||
@@ -228,6 +231,9 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
this.plugin.triggerEmbedUpdates();
|
||||
}
|
||||
this.plugin.scriptEngine.updateScriptPath();
|
||||
if(this.reloadMathJax) {
|
||||
this.plugin.loadMathJax();
|
||||
}
|
||||
}
|
||||
|
||||
async display() {
|
||||
@@ -1108,6 +1114,24 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}),
|
||||
);
|
||||
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/628
|
||||
new Setting(containerEl)
|
||||
.setName(t("MATHJAX_NAME"))
|
||||
.setDesc(t("MATHJAX_DESC"))
|
||||
.addDropdown((dropdown) => {
|
||||
dropdown
|
||||
.addOption("https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js", "jsdelivr")
|
||||
.addOption("https://unpkg.com/mathjax@3.2.1/es5/tex-svg.js", "unpkg")
|
||||
.addOption("https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.1/es5/tex-svg-full.min.js","cdnjs")
|
||||
.setValue(this.plugin.settings.mathjaxSourceURL)
|
||||
.onChange((value)=> {
|
||||
this.plugin.settings.mathjaxSourceURL = value;
|
||||
this.reloadMathJax = true;
|
||||
this.applySettingsUpdate();
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
this.containerEl.createEl("h1", { text: t("EXPERIMENTAL_HEAD") });
|
||||
this.containerEl.createEl("p", { text: t("EXPERIMENTAL_DESC") });
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"1.6.31": "0.12.16",
|
||||
"1.6.32": "0.12.16",
|
||||
"1.4.2": "0.11.13"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user