mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-12-20 22:22:06 +03:00
Lexical: Fixed undefined entity selector value
Also added pre-fill of selector search based on selected text range.
This commit is contained in:
@@ -71,6 +71,9 @@ const actionsByKeys: Record<string, ShortcutAction> = {
|
||||
return true;
|
||||
},
|
||||
'meta+shift+k': (editor, context) => {
|
||||
editor.getEditorState().read(() => {
|
||||
const selection = $getSelection();
|
||||
const selectionText = selection?.getTextContent() || '';
|
||||
showLinkSelector(entity => {
|
||||
insertOrUpdateLink(editor, {
|
||||
text: entity.name,
|
||||
@@ -78,6 +81,7 @@ const actionsByKeys: Record<string, ShortcutAction> = {
|
||||
target: '',
|
||||
url: entity.link,
|
||||
});
|
||||
}, selectionText);
|
||||
});
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ type EditorEntityData = {
|
||||
export function showLinkSelector(callback: (entity: EditorEntityData) => any, selectionText?: string) {
|
||||
const selector: EntitySelectorPopup = window.$components.first('entity-selector-popup') as EntitySelectorPopup;
|
||||
selector.show((entity: EditorEntityData) => callback(entity), {
|
||||
initialValue: selectionText,
|
||||
initialValue: selectionText || '',
|
||||
searchEndpoint: '/search/entity-selector',
|
||||
entityTypes: 'page,book,chapter,bookshelf',
|
||||
entityPermission: 'view',
|
||||
|
||||
Reference in New Issue
Block a user