@contentful/field-editor-rich-text 2.0.0-next.26 → 2.0.0-next.27
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/field-editor-rich-text.cjs.development.js +41 -5
- package/dist/field-editor-rich-text.cjs.development.js.map +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js +1 -1
- package/dist/field-editor-rich-text.cjs.production.min.js.map +1 -1
- package/dist/field-editor-rich-text.esm.js +42 -6
- package/dist/field-editor-rich-text.esm.js.map +1 -1
- package/dist/helpers/editor.d.ts +1 -1
- package/dist/test-utils/jsx.d.ts +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,7 @@ import { createBoldPlugin as createBoldPlugin$1, createCodePlugin as createCodeP
|
|
|
26
26
|
import isPlainObject from 'is-plain-obj';
|
|
27
27
|
import { createParagraphPlugin as createParagraphPlugin$1 } from '@udecode/plate-paragraph';
|
|
28
28
|
import { createSelectOnBackspacePlugin as createSelectOnBackspacePlugin$1 } from '@udecode/plate-select';
|
|
29
|
-
import { ELEMENT_TABLE, ELEMENT_TR, getEmptyRowNode, ELEMENT_TD, ELEMENT_TH, getEmptyCellNode, insertTable, deleteRow, deleteColumn, deleteTable, createTablePlugin as createTablePlugin$1, onKeyDownTable } from '@udecode/plate-table';
|
|
29
|
+
import { ELEMENT_TABLE, ELEMENT_TR, getEmptyRowNode, ELEMENT_TD, ELEMENT_TH, getEmptyCellNode, insertTable, deleteRow, deleteColumn, deleteTable, createTablePlugin as createTablePlugin$1, withTable, onKeyDownTable } from '@udecode/plate-table';
|
|
30
30
|
import { toContentfulDocument, toSlatejsDocument } from '@contentful/contentful-slatejs-adapter';
|
|
31
31
|
import { documentToPlainTextString } from '@contentful/rich-text-plain-text-renderer';
|
|
32
32
|
import { createTrailingBlockPlugin } from '@udecode/plate-trailing-block';
|
|
@@ -454,7 +454,7 @@ function moveToTheNextChar(editor) {
|
|
|
454
454
|
unit: 'character'
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
-
function insertEmptyParagraph(editor) {
|
|
457
|
+
function insertEmptyParagraph(editor, options) {
|
|
458
458
|
var emptyParagraph = {
|
|
459
459
|
type: BLOCKS.PARAGRAPH,
|
|
460
460
|
children: [{
|
|
@@ -463,7 +463,7 @@ function insertEmptyParagraph(editor) {
|
|
|
463
463
|
data: {},
|
|
464
464
|
isVoid: false
|
|
465
465
|
};
|
|
466
|
-
Transforms.insertNodes(editor, emptyParagraph);
|
|
466
|
+
Transforms.insertNodes(editor, emptyParagraph, options);
|
|
467
467
|
}
|
|
468
468
|
function getElementFromCurrentSelection(editor) {
|
|
469
469
|
if (!editor.selection) return [];
|
|
@@ -5916,9 +5916,11 @@ var Row = function Row(props) {
|
|
|
5916
5916
|
var _templateObject$a;
|
|
5917
5917
|
var style$5 = /*#__PURE__*/css(_templateObject$a || (_templateObject$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n margin-bottom: 1.5em;\n border-collapse: collapse;\n border-radius: 5px;\n border-style: hidden;\n box-shadow: 0 0 0 1px ", ";\n width: 100%;\n table-layout: fixed;\n overflow: hidden;\n"])), tokens.gray400);
|
|
5918
5918
|
var Table = function Table(props) {
|
|
5919
|
-
return /*#__PURE__*/createElement("
|
|
5919
|
+
return /*#__PURE__*/createElement("div", {
|
|
5920
|
+
"data-block-type": BLOCKS.TABLE
|
|
5921
|
+
}, /*#__PURE__*/createElement("table", Object.assign({
|
|
5920
5922
|
className: style$5
|
|
5921
|
-
}), /*#__PURE__*/createElement("tbody", null, props.children));
|
|
5923
|
+
}, props.attributes), /*#__PURE__*/createElement("tbody", null, props.children)));
|
|
5922
5924
|
};
|
|
5923
5925
|
|
|
5924
5926
|
var createTableOnKeyDown = function createTableOnKeyDown(editor, plugin) {
|
|
@@ -5931,6 +5933,38 @@ var createTableOnKeyDown = function createTableOnKeyDown(editor, plugin) {
|
|
|
5931
5933
|
event.preventDefault();
|
|
5932
5934
|
event.stopPropagation();
|
|
5933
5935
|
return;
|
|
5936
|
+
} // This fixes `Cannot resolve a Slate point from DOM point: [object HTMLDivElement]` when typing while the cursor is before table
|
|
5937
|
+
|
|
5938
|
+
|
|
5939
|
+
var windowSelection = window.getSelection();
|
|
5940
|
+
|
|
5941
|
+
if (windowSelection) {
|
|
5942
|
+
var _windowSelection$anch, _windowSelection$anch2;
|
|
5943
|
+
|
|
5944
|
+
// @ts-expect-error
|
|
5945
|
+
var blockType = (_windowSelection$anch = windowSelection.anchorNode.attributes) == null ? void 0 : (_windowSelection$anch2 = _windowSelection$anch['data-block-type']) == null ? void 0 : _windowSelection$anch2.value; // this attribute comes from `plugins/Table/components/Table.tsx`
|
|
5946
|
+
|
|
5947
|
+
var isBeforeTable = blockType === BLOCKS.TABLE;
|
|
5948
|
+
|
|
5949
|
+
if (isBeforeTable) {
|
|
5950
|
+
if (event.key === 'Enter') {
|
|
5951
|
+
var above = getAbove(editor, {
|
|
5952
|
+
match: {
|
|
5953
|
+
type: BLOCKS.TABLE
|
|
5954
|
+
}
|
|
5955
|
+
});
|
|
5956
|
+
if (!above) return;
|
|
5957
|
+
var tablePath = above[1];
|
|
5958
|
+
insertEmptyParagraph(editor, {
|
|
5959
|
+
at: tablePath,
|
|
5960
|
+
select: true
|
|
5961
|
+
});
|
|
5962
|
+
}
|
|
5963
|
+
|
|
5964
|
+
event.preventDefault();
|
|
5965
|
+
event.stopPropagation();
|
|
5966
|
+
return;
|
|
5967
|
+
}
|
|
5934
5968
|
}
|
|
5935
5969
|
|
|
5936
5970
|
defaultHandler(event);
|
|
@@ -5945,7 +5979,9 @@ var createTablePlugin = function createTablePlugin() {
|
|
|
5945
5979
|
handlers: {
|
|
5946
5980
|
onKeyDown: createTableOnKeyDown
|
|
5947
5981
|
},
|
|
5948
|
-
withOverrides: function withOverrides(editor) {
|
|
5982
|
+
withOverrides: function withOverrides(editor, plugin) {
|
|
5983
|
+
// injects important fixes from plate's original table plugin
|
|
5984
|
+
withTable(editor, plugin);
|
|
5949
5985
|
addTableTrackingEvents(editor);
|
|
5950
5986
|
var insertFragment = editor.insertFragment;
|
|
5951
5987
|
|