Compare commits

...
Author SHA1 Message Date
zsviczian cc18cf9166 2.19.0-beta-2: see sidepanels branch for the actual implementation 2025-12-27 22:19:00 +01:00
zsviczian 5236a73a1e 2.19.0-beta-1 2025-12-27 00:04:45 +01:00
zsviczian faa900a352 ownerWindow? 2025-12-26 10:33:52 +01:00
zsviczian 2ceebab04f refactor UI Modal 2025-12-26 10:15:47 +01:00
zsviczian 497125d7cc lint 2025-12-26 08:13:45 +01:00
zsviczian 4e8baed49f remove end of line spaces 2025-12-26 07:55:40 +01:00
zsviczian 3f93be3b45 typo, unused const 2025-12-26 07:47:34 +01:00
zsviczian bb17694219 refactor, bug fixes 2025-12-26 07:22:34 +01:00
zsviczian 12bc2a1680 added box/unbox to toolbar 2025-12-25 19:01:03 +01:00
zsviczian a1561de832 ea.setView improvements 2025-12-24 09:23:46 +01:00
zsviczian 1900cfcf84 modified training files 2025-12-23 14:51:41 +01:00
zsviczian aa47d1375b updated mindmap builder 2025-12-23 14:46:50 +01:00
zsviczian 61ae34968a added ALT+C,X,V to cut,copy,paste 2025-12-23 14:46:11 +01:00
zsviczian 296ac84f08 2.18.3, 0.18.0-63 2025-12-23 12:36:40 +01:00
zsviczian bcd63ad7fe fix isSolidArrow overwritten in centerText, and fix grouping of non-autolayed out element 2025-12-22 22:15:32 +01:00
zsviczian 1fec09c367 smaller minimized view 2025-12-22 17:48:27 +01:00
zsviczian 4cd5dde3d6 option to center text, added force rearrange button 2025-12-22 15:29:02 +01:00
zsviczian 36ee7f6e52 canvas pointer listener 2025-12-22 14:46:39 +01:00
zsviczian 32f76d4ea4 add branch pinning, added connector arrow handling 2025-12-22 12:39:24 +01:00
zsviczian 53aed86777 publishing linear calendar generator 2025-12-22 07:48:44 +01:00
zsviczian 573587bd88 publish linear calenar 2025-12-22 07:40:06 +01:00
zsviczian 558d0105a5 Merge pull request #2584 from superle3/fix/latex_suite_display_math
fix: use displaymath in latex mock parser
2025-12-22 07:06:59 +01:00
superle3 76910a3352 fix: use displaymath in latex mock parser
For latex suite, the mocked opening math node should be math-begin-math-block to indicate that its displaymath and newlines can be entered and thus snippets with newlines are used instead of those without.
2025-12-22 00:04:08 +01:00
zsviczian e2c9e2b256 removed - node.width/2 from 2025-12-21 22:43:53 +01:00
25 changed files with 4672 additions and 719 deletions

No files matched your search

