@contentful/field-editor-rich-text 6.6.14 → 6.6.15-canary.2

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.
Files changed (32) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/RichTextEditor.js +2 -2
  3. package/dist/cjs/helpers/isEmptyRichTextDocument.integration.test.js +136 -0
  4. package/dist/cjs/helpers/isEmptyRichTextDocument.js +54 -0
  5. package/dist/cjs/helpers/isEmptyRichTextDocument.test.js +277 -0
  6. package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +82 -0
  7. package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +198 -0
  8. package/dist/cjs/plugins/List/withList.js +25 -1
  9. package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +328 -0
  10. package/dist/cjs/plugins/Table/createTablePlugin.js +2 -0
  11. package/dist/cjs/plugins/Table/onKeyDownTable.js +0 -14
  12. package/dist/cjs/plugins/Table/withDeleteBackwardTable.js +59 -0
  13. package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +63 -0
  14. package/dist/cjs/plugins/Text/createTextPlugin.js +21 -5
  15. package/dist/esm/RichTextEditor.js +2 -2
  16. package/dist/esm/helpers/isEmptyRichTextDocument.integration.test.js +91 -0
  17. package/dist/esm/helpers/isEmptyRichTextDocument.js +44 -0
  18. package/dist/esm/helpers/isEmptyRichTextDocument.test.js +273 -0
  19. package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +83 -1
  20. package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +200 -2
  21. package/dist/esm/plugins/List/withList.js +26 -2
  22. package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +329 -1
  23. package/dist/esm/plugins/Table/createTablePlugin.js +2 -0
  24. package/dist/esm/plugins/Table/onKeyDownTable.js +1 -15
  25. package/dist/esm/plugins/Table/withDeleteBackwardTable.js +49 -0
  26. package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +64 -1
  27. package/dist/esm/plugins/Text/createTextPlugin.js +22 -6
  28. package/dist/types/helpers/isEmptyRichTextDocument.d.ts +7 -0
  29. package/dist/types/helpers/isEmptyRichTextDocument.integration.test.d.ts +1 -0
  30. package/dist/types/helpers/isEmptyRichTextDocument.test.d.ts +1 -0
  31. package/dist/types/plugins/Table/withDeleteBackwardTable.d.ts +2 -0
  32. package/package.json +2 -2
package/README.md CHANGED
@@ -10,6 +10,12 @@ This package contains a React `RichTextEditor` component that is used as the def
10
10
  import { RichTextEditor } from '@contentful/field-editor-rich-text';
