X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/cc10d1ddfc652f6bcf3bbf61d5ec2e2861394c03..refs/pull/5607/head:/resources/js/markdown/actions.js diff --git a/resources/js/markdown/actions.js b/resources/js/markdown/actions.js index 4909a59d0..e99bbf3e1 100644 --- a/resources/js/markdown/actions.js +++ b/resources/js/markdown/actions.js @@ -1,4 +1,4 @@ -import * as DrawIO from '../services/drawio'; +import * as DrawIO from '../services/drawio.ts'; export class Actions { @@ -73,7 +73,12 @@ export class Actions { const selectedText = selectionText || entity.name; const newText = `[${selectedText}](${entity.link})`; this.#replaceSelection(newText, newText.length, selectionRange); - }, selectionText); + }, { + initialValue: selectionText, + searchEndpoint: '/search/entity-selector', + entityTypes: 'page,book,chapter,bookshelf', + entityPermission: 'view', + }); } // Show draw.io if enabled and handle save. @@ -440,8 +445,12 @@ export class Actions { selectionRange = selectionRange || this.#getSelectionRange(); const newDoc = this.editor.cm.state.toText(text); const newSelectFrom = Math.min(selectionRange.from, newDoc.length); + const scrollTop = this.editor.cm.scrollDOM.scrollTop; this.#dispatchChange(0, this.editor.cm.state.doc.length, text, newSelectFrom); this.focus(); + window.requestAnimationFrame(() => { + this.editor.cm.scrollDOM.scrollTop = scrollTop; + }); } /**