diff --git a/manifest-beta.json b/manifest-beta.json index d1bba33..a1f18b4 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "2.6.0-beta-1", + "version": "2.6.0-beta-2", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 5799e5f..d1d29f6 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -3851,12 +3851,14 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{ return; } - //dobule click - const now = Date.now(); - if ((now - this.doubleClickTimestamp) < 600 && (now - this.doubleClickTimestamp) > 40) { - this.identifyElementClicked(); + if(this.plugin.settings.doubleClickLinkOpenViewMode) { + //dobule click + const now = Date.now(); + if ((now - this.doubleClickTimestamp) < 600 && (now - this.doubleClickTimestamp) > 40) { + this.identifyElementClicked(); + } + this.doubleClickTimestamp = now; } - this.doubleClickTimestamp = now; return; } if (p.button === "up") { diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 029fede..7fa4782 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -98,6 +98,8 @@ export default { RESET_IMG_ASPECT_RATIO: "Reset selected image element aspect ratio", TEMPORARY_DISABLE_AUTOSAVE: "Disable autosave until next time Obsidian starts (only set this if you know what you are doing)", TEMPORARY_ENABLE_AUTOSAVE: "Enable autosave", + FONTS_LOADED: "Excalidraw: CJK Fonts loaded", + FONTS_LOAD_ERROR: "Excalidraw: Could not find CJK Fonts in the assets folder\n", //ExcalidrawView.ts NO_SEARCH_RESULT: "Didn't find a matching element in the drawing", @@ -432,6 +434,7 @@ FILENAME_HEAD: "Filename", LONG_PRESS_DESKTOP_DESC: "Long press delay in milliseconds to open an Excalidraw Drawing embedded in a Markdown file. ", LONG_PRESS_MOBILE_NAME: "Long press to open mobile", LONG_PRESS_MOBILE_DESC: "Long press delay in milliseconds to open an Excalidraw Drawing embedded in a Markdown file. ", + DOUBLE_CLICK_LINK_OPEN_VIEW_MODE: "Allow double-click to open links in view mode", FOCUS_ON_EXISTING_TAB_NAME: "Focus on Existing Tab", FOCUS_ON_EXISTING_TAB_DESC: "When opening a link, Excalidraw will focus on the existing tab if the file is already open. " + diff --git a/src/main.ts b/src/main.ts index f7de6be..b0ddd51 100644 --- a/src/main.ts +++ b/src/main.ts @@ -440,14 +440,18 @@ export default class ExcalidrawPlugin extends Plugin { (process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.initializeFonts, `ExcalidrawPlugin.initializeFonts > app.workspace.onLayoutReady`); const cjkFontDataURLs = await getCJKDataURLs(this); - if(cjkFontDataURLs) { + if(typeof cjkFontDataURLs === "boolean" && !cjkFontDataURLs) { + new Notice(t("FONTS_LOAD_ERROR") + this.settings.fontAssetsPath,6000); + } + + if(typeof cjkFontDataURLs === "object") { const fontDeclarations = cjkFontDataURLs.map(dataURL => `@font-face { font-family: 'Xiaolai'; src: url("${dataURL}"); font-display: swap; font-weight: 400; }` ); for(const ownerDocument of this.getOpenObsidianDocuments()) { await this.addFonts(fontDeclarations, ownerDocument, CJK_STYLE_ID); }; - new Notice("Excalidraw: CJK Fonts loaded"); + new Notice(t("FONTS_LOADED")); } const font = await getFontDataURL( diff --git a/src/settings.ts b/src/settings.ts index b53a761..9b4d5fd 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -209,6 +209,7 @@ export interface ExcalidrawSettings { areaZoomLimit: number; longPressDesktop: number; longPressMobile: number; + doubleClickLinkOpenViewMode: boolean; isDebugMode: boolean; rank: Rank; modifierKeyOverrides: {modifiers: Modifier[], key: string}[]; @@ -480,6 +481,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = { areaZoomLimit: 1, longPressDesktop: 500, longPressMobile: 500, + doubleClickLinkOpenViewMode: true, isDebugMode: false, rank: "Bronze", modifierKeyOverrides: [ @@ -1493,6 +1495,18 @@ export class ExcalidrawSettingTab extends PluginSettingTab { el.innerText = ` ${this.plugin.settings.longPressMobile.toString()}`; }); + new Setting(detailsEl) + .setName(t("DOUBLE_CLICK_LINK_OPEN_VIEW_MODE")) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.doubleClickLinkOpenViewMode) + .onChange(async (value) => { + this.plugin.settings.doubleClickLinkOpenViewMode = value; + this.applySettingsUpdate(); + }), + ); + + new ModifierKeySettingsComponent( detailsEl, this.plugin.settings.modifierKeyConfig, diff --git a/src/utils/CJKLoader.ts b/src/utils/CJKLoader.ts index 632b99e..250f207 100644 --- a/src/utils/CJKLoader.ts +++ b/src/utils/CJKLoader.ts @@ -1354,7 +1354,15 @@ export function matchesCJKRange( }); } -export async function getCJKDataURLs(plugin: ExcalidrawPlugin): Promise { +/** + * + * @param plugin + * @returns + * - undefined if no CJK ranges are specified + * - false if no CJK fonts are found + * - array of Data URLs for CJK fonts + */ +export async function getCJKDataURLs(plugin: ExcalidrawPlugin): Promise { const rangesToLoad = plugin.getCJKFontSettings(); if (!(rangesToLoad.c || rangesToLoad.j || rangesToLoad.k)) { return; @@ -1391,5 +1399,5 @@ export async function getCJKDataURLs(plugin: ExcalidrawPlugin): Promise 0 ? dataUrls : false; // Return the array of Data URLs } \ No newline at end of file