mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
118
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5236a73a1e | ||
|
|
faa900a352 | ||
|
|
2ceebab04f | ||
|
|
497125d7cc | ||
|
|
4e8baed49f | ||
|
|
3f93be3b45 | ||
|
|
bb17694219 | ||
|
|
12bc2a1680 | ||
|
|
a1561de832 | ||
|
|
1900cfcf84 | ||
|
|
aa47d1375b | ||
|
|
61ae34968a | ||
|
|
296ac84f08 | ||
|
|
bcd63ad7fe | ||
|
|
1fec09c367 | ||
|
|
4cd5dde3d6 | ||
|
|
36ee7f6e52 | ||
|
|
32f76d4ea4 | ||
|
|
53aed86777 | ||
|
|
573587bd88 | ||
|
|
558d0105a5 | ||
|
|
76910a3352 | ||
|
|
e2c9e2b256 | ||
|
|
9630db68a4 | ||
|
|
7541fa22b4 | ||
|
|
c5cf6d630f | ||
|
|
2f296c7a46 | ||
|
|
095ff057cd | ||
|
|
b38956cb51 | ||
|
|
03392db757 | ||
|
|
2bd252fcff | ||
|
|
12b52e42f2 | ||
|
|
76675591fe | ||
|
|
966f6b53ea | ||
|
|
efbca80f74 | ||
|
|
ee8ac2f7ad | ||
|
|
0ac7ccde66 | ||
|
|
b5bd27f115 | ||
|
|
600b2d9621 | ||
|
|
c709562925 | ||
|
|
c3cfe0b0ed | ||
|
|
686ff92f4d | ||
|
|
37f3937bd6 | ||
|
|
16c61c44ce | ||
|
|
2f968a7bbc | ||
|
|
475492beda | ||
|
|
ab11258d0d | ||
|
|
1ab682e726 | ||
|
|
cb370645b7 | ||
|
|
c80420772e | ||
|
|
5fd76e07ba | ||
|
|
fda8d5ce77 | ||
|
|
2e52744743 | ||
|
|
a634d24f6b | ||
|
|
ebc0ecbfc4 | ||
|
|
9622e137ba | ||
|
|
b3bf3b5a60 | ||
|
|
cc1ae730d1 | ||
|
|
9841941431 | ||
|
|
f179b6720b | ||
|
|
b44d2a4a9a | ||
|
|
6a82011bdb | ||
|
|
c835943fc5 | ||
|
|
a4f0676686 | ||
|
|
e69487c456 | ||
|
|
e7a067d53a | ||
|
|
fe8ece275a | ||
|
|
a5f2da74ba | ||
|
|
ce602b8268 | ||
|
|
7bb718da81 | ||
|
|
cceb2cae82 | ||
|
|
f5f0134509 | ||
|
|
44588ab4b8 | ||
|
|
989e7969dc | ||
|
|
f5c7820315 | ||
|
|
c416c21985 | ||
|
|
e5f6466542 | ||
|
|
95ba981445 | ||
|
|
31cc45ff6d | ||
|
|
62f51511ed | ||
|
|
5c628e08f4 | ||
|
|
0e11150055 | ||
|
|
37b4cdd44a | ||
|
|
a2a33bc463 | ||
|
|
00531325ea | ||
|
|
a7d4d59619 | ||
|
|
b05e26d138 | ||
|
|
ce3cda7a1d | ||
|
|
ba5d1aa6d6 | ||
|
|
686f462716 | ||
|
|
21dec11170 | ||
|
|
168b1d1871 | ||
|
|
8df45aed14 | ||
|
|
2e9b5ce593 | ||
|
|
c332608bb5 | ||
|
|
ed9fe5f3d4 | ||
|
|
57afd6f134 | ||
|
|
63e0c1368f | ||
|
|
3b2f7d2c98 | ||
|
|
684d19eebd | ||
|
|
d65e967e4b | ||
|
|
59fe5abfa8 | ||
|
|
919913044d | ||
|
|
306e6db564 | ||
|
|
c32d0cb350 | ||
|
|
a43e527602 | ||
|
|
2e48ee8484 | ||
|
|
d568003915 | ||
|
|
247685b13f | ||
|
|
73c20e0d9d | ||
|
|
222ff139d8 | ||
|
|
0e0774d973 | ||
|
|
ae722623e5 | ||
|
|
65ab00a932 | ||
|
|
418063e9b6 | ||
|
|
b2f051e088 | ||
|
|
c884db0840 | ||
|
|
e4d1b509f7 |
No files matched your search
@@ -14,6 +14,7 @@ data.json
|
||||
lib
|
||||
dist
|
||||
tmp
|
||||
deploy.ps1
|
||||
|
||||
#VSCode
|
||||
.vscode
|
||||
|
||||
Generated
+5
-5
@@ -9,7 +9,7 @@
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"mathjax-full": "^3.2.2",
|
||||
"nanoid": "^4.0.2"
|
||||
"nanoid": "^5.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^26.0.1",
|
||||
@@ -749,9 +749,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/nanoid": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-4.0.2.tgz",
|
||||
"integrity": "sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==",
|
||||
"version": "5.0.9",
|
||||
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.9.tgz",
|
||||
"integrity": "sha512-Aooyr6MXU6HpvvWXKoVoXwKMs/KyVakWwg7xQfv5/S/RIgJMy0Ifa45H9qqYy7pTCszrHzP21Uk4PZq2HpEM8Q==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
@@ -763,7 +763,7 @@
|
||||
"nanoid": "bin/nanoid.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14 || ^16 || >=18"
|
||||
"node": "^18 || >=20"
|
||||
}
|
||||
},
|
||||
"node_modules/obsidian": {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"mathjax-full": "^3.2.2",
|
||||
"nanoid": "^4.0.2"
|
||||
"nanoid": "^5.0.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^26.0.1",
|
||||
|
||||
@@ -341,6 +341,24 @@ export declare class ExcalidrawAutomate {
|
||||
* @returns {Mutable<ExcalidrawElement>} The element with the specified ID.
|
||||
*/
|
||||
getElement(id: string): Mutable<ExcalidrawElement>;
|
||||
/**
|
||||
* Returns an object describing the bound text element.
|
||||
* If a text element is provided:
|
||||
* - returns { eaElement } if the element is in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If a container element is provided, searches for the bound text element:
|
||||
* - returns { eaElement } if found in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If not found, returns {}.
|
||||
* Does not add the text element to elementsDict.
|
||||
* @param element
|
||||
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
|
||||
* @returns Object containing either eaElement or sceneElement or empty if not found.
|
||||
*/
|
||||
getBoundTextElement(element: ExcalidrawElement, searchInView?: boolean): {
|
||||
eaElement?: Mutable<ExcalidrawTextElement>;
|
||||
sceneElement?: ExcalidrawTextElement;
|
||||
};
|
||||
/**
|
||||
* Creates a drawing and saves it to the specified filename.
|
||||
* @param {Object} [params] - Parameters for creating the drawing.
|
||||
@@ -375,6 +393,7 @@ export declare class ExcalidrawAutomate {
|
||||
"excalidraw-autoexport"?: boolean;
|
||||
"excalidraw-mask"?: boolean;
|
||||
"excalidraw-open-md"?: boolean;
|
||||
"excalidraw-export-internal-links"?: boolean;
|
||||
"cssclasses"?: string;
|
||||
};
|
||||
plaintext?: string;
|
||||
@@ -457,7 +476,7 @@ export declare class ExcalidrawAutomate {
|
||||
* @param {number} [padding] - The padding to use for the SVG.
|
||||
* @returns {Promise<SVGSVGElement>} Promise resolving to the created SVG element.
|
||||
*/
|
||||
createSVG(templatePath?: string, embedFont?: boolean, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string, padding?: number): Promise<SVGSVGElement>;
|
||||
createSVG(templatePath?: string, embedFont?: boolean, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string, padding?: number, convertMarkdownLinksToObsidianURLs?: boolean, includeInternalLinks?: boolean): Promise<SVGSVGElement>;
|
||||
/**
|
||||
* Creates a PNG image from the ExcalidrawAutomate elements and the template provided.
|
||||
* @param {string} [templatePath] - The template path to use for the PNG.
|
||||
@@ -658,6 +677,17 @@ export declare class ExcalidrawAutomate {
|
||||
* @param {"arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null} [formatting.endArrowHead] - The end arrowhead type.
|
||||
* @param {string} [formatting.startObjectId] - The ID of the start object.
|
||||
* @param {string} [formatting.endObjectId] - The ID of the end object.
|
||||
* BindMode Determines whether the arrow remains outside the shape or is allowed to
|
||||
* go all the way inside the shape up to the exact fixed point.
|
||||
* @param {"inside" | "orbit"} [formatting.startBindMode] - The binding mode for the start object.
|
||||
* @param {"inside" | "orbit"} [formatting.endBindMode] - The binding mode for the end object.
|
||||
* FixedPoint represents the fixed point binding information in form of a vertical and
|
||||
* horizontal ratio (i.e. a percentage value in the 0.0-1.0 range). This ratio
|
||||
* gives the user selected fixed point by multiplying the bound element width
|
||||
* with fixedPoint[0] and the bound element height with fixedPoint[1] to get the
|
||||
* bound element-local point coordinate.
|
||||
* @param {[number, number]} [formatting.startFixedPoint] - The fixed point for the start object.
|
||||
* @param {[number, number]} [formatting.endFixedPoint] - The fixed point for the end object.
|
||||
* @param {string} [id] - The ID of the arrow element.
|
||||
* @returns {string} The ID of the added arrow element.
|
||||
*/
|
||||
@@ -666,6 +696,11 @@ export declare class ExcalidrawAutomate {
|
||||
endArrowHead?: "arrow" | "bar" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | null;
|
||||
startObjectId?: string;
|
||||
endObjectId?: string;
|
||||
startBindMode?: "inside" | "orbit";
|
||||
endBindMode?: "inside" | "orbit";
|
||||
startFixedPoint?: [number, number];
|
||||
endFixedPoint?: [number, number];
|
||||
elbowed?: boolean;
|
||||
}, id?: string): string;
|
||||
/**
|
||||
* Adds a mermaid diagram to ExcalidrawAutomate elements.
|
||||
@@ -1224,6 +1259,9 @@ export declare class ExcalidrawAutomate {
|
||||
* @returns {Promise<void>} Promise resolving when the settings are saved.
|
||||
*/
|
||||
setScriptSettings(settings: any): Promise<void>;
|
||||
setScriptSettingValue(key: string, value: ScriptSettingValue): void;
|
||||
getScriptSettingValue(key: string, defaultValue: ScriptSettingValue): ScriptSettingValue;
|
||||
saveScriptSettings(): Promise<void>;
|
||||
/**
|
||||
* Opens a file in a new workspace leaf or reuses an existing adjacent leaf depending on Excalidraw Plugin Settings.
|
||||
* @param {TFile} file - The file to open.
|
||||
@@ -1359,6 +1397,13 @@ export type SVGColorInfo = Map<string, {
|
||||
fill: boolean;
|
||||
stroke: boolean;
|
||||
}>;
|
||||
export type ScriptSettingValue = {
|
||||
value?: string | number | boolean;
|
||||
hidden?: boolean;
|
||||
description?: string;
|
||||
valueset?: string[];
|
||||
height?: number;
|
||||
};
|
||||
export type ImageInfo = {
|
||||
mimeType: MimeType;
|
||||
id: FileId;
|
||||
@@ -1848,14 +1893,12 @@ export type ExcalidrawTextElementWithContainer = {
|
||||
containerId: ExcalidrawTextContainer["id"];
|
||||
} & ExcalidrawTextElement;
|
||||
export type FixedPoint = [number, number];
|
||||
export type PointBinding = {
|
||||
export type BindMode = "inside" | "orbit" | "skip";
|
||||
export type FixedPointBinding = {
|
||||
elementId: ExcalidrawBindableElement["id"];
|
||||
focus: number;
|
||||
gap: number;
|
||||
};
|
||||
export type FixedPointBinding = Merge<PointBinding, {
|
||||
fixedPoint: FixedPoint;
|
||||
}>;
|
||||
mode: BindMode;
|
||||
};
|
||||
type Index = number;
|
||||
export type PointsPositionUpdates = Map<Index, {
|
||||
point: LocalPoint;
|
||||
@@ -1865,9 +1908,8 @@ export type Arrowhead = "arrow" | "bar" | "dot" | "circle" | "circle_outline" |
|
||||
export type ExcalidrawLinearElement = _ExcalidrawElementBase & Readonly<{
|
||||
type: "line" | "arrow";
|
||||
points: readonly LocalPoint[];
|
||||
lastCommittedPoint: LocalPoint | null;
|
||||
startBinding: PointBinding | null;
|
||||
endBinding: PointBinding | null;
|
||||
startBinding: FixedPointBinding | null;
|
||||
endBinding: FixedPointBinding | null;
|
||||
startArrowhead: Arrowhead | null;
|
||||
endArrowhead: Arrowhead | null;
|
||||
}>;
|
||||
@@ -1886,9 +1928,9 @@ export type ExcalidrawArrowElement = ExcalidrawLinearElement & Readonly<{
|
||||
}>;
|
||||
export type ExcalidrawElbowArrowElement = Merge<ExcalidrawArrowElement, {
|
||||
elbowed: true;
|
||||
fixedSegments: readonly FixedSegment[] | null;
|
||||
startBinding: FixedPointBinding | null;
|
||||
endBinding: FixedPointBinding | null;
|
||||
fixedSegments: readonly FixedSegment[] | null;
|
||||
/**
|
||||
* Marks that the 3rd point should be used as the 2nd point of the arrow in
|
||||
* order to temporarily hide the first segment of the arrow without losing
|
||||
@@ -1911,7 +1953,6 @@ export type ExcalidrawFreeDrawElement = _ExcalidrawElementBase & Readonly<{
|
||||
points: readonly LocalPoint[];
|
||||
pressures: readonly number[];
|
||||
simulatePressure: boolean;
|
||||
lastCommittedPoint: LocalPoint | null;
|
||||
}>;
|
||||
export type FileId = string & {
|
||||
_brand: "FileId";
|
||||
@@ -2058,6 +2099,7 @@ export type StaticCanvasAppState = Readonly<_CommonCanvasAppState & {
|
||||
frameColor: AppState["frameColor"];
|
||||
currentHoveredFontFamily: AppState["currentHoveredFontFamily"];
|
||||
hoveredElementIds: AppState["hoveredElementIds"];
|
||||
suggestedBinding: AppState["suggestedBinding"];
|
||||
croppingElementId: AppState["croppingElementId"];
|
||||
}>;
|
||||
export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
||||
@@ -2066,14 +2108,16 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
||||
selectedGroupIds: AppState["selectedGroupIds"];
|
||||
selectedLinearElement: AppState["selectedLinearElement"];
|
||||
multiElement: AppState["multiElement"];
|
||||
newElement: AppState["newElement"];
|
||||
isBindingEnabled: AppState["isBindingEnabled"];
|
||||
suggestedBindings: AppState["suggestedBindings"];
|
||||
suggestedBinding: AppState["suggestedBinding"];
|
||||
isRotating: AppState["isRotating"];
|
||||
elementsToHighlight: AppState["elementsToHighlight"];
|
||||
collaborators: AppState["collaborators"];
|
||||
snapLines: AppState["snapLines"];
|
||||
zenModeEnabled: AppState["zenModeEnabled"];
|
||||
editingTextElement: AppState["editingTextElement"];
|
||||
viewBackgroundColor: AppState["viewBackgroundColor"];
|
||||
gridColor: AppState["gridColor"];
|
||||
gridDirection: AppState["gridDirection"];
|
||||
highlightSearchResult: AppState["highlightSearchResult"];
|
||||
@@ -2081,6 +2125,11 @@ export type InteractiveCanvasAppState = Readonly<_CommonCanvasAppState & {
|
||||
croppingElementId: AppState["croppingElementId"];
|
||||
searchMatches: AppState["searchMatches"];
|
||||
activeLockedId: AppState["activeLockedId"];
|
||||
hoveredElementIds: AppState["hoveredElementIds"];
|
||||
frameRendering: AppState["frameRendering"];
|
||||
frameColor: AppState["frameColor"];
|
||||
shouldCacheIgnoreZoom: AppState["shouldCacheIgnoreZoom"];
|
||||
exportScale: AppState["exportScale"];
|
||||
}>;
|
||||
export type ObservedAppState = ObservedStandaloneAppState & ObservedElementsAppState;
|
||||
export type ObservedStandaloneAppState = {
|
||||
@@ -2134,7 +2183,7 @@ export interface AppState {
|
||||
selectionElement: NonDeletedExcalidrawElement | null;
|
||||
isBindingEnabled: boolean;
|
||||
startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
|
||||
suggestedBindings: SuggestedBinding[];
|
||||
suggestedBinding: NonDeleted<ExcalidrawBindableElement> | null;
|
||||
frameToHighlight: NonDeleted<ExcalidrawFrameLikeElement> | null;
|
||||
frameRendering: {
|
||||
enabled: boolean;
|
||||
@@ -2207,6 +2256,8 @@ export interface AppState {
|
||||
tab: "text-to-diagram" | "mermaid";
|
||||
} | {
|
||||
name: "commandPalette";
|
||||
} | {
|
||||
name: "settings";
|
||||
} | {
|
||||
name: "elementLinkSelector";
|
||||
sourceElementId: ExcalidrawElement["id"];
|
||||
@@ -2283,6 +2334,7 @@ export interface AppState {
|
||||
};
|
||||
allowWheelZoom?: boolean;
|
||||
allowPinchZoom?: boolean;
|
||||
disableContextMenu: boolean;
|
||||
pinnedScripts?: string[];
|
||||
customPens?: any[];
|
||||
currentStrokeOptions?: any;
|
||||
@@ -2329,8 +2381,7 @@ export interface AppState {
|
||||
lockedMultiSelections: {
|
||||
[groupId: string]: true;
|
||||
};
|
||||
/** properties sidebar mode - determines whether to show compact or complete sidebar */
|
||||
stylesPanelMode: "compact" | "full" | "mobile" | "tray";
|
||||
bindMode: BindMode;
|
||||
}
|
||||
export type SearchMatch = {
|
||||
id: string;
|
||||
@@ -2343,7 +2394,7 @@ export type SearchMatch = {
|
||||
showOnCanvas: boolean;
|
||||
}[];
|
||||
};
|
||||
export type UIAppState = Omit<AppState, "suggestedBindings" | "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
||||
export type UIAppState = Omit<AppState, "startBoundElement" | "cursorButton" | "scrollX" | "scrollY">;
|
||||
export type NormalizedZoomValue = number & {
|
||||
_brand: "normalizedZoom";
|
||||
};
|
||||
@@ -2495,6 +2546,12 @@ export type UIOptions = Partial<{
|
||||
tools: {
|
||||
image: boolean;
|
||||
};
|
||||
/**
|
||||
* Optionally control the editor form factor and desktop UI mode from the host app.
|
||||
* If not provided, we will take care of it internally.
|
||||
*/
|
||||
formFactor?: EditorInterface["formFactor"];
|
||||
desktopUIMode?: EditorInterface["desktopUIMode"];
|
||||
/** @deprecated does nothing. Will be removed in 0.15 */
|
||||
welcomeScreen?: boolean;
|
||||
}>;
|
||||
@@ -2525,7 +2582,7 @@ export type AppClassProperties = {
|
||||
mimeType: ValueOf<typeof IMAGE_MIME_TYPES>;
|
||||
}>;
|
||||
files: BinaryFiles;
|
||||
device: App["device"];
|
||||
editorInterface: App["editorInterface"];
|
||||
scene: App["scene"];
|
||||
syncActionResult: App["syncActionResult"];
|
||||
fonts: App["fonts"];
|
||||
@@ -2556,6 +2613,7 @@ export type AppClassProperties = {
|
||||
onPointerUpEmitter: App["onPointerUpEmitter"];
|
||||
updateEditorAtom: App["updateEditorAtom"];
|
||||
onPointerDownEmitter: App["onPointerDownEmitter"];
|
||||
bindModeHandler: App["bindModeHandler"];
|
||||
};
|
||||
export type PointerDownState = Readonly<{
|
||||
origin: Readonly<{
|
||||
@@ -2629,11 +2687,15 @@ export interface ExcalidrawImperativeAPI {
|
||||
};
|
||||
setForceRenderAllEmbeddables: InstanceType<typeof App>["setForceRenderAllEmbeddables"];
|
||||
zoomToFit: InstanceType<typeof App>["zoomToFit"];
|
||||
refreshEditorBreakpoints: InstanceType<typeof App>["refreshEditorBreakpoints"];
|
||||
refreshEditorInterface: InstanceType<typeof App>["refreshEditorInterface"];
|
||||
isTouchScreen: InstanceType<typeof App>["isTouchScreen"];
|
||||
setTrayModeEnabled: InstanceType<typeof App>["setTrayModeEnabled"];
|
||||
setDesktopUIMode: InstanceType<typeof App>["setDesktopUIMode"];
|
||||
setMobileModeAllowed: InstanceType<typeof App>["setMobileModeAllowed"];
|
||||
isTrayModeEnabled: InstanceType<typeof App>["isTrayModeEnabled"];
|
||||
getColorAtScenePoint: InstanceType<typeof App>["getColorAtScenePoint"];
|
||||
startLineEditor: InstanceType<typeof App>["startLineEditor"];
|
||||
refreshAllArrows: InstanceType<typeof App>["refreshAllArrows"];
|
||||
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
||||
getAppState: () => InstanceType<typeof App>["state"];
|
||||
getFiles: () => InstanceType<typeof App>["files"];
|
||||
@@ -2650,12 +2712,12 @@ export interface ExcalidrawImperativeAPI {
|
||||
bringForward: (elements: readonly ExcalidrawElement[]) => void;
|
||||
sendToBack: (elements: readonly ExcalidrawElement[]) => void;
|
||||
bringToFront: (elements: readonly ExcalidrawElement[]) => void;
|
||||
setMobileModeAllowed: (allow: boolean) => void;
|
||||
setActiveTool: InstanceType<typeof App>["setActiveTool"];
|
||||
setCursor: InstanceType<typeof App>["setCursor"];
|
||||
resetCursor: InstanceType<typeof App>["resetCursor"];
|
||||
toggleSidebar: InstanceType<typeof App>["toggleSidebar"];
|
||||
getHTMLIFrameElement: InstanceType<typeof App>["getHTMLIFrameElement"];
|
||||
getEditorInterface: () => EditorInterface;
|
||||
/**
|
||||
* Disables rendering of frames (including element clipping), but currently
|
||||
* the frames are still interactive in edit mode. As such, this API should be
|
||||
@@ -2669,18 +2731,6 @@ export interface ExcalidrawImperativeAPI {
|
||||
onScrollChange: (callback: (scrollX: number, scrollY: number, zoom: Zoom) => void) => UnsubscribeCallback;
|
||||
onUserFollow: (callback: (payload: OnUserFollowedPayload) => void) => UnsubscribeCallback;
|
||||
}
|
||||
export type Device = Readonly<{
|
||||
viewport: {
|
||||
isMobile: boolean;
|
||||
isLandscape: boolean;
|
||||
};
|
||||
editor: {
|
||||
isMobile: boolean;
|
||||
canFitSidebar: boolean;
|
||||
};
|
||||
isTouchScreen: boolean;
|
||||
isTrayMode: boolean;
|
||||
}>;
|
||||
export type FrameNameBounds = {
|
||||
x: number;
|
||||
y: number;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
|
||||
This script generates a linear (horizontal) calendar for a specified year, with days flowing left to right and months as rows.
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
- Horizontal timeline layout with days of the week as columns
|
||||
- Month names displayed on both left and right sides
|
||||
- Weekend days (Saturday & Sunday) highlighted
|
||||
- Day-of-week headers at top and bottom
|
||||
|
||||
## Customizable Colors
|
||||
|
||||
You can personalize the calendar's appearance by defining your own colors:
|
||||
|
||||
1. Create two rectangles in your design.
|
||||
2. Select both rectangles before running the script:
|
||||
• The **fill and stroke colors of the first rectangle** will be applied to weekdays.
|
||||
• The **fill and stroke colors of the second rectangle** will be used for weekends.
|
||||
|
||||
If no rectangles are selected, the default color schema will be used (white and light blue-gray for weekends).
|
||||
|
||||
```javascript
|
||||
*/
|
||||
|
||||
// -------------------------------------
|
||||
// Constants initiation
|
||||
// -------------------------------------
|
||||
|
||||
const CELL_WIDTH = 176; // Width of each day cell
|
||||
const CELL_HEIGHT = 288; // Height of each day cell
|
||||
const START_X = 0; // X start position
|
||||
const START_Y = 0; // Y start position
|
||||
const ROW_SPACING = 32; // Space between month rows
|
||||
const MONTH_LABEL_WIDTH = 240; // Space for month labels on sides
|
||||
|
||||
// Colors
|
||||
let COLOR_WEEKEND = "#e8eaed";
|
||||
let COLOR_WEEKDAY = "#ffffff";
|
||||
let COLOR_TEXT = "#000000";
|
||||
let COLOR_WEEKEND_TEXT = "#000000";
|
||||
let COLOR_HEADER_TEXT = "#000000";
|
||||
const COLOR_STROKE = "#d0d4db";
|
||||
let STROKE_WIDTH = 1;
|
||||
let FILLSTYLE = "solid";
|
||||
const ROUGHNESS = 0; // 0 = Architect, 1 = Artist, 2 = Cartoonist
|
||||
const FONT_FAMILY = 3; // 1 = Virgil, 2 = Helvetica, 3 = Cascadia (code), 4 = Little One
|
||||
|
||||
// Font sizes
|
||||
const FONT_SIZE_DAY = 56;
|
||||
const FONT_SIZE_HEADER = 48;
|
||||
const FONT_SIZE_MONTH = 64;
|
||||
const FONT_SIZE_YEAR = 112;
|
||||
|
||||
// Day constants
|
||||
const SATURDAY = 6;
|
||||
const SUNDAY = 0;
|
||||
const JANUARY = 0;
|
||||
const FIRST_DAY_OF_THE_MONTH = 1;
|
||||
|
||||
// Day names (short)
|
||||
const DAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
|
||||
|
||||
// Month names (short)
|
||||
const MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||
|
||||
// Number of day columns needed (max 37 to cover all possible month alignments: 6 days offset + 31 days)
|
||||
const NUM_COLUMNS = 37;
|
||||
|
||||
// -------------------------------------
|
||||
|
||||
// Ask for requested Year
|
||||
let requestedYear = parseFloat(new Date().getFullYear());
|
||||
requestedYear = parseFloat(await utils.inputPrompt("Year?", requestedYear, requestedYear));
|
||||
if (isNaN(requestedYear)) {
|
||||
new Notice("Invalid number");
|
||||
return;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Use selected elements for calendar style
|
||||
// -------------------------------------
|
||||
|
||||
let elements = ea.getViewSelectedElements();
|
||||
if (elements.length >= 1) {
|
||||
COLOR_WEEKDAY = elements[0].backgroundColor;
|
||||
FILLSTYLE = elements[0].fillStyle;
|
||||
STROKE_WIDTH = elements[0].strokeWidth;
|
||||
}
|
||||
if (elements.length >= 2) {
|
||||
COLOR_WEEKEND = elements[1].backgroundColor;
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Helper function to get days in a month
|
||||
// -------------------------------------
|
||||
|
||||
function getDaysInMonth(year, month) {
|
||||
return new Date(year, month + 1, 0).getDate();
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Helper function to get the day of week for first day of month
|
||||
// -------------------------------------
|
||||
|
||||
function getFirstDayOfMonth(year, month) {
|
||||
return new Date(year, month, 1).getDay();
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Draw day-of-week headers
|
||||
// -------------------------------------
|
||||
|
||||
function drawDayHeaders(yPosition) {
|
||||
ea.style.fontSize = FONT_SIZE_HEADER;
|
||||
ea.style.strokeColor = COLOR_TEXT;
|
||||
ea.style.fontFamily = FONT_FAMILY;
|
||||
|
||||
for (let col = 0; col < NUM_COLUMNS; col++) {
|
||||
const dayIndex = col % 7;
|
||||
const x = START_X + MONTH_LABEL_WIDTH + (col * CELL_WIDTH);
|
||||
|
||||
// Center the text in the cell (approximate width of 2 chars)
|
||||
const textX = x + (CELL_WIDTH / 2) - (FONT_SIZE_HEADER * 0.6);
|
||||
ea.addText(textX, yPosition, DAY_NAMES[dayIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Draw month row
|
||||
// -------------------------------------
|
||||
|
||||
function drawMonthRow(year, month, rowIndex) {
|
||||
const daysInMonth = getDaysInMonth(year, month);
|
||||
const firstDayOfWeek = getFirstDayOfMonth(year, month);
|
||||
const y = START_Y + 160 + (rowIndex * (CELL_HEIGHT + ROW_SPACING));
|
||||
|
||||
// Draw month label on the left
|
||||
ea.style.fontSize = FONT_SIZE_MONTH;
|
||||
ea.style.strokeColor = COLOR_TEXT;
|
||||
ea.style.fontFamily = FONT_FAMILY;
|
||||
const monthLabelY = y + (CELL_HEIGHT / 2) - (FONT_SIZE_MONTH / 2);
|
||||
ea.addText(START_X, monthLabelY, MONTH_NAMES[month]);
|
||||
|
||||
// Draw day cells
|
||||
for (let day = 1; day <= daysInMonth; day++) {
|
||||
const date = new Date(year, month, day);
|
||||
const dayOfWeek = date.getDay();
|
||||
const col = firstDayOfWeek + day - 1; // Column position based on day of week alignment
|
||||
|
||||
const x = START_X + MONTH_LABEL_WIDTH + (col * CELL_WIDTH);
|
||||
const isWeekend = dayOfWeek === SATURDAY || dayOfWeek === SUNDAY;
|
||||
|
||||
// Set cell style
|
||||
ea.style.backgroundColor = isWeekend ? COLOR_WEEKEND : COLOR_WEEKDAY;
|
||||
ea.style.strokeColor = COLOR_STROKE;
|
||||
ea.style.strokeWidth = STROKE_WIDTH;
|
||||
ea.style.fillStyle = FILLSTYLE;
|
||||
ea.style.roughness = ROUGHNESS;
|
||||
|
||||
// Draw cell rectangle
|
||||
ea.addRect(x, y, CELL_WIDTH, CELL_HEIGHT);
|
||||
|
||||
// Draw day number
|
||||
ea.style.fontSize = FONT_SIZE_DAY;
|
||||
ea.style.strokeColor = COLOR_TEXT;
|
||||
ea.style.fontFamily = FONT_FAMILY;
|
||||
|
||||
// Position the day number at top center of the cell
|
||||
const dayStr = String(day).padStart(2, "0");
|
||||
const charWidth = FONT_SIZE_DAY * 0.6; // Approximate character width
|
||||
const textWidth = dayStr.length * charWidth;
|
||||
const textX = x + (CELL_WIDTH - textWidth) / 2;
|
||||
const textY = y + 32; // 32px padding from top
|
||||
ea.addText(textX, textY, dayStr);
|
||||
}
|
||||
|
||||
// Draw month label on the right
|
||||
ea.style.fontSize = FONT_SIZE_MONTH;
|
||||
ea.style.strokeColor = COLOR_TEXT;
|
||||
const rightLabelX = START_X + MONTH_LABEL_WIDTH + (NUM_COLUMNS * CELL_WIDTH) + 60;
|
||||
ea.addText(rightLabelX, monthLabelY, MONTH_NAMES[month]);
|
||||
}
|
||||
|
||||
// -------------------------------------
|
||||
// Main calendar generation
|
||||
// -------------------------------------
|
||||
|
||||
// Draw year title (centered above calendar)
|
||||
ea.style.fontSize = FONT_SIZE_YEAR;
|
||||
ea.style.strokeColor = COLOR_TEXT;
|
||||
ea.style.fontFamily = FONT_FAMILY;
|
||||
const yearX = START_X + MONTH_LABEL_WIDTH + ((NUM_COLUMNS * CELL_WIDTH) / 2) - 120;
|
||||
ea.addText(yearX, START_Y - 200, String(requestedYear));
|
||||
|
||||
// Draw top day-of-week headers
|
||||
drawDayHeaders(START_Y);
|
||||
|
||||
// Draw all 12 months
|
||||
for (let month = 0; month < 12; month++) {
|
||||
drawMonthRow(requestedYear, month, month);
|
||||
}
|
||||
|
||||
// Draw bottom day-of-week headers
|
||||
const bottomHeaderY = START_Y + 160 + (12 * (CELL_HEIGHT + ROW_SPACING)) + 40;
|
||||
drawDayHeaders(bottomHeaderY);
|
||||
|
||||
await ea.addElementsToView(false, false, true);
|
||||
@@ -0,0 +1,24 @@
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50.097575068473816 56.100231877975375" width="50.097575068473816" height="56.100231877975375" class="excalidraw-svg">
|
||||
<!-- Linear calendar icon (same size/viewBox as original) -->
|
||||
|
||||
<g stroke="#1e1e1e" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" fill="none">
|
||||
<!-- Binding rings -->
|
||||
<path d="M16 3 L16 12" />
|
||||
<path d="M34.5 3 L34.5 12" />
|
||||
|
||||
<!-- Outer calendar body -->
|
||||
<rect x="4" y="9" width="42.097575068473816" height="44.100231877975375" rx="5" ry="5" />
|
||||
|
||||
<!-- Header separator -->
|
||||
<path d="M4 19 L46.097575068473816 19" />
|
||||
|
||||
<!-- A single highlighted date block -->
|
||||
<rect x="10" y="23" width="8" height="8" rx="1.5" ry="1.5" />
|
||||
|
||||
<!-- Linear agenda lines -->
|
||||
<path d="M22 27 L42 27" />
|
||||
<path d="M10 35 L42 35" />
|
||||
<path d="M10 43 L42 43" />
|
||||
<path d="M10 51 L30 51" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 929 B |
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="skip"><path d="m11 19-1.106-.552a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0l4.212 2.106a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619V12"/><path d="M15 5.764V12"/><path d="M18 15v6"/><path d="M21 18h-6"/><path d="M9 3.236v15"/></svg>
|
||||
|
After Width: | Height: | Size: 485 B |
@@ -23,6 +23,8 @@ const HELP_TEXT = `
|
||||
- Additionally if the same color is used as fill and stroke the color can only be mapped once
|
||||
- This is an experimental script - contributions welcome on GitHub via PRs
|
||||
|
||||
😍 If you find this script helpful, please [buy me a coffee ☕](https://ko-fi.com/zsolt).
|
||||
|
||||
<a href="https://www.youtube.com/watch?v=ISuORbVKyhQ" target="_blank"><img src ="https://i.ytimg.com/vi/ISuORbVKyhQ/maxresdefault.jpg" style="max-width:560px; width:100%"></a>
|
||||
|
||||
`;
|
||||
@@ -324,7 +326,7 @@ function slider(contentEl, action, min, max, step, invert) {
|
||||
|
||||
function showModal() {
|
||||
let debounceColorPicker = true;
|
||||
const modal = new ea.obsidian.Modal(app);
|
||||
const modal = new ea.FloatingModal(app);
|
||||
let dirty = false;
|
||||
|
||||
modal.onOpen = async () => {
|
||||
@@ -562,8 +564,6 @@ function showModal() {
|
||||
.setButtonText("Close")
|
||||
.setCta(true)
|
||||
.onClick(() => modal.close()));
|
||||
|
||||
makeModalDraggable(modalEl);
|
||||
|
||||
const maxHeight = Math.round(height * 0.6);
|
||||
const maxWidth = Math.round(width * 0.9);
|
||||
@@ -584,60 +584,6 @@ function showModal() {
|
||||
modal.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add draggable functionality to the modal element.
|
||||
* @param {HTMLElement} modalEl - The modal element to make draggable.
|
||||
*/
|
||||
function makeModalDraggable(modalEl) {
|
||||
let isDragging = false;
|
||||
let startX, startY, initialX, initialY;
|
||||
|
||||
const header = modalEl.querySelector('.modal-titlebar') || modalEl; // Default to modalEl if no titlebar
|
||||
header.style.cursor = 'move';
|
||||
|
||||
const onPointerDown = (e) => {
|
||||
// Ensure the event target isn't an interactive element like slider, button, or input
|
||||
if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON') return;
|
||||
|
||||
isDragging = true;
|
||||
startX = e.clientX;
|
||||
startY = e.clientY;
|
||||
const rect = modalEl.getBoundingClientRect();
|
||||
initialX = rect.left;
|
||||
initialY = rect.top;
|
||||
|
||||
modalEl.style.position = 'absolute';
|
||||
modalEl.style.margin = '0';
|
||||
modalEl.style.left = `${initialX}px`;
|
||||
modalEl.style.top = `${initialY}px`;
|
||||
};
|
||||
|
||||
const onPointerMove = (e) => {
|
||||
if (!isDragging) return;
|
||||
|
||||
const dx = e.clientX - startX;
|
||||
const dy = e.clientY - startY;
|
||||
|
||||
modalEl.style.left = `${initialX + dx}px`;
|
||||
modalEl.style.top = `${initialY + dy}px`;
|
||||
};
|
||||
|
||||
const onPointerUp = () => {
|
||||
isDragging = false;
|
||||
};
|
||||
|
||||
header.addEventListener('pointerdown', onPointerDown);
|
||||
document.addEventListener('pointermove', onPointerMove);
|
||||
document.addEventListener('pointerup', onPointerUp);
|
||||
|
||||
// Clean up event listeners on modal close
|
||||
modalEl.addEventListener('remove', () => {
|
||||
header.removeEventListener('pointerdown', onPointerDown);
|
||||
document.removeEventListener('pointermove', onPointerMove);
|
||||
document.removeEventListener('pointerup', onPointerUp);
|
||||
});
|
||||
}
|
||||
|
||||
function executeChange(isDecrease, step, action) {
|
||||
const modifyStroke = settings[STROKE].value;
|
||||
const modifyBackground = settings[BACKGROUND].value;
|
||||
|
||||
+19
-2
@@ -61,6 +61,7 @@ const SVG_MINIMIZE = ea.obsidian.getIcon("lucide-minimize").outerHTML;
|
||||
const SVG_LASER_ON = ea.obsidian.getIcon("lucide-hand").outerHTML;
|
||||
const SVG_LASER_OFF = ea.obsidian.getIcon("lucide-wand").outerHTML;
|
||||
const SVG_PRINTER = ea.obsidian.getIcon("lucide-printer").outerHTML;
|
||||
const SVG_REFOCUS = ea.obsidian.getIcon("lucide-scan-eye").outerHTML;
|
||||
|
||||
//-------------------------------
|
||||
//utility & convenience functions
|
||||
@@ -500,9 +501,22 @@ const createPresentationNavigationPanel = () => {
|
||||
}
|
||||
});
|
||||
|
||||
el.createEl("button",{
|
||||
attr: {
|
||||
title: "Re-focus current slide (shortcut: HOME)"
|
||||
}
|
||||
}, button => {
|
||||
button.innerHTML = SVG_REFOCUS;
|
||||
button.onclick = () => {
|
||||
debugger;
|
||||
slide--;
|
||||
navigate("fwd");
|
||||
}
|
||||
});
|
||||
|
||||
el.createEl("button",{
|
||||
attr: {
|
||||
title: "Toggle fullscreen. If you hold ALT/OPT when starting the presentation it will not go fullscreen."
|
||||
title: "Toggle fullscreen. If you hold ALT/OPT when starting the presentation it will not go fullscreen. (shortcut: f)"
|
||||
},
|
||||
}, button => {
|
||||
toggleFullscreenButton = button;
|
||||
@@ -591,7 +605,7 @@ const keydownListener = (e) => {
|
||||
navigate("fwd");
|
||||
break;
|
||||
case "Home":
|
||||
slide = -1;
|
||||
slide--;
|
||||
navigate("fwd");
|
||||
break;
|
||||
case "e":
|
||||
@@ -601,6 +615,9 @@ const keydownListener = (e) => {
|
||||
exitPresentation(true);
|
||||
})()
|
||||
break;
|
||||
case "f":
|
||||
toggleFullscreen();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
[{"fname":"Mindmap connector.md","mtime":1658686599427},{"fname":"Mindmap connector.svg","mtime":1658686599427},{"fname":"Add Connector Point.md","mtime":1735420748564},{"fname":"Add Connector Point.svg","mtime":1645944722000},{"fname":"Add Link to Existing File and Open.md","mtime":1647807918345},{"fname":"Add Link to Existing File and Open.svg","mtime":1645964261000},{"fname":"Add Link to New Page and Open.md","mtime":1654168862138},{"fname":"Add Link to New Page and Open.svg","mtime":1645960639000},{"fname":"Add Next Step in Process.md","mtime":1688304760357},{"fname":"Add Next Step in Process.svg","mtime":1645960639000},{"fname":"Box Each Selected Groups.md","mtime":1645305706000},{"fname":"Box Each Selected Groups.svg","mtime":1645967510000},{"fname":"Box Selected Elements.md","mtime":1645305706000},{"fname":"Box Selected Elements.svg","mtime":1645960639000},{"fname":"Change shape of selected elements.md","mtime":1652701169236},{"fname":"Change shape of selected elements.svg","mtime":1645960775000},{"fname":"Connect elements.md","mtime":1645305706000},{"fname":"Connect elements.svg","mtime":1645960639000},{"fname":"Convert freedraw to line.md","mtime":1645305706000},{"fname":"Convert freedraw to line.svg","mtime":1645960639000},{"fname":"Convert selected text elements to sticky notes.md","mtime":1670169501383},{"fname":"Convert selected text elements to sticky notes.svg","mtime":1645960639000},{"fname":"Convert text to link with folder and alias.md","mtime":1641639819000},{"fname":"Convert text to link with folder and alias.svg","mtime":1645960639000},{"fname":"Copy Selected Element Styles to Global.md","mtime":1642232088000},{"fname":"Copy Selected Element Styles to Global.svg","mtime":1645960639000},{"fname":"Create new markdown file and embed into active drawing.md","mtime":1640866935000},{"fname":"Create new markdown file and embed into active drawing.svg","mtime":1645960639000},{"fname":"Darken background color.md","mtime":1663059051059},{"fname":"Darken background color.svg","mtime":1645960639000},{"fname":"Elbow connectors.md","mtime":1671126911490},{"fname":"Elbow connectors.svg","mtime":1645960639000},{"fname":"Expand rectangles horizontally keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles horizontally keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles horizontally.md","mtime":1644950235000},{"fname":"Expand rectangles horizontally.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles vertically keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically.md","mtime":1658686599427},{"fname":"Expand rectangles vertically.svg","mtime":1645967510000},{"fname":"Fixed horizontal distance between centers.md","mtime":1646743234000},{"fname":"Fixed horizontal distance between centers.svg","mtime":1645960639000},{"fname":"Fixed inner distance.md","mtime":1646743234000},{"fname":"Fixed inner distance.svg","mtime":1645960639000},{"fname":"Fixed spacing.md","mtime":1646743234000},{"fname":"Fixed spacing.svg","mtime":1645967510000},{"fname":"Fixed vertical distance between centers.md","mtime":1646743234000},{"fname":"Fixed vertical distance between centers.svg","mtime":1645967510000},{"fname":"Fixed vertical distance.md","mtime":1646743234000},{"fname":"Fixed vertical distance.svg","mtime":1645967510000},{"fname":"Lighten background color.md","mtime":1663059051059},{"fname":"Lighten background color.svg","mtime":1645959546000},{"fname":"Modify background color opacity.md","mtime":1644924415000},{"fname":"Modify background color opacity.svg","mtime":1645944722000},{"fname":"Normalize Selected Arrows.md","mtime":1670403743278},{"fname":"Normalize Selected Arrows.svg","mtime":1645960639000},{"fname":"Organic Line.md","mtime":1672920172531},{"fname":"Organic Line.svg","mtime":1645964261000},{"fname":"Organic Line Legacy.md","mtime":1690607372668},{"fname":"Organic Line Legacy.svg","mtime":1690607372668},{"fname":"README.md","mtime":1645175700000},{"fname":"Repeat Elements.md","mtime":1663059051059},{"fname":"Repeat Elements.svg","mtime":1645960639000},{"fname":"Reverse arrows.md","mtime":1645305706000},{"fname":"Reverse arrows.svg","mtime":1645960639000},{"fname":"Scribble Helper.md","mtime":1747585400113},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1748189277Line truncated
|
||||
[{"fname":"Mindmap connector.md","mtime":1658686599427},{"fname":"Mindmap connector.svg","mtime":1658686599427},{"fname":"Add Connector Point.md","mtime":1735420748564},{"fname":"Add Connector Point.svg","mtime":1645944722000},{"fname":"Add Link to Existing File and Open.md","mtime":1647807918345},{"fname":"Add Link to Existing File and Open.svg","mtime":1645964261000},{"fname":"Add Link to New Page and Open.md","mtime":1654168862138},{"fname":"Add Link to New Page and Open.svg","mtime":1645960639000},{"fname":"Add Next Step in Process.md","mtime":1688304760357},{"fname":"Add Next Step in Process.svg","mtime":1645960639000},{"fname":"Box Each Selected Groups.md","mtime":1645305706000},{"fname":"Box Each Selected Groups.svg","mtime":1645967510000},{"fname":"Box Selected Elements.md","mtime":1645305706000},{"fname":"Box Selected Elements.svg","mtime":1645960639000},{"fname":"Change shape of selected elements.md","mtime":1652701169236},{"fname":"Change shape of selected elements.svg","mtime":1645960775000},{"fname":"Connect elements.md","mtime":1645305706000},{"fname":"Connect elements.svg","mtime":1645960639000},{"fname":"Convert freedraw to line.md","mtime":1645305706000},{"fname":"Convert freedraw to line.svg","mtime":1645960639000},{"fname":"Convert selected text elements to sticky notes.md","mtime":1670169501383},{"fname":"Convert selected text elements to sticky notes.svg","mtime":1645960639000},{"fname":"Convert text to link with folder and alias.md","mtime":1641639819000},{"fname":"Convert text to link with folder and alias.svg","mtime":1645960639000},{"fname":"Copy Selected Element Styles to Global.md","mtime":1642232088000},{"fname":"Copy Selected Element Styles to Global.svg","mtime":1645960639000},{"fname":"Create new markdown file and embed into active drawing.md","mtime":1640866935000},{"fname":"Create new markdown file and embed into active drawing.svg","mtime":1645960639000},{"fname":"Darken background color.md","mtime":1663059051059},{"fname":"Darken background color.svg","mtime":1645960639000},{"fname":"Elbow connectors.md","mtime":1671126911490},{"fname":"Elbow connectors.svg","mtime":1645960639000},{"fname":"Expand rectangles horizontally keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles horizontally keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles horizontally.md","mtime":1644950235000},{"fname":"Expand rectangles horizontally.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles vertically keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically.md","mtime":1658686599427},{"fname":"Expand rectangles vertically.svg","mtime":1645967510000},{"fname":"Fixed horizontal distance between centers.md","mtime":1646743234000},{"fname":"Fixed horizontal distance between centers.svg","mtime":1645960639000},{"fname":"Fixed inner distance.md","mtime":1646743234000},{"fname":"Fixed inner distance.svg","mtime":1645960639000},{"fname":"Fixed spacing.md","mtime":1646743234000},{"fname":"Fixed spacing.svg","mtime":1645967510000},{"fname":"Fixed vertical distance between centers.md","mtime":1646743234000},{"fname":"Fixed vertical distance between centers.svg","mtime":1645967510000},{"fname":"Fixed vertical distance.md","mtime":1646743234000},{"fname":"Fixed vertical distance.svg","mtime":1645967510000},{"fname":"Lighten background color.md","mtime":1663059051059},{"fname":"Lighten background color.svg","mtime":1645959546000},{"fname":"Modify background color opacity.md","mtime":1644924415000},{"fname":"Modify background color opacity.svg","mtime":1645944722000},{"fname":"Normalize Selected Arrows.md","mtime":1670403743278},{"fname":"Normalize Selected Arrows.svg","mtime":1645960639000},{"fname":"Organic Line.md","mtime":1672920172531},{"fname":"Organic Line.svg","mtime":1645964261000},{"fname":"Organic Line Legacy.md","mtime":1690607372668},{"fname":"Organic Line Legacy.svg","mtime":1690607372668},{"fname":"README.md","mtime":1645175700000},{"fname":"Repeat Elements.md","mtime":1663059051059},{"fname":"Repeat Elements.svg","mtime":1645960639000},{"fname":"Reverse arrows.md","mtime":1645305706000},{"fname":"Reverse arrows.svg","mtime":1645960639000},{"fname":"Scribble Helper.md","mtime":1747585400113},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1748189277Line truncated
|
||||
@@ -55,6 +55,7 @@ These are the scripts I use most often. I tried to order them by importance, but
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Excalidraw%20Writing%20Machine.svg"/></div>|[[#Excalidraw Writing Machine]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20freedraw%20to%20line.svg"/></div>|[[#Convert freedraw to line]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Crop%20Vintage%20Mask.svg"/></div>|[[#Crop Vintage Mask]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20Builder.svg"/></div>|[[#Mindmap Builder]]|
|
||||
|
||||
## Layout and Organization
|
||||
**Keywords**: Design, Placement, Arrangement, Structure, Formatting, Alignment
|
||||
@@ -76,6 +77,7 @@ These are the scripts I use most often. I tried to order them by importance, but
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Fixed%20vertical%20distance.svg"/></div>|[[#Fixed vertical distance]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Golden%20Ratio.svg"/></div>|[[#Golden Ratio]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Grid%20Selected%20Images.svg"/></div>|[[#Grid selected images]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-mindmap-builder.png"/></div>|[[#Mindmap Builder]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20format.svg"/></div>|[[#Mindmap format]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Printable%20Layout%20Wizard.svg"/></div>|[[#Printable Layout Wizard]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Zoom%20to%20Fit%20Selected%20Elements.svg"/></div>|[[#Zoom to Fit Selected Elements]]|
|
||||
@@ -181,6 +183,7 @@ These are the scripts I use most often. I tried to order them by importance, but
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20freedraw%20to%20line.svg"/></div>|[[#Convert freedraw to line]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Deconstruct%20selected%20elements%20into%20new%20drawing.svg"/></div>|[[#Deconstruct selected elements into new drawing]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Full-Year%20Calendar%20Generator.svg"/></div>|[[#Full-Year Calendar Generator]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Linear%20Calendar%20Generator.svg"/></div>|[[#Linear Calendar Generator]]|
|
||||
|
||||
## Masking and cropping
|
||||
**Keywords**: Crop, Mask, Transform images
|
||||
@@ -457,6 +460,18 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/1-2-3'>@1-2-3</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Lighten%20background%20color.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">This script lightens the background color of the selected element by 2% at a time. You can use this script several times until you are satisfied. It is recommended to set a shortcut key for this script so that you can quickly try to DARKEN and LIGHTEN the color effect.In contrast to the `Modify background color opacity` script, the advantage is that the background color of the element is not affected by the canvas color, and the color value does not appear in a strange rgba() form.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/darken-lighten-background-color.png'></td></tr></table>
|
||||
|
||||
## Linear Calendar Generator
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Linear%20Calendar%20Generator.md
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/iwanhoogendoorn'>@iwanhoogendoorn</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Linear%20Calendar%20Generator.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Generates a complete calendar for a specified year.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-Linear-Calendar-Generator.jpg'></td></tr></table>
|
||||
|
||||
## Mindmap Builder
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20Builder.md
|
||||
```
|
||||
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Mindmap%20Builder.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Rapid mind mapping workflow driven by keyboard shortcuts: add sibling/child nodes, auto-layout and branch styling, quick navigation, optional recursive grouping, and Markdown copy/paste import/export for bullet-list sync.<br><a href="https://www.youtube.com/watch?v=dZguonMP2KU" target="_blank"><img src ="https://i.ytimg.com/vi/dZguonMP2KU/maxresdefault.jpg" style="width:400px;"></a><br><a href='https://youtu.be/dZguonMP2KU' target='_blank'>Link to video on YouTube</a><br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-mindmap-builder.png'></td></tr></table>
|
||||
|
||||
## Mindmap connector
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20connector.md
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 344 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 76 KiB |
+2
-2
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.17.0-beta-6",
|
||||
"version": "2.19.0-beta-1",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"description": "Sketch Your Mind. An Obsidian plugin to edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
"authorUrl": "https://excalidraw-obsidian.online",
|
||||
"isDesktopOnly": false
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.16.1",
|
||||
"version": "2.18.3",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"description": "Sketch Your Mind. An Obsidian plugin to edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
"authorUrl": "https://excalidraw-obsidian.online",
|
||||
"fundingUrl": "https://ko-fi.com/zsolt",
|
||||
"helpUrl": "https://github.com/zsviczian/obsidian-excalidraw-plugin#readme",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
}
|
||||
Generated
+5
-4
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
"@zsviczian/excalidraw": "0.18.0-42",
|
||||
"@zsviczian/excalidraw": "0.18.0-63",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -3484,9 +3484,10 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@zsviczian/excalidraw": {
|
||||
"version": "0.18.0-42",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-42.tgz",
|
||||
"integrity": "sha512-XskVyobY5YAnfC+TeQXi+3/o0QfLLSTL/XUMm8CT6asCY9ry9SnPpMCpHa9SRQyR1qPPY2Vxw/8+xc5Vev8QSA==",
|
||||
"version": "0.18.0-63",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-63.tgz",
|
||||
"integrity": "sha512-5pzmT55fmYNZzs0Wi66dK5cEwNmOKsZynSLc/WijdL4epe5sOl5q2wP+mTOkXJv/rvclSSMkmycg2FlZAFWOPg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "6.0.2",
|
||||
"@excalidraw/random-username": "1.1.0",
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-48",
|
||||
"@zsviczian/excalidraw": "0.18.0-63",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
+4
-2
@@ -188,8 +188,10 @@ const BUILD_CONFIG = {
|
||||
},
|
||||
}),
|
||||
postprocess([
|
||||
[/React=require\("react"\),state=require\("@codemirror\/state"\),view=require\("@codemirror\/view"\)/,
|
||||
`state=require("@codemirror/state"),view=require("@codemirror/view")` + packageString],
|
||||
[
|
||||
/(var[^;]*?),\s*React\s*=\s*require\(["']react["']\)([^;]*;)/,
|
||||
(_, g1, g2) => `${g1}${g2}${packageString}`
|
||||
],
|
||||
]),
|
||||
] : [
|
||||
postprocess([ [/var React = require\('react'\);/, packageString] ]),
|
||||
|
||||
@@ -590,7 +590,7 @@ function main() {
|
||||
const excalidrawLibFunctionsSection = buildExcalidrawLibFunctionsSection();
|
||||
|
||||
const combined =
|
||||
AI_TRAINING_INTRO +
|
||||
(AI_TRAINING_INTRO +
|
||||
'\n---\n\n' +
|
||||
typeDefContent.trim() +
|
||||
'\n\n---\n\n' +
|
||||
@@ -600,7 +600,10 @@ function main() {
|
||||
'\n---\n\n' +
|
||||
scriptLibContent.trim() +
|
||||
startupSection +
|
||||
'\n';
|
||||
'\n')
|
||||
.replaceAll("https://youtu.be/", "YouTube: ")
|
||||
.replaceAll("https://www.youtube.com/watch?v=", "YouTube: ")
|
||||
.replaceAll("https://www.youtube.com/", "YouTube: "); // prevent accidental link triggering
|
||||
|
||||
fs.writeFileSync(AI_TRAINING_OUT, combined, 'utf8');
|
||||
console.log('[script-library] Wrote:', AI_TRAINING_OUT);
|
||||
|
||||
@@ -879,7 +879,7 @@ export const penIcon = (pen: PenStyle) => {
|
||||
}
|
||||
|
||||
export const stringToSVG = (svg: string) => {
|
||||
if(svg.match('class="skip"')) {
|
||||
if(svg.match(/class=("|')[^"']*(lucide|skip)[^"']*("|')/)) {
|
||||
return <div dangerouslySetInnerHTML={{__html: svg}}></div>
|
||||
}
|
||||
svg = svg
|
||||
|
||||
@@ -86,7 +86,6 @@ export const obsidianToExcalidrawMap: { [key: string]: string } = {
|
||||
export let {
|
||||
sceneCoordsToViewportCoords,
|
||||
viewportCoordsToSceneCoords,
|
||||
determineFocusDistance,
|
||||
intersectElementWithLine,
|
||||
getCommonBoundingBox,
|
||||
getMaximumGroups,
|
||||
@@ -120,7 +119,6 @@ export function updateExcalidrawLib() {
|
||||
const requiredFunctions = [
|
||||
'sceneCoordsToViewportCoords',
|
||||
'viewportCoordsToSceneCoords',
|
||||
'determineFocusDistance',
|
||||
'intersectElementWithLine',
|
||||
'getCommonBoundingBox',
|
||||
'measureText',
|
||||
@@ -138,7 +136,6 @@ export function updateExcalidrawLib() {
|
||||
({
|
||||
sceneCoordsToViewportCoords,
|
||||
viewportCoordsToSceneCoords,
|
||||
determineFocusDistance,
|
||||
intersectElementWithLine,
|
||||
getCommonBoundingBox,
|
||||
getMaximumGroups,
|
||||
@@ -249,6 +246,7 @@ export const FRONTMATTER_KEYS:{[key:string]: {name: string, type: string, depric
|
||||
"export-padding": {name: "excalidraw-export-padding", type: "number"},
|
||||
"export-pngscale": {name: "excalidraw-export-pngscale", type: "number"},
|
||||
"export-embed-scene": {name: "excalidraw-export-embed-scene", type: "checkbox"},
|
||||
"export-internal-links": {name: "excalidraw-export-internal-links", type: "checkbox"},
|
||||
"link-prefix": {name: "excalidraw-link-prefix", type: "text"},
|
||||
"url-prefix": {name: "excalidraw-url-prefix", type: "text"},
|
||||
"link-brackets": {name: "excalidraw-link-brackets", type: "checkbox"},
|
||||
|
||||
+13
-2
@@ -90,6 +90,8 @@ import { CommandManager } from "./managers/CommandManager";
|
||||
import { EventManager } from "./managers/EventManager";
|
||||
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
|
||||
import en from "src/lang/locale/en";
|
||||
import { get } from "http";
|
||||
import { getHighlightColor } from "src/utils/dynamicStyling";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare const INITIAL_TIMESTAMP: number;
|
||||
@@ -116,6 +118,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
public settings: ExcalidrawSettings;
|
||||
public activeExcalidrawView: ExcalidrawView = null;
|
||||
public lastActiveExcalidrawFilePath: string = null;
|
||||
public lastActiveExcalidrawLeafID: string = null;
|
||||
public hover: { linkText: string; sourcePath: string } = {
|
||||
linkText: null,
|
||||
sourcePath: null,
|
||||
@@ -558,7 +561,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
let fontMetrics = f.extension.startsWith("woff") ? undefined : await getFontMetrics(fourthFontDataURL, "Local Font");
|
||||
|
||||
if (!fontMetrics) {
|
||||
console.log("Font Metrics not found, using default");
|
||||
//console.log("Font Metrics not found, using default");
|
||||
fontMetrics = {
|
||||
unitsPerEm: 1000,
|
||||
ascender: 750,
|
||||
@@ -1265,10 +1268,14 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
return JSON_parse(this.settings.library);
|
||||
}
|
||||
|
||||
public setStencilLibrary(library: {}) {
|
||||
public async setStencilLibrary(library: {}) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setStencilLibrary,`ExcalidrawPlugin.setStencilLibrary`, library);
|
||||
this.settings.library = "deprecated";
|
||||
if(JSON.stringify(this.settings.library2) === JSON.stringify(library)) {
|
||||
return;
|
||||
}
|
||||
this.settings.library2 = library;
|
||||
await this.saveSettings();
|
||||
}
|
||||
|
||||
public triggerEmbedUpdates(filepath?: string) {
|
||||
@@ -1486,4 +1493,8 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
public getObsidianDevice(): DeviceType {
|
||||
return DEVICE;
|
||||
}
|
||||
|
||||
public getHighlightColor(sceneBgColor: string, opacity: number = 1): string {
|
||||
return getHighlightColor(this.ea, sceneBgColor, opacity);
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,7 @@ import { carveOutImage, carveOutPDF, createImageCropperFile } from "../../utils/
|
||||
import { showFrameSettings } from "../../shared/Dialogs/FrameSettings";
|
||||
import { insertImageToView } from "../../utils/excalidrawViewUtils";
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -987,6 +988,7 @@ export class CommandManager {
|
||||
name: t("TOGGLE_LEFTHANDED_MODE"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
if (checking) {
|
||||
if(DEVICE.isMobile) return false;
|
||||
if(this.app.workspace.getActiveViewOfType(ExcalidrawView)) {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
const api = view?.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
@@ -1010,6 +1012,24 @@ export class CommandManager {
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "toggle-enable-context-menu",
|
||||
name: t("TOGGLE_ENABLE_CONTEXT_MENU"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
if (checking) {
|
||||
if(this.app.workspace.getActiveViewOfType(ExcalidrawView)) {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
const api = view?.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
view.toggleEnableContextMenu();
|
||||
return true;
|
||||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "flip-image",
|
||||
name: t("FLIP_IMAGE"),
|
||||
@@ -1640,7 +1660,7 @@ export class CommandManager {
|
||||
|
||||
this.addCommand({
|
||||
id: "tray-mode",
|
||||
name: t("TRAY_MODE"),
|
||||
name: t("UI_MODE"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
if (checking) {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
@@ -1655,7 +1675,8 @@ export class CommandManager {
|
||||
}
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view && view.excalidrawAPI) {
|
||||
view.toggleTrayMode();
|
||||
const uiModeSettings = new UIModeSettings(this.plugin);
|
||||
uiModeSettings.open();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -53,6 +53,10 @@ export class EventManager {
|
||||
window.clearTimeout(this.leafChangeTimeout);
|
||||
this.leafChangeTimeout = null;
|
||||
}
|
||||
if(this.debunceActiveLeafChangeHandlerTimer) {
|
||||
window.clearTimeout(this.debunceActiveLeafChangeHandlerTimer);
|
||||
this.debunceActiveLeafChangeHandlerTimer = null;
|
||||
}
|
||||
this.removeEventLisnters.forEach((removeEventListener) =>
|
||||
removeEventListener(),
|
||||
);
|
||||
@@ -189,6 +193,15 @@ export class EventManager {
|
||||
this.plugin.lastPDFLeafID = leaf.id;
|
||||
}
|
||||
|
||||
if (leaf.view && leaf.view.getViewType() === VIEW_TYPE_EXCALIDRAW) {
|
||||
this.plugin.lastActiveExcalidrawLeafID = leaf.id;
|
||||
} else {
|
||||
const lastLeaf = this.app.workspace.getLeafById(this.plugin.lastActiveExcalidrawLeafID);
|
||||
if(!lastLeaf || !(lastLeaf.view instanceof ExcalidrawView)) {
|
||||
this.plugin.lastActiveExcalidrawLeafID = null;
|
||||
}
|
||||
}
|
||||
|
||||
if(this.leafChangeTimeout) {
|
||||
window.clearTimeout(this.leafChangeTimeout);
|
||||
}
|
||||
|
||||
@@ -136,8 +136,17 @@ const _getPNG = async ({imgAttributes,filenameParts,theme,cacheReady,img,file,ex
|
||||
if (!png) {
|
||||
return null;
|
||||
}
|
||||
img.src = URL.createObjectURL(png);
|
||||
cacheReady && imageCache.addImageToCache(cacheKey, img.src, png);
|
||||
const blobUrl = URL.createObjectURL(png);
|
||||
img.src = blobUrl;
|
||||
|
||||
// Revoke the ObjectURL after the image loads or fails to prevent memory leaks
|
||||
if (!cacheReady) {
|
||||
const cleanup = () => URL.revokeObjectURL(blobUrl);
|
||||
img.addEventListener('load', cleanup, { once: true });
|
||||
img.addEventListener('error', cleanup, { once: true });
|
||||
}
|
||||
|
||||
cacheReady && imageCache.addImageToCache(cacheKey, blobUrl, png);
|
||||
return img;
|
||||
}
|
||||
|
||||
@@ -382,6 +391,14 @@ const addSVGToImgSrc = (img: HTMLImageElement, svg: SVGSVGElement, cacheReady: b
|
||||
const blob = new Blob([svgString], { type: 'image/svg+xml' });
|
||||
const blobUrl = URL.createObjectURL(blob);
|
||||
img.setAttribute("src", blobUrl);
|
||||
|
||||
// Revoke the ObjectURL after the image loads or fails to prevent memory leaks
|
||||
if (!cacheReady) {
|
||||
const cleanup = () => URL.revokeObjectURL(blobUrl);
|
||||
img.addEventListener('load', cleanup, { once: true });
|
||||
img.addEventListener('error', cleanup, { once: true });
|
||||
}
|
||||
|
||||
cacheReady && imageCache.addImageToCache(cacheKey, blobUrl, blob);
|
||||
return img;
|
||||
}
|
||||
@@ -812,7 +829,10 @@ const tmpObsidianWYSIWYG = async (
|
||||
}
|
||||
if(warningEl) {
|
||||
const dataHeading = warningEl.getAttr("data-heading");
|
||||
const ref = dataHeading.match(/.+(\^(?:group=|area=|frame=|clippedframe=)[A-Za-z0-9_-]{8,21})/)?.[1];
|
||||
const ref = dataHeading.match(/.+(\^(?:group=|area=|frame=|clippedframe=)[A-Za-z0-9_-]{8,21})/)?.[1]
|
||||
// I am unsure if this works with all Obsidian translations,
|
||||
// thus I kept the first with the fix ID length and have the frame name as fallback
|
||||
?? dataHeading.match(/.+(\^(?:group=|area=|frame=|clippedframe=)[\p{L}\p{N}_ -]+)/u)?.[1];
|
||||
if(ref) {
|
||||
attr.fname = file.path + "#" +ref;
|
||||
areaPreview = true;
|
||||
@@ -836,6 +856,13 @@ const tmpObsidianWYSIWYG = async (
|
||||
imgDiv.firstChild.style.maxHeight = "100%";
|
||||
imgDiv.firstChild.style.maxWidth = null;
|
||||
}
|
||||
// Resolve the cyclic size dependency by applying a CSS width and/or height
|
||||
if(!onCanvas && isHoverPopover && imgDiv.firstChild instanceof HTMLImageElement) {
|
||||
internalEmbedDiv.style.setProperty("--popover-width", attr.fwidth + "px");
|
||||
internalEmbedDiv.style.setProperty("--popover-height", attr.fheight + "px");
|
||||
internalEmbedDiv.style.width = "var(--popover-width)";
|
||||
internalEmbedDiv.style.height = "var(--popover-height)";
|
||||
}
|
||||
internalEmbedDiv.appendChild(imgDiv.firstChild);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -41,19 +41,20 @@ export class ObserverManager {
|
||||
this.removeModalContainerObserver();
|
||||
if (this.workspaceDrawerLeftObserver) {
|
||||
this.workspaceDrawerLeftObserver.disconnect();
|
||||
this.workspaceDrawerLeftObserver = null;
|
||||
}
|
||||
if (this.workspaceDrawerRightObserver) {
|
||||
this.workspaceDrawerRightObserver.disconnect();
|
||||
this.workspaceDrawerRightObserver = null;
|
||||
}
|
||||
if (this.fileExplorerObserver) {
|
||||
this.fileExplorerObserver.disconnect();
|
||||
this.fileExplorerObserver = null;
|
||||
}
|
||||
if (this.workspaceDrawerRightObserver) {
|
||||
this.workspaceDrawerRightObserver.disconnect();
|
||||
}
|
||||
if (this.workspaceDrawerLeftObserver) {
|
||||
this.workspaceDrawerLeftObserver.disconnect();
|
||||
}
|
||||
|
||||
this.plugin = null;
|
||||
this.app = null;
|
||||
this.activeViewDoc = null;
|
||||
}
|
||||
|
||||
public addThemeObserver() {
|
||||
|
||||
+65
-72
@@ -26,9 +26,6 @@ import { PENS } from "src/utils/pens";
|
||||
import {
|
||||
addYouTubeThumbnail,
|
||||
fragWithHTML,
|
||||
setDesktopUIMode,
|
||||
setLeftHandedMode,
|
||||
setTrayMode,
|
||||
} from "src/utils/utils";
|
||||
import { imageCache } from "src/shared/ImageCache";
|
||||
import { MultiOptionConfirmationPrompt } from "src/shared/Dialogs/Prompt";
|
||||
@@ -47,8 +44,12 @@ import { getExcalidrawViews } from "src/utils/obsidianUtils";
|
||||
import { createSliderWithText } from "src/utils/sliderUtils";
|
||||
import { PDFExportSettingsComponent, PDFExportSettings } from "src/shared/Dialogs/PDFExportSettingsComponent";
|
||||
import { ContentSearcher } from "src/shared/components/ContentSearcher";
|
||||
import { UIMode, UIModeSettingsComponent } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
import { ScriptSettingValue } from "src/types/excalidrawAutomateTypes";
|
||||
|
||||
export interface ExcalidrawSettings {
|
||||
copyLinkToElemenetAnchorTo100: boolean;
|
||||
copyFrameLinkByName: boolean;
|
||||
disableDoubleClickTextEditing: boolean;
|
||||
folder: string;
|
||||
cropFolder: string;
|
||||
@@ -89,6 +90,8 @@ export interface ExcalidrawSettings {
|
||||
overrideObsidianFontSize: boolean;
|
||||
dynamicStyling: DynamicStyle;
|
||||
isLeftHanded: boolean;
|
||||
desktopUIMode: UIMode;
|
||||
tabletUIMode: UIMode;
|
||||
iframeMatchExcalidrawTheme: boolean;
|
||||
matchTheme: boolean;
|
||||
matchThemeAlways: boolean;
|
||||
@@ -115,6 +118,7 @@ export interface ExcalidrawSettings {
|
||||
focusOnFileTab: boolean;
|
||||
openInMainWorkspace: boolean;
|
||||
showLinkBrackets: boolean;
|
||||
//allowLinkSync: boolean;
|
||||
linkPrefix: string;
|
||||
urlPrefix: string;
|
||||
parseTODO: boolean;
|
||||
@@ -169,18 +173,9 @@ export interface ExcalidrawSettings {
|
||||
mdCSS: string;
|
||||
scriptEngineSettings: {
|
||||
[key:string]: {
|
||||
[key:string]: {
|
||||
value?:string,
|
||||
hidden?: boolean,
|
||||
description?: string,
|
||||
valueset?: string[],
|
||||
height?: number,
|
||||
}
|
||||
[key:string]: ScriptSettingValue;
|
||||
}
|
||||
};
|
||||
defaultTrayMode: boolean;
|
||||
compactModeOnTablets: boolean;
|
||||
compactModeOnDesktops: boolean;
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
compareManifestToPluginVersion: boolean;
|
||||
@@ -216,6 +211,7 @@ export interface ExcalidrawSettings {
|
||||
aiEnabled: boolean,
|
||||
openAIAPIToken: string,
|
||||
openAIDefaultTextModel: string,
|
||||
openAIDefaultTextModelMaxTokens: number,
|
||||
openAIDefaultVisionModel: string,
|
||||
openAIDefaultImageGenerationModel: string,
|
||||
openAIURL: string,
|
||||
@@ -242,6 +238,8 @@ export interface ExcalidrawSettings {
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
copyLinkToElemenetAnchorTo100: false,
|
||||
copyFrameLinkByName: false,
|
||||
disableDoubleClickTextEditing: false,
|
||||
folder: "Excalidraw",
|
||||
cropFolder: "",
|
||||
@@ -282,6 +280,8 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
overrideObsidianFontSize: false,
|
||||
dynamicStyling: "colorful",
|
||||
isLeftHanded: false,
|
||||
desktopUIMode: "tray",
|
||||
tabletUIMode: "compact",
|
||||
iframeMatchExcalidrawTheme: true,
|
||||
matchTheme: false,
|
||||
matchThemeAlways: false,
|
||||
@@ -315,6 +315,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
focusOnFileTab: true,
|
||||
openInMainWorkspace: true,
|
||||
showLinkBrackets: true,
|
||||
//allowLinkSync: true,
|
||||
allowCtrlClick: true,
|
||||
forceWrap: false,
|
||||
pageTransclusionCharLimit: 200,
|
||||
@@ -366,9 +367,6 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
mdBorderColor: "Black",
|
||||
mdCSS: "",
|
||||
scriptEngineSettings: {},
|
||||
defaultTrayMode: true,
|
||||
compactModeOnTablets: true,
|
||||
compactModeOnDesktops: false,
|
||||
previousRelease: "0.0.0",
|
||||
showReleaseNotes: true,
|
||||
compareManifestToPluginVersion: true,
|
||||
@@ -430,6 +428,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
aiEnabled: true,
|
||||
openAIAPIToken: "",
|
||||
openAIDefaultTextModel: "gpt-3.5-turbo-1106",
|
||||
openAIDefaultTextModelMaxTokens: 4096,
|
||||
openAIDefaultVisionModel: "gpt-4o",
|
||||
openAIDefaultImageGenerationModel: "dall-e-3",
|
||||
openAIURL: "https://api.openai.com/v1/chat/completions",
|
||||
@@ -1162,6 +1161,35 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("AI_OPENAI_DEFAULT_MAX_TOKENS_NAME"))
|
||||
.setDesc(fragWithHTML(t("AI_OPENAI_DEFAULT_MAX_TOKENS_DESC")))
|
||||
.addText((text) =>
|
||||
text
|
||||
.setPlaceholder("e.g.: 4096")
|
||||
.setValue(this.plugin.settings.openAIDefaultTextModelMaxTokens.toString())
|
||||
.onChange(async (value) => {
|
||||
const intVal = parseInt(value);
|
||||
if (isNaN(intVal) && value !== "") {
|
||||
text.setValue(this.plugin.settings.openAIDefaultTextModelMaxTokens.toString());
|
||||
return;
|
||||
}
|
||||
if (value === "") {
|
||||
this.plugin.settings.openAIDefaultTextModelMaxTokens = 4096;
|
||||
text.setValue("4096");
|
||||
this.applySettingsUpdate();
|
||||
return;
|
||||
}
|
||||
if (intVal < 0) {
|
||||
text.setValue(this.plugin.settings.openAIDefaultTextModelMaxTokens.toString());
|
||||
return;
|
||||
}
|
||||
this.plugin.settings.openAIDefaultTextModelMaxTokens = intVal;
|
||||
text.setValue(intVal.toString());
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("AI_OPENAI_DEFAULT_VISION_MODEL_NAME"))
|
||||
.setDesc(fragWithHTML(t("AI_OPENAI_DEFAULT_VISION_MODEL_DESC")))
|
||||
@@ -1267,61 +1295,12 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
cls: "excalidraw-setting-h3",
|
||||
});
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("TRAY_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("ARIA_LABEL_TRAY_MODE")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.defaultTrayMode)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.defaultTrayMode = value;
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("PREFER_COMPACT_MODE_DESKTOP_NAME"))
|
||||
.setDesc(fragWithHTML(t("PREFER_COMPACT_MODE_DESKTOP_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.compactModeOnDesktops)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.compactModeOnDesktops = value;
|
||||
setDesktopUIMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("COMPACT_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("COMPACT_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.compactModeOnTablets)
|
||||
.onChange((value) => {
|
||||
this.plugin.settings.compactModeOnTablets = value;
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("LEFTHANDED_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.isLeftHanded)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.isLeftHanded = value;
|
||||
//not clear why I need to do this. If I don't double apply the stylesheet changes
|
||||
//then the style won't be applied in the popout windows
|
||||
setLeftHandedMode(value);
|
||||
setTimeout(()=>setLeftHandedMode(value));
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
new UIModeSettingsComponent(
|
||||
detailsEl,
|
||||
this.plugin.settings,
|
||||
this.app,
|
||||
()=>this.applySettingsUpdate(),
|
||||
).render();
|
||||
addYouTubeThumbnail(detailsEl, "H8Njp7ZXYag",999);
|
||||
|
||||
detailsEl = displayDetailsEl.createEl("details");
|
||||
@@ -1896,6 +1875,20 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}),
|
||||
);
|
||||
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2571
|
||||
//Solution is not completely straightforward, there is a link update in Excalidraw Data that also needs to be handled
|
||||
/*new Setting(detailsEl)
|
||||
.setName(t("LINK_DETECTION_NAME"))
|
||||
.setDesc(fragWithHTML(t("LINK_DETECTION_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!this.plugin.settings.allowLinkSync)
|
||||
.onChange(value => {
|
||||
this.plugin.settings.allowLinkSync = !value;
|
||||
this.applySettingsUpdate(true);
|
||||
}),
|
||||
);*/
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("LINK_PREFIX_NAME"))
|
||||
.setDesc(fragWithHTML(t("LINK_PREFIX_DESC")))
|
||||
@@ -2584,7 +2577,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
new EmbeddalbeMDFileCustomDataSettingsComponent(
|
||||
detailsEl,
|
||||
this.plugin.settings.embeddableMarkdownDefaults,
|
||||
this.applySettingsUpdate,
|
||||
(val?:boolean) => this.applySettingsUpdate(val),
|
||||
).render();
|
||||
|
||||
detailsEl = embedFilesDetailsEl.createEl("details");
|
||||
|
||||
+25
-7
@@ -63,6 +63,7 @@ export default {
|
||||
MARKER_FRAME_TITLE_SHOW: "Show Marker Frame Titles",
|
||||
MARKER_FRAME_TITLE_HIDE: "Hide Marker Frame Titles",
|
||||
COPY_ELEMENT_LINK: "Copy [[link]] for selected element(s)",
|
||||
FRAME_WITH_NAME: "Copy frame link by name",
|
||||
COPY_DRAWING_LINK: "Copy ![[embed link]] for this drawing",
|
||||
INSERT_LINK_TO_ELEMENT:
|
||||
`Copy [[link]] for selected element to clipboard. ${labelCTRL()}+CLICK to copy 'group=' link. ${labelSHIFT()}+CLICK to copy an 'area=' link.`,
|
||||
@@ -98,7 +99,7 @@ export default {
|
||||
RUN_OCR: "OCR full drawing: Grab text from freedraw + images to clipboard and doc.props",
|
||||
RERUN_OCR: "OCR full drawing re-run: Grab text from freedraw + images to clipboard and doc.props",
|
||||
RUN_OCR_ELEMENTS: "OCR selected elements: Grab text from freedraw + images to clipboard",
|
||||
TRAY_MODE: "Toggle property-panel tray-mode",
|
||||
UI_MODE: "Toggle UI-mode",
|
||||
SEARCH: "Search for text in drawing",
|
||||
CROP_PAGE: "Crop and mask selected page",
|
||||
CROP_IMAGE: "Crop and mask image",
|
||||
@@ -110,11 +111,13 @@ export default {
|
||||
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",
|
||||
TOGGLE_ENABLE_CONTEXT_MENU: "Toggle enable context menu (helpful on Mobile devices)",
|
||||
|
||||
//Prompt.ts
|
||||
SELECT_LINK_TO_OPEN: "Select a link to open",
|
||||
|
||||
//ExcalidrawView.ts
|
||||
ABOUT_LIBRARIES: "How to load libraries",
|
||||
ERROR_CANT_READ_FILEPATH: "Error, can't read file path. Importing file instead",
|
||||
NO_SEARCH_RESULT: "Didn't find a matching element in the drawing",
|
||||
FORCE_SAVE_ABORTED: "Force Save aborted because saving is in progress",
|
||||
@@ -137,9 +140,8 @@ export default {
|
||||
"1) Please select your drawing using CTRL/CMD+A and make a copy with CTRL/CMD+C.\n" +
|
||||
"2) Then create an empty drawing in a new pane by CTRL/CMD+clicking the Excalidraw ribbon button,\n" +
|
||||
"3) and paste your work to the new document with CTRL/CMD+V.",
|
||||
ARIA_LABEL_TRAY_MODE: "Tray-mode offers an alternative, more spacious canvas",
|
||||
TRAY_TRAY_MODE: "Toggle tray-mode",
|
||||
TOGGLE_COMPACT_MODE: "Toggle compact-mode",
|
||||
ARIA_LABEL_TRAY_MODE: "You can choose from 3 different desktop and tablet UI modes: Full, Compact, and Tray. On Phones only the Phone mode is available.",
|
||||
TRAY_TRAY_MODE: "Toggle UI-mode",
|
||||
TRAY_SCRIPT_LIBRARY: "Script Library",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "Explore the Excalidraw Script Library",
|
||||
TRAY_EXPORT: "Export Image...",
|
||||
@@ -312,6 +314,9 @@ export default {
|
||||
"The default AI model to use when generating text. This is a freetext field, so you can enter any valid OpenAI model name. " +
|
||||
"Find out more about the available models on the <a href='https://platform.openai.com/docs/models'>OpenAI website</a>.",
|
||||
AI_OPENAI_DEFAULT_MODEL_PLACEHOLDER: "Enter your default AI model here. e.g.: gpt-3.5-turbo-1106",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_NAME: "Max tokens",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_DESC:
|
||||
"Maximum number of tokens to generate in the API response. Set to 0 to omit the max_tokens field (useful for models that don't support this parameter, such as GPT-5).",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_NAME: "Default Image Generation AI model",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_DESC:
|
||||
"The default AI model to use when generating images. Image editing and variations are only supported by dall-e-2 at this time by OpenAI, " +
|
||||
@@ -452,7 +457,14 @@ export default {
|
||||
"Note: This setting does not affect the PDF export feature within Excalidraw itself.<br>" +
|
||||
"See the other related setting for <a href='#"+TAG_MDREADINGMODE+"'>Markdown Reading Mode</a> under 'Appearance and Behavior' further above.<br>" +
|
||||
"⚠️ You must close and reopen the Excalidraw/markdown file for changes to take effect. ⚠️",
|
||||
MODES_HEAD: "Modes",
|
||||
MODES_HEAD: "UI Modes",
|
||||
DESKTOP_UI_MODE_NAME: "Preferred Desktop Mode",
|
||||
DESKTOP_UI_MODE_DESC: "Select the default UI mode for desktop devices.",
|
||||
TABLET_UI_MODE_NAME: "Preferred Tablet Mode",
|
||||
TABLET_UI_MODE_DESC: "Select the default UI mode for tablet devices.",
|
||||
MODE_FULL: "Desktop-mode",
|
||||
MODE_COMPACT: "Compact-mode",
|
||||
MODE_TRAY: "Tray-mode",
|
||||
TRAY_MODE_NAME: "Enable tray-mode",
|
||||
PREFER_COMPACT_MODE_DESKTOP_NAME: "Prefer compact-mode on Desktop",
|
||||
PREFER_COMPACT_MODE_DESKTOP_DESC: "When toggling tray-mode on a desktop, if this option is enabled, Excalidraw will toggle between compact-mode and tray-mode. " +
|
||||
@@ -498,8 +510,7 @@ export default {
|
||||
"<b><u>Toggle ON:</u></b>Change grid color to match the canvas color<br><b><u>Toggle OFF:</u></b>Use the color below as the grid color",
|
||||
GRID_COLOR_NAME: "Grid color",
|
||||
GRID_OPACITY_NAME: "Grid opacity",
|
||||
GRID_OPACITY_DESC: "Grid opacity will also control the opacity of the binding box when binding an arrow to an element.<br>" +
|
||||
"Set the opacity of the grid. 0 is transparent, 100 is opaque.",
|
||||
GRID_OPACITY_DESC: "Sets the opacity of the grid. 0 is transparent, 100 is opaque.",
|
||||
GRID_DIRECTION_NAME: "Grid direction",
|
||||
GRID_DIRECTION_DESC: "The first toggle shows/hides the horizontal grid, the second toggle shows/hides the vertical grid.",
|
||||
GRID_HORIZONTAL: "Render horizontal grid",
|
||||
@@ -553,6 +564,12 @@ export default {
|
||||
"In PREVIEW mode, when parsing Text Elements, place brackets around links. " +
|
||||
"You can override this setting for a specific drawing by adding <code>"
|
||||
}${FRONTMATTER_KEYS["link-brackets"].name}: true/false</code> to the file's frontmatter.`,
|
||||
/*LINK_DETECTION_NAME: "Do not auto-create element link from text",
|
||||
LINK_DETECTION_DESC: "By default, Excalidraw will automatically create an element link when you type or paste a valid " +
|
||||
"[[Obsidian link]] or a (web link) into a Text Element. This link overrides whatever element link you may have set previously. " +
|
||||
"Even if you delete the element link, if the text element contains a valid link, Excalidraw will recreate the element link. " +
|
||||
"If you turn this setting on, Excalidraw will not auto-create element links from text. You can still manually set element links " +
|
||||
`Links in the text will still be navigable when you ${labelCTRL()} + CLICK the element.`,*/
|
||||
LINK_PREFIX_NAME: "Link prefix",
|
||||
LINK_PREFIX_DESC: `${
|
||||
"In PREVIEW mode, if the Text Element contains a link, precede the text with these characters. " +
|
||||
@@ -1123,6 +1140,7 @@ export default {
|
||||
EXPORTDIALOG_BACKGROUND: "Background",
|
||||
EXPORTDIALOG_BACKGROUND_TRANSPARENT: "Transparent",
|
||||
EXPORTDIALOG_BACKGROUND_USE_COLOR: "Use scene color",
|
||||
EXPORTDIALOG_INCLUDE_INTERNAL_LINKS: "Export internal links to SVG/PDF?",
|
||||
// Selection
|
||||
EXPORTDIALOG_SELECTED_ELEMENTS: "Export",
|
||||
EXPORTDIALOG_SELECTED_ALL: "Entire scene",
|
||||
|
||||
@@ -310,6 +310,9 @@ export default {
|
||||
"El modelo de IA predeterminado para usar al generar texto. Este es un campo de texto libre, así que puedes ingresar cualquier nombre de modelo de OpenAI válido. " +
|
||||
"Encuentra más información sobre los modelos disponibles en el sitio web de OpenAI: <a href='https://platform.openai.com/docs/models'></a>.",
|
||||
AI_OPENAI_DEFAULT_MODEL_PLACEHOLDER: "Ingresa aquí tu modelo de IA predeterminado. Ej.: gpt-3.5-turbo-1106",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_NAME: "Tokens máximos",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_DESC:
|
||||
"Número máximo de tokens a generar en la respuesta de la API. Establece en 0 para omitir el campo max_tokens (útil para modelos que no admiten este parámetro, como GPT-5).",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_NAME: "Modelo de IA predeterminado para generación de imágenes",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_DESC:
|
||||
"El modelo de IA predeterminado para usar al generar imágenes. La edición y variaciones de imágenes solo son compatibles con Dall-E 2 en este momento por parte de OpenAI, " +
|
||||
|
||||
@@ -215,6 +215,9 @@ export default {
|
||||
"Модель ИИ по умолчанию, используемая при генерации текста. Это поле свободного текста, поэтому вы можете ввести любое действительное имя модели OpenAI. " +
|
||||
"Узнайте больше о доступных моделях на <a href='https://platform.openai.com/docs/models'>OpenAI сайте</a>.",
|
||||
AI_OPENAI_DEFAULT_MODEL_PLACEHOLDER: "Введите здесь модель искусственного интеллекта по умолчанию, например: gpt-3.5-turbo-1106.",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_NAME: "Максимальное количество токенов",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_DESC:
|
||||
"Максимальное количество токенов для генерации в ответе API. Установите значение 0, чтобы пропустить поле max_tokens (полезно для моделей, которые не поддерживают этот параметр, таких как GPT-5).",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_NAME: "Модель ИИ для генерации изображений по умолчанию",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_DESC:
|
||||
"Модель ИИ по умолчанию, используемая при генерации изображений. Редактирование и изменение изображений поддерживается OpenAI только в dall-e-2, " +
|
||||
|
||||
+35
-20
@@ -63,6 +63,7 @@ export default {
|
||||
MARKER_FRAME_TITLE_SHOW: "显示标记画框名称",
|
||||
MARKER_FRAME_TITLE_HIDE: "隐藏标记画框名称",
|
||||
COPY_ELEMENT_LINK: "复制所选元素的 [[file#^id]] 链接",
|
||||
FRAME_WITH_NAME: "按名称复制画框链接",
|
||||
COPY_DRAWING_LINK: "复制绘图的 ![[drawing]] 链接",
|
||||
INSERT_LINK_TO_ELEMENT:
|
||||
`单击=复制所选元素的 [[file#^id]] 链接\n${labelCTRL()}=复制元素所在分组为 [[file#^group=id]] 链接\n${labelSHIFT()}=复制所选元素所在区域为 [[file#^area=id]] 链接`,
|
||||
@@ -98,7 +99,7 @@ export default {
|
||||
RUN_OCR: "OCR 整个绘图:识别涂鸦和图片里的文本并复制到剪贴板和笔记属性中",
|
||||
RERUN_OCR: "重新 OCR 整个绘图:识别涂鸦和图片里的文本并复制到剪贴板和笔记属性中",
|
||||
RUN_OCR_ELEMENTS: "OCR 选中的元素:识别涂鸦和图片里的文本并复制到剪贴板",
|
||||
TRAY_MODE: "绘图工具属性页:面板模式 ⟺ 托盘模式",
|
||||
UI_MODE: "切换 UI 模式",
|
||||
SEARCH: "搜索文本",
|
||||
CROP_PAGE: "裁剪所选页面并添加蒙版",
|
||||
CROP_IMAGE: "裁剪图片并添加蒙版",
|
||||
@@ -110,11 +111,13 @@ export default {
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "启用自动保存功能",
|
||||
FONTS_LOADED: "Excalidraw: CJK 字体已加载",
|
||||
FONTS_LOAD_ERROR: "Excalidraw: 在资源文件夹下找不到 CJK 字体\n",
|
||||
TOGGLE_ENABLE_CONTEXT_MENU: "切换是否启用上下文菜单(在移动设备上很有用)",
|
||||
|
||||
//Prompt.ts
|
||||
SELECT_LINK_TO_OPEN: "选择要打开的链接",
|
||||
|
||||
//ExcalidrawView.ts
|
||||
ABOUT_LIBRARIES: "如何加载素材库",
|
||||
ERROR_CANT_READ_FILEPATH: "错误,无法读取文件路径。正在改为导入文件",
|
||||
NO_SEARCH_RESULT: "在绘图中未找到匹配的元素",
|
||||
FORCE_SAVE_ABORTED: "自动保存被中止,因为文件正在保存中",
|
||||
@@ -137,9 +140,8 @@ export default {
|
||||
"1) 使用 Ctrl/CMD+A 选择您的绘图,然后使用 Ctrl/CMD+C 进行复制。\n" +
|
||||
"2) 然后在新窗格中,通过 Ctrl/CMD 点击 Excalidraw 功能区按钮创建一个空白绘图。\n" +
|
||||
"3) 最后,使用 Ctrl/CMD+V 将您的作品粘贴到新文件中。",
|
||||
ARIA_LABEL_TRAY_MODE: "托盘模式提供更宽敞的绘图空间",
|
||||
TRAY_TRAY_MODE: "切换托盘模式",
|
||||
TOGGLE_COMPACT_MODE: "切换紧凑模式",
|
||||
ARIA_LABEL_TRAY_MODE: "切换 3 种 UI 模式:完整模式(桌面端)、紧凑模式、托盘模式。手机端只有手机端模式。",
|
||||
TRAY_TRAY_MODE: "切换 UI 模式",
|
||||
TRAY_SCRIPT_LIBRARY: "脚本库",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "浏览 Excalidraw 脚本库",
|
||||
TRAY_EXPORT: "导出绘图…",
|
||||
@@ -216,7 +218,7 @@ export default {
|
||||
|
||||
//settings.ts
|
||||
DISABLE_CONTEXT_MENU_NAME: "禁用 Excalidraw 上下文菜单",
|
||||
DISABLE_CONTEXT_MENU_DESC: "禁用 Excalidraw 的上下文菜单。这在移动设备上非常有用,因为上下文菜单有时会在不需要的时候弹出。",
|
||||
DISABLE_CONTEXT_MENU_DESC: "禁用 Excalidraw 的上下文菜单。这在移动设备上很有用,因为上下文菜单有时会在不需要的时候弹出。",
|
||||
NOTEBOOKLM_LINK_ARIA: "向 NotebookLM 咨询有关插件的帮助。此模型已预加载了我所有的视频转录稿、发布说明和其他帮助内容。与 NotebookLM 聊天,浏览我的 250+ 视频和 Excalidraw 文件。",
|
||||
NOTEBOOKLM_LINK_TEXT: "学习插件。访问 NotebookLM 知识库。",
|
||||
LINKS_BUGS_ARIA: "在插件的 GitHub 页面报告错误和提交功能请求",
|
||||
@@ -230,8 +232,8 @@ export default {
|
||||
LINKS_VTW: "加入研讨会",
|
||||
LINKS_BOOK_ARIA: "阅读我的视觉思维著作《Sketch Your Mind》",
|
||||
LINKS_BOOK: "阅读书籍",
|
||||
LINKS_WIKI: "插件 Wiki",
|
||||
LINKS_WIKI_ARIA: "浏览 Excalidraw 插件 Wiki",
|
||||
LINKS_WIKI: "插件维基",
|
||||
LINKS_WIKI_ARIA: "浏览 Excalidraw 插件维基",
|
||||
|
||||
RELEASE_NOTES_NAME: "显示更新说明",
|
||||
RELEASE_NOTES_DESC:
|
||||
@@ -312,6 +314,9 @@ export default {
|
||||
"使用哪个 AI 模型来生成文本。请填写有效的 OpenAI 模型名称。" +
|
||||
"您可访问 <a href='https://platform.openai.com/docs/models'>OpenAI 网站</a> 了解更多模型信息。",
|
||||
AI_OPENAI_DEFAULT_MODEL_PLACEHOLDER: "gpt-3.5-turbo-1106",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_NAME: "最大 token 数",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_DESC:
|
||||
"API 响应中生成的最大 token 数。设置为 0 以忽略 max_tokens 字段(适用于不支持该参数的模型,如 GPT-5)。",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_NAME: "默认的图片 AI 模型",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_DESC:
|
||||
"使用哪个 AI 模型来生成图片。图生图会强制使用 dall-e-2 模型," +
|
||||
@@ -452,10 +457,20 @@ export default {
|
||||
"注意:该项不会影响 Excalidraw 本身的 PDF 导出功能。<br>" +
|
||||
"请参阅下方 <a href='#"+TAG_PDFEXPORT+"'>PDF 导出设置</a>。<br>" +
|
||||
"⚠️ 关闭并重新打开 Excalidraw/Markdown 文件后生效。",
|
||||
MODES_HEAD: "模式",
|
||||
MODES_HEAD: "UI 模式",
|
||||
DESKTOP_UI_MODE_NAME: "桌面端偏好模式",
|
||||
DESKTOP_UI_MODE_DESC: "桌面端设备默认 UI 模式。",
|
||||
TABLET_UI_MODE_NAME: "平板端偏好模式",
|
||||
TABLET_UI_MODE_DESC: "平板端设备默认 UI 模式。",
|
||||
MODE_FULL: "Desktop-mode",
|
||||
MODE_COMPACT: "Compact-mode",
|
||||
MODE_TRAY: "Tray-mode",
|
||||
TRAY_MODE_NAME: "启用托盘模式",
|
||||
COMPACT_MODE_NAME: "平板上的紧凑模式",
|
||||
COMPACT_MODE_DESC: "覆盖平板上的托盘模式,使用原生的 Excalidraw 紧凑模式。",
|
||||
PREFER_COMPACT_MODE_DESKTOP_NAME: "在桌面端偏好紧凑模式",
|
||||
PREFER_COMPACT_MODE_DESKTOP_DESC: "切换托盘模式时,开启该项,Excalidraw 将在紧凑模式与托盘模式之间切换。" +
|
||||
"关闭该项,则在完整模式与托盘模式之间切换。",
|
||||
COMPACT_MODE_NAME: "在平板端偏好紧凑模式",
|
||||
COMPACT_MODE_DESC: "该项允许平板端和桌面端设置不同的默认模式。你可以在平板端默认使用紧凑模式,而在桌面端默认使用托盘模式。",
|
||||
HOTKEY_OVERRIDE_HEAD: "热键覆盖",
|
||||
HOTKEY_OVERRIDE_DESC: `一些 Excalidraw 的热键,如 ${labelCTRL()}+Enter 用于编辑文本,或 ${labelCTRL()}+K 用于创建元素链接,` +
|
||||
"与 Obsidian 的热键设置冲突。您在下面添加的热键组合将在使用 Excalidraw 时覆盖 Obsidian 的热键设置," +
|
||||
@@ -494,9 +509,8 @@ export default {
|
||||
GRID_DYNAMIC_COLOR_DESC:
|
||||
"<b>开启:</b>更改网格颜色以匹配绘图颜色。<br><b>关闭:</b>将以下颜色用作网格颜色。",
|
||||
GRID_COLOR_NAME: "网格颜色",
|
||||
GRID_OPACITY_NAME: "网格透明度",
|
||||
GRID_OPACITY_DESC: "设置网格的透明度。还将控制将箭头绑定到元素时绑定框的透明度。" +
|
||||
"0 全透明 ⟺ 100 不透明。",
|
||||
GRID_OPACITY_NAME: "网格不透明度",
|
||||
GRID_OPACITY_DESC: "设置网格的不透明度。0 全透明 ⟺ 100 不透明。",
|
||||
GRID_DIRECTION_NAME: "网格方向",
|
||||
GRID_DIRECTION_DESC: "第一个开关显示/隐藏水平网格,第二个开关显示/隐藏垂直网格。",
|
||||
GRID_HORIZONTAL: "渲染水平网格",
|
||||
@@ -571,9 +585,9 @@ export default {
|
||||
`<b>开启:</b>在 Excalidraw <u>查看模式(View)</u>下,鼠标悬停在 <code>[[内部链接]]</code> 上即可预览;` +
|
||||
"而在<u>普通模式(Normal)</u>下,鼠标悬停在内部链接右上角的蓝色标识上即可预览。<br>" +
|
||||
`<b>关闭:</b>鼠标悬停在 <code>[[内部链接]]</code> 上,并且按住 ${labelCTRL()} 才能预览。`,
|
||||
LINKOPACITY_NAME: "链接标识的透明度",
|
||||
LINKOPACITY_NAME: "链接标识的不透明度",
|
||||
LINKOPACITY_DESC:
|
||||
"含有链接的元素,其右上角的链接标识的透明度。0 全透明 ⟺ 100 不透明。",
|
||||
"含有链接的元素,其右上角的链接标识的不透明度。0 全透明 ⟺ 100 不透明。",
|
||||
LINK_CTRL_CLICK_NAME:
|
||||
`按住 ${labelCTRL()} 并点击含有 [[链接]] 或 [别名](链接) 的文本来打开链接`,
|
||||
LINK_CTRL_CLICK_DESC:
|
||||
@@ -768,7 +782,7 @@ export default {
|
||||
PRESERVE_TEXT_AFTER_DRAWING_NAME: "兼容 Zotero 和脚注(footnotes)",
|
||||
PRESERVE_TEXT_AFTER_DRAWING_DESC: "保留 Excalidraw Markdown 中 <code>## Drawing</code> 部分之后的文本内容。保存非常大的绘图时,这可能会造成微小的性能影响。",
|
||||
DEBUGMODE_NAME: "开启 debug 信息",
|
||||
DEBUGMODE_DESC: "我建议在启用/禁用该项后重新启动 Obsidian。这将在控制台中启用调试消息。这对于排查问题很有帮助。" +
|
||||
DEBUGMODE_DESC: "我建议在启用/禁用该项后重新启动 Obsidian。这将在控制台中启用调试消息,有助于排查问题。" +
|
||||
"如果您在使用插件时遇到问题,请启用该项,重现问题,并在 <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/issues'>GitHub</a> 上提出的问题中包含控制台日志。",
|
||||
SLIDING_PANES_NAME: "支持 Sliding Panes 插件",
|
||||
SLIDING_PANES_DESC:
|
||||
@@ -1003,15 +1017,15 @@ export default {
|
||||
ES_FILENAME_VISIBLE: "显示页内标题",
|
||||
ES_BACKGROUND_HEAD: "背景色",
|
||||
ES_BACKGROUND_DESC_INFO: "点击此处查看更多颜色信息",
|
||||
ES_BACKGROUND_DESC_DETAIL: "背景色仅影响预览模式的 MD-Embeddable。在编辑模式,它会根据场景(通过笔记属性设置)或插件设置,遵循 Obsidian 的深色/浅色主题。背景色有两层:元素背景色(下层颜色)和上层颜色。选择“匹配元素”表示两层都遵循元素背景色。选择“匹配绘图”或特定背景色不会改变元素背景色。设置透明度(如 50%)会将绘图或选定的颜色与元素背景色混合。要移除元素背景色,可以在 Excalidraw 的元素属性编辑器中将元素背景色设置为透明,这样只有上层颜色生效。",
|
||||
ES_BACKGROUND_DESC_DETAIL: "背景色仅影响预览模式的 MD-Embeddable。在编辑模式,它会根据场景(通过笔记属性设置)或插件设置,遵循 Obsidian 的深色/浅色主题。背景色有两层:元素背景色(下层颜色)和上层颜色。选择“匹配元素”表示两层都遵循元素背景色。选择“匹配绘图”或特定背景色不会改变元素背景色。设置不透明度(如 50%)会将绘图或选定的颜色与元素背景色混合。要移除元素背景色,可以在 Excalidraw 的元素属性编辑器中将元素背景色设置为透明,这样只有上层颜色生效。",
|
||||
ES_BACKGROUND_MATCH_ELEMENT: "匹配元素背景色",
|
||||
ES_BACKGROUND_MATCH_CANVAS: "匹配绘图背景色",
|
||||
ES_BACKGROUND_COLOR: "背景色",
|
||||
ES_BORDER_HEAD: "边框颜色",
|
||||
ES_BORDER_COLOR: "边框颜色",
|
||||
ES_BORDER_MATCH_ELEMENT: "匹配元素边框颜色",
|
||||
ES_BACKGROUND_OPACITY: "背景透明度",
|
||||
ES_BORDER_OPACITY: "边框透明度",
|
||||
ES_BACKGROUND_OPACITY: "背景不透明度",
|
||||
ES_BORDER_OPACITY: "边框不透明度",
|
||||
ES_EMBEDDABLE_SETTINGS: "MD-Embeddable 设置",
|
||||
ES_USE_OBSIDIAN_DEFAULTS: "使用 Obsidian 默认设置",
|
||||
ES_ZOOM_100_RELATIVE_DESC: "使元素的缩放等级等于当前绘图的缩放等级",
|
||||
@@ -1120,6 +1134,7 @@ export default {
|
||||
EXPORTDIALOG_BACKGROUND: "背景",
|
||||
EXPORTDIALOG_BACKGROUND_TRANSPARENT: "透明",
|
||||
EXPORTDIALOG_BACKGROUND_USE_COLOR: "使用场景颜色",
|
||||
EXPORTDIALOG_INCLUDE_INTERNAL_LINKS: "导出内部链接为 SVG/PDF?",
|
||||
// Selection
|
||||
EXPORTDIALOG_SELECTED_ELEMENTS: "导出",
|
||||
EXPORTDIALOG_SELECTED_ALL: "整个场景",
|
||||
@@ -1194,7 +1209,7 @@ export default {
|
||||
UIFM_TITLE: "从仓库中嵌入文件",
|
||||
UIFM_SECTION_HEAD: "选择章节标题",
|
||||
UIFM_ANCHOR: "锚定为原始大小的 100%",
|
||||
UIFM_ANCHOR_DESC: "这是一个专业功能,请在了解其作用的情况下再使用。启用后,即使你在 Excalidraw 中调整了导入图像的大小,下次打开绘图时,该图像仍会恢复为原始大小的 100%。这在将一个独立的 Excalidraw 点子嵌入到另一份笔记中,并希望保持文字和图标的相对尺寸时非常有用。",
|
||||
UIFM_ANCHOR_DESC: "这是一个专业功能,请在了解其作用的情况下再使用。启用后,即使你在 Excalidraw 中调整了导入图像的大小,下次打开绘图时,该图像仍会恢复为原始大小的 100%。当你将一个独立的 Excalidraw 点子嵌入到另一份笔记中,并希望保持文字和图标的相对尺寸时,这会很有用。",
|
||||
UIFM_BTN_EMBEDDABLE: "以交互形式",
|
||||
UIFM_BTN_PDF: "PDF 页面",
|
||||
UIFM_BTN_IMAGE: "以图像形式",
|
||||
|
||||
+31
-14
@@ -86,7 +86,7 @@ export default {
|
||||
INSERT_MD: "以影像形式嵌入 Markdown 文件到當前繪圖中",
|
||||
INSERT_PDF: "以影像形式嵌入 PDF 到當前繪圖中",
|
||||
INSERT_LAST_ACTIVE_PDF_PAGE_AS_IMAGE: "以影像形式嵌入最後啟用的 PDF 頁面",
|
||||
UNIVERSAL_ADD_FILE: "以互動或影像形式嵌入檔案",
|
||||
UNIVERSAL_ADD_FILE: "嵌入檔案 (Insert ANY file)",
|
||||
INSERT_CARD: "插入“背景筆記”卡片",
|
||||
CONVERT_CARD_TO_FILE: "將“背景筆記”卡片儲存到檔案",
|
||||
ERROR_TRY_AGAIN: "請重試。",
|
||||
@@ -98,7 +98,7 @@ export default {
|
||||
RUN_OCR: "OCR 整個繪圖:識別塗鴉和圖片裡的文字並複製到剪貼簿和筆記屬性中",
|
||||
RERUN_OCR: "重新 OCR 整個繪圖:識別塗鴉和圖片裡的文字並複製到剪貼簿和筆記屬性中",
|
||||
RUN_OCR_ELEMENTS: "OCR 選中的元素:識別塗鴉和圖片裡的文字並複製到剪貼簿",
|
||||
TRAY_MODE: "繪圖工具屬性頁:面板模式 ⟺ 托盤模式",
|
||||
UI_MODE: "切換 UI 模式",
|
||||
SEARCH: "搜尋文字",
|
||||
CROP_PAGE: "裁剪所選頁面並新增蒙版",
|
||||
CROP_IMAGE: "裁剪圖片並新增蒙版",
|
||||
@@ -110,11 +110,13 @@ export default {
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "啟用自動儲存功能",
|
||||
FONTS_LOADED: "Excalidraw: CJK 字型已載入",
|
||||
FONTS_LOAD_ERROR: "Excalidraw: 在資原始檔夾下找不到 CJK 字型\n",
|
||||
TOGGLE_ENABLE_CONTEXT_MENU: "切換是否啟用上下文選單(在移動裝置上很有用)",
|
||||
|
||||
//Prompt.ts
|
||||
SELECT_LINK_TO_OPEN: "選擇要開啟的連結",
|
||||
|
||||
//ExcalidrawView.ts
|
||||
ABOUT_LIBRARIES: "如何載入素材庫",
|
||||
ERROR_CANT_READ_FILEPATH: "錯誤,無法讀取檔案路徑。正在改為匯入檔案",
|
||||
NO_SEARCH_RESULT: "在繪圖中未找到匹配的元素",
|
||||
FORCE_SAVE_ABORTED: "自動儲存被中止,因為檔案正在儲存中",
|
||||
@@ -137,9 +139,8 @@ export default {
|
||||
"1) 使用 Ctrl/CMD+A 選擇您的繪圖,然後使用 Ctrl/CMD+C 進行復制。\n" +
|
||||
"2) 然後在新窗格中,透過 Ctrl/CMD 點選 Excalidraw 功能區按鈕建立一個空白繪圖。\n" +
|
||||
"3) 最後,使用 Ctrl/CMD+V 將您的作品貼上到新檔案中。",
|
||||
ARIA_LABEL_TRAY_MODE: "托盤模式提供更寬敞的繪圖空間",
|
||||
TRAY_TRAY_MODE: "切換托盤模式",
|
||||
TOGGLE_COMPACT_MODE: "切換緊湊模式",
|
||||
ARIA_LABEL_TRAY_MODE: "切換 3 種 UI 模式:完整模式(桌面端)、緊湊模式、托盤模式。手機端只有手機端模式。",
|
||||
TRAY_TRAY_MODE: "切換 UI 模式",
|
||||
TRAY_SCRIPT_LIBRARY: "指令碼庫",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "瀏覽 Excalidraw 指令碼庫",
|
||||
TRAY_EXPORT: "匯出繪圖…",
|
||||
@@ -169,7 +170,7 @@ export default {
|
||||
COMPATIBILITY_MODE:
|
||||
"*.excalidraw 是相容舊版的繪圖檔案格式。需要轉換為新格式才能解鎖本外掛的全部功能。",
|
||||
CONVERT_FILE: "轉換為新格式",
|
||||
BACKUP_AVAILABLE: "載入繪圖檔案時出錯,可能是由於 Obsidian 在上次儲存時意外退出了(手機上更容易發生這種意外)。<br><br><b>好訊息:</b>這臺裝置上存在備份。您是否想要恢復本裝置上的備份?<br><br>(我建議您先嚐試在最近使用過的其他裝置上開啟該繪圖,以檢查是否有更新的備份。)",
|
||||
BACKUP_AVAILABLE: "載入繪圖檔案時出錯,可能是由於 Obsidian 在上次儲存時意外退出了(移動裝置上更容易發生這種意外)。<br><br><b>好訊息:</b>這臺裝置上存在備份。您是否想要恢復本裝置上的備份?<br><br>(我建議您先嚐試在最近使用過的其他裝置上開啟該繪圖,以檢查是否有更新的備份。)",
|
||||
BACKUP_RESTORED: "已恢復備份",
|
||||
BACKUP_SAVE_AS_FILE: "此繪圖為空。但有一個非空的備份可用。您想將其恢復為新檔案並在新標籤頁中開啟嗎?",
|
||||
BACKUP_SAVE: "恢復",
|
||||
@@ -215,6 +216,8 @@ export default {
|
||||
|
||||
|
||||
//settings.ts
|
||||
DISABLE_CONTEXT_MENU_NAME: "停用 Excalidraw 上下文選單",
|
||||
DISABLE_CONTEXT_MENU_DESC: "停用 Excalidraw 的上下文選單。這在移動裝置上很有用,因為上下文選單有時會在不需要的時候彈出。",
|
||||
NOTEBOOKLM_LINK_ARIA: "向 NotebookLM 諮詢有關外掛的幫助。此模型已預載入了我所有的影片轉錄稿、釋出說明和其他幫助內容。與 NotebookLM 聊天,瀏覽我的 250+ 影片和 Excalidraw 檔案。",
|
||||
NOTEBOOKLM_LINK_TEXT: "學習外掛。訪問 NotebookLM 知識庫。",
|
||||
LINKS_BUGS_ARIA: "在外掛的 GitHub 頁面報告錯誤和提交功能請求",
|
||||
@@ -228,8 +231,8 @@ export default {
|
||||
LINKS_VTW: "加入研討會",
|
||||
LINKS_BOOK_ARIA: "閱讀我的視覺思維著作《Sketch Your Mind》",
|
||||
LINKS_BOOK: "閱讀書籍",
|
||||
LINKS_WIKI: "外掛 Wiki",
|
||||
LINKS_WIKI_ARIA: "瀏覽 Excalidraw 外掛 Wiki",
|
||||
LINKS_WIKI: "外掛維基",
|
||||
LINKS_WIKI_ARIA: "瀏覽 Excalidraw 外掛維基",
|
||||
|
||||
RELEASE_NOTES_NAME: "顯示更新說明",
|
||||
RELEASE_NOTES_DESC:
|
||||
@@ -310,6 +313,9 @@ export default {
|
||||
"使用哪個 AI 模型來生成文字。請填寫有效的 OpenAI 模型名稱。" +
|
||||
"您可訪問 <a href='https://platform.openai.com/docs/models'>OpenAI 網站</a> 瞭解更多模型資訊。",
|
||||
AI_OPENAI_DEFAULT_MODEL_PLACEHOLDER: "gpt-3.5-turbo-1106",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_NAME: "最大 token 數",
|
||||
AI_OPENAI_DEFAULT_MAX_TOKENS_DESC:
|
||||
"API 生成的最大 token 數。設定為 0 以忽略 max_tokens 欄位(適用於不支援該引數的模型,如 GPT-5)。",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_NAME: "預設的圖片 AI 模型",
|
||||
AI_OPENAI_DEFAULT_IMAGE_MODEL_DESC:
|
||||
"使用哪個 AI 模型來生成圖片。圖生圖會強制使用 dall-e-2 模型," +
|
||||
@@ -450,10 +456,20 @@ export default {
|
||||
"注意:該項不會影響 Excalidraw 本身的 PDF 匯出功能。<br>" +
|
||||
"請參閱下方 <a href='#"+TAG_PDFEXPORT+"'>PDF 匯出設定</a>。<br>" +
|
||||
"⚠️ 關閉並重新開啟 Excalidraw/Markdown 檔案後生效。",
|
||||
MODES_HEAD: "模式",
|
||||
MODES_HEAD: "UI 模式",
|
||||
DESKTOP_UI_MODE_NAME: "桌面端偏好模式",
|
||||
DESKTOP_UI_MODE_DESC: "桌面端裝置預設 UI 模式。",
|
||||
TABLET_UI_MODE_NAME: "平板端偏好模式",
|
||||
TABLET_UI_MODE_DESC: "平板端裝置預設 UI 模式。",
|
||||
MODE_FULL: "Desktop-mode",
|
||||
MODE_COMPACT: "Compact-mode",
|
||||
MODE_TRAY: "Tray-mode",
|
||||
TRAY_MODE_NAME: "啟用托盤模式",
|
||||
COMPACT_MODE_NAME: "平板上的緊湊模式",
|
||||
COMPACT_MODE_DESC: "覆蓋平板上的托盤模式,使用原生的 Excalidraw 緊湊模式。",
|
||||
PREFER_COMPACT_MODE_DESKTOP_NAME: "在桌面端偏好緊湊模式",
|
||||
PREFER_COMPACT_MODE_DESKTOP_DESC: "切換托盤模式時,開啟該項,Excalidraw 將在緊湊模式與托盤模式之間切換。" +
|
||||
"關閉該項,則在完整模式與托盤模式之間切換。",
|
||||
COMPACT_MODE_NAME: "在平板端偏好緊湊模式",
|
||||
COMPACT_MODE_DESC: "該項允許平板端和桌面端設定不同的預設模式。你可以在平板端預設使用緊湊模式,而在桌面端預設使用托盤模式。",
|
||||
HOTKEY_OVERRIDE_HEAD: "熱鍵覆蓋",
|
||||
HOTKEY_OVERRIDE_DESC: `一些 Excalidraw 的熱鍵,如 ${labelCTRL()}+Enter 用於編輯文字,或 ${labelCTRL()}+K 用於建立元素連結,` +
|
||||
"與 Obsidian 的熱鍵設定衝突。您在下面新增的熱鍵組合將在使用 Excalidraw 時覆蓋 Obsidian 的熱鍵設定," +
|
||||
@@ -676,7 +692,7 @@ export default {
|
||||
EMBED_REUSE_EXPORTED_IMAGE_DESC:
|
||||
"該項與下方“匯出”部分“匯出設定”中的 <a href='#"+TAG_AUTOEXPORT+"'>自動匯出 SVG/PNG 副本</a> 選項配合使用。如果嵌入到 Markdown 文件中的繪圖檔案存在同名的 SVG/PNG 副本,則將其作為預覽圖,而不再重新生成。<br>" +
|
||||
"該項能夠提高 Markdown 文件的開啟速度,尤其是當嵌入到 Markdown 文件中的繪圖檔案中含有大量圖片或 MD-Embed 時。" +
|
||||
"但是,該項也可能導致預覽圖無法立即響應繪圖檔案或者 Obsidian 主題的修改。<br>" +
|
||||
"但是,該項也可能導致預覽圖無法即時反應繪圖檔案或者 Obsidian 主題的修改。<br>" +
|
||||
"該項僅作用於嵌入到 Markdown 文件中的繪圖。" +
|
||||
"該項無法提升繪圖檔案的開啟速度。詳見 <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.6.23' target='_blank'>此說明</a>。",
|
||||
/*EMBED_PREVIEW_SVG_NAME: "生成 SVG 格式的預覽圖",
|
||||
@@ -766,7 +782,7 @@ export default {
|
||||
PRESERVE_TEXT_AFTER_DRAWING_NAME: "相容 Zotero 和腳註(footnotes)",
|
||||
PRESERVE_TEXT_AFTER_DRAWING_DESC: "保留 Excalidraw Markdown 中 <code>## Drawing</code> 部分之後的文字內容。儲存非常大的繪圖時,這可能會造成微小的效能影響。",
|
||||
DEBUGMODE_NAME: "開啟 debug 資訊",
|
||||
DEBUGMODE_DESC: "我建議在啟用/停用該項後重新啟動 Obsidian。這將在控制檯中啟用除錯訊息。這對於排查問題很有幫助。" +
|
||||
DEBUGMODE_DESC: "我建議在啟用/停用該項後重新啟動 Obsidian。這將在控制檯中啟用除錯訊息,有助於排查問題。" +
|
||||
"如果您在使用外掛時遇到問題,請啟用該項,重現問題,並在 <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/issues'>GitHub</a> 上提出的問題中包含控制檯日誌。",
|
||||
SLIDING_PANES_NAME: "支援 Sliding Panes 外掛",
|
||||
SLIDING_PANES_DESC:
|
||||
@@ -1118,6 +1134,7 @@ export default {
|
||||
EXPORTDIALOG_BACKGROUND: "背景",
|
||||
EXPORTDIALOG_BACKGROUND_TRANSPARENT: "透明",
|
||||
EXPORTDIALOG_BACKGROUND_USE_COLOR: "使用場景顏色",
|
||||
EXPORTDIALOG_INCLUDE_INTERNAL_LINKS: "匯出內部連結為 SVG/PDF?",
|
||||
// Selection
|
||||
EXPORTDIALOG_SELECTED_ELEMENTS: "匯出",
|
||||
EXPORTDIALOG_SELECTED_ALL: "整個場景",
|
||||
@@ -1192,7 +1209,7 @@ export default {
|
||||
UIFM_TITLE: "從倉庫中嵌入檔案",
|
||||
UIFM_SECTION_HEAD: "選擇章節標題",
|
||||
UIFM_ANCHOR: "錨定為原始大小的 100%",
|
||||
UIFM_ANCHOR_DESC: "這是一個專業功能,請在瞭解其作用的情況下再使用。啟用後,即使你在 Excalidraw 中調整了匯入影像的大小,下次開啟繪圖時,該影像仍會恢復為原始大小的 100%。這在將一個獨立的 Excalidraw 點子嵌入到另一份筆記中,並希望保持文字和圖示的相對尺寸時非常有用。",
|
||||
UIFM_ANCHOR_DESC: "這是一個專業功能,請在瞭解其作用的情況下再使用。啟用後,即使你在 Excalidraw 中調整了匯入影像的大小,下次開啟繪圖時,該影像仍會恢復為原始大小的 100%。當你將一個獨立的 Excalidraw 點子嵌入到另一份筆記中,並希望保持文字和圖示的相對尺寸時,這會很有用。",
|
||||
UIFM_BTN_EMBEDDABLE: "以互動形式",
|
||||
UIFM_BTN_PDF: "PDF 頁面",
|
||||
UIFM_BTN_IMAGE: "以影像形式",
|
||||
|
||||
@@ -37,6 +37,7 @@ export class EmbeddableSettings extends Modal {
|
||||
private isLocalURI: boolean;
|
||||
private mdCustomData: EmbeddableMDCustomProps;
|
||||
private onKeyDown: (ev: KeyboardEvent) => void;
|
||||
private listenerHost: Document | null = null;
|
||||
|
||||
constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
@@ -72,7 +73,10 @@ export class EmbeddableSettings extends Modal {
|
||||
}
|
||||
|
||||
onClose() {
|
||||
this.containerEl.removeEventListener("keydown",this.onKeyDown);
|
||||
if(this.listenerHost && this.onKeyDown) {
|
||||
this.listenerHost.removeEventListener("keydown",this.onKeyDown);
|
||||
this.listenerHost = null;
|
||||
}
|
||||
this.plugin = null;
|
||||
this.view = null;
|
||||
this.file = null;
|
||||
@@ -166,7 +170,11 @@ export class EmbeddableSettings extends Modal {
|
||||
}
|
||||
|
||||
this.onKeyDown = onKeyDown;
|
||||
this.containerEl.ownerDocument.addEventListener("keydown",onKeyDown);
|
||||
const ownerDoc = this.containerEl.ownerDocument;
|
||||
if(ownerDoc) {
|
||||
this.listenerHost = ownerDoc;
|
||||
ownerDoc.addEventListener("keydown",onKeyDown);
|
||||
}
|
||||
}
|
||||
|
||||
private async applySettings() {
|
||||
|
||||
@@ -5,7 +5,7 @@ import { DEVICE } from "src/constants/constants";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { fragWithHTML, getExportPadding, getExportTheme, getPNGScale, getWithBackground, shouldEmbedScene } from "src/utils/utils";
|
||||
import { fragWithHTML, getExportInternalLinks, getExportPadding, getExportTheme, getPNGScale, getWithBackground, shouldEmbedScene } from "src/utils/utils";
|
||||
import { exportSVGToClipboard, exportPNG, exportPNGToClipboard } from "src/utils/exportUtils";
|
||||
import { PageOrientation, PageSize, PDFPageAlignment, PDFPageMarginString } from "src/types/exportUtilTypes";
|
||||
import { t } from "src/lang/helpers";
|
||||
@@ -22,6 +22,7 @@ export class ExportDialog extends Modal {
|
||||
public scale: number;
|
||||
public theme: string;
|
||||
public transparent: boolean;
|
||||
public exportInternalLinks: boolean = true;
|
||||
public saveSettings: boolean;
|
||||
public dirty: boolean = false;
|
||||
private selectedOnlySetting: Setting;
|
||||
@@ -64,6 +65,7 @@ export class ExportDialog extends Modal {
|
||||
this.exportSelectedOnly = false;
|
||||
this.saveToVault = true;
|
||||
this.transparent = !getWithBackground(this.plugin, this.file);
|
||||
this.exportInternalLinks = getExportInternalLinks(this.plugin, this.file);
|
||||
|
||||
this.pageSize = plugin.settings.pdfSettings.pageSize;
|
||||
this.pageOrientation = plugin.settings.pdfSettings.pageOrientation;
|
||||
@@ -302,7 +304,17 @@ export class ExportDialog extends Modal {
|
||||
.onChange(value => {
|
||||
this.transparent = value === "transparent";
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
new Setting(this.contentContainer)
|
||||
.setName(t("EXPORTDIALOG_INCLUDE_INTERNAL_LINKS"))
|
||||
.addToggle(toggle =>
|
||||
toggle
|
||||
.setValue(this.exportInternalLinks)
|
||||
.onChange(value => {
|
||||
this.exportInternalLinks = value;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
this.selectedOnlySetting = new Setting(this.contentContainer)
|
||||
|
||||
@@ -1,5 +1,68 @@
|
||||
import { App, Modal } from "obsidian";
|
||||
|
||||
function getClientPoint(e: PointerEvent | TouchEvent) {
|
||||
if (e.type.startsWith("touch")) {
|
||||
const t = (e as TouchEvent).touches[0] ?? (e as TouchEvent).changedTouches[0];
|
||||
return t ? { x: t.clientX, y: t.clientY } : null;
|
||||
}
|
||||
const p = e as PointerEvent;
|
||||
return { x: p.clientX, y: p.clientY };
|
||||
}
|
||||
|
||||
function pointInRect(pt: { x: number; y: number }, r: DOMRect, padding = 1): boolean {
|
||||
return (
|
||||
pt.x >= r.left - padding &&
|
||||
pt.x <= r.right + padding &&
|
||||
pt.y >= r.top - padding &&
|
||||
pt.y <= r.bottom + padding
|
||||
);
|
||||
}
|
||||
|
||||
function isPointOnText(e: PointerEvent | TouchEvent): boolean {
|
||||
const pt = getClientPoint(e);
|
||||
if (!pt) return false;
|
||||
|
||||
let offsetNode: Node | null = null;
|
||||
let offset: number | null = null;
|
||||
|
||||
// Chromium/Firefox-ish
|
||||
const caretPos = (document as any).caretPositionFromPoint?.(pt.x, pt.y);
|
||||
if (caretPos?.offsetNode) {
|
||||
offsetNode = caretPos.offsetNode;
|
||||
offset = typeof caretPos.offset === "number" ? caretPos.offset : null;
|
||||
} else {
|
||||
// Safari/WebKit
|
||||
const caretRange = (document as any).caretRangeFromPoint?.(pt.x, pt.y);
|
||||
if (caretRange?.startContainer) {
|
||||
offsetNode = caretRange.startContainer;
|
||||
offset = typeof caretRange.startOffset === "number" ? caretRange.startOffset : null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!offsetNode || offsetNode.nodeType !== Node.TEXT_NODE || offset == null) return false;
|
||||
if (!offsetNode.textContent?.trim()) return false;
|
||||
|
||||
const textNode = offsetNode as Text;
|
||||
const len = textNode.data.length;
|
||||
const at = Math.max(0, Math.min(offset, len));
|
||||
|
||||
const range = document.createRange();
|
||||
if (at < len) {
|
||||
range.setStart(textNode, at);
|
||||
range.setEnd(textNode, at + 1);
|
||||
} else if (at > 0) {
|
||||
range.setStart(textNode, at - 1);
|
||||
range.setEnd(textNode, at);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
const rects = Array.from(range.getClientRects());
|
||||
if (rects.length === 0) return false;
|
||||
|
||||
return rects.some((r) => pointInRect(pt, r, 1));
|
||||
}
|
||||
|
||||
export class FloatingModal extends Modal {
|
||||
private dragging = false;
|
||||
private offsetX = 0;
|
||||
@@ -34,7 +97,9 @@ export class FloatingModal extends Modal {
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement ||
|
||||
target instanceof HTMLButtonElement ||
|
||||
target.closest(".clickable-icon")
|
||||
isPointOnText(e) ||
|
||||
target.closest(".clickable-icon") ||
|
||||
target.closest(".modal-close-button") // ensure close button never starts drag
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -51,6 +116,7 @@ export class FloatingModal extends Modal {
|
||||
const { modalEl } = this;
|
||||
this.offsetX = touch.clientX - modalEl.getBoundingClientRect().left;
|
||||
this.offsetY = touch.clientY - modalEl.getBoundingClientRect().top;
|
||||
modalEl.style.height = "fit-content";
|
||||
|
||||
// Add touch-specific event listeners
|
||||
document.addEventListener("touchmove", this.pointerMoveHandler as (e: TouchEvent) => void, {
|
||||
@@ -178,6 +244,12 @@ export class FloatingModal extends Modal {
|
||||
}
|
||||
// Add ESC listener (capture to run before underlying workspace)
|
||||
document.addEventListener("keydown", this.escListener, { capture: true });
|
||||
|
||||
// NEW: re-enable pointer events on the close button so it is tappable on mobile
|
||||
const closeBtn = containerEl.querySelector(".modal-close-button");
|
||||
if (closeBtn) {
|
||||
(closeBtn as HTMLElement).style.pointerEvents = "auto";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+137
-52
@@ -17,12 +17,146 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
|
||||
<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.19.0":`
|
||||
## New in ExcalidrawAutomate
|
||||
- **setView() improvements**
|
||||
- Calling \`setView()\` now picks a sensible target automatically:
|
||||
- It prefers the **currently active Excalidraw view**.
|
||||
- If no active Excalidraw view is found (e.g., the user is focused on a different tab like the File Explorer/sidebar), it will fall back to the **last active Excalidraw view (as long as it is still available)** — typically the drawing the user came from.
|
||||
- **New selector**: \`"auto"\` (equivalent to calling \`setView()\`).
|
||||
- Useful when you also want to reveal/focus the view: \`setView("auto", true)\`.
|
||||
- **Deprecated selectors**: \`"active"\` and \`"first"\` are deprecated and kept only for backward compatibility.
|
||||
- Recommended usage is either \`setView()\`, \`setView("auto")\`, or \`setView(excalidrawView)\` (explicitly target a specific view).
|
||||
|
||||
\`\`\`ts
|
||||
setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false)
|
||||
\`\`\`
|
||||
`,
|
||||
"2.18.3":`
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=dZguonMP2KU" target="_blank"><img src ="https://i.ytimg.com/vi/dZguonMP2KU/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
|
||||
## New
|
||||
- Added Mindmap Builder script to the store.
|
||||
- LaTeX Suit Integration by [@TravisLEBLANC1](https://github.com/TravisLEBLANC1)
|
||||
- Added Linear Calendar Generator script to the store. 🙏 [@iwanhoogendoorn](https://github.com/iwanhoogendoorn)
|
||||
|
||||
## Fixed
|
||||
- YouTube video embeds working on iOS [#2569](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2569)
|
||||
- Stroke color setting for Embeddedables (markdown notes, websites) is missing after 2.17.0 update [#2580](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2580)
|
||||
- Context menu paste pastes in image twice [#10542](https://github.com/excalidraw/excalidraw/issues/10542)
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
- Added 3 new helper functions for working with Script Engine settings (safe during initialization when \`scriptEngineSettings[activeScript]\` is \`undefined\` / \`null\`):
|
||||
- \`setScriptSettingValue(key: string, value: ScriptSettingValue): void\`
|
||||
- \`getScriptSettingValue(key: string, defaultValue: ScriptSettingValue): ScriptSettingValue\`
|
||||
- \`saveScriptSettings(): Promise<void>\`
|
||||
|
||||
- Updated \`addArrow()\` to support the new Excalidraw binding options:
|
||||
- \`startBindMode?: "inside" | "orbit"\`
|
||||
- \`endBindMode?: "inside" | "orbit"\`
|
||||
- \`startFixedPoint?: [number, number]\`
|
||||
- \`endFixedPoint?: [number, number]\`
|
||||
- \`elbowed?: boolean\`
|
||||
|
||||
\`\`\`ts
|
||||
/**
|
||||
* Returns an object describing the bound text element.
|
||||
* If a text element is provided:
|
||||
* - returns { eaElement } if the element is in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If a container element is provided, searches for the bound text element:
|
||||
* - returns { eaElement } if found in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If not found, returns {}.
|
||||
* Does not add the text element to elementsDict.
|
||||
* @param element
|
||||
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
|
||||
* @returns Object containing either eaElement or sceneElement or empty if not found.
|
||||
*/
|
||||
getBoundTextElement(element: ExcalidrawElement, searchInView: boolean = false): {
|
||||
eaElement?: Mutable<ExcalidrawTextElement>,
|
||||
sceneElement?: ExcalidrawTextElement
|
||||
};
|
||||
\`\`\`
|
||||
`,
|
||||
"2.18.2":`
|
||||
## Fixed
|
||||
- Stroke palette menu for embedded notes is gone after 2.17 update [#2580](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2580)
|
||||
- Cannot link to group [#2579](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2579)
|
||||
|
||||
`,
|
||||
"2.18.1":`
|
||||
## New
|
||||
- Improved the **Copy [[link]] for selected elements** context-menu action:
|
||||
- Added an optional checkbox to append the \`|100%\` anchor to the copied link.
|
||||
- Added an option to copy by **frame name** (instead of frame ID) when the frame is named.
|
||||
|
||||
## Fixed
|
||||
- Prevented unnecessary \`data.json\` saves each time a drawing is opened. [#2562](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2562)
|
||||
- Fixed angle snapping when a line passes over an object.
|
||||
- Fixed hover preview when referencing a frame by name in an image reference.
|
||||
- Fixed “Back of note” card insertion breaking LaTeX equations in existing cards. [#2296](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2296) 🙏[@TravisLEBLANC1](https://github.com/TravisLEBLANC1)
|
||||
- Adjusted hover-preview sizing to more closely match embeds. [#2525](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2575) 🙏[parkero](https://github.com/parkero)
|
||||
`,
|
||||
"2.18.0":`
|
||||
## New from Excalidraw.com
|
||||
- 🔥🔥🔥 New arrow behavior allows binding arrows to the inside of shapes and image! 🙏[mtolmacs](https://github.com/mtolmacs), [dwelle](https://github.com/dwelle) [#9670](https://github.com/excalidraw/excalidraw/pull/9670)
|
||||
|
||||
## New
|
||||
- New option in the Export Dialog to **include/exclude internal links** when exporting to SVG or PDF.
|
||||
- Useful when sharing an SVG or PDF with others.
|
||||
- Internal links are links that point to files in your Obsidian vault.
|
||||
- By default, internal links are included in exports.
|
||||
- Use the new document property: \`export-internal-links: false\` to disable exporting internal links on a per-drawing basis.
|
||||
|
||||
## Fixed
|
||||
- Memory leak issues
|
||||
- Potential fix to Backspace and CTRL+V stopping working in text elements after extended use of Excalidraw.
|
||||
- Improved detection of on-screen keyboard on mobile devices. (issue reported on [Discord](https://discord.com/channels/1026825302900494357/1444652800360316959))
|
||||
- Insert any file, insert LaTeX and some other dialogs got hidden behind the on-screen keyboard on mobile devices. Dialogs appear at the top of the screen now on mobile devices.
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
- **createSVG()** now exposes convertMarkdownLinksToObsidianURLs and includeInternalLinks parameters.
|
||||
\`\`\`ts
|
||||
async createSVG(
|
||||
templatePath?: string,
|
||||
embedFont: boolean = false,
|
||||
exportSettings?: ExportSettings,
|
||||
loader?: EmbeddedFilesLoader,
|
||||
theme?: string,
|
||||
padding?: number,
|
||||
convertMarkdownLinksToObsidianURLs: boolean = false,
|
||||
includeInternalLinks: boolean = true,
|
||||
): Promise<SVGSVGElement>
|
||||
\`\`\`
|
||||
`,
|
||||
"2.17.2":`
|
||||
## Fixed
|
||||
- Lasso selection tool is back in the more tools menu in tray-mode and desktop mode.
|
||||
- "Toggle enable context menu" command palette action is available on mobile devices.
|
||||
- FloatingModal window top-right close button did not work on mobile devices.
|
||||
- Hover preview flashed for larger PDF hover previews, in some cases would not even show.
|
||||
- Fixed: opanAI API URL in settings will be honored when creating code from diagram [#2540](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2540) 🙏[@threeq](https://github.com/threeq)
|
||||
- Fixed export to PDF. Rounded images cropped from the left and the top were transformed incorrectly. [#2544](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2544)
|
||||
|
||||
## New
|
||||
- Added configurable max tokens setting for OpenAI API [#2543](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2543) 🙏[@dddrop](https://github.com/dddrop)
|
||||
`,
|
||||
"2.17.1":`
|
||||
## Fixed
|
||||
- Excalibrain stopped working after the 2.17.0 update. Fixed. [#2532](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2532)
|
||||
- Pinned scripts are not hidden in view mode when in phone UI mode.
|
||||
`,
|
||||
"2.17.0":`
|
||||
## New
|
||||
- Phone UI from Excalidraw.com [#9996](https://github.com/excalidraw/excalidraw/pull/9996)
|
||||
- Custom pen settings now allow pen width to be set at 0.1 increments from 0.1 to 8.0
|
||||
- Updated the "Palm Guard" script to support the change UI configurations.
|
||||
- Setting under Modes in Plugin Settings to prefer "compact-mode" on desktops when toggling tray mode.
|
||||
- Restructured UI-Mode settings in plugin settings. You can now set the preference for UI mode for desktop and tablets.
|
||||
The old "prefer tray-mode" toggle has been removed. "Toggle Tray-Mode" changes to "Toggle UI-Mode".
|
||||
- New command palette action: "Toggle enable context menu". This setting is helpful on Mobile devices, where the context menu may interfere with touch interactions. The setting is saved with the drawing, thus you can add it to your templates (then press CTRL+S to force save) if you want the context menu to be disabled by default.
|
||||
|
||||
## Fixed
|
||||
- side panel does not attach correctly when library is pinned [#2510](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2510)
|
||||
@@ -31,7 +165,8 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
- Fixed duplicated PDF elements after copy-pasting from scene to scene.
|
||||
- Resolved the large gap at the top on iOS devices. As it turns out, Apple adds additional padding automatically to avoid collision with the notch.
|
||||
- Fixed the positioning of the "Canvas and Shape Properties" window.
|
||||
- Attempt to fix mobile keyboard popup distorting the view.
|
||||
- Attempt to fix the mobile keyboard pop-up, distorting the view.
|
||||
- Added finalize multipoint-line button to compact layout
|
||||
`,
|
||||
"2.16.1":`
|
||||
## Fixed
|
||||
@@ -152,54 +287,4 @@ public getViewCenterPosition(): {x:number, y:number};
|
||||
):ExcalidrawElement[]
|
||||
\`\`\`
|
||||
`,
|
||||
"2.14.3":`
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=29EWeglRm7s" target="_blank"><img src ="https://i.ytimg.com/vi/29EWeglRm7s/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
|
||||
Updated the Printable Layout Wizard script with the option to exclude empty pages.
|
||||
|
||||
## Fixed
|
||||
- If a frame is locked, elements created over the frame or dragged over the frame should not be auto-added to the frame. [#9850](https://github.com/excalidraw/excalidraw/issues/9850)
|
||||
|
||||
## Fixed in ExcalidrawAutomate
|
||||
- Not all AppState properties were being correctly copied to the template when creating a new drawing with ea.create() [#2440](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2440)
|
||||
`,
|
||||
"2.14.2":`
|
||||
## Fixed
|
||||
- Converting Markdown to Excalidraw ("Back of note"/"Convert markdown to ExcaliDrawing") no longer appends T00:00:00.000Z to an existing date frontmatter field and handles merging of lists such as tags intelligently [#2414](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2414)
|
||||
- Multi‑point line creation on touchscreens (tap–tap–tap) produced a horizontal line after using a pen. Fixed. [#9840](https://github.com/excalidraw/excalidraw/pull/9840#issuecomment-3165319266)
|
||||
|
||||
## New
|
||||
- Zoom settings (Settings → Excalidraw → Appearance and Behavior → Zoom) [#2434](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2434):
|
||||
- Zoom increment (default 5%) to fine‑tune mouse wheel / gesture precision.
|
||||
- Minimum zoom (default 10%) controls how far you can zoom out (below 10% may be unstable—use with caution).
|
||||
- Maximum zoom (default 3000%) defines the upper zoom limit.
|
||||
- Palm Guard script (in script store): Mobile-friendly drawing mode for stylus users. Enters fullscreen, hides UI, shows a draggable minimal toolbar (toggle + exit) to prevent accidental palm taps; single tap to exit. Inspired by [#2409](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2409)
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=A_udjVjgWN0" target="_blank"><img src ="https://i.ytimg.com/vi/A_udjVjgWN0/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
|
||||
## ExcalidrawAutomate
|
||||
- Improved \`FloatingModal\` behavior. Floating Modal now does not trap keyboard events, the header element does not block "X" button in the top right corner, all four corners are rounded on Mobile Devices.
|
||||
|
||||
`,
|
||||
"2.14.1":`
|
||||
## Fixed
|
||||
- Excalidraw broke Obsidian's UI in Arabic, Persian, and Hebrew due to LTR, RTL conflict. [#2423](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2423)
|
||||
- Styling issues impacting native Obsidian search/replace dialogs. [#2420](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2420)
|
||||
- Now using native Obsidian attachment location function. 🙏 [mnaoumov](https://github.com/mnaoumov) [#2421](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2421), potentially fixes [#179](https://github.com/RainCat1998/obsidian-custom-attachment-location/issues/179) of the Obsidian Custom Attachment Location plugin issue.
|
||||
|
||||
## New
|
||||
- New frontmatter option \`excalidraw-embed-md\`. When set to \`true\`, embedding the drawing into a markdown note will render the "back of the note" (its markdown content) instead of rendering it as an image.
|
||||
- If you want to always display the drawing as an image, even when \`excalidraw-embed-md\` is enabled, use the special embed syntax: \`![[drawing#^as-image]]\`. Here, \`as-image\` is a phantom block reference that forces image rendering.
|
||||
- Added Spanish translation by [@Joakim31](https://github.com/Joakim31) [#2425](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2425)
|
||||
- Incremental minor updates from the main [Excalidraw project](https://github.com/excalidraw/excalidraw).
|
||||
`,
|
||||
"2.14.0":`
|
||||
## A Big "Small" Update
|
||||
- Added search to Excalidraw Settings, plus added a link to access the public NotebookLM workbook pre-loaded with everything about the plugin
|
||||
- New Taiwan-idiomatic Traditional Chinese translation by [@rlan](https://github.com/rlan) [#2413](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2413)
|
||||
`,
|
||||
};
|
||||
+233
-51
@@ -8,6 +8,7 @@ import {
|
||||
TFile,
|
||||
Notice,
|
||||
TextAreaComponent,
|
||||
getIcon,
|
||||
} from "obsidian";
|
||||
import ExcalidrawView from "../../view/ExcalidrawView";
|
||||
import ExcalidrawPlugin from "../../core/main";
|
||||
@@ -23,6 +24,11 @@ import { REGEX_LINK, REGEX_TAGS } from "../ExcalidrawData";
|
||||
import { ScriptEngine } from "../Scripts";
|
||||
import { openExternalLink, openTagSearch, parseObsidianLink } from "src/utils/excalidrawViewUtils";
|
||||
import { ButtonDefinition } from "src/types/promptTypes";
|
||||
import { EditorView, keymap } from "@codemirror/view";
|
||||
import { history } from "@codemirror/commands";
|
||||
import { parser } from "./math-only";
|
||||
import { LRLanguage } from "@codemirror/language";
|
||||
import { editorLivePreviewField } from "obsidian";
|
||||
|
||||
export class Prompt extends Modal {
|
||||
private promptEl: HTMLInputElement;
|
||||
@@ -79,6 +85,149 @@ export class Prompt extends Modal {
|
||||
}
|
||||
}
|
||||
|
||||
export class LaTexPrompt extends Modal {
|
||||
public waitForClose : Promise<string>;
|
||||
private promptEl: HTMLInputElement;
|
||||
private resolvePromise: (input: string) => void;
|
||||
private rejectPromise: (reason?: any) => void;
|
||||
private editorView : EditorView;
|
||||
private latexsSuitePlugin : any;
|
||||
|
||||
protected constructor(
|
||||
app: App,
|
||||
private prompt_text: string,
|
||||
private default_value?: string,
|
||||
) {
|
||||
super(app);
|
||||
this.titleEl.setText(this.prompt_text);
|
||||
this.contentEl.addClass("excalidraw-LatexPrompt");
|
||||
this.latexsSuitePlugin = app.plugins.plugins["obsidian-latex-suite"];
|
||||
const mainContentContainer: HTMLDivElement = this.contentEl.createDiv();
|
||||
this.display(default_value, mainContentContainer);
|
||||
this.waitForClose = new Promise<string>((resolve, reject) => {
|
||||
this.resolvePromise = resolve;
|
||||
this.rejectPromise = reject;
|
||||
});
|
||||
this.editorView.focus();
|
||||
}
|
||||
|
||||
public static Prompt(app: App,
|
||||
prompt_text?: string,
|
||||
default_value?: string,
|
||||
): Promise<string>{
|
||||
const latexprompt = new LaTexPrompt(app, prompt_text, default_value);
|
||||
|
||||
return latexprompt.waitForClose;
|
||||
}
|
||||
|
||||
private display(value : string, container : HTMLDivElement) {
|
||||
if (this.latexsSuitePlugin) {
|
||||
// the language put eveything in a "math" node
|
||||
// surrounded by "math-begin" and "math-end"
|
||||
// so that latex-suite always thinks we are in mathmode
|
||||
const language = LRLanguage.define({parser:parser});
|
||||
const extensions = [
|
||||
language,
|
||||
keymap.of([{
|
||||
key:"Mod-Enter",
|
||||
run : () => {this.submitCallback(); return true;}
|
||||
}]),
|
||||
history(),
|
||||
editorLivePreviewField.init(() => false),
|
||||
... this.latexsSuitePlugin.editorExtensions
|
||||
];
|
||||
|
||||
this.editorView = new EditorView({
|
||||
doc: value,
|
||||
parent : container,
|
||||
extensions : extensions,
|
||||
});
|
||||
} else {
|
||||
const extensions = [
|
||||
keymap.of([{
|
||||
key:"Mod-Enter",
|
||||
run : () => {this.submitCallback(); return true;}
|
||||
}]),
|
||||
history(),
|
||||
];
|
||||
this.editorView = new EditorView({
|
||||
doc: value,
|
||||
extensions : extensions,
|
||||
parent : container,
|
||||
});
|
||||
}
|
||||
|
||||
const buttonBarContainer: HTMLDivElement = container.createDiv();
|
||||
buttonBarContainer.addClass(`excalidraw-prompt-buttonbar-bottom`);
|
||||
const actionButtonContainer: HTMLDivElement = buttonBarContainer.createDiv();
|
||||
|
||||
this.createButton(
|
||||
actionButtonContainer,
|
||||
"",
|
||||
this.submitCallback.bind(this),
|
||||
t("PROMPT_BUTTON_OK") ?? "",
|
||||
undefined,
|
||||
"check"
|
||||
).setCta().buttonEl.style.marginRight = "0";
|
||||
this.createButton(
|
||||
actionButtonContainer,
|
||||
"",
|
||||
this.cancelCallback.bind(this),
|
||||
t("PROMPT_BUTTON_CANCEL"),
|
||||
undefined,
|
||||
"x"
|
||||
);
|
||||
this.open();
|
||||
}
|
||||
|
||||
private createButton(container: HTMLElement,
|
||||
text: string,
|
||||
callback: (evt: MouseEvent) => any,
|
||||
tooltip: string = "",
|
||||
margin: string = "5px",
|
||||
iconId?:string,
|
||||
){
|
||||
const btn = new ButtonComponent(container);
|
||||
btn.buttonEl.style.padding = "0.5em";
|
||||
btn.buttonEl.style.marginLeft = margin;
|
||||
btn.setTooltip(tooltip);
|
||||
|
||||
if (iconId) {
|
||||
btn.setIcon(iconId);
|
||||
} else {
|
||||
btn.setButtonText(text);
|
||||
}
|
||||
|
||||
btn.onClick(callback);
|
||||
return btn;
|
||||
}
|
||||
|
||||
private submitCallback(){
|
||||
const res = this.editorView.state.doc.toString();
|
||||
if (res.trim().length == 0) {
|
||||
this.rejectPromise("empty latex");
|
||||
} else {
|
||||
this.resolvePromise(res);
|
||||
}
|
||||
this.close();
|
||||
}
|
||||
|
||||
private cancelCallback(){
|
||||
this.rejectPromise("Canceled input");
|
||||
this.close();
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
super.onOpen();
|
||||
this.editorView.focus();
|
||||
}
|
||||
|
||||
onClose(): void {
|
||||
this.contentEl.empty();
|
||||
this.editorView.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
export class GenericInputPrompt extends Modal {
|
||||
public waitForClose: Promise<string>;
|
||||
private view: ExcalidrawView;
|
||||
@@ -101,6 +250,26 @@ export class GenericInputPrompt extends Modal {
|
||||
private draggable: boolean = false;
|
||||
private cleanupDragListeners: (() => void) | null = null;
|
||||
|
||||
// Add event handler instance properties
|
||||
private handleKeyDown = (evt: KeyboardEvent) => {
|
||||
if ((evt.key === "Enter" && this.lines === 1) || (isWinCTRLorMacCMD(evt) && evt.key === "Enter")) {
|
||||
evt.preventDefault();
|
||||
this.submit();
|
||||
}
|
||||
if (this.displayEditorButtons && evt.key === "k" && isWinCTRLorMacCMD(evt)) {
|
||||
evt.preventDefault();
|
||||
this.linkBtnClickCallback();
|
||||
}
|
||||
};
|
||||
|
||||
private handleCheckCaret = () => {
|
||||
//timer is implemented because on iPad with pencil the button click generates an event on the textarea
|
||||
this.selectionUpdateTimer = this.view.ownerWindow.setTimeout(() => {
|
||||
this.selectionStart = this.inputComponent.inputEl.selectionStart;
|
||||
this.selectionEnd = this.inputComponent.inputEl.selectionEnd;
|
||||
}, 30);
|
||||
};
|
||||
|
||||
public static Prompt(
|
||||
view: ExcalidrawView,
|
||||
plugin: ExcalidrawPlugin,
|
||||
@@ -141,7 +310,7 @@ export class GenericInputPrompt extends Modal {
|
||||
private header: string,
|
||||
placeholder?: string,
|
||||
value?: string,
|
||||
buttons?: { caption: string; action: Function }[],
|
||||
buttons?: ButtonDefinition[],
|
||||
lines?: number,
|
||||
displayEditorButtons?: boolean,
|
||||
customComponents?: (container: HTMLElement) => void,
|
||||
@@ -226,25 +395,15 @@ export class GenericInputPrompt extends Modal {
|
||||
.setValue(value ?? "")
|
||||
.onChange((value) => (this.input = value));
|
||||
|
||||
let i = 0;
|
||||
|
||||
const checkcaret = () => {
|
||||
//timer is implemented because on iPad with pencil the button click generates an event on the textarea
|
||||
this.selectionUpdateTimer = this.view.ownerWindow.setTimeout(() => {
|
||||
this.selectionStart = this.inputComponent.inputEl.selectionStart;
|
||||
this.selectionEnd = this.inputComponent.inputEl.selectionEnd;
|
||||
}, 30);
|
||||
}
|
||||
|
||||
textComponent.inputEl.addEventListener("keydown", this.keyDownCallback.bind(this));
|
||||
textComponent.inputEl.addEventListener('keyup', checkcaret.bind(this)); // Every character written
|
||||
textComponent.inputEl.addEventListener('pointerup', checkcaret.bind(this)); // Click down
|
||||
textComponent.inputEl.addEventListener('touchend', checkcaret.bind(this)); // Click down
|
||||
textComponent.inputEl.addEventListener('input', checkcaret.bind(this)); // Other input events
|
||||
textComponent.inputEl.addEventListener('paste', checkcaret.bind(this)); // Clipboard actions
|
||||
textComponent.inputEl.addEventListener('cut', checkcaret.bind(this));
|
||||
textComponent.inputEl.addEventListener('select', checkcaret.bind(this)); // Some browsers support this event
|
||||
textComponent.inputEl.addEventListener('selectionchange', checkcaret.bind(this));// Some browsers support this event
|
||||
textComponent.inputEl.addEventListener("keydown", this.handleKeyDown);
|
||||
textComponent.inputEl.addEventListener('keyup', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('pointerup', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('touchend', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('input', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('paste', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('cut', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('select', this.handleCheckCaret);
|
||||
textComponent.inputEl.addEventListener('selectionchange', this.handleCheckCaret);
|
||||
|
||||
return textComponent;
|
||||
}
|
||||
@@ -255,12 +414,20 @@ export class GenericInputPrompt extends Modal {
|
||||
callback: (evt: MouseEvent) => any,
|
||||
tooltip: string = "",
|
||||
margin: string = "5px",
|
||||
iconId?:string,
|
||||
) {
|
||||
const btn = new ButtonComponent(container);
|
||||
btn.buttonEl.style.padding = "0.5em";
|
||||
btn.buttonEl.style.marginLeft = margin;
|
||||
btn.setTooltip(tooltip);
|
||||
btn.setButtonText(text).onClick(callback);
|
||||
|
||||
if (iconId) {
|
||||
btn.setIcon(iconId);
|
||||
} else {
|
||||
btn.setButtonText(text);
|
||||
}
|
||||
|
||||
btn.onClick(callback);
|
||||
return btn;
|
||||
}
|
||||
|
||||
@@ -276,13 +443,17 @@ export class GenericInputPrompt extends Modal {
|
||||
const btn = new ButtonComponent(actionButtonContainer);
|
||||
btn.buttonEl.style.marginLeft="5px";
|
||||
if(button.tooltip) btn.setTooltip(button.tooltip);
|
||||
btn.setButtonText(button.caption).onClick((evt: MouseEvent) => {
|
||||
const res = button.action(this.input);
|
||||
if (res) {
|
||||
this.input = res;
|
||||
}
|
||||
this.submit();
|
||||
});
|
||||
button.iconId
|
||||
? btn.setIcon(button.iconId)
|
||||
: btn.setButtonText(button.caption);
|
||||
button.tooltip && btn.setTooltip(button.tooltip);
|
||||
btn.onClick((evt: MouseEvent) => {
|
||||
const res = button.action(this.input);
|
||||
if (res) {
|
||||
this.input = res;
|
||||
}
|
||||
this.submit();
|
||||
});
|
||||
b = b ?? btn;
|
||||
}
|
||||
if (b) {
|
||||
@@ -292,20 +463,32 @@ export class GenericInputPrompt extends Modal {
|
||||
} else {
|
||||
this.createButton(
|
||||
actionButtonContainer,
|
||||
"✅",
|
||||
"",
|
||||
this.submitClickCallback.bind(this),
|
||||
t("PROMPT_BUTTON_OK") ?? "",
|
||||
"5px",
|
||||
"check",
|
||||
).setCta().buttonEl.style.marginRight = "0";
|
||||
}
|
||||
this.createButton(actionButtonContainer, "❌", this.cancelClickCallback.bind(this), t("PROMPT_BUTTON_CANCEL"));
|
||||
|
||||
this.createButton(
|
||||
actionButtonContainer,
|
||||
"",
|
||||
this.cancelClickCallback.bind(this),
|
||||
t("PROMPT_BUTTON_CANCEL"),
|
||||
"5px",
|
||||
"x",
|
||||
);
|
||||
|
||||
if(this.displayEditorButtons) {
|
||||
this.createButton(editorButtonContainer, "⏎", ()=>this.insertStringBtnClickCallback("\n"), t("PROMPT_BUTTON_INSERT_LINE"), "0");
|
||||
this.createButton(editorButtonContainer, "⌫", this.delBtnClickCallback.bind(this), "Delete");
|
||||
this.createButton(editorButtonContainer, "⎵", ()=>this.insertStringBtnClickCallback(" "), t("PROMPT_BUTTON_INSERT_SPACE"));
|
||||
this.createButton(editorButtonContainer, "§", this.specialCharsBtnClickCallback.bind(this), t("PROMPT_BUTTON_SPECIAL_CHARS"));
|
||||
this.createButton(editorButtonContainer, "", ()=>this.insertStringBtnClickCallback("\n"), t("PROMPT_BUTTON_INSERT_LINE"), "0", "corner-down-left");
|
||||
this.createButton(editorButtonContainer, "", this.delBtnClickCallback.bind(this), "Delete", "5px", "delete");
|
||||
this.createButton(editorButtonContainer, "", ()=>this.insertStringBtnClickCallback(" "), t("PROMPT_BUTTON_INSERT_SPACE"), "5px", "space");
|
||||
this.createButton(editorButtonContainer, "", this.specialCharsBtnClickCallback.bind(this), t("PROMPT_BUTTON_SPECIAL_CHARS"), "5px", "at-sign");
|
||||
if(this.view) {
|
||||
this.createButton(editorButtonContainer, "🔗", this.linkBtnClickCallback.bind(this), t("PROMPT_BUTTON_INSERT_LINK"));
|
||||
this.createButton(editorButtonContainer, "", this.linkBtnClickCallback.bind(this), t("PROMPT_BUTTON_INSERT_LINK"), "5px", "link");
|
||||
}
|
||||
this.createButton(editorButtonContainer, "🔠", this.uppercaseBtnClickCallback.bind(this), t("PROMPT_BUTTON_UPPERCASE"));
|
||||
this.createButton(editorButtonContainer, "", this.uppercaseBtnClickCallback.bind(this), t("PROMPT_BUTTON_UPPERCASE"), "5px", "arrow-big-up");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,17 +555,6 @@ export class GenericInputPrompt extends Modal {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
private keyDownCallback = (evt: KeyboardEvent) => {
|
||||
if ((evt.key === "Enter" && this.lines === 1) || (isWinCTRLorMacCMD(evt) && evt.key === "Enter")) {
|
||||
evt.preventDefault();
|
||||
this.submit();
|
||||
}
|
||||
if (this.displayEditorButtons && evt.key === "k" && isWinCTRLorMacCMD(evt)) {
|
||||
evt.preventDefault();
|
||||
this.linkBtnClickCallback();
|
||||
}
|
||||
};
|
||||
|
||||
private submit() {
|
||||
this.didSubmit = true;
|
||||
this.close();
|
||||
@@ -401,10 +573,18 @@ export class GenericInputPrompt extends Modal {
|
||||
}
|
||||
|
||||
private removeInputListener() {
|
||||
this.inputComponent?.inputEl?.removeEventListener(
|
||||
"keydown",
|
||||
this.keyDownCallback,
|
||||
);
|
||||
if (!this.inputComponent?.inputEl) return;
|
||||
|
||||
const inputEl = this.inputComponent.inputEl;
|
||||
inputEl.removeEventListener("keydown", this.handleKeyDown);
|
||||
inputEl.removeEventListener('keyup', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('pointerup', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('touchend', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('input', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('paste', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('cut', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('select', this.handleCheckCaret);
|
||||
inputEl.removeEventListener('selectionchange', this.handleCheckCaret);
|
||||
}
|
||||
|
||||
private specialCharsBtnClickCallback = (evt: MouseEvent) => {
|
||||
@@ -477,6 +657,8 @@ export class GenericInputPrompt extends Modal {
|
||||
|
||||
onOpen() {
|
||||
super.onOpen();
|
||||
this.modalEl.classList.add("excalidraw-modal");
|
||||
this.containerEl.classList.add("excalidraw-modal");
|
||||
this.inputComponent.inputEl.focus();
|
||||
this.inputComponent.inputEl.select();
|
||||
|
||||
|
||||
@@ -202,6 +202,22 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
desc: "Get single element from ExcalidrawAutomate elementsDict",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "getBoundTextElement",
|
||||
code:
|
||||
"getBoundTextElement(element: ExcalidrawElement, searchInView?: boolean): { eaElement?: Mutable<ExcalidrawTextElement>; sceneElement?: ExcalidrawTextElement; };",
|
||||
desc:
|
||||
"Returns an object describing the bound text element.\n" +
|
||||
"If a text element is provided:\n" +
|
||||
" - returns { eaElement } if the element is in ea.elementsDict\n" +
|
||||
" - else (if searchInView is true) returns { sceneElement } if found in the targetView scene\n" +
|
||||
"If a container element is provided, searches for the bound text element:\n" +
|
||||
" - returns { eaElement } if found in ea.elementsDict\n" +
|
||||
" - else (if searchInView is true) returns { sceneElement } if found in the targetView scene\n" +
|
||||
"If not found, returns {}.\n" +
|
||||
"Does not add the text element to elementsDict.",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "create",
|
||||
code: 'async create(params?: {filename?: string, foldername?: string, templatePath?: string, onNewPane?: boolean, silent?: boolean, frontmatterKeys?: {},}): Promise<string>;',
|
||||
@@ -221,12 +237,13 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
' "excalidraw-linkbutton-opacity"?: number;\n' +
|
||||
' "excalidraw-autoexport"?: boolean;\n' +
|
||||
' "excalidraw-mask"?: boolean;\n' +
|
||||
' "excalidraw-export-internal-links"?: boolean;\n' +
|
||||
' "cssclasses"?: string;\n}',
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "createSVG",
|
||||
code: "async createSVG(templatePath?: string, embedFont?: boolean, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string,): Promise<SVGSVGElement>;",
|
||||
code: "async createSVG(templatePath?: string, embedFont?: boolean, exportSettings?: ExportSettings, loader?: EmbeddedFilesLoader, theme?: string, padding?: number, convertMarkdownLinksToObsidianURLs: boolean = false, includeInternalLinks: boolean = true,): Promise<SVGSVGElement>;",
|
||||
desc: "Use ExcalidrawAutomate.getExportSettings(boolean,boolean) to create an ExportSettings object.\nUse ExcalidrawAutomate.getEmbeddedFilesLoader(boolean?) to create an EmbeddedFilesLoader object.",
|
||||
after: "",
|
||||
},
|
||||
@@ -387,8 +404,14 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
},
|
||||
{
|
||||
field: "addArrow",
|
||||
code: "addArrow(points: [[x: number, y: number]], formatting?: { startArrowHead?: string; endArrowHead?: string; startObjectId?: string; endObjectId?: string;}, id?:string): string;",
|
||||
desc: `valid values for startArrowHead and endArrowHead are: "arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null`,
|
||||
code:
|
||||
'addArrow(points: [x: number, y: number][], formatting?: { startArrowHead?: string; endArrowHead?: string; startObjectId?: string; endObjectId?: string; startBindMode?: string; endBindMode?: string; startFixedPoint?: [number, number]; endFixedPoint?: [number, number]; elbowed?: boolean}, id?: string): string;',
|
||||
desc:
|
||||
"Adds an arrow element.\n" +
|
||||
'Arrowheads: "arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null.\n' +
|
||||
'Bindings: "inside" | "outside" Sets startObjectId/endObjectId to bind the arrow ends to shapes. Bind mode: "orbit" (default) or "inside".\n' +
|
||||
"Fixed point: [xRatio,yRatio] in 0..1 (percentage of bound element width/height) to bind to a specific point on the element. In case of orbit mode, the orbit will happen around this immaginary point.\n" +
|
||||
"Elbowed: true will create an elbowed arrow.",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
@@ -468,9 +491,18 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
},
|
||||
{
|
||||
field: "setView",
|
||||
code: 'setView(view: ExcalidrawView | "first" | "active"): ExcalidrawView;',
|
||||
desc: null,
|
||||
after: "",
|
||||
code: 'setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false): ExcalidrawView;',
|
||||
desc: "Sets the target view for EA. All the view operations and the access to Excalidraw API will be performed on this view. " +
|
||||
"Typically you will use setView() (to pick a sensible default) or setView(excalidrawView) (to explicitly target a specific view).\n" +
|
||||
'"auto" is equivalent to calling setView() and can read nicer when you want to show the view (e.g. setView("auto", true)).\n' +
|
||||
'"active" and "first" are deprecated and are kept for backward compatibility.\n' +
|
||||
'If view is null or undefined (or "auto"), EA will pick a sensible default: first the currently active Excalidraw view (if any), otherwise the last active Excalidraw view (if it is still available), otherwise the "first" Excalidraw view in the workspace.\n' +
|
||||
"If show is true, the view will be brought to front and focused.\n" +
|
||||
'If "first" is provided, the target will be the first Excalidraw view returned by Obsidian\'s workspace leaf collection (i.e., the first item in getExcalidrawViews()). ' +
|
||||
"This ordering is managed by Obsidian and does not necessarily match what a user would consider the “first” view; from a user's perspective it may appear random.\n" +
|
||||
'If "active" is provided, the currently active Excalidraw view in the workspace will be used. If that is not available, then the last active Excalidraw view will be used.\n' +
|
||||
"The function returns the ExcalidrawView that was set as targetView.",
|
||||
after: '("auto",true);',
|
||||
},
|
||||
{
|
||||
field: "getExcalidrawAPI",
|
||||
@@ -678,6 +710,37 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
desc: `Sets script settings.\nSee for more details: ${hyperlink("https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html","Script Engine Help")}`,
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "setScriptSettingValue",
|
||||
code: "setScriptSettingValue(key: string, value: ScriptSettingValue): void;",
|
||||
desc:
|
||||
`Sets a single Script Engine setting value for the active script (in-memory).\n` +
|
||||
`Use saveScriptSettings() to persist changes.\n` +
|
||||
`Handles initialization when scriptEngineSettings[activeScript] is undefined/null.\n` +
|
||||
`See for more details: ${hyperlink("https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html","Script Engine Help")}\n\n` +
|
||||
`type ScriptSettingValue = { value?: string; hidden?: boolean; description?: string; valueset?: string[]; height?: number; };`,
|
||||
after: `("myKey", { value: "" });`,
|
||||
},
|
||||
{
|
||||
field: "getScriptSettingValue",
|
||||
code: "getScriptSettingValue(key: string, defaultValue: ScriptSettingValue): ScriptSettingValue;",
|
||||
desc:
|
||||
`Gets a single Script Engine setting value for the active script.\n` +
|
||||
`Returns defaultValue if the key does not exist (or if activeScript is not set).\n` +
|
||||
`Handles initialization when scriptEngineSettings[activeScript] is undefined/null.\n` +
|
||||
`See for more details: ${hyperlink("https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html","Script Engine Help")}\n\n` +
|
||||
`type ScriptSettingValue = { value?: string; hidden?: boolean; description?: string; valueset?: string[]; height?: number; };`,
|
||||
after: `("myKey", { value: "" });`,
|
||||
},
|
||||
{
|
||||
field: "saveScriptSettings",
|
||||
code: "async saveScriptSettings(): Promise<void>;",
|
||||
desc:
|
||||
`Persists Script Engine settings to disk (plugin settings).\n` +
|
||||
`Useful after calling setScriptSettingValue().\n` +
|
||||
`See for more details: ${hyperlink("https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html","Script Engine Help")}`,
|
||||
after: "()",
|
||||
},
|
||||
{
|
||||
field: "openFileInNewOrAdjacentLeaf",
|
||||
code: "openFileInNewOrAdjacentLeaf(file: TFile): WorkspaceLeaf;",
|
||||
@@ -950,7 +1013,7 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
export const EXCALIDRAW_SCRIPTENGINE_INFO: SuggesterInfo[] = [
|
||||
{
|
||||
field: "inputPrompt",
|
||||
code: "inputPrompt: (opts: {header: string, placeholder?: string, value?: string, buttons?: {caption:string, tooltip?:string, action:Function}[], lines?: number, displayEditorButtons?: boolean, customComponents?: (container: HTMLElement) => void, blockPointerInputOutsideModal?: boolean, controlsOnTop?: boolean});",
|
||||
code: "inputPrompt: (opts: {header: string, placeholder?: string, value?: string, buttons?: {caption:string, tooltip?:string, iconId?: string, action:Function}[], lines?: number, displayEditorButtons?: boolean, customComponents?: (container: HTMLElement) => void, blockPointerInputOutsideModal?: boolean, controlsOnTop?: boolean});",
|
||||
desc:
|
||||
"Opens a prompt that asks for an input.\nReturns a string with the input.\nYou need to await the result of inputPrompt.\n" +
|
||||
"Editor buttons are text editing buttons like delete, enter, allcaps - these are only displayed if lines is greater than 1 \n" +
|
||||
@@ -958,6 +1021,7 @@ export const EXCALIDRAW_SCRIPTENGINE_INFO: SuggesterInfo[] = [
|
||||
"blockPointerInputOutsideModal will block pointer input outside the modal. This is useful if you want to prevent the user accidently closing the modal or interacting with the excalidraw canvas while the prompt is open.\n" +
|
||||
"controlsOnTop when set to true will move all the buttons to the top of the modal, leaving the text area at the bottom. This feature was developed for Scribble Helper script to avoid your palm pressing buttons while scribbling.\n"+
|
||||
"buttons.action(input: string) => string\nThe button action function will receive the actual input string. If action returns null, input will be unchanged. If action returns a string, input will receive that value when the promise is resolved. " +
|
||||
"iconId is the lucide.dev icon name. If iconId is provided caption will be ignored, simply submit \"\" as caption in that case. \n" +
|
||||
"example:\n<code>let fileType = '';\nconst filename = await utils.inputPrompt (\n 'Filename',\n '',\n '',\n, [\n {\n caption: 'Markdown',\n action: ()=>{fileType='md';return;}\n },\n {\n caption: 'Excalidraw',\n action: ()=>{fileType='ex';return;}\n }\n ]\n);</code>",
|
||||
after: `({\n header: "",\n placeholder: undefined, //string\n value: undefined, //string\n buttons: [{ //optional, may leave undefined\n caption: "", //string\n tooltip: undefined, //string\n action: (input)=>{} //Function\n }],\n lines: undefined, //number\n displayEditorButtons: undefined, //boolean\n customComponents: undefined, //(container: HTMLElement) => void\n blockPointerInputOutsideModal: undefined, //boolean\n controlsOnTop: undefined, //boolean\n draggable: undefined, //boolean\n});`,
|
||||
},
|
||||
@@ -1073,6 +1137,12 @@ export const FRONTMATTER_KEYS_INFO: SuggesterInfo[] = [
|
||||
desc: "If this key is present it will override the default excalidraw embed and export setting.",
|
||||
after: ": false",
|
||||
},
|
||||
{
|
||||
field: "export-internal-links",
|
||||
code: null,
|
||||
desc: "Default value (if not set) is true, if set to false internal links will not be exported to SVG images and PDFs.",
|
||||
after: ": false",
|
||||
},
|
||||
{
|
||||
field: "open-md",
|
||||
code: null,
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import { Setting, DropdownComponent, App } from "obsidian";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { ExcalidrawSettings } from "src/core/settings";
|
||||
import { fragWithHTML, setLeftHandedMode, setUIMode } from "src/utils/utils";
|
||||
import { DEVICE } from "src/constants/constants";
|
||||
|
||||
export type UIMode = "full" | "compact" | "tray" | "phone";
|
||||
|
||||
//setTrayMode(this.app, this.plugin.settings);
|
||||
//setDesktopUIMode(this.app, this.plugin.settings);
|
||||
|
||||
|
||||
export class UIModeSettingsComponent {
|
||||
private containerEl: HTMLElement;
|
||||
private settings: ExcalidrawSettings;
|
||||
private app: App;
|
||||
private onChange: () => void;
|
||||
|
||||
constructor(
|
||||
containerEl: HTMLElement,
|
||||
settings: ExcalidrawSettings,
|
||||
app: App,
|
||||
onChange: () => void,
|
||||
) {
|
||||
this.containerEl = containerEl;
|
||||
this.settings = settings;
|
||||
this.app = app;
|
||||
this.onChange = onChange;
|
||||
}
|
||||
|
||||
render(): void {
|
||||
const { containerEl } = this;
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("DESKTOP_UI_MODE_NAME"))
|
||||
.setDesc(t("DESKTOP_UI_MODE_DESC"))
|
||||
.addDropdown((dropdown: DropdownComponent) =>
|
||||
dropdown
|
||||
.addOption("full", t("MODE_FULL"))
|
||||
.addOption("compact", t("MODE_COMPACT"))
|
||||
.addOption("tray", t("MODE_TRAY"))
|
||||
.setValue(this.settings.desktopUIMode)
|
||||
.onChange((value: UIMode) => {
|
||||
this.settings.desktopUIMode = value;
|
||||
if (DEVICE.isDesktop) {
|
||||
setUIMode(this.app, this.settings);
|
||||
}
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("TABLET_UI_MODE_NAME"))
|
||||
.setDesc(t("TABLET_UI_MODE_DESC"))
|
||||
.addDropdown((dropdown: DropdownComponent) =>
|
||||
dropdown
|
||||
.addOption("compact", t("MODE_COMPACT"))
|
||||
.addOption("tray", t("MODE_TRAY"))
|
||||
.setValue(this.settings.tabletUIMode)
|
||||
.onChange((value: UIMode) => {
|
||||
this.settings.tabletUIMode = value;
|
||||
if (DEVICE.isTablet) {
|
||||
setUIMode(this.app, this.settings);
|
||||
}
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(t("LEFTHANDED_MODE_NAME"))
|
||||
.setDesc(fragWithHTML(t("LEFTHANDED_MODE_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.settings.isLeftHanded)
|
||||
.onChange(async (value) => {
|
||||
this.settings.isLeftHanded = value;
|
||||
//not clear why I need to do this. If I don't double apply the stylesheet changes
|
||||
//then the style won't be applied in the popout windows
|
||||
setLeftHandedMode(value);
|
||||
setTimeout(()=>setLeftHandedMode(value));
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { UIModeSettingsComponent } from "./UIModeSettingComponent";
|
||||
import { FloatingModal } from "./FloatingModal";
|
||||
import { Modal } from "obsidian";
|
||||
|
||||
export class UIModeSettings extends Modal {
|
||||
private isDirty = false;
|
||||
constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
) {
|
||||
super(plugin.app);
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
this.containerEl.classList.add("excalidraw-release");
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
if (this.isDirty) {
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
this.plugin = null;
|
||||
}
|
||||
|
||||
async createForm() {
|
||||
this.contentEl.createEl("h1",{text: t("MODES_HEAD")});
|
||||
new UIModeSettingsComponent(
|
||||
this.contentEl,
|
||||
this.plugin.settings,
|
||||
this.app,
|
||||
()=>this.applySettingsUpdate(),
|
||||
).render();
|
||||
}
|
||||
|
||||
private async applySettingsUpdate() {
|
||||
this.isDirty = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -61,7 +61,10 @@ export class UniversalInsertFileModal extends Modal {
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
const modalEl = this.modalEl;
|
||||
modalEl.classList.add("excalidraw-modal");
|
||||
this.containerEl.classList.add("excalidraw-release");
|
||||
this.containerEl.classList.add("excalidraw-modal");
|
||||
this.titleEl.setText(t("UIFM_TITLE"));
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,240 @@
|
||||
import { ExcalidrawTextElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { Notice } from "obsidian";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { ScriptEngine } from "../Scripts";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
|
||||
/**
|
||||
*
|
||||
* @param view - ExcalidrawView instance
|
||||
* @param prefix - defines the default button.
|
||||
* @returns
|
||||
*/
|
||||
export async function copyLinkToSelectedElementToClipboard(view: ExcalidrawView, prefix: string) {
|
||||
const elements = view.getViewSelectedElements();
|
||||
if (elements.length < 1) {
|
||||
new Notice(t("INSERT_LINK_TO_ELEMENT_ERROR"));
|
||||
return;
|
||||
}
|
||||
|
||||
let elementId: string = undefined;
|
||||
|
||||
if (elements.length === 2) {
|
||||
const textEl = elements.filter((el) => el.type === "text");
|
||||
if (textEl.length === 1 && (textEl[0] as ExcalidrawTextElement).containerId) {
|
||||
const container = elements.filter(
|
||||
(el) => el.boundElements && el.boundElements.some((be) => be.type === "text"),
|
||||
);
|
||||
if (container.length === 1) {
|
||||
elementId = textEl[0].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!elementId) {
|
||||
elementId =
|
||||
elements.length === 1
|
||||
? elements[0].id
|
||||
: view.plugin.ea.getLargestElement(elements).id;
|
||||
}
|
||||
|
||||
const frames = elements.filter((el) => el.type === "frame");
|
||||
const hasFrame = frames.length === 1;
|
||||
const hasMarkerFrame = hasFrame && (frames[0] as any).frameRole === "marker";
|
||||
const hasGroup = elements.some((el) => el.groupIds && el.groupIds.length > 0);
|
||||
|
||||
// Feature 1: UIFM_ANCHOR checkbox (persisted)
|
||||
let anchorTo100 = Boolean(view.plugin.settings.copyLinkToElemenetAnchorTo100);
|
||||
|
||||
// Feature 2: frame link by name (persisted)
|
||||
let copyFrameLinkByName = Boolean(view.plugin.settings.copyFrameLinkByName);
|
||||
|
||||
const frameNameRaw = hasFrame ? (frames[0] as any)?.name : undefined;
|
||||
const frameName = typeof frameNameRaw === "string" ? frameNameRaw.trim() : "";
|
||||
const frameNameIsValid =
|
||||
hasFrame && frameName.length > 0 && /[\p{L}\p{N}_ -]+/u.test(frameName);
|
||||
|
||||
const getFrameTarget = () =>
|
||||
frameNameIsValid && copyFrameLinkByName ? frameName : frames[0].id;
|
||||
|
||||
let cancelled = true;
|
||||
|
||||
const button = {
|
||||
area: {
|
||||
caption: "Area",
|
||||
action: () => {
|
||||
cancelled = false;
|
||||
prefix = "area=";
|
||||
return;
|
||||
}
|
||||
},
|
||||
link: {
|
||||
caption: "Link",
|
||||
action: () => {
|
||||
cancelled = false;
|
||||
prefix = "";
|
||||
return;
|
||||
} },
|
||||
group: {
|
||||
caption: "Group",
|
||||
action: () => {
|
||||
cancelled = false;
|
||||
prefix = "group=";
|
||||
return;
|
||||
}
|
||||
},
|
||||
frame: {
|
||||
caption: "Frame",
|
||||
action: () => {
|
||||
cancelled = false;
|
||||
prefix = "frame=";
|
||||
elementId = getFrameTarget();
|
||||
return;
|
||||
},
|
||||
},
|
||||
clippedframe: {
|
||||
caption: "Clipped Frame",
|
||||
action: () => {
|
||||
cancelled = false;
|
||||
prefix = "clippedframe=";
|
||||
elementId = getFrameTarget();
|
||||
return;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
let buttons = [];
|
||||
switch (prefix) {
|
||||
case "area=":
|
||||
buttons = [
|
||||
button.area,
|
||||
button.link,
|
||||
...(hasGroup ? [button.group] : []),
|
||||
...(hasFrame && !hasMarkerFrame ? [button.clippedframe] : []),
|
||||
...(hasFrame ? [button.frame] : []),
|
||||
];
|
||||
break;
|
||||
case "group=":
|
||||
buttons = [
|
||||
...(hasGroup ? [button.group] : []),
|
||||
button.link,
|
||||
button.area,
|
||||
...(hasFrame && !hasMarkerFrame ? [button.clippedframe] : []),
|
||||
...(hasFrame ? [button.frame] : []),
|
||||
];
|
||||
break;
|
||||
case "frame=":
|
||||
buttons = [
|
||||
...(hasFrame && !hasMarkerFrame ? [button.clippedframe] : []),
|
||||
...(hasFrame ? [button.frame] : []),
|
||||
...(hasGroup ? [button.group] : []),
|
||||
button.link,
|
||||
button.area,
|
||||
];
|
||||
break;
|
||||
case "clippedframe=":
|
||||
buttons = [
|
||||
...(hasFrame && !hasMarkerFrame ? [button.clippedframe] : []),
|
||||
...(hasFrame ? [button.frame] : []),
|
||||
...(hasGroup ? [button.group] : []),
|
||||
button.link,
|
||||
button.area,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
buttons = [
|
||||
button.link,
|
||||
button.area,
|
||||
button.group,
|
||||
...(hasFrame && !hasMarkerFrame ? [button.clippedframe] : []),
|
||||
...(hasFrame ? [button.frame] : []),
|
||||
];
|
||||
}
|
||||
|
||||
let alias: string;
|
||||
try {
|
||||
alias = await ScriptEngine.inputPrompt(
|
||||
view,
|
||||
view.plugin,
|
||||
view.app,
|
||||
"Set link alias",
|
||||
"Leave empty if you do not want to set an alias",
|
||||
"",
|
||||
buttons,
|
||||
undefined,
|
||||
undefined,
|
||||
(container: HTMLElement) => {
|
||||
const wrapper = container.createDiv?.("excalidraw-prompt-checkboxes") ?? container;
|
||||
const ownerDoc = wrapper.ownerDocument ?? document;
|
||||
|
||||
const anchorRow = ownerDoc.createElement("label");
|
||||
anchorRow.style.display = "flex";
|
||||
anchorRow.style.alignItems = "center";
|
||||
anchorRow.style.gap = "8px";
|
||||
anchorRow.style.marginTop = "8px";
|
||||
|
||||
const anchorCb = ownerDoc.createElement("input");
|
||||
anchorCb.type = "checkbox";
|
||||
anchorCb.checked = anchorTo100;
|
||||
anchorCb.setAttribute("aria-label", t("UIFM_ANCHOR_DESC"));
|
||||
anchorCb.addEventListener("change", () => {
|
||||
anchorTo100 = anchorCb.checked;
|
||||
});
|
||||
|
||||
const anchorText = ownerDoc.createElement("span");
|
||||
anchorText.textContent = t("UIFM_ANCHOR");
|
||||
|
||||
anchorRow.appendChild(anchorCb);
|
||||
anchorRow.appendChild(anchorText);
|
||||
wrapper.appendChild(anchorRow);
|
||||
|
||||
if (frameNameIsValid) {
|
||||
const frameRow = ownerDoc.createElement("label");
|
||||
frameRow.style.display = "flex";
|
||||
frameRow.style.alignItems = "center";
|
||||
frameRow.style.gap = "8px";
|
||||
frameRow.style.marginTop = "8px";
|
||||
|
||||
const frameCb = ownerDoc.createElement("input");
|
||||
frameCb.type = "checkbox";
|
||||
frameCb.checked = copyFrameLinkByName;
|
||||
frameCb.setAttribute("aria-label", t("FRAME_WITH_NAME"));
|
||||
frameCb.addEventListener("change", () => {
|
||||
copyFrameLinkByName = frameCb.checked;
|
||||
});
|
||||
|
||||
const frameText = ownerDoc.createElement("span");
|
||||
frameText.textContent = t("FRAME_WITH_NAME");
|
||||
|
||||
frameRow.appendChild(frameCb);
|
||||
frameRow.appendChild(frameText);
|
||||
wrapper.appendChild(frameRow);
|
||||
}
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
const changed =
|
||||
view.plugin.settings.copyLinkToElemenetAnchorTo100 !== anchorTo100 ||
|
||||
view.plugin.settings.copyFrameLinkByName !== copyFrameLinkByName;
|
||||
|
||||
if (changed) {
|
||||
await view.plugin.loadSettings();
|
||||
view.plugin.settings.copyLinkToElemenetAnchorTo100 = anchorTo100;
|
||||
view.plugin.settings.copyFrameLinkByName = copyFrameLinkByName;
|
||||
await view.plugin.saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
if (cancelled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((alias === "" || alias == null) && anchorTo100) {
|
||||
alias = "100%";
|
||||
}
|
||||
|
||||
navigator.clipboard.writeText(
|
||||
`${prefix.length > 0 ? "!" : ""}[[${view.file.path}#^${prefix}${elementId}${alias ? `|${alias}` : ``}]]`,
|
||||
);
|
||||
new Notice(t("INSERT_LINK_TO_ELEMENT_READY"));
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// This file was generated by lezer-generator. You probably shouldn't edit it.
|
||||
/*
|
||||
Obsidian uses a slightly modified version of the hypermd parser for math blocks
|
||||
found at https://github.com/laobubu/HyperMD/blob/071ce236605bb7693efa6d4b829c39413a3d37fb/src/mode/hypermd.ts#L329-L336
|
||||
where spaces are replaced with `_` and the mathlevel of 1|2 is replaced with `math-block` for display math and nothing for inline math
|
||||
create from the following grammar (where we remove the upper-cases):
|
||||
@top Document { Formatting_formatting-math_formatting-math-begin_keyword_math_math-block Math Formatting_formatting-math_formatting-math-end_keyword_math_math- }
|
||||
|
||||
Formatting_formatting-math_formatting-math-begin_keyword_math_math-block { "" }
|
||||
Math { any* }
|
||||
Formatting_formatting-math_formatting-math-end_keyword_math_math- { "" }
|
||||
|
||||
@tokens {
|
||||
any { _ }
|
||||
}
|
||||
*/
|
||||
import {LRParser} from "@lezer/lr"
|
||||
export const parser = LRParser.deserialize({
|
||||
version: 14,
|
||||
states: "zOOOO?MrOOQOPOOOOOO'#Ca'#CaOYOPO'#C_OOOO?MtOOOOO-E6_-E6_QOOOOO",
|
||||
stateData: "b~OVQOURP~OVQOURX~O",
|
||||
goto: "fUPPVY]`RPORSPRUSQRPRTR",
|
||||
nodeNames: "⚠ Document formatting_formatting-math_formatting-math-begin_keyword_math_math-block math formatting_formatting-math_formatting-math-end_keyword_math_math-",
|
||||
maxTerm: 7,
|
||||
skippedNodes: [0],
|
||||
repeatNodeCount: 1,
|
||||
tokenData: "i~RRO;'S[;'S;=`a;=`O[~aOV~~fPV~;=`<%l[",
|
||||
tokenizers: [0],
|
||||
topRules: {"Document":[0,1]},
|
||||
tokenPrec: 0
|
||||
})
|
||||
@@ -742,6 +742,10 @@ export class EmbeddedFilesLoader {
|
||||
}
|
||||
|
||||
const addFilesTimer = setInterval(() => {
|
||||
if (this.terminate) {
|
||||
clearInterval(addFilesTimer);
|
||||
return;
|
||||
}
|
||||
if(files[batch].length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
COLOR_NAMES,
|
||||
fileid,
|
||||
GITHUB_RELEASES,
|
||||
determineFocusDistance,
|
||||
getCommonBoundingBox,
|
||||
getLineHeight,
|
||||
getMaximumGroups,
|
||||
@@ -77,12 +76,12 @@ import {
|
||||
extractCodeBlocks as _extractCodeBlocks,
|
||||
} from "../utils/AIUtils";
|
||||
import { EXCALIDRAW_AUTOMATE_INFO, EXCALIDRAW_SCRIPTENGINE_INFO } from "./Dialogs/SuggesterInfo";
|
||||
import { addBackOfTheNoteCard } from "../utils/excalidrawViewUtils";
|
||||
import { addBackOfTheNoteCard, sceneRemoveInternalLinks } from "../utils/excalidrawViewUtils";
|
||||
import { log } from "../utils/debugHelper";
|
||||
import { ExcalidrawLib } from "../types/excalidrawLib";
|
||||
import { GlobalPoint } from "@zsviczian/excalidraw/types/math/src/types";
|
||||
import { AddImageOptions, ImageInfo, SVGColorInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { _measureText, cloneElement, createPNG, createSVG, errorMessage, filterColorMap, getEmbeddedFileForImageElment, getFontFamily, getLineBox, getTemplate, isColorStringTransparent, isSVGColorInfo, mergeColorMapIntoSVGColorInfo, normalizeLinePoints, repositionElementsToCursor, svgColorInfoToColorMap, updateOrAddSVGColorInfo, verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils";
|
||||
import { AddImageOptions, ImageInfo, ScriptSettingValue, SVGColorInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { _measureText, cloneElement, createPNG, createSVG, ensureActiveScriptSettingsObject, errorMessage, filterColorMap, getEmbeddedFileForImageElment, getFontFamily, getLastActiveExcalidrawView, getLineBox, getTemplate, isColorStringTransparent, isSVGColorInfo, mergeColorMapIntoSVGColorInfo, normalizeBindMode, normalizeFixedPoint, normalizeLinePoints, repositionElementsToCursor, svgColorInfoToColorMap, updateOrAddSVGColorInfo, verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils";
|
||||
import { exportToPDF, getMarginValue, getPageDimensions } from "src/utils/exportUtils";
|
||||
import { PageDimensions, PageOrientation, PageSize, PDFExportScale, PDFPageProperties, ExportSettings} from "src/types/exportUtilTypes";
|
||||
import { FrameRenderingOptions } from "src/types/utilTypes";
|
||||
@@ -92,6 +91,8 @@ import { FloatingModal } from "./Dialogs/FloatingModal";
|
||||
import { patchMobileView } from "src/utils/customEmbeddableUtils";
|
||||
import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
|
||||
import { AIRequest } from "src/types/AIUtilTypes";
|
||||
import { arrow, end } from "@popperjs/core";
|
||||
import { start } from "repl";
|
||||
|
||||
extendPlugins([
|
||||
HarmonyPlugin,
|
||||
@@ -766,6 +767,56 @@ export class ExcalidrawAutomate {
|
||||
return this.elementsDict[id];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an object describing the bound text element.
|
||||
* If a text element is provided:
|
||||
* - returns { eaElement } if the element is in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If a container element is provided, searches for the bound text element:
|
||||
* - returns { eaElement } if found in ea.elementsDict
|
||||
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
|
||||
* If not found, returns {}.
|
||||
* Does not add the text element to elementsDict.
|
||||
* @param element
|
||||
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
|
||||
* @returns Object containing either eaElement or sceneElement or empty if not found.
|
||||
*/
|
||||
getBoundTextElement(element: ExcalidrawElement, searchInView: boolean = false): {
|
||||
eaElement?: Mutable<ExcalidrawTextElement>,
|
||||
sceneElement?: ExcalidrawTextElement
|
||||
} {
|
||||
if(element.type === "text") {
|
||||
if(element.id in this.elementsDict) {
|
||||
return {eaElement: element as Mutable<ExcalidrawTextElement>};
|
||||
}
|
||||
|
||||
if (searchInView && this.targetView && this.targetView._loaded) {
|
||||
const viewElements = this.getViewElements();
|
||||
const ve = viewElements.find((e) => e.id === element.id);
|
||||
if(ve) {
|
||||
return {
|
||||
sceneElement: ve as ExcalidrawTextElement
|
||||
};
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
const boundElement = element.boundElements?.find((be) => be.type === "text");
|
||||
if (!boundElement) {
|
||||
return {};
|
||||
}
|
||||
let textElement = this.elementsDict[boundElement.id] as Mutable<ExcalidrawTextElement>;
|
||||
if (textElement) {
|
||||
return {eaElement: textElement};
|
||||
}
|
||||
if (!textElement && searchInView && this.targetView && this.targetView._loaded) {
|
||||
const viewElements = this.getViewElements();
|
||||
const ve = viewElements.find((e) => e.id === boundElement.id);
|
||||
return {sceneElement: ve as ExcalidrawTextElement};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a drawing and saves it to the specified filename.
|
||||
* @param {Object} [params] - Parameters for creating the drawing.
|
||||
@@ -800,6 +851,7 @@ export class ExcalidrawAutomate {
|
||||
"excalidraw-autoexport"?: boolean;
|
||||
"excalidraw-mask"?: boolean;
|
||||
"excalidraw-open-md"?: boolean;
|
||||
"excalidraw-export-internal-links"?: boolean;
|
||||
"cssclasses"?: string;
|
||||
};
|
||||
plaintext?: string; //text to insert above the `# Text Elements` section
|
||||
@@ -1100,6 +1152,11 @@ export class ExcalidrawAutomate {
|
||||
if(elementsOverride) {
|
||||
scene.elements = elementsOverride;
|
||||
}
|
||||
|
||||
if(!view.getViewExportIncludeInternalLinks()) {
|
||||
scene.elements = sceneRemoveInternalLinks(scene);
|
||||
}
|
||||
|
||||
const exportSettings: ExportSettings = {
|
||||
withBackground: view.getViewExportWithBackground(withBackground),
|
||||
withTheme: true,
|
||||
@@ -1142,6 +1199,8 @@ export class ExcalidrawAutomate {
|
||||
loader?: EmbeddedFilesLoader,
|
||||
theme?: string,
|
||||
padding?: number,
|
||||
convertMarkdownLinksToObsidianURLs: boolean = false,
|
||||
includeInternalLinks: boolean = true,
|
||||
): Promise<SVGSVGElement> {
|
||||
if (!theme) {
|
||||
theme = this.plugin.settings.previewMatchObsidianTheme
|
||||
@@ -1179,7 +1238,9 @@ export class ExcalidrawAutomate {
|
||||
this.plugin,
|
||||
0,
|
||||
padding,
|
||||
this.imagesDict
|
||||
this.imagesDict,
|
||||
convertMarkdownLinksToObsidianURLs,
|
||||
includeInternalLinks,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1787,6 +1848,17 @@ export class ExcalidrawAutomate {
|
||||
* @param {"arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null} [formatting.endArrowHead] - The end arrowhead type.
|
||||
* @param {string} [formatting.startObjectId] - The ID of the start object.
|
||||
* @param {string} [formatting.endObjectId] - The ID of the end object.
|
||||
* BindMode Determines whether the arrow remains outside the shape or is allowed to
|
||||
* go all the way inside the shape up to the exact fixed point.
|
||||
* @param {"inside" | "orbit"} [formatting.startBindMode] - The binding mode for the start object.
|
||||
* @param {"inside" | "orbit"} [formatting.endBindMode] - The binding mode for the end object.
|
||||
* FixedPoint represents the fixed point binding information in form of a vertical and
|
||||
* horizontal ratio (i.e. a percentage value in the 0.0-1.0 range). This ratio
|
||||
* gives the user selected fixed point by multiplying the bound element width
|
||||
* with fixedPoint[0] and the bound element height with fixedPoint[1] to get the
|
||||
* bound element-local point coordinate.
|
||||
* @param {[number, number]} [formatting.startFixedPoint] - The fixed point for the start object.
|
||||
* @param {[number, number]} [formatting.endFixedPoint] - The fixed point for the end object.
|
||||
* @param {string} [id] - The ID of the arrow element.
|
||||
* @returns {string} The ID of the added arrow element.
|
||||
*/
|
||||
@@ -1797,40 +1869,40 @@ export class ExcalidrawAutomate {
|
||||
endArrowHead?: "arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null;
|
||||
startObjectId?: string;
|
||||
endObjectId?: string;
|
||||
startBindMode?: "inside" | "orbit";
|
||||
endBindMode?: "inside" | "orbit";
|
||||
startFixedPoint?: [number, number];
|
||||
endFixedPoint?: [number, number];
|
||||
elbowed?: boolean;
|
||||
},
|
||||
id?: string,
|
||||
): string {
|
||||
const startFixedPoint = normalizeFixedPoint(formatting?.startFixedPoint);
|
||||
const endFixedPoint = normalizeFixedPoint(formatting?.endFixedPoint);
|
||||
const startMode = normalizeBindMode(formatting?.startBindMode);
|
||||
const endMode = normalizeBindMode(formatting?.endBindMode);
|
||||
const box = getLineBox(points);
|
||||
const elbowed = formatting?.elbowed ?? false;
|
||||
const startElement = formatting?.startObjectId
|
||||
? this.getElement(formatting.startObjectId) as Mutable<ExcalidrawBindableElement>
|
||||
: null;
|
||||
const endElement = formatting?.endObjectId
|
||||
? this.getElement(formatting.endObjectId) as Mutable<ExcalidrawBindableElement>
|
||||
: null;
|
||||
id = id ?? nanoid();
|
||||
const startPoint = points[0] as GlobalPoint;
|
||||
const endPoint = points[points.length - 1] as GlobalPoint;
|
||||
const elementsMap = arrayToMap(this.getElements());
|
||||
this.elementsDict[id] = {
|
||||
points: normalizeLinePoints(points),
|
||||
elbowed,
|
||||
lastCommittedPoint: null,
|
||||
startBinding: {
|
||||
elementId: formatting?.startObjectId,
|
||||
focus: formatting?.startObjectId
|
||||
? determineFocusDistance(
|
||||
this.getElement(formatting?.startObjectId) as ExcalidrawBindableElement,
|
||||
elementsMap,
|
||||
endPoint,
|
||||
startPoint,
|
||||
)
|
||||
: 0.1,
|
||||
gap: GAP,
|
||||
mode: startMode,
|
||||
fixedPoint: startFixedPoint,
|
||||
},
|
||||
endBinding: {
|
||||
elementId: formatting?.endObjectId,
|
||||
focus: formatting?.endObjectId
|
||||
? determineFocusDistance(
|
||||
this.getElement(formatting?.endObjectId) as ExcalidrawBindableElement,
|
||||
elementsMap,
|
||||
startPoint,
|
||||
endPoint,
|
||||
)
|
||||
: 0.1,
|
||||
gap: GAP,
|
||||
mode: endMode,
|
||||
fixedPoint: endFixedPoint,
|
||||
},
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/388
|
||||
startArrowhead:
|
||||
@@ -1843,20 +1915,20 @@ export class ExcalidrawAutomate {
|
||||
: this.style.endArrowHead,
|
||||
...this.boxedElement(id, "arrow", points[0][0], points[0][1], box.w, box.h),
|
||||
};
|
||||
if (formatting?.startObjectId) {
|
||||
if (!this.elementsDict[formatting.startObjectId].boundElements) {
|
||||
this.elementsDict[formatting.startObjectId].boundElements = [];
|
||||
if (startElement) {
|
||||
if (!startElement.boundElements) {
|
||||
startElement.boundElements = [];
|
||||
}
|
||||
this.elementsDict[formatting.startObjectId].boundElements.push({
|
||||
(startElement.boundElements as Mutable<ExcalidrawElement["boundElements"]>).push({
|
||||
type: "arrow",
|
||||
id,
|
||||
});
|
||||
}
|
||||
if (formatting?.endObjectId) {
|
||||
if (!this.elementsDict[formatting.endObjectId].boundElements) {
|
||||
this.elementsDict[formatting.endObjectId].boundElements = [];
|
||||
if (endElement) {
|
||||
if (!endElement.boundElements) {
|
||||
endElement.boundElements = [];
|
||||
}
|
||||
this.elementsDict[formatting.endObjectId].boundElements.push({
|
||||
(endElement.boundElements as Mutable<ExcalidrawElement["boundElements"]>).push({
|
||||
type: "arrow",
|
||||
id,
|
||||
});
|
||||
@@ -2009,6 +2081,9 @@ export class ExcalidrawAutomate {
|
||||
* @returns {Promise<string>} Promise resolving to the ID of the added LaTeX image element.
|
||||
*/
|
||||
async addLaTex(topX: number, topY: number, tex: string): Promise<string> {
|
||||
if (!tex){
|
||||
return null;
|
||||
}
|
||||
const id = nanoid();
|
||||
const image = await tex2dataURL(tex, 4, this.plugin);
|
||||
if (!image) {
|
||||
@@ -2256,35 +2331,72 @@ export class ExcalidrawAutomate {
|
||||
isExcalidrawFile(f: TFile): boolean {
|
||||
return this.plugin.isExcalidrawFile(f);
|
||||
};
|
||||
|
||||
targetView: ExcalidrawView = null; //the view currently edited
|
||||
/**
|
||||
* Sets the target view for EA. All the view operations and the access to Excalidraw API will be performed on this view.
|
||||
* If view is null or undefined, the function will first try setView("active"), then setView("first").
|
||||
* @param {ExcalidrawView | "first" | "active"} [view] - The view to set as target.
|
||||
* @returns {ExcalidrawView} The target view.
|
||||
* Sets the target view for EA. All view operations and all access to the Excalidraw API
|
||||
* will be performed on this view.
|
||||
*
|
||||
* Typical usage:
|
||||
* - `setView()` to pick a sensible default automatically
|
||||
* - `setView(excalidrawView)` to explicitly target a specific view
|
||||
*
|
||||
* Selectors:
|
||||
* - If `view` is `null` or `undefined` (or `"auto"`), EA will pick a sensible default:
|
||||
* 1) the currently active Excalidraw view (if any),
|
||||
* 2) otherwise the last active Excalidraw view (if it is still available),
|
||||
* 3) otherwise the `"first"` Excalidraw view in the workspace.
|
||||
* - If `show` is `true`, the view will be revealed (brought to front) and focused.
|
||||
*
|
||||
* Deprecated selectors (kept for backward compatibility):
|
||||
* - If `"active"` is provided, the currently active Excalidraw view will be used. If no
|
||||
* active Excalidraw view is available, the last active Excalidraw view will be used.
|
||||
* - If `"first"` is provided, the target will be the first Excalidraw view returned by
|
||||
* Obsidian's workspace leaf collection (i.e., the first item in the current
|
||||
* `getExcalidrawViews()` result). **This ordering is managed by Obsidian and does not
|
||||
* necessarily match what a user would consider the “first”/“leftmost”/“topmost” view;
|
||||
* from a user's perspective it may appear effectively random.**
|
||||
*
|
||||
* @param {ExcalidrawView | "auto" | "first" | "active" | null | undefined} [view] - The view (or selector) to set as target.
|
||||
* @param {boolean} [show=false] - Whether to reveal/focus the target view.
|
||||
* @returns {ExcalidrawView} The ExcalidrawView that was set as `targetView` (or `null` if none found).
|
||||
*/
|
||||
setView(view?: ExcalidrawView | "first" | "active"): ExcalidrawView {
|
||||
if(!view) {
|
||||
const v = this.plugin.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (v instanceof ExcalidrawView) {
|
||||
this.targetView = v;
|
||||
}
|
||||
else {
|
||||
this.targetView = getExcalidrawViews(this.plugin.app)[0];
|
||||
}
|
||||
}
|
||||
if (view == "active") {
|
||||
const v = this.plugin.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (!(v instanceof ExcalidrawView)) {
|
||||
setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false): ExcalidrawView {
|
||||
const app = this.plugin.app;
|
||||
const workspace = app.workspace;
|
||||
const setView = () => {
|
||||
if(!view || view === "auto") {
|
||||
view = workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view instanceof ExcalidrawView) {
|
||||
this.targetView = view;
|
||||
return;
|
||||
}
|
||||
view = getLastActiveExcalidrawView(this.plugin);
|
||||
this.targetView = view ?? getExcalidrawViews(this.plugin.app)[0];
|
||||
return;
|
||||
}
|
||||
this.targetView = v;
|
||||
if (view == "active") {
|
||||
view = workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view instanceof ExcalidrawView) {
|
||||
this.targetView = view;
|
||||
return;
|
||||
}
|
||||
this.targetView = getLastActiveExcalidrawView(this.plugin);
|
||||
return;
|
||||
}
|
||||
if (view == "first") {
|
||||
this.targetView = getExcalidrawViews(this.plugin.app)[0];
|
||||
return;
|
||||
}
|
||||
if (view instanceof ExcalidrawView) {
|
||||
this.targetView = view;
|
||||
}
|
||||
}
|
||||
if (view == "first") {
|
||||
this.targetView = getExcalidrawViews(this.plugin.app)[0];
|
||||
}
|
||||
if (view instanceof ExcalidrawView) {
|
||||
this.targetView = view;
|
||||
setView();
|
||||
if(show && this.targetView) {
|
||||
this.plugin.app.workspace.revealLeaf(
|
||||
this.targetView.leaf,
|
||||
);
|
||||
}
|
||||
return this.targetView;
|
||||
};
|
||||
@@ -3308,6 +3420,23 @@ export class ExcalidrawAutomate {
|
||||
await this.plugin.saveSettings();
|
||||
};
|
||||
|
||||
public setScriptSettingValue(key: string, value: ScriptSettingValue): void {
|
||||
const settings = ensureActiveScriptSettingsObject(this);
|
||||
if (!settings) return;
|
||||
settings[key] = value;
|
||||
}
|
||||
|
||||
public getScriptSettingValue(key: string, defaultValue: ScriptSettingValue): ScriptSettingValue {
|
||||
const settings = ensureActiveScriptSettingsObject(this);
|
||||
if (!settings) return defaultValue;
|
||||
return settings[key] ?? defaultValue;
|
||||
}
|
||||
|
||||
public async saveScriptSettings(): Promise<void> {
|
||||
ensureActiveScriptSettingsObject(this);
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a file in a new workspace leaf or reuses an existing adjacent leaf depending on Excalidraw Plugin Settings.
|
||||
* @param {TFile} file - The file to open.
|
||||
|
||||
@@ -55,6 +55,7 @@ class ImageCache {
|
||||
this.db = null;
|
||||
this.plugin = null;
|
||||
this.app = null;
|
||||
this.obsidanURLCache.forEach((url) => URL.revokeObjectURL(url));
|
||||
this.obsidanURLCache.clear();
|
||||
this.obsidanURLCache = null;
|
||||
}
|
||||
@@ -179,6 +180,10 @@ class ImageCache {
|
||||
const fileExists = files.some((f: TFile) => f.path === filepath);
|
||||
const file = fileExists ? files.find((f: TFile) => f.path === filepath) : null;
|
||||
if (isLegacyKey || !file || (file && (file.stat.mtime > cursor.value.mtime)) || (!cursor.value.blob && !cursor.value.svg)) {
|
||||
if(this.obsidanURLCache.has(key)) {
|
||||
URL.revokeObjectURL(this.obsidanURLCache.get(key));
|
||||
this.obsidanURLCache.delete(key);
|
||||
}
|
||||
deletePromises.push(
|
||||
new Promise<void>((innerResolve, innerReject) => {
|
||||
const deleteRequest = store.delete(cursor.primaryKey);
|
||||
@@ -368,6 +373,9 @@ class ImageCache {
|
||||
const key = getKey(key_);
|
||||
store.put(data, key);
|
||||
if(!Boolean(svg)) {
|
||||
if(this.obsidanURLCache.has(key) && this.obsidanURLCache.get(key) !== obsidianURL) {
|
||||
URL.revokeObjectURL(this.obsidanURLCache.get(key));
|
||||
}
|
||||
this.obsidanURLCache.set(key, obsidianURL);
|
||||
}
|
||||
}
|
||||
@@ -406,6 +414,9 @@ class ImageCache {
|
||||
return; // Database not initialized yet
|
||||
}
|
||||
|
||||
this.obsidanURLCache.forEach((url) => URL.revokeObjectURL(url));
|
||||
this.obsidanURLCache.clear();
|
||||
|
||||
return this.clear(this.cacheStoreName, "Image cache was cleared");
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
import { getEA } from "src/core";
|
||||
import { ExcalidrawAutomate } from "../shared/ExcalidrawAutomate";
|
||||
import { WeakArray } from "./WeakArray";
|
||||
import { getExcalidrawViews } from "../utils/obsidianUtils";
|
||||
import { getExcalidrawViews, stripYamlFrontmatter } from "../utils/obsidianUtils";
|
||||
import { ButtonDefinition, InputPromptOptions } from "src/types/promptTypes";
|
||||
|
||||
export type ScriptIconMap = {
|
||||
@@ -211,9 +211,8 @@ export class ScriptEngine {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view) {
|
||||
(async()=>{
|
||||
const script = await this.app.vault.read(f);
|
||||
const script = stripYamlFrontmatter(await this.app.vault.read(f));
|
||||
if(script) {
|
||||
//remove YAML frontmatter if present
|
||||
this.executeScript(view, script, scriptName,f);
|
||||
}
|
||||
})()
|
||||
@@ -260,7 +259,7 @@ export class ScriptEngine {
|
||||
await view.save(false, true);
|
||||
}
|
||||
|
||||
script = script.replace(/^---.*?---\n/gs, "");
|
||||
script = stripYamlFrontmatter(script);
|
||||
const ea = getEA(view);
|
||||
this.eaInstances.push(ea);
|
||||
ea.activeScript = title;
|
||||
|
||||
@@ -17,6 +17,8 @@ export class FileSuggestionModal extends SuggestionModal<LinkSuggestion> {
|
||||
cache: CachedMetadata;
|
||||
filesAndAliases: LinkSuggestion[];
|
||||
file: TFile;
|
||||
private handleGetFile: () => void;
|
||||
|
||||
constructor(app: App, input: TextComponent, items: TFile[], private plugin: ExcalidrawPlugin) {
|
||||
const filesAndAliases = [];
|
||||
for (const file of items) {
|
||||
@@ -36,7 +38,11 @@ export class FileSuggestionModal extends SuggestionModal<LinkSuggestion> {
|
||||
this.text = input;
|
||||
this.suggestEl.style.maxWidth = "100%";
|
||||
this.suggestEl.style.width = `${input.inputEl.clientWidth}px`;
|
||||
this.inputEl.addEventListener("input", () => this.getFile());
|
||||
|
||||
// Pre-bind the handler
|
||||
this.handleGetFile = this.getFile.bind(this);
|
||||
this.inputEl.addEventListener("input", this.handleGetFile);
|
||||
|
||||
this.setPlaceholder(t("SELECT_FILE_TO_INSERT"));
|
||||
this.emptyStateText = t("NO_MATCH");
|
||||
}
|
||||
@@ -139,4 +145,9 @@ export class FileSuggestionModal extends SuggestionModal<LinkSuggestion> {
|
||||
getItems() {
|
||||
return this.filesAndAliases;
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.inputEl.removeEventListener("input", this.handleGetFile);
|
||||
super.close();
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,16 @@ export class FolderSuggestionModal extends SuggestionModal<TFolder> {
|
||||
cache: CachedMetadata;
|
||||
folders: TFolder[];
|
||||
folder: TFolder;
|
||||
private handleGetFolder: () => void;
|
||||
|
||||
constructor(app: App, input: TextComponent, items: TFolder[]) {
|
||||
super(app, input.inputEl, items);
|
||||
this.folders = [...items];
|
||||
this.text = input;
|
||||
|
||||
this.inputEl.addEventListener("input", () => this.getFolder());
|
||||
// Pre-bind the handler
|
||||
this.handleGetFolder = this.getFolder.bind(this);
|
||||
this.inputEl.addEventListener("input", this.handleGetFolder);
|
||||
}
|
||||
getFolder() {
|
||||
const v = this.inputEl.value;
|
||||
@@ -32,6 +36,10 @@ export class FolderSuggestionModal extends SuggestionModal<TFolder> {
|
||||
|
||||
this.onInputChanged();
|
||||
}
|
||||
close(): void {
|
||||
this.inputEl.removeEventListener("input", this.handleGetFolder);
|
||||
super.close();
|
||||
}
|
||||
getItemText(item: TFolder) {
|
||||
return item.path;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,16 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
files: TFile[];
|
||||
text: TextComponent;
|
||||
cache: CachedMetadata;
|
||||
private handleGetFile: () => void;
|
||||
|
||||
constructor(app: App, input: TextComponent, items: TFile[]) {
|
||||
super(app, input.inputEl, items);
|
||||
this.files = [...items];
|
||||
this.text = input;
|
||||
//this.getFile();
|
||||
|
||||
this.inputEl.addEventListener("input", this.getFile.bind(this));
|
||||
// Pre-bind the handler
|
||||
this.handleGetFile = this.getFile.bind(this);
|
||||
this.inputEl.addEventListener("input", this.handleGetFile);
|
||||
}
|
||||
|
||||
getFile() {
|
||||
@@ -40,6 +43,12 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
}
|
||||
this.onInputChanged();
|
||||
}
|
||||
|
||||
close(): void {
|
||||
this.inputEl.removeEventListener("input", this.handleGetFile);
|
||||
super.close();
|
||||
}
|
||||
|
||||
getItemText(item: TFile | HeadingCache | BlockCache) {
|
||||
if (item instanceof TFile) {
|
||||
return item.path;
|
||||
@@ -51,6 +60,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
return (<BlockCache>item).id;
|
||||
}
|
||||
}
|
||||
|
||||
onChooseItem(item: TFile | HeadingCache | BlockCache) {
|
||||
if (item instanceof TFile) {
|
||||
this.text.setValue(item.basename);
|
||||
@@ -64,6 +74,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
this.text.setValue(`${this.file.basename}^${(<BlockCache>item).id}`);
|
||||
}
|
||||
}
|
||||
|
||||
selectSuggestion({ item }: FuzzyMatch<TFile | BlockCache | HeadingCache>) {
|
||||
let link: string;
|
||||
if (item instanceof TFile) {
|
||||
@@ -79,6 +90,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
||||
renderSuggestion(
|
||||
result: FuzzyMatch<TFile | BlockCache | HeadingCache>,
|
||||
el: HTMLElement,
|
||||
@@ -131,6 +143,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
content.setText((<BlockCache>item).id);
|
||||
}
|
||||
}
|
||||
|
||||
get headings() {
|
||||
if (!this.file) {
|
||||
return [];
|
||||
@@ -140,6 +153,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
}
|
||||
return this.cache.headings || [];
|
||||
}
|
||||
|
||||
get blocks() {
|
||||
if (!this.file) {
|
||||
return [];
|
||||
@@ -149,6 +163,7 @@ export class PathSuggestionModal extends SuggestionModal<
|
||||
}
|
||||
return Object.values(this.cache.blocks || {}) || [];
|
||||
}
|
||||
|
||||
getItems() {
|
||||
const v = this.inputEl.value;
|
||||
if (/#/.test(v)) {
|
||||
|
||||
@@ -19,24 +19,34 @@ export abstract class SuggestionModal<T> extends FuzzySuggestModal<T> {
|
||||
emptyStateText: string = "No match found";
|
||||
limit: number = 100;
|
||||
shouldNotOpen: boolean;
|
||||
|
||||
// Pre-bound event handlers
|
||||
private handleInput: () => void;
|
||||
private handleFocus: () => void;
|
||||
private handleBlur: () => void;
|
||||
private handleMouseDown: (event: MouseEvent) => void;
|
||||
|
||||
constructor(app: App, inputEl: HTMLInputElement, items: T[]) {
|
||||
super(app);
|
||||
this.inputEl = inputEl;
|
||||
this.items = items;
|
||||
|
||||
// Pre-bind event handlers
|
||||
this.handleInput = this.onInputChanged.bind(this);
|
||||
this.handleFocus = this.onFocus.bind(this);
|
||||
this.handleBlur = this.close.bind(this);
|
||||
this.handleMouseDown = (event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
this.suggestEl = createDiv("suggestion-container");
|
||||
this.contentEl = this.suggestEl.createDiv("suggestion");
|
||||
this.suggester = new Suggester(this, this.contentEl, this.scope);
|
||||
this.scope.register([], "Escape", this.onEscape.bind(this));
|
||||
this.inputEl.addEventListener("input", this.onInputChanged.bind(this));
|
||||
this.inputEl.addEventListener("focus", this.onFocus.bind(this));
|
||||
this.inputEl.addEventListener("blur", this.close.bind(this));
|
||||
this.suggestEl.on(
|
||||
"mousedown",
|
||||
".suggestion-container",
|
||||
(event: MouseEvent) => {
|
||||
event.preventDefault();
|
||||
},
|
||||
);
|
||||
this.inputEl.addEventListener("input", this.handleInput);
|
||||
this.inputEl.addEventListener("focus", this.handleFocus);
|
||||
this.inputEl.addEventListener("blur", this.handleBlur);
|
||||
this.suggestEl.on("mousedown", ".suggestion-container", this.handleMouseDown);
|
||||
}
|
||||
|
||||
empty() {
|
||||
@@ -74,24 +84,27 @@ export abstract class SuggestionModal<T> extends FuzzySuggestModal<T> {
|
||||
open(): void {
|
||||
// TODO: Figure out a better way to do this. Idea from Periodic Notes plugin
|
||||
this.app.keymap.pushScope(this.scope);
|
||||
this.inputEl.ownerDocument.body.appendChild(this.suggestEl);
|
||||
this.popper = new WeakRef(createPopper(this.inputEl, this.suggestEl, {
|
||||
placement: "bottom-start",
|
||||
modifiers: [
|
||||
{
|
||||
name: "offset",
|
||||
options: {
|
||||
offset: [0, 10],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "flip",
|
||||
options: {
|
||||
fallbackPlacements: ["top"],
|
||||
},
|
||||
},
|
||||
],
|
||||
}));
|
||||
//setTimeout(() => {
|
||||
const modal = this.inputEl.closest(".modal");
|
||||
const modalContainer =
|
||||
(this.inputEl.closest(".modal-container") as HTMLElement) ??
|
||||
(modal?.parentElement?.matches(".modal-container")
|
||||
? (modal.parentElement as HTMLElement)
|
||||
: null);
|
||||
|
||||
const host = modalContainer ?? this.inputEl.ownerDocument.body;
|
||||
|
||||
host.appendChild(this.suggestEl);
|
||||
|
||||
this.popper = new WeakRef(createPopper(this.inputEl, this.suggestEl, {
|
||||
placement: "bottom-start",
|
||||
strategy: host.matches(".modal-container") ? "absolute" : "fixed",
|
||||
modifiers: [
|
||||
{ name: "offset", options: { offset: [0, 10] } },
|
||||
{ name: "flip", options: { fallbackPlacements: ["top"] } },
|
||||
],
|
||||
}));
|
||||
//},50);
|
||||
}
|
||||
|
||||
onEscape(): void {
|
||||
@@ -106,9 +119,9 @@ export abstract class SuggestionModal<T> extends FuzzySuggestModal<T> {
|
||||
if (this.popper?.deref()) {
|
||||
this.popper.deref().destroy();
|
||||
}
|
||||
this.inputEl.removeEventListener("input", this.onInputChanged.bind(this));
|
||||
this.inputEl.removeEventListener("focus", this.onFocus.bind(this));
|
||||
this.inputEl.removeEventListener("blur", this.close.bind(this));
|
||||
this.inputEl.removeEventListener("input", this.handleInput);
|
||||
this.inputEl.removeEventListener("focus", this.handleFocus);
|
||||
this.inputEl.removeEventListener("blur", this.handleBlur);
|
||||
this.suggestEl.detach();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,14 @@ export type SVGColorInfo = Map<string, {
|
||||
stroke: boolean;
|
||||
}>;
|
||||
|
||||
export type ScriptSettingValue = {
|
||||
value?:string | number | boolean,
|
||||
hidden?: boolean,
|
||||
description?: string,
|
||||
valueset?: string[],
|
||||
height?: number,
|
||||
};
|
||||
|
||||
export type ImageInfo = {
|
||||
mimeType: MimeType,
|
||||
id: FileId,
|
||||
|
||||
Vendored
-7
@@ -106,13 +106,6 @@ declare namespace ExcalidrawLib {
|
||||
},
|
||||
): { x: number; y: number };
|
||||
|
||||
function determineFocusDistance(
|
||||
element: ExcalidrawBindableElement,
|
||||
elementsMap: ElementsMap,
|
||||
a: GlobalPoint,
|
||||
b: GlobalPoint,
|
||||
): number;
|
||||
|
||||
function intersectElementWithLine(
|
||||
element: ExcalidrawBindableElement,
|
||||
a: GlobalPoint,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type ButtonDefinition = { caption: string; tooltip?:string; action: Function };
|
||||
export type ButtonDefinition = { caption: string; tooltip?:string; action: Function, iconId?: string };
|
||||
|
||||
export interface InputPromptOptions {
|
||||
header: string,
|
||||
|
||||
@@ -58,6 +58,7 @@ const handleGenericPrompt = async (request: AIRequest) : Promise<RequestUrlRespo
|
||||
const {
|
||||
openAIAPIToken,
|
||||
openAIDefaultTextModel,
|
||||
openAIDefaultTextModelMaxTokens,
|
||||
openAIDefaultVisionModel,
|
||||
openAIURL,
|
||||
openAIImageGenerationURL,
|
||||
@@ -72,7 +73,7 @@ const handleGenericPrompt = async (request: AIRequest) : Promise<RequestUrlRespo
|
||||
case "text":
|
||||
body = {
|
||||
model: openAIDefaultTextModel,
|
||||
max_tokens: 4096,
|
||||
...(openAIDefaultTextModelMaxTokens > 0 && { max_tokens: openAIDefaultTextModelMaxTokens }),
|
||||
messages: [
|
||||
...(systemPrompt && systemPrompt.trim() !=="" ? [{role: "system" as const,content: systemPrompt}] : []),
|
||||
{
|
||||
@@ -86,7 +87,7 @@ const handleGenericPrompt = async (request: AIRequest) : Promise<RequestUrlRespo
|
||||
case "image":
|
||||
body = {
|
||||
model: openAIDefaultVisionModel,
|
||||
max_tokens: 4096,
|
||||
...(openAIDefaultTextModelMaxTokens > 0 && { max_tokens: openAIDefaultTextModelMaxTokens }),
|
||||
messages: [
|
||||
...(systemPrompt && systemPrompt.trim() !=="" ? [{role: "system" as const,content: systemPrompt}] : []),
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { ColorMaster } from "@zsviczian/colormaster";
|
||||
import CM, { ColorMaster } from "@zsviczian/colormaster";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { DynamicStyle } from "src/types/types";
|
||||
@@ -190,4 +190,43 @@ export const setDynamicStyle = (
|
||||
color = null;
|
||||
dynamicStyle = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const colorsCache: Map<string,string> = new Map();
|
||||
|
||||
export function getHighlightColor(
|
||||
ea: ExcalidrawAutomate,
|
||||
bgColor: string,
|
||||
opacity:number = 1
|
||||
): string {
|
||||
bgColor = bgColor==="transparent" ? "#ffffff": bgColor;
|
||||
|
||||
let contrastedRGBA = colorsCache.get(bgColor);
|
||||
if(!contrastedRGBA) {
|
||||
const bg = ea.getCM(bgColor);
|
||||
const bgMix = ea.getCM(bgColor);
|
||||
const isDark = bg.isDark();
|
||||
|
||||
const step = 15;
|
||||
const candidates = [
|
||||
CM((isDark ? bg.lighterBy(step) : bg.darkerBy(step)).stringHEX()),
|
||||
CM((isDark ? bg.lighterBy(step) : bg.darkerBy(step)).stringHEX()),
|
||||
isDark ? bg.lighterBy(step) : bg.darkerBy(step),
|
||||
// Vibrancy boost by mixing toward the opposite theme color
|
||||
bgMix.mix({color: ea.getCM(isDark ? "#ffffff" : "#000000"), ratio:0.35}),
|
||||
ea.getCM(isDark ? "#ffffff" : "#000000"),
|
||||
ea.getCM(isDark ? "#000000" : "#ffffff"),
|
||||
];
|
||||
|
||||
const desiredContrast = 2.5;
|
||||
const contrasted = candidates.find(color =>
|
||||
color.contrast({bgColor, ratio:false}) as number >= desiredContrast) ??
|
||||
candidates.reduce((best, color) =>
|
||||
(color.contrast({bgColor, ratio: false}) > best.contrast({bgColor, ratio:false}) ? color : best)
|
||||
);
|
||||
contrastedRGBA = `rgba(${Math.round(contrasted.red)
|
||||
},${Math.round(contrasted.green)},${Math.round(contrasted.blue)}`;
|
||||
colorsCache.set(bgColor,contrastedRGBA);
|
||||
}
|
||||
return `${contrastedRGBA},${opacity})`;
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawImageElement,
|
||||
FileId,
|
||||
FixedPoint,
|
||||
} from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { normalizePath, TFile } from "obsidian";
|
||||
|
||||
@@ -30,7 +31,7 @@ import {
|
||||
isVersionNewerThanOther,
|
||||
scaleLoadedImage,
|
||||
} from "src/utils/utils";
|
||||
import { GenericInputPrompt, NewFileActions } from "src/shared/Dialogs/Prompt";
|
||||
import { GenericInputPrompt, LaTexPrompt, NewFileActions } from "src/shared/Dialogs/Prompt";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types";
|
||||
import {
|
||||
@@ -38,9 +39,9 @@ import {
|
||||
extractCodeBlocks as _extractCodeBlocks,
|
||||
} from "../utils/AIUtils";
|
||||
import { EmbeddedFilesLoader } from "src/shared/EmbeddedFileLoader";
|
||||
import { SVGColorInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { ExcalidrawData, getExcalidrawMarkdownHeaderSection, REGEX_LINK } from "src/shared/ExcalidrawData";
|
||||
import { getFrameBasedOnFrameNameOrId } from "./excalidrawViewUtils";
|
||||
import { ScriptSettingValue, SVGColorInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { ExcalidrawData, getExcalidrawMarkdownHeaderSection, REG_LINKINDEX_HYPERLINK, REGEX_LINK } from "src/shared/ExcalidrawData";
|
||||
import { getFrameBasedOnFrameNameOrId, sceneRemoveInternalLinks } from "./excalidrawViewUtils";
|
||||
import { ScriptEngine } from "src/shared/Scripts";
|
||||
import { getEA } from "src/core";
|
||||
import { ColorMap, FileData } from "src/types/embeddedFileLoaderTypes";
|
||||
@@ -450,6 +451,12 @@ export const updateElementLinksToObsidianLinks = ({elements, hostFile}:{
|
||||
const partsArray = REGEX_LINK.getResList(el.link)[0];
|
||||
if(!partsArray?.value) return el;
|
||||
let linkText = REGEX_LINK.getLink(partsArray);
|
||||
if (linkText.match(REG_LINKINDEX_HYPERLINK)) {
|
||||
if(linkText.startsWith("obsidian://") || linkText.startsWith("cmd://")) return el;
|
||||
const newElement: Mutable<ExcalidrawElement> = cloneElement(el);
|
||||
newElement.link = linkText;
|
||||
return newElement;
|
||||
}
|
||||
if (linkText.search("#") > -1) {
|
||||
const linkParts = getLinkParts(linkText, hostFile);
|
||||
linkText = linkParts.path;
|
||||
@@ -506,6 +513,7 @@ export async function createSVG(
|
||||
padding?: number,
|
||||
imagesDict?: any,
|
||||
convertMarkdownLinksToObsidianURLs: boolean = false,
|
||||
includeInternalLinks: boolean = true,
|
||||
): Promise<SVGSVGElement> {
|
||||
if (!loader) {
|
||||
loader = new EmbeddedFilesLoader(plugin);
|
||||
@@ -536,7 +544,7 @@ export async function createSVG(
|
||||
type: "excalidraw",
|
||||
version: 2,
|
||||
source: GITHUB_RELEASES+PLUGIN_VERSION,
|
||||
elements,
|
||||
elements: includeInternalLinks ? elements : sceneRemoveInternalLinks({elements}),
|
||||
appState: {
|
||||
theme,
|
||||
viewBackgroundColor:
|
||||
@@ -649,15 +657,19 @@ export function repositionElementsToCursor(
|
||||
export const insertLaTeXToView = (view: ExcalidrawView, center: boolean = false) => {
|
||||
const app = view.plugin.app;
|
||||
const ea = getEA(view) as ExcalidrawAutomate;
|
||||
GenericInputPrompt.Prompt(
|
||||
view,
|
||||
view.plugin,
|
||||
app,
|
||||
t("ENTER_LATEX"),
|
||||
"\\color{red}\\oint_S {E_n dA = \\frac{1}{{\\varepsilon _0 }}} Q_{inside}",
|
||||
view.plugin.settings.latexBoilerplate,
|
||||
undefined,
|
||||
3
|
||||
const isLatexSuitAvailable = !!app.plugins.plugins["obsidian-latex-suite"];
|
||||
(isLatexSuitAvailable
|
||||
? LaTexPrompt.Prompt(app, t("ENTER_LATEX"), view.plugin.settings.latexBoilerplate)
|
||||
: GenericInputPrompt.Prompt(
|
||||
view,
|
||||
view.plugin,
|
||||
app,
|
||||
t("ENTER_LATEX"),
|
||||
"\\color{red}\\oint_S {E_n dA = \\frac{1}{{\\varepsilon _0 }}} Q_{inside}",
|
||||
view.plugin.settings.latexBoilerplate,
|
||||
undefined,
|
||||
3
|
||||
)
|
||||
).then(async (formula: string) => {
|
||||
if (formula) {
|
||||
const id = await ea.addLaTex(0, 0, formula);
|
||||
@@ -672,7 +684,7 @@ export const insertLaTeXToView = (view: ExcalidrawView, center: boolean = false)
|
||||
ea.selectElementsInView([id]);
|
||||
}
|
||||
ea.destroy();
|
||||
});
|
||||
}, () => {});
|
||||
};
|
||||
|
||||
export const search = async (view: ExcalidrawView) => {
|
||||
@@ -845,4 +857,83 @@ export const getBoundTextElementId = (container: ExcalidrawElement | null) => {
|
||||
return container?.boundElements?.length
|
||||
? container?.boundElements?.find((ele) => ele.type === "text")?.id || null
|
||||
: null;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* FixedPoint represents the fixed point binding information in form of a vertical and
|
||||
* horizontal ratio (i.e. a percentage value in the 0.0-1.0 range). This ratio
|
||||
* gives the user selected fixed point by multiplying the bound element width
|
||||
* with fixedPoint[0] and the bound element height with fixedPoint[1] to get the
|
||||
* bound element-local point coordinate.
|
||||
*/
|
||||
export const normalizeFixedPoint = <T extends FixedPoint | null | undefined>(
|
||||
fixedPoint: T,
|
||||
): T extends null ? null : FixedPoint => {
|
||||
if (!fixedPoint) {
|
||||
return [0.50001, 0.5001] as any as T extends null ? null : FixedPoint;
|
||||
}
|
||||
if (fixedPoint[0] < 0 || fixedPoint[0] > 1) {
|
||||
fixedPoint[0] = 0.5001;
|
||||
}
|
||||
if (fixedPoint[1] < 0 || fixedPoint[1] > 1) {
|
||||
fixedPoint[1] = 0.5001;
|
||||
}
|
||||
// Do not allow a precise 0.5 for fixed point ratio
|
||||
// to avoid jumping arrow heading due to floating point imprecision
|
||||
if (
|
||||
fixedPoint &&
|
||||
(Math.abs(fixedPoint[0] - 0.5) < 0.0001 ||
|
||||
Math.abs(fixedPoint[1] - 0.5) < 0.0001)
|
||||
) {
|
||||
return fixedPoint.map((ratio) =>
|
||||
Math.abs(ratio - 0.5) < 0.0001 ? 0.5001 : ratio,
|
||||
) as T extends null ? null : FixedPoint;
|
||||
}
|
||||
return fixedPoint as any as T extends null ? null : FixedPoint;
|
||||
};
|
||||
|
||||
export const normalizeBindMode = (bindMode?: string): "orbit" | "inside" => {
|
||||
if (!bindMode || (bindMode !== "orbit" && bindMode !== "inside")) {
|
||||
return "orbit";
|
||||
}
|
||||
return bindMode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ensures that plugin.settings.scriptEngineSettings and the active script's settings object exist.
|
||||
* Handles undefined/null during initialization.
|
||||
*
|
||||
* Note: kept in utils (not as an EA private method) so it won't be exposed on window.ExcalidrawAutomate.
|
||||
*/
|
||||
export function ensureActiveScriptSettingsObject(
|
||||
ea: ExcalidrawAutomate
|
||||
): Record<string, ScriptSettingValue> | null {
|
||||
const activeScript = ea?.activeScript;
|
||||
const plugin = ea?.plugin;
|
||||
|
||||
if (!activeScript || !plugin?.settings) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Ensure the top-level container exists
|
||||
if (!plugin.settings.scriptEngineSettings || typeof plugin.settings.scriptEngineSettings !== "object") {
|
||||
plugin.settings.scriptEngineSettings = {};
|
||||
}
|
||||
|
||||
// Ensure the per-script settings object exists (handle null/undefined)
|
||||
const current = plugin.settings.scriptEngineSettings[activeScript];
|
||||
if (!current || typeof current !== "object") {
|
||||
plugin.settings.scriptEngineSettings[activeScript] = {};
|
||||
}
|
||||
|
||||
return plugin.settings.scriptEngineSettings[activeScript] as Record<string, ScriptSettingValue>;
|
||||
}
|
||||
|
||||
export function getLastActiveExcalidrawView(plugin: ExcalidrawPlugin): ExcalidrawView | null {
|
||||
const leaf = plugin.app.workspace.getLeafById(plugin.lastActiveExcalidrawLeafID);
|
||||
if(leaf && leaf.view instanceof ExcalidrawView) {
|
||||
return leaf.view as ExcalidrawView;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -137,6 +137,23 @@ function getLinkFromMarkdownLink(link: string): string {
|
||||
return result ? result[1] : link;
|
||||
}
|
||||
|
||||
function isInternalLink(link:string):boolean {
|
||||
link = getLinkFromMarkdownLink(link);
|
||||
if (link.startsWith("cmd://")) return true;
|
||||
if (link.startsWith("obsidian://")) return true;
|
||||
if (link.match(REG_LINKINDEX_HYPERLINK)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export function sceneRemoveInternalLinks(scene: {elements: ExcalidrawElement[]}): ExcalidrawElement[] {
|
||||
const elements: ExcalidrawElement[] = JSON.parse(JSON.stringify(scene.elements));
|
||||
elements.forEach(el => {
|
||||
if(!el.link) return;
|
||||
if(isInternalLink(el.link)) (el as Mutable<ExcalidrawElement>).link = null;
|
||||
});
|
||||
return elements;
|
||||
}
|
||||
|
||||
export function openExternalLink (link:string, app: App, element?: ExcalidrawElement):boolean {
|
||||
link = getLinkFromMarkdownLink(link);
|
||||
if (link.match(/^cmd:\/\/.*/)) {
|
||||
@@ -254,12 +271,11 @@ export async function addBackOfTheNoteCard(
|
||||
const shouldRemoveTrailingHashtag = Boolean(hastag);
|
||||
view.data = data.replace(
|
||||
header,
|
||||
(shouldRemoveTrailingHashtag
|
||||
() => (shouldRemoveTrailingHashtag
|
||||
? header.substring(0,header.length-hastag[0].length)
|
||||
: header) +
|
||||
`\n# ${title}\n\n${cardBody ? cardBody+"\n\n" : ""}${
|
||||
shouldAddHashtag || shouldRemoveTrailingHashtag ? "#\n" : ""}`);
|
||||
|
||||
await view.forceSave(true);
|
||||
let watchdog = 0;
|
||||
await sleep(200);
|
||||
|
||||
@@ -176,7 +176,9 @@ async function printPdf(
|
||||
printDiv.style.top = "0";
|
||||
printDiv.style.left = "0";
|
||||
printDiv.style.display = "flex";
|
||||
printDiv.appendChild(elementToPrint);
|
||||
//printDiv.appendChild(elementToPrint); // if I append directly, rounded images and clip paths get messed up
|
||||
// see https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2544
|
||||
printDiv.innerHTML = elementToPrint.outerHTML;
|
||||
|
||||
const options: PrintToPDFOptions = {
|
||||
includeName: false,
|
||||
|
||||
+3
-1
@@ -36,11 +36,13 @@ export async function diagramToHTML({
|
||||
apiKey,
|
||||
text,
|
||||
theme = THEME.LIGHT,
|
||||
openAIURL = "https://api.openai.com/v1/chat/completions",
|
||||
}: {
|
||||
image: DataURL;
|
||||
apiKey: string;
|
||||
text: string;
|
||||
theme?: Theme;
|
||||
openAIURL?: string;
|
||||
}) {
|
||||
const body: OpenAIInput.ChatCompletionCreateParamsBase = {
|
||||
model: EXCALIDRAW_PLUGIN.settings.openAIDefaultVisionModel,
|
||||
@@ -79,7 +81,7 @@ export async function diagramToHTML({
|
||||
| ({ ok: true } & OpenAIOutput.ChatCompletion)
|
||||
| ({ ok: false } & OpenAIOutput.APIError);
|
||||
|
||||
return await fetch("https://api.openai.com/v1/chat/completions", {
|
||||
return await fetch(openAIURL, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
|
||||
@@ -512,4 +512,9 @@ export function getAudioElementHeight(): number {
|
||||
}
|
||||
|
||||
return Math.round(height);
|
||||
}
|
||||
|
||||
export function stripYamlFrontmatter(text: string): string {
|
||||
if (!text) return text;
|
||||
return text.replace(/^---\s*\r?\n[\s\S]*?\r?\n---\s*\r?\n?/, "");
|
||||
}
|
||||
+38
-25
@@ -6,7 +6,7 @@ import {
|
||||
TFolder,
|
||||
} from "obsidian";
|
||||
import { Random } from "roughjs/bin/math";
|
||||
import { BinaryFileData, DataURL, ExcalidrawImperativeAPI} from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { BinaryFileData, DataURL} from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import {
|
||||
exportToSvg,
|
||||
exportToBlob,
|
||||
@@ -36,6 +36,7 @@ import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
|
||||
import { ExcalidrawSettings } from "src/core/settings";
|
||||
import { FileData } from "src/types/embeddedFileLoaderTypes";
|
||||
import { ExportSettings } from "src/types/exportUtilTypes";
|
||||
import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
@@ -605,7 +606,12 @@ export function scaleLoadedImage (
|
||||
export function setDocLeftHandedMode(isLeftHanded: boolean, ownerDocument:Document) {
|
||||
const newStylesheet = ownerDocument.createElement("style");
|
||||
newStylesheet.id = "excalidraw-left-handed";
|
||||
newStylesheet.textContent = `.excalidraw .App-bottom-bar{justify-content:flex-end;}`;
|
||||
newStylesheet.textContent = `.excalidraw .App-bottom-bar {
|
||||
justify-content:flex-end !important;
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
transform: none !important;
|
||||
}`;
|
||||
const oldStylesheet = ownerDocument.getElementById(newStylesheet.id);
|
||||
if (oldStylesheet) {
|
||||
ownerDocument.head.removeChild(oldStylesheet);
|
||||
@@ -616,6 +622,7 @@ export function setDocLeftHandedMode(isLeftHanded: boolean, ownerDocument:Docume
|
||||
}
|
||||
|
||||
export function setLeftHandedMode (isLeftHanded: boolean) {
|
||||
if(DEVICE.isPhone) return; //no lefthanded mode on phones
|
||||
const visitedDocs = new Set<Document>();
|
||||
EXCALIDRAW_PLUGIN.app.workspace.iterateAllLeaves((leaf) => {
|
||||
const ownerDocument = DEVICE.isMobile?document:leaf.view.containerEl.ownerDocument;
|
||||
@@ -626,31 +633,20 @@ export function setLeftHandedMode (isLeftHanded: boolean) {
|
||||
})
|
||||
};
|
||||
|
||||
export function calculateTrayModeValue(settings: ExcalidrawSettings): boolean {
|
||||
const { defaultTrayMode, compactModeOnTablets } = settings;
|
||||
const isTrayMode = DEVICE.isTablet
|
||||
? (compactModeOnTablets ? false : defaultTrayMode)
|
||||
: defaultTrayMode;
|
||||
return isTrayMode;
|
||||
export function calculateUIModeValue(settings: ExcalidrawSettings): UIMode {
|
||||
return DEVICE.isPhone
|
||||
? "phone"
|
||||
: DEVICE.isTablet
|
||||
? settings.tabletUIMode
|
||||
: DEVICE.isDesktop
|
||||
? settings.desktopUIMode
|
||||
: "tray";
|
||||
}
|
||||
|
||||
export function setTrayMode(app: App, settings: ExcalidrawSettings) {
|
||||
const isTrayMode = calculateTrayModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setTrayMode(isTrayMode));
|
||||
}
|
||||
|
||||
export function setDesktopUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const isTrayMode = settings.defaultTrayMode;
|
||||
getExcalidrawViews(app).forEach((view) => view
|
||||
.setDesktopUIMode(
|
||||
isTrayMode
|
||||
? "tray"
|
||||
: settings.compactModeOnDesktops
|
||||
? "compact"
|
||||
: "full"
|
||||
)
|
||||
);
|
||||
}
|
||||
export function setUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const uiMode = calculateUIModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setUIMode(uiMode));
|
||||
};
|
||||
|
||||
export type LinkParts = {
|
||||
original: string;
|
||||
@@ -820,6 +816,23 @@ export function getWithBackground (
|
||||
return plugin.settings.exportWithBackground;
|
||||
};
|
||||
|
||||
export function getExportInternalLinks(
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
if (
|
||||
fileCache?.frontmatter &&
|
||||
fileCache.frontmatter[FRONTMATTER_KEYS["export-internal-links"].name] !== null &&
|
||||
(typeof fileCache.frontmatter[FRONTMATTER_KEYS["export-internal-links"].name] !== "undefined")
|
||||
) {
|
||||
return fileCache.frontmatter[FRONTMATTER_KEYS["export-internal-links"].name];
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
export function getExportPadding (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
|
||||
+207
-199
@@ -110,13 +110,12 @@ import {
|
||||
getFilePathFromObsidianURL,
|
||||
getLinkParts,
|
||||
checkVersionMismatch,
|
||||
calculateTrayModeValue,
|
||||
setTrayMode,
|
||||
setDesktopUIMode,
|
||||
calculateUIModeValue,
|
||||
getExportInternalLinks,
|
||||
} from "../utils/utils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getAttachmentsFolderAndFilePath, getExcalidraAndMarkdowViewsForFile, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
import { GenericInputPrompt, MultiOptionConfirmationPrompt, NewFileActions, Prompt, linkPrompt } from "../shared/Dialogs/Prompt";
|
||||
import { GenericInputPrompt, LaTexPrompt, MultiOptionConfirmationPrompt, NewFileActions, Prompt, linkPrompt } from "../shared/Dialogs/Prompt";
|
||||
import { ClipboardData } from "@zsviczian/excalidraw/types/excalidraw/clipboard";
|
||||
import { updateEquation } from "../shared/LaTeX";
|
||||
import {
|
||||
@@ -135,7 +134,7 @@ import { getEA } from "src/core"
|
||||
import { anyModifierKeysPressed, emulateKeysForLinkClick, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, ModifierKeys } from "../utils/modifierkeyHelper";
|
||||
import { setDynamicStyle } from "../utils/dynamicStyling";
|
||||
import { CustomEmbeddable, renderWebView } from "./components/CustomEmbeddable";
|
||||
import { addBackOfTheNoteCard, deleteAppStateKeys, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, onLoadMessages, openExternalLink, parseObsidianLink, renderContextMenuAction, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { addBackOfTheNoteCard, deleteAppStateKeys, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, onLoadMessages, openExternalLink, parseObsidianLink, renderContextMenuAction, sceneRemoveInternalLinks, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { imageCache } from "../shared/ImageCache";
|
||||
import { CanvasNodeFactory, ObsidianCanvasNode } from "./managers/CanvasNodeFactory";
|
||||
import { EmbeddableMenu } from "./components/menu/EmbeddableActionsMenu";
|
||||
@@ -160,6 +159,9 @@ import { PageOrientation, PageSize, ExportSettings } from "src/types/exportUtilT
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { updateElementIdsInScene } from "src/utils/excalidrawSceneUtils";
|
||||
import { FileData } from "src/types/embeddedFileLoaderTypes";
|
||||
import { UIMode } from "src/shared/Dialogs/UIModeSettingComponent";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
import { copyLinkToSelectedElementToClipboard } from "src/shared/Dialogs/copyLinkToSelectedElement";
|
||||
|
||||
const EMBEDDABLE_SEMAPHORE_TIMEOUT = 2000;
|
||||
const PREVENT_RELOAD_TIMEOUT = 2000;
|
||||
@@ -338,6 +340,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
private destroyers: Function[] = [];
|
||||
private previousContentElHeight: number = 0;
|
||||
private resizeBatchTimer: number = null;
|
||||
private resizeBatchWindowStart: number = 0;
|
||||
private lastAggregatedDh = 0;
|
||||
private oldKeyboardScroll:{scrollY:number, scrollX:number}|null = null;
|
||||
|
||||
@@ -520,6 +523,15 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
const ed = this.exportDialog;
|
||||
return ed ? !ed.transparent : getWithBackground(this.plugin, this.file)
|
||||
}
|
||||
|
||||
public getViewExportIncludeInternalLinks(includeInternalLinks?:boolean) {
|
||||
if(typeof includeInternalLinks !== "undefined") return includeInternalLinks;
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
const ed = this.exportDialog;
|
||||
return ed ? ed.exportInternalLinks : getExportInternalLinks(this.plugin, this.file)
|
||||
}
|
||||
|
||||
public async svg(scene: any, theme?:string, embedScene?: boolean, embedFont: boolean = false): Promise<SVGSVGElement> {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.svg, "ExcalidrawView.svg", scene, theme, embedScene);
|
||||
@@ -586,7 +598,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
return;
|
||||
}
|
||||
|
||||
const svg = await this.svg(this.getScene(selectedOnly),undefined,embedScene, true);
|
||||
const scene = this.getScene(selectedOnly);
|
||||
if(!this.getViewExportIncludeInternalLinks()) {
|
||||
scene.elements = sceneRemoveInternalLinks(scene);
|
||||
}
|
||||
const svg = await this.svg(scene, undefined, embedScene, true);
|
||||
if (!svg) {
|
||||
return;
|
||||
}
|
||||
@@ -616,6 +632,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
const scene = this.getScene(selectedOnly);
|
||||
if(!this.getViewExportIncludeInternalLinks()) {
|
||||
scene.elements = sceneRemoveInternalLinks(scene);
|
||||
}
|
||||
|
||||
const svg = await this.svg(
|
||||
scene,
|
||||
@@ -968,7 +987,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
[FRONTMATTER_KEYS["export-dark"].name, this.exportDialog.theme === "dark" ? "true" : "false"],
|
||||
[FRONTMATTER_KEYS["export-transparent"].name, this.exportDialog.transparent ? "true" : "false"],
|
||||
[FRONTMATTER_KEYS["plugin"].name, this.textMode === TextMode.raw ? "raw" : "parsed"],
|
||||
[FRONTMATTER_KEYS["export-embed-scene"].name, this.exportDialog.embedScene ? "true" : "false"],
|
||||
[FRONTMATTER_KEYS["export-embed-scene"].name, this.exportDialog.embedScene ? "true" : "false"],
|
||||
[FRONTMATTER_KEYS["export-internal-links"].name, this.exportDialog.exportInternalLinks ? "true" : "false"],
|
||||
]
|
||||
: [
|
||||
[FRONTMATTER_KEYS["plugin"].name, this.textMode === TextMode.raw ? "raw" : "parsed"]
|
||||
@@ -1041,7 +1061,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(!equation) return;
|
||||
}
|
||||
|
||||
GenericInputPrompt.Prompt(this,this.plugin,this.app,t("ENTER_LATEX"),undefined,equation, undefined, 3).then(async (formula: string) => {
|
||||
//GenericInputPrompt.Prompt(this,this.plugin,this.app,t("ENTER_LATEX"),undefined,equation, undefined, 3)
|
||||
LaTexPrompt.Prompt(this.app, t("ENTER_LATEX"), equation)
|
||||
.then(async (formula: string) => {
|
||||
if (!formula || formula === equation) {
|
||||
return;
|
||||
}
|
||||
@@ -1057,7 +1079,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
addFiles,
|
||||
);
|
||||
this.setDirty(1);
|
||||
});
|
||||
}, () => {} );
|
||||
}
|
||||
|
||||
async openEmbeddedLinkEditor(imgId:string) {
|
||||
@@ -1105,7 +1127,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
t("MARKDOWN_EMBED_CUSTOMIZE_LINK_PROMPT_TITLE"),
|
||||
undefined,
|
||||
ef.linkParts.original,
|
||||
[{caption: "✅", action: (x:string)=>{x.replaceAll("\n","").trim()}}],
|
||||
[{iconId: "check", caption: "", action: (x:string)=>{x.replaceAll("\n","").trim()}}],
|
||||
3,
|
||||
false,
|
||||
(container) => container.createEl("p",{text: fragWithHTML(t("MARKDOWN_EMBED_CUSTOMIZE_LINK_PROMPT"))}),
|
||||
@@ -1636,21 +1658,26 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.registerDomEvent(this.containerEl,"wheel",wheelEvent, {passive: false});
|
||||
|
||||
this.actionButtons = {
|
||||
scriptInstall: this.addAction(SCRIPTENGINE_ICON_NAME, t("INSTALL_SCRIPT_BUTTON"), () => {
|
||||
new ScriptInstallPrompt(this.plugin).open();
|
||||
scriptInstall: this.addAction(
|
||||
SCRIPTENGINE_ICON_NAME,
|
||||
!DEVICE.isMobile ? t("INSTALL_SCRIPT_BUTTON") : "",
|
||||
() => {
|
||||
new ScriptInstallPrompt(this.plugin).open();
|
||||
}),
|
||||
save: this.addAction(
|
||||
DISK_ICON_NAME,
|
||||
t("FORCE_SAVE"),
|
||||
!DEVICE.isMobile ? t("FORCE_SAVE") : "",
|
||||
async () => this.forceSave(),
|
||||
),
|
||||
isRaw: this.addAction(
|
||||
TEXT_DISPLAY_RAW_ICON_NAME,
|
||||
t("RAW"),
|
||||
!DEVICE.isMobile ? t("RAW") : "",
|
||||
() => this.changeTextMode(TextMode.parsed),
|
||||
),
|
||||
link: this.addAction("link", t("OPEN_LINK"), (ev) =>
|
||||
this.handleLinkClick(ev),
|
||||
link: this.addAction(
|
||||
"link",
|
||||
!DEVICE.isMobile ? t("OPEN_LINK") : "",
|
||||
(ev) => this.handleLinkClick(ev),
|
||||
),
|
||||
}
|
||||
/*this.actionButtons['isParsed'] = this.addAction(
|
||||
@@ -2013,7 +2040,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//I noticed Obsidian calls this function twice when disabling the plugin
|
||||
//once from "unregisterView"
|
||||
//the from "detachLeavesOfType"
|
||||
if(!this.dropManager) return; //the view is already closed
|
||||
if(!this.dropManager && !this.excalidrawRoot) return; //the view is already closed
|
||||
|
||||
// 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
|
||||
@@ -2021,6 +2048,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(!this.file) return;
|
||||
|
||||
this.exitFullscreen();
|
||||
|
||||
await this.forceSaveIfRequired();
|
||||
if (this.excalidrawRoot) {
|
||||
this.excalidrawRoot.unmount();
|
||||
@@ -2029,38 +2057,69 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
this.clearPreventReloadTimer();
|
||||
this.clearEmbeddableNodeIsEditingTimer();
|
||||
this.plugin.scriptEngine?.removeViewEAs(this);
|
||||
if (this.activeLoader) {
|
||||
this.activeLoader.terminate = true;
|
||||
this.activeLoader = null;
|
||||
}
|
||||
if (this.nextLoader) {
|
||||
this.nextLoader.terminate = true;
|
||||
this.nextLoader = null;
|
||||
}
|
||||
if (this.plugin) {
|
||||
this.plugin.scriptEngine?.removeViewEAs(this);
|
||||
if(this.plugin.ea?.targetView === this) {
|
||||
this.plugin.ea.targetView = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.excalidrawAPI = null;
|
||||
|
||||
this.dropManager.destroy();
|
||||
this.dropManager = null;
|
||||
if (this.dropManager) {
|
||||
this.dropManager.destroy();
|
||||
this.dropManager = null;
|
||||
}
|
||||
|
||||
if(this.canvasNodeFactory) {
|
||||
this.canvasNodeFactory.destroy();
|
||||
this.canvasNodeFactory = null;
|
||||
}
|
||||
this.canvasNodeFactory = null;
|
||||
this.embeddableLeafRefs.clear();
|
||||
this.embeddableRefs.clear();
|
||||
Object.values(this.actionButtons).forEach((el) => el.remove());
|
||||
this.actionButtons = {} as Record<ActionButtons, HTMLElement>;
|
||||
|
||||
if(this.embeddableLeafRefs) {
|
||||
this.embeddableLeafRefs.clear();
|
||||
this.embeddableLeafRefs = null;
|
||||
}
|
||||
|
||||
if(this.embeddableRefs) {
|
||||
this.embeddableRefs.clear();
|
||||
this.embeddableRefs = null;
|
||||
}
|
||||
|
||||
if(this.actionButtons) {
|
||||
Object.values(this.actionButtons).forEach((el) => el.remove());
|
||||
this.actionButtons = null; //{} as Record<ActionButtons, HTMLElement>;
|
||||
}
|
||||
|
||||
if (this.excalidrawData) {
|
||||
this.excalidrawData.destroy();
|
||||
this.excalidrawData = null;
|
||||
};
|
||||
|
||||
if(this.exportDialog) {
|
||||
this.exportDialog.destroy();
|
||||
this.exportDialog = null;
|
||||
}
|
||||
|
||||
this.hoverPreviewTarget = null;
|
||||
if(this.plugin.ea?.targetView === this) {
|
||||
this.plugin.ea.targetView = null;
|
||||
}
|
||||
|
||||
if(this._hookServer?.targetView === this) {
|
||||
this._hookServer.targetView = null;
|
||||
}
|
||||
this._hookServer = null;
|
||||
this.containerEl.onWindowMigrated = null;
|
||||
this.packages = {react:null, reactDOM:null, excalidrawLib:null};
|
||||
if(this.containerEl) {
|
||||
this.containerEl.onWindowMigrated = null;
|
||||
}
|
||||
|
||||
this.packages = null; //{react:null, reactDOM:null, excalidrawLib:null};
|
||||
|
||||
let leafcount = 0;
|
||||
this.app.workspace.iterateAllLeaves(l=>{
|
||||
@@ -2070,7 +2129,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
leafcount++;
|
||||
}
|
||||
})
|
||||
if(leafcount === 0) {
|
||||
if(leafcount === 0 && this.plugin) {
|
||||
this.plugin.deletePackage(this.ownerWindow);
|
||||
}
|
||||
|
||||
@@ -2080,6 +2139,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
//super.onClose will unmount Excalidraw, need to save before that
|
||||
await super.onClose();
|
||||
this._plugin = null;
|
||||
this._hookServer = null;
|
||||
this.excalidrawData = null;
|
||||
this.canvasNodeFactory = null;
|
||||
|
||||
tmpBruteForceCleanup(this);
|
||||
}
|
||||
|
||||
@@ -2107,11 +2171,42 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.removeParentMoveObserver();
|
||||
this.removeSlidingPanesListner();
|
||||
if (this.autosaveTimer) {
|
||||
window.clearInterval(this.autosaveTimer);
|
||||
window.clearTimeout(this.autosaveTimer);
|
||||
this.autosaveTimer = null;
|
||||
}
|
||||
this.autosaveFunction = null;
|
||||
|
||||
if (this.dropManager) {
|
||||
this.dropManager.destroy();
|
||||
this.dropManager = null;
|
||||
}
|
||||
|
||||
// Clear all other timers
|
||||
if (this.isEditingTextResetTimer) {
|
||||
window.clearTimeout(this.isEditingTextResetTimer);
|
||||
this.isEditingTextResetTimer = null;
|
||||
}
|
||||
if (this.preventReloadResetTimer) {
|
||||
window.clearTimeout(this.preventReloadResetTimer);
|
||||
this.preventReloadResetTimer = null;
|
||||
}
|
||||
if (this.editingSelfResetTimer) {
|
||||
window.clearTimeout(this.editingSelfResetTimer);
|
||||
this.editingSelfResetTimer = null;
|
||||
}
|
||||
if (this.resizeBatchTimer) {
|
||||
window.clearTimeout(this.resizeBatchTimer);
|
||||
this.resizeBatchTimer = null;
|
||||
}
|
||||
if (this.colorChangeTimer) {
|
||||
window.clearTimeout(this.colorChangeTimer);
|
||||
this.colorChangeTimer = null;
|
||||
}
|
||||
if (this.semaphores?.wheelTimeout) {
|
||||
window.clearTimeout(this.semaphores.wheelTimeout);
|
||||
this.semaphores.wheelTimeout = null;
|
||||
}
|
||||
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.onunload,`ExcalidrawView.onunload, completed`);
|
||||
}
|
||||
|
||||
@@ -2563,7 +2658,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
const opacity = this.plugin.settings.gridSettings.OPACITY/100;
|
||||
|
||||
if (this.plugin.settings.gridSettings.DYNAMIC_COLOR) {
|
||||
// Dynamic color: concatenate opacity to the HEX string
|
||||
// Dynamic color: concatenate opacity to the RGB string !!! Excalidraw expects an RGBA string !!!
|
||||
Regular = (isDark ? cm.lighterBy(10) : cm.darkerBy(10)).alphaTo(opacity).stringRGB({ alpha: true });
|
||||
Bold = (isDark ? cm.lighterBy(5) : cm.darkerBy(5)).alphaTo(opacity).stringRGB({ alpha: true });
|
||||
} else {
|
||||
@@ -2574,7 +2669,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
// Regular uses the custom color directly
|
||||
Regular = customCM.alphaTo(opacity).stringRGB({ alpha: true });
|
||||
|
||||
// Bold is 7 shades lighter or darker based on the custom color's darkness
|
||||
// Bold is 10 shades lighter or darker based on the custom color's darkness
|
||||
Bold = (customIsDark ? customCM.lighterBy(10) : customCM.darkerBy(10)).alphaTo(opacity).stringRGB({ alpha: true });
|
||||
}
|
||||
|
||||
@@ -2913,7 +3008,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true, justloaded);
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
this.setTrayMode(calculateTrayModeValue(this.plugin.settings));
|
||||
const uiMode = calculateUIModeValue(this.plugin.settings);
|
||||
this.setUIMode(uiMode);
|
||||
}
|
||||
|
||||
public setDirty(location?:number) {
|
||||
@@ -3628,6 +3724,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
api.updateContainerSize(api.getSceneElements().filter(el => newIds.includes(el.id)).filter(isContainer));
|
||||
api.refreshAllArrows();
|
||||
if (save) {
|
||||
await this.save(false); //preventReload=false will ensure that markdown links are paresed and displayed correctly
|
||||
} else {
|
||||
@@ -3702,6 +3799,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
frameRendering: st.frameRendering,
|
||||
objectsSnapModeEnabled: st.objectsSnapModeEnabled,
|
||||
activeTool,
|
||||
disableContextMenu: st.disableContextMenu,
|
||||
},
|
||||
prevTextMode: this.prevTextMode,
|
||||
files,
|
||||
@@ -3796,6 +3894,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
};
|
||||
|
||||
private showHoverPreview(linktext?: string, element?: ExcalidrawElement) {
|
||||
if(this.hoverPreviewTarget) return; //hover preview is already shown
|
||||
//(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.showHoverPreview, "ExcalidrawView.showHoverPreview", linktext, element);
|
||||
if(!this.lastMouseEvent) return;
|
||||
const st = this.excalidrawAPI?.getAppState();
|
||||
@@ -4023,7 +4122,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
st = (this.excalidrawAPI as ExcalidrawImperativeAPI).getAppState();
|
||||
canvasColor = canvasColor ?? st.viewBackgroundColor === "transparent" ? "white" : st.viewBackgroundColor;
|
||||
}
|
||||
window.setTimeout(()=>this.updateScene({appState:{gridColor: this.getGridColor(canvasColor, st)}, captureUpdate: CaptureUpdateAction.NEVER}));
|
||||
window.setTimeout(()=>this.updateScene(
|
||||
{
|
||||
appState:{
|
||||
gridColor: this.getGridColor(canvasColor, st),
|
||||
},
|
||||
captureUpdate: CaptureUpdateAction.NEVER}));
|
||||
}
|
||||
|
||||
public updateGridDirection(gridDirection: {horizontal: boolean, vertical: boolean}) {
|
||||
@@ -4151,8 +4255,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
source: GITHUB_RELEASES+PLUGIN_VERSION,
|
||||
libraryItems: items,
|
||||
};
|
||||
this.plugin.setStencilLibrary(lib);
|
||||
await this.plugin.saveSettings();
|
||||
|
||||
await this.plugin.setStencilLibrary(lib)
|
||||
})();
|
||||
}
|
||||
|
||||
@@ -4547,6 +4651,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
// - depending on the textMode, return the text with markdown markup or the parsed text
|
||||
// if quick parse was not successful return [null, null, null] to indicate that the no changes were made to the text element
|
||||
if (parseResultOriginal) {
|
||||
//const allowLinkSync = this.plugin.settings.allowLinkSync;
|
||||
//there were no transclusions in the raw text, quick parse was successful
|
||||
if (containerId) {
|
||||
this.updateContainerSize(containerId, true);
|
||||
@@ -5198,6 +5303,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
apiKey: this.plugin.settings.openAIAPIToken,
|
||||
text: textFromFrameChildren,
|
||||
theme: appState.theme,
|
||||
openAIURL: this.plugin.settings.openAIURL,
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
@@ -5359,15 +5465,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
icon: ICONS.trayMode,
|
||||
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
|
||||
onSelect: ()=> {
|
||||
if(!DEVICE.isTablet) {
|
||||
this.toggleTrayMode();
|
||||
return;
|
||||
}
|
||||
if(this.plugin.settings.defaultTrayMode) {
|
||||
this.toggleCompactMode();
|
||||
return;
|
||||
}
|
||||
this.toggleTrayMode(false);
|
||||
const uiModes = new UIModeSettings(this.plugin);
|
||||
uiModes.open();
|
||||
},
|
||||
},
|
||||
t("TRAY_TRAY_MODE")
|
||||
@@ -5477,20 +5576,34 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
private scheduleBatchedResize(currentDeltaHeight: number) {
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if(!api || !api.isTouchScreen) return;
|
||||
if (!api || !api.isTouchScreen) return;
|
||||
|
||||
if (!this.resizeBatchTimer) {
|
||||
this.lastAggregatedDh = 0;
|
||||
}
|
||||
this.resizeBatchWindowStart = Date.now();
|
||||
}
|
||||
|
||||
this.lastAggregatedDh += currentDeltaHeight;
|
||||
|
||||
if (this.resizeBatchTimer) window.clearTimeout(this.resizeBatchTimer);
|
||||
|
||||
const elapsed = Date.now() - this.resizeBatchWindowStart;
|
||||
const absoluteDelta = Math.abs(this.lastAggregatedDh);
|
||||
const deltaExceeded = absoluteDelta >= 80; // lower threshold to catch multi-step keyboards
|
||||
const windowExceeded = elapsed > 2000; // hard stop if the keyboard resizes in many tiny steps
|
||||
const debounceDelay = deltaExceeded ? 60 : 200; // short delay once we see large movement
|
||||
const finalDelay = windowExceeded ? 0 : debounceDelay;
|
||||
|
||||
this.resizeBatchTimer = window.setTimeout(() => {
|
||||
const dh = this.lastAggregatedDh;
|
||||
this.resizeBatchTimer = null;
|
||||
this.lastAggregatedDh = 0;
|
||||
if (Math.abs(dh) > 120) {
|
||||
this.resizeBatchWindowStart = 0;
|
||||
|
||||
if (Math.abs(dh) > 60) { // slightly lower than previous 120 to react earlier
|
||||
this.onExcalidrawResize();
|
||||
}
|
||||
}, Math.abs(currentDeltaHeight) < 120 ? 700 : 20);
|
||||
}, finalDelay);
|
||||
}
|
||||
|
||||
private onExcalidrawResize() {
|
||||
@@ -5685,11 +5798,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
saveAsImage: false,
|
||||
saveToActiveFile: false,
|
||||
},
|
||||
desktopUIMode: this.plugin.settings.defaultTrayMode
|
||||
? "tray"
|
||||
: this.plugin.settings.compactModeOnDesktops
|
||||
? "compact"
|
||||
: "full",
|
||||
desktopUIMode: calculateUIModeValue(this.plugin.settings),
|
||||
//formFactor: DEVICE.isMobile ? "phone" : DEVICE.isTablet ? "tablet" : "desktop",
|
||||
},
|
||||
initState: initdata?.appState,
|
||||
@@ -5866,44 +5975,24 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
});
|
||||
}
|
||||
|
||||
public async toggleCompactMode() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleCompactMode, "ExcalidrawView.toggleCompactMode");
|
||||
|
||||
//just in case settings were updated via Obsidian sync
|
||||
const newCompactMode = !this.plugin.settings.compactModeOnTablets;
|
||||
await this.plugin.loadSettings();
|
||||
this.plugin.settings.compactModeOnTablets = newCompactMode;
|
||||
await this.plugin.saveSettings();
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
}
|
||||
|
||||
public async toggleTrayMode(compactMode?: boolean) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.toggleTrayMode");
|
||||
//just in case settings were updated via Obsidian sync
|
||||
const newTrayMode = !this.plugin.settings.defaultTrayMode;
|
||||
await this.plugin.loadSettings();
|
||||
this.plugin.settings.defaultTrayMode = newTrayMode;
|
||||
if(compactMode!==undefined) {
|
||||
this.plugin.settings.compactModeOnTablets = compactMode;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
if(!newTrayMode) {
|
||||
setDesktopUIMode(this.app, this.plugin.settings);
|
||||
}
|
||||
}
|
||||
|
||||
public setTrayMode(on: boolean) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleTrayMode, "ExcalidrawView.setTrayMode");
|
||||
public toggleEnableContextMenu() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.toggleEnableContextMenu, "ExcalidrawView.toggleEnableContextMenu");
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
api.setTrayModeEnabled(on);
|
||||
//setTimeout(()=>api.refreshEditorBreakpoints());
|
||||
if (!api) {
|
||||
return;
|
||||
}
|
||||
const disableContextMenu = api.getAppState().disableContextMenu;
|
||||
this.updateScene({appState: {disableContextMenu: !disableContextMenu}, captureUpdate: CaptureUpdateAction.NEVER});
|
||||
}
|
||||
|
||||
public setDesktopUIMode(mode: "full" | "compact" | "tray") {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setDesktopUIMode, "ExcalidrawView.setDesktopUIMode");
|
||||
public setUIMode(mode: UIMode) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setUIMode, "ExcalidrawView.setDesktopUIMode");
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if (mode === "phone") {
|
||||
return;
|
||||
}
|
||||
api.setDesktopUIMode(mode);
|
||||
api.setTrayModeEnabled(mode === "tray");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -6039,110 +6128,19 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param prefix - defines the default button.
|
||||
* @returns
|
||||
*
|
||||
* @param prefix - defines the default button.
|
||||
* @returns
|
||||
*/
|
||||
public async copyLinkToSelectedElementToClipboard(prefix:string) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.copyLinkToSelectedElementToClipboard, "ExcalidrawView.copyLinkToSelectedElementToClipboard", prefix);
|
||||
const elements = this.getViewSelectedElements();
|
||||
if (elements.length < 1) {
|
||||
new Notice(t("INSERT_LINK_TO_ELEMENT_ERROR"));
|
||||
return;
|
||||
}
|
||||
|
||||
let elementId:string = undefined;
|
||||
|
||||
if(elements.length === 2) {
|
||||
const textEl = elements.filter(el=>el.type==="text");
|
||||
if(textEl.length===1 && (textEl[0] as ExcalidrawTextElement).containerId) {
|
||||
const container = elements.filter(el=>el.boundElements && el.boundElements.some(be=>be.type==="text"))
|
||||
if(container.length===1) {
|
||||
elementId = textEl[0].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!elementId) {
|
||||
elementId = elements.length === 1
|
||||
? elements[0].id
|
||||
: this.plugin.ea.getLargestElement(elements).id;
|
||||
}
|
||||
|
||||
const frames = elements.filter(el=>el.type==="frame");
|
||||
const hasFrame = frames.length === 1;
|
||||
const hasMarkerFrame = hasFrame && frames[0].frameRole === "marker";
|
||||
const hasGroup = elements.some(el=>el.groupIds && el.groupIds.length>0);
|
||||
|
||||
let button = {
|
||||
area: {caption: "Area", action:()=>{prefix="area="; return;}},
|
||||
link: {caption: "Link", action:()=>{prefix="";return}},
|
||||
group: {caption: "Group", action:()=>{prefix="group="; return;}},
|
||||
frame: {caption: "Frame", action:()=>{prefix="frame="; elementId = frames[0].id; return;}},
|
||||
clippedframe: {caption: "Clipped Frame", action:()=>{prefix="clippedframe="; ; elementId = frames[0].id; return;}},
|
||||
}
|
||||
|
||||
let buttons = [];
|
||||
switch(prefix) {
|
||||
case "area=":
|
||||
buttons = [
|
||||
button.area,
|
||||
button.link,
|
||||
...hasGroup ? [button.group] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
];
|
||||
break;
|
||||
case "group=":
|
||||
buttons = [
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
];
|
||||
break;
|
||||
case "frame=":
|
||||
buttons = [
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
];
|
||||
break;
|
||||
case "clippedframe=":
|
||||
buttons = [
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
buttons = [
|
||||
{caption: "Link", action:()=>{prefix="";return}},
|
||||
{caption: "Area", action:()=>{prefix="area="; return;}},
|
||||
{caption: "Group", action:()=>{prefix="group="; return;}},
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
]
|
||||
}
|
||||
|
||||
const alias = await ScriptEngine.inputPrompt(
|
||||
this,
|
||||
this.plugin,
|
||||
this.app,
|
||||
"Set link alias",
|
||||
"Leave empty if you do not want to set an alias",
|
||||
"",
|
||||
buttons,
|
||||
);
|
||||
navigator.clipboard.writeText(
|
||||
`${prefix.length>0?"!":""}[[${this.file.path}#^${prefix}${elementId}${alias ? `|${alias}` : ``}]]`,
|
||||
);
|
||||
new Notice(t("INSERT_LINK_TO_ELEMENT_READY"));
|
||||
public copyLinkToSelectedElementToClipboard(prefix: string) {
|
||||
(process.env.NODE_ENV === "development") &&
|
||||
DEBUGGING &&
|
||||
debug(
|
||||
this.copyLinkToSelectedElementToClipboard,
|
||||
"ExcalidrawView.copyLinkToSelectedElementToClipboard",
|
||||
prefix,
|
||||
);
|
||||
copyLinkToSelectedElementToClipboard(this, prefix);
|
||||
}
|
||||
|
||||
public updateScene(
|
||||
@@ -6215,10 +6213,15 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
}
|
||||
|
||||
public updateEmbeddableRef(id: string, ref: HTMLIFrameElement | HTMLWebViewElement | null) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.updateEmbeddableRef, "ExcalidrawView.updateEmbeddableRef", id, ref);
|
||||
public updateEmbeddableRef(
|
||||
elementId: string,
|
||||
ref: HTMLIFrameElement | HTMLWebViewElement | null,
|
||||
) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.updateEmbeddableRef, "ExcalidrawView.updateEmbeddableRef", elementId, ref);
|
||||
if (ref) {
|
||||
this.embeddableRefs.set(id, ref);
|
||||
this.embeddableRefs.set(elementId, ref);
|
||||
} else {
|
||||
this.embeddableRefs.delete(elementId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6227,10 +6230,15 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
return this.embeddableRefs.get(id);
|
||||
}
|
||||
|
||||
public updateEmbeddableLeafRef(id: string, ref: any) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.updateEmbeddableLeafRef, "ExcalidrawView.updateEmbeddableLeafRef", id, ref);
|
||||
public updateEmbeddableLeafRef(
|
||||
elementId: string,
|
||||
ref?: any
|
||||
) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.updateEmbeddableLeafRef, "ExcalidrawView.updateEmbeddableLeafRef", elementId, ref);
|
||||
if(ref) {
|
||||
this.embeddableLeafRefs.set(id, ref);
|
||||
this.embeddableLeafRefs.set(elementId, ref);
|
||||
} else {
|
||||
this.embeddableLeafRefs.delete(elementId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6273,4 +6281,4 @@ export function getTextMode(data: string): TextMode {
|
||||
data.search("excalidraw-plugin: parsed\n") > -1 ||
|
||||
data.search("excalidraw-plugin: locked\n") > -1; //locked for backward compatibility
|
||||
return parsed ? TextMode.parsed : TextMode.raw;
|
||||
}
|
||||
}
|
||||
@@ -542,6 +542,8 @@ function RenderObsidianView(
|
||||
try { mobilePatchCleanupRef.current?.(); } catch {}
|
||||
mobilePatchCleanupRef.current = null;
|
||||
|
||||
view.updateEmbeddableLeafRef(element.id);
|
||||
|
||||
if(!leafRef.current) {
|
||||
return;
|
||||
}
|
||||
@@ -549,7 +551,7 @@ function RenderObsidianView(
|
||||
leafRef.current.leaf?.detach();
|
||||
leafRef.current = null;
|
||||
}; //cleanup on unmount
|
||||
}, [linkText, subpath, containerRef]);
|
||||
}, [linkText, subpath, containerRef, element.id, file.path]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//Set colors of the canvas node
|
||||
|
||||
@@ -19,6 +19,7 @@ import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFile
|
||||
import { DEBUGGING, debug } from "src/utils/debugHelper";
|
||||
import { REM_VALUE } from "src/core/managers/StylesManager";
|
||||
import { getExcalidrawViews } from "src/utils/obsidianUtils";
|
||||
import { UIModeSettings } from "src/shared/Dialogs/UIModeSettings";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -56,7 +57,9 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
onRightEdge: boolean = false;
|
||||
onBottomEdge: boolean = false;
|
||||
public containerRef: React.RefObject<HTMLDivElement>;
|
||||
private view: ExcalidrawView;
|
||||
private getView(): ExcalidrawView | null {
|
||||
return this.props.view?.deref() ?? null;
|
||||
}
|
||||
|
||||
componentWillUnmount(): void {
|
||||
if (this.containerRef.current) {
|
||||
@@ -64,14 +67,11 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
this.setState({ scriptIconMap: null });
|
||||
this.containerRef = null;
|
||||
this.view = null;
|
||||
}
|
||||
|
||||
constructor(props: PanelProps) {
|
||||
super(props);
|
||||
this.view = props.view.deref();
|
||||
const react = this.view.packages.react;
|
||||
|
||||
const react = this.getView()?.packages.react;
|
||||
this.containerRef = react.createRef();
|
||||
this.state = {
|
||||
visible: props.visible,
|
||||
@@ -208,83 +208,103 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
actionOpenScriptInstallDialog() {
|
||||
new ScriptInstallPrompt(this.view.plugin).open();
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
new ScriptInstallPrompt(view.plugin).open()
|
||||
}
|
||||
|
||||
actionOpenReleaseNotes() {
|
||||
new ReleaseNotes(
|
||||
this.view.app,
|
||||
this.view.plugin,
|
||||
PLUGIN_VERSION,
|
||||
).open();
|
||||
const view = this.getView();
|
||||
if (!view) return
|
||||
new ReleaseNotes(view.app, view.plugin, PLUGIN_VERSION).open();
|
||||
}
|
||||
|
||||
actionConvertExcalidrawToMD() {
|
||||
this.view.convertExcalidrawToMD();
|
||||
this.getView()?.convertExcalidrawToMD();
|
||||
}
|
||||
|
||||
actionToggleViewMode() {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
if (this.state.isPreviewMode) {
|
||||
this.view.changeTextMode(TextMode.raw);
|
||||
view.changeTextMode(TextMode.raw);
|
||||
} else {
|
||||
this.view.changeTextMode(TextMode.parsed);
|
||||
view.changeTextMode(TextMode.parsed);
|
||||
}
|
||||
}
|
||||
|
||||
actionToggleTrayMode() {
|
||||
this.view.toggleTrayMode();
|
||||
const plugin = this.getView()?.plugin;
|
||||
if (!plugin) return;
|
||||
new UIModeSettings(plugin).open();
|
||||
}
|
||||
|
||||
actionToggleFullscreen() {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
if (this.state.isFullscreen) {
|
||||
this.view.exitFullscreen();
|
||||
view.exitFullscreen();
|
||||
} else {
|
||||
this.view.gotoFullscreen();
|
||||
view.gotoFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
actionSearch() {
|
||||
search(this.view);
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
search(view);
|
||||
}
|
||||
|
||||
actionOCR(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
if(!this.view.plugin.settings.taskboneEnabled) {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
if(!plugin.settings.taskboneEnabled) {
|
||||
new Notice("Taskbone OCR is not enabled. Please go to plugins settings to enable it.",4000);
|
||||
return;
|
||||
}
|
||||
this.view.plugin.taskbone.getTextForView(this.view, {forceReScan: isWinCTRLorMacCMD(e)});
|
||||
plugin.taskbone.getTextForView(view, {forceReScan: isWinCTRLorMacCMD(e)});
|
||||
}
|
||||
|
||||
actionOpenLink(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
const event = new MouseEvent("click", {
|
||||
ctrlKey: e.ctrlKey || !(DEVICE.isIOS || DEVICE.isMacOS),
|
||||
metaKey: e.metaKey || (DEVICE.isIOS || DEVICE.isMacOS),
|
||||
shiftKey: e.shiftKey,
|
||||
altKey: e.altKey,
|
||||
});
|
||||
this.view.handleLinkClick(event, true);
|
||||
view.handleLinkClick(event, true);
|
||||
}
|
||||
|
||||
actionOpenLinkProperties() {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
const event = new MouseEvent("click", {
|
||||
ctrlKey: true,
|
||||
metaKey: true,
|
||||
shiftKey: false,
|
||||
altKey: false,
|
||||
});
|
||||
this.view.handleLinkClick(event);
|
||||
view.handleLinkClick(event);
|
||||
}
|
||||
|
||||
actionForceSave() {
|
||||
this.view.forceSave();
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
view.forceSave();
|
||||
}
|
||||
|
||||
actionExportLibrary() {
|
||||
this.view.plugin.exportLibrary();
|
||||
const plugin = this.getView()?.plugin;
|
||||
if (!plugin) return;
|
||||
plugin.exportLibrary();
|
||||
}
|
||||
|
||||
actionExportImage() {
|
||||
const view = this.view;
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
if(!view.exportDialog) {
|
||||
view.exportDialog = new ExportDialog(view.plugin, view,view.file);
|
||||
view.exportDialog.createForm();
|
||||
@@ -293,69 +313,91 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
actionOpenAsMarkdown() {
|
||||
this.view.openAsMarkdown();
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
view.openAsMarkdown();
|
||||
}
|
||||
|
||||
actionLinkToElement(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
if(isWinALTorMacOPT(e)) {
|
||||
openExternalLink("https://youtu.be/yZQoJg2RCKI", this.view.app);
|
||||
openExternalLink("https://youtu.be/yZQoJg2RCKI", view.app);
|
||||
return;
|
||||
}
|
||||
this.view.copyLinkToSelectedElementToClipboard(
|
||||
view.copyLinkToSelectedElementToClipboard(
|
||||
isWinCTRLorMacCMD(e) ? "group=" : (isSHIFT(e) ? "area=" : "")
|
||||
);
|
||||
}
|
||||
|
||||
actionAddAnyFile() {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
this.props.centerPointer();
|
||||
const insertFileModal = new UniversalInsertFileModal(this.view.plugin, this.view);
|
||||
const insertFileModal = new UniversalInsertFileModal(plugin, view);
|
||||
insertFileModal.open();
|
||||
}
|
||||
|
||||
actionInsertImage() {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
this.props.centerPointer();
|
||||
this.view.plugin.insertImageDialog.start(
|
||||
this.view,
|
||||
);
|
||||
plugin.insertImageDialog.start(view);
|
||||
}
|
||||
|
||||
actionInsertPDF() {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
this.props.centerPointer();
|
||||
const insertPDFModal = new InsertPDFModal(this.view.plugin, this.view);
|
||||
const insertPDFModal = new InsertPDFModal(plugin, view);
|
||||
insertPDFModal.open();
|
||||
}
|
||||
|
||||
actionInsertMarkdown() {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
this.props.centerPointer();
|
||||
this.view.plugin.insertMDDialog.start(
|
||||
this.view,
|
||||
);
|
||||
plugin.insertMDDialog.start(view);
|
||||
}
|
||||
|
||||
actionInsertBackOfNote() {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
this.props.centerPointer();
|
||||
this.view.insertBackOfTheNoteCard();
|
||||
view.insertBackOfTheNoteCard();
|
||||
}
|
||||
|
||||
actionInsertLaTeX(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
if(isWinALTorMacOPT(e)) {
|
||||
openExternalLink("https://youtu.be/r08wk-58DPk", this.view.app);
|
||||
openExternalLink("https://youtu.be/r08wk-58DPk", view.app);
|
||||
return;
|
||||
}
|
||||
this.props.centerPointer();
|
||||
insertLaTeXToView(this.view);
|
||||
insertLaTeXToView(view);
|
||||
}
|
||||
|
||||
actionInsertLink() {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
this.props.centerPointer();
|
||||
this.view.plugin.insertLinkDialog.start(
|
||||
this.view.file.path,
|
||||
(text: string, fontFamily?: 1 | 2 | 3 | 4, save?: boolean) => this.view.addText (text, fontFamily, save),
|
||||
plugin.insertLinkDialog.start(
|
||||
view.file.path,
|
||||
(text: string, fontFamily?: 1 | 2 | 3 | 4, save?: boolean) => view.addText (text, fontFamily, save),
|
||||
);
|
||||
}
|
||||
|
||||
actionImportSVG(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
this.view.plugin.importSVGDialog.start(this.view);
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
plugin.importSVGDialog.start(view);
|
||||
}
|
||||
|
||||
actionCropImage(e:React.MouseEvent<HTMLButtonElement, MouseEvent>) {
|
||||
@@ -364,8 +406,9 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
async actionRunScript(key: string) {
|
||||
const view = this.view;
|
||||
const plugin = view.plugin;
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
const f = plugin.app.vault.getAbstractFileByPath(key);
|
||||
if (f && f instanceof TFile) {
|
||||
plugin.scriptEngine.executeScript(
|
||||
@@ -378,9 +421,10 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
async actionPinScript(key: string, scriptName: string) {
|
||||
const view = this.view;
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return;
|
||||
const api = view.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
const plugin = view.plugin;
|
||||
await plugin.loadSettings();
|
||||
const index = plugin.settings.pinnedScripts.indexOf(key)
|
||||
if(index > -1) {
|
||||
@@ -410,27 +454,30 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
private islandOnPointerDown(event: React.PointerEvent) {
|
||||
const onDrag = (e: PointerEvent) => {
|
||||
e.preventDefault();
|
||||
this.pos1 = this.pos3 - e.clientX;
|
||||
this.pos2 = this.pos4 - e.clientY;
|
||||
this.pos3 = e.clientX;
|
||||
this.pos4 = e.clientY;
|
||||
this.updatePosition(this.pos2, this.pos1);
|
||||
};
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
|
||||
const onPointerUp = () => {
|
||||
this.view.ownerDocument?.removeEventListener("pointerup", onPointerUp);
|
||||
this.view.ownerDocument?.removeEventListener("pointermove", onDrag);
|
||||
};
|
||||
|
||||
event.preventDefault();
|
||||
this.penDownX = this.pos3 = event.clientX;
|
||||
this.penDownY = this.pos4 = event.clientY;
|
||||
this.view.ownerDocument.addEventListener("pointerup", onPointerUp);
|
||||
this.view.ownerDocument.addEventListener("pointermove", onDrag);
|
||||
const onDrag = (e: PointerEvent) => {
|
||||
e.preventDefault();
|
||||
this.pos1 = this.pos3 - e.clientX;
|
||||
this.pos2 = this.pos4 - e.clientY;
|
||||
this.pos3 = e.clientX;
|
||||
this.pos4 = e.clientY;
|
||||
this.updatePosition(this.pos2, this.pos1);
|
||||
};
|
||||
|
||||
const onPointerUp = () => {
|
||||
view.ownerDocument?.removeEventListener("pointerup", onPointerUp);
|
||||
view.ownerDocument?.removeEventListener("pointermove", onDrag);
|
||||
};
|
||||
|
||||
event.preventDefault();
|
||||
this.penDownX = this.pos3 = event.clientX;
|
||||
this.penDownY = this.pos4 = event.clientY;
|
||||
view.ownerDocument.addEventListener("pointerup", onPointerUp);
|
||||
view.ownerDocument.addEventListener("pointermove", onDrag);
|
||||
};
|
||||
|
||||
render() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.render,"ToolsPanel.render()");
|
||||
return (
|
||||
@@ -530,8 +577,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
/>
|
||||
)}
|
||||
<ActionButton
|
||||
key={"tray-mode"}
|
||||
title={t("TRAY_MODE")}
|
||||
key={"ui-mode"}
|
||||
title={t("UI_MODE")}
|
||||
action={this.actionToggleTrayMode.bind(this)}
|
||||
icon={ICONS.trayMode}
|
||||
/>
|
||||
@@ -686,11 +733,16 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(!this.view.plugin._loaded) {
|
||||
const view = this.getView();
|
||||
const plugin = view?.plugin;
|
||||
if (!view || !plugin) return null;
|
||||
|
||||
|
||||
if(!plugin._loaded) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const downloadedScriptsRoot = `${this.view.plugin.settings.scriptFolderPath}/${SCRIPT_INSTALL_FOLDER}/`;
|
||||
const downloadedScriptsRoot = `${plugin.settings.scriptFolderPath}/${SCRIPT_INSTALL_FOLDER}/`;
|
||||
|
||||
const filterCondition = (key: string): boolean =>
|
||||
isDownloaded
|
||||
|
||||
+25
@@ -714,6 +714,13 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
margin-bottom: -2px;
|
||||
}
|
||||
|
||||
.is-mobile .modal-container.excalidraw-modal .modal.excalidraw-modal {
|
||||
align-self: flex-start;
|
||||
transform: none !important;
|
||||
margin-top: calc(var(--safe-area-inset-top) + var(--header-height) + var(--size-4-2));
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.excalidraw .picker-content {
|
||||
grid-gap: 0.2rem !important;
|
||||
}
|
||||
@@ -892,6 +899,7 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.excalidraw .excalidraw-ui-top-right.library-and-pen,
|
||||
.ExcalidrawObsidianMenu--mobile {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@@ -901,6 +909,10 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.excalidraw .excalidraw-ui-top-right.library-and-pen .ToolIcon__penMode {
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.ExcalidrawObsidianMenu {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@@ -908,4 +920,17 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
|
||||
.excalidraw .FixedSideContainer_side_top {
|
||||
padding-top: 0 !important;
|
||||
|
||||
}
|
||||
|
||||
.excalidraw .ToolIcon.ToolIcon__penMode {
|
||||
height:fit-content
|
||||
}
|
||||
|
||||
.excalidraw-LatexPrompt .cm-content {
|
||||
caret-color: var(--caret-color);
|
||||
}
|
||||
|
||||
.excalidraw-LatexPrompt .cm-editor {
|
||||
margin-top: 90px;
|
||||
}
|
||||
Reference in new issue
Block a user