11
11
  ```
12
12
 
13
+ ## Clearing a field
14
+
15
+ When an edit leaves only empty paragraphs or list items, the editor removes the locale's field value. Blank paragraphs within documents containing content are preserved. Whitespace, embedded entities, horizontal rules, and tables count as content.
16
+
17
+ Backspace removes a wholly empty list at its start. It removes a wholly empty table from the start of its first cell or the paragraph immediately after it. A heading keeps its formatting when its final character is deleted; pressing Backspace again removes the empty heading and returns to normal text.
18
+
13
19
  ## ⚠️ Important: Package Configuration
14
20
 
15
21
  Plate 53.3.14 pins `slate-react` to 0.126.4. To use the latest Slate React version tested by this package (0.127.1), update existing overrides in your application as shown below. Package-manager overrides in this repository are not inherited by applications that install the published package.
@@ -19,7 +19,6 @@ _export(exports, {
19
19
  const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
20
20
  const _fieldeditorreference = require("@contentful/field-editor-reference");
21
21
  const _fieldeditorshared = require("@contentful/field-editor-shared");
22
- const _richtexttypes = /*#__PURE__*/ _interop_require_wildcard(require("@contentful/rich-text-types"));
23
22
  const _css = require("@emotion/css");
24
23
  const _fastdeepequal = /*#__PURE__*/ _interop_require_default(require("fast-deep-equal"));
25
24
  const _noop = /*#__PURE__*/ _interop_require_default(require("lodash/noop"));
@@ -28,6 +27,7 @@ const _CharConstraints = require("./CharConstraints");
28
27
  const _ContentfulEditorProvider = require("./ContentfulEditorProvider");
29
28
  const _editoroverrides = require("./editor-overrides");
30
29
  const _callbacks = require("./helpers/callbacks");
30
+ const _isEmptyRichTextDocument = require("./helpers/isEmptyRichTextDocument");
31
31
  const _toSlateDoc = require("./helpers/toSlateDoc");
32
32
  const _plate = require("./internal/plate");
33
33
  const _pluginAdapter = require("./internal/pluginAdapter");
@@ -173,7 +173,7 @@ const ConnectedRichTextEditor = _react.memo(function ConnectedRichTextEditor(pro
173
173
  });
174
174
  const RichTextEditor = (props)=>{
175
175
  const { sdk, isInitiallyDisabled, onAction, restrictedMarks, onChange, isDisabled, queryClient, ...otherProps } = props;
176
- const isEmptyValue = _react.useCallback((value)=>!value || (0, _fastdeepequal.default)(value, _richtexttypes.EMPTY_DOCUMENT), []);
176
+ const isEmptyValue = _react.useCallback((value)=>!value || (0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(value), []);
177
177
  _react.useEffect(()=>{
178
178
  if (!onChange) {
179
179
  return;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
6
+ const _fieldeditorshared = require("@contentful/field-editor-shared");
7
+ const _fieldeditortestutils = require("@contentful/field-editor-test-utils");
8
+ const _richtexttypes = require("@contentful/rich-text-types");
9
+ const _react1 = require("@testing-library/react");
10
+ const _vitest = require("vitest");
11
+ const _isEmptyRichTextDocument = require("./isEmptyRichTextDocument");
12
+ function _getRequireWildcardCache(nodeInterop) {
13
+ if (typeof WeakMap !== "function") return null;
14
+ var cacheBabelInterop = new WeakMap();
15
+ var cacheNodeInterop = new WeakMap();
16
+ return (_getRequireWildcardCache = function(nodeInterop) {
17
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
+ })(nodeInterop);
19
+ }
20
+ function _interop_require_wildcard(obj, nodeInterop) {
21
+ if (!nodeInterop && obj && obj.__esModule) {
22
+ return obj;
23
+ }
24
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
+ return {
26
+ default: obj
27
+ };
28
+ }
29
+ var cache = _getRequireWildcardCache(nodeInterop);
30
+ if (cache && cache.has(obj)) {
31
+ return cache.get(obj);
32
+ }
33
+ var newObj = {
34
+ __proto__: null
35
+ };
36
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
37
+ for(var key in obj){
38
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
39
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
40
+ if (desc && (desc.get || desc.set)) {
41
+ Object.defineProperty(newObj, key, desc);
42
+ } else {
43
+ newObj[key] = obj[key];
44
+ }
45
+ }
46
+ }
47
+ newObj.default = obj;
48
+ if (cache) {
49
+ cache.set(obj, newObj);
50
+ }
51
+ return newObj;
52
+ }
53
+ const paragraph = (value, marks = [])=>({
54
+ nodeType: _richtexttypes.BLOCKS.PARAGRAPH,
55
+ data: {},
56
+ content: [
57
+ {
58
+ nodeType: 'text',
59
+ value,
60
+ marks,
61
+ data: {}
62
+ }
63
+ ]
64
+ });
65
+ const document = (...content)=>({
66
+ nodeType: _richtexttypes.BLOCKS.DOCUMENT,
67
+ data: {},
68
+ content
69
+ });
70
+ const initialValue = document(paragraph('content'));
71
+ const emptyList = (type)=>document({
72
+ nodeType: type,
73
+ data: {},
74
+ content: [
75
+ {
76
+ nodeType: _richtexttypes.BLOCKS.LIST_ITEM,
77
+ data: {},
78
+ content: [
79
+ paragraph('', [
80
+ {
81
+ type: _richtexttypes.MARKS.BOLD
82
+ }
83
+ ])
84
+ ]
85
+ }
86
+ ]
87
+ }, paragraph(''));
88
+ _vitest.it.each([
89
+ [
90
+ 'multiple empty paragraphs',
91
+ document(paragraph(''), paragraph(''))
92
+ ],
93
+ [
94
+ 'an empty unordered list',
95
+ emptyList(_richtexttypes.BLOCKS.UL_LIST)
96
+ ],
97
+ [
98
+ 'an empty ordered list',
99
+ emptyList(_richtexttypes.BLOCKS.OL_LIST)
100
+ ]
101
+ ])('removes the SDK field value after editing to %s', async (_description, editedValue)=>{
102
+ const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)(undefined, initialValue);
103
+ (0, _react1.render)(_react.createElement(_fieldeditorshared.FieldConnector, {
104
+ field: field,
105
+ isInitiallyDisabled: false,
106
+ isEmptyValue: _isEmptyRichTextDocument.isEmptyRichTextDocument,
107
+ debounce: 0
108
+ }, ({ setValue })=>_react.createElement("button", {
109
+ onClick: ()=>void setValue(editedValue)
110
+ }, "Save edit")));
111
+ (0, _vitest.expect)(field.getValue()).toEqual(initialValue);
112
+ _react1.fireEvent.click(_react1.screen.getByRole('button', {
113
+ name: 'Save edit'
114
+ }));
115
+ await (0, _react1.waitFor)(()=>(0, _vitest.expect)(field.getValue()).toBeUndefined());
116
+ });
117
+ (0, _vitest.it)('saves a horizontal rule even though it contains no text', async ()=>{
118
+ const [field] = (0, _fieldeditortestutils.createFakeFieldAPI)(undefined, initialValue);
119
+ const editedValue = document({
120
+ nodeType: _richtexttypes.BLOCKS.HR,
121
+ data: {},
122
+ content: []
123
+ }, paragraph(''));
124
+ (0, _react1.render)(_react.createElement(_fieldeditorshared.FieldConnector, {
125
+ field: field,
126
+ isInitiallyDisabled: false,
127
+ isEmptyValue: _isEmptyRichTextDocument.isEmptyRichTextDocument,
128
+ debounce: 0
129
+ }, ({ setValue })=>_react.createElement("button", {
130
+ onClick: ()=>void setValue(editedValue)
131
+ }, "Save edit")));
132
+ _react1.fireEvent.click(_react1.screen.getByRole('button', {
133
+ name: 'Save edit'
134
+ }));
135
+ await (0, _react1.waitFor)(()=>(0, _vitest.expect)(field.getValue()).toEqual(editedValue));
136
+ });
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "isEmptyRichTextDocument", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return isEmptyRichTextDocument;
9
+ }
10
+ });
11
+ const _richtexttypes = require("@contentful/rich-text-types");
12
+ const knownMarkTypes = new Set(Object.values(_richtexttypes.MARKS));
13
+ const hasOnlyKeys = (value, keys)=>Object.keys(value).every((key)=>keys.includes(key));
14
+ const isJsonObject = (value)=>value !== null && typeof value === 'object' && !Array.isArray(value);
15
+ const hasEmptyData = (value)=>isJsonObject(value) && Object.keys(value).length === 0;
16
+ const isKnownMark = (value)=>isJsonObject(value) && hasOnlyKeys(value, [
17
+ 'type'
18
+ ]) && typeof value.type === 'string' && knownMarkTypes.has(value.type);
19
+ function isEmptyText(node) {
20
+ return isJsonObject(node) && hasOnlyKeys(node, [
21
+ 'nodeType',
22
+ 'value',
23
+ 'marks',
24
+ 'data'
25
+ ]) && node.nodeType === 'text' && node.value === '' && Array.isArray(node.marks) && node.marks.every(isKnownMark) && hasEmptyData(node.data);
26
+ }
27
+ function isEmptyParagraph(node) {
28
+ return isJsonObject(node) && hasOnlyKeys(node, [
29
+ 'nodeType',
30
+ 'data',
31
+ 'content'
32
+ ]) && node.nodeType === _richtexttypes.BLOCKS.PARAGRAPH && hasEmptyData(node.data) && Array.isArray(node.content) && node.content.length > 0 && node.content.every(isEmptyText);
33
+ }
34
+ function isEmptyList(node) {
35
+ return isJsonObject(node) && hasOnlyKeys(node, [
36
+ 'nodeType',
37
+ 'data',
38
+ 'content'
39
+ ]) && (node.nodeType === _richtexttypes.BLOCKS.UL_LIST || node.nodeType === _richtexttypes.BLOCKS.OL_LIST) && hasEmptyData(node.data) && Array.isArray(node.content) && node.content.every(isEmptyListItem);
40
+ }
41
+ function isEmptyListItem(node) {
42
+ return isJsonObject(node) && hasOnlyKeys(node, [
43
+ 'nodeType',
44
+ 'data',
45
+ 'content'
46
+ ]) && node.nodeType === _richtexttypes.BLOCKS.LIST_ITEM && hasEmptyData(node.data) && Array.isArray(node.content) && node.content.length > 0 && node.content.every((child)=>isEmptyParagraph(child) || isEmptyList(child));
47
+ }
48
+ function isEmptyRichTextDocument(value) {
49
+ return isJsonObject(value) && hasOnlyKeys(value, [
50
+ 'nodeType',
51
+ 'data',
52
+ 'content'
53
+ ]) && value.nodeType === _richtexttypes.BLOCKS.DOCUMENT && hasEmptyData(value.data) && Array.isArray(value.content) && value.content.every((node)=>isEmptyParagraph(node) || isEmptyList(node));
54
+ }
@@ -0,0 +1,277 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ const _richtexttypes = require("@contentful/rich-text-types");
6
+ const _vitest = require("vitest");
7
+ const _isEmptyRichTextDocument = require("./isEmptyRichTextDocument");
8
+ const emptyText = {
9
+ nodeType: 'text',
10
+ value: '',
11
+ marks: [],
12
+ data: {}
13
+ };
14
+ const emptyParagraph = {
15
+ nodeType: 'paragraph',
16
+ data: {},
17
+ content: [
18
+ emptyText
19
+ ]
20
+ };
21
+ const document = (...content)=>({
22
+ nodeType: 'document',
23
+ data: {},
24
+ content
25
+ });
26
+ (0, _vitest.describe)('isEmptyRichTextDocument', ()=>{
27
+ (0, _vitest.it)('recognizes the canonical empty document', ()=>{
28
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document(emptyParagraph))).toBe(true);
29
+ });
30
+ (0, _vitest.it)('recognizes documents with multiple empty paragraphs', ()=>{
31
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document(emptyParagraph, emptyParagraph))).toBe(true);
32
+ });
33
+ _vitest.it.each(Object.values(_richtexttypes.MARKS))('recognizes empty text with the %s mark', (type)=>{
34
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document({
35
+ ...emptyParagraph,
36
+ content: [
37
+ {
38
+ ...emptyText,
39
+ marks: [
40
+ {
41
+ type
42
+ }
43
+ ]
44
+ }
45
+ ]
46
+ }))).toBe(true);
47
+ });
48
+ (0, _vitest.it)('recognizes an empty list with multiple formatting marks', ()=>{
49
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document({
50
+ nodeType: 'unordered-list',
51
+ data: {},
52
+ content: [
53
+ {
54
+ nodeType: 'list-item',
55
+ data: {},
56
+ content: [
57
+ {
58
+ ...emptyParagraph,
59
+ content: [
60
+ {
61
+ ...emptyText,
62
+ marks: [
63
+ {
64
+ type: _richtexttypes.MARKS.BOLD
65
+ },
66
+ {
67
+ type: _richtexttypes.MARKS.ITALIC
68
+ }
69
+ ]
70
+ }
71
+ ]
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ }))).toBe(true);
77
+ });
78
+ (0, _vitest.it)('recognizes an empty list followed by the editor trailing paragraph', ()=>{
79
+ const emptyList = {
80
+ nodeType: 'unordered-list',
81
+ data: {},
82
+ content: [
83
+ {
84
+ nodeType: 'list-item',
85
+ data: {},
86
+ content: [
87
+ emptyParagraph
88
+ ]
89
+ }
90
+ ]
91
+ };
92
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document(emptyList, emptyParagraph))).toBe(true);
93
+ });
94
+ (0, _vitest.it)('recognizes empty nested ordered and unordered lists', ()=>{
95
+ const nestedList = {
96
+ nodeType: 'ordered-list',
97
+ data: {},
98
+ content: [
99
+ {
100
+ nodeType: 'list-item',
101
+ data: {},
102
+ content: [
103
+ emptyParagraph,
104
+ {
105
+ nodeType: 'unordered-list',
106
+ data: {},
107
+ content: [
108
+ {
109
+ nodeType: 'list-item',
110
+ data: {},
111
+ content: [
112
+ emptyParagraph
113
+ ]
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ };
121
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document(nestedList))).toBe(true);
122
+ });
123
+ (0, _vitest.it)('recognizes a document with no blocks', ()=>{
124
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document())).toBe(true);
125
+ });
126
+ _vitest.it.each([
127
+ [
128
+ 'whitespace text',
129
+ document({
130
+ ...emptyParagraph,
131
+ content: [
132
+ {
133
+ ...emptyText,
134
+ value: ' '
135
+ }
136
+ ]
137
+ })
138
+ ],
139
+ [
140
+ 'nonempty text',
141
+ document({
142
+ ...emptyParagraph,
143
+ content: [
144
+ {
145
+ ...emptyText,
146
+ value: 'text'
147
+ }
148
+ ]
149
+ })
150
+ ],
151
+ [
152
+ 'an unknown mark',
153
+ document({
154
+ ...emptyParagraph,
155
+ content: [
156
+ {
157
+ ...emptyText,
158
+ marks: [
159
+ {
160
+ type: 'custom-mark'
161
+ }
162
+ ]
163
+ }
164
+ ]
165
+ })
166
+ ],
167
+ [
168
+ 'mark metadata',
169
+ document({
170
+ ...emptyParagraph,
171
+ content: [
172
+ {
173
+ ...emptyText,
174
+ marks: [
175
+ {
176
+ type: _richtexttypes.MARKS.BOLD,
177
+ custom: true
178
+ }
179
+ ]
180
+ }
181
+ ]
182
+ })
183
+ ],
184
+ [
185
+ 'an embedded entry',
186
+ document({
187
+ nodeType: 'embedded-entry-block',
188
+ data: {},
189
+ content: []
190
+ })
191
+ ],
192
+ [
193
+ 'a horizontal rule',
194
+ document({
195
+ nodeType: 'hr',
196
+ data: {},
197
+ content: []
198
+ })
199
+ ],
200
+ [
201
+ 'a table',
202
+ document({
203
+ nodeType: 'table',
204
+ data: {},
205
+ content: []
206
+ })
207
+ ],
208
+ [
209
+ 'an empty heading',
210
+ document({
211
+ ...emptyParagraph,
212
+ nodeType: 'heading-1'
213
+ })
214
+ ],
215
+ [
216
+ 'blank paragraphs around text',
217
+ document(emptyParagraph, {
218
+ ...emptyParagraph,
219
+ content: [
220
+ {
221
+ ...emptyText,
222
+ value: 'text'
223
+ }
224
+ ]
225
+ }, emptyParagraph)
226
+ ],
227
+ [
228
+ 'an unknown node',
229
+ document({
230
+ nodeType: 'custom-block',
231
+ data: {},
232
+ content: []
233
+ })
234
+ ],
235
+ [
236
+ 'custom node data',
237
+ document({
238
+ ...emptyParagraph,
239
+ data: {
240
+ custom: true
241
+ }
242
+ })
243
+ ],
244
+ [
245
+ 'extra document data',
246
+ {
247
+ ...document(emptyParagraph),
248
+ data: {
249
+ custom: true
250
+ }
251
+ }
252
+ ]
253
+ ])('preserves %s', (_description, value)=>{
254
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(value)).toBe(false);
255
+ });
256
+ (0, _vitest.it)('preserves invalid or unknown structures', ()=>{
257
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(null)).toBe(false);
258
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)({
259
+ nodeType: 'document',
260
+ data: {},
261
+ content: [
262
+ null
263
+ ]
264
+ })).toBe(false);
265
+ (0, _vitest.expect)((0, _isEmptyRichTextDocument.isEmptyRichTextDocument)(document({
266
+ nodeType: 'unordered-list',
267
+ data: {},
268
+ content: [
269
+ {
270
+ nodeType: 'list-item',
271
+ data: {},
272
+ content: []
273
+ }
274
+ ]
275
+ }))).toBe(false);
276
+ });
277
+ });
@@ -6,6 +6,88 @@ const _richtexttypes = require("@contentful/rich-text-types");
6
6
  const _vitest = require("vitest");
7
7
  const _testutils = require("../../../test-utils");
8
8
  const _createHeadingPlugin = require("../createHeadingPlugin");
9
+ (0, _vitest.describe)('backward deletion', ()=>{
10
+ _vitest.it.each(_richtexttypes.HEADINGS)('keeps a non-empty %s when Backspace is pressed at the document start', (type)=>{
11
+ const { editor } = (0, _testutils.createTestEditor)({});
12
+ editor.children = [
13
+ {
14
+ type,
15
+ children: [
16
+ {
17
+ text: 'x'
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ type: _richtexttypes.BLOCKS.PARAGRAPH,
23
+ children: [
24
+ {
25
+ text: ''
26
+ }
27
+ ]
28
+ }
29
+ ];
30
+ editor.tf.select({
31
+ path: [
32
+ 0,
33
+ 0
34
+ ],
35
+ offset: 0
36
+ });
37
+ editor.deleteBackward('character');
38
+ (0, _vitest.expect)(editor.children[0]).toMatchObject({
39
+ type,
40
+ children: [
41
+ {
42
+ text: 'x'
43
+ }
44
+ ]
45
+ });
46
+ });
47
+ _vitest.it.each(_richtexttypes.HEADINGS)('removes an empty %s on an additional Backspace', (type)=>{
48
+ const { editor } = (0, _testutils.createTestEditor)({});
49
+ editor.children = [
50
+ {
51
+ type,
52
+ children: [
53
+ {
54
+ text: 'x'
55
+ }
56
+ ]
57
+ },
58
+ {
59
+ type: _richtexttypes.BLOCKS.PARAGRAPH,
60
+ children: [
61
+ {
62
+ text: ''
63
+ }
64
+ ]
65
+ }
66
+ ];
67
+ editor.tf.select({
68
+ path: [
69
+ 0,
70
+ 0
71
+ ],
72
+ offset: 1
73
+ });
74
+ editor.deleteBackward('character');
75
+ (0, _vitest.expect)(editor.children[0]).toMatchObject({
76
+ type,
77
+ children: [
78
+ {
79
+ text: ''
80
+ }
81
+ ]
82
+ });
83
+ editor.deleteBackward('character');
84
+ (0, _vitest.expect)(editor.children[0].type).toBe(_richtexttypes.BLOCKS.PARAGRAPH);
85
+ (0, _vitest.expect)(editor.selection?.anchor.path).toEqual([
86
+ 0,
87
+ 0
88
+ ]);
89
+ });
90
+ });
9
91
  (0, _vitest.describe)('normalization', ()=>{
10
92
  (0, _vitest.it)('can contain inline entries & hyperlinks', ()=>{
11
93
  const input = (0, _testutils.jsx)("editor", null, (0, _testutils.jsx)("hh1", null, "some text before", (0, _testutils.jsx)("hinline", {