@quadrats/common 1.1.5 → 1.1.7
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.
|
@@ -11,8 +11,8 @@ function createAccordion(options = {}) {
|
|
|
11
11
|
{ type: types.accordion_content, children: [{ text: '' }] },
|
|
12
12
|
],
|
|
13
13
|
});
|
|
14
|
-
const isSelectionInAccordionTitle = editor => isNodesTypeIn(editor, [types.accordion_title]);
|
|
15
|
-
const isSelectionInAccordionContent = editor => isNodesTypeIn(editor, [types.accordion_content]);
|
|
14
|
+
const isSelectionInAccordionTitle = (editor) => isNodesTypeIn(editor, [types.accordion_title]);
|
|
15
|
+
const isSelectionInAccordionContent = (editor) => isNodesTypeIn(editor, [types.accordion_content]);
|
|
16
16
|
const insertAccordion = (editor) => {
|
|
17
17
|
Transforms.insertNodes(editor, createAccordionElement());
|
|
18
18
|
};
|
|
@@ -23,6 +23,7 @@ function createAccordion(options = {}) {
|
|
|
23
23
|
isSelectionInAccordionContent,
|
|
24
24
|
insertAccordion,
|
|
25
25
|
with(editor) {
|
|
26
|
+
const { normalizeNode } = editor;
|
|
26
27
|
editor.normalizeNode = (entry) => {
|
|
27
28
|
const [node, path] = entry;
|
|
28
29
|
if (Element.isElement(node)) {
|
|
@@ -41,7 +42,7 @@ function createAccordion(options = {}) {
|
|
|
41
42
|
}
|
|
42
43
|
else if (type === types.accordion_title || type === types.accordion_content) {
|
|
43
44
|
if (node.children.length !== 1 || !Text.isText(node.children[0])) {
|
|
44
|
-
const mergedText = node.children.map(child => Node.string(child)).join('');
|
|
45
|
+
const mergedText = node.children.map((child) => Node.string(child)).join('');
|
|
45
46
|
const mergedElement = {
|
|
46
47
|
type,
|
|
47
48
|
children: [{ text: mergedText }],
|
|
@@ -53,6 +54,7 @@ function createAccordion(options = {}) {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
57
|
+
normalizeNode(entry);
|
|
56
58
|
};
|
|
57
59
|
return editor;
|
|
58
60
|
},
|
package/accordion/index.cjs.js
CHANGED
|
@@ -21,8 +21,8 @@ function createAccordion(options = {}) {
|
|
|
21
21
|
{ type: types.accordion_content, children: [{ text: '' }] },
|
|
22
22
|
],
|
|
23
23
|
});
|
|
24
|
-
const isSelectionInAccordionTitle = editor => core.isNodesTypeIn(editor, [types.accordion_title]);
|
|
25
|
-
const isSelectionInAccordionContent = editor => core.isNodesTypeIn(editor, [types.accordion_content]);
|
|
24
|
+
const isSelectionInAccordionTitle = (editor) => core.isNodesTypeIn(editor, [types.accordion_title]);
|
|
25
|
+
const isSelectionInAccordionContent = (editor) => core.isNodesTypeIn(editor, [types.accordion_content]);
|
|
26
26
|
const insertAccordion = (editor) => {
|
|
27
27
|
core.Transforms.insertNodes(editor, createAccordionElement());
|
|
28
28
|
};
|
|
@@ -33,6 +33,7 @@ function createAccordion(options = {}) {
|
|
|
33
33
|
isSelectionInAccordionContent,
|
|
34
34
|
insertAccordion,
|
|
35
35
|
with(editor) {
|
|
36
|
+
const { normalizeNode } = editor;
|
|
36
37
|
editor.normalizeNode = (entry) => {
|
|
37
38
|
const [node, path] = entry;
|
|
38
39
|
if (core.Element.isElement(node)) {
|
|
@@ -51,7 +52,7 @@ function createAccordion(options = {}) {
|
|
|
51
52
|
}
|
|
52
53
|
else if (type === types.accordion_title || type === types.accordion_content) {
|
|
53
54
|
if (node.children.length !== 1 || !core.Text.isText(node.children[0])) {
|
|
54
|
-
const mergedText = node.children.map(child => core.Node.string(child)).join('');
|
|
55
|
+
const mergedText = node.children.map((child) => core.Node.string(child)).join('');
|
|
55
56
|
const mergedElement = {
|
|
56
57
|
type,
|
|
57
58
|
children: [{ text: mergedText }],
|
|
@@ -63,6 +64,7 @@ function createAccordion(options = {}) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
}
|
|
67
|
+
normalizeNode(entry);
|
|
66
68
|
};
|
|
67
69
|
return editor;
|
|
68
70
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isNodesTypeIn, Editor, wrapNodesWithUnhangRange, unwrapNodesByTypes } from '@quadrats/core';
|
|
1
|
+
import { isNodesTypeIn, Element, Node, Editor, wrapNodesWithUnhangRange, unwrapNodesByTypes } from '@quadrats/core';
|
|
2
2
|
import { BLOCKQUOTE_TYPE } from './constants.js';
|
|
3
3
|
import { TABLE_CELL_TYPE } from '@quadrats/common/table';
|
|
4
4
|
|
|
@@ -47,6 +47,22 @@ function createBlockquote({ type = BLOCKQUOTE_TYPE } = {}) {
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
with(editor) {
|
|
50
|
+
const { normalizeNode } = editor;
|
|
51
|
+
editor.normalizeNode = (entry) => {
|
|
52
|
+
const [node, path] = entry;
|
|
53
|
+
if (Element.isElement(node)) {
|
|
54
|
+
const currentType = node.type;
|
|
55
|
+
if (currentType === type) {
|
|
56
|
+
for (const [child] of Node.children(editor, path)) {
|
|
57
|
+
if (Element.isElement(child) && child.type === type) {
|
|
58
|
+
unwrapBlockquote(editor);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
normalizeNode(entry);
|
|
65
|
+
};
|
|
50
66
|
return editor;
|
|
51
67
|
},
|
|
52
68
|
};
|
package/blockquote/index.cjs.js
CHANGED
|
@@ -50,6 +50,22 @@ function createBlockquote({ type = BLOCKQUOTE_TYPE } = {}) {
|
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
with(editor) {
|
|
53
|
+
const { normalizeNode } = editor;
|
|
54
|
+
editor.normalizeNode = (entry) => {
|
|
55
|
+
const [node, path] = entry;
|
|
56
|
+
if (core.Element.isElement(node)) {
|
|
57
|
+
const currentType = node.type;
|
|
58
|
+
if (currentType === type) {
|
|
59
|
+
for (const [child] of core.Node.children(editor, path)) {
|
|
60
|
+
if (core.Element.isElement(child) && child.type === type) {
|
|
61
|
+
unwrapBlockquote(editor);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
normalizeNode(entry);
|
|
68
|
+
};
|
|
53
69
|
return editor;
|
|
54
70
|
},
|
|
55
71
|
};
|
package/package.json
CHANGED
package/table/createTable.js
CHANGED
|
@@ -223,7 +223,7 @@ function createTable(options = {}) {
|
|
|
223
223
|
extendSelectionUp,
|
|
224
224
|
extendSelectionDown,
|
|
225
225
|
with(editor) {
|
|
226
|
-
const { insertFragment, deleteBackward } = editor;
|
|
226
|
+
const { insertFragment, deleteBackward, normalizeNode } = editor;
|
|
227
227
|
editor.normalizeNode = (entry) => {
|
|
228
228
|
const [node, path] = entry;
|
|
229
229
|
if (Element.isElement(node)) {
|
|
@@ -360,6 +360,7 @@ function createTable(options = {}) {
|
|
|
360
360
|
}
|
|
361
361
|
}
|
|
362
362
|
}
|
|
363
|
+
normalizeNode(entry);
|
|
363
364
|
};
|
|
364
365
|
editor.deleteBackward = (unit) => {
|
|
365
366
|
const { selection } = editor;
|
package/table/index.cjs.js
CHANGED
|
@@ -487,7 +487,7 @@ function createTable(options = {}) {
|
|
|
487
487
|
extendSelectionUp,
|
|
488
488
|
extendSelectionDown,
|
|
489
489
|
with(editor) {
|
|
490
|
-
const { insertFragment, deleteBackward } = editor;
|
|
490
|
+
const { insertFragment, deleteBackward, normalizeNode } = editor;
|
|
491
491
|
editor.normalizeNode = (entry) => {
|
|
492
492
|
const [node, path] = entry;
|
|
493
493
|
if (core.Element.isElement(node)) {
|
|
@@ -624,6 +624,7 @@ function createTable(options = {}) {
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
}
|
|
627
|
+
normalizeNode(entry);
|
|
627
628
|
};
|
|
628
629
|
editor.deleteBackward = (unit) => {
|
|
629
630
|
const { selection } = editor;
|