markupeditor 0.9.31 → 0.9.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -32935,6 +32935,40 @@ function handleDelete() {
32935
32935
  return false
32936
32936
  }
32937
32937
 
32938
+ /**
32939
+ * Delete a `\n` immediately before (dir -1) or after (dir +1) the cursor inside a code_block's
32940
+ * text, via a direct transaction rather than relying on native contenteditable editing.
32941
+ *
32942
+ * Safari/WebKit never issues a native deleteContentBackward/deleteContentForward `beforeinput`
32943
+ * at all when the adjacent `\n` is the last character in the block (cursor at the start of an
32944
+ * empty trailing line) under `white-space: pre-wrap` — confirmed by instrumenting keydown/
32945
+ * beforeinput/input: keydown fires and is not prevented, but no beforeinput or input event
32946
+ * follows, and neither the ProseMirror doc nor the DOM change. The unhandled key produces the
32947
+ * system beep. This only reproduces with the real `white-space: pre-wrap` styling the editor
32948
+ * ships with; it does not reproduce against an unstyled contenteditable. Newline deletion inside
32949
+ * a code_block is therefore always handled explicitly here so it never depends on native
32950
+ * contenteditable editing for this specific character.
32951
+ *
32952
+ * @ignore
32953
+ */
32954
+ function deleteAdjacentNewline(dir) {
32955
+ return (state, dispatch) => {
32956
+ const { $from, empty } = state.selection;
32957
+ if (!empty || $from.parent.type !== state.schema.nodes.code_block) return false
32958
+ const text = $from.parent.textContent;
32959
+ const charOffset = dir < 0 ? $from.parentOffset - 1 : $from.parentOffset;
32960
+ if (charOffset < 0 || charOffset >= text.length || text[charOffset] !== '\n') return false
32961
+ if (dispatch) {
32962
+ const from = $from.pos + (dir < 0 ? -1 : 0);
32963
+ dispatch(state.tr.delete(from, from + 1));
32964
+ }
32965
+ return true
32966
+ }
32967
+ }
32968
+
32969
+ const deleteNewlineBackward = deleteAdjacentNewline(-1);
32970
+ const deleteNewlineForward = deleteAdjacentNewline(1);
32971
+
32938
32972
  /**
32939
32973
  * Called to set attributes to the editor div, typically to ,
32940
32974
  * set spellcheck and autocorrect. Note that contenteditable
@@ -40591,7 +40625,7 @@ function buildKeymap(config, schema) {
40591
40625
  // The MarkupEditor handles Shift-Enter as searchBackward when search is active.
40592
40626
  bind("Shift-Enter", handleShiftEnter);
40593
40627
  // The MarkupEditor needs to be notified of state changes on Delete, like Backspace
40594
- bind("Delete", handleDelete);
40628
+ bind("Delete", chainCommands(handleDelete, deleteNewlineForward));
40595
40629
  // Table navigation by Tab/Shift-Tab
40596
40630
  bind('Tab', goToNextCell(1));
40597
40631
  bind('Shift-Tab', goToNextCell(-1));
@@ -40607,7 +40641,7 @@ function buildKeymap(config, schema) {
40607
40641
  // Correction (needs to be chained with stateChanged also)
40608
40642
  bind(keymap.undo, undoCommand());
40609
40643
  bind(keymap.redo, redoCommand());
40610
- bind("Backspace", chainCommands(handleDelete, undoInputRule));
40644
+ bind("Backspace", chainCommands(handleDelete, deleteNewlineBackward, undoInputRule));
40611
40645
  // List types
40612
40646
  bind(keymap.bullet, wrapInListCommand(schema, schema.nodes.bullet_list));
40613
40647
  bind(keymap.number, wrapInListCommand(schema, schema.nodes.ordered_list));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markupeditor",
3
- "version": "0.9.31",
3
+ "version": "0.9.32",
4
4
  "description": "A web component and API for WYSIWYG HTML editing.",
5
5
  "keywords": [
6
6
  "wysiwyg",