mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 12:12:54 +01:00
fix(tinymce-plugins): first line not backspace-able (#132)
This commit is contained in:
@@ -5,11 +5,29 @@ const ZERO_WIDTH_NOBREAK_SPACE = 65279;
|
||||
* @param {import("tinymce").Editor} editor
|
||||
*/
|
||||
function register(editor) {
|
||||
firstLineBackspaceQuirk(editor);
|
||||
androidBackspaceKeyQuirk(editor);
|
||||
androidGboardEnterKeyQuirk(editor);
|
||||
androidSwiftKeyFormattingQuirk(editor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("tinymce").Editor} editor
|
||||
*/
|
||||
function firstLineBackspaceQuirk(editor) {
|
||||
editor.on("keydown", (e) => {
|
||||
if (e.key !== "Backspace" && e.key !== "Delete") return;
|
||||
|
||||
const selectionStartElement = editor.selection.getStart(true);
|
||||
if (
|
||||
selectionStartElement === editor.getBody().firstElementChild &&
|
||||
!selectionStartElement.textContent.trim()
|
||||
) {
|
||||
selectionStartElement.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* => Detected & tested on:
|
||||
* Google Chrome Android with SwiftKey Keyboard
|
||||
|
||||
Reference in New Issue
Block a user