mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
17
Commits
2.15.1
...
2.15.3-beta-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37543c6a56 | ||
|
|
98f065c8cc | ||
|
|
a29d9cb7b1 | ||
|
|
2eef8d0151 | ||
|
|
f7676b4102 | ||
|
|
ff6da66f94 | ||
|
|
0f7def145d | ||
|
|
a6586803de | ||
|
|
7fe1dc5494 | ||
|
|
b092a09c3b | ||
|
|
e67ed7ff4f | ||
|
|
5ab7311e74 | ||
|
|
dd05339f73 | ||
|
|
ec23f166ab | ||
|
|
42af86ed9f | ||
|
|
8b198a5785 | ||
|
|
739b745e95 |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.15.1",
|
||||
"version": "2.15.3-beta-2",
|
||||
"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.15.1",
|
||||
"version": "2.15.2",
|
||||
"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-31",
|
||||
"@zsviczian/excalidraw": "0.18.0-37",
|
||||
"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-31",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-31.tgz",
|
||||
"integrity": "sha512-A1wyp8EVOhCdoxdX7middc8LoLpjPLtxiSTeBbdMtungl8VQzAcQ2tSGCkncK/8RBcBaUk44Hr6KcWjezHnQew==",
|
||||
"version": "0.18.0-37",
|
||||
"resolved": "https://registry.npmjs.org/@zsviczian/excalidraw/-/excalidraw-0.18.0-37.tgz",
|
||||
"integrity": "sha512-SC4a6wj6IzE9HucxImDoOPcojojW/8FSry1hSA+hXfU350DhY6VlpFQ1DHJMPqVgIkFHB/hbCHt3klV+66+ouw==",
|
||||
"dependencies": {
|
||||
"@braintree/sanitize-url": "6.0.2",
|
||||
"@excalidraw/random-username": "1.1.0",
|
||||
|
||||
@@ -236,9 +236,8 @@ export const EXPORT_TYPES = ["svg", "dark.svg", "light.svg", "png", "dark.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"];
|
||||
export const VIDEO_TYPES = ["mp4","webm","ogv","mov","mkv","avi","m4v","wmv"];
|
||||
export const AUDIO_TYPES = ["mp3","wav", "m4a", "3gp", "flac", "ogg", "oga", "opus", "aac", "aiff", "aif", "mid", "midi"];
|
||||
export const CODE_TYPES = ["json", "css", "js"];
|
||||
|
||||
export const FRONTMATTER_KEYS:{[key:string]: {name: string, type: string, depricated?:boolean}} = {
|
||||
|
||||
+16
-1
@@ -90,6 +90,7 @@ import { CommandManager } from "./managers/CommandManager";
|
||||
import { EventManager } from "./managers/EventManager";
|
||||
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
|
||||
import en from "src/lang/locale/en";
|
||||
import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare const INITIAL_TIMESTAMP: number;
|
||||
@@ -423,7 +424,21 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.logStartupEvent("Switched to Excalidraw views");
|
||||
|
||||
try {
|
||||
if (this.settings.showReleaseNotes) {
|
||||
let skipReleaseNotes = false;
|
||||
if (this.settings.compareManifestToPluginVersion) {
|
||||
if (this.manifest.version !== PLUGIN_VERSION) {
|
||||
const versionMismatchPrompt = new VersionMismatchPrompt(this);
|
||||
const result = await versionMismatchPrompt.start();
|
||||
if(result) {
|
||||
skipReleaseNotes = true;
|
||||
this.manifest.version = PLUGIN_VERSION;
|
||||
await this.app.setting.open();
|
||||
this.app.setting.openTabById("community-plugins");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipReleaseNotes && this.settings.showReleaseNotes) {
|
||||
//I am repurposing imageElementNotice, if the value is true, this means the plugin was just newly installed to Obsidian.
|
||||
const obsidianJustInstalled = (this.settings.previousRelease === "0.0.0") || !this.settings.previousRelease;
|
||||
|
||||
|
||||
+15
-1
@@ -181,6 +181,7 @@ export interface ExcalidrawSettings {
|
||||
defaultTrayMode: boolean;
|
||||
previousRelease: string;
|
||||
showReleaseNotes: boolean;
|
||||
compareManifestToPluginVersion: boolean;
|
||||
showNewVersionNotification: boolean;
|
||||
//mathjaxSourceURL: string;
|
||||
latexBoilerplate: string;
|
||||
@@ -294,7 +295,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
allowPinchZoom: false,
|
||||
allowWheelZoom: false,
|
||||
zoomToFitOnOpen: true,
|
||||
zoomToFitOnResize: true,
|
||||
zoomToFitOnResize: false,
|
||||
zoomToFitMaxLevel: 2,
|
||||
zoomStep: 0.05,
|
||||
zoomMin: 0.1,
|
||||
@@ -365,6 +366,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
defaultTrayMode: true,
|
||||
previousRelease: "0.0.0",
|
||||
showReleaseNotes: true,
|
||||
compareManifestToPluginVersion: true,
|
||||
showNewVersionNotification: true,
|
||||
//mathjaxSourceURL: "https://cdn.jsdelivr.net/npm/mathjax@3.2.1/es5/tex-svg.js",
|
||||
latexBoilerplate: "\\color{blue}",
|
||||
@@ -726,6 +728,18 @@ export class ExcalidrawSettingTab extends PluginSettingTab {
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("WARN_ON_MANIFEST_MISMATCH_NAME"))
|
||||
.setDesc(fragWithHTML(t("WARN_ON_MANIFEST_MISMATCH_DESC")))
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(this.plugin.settings.compareManifestToPluginVersion)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.compareManifestToPluginVersion = value;
|
||||
this.applySettingsUpdate();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(detailsEl)
|
||||
.setName(t("NEWVERSION_NOTIFICATION_NAME"))
|
||||
.setDesc(fragWithHTML(t("NEWVERSION_NOTIFICATION_DESC")))
|
||||
|
||||
@@ -234,6 +234,8 @@ export default {
|
||||
RELEASE_NOTES_DESC:
|
||||
"<b><u>Toggle ON:</u></b> Display release notes each time you update Excalidraw to a newer version.<br>" +
|
||||
"<b><u>Toggle OFF:</u></b> Silent mode. You can still read release notes on <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases'>GitHub</a>.",
|
||||
WARN_ON_MANIFEST_MISMATCH_NAME: "Warn about incomplete plugin updates",
|
||||
WARN_ON_MANIFEST_MISMATCH_DESC: "Checks that the installed Excalidraw executable matches the version shown in Obsidian's plugin list. If they don't match (often after partial sync), you'll see a warning and can update. Disable to stop checking.",
|
||||
NEWVERSION_NOTIFICATION_NAME: "Plugin update notification",
|
||||
NEWVERSION_NOTIFICATION_DESC:
|
||||
"<b><u>Toggle ON:</u></b> Show a notification when a new version of the plugin is available.<br>" +
|
||||
@@ -1210,4 +1212,17 @@ export default {
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "Save current position in document",
|
||||
CAPTURE_PAGE: "Capture current page as image",
|
||||
|
||||
//VersionMismatch.ts
|
||||
//WARNING: Do not change the {VAL_RECORDED} and {VAL_ACTUAL} strings, they are replaced by the actual version values at runtime!
|
||||
VERSION_MISMATCH_NOTICE: `The version recorded by Obsidian is <b>{VAL_RECORDED}</b>, but the installed Excalidraw code is <b>{VAL_ACTUAL}</b>.`,
|
||||
|
||||
VERSION_MISMATCH_HEADING: "Excalidraw version mismatch",
|
||||
VERSION_MISMATCH_CAUSE: "This usually happens after a partial sync (e.g. Obsidian Sync Standard) where large files (main.js > 5MB) did not sync, so only <code>manifest.json</code> updated.",
|
||||
VERSION_MISMATCH_OPTIONS: "Options:<br><b>1.</b> Re-download the plugin (recommended).<br><b>2.</b> Ignore for now.",
|
||||
VERSION_MISMATCH_NOTE: "Note: Updating version info manually may affect tools that read manifest.json directly (e.g. Plugin Update Tracker, BRAT) until a full reinstall.",
|
||||
VERSION_MISMATCH_DISABLE_NAME: "Disable future mismatch warnings",
|
||||
VERSION_MISMATCH_DISABLE_DESC: "You can re-enable this under: Settings → Excalidraw → Basic → Warn about incomplete plugin updates.",
|
||||
VERSION_MISMATCH_REDOWNLOAD: "Re-download plugin",
|
||||
VERSION_MISMATCH_IGNORE: "Ignore",
|
||||
};
|
||||
+47
-1
@@ -58,6 +58,10 @@ export default {
|
||||
NEW_IN_POPOUT_WINDOW_EMBED: "Crear nuevo bosquejo - EN UNA VENTANA EMERGENTE - e incrustar en el documento activo",
|
||||
TOGGLE_LOCK: "Alternar Elemento de Texto entre edición RAW y VISTA PREVIA",
|
||||
DELETE_FILE: "Eliminar imagen o archivo Markdown seleccionado de la Bóveda de Obsidian",
|
||||
MARKER_FRAME_SHOW: "Mostrar Marker Frames(marcos de marcador)",
|
||||
MARKER_FRAME_HIDE: "Ocultar Marker Frames(marcos de marcador)",
|
||||
MARKER_FRAME_TITLE_SHOW: "Mostrar títulos de Marker Frames(marcos de marcador)",
|
||||
MARKER_FRAME_TITLE_HIDE: "Ocultar títulos de Marker Frames(marcos de marcador)",
|
||||
COPY_ELEMENT_LINK: "Copiar [[enlace]] para el/los elemento(s) seleccionado(s)",
|
||||
COPY_DRAWING_LINK: "Copiar ![[enlace incrustado]] de este bosquejo",
|
||||
INSERT_LINK_TO_ELEMENT:
|
||||
@@ -134,6 +138,14 @@ export default {
|
||||
"2) Luego, crea un bosquejo vacío en un nuevo panel haciendo CTRL/CMD+clic en el botón de la barra de Excalidraw,\n" +
|
||||
"3) y pega tu trabajo en el nuevo documento con CTRL/CMD+V.",
|
||||
ARIA_LABEL_TRAY_MODE: "El modo bandeja ofrece un lienzo alternativo y más espacioso",
|
||||
TRAY_TRAY_MODE: "Activar/desactivar modo bandeja",
|
||||
TRAY_SCRIPT_LIBRARY: "Biblioteca de scripts",
|
||||
TRAY_SCRIPT_LIBRARY_ARIA: "Explorar la biblioteca de scripts de Excalidraw",
|
||||
TRAY_EXPORT: "Exportar imagen...",
|
||||
TRAY_EXPORT_ARIA: "Exportar imagen como archivo PNG, SVG o Excalidraw",
|
||||
TRAY_SAVE: "Guardar",
|
||||
TRAY_SWITCH_TO_MD: "Abrir como Markdown",
|
||||
TRAY_SWITCH_TO_MD_ARIA: "Cambiar a vista de Markdown",
|
||||
MASK_FILE_NOTICE: "Este es un archivo de máscara. Se usa para recortar y enmascarar partes de la imagen. Mantén presionado el aviso para abrir el video de ayuda.",
|
||||
INSTALL_SCRIPT_BUTTON: "Instalar o actualizar scripts de Excalidraw",
|
||||
OPEN_AS_MD: "Abrir como Markdown",
|
||||
@@ -178,7 +190,7 @@ export default {
|
||||
WELCOME_COMMAND_PALETTE: 'Escribe "Excalidraw" en la Paleta de Comandos',
|
||||
WELCOME_OBSIDIAN_MENU: "Explora el Menú de Obsidian en la esquina superior derecha",
|
||||
WELCOME_SCRIPT_LIBRARY: "Visita la Librería de Scripts",
|
||||
WELCOME_HELP_MENU: "Encuentra ayuda en el menú_de_hamburguesa",
|
||||
WELCOME_HELP_MENU: "Encuentra ayuda en el menú de la esquina superior izquierda",
|
||||
WELCOME_YOUTUBE_ARIA: "Canal de YouTube de PKM Visual",
|
||||
WELCOME_YOUTUBE_LINK: "Echa un vistazo al canal de YouTube de PKM Visual.",
|
||||
WELCOME_DISCORD_ARIA: "Únete al servidor de Discord",
|
||||
@@ -912,6 +924,10 @@ FILENAME_HEAD: "Nombre de archivo",
|
||||
SCRIPT_EXECUTION_ERROR:
|
||||
"Error de ejecución del script. Por favor, revisa la consola del desarrollador para ver el mensaje de error.",
|
||||
|
||||
//ExcalidrawViewUtils.ts
|
||||
MARKER_FRAME_RENDERING_DISABLED_NOTICE: "Hay marker-frames (marcos de marcador) ocultos en la escena.",
|
||||
//DRAWING_HAS_BACK_OF_THE_CARD: "Hay notas en el reverso de este dibujo.",
|
||||
|
||||
//ExcalidrawData.ts
|
||||
LOAD_FROM_BACKUP: "El archivo de Excalidraw estaba dañado. Cargando desde el archivo de backup(copia de seguridad).",
|
||||
FONT_LOAD_SLOW: "Cargando fuentes...\n\n Esto está tomando más tiempo de lo esperado. Si este retraso ocurre regularmente, puedes descargar las fuentes de forma local en tu Bóveda. \n\n" +
|
||||
@@ -1164,4 +1180,34 @@ FILENAME_HEAD: "Nombre de archivo",
|
||||
|
||||
//exportUtils.ts
|
||||
PDF_EXPORT_DESKTOP_ONLY: "La exportación a PDF solo está disponible en escritorio.",
|
||||
|
||||
//UniversalInsertFileModal.ts
|
||||
UIFM_TITLE: "Insertar archivo desde la bóveda",
|
||||
UIFM_SECTION_HEAD: "Seleccionar encabezado de sección",
|
||||
UIFM_ANCHOR: "Anclar al 100% del tamaño original",
|
||||
UIFM_ANCHOR_DESC: "Esta es una función Pro, úsala solo si entiendes cómo funciona. Si se activa, incluso si cambias el tamaño de la imagen importada en Excalidraw, la próxima vez que abras el dibujo, la imagen volverá al 100% de su tamaño. Esto es útil para incrustar una idea atómica de Excalidraw en otra nota y preservar el tamaño relativo del texto y los íconos.",
|
||||
UIFM_BTN_EMBEDDABLE: "como Incrustable",
|
||||
UIFM_BTN_PDF: "como Pdf",
|
||||
UIFM_BTN_IMAGE: "como Imagen",
|
||||
|
||||
//ReleaseNotes.ts
|
||||
RN_WELCOME: "Bienvenido a Excalidraw",
|
||||
|
||||
//Excalidraw component
|
||||
COMP_IMG: "Imágenes y archivos",
|
||||
COMP_IMG_FROM_SYSTEM: "Importar desde el sistema",
|
||||
COMP_IMG_ANY_FILE: "Cualquier archivo de la bóveda",
|
||||
COMP_IMG_LaTeX: "Fórmula de LaTeX",
|
||||
COMP_FRAME: "Acciones de Frame(marco)",
|
||||
COMP_FRAME_HINT: "Activar/desactivar Marker-Frame (marco de marcador). Marcos de guía para definir diapositivas/áreas de impresión/referencias de imagen. " +
|
||||
"Se ocultan en las exportaciones de imágenes y no contienen elementos. Oculta/muestra los marcos desde el menú contextual del lienzo.",
|
||||
|
||||
//CustomEmbeddable.tsx
|
||||
NOTICE_PDF_THEME: "Sobreescritura de Tema de PDF .\n" +
|
||||
"Controla esto a través de la propiedad de documento 'excalidraw-embeddable-theme' de este archivo (anula la configuración del complemento).\n\n" +
|
||||
"Valores: dark, light, auto=Excalidraw, default=Obsidian.",
|
||||
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "Guardar posición actual en el documento",
|
||||
CAPTURE_PAGE: "Capturar la página actual como imagen",
|
||||
};
|
||||
+24
-20
@@ -92,7 +92,7 @@ export default {
|
||||
ERROR_TRY_AGAIN: "请重试。",
|
||||
PASTE_CODEBLOCK: "粘贴代码块",
|
||||
INSERT_LATEX:
|
||||
`插入 LaTeX 公式(如:\\binom{n}{k} = \\frac{n!}{k!(n-k)!})`,
|
||||
`插入 LaTeX 公式到当前绘图中`,
|
||||
ENTER_LATEX: "输入 LaTeX 公式",
|
||||
READ_RELEASE_NOTES: "阅读本插件的更新说明",
|
||||
RUN_OCR: "OCR 整个绘图:识别涂鸦和图片里的文本并复制到剪贴板和笔记属性中",
|
||||
@@ -155,7 +155,7 @@ export default {
|
||||
LINK_BUTTON_CLICK_NO_TEXT:
|
||||
"请选择一个包含内部或外部链接的元素。\n",
|
||||
LINEAR_ELEMENT_LINK_CLICK_ERROR:
|
||||
"箭头和线元素的链接无法通过 " + labelCTRL() + " + 点击元素来导航,因为这也会激活线编辑器。\n" +
|
||||
"箭头和线条元素的链接无法通过 " + labelCTRL() + " + 点击元素来跳转,因为这也会激活线条编辑器。\n" +
|
||||
"请使用右键上下文菜单打开链接,或点击元素右上角的链接指示器。\n",
|
||||
FILENAME_INVALID_CHARS:
|
||||
'文件名不能包含以下符号: * " \\ < > : | ? #',
|
||||
@@ -278,10 +278,10 @@ export default {
|
||||
TEMPLATE_NAME: "Excalidraw 模板文件(區分大小寫!)",
|
||||
TEMPLATE_DESC:
|
||||
"Excalidraw 模板文件(文件夹)的存储路径。<br>" +
|
||||
"<b>模板文件:</b>比如:您的模板在默认的 Excalidraw 文件夹中且文件名是 Template.md," +
|
||||
"<b>模板文件:</b>例如:您的模板在默认的 Excalidraw 文件夹中且文件名是 Template.md," +
|
||||
"则该项应设为 Excalidraw/Template.md 或 Excalidraw/Template(省略 .md 扩展名)。<br>" +
|
||||
"如果您在兼容模式下使用 Excalidraw,那么您的模板文件也必须是旧的 *.excalidraw 格式," +
|
||||
"例如 Excalidraw/Template.excalidraw。<br><b>模板文件夹:</b> 您还可以将文件夹设置为模板。" +
|
||||
"如 Excalidraw/Template.excalidraw。<br><b>模板文件夹:</b> 您还可以将文件夹设置为模板。" +
|
||||
"这时,创建新绘图时将提示您选择使用哪个模板。<br>" +
|
||||
"<b>专业提示:</b> 如果您正在使用 Obsidian Templater 插件,您可以将 Templater 代码添加到不同的" +
|
||||
"Excalidraw 模板中,以自动配置您的绘图。",
|
||||
@@ -323,7 +323,7 @@ export default {
|
||||
"默认的 OpenAI API URL。请填写有效的 OpenAI API URL。" +
|
||||
"Excalidraw 会通过该 URL 发送 API 请求给 OpenAI。我没有对该项做任何错误处理,请谨慎修改。",
|
||||
AI_OPENAI_DEFAULT_IMAGE_API_URL_NAME: "OpenAI 图片生成 API URL",
|
||||
AI_OPENAI_DEFAULT_VISION_MODEL_PLACEHOLDER: "输入默认 AI 模型名称,例如:gpt-4o",
|
||||
AI_OPENAI_DEFAULT_VISION_MODEL_PLACEHOLDER: "输入默认 AI 模型名称,如 gpt-4o",
|
||||
SAVING_HEAD: "保存",
|
||||
SAVING_DESC: "包括:压缩,自动保存的时间间隔,文件的命名格式和扩展名等。",
|
||||
COMPRESS_NAME: "压缩 Excalidraw JSON",
|
||||
@@ -332,7 +332,7 @@ export default {
|
||||
"(使用 <a href='https://pieroxy.net/blog/pages/lz-string/index.html'>LZ-String</a> 算法)。" +
|
||||
"这样一方面可以避免原来的明文 JSON 数据干扰 Obsidian 的文本搜索结果," +
|
||||
"另一方面减小了绘图文件的体积。<br>" +
|
||||
"当您通过功能区按钮或命令将绘图切换至 Markdown 视图模式时," +
|
||||
"当您通过菜单按钮或命令将绘图切换至 Markdown 视图模式时," +
|
||||
"数据将被解码回 JSON 格式以便阅读和编辑;" +
|
||||
"而当您切换回 Excalidraw 模式时,数据就会被再次编码。<br>" +
|
||||
"开启该项后,对于之前已存在但未压缩的绘图文件," +
|
||||
@@ -347,8 +347,8 @@ export default {
|
||||
"在需要阅读或编辑时手动解压缩绘图 JSON。",
|
||||
AUTOSAVE_INTERVAL_DESKTOP_NAME: "桌面端自动保存时间间隔",
|
||||
AUTOSAVE_INTERVAL_DESKTOP_DESC:
|
||||
"每隔多长时间自动保存一次(如果绘图文件没有发生改变,将不会保存)。" +
|
||||
"当 Obsidian 应用内的焦点离开活动文件,如关闭工作空间、点击菜单栏、切换到其他页面或面板等时,也会触发自动保存;" +
|
||||
"每隔多长时间自动保存一次。如果绘图文件没有发生改变,将不会保存。" +
|
||||
"当 Obsidian 应用内的焦点离开活动文件,如关闭某个标签页、点击功能区、切换到其他标签页等时,也会触发自动保存;" +
|
||||
"直接退出 Obsidian 应用(不管是终结进程还是点关闭按钮)不会触发自动保存。",
|
||||
AUTOSAVE_INTERVAL_MOBILE_NAME: "移动端自动保存时间间隔",
|
||||
AUTOSAVE_INTERVAL_MOBILE_DESC:
|
||||
@@ -448,9 +448,9 @@ export default {
|
||||
"请参阅下方 <a href='#"+TAG_PDFEXPORT+"'>PDF 导出设置</a>。<br>" +
|
||||
"⚠️ 关闭并重新打开 Excalidraw/Markdown 文件后生效。",
|
||||
HOTKEY_OVERRIDE_HEAD: "热键覆盖",
|
||||
HOTKEY_OVERRIDE_DESC: `一些 Excalidraw 的热键,例如 ${labelCTRL()}+Enter 用于编辑文本,或 ${labelCTRL()}+K 用于创建元素链接。` +
|
||||
"与 Obsidian 的热键设置发生冲突。您在下面添加的热键组合将在使用 Excalidraw 时覆盖 Obsidian 的热键设置," +
|
||||
`因此如果您希望在 Excalidraw 中默认选择“组合对象”,而不是“查看关系图谱”(核心插件 - 关系图谱),您可以添加 ${labelCTRL()}+G。`,
|
||||
HOTKEY_OVERRIDE_DESC: `一些 Excalidraw 的热键,如 ${labelCTRL()}+Enter 用于编辑文本,或 ${labelCTRL()}+K 用于创建元素链接,` +
|
||||
"与 Obsidian 的热键设置冲突。您在下面添加的热键组合将在使用 Excalidraw 时覆盖 Obsidian 的热键设置," +
|
||||
`因此如果您希望在 Excalidraw 中默认“编组”,而不是“查看关系图谱”(核心插件 - 关系图谱),您可以添加 ${labelCTRL()}+G。`,
|
||||
THEME_HEAD: "主题和样式",
|
||||
ZOOM_AND_PAN_HEAD: "缩放和平移",
|
||||
PAN_WITH_RIGHT_MOUSE_BUTTON_NAME: "右键拖动平移",
|
||||
@@ -621,17 +621,17 @@ export default {
|
||||
MD_DEFAULT_COLOR_NAME:
|
||||
"MD-Embed 的默认文本颜色",
|
||||
MD_DEFAULT_COLOR_DESC:
|
||||
"可以填写 HTML 颜色名,如 steelblue(参考 <a href='https://www.w3schools.com/colors/colors_names.asp'>HTML Color Names</a>),或者有效的 16 进制颜色值,例如 #e67700,或者任何其他有效的 CSS 颜色。<br>" +
|
||||
"可以填写 HTML 颜色名,如 steelblue(参考 <a href='https://www.w3schools.com/colors/colors_names.asp'>HTML Color Names</a>),或者有效的 16 进制颜色值,如 #e67700,或者任何其他有效的 CSS 颜色。<br>" +
|
||||
"可为某个 MD-Embed 单独设置,方法是在其 frontmatter 中添加如 <code>excalidraw-font-color: steelblue</code> 的键值对。",
|
||||
MD_DEFAULT_BORDER_COLOR_NAME:
|
||||
"MD-Embed 的默认边框颜色",
|
||||
MD_DEFAULT_BORDER_COLOR_DESC:
|
||||
"可以填写 HTML 颜色名,如 steelblue(参考 <a href='https://www.w3schools.com/colors/colors_names.asp'>HTML Color Names</a>),或者有效的 16 进制颜色值,例如 #e67700,或者任何其他有效的 CSS 颜色。<br>" +
|
||||
"可以填写 HTML 颜色名,如 steelblue(参考 <a href='https://www.w3schools.com/colors/colors_names.asp'>HTML Color Names</a>),或者有效的 16 进制颜色值,如 #e67700,或者任何其他有效的 CSS 颜色。<br>" +
|
||||
"可为某个 MD-Embed 单独设置,方法是在其 frontmatter 中添加如 <code>excalidraw-border-color: gray</code> 的键值对。<br>" +
|
||||
"如果您不想要边框,请留空。",
|
||||
MD_CSS_NAME: "MD-Embed 的默认 CSS 样式表",
|
||||
MD_CSS_DESC:
|
||||
"MD-Embed 图像所采用的 CSS 样式表文件名。需包含扩展名,例如 md-embed.css。" +
|
||||
"MD-Embed 图像所采用的 CSS 样式表文件名。需包含扩展名,如 md-embed.css。" +
|
||||
"允许使用 Markdown 文档(如 md-embed-css.md),但其内容应符合 CSS 语法。<br>" +
|
||||
"如果您要查询 CSS 所作用的 HTML 节点,请在 Obsidian 开发者控制台(Ctrl+Shift+I)中键入命令:" +
|
||||
"<code>ExcalidrawAutomate.mostRecentMarkdownSVG</code> —— 这将显示 Excalidraw 最近生成的 SVG。<br>" +
|
||||
@@ -703,7 +703,7 @@ export default {
|
||||
"也就是说,该项不会自动帮您生成 SVG/PNG 副本,而只会引用已有的 SVG/PNG 副本。",
|
||||
EMBED_MARKDOWN_COMMENT_NAME: "将链接作为注释插入",
|
||||
EMBED_MARKDOWN_COMMENT_DESC:
|
||||
"在图像下方以 Markdown 链接形式插入原始 Excalidraw 文件的链接,例如:<code>%%[[drawing.excalidraw]]%%</code>。<br>" +
|
||||
"在图像下方以 Markdown 链接形式插入原始 Excalidraw 文件的链接,如 <code>%%[[drawing.excalidraw]]%%</code>。<br>" +
|
||||
"除了添加 Markdown 注释之外,您还可以选择嵌入的 SVG 或 PNG,并使用命令面板:" +
|
||||
"'<code>Excalidraw: 打开 Excalidraw 绘图</code>'来打开该绘图",
|
||||
EMBED_WIKILINK_NAME: "“嵌入绘图到当前 Markdown 文档中”系列命令产生的内部链接类型",
|
||||
@@ -748,7 +748,7 @@ export default {
|
||||
EXPORT_BOTH_DARK_AND_LIGHT_DESC: "若开启,Excalidraw 将导出两个文件:filename.dark.png(或 .svg)和 filename.light.png(或 .svg)。<br>" +
|
||||
"该项可作用于“自动导出 SVG 副本”、“自动导出 PNG 副本”,以及其他的手动的导出命令。",
|
||||
COMPATIBILITY_HEAD: "兼容性设置",
|
||||
COMPATIBILITY_DESC: "如果没有特殊原因(例如您想同时在 VSCode/Logseq 和 Obsidian 中使用 Excalidraw),建议您使用 Markdown 格式的绘图文件,而不是旧的 Excalidraw.com 格式,因为本插件的很多功能在旧格式中无法使用。",
|
||||
COMPATIBILITY_DESC: "如果没有特殊原因(例如:您想同时在 VSCode/Logseq 和 Obsidian 中使用 Excalidraw),建议您使用 Markdown 格式的绘图文件,而不是旧的 Excalidraw.com 格式,因为本插件的很多功能在旧格式中无法使用。",
|
||||
DUMMY_TEXT_ELEMENT_LINT_SUPPORT_NAME: "兼容代码格式化(Linting)",
|
||||
DUMMY_TEXT_ELEMENT_LINT_SUPPORT_DESC: "Excalidraw 对 <code># Excalidraw Data</code> 下的文件结构非常敏感。文档的自动格式化可能会在 Excalidraw 数据中造成错误。" +
|
||||
"虽然我已经努力使数据加载对自动格式化变更具有一定的抗性,但这种解决方案并非万无一失。<br>" +
|
||||
@@ -864,7 +864,7 @@ export default {
|
||||
下载后,将内容解压到您的仓库中的一个文件夹内。<br>
|
||||
预加载字体会影响启动性能。因此,您可以选择加载哪些字体。`,
|
||||
CJK_ASSETS_FOLDER_NAME: "CJK 字体文件夹(區分大小寫!)",
|
||||
CJK_ASSETS_FOLDER_DESC: `您可以在此设置 CJK 字体文件夹的位置。例如,您可以选择将其放置在 <code>Excalidraw/CJK Fonts</code> 下。<br>
|
||||
CJK_ASSETS_FOLDER_DESC: `您可以在此设置 CJK 字体文件夹的位置。例如:<code>Excalidraw/CJK Fonts</code>。<br>
|
||||
<strong>重要:</strong> 请勿将此文件夹设置为仓库根目录!请勿在此文件夹中放置其他字体。<br>
|
||||
<strong>注意:</strong> 如果您使用 Obsidian Sync 并希望在设备之间同步这些字体文件,请确保 Obsidian Sync 设置为同步“所有其他文件类型”。`,
|
||||
LOAD_CHINESE_FONTS_NAME: "启动时从文件加载中文字体",
|
||||
@@ -994,7 +994,7 @@ export default {
|
||||
ES_FILENAME_VISIBLE: "显示页内标题",
|
||||
ES_BACKGROUND_HEAD: "背景色",
|
||||
ES_BACKGROUND_DESC_INFO: "点击此处查看更多颜色信息",
|
||||
ES_BACKGROUND_DESC_DETAIL: "背景色仅影响预览模式的 MD-Embeddable。在编辑模式,它会根据场景(通过笔记属性设置)或插件设置,遵循 Obsidian 的深色/浅色主题。背景色有两层:元素背景色(下层颜色)和上层颜色。选择“匹配元素”表示两层都遵循元素背景色。选择“匹配绘图”或特定背景色不会改变元素背景色。设置透明度(例如 50%)会将绘图或选定的颜色与元素背景色混合。要移除元素背景色,可以在 Excalidraw 的元素属性编辑器中将元素背景色设置为透明,这样只有上层颜色生效。",
|
||||
ES_BACKGROUND_DESC_DETAIL: "背景色仅影响预览模式的 MD-Embeddable。在编辑模式,它会根据场景(通过笔记属性设置)或插件设置,遵循 Obsidian 的深色/浅色主题。背景色有两层:元素背景色(下层颜色)和上层颜色。选择“匹配元素”表示两层都遵循元素背景色。选择“匹配绘图”或特定背景色不会改变元素背景色。设置透明度(如 50%)会将绘图或选定的颜色与元素背景色混合。要移除元素背景色,可以在 Excalidraw 的元素属性编辑器中将元素背景色设置为透明,这样只有上层颜色生效。",
|
||||
ES_BACKGROUND_MATCH_ELEMENT: "匹配元素背景色",
|
||||
ES_BACKGROUND_MATCH_CANVAS: "匹配绘图背景色",
|
||||
ES_BACKGROUND_COLOR: "背景色",
|
||||
@@ -1171,7 +1171,7 @@ export default {
|
||||
// Screenshot tab
|
||||
EXPORTDIALOG_NOT_AVAILALBE: "抱歉,此功能仅在绘图在主 Obsidian 工作区打开时可用。",
|
||||
EXPORTDIALOG_TAB_SCREENSHOT: "截图",
|
||||
EXPORTDIALOG_SCREENSHOT_DESC: "截图将包含可嵌入的内容,例如 Markdown 页面、YouTube、网站等。它们仅在桌面端可用,无法自动导出,并且仅支持 PNG 格式。",
|
||||
EXPORTDIALOG_SCREENSHOT_DESC: "截图将包含可嵌入的内容,如 Markdown 页面、YouTube、网站等。它们仅在桌面端可用,无法自动导出,并且仅支持 PNG 格式。",
|
||||
SCREENSHOT_DESKTOP_ONLY: "截图功能仅在桌面端可用",
|
||||
SCREENSHOT_FILE_SUCCESS: "截图已保存到仓库",
|
||||
SCREENSHOT_CLIPBOARD_SUCCESS: "截图已复制到剪贴板",
|
||||
@@ -1200,10 +1200,14 @@ export default {
|
||||
COMP_IMG_LaTeX: "LaTeX 公式",
|
||||
COMP_FRAME: "画框操作",
|
||||
COMP_FRAME_HINT: "切换标记画框。标记画框仅用于引导,用于定义幻灯片/打印区域/[[file#^frame=id]]," +
|
||||
"导出时会隐藏;也不会包含元素。通过上下文菜单显示/隐藏标记画框。",
|
||||
"导出时会隐藏;也不会包含元素。通过上下文菜单显示/隐藏标记画框。",
|
||||
|
||||
//CustomEmbeddable.tsx
|
||||
NOTICE_PDF_THEME: "已覆盖 PDF 主题。\n" +
|
||||
"通过文件的 'excalidraw-embeddable-theme' 笔记属性设置(将覆盖插件设置)。\n\n" +
|
||||
"值:dark/light/auto/default,表示深色、浅色、跟随 Excalidraw 或 Obsidian 主题。",
|
||||
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "保存当前进度",
|
||||
CAPTURE_PAGE: "以图像形式截取当前页面",
|
||||
};
|
||||
+460
-414
File diff suppressed because it is too large.
Load diff
@@ -17,6 +17,23 @@ 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.15.3":`
|
||||
## Fixed
|
||||
- New back of the note cards are not visible until the drawing is saved. When adding a back-of-the-note card using the context menu, the card got placed at the absolute 0,0 position in the scene instead of the current pointer position. [#9949](https://github.com/excalidraw/excalidraw/issues/9949)
|
||||
- Drawings created 4 years ago don't open [#2479](https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/2479)
|
||||
|
||||
## New
|
||||
- Added startup check that detects when Obsidian's recorded plugin version differs from the installed Excalidraw code (e.g. after partial sync of large files) and offers to update or ignore, with a setting to disable the check.
|
||||
`,
|
||||
"2.15.2":`
|
||||
## Fixed:
|
||||
- Pressing enter on a text element erroneously activated all markdown embeddables in the scene. [discord](https://discord.com/channels/1026825302900494357/1412683408424833045)
|
||||
- After updating to PDF++ 0.40.31, touch scrolling of embedded PDF documents stopped working on mobile devices, and the PDF document appeared with the wrong themes in some cases.
|
||||
- Issue with the Kanban board as an active embeddable on mobile phones is fixed.
|
||||
|
||||
## Fixed in ExcalidrawAutomate
|
||||
- \`getActiveEmbeddableViewOrEditor (view?:ExcalidrawView): {view:any}|{file:TFile, editor:Editor}|{node: ObsidianCanvasNode}|null;\` no returns the node, instead of the empty view from the leaf.
|
||||
`,
|
||||
"2.15.1":`
|
||||
## Fixed
|
||||
- PDF improvements
|
||||
|
||||
@@ -8,6 +8,8 @@ import { addBackOfTheNoteCard } from "src/utils/excalidrawViewUtils";
|
||||
|
||||
export class SelectCard extends FuzzySuggestModal<string> {
|
||||
private center: boolean = false;
|
||||
private x: number = 0;
|
||||
private y: number = 0;
|
||||
|
||||
constructor(
|
||||
public app: App,
|
||||
@@ -32,7 +34,7 @@ export class SelectCard extends FuzzySuggestModal<string> {
|
||||
this.close();
|
||||
return;
|
||||
}
|
||||
addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center);
|
||||
addBackOfTheNoteCard(this.view, item, true, undefined, undefined, this.center, {x: this.x, y: this.y});
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
@@ -49,17 +51,16 @@ 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);
|
||||
this.x = centerPos.x - (CARD_WIDTH / 2);
|
||||
this.y = centerPos.y - (CARD_HEIGHT / 2);
|
||||
}
|
||||
}
|
||||
|
||||
const id = ea.addEmbeddable(
|
||||
x,y,CARD_WIDTH,CARD_HEIGHT,
|
||||
this.x,this.y,CARD_WIDTH,CARD_HEIGHT,
|
||||
`[[${this.view.file.path}#${item}]]`
|
||||
);
|
||||
(async () => {
|
||||
@@ -70,7 +71,9 @@ export class SelectCard extends FuzzySuggestModal<string> {
|
||||
}
|
||||
|
||||
public start(center: boolean = false): void {
|
||||
this.center = center;
|
||||
this.x = this.view.currentPosition.x;
|
||||
this.y = this.view.currentPosition.y;
|
||||
this.center = !!center;
|
||||
this.emptyStateText = t("EMPTY_SECTION_MESSAGE");
|
||||
this.setPlaceholder(t("SELECT_SECTION_OR_TYPE_NEW"));
|
||||
this.open();
|
||||
|
||||
@@ -819,11 +819,11 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
},
|
||||
{
|
||||
field: "getActiveEmbeddableViewOrEditor",
|
||||
code: "getActiveEmbeddableViewOrEditor(view?: ExcalidrawView);",
|
||||
code: "getActiveEmbeddableViewOrEditor (view?:ExcalidrawView): {view:any}|{file:TFile, editor:Editor}|{node: ObsidianCanvasNode}|null;",
|
||||
desc: "Returns the editor or leaf.view of the currently active embedded obsidian file.<br>" +
|
||||
"If view is not provided, ea.targetView is used.<br>" +
|
||||
"If the embedded file is a markdown document the function will return<br>" +
|
||||
"<code>{file:TFile, editor:Editor}</code> otherwise it will return {view:any}. You can check view type with view.getViewType();",
|
||||
"If the embedded file is an eligible Obsidian canvas node document the function will return<br>" +
|
||||
"<code>{file:TFile, editor:Editor}</code> of {node: ObsidianCanvasNode}, otherwise it will return {view:any}. You can check view type with view.getViewType();",
|
||||
after: "",
|
||||
},
|
||||
{
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import { Modal, Setting } from "obsidian";
|
||||
import ExcalidrawPlugin from "src/core/main";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
declare const PLUGIN_VERSION: string;
|
||||
|
||||
/**
|
||||
* A modal dialog that informs the user about a version mismatch between the version recorded by Obsidian and the actual version of the plugin executable.
|
||||
* Explain that this can be the result of a partial sync, such as an Obsidian Sync Standard plan, which does not syncronize files larger than 5MB, and the plugin executable is larger.
|
||||
* Explain that changing the plugin version information in Obsidian can lead to unexpected behavior in plugins suchs as the Plugin Update Tracker plugin or the BRAT plugin.
|
||||
* The user has a toggle button to disable this check in the future. There is additional information that this can be reenabled in plugin settings.
|
||||
* The user can click update obsidian version info to match the plugin version, and open Obsidian settings to redownload the plugin.
|
||||
* The user can click ignore to dismiss the dialog.
|
||||
*/
|
||||
export class VersionMismatchPrompt extends Modal {
|
||||
private resolvePromise: (value: any) => void;
|
||||
public promise: Promise<any>;
|
||||
private resolved: boolean;
|
||||
private isDirty: boolean = false;
|
||||
|
||||
public constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
) {
|
||||
super(plugin.app);
|
||||
}
|
||||
|
||||
async start(): Promise<any> {
|
||||
this.promise = new Promise((resolve) => {
|
||||
this.resolvePromise = resolve;
|
||||
});
|
||||
await this.plugin.loadSettings();
|
||||
this.buildUI();
|
||||
this.open();
|
||||
return this.promise;
|
||||
}
|
||||
|
||||
private buildUI() {
|
||||
const { contentEl } = this;
|
||||
contentEl.empty();
|
||||
const recorded = this.plugin.manifest.version;
|
||||
const actual = PLUGIN_VERSION;
|
||||
|
||||
contentEl.createEl("h2", { text: t("VERSION_MISMATCH_HEADING") });
|
||||
const p1 = contentEl.createEl("p");
|
||||
p1.innerHTML = t("VERSION_MISMATCH_NOTICE")
|
||||
.replace("{VAL_RECORDED}", recorded)
|
||||
.replace("{VAL_ACTUAL}", actual);
|
||||
|
||||
const p2 = contentEl.createEl("p");
|
||||
p2.innerHTML = t("VERSION_MISMATCH_CAUSE");
|
||||
|
||||
const p3 = contentEl.createEl("p");
|
||||
p3.innerHTML = t("VERSION_MISMATCH_OPTIONS");
|
||||
|
||||
const p4 = contentEl.createEl("p");
|
||||
p4.innerHTML = t("VERSION_MISMATCH_NOTE");
|
||||
|
||||
new Setting(contentEl)
|
||||
.setName(t("VERSION_MISMATCH_DISABLE_NAME"))
|
||||
.setDesc(t("VERSION_MISMATCH_DISABLE_DESC"))
|
||||
.addToggle(tg =>
|
||||
tg.setValue(!this.plugin.settings.compareManifestToPluginVersion ? true : false)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.compareManifestToPluginVersion = !value; // invert because label is Disable ...
|
||||
this.isDirty = true;
|
||||
}),
|
||||
);
|
||||
|
||||
// Buttons row
|
||||
const buttonBar = contentEl.createDiv({ cls: "ex-version-mismatch-buttons" });
|
||||
|
||||
const redownloadBtn = buttonBar.createEl("button", { text: t("VERSION_MISMATCH_REDOWNLOAD") });
|
||||
redownloadBtn.addEventListener("click", () => {
|
||||
this.resolved = true; // triggers opening settings in caller
|
||||
this.close();
|
||||
});
|
||||
|
||||
const ignoreBtn = buttonBar.createEl("button", { text: t("VERSION_MISMATCH_IGNORE") });
|
||||
ignoreBtn.addEventListener("click", () => {
|
||||
this.resolved = false;
|
||||
this.close();
|
||||
});
|
||||
|
||||
buttonBar.style.display = "flex";
|
||||
buttonBar.style.gap = "0.5rem";
|
||||
buttonBar.style.marginTop = "1rem";
|
||||
redownloadBtn.style.backgroundColor = "var(--interactive-accent)";
|
||||
redownloadBtn.style.color = "var(--text-on-accent)";
|
||||
}
|
||||
|
||||
async onClose() {
|
||||
super.onClose();
|
||||
if(this.isDirty) {
|
||||
await this.plugin.saveSettings();
|
||||
}
|
||||
if (!this.resolved) {
|
||||
this.resolvePromise && this.resolvePromise(false);
|
||||
} else {
|
||||
this.resolvePromise && this.resolvePromise(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,6 +90,7 @@ import { CaptureUpdateAction } from "src/constants/constants";
|
||||
import { AutoexportConfig } from "src/types/excalidrawViewTypes";
|
||||
import { FloatingModal } from "./Dialogs/FloatingModal";
|
||||
import { patchMobileView } from "src/utils/customEmbeddableUtils";
|
||||
import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
|
||||
|
||||
extendPlugins([
|
||||
HarmonyPlugin,
|
||||
@@ -476,7 +477,7 @@ export class ExcalidrawAutomate {
|
||||
* @param {ExcalidrawView} [view] - The view to check.
|
||||
* @returns {{view:any}|{file:TFile, editor:Editor}|null} The active embeddable view or editor.
|
||||
*/
|
||||
public getActiveEmbeddableViewOrEditor (view?:ExcalidrawView): {view:any}|{file:TFile, editor:Editor}|null {
|
||||
public getActiveEmbeddableViewOrEditor (view?:ExcalidrawView): {view:any}|{file:TFile, editor:Editor}|{node: ObsidianCanvasNode}|null {
|
||||
if (!this.targetView && !view) {
|
||||
return null;
|
||||
}
|
||||
@@ -486,6 +487,9 @@ export class ExcalidrawAutomate {
|
||||
if(leafOrNode.node && leafOrNode.node.isEditing) {
|
||||
return {file: leafOrNode.node.file, editor: leafOrNode.node.child.editor};
|
||||
}
|
||||
if(leafOrNode.node) {
|
||||
return {node: leafOrNode.node};
|
||||
}
|
||||
if(leafOrNode.leaf && leafOrNode.leaf.view) {
|
||||
return {view: leafOrNode.leaf.view};
|
||||
}
|
||||
|
||||
@@ -581,6 +581,10 @@ export class ExcalidrawData {
|
||||
el.containerId = null;
|
||||
}
|
||||
|
||||
if (el.type === "text" && !el.originalText) {
|
||||
el.originalText = el.rawText ?? el.text ?? "";
|
||||
}
|
||||
|
||||
//https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/494
|
||||
if (el.x === null) {
|
||||
el.x = 0;
|
||||
@@ -760,6 +764,27 @@ export class ExcalidrawData {
|
||||
|
||||
this.deletedElements = this.scene.elements.filter((el:ExcalidrawElement)=>el.isDeleted);
|
||||
this.scene.elements = this.scene.elements.filter((el:ExcalidrawElement)=>!el.isDeleted);
|
||||
|
||||
//once off migration of legacy scenes
|
||||
if(this.scene?.elements?.some((el:any)=>el.type==="iframe" && !el.customData)) {
|
||||
const prompt = new MultiOptionConfirmationPrompt(
|
||||
this.plugin,
|
||||
"This file contains embedded frames " +
|
||||
"which will be migrated to a newer version for compatibility with " +
|
||||
"<a href='https://excalidraw.com'>excalidraw.com</a>.<br>🔄 If you're using Obsidian on " +
|
||||
"multiple devices, you may proceed now, but please, before opening this " +
|
||||
"file on your other devices, update Excalidraw on those as well.<br>🔍 More info is available "+
|
||||
"<a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.9.9'>here</a>.<br>🌐 " +
|
||||
"<a href='https://translate.google.com/?sl=en&tl=zh-CN&text=This%20file%20contains%20embedded%20frames%20which%20will%20be%20migrated%20to%20a%20newer%20version%20for%20compatibility%20with%20excalidraw.com.%0A%0AIf%20you%27re%20using%20Obsidian%20on%20multiple%20devices%2C%20you%20may%20proceed%20now%2C%20but%20please%2C%20before%20opening%20this%20file%20on%20your%20other%20devices%2C%20update%20Excalidraw%20on%20those%20as%20well.%0A%0AMore%20info%20is%20available%20here%3A%20https%3A%2F%2Fgithub.com%2Fzsviczian%2Fobsidian-excalidraw-plugin%2Freleases%2Ftag%2F1.9.9%27%3Ehere%3C%2Fa%3E.&op=translate'>" +
|
||||
"Translate</a>.",
|
||||
);
|
||||
prompt.contentEl.focus();
|
||||
const confirmation = await prompt.waitForClose
|
||||
if(!confirmation) {
|
||||
throw new Error(ERROR_IFRAME_CONVERSION_CANCELED);
|
||||
}
|
||||
}
|
||||
this.initializeNonInitializedFields();
|
||||
|
||||
const timer = window.setTimeout(()=>{
|
||||
const notice = new Notice(t("FONT_LOAD_SLOW"),15000);
|
||||
@@ -802,27 +827,6 @@ export class ExcalidrawData {
|
||||
delete this.scene.appState.gridColor.MajorGridFrequency;
|
||||
}
|
||||
|
||||
//once off migration of legacy scenes
|
||||
if(this.scene?.elements?.some((el:any)=>el.type==="iframe" && !el.customData)) {
|
||||
const prompt = new MultiOptionConfirmationPrompt(
|
||||
this.plugin,
|
||||
"This file contains embedded frames " +
|
||||
"which will be migrated to a newer version for compatibility with " +
|
||||
"<a href='https://excalidraw.com'>excalidraw.com</a>.<br>🔄 If you're using Obsidian on " +
|
||||
"multiple devices, you may proceed now, but please, before opening this " +
|
||||
"file on your other devices, update Excalidraw on those as well.<br>🔍 More info is available "+
|
||||
"<a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/1.9.9'>here</a>.<br>🌐 " +
|
||||
"<a href='https://translate.google.com/?sl=en&tl=zh-CN&text=This%20file%20contains%20embedded%20frames%20which%20will%20be%20migrated%20to%20a%20newer%20version%20for%20compatibility%20with%20excalidraw.com.%0A%0AIf%20you%27re%20using%20Obsidian%20on%20multiple%20devices%2C%20you%20may%20proceed%20now%2C%20but%20please%2C%20before%20opening%20this%20file%20on%20your%20other%20devices%2C%20update%20Excalidraw%20on%20those%20as%20well.%0A%0AMore%20info%20is%20available%20here%3A%20https%3A%2F%2Fgithub.com%2Fzsviczian%2Fobsidian-excalidraw-plugin%2Freleases%2Ftag%2F1.9.9%27%3Ehere%3C%2Fa%3E.&op=translate'>" +
|
||||
"Translate</a>.",
|
||||
);
|
||||
prompt.contentEl.focus();
|
||||
const confirmation = await prompt.waitForClose
|
||||
if(!confirmation) {
|
||||
throw new Error(ERROR_IFRAME_CONVERSION_CANCELED);
|
||||
}
|
||||
}
|
||||
this.initializeNonInitializedFields();
|
||||
|
||||
data = data.substring(0, sceneJSONandPOS.pos);
|
||||
|
||||
//The Markdown # Text Elements take priority over the JSON text elements. Assuming the scenario in which the
|
||||
|
||||
Vendored
+1
@@ -58,6 +58,7 @@ declare global {
|
||||
declare module "obsidian" {
|
||||
interface App {
|
||||
internalPlugins: any;
|
||||
setting: any;
|
||||
isMobile(): boolean;
|
||||
getObsidianUrl(file:TFile): string;
|
||||
metadataTypeManager: {
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
import { NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { DEVICE, REG_LINKINDEX_INVALIDCHARS } from "src/constants/constants";
|
||||
import { getParentOfClass } from "./obsidianUtils";
|
||||
import { App, TFile, WorkspaceLeaf } from "obsidian";
|
||||
import { AUDIO_TYPES, DEVICE, REG_LINKINDEX_INVALIDCHARS, VIDEO_TYPES } from "src/constants/constants";
|
||||
import { ConstructableWorkspaceSplit, getContainerForDocument, getParentOfClass } from "./obsidianUtils";
|
||||
import { App, TFile, WorkspaceLeaf, WorkspaceSplit } from "obsidian";
|
||||
import { getLinkParts } from "./utils";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { ObsidianCanvasNode } from "src/view/managers/CanvasNodeFactory";
|
||||
|
||||
export const createLeaf = (view: ExcalidrawView): {leaf: WorkspaceLeaf, rootSplit: WorkspaceSplit} => {
|
||||
const doc = view.ownerDocument;
|
||||
const rootSplit:WorkspaceSplit = new (WorkspaceSplit as ConstructableWorkspaceSplit)(view.app.workspace, "vertical");
|
||||
rootSplit.getRoot = () => view.app.workspace[doc === document ? 'rootSplit' : 'floatingSplit'];
|
||||
rootSplit.getContainer = () => getContainerForDocument(doc);
|
||||
rootSplit.containerEl.style.width = '100%';
|
||||
rootSplit.containerEl.style.height = '100%';
|
||||
rootSplit.containerEl.style.borderRadius = "var(--embeddable-radius)";
|
||||
view.plugin.setDebounceActiveLeafChangeHandler();
|
||||
return {
|
||||
leaf: view.app.workspace.createLeafInParent(rootSplit, 0),
|
||||
rootSplit,
|
||||
};
|
||||
}
|
||||
|
||||
export const useDefaultExcalidrawFrame = (element: NonDeletedExcalidrawElement) => {
|
||||
return !(element.link.startsWith("[") || element.link.startsWith("file:") || element.link.startsWith("data:")); // && !element.link.match(TWITTER_REG);
|
||||
@@ -14,22 +30,38 @@ 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;
|
||||
export const patchMobileView = (
|
||||
view: ExcalidrawView,
|
||||
opts?: { keepAlive?: boolean; isActive?: () => boolean }
|
||||
): (() => void) | void => {
|
||||
if (!DEVICE.isPhone) return;
|
||||
console.log("patching mobile view");
|
||||
const parent = getParentOfClass(view.containerEl,"mod-top");
|
||||
if(parent) {
|
||||
if(!parent.hasClass("mod-visible")) {
|
||||
const parent = getParentOfClass(view.containerEl, "mod-top");
|
||||
if (parent) {
|
||||
if (!parent.hasClass("mod-visible")) {
|
||||
parent.addClass("mod-visible");
|
||||
}
|
||||
//create observer here
|
||||
// create observer here
|
||||
const observer = new MutationObserver(() => {
|
||||
if(!parent.hasClass("mod-visible")) {
|
||||
if (opts?.keepAlive && opts?.isActive && !opts.isActive()) {
|
||||
observer.disconnect();
|
||||
return;
|
||||
}
|
||||
if (!parent.hasClass("mod-visible")) {
|
||||
parent.addClass("mod-visible");
|
||||
}
|
||||
});
|
||||
observer.observe(parent, { attributes: true, attributeFilter: ["class"] });
|
||||
window.setTimeout(() => observer.disconnect(), 500);
|
||||
|
||||
const cleanup = () => observer.disconnect();
|
||||
|
||||
if (opts?.keepAlive) {
|
||||
// Keep the observer alive until caller cleans up (or callback signals inactive)
|
||||
return cleanup;
|
||||
}
|
||||
// default behavior: disconnect after 500ms
|
||||
window.setTimeout(cleanup, 500);
|
||||
return cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,3 +112,45 @@ export function setFileToLocalGraph(app: App, file: TFile) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
export function predictViewType(app: App, file: TFile): string {
|
||||
const ext = file.extension?.toLowerCase?.() ?? "";
|
||||
|
||||
// 1) Try private registry APIs when available (covers .md files with custom views like Kanban)
|
||||
const vr = (app as any)?.viewRegistry;
|
||||
const registryFileMethods = [
|
||||
"getViewTypeForFile",
|
||||
"getViewTypeByFile",
|
||||
"getTypeByFile",
|
||||
];
|
||||
for (const m of registryFileMethods) {
|
||||
if (vr?.[m]) {
|
||||
try {
|
||||
const vt = vr[m](file);
|
||||
if (typeof vt === "string" && vt) return vt;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
// 2) Try extension mapping from registry
|
||||
const registryExtMethods = [
|
||||
"getViewTypeByExtension",
|
||||
"getTypeByExtension",
|
||||
];
|
||||
for (const m of registryExtMethods) {
|
||||
if (vr?.[m]) {
|
||||
try {
|
||||
const vt = vr[m](ext);
|
||||
if (typeof vt === "string" && vt) return vt;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
// 3) Fallbacks by extension
|
||||
if (ext === "md") return "markdown";
|
||||
if (ext === "pdf") return "pdf";
|
||||
if (ext === "canvas") return "canvas";
|
||||
if (AUDIO_TYPES.contains(ext)) return "audio";
|
||||
if (VIDEO_TYPES.contains(ext)) return "video";
|
||||
|
||||
return "empty";
|
||||
}
|
||||
@@ -234,6 +234,7 @@ export async function addBackOfTheNoteCard(
|
||||
cardBody?: string,
|
||||
embeddableCustomData?: EmbeddableMDCustomProps,
|
||||
center: boolean = false,
|
||||
position?: {x: number, y: number},
|
||||
):Promise<string> {
|
||||
const data = view.data;
|
||||
const header = getExcalidrawMarkdownHeaderSection(data);
|
||||
@@ -263,7 +264,7 @@ export async function addBackOfTheNoteCard(
|
||||
}
|
||||
|
||||
const ea = getEA(view) as ExcalidrawAutomate;
|
||||
let x,y = 0;
|
||||
let {x,y} = position ?? ea.targetView.currentPosition;
|
||||
if(center) {
|
||||
const centerPos = ea.getViewCenterPosition();
|
||||
if(centerPos) {
|
||||
@@ -287,7 +288,7 @@ export async function addBackOfTheNoteCard(
|
||||
window.setTimeout(()=>{
|
||||
api.updateScene({appState: {activeEmbeddable: {element: el, state: "active"}}, captureUpdate: CaptureUpdateAction.NEVER,});
|
||||
if(found) view.getEmbeddableLeafElementById(el.id)?.editNode?.();
|
||||
});
|
||||
},200);
|
||||
}
|
||||
ea.destroy();
|
||||
return el.id;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { ExcalidrawEmbeddableElement, NonDeletedExcalidrawElement } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import { ExcalidrawEmbeddableElement, } from "@zsviczian/excalidraw/types/element/src/types";
|
||||
import ExcalidrawView from "src/view/ExcalidrawView";
|
||||
import { Notice, WorkspaceLeaf, WorkspaceSplit } from "obsidian";
|
||||
import { Notice, WorkspaceLeaf, } from "obsidian";
|
||||
import * as React from "react";
|
||||
import { ConstructableWorkspaceSplit, getContainerForDocument, isObsidianThemeDark } from "src/utils/obsidianUtils";
|
||||
import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES, VIEW_TYPE_EXCALIDRAW } from "src/constants/constants";
|
||||
import { isObsidianThemeDark } from "src/utils/obsidianUtils";
|
||||
import { DEVICE, EXTENDED_EVENT_TYPES, KEYBOARD_EVENT_TYPES, } 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 { processLinkText, patchMobileView, setFileToLocalGraph, createLeaf, predictViewType } from "src/utils/customEmbeddableUtils";
|
||||
import { EmbeddableMDCustomProps } from "src/shared/Dialogs/EmbeddableSettings";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
@@ -77,7 +77,6 @@ function setPDFViewTheme(view: ExcalidrawView, pdfView: any) {
|
||||
}
|
||||
}
|
||||
|
||||
// New: carve out PDF setup logic
|
||||
function setupPdfViewEnhancements(
|
||||
view: ExcalidrawView,
|
||||
leafRef: React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
|
||||
@@ -229,6 +228,45 @@ function setupPdfViewEnhancements(
|
||||
attributes: true,
|
||||
attributeFilter: ["class"],
|
||||
});
|
||||
|
||||
// https://github.com/RyotaUshio/obsidian-pdf-plus/issues/477
|
||||
// Watch for the PDF container being removed from DOM (e.g. by PDF+)
|
||||
const rootEl = pdfView.containerEl as HTMLElement | null;
|
||||
if (rootEl) {
|
||||
let detachObserver: MutationObserver | null = new MutationObserver((_muts, obs) => {
|
||||
// If the tracked pdfContainerEl is gone/replaced, clean up and reattach
|
||||
if (!pdfContainerEl.isConnected || !rootEl.contains(pdfContainerEl)) {
|
||||
obs.disconnect();
|
||||
detachObserver = null;
|
||||
|
||||
// Cleanup existing handlers/observers
|
||||
try { (pdfObserverRef as any).currentCleanup?.(); } catch {}
|
||||
try { pdfObserverRef.current?.disconnect(); } catch {}
|
||||
|
||||
// Re-setup on next tick to allow DOM to settle
|
||||
setTimeout(() => {
|
||||
if (leafRef.current?.node?.child?.containerEl?.isConnected) {
|
||||
setupPdfViewEnhancements(
|
||||
view,
|
||||
leafRef as React.MutableRefObject<{ leaf: WorkspaceLeaf; node?: ObsidianCanvasNode; editNode?: Function } | null>,
|
||||
pdfObserverRef as any,
|
||||
pdfObserverDisabledRef
|
||||
);
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
detachObserver.observe(rootEl, { childList: true, subtree: true });
|
||||
|
||||
// Extend cleanup to also stop the detachObserver and the class observer
|
||||
const prevCleanup = (pdfObserverRef as any).currentCleanup;
|
||||
(pdfObserverRef as any).currentCleanup = () => {
|
||||
try { prevCleanup?.(); } catch {}
|
||||
try { pdfObserverRef.current?.disconnect(); } catch {}
|
||||
try { detachObserver?.disconnect(); } catch {}
|
||||
detachObserver = null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -301,7 +339,7 @@ export function renderWebView (src: string, view: ExcalidrawView, id: string, _:
|
||||
//Render WorkspaceLeaf or CanvasNode
|
||||
//--------------------------------------------------------------------------------
|
||||
function RenderObsidianView(
|
||||
{ mdProps, element, linkText, view, containerRef, activeEmbeddable, theme, canvasColor }:{
|
||||
{ mdProps, element, linkText, view, containerRef, activeEmbeddable, theme, canvasColor, selectedElementId }:{
|
||||
mdProps: EmbeddableMDCustomProps;
|
||||
element: ExcalidrawEmbeddableElement;
|
||||
linkText: string;
|
||||
@@ -310,6 +348,7 @@ function RenderObsidianView(
|
||||
activeEmbeddable: {element: ExcalidrawEmbeddableElement; state: string};
|
||||
theme: string;
|
||||
canvasColor: string;
|
||||
selectedElementId: string;
|
||||
}): JSX.Element {
|
||||
|
||||
const { subpath, file } = processLinkText(linkText, view);
|
||||
@@ -323,10 +362,13 @@ function RenderObsidianView(
|
||||
const leafRef = React.useRef<{leaf: WorkspaceLeaf; node?: ObsidianCanvasNode, editNode?: Function} | null>(null);
|
||||
const isEditingRef = React.useRef(false);
|
||||
const isActiveRef = React.useRef(false);
|
||||
const viewTypeRef = React.useRef("empty");
|
||||
const themeRef = React.useRef(theme);
|
||||
const elementRef = React.useRef(element);
|
||||
const pdfObserverRef = React.useRef(null);
|
||||
const pdfObserverDisabledRef = React.useRef(false);
|
||||
// Keep-alive mobile patch cleanup holder
|
||||
const mobilePatchCleanupRef = React.useRef(null);
|
||||
|
||||
// Update themeRef when theme changes
|
||||
React.useEffect(() => {
|
||||
@@ -424,53 +466,29 @@ function RenderObsidianView(
|
||||
|
||||
containerRef.current.parentElement.style.padding = "";
|
||||
|
||||
const doc = view.ownerDocument;
|
||||
const rootSplit:WorkspaceSplit = new (WorkspaceSplit as ConstructableWorkspaceSplit)(view.app.workspace, "vertical");
|
||||
rootSplit.getRoot = () => view.app.workspace[doc === document ? 'rootSplit' : 'floatingSplit'];
|
||||
rootSplit.getContainer = () => getContainerForDocument(doc);
|
||||
rootSplit.containerEl.style.width = '100%';
|
||||
rootSplit.containerEl.style.height = '100%';
|
||||
rootSplit.containerEl.style.borderRadius = "var(--embeddable-radius)";
|
||||
view.plugin.setDebounceActiveLeafChangeHandler();
|
||||
leafRef.current = {
|
||||
leaf: view.app.workspace.createLeafInParent(rootSplit, 0),
|
||||
leaf: null,
|
||||
node: null,
|
||||
editNode: null,
|
||||
};
|
||||
|
||||
const createNode = (viewType: string) => {
|
||||
setKeepOnTop();
|
||||
leafRef.current.node = view.canvasNodeFactory.createFileNote(file, subpath, containerRef.current, element.id);
|
||||
setColors(containerRef.current, element, mdProps, canvasColor, viewType);
|
||||
view.updateEmbeddableLeafRef(element.id, leafRef.current);
|
||||
viewTypeRef.current = "markdown";
|
||||
}
|
||||
|
||||
patchMobileView(view);
|
||||
//if subpath is defined, create a canvas node else create a workspace leaf
|
||||
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);
|
||||
createNode("markdown");
|
||||
} else {
|
||||
(async () => {
|
||||
await leafRef.current.leaf.openFile(file, {
|
||||
active: false,
|
||||
state: {mode:"preview"},
|
||||
...subpath ? { eState: { subpath }}:{},
|
||||
});
|
||||
const viewType = leafRef.current.leaf.view?.getViewType();
|
||||
if(viewType === "canvas") {
|
||||
leafRef.current.leaf.view.canvas?.setReadonly(true);
|
||||
}
|
||||
if (CANVAS_VIEWTYPES.has(viewType) && view.canvasNodeFactory.isInitialized()) {
|
||||
setKeepOnTop();
|
||||
//I haven't found a better way of deciding if an .md file has its own view (e.g., kanban) or not
|
||||
//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, 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, viewType);
|
||||
}
|
||||
view.updateEmbeddableLeafRef(element.id, leafRef.current);
|
||||
|
||||
let viewType = predictViewType(view.app,file);
|
||||
// markdown could still be a kanban board or other custom view on top of markdown, those need to be displayed in leaves
|
||||
if(viewType !== "markdown" && CANVAS_VIEWTYPES.has(viewType) && view.canvasNodeFactory.isInitialized()) {
|
||||
createNode(viewType);
|
||||
if(viewType === "pdf") {
|
||||
// Moved PDF setup logic into a helper for readability
|
||||
setupPdfViewEnhancements(
|
||||
@@ -480,7 +498,36 @@ function RenderObsidianView(
|
||||
pdfObserverDisabledRef
|
||||
);
|
||||
}
|
||||
})();
|
||||
} else {
|
||||
(async () => {
|
||||
const {rootSplit, leaf } = createLeaf(view);
|
||||
leafRef.current.leaf = leaf;
|
||||
await leafRef.current.leaf.openFile(file, {
|
||||
active: false,
|
||||
state: {mode:"preview"},
|
||||
...subpath ? { eState: { subpath }}:{},
|
||||
});
|
||||
const viewType = leafRef.current.leaf.view?.getViewType();
|
||||
viewTypeRef.current = viewType;
|
||||
if(viewType === "canvas") {
|
||||
leafRef.current.leaf.view.canvas?.setReadonly(true);
|
||||
}
|
||||
if (viewType === "markdown" && view.canvasNodeFactory.isInitialized()) {
|
||||
createNode("markdown");
|
||||
//I haven't found a better way of deciding if an .md file has its own view (e.g., kanban) or not
|
||||
//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.leaf?.detach();
|
||||
} 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, viewType);
|
||||
view.updateEmbeddableLeafRef(element.id, leafRef.current);
|
||||
}
|
||||
})();
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
@@ -489,6 +536,10 @@ function RenderObsidianView(
|
||||
pdfObserverRef.current?.disconnect();
|
||||
pdfObserverRef.current = null;
|
||||
|
||||
// cleanup persistent mobile patch if active
|
||||
try { mobilePatchCleanupRef.current?.(); } catch {}
|
||||
mobilePatchCleanupRef.current = null;
|
||||
|
||||
if(!leafRef.current) {
|
||||
return;
|
||||
}
|
||||
@@ -595,8 +646,7 @@ function RenderObsidianView(
|
||||
const element = elementRef.current;
|
||||
const canvasNode = containerRef.current;
|
||||
if(!canvasNode.hasClass("canvas-node")) return;
|
||||
const viewType = leafRef.current.leaf.view?.getViewType();
|
||||
setColors(canvasNode, element, mdProps, canvasColor, viewType);
|
||||
setColors(canvasNode, element, mdProps, canvasColor, viewTypeRef.current);
|
||||
}, [
|
||||
mdProps?.useObsidianDefaults,
|
||||
mdProps?.backgroundMatchCanvas,
|
||||
@@ -609,7 +659,7 @@ function RenderObsidianView(
|
||||
elementRef.current,
|
||||
containerRef.current,
|
||||
canvasColor,
|
||||
leafRef.current,
|
||||
viewTypeRef.current,
|
||||
])
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
@@ -633,36 +683,40 @@ function RenderObsidianView(
|
||||
event?.stopPropagation();
|
||||
}
|
||||
|
||||
if(!isActiveRef.current || isEditingRef.current || !leafRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*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;
|
||||
const el = api.getSceneElements().filter(el=>el.id === element.id)[0];
|
||||
|
||||
if(!el || el.angle !== 0) {
|
||||
new Notice("Sorry, cannot edit rotated markdown documents");
|
||||
return;
|
||||
}
|
||||
//@ts-ignore
|
||||
const modes = leafRef.current.leaf.view.modes;
|
||||
if (!modes) {
|
||||
return;
|
||||
}
|
||||
patchMobileView(view);
|
||||
leafRef.current.leaf.view.setMode(modes['source']);
|
||||
isEditingRef.current = true;
|
||||
} else if (leafRef.current?.node) {
|
||||
//Handle canvas node
|
||||
const newTheme = getTheme(view, themeRef.current);
|
||||
containerRef.current?.addClasses(["is-editing", "is-focused"]);
|
||||
view.canvasNodeFactory.startEditing(leafRef.current.node, newTheme);
|
||||
}
|
||||
if (leafRef.current.node) {
|
||||
//Handle canvas node
|
||||
const newTheme = getTheme(view, themeRef.current);
|
||||
containerRef.current?.addClasses(["is-editing", "is-focused"]);
|
||||
view.canvasNodeFactory.startEditing(leafRef.current.node, newTheme);
|
||||
return;
|
||||
}
|
||||
}, [leafRef.current?.leaf, element.id, view, themeRef.current, isActiveRef.current, isEditingRef.current]);
|
||||
|
||||
if(leafRef.current.leaf && viewTypeRef.current === "markdown") {
|
||||
const api:ExcalidrawImperativeAPI = view.excalidrawAPI;
|
||||
const el = api.getSceneElements().filter(el=>el.id === element.id)[0];
|
||||
if(!el || el.angle !== 0) {
|
||||
new Notice("Sorry, cannot edit rotated markdown documents");
|
||||
return;
|
||||
}
|
||||
//@ts-ignore
|
||||
const modes = leafRef.current.leaf.view.modes;
|
||||
if (!modes) {
|
||||
return;
|
||||
}
|
||||
patchMobileView(view);
|
||||
leafRef.current.leaf.view.setMode(modes['source']);
|
||||
isEditingRef.current = true;
|
||||
}
|
||||
}, [leafRef.current?.leaf, element.id, view, themeRef.current, isActiveRef.current, isEditingRef.current, viewTypeRef.current]);
|
||||
|
||||
const startEditing = React.useCallback(() => {
|
||||
if(isActiveRef.current && isEditingRef.current) {
|
||||
@@ -684,7 +738,11 @@ function RenderObsidianView(
|
||||
return;
|
||||
}
|
||||
// Existing Enter behavior
|
||||
if (event.key === "Enter" && !isActiveRef.current) {
|
||||
|
||||
if (
|
||||
event.key === "Enter" && !isEditingRef.current &&
|
||||
(selectedElementId === element.id || activeEmbeddable?.element?.id === element.id)
|
||||
) {
|
||||
startEditing(); // Call handleClick function when Enter key is pressed
|
||||
}
|
||||
};
|
||||
@@ -695,10 +753,10 @@ function RenderObsidianView(
|
||||
return () => {
|
||||
document.removeEventListener("keydown", handleKeyPress, true);
|
||||
};
|
||||
}, [handleClick, isActiveRef.current, view]);
|
||||
}, [handleClick, isActiveRef.current, view, activeEmbeddable, element, selectedElementId]);
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// Set isActiveRef and switch to preview mode when the iframe is not active
|
||||
// Set isActiveRef and switch to preview mode when the embeddable is not active
|
||||
//--------------------------------------------------------------------------------
|
||||
React.useEffect(() => {
|
||||
if(!containerRef?.current || !leafRef?.current) {
|
||||
@@ -708,35 +766,16 @@ function RenderObsidianView(
|
||||
const previousIsActive = isActiveRef.current;
|
||||
isActiveRef.current = (activeEmbeddable?.element.id === element.id) && (activeEmbeddable?.state === "active");
|
||||
|
||||
const node = leafRef.current?.node as ObsidianCanvasNode;
|
||||
if (previousIsActive === isActiveRef.current) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*if(leafRef.current?.leaf) {
|
||||
setKeepOnTop();
|
||||
view.app.workspace.setActiveLeaf(leafRef.current.leaf, { focus: true });
|
||||
}*/
|
||||
|
||||
if(file !== view.file) {
|
||||
setFileToLocalGraph(view.app, file);
|
||||
}
|
||||
|
||||
if(leafRef.current.leaf?.view?.getViewType() === "markdown") {
|
||||
//Handle markdown leaf
|
||||
//@ts-ignore
|
||||
const modes = leafRef.current.leaf.view.modes;
|
||||
if(!modes) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isActiveRef.current) {
|
||||
//@ts-ignore
|
||||
leafRef.current.leaf.view.setMode(modes["preview"]);
|
||||
isEditingRef.current = false;
|
||||
return;
|
||||
}
|
||||
} else if (node) {
|
||||
const node = leafRef.current?.node as ObsidianCanvasNode;
|
||||
if (node) {
|
||||
//Handle canvas node
|
||||
if(isActiveRef.current && view.plugin.settings.markdownNodeOneClickEditing && !containerRef.current?.hasClass("is-editing")) { //!node.isEditing
|
||||
const newTheme = getTheme(view, themeRef.current);
|
||||
@@ -746,6 +785,44 @@ function RenderObsidianView(
|
||||
containerRef.current?.removeClasses(["is-editing", "is-focused"]);
|
||||
view.canvasNodeFactory.stopEditing(node);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(leafRef.current.leaf) {
|
||||
// Manage persistent mobile patch lifecycle for LEAF on phones
|
||||
if (DEVICE.isPhone) {
|
||||
if (isActiveRef.current) {
|
||||
// start persistent observer if not running
|
||||
if (!mobilePatchCleanupRef.current) {
|
||||
const cleanup = patchMobileView(view, {
|
||||
keepAlive: true,
|
||||
isActive: () => isActiveRef.current,
|
||||
});
|
||||
mobilePatchCleanupRef.current = (typeof cleanup === "function") ? cleanup : null;
|
||||
}
|
||||
} else {
|
||||
// stop persistent observer when deactivated
|
||||
try { mobilePatchCleanupRef.current?.(); } catch {}
|
||||
mobilePatchCleanupRef.current = null;
|
||||
}
|
||||
}
|
||||
|
||||
//I think this no longer happens since markdown is always a canvas node if canvasNodeFactory is initialized
|
||||
if(viewTypeRef.current === "markdown") {
|
||||
//Handle markdown leaf
|
||||
//@ts-ignore
|
||||
const modes = leafRef.current.leaf?.view.modes;
|
||||
if(!modes) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isActiveRef.current) {
|
||||
//@ts-ignore
|
||||
leafRef.current.leaf.view.setMode(modes["preview"]);
|
||||
isEditingRef.current = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [
|
||||
containerRef,
|
||||
@@ -770,6 +847,7 @@ export const CustomEmbeddable: React.FC<{element: ExcalidrawEmbeddableElement; v
|
||||
const containerRef: React.RefObject<HTMLDivElement> = React.useRef(null);
|
||||
const theme = getTheme(view, appState.theme);
|
||||
const mdProps: EmbeddableMDCustomProps = element.customData?.mdProps || null;
|
||||
const selectedElementIds = Object.keys(appState.selectedElementIds);
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
@@ -792,6 +870,7 @@ export const CustomEmbeddable: React.FC<{element: ExcalidrawEmbeddableElement; v
|
||||
activeEmbeddable={appState.activeEmbeddable}
|
||||
theme={appState.theme}
|
||||
canvasColor={appState.viewBackgroundColor}
|
||||
selectedElementId={selectedElementIds.length === 1 ? selectedElementIds[0] : null}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -85,8 +85,8 @@ export class CanvasNodeFactory {
|
||||
|
||||
private async waitForEditor(node: ObsidianCanvasNode): Promise<HTMLElement | null> {
|
||||
let counter = 0;
|
||||
while (!node.child.editor?.containerEl?.parentElement?.parentElement && counter++ < 100) {
|
||||
await new Promise(resolve => setTimeout(resolve, 25));
|
||||
while (!node.child.editor?.containerEl?.parentElement?.parentElement && counter++ < 40) {
|
||||
await sleep(25);
|
||||
}
|
||||
return node.child.editor?.containerEl?.parentElement?.parentElement;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user