Compare commits

...
15 Commits
Author SHA1 Message Date
zsviczian 45709e5f1e 2.22.0-beta-1, 0.18.0-87 2026-03-25 21:48:38 +01:00
zsviczian 5e9eb66510 Embedded file loader breaks if a single load breaks, needs multiple file open for the loader to complete 2026-03-25 18:54:02 +01:00
zsviczian af7891da4e update messages 2026-03-25 06:46:13 +00:00
zsviczian 65831073a6 MindMap Builder v26.03.25 (fix navigation) 2026-03-25 06:39:14 +00:00
zsviczian 7093c221d1 Merge pull request #2719 from heinrich26/fix-moving-tray
fix #2718
2026-03-25 07:34:04 +01:00
zsviczian 675700696a navigation bug fix 2026-03-24 20:28:21 +01:00
zsviczian becb650902 mindmap builder group/ungroup fix 2026-03-24 18:50:25 +01:00
henrich26 1a7d9c6f8c fix #2718
rewrote the toggle-mechanism for the left-handedness to use css-classes, making it easier to style.
2026-03-24 17:39:07 +01:00
zsviczian 403467c134 fixed mindmap builder 26.03.20b 2026-03-20 06:01:47 +01:00
zsviczian 8a1b90c06b mindmap builder fix toggle node between embeddable and link 2026-03-19 20:49:08 +01:00
zsviczian f93b3b9306 fixed MindMap Builder PDF and Embeddable paste 2026-03-19 13:15:39 +01:00
zsviczian f7ce333fea 2.21.2 2026-03-19 06:47:35 +01:00
zsviczian 78b2a351bd Merge pull request #2715 from sreedharsreeram/fix/pen-roughness-not-applying-to-shapes
Fix custom pen sloppiness not applying to shapes/lines
2026-03-19 06:35:34 +01:00
Sreeram Sreedhar 1db888991a Fix custom pen sloppiness not applying to shapes
The condition for applying pen.roughness was inverted - it was skipping
the roughness value when set and applying it when null.
2026-03-18 20:51:17 -07:00
zsviczian a72ecbc75d updated package lock 2026-03-18 20:40:07 +01:00
23 changed files with 1882 additions and 1062 deletions

No files matched your search

