Compare commits

..

5 Commits

Author SHA1 Message Date
zsviczian
d5b86289b6 Merge branch 'master' of https://github.com/zsviczian/obsidian-excalidraw-plugin 2025-04-20 10:02:54 +02:00
zsviczian
dceb6ce690 2.10.2-beta-1 0.18.0-8 2025-04-20 10:02:42 +02:00
zsviczian
c29c25d252 Merge pull request #2323 from dmscode/master
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
Update zh-cn.ts to 6e57d4e
2025-04-18 15:39:03 +02:00
dmscode
a2fb36671d Update zh-cn.ts to 6e57d4e 2025-04-17 06:56:13 +08:00
zsviczian
6e57d4e69a 2.10.1 0.18.0-7
Some checks failed
CodeQL / Analyze (javascript) (push) Has been cancelled
2025-04-16 20:33:48 +02:00
12 changed files with 133 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.10.0",
"version": "2.10.2-beta-1",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",

View File

@@ -1,7 +1,7 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.10.0",
"version": "2.10.1",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",

View File

@@ -23,7 +23,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.18.0-6",
"@zsviczian/excalidraw": "0.18.0-8",
"chroma-js": "^2.4.2",
"clsx": "^2.0.0",
"@zsviczian/colormaster": "^1.2.2",

View File

