Skip to content

Commit

Permalink
2.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Sep 6, 2024
1 parent a910550 commit c6bf24e
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 86 deletions.
36 changes: 0 additions & 36 deletions dev.postprocess.config.js

This file was deleted.

2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.4.2-rc-1",
"version": "2.4.2",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.4.1",
"version": "2.4.2",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
Expand Down
32 changes: 0 additions & 32 deletions prod.postprocess.config.js

This file was deleted.

20 changes: 11 additions & 9 deletions src/ExcalidrawAutomate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ export class ExcalidrawAutomate {
* @returns
*/
public getAPI(view?:ExcalidrawView):ExcalidrawAutomate {
return new ExcalidrawAutomate(this.plugin, view);
const ea = new ExcalidrawAutomate(this.plugin, view);
this.plugin.eaInstances.push(ea);
return ea;
}

/**
Expand Down Expand Up @@ -741,34 +743,34 @@ export class ExcalidrawAutomate {

outString += Object.keys(this.imagesDict).length > 0
? `\n## Embedded Files\n`
: "";
: "\n";

Object.keys(this.imagesDict).forEach((key: FileId)=> {
const item = this.imagesDict[key];
if(item.latex) {
outString += `${key}: $$${item.latex}$$\n`;
outString += `${key}: $$${item.latex}$$\n\n`;
} else {
if(item.file) {
if(item.file instanceof TFile) {
outString += `${key}: [[${item.file.path}]]\n`;
outString += `${key}: [[${item.file.path}]]\n\n`;
} else {
outString += `${key}: [[${item.file}]]\n`;
outString += `${key}: [[${item.file}]]\n\n`;
}
} else {
const hyperlinkSplit = item.hyperlink.split("#");
const file = this.plugin.app.vault.getAbstractFileByPath(hyperlinkSplit[0]);
if(file && file instanceof TFile) {
const hasFileRef = hyperlinkSplit.length === 2
outString += hasFileRef
? `${key}: [[${file.path}#${hyperlinkSplit[1]}]]\n`
: `${key}: [[${file.path}]]\n`;
? `${key}: [[${file.path}#${hyperlinkSplit[1]}]]\n\n`
: `${key}: [[${file.path}]]\n\n`;
} else {
outString += `${key}: ${item.hyperlink}\n`;
outString += `${key}: ${item.hyperlink}\n\n`;
}
}
}
})
return outString + "\n%%\n";
return outString + "%%\n";
}

const filename = params?.filename
Expand Down
13 changes: 6 additions & 7 deletions src/ExcalidrawData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1434,12 +1434,11 @@ export class ExcalidrawData {
if (this.elementLinks.size > 0 || textElementLinks.size > 0) {
outString += `## Element Links\n`;
for (const key of this.elementLinks.keys()) {
outString += `${key}: ${this.elementLinks.get(key)}\n`;
outString += `${key}: ${this.elementLinks.get(key)}\n\n`;
}
for (const key of textElementLinks.keys()) {
outString += `${key}: ${textElementLinks.get(key)}\n`;
outString += `${key}: ${textElementLinks.get(key)}\n\n`;
}
outString += "\n";
}

// deliberately not adding mermaids to here. It is enough to have the mermaidText in the image element's customData
Expand All @@ -1449,26 +1448,26 @@ export class ExcalidrawData {
: "";
if (this.equations.size > 0) {
for (const key of this.equations.keys()) {
outString += `${key}: $$${this.equations.get(key).latex}$$\n`;
outString += `${key}: $$${this.equations.get(key).latex}$$\n\n`;
}
}
if (this.files.size > 0) {
for (const key of this.files.keys()) {
const PATHREG = /(^[^#\|]*)/;
const ef = this.files.get(key);
if(ef.isHyperLink || ef.isLocalLink) {
outString += `${key}: ${ef.hyperlink}\n`;
outString += `${key}: ${ef.hyperlink}\n\n`;
} else {
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/829
const path = ef.file
? ef.linkParts.original.replace(PATHREG,this.app.metadataCache.fileToLinktext(ef.file,this.file.path))
: ef.linkParts.original;
const colorMap = ef.colorMap ? " " + JSON.stringify(ef.colorMap) : "";
outString += `${key}: [[${path}]]${colorMap}\n`;
outString += `${key}: [[${path}]]${colorMap}\n\n`;
}
}
}
outString += this.equations.size > 0 || this.files.size > 0 ? "\n" : "";
//outString += this.equations.size > 0 || this.files.size > 0 ? "\n" : "";

const sceneJSONstring = JSON.stringify({
type: this.scene.type,
Expand Down
4 changes: 4 additions & 0 deletions src/ExcalidrawView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,10 @@ export default class ExcalidrawView extends TextFileView {
}

async openLaTeXEditor(eqId: string) {
if(await this.excalidrawData.syncElements(this.getScene())) {
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1994
await this.forceSave(true);
}
const el = this.getViewElements().find((el:ExcalidrawElement)=>el.id === eqId && el.type==="image") as ExcalidrawImageElement;
if(!el) {
return;
Expand Down
17 changes: 17 additions & 0 deletions src/dialogs/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,23 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
<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>
`,
"2.4.2": `
This release addresses critical issues for all Obsidian Mobile users.
#### 😞 I made two mistakes...
- I expedited the 2.4.1 release to resolve a major bug, but in doing so, I skippes some of my usual rigorous testing
- I included a new feature in 2.4.1 fresh from Excalidraw.com because I believe it brings significant end user benefits and did not want to wait until October. However, a small part of this feature was designed for server-side execution on Excalidraw.com, not for local use on Obsidian Mobile.
Despite the recent two (2.4.1 and 2.4.2) emergency bug-fix releases, this doesn't deviate from the [monthly release schedule](https://youtu.be/2poSS-Z91lY). The next feature update is still planned for early October.
## Fixes:
- **Excalidraw rendering issues on Obsidian Mobile:** [#1995](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1995), [#1997](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1997)
- Nested Excalidraw drawings with text failed to render.
- Drawings in Markdown view didn't render if they contained text and were set to SVG Image or SVG Native (they worked with PNG).
- SVG export failed for drawings containing text.
- **LaTeX equation duplication:** After using ALT+Drag to duplicate a LaTeX equation, editing the duplicate modified the original instead. [#1984](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1994)
- **Unreadable Obsidian search results:** When drawings contained numerous Element Links and Embedded Files Links, search results became unreadable. This fix will apply to files saved after installing the update. [#1999](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1999)
`,
"2.4.1": `
This release includes an important fix that can result in your drawing being overwritten by another drawing. Please update to this version as soon as possible.
Expand Down
6 changes: 6 additions & 0 deletions src/dialogs/SuggesterInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,12 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
"the function will use ea.targetView.file",
after: "",
},
{
field: "getAPI",
code: "public getAPI(view?:ExcalidrawView):ExcalidrawAutomate",
desc: "Returns a new instance of ExcalidrawAutomate.",
after: "",
},
{
field: "getAttachmentFilepath",
code: "async getAttachmentFilepath(filename: string): Promise<string>",
Expand Down
6 changes: 6 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ import { ExcalidrawLib } from "./ExcalidrawLib";
import { Rank, SwordColors } from "./menu/ActionIcons";
import { RankMessage } from "./dialogs/RankMessage";
import { initCompressionWorker, terminateCompressionWorker } from "./workers/compression-worker";
import { WeakArray } from "./utils/WeakArray";

declare let EXCALIDRAW_PACKAGES:string;
declare let react:any;
Expand All @@ -147,6 +148,7 @@ declare let excalidrawLib: typeof ExcalidrawLib;
declare let PLUGIN_VERSION:string;

export default class ExcalidrawPlugin extends Plugin {
public eaInstances = new WeakArray<ExcalidrawAutomate>();
public fourthFontLoaded: boolean = false;
public excalidrawConfig: ExcalidrawConfig;
public taskbone: Taskbone;
Expand Down Expand Up @@ -3249,6 +3251,10 @@ export default class ExcalidrawPlugin extends Plugin {
);
this.removeEventLisnters = [];

this.eaInstances.forEach((ea) => ea?.destroy());
this.eaInstances.clear();
this.eaInstances = null;

this.ea.destroy();
this.ea = null;

Expand Down

0 comments on commit c6bf24e

Please sign in to comment.