mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-12-03 06:43:35 +00:00
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c5ca730946 | ||
|
|
537b01f461 | ||
|
|
428f2c50b6 | ||
|
|
b976a5d5e6 | ||
|
|
9221b8c475 | ||
|
|
6d659042ec |
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"id": "obsidian-excalidraw-plugin",
|
||||
"name": "Excalidraw",
|
||||
"version": "2.15.3-beta-2",
|
||||
"version": "2.16.0-beta-1",
|
||||
"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.2",
|
||||
"version": "2.15.3",
|
||||
"minAppVersion": "1.5.7",
|
||||
"description": "An Obsidian plugin to edit and view Excalidraw drawings",
|
||||
"author": "Zsolt Viczian",
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"@zsviczian/excalidraw": "0.18.0-37",
|
||||
"@zsviczian/excalidraw": "0.18.0-39",
|
||||
"chroma-js": "^3.1.2",
|
||||
"clsx": "^2.0.0",
|
||||
"@zsviczian/colormaster": "^1.2.2",
|
||||
|
||||
+1
-16
@@ -90,7 +90,6 @@ 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;
|
||||
@@ -424,21 +423,7 @@ export default class ExcalidrawPlugin extends Plugin {
|
||||
this.logStartupEvent("Switched to Excalidraw views");
|
||||
|
||||
try {
|
||||
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) {
|
||||
if (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;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ export default {
|
||||
TRANSCLUDE_MOST_RECENT: "Embed the most recently edited drawing",
|
||||
TOGGLE_LEFTHANDED_MODE: "Toggle left-handed mode",
|
||||
TOGGLE_SPLASHSCREEN: "Show splash screen in new drawings",
|
||||
FLIP_IMAGE: "Open the back-of-the-note for the selected image in a popout window",
|
||||
FLIP_IMAGE: "Open the back-of-the-note for the selected image in a popout window (flip the card)",
|
||||
NEW_IN_NEW_PANE: "Create new drawing - IN AN ADJACENT WINDOW",
|
||||
NEW_IN_NEW_TAB: "Create new drawing - IN A NEW TAB",
|
||||
NEW_IN_ACTIVE_PANE: "Create new drawing - IN THE CURRENT ACTIVE WINDOW",
|
||||
|
||||
@@ -234,6 +234,8 @@ export default {
|
||||
RELEASE_NOTES_DESC:
|
||||
"<b>开启:</b>每次更新本插件后,显示最新发行版本的说明。<br>" +
|
||||
"<b>关闭:</b>您仍可以在 <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases'>GitHub</a> 上阅读更新说明。",
|
||||
WARN_ON_MANIFEST_MISMATCH_NAME: "警告插件更新不完整",
|
||||
WARN_ON_MANIFEST_MISMATCH_DESC: "检查已安装的 Excalidraw 可执行文件是否与 Obsidian 插件列表中显示的版本一致。如果不一致(通常源于同步不完整),你会看到警告并可以选择更新。关闭该项可禁用检查。",
|
||||
NEWVERSION_NOTIFICATION_NAME: "插件更新通知",
|
||||
NEWVERSION_NOTIFICATION_DESC:
|
||||
"<b>开启:</b>当本插件存在可用更新时,显示通知。<br>" +
|
||||
@@ -1210,4 +1212,16 @@ export default {
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "保存当前进度",
|
||||
CAPTURE_PAGE: "以图像形式截取当前页面",
|
||||
|
||||
//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: `Obsidian 显示的版本是 <b>{VAL_RECORDED}</b>,但已安装的 Excalidraw 代码显示的版本是 <b>{VAL_ACTUAL}</b>。`,
|
||||
VERSION_MISMATCH_HEADING: "Excalidraw 版本不匹配",
|
||||
VERSION_MISMATCH_CAUSE: "通常源于同步不完整,大文件未能同步(如使用 Obsidian Sync Standard,main.js > 5MB),只更新了 <code>manifest.json</code>。",
|
||||
VERSION_MISMATCH_OPTIONS: "选项:<br><b>1.</b> 重新下载插件(推荐)。<br><b>2.</b> 暂时忽略。",
|
||||
VERSION_MISMATCH_NOTE: "注意:手动更新版本信息可能会影响依赖 manifest.json 的工具(如 Plugin Update Tracker、BRAT),直到你完全重装插件。",
|
||||
VERSION_MISMATCH_DISABLE_NAME: "禁用版本不匹配警告",
|
||||
VERSION_MISMATCH_DISABLE_DESC: "可在以下位置重新启用:设置 → Excalidraw → 基本 → 警告插件更新不完整",
|
||||
VERSION_MISMATCH_REDOWNLOAD: "重新下载插件",
|
||||
VERSION_MISMATCH_IGNORE: "忽略",
|
||||
};
|
||||
@@ -234,6 +234,8 @@ export default {
|
||||
RELEASE_NOTES_DESC:
|
||||
"<b>開啟:</b>每次更新本外掛後,顯示最新發行版本的說明。<br>" +
|
||||
"<b>關閉:</b>您仍可以在 <a href='https://github.com/zsviczian/obsidian-excalidraw-plugin/releases'>GitHub</a> 上閱讀更新說明。",
|
||||
WARN_ON_MANIFEST_MISMATCH_NAME: "警告外掛更新不完整",
|
||||
WARN_ON_MANIFEST_MISMATCH_DESC: "檢查已安裝的 Excalidraw 可執行檔案是否與 Obsidian 外掛列表中顯示的版本一致。如果不一致(通常源於同步不完整),你會看到警告並可以選擇更新。關閉該項可停用檢查。",
|
||||
NEWVERSION_NOTIFICATION_NAME: "外掛更新通知",
|
||||
NEWVERSION_NOTIFICATION_DESC:
|
||||
"<b>開啟:</b>當本外掛存在可用更新時,顯示通知。<br>" +
|
||||
@@ -1210,4 +1212,16 @@ export default {
|
||||
//EmbeddableActionsMenu.tsx
|
||||
BOOKMARK_PAGE: "儲存當前進度",
|
||||
CAPTURE_PAGE: "以影像形式擷取當前頁面",
|
||||
|
||||
//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: `Obsidian 顯示的版本是 <b>{VAL_RECORDED}</b>,但已安裝的 Excalidraw 程式碼顯示的版本是 <b>{VAL_ACTUAL}</b>。`,
|
||||
VERSION_MISMATCH_HEADING: "Excalidraw 版本不匹配",
|
||||
VERSION_MISMATCH_CAUSE: "通常源於同步不完整,大檔案未能同步(如使用 Obsidian Sync Standard,main.js > 5MB),只更新了 <code>manifest.json</code>。",
|
||||
VERSION_MISMATCH_OPTIONS: "選項:<br><b>1.</b> 重新下載外掛(推薦)。<br><b>2.</b> 暫時忽略。",
|
||||
VERSION_MISMATCH_NOTE: "注意:手動更新版本資訊可能會影響依賴 manifest.json 的工具(如 Plugin Update Tracker、BRAT),直到你完全重灌外掛。",
|
||||
VERSION_MISMATCH_DISABLE_NAME: "停用版本不匹配警告",
|
||||
VERSION_MISMATCH_DISABLE_DESC: "可在以下位置重新啟用:設定 → Excalidraw → 基本 → 警告外掛更新不完整",
|
||||
VERSION_MISMATCH_REDOWNLOAD: "重新下載外掛",
|
||||
VERSION_MISMATCH_IGNORE: "忽略",
|
||||
};
|
||||
@@ -17,13 +17,21 @@ 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.16.0":`
|
||||
# New from Excalidraw.com
|
||||
- New library search feature [#9903](https://github.com/excalidraw/excalidraw/pull/9903)
|
||||
- You can rename library items by selecting them, then choosing "Rename or publish" from the ... menu.
|
||||
`,
|
||||
"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)
|
||||
- On Obsidian Mobile, when an element has multiple links, clicking the link icon, the link selector pops up and immediately closes
|
||||
- Improved handling of importing external images and drag and drop of images from inside Obsidian. Features like (Convert SVG to Strokes) and (Flip the card) now work immediately, you don't need to force save, or wait for autosave to kick in.
|
||||
|
||||
## 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.
|
||||
- When Excalidraw is open in two or more tabs—either as Markdown or Excalidraw—auto-zoom is disabled. This allows you to work in multiple tabs on the same drawing at once: focusing on different areas of the same drawing, or editing the Markdown and Excalidraw views in parallel.
|
||||
`,
|
||||
"2.15.2":`
|
||||
## Fixed:
|
||||
|
||||
@@ -1011,6 +1011,7 @@ export async function linkPrompt(
|
||||
...tagsArray,
|
||||
];
|
||||
|
||||
await sleep(10); //obsidian modal link click immediately refocuses the editor, so we need to wait a bit
|
||||
if (items.length>1) {
|
||||
parts = await ScriptEngine.suggester(
|
||||
app,
|
||||
|
||||
@@ -40,6 +40,16 @@ export async function insertImageToView(
|
||||
return id;
|
||||
}
|
||||
|
||||
export function deleteAppStateKeys(
|
||||
st: AppState,
|
||||
[...keys]: (keyof AppState)[],
|
||||
): Partial<AppState> {
|
||||
keys.forEach((key) => {
|
||||
delete (st as Mutable<AppState>)[key];
|
||||
});
|
||||
return st;
|
||||
};
|
||||
|
||||
export async function insertEmbeddableToView (
|
||||
ea: ExcalidrawAutomate,
|
||||
position: { x: number, y: number },
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
Editor,
|
||||
FrontMatterCache,
|
||||
MarkdownView,
|
||||
OpenViewState, parseFrontMatterEntry, TFile, View, ViewState, Workspace, WorkspaceLeaf, WorkspaceSplit
|
||||
OpenViewState, parseFrontMatterEntry, TextFileView, TFile, View, ViewState, Workspace, WorkspaceLeaf, WorkspaceSplit
|
||||
} from "obsidian";
|
||||
import ExcalidrawPlugin from "../core/main";
|
||||
import { splitFolderAndFilename } from "./fileUtils";
|
||||
@@ -30,6 +30,14 @@ export function getExcalidrawViews(app: App): ExcalidrawView[] {
|
||||
return leaves.map(l=>l.view as ExcalidrawView);
|
||||
}
|
||||
|
||||
export function getExcalidraAndMarkdowViewsForFile(app: App, file: TFile): TextFileView[] {
|
||||
const leaves = [
|
||||
...app.workspace.getLeavesOfType(VIEW_TYPE_EXCALIDRAW).filter(l=>l.view instanceof ExcalidrawView),
|
||||
...app.workspace.getLeavesOfType("markdown").filter(l=>l.view instanceof MarkdownView)
|
||||
];
|
||||
return leaves.map(l=>l.view as TextFileView).filter(v=>v.file === file);
|
||||
}
|
||||
|
||||
export const getLeaf = (
|
||||
plugin: ExcalidrawPlugin,
|
||||
origo: WorkspaceLeaf,
|
||||
|
||||
+16
-1
@@ -33,8 +33,8 @@ import { runCompressionWorker } from "src/shared/Workers/compression-worker";
|
||||
import Pool from "es6-promise-pool";
|
||||
import { FileData } from "../shared/EmbeddedFileLoader";
|
||||
import { t } from "src/lang/helpers";
|
||||
import ExcalidrawScene from "src/shared/svgToExcalidraw/elements/ExcalidrawScene";
|
||||
import { log } from "./debugHelper";
|
||||
import { VersionMismatchPrompt } from "src/shared/Dialogs/VersionMismatch";
|
||||
|
||||
declare const PLUGIN_VERSION:string;
|
||||
declare var LZString: any;
|
||||
@@ -51,6 +51,21 @@ declare module "obsidian" {
|
||||
}
|
||||
}
|
||||
|
||||
let versionMismatchChecked = false;
|
||||
export async function checkVersionMismatch(plugin: ExcalidrawPlugin) {
|
||||
if (!versionMismatchChecked && plugin.manifest.version !== PLUGIN_VERSION) {
|
||||
versionMismatchChecked = true;
|
||||
const versionMismatchPrompt = new VersionMismatchPrompt(plugin);
|
||||
const result = await versionMismatchPrompt.start();
|
||||
if(result) {
|
||||
plugin.manifest.version = PLUGIN_VERSION;
|
||||
await plugin.app.setting.open();
|
||||
plugin.app.setting.openTabById("community-plugins");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
export let versionUpdateCheckTimer: number = null;
|
||||
let versionUpdateChecked = false;
|
||||
export async function checkExcalidrawVersion() {
|
||||
|
||||
+35
-11
@@ -38,7 +38,6 @@ import {
|
||||
DISK_ICON_NAME,
|
||||
SCRIPTENGINE_ICON_NAME,
|
||||
TEXT_DISPLAY_RAW_ICON_NAME,
|
||||
TEXT_DISPLAY_PARSED_ICON_NAME,
|
||||
IMAGE_TYPES,
|
||||
KEYCODE,
|
||||
FRONTMATTER_KEYS,
|
||||
@@ -110,8 +109,9 @@ import {
|
||||
addAppendUpdateCustomData,
|
||||
getFilePathFromObsidianURL,
|
||||
getLinkParts,
|
||||
checkVersionMismatch,
|
||||
} from "../utils/utils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getActivePDFPageNumberFromPDFView, getAttachmentsFolderAndFilePath, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { cleanBlockRef, cleanSectionHeading, closeLeafView, getAttachmentsFolderAndFilePath, getExcalidraAndMarkdowViewsForFile, getLeaf, getParentOfClass, obsidianPDFQuoteWithRef, openLeaf, setExcalidrawView } from "../utils/obsidianUtils";
|
||||
import { splitFolderAndFilename } from "../utils/fileUtils";
|
||||
import { GenericInputPrompt, MultiOptionConfirmationPrompt, NewFileActions, Prompt, linkPrompt } from "../shared/Dialogs/Prompt";
|
||||
import { ClipboardData } from "@zsviczian/excalidraw/types/excalidraw/clipboard";
|
||||
@@ -130,10 +130,10 @@ import { getTextElementAtPointer, getImageElementAtPointer, getElementWithLinkAt
|
||||
import { excalidrawSword, ICONS, LogoWrapper, Rank, saveIcon, SwordColors } from "../constants/actionIcons";
|
||||
import { ExportDialog } from "../shared/Dialogs/ExportDialog";
|
||||
import { getEA } from "src/core"
|
||||
import { anyModifierKeysPressed, emulateKeysForLinkClick, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, localFileDragModifierType, ModifierKeys, modifierKeyTooltipMessages } from "../utils/modifierkeyHelper";
|
||||
import { anyModifierKeysPressed, emulateKeysForLinkClick, isWinALTorMacOPT, isWinCTRLorMacCMD, isWinMETAorMacCTRL, isSHIFT, linkClickModifierType, ModifierKeys } from "../utils/modifierkeyHelper";
|
||||
import { setDynamicStyle } from "../utils/dynamicStyling";
|
||||
import { CustomEmbeddable, renderWebView } from "./components/CustomEmbeddable";
|
||||
import { addBackOfTheNoteCard, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, onLoadMessages, openExternalLink, parseObsidianLink, renderContextMenuAction, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { addBackOfTheNoteCard, deleteAppStateKeys, getExcalidrawFileForwardLinks, getFrameBasedOnFrameNameOrId, getLinkTextFromLink, insertEmbeddableToView, insertImageToView, isTextImageTransclusion, onLoadMessages, openExternalLink, parseObsidianLink, renderContextMenuAction, tmpBruteForceCleanup, toggleImageAnchoring } from "../utils/excalidrawViewUtils";
|
||||
import { imageCache } from "../shared/ImageCache";
|
||||
import { CanvasNodeFactory, ObsidianCanvasNode } from "./managers/CanvasNodeFactory";
|
||||
import { EmbeddableMenu } from "./components/menu/EmbeddableActionsMenu";
|
||||
@@ -2165,7 +2165,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
await this.excalidrawData.setTextMode(this.textMode);
|
||||
}
|
||||
this.excalidrawData.scene.appState.theme = api.getAppState().theme;
|
||||
await this.loadDrawing(loadOnModifyTrigger);
|
||||
await this.loadDrawing(loadOnModifyTrigger, undefined, true);
|
||||
this.clearDirty();
|
||||
}
|
||||
|
||||
@@ -2356,6 +2356,7 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if(this.lastLoadedFile === this.file) return;
|
||||
this.isLoaded = false;
|
||||
if(!this.file) return;
|
||||
if(this.plugin.settings.compareManifestToPluginVersion) checkVersionMismatch(this.plugin);
|
||||
if(this.plugin.settings.showNewVersionNotification) checkExcalidrawVersion();
|
||||
if(isMaskFile(this.plugin,this.file)) {
|
||||
const notice = new Notice(t("MASK_FILE_NOTICE"), 5000);
|
||||
@@ -2778,9 +2779,10 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
*
|
||||
* @param justloaded - a flag to trigger zoom to fit after the drawing has been loaded
|
||||
*/
|
||||
public async loadDrawing(justloaded: boolean, deletedElements?: ExcalidrawElement[]) {
|
||||
public async loadDrawing(justloaded: boolean, deletedElements?: ExcalidrawElement[], isReloading: boolean = false) {
|
||||
(process.env.NODE_ENV === 'development') && DEBUGGING && debug(this.loadDrawing, "ExcalidrawView.loadDrawing", justloaded, deletedElements);
|
||||
const excalidrawData = this.excalidrawData.scene;
|
||||
const isOpenInMultipleLeaves = getExcalidraAndMarkdowViewsForFile(this.app,this.file).length > 1;
|
||||
this.semaphores.justLoaded = justloaded;
|
||||
this.clearDirty();
|
||||
const om = this.excalidrawData.getOpenMode();
|
||||
@@ -2798,7 +2800,6 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
//debug({where:"ExcalidrawView.loadDrawing",file:this.file.name,dataTheme:excalidrawData.appState.theme,before:"updateScene"})
|
||||
//api.setLocalFont(this.plugin.settings.experimentalEnableFourthFont);
|
||||
|
||||
|
||||
this.updateScene(
|
||||
{
|
||||
elements: excalidrawData.elements.concat(deletedElements??[]), //need to preserve deleted elements during autosave if images, links, etc. are updated
|
||||
@@ -2811,7 +2812,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
{
|
||||
//elements: excalidrawData.elements.concat(deletedElements??[]), //need to preserve deleted elements during autosave if images, links, etc. are updated
|
||||
appState: {
|
||||
...excalidrawData.appState,
|
||||
...isReloading && isOpenInMultipleLeaves
|
||||
? deleteAppStateKeys(excalidrawData.appState, ["scrollX","scrollY","zoom"])
|
||||
: excalidrawData.appState,
|
||||
...this.excalidrawData.selectedElementIds //https://github.com/zsviczian/obsidian-excalidraw-plugin/issues/609
|
||||
? this.excalidrawData.selectedElementIds
|
||||
: {},
|
||||
@@ -2846,7 +2849,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
this.instantiateExcalidraw({
|
||||
elements: excalidrawData.elements,
|
||||
appState: {
|
||||
...excalidrawData.appState,
|
||||
...isReloading && isOpenInMultipleLeaves
|
||||
? deleteAppStateKeys(excalidrawData.appState, ["scrollX","scrollY","zoom"])
|
||||
: excalidrawData.appState,
|
||||
...excalidrawData.appState.frameRendering && excalidrawData.appState.frameRendering.markerName === undefined
|
||||
? { frameRendering: {...excalidrawData.appState.frameRendering, markerName: true, markerEnabled: true } }
|
||||
: {},
|
||||
@@ -4047,7 +4052,23 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
}
|
||||
|
||||
private shouldSaveImportedImage: boolean = false;
|
||||
private onChange (et: ExcalidrawElement[], st: AppState) {
|
||||
if(st.activeTool?.type) {
|
||||
if(st.activeTool.type === "image") {
|
||||
if(st.selectedElementIds && Object.keys(st.selectedElementIds).length === 1) {
|
||||
const selectedElement = et.filter(el=>el.id === Object.keys(st.selectedElementIds)[0])[0];
|
||||
if(selectedElement && selectedElement.type === "image") {
|
||||
this.shouldSaveImportedImage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(st.activeTool.type === "selection" && this.shouldSaveImportedImage) {
|
||||
this.shouldSaveImportedImage = false;
|
||||
setTimeout(()=>this.save(true, true),100); //image is being added to the scene
|
||||
}
|
||||
}
|
||||
|
||||
if(st.newElement?.type === "freedraw") {
|
||||
this.freedrawLastActiveTimestamp = Date.now();
|
||||
}
|
||||
@@ -4064,7 +4085,9 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
if( elcount>0 && et.length===0 ) return;
|
||||
this.semaphores.justLoaded = false;
|
||||
if (!this.semaphores.preventAutozoom && this.plugin.settings.zoomToFitOnOpen) {
|
||||
this.zoomToFit(false,true);
|
||||
if(getExcalidraAndMarkdowViewsForFile(this.app, this.file).length === 1) {
|
||||
this.zoomToFit(false,true);
|
||||
}
|
||||
}
|
||||
this.previousSceneVersion = this.getSceneVersion(et);
|
||||
this.previousBackgroundColor = st.viewBackgroundColor;
|
||||
@@ -4237,7 +4260,8 @@ export default class ExcalidrawView extends TextFileView implements HoverParent{
|
||||
}
|
||||
}
|
||||
if (data.elements) {
|
||||
window.setTimeout(() => this.save(), 30); //removed prevent reload = false, as reload was triggered when pasted containers were processed and there was a conflict with the new elements
|
||||
const preventReload = !(data.elements.some((el) => el.type === "image") && !data.elements.some((el) => el.type !== "image"));
|
||||
window.setTimeout(() => this.save(preventReload), 30); //removed prevent reload = false, as reload was triggered when pasted containers were processed and there was a conflict with the new elements
|
||||
}
|
||||
|
||||
//process pasted text after it was processed into elements by Excalidraw
|
||||
|
||||
@@ -105,6 +105,7 @@ export class DropManager {
|
||||
files: TFile[],
|
||||
text: string,
|
||||
): boolean => {
|
||||
this.app.workspace.setActiveLeaf(this.view.leaf); //ensure the view is active, so ModalContainerObserver is active
|
||||
if (this.view.getHookServer().onDropHook) {
|
||||
try {
|
||||
return this.view.getHookServer().onDropHook({
|
||||
|
||||
Reference in new issue
Block a user