+1
View File
@@ -14,6 +14,7 @@ data.json
lib
dist
tmp
deploy.ps1
#VSCode
.vscode
@@ -341,6 +341,24 @@ export declare class ExcalidrawAutomate {
* @returns {Mutable<ExcalidrawElement>} The element with the specified ID.
*/
getElement(id: string): Mutable<ExcalidrawElement>;
/**
* Returns an object describing the bound text element.
* If a text element is provided:
* - returns { eaElement } if the element is in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If a container element is provided, searches for the bound text element:
* - returns { eaElement } if found in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If not found, returns {}.
* Does not add the text element to elementsDict.
* @param element
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
* @returns Object containing either eaElement or sceneElement or empty if not found.
*/
getBoundTextElement(element: ExcalidrawElement, searchInView?: boolean): {
eaElement?: Mutable<ExcalidrawTextElement>;
sceneElement?: ExcalidrawTextElement;
};
/**
* Creates a drawing and saves it to the specified filename.
* @param {Object} [params] - Parameters for creating the drawing.
@@ -659,6 +677,17 @@ export declare class ExcalidrawAutomate {
* @param {"arrow"|"bar"|"circle"|"circle_outline"|"triangle"|"triangle_outline"|"diamond"|"diamond_outline"|null} [formatting.endArrowHead] - The end arrowhead type.
* @param {string} [formatting.startObjectId] - The ID of the start object.
* @param {string} [formatting.endObjectId] - The ID of the end object.
* BindMode Determines whether the arrow remains outside the shape or is allowed to
* go all the way inside the shape up to the exact fixed point.
* @param {"inside" | "orbit"} [formatting.startBindMode] - The binding mode for the start object.
* @param {"inside" | "orbit"} [formatting.endBindMode] - The binding mode for the end object.
* FixedPoint represents the fixed point binding information in form of a vertical and
* horizontal ratio (i.e. a percentage value in the 0.0-1.0 range). This ratio
* gives the user selected fixed point by multiplying the bound element width
* with fixedPoint[0] and the bound element height with fixedPoint[1] to get the
* bound element-local point coordinate.
* @param {[number, number]} [formatting.startFixedPoint] - The fixed point for the start object.
* @param {[number, number]} [formatting.endFixedPoint] - The fixed point for the end object.
* @param {string} [id] - The ID of the arrow element.
* @returns {string} The ID of the added arrow element.
*/
@@ -667,6 +696,11 @@ export declare class ExcalidrawAutomate {
endArrowHead?: "arrow" | "bar" | "circle" | "circle_outline" | "triangle" | "triangle_outline" | "diamond" | "diamond_outline" | null;
startObjectId?: string;
endObjectId?: string;
startBindMode?: "inside" | "orbit";
endBindMode?: "inside" | "orbit";
startFixedPoint?: [number, number];
endFixedPoint?: [number, number];
elbowed?: boolean;
}, id?: string): string;
/**
* Adds a mermaid diagram to ExcalidrawAutomate elements.
@@ -1225,6 +1259,9 @@ export declare class ExcalidrawAutomate {
* @returns {Promise<void>} Promise resolving when the settings are saved.
*/
setScriptSettings(settings: any): Promise<void>;
setScriptSettingValue(key: string, value: ScriptSettingValue): void;
getScriptSettingValue(key: string, defaultValue: ScriptSettingValue): ScriptSettingValue;
saveScriptSettings(): Promise<void>;
/**
* Opens a file in a new workspace leaf or reuses an existing adjacent leaf depending on Excalidraw Plugin Settings.
* @param {TFile} file - The file to open.
@@ -1360,6 +1397,13 @@ export type SVGColorInfo = Map<string, {
fill: boolean;
stroke: boolean;
}>;
export type ScriptSettingValue = {
value?: string | number | boolean;
hidden?: boolean;
description?: string;
valueset?: string[];
height?: number;
};
export type ImageInfo = {
mimeType: MimeType;
id: FileId;
@@ -2651,6 +2695,7 @@ export interface ExcalidrawImperativeAPI {
isTrayModeEnabled: InstanceType<typeof App>["isTrayModeEnabled"];
getColorAtScenePoint: InstanceType<typeof App>["getColorAtScenePoint"];
startLineEditor: InstanceType<typeof App>["startLineEditor"];
refreshAllArrows: InstanceType<typeof App>["refreshAllArrows"];
getSceneElements: InstanceType<typeof App>["getSceneElements"];
getAppState: () => InstanceType<typeof App>["state"];
getFiles: () => InstanceType<typeof App>["files"];
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+209
View File
@@ -0,0 +1,209 @@
/*
This script generates a linear (horizontal) calendar for a specified year, with days flowing left to right and months as rows.
![300](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-Linear-Calendar-Generator.jpg)
## Features
- Horizontal timeline layout with days of the week as columns
- Month names displayed on both left and right sides
- Weekend days (Saturday & Sunday) highlighted
- Day-of-week headers at top and bottom
## Customizable Colors
You can personalize the calendar's appearance by defining your own colors:
1. Create two rectangles in your design.
2. Select both rectangles before running the script:
• The **fill and stroke colors of the first rectangle** will be applied to weekdays.
• The **fill and stroke colors of the second rectangle** will be used for weekends.
If no rectangles are selected, the default color schema will be used (white and light blue-gray for weekends).
```javascript
*/
// -------------------------------------
// Constants initiation
// -------------------------------------
const CELL_WIDTH = 176; // Width of each day cell
const CELL_HEIGHT = 288; // Height of each day cell
const START_X = 0; // X start position
const START_Y = 0; // Y start position
const ROW_SPACING = 32; // Space between month rows
const MONTH_LABEL_WIDTH = 240; // Space for month labels on sides
// Colors
let COLOR_WEEKEND = "#e8eaed";
let COLOR_WEEKDAY = "#ffffff";
let COLOR_TEXT = "#000000";
let COLOR_WEEKEND_TEXT = "#000000";
let COLOR_HEADER_TEXT = "#000000";
const COLOR_STROKE = "#d0d4db";
let STROKE_WIDTH = 1;
let FILLSTYLE = "solid";
const ROUGHNESS = 0; // 0 = Architect, 1 = Artist, 2 = Cartoonist
const FONT_FAMILY = 3; // 1 = Virgil, 2 = Helvetica, 3 = Cascadia (code), 4 = Little One
// Font sizes
const FONT_SIZE_DAY = 56;
const FONT_SIZE_HEADER = 48;
const FONT_SIZE_MONTH = 64;
const FONT_SIZE_YEAR = 112;
// Day constants
const SATURDAY = 6;
const SUNDAY = 0;
const JANUARY = 0;
const FIRST_DAY_OF_THE_MONTH = 1;
// Day names (short)
const DAY_NAMES = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
// Month names (short)
const MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
// Number of day columns needed (max 37 to cover all possible month alignments: 6 days offset + 31 days)
const NUM_COLUMNS = 37;
// -------------------------------------
// Ask for requested Year
let requestedYear = parseFloat(new Date().getFullYear());
requestedYear = parseFloat(await utils.inputPrompt("Year?", requestedYear, requestedYear));
if (isNaN(requestedYear)) {
new Notice("Invalid number");
return;
}
// -------------------------------------
// Use selected elements for calendar style
// -------------------------------------
let elements = ea.getViewSelectedElements();
if (elements.length >= 1) {
COLOR_WEEKDAY = elements[0].backgroundColor;
FILLSTYLE = elements[0].fillStyle;
STROKE_WIDTH = elements[0].strokeWidth;
}
if (elements.length >= 2) {
COLOR_WEEKEND = elements[1].backgroundColor;
}
// -------------------------------------
// Helper function to get days in a month
// -------------------------------------
function getDaysInMonth(year, month) {
return new Date(year, month + 1, 0).getDate();
}
// -------------------------------------
// Helper function to get the day of week for first day of month
// -------------------------------------
function getFirstDayOfMonth(year, month) {
return new Date(year, month, 1).getDay();
}
// -------------------------------------
// Draw day-of-week headers
// -------------------------------------
function drawDayHeaders(yPosition) {
ea.style.fontSize = FONT_SIZE_HEADER;
ea.style.strokeColor = COLOR_TEXT;
ea.style.fontFamily = FONT_FAMILY;
for (let col = 0; col < NUM_COLUMNS; col++) {
const dayIndex = col % 7;
const x = START_X + MONTH_LABEL_WIDTH + (col * CELL_WIDTH);
// Center the text in the cell (approximate width of 2 chars)
const textX = x + (CELL_WIDTH / 2) - (FONT_SIZE_HEADER * 0.6);
ea.addText(textX, yPosition, DAY_NAMES[dayIndex]);
}
}
// -------------------------------------
// Draw month row
// -------------------------------------
function drawMonthRow(year, month, rowIndex) {
const daysInMonth = getDaysInMonth(year, month);
const firstDayOfWeek = getFirstDayOfMonth(year, month);
const y = START_Y + 160 + (rowIndex * (CELL_HEIGHT + ROW_SPACING));
// Draw month label on the left
ea.style.fontSize = FONT_SIZE_MONTH;
ea.style.strokeColor = COLOR_TEXT;
ea.style.fontFamily = FONT_FAMILY;
const monthLabelY = y + (CELL_HEIGHT / 2) - (FONT_SIZE_MONTH / 2);
ea.addText(START_X, monthLabelY, MONTH_NAMES[month]);
// Draw day cells
for (let day = 1; day <= daysInMonth; day++) {
const date = new Date(year, month, day);
const dayOfWeek = date.getDay();
const col = firstDayOfWeek + day - 1; // Column position based on day of week alignment
const x = START_X + MONTH_LABEL_WIDTH + (col * CELL_WIDTH);
const isWeekend = dayOfWeek === SATURDAY || dayOfWeek === SUNDAY;
// Set cell style
ea.style.backgroundColor = isWeekend ? COLOR_WEEKEND : COLOR_WEEKDAY;
ea.style.strokeColor = COLOR_STROKE;
ea.style.strokeWidth = STROKE_WIDTH;
ea.style.fillStyle = FILLSTYLE;
ea.style.roughness = ROUGHNESS;
// Draw cell rectangle
ea.addRect(x, y, CELL_WIDTH, CELL_HEIGHT);
// Draw day number
ea.style.fontSize = FONT_SIZE_DAY;
ea.style.strokeColor = COLOR_TEXT;
ea.style.fontFamily = FONT_FAMILY;
// Position the day number at top center of the cell
const dayStr = String(day).padStart(2, "0");
const charWidth = FONT_SIZE_DAY * 0.6; // Approximate character width
const textWidth = dayStr.length * charWidth;
const textX = x + (CELL_WIDTH - textWidth) / 2;
const textY = y + 32; // 32px padding from top
ea.addText(textX, textY, dayStr);
}
// Draw month label on the right
ea.style.fontSize = FONT_SIZE_MONTH;
ea.style.strokeColor = COLOR_TEXT;
const rightLabelX = START_X + MONTH_LABEL_WIDTH + (NUM_COLUMNS * CELL_WIDTH) + 60;
ea.addText(rightLabelX, monthLabelY, MONTH_NAMES[month]);
}
// -------------------------------------
// Main calendar generation
// -------------------------------------
// Draw year title (centered above calendar)
ea.style.fontSize = FONT_SIZE_YEAR;
ea.style.strokeColor = COLOR_TEXT;
ea.style.fontFamily = FONT_FAMILY;
const yearX = START_X + MONTH_LABEL_WIDTH + ((NUM_COLUMNS * CELL_WIDTH) / 2) - 120;
ea.addText(yearX, START_Y - 200, String(requestedYear));
// Draw top day-of-week headers
drawDayHeaders(START_Y);
// Draw all 12 months
for (let month = 0; month < 12; month++) {
drawMonthRow(requestedYear, month, month);
}
// Draw bottom day-of-week headers
const bottomHeaderY = START_Y + 160 + (12 * (CELL_HEIGHT + ROW_SPACING)) + 40;
drawDayHeaders(bottomHeaderY);
await ea.addElementsToView(false, false, true);
+24
View File
@@ -0,0 +1,24 @@
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50.097575068473816 56.100231877975375" width="50.097575068473816" height="56.100231877975375" class="excalidraw-svg">
<!-- Linear calendar icon (same size/viewBox as original) -->
<g stroke="#1e1e1e" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" fill="none">
<!-- Binding rings -->
<path d="M16 3 L16 12" />
<path d="M34.5 3 L34.5 12" />
<!-- Outer calendar body -->
<rect x="4" y="9" width="42.097575068473816" height="44.100231877975375" rx="5" ry="5" />
<!-- Header separator -->
<path d="M4 19 L46.097575068473816 19" />
<!-- A single highlighted date block -->
<rect x="10" y="23" width="8" height="8" rx="1.5" ry="1.5" />
<!-- Linear agenda lines -->
<path d="M22 27 L42 27" />
<path d="M10 35 L42 35" />
<path d="M10 43 L42 43" />
<path d="M10 51 L30 51" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 929 B

