markupeditor 0.9.41 → 0.9.42
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.
- package/dist/markup-editor.js +37 -2
- package/package.json +1 -1
package/dist/markup-editor.js
CHANGED
|
@@ -36358,7 +36358,7 @@ function _hasColspannedHeader(state) {
|
|
|
36358
36358
|
const headers = [];
|
|
36359
36359
|
let tableAttributes = _getTableAttributes(state);
|
|
36360
36360
|
if (!tableAttributes.table) return false;
|
|
36361
|
-
state.tr.doc.nodesBetween(tableAttributes.from, tableAttributes.to, (node
|
|
36361
|
+
state.tr.doc.nodesBetween(tableAttributes.from, tableAttributes.to, (node) => {
|
|
36362
36362
|
if (node.type == nodeTypes.table_header) {
|
|
36363
36363
|
headers.push(node);
|
|
36364
36364
|
return false;
|
|
@@ -36437,7 +36437,7 @@ function justifyColumnCommand(align) {
|
|
|
36437
36437
|
// 'left' means "clear", matching an unaligned GFM column having no delimiter-row marker
|
|
36438
36438
|
// at all -- an alias here rather than relying on every caller to pass null/undefined.
|
|
36439
36439
|
const resolvedAlign = (align && align !== 'left') ? align : null;
|
|
36440
|
-
const commandAdapter = (state, dispatch
|
|
36440
|
+
const commandAdapter = (state, dispatch) => {
|
|
36441
36441
|
if (!isTableSelected(state)) return false;
|
|
36442
36442
|
const nodeTypes = state.schema.nodes;
|
|
36443
36443
|
const tableAttributes = _getTableAttributes(state);
|
|
@@ -36494,6 +36494,37 @@ function tableHasHeader(state) {
|
|
|
36494
36494
|
return _getTableAttributes(state).header === true
|
|
36495
36495
|
}
|
|
36496
36496
|
|
|
36497
|
+
/**
|
|
36498
|
+
* Handle Mod-Enter when the selection is inside a table: insert a paragraph
|
|
36499
|
+
* immediately after the table and move the selection into it.
|
|
36500
|
+
*
|
|
36501
|
+
* Mirrors prosemirror-commands' `exitCode`, which does the same for code_block
|
|
36502
|
+
* via its `code` node spec. Bound alongside (not instead of) `exitCode` in
|
|
36503
|
+
* keymap.js; returning false when the selection isn't in a table lets that
|
|
36504
|
+
* binding fall through to `exitCode` as usual.
|
|
36505
|
+
*
|
|
36506
|
+
* @ignore
|
|
36507
|
+
* @returns {boolean} True if a paragraph was inserted after the table; else false.
|
|
36508
|
+
*/
|
|
36509
|
+
function exitTableCommand(state, dispatch) {
|
|
36510
|
+
const { $head, $anchor } = state.selection;
|
|
36511
|
+
if (!$head.sameParent($anchor)) return false
|
|
36512
|
+
const tableAttributes = _getTableAttributes(state);
|
|
36513
|
+
if (!tableAttributes.table) return false
|
|
36514
|
+
const paragraphType = state.schema.nodes.paragraph;
|
|
36515
|
+
const pos = tableAttributes.to;
|
|
36516
|
+
const $after = state.doc.resolve(pos);
|
|
36517
|
+
const after = $after.index();
|
|
36518
|
+
if (!$after.parent.canReplaceWith(after, after, paragraphType)) return false
|
|
36519
|
+
if (dispatch) {
|
|
36520
|
+
const tr = state.tr.replaceWith(pos, pos, paragraphType.createAndFill());
|
|
36521
|
+
tr.setSelection(TextSelection.near(tr.doc.resolve(pos)));
|
|
36522
|
+
dispatch(tr.scrollIntoView());
|
|
36523
|
+
stateChanged(activeView());
|
|
36524
|
+
}
|
|
36525
|
+
return true
|
|
36526
|
+
}
|
|
36527
|
+
|
|
36497
36528
|
function setBorderCommand(border) {
|
|
36498
36529
|
const commandAdapter = (viewState, dispatch, view) => {
|
|
36499
36530
|
let state = view?.state ?? viewState;
|
|
@@ -40988,6 +41019,10 @@ function buildKeymap(config, schema) {
|
|
|
40988
41019
|
bind("Shift-Enter", handleShiftEnter);
|
|
40989
41020
|
// The MarkupEditor needs to be notified of state changes on Delete, like Backspace
|
|
40990
41021
|
bind("Delete", chainCommands(handleDelete, deleteNewlineForward));
|
|
41022
|
+
// Escape a table the same way Mod-Enter already escapes a code_block (via
|
|
41023
|
+
// prosemirror-commands' exitCode, bound in baseKeymap): if the selection isn't
|
|
41024
|
+
// in a table, exitTableCommand returns false and this falls through to exitCode.
|
|
41025
|
+
bind("Mod-Enter", exitTableCommand);
|
|
40991
41026
|
// Table navigation by Tab/Shift-Tab
|
|
40992
41027
|
bind('Tab', goToNextCell(1));
|
|
40993
41028
|
bind('Shift-Tab', goToNextCell(-1));
|