diff --git a/manifest-beta.json b/manifest-beta.json index f902dae..3d3246d 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.4.0-beta-10", + "version": "2.4.0-rc-1", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawData.ts b/src/ExcalidrawData.ts index 9c97a13..208aa33 100644 --- a/src/ExcalidrawData.ts +++ b/src/ExcalidrawData.ts @@ -94,7 +94,10 @@ export const REGEX_TAGS = { export const REGEX_LINK = { //![[link|alias]] [alias](link){num} // 1 2 3 4 5 67 8 9 - EXPR: /(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g, //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/187 + //EXPR: /(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g, //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/187 + // 1 2 3 4 5 67 8 9 + EXPR: /(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(((?:[^\(\)]|\([^\(\)]*\))*)\))(\{(\d+)\})?/g, //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1963 + getResList: (text: string): IteratorResult[] => { const res = text.matchAll(REGEX_LINK.EXPR); let parts: IteratorResult; diff --git a/src/customEmbeddable.tsx b/src/customEmbeddable.tsx index c12ce41..7f2404a 100644 --- a/src/customEmbeddable.tsx +++ b/src/customEmbeddable.tsx @@ -416,8 +416,14 @@ function RenderObsidianView( } } else if (leafRef.current?.node) { //Handle canvas node - containerRef.current?.removeClasses(["is-editing", "is-focused"]); - view.canvasNodeFactory.stopEditing(leafRef.current.node); + if(view.plugin.settings.markdownNodeOneClickEditing && !containerRef.current?.hasClass("is-editing")) { + const newTheme = getTheme(view, themeRef.current); + containerRef.current?.addClasses(["is-editing", "is-focused"]); + view.canvasNodeFactory.startEditing(leafRef.current.node, newTheme); + } else { + containerRef.current?.removeClasses(["is-editing", "is-focused"]); + view.canvasNodeFactory.stopEditing(leafRef.current.node); + } } }, [ containerRef, @@ -428,7 +434,8 @@ function RenderObsidianView( element, view, isEditingRef, - view.canvasNodeFactory + view.canvasNodeFactory, + themeRef.current ]); return null; diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index b89a6e0..b078e1d 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -477,7 +477,11 @@ FILENAME_HEAD: "Filename", EMBED_TOEXCALIDRAW_DESC: "In the Embed Files section of Excalidraw Settings, you can configure how various files are embedded into Excalidraw. This includes options for embedding interactive markdown files, PDFs, and markdown files as images.", MD_HEAD: "Embed markdown into Excalidraw as image", MD_EMBED_CUSTOMDATA_HEAD_NAME: "Interactive Markdown Files", - MD_EMBED_CUSTOMDATA_HEAD_DESC: `These settings will only effect future embeds. Current embeds remain unchanged. The theme setting of embedded frames is under the "Excalidraw appearance and behavior" section.`, + MD_EMBED_CUSTOMDATA_HEAD_DESC: `The below settings will only effect future embeds. Current embeds remain unchanged. The theme setting of embedded frames is under the "Excalidraw appearance and behavior" section.`, + MD_EMBED_SINGLECLICK_EDIT_NAME: "Single click to edit embedded markdown", + MD_EMBED_SINGLECLICK_EDIT_DESC: + "Single click on an embedded markdown file to edit it. " + + "When turned off, the markdown file will first open in preview mode, then switch to edit mode when you click on it again.", MD_TRANSCLUDE_WIDTH_NAME: "Default width of a transcluded markdown document", MD_TRANSCLUDE_WIDTH_DESC: "The width of the markdown page. This affects the word wrapping when transcluding longer paragraphs, and the width of " + diff --git a/src/settings.ts b/src/settings.ts index 4b28587..5513de7 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -183,6 +183,7 @@ export interface ExcalidrawSettings { COLOR: string, }; embeddableMarkdownDefaults: EmbeddableMDCustomProps; + markdownNodeOneClickEditing: boolean; canvasImmersiveEmbed: boolean, startupScriptPath: string, openAIAPIToken: string, @@ -366,6 +367,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = { borderOpacity: 0, filenameVisible: false, }, + markdownNodeOneClickEditing: false, canvasImmersiveEmbed: true, startupScriptPath: "", openAIAPIToken: "", @@ -2125,7 +2127,26 @@ export class ExcalidrawSettingTab extends PluginSettingTab { text: t("MD_EMBED_CUSTOMDATA_HEAD_NAME"), cls: "excalidraw-setting-h3", }); - detailsEl.createEl("span", {text: t("MD_EMBED_CUSTOMDATA_HEAD_DESC")}); + + new Setting(detailsEl) + .setName(t("MD_EMBED_SINGLECLICK_EDIT_NAME")) + .setDesc(fragWithHTML(t("MD_EMBED_SINGLECLICK_EDIT_DESC"))) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.markdownNodeOneClickEditing) + .onChange(async (value) => { + this.plugin.settings.markdownNodeOneClickEditing = value; + this.applySettingsUpdate(); + }) + ); + + detailsEl.createEl("hr", { cls: "excalidraw-setting-hr" }); + detailsEl.createEl("span", {}, (el) => { + el.innerHTML = t("MD_EMBED_CUSTOMDATA_HEAD_DESC"); + }); + + + new EmbeddalbeMDFileCustomDataSettingsComponent( detailsEl, diff --git a/styles.css b/styles.css index 88ce582..d08231c 100644 --- a/styles.css +++ b/styles.css @@ -625,4 +625,8 @@ textarea.excalidraw-wysiwyg, .excalidraw input { .excalidraw-rank svg { height: 8rem; width: 8rem; +} + +.excalidraw .color-picker-content input[type="color"] { + filter: var(--theme-filter); } \ No newline at end of file