Skip to content

Commit

Permalink
2.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Dec 21, 2024
1 parent d3133f0 commit 5a413ab
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 12 deletions.
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.7.1",
"version": "2.7.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.7.1",
"version": "2.7.2",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
Expand Down
1 change: 0 additions & 1 deletion src/core/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
DEVICE,
FONTS_STYLE_ID,
CJK_STYLE_ID,
updateExcalidrawLib,
loadMermaid,
setRootElementSize,
} from "../constants/constants";
Expand Down
8 changes: 7 additions & 1 deletion src/core/managers/EventManager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WorkspaceLeaf, TFile, Editor, MarkdownView, MarkdownFileInfo, MetadataCache, App, EventRef, Menu, FileView } from "obsidian";
import { ExcalidrawElement } from "@zsviczian/excalidraw/types/excalidraw/element/types";
import { getLink } from "../../utils/fileUtils";
import { editorInsertText, getParentOfClass, setExcalidrawView } from "../../utils/obsidianUtils";
import { editorInsertText, getExcalidrawViews, getParentOfClass, setExcalidrawView } from "../../utils/obsidianUtils";
import ExcalidrawPlugin from "src/core/main";
import { DEBUGGING, debug } from "src/utils/debugHelper";
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
Expand Down Expand Up @@ -81,6 +81,8 @@ export class EventManager {
//save Excalidraw leaf and update embeds when switching to another leaf
this.registerEvent(this.plugin.app.workspace.on("active-leaf-change", this.onActiveLeafChangeHandler.bind(this)));

this.registerEvent(this.app.workspace.on("layout-change", this.onLayoutChangeHandler.bind(this)));

//File Save Trigger Handlers
//Save the drawing if the user clicks outside the Excalidraw Canvas
const onClickEventSaveActiveDrawing = this.onClickSaveActiveDrawing.bind(this);
Expand All @@ -101,6 +103,10 @@ export class EventManager {
this.plugin.registerEvent(this.plugin.app.workspace.on("editor-menu", this.onEditorMenuHandler.bind(this)));
}

private onLayoutChangeHandler() {
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.refresh());
}

private onPasteHandler (evt: ClipboardEvent, editor: Editor, info: MarkdownView | MarkdownFileInfo ) {
if(evt.defaultPrevented) return
const data = evt.clipboardData.getData("text/plain");
Expand Down
12 changes: 12 additions & 0 deletions src/shared/Dialogs/Messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ 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://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
`,
"2.7.2":`
## Fixed
- The plugin did not load on **iOS 16 and older**. [#2170](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2170)
- Added empty line between ${String.fromCharCode(96)}# Excalidraw Data${String.fromCharCode(96)} and ${String.fromCharCode(96)}## Text Elements${String.fromCharCode(96)}. This will now follow **correct markdown linting**. [#2168](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2168)
- Adding an **embeddable** to view did not **honor the element background and element stroke colors**, even if it was configured in plugin settings. [#2172](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2172)
- **Deconstruct selected elements script** did not copy URLs and URIs for images embedded from outside Obsidian. Please update your script from the script library.
- When **rearranging tabs in Obsidian**, e.g. having two tabs side by side, and moving one of them to another location, if the tab was an Excalidraw tab, it appeared as non-responsive after the move, until the tab was resized.
## Source Code Refactoring
- Updated filenames, file locations, and file name letter-casing across the project
- Extracted onDrop, onDragover, etc. handlers to DropManger in ExcalidrawView
`,
"2.7.1":`
## Fixed
- Deleting excalidraw file from file system while it is open in fullscreen mode in Obsidian causes Obsidian to be stuck in full-screen view [#2161](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2161)
Expand Down
9 changes: 3 additions & 6 deletions src/shared/EmbeddedFileLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,18 +812,15 @@ export class EmbeddedFilesLoader {

//when obsidian loads there seems to be an occasional race condition where the rendering is cancelled
//this is a workaround for that
const maxRetries = 3;
const maxRetries = 4;
for (let i = 0; i < maxRetries; i++) {
try {
await page.render(renderCtx).promise;
break;
} catch (e) {
if (i === maxRetries - 1) throw e; // Throw on last retry
if (e.name === 'RenderingCancelledException') {
await new Promise(resolve => setTimeout(resolve, 50 * (i + 1))); // Incremental backoff
continue;
}
throw e; // Throw other errors immediately
await sleep(50*(i+1));
continue;
}
}
if(validRect) {
Expand Down
17 changes: 15 additions & 2 deletions src/utils/excalidrawViewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,21 @@ export async function insertEmbeddableToView (
shouldInsertToView: boolean = true,
):Promise<string> {
if(shouldInsertToView) {ea.clear();}
ea.style.strokeColor = "transparent";
ea.style.backgroundColor = "transparent";
const api = ea.getExcalidrawAPI() as ExcalidrawImperativeAPI;
const st = api.getAppState();

if(ea.plugin.settings.embeddableMarkdownDefaults.backgroundMatchElement) {
ea.style.backgroundColor = st.currentItemBackgroundColor;
} else {
ea.style.backgroundColor = "transparent";
}

if(ea.plugin.settings.embeddableMarkdownDefaults.borderMatchElement) {
ea.style.strokeColor = st.currentItemStrokeColor;
} else {
ea.style.strokeColor = "transparent";
}

if(file && (IMAGE_TYPES.contains(file.extension) || ea.isExcalidrawFile(file)) && !ANIMATED_IMAGE_TYPES.contains(file.extension)) {
return await insertImageToView(ea, position, link??file, undefined, shouldInsertToView);
} else {
Expand Down
6 changes: 6 additions & 0 deletions src/view/ExcalidrawView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
//onClose happens after onunload
protected async onClose(): Promise<void> {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.onClose,`ExcalidrawView.onClose, file:${this.file?.name}`);

// This happens when the user right clicks a tab and selects delete
// in this case the onDelete event handler tirggers, but then Obsidian's delete event handler reaches onclose first, and
// when the function is called a second time via on delete an error is thrown.)
if(!this.file) return;

this.exitFullscreen();
await this.forceSaveIfRequired();
if (this.excalidrawRoot) {
Expand Down

0 comments on commit 5a413ab

Please sign in to comment.