@@ -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;
@@ -3255,6 +3255,7 @@ 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: {
@@ -3425,6 +3426,7 @@ declare class App extends React.Component<AppProps, AppState> {
private handleIframeLikeElementHover;
/** @returns true if iframe-like element click handled */
private handleIframeLikeCenterClick;
private isDoubleClick;
private isIframeLikeElementCenter;
private updateEmbedValidationStatus;
private updateEmbeddables;
@@ -3637,6 +3639,8 @@ declare class App extends React.Component<AppProps, AppState> {
private onGestureEnd;
private handleTextWysiwyg;
private deselectElements;
private getSelectedTextElement;
private getSelectedTextEditingContainerAtPosition;
private getTextElementAtPosition;
private getElementAtPosition;
private getElementsAtPosition;
+132 -41
View File
@@ -12,7 +12,7 @@ Content structure:
2. The curated script overview (index-new.md)
3. Raw source of every *.md script in /ea-scripts (each fenced code block is auto-closed to ensure well-formed aggregation)
Generated on: 2026-03-16T18:46:00.868Z
Generated on: 2026-03-25T06:30:54.111Z
---
@@ -9946,8 +9946,22 @@ 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);
if (!trimmed.startsWith("![[") || !trimmed.endsWith("]]")) return null;
const content = trimmed.slice(3, -2);
@@ -9965,7 +9979,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 {
@@ -11757,8 +11771,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;
}
@@ -11773,13 +11798,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;
};
@@ -11800,7 +11836,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) => {
@@ -11972,7 +12008,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]];
}
@@ -13281,7 +13317,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));
}
});
}
@@ -13516,7 +13552,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);
@@ -13644,17 +13680,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 = (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;
@@ -13953,7 +13995,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);
@@ -14091,6 +14133,9 @@ const getTextFromNode = (all, node, getRaw = false, shortPath = false) => {
}
const file = ea.getViewFileForImageElement(node);
if (file) {
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 "";
@@ -15793,12 +15838,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
@@ -15913,11 +15981,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
@@ -16085,9 +16167,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]);
}
@@ -16097,7 +16185,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();
@@ -16363,7 +16453,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 = [];
@@ -16607,7 +16697,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)}`);
@@ -16907,7 +16997,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;
@@ -16931,10 +17021,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;
@@ -17078,7 +17169,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;
@@ -18725,7 +18816,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") {
File diff suppressed because it is too large. Load diff
+131 -40
View File
@@ -1229,8 +1229,22 @@ 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);
if (!trimmed.startsWith("![[") || !trimmed.endsWith("]]")) return null;
const content = trimmed.slice(3, -2);
@@ -1248,7 +1262,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 {
@@ -3040,8 +3054,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 +3081,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 +3119,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 +3291,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 +4600,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));
}
});
}
@@ -4799,7 +4835,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 +4963,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 = (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;
@@ -5236,7 +5278,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);
@@ -5374,6 +5416,9 @@ const getTextFromNode = (all, node, getRaw = false, shortPath = false) => {
}
const file = ea.getViewFileForImageElement(node);
if (file) {
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 "";
@@ -7076,12 +7121,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 +7264,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 +7450,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 +7468,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();
@@ -7646,7 +7736,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 +7980,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)}`);
@@ -8190,7 +8280,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 +8304,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 +8452,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;
@@ -10008,7 +10099,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") {
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -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
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.21.1",
"version": "2.22.0-beta-1",
"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",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.21.1",
"version": "2.21.2",
"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",
+81 -199
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -25,7 +25,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.18.0-86",
"@zsviczian/excalidraw": "0.18.0-87",
"chroma-js": "^3.1.2",
"clsx": "^2.0.0",
"@zsviczian/colormaster": "^1.2.2",
+1 -6
View File
@@ -1260,13 +1260,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 +1274,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);
}
+1 -4
View File
@@ -1010,13 +1010,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;
},
+18
View File
@@ -16,6 +16,24 @@ export const RELEASE_NOTES: { [k: string]: string } = {
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…
<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.0":`
## Fixed
- Tray-mode panel buttons get misaligned [#2718](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2718) 🙏[@heinrich26](https://github.com/heinrich26)
- Improved loading of nested Excalidraw files in the Excalidraw scene, plus some limited performance improvement.
## New from Excalidraw.com
- Various text element editing improvements, including handle on the right side of wrapped text to enable text auto-resizing (instead of having to open the context menu for this) [#10979](https://github.com/excalidraw/excalidraw/pull/10979)
- Support for Mermaid state diagrams [#11031](https://github.com/excalidraw/excalidraw/pull/11031)
## New
- (partial) support for embedding the [Sheet Plus](obsidian://show-plugin?id=sheet-plus) plugin as an active embedded element in Excalidraw.
`,
"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.
- 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":`
## Fixed
+1 -4
View File
@@ -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();
}),
);
+137 -98
View File
@@ -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,
});
}
};
+2 -1
View File
@@ -89,7 +89,7 @@ import { log } from "../utils/debugHelper";
import { ExcalidrawLib } from "../types/excalidrawLib";
import { GlobalPoint } from "@zsviczian/excalidraw/types/math/src/types";
import { AddImageOptions, ImageInfo, KeyBlocker, ScriptSettingValue, SVGColorInfo } from "src/types/excalidrawAutomateTypes";
import { _measureText, cloneElement, createPNG, createSVG, ensureActiveScriptSettingsObject, errorMessage, filterColorMap, getEmbeddedFileForImageElment, getLineBox, getTemplate, isColorStringTransparent, isSVGColorInfo, mergeColorMapIntoSVGColorInfo, normalizeBindMode, normalizeFixedPoint, normalizeLinePoints, repositionElementsToCursor, svgColorInfoToColorMap, updateOrAddSVGColorInfo, verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils";
import { _measureText, cloneElement, createPNG, createSVG, ensureActiveScriptSettingsObject, errorMessage, filterColorMap, getEmbeddedFileForImageElment, getLineBox, getTemplate, isColorStringTransparent, isImageOrPDFTransclusion, isSVGColorInfo, mergeColorMapIntoSVGColorInfo, normalizeBindMode, normalizeFixedPoint, normalizeLinePoints, repositionElementsToCursor, svgColorInfoToColorMap, updateOrAddSVGColorInfo, verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils";
import { getLastActiveExcalidrawView } from "src/utils/excalidrawViewLookup";
import { exportToPDF, getMarginValue, getPageDimensions } from "src/utils/exportUtils";
import { PageDimensions, PageOrientation, PageSize, PDFExportScale, PDFPageProperties, ExportSettings} from "src/types/exportUtilTypes";
@@ -715,6 +715,7 @@ export class ExcalidrawAutomate {
if(!text) return;
if (!this.targetView || !this.targetView?._loaded) return;
if (!this.targetView.excalidrawData) return;
if (isImageOrPDFTransclusion(this, text)) return text;
return await this.targetView.excalidrawData.parseText(text);
}
+44
View File
@@ -14,6 +14,7 @@ import type ExcalidrawView from "src/view/ExcalidrawView";
import {
GITHUB_RELEASES,
getCommonBoundingBox,
IMAGE_TYPES,
restoreElements,
REG_LINKINDEX_INVALIDCHARS,
THEME_FILTER,
@@ -153,6 +154,49 @@ export function errorMessage(message: string, source: string):void {
}
}
export function isImageOrPDFTransclusion(
ea: ExcalidrawAutomate,
text: string,
): boolean {
const trimmed = text?.trim();
if (!trimmed?.startsWith("![[") || !trimmed.endsWith("]]")) {
return false;
}
const content = trimmed.slice(3, -2).trim();
if (!content) {
return false;
}
const path = content.split("|")[0]?.trim();
if (!path) {
return false;
}
if (/^[^#]*#page=\d*(&\w*=[^&]+){0,}&rect=\d*,\d*,\d*,\d*/.test(path)) {
return true;
}
const [linkPath, subpath] = path.split("#");
const extension = linkPath.substring(linkPath.lastIndexOf(".") + 1).toLowerCase();
if (IMAGE_TYPES.includes(extension) || extension === "pdf") {
return true;
}
const sourcePath = ea.targetView?.file?.path;
const file = sourcePath
? ea.plugin.app.metadataCache.getFirstLinkpathDest(linkPath, sourcePath)
: null;
if (!file) {
return false;
}
return IMAGE_TYPES.includes(file.extension.toLowerCase())
|| file.extension.toLowerCase() === "pdf"
|| (ea.isExcalidrawFile(file) && !!subpath);
}
export function isColorStringTransparent(color: string): boolean {
const rgbaHslaTransparentRegex = /^(rgba|hsla)\(.*?,.*?,.*?,\s*0(\.0+)?\)$/i;
const hexTransparentRegex = /^#[a-fA-F0-9]{6}00$/i;
+39 -2
View File
@@ -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> {
+8 -27
View File
@@ -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";
+12 -1
View File
@@ -6263,8 +6263,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 +6399,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
+34 -9
View File
@@ -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>
)
+1 -1
View File
@@ -23,7 +23,7 @@ export function setPen (pen: PenStyle, api: any) {
...pen.backgroundColor ? {currentItemBackgroundColor: pen.backgroundColor} : null,
...pen.strokeColor ? {currentItemStrokeColor: pen.strokeColor} : null,
...pen.fillStyle === "" ? null : {currentItemFillStyle: pen.fillStyle},
...pen.roughness ? null : {currentItemRoughness: pen.roughness},
...(pen.roughness !== null) ? {currentItemRoughness: pen.roughness} : null,
...pen.freedrawOnly && !st.resetCustomPen //switching from custom pen to next custom pen
? {
resetCustomPen: {
+43 -5
View File
@@ -938,16 +938,19 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
box-shadow: 0 1px 4px 0 rgba(0,0,0,0.10);
padding: 0.5em 0.8em;
margin-bottom: 2em;
min-width: 18rem;
width: fit-content;
max-width: calc(100% - 1.6em);
position: sticky;
top: 1rem;
margin-right: 1rem;
margin-left: 1rem;
margin-right: auto;
margin-left: auto;
}
.excalidraw-search .document-search {
align-items: center;
max-width: none;
align-self: center;
max-width: 30rem;
width: min(100%, 30rem);
}
.excalidraw-search .search-input-container.document-search-input {
@@ -1046,6 +1049,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 +1181,24 @@ 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
*/