mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
shouldRestoreElements
This commit is contained in:
@@ -1626,6 +1626,7 @@ export class ExcalidrawAutomate implements ExcalidrawAutomateInterface {
|
||||
repositionToCursor: boolean = false,
|
||||
save: boolean = true,
|
||||
newElementsOnTop: boolean = false,
|
||||
shouldRestoreElements: boolean = false, //restore elements - auto corrects broken, incomplete or old elements included in the update
|
||||
): Promise<boolean> {
|
||||
//@ts-ignore
|
||||
if (!this.targetView || !this.targetView?._loaded) {
|
||||
@@ -1639,6 +1640,7 @@ export class ExcalidrawAutomate implements ExcalidrawAutomateInterface {
|
||||
save,
|
||||
this.imagesDict,
|
||||
newElementsOnTop,
|
||||
shouldRestoreElements,
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -2610,6 +2610,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
save: boolean = false,
|
||||
images: any,
|
||||
newElementsOnTop: boolean = false,
|
||||
shouldRestoreElements: boolean = false,
|
||||
): Promise<boolean> => {
|
||||
const api = this.excalidrawAPI as ExcalidrawImperativeAPI;
|
||||
if (!excalidrawRef?.current || !api) {
|
||||
@@ -2668,7 +2669,7 @@ export default class ExcalidrawView extends TextFileView {
|
||||
elements,
|
||||
commitToHistory: true,
|
||||
},
|
||||
true, //set to true because svtToExcalidraw generates a legacy Excalidraw object
|
||||
shouldRestoreElements,
|
||||
);
|
||||
|
||||
if (images && Object.keys(images).length >0) {
|
||||
|
||||
@@ -44,7 +44,7 @@ export class ImportSVGDialog extends FuzzySuggestModal<TFile> {
|
||||
const svg = await app.vault.read(item);
|
||||
if(!svg || svg === "") return;
|
||||
ea.importSVG(svg);
|
||||
ea.addElementsToView(true, true, true);
|
||||
ea.addElementsToView(true, true, true,true);
|
||||
}
|
||||
|
||||
public start(view: ExcalidrawView) {
|
||||
|
||||
@@ -356,7 +356,7 @@ export const EXCALIDRAW_AUTOMATE_INFO: SuggesterInfo[] = [
|
||||
},
|
||||
{
|
||||
field: "addElementsToView",
|
||||
code: "addElementsToView(repositionToCursor?: boolean, save?: boolean, newElementsOnTop?: boolean,): Promise<boolean>;",
|
||||
code: "addElementsToView(repositionToCursor?: boolean, save?: boolean, newElementsOnTop?: boolean,shouldRestoreElements?: boolean,): Promise<boolean>;",
|
||||
desc: "Adds elements from elementsDict to the current view\nrepositionToCursor: default is false\nsave: default is true\nnewElementsOnTop: default is false, i.e. the new elements get to the bottom of the stack\nnewElementsOnTop controls whether elements created with ExcalidrawAutomate are added at the bottom of the stack or the top of the stack of elements already in the view\nNote that elements copied to the view with copyViewElementsToEAforEditing retain their position in the stack of elements in the view even if modified using EA",
|
||||
after: "",
|
||||
},
|
||||
|
||||
1
src/types.d.ts
vendored
1
src/types.d.ts
vendored
@@ -203,6 +203,7 @@ export interface ExcalidrawAutomateInterface {
|
||||
//Note that elements copied to the view with copyViewElementsToEAforEditing retain their
|
||||
//position in the stack of elements in the view even if modified using EA
|
||||
newElementsOnTop?: boolean, //default is false, i.e. the new elements get to the bottom of the stack
|
||||
shouldRestoreElements?: boolean, //restore elements - auto corrects broken, incomplete or old elements included in the update
|
||||
): Promise<boolean>;
|
||||
//Register instance of EA to use for hooks with TargetView
|
||||
//By default ExcalidrawViews will check window.ExcalidrawAutomate for event hooks.
|
||||
|
||||
Reference in New Issue
Block a user