File diff suppressed because it is too large. Load diff
+3 -57
View File
@@ -23,6 +23,8 @@ const HELP_TEXT = `
- Additionally if the same color is used as fill and stroke the color can only be mapped once
- This is an experimental script - contributions welcome on GitHub via PRs
😍 If you find this script helpful, please [buy me a coffee ☕](https://ko-fi.com/zsolt).
<a href="https://www.youtube.com/watch?v=ISuORbVKyhQ" target="_blank"><img src ="https://i.ytimg.com/vi/ISuORbVKyhQ/maxresdefault.jpg" style="max-width:560px; width:100%"></a>
`;
@@ -324,7 +326,7 @@ function slider(contentEl, action, min, max, step, invert) {
function showModal() {
let debounceColorPicker = true;
const modal = new ea.obsidian.Modal(app);
const modal = new ea.FloatingModal(app);
let dirty = false;
modal.onOpen = async () => {
@@ -562,8 +564,6 @@ function showModal() {
.setButtonText("Close")
.setCta(true)
.onClick(() => modal.close()));
makeModalDraggable(modalEl);
const maxHeight = Math.round(height * 0.6);
const maxWidth = Math.round(width * 0.9);
@@ -584,60 +584,6 @@ function showModal() {
modal.open();
}
/**
* Add draggable functionality to the modal element.
* @param {HTMLElement} modalEl - The modal element to make draggable.
*/
function makeModalDraggable(modalEl) {
let isDragging = false;
let startX, startY, initialX, initialY;
const header = modalEl.querySelector('.modal-titlebar') || modalEl; // Default to modalEl if no titlebar
header.style.cursor = 'move';
const onPointerDown = (e) => {
// Ensure the event target isn't an interactive element like slider, button, or input
if (e.target.tagName === 'INPUT' || e.target.tagName === 'BUTTON') return;
isDragging = true;
startX = e.clientX;
startY = e.clientY;
const rect = modalEl.getBoundingClientRect();
initialX = rect.left;
initialY = rect.top;
modalEl.style.position = 'absolute';
modalEl.style.margin = '0';
modalEl.style.left = `${initialX}px`;
modalEl.style.top = `${initialY}px`;
};
const onPointerMove = (e) => {
if (!isDragging) return;
const dx = e.clientX - startX;
const dy = e.clientY - startY;
modalEl.style.left = `${initialX + dx}px`;
modalEl.style.top = `${initialY + dy}px`;
};
const onPointerUp = () => {
isDragging = false;
};
header.addEventListener('pointerdown', onPointerDown);
document.addEventListener('pointermove', onPointerMove);
document.addEventListener('pointerup', onPointerUp);
// Clean up event listeners on modal close
modalEl.addEventListener('remove', () => {
header.removeEventListener('pointerdown', onPointerDown);
document.removeEventListener('pointermove', onPointerMove);
document.removeEventListener('pointerup', onPointerUp);
});
}
function executeChange(isDecrease, step, action) {
const modifyStroke = settings[STROKE].value;
const modifyBackground = settings[BACKGROUND].value;
+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":1747585400113},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1748189277Line truncated
[{"fname":"Mindmap connector.md","mtime":1658686599427},{"fname":"Mindmap connector.svg","mtime":1658686599427},{"fname":"Add Connector Point.md","mtime":1735420748564},{"fname":"Add Connector Point.svg","mtime":1645944722000},{"fname":"Add Link to Existing File and Open.md","mtime":1647807918345},{"fname":"Add Link to Existing File and Open.svg","mtime":1645964261000},{"fname":"Add Link to New Page and Open.md","mtime":1654168862138},{"fname":"Add Link to New Page and Open.svg","mtime":1645960639000},{"fname":"Add Next Step in Process.md","mtime":1688304760357},{"fname":"Add Next Step in Process.svg","mtime":1645960639000},{"fname":"Box Each Selected Groups.md","mtime":1645305706000},{"fname":"Box Each Selected Groups.svg","mtime":1645967510000},{"fname":"Box Selected Elements.md","mtime":1645305706000},{"fname":"Box Selected Elements.svg","mtime":1645960639000},{"fname":"Change shape of selected elements.md","mtime":1652701169236},{"fname":"Change shape of selected elements.svg","mtime":1645960775000},{"fname":"Connect elements.md","mtime":1645305706000},{"fname":"Connect elements.svg","mtime":1645960639000},{"fname":"Convert freedraw to line.md","mtime":1645305706000},{"fname":"Convert freedraw to line.svg","mtime":1645960639000},{"fname":"Convert selected text elements to sticky notes.md","mtime":1670169501383},{"fname":"Convert selected text elements to sticky notes.svg","mtime":1645960639000},{"fname":"Convert text to link with folder and alias.md","mtime":1641639819000},{"fname":"Convert text to link with folder and alias.svg","mtime":1645960639000},{"fname":"Copy Selected Element Styles to Global.md","mtime":1642232088000},{"fname":"Copy Selected Element Styles to Global.svg","mtime":1645960639000},{"fname":"Create new markdown file and embed into active drawing.md","mtime":1640866935000},{"fname":"Create new markdown file and embed into active drawing.svg","mtime":1645960639000},{"fname":"Darken background color.md","mtime":1663059051059},{"fname":"Darken background color.svg","mtime":1645960639000},{"fname":"Elbow connectors.md","mtime":1671126911490},{"fname":"Elbow connectors.svg","mtime":1645960639000},{"fname":"Expand rectangles horizontally keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles horizontally keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles horizontally.md","mtime":1644950235000},{"fname":"Expand rectangles horizontally.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically keep text centered.md","mtime":1646563692000},{"fname":"Expand rectangles vertically keep text centered.svg","mtime":1645967510000},{"fname":"Expand rectangles vertically.md","mtime":1658686599427},{"fname":"Expand rectangles vertically.svg","mtime":1645967510000},{"fname":"Fixed horizontal distance between centers.md","mtime":1646743234000},{"fname":"Fixed horizontal distance between centers.svg","mtime":1645960639000},{"fname":"Fixed inner distance.md","mtime":1646743234000},{"fname":"Fixed inner distance.svg","mtime":1645960639000},{"fname":"Fixed spacing.md","mtime":1646743234000},{"fname":"Fixed spacing.svg","mtime":1645967510000},{"fname":"Fixed vertical distance between centers.md","mtime":1646743234000},{"fname":"Fixed vertical distance between centers.svg","mtime":1645967510000},{"fname":"Fixed vertical distance.md","mtime":1646743234000},{"fname":"Fixed vertical distance.svg","mtime":1645967510000},{"fname":"Lighten background color.md","mtime":1663059051059},{"fname":"Lighten background color.svg","mtime":1645959546000},{"fname":"Modify background color opacity.md","mtime":1644924415000},{"fname":"Modify background color opacity.svg","mtime":1645944722000},{"fname":"Normalize Selected Arrows.md","mtime":1670403743278},{"fname":"Normalize Selected Arrows.svg","mtime":1645960639000},{"fname":"Organic Line.md","mtime":1672920172531},{"fname":"Organic Line.svg","mtime":1645964261000},{"fname":"Organic Line Legacy.md","mtime":1690607372668},{"fname":"Organic Line Legacy.svg","mtime":1690607372668},{"fname":"README.md","mtime":1645175700000},{"fname":"Repeat Elements.md","mtime":1663059051059},{"fname":"Repeat Elements.svg","mtime":1645960639000},{"fname":"Reverse arrows.md","mtime":1645305706000},{"fname":"Reverse arrows.svg","mtime":1645960639000},{"fname":"Scribble Helper.md","mtime":1747585400113},{"fname":"Scribble Helper.svg","mtime":1645944722000},{"fname":"Select Elements of Type.md","mtime":1643464321000},{"fname":"Select Elements of Type.svg","mtime":1645960639000},{"fname":"Set Dimensions.md","mtime":1645305706000},{"fname":"Set Dimensions.svg","mtime":1645944722000},{"fname":"Set Font Family.md","mtime":1645305706000},{"fname":"Set Font Family.svg","mtime":1645944722000},{"fname":"Set Grid.md","mtime":1693725826368},{"fname":"Set Grid.svg","mtime":1645960639000},{"fname":"Set Link Alias.md","mtime":1645305706000},{"fname":"Set Link Alias.svg","mtime":1645960639000},{"fname":"Set Stroke Width of Selected Elements.md","mtime":1748189277Line truncated
+9 -2
View File
@@ -55,7 +55,7 @@ These are the scripts I use most often. I tried to order them by importance, but
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Excalidraw%20Writing%20Machine.svg"/></div>|[[#Excalidraw Writing Machine]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20freedraw%20to%20line.svg"/></div>|[[#Convert freedraw to line]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Crop%20Vintage%20Mask.svg"/></div>|[[#Crop Vintage Mask]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-mindmap-builder.png"/></div>|[[#Mindmap Builder]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20Builder.svg"/></div>|[[#Mindmap Builder]]|
## Layout and Organization
**Keywords**: Design, Placement, Arrangement, Structure, Formatting, Alignment
@@ -183,6 +183,7 @@ These are the scripts I use most often. I tried to order them by importance, but
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Convert%20freedraw%20to%20line.svg"/></div>|[[#Convert freedraw to line]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Deconstruct%20selected%20elements%20into%20new%20drawing.svg"/></div>|[[#Deconstruct selected elements into new drawing]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Full-Year%20Calendar%20Generator.svg"/></div>|[[#Full-Year Calendar Generator]]|
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Linear%20Calendar%20Generator.svg"/></div>|[[#Linear Calendar Generator]]|
## Masking and cropping
**Keywords**: Crop, Mask, Transform images
@@ -459,11 +460,17 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
```
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/1-2-3'>@1-2-3</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Lighten%20background%20color.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">This script lightens the background color of the selected element by 2% at a time. You can use this script several times until you are satisfied. It is recommended to set a shortcut key for this script so that you can quickly try to DARKEN and LIGHTEN the color effect.In contrast to the `Modify background color opacity` script, the advantage is that the background color of the element is not affected by the canvas color, and the color value does not appear in a strange rgba() form.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/darken-lighten-background-color.png'></td></tr></table>
## Linear Calendar Generator
```excalidraw-script-install
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Linear%20Calendar%20Generator.md
```
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/iwanhoogendoorn'>@iwanhoogendoorn</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Linear%20Calendar%20Generator.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Generates a complete calendar for a specified year.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-Linear-Calendar-Generator.jpg'></td></tr></table>
## Mindmap Builder
```excalidraw-script-install
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Mindmap%20Builder.md
```
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Mindmap%20Builder.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Rapid mind mapping workflow driven by keyboard shortcuts: add sibling/child nodes, auto-layout and branch styling, quick navigation, optional recursive grouping, and Markdown copy/paste import/export for bullet-list sync.<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-mindmap-builder.png'></td></tr></table>
<table><tr valign='top'><td class="label">Author</td><td class="data"><a href='https://github.com/zsviczian'>@zsviczian</a></td></tr><tr valign='top'><td class="label">Source</td><td class="data"><a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/blob/master/ea-scripts/Mindmap%20Builder.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Rapid mind mapping workflow driven by keyboard shortcuts: add sibling/child nodes, auto-layout and branch styling, quick navigation, optional recursive grouping, and Markdown copy/paste import/export for bullet-list sync.<br><a href="https://www.youtube.com/watch?v=dZguonMP2KU" target="_blank"><img src ="https://i.ytimg.com/vi/dZguonMP2KU/maxresdefault.jpg" style="width:400px;"></a><br><a href='https://youtu.be/dZguonMP2KU' target='_blank'>Link to video on YouTube</a><br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-mindmap-builder.png'></td></tr></table>
## Mindmap connector
```excalidraw-script-install
Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.18.3-beta-1",
"version": "2.19.0-beta-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",
+1 -1
View File
@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.18.2",
"version": "2.18.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",
+1
View File
@@ -118,6 +118,7 @@ export default class ExcalidrawPlugin extends Plugin {
public settings: ExcalidrawSettings;
public activeExcalidrawView: ExcalidrawView = null;
public lastActiveExcalidrawFilePath: string = null;
public lastActiveExcalidrawLeafID: string = null;
public hover: { linkText: string; sourcePath: string } = {
linkText: null,
sourcePath: null,
+9
View File
@@ -193,6 +193,15 @@ export class EventManager {
this.plugin.lastPDFLeafID = leaf.id;
}
if (leaf.view && leaf.view.getViewType() === VIEW_TYPE_EXCALIDRAW) {
this.plugin.lastActiveExcalidrawLeafID = leaf.id;
} else {
const lastLeaf = this.app.workspace.getLeafById(this.plugin.lastActiveExcalidrawLeafID);
if(!lastLeaf || !(lastLeaf.view instanceof ExcalidrawView)) {
this.plugin.lastActiveExcalidrawLeafID = null;
}
}
if(this.leafChangeTimeout) {
window.clearTimeout(this.leafChangeTimeout);
}
+64
View File
@@ -1,5 +1,68 @@
import { App, Modal } from "obsidian";
function getClientPoint(e: PointerEvent | TouchEvent) {
if (e.type.startsWith("touch")) {
const t = (e as TouchEvent).touches[0] ?? (e as TouchEvent).changedTouches[0];
return t ? { x: t.clientX, y: t.clientY } : null;
}
const p = e as PointerEvent;
return { x: p.clientX, y: p.clientY };
}
function pointInRect(pt: { x: number; y: number }, r: DOMRect, padding = 1): boolean {
return (
pt.x >= r.left - padding &&
pt.x <= r.right + padding &&
pt.y >= r.top - padding &&
pt.y <= r.bottom + padding
);
}
function isPointOnText(e: PointerEvent | TouchEvent): boolean {
const pt = getClientPoint(e);
if (!pt) return false;
let offsetNode: Node | null = null;
let offset: number | null = null;
// Chromium/Firefox-ish
const caretPos = (document as any).caretPositionFromPoint?.(pt.x, pt.y);
if (caretPos?.offsetNode) {
offsetNode = caretPos.offsetNode;
offset = typeof caretPos.offset === "number" ? caretPos.offset : null;
} else {
// Safari/WebKit
const caretRange = (document as any).caretRangeFromPoint?.(pt.x, pt.y);
if (caretRange?.startContainer) {
offsetNode = caretRange.startContainer;
offset = typeof caretRange.startOffset === "number" ? caretRange.startOffset : null;
}
}
if (!offsetNode || offsetNode.nodeType !== Node.TEXT_NODE || offset == null) return false;
if (!offsetNode.textContent?.trim()) return false;
const textNode = offsetNode as Text;
const len = textNode.data.length;
const at = Math.max(0, Math.min(offset, len));
const range = document.createRange();
if (at < len) {
range.setStart(textNode, at);
range.setEnd(textNode, at + 1);
} else if (at > 0) {
range.setStart(textNode, at - 1);
range.setEnd(textNode, at);
} else {
return false;
}
const rects = Array.from(range.getClientRects());
if (rects.length === 0) return false;
return rects.some((r) => pointInRect(pt, r, 1));
}
export class FloatingModal extends Modal {
private dragging = false;
private offsetX = 0;
@@ -34,6 +97,7 @@ export class FloatingModal extends Modal {
target instanceof HTMLTextAreaElement ||
target instanceof HTMLSelectElement ||
target instanceof HTMLButtonElement ||
isPointOnText(e) ||
target.closest(".clickable-icon") ||
target.closest(".modal-close-button") // ensure close button never starts drag
) {
+44 -51
View File
@@ -17,13 +17,35 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
`,
"2.19.0":`
## New in ExcalidrawAutomate
- **setView() improvements**
- Calling \`setView()\` now picks a sensible target automatically:
- It prefers the **currently active Excalidraw view**.
- If no active Excalidraw view is found (e.g., the user is focused on a different tab like the File Explorer/sidebar), it will fall back to the **last active Excalidraw view (as long as it is still available)** — typically the drawing the user came from.
- **New selector**: \`"auto"\` (equivalent to calling \`setView()\`).
- Useful when you also want to reveal/focus the view: \`setView("auto", true)\`.
- **Deprecated selectors**: \`"active"\` and \`"first"\` are deprecated and kept only for backward compatibility.
- Recommended usage is either \`setView()\`, \`setView("auto")\`, or \`setView(excalidrawView)\` (explicitly target a specific view).
\`\`\`ts
setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false)
\`\`\`
`,
"2.18.3":`
<div class="excalidraw-videoWrapper">
<a href="https://www.youtube.com/watch?v=dZguonMP2KU" target="_blank"><img src ="https://i.ytimg.com/vi/dZguonMP2KU/maxresdefault.jpg" style="width:100%;"></a>
</div>
## New
- Added Mindmap Builder script to the script store.
- Added Mindmap Builder script to the store.
- LaTeX Suit Integration by [@TravisLEBLANC1](https://github.com/TravisLEBLANC1)
- Added Linear Calendar Generator script to the store. 🙏 [@iwanhoogendoorn](https://github.com/iwanhoogendoorn)
## Fixed
- YouTube video embeds working on iOS [#2569](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2569)
- Stroke color setting for Embeddedables (markdown notes, websites) is missing after 2.17.0 update [#2580](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2580)
- Context menu paste pastes in image twice [#10542](https://github.com/excalidraw/excalidraw/issues/10542)
## New in ExcalidrawAutomate
- Added 3 new helper functions for working with Script Engine settings (safe during initialization when \`scriptEngineSettings[activeScript]\` is \`undefined\` / \`null\`):
@@ -37,6 +59,27 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
- \`startFixedPoint?: [number, number]\`
- \`endFixedPoint?: [number, number]\`
- \`elbowed?: boolean\`
\`\`\`ts
/**
* Returns an object describing the bound text element.
* If a text element is provided:
* - returns { eaElement } if the element is in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If a container element is provided, searches for the bound text element:
* - returns { eaElement } if found in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If not found, returns {}.
* Does not add the text element to elementsDict.
* @param element
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
* @returns Object containing either eaElement or sceneElement or empty if not found.
*/
getBoundTextElement(element: ExcalidrawElement, searchInView: boolean = false): {
eaElement?: Mutable<ExcalidrawTextElement>,
sceneElement?: ExcalidrawTextElement
};
\`\`\`
`,
"2.18.2":`
## Fixed
@@ -244,54 +287,4 @@ public getViewCenterPosition(): {x:number, y:number};
):ExcalidrawElement[]
\`\`\`
`,
"2.14.3":`
<div class="excalidraw-videoWrapper">
<a href="https://www.youtube.com/watch?v=29EWeglRm7s" target="_blank"><img src ="https://i.ytimg.com/vi/29EWeglRm7s/maxresdefault.jpg" style="width:100%;"></a>
</div>
Updated the Printable Layout Wizard script with the option to exclude empty pages.
## Fixed
- If a frame is locked, elements created over the frame or dragged over the frame should not be auto-added to the frame. [#9850](https://github.com/excalidraw/excalidraw/issues/9850)
## Fixed in ExcalidrawAutomate
- Not all AppState properties were being correctly copied to the template when creating a new drawing with ea.create() [#2440](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2440)
`,
"2.14.2":`
## Fixed
- Converting Markdown to Excalidraw ("Back of note"/"Convert markdown to ExcaliDrawing") no longer appends T00:00:00.000Z to an existing date frontmatter field and handles merging of lists such as tags intelligently [#2414](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2414)
- Multi‑point line creation on touchscreens (tap–tap–tap) produced a horizontal line after using a pen. Fixed. [#9840](https://github.com/excalidraw/excalidraw/pull/9840#issuecomment-3165319266)
## New
- Zoom settings (Settings → Excalidraw → Appearance and Behavior → Zoom) [#2434](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2434):
- Zoom increment (default 5%) to fine‑tune mouse wheel / gesture precision.
- Minimum zoom (default 10%) controls how far you can zoom out (below 10% may be unstable—use with caution).
- Maximum zoom (default 3000%) defines the upper zoom limit.
- Palm Guard script (in script store): Mobile-friendly drawing mode for stylus users. Enters fullscreen, hides UI, shows a draggable minimal toolbar (toggle + exit) to prevent accidental palm taps; single tap to exit. Inspired by [#2409](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2409)
<div class="excalidraw-videoWrapper">
<a href="https://www.youtube.com/watch?v=A_udjVjgWN0" target="_blank"><img src ="https://i.ytimg.com/vi/A_udjVjgWN0/maxresdefault.jpg" style="width:100%;"></a>
</div>
## ExcalidrawAutomate
- Improved \`FloatingModal\` behavior. Floating Modal now does not trap keyboard events, the header element does not block "X" button in the top right corner, all four corners are rounded on Mobile Devices.
`,
"2.14.1":`
## Fixed
- Excalidraw broke Obsidian's UI in Arabic, Persian, and Hebrew due to LTR, RTL conflict. [#2423](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2423)
- Styling issues impacting native Obsidian search/replace dialogs. [#2420](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2420)
- Now using native Obsidian attachment location function. 🙏 [mnaoumov](https://github.com/mnaoumov) [#2421](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2421), potentially fixes [#179](https://github.com/RainCat1998/obsidian-custom-attachment-location/issues/179) of the Obsidian Custom Attachment Location plugin issue.
## New
- New frontmatter option \`excalidraw-embed-md\`. When set to \`true\`, embedding the drawing into a markdown note will render the "back of the note" (its markdown content) instead of rendering it as an image.
- If you want to always display the drawing as an image, even when \`excalidraw-embed-md\` is enabled, use the special embed syntax: \`![[drawing#^as-image]]\`. Here, \`as-image\` is a phantom block reference that forces image rendering.
- Added Spanish translation by [@Joakim31](https://github.com/Joakim31) [#2425](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2425)
- Incremental minor updates from the main [Excalidraw project](https://github.com/excalidraw/excalidraw).
`,
"2.14.0":`
## A Big "Small" Update
- Added search to Excalidraw Settings, plus added a link to access the public NotebookLM workbook pre-loaded with everything about the plugin
- New Taiwan-idiomatic Traditional Chinese translation by [@rlan](https://github.com/rlan) [#2413](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2413)
`,
};
+1 -5
View File
@@ -100,6 +100,7 @@ export class LaTexPrompt extends Modal {
) {
super(app);
this.titleEl.setText(this.prompt_text);
this.contentEl.addClass("excalidraw-LatexPrompt");
this.latexsSuitePlugin = app.plugins.plugins["obsidian-latex-suite"];
const mainContentContainer: HTMLDivElement = this.contentEl.createDiv();
this.display(default_value, mainContentContainer);
@@ -156,11 +157,6 @@ export class LaTexPrompt extends Modal {
});
}
const cmContent = this.editorView.dom.querySelector('.cm-content') as HTMLElement;
if (cmContent) {
cmContent.style.caretColor = 'var(--caret-color)';
}
const buttonBarContainer: HTMLDivElement = container.createDiv();
buttonBarContainer.addClass(`excalidraw-prompt-buttonbar-bottom`);
const actionButtonContainer: HTMLDivElement = buttonBarContainer.createDiv();
+28 -3
View File
@@ -202,6 +202,22 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
desc: "Get single element from ExcalidrawAutomate elementsDict",
after: "",
},
{
field: "getBoundTextElement",
code:
"getBoundTextElement(element: ExcalidrawElement, searchInView?: boolean): { eaElement?: Mutable<ExcalidrawTextElement>; sceneElement?: ExcalidrawTextElement; };",
desc:
"Returns an object describing the bound text element.\n" +
"If a text element is provided:\n" +
" - returns { eaElement } if the element is in ea.elementsDict\n" +
" - else (if searchInView is true) returns { sceneElement } if found in the targetView scene\n" +
"If a container element is provided, searches for the bound text element:\n" +
" - returns { eaElement } if found in ea.elementsDict\n" +
" - else (if searchInView is true) returns { sceneElement } if found in the targetView scene\n" +
"If not found, returns {}.\n" +
"Does not add the text element to elementsDict.",
after: "",
},
{
field: "create",
code: 'async create(params?: {filename?: string, foldername?: string, templatePath?: string, onNewPane?: boolean, silent?: boolean, frontmatterKeys?: {},}): Promise<string>;',
@@ -475,9 +491,18 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
},
{
field: "setView",
code: 'setView(view: ExcalidrawView | "first" | "active"): ExcalidrawView;',
desc: null,
after: "",
code: 'setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false): ExcalidrawView;',
desc: "Sets the target view for EA. All the view operations and the access to Excalidraw API will be performed on this view. " +
"Typically you will use setView() (to pick a sensible default) or setView(excalidrawView) (to explicitly target a specific view).\n" +
'"auto" is equivalent to calling setView() and can read nicer when you want to show the view (e.g. setView("auto", true)).\n' +
'"active" and "first" are deprecated and are kept for backward compatibility.\n' +
'If view is null or undefined (or "auto"), EA will pick a sensible default: first the currently active Excalidraw view (if any), otherwise the last active Excalidraw view (if it is still available), otherwise the "first" Excalidraw view in the workspace.\n' +
"If show is true, the view will be brought to front and focused.\n" +
'If "first" is provided, the target will be the first Excalidraw view returned by Obsidian\'s workspace leaf collection (i.e., the first item in getExcalidrawViews()). ' +
"This ordering is managed by Obsidian and does not necessarily match what a user would consider the “first” view; from a user's perspective it may appear random.\n" +
'If "active" is provided, the currently active Excalidraw view in the workspace will be used. If that is not available, then the last active Excalidraw view will be used.\n' +
"The function returns the ExcalidrawView that was set as targetView.",
after: '("auto",true);',
},
{
field: "getExcalidrawAPI",
+7 -5
View File
@@ -1,12 +1,14 @@
// This file was generated by lezer-generator. You probably shouldn't edit it.
/*
Obsidian uses a slightly modified version of the hypermd parser for math blocks
found at https://github.com/laobubu/HyperMD/blob/071ce236605bb7693efa6d4b829c39413a3d37fb/src/mode/hypermd.ts#L329-L336
where spaces are replaced with `_` and the mathlevel of 1|2 is replaced with `math-block` for display math and nothing for inline math
create from the following grammar (where we remove the upper-cases):
@top Document { Formatting_formatting-math_formatting-math-begin_keyword_math_math-block Math Formatting_formatting-math_formatting-math-end_keyword_math_math- }
@top Document { Math-begin Math Math-end }
Math-begin { "" }
Formatting_formatting-math_formatting-math-begin_keyword_math_math-block { "" }
Math { any* }
Math-end { "" }
Formatting_formatting-math_formatting-math-end_keyword_math_math- { "" }
@tokens {
any { _ }
@@ -18,7 +20,7 @@ export const parser = LRParser.deserialize({
states: "zOOOO?MrOOQOPOOOOOO'#Ca'#CaOYOPO'#C_OOOO?MtOOOOO-E6_-E6_QOOOOO",
stateData: "b~OVQOURP~OVQOURX~O",
goto: "fUPPVY]`RPORSPRUSQRPRTR",
nodeNames: "⚠ Document math-begin math math-end",
nodeNames: "⚠ Document formatting_formatting-math_formatting-math-begin_keyword_math_math-block math formatting_formatting-math_formatting-math-end_keyword_math_math-",
maxTerm: 7,
skippedNodes: [0],
repeatNodeCount: 1,
+111 -24
View File
@@ -81,7 +81,7 @@ import { log } from "../utils/debugHelper";
import { ExcalidrawLib } from "../types/excalidrawLib";
import { GlobalPoint } from "@zsviczian/excalidraw/types/math/src/types";
import { AddImageOptions, ImageInfo, ScriptSettingValue, SVGColorInfo } from "src/types/excalidrawAutomateTypes";
import { _measureText, cloneElement, createPNG, createSVG, ensureActiveScriptSettingsObject, errorMessage, filterColorMap, getEmbeddedFileForImageElment, getFontFamily, 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, getFontFamily, getLastActiveExcalidrawView, getLineBox, getTemplate, isColorStringTransparent, isSVGColorInfo, mergeColorMapIntoSVGColorInfo, normalizeBindMode, normalizeFixedPoint, normalizeLinePoints, repositionElementsToCursor, svgColorInfoToColorMap, updateOrAddSVGColorInfo, verifyMinimumPluginVersion } from "src/utils/excalidrawAutomateUtils";
import { exportToPDF, getMarginValue, getPageDimensions } from "src/utils/exportUtils";
import { PageDimensions, PageOrientation, PageSize, PDFExportScale, PDFPageProperties, ExportSettings} from "src/types/exportUtilTypes";
import { FrameRenderingOptions } from "src/types/utilTypes";
@@ -767,6 +767,56 @@ export class ExcalidrawAutomate {
return this.elementsDict[id];
};
/**
* Returns an object describing the bound text element.
* If a text element is provided:
* - returns { eaElement } if the element is in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If a container element is provided, searches for the bound text element:
* - returns { eaElement } if found in ea.elementsDict
* - else (if searchInView is true) returns { sceneElement } if found in the targetView scene
* If not found, returns {}.
* Does not add the text element to elementsDict.
* @param element
* @param searchInView - If true, searches in the targetView elements if not found in elementsDict.
* @returns Object containing either eaElement or sceneElement or empty if not found.
*/
getBoundTextElement(element: ExcalidrawElement, searchInView: boolean = false): {
eaElement?: Mutable<ExcalidrawTextElement>,
sceneElement?: ExcalidrawTextElement
} {
if(element.type === "text") {
if(element.id in this.elementsDict) {
return {eaElement: element as Mutable<ExcalidrawTextElement>};
}
if (searchInView && this.targetView && this.targetView._loaded) {
const viewElements = this.getViewElements();
const ve = viewElements.find((e) => e.id === element.id);
if(ve) {
return {
sceneElement: ve as ExcalidrawTextElement
};
}
}
return {};
}
const boundElement = element.boundElements?.find((be) => be.type === "text");
if (!boundElement) {
return {};
}
let textElement = this.elementsDict[boundElement.id] as Mutable<ExcalidrawTextElement>;
if (textElement) {
return {eaElement: textElement};
}
if (!textElement && searchInView && this.targetView && this.targetView._loaded) {
const viewElements = this.getViewElements();
const ve = viewElements.find((e) => e.id === boundElement.id);
return {sceneElement: ve as ExcalidrawTextElement};
}
return {};
}
/**
* Creates a drawing and saves it to the specified filename.
* @param {Object} [params] - Parameters for creating the drawing.
@@ -2281,35 +2331,72 @@ export class ExcalidrawAutomate {
isExcalidrawFile(f: TFile): boolean {
return this.plugin.isExcalidrawFile(f);
};
targetView: ExcalidrawView = null; //the view currently edited
/**
* Sets the target view for EA. All the view operations and the access to Excalidraw API will be performed on this view.
* If view is null or undefined, the function will first try setView("active"), then setView("first").
* @param {ExcalidrawView | "first" | "active"} [view] - The view to set as target.
* @returns {ExcalidrawView} The target view.
* Sets the target view for EA. All view operations and all access to the Excalidraw API
* will be performed on this view.
*
* Typical usage:
* - `setView()` to pick a sensible default automatically
* - `setView(excalidrawView)` to explicitly target a specific view
*
* Selectors:
* - If `view` is `null` or `undefined` (or `"auto"`), EA will pick a sensible default:
* 1) the currently active Excalidraw view (if any),
* 2) otherwise the last active Excalidraw view (if it is still available),
* 3) otherwise the `"first"` Excalidraw view in the workspace.
* - If `show` is `true`, the view will be revealed (brought to front) and focused.
*
* Deprecated selectors (kept for backward compatibility):
* - If `"active"` is provided, the currently active Excalidraw view will be used. If no
* active Excalidraw view is available, the last active Excalidraw view will be used.
* - If `"first"` is provided, the target will be the first Excalidraw view returned by
* Obsidian's workspace leaf collection (i.e., the first item in the current
* `getExcalidrawViews()` result). **This ordering is managed by Obsidian and does not
* necessarily match what a user would consider the “first”/“leftmost”/“topmost” view;
* from a user's perspective it may appear effectively random.**
*
* @param {ExcalidrawView | "auto" | "first" | "active" | null | undefined} [view] - The view (or selector) to set as target.
* @param {boolean} [show=false] - Whether to reveal/focus the target view.
* @returns {ExcalidrawView} The ExcalidrawView that was set as `targetView` (or `null` if none found).
*/
setView(view?: ExcalidrawView | "first" | "active"): ExcalidrawView {
if(!view) {
const v = this.plugin.app.workspace.getActiveViewOfType(ExcalidrawView);
if (v instanceof ExcalidrawView) {
this.targetView = v;
}
else {
this.targetView = getExcalidrawViews(this.plugin.app)[0];
}
}
if (view == "active") {
const v = this.plugin.app.workspace.getActiveViewOfType(ExcalidrawView);
if (!(v instanceof ExcalidrawView)) {
setView(view?: ExcalidrawView | "auto" | "first" | "active" | null, show: boolean = false): ExcalidrawView {
const app = this.plugin.app;
const workspace = app.workspace;
const setView = () => {
if(!view || view === "auto") {
view = workspace.getActiveViewOfType(ExcalidrawView);
if (view instanceof ExcalidrawView) {
this.targetView = view;
return;
}
view = getLastActiveExcalidrawView(this.plugin);
this.targetView = view ?? getExcalidrawViews(this.plugin.app)[0];
return;
}
this.targetView = v;
if (view == "active") {
view = workspace.getActiveViewOfType(ExcalidrawView);
if (view instanceof ExcalidrawView) {
this.targetView = view;
return;
}
this.targetView = getLastActiveExcalidrawView(this.plugin);
return;
}
if (view == "first") {
this.targetView = getExcalidrawViews(this.plugin.app)[0];
return;
}
if (view instanceof ExcalidrawView) {
this.targetView = view;
}
}
if (view == "first") {
this.targetView = getExcalidrawViews(this.plugin.app)[0];
}
if (view instanceof ExcalidrawView) {
this.targetView = view;
setView();
if(show && this.targetView) {
this.plugin.app.workspace.revealLeaf(
this.targetView.leaf,
);
}
return this.targetView;
};
+3 -4
View File
@@ -14,7 +14,7 @@ import { splitFolderAndFilename } from "../utils/fileUtils";
import { getEA } from "src/core";
import { ExcalidrawAutomate } from "../shared/ExcalidrawAutomate";
import { WeakArray } from "./WeakArray";
import { getExcalidrawViews } from "../utils/obsidianUtils";
import { getExcalidrawViews, stripYamlFrontmatter } from "../utils/obsidianUtils";
import { ButtonDefinition, InputPromptOptions } from "src/types/promptTypes";
export type ScriptIconMap = {
@@ -211,9 +211,8 @@ export class ScriptEngine {
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
if (view) {
(async()=>{
const script = await this.app.vault.read(f);
const script = stripYamlFrontmatter(await this.app.vault.read(f));
if(script) {
//remove YAML frontmatter if present
this.executeScript(view, script, scriptName,f);
}
})()
@@ -260,7 +259,7 @@ export class ScriptEngine {
await view.save(false, true);
}
script = script.replace(/^---.*?---\n/gs, "");
script = stripYamlFrontmatter(script);
const ea = getEA(view);
this.eaInstances.push(ea);
ea.activeScript = title;
+8
View File
@@ -929,3 +929,11 @@ export function ensureActiveScriptSettingsObject(
return plugin.settings.scriptEngineSettings[activeScript] as Record<string, ScriptSettingValue>;
}
export function getLastActiveExcalidrawView(plugin: ExcalidrawPlugin): ExcalidrawView | null {
const leaf = plugin.app.workspace.getLeafById(plugin.lastActiveExcalidrawLeafID);
if(leaf && leaf.view instanceof ExcalidrawView) {
return leaf.view as ExcalidrawView;
}
return null;
}
+5
View File
@@ -512,4 +512,9 @@ export function getAudioElementHeight(): number {
}
return Math.round(height);
}
export function stripYamlFrontmatter(text: string): string {
if (!text) return text;
return text.replace(/^---\s*\r?\n[\s\S]*?\r?\n---\s*\r?\n?/, "");
}
+8
View File
@@ -926,3 +926,11 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
.excalidraw .ToolIcon.ToolIcon__penMode {
height:fit-content
}
.excalidraw-LatexPrompt .cm-content {
caret-color: var(--caret-color);
}
.excalidraw-LatexPrompt .cm-editor {
margin-top: 90px;
}