diff --git a/manifest-beta.json b/manifest-beta.json index a930519..1e7f610 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -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 } diff --git a/manifest.json b/manifest.json index 4db45ed..a2bec7b 100644 --- a/manifest.json +++ b/manifest.json @@ -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 diff --git a/package.json b/package.json index 03bb9ce..ffffc99 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/core/managers/ObserverManager.ts b/src/core/managers/ObserverManager.ts index eeb5772..f28b3b5 100644 --- a/src/core/managers/ObserverManager.ts +++ b/src/core/managers/ObserverManager.ts @@ -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, diff --git a/src/core/settings.ts b/src/core/settings.ts index 3752513..4c3a550 100644 --- a/src/core/settings.ts +++ b/src/core/settings.ts @@ -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"))) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index d8ca1e9..2607d00 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -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 OpenAI account.", diff --git a/src/shared/Dialogs/EmbeddableSettings.ts b/src/shared/Dialogs/EmbeddableSettings.ts index 6e964a0..97dd50b 100644 --- a/src/shared/Dialogs/EmbeddableSettings.ts +++ b/src/shared/Dialogs/EmbeddableSettings.ts @@ -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 })(); diff --git a/src/shared/Dialogs/Messages.ts b/src/shared/Dialogs/Messages.ts index c38c1e4..02968e9 100644 --- a/src/shared/Dialogs/Messages.ts +++ b/src/shared/Dialogs/Messages.ts @@ -17,6 +17,19 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
`, +"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) --- diff --git a/src/shared/ExcalidrawAutomate.ts b/src/shared/ExcalidrawAutomate.ts index 9564df0..b59b7d5 100644 --- a/src/shared/ExcalidrawAutomate.ts +++ b/src/shared/ExcalidrawAutomate.ts @@ -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", diff --git a/src/view/ExcalidrawView.ts b/src/view/ExcalidrawView.ts index 5db542a..78ee4f4 100644 --- a/src/view/ExcalidrawView.ts +++ b/src/view/ExcalidrawView.ts @@ -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),