diff --git a/ea-scripts/Convert text to link with folder and alias.md b/ea-scripts/Convert text to link with folder and alias.md index 401a947..067e1a3 100644 --- a/ea-scripts/Convert text to link with folder and alias.md +++ b/ea-scripts/Convert text to link with folder and alias.md @@ -18,12 +18,15 @@ app.vault.getFiles().forEach((f)=> f = Array.from(folders); folder = await utils.suggester(f,f); +folder = folder??""; //if exiting suggester with ESC folder = folder === "" ? folder : folder + "/"; elements = ea.getViewSelectedElements().filter((el)=>el.type==="text"); elements.forEach((el)=>{ el.rawText = "[["+folder+el.rawText+"|"+el.rawText+"]]"; + el.text = "[["+folder+el.text+"|"+el.text+"]]"; + el.originalText = "[["+folder+el.originalText+"|"+el.originalText+"]]"; }) ea.copyViewElementsToEAforEditing(elements); ea.addElementsToView(); \ No newline at end of file diff --git a/src/ExcalidrawAutomate.ts b/src/ExcalidrawAutomate.ts index 704807d..a823f56 100644 --- a/src/ExcalidrawAutomate.ts +++ b/src/ExcalidrawAutomate.ts @@ -211,7 +211,7 @@ export interface ExcalidrawAutomate { b: readonly [number, number], gap?: number, //if given, element is inflated by this value ): Point[]; - + //See OCR plugin for example on how to use scriptSettings activeScript: string; //Set automatically by the ScriptEngine getScriptSettings(): {}; //Returns script settings. Saves settings in plugin settings, under the activeScript key @@ -1182,7 +1182,7 @@ export async function initExcalidrawAutomate( return false; } const elements = this.getElements(); - return await this.targetView.addElements( + return await this.targetView.addElements( elements, repositionToCursor, save, diff --git a/src/ExcalidrawView.ts b/src/ExcalidrawView.ts index 12f15f5..537d0fd 100644 --- a/src/ExcalidrawView.ts +++ b/src/ExcalidrawView.ts @@ -345,7 +345,7 @@ export default class ExcalidrawView extends TextFileView { return; } this.contentEl.requestFullscreen(); //{navigationUI: "hide"}); - this.excalidrawWrapperRef.current.focus(); + this.excalidrawWrapperRef.current.firstElementChild?.focus(); this.contentEl.setAttribute("style", "padding:0px;margin:0px;"); this.fullscreenModalObserver = new MutationObserver((m) => { @@ -837,7 +837,8 @@ export default class ExcalidrawView extends TextFileView { this.app.workspace.activeLeaf === this.leaf && this.excalidrawWrapperRef ) { - this.excalidrawWrapperRef.current.focus(); + //.firstElmentChild solves this issue: https://github.com/zsviczian/obsidian-excalidraw-plugin/pull/346 + this.excalidrawWrapperRef.current?.firstElementChild?.focus(); } //debug({where:"ExcalidrawView.loadDrawing",file:this.file.name,before:"this.loadSceneFiles"}); this.loadSceneFiles(); @@ -1326,7 +1327,7 @@ export default class ExcalidrawView extends TextFileView { this.excalidrawAPI.addFiles(files); } if (save) { - this.save(false); + await this.save(false); //preventReload=false will ensure that markdown links are paresed and displayed correctly } else { this.dirty = this.file?.path; } @@ -2003,7 +2004,7 @@ export default class ExcalidrawView extends TextFileView { return React.createElement(React.Fragment, null, excalidrawDiv); }); ReactDOM.render(reactElement, this.contentEl, () => { - this.excalidrawWrapperRef.current.focus(); + this.excalidrawWrapperRef.current.firstElementChild?.focus(); this.addFullscreenchangeEvent(); }); }