1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-30 04:23:11 +03:00

Editors: Updated entity link select to pre-fill with selection

Updated all uses across both editors, so the entity link selector popup
now initates a search with the selection text if existing.

For #4571
This commit is contained in:
Dan Brown
2023-09-24 18:33:33 +01:00
parent e9664dc678
commit 21badde4ef
5 changed files with 18 additions and 5 deletions

View File

@ -68,11 +68,12 @@ export class Actions {
/** @type {EntitySelectorPopup} * */
const selector = window.$components.first('entity-selector-popup');
const selectionText = this.#getSelectionText(selectionRange);
selector.show(entity => {
const selectedText = this.#getSelectionText(selectionRange) || entity.name;
const selectedText = selectionText || entity.name;
const newText = `[${selectedText}](${entity.link})`;
this.#replaceSelection(newText, newText.length, selectionRange);
});
}, selectionText);
}
// Show draw.io if enabled and handle save.