mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25474af843 | ||
|
|
444ac933fa | ||
|
|
5bfd690c7a | ||
|
|
95c562b15c | ||
|
|
7e18367075 | ||
|
|
713f197381 | ||
|
|
d1e4b9a905 | ||
|
|
29c215bbfb | ||
|
|
fb21d5516d | ||
|
|
c2f986dff7 | ||
|
|
d2c8abf0fc | ||
|
|
22835f3c1f | ||
|
|
e1ad165313 | ||
|
|
67f291177d | ||
|
|
ad0e47033a | ||
|
|
65b8de8965 | ||
|
|
27b899ecbc | ||
|
|
62e6142813 | ||
|
|
b967cddf4c | ||
|
|
45709e5f1e | ||
|
|
5e9eb66510 | ||
|
|
af7891da4e | ||
|
|
65831073a6 | ||
|
|
7093c221d1 | ||
|
|
675700696a | ||
|
|
becb650902 | ||
|
|
1a7d9c6f8c | ||
|
|
403467c134 | ||
|
|
8a1b90c06b | ||
|
|
f93b3b9306 |
No files matched your search
Generated
+5
-4
@@ -20,7 +20,7 @@
|
||||
"rollup": "^2.70.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.7.3"
|
||||
"typescript": "5.9.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
@@ -1180,10 +1180,11 @@
|
||||
"license": "0BSD"
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.7.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
|
||||
"integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
||||
@@ -19,6 +19,6 @@
|
||||
"rollup": "^2.70.1",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"tslib": "^2.8.1",
|
||||
"typescript": "^5.7.3"
|
||||
"typescript": "5.9.3"
|
||||
}
|
||||
}
|
||||
@@ -1780,8 +1780,8 @@ export declare const STANDARD_PAGE_SIZES: {
|
||||
readonly height: 1632;
|
||||
};
|
||||
readonly Ledger: {
|
||||
readonly width: 1632;
|
||||
readonly height: 1056;
|
||||
readonly width: 1056;
|
||||
readonly height: 1632;
|
||||
};
|
||||
readonly "HD Screen": {
|
||||
readonly width: 1920;
|
||||
@@ -2380,6 +2380,7 @@ export type ObservedElementsAppState = {
|
||||
lockedMultiSelections: AppState["lockedMultiSelections"];
|
||||
activeLockedId: AppState["activeLockedId"];
|
||||
};
|
||||
export type BoxSelectionMode = "contain" | "overlap";
|
||||
export interface AppState {
|
||||
contextMenu: {
|
||||
items: ContextMenuItems;
|
||||
@@ -2418,6 +2419,8 @@ export interface AppState {
|
||||
* `bindingPreference` and keyboard modifiers (ctrl/alt)
|
||||
*/
|
||||
isBindingEnabled: boolean;
|
||||
/** user box selection preference; defaults to "contain" when unset */
|
||||
boxSelectionMode: BoxSelectionMode;
|
||||
/** user arrow binding preference */
|
||||
bindingPreference: "enabled" | "disabled";
|
||||
/** user preference whether arrow snap to midpoints while binding */
|
||||
@@ -2441,7 +2444,7 @@ export interface AppState {
|
||||
/**
|
||||
* set when a new text is created or when an existing text is being edited
|
||||
*/
|
||||
editingTextElement: NonDeletedExcalidrawElement | null;
|
||||
editingTextElement: ExcalidrawTextElement | null;
|
||||
activeTool: {
|
||||
/**
|
||||
* indicates a previous tool we should revert back to if we deselect the
|
||||
@@ -3114,7 +3117,7 @@ export declare const getRectangleBoxAbsoluteCoords: (boxSceneCoords: RectangleBo
|
||||
export declare const getDiamondPoints: (element: ExcalidrawElement) => number[];
|
||||
export declare const getCubicBezierCurveBound: (p0: GlobalPoint, p1: GlobalPoint, p2: GlobalPoint, p3: GlobalPoint) => Bounds;
|
||||
export declare const getMinMaxXYFromCurvePathOps: (ops: Op[], transformXY?: (p: GlobalPoint) => GlobalPoint) => Bounds;
|
||||
export declare const getBoundsFromPoints: (points: ExcalidrawFreeDrawElement["points"]) => Bounds;
|
||||
export declare const getBoundsFromPoints: <P extends GlobalPoint | LocalPoint>(points: readonly P[], padding?: number) => Bounds;
|
||||
/** @returns number in pixels */
|
||||
export declare const getArrowheadSize: (arrowhead: Arrowhead) => number;
|
||||
/** @returns number in degrees */
|
||||
@@ -3153,7 +3156,9 @@ export declare const getCenterForBounds: (bounds: Bounds) => GlobalPoint;
|
||||
*/
|
||||
export declare const aabbForElement: (element: Readonly<ExcalidrawElement>, elementsMap: ElementsMap, offset?: [number, number, number, number]) => Bounds;
|
||||
export declare const pointInsideBounds: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
|
||||
export declare const pointInsideBoundsInclusive: <P extends GlobalPoint | LocalPoint>(p: P, bounds: Bounds) => boolean;
|
||||
export declare const doBoundsIntersect: (bounds1: Bounds | null, bounds2: Bounds | null) => boolean;
|
||||
export declare const boundsContainBounds: (outerBounds: Bounds, innerBounds: Bounds) => boolean;
|
||||
export declare const elementCenterPoint: (element: ExcalidrawElement, elementsMap: ElementsMap, xOffset?: number, yOffset?: number) => GlobalPoint;
|
||||
|
||||
/* ************************************** */
|
||||
@@ -3255,12 +3260,14 @@ declare class App extends React.Component<AppProps, AppState> {
|
||||
hitLinkElement?: NonDeletedExcalidrawElement;
|
||||
lastPointerDownEvent: React.PointerEvent<HTMLElement> | null;
|
||||
lastPointerUpEvent: React.PointerEvent<HTMLElement> | PointerEvent | null;
|
||||
lastPointerUpIsDoubleClick: boolean;
|
||||
lastPointerMoveEvent: PointerEvent | null;
|
||||
/** current frame pointer cords */
|
||||
lastPointerMoveCoords: {
|
||||
x: number;
|
||||
y: number;
|
||||
} | null;
|
||||
private lastCompletedCanvasClicks;
|
||||
/** previous frame pointer coords */
|
||||
previousPointerMoveCoords: {
|
||||
x: number;
|
||||
@@ -3421,10 +3428,12 @@ declare class App extends React.Component<AppProps, AppState> {
|
||||
* If disabled, returns null.
|
||||
*/
|
||||
getEffectiveGridSize: () => NullableGridSize;
|
||||
private getTextCreationGridPoint;
|
||||
private getHTMLIFrameElement;
|
||||
private handleIframeLikeElementHover;
|
||||
/** @returns true if iframe-like element click handled */
|
||||
private handleIframeLikeCenterClick;
|
||||
private isDoubleClick;
|
||||
private isIframeLikeElementCenter;
|
||||
private updateEmbedValidationStatus;
|
||||
private updateEmbeddables;
|
||||
@@ -3637,7 +3646,11 @@ declare class App extends React.Component<AppProps, AppState> {
|
||||
private onGestureEnd;
|
||||
private handleTextWysiwyg;
|
||||
private deselectElements;
|
||||
private getSelectedTextElement;
|
||||
private getSelectedTextEditingContainerAtPosition;
|
||||
private getTextElementAtPosition;
|
||||
private isHittingTextAutoResizeHandle;
|
||||
private handleTextAutoResizeHandlePointerDown;
|
||||
private getElementAtPosition;
|
||||
private getElementsAtPosition;
|
||||
getElementHitThreshold(element: ExcalidrawElement): number;
|
||||
@@ -3647,7 +3660,9 @@ declare class App extends React.Component<AppProps, AppState> {
|
||||
private debounceDoubleClickTimestamp;
|
||||
private startImageCropping;
|
||||
private finishImageCropping;
|
||||
private shouldHandleBrowserCanvasDoubleClick;
|
||||
private handleCanvasDoubleClick;
|
||||
private handleCanvasClick;
|
||||
private getElementLinkAtPosition;
|
||||
private handleElementLinkClick;
|
||||
private getTopLayerFrameAtSceneCoords;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+252
-63
@@ -1229,8 +1229,60 @@ const IMAGE_TYPES = ["jpeg", "jpg", "png", "gif", "svg", "webp", "bmp", "ico", "
|
||||
const EMBEDED_OBJECT_WIDTH_ROOT = 400;
|
||||
const EMBEDED_OBJECT_WIDTH_CHILD = 180;
|
||||
|
||||
//special trim function that returns trimmed text, including trimming a bullet point of the bullet
|
||||
const trimText = (text) => {
|
||||
if(!text) return text;
|
||||
return text.match(/^(?:[ \t]*[-\*][ \t])?(?:[ \t]*)(.*?)[ \t]*$/)[1];
|
||||
}
|
||||
|
||||
const parseText = async (text) => {
|
||||
const trimmed = trimText(text);
|
||||
if (trimmed && (trimmed.startsWith("![[") || trimmed.match(/^[-*][ \t]+!\[\[/)) && trimmed.endsWith("]]")) {
|
||||
return text;
|
||||
}
|
||||
return await ea.parseText(text);
|
||||
}
|
||||
|
||||
const parseImageInput = (input) => {
|
||||
const trimmed = input.trim();
|
||||
const trimmed = trimText(input);
|
||||
|
||||
// Check for external/local markdown image link:  or 
|
||||
const externalMatch = trimmed.match(/^!\[(.*?)\]\(((?:https?|file):\/\/[^)]+)\)$/i);
|
||||
if (externalMatch) {
|
||||
const altText = externalMatch[1];
|
||||
const url = externalMatch[2];
|
||||
|
||||
let width = null;
|
||||
if (altText) {
|
||||
const parts = altText.split("|");
|
||||
const last = parts[parts.length - 1];
|
||||
if (/^\d+$/.test(last)) {
|
||||
width = parseInt(last);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const urlObj = new URL(url);
|
||||
const pathname = urlObj.pathname.toLowerCase();
|
||||
// Heuristic: check if the URL points to a standard image file extension
|
||||
const isImageUrl = IMAGE_TYPES.some(ext => pathname.endsWith("." + ext));
|
||||
|
||||
if (isImageUrl) {
|
||||
return {
|
||||
path: url,
|
||||
width,
|
||||
imageFile: null,
|
||||
isImagePath: true, // This triggers image addition in addNode
|
||||
file: null,
|
||||
isExternalImage: true // Flag to help direct link assignments later
|
||||
};
|
||||
}
|
||||
} catch (e) {}
|
||||
|
||||
// If not matching an image extension, return null so parseEmbeddableInput takes over
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!trimmed.startsWith("![[") || !trimmed.endsWith("]]")) return null;
|
||||
|
||||
const content = trimmed.slice(3, -2);
|
||||
@@ -1248,7 +1300,7 @@ const parseImageInput = (input) => {
|
||||
let imageFile = file = null;
|
||||
let isImagePath = false;
|
||||
|
||||
const PDF_RECT_LINK_REGEX = /^[^#]*#page=\d*(&\w*=[^&]+){0,}&rect=\d*,\d*,\d*,\d*/;
|
||||
const PDF_RECT_LINK_REGEX = /^[^#]*#page=\d*/; //(&\w*=[^&]+){0,}&rect=\d*,\d*,\d*,\d*
|
||||
if (path.match(PDF_RECT_LINK_REGEX)) {
|
||||
isImagePath = true;
|
||||
} else {
|
||||
@@ -1271,8 +1323,13 @@ const parseImageInput = (input) => {
|
||||
|
||||
const parseEmbeddableInput = (input, imageInfo) => {
|
||||
const trimmed = input.trim();
|
||||
const match = trimmed.match(/^!\[\]\((https?:\/\/[^)]+)\)$/);
|
||||
if (match) return match[1];
|
||||
// Ensure we capture potential alt-text formatting so we gracefully match the pattern
|
||||
const match = trimmed.match(/^!\[(.*?)\]\(((?:https?|file):\/\/[^)]+)\)$/i);
|
||||
if (match) {
|
||||
// If parseImageInput already claimed this as an external image, do not override
|
||||
if (imageInfo && imageInfo.isExternalImage) return null;
|
||||
return match[2];
|
||||
}
|
||||
const pathSplit = imageInfo?.path?.split("#");
|
||||
if (imageInfo && imageInfo.file && imageInfo.file.extension === "md" &&
|
||||
// Not an Excalidraw File or maybe an Excalidraw file with a back-of-the-card note reference
|
||||
@@ -3040,8 +3097,19 @@ const isStructuralElement = (el, allElements, rootId = null, elementById = null,
|
||||
const isStructuralType = el.customData?.isBranch || el.customData?.growthMode || el.customData?.isBoundary || typeof el.customData?.mindmapOrder !== "undefined";
|
||||
|
||||
if (rootId && isStructuralType) {
|
||||
// Optimization: Pass maps to getHierarchy to prevent O(N) lookups
|
||||
const info = getHierarchy(el, allElements, elementById, parentMap);
|
||||
let targetEl = el;
|
||||
|
||||
if (el.type === "arrow" && el.customData?.isBranch) {
|
||||
const targetId = el.endBinding?.elementId || el.startBinding?.elementId;
|
||||
if (targetId) {
|
||||
targetEl = elementById?.get(targetId) || allElements.find(e => e.id === targetId);
|
||||
}
|
||||
}
|
||||
|
||||
if (!targetEl) return false;
|
||||
|
||||
// Pass maps to getHierarchy to prevent O(N) lookups
|
||||
const info = getHierarchy(targetEl, allElements, elementById, parentMap);
|
||||
if (info?.rootId === rootId) return true;
|
||||
if (info?.rootId) return false;
|
||||
}
|
||||
@@ -3056,13 +3124,24 @@ const isStructuralElement = (el, allElements, rootId = null, elementById = null,
|
||||
return !!connectedArrow;
|
||||
};
|
||||
|
||||
const getViewGroupElements = (groupID) => {
|
||||
return ea.getViewElements().filter( el => el.groupIds.includes(groupID) );
|
||||
}
|
||||
|
||||
const getCommonGroupForElements = (elements) => {
|
||||
const groupIds = elements
|
||||
.map(el=>el.groupIds)
|
||||
.reduce((prev,cur)=>cur.filter(v=>prev.includes(v)));
|
||||
return groupIds;
|
||||
};
|
||||
|
||||
/**
|
||||
* A group is considered a "Mindmap Group" if it contains at least 2 structural elements.
|
||||
* Groups with only 1 structural element (e.g. a Node grouped with a Sticker) are treated as decoration.
|
||||
*/
|
||||
const isMindmapGroup = (groupId, allElements, rootId) => {
|
||||
const isMindmapGroup = (groupId, allElements) => {
|
||||
const groupEls = allElements.filter(el => el.groupIds?.includes(groupId));
|
||||
const structuralCount = groupEls.filter(el => isStructuralElement(el, allElements, rootId)).length;
|
||||
const structuralCount = groupEls.filter(el => isStructuralElement(el, allElements)).length;
|
||||
return structuralCount >= 2;
|
||||
};
|
||||
|
||||
@@ -3083,7 +3162,7 @@ const collectDecorationIds = (allElements, rootId) => new Set(
|
||||
*/
|
||||
const getStructuralGroup = (element, allElements, rootId) => {
|
||||
if (!element.groupIds || element.groupIds.length === 0) return null;
|
||||
return element.groupIds.find(gid => isMindmapGroup(gid, allElements, rootId));
|
||||
return element.groupIds.find(gid => isMindmapGroup(gid, allElements));
|
||||
};
|
||||
|
||||
const applyRecursiveGrouping = (nodeId, allElements) => {
|
||||
@@ -3255,7 +3334,7 @@ const updateNodeBoundary = (node, allElements, rootId) => {
|
||||
boundaryEl.polygon = true;
|
||||
boundaryEl.locked = false;
|
||||
|
||||
if (node.groupIds.length > 0 && isMindmapGroup(node.groupIds[0], allElements, rootId)) {
|
||||
if (node.groupIds.length > 0 && isMindmapGroup(node.groupIds[0], allElements)) {
|
||||
if (!boundaryEl.groupIds || boundaryEl.groupIds.length === 0 || boundaryEl.groupIds[0] !== node.groupIds[0]) {
|
||||
boundaryEl.groupIds = [node.groupIds[0]];
|
||||
}
|
||||
@@ -4564,7 +4643,7 @@ const triggerGlobalLayout = async (rootId, forceUngroup = false, mustHonorMindma
|
||||
mindmapIds.forEach((id) => {
|
||||
const el = ea.getElement(id);
|
||||
if (el && el.groupIds) {
|
||||
el.groupIds = el.groupIds.filter(gid => !isMindmapGroup(gid, allElements, rootId));
|
||||
el.groupIds = el.groupIds.filter(gid => !isMindmapGroup(gid, allElements));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -4766,16 +4845,30 @@ const triggerGlobalLayout = async (rootId, forceUngroup = false, mustHonorMindma
|
||||
|
||||
await run(allElements, mindmapIds, root, false, sharedSets, mustHonorMindmapOrder);
|
||||
|
||||
if (structuralGroupId) {
|
||||
ea.addToGroup(groupedElementIds);
|
||||
if (structuralGroupId && !forceUngroup) {
|
||||
// Restore the exact same group ID instead of creating a new one
|
||||
// This prevents Excalidraw's editingGroupId from pointing to a deleted group,
|
||||
// which causes the 0x0 rendering artifact at the origin.
|
||||
groupedElementIds.forEach(id => {
|
||||
const el = ea.getElement(id);
|
||||
if (el && (!el.groupIds || !el.groupIds.includes(structuralGroupId))) {
|
||||
el.groupIds = [...(el.groupIds || []), structuralGroupId];
|
||||
}
|
||||
});
|
||||
}
|
||||
await addElementsToView({ captureUpdate: "IMMEDIATELY" });
|
||||
|
||||
} else {
|
||||
// If only visual change (no struct change, no boundary move), commit Run 1
|
||||
if (result1.visualChange) {
|
||||
if (structuralGroupId) {
|
||||
ea.addToGroup(groupedElementIds);
|
||||
if (structuralGroupId && !forceUngroup) {
|
||||
// Restore the exact same group ID instead of creating a new one
|
||||
groupedElementIds.forEach(id => {
|
||||
const el = ea.getElement(id);
|
||||
if (el && (!el.groupIds || !el.groupIds.includes(structuralGroupId))) {
|
||||
el.groupIds = [...(el.groupIds || []), structuralGroupId];
|
||||
}
|
||||
});
|
||||
}
|
||||
await addElementsToView({ captureUpdate: "IMMEDIATELY" });
|
||||
} else {
|
||||
@@ -4799,7 +4892,7 @@ const getAdjustedMaxWidth = async (text, max) => {
|
||||
const fontString = `${ea.style.fontSize.toString()}px ${
|
||||
ExcalidrawLib.getFontFamilyString({fontFamily: ea.style.fontFamily})}`;
|
||||
|
||||
const parsedText = (await ea.parseText(text)) ?? text;
|
||||
const parsedText = (await parseText(text)) ?? text;
|
||||
|
||||
const wrappedText = ExcalidrawLib.wrapText(parsedText, fontString, max);
|
||||
const metrics = ea.measureText(wrappedText);
|
||||
@@ -4927,17 +5020,23 @@ const addNode = async (text, follow = false, skipFinalLayout = false, batchModeA
|
||||
const effectiveMaxWrap = rootCfgForAdd?.maxWrapWidth ?? maxWidth;
|
||||
let curMaxW = depth === 0 ? Math.max(400, effectiveMaxWrap) : effectiveMaxWrap;
|
||||
|
||||
// --- ADDED AWAIT EA.PARSETEXT AND AWAIT GETADJUSTEDMAXWIDTH ---
|
||||
const renderedText = text; //(await ea.parseText(text)) ?? text;
|
||||
const metrics = ea.measureText(renderedText);
|
||||
const shouldWrap = metrics.width > curMaxW;
|
||||
let curMaxH = metrics.height;
|
||||
let renderedText=text;
|
||||
let metrics = { w: 0, h: 0 };
|
||||
let shouldWrap = false;
|
||||
let curMaxH = 0;
|
||||
|
||||
if (!imageInfo?.isImagePath && !imageInfo?.imageFile && !embeddableUrl) {
|
||||
renderedText = (await parseText(text)) ?? text;
|
||||
metrics = ea.measureText(renderedText);
|
||||
shouldWrap = metrics.width > curMaxW;
|
||||
curMaxH = metrics.height;
|
||||
|
||||
if (shouldWrap) {
|
||||
const res = await getAdjustedMaxWidth(text, curMaxW);
|
||||
curMaxW = res.width;
|
||||
curMaxH = res.height;
|
||||
}
|
||||
if (shouldWrap) {
|
||||
const res = await getAdjustedMaxWidth(text, curMaxW);
|
||||
curMaxW = res.width;
|
||||
curMaxH = res.height;
|
||||
}
|
||||
}
|
||||
|
||||
if (!parent) {
|
||||
ea.style.strokeColor = multicolor ? defaultNodeColor : st.currentItemStrokeColor;
|
||||
@@ -4948,6 +5047,11 @@ const addNode = async (text, follow = false, skipFinalLayout = false, batchModeA
|
||||
width: imageInfo.width,
|
||||
depth
|
||||
});
|
||||
// Attach the URL to the element's link so we can trace it back
|
||||
if (imageInfo.isExternalImage && newNodeId) {
|
||||
const el = ea.getElement(newNodeId);
|
||||
if (el && !el.link) el.link = imageInfo.path;
|
||||
}
|
||||
} else if (imageInfo?.imageFile) {
|
||||
newNodeId = await addImage({
|
||||
pathOrFile: imageInfo.imageFile,
|
||||
@@ -5102,6 +5206,11 @@ const addNode = async (text, follow = false, skipFinalLayout = false, batchModeA
|
||||
y: py,
|
||||
depth
|
||||
});
|
||||
// Attach the URL to the element's link so we can trace it back
|
||||
if (imageInfo.isExternalImage && newNodeId) {
|
||||
const el = ea.getElement(newNodeId);
|
||||
if (el && !el.link) el.link = imageInfo.path;
|
||||
}
|
||||
} else if (imageInfo?.imageFile) {
|
||||
newNodeId = await addImage({
|
||||
pathOrFile: imageInfo.imageFile,
|
||||
@@ -5236,7 +5345,7 @@ const addNode = async (text, follow = false, skipFinalLayout = false, batchModeA
|
||||
if (groupBranches) {
|
||||
ea.getElements().forEach((el) => {
|
||||
if (el.groupIds) {
|
||||
el.groupIds = el.groupIds.filter(gid => !isMindmapGroup(gid, allEls, rootId));
|
||||
el.groupIds = el.groupIds.filter(gid => !isMindmapGroup(gid, allEls));
|
||||
}
|
||||
});
|
||||
const l1Nodes = getChildrenNodes(rootId, allEls);
|
||||
@@ -5368,13 +5477,24 @@ const getTextFromNode = (all, node, getRaw = false, shortPath = false) => {
|
||||
if (node.type === "image") {
|
||||
const embeddedFile = ea.targetView?.excalidrawData?.getFile(node.fileId);
|
||||
if (!embeddedFile) return "";
|
||||
|
||||
const file = ea.getViewFileForImageElement(node);
|
||||
|
||||
// Handle external image URLs or local file URIs saved in node.link
|
||||
if (!file && node.link && node.link.match(/^(https?|file):\/\//i)) {
|
||||
return ``;
|
||||
}
|
||||
|
||||
if (shortPath) {
|
||||
const originalPath = embeddedFile.linkParts?.original;
|
||||
return `![[${originalPath}|${Math.round(node.width)}]]`;
|
||||
}
|
||||
const file = ea.getViewFileForImageElement(node);
|
||||
|
||||
if (file) {
|
||||
return `![[${file.path}${embeddedFile.filenameparts?.linkpartReference}|${Math.round(node.width)}]]`;
|
||||
if (file.extension === "pdf" && node.link?.startsWith("[[")) {
|
||||
return `!${node.link.match(/^(.*?)\]\]/)[1]}|${Math.round(node.width)}]]`;
|
||||
}
|
||||
return `![[${file.path}${embeddedFile.filenameparts?.linkpartReference || ""}|${Math.round(node.width)}]]`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -6690,18 +6810,21 @@ const changeNodeOrder = async (key) => {
|
||||
|
||||
// Gather all elements in branch + decorations
|
||||
const branchIds = getBranchElementIds(current.id, allElements);
|
||||
|
||||
// Use the specialized function to get decorations and crosslinks
|
||||
// to safely ignore structural groups that might encompass the entire map
|
||||
const decorationAndCrossLinkIds = getDecorationAndCrossLinkIdsForBranches(branchIds, allElements, info.rootId);
|
||||
|
||||
const elementsToMove = new Set();
|
||||
|
||||
branchIds.forEach(id => {
|
||||
const el = allElements.find(x => x.id === id);
|
||||
if (el) {
|
||||
elementsToMove.add(el);
|
||||
// Include attached decorations (grouped elements)
|
||||
if (el.groupIds && el.groupIds.length > 0) {
|
||||
const groupEls = ea.getElementsInTheSameGroupWithElement(el, allElements);
|
||||
groupEls.forEach(gEl => elementsToMove.add(gEl));
|
||||
}
|
||||
}
|
||||
if (el) elementsToMove.add(el);
|
||||
});
|
||||
|
||||
decorationAndCrossLinkIds.forEach(id => {
|
||||
const el = allElements.find(x => x.id === id);
|
||||
if (el) elementsToMove.add(el);
|
||||
});
|
||||
|
||||
const arr = Array.from(elementsToMove);
|
||||
@@ -7076,12 +7199,35 @@ const navigateMap = async ({key, zoom = false, focus = false} = {}) => {
|
||||
const parentCenter = { x: parent.x + parent.width / 2, y: parent.y + parent.height / 2 };
|
||||
|
||||
// Always sort by angle from 12 o'clock (0 degrees) to ensure clockwise navigation
|
||||
// regardless of layout mode or hierarchy level
|
||||
siblings.sort(
|
||||
(a, b) =>
|
||||
getAngleFromCenter(parentCenter, { x: a.x + a.width / 2, y: a.y + a.height / 2 }) -
|
||||
getAngleFromCenter(parentCenter, { x: b.x + b.width / 2, y: b.y + b.height / 2 }),
|
||||
);
|
||||
// regardless of layout mode or hierarchy level.
|
||||
// We project the coordinates to neutralize width/height skewing the geometric center.
|
||||
siblings.sort((a, b) => {
|
||||
const aCX = a.x + a.width / 2;
|
||||
const aCY = a.y + a.height / 2;
|
||||
const bCX = b.x + b.width / 2;
|
||||
const bCY = b.y + b.height / 2;
|
||||
|
||||
let aPoint = { x: aCX, y: aCY };
|
||||
let bPoint = { x: bCX, y: bCY };
|
||||
|
||||
if (mapMode === "Radial") {
|
||||
// Use the edge closest to the parent to neutralize text width/height skew in Radial
|
||||
aPoint.x = aCX >= parentCenter.x ? a.x : a.x + a.width;
|
||||
aPoint.y = aCY >= parentCenter.y ? a.y : a.y + a.height;
|
||||
bPoint.x = bCX >= parentCenter.x ? b.x : b.x + b.width;
|
||||
bPoint.y = bCY >= parentCenter.y ? b.y : b.y + b.height;
|
||||
} else if (isVerticalLayout) {
|
||||
// Neutralize Y distance to sort strictly by X sequentially on each side
|
||||
aPoint.y = parentCenter.y + (aCY >= parentCenter.y ? 100000 : -100000);
|
||||
bPoint.y = parentCenter.y + (bCY >= parentCenter.y ? 100000 : -100000);
|
||||
} else {
|
||||
// Neutralize X distance to sort strictly by Y sequentially on each side
|
||||
aPoint.x = parentCenter.x + (aCX >= parentCenter.x ? 100000 : -100000);
|
||||
bPoint.x = parentCenter.x + (bCX >= parentCenter.x ? 100000 : -100000);
|
||||
}
|
||||
|
||||
return getAngleFromCenter(parentCenter, aPoint) - getAngleFromCenter(parentCenter, bPoint);
|
||||
});
|
||||
|
||||
const idx = siblings.findIndex((s) => s.id === current.id);
|
||||
const startIndex = (idx === -1 ? 0 : idx); // Start at 0 if current isn't found
|
||||
@@ -7196,11 +7342,25 @@ const getBranchElementIds = (nodeId, allElements) => {
|
||||
const getStructuralGroupForNode = (branchIds, workbenchEls, rootId) => {
|
||||
const decorationAndCrossLinkIds = getDecorationAndCrossLinkIdsForBranches(branchIds, workbenchEls, rootId);
|
||||
const elements = workbenchEls.filter(el => branchIds.includes(el.id) || decorationAndCrossLinkIds.includes(el.id));
|
||||
const commonGroupId = ea.getCommonGroupForElements(elements);
|
||||
const structuralGroupId = (commonGroupId && isMindmapGroup(commonGroupId, workbenchEls, rootId)) ? commonGroupId : null;
|
||||
const commonGroupId = getCommonGroupForElements(elements)[0];
|
||||
const structuralGroupId = (commonGroupId && isMindmapGroup(commonGroupId, workbenchEls)) ? commonGroupId : null;
|
||||
return {structuralGroupId, groupedElementIds: structuralGroupId ? elements.map(e => e.id) : []};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} nodeId
|
||||
* @param {*} workbenchEls ExcalidrawAutomate elements on the workbench
|
||||
* @returns the group ID if a structural mindmap group exists for the branch, else null
|
||||
*/
|
||||
const getStructuralGroupsForNode = (branchIds, workbenchEls, rootId) => {
|
||||
const decorationAndCrossLinkIds = getDecorationAndCrossLinkIdsForBranches(branchIds, workbenchEls, rootId);
|
||||
const elements = workbenchEls.filter(el => branchIds.includes(el.id) || decorationAndCrossLinkIds.includes(el.id));
|
||||
const commonGroupIds = getCommonGroupForElements(elements);
|
||||
const structuralGroupIds = commonGroupIds.filter(commonGroupId => isMindmapGroup(commonGroupId, workbenchEls));
|
||||
return {structuralGroupIds, groupedElementIds: elements.map(e => e.id)};
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {*} groupId
|
||||
@@ -7368,9 +7528,15 @@ const toggleBranchGroup = async () => {
|
||||
const workbenchEls = ea.getElements();
|
||||
|
||||
let newGroupId;
|
||||
const {structuralGroupId} = getStructuralGroupForNode(branchIds, workbenchEls, info.rootId);
|
||||
if (structuralGroupId) {
|
||||
removeGroupFromElements(structuralGroupId, workbenchEls);
|
||||
let {structuralGroupIds, groupedElementIds} = getStructuralGroupsForNode(branchIds, workbenchEls, info.rootId);
|
||||
if (structuralGroupIds.length > 0) {
|
||||
//normally there should only be one structural group, however do to a bug in earlier MinMap Builder versions,
|
||||
//some branches may have multiple structural groups for the exact same set of nodes.
|
||||
structuralGroupIds.forEach(structuralGroupId => {
|
||||
if(getViewGroupElements(structuralGroupId).length === groupedElementIds.length) {
|
||||
removeGroupFromElements(structuralGroupId, workbenchEls);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
newGroupId = ea.addToGroup([...branchIds, ...decorationAndCrossLinkIds]);
|
||||
}
|
||||
@@ -7380,7 +7546,9 @@ const toggleBranchGroup = async () => {
|
||||
if (newGroupId) {
|
||||
let selectedGroupIds = {};
|
||||
selectedGroupIds[newGroupId] = true;
|
||||
ea.viewUpdateScene({appState: {selectedGroupIds}})
|
||||
ea.viewUpdateScene({appState: {selectedGroupIds, selectedElementIds: {}}});
|
||||
} else {
|
||||
ea.viewUpdateScene({appState: {selectedGroupIds: {}, selectedElementIds: {[sel.id]: true}}});
|
||||
}
|
||||
|
||||
updateUI();
|
||||
@@ -7537,7 +7705,11 @@ const toggleBox = async (shape = "rectangle") => {
|
||||
const container = allElements.find((el) => el.id === containerId);
|
||||
ea.copyViewElementsToEAforEditing(arrowsToUpdate.concat(sel, container));
|
||||
const textEl = ea.getElement(sel.id);
|
||||
ea.addAppendUpdateCustomData(textEl.id, { isPinned: !!container.customData?.isPinned, mindmapOrder: container.customData?.mindmapOrder });
|
||||
|
||||
// Transfer all custom data from the container back to the text element
|
||||
const dataToCopy = { ...(container.customData || {}) };
|
||||
ea.addAppendUpdateCustomData(textEl.id, dataToCopy);
|
||||
|
||||
textEl.containerId = null;
|
||||
textEl.boundElements =[]; //not null because I will add bound arrows a bit further down
|
||||
ea.getElement(containerId).isDeleted = true;
|
||||
@@ -7558,7 +7730,11 @@ const toggleBox = async (shape = "rectangle") => {
|
||||
|
||||
finalElId = newBindId = rectId;
|
||||
const rect = ea.getElement(rectId);
|
||||
ea.addAppendUpdateCustomData(rectId, { isPinned: !!sel.customData?.isPinned, mindmapOrder: sel.customData?.mindmapOrder });
|
||||
|
||||
// Transfer all custom data from the text element to the new container
|
||||
const dataToCopy = { ...(sel.customData || {}) };
|
||||
ea.addAppendUpdateCustomData(rectId, dataToCopy);
|
||||
|
||||
rect.strokeColor = ea.getCM(sel.strokeColor).stringRGB();
|
||||
rect.strokeWidth = getStrokeWidthForDepth(depth);
|
||||
rect.roughness = getAppState().currentItemRoughness;
|
||||
@@ -7646,7 +7822,7 @@ const toggleBoundary = async () => {
|
||||
roundness: arrowType === "curved" ? {type: 2} : null,
|
||||
};
|
||||
|
||||
if (sel.groupIds.length > 0 && isMindmapGroup(sel.groupIds[0], ea.getViewElements(), info?.rootId)) {
|
||||
if (sel.groupIds.length > 0 && isMindmapGroup(sel.groupIds[0], ea.getViewElements())) {
|
||||
boundaryEl.groupIds = [sel.groupIds[0]];
|
||||
} else {
|
||||
boundaryEl.groupIds = [];
|
||||
@@ -7890,7 +8066,7 @@ const updateUI = (sel) => {
|
||||
|
||||
const updateGroupBtn = (btn) => {
|
||||
if (!btn) return;
|
||||
const isGrouped = branchIds.length > 1 && !!ea.getCommonGroupForElements(all.filter(el => branchIds.includes(el.id)));
|
||||
const isGrouped = branchIds.length > 1 && !!getCommonGroupForElements(all.filter(el => branchIds.includes(el.id)))[0];
|
||||
btn.setIcon(isGrouped ? "ungroup" : "group");
|
||||
const groupTooltip = isGrouped ? t("TOGGLE_GROUP_TOOLTIP_UNGROUP") : t("TOGGLE_GROUP_TOOLTIP_GROUP");
|
||||
btn.setTooltip(`${groupTooltip} ${getActionHotkeyString(ACTION_TOGGLE_GROUP)}`);
|
||||
@@ -8162,6 +8338,11 @@ const commitEdit = async () => {
|
||||
width: imageInfo.width,
|
||||
depth,
|
||||
});
|
||||
// Check for external image flag and append to link to preserve routing
|
||||
if (imageInfo.isExternalImage && newNodeId) {
|
||||
const el = ea.getElement(newNodeId);
|
||||
if (el && !el.link) el.link = imageInfo.path;
|
||||
}
|
||||
} else {
|
||||
newNodeId = await addImage({
|
||||
pathOrFile: imageInfo.imageFile,
|
||||
@@ -8190,7 +8371,7 @@ const commitEdit = async () => {
|
||||
}
|
||||
ea.style.roughness = getAppState().currentItemRoughness;
|
||||
|
||||
const renderedText = await ea.parseText(textInput);
|
||||
const renderedText = await parseText(textInput);
|
||||
const metrics = ea.measureText(renderedText);
|
||||
const shouldWrap = metrics.width > maxWidth;
|
||||
|
||||
@@ -8214,10 +8395,11 @@ const commitEdit = async () => {
|
||||
autoResize: boxChildren ? false : !shouldWrap
|
||||
});
|
||||
|
||||
containerToUpdate = boxChildren ? ea.getElement(newNodeId) : null;
|
||||
const newElement = ea.getElement(newNodeId);
|
||||
containerToUpdate = boxChildren ? newElement : null;
|
||||
|
||||
// Explicitly overwrite raw, original and text properties to handle links correctly
|
||||
newTextElement = boxChildren ? ea.getElement(containerToUpdate.boundElements[0].id) : containerToUpdate;
|
||||
newTextElement = boxChildren ? ea.getElement(containerToUpdate.boundElements[0].id) : newElement;
|
||||
newTextElement.rawText = textInput;
|
||||
newTextElement.originalText = renderedText;
|
||||
newTextElement.text = finalWrappedText;
|
||||
@@ -8361,7 +8543,7 @@ const commitEdit = async () => {
|
||||
ea.copyViewElementsToEAforEditing([textEl]);
|
||||
const eaEl = ea.getElement(textEl.id);
|
||||
|
||||
const renderedText = await ea.parseText(textInput);
|
||||
const renderedText = await parseText(textInput);
|
||||
|
||||
eaEl.rawText = textInput;
|
||||
eaEl.originalText = renderedText;
|
||||
@@ -8877,7 +9059,7 @@ const renderInput = (container, isFloating = false) => {
|
||||
inputRow.controlEl.style.width = "100%";
|
||||
inputRow.controlEl.style.marginTop = "8px";
|
||||
} else {
|
||||
container.style.width = "70vw";
|
||||
container.style.width = "85vw";
|
||||
container.style.maxWidth = "calc((var(--icon-size) + 2 * var(--size-2-3)) * 17)";
|
||||
inputRow.settingEl.style.border = "none";
|
||||
inputRow.settingEl.style.padding = "0";
|
||||
@@ -9801,6 +9983,7 @@ const registerStyles = () => {
|
||||
" overflow: hidden;",
|
||||
" scrollbar-width: none;",
|
||||
"}",
|
||||
".excalidraw-mindmap-ui .modal-header-button {display: none;}",
|
||||
// Focus styles
|
||||
".excalidraw-mindmap-ui button:focus,",
|
||||
".excalidraw-mindmap-ui .clickable-icon:focus,",
|
||||
@@ -9897,9 +10080,11 @@ const toggleDock = async ({silent=false, forceDock=false, saveSetting=false} = {
|
||||
if (isUndocked) {
|
||||
// UNDOCK: Initialize floating modal
|
||||
floatingInputModal = new ea.FloatingModal(ea.plugin.app);
|
||||
const { contentEl, titleEl, modalEl, headerEl } = floatingInputModal;
|
||||
const { contentEl, titleEl, modalEl, headerEl, bgEl } = floatingInputModal;
|
||||
modalEl.classList.add("excalidraw-mindmap-ui");
|
||||
|
||||
if (bgEl) {
|
||||
bgEl.style.display="none";
|
||||
}
|
||||
floatingInputModal.onOpen = () => {
|
||||
// Reparent modal to target view window
|
||||
if (ea.targetView && modalEl.ownerDocument !== ea.targetView.ownerDocument) {
|
||||
@@ -9926,9 +10111,13 @@ const toggleDock = async ({silent=false, forceDock=false, saveSetting=false} = {
|
||||
//otherwise the event handlers in FloatingModal would override the move
|
||||
//leaving modalEl in the center of the view
|
||||
//modalEl.style.top and left must stay in the timeout call
|
||||
modalEl.style.top = `${ y + FLOAT_MODAL_OFFSET }px`;
|
||||
const {x, y} = ea.targetView.contentEl.getBoundingClientRect();
|
||||
const desktopShift = !!ea.targetView.contentEl.querySelector(".App-bottom-bar .App-toolbar")
|
||||
? 0
|
||||
: (ea.targetView.contentEl.clientWidth < 1200 ? 36 : 0);
|
||||
modalEl.style.top = `${ y + FLOAT_MODAL_OFFSET + desktopShift}px`;
|
||||
modalEl.style.left = `${ x + FLOAT_MODAL_OFFSET }px`;
|
||||
}, 100);
|
||||
}, ea.DEVICE.isMobile ? 400:150);
|
||||
};
|
||||
|
||||
floatingInputModal.onClose = () => {
|
||||
@@ -10008,7 +10197,7 @@ const handleKeydown = (e) => {
|
||||
if (!currentWindow) return;
|
||||
|
||||
const st = getAppState();
|
||||
if (!st || !!st.editingTextElement || !!st.selectedLinearElement?.isEditing || !!st.showHyperlinkPopup) return;
|
||||
if (!st || !!st.editingTextElement || !!st.selectedLinearElement?.isEditing || (st.showHyperlinkPopup === "editor")) return;
|
||||
|
||||
if (linkSuggester?.isBlockingKeys()) {
|
||||
if (e.key === "Escape") {
|
||||
|
||||
+382
-370
File diff suppressed because it is too large.
Load diff
+642
-354
File diff suppressed because it is too large.
Load diff
@@ -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":1767536720161},{"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":1767536720161},{"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
|
||||
+21
-4
@@ -1,6 +1,14 @@
|
||||
If you are enjoying the Excalidraw plugin then please support my work and enthusiasm by buying me a coffee on [https://ko-fi/zsolt](https://ko-fi.com/zsolt).
|
||||
<div style="text-align:center;margin-bottom:20px;">
|
||||
<a href="https://community.sketch-your-mind.com/em" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EM.png" style="width:50%; max-width: 200px;"></a>
|
||||
</div>
|
||||
|
||||
[<img src="https://user-images.githubusercontent.com/14358394/115450238-f39e8100-a21b-11eb-89d0-fa4b82cdbce8.png" class="coffee">](https://ko-fi.com/zsolt)
|
||||
**It looks like you want to get more out of Excalidraw!**
|
||||
|
||||
Scripts are a true superpower in Excalidraw. If you are ready to eliminate tool friction and build heavy-duty workflows, join[Excalidraw Mastery](https://community.sketch-your-mind.com/em). Master Excalidraw and Visual PKM alongside a supportive community of fellow visual thinkers in the [Sketch Your Mind Community](https://community.sketch-your-mind.com)!
|
||||
|
||||
---
|
||||
|
||||
If you are enjoying the Excalidraw plugin then please support my work and enthusiasm by buying me a coffee on [https://ko-fi/zsolt](https://ko-fi.com/zsolt). [<img src="https://user-images.githubusercontent.com/14358394/115450238-f39e8100-a21b-11eb-89d0-fa4b82cdbce8.png" class="coffee">](https://ko-fi.com/zsolt)
|
||||
|
||||
---
|
||||
|
||||
@@ -13,6 +21,16 @@ Script Engine scripts are installed in the `Downloaded` subfolder of the `Excali
|
||||
|
||||
In the `Command Palette` installed scripts are prefixed with `Downloaded/`, thus you can always know if you are executing a local script of your own, or one that you have downloaded from GitHub.
|
||||
|
||||
## Create Your Own Scripts with AI Superpowers
|
||||
|
||||
You don't need to know how to code to build custom scripts! In this video, I show how to create powerful, custom Excalidraw scripts from scratch using the power of AI.
|
||||
|
||||
Follow along as I generate a complete Layer Manager script for Excalidraw in Obsidian, allowing you to hide, show, lock, and manage elements on different layers. I'll walk you through the entire process, from using a custom training library for Excalidraw Automate to prompting Google's Gemini AI Studio to write the code for us. Discover how to unlock a true superpower for your Obsidian and Excalidraw workflow by generating any script you can imagine.
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://youtu.be/6BjhUyfS4iM" target="_blank"><img src="https://i.ytimg.com/vi/6BjhUyfS4iM/maxresdefault.jpg" style="width:560px;"></a>
|
||||
</div>
|
||||
|
||||
## Attention developers and hobby hackers
|
||||
<img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/hobby-programmer.svg' align='left' style='background-color:whitesmoke; width:80px; margin-right:15px; margin-bottom:10px;'/>
|
||||
If you want to modify scripts, I recommend moving them to the `Excalidraw Automate script folder` or a different subfolder under the script folder. Scripts in the `Downloaded` folder will be overwritten when you click the `Update this script` button. Note also, that at this time, I do not check if the script file has been updated on GitHub, thus the `Update this script` button is always visible once you have installed a script, not only when an update is available (hope to build this feature in the future).
|
||||
@@ -20,8 +38,7 @@ If you want to modify scripts, I recommend moving them to the `Excalidraw Automa
|
||||
I would love to include your contribution in the script library. If you have a script of your own that you would like to share with the community, please open a [PR](https://github.com/zsviczian/obsidian-excalidraw-plugin/pulls) on GitHub. Be sure to include the following in your pull request
|
||||
- The [script file](https://github.com/zsviczian/obsidian-excalidraw-plugin/tree/master/ea-scripts) with a self explanetory name. The name of the file will be the name of the script in the Command Palette.
|
||||
- An [image](https://github.com/zsviczian/obsidian-excalidraw-plugin/tree/master/images) explaining the scripts purpose. Remember a picture speaks thousand words!
|
||||
- An update to this file [ea-scripts/index-new.md](https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/index-new.md)
|
||||
|
||||
- An update to this file[ea-scripts/index-new.md](https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/index-new.md)
|
||||
---
|
||||
|
||||
# List of available scripts
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.21.2",
|
||||
"minAppVersion": "1.5.7",
|
||||
"version": "2.22.3",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "Sketch Your Mind. An Obsidian plugin to edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
"authorUrl": "https://excalidraw-obsidian.online",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.21.2",
|
||||
"version": "2.22.3",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "Sketch Your Mind. An Obsidian plugin to edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
Generated
+84
-200
File diff suppressed because it is too large.
Load diff
+3
-3
@@ -25,7 +25,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-86",
|
||||
"@zsviczian/excalidraw": "0.18.0-90",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
@@ -63,7 +63,7 @@
|
||||
"@types/chroma-js": "^3.1.1",
|
||||
"@types/js-beautify": "^1.14.0",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/node": "^20.10.5",
|
||||
"@types/node": "20.19.37",
|
||||
"@types/opentype.js": "^1.3.8",
|
||||
"@types/react": "^18.2.45",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
@@ -84,7 +84,7 @@
|
||||
"rollup-plugin-typescript2": "^0.36.0",
|
||||
"tslib": "^2.8.1",
|
||||
"ttypescript": "^1.5.15",
|
||||
"typescript": "^5.7.3",
|
||||
"typescript": "5.9.3",
|
||||
"fs-extra": "^11.2.0",
|
||||
"uglify-js": "^3.19.3"
|
||||
},
|
||||
|
||||
@@ -31,6 +31,7 @@ export const getIconAsJSX = (iconId: string) => {
|
||||
|
||||
export const ICONS = {
|
||||
ExportImage: getIconAsJSX("image-down"),
|
||||
Info: getIconAsJSX("info"),
|
||||
BackOfNote: getIconAsJSX("text-select"),
|
||||
Reload: getIconAsJSX("rotate-ccw"),
|
||||
Copy: getIconAsJSX("copy"),
|
||||
@@ -55,21 +56,6 @@ export const ICONS = {
|
||||
</svg>
|
||||
),
|
||||
Learn: getIconAsJSX("graduation-cap"),
|
||||
Discord: (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="var(--icon-fill-color)"
|
||||
stroke="none"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
viewBox="0 0 640 512"
|
||||
>
|
||||
<path
|
||||
d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
Github: getIconAsJSX("github"),
|
||||
YouTube: getIconAsJSX("youtube"),
|
||||
heart: getIconAsJSX("heart"),
|
||||
|
||||
@@ -515,3 +515,5 @@ export const DISK_ICON_NAME = "save";
|
||||
export const EXPORT_IMG_ICON = ` <g transform="scale(4.166)" strokeWidth="1.25" fill="none" stroke="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M15 8h.01"></path><path d="M12 20h-5a3 3 0 0 1 -3 -3v-10a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v5"></path><path d="M4 15l4 -4c.928 -.893 2.072 -.893 3 0l4 4"></path><path d="M14 14l1 -1c.617 -.593 1.328 -.793 2.009 -.598"></path><path d="M19 16v6"></path><path d="M22 19l-3 3l-3 -3"></path></g>`;
|
||||
export const EXPORT_IMG_ICON_NAME = `export-img`;
|
||||
export const EXCALIDRAW_ICON = `<path d="M24 17h121v121H24z" style="fill:none" transform="matrix(.8843 0 0 .83471 -21.223 -14.19)"/><path d="M119.81 105.98a.549.549 0 0 0-.53-.12c-4.19-6.19-9.52-12.06-14.68-17.73l-.85-.93c0-.11-.05-.21-.12-.3a.548.548 0 0 0-.34-.2l-.17-.18-.12-.09c-.15-.32-.53-.56-.95-.35-1.58.81-3 1.97-4.4 3.04-1.87 1.43-3.7 2.92-5.42 4.52-.7.65-1.39 1.33-1.97 2.09-.28.37-.07.72.27.87-1.22 1.2-2.45 2.45-3.68 3.74-.11.12-.17.28-.16.44.01.16.09.31.22.41l2.16 1.65s.01.03.03.04c3.09 3.05 8.51 7.28 14.25 11.76.85.67 1.71 1.34 2.57 2.01.39.47.76.94 1.12 1.4.19.25.55.3.8.11.13.1.26.21.39.31a.57.57 0 0 0 .8-.1c.07-.09.1-.2.11-.31.04 0 .07.03.1.03.15 0 .31-.06.42-.18l10.18-11.12a.56.56 0 0 0-.04-.8l.01-.01Zm-29.23-3.85c.07.09.14.17.21.25 1.16.98 2.4 2.04 3.66 3.12l-5.12-3.91s-.32-.22-.52-.36c-.11-.08-.21-.16-.31-.24l-.38-.32s.07-.07.1-.11l.35-.35c1.72-1.74 4.67-4.64 6.19-6.06-1.61 1.62-4.87 6.37-4.17 7.98h-.01Zm17.53 13.81-4.22-3.22c-1.65-1.71-3.43-3.4-5.24-5.03 2.28 1.76 4.23 3.25 4.52 3.51 2.21 1.97 2.11 1.61 3.63 2.91l1.83 1.33c-.18.16-.36.33-.53.49l.01.01Zm1.06.81-.08-.06c.16-.13.33-.25.49-.38l-.4.44h-.01Zm-66.93-65.3c.14.72.27 1.43.4 2.11.69 3.7 1.33 7.03 2.55 9.56l.48 1.92c.19.73.46 1.64.71 1.83 2.85 2.52 7.22 6.28 11.89 9.82.21.16.5.15.7-.01.01.02.03.03.04.04.11.1.24.15.38.15.16 0 .31-.06.42-.19 5.98-6.65 10.43-12.12 13.6-16.7.2-.25.3-.54.29-.84.2-.24.41-.48.6-.68a.558.558 0 0 0-.1-.86.578.578 0 0 0-.17-.36c-1.39-1.34-2.42-2.31-3.46-3.28-1.84-1.72-3.74-3.5-7.77-7.51-.02-.02-.05-.04-.07-.06a.555.555 0 0 0-.22-.14c-1.11-.39-3.39-.78-6.26-1.28-4.22-.72-10-1.72-15.2-3.27h-.04v-.01s-.02 0-.03.02h-.01l.04-.02s-.31.01-.37.04c-.08.04-.14.09-.19.15-.05.06-.09.12-.47.2-.38.08.08 0 .11 0h-.11v.03c.07.34.05.58.16.97-.02.1.21 1.02.24 1.11l1.83 7.26h.03Zm30.95 6.54s-.03.04-.04.05l-.64-.71c.22.21.44.42.68.66Zm-7.09 9.39s-.07.08-.1.12l-.02-.02c.04-.03.08-.07.13-.1h-.01Zm-7.07 8.47Zm3.02-28.57c.35.35 1.74 1.65 2.06 1.97-1.45-.66-5.06-2.34-6.74-2.88 1.65.29 3.93.66 4.68.91Zm-19.18-2.77c.84 1.44 1.5 6.49 2.16 11.4-.37-1.58-.69-3.12-.99-4.6-.52-2.56-1-4.85-1.67-6.88.14.01.31.03.49.05 0 .01 0 .02.02.03h-.01Zm-.29-1.21c-.23-.02-.44-.04-.62-.05-.02-.04-.03-.08-.04-.12l.66.18v-.01Zm-2.22.45v-.02.02Zm78.54-1.18c.04-.23-1.1-1.24-.74-1.26.85-.04.86-1.35 0-1.31-1.13.06-2.27.32-3.37.53-1.98.37-3.95.78-5.92 1.21-4.39.94-8.77 1.93-13.1 3.11-1.36.37-2.86.7-4.11 1.36-.42.22-.4.67-.17.95-.09.05-.18.08-.28.09-.37.07-.74.13-1.11.19a.566.566 0 0 0-.39.86c-2.32 3.1-4.96 6.44-7.82 9.95-2.81 3.21-5.73 6.63-8.72 10.14-9.41 11.06-20.08 23.6-31.9 34.64-.23.21-.24.57-.03.8.05.06.12.1.19.13-.16.15-.32.3-.48.44-.1.09-.14.2-.16.32-.08.08-.16.17-.23.25-.21.23-.2.59.03.8.23.21.59.2.8-.03.04-.04.08-.09.12-.13a.84.84 0 0 1 1.22 0c.69.74 1.34 1.44 1.95 2.09l-1.38-1.15a.57.57 0 0 0-.8.07c-.2.24-.17.6.07.8l14.82 12.43c.11.09.24.13.37.13.15 0 .29-.06.4-.17l.36-.36a.56.56 0 0 0 .63-.12c20.09-20.18 36.27-35.43 54.8-49.06.17-.12.25-.32.23-.51a.57.57 0 0 0 .48-.39c3.42-10.46 4.08-19.72 4.28-24.27 0-.03.01-.05.02-.07.02-.05.03-.1.04-.14.03-.11.05-.19.05-.19.26-.78.17-1.53-.15-2.15v.02ZM82.98 58.94c.9-1.03 1.79-2.04 2.67-3.02-5.76 7.58-15.3 19.26-28.81 33.14 9.2-10.18 18.47-20.73 26.14-30.12Zm-32.55 52.81-.03-.03c.11.02.19.04.2.04a.47.47 0 0 0-.17 0v-.01Zm6.9 6.42-.05-.04.03-.03c.02 0 .03.02.04.02 0 .02-.02.03-.03.05h.01Zm8.36-7.21 1.38-1.44c.01.01.02.03.03.05-.47.46-.94.93-1.42 1.39h.01Zm2.24-2.21c.26-.3.56-.65.87-1.02.01-.01.02-.03.04-.04 3.29-3.39 6.68-6.82 10.18-10.25.02-.02.05-.04.07-.06.86-.66 1.82-1.39 2.72-2.08-4.52 4.32-9.11 8.78-13.88 13.46v-.01Zm21.65-55.88c-1.86 2.42-3.9 5.56-5.63 8.07-5.46 7.91-23.04 27.28-23.43 27.65-2.71 2.62-10.88 10.46-16.09 15.37-.14.13-.25.24-.34.35a.794.794 0 0 1 .03-1.13c24.82-23.4 39.88-42.89 46-51.38-.13.33-.24.69-.55 1.09l.01-.02Zm16.51 7.1-.01.02c0-.02-.02-.07.01-.02Zm-.91-5.13Zm-5.89 9.45c-2.26-1.31-3.32-3.27-2.71-5.25l.19-.66c.08-.19.17-.38.28-.57.59-.98 1.49-1.85 2.52-2.36.05-.02.1-.03.15-.04a.795.795 0 0 1-.04-.43c.05-.31.25-.58.66-.58.67 0 2.75.62 3.54 1.3.24.19.47.4.68.63.3.35.74.92.96 1.33.13.06.23.62.38.91.14.46.2.93.18 1.4 0 .02 0 .02.01.03-.03.07 0 .37-.04.4-.1.72-.36 1.43-.75 2.05-.04.05-.07.11-.11.16 0 .01-.02.02-.03.04-.3.43-.65.83-1.08 1.13-1.26.89-2.73 1.16-4.2.79a6.33 6.33 0 0 1-.57-.25l-.02-.03Zm16.27-1.63c-.49 2.05-1.09 4.19-1.8 6.38-.03.08-.03.16-.03.23-.1.01-.19.05-.27.11-4.44 3.26-8.73 6.62-12.98 10.11 3.67-3.32 7.39-6.62 11.23-9.95a6.409 6.409 0 0 0 2.11-3.74l.56-3.37.03-.1c.25-.71 1.34-.4 1.17.33h-.02Z" style="fill:currentColor;fill-rule:nonzero" transform="translate(-26.41 -29.49)"/>`;
|
||||
|
||||
export const LOGO_EXCALIDRAW_MASTERY = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAADECAYAAADApo5rAAAQAElEQVR4AeydB5xU1fn3n1lQEaWIBV0pSwdB0bAWgsCuDWPsRo389QWUptFoYmJMVFiwxBaTqImIRECxJ7H3sgtobGgUKzYWVGpARGwI7Hu/9865c26buTNzp+zu8OHZ0+t9fud5nnPOvVMmpX+lGSjNgD0DJUDYU5Ejz8SJFQKNHVsl48aNtmn8+Mmi04QJMx1hPS9loRx1sVRtYgZKgEjMReY+GB4GVgw+blytwfi1BoM3yJYti00qK6uVWGymTSI1olNDw2hHWM9LWWj8+AajzsUm0QYgol2oBBhj+rL/XwJEunMI88N8MD9MCZPC9DCwYvBYrMpg/Kp0qw6Zv8LIV2HWD4hoF7IAs9gEogIKfTUyl/6Hn4ESIFLNFUzlZn6YT6TGZEopqn9OoADU8eMXSwkgoR9SIwJE6DFln1GBAGaCqSJg/ooOO4iiqp7dRdHo/SpFJxWPq/LjZjGoClGShLEwJgCOlMui0qZatKypDiztccEgMIpSgQCBSIWE/AfTwsQw9+TDDxWo9uwJsnjS76XhL1ebLn6o9uyJomjmyJNEJxWPS143USf5qZ+2aDNkF1U2xlQjSDnAoaSHSm3mbvMGREISNJgMYoEgJUvA/BBMCXMqhoeJCdcYgICqevYwpULKCkNkoD2IOgEC9dMWbar2CZNWZUigEFWSJSE9AAcLAgsDKc2UmicgePAYxKgQIUBgMWJ3x6rPyg1TwoDFwDv0kb4ACj+QhOijU3KwcxWiUFPL0nwAoUsDQMBOUJKnCYMhAVBRYH6YDABUGat+kmJFlcQYFEisMUwwQV2VWoJUGBsGnItYBjlzV1Qjy11nmj4geJhIhBDSAAYCBDAPlDEAcve8Mq6ZsVUZYGZMgJvxIU2qkoPDUqm2bKk1d6qYy4x70DgKNl1A8PBCAAFGcYOAuHw8vvolS6Xm8iulbt4L+WjO0QZjRHoocDAHjgzOgAKGJTGasJ3R9AABENg5SSERYAiYgJWSVZOwkwdyG5o1507p1m8vmWIAovrwn5rAyG2LwbUzduaAuUgpNdjCZYeKOW6CwGg6gAAISiLw0AKevwIBDx8mCMiWs2glFcaMP8vRxmwDIJa0eN4Rn88AwAgtNZhjBQzmPp8dzWFbTQMQCggYywGTBRDYngQEPPiAbJFFz5pzl8wymLxu3vMCCPDD8EoqqIaqhh5oesljSYsjTckBYMgPURYSiUm+/jFHzBULB3MX2C7AwMbgGQRmajwJjRsQiGz2zwOAwEPlYSog5OuxwPRjxp8pMHX14QkGh+H1Pky+6EKZOf3vgqvHAw4AQH6IeqBu/fbUs0XiT1UJcxgCGBVGPTXmpUOeiRForP8bJyAQ0eiwiOyA02SAwOrGw8z3w4Ghk7WJVFj83kKpMQBBPlzCAIM04oqNQgODZ8Kz4RkV2yBC9KfxAYIDIwxmRLXPANGB8y0R3N2AsVUcDD761JECEQ/j1z75iJlcPcKSHkgUJALAII08ENKjomsXMy9/Rhn14BaSQgGDZ9NI1ajGAwhWHE6XuerswxE8KA7R2CXxSc5rFCBQDQ4fdqCpFsHcMLxicFSguvmWAY1EQTXC3qAceSDqIY04iPK4xUDMN9IXKYzfp0+WGsUz49n5ZCjGqMYBCPRSpILP6TIPQ6lHVcbBUzFMMsys+sHukfIrF2mgwKDnBRQqD64eRroQV2zE/HOWwTPw7RvPDGmBZPfNUFyRxQ8Idi/QS33mDfWIFYqVyie5YFEwOas7HWCFVys/YTfpalD90qWOZAUaIqkTtxgJUPAMeBYBwKgQJDvPMvMB5KVk8QICMYu49dlB4gEUi3oU9JRQlVSaztgqzs+t6JKwF0gHTLgQNghuMRPPBWAkUVutnSiebZEOpDgBkURFqurZ3Xy3oKpI1KOg56okBOlzjbMIXEU64+tqkS4FUKtU/sYABtVXXCW5q4xnRdhFFVLEKlTxAQJdM0BFQhyjr7omuCiDOnO7VaEqw9DWAaMGoKtPOoj0eJW32F2kxcyRJ5u3a336igplfXXEJ7GQUcUFCHRMdE3XjDC5qEiIY1dS0QYBhGJ6VB+3HcGuk0onb+0TjwhAUQPSJYQer9Ibg8tz45lhW+B39bnCCKNCTTbcovlfPIAIsBcQu0xoVZGrSH5PFEZX8W47gjTOHBq+WSecOehMr4OhsalLary6CxiQ7Eh4PT7urzG/FBIPFNqJBhDZjAIDCzCwPeeqB12UiXRFN5pgV+1QTVeBUg0AiaLy6Ma5imuMLqDgefqCgmfPFRx4ocCDKywgmIDNm2caW3JV7nmYGX/53h3fmMJKJaLPbjuCuCBasiSx/arXEZS/scQDClQoX1BwBQdjG54o4IAKBwgGHgAG7AVWkwLOSyRNoxYphmbVh8JUrKtX1BGmTGPKAyhQg336bO1AwRs+ifmIKgwgGLAPGFhBAENjtBf8HhbMrKs8YQERNp9fm40ljmcNKHBdfS4oKPIPiCRgYIKaChjUQ1YSgrC+8hP2Ix0MTcGg9hujigMM2Ii4Ki7uFgwU+QVECjDEJyOnTiErD2NY66DRjfJC9juXbQOGYgJF/gDRTMGA2qQYKh3DWpVpDm4xgSJ/gAiwGVCTmvJDBxBKbdLVoaAx63koG5SvqcWnBEWeBpwfQPicMzABTR0Mfs/QfWLtzqNvuep3ntz5mmIYnghUn3gLLw+Dzj0grOsYjnMGBt6cwJDpSp9puTzwTc6agDd8QcFbePBSzlq2Ks4tILi1KlIjrn8curmimk0wDTui2cyJe6AKFO54I5zzu0+5AwRg8Lm1Wuhzhg0bvhbUlrvv+5esWLnSmOPc/9d3i5SN8N333xvtr5Jvvv1WGrQuqHQtKmvvylWr5P6HHpE77r7XHPt3332XdZ1hK9DbfuqZ5+TL9etDFbVAMcEv72iBt/xSIojLDSDYUfIBA5Ih3+cMDQ0N5neRJl/2R+m7977SZpfdhU/DnDLqDLl4ymWyadOmCKYxeRW66kN/Pl+2XBZ98KHALB9+9LG8/c47snzFStmyZYvoebMBxw8//CCAvueAfWTXit5y/M9PlVNPH2+OvW3HznLZldfI119/k7zjGaZS76zb7xR32yOOPl7a79pFTjp1tHz2+bKUtcMrM0ee5M5XIWVlM80fsnSnRBDODSDYUXJ1jqsYkCs6J0GY7oMPP5LzfnuhdCivMD/8NfWKq0wm1Bu8/8FHBIbU43Lh143j1f/7n/xvzRpHM1u2NMiq1avlAwMcGzdudKSlG4AZ//q3abJT5+4C6D/+ZLGnCsByydTLZeD+Q+TV1173pGca8elnn8svzvuNtO3YScZMOEv82qbu+/79gHTfY6DcdsfdwrMiLojgGZ+7TxXG6lEbVCab+OgBgeHD7UWtV1U9u5u/kqNFRe5lYllRWfU7du0lfQZWCoyx7ssvA9ta+8UXMu+F/wSmR5Xwn5detqtqMJjfDrg83xtqVLv27Vyx4YIA4err/io7d+luLgTr13+VsiAMO+SgEaEYM1lliwxphwTq0ru//H36DINXtyTLbqYBylHjJsp11/8tFCgAhlkw8afC/CJ5IhyJL1pAjB1bZfTKYURbuuBEIzo3/1E7YIROPfuZkuDyq64VVuGwrT39bG3O1CbUAhjloppLw3ZHkgHGr5Jvv/1Obp09R8p79JHfXTxZCPvlC4qDMVnNZ8+5S1hUgvK548m78O135LCjjpO+e+9r2ijuPGHCF1w0Sf794MNJs8JDSAkWVkdGdp4snnNEZxOIFhDodq7ezPTqgK4c6QdZDefcdY/sc8BQUz+GEZYtX5F+RUaJBa//19DlVxu+6P7DlIAUtQBjVq+5vHxXPZjU/+DDjwamb968We791/2GXVQpZ5x5toSRCEGVbTFsF+pIxZiUV0D4cfVhMnC/IcKCQnymRNtjzzxHXlnwWtIqAMXMkSd788Bz2KzelIxiogMEh2/cade6YaG6hxaTuRcGQPX46XEnmTrqaWdMkDcWvpV5hfGSSz/9TN57f1E8lJ1DH++695/Stc8Ac7Vm9U23xspB+9hF7rv/Ac+qrRhycNWhcvJpY4T+2wWy8MCYE8/5lbzz3vuBtbxrpGEYA4SXXnk1MF+6Cai1p0/4hWlHJStrgcLHyG5oiOw11GgAwYcBfOyGmsMPTTa+UGkYaudfeJG5O4S++9iTT4XSUUNVbmSCwWrnzTd8mf+njpdfXSCDDSYdOXpsUpWt8kcJhvdrsXy3hARZuWq16JIPFeyEU04zV+YojWHVD4z9Cy+u8ahdiwwb4ZgTT5H+gw7IWiKottwuQLzi6j95FgB3PmwJX9UJ29WdOYNw9oBAXPl8GGCmn3gL2UFUIrVth6GG4YUaErJ42tleePEl4Xwi7YJGgUUGsxx70kg5YPghoXZsynfbzSgV/J90BRq2hBfXLzG3R6+89s/mzoxbBQuuKbOUR594Uh5/6mmzMGMDCGxXP/To42ZcLv/cdMut8vx/XkrZxEyDt5AWroyjo9iKzR4QPlusHL75dNjVf2cQdeM/xm4MakCqbTtnyexDb739rnz62WdpVYSYP/H/Rhk6/L4SllnaGztI04yHrmiSsfWJ/uymZcuX231hexSD+feTpohbBWvfvr2dLyoP0o4t6qNO+HlaY4uifbacsb1SLX7wFuq4q80K8eFFVx6RFBHZAQIL36UqWSItvN2wZu1aYRJ269ZHUIkwFNFnU/Q70mS2Xz/8+JO06vzWOGFOZQi6K1y37kuZNuNWmwASRr2bdDWpzlDnggzmdevWyY47dnA3k3X4zbfelkcefyLrejKpAAk193nrI9DJysNnkCMPvAhPOiLTC2QHiFjMY8z4INfTI1YhDLT/N3ai7NSpu2mAprNV6qkwgohnnqtLu5avv/467
Line truncated
|
||||
+47
-6
@@ -111,6 +111,13 @@ type FileMasterInfo = {
|
||||
colorMapJSON?: string
|
||||
}
|
||||
|
||||
const PHONE_FOOTER_SAFE_AREA_STYLE_ID = "excalidraw-phone-footer-safe-area";
|
||||
const PHONE_FOOTER_SAFE_AREA_CSS = `
|
||||
.excalidraw .App-bottom-bar {
|
||||
padding-bottom: 50px;
|
||||
}
|
||||
`;
|
||||
|
||||
export default class ExcalidrawPlugin extends Plugin {
|
||||
private fileManager: PluginFileManager;
|
||||
private observerManager: ObserverManager;
|
||||
@@ -153,6 +160,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
public wasPenModeActivePreviously: boolean = false;
|
||||
public popScope: Function = null;
|
||||
public lastPDFLeafID: string = null;
|
||||
public forceExcalidrawViewMode: boolean = false;
|
||||
|
||||
constructor(app: App, manifest: PluginManifest) {
|
||||
super(app, manifest);
|
||||
@@ -401,6 +409,8 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}
|
||||
this.logStartupEvent("Styles manager initialized");
|
||||
|
||||
this.updatePhoneFooterSafeAreaPadding();
|
||||
|
||||
try {
|
||||
this.scriptEngine = new ScriptEngine(this);
|
||||
} catch (e) {
|
||||
@@ -617,6 +627,41 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public updatePhoneFooterSafeAreaPadding() {
|
||||
const documents = new Set<Document>([document, ...this.getOpenObsidianDocuments()]);
|
||||
const shouldEnable = DEVICE.isPhone && this.settings?.phoneFooterSafeAreaPadding;
|
||||
|
||||
documents.forEach((ownerDocument) => {
|
||||
const existingStylesheet = ownerDocument.getElementById(PHONE_FOOTER_SAFE_AREA_STYLE_ID);
|
||||
if (!shouldEnable) {
|
||||
if (existingStylesheet) {
|
||||
ownerDocument.head.removeChild(existingStylesheet);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (existingStylesheet instanceof HTMLStyleElement) {
|
||||
existingStylesheet.textContent = PHONE_FOOTER_SAFE_AREA_CSS;
|
||||
return;
|
||||
}
|
||||
|
||||
const stylesheet = ownerDocument.createElement("style");
|
||||
stylesheet.id = PHONE_FOOTER_SAFE_AREA_STYLE_ID;
|
||||
stylesheet.textContent = PHONE_FOOTER_SAFE_AREA_CSS;
|
||||
ownerDocument.head.appendChild(stylesheet);
|
||||
});
|
||||
}
|
||||
|
||||
private removePhoneFooterSafeAreaPadding() {
|
||||
const documents = new Set<Document>([document, ...this.getOpenObsidianDocuments()]);
|
||||
documents.forEach((ownerDocument) => {
|
||||
const existingStylesheet = ownerDocument.getElementById(PHONE_FOOTER_SAFE_AREA_STYLE_ID);
|
||||
if (existingStylesheet) {
|
||||
ownerDocument.head.removeChild(existingStylesheet);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private getOpenObsidianDocuments(): Document[] {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.getOpenObsidianDocuments,`ExcalidrawPlugin.getOpenObsidianDocuments`);
|
||||
@@ -1209,6 +1254,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.stylesManager = null;
|
||||
|
||||
this.removeFonts();
|
||||
this.removePhoneFooterSafeAreaPadding();
|
||||
|
||||
this.eaInstances.forEach((ea) => ea?.destroy());
|
||||
this.eaInstances.clear();
|
||||
@@ -1260,13 +1306,9 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
terminateCompressionWorker();
|
||||
}
|
||||
|
||||
public async loadSettings(opts: {
|
||||
applyLefthandedMode?: boolean,
|
||||
reEnableAutosave?: boolean
|
||||
} = {applyLefthandedMode: true, reEnableAutosave: false}
|
||||
public async loadSettings(opts: { reEnableAutosave?: boolean } = { reEnableAutosave: false }
|
||||
) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.loadSettings,`ExcalidrawPlugin.loadSettings`, opts);
|
||||
if(typeof opts.applyLefthandedMode === "undefined") opts.applyLefthandedMode = true;
|
||||
if(typeof opts.reEnableAutosave === "undefined") opts.reEnableAutosave = false;
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
if(!this.settings.previewImageType) { //migration 1.9.13
|
||||
@@ -1278,7 +1320,6 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
: PreviewImageType.PNG;
|
||||
}
|
||||
}
|
||||
if(opts.applyLefthandedMode) setLeftHandedMode(this.settings.isLeftHanded);
|
||||
if(opts.reEnableAutosave) this.settings.autosave = true;
|
||||
setDebugging(this.settings.isDebugMode);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
ICON_NAME,
|
||||
IMAGE_TYPES,
|
||||
DEVICE,
|
||||
CaptureUpdateAction,
|
||||
sceneCoordsToViewportCoords,
|
||||
fileid,
|
||||
} from "../../constants/constants";
|
||||
@@ -52,7 +53,7 @@ import {
|
||||
decompress,
|
||||
getImageSize,
|
||||
} from "../../utils/utils";
|
||||
import { extractSVGPNGFileName, getActivePDFPageNumberFromPDFView, isObsidianThemeDark, mergeMarkdownFiles, setExcalidrawView } from "../../utils/obsidianUtils";
|
||||
import { extractSVGPNGFileName, getActivePDFPageNumberFromPDFView, getExcalidrawViews, isObsidianThemeDark, mergeMarkdownFiles, setExcalidrawView } from "../../utils/obsidianUtils";
|
||||
import { getAttachmentsFolderAndFilePath } from "../../utils/pathUtils";
|
||||
import { ExcalidrawElement, ExcalidrawEmbeddableElement, ExcalidrawImageElement, ExcalidrawTextElement, FileId } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { ReleaseNotes } from "../../shared/Dialogs/ReleaseNotes";
|
||||
@@ -105,6 +106,19 @@ export class CommandManager {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private setAllExcalidrawViewsToViewMode(enabled: boolean) {
|
||||
getExcalidrawViews(this.app, true).forEach((view) => {
|
||||
view.updateScene({
|
||||
appState: {
|
||||
viewModeEnabled: enabled,
|
||||
zenModeEnabled: enabled ? false : view.excalidrawAPI?.getAppState()?.zenModeEnabled,
|
||||
},
|
||||
captureUpdate: CaptureUpdateAction.NEVER,
|
||||
});
|
||||
view.toolsPanelRef?.current?.setExcalidrawViewMode(enabled);
|
||||
});
|
||||
}
|
||||
|
||||
public initialize() {
|
||||
try {
|
||||
this.taskbone = new Taskbone(this.plugin);
|
||||
@@ -396,6 +410,17 @@ export class CommandManager {
|
||||
}
|
||||
})
|
||||
|
||||
this.addCommand({
|
||||
id: "excalidraw-toggle-session-view-mode",
|
||||
name: t("TEMPORARY_TOGGLE_VIEW_MODE_FOR_ALL_DRAWINGS"),
|
||||
checkCallback: (checking) => {
|
||||
if (checking) return true;
|
||||
this.plugin.forceExcalidrawViewMode = !this.plugin.forceExcalidrawViewMode;
|
||||
this.setAllExcalidrawViewsToViewMode(this.plugin.forceExcalidrawViewMode);
|
||||
return true;
|
||||
}
|
||||
})
|
||||
|
||||
this.addCommand({
|
||||
id: "excalidraw-download-lib",
|
||||
name: t("DOWNLOAD_LIBRARY"),
|
||||
@@ -1010,13 +1035,10 @@ export class CommandManager {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
(async()=>{
|
||||
const isLeftHanded = this.settings.isLeftHanded;
|
||||
await this.plugin.loadSettings({applyLefthandedMode: false});
|
||||
await this.plugin.loadSettings();
|
||||
this.settings.isLeftHanded = !isLeftHanded;
|
||||
this.plugin.saveSettings();
|
||||
//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(!isLeftHanded);
|
||||
setTimeout(()=>setLeftHandedMode(!isLeftHanded));
|
||||
})()
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -120,7 +120,7 @@ export class EventManager {
|
||||
|
||||
private onLayoutChangeHandler() {
|
||||
if (this.app.workspace.layoutReady) {
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>!!excalidrawView?.refresh && excalidrawView.refresh());
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>!!excalidrawView?.refresh && excalidrawView.refresh());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,12 +142,15 @@ export class EventManager {
|
||||
if (element.type === "image") {
|
||||
const fileinfo = this.plugin.filesMaster.get(element.fileId);
|
||||
if(fileinfo && fileinfo.path) {
|
||||
let path = fileinfo.path;
|
||||
let path = fileinfo.path.split("|")[0]; // strip size anchoring (e.g. |100%)
|
||||
const sourceFile = info.file;
|
||||
const imageFile = this.app.vault.getAbstractFileByPath(path);
|
||||
if(sourceFile && imageFile && imageFile instanceof TFile) {
|
||||
path = this.app.metadataCache.fileToLinktext(imageFile,sourceFile.path);
|
||||
}
|
||||
if (fileinfo.blockrefData) {
|
||||
path = `${path}#${fileinfo.blockrefData.split("|")[0]}`; // strip size anchoring (e.g. |100%)
|
||||
}
|
||||
editorInsertText(editor, getLink(this.plugin, {path}));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -412,6 +412,11 @@ export class PluginFileManager {
|
||||
if (!this.isExcalidrawFile(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.app.workspace.activeLeaf?.view instanceof ExcalidrawView && this.app.workspace.activeLeaf.view.file === file) {
|
||||
this.plugin.lastActiveExcalidrawFilePath = file.path;
|
||||
}
|
||||
|
||||
this.moveBAKFile(oldPath, file.path);
|
||||
|
||||
if (!this.settings.keepInSync) {
|
||||
|
||||
@@ -243,7 +243,8 @@ const _getSVGIMG = async ({filenameParts,theme,cacheReady,img,file,exportSetting
|
||||
}
|
||||
|
||||
//need to remove width and height attributes to support area= embeds
|
||||
svg.removeAttribute("width");
|
||||
//svg.removeAttribute("width");
|
||||
svg.setAttribute("width", "6000");
|
||||
svg.removeAttribute("height");
|
||||
return addSVGToImgSrc(img, svg, cacheReady, cacheKey);
|
||||
}
|
||||
@@ -392,7 +393,7 @@ const getIMG = async (
|
||||
exportSettings,
|
||||
loader,
|
||||
width: imgAttributes.fwidth
|
||||
? (!imgAttributes.fwidth.endsWith("%") ? parseInt(imgAttributes.fwidth) : 1000)
|
||||
? (!imgAttributes.fwidth.endsWith("%") ? parseInt(imgAttributes.fwidth) : 6000)
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -80,9 +80,9 @@ export class ObserverManager {
|
||||
|
||||
setTimeout(()=>{ //run async to avoid blocking the UI
|
||||
const theme = isObsidianThemeDark() ? "dark" : "light";
|
||||
const excalidrawViews = getExcalidrawViews(this.app);
|
||||
const excalidrawViews = getExcalidrawViews(this.app, true);
|
||||
excalidrawViews.forEach(excalidrawView => {
|
||||
if (excalidrawView.file && excalidrawView.excalidrawAPI) {
|
||||
if (excalidrawView.file) {
|
||||
excalidrawView.setTheme(theme);
|
||||
}
|
||||
});
|
||||
|
||||
+182
-40
@@ -10,7 +10,7 @@ import {
|
||||
TextComponent,
|
||||
TFile,
|
||||
} from "obsidian";
|
||||
import { GITHUB_RELEASES, setRootElementSize } from "src/constants/constants";
|
||||
import { GITHUB_RELEASES, LOGO_EXCALIDRAW_MASTERY, setRootElementSize } from "src/constants/constants";
|
||||
import { t } from "src/lang/helpers";
|
||||
import type ExcalidrawPlugin from "src/core/main";
|
||||
import { PenStyle } from "src/types/penTypes";
|
||||
@@ -51,6 +51,7 @@ export interface ExcalidrawSettings {
|
||||
copyLinkToElemenetAnchorTo100: boolean;
|
||||
copyFrameLinkByName: boolean;
|
||||
disableDoubleClickTextEditing: boolean;
|
||||
phoneFooterSafeAreaPadding: boolean;
|
||||
folder: string;
|
||||
cropFolder: string;
|
||||
annotateFolder: string;
|
||||
@@ -179,6 +180,7 @@ export interface ExcalidrawSettings {
|
||||
};
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
excalidrawMasteryPromoCollapsed: boolean;
|
||||
compareManifestToPluginVersion: boolean;
|
||||
showNewVersionNotification: boolean;
|
||||
//mathjaxSourceURL: string;
|
||||
@@ -243,6 +245,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
copyLinkToElemenetAnchorTo100: false,
|
||||
copyFrameLinkByName: false,
|
||||
disableDoubleClickTextEditing: false,
|
||||
phoneFooterSafeAreaPadding: false,
|
||||
folder: "Excalidraw",
|
||||
cropFolder: "",
|
||||
annotateFolder: "",
|
||||
@@ -270,8 +273,8 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
annotateSuffix: "",
|
||||
annotatePrefix: ANNOTATED_PREFIX,
|
||||
annotatePreserveSize: false,
|
||||
displaySVGInPreview: undefined,
|
||||
previewImageType: undefined,
|
||||
displaySVGInPreview: false,
|
||||
previewImageType: PreviewImageType.SVG,
|
||||
renderingConcurrency: 3,
|
||||
allowImageCache: true,
|
||||
allowImageCacheInScene: true,
|
||||
@@ -372,6 +375,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
scriptEngineSettings: {},
|
||||
previousRelease: "0.0.0",
|
||||
showReleaseNotes: true,
|
||||
excalidrawMasteryPromoCollapsed: false,
|
||||
compareManifestToPluginVersion: true,
|
||||
showNewVersionNotification: true,
|
||||
//mathjaxSourceURL: "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js",
|
||||
@@ -471,11 +475,11 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
LinkClickAction: {
|
||||
defaultAction: "new-tab",
|
||||
rules: [
|
||||
{ shift: false, ctrl_cmd: false, alt_opt: false, meta_ctrl: false, result: "active-pane" },
|
||||
{ shift: false, ctrl_cmd: true , alt_opt: false, meta_ctrl: false, result: "new-tab" },
|
||||
{ shift: false, ctrl_cmd: true , alt_opt: true , meta_ctrl: false, result: "new-pane" },
|
||||
{ shift: true , ctrl_cmd: true , alt_opt: true , meta_ctrl: false, result: "popout-window" },
|
||||
{ shift: false, ctrl_cmd: true , alt_opt: false, meta_ctrl: true , result: "md-properties" },
|
||||
{ shift: true, ctrl_cmd: true, alt_opt: false, meta_ctrl: false, result: "active-pane" },
|
||||
{ shift: false, ctrl_cmd: true, alt_opt: false, meta_ctrl: false, result: "new-tab" },
|
||||
{ shift: false, ctrl_cmd: true, alt_opt: true , meta_ctrl: false, result: "new-pane" },
|
||||
{ shift: true , ctrl_cmd: true, alt_opt: true , meta_ctrl: false, result: "popout-window" },
|
||||
{ shift: false, ctrl_cmd: true, alt_opt: false, meta_ctrl: true , result: "md-properties" },
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -550,6 +554,10 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
private requestReloadDrawings: boolean = false;
|
||||
private requestUpdatePinnedPens: boolean = false;
|
||||
private requestUpdateDynamicStyling: boolean = false;
|
||||
private settingsDirty: boolean = false;
|
||||
private settingsRevision: number = 0;
|
||||
private isPersistingSettings: boolean = false;
|
||||
private settingsFocusoutHandler: ((event: FocusEvent) => void) | null = null;
|
||||
private hotkeyEditor: HotkeyEditor;
|
||||
//private reloadMathJax: boolean = false;
|
||||
//private applyDebounceTimer: number = 0;
|
||||
@@ -559,21 +567,12 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
applySettingsUpdate(requestReloadDrawings: boolean = false) {
|
||||
if (requestReloadDrawings) {
|
||||
this.requestReloadDrawings = true;
|
||||
}
|
||||
private markSettingsDirty() {
|
||||
this.settingsDirty = true;
|
||||
this.settingsRevision += 1;
|
||||
}
|
||||
|
||||
async hide() {
|
||||
if(this.plugin.settings.overrideObsidianFontSize) {
|
||||
document.documentElement.style.fontSize = "";
|
||||
setRootElementSize(16);
|
||||
} else if(!document.documentElement.style.fontSize) {
|
||||
document.documentElement.style.fontSize = getComputedStyle(document.body).getPropertyValue("--font-text-size");
|
||||
setRootElementSize();
|
||||
}
|
||||
|
||||
private normalizeSettingsBeforeSave() {
|
||||
this.plugin.settings.scriptFolderPath = normalizePath(
|
||||
this.plugin.settings.scriptFolderPath,
|
||||
);
|
||||
@@ -583,14 +582,80 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
) {
|
||||
this.plugin.settings.scriptFolderPath = "Excalidraw/Scripts";
|
||||
}
|
||||
this.plugin.saveSettings();
|
||||
}
|
||||
|
||||
private async persistDirtySettings() {
|
||||
if (!this.settingsDirty || this.isPersistingSettings) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.isPersistingSettings = true;
|
||||
try {
|
||||
while (this.settingsDirty) {
|
||||
const revisionToSave = this.settingsRevision;
|
||||
this.normalizeSettingsBeforeSave();
|
||||
await this.plugin.saveSettings();
|
||||
if (this.settingsRevision === revisionToSave) {
|
||||
this.settingsDirty = false;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.isPersistingSettings = false;
|
||||
}
|
||||
}
|
||||
|
||||
private detachSettingsFocusoutHandler() {
|
||||
if (!this.settingsFocusoutHandler) {
|
||||
return;
|
||||
}
|
||||
this.containerEl.removeEventListener("focusout", this.settingsFocusoutHandler);
|
||||
this.settingsFocusoutHandler = null;
|
||||
}
|
||||
|
||||
private attachSettingsFocusoutHandler() {
|
||||
this.detachSettingsFocusoutHandler();
|
||||
this.settingsFocusoutHandler = (event: FocusEvent) => {
|
||||
window.setTimeout(() => {
|
||||
if (!this.settingsDirty || !this.containerEl?.isConnected) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nextFocusTarget = (event.relatedTarget as Node | null) ?? this.containerEl.ownerDocument.activeElement;
|
||||
if (nextFocusTarget && this.containerEl.contains(nextFocusTarget)) {
|
||||
return;
|
||||
}
|
||||
|
||||
void this.persistDirtySettings();
|
||||
}, 0);
|
||||
};
|
||||
this.containerEl.addEventListener("focusout", this.settingsFocusoutHandler);
|
||||
}
|
||||
|
||||
applySettingsUpdate(requestReloadDrawings: boolean = false) {
|
||||
this.markSettingsDirty();
|
||||
if (requestReloadDrawings) {
|
||||
this.requestReloadDrawings = true;
|
||||
}
|
||||
}
|
||||
|
||||
async hide() {
|
||||
this.detachSettingsFocusoutHandler();
|
||||
if(this.plugin.settings.overrideObsidianFontSize) {
|
||||
document.documentElement.style.fontSize = "";
|
||||
setRootElementSize(16);
|
||||
} else if(!document.documentElement.style.fontSize) {
|
||||
document.documentElement.style.fontSize = getComputedStyle(document.body).getPropertyValue("--font-text-size");
|
||||
setRootElementSize();
|
||||
}
|
||||
|
||||
await this.persistDirtySettings();
|
||||
if (this.requestUpdatePinnedPens) {
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView =>
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView =>
|
||||
excalidrawView.updatePinnedCustomPens()
|
||||
)
|
||||
}
|
||||
if (this.requestUpdateDynamicStyling) {
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView =>
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView =>
|
||||
setDynamicStyle(this.plugin.ea,excalidrawView,excalidrawView.previousBackgroundColor,this.plugin.settings.dynamicStyling)
|
||||
)
|
||||
}
|
||||
@@ -599,7 +664,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
this.plugin.registerHotkeyOverrides();
|
||||
}
|
||||
if (this.requestReloadDrawings) {
|
||||
const excalidrawViews = getExcalidrawViews(this.app);
|
||||
const excalidrawViews = getExcalidrawViews(this.app, true);
|
||||
for (const excalidrawView of excalidrawViews) {
|
||||
await excalidrawView.save(false);
|
||||
//debug({where:"ExcalidrawSettings.hide",file:v.view.file.name,before:"reload(true)"})
|
||||
@@ -620,11 +685,13 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
let detailsEl: HTMLElement;
|
||||
|
||||
await this.plugin.loadSettings(); //in case sync loaded changed settings in the background
|
||||
this.settingsDirty = false;
|
||||
this.requestEmbedUpdate = false;
|
||||
this.requestReloadDrawings = false;
|
||||
const { containerEl } = this;
|
||||
containerEl.addClass("excalidraw-settings");
|
||||
this.containerEl.empty();
|
||||
this.attachSettingsFocusoutHandler();
|
||||
|
||||
// ------------------------------------------------
|
||||
// Search and Settings to Clipboard
|
||||
@@ -645,6 +712,73 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}`;
|
||||
}
|
||||
);
|
||||
|
||||
const excalidrawMasteryPromo = containerEl.createEl("details", {
|
||||
cls: "setting-item-description excalidraw-mastery-promo",
|
||||
});
|
||||
excalidrawMasteryPromo.open = !this.plugin.settings.excalidrawMasteryPromoCollapsed;
|
||||
excalidrawMasteryPromo.classList.toggle(
|
||||
"is-collapsed",
|
||||
this.plugin.settings.excalidrawMasteryPromoCollapsed,
|
||||
);
|
||||
|
||||
const excalidrawMasterySummary = excalidrawMasteryPromo.createEl("summary", {
|
||||
cls: "excalidraw-mastery-promo__summary",
|
||||
});
|
||||
const excalidrawMasterySummaryTitle = excalidrawMasterySummary.createEl("span", {
|
||||
cls: "excalidraw-mastery-promo__summary-title",
|
||||
text: "Excalidraw Mastery",
|
||||
});
|
||||
const excalidrawMasterySummaryState = excalidrawMasterySummary.createEl("span", {
|
||||
cls: "excalidraw-mastery-promo__summary-state",
|
||||
});
|
||||
|
||||
const excalidrawMasteryLink = "https://community.sketch-your-mind.com/em";
|
||||
const updateExcalidrawMasteryPromoState = (persist: boolean) => {
|
||||
const isCollapsed = !excalidrawMasteryPromo.open;
|
||||
this.plugin.settings.excalidrawMasteryPromoCollapsed = isCollapsed;
|
||||
excalidrawMasteryPromo.classList.toggle("is-collapsed", isCollapsed);
|
||||
excalidrawMasterySummaryTitle.classList.toggle("is-hidden", !isCollapsed);
|
||||
excalidrawMasterySummaryState.setText(
|
||||
isCollapsed ? t("EXCALIDRAW_MASTERY_PROMO_SHOW") : t("EXCALIDRAW_MASTERY_PROMO_HIDE"),
|
||||
);
|
||||
if (persist) {
|
||||
void this.plugin.saveSettings();
|
||||
}
|
||||
};
|
||||
|
||||
excalidrawMasteryPromo.addEventListener("toggle", () => updateExcalidrawMasteryPromoState(true));
|
||||
updateExcalidrawMasteryPromoState(false);
|
||||
|
||||
const excalidrawMasteryContent = excalidrawMasteryPromo.createDiv({
|
||||
cls: "excalidraw-mastery-promo__content",
|
||||
});
|
||||
const excalidrawMasteryImageLink = excalidrawMasteryContent.createEl("a", {
|
||||
cls: "excalidraw-mastery-promo__image-link",
|
||||
href: excalidrawMasteryLink,
|
||||
attr: {
|
||||
"aria-label": t("EXCALIDRAW_MASTERY_PROMO_ARIA"),
|
||||
"target": "_blank",
|
||||
"rel": "noopener noreferrer",
|
||||
},
|
||||
});
|
||||
excalidrawMasteryImageLink.createEl("img", {
|
||||
cls: "excalidraw-mastery-promo__image",
|
||||
attr: {
|
||||
src: LOGO_EXCALIDRAW_MASTERY,
|
||||
alt: "Excalidraw Mastery",
|
||||
},
|
||||
});
|
||||
|
||||
const excalidrawMasteryText = excalidrawMasteryContent.createDiv({
|
||||
cls: "excalidraw-mastery-promo__text",
|
||||
});
|
||||
excalidrawMasteryText.innerHTML = t("EXCALIDRAW_MASTERY_PROMO_HTML");
|
||||
excalidrawMasteryText.querySelectorAll("a").forEach((anchor: HTMLAnchorElement) => {
|
||||
anchor.setAttribute("aria-label", t("EXCALIDRAW_MASTERY_PROMO_ARIA"));
|
||||
anchor.setAttribute("target", "_blank");
|
||||
anchor.setAttribute("rel", "noopener noreferrer");
|
||||
});
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
@@ -672,7 +806,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
},
|
||||
{
|
||||
icon: getIcon("globe").outerHTML,
|
||||
href: "https://excalidraw-obsidian.online/",
|
||||
href: "https://community.sketch-your-mind.com/wiki",
|
||||
aria: t("LINKS_WIKI_ARIA"),
|
||||
text: t("LINKS_WIKI"),
|
||||
},
|
||||
@@ -683,10 +817,10 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
text: t("LINKS_YT"),
|
||||
},
|
||||
{
|
||||
icon: `<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" stroke="none" strokeWidth="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 640 512"><path d="M524.531,69.836a1.5,1.5,0,0,0-.764-.7A485.065,485.065,0,0,0,404.081,32.03a1.816,1.816,0,0,0-1.923.91,337.461,337.461,0,0,0-14.9,30.6,447.848,447.848,0,0,0-134.426,0,309.541,309.541,0,0,0-15.135-30.6,1.89,1.89,0,0,0-1.924-.91A483.689,483.689,0,0,0,116.085,69.137a1.712,1.712,0,0,0-.788.676C39.068,183.651,18.186,294.69,28.43,404.354a2.016,2.016,0,0,0,.765,1.375A487.666,487.666,0,0,0,176.02,479.918a1.9,1.9,0,0,0,2.063-.676A348.2,348.2,0,0,0,208.12,430.4a1.86,1.86,0,0,0-1.019-2.588,321.173,321.173,0,0,1-45.868-21.853,1.885,1.885,0,0,1-.185-3.126c3.082-2.309,6.166-4.711,9.109-7.137a1.819,1.819,0,0,1,1.9-.256c96.229,43.917,200.41,43.917,295.5,0a1.812,1.812,0,0,1,1.924.233c2.944,2.426,6.027,4.851,9.132,7.16a1.884,1.884,0,0,1-.162,3.126,301.407,301.407,0,0,1-45.89,21.83,1.875,1.875,0,0,0-1,2.611,391.055,391.055,0,0,0,30.014,48.815,1.864,1.864,0,0,0,2.063.7A486.048,486.048,0,0,0,610.7,405.729a1.882,1.882,0,0,0,.765-1.352C623.729,277.594,590.933,167.465,524.531,69.836ZM222.491,337.58c-28.972,0-52.844-26.587-52.844-59.239S193.056,219.1,222.491,219.1c29.665,0,53.306,26.82,52.843,59.239C275.334,310.993,251.924,337.58,222.491,337.58Zm195.38,0c-28.971,0-52.843-26.587-52.843-59.239S388.437,219.1,417.871,219.1c29.667,0,53.307,26.82,52.844,59.239C470.715,310.993,447.538,337.58,417.871,337.58Z"/></svg>`,
|
||||
href: "https://discord.gg/DyfAXFwUHc",
|
||||
aria: t("LINKS_DISCORD_ARIA"),
|
||||
text: t("LINKS_DISCORD"),
|
||||
icon: getIcon("graduation-cap").outerHTML,
|
||||
href: "https://community.sketch-your-mind.com/ee",
|
||||
aria: t("LINKS_JOIN_SYM_ARIA"),
|
||||
text: t("LINKS_JOIN_SYM"),
|
||||
},
|
||||
{
|
||||
icon: getIcon("twitter").outerHTML,
|
||||
@@ -694,12 +828,6 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
aria: t("LINKS_TWITTER"),
|
||||
text: t("LINKS_TWITTER"),
|
||||
},
|
||||
{
|
||||
icon: getIcon("graduation-cap").outerHTML,
|
||||
href: "https://visual-thinking-workshop.com",
|
||||
aria: t("LINKS_VTW_ARIA"),
|
||||
text: t("LINKS_VTW"),
|
||||
},
|
||||
{
|
||||
icon: getIcon("book").outerHTML,
|
||||
href: "https://sketch-your-mind.com",
|
||||
@@ -715,6 +843,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ------------------------------------------------
|
||||
// Saving
|
||||
// ------------------------------------------------
|
||||
@@ -1424,6 +1553,19 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("PHONE_FOOTER_SAFE_AREA_PADDING_NAME"))
|
||||
.setDesc(fragWithHTML(t("PHONE_FOOTER_SAFE_AREA_PADDING_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.phoneFooterSafeAreaPadding)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.phoneFooterSafeAreaPadding = value;
|
||||
this.plugin.updatePhoneFooterSafeAreaPadding();
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
detailsEl = displayDetailsEl.createEl("details");
|
||||
detailsEl.createEl("summary", {
|
||||
text: t("ZOOM_AND_PAN_HEAD"), //mfuria #329
|
||||
@@ -1452,7 +1594,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
.setValue(this.plugin.settings.allowPinchZoom)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.allowPinchZoom = value;
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updatePinchZoom())
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>excalidrawView.updatePinchZoom())
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
@@ -1466,7 +1608,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
.setValue(this.plugin.settings.allowWheelZoom)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.allowWheelZoom = value;
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updateWheelZoom());
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>excalidrawView.updateWheelZoom());
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
@@ -1616,11 +1758,11 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
});
|
||||
|
||||
const updateGridColor = () => {
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updateGridColor());
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>excalidrawView.updateGridColor());
|
||||
};
|
||||
|
||||
const updateGridDirection = () => {
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>
|
||||
excalidrawView.updateGridDirection(this.plugin.settings.gridSettings.GRID_DIRECTION));
|
||||
}
|
||||
|
||||
|
||||
+31
-4
@@ -97,6 +97,7 @@ export default {
|
||||
ENTER_LATEX: "Enter a valid LaTeX expression",
|
||||
EDIT_LATEX: "Edit LaTeX formula",
|
||||
READ_RELEASE_NOTES: "Read latest release notes",
|
||||
ABOUT_EXCALIDRAW: "About Excalidraw",
|
||||
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",
|
||||
@@ -110,6 +111,7 @@ export default {
|
||||
RESET_IMG_ASPECT_RATIO: "Reset selected image element aspect ratio",
|
||||
TEMPORARY_DISABLE_AUTOSAVE: "Disable autosave until next time Obsidian starts (only set this if you know what you are doing)",
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "Enable autosave",
|
||||
TEMPORARY_TOGGLE_VIEW_MODE_FOR_ALL_DRAWINGS: "Toggle view mode for all Excalidraw drawings until Obsidian restarts",
|
||||
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)",
|
||||
@@ -196,8 +198,8 @@ export default {
|
||||
WELCOME_HELP_MENU: "Find help in the hamburger-menu",
|
||||
WELCOME_YOUTUBE_ARIA: "Visual PKM YouTube Channel",
|
||||
WELCOME_YOUTUBE_LINK: "Check out the Visual PKM YouTube channel.",
|
||||
WELCOME_DISCORD_ARIA: "Join the Discord Server",
|
||||
WELCOME_DISCORD_LINK: "Join the Discord Server",
|
||||
WELCOME_SYM_ARIA: "Learn Excalidraw, Master PKM, Join the Community",
|
||||
WELCOME_SYM_LINK: "Learn Excalidraw, Master PKM, Join the Community",
|
||||
WELCOME_TWITTER_ARIA: "Follow me on Twitter",
|
||||
WELCOME_TWITTER_LINK: "Follow me on Twitter",
|
||||
WELCOME_LEARN_ARIA: "Learn Visual PKM",
|
||||
@@ -221,12 +223,16 @@ export default {
|
||||
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.",
|
||||
EXCALIDRAW_MASTERY_PROMO_ARIA: "Open Excalidraw Mastery",
|
||||
EXCALIDRAW_MASTERY_PROMO_HTML: `<p><b>Feeling lost in the toggles and menus?</b></p><p>Excalidraw is a Visual PKM powerhouse built for heavy-duty workflows like <b>Visual-First Daily Notes</b>, deep <b>PDF research</b>, <b>automation</b>, <b>AI integration</b>, and <b>Visual Zettelkasten</b>. But all this power comes with complexity.</p><p>Skip the trial and error. <a href="https://community.sketch-your-mind.com/em" target="_blank">👉 Join Excalidraw Mastery</a> to learn these exact setups step-by-step. Overcome tool friction and master your knowledge alongside a supportive community of visual thinkers!</p>`,
|
||||
EXCALIDRAW_MASTERY_PROMO_SHOW: "Show",
|
||||
EXCALIDRAW_MASTERY_PROMO_HIDE: "Hide",
|
||||
LINKS_BUGS_ARIA: "Report bugs and raise feature requsts on the plugin's GitHub page",
|
||||
LINKS_BUGS: "Report Bugs",
|
||||
LINKS_YT_ARIA: "Check out my YouTube channel to learn about Visual Thinking and Excalidraw",
|
||||
LINKS_YT: "Learn on YouTube",
|
||||
LINKS_DISCORD_ARIA: "Join the Visual Thinking Workshop Discord Server",
|
||||
LINKS_DISCORD: "Join the Community",
|
||||
LINKS_JOIN_SYM_ARIA: "Learn Excalidraw, Master Visual Thinking, Join the Community",
|
||||
LINKS_JOIN_SYM: "Learn Excalidraw",
|
||||
LINKS_TWITTER: "Follow me",
|
||||
LINKS_VTW_ARIA: "Learn about Visual PKM, Excalidraw, Obsidian, ExcaliBrain and more",
|
||||
LINKS_VTW: "Join a Workshop",
|
||||
@@ -426,6 +432,8 @@ export default {
|
||||
DEFAULT_OPEN_MODE_DESC:
|
||||
"Specifies the mode how Excalidraw opens: Normal, Zen, or View mode. You may also set this behavior on a file level by " +
|
||||
"adding the excalidraw-default-mode frontmatter key with a value of: normal, view, or zen to your document.",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_NAME: "Extra bottom padding for phone controls",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_DESC: "Adds extra bottom padding to the Excalidraw footer controls so zoom and undo buttons stay above the system navigation bar on phones. This setting only applies on phones.",
|
||||
DEFAULT_PEN_MODE_NAME: "Pen mode",
|
||||
DEFAULT_PEN_MODE_DESC:
|
||||
"Should pen mode be automatically enabled when opening Excalidraw?",
|
||||
@@ -1226,6 +1234,25 @@ export default {
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "Welcome to Excalidraw",
|
||||
FIRST_RUN: `
|
||||
The Excalidraw Obsidian plugin is much more than "just" a drawing tool. Because it integrates deeply with Obsidian, it opens up a whole new paradigm for Visual Personal Knowledge Management.
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="https://community.sketch-your-mind.com/ee" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EE.png" style="width:50%;"></a>
|
||||
</div>
|
||||
|
||||
To help you get started without the overwhelm, I highly recommend taking the free **[Excalidraw Essentials](https://community.sketch-your-mind.com/ee)** mini-course. It cuts through the noise and teaches you the fundamentals in a fast, structured way.
|
||||
|
||||
You also don't have to figure it all out alone! Come join the **[Sketch Your Mind Community](https://community.sketch-your-mind.com)** to connect with fellow visual thinkers, share your workflows, and build a frictionless PKM system together.
|
||||
|
||||
If you'd like to see what's possible right now, here is a showcase of the key features. To keep abreast of the latest updates and to explore visual PKM, please subscribe to my YouTube channel: [Visual PKM](https://www.youtube.com/@visualPKM).
|
||||
|
||||
Thank you & Enjoy!
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=P_Q6avJGoWI" target="_blank"><img src ="https://i.ytimg.com/vi/P_Q6avJGoWI/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
`,
|
||||
|
||||
//Excalidraw component
|
||||
COMP_IMG: "Image & Files",
|
||||
|
||||
@@ -67,6 +67,7 @@ export default {
|
||||
INSERT_LATEX: `Вставьте формулу LaTeX (например, \\\binom{n}{k} = \\\frac{n!}{k!(n-k)!}).`,
|
||||
ENTER_LATEX: "Введите правильное выражение LaTeX",
|
||||
READ_RELEASE_NOTES: "Прочитать последние заметки о выпуске",
|
||||
ABOUT_EXCALIDRAW: "О Excalidraw",
|
||||
RUN_OCR: "OCR полного чертежа: Захват текста из freedraw + изображения в буфер обмена и doc.props",
|
||||
RERUN_OCR: "Повторный запуск полного чертежа OCR: Захват текста из freedraw + изображения в буфер обмена и doc.props",
|
||||
RUN_OCR_ELEMENTS: "OCR выделенных элементов: Захват текста из freedraw + изображения в буфер обмена",
|
||||
@@ -81,6 +82,28 @@ export default {
|
||||
TEMPORARY_DISABLE_AUTOSAVE: "Отключить автосохранение до следующего запуска Obsidian (устанавливайте этот параметр, только если вы знаете, что делаете)",
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "Включить автосохранение",
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "Добро пожаловать в Excalidraw",
|
||||
FIRST_RUN: `
|
||||
Плагин Excalidraw для Obsidian - это гораздо больше, чем «просто» инструмент для рисования. Благодаря глубокой интеграции с Obsidian он открывает совершенно новый подход к визуальному управлению личными знаниями.
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="https://community.sketch-your-mind.com/ee" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EE.png" style="width:50%;"></a>
|
||||
</div>
|
||||
|
||||
Чтобы начать без перегруза, очень рекомендую бесплатный мини-курс **[Excalidraw Essentials](https://community.sketch-your-mind.com/ee)**. Он помогает быстро разобраться в главном и освоить базовые принципы в структурированном формате.
|
||||
|
||||
Вам не обязательно разбираться во всем в одиночку. Присоединяйтесь к **[сообществу Sketch Your Mind](https://community.sketch-your-mind.com)**, чтобы общаться с другими визуально мыслящими людьми, делиться своими рабочими процессами и выстраивать более плавную систему PKM.
|
||||
|
||||
Если хотите увидеть, что уже возможно прямо сейчас, ниже есть обзор ключевых возможностей. А чтобы следить за новыми обновлениями и идеями по Visual PKM, подписывайтесь на мой YouTube-канал: [Visual PKM](https://www.youtube.com/@visualPKM).
|
||||
|
||||
Спасибо и приятной работы!
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=P_Q6avJGoWI" target="_blank"><img src ="https://i.ytimg.com/vi/P_Q6avJGoWI/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
`,
|
||||
|
||||
//ExcalidrawView.ts
|
||||
NO_SEARCH_RESULT: "Не удалось найти подходящий элемент на чертеже",
|
||||
FORCE_SAVE_ABORTED: "Принудительное сохранение прервано, поскольку идет процесс сохранения",
|
||||
@@ -156,6 +179,10 @@ export default {
|
||||
RELEASE_NOTES_DESC:
|
||||
"<b><u>Переключатель ВКЛ:</u></b> Отображение информации о выпуске при каждом обновлении Excalidraw до новой версии.<br>" +
|
||||
"<b><u>Переключатель ВЫКЛ:</u></b> Тихий режим. Вы все еще можете прочитать заметки о выпуске на <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases'>GitHub</a>.",
|
||||
EXCALIDRAW_MASTERY_PROMO_ARIA: "Открыть Excalidraw Mastery",
|
||||
EXCALIDRAW_MASTERY_PROMO_HTML: `<p><b>Потерялись в переключателях и меню?</b></p><p>Excalidraw - мощный инструмент Visual PKM, созданный для сложных рабочих процессов: <b>Visual-First Daily Notes</b>, глубокое <b>PDF-исследование</b>, <b>автоматизация</b>, <b>интеграция ИИ</b> и <b>визуальный Zettelkasten</b>. Но такая мощность неизбежно приносит и сложность.</p><p>Пропустите этап проб и ошибок. <a href="https://community.sketch-your-mind.com/em" target="_blank">👉 Присоединяйтесь к Excalidraw Mastery</a>, чтобы шаг за шагом освоить именно эти настройки. Уберите трение инструмента и развивайте свои знания вместе с поддерживающим сообществом визуально мыслящих людей!</p>`,
|
||||
EXCALIDRAW_MASTERY_PROMO_SHOW: "Показать",
|
||||
EXCALIDRAW_MASTERY_PROMO_HIDE: "Скрыть",
|
||||
NEWVERSION_NOTIFICATION_NAME: "Уведомление об обновлении плагина",
|
||||
NEWVERSION_NOTIFICATION_DESC:
|
||||
"<b><u>Переключатель ВКЛ:</u></b> Показывайте уведомление о появлении новой версии плагина.<br>" +
|
||||
|
||||
@@ -97,6 +97,7 @@ export default {
|
||||
ENTER_LATEX: "输入 LaTeX 公式",
|
||||
EDIT_LATEX: "编辑 LaTeX 公式",
|
||||
READ_RELEASE_NOTES: "阅读本插件的更新说明",
|
||||
ABOUT_EXCALIDRAW: "关于 Excalidraw",
|
||||
RUN_OCR: "OCR 整个绘图:识别涂鸦和图片里的文本并复制到剪贴板和笔记属性中",
|
||||
RERUN_OCR: "重新 OCR 整个绘图:识别涂鸦和图片里的文本并复制到剪贴板和笔记属性中",
|
||||
RUN_OCR_ELEMENTS: "OCR 选中的元素:识别涂鸦和图片里的文本并复制到剪贴板",
|
||||
@@ -110,6 +111,7 @@ export default {
|
||||
RESET_IMG_ASPECT_RATIO: "重置所选图像的纵横比",
|
||||
TEMPORARY_DISABLE_AUTOSAVE: "临时禁用自动保存功能,直到本次 Obsidian 退出(小白慎用!)",
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "启用自动保存功能",
|
||||
TEMPORARY_TOGGLE_VIEW_MODE_FOR_ALL_DRAWINGS: "切换所有 Excalidraw 绘图的查看模式,直到本次 Obsidian 退出",
|
||||
FONTS_LOADED: "Excalidraw: CJK 字体已加载",
|
||||
FONTS_LOAD_ERROR: "Excalidraw: 在资源文件夹下找不到 CJK 字体\n",
|
||||
TOGGLE_ENABLE_CONTEXT_MENU: "切换是否启用上下文菜单(在移动设备上很有用)",
|
||||
@@ -221,6 +223,10 @@ export default {
|
||||
DISABLE_CONTEXT_MENU_DESC: "禁用 Excalidraw 的上下文菜单。这在移动设备上很有用,因为上下文菜单有时会在不需要的时候弹出。",
|
||||
NOTEBOOKLM_LINK_ARIA: "向 NotebookLM 咨询有关插件的帮助。此模型已预加载了我所有的视频转录稿、发布说明和其他帮助内容。与 NotebookLM 聊天,浏览我的 250+ 视频和 Excalidraw 文件。",
|
||||
NOTEBOOKLM_LINK_TEXT: "学习插件。访问 NotebookLM 知识库。",
|
||||
EXCALIDRAW_MASTERY_PROMO_ARIA: "打开 Excalidraw Mastery",
|
||||
EXCALIDRAW_MASTERY_PROMO_HTML: `<p><b>在各种开关和菜单里有点迷路吗?</b></p><p>Excalidraw 是一款为高强度工作流打造的 Visual PKM 强力工具,适合 <b>Visual-First Daily Notes</b>、深入的 <b>PDF 研究</b>、<b>自动化</b>、<b>AI 集成</b> 和 <b>Visual Zettelkasten</b>。但强大能力也意味着更高的复杂度。</p><p>跳过反复试错。<a href="https://community.sketch-your-mind.com/em" target="_blank">👉 加入 Excalidraw Mastery</a>,一步一步学会这些具体配置。减少工具摩擦,与一群善于视觉思考的支持型社群一起掌握你的知识体系。</p>`,
|
||||
EXCALIDRAW_MASTERY_PROMO_SHOW: "显示",
|
||||
EXCALIDRAW_MASTERY_PROMO_HIDE: "隐藏",
|
||||
LINKS_BUGS_ARIA: "在插件的 GitHub 页面报告错误和提交功能请求",
|
||||
LINKS_BUGS: "报告错误",
|
||||
LINKS_YT_ARIA: "访问我的 YouTube 频道学习视觉思维和 Excalidraw",
|
||||
@@ -426,6 +432,8 @@ export default {
|
||||
DEFAULT_OPEN_MODE_DESC:
|
||||
"设置 Excalidraw 的运行模式:普通模式(Normal)/禅模式(Zen)/查看模式(View)。<br>" +
|
||||
"可为某个绘图单独设置,方法是在其 frontmatter 中添加如 <code>excalidraw-default-mode: normal/zen/view</code> 的键值对。",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_NAME: "为手机端底部控件增加额外留白",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_DESC: "为 Excalidraw 底部控件增加额外底部留白,让缩放和撤销按钮在手机上保持位于系统导航栏之上。该设置仅在手机上生效。",
|
||||
DEFAULT_PEN_MODE_NAME: "触控笔模式(Pen mode)",
|
||||
DEFAULT_PEN_MODE_DESC:
|
||||
"打开绘图时,是否自动开启触控笔模式?",
|
||||
@@ -1226,6 +1234,25 @@ export default {
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "欢迎使用 Excalidraw",
|
||||
FIRST_RUN: `
|
||||
Obsidian 的 Excalidraw 插件远不只是一个“画图工具”。由于它与 Obsidian 深度集成,它为可视化个人知识管理带来了全新的工作范式。
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="https://community.sketch-your-mind.com/ee" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EE.png" style="width:50%;"></a>
|
||||
</div>
|
||||
|
||||
如果你想顺利入门、避免一开始就被大量功能淹没,我非常推荐免费的 **[Excalidraw Essentials](https://community.sketch-your-mind.com/ee)** 微课程。它能帮你快速抓住重点,用清晰的结构掌握核心基础。
|
||||
|
||||
你也不必独自摸索。欢迎加入 **[Sketch Your Mind 社区](https://community.sketch-your-mind.com)**,与其他视觉思考者交流、分享工作流,一起构建更顺滑的 PKM 系统。
|
||||
|
||||
如果你想先看看它现在都能做到什么,下面有一个核心功能展示。想持续了解最新更新,并进一步探索 Visual PKM,也欢迎订阅我的 YouTube 频道:[Visual PKM](https://www.youtube.com/@visualPKM)。
|
||||
|
||||
感谢使用,祝你玩得开心!
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=P_Q6avJGoWI" target="_blank"><img src ="https://i.ytimg.com/vi/P_Q6avJGoWI/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
`,
|
||||
|
||||
//Excalidraw component
|
||||
COMP_IMG: "图片 & 文件",
|
||||
|
||||
@@ -97,6 +97,7 @@ export default {
|
||||
ENTER_LATEX: "輸入 LaTeX 公式",
|
||||
EDIT_LATEX: "編輯 LaTeX 公式",
|
||||
READ_RELEASE_NOTES: "閱讀本外掛的更新說明",
|
||||
ABOUT_EXCALIDRAW: "關於 Excalidraw",
|
||||
RUN_OCR: "OCR 整個繪圖:識別塗鴉和圖片裡的文字並複製到剪貼簿和筆記屬性中",
|
||||
RERUN_OCR: "重新 OCR 整個繪圖:識別塗鴉和圖片裡的文字並複製到剪貼簿和筆記屬性中",
|
||||
RUN_OCR_ELEMENTS: "OCR 選中的元素:識別塗鴉和圖片裡的文字並複製到剪貼簿",
|
||||
@@ -110,6 +111,7 @@ export default {
|
||||
RESET_IMG_ASPECT_RATIO: "重置所選影像的縱橫比",
|
||||
TEMPORARY_DISABLE_AUTOSAVE: "臨時停用自動儲存功能,直到本次 Obsidian 退出(小白慎用!)",
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "啟用自動儲存功能",
|
||||
TEMPORARY_TOGGLE_VIEW_MODE_FOR_ALL_DRAWINGS: "切換所有 Excalidraw 繪圖的檢視模式,直到本次 Obsidian 退出",
|
||||
FONTS_LOADED: "Excalidraw: CJK 字型已載入",
|
||||
FONTS_LOAD_ERROR: "Excalidraw: 在資原始檔夾下找不到 CJK 字型\n",
|
||||
TOGGLE_ENABLE_CONTEXT_MENU: "切換是否啟用上下文選單(在移動裝置上很有用)",
|
||||
@@ -221,6 +223,10 @@ export default {
|
||||
DISABLE_CONTEXT_MENU_DESC: "停用 Excalidraw 的上下文選單。這在移動裝置上很有用,因為上下文選單有時會在不需要的時候彈出。",
|
||||
NOTEBOOKLM_LINK_ARIA: "向 NotebookLM 諮詢有關外掛的幫助。此模型已預載入了我所有的影片轉錄稿、釋出說明和其他幫助內容。與 NotebookLM 聊天,瀏覽我的 250+ 影片和 Excalidraw 檔案。",
|
||||
NOTEBOOKLM_LINK_TEXT: "學習外掛。訪問 NotebookLM 知識庫。",
|
||||
EXCALIDRAW_MASTERY_PROMO_ARIA: "開啟 Excalidraw Mastery",
|
||||
EXCALIDRAW_MASTERY_PROMO_HTML: `<p><b>在各種切換與選單中感到迷失嗎?</b></p><p>Excalidraw 是為高強度工作流程打造的 Visual PKM 強大工具,適合 <b>Visual-First Daily Notes</b>、深入的 <b>PDF 研究</b>、<b>自動化</b>、<b>AI 整合</b> 與 <b>Visual Zettelkasten</b>。但這些強大功能也伴隨著複雜度。</p><p>跳過反覆試錯。<a href="https://community.sketch-your-mind.com/em" target="_blank">👉 加入 Excalidraw Mastery</a>,一步一步學會這些具體設定。降低工具摩擦,並與一群擅長視覺思考的支持型社群一起掌握你的知識系統。</p>`,
|
||||
EXCALIDRAW_MASTERY_PROMO_SHOW: "顯示",
|
||||
EXCALIDRAW_MASTERY_PROMO_HIDE: "隱藏",
|
||||
LINKS_BUGS_ARIA: "在外掛的 GitHub 頁面報告錯誤和提交功能請求",
|
||||
LINKS_BUGS: "報告錯誤",
|
||||
LINKS_YT_ARIA: "訪問我的 YouTube 頻道學習視覺思維和 Excalidraw",
|
||||
@@ -426,6 +432,8 @@ export default {
|
||||
DEFAULT_OPEN_MODE_DESC:
|
||||
"設定 Excalidraw 的執行模式:普通模式(Normal)/禪模式(Zen)/檢視模式(View)。<br>" +
|
||||
"可為某個繪圖單獨設定,方法是在其 frontmatter 中新增如 <code>excalidraw-default-mode: normal/zen/view</code> 的鍵值對。",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_NAME: "為手機端底部控制項增加額外留白",
|
||||
PHONE_FOOTER_SAFE_AREA_PADDING_DESC: "為 Excalidraw 底部控制項增加額外底部留白,讓縮放與復原按鈕在手機上保持位於系統導覽列之上。該設定僅在手機上生效。",
|
||||
DEFAULT_PEN_MODE_NAME: "觸控筆模式(Pen mode)",
|
||||
DEFAULT_PEN_MODE_DESC:
|
||||
"開啟繪圖時,是否自動開啟觸控筆模式?",
|
||||
@@ -1226,6 +1234,25 @@ export default {
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "歡迎使用 Excalidraw",
|
||||
FIRST_RUN: `
|
||||
Obsidian 的 Excalidraw 外掛遠不只是「畫圖工具」。由於它與 Obsidian 深度整合,它為視覺化個人知識管理帶來了全新的工作方式。
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="https://community.sketch-your-mind.com/ee" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EE.png" style="width:50%;"></a>
|
||||
</div>
|
||||
|
||||
如果你想順利上手、避免一開始就被大量功能淹沒,我非常推薦免費的 **[Excalidraw Essentials](https://community.sketch-your-mind.com/ee)** 微課程。它能幫你快速抓住重點,用清楚的結構掌握核心基礎。
|
||||
|
||||
你也不必自己摸索。歡迎加入 **[Sketch Your Mind 社群](https://community.sketch-your-mind.com)**,與其他視覺思考者交流、分享工作流程,一起打造更順暢的 PKM 系統。
|
||||
|
||||
如果你想先看看它現在能做到什麼,下面有一段核心功能展示。若想持續了解最新更新,並進一步探索 Visual PKM,也歡迎訂閱我的 YouTube 頻道:[Visual PKM](https://www.youtube.com/@visualPKM)。
|
||||
|
||||
感謝使用,祝你玩得愉快!
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=P_Q6avJGoWI" target="_blank"><img src ="https://i.ytimg.com/vi/P_Q6avJGoWI/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
`,
|
||||
|
||||
//Excalidraw component
|
||||
COMP_IMG: "圖片 & 檔案",
|
||||
|
||||
@@ -25,7 +25,7 @@ export class ExportDialog extends Modal {
|
||||
public exportInternalLinks: boolean = true;
|
||||
public saveSettings: boolean;
|
||||
public dirty: boolean = false;
|
||||
private selectedOnlySetting: Setting;
|
||||
private selectedOnlySetting: Setting | null = null;
|
||||
private hasSelectedElements: boolean = false;
|
||||
private boundingBox: {
|
||||
topX: number;
|
||||
@@ -39,15 +39,15 @@ export class ExportDialog extends Modal {
|
||||
public pageSize: PageSize = "A4";
|
||||
public pageOrientation: PageOrientation = "portrait";
|
||||
private activeTab: "image" | "pdf" | "screenshot" = "image";
|
||||
private contentContainer: HTMLDivElement;
|
||||
private buttonContainerRow1: HTMLDivElement;
|
||||
private buttonContainerRow2: HTMLDivElement;
|
||||
private contentContainer: HTMLDivElement | null = null;
|
||||
private buttonContainerRow1: HTMLDivElement | null = null;
|
||||
private buttonContainerRow2: HTMLDivElement | null = null;
|
||||
public fitToPage: number = 1;
|
||||
public paperColor: "white" | "scene" | "custom" = "white";
|
||||
public customPaperColor: string = "#ffffff";
|
||||
public alignment: PDFPageAlignment = "center";
|
||||
public margin: PDFPageMarginString = "normal";
|
||||
private scaleSetting:Setting;
|
||||
private scaleSetting:Setting | null = null;
|
||||
|
||||
constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
|
||||
@@ -1,26 +1,76 @@
|
||||
export const FIRST_RUN = `
|
||||
The Excalidraw Obsidian plugin is much more than "just" a drawing tool. To help you get started here's a showcase of the key Excalidraw plugin features.
|
||||
|
||||
If you'd like to learn more, please subscribe to my YouTube channel: [Visual PKM](https://www.youtube.com/channel/UCC0gns4a9fhVkGkngvSumAQ) where I regularly share videos about Obsidian-Excalidraw and about tools and techniques for Visual Personal Knowledge Management.
|
||||
|
||||
Thank you & Enjoy!
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=P_Q6avJGoWI" target="_blank"><img src ="https://i.ytimg.com/vi/P_Q6avJGoWI/maxresdefault.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export const RELEASE_NOTES: { [k: string]: string } = {
|
||||
Intro: `After each update, you'll see these release notes (you can turn this off in the plugin settings).
|
||||
|
||||
I build this plugin in my free time, as a labor of love. Curious about the philosophy behind it? Check out [📕 Sketch Your Mind](https://sketch-your-mind.com). If you find it valuable, say THANK YOU or…
|
||||
I build this plugin as a labor of love. Curious about the philosophy behind it? Check out [📕 Sketch Your Mind](https://sketch-your-mind.com). Want to master Excalidraw? Join [Excalidraw Mastery](https://community.sketch-your-mind.com/em). If you find it valuable, say THANK YOU or…
|
||||
|
||||
<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.22.3":`
|
||||
|
||||
Feeling overwhelmed by Excalidraw’s endless features?
|
||||
|
||||
It's not just a drawing tool. Inside Obsidian, it becomes a thinking tool.
|
||||
To unlock linking, embedding, and referencing, you need a mindset shift.
|
||||
|
||||
**Join Excalidraw Mastery** to make that shift.
|
||||
Courses, live Q&As, and deep dives to help you move into true 4D Visual PKM. 👉 https://community.sketch-your-mind.com/em
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="https://community.sketch-your-mind.com/em" target="_blank"><img src="https://sketch-your-mind.com/images/logo-EM.png" style="width:50%"></a>
|
||||
</div>
|
||||
|
||||
Excalidraw Mastery is part of the **Sketch Your Mind Community**—a space for visual thinkers.
|
||||
Share your work. Ask questions. Learn from others. 👉 https://community.sketch-your-mind.com
|
||||
|
||||
Curious about the philosophy behind it?
|
||||
|
||||
<div class="excalidraw-videoWrapper">
|
||||
<a href="https://www.youtube.com/watch?v=TnwRlaIdhSU" target="_blank"><img src ="https://sketch-your-mind.com/images/Thumbnail-podcast.jpg" style="width:100%;"></a>
|
||||
</div>
|
||||
|
||||
`,
|
||||
"2.22.1": `
|
||||
## New
|
||||
- Added a command palette action to switch all currently open Excalidraw drawings to view mode.
|
||||
- While this temporary mode is enabled, any Excalidraw drawing opened afterward will also open in view mode.
|
||||
- This is useful when presenting multiple drawings and you want to avoid accidentally moving elements, and when you don't want the tools to be in the way.
|
||||
- Added an optional phone-only layout setting to push Excalidraw's footer controls above the system navigation bar on some Android devices [#2688](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2688), [#2652](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2652), [#798](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/798)
|
||||
- Look for ""Extra bottom padding for phone controls" in the plugin settings.
|
||||
|
||||
## Fixed
|
||||
- invisible cursor color in color picker, mermaid chat, in text elements in dark mode [#2739](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2739)
|
||||
- image sizing issue when embedding image type "SVG Image" to markdown
|
||||
- copying a nested image fragment in Excalidraw and pasting to markdown lost the image block reference
|
||||
- modifier keys conflicted with Excalidraw alt-select (lasso) behavior
|
||||
`,
|
||||
"2.22.0":`
|
||||
## Fixed
|
||||
- Fixed misaligned panel buttons in tray mode [#2718](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2718) 🙏[@heinrich26](https://github.com/heinrich26)
|
||||
- Improved loading of nested Excalidraw files within a scene, with some additional performance gains.
|
||||
- Fixed an issue where the caret color did not match the text color [#11018](https://github.com/excalidraw/excalidraw/issues/11018)
|
||||
|
||||
## New from Excalidraw.com
|
||||
- Added several text editing improvements, including a right-side handle on wrapped text for easier auto-resizing without opening the context menu [#10979](https://github.com/excalidraw/excalidraw/pull/10979)
|
||||
- Added support for Mermaid state diagrams [#11031](https://github.com/excalidraw/excalidraw/pull/11031)
|
||||
- There is a new Preferences menu above the Dark/Light mode switch in the main menu [#10760](https://github.com/excalidraw/excalidraw/pull/10760)
|
||||
- Added a new Preferences option to switch between Wrap and Overlap selection modes. Overlap mode behaves similarly to the lasso selection tool available under More Tools [#11053](https://github.com/excalidraw/excalidraw/pull/11053)
|
||||
|
||||
## New
|
||||
- Added support for embedding the [Sheet Plus](obsidian://show-plugin?id=sheet-plus) plugin as an active embeddable element in Excalidraw. At the moment, changing the canvas theme between dark and light mode does not automatically re-render embedded sheets. To apply the theme change, close and reopen the drawing. This will likely be improved in a future update.
|
||||
`,
|
||||
"2.21.3":`
|
||||
## Fixed
|
||||
- Caret color for link editor, text elemnts in dark mode, color picker input element.
|
||||
- Link click behavior modifier keys setting in plugin settings now enforces CTRL/CMD for link clicks and improves on clarity of setting UI by adding a header row
|
||||
- Link click conbinations that included ALT/OPT did not work because they trigger lasso selection in Excalidraw. This is now fixed, if you CTRL+ALT click a link it will navigate while retaining the lasso select feature when pressing ALT/OPT.
|
||||
- Copying an image block embed (e.g. \`![[drawing#^frame=my_frame]]\`) from the excalidraw scene and pasting it to markdown no longer loses the frame reference
|
||||
- Embed "SVG Image" to markdown should size correctly now when setting a percentage \`![[drawing|50%]]\` where 50% is relative to the width of the markdown note.
|
||||
|
||||
`,
|
||||
"2.21.2":`
|
||||
## Fixed
|
||||
- The new ExcalidrawAutomate function \`parseText()\` broke if the text was a transcluded image or PDF document, causing downstream paste issues in MindMap Builder.
|
||||
- Fix custom pen sloppiness not being saved to a template drawing [#2715](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2715) 🙏[@sreedharsreeram](https://github.com/sreedharsreeram)
|
||||
- Custom pen sloppiness not being saved to a template drawing [#2715](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2715) 🙏[@sreedharsreeram](https://github.com/sreedharsreeram)
|
||||
|
||||
`,
|
||||
"2.21.1":`
|
||||
|
||||
@@ -45,6 +45,31 @@ export class ModifierKeySettingsComponent {
|
||||
text: t("DEFAULT_ACTION_DESC") + modifierKeyTooltipMessages()[modifierSetType][modifierKeys.defaultAction],
|
||||
cls: "setting-item-description"
|
||||
});
|
||||
// Ensure all LinkClickAction rules have ctrl_cmd enabled
|
||||
if (modifierSetType === "LinkClickAction") {
|
||||
let dirty = false;
|
||||
modifierKeys.rules.forEach((rule) => {
|
||||
if (!rule.ctrl_cmd) { rule.ctrl_cmd = true; dirty = true; }
|
||||
});
|
||||
if (dirty) this.update?.();
|
||||
}
|
||||
|
||||
// Column header row
|
||||
const headerSetting = new Setting(detailsEl);
|
||||
headerSetting.settingEl.addClass("modifier-key-header-row");
|
||||
headerSetting.infoEl.remove();
|
||||
[
|
||||
"SHIFT",
|
||||
this.isMacOS ? "CMD" : "CTRL",
|
||||
this.isMacOS ? "OPT" : "ALT",
|
||||
this.isMacOS ? "CTRL" : "META",
|
||||
].forEach((key) => {
|
||||
headerSetting.controlEl.createEl("span", {
|
||||
text: key,
|
||||
cls: "modifier-key-col-header",
|
||||
});
|
||||
});
|
||||
|
||||
Object.entries(modifierKeys.rules).forEach(([action, rule]) => {
|
||||
const setting = new Setting(detailsEl)
|
||||
//@ts-ignore
|
||||
@@ -60,14 +85,18 @@ export class ModifierKeySettingsComponent {
|
||||
})
|
||||
);
|
||||
setting.addToggle((toggle) => {
|
||||
const isLinkClick = modifierSetType === "LinkClickAction";
|
||||
toggle
|
||||
.setValue(rule.ctrl_cmd)
|
||||
.setValue(isLinkClick ? true : rule.ctrl_cmd)
|
||||
.setTooltip(this.isMacOS ? "CMD" : "CTRL")
|
||||
.onChange((value) => {
|
||||
rule.ctrl_cmd = value;
|
||||
this.update();
|
||||
})
|
||||
if(this.isMacOS && modifierSetType !== "LinkClickAction") {
|
||||
});
|
||||
if (isLinkClick || this.isMacOS) {
|
||||
// CMD is always required for link-click actions (Excalidraw detects
|
||||
// the click via CMD being held). On macOS, CMD is also reserved for
|
||||
// non-link-click actions.
|
||||
toggle.setDisabled(true);
|
||||
toggle.toggleEl.style.opacity = "0.5";
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ export class PenSettingsModal extends Modal {
|
||||
async onClose() {
|
||||
if(this.dirty) {
|
||||
await this.plugin.saveSettings();
|
||||
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updatePinnedCustomPens());
|
||||
getExcalidrawViews(this.app, true).forEach(excalidrawView=>excalidrawView.updatePinnedCustomPens());
|
||||
const pen = this.plugin.settings.customPens[this.pen]
|
||||
const api = this.view.excalidrawAPI;
|
||||
setPen(pen,api);
|
||||
|
||||
@@ -1,18 +1,26 @@
|
||||
import { App, MarkdownRenderer, Modal } from "obsidian";
|
||||
import { isVersionNewerThanOther } from "src/utils/utils";
|
||||
import ExcalidrawPlugin from "../../core/main";
|
||||
import { FIRST_RUN, RELEASE_NOTES } from "./Messages";
|
||||
import { RELEASE_NOTES } from "./Messages";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
type ReleaseNotesOptions = {
|
||||
message?: string;
|
||||
persistVersion?: boolean;
|
||||
title?: string;
|
||||
};
|
||||
|
||||
export class ReleaseNotes extends Modal {
|
||||
private plugin: ExcalidrawPlugin;
|
||||
private options: ReleaseNotesOptions;
|
||||
private version: string;
|
||||
|
||||
constructor(app: App, plugin: ExcalidrawPlugin, version: string) {
|
||||
constructor(app: App, plugin: ExcalidrawPlugin, version: string, options: ReleaseNotesOptions = {}) {
|
||||
super(app);
|
||||
this.plugin = plugin;
|
||||
this.options = options;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
@@ -21,7 +29,7 @@ export class ReleaseNotes extends Modal {
|
||||
const { containerEl, contentEl, titleEl, headerEl } = this;
|
||||
//this.contentEl.classList.add("excalidraw-release");
|
||||
containerEl.classList.add("excalidraw-release");
|
||||
titleEl.setText(`${t("RN_WELCOME")} ${this.version ?? ""}`);
|
||||
titleEl.setText(this.options.title ?? `${t("RN_WELCOME")} ${this.version ?? ""}`.trim());
|
||||
this.createForm();
|
||||
|
||||
if(headerEl) headerEl.style.pointerEvents = "none"; // Disable pointer events on header to allow clicks through
|
||||
@@ -29,6 +37,9 @@ export class ReleaseNotes extends Modal {
|
||||
|
||||
async onClose() {
|
||||
this.contentEl.empty();
|
||||
if (this.options.persistVersion === false) {
|
||||
return;
|
||||
}
|
||||
await this.plugin.loadSettings();
|
||||
if(this.plugin.settings.previousRelease !== PLUGIN_VERSION) {
|
||||
this.plugin.settings.previousRelease = PLUGIN_VERSION;
|
||||
@@ -39,13 +50,13 @@ export class ReleaseNotes extends Modal {
|
||||
async createForm() {
|
||||
let prevRelease = this.plugin.settings.previousRelease;
|
||||
prevRelease = this.version === prevRelease ? "0.0.0" : prevRelease;
|
||||
const message = this.version
|
||||
const message = this.options.message ?? (this.version
|
||||
? Object.keys(RELEASE_NOTES)
|
||||
.filter((key) => key === "Intro" || isVersionNewerThanOther(key,prevRelease))
|
||||
.map((key: string) => `${key==="Intro" ? "" : `# ${key}\n`}${RELEASE_NOTES[key]}`)
|
||||
.slice(0, 10)
|
||||
.join("\n\n---\n")
|
||||
: FIRST_RUN;
|
||||
: t("FIRST_RUN"));
|
||||
await MarkdownRenderer.render(
|
||||
this.app,
|
||||
message,
|
||||
|
||||
@@ -96,10 +96,7 @@ export class UIModeSettingsComponent {
|
||||
.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));
|
||||
setLeftHandedMode(value);
|
||||
this.onChange();
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -486,104 +486,108 @@ export class EmbeddedFilesLoader {
|
||||
return null;
|
||||
}
|
||||
|
||||
const app = this.plugin.app;
|
||||
try {
|
||||
const app = this.plugin.app;
|
||||
|
||||
const isHyperLink = inFile instanceof EmbeddedFile ? inFile.isHyperLink : false;
|
||||
const isLocalLink = inFile instanceof EmbeddedFile ? inFile.isLocalLink : false;
|
||||
const hyperlink = inFile instanceof EmbeddedFile ? inFile.hyperlink : "";
|
||||
const file: TFile = inFile instanceof EmbeddedFile ? inFile.file : inFile;
|
||||
if(file && markdownRendererRecursionWatcthdog.has(file)) {
|
||||
new Notice(`Loading of ${file.path}. Please check if there is an inifinite loop of one file embedded in the other.`);
|
||||
return null;
|
||||
}
|
||||
const isHyperLink = inFile instanceof EmbeddedFile ? inFile.isHyperLink : false;
|
||||
const isLocalLink = inFile instanceof EmbeddedFile ? inFile.isLocalLink : false;
|
||||
const hyperlink = inFile instanceof EmbeddedFile ? inFile.hyperlink : "";
|
||||
const file: TFile = inFile instanceof EmbeddedFile ? inFile.file : inFile;
|
||||
if(file && markdownRendererRecursionWatcthdog.has(file)) {
|
||||
new Notice(`Loading of ${file.path}. Please check if there is an inifinite loop of one file embedded in the other.`);
|
||||
return null;
|
||||
}
|
||||
|
||||
const linkParts =
|
||||
isHyperLink
|
||||
? null
|
||||
: inFile instanceof EmbeddedFile
|
||||
? inFile.linkParts
|
||||
: {
|
||||
original: file.path,
|
||||
path: file.path,
|
||||
isBlockRef: false,
|
||||
ref: null,
|
||||
width: this.plugin.settings.mdSVGwidth,
|
||||
height: this.plugin.settings.mdSVGmaxHeight,
|
||||
page: null,
|
||||
};
|
||||
|
||||
let hasSVGwithBitmap = false;
|
||||
const isExcalidrawFile = !isHyperLink && !isLocalLink && this.plugin.isExcalidrawFile(file);
|
||||
const isPDF = !isHyperLink && !isLocalLink && file.extension.toLowerCase() === "pdf";
|
||||
|
||||
if (
|
||||
!isHyperLink && !isPDF && !isLocalLink &&
|
||||
!(
|
||||
IMAGE_TYPES.contains(file.extension) ||
|
||||
isExcalidrawFile ||
|
||||
file.extension === "md"
|
||||
)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const ab = isHyperLink || isPDF || isExcalidrawFile
|
||||
? null
|
||||
: isLocalLink
|
||||
? await readLocalFileBinary(this.getLocalPath((inFile as EmbeddedFile).hyperlink))
|
||||
: await app.vault.readBinary(file);
|
||||
|
||||
let dURL: DataURL = null;
|
||||
if (isExcalidrawFile) {
|
||||
const res = await this.getExcalidrawSVG({
|
||||
isDark: this.isDark,
|
||||
file,
|
||||
depth,
|
||||
inFile,
|
||||
hasSVGwithBitmap,
|
||||
});
|
||||
dURL = res.dataURL;
|
||||
hasSVGwithBitmap = res.hasSVGwithBitmap;
|
||||
}
|
||||
|
||||
const excalidrawSVG = isExcalidrawFile ? dURL : null;
|
||||
|
||||
const [pdfDataURL, pdfSize, pdfPageViewProps] = isPDF
|
||||
? await this.pdfToDataURL(file,linkParts)
|
||||
: [null, null, null];
|
||||
|
||||
let mimeType: MimeType = isPDF
|
||||
? "image/png"
|
||||
: "image/svg+xml";
|
||||
|
||||
const extension = isHyperLink || isLocalLink
|
||||
? getURLImageExtension(hyperlink)
|
||||
: file.extension;
|
||||
if (!isExcalidrawFile && !isPDF) {
|
||||
mimeType = getMimeType(extension);
|
||||
}
|
||||
|
||||
let dataURL =
|
||||
isHyperLink
|
||||
? (
|
||||
inFile instanceof EmbeddedFile
|
||||
? await getDataURLFromURL(inFile.hyperlink, mimeType)
|
||||
: null
|
||||
)
|
||||
: excalidrawSVG ?? pdfDataURL ??
|
||||
(file?.extension === "svg"
|
||||
? await getSVGData(app, file, inFile instanceof EmbeddedFile ? inFile.colorMap : null)
|
||||
: file?.extension === "md"
|
||||
const linkParts =
|
||||
isHyperLink
|
||||
? null
|
||||
: await getDataURL(ab, mimeType));
|
||||
: inFile instanceof EmbeddedFile
|
||||
? inFile.linkParts
|
||||
: {
|
||||
original: file.path,
|
||||
path: file.path,
|
||||
isBlockRef: false,
|
||||
ref: null,
|
||||
width: this.plugin.settings.mdSVGwidth,
|
||||
height: this.plugin.settings.mdSVGmaxHeight,
|
||||
page: null,
|
||||
};
|
||||
|
||||
let hasSVGwithBitmap = false;
|
||||
const isExcalidrawFile = !isHyperLink && !isLocalLink && this.plugin.isExcalidrawFile(file);
|
||||
const isPDF = !isHyperLink && !isLocalLink && file.extension.toLowerCase() === "pdf";
|
||||
|
||||
if (
|
||||
!isHyperLink && !isPDF && !isLocalLink &&
|
||||
!(
|
||||
IMAGE_TYPES.contains(file.extension) ||
|
||||
isExcalidrawFile ||
|
||||
file.extension === "md"
|
||||
)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
const ab = isHyperLink || isPDF || isExcalidrawFile
|
||||
? null
|
||||
: isLocalLink
|
||||
? await readLocalFileBinary(this.getLocalPath((inFile as EmbeddedFile).hyperlink))
|
||||
: await app.vault.readBinary(file);
|
||||
|
||||
let dURL: DataURL = null;
|
||||
if (isExcalidrawFile) {
|
||||
const res = await this.getExcalidrawSVG({
|
||||
isDark: this.isDark,
|
||||
file,
|
||||
depth,
|
||||
inFile,
|
||||
hasSVGwithBitmap,
|
||||
});
|
||||
dURL = res.dataURL;
|
||||
hasSVGwithBitmap = res.hasSVGwithBitmap;
|
||||
}
|
||||
|
||||
const excalidrawSVG = isExcalidrawFile ? dURL : null;
|
||||
|
||||
const [pdfDataURL, pdfSize, pdfPageViewProps] = isPDF
|
||||
? await this.pdfToDataURL(file,linkParts)
|
||||
: [null, null, null];
|
||||
|
||||
let mimeType: MimeType = isPDF
|
||||
? "image/png"
|
||||
: "image/svg+xml";
|
||||
|
||||
const extension = isHyperLink || isLocalLink
|
||||
? getURLImageExtension(hyperlink)
|
||||
: file.extension;
|
||||
if (!isExcalidrawFile && !isPDF) {
|
||||
mimeType = getMimeType(extension);
|
||||
}
|
||||
|
||||
let dataURL =
|
||||
isHyperLink
|
||||
? (
|
||||
inFile instanceof EmbeddedFile
|
||||
? await getDataURLFromURL(inFile.hyperlink, mimeType)
|
||||
: null
|
||||
)
|
||||
: excalidrawSVG ?? pdfDataURL ??
|
||||
(file?.extension === "svg"
|
||||
? await getSVGData(app, file, inFile instanceof EmbeddedFile ? inFile.colorMap : null)
|
||||
: file?.extension === "md"
|
||||
? null
|
||||
: await getDataURL(ab, mimeType));
|
||||
|
||||
if(!isHyperLink && !dataURL && !isLocalLink) {
|
||||
markdownRendererRecursionWatcthdog.add(file);
|
||||
try {
|
||||
const result = await this.convertMarkdownToSVG(this.plugin, file, linkParts, depth);
|
||||
dataURL = result.dataURL;
|
||||
hasSVGwithBitmap = result.hasSVGwithBitmap;
|
||||
} finally {
|
||||
markdownRendererRecursionWatcthdog.delete(file);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isHyperLink && !dataURL && !isLocalLink) {
|
||||
markdownRendererRecursionWatcthdog.add(file);
|
||||
const result = await this.convertMarkdownToSVG(this.plugin, file, linkParts, depth);
|
||||
markdownRendererRecursionWatcthdog.delete(file);
|
||||
dataURL = result.dataURL;
|
||||
hasSVGwithBitmap = result.hasSVGwithBitmap;
|
||||
}
|
||||
try{
|
||||
const size = isPDF ? pdfSize : await getImageSize(dataURL);
|
||||
return {
|
||||
mimeType,
|
||||
@@ -597,7 +601,14 @@ export class EmbeddedFilesLoader {
|
||||
size,
|
||||
pdfPageViewProps,
|
||||
};
|
||||
} catch(e) {
|
||||
} catch (error) {
|
||||
errorlog({
|
||||
where: "EmbeddedFileLoader._getObsidianImage",
|
||||
uid: this.uid,
|
||||
file: inFile instanceof EmbeddedFile ? inFile.file?.path ?? inFile.hyperlink : inFile?.path,
|
||||
depth,
|
||||
error,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -625,6 +636,21 @@ export class EmbeddedFilesLoader {
|
||||
if (this.isDark === undefined) {
|
||||
this.isDark = excalidrawData?.scene?.appState?.theme === "dark";
|
||||
}
|
||||
const createSafeLoadTask = (
|
||||
task: () => Promise<void>,
|
||||
context: Record<string, unknown>,
|
||||
) => promiseTry(async () => {
|
||||
try {
|
||||
await task();
|
||||
} catch (error) {
|
||||
errorlog({
|
||||
where: "EmbeddedFileLoader.loadSceneFiles",
|
||||
uid: this.uid,
|
||||
...context,
|
||||
error,
|
||||
});
|
||||
}
|
||||
});
|
||||
let entry: IteratorResult<[FileId, EmbeddedFile]>;
|
||||
const files: FileData[][] = [];
|
||||
files.push([]);
|
||||
@@ -635,7 +661,7 @@ export class EmbeddedFilesLoader {
|
||||
if(fileIDWhiteList && !fileIDWhiteList.has(entry.value[0])) continue;
|
||||
const embeddedFile: EmbeddedFile = entry.value[1];
|
||||
const id = entry.value[0];
|
||||
yield promiseTry(async () => {
|
||||
yield createSafeLoadTask(async () => {
|
||||
if(this.terminate) {
|
||||
return;
|
||||
}
|
||||
@@ -669,6 +695,11 @@ export class EmbeddedFilesLoader {
|
||||
};
|
||||
files[batch].push(fileData);
|
||||
}
|
||||
}, {
|
||||
phase: "embedded-file",
|
||||
fileId: id,
|
||||
filepath: embeddedFile.file?.path ?? embeddedFile.hyperlink,
|
||||
depth,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -678,7 +709,7 @@ export class EmbeddedFilesLoader {
|
||||
if(fileIDWhiteList && !fileIDWhiteList.has(equationItem.value[0])) continue;
|
||||
const equation = equationItem.value[1];
|
||||
const id = equationItem.value[0];
|
||||
yield promiseTry(async () => {
|
||||
yield createSafeLoadTask(async () => {
|
||||
if (this.terminate) {
|
||||
return;
|
||||
}
|
||||
@@ -698,13 +729,17 @@ export class EmbeddedFilesLoader {
|
||||
files[batch].push(fileData);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
phase: "equation",
|
||||
fileId: id,
|
||||
latex: equation?.latex,
|
||||
});
|
||||
}
|
||||
|
||||
if(shouldRenderMermaid()) {
|
||||
const mermaidElements = getMermaidImageElements(excalidrawData.scene.elements);
|
||||
for(const element of mermaidElements) {
|
||||
yield promiseTry(async () => {
|
||||
yield createSafeLoadTask(async () => {
|
||||
if(this.terminate) {
|
||||
return;
|
||||
}
|
||||
@@ -758,6 +793,10 @@ export class EmbeddedFilesLoader {
|
||||
}
|
||||
return;
|
||||
}
|
||||
}, {
|
||||
phase: "mermaid",
|
||||
fileId: element.fileId,
|
||||
elementId: element.id,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2640,7 +2640,7 @@ export class ExcalidrawAutomate {
|
||||
return;
|
||||
}
|
||||
view = getLastActiveExcalidrawView(this.plugin);
|
||||
this.targetView = view ?? getExcalidrawViews(this.plugin.app)[0];
|
||||
this.targetView = view ?? getExcalidrawViews(this.plugin.app, true)[0];
|
||||
return;
|
||||
}
|
||||
if (view == "active") {
|
||||
@@ -2653,7 +2653,7 @@ export class ExcalidrawAutomate {
|
||||
return;
|
||||
}
|
||||
if (view == "first") {
|
||||
this.targetView = getExcalidrawViews(this.plugin.app)[0];
|
||||
this.targetView = getExcalidrawViews(this.plugin.app, true)[0];
|
||||
return;
|
||||
}
|
||||
if (view instanceof ExcalidrawView) {
|
||||
|
||||
@@ -1879,6 +1879,9 @@ export class ExcalidrawData {
|
||||
|
||||
public getOpenMode(): { viewModeEnabled: boolean; zenModeEnabled: boolean } {
|
||||
const fileCache = this.app.metadataCache.getFileCache(this.file);
|
||||
if (this.plugin.forceExcalidrawViewMode) {
|
||||
return { viewModeEnabled: true, zenModeEnabled: false };
|
||||
}
|
||||
let mode = this.plugin.settings.defaultMode === "view-mobile"
|
||||
? (DEVICE.isPhone ? "view" : "normal")
|
||||
: this.plugin.settings.defaultMode;
|
||||
|
||||
@@ -346,7 +346,7 @@ export class ScriptEngine {
|
||||
}
|
||||
|
||||
private updateToolPannels() {
|
||||
const excalidrawViews = getExcalidrawViews(this.app);
|
||||
const excalidrawViews = getExcalidrawViews(this.app, true);
|
||||
excalidrawViews.forEach(excalidrawView => {
|
||||
excalidrawView.toolsPanelRef?.current?.updateScriptIconMap(
|
||||
this.scriptIconMap,
|
||||
|
||||
@@ -281,10 +281,7 @@ export class ContentSearcher {
|
||||
|
||||
// Use setTimeout to ensure DOM has time to update after expanding details
|
||||
setTimeout(() => {
|
||||
nextActiveHighlight.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "nearest",
|
||||
});
|
||||
this.scrollResultIntoView(nextActiveHighlight);
|
||||
}, 100);
|
||||
|
||||
// Update the hit count
|
||||
@@ -303,4 +300,46 @@ export class ContentSearcher {
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
}
|
||||
|
||||
private scrollResultIntoView(element: HTMLElement): void {
|
||||
const scrollContainer = this.getScrollContainer(element);
|
||||
const targetRatio = 2 / 3;
|
||||
|
||||
if (!scrollContainer) {
|
||||
const targetScrollTop = window.scrollY + element.getBoundingClientRect().top - window.innerHeight * targetRatio;
|
||||
window.scrollTo({
|
||||
top: Math.max(0, targetScrollTop),
|
||||
behavior: "smooth",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const containerRect = scrollContainer.getBoundingClientRect();
|
||||
const elementRect = element.getBoundingClientRect();
|
||||
const targetScrollTop = scrollContainer.scrollTop + (elementRect.top - containerRect.top) - containerRect.height * targetRatio;
|
||||
const maxScrollTop = Math.max(0, scrollContainer.scrollHeight - scrollContainer.clientHeight);
|
||||
|
||||
scrollContainer.scrollTo({
|
||||
top: Math.min(Math.max(0, targetScrollTop), maxScrollTop),
|
||||
behavior: "smooth",
|
||||
});
|
||||
}
|
||||
|
||||
private getScrollContainer(element: HTMLElement): HTMLElement | null {
|
||||
let parent = element.parentElement;
|
||||
|
||||
while (parent && parent !== document.body) {
|
||||
const style = window.getComputedStyle(parent);
|
||||
const overflowY = style.overflowY;
|
||||
const isScrollable = ["auto", "scroll", "overlay"].includes(overflowY);
|
||||
if (isScrollable && parent.scrollHeight > parent.clientHeight) {
|
||||
return parent;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
|
||||
return document.scrollingElement instanceof HTMLElement
|
||||
? document.scrollingElement
|
||||
: null;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ export interface ViewSemaphores {
|
||||
|
||||
autosaving: boolean; //flags that autosaving is in progress. Autosave is an async timer, the flag prevents collision with force save
|
||||
forceSaving: boolean; //flags that forcesaving is in progress. The flag prevents collision with autosaving
|
||||
dirty: string; //null if there are no changes to be saved, the path of the file if the drawing has unsaved changes
|
||||
dirty: string | null; //null if there are no changes to be saved, the path of the file if the drawing has unsaved changes
|
||||
|
||||
//reload() is triggered by modifyEventHandler in main.ts. preventReload is a one time flag to abort reloading
|
||||
//to avoid interrupting the flow of drawing by the user.
|
||||
@@ -66,6 +66,6 @@ export interface ViewSemaphores {
|
||||
//This semaphore helps avoid collision of saves
|
||||
saving: boolean;
|
||||
hoverSleep: boolean; //flag with timer to prevent hover preview from being triggered dozens of times
|
||||
wheelTimeout:number; //used to avoid hover preview while zooming
|
||||
wheelTimeout:number | null; //used to avoid hover preview while zooming
|
||||
shouldSaveImportedImage: boolean; //forceSave after image import via the Excalidraw Image Tool or by way of paste
|
||||
}
|
||||
Vendored
+1
-1
@@ -7,7 +7,7 @@ export type ConnectionPoint = "top" | "bottom" | "left" | "right" | null;
|
||||
export type Packages = {
|
||||
react: any,
|
||||
reactDOM: any,
|
||||
excalidrawLib: typeof ExcalidrawLib,
|
||||
excalidrawLib: typeof ExcalidrawLib | null,
|
||||
}
|
||||
|
||||
export type ValueOf<T> = T[keyof T];
|
||||
|
||||
+20
-19
@@ -78,7 +78,7 @@ export const setDynamicStyle = (
|
||||
: isDark ? cmBG().lighterBy(4).mix({color:cmBlack(),ratio:0.5}) : cmBG().darkerBy(4).mix({color:cmBlack(),ratio:0.5});
|
||||
|
||||
|
||||
const text = cmBG().mix({color:isDark?lighter:darker, ratio:mixRatio});
|
||||
const text = () => cmBG().mix({color:isDark?lighter:darker, ratio:mixRatio});
|
||||
|
||||
const str = (cm: ColorMaster) => cm.stringHEX({alpha:false});
|
||||
const styleObject:{[x: string]: string;} = {
|
||||
@@ -92,23 +92,24 @@ export const setDynamicStyle = (
|
||||
[`--color-surface-primary-container`]: str(isDark?accent().darkerBy(step):accent().lighterBy(step)),
|
||||
[`--bold-color`]: str(!isDark?accent().darkerBy(15):accent().lighterBy(15)),
|
||||
[`--color-primary-darker`]: str(accent().darkerBy(step)),
|
||||
[`--color-brand-hover`]: str(accent().darkerBy(step)),
|
||||
[`--color-primary-darkest`]: str(accent().darkerBy(2*step)),
|
||||
['--button-bg-color']: str(gray1()),
|
||||
[`--button-gray-1`]: str(gray1()),
|
||||
[`--button-gray-2`]: str(gray2()),
|
||||
[`--input-border-color`]: str(gray1()),
|
||||
[`--input-bg-color`]: str(gray2()),
|
||||
[`--input-label-color`]: str(text),
|
||||
[`--input-label-color`]: str(text()),
|
||||
[`--island-bg-color`]: gray2().alphaTo(0.93).stringHEX(),
|
||||
[`--popup-secondary-bg-color`]: gray2().alphaTo(0.93).stringHEX(),
|
||||
[`--icon-fill-color`]: str(text),
|
||||
[`--text-primary-color`]: str(text),
|
||||
[`--icon-fill-color`]: str(text()),
|
||||
[`--text-primary-color`]: str(text()),
|
||||
[`--overlay-bg-color`]: gray2().alphaTo(0.6).stringHEX(),
|
||||
[`--popup-bg-color`]: str(gray1()),
|
||||
[`--color-on-surface`]: str(text),
|
||||
[`--color-on-surface`]: str(text()),
|
||||
[`--default-border-color`]: str(gray1()),
|
||||
//[`--color-gray-100`]: str(text),
|
||||
[`--color-gray-40`]: str(text), //frame
|
||||
//[`--color-gray-100`]: str(text()),
|
||||
[`--color-gray-40`]: str(isDark?text().darkerBy(30):text().lighterBy(30)), //frame
|
||||
[`--color-surface-highlight`]: str(gray1()),
|
||||
[`--color-gray-20`]: str(gray1()),
|
||||
[`--sidebar-border-color`]: str(gray1()),
|
||||
@@ -116,23 +117,23 @@ export const setDynamicStyle = (
|
||||
[`--button-hover-bg`]: str(gray1()),
|
||||
[`--sidebar-bg-color`]: gray2().alphaTo(0.93).stringHEX(),
|
||||
[`--sidebar-shadow`]: str(gray1()),
|
||||
[`--popup-text-color`]: str(text),
|
||||
[`--code-normal`]: str(text),
|
||||
[`--popup-text-color`]: str(text()),
|
||||
[`--code-normal`]: str(text()),
|
||||
[`--code-background`]: str(gray2()),
|
||||
[`--h1-color`]: str(text),
|
||||
[`--h2-color`]: str(text),
|
||||
[`--h3-color`]: str(text),
|
||||
[`--h4-color`]: str(text),
|
||||
[`color`]: str(text),
|
||||
[`--h1-color`]: str(text()),
|
||||
[`--h2-color`]: str(text()),
|
||||
[`--h3-color`]: str(text()),
|
||||
[`--h4-color`]: str(text()),
|
||||
[`color`]: str(text()),
|
||||
['--excalidraw-caret-color']: textBackgroundColor
|
||||
? str(isLightTheme ? invertColor(textBackgroundColor) : ea.getCM(textBackgroundColor))
|
||||
: (isLightTheme ? str(invertColor(color)): color),
|
||||
[`--select-highlight-color`]: str(gray1()),
|
||||
[`--color-gray-90`]: str(isDark?text.darkerBy(5):text.lighterBy(5)), //search background
|
||||
[`--color-gray-80`]: str(isDark?text.darkerBy(10):text.lighterBy(10)), //frame
|
||||
[`--color-gray-70`]: str(isDark?text.darkerBy(10):text.lighterBy(10)), //frame
|
||||
[`--default-bg-color`]: str(isDark?text.darkerBy(20):text.lighterBy(20)), //search background,
|
||||
[`--color-gray-50`]: str(text), //frame
|
||||
[`--color-gray-90`]: str(isDark?text().darkerBy(5):text().lighterBy(5)), //search background
|
||||
[`--color-gray-80`]: str(isDark?text().darkerBy(10):text().lighterBy(10)), //frame
|
||||
[`--color-gray-70`]: str(isDark?text().darkerBy(15):text().lighterBy(15)), //frame
|
||||
[`--default-bg-color`]: str(isDark?text().darkerBy(20):text().lighterBy(20)), //search background,
|
||||
[`--color-gray-50`]: str(isDark?text().darkerBy(25):text().lighterBy(25)),
|
||||
};
|
||||
|
||||
const styleString = Object.keys(styleObject)
|
||||
|
||||
+39
-2
@@ -485,8 +485,45 @@ export const getExcalidrawEmbeddedFilesFiletree = (sourceFile: TFile, plugin: Ex
|
||||
}
|
||||
|
||||
export const hasExcalidrawEmbeddedImagesTreeChanged = (sourceFile: TFile, mtime:number, plugin: ExcalidrawPlugin):boolean => {
|
||||
const fileList = getExcalidrawEmbeddedFilesFiletree(sourceFile, plugin);
|
||||
return fileList.some(f=>f.stat.mtime > mtime);
|
||||
if(!sourceFile || !plugin.isExcalidrawFile(sourceFile)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const visited = new Set<TFile>();
|
||||
const stack: TFile[] = [sourceFile];
|
||||
const app = plugin.app;
|
||||
|
||||
while (stack.length > 0) {
|
||||
const currentFile = stack.pop();
|
||||
const resolvedLinks = app.metadataCache.resolvedLinks[currentFile.path];
|
||||
if (!resolvedLinks) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const paths = Object.keys(resolvedLinks);
|
||||
for (let i = paths.length - 1; i >= 0; i--) {
|
||||
const file = app.vault.getAbstractFileByPath(paths[i]);
|
||||
if (!file || !(file instanceof TFile)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const isExcalidraw = plugin.isExcalidrawFile(file);
|
||||
if ((file.extension === "md" && !isExcalidraw) || visited.has(file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
visited.add(file);
|
||||
if (file.stat.mtime > mtime) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isExcalidraw) {
|
||||
stack.push(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function exportImageToFile(view: ExcalidrawView, path: string, content: string | ArrayBuffer | Blob, extension: string): Promise<TFile> {
|
||||
|
||||
@@ -24,9 +24,11 @@ export const getParentOfClass = (element: Element, cssClass: string):HTMLElement
|
||||
return parent?.classList?.contains(cssClass) ? parent : null;
|
||||
};
|
||||
|
||||
export function getExcalidrawViews(app: App): ExcalidrawView[] {
|
||||
export function getExcalidrawViews(app: App, initializedOnly: boolean = false): ExcalidrawView[] {
|
||||
const leaves = app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW).filter(l => l.view.getViewType?.() === VIEW_TYPE_EXCALIDRAW);
|
||||
return leaves.map(l=>l.view as ExcalidrawView);
|
||||
return leaves
|
||||
.map(l=>l.view as ExcalidrawView)
|
||||
.filter(view => !initializedOnly || Boolean(view?._loaded && view.excalidrawAPI));
|
||||
}
|
||||
|
||||
export function getExcalidraAndMarkdowViewsForFile(app: App, file: TFile): TextFileView[] {
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
import { normalizePath, type App } from "obsidian";
|
||||
import { REG_BLOCK_REF_CLEAN, REG_SECTION_REF_CLEAN } from "src/constants/constants";
|
||||
|
||||
export function splitFolderAndFilename(filepath: string): {
|
||||
export function splitFolderAndFilename(filepath: string | undefined): {
|
||||
folderpath: string;
|
||||
filename: string;
|
||||
basename: string;
|
||||
extension: string;
|
||||
} {
|
||||
if (!filepath) {
|
||||
return {
|
||||
folderpath: "",
|
||||
filename: "",
|
||||
basename: "",
|
||||
extension: "",
|
||||
};
|
||||
}
|
||||
const lastIndex = filepath.lastIndexOf("/");
|
||||
const filename = lastIndex === -1 ? filepath : filepath.substring(lastIndex + 1);
|
||||
const lastDotIndex = filename.lastIndexOf(".");
|
||||
|
||||
+18
-37
@@ -19,6 +19,7 @@ import {
|
||||
DEVICE,
|
||||
getContainerElement,
|
||||
SCRIPT_INSTALL_FOLDER,
|
||||
VIEW_TYPE_EXCALIDRAW,
|
||||
} from "../constants/constants";
|
||||
import ExcalidrawPlugin from "../core/main";
|
||||
import { ExcalidrawElement, ExcalidrawImageElement, ExcalidrawTextElement, ImageCrop } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
@@ -42,6 +43,7 @@ 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";
|
||||
import ExcalidrawView from "../view/ExcalidrawView";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
@@ -595,35 +597,14 @@ export function scaleLoadedImage (
|
||||
return { dirty, scene };
|
||||
};
|
||||
|
||||
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 !important;
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
transform: none !important;
|
||||
}`;
|
||||
const oldStylesheet = ownerDocument.getElementById(newStylesheet.id);
|
||||
if (oldStylesheet) {
|
||||
ownerDocument.head.removeChild(oldStylesheet);
|
||||
}
|
||||
if (isLeftHanded) {
|
||||
ownerDocument.head.appendChild(newStylesheet);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
if(!ownerDocument) return;
|
||||
if(visitedDocs.has(ownerDocument)) return;
|
||||
visitedDocs.add(ownerDocument);
|
||||
setDocLeftHandedMode(isLeftHanded,ownerDocument);
|
||||
if (DEVICE.isPhone) return; // no left-handed mode on phones
|
||||
EXCALIDRAW_PLUGIN.app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW).forEach((leaf) => {
|
||||
if (leaf.view instanceof ExcalidrawView) {
|
||||
leaf.view.setHandedness(isLeftHanded);
|
||||
}
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
export function calculateUIModeValue(settings: ExcalidrawSettings): UIMode {
|
||||
const phoneMode = settings.phoneUIMode ?? "mobile";
|
||||
@@ -641,7 +622,7 @@ export function calculateUIModeValue(settings: ExcalidrawSettings): UIMode {
|
||||
|
||||
export function setUIMode(app: App, settings: ExcalidrawSettings) {
|
||||
const uiMode = calculateUIModeValue(settings);
|
||||
getExcalidrawViews(app).forEach((view) => view.setUIMode(uiMode));
|
||||
getExcalidrawViews(app, true).forEach((view:ExcalidrawView) => view.setUIMode(uiMode));
|
||||
};
|
||||
|
||||
export type LinkParts = {
|
||||
@@ -709,7 +690,7 @@ export function decompress (data: string, isAsync:boolean = false): string {
|
||||
|
||||
export function isMaskFile (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -726,7 +707,7 @@ export function isMaskFile (
|
||||
|
||||
export function hasExportTheme (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -743,7 +724,7 @@ export function hasExportTheme (
|
||||
|
||||
export function getExportTheme (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
theme: string,
|
||||
): string {
|
||||
if (file) {
|
||||
@@ -763,7 +744,7 @@ export function getExportTheme (
|
||||
|
||||
export function shouldEmbedScene (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile
|
||||
file: TFile | null
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -780,7 +761,7 @@ export function shouldEmbedScene (
|
||||
|
||||
export function hasExportBackground (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -797,7 +778,7 @@ export function hasExportBackground (
|
||||
|
||||
export function getWithBackground (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -814,7 +795,7 @@ export function getWithBackground (
|
||||
|
||||
export function getExportInternalLinks(
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): boolean {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -831,7 +812,7 @@ export function getExportInternalLinks(
|
||||
|
||||
export function getExportPadding (
|
||||
plugin: ExcalidrawPlugin,
|
||||
file: TFile,
|
||||
file: TFile | null,
|
||||
): number {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
@@ -866,7 +847,7 @@ export function getExportPadding (
|
||||
return plugin.settings.exportPaddingSVG;
|
||||
};
|
||||
|
||||
export function getPNGScale (plugin: ExcalidrawPlugin, file: TFile): number {
|
||||
export function getPNGScale (plugin: ExcalidrawPlugin, file: TFile | null): number {
|
||||
if (file) {
|
||||
const fileCache = plugin.app.metadataCache.getFileCache(file);
|
||||
if (
|
||||
|
||||
@@ -24,9 +24,10 @@ export class ExcalidrawLoading extends FileView {
|
||||
public async switchToeExcalidraw() {
|
||||
const prevLeaf = this.app.workspace.activeLeaf;
|
||||
await setExcalidrawView(this.leaf);
|
||||
await sleep(100); // added this 2026.04.19 after instances where the hack did not seem to work, but wasn't able to reliably reproduce. This timeout does not seem to cause any issues and may help in cases where the hack was not working due to some sort of race condition
|
||||
const activeLeaf = this.app.workspace.activeLeaf;
|
||||
if(prevLeaf === this.leaf && activeLeaf !== prevLeaf && isUnwantedLeaf(activeLeaf)) {
|
||||
this.app.workspace.activeLeaf.detach();
|
||||
activeLeaf.detach();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+105
-61
@@ -265,7 +265,7 @@ export const addFiles = async (
|
||||
imgBase64: f.dataURL,
|
||||
mimeType: f.mimeType,
|
||||
size: f.size,
|
||||
isDark,
|
||||
isDark: !!isDark,
|
||||
isSVGwithBitmap: f.hasSVGwithBitmap,
|
||||
pdfPageViewProps: f.pdfPageViewProps,
|
||||
});
|
||||
@@ -288,22 +288,22 @@ let windowMigratedDisableZoomOnce = false;
|
||||
|
||||
export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
private dropManager: DropManager;
|
||||
public hoverPopover: HoverPopover;
|
||||
public hoverPopover: HoverPopover | null = null;
|
||||
private freedrawLastActiveTimestamp: number = 0;
|
||||
public exportDialog: ExportDialog;
|
||||
public exportDialog: ExportDialog | null = null;
|
||||
public excalidrawData: ExcalidrawData;
|
||||
//public excalidrawRef: React.MutableRefObject<any> = null;
|
||||
public excalidrawRoot: any;
|
||||
public excalidrawAPI:any = null;
|
||||
public excalidrawWrapperRef: React.MutableRefObject<any> = null;
|
||||
public toolsPanelRef: React.MutableRefObject<any> = null;
|
||||
public embeddableMenuRef: React.MutableRefObject<any> = null;
|
||||
private parentMoveObserver: MutationObserver | CustomMutationObserver;
|
||||
public excalidrawWrapperRef: React.MutableRefObject<any> | null = null;
|
||||
public toolsPanelRef: React.MutableRefObject<any> | null = null;
|
||||
public embeddableMenuRef: React.MutableRefObject<any> | null = null;
|
||||
private parentMoveObserver: MutationObserver | CustomMutationObserver | null = null;
|
||||
public linksAlwaysOpenInANewPane: boolean = false; //override the need for SHIFT+CTRL+click (used by ExcaliBrain)
|
||||
public allowFrameButtonsInViewMode: boolean = false; //override for ExcaliBrain
|
||||
private _hookServer: ExcalidrawAutomate;
|
||||
private _hookServer: ExcalidrawAutomate | null = null;
|
||||
public lastSaveTimestamp: number = 0; //used to validate if incoming file should sync with open file
|
||||
private lastLoadedFile: TFile = null;
|
||||
private lastLoadedFile: TFile | null = null;
|
||||
//store key state for view mode link resolution
|
||||
private modifierKeyDown: ModifierKeys = {shiftKey:false, metaKey: false, ctrlKey: false, altKey: false}
|
||||
public currentPosition: Position = { x: 0, y: 0 }; //these are scene coord thus would be more apt to call them sceneX and sceneY, however due to scrits already using x and y, I will keep it as is
|
||||
@@ -337,36 +337,36 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
public textMode: TextMode = TextMode.raw;
|
||||
private actionButtons: Record<ActionButtons, HTMLElement> = {} as Record<ActionButtons, HTMLElement>;
|
||||
public compatibilityMode: boolean = false;
|
||||
private obsidianMenu: ObsidianMenu;
|
||||
private embeddableMenu: EmbeddableMenu;
|
||||
private obsidianMenu: ObsidianMenu | null = null;
|
||||
private embeddableMenu: EmbeddableMenu | null = null;
|
||||
private destroyers: Function[] = [];
|
||||
private previousContentElHeight: number = 0;
|
||||
private resizeBatchTimer: number = null;
|
||||
private resizeBatchTimer: number | null = null;
|
||||
private resizeBatchWindowStart: number = 0;
|
||||
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;
|
||||
private preventReloadResetTimer: number = null;
|
||||
private editingSelfResetTimer: number = null;
|
||||
private colorChangeTimer:number = null;
|
||||
private isEditingTextResetTimer: number | null = null;
|
||||
private preventReloadResetTimer: number | null = null;
|
||||
private editingSelfResetTimer: number | null = null;
|
||||
private colorChangeTimer:number | null = null;
|
||||
private previousSceneVersion = 0;
|
||||
public previousBackgroundColor = "";
|
||||
public previousTheme = "";
|
||||
|
||||
//variables used to handle click events in view mode
|
||||
private selectedTextElement: SelectedElementWithLink = null;
|
||||
private selectedImageElement: SelectedImage = null;
|
||||
private selectedElementWithLink: SelectedElementWithLink = null;
|
||||
private selectedTextElement: SelectedElementWithLink | null = null;
|
||||
private selectedImageElement: SelectedImage | null = null;
|
||||
private selectedElementWithLink: SelectedElementWithLink | null = null;
|
||||
private blockOnMouseButtonDown = false;
|
||||
private doubleClickTimestamp = Date.now();
|
||||
|
||||
private hoverPoint = { x: 0, y: 0 };
|
||||
private hoverPreviewTarget: EventTarget = null;
|
||||
private hoverPreviewTarget: EventTarget | null = null;
|
||||
private viewModeEnabled:boolean = false;
|
||||
private lastMouseEvent: any = null;
|
||||
private editingTextElementId: string = null; //storing to handle on-screen keyboard hide events
|
||||
private editingTextElementId: string | null = null; //storing to handle on-screen keyboard hide events
|
||||
/* private lastSceneSnapshot: any = null;
|
||||
private lastViewDataSnapshot: any = null;*/
|
||||
|
||||
@@ -382,7 +382,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.dropManager = new DropManager(this);
|
||||
}
|
||||
|
||||
get hookServer (): ExcalidrawAutomate {
|
||||
get hookServer (): ExcalidrawAutomate | null {
|
||||
return this._hookServer;
|
||||
}
|
||||
get plugin(): ExcalidrawPlugin {
|
||||
@@ -394,7 +394,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
get ownerDocument(): Document {
|
||||
return DEVICE.isMobile?document:this.containerEl.ownerDocument;
|
||||
}
|
||||
get ownerWindow(): Window {
|
||||
get ownerWindow(): Window | null {
|
||||
return this.ownerDocument.defaultView;
|
||||
}
|
||||
|
||||
@@ -417,7 +417,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
preventAutozoom() {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.preventAutozoom, "ExcalidrawView.preventAutozoom");
|
||||
this.semaphores.preventAutozoom = true;
|
||||
if (!!this.semaphores) {
|
||||
this.semaphores.preventAutozoom = true;
|
||||
}
|
||||
window.setTimeout(() => {
|
||||
if(!this.semaphores) return;
|
||||
this.semaphores.preventAutozoom = false;
|
||||
@@ -432,7 +434,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
scene = this.getScene();
|
||||
}
|
||||
const filepath = `${this.file.path.substring(
|
||||
const filepath = `${this.file?.path.substring(
|
||||
0,
|
||||
this.file.path.lastIndexOf(".md"),
|
||||
)}.excalidraw`;
|
||||
@@ -456,7 +458,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
return;
|
||||
}
|
||||
filename = `${filename}.excalidraw`;
|
||||
const folderpath = splitFolderAndFilename(this.file.path).folderpath;
|
||||
const folderpath = splitFolderAndFilename(this.file?.path).folderpath;
|
||||
await checkAndCreateFolder(folderpath); //create folder if it does not exist
|
||||
const path = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
@@ -482,6 +484,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
public getViewExportTheme(theme?:string):string {
|
||||
if(theme) return theme;
|
||||
if(!this.file) return this.excalidrawAPI.getAppState().theme;
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -490,6 +493,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
public getViewExportEmbedScene(embedScene?:boolean):boolean {
|
||||
if(!this.file) return false;
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -501,6 +505,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
public getViewExportPadding(padding?: number): number {
|
||||
if(typeof padding !== "undefined") return padding;
|
||||
if(!this.file) return 0;
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -510,6 +515,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
public getViewExportScale(scale?: number): number {
|
||||
if(typeof scale !== "undefined") return scale;
|
||||
if(!this.file) return 1;
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -518,7 +524,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
public getViewExportWithBackground(withBackground?:boolean) {
|
||||
if(typeof withBackground !== "undefined") return withBackground;
|
||||
if(typeof withBackground !== "undefined" || !this.file) {
|
||||
return withBackground;
|
||||
}
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -527,7 +535,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
public getViewExportIncludeInternalLinks(includeInternalLinks?:boolean) {
|
||||
if(typeof includeInternalLinks !== "undefined") return includeInternalLinks;
|
||||
if(typeof includeInternalLinks !== "undefined" || !this.file) {
|
||||
return includeInternalLinks;
|
||||
}
|
||||
if(!this.exportDialog) {
|
||||
this.exportDialog = new ExportDialog(this.plugin, this,this.file);
|
||||
}
|
||||
@@ -576,7 +586,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.svg, "ExcalidrawView.svg", scene, theme, embedScene);
|
||||
|
||||
const exportSettings: ExportSettings = {
|
||||
withBackground: this.getViewExportWithBackground(),
|
||||
withBackground: !!this.getViewExportWithBackground(),
|
||||
withTheme: true,
|
||||
isMask: isMaskFile(this.plugin, this.file),
|
||||
skipInliningFonts: !embedFont,
|
||||
@@ -607,6 +617,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(!data) {
|
||||
data = {};
|
||||
}
|
||||
if (!this.file) return;
|
||||
let { scene, embedScene, autoexportConfig } = data;
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.saveSVG, "ExcalidrawView.saveSVG", scene, embedScene);
|
||||
if (!scene) {
|
||||
@@ -642,6 +653,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
const scene = this.getScene(selectedOnly);
|
||||
if(!scene) {
|
||||
return;
|
||||
}
|
||||
if(!this.getViewExportIncludeInternalLinks()) {
|
||||
scene.elements = sceneRemoveInternalLinks(scene);
|
||||
}
|
||||
@@ -655,12 +669,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
public async getSVG(embedScene?: boolean, selectedOnly?: boolean):Promise<SVGSVGElement> {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.getSVG, "ExcalidrawView.getSVG", embedScene, selectedOnly);
|
||||
if (!this.excalidrawAPI || !this.file) {
|
||||
return;
|
||||
return new SVGSVGElement();
|
||||
}
|
||||
|
||||
const svg = await this.svg(this.getScene(selectedOnly),undefined,embedScene, true);
|
||||
if (!svg) {
|
||||
return;
|
||||
return new SVGSVGElement();
|
||||
}
|
||||
return svg;
|
||||
}
|
||||
@@ -675,6 +689,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
const scene = this.getScene(selectedOnly);
|
||||
if (!scene) {
|
||||
return;
|
||||
}
|
||||
if(!this.getViewExportIncludeInternalLinks()) {
|
||||
scene.elements = sceneRemoveInternalLinks(scene);
|
||||
}
|
||||
@@ -691,22 +708,22 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
|
||||
const boundingBox = this.plugin.ea.getBoundingBox(scene.elements);
|
||||
const margin = getMarginValue(this.exportDialog.margin);
|
||||
const margin = getMarginValue(this.exportDialog?.margin ?? "normal");
|
||||
const [width, height] = [boundingBox.width, boundingBox.height];
|
||||
|
||||
exportToPDF({
|
||||
SVG: [svg],
|
||||
scale: {
|
||||
zoom: this.exportDialog.scale,
|
||||
zoom: this.exportDialog?.scale ?? 1,
|
||||
fitToPage: pageSize === "MATCH IMAGE" || pageSize === "HD Screen"
|
||||
? 1
|
||||
: this.exportDialog.fitToPage
|
||||
: (this.exportDialog?.fitToPage ?? 1)
|
||||
},
|
||||
pageProps: {
|
||||
dimensions: getPageDimensions(pageSize, orientation, {width, height}),
|
||||
backgroundColor: this.exportDialog.getPaperColor(),
|
||||
backgroundColor: this.exportDialog?.getPaperColor() ?? "#FFFFFF",
|
||||
margin,
|
||||
alignment: this.exportDialog.alignment,
|
||||
alignment: this.exportDialog?.alignment ?? "center",
|
||||
},
|
||||
filename: this.file.basename+".pdf",
|
||||
});
|
||||
@@ -716,7 +733,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.png, "ExcalidrawView.png", scene, theme, embedScene);
|
||||
|
||||
const exportSettings: ExportSettings = {
|
||||
withBackground: this.getViewExportWithBackground(),
|
||||
withBackground: !!this.getViewExportWithBackground(),
|
||||
withTheme: true,
|
||||
isMask: isMaskFile(this.plugin, this.file),
|
||||
};
|
||||
@@ -746,6 +763,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(!data) {
|
||||
data = {};
|
||||
}
|
||||
if (!this.file) return;
|
||||
let { scene, embedScene, autoexportConfig } = data;
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.savePNG, "ExcalidrawView.savePNG", scene, embedScene);
|
||||
if (!scene) {
|
||||
@@ -3966,6 +3984,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
bindingPreference: st.bindingPreference,
|
||||
isBindingEnabled: st.isBindingEnabled,
|
||||
isMidpointSnappingEnabled: st.isMidpointSnappingEnabled,
|
||||
boxSelectionMode: st.boxSelectionMode,
|
||||
},
|
||||
prevTextMode: this.prevTextMode,
|
||||
files,
|
||||
@@ -4251,8 +4270,22 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//Timeout is required for Excalidraw to first complete the selection action before execution
|
||||
//of the link click continues
|
||||
window.setTimeout(()=>{
|
||||
if (!this.isLinkSelected()) return;
|
||||
this.handleLinkClick(e);
|
||||
if (this.isLinkSelected()) {
|
||||
this.handleLinkClick(e);
|
||||
return;
|
||||
}
|
||||
// When CTRL+ALT (or CMD+OPT on Mac) is pressed, Excalidraw switches to lasso select
|
||||
// mode instead of selecting the element under the pointer, so isLinkSelected() returns
|
||||
// false. Fall back to checking the element at the current pointer position.
|
||||
if (isWinCTRLorMacCMD(e) && isWinALTorMacOPT(e)) {
|
||||
const selectedText = getTextElementAtPointer(this.currentPosition, this);
|
||||
const selectedImage = selectedText?.id ? null : getImageElementAtPointer(this.currentPosition, this);
|
||||
const selectedElementWithLink = (selectedText?.id || selectedImage?.id) ? null : getElementWithLinkAtPointer(this.currentPosition, this);
|
||||
if (selectedText?.id || selectedImage?.id || selectedElementWithLink?.id) {
|
||||
this.removeLinkTooltip();
|
||||
this.linkClick(e, selectedText, selectedImage, selectedElementWithLink);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5776,7 +5809,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.Heading,
|
||||
{
|
||||
color: decoration,
|
||||
color: "var(--color-gray-40)",
|
||||
message: nextRankDelta > 0
|
||||
? `${rank}: ${nextRankDelta} ${t("WELCOME_RANK_NEXT")}`
|
||||
: `${rank}: ${t("WELCOME_RANK_LEGENDARY")}`,
|
||||
@@ -5797,6 +5830,16 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.Menu,
|
||||
{},
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
icon: ICONS.Learn,
|
||||
href: "https://community.sketch-your-mind.com",
|
||||
shortcut: null,
|
||||
"aria-label": t("WELCOME_SYM_ARIA"),
|
||||
},
|
||||
t("WELCOME_SYM_LINK")
|
||||
),
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
@@ -5807,16 +5850,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
},
|
||||
t("WELCOME_YOUTUBE_LINK")
|
||||
),
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
icon: ICONS.Discord,
|
||||
href: "https://discord.gg/DyfAXFwUHc",
|
||||
shortcut: null,
|
||||
"aria-label": t("WELCOME_DISCORD_ARIA"),
|
||||
},
|
||||
t("WELCOME_DISCORD_LINK")
|
||||
),
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
@@ -5827,16 +5860,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
},
|
||||
t("WELCOME_TWITTER_LINK")
|
||||
),
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
icon: ICONS.Learn,
|
||||
href: "https://visual-thinking-workshop.com",
|
||||
shortcut: null,
|
||||
"aria-label": t("WELCOME_LEARN_ARIA"),
|
||||
},
|
||||
t("WELCOME_LEARN_LINK")
|
||||
),
|
||||
React.createElement(
|
||||
WelcomeScreen.Center.MenuItemLink,
|
||||
{
|
||||
@@ -5860,6 +5883,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
MainMenu,
|
||||
{},
|
||||
React.createElement(MainMenu.DefaultItems.ChangeCanvasBackground),
|
||||
React.createElement(MainMenu.DefaultItems.Preferences),
|
||||
React.createElement(MainMenu.DefaultItems.ToggleTheme),
|
||||
React.createElement(MainMenu.Separator),
|
||||
React.createElement(
|
||||
@@ -5911,6 +5935,15 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
t("TRAY_SWITCH_TO_MD")
|
||||
),
|
||||
React.createElement(MainMenu.Separator),
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
icon: ICONS.Learn,
|
||||
"aria-label": t("LINKS_JOIN_SYM_ARIA"),
|
||||
onSelect: ()=> openExternalLink("https://community.sketch-your-mind.com", this.app),
|
||||
},
|
||||
t("LINKS_JOIN_SYM")
|
||||
),
|
||||
React.createElement(MainMenu.DefaultItems.Help),
|
||||
React.createElement(MainMenu.DefaultItems.ClearCanvas),
|
||||
);
|
||||
@@ -6263,8 +6296,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//console.log("ExcalidrawView.instantiateExcalidraw()");
|
||||
this.clearDirty();
|
||||
|
||||
// apply the handedness, settings were just reloaded in the calling method.
|
||||
this.setHandedness(this.plugin.settings.isLeftHanded);
|
||||
|
||||
this.excalidrawRoot = ReactDOM.createRoot(this.contentEl);
|
||||
this.excalidrawRoot.render(React.createElement(this.excalidrawRootElement.bind(this,initdata)));
|
||||
this.excalidrawRoot.render(React.createElement(this.excalidrawRootElement.bind(this, initdata)));
|
||||
}
|
||||
|
||||
private updateContainerSize(containerId?: string, delay: boolean = false, justloaded: boolean = false) {
|
||||
@@ -6396,6 +6432,14 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
api.setDesktopUIMode(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the desired handedness to this `ExcalidrawView`.
|
||||
* @param isLeftHanded - the desired handedness
|
||||
*/
|
||||
public setHandedness(isLeftHanded: boolean) {
|
||||
this.contentEl.toggleClass("excalidraw-left-handed", isLeftHanded);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param elements
|
||||
|
||||
@@ -339,7 +339,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
|
||||
//Render WorkspaceLeaf or CanvasNode
|
||||
//--------------------------------------------------------------------------------
|
||||
function RenderObsidianView(
|
||||
{ mdProps, element, linkText, view, containerRef, activeEmbeddable, theme, canvasColor, selectedElementId }:{
|
||||
{ mdProps, element, linkText, view, containerRef, activeEmbeddable, theme, canvasColor, selectedElementId, sceneZoom }:{
|
||||
mdProps: EmbeddableMDCustomProps;
|
||||
element: ExcalidrawEmbeddableElement;
|
||||
linkText: string;
|
||||
@@ -349,6 +349,7 @@ function RenderObsidianView(
|
||||
theme: string;
|
||||
canvasColor: string;
|
||||
selectedElementId: string;
|
||||
sceneZoom: number;
|
||||
}): JSX.Element {
|
||||
|
||||
const { subpath, file } = processLinkText(linkText, view);
|
||||
@@ -364,7 +365,6 @@ function RenderObsidianView(
|
||||
const isActiveRef = React.useRef(false);
|
||||
const viewTypeRef = React.useRef("empty");
|
||||
const themeRef = React.useRef(theme);
|
||||
const elementRef = React.useRef(element);
|
||||
const pdfObserverRef = React.useRef(null);
|
||||
const pdfObserverDisabledRef = React.useRef(false);
|
||||
const mobilePatchCleanupRef = React.useRef(null);
|
||||
@@ -374,11 +374,6 @@ function RenderObsidianView(
|
||||
React.useEffect(() => {
|
||||
themeRef.current = theme;
|
||||
}, [theme]);
|
||||
|
||||
// Update elementRef when element changes
|
||||
React.useEffect(() => {
|
||||
elementRef.current = element;
|
||||
}, [element]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//block propagation of events to the parent if the embeddable element is active
|
||||
@@ -556,7 +551,24 @@ function RenderObsidianView(
|
||||
//--------------------------------------------------------------------------------
|
||||
//Set colors of the canvas node
|
||||
//--------------------------------------------------------------------------------
|
||||
function roundEmbeddableSize(value: number): number {
|
||||
return Math.round(value * 1000) / 1000;
|
||||
}
|
||||
|
||||
function setEmbeddableSizeVars(canvasNode: HTMLDivElement, element: ExcalidrawEmbeddableElement, sceneZoom: number) {
|
||||
const scaleX = Math.abs(element.scale?.[0] ?? 1);
|
||||
const scaleY = Math.abs(element.scale?.[1] ?? 1);
|
||||
const width = roundEmbeddableSize(element.width / scaleX);
|
||||
const height = roundEmbeddableSize(element.height / scaleY);
|
||||
canvasNode?.style.setProperty("--embeddable-width", `${width}px`);
|
||||
canvasNode?.style.setProperty("--embeddable-height", `${height}px`);
|
||||
canvasNode?.style.setProperty("--embeddable-scaleX", `${roundEmbeddableSize(scaleX)}`);
|
||||
canvasNode?.style.setProperty("--embeddable-scaleY", `${roundEmbeddableSize(scaleY)}`);
|
||||
canvasNode?.style.setProperty("--scene-zoom", `${roundEmbeddableSize(sceneZoom ?? 1)}`);
|
||||
}
|
||||
|
||||
function setColors (canvasNode: HTMLDivElement, element: ExcalidrawEmbeddableElement, mdProps: EmbeddableMDCustomProps, canvasColor: string, viewType: string) {
|
||||
setEmbeddableSizeVars(canvasNode, element, sceneZoom);
|
||||
if(!mdProps) return;
|
||||
if (!leafRef.current?.hasOwnProperty("node")) return;
|
||||
|
||||
@@ -647,7 +659,6 @@ function RenderObsidianView(
|
||||
if(!containerRef.current) {
|
||||
return;
|
||||
}
|
||||
const element = elementRef.current;
|
||||
const canvasNode = containerRef.current;
|
||||
if(!canvasNode.hasClass("canvas-node")) return;
|
||||
setColors(canvasNode, element, mdProps, canvasColor, viewTypeRef.current);
|
||||
@@ -660,12 +671,25 @@ function RenderObsidianView(
|
||||
mdProps?.borderMatchElement,
|
||||
mdProps?.borderColor,
|
||||
mdProps?.borderOpacity,
|
||||
elementRef.current,
|
||||
element.backgroundColor,
|
||||
element.strokeColor,
|
||||
element.width,
|
||||
element.height,
|
||||
element.scale?.[0],
|
||||
element.scale?.[1],
|
||||
sceneZoom,
|
||||
containerRef.current,
|
||||
canvasColor,
|
||||
viewTypeRef.current,
|
||||
])
|
||||
|
||||
React.useEffect(() => {
|
||||
if(!containerRef.current) {
|
||||
return;
|
||||
}
|
||||
setEmbeddableSizeVars(containerRef.current, element, sceneZoom);
|
||||
}, [element.width, element.height, element.scale?.[0], element.scale?.[1], sceneZoom]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//Switch to preview mode when the iframe is not active
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -886,6 +910,7 @@ export const CustomEmbeddable: React.FC<{element: ExcalidrawEmbeddableElement; v
|
||||
theme={appState.theme}
|
||||
canvasColor={appState.viewBackgroundColor}
|
||||
selectedElementId={selectedElementIds.length === 1 ? selectedElementIds[0] : null}
|
||||
sceneZoom={appState.zoom.value}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -134,7 +134,7 @@ export class ObsidianMenu {
|
||||
this.view.excalidrawAPI?.setToast({message:`Pin removed: ${name}`, duration: 3000, closable: true});
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
getExcalidrawViews(this.plugin.app).forEach(excalidrawView=>excalidrawView.updatePinnedScripts());
|
||||
getExcalidrawViews(this.plugin.app, true).forEach(excalidrawView=>excalidrawView.updatePinnedScripts());
|
||||
})()
|
||||
},
|
||||
1500
|
||||
|
||||
@@ -220,6 +220,16 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
new ReleaseNotes(view.app, view.plugin, PLUGIN_VERSION).open();
|
||||
}
|
||||
|
||||
actionOpenAboutExcalidraw() {
|
||||
const view = this.getView();
|
||||
if (!view) return;
|
||||
new ReleaseNotes(view.app, view.plugin, null, {
|
||||
message: t("FIRST_RUN"),
|
||||
persistVersion: false,
|
||||
title: t("ABOUT_EXCALIDRAW"),
|
||||
}).open();
|
||||
}
|
||||
|
||||
actionConvertExcalidrawToMD() {
|
||||
this.getView()?.convertExcalidrawToMD();
|
||||
}
|
||||
@@ -436,7 +446,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
api?.setToast({message:`Pinned: ${scriptName}`, duration: 3000, closable: true})
|
||||
}
|
||||
await plugin.saveSettings();
|
||||
getExcalidrawViews(plugin.app).forEach(excalidrawView=>excalidrawView.updatePinnedScripts());
|
||||
getExcalidrawViews(plugin.app, true).forEach(excalidrawView=>excalidrawView.updatePinnedScripts());
|
||||
}
|
||||
|
||||
private islandOnClick(event: React.MouseEvent<HTMLDivElement, MouseEvent>) {
|
||||
@@ -558,6 +568,12 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
action={this.actionOpenReleaseNotes.bind(this)}
|
||||
icon={ICONS.releaseNotes}
|
||||
/>
|
||||
<ActionButton
|
||||
key={"about-excalidraw"}
|
||||
title={t("ABOUT_EXCALIDRAW")}
|
||||
action={this.actionOpenAboutExcalidraw.bind(this)}
|
||||
icon={ICONS.Info}
|
||||
/>
|
||||
{this.state.isPreviewMode === null ? (
|
||||
<ActionButton
|
||||
key={"convert"}
|
||||
|
||||
+177
-13
@@ -136,6 +136,92 @@ li[data-testid] {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo {
|
||||
margin: 0 auto 1rem;
|
||||
width: calc(100% - 1.6em);
|
||||
max-width: calc(100% - 1.6em);
|
||||
box-sizing: border-box;
|
||||
padding: 0.35rem 0.75rem;
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
border-radius: 12px;
|
||||
background: linear-gradient(135deg, var(--background-secondary), var(--background-primary));
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
cursor: pointer;
|
||||
font-size: var(--font-ui-smaller);
|
||||
font-weight: var(--font-medium);
|
||||
list-style: revert;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__summary-title {
|
||||
color: var(--text-normal);
|
||||
font-size: var(--font-ui-smaller);
|
||||
font-weight: var(--font-medium);
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__summary-title.is-hidden {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__summary-state {
|
||||
color: var(--text-muted);
|
||||
font-size: var(--font-ui-smaller);
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__content {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 8rem) minmax(0, 1fr);
|
||||
gap: 1rem;
|
||||
align-items: center;
|
||||
margin-top: 0.85rem;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__image-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 8rem;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__text p {
|
||||
margin: 0 0 0.7rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__text p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__text a {
|
||||
font-weight: var(--font-semibold);
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo.is-collapsed {
|
||||
padding-bottom: 0.35rem;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.excalidraw-mastery-promo__content {
|
||||
grid-template-columns: 1fr;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.excalidraw-mastery-promo__image {
|
||||
max-width: 7rem;
|
||||
}
|
||||
}
|
||||
|
||||
.excalidraw-scriptengine-install td>img {
|
||||
width: 100%;
|
||||
max-width:800px;
|
||||
@@ -412,10 +498,11 @@ div.excalidraw-draginfo {
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
/*
|
||||
.excalidraw [data-radix-popper-content-wrapper] {
|
||||
/*Overrides position:fixed in popover*/
|
||||
Overrides position:fixed in popover
|
||||
position: absolute !important;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* In Obsidian-Excalidraw, the Sidebar-Trigger is sometimes in a Container/
|
||||
Island, so it shall be styled like any other of its .ToolIcon siblings */
|
||||
@@ -640,6 +727,23 @@ summary.excalidraw-setting-h3 {
|
||||
margin-block-end: var(--p-spacing);
|
||||
}
|
||||
|
||||
/* Modifier key settings column headers */
|
||||
.modifier-key-header-row {
|
||||
padding-block: 2px;
|
||||
min-height: unset;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
.modifier-key-col-header {
|
||||
display: inline-flex;
|
||||
width: var(--toggle-width, 40px);
|
||||
justify-content: center;
|
||||
font-size: var(--font-smallest);
|
||||
color: var(--text-muted);
|
||||
font-weight: var(--font-semibold);
|
||||
letter-spacing: 0.03em;
|
||||
}
|
||||
|
||||
summary.excalidraw-setting-h4 {
|
||||
font-variant: var(--h4-variant);
|
||||
letter-spacing: -0.015em;
|
||||
@@ -775,7 +879,14 @@ root {
|
||||
--excalidraw-caret-color: initial;
|
||||
}
|
||||
|
||||
textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
/*
|
||||
textarea.excalidraw-wysiwyg,*/
|
||||
.excalidraw input,
|
||||
.excalidraw .ttd-dialog-content textarea {
|
||||
caret-color: var(--excalidraw-caret-color) !important;
|
||||
}
|
||||
|
||||
.excalidraw textarea.ttd-dialog-input {
|
||||
caret-color: var(--excalidraw-caret-color) !important;
|
||||
}
|
||||
|
||||
@@ -829,10 +940,6 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
color: var(--color-gray-50);
|
||||
}
|
||||
|
||||
.excalidraw textarea.ttd-dialog-input {
|
||||
caret-color: var(--excalidraw-caret-color) !important;
|
||||
}
|
||||
|
||||
.excalidraw .ToolIcon_type_button {
|
||||
color: var(--text-primary-color);
|
||||
}
|
||||
@@ -937,17 +1044,17 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 1px 4px 0 rgba(0,0,0,0.10);
|
||||
padding: 0.5em 0.8em;
|
||||
margin-bottom: 2em;
|
||||
min-width: 18rem;
|
||||
margin-bottom: 0.5em;
|
||||
max-width: calc(100% - 1.6em);
|
||||
position: sticky;
|
||||
top: 1rem;
|
||||
margin-right: 1rem;
|
||||
margin-left: 1rem;
|
||||
top: 0;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.excalidraw-search .document-search {
|
||||
align-items: center;
|
||||
max-width: none;
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.excalidraw-search .search-input-container.document-search-input {
|
||||
@@ -1046,6 +1153,21 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
z-index: 9999;
|
||||
}
|
||||
|
||||
.excalidraw .App-bottom-bar .App-toolbar {
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
.excalidraw-left-handed .excalidraw .App-bottom-bar {
|
||||
justify-content: flex-end !important;
|
||||
left: auto !important;
|
||||
right: 0 !important;
|
||||
transform: none !important;
|
||||
|
||||
.App-toolbar {
|
||||
justify-content: end;
|
||||
}
|
||||
}
|
||||
|
||||
.excalidraw--tray .App-bottom-bar > .Island > .App-toolbar > .App-toolbar-content {
|
||||
/* This will render the undo/redo buttons as if they weren't
|
||||
in a separate container, but simply part of the row */
|
||||
@@ -1163,4 +1285,46 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
|
||||
.is-mobile .excalidraw.excalidraw--mobile .FixedSideContainer.FixedSideContainer_side_top.App-top-bar {
|
||||
margin-top: 1rem
|
||||
}
|
||||
|
||||
/*
|
||||
Obsidian Sheets Plus support
|
||||
*/
|
||||
.excalidraw__embeddable__outer .lj-content-view {
|
||||
width: var(--embeddable-width);
|
||||
height: var(--embeddable-height);
|
||||
}
|
||||
|
||||
.excalidraw__embeddable__outer #sheet-box {
|
||||
height: calc(var(--embeddable-height) - var(--lj-toolbar-height) + 40px);
|
||||
}
|
||||
|
||||
.excalidraw__embeddable__outer .lj-univer .univer-relative.univer-grid {
|
||||
width: var(--embeddable-width);
|
||||
}
|
||||
|
||||
/*
|
||||
End Obsidian Sheets Plus support
|
||||
*/
|
||||
|
||||
/*Revert greedy Obsidian style settings*/
|
||||
|
||||
.excalidraw input[type="radio"]:active,
|
||||
.excalidraw input[type="radio"]:focus,
|
||||
.excalidraw input[type="radio"]:focus-visible,
|
||||
.excalidraw input[type="radio"]:checked {
|
||||
background-color: revert;
|
||||
border-color: revert;
|
||||
box-shadow: none;
|
||||
outline: revert;
|
||||
}
|
||||
|
||||
.excalidraw input[type="radio"]::after,
|
||||
.excalidraw input[type="radio"]:checked::after {
|
||||
content: none !important;
|
||||
display: none !important;
|
||||
background-color: transparent !important;
|
||||
-webkit-mask-image: none !important;
|
||||
-webkit-mask-size: initial !important;
|
||||
-webkit-mask-position: initial !important;
|
||||
}
|
||||
+4
-1
@@ -1,12 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"sourceMap": false,
|
||||
"module": "es2020",
|
||||
"target": "es2022", //min es2017 because script engine requires for async execution and min es2018 for named capture groups
|
||||
"allowJs": false,
|
||||
"noImplicitAny": true,
|
||||
"moduleResolution": "node",
|
||||
"types": ["node"],
|
||||
"paths": {
|
||||
"src/*": ["./src/*"]
|
||||
},
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
"resolveJsonModule": true,
|
||||
|
||||
+4
-1
@@ -1,11 +1,14 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"sourceMap": false,
|
||||
"module": "es2020",
|
||||
"target": "es2022", //min es2017 because script engine requires for async execution and min es2018 for named capture groups
|
||||
"allowJs": false,
|
||||
"noImplicitAny": true,
|
||||
"types": ["node"],
|
||||
"paths": {
|
||||
"src/*": ["./src/*"]
|
||||
},
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"importHelpers": true,
|
||||
|
||||
Reference in new issue
Block a user