2.6.0-beta-2

This commit is contained in:
zsviczian
2024-10-26 08:39:28 +02:00
parent 2dab801ff5
commit a775a858c7
6 changed files with 41 additions and 10 deletions

View File

@@ -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",

View File

@@ -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") {

View File

@@ -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. " +

View File

@@ -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(

View File

@@ -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,

View File

@@ -1354,7 +1354,15 @@ export function matchesCJKRange(
});
}
export async function getCJKDataURLs(plugin: ExcalidrawPlugin): Promise<string[] | undefined> {
/**
*
* @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<string[] | undefined | boolean> {
const rangesToLoad = plugin.getCJKFontSettings();
if (!(rangesToLoad.c || rangesToLoad.j || rangesToLoad.k)) {
return;
@@ -1391,5 +1399,5 @@ export async function getCJKDataURLs(plugin: ExcalidrawPlugin): Promise<string[]
dataUrls.push("data:font/woff2;base64," + dataUrl);
}
return dataUrls; // Return the array of Data URLs
return dataUrls.length > 0 ? dataUrls : false; // Return the array of Data URLs
}