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

Lexical: Table cell bg and format setting fixes

- Updated table cell background color setting to be stable by
  specifically using the background property over the general styles.
- Updated format shorcuts to be correct header levels as per old editor
  and format menu.
- Updated format changes to properly update UI afterwards.
This commit is contained in:
Dan Brown
2025-07-24 16:51:11 +01:00
parent 5fc19b0edf
commit ae4d1d804a
5 changed files with 20 additions and 11 deletions

View File

@@ -13,14 +13,16 @@ import {$showLinkForm} from "../ui/defaults/forms/objects";
import {showLinkSelector} from "../utils/links";
import {HeadingTagType} from "@lexical/rich-text/LexicalHeadingNode";
function headerHandler(editor: LexicalEditor, tag: HeadingTagType): boolean {
toggleSelectionAsHeading(editor, tag);
function headerHandler(context: EditorUiContext, tag: HeadingTagType): boolean {
toggleSelectionAsHeading(context.editor, tag);
context.manager.triggerFutureStateRefresh();
return true;
}
function wrapFormatAction(formatAction: (editor: LexicalEditor) => any): ShortcutAction {
return (editor: LexicalEditor) => {
return (editor: LexicalEditor, context: EditorUiContext) => {
formatAction(editor);
context.manager.triggerFutureStateRefresh();
return true;
};
}
@@ -45,10 +47,10 @@ const actionsByKeys: Record<string, ShortcutAction> = {
window.$events.emit('editor-save-page');
return true;
},
'meta+1': (editor) => headerHandler(editor, 'h1'),
'meta+2': (editor) => headerHandler(editor, 'h2'),
'meta+3': (editor) => headerHandler(editor, 'h3'),
'meta+4': (editor) => headerHandler(editor, 'h4'),
'meta+1': (editor, context) => headerHandler(context, 'h2'),
'meta+2': (editor, context) => headerHandler(context, 'h3'),
'meta+3': (editor, context) => headerHandler(context, 'h4'),
'meta+4': (editor, context) => headerHandler(context, 'h5'),
'meta+5': wrapFormatAction(toggleSelectionAsParagraph),
'meta+d': wrapFormatAction(toggleSelectionAsParagraph),
'meta+6': wrapFormatAction(toggleSelectionAsBlockquote),