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:
@ -78,12 +78,13 @@ function filePickerCallback(callback, value, meta) {
|
||||
if (meta.filetype === 'file') {
|
||||
/** @type {EntitySelectorPopup} * */
|
||||
const selector = window.$components.first('entity-selector-popup');
|
||||
const selectionText = this.selection.getContent({format: 'text'}).trim();
|
||||
selector.show(entity => {
|
||||
callback(entity.link, {
|
||||
text: entity.name,
|
||||
title: entity.name,
|
||||
});
|
||||
});
|
||||
}, selectionText);
|
||||
}
|
||||
|
||||
if (meta.filetype === 'image') {
|
||||
|
@ -48,6 +48,7 @@ export function register(editor) {
|
||||
editor.shortcuts.add('meta+shift+K', '', () => {
|
||||
/** @var {EntitySelectorPopup} * */
|
||||
const selectorPopup = window.$components.first('entity-selector-popup');
|
||||
const selectionText = editor.selection.getContent({format: 'text'}).trim();
|
||||
selectorPopup.show(entity => {
|
||||
if (editor.selection.isCollapsed()) {
|
||||
editor.insertContent(editor.dom.createHTML('a', {href: entity.link}, editor.dom.encode(entity.name)));
|
||||
@ -57,6 +58,6 @@ export function register(editor) {
|
||||
|
||||
editor.selection.collapse(false);
|
||||
editor.focus();
|
||||
});
|
||||
}, selectionText);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user