mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
29
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37ceca8ccd | ||
|
|
1ca55ccfcb | ||
|
|
24566dfb8c | ||
|
|
dab8528fb6 | ||
|
|
f4c52ea675 | ||
|
|
10abb50a5c | ||
|
|
1427b0791a | ||
|
|
10fad8a29c | ||
|
|
429c9b0f55 | ||
|
|
38d524db75 | ||
|
|
f7ef047ebd | ||
|
|
e167dd21c3 | ||
|
|
8baa3aa0e4 | ||
|
|
615f66393e | ||
|
|
c621a96179 | ||
|
|
65b88ab67d | ||
|
|
691c2fdc3e | ||
|
|
79979d38e4 | ||
|
|
536479c3d9 | ||
|
|
1065551196 | ||
|
|
3105d5533c | ||
|
|
4cff3f013b | ||
|
|
4a3e527605 | ||
|
|
fd592e9325 | ||
|
|
7ad928ccdc | ||
|
|
e9f632e4db | ||
|
|
6689d9497c | ||
|
|
3e86419421 | ||
|
|
d2d4f16ebd |
No files matched your search
@@ -10,10 +10,10 @@ body:
|
||||
I am a one-person team working on this plugin as a part-time hobby. Please help me manage the workload by following these guidelines. **Support requests that don't include enough details may be closed without review**.
|
||||
|
||||
Before submitting a support request, please:
|
||||
1. **Review the [documentation](https://github.com/zsviczian/obsidian-excalidraw-plugin/wiki)** – your question may already be answered.
|
||||
2. **[Search issues](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues) (including closed ones)** to see if your question has already been addressed.
|
||||
3. **[Watch the Feature Walkthrough Video](https://youtu.be/P_Q6avJGoWI)**: As it infact answers 90% of the typical questions I receive
|
||||
4. **[Consult NotebookLM with your question](https://excalidraw-obsidian.online/WIKI/09+Video+Transcripts/Videos/Turn+any+YouTube+Channel+into+your+AI+Mentor+-+Obsidian+is+the+ultimate+automation+workbench+for+PKM)**
|
||||
1. **[Consult NotebookLM with your question](https://notebooklm.google.com/notebook/42d76a2f-c11d-4002-9286-1683c43d0ab0)**
|
||||
2. **Review the [documentation](https://github.com/zsviczian/obsidian-excalidraw-plugin/wiki)** – your question may already be answered.
|
||||
3. **[Search issues](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues) (including closed ones)** to see if your question has already been addressed.
|
||||
4. **[Watch the Feature Walkthrough Video](https://youtu.be/P_Q6avJGoWI)**: As it infact answers 90% of the typical questions I receive
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -11,9 +11,9 @@ body:
|
||||
|
||||
Before creating a bug report, please:
|
||||
1. **Review recent [release notes](https://github.com/zsviczian/obsidian-excalidraw-plugin/releases)** – maybe there is already an answer.
|
||||
2. **[Search issues](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues) (including closed ones)** to see if there is anything similar.
|
||||
3. **[Watch the Feature Walkthrough Video](https://youtu.be/P_Q6avJGoWI)**: As it infact answers 90% of the typical questions I receive
|
||||
4. **[Consult NotebookLM with your question](https://excalidraw-obsidian.online/WIKI/09+Video+Transcripts/Videos/Turn+any+YouTube+Channel+into+your+AI+Mentor+-+Obsidian+is+the+ultimate+automation+workbench+for+PKM)** Here's the [direct link to a preloaded NotebookLM](https://notebooklm.google.com/notebook/42d76a2f-c11d-4002-9286-1683c43d0ab0)
|
||||
2. **[Consult NotebookLM with your question](https://notebooklm.google.com/notebook/42d76a2f-c11d-4002-9286-1683c43d0ab0)**
|
||||
3. **[Search issues](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues) (including closed ones)** to see if there is anything similar.
|
||||
4. **[Watch the Feature Walkthrough Video](https://youtu.be/P_Q6avJGoWI)**: As it infact answers 90% of the typical questions I receive
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -7,6 +7,8 @@ body:
|
||||
value: |
|
||||
🛠️ **Important: Please Read Before Submitting a Feature Request** 🛠️
|
||||
|
||||
Before you go further, please chat with [NotebookLM](https://notebooklm.google.com/notebook/42d76a2f-c11d-4002-9286-1683c43d0ab0), it may very well be that the feature you are looking for is already there, or you can find a suitable workaround.
|
||||
|
||||
I develop Excalidraw primarily as a hobby, and I prioritize features that I personally use regularly. Features I don't use often break without me noticing, which is why the plugin is as stable as it is—because I rely on it every day.
|
||||
|
||||
**Your task isn't just to describe the feature you want, but to sell me on the idea**. If I'm not convinced that the feature would significantly benefit my own workflow, it's unlikely I'll spend my free hobby time on it.
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
The Obsidian-Excalidraw plugin integrates [Excalidraw](https://excalidraw.com/), a feature rich sketching tool, into Obsidian. You can store and edit Excalidraw files in your vault, you can embed drawings into your documents, and you can link to documents and other drawings to/and from Excalidraw. For a showcase of Excalidraw features, please read my blog post [here](https://www.zsolt.blog/2021/03/showcasing-excalidraw.html) and/or watch the videos below.
|
||||
|
||||
Excalidraw for Obsidian keeps evolving; it is extremely feature‑rich and can feel intimidating at first. The Video Walkthrough below should ease that initial overwhelm. For a comprehensive, searchable knowledge base covering features, settings, scripting, workflows, and visual thinking methods, explore the public [NotebookLM workbook](https://notebooklm.google.com/notebook/42d76a2f-c11d-4002-9286-1683c43d0ab0) (a must‑have learning resource). If you are curious about the Visual PKM philosophy behind the plugin, consider my book [Sketch Your Mind](https://sketch-your-mind.com/) and the [Visual Thinking Workshops](https://visual-thinking-workshop.com/). Finally, keep the [Excalidraw Plugin Wiki](https://excalidraw-obsidian.online/) at hand—it is an essential companion.
|
||||
|
||||
## Video Walkthrough
|
||||
<a href="https://youtu.be/P_Q6avJGoWI" target="_blank"><img src="https://github.com/zsviczian/obsidian-excalidraw-plugin/assets/14358394/da34bb33-7610-45e6-b36f-cb7a02a9141b" width="300"/></a>
|
||||
<a href="https://youtu.be/o0exK-xFP3k" target="_blank"><img src="https://user-images.githubusercontent.com/14358394/156931370-aa4d88de-c4a8-46cc-aeb2-dc09aa0bea39.jpg" width="300"/></a>
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
Palm Guard: A mobile-friendly drawing mode for Excalidraw that prevents accidental palm touches by hiding UI controls and entering fullscreen mode. Perfect for drawing with a stylus on tablets.
|
||||
|
||||
Features:
|
||||
- Enters fullscreen to maximize drawing space (configurable in plugin script settings)
|
||||
- Hides all UI controls to prevent accidental taps
|
||||
- Provides a minimal floating toolbar with toggle visibility button
|
||||
- Enables a completely distraction-free canvas even on desktop devices by hiding the main toolbar and all chrome while keeping a tiny movable toggle control (addresses immersive canvas / beyond Zen Mode request)
|
||||
- Draggable toolbar can be positioned anywhere on screen
|
||||
- Exit Palm Guard mode with a single tap
|
||||
- Press the hotkey you configured for this script in Obsidian's Hotkey settings (e.g., ALT+X) to toggle UI visibility; if no hotkey is set, use the on-screen toggle button.
|
||||
|
||||

|
||||
|
||||
```js
|
||||
*/
|
||||
|
||||
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("2.14.2")) {
|
||||
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
|
||||
return;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
if(window.excalidrawPalmGuard) {
|
||||
window.excalidrawPalmGuard()
|
||||
return;
|
||||
}
|
||||
const modal = new ea.FloatingModal(ea.plugin.app);
|
||||
const FULLSCREEN = "Goto fullscreen?";
|
||||
let settings = ea.getScriptSettings() || {};
|
||||
if(!settings[FULLSCREEN]) {
|
||||
settings[FULLSCREEN] = { value: true };
|
||||
await ea.setScriptSettings(settings);
|
||||
}
|
||||
|
||||
//added only to clean up settings if someone installed the initial version of the script
|
||||
const HOTKEY_MODIFIERS = "PalmGuard Toggle UI Hotkey Modifiers";
|
||||
const HOTKEY_KEY = "PalmGuard Toggle UI Hotkey Key";
|
||||
if(settings[HOTKEY_MODIFIERS] || settings[HOTKEY_KEY]) {
|
||||
delete settings[HOTKEY_MODIFIERS];
|
||||
delete settings[HOTKEY_KEY];
|
||||
await ea.setScriptSettings(settings);
|
||||
}
|
||||
|
||||
const enableFullscreen = settings[FULLSCREEN].value;
|
||||
|
||||
// Initialize state
|
||||
let uiHidden = true;
|
||||
let currentIcon = "eye";
|
||||
const toolbar = ea.targetView.contentEl.querySelector(".excalidraw > .Island");
|
||||
let toolbarActive = toolbar?.style.display === "block";
|
||||
let prevHiddenState = false;
|
||||
|
||||
// Function to toggle UI visibility
|
||||
const toggleUIVisibility = (hidden) => {
|
||||
if(hidden === prevHiddenState) return hidden;
|
||||
prevHiddenState = hidden;
|
||||
try{
|
||||
const topBar = ea.targetView.containerEl.querySelector(".App-top-bar");
|
||||
const bottomBar = ea.targetView.containerEl.querySelector(".App-bottom-bar");
|
||||
const sidebarToggle = ea.targetView.containerEl.querySelector(".sidebar-toggle");
|
||||
const plugins = ea.targetView.containerEl.querySelector(".plugins-container");
|
||||
|
||||
if(hidden) {
|
||||
if (toolbarActive && (toolbar?.style.display === "none")) {
|
||||
toolbarActive = false;
|
||||
}
|
||||
if (toolbarActive = toolbar?.style.display === "block") {
|
||||
toolbarActive = true;
|
||||
};
|
||||
}
|
||||
|
||||
const display = hidden ? "none" : "";
|
||||
|
||||
if (topBar) topBar.style.display = display;
|
||||
if (bottomBar) bottomBar.style.display = display;
|
||||
if (sidebarToggle) sidebarToggle.style.display = display;
|
||||
if (plugins) plugins.style.display = display;
|
||||
if (toolbarActive) toolbar.style.display = hidden ? "none" : "block";
|
||||
modal.modalEl.style.opacity = hidden ? "0.4" : "0.8";
|
||||
} catch {};
|
||||
return hidden;
|
||||
};
|
||||
|
||||
// Enter fullscreen view mode
|
||||
if(enableFullscreen) ea.targetView.gotoFullscreen();
|
||||
setTimeout(()=>toggleUIVisibility(true),100);
|
||||
|
||||
// Create floating toolbar modal
|
||||
Object.assign(modal.modalEl.style, {
|
||||
width: "fit-content",
|
||||
minWidth: "fit-content",
|
||||
height: "fit-content",
|
||||
minHeight: "fit-content",
|
||||
paddingBottom: "4px",
|
||||
paddingTop: "16px",
|
||||
paddingRight: "4px",
|
||||
paddingLeft: "4px"
|
||||
});
|
||||
|
||||
modal.headerEl.style.display = "none";
|
||||
// Configure modal
|
||||
modal.titleEl.setText(""); // No title for minimal UI
|
||||
|
||||
// Create modal content
|
||||
modal.contentEl.createDiv({ cls: "palm-guard-toolbar" }, div => {
|
||||
const container = div.createDiv({
|
||||
attr: {
|
||||
style: "display: flex; flex-direction: column; background-color: var(--background-secondary); border-radius: 4px;"
|
||||
}
|
||||
});
|
||||
|
||||
// Button container
|
||||
const buttonContainer = container.createDiv({
|
||||
attr: {
|
||||
style: "display: flex; flex-wrap: wrap; gap: 4px; justify-content: center;"
|
||||
}
|
||||
});
|
||||
|
||||
// Toggle UI visibility button
|
||||
const toggleButton = buttonContainer.createEl("button", {
|
||||
cls: "palm-guard-btn clickable-icon",
|
||||
attr: {
|
||||
style: "background-color: var(--interactive-accent); color: var(--text-on-accent);"
|
||||
}
|
||||
});
|
||||
toggleButton.innerHTML = ea.obsidian.getIcon("eye").outerHTML;
|
||||
// Keyboard hotkey listener (only acts if hotkey configured)
|
||||
window.excalidrawPalmGuard = () => toggleButton.click();
|
||||
toggleButton.addEventListener("click", () => {
|
||||
uiHidden = !uiHidden;
|
||||
toggleUIVisibility(uiHidden);
|
||||
|
||||
// Toggle icon
|
||||
currentIcon = uiHidden ? "eye" : "eye-off";
|
||||
toggleButton.innerHTML = ea.obsidian.getIcon(currentIcon).outerHTML;
|
||||
});
|
||||
|
||||
// Exit button
|
||||
const exitButton = buttonContainer.createEl("button", {
|
||||
cls: "palm-guard-btn clickable-icon",
|
||||
attr: {
|
||||
style: "background-color: var(--background-secondary-alt); color: var(--text-normal);"
|
||||
}
|
||||
});
|
||||
exitButton.innerHTML = ea.obsidian.getIcon("cross").outerHTML;
|
||||
|
||||
exitButton.addEventListener("click", () => {
|
||||
modal.close();
|
||||
});
|
||||
|
||||
// Add CSS
|
||||
div.createEl("style", {
|
||||
text: `
|
||||
.palm-guard-btn:hover {
|
||||
filter: brightness(1.1);
|
||||
}
|
||||
.modal-close-button {
|
||||
display: none;
|
||||
}
|
||||
.palm-guard-btn {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 4px;
|
||||
border-radius: 10%;
|
||||
width: 2em;
|
||||
height: 2em;
|
||||
cursor: pointer;
|
||||
}
|
||||
`
|
||||
});
|
||||
});
|
||||
|
||||
const autocloseTimer = setInterval(()=>{
|
||||
if(!ea.targetView) modal.close();
|
||||
},1000);
|
||||
|
||||
// Handle modal close (exit Palm Guard mode)
|
||||
modal.onClose = () => {
|
||||
// Show all UI elements
|
||||
toggleUIVisibility(false);
|
||||
|
||||
// Exit fullscreen
|
||||
if(ea.targetView && enableFullscreen) ea.targetView.exitFullscreen();
|
||||
clearInterval(autocloseTimer);
|
||||
delete window.excalidrawPalmGuard;
|
||||
};
|
||||
|
||||
// Open the modal
|
||||
modal.open();
|
||||
|
||||
// Position the modal in the top left initially
|
||||
setTimeout(() => {
|
||||
const modalEl = modal.modalEl;
|
||||
const rect = ea.targetView.contentEl.getBoundingClientRect();
|
||||
if (modalEl) {
|
||||
modalEl.style.left = `${rect.left+10}px`;
|
||||
modalEl.style.top = `${rect.top+10}px`;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
run();
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="skip"><path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2"/><path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2"/><path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8"/><path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15"/></svg>
|
||||
|
After Width: | Height: | Size: 459 B |
@@ -6,13 +6,27 @@ Export Excalidraw to PDF Pages: Define printable page areas using frames, then e
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
```js
|
||||
*/
|
||||
|
||||
if(!ea.verifyMinimumPluginVersion || !ea.verifyMinimumPluginVersion("2.15.0")) {
|
||||
new Notice("This script requires a newer version of Excalidraw. Please install the latest version.");
|
||||
return;
|
||||
}
|
||||
|
||||
async function run() {
|
||||
// Help text for the script
|
||||
const HELP_TEXT = `
|
||||
if(window.excalidrawPrintableLayoutWizardModal) {
|
||||
window.excalidrawPrintableLayoutWizardModal.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Help text for the script
|
||||
const HELP_TEXT = `
|
||||
**Easily split your Excalidraw drawing into printable pages!**
|
||||
|
||||
If you find this script helpful, consider [buying me a coffee](https://ko-fi.com/zsolt). Thank you.
|
||||
@@ -59,19 +73,30 @@ You can also access script settings at the bottom of Excalidraw Plugin settings.
|
||||
---
|
||||
|
||||
**Tip:** For more on templates, see [Mastering Excalidraw Templates](https://youtu.be/jgUpYznHP9A). For referencing pages in markdown, see [Image Fragments](https://youtu.be/sjZfdqpxqsg) and [Image Block References](https://youtu.be/yZQoJg2RCKI).
|
||||
|
||||

|
||||
|
||||

|
||||
`;
|
||||
|
||||
async function run() {
|
||||
modal = new ea.FloatingModal(ea.plugin.app);
|
||||
window.excalidrawPrintableLayoutWizardModal = modal;
|
||||
modal.contentEl.empty();
|
||||
let shouldRestart = false;
|
||||
// Enable frame rendering
|
||||
const st = ea.getExcalidrawAPI().getAppState();
|
||||
const {enabled, clip, name, outline} = st.frameRendering;
|
||||
if(!enabled || clip || !name || !outline) {
|
||||
let {enabled, clip, name, outline, markerName, markerEnabled} = st.frameRendering;
|
||||
if(!enabled || !name || !outline || !markerEnabled || !markerName) {
|
||||
ea.viewUpdateScene({
|
||||
appState: {
|
||||
frameRendering: {
|
||||
enabled: true,
|
||||
clip: false,
|
||||
clip: clip,
|
||||
name: true,
|
||||
outline: true
|
||||
outline: true,
|
||||
markerName: true,
|
||||
markerEnabled: true
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -103,35 +128,74 @@ You can also access script settings at the bottom of Excalidraw Plugin settings.
|
||||
const LOCK_FRAME = "Lock frame after it is created";
|
||||
const SHOULD_ZOOM = "Should zoom after adding page";
|
||||
const SHOULD_CLOSE = "Should close after adding page";
|
||||
const PRINT_EMPTY = "Print empty pages";
|
||||
const PRINT_MARKERS_ONLY = "Print only marker frames";
|
||||
|
||||
// Set default values on first run
|
||||
if (!settings[PAGE_SIZE]) {
|
||||
settings = {};
|
||||
settings[PAGE_SIZE] = { value: "A4", valueSet: PAGE_SIZES };
|
||||
settings[ORIENTATION] = { value: "portrait", valueSet: PAGE_ORIENTATIONS };
|
||||
settings[MARGIN] = { value: "none", valueSet: Object.keys(MARGINS)};
|
||||
settings[PAGE_SIZE] = { value: "A4", valueset: PAGE_SIZES };
|
||||
settings[ORIENTATION] = { value: "portrait", valueset: PAGE_ORIENTATIONS };
|
||||
settings[MARGIN] = { value: "none", valueset: Object.keys(MARGINS)};
|
||||
settings[SHOULD_ZOOM] = { value: false };
|
||||
settings[SHOULD_CLOSE] = { value: false };
|
||||
settings[LOCK_FRAME] = { value: true };
|
||||
await ea.setScriptSettings(settings);
|
||||
settings[PRINT_EMPTY] = { value: false };
|
||||
settings[PRINT_MARKERS_ONLY] = { value: true };
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
const getSortedFrames = () => ea.getViewElements()
|
||||
.filter(el => el.type === "frame")
|
||||
.sort((a, b) => {
|
||||
const nameA = a.name || "";
|
||||
const nameB = b.name || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
});
|
||||
//once off correction. In the first version I incorrectly used valueSet with wrong casing.
|
||||
if(settings[PAGE_SIZE].valueSet) {
|
||||
settings[PAGE_SIZE].valueset = settings[PAGE_SIZE].valueSet;
|
||||
delete settings[PAGE_SIZE].valueSet;
|
||||
settings[ORIENTATION].valueset = settings[ORIENTATION].valueSet;
|
||||
delete settings[ORIENTATION].valueSet;
|
||||
settings[MARGIN].valueset = settings[MARGIN].valueSet;
|
||||
delete settings[MARGIN].valueSet;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
// Find existing page frames and determine next page number
|
||||
if(!settings[LOCK_FRAME]) {
|
||||
settings[LOCK_FRAME] = { value: true };
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
if(!settings[PRINT_EMPTY]) {
|
||||
settings[PRINT_EMPTY] = { value: false };
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
|
||||
if(!settings[PRINT_MARKERS_ONLY]) {
|
||||
settings[PRINT_MARKERS_ONLY] = { value: true };
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
let lockFrame = settings[LOCK_FRAME].value;
|
||||
let shouldClose = settings[SHOULD_CLOSE].value;
|
||||
let shouldZoom = settings[SHOULD_ZOOM].value;
|
||||
let printEmptyPages = settings[PRINT_EMPTY].value;
|
||||
let printMarkersOnly = settings[PRINT_MARKERS_ONLY].value;
|
||||
|
||||
const getSortedFrames = () => {
|
||||
return ea.getViewElements()
|
||||
.filter(el => isEligibleFrame(el))
|
||||
.sort((a, b) => {
|
||||
const nameA = a.name || "";
|
||||
const nameB = b.name || "";
|
||||
return nameA.localeCompare(nameB);
|
||||
});
|
||||
};
|
||||
|
||||
// Find existing page frames and determine next page number
|
||||
const findExistingPages = (selectLastFrame = false) => {
|
||||
const frameElements = getSortedFrames();
|
||||
|
||||
// Extract page numbers from frame names
|
||||
const pageNumbers = frameElements
|
||||
.map(frame => {
|
||||
const match = frame.name?.match(/Page\s+(\d+)/i);
|
||||
const match = frame.name?.match(/(?:Page\s+)?(\d+)/i);
|
||||
return match ? parseInt(match[1]) : 0;
|
||||
})
|
||||
.filter(num => !isNaN(num));
|
||||
@@ -150,10 +214,13 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
nextPageNumber: nextPageNumber
|
||||
};
|
||||
};
|
||||
|
||||
const isEligibleFrame = (el) => el.type === "frame" && (printMarkersOnly ? el.frameRole === "marker" : true);
|
||||
|
||||
// Check if there are frames in the scene and if a frame is selected
|
||||
let existingFrames = ea.getViewElements().filter(el => el.type === "frame");
|
||||
let selectedFrame = ea.getViewSelectedElements().find(el => el.type === "frame");
|
||||
let existingFrames = ea.getViewElements().filter(el => isEligibleFrame(el));
|
||||
let selectedFrame = ea.getViewSelectedElements().find(el => isEligibleFrame(el));
|
||||
|
||||
const hasFrames = existingFrames.length > 0;
|
||||
if(hasFrames && !selectedFrame) {
|
||||
if(st.activeLockedId && existingFrames.find(f=>f.id === st.activeLockedId)) {
|
||||
@@ -162,14 +229,20 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
ea.selectElementsInView([selectedFrame]);
|
||||
} else {
|
||||
findExistingPages(true);
|
||||
selectedFrame = ea.getViewSelectedElements().find(el => el.type === "frame");
|
||||
selectedFrame = ea.getViewSelectedElements().find(el => isEligibleFrame(el));
|
||||
}
|
||||
}
|
||||
|
||||
const hasSelectedFrame = !!selectedFrame;
|
||||
const modal = new ea.FloatingModal(ea.plugin.app);
|
||||
let lockFrame = !!settings[LOCK_FRAME]?.value;
|
||||
let shouldClose = settings[SHOULD_CLOSE].value;
|
||||
let shouldZoom = settings[SHOULD_ZOOM].value;
|
||||
|
||||
// rotation is now a temporary UI state controlled by the center button
|
||||
let rotateOnAdd = false;
|
||||
let centerRotateBtn = null;
|
||||
const setRotateBtnActive = (active) => {
|
||||
if (!centerRotateBtn) return;
|
||||
centerRotateBtn.classList.toggle("is-accent", active);
|
||||
centerRotateBtn.setAttribute("aria-pressed", active ? "true" : "false");
|
||||
};
|
||||
|
||||
// Show notice if there are frames but none selected
|
||||
if (hasFrames && !hasSelectedFrame) {
|
||||
@@ -199,7 +272,7 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
}
|
||||
|
||||
// Format page number with leading zero
|
||||
const pageName = "Page 01";
|
||||
const pageName = "01";
|
||||
|
||||
// Calculate position to center the frame
|
||||
const appState = ea.getExcalidrawAPI().getAppState();
|
||||
@@ -211,19 +284,26 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
|
||||
// Add new page frame
|
||||
const addPage = async (direction, pageSize, orientation) => {
|
||||
selectedFrame = ea.getViewSelectedElements().find(el => el.type === "frame");
|
||||
if (!selectedFrame) return;
|
||||
selectedFrame = ea.getViewSelectedElements().find(el => isEligibleFrame(el));
|
||||
if (!selectedFrame) {
|
||||
const { activeLockedId } = ea.getExcalidrawAPI().getAppState();
|
||||
if(activeLockedId) {
|
||||
selectedFrame = ea.getViewElements().find(el=>el.id === activeLockedId && isEligibleFrame(el));
|
||||
}
|
||||
if (!selectedFrame) return;
|
||||
}
|
||||
ea.viewUpdateScene({appState: {activeLockedId: null}});
|
||||
|
||||
const { frames, nextPageNumber } = findExistingPages();
|
||||
|
||||
// Get dimensions from selected frame
|
||||
// Get dimensions from selected frame, support optional rotation
|
||||
const dimensions = {
|
||||
width: selectedFrame.width,
|
||||
height: selectedFrame.height
|
||||
width: rotateOnAdd ? selectedFrame.height : selectedFrame.width,
|
||||
height: rotateOnAdd ? selectedFrame.width : selectedFrame.height
|
||||
};
|
||||
|
||||
// Format page number with leading zero
|
||||
const pageName = `Page ${nextPageNumber.toString().padStart(2, '0')}`;
|
||||
const pageName = `${nextPageNumber.toString().padStart(2, '0')}`;
|
||||
|
||||
// Calculate position based on direction and selected frame
|
||||
let x = 0;
|
||||
@@ -248,11 +328,16 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
break;
|
||||
}
|
||||
|
||||
return await addFrameElement(x, y, dimensions.width, dimensions.height, pageName);
|
||||
const added = await addFrameElement(x, y, dimensions.width, dimensions.height, pageName);
|
||||
// reset the rotate toggle after adding the frame
|
||||
rotateOnAdd = false;
|
||||
setRotateBtnActive(false);
|
||||
return added;
|
||||
};
|
||||
|
||||
addFrameElement = async (x, y, width, height, pageName, repositionToCursor = false) => {
|
||||
const frameId = ea.addFrame(x, y, width, height, pageName);
|
||||
ea.getElement(frameId).frameRole = "marker";
|
||||
if(lockFrame) {
|
||||
ea.getElement(frameId).locked = true;
|
||||
}
|
||||
@@ -273,8 +358,9 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
return addedFrame;
|
||||
}
|
||||
|
||||
const translateToZero = ({ top, left, bottom, right }, padding=0) => {
|
||||
const {topX, topY, width, height} = ea.getBoundingBox(ea.getViewElements());
|
||||
const translateToZero = ({ x, y, width, height }, padding=0) => {
|
||||
const top = y, left = x, right = x + width, bottom = y + height;
|
||||
const {topX, topY, width:w, height:h} = ea.getBoundingBox(ea.getViewElements());
|
||||
const newTop = top - (topY - padding);
|
||||
const newLeft = left - (topX - padding);
|
||||
const newBottom = bottom - (topY - padding);
|
||||
@@ -288,7 +374,9 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
};
|
||||
}
|
||||
|
||||
// Check if all frames have the same size
|
||||
// NEW: detect if any non-frame element overlaps the given area
|
||||
const hasElementsInArea = (area) => ea.getElementsInArea(ea.getViewElements(), area).length>0;
|
||||
|
||||
const checkFrameSizes = (frames) => {
|
||||
if (frames.length <= 1) return true;
|
||||
|
||||
@@ -301,7 +389,6 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
);
|
||||
};
|
||||
|
||||
// Print frames to PDF
|
||||
const printToPDF = async (marginSize) => {
|
||||
const margin = MARGINS[marginSize] || 0;
|
||||
|
||||
@@ -318,12 +405,6 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
new Notice("No frames found to print");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if all frames have the same size
|
||||
if (!checkFrameSizes(frames)) {
|
||||
new Notice("Only same sized pages are supported currently", 7000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a notice during processing
|
||||
const notice = new Notice("Preparing PDF, please wait...", 0);
|
||||
@@ -331,23 +412,33 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
// Create SVGs for each frame
|
||||
const svgPages = [];
|
||||
|
||||
let placeholderRects = [];
|
||||
ea.clear();
|
||||
for (const frame of frames) {
|
||||
ea.style.opacity = 0;
|
||||
ea.style.roughness = 0;
|
||||
ea.style.fillStyle = "solid";
|
||||
ea.style.backgroundColor = "black"
|
||||
ea.style.strokeWidth = 0.01;
|
||||
ea.addRect(frame.x, frame.y, frame.width, frame.height);
|
||||
}
|
||||
|
||||
const svgScene = await ea.createViewSVG({
|
||||
withBackground: true,
|
||||
theme: st.theme,
|
||||
frameRendering: { enabled: false, name: false, outline: false, clip: false },
|
||||
//frameRendering: { enabled: false, name: false, outline: false, clip: false },
|
||||
padding: 0,
|
||||
selectedOnly: false,
|
||||
skipInliningFonts: false,
|
||||
embedScene: false,
|
||||
elementsOverride: ea.getViewElements().concat(ea.getElements()),
|
||||
});
|
||||
|
||||
ea.clear();
|
||||
for (const frame of frames) {
|
||||
const { top, left, bottom, right } = translateToZero({
|
||||
top: frame.y,
|
||||
left: frame.x,
|
||||
bottom: frame.y + frame.height,
|
||||
right: frame.x + frame.width,
|
||||
});
|
||||
// NEW: skip empty frames unless user opted to print them
|
||||
if(!printEmptyPages && !hasElementsInArea(frame)) continue;
|
||||
|
||||
const { top, left, bottom, right } = translateToZero(frame);
|
||||
|
||||
//always create the new SVG in the main Obsidian workspace (not the popout window, if present)
|
||||
const host = window.createDiv();
|
||||
@@ -361,6 +452,14 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
svgPages.push(clonedSVG);
|
||||
}
|
||||
|
||||
// NEW: abort if nothing to print
|
||||
if(svgPages.length === 0) {
|
||||
notice.hide();
|
||||
new Notice("No pages to print (all selected frames are empty)");
|
||||
notice.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
// Use dimensions from the first frame
|
||||
const width = frames[0].width;
|
||||
const height = frames[0].height;
|
||||
@@ -370,7 +469,8 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
SVG: svgPages,
|
||||
scale: { fitToPage: true },
|
||||
pageProps: {
|
||||
dimensions: { width, height },
|
||||
dimensions: {},
|
||||
//dimensions: { width, height },
|
||||
backgroundColor: "#ffffff",
|
||||
margin: {
|
||||
left: margin,
|
||||
@@ -392,11 +492,17 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
modal.titleEl.setText("Page Management");
|
||||
modal.titleEl.style.textAlign = "center";
|
||||
|
||||
// Handle save settings on modal close
|
||||
modal.onClose = () => {
|
||||
modal.onClose = async () => {
|
||||
delete window.excalidrawPrintableLayoutWizardModal;
|
||||
if (dirty) {
|
||||
ea.setScriptSettings(settings);
|
||||
await ea.setScriptSettings(settings);
|
||||
}
|
||||
ea.viewUpdateScene({
|
||||
appState: {
|
||||
frameRendering: {enabled, clip, name, outline, markerName, markerEnabled}
|
||||
}
|
||||
});
|
||||
if(shouldRestart) setTimeout(()=>run());
|
||||
};
|
||||
|
||||
// Create modal content
|
||||
@@ -407,13 +513,12 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
}
|
||||
});
|
||||
|
||||
// Add help section at the top
|
||||
// Help section
|
||||
const helpDiv = container.createDiv({
|
||||
attr: {
|
||||
style: "margin-bottom: 10px;"
|
||||
}
|
||||
});
|
||||
|
||||
helpDiv.createEl("details", {}, (details) => {
|
||||
details.createEl("summary", {
|
||||
text: "Help & Information",
|
||||
@@ -430,128 +535,153 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
ea.obsidian.MarkdownRenderer.render(ea.plugin.app, HELP_TEXT, div, "", ea.plugin)
|
||||
});
|
||||
});
|
||||
|
||||
let pageSizeDropdown, orientationDropdown, marginDropdown;
|
||||
|
||||
// Settings section - only show for first frame creation
|
||||
if (!hasFrames) {
|
||||
const settingsContainer = container.createDiv({
|
||||
attr: {
|
||||
style: "display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;"
|
||||
}
|
||||
});
|
||||
|
||||
// Page size dropdown
|
||||
settingsContainer.createEl("label", { text: "Page Size:" });
|
||||
pageSizeDropdown = settingsContainer.createEl("select", {
|
||||
cls: "dropdown",
|
||||
attr: { style: "width: 100%;" }
|
||||
});
|
||||
|
||||
PAGE_SIZES.forEach(size => {
|
||||
pageSizeDropdown.createEl("option", { text: size, value: size });
|
||||
});
|
||||
pageSizeDropdown.value = settings[PAGE_SIZE].value;
|
||||
|
||||
// Orientation dropdown
|
||||
settingsContainer.createEl("label", { text: "Orientation:" });
|
||||
orientationDropdown = settingsContainer.createEl("select", {
|
||||
cls: "dropdown",
|
||||
attr: { style: "width: 100%;" }
|
||||
});
|
||||
|
||||
PAGE_ORIENTATIONS.forEach(orientation => {
|
||||
orientationDropdown.createEl("option", { text: orientation, value: orientation });
|
||||
});
|
||||
orientationDropdown.value = settings[ORIENTATION].value;
|
||||
}
|
||||
|
||||
// Show margin settings only if frames exist
|
||||
|
||||
// Tabs (show only when frames exist)
|
||||
let framesTabEl, printingTabEl, tabsHeaderEl, marginDropdown;
|
||||
if (hasFrames) {
|
||||
const marginContainer = container.createDiv({
|
||||
attr: {
|
||||
style: "display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center;"
|
||||
tabsHeaderEl = container.createDiv({
|
||||
attr: { style: "display:flex; gap:8px; border-bottom:1px solid var(--background-modifier-border); padding-bottom:0;" }
|
||||
});
|
||||
tabsHeaderEl.addClass("tabs-header"); // NEW
|
||||
|
||||
const framesTabBtn = tabsHeaderEl.createEl("button", {
|
||||
text: "Frames",
|
||||
attr: { style: "padding:8px 12px; cursor:pointer;" }
|
||||
});
|
||||
framesTabBtn.addClass("tab-btn"); // NEW
|
||||
|
||||
const printingTabBtn = tabsHeaderEl.createEl("button", {
|
||||
text: "Printing",
|
||||
attr: { style: "padding:8px 12px; cursor:pointer;" }
|
||||
});
|
||||
printingTabBtn.addClass("tab-btn"); // NEW
|
||||
|
||||
const tabsBody = container.createDiv();
|
||||
tabsBody.addClass("tab-panels"); // NEW
|
||||
|
||||
framesTabEl = tabsBody.createDiv({ attr: { style: "display:block;" } });
|
||||
framesTabEl.addClass("tab-panel"); // NEW
|
||||
|
||||
printingTabEl = tabsBody.createDiv({ attr: { style: "display:none;" } });
|
||||
printingTabEl.addClass("tab-panel"); // NEW
|
||||
|
||||
const activate = (tab) => {
|
||||
if (tab === "frames") {
|
||||
framesTabEl.style.display = "";
|
||||
printingTabEl.style.display = "none";
|
||||
framesTabBtn.classList.add("is-active");
|
||||
printingTabBtn.classList.remove("is-active");
|
||||
} else {
|
||||
framesTabEl.style.display = "none";
|
||||
printingTabEl.style.display = "";
|
||||
framesTabBtn.classList.remove("is-active");
|
||||
printingTabBtn.classList.add("is-active");
|
||||
}
|
||||
};
|
||||
framesTabBtn.addEventListener("click", () => {
|
||||
window.excalidrawPrintLayoutWizard = "frames";
|
||||
activate("frames")
|
||||
});
|
||||
|
||||
// Margin dropdown (for printing)
|
||||
marginContainer.createEl("label", { text: "Print Margin:" });
|
||||
marginDropdown = marginContainer.createEl("select", {
|
||||
cls: "dropdown",
|
||||
attr: { style: "width: 100%;" }
|
||||
printingTabBtn.addEventListener("click", () => {
|
||||
window.excalidrawPrintLayoutWizard = "printing";
|
||||
activate("printing")
|
||||
});
|
||||
|
||||
Object.keys(MARGINS).forEach(margin => {
|
||||
marginDropdown.createEl("option", { text: margin, value: margin });
|
||||
});
|
||||
marginDropdown.value = settings[MARGIN].value;
|
||||
activate(window.excalidrawPrintLayoutWizard ?? "frames");
|
||||
} else {
|
||||
// No frames yet, only frames tab content
|
||||
framesTabEl = container.createDiv();
|
||||
}
|
||||
|
||||
// Add checkboxes for zoom and modal behavior only when frames exist
|
||||
const optionsContainer = container.createDiv({
|
||||
attr: {
|
||||
style: "margin-top: 10px;"
|
||||
}
|
||||
});
|
||||
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Lock")
|
||||
.setDesc("Lock the new frame element after it is created.")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(lockFrame)
|
||||
.onChange(value => {
|
||||
const createOptionsContainerCommonControls = (optionsContainer) => {
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Lock")
|
||||
.setDesc("Lock the new frame element after it is created.")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(lockFrame).onChange(value => {
|
||||
lockFrame = value;
|
||||
if (settings[LOCK_FRAME].value !== value) {
|
||||
settings[LOCK_FRAME].value = value;
|
||||
dirty = true;
|
||||
settings[LOCK_FRAME].value = value; dirty = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Zoom to added frame checkbox
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Zoom to new frame")
|
||||
.setDesc("Automatically zoom to the newly created frame")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(shouldZoom)
|
||||
.onChange(value => {
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Zoom to new frame")
|
||||
.setDesc("Automatically zoom to the newly created frame")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(shouldZoom).onChange(value => {
|
||||
shouldZoom = value;
|
||||
if (settings[SHOULD_ZOOM].value !== value) {
|
||||
settings[SHOULD_ZOOM].value = value;
|
||||
dirty = true;
|
||||
settings[SHOULD_ZOOM].value = value; dirty = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Close after adding checkbox
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Close after adding")
|
||||
.setDesc("Close this dialog after adding a new frame")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(shouldClose)
|
||||
.onChange(value => {
|
||||
});
|
||||
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Close after adding")
|
||||
.setDesc("Close this dialog after adding a new frame")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(shouldClose).onChange(value => {
|
||||
shouldClose = value;
|
||||
if (settings[SHOULD_CLOSE].value !== value) {
|
||||
settings[SHOULD_CLOSE].value = value;
|
||||
dirty = true;
|
||||
settings[SHOULD_CLOSE].value = value; dirty = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Buttons section
|
||||
const buttonContainer = container.createDiv({
|
||||
attr: {
|
||||
style: "display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px;"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
new ea.obsidian.Setting(optionsContainer)
|
||||
.setName("Use only Marker Frames")
|
||||
.setDesc("When off, all frames will be printed (not just marker frames)")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(printMarkersOnly).onChange(value => {
|
||||
printMarkersOnly = value;
|
||||
if (settings[PRINT_MARKERS_ONLY].value !== value) {
|
||||
settings[PRINT_MARKERS_ONLY].value = value;
|
||||
dirty = true;
|
||||
shouldRestart = true;
|
||||
modal.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// FRAMES TAB CONTENT
|
||||
// When no frames yet: initial size/orientation inputs and Create First Frame button
|
||||
if (!hasFrames) {
|
||||
// First frame creation button (centered)
|
||||
const settingsContainer = framesTabEl.createDiv({
|
||||
attr: {
|
||||
// four columns: label + input, label + input
|
||||
style: "display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 10px; align-items: center;"
|
||||
}
|
||||
});
|
||||
// Page Size
|
||||
settingsContainer.createEl("label", { text: "Page Size:" });
|
||||
const pageSizeDropdown = settingsContainer.createEl("select", {
|
||||
cls: "dropdown",
|
||||
attr: { style: "width: 100%;" }
|
||||
});
|
||||
PAGE_SIZES.forEach(size => pageSizeDropdown.createEl("option", { text: size, value: size }));
|
||||
pageSizeDropdown.value = settings[PAGE_SIZE].value;
|
||||
|
||||
// Orientation
|
||||
settingsContainer.createEl("label", { text: "Orientation:" });
|
||||
const orientationDropdown = settingsContainer.createEl("select", {
|
||||
cls: "dropdown",
|
||||
attr: { style: "width: 100%;" }
|
||||
});
|
||||
PAGE_ORIENTATIONS.forEach(orientation => orientationDropdown.createEl("option", { text: orientation, value: orientation }));
|
||||
orientationDropdown.value = settings[ORIENTATION].value;
|
||||
|
||||
const optionsContainer = framesTabEl.createDiv({ attr: { style: "margin-top: 10px;" } });
|
||||
createOptionsContainerCommonControls(optionsContainer);
|
||||
|
||||
// Create First Frame button
|
||||
const buttonContainer = framesTabEl.createDiv({
|
||||
attr: { style: "display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 10px;" }
|
||||
});
|
||||
const createFirstBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: {
|
||||
style: "grid-column: 1 / span 3; height: 40px; background-color: var(--interactive-accent); color: var(--text-on-accent);"
|
||||
}
|
||||
attr: { style: "height: 40px; background-color: var(--interactive-accent); color: var(--text-on-accent);" }
|
||||
});
|
||||
createFirstBtn.textContent = "Create First Frame";
|
||||
createFirstBtn.addEventListener("click", async () => {
|
||||
@@ -559,77 +689,106 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
shouldClose = true;
|
||||
await createFirstFrame(pageSizeDropdown.value, orientationDropdown.value);
|
||||
shouldClose = tmpShouldClose;
|
||||
if(!shouldClose) run();
|
||||
});
|
||||
} else if (hasSelectedFrame) {
|
||||
// Only show navigation buttons and print when a frame is selected
|
||||
|
||||
// Up button (in middle of top row)
|
||||
const upBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: {
|
||||
style: "grid-column: 2; grid-row: 1; height: 40px;"
|
||||
if(!shouldClose) {
|
||||
shouldRestart = true;
|
||||
modal.close()
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// hasFrames: frame-management options + arrow buttons
|
||||
const optionsContainer = framesTabEl.createDiv({ attr: { style: "margin-top: 10px;" } });
|
||||
createOptionsContainerCommonControls(optionsContainer);
|
||||
|
||||
// Arrow buttons with center rotate toggle
|
||||
const buttonContainer = framesTabEl.createDiv({
|
||||
attr: {
|
||||
style: "display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px;"
|
||||
}
|
||||
});
|
||||
|
||||
const upBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: { style: "grid-column: 2; grid-row: 1; height: 40px;" }
|
||||
});
|
||||
upBtn.innerHTML = ea.obsidian.getIcon("arrow-big-up").outerHTML;
|
||||
upBtn.addEventListener("click", async () => {
|
||||
await addPage("up");
|
||||
});
|
||||
|
||||
// Add empty space
|
||||
buttonContainer.createDiv({
|
||||
attr: { style: "grid-column: 3; grid-row: 1;" }
|
||||
});
|
||||
|
||||
// Left button
|
||||
upBtn.addEventListener("click", async () => { await addPage("up"); });
|
||||
|
||||
buttonContainer.createDiv({ attr: { style: "grid-column: 3; grid-row: 1;" } });
|
||||
|
||||
const leftBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: { style: "grid-column: 1; grid-row: 2; height: 40px;" }
|
||||
});
|
||||
leftBtn.innerHTML = ea.obsidian.getIcon("arrow-big-left").outerHTML;
|
||||
leftBtn.addEventListener("click", async () => {
|
||||
await addPage("left");
|
||||
});
|
||||
|
||||
// Print button (center)
|
||||
const printBtn = buttonContainer.createEl("button", {
|
||||
leftBtn.addEventListener("click", async () => { await addPage("left"); });
|
||||
|
||||
// Center toggle: Rotate next page
|
||||
centerRotateBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: {
|
||||
style: "grid-column: 2; grid-row: 2; height: 40px; background-color: var(--interactive-accent);"
|
||||
}
|
||||
attr: { style: "grid-column: 2; grid-row: 2; height: 40px;" }
|
||||
});
|
||||
printBtn.innerHTML = ea.obsidian.getIcon("printer").outerHTML;
|
||||
printBtn.addEventListener("click", async () => {
|
||||
await printToPDF(marginDropdown.value);
|
||||
centerRotateBtn.textContent = "Rotate next page";
|
||||
centerRotateBtn.addEventListener("click", () => {
|
||||
rotateOnAdd = !rotateOnAdd;
|
||||
setRotateBtnActive(rotateOnAdd);
|
||||
});
|
||||
|
||||
// Right button
|
||||
setRotateBtnActive(rotateOnAdd);
|
||||
|
||||
const rightBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: { style: "grid-column: 3; grid-row: 2; height: 40px;" }
|
||||
});
|
||||
rightBtn.innerHTML = ea.obsidian.getIcon("arrow-big-right").outerHTML;
|
||||
rightBtn.addEventListener("click", async () => {
|
||||
await addPage("right");
|
||||
});
|
||||
|
||||
// Down button (in middle of bottom row)
|
||||
rightBtn.addEventListener("click", async () => { await addPage("right"); });
|
||||
|
||||
const downBtn = buttonContainer.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: { style: "grid-column: 2; grid-row: 3; height: 40px;" }
|
||||
});
|
||||
downBtn.innerHTML = ea.obsidian.getIcon("arrow-big-down").outerHTML;
|
||||
downBtn.addEventListener("click", async () => {
|
||||
await addPage("down");
|
||||
});
|
||||
|
||||
// Add empty space
|
||||
buttonContainer.createDiv({
|
||||
attr: { style: "grid-column: 1; grid-row: 3;" }
|
||||
});
|
||||
downBtn.addEventListener("click", async () => { await addPage("down"); });
|
||||
|
||||
buttonContainer.createDiv({ attr: { style: "grid-column: 1; grid-row: 3;" } });
|
||||
}
|
||||
|
||||
// Add CSS
|
||||
|
||||
// PRINTING TAB CONTENT (only when hasFrames)
|
||||
if (hasFrames && printingTabEl) {
|
||||
const marginContainer = printingTabEl.createDiv({
|
||||
attr: {
|
||||
style: "display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-top: 6px;"
|
||||
}
|
||||
});
|
||||
marginContainer.createEl("label", { text: "Print Margin:" });
|
||||
marginDropdown = marginContainer.createEl("select", { cls: "dropdown", attr: { style: "width: 100%;" } });
|
||||
Object.keys(MARGINS).forEach(margin => marginDropdown.createEl("option", { text: margin, value: margin }));
|
||||
marginDropdown.value = settings[MARGIN].value;
|
||||
|
||||
const printingOptions = printingTabEl.createDiv({ attr: { style: "margin-top: 10px;" } });
|
||||
|
||||
new ea.obsidian.Setting(printingOptions)
|
||||
.setName(PRINT_EMPTY)
|
||||
.setDesc("Include frames with no content in the PDF")
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(printEmptyPages).onChange(value => {
|
||||
printEmptyPages = value;
|
||||
if(settings[PRINT_EMPTY].value !== value) {
|
||||
settings[PRINT_EMPTY].value = value;
|
||||
dirty = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
const printBtnRow = printingTabEl.createDiv({ attr: { style: "margin-top: 10px; display:flex; justify-content:flex-start;" } });
|
||||
const printBtn = printBtnRow.createEl("button", {
|
||||
cls: "page-btn",
|
||||
attr: { style: "height: 40px; background-color: var(--interactive-accent);" }
|
||||
});
|
||||
printBtn.innerHTML = ea.obsidian.getIcon("printer").outerHTML;
|
||||
printBtn.addEventListener("click", async () => { await printToPDF(marginDropdown.value); });
|
||||
}
|
||||
|
||||
// CSS
|
||||
div.createEl("style", {
|
||||
text: `
|
||||
.page-btn {
|
||||
@@ -650,6 +809,51 @@ const getSortedFrames = () => ea.getViewElements()
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
padding: 0 10px;
|
||||
}
|
||||
.is-active {
|
||||
background-color: var(--background-modifier-hover);
|
||||
border-radius: 4px;
|
||||
}
|
||||
/* Tabs styling - NEW */
|
||||
.tabs-header {
|
||||
gap: 8px;
|
||||
border-bottom: 1px solid var(--background-modifier-border);
|
||||
}
|
||||
.tabs-header .tab-btn {
|
||||
background: var(--background-primary);
|
||||
color: var(--text-normal);
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
border-bottom: none;
|
||||
border-top-left-radius: 6px;
|
||||
border-top-right-radius: 6px;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
padding: 8px 12px;
|
||||
margin-bottom: -1px; /* sit on top of the panel border */
|
||||
}
|
||||
.tabs-header .tab-btn:hover {
|
||||
background: var(--background-modifier-hover);
|
||||
}
|
||||
.tabs-header .tab-btn.is-active {
|
||||
background: var(--background-secondary);
|
||||
color: var(--text-normal);
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
}
|
||||
.tab-panels {
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
border-radius: 0 6px 6px 6px; /* merge with active tab */
|
||||
padding: 12px;
|
||||
background: var(--background-primary);
|
||||
}
|
||||
|
||||
/* accent styling for center rotate toggle when active */
|
||||
.page-btn.is-accent {
|
||||
background-color: var(--interactive-accent);
|
||||
color: var(--text-on-accent);
|
||||
}
|
||||
.page-btn.is-accent:hover {
|
||||
background-color: var(--interactive-accent-hover, var(--interactive-accent));
|
||||
}
|
||||
`
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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
|
||||
+41
-1
@@ -26,6 +26,36 @@ I would love to include your contribution in the script library. If you have a s
|
||||
|
||||
# List of available scripts
|
||||
|
||||
## Editors Picks
|
||||
These are the scripts I use most often. I tried to order them by importance, but usefulness is situational—some days Crop Vintage Mask is as helpful as Deconstruct Selected Elements. I do deconstruct drawings daily; the entries lower in the Editors’ Picks list are still valuable, just needed less frequently.
|
||||
|
||||
| | |
|
||||
|----|-----|
|
||||
|<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/Slideshow.svg"/></div>|[[#Slideshow]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Shade%20Master.svg"/></div>|[[#Shade Master]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Palette%20loader.svg"/></div>|[[#Palette Loader]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Palm%20Guard.svg"/></div>|[[#Palm Guard]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Rename%20Image.svg"/></div>|[[#Rename Image]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Select%20Elements%20of%20Type.svg"/></div>|[[#Select Elements of Type]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Select%20Similar%20Elements.svg"/></div>|[[#Select Similar Elements]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Boolean%20Operations.svg"/></div>|[[#Boolean Operations]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Split%20Ellipse.svg"/></div>|[[#Split Ellipse]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Text%20to%20Path.svg"/></div>|[[#Text to Path]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Dimensions.svg"/></div>|[[#Set Dimensions]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20Stroke%20Width%20of%20Selected%20Elements.svg"/></div>|[[#Set Stroke Width of Selected Elements]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Scribble%20Helper.svg"/></div>|[[#Scribble Helper]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Split%20text%20by%20lines.svg"/></div>|[[#Split text by lines]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Text%20Aura.svg"/></div>|[[#Text Aura]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Golden%20Ratio.svg"/></div>|[[#Golden Ratio]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Printable%20Layout%20Wizard.svg"/></div>|[[#Printable Layout Wizard]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Concatenate%20lines.svg"></div>|[[#Concatenate lines]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Repeat%20Elements.svg"/></div>|[[#Repeat Elements]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Set%20background%20color%20of%20unclosed%20line%20object%20by%20adding%20a%20shadow%20clone.svg"/></div>|[[#Set background color of unclosed line object by adding a shadow clone]]|
|
||||
|<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]]|
|
||||
|
||||
## Layout and Organization
|
||||
**Keywords**: Design, Placement, Arrangement, Structure, Formatting, Alignment
|
||||
|
||||
@@ -124,6 +154,7 @@ I would love to include your contribution in the script library. If you have a s
|
||||
|<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/GPT-Draw-a-UI.svg"/></div>|[[#GPT Draw-a-UI]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Palette%20loader.svg"/></div>|[[#Palette Loader]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Palm%20Guard.svg"/></div>|[[#Palm Guard]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/PDF%20Page%20Text%20to%20Clipboard.svg"/></div>|[[#PDF Page Text to Clipboard]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Rename%20Image.svg"/></div>|[[#Rename Image]]|
|
||||
|<div><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Repeat%20Elements.svg"/></div>|[[#Repeat Elements]]|
|
||||
@@ -468,6 +499,14 @@ 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/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/Palette%20loader.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Design your palette at <a href="http://paletton.com/" target="_blank">paletton.com</a> Once you are happy with your colors, click Tables/Export in the bottom right of the screen. Then click "Color swatches/as Sketch Palette", and copy the contents of the page to a markdown file in the palette folder of your vault (default is Excalidraw/Palette)<br><img src='https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-sketch-palette-loader-1.jpg'></td></tr></table>
|
||||
|
||||
## Palm Guard
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Palm%20Guard.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/Palm%20Guard.md'>File on GitHub</a></td></tr>
|
||||
<tr valign='top'><td class="label">Description</td><td class="data">Mobile & desktop palm‑rejection and distraction‑free drawing mode: optionally enters fullscreen, hides ALL Excalidraw UI chrome (top toolbar, side / bottom bars, plugin panels) for a clean / zen / immersive / kiosk / focus mode canvas. Provides a tiny draggable micro toolbar (toggle visibility + exit) so you gain maximum drawing area while preventing accidental palm taps. Uses the hotkey you assign in Obsidian’s Hotkey settings for this script to instantly show / hide controls (if no hotkey is set, use the on‑screen toggle). Ideal for stylus sketching, presentations, screen recording, split‑view space saving, or anyone searching for: palm rejection, hide toolbar, hide UI controls, clean mode, distraction free Excalidraw.<br><iframe width="400" height="225" src="https://www.youtube.com/embed/A_udjVjgWN0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/A_udjVjgWN0' target='_blank'>Link to video on YouTube</a></td></tr></table>
|
||||
|
||||
## PDF Page Text to Clipboard
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/PDF%20Page%20Text%20to%20Clipboard.md
|
||||
@@ -637,7 +676,8 @@ https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea
|
||||
```excalidraw-script-install
|
||||
https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/ea-scripts/Printable%20Layout%20Wizard.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/Printable%20Layout%20Wizard.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Export Excalidraw to PDF Pages: Define printable page areas using frames, then export each frame as a separate page in a multi-page PDF. Perfect for turning your Excalidraw drawings into printable notes, handouts, or booklets. Supports standard and custom page sizes, margins, and easy frame arrangement.<br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-01.png" style="max-width: 400px;"><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-02.png" style="max-width: 400px;"></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/Printable%20Layout%20Wizard.md'>File on GitHub</a></td></tr><tr valign='top'><td class="label">Description</td><td class="data">Export Excalidraw to PDF Pages: Define printable page areas using frames, then export each frame as a separate page in a multi-page PDF. Perfect for turning your Excalidraw drawings into printable notes, handouts, or booklets. Supports standard and custom page sizes, margins, and easy frame arrangement.<br><iframe width="400" height="225" src="https://www.youtube.com/embed/29EWeglRm7" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/29EWeglRm7' target='_blank'>Link to video on YouTube</a><br><br><iframe width="400" height="225" src="https://www.youtube.com/embed/DqDnzCOoYMc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><br><a href='https://youtu.be/DqDnzCOoYMc' target='_blank'>Link to video on YouTube</a><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-01.png" style="max-width: 400px;"><br><img src="https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-layout-wizard-02.png" style="max-width: 400px;"></td></tr></table>
|
||||
|
||||
|
||||
## Zoom to Fit Selected Elements
|
||||
```excalidraw-script-install
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 101 KiB After Width: | Height: | Size: 41 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 63 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.14.1-beta-2",
|
||||
"version": "2.15.0",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.14.0",
|
||||
"version": "2.15.0",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
Generated
+4
-4
@@ -11,7 +11,7 @@
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
"@zsviczian/excalidraw": "0.18.0-25",
|
||||
"@zsviczian/excalidraw": "0.18.0-31",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"es6-promise-pool": "2.5.0",
|
||||
@@ -3494,9 +3494,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@zsviczian/excalidraw": {
|
||||
"version": "0.18.0-25",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-25.tgz",
|
||||
"integrity": "sha512-aZKkzm1ENNUpwf9ANR+RA34fk2FYZNheHWNFj9CkNig/28bsS/MSVntWJNbk1qcqEQOdxhJkRhVN6NYlUtAZjA==",
|
||||
"version": "0.18.0-31",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-31.tgz",
|
||||
"integrity": "sha512-A1wyp8EVOhCdoxdX7middc8LoLpjPLtxiSTeBbdMtungl8VQzAcQ2tSGCkncK/8RBcBaUk44Hr6KcWjezHnQew==",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "6.0.2",
|
||||
"@excalidraw/random-username": "1.1.0",
|
||||
|
||||
+3
-2
@@ -16,14 +16,15 @@
|
||||
"build:mathjax": "cd MathjaxToSVG && npm run build",
|
||||
"build:all": "npm run build:mathjax && npm run build",
|
||||
"dev:mathjax": "cd MathjaxToSVG && npm run dev",
|
||||
"dev:all": "npm run dev:mathjax && npm run dev"
|
||||
"dev:all": "npm run dev:mathjax && npm run dev",
|
||||
"doc": "node scripts/generate-script-library.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-27",
|
||||
"@zsviczian/excalidraw": "0.18.0-33",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/* eslint-disable no-console */
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const ROOT = path.resolve(__dirname, '..');
|
||||
const EA_SCRIPTS_DIR = path.join(ROOT, 'ea-scripts');
|
||||
const INDEX_NEW = path.join(EA_SCRIPTS_DIR, 'index-new.md');
|
||||
const DIST_DIR = path.join(ROOT, 'dist');
|
||||
const OUTPUT_FILE = path.join(DIST_DIR, 'Excalidraw Script Library.md');
|
||||
|
||||
const INTRO = `# Excalidraw Script Library
|
||||
|
||||
This file is an automatically generated knowledge base intended for Retrieval Augmented Generation (RAG) and other AI-assisted workflows (e.g. NotebookLM or local embeddings tools).
|
||||
Its purpose:
|
||||
- Provide a single, query-friendly corpus of all Excalidraw Automate scripts.
|
||||
- Serve as a practical pattern and snippet library for developers learning Excalidraw Automate.
|
||||
- Preserve original source side by side with the higher-level index (index-new.md) to improve semantic recall.
|
||||
- Enable AI tools to answer questions about how to manipulate the Excalidraw canvas, elements, styling, or integration features by referencing real, working examples.
|
||||
|
||||
Content structure:
|
||||
1. Intro (this section)
|
||||
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: ${new Date().toISOString()}
|
||||
|
||||
---
|
||||
|
||||
`;
|
||||
|
||||
/**
|
||||
* Returns true if content contains at least one line starting with ```
|
||||
* and has an odd number of fences (unbalanced).
|
||||
*/
|
||||
function needsClosingFence(content) {
|
||||
const fenceCount = (content.match(/^```/gm) || []).length;
|
||||
return fenceCount > 0 && fenceCount % 2 === 1;
|
||||
}
|
||||
|
||||
function main() {
|
||||
console.log('[script-library] Generating Excalidraw Script Library...');
|
||||
if (!fs.existsSync(EA_SCRIPTS_DIR)) {
|
||||
console.error('ea-scripts directory not found:', EA_SCRIPTS_DIR);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!fs.existsSync(INDEX_NEW)) {
|
||||
console.error('index-new.md not found:', INDEX_NEW);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!fs.existsSync(DIST_DIR)) {
|
||||
fs.mkdirSync(DIST_DIR, { recursive: true });
|
||||
}
|
||||
|
||||
let output = INTRO;
|
||||
|
||||
console.log('[script-library] Adding index-new.md');
|
||||
const indexNewContent = fs.readFileSync(INDEX_NEW, 'utf8');
|
||||
output += `<!-- BEGIN index-new.md -->\n${indexNewContent.trim()}\n<!-- END index-new.md -->\n\n`;
|
||||
output += `---\n\n# Script Sources\n`;
|
||||
|
||||
// Collect *.md files (non-recursive) excluding index-new.md
|
||||
const files = fs
|
||||
.readdirSync(EA_SCRIPTS_DIR, { withFileTypes: true })
|
||||
.filter(
|
||||
(d) =>
|
||||
d.isFile() &&
|
||||
d.name.endsWith('.md') &&
|
||||
d.name.toLowerCase() !== 'index-new.md'
|
||||
)
|
||||
.map((d) => d.name)
|
||||
.sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' }));
|
||||
|
||||
for (const file of files) {
|
||||
const full = path.join(EA_SCRIPTS_DIR, file);
|
||||
let content = fs.readFileSync(full, 'utf8');
|
||||
|
||||
output += `\n---\n\n## ${file}\n`;
|
||||
output += `<!-- Source: ea-scripts/${file} -->\n\n`;
|
||||
|
||||
// Normalize line endings
|
||||
content = content.replace(/\r\n/g, '\n');
|
||||
|
||||
output += content.trimEnd() + '\n';
|
||||
|
||||
if (needsClosingFence(content)) {
|
||||
output += '```\n';
|
||||
console.log(`[script-library] Added missing closing fence to ${file}`);
|
||||
} else {
|
||||
console.log(`[script-library] Added ${file} (no fence fix needed)`);
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFileSync(OUTPUT_FILE, output, 'utf8');
|
||||
console.log('[script-library] Wrote:', OUTPUT_FILE);
|
||||
console.log('[script-library] Done.');
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
try {
|
||||
main();
|
||||
} catch (e) {
|
||||
console.error('[script-library] Failed:', e);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
@@ -709,7 +709,7 @@ export class CommandManager {
|
||||
}
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view) {
|
||||
showFrameSettings(getEA(view));
|
||||
showFrameSettings(view);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+46
-1
@@ -106,6 +106,9 @@ export interface ExcalidrawSettings {
|
||||
zoomToFitOnOpen: boolean;
|
||||
zoomToFitOnResize: boolean;
|
||||
zoomToFitMaxLevel: number;
|
||||
zoomStep: number; // % increment per zoom action (e.g. mouse wheel)
|
||||
zoomMin: number; // minimum zoom percentage
|
||||
zoomMax: number; // maximum zoom percentage
|
||||
openInAdjacentPane: boolean;
|
||||
showSecondOrderLinks: boolean;
|
||||
focusOnFileTab: boolean;
|
||||
@@ -291,6 +294,9 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
zoomToFitOnOpen: true,
|
||||
zoomToFitOnResize: true,
|
||||
zoomToFitMaxLevel: 2,
|
||||
zoomStep: 0.05,
|
||||
zoomMin: 0.1,
|
||||
zoomMax: 30,
|
||||
linkPrefix: "📍",
|
||||
urlPrefix: "🌐",
|
||||
parseTODO: false,
|
||||
@@ -1425,6 +1431,45 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}
|
||||
})
|
||||
|
||||
createSliderWithText(detailsEl, {
|
||||
name: t("ZOOM_STEP_NAME"),
|
||||
desc: t("ZOOM_STEP_DESC"),
|
||||
value: this.plugin.settings.zoomStep*100,
|
||||
min: 1,
|
||||
max: 25,
|
||||
step: 1,
|
||||
onChange: (value) => {
|
||||
this.plugin.settings.zoomStep = value/100;
|
||||
this.applySettingsUpdate();
|
||||
}
|
||||
})
|
||||
|
||||
createSliderWithText(detailsEl, {
|
||||
name: t("ZOOM_MIN_NAME"),
|
||||
desc: t("ZOOM_MIN_DESC"),
|
||||
value: this.plugin.settings.zoomMin*100,
|
||||
min: 1,
|
||||
max: 50,
|
||||
step: 1,
|
||||
onChange: (value) => {
|
||||
this.plugin.settings.zoomMin = value/100;
|
||||
this.applySettingsUpdate();
|
||||
}
|
||||
})
|
||||
|
||||
createSliderWithText(detailsEl, {
|
||||
name: t("ZOOM_MAX_NAME"),
|
||||
desc: t("ZOOM_MAX_DESC"),
|
||||
value: this.plugin.settings.zoomMax*100,
|
||||
min: 500,
|
||||
max: 6000,
|
||||
step: 100,
|
||||
onChange: (value) => {
|
||||
this.plugin.settings.zoomMax = value/100;
|
||||
this.applySettingsUpdate();
|
||||
}
|
||||
})
|
||||
|
||||
// ------------------------------------------------
|
||||
// Pen
|
||||
// ------------------------------------------------
|
||||
@@ -2575,7 +2620,7 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
// Non-excalidraw.com supported features
|
||||
// ------------------------------------------------
|
||||
containerEl.createEl("hr", { cls: "excalidraw-setting-hr" });
|
||||
containerEl.createDiv({ text: t("NONSTANDARD_DESC"), cls: "setting-item-description" });
|
||||
containerEl.createDiv( { text: t("NONSTANDARD_DESC"), cls: "setting-item-description" });
|
||||
detailsEl = this.containerEl.createEl("details");
|
||||
const nonstandardDetailsEl = detailsEl;
|
||||
detailsEl.createEl("summary", {
|
||||
|
||||
+15
-1
@@ -58,6 +58,10 @@ export default {
|
||||
NEW_IN_POPOUT_WINDOW_EMBED: "Create new drawing - IN A POPOUT WINDOW - and embed into active document",
|
||||
TOGGLE_LOCK: "Toggle Text Element between edit RAW and PREVIEW",
|
||||
DELETE_FILE: "Delete selected image or Markdown file from Obsidian Vault",
|
||||
MARKER_FRAME_SHOW: "Show Marker Frames",
|
||||
MARKER_FRAME_HIDE: "Hide Marker Frames",
|
||||
MARKER_FRAME_TITLE_SHOW: "Show Marker Frame Titles",
|
||||
MARKER_FRAME_TITLE_HIDE: "Hide Marker Frame Titles",
|
||||
COPY_ELEMENT_LINK: "Copy [[link]] for selected element(s)",
|
||||
COPY_DRAWING_LINK: "Copy ![[embed link]] for this drawing",
|
||||
INSERT_LINK_TO_ELEMENT:
|
||||
@@ -344,7 +348,7 @@ export default {
|
||||
"Excalidraw will also save the file when closing a workspace tab or navigating within Obsidian, but away from the active Excalidraw tab (i.e. tapping on the Obsidian ribbon or checking backlinks, etc.). " +
|
||||
"Excalidraw will not be able to save your work when terminating Obsidian directly (i.e. swiping it away). Also note, that when you switch apps on a Mobile device, sometimes Android and iOS closes " +
|
||||
"Obsidian in the background to save system resources. In such a case Excalidraw will not be able to save the latest changes.",
|
||||
FILENAME_HEAD: "Filename",
|
||||
FILENAME_HEAD: "Filename",
|
||||
FILENAME_DESC:
|
||||
"<p>Click this link for the <a href='https://momentjs.com/docs/#/displaying/format/'>" +
|
||||
"date and time format reference</a>.</p>",
|
||||
@@ -459,6 +463,12 @@ FILENAME_HEAD: "Filename",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_NAME: "Zoom to fit max ZOOM level",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_DESC:
|
||||
"Set the maximum level to which zoom to fit will enlarge the drawing. Minimum is 0.5 (50%) and maximum is 10 (1000%).",
|
||||
ZOOM_STEP_NAME: "Zoom increment",
|
||||
ZOOM_STEP_DESC: "Zoom increment (in percentage points) for actions like mouse wheel zoom. Smaller values give finer control but may require excessive scrolling. Default: 5%.",
|
||||
ZOOM_MIN_NAME: "Minimum zoom",
|
||||
ZOOM_MIN_DESC: "How far you can zoom out (fit more of the drawing on screen). Default: 10%. Values below 10% were historically unstable—lower with caution and reset to 10% if issues occur.",
|
||||
ZOOM_MAX_NAME: "Maximum zoom",
|
||||
ZOOM_MAX_DESC: "Upper zoom limit. Default: 3000%. Usually no need to change; included for completeness.",
|
||||
PEN_HEAD: "Pen",
|
||||
GRID_HEAD: "Grid",
|
||||
GRID_DYNAMIC_COLOR_NAME: "Dynamic grid color",
|
||||
@@ -904,6 +914,10 @@ FILENAME_HEAD: "Filename",
|
||||
SCRIPT_EXECUTION_ERROR:
|
||||
"Script execution error. Please find error message on the developer console.",
|
||||
|
||||
//ExcalidrawViewUtils.ts
|
||||
MARKER_FRAME_RENDERING_DISABLED_NOTICE: "There are hidden marker-frames in the scene.",
|
||||
//DRAWING_HAS_BACK_OF_THE_CARD: "There are notes on the back of this drawing.",
|
||||
|
||||
//ExcalidrawData.ts
|
||||
LOAD_FROM_BACKUP: "Excalidraw file was corrupted. Loading from backup file.",
|
||||
FONT_LOAD_SLOW: "Loading Fonts...\n\n This is taking longer than expected. If this delay occurs regularly then you may download the fonts locally to your Vault. \n\n" +
|
||||
|
||||
@@ -419,7 +419,8 @@ FILENAME_HEAD: "Nombre de archivo",
|
||||
SHOW_DRAWING_OR_MD_IN_HOVER_PREVIEW_DESC:
|
||||
"...incluso si el archivo tiene la clave frontmatter <b>excalidraw-open-md: true</b>.<br>" +
|
||||
"Cuando esta configuración está desactivada y el archivo está configurado para abrirse en Markdown por defecto, " +
|
||||
"la vista previa al pasar el mouse mostrará el lado Markdown del documento.",
|
||||
"la vista previa al pasar el mouse mostrará el lado Markdown del documento.<br>" +
|
||||
"Nota: <b>excalidraw-open-md</b> es diferente de <b>excalidraw-embed-md</b>. Si <b>excalidraw-embed-md</b> está establecido en true, a vista previa al pasar el mouse siempre mostrará el lado Markdown, sin importar esta configuración. Para forzar la renderización de la imagen al incrustar, usa <code>![[drawing#^as-image]]</code> en tu archivo Markdown.",
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_NAME: "Renderizar como imagen en el modo de lectura Markdown de un archivo de Excalidraw",
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_DESC:
|
||||
"Cuando estás en modo de lectura Markdown (es decir, leyendo el reverso del bosquejo), ¿debe renderizarse el bosquejo de Excalidraw como una imagen? " +
|
||||
@@ -458,6 +459,12 @@ FILENAME_HEAD: "Nombre de archivo",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_NAME: "Nivel máximo de zoom para ajustar",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_DESC:
|
||||
"Establece el nivel máximo al que el zoom para encajar agrandará el bosquejo. El mínimo es 0.5 (50%) y el máximo es 10 (1000%).",
|
||||
ZOOM_STEP_NAME: "Incremento del zoom",
|
||||
ZOOM_STEP_DESC: "Incremento del zoom (en puntos porcentuales) para acciones como el zoom con la rueda del ratón. Valores más pequeños dan un control más preciso, pero pueden requerir un desplazamiento excesivo. Predeterminado: 5%.",
|
||||
ZOOM_MIN_NAME: "Zoom mínimo",
|
||||
ZOOM_MIN_DESC: "Qué tanto puedes alejarte con el zoom (para que quepa más del bosquejo en la pantalla). Predeterminado: 10%. Históricamente, los valores por debajo del 10% eran inestables; bájalo con precaución y restablece a 10% si surgen problemas.",
|
||||
ZOOM_MAX_NAME: "Zoom máximo",
|
||||
ZOOM_MAX_DESC: "Límite superior del zoom. Predeterminado: 3000%. Por lo general, no es necesario cambiarlo; se incluye para ser exhaustivos.",
|
||||
PEN_HEAD: "Lápiz",
|
||||
GRID_HEAD: "Cuadrícula",
|
||||
GRID_DYNAMIC_COLOR_NAME: "Color de cuadrícula dinámica",
|
||||
|
||||
@@ -58,6 +58,10 @@ export default {
|
||||
NEW_IN_POPOUT_WINDOW_EMBED: "新建绘图 - 于新窗口 - 并将其嵌入(形如 ![[drawing]])到当前 Markdown 文档中",
|
||||
TOGGLE_LOCK: "文本元素:原文模式(RAW)⟺ 预览模式(PREVIEW)",
|
||||
DELETE_FILE: "从库中删除所选图像(或以图像形式嵌入绘图中的 Markdown)的源文件",
|
||||
MARKER_FRAME_SHOW: "显示标记框架",
|
||||
MARKER_FRAME_HIDE: "隐藏标记框架",
|
||||
MARKER_FRAME_TITLE_SHOW: "显示标记框架标题",
|
||||
MARKER_FRAME_TITLE_HIDE: "隐藏标记框架标题",
|
||||
COPY_ELEMENT_LINK: "复制所选元素的链接(形如 [[file#^id]])",
|
||||
COPY_DRAWING_LINK: "复制绘图的嵌入链接(形如 ![[drawing]])",
|
||||
INSERT_LINK_TO_ELEMENT:
|
||||
@@ -344,7 +348,7 @@ export default {
|
||||
"当 Obsidian 应用内的焦点离开活动文档(如关闭工作空间、点击菜单栏、切换到其他页签或面板等)的时候,也会触发自动保存。" +
|
||||
"直接退出 Obsidian 应用(在应用切换器中划掉)不会触发自动保存。此外,当您切换到其他应用时,有时候" +
|
||||
"系统会自动清理 Obsidian 后台以释放资源。这种情况下,自动保存会失效。",
|
||||
FILENAME_HEAD: "文件名",
|
||||
FILENAME_HEAD: "文件名",
|
||||
FILENAME_DESC:
|
||||
"<p>点击阅读" +
|
||||
"<a href='https://momentjs.com/docs/#/displaying/format/'>日期和时间格式参考</a>。</p>",
|
||||
@@ -419,7 +423,8 @@ FILENAME_HEAD: "文件名",
|
||||
SHOW_DRAWING_OR_MD_IN_HOVER_PREVIEW_DESC:
|
||||
"...即使文件具有 `<b>excalidraw-open-md: true</b>` frontmatter 属性。<br>" +
|
||||
"当此设置关闭且文件默认设置为以 md 格式打开时,悬停预览将显示文档的 Markdown 部分(背景笔记)。" +
|
||||
"",
|
||||
"<br>" +
|
||||
"注意:<b>excalidraw-open-md</b> 与 <b>excalidraw-embed-md</b> 是不同的。如果 <b>excalidraw-embed-md</b> 设置为 true,则悬停预览始终显示 markdown 部分,而不受此设置影响。要在嵌入时强制图像渲染,请在你的 markdown 文件中使用 <code>![[drawing#^as-image]]</code>。" ,
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_NAME: "Excalidraw 文件在 Markdown 阅读模式下渲染为图片",
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_DESC:
|
||||
"当您处于 Markdown 阅读模式(即查看绘图的背景笔记)时,Excalidraw 绘图是否应该渲染为图像?" +
|
||||
@@ -458,6 +463,12 @@ FILENAME_HEAD: "文件名",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_NAME: "自动缩放的最高级别",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_DESC:
|
||||
"自动缩放画布时,允许放大的最高级别。该值不能低于 0.5(50%)且不能超过 10(1000%)。",
|
||||
ZOOM_STEP_NAME : "缩放增量" ,
|
||||
ZOOM_STEP_DESC : "用于鼠标滚轮缩放等操作的缩放增量(以百分比为单位)。值越小,控制越精细,但可能需要过多滚动。默认值:5%。" ,
|
||||
ZOOM_MIN_NAME : "最小缩放" ,
|
||||
ZOOM_MIN_DESC : "屏幕上可缩小到的最小比例(显示更多绘图内容)。默认值:10%。历史上低于 10% 的值可能会导致不稳定问题,建议谨慎调整,并在出现问题时重置为 10%。" ,
|
||||
ZOOM_MAX_NAME : "最大缩放" ,
|
||||
ZOOM_MAX_DESC : "缩放的上限值。默认值:3000%。通常不需要修改,仅供完整性考虑而设置。" ,
|
||||
PEN_HEAD: "手写笔",
|
||||
GRID_HEAD: "网格",
|
||||
GRID_DYNAMIC_COLOR_NAME: "动态网格颜色",
|
||||
|
||||
+169
-162
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
DEVICE,
|
||||
FRONTMATTER_KEYS,
|
||||
CJK_FONTS
|
||||
CJK_FONTS,
|
||||
} from "src/constants/constants";
|
||||
import { TAG_AUTOEXPORT, TAG_MDREADINGMODE, TAG_PDFEXPORT } from "src/constants/constSettingsTags";
|
||||
import { labelALT, labelCTRL, labelMETA, labelSHIFT } from "src/utils/modifierkeyHelper";
|
||||
@@ -104,14 +104,14 @@ export default {
|
||||
RESET_IMG_ASPECT_RATIO: "重置所選影像元素的縱橫比",
|
||||
TEMPORARY_DISABLE_AUTOSAVE: "臨時停用自動儲存功能,直到本次 Obsidian 退出(小白慎用!)",
|
||||
TEMPORARY_ENABLE_AUTOSAVE: "啟用自動儲存功能",
|
||||
FONTS_LOADED : "Excalidraw: CJK 字型已載入" ,
|
||||
FONTS_LOAD_ERROR : "Excalidraw: 在資原始檔夾下找不到 CJK 字型\n" ,
|
||||
FONTS_LOADED: "Excalidraw: CJK 字型已載入",
|
||||
FONTS_LOAD_ERROR: "Excalidraw: 在資原始檔夾下找不到 CJK 字型\n",
|
||||
|
||||
//Prompt.ts
|
||||
SELECT_LINK_TO_OPEN: "選擇要開啟的連結",
|
||||
|
||||
//ExcalidrawView.ts
|
||||
ERROR_CANT_READ_FILEPATH : "錯誤,無法讀取檔案路徑。正在改為匯入檔案",
|
||||
ERROR_CANT_READ_FILEPATH: "錯誤,無法讀取檔案路徑。正在改為匯入檔案",
|
||||
NO_SEARCH_RESULT: "在繪圖中未找到匹配的元素",
|
||||
FORCE_SAVE_ABORTED: "自動儲存被中止,因為檔案正在儲存中",
|
||||
LINKLIST_SECOND_ORDER_LINK: "二級連結",
|
||||
@@ -158,11 +158,11 @@ export default {
|
||||
CONVERT_FILE: "轉換為新格式",
|
||||
BACKUP_AVAILABLE: "載入繪圖檔案時出錯,可能是由於 Obsidian 在上次儲存時意外退出了(手機上更容易發生這種意外)。<br><br><b>好訊息:</b>這臺裝置上存在備份。您是否想要恢復本裝置上的備份?<br><br>(我建議您先嚐試在最近使用過的其他裝置上開啟該繪圖,以檢查是否有更新的備份。)",
|
||||
BACKUP_RESTORED: "已恢復備份",
|
||||
BACKUP_SAVE_AS_FILE : "此繪圖為空。存在一個非空的備份。您是否希望將其恢復為新檔案並在新標籤頁中開啟?" ,
|
||||
BACKUP_SAVE : "恢復" ,
|
||||
BACKUP_DELETE : "刪除備份" ,
|
||||
BACKUP_CANCEL : "取消" ,
|
||||
CACHE_NOT_READY : "很抱歉給您帶來不便,載入檔案時發生了錯誤。<br><br><mark>稍作等待可能會節省您大量時間……</mark><br><br>外掛有一個備份快取,但似乎您剛剛啟動了 Obsidian。初始化備份快取可能需要一些時間,通常取決於裝置效能,可能需要一分鐘或更長時間。當快取初始化完成時,您會在右上角收到通知。<br><br>請按“確定”嘗試重新載入檔案,並檢查快取是否已完成初始化。如果在此訊息後看到一個完全空白的檔案,我建議等待備份快取準備就緒後再繼續操作。或者,您也可以選擇“取消”以手動修復您的檔案。<br>" ,
|
||||
BACKUP_SAVE_AS_FILE: "此繪圖為空。存在一個非空的備份。您是否希望將其恢復為新檔案並在新標籤頁中開啟?",
|
||||
BACKUP_SAVE: "恢復",
|
||||
BACKUP_DELETE: "刪除備份",
|
||||
BACKUP_CANCEL: "取消",
|
||||
CACHE_NOT_READY: "很抱歉給您帶來不便,載入檔案時發生了錯誤。<br><br><mark>稍作等待可能會節省您大量時間……</mark><br><br>外掛有一個備份快取,但似乎您剛剛啟動了 Obsidian。初始化備份快取可能需要一些時間,通常取決於裝置效能,可能需要一分鐘或更長時間。當快取初始化完成時,您會在右上角收到通知。<br><br>請按“確定”嘗試重新載入檔案,並檢查快取是否已完成初始化。如果在此訊息後看到一個完全空白的檔案,我建議等待備份快取準備就緒後再繼續操作。或者,您也可以選擇“取消”以手動修復您的檔案。<br>",
|
||||
OBSIDIAN_TOOLS_PANEL: "Obsidian 工具面板",
|
||||
ERROR_SAVING_IMAGE: "獲取影像時發生未知錯誤。可能是由於某種原因,影像不可用或拒絕了 Obsidian 的獲取請求。",
|
||||
WARNING_PASTING_ELEMENT_AS_TEXT: "你不能將 Excalidraw 元素貼上為文字元素!",
|
||||
@@ -194,18 +194,18 @@ export default {
|
||||
|
||||
//ContentSearcher.ts
|
||||
SEARCH_COPIED_TO_CLIPBOARD: "Markdown 已複製到剪貼簿",
|
||||
SEARCH_COPY_TO_CLIPBOARD_ARIA: "將整個對話框複製為 Markdown 到剪貼簿。非常適合搭配 ChatGPT 等工具進行搜尋和理解。",
|
||||
SEARCH_SHOWHIDE_ARIA : "顯示/隱藏搜尋欄" ,
|
||||
SEARCH_COPY_TO_CLIPBOARD_ARIA: "將整個對話方塊複製為 Markdown 到剪貼簿。非常適合搭配 ChatGPT 等工具進行搜尋和理解。",
|
||||
SEARCH_SHOWHIDE_ARIA: "顯示/隱藏搜尋欄",
|
||||
SEARCH_NEXT: "下一個",
|
||||
SEARCH_PREVIOUS: "上一個",
|
||||
|
||||
|
||||
|
||||
//settings.ts
|
||||
NOTEBOOKLM_LINK_ARIA : "向 NotebookLM 諮詢有關外掛的幫助。此模型已預載入我的所有影片轉錄、發佈說明以及其他有用內容。與 NotebookLM 聊天,探索我的 250+ 影片以及 Excalidraw 文件。" ,
|
||||
NOTEBOOKLM_LINK_TEXT : "瞭解外掛。訪問 NotebookLM 知識庫。" ,
|
||||
LINKS_BUGS_ARIA: "在外掛的 GitHub 頁面回報錯誤和提交功能請求",
|
||||
LINKS_BUGS: "回報錯誤",
|
||||
NOTEBOOKLM_LINK_ARIA: "向 NotebookLM 諮詢有關外掛的幫助。此模型已預載入我的所有影片轉錄、釋出說明以及其他有用內容。與 NotebookLM 聊天,探索我的 250+ 影片以及 Excalidraw 文件。",
|
||||
NOTEBOOKLM_LINK_TEXT: "瞭解外掛。訪問 NotebookLM 知識庫。",
|
||||
LINKS_BUGS_ARIA: "在外掛的 GitHub 頁面報告錯誤和提交功能請求",
|
||||
LINKS_BUGS: "報告錯誤",
|
||||
LINKS_YT_ARIA: "訪問我的 YouTube 頻道學習視覺思維和 Excalidraw",
|
||||
LINKS_YT: "在 YouTube 學習",
|
||||
LINKS_DISCORD_ARIA: "加入視覺思維研討會 Discord 伺服器",
|
||||
@@ -215,8 +215,8 @@ export default {
|
||||
LINKS_VTW: "參加研討會",
|
||||
LINKS_BOOK_ARIA: "閱讀我的視覺思維著作《Sketch Your Mind》",
|
||||
LINKS_BOOK: "閱讀書籍",
|
||||
LINKS_WIKI : "外掛 Wiki" ,
|
||||
LINKS_WIKI_ARIA : "探索 Excalidraw 外掛 Wiki" ,
|
||||
LINKS_WIKI: "外掛 Wiki",
|
||||
LINKS_WIKI_ARIA: "探索 Excalidraw 外掛 Wiki",
|
||||
|
||||
RELEASE_NOTES_NAME: "顯示更新說明",
|
||||
RELEASE_NOTES_DESC:
|
||||
@@ -232,22 +232,22 @@ export default {
|
||||
FOLDER_NAME: "Excalidraw 資料夾(區分大小寫!)",
|
||||
FOLDER_DESC:
|
||||
"新繪圖的預設儲存路徑。若為空,將在庫的根目錄中建立新繪圖。",
|
||||
CROP_SUFFIX_NAME : "裁剪檔案字尾" ,
|
||||
CROP_SUFFIX_DESC :
|
||||
CROP_SUFFIX_NAME: "裁剪檔案字尾",
|
||||
CROP_SUFFIX_DESC:
|
||||
"為裁剪影像時建立的新圖紙檔名的最後部分。" +
|
||||
"如果不需要字尾,請留空。" ,
|
||||
"如果不需要字尾,請留空。",
|
||||
CROP_PREFIX_NAME: "剪貼檔案的字首",
|
||||
CROP_PREFIX_DESC:
|
||||
"當剪貼圖片進來時儲存的檔名的字首。 " +
|
||||
"如果不需要字首,請留空。" ,
|
||||
ANNOTATE_SUFFIX_NAME : "註釋檔案字尾" ,
|
||||
ANNOTATE_SUFFIX_DESC :
|
||||
"當剪貼圖片進來時儲存的檔名的字首。" +
|
||||
"如果不需要字首,請留空。",
|
||||
ANNOTATE_SUFFIX_NAME: "註釋檔案字尾",
|
||||
ANNOTATE_SUFFIX_DESC:
|
||||
"為註釋影像時建立的新繪圖檔名的最後部分。" +
|
||||
"如果不需要字尾,請留空。" ,
|
||||
"如果不需要字尾,請留空。",
|
||||
ANNOTATE_PREFIX_NAME: "標註檔案的字首",
|
||||
ANNOTATE_PREFIX_DESC:
|
||||
"在標註影像時建立新繪圖的檔名的第一部分。" +
|
||||
"如果不需要字首,請留空。" ,
|
||||
"如果不需要字首,請留空。",
|
||||
ANNOTATE_PRESERVE_SIZE_NAME: "在標註時保留影像尺寸",
|
||||
ANNOTATE_PRESERVE_SIZE_DESC:
|
||||
"當在 Markdown 中標註影像時,替換後的影像連結將包含原始影像的寬度。",
|
||||
@@ -284,8 +284,8 @@ export default {
|
||||
`目前 OpenAI API 還處於測試中,您需要在自己的。` +
|
||||
`OpenAI 賬戶中充值至少 5 美元后才能生成 API key,` +
|
||||
`然後就可以在 Excalidraw 中配置並使用 AI。`,
|
||||
AI_ENABLED_NAME : "啟用 AI 功能" ,
|
||||
AI_ENABLED_DESC : "您需要重新開啟 Excalidraw 才能使更改生效。" ,
|
||||
AI_ENABLED_NAME: "啟用 AI 功能",
|
||||
AI_ENABLED_DESC: "您需要重新開啟 Excalidraw 才能使更改生效。",
|
||||
AI_OPENAI_TOKEN_NAME: "OpenAI API key",
|
||||
AI_OPENAI_TOKEN_DESC:
|
||||
"您可以訪問您的<a href='https://platform.openai.com/api-keys'> OpenAI 賬戶</a>來獲取自己的 OpenAI API key。",
|
||||
@@ -344,7 +344,7 @@ export default {
|
||||
"當 Obsidian 應用內的焦點離開活動文件(如關閉工作空間、點選選單欄、切換到其他頁籤或面板等)的時候,也會觸發自動儲存。" +
|
||||
"直接退出 Obsidian 應用(在應用切換器中劃掉)不會觸發自動儲存。此外,當您切換到其他應用時,有時候" +
|
||||
"系統會自動清理 Obsidian 後臺以釋放資源。這種情況下,自動儲存會失效。",
|
||||
FILENAME_HEAD: "檔名",
|
||||
FILENAME_HEAD: "檔名",
|
||||
FILENAME_DESC:
|
||||
"<p>點選閱讀" +
|
||||
"<a href='https://momentjs.com/docs/#/displaying/format/'>日期和時間格式參考</a>。</p>",
|
||||
@@ -371,11 +371,11 @@ FILENAME_HEAD: "檔名",
|
||||
"<b>開啟:</b>使用 .excalidraw.md 作為副檔名。<br><b>關閉:</b>使用 .md 作為副檔名。",
|
||||
DISPLAY_HEAD: "介面 & 行為",
|
||||
DISPLAY_DESC: "在 Excalidraw 設定的 '外觀和行為' 部分,您可以微調 Excalidraw 的外觀和行為。這包括動態樣式、左手模式、匹配 Excalidraw 和 Obsidian 主題、預設模式等選項。",
|
||||
OVERRIDE_OBSIDIAN_FONT_SIZE_NAME : "限制 Obsidian 字型大小為編輯器文字" ,
|
||||
OVERRIDE_OBSIDIAN_FONT_SIZE_NAME: "限制 Obsidian 字型大小為編輯器文字",
|
||||
OVERRIDE_OBSIDIAN_FONT_SIZE_DESC :
|
||||
"Obsidian 的自定義字型大小設定會影響整個介面,包括 Excalidraw 和依賴預設字型大小的主題。" +
|
||||
"啟用此選項將限制字型大小更改為編輯器文字,這將改善 Excalidraw 的外觀。" +
|
||||
"如果啟用後發現介面的某些部分看起來不正確,請嘗試關閉此設定。" ,
|
||||
"如果啟用後發現介面的某些部分看起來不正確,請嘗試關閉此設定。",
|
||||
DYNAMICSTYLE_NAME: "動態樣式",
|
||||
DYNAMICSTYLE_DESC:
|
||||
"根據畫布顏色自動調節 Excalidraw 介面顏色",
|
||||
@@ -408,7 +408,7 @@ FILENAME_HEAD: "檔名",
|
||||
DEFAULT_PEN_MODE_NAME: "觸控筆模式(Pen mode)",
|
||||
DEFAULT_PEN_MODE_DESC:
|
||||
"開啟繪圖時,是否自動開啟觸控筆模式?",
|
||||
ENABLE_DOUBLE_CLICK_TEXT_EDITING_NAME : "啟用雙擊文字建立",
|
||||
ENABLE_DOUBLE_CLICK_TEXT_EDITING_NAME: "啟用雙擊文字建立",
|
||||
DISABLE_DOUBLE_TAP_ERASER_NAME: "啟用手寫模式下的雙擊橡皮擦功能",
|
||||
DISABLE_SINGLE_FINGER_PANNING_NAME: "啟用手寫模式下的單指平移功能",
|
||||
SHOW_PEN_MODE_FREEDRAW_CROSSHAIR_NAME: "在觸控筆模式下顯示十字準星(+)",
|
||||
@@ -419,14 +419,15 @@ FILENAME_HEAD: "檔名",
|
||||
SHOW_DRAWING_OR_MD_IN_HOVER_PREVIEW_DESC:
|
||||
"...即使檔案具有 `<b>excalidraw-open-md: true</b>` frontmatter 屬性。<br>" +
|
||||
"當此設定關閉且檔案預設設定為以 md 格式開啟時,懸停預覽將顯示文件的 Markdown 部分(背景筆記)。" +
|
||||
"",
|
||||
"<br>" +
|
||||
"注意:<b>excalidraw-open-md</b> 與 <b>excalidraw-embed-md</b> 是不同的。如果 <b>excalidraw-embed-md</b> 設定為 true,則懸停預覽始終顯示 markdown 部分,而不受此設定影響。要在嵌入時強制影像渲染,請在你的 markdown 檔案中使用 <code>![[drawing#^as-image]]</code>。",
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_NAME: "Excalidraw 檔案在 Markdown 閱讀模式下渲染為圖片",
|
||||
SHOW_DRAWING_OR_MD_IN_READING_MODE_DESC:
|
||||
"當您處於 Markdown 閱讀模式(即檢視繪圖的背景筆記)時,Excalidraw 繪圖是否應該渲染為影像?" +
|
||||
"此設定不會影響您在 Excalidraw 模式下的繪圖顯示,或者在將繪圖嵌入 Markdown 文件時,或在渲染懸停預覽時。<br><ul>" +
|
||||
"<li>請參閱下面‘嵌入和匯出’部分的 <a href='#"+TAG_PDFEXPORT+"'>PDF 匯出</a> 相關設定。</li></ul><br>" +
|
||||
"您必須關閉當前的 Excalidraw/Markdown 檔案並重新開啟,以使此更改生效。",
|
||||
SHOW_DRAWING_OR_MD_IN_EXPORTPDF_NAME : "在 Obsidian 中匯出為 PDF 格式時將 Excalidraw 渲染為影像" ,
|
||||
SHOW_DRAWING_OR_MD_IN_EXPORTPDF_NAME: "在 Obsidian 中匯出為 PDF 格式時將 Excalidraw 渲染為影像",
|
||||
SHOW_DRAWING_OR_MD_IN_EXPORTPDF_DESC:
|
||||
"此設定控制在使用 Obsidian 內建的<b>匯出為 PDF</b>功能,如何將 Excalidraw 檔案匯出為 PDF。<br>" +
|
||||
"<ul><li><b>啟用:</b>PDF 將包含影像格式的 Excalidraw 繪圖。</li>" +
|
||||
@@ -458,6 +459,12 @@ FILENAME_HEAD: "檔名",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_NAME: "自動縮放的最高級別",
|
||||
ZOOM_TO_FIT_MAX_LEVEL_DESC:
|
||||
"自動縮放畫布時,允許放大的最高級別。該值不能低於 0.5(50%)且不能超過 10(1000%)。",
|
||||
ZOOM_STEP_NAME: "縮放增量",
|
||||
ZOOM_STEP_DESC: "用於滑鼠滾輪縮放等操作的縮放增量(以百分比為單位)。值越小,控制越精細,但可能需要過多滾動。預設值:5%。",
|
||||
ZOOM_MIN_NAME: "最小縮放",
|
||||
ZOOM_MIN_DESC: "螢幕上可縮小到的最小比例(顯示更多繪圖內容)。預設值:10%。歷史上低於 10% 的值可能會導致不穩定問題,建議謹慎調整,並在出現問題時重置為 10%。",
|
||||
ZOOM_MAX_NAME: "最大縮放",
|
||||
ZOOM_MAX_DESC: "縮放的上限值。預設值:3000%。通常不需要修改,僅供完整性考慮而設定。",
|
||||
PEN_HEAD: "手寫筆",
|
||||
GRID_HEAD: "網格",
|
||||
GRID_DYNAMIC_COLOR_NAME: "動態網格顏色",
|
||||
@@ -467,10 +474,10 @@ FILENAME_HEAD: "檔名",
|
||||
GRID_OPACITY_NAME: "網格透明度",
|
||||
GRID_OPACITY_DESC: "網格透明度還將控制將箭頭繫結到元素時繫結框的透明度。<br>"+
|
||||
"設定網格的不透明度。 0 表示完全透明,100 表示完全不透明。",
|
||||
GRID_DIRECTION_NAME : "網格方向" ,
|
||||
GRID_DIRECTION_DESC : "第一個開關顯示/隱藏水平網格,第二個開關顯示/隱藏垂直網格。" ,
|
||||
GRID_HORIZONTAL : "渲染水平網格" ,
|
||||
GRID_VERTICAL : "渲染垂直網格" ,
|
||||
GRID_DIRECTION_NAME: "網格方向",
|
||||
GRID_DIRECTION_DESC: "第一個開關顯示/隱藏水平網格,第二個開關顯示/隱藏垂直網格。",
|
||||
GRID_HORIZONTAL: "渲染水平網格",
|
||||
GRID_VERTICAL: "渲染垂直網格",
|
||||
LASER_HEAD: "雷射筆工具(更多工具 > 雷射筆)",
|
||||
LASER_COLOR: "雷射筆顏色",
|
||||
LASER_DECAY_TIME_NAME: "雷射筆消失時間",
|
||||
@@ -625,11 +632,11 @@ FILENAME_HEAD: "檔名",
|
||||
EMBED_CANVAS_DESC:
|
||||
"當嵌入繪圖到 Obsidian 白板中時,隱藏元素的邊界和背景。" +
|
||||
"注意:如果想要背景完全透明,您依然需要在 Excalidraw 中設定“匯出的影像不包含背景”。",
|
||||
EMBED_CACHING : "影像快取和渲染最佳化" ,
|
||||
RENDERING_CONCURRENCY_NAME : "影像渲染併發性" ,
|
||||
EMBED_CACHING: "影像快取和渲染最佳化",
|
||||
RENDERING_CONCURRENCY_NAME: "影像渲染併發性",
|
||||
RENDERING_CONCURRENCY_DESC :
|
||||
"用於影像渲染的並行工作執行緒數。增加此數值可以加快渲染速度,但可能會減慢系統的其他部分執行速度。" +
|
||||
"預設值為 3。如果您的系統性能強大,可以增加此數值。" ,
|
||||
"預設值為 3。如果您的系統性能強大,可以增加此數值。",
|
||||
EXPORT_SUBHEAD: "匯出",
|
||||
EMBED_SIZING: "影像尺寸",
|
||||
EMBED_THEME_BACKGROUND: "影像的主題和背景色",
|
||||
@@ -706,7 +713,7 @@ FILENAME_HEAD: "檔名",
|
||||
EXPORT_EMBED_SCENE_DESC:
|
||||
"在匯出的影像中嵌入 Excalidraw 場景。可以透過在檔案級別新增 <code>excalidraw-export-embed-scene: true/false</code> frontmatter 元資料鍵來覆蓋此設定。" +
|
||||
"此設定僅在您下次(重新)開啟繪圖時生效。",
|
||||
PDF_EXPORT_SETTINGS : "PDF 匯出設定",
|
||||
PDF_EXPORT_SETTINGS: "PDF 匯出設定",
|
||||
EXPORT_HEAD: "匯出設定",
|
||||
EXPORT_SYNC_NAME:
|
||||
"保持 SVG/PNG 檔名與繪圖檔案同步",
|
||||
@@ -734,7 +741,7 @@ FILENAME_HEAD: "檔名",
|
||||
"<mark>最好的方法是避免使用不同的外掛對 Excalidraw 文件進行自動更改。</mark><br>" +
|
||||
"如果出於某些合理的原因,您決定忽略我的建議並配置了 Excalidraw 檔案的自動程式碼格式化,那麼可以使用這個設定<br> " +
|
||||
"<code>## Text Elements</code> 部分對空行很敏感。一種常見的程式碼格式化是在章節標題後新增一個空行。但對於 Excalidraw 來說,這將破壞/改變您繪圖中的第一個文字元素。" +
|
||||
"為了解決這個問題,您可以啟用這個設定。啟用後 Excalidraw 將在 <code>## Text Elements</code> 的開頭新增一個虛擬元素,供自動程式碼格式化工具修改。" ,
|
||||
"為了解決這個問題,您可以啟用這個設定。啟用後 Excalidraw 將在 <code>## Text Elements</code> 的開頭新增一個虛擬元素,供自動程式碼格式化工具修改。",
|
||||
PRESERVE_TEXT_AFTER_DRAWING_NAME: "Zotero 和腳註(footnotes)的相容性",
|
||||
PRESERVE_TEXT_AFTER_DRAWING_DESC: "保留 Markdown 檔案中 <code>## Drawing</code> 部分之後的文字內容。儲存非常大的繪圖時,這可能會造成微小的效能影響。",
|
||||
DEBUGMODE_NAME: "開啟 debug 資訊",
|
||||
@@ -766,8 +773,8 @@ FILENAME_HEAD: "檔名",
|
||||
"更改此選項後,您可能需要重啟 Obsidian 來使其生效。",
|
||||
LATEX_DEFAULT_NAME: "插入 LaTeX 時的預設表示式",
|
||||
LATEX_DEFAULT_DESC: "允許留空。允許使用類似 <code>\\color{white}</code> 的格式化表示式。",
|
||||
LATEX_PREAMBLE_NAME : "LaTeX 前言檔案(區分大小寫!)" ,
|
||||
LATEX_PREAMBLE_DESC : "前言檔案的完整路徑,留空則使用預設值。如果檔案不存在,此選項將被忽略。<br><strong>重要:</strong>更改後需要重新載入 Obsidian 才能生效!" ,
|
||||
LATEX_PREAMBLE_NAME: "LaTeX 前言檔案(區分大小寫!)",
|
||||
LATEX_PREAMBLE_DESC: "前言檔案的完整路徑,留空則使用預設值。如果檔案不存在,此選項將被忽略。<br><strong>重要:</strong>更改後需要重新載入 Obsidian 才能生效!",
|
||||
NONSTANDARD_HEAD: "非 Excalidraw.com 官方支援的特性",
|
||||
NONSTANDARD_DESC: `這些特性不受 Excalidraw.com 官方支援。如果在 Excalidraw.com 匯入繪圖,這些特性將會發生不可預知的變化。
|
||||
包括:自定義畫筆工具的數量,自定義字型等。`,
|
||||
@@ -947,12 +954,12 @@ FILENAME_HEAD: "檔名",
|
||||
|
||||
//IFrameActionsMenu.tsx
|
||||
NARROW_TO_HEADING: "縮放至標題",
|
||||
PIN_VIEW: "釘選視圖",
|
||||
DO_NOT_PIN_VIEW: "取消釘選視圖",
|
||||
PIN_VIEW: "鎖定檢視",
|
||||
DO_NOT_PIN_VIEW: "取消鎖定檢視",
|
||||
NARROW_TO_BLOCK: "縮放至塊",
|
||||
SHOW_ENTIRE_FILE: "顯示全部",
|
||||
SELECT_SECTION: "從文件選擇區塊",
|
||||
SELECT_VIEW: "從基礎選擇視圖",
|
||||
SELECT_SECTION: "從文件選擇章節",
|
||||
SELECT_VIEW: "從 base 選擇檢視",
|
||||
ZOOM_TO_FIT: "縮放至合適大小",
|
||||
RELOAD: "過載連結",
|
||||
OPEN_IN_BROWSER: "在瀏覽器中開啟",
|
||||
@@ -968,8 +975,8 @@ FILENAME_HEAD: "檔名",
|
||||
ES_YOUTUBE_START_INVALID: "YouTube 起始時間無效。請檢查格式並重試",
|
||||
ES_FILENAME_VISIBLE: "顯示檔名",
|
||||
ES_BACKGROUND_HEAD: "背景色",
|
||||
ES_BACKGROUND_DESC_INFO : "點選此處瞭解更多顏色資訊" ,
|
||||
ES_BACKGROUND_DESC_DETAIL : "背景顏色僅影響 Markdown 嵌入預覽模式。在編輯模式下,它會根據場景(透過文件屬性設定)或外掛設定,遵循 Obsidian 的淺色/深色主題。背景顏色有兩層:元素背景顏色(下層)和上層顏色。選擇“匹配元素背景”意味著兩層都遵循元素顏色。選擇“匹配畫布”或特定背景顏色時,保留元素背景層。設定透明度(例如 50%)會將畫布或選定的顏色與元素背景顏色混合。要移除元素背景層,可以在 Excalidraw 的元素屬性編輯器中將元素顏色設定為透明,這樣只有上層顏色生效。" ,
|
||||
ES_BACKGROUND_DESC_INFO: "點選此處瞭解更多顏色資訊",
|
||||
ES_BACKGROUND_DESC_DETAIL: "背景顏色僅影響 Markdown 嵌入預覽模式。在編輯模式下,它會根據場景(透過文件屬性設定)或外掛設定,遵循 Obsidian 的淺色/深色主題。背景顏色有兩層:元素背景顏色(下層)和上層顏色。選擇“匹配元素背景”意味著兩層都遵循元素顏色。選擇“匹配畫布”或特定背景顏色時,保留元素背景層。設定透明度(例如 50%)會將畫布或選定的顏色與元素背景顏色混合。要移除元素背景層,可以在 Excalidraw 的元素屬性編輯器中將元素顏色設定為透明,這樣只有上層顏色生效。",
|
||||
ES_BACKGROUND_MATCH_ELEMENT: "匹配元素背景色",
|
||||
ES_BACKGROUND_MATCH_CANVAS: "匹配畫布背景色",
|
||||
ES_BACKGROUND_COLOR: "背景色",
|
||||
@@ -1002,7 +1009,7 @@ FILENAME_HEAD: "檔名",
|
||||
PROMPT_BUTTON_INSERT_SPACE: "插入空格",
|
||||
PROMPT_BUTTON_INSERT_LINK: "插入內部連結",
|
||||
PROMPT_BUTTON_UPPERCASE: "大寫",
|
||||
PROMPT_BUTTON_SPECIAL_CHARS : "特殊字元" ,
|
||||
PROMPT_BUTTON_SPECIAL_CHARS: "特殊字元",
|
||||
PROMPT_SELECT_TEMPLATE: "選擇一個模板",
|
||||
|
||||
//ModifierKeySettings
|
||||
@@ -1035,124 +1042,124 @@ FILENAME_HEAD: "檔名",
|
||||
SCRIPT_UPDATES_AVAILABLE : `指令碼更新可用 - 請檢查指令碼儲存。\n\n ${ DEVICE . isDesktop ? `此訊息可在控制檯日誌中檢視 ( ${ DEVICE . isMacOS ? "CMD+OPT+i" : "CTRL+SHIFT+i" } )\n\n` : "" } 如果您已將指令碼組織到指令碼儲存資料夾下的子資料夾中,並且存在同一指令碼的多個副本,可能需要清理未使用的版本以消除此警報。對於不需要更新的私人指令碼副本,請將它們儲存在指令碼儲存資料夾之外。` ,
|
||||
ERROR_PNG_TOO_LARGE: "匯出 PNG 時出錯 - PNG 檔案過大,請嘗試較小的解析度",
|
||||
|
||||
// ModifierkeyHelper.ts
|
||||
//modifierkeyHelper.ts
|
||||
// WebBrowserDragAction
|
||||
WEB_DRAG_IMPORT_IMAGE : "匯入圖片到 Vault" ,
|
||||
WEB_DRAG_IMAGE_URL : "透過 URL 插入圖片或 YouTube 縮圖" ,
|
||||
WEB_DRAG_LINK : "插入連結" ,
|
||||
WEB_DRAG_EMBEDDABLE : "插入互動框架" ,
|
||||
WEB_DRAG_IMPORT_IMAGE: "匯入圖片到 Vault",
|
||||
WEB_DRAG_IMAGE_URL: "透過 URL 插入圖片或 YouTube 縮圖",
|
||||
WEB_DRAG_LINK: "插入連結",
|
||||
WEB_DRAG_EMBEDDABLE: "插入互動框架",
|
||||
|
||||
// LocalFileDragAction
|
||||
LOCAL_DRAG_IMPORT : "匯入外部檔案,或在路徑來自 Vault 時複用現有檔案" ,
|
||||
LOCAL_DRAG_IMAGE : "插入圖片:使用本地 URI,或在路徑來自 Vault 時使用內部連結" ,
|
||||
LOCAL_DRAG_LINK : "插入連結:使用本地 URI,或在路徑來自 Vault 時使用內部連結" ,
|
||||
LOCAL_DRAG_EMBEDDABLE : "插入互動框架:使用本地 URI,或在路徑來自 Vault 時使用內部連結" ,
|
||||
LOCAL_DRAG_IMPORT: "匯入外部檔案,或在路徑來自 Vault 時複用現有檔案",
|
||||
LOCAL_DRAG_IMAGE: "插入圖片:使用本地 URI,或在路徑來自 Vault 時使用內部連結",
|
||||
LOCAL_DRAG_LINK: "插入連結:使用本地 URI,或在路徑來自 Vault 時使用內部連結",
|
||||
LOCAL_DRAG_EMBEDDABLE: "插入互動框架:使用本地 URI,或在路徑來自 Vault 時使用內部連結",
|
||||
|
||||
// InternalDragAction
|
||||
INTERNAL_DRAG_IMAGE : "插入圖片" ,
|
||||
INTERNAL_DRAG_IMAGE_FULL : "插入圖片(100% 尺寸)" ,
|
||||
INTERNAL_DRAG_LINK : "插入連結" ,
|
||||
INTERNAL_DRAG_EMBEDDABLE : "插入互動框架" ,
|
||||
INTERNAL_DRAG_IMAGE: "插入圖片",
|
||||
INTERNAL_DRAG_IMAGE_FULL: "插入圖片(100% 尺寸)",
|
||||
INTERNAL_DRAG_LINK: "插入連結",
|
||||
INTERNAL_DRAG_EMBEDDABLE: "插入互動框架",
|
||||
|
||||
// LinkClickAction
|
||||
LINK_CLICK_ACTIVE : "在當前活動視窗中開啟" ,
|
||||
LINK_CLICK_NEW_PANE : "在相鄰的新視窗中開啟" ,
|
||||
LINK_CLICK_POPOUT : "在彈出視窗中開啟" ,
|
||||
LINK_CLICK_NEW_TAB : "在新標籤頁中開啟" ,
|
||||
LINK_CLICK_MD_PROPS : "顯示 Markdown 圖片屬性對話方塊(僅在嵌入 Markdown 文件為圖片時適用)" ,
|
||||
LINK_CLICK_ACTIVE: "在當前活動視窗中開啟",
|
||||
LINK_CLICK_NEW_PANE: "在相鄰的新視窗中開啟",
|
||||
LINK_CLICK_POPOUT: "在彈出視窗中開啟",
|
||||
LINK_CLICK_NEW_TAB: "在新標籤頁中開啟",
|
||||
LINK_CLICK_MD_PROPS: "顯示 Markdown 圖片屬性對話方塊(僅在嵌入 Markdown 文件為圖片時適用)",
|
||||
|
||||
// 匯出對話方塊
|
||||
// 對話方塊和標籤頁
|
||||
EXPORTDIALOG_TITLE: "匯出圖形",
|
||||
EXPORTDIALOG_TAB_IMAGE: "影像",
|
||||
EXPORTDIALOG_TAB_PDF: "PDF",
|
||||
// 設定持久化
|
||||
EXPORTDIALOG_SAVE_SETTINGS: "將影像設定儲存到檔案 doc.properties 嗎?",
|
||||
EXPORTDIALOG_SAVE_SETTINGS_SAVE: "儲存為預設",
|
||||
EXPORTDIALOG_SAVE_SETTINGS_ONETIME: "僅本次使用",
|
||||
// 影像設定
|
||||
EXPORTDIALOG_IMAGE_SETTINGS: "影像",
|
||||
EXPORTDIALOG_IMAGE_DESC: "PNG 支援透明。外部檔案可以包含 Excalidraw 場景資料。",
|
||||
EXPORTDIALOG_PADDING: "邊距",
|
||||
EXPORTDIALOG_SCALE: "縮放",
|
||||
EXPORTDIALOG_CURRENT_PADDING: "當前邊距:",
|
||||
EXPORTDIALOG_SIZE_DESC: "縮放會影響輸出大小",
|
||||
EXPORTDIALOG_SCALE_VALUE: "縮放:",
|
||||
EXPORTDIALOG_IMAGE_SIZE: "大小:",
|
||||
// 主題和背景
|
||||
EXPORTDIALOG_EXPORT_THEME: "主題",
|
||||
EXPORTDIALOG_THEME_LIGHT: "淺色",
|
||||
EXPORTDIALOG_THEME_DARK: "深色",
|
||||
EXPORTDIALOG_BACKGROUND: "背景",
|
||||
EXPORTDIALOG_BACKGROUND_TRANSPARENT: "透明",
|
||||
EXPORTDIALOG_BACKGROUND_USE_COLOR: "使用場景顏色",
|
||||
// 選擇
|
||||
EXPORTDIALOG_SELECTED_ELEMENTS: "匯出",
|
||||
EXPORTDIALOG_SELECTED_ALL: "整個場景",
|
||||
EXPORTDIALOG_SELECTED_SELECTED: "僅選中部分",
|
||||
// 匯出選項
|
||||
EXPORTDIALOG_EMBED_SCENE: "包含場景資料嗎?",
|
||||
EXPORTDIALOG_EMBED_YES: "是",
|
||||
EXPORTDIALOG_EMBED_NO: "否",
|
||||
// PDF 設定
|
||||
EXPORTDIALOG_PDF_SETTINGS: "PDF",
|
||||
EXPORTDIALOG_PAGE_SIZE: "頁面大小",
|
||||
EXPORTDIALOG_PAGE_ORIENTATION: "方向",
|
||||
EXPORTDIALOG_ORIENTATION_PORTRAIT: "縱向",
|
||||
EXPORTDIALOG_ORIENTATION_LANDSCAPE: "橫向",
|
||||
EXPORTDIALOG_PDF_FIT_TO_PAGE: "頁面適配",
|
||||
EXPORTDIALOG_PDF_FIT_OPTION: "適配頁面",
|
||||
EXPORTDIALOG_PDF_FIT_2_OPTION: "適配至最多 2 頁" ,
|
||||
EXPORTDIALOG_PDF_FIT_4_OPTION: "適配至最多 4 頁" ,
|
||||
EXPORTDIALOG_PDF_FIT_6_OPTION: "適配至最多 6 頁" ,
|
||||
EXPORTDIALOG_PDF_FIT_8_OPTION: "適配至最多 8 頁" ,
|
||||
EXPORTDIALOG_PDF_FIT_12_OPTION: "適配至最多 12 頁" ,
|
||||
EXPORTDIALOG_PDF_FIT_16_OPTION: "適配至最多 16 頁" ,
|
||||
EXPORTDIALOG_PDF_SCALE_OPTION: "使用影像縮放(可能跨多頁)",
|
||||
EXPORTDIALOG_PDF_PAPER_COLOR: "紙張顏色",
|
||||
EXPORTDIALOG_PDF_PAPER_WHITE: "白色",
|
||||
EXPORTDIALOG_PDF_PAPER_SCENE: "使用場景顏色",
|
||||
EXPORTDIALOG_PDF_PAPER_CUSTOM: "自定義顏色",
|
||||
EXPORTDIALOG_PDF_ALIGNMENT: "頁面位置",
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER: "居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER_LEFT: "左對齊居中" ,
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER_RIGHT: "右對齊居中" ,
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_LEFT: "左上角",
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_CENTER: "頂部居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_RIGHT: "右上角",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_LEFT: "左下角",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_CENTER: "底部居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_RIGHT: "右下角",
|
||||
EXPORTDIALOG_PDF_MARGIN: "邊距",
|
||||
EXPORTDIALOG_PDF_MARGIN_NONE: "無",
|
||||
EXPORTDIALOG_PDF_MARGIN_TINY: "小",
|
||||
EXPORTDIALOG_PDF_MARGIN_NORMAL: "正常",
|
||||
EXPORTDIALOG_SAVE_PDF_SETTINGS: "儲存 PDF 設定",
|
||||
EXPORTDIALOG_SAVE_CONFIRMATION: "PDF 配置已儲存為外掛預設設定",
|
||||
// 按鈕
|
||||
EXPORTDIALOG_PNGTOFILE: "匯出 PNG 檔案",
|
||||
EXPORTDIALOG_SVGTOFILE: "匯出 SVG 檔案",
|
||||
EXPORTDIALOG_PNGTOVAULT: "PNG 儲存到 Vault",
|
||||
EXPORTDIALOG_SVGTOVAULT: "SVG 儲存到 Vault",
|
||||
EXPORTDIALOG_EXCALIDRAW: "Excalidraw",
|
||||
EXPORTDIALOG_PNGTOCLIPBOARD: "PNG 複製到剪貼簿",
|
||||
EXPORTDIALOG_SVGTOCLIPBOARD: "SVG 複製到剪貼簿",
|
||||
EXPORTDIALOG_PDF: "匯出 PDF 檔案",
|
||||
//ExportDialog
|
||||
// Dialog and tabs
|
||||
EXPORTDIALOG_TITLE: "匯出圖形",
|
||||
EXPORTDIALOG_TAB_IMAGE: "影像",
|
||||
EXPORTDIALOG_TAB_PDF: "PDF",
|
||||
// Settings persistence
|
||||
EXPORTDIALOG_SAVE_SETTINGS: "將影像設定儲存到檔案 doc.properties 嗎?",
|
||||
EXPORTDIALOG_SAVE_SETTINGS_SAVE: "儲存為預設",
|
||||
EXPORTDIALOG_SAVE_SETTINGS_ONETIME: "僅本次使用",
|
||||
// Image settings
|
||||
EXPORTDIALOG_IMAGE_SETTINGS: "影像",
|
||||
EXPORTDIALOG_IMAGE_DESC: "PNG 支援透明。外部檔案可以包含 Excalidraw 場景資料。",
|
||||
EXPORTDIALOG_PADDING: "邊距",
|
||||
EXPORTDIALOG_SCALE: "縮放",
|
||||
EXPORTDIALOG_CURRENT_PADDING: "當前邊距:",
|
||||
EXPORTDIALOG_SIZE_DESC: "縮放會影響輸出大小",
|
||||
EXPORTDIALOG_SCALE_VALUE: "縮放:",
|
||||
EXPORTDIALOG_IMAGE_SIZE: "大小:",
|
||||
// Theme and background
|
||||
EXPORTDIALOG_EXPORT_THEME: "主題",
|
||||
EXPORTDIALOG_THEME_LIGHT: "淺色",
|
||||
EXPORTDIALOG_THEME_DARK: "深色",
|
||||
EXPORTDIALOG_BACKGROUND: "背景",
|
||||
EXPORTDIALOG_BACKGROUND_TRANSPARENT: "透明",
|
||||
EXPORTDIALOG_BACKGROUND_USE_COLOR: "使用場景顏色",
|
||||
// Selection
|
||||
EXPORTDIALOG_SELECTED_ELEMENTS: "匯出",
|
||||
EXPORTDIALOG_SELECTED_ALL: "整個場景",
|
||||
EXPORTDIALOG_SELECTED_SELECTED: "僅選中部分",
|
||||
// Export options
|
||||
EXPORTDIALOG_EMBED_SCENE: "包含場景資料嗎?",
|
||||
EXPORTDIALOG_EMBED_YES: "是",
|
||||
EXPORTDIALOG_EMBED_NO: "否",
|
||||
// PDF settings
|
||||
EXPORTDIALOG_PDF_SETTINGS: "PDF",
|
||||
EXPORTDIALOG_PAGE_SIZE: "頁面大小",
|
||||
EXPORTDIALOG_PAGE_ORIENTATION: "方向",
|
||||
EXPORTDIALOG_ORIENTATION_PORTRAIT: "縱向",
|
||||
EXPORTDIALOG_ORIENTATION_LANDSCAPE: "橫向",
|
||||
EXPORTDIALOG_PDF_FIT_TO_PAGE: "頁面適配",
|
||||
EXPORTDIALOG_PDF_FIT_OPTION: "適配頁面",
|
||||
EXPORTDIALOG_PDF_FIT_2_OPTION: "適配至最多 2 頁",
|
||||
EXPORTDIALOG_PDF_FIT_4_OPTION: "適配至最多 4 頁",
|
||||
EXPORTDIALOG_PDF_FIT_6_OPTION: "適配至最多 6 頁",
|
||||
EXPORTDIALOG_PDF_FIT_8_OPTION: "適配至最多 8 頁",
|
||||
EXPORTDIALOG_PDF_FIT_12_OPTION: "適配至最多 12 頁",
|
||||
EXPORTDIALOG_PDF_FIT_16_OPTION: "適配至最多 16 頁",
|
||||
EXPORTDIALOG_PDF_SCALE_OPTION: "使用影像縮放(可能跨多頁)",
|
||||
EXPORTDIALOG_PDF_PAPER_COLOR: "紙張顏色",
|
||||
EXPORTDIALOG_PDF_PAPER_WHITE: "白色",
|
||||
EXPORTDIALOG_PDF_PAPER_SCENE: "使用場景顏色",
|
||||
EXPORTDIALOG_PDF_PAPER_CUSTOM: "自定義顏色",
|
||||
EXPORTDIALOG_PDF_ALIGNMENT: "頁面位置",
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER: "居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER_LEFT: "左對齊居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_CENTER_RIGHT: "右對齊居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_LEFT: "左上角",
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_CENTER: "頂部居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_TOP_RIGHT: "右上角",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_LEFT: "左下角",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_CENTER: "底部居中",
|
||||
EXPORTDIALOG_PDF_ALIGN_BOTTOM_RIGHT: "右下角",
|
||||
EXPORTDIALOG_PDF_MARGIN: "邊距",
|
||||
EXPORTDIALOG_PDF_MARGIN_NONE: "無",
|
||||
EXPORTDIALOG_PDF_MARGIN_TINY: "小",
|
||||
EXPORTDIALOG_PDF_MARGIN_NORMAL: "正常",
|
||||
EXPORTDIALOG_SAVE_PDF_SETTINGS: "儲存 PDF 設定",
|
||||
EXPORTDIALOG_SAVE_CONFIRMATION: "PDF 配置已儲存為外掛預設設定",
|
||||
// Buttons
|
||||
EXPORTDIALOG_PNGTOFILE: "匯出 PNG 檔案",
|
||||
EXPORTDIALOG_SVGTOFILE: "匯出 SVG 檔案",
|
||||
EXPORTDIALOG_PNGTOVAULT: "PNG 儲存到 Vault",
|
||||
EXPORTDIALOG_SVGTOVAULT: "SVG 儲存到 Vault",
|
||||
EXPORTDIALOG_EXCALIDRAW: "Excalidraw",
|
||||
EXPORTDIALOG_PNGTOCLIPBOARD: "PNG 複製到剪貼簿",
|
||||
EXPORTDIALOG_SVGTOCLIPBOARD: "SVG 複製到剪貼簿",
|
||||
EXPORTDIALOG_PDF: "匯出 PDF 檔案",
|
||||
|
||||
EXPORTDIALOG_PDF_PROGRESS_NOTICE: "正在匯出 PDF。如果影像較大,可能需要一些時間。" ,
|
||||
EXPORTDIALOG_PDF_PROGRESS_DONE: "匯出完成" ,
|
||||
EXPORTDIALOG_PDF_PROGRESS_ERROR: "匯出 PDF 時出錯,請檢查開發者控制檯以獲取詳細資訊" ,
|
||||
EXPORTDIALOG_PDF_PROGRESS_NOTICE: "正在匯出 PDF。如果影像較大,可能需要一些時間。",
|
||||
EXPORTDIALOG_PDF_PROGRESS_DONE: "匯出完成",
|
||||
EXPORTDIALOG_PDF_PROGRESS_ERROR: "匯出 PDF 時出錯,請檢查開發者控制檯以獲取詳細資訊",
|
||||
|
||||
// Screenshot tab
|
||||
EXPORTDIALOG_NOT_AVAILALBE : "抱歉,此功能僅在繪圖在主 Obsidian 工作區開啟時可用。",
|
||||
EXPORTDIALOG_TAB_SCREENSHOT : "截圖" ,
|
||||
EXPORTDIALOG_SCREENSHOT_DESC : "截圖將包括可嵌入的內容,例如 markdown 頁面、YouTube、網站等。它們僅在桌面端可用,無法自動匯出,並且僅支援 PNG 格式。" ,
|
||||
SCREENSHOT_DESKTOP_ONLY : "截圖功能僅在桌面端可用" ,
|
||||
SCREENSHOT_FILE_SUCCESS : "截圖已儲存到倉庫" ,
|
||||
SCREENSHOT_CLIPBOARD_SUCCESS : "截圖已複製到剪貼簿" ,
|
||||
SCREENSHOT_CLIPBOARD_ERROR : "無法複製截圖到剪貼簿:" ,
|
||||
SCREENSHOT_ERROR : "截圖出錯 - 請檢視控制檯日誌" ,
|
||||
// Screenshot tab
|
||||
EXPORTDIALOG_NOT_AVAILALBE: "抱歉,此功能僅在繪圖在主 Obsidian 工作區開啟時可用。",
|
||||
EXPORTDIALOG_TAB_SCREENSHOT: "截圖",
|
||||
EXPORTDIALOG_SCREENSHOT_DESC: "截圖將包括可嵌入的內容,例如 markdown 頁面、YouTube、網站等。它們僅在桌面端可用,無法自動匯出,並且僅支援 PNG 格式。",
|
||||
SCREENSHOT_DESKTOP_ONLY: "截圖功能僅在桌面端可用",
|
||||
SCREENSHOT_FILE_SUCCESS: "截圖已儲存到倉庫",
|
||||
SCREENSHOT_CLIPBOARD_SUCCESS: "截圖已複製到剪貼簿",
|
||||
SCREENSHOT_CLIPBOARD_ERROR: "無法複製截圖到剪貼簿:",
|
||||
SCREENSHOT_ERROR: "截圖出錯 - 請檢視控制檯日誌",
|
||||
|
||||
// exportUtils.ts
|
||||
PDF_EXPORT_DESKTOP_ONLY: "PDF 匯出功能僅限桌面端使用" ,
|
||||
};
|
||||
//exportUtils.ts
|
||||
PDF_EXPORT_DESKTOP_ONLY: "PDF 匯出功能僅限桌面端使用",
|
||||
};
|
||||
@@ -4,10 +4,15 @@ export class FloatingModal extends Modal {
|
||||
private dragging = false;
|
||||
private offsetX = 0;
|
||||
private offsetY = 0;
|
||||
private pointerDownHandler: (e: PointerEvent) => void;
|
||||
private pointerMoveHandler: (e: PointerEvent) => void;
|
||||
private pointerDownHandler: (e: PointerEvent | TouchEvent) => void;
|
||||
private pointerMoveHandler: (e: PointerEvent | TouchEvent) => void;
|
||||
private pointerUpHandler: () => void;
|
||||
|
||||
private disableKeyCapture = true; // new flag: when true, let keystrokes pass through to workspace
|
||||
private previousActive: HTMLElement | null = null; // stores element focused before opening
|
||||
private escListener: (e: KeyboardEvent) => void;
|
||||
private modalKeydownStopHandler: (e: KeyboardEvent) => void; // store handler so we can remove it
|
||||
|
||||
constructor(app: App) {
|
||||
super(app);
|
||||
|
||||
@@ -15,40 +20,82 @@ export class FloatingModal extends Modal {
|
||||
this.pointerDownHandler = this.handlePointerDown.bind(this);
|
||||
this.pointerMoveHandler = this.handlePointerMove.bind(this);
|
||||
this.pointerUpHandler = this.handlePointerUp.bind(this);
|
||||
this.escListener = this.handleEscKey.bind(this);
|
||||
this.modalKeydownStopHandler = (ev: KeyboardEvent) => ev.stopPropagation();
|
||||
}
|
||||
|
||||
private handlePointerDown(e: PointerEvent): void {
|
||||
private handlePointerDown(e: PointerEvent | TouchEvent): void {
|
||||
// Get the target element
|
||||
const target = e.target as HTMLElement;
|
||||
|
||||
// Ignore if clicking on interactive elements
|
||||
if (
|
||||
e.target instanceof HTMLInputElement ||
|
||||
e.target instanceof HTMLTextAreaElement ||
|
||||
e.target instanceof HTMLSelectElement ||
|
||||
e.target instanceof HTMLButtonElement ||
|
||||
(e.target as HTMLElement).closest(".clickable-icon")
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement ||
|
||||
target instanceof HTMLSelectElement ||
|
||||
target instanceof HTMLButtonElement ||
|
||||
target.closest(".clickable-icon")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.dragging = true;
|
||||
const { modalEl } = this;
|
||||
this.offsetX = e.clientX - modalEl.getBoundingClientRect().left;
|
||||
this.offsetY = e.clientY - modalEl.getBoundingClientRect().top;
|
||||
// For touch events, prevent default behavior to avoid Obsidian's handling
|
||||
if (e.type === "touchstart") {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
// Add global event listeners for move and up events
|
||||
document.addEventListener("pointermove", this.pointerMoveHandler);
|
||||
document.addEventListener("pointerup", this.pointerUpHandler);
|
||||
// Capture the pointer to ensure we get events even when outside the target
|
||||
(e.target as HTMLElement).setPointerCapture(e.pointerId);
|
||||
if ((e as TouchEvent).touches.length !== 1) return;
|
||||
|
||||
const touch = (e as TouchEvent).touches[0];
|
||||
this.dragging = true;
|
||||
const { modalEl } = this;
|
||||
this.offsetX = touch.clientX - modalEl.getBoundingClientRect().left;
|
||||
this.offsetY = touch.clientY - modalEl.getBoundingClientRect().top;
|
||||
|
||||
// Add touch-specific event listeners
|
||||
document.addEventListener("touchmove", this.pointerMoveHandler as (e: TouchEvent) => void, {
|
||||
passive: false,
|
||||
});
|
||||
document.addEventListener("touchend", this.pointerUpHandler);
|
||||
document.addEventListener("touchcancel", this.pointerUpHandler);
|
||||
} else {
|
||||
// Handle pointer events
|
||||
this.dragging = true;
|
||||
const { modalEl } = this;
|
||||
const pointerEvent = e as PointerEvent;
|
||||
this.offsetX = pointerEvent.clientX - modalEl.getBoundingClientRect().left;
|
||||
this.offsetY = pointerEvent.clientY - modalEl.getBoundingClientRect().top;
|
||||
|
||||
// Add pointer-specific event listeners
|
||||
document.addEventListener("pointermove", this.pointerMoveHandler as (e: PointerEvent) => void);
|
||||
document.addEventListener("pointerup", this.pointerUpHandler);
|
||||
// Capture the pointer to ensure we get events even when outside the target
|
||||
target.setPointerCapture(pointerEvent.pointerId);
|
||||
}
|
||||
}
|
||||
|
||||
private handlePointerMove(e: PointerEvent): void {
|
||||
private handlePointerMove(e: PointerEvent | TouchEvent): void {
|
||||
if (!this.dragging) return;
|
||||
const { modalEl } = this;
|
||||
|
||||
// Prevent default behavior
|
||||
e.preventDefault();
|
||||
if (e.type === "touchmove") e.stopPropagation();
|
||||
|
||||
const x = e.clientX - this.offsetX;
|
||||
const y = e.clientY - this.offsetY;
|
||||
let clientX, clientY;
|
||||
|
||||
if (e.type === "touchmove") {
|
||||
const touch = (e as TouchEvent).touches[0];
|
||||
clientX = touch.clientX;
|
||||
clientY = touch.clientY;
|
||||
} else {
|
||||
const pointerEvent = e as PointerEvent;
|
||||
clientX = pointerEvent.clientX;
|
||||
clientY = pointerEvent.clientY;
|
||||
}
|
||||
|
||||
const x = clientX - this.offsetX;
|
||||
const y = clientY - this.offsetY;
|
||||
|
||||
// Position the modal element
|
||||
modalEl.style.left = `${x}px`;
|
||||
@@ -58,17 +105,42 @@ export class FloatingModal extends Modal {
|
||||
|
||||
private handlePointerUp(): void {
|
||||
this.dragging = false;
|
||||
document.removeEventListener("pointermove", this.pointerMoveHandler);
|
||||
// Remove all event listeners
|
||||
document.removeEventListener("pointermove", this.pointerMoveHandler as (e: PointerEvent) => void);
|
||||
document.removeEventListener("pointerup", this.pointerUpHandler);
|
||||
document.removeEventListener("touchmove", this.pointerMoveHandler as (e: TouchEvent) => void);
|
||||
document.removeEventListener("touchend", this.pointerUpHandler);
|
||||
document.removeEventListener("touchcancel", this.pointerUpHandler);
|
||||
}
|
||||
|
||||
private handleEscKey(e: KeyboardEvent) {
|
||||
if (e.key === "Escape") {
|
||||
// Optionally stop propagation if you do not want other handlers firing
|
||||
e.stopPropagation();
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
||||
open(): void {
|
||||
super.open();
|
||||
// NEW: capture previously focused element & release Obsidian modal key trapping
|
||||
if (this.disableKeyCapture) {
|
||||
this.previousActive = document.activeElement as HTMLElement | null;
|
||||
try {
|
||||
// @ts-ignore pop modal's key scope so keys are not intercepted
|
||||
this.app.keymap.popScope(this.scope);
|
||||
} catch {}
|
||||
try {
|
||||
// @ts-ignore prevent automatic selection / focus restoration
|
||||
this.shouldRestoreSelection = false;
|
||||
} catch {}
|
||||
}
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
const { containerEl, modalEl, bgEl } = this;
|
||||
const { containerEl, modalEl, bgEl, headerEl } = this;
|
||||
containerEl.style.pointerEvents = "none";
|
||||
if (bgEl) bgEl.style.display = "none";
|
||||
if (headerEl) headerEl.style.pointerEvents = "none";
|
||||
|
||||
// Set initial position and make modal draggable
|
||||
if (modalEl) {
|
||||
@@ -84,22 +156,53 @@ export class FloatingModal extends Modal {
|
||||
modalEl.style.left = `${centerX}px`;
|
||||
modalEl.style.top = `${centerY}px`;
|
||||
modalEl.style.transform = "none";
|
||||
const modalStyle = window.getComputedStyle(modalEl);
|
||||
modalEl.style.borderBottomLeftRadius = modalStyle.borderTopLeftRadius;
|
||||
modalEl.style.borderBottomRightRadius = modalStyle.borderTopRightRadius;
|
||||
|
||||
// Add pointer down listener to start dragging
|
||||
modalEl.addEventListener("pointerdown", this.pointerDownHandler);
|
||||
// Add event listeners for both pointer and touch events
|
||||
modalEl.addEventListener("pointerdown", this.pointerDownHandler as (e: PointerEvent) => void);
|
||||
modalEl.addEventListener("touchstart", this.pointerDownHandler as (e: TouchEvent) => void, {
|
||||
passive: false,
|
||||
});
|
||||
|
||||
if (this.disableKeyCapture) {
|
||||
// Prevent the modal from stealing focus
|
||||
modalEl.setAttr("tabindex", "-1");
|
||||
// Refocus previous element (if still in DOM)
|
||||
if (this.previousActive?.isConnected) {
|
||||
this.previousActive.focus({ preventScroll: true });
|
||||
}
|
||||
// Stop key events originating inside the modal from bubbling back
|
||||
modalEl.addEventListener("keydown", this.modalKeydownStopHandler, { capture: true });
|
||||
}
|
||||
// Add ESC listener (capture to run before underlying workspace)
|
||||
document.addEventListener("keydown", this.escListener, { capture: true });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
close(): void {
|
||||
// Optional: restore previous focus if body ended up focused
|
||||
if (this.disableKeyCapture && this.previousActive?.isConnected && document.activeElement === document.body) {
|
||||
try { this.previousActive.focus({ preventScroll: true }); } catch {}
|
||||
}
|
||||
const { modalEl } = this;
|
||||
// Clean up event listeners
|
||||
if (modalEl) {
|
||||
modalEl.removeEventListener("pointerdown", this.pointerDownHandler);
|
||||
modalEl.removeEventListener("pointerdown", this.pointerDownHandler as (e: PointerEvent) => void);
|
||||
modalEl.removeEventListener("touchstart", this.pointerDownHandler as (e: TouchEvent) => void);
|
||||
// Remove the capturing keydown stopper if it was added
|
||||
modalEl.removeEventListener("keydown", this.modalKeydownStopHandler, { capture: true });
|
||||
}
|
||||
document.removeEventListener("pointermove", this.pointerMoveHandler);
|
||||
document.removeEventListener("pointerup", this.pointerUpHandler);
|
||||
// Remove any remaining document event listeners
|
||||
this.handlePointerUp();
|
||||
document.removeEventListener("keydown", this.escListener, { capture: true });
|
||||
|
||||
super.close();
|
||||
}
|
||||
|
||||
// (Optional helper if you want to toggle later)
|
||||
enableKeyCapture() { this.disableKeyCapture = false; }
|
||||
disableKeyCaptureFn() { this.disableKeyCapture = true; }
|
||||
}
|
||||
@@ -1,22 +1,25 @@
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { FloatingModal } from "./FloatingModal";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { Setting } from "obsidian";
|
||||
|
||||
export const showFrameSettings = (ea: ExcalidrawAutomate) => {
|
||||
const {enabled, clip, name, outline} = ea.getExcalidrawAPI().getAppState().frameRendering;
|
||||
export const showFrameSettings = (view: ExcalidrawView) => {
|
||||
const {enabled, clip, name, outline, markerName, markerEnabled} = view.excalidrawAPI.getAppState().frameRendering;
|
||||
|
||||
// Create modal dialog
|
||||
const frameSettingsModal = new ea.obsidian.Modal(ea.plugin.app);
|
||||
const frameSettingsModal = new FloatingModal(view.app);
|
||||
|
||||
frameSettingsModal.onOpen = () => {
|
||||
const {contentEl} = frameSettingsModal;
|
||||
|
||||
contentEl.createEl("h1", {text: t("FRAME_SETTINGS_TITLE")});
|
||||
|
||||
const settings = { enabled, clip, name, outline };
|
||||
const settings = { enabled, clip, name, outline, markerName, markerEnabled };
|
||||
|
||||
// Add toggles
|
||||
const enableFramesSetting = new ea.obsidian.Setting(contentEl)
|
||||
new Setting(contentEl)
|
||||
.setName(t("FRAME_SETTINGS_ENABLE"))
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(settings.enabled)
|
||||
@@ -28,21 +31,21 @@ export const showFrameSettings = (ea: ExcalidrawAutomate) => {
|
||||
})
|
||||
);
|
||||
|
||||
const displayFrameNameSetting = new ea.obsidian.Setting(contentEl)
|
||||
const displayFrameNameSetting = new Setting(contentEl)
|
||||
.setName(t("FRAME_SETTIGNS_NAME"))
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(settings.name)
|
||||
.onChange(value => settings.name = value)
|
||||
);
|
||||
|
||||
const displayFrameOutlineSetting = new ea.obsidian.Setting(contentEl)
|
||||
const displayFrameOutlineSetting = new Setting(contentEl)
|
||||
.setName(t("FRAME_SETTINGS_OUTLINE"))
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(settings.outline)
|
||||
.onChange(value => settings.outline = value)
|
||||
);
|
||||
|
||||
const enableFrameClippingSetting = new ea.obsidian.Setting(contentEl)
|
||||
const enableFrameClippingSetting = new Setting(contentEl)
|
||||
.setName(t("FRAME_SETTINGS_CLIP"))
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(settings.clip)
|
||||
@@ -55,12 +58,12 @@ export const showFrameSettings = (ea: ExcalidrawAutomate) => {
|
||||
hideComponent(enableFrameClippingSetting, !settings.enabled);
|
||||
|
||||
// Add OK button
|
||||
new ea.obsidian.Setting(contentEl)
|
||||
new Setting(contentEl)
|
||||
.addButton(button => button
|
||||
.setButtonText("OK")
|
||||
.onClick(() => {
|
||||
// Update appState with new settings
|
||||
ea.viewUpdateScene({
|
||||
view.updateScene({
|
||||
// @ts-ignore
|
||||
appState: {
|
||||
frameRendering: settings
|
||||
@@ -72,9 +75,6 @@ export const showFrameSettings = (ea: ExcalidrawAutomate) => {
|
||||
);
|
||||
};
|
||||
|
||||
frameSettingsModal.onClose = () => {
|
||||
ea.destroy();
|
||||
}
|
||||
frameSettingsModal.open();
|
||||
};
|
||||
|
||||
|
||||
@@ -17,16 +17,88 @@ 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.14.1":`
|
||||
"2.15.0":`
|
||||
<div class="excalidraw-videoWrapper"><div>
|
||||
<iframe src="https://www.youtube.com/embed/DqDnzCOoYMc" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
</div></div>
|
||||
|
||||
## New
|
||||
- New frontmatter option \`excalidraw-embed-md\`. When set to \`true\`, embedding this Excalidraw file into another markdown file will display its markdown content (the "back of the note") instead of rendering it as an image.
|
||||
- Introducing **Marker Frames**. These are special frames that can be used to mark slides, pages areas for PDF printouts, image references, etc.
|
||||
To create a marker frame, create a frame and toggle the marker frame in the elements properties panel.
|
||||
- Markers are not included in exports such as images or PDFs.
|
||||
- Markers do not contain elements
|
||||
- Markers can be hidden/shown from the canvas context menu
|
||||
- Updated the "Printable Layout Wizard" script
|
||||
- Now works with marker frames
|
||||
- Supports different page sizes and orientations within a single PDF document
|
||||
- The printout may include non-marker frames (e.g., PDF image embeds in frames)
|
||||
- Pro-tip: You can also use marker frames...
|
||||
- with the Slideshow plugin
|
||||
- to create image-area references such that the frames do not get rendered in exported images, and you can reference areas by frame name
|
||||
- Performance improvement of Image-area references
|
||||
|
||||
# New in ExcalidrawAutomate
|
||||
- \`createPDF()\` now supports \`SVG[]\` array of SVGs with different sizes.
|
||||
- New function:
|
||||
\`\`\`ts
|
||||
/**
|
||||
* Gets the elements within a specific area.
|
||||
* @param elements - The elements to check.
|
||||
* @param param1 - The area to check against.
|
||||
* @returns The elements within the area.
|
||||
*/
|
||||
elementsInArea(
|
||||
elements: NonDeletedExcalidrawElement[],
|
||||
{x, y, width, height}:{
|
||||
x:number; y:number; width:number; height:number;
|
||||
}
|
||||
):ExcalidrawElement[]
|
||||
\`\`\`
|
||||
`,
|
||||
"2.14.3":`
|
||||
<div class="excalidraw-videoWrapper"><div>
|
||||
<iframe src="https://www.youtube.com/embed/29EWeglRm7s" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
</div></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"><div>
|
||||
<iframe src="https://www.youtube.com/embed/A_udjVjgWN0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
</div></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).
|
||||
|
||||
## Fixed
|
||||
- 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.
|
||||
`,
|
||||
"2.14.0":`
|
||||
## A Big "Small" Update
|
||||
|
||||
@@ -16,10 +16,14 @@ export class ReleaseNotes extends Modal {
|
||||
}
|
||||
|
||||
onOpen(): void {
|
||||
//@ts-ignore
|
||||
const { containerEl, contentEl, titleEl, headerEl } = this;
|
||||
//this.contentEl.classList.add("excalidraw-release");
|
||||
this.containerEl.classList.add("excalidraw-release");
|
||||
this.titleEl.setText(`Welcome to Excalidraw ${this.version ?? ""}`);
|
||||
containerEl.classList.add("excalidraw-release");
|
||||
titleEl.setText(`Welcome to Excalidraw ${this.version ?? ""}`);
|
||||
this.createForm();
|
||||
|
||||
if(headerEl) headerEl.style.pointerEvents = "none"; // Disable pointer events on header to allow clicks through
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
|
||||
@@ -611,6 +611,12 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
"}",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "getElementsInArea",
|
||||
code: "getElementsInArea(elements: ExcalidrawElement[], area: {x: number, y: number, width: number, height: number}): ExcalidrawElement[];",
|
||||
desc: "Filter the elements and returns only those within the specific area.",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "getBoundingBox",
|
||||
code: "getBoundingBox(elements: ExcalidrawElement[]): {topX: number, topY: number, width: number, height: number,};",
|
||||
|
||||
@@ -608,7 +608,7 @@ export class EmbeddedFilesLoader {
|
||||
return {
|
||||
mimeType,
|
||||
fileId: await generateIdFromFile(
|
||||
isHyperLink || isPDF || isExcalidrawFile ? (new TextEncoder()).encode(dataURL as string) : ab,
|
||||
isHyperLink || isPDF || isExcalidrawFile ? (new TextEncoder()).encode(dataURL as string).buffer : ab,
|
||||
inFile instanceof EmbeddedFile ? inFile.filenameparts?.linkpartReference : undefined
|
||||
),
|
||||
dataURL,
|
||||
@@ -1215,11 +1215,14 @@ export const generateIdFromFile = async (file: ArrayBuffer, key?: string): Promi
|
||||
}
|
||||
|
||||
// Hash the combined data (file and key, if provided)
|
||||
const hashBuffer = await window.crypto.subtle.digest("SHA-1", dataToHash);
|
||||
// Ensure we pass an ArrayBuffer (not ArrayBufferLike) to subtle.digest
|
||||
const buffer: ArrayBuffer = dataToHash.buffer.slice(
|
||||
dataToHash.byteOffset,
|
||||
dataToHash.byteOffset + dataToHash.byteLength
|
||||
) as ArrayBuffer;
|
||||
const hashBuffer = await window.crypto.subtle.digest("SHA-1", buffer);
|
||||
id =
|
||||
// Convert buffer to byte array
|
||||
Array.from(new Uint8Array(hashBuffer))
|
||||
// Convert to hex string
|
||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||
.join("") as FileId;
|
||||
} catch (error) {
|
||||
|
||||
@@ -832,59 +832,60 @@ export class ExcalidrawAutomate {
|
||||
frontmatter = mergeMarkdownFiles(template.frontmatter,frontmatter);
|
||||
}
|
||||
|
||||
const templateAppstate = template?.appState ?? {};
|
||||
Object.keys(templateAppstate).forEach((key) => {
|
||||
if(templateAppstate[key] === undefined) {
|
||||
delete templateAppstate[key];
|
||||
}
|
||||
});
|
||||
const scene = {
|
||||
type: "excalidraw",
|
||||
version: 2,
|
||||
source: GITHUB_RELEASES+PLUGIN_VERSION,
|
||||
elements,
|
||||
appState: {
|
||||
theme: template?.appState?.theme ?? this.canvas.theme,
|
||||
...templateAppstate,
|
||||
theme: templateAppstate.theme ?? this.canvas.theme,
|
||||
viewBackgroundColor:
|
||||
template?.appState?.viewBackgroundColor ??
|
||||
templateAppstate.viewBackgroundColor ??
|
||||
this.canvas.viewBackgroundColor,
|
||||
currentItemStrokeColor:
|
||||
template?.appState?.currentItemStrokeColor ??
|
||||
templateAppstate.currentItemStrokeColor ??
|
||||
this.style.strokeColor,
|
||||
currentItemBackgroundColor:
|
||||
template?.appState?.currentItemBackgroundColor ??
|
||||
templateAppstate.currentItemBackgroundColor ??
|
||||
this.style.backgroundColor,
|
||||
currentItemFillStyle:
|
||||
template?.appState?.currentItemFillStyle ?? this.style.fillStyle,
|
||||
templateAppstate.currentItemFillStyle ?? this.style.fillStyle,
|
||||
currentItemStrokeWidth:
|
||||
template?.appState?.currentItemStrokeWidth ??
|
||||
templateAppstate.currentItemStrokeWidth ??
|
||||
this.style.strokeWidth,
|
||||
currentItemStrokeStyle:
|
||||
template?.appState?.currentItemStrokeStyle ??
|
||||
templateAppstate.currentItemStrokeStyle ??
|
||||
this.style.strokeStyle,
|
||||
currentItemRoughness:
|
||||
template?.appState?.currentItemRoughness ?? this.style.roughness,
|
||||
templateAppstate.currentItemRoughness ?? this.style.roughness,
|
||||
currentItemOpacity:
|
||||
template?.appState?.currentItemOpacity ?? this.style.opacity,
|
||||
templateAppstate.currentItemOpacity ?? this.style.opacity,
|
||||
currentItemFontFamily:
|
||||
template?.appState?.currentItemFontFamily ?? this.style.fontFamily,
|
||||
templateAppstate.currentItemFontFamily ?? this.style.fontFamily,
|
||||
currentItemFontSize:
|
||||
template?.appState?.currentItemFontSize ?? this.style.fontSize,
|
||||
templateAppstate.currentItemFontSize ?? this.style.fontSize,
|
||||
currentItemTextAlign:
|
||||
template?.appState?.currentItemTextAlign ?? this.style.textAlign,
|
||||
templateAppstate.currentItemTextAlign ?? this.style.textAlign,
|
||||
currentItemStartArrowhead:
|
||||
template?.appState?.currentItemStartArrowhead ??
|
||||
templateAppstate.currentItemStartArrowhead ??
|
||||
this.style.startArrowHead,
|
||||
currentItemEndArrowhead:
|
||||
template?.appState?.currentItemEndArrowhead ??
|
||||
templateAppstate.currentItemEndArrowhead ??
|
||||
this.style.endArrowHead,
|
||||
currentItemRoundness: //type StrokeRoundness = "round" | "sharp"
|
||||
template?.appState?.currentItemLinearStrokeSharpness ?? //legacy compatibility
|
||||
template?.appState?.currentItemStrokeSharpness ?? //legacy compatibility
|
||||
template?.appState?.currentItemRoundness ??
|
||||
currentItemRoundness:
|
||||
templateAppstate.currentItemLinearStrokeSharpness ??
|
||||
templateAppstate.currentItemStrokeSharpness ??
|
||||
templateAppstate.currentItemRoundness ??
|
||||
this.style.roundness ? "round":"sharp",
|
||||
gridSize: template?.appState?.gridSize ?? this.canvas.gridSize,
|
||||
colorPalette: template?.appState?.colorPalette ?? this.colorPalette,
|
||||
...template?.appState?.frameRendering
|
||||
? {frameRendering: template.appState.frameRendering}
|
||||
: {},
|
||||
...template?.appState?.objectsSnapModeEnabled
|
||||
? {objectsSnapModeEnabled: template.appState.objectsSnapModeEnabled}
|
||||
: {},
|
||||
gridSize: templateAppstate.gridSize ?? this.canvas.gridSize,
|
||||
colorPalette: templateAppstate.colorPalette ?? this.colorPalette,
|
||||
},
|
||||
files: template?.files ?? {},
|
||||
};
|
||||
@@ -1041,6 +1042,7 @@ export class ExcalidrawAutomate {
|
||||
* @param {boolean} [options.selectedOnly=false] - Whether to include only the selected elements in the SVG.
|
||||
* @param {boolean} [options.skipInliningFonts=false] - Whether to skip inlining fonts in the SVG.
|
||||
* @param {boolean} [options.embedScene=false] - Whether to embed the scene in the SVG.
|
||||
* @param {ExcalidrawElement[]} [options.elementsOverride] - Optional override for the elements to include in the SVG. Primary to support the Printable Layout Wizard script
|
||||
* @returns {Promise<SVGSVGElement>} A promise that resolves to the SVG element.
|
||||
*/
|
||||
async createViewSVG({
|
||||
@@ -1051,6 +1053,7 @@ export class ExcalidrawAutomate {
|
||||
selectedOnly = false,
|
||||
skipInliningFonts = false,
|
||||
embedScene = false,
|
||||
elementsOverride,
|
||||
} : {
|
||||
withBackground?: boolean,
|
||||
theme?: "light" | "dark",
|
||||
@@ -1059,6 +1062,7 @@ export class ExcalidrawAutomate {
|
||||
selectedOnly?: boolean,
|
||||
skipInliningFonts?: boolean,
|
||||
embedScene?: boolean,
|
||||
elementsOverride?: ExcalidrawElement[]
|
||||
}): Promise<SVGSVGElement> {
|
||||
if(!this.targetView || !this.targetView.file || !this.targetView._loaded) {
|
||||
console.log("No view loaded");
|
||||
@@ -1067,6 +1071,9 @@ export class ExcalidrawAutomate {
|
||||
const view = this.targetView;
|
||||
const scene = this.targetView.getScene(selectedOnly);
|
||||
|
||||
if(elementsOverride) {
|
||||
scene.elements = elementsOverride;
|
||||
}
|
||||
const exportSettings: ExportSettings = {
|
||||
withBackground: view.getViewExportWithBackground(withBackground),
|
||||
withTheme: true,
|
||||
@@ -1680,6 +1687,7 @@ export class ExcalidrawAutomate {
|
||||
);
|
||||
|
||||
if(dimensions && !formatting?.width) {
|
||||
|
||||
textElement.width = dimensions.width;
|
||||
textElement.height = dimensions.height;
|
||||
textElement.x = dimensions.x;
|
||||
@@ -3030,6 +3038,32 @@ export class ExcalidrawAutomate {
|
||||
return { withBackground, withTheme, isMask };
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Gets the elements within a specific area.
|
||||
* @param elements - The elements to check.
|
||||
* @param param1 - The area to check against.
|
||||
* @returns The elements within the area.
|
||||
*/
|
||||
getElementsInArea(
|
||||
elements: NonDeletedExcalidrawElement[],
|
||||
{x, y, width, height}:{
|
||||
x:number; y:number; width:number; height:number;
|
||||
}
|
||||
):ExcalidrawElement[] {
|
||||
return elements
|
||||
.filter(el => {
|
||||
if((el.type==="frame" && el.frameRole==="marker")) return false;
|
||||
const {topX, topY, width:w, height:h} = this.getBoundingBox([el]);
|
||||
const elLeft = topX;
|
||||
const elTop = topY;
|
||||
const elRight = topX + w;
|
||||
const elBottom = topY + h;
|
||||
// overlap exists if rectangles intersect
|
||||
return !(elLeft >= x + width || elRight <= x || elTop >= y + height || elBottom <= y);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the bounding box of the specified elements.
|
||||
* The bounding box is the box encapsulating all of the elements completely.
|
||||
|
||||
@@ -304,7 +304,11 @@ const RE_TEXTELEMENTS_FALLBACK_2 = /(.*)##? Text Elements(?:\n|$)/m;
|
||||
|
||||
const RE_DRAWING = /^(%%\n+)?##? Drawing\n/m;
|
||||
|
||||
export const getExcalidrawMarkdownHeaderSection = (data:string, keys?:[string,string][]):string => {
|
||||
export function getExcalidrawMarkdownHeader (data: string): {
|
||||
header: string,
|
||||
shouldFixTrailingHashtag: boolean,
|
||||
processingOk: boolean,
|
||||
} {
|
||||
//The base case scenario is at the top, continued with fallbacks in order of likelihood and file structure
|
||||
//change history for sake of backward compatibility
|
||||
|
||||
@@ -439,10 +443,18 @@ export const getExcalidrawMarkdownHeaderSection = (data:string, keys?:[string,st
|
||||
}
|
||||
}
|
||||
if (trimLocation === -1) {
|
||||
return data.endsWith("\n") ? data : (data + "\n");
|
||||
return {header:data.endsWith("\n") ? data : (data + "\n"), shouldFixTrailingHashtag, processingOk: false};
|
||||
}
|
||||
|
||||
let header = updateFrontmatterInString(data.substring(0, trimLocation),keys);
|
||||
return {header: data.substring(0, trimLocation), shouldFixTrailingHashtag, processingOk: true};
|
||||
}
|
||||
|
||||
export const getExcalidrawMarkdownHeaderSection = (data:string, keys?:[string,string][]):string => {
|
||||
|
||||
const {header, shouldFixTrailingHashtag, processingOk} = getExcalidrawMarkdownHeader(data);
|
||||
if(!processingOk) return header;
|
||||
|
||||
const updatedHeader = updateFrontmatterInString(header, keys);
|
||||
//this should be removed at a later time. Left it here to remediate 1.4.9 mistake
|
||||
/*const REG_IMG = /(^---[\w\W]*?---\n)(!\[\[.*?]]\n(%%\n)?)/m; //(%%\n)? because of 1.4.8-beta... to be backward compatible with anyone who installed that version
|
||||
if (header.match(REG_IMG)) {
|
||||
@@ -450,8 +462,8 @@ export const getExcalidrawMarkdownHeaderSection = (data:string, keys?:[string,st
|
||||
}*/
|
||||
//end of remove
|
||||
return shouldFixTrailingHashtag
|
||||
? header + "\n#\n"
|
||||
: header.endsWith("\n") ? header : (header + "\n");
|
||||
? updatedHeader + "\n#\n"
|
||||
: updatedHeader.endsWith("\n") ? header : (header + "\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -280,10 +280,17 @@ export async function getTemplate(
|
||||
}
|
||||
}
|
||||
if(filenameParts.hasFrameref || filenameParts.hasClippedFrameref) {
|
||||
const el = getFrameBasedOnFrameNameOrId(filenameParts.blockref,scene.elements);
|
||||
|
||||
const el = getFrameBasedOnFrameNameOrId(filenameParts.blockref,scene.elements);
|
||||
if(el) {
|
||||
groupElements = plugin.ea.getElementsInFrame(el,scene.elements, filenameParts.hasClippedFrameref);
|
||||
groupElements = el.frameRole === "marker"
|
||||
? plugin.ea.getElementsInArea(scene.elements, el).concat(el)
|
||||
: plugin.ea.getElementsInFrame(el,scene.elements, filenameParts.hasClippedFrameref);
|
||||
}
|
||||
}
|
||||
if(filenameParts.hasArearef) {
|
||||
const el=scene.elements.find((el: ExcalidrawElement)=>el.id===filenameParts.blockref);
|
||||
if(el) {
|
||||
groupElements = plugin.ea.getElementsInArea(scene.elements, el).concat(el);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,13 +558,21 @@ export async function createSVG(
|
||||
if (withTheme && theme === "dark") addFilterToForeignObjects(svg);
|
||||
|
||||
if(
|
||||
!(filenameParts.hasGroupref || filenameParts.hasFrameref || filenameParts.hasClippedFrameref) &&
|
||||
!(filenameParts.hasGroupref || filenameParts.hasClippedFrameref) &&
|
||||
(filenameParts.hasBlockref || filenameParts.hasSectionref)
|
||||
) {
|
||||
let el = filenameParts.hasSectionref
|
||||
? getTextElementsMatchingQuery(elements,["# "+filenameParts.sectionref],true)
|
||||
: elements.filter((el: ExcalidrawElement)=>el.id===filenameParts.blockref);
|
||||
if(el.length>0) {
|
||||
if(el.length === 0 && filenameParts.hasFrameref) {
|
||||
const frame = getFrameBasedOnFrameNameOrId(filenameParts.blockref, elements);
|
||||
if(frame) {
|
||||
el = [frame];
|
||||
}
|
||||
}
|
||||
const isNonMarkerFrameRef = filenameParts.hasFrameref && el.length === 1 && el[0].type === "frame" && el[0].frameRole !== "marker";
|
||||
|
||||
if(el.length>0 && !isNonMarkerFrameRef) {
|
||||
const containerId = el[0].containerId;
|
||||
if(containerId) {
|
||||
el = el.concat(elements.filter((el: ExcalidrawElement)=>el.id === containerId));
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
|
||||
import { MAX_IMAGE_SIZE, IMAGE_TYPES, ANIMATED_IMAGE_TYPES, MD_EX_SECTIONS } from "src/constants/constants";
|
||||
import { App, Modal, Notice, TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { App, Modal, Notice, TFile } from "obsidian";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { REGEX_LINK, REG_LINKINDEX_HYPERLINK, getExcalidrawMarkdownHeaderSection, REGEX_TAGS } from "../shared/ExcalidrawData";
|
||||
import { REGEX_LINK, REG_LINKINDEX_HYPERLINK, getExcalidrawMarkdownHeaderSection, REGEX_TAGS, getExcalidrawMarkdownHeader } from "../shared/ExcalidrawData";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { ExcalidrawElement, ExcalidrawFrameElement, ExcalidrawImageElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { getEmbeddedFilenameParts, getLinkParts, isImagePartRef } from "./utils";
|
||||
import { cleanSectionHeading } from "./obsidianUtils";
|
||||
import { getEA } from "src/core";
|
||||
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { AppState, ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
|
||||
import { nanoid } from "nanoid";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types";
|
||||
import { EmbeddedFile } from "src/shared/EmbeddedFileLoader";
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
|
||||
export async function insertImageToView(
|
||||
ea: ExcalidrawAutomate,
|
||||
@@ -209,8 +210,8 @@ export function getFrameBasedOnFrameNameOrId(
|
||||
): ExcalidrawFrameElement | null {
|
||||
const frames = elements
|
||||
.filter((el: ExcalidrawElement)=>el.type==="frame")
|
||||
.map((el: ExcalidrawFrameElement, idx: number)=>{
|
||||
return {el: el, id: el.id, name: el.name ?? `Frame ${String(idx+1).padStart(2,"0")}`};
|
||||
.map((el: ExcalidrawFrameElement)=>{
|
||||
return {el: el, id: el.id, name: el.name ?? "Frame"};
|
||||
})
|
||||
.filter((item:any) => item.id === frameName || item.name === frameName)
|
||||
.map((item:any)=>item.el as ExcalidrawFrameElement);
|
||||
@@ -465,4 +466,20 @@ export async function toggleImageAnchoring(
|
||||
}
|
||||
await ea.addElementsToView(false, false);
|
||||
ea.destroy();
|
||||
}
|
||||
|
||||
export function onLoadMessages(plugin: ExcalidrawPlugin, scene: {elements: ExcalidrawElement[], appState: AppState}, data: string) {
|
||||
setTimeout(() => {
|
||||
if(!(scene.appState.frameRendering?.markerEnabled ?? true) && scene.elements.some(el=>el.type === "frame" && el.frameRole === "marker")) {
|
||||
new Notice(t("MARKER_FRAME_RENDERING_DISABLED_NOTICE"));
|
||||
}
|
||||
/*const backOfTheCardNote = getExcalidrawMarkdownHeader(data)
|
||||
.header
|
||||
.replace(/^---\n[\s\S]*?\n---/gm, "")
|
||||
.replace("==⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠== You can decompress Drawing data with the command palette: 'Decompress current Excalidraw file'. For more info check in plugin settings under 'Saving'","")
|
||||
.trim();
|
||||
if(backOfTheCardNote.length>0) {
|
||||
new Notice(t("DRAWING_HAS_BACK_OF_THE_CARD"));
|
||||
}*/
|
||||
});
|
||||
}
|
||||
+244
-51
@@ -96,6 +96,10 @@ interface PrintToPDFOptions {
|
||||
scale: number;
|
||||
open: boolean;
|
||||
filepath: string;
|
||||
// Prefer CSS @page size over the numeric pageSize for mixed-size documents
|
||||
preferCSSPageSize?: boolean;
|
||||
// Exclude page ranges from output (Chromium/Electron supports either string "2-" or array)
|
||||
pageRanges?: string | { from: number; to: number }[];
|
||||
}
|
||||
|
||||
interface SaveDialogOptions {
|
||||
@@ -172,23 +176,54 @@ async function printPdf(
|
||||
bgColor: string,
|
||||
pageSize: PageSize | PageDimensions,
|
||||
isLandscape: boolean,
|
||||
margins: { top: number; left: number; right: number; bottom: number }
|
||||
margins: { top: number; left: number; right: number; bottom: number },
|
||||
shouldOpen: boolean = true,
|
||||
extraCss: string = "",
|
||||
pageRanges?: string | { from: number; to: number }[], // NEW
|
||||
): Promise<void> {
|
||||
const styleTag = document.createElement('style');
|
||||
styleTag.textContent = `
|
||||
@media print {
|
||||
/* Ensure the print root expands to the widest page and is not constrained by app layout */
|
||||
.print {
|
||||
background-color: ${bgColor} !important;
|
||||
display: flex !important;
|
||||
justify-content: center !important;
|
||||
align-items: center !important;
|
||||
display: block !important;
|
||||
width: max-content !important;
|
||||
max-width: none !important;
|
||||
overflow: visible !important;
|
||||
-webkit-print-color-adjust: exact !important;
|
||||
print-color-adjust: exact !important;
|
||||
flex-direction: column !important;
|
||||
page-break-before: always;
|
||||
margin: 0px !important;
|
||||
padding: 0px !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
position: static !important;
|
||||
transform: none !important;
|
||||
box-sizing: content-box !important;
|
||||
}
|
||||
.print > * {
|
||||
width: max-content !important;
|
||||
max-width: none !important;
|
||||
}
|
||||
.print-page {
|
||||
display: block !important;
|
||||
break-after: page !important;
|
||||
page-break-after: always !important;
|
||||
break-inside: avoid-page !important;
|
||||
overflow: visible !important;
|
||||
margin: 0 !important;
|
||||
position: relative !important;
|
||||
}
|
||||
/* Keep spacer tiny; it still establishes the initial page box */
|
||||
.print-page.dummy-first {
|
||||
width: 1px !important;
|
||||
height: 1px !important;
|
||||
}
|
||||
.print svg,
|
||||
.print img,
|
||||
.print canvas {
|
||||
max-width: none !important;
|
||||
max-height: none !important;
|
||||
}
|
||||
${extraCss}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(styleTag);
|
||||
@@ -206,8 +241,10 @@ async function printPdf(
|
||||
margins,
|
||||
scaleFactor: 100,
|
||||
scale: 1,
|
||||
open: true,
|
||||
open: shouldOpen,
|
||||
filepath: pdfPath,
|
||||
preferCSSPageSize: true,
|
||||
...(pageRanges ? { pageRanges } : {}), // NEW
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -256,8 +293,8 @@ function calculateDimensions(
|
||||
const mid = (low + high) / 2;
|
||||
const scaledWidth = svgWidth * mid;
|
||||
const scaledHeight = svgHeight * mid;
|
||||
const pages = Math.ceil(scaledWidth / availableWidth) *
|
||||
Math.ceil(scaledHeight / availableHeight);
|
||||
const pages = Math.ceil(scaledWidth / availableWidth) *
|
||||
Math.ceil(scaledHeight / availableHeight);
|
||||
|
||||
if (pages > scale.fitToPage) {
|
||||
high = mid;
|
||||
@@ -445,60 +482,216 @@ export async function exportToPDF({
|
||||
const savePath = await getSavePath(filename);
|
||||
if (!savePath) return;
|
||||
|
||||
const {width, height} = getPageSizePixels(pageProps.dimensions, false);
|
||||
const allPagesDiv = createDiv();
|
||||
allPagesDiv.style.width = "100%";
|
||||
allPagesDiv.style.height = "fit-content";
|
||||
// Decide if we should run multiple print jobs based on requested dimensions
|
||||
const dims = pageProps?.dimensions as any;
|
||||
const useMultiJob =
|
||||
!dims ||
|
||||
typeof dims.width !== "number" ||
|
||||
typeof dims.height !== "number" ||
|
||||
dims.width <= 0 ||
|
||||
dims.height <= 0;
|
||||
|
||||
let j = 0;
|
||||
for (const svg of SVG) {
|
||||
const svgWidth = parseFloat(svg.getAttribute('width') || '0');
|
||||
const svgHeight = parseFloat(svg.getAttribute('height') || '0');
|
||||
|
||||
const {tiles} = calculateDimensions(
|
||||
svg,
|
||||
svgWidth,
|
||||
svgHeight,
|
||||
pageProps.dimensions,
|
||||
pageProps.margin,
|
||||
scale,
|
||||
pageProps.alignment
|
||||
);
|
||||
// Single fixed-size job (existing behavior)
|
||||
if (!useMultiJob) {
|
||||
const allPagesDiv = createDiv();
|
||||
allPagesDiv.style.width = "100%";
|
||||
allPagesDiv.style.height = "fit-content";
|
||||
|
||||
let i = 0;
|
||||
for (const tile of tiles) {
|
||||
const pageDiv = createDiv();
|
||||
pageDiv.style.width = `${width}px`;
|
||||
pageDiv.style.height = `${height}px`;
|
||||
pageDiv.style.display = "flex";
|
||||
pageDiv.style.justifyContent = "start";
|
||||
pageDiv.style.alignItems = "left";
|
||||
pageDiv.style.padding = `${pageProps.margin.top}px ${pageProps.margin.right}px ${pageProps.margin.bottom}px ${pageProps.margin.left}px`;
|
||||
let j = 0;
|
||||
for (const svg of SVG) {
|
||||
const svgWidth = parseFloat(svg.getAttribute('width') || '0');
|
||||
const svgHeight = parseFloat(svg.getAttribute('height') || '0');
|
||||
|
||||
const clonedSVG = svg.cloneNode(true) as SVGSVGElement;
|
||||
clonedSVG.setAttribute('viewBox', tile.viewBox);
|
||||
clonedSVG.style.width = `${tile.width}px`;
|
||||
clonedSVG.style.height = `${tile.height}px`;
|
||||
clonedSVG.style.position = 'absolute';
|
||||
clonedSVG.style.left = `${tile.x}px`;
|
||||
clonedSVG.style.top = `${tile.y + (i+j)*height}px`;
|
||||
const pageDimForSvg: PageDimensions = pageProps.dimensions; // fixed size
|
||||
const { tiles } = calculateDimensions(
|
||||
svg,
|
||||
svgWidth,
|
||||
svgHeight,
|
||||
pageDimForSvg,
|
||||
pageProps.margin,
|
||||
scale,
|
||||
pageProps.alignment
|
||||
);
|
||||
|
||||
pageDiv.appendChild(clonedSVG);
|
||||
allPagesDiv.appendChild(pageDiv);
|
||||
i++;
|
||||
const { width: pageWidth, height: pageHeight } = getPageSizePixels(pageDimForSvg, false);
|
||||
|
||||
let i = 0;
|
||||
for (const tile of tiles) {
|
||||
const pageDiv = createDiv();
|
||||
pageDiv.addClass('print-page');
|
||||
|
||||
// NEW: content box sizing
|
||||
pageDiv.style.width = `${pageWidth}px`;
|
||||
pageDiv.style.height = `${pageHeight}px`;
|
||||
|
||||
pageDiv.style.display = "flex";
|
||||
pageDiv.style.justifyContent = "start";
|
||||
pageDiv.style.alignItems = "left";
|
||||
//pageDiv.style.padding = `${pageProps.margin.top}px ${pageProps.margin.right}px ${pageProps.margin.bottom}px ${pageProps.margin.left}px`;
|
||||
pageDiv.style.left = `${pageProps.margin.left}px`;
|
||||
pageDiv.style.top = `${pageProps.margin.top}px`;
|
||||
pageDiv.style.position = "relative";
|
||||
|
||||
const clonedSVG = svg.cloneNode(true) as SVGSVGElement;
|
||||
clonedSVG.setAttribute('viewBox', tile.viewBox);
|
||||
clonedSVG.style.width = `${tile.width}px`;
|
||||
clonedSVG.style.height = `${tile.height}px`;
|
||||
clonedSVG.style.position = 'absolute';
|
||||
|
||||
// NEW: position within padding box (subtract margins)
|
||||
clonedSVG.style.left = `${tile.x - pageProps.margin.left}px`;
|
||||
clonedSVG.style.top = `${tile.y - pageProps.margin.top}px`;
|
||||
|
||||
pageDiv.appendChild(clonedSVG);
|
||||
allPagesDiv.appendChild(pageDiv);
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
j++;
|
||||
|
||||
new Notice(t("EXPORTDIALOG_PDF_PROGRESS_NOTICE"));
|
||||
try {
|
||||
await printPdf(
|
||||
allPagesDiv,
|
||||
savePath,
|
||||
pageProps.backgroundColor || "#ffffff",
|
||||
pageProps.dimensions,
|
||||
false,
|
||||
{ top: 0, right: 0, bottom: 0, left: 0 },
|
||||
true,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to export to PDF: ", error);
|
||||
new Notice(t("EXPORTDIALOG_PDF_PROGRESS_ERROR"));
|
||||
}
|
||||
new Notice(t("EXPORTDIALOG_PDF_PROGRESS_DONE"));
|
||||
return;
|
||||
}
|
||||
|
||||
// Mixed-size single job using CSS @page rules
|
||||
new Notice(t("EXPORTDIALOG_PDF_PROGRESS_NOTICE"));
|
||||
try {
|
||||
const allPagesDiv = createDiv();
|
||||
allPagesDiv.style.width = "100%";
|
||||
allPagesDiv.style.height = "fit-content";
|
||||
|
||||
// Collect unique page sizes -> named @page rules
|
||||
const pageRuleNames = new Map<string, { name: string; w: number; h: number }>();
|
||||
const makeKey = (w: number, h: number) => `${w.toFixed(2)}x${h.toFixed(2)}`;
|
||||
const toIn = (px: number) => (px / DPI);
|
||||
const toCssName = (key: string) => `p_${key.replace(/[^\w-]/g, "_")}`;
|
||||
|
||||
for (const svg of SVG) {
|
||||
const svgWidth = parseFloat(svg.getAttribute('width') || '0');
|
||||
const svgHeight = parseFloat(svg.getAttribute('height') || '0');
|
||||
|
||||
const pageDimForSvg: PageDimensions = {
|
||||
width: svgWidth,
|
||||
height: svgHeight
|
||||
};
|
||||
|
||||
const key = makeKey(pageDimForSvg.width, pageDimForSvg.height);
|
||||
if (!pageRuleNames.has(key)) {
|
||||
pageRuleNames.set(key, { name: toCssName(key), w: pageDimForSvg.width, h: pageDimForSvg.height });
|
||||
}
|
||||
|
||||
const { tiles } = calculateDimensions(
|
||||
svg,
|
||||
svgWidth,
|
||||
svgHeight,
|
||||
pageDimForSvg,
|
||||
pageProps.margin,
|
||||
scale,
|
||||
pageProps.alignment
|
||||
);
|
||||
|
||||
const { width: pageWidth, height: pageHeight } = getPageSizePixels(pageDimForSvg, false);
|
||||
const pageClass = pageRuleNames.get(key)!.name;
|
||||
|
||||
for (const tile of tiles) {
|
||||
const pageDiv = createDiv();
|
||||
pageDiv.addClass('print-page');
|
||||
// bind to @page rule via page: <name>
|
||||
pageDiv.addClass(pageClass);
|
||||
pageDiv.style.setProperty('page', pageClass);
|
||||
|
||||
pageDiv.style.width = `${pageWidth}px`;
|
||||
pageDiv.style.height = `${pageHeight}px`;
|
||||
|
||||
pageDiv.style.display = "flex";
|
||||
pageDiv.style.justifyContent = "start";
|
||||
pageDiv.style.alignItems = "left";
|
||||
pageDiv.style.left = `${pageProps.margin.left}px`;
|
||||
pageDiv.style.top = `${pageProps.margin.top}px`;
|
||||
pageDiv.style.position = "relative";
|
||||
|
||||
const clonedSVG = svg.cloneNode(true) as SVGSVGElement;
|
||||
clonedSVG.setAttribute('viewBox', tile.viewBox);
|
||||
clonedSVG.style.width = `${tile.width}px`;
|
||||
clonedSVG.style.height = `${tile.height}px`;
|
||||
clonedSVG.style.position = 'absolute';
|
||||
|
||||
// Position within padding box: subtract margins from tile coordinates
|
||||
clonedSVG.style.left = `${tile.x - pageProps.margin.left}px`;
|
||||
clonedSVG.style.top = `${tile.y - pageProps.margin.top}px`;
|
||||
|
||||
pageDiv.appendChild(clonedSVG);
|
||||
allPagesDiv.appendChild(pageDiv);
|
||||
}
|
||||
}
|
||||
|
||||
// Build @page CSS with named sizes
|
||||
let extraCss = "";
|
||||
for (const { name, w, h } of pageRuleNames.values()) {
|
||||
extraCss += `
|
||||
@page ${name} {
|
||||
size: ${toIn(w)}in ${toIn(h)}in;
|
||||
margin: 0;
|
||||
}
|
||||
.print-page.${name} { page: ${name}; }
|
||||
`;
|
||||
}
|
||||
|
||||
// Determine a base numeric page size large enough for all pages
|
||||
let baseW = 0, baseH = 0;
|
||||
for (const { w, h } of pageRuleNames.values()) {
|
||||
baseW = Math.max(baseW, w);
|
||||
baseH = Math.max(baseH, h);
|
||||
}
|
||||
const basePageSize = { width: baseW || 800, height: baseH || 600 };
|
||||
|
||||
// Ensure we have a class for the base size
|
||||
const baseKey = makeKey(basePageSize.width, basePageSize.height);
|
||||
if (!pageRuleNames.has(baseKey)) {
|
||||
pageRuleNames.set(baseKey, { name: toCssName(baseKey), w: basePageSize.width, h: basePageSize.height });
|
||||
extraCss += `
|
||||
@page ${pageRuleNames.get(baseKey)!.name} {
|
||||
size: ${toIn(basePageSize.width)}in ${toIn(basePageSize.height)}in;
|
||||
margin: 0;
|
||||
}
|
||||
.print-page.${pageRuleNames.get(baseKey)!.name} { page: ${pageRuleNames.get(baseKey)!.name}; }
|
||||
`;
|
||||
}
|
||||
const baseClass = pageRuleNames.get(baseKey)!.name;
|
||||
|
||||
// Insert a dummy first page to prime Chromium with the largest page box
|
||||
const dummy = createDiv();
|
||||
dummy.addClass('print-page');
|
||||
dummy.addClass('dummy-first');
|
||||
dummy.addClass(baseClass);
|
||||
allPagesDiv.prepend(dummy);
|
||||
|
||||
// Kick a single print job, excluding the first (dummy) page
|
||||
await printPdf(
|
||||
allPagesDiv,
|
||||
savePath,
|
||||
pageProps.backgroundColor || "#ffffff",
|
||||
pageProps.dimensions,
|
||||
basePageSize,
|
||||
false,
|
||||
{ top: 0, right: 0, bottom: 0, left: 0 }
|
||||
{ top: 0, right: 0, bottom: 0, left: 0 },
|
||||
true,
|
||||
extraCss,
|
||||
"2-" // EXCLUDE PAGE 1, included to prime the Chromium page box
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to export to PDF: ", error);
|
||||
|
||||
+77
-34
@@ -296,50 +296,93 @@ export const openLeaf = ({
|
||||
}
|
||||
|
||||
export function mergeMarkdownFiles (template: string, target: string): string {
|
||||
// Extract frontmatter from the template
|
||||
const templateFrontmatterEnd = template.indexOf('---', 4); // Find end of frontmatter
|
||||
const templateFrontmatter = template.substring(4, templateFrontmatterEnd).trim();
|
||||
const templateContent = template.substring(templateFrontmatterEnd + 3); // Skip frontmatter and ---
|
||||
|
||||
// Parse template frontmatter
|
||||
const templateFrontmatterObj: FrontMatterCache = yaml.load(templateFrontmatter) || {};
|
||||
// Template frontmatter
|
||||
const templateFrontmatterEnd = template.indexOf('---', 4);
|
||||
const templateFrontmatterRaw = template.substring(4, templateFrontmatterEnd).trim();
|
||||
const templateContent = template.substring(templateFrontmatterEnd + 3);
|
||||
const templateFrontmatterObj: FrontMatterCache = yaml.load(templateFrontmatterRaw) || {};
|
||||
|
||||
// Extract frontmatter from the target if it exists
|
||||
let targetFrontmatterObj: FrontMatterCache = {};
|
||||
let targetContent = '';
|
||||
if (target.startsWith('---\n') && target.indexOf('---\n', 4) > 0) {
|
||||
const targetFrontmatterEnd = target.indexOf('---\n', 4); // Find end of frontmatter
|
||||
const targetFrontmatter = target.substring(4, targetFrontmatterEnd).trim();
|
||||
targetContent = target.substring(targetFrontmatterEnd + 3); // Skip frontmatter and ---
|
||||
const hasTargetFM = target.startsWith('---\n') && target.indexOf('---\n', 4) > 0;
|
||||
if (hasTargetFM) {
|
||||
const targetFrontmatterEnd = target.indexOf('---\n', 4);
|
||||
let targetFrontmatterRaw = target.substring(4, targetFrontmatterEnd).replace(/\s+$/,''); // keep as-is
|
||||
const targetContent = target.substring(targetFrontmatterEnd + 3);
|
||||
|
||||
// Parse target frontmatter
|
||||
targetFrontmatterObj = yaml.load(targetFrontmatter) || {};
|
||||
const targetFrontmatterObj: FrontMatterCache = yaml.load(targetFrontmatterRaw) || {};
|
||||
|
||||
// 1. Merge array keys present in both (target has precedence for ordering)
|
||||
const mergeArrayKeys = Object.keys(templateFrontmatterObj)
|
||||
.filter(k => Array.isArray(templateFrontmatterObj[k]) && Array.isArray(targetFrontmatterObj[k]));
|
||||
|
||||
if (mergeArrayKeys.length) {
|
||||
for (const k of mergeArrayKeys) {
|
||||
const tArr = targetFrontmatterObj[k] as any[];
|
||||
const tplArr = templateFrontmatterObj[k] as any[];
|
||||
const merged = [...tArr, ...tplArr.filter(v => !tArr.includes(v))];
|
||||
// Produce YAML for just this key
|
||||
const mergedYaml = yaml.dump({ [k]: merged }).trimEnd();
|
||||
targetFrontmatterRaw = replaceYamlKeyBlock(targetFrontmatterRaw, k, mergedYaml) ?? targetFrontmatterRaw;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Append only missing keys (not present in target)
|
||||
const newKeys: Record<string, any> = {};
|
||||
for (const k of Object.keys(templateFrontmatterObj)) {
|
||||
if (!(k in targetFrontmatterObj)) {
|
||||
newKeys[k] = templateFrontmatterObj[k];
|
||||
}
|
||||
}
|
||||
|
||||
const appended = Object.keys(newKeys).length
|
||||
? targetFrontmatterRaw + '\n' + yaml.dump(newKeys).trimEnd()
|
||||
: targetFrontmatterRaw;
|
||||
|
||||
return `---\n${appended}\n---\n${targetContent}\n\n${templateContent.trim()}\n`;
|
||||
} else {
|
||||
// If target doesn't have frontmatter, consider the entire content as target content
|
||||
targetContent = target.trim();
|
||||
// No frontmatter in target: use template FM + target content + template content
|
||||
const targetContent = target.trim();
|
||||
const templateFMYaml = yaml.dump(templateFrontmatterObj).trimEnd();
|
||||
return `---\n${templateFMYaml}\n---\n${targetContent}\n\n${templateContent.trim()}\n`;
|
||||
}
|
||||
};
|
||||
|
||||
// Merge frontmatter with target values taking precedence
|
||||
const mergedFrontmatter: FrontMatterCache = { ...templateFrontmatterObj };
|
||||
|
||||
// Merge arrays by combining and removing duplicates
|
||||
for (const key in targetFrontmatterObj) {
|
||||
if (Array.isArray(targetFrontmatterObj[key]) && Array.isArray(mergedFrontmatter[key])) {
|
||||
const combinedArray = [...new Set([...mergedFrontmatter[key], ...targetFrontmatterObj[key]])];
|
||||
mergedFrontmatter[key] = combinedArray;
|
||||
} else {
|
||||
mergedFrontmatter[key] = targetFrontmatterObj[key];
|
||||
// Helper: replace a top-level YAML key block (line-based, avoids partial matches causing duplicates)
|
||||
function replaceYamlKeyBlock(src: string, key: string, newBlock: string): string | null {
|
||||
const lines = src.split(/\r?\n/);
|
||||
let start = -1;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (new RegExp(`^${escapeRegex(key)}\\s*:`).test(lines[i])) {
|
||||
start = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start === -1) return null;
|
||||
|
||||
// Convert merged frontmatter back to YAML
|
||||
const mergedFrontmatterYaml = yaml.dump(mergedFrontmatter);
|
||||
let end = start + 1;
|
||||
while (end < lines.length) {
|
||||
const line = lines[end];
|
||||
if (line.trim() === "") { // blank line ends block (retain blank after replacement)
|
||||
break;
|
||||
}
|
||||
if (/^[^\s].*?:/.test(line)) { // next top-level key
|
||||
break;
|
||||
}
|
||||
if (!/^\s/.test(line)) { // safety: non-indented (shouldn't happen)
|
||||
break;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
|
||||
// Concatenate frontmatter and content
|
||||
const mergedMarkdown = `---\n${mergedFrontmatterYaml}---\n${targetContent}\n\n${templateContent.trim()}\n`;
|
||||
const before = lines.slice(0, start);
|
||||
const after = lines.slice(end);
|
||||
const replaced = [...before, newBlock, ...after].join('\n');
|
||||
|
||||
return mergedMarkdown;
|
||||
};
|
||||
return replaced;
|
||||
}
|
||||
|
||||
function escapeRegex(s: string) {
|
||||
return s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
export const editorInsertText = (editor: Editor, text: string)=> {
|
||||
const cursor = editor.getCursor();
|
||||
|
||||
@@ -132,7 +132,7 @@ import { getEA } from "src/core"
|
||||
import { anyModifierKeysPressed, emulateKeysForLinkClick, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, localFileDragModifierType, ModifierKeys, modifierKeyTooltipMessages } from "../utils/modifierkeyHelper";
|
||||
import { setDynamicStyle } from "../utils/dynamicStyling";
|
||||
import { CustomEmbeddable, renderWebView } from "./components/CustomEmbeddable";
|
||||
import { addBackOfTheNoteCard, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, openExternalLink, parseObsidianLink, renderContextMenuAction, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { addBackOfTheNoteCard, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, onLoadMessages, openExternalLink, parseObsidianLink, renderContextMenuAction, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { imageCache } from "../shared/ImageCache";
|
||||
import { CanvasNodeFactory, ObsidianCanvasNode } from "./managers/CanvasNodeFactory";
|
||||
import { EmbeddableMenu } from "./components/menu/EmbeddableActionsMenu";
|
||||
@@ -155,7 +155,6 @@ import { ImageInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { exportPNG, exportPNGToClipboard, exportSVG, exportToPDF, getMarginValue, getPageDimensions, PageOrientation, PageSize } from "src/utils/exportUtils";
|
||||
import { FrameRenderingOptions } from "src/types/utilTypes";
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { Backpack } from "lucide-react";
|
||||
|
||||
const EMBEDDABLE_SEMAPHORE_TIMEOUT = 2000;
|
||||
const PREVENT_RELOAD_TIMEOUT = 2000;
|
||||
@@ -2501,6 +2500,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
await this.loadDrawing(true);
|
||||
|
||||
onLoadMessages(this.plugin, this.excalidrawData.scene,this.data);
|
||||
|
||||
if(this.plugin.ea.onFileOpenHook) {
|
||||
const tempEA = getEA(this);
|
||||
try {
|
||||
@@ -2796,6 +2797,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//debug({where:"ExcalidrawView.loadDrawing",file:this.file.name,dataTheme:excalidrawData.appState.theme,before:"updateScene"})
|
||||
//api.setLocalFont(this.plugin.settings.experimentalEnableFourthFont);
|
||||
|
||||
|
||||
this.updateScene(
|
||||
{
|
||||
elements: excalidrawData.elements.concat(deletedElements??[]), //need to preserve deleted elements during autosave if images, links, etc. are updated
|
||||
@@ -2812,6 +2814,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
...this.excalidrawData.selectedElementIds //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/609
|
||||
? this.excalidrawData.selectedElementIds
|
||||
: {},
|
||||
...excalidrawData.appState.frameRendering && excalidrawData.appState.frameRendering.markerName === undefined
|
||||
? { frameRendering: {...excalidrawData.appState.frameRendering, markerName: true, markerEnabled: true } }
|
||||
: {},
|
||||
zenModeEnabled,
|
||||
viewModeEnabled,
|
||||
linkOpacity: this.excalidrawData.getLinkOpacity(),
|
||||
@@ -2841,6 +2846,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
elements: excalidrawData.elements,
|
||||
appState: {
|
||||
...excalidrawData.appState,
|
||||
...excalidrawData.appState.frameRendering && excalidrawData.appState.frameRendering.markerName === undefined
|
||||
? { frameRendering: {...excalidrawData.appState.frameRendering, markerName: true, markerEnabled: true } }
|
||||
: {},
|
||||
zenModeEnabled: om.zenModeEnabled,
|
||||
viewModeEnabled: excalidrawData.elements.length > 0 ? om.viewModeEnabled : false,
|
||||
linkOpacity: this.excalidrawData.getLinkOpacity(),
|
||||
@@ -3658,6 +3666,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
currentItemStartArrowhead: st.currentItemStartArrowhead,
|
||||
currentItemEndArrowhead: st.currentItemEndArrowhead,
|
||||
currentItemArrowType: st.currentItemArrowType,
|
||||
currentItemFrameRole: st.currentItemFrameRole,
|
||||
scrollX: st.scrollX,
|
||||
scrollY: st.scrollY,
|
||||
zoom: st.zoom,
|
||||
@@ -4978,6 +4987,44 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
onClose
|
||||
),
|
||||
])
|
||||
|
||||
if(
|
||||
!areElementsSelected &&
|
||||
elements.some(el=>el.type === "frame" && el.frameRole === "marker")
|
||||
) {
|
||||
const {frameRendering} = appState;
|
||||
contextMenuActions.push([
|
||||
renderContextMenuAction(
|
||||
React,
|
||||
frameRendering.markerEnabled && frameRendering.enabled && frameRendering.outline
|
||||
? t("MARKER_FRAME_HIDE")
|
||||
: t("MARKER_FRAME_SHOW"),
|
||||
() => {
|
||||
const markerEnabled = !(frameRendering.markerEnabled && frameRendering.enabled && frameRendering.outline);
|
||||
if(markerEnabled) {
|
||||
setTimeout(() => this.updateScene({appState: {frameRendering: {...frameRendering, enabled: true, outline: true, markerEnabled}}, captureUpdate: CaptureUpdateAction.NEVER}));
|
||||
} else {
|
||||
setTimeout(() => this.updateScene({appState: {frameRendering: {...frameRendering, markerEnabled}}, captureUpdate: CaptureUpdateAction.NEVER}));
|
||||
}
|
||||
},
|
||||
onClose
|
||||
),
|
||||
]);
|
||||
if(frameRendering.markerEnabled && frameRendering.enabled && frameRendering.outline) {
|
||||
contextMenuActions.push([
|
||||
renderContextMenuAction(
|
||||
React,
|
||||
frameRendering.markerName
|
||||
? t("MARKER_FRAME_TITLE_HIDE")
|
||||
: t("MARKER_FRAME_TITLE_SHOW"),
|
||||
() => {
|
||||
setTimeout(() => this.updateScene({appState: {frameRendering: {...frameRendering, markerName: !frameRendering.markerName}}, captureUpdate: CaptureUpdateAction.NEVER}));
|
||||
},
|
||||
onClose
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(contextMenuActions.length === 0) return;
|
||||
@@ -5909,6 +5956,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
|
||||
const frames = elements.filter(el=>el.type==="frame");
|
||||
const hasFrame = frames.length === 1;
|
||||
const hasMarkerFrame = hasFrame && frames[0].frameRole === "marker";
|
||||
const hasGroup = elements.some(el=>el.groupIds && el.groupIds.length>0);
|
||||
|
||||
let button = {
|
||||
@@ -5926,7 +5974,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
button.area,
|
||||
button.link,
|
||||
...hasGroup ? [button.group] : [],
|
||||
...hasFrame ? [button.frame, button.clippedframe] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
];
|
||||
break;
|
||||
case "group=":
|
||||
@@ -5934,12 +5983,14 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
...hasFrame ? [button.frame, button.clippedframe] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
];
|
||||
break;
|
||||
case "frame=":
|
||||
buttons = [
|
||||
...hasFrame ? [button.frame, button.clippedframe] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
@@ -5947,7 +5998,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
break;
|
||||
case "clippedframe=":
|
||||
buttons = [
|
||||
...hasFrame ? [button.clippedframe, button.frame] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
...hasGroup ? [button.group] : [],
|
||||
button.link,
|
||||
button.area,
|
||||
@@ -5958,7 +6010,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
{caption: "Link", action:()=>{prefix="";return}},
|
||||
{caption: "Area", action:()=>{prefix="area="; return;}},
|
||||
{caption: "Group", action:()=>{prefix="group="; return;}},
|
||||
...hasFrame ? [button.frame, button.clippedframe] : [],
|
||||
...hasFrame && !hasMarkerFrame ? [button.clippedframe] : [],
|
||||
...hasFrame ? [button.frame] : [],
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user