@flozy/editor 10.5.8 → 10.6.0
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.
@@ -3,7 +3,6 @@ import { Editor, Text } from "slate";
|
|
3
3
|
import { useSlate } from "slate-react";
|
4
4
|
import { getNodeText } from "../../utils/helper";
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
7
6
|
const isEmptyTextNode = node => {
|
8
7
|
if (Text.isText(node)) {
|
9
8
|
return !node.text.trim();
|
@@ -19,7 +18,7 @@ const Title = props => {
|
|
19
18
|
} = props;
|
20
19
|
const isEmpty = !customProps?.readOnly && isEmptyTextNode(element?.children[0]) ? "empty" : "";
|
21
20
|
useDetectExitFromTitle(element, customProps?.getTitleSaveData);
|
22
|
-
return /*#__PURE__*/
|
21
|
+
return /*#__PURE__*/_jsx("div", {
|
23
22
|
...attributes,
|
24
23
|
placeholder: "Title",
|
25
24
|
className: `content-editable ${isEmpty}`,
|
@@ -27,9 +26,7 @@ const Title = props => {
|
|
27
26
|
fontWeight: "bold",
|
28
27
|
fontSize: "20px"
|
29
28
|
},
|
30
|
-
children:
|
31
|
-
contentEditable: false
|
32
|
-
})]
|
29
|
+
children: children
|
33
30
|
});
|
34
31
|
};
|
35
32
|
export default Title;
|
@@ -49,7 +49,6 @@ import ColumnView from "../Elements/DataView/Layouts/ColumnView";
|
|
49
49
|
import SearchAttachment from "../Elements/Search/SearchAttachment";
|
50
50
|
import { wrapThemeBreakpoints } from "../Elements/FreeGrid/breakpointConstants";
|
51
51
|
import { jsx as _jsx } from "react/jsx-runtime";
|
52
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
53
52
|
const alignment = ["alignLeft", "alignRight", "alignCenter", "alignJustify"];
|
54
53
|
const list_types = ["orderedList", "unorderedList"];
|
55
54
|
const LIST_FORMAT_TYPE = {
|
@@ -421,52 +420,52 @@ export const getBlock = props => {
|
|
421
420
|
const selectedLineHeight = getBreakpointLineSpacing(lineH, breakpoint);
|
422
421
|
switch (element.type) {
|
423
422
|
case "headingOne":
|
424
|
-
return /*#__PURE__*/
|
425
|
-
...
|
423
|
+
return /*#__PURE__*/_jsx("h1", {
|
424
|
+
...attributes,
|
425
|
+
...element.attr,
|
426
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
426
427
|
placeholder: translation("Heading 1"),
|
427
|
-
children:
|
428
|
-
contentEditable: false
|
429
|
-
})]
|
428
|
+
children: children
|
430
429
|
});
|
431
430
|
case "headingTwo":
|
432
|
-
return /*#__PURE__*/
|
433
|
-
...
|
431
|
+
return /*#__PURE__*/_jsx("h2", {
|
432
|
+
...attributes,
|
433
|
+
...element.attr,
|
434
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
434
435
|
placeholder: translation("Heading 2"),
|
435
|
-
children:
|
436
|
-
contentEditable: false
|
437
|
-
})]
|
436
|
+
children: children
|
438
437
|
});
|
439
438
|
case "headingThree":
|
440
|
-
return /*#__PURE__*/
|
441
|
-
...
|
439
|
+
return /*#__PURE__*/_jsx("h3", {
|
440
|
+
...attributes,
|
441
|
+
...element.attr,
|
442
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
442
443
|
placeholder: translation("Heading 3"),
|
443
|
-
children:
|
444
|
-
contentEditable: false
|
445
|
-
})]
|
444
|
+
children: children
|
446
445
|
});
|
447
446
|
case "headingFour":
|
448
|
-
return /*#__PURE__*/
|
449
|
-
...
|
447
|
+
return /*#__PURE__*/_jsx("h4", {
|
448
|
+
...attributes,
|
449
|
+
...element.attr,
|
450
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
450
451
|
placeholder: translation("Heading 4"),
|
451
|
-
children:
|
452
|
-
contentEditable: false
|
453
|
-
})]
|
452
|
+
children: children
|
454
453
|
});
|
455
454
|
case "headingFive":
|
456
|
-
return /*#__PURE__*/
|
457
|
-
...
|
455
|
+
return /*#__PURE__*/_jsx("h5", {
|
456
|
+
...attributes,
|
457
|
+
...element.attr,
|
458
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
458
459
|
placeholder: translation("Heading 5"),
|
459
|
-
children:
|
460
|
-
contentEditable: false
|
461
|
-
})]
|
460
|
+
children: children
|
462
461
|
});
|
463
462
|
case "headingSix":
|
464
|
-
return /*#__PURE__*/
|
465
|
-
...
|
463
|
+
return /*#__PURE__*/_jsx("h6", {
|
464
|
+
...attributes,
|
465
|
+
...element.attr,
|
466
|
+
className: `edt-headings content-editable ${isEmpty ? "empty" : ""} disablePointerEvent`,
|
466
467
|
placeholder: translation("Heading 6"),
|
467
|
-
children:
|
468
|
-
contentEditable: false
|
469
|
-
})]
|
468
|
+
children: children
|
470
469
|
});
|
471
470
|
case "paragraphOne":
|
472
471
|
return /*#__PURE__*/_jsx("p", {
|
@@ -1,6 +1,5 @@
|
|
1
|
-
import { Editor,
|
1
|
+
import { Editor, Element, Transforms } from "slate";
|
2
2
|
import insertNewLine from "./insertNewLine";
|
3
|
-
import { getCurrentNodeText, getSelectedText } from "./helper";
|
4
3
|
import { isMobileWindow } from "../helper";
|
5
4
|
const focusAccordion = (editor, upPath) => {
|
6
5
|
Transforms.select(editor, {
|
@@ -8,77 +7,52 @@ const focusAccordion = (editor, upPath) => {
|
|
8
7
|
offset: 0
|
9
8
|
});
|
10
9
|
};
|
11
|
-
function isSelectionInSingleNode(editor) {
|
12
|
-
const {
|
13
|
-
anchor,
|
14
|
-
focus
|
15
|
-
} = editor.selection;
|
16
|
-
return Editor.path(editor, anchor).toString() === Editor.path(editor, focus).toString();
|
17
|
-
}
|
18
10
|
export const insertAccordion = (editor, path) => {
|
19
11
|
try {
|
20
12
|
const {
|
21
13
|
selection
|
22
14
|
} = editor;
|
23
|
-
|
24
|
-
|
25
|
-
|
15
|
+
if (selection) {
|
16
|
+
const selectedNodes = Array.from(Editor.nodes(editor, {
|
17
|
+
at: selection,
|
18
|
+
match: n => Element.isElement(n),
|
19
|
+
mode: "lowest" // use 'lowest' to get individual blocks
|
20
|
+
}));
|
26
21
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
if (isSingleNodeSelected) {
|
31
|
-
const currentNodeText = selectedText ? getCurrentNodeText(editor) : "";
|
32
|
-
fullySelected = selectedText?.length && currentNodeText.length === selectedText?.length;
|
33
|
-
}
|
34
|
-
const accordion = {
|
35
|
-
type: "accordion",
|
36
|
-
children: [{
|
37
|
-
type: "accordion-summary",
|
38
|
-
children: [{
|
39
|
-
type: "paragraph",
|
40
|
-
children: [{
|
41
|
-
text: selectedText || ""
|
42
|
-
}]
|
43
|
-
}]
|
44
|
-
}, {
|
45
|
-
type: "accordion-details",
|
46
|
-
children: [{
|
47
|
-
type: "paragraph",
|
22
|
+
for (const [node, path] of selectedNodes) {
|
23
|
+
const accordion = {
|
24
|
+
type: "accordion",
|
48
25
|
children: [{
|
49
|
-
|
26
|
+
type: "accordion-summary",
|
27
|
+
children: [node]
|
28
|
+
}, {
|
29
|
+
type: "accordion-details",
|
30
|
+
children: [{
|
31
|
+
type: "paragraph",
|
32
|
+
children: [{
|
33
|
+
text: ""
|
34
|
+
}]
|
35
|
+
}]
|
50
36
|
}]
|
51
|
-
}
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
const
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
const upPath = [...curPath];
|
70
|
-
// get title index
|
71
|
-
const summaryIndex = upPath.length - 3;
|
72
|
-
upPath[summaryIndex] = upPath[summaryIndex] === 0 ? 0 : upPath[summaryIndex] - 1;
|
73
|
-
|
74
|
-
// select accordion title by default
|
75
|
-
if (isMobileWindow()) {
|
76
|
-
// timeout to resolve focus issue in mobile
|
77
|
-
setTimeout(() => focusAccordion(editor, upPath), 0);
|
78
|
-
} else {
|
79
|
-
focusAccordion(editor, upPath);
|
37
|
+
};
|
38
|
+
Transforms.removeNodes(editor, {
|
39
|
+
at: path
|
40
|
+
});
|
41
|
+
Transforms.insertNodes(editor, accordion, {
|
42
|
+
at: path
|
43
|
+
});
|
44
|
+
}
|
45
|
+
const lastNode = selectedNodes[selectedNodes.length - 1];
|
46
|
+
const lastNodePath = lastNode[1];
|
47
|
+
const accordionPath = [...lastNodePath, 0, 0, 0];
|
48
|
+
if (isMobileWindow()) {
|
49
|
+
// timeout to resolve focus issue in mobile
|
50
|
+
setTimeout(() => focusAccordion(editor, accordionPath), 0);
|
51
|
+
} else {
|
52
|
+
focusAccordion(editor, accordionPath);
|
53
|
+
}
|
54
|
+
insertNewLine(editor);
|
80
55
|
}
|
81
|
-
insertNewLine(editor);
|
82
56
|
} catch (err) {
|
83
57
|
console.log(err);
|
84
58
|
}
|