diff --git a/manifest.json b/manifest.json index e699c5c..40be500 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-excalidraw-plugin", "name": "Excalidraw", - "version": "1.9.17", + "version": "1.9.18", "minAppVersion": "1.1.6", "description": "An Obsidian plugin to edit and view Excalidraw drawings", "author": "Zsolt Viczian", diff --git a/rollup.config.js b/rollup.config.js index 537dc67..5d26200 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -70,7 +70,7 @@ const BUILD_CONFIG = { presets: [['@babel/preset-env', { targets: { esmodules: true, - } + }, }]], exclude: "node_modules/**" }), diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 76bf3c2..fc921f2 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -48,6 +48,7 @@ import { viewportCoordsToSceneCoords, ERROR_IFRAME_CONVERSION_CANCELED, restore, + obsidianToExcalidrawMap, } from "./constants"; import ExcalidrawPlugin from "./main"; import { @@ -125,6 +126,7 @@ import { CanvasNodeFactory, ObsidianCanvasNode } from "./utils/CanvasNodeFactory import { EmbeddableMenu } from "./menu/EmbeddableActionsMenu"; import { useDefaultExcalidrawFrame } from "./utils/CustomEmbeddableUtils"; import { UniversalInsertFileModal } from "./dialogs/UniversalInsertFileModal"; +import { moment } from "obsidian"; declare const PLUGIN_VERSION:string; @@ -3179,6 +3181,7 @@ export default class ExcalidrawView extends TextFileView { }, libraryReturnUrl: "app://obsidian.md", autoFocus: true, + langCode: obsidianToExcalidrawMap[moment.locale()]??"en-EN", onChange: (et: ExcalidrawElement[], st: AppState) => { const canvasColorChangeHook = () => { const canvasColor = st.viewBackgroundColor === "transparent" ? "white" : st.viewBackgroundColor; @@ -4155,12 +4158,8 @@ export default class ExcalidrawView extends TextFileView { return React.createElement(React.Fragment, null, excalidrawDiv); }); - //REACT 18 const root = ReactDOM.createRoot(this.contentEl); root.render(reactElement); - /*REACT 17 - ReactDOM.render(reactElement, this.contentEl, () => {}); - */ } private updateContainerSize(containerId?: string, delay: boolean = false) { diff --git a/src/constants.ts b/src/constants.ts index 8f2151d..093c418 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -8,6 +8,60 @@ export const ERROR_IFRAME_CONVERSION_CANCELED = "iframe conversion canceled"; declare const excalidrawLib: typeof ExcalidrawLib; +export const obsidianToExcalidrawMap: { [key: string]: string } = { + 'en': 'en-US', + 'af': 'af-ZA', // Assuming South Africa for Afrikaans + 'am': 'am-ET', // Assuming Ethiopia for Amharic + 'ar': 'ar-SA', + 'eu': 'eu-ES', + 'be': 'be-BY', // Assuming Belarus for Belarusian + 'bg': 'bg-BG', + 'bn': 'bn-BD', // Assuming Bangladesh for Bengali + 'ca': 'ca-ES', + 'cs': 'cs-CZ', + 'da': 'da-DK', // Assuming Denmark for Danish + 'de': 'de-DE', + 'el': 'el-GR', + 'eo': 'eo-EO', // Esperanto doesn't have a country + 'es': 'es-ES', + 'fa': 'fa-IR', + 'fi-fi': 'fi-FI', + 'fr': 'fr-FR', + 'gl': 'gl-ES', + 'he': 'he-IL', + 'hi': 'hi-IN', + 'hu': 'hu-HU', + 'id': 'id-ID', + 'it': 'it-IT', + 'ja': 'ja-JP', + 'ko': 'ko-KR', + 'lv': 'lv-LV', + 'ml': 'ml-IN', // Assuming India for Malayalam + 'ms': 'ms-MY', // Assuming Malaysia for Malay + 'nl': 'nl-NL', + 'no': 'nb-NO', // Using Norwegian Bokmål for Norwegian + 'oc': 'oc-FR', // Assuming France for Occitan + 'pl': 'pl-PL', + 'pt': 'pt-PT', + 'pt-BR': 'pt-BR', + 'ro': 'ro-RO', + 'ru': 'ru-RU', + 'sr': 'sr-RS', // Assuming Serbia for Serbian + 'se': 'sv-SE', // Assuming Swedish for 'se' + 'sk': 'sk-SK', + 'sq': 'sq-AL', // Assuming Albania for Albanian + 'ta': 'ta-IN', // Assuming India for Tamil + 'te': 'te-IN', // Assuming India for Telugu + 'th': 'th-TH', + 'tr': 'tr-TR', + 'uk': 'uk-UA', + 'ur': 'ur-PK', // Assuming Pakistan for Urdu + 'vi': 'vi-VN', + 'zh': 'zh-CN', + 'zh-TW': 'zh-TW', +}; + + export const { sceneCoordsToViewportCoords, viewportCoordsToSceneCoords, diff --git a/src/dialogs/Messages.ts b/src/dialogs/Messages.ts index 920dd6f..56b8af9 100644 --- a/src/dialogs/Messages.ts +++ b/src/dialogs/Messages.ts @@ -17,6 +17,21 @@ I develop this plugin as a hobby, spending my free time doing this. If you find
`, +"1.9.18":` +## New +- Excalidraw now syncs with Obsidian's language settings, provided translations are available. [#1297](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1297) + +## Fixed +- [#1285](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1285): Solved Obsidian crashes caused by copying images from Excalidraw into markdown notes. Going forward: + - Copying an image will paste its embed link, + - Copying a text element will paste the text, + - For all other elements with links, the link will be pasted. + - In all other cases nothing will be pasted. + +- Resolved grid instability ([#1298](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/1298)). +- Fixed missing ${String.fromCharCode(96)}[[square brackets]]${String.fromCharCode(96)} in PDF section references, making the links functional. +- Corrected the behavior of "Open current link in browser" for embedded YouTube and Vimeo frames. Clicking the globe button will now correctly open the links. +`, "1.9.17":` ## New - Significant performance improvements from Excalidraw.com diff --git a/src/menu/EmbeddableActionsMenu.tsx b/src/menu/EmbeddableActionsMenu.tsx index 6608a71..b0473b7 100644 --- a/src/menu/EmbeddableActionsMenu.tsx +++ b/src/menu/EmbeddableActionsMenu.tsx @@ -233,7 +233,11 @@ export class EmbeddableMenu { key={"Open"} title={t("OPEN_IN_BROWSER")} action={() => { - view.openExternalLink(iframe.src); + view.openExternalLink( + !iframe.src.startsWith("https://www.youtube.com") && !iframe.src.startsWith("https://player.vimeo.com") + ? iframe.src + : element.link + ); }} icon={ICONS.Globe} view={view}