Skip to content

Commit

Permalink
2.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
zsviczian committed Oct 13, 2024
1 parent 4e2d7eb commit fc0ac92
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 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.5.1",
"version": "2.5.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.5.1",
"version": "2.5.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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.17.1-obsidian-56",
"@zsviczian/excalidraw": "0.17.1-obsidian-57",
"chroma-js": "^2.4.2",
"clsx": "^2.0.0",
"@zsviczian/colormaster": "^1.2.2",
Expand Down
2 changes: 1 addition & 1 deletion src/ExcalidrawView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3444,7 +3444,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
toDelete.forEach((k) => delete files[k]);
}

const activeTool = st.activeTool;
const activeTool = {...st.activeTool};
if(!["freedraw","hand"].includes(activeTool.type)) {
activeTool.type = "selection";
}
Expand Down
8 changes: 5 additions & 3 deletions src/MarkdownPostProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { FILENAMEPARTS, PreviewImageType } from "./utils/UtilTypes";
import { CustomMutationObserver, debug, DEBUGGING } from "./utils/DebugHelper";
import { getExcalidrawFileForwardLinks } from "./utils/ExcalidrawViewUtils";
import { linkPrompt } from "./dialogs/Prompt";
import { isHTMLElement } from "./utils/typechecks";

interface imgElementAttributes {
file?: TFile;
Expand Down Expand Up @@ -405,12 +406,13 @@ const createImgElement = async (

let timer:number;
const clickEvent = (ev:PointerEvent) => {
if(!(ev.target instanceof Element)) {
if (!isHTMLElement(ev.target)) {
return;
}
const containerElement = ev.target.hasClass("excalidraw-embedded-img")
const targetElement = ev.target as HTMLElement;
const containerElement = targetElement.hasClass("excalidraw-embedded-img")
? ev.target
: getParentOfClass(ev.target, "excalidraw-embedded-img");
: getParentOfClass(targetElement, "excalidraw-embedded-img");
if (!containerElement) {
return;
}
Expand Down
12 changes: 12 additions & 0 deletions src/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://cdn.ko-fi.com/cdn/kofi3.png?v=3" height=45></a></div>
`,
"2.5.2": `
## Fixed
- Text became disconnected from sticky notes (rectangle/ellipse/diamond + text) if the sticky note contained a link (e.g., URL or wiki link), and in some cases, triggered a save error warning. [#2054](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2054)
- Long-clicking to open an Excalidraw drawing from a markdown note did not work when the note was in an Obsidian pop-out window.
- Active tool was deactivated after autosave, requiring the user to reselect the tool.
## Minor changes to default settings
- I adjusted some of the default settings. This change only affects new installs of Excalidraw; existing installs and settings remain unchanged:
- **Reuse Adjacent Pane** is now the default for opening new drawings. Excalidraw will try to open the drawing in the most recently used adjacent pane, if available.
- **Focus on Existing Tab** is the default for reopening an already open drawing. Excalidraw will switch to the existing tab where the drawing is open, instead of creating a new one.
- **Autosave Interval** is now set to a default value of 1 minute on Desktop and 30 seconds on mobile platforms.
`,
"2.5.1": `
## New
- Excalidraw will now save images using the filename from the file system when adding an image via the image tool (in the top toolbar).
Expand Down
8 changes: 4 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
onceOffCompressFlagReset: false,
onceOffGPTVersionReset: false,
autosave: true,
autosaveIntervalDesktop: 30000,
autosaveIntervalMobile: 20000,
autosaveIntervalDesktop: 60000,
autosaveIntervalMobile: 30000,
drawingFilenamePrefix: "Drawing ",
drawingEmbedPrefixWithFilename: true,
drawingFilnameEmbedPostfix: " ",
Expand Down Expand Up @@ -268,9 +268,9 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
done: "🗹",
hoverPreviewWithoutCTRL: false,
linkOpacity: 1,
openInAdjacentPane: false,
openInAdjacentPane: true,
showSecondOrderLinks: true,
focusOnFileTab: false,
focusOnFileTab: true,
openInMainWorkspace: true,
showLinkBrackets: true,
allowCtrlClick: true,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/ExcalidrawSceneUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export function updateElementIdsInScene(
boundEl.boundElements?.filter(x=>x.id === elementToChange.id).forEach( x => {
(x.id as Mutable<string>) = newID;
});
if(boundEl.type === "text") {
boundEl.containerId = newID;
}
if(boundEl.type === "arrow") {
const arrow = boundEl as Mutable<ExcalidrawArrowElement>;
if(arrow.startBinding?.elementId === elementToChange.id) {
Expand Down
18 changes: 18 additions & 0 deletions src/utils/typechecks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Checks if a given target is an HTMLElement.
*
* This function is necessary because `instanceof HTMLElement` can fail
* in environments with multiple execution contexts (e.g., popout windows),
* where `HTMLElement` comes from different global objects.
* Instead, we use feature detection by checking for key properties
* common to all HTML elements (nodeType and tagName).
*
* @param target - The target to check.
* @returns True if the target is an HTMLElement, false otherwise.
*/
export function isHTMLElement (target: any): target is HTMLElement {
return target &&
typeof target === 'object' &&
target.nodeType === 1 && // nodeType 1 means it's an element
typeof target.tagName === 'string'; // tagName exists on HTML elements
}

0 comments on commit fc0ac92

Please sign in to comment.