mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cabe90927d | ||
|
|
3220889563 | ||
|
|
907e2267d5 | ||
|
|
730705efe6 | ||
|
|
f8338b6d46 | ||
|
|
4c1ffcb104 | ||
|
|
52c54a999e |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.26.0-beta.7",
|
||||
"version": "2.26.0-rc.1",
|
||||
"minAppVersion": "1.8.7",
|
||||
"description": "Sketch Your Mind. Edit and view Excalidraw drawings. Enter the world of 4D Visual PKM.",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
@@ -20,7 +20,8 @@ import {
|
||||
nanoid,
|
||||
VIEW_TYPE_EXCALIDRAW,
|
||||
} from "src/constants/constants";
|
||||
import { Prompt, templatePromt } from "src/shared/Dialogs/Prompt";
|
||||
import { templatePromt } from "src/shared/Dialogs/Prompt";
|
||||
import { FileAndFolderSelectorModal } from "src/shared/Dialogs/FileAndFolderSelectorModal";
|
||||
import {
|
||||
changeThemeOfExcalidrawMD,
|
||||
ExcalidrawData,
|
||||
@@ -32,6 +33,7 @@ import ExcalidrawPlugin from "src/core/main";
|
||||
import {
|
||||
checkAndCreateFolder,
|
||||
createFileAndAwaitMetacacheUpdate,
|
||||
createOrOverwriteFile,
|
||||
download,
|
||||
getIMGFilename,
|
||||
getLink,
|
||||
@@ -47,6 +49,7 @@ import {
|
||||
import { errorlog, getExportTheme } from "src/utils/utils";
|
||||
import { getImageCache } from "src/shared/ImageCache";
|
||||
import { PaneTarget } from "src/types/utilTypes";
|
||||
import { t } from "src/lang/helpers";
|
||||
|
||||
export class PluginFileManager {
|
||||
private plugin: ExcalidrawPlugin;
|
||||
@@ -384,29 +387,29 @@ export class PluginFileManager {
|
||||
|
||||
public async exportLibrary() {
|
||||
if (DEVICE.isMobile) {
|
||||
const prompt = new Prompt(
|
||||
this.app,
|
||||
"Please provide a filename",
|
||||
"my-library",
|
||||
"filename, leave blank to cancel action",
|
||||
const location = await new FileAndFolderSelectorModal(this.app, {
|
||||
title: t("FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE"),
|
||||
folderLabel: t("FILE_AND_FOLDER_SELECTOR_FOLDER"),
|
||||
fileNameLabel: t("FILE_AND_FOLDER_SELECTOR_FILENAME"),
|
||||
submitButtonText: t("FILE_AND_FOLDER_SELECTOR_EXPORT"),
|
||||
folderPath: normalizePath(this.settings.folder),
|
||||
fileName: "my-library.excalidrawlib",
|
||||
}).start();
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
const filename = location.fileName
|
||||
.toLowerCase()
|
||||
.endsWith(".excalidrawlib")
|
||||
? location.fileName
|
||||
: `${location.fileName}.excalidrawlib`;
|
||||
const fname = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
location.folderPath,
|
||||
);
|
||||
void prompt.openAndGetValue((filename: string) => {
|
||||
void (async () => {
|
||||
if (!filename) {
|
||||
return;
|
||||
}
|
||||
filename = `${filename}.excalidrawlib`;
|
||||
const folderpath = normalizePath(this.settings.folder);
|
||||
await checkAndCreateFolder(folderpath); //create folder if it does not exist
|
||||
const fname = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
folderpath,
|
||||
);
|
||||
await this.app.vault.create(fname, this.settings.library);
|
||||
new Notice(`Exported library to ${fname}`, 6000);
|
||||
})();
|
||||
});
|
||||
await createOrOverwriteFile(this.app, fname, this.settings.library);
|
||||
new Notice(`Exported library to ${fname}`, 6000);
|
||||
return;
|
||||
}
|
||||
download(
|
||||
|
||||
@@ -722,6 +722,7 @@ export const DEFAULT_SETTINGS: ExcalidrawSettings = {
|
||||
markdownImageSettings: {
|
||||
defaults: {
|
||||
width: 500,
|
||||
paddingBottom: 10,
|
||||
fontFamily: "Cascadia",
|
||||
fontColor: "Black",
|
||||
border: {
|
||||
|
||||
@@ -137,6 +137,9 @@ export default {
|
||||
MARKDOWN_IMAGE_APPEARANCE: "Appearance",
|
||||
MARKDOWN_IMAGE_WIDTH: "Width",
|
||||
MARKDOWN_IMAGE_WIDTH_DESC: "Markdown flow width in canvas units",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING: "Bottom padding",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING_DESC:
|
||||
"Extra space below the rendered Markdown, in pixels",
|
||||
MARKDOWN_IMAGE_FONT: "Font",
|
||||
MARKDOWN_IMAGE_FONT_COLOR: "Font color",
|
||||
MARKDOWN_IMAGE_BORDER: "Border",
|
||||
@@ -187,7 +190,10 @@ export default {
|
||||
"Could not change the Markdown image source",
|
||||
MARKDOWN_IMAGE_LOCAL_COPY_ERROR: "Could not create a local Markdown copy",
|
||||
MARKDOWN_IMAGE_EXTRACT_TITLE: "Extract Markdown image to note",
|
||||
MARKDOWN_IMAGE_EXTRACT_PATH: "Path to the new Markdown note",
|
||||
FILE_AND_FOLDER_SELECTOR_FOLDER: "Folder",
|
||||
FILE_AND_FOLDER_SELECTOR_FILENAME: "File name",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE: "Export to Vault",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT: "Export",
|
||||
MARKDOWN_IMAGE_DEFAULT_NOTE: "Markdown image.md",
|
||||
MARKDOWN_IMAGE_CREATE_NOTE_ERROR: "Could not create Markdown note",
|
||||
MARKDOWN_IMAGE_UNKNOWN_ERROR: "Unknown error",
|
||||
@@ -289,8 +295,6 @@ export default {
|
||||
"Inverted Mode: Default arrow binding is now disabled. Use CTRL/CMD to temporarily enable binding when needed.",
|
||||
ARROW_BINDING_NORMAL_MODE:
|
||||
"Normal Mode: Arrow binding is now enabled. Use CTRL/CMD to temporarily disable binding when needed.",
|
||||
EXPORT_FILENAME_PROMPT: "Please provide filename",
|
||||
EXPORT_FILENAME_PROMPT_PLACEHOLDER: "filename, leave blank to cancel action",
|
||||
WARNING_SERIOUS_ERROR:
|
||||
"WARNING: Excalidraw ran into an unknown problem!\n\n" +
|
||||
"There is a risk that your most recent changes cannot be saved.\n\n" +
|
||||
|
||||
@@ -138,6 +138,9 @@ export default {
|
||||
MARKDOWN_IMAGE_APPEARANCE: "Apariencia",
|
||||
MARKDOWN_IMAGE_WIDTH: "Ancho",
|
||||
MARKDOWN_IMAGE_WIDTH_DESC: "Ancho del flujo Markdown en unidades del lienzo",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING: "Relleno inferior",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING_DESC:
|
||||
"Espacio adicional debajo del Markdown renderizado, en píxeles",
|
||||
MARKDOWN_IMAGE_FONT: "Fuente",
|
||||
MARKDOWN_IMAGE_FONT_COLOR: "Color de fuente",
|
||||
MARKDOWN_IMAGE_BORDER: "Borde",
|
||||
@@ -187,7 +190,10 @@ export default {
|
||||
MARKDOWN_IMAGE_CHANGE_SOURCE_ERROR: "No se pudo cambiar la fuente de la imagen Markdown",
|
||||
MARKDOWN_IMAGE_LOCAL_COPY_ERROR: "No se pudo crear una copia Markdown local",
|
||||
MARKDOWN_IMAGE_EXTRACT_TITLE: "Extraer imagen Markdown a una nota",
|
||||
MARKDOWN_IMAGE_EXTRACT_PATH: "Ruta de la nueva nota Markdown",
|
||||
FILE_AND_FOLDER_SELECTOR_FOLDER: "Carpeta",
|
||||
FILE_AND_FOLDER_SELECTOR_FILENAME: "Nombre del archivo",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE: "Exportar a la bóveda",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT: "Exportar",
|
||||
MARKDOWN_IMAGE_DEFAULT_NOTE: "Imagen Markdown.md",
|
||||
MARKDOWN_IMAGE_CREATE_NOTE_ERROR: "No se pudo crear la nota Markdown",
|
||||
MARKDOWN_IMAGE_UNKNOWN_ERROR: "Error desconocido",
|
||||
@@ -279,9 +285,6 @@ export default {
|
||||
"Modo Invertido: La vinculación de flechas predeterminada está ahora deshabilitada. Usa CTRL/CMD para habilitar temporalmente la vinculación cuando sea necesario.",
|
||||
ARROW_BINDING_NORMAL_MODE:
|
||||
"Modo Normal: La vinculación de flechas está ahora habilitada. Usa CTRL/CMD para deshabilitar temporalmente la vinculación cuando sea necesario.",
|
||||
EXPORT_FILENAME_PROMPT: "Por favor, ingresa el nombre de archivo",
|
||||
EXPORT_FILENAME_PROMPT_PLACEHOLDER:
|
||||
"nombre de archivo, dejar en blanco para cancelar la acción",
|
||||
WARNING_SERIOUS_ERROR:
|
||||
"ADVERTENCIA: ¡Excalidraw encontró un problema desconocido!\n\n" +
|
||||
"Existe el riesgo de que tus cambios más recientes no se puedan guardar.\n\n" +
|
||||
|
||||
@@ -129,6 +129,9 @@ export default {
|
||||
MARKDOWN_IMAGE_APPEARANCE: "Оформление",
|
||||
MARKDOWN_IMAGE_WIDTH: "Ширина",
|
||||
MARKDOWN_IMAGE_WIDTH_DESC: "Ширина потока Markdown в единицах холста",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING: "Нижний отступ",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING_DESC:
|
||||
"Дополнительное пространство под отрисованным Markdown в пикселях",
|
||||
MARKDOWN_IMAGE_FONT: "Шрифт",
|
||||
MARKDOWN_IMAGE_FONT_COLOR: "Цвет шрифта",
|
||||
MARKDOWN_IMAGE_BORDER: "Рамка",
|
||||
@@ -179,7 +182,10 @@ export default {
|
||||
MARKDOWN_IMAGE_CHANGE_SOURCE_ERROR: "Не удалось изменить источник Markdown-изображения",
|
||||
MARKDOWN_IMAGE_LOCAL_COPY_ERROR: "Не удалось создать локальную копию Markdown",
|
||||
MARKDOWN_IMAGE_EXTRACT_TITLE: "Извлечь Markdown-изображение в заметку",
|
||||
MARKDOWN_IMAGE_EXTRACT_PATH: "Путь к новой Markdown-заметке",
|
||||
FILE_AND_FOLDER_SELECTOR_FOLDER: "Папка",
|
||||
FILE_AND_FOLDER_SELECTOR_FILENAME: "Имя файла",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE: "Экспорт в хранилище",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT: "Экспортировать",
|
||||
MARKDOWN_IMAGE_DEFAULT_NOTE: "Markdown-изображение.md",
|
||||
MARKDOWN_IMAGE_CREATE_NOTE_ERROR: "Не удалось создать Markdown-заметку",
|
||||
MARKDOWN_IMAGE_UNKNOWN_ERROR: "Неизвестная ошибка",
|
||||
@@ -281,9 +287,6 @@ export default {
|
||||
"Инвертированный режим: Привязка стрелок по умолчанию теперь отключена. Используйте CTRL/CMD, чтобы временно включить привязку, когда это необходимо.",
|
||||
ARROW_BINDING_NORMAL_MODE:
|
||||
"Обычный режим: Привязка стрелок теперь включена. Используйте CTRL/CMD, чтобы временно отключить привязку при необходимости.",
|
||||
EXPORT_FILENAME_PROMPT: "Пожалуйста, укажите имя файла",
|
||||
EXPORT_FILENAME_PROMPT_PLACEHOLDER:
|
||||
"имя файла, оставьте пустым, чтобы отменить действие",
|
||||
WARNING_SERIOUS_ERROR:
|
||||
"ПРЕДУПРЕЖДЕНИЕ: Excalidraw столкнулся с неизвестной проблемой!\n\n" +
|
||||
"Есть риск, что последние изменения не будут сохранены.\n\n" +
|
||||
|
||||
@@ -117,6 +117,9 @@ export default {
|
||||
MARKDOWN_IMAGE_APPEARANCE: "外观",
|
||||
MARKDOWN_IMAGE_WIDTH: "宽度",
|
||||
MARKDOWN_IMAGE_WIDTH_DESC: "以画布单位表示的 Markdown 排版宽度",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING: "底部内边距",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING_DESC:
|
||||
"渲染后的 Markdown 下方额外空间(像素)",
|
||||
MARKDOWN_IMAGE_FONT: "字体",
|
||||
MARKDOWN_IMAGE_FONT_COLOR: "字体颜色",
|
||||
MARKDOWN_IMAGE_BORDER: "边框",
|
||||
@@ -161,7 +164,10 @@ export default {
|
||||
MARKDOWN_IMAGE_CHANGE_SOURCE_ERROR: "无法更改 Markdown 图像来源",
|
||||
MARKDOWN_IMAGE_LOCAL_COPY_ERROR: "无法创建本地 Markdown 副本",
|
||||
MARKDOWN_IMAGE_EXTRACT_TITLE: "将 Markdown 图像提取到笔记",
|
||||
MARKDOWN_IMAGE_EXTRACT_PATH: "新 Markdown 笔记的路径",
|
||||
FILE_AND_FOLDER_SELECTOR_FOLDER: "文件夹",
|
||||
FILE_AND_FOLDER_SELECTOR_FILENAME: "文件名",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE: "导出到仓库",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT: "导出",
|
||||
MARKDOWN_IMAGE_DEFAULT_NOTE: "Markdown 图像.md",
|
||||
MARKDOWN_IMAGE_CREATE_NOTE_ERROR: "无法创建 Markdown 笔记",
|
||||
MARKDOWN_IMAGE_UNKNOWN_ERROR: "未知错误",
|
||||
@@ -252,8 +258,6 @@ export default {
|
||||
"反转模式:默认方向按键已禁用。需要时请使用 Ctrl/CMD 临时启用。",
|
||||
ARROW_BINDING_NORMAL_MODE:
|
||||
"正常模式:方向键已启用。需要时请使用 Ctrl/CMD 临时禁用。",
|
||||
EXPORT_FILENAME_PROMPT: "请提供文件名",
|
||||
EXPORT_FILENAME_PROMPT_PLACEHOLDER: "请输入文件名,留空以取消操作",
|
||||
WARNING_SERIOUS_ERROR:
|
||||
"警告:Excalidraw 遇到了未知的问题!\n\n" +
|
||||
"您最近的更改可能无法保存。\n\n" +
|
||||
|
||||
@@ -117,6 +117,9 @@ export default {
|
||||
MARKDOWN_IMAGE_APPEARANCE: "外觀",
|
||||
MARKDOWN_IMAGE_WIDTH: "寬度",
|
||||
MARKDOWN_IMAGE_WIDTH_DESC: "以畫布單位表示的 Markdown 排版寬度",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING: "底部內距",
|
||||
MARKDOWN_IMAGE_BOTTOM_PADDING_DESC:
|
||||
"算繪後的 Markdown 下方額外空間(像素)",
|
||||
MARKDOWN_IMAGE_FONT: "字型",
|
||||
MARKDOWN_IMAGE_FONT_COLOR: "字型顏色",
|
||||
MARKDOWN_IMAGE_BORDER: "邊框",
|
||||
@@ -161,7 +164,10 @@ export default {
|
||||
MARKDOWN_IMAGE_CHANGE_SOURCE_ERROR: "無法變更 Markdown 圖像來源",
|
||||
MARKDOWN_IMAGE_LOCAL_COPY_ERROR: "無法建立本機 Markdown 副本",
|
||||
MARKDOWN_IMAGE_EXTRACT_TITLE: "將 Markdown 圖像擷取到筆記",
|
||||
MARKDOWN_IMAGE_EXTRACT_PATH: "新 Markdown 筆記的路徑",
|
||||
FILE_AND_FOLDER_SELECTOR_FOLDER: "資料夾",
|
||||
FILE_AND_FOLDER_SELECTOR_FILENAME: "檔案名稱",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE: "匯出到儲存庫",
|
||||
FILE_AND_FOLDER_SELECTOR_EXPORT: "匯出",
|
||||
MARKDOWN_IMAGE_DEFAULT_NOTE: "Markdown 圖像.md",
|
||||
MARKDOWN_IMAGE_CREATE_NOTE_ERROR: "無法建立 Markdown 筆記",
|
||||
MARKDOWN_IMAGE_UNKNOWN_ERROR: "未知錯誤",
|
||||
@@ -252,8 +258,6 @@ export default {
|
||||
"反轉模式:預設方向按鍵已停用。需要時請使用 Ctrl/CMD 臨時啟用。",
|
||||
ARROW_BINDING_NORMAL_MODE:
|
||||
"正常模式:方向鍵已啟用。需要時請使用 Ctrl/CMD 臨時停用。",
|
||||
EXPORT_FILENAME_PROMPT: "請提供檔名",
|
||||
EXPORT_FILENAME_PROMPT_PLACEHOLDER: "請輸入檔名,留空以取消操作",
|
||||
WARNING_SERIOUS_ERROR:
|
||||
"警告:Excalidraw 遇到了未知的問題!\n\n" +
|
||||
"您最近的更改可能無法儲存。\n\n" +
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
import { Modal, Setting, type App, type ButtonComponent } from "obsidian";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { VaultPathSuggest } from "src/shared/Suggesters/VaultPathSuggest";
|
||||
|
||||
/** Folder and filename selected in a {@link FileAndFolderSelectorModal}. */
|
||||
export type FileAndFolderSelection = {
|
||||
folderPath: string;
|
||||
fileName: string;
|
||||
};
|
||||
|
||||
/** Labels and initial values for a {@link FileAndFolderSelectorModal}. */
|
||||
export type FileAndFolderSelectorOptions = FileAndFolderSelection & {
|
||||
title: string;
|
||||
folderLabel: string;
|
||||
fileNameLabel: string;
|
||||
submitButtonText: string;
|
||||
};
|
||||
|
||||
/** Prompts for a Vault folder and filename. */
|
||||
export class FileAndFolderSelectorModal extends Modal {
|
||||
private resolvePromise: (
|
||||
selection: FileAndFolderSelection | null,
|
||||
) => void;
|
||||
private result: FileAndFolderSelection | null = null;
|
||||
|
||||
constructor(
|
||||
app: App,
|
||||
private readonly options: FileAndFolderSelectorOptions,
|
||||
) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
/** Opens the modal and resolves with the selection or null when cancelled. */
|
||||
public start(): Promise<FileAndFolderSelection | null> {
|
||||
const result = new Promise<FileAndFolderSelection | null>((resolve) => {
|
||||
this.resolvePromise = resolve;
|
||||
});
|
||||
this.open();
|
||||
return result;
|
||||
}
|
||||
|
||||
public onOpen(): void {
|
||||
this.titleEl.setText(this.options.title);
|
||||
this.contentEl.addClass("excalidraw-file-and-folder-selector");
|
||||
|
||||
let folderPath = this.options.folderPath;
|
||||
let fileName = this.options.fileName;
|
||||
let submitButton: ButtonComponent | null = null;
|
||||
const updateSubmitButton = (): void => {
|
||||
submitButton?.setDisabled(fileName.trim().length === 0);
|
||||
};
|
||||
|
||||
const folderSetting = new Setting(this.contentEl)
|
||||
.setClass("excalidraw-file-and-folder-selector__field")
|
||||
.setName(this.options.folderLabel)
|
||||
.addText((text) => {
|
||||
text.setValue(folderPath).onChange((value) => {
|
||||
folderPath = value.trim();
|
||||
});
|
||||
new VaultPathSuggest(this.app, text.inputEl, "folder");
|
||||
});
|
||||
folderSetting.controlEl.addClass("excalidraw-folder-path-control");
|
||||
|
||||
let fileNameInput: HTMLInputElement | null = null;
|
||||
new Setting(this.contentEl)
|
||||
.setClass("excalidraw-file-and-folder-selector__field")
|
||||
.setName(this.options.fileNameLabel)
|
||||
.addText((text) => {
|
||||
fileNameInput = text.inputEl;
|
||||
text.setValue(fileName).onChange((value) => {
|
||||
fileName = value;
|
||||
updateSubmitButton();
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(this.contentEl)
|
||||
.addButton((button) =>
|
||||
button
|
||||
.setButtonText(t("PROMPT_BUTTON_CANCEL"))
|
||||
.onClick(() => this.close()),
|
||||
)
|
||||
.addButton((button) => {
|
||||
submitButton = button;
|
||||
button
|
||||
.setCta()
|
||||
.setButtonText(this.options.submitButtonText)
|
||||
.onClick(() => {
|
||||
this.result = {
|
||||
folderPath,
|
||||
fileName: fileName.trim(),
|
||||
};
|
||||
this.close();
|
||||
});
|
||||
updateSubmitButton();
|
||||
});
|
||||
|
||||
this.containerEl.ownerDocument.defaultView?.setTimeout(
|
||||
() => fileNameInput?.focus(),
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
public onClose(): void {
|
||||
this.contentEl.empty();
|
||||
this.resolvePromise?.(this.result);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { FuzzySuggestModal, TFile } from "obsidian";
|
||||
import ExcalidrawView from "../../view/ExcalidrawView";
|
||||
import { t } from "../../lang/helpers";
|
||||
import ExcalidrawPlugin from "../../core/main";
|
||||
import { getEA } from "src/core";
|
||||
import { UniversalInsertFileModal } from "./UniversalInsertFileModal";
|
||||
|
||||
export class InsertMDDialog extends FuzzySuggestModal<TFile> {
|
||||
public plugin: ExcalidrawPlugin;
|
||||
@@ -40,12 +40,11 @@ export class InsertMDDialog extends FuzzySuggestModal<TFile> {
|
||||
}
|
||||
|
||||
onChooseItem(item: TFile): void {
|
||||
const ea = getEA(this.view);
|
||||
void (async () => {
|
||||
await ea.addImage(0, 0, item);
|
||||
await ea.addElementsToView(true, false, true);
|
||||
ea.destroy();
|
||||
})();
|
||||
new UniversalInsertFileModal(this.plugin, this.view).open(
|
||||
item,
|
||||
this.view.currentPosition,
|
||||
"image",
|
||||
);
|
||||
}
|
||||
|
||||
public start(view: ExcalidrawView) {
|
||||
|
||||
@@ -25,6 +25,7 @@ I build this plugin as a labor of love. Curious about the philosophy behind it?
|
||||
- Their source can be stored locally as back-of-the-card markdown content in the drawing or linked to an external Markdown note, heading, or block, including an Excalidraw Markdown file.
|
||||
- Edit content and appearance in the Excalidraw sidepanel or use the action menu on a selected Markdown image; the editor supports standard Obsidian Markdown shortcuts and refreshes the image when focus leaves the editor.
|
||||
- Markdown images participate in normal canvas layering and image export.
|
||||
- Dropping a Markdown note as an image now offers its headings when available and lets you insert the selected source as an editable Markdown image or embeddable. Excalidraw notes offer their back-of-note headings while hiding Excalidraw Managed data sections.
|
||||
- Ordinary copies of a local Markdown image share its Markdown source; use **Duplicate selected image** to create an independent image ID and Markdown body. You can also convert interactive embeddables into images and back in the embeddable/image menu in the top left of the selected element, and control dark-mode image inversion from the context menu.
|
||||
- Added the Voronoi diagram script. 🙏[@FreeCutter](${URLs.GITHUB_COM}/FreeCutter) [#2845](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2845)
|
||||
- Image-reference embeds now accept an optional \`,padding=N\` link parameter to override their export padding, including \`area=\`, \`group=\`, \`frame=\`, and \`clippedframe=\` references. For \`area=\`, the value also controls how far around the target Excalidraw searches for surrounding elements. Use \`padding=0\` for no added margin. [#2850](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2850) 🙏[@Evgene-Kopylov](${URLs.GITHUB_COM}/Evgene-Kopylov)
|
||||
@@ -38,6 +39,7 @@ I build this plugin as a labor of love. Curious about the philosophy behind it?
|
||||
|
||||
## Fixed
|
||||
- Custom freedraw pens now remain selected while temporarily using the eraser or another tool, and are restored when returning to freedraw. [#2859](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2859)
|
||||
- Markdown images now offer configurable bottom padding in the sidepanel Appearance section to prevent the final rendered line or border from being clipped.
|
||||
- Font selectors for Markdown images and font settings now preview each available font face and refresh the vault font list whenever opened.
|
||||
- Empty Markdown-image font colors now normalize to black when the editor loads or the color field loses focus. The CSS controls can also copy the selected image's generated SVG directly for inspection.
|
||||
- Dragging an external video or other non-image file with the **Import external file** action now offers the same use, overwrite, or import choice as images when a matching file already exists in the Vault. [#2851](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2851) 🙏[@WolfExplode](${URLs.GITHUB_COM}/WolfExplode)
|
||||
@@ -435,253 +437,5 @@ async addImage(
|
||||
anchor: boolean = true,
|
||||
): Promise<string>;
|
||||
\`\`\`
|
||||
`,
|
||||
"2.22.3": `
|
||||
|
||||
Feeling overwhelmed by Excalidraw's endless features?
|
||||
|
||||
It's not just a drawing tool. Inside Obsidian, it becomes a thinking tool.
|
||||
To unlock linking, embedding, and referencing, you need a mindset shift.
|
||||
|
||||
**Join Excalidraw Mastery** to make that shift.
|
||||
Courses, live Q&As, and deep dives to help you move into true 4D Visual PKM. 👉 https://community.sketch-your-mind.com/em
|
||||
|
||||
<div style="text-align:center;margin-top:10px;">
|
||||
<a href="${URLs.COMMUNITY_SKETCH_YOUR_MIND_COM_EM}" target="_blank"><img src="${URLs.SKETCH_YOUR_MIND_COM_IMAGES_LOGO_EM_PNG}" style="width:50%"></a>
|
||||
</div>
|
||||
|
||||
Excalidraw Mastery is part of the **Sketch Your Mind Community**—a space for visual thinkers.
|
||||
Share your work. Ask questions. Learn from others. 👉 https://community.sketch-your-mind.com
|
||||
|
||||
Curious about the philosophy behind it?
|
||||
|
||||
${getYouTubeDiv("TnwRlaIdhSU")}
|
||||
|
||||
`,
|
||||
"2.22.1": `
|
||||
## New
|
||||
- Added a command palette action to switch all currently open Excalidraw drawings to view mode.
|
||||
- While this temporary mode is enabled, any Excalidraw drawing opened afterward will also open in view mode.
|
||||
- This is useful when presenting multiple drawings and you want to avoid accidentally moving elements, and when you don't want the tools to be in the way.
|
||||
- Added an optional phone-only layout setting to push Excalidraw's footer controls above the system navigation bar on some Android devices [#2688](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2688), [#2652](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2652), [#798](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/798)
|
||||
- Look for ""Extra bottom padding for phone controls" in the plugin settings.
|
||||
|
||||
## Fixed
|
||||
- invisible cursor color in color picker, mermaid chat, in text elements in dark mode [#2739](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2739)
|
||||
- image sizing issue when embedding image type "SVG Image" to markdown
|
||||
- copying a nested image fragment in Excalidraw and pasting to markdown lost the image block reference
|
||||
- modifier keys conflicted with Excalidraw alt-select (lasso) behavior
|
||||
`,
|
||||
"2.22.0": `
|
||||
## Fixed
|
||||
- Fixed misaligned panel buttons in tray mode [#2718](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2718) 🙏[@heinrich26](${URLs.GITHUB_COM}/heinrich26)
|
||||
- Improved loading of nested Excalidraw files within a scene, with some additional performance gains.
|
||||
- Fixed an issue where the caret color did not match the text color [#11018](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_ISSUES}/11018)
|
||||
|
||||
## New from Excalidraw.com
|
||||
- Added several text editing improvements, including a right-side handle on wrapped text for easier auto-resizing without opening the context menu [#10979](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10979)
|
||||
- Added support for Mermaid state diagrams [#11031](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/11031)
|
||||
- There is a new Preferences menu above the Dark/Light mode switch in the main menu [#10760](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10760)
|
||||
- Added a new Preferences option to switch between Wrap and Overlap selection modes. Overlap mode behaves similarly to the lasso selection tool available under More Tools [#11053](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/11053)
|
||||
|
||||
## New
|
||||
- Added support for embedding the [Sheet Plus](obsidian://show-plugin?id=sheet-plus) plugin as an active embeddable element in Excalidraw. At the moment, changing the canvas theme between dark and light mode does not automatically re-render embedded sheets. To apply the theme change, close and reopen the drawing. This will likely be improved in a future update.
|
||||
`,
|
||||
"2.21.3": `
|
||||
## Fixed
|
||||
- Caret color for link editor, text elemnts in dark mode, color picker input element.
|
||||
- Link click behavior modifier keys setting in plugin settings now enforces CTRL/CMD for link clicks and improves on clarity of setting UI by adding a header row
|
||||
- Link click conbinations that included ALT/OPT did not work because they trigger lasso selection in Excalidraw. This is now fixed, if you CTRL+ALT click a link it will navigate while retaining the lasso select feature when pressing ALT/OPT.
|
||||
- Copying an image block embed (e.g. \`![[drawing#^frame=my_frame]]\`) from the excalidraw scene and pasting it to markdown no longer loses the frame reference
|
||||
- Embed "SVG Image" to markdown should size correctly now when setting a percentage \`![[drawing|50%]]\` where 50% is relative to the width of the markdown note.
|
||||
|
||||
`,
|
||||
"2.21.2": `
|
||||
## Fixed
|
||||
- The new ExcalidrawAutomate function \`parseText()\` broke if the text was a transcluded image or PDF document, causing downstream paste issues in MindMap Builder.
|
||||
- Custom pen sloppiness not being saved to a template drawing [#2715](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2715) 🙏[@sreedharsreeram](${URLs.GITHUB_COM_SREEDHARSREERAM})
|
||||
|
||||
`,
|
||||
"2.21.1": `
|
||||
## Fixed
|
||||
- Drawing and editor fails to initialize in a new window [#2713](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2713)
|
||||
- Duplicate selected image with a different image ID command palette action did not duplicate cropped PDF images.
|
||||
- Memory leak issue with PDF import as images.
|
||||
|
||||
## New
|
||||
- Put caret at pointer position when clicking on selected text element [#10970](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10970)
|
||||
|
||||
`,
|
||||
"2.21.0": `
|
||||
## New
|
||||
- LaTeX editor is now floating [#2684](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2684) 🙏[@TravisLEBLANC1](${URLs.GITHUB_COM_TRAVISLEBLANC1}), [#2698](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2698) 🙏[@heinrich26](${URLs.GITHUB_COM}/heinrich26)
|
||||
- Inline link suggester supports new triggers \`
|
||||
- New Context Menu options to disable arrow binding and midpoint snapping [#10906](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10906)
|
||||
- Improved UI styling and icons are better aligned with Obsidian [#2703](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2703), [#2687](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2687), [#2697](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2697) 🙏[@heinrich26](${URLs.GITHUB_COM}/heinrich26)
|
||||
|
||||
## Fixed
|
||||
- Sizing of embedded images in Markdown when image type is set to SVG [#2685](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2685)
|
||||
- Fixed Enter, Up/Down arrows, and TAB keys stopped working in text elements after deleting the \`#\` character [#2704](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2704)
|
||||
|
||||
## MindMap Builder
|
||||
- Fixed navigation (arrow keys) scoping and recognition
|
||||
- Added new feature to paste images and single Excalidraw elements like container with text, text element, or image element directly as a map leaf (using the MindMap Builder default paste shortcut: ALT/OPT+V)
|
||||
- Added new action to toggle a markdown link between markdown embeddable and link as text. Default shortcut is ALT/OPT+E.
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
\`\`\`ts
|
||||
/**
|
||||
* Parses text using the target view's ExcalidrawData parser.
|
||||
*
|
||||
* This reuses ExcalidrawData parsing logic directly, including transclusion
|
||||
* resolution, link bracket rendering, and link/url prefixes based on the
|
||||
* target file's frontmatter.
|
||||
*
|
||||
* @param {string} text - Raw text to parse.
|
||||
* @returns {Promise<string | undefined>} Parsed text, or undefined when input/view is unavailable.
|
||||
*/
|
||||
public async parseText (text: string): Promise<string | undefined>;
|
||||
\`\`\`
|
||||
`,
|
||||
"2.20.6": `
|
||||
${getYouTubeDiv("g-BiyQ7TJTM")}
|
||||
|
||||
## New
|
||||
- Inline suggester now supports searching for tags in addition to files. Trigger with "#".
|
||||
- In Mindmap Builder
|
||||
- Added Up-Facing, Down-Facing, and Up-Down maps
|
||||
- Added submaps. You can now promote any node to be a new mindmap root (a sub-map). Sub-maps can have different layout settings such as different growth strategies, different colors, etc.
|
||||
- Added experimental MindMap Builder API, accessible via \`window.MindMapBuilderAPI\`. See [MindMap Builder API documentation](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_BLOB_MASTER_DOCS_EA_SCRIPT_DOCS_MINDMAPBUILDERAPI_MD}) for more. Essentially, the API allows mindmaps to be created using the Obsidian CLI.
|
||||
|
||||
## New from Excalidraw.com
|
||||
- Allow clicking on links and embeds with laser tool [#10797](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10797)
|
||||
- Improved paste text to diagram with more options and support for more data [#10824](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10824)
|
||||
|
||||
try copy/pasting this into Excalidraw:
|
||||
\`\`\`
|
||||
skill, junior, medior, senior
|
||||
business_analysis, 2, 6, 9
|
||||
business_writing, 3, 7, 9
|
||||
stakeholder_mgmt, 1, 6, 10
|
||||
\`\`\`
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
- Added \`skipScriptRestore(scriptName?: string): boolean\` function to the API. This allows scripts to queue a one-time skip marker so sidepanel persisted restoration will not re-run the script. Intended for startup race conditions where a script is started from the Command Palette/hotkey before the sidepanel has opened. If scriptName is omitted, the function uses ea.activeScript.
|
||||
|
||||
## Fixed
|
||||
- Significant performance improvement of MindMap Builder and all other scripts modifying elements in large scenes containing thousands of elements.
|
||||
- Multiple arrow related updates and fixes from Excalidraw.com [#10832](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10832) [#10831](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10831) [#10816](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10816)
|
||||
- Hide MindMap Builder and other floating tools when creating a screenshot
|
||||
`,
|
||||
"2.20.5": `
|
||||
## Fixed
|
||||
- Obsidian Mobile: The floating navigation bar got stuck at the bottom after closing Excalidraw or switching to a markdown note. [#2673](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2673)
|
||||
- "Toggle UI Mode" now includes a preference setting for Obsidian Phone as well. You can now set different default layouts for phone, tablet, and desktop. [#2670](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2670)
|
||||
|
||||
## New
|
||||
- Added "Toggle Full Screen" button to toolbar right next to the "Obsidian menu", and the "Insert Any File" button.
|
||||
`,
|
||||
"2.20.4": `
|
||||
## Fixed
|
||||
- Fix NativeSVG embed mode into Markdown documents, ahead of the Obsidian 1.12.1 release. [#2665](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2665)
|
||||
- Color picker once again supports 8-digit hex codes (Hex color string with an opacity). [#10772](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_ISSUES}/10772)
|
||||
- Fixed regression that removed LaTeX scaling. [#2668](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2668) 🙏[@TravisLEBLANC1](${URLs.GITHUB_COM_TRAVISLEBLANC1})
|
||||
- Corrected malformed frame embeds when using marker frames.
|
||||
- Context menu options **“Do not invert image(s) in dark mode”** and **“Invert image(s) in dark mode”** now properly cascade when drawings are nested as images inside other drawings.
|
||||
- Improved performance of the [MindMap Builder script](${URLs.VISUAL_THINKING_WORKSHOP_COM_MINDMAP}).
|
||||
|
||||
## New
|
||||
- [Deconstruct Selected Elements script](${getYouTubeUrl("HRtaaD34Zzg")}) now includes a folder selection option, allowing you to choose the destination folder for the generated image.
|
||||
- Arrow binding midpoints. When the projected point is close to center, snap it to the exact center. This way it's easier to create neat(er) simple arrow connections. [#10611](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10611)
|
||||
|
||||
`,
|
||||
"2.20.3": `
|
||||
## Fixed
|
||||
- Hover preview when hovering an element with a link in the scene was unreliable
|
||||
- If a text element had a link in the text body, in some situations, the link became unresponsive to clicks. [#2660](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2660)
|
||||
|
||||
## New
|
||||
- Added default keymap to latex editor [#2655](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_PULL}/2655) 🙏[superle3](${URLs.GITHUB_COM_SUPERLE3})
|
||||
`,
|
||||
"2.20.2": `
|
||||
## New from Excalidraw.com
|
||||
- Arrow focus indicator [#10613](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10613)
|
||||
|
||||
## Fixed
|
||||
- Experimental file type display now also works in Obsidian Mobile. (Reported on Discord)
|
||||
- Text to Mermaid stores chat history locally (i.e. not synchronized between devices).
|
||||
- Image positioning in crop editor [#2589](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2589), [#10726](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10726)
|
||||
|
||||
## MindMap Builder
|
||||
- Implemented better undo support (effective only for the very last MindMap Builder action). Additionally, CMD/CTRL+Z and CTRL+Y, CMD+SHIFT+Z now work when the MindMap input window is focused.
|
||||
- Fixed: Double character input issue (IME Composition Error) when creating nodes [#2647](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2647)
|
||||
- Fixed: More robust error handling when the MindMap is corrupted or invalid.
|
||||
- Updated Excalidraw Writing Machine to support document generation from MindMaps. Writing Machine will honor the branch order. Requires update of the Writing Machine Script.
|
||||
|
||||
## New in ExcalidrawAutomate
|
||||
- \`getBoundTextElement()\` now also accepts an \`ExcalidrawElement[]\` (2-element selection: container + text) in addition to a single element.
|
||||
- \`addElementsToView()\` extended with \`captureUpdate\` parameter (default: "IMMEDIATELY"). When set to false, the addition of elements will not be recorded in the view's history.
|
||||
|
||||
\`\`\`ts
|
||||
async addElementsToView(
|
||||
repositionToCursor: boolean = false,
|
||||
save: boolean = true,
|
||||
newElementsOnTop: boolean = false,
|
||||
shouldRestoreElements: boolean = false,
|
||||
captureUpdate: CaptureUpdateActionType = CaptureUpdateAction.IMMEDIATELY,
|
||||
): Promise<boolean>
|
||||
\`\`\`
|
||||
`,
|
||||
"2.20.1": `
|
||||
## Fixed
|
||||
- Fixed Experimental file type display, available under miscellaneous settings. (Reported on Discord)
|
||||
- Fixed image inversion in dark mode on iOS devices. [#2636](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2636)
|
||||
- Fixed UI Mode switching on tablets was unreliable.
|
||||
|
||||
## New/Fixed in MindMap Builder
|
||||
- **Connector Ontology**: Added support for labeling connection lines. A secondary input field (accessible via Shift+Tab) is now available in both docked and floating modes. Labels are preserved during copy/paste operations using inline Dataview syntax (e.g., link ontology:: node content).
|
||||
- **Connector Styling**: Introduced configuration settings for branch thickness and scaling strategies, allowing a choice between Hierarchical (tapering width by depth) or Uniform connector widths.
|
||||
- **Smart Resume**: The Focus and Zoom actions now target the most recently active node if no current selection is made. This automatically focuses the input field, allowing you to quickly resume mapping from where you left off.
|
||||
- **Radial Fill Sweep**: Added a "Fill Sweep Angle" option for Radial layouts. When enabled, nodes are distributed evenly across the full configured arc range, even when there are only a few nodes. (Visible only when Growth Strategy is set to "Radial").
|
||||
- **Radial Navigation**: Updated Level 1 node navigation in Radial maps to follow visual vertical alignment instead of rotational order. Up/Down keys now consistently move the selection visually up or down on both sides of the circle, matching the behavior of Right-Left layouts.
|
||||
- **Fixed**:
|
||||
- Sidepanel opens on activation of MindMap Builder even in floating mode. Requires update of both Excalidraw and the MindMap Builder script.
|
||||
- **Node Reordering**: Overhauled the logic for moving nodes via CMD/CTRL+Arrow to resolve unpredictability; nodes now move consistently to the intended locations.
|
||||
- **iOS Navigation**: Resolved an issue where using the Tab key to cycle focus between components in the floating input window did not work reliably on iOS.
|
||||
- **Boundary Layering**: Fixed an issue where sub-branch boundaries were placed above text elements when pasting a map; they now correctly render on the layer below the text.
|
||||
- **Layout Stability**: Fixed an issue where the viewport would shift unexpectedly when pasting multiple elements onto an existing node in large scenes.
|
||||
|
||||
> [!Tip]- Learn MindMap Builder
|
||||
> Learn it fast with the low-cost [MindMap Builder course](${URLs.VISUAL_THINKING_WORKSHOP_COM_MINDMAP}). Register before **31 Jan** to join a live Q&A:
|
||||
> - Sat Jan 31 @ 18:00 CET ([local time](${URLs.WWW_TIMEANDDATE_COM_WORLDCLOCK_FIXEDTIME_HTML}))
|
||||
> - Sun Feb 1 @ 09:00 CET ([local time](${URLs.WWW_TIMEANDDATE_COM_WORLDCLOCK_FIXEDTIME_HTML_1}))
|
||||
|
||||
`,
|
||||
"2.20.0": `
|
||||
${getYouTubeDiv("5G9QF-u9w0Q")}
|
||||
|
||||
> [!Tip]- Learn MindMap Builder
|
||||
> Learn it fast with the low-cost [MindMap Builder course](${URLs.VISUAL_THINKING_WORKSHOP_COM_MINDMAP}). Register before **31 Jan** to join a live Q&A:
|
||||
> - Sat Jan 31 @ 18:00 CET ([local time](${URLs.WWW_TIMEANDDATE_COM_WORLDCLOCK_FIXEDTIME_HTML}))
|
||||
> - Sun Feb 1 @ 09:00 CET ([local time](${URLs.WWW_TIMEANDDATE_COM_WORLDCLOCK_FIXEDTIME_HTML_1}))
|
||||
|
||||
## Scripts
|
||||
- Moved [Shade Master](${getYouTubeUrl("ISuORbVKyhQ")}) to use the new Excalidraw Sidepanel API (just like MindMap Builder).
|
||||
|
||||
## New
|
||||
- Dark theme from Excalidraw.com [#10578](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10578) (including correct emoji rendering in dark mode 😍).
|
||||
- New image context-menu option (right-click an image) to control whether that image inverts in dark mode
|
||||
- Default behavior: SVG-based images (including LaTeX, Mermaid, and nested Excalidraw images) invert in dark mode; bitmap images (PNG/JPG) do not.
|
||||
- New from Excalidraw.com: chat-style interface for Mermaid TextToDiagrams (requires an OpenAI API key configured in Excalidraw plugin settings). [#10530](${URLs.GITHUB_COM_EXCALIDRAW_EXCALIDRAW_PULL}/10530)
|
||||
- Breaking change: the legacy “force SVG” option for Mermaid diagrams is no longer supported. If a diagram can be rendered as Excalidraw, it will be; otherwise, an SVG will be used.
|
||||
- Moved the Shade Master script to use the new Sidepanel (just like MindMap Builder).
|
||||
|
||||
## Fixed
|
||||
- In full-screen mode on phones, a large area at the top of the screen was left unused. Also fixed an issue where the Obsidian Mobile navigation bar could overlap the Excalidraw toolbar.
|
||||
- The link indicator in the top-right corner would remain visible even when an element was set to transparent [#2625](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2625)
|
||||
- Importing PDFs with mixed page sizes could produce distorted pages [#2578](${URLs.GITHUB_COM_ZSVICZIAN_OBSIDIAN_EXCALIDRAW_PLUGIN_ISSUES}/2578)
|
||||
- Some PDFs failed to load when importing PDFs as images (notably documents using JPEG2000-compressed images). Also improved handling of certain color profiles and cases where text rendered with missing/incorrect glyphs.
|
||||
- A long-standing export issue: when exporting in a theme different from the current view (e.g., viewing in dark mode but exporting in light mode), nested Excalidraw images containing bitmap images could export with inverted colors.
|
||||
`,
|
||||
};
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
viewportCoordsToSceneCoords,
|
||||
MAX_IMAGE_SIZE,
|
||||
ANIMATED_IMAGE_TYPES,
|
||||
MD_EX_SECTIONS,
|
||||
} from "src/constants/constants";
|
||||
import {
|
||||
insertEmbeddableToView,
|
||||
@@ -17,14 +16,21 @@ import {
|
||||
} from "src/utils/excalidrawViewUtils";
|
||||
import { getEA } from "src/core";
|
||||
import { InsertPDFModal } from "./InsertPDFModal";
|
||||
import { ExcalidrawAutomate } from "src/shared/ExcalidrawAutomate";
|
||||
import { cleanSectionHeading } from "src/utils/pathUtils";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { hideElement, setStyle, showElement } from "src/utils/styleUtils";
|
||||
import {
|
||||
getMarkdownHeadingSubpaths,
|
||||
type MarkdownHeadingSubpath,
|
||||
} from "src/shared/Suggesters/markdownSubpathSuggester";
|
||||
import { insertMarkdownImage } from "src/shared/MarkdownImage";
|
||||
import { EmbeddedFile } from "src/shared/EmbeddedFileLoader";
|
||||
|
||||
export type UniversalInsertFileAction = "image" | "embeddable";
|
||||
|
||||
export class UniversalInsertFileModal extends Modal {
|
||||
private center: { x: number; y: number } = { x: 0, y: 0 };
|
||||
private file: TFile;
|
||||
private preferredAction: UniversalInsertFileAction | null = null;
|
||||
|
||||
constructor(
|
||||
private plugin: ExcalidrawPlugin,
|
||||
@@ -72,9 +78,14 @@ export class UniversalInsertFileModal extends Modal {
|
||||
|
||||
private onKeyDown: (evt: KeyboardEvent) => void;
|
||||
|
||||
open(file?: TFile, center?: { x: number; y: number }) {
|
||||
open(
|
||||
file?: TFile,
|
||||
center?: { x: number; y: number },
|
||||
preferredAction?: UniversalInsertFileAction,
|
||||
) {
|
||||
this.file = file;
|
||||
this.center = center ?? this.center;
|
||||
this.preferredAction = preferredAction ?? null;
|
||||
super.open();
|
||||
}
|
||||
|
||||
@@ -95,6 +106,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
let actionPDF: ButtonComponent;
|
||||
let anchorTo100: boolean = false;
|
||||
let file = this.file;
|
||||
let fileSections: MarkdownHeadingSubpath[] = [];
|
||||
|
||||
const updateForm = async () => {
|
||||
const ea = this.plugin.ea;
|
||||
@@ -110,38 +122,26 @@ export class UniversalInsertFileModal extends Modal {
|
||||
const isPDF = file && file.extension === "pdf";
|
||||
const isExcalidraw = file && ea.isExcalidrawFile(file);
|
||||
|
||||
const sections =
|
||||
file && file.extension === "md"
|
||||
? (
|
||||
await this.plugin.app.metadataCache.blockCache.getForFile(
|
||||
{ isCancelled: () => false },
|
||||
file,
|
||||
)
|
||||
).blocks
|
||||
.filter(
|
||||
(b: { display: string; node?: { type: string } }) =>
|
||||
b.display && b.node?.type === "heading",
|
||||
)
|
||||
.filter(
|
||||
(b: { display: string; node?: { type: string } }) =>
|
||||
!isExcalidraw || !MD_EX_SECTIONS.includes(b.display),
|
||||
)
|
||||
: null;
|
||||
fileSections =
|
||||
file?.extension === "md"
|
||||
? await getMarkdownHeadingSubpaths(
|
||||
this.app,
|
||||
file,
|
||||
Boolean(isExcalidraw),
|
||||
)
|
||||
: [];
|
||||
|
||||
if (isMarkdown || (isExcalidraw && sections?.length > 0)) {
|
||||
while (sectionPicker.selectEl.options.length > 0) {
|
||||
sectionPicker.selectEl.remove(0);
|
||||
}
|
||||
if (isMarkdown || (isExcalidraw && fileSections.length > 0)) {
|
||||
showElement(sectionPickerSetting.settingEl);
|
||||
showElement(sectionPicker.selectEl);
|
||||
while (sectionPicker.selectEl.options.length > 0) {
|
||||
sectionPicker.selectEl.remove(0);
|
||||
if (!isSelf) {
|
||||
sectionPicker.addOption("", t("SHOW_ENTIRE_FILE"));
|
||||
}
|
||||
if (!isExcalidraw) {
|
||||
sectionPicker.addOption("", "");
|
||||
}
|
||||
sections.forEach((b: { display: string; node?: { type: string } }) => {
|
||||
sectionPicker.addOption(
|
||||
`#${cleanSectionHeading(b.display)}`,
|
||||
b.display,
|
||||
);
|
||||
fileSections.forEach((section) => {
|
||||
sectionPicker.addOption(section.subpath, section.display);
|
||||
});
|
||||
} else {
|
||||
hideElement(sectionPickerSetting.settingEl);
|
||||
@@ -154,7 +154,10 @@ export class UniversalInsertFileModal extends Modal {
|
||||
hideElement(sizeToggleSetting.settingEl);
|
||||
}
|
||||
|
||||
if (!isSelf && (isImage || file?.extension === "md")) {
|
||||
if (
|
||||
(!isSelf && (isImage || file?.extension === "md")) ||
|
||||
(isSelf && isExcalidraw && fileSections.length > 0)
|
||||
) {
|
||||
showElement(actionImage.buttonEl);
|
||||
} else {
|
||||
hideElement(actionImage.buttonEl);
|
||||
@@ -163,7 +166,7 @@ export class UniversalInsertFileModal extends Modal {
|
||||
if (
|
||||
isIFrame ||
|
||||
isAnimatedImage ||
|
||||
(isExcalidraw && sections?.length > 0)
|
||||
(isExcalidraw && (!isSelf || fileSections.length > 0))
|
||||
) {
|
||||
showElement(actionIFrame.buttonEl);
|
||||
} else {
|
||||
@@ -177,20 +180,11 @@ export class UniversalInsertFileModal extends Modal {
|
||||
}
|
||||
};
|
||||
|
||||
const sections = (
|
||||
await this.plugin.app.metadataCache.blockCache.getForFile(
|
||||
{ isCancelled: () => false },
|
||||
this.view.file,
|
||||
)
|
||||
).blocks
|
||||
.filter(
|
||||
(b: { display: string; node?: { type: string } }) =>
|
||||
b.display && b.node?.type === "heading",
|
||||
)
|
||||
.filter(
|
||||
(b: { display: string; node?: { type: string } }) =>
|
||||
!MD_EX_SECTIONS.includes(b.display),
|
||||
);
|
||||
const currentFileSections = await getMarkdownHeadingSubpaths(
|
||||
this.app,
|
||||
this.view.file,
|
||||
true,
|
||||
);
|
||||
|
||||
const search = new TextComponent(ce);
|
||||
setStyle(search.inputEl, { width: "100%" });
|
||||
@@ -199,7 +193,9 @@ export class UniversalInsertFileModal extends Modal {
|
||||
search,
|
||||
this.app.vault
|
||||
.getFiles()
|
||||
.filter((f: TFile) => sections?.length > 0 || f !== this.view.file),
|
||||
.filter(
|
||||
(f: TFile) => currentFileSections.length > 0 || f !== this.view.file,
|
||||
),
|
||||
this.plugin,
|
||||
);
|
||||
search.onChange(() => {
|
||||
@@ -225,13 +221,16 @@ export class UniversalInsertFileModal extends Modal {
|
||||
|
||||
new Setting(ce)
|
||||
.addButton((button) => {
|
||||
if (this.preferredAction === "embeddable") {
|
||||
button.setCta();
|
||||
}
|
||||
button.setButtonText(t("UIFM_BTN_EMBEDDABLE")).onClick(async () => {
|
||||
const path = this.app.metadataCache.fileToLinktext(
|
||||
file,
|
||||
this.view.file.path,
|
||||
file.extension === "md",
|
||||
);
|
||||
const ea: ExcalidrawAutomate = getEA(this.view);
|
||||
const ea = getEA(this.view);
|
||||
ea.selectElementsInView([
|
||||
await insertEmbeddableToView(
|
||||
ea,
|
||||
@@ -255,24 +254,39 @@ export class UniversalInsertFileModal extends Modal {
|
||||
actionPDF = button;
|
||||
})
|
||||
.addButton((button) => {
|
||||
if (this.preferredAction === "image") {
|
||||
button.setCta();
|
||||
}
|
||||
button.setButtonText(t("UIFM_BTN_IMAGE")).onClick(async () => {
|
||||
const ea: ExcalidrawAutomate = getEA(this.view);
|
||||
const isMarkdown =
|
||||
file && file.extension === "md" && !ea.isExcalidrawFile(file);
|
||||
ea.selectElementsInView([
|
||||
await insertImageToView(
|
||||
ea,
|
||||
this.center,
|
||||
//this.view.currentPosition,
|
||||
isMarkdown &&
|
||||
sectionPicker.selectEl.value &&
|
||||
sectionPicker.selectEl.value !== ""
|
||||
? `${file.path}${sectionPicker.selectEl.value}`
|
||||
file &&
|
||||
file.extension === "md" &&
|
||||
!this.plugin.isExcalidrawFile(file);
|
||||
const section = sectionPicker.selectEl.value;
|
||||
if (isMarkdown || (file?.extension === "md" && section)) {
|
||||
await insertMarkdownImage(
|
||||
this.view,
|
||||
section
|
||||
? new EmbeddedFile(
|
||||
this.plugin,
|
||||
this.view.file.path,
|
||||
`${file.path}${section}`,
|
||||
)
|
||||
: file,
|
||||
ea.isExcalidrawFile(file) ? !anchorTo100 : undefined,
|
||||
),
|
||||
]);
|
||||
ea.destroy();
|
||||
this.center,
|
||||
);
|
||||
} else {
|
||||
const ea = getEA(this.view);
|
||||
ea.selectElementsInView([
|
||||
await insertImageToView(
|
||||
ea,
|
||||
this.center,
|
||||
file,
|
||||
ea.isExcalidrawFile(file) ? !anchorTo100 : undefined,
|
||||
),
|
||||
]);
|
||||
ea.destroy();
|
||||
}
|
||||
this.close();
|
||||
});
|
||||
actionImage = button;
|
||||
|
||||
@@ -1872,6 +1872,10 @@ export class EmbeddedFilesLoader {
|
||||
overflow: "auto",
|
||||
display: "block",
|
||||
color: fontColor && fontColor !== "" ? fontColor : "initial",
|
||||
paddingBottom:
|
||||
overrides && !overrides.isTransclusion
|
||||
? `${overrides.render.paddingBottom}px`
|
||||
: undefined,
|
||||
});
|
||||
|
||||
const renderHost = mainDocument.body.createDiv();
|
||||
|
||||
+75
-34
@@ -1,4 +1,5 @@
|
||||
import type { Mutable } from "@zsviczian/excalidraw/types/common/src/utility-types";
|
||||
import { TFile } from "obsidian";
|
||||
import type {
|
||||
ExcalidrawElement,
|
||||
ExcalidrawEmbeddableElement,
|
||||
@@ -115,25 +116,46 @@ export function setMarkdownImageCustomData(
|
||||
});
|
||||
}
|
||||
|
||||
/** Resolves the current local fragment or external Markdown transclusion. */
|
||||
/** Resolves a Markdown image element or Markdown file to its renderable source. */
|
||||
export async function getMarkdownImageSource(
|
||||
view: ExcalidrawView,
|
||||
element: ExcalidrawImageElement,
|
||||
source: ExcalidrawImageElement | TFile | EmbeddedFile,
|
||||
): Promise<MarkdownImageSourceData | null> {
|
||||
const customData = getMarkdownImageCustomData(element);
|
||||
let sourceFile: TFile | null;
|
||||
let suppliedEmbeddedFile: EmbeddedFile | null;
|
||||
let element: ExcalidrawImageElement | null;
|
||||
if (source instanceof TFile) {
|
||||
sourceFile = source;
|
||||
suppliedEmbeddedFile = null;
|
||||
element = null;
|
||||
} else if (source instanceof EmbeddedFile) {
|
||||
sourceFile = null;
|
||||
suppliedEmbeddedFile = source;
|
||||
element = null;
|
||||
} else {
|
||||
sourceFile = null;
|
||||
suppliedEmbeddedFile = null;
|
||||
element = source;
|
||||
}
|
||||
const customData = element ? getMarkdownImageCustomData(element) : null;
|
||||
const preferredSource = customData?.source;
|
||||
const local =
|
||||
preferredSource === "external"
|
||||
!element || preferredSource === "external"
|
||||
? undefined
|
||||
: view.excalidrawData.getMarkdownImage(element.fileId);
|
||||
if (local !== undefined) {
|
||||
return { markdown: local.markdown, source: "local" };
|
||||
}
|
||||
const embeddedFile = view.excalidrawData.getFile(element.fileId);
|
||||
const embeddedFile = element
|
||||
? view.excalidrawData.getFile(element.fileId)
|
||||
: (suppliedEmbeddedFile ??
|
||||
new EmbeddedFile(view.plugin, view.file.path, sourceFile.path));
|
||||
if (
|
||||
!embeddedFile?.file ||
|
||||
embeddedFile.file.extension.toLowerCase() !== "md" ||
|
||||
(view.plugin.isExcalidrawFile(embeddedFile.file) && !customData)
|
||||
(view.plugin.isExcalidrawFile(embeddedFile.file) &&
|
||||
!customData &&
|
||||
!suppliedEmbeddedFile?.linkParts.ref)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
@@ -188,6 +210,28 @@ const setRenderedMarkdownImageFile = (
|
||||
};
|
||||
};
|
||||
|
||||
const setMarkdownImageSource = (
|
||||
view: ExcalidrawView,
|
||||
fileId: FileId,
|
||||
sourceData: MarkdownImageSourceData,
|
||||
): void => {
|
||||
if (sourceData.source === "local") {
|
||||
view.excalidrawData.setMarkdownImage(fileId, {
|
||||
markdown: sourceData.markdown,
|
||||
});
|
||||
} else if (sourceData.embeddedFile) {
|
||||
view.excalidrawData.setFile(fileId, sourceData.embeddedFile);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteMarkdownImageSource = (
|
||||
view: ExcalidrawView,
|
||||
fileId: FileId,
|
||||
): void => {
|
||||
view.excalidrawData.deleteMarkdownImage(fileId, true);
|
||||
view.excalidrawData.deleteFile(fileId);
|
||||
};
|
||||
|
||||
const getEmbeddableLinkTarget = (link: string): string | null => {
|
||||
const result = REGEX_LINK.getRes(link).next();
|
||||
if (result.value) {
|
||||
@@ -273,20 +317,13 @@ export async function convertEmbeddableElementToMarkdownImage(
|
||||
render,
|
||||
);
|
||||
setRenderedMarkdownImageFile(ea, fileId, rendered);
|
||||
if (sourceData.source === "local") {
|
||||
view.excalidrawData.setMarkdownImage(fileId, {
|
||||
markdown: sourceData.markdown,
|
||||
});
|
||||
} else if (sourceData.embeddedFile) {
|
||||
view.excalidrawData.setFile(fileId, sourceData.embeddedFile);
|
||||
}
|
||||
setMarkdownImageSource(view, fileId, sourceData);
|
||||
let committed = false;
|
||||
try {
|
||||
committed = await commitElements(ea);
|
||||
} finally {
|
||||
if (!committed) {
|
||||
view.excalidrawData.deleteMarkdownImage(fileId, true);
|
||||
view.excalidrawData.deleteFile(fileId);
|
||||
deleteMarkdownImageSource(view, fileId);
|
||||
}
|
||||
}
|
||||
if (!committed) {
|
||||
@@ -379,24 +416,37 @@ export function getLevelOneMarkdownHeadings(
|
||||
return headings;
|
||||
}
|
||||
|
||||
/** Inserts a new local editable Markdown image without adding wrapper content. */
|
||||
/** Inserts an editable Markdown image from local text or a linked Markdown note. */
|
||||
export async function insertMarkdownImage(
|
||||
view: ExcalidrawView,
|
||||
markdown: string = "",
|
||||
source: string | TFile | EmbeddedFile = "",
|
||||
position: { x: number; y: number } = view.currentPosition,
|
||||
): Promise<string | null> {
|
||||
if (!view.excalidrawAPI || !view.file) {
|
||||
return null;
|
||||
}
|
||||
const sourceData =
|
||||
typeof source === "string"
|
||||
? { markdown: source, source: "local" as const }
|
||||
: await getMarkdownImageSource(view, source);
|
||||
if (!sourceData) {
|
||||
return null;
|
||||
}
|
||||
const render = getMarkdownImageRenderSettings(view.plugin);
|
||||
const rendered = await renderMarkdown(view, markdown, render);
|
||||
const rendered = await renderMarkdown(
|
||||
view,
|
||||
sourceData.markdown,
|
||||
render,
|
||||
sourceData.embeddedFile?.file ?? view.file,
|
||||
);
|
||||
if (!rendered.dataURL || rendered.size.height <= 0) {
|
||||
return null;
|
||||
}
|
||||
const ea = getEA(view);
|
||||
const fileId = fileid() as FileId;
|
||||
const id = await ea.addImage(
|
||||
view.currentPosition.x,
|
||||
view.currentPosition.y,
|
||||
position.x,
|
||||
position.y,
|
||||
rendered.dataURL,
|
||||
false,
|
||||
false,
|
||||
@@ -406,29 +456,20 @@ export async function insertMarkdownImage(
|
||||
return null;
|
||||
}
|
||||
const element = ea.getElement(id) as Mutable<ExcalidrawImageElement>;
|
||||
const generatedFileId = element.fileId;
|
||||
const image = ea.imagesDict[generatedFileId];
|
||||
delete ea.imagesDict[generatedFileId];
|
||||
delete ea.imagesDict[element.fileId];
|
||||
element.fileId = fileId;
|
||||
element.width = render.width;
|
||||
element.height = rendered.size.height;
|
||||
element.crop = null;
|
||||
setMarkdownImageCustomData(element, "local", render);
|
||||
ea.imagesDict[fileId] = {
|
||||
...image,
|
||||
id: fileId,
|
||||
dataURL: rendered.dataURL,
|
||||
mimeType: "image/svg+xml",
|
||||
size: rendered.size,
|
||||
hasSVGwithBitmap: rendered.hasSVGwithBitmap,
|
||||
};
|
||||
view.excalidrawData.setMarkdownImage(fileId, { markdown });
|
||||
setMarkdownImageCustomData(element, sourceData.source, render);
|
||||
setRenderedMarkdownImageFile(ea, fileId, rendered);
|
||||
setMarkdownImageSource(view, fileId, sourceData);
|
||||
let committed = false;
|
||||
try {
|
||||
committed = await commitElements(ea, true);
|
||||
} finally {
|
||||
if (!committed) {
|
||||
view.excalidrawData.deleteMarkdownImage(fileId, true);
|
||||
deleteMarkdownImageSource(view, fileId);
|
||||
}
|
||||
}
|
||||
if (!committed) {
|
||||
|
||||
@@ -24,6 +24,34 @@ function isHeadingBlockEntry(entry: BlockCacheEntry): entry is HeadingBlockEntry
|
||||
return Boolean(entry.display && entry.node?.type === "heading");
|
||||
}
|
||||
|
||||
export type MarkdownHeadingSubpath = {
|
||||
display: string;
|
||||
subpath: string;
|
||||
};
|
||||
|
||||
/** Returns link subpaths for user-authored Markdown headings. */
|
||||
export async function getMarkdownHeadingSubpaths(
|
||||
app: App,
|
||||
file: TFile,
|
||||
isExcalidrawFile: boolean,
|
||||
): Promise<MarkdownHeadingSubpath[]> {
|
||||
return (
|
||||
await app.metadataCache.blockCache.getForFile(
|
||||
{ isCancelled: () => false },
|
||||
file,
|
||||
)
|
||||
).blocks
|
||||
.filter(isHeadingBlockEntry)
|
||||
.filter(
|
||||
(entry) =>
|
||||
!isExcalidrawFile || !MD_EX_SECTIONS.includes(entry.display),
|
||||
)
|
||||
.map((entry) => ({
|
||||
display: entry.display,
|
||||
subpath: `#${cleanSectionHeading(entry.display)}`,
|
||||
}));
|
||||
}
|
||||
|
||||
function isParagraphLikeBlockEntry(
|
||||
entry: BlockCacheEntry,
|
||||
): entry is ParagraphLikeBlockEntry {
|
||||
@@ -45,20 +73,12 @@ export async function selectMarkdownHeadingSubpath(
|
||||
isExcalidrawFile: boolean,
|
||||
isCancelled?: () => boolean,
|
||||
): Promise<string | null> {
|
||||
const sections = (
|
||||
await app.metadataCache.blockCache.getForFile(
|
||||
{ isCancelled: () => false },
|
||||
file,
|
||||
)
|
||||
).blocks
|
||||
.filter(isHeadingBlockEntry)
|
||||
.filter(
|
||||
(entry) =>
|
||||
!isExcalidrawFile || !MD_EX_SECTIONS.includes(entry.display),
|
||||
);
|
||||
const values = sections.map(
|
||||
(entry) => `#${cleanSectionHeading(entry.display)}`,
|
||||
const sections = await getMarkdownHeadingSubpaths(
|
||||
app,
|
||||
file,
|
||||
isExcalidrawFile,
|
||||
);
|
||||
const values = sections.map((entry) => entry.subpath);
|
||||
const display = sections.map((entry) => entry.display);
|
||||
if (!isExcalidrawFile) {
|
||||
values.unshift("");
|
||||
|
||||
@@ -119,19 +119,16 @@ export class FontPickerComponent extends ValueComponent<string> {
|
||||
option: SelectableFontOption;
|
||||
element: HTMLSpanElement;
|
||||
}> = [];
|
||||
let firstOptionEl: HTMLSpanElement | null = null;
|
||||
const menu = new Menu().setUseNativeMenu(false);
|
||||
for (const option of options) {
|
||||
menu.addItem((item) => {
|
||||
const title = createFragment();
|
||||
const label = title.createSpan({
|
||||
cls: [
|
||||
"excalidraw-font-picker__option",
|
||||
...(!DEVICE.isMobile
|
||||
? ["excalidraw-font-picker__option--desktop"]
|
||||
: []),
|
||||
],
|
||||
cls: "excalidraw-font-picker__option",
|
||||
text: option.label,
|
||||
});
|
||||
firstOptionEl ??= label;
|
||||
if (option.fontFile) {
|
||||
localPreviews.push({ option, element: label });
|
||||
} else {
|
||||
@@ -158,10 +155,22 @@ export class FontPickerComponent extends ValueComponent<string> {
|
||||
this.menu = menu;
|
||||
this.buttonEl.setAttribute("aria-expanded", "true");
|
||||
const rect = this.buttonEl.getBoundingClientRect();
|
||||
menu.showAtPosition(
|
||||
{ x: rect.left, y: rect.bottom, width: rect.width },
|
||||
doc,
|
||||
);
|
||||
if (!DEVICE.isMobile) {
|
||||
doc.body.classList.add("excalidraw-font-picker-menu-opening");
|
||||
}
|
||||
try {
|
||||
menu.showAtPosition(
|
||||
{ x: rect.left, y: rect.bottom, width: rect.width },
|
||||
doc,
|
||||
);
|
||||
if (!DEVICE.isMobile) {
|
||||
firstOptionEl
|
||||
?.closest<HTMLElement>(".menu")
|
||||
?.classList.add("excalidraw-font-picker-menu--desktop");
|
||||
}
|
||||
} finally {
|
||||
doc.body.classList.remove("excalidraw-font-picker-menu-opening");
|
||||
}
|
||||
this.observeLocalPreviews(localPreviews, doc);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ export type MarkdownImageTransclusionRenderSettings = {
|
||||
|
||||
export type MarkdownImageRenderSettings = {
|
||||
width: number;
|
||||
paddingBottom: number;
|
||||
fontFamily: string;
|
||||
fontColor: string;
|
||||
border: {
|
||||
|
||||
@@ -12,6 +12,10 @@ export function resolveMarkdownImageRenderSettings(
|
||||
const defaultTransclusion = defaults.transclusion;
|
||||
return {
|
||||
width: stored?.width ?? defaults.width,
|
||||
paddingBottom: Math.min(
|
||||
100,
|
||||
Math.max(0, Math.round(stored?.paddingBottom ?? defaults.paddingBottom)),
|
||||
),
|
||||
fontFamily: stored?.fontFamily ?? defaults.fontFamily,
|
||||
fontColor: normalizeFontColor(stored?.fontColor ?? defaults.fontColor),
|
||||
border: {
|
||||
|
||||
+112
-115
@@ -82,7 +82,6 @@ import {
|
||||
unwrapMarkdownImageBlock,
|
||||
} from "../shared/ExcalidrawData";
|
||||
import {
|
||||
checkAndCreateFolder,
|
||||
createFileAndAwaitMetacacheUpdate,
|
||||
createOrOverwriteFile,
|
||||
download,
|
||||
@@ -143,7 +142,6 @@ import {
|
||||
LaTexPrompt,
|
||||
MultiOptionConfirmationPrompt,
|
||||
NewFileActions,
|
||||
Prompt,
|
||||
linkPrompt,
|
||||
} from "../shared/Dialogs/Prompt";
|
||||
import {
|
||||
@@ -188,6 +186,7 @@ import {
|
||||
SwordColors,
|
||||
} from "../constants/actionIcons";
|
||||
import { ExportDialog } from "../shared/Dialogs/ExportDialog";
|
||||
import { FileAndFolderSelectorModal } from "../shared/Dialogs/FileAndFolderSelectorModal";
|
||||
import { getEA } from "src/core";
|
||||
import {
|
||||
anyModifierKeysPressed,
|
||||
@@ -617,34 +616,32 @@ export default class ExcalidrawView
|
||||
return;
|
||||
}
|
||||
if (DEVICE.isMobile) {
|
||||
const prompt = new Prompt(
|
||||
this.app,
|
||||
t("EXPORT_FILENAME_PROMPT"),
|
||||
this.file.basename,
|
||||
t("EXPORT_FILENAME_PROMPT_PLACEHOLDER"),
|
||||
const location = await new FileAndFolderSelectorModal(this.app, {
|
||||
title: t("FILE_AND_FOLDER_SELECTOR_EXPORT_TITLE"),
|
||||
folderLabel: t("FILE_AND_FOLDER_SELECTOR_FOLDER"),
|
||||
fileNameLabel: t("FILE_AND_FOLDER_SELECTOR_FILENAME"),
|
||||
submitButtonText: t("FILE_AND_FOLDER_SELECTOR_EXPORT"),
|
||||
folderPath: splitFolderAndFilename(this.file.path).folderpath,
|
||||
fileName: `${this.file.basename}.excalidraw`,
|
||||
}).start();
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
const filename = location.fileName.toLowerCase().endsWith(".excalidraw")
|
||||
? location.fileName
|
||||
: `${location.fileName}.excalidraw`;
|
||||
const path = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
location.folderPath,
|
||||
);
|
||||
void prompt.openAndGetValue((filename: string) => {
|
||||
if (!filename) {
|
||||
return;
|
||||
}
|
||||
void (async () => {
|
||||
filename = `${filename}.excalidraw`;
|
||||
const folderpath = splitFolderAndFilename(this.file?.path).folderpath;
|
||||
await checkAndCreateFolder(folderpath); //create folder if it does not exist
|
||||
const path = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
folderpath,
|
||||
);
|
||||
const file = await exportImageToFile(
|
||||
this,
|
||||
path,
|
||||
JSON.stringify(this.getScene(), null, "\t"),
|
||||
".excalidraw",
|
||||
);
|
||||
new Notice(`Exported to ${file?.name}`, 6000);
|
||||
})();
|
||||
});
|
||||
const file = await exportImageToFile(
|
||||
this,
|
||||
path,
|
||||
JSON.stringify(this.getScene(), null, "\t"),
|
||||
".excalidraw",
|
||||
);
|
||||
new Notice(`Exported to ${file?.name}`, 6000);
|
||||
return;
|
||||
}
|
||||
download(
|
||||
@@ -4529,94 +4526,94 @@ export default class ExcalidrawView
|
||||
if (!textElement) {
|
||||
return;
|
||||
}
|
||||
const prompt = new Prompt(
|
||||
this.app,
|
||||
"Filename",
|
||||
"",
|
||||
"Leave blank to cancel this action",
|
||||
);
|
||||
void prompt.openAndGetValue((filename: string) => {
|
||||
void (async () => {
|
||||
if (!filename) {
|
||||
return;
|
||||
}
|
||||
filename = `${filename}.md`;
|
||||
const folderpath = splitFolderAndFilename(this.file.path).folderpath;
|
||||
await checkAndCreateFolder(folderpath); //create folder if it does not exist
|
||||
const fname = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
folderpath,
|
||||
);
|
||||
const text: string[] = [];
|
||||
if (containerElement && containerElement.link) {
|
||||
text.push(containerElement.link);
|
||||
}
|
||||
text.push(textElement.rawText);
|
||||
const f = await createOrOverwriteFile(this.app, fname, text.join("\n"));
|
||||
if (f) {
|
||||
const ea: ExcalidrawAutomate = getEA(this);
|
||||
const elements = containerElement
|
||||
? [textElement, containerElement]
|
||||
: [textElement];
|
||||
ea.copyViewElementsToEAforEditing(elements);
|
||||
ea.getElements().forEach((el) => (el.isDeleted = true));
|
||||
const [x, y, w, h] = containerElement
|
||||
? [
|
||||
containerElement.x,
|
||||
containerElement.y,
|
||||
containerElement.width,
|
||||
containerElement.height,
|
||||
]
|
||||
: [textElement.x, textElement.y, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE];
|
||||
const id = ea.addEmbeddable(x, y, w, h, undefined, f);
|
||||
if (containerElement) {
|
||||
const props: (keyof ExcalidrawElement)[] = [
|
||||
"backgroundColor",
|
||||
"fillStyle",
|
||||
"roughness",
|
||||
"roundness",
|
||||
"strokeColor",
|
||||
"strokeStyle",
|
||||
"strokeWidth",
|
||||
];
|
||||
props.forEach((prop) => {
|
||||
const element = ea.getElement(id);
|
||||
if (prop in element) {
|
||||
const mutableElement = element as Mutable<ExcalidrawElement>;
|
||||
switch (prop) {
|
||||
case "backgroundColor":
|
||||
mutableElement.backgroundColor =
|
||||
containerElement.backgroundColor;
|
||||
break;
|
||||
case "fillStyle":
|
||||
mutableElement.fillStyle = containerElement.fillStyle;
|
||||
break;
|
||||
case "roughness":
|
||||
mutableElement.roughness = containerElement.roughness;
|
||||
break;
|
||||
case "roundness":
|
||||
mutableElement.roundness = containerElement.roundness;
|
||||
break;
|
||||
case "strokeColor":
|
||||
mutableElement.strokeColor = containerElement.strokeColor;
|
||||
break;
|
||||
case "strokeStyle":
|
||||
mutableElement.strokeStyle = containerElement.strokeStyle;
|
||||
break;
|
||||
case "strokeWidth":
|
||||
mutableElement.strokeWidth = containerElement.strokeWidth;
|
||||
break;
|
||||
}
|
||||
void (async () => {
|
||||
const location = await new FileAndFolderSelectorModal(this.app, {
|
||||
title: t("CONVERT_TO_MARKDOWN"),
|
||||
folderLabel: t("FILE_AND_FOLDER_SELECTOR_FOLDER"),
|
||||
fileNameLabel: t("FILE_AND_FOLDER_SELECTOR_FILENAME"),
|
||||
submitButtonText: t("PROMPT_BUTTON_CREATE_MARKDOWN"),
|
||||
folderPath: splitFolderAndFilename(this.file.path).folderpath,
|
||||
fileName: "",
|
||||
}).start();
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
const filename = location.fileName.toLowerCase().endsWith(".md")
|
||||
? location.fileName
|
||||
: `${location.fileName}.md`;
|
||||
const fname = getNewUniqueFilepath(
|
||||
this.app.vault,
|
||||
filename,
|
||||
location.folderPath,
|
||||
);
|
||||
const text: string[] = [];
|
||||
if (containerElement && containerElement.link) {
|
||||
text.push(containerElement.link);
|
||||
}
|
||||
text.push(textElement.rawText);
|
||||
const f = await createOrOverwriteFile(this.app, fname, text.join("\n"));
|
||||
if (f) {
|
||||
const ea: ExcalidrawAutomate = getEA(this);
|
||||
const elements = containerElement
|
||||
? [textElement, containerElement]
|
||||
: [textElement];
|
||||
ea.copyViewElementsToEAforEditing(elements);
|
||||
ea.getElements().forEach((el) => (el.isDeleted = true));
|
||||
const [x, y, w, h] = containerElement
|
||||
? [
|
||||
containerElement.x,
|
||||
containerElement.y,
|
||||
containerElement.width,
|
||||
containerElement.height,
|
||||
]
|
||||
: [textElement.x, textElement.y, MAX_IMAGE_SIZE, MAX_IMAGE_SIZE];
|
||||
const id = ea.addEmbeddable(x, y, w, h, undefined, f);
|
||||
if (containerElement) {
|
||||
const props: (keyof ExcalidrawElement)[] = [
|
||||
"backgroundColor",
|
||||
"fillStyle",
|
||||
"roughness",
|
||||
"roundness",
|
||||
"strokeColor",
|
||||
"strokeStyle",
|
||||
"strokeWidth",
|
||||
];
|
||||
props.forEach((prop) => {
|
||||
const element = ea.getElement(id);
|
||||
if (prop in element) {
|
||||
const mutableElement = element as Mutable<ExcalidrawElement>;
|
||||
switch (prop) {
|
||||
case "backgroundColor":
|
||||
mutableElement.backgroundColor =
|
||||
containerElement.backgroundColor;
|
||||
break;
|
||||
case "fillStyle":
|
||||
mutableElement.fillStyle = containerElement.fillStyle;
|
||||
break;
|
||||
case "roughness":
|
||||
mutableElement.roughness = containerElement.roughness;
|
||||
break;
|
||||
case "roundness":
|
||||
mutableElement.roundness = containerElement.roundness;
|
||||
break;
|
||||
case "strokeColor":
|
||||
mutableElement.strokeColor = containerElement.strokeColor;
|
||||
break;
|
||||
case "strokeStyle":
|
||||
mutableElement.strokeStyle = containerElement.strokeStyle;
|
||||
break;
|
||||
case "strokeWidth":
|
||||
mutableElement.strokeWidth = containerElement.strokeWidth;
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
ea.getElement(id);
|
||||
await ea.addElementsToView();
|
||||
ea.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
});
|
||||
ea.getElement(id);
|
||||
await ea.addElementsToView();
|
||||
ea.destroy();
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
async addYouTubeThumbnail(link: string) {
|
||||
|
||||
@@ -38,11 +38,15 @@ import {
|
||||
importFileToVault,
|
||||
} from "src/utils/fileUtils";
|
||||
import { ScriptEngine } from "src/shared/Scripts";
|
||||
import { UniversalInsertFileModal } from "src/shared/Dialogs/UniversalInsertFileModal";
|
||||
import {
|
||||
UniversalInsertFileModal,
|
||||
type UniversalInsertFileAction,
|
||||
} from "src/shared/Dialogs/UniversalInsertFileModal";
|
||||
import { Position } from "src/types/excalidrawViewTypes";
|
||||
import { setStyle } from "src/utils/styleUtils";
|
||||
import { ObsidianDraggable } from "src/types/types";
|
||||
import type React from "react";
|
||||
import { insertMarkdownImage } from "src/shared/MarkdownImage";
|
||||
|
||||
/*
|
||||
static getDropAction(event: DragEvent): string {
|
||||
@@ -106,6 +110,18 @@ export class DropManager {
|
||||
return this.view.file;
|
||||
}
|
||||
|
||||
private openDroppedMarkdownFile(
|
||||
file: TFile,
|
||||
position: Position,
|
||||
action: UniversalInsertFileAction,
|
||||
): void {
|
||||
new UniversalInsertFileModal(this.plugin, this.view).open(
|
||||
file,
|
||||
position,
|
||||
action,
|
||||
);
|
||||
}
|
||||
|
||||
public onDrop(event: React.DragEvent<HTMLDivElement>): boolean {
|
||||
if (this.draginfoDiv) {
|
||||
this.ownerDocument.body.removeChild(this.draginfoDiv);
|
||||
@@ -171,6 +187,18 @@ export class DropManager {
|
||||
new Notice(t("FILENAME_INVALID_CHARS"), 4000);
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
file.extension.toLowerCase() === "md" &&
|
||||
(internalDragAction === "image" ||
|
||||
internalDragAction === "embeddable")
|
||||
) {
|
||||
this.openDroppedMarkdownFile(
|
||||
file,
|
||||
{ ...this.currentPosition },
|
||||
internalDragAction,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if (
|
||||
["image", "image-fullsize"].contains(internalDragAction) &&
|
||||
(IMAGE_TYPES.contains(file.extension) ||
|
||||
@@ -220,6 +248,19 @@ export class DropManager {
|
||||
return false;
|
||||
case "files":
|
||||
if (!onDropHook("file", draggable.files, null)) {
|
||||
if (
|
||||
draggable.files.length === 1 &&
|
||||
draggable.files[0].extension.toLowerCase() === "md" &&
|
||||
(internalDragAction === "image" ||
|
||||
internalDragAction === "embeddable")
|
||||
) {
|
||||
this.openDroppedMarkdownFile(
|
||||
draggable.files[0],
|
||||
{ ...this.currentPosition },
|
||||
internalDragAction,
|
||||
);
|
||||
return false;
|
||||
}
|
||||
void (async () => {
|
||||
if (["image", "image-fullsize"].contains(internalDragAction)) {
|
||||
const ea: ExcalidrawAutomate = getEA(this.view);
|
||||
@@ -227,6 +268,22 @@ export class DropManager {
|
||||
let counter: number = 0;
|
||||
const ids: string[] = [];
|
||||
for (const f of draggable.files) {
|
||||
if (
|
||||
internalDragAction === "image" &&
|
||||
f.extension.toLowerCase() === "md" &&
|
||||
!this.plugin.isExcalidrawFile(f)
|
||||
) {
|
||||
const id = await insertMarkdownImage(this.view, f, {
|
||||
x: this.currentPosition.x + counter * 50,
|
||||
y: this.currentPosition.y + counter * 50,
|
||||
});
|
||||
if (id) {
|
||||
ids.push(id);
|
||||
counter++;
|
||||
ea.selectElementsInView(ids);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (IMAGE_TYPES.contains(f.extension) || f.extension === "md") {
|
||||
ids.push(
|
||||
await ea.addImage(
|
||||
@@ -403,6 +460,19 @@ export class DropManager {
|
||||
const { x, y } = this.currentPosition;
|
||||
const pos = { x: x + i * 300, y: y + i * 300 };
|
||||
if (link.isInternal) {
|
||||
if (
|
||||
files.length === 1 &&
|
||||
link.file.extension.toLowerCase() === "md"
|
||||
) {
|
||||
this.openDroppedMarkdownFile(
|
||||
link.file,
|
||||
pos,
|
||||
localFileDragAction === "embeddable"
|
||||
? "embeddable"
|
||||
: "image",
|
||||
);
|
||||
continue;
|
||||
}
|
||||
if (localFileDragAction === "embeddable") {
|
||||
const ea = getEA(this.view);
|
||||
void insertEmbeddableToView(ea, pos, link.file).then(() =>
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
ButtonComponent,
|
||||
MarkdownView,
|
||||
Notice,
|
||||
resolveSubpath,
|
||||
Setting,
|
||||
type App,
|
||||
type ColorComponent,
|
||||
@@ -35,12 +36,12 @@ import {
|
||||
} from "src/utils/customEmbeddableUtils";
|
||||
import { setStyle } from "src/utils/styleUtils";
|
||||
import { EmbeddedFile } from "src/shared/EmbeddedFileLoader";
|
||||
import { ScriptEngine } from "src/shared/Scripts";
|
||||
import {
|
||||
createOrOverwriteFile,
|
||||
getNewUniqueFilepath,
|
||||
splitFolderAndFilename,
|
||||
} from "src/utils/fileUtils";
|
||||
import { getAttachmentsFolderAndFilePath } from "src/utils/pathUtils";
|
||||
import { t } from "src/lang/helpers";
|
||||
import { showColorPicker } from "src/shared/Dialogs/ColorPicker";
|
||||
import { getBinaryFileFromDataURL } from "src/utils/utils";
|
||||
@@ -67,6 +68,7 @@ import {
|
||||
BLOCK_REFERENCE_ICON_ID,
|
||||
BLOCK_REFERENCE_ICON_REGISTRY_SVG,
|
||||
} from "src/constants/blockReferenceIcon";
|
||||
import { FileAndFolderSelectorModal } from "src/shared/Dialogs/FileAndFolderSelectorModal";
|
||||
|
||||
let blockReferenceIconRegistered = false;
|
||||
|
||||
@@ -359,6 +361,27 @@ class MarkdownImageEditorController {
|
||||
});
|
||||
});
|
||||
|
||||
new Setting(appearance)
|
||||
.setClass("excalidraw-markdown-image-editor__setting--wide")
|
||||
.setName(t("MARKDOWN_IMAGE_BOTTOM_PADDING"))
|
||||
.setDesc(t("MARKDOWN_IMAGE_BOTTOM_PADDING_DESC"))
|
||||
.addSlider((slider) =>
|
||||
slider
|
||||
.setLimits(0, 100, 1)
|
||||
.setValue(this.renderSettings.paddingBottom)
|
||||
.setDynamicTooltip()
|
||||
.onChange((paddingBottom) => {
|
||||
if (!this.renderSettings) {
|
||||
return;
|
||||
}
|
||||
this.renderSettings = {
|
||||
...this.renderSettings,
|
||||
paddingBottom,
|
||||
};
|
||||
this.scheduleRender();
|
||||
}),
|
||||
);
|
||||
|
||||
this.renderAppearanceControls(appearance, {
|
||||
scope: "image",
|
||||
cssName: t("MARKDOWN_IMAGE_CSS"),
|
||||
@@ -1264,26 +1287,36 @@ class MarkdownImageEditorController {
|
||||
if (!this.ensureOwnerValid() || !source || source.source !== "local") {
|
||||
return;
|
||||
}
|
||||
let path = await ScriptEngine.inputPrompt(
|
||||
this.view,
|
||||
this.view.plugin,
|
||||
this.view.app,
|
||||
t("MARKDOWN_IMAGE_EXTRACT_TITLE"),
|
||||
t("MARKDOWN_IMAGE_EXTRACT_PATH"),
|
||||
const attachmentLocation = await getAttachmentsFolderAndFilePath(
|
||||
this.app,
|
||||
this.view.file.path,
|
||||
t("MARKDOWN_IMAGE_DEFAULT_NOTE"),
|
||||
);
|
||||
if (!path || !this.ensureOwnerValid()) {
|
||||
if (!this.ensureOwnerValid()) {
|
||||
return;
|
||||
}
|
||||
if (!path.toLowerCase().endsWith(".md")) {
|
||||
path += ".md";
|
||||
const defaultLocation = splitFolderAndFilename(
|
||||
attachmentLocation.filepath,
|
||||
);
|
||||
const location = await new FileAndFolderSelectorModal(this.app, {
|
||||
title: t("MARKDOWN_IMAGE_EXTRACT_TITLE"),
|
||||
folderLabel: t("FILE_AND_FOLDER_SELECTOR_FOLDER"),
|
||||
fileNameLabel: t("FILE_AND_FOLDER_SELECTOR_FILENAME"),
|
||||
submitButtonText: t("MARKDOWN_IMAGE_EXTRACT"),
|
||||
folderPath: defaultLocation.folderpath,
|
||||
fileName: defaultLocation.filename,
|
||||
}).start();
|
||||
if (!location || !this.ensureOwnerValid()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const { folderpath, filename } = splitFolderAndFilename(path);
|
||||
path = getNewUniqueFilepath(
|
||||
const filename = location.fileName.toLowerCase().endsWith(".md")
|
||||
? location.fileName
|
||||
: `${location.fileName}.md`;
|
||||
const path = getNewUniqueFilepath(
|
||||
this.view.app.vault,
|
||||
filename,
|
||||
folderpath,
|
||||
location.folderPath,
|
||||
);
|
||||
const file = await createOrOverwriteFile(
|
||||
this.view.app,
|
||||
@@ -1422,6 +1455,9 @@ class MarkdownImageEditorController {
|
||||
host.setText(t("MARKDOWN_IMAGE_SOURCE_UNAVAILABLE"));
|
||||
return;
|
||||
}
|
||||
const ownerView = this.view;
|
||||
const ownerFile = this.ownerFile;
|
||||
const elementFileId = element.fileId;
|
||||
const { leaf, rootSplit } = createLeaf(this.view, host.ownerDocument);
|
||||
this.editorLeaf = leaf;
|
||||
this.editorRoot = rootSplit;
|
||||
@@ -1447,13 +1483,9 @@ class MarkdownImageEditorController {
|
||||
{ history: false },
|
||||
);
|
||||
await leaf.loadIfDeferred();
|
||||
if (ref) {
|
||||
leaf.setEphemeralState({ subpath: ref });
|
||||
}
|
||||
} else {
|
||||
await leaf.openFile(sourceFile, {
|
||||
active: false,
|
||||
...(ref ? { eState: { subpath: ref } } : {}),
|
||||
});
|
||||
}
|
||||
if (
|
||||
@@ -1468,6 +1500,7 @@ class MarkdownImageEditorController {
|
||||
if (leaf.view instanceof MarkdownView) {
|
||||
this.editorView = leaf.view;
|
||||
this.prepareEditorView(host, leaf.view);
|
||||
this.revealExternalSourceSubpath(leaf.view, sourceFile, ref);
|
||||
this.watchEditorChanges();
|
||||
}
|
||||
return;
|
||||
@@ -1476,18 +1509,23 @@ class MarkdownImageEditorController {
|
||||
const fragmentView = new MarkdownFragmentView(
|
||||
leaf,
|
||||
async (markdown) => {
|
||||
if (!this.element) {
|
||||
return;
|
||||
}
|
||||
if (containsReservedMarkdownImageMarker(markdown)) {
|
||||
new Notice(t("MARKDOWN_IMAGE_RESERVED_MARKER"));
|
||||
return;
|
||||
}
|
||||
this.view.excalidrawData.setMarkdownImage(this.element.fileId, {
|
||||
const excalidrawData = ownerView.excalidrawData;
|
||||
if (
|
||||
!excalidrawData ||
|
||||
excalidrawData.file !== ownerFile ||
|
||||
ownerView.file !== ownerFile
|
||||
) {
|
||||
return;
|
||||
}
|
||||
excalidrawData.setMarkdownImage(elementFileId, {
|
||||
markdown,
|
||||
});
|
||||
this.view.setDirty();
|
||||
this.view.setMarkdownImageEditorIsEditing();
|
||||
ownerView.setDirty();
|
||||
ownerView.setMarkdownImageEditorIsEditing();
|
||||
},
|
||||
);
|
||||
await leaf.open(fragmentView);
|
||||
@@ -1506,6 +1544,29 @@ class MarkdownImageEditorController {
|
||||
this.watchEditorChanges();
|
||||
}
|
||||
|
||||
private revealExternalSourceSubpath(
|
||||
editorView: MarkdownView,
|
||||
sourceFile: TFile,
|
||||
subpath: string,
|
||||
): void {
|
||||
if (!subpath) {
|
||||
return;
|
||||
}
|
||||
const cache = this.app.metadataCache.getFileCache(sourceFile);
|
||||
const location = cache ? resolveSubpath(cache, subpath) : null;
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
const position = {
|
||||
line: location.start.line,
|
||||
ch: location.start.col,
|
||||
};
|
||||
// A collapsed cursor reveals the referenced content without leaving the
|
||||
// detached MarkdownView in Obsidian's persistent subpath-selection state.
|
||||
editorView.editor.setCursor(position);
|
||||
editorView.editor.scrollIntoView({ from: position, to: position }, true);
|
||||
}
|
||||
|
||||
private prepareEditorView(host: HTMLElement, editorView: MarkdownView): void {
|
||||
if (!this.ensureOwnerValid()) {
|
||||
return;
|
||||
@@ -1751,11 +1812,24 @@ class MarkdownImageEditorController {
|
||||
if (!source || this.closed || !this.ensureOwnerValid()) {
|
||||
return;
|
||||
}
|
||||
let renderMarkdown = markdown;
|
||||
if (source.source === "external") {
|
||||
await editorView.save();
|
||||
if (!this.ensureOwnerValid()) {
|
||||
return;
|
||||
}
|
||||
const refreshedSource = await getMarkdownImageSource(
|
||||
this.view,
|
||||
element,
|
||||
);
|
||||
if (
|
||||
!refreshedSource ||
|
||||
refreshedSource.source !== "external" ||
|
||||
!this.ensureOwnerValid()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
renderMarkdown = refreshedSource.markdown;
|
||||
} else {
|
||||
this.view.excalidrawData.setMarkdownImage(element.fileId, {
|
||||
markdown,
|
||||
@@ -1765,7 +1839,7 @@ class MarkdownImageEditorController {
|
||||
const updated = await updateMarkdownImage(
|
||||
this.view,
|
||||
element,
|
||||
markdown,
|
||||
renderMarkdown,
|
||||
renderSettings,
|
||||
source.source,
|
||||
);
|
||||
@@ -1940,10 +2014,13 @@ class MarkdownImageEditorController {
|
||||
this.app.workspace.offref(this.editorChangeRef);
|
||||
this.editorChangeRef = null;
|
||||
}
|
||||
if (editorView && saveEditor) {
|
||||
await editorView.save();
|
||||
try {
|
||||
if (editorView && saveEditor) {
|
||||
await editorView.save();
|
||||
}
|
||||
} finally {
|
||||
editorLeaf?.detach();
|
||||
}
|
||||
editorLeaf?.detach();
|
||||
}
|
||||
|
||||
private close(): void {
|
||||
|
||||
+77
-57
@@ -366,21 +366,40 @@ textarea.excalidraw-wysiwyg {
|
||||
min-width: 10em;
|
||||
}
|
||||
|
||||
.excalidraw-folder-path-control {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.excalidraw-folder-create-row {
|
||||
display: flex;
|
||||
flex: 0 0 100%;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.excalidraw-folder-create-row > button:not(.excalidraw-display-none) {
|
||||
margin-top: var(--size-2-2);
|
||||
}
|
||||
|
||||
.excalidraw-folder-path-control {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.excalidraw-file-and-folder-selector__field {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.excalidraw-file-and-folder-selector__field>.setting-item-control {
|
||||
flex: 1 1 18rem;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.excalidraw-file-and-folder-selector__field input[type="text"] {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.is-mobile .excalidraw-file-and-folder-selector .setting-item-control {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.excalidraw-folder-create-row {
|
||||
display: flex;
|
||||
flex: 0 0 100%;
|
||||
justify-content: flex-end;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.excalidraw-folder-create-row>button:not(.excalidraw-display-none) {
|
||||
margin-top: var(--size-2-2);
|
||||
}
|
||||
|
||||
.excalidraw-ai-provider-table {
|
||||
margin: auto;
|
||||
width: 80%;
|
||||
@@ -1352,9 +1371,9 @@ End Obsidian Sheets Plus support
|
||||
flex: 1 1 64px;
|
||||
}
|
||||
|
||||
.excalidraw-markdown-image-editor__source .setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__appearance .setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__appearance .setting-item-control .excalidraw-font-picker {
|
||||
.excalidraw-markdown-image-editor__source .setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__appearance .setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__appearance .setting-item-control .excalidraw-font-picker {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
@@ -1395,8 +1414,8 @@ End Obsidian Sheets Plus support
|
||||
flex: 0 0 var(--input-height, 32px);
|
||||
}
|
||||
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control .excalidraw-font-picker {
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control .excalidraw-font-picker {
|
||||
width: min(240px, 100%);
|
||||
}
|
||||
|
||||
@@ -1447,8 +1466,8 @@ End Obsidian Sheets Plus support
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control .excalidraw-font-picker {
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control select,
|
||||
.excalidraw-markdown-image-editor__setting--font>.setting-item-control .excalidraw-font-picker {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@@ -1576,44 +1595,45 @@ End Obsidian Sheets Plus support
|
||||
flex: 0 0 var(--input-height, 32px);
|
||||
}
|
||||
|
||||
.excalidraw-markdown-image-editor__placeholder {
|
||||
.excalidraw-markdown-image-editor__placeholder {
|
||||
margin: auto;
|
||||
max-width: 28em;
|
||||
padding: 32px 20px;
|
||||
border: 1px dashed var(--background-modifier-border);
|
||||
border-radius: var(--radius-m);
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button.excalidraw-font-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: min(240px, 100%);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.excalidraw-font-picker__label {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.excalidraw-font-picker__option {
|
||||
display: block;
|
||||
min-width: min(12rem, calc(100vw - 4rem));
|
||||
max-width: calc(100vw - 4rem);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: var(--font-ui-medium);
|
||||
}
|
||||
|
||||
.menu:has(.excalidraw-font-picker__option--desktop) {
|
||||
max-height: min(420px, 60vh);
|
||||
overflow-y: auto;
|
||||
}
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button.excalidraw-font-picker {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: min(240px, 100%);
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
text-align: start;
|
||||
}
|
||||
|
||||
.excalidraw-font-picker__label {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.excalidraw-font-picker__option {
|
||||
display: block;
|
||||
min-width: min(12rem, calc(100vw - 4rem));
|
||||
max-width: calc(100vw - 4rem);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: var(--font-ui-medium);
|
||||
}
|
||||
|
||||
.excalidraw-font-picker-menu-opening .menu,
|
||||
.menu.excalidraw-font-picker-menu--desktop {
|
||||
max-height: min(420px, 60vh);
|
||||
overflow-y: auto;
|
||||
}
|
||||
Reference in new issue
Block a user