mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
Compare commits
68
Commits
2.14.1-beta-2
...
2.15.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccb5590f0c | ||
|
|
524c33a7e5 | ||
|
|
09bb5c5486 | ||
|
|
434f61653d | ||
|
|
613b86e9d0 | ||
|
|
a6cad5010e | ||
|
|
49cf799f66 | ||
|
|
662737436a | ||
|
|
887651a4bc | ||
|
|
c0a40c69a1 | ||
|
|
e69676f461 | ||
|
|
9582758483 | ||
|
|
a227c746a2 | ||
|
|
425d8304d5 | ||
|
|
1ee277c814 | ||
|
|
5a2cbadc9d | ||
|
|
f2d0c8c6b7 | ||
|
|
afecea3e67 | ||
|
|
a3b6acb0a7 | ||
|
|
a7f33f3be0 | ||
|
|
0ec5ad1bbb | ||
|
|
89f2a3beb5 | ||
|
|
88e27a35ef | ||
|
|
ea3103b650 | ||
|
|
59bbbb907d | ||
|
|
488daf0fde | ||
|
|
cf6128433d | ||
|
|
945afffc11 | ||
|
|
fe322f492e | ||
|
|
22eee5e37e | ||
|
|
5bf7271f86 | ||
|
|
1db4654fe2 | ||
|
|
3152ec2c58 | ||
|
|
1bd9a70635 | ||
|
|
4a775d81f4 | ||
|
|
a0630b4719 | ||
|
|
37ceca8ccd | ||
|
|
00acbce5f0 | ||
|
|
ea502134fd | ||
|
|
1c5daeafae | ||
|
|
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.
|
||||
|
||||
@@ -21,3 +21,6 @@ yarn.lock
|
||||
.DS_Store
|
||||
.lock
|
||||
.lock
|
||||
|
||||
# Obsidian files
|
||||
Obsidian
|
||||
@@ -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/29EWeglRm7s" 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/29EWeglRm7s' target='_blank'>Link to video on YouTube</a><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.1",
|
||||
"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.1",
|
||||
"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-37",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ if (!isLib) {
|
||||
? fs.readFileSync("./node_modules/@zsviczian/excalidraw/dist/styles.production.css", "utf8")
|
||||
: fs.readFileSync("./node_modules/@zsviczian/excalidraw/dist/styles.development.css", "utf8");
|
||||
const plugin_styles = fs.readFileSync("./styles.css", "utf8");
|
||||
const styles = plugin_styles + excalidraw_styles;
|
||||
const styles = excalidraw_styles + plugin_styles;
|
||||
cssnano()
|
||||
.process(styles) // Process the CSS
|
||||
.then(result => {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Copy, Crop, Globe, RotateCcw, Scan, Settings, TextSelect } from "lucide-react";
|
||||
import { Bookmark, Camera, Copy, Crop, Globe, RotateCcw, Scan, Settings, TextSelect } from "lucide-react";
|
||||
import * as React from "react";
|
||||
import { PenStyle } from "src/types/penTypes";
|
||||
|
||||
@@ -31,6 +31,8 @@ export const ICONS = {
|
||||
Copy: (<Copy /> ),
|
||||
Globe: (<Globe />),
|
||||
Crop: (<Crop />),
|
||||
Bookmark: (<Bookmark />),
|
||||
Camera: (<Camera />),
|
||||
ZoomToSelectedElement: (<Scan />),
|
||||
Properties: (<Settings />),
|
||||
ZoomToSection: (
|
||||
|
||||
@@ -234,6 +234,8 @@ export const IMAGE_TYPES = ["jpeg", "jpg", "png", "gif", "svg", "webp", "bmp", "
|
||||
export const ANIMATED_IMAGE_TYPES = ["gif", "webp", "apng", "svg"];
|
||||
export const EXPORT_TYPES = ["svg", "dark.svg", "light.svg", "png", "dark.png", "light.png"];
|
||||
export const MAX_IMAGE_SIZE = 500;
|
||||
export const CARD_WIDTH = 400;
|
||||
export const CARD_HEIGHT = 500;
|
||||
|
||||
export const VIDEO_TYPES = ["mp4", "webm", "ogv", "mov", "mkv"];
|
||||
export const AUDIO_TYPES = ["mp3", "wav", "m4a", "3gp", "flac", "ogg", "oga", "opus"];
|
||||
|
||||
+37
-1
@@ -40,7 +40,7 @@ import {
|
||||
} from "../constants/constants";
|
||||
import { ExcalidrawSettings, DEFAULT_SETTINGS, ExcalidrawSettingTab } from "./settings";
|
||||
import { ExcalidrawAutomate } from "../shared/ExcalidrawAutomate";
|
||||
import { initExcalidrawAutomate } from "src/utils/excalidrawAutomateUtils";
|
||||
import { initExcalidrawAutomate, insertLaTeXToView } from "src/utils/excalidrawAutomateUtils";
|
||||
import { around, dedupe } from "monkey-around";
|
||||
import { t } from "../lang/helpers";
|
||||
import {
|
||||
@@ -88,6 +88,8 @@ import { PackageManager } from "./managers/PackageManager";
|
||||
import ExcalidrawView from "../view/ExcalidrawView";
|
||||
import { CommandManager } from "./managers/CommandManager";
|
||||
import { EventManager } from "./managers/EventManager";
|
||||
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
|
||||
import en from "src/lang/locale/en";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare const INITIAL_TIMESTAMP: number;
|
||||
@@ -1077,6 +1079,15 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.eventManager.setDebounceActiveLeafChangeHandler();
|
||||
}
|
||||
|
||||
private getPathForFile(file: File) {
|
||||
let path = "";
|
||||
const { webUtils } = require('electron');
|
||||
if(webUtils && webUtils.getPathForFile) {
|
||||
path = webUtils.getPathForFile(file);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
public registerHotkeyOverrides() {
|
||||
//this is repeated here because the same function is called when settings is closed after hotkeys have changed
|
||||
if (this.popScope) {
|
||||
@@ -1446,4 +1457,29 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
public updateFileCache(file: TFile, frontmatter: FrontMatterCache) {
|
||||
this.fileManager.updateFileCache(file, frontmatter);
|
||||
}
|
||||
|
||||
//used by obsidianUtils in the Excalidraw Pacakge
|
||||
//aweful coding, but does the job
|
||||
public runAction(action: "anyFile" | "LaTeX" | "card") {
|
||||
if(!this.activeExcalidrawView) return;
|
||||
switch (action) {
|
||||
case "anyFile":
|
||||
this.activeExcalidrawView.setCurrentPositionToCenter();
|
||||
const insertFileModal = new UniversalInsertFileModal(this, this.activeExcalidrawView);
|
||||
insertFileModal.open();
|
||||
break;
|
||||
case "LaTeX":
|
||||
insertLaTeXToView(this.activeExcalidrawView, true);
|
||||
break;
|
||||
case "card":
|
||||
this.activeExcalidrawView.insertBackOfTheNoteCard(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//used by obsidianUtils in the Excalidraw Pacakge
|
||||
//aweful coding, but does the job
|
||||
public getLabel(key: keyof typeof en): string {
|
||||
return t(key);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -781,20 +781,19 @@ export class CommandManager {
|
||||
checkCallback: (checking:boolean) => this.plugin.forceSaveActiveView(checking),
|
||||
})
|
||||
|
||||
//removing raw mode. Not required. I never use it. Raw mode can still be enabled
|
||||
//via document properties. Only showing command palette action if raw mode is enabled
|
||||
this.addCommand({
|
||||
id: "toggle-lock",
|
||||
name: t("TOGGLE_LOCK"),
|
||||
checkCallback: (checking: boolean) => {
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (checking) {
|
||||
if (
|
||||
Boolean(this.app.workspace.getActiveViewOfType(ExcalidrawView))
|
||||
) {
|
||||
return !(this.app.workspace.getActiveViewOfType(ExcalidrawView))
|
||||
.compatibilityMode;
|
||||
if (view) {
|
||||
return !view.compatibilityMode && view.textMode === TextMode.raw;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
const view = this.app.workspace.getActiveViewOfType(ExcalidrawView);
|
||||
if (view && !view.compatibilityMode) {
|
||||
view.changeTextMode(
|
||||
view.textMode === TextMode.parsed ? TextMode.raw : TextMode.parsed,
|
||||
@@ -1281,7 +1280,7 @@ export class CommandManager {
|
||||
if(!excalidrawView.excalidrawAPI) return false;
|
||||
const embeddables = excalidrawView.getViewSelectedElements().filter(el=>el.type==="embeddable");
|
||||
const imageEls = excalidrawView.getViewSelectedElements().filter(el=>el.type==="image");
|
||||
const isPDF = (imageEls.length === 0 && embeddables.length === 1 && excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.leaf?.view?.getViewType() === "pdf")
|
||||
const isPDF = (imageEls.length === 0 && embeddables.length === 1 && excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.node?.child?.file?.extension === "pdf")
|
||||
const isImage = (imageEls.length === 1 && embeddables.length === 0)
|
||||
|
||||
if(!isPDF && !isImage) {
|
||||
@@ -1290,7 +1289,7 @@ export class CommandManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
const page = isPDF ? getActivePDFPageNumberFromPDFView(excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.leaf?.view) : undefined;
|
||||
const page = isPDF ? getActivePDFPageNumberFromPDFView(excalidrawView.getEmbeddableLeafElementById(embeddables[0].id)?.node?.child) : undefined;
|
||||
if(isPDF && !page) {
|
||||
return false;
|
||||
}
|
||||
@@ -1300,8 +1299,8 @@ export class CommandManager {
|
||||
if(isPDF) {
|
||||
const embeddableEl = embeddables[0] as ExcalidrawEmbeddableElement;
|
||||
const ea = new ExcalidrawAutomate(this.plugin,excalidrawView);
|
||||
const view = excalidrawView.getEmbeddableLeafElementById(embeddableEl.id)?.leaf?.view;
|
||||
const pdfFile: TFile = view && (view instanceof FileView) ? view.file : undefined;
|
||||
const view = excalidrawView.getEmbeddableLeafElementById(embeddableEl.id)?.node?.child;
|
||||
const pdfFile: TFile = view?.file;
|
||||
carveOutPDF(ea, embeddableEl, `${pdfFile?.path}#page=${page}`, pdfFile);
|
||||
return;
|
||||
}
|
||||
@@ -1707,15 +1706,19 @@ export class CommandManager {
|
||||
const PDFLink = this.plugin.getLastActivePDFPageLink(view.file);
|
||||
if(!PDFLink) return false;
|
||||
if(checking) return true;
|
||||
const ea = getEA(view);
|
||||
insertImageToView(
|
||||
ea,
|
||||
view.currentPosition,
|
||||
PDFLink,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
(async()=>{
|
||||
const ea = getEA(view) as ExcalidrawAutomate;
|
||||
const id = await insertImageToView(
|
||||
ea,
|
||||
view.currentPosition,
|
||||
PDFLink,
|
||||
undefined,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
ea.selectElementsInView([id]);
|
||||
ea.destroy()
|
||||
})();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import ExcalidrawPlugin from "src/core/main";
|
||||
import { CustomMutationObserver } from "src/utils/debugHelper";
|
||||
import { getExcalidrawViews, isObsidianThemeDark } from "src/utils/obsidianUtils";
|
||||
import { App, Notice, TFile } from "obsidian";
|
||||
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
|
||||
export class ObserverManager {
|
||||
private plugin: ExcalidrawPlugin;
|
||||
@@ -183,17 +184,20 @@ export class ObserverManager {
|
||||
//The user clicks settings, or "open another vault", or the command palette
|
||||
const modalContainerObserverFn: MutationCallback = async (m: MutationRecord[]) => {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(modalContainerObserverFn,`ExcalidrawPlugin.modalContainerObserverFn`, m);
|
||||
const view = this.plugin.activeExcalidrawView;
|
||||
if (
|
||||
(m.length !== 1) ||
|
||||
(m[0].type !== "childList") ||
|
||||
(m[0].addedNodes.length !== 1) ||
|
||||
(!this.plugin.activeExcalidrawView) ||
|
||||
this.plugin.activeExcalidrawView?.semaphores?.viewunload ||
|
||||
(!this.plugin.activeExcalidrawView?.isDirty())
|
||||
(!view) ||
|
||||
view.semaphores?.viewunload ||
|
||||
(!view.isDirty())
|
||||
) {
|
||||
return;
|
||||
}
|
||||
this.plugin.activeExcalidrawView.save();
|
||||
|
||||
const { errorMessage } = (view.excalidrawAPI as ExcalidrawImperativeAPI).getAppState();
|
||||
if (!errorMessage) this.plugin.activeExcalidrawView.save();
|
||||
};
|
||||
|
||||
this.modalContainerObserver = DEBUGGING
|
||||
|
||||
+64
-2
@@ -98,6 +98,7 @@ export interface ExcalidrawSettings {
|
||||
penModeDoubleTapEraser: boolean;
|
||||
penModeSingleFingerPanning: boolean;
|
||||
penModeCrosshairVisible: boolean;
|
||||
panWithRightMouseButton: boolean; //mfuria #329
|
||||
renderImageInMarkdownReadingMode: boolean,
|
||||
renderImageInHoverPreviewForMDNotes: boolean,
|
||||
renderImageInMarkdownToPDF: boolean,
|
||||
@@ -106,6 +107,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;
|
||||
@@ -283,6 +287,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
penModeDoubleTapEraser: true,
|
||||
penModeSingleFingerPanning: true,
|
||||
penModeCrosshairVisible: true,
|
||||
panWithRightMouseButton: false, //mfuria #329
|
||||
renderImageInMarkdownReadingMode: false,
|
||||
renderImageInHoverPreviewForMDNotes: false,
|
||||
renderImageInMarkdownToPDF: false,
|
||||
@@ -291,6 +296,9 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
zoomToFitOnOpen: true,
|
||||
zoomToFitOnResize: true,
|
||||
zoomToFitMaxLevel: 2,
|
||||
zoomStep: 0.05,
|
||||
zoomMin: 0.1,
|
||||
zoomMax: 30,
|
||||
linkPrefix: "📍",
|
||||
urlPrefix: "🌐",
|
||||
parseTODO: false,
|
||||
@@ -1357,9 +1365,24 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
|
||||
detailsEl = displayDetailsEl.createEl("details");
|
||||
detailsEl.createEl("summary", {
|
||||
text: t("ZOOM_HEAD"),
|
||||
text: t("ZOOM_AND_PAN_HEAD"), //mfuria #329
|
||||
cls: "excalidraw-setting-h3",
|
||||
});
|
||||
|
||||
//mfuria #329. Added setting for right-click panning
|
||||
new Setting(detailsEl)
|
||||
.setName(t("PAN_WITH_RIGHT_MOUSE_BUTTON_NAME"))
|
||||
.setDesc(fragWithHTML(t("PAN_WITH_RIGHT_MOUSE_BUTTON_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.panWithRightMouseButton)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.panWithRightMouseButton = value;
|
||||
this.applySettingsUpdate(true);
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("DEFAULT_PINCHZOOM_NAME"))
|
||||
.setDesc(fragWithHTML(t("DEFAULT_PINCHZOOM_DESC")))
|
||||
@@ -1425,6 +1448,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 +2637,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", {
|
||||
|
||||
+56
-2
@@ -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:
|
||||
@@ -134,6 +138,14 @@ export default {
|
||||
"2) Then create an empty drawing in a new pane by CTRL/CMD+clicking the Excalidraw ribbon button,\n" +
|
||||
"3) and paste your work to the new document with CTRL/CMD+V.",
|
||||
ARIA_LABEL_TRAY_MODE: "Tray-mode offers an alternative, more spacious canvas",
|
||||
TRAY_TRAY_MODE: "Toggle tray-mode",
|
||||
TRAY_SCRIPT_LIBRARY: "Script Library",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "Explore the Excalidraw Script Library",
|
||||
TRAY_EXPORT: "Export Image...",
|
||||
TRAY_EXPORT_ARIA: "Export image as PNG, SVG, or Excalidraw file",
|
||||
TRAY_SAVE: "Save",
|
||||
TRAY_SWITCH_TO_MD: "Open as Markdown",
|
||||
TRAY_SWITCH_TO_MD_ARIA: "Switch to markdown view",
|
||||
MASK_FILE_NOTICE: "This is a mask file. It is used to crop images and mask out parts of the image. Press and hold notice to open the help video.",
|
||||
INSTALL_SCRIPT_BUTTON: "Install or update Excalidraw Scripts",
|
||||
OPEN_AS_MD: "Open as Markdown",
|
||||
@@ -344,7 +356,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>",
|
||||
@@ -440,7 +452,9 @@ FILENAME_HEAD: "Filename",
|
||||
"conflict with Obsidian hotkey settings. The hotkey combinations you add below will override Obsidian's hotkey settings while using Excalidraw, thus " +
|
||||
`you can add <code>${labelCTRL()}+G</code> if you want to default to Group Object in Excalidraw instead of opening Graph View.`,
|
||||
THEME_HEAD: "Theme and styling",
|
||||
ZOOM_HEAD: "Zoom",
|
||||
ZOOM_AND_PAN_HEAD: "Zoom and Pan",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_NAME: "Right-click drag to pan",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_DESC: "Right-click and drag to pan the canvas (Miro-style). Press 'm' to open the context menu.",
|
||||
DEFAULT_PINCHZOOM_NAME: "Allow pinch zoom in pen mode",
|
||||
DEFAULT_PINCHZOOM_DESC:
|
||||
"Pinch zoom in pen mode when using the freedraw tool is disabled by default to prevent unwanted accidental zooming with your palm.<br>" +
|
||||
@@ -459,6 +473,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 +924,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" +
|
||||
@@ -1156,4 +1180,34 @@ FILENAME_HEAD: "Filename",
|
||||
|
||||
//exportUtils.ts
|
||||
PDF_EXPORT_DESKTOP_ONLY: "PDF export is only available on desktop",
|
||||
|
||||
//UniversalInsertFileModal.ts
|
||||
UIFM_TITLE: "Insert File From Vault",
|
||||
UIFM_SECTION_HEAD: "Select section heading",
|
||||
UIFM_ANCHOR: "Anchor to 100% of original size",
|
||||
UIFM_ANCHOR_DESC: "This is a pro feature, use it only if you understand how it works. If enabled even if you change the size of the imported image in Excalidraw, the next time you open the drawing this image will pop back to 100% size. This is useful when embedding an atomic Excalidraw idea into another note and preserving relative sizing of text and icons.",
|
||||
UIFM_BTN_EMBEDDABLE: "as Embeddable",
|
||||
UIFM_BTN_PDF: "as Pdf",
|
||||
UIFM_BTN_IMAGE: "as Image",
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "Welcome to Excalidraw",
|
||||
|
||||
//Excalidraw component
|
||||
COMP_IMG: "Image & Files",
|
||||
COMP_IMG_FROM_SYSTEM: "Import from system",
|
||||
COMP_IMG_ANY_FILE: "ANY file from Vault",
|
||||
COMP_IMG_LaTeX: "LaTeX formula",
|
||||
COMP_FRAME: "Frame Actions",
|
||||
COMP_FRAME_HINT: "Toggle Marker Frame. Guide-only frames to define slides/print areas/image references. " +
|
||||
"Hidden in image exports; doesn't contain elements. Hide/show frames via canvas context menu.",
|
||||
|
||||
//CustomEmbeddable.tsx
|
||||
NOTICE_PDF_THEME: "PDF theme overridden.\n" +
|
||||
"Control via this file's 'excalidraw-embeddable-theme' document property (overrides plugin).\n\n" +
|
||||
"Values: dark, light, auto=Excalidraw, default=Obsidian.",
|
||||
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "Save current position in document",
|
||||
CAPTURE_PAGE: "Capture current page as image",
|
||||
};
|
||||
+11
-2
@@ -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? " +
|
||||
@@ -439,7 +440,9 @@ FILENAME_HEAD: "Nombre de archivo",
|
||||
"entran en conflicto con la configuración de atajos de teclado de Obsidian. Las combinaciones de atajos de teclado que agregues a continuación anularán la configuración de atajos de teclado de Obsidian mientras usas Excalidraw. Por lo tanto, " +
|
||||
`puedes agregar <code>${labelCTRL()}+G</code> si quieres que el comportamiento predeterminado sea Agrupar Objeto en Excalidraw en lugar de abrir la Vista de Gráfico.`,
|
||||
THEME_HEAD: "Tema y estilo",
|
||||
ZOOM_HEAD: "Zoom",
|
||||
ZOOM_AND_PAN_HEAD: "Zoom y panorámica",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_NAME: "Desplazar el lienzo con el botón derecho del mouse (abrir menú con 'm')",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_DESC: "Cuando está habilitado, puedes desplazar el lienzo haciendo clic derecho y arrastrando. El menú contextual se abrirá con la tecla 'm', a menos que estés editando texto.",
|
||||
DEFAULT_PINCHZOOM_NAME: "Permitir zoom con pellizco en modo lápiz",
|
||||
DEFAULT_PINCHZOOM_DESC:
|
||||
"El zoom con pellizco en modo lápiz, al usar la herramienta de dibujo a mano alzada, está deshabilitado por defecto para evitar zooms accidentales no deseados con la palma de la mano.<br>" +
|
||||
@@ -458,6 +461,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",
|
||||
|
||||
@@ -345,7 +345,9 @@ FILENAME_HEAD: "Имя файла",
|
||||
"конфликтуют с настройками горячих клавиш Obsidian. Комбинации горячих клавиш, которые вы добавите ниже, отменят настройки горячих клавиш Obsidian при использовании Excalidraw, таким образом " +
|
||||
`Вы можете добавить <code>${labelCTRL()}+G</code>, если хотите по умолчанию перейти к Группе Объектов в Excalidraw вместо открытия Режима просмотра Графиков.`,
|
||||
THEME_HEAD: "Тема и стиль",
|
||||
ZOOM_HEAD: "Масштабирование",
|
||||
ZOOM_AND_PAN_HEAD: "Масштаб и панорамирование",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_NAME: "Перемещение холста правой кнопкой мыши (открыть меню с 'm')",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_DESC: "Когда этот параметр включен, вы можете перемещать холст, нажимая правую кнопку мыши и перетаскивая. Контекстное меню откроется с помощью клавиши 'm', если только вы не редактируете текст.",
|
||||
DEFAULT_PINCHZOOM_NAME: "Разрешить масштабирование в режиме пера",
|
||||
DEFAULT_PINCHZOOM_DESC:
|
||||
"По умолчанию зуммирование в режиме пера при использовании инструмента «Свободное рисование» отключено, чтобы предотвратить нежелательное случайное масштабирование с помощью ладони.<br>" +
|
||||
|
||||
+564
-513
File diff suppressed because it is too large.
Load diff
+172
-163
@@ -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>" +
|
||||
@@ -439,7 +440,9 @@ FILENAME_HEAD: "檔名",
|
||||
"與 Obsidian 的熱鍵設定發生衝突。您在下面新增的熱鍵組合將在使用 Excalidraw 時覆蓋 Obsidian 的熱鍵設定," +
|
||||
`因此如果您希望在 Excalidraw 中預設選擇“組合物件”,而不是開啟“圖形檢視”,您可以新增 ${labelCTRL()}+G。`,
|
||||
THEME_HEAD: "主題和樣式",
|
||||
ZOOM_HEAD: "縮放",
|
||||
ZOOM_AND_PAN_HEAD: "縮放與平移",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_NAME: "使用滑鼠右鍵平移畫布(按下 'm' 鍵開啟選單)",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_DESC: "啟用後,您可以通過右鍵點擊並拖動來平移畫布。當您不編輯文字時,將使用 'm' 鍵開啟上下文選單。",
|
||||
DEFAULT_PINCHZOOM_NAME: "允許在觸控筆模式下進行雙指縮放",
|
||||
DEFAULT_PINCHZOOM_DESC:
|
||||
"在觸控筆模式下使用自由畫筆工具時,雙指縮放可能造成干擾。<br>" +
|
||||
@@ -458,6 +461,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 +476,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 +634,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 +715,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 +743,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 +775,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 +956,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 +977,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 +1011,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 +1044,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 匯出功能僅限桌面端使用",
|
||||
};
|
||||
@@ -50,7 +50,7 @@ export class EmbeddableSettings extends Modal {
|
||||
this.zoomValue = element.scale[0];
|
||||
this.isYouTube = isYouTube(this.element.link);
|
||||
this.notExcalidrawIsInternal = this.file && !this.view.plugin.isExcalidrawFile(this.file)
|
||||
this.isMDFile = this.file && this.file.extension === "md"; // && !this.view.plugin.isExcalidrawFile(this.file);
|
||||
this.isMDFile = this.file && this.file.extension.toLowerCase() === "md"; // && !this.view.plugin.isExcalidrawFile(this.file);
|
||||
this.isLocalURI = this.element.link.startsWith("file://");
|
||||
if(isYouTube) this.youtubeStart = getYouTubeStartAt(this.element.link);
|
||||
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { App, FuzzySuggestModal, TFile } from "obsidian";
|
||||
import { REG_LINKINDEX_INVALIDCHARS } from "../../constants/constants";
|
||||
import { t } from "../../lang/helpers";
|
||||
|
||||
export class InsertCommandDialog extends FuzzySuggestModal<TFile> {
|
||||
|
||||
@@ -17,16 +17,125 @@ 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.1":`
|
||||
## Fixed
|
||||
- PDF improvements
|
||||
- It was not possible to scroll the embedded PDF. [#9891](https://github.com/excalidraw/excalidraw/pull/9891)
|
||||
- Embedded PDF pages were blurred (pixelated).
|
||||
- Embedded PDF now accurately follows \`excalidraw-embeddable-theme\` document property.
|
||||
- auto: follows Excalidraw theme (regardless of Obsidian theme)
|
||||
- default: follows Obsidian theme (regardless of Excalidraw theme)
|
||||
- dark: always displays the PDF in dark mode (regardless of Excalidraw and Obsidian themes)
|
||||
- light: always displays the PDF in light mode (regardless of Excalidraw and Obsidian themes)
|
||||
- New embeddable-menu buttons:
|
||||
- Snapshot: inserts an image of the current active page to the scene
|
||||
- Bookmark: updates the embed link to the current page
|
||||
- Pasting an oversized image triggered an error and caused Excalidraw to discard the scene. [#2453](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2453), [#9878](https://github.com/excalidraw/excalidraw/issues/9878)
|
||||
- Video with local URI will no longer autoplay when the scene loads
|
||||
- Error creating link to element when element is a sticky note
|
||||
- Area link embeds hide the content of the objects within the area [#2461](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2461)
|
||||
- On Obsidian Mobile 1.9.10, embeddables could cause a black/white screen (no active view) until reselecting the Excalidraw page; [#2460](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2460)
|
||||
- Scrolling of embedded web pages on mobile devices is working again.
|
||||
|
||||
## 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.
|
||||
- Insert Any File now supports adding Audio files.
|
||||
- New option in settings under "Zoom and Pan". Pan with right mouse button (Miro-style): right-click and drag to pan the canvas. Press 'm' for the context menu (disabled while editing text). 🙏 [@mfuria](https://github.com/mfuria) for making this happen! [#2450](https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/2450), [#329](https://github.com/zsviczian/excalidraw/pull/329)
|
||||
- Insert image in the main toolbar now opens a dropdown menu of options: Insert from system, insert from Vault, insert Card, and insert LaTeX. [#2448](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2448)
|
||||
|
||||
## Deprecated
|
||||
- Removed "Toggle RAW mode" from the Command Palette and the Obsidian Tools menu due to low usage. RAW mode remains available by adding \`excalidraw-plugin: raw\` to the note's YAML frontmatter/document properties.
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
\`\`\`ts
|
||||
/**
|
||||
* Returns the center position of the current view in Excalidraw coordinates.
|
||||
* @returns {{x:number, y:number}} The center position of the view.
|
||||
*/
|
||||
public getViewCenterPosition(): {x:number, y:number};
|
||||
\`\`\`
|
||||
`,
|
||||
"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
|
||||
- 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
|
||||
|
||||
@@ -2,6 +2,7 @@ import { App, MarkdownRenderer, Modal } from "obsidian";
|
||||
import { isVersionNewerThanOther } from "src/utils/utils";
|
||||
import ExcalidrawPlugin from "../../core/main";
|
||||
import { FIRST_RUN, RELEASE_NOTES } from "./Messages";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -16,10 +17,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(`${t("RN_WELCOME")} ${this.version ?? ""}`);
|
||||
this.createForm();
|
||||
|
||||
if(headerEl) headerEl.style.pointerEvents = "none"; // Disable pointer events on header to allow clicks through
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
|
||||
@@ -3,10 +3,11 @@ import { t } from "../../lang/helpers";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { getEA } from "src/core";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { MD_EX_SECTIONS } from "src/constants/constants";
|
||||
import { CARD_HEIGHT, CARD_WIDTH, MD_EX_SECTIONS } from "src/constants/constants";
|
||||
import { addBackOfTheNoteCard } from "src/utils/excalidrawViewUtils";
|
||||
|
||||
export class SelectCard extends FuzzySuggestModal<string> {
|
||||
private center: boolean = false;
|
||||
|
||||
constructor(
|
||||
public app: App,
|
||||
@@ -31,7 +32,7 @@ export class SelectCard extends FuzzySuggestModal<string> {
|
||||
this.close();
|
||||
return;
|
||||
}
|
||||
addBackOfTheNoteCard(this.view, item);
|
||||
addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
@@ -48,18 +49,28 @@ export class SelectCard extends FuzzySuggestModal<string> {
|
||||
|
||||
onChooseItem(item: string): void {
|
||||
const ea = getEA(this.view) as ExcalidrawAutomate;
|
||||
let x,y = 0;
|
||||
if(this.center) {
|
||||
const centerPos = ea.getViewCenterPosition();
|
||||
if(centerPos) {
|
||||
x = centerPos.x - (CARD_WIDTH / 2);
|
||||
y = centerPos.y - (CARD_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
|
||||
const id = ea.addEmbeddable(
|
||||
0,0,400,500,
|
||||
x,y,CARD_WIDTH,CARD_HEIGHT,
|
||||
`[[${this.view.file.path}#${item}]]`
|
||||
);
|
||||
(async () => {
|
||||
await ea.addElementsToView(true, false, true);
|
||||
await ea.addElementsToView(!this.center, false, true);
|
||||
ea.selectElementsInView([id]);
|
||||
ea.destroy();
|
||||
})();
|
||||
}
|
||||
|
||||
public start(): void {
|
||||
public start(center: boolean = false): void {
|
||||
this.center = center;
|
||||
this.emptyStateText = t("EMPTY_SECTION_MESSAGE");
|
||||
this.setPlaceholder(t("SELECT_SECTION_OR_TYPE_NEW"));
|
||||
this.open();
|
||||
|
||||
@@ -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,};",
|
||||
@@ -826,6 +832,12 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
desc: "@returns the last recorded pointer position on the Excalidraw canvas",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "getViewCenterPosition",
|
||||
code: "getViewCenterPosition(): {x: number, y: number};",
|
||||
desc: "@returns the center position of the current view in Excalidraw coordinates",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
field: "getleaf",
|
||||
code: "getLeaf(origo: WorkspaceLeaf, targetPane?: PaneTarget): WorkspaceLeaf;",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ButtonComponent, DropdownComponent, TFile, ToggleComponent } from "obsidian";
|
||||
import { ButtonComponent, DropdownComponent, TFile } from "obsidian";
|
||||
import ExcalidrawView from "../../view/ExcalidrawView";
|
||||
import ExcalidrawPlugin from "../../core/main";
|
||||
import { Modal, Setting, TextComponent } from "obsidian";
|
||||
@@ -10,6 +10,7 @@ import { InsertPDFModal } from "./InsertPDFModal";
|
||||
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { cleanSectionHeading } from "src/utils/obsidianUtils";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
export class UniversalInsertFileModal extends Modal {
|
||||
private center: { x: number, y: number } = { x: 0, y: 0 };
|
||||
@@ -61,7 +62,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
|
||||
onOpen(): void {
|
||||
this.containerEl.classList.add("excalidraw-release");
|
||||
this.titleEl.setText(`Insert File From Vault`);
|
||||
this.titleEl.setText(t("UIFM_TITLE"));
|
||||
this.createForm();
|
||||
}
|
||||
|
||||
@@ -155,15 +156,15 @@ export class UniversalInsertFileModal extends Modal {
|
||||
});
|
||||
|
||||
sectionPickerSetting = new Setting(ce)
|
||||
.setName("Select section heading")
|
||||
.setName(t("UIFM_SECTION_HEAD"))
|
||||
.addDropdown(dropdown => {
|
||||
sectionPicker = dropdown;
|
||||
sectionPicker.selectEl.style.width = "100%";
|
||||
})
|
||||
|
||||
sizeToggleSetting = new Setting(ce)
|
||||
.setName("Anchor to 100% of original size")
|
||||
.setDesc("This is a pro feature, use it only if you understand how it works. If enabled even if you change the size of the imported image in Excalidraw, the next time you open the drawing this image will pop back to 100% size. This is useful when embedding an atomic Excalidraw idea into another note and preserving relative sizing of text and icons.")
|
||||
.setName(t("UIFM_ANCHOR"))
|
||||
.setDesc(t("UIFM_ANCHOR_DESC"))
|
||||
.addToggle(toggle => {
|
||||
toggle.setValue(anchorTo100)
|
||||
.onChange((value) => {
|
||||
@@ -174,7 +175,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
new Setting(ce)
|
||||
.addButton(button => {
|
||||
button
|
||||
.setButtonText("as Embeddable")
|
||||
.setButtonText(t("UIFM_BTN_EMBEDDABLE"))
|
||||
.onClick(async () => {
|
||||
const path = this.app.metadataCache.fileToLinktext(
|
||||
file,
|
||||
@@ -198,7 +199,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
})
|
||||
.addButton(button => {
|
||||
button
|
||||
.setButtonText("as Pdf")
|
||||
.setButtonText(t("UIFM_BTN_PDF"))
|
||||
.onClick(() => {
|
||||
const insertPDFModal = new InsertPDFModal(this.plugin, this.view);
|
||||
insertPDFModal.open(file);
|
||||
@@ -208,7 +209,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
})
|
||||
.addButton(button => {
|
||||
button
|
||||
.setButtonText("as Image")
|
||||
.setButtonText(t("UIFM_BTN_IMAGE"))
|
||||
.onClick(async () => {
|
||||
const ea:ExcalidrawAutomate = getEA(this.view);
|
||||
const isMarkdown = file && file.extension === "md" && !ea.isExcalidrawFile(file);
|
||||
|
||||
@@ -201,6 +201,10 @@ export class EmbeddedFile {
|
||||
}
|
||||
}
|
||||
|
||||
get hasSeparateDarkAndLightVersion(): boolean {
|
||||
return this.isSVGwithBitmap || (this.file && this.file.extension.toLowerCase() === "pdf");
|
||||
}
|
||||
|
||||
public resetImage(hostPath: string, imgPath: string) {
|
||||
this.imgInverted = this.img = "";
|
||||
this.mtime = 0;
|
||||
@@ -278,11 +282,12 @@ export class EmbeddedFile {
|
||||
if (this.fileChanged()) {
|
||||
this.imgInverted = this.img = "";
|
||||
}
|
||||
this.isSVGwithBitmap = isSVGwithBitmap;
|
||||
this.mtime = this.isHyperLink || this.isLocalLink ? 0 : this.file.stat.mtime;
|
||||
this.pdfPageViewProps = pdfPageViewProps;
|
||||
this.size = size;
|
||||
this.mimeType = mimeType;
|
||||
switch (isDark && isSVGwithBitmap) {
|
||||
switch (isDark && this.hasSeparateDarkAndLightVersion) {
|
||||
case true:
|
||||
this.imgInverted = imgBase64;
|
||||
break;
|
||||
@@ -290,7 +295,6 @@ export class EmbeddedFile {
|
||||
this.img = imgBase64;
|
||||
break; //bitmaps and SVGs without an embedded bitmap do not need a negative image
|
||||
}
|
||||
this.isSVGwithBitmap = isSVGwithBitmap;
|
||||
}
|
||||
|
||||
public isLoaded(isDark: boolean): boolean {
|
||||
@@ -309,7 +313,7 @@ export class EmbeddedFile {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (this.isSVGwithBitmap && isDark) {
|
||||
if (this.hasSeparateDarkAndLightVersion && isDark) {
|
||||
return this.imgInverted !== "";
|
||||
}
|
||||
return this.img !== "";
|
||||
@@ -319,7 +323,7 @@ export class EmbeddedFile {
|
||||
if (!this.file && !this.isHyperLink && !this.isLocalLink) {
|
||||
return "";
|
||||
}
|
||||
if (isDark && this.isSVGwithBitmap) {
|
||||
if (this.hasSeparateDarkAndLightVersion && isDark) {
|
||||
return this.imgInverted;
|
||||
}
|
||||
return this.img; //images that are not SVGwithBitmap, only the light string is stored, since inverted and non-inverted are ===
|
||||
@@ -608,7 +612,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,
|
||||
@@ -675,7 +679,7 @@ export class EmbeddedFilesLoader {
|
||||
};
|
||||
files[batch].push(fileData);
|
||||
}
|
||||
} else if (embeddedFile.isSVGwithBitmap && (depth !== 0 || isThemeChange)) {
|
||||
} else if (embeddedFile.hasSeparateDarkAndLightVersion && (depth !== 0 || isThemeChange)) {
|
||||
//this will reload the image in light/dark mode when switching themes
|
||||
const fileData: FileData = {
|
||||
mimeType: embeddedFile.mimeType,
|
||||
@@ -927,6 +931,26 @@ export class EmbeddedFilesLoader {
|
||||
|
||||
const canvas = await renderPage(pageNum);
|
||||
if(canvas) {
|
||||
// NEW: invert colors for dark theme (keep alpha unchanged)
|
||||
if (this.isDark) {
|
||||
const ctx = canvas.getContext('2d');
|
||||
if (ctx) {
|
||||
try {
|
||||
const img = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
const data = img.data;
|
||||
for (let i = 0; i < data.length; i += 4) {
|
||||
data[i] = 255 - data[i]; // R
|
||||
data[i + 1] = 255 - data[i+1]; // G
|
||||
data[i + 2] = 255 - data[i+2]; // B
|
||||
// alpha channel (data[i+3]) remains unchanged
|
||||
}
|
||||
ctx.putImageData(img, 0, 0);
|
||||
} catch (e) {
|
||||
// If reading pixel data fails, silently fallback to non-inverted
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const result: [DataURL,Size, PDFPageViewProps] = [`data:image/png;base64,${await new Promise((resolve, reject) => {
|
||||
canvas.toBlob(async (blob) => {
|
||||
const dataURL = await blobToBase64(blob);
|
||||
@@ -1215,11 +1239,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) {
|
||||
|
||||
@@ -89,6 +89,7 @@ import { FrameRenderingOptions } from "src/types/utilTypes";
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { AutoexportConfig } from "src/types/excalidrawViewTypes";
|
||||
import { FloatingModal } from "./Dialogs/FloatingModal";
|
||||
import { patchMobileView } from "src/utils/customEmbeddableUtils";
|
||||
|
||||
extendPlugins([
|
||||
HarmonyPlugin,
|
||||
@@ -555,6 +556,25 @@ export class ExcalidrawAutomate {
|
||||
return this.targetView.currentPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the center position of the current view in Excalidraw coordinates.
|
||||
* @returns {{x:number, y:number}} The center position of the view.
|
||||
*/
|
||||
public getViewCenterPosition(): {x:number, y:number} {
|
||||
if (!this.targetView || !this.targetView?._loaded) {
|
||||
errorMessage("targetView not set", "getExcalidrawAPI()");
|
||||
return null;
|
||||
}
|
||||
const st = (this.getExcalidrawAPI() as ExcalidrawImperativeAPI).getAppState();
|
||||
if (!st) return null;
|
||||
|
||||
const zoom = st.zoom?.value ?? 1;
|
||||
const x = -st.scrollX + (st.width / 2) / zoom;
|
||||
const y = -st.scrollY + (st.height / 2) / zoom;
|
||||
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Excalidraw API for the current view or the view provided.
|
||||
* @param {ExcalidrawView} [view] - The view to get the API for.
|
||||
@@ -832,59 +852,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 +1062,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 +1073,7 @@ export class ExcalidrawAutomate {
|
||||
selectedOnly = false,
|
||||
skipInliningFonts = false,
|
||||
embedScene = false,
|
||||
elementsOverride,
|
||||
} : {
|
||||
withBackground?: boolean,
|
||||
theme?: "light" | "dark",
|
||||
@@ -1059,6 +1082,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 +1091,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,
|
||||
@@ -1291,6 +1318,7 @@ export class ExcalidrawAutomate {
|
||||
boundElements: [] as any,
|
||||
link,
|
||||
locked: false,
|
||||
frameId: null as string,
|
||||
...scale ? {scale} : {},
|
||||
};
|
||||
}
|
||||
@@ -1680,6 +1708,7 @@ export class ExcalidrawAutomate {
|
||||
);
|
||||
|
||||
if(dimensions && !formatting?.width) {
|
||||
|
||||
textElement.width = dimensions.width;
|
||||
textElement.height = dimensions.height;
|
||||
textElement.x = dimensions.x;
|
||||
@@ -1926,10 +1955,12 @@ export class ExcalidrawAutomate {
|
||||
image.size.width,
|
||||
image.size.height,
|
||||
);
|
||||
this.elementsDict[id].fileId = fileId;
|
||||
this.elementsDict[id].scale = [1, 1];
|
||||
const newEl = this.elementsDict[id] as Mutable<ExcalidrawImageElement>;
|
||||
newEl.fileId = fileId;
|
||||
newEl.scale = [1, 1];
|
||||
newEl.crop = null;
|
||||
if(!scale && anchor) {
|
||||
this.elementsDict[id].customData = {isAnchored: true}
|
||||
newEl.customData = {isAnchored: true}
|
||||
};
|
||||
return id;
|
||||
};
|
||||
@@ -2726,8 +2757,11 @@ export class ExcalidrawAutomate {
|
||||
errorMessage("targetView not set", "addElementsToView()");
|
||||
return false;
|
||||
}
|
||||
const elements = this.getElements();
|
||||
return await this.targetView.addElements({
|
||||
const elements = this.getElements();
|
||||
if(elements.some(el=>el.type === "embeddable")) {
|
||||
patchMobileView(this.targetView);
|
||||
}
|
||||
const result = await this.targetView.addElements({
|
||||
newElements: elements,
|
||||
repositionToCursor,
|
||||
save,
|
||||
@@ -2735,6 +2769,7 @@ export class ExcalidrawAutomate {
|
||||
newElementsOnTop,
|
||||
shouldRestoreElements,
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -3030,6 +3065,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[],
|
||||
element: NonDeletedExcalidrawElement,
|
||||
):ExcalidrawElement[] {
|
||||
const {x, y, width, height, id} = element;
|
||||
return elements
|
||||
.filter(el => {
|
||||
if((el.type==="frame" && el.frameRole==="marker")) return false;
|
||||
if(el.id === id) return true;
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { DEVICE, REG_LINKINDEX_INVALIDCHARS } from "src/constants/constants";
|
||||
import { getParentOfClass } from "./obsidianUtils";
|
||||
import { App, Notice, TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { App, TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { getLinkParts } from "./utils";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
|
||||
@@ -13,6 +13,7 @@ export const leafMap = new Map<string, WorkspaceLeaf>();
|
||||
|
||||
//This is definitely not the right solution, feels like sticking plaster
|
||||
//patch disappearing content on mobile
|
||||
//based on obsidian app.js, obsidian is looking for activeEditor, but active editor is in a leaf that is disconnected from root
|
||||
export const patchMobileView = (view: ExcalidrawView) => {
|
||||
if(DEVICE.isDesktop) return;
|
||||
console.log("patching mobile view");
|
||||
@@ -21,6 +22,14 @@ export const patchMobileView = (view: ExcalidrawView) => {
|
||||
if(!parent.hasClass("mod-visible")) {
|
||||
parent.addClass("mod-visible");
|
||||
}
|
||||
//create observer here
|
||||
const observer = new MutationObserver(() => {
|
||||
if(!parent.hasClass("mod-visible")) {
|
||||
parent.addClass("mod-visible");
|
||||
}
|
||||
});
|
||||
observer.observe(parent, { attributes: true, attributeFilter: ["class"] });
|
||||
window.setTimeout(() => observer.disconnect(), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,15 +67,14 @@ export const generateEmbeddableLink = (src: string, theme: "light" | "dark"):str
|
||||
}
|
||||
|
||||
export function setFileToLocalGraph(app: App, file: TFile) {
|
||||
let lgv;
|
||||
let lgv: any;
|
||||
app.workspace.iterateAllLeaves((l) => {
|
||||
if (l.view?.getViewType() === "localgraph") lgv = l.view;
|
||||
});
|
||||
if(!lgv) return;
|
||||
try {
|
||||
//@ts-ignore
|
||||
const loadFile = lgv?.loadFile;
|
||||
if (loadFile) {
|
||||
loadFile(file);
|
||||
if (lgv.loadFile && lgv.file !== file) {
|
||||
lgv.loadFile(file);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -42,6 +42,7 @@ import { SVGColorInfo } from "src/types/excalidrawAutomateTypes";
|
||||
import { ExcalidrawData, getExcalidrawMarkdownHeaderSection, REGEX_LINK } from "src/shared/ExcalidrawData";
|
||||
import { getFrameBasedOnFrameNameOrId } from "./excalidrawViewUtils";
|
||||
import { ScriptEngine } from "src/shared/Scripts";
|
||||
import { getEA } from "src/core";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
|
||||
@@ -280,10 +281,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,13 +559,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));
|
||||
@@ -628,9 +644,9 @@ export function repositionElementsToCursor(
|
||||
return restore({elements}, null, null).elements;
|
||||
}
|
||||
|
||||
export const insertLaTeXToView = (view: ExcalidrawView) => {
|
||||
export const insertLaTeXToView = (view: ExcalidrawView, center: boolean = false) => {
|
||||
const app = view.plugin.app;
|
||||
const ea = view.plugin.ea;
|
||||
const ea = getEA(view) as ExcalidrawAutomate;
|
||||
GenericInputPrompt.Prompt(
|
||||
view,
|
||||
view.plugin,
|
||||
@@ -641,13 +657,19 @@ export const insertLaTeXToView = (view: ExcalidrawView) => {
|
||||
undefined,
|
||||
3
|
||||
).then(async (formula: string) => {
|
||||
if (!formula) {
|
||||
return;
|
||||
if (formula) {
|
||||
const id = await ea.addLaTex(0, 0, formula);
|
||||
if(center) {
|
||||
const el = ea.getElement(id);
|
||||
let {width, height} = el;
|
||||
let {x, y} = ea.getViewCenterPosition();
|
||||
el.x = x - width / 2;
|
||||
el.y = y - height / 2;
|
||||
}
|
||||
await ea.addElementsToView(!center, false, true);
|
||||
ea.selectElementsInView([id]);
|
||||
}
|
||||
ea.reset();
|
||||
await ea.addLaTex(0, 0, formula);
|
||||
ea.setView(view);
|
||||
ea.addElementsToView(true, false, true);
|
||||
ea.destroy();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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 { MAX_IMAGE_SIZE, IMAGE_TYPES, ANIMATED_IMAGE_TYPES, MD_EX_SECTIONS, AUDIO_TYPES, CARD_WIDTH, CARD_HEIGHT } from "src/constants/constants";
|
||||
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 { cleanSectionHeading, getAudioElementHeight } 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,
|
||||
@@ -65,11 +66,20 @@ export async function insertEmbeddableToView (
|
||||
if(file && (IMAGE_TYPES.contains(file.extension) || ea.isExcalidrawFile(file)) && !ANIMATED_IMAGE_TYPES.contains(file.extension)) {
|
||||
return await insertImageToView(ea, position, link??file, undefined, shouldInsertToView);
|
||||
} else {
|
||||
let height = MAX_IMAGE_SIZE;
|
||||
if (
|
||||
(file && AUDIO_TYPES.contains(file.extension.toLowerCase())) ||
|
||||
(link && AUDIO_TYPES.contains(link.match(/\[\[[^\]]+?\.([^\.\]]+)]]/)?.[1]?.toLocaleLowerCase()))
|
||||
) {
|
||||
ea.style.strokeColor = "transparent";
|
||||
ea.style.backgroundColor = "transparent";
|
||||
height = getAudioElementHeight();
|
||||
}
|
||||
const id = ea.addEmbeddable(
|
||||
position.x,
|
||||
position.y,
|
||||
MAX_IMAGE_SIZE,
|
||||
MAX_IMAGE_SIZE,
|
||||
height,
|
||||
link,
|
||||
file,
|
||||
);
|
||||
@@ -209,8 +219,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);
|
||||
@@ -223,6 +233,7 @@ export async function addBackOfTheNoteCard(
|
||||
activate: boolean = true,
|
||||
cardBody?: string,
|
||||
embeddableCustomData?: EmbeddableMDCustomProps,
|
||||
center: boolean = false,
|
||||
):Promise<string> {
|
||||
const data = view.data;
|
||||
const header = getExcalidrawMarkdownHeaderSection(data);
|
||||
@@ -252,13 +263,22 @@ export async function addBackOfTheNoteCard(
|
||||
}
|
||||
|
||||
const ea = getEA(view) as ExcalidrawAutomate;
|
||||
let x,y = 0;
|
||||
if(center) {
|
||||
const centerPos = ea.getViewCenterPosition();
|
||||
if(centerPos) {
|
||||
x = centerPos.x - (CARD_WIDTH / 2);
|
||||
y = centerPos.y - (CARD_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
|
||||
const id = ea.addEmbeddable(
|
||||
0,0,400,500,
|
||||
x,y,CARD_WIDTH,CARD_HEIGHT,
|
||||
`[[${view.file.path}#${title}]]`,
|
||||
undefined,
|
||||
embeddableCustomData
|
||||
);
|
||||
await ea.addElementsToView(true, false, true);
|
||||
await ea.addElementsToView(!center, false, true);
|
||||
|
||||
const api = view.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
const el = ea.getViewElements().find(el=>el.id === id);
|
||||
@@ -465,4 +485,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);
|
||||
|
||||
+126
-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();
|
||||
@@ -412,4 +455,53 @@ export function isUnwantedLeaf(leaf:WorkspaceLeaf):boolean {
|
||||
leaf.view?.getViewType() === "empty" && leaf.parent && !leaf.parent.parent &&
|
||||
//@ts-ignore
|
||||
leaf.parent.type === "split" && leaf.parent.children.length === 1
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the height of an audio element in Obsidian's CSS environment
|
||||
* @returns The height of the audio element in pixels
|
||||
*/
|
||||
export function getAudioElementHeight(): number {
|
||||
// Create a temporary audio element with controls
|
||||
const audioElement = document.createElement("audio");
|
||||
audioElement.controls = true;
|
||||
audioElement.src = "data:audio/wav;base64,UklGRigAAABXQVZFZm10IBIAAAABAAEARKwAAIhYAQACABAAAABkYXRhAgAAAAEA"; // Minimal valid audio
|
||||
|
||||
// Create a wrapper to avoid affecting page layout
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.style.position = "absolute";
|
||||
wrapper.style.left = "-9999px";
|
||||
wrapper.style.visibility = "hidden";
|
||||
wrapper.style.pointerEvents = "none";
|
||||
wrapper.appendChild(audioElement);
|
||||
|
||||
// Add to document to allow CSS to be applied
|
||||
document.body.appendChild(wrapper);
|
||||
|
||||
// Get height
|
||||
let height = 0;
|
||||
try {
|
||||
// Force layout calculation
|
||||
document.body.offsetHeight;
|
||||
|
||||
// Get height from bounding rect
|
||||
const rect = audioElement.getBoundingClientRect();
|
||||
height = rect.height;
|
||||
|
||||
// Fallback to computed style if bounding rect returns 0
|
||||
if (height === 0) {
|
||||
const computedStyle = window.getComputedStyle(audioElement);
|
||||
height = parseFloat(computedStyle.height) || 0;
|
||||
|
||||
// If still 0, try measuring the wrapper
|
||||
if (height === 0) {
|
||||
height = wrapper.getBoundingClientRect().height;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
// Clean up
|
||||
document.body.removeChild(wrapper);
|
||||
}
|
||||
|
||||
return Math.round(height);
|
||||
}
|
||||
+3
-1
@@ -625,6 +625,8 @@ export function getLinkParts (fname: string, file?: TFile): LinkParts {
|
||||
const REG = /(^[^#\|]*)#?(\^)?([^\|]*)?\|?(\d*)x?(\d*)/;
|
||||
const parts = fname.match(REG);
|
||||
const isBlockRef = parts[2] === "^";
|
||||
let page = parseInt(parts[3]?.match(/page=(\d*)/)?.[1]);
|
||||
page = isNaN(page) ? null : page;
|
||||
return {
|
||||
original: fname,
|
||||
path: file && (parts[1] === "") ? file.path : parts[1],
|
||||
@@ -634,7 +636,7 @@ export function getLinkParts (fname: string, file?: TFile): LinkParts {
|
||||
: isBlockRef ? cleanBlockRef(parts[3]) : cleanSectionHeading(parts[3]),
|
||||
width: parts[4] ? parseInt(parts[4]) : undefined,
|
||||
height: parts[5] ? parseInt(parts[5]) : undefined,
|
||||
page: parseInt(parts[3]?.match(/page=(\d*)/)?.[1])
|
||||
page,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+84
-24
@@ -109,6 +109,7 @@ import {
|
||||
arrayToMap,
|
||||
addAppendUpdateCustomData,
|
||||
getFilePathFromObsidianURL,
|
||||
getLinkParts,
|
||||
} from "../utils/utils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getActivePDFPageNumberFromPDFView, getAttachmentsFolderAndFilePath, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
@@ -132,7 +133,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 +156,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;
|
||||
@@ -1650,11 +1650,11 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
t("RAW"),
|
||||
() => this.changeTextMode(TextMode.parsed),
|
||||
);
|
||||
this.actionButtons['isParsed'] = this.addAction(
|
||||
/*this.actionButtons['isParsed'] = this.addAction(
|
||||
TEXT_DISPLAY_PARSED_ICON_NAME,
|
||||
t("PARSED"),
|
||||
() => this.changeTextMode(TextMode.raw),
|
||||
);
|
||||
);*/
|
||||
|
||||
this.actionButtons['link'] = this.addAction("link", t("OPEN_LINK"), (ev) =>
|
||||
this.handleLinkClick(ev),
|
||||
@@ -1846,10 +1846,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.textMode = textMode;
|
||||
if (textMode === TextMode.parsed) {
|
||||
this.actionButtons['isRaw'].hide();
|
||||
this.actionButtons['isParsed'].show();
|
||||
//this.actionButtons['isParsed'].hide();
|
||||
} else {
|
||||
this.actionButtons['isRaw'].show();
|
||||
this.actionButtons['isParsed'].hide();
|
||||
//this.actionButtons['isParsed'].hide();
|
||||
}
|
||||
if (this.toolsPanelRef && this.toolsPanelRef.current) {
|
||||
this.toolsPanelRef.current.setPreviewMode(textMode === TextMode.parsed);
|
||||
@@ -2501,6 +2501,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 +2798,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 +2815,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 +2847,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 +3667,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,
|
||||
@@ -4423,8 +4433,14 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
ea.selectElementsInView([await insertEmbeddableToView (ea, center, file, link)]);
|
||||
ea.destroy();
|
||||
} else {
|
||||
const modal = new UniversalInsertFileModal(this.plugin, this);
|
||||
modal.open(file, center);
|
||||
const linkParts = getLinkParts(link);
|
||||
if(linkParts.page) {
|
||||
const path = file.path + "#" + link.split("#")[1];
|
||||
ea.selectElementsInView([await insertImageToView (ea, center, path)]);
|
||||
} else {
|
||||
const modal = new UniversalInsertFileModal(this.plugin, this);
|
||||
modal.open(file, center);
|
||||
}
|
||||
}
|
||||
this.setDirty(9);
|
||||
}
|
||||
@@ -4627,12 +4643,12 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
return {imageEl: el, embeddedFile: imageFile};
|
||||
}
|
||||
|
||||
public async insertBackOfTheNoteCard() {
|
||||
public async insertBackOfTheNoteCard(center: boolean = false) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.insertBackOfTheNoteCard, "ExcalidrawView.insertBackOfTheNoteCard");
|
||||
await this.forceSave(true);
|
||||
const sections = await this.getBackOfTheNoteSections();
|
||||
const selectCardDialog = new SelectCard(this.app,this,sections);
|
||||
selectCardDialog.start();
|
||||
selectCardDialog.start(center);
|
||||
}
|
||||
|
||||
public async moveBackOfTheNoteCardToFile(id?: string) {
|
||||
@@ -4978,6 +4994,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;
|
||||
@@ -5262,7 +5316,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
"aria-label": t("ARIA_LABEL_TRAY_MODE"),
|
||||
onSelect: ()=> this.toggleTrayMode(),
|
||||
},
|
||||
"Toggle tray-mode"
|
||||
t("TRAY_TRAY_MODE")
|
||||
) : null,
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
@@ -5271,34 +5325,34 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
"aria-label": t("FORCE_SAVE"),
|
||||
onSelect: ()=> this.forceSave(),
|
||||
},
|
||||
"Save"
|
||||
t("TRAY_SAVE")
|
||||
),
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
icon: ICONS.scriptEngine,
|
||||
"aria-label": "Explore the Excalidraw Script Library",
|
||||
"aria-label": t("TRAY_SCRIPT_LIBRARY_ARIA"),
|
||||
onSelect: ()=> this.actionOpenScriptInstallPrompt(),
|
||||
},
|
||||
"Script Library"
|
||||
t("TRAY_SCRIPT_LIBRARY")
|
||||
),
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
icon: ICONS.ExportImage,
|
||||
"aria-label": "Export image as PNG, SVG, or Excalidraw file",
|
||||
"aria-label": t("TRAY_EXPORT_ARIA"),
|
||||
onSelect: ()=> this.actionOpenExportImageDialog(),
|
||||
},
|
||||
"Export Image..."
|
||||
t("TRAY_EXPORT")
|
||||
),
|
||||
React.createElement(
|
||||
MainMenu.Item,
|
||||
{
|
||||
icon: ICONS.switchToMarkdown,
|
||||
"aria-label": "Switch to markdown view",
|
||||
"aria-label": t("TRAY_SWITCH_TO_MD_ARIA"),
|
||||
onSelect: ()=> this.openAsMarkdown(),
|
||||
},
|
||||
"Open as Markdown"
|
||||
t("TRAY_SWITCH_TO_MD")
|
||||
),
|
||||
React.createElement(MainMenu.Separator),
|
||||
React.createElement(MainMenu.DefaultItems.Help),
|
||||
@@ -5894,7 +5948,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(elements.length === 2) {
|
||||
const textEl = elements.filter(el=>el.type==="text");
|
||||
if(textEl.length===1 && (textEl[0] as ExcalidrawTextElement).containerId) {
|
||||
const container = elements.filter(el=>el.boundElements.some(be=>be.type==="text"))
|
||||
const container = elements.filter(el=>el.boundElements && el.boundElements.some(be=>be.type==="text"))
|
||||
if(container.length===1) {
|
||||
elementId = textEl[0].id;
|
||||
}
|
||||
@@ -5909,6 +5963,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 +5981,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 +5990,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 +6005,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 +6017,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] : [],
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { Notice, WorkspaceLeaf, WorkspaceSplit } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { ConstructableWorkspaceSplit, getContainerForDocument, isObsidianThemeDark } from "src/utils/obsidianUtils";
|
||||
import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES } from "src/constants/constants";
|
||||
import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES, VIEW_TYPE_EXCALIDRAW } from "src/constants/constants";
|
||||
import { ExcalidrawImperativeAPI, UIAppState } from "@zsviczian/excalidraw/types/excalidraw/types";
|
||||
import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
|
||||
import { processLinkText, patchMobileView, setFileToLocalGraph } from "src/utils/customEmbeddableUtils";
|
||||
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
const CANVAS_VIEWTYPES = new Set(["markdown", "bases"]);
|
||||
const CANVAS_VIEWTYPES = new Set(["markdown", "bases", "audio", "video", "pdf"]);
|
||||
|
||||
declare module "obsidian" {
|
||||
interface Workspace {
|
||||
@@ -21,6 +22,17 @@ declare module "obsidian" {
|
||||
}
|
||||
}
|
||||
|
||||
let noticeTimer: number;
|
||||
function showNoticeOnce(message: string) {
|
||||
if (noticeTimer) {
|
||||
return
|
||||
}
|
||||
noticeTimer = window.setTimeout(() => {
|
||||
noticeTimer = undefined;
|
||||
}, 1000);
|
||||
new Notice(message,6000);
|
||||
}
|
||||
|
||||
function getTheme (view: ExcalidrawView, theme:string): string {
|
||||
return view.excalidrawData.embeddableTheme === "dark"
|
||||
? "theme-dark"
|
||||
@@ -31,6 +43,220 @@ function getTheme (view: ExcalidrawView, theme:string): string {
|
||||
: isObsidianThemeDark() ? "theme-dark" : "theme-light";
|
||||
}
|
||||
|
||||
function setPDFViewTheme(view: ExcalidrawView, pdfView: any) {
|
||||
if(!pdfView) return;
|
||||
if(view.excalidrawData.embeddableTheme === "auto") {
|
||||
pdfView.viewer?.child?.pdfViewer?.setBackground?.(null, false);
|
||||
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container");
|
||||
if(pdfContainerEl) {
|
||||
pdfContainerEl.classList.remove("mod-themed");
|
||||
}
|
||||
const thumbnailViewEl = pdfView.containerEl?.querySelector(".pdf-thumbnail-view");
|
||||
if(thumbnailViewEl) {
|
||||
thumbnailViewEl.style.filter = "var(--theme-filter)";
|
||||
}
|
||||
} else {
|
||||
const pdfViewerEl = pdfView.containerEl?.querySelector("div.pdfViewer");
|
||||
if(pdfViewerEl) {
|
||||
pdfViewerEl.addClass("mod-nofilter");
|
||||
}
|
||||
}
|
||||
if(["dark", "light"].includes(view.excalidrawData.embeddableTheme)) {
|
||||
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container");
|
||||
if(pdfContainerEl && !pdfContainerEl.classList.contains("mod-themed")) {
|
||||
pdfContainerEl.classList.add("mod-themed");
|
||||
}
|
||||
}
|
||||
if(view.excalidrawData.embeddableTheme === "light") {
|
||||
pdfView.viewer?.child?.pdfViewer?.setBackground?.(null, false);
|
||||
}
|
||||
if(view.excalidrawData.embeddableTheme === "dark") {
|
||||
pdfView.viewer?.child?.pdfViewer?.setBackground?.(
|
||||
document.body.getCssPropertyValue("--color-base-00"), true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// New: carve out PDF setup logic
|
||||
function setupPdfViewEnhancements(
|
||||
view: ExcalidrawView,
|
||||
leafRef: React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
|
||||
pdfObserverRef: React.MutableRefObject<MutationObserver | null> & { currentCleanup?: () => void },
|
||||
pdfObserverDisabledRef: React.MutableRefObject<boolean>
|
||||
) {
|
||||
const pdfView = leafRef.current?.node?.child;
|
||||
if (!pdfView) return;
|
||||
|
||||
const patchPDF = () => {
|
||||
// Disable observer while applying the theme to avoid loops
|
||||
pdfObserverDisabledRef.current = true;
|
||||
setPDFViewTheme(view, pdfView);
|
||||
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
|
||||
|
||||
// Observe inline height changes on the PDF root container and reset them
|
||||
// this could be an obsidian bug, should be revisted later 2025-08-23
|
||||
const containerEl = pdfView.containerEl as HTMLElement | null;
|
||||
let prevHeight = containerEl?.style?.height || "";
|
||||
let heightObserver: MutationObserver | null = null;
|
||||
if (containerEl) {
|
||||
heightObserver = new MutationObserver(() => {
|
||||
const h = containerEl.style.height || "";
|
||||
if (h !== prevHeight) {
|
||||
prevHeight = h;
|
||||
if (h) {
|
||||
containerEl.style.height = "";
|
||||
prevHeight = "";
|
||||
}
|
||||
}
|
||||
});
|
||||
heightObserver.observe(containerEl, { attributes: true, attributeFilter: ["style"] });
|
||||
}
|
||||
|
||||
// Transform-aware MMB drag-to-scroll (bypasses Chromium autoscroll)
|
||||
const scroller = pdfView.containerEl?.querySelector(".pdf-viewer-container") || null;
|
||||
let active = false;
|
||||
let lastX = 0, lastY = 0;
|
||||
let scaleX = 1, scaleY = 1;
|
||||
|
||||
const getScaleFromAncestor = (target: Element | null) => {
|
||||
// Read scale from the outer excalidraw embeddable container transform
|
||||
const container = target?.closest(".excalidraw__embeddable-container") as HTMLElement | null;
|
||||
if (!container) return { sx: 1, sy: 1 };
|
||||
const t = getComputedStyle(container).transform;
|
||||
// t can be "none", "matrix(a,b,c,d,tx,ty)" or "matrix3d(...)"
|
||||
if (!t || t === "none") return { sx: 1, sy: 1 };
|
||||
if (t.startsWith("matrix3d(")) {
|
||||
// matrix3d: m11=a1, m12=b1, m21=a2, m22=b2 in the first 6 entries
|
||||
const m = t.slice(9, -1).split(",").map(Number);
|
||||
const a = m[0], b = m[1], c = m[4], d = m[5];
|
||||
// scaleX = length of first column, scaleY = length of second column
|
||||
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
|
||||
}
|
||||
if (t.startsWith("matrix(")) {
|
||||
const m = t.slice(7, -1).split(",").map(Number); // [a,b,c,d,tx,ty]
|
||||
const a = m[0], b = m[1], c = m[2], d = m[3];
|
||||
return { sx: Math.hypot(a, b) || 1, sy: Math.hypot(c, d) || 1 };
|
||||
}
|
||||
return { sx: 1, sy: 1 };
|
||||
};
|
||||
|
||||
const onPointerDownCapture = (e: PointerEvent) => {
|
||||
if ((
|
||||
(DEVICE.isDesktop && e.button !== 1) ||
|
||||
(DEVICE.isMobile && e.button !== 0)) ||
|
||||
!scroller) return;
|
||||
// Start custom pan, cancel browser autoscroll and prevent Excalidraw from handling it.
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
active = true;
|
||||
lastX = e.clientX;
|
||||
lastY = e.clientY;
|
||||
|
||||
const { sx, sy } = getScaleFromAncestor(scroller);
|
||||
scaleX = sx;
|
||||
scaleY = sy;
|
||||
|
||||
// Listen on window so we keep panning even if we leave the element.
|
||||
window.addEventListener("pointermove", onPointerMove, { capture: true });
|
||||
window.addEventListener("pointerup", onPointerUp, { capture: true, once: true });
|
||||
window.addEventListener("pointercancel", onPointerUp, { capture: true, once: true });
|
||||
|
||||
try { (view.contentEl as HTMLElement).style.cursor = "grabbing"; } catch {}
|
||||
};
|
||||
|
||||
const onPointerMove = (e: PointerEvent) => {
|
||||
if (!active || !scroller) return;
|
||||
// Continue only while the pointer button is held:
|
||||
// - Desktop: middle mouse button (bit 3 = 4)
|
||||
// - Mobile: primary/left button (bit 0 = 1)
|
||||
if (
|
||||
(DEVICE.isDesktop && (e.buttons & 4) === 0) ||
|
||||
(DEVICE.isMobile && (e.buttons & 1) === 0)
|
||||
) return;
|
||||
|
||||
const dx = e.clientX - lastX;
|
||||
const dy = e.clientY - lastY;
|
||||
lastX = e.clientX;
|
||||
lastY = e.clientY;
|
||||
|
||||
// Convert viewport dx/dy to local CSS px by dividing on scale.
|
||||
scroller.scrollLeft -= dx / (scaleX || 1);
|
||||
scroller.scrollTop -= dy / (scaleY || 1);
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
const onPointerUp = (_e: PointerEvent) => {
|
||||
active = false;
|
||||
try { (view.contentEl as HTMLElement).style.cursor = ""; } catch {}
|
||||
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
|
||||
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
|
||||
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
|
||||
};
|
||||
|
||||
const root = pdfView.containerEl as HTMLElement;
|
||||
root?.addEventListener("pointerdown", onPointerDownCapture, { capture: true });
|
||||
|
||||
const cleanupPan = () => {
|
||||
root?.removeEventListener("pointerdown", onPointerDownCapture, { capture: true } as any);
|
||||
window.removeEventListener("pointermove", onPointerMove, { capture: true } as any);
|
||||
window.removeEventListener("pointerup", onPointerUp, { capture: true } as any);
|
||||
window.removeEventListener("pointercancel", onPointerUp,{ capture: true } as any);
|
||||
heightObserver?.disconnect();
|
||||
heightObserver = null;
|
||||
};
|
||||
(pdfObserverRef as any).currentCleanup = () => { cleanupPan(); };
|
||||
|
||||
if (view.excalidrawData.embeddableTheme !== "default") {
|
||||
const pdfContainerEl = pdfView.containerEl?.querySelector(".pdf-container") as HTMLElement | null;
|
||||
if (pdfContainerEl) {
|
||||
pdfObserverRef.current?.disconnect();
|
||||
pdfObserverRef.current = new MutationObserver(() => {
|
||||
if (pdfObserverDisabledRef.current) return;
|
||||
pdfObserverDisabledRef.current = true;
|
||||
try {
|
||||
setPDFViewTheme(view, pdfView);
|
||||
if(view.excalidrawData.embeddableTheme !== "default") {
|
||||
showNoticeOnce(t("NOTICE_PDF_THEME"));
|
||||
}
|
||||
} finally {
|
||||
requestAnimationFrame(() => { pdfObserverDisabledRef.current = false; });
|
||||
}
|
||||
});
|
||||
pdfObserverRef.current.observe(pdfContainerEl, {
|
||||
attributes: true,
|
||||
attributeFilter: ["class"],
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const root = leafRef?.current?.node?.child?.containerEl;
|
||||
if (root) {
|
||||
const selector = ".pdf-viewer-container";
|
||||
const existing = root.querySelector(selector);
|
||||
if (existing) {
|
||||
patchPDF();
|
||||
} else {
|
||||
let timeoutId:number = null as any;
|
||||
const mo = new MutationObserver((_, obs) => {
|
||||
const el = root.querySelector(selector);
|
||||
if (el) {
|
||||
patchPDF();
|
||||
obs.disconnect();
|
||||
if (timeoutId) clearTimeout(timeoutId);
|
||||
}
|
||||
});
|
||||
mo.observe(root as HTMLElement, { childList: true, subtree: true });
|
||||
timeoutId = window.setTimeout(() => {
|
||||
mo.disconnect();
|
||||
}, 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//Render webview for anything other than Vimeo and Youtube
|
||||
//Vimeo and Youtube are rendered by Excalidraw because of the window messaging
|
||||
@@ -46,6 +272,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
|
||||
title="Excalidraw Embedded Content"
|
||||
allowFullScreen={true}
|
||||
src={src}
|
||||
webpreferences="autoplayPolicy=document-user-activation-required"
|
||||
style={{
|
||||
overflow: "hidden",
|
||||
borderRadius: "var(--embeddable-radius)",
|
||||
@@ -59,7 +286,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
|
||||
className="excalidraw__embeddable"
|
||||
title="Excalidraw Embedded Content"
|
||||
allowFullScreen={true}
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
||||
src={isDataURL ? null : src}
|
||||
style={{
|
||||
overflow: "hidden",
|
||||
@@ -76,11 +303,11 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
|
||||
function RenderObsidianView(
|
||||
{ mdProps, element, linkText, view, containerRef, activeEmbeddable, theme, canvasColor }:{
|
||||
mdProps: EmbeddableMDCustomProps;
|
||||
element: NonDeletedExcalidrawElement;
|
||||
element: ExcalidrawEmbeddableElement;
|
||||
linkText: string;
|
||||
view: ExcalidrawView;
|
||||
containerRef: React.RefObject<HTMLDivElement>;
|
||||
activeEmbeddable: {element: NonDeletedExcalidrawElement; state: string};
|
||||
activeEmbeddable: {element: ExcalidrawEmbeddableElement; state: string};
|
||||
theme: string;
|
||||
canvasColor: string;
|
||||
}): JSX.Element {
|
||||
@@ -98,6 +325,8 @@ function RenderObsidianView(
|
||||
const isActiveRef = React.useRef(false);
|
||||
const themeRef = React.useRef(theme);
|
||||
const elementRef = React.useRef(element);
|
||||
const pdfObserverRef = React.useRef(null);
|
||||
const pdfObserverDisabledRef = React.useRef(false);
|
||||
|
||||
// Update themeRef when theme changes
|
||||
React.useEffect(() => {
|
||||
@@ -110,7 +339,7 @@ function RenderObsidianView(
|
||||
}, [element]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//block propagation of events to the parent if the iframe element is active
|
||||
//block propagation of events to the parent if the embeddable element is active
|
||||
//--------------------------------------------------------------------------------
|
||||
const stopPropagation = React.useCallback((event:React.PointerEvent<HTMLElement>) => {
|
||||
if(isActiveRef.current) {
|
||||
@@ -137,7 +366,7 @@ function RenderObsidianView(
|
||||
}; //cleanup on unmount
|
||||
}, []);
|
||||
|
||||
//blocking or not the propagation of events to the parent if the iframe is active
|
||||
//blocking or not the propagation of events to the parent if the embeddable element is active
|
||||
React.useEffect(() => {
|
||||
EXTENDED_EVENT_TYPES.forEach((type) => containerRef.current.removeEventListener(type, stopPropagation));
|
||||
if(!containerRef?.current) {
|
||||
@@ -166,6 +395,21 @@ function RenderObsidianView(
|
||||
}
|
||||
}, [isActiveRef.current]);
|
||||
|
||||
const setKeepOnTop = () => {
|
||||
const keepontop = (view.app.workspace.activeLeaf === view.leaf) && DEVICE.isDesktop;
|
||||
if (keepontop) {
|
||||
//@ts-ignore
|
||||
if(!view.ownerWindow.electronWindow.isAlwaysOnTop()) {
|
||||
//@ts-ignore
|
||||
view.ownerWindow.electronWindow.setAlwaysOnTop(true);
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
view.ownerWindow.electronWindow.setAlwaysOnTop(false);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
//Mount the workspace leaf or the canvas node depending on subpath
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -194,23 +438,9 @@ function RenderObsidianView(
|
||||
editNode: null,
|
||||
};
|
||||
|
||||
const setKeepOnTop = () => {
|
||||
const keepontop = (view.app.workspace.activeLeaf === view.leaf) && DEVICE.isDesktop;
|
||||
if (keepontop) {
|
||||
//@ts-ignore
|
||||
if(!view.ownerWindow.electronWindow.isAlwaysOnTop()) {
|
||||
//@ts-ignore
|
||||
view.ownerWindow.electronWindow.setAlwaysOnTop(true);
|
||||
setTimeout(() => {
|
||||
//@ts-ignore
|
||||
view.ownerWindow.electronWindow.setAlwaysOnTop(false);
|
||||
}, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patchMobileView(view);
|
||||
//if subpath is defined, create a canvas node else create a workspace leaf
|
||||
if(subpath && view.canvasNodeFactory.isInitialized()) {
|
||||
if(subpath && view.canvasNodeFactory.isInitialized() && file.extension.toLowerCase() === "md") {
|
||||
setKeepOnTop();
|
||||
leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id);
|
||||
view.updateEmbeddableLeafRef(element.id, leafRef.current);
|
||||
@@ -231,20 +461,34 @@ function RenderObsidianView(
|
||||
//This runs only when the file is added, thus should not be a major performance issue
|
||||
await leafRef.current.leaf.setViewState({state: {file:null}})
|
||||
leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id);
|
||||
setColors(containerRef.current, element, mdProps, canvasColor);
|
||||
setColors(containerRef.current, element, mdProps, canvasColor, viewType);
|
||||
} else {
|
||||
const workspaceLeaf:HTMLDivElement = rootSplit.containerEl.querySelector("div.workspace-leaf");
|
||||
if(workspaceLeaf) workspaceLeaf.style.borderRadius = "var(--embeddable-radius)";
|
||||
rootSplit.containerEl.addClass("mod-visible");
|
||||
containerRef.current.appendChild(rootSplit.containerEl);
|
||||
setColors(containerRef.current, element, mdProps, canvasColor);
|
||||
setColors(containerRef.current, element, mdProps, canvasColor, viewType);
|
||||
}
|
||||
patchMobileView(view);
|
||||
view.updateEmbeddableLeafRef(element.id, leafRef.current);
|
||||
|
||||
if(viewType === "pdf") {
|
||||
// Moved PDF setup logic into a helper for readability
|
||||
setupPdfViewEnhancements(
|
||||
view,
|
||||
leafRef as React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
|
||||
pdfObserverRef as unknown as React.MutableRefObject<MutationObserver | null> & { currentCleanup?: () => void },
|
||||
pdfObserverDisabledRef
|
||||
);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
return () => {
|
||||
// disconnect observer if any
|
||||
(pdfObserverRef as any).currentCleanup?.();
|
||||
pdfObserverRef.current?.disconnect();
|
||||
pdfObserverRef.current = null;
|
||||
|
||||
if(!leafRef.current) {
|
||||
return;
|
||||
}
|
||||
@@ -257,7 +501,7 @@ function RenderObsidianView(
|
||||
//--------------------------------------------------------------------------------
|
||||
//Set colors of the canvas node
|
||||
//--------------------------------------------------------------------------------
|
||||
function setColors (canvasNode: HTMLDivElement, element: NonDeletedExcalidrawElement, mdProps: EmbeddableMDCustomProps, canvasColor: string) {
|
||||
function setColors (canvasNode: HTMLDivElement, element: ExcalidrawEmbeddableElement, mdProps: EmbeddableMDCustomProps, canvasColor: string, viewType: string) {
|
||||
if(!mdProps) return;
|
||||
if (!leafRef.current?.hasOwnProperty("node")) return;
|
||||
|
||||
@@ -297,22 +541,31 @@ function RenderObsidianView(
|
||||
canvasNode?.style.setProperty("--background-primary", color);
|
||||
canvasNodeContainer?.style.setProperty("background-color", color);
|
||||
}
|
||||
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-embed-border-color","var(--background-modifier-border)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-color","var(--text-muted)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-background-hover","var(--background-modifier-hover)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-sort-mask","linear-gradient(to left, transparent var(--size-4-6), black var(--size-4-6))");
|
||||
canvasNode?.style.setProperty("--bases-table-border-color","var(--table-border-color)");
|
||||
canvasNode?.style.setProperty("--bases-table-row-background-hover","var(--table-row-background-hover)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-shadow-active","0 0 0 2px var(--interactive-accent)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-background-active","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-background-disabled","var(--background-primary-alt)");
|
||||
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-cards-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-cards-cover-background","var(--background-primary-alt)");
|
||||
canvasNode?.style.setProperty("--bases-cards-shadow","0 0 0 1px var(--background-modifier-border)");
|
||||
canvasNode?.style.setProperty("--bases-cards-shadow-hover","0 0 0 1px var(--background-modifier-border-hover)");
|
||||
switch (viewType) {
|
||||
case "bases":
|
||||
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-embed-border-color","var(--background-modifier-border)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-color","var(--text-muted)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-background-hover","var(--background-modifier-hover)");
|
||||
canvasNode?.style.setProperty("--bases-table-header-sort-mask","linear-gradient(to left, transparent var(--size-4-6), black var(--size-4-6))");
|
||||
canvasNode?.style.setProperty("--bases-table-border-color","var(--table-border-color)");
|
||||
canvasNode?.style.setProperty("--bases-table-row-background-hover","var(--table-row-background-hover)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-shadow-active","0 0 0 2px var(--interactive-accent)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-background-active","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-table-cell-background-disabled","var(--background-primary-alt)");
|
||||
canvasNode?.style.setProperty("--bases-cards-container-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-cards-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--bases-cards-cover-background","var(--background-primary-alt)");
|
||||
canvasNode?.style.setProperty("--bases-cards-shadow","0 0 0 1px var(--background-modifier-border)");
|
||||
canvasNode?.style.setProperty("--bases-cards-shadow-hover","0 0 0 1px var(--background-modifier-border-hover)");
|
||||
break;
|
||||
case "pdf":
|
||||
canvasNode?.style.setProperty("--pdf-sidebar-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--pdf-background","var(--background-primary)");
|
||||
canvasNode?.style.setProperty("--pdf-sidebar-background","var(--background-primary)");
|
||||
break;
|
||||
}
|
||||
|
||||
if(mdProps.borderMatchElement) {
|
||||
const opacity = (mdProps?.borderOpacity ?? 50)/100;
|
||||
@@ -342,7 +595,8 @@ function RenderObsidianView(
|
||||
const element = elementRef.current;
|
||||
const canvasNode = containerRef.current;
|
||||
if(!canvasNode.hasClass("canvas-node")) return;
|
||||
setColors(canvasNode, element, mdProps, canvasColor);
|
||||
const viewType = leafRef.current.leaf.view?.getViewType();
|
||||
setColors(canvasNode, element, mdProps, canvasColor, viewType);
|
||||
}, [
|
||||
mdProps?.useObsidianDefaults,
|
||||
mdProps?.backgroundMatchCanvas,
|
||||
@@ -355,6 +609,7 @@ function RenderObsidianView(
|
||||
elementRef.current,
|
||||
containerRef.current,
|
||||
canvasColor,
|
||||
leafRef.current,
|
||||
])
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -378,6 +633,11 @@ function RenderObsidianView(
|
||||
event?.stopPropagation();
|
||||
}
|
||||
|
||||
/*if(isActiveRef.current && leafRef.current?.leaf) {
|
||||
setKeepOnTop();
|
||||
view.app.workspace.setActiveLeaf(leafRef.current.leaf, { focus: true });
|
||||
}*/
|
||||
|
||||
if (isActiveRef.current && !isEditingRef.current && leafRef.current?.leaf) {
|
||||
if(leafRef.current.leaf.view?.getViewType() === "markdown") {
|
||||
const api:ExcalidrawImperativeAPI = view.excalidrawAPI;
|
||||
@@ -392,9 +652,9 @@ function RenderObsidianView(
|
||||
if (!modes) {
|
||||
return;
|
||||
}
|
||||
patchMobileView(view);
|
||||
leafRef.current.leaf.view.setMode(modes['source']);
|
||||
isEditingRef.current = true;
|
||||
patchMobileView(view);
|
||||
} else if (leafRef.current?.node) {
|
||||
//Handle canvas node
|
||||
const newTheme = getTheme(view, themeRef.current);
|
||||
@@ -402,23 +662,40 @@ function RenderObsidianView(
|
||||
view.canvasNodeFactory.startEditing(leafRef.current.node, newTheme);
|
||||
}
|
||||
}
|
||||
}, [leafRef.current?.leaf, element.id, view, themeRef.current]);
|
||||
}, [leafRef.current?.leaf, element.id, view, themeRef.current, isActiveRef.current, isEditingRef.current]);
|
||||
|
||||
if(leafRef.current) leafRef.current.editNode = handleClick;
|
||||
const startEditing = React.useCallback(() => {
|
||||
if(isActiveRef.current && isEditingRef.current) {
|
||||
return;
|
||||
}
|
||||
isActiveRef.current = true;
|
||||
handleClick();
|
||||
}, [isActiveRef.current, isEditingRef.current, handleClick]);
|
||||
|
||||
if(leafRef.current) leafRef.current.editNode = startEditing;
|
||||
// Event listener for key press
|
||||
React.useEffect(() => {
|
||||
const handleKeyPress = (event: KeyboardEvent) => {
|
||||
if (event.key === "Enter") {
|
||||
handleClick(event); // Call handleClick function when Enter key is pressed
|
||||
// Deactivate active embeddable on Escape
|
||||
if (event.key === "Escape" && isActiveRef.current) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
view.updateScene({ appState: { activeEmbeddable: null } });
|
||||
return;
|
||||
}
|
||||
// Existing Enter behavior
|
||||
if (event.key === "Enter" && !isActiveRef.current) {
|
||||
startEditing(); // Call handleClick function when Enter key is pressed
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("keydown", handleKeyPress); // Add event listener for key press
|
||||
// Use capture so this runs even if container stops bubbling
|
||||
document.addEventListener("keydown", handleKeyPress, true);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener("keydown", handleKeyPress); // Remove event listener when component unmounts
|
||||
document.removeEventListener("keydown", handleKeyPress, true);
|
||||
};
|
||||
}, [handleClick]);
|
||||
}, [handleClick, isActiveRef.current, view]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Set isActiveRef and switch to preview mode when the iframe is not active
|
||||
@@ -436,6 +713,11 @@ function RenderObsidianView(
|
||||
return;
|
||||
}
|
||||
|
||||
/*if(leafRef.current?.leaf) {
|
||||
setKeepOnTop();
|
||||
view.app.workspace.setActiveLeaf(leafRef.current.leaf, { focus: true });
|
||||
}*/
|
||||
|
||||
if(file !== view.file) {
|
||||
setFileToLocalGraph(view.app, file);
|
||||
}
|
||||
@@ -468,6 +750,7 @@ function RenderObsidianView(
|
||||
}, [
|
||||
containerRef,
|
||||
leafRef,
|
||||
activeEmbeddable?.state,
|
||||
isActiveRef,
|
||||
activeEmbeddable?.element,
|
||||
activeEmbeddable?.state,
|
||||
@@ -482,7 +765,7 @@ function RenderObsidianView(
|
||||
};
|
||||
|
||||
|
||||
export const CustomEmbeddable: React.FC<{element: NonDeletedExcalidrawElement; view: ExcalidrawView; appState: UIAppState; linkText: string}> = ({ element, view, appState, linkText }) => {
|
||||
export const CustomEmbeddable: React.FC<{element: ExcalidrawEmbeddableElement; view: ExcalidrawView; appState: UIAppState; linkText: string}> = ({ element, view, appState, linkText }) => {
|
||||
const React = view.packages.react;
|
||||
const containerRef: React.RefObject<HTMLDivElement> = React.useRef(null);
|
||||
const theme = getTheme(view, appState.theme);
|
||||
@@ -495,6 +778,7 @@ export const CustomEmbeddable: React.FC<{element: NonDeletedExcalidrawElement; v
|
||||
height: `100%`,
|
||||
borderRadius: "var(--embeddable-radius)",
|
||||
color: `var(--text-normal)`,
|
||||
touchAction: "auto",
|
||||
}}
|
||||
className={`${theme} canvas-node ${
|
||||
mdProps?.filenameVisible && !mdProps.useObsidianDefaults ? "" : "excalidraw-mdEmbed-hideFilename"}`}
|
||||
|
||||
@@ -10,9 +10,9 @@ import { ScriptEngine } from "../../../shared/Scripts";
|
||||
import { MD_EX_SECTIONS, ROOTELEMENTSIZE, nanoid, sceneCoordsToViewportCoords } from "src/constants/constants";
|
||||
import { REGEX_LINK, REG_LINKINDEX_HYPERLINK } from "../../../shared/ExcalidrawData";
|
||||
import { processLinkText, useDefaultExcalidrawFrame } from "src/utils/customEmbeddableUtils";
|
||||
import { cleanSectionHeading } from "src/utils/obsidianUtils";
|
||||
import { cleanSectionHeading, getActivePDFPageNumberFromPDFView } from "src/utils/obsidianUtils";
|
||||
import { EmbeddableSettings } from "src/shared/Dialogs/EmbeddableSettings";
|
||||
import { openExternalLink } from "src/utils/excalidrawViewUtils";
|
||||
import { insertImageToView, openExternalLink } from "src/utils/excalidrawViewUtils";
|
||||
import { getEA } from "src/core";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { CaptureUpdateAction } from "src/constants/constants";
|
||||
@@ -40,7 +40,7 @@ export class EmbeddableMenu {
|
||||
this.renderButtons = null;
|
||||
}
|
||||
|
||||
private updateElement = (subpath: string, element: ExcalidrawEmbeddableElement, file: TFile) => {
|
||||
private updateElement = async (subpath: string, element: ExcalidrawEmbeddableElement, file: TFile, save: boolean = true) => {
|
||||
if(!element) return;
|
||||
const view = this.view;
|
||||
const app = view.app;
|
||||
@@ -56,7 +56,8 @@ export class EmbeddableMenu {
|
||||
ea.copyViewElementsToEAforEditing([element]);
|
||||
ea.getElement(element.id).link = link;
|
||||
view.excalidrawData.elementLinks.set(element.id, link);
|
||||
ea.addElementsToView(false, true, true).then(() => ea.destroy());
|
||||
await ea.addElementsToView(false, save, true);
|
||||
ea.destroy();
|
||||
}
|
||||
|
||||
private handleMouseEnter () {
|
||||
@@ -119,6 +120,46 @@ export class EmbeddableMenu {
|
||||
}
|
||||
}
|
||||
|
||||
private actionBookmarkPage (element: ExcalidrawEmbeddableElement) {
|
||||
if(!element) return;
|
||||
const pdfView = this.view.getEmbeddableLeafElementById(element.id)?.node?.child;
|
||||
if(!pdfView) return;
|
||||
const page = getActivePDFPageNumberFromPDFView(pdfView);
|
||||
if(!page) return;
|
||||
const pdfFile: TFile = pdfView?.file;
|
||||
if(!pdfFile) return;
|
||||
this.updateElement(`#page=${page}`, element, pdfFile, false);
|
||||
}
|
||||
|
||||
private async actionInsertPageAsImage (element: ExcalidrawEmbeddableElement) {
|
||||
if(!element) return;
|
||||
const pdfView = this.view.getEmbeddableLeafElementById(element.id)?.node?.child;
|
||||
if(!pdfView) return;
|
||||
const page = getActivePDFPageNumberFromPDFView(pdfView);
|
||||
if(!page) return;
|
||||
const pdfFile: TFile = pdfView?.file;
|
||||
if(!pdfFile) return;
|
||||
const ea = getEA(this.view) as ExcalidrawAutomate;
|
||||
ea.selectElementsInView([]);
|
||||
const x = element.x + element.width + 20;
|
||||
const y = element.y;
|
||||
const path = this.view.app.metadataCache.fileToLinktext(
|
||||
pdfFile,
|
||||
this.view.file.path,
|
||||
false,
|
||||
)
|
||||
const id = await insertImageToView(
|
||||
ea,
|
||||
{x,y},
|
||||
`${path}#page=${page}`,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
);
|
||||
ea.selectElementsInView([id]);
|
||||
ea.destroy();
|
||||
}
|
||||
|
||||
private async actionMarkdownBlock (file: TFile, subpath: string, element: ExcalidrawEmbeddableElement) {
|
||||
if(!file) return;
|
||||
this.view.updateScene({appState: {activeEmbeddable: null}, captureUpdate: CaptureUpdateAction.NEVER});
|
||||
@@ -298,12 +339,26 @@ export class EmbeddableMenu {
|
||||
icon={ICONS.Properties}
|
||||
/>
|
||||
{isPDF && (
|
||||
<ActionButton
|
||||
key={"Crop"}
|
||||
title={t("CROP_PAGE")}
|
||||
action={() => this.actionCrop(element)}
|
||||
icon={ICONS.Crop}
|
||||
/>
|
||||
<>
|
||||
<ActionButton
|
||||
key={"Crop"}
|
||||
title={t("CROP_PAGE")}
|
||||
action={() => this.actionCrop(element)}
|
||||
icon={ICONS.Crop}
|
||||
/>
|
||||
<ActionButton
|
||||
key={"Bookmark"}
|
||||
title={t("BOOKMARK_PAGE")}
|
||||
action={() => this.actionBookmarkPage(element)}
|
||||
icon={ICONS.Bookmark}
|
||||
/>
|
||||
<ActionButton
|
||||
key={"Camera"}
|
||||
title={t("CAPTURE_PAGE")}
|
||||
action={() => this.actionInsertPageAsImage(element)}
|
||||
icon={ICONS.Camera}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -498,7 +498,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
<fieldset>
|
||||
<legend>Utility actions</legend>
|
||||
<div className="buttonList buttonListIcon">
|
||||
<ActionButton
|
||||
<ActionButton
|
||||
key={"scriptEngine"}
|
||||
title={t("INSTALL_SCRIPT_BUTTON")}
|
||||
action={this.actionOpenScriptInstallDialog.bind(this)}
|
||||
@@ -517,7 +517,7 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
action={(this.actionConvertExcalidrawToMD.bind(this))}
|
||||
icon={ICONS.convertFile}
|
||||
/>
|
||||
) : (
|
||||
) : !this.state.isPreviewMode && (
|
||||
<ActionButton
|
||||
key={"viewmode"}
|
||||
title={this.state.isPreviewMode ? t("PARSED") : t("RAW")}
|
||||
@@ -549,6 +549,8 @@ export class ToolsPanel extends React.Component<PanelProps, PanelState> {
|
||||
: ICONS.gotoFullScreen
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="buttonList buttonListIcon">
|
||||
<ActionButton
|
||||
key={"search"}
|
||||
title={t("SEARCH")}
|
||||
|
||||
@@ -34,6 +34,7 @@ export interface ObsidianCanvasNode {
|
||||
isEditing: boolean;
|
||||
file: TFile;
|
||||
detach: Function;
|
||||
isEditable: Function;
|
||||
}
|
||||
|
||||
export class CanvasNodeFactory {
|
||||
@@ -112,12 +113,11 @@ export class CanvasNodeFactory {
|
||||
}
|
||||
|
||||
public async startEditing(node: ObsidianCanvasNode, theme: string) {
|
||||
if (!this.initialized || !node) return;
|
||||
if (!this.initialized || !node || !node.isEditable()) return;
|
||||
|
||||
try {
|
||||
//if (node.file === this.view.file) {
|
||||
await this.view.setEmbeddableNodeIsEditing();
|
||||
//}
|
||||
await this.view.setEmbeddableNodeIsEditing();
|
||||
|
||||
node.startEditing();
|
||||
node.isEditing = true;
|
||||
|
||||
@@ -138,12 +138,10 @@ export class CanvasNodeFactory {
|
||||
}
|
||||
|
||||
public stopEditing(node: ObsidianCanvasNode) {
|
||||
if (!this.initialized || !node || !node.isEditing) return;
|
||||
if (!this.initialized || !node || !node.isEditing || !node.isEditable()) return;
|
||||
|
||||
try {
|
||||
//if (node.file === this.view.file) {
|
||||
this.view.clearEmbeddableNodeIsEditing();
|
||||
//}
|
||||
this.view.clearEmbeddableNodeIsEditing();
|
||||
node.child.showPreview();
|
||||
node.isEditing = false;
|
||||
this.observer?.disconnect();
|
||||
|
||||
+23
@@ -857,3 +857,26 @@ textarea.excalidraw-wysiwyg, .excalidraw input {
|
||||
fill: none;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/*remove blur from PDF embed*/
|
||||
.excalidraw__embeddable-container canvas {
|
||||
image-rendering: auto;
|
||||
}
|
||||
|
||||
.excalidraw__embeddable-container .mod-nofilter canvas {
|
||||
filter: none !important;
|
||||
}
|
||||
|
||||
.excalidraw__embeddable-container .canvas-node.is-selected .canvas-node-container,
|
||||
.excalidraw__embeddable-container .canvas-node.is-focused .canvas-node-container {
|
||||
border-color: inherit;
|
||||
box-shadow: inherit;
|
||||
}
|
||||
|
||||
.excalidraw__embeddable-container .pdf-toolbar-right {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.excalidraw-scriptengine-install .modal-close-button {
|
||||
z-index: 9999;
|
||||
}
|
||||
Reference in new issue
Block a user