Skip to content

Keyboard shortcut Mod-a prevents selecting the whole document #20

@eduludi

Description

@eduludi

When enabling this extension in TipTap editor, the document can't be fully selected with the default Mod-a keyboard shortcut, at least on macOS where cmd+a selects the whole document.

cmd+a only works within a footnote, wher only the text of the footnote is selected.

It looks like these lines set this behavior:

addKeyboardShortcuts() {
return {
// override the default behavior of Mod-a:
// rather than selecting the whole text content of the editor, only select the text inside the current footnote
"Mod-a": ({ editor }) => {
try {
const { selection } = editor.state;
const { $from } = selection;
// footnote listItems are at depth 2, we are getting the start & end position of the parent list item from the current cursor position
const start = $from.start(2);
const startNode = editor.$pos(start);
if (startNode.node.type.name != "footnote") return false;
const end = $from.end(2);
editor.commands.setTextSelection({
from: start + 1,
to: end - 1,
});
return true;
} catch (e) {
return false;
}
},
};
},

P.S.: Thanks for this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    EditorbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions