mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2026-11-27 06:32:42 +00:00
2.15.3
This commit is contained in:
1 parent
9221b8c475
commit
b976a5d5e6
11 files changed
+79
-32
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.15.3",
|
||||
"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
-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",
|
||||
|
||||
@@ -21,9 +21,12 @@ I build this plugin in my free time, as a labor of love. Curious about the philo
|
||||
## 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