Merge branch 'zsviczian:master' into master

This commit is contained in:
稻米鼠
2025-04-20 18:12:27 +08:00
committed by GitHub
10 changed files with 55 additions and 11 deletions

View File

@@ -1,10 +1,10 @@
{
"id": "obsidian-excalidraw-plugin",
"name": "Excalidraw",
"version": "2.10.1",
"version": "2.10.2-beta-1",
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
"authorUrl": "https://zsolt.blog",
"authorUrl": "https://excalidraw-obsidian.online",
"isDesktopOnly": false
}

View File

@@ -5,7 +5,7 @@
"minAppVersion": "1.1.6",
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
"author": "Zsolt Viczian",
"authorUrl": "https://www.zsolt.blog",
"authorUrl": "https://excalidraw-obsidian.online",
"fundingUrl": "https://ko-fi.com/zsolt",
"helpUrl": "https://github.com/zsviczian/obsidian-excalidraw-plugin#readme",
"isDesktopOnly": false

View File

@@ -23,7 +23,7 @@
"license": "MIT",
"dependencies": {
"@popperjs/core": "^2.11.8",
"@zsviczian/excalidraw": "0.18.0-7",
"@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,
@@ -401,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",
@@ -993,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")))

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>.",

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

@@ -17,6 +17,19 @@ 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.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
@@ -26,7 +39,7 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
- 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)
- ${String.fromCharCode(96)}ea.createSVG${String.fromCharCode(96)} throws error [#2321](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2321)
---

View File

@@ -1655,7 +1655,8 @@ export class ExcalidrawAutomate {
arrayToMap(this.getElements()),
originalText,
);
if(dimensions) {
if(dimensions && !formatting?.width) {
textElement.width = dimensions.width;
textElement.height = dimensions.height;
textElement.x = dimensions.x;
@@ -2606,7 +2607,7 @@ export class ExcalidrawAutomate {
viewUpdateScene (
scene: {
elements?: ExcalidrawElement[],
appState?: AppState,
appState?: AppState | {},
files?: BinaryFileData,
commitToHistory?: boolean,
storeAction?: "capture" | "none" | "update",

View File

@@ -750,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 () {
@@ -3741,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
@@ -4562,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();
@@ -5491,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),