mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
45
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8df45aed14 | ||
|
|
2e9b5ce593 | ||
|
|
ed9fe5f3d4 | ||
|
|
57afd6f134 | ||
|
|
63e0c1368f | ||
|
|
3b2f7d2c98 | ||
|
|
684d19eebd | ||
|
|
d65e967e4b | ||
|
|
59fe5abfa8 | ||
|
|
919913044d | ||
|
|
306e6db564 | ||
|
|
c32d0cb350 | ||
|
|
a43e527602 | ||
|
|
2e48ee8484 | ||
|
|
d568003915 | ||
|
|
247685b13f | ||
|
|
73c20e0d9d | ||
|
|
222ff139d8 | ||
|
|
0e0774d973 | ||
|
|
ae722623e5 | ||
|
|
65ab00a932 | ||
|
|
418063e9b6 | ||
|
|
b2f051e088 | ||
|
|
c884db0840 | ||
|
|
e4d1b509f7 | ||
|
|
97da7c680f | ||
|
|
5696a33e60 | ||
|
|
b68e8c0b20 | ||
|
|
3a43571f3e | ||
|
|
65c3a11fba | ||
|
|
010fd5c624 | ||
|
|
8ddf03cdd3 | ||
|
|
a5fd91a33c | ||
|
|
d8de0db423 | ||
|
|
b5d9fa4625 | ||
|
|
fcc0f94974 | ||
|
|
6b7d8c8b69 | ||
|
|
259e6277ed | ||
|
|
88405af417 | ||
|
|
8fecb75f97 | ||
|
|
bd1b13b58c | ||
|
|
d8cac4eacd | ||
|
|
8379f9315e | ||
|
|
123fa12122 | ||
|
|
46a41feaf3 |
No files matched your search
@@ -38,7 +38,8 @@
|
||||
* you may access this object via the variable `ea`. e.g. ea.addImage(); This ea object is already set to the targetView.
|
||||
* Through ea.obsidian all of the Obsidian API is available to the script. Thus you can create modal views, open files, etc.
|
||||
* You can access Obsidian type definitions here: https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts
|
||||
* In addition to the ea object, the script also receives the `utils` object. utils includes to utility functions: suggester and inputPrompt
|
||||
* In addition to the ea instance, the script also receives the `utils` object. utils includes to utility functions: suggester and inputPrompt.
|
||||
* You may access these via the variable `utils`. e.g. utils.suggester(...);
|
||||
* - inputPrompt(inputPrompt: (
|
||||
* header: string,
|
||||
* placeholder?: string,
|
||||
@@ -2270,7 +2271,6 @@ export interface AppState {
|
||||
};
|
||||
showHyperlinkPopup: false | "info" | "editor";
|
||||
linkOpacity: number;
|
||||
trayModeEnabled: boolean;
|
||||
colorPalette?: {
|
||||
canvasBackground: ColorPaletteCustom;
|
||||
elementBackground: ColorPaletteCustom;
|
||||
@@ -2283,6 +2283,7 @@ export interface AppState {
|
||||
};
|
||||
allowWheelZoom?: boolean;
|
||||
allowPinchZoom?: boolean;
|
||||
disableContextMenu: boolean;
|
||||
pinnedScripts?: string[];
|
||||
customPens?: any[];
|
||||
currentStrokeOptions?: any;
|
||||
@@ -2329,8 +2330,6 @@ export interface AppState {
|
||||
lockedMultiSelections: {
|
||||
[groupId: string]: true;
|
||||
};
|
||||
/** properties sidebar mode - determines whether to show compact or complete sidebar */
|
||||
stylesPanelMode: "compact" | "full" | "mobile" | "tray";
|
||||
}
|
||||
export type SearchMatch = {
|
||||
id: string;
|
||||
@@ -2495,6 +2494,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 +2530,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"];
|
||||
@@ -2629,7 +2634,11 @@ 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"];
|
||||
isTrayModeEnabled: InstanceType<typeof App>["isTrayModeEnabled"];
|
||||
getColorAtScenePoint: InstanceType<typeof App>["getColorAtScenePoint"];
|
||||
startLineEditor: InstanceType<typeof App>["startLineEditor"];
|
||||
getSceneElements: InstanceType<typeof App>["getSceneElements"];
|
||||
@@ -2648,12 +2657,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
|
||||
@@ -2667,17 +2676,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;
|
||||
}>;
|
||||
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
@@ -3011,7 +3011,7 @@ Fix:
|
||||
- Transcluded text will now exclude ^block-references at end of lines
|
||||
- Phantom duplicates of the drawing appear when "zoom to fit" results in a zoom value below 10% and there are many objects on the canvas [#850](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/850)
|
||||
- CTRL+Wheel will increase/decrease zoom in steps of 5% matching the behavior of the "+" & "-" zoom buttons.
|
||||
- Latest updates from Excalidarw.com
|
||||
- Latest updates from Excalidraw.com
|
||||
- Freedraw flip not scaling correctly [#5752](https://github.com/excalidraw/excalidraw/pull/5752)
|
||||
- Multiple elements resizing regressions [#5586](https://github.com/excalidraw/excalidraw/pull/5586)
|
||||
|
||||
@@ -4339,7 +4339,7 @@ Fixed:
|
||||
|
||||
# 1.5.8
|
||||
|
||||
- minor fix to ExcalidarwAutomate addText to handle non-container bound text wrapping correctly.
|
||||
- minor fix to ExcalidrawAutomate addText to handle non-container bound text wrapping correctly.
|
||||
|
||||
# 1.5.7
|
||||
|
||||
|
||||
@@ -3011,7 +3011,7 @@ Fix:
|
||||
- Transcluded text will now exclude ^block-references at end of lines
|
||||
- Phantom duplicates of the drawing appear when "zoom to fit" results in a zoom value below 10% and there are many objects on the canvas [#850](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/850)
|
||||
- CTRL+Wheel will increase/decrease zoom in steps of 5% matching the behavior of the "+" & "-" zoom buttons.
|
||||
- Latest updates from Excalidarw.com
|
||||
- Latest updates from Excalidraw.com
|
||||
- Freedraw flip not scaling correctly [#5752](https://github.com/excalidraw/excalidraw/pull/5752)
|
||||
- Multiple elements resizing regressions [#5586](https://github.com/excalidraw/excalidraw/pull/5586)
|
||||
|
||||
@@ -4339,7 +4339,7 @@ Fixed:
|
||||
|
||||
# 1.5.8
|
||||
|
||||
- minor fix to ExcalidarwAutomate addText to handle non-container bound text wrapping correctly.
|
||||
- minor fix to ExcalidrawAutomate addText to handle non-container bound text wrapping correctly.
|
||||
|
||||
# 1.5.7
|
||||
|
||||
|
||||
+34
-23
@@ -47,6 +47,7 @@ async function run() {
|
||||
// Initialize state
|
||||
let uiHidden = true;
|
||||
let currentIcon = "eye";
|
||||
let layerUIWrapper = ea.targetView.contentEl.querySelector(".excalidraw.excalidraw-container > .layer-ui__wrapper");
|
||||
const toolbar = ea.targetView.contentEl.querySelector(".excalidraw > .Island");
|
||||
let toolbarActive = toolbar?.style.display === "block";
|
||||
let prevHiddenState = false;
|
||||
@@ -55,30 +56,40 @@ async function run() {
|
||||
const toggleUIVisibility = (hidden) => {
|
||||
if(hidden === prevHiddenState) return hidden;
|
||||
prevHiddenState = hidden;
|
||||
try{
|
||||
const topBar = ea.targetView.containerEl.querySelector(".App-top-bar");
|
||||
const bottomBar = ea.targetView.containerEl.querySelector(".App-bottom-bar");
|
||||
const sidebarToggle = ea.targetView.containerEl.querySelector(".sidebar-toggle");
|
||||
const plugins = ea.targetView.containerEl.querySelector(".plugins-container");
|
||||
|
||||
if(hidden) {
|
||||
if (toolbarActive && (toolbar?.style.display === "none")) {
|
||||
toolbarActive = false;
|
||||
if (!!layerUIWrapper) {
|
||||
try {
|
||||
if(hidden) {
|
||||
layerUIWrapper.style.display = "none";
|
||||
} else {
|
||||
layerUIWrapper.style.display = "block";
|
||||
}
|
||||
} catch {};
|
||||
} else {
|
||||
try{
|
||||
const topBar = ea.targetView.containerEl.querySelector(".App-top-bar");
|
||||
const bottomBar = ea.targetView.containerEl.querySelector(".App-bottom-bar");
|
||||
const sidebarToggle = ea.targetView.containerEl.querySelector(".sidebar-toggle");
|
||||
const plugins = ea.targetView.containerEl.querySelector(".plugins-container");
|
||||
|
||||
if(hidden) {
|
||||
if (toolbarActive && (toolbar?.style.display === "none")) {
|
||||
toolbarActive = false;
|
||||
}
|
||||
if (toolbarActive = toolbar?.style.display === "block") {
|
||||
toolbarActive = true;
|
||||
};
|
||||
}
|
||||
if (toolbarActive = toolbar?.style.display === "block") {
|
||||
toolbarActive = true;
|
||||
};
|
||||
}
|
||||
|
||||
const display = hidden ? "none" : "";
|
||||
|
||||
if (topBar) topBar.style.display = display;
|
||||
if (bottomBar) bottomBar.style.display = display;
|
||||
if (sidebarToggle) sidebarToggle.style.display = display;
|
||||
if (plugins) plugins.style.display = display;
|
||||
if (toolbarActive) toolbar.style.display = hidden ? "none" : "block";
|
||||
modal.modalEl.style.opacity = hidden ? "0.4" : "0.8";
|
||||
} catch {};
|
||||
|
||||
const display = hidden ? "none" : "";
|
||||
|
||||
if (topBar) topBar.style.display = display;
|
||||
if (bottomBar) bottomBar.style.display = display;
|
||||
if (sidebarToggle) sidebarToggle.style.display = display;
|
||||
if (plugins) plugins.style.display = display;
|
||||
if (toolbarActive) toolbar.style.display = hidden ? "none" : "block";
|
||||
modal.modalEl.style.opacity = hidden ? "0.4" : "0.8";
|
||||
} catch {};
|
||||
};
|
||||
return hidden;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.17.0-beta-1",
|
||||
"version": "2.18.0-beta-2",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.16.1",
|
||||
"version": "2.17.2",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
Generated
+4
-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-51",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -3484,9 +3484,9 @@
|
||||
"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-51",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-51.tgz",
|
||||
"integrity": "sha512-LScnN0iCQmJ8bkP+1AiGsUfhV9yZGOEyrQDzgRVnloWmrtA5Z/7G0ZKvQ1BspGH5T1Sa7h1SgWdrQ41luNj4Xw==",
|
||||
"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-42",
|
||||
"@zsviczian/excalidraw": "0.18.0-55",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
@@ -17,9 +17,163 @@ Excalidraw-Obsidian is an Obsidian.md plugins that is built on the open source E
|
||||
|
||||
Read the information below and respond with I'm ready. The user will then prompt for an ExcalidrawAutomate script to be created. Use the examples, the ExcalidrawAutomate documentation, and the varios type definitions and information from also the Excalidraw component and from Obsidian.md to generate the script based on the user's requirements.
|
||||
|
||||
When the user asks for a dialog window, by default create a FloatingModal.
|
||||
In addition to ExcalidrawAutomate, you can also use two other sources of functions:
|
||||
- The Excalidraw API available via ea.getExcalidrawAPI(). Note: the API is only available if ea.targetView is set. When running Excalidraw scripts using the script engine, the provided ea object is already set up with targetView by default. Otherwise you need to first run ea.setView().
|
||||
- window.ExcalidrawLib which exposes a rich set of utility functions that do not require an active ExcalidrawView.
|
||||
|
||||
The Obsidian.md module is available on ea.obsidian.
|
||||
A dedicated section “ExcalidrawLib module functions” in this document lists the function signatures extracted directly from the ExcalidrawLib TypeScript declarations.
|
||||
|
||||
- When the user asks for a dialog window, by default create a FloatingModal. Do not extend the FloatingModal class. Instead, define the modal's behavior by creating a new instance (e.g., const modal = new ea.FloatingModal(...)) and then assigning functions directly to the onOpen and onClose properties of that instance.
|
||||
For a reference, follow the implementation pattern used in the "Printable Layout Wizard.md" script.
|
||||
- Elements have a customData property that can be used to store arbitrary data. To ensure the data the script adds to elements use the ea.addAppendUpdateCustomData function. This function ensures that existing customData is preserved when adding new data.
|
||||
- Elements can be hidden by setting their opacity to 0. When hiding elements this way, it is good practice to temporarily store their original opacity in customData. This allows for easy restoration of the original opacity later.
|
||||
- Elements can be deleted from the scene by setting their isDeleted property to true.
|
||||
- The Obsidian.md module is available on ea.obsidian.
|
||||
|
||||
#### **1. The Core Workflow: Handling Element Immutability**
|
||||
|
||||
* **Central Rule:** Elements in the Excalidraw scene are immutable and should never be modified directly. Always use the ExcalidrawAutomate (EA) "workbench" pattern for modifications.
|
||||
* **The Workflow:**
|
||||
1. Get elements from the current view using \`ea.getViewElements()\` or \`ea.getViewSelectedElements()\`.
|
||||
2. Copy these elements into the EA workbench for editing using \`ea.copyViewElementsToEAforEditing(elements)\`.
|
||||
3. Modify the properties of the element copies that are now in the EA workbench (e.g., \`ea.getElement(id).locked = true;\`).
|
||||
4. Commit the changes back to the scene using \`await ea.addElementsToView()\`.
|
||||
* **Deletion:** To delete an element, set its \`isDeleted\` property to \`true\` on the workbench copy (\`ea.getElement(id).isDeleted = true;\`) and then commit with \`await ea.addElementsToView()\`.
|
||||
* **Cleanup:** Use \`ea.clear()\` at the beginning of a script if you are creating a completely new set of elements, to ensure the EA workbench is empty and doesn't contain artifacts from a previous run.
|
||||
|
||||
#### **2. User Interaction: Prompts and Dialogs**
|
||||
|
||||
* **Simple Input:** For straightforward user input, use the \`utils\` object provided to the script.
|
||||
* \`await utils.inputPrompt()\`: To get a string or number from the user.
|
||||
* \`await utils.suggester()\`: To let the user select from a predefined list of options.
|
||||
* **Complex Dialogs:** When a more complex UI with multiple controls is needed, create a floating dialog window.
|
||||
* **Use \`FloatingModal\`:** Always create a new instance: \`const modal = new ea.FloatingModal(ea.plugin.app);\`.
|
||||
* **Do Not Extend:** Do not use \`class MyModal extends ea.FloatingModal\`.
|
||||
* **Define Behavior:** Assign functions directly to the \`onOpen\` and \`onClose\` properties of the instance. Inside \`onOpen\`, use the \`modal.contentEl\` property to build your UI.
|
||||
* **Reference Implementation:** The script "Printable Layout Wizard.md" is the canonical example for this pattern. Use \`ea.obsidian.Setting\` to add controls like toggles and dropdowns within the modal.
|
||||
|
||||
#### **3. Element Manipulation and Querying**
|
||||
|
||||
* **Finding Elements:** The most common starting point is to get the user's selection with \`ea.getViewSelectedElements()\`. Use standard JavaScript array methods like \`.filter()\` to narrow down the selection (e.g., \`elements.filter(el => el.type === "text")\`).
|
||||
* **Geometric Calculations:**
|
||||
* Before performing layout or positioning tasks, use \`ea.getBoundingBox(elements)\` to get the collective dimensions and position of a group of elements.
|
||||
* Use \`ea.measureText(text)\` to determine the width and height of a string based on the current \`ea.style\` settings before creating a text element or a container for it.
|
||||
* **Grouping:**
|
||||
* To create a group, use \`ea.addToGroup([elementId1, elementId2, ...])\`.
|
||||
* To operate on existing groups within a selection, use \`ea.getMaximumGroups(selectedElements)\` which correctly identifies the top-level groups. Use \`ea.getLargestElement(group)\` to find the primary container within a group (e.g., the box around a text element).
|
||||
|
||||
#### **4. Styling: Creation vs. Modification**
|
||||
|
||||
* **For New Elements:** Set the properties on the global \`ea.style\` object *before* you call a creation function like \`ea.addText()\` or \`ea.addRect()\`. This acts like setting the active color/style on a paintbrush.
|
||||
* **For Existing Elements:** To change the style of an existing element, modify the properties directly on the element's copy in the EA workbench (after \`copyViewElementsToEAforEditing\`). For example: \`const myElement = ea.getElement(id); myElement.strokeColor = '#FF0000';\`.
|
||||
|
||||
#### **5. Data Persistence and Customization**
|
||||
|
||||
* **Storing Custom Data:** Elements have a \`customData\` property for arbitrary data.
|
||||
* **Always Use \`ea.addAppendUpdateCustomData(id, newData)\`:** This is crucial. It safely adds or updates your key-value pairs without overwriting data that might have been stored by other scripts or the Excalidraw plugin itself.
|
||||
* **Creating Configurable Scripts:** To make your script's behavior customizable by the user:
|
||||
* Use \`ea.getScriptSettings()\` to retrieve saved settings.
|
||||
* Check if settings exist, and if not, define the default structure.
|
||||
* Use \`await ea.setScriptSettings(settings)\` to save any changes. This allows users to configure your script in the Excalidraw plugin settings pane.
|
||||
|
||||
#### **6. Best Practices and Advanced Techniques**
|
||||
|
||||
* **Embrace \`await\`:** Many EA functions are asynchronous and return a \`Promise\` (e.g., \`ea.addElementsToView()\`, \`ea.createSVG()\`, \`utils.inputPrompt()\`). **Always** use \`await\` when calling these functions to ensure your script executes in the correct order.
|
||||
* **Version Checking:** At the beginning of your script, include a check like \`if(!ea.verifyMinimumPluginVersion("1.X.X")) { new Notice(...); return; }\` to ensure the user has a compatible version of the Excalidraw plugin, preventing errors from missing API functions.
|
||||
* **Accessing Obsidian API:** The full Obsidian API is available via \`ea.obsidian\`. For example, use \`new ea.obsidian.Notice("message")\` or \`ea.obsidian.normalizePath(filepath)\`.
|
||||
* **Visibility vs. Deletion:**
|
||||
* To temporarily hide an element, set \`element.opacity = 0\`. It's good practice to store the original opacity in \`customData\` so it can be restored. It is also recommended to lock hidden elements so they do not get accidentally selected or moved around.
|
||||
* To permanently remove an element from the scene, set \`element.isDeleted = true\`.
|
||||
* **Image Handling:** When dealing with image elements, use \`ea.getViewFileForImageElement(imageElement)\` to get the corresponding \`TFile\` from the Obsidian vault. This is necessary for any logic that needs to read or manipulate the source image file.
|
||||
|
||||
#### **7. Custom Pens and Perfect Freehand**
|
||||
|
||||
Excalidraw's freehand tool is powered by the open-source Perfect Freehand library. The plugin exposes “custom pens” that bundle:
|
||||
- Canvas style for the next strokes (colors, width, fillStyle, roughness).
|
||||
- Perfect Freehand stroke geometry and behavior (pressure simulation, outline, tapering, easing, etc.).
|
||||
|
||||
Key concepts:
|
||||
- AppState-driven drawing: When \`appState.currentStrokeOptions\` is set, the freedraw tool renders new strokes using those Perfect Freehand options.
|
||||
- Element-level persistence: If a freedraw element has \`element.customData.strokeOptions\`, it is rendered with those options regardless of the current tool state.
|
||||
- Types reference: See \`src/types/penTypes.ts\`. The \`PenOptions\` shape is:
|
||||
\`\`\`ts
|
||||
interface PenOptions {
|
||||
highlighter: boolean; // if true the pen is drawn at the lowest layer, behind all other elements
|
||||
constantPressure: boolean;
|
||||
hasOutline: boolean;
|
||||
outlineWidth: number;
|
||||
options: {
|
||||
thinning: number;
|
||||
smoothing: number;
|
||||
streamline: number;
|
||||
easing: string; // see supported names below
|
||||
start: { cap: boolean; taper: number | boolean; easing: string; };
|
||||
end: { cap: boolean; taper: number | boolean; easing: string; };
|
||||
};
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
Using custom pens from scripts:
|
||||
- Activate a custom pen for drawing:
|
||||
\`\`\`ts
|
||||
// obtain the Excalidraw API
|
||||
const api = ea.getExcalidrawAPI();
|
||||
|
||||
// define Perfect Freehand options (example similar to "finetip")
|
||||
const penOptions = {
|
||||
highlighter: false,
|
||||
constantPressure: true,
|
||||
hasOutline: false,
|
||||
outlineWidth: 1,
|
||||
options: {
|
||||
thinning: -0.5,
|
||||
smoothing: 0.4,
|
||||
streamline: 0.4,
|
||||
easing: "linear",
|
||||
start: { taper: 5, cap: false, easing: "linear" },
|
||||
end: { taper: 5, cap: false, easing: "linear" },
|
||||
},
|
||||
};
|
||||
|
||||
// apply stroke options + canvas style, then switch to freedraw (strokeWidth, color, background, fillStyle are optional)
|
||||
ea.viewUpdateScene({
|
||||
appState: {
|
||||
currentStrokeOptions: penOptions,
|
||||
currentItemStrokeWidth: 0.5,
|
||||
currentItemStrokeColor: "#3E6F8D",
|
||||
currentItemBackgroundColor: "transparent",
|
||||
currentItemFillStyle: "hachure",
|
||||
},
|
||||
});
|
||||
api.setActiveTool({ type: "freedraw" });
|
||||
\`\`\`
|
||||
|
||||
- Clear custom pen (revert to default freedraw behavior):
|
||||
\`\`\`ts
|
||||
ea.viewUpdateScene({ appState: { currentStrokeOptions: null } });
|
||||
\`\`\`
|
||||
|
||||
- Persist custom strokeOptions onto existing freedraw elements:
|
||||
\`\`\`ts
|
||||
const selected = ea.getViewSelectedElements().filter(el => el.type === "freedraw");
|
||||
ea.copyViewElementsToEAforEditing(selected);
|
||||
for (const el of selected) {
|
||||
ea.addAppendUpdateCustomData(el.id, { strokeOptions: penOptions });
|
||||
}
|
||||
await ea.addElementsToView();
|
||||
\`\`\`
|
||||
|
||||
Notes:
|
||||
- New strokes respect \`appState.currentStrokeOptions\` at draw time. Existing elements only change if you update their \`customData.strokeOptions\`.
|
||||
- For pens that should behave like real markers/highlighters, set \`highlighter: true\` and often \`constantPressure: true\` with an \`outlineWidth\` for the edge.
|
||||
|
||||
Supported easing names (string values for \`options.easing\`, \`options.start.easing\`, \`options.end.easing\`):
|
||||
linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, easeInQuint, easeOutQuint, easeInOutQuint, easeInSine, easeOutSine, easeInOutSine, easeInExpo, easeOutExpo, easeInOutExpo, easeInCirc, easeOutCirc, easeInOutCirc, easeInBack, easeOutBack, easeInOutBack, easeInElastic, easeOutElastic, easeInOutElastic, easeInBounce, easeOutBounce, easeInOutBounce.
|
||||
|
||||
Example freedraw element carrying \`customData.strokeOptions\`:
|
||||
\`\`\`json
|
||||
{"type":"excalidraw/clipboard","elements":[{"id":"...","type":"freedraw","strokeColor":"#3E6F8D","backgroundColor":"transparent","fillStyle":"hachure","strokeWidth":0.5,"roughness":0,"customData":{"strokeOptions":{"highlighter":false,"hasOutline":false,"outlineWidth":0,"constantPressure":true,"options":{"smoothing":0.4,"thinning":-0.5,"streamline":0.4,"easing":"linear","start":{"taper":5,"cap":false,"easing":"linear"},"end":{"taper":5,"cap":false,"easing":"linear"}}}}}],"files":{}}
|
||||
\`\`\`
|
||||
|
||||
`;
|
||||
|
||||
@@ -197,6 +351,143 @@ function buildAdditionalTypeDefsMarkdown() {
|
||||
return body;
|
||||
}
|
||||
|
||||
// NEW: Resolve module specifiers from types/excalidraw/index.d.ts to absolute .d.ts paths
|
||||
function resolveExcalModulePath(spec, excalIndexAbs) {
|
||||
const baseTypesRoot = path.join(ROOT, 'node_modules', '@zsviczian', 'excalidraw', 'types');
|
||||
if (spec.startsWith('@excalidraw/')) {
|
||||
const sub = spec.slice('@excalidraw/'.length); // e.g. 'element', 'element/bounds'
|
||||
const parts = sub.split('/');
|
||||
const pkg = parts.shift(); // 'element' | 'common' | 'utils'
|
||||
const rest = parts;
|
||||
if (!pkg) return null;
|
||||
const base = path.join(baseTypesRoot, pkg);
|
||||
if (rest.length === 0) {
|
||||
return path.join(base, 'src', 'index.d.ts');
|
||||
}
|
||||
return path.join(base, 'src', ...rest) + '.d.ts';
|
||||
}
|
||||
// relative to the excalidraw index.d.ts
|
||||
if (spec.startsWith('.')) {
|
||||
const dir = path.dirname(excalIndexAbs);
|
||||
return path.resolve(dir, spec) + '.d.ts';
|
||||
}
|
||||
// anything else is not expected
|
||||
return null;
|
||||
}
|
||||
|
||||
// NEW: Extract function signatures for a set of names from a .d.ts file
|
||||
function extractFunctionSignaturesFromModule(absPath, names) {
|
||||
const out = {};
|
||||
if (!absPath || !fs.existsSync(absPath)) {
|
||||
return out;
|
||||
}
|
||||
const content = fs.readFileSync(absPath, 'utf8');
|
||||
|
||||
for (const rawName of names) {
|
||||
const name = rawName.trim();
|
||||
if (!name) continue;
|
||||
|
||||
// Try "export declare function NAME ..."
|
||||
let m = content.match(new RegExp(`export\\s+declare\\s+function\\s+${name}[\\s\\S]*?;`, 'm'));
|
||||
if (m) {
|
||||
out[name] = m[0].trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try "declare function NAME ..." (re-exported later)
|
||||
m = content.match(new RegExp(`(^|\\n)declare\\s+function\\s+${name}[\\s\\S]*?;`, 'm'));
|
||||
if (m) {
|
||||
// Ensure it starts with export for readability
|
||||
out[name] = m[0].replace(/^\s*declare\s+/, 'export declare ').trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try "export declare const NAME: (...args) => ...;"
|
||||
m = content.match(new RegExp(`export\\s+declare\\s+const\\s+${name}\\s*:\\s*[\\s\\S]*?=>[\\s\\S]*?;`, 'm'));
|
||||
if (m) {
|
||||
out[name] = m[0].trim();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try "export declare function-type via type alias" (rare) - fallback to any const function shape
|
||||
m = content.match(new RegExp(`export\\s+declare\\s+(?:var|let|const)\\s+${name}\\s*:\\s*[\\s\\S]*?;`, 'm'));
|
||||
if (m && /=>/.test(m[0])) {
|
||||
out[name] = m[0].trim();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
// NEW: Build "ExcalidrawLib module functions" section from index.d.ts
|
||||
function buildExcalidrawLibFunctionsSection() {
|
||||
const excalIndexRel = 'node_modules/@zsviczian/excalidraw/types/excalidraw/index.d.ts';
|
||||
const excalIndexAbs = path.join(ROOT, ...excalIndexRel.split('/'));
|
||||
if (!fs.existsSync(excalIndexAbs)) {
|
||||
console.warn('[script-library] Missing Excalidraw index.d.ts:', excalIndexRel);
|
||||
return '';
|
||||
}
|
||||
|
||||
const content = fs.readFileSync(excalIndexAbs, 'utf8');
|
||||
const reExport = /export\s*\{\s*([\s\S]*?)\s*\}\s*from\s*["']([^"']+)["'];/g;
|
||||
|
||||
// Collect names by source module
|
||||
const moduleToNames = new Map();
|
||||
for (const match of content.matchAll(reExport)) {
|
||||
const namesChunk = match[1];
|
||||
const spec = match[2];
|
||||
// skip if the export list contains only types we know we shouldn't include? We'll filter later by signature detection.
|
||||
const names = namesChunk
|
||||
.split(',')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
if (!names.length) continue;
|
||||
const abs = resolveExcalModulePath(spec, excalIndexAbs);
|
||||
if (!abs) continue;
|
||||
const key = spec;
|
||||
const curr = moduleToNames.get(key) || { abs, names: new Set() };
|
||||
for (const n of names) curr.names.add(n);
|
||||
moduleToNames.set(key, curr);
|
||||
}
|
||||
|
||||
// Extract signatures
|
||||
const seen = new Set();
|
||||
const sections = [];
|
||||
let functionsFound = 0;
|
||||
|
||||
for (const [spec, { abs, names }] of moduleToNames) {
|
||||
const sigs = extractFunctionSignaturesFromModule(abs, Array.from(names));
|
||||
const sigEntries = Object.entries(sigs)
|
||||
.filter(([name]) => {
|
||||
if (seen.has(name)) return false;
|
||||
seen.add(name);
|
||||
return true;
|
||||
})
|
||||
.sort(([a], [b]) => a.localeCompare(b, 'en', { sensitivity: 'base' }));
|
||||
|
||||
if (!sigEntries.length) continue;
|
||||
|
||||
const rel = path.relative(ROOT, abs).replace(/\\/g, '/');
|
||||
const header = makeSectionHeader(`${spec} -> ${rel}`).replace(/\*\/\n\/\*/g, '*\/\n/*'); // keep style
|
||||
sections.push(header + sigEntries.map(([, s]) => s).join('\n') + '\n');
|
||||
functionsFound += sigEntries.length;
|
||||
}
|
||||
|
||||
if (!sections.length) {
|
||||
console.warn('[script-library] No function signatures found in ExcalidrawLib exports.');
|
||||
}
|
||||
|
||||
const body =
|
||||
'# ExcalidrawLib module functions\n\n' +
|
||||
'The following functions are exposed via window.ExcalidrawLib. Signatures are extracted from TypeScript declarations.\n\n' +
|
||||
'```ts\n' +
|
||||
sections.join('\n') +
|
||||
'```\n';
|
||||
|
||||
console.log(`[script-library] Collected ${functionsFound} ExcalidrawLib function signatures`);
|
||||
return body;
|
||||
}
|
||||
|
||||
function main() {
|
||||
console.log('[script-library] Generating Excalidraw Script Library...');
|
||||
if (!fs.existsSync(EA_SCRIPTS_DIR)) {
|
||||
@@ -295,6 +586,9 @@ function main() {
|
||||
? `<!-- ${EXCALIDRAW_STARTUP_EXAMPLE} -->\n${startupExample}\n`
|
||||
: '');
|
||||
|
||||
// NEW: Build ExcalidrawLib functions section
|
||||
const excalidrawLibFunctionsSection = buildExcalidrawLibFunctionsSection();
|
||||
|
||||
const combined =
|
||||
AI_TRAINING_INTRO +
|
||||
'\n---\n\n' +
|
||||
@@ -302,8 +596,10 @@ function main() {
|
||||
'\n\n---\n\n' +
|
||||
additionalTypeDefs +
|
||||
'\n\n---\n\n' +
|
||||
excalidrawLibFunctionsSection +
|
||||
'\n---\n\n' +
|
||||
scriptLibContent.trim() +
|
||||
startupSection + // NEW: append startup message + files
|
||||
startupSection +
|
||||
'\n';
|
||||
|
||||
fs.writeFileSync(AI_TRAINING_OUT, combined, 'utf8');
|
||||
|
||||
@@ -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"},
|
||||
|
||||
+9
-5
@@ -66,7 +66,7 @@ import { ScriptEngine } from "../shared/Scripts";
|
||||
import { hoverEvent, initializeMarkdownPostProcessor, markdownPostProcessor, legacyExcalidrawPopoverObserver } from "./managers/MarkdownPostProcessor";
|
||||
import { FieldSuggester } from "../shared/Suggesters/FieldSuggester";
|
||||
import { ReleaseNotes } from "../shared/Dialogs/ReleaseNotes";
|
||||
import { Packages } from "../types/types";
|
||||
import { DeviceType, Packages } from "../types/types";
|
||||
import { PreviewImageType } from "../types/utilTypes";
|
||||
import { emulateCTRLClickForLinks, linkClickModifierType, PaneTarget } from "../utils/modifierkeyHelper";
|
||||
import { imageCache } from "../shared/ImageCache";
|
||||
@@ -415,7 +415,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
try {
|
||||
this.isReady = true;
|
||||
await switchToExcalidraw(this.app);
|
||||
this.switchToExcalidarwAfterLoad();
|
||||
this.switchToExcalidrawAfterLoad();
|
||||
} catch (e) {
|
||||
new Notice("Error switching views to Excalidraw", 6000);
|
||||
console.error("Error switching views to Excalidraw", e);
|
||||
@@ -620,8 +620,8 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
/**
|
||||
* Must be called after the workspace is ready
|
||||
*/
|
||||
private switchToExcalidarwAfterLoad() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.switchToExcalidarwAfterLoad, `ExcalidrawPlugin.switchToExcalidarwAfterLoad`);
|
||||
private switchToExcalidrawAfterLoad() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.switchToExcalidrawAfterLoad, `ExcalidrawPlugin.switchToExcalidrawAfterLoad`);
|
||||
let leaf: WorkspaceLeaf;
|
||||
for (leaf of this.app.workspace.getLeavesOfType("markdown")) {
|
||||
if ( leaf.view instanceof MarkdownView && this.isExcalidrawFile(leaf.view.file)) {
|
||||
@@ -1482,4 +1482,8 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
public getLabel(key: keyof typeof en): string {
|
||||
return t(key);
|
||||
}
|
||||
}
|
||||
|
||||
public getObsidianDevice(): DeviceType {
|
||||
return DEVICE;
|
||||
}
|
||||
}
|
||||
@@ -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,12 +988,11 @@ 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;
|
||||
if(!api) return false;
|
||||
const st = api.getAppState();
|
||||
if(!st.trayModeEnabled) return false;
|
||||
const api = view?.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if(!api.isTrayModeEnabled()) return false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1012,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"),
|
||||
@@ -1642,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);
|
||||
@@ -1657,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;
|
||||
|
||||
@@ -242,7 +242,7 @@ export class EventManager {
|
||||
|
||||
if (previouslyActiveEV && previouslyActiveEV !== newActiveviewEV) {
|
||||
if (previouslyActiveEV.leaf !== leaf) {
|
||||
//if loading new view to same leaf then don't save. Excalidarw view will take care of saving anyway.
|
||||
//if loading new view to same leaf then don't save. Excalidraw view will take care of saving anyway.
|
||||
//avoid double saving
|
||||
if(previouslyActiveEV?.isDirty() && !previouslyActiveEV.semaphores?.viewunload) {
|
||||
await previouslyActiveEV.save(true); //this will update transclusions in the drawing
|
||||
@@ -364,4 +364,4 @@ export class EventManager {
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -562,9 +562,9 @@ export class PluginFileManager {
|
||||
return;
|
||||
}
|
||||
|
||||
const isExcalidarwFile = this.getExcalidrawFiles().has(file);
|
||||
const isExcalidrawFile = this.getExcalidrawFiles().has(file);
|
||||
this.updateFileCache(file, undefined, true);
|
||||
if (!isExcalidarwFile) {
|
||||
if (!isExcalidrawFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -614,4 +614,4 @@ export class PluginFileManager {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
+57
-49
@@ -26,8 +26,6 @@ import { PENS } from "src/utils/pens";
|
||||
import {
|
||||
addYouTubeThumbnail,
|
||||
fragWithHTML,
|
||||
setLeftHandedMode,
|
||||
setTrayMode,
|
||||
} from "src/utils/utils";
|
||||
import { imageCache } from "src/shared/ImageCache";
|
||||
import { MultiOptionConfirmationPrompt } from "src/shared/Dialogs/Prompt";
|
||||
@@ -46,6 +44,7 @@ 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";
|
||||
|
||||
export interface ExcalidrawSettings {
|
||||
disableDoubleClickTextEditing: boolean;
|
||||
@@ -88,6 +87,8 @@ export interface ExcalidrawSettings {
|
||||
overrideObsidianFontSize: boolean;
|
||||
dynamicStyling: DynamicStyle;
|
||||
isLeftHanded: boolean;
|
||||
desktopUIMode: UIMode;
|
||||
tabletUIMode: UIMode;
|
||||
iframeMatchExcalidrawTheme: boolean;
|
||||
matchTheme: boolean;
|
||||
matchThemeAlways: boolean;
|
||||
@@ -177,8 +178,6 @@ export interface ExcalidrawSettings {
|
||||
}
|
||||
}
|
||||
};
|
||||
defaultTrayMode: boolean;
|
||||
compactModeOnTablets: boolean;
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
compareManifestToPluginVersion: boolean;
|
||||
@@ -214,6 +213,7 @@ export interface ExcalidrawSettings {
|
||||
aiEnabled: boolean,
|
||||
openAIAPIToken: string,
|
||||
openAIDefaultTextModel: string,
|
||||
openAIDefaultTextModelMaxTokens: number,
|
||||
openAIDefaultVisionModel: string,
|
||||
openAIDefaultImageGenerationModel: string,
|
||||
openAIURL: string,
|
||||
@@ -234,6 +234,7 @@ export interface ExcalidrawSettings {
|
||||
modifierKeyOverrides: {modifiers: Modifier[], key: string}[];
|
||||
showSplashscreen: boolean;
|
||||
pdfSettings: PDFExportSettings;
|
||||
disableContextMenu: boolean;
|
||||
}
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
@@ -279,6 +280,8 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
overrideObsidianFontSize: false,
|
||||
dynamicStyling: "colorful",
|
||||
isLeftHanded: false,
|
||||
desktopUIMode: "tray",
|
||||
tabletUIMode: "compact",
|
||||
iframeMatchExcalidrawTheme: true,
|
||||
matchTheme: false,
|
||||
matchThemeAlways: false,
|
||||
@@ -363,8 +366,6 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
mdBorderColor: "Black",
|
||||
mdCSS: "",
|
||||
scriptEngineSettings: {},
|
||||
defaultTrayMode: true,
|
||||
compactModeOnTablets: true,
|
||||
previousRelease: "0.0.0",
|
||||
showReleaseNotes: true,
|
||||
compareManifestToPluginVersion: true,
|
||||
@@ -426,6 +427,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",
|
||||
@@ -534,6 +536,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
alignment: "center",
|
||||
margin: "normal",
|
||||
},
|
||||
disableContextMenu: false,
|
||||
};
|
||||
|
||||
export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
@@ -1157,6 +1160,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")))
|
||||
@@ -1218,6 +1250,18 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("DISABLE_CONTEXT_MENU_NAME"))
|
||||
.setDesc(t("DISABLE_CONTEXT_MENU_DESC"))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(!this.plugin.settings.disableContextMenu)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.disableContextMenu = !value;
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
const readingModeEl = new Setting(detailsEl)
|
||||
.setName(t("SHOW_DRAWING_OR_MD_IN_READING_MODE_NAME"))
|
||||
@@ -1250,48 +1294,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("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");
|
||||
@@ -2554,7 +2562,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");
|
||||
|
||||
+24
-7
@@ -98,7 +98,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 +110,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 +139,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...",
|
||||
@@ -215,6 +216,8 @@ export default {
|
||||
|
||||
|
||||
//settings.ts
|
||||
DISABLE_CONTEXT_MENU_NAME: "Disable Excalidraw context menu",
|
||||
DISABLE_CONTEXT_MENU_DESC: "Disables the Excalidraw context menu. This can be useful on Mobile devices where the context menu pops up in unwanted moments.",
|
||||
NOTEBOOKLM_LINK_ARIA: "Ask NotebookLM for help about the plugin. This model is pre-loaded with all my video transcripts, release notes and other helpful content. Chat with NotebookLM to explore my 250+ videos and the Excalidraw documentation.",
|
||||
NOTEBOOKLM_LINK_TEXT: "Learn the Plugin. Access the NotebookLM knowledgebase.",
|
||||
LINKS_BUGS_ARIA: "Report bugs and raise feature requsts on the plugin's GitHub page",
|
||||
@@ -310,6 +313,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, " +
|
||||
@@ -450,10 +456,20 @@ 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",
|
||||
COMPACT_MODE_NAME: "Compact-mode on Tablets",
|
||||
COMPACT_MODE_DESC: "Overrides tray-mode on tablets, allowing the native Excalidraw compact-mode to be used instead.",
|
||||
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. " +
|
||||
"If this setting is off, it will toggle betweeen full-mode and tray-mode.",
|
||||
COMPACT_MODE_NAME: "Prefer compact-mode on Tablets",
|
||||
COMPACT_MODE_DESC: "This setting allows you to have a different default mode on tablets, then on desktops. You can default to compact mode on tablets, and to tray-mode on desktops with the help of this setting.",
|
||||
HOTKEY_OVERRIDE_HEAD: "Hotkey overrides",
|
||||
HOTKEY_OVERRIDE_DESC: `Some of the Excalidraw hotkeys such as <code>${labelCTRL()}+Enter</code> to edit text or <code>${labelCTRL()}+K</code> to create an element link ` +
|
||||
"conflict with Obsidian hotkey settings. The hotkey combinations you add below will override Obsidian's hotkey settings while using Excalidraw, thus " +
|
||||
@@ -1118,6 +1134,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, " +
|
||||
|
||||
+29
-13
@@ -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 的热键设置," +
|
||||
@@ -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:
|
||||
@@ -1192,7 +1208,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: "以图像形式",
|
||||
|
||||
+29
-13
@@ -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 的熱鍵設定," +
|
||||
@@ -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:
|
||||
@@ -1192,7 +1208,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: "以影像形式",
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -34,7 +34,8 @@ export class FloatingModal extends Modal {
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement ||
|
||||
target instanceof HTMLButtonElement ||
|
||||
target.closest(".clickable-icon")
|
||||
target.closest(".clickable-icon") ||
|
||||
target.closest(".modal-close-button") // ensure close button never starts drag
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -51,6 +52,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 +180,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";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,15 +17,67 @@ 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.18.0":`
|
||||
## New from Excalidraw.com
|
||||
- New arrow behavior allows binding arrows to the inside of Shapes. 🙏[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.
|
||||
|
||||
## 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.
|
||||
- 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)
|
||||
- Fixed print area when using marker frames and printing Slideshow to PDF
|
||||
- The Invert Colors script and ExcalidrawAutomate bugs that resulted in broken colors and Excalidarw crash in some cases after color inversion.
|
||||
- The "Invert Colors" script and ExcalidrawAutomate bugs that resulted in broken colors and Excalidraw crashes in some cases after color inversion.
|
||||
- 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 the mobile keyboard pop-up, distorting the view.
|
||||
- Added finalize multipoint-line button to compact layout
|
||||
`,
|
||||
"2.16.1":`
|
||||
## Fixed
|
||||
|
||||
@@ -66,8 +66,8 @@ export class PenSettingsModal extends Modal {
|
||||
|
||||
async onClose() {
|
||||
if(this.dirty) {
|
||||
await this.plugin.saveSettings();
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updatePinnedCustomPens());
|
||||
this.plugin.saveSettings();
|
||||
const pen = this.plugin.settings.customPens[this.pen]
|
||||
const api = this.view.excalidrawAPI;
|
||||
setPen(pen,api);
|
||||
@@ -369,7 +369,7 @@ export class PenSettingsModal extends Modal {
|
||||
.setName(fragWithHTML(`Stroke Width <b>${ps.strokeWidth === 0 ? "Not Set" : ps.strokeWidth}</b>`))
|
||||
.addSlider(slider =>
|
||||
slider
|
||||
.setLimits(0,5,0.1)
|
||||
.setLimits(0.1,8,0.1)
|
||||
.setValue(ps.strokeWidth)
|
||||
.onChange(value => {
|
||||
this.dirty = true;
|
||||
|
||||
@@ -221,12 +221,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: "",
|
||||
},
|
||||
@@ -979,7 +980,7 @@ export const FRONTMATTER_KEYS_INFO: SuggesterInfo[] = [
|
||||
{
|
||||
field: "plugin",
|
||||
code: null,
|
||||
desc: "Denotes an excalidraw file. If key is not present, the file will not be recognized as an Excalidarw file. Valid values are 'parsed' and 'raw'",
|
||||
desc: "Denotes an excalidraw file. If key is not present, the file will not be recognized as an Excalidraw file. Valid values are 'parsed' and 'raw'",
|
||||
after: ": parsed",
|
||||
},
|
||||
{
|
||||
@@ -1073,6 +1074,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;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import {
|
||||
COLOR_NAMES,
|
||||
fileid,
|
||||
GITHUB_RELEASES,
|
||||
determineFocusDistance,
|
||||
getCommonBoundingBox,
|
||||
getLineHeight,
|
||||
getMaximumGroups,
|
||||
@@ -77,7 +76,7 @@ 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";
|
||||
@@ -148,7 +147,8 @@ const GAP = 4;
|
||||
* you may access this object via the variable `ea`. e.g. ea.addImage(); This ea object is already set to the targetView.
|
||||
* Through ea.obsidian all of the Obsidian API is available to the script. Thus you can create modal views, open files, etc.
|
||||
* You can access Obsidian type definitions here: https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts
|
||||
* In addition to the ea object, the script also receives the `utils` object. utils includes to utility functions: suggester and inputPrompt
|
||||
* In addition to the ea instance, the script also receives the `utils` object. utils includes to utility functions: suggester and inputPrompt.
|
||||
* You may access these via the variable `utils`. e.g. utils.suggester(...);
|
||||
* - inputPrompt(inputPrompt: (
|
||||
* header: string,
|
||||
* placeholder?: string,
|
||||
@@ -799,6 +799,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
|
||||
@@ -1099,6 +1100,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,
|
||||
@@ -1141,6 +1147,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
|
||||
@@ -1178,7 +1186,9 @@ export class ExcalidrawAutomate {
|
||||
this.plugin,
|
||||
0,
|
||||
padding,
|
||||
this.imagesDict
|
||||
this.imagesDict,
|
||||
convertMarkdownLinksToObsidianURLs,
|
||||
includeInternalLinks,
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1809,27 +1819,19 @@ export class ExcalidrawAutomate {
|
||||
lastCommittedPoint: null,
|
||||
startBinding: {
|
||||
elementId: formatting?.startObjectId,
|
||||
focus: formatting?.startObjectId
|
||||
? determineFocusDistance(
|
||||
this.getElement(formatting?.startObjectId) as ExcalidrawBindableElement,
|
||||
elementsMap,
|
||||
endPoint,
|
||||
startPoint,
|
||||
)
|
||||
: 0.1,
|
||||
gap: GAP,
|
||||
mode: "orbit",
|
||||
fixedPoint: [
|
||||
1,
|
||||
1
|
||||
],
|
||||
},
|
||||
endBinding: {
|
||||
elementId: formatting?.endObjectId,
|
||||
focus: formatting?.endObjectId
|
||||
? determineFocusDistance(
|
||||
this.getElement(formatting?.endObjectId) as ExcalidrawBindableElement,
|
||||
elementsMap,
|
||||
startPoint,
|
||||
endPoint,
|
||||
)
|
||||
: 0.1,
|
||||
gap: GAP,
|
||||
mode: "orbit",
|
||||
fixedPoint: [
|
||||
0,
|
||||
0
|
||||
],
|
||||
},
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/388
|
||||
startArrowhead:
|
||||
|
||||
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,
|
||||
|
||||
@@ -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}] : []),
|
||||
{
|
||||
|
||||
@@ -39,8 +39,8 @@ import {
|
||||
} 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 { 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 +450,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 +512,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 +543,7 @@ export async function createSVG(
|
||||
type: "excalidraw",
|
||||
version: 2,
|
||||
source: GITHUB_RELEASES+PLUGIN_VERSION,
|
||||
elements,
|
||||
elements: includeInternalLinks ? elements : sceneRemoveInternalLinks({elements}),
|
||||
appState: {
|
||||
theme,
|
||||
viewBackgroundColor:
|
||||
|
||||
@@ -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:\/\/.*/)) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
+37
-11
@@ -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,18 +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 setUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const uiMode = calculateUIModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setUIMode(uiMode));
|
||||
};
|
||||
|
||||
export type LinkParts = {
|
||||
original: string;
|
||||
@@ -807,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,
|
||||
|
||||
+136
-93
@@ -110,8 +110,8 @@ import {
|
||||
getFilePathFromObsidianURL,
|
||||
getLinkParts,
|
||||
checkVersionMismatch,
|
||||
calculateTrayModeValue,
|
||||
setTrayMode,
|
||||
calculateUIModeValue,
|
||||
getExportInternalLinks,
|
||||
} from "../utils/utils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getAttachmentsFolderAndFilePath, getExcalidraAndMarkdowViewsForFile, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
@@ -134,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";
|
||||
@@ -159,6 +159,8 @@ 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";
|
||||
|
||||
const EMBEDDABLE_SEMAPHORE_TIMEOUT = 2000;
|
||||
const PREVENT_RELOAD_TIMEOUT = 2000;
|
||||
@@ -278,7 +280,7 @@ const warningUnknowSeriousError = () => {
|
||||
new Notice(t("WARNING_SERIOUS_ERROR"),60000);
|
||||
};
|
||||
|
||||
type ActionButtons = "save" | "isParsed" | "isRaw" | "link" | "scriptInstall";
|
||||
type ActionButtons = "save" | "isRaw" | "link" | "scriptInstall";
|
||||
|
||||
let windowMigratedDisableZoomOnce = false;
|
||||
|
||||
@@ -335,6 +337,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
private obsidianMenu: ObsidianMenu;
|
||||
private embeddableMenu: EmbeddableMenu;
|
||||
private destroyers: Function[] = [];
|
||||
private previousContentElHeight: number = 0;
|
||||
private resizeBatchTimer: number = null;
|
||||
private lastAggregatedDh = 0;
|
||||
private oldKeyboardScroll:{scrollY:number, scrollX:number}|null = null;
|
||||
|
||||
//https://stackoverflow.com/questions/27132796/is-there-any-javascript-event-fired-when-the-on-screen-keyboard-on-mobile-safari
|
||||
private isEditingTextResetTimer: number = null;
|
||||
@@ -515,6 +521,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);
|
||||
@@ -581,7 +596,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;
|
||||
}
|
||||
@@ -611,6 +630,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,
|
||||
@@ -963,7 +985,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"]
|
||||
@@ -1630,32 +1653,45 @@ 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();
|
||||
});
|
||||
|
||||
this.actionButtons['save'] = this.addAction(
|
||||
DISK_ICON_NAME,
|
||||
t("FORCE_SAVE"),
|
||||
async () => this.forceSave(),
|
||||
);
|
||||
|
||||
this.actionButtons['isRaw'] = this.addAction(
|
||||
TEXT_DISPLAY_RAW_ICON_NAME,
|
||||
t("RAW"),
|
||||
() => this.changeTextMode(TextMode.parsed),
|
||||
);
|
||||
this.actionButtons = {
|
||||
scriptInstall: this.addAction(
|
||||
SCRIPTENGINE_ICON_NAME,
|
||||
!DEVICE.isMobile ? t("INSTALL_SCRIPT_BUTTON") : "",
|
||||
() => {
|
||||
new ScriptInstallPrompt(this.plugin).open();
|
||||
}),
|
||||
save: this.addAction(
|
||||
DISK_ICON_NAME,
|
||||
!DEVICE.isMobile ? t("FORCE_SAVE") : "",
|
||||
async () => this.forceSave(),
|
||||
),
|
||||
isRaw: this.addAction(
|
||||
TEXT_DISPLAY_RAW_ICON_NAME,
|
||||
!DEVICE.isMobile ? t("RAW") : "",
|
||||
() => this.changeTextMode(TextMode.parsed),
|
||||
),
|
||||
link: this.addAction(
|
||||
"link",
|
||||
!DEVICE.isMobile ? t("OPEN_LINK") : "",
|
||||
(ev) => this.handleLinkClick(ev),
|
||||
),
|
||||
}
|
||||
/*this.actionButtons['isParsed'] = this.addAction(
|
||||
TEXT_DISPLAY_PARSED_ICON_NAME,
|
||||
t("PARSED"),
|
||||
() => this.changeTextMode(TextMode.raw),
|
||||
);*/
|
||||
|
||||
this.actionButtons['link'] = this.addAction("link", t("OPEN_LINK"), (ev) =>
|
||||
this.handleLinkClick(ev),
|
||||
);
|
||||
|
||||
this.registerDomEvent(this.ownerWindow, "resize", this.onExcalidrawResize.bind(this));
|
||||
const ro = new ResizeObserver(() => {
|
||||
const height = this.contentEl.clientHeight;
|
||||
const prevHeight = this.previousContentElHeight;
|
||||
const dh = prevHeight ? height - prevHeight : 0;
|
||||
this.previousContentElHeight = height;
|
||||
this.scheduleBatchedResize(dh);
|
||||
});
|
||||
this.previousContentElHeight = this.contentEl.clientHeight;
|
||||
ro.observe(this.contentEl);
|
||||
this.destroyers.push(() => ro.disconnect());
|
||||
|
||||
this.app.workspace.onLayoutReady(async () => {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.onload,`ExcalidrawView.onload > app.workspace.onLayoutReady, file:${this.file?.name}, isActiveLeaf:${this?.app?.workspace?.activeLeaf === this.leaf}, is activeExcalidrawView set:${Boolean(this?.plugin?.activeExcalidrawView)}`);
|
||||
@@ -2397,7 +2433,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if (this.compatibilityMode) {
|
||||
this.plugin.enableLegacyFilePopoverObserver();
|
||||
this.actionButtons['isRaw'].hide();
|
||||
this.actionButtons['isParsed'].hide();
|
||||
// this.actionButtons['isParsed'].hide();
|
||||
this.actionButtons['link'].hide();
|
||||
this.textMode = TextMode.raw;
|
||||
await this.excalidrawData.loadLegacyData(data, this.file);
|
||||
@@ -2828,7 +2864,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
zenModeEnabled,
|
||||
viewModeEnabled,
|
||||
linkOpacity: this.excalidrawData.getLinkOpacity(),
|
||||
trayModeEnabled: calculateTrayModeValue(this.plugin.settings),
|
||||
penMode: penEnabled,
|
||||
penDetected: penEnabled,
|
||||
allowPinchZoom: this.plugin.settings.allowPinchZoom,
|
||||
@@ -2862,7 +2897,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
zenModeEnabled: om.zenModeEnabled,
|
||||
viewModeEnabled: excalidrawData.elements.length > 0 ? om.viewModeEnabled : false,
|
||||
linkOpacity: this.excalidrawData.getLinkOpacity(),
|
||||
trayModeEnabled: calculateTrayModeValue(this.plugin.settings),
|
||||
penMode: penEnabled,
|
||||
penDetected: penEnabled,
|
||||
allowPinchZoom: this.plugin.settings.allowPinchZoom,
|
||||
@@ -2902,6 +2936,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.loadSceneFiles();
|
||||
this.updateContainerSize(null, true, justloaded);
|
||||
this.initializeToolsIconPanelAfterLoading();
|
||||
const uiMode = calculateUIModeValue(this.plugin.settings);
|
||||
this.setUIMode(uiMode);
|
||||
}
|
||||
|
||||
public setDirty(location?:number) {
|
||||
@@ -3690,6 +3726,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
frameRendering: st.frameRendering,
|
||||
objectsSnapModeEnabled: st.objectsSnapModeEnabled,
|
||||
activeTool,
|
||||
disableContextMenu: st.disableContextMenu,
|
||||
},
|
||||
prevTextMode: this.prevTextMode,
|
||||
files,
|
||||
@@ -3784,6 +3821,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();
|
||||
@@ -5186,6 +5224,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) {
|
||||
@@ -5347,15 +5386,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")
|
||||
@@ -5463,7 +5495,25 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
return this.obsidianMenu?.renderButton (isMobile, appState);
|
||||
}
|
||||
|
||||
private onExcalidrawResize () {
|
||||
private scheduleBatchedResize(currentDeltaHeight: number) {
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if(!api || !api.isTouchScreen) return;
|
||||
if (!this.resizeBatchTimer) {
|
||||
this.lastAggregatedDh = 0;
|
||||
}
|
||||
this.lastAggregatedDh += currentDeltaHeight;
|
||||
if (this.resizeBatchTimer) window.clearTimeout(this.resizeBatchTimer);
|
||||
this.resizeBatchTimer = window.setTimeout(() => {
|
||||
const dh = this.lastAggregatedDh;
|
||||
this.resizeBatchTimer = null;
|
||||
this.lastAggregatedDh = 0;
|
||||
if (Math.abs(dh) > 120) {
|
||||
this.onExcalidrawResize();
|
||||
}
|
||||
}, Math.abs(currentDeltaHeight) < 120 ? 700 : 20);
|
||||
}
|
||||
|
||||
private onExcalidrawResize() {
|
||||
try {
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if(!api) return;
|
||||
@@ -5488,30 +5538,38 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
const isKeyboardOutEvent:Boolean = st.editingTextElement && !isEventOnSameElement;
|
||||
const isKeyboardBackEvent:Boolean = (this.semaphores.isEditingText || isEventOnSameElement) && !isKeyboardOutEvent;
|
||||
this.editingTextElementId = isKeyboardOutEvent ? st.editingTextElement.id : null;
|
||||
|
||||
if(isKeyboardOutEvent) {
|
||||
const appToolHeight = (this.contentEl.querySelector(".Island.App-toolbar") as HTMLElement)?.clientHeight ?? 0;
|
||||
const editingElViewY = sceneCoordsToViewportCoords({sceneX:0, sceneY:st.editingTextElement.y}, st).y;
|
||||
const scrollViewY = sceneCoordsToViewportCoords({sceneX:0, sceneY:-st.scrollY}, st).y;
|
||||
const delta = editingElViewY - scrollViewY;
|
||||
const isElementAboveKeyboard = height > (delta + appToolHeight*2)
|
||||
const excalidrawWrapper = this.excalidrawWrapperRef.current;
|
||||
//console.log({isElementAboveKeyboard});
|
||||
if(excalidrawWrapper && !isElementAboveKeyboard) {
|
||||
excalidrawWrapper.style.top = `${-(st.height - height)}px`;
|
||||
excalidrawWrapper.style.height = `${st.height}px`;
|
||||
this.excalidrawContainer?.querySelector(".App-bottom-bar")?.scrollIntoView();
|
||||
this.headerEl?.scrollIntoView();
|
||||
}
|
||||
const elTop = st.editingTextElement.y;
|
||||
const elHeight = (st.editingTextElement as any).height ?? 0;
|
||||
const elCenterY = elTop + elHeight / 2;
|
||||
|
||||
const visibleHeight = st.height / st.zoom.value;
|
||||
// visibleTop is -scrollY in scene coords
|
||||
const visibleTop = -st.scrollY;
|
||||
const topThreeQuarterThreshold = visibleTop + visibleHeight * 0.75;
|
||||
|
||||
// If the editing text element is in the top 3/4 of the visible screen, do not change scroll
|
||||
if (!(elCenterY >= visibleTop && elCenterY <= topThreeQuarterThreshold)) {
|
||||
// Otherwise, vertically center the editing text element in the visible area
|
||||
const desiredVisibleTop = elCenterY - visibleHeight / 2;
|
||||
const newScrollY = -desiredVisibleTop;
|
||||
|
||||
this.oldKeyboardScroll = {scrollY: st.scrollY, scrollX: st.scrollX};
|
||||
this.updateScene({appState: {scrollY: newScrollY}, captureUpdate: CaptureUpdateAction.NEVER});
|
||||
}
|
||||
|
||||
this.containerEl.scrollIntoView();
|
||||
}
|
||||
if(isKeyboardBackEvent) {
|
||||
const excalidrawWrapper = this.excalidrawWrapperRef.current;
|
||||
const appButtonBar = this.excalidrawContainer?.querySelector(".App-bottom-bar");
|
||||
const headerEl = this.headerEl;
|
||||
if(excalidrawWrapper) {
|
||||
excalidrawWrapper.style.top = "";
|
||||
excalidrawWrapper.style.height = "";
|
||||
appButtonBar?.scrollIntoView();
|
||||
headerEl?.scrollIntoView();
|
||||
if (isKeyboardBackEvent) {
|
||||
if(this.oldKeyboardScroll != null) {
|
||||
// Restore only vertical scroll; remove horizontal scroll completely
|
||||
this.updateScene({
|
||||
appState: {scrollY: this.oldKeyboardScroll.scrollY},
|
||||
captureUpdate: CaptureUpdateAction.NEVER
|
||||
});
|
||||
this.oldKeyboardScroll = null;
|
||||
this.containerEl.scrollIntoView();
|
||||
}
|
||||
}
|
||||
//end of aweful hack
|
||||
@@ -5647,6 +5705,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
saveAsImage: false,
|
||||
saveToActiveFile: false,
|
||||
},
|
||||
desktopUIMode: calculateUIModeValue(this.plugin.settings),
|
||||
//formFactor: DEVICE.isMobile ? "phone" : DEVICE.isTablet ? "tablet" : "desktop",
|
||||
},
|
||||
initState: initdata?.appState,
|
||||
initialData: initdata,
|
||||
@@ -5822,41 +5882,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;
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
setTrayMode(this.app, this.plugin.settings);
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
|
||||
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;
|
||||
if (!api) {
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
api.updateScene({
|
||||
appState: { trayModeEnabled: on },
|
||||
captureUpdate: CaptureUpdateAction.NEVER,
|
||||
});
|
||||
setTimeout(()=>api.refreshEditorBreakpoints());
|
||||
const disableContextMenu = api.getAppState().disableContextMenu;
|
||||
this.updateScene({appState: {disableContextMenu: !disableContextMenu}, captureUpdate: CaptureUpdateAction.NEVER});
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -232,7 +233,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
}
|
||||
|
||||
actionToggleTrayMode() {
|
||||
this.view.toggleTrayMode();
|
||||
const uiModeSettings = new UIModeSettings(this.view.plugin);
|
||||
uiModeSettings.open();
|
||||
}
|
||||
|
||||
actionToggleFullscreen() {
|
||||
@@ -530,8 +532,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}
|
||||
/>
|
||||
|
||||
@@ -349,7 +349,7 @@ export class DropManager {
|
||||
}
|
||||
if(!path) {
|
||||
new Notice(t("ERROR_CANT_READ_FILEPATH"),6000);
|
||||
return true; //excalidarw to continue processing
|
||||
return true; //excalidraw to continue processing
|
||||
}
|
||||
const link = getInternalLinkOrFileURLLink(path, this.plugin, event.dataTransfer.files[i].name, this.file);
|
||||
const {x,y} = this.currentPosition;
|
||||
@@ -414,7 +414,7 @@ export class DropManager {
|
||||
ea.destroy();
|
||||
})();
|
||||
} else if(extension === "excalidraw") {
|
||||
return true; //excalidarw to continue processing
|
||||
return true; //excalidraw to continue processing
|
||||
} else {
|
||||
(async () => {
|
||||
const file = await importFileToVault(
|
||||
@@ -460,7 +460,7 @@ export class DropManager {
|
||||
if(!path || !name) {
|
||||
new Notice(t("ERROR_CANT_READ_FILEPATH"),6000);
|
||||
ea.destroy();
|
||||
return true; //excalidarw to continue processing
|
||||
return true; //excalidraw to continue processing
|
||||
}
|
||||
const link = getInternalLinkOrFileURLLink(path, this.plugin, name, this.file);
|
||||
const id = ea.addText(
|
||||
@@ -635,4 +635,4 @@ export class DropManager {
|
||||
return "copy";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+15
-1
@@ -892,6 +892,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,7 +902,20 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
.excalidraw .FixedSideContainer_side_top {
|
||||
padding-top: 0 !important;
|
||||
|
||||
}
|
||||
|
||||
.excalidraw .ToolIcon.ToolIcon__penMode {
|
||||
height:fit-content
|
||||
}
|
||||
Reference in new issue
Block a user