@@ -130,7 +130,7 @@ export class ObserverManager {
return;
}
if (this.plugin.isExcalidrawFile(f)) {
el.insertBefore(
el.insertAfter(
createDiv({
cls: "nav-file-tag",
text: this.settings.experimentalFileTag,

View File

@@ -43,6 +43,7 @@ import { HotkeyEditor } from "src/shared/Dialogs/HotkeyEditor";
import { getExcalidrawViews } from "src/utils/obsidianUtils";
import { createSliderWithText } from "src/utils/sliderUtils";
import { PDFExportSettingsComponent, PDFExportSettings } from "src/shared/Dialogs/PDFExportSettingsComponent";
import de from "src/lang/locale/de";
export interface ExcalidrawSettings {
folder: string;
@@ -199,6 +200,7 @@ export interface ExcalidrawSettings {
markdownNodeOneClickEditing: boolean;
canvasImmersiveEmbed: boolean,
startupScriptPath: string,
aiEnabled: boolean,
openAIAPIToken: string,
openAIDefaultTextModel: string,
openAIDefaultVisionModel: string,
@@ -380,6 +382,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
DYNAMIC_COLOR: true,
COLOR: "#000000",
OPACITY: 50,
GRID_DIRECTION: {horizontal: true, vertical: true},
},
laserSettings: {
DECAY_LENGTH: 50,
@@ -400,6 +403,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
markdownNodeOneClickEditing: false,
canvasImmersiveEmbed: true,
startupScriptPath: "",
aiEnabled: true,
openAIAPIToken: "",
openAIDefaultTextModel: "gpt-3.5-turbo-1106",
openAIDefaultVisionModel: "gpt-4o",
@@ -992,6 +996,27 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
cls: "excalidraw-setting-h1",
});
let aiEl: HTMLElement;
new Setting(detailsEl)
.setName(t("AI_ENABLED_NAME"))
.setDesc(fragWithHTML(t("AI_ENABLED_DESC")))
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.aiEnabled??true)
.onChange(async (value) => {
aiEl.style.display = value ? "block" : "none";
this.plugin.settings.aiEnabled = value;
this.applySettingsUpdate();
}),
);
detailsEl = detailsEl.createDiv();
aiEl = detailsEl;
if(!(this.plugin.settings.aiEnabled??true)) {
detailsEl.style.display = "none";
}
new Setting(detailsEl)
.setName(t("AI_OPENAI_TOKEN_NAME"))
.setDesc(fragWithHTML(t("AI_OPENAI_TOKEN_DESC")))
@@ -1380,6 +1405,42 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
getExcalidrawViews(this.app).forEach(excalidrawView=>excalidrawView.updateGridColor());
};
const updateGridDirection = () => {
getExcalidrawViews(this.app).forEach(excalidrawView=>
excalidrawView.updateGridDirection(this.plugin.settings.gridSettings.GRID_DIRECTION));
}
new Setting(detailsEl)
.setName(t("GRID_DIRECTION_NAME"))
.setDesc(t("GRID_DIRECTION_DESC"))
.addToggle((toggle) =>
toggle
.setTooltip(t("GRID_HORIZONTAL"))
.setValue(this.plugin.settings.gridSettings.GRID_DIRECTION?.horizontal ?? true)
.onChange((value) => {
if(!this.plugin.settings.gridSettings.GRID_DIRECTION) {
this.plugin.settings.gridSettings.GRID_DIRECTION = { horizontal: true, vertical: true };
} //2.10.1 migration
this.plugin.settings.gridSettings.GRID_DIRECTION.horizontal = value;
this.applySettingsUpdate();
updateGridDirection();
}),
)
.addToggle((toggle) =>
toggle
.setTooltip(t("GRID_VERTICAL"))
.setValue(this.plugin.settings.gridSettings.GRID_DIRECTION?.vertical ?? true)
.onChange((value) => {
if(!this.plugin.settings.gridSettings.GRID_DIRECTION) {
this.plugin.settings.gridSettings.GRID_DIRECTION = { horizontal: true, vertical: true };
} //2.10.1 migration
this.plugin.settings.gridSettings.GRID_DIRECTION.vertical = value;
this.applySettingsUpdate();
updateGridDirection();
}),
);
// Dynamic color toggle
let gridColorSection: HTMLDivElement;
new Setting(detailsEl)

View File

@@ -247,6 +247,8 @@ export default {
`While the OpenAI API is in beta, its use is strictly limited — as such we require you use your own API key. ` +
`You can create an OpenAI account, add a small credit (5 USD minimum), and generate your own API key. ` +
`Once API key is set, you can use the AI tools in Excalidraw.`,
AI_ENABLED_NAME: "Enable AI features",
AI_ENABLED_DESC: "You need to reopen Excalidraw for the changes to take effect.",
AI_OPENAI_TOKEN_NAME: "OpenAI API key",
AI_OPENAI_TOKEN_DESC:
"You can get your OpenAI API key from your <a href='https://platform.openai.com/api-keys'>OpenAI account</a>.",
@@ -427,6 +429,10 @@ FILENAME_HEAD: "Filename",
GRID_OPACITY_NAME: "Grid opacity",
GRID_OPACITY_DESC: "Grid opacity will also control the opacity of the binding box when binding an arrow to an element.<br>" +
"Set the opacity of the grid. 0 is transparent, 100 is opaque.",
GRID_DIRECTION_NAME: "Grid direction",
GRID_DIRECTION_DESC: "The first toggle shows/hides the horizontal grid, the second toggle shows/hides the vertical grid.",
GRID_HORIZONTAL: "Render horizontal grid",
GRID_VERTICAL: "Render vertical grid",
LASER_HEAD: "Laser pointer",
LASER_COLOR: "Laser pointer color",
LASER_DECAY_TIME_NAME: "Laser pointer decay time",

View File

@@ -427,6 +427,10 @@ FILENAME_HEAD: "文件名",
GRID_OPACITY_NAME: "网格透明度",
GRID_OPACITY_DESC: "网格透明度还将控制将箭头绑定到元素时绑定框的透明度。<br>"+
"设置网格的不透明度。 0 表示完全透明100 表示完全不透明。",
GRID_DIRECTION_NAME : "网格方向" ,
GRID_DIRECTION_DESC : "第一个开关显示/隐藏水平网格,第二个开关显示/隐藏垂直网格。" ,
GRID_HORIZONTAL : "渲染水平网格" ,
GRID_VERTICAL : "渲染垂直网格" ,
LASER_HEAD: "激光笔工具(更多工具 > 激光笔)",
LASER_COLOR: "激光笔颜色",
LASER_DECAY_TIME_NAME: "激光笔消失时间",

View File

@@ -12,6 +12,7 @@ import { getYouTubeStartAt, isValidYouTubeStart, isYouTube, updateYouTubeStartTi
import { EmbeddalbeMDFileCustomDataSettingsComponent } from "./EmbeddableMDFileCustomDataSettingsComponent";
import { isWinCTRLorMacCMD } from "src/utils/modifierkeyHelper";
import { ExcalidrawImperativeAPI } from "@zsviczian/excalidraw/types/excalidraw/types";
import { CaptureUpdateAction } from "src/constants/constants";
export type EmbeddableMDCustomProps = {
useObsidianDefaults: boolean;
@@ -225,7 +226,6 @@ export class EmbeddableSettings extends Modal {
if(dirty) {
(async() => {
await this.ea.addElementsToView();
//@ts-ignore
this.ea.viewUpdateScene({appState: {}, captureUpdate: CaptureUpdateAction.NEVER});
this.close(); //close should only run once update scene is done
})();

View File

@@ -11,12 +11,45 @@ Thank you & Enjoy!
`;
export const RELEASE_NOTES: { [k: string]: string } = {
Intro: `After each update you'll be prompted with the release notes. You can disable this in plugin settings.
Intro: `After each update, youll see these release notes (you can turn this off in the plugin settings).
I develop this plugin as a hobby, spending my free time doing this. If you find it valuable, then please say THANK YOU or...
I build this plugin in my free time, as a labor of love. Curious about the philosophy behind it? Check out [📕 Sketch Your Mind](https://sketch-your-mind.com). If you find it valuable, say THANK YOU or
<div class="ex-coffee-div"><a href="https://ko-fi.com/zsolt"><img src="https://storage.ko-fi.com/cdn/kofi6.png?v=6" border="0" alt="Buy Me a Coffee at ko-fi.com" height=45></a></div>
`,
"2.10.2": `
## Fixed by Excalidraw.com
- Alt-duplicate now preserves the original element. Previously, using Alt to duplicate would swap the original with the new element, leading to unexpected behavior and several downstream issues. [#9403](https://github.com/excalidraw/excalidraw/pull/9403)
## New
- Expose parameter in plugin settings to disable AI functionality [#2325](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2325)
## Fixed in the plugin
- Scaling multiple embeddables at once did not work. [#2276](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2276)
- When creating multiple back-of-the-note the second card is not created correctly if autosave has not yet happened.
- Drawing reloads while editing the back-of-the-note card in certain cases causing editing to be interrupted.
- Moved Excalidraw filetype indicator ✏️ to after filename where other filetype tags are displayed. You can turn filetype indicator on/off in plugin settings under Miscellaneous.
`,
"2.10.1": `
## Fixed by Excalidraw.com
- Eraser performance improvement regression. Erasing locked elements. [#9400](https://github.com/excalidraw/excalidraw/pull/9400)
## New
- Grid Customization Options in plugin settings (appearance and behavior/grid): You can now selectively show or hide vertical and horizontal grid lines independently. This allows you to create alternative grid styles, such as horizontal-only lined grids instead of the traditional checkered pattern.
## Fixed in ExcalidrawAutomate
- ${String.fromCharCode(96)}ea.createSVG${String.fromCharCode(96)} throws error [#2321](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2321)
---
## ❤️ Enjoying the plugin?
Support my work by checking out my new book, now available for pre-order:
[Sketch Your Mind: Nurture a Playful and Creative Brain](https://sketch-your-mind.com) is about visual Personal Knowledge Management. It explores the thinking behind Excalidraw and how it helps you structure and evolve ideas visually. Its the book I wish I had when I began my own PKM journey.
<div class="ex-coffee-div"><a href="https://sketch-your-mind.com"><img src="https://raw.githubusercontent.com/zsviczian/sketch-your-mind/refs/heads/main/images/cover-mini.jpg" border="0" alt="Pre-order Sketch Your Mind" height="100%"></a></div>
`,
"2.10.0": `
## New from Excalidraw.com
- Lasso select [#9169](https://github.com/excalidraw/excalidraw/pull/9169)
@@ -28,7 +61,7 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
- Keep arrow label horizontal [#9364](https://github.com/excalidraw/excalidraw/pull/9364)
## Fixed in ExcalidrawAutomate
- ea.addText did not honor the width parameter.
- ${String.fromCharCode(96)}ea.addText${String.fromCharCode(96)} did not honor the width parameter.
`,
"2.9.2":`
- More minor fix. Toolbars are not responsive when dynamic styling is turned off. [#2287](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2287)

View File

@@ -1096,13 +1096,14 @@ export class ExcalidrawAutomate {
? "light"
: undefined;
}
if (theme && !exportSettings) {
if (!exportSettings) {
exportSettings = {
withBackground: this.plugin.settings.exportWithBackground,
withTheme: true,
isMask: false,
skipInliningFonts: !embedFont,
};
}
}
if (!loader) {
loader = new EmbeddedFilesLoader(
this.plugin,
@@ -2605,7 +2606,7 @@ export class ExcalidrawAutomate {
viewUpdateScene (
scene: {
elements?: ExcalidrawElement[],
appState?: AppState,
appState?: AppState | {},
files?: BinaryFileData,
commitToHistory?: boolean,
storeAction?: "capture" | "none" | "update",

View File

@@ -18,6 +18,7 @@ export type GridSettings = {
DYNAMIC_COLOR: boolean; // Whether the grid color is dynamic
COLOR: string; // The grid color (in hex format)
OPACITY: number; // The grid opacity (hex value between "00" and "FF")
GRID_DIRECTION: {horizontal: boolean, vertical: boolean}; // Whether the grid is horizontal or vertical
};
export type DeviceType = {

View File

@@ -155,6 +155,7 @@ import { ImageInfo } from "src/types/excalidrawAutomateTypes";
import { exportToPDF, getMarginValue, getPageDimensions, PageOrientation, PageSize } from "src/utils/exportUtils";
import { FrameRenderingOptions } from "src/types/utilTypes";
import { CaptureUpdateAction } from "src/constants/constants";
import { FlipHorizontal } from "lucide-react";
const EMBEDDABLE_SEMAPHORE_TIMEOUT = 2000;
const PREVENT_RELOAD_TIMEOUT = 2000;
@@ -749,8 +750,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
public async setEmbeddableNodeIsEditing() {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.setEmbeddableNodeIsEditing, "ExcalidrawView.setEmbeddableNodeIsEditing");
this.clearEmbeddableNodeIsEditingTimer();
await this.forceSave(true);
this.semaphores.embeddableIsEditingSelf = true;
await this.forceSave(true);
}
public clearEmbeddableNodeIsEditingTimer () {
@@ -2769,6 +2770,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
allowWheelZoom: this.plugin.settings.allowWheelZoom,
pinnedScripts: this.plugin.settings.pinnedScripts,
customPens: this.plugin.settings.customPens.slice(0,this.plugin.settings.numberOfCustomPens),
gridDirection: this.plugin.settings.gridSettings.GRID_DIRECTION ?? {horizontal: true, vertical: true},
},
captureUpdate: CaptureUpdateAction.NEVER,
},
@@ -2797,6 +2799,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
allowWheelZoom: this.plugin.settings.allowWheelZoom,
pinnedScripts: this.plugin.settings.pinnedScripts,
customPens: this.plugin.settings.customPens.slice(0,this.plugin.settings.numberOfCustomPens),
gridDirection: this.plugin.settings.gridSettings.GRID_DIRECTION,
},
files: excalidrawData.files,
libraryItems: await this.getLibrary(),
@@ -3738,6 +3741,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
return;
}
const ef = this.excalidrawData.getFile(selectedImgElement.fileId);
if(!ef.file) {
return;
}
if (
(ef.isHyperLink || ef.isLocalLink) || //web images don't have a preview
(IMAGE_TYPES.contains(ef.file.extension)) || //images don't have a preview
@@ -3939,6 +3945,13 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
window.setTimeout(()=>this.updateScene({appState:{gridColor: this.getGridColor(canvasColor, st)}, captureUpdate: CaptureUpdateAction.NEVER}));
}
public updateGridDirection(gridDirection: {horizontal: boolean, vertical: boolean}) {
window.setTimeout(()=>this.updateScene({appState:{gridDirection: {
horizontal: gridDirection.horizontal,
vertical: gridDirection.vertical}
}, captureUpdate: CaptureUpdateAction.NEVER}));
}
private canvasColorChangeHook(st: AppState) {
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.canvasColorChangeHook, "ExcalidrawView.canvasColorChangeHook", st);
const canvasColor = st.viewBackgroundColor === "transparent" ? "white" : st.viewBackgroundColor;
@@ -4552,6 +4565,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
public async insertBackOfTheNoteCard() {
(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();
@@ -5481,7 +5495,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
libraryReturnUrl: "app://obsidian.md",
autoFocus: true,
langCode: obsidianToExcalidrawMap[this.plugin.locale]??"en-EN",
aiEnabled: true,
aiEnabled: this.plugin.settings.aiEnabled??true,
onChange: this.onChange.bind(this),
onLibraryChange: this.onLibraryChange.bind(this),
renderTopRightUI: this.renderTopRightUI.bind(this), //(isMobile: boolean, appState: AppState) => this.obsidianMenu.renderButton (isMobile, appState),