microboard-temp 0.4.4 → 0.4.6
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/cjs/browser.js +61 -36
- package/dist/cjs/index.js +61 -36
- package/dist/cjs/node.js +61 -36
- package/dist/esm/browser.js +62 -37
- package/dist/esm/index.js +62 -37
- package/dist/esm/node.js +62 -37
- package/dist/types/Items/Connector/getLine/getCurvedLine.d.ts +2 -2
- package/dist/types/Items/Connector/getLine/getOrthogonalLine.d.ts +2 -2
- package/dist/types/Items/RichText/CanvasText/LayoutBlockNodes.d.ts +2 -1
- package/dist/types/Items/RichText/CanvasText/Render.d.ts +61 -0
- package/dist/types/Items/RichText/Editor/BlockNode.d.ts +4 -11
- package/dist/types/Items/RichText/EditorContainer.d.ts +2 -2
- package/dist/types/Items/RichText/editorHelpers/common/getAreAllChildrenEmpty.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -9695,17 +9695,18 @@ function getBlockNode(data, maxWidth, isFrame, listData, listMark, newLine = fal
|
|
|
9695
9695
|
break;
|
|
9696
9696
|
default:
|
|
9697
9697
|
if ("text" in child && typeof child.text === "string") {
|
|
9698
|
-
const
|
|
9698
|
+
const textNode = child;
|
|
9699
|
+
const fontScale2 = (textNode.fontSize === "auto" ? 14 : textNode.fontSize ?? 14) / 14;
|
|
9699
9700
|
handleTextNode({
|
|
9700
9701
|
isFrame,
|
|
9701
|
-
child,
|
|
9702
|
+
child: textNode,
|
|
9702
9703
|
node,
|
|
9703
9704
|
maxWidth,
|
|
9704
9705
|
paddingTop: i === 0 ? 16 * (data.paddingTop || 0) : 0,
|
|
9705
9706
|
marginLeft: (listData ? fontScale2 * 16 : 0) + (listData?.level || 0) * fontScale2 * 24,
|
|
9706
9707
|
newLine: i === 0 ? newLine : false,
|
|
9707
9708
|
listMark: i === 0 ? listMark : undefined,
|
|
9708
|
-
link:
|
|
9709
|
+
link: textNode.link
|
|
9709
9710
|
});
|
|
9710
9711
|
} else {
|
|
9711
9712
|
const blockNode = getBlockNode(child, maxWidth, isFrame, listData, i === 0 ? listMark : undefined, true);
|
|
@@ -9749,7 +9750,8 @@ function getTextNode(data) {
|
|
|
9749
9750
|
type: "text",
|
|
9750
9751
|
text,
|
|
9751
9752
|
style: getTextStyle(data),
|
|
9752
|
-
blocks: []
|
|
9753
|
+
blocks: [],
|
|
9754
|
+
newLine: false
|
|
9753
9755
|
};
|
|
9754
9756
|
return node;
|
|
9755
9757
|
}
|
|
@@ -9995,7 +9997,7 @@ function setBlockNodeCoordinates(blockNode) {
|
|
|
9995
9997
|
}
|
|
9996
9998
|
lineBottom += maxFontSize * lineHeight;
|
|
9997
9999
|
leading = maxFontSize * lineHeight - maxFontSize;
|
|
9998
|
-
yOffset = lineBottom - leading / 2 - highestBlock
|
|
10000
|
+
yOffset = lineBottom - leading / 2 - (highestBlock?.measure.descent || 0);
|
|
9999
10001
|
for (const block of line) {
|
|
10000
10002
|
block.y = yOffset;
|
|
10001
10003
|
}
|
|
@@ -10019,7 +10021,7 @@ function getTextBlock({
|
|
|
10019
10021
|
x: 0,
|
|
10020
10022
|
y: 0,
|
|
10021
10023
|
measure,
|
|
10022
|
-
fontSize: style.fontSize,
|
|
10024
|
+
fontSize: style.fontSize === "auto" ? 14 : style.fontSize,
|
|
10023
10025
|
paddingTop,
|
|
10024
10026
|
marginLeft,
|
|
10025
10027
|
listMark,
|
|
@@ -10537,7 +10539,7 @@ function handleListMerge(editor) {
|
|
|
10537
10539
|
return false;
|
|
10538
10540
|
}
|
|
10539
10541
|
const [textNode, textNodePath] = import_slate3.Editor.node(editor, anchor.path);
|
|
10540
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10542
|
+
if (!textNode || import_slate3.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
10541
10543
|
return false;
|
|
10542
10544
|
}
|
|
10543
10545
|
const paragraphPath = import_slate3.Path.parent(textNodePath);
|
|
@@ -10547,12 +10549,12 @@ function handleListMerge(editor) {
|
|
|
10547
10549
|
}
|
|
10548
10550
|
const listItemPath = import_slate3.Path.parent(paragraphPath);
|
|
10549
10551
|
const [listItem] = import_slate3.Editor.node(editor, listItemPath);
|
|
10550
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10552
|
+
if (!listItem || import_slate3.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10551
10553
|
return false;
|
|
10552
10554
|
}
|
|
10553
10555
|
const listPath = import_slate3.Path.parent(listItemPath);
|
|
10554
10556
|
const [list] = import_slate3.Editor.node(editor, listPath);
|
|
10555
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10557
|
+
if (!list || import_slate3.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10556
10558
|
return false;
|
|
10557
10559
|
}
|
|
10558
10560
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
@@ -10586,6 +10588,9 @@ function handleListMerge(editor) {
|
|
|
10586
10588
|
} else {
|
|
10587
10589
|
const previousItemPath = import_slate3.Path.previous(listItemPath);
|
|
10588
10590
|
const [previousItem] = import_slate3.Editor.node(editor, previousItemPath);
|
|
10591
|
+
if ("text" in previousItem) {
|
|
10592
|
+
return false;
|
|
10593
|
+
}
|
|
10589
10594
|
currentListItemChildren.forEach((childNode, index) => {
|
|
10590
10595
|
const copiedNode = structuredClone(childNode);
|
|
10591
10596
|
copiedNode.paddingTop = 0;
|
|
@@ -10617,7 +10622,18 @@ function createParagraphNode(text, editor, horisontalAlignment) {
|
|
|
10617
10622
|
const marks = import_slate4.Editor.marks(editor) || {};
|
|
10618
10623
|
const pargaraph = {
|
|
10619
10624
|
type: "paragraph",
|
|
10620
|
-
children: [{
|
|
10625
|
+
children: [{
|
|
10626
|
+
type: "text",
|
|
10627
|
+
text,
|
|
10628
|
+
...marks,
|
|
10629
|
+
bold: false,
|
|
10630
|
+
italic: false,
|
|
10631
|
+
underline: false,
|
|
10632
|
+
overline: false,
|
|
10633
|
+
"line-through": false,
|
|
10634
|
+
subscript: false,
|
|
10635
|
+
superscript: false
|
|
10636
|
+
}]
|
|
10621
10637
|
};
|
|
10622
10638
|
if (horisontalAlignment) {
|
|
10623
10639
|
pargaraph.horisontalAlignment = horisontalAlignment;
|
|
@@ -10671,6 +10687,9 @@ function handleSplitListItem(editor) {
|
|
|
10671
10687
|
if (isBlockEmpty && isOnlyChildParagraph) {
|
|
10672
10688
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
10673
10689
|
const [parentList, parentListPath] = import_slate5.Editor.parent(editor, listItemPath);
|
|
10690
|
+
if (import_slate5.Editor.isEditor(parentList) || parentList.type !== "ol_list" && parentList.type !== "ul_list") {
|
|
10691
|
+
return false;
|
|
10692
|
+
}
|
|
10674
10693
|
const listType = parentList.type;
|
|
10675
10694
|
import_slate5.Editor.withoutNormalizing(editor, () => {
|
|
10676
10695
|
const nextPath = import_slate5.Path.next(parentListPath);
|
|
@@ -10695,6 +10714,9 @@ function handleSplitListItem(editor) {
|
|
|
10695
10714
|
match: (n, path2) => path2[path2.length - 1] >= listItemIndex
|
|
10696
10715
|
});
|
|
10697
10716
|
const [updatedParentList] = import_slate5.Editor.node(editor, parentListPath);
|
|
10717
|
+
if (import_slate5.Editor.isEditor(updatedParentList)) {
|
|
10718
|
+
return false;
|
|
10719
|
+
}
|
|
10698
10720
|
if (getAreAllChildrenEmpty(updatedParentList)) {
|
|
10699
10721
|
import_slate5.Transforms.removeNodes(editor, { at: parentListPath });
|
|
10700
10722
|
}
|
|
@@ -10726,7 +10748,7 @@ var import_slate7 = require("slate");
|
|
|
10726
10748
|
var import_slate6 = require("slate");
|
|
10727
10749
|
function clearAllTextNodes(editor) {
|
|
10728
10750
|
for (const [node, path2] of import_slate6.Editor.nodes(editor, {
|
|
10729
|
-
match: (n) => n.type === "text"
|
|
10751
|
+
match: (n) => !import_slate6.Editor.isEditor(n) && n.type === "text"
|
|
10730
10752
|
})) {
|
|
10731
10753
|
import_slate6.Transforms.removeNodes(editor, { at: path2 });
|
|
10732
10754
|
import_slate6.Transforms.setNodes(editor, { ...node, text: "" }, { at: path2 });
|
|
@@ -10761,7 +10783,7 @@ function handleWrapIntoNestedList(editor) {
|
|
|
10761
10783
|
}
|
|
10762
10784
|
const { anchor } = selection;
|
|
10763
10785
|
const [textNode, textNodePath] = import_slate8.Editor.node(editor, anchor.path);
|
|
10764
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10786
|
+
if (!textNode || import_slate8.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
10765
10787
|
return false;
|
|
10766
10788
|
}
|
|
10767
10789
|
const paragraphPath = import_slate8.Path.parent(textNodePath);
|
|
@@ -10771,12 +10793,12 @@ function handleWrapIntoNestedList(editor) {
|
|
|
10771
10793
|
}
|
|
10772
10794
|
const listItemPath = import_slate8.Path.parent(paragraphPath);
|
|
10773
10795
|
const [listItem] = import_slate8.Editor.node(editor, listItemPath);
|
|
10774
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10796
|
+
if (!listItem || import_slate8.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10775
10797
|
return false;
|
|
10776
10798
|
}
|
|
10777
10799
|
const listPath = import_slate8.Path.parent(listItemPath);
|
|
10778
10800
|
const [list] = import_slate8.Editor.node(editor, listPath);
|
|
10779
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10801
|
+
if (!list || import_slate8.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10780
10802
|
return false;
|
|
10781
10803
|
}
|
|
10782
10804
|
import_slate8.Transforms.wrapNodes(editor, { type: "list_item", children: [] }, { at: paragraphPath });
|
|
@@ -10806,12 +10828,12 @@ var import_slate10 = require("slate");
|
|
|
10806
10828
|
function getBlockParentList(editor, blockPath) {
|
|
10807
10829
|
const listItemPath = import_slate10.Path.parent(blockPath);
|
|
10808
10830
|
const [listItem] = import_slate10.Editor.node(editor, listItemPath);
|
|
10809
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10831
|
+
if (!listItem || import_slate10.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10810
10832
|
return null;
|
|
10811
10833
|
}
|
|
10812
10834
|
const listPath = import_slate10.Path.parent(listItemPath);
|
|
10813
10835
|
const [list] = import_slate10.Editor.node(editor, listPath);
|
|
10814
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10836
|
+
if (!list || import_slate10.Editor.isEditor(listItem) || "type" in list && list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10815
10837
|
return null;
|
|
10816
10838
|
}
|
|
10817
10839
|
return [list, listPath];
|
|
@@ -10824,17 +10846,16 @@ function toggleListTypeForSelection(editor, targetListType) {
|
|
|
10824
10846
|
return false;
|
|
10825
10847
|
}
|
|
10826
10848
|
import_slate11.Editor.withoutNormalizing(editor, () => {
|
|
10827
|
-
const [start, end] = import_slate11.Range.edges(selection);
|
|
10828
|
-
const commonAncestorPath = import_slate11.Path.common(start.path, end.path);
|
|
10829
10849
|
const nodes = Array.from(import_slate11.Editor.nodes(editor, {
|
|
10830
10850
|
at: selection,
|
|
10831
10851
|
mode: "lowest",
|
|
10832
|
-
match: (n) => import_slate11.Editor.isBlock(editor, n)
|
|
10852
|
+
match: (n) => !import_slate11.Editor.isEditor(n) && n.type !== "text" && import_slate11.Editor.isBlock(editor, n)
|
|
10833
10853
|
}));
|
|
10834
10854
|
const nodesWithLists = {};
|
|
10835
10855
|
const unwrapCandidates = [];
|
|
10836
10856
|
nodes.forEach(([node, path2]) => {
|
|
10837
10857
|
const parentList = getBlockParentList(editor, path2);
|
|
10858
|
+
node = node;
|
|
10838
10859
|
if (parentList) {
|
|
10839
10860
|
unwrapCandidates.push(node);
|
|
10840
10861
|
if (!nodesWithLists[parentList[1].length]) {
|
|
@@ -10944,7 +10965,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10944
10965
|
import_slate12.Editor.withoutNormalizing(editor, () => {
|
|
10945
10966
|
const { anchor } = selection;
|
|
10946
10967
|
const [textNode, textNodePath] = import_slate12.Editor.node(editor, anchor.path);
|
|
10947
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10968
|
+
if (!textNode || import_slate12.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode)) {
|
|
10948
10969
|
result = false;
|
|
10949
10970
|
return;
|
|
10950
10971
|
}
|
|
@@ -10956,7 +10977,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10956
10977
|
}
|
|
10957
10978
|
const listItemPath = import_slate12.Path.parent(paragraphPath);
|
|
10958
10979
|
const [listItem] = import_slate12.Editor.node(editor, listItemPath);
|
|
10959
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10980
|
+
if (!listItem || import_slate12.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10960
10981
|
if (shouldWrap) {
|
|
10961
10982
|
wrapIntoList(editor, targetListType, selection);
|
|
10962
10983
|
return;
|
|
@@ -10966,7 +10987,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10966
10987
|
}
|
|
10967
10988
|
const listPath = import_slate12.Path.parent(listItemPath);
|
|
10968
10989
|
const [list] = import_slate12.Editor.node(editor, listPath);
|
|
10969
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10990
|
+
if (!list || import_slate12.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10970
10991
|
if (shouldWrap) {
|
|
10971
10992
|
wrapIntoList(editor, targetListType, selection);
|
|
10972
10993
|
return;
|
|
@@ -11048,7 +11069,7 @@ function getListTypeAtSelectionStart(editor) {
|
|
|
11048
11069
|
const startPoint = import_slate14.Range.start(selection);
|
|
11049
11070
|
const listEntry = import_slate14.Editor.above(editor, {
|
|
11050
11071
|
at: startPoint,
|
|
11051
|
-
match: (n) => n.type === "ol_list" || n.type === "ul_list"
|
|
11072
|
+
match: (n) => !import_slate14.Editor.isEditor(n) && (n.type === "ol_list" || n.type === "ul_list")
|
|
11052
11073
|
});
|
|
11053
11074
|
if (listEntry) {
|
|
11054
11075
|
const [listNode] = listEntry;
|
|
@@ -11071,11 +11092,11 @@ var setLink = (editor, link, selection) => {
|
|
|
11071
11092
|
const format = link ? "rgba(71, 120, 245, 1)" : "rgb(20, 21, 26)";
|
|
11072
11093
|
import_slate15.Editor.addMark(editor, "fontColor", format);
|
|
11073
11094
|
for (const [node, path2] of import_slate15.Editor.nodes(editor, {
|
|
11074
|
-
match: (n) => n.type === "text"
|
|
11095
|
+
match: (n) => !import_slate15.Editor.isEditor(n) && n.type === "text"
|
|
11075
11096
|
})) {
|
|
11076
11097
|
const nodeRange = import_slate15.Editor.range(editor, path2);
|
|
11077
11098
|
import_slate15.Transforms.select(editor, nodeRange);
|
|
11078
|
-
import_slate15.Transforms.setNodes(editor, { link }, { split: false, match: (n) => n.type === "text" });
|
|
11099
|
+
import_slate15.Transforms.setNodes(editor, { link }, { split: false, match: (n) => !import_slate15.Editor.isEditor(n) && n.type === "text" });
|
|
11079
11100
|
}
|
|
11080
11101
|
};
|
|
11081
11102
|
|
|
@@ -17465,7 +17486,7 @@ function getFirstSelectionLink(editor, selection) {
|
|
|
17465
17486
|
}
|
|
17466
17487
|
for (const [node2] of import_slate23.Editor.nodes(editor, {
|
|
17467
17488
|
at: selection,
|
|
17468
|
-
match: (n) => !!n.link
|
|
17489
|
+
match: (n) => ("link" in n) && !!n.link
|
|
17469
17490
|
})) {
|
|
17470
17491
|
return node2.link;
|
|
17471
17492
|
}
|
|
@@ -17771,15 +17792,17 @@ class EditorContainer {
|
|
|
17771
17792
|
if (isRecordingOperations) {
|
|
17772
17793
|
const isSettingNodeFontSize = operation.type === "set_node" && "fontSize" in operation.newProperties && "fontSize" in operation.properties;
|
|
17773
17794
|
if (isSettingNodeFontSize) {
|
|
17774
|
-
const
|
|
17795
|
+
const newProperties = operation.newProperties;
|
|
17796
|
+
const properties = operation.properties;
|
|
17797
|
+
const isSettingNodeFontSizeToAuto = newProperties.fontSize === "auto";
|
|
17775
17798
|
if (isSettingNodeFontSizeToAuto) {
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17799
|
+
newProperties.fontSize = 14;
|
|
17800
|
+
newProperties.enableAuto = true;
|
|
17801
|
+
properties.enableAuto = false;
|
|
17779
17802
|
} else {
|
|
17780
|
-
|
|
17803
|
+
newProperties.enableAuto = false;
|
|
17781
17804
|
if (this.getAutosize()) {
|
|
17782
|
-
|
|
17805
|
+
properties.enableAuto = true;
|
|
17783
17806
|
}
|
|
17784
17807
|
}
|
|
17785
17808
|
}
|
|
@@ -17862,7 +17885,7 @@ class EditorContainer {
|
|
|
17862
17885
|
stopOpRecordingAndGetOps() {
|
|
17863
17886
|
const op = this.recordedOps;
|
|
17864
17887
|
this.recordedOps = null;
|
|
17865
|
-
const opsArr = op
|
|
17888
|
+
const opsArr = op ? "ops" in op ? op.ops : op : [];
|
|
17866
17889
|
return opsArr.filter((op2) => op2.type !== "set_selection");
|
|
17867
17890
|
}
|
|
17868
17891
|
applyRichTextOp(op) {
|
|
@@ -17885,7 +17908,6 @@ class EditorContainer {
|
|
|
17885
17908
|
case "setSelectionHorizontalAlignment":
|
|
17886
17909
|
this.applySelectionOp(op);
|
|
17887
17910
|
break;
|
|
17888
|
-
case "setBlockType":
|
|
17889
17911
|
case "setFontStyle":
|
|
17890
17912
|
case "setFontColor":
|
|
17891
17913
|
case "setFontFamily":
|
|
@@ -17900,7 +17922,11 @@ class EditorContainer {
|
|
|
17900
17922
|
}
|
|
17901
17923
|
} catch (error) {
|
|
17902
17924
|
console.error("Error in applying RichText Operation in Item: ", this.id, error);
|
|
17903
|
-
|
|
17925
|
+
const operations2 = [];
|
|
17926
|
+
if ("ops" in op && Array.isArray(op.ops)) {
|
|
17927
|
+
operations2.push(...op.ops.map((op2) => op2.type));
|
|
17928
|
+
}
|
|
17929
|
+
console.error("Error applying this type operation: ", operations2);
|
|
17904
17930
|
}
|
|
17905
17931
|
}
|
|
17906
17932
|
applySelectionEdit(op) {
|
|
@@ -17930,7 +17956,6 @@ class EditorContainer {
|
|
|
17930
17956
|
this.setSelectionFontColor(op.fontColor);
|
|
17931
17957
|
break;
|
|
17932
17958
|
case "setFontFamily":
|
|
17933
|
-
this.setSelectionFontFamily(op.fontFamily);
|
|
17934
17959
|
break;
|
|
17935
17960
|
case "setFontSize":
|
|
17936
17961
|
this.textScale = Number(op.fontSize) / this.getScale() / this.initialTextStyles.fontSize;
|
package/dist/cjs/index.js
CHANGED
|
@@ -9695,17 +9695,18 @@ function getBlockNode(data, maxWidth, isFrame, listData, listMark, newLine = fal
|
|
|
9695
9695
|
break;
|
|
9696
9696
|
default:
|
|
9697
9697
|
if ("text" in child && typeof child.text === "string") {
|
|
9698
|
-
const
|
|
9698
|
+
const textNode = child;
|
|
9699
|
+
const fontScale2 = (textNode.fontSize === "auto" ? 14 : textNode.fontSize ?? 14) / 14;
|
|
9699
9700
|
handleTextNode({
|
|
9700
9701
|
isFrame,
|
|
9701
|
-
child,
|
|
9702
|
+
child: textNode,
|
|
9702
9703
|
node,
|
|
9703
9704
|
maxWidth,
|
|
9704
9705
|
paddingTop: i === 0 ? 16 * (data.paddingTop || 0) : 0,
|
|
9705
9706
|
marginLeft: (listData ? fontScale2 * 16 : 0) + (listData?.level || 0) * fontScale2 * 24,
|
|
9706
9707
|
newLine: i === 0 ? newLine : false,
|
|
9707
9708
|
listMark: i === 0 ? listMark : undefined,
|
|
9708
|
-
link:
|
|
9709
|
+
link: textNode.link
|
|
9709
9710
|
});
|
|
9710
9711
|
} else {
|
|
9711
9712
|
const blockNode = getBlockNode(child, maxWidth, isFrame, listData, i === 0 ? listMark : undefined, true);
|
|
@@ -9749,7 +9750,8 @@ function getTextNode(data) {
|
|
|
9749
9750
|
type: "text",
|
|
9750
9751
|
text,
|
|
9751
9752
|
style: getTextStyle(data),
|
|
9752
|
-
blocks: []
|
|
9753
|
+
blocks: [],
|
|
9754
|
+
newLine: false
|
|
9753
9755
|
};
|
|
9754
9756
|
return node;
|
|
9755
9757
|
}
|
|
@@ -9995,7 +9997,7 @@ function setBlockNodeCoordinates(blockNode) {
|
|
|
9995
9997
|
}
|
|
9996
9998
|
lineBottom += maxFontSize * lineHeight;
|
|
9997
9999
|
leading = maxFontSize * lineHeight - maxFontSize;
|
|
9998
|
-
yOffset = lineBottom - leading / 2 - highestBlock
|
|
10000
|
+
yOffset = lineBottom - leading / 2 - (highestBlock?.measure.descent || 0);
|
|
9999
10001
|
for (const block of line) {
|
|
10000
10002
|
block.y = yOffset;
|
|
10001
10003
|
}
|
|
@@ -10019,7 +10021,7 @@ function getTextBlock({
|
|
|
10019
10021
|
x: 0,
|
|
10020
10022
|
y: 0,
|
|
10021
10023
|
measure,
|
|
10022
|
-
fontSize: style.fontSize,
|
|
10024
|
+
fontSize: style.fontSize === "auto" ? 14 : style.fontSize,
|
|
10023
10025
|
paddingTop,
|
|
10024
10026
|
marginLeft,
|
|
10025
10027
|
listMark,
|
|
@@ -10537,7 +10539,7 @@ function handleListMerge(editor) {
|
|
|
10537
10539
|
return false;
|
|
10538
10540
|
}
|
|
10539
10541
|
const [textNode, textNodePath] = import_slate3.Editor.node(editor, anchor.path);
|
|
10540
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10542
|
+
if (!textNode || import_slate3.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
10541
10543
|
return false;
|
|
10542
10544
|
}
|
|
10543
10545
|
const paragraphPath = import_slate3.Path.parent(textNodePath);
|
|
@@ -10547,12 +10549,12 @@ function handleListMerge(editor) {
|
|
|
10547
10549
|
}
|
|
10548
10550
|
const listItemPath = import_slate3.Path.parent(paragraphPath);
|
|
10549
10551
|
const [listItem] = import_slate3.Editor.node(editor, listItemPath);
|
|
10550
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10552
|
+
if (!listItem || import_slate3.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10551
10553
|
return false;
|
|
10552
10554
|
}
|
|
10553
10555
|
const listPath = import_slate3.Path.parent(listItemPath);
|
|
10554
10556
|
const [list] = import_slate3.Editor.node(editor, listPath);
|
|
10555
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10557
|
+
if (!list || import_slate3.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10556
10558
|
return false;
|
|
10557
10559
|
}
|
|
10558
10560
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
@@ -10586,6 +10588,9 @@ function handleListMerge(editor) {
|
|
|
10586
10588
|
} else {
|
|
10587
10589
|
const previousItemPath = import_slate3.Path.previous(listItemPath);
|
|
10588
10590
|
const [previousItem] = import_slate3.Editor.node(editor, previousItemPath);
|
|
10591
|
+
if ("text" in previousItem) {
|
|
10592
|
+
return false;
|
|
10593
|
+
}
|
|
10589
10594
|
currentListItemChildren.forEach((childNode, index) => {
|
|
10590
10595
|
const copiedNode = structuredClone(childNode);
|
|
10591
10596
|
copiedNode.paddingTop = 0;
|
|
@@ -10617,7 +10622,18 @@ function createParagraphNode(text, editor, horisontalAlignment) {
|
|
|
10617
10622
|
const marks = import_slate4.Editor.marks(editor) || {};
|
|
10618
10623
|
const pargaraph = {
|
|
10619
10624
|
type: "paragraph",
|
|
10620
|
-
children: [{
|
|
10625
|
+
children: [{
|
|
10626
|
+
type: "text",
|
|
10627
|
+
text,
|
|
10628
|
+
...marks,
|
|
10629
|
+
bold: false,
|
|
10630
|
+
italic: false,
|
|
10631
|
+
underline: false,
|
|
10632
|
+
overline: false,
|
|
10633
|
+
"line-through": false,
|
|
10634
|
+
subscript: false,
|
|
10635
|
+
superscript: false
|
|
10636
|
+
}]
|
|
10621
10637
|
};
|
|
10622
10638
|
if (horisontalAlignment) {
|
|
10623
10639
|
pargaraph.horisontalAlignment = horisontalAlignment;
|
|
@@ -10671,6 +10687,9 @@ function handleSplitListItem(editor) {
|
|
|
10671
10687
|
if (isBlockEmpty && isOnlyChildParagraph) {
|
|
10672
10688
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
10673
10689
|
const [parentList, parentListPath] = import_slate5.Editor.parent(editor, listItemPath);
|
|
10690
|
+
if (import_slate5.Editor.isEditor(parentList) || parentList.type !== "ol_list" && parentList.type !== "ul_list") {
|
|
10691
|
+
return false;
|
|
10692
|
+
}
|
|
10674
10693
|
const listType = parentList.type;
|
|
10675
10694
|
import_slate5.Editor.withoutNormalizing(editor, () => {
|
|
10676
10695
|
const nextPath = import_slate5.Path.next(parentListPath);
|
|
@@ -10695,6 +10714,9 @@ function handleSplitListItem(editor) {
|
|
|
10695
10714
|
match: (n, path2) => path2[path2.length - 1] >= listItemIndex
|
|
10696
10715
|
});
|
|
10697
10716
|
const [updatedParentList] = import_slate5.Editor.node(editor, parentListPath);
|
|
10717
|
+
if (import_slate5.Editor.isEditor(updatedParentList)) {
|
|
10718
|
+
return false;
|
|
10719
|
+
}
|
|
10698
10720
|
if (getAreAllChildrenEmpty(updatedParentList)) {
|
|
10699
10721
|
import_slate5.Transforms.removeNodes(editor, { at: parentListPath });
|
|
10700
10722
|
}
|
|
@@ -10726,7 +10748,7 @@ var import_slate7 = require("slate");
|
|
|
10726
10748
|
var import_slate6 = require("slate");
|
|
10727
10749
|
function clearAllTextNodes(editor) {
|
|
10728
10750
|
for (const [node, path2] of import_slate6.Editor.nodes(editor, {
|
|
10729
|
-
match: (n) => n.type === "text"
|
|
10751
|
+
match: (n) => !import_slate6.Editor.isEditor(n) && n.type === "text"
|
|
10730
10752
|
})) {
|
|
10731
10753
|
import_slate6.Transforms.removeNodes(editor, { at: path2 });
|
|
10732
10754
|
import_slate6.Transforms.setNodes(editor, { ...node, text: "" }, { at: path2 });
|
|
@@ -10761,7 +10783,7 @@ function handleWrapIntoNestedList(editor) {
|
|
|
10761
10783
|
}
|
|
10762
10784
|
const { anchor } = selection;
|
|
10763
10785
|
const [textNode, textNodePath] = import_slate8.Editor.node(editor, anchor.path);
|
|
10764
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10786
|
+
if (!textNode || import_slate8.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
10765
10787
|
return false;
|
|
10766
10788
|
}
|
|
10767
10789
|
const paragraphPath = import_slate8.Path.parent(textNodePath);
|
|
@@ -10771,12 +10793,12 @@ function handleWrapIntoNestedList(editor) {
|
|
|
10771
10793
|
}
|
|
10772
10794
|
const listItemPath = import_slate8.Path.parent(paragraphPath);
|
|
10773
10795
|
const [listItem] = import_slate8.Editor.node(editor, listItemPath);
|
|
10774
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10796
|
+
if (!listItem || import_slate8.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10775
10797
|
return false;
|
|
10776
10798
|
}
|
|
10777
10799
|
const listPath = import_slate8.Path.parent(listItemPath);
|
|
10778
10800
|
const [list] = import_slate8.Editor.node(editor, listPath);
|
|
10779
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10801
|
+
if (!list || import_slate8.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10780
10802
|
return false;
|
|
10781
10803
|
}
|
|
10782
10804
|
import_slate8.Transforms.wrapNodes(editor, { type: "list_item", children: [] }, { at: paragraphPath });
|
|
@@ -10806,12 +10828,12 @@ var import_slate10 = require("slate");
|
|
|
10806
10828
|
function getBlockParentList(editor, blockPath) {
|
|
10807
10829
|
const listItemPath = import_slate10.Path.parent(blockPath);
|
|
10808
10830
|
const [listItem] = import_slate10.Editor.node(editor, listItemPath);
|
|
10809
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10831
|
+
if (!listItem || import_slate10.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10810
10832
|
return null;
|
|
10811
10833
|
}
|
|
10812
10834
|
const listPath = import_slate10.Path.parent(listItemPath);
|
|
10813
10835
|
const [list] = import_slate10.Editor.node(editor, listPath);
|
|
10814
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10836
|
+
if (!list || import_slate10.Editor.isEditor(listItem) || "type" in list && list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10815
10837
|
return null;
|
|
10816
10838
|
}
|
|
10817
10839
|
return [list, listPath];
|
|
@@ -10824,17 +10846,16 @@ function toggleListTypeForSelection(editor, targetListType) {
|
|
|
10824
10846
|
return false;
|
|
10825
10847
|
}
|
|
10826
10848
|
import_slate11.Editor.withoutNormalizing(editor, () => {
|
|
10827
|
-
const [start, end] = import_slate11.Range.edges(selection);
|
|
10828
|
-
const commonAncestorPath = import_slate11.Path.common(start.path, end.path);
|
|
10829
10849
|
const nodes = Array.from(import_slate11.Editor.nodes(editor, {
|
|
10830
10850
|
at: selection,
|
|
10831
10851
|
mode: "lowest",
|
|
10832
|
-
match: (n) => import_slate11.Editor.isBlock(editor, n)
|
|
10852
|
+
match: (n) => !import_slate11.Editor.isEditor(n) && n.type !== "text" && import_slate11.Editor.isBlock(editor, n)
|
|
10833
10853
|
}));
|
|
10834
10854
|
const nodesWithLists = {};
|
|
10835
10855
|
const unwrapCandidates = [];
|
|
10836
10856
|
nodes.forEach(([node, path2]) => {
|
|
10837
10857
|
const parentList = getBlockParentList(editor, path2);
|
|
10858
|
+
node = node;
|
|
10838
10859
|
if (parentList) {
|
|
10839
10860
|
unwrapCandidates.push(node);
|
|
10840
10861
|
if (!nodesWithLists[parentList[1].length]) {
|
|
@@ -10944,7 +10965,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10944
10965
|
import_slate12.Editor.withoutNormalizing(editor, () => {
|
|
10945
10966
|
const { anchor } = selection;
|
|
10946
10967
|
const [textNode, textNodePath] = import_slate12.Editor.node(editor, anchor.path);
|
|
10947
|
-
if (!textNode || textNode.type !== "text" ||
|
|
10968
|
+
if (!textNode || import_slate12.Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode)) {
|
|
10948
10969
|
result = false;
|
|
10949
10970
|
return;
|
|
10950
10971
|
}
|
|
@@ -10956,7 +10977,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10956
10977
|
}
|
|
10957
10978
|
const listItemPath = import_slate12.Path.parent(paragraphPath);
|
|
10958
10979
|
const [listItem] = import_slate12.Editor.node(editor, listItemPath);
|
|
10959
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
10980
|
+
if (!listItem || import_slate12.Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
10960
10981
|
if (shouldWrap) {
|
|
10961
10982
|
wrapIntoList(editor, targetListType, selection);
|
|
10962
10983
|
return;
|
|
@@ -10966,7 +10987,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
10966
10987
|
}
|
|
10967
10988
|
const listPath = import_slate12.Path.parent(listItemPath);
|
|
10968
10989
|
const [list] = import_slate12.Editor.node(editor, listPath);
|
|
10969
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10990
|
+
if (!list || import_slate12.Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
10970
10991
|
if (shouldWrap) {
|
|
10971
10992
|
wrapIntoList(editor, targetListType, selection);
|
|
10972
10993
|
return;
|
|
@@ -11048,7 +11069,7 @@ function getListTypeAtSelectionStart(editor) {
|
|
|
11048
11069
|
const startPoint = import_slate14.Range.start(selection);
|
|
11049
11070
|
const listEntry = import_slate14.Editor.above(editor, {
|
|
11050
11071
|
at: startPoint,
|
|
11051
|
-
match: (n) => n.type === "ol_list" || n.type === "ul_list"
|
|
11072
|
+
match: (n) => !import_slate14.Editor.isEditor(n) && (n.type === "ol_list" || n.type === "ul_list")
|
|
11052
11073
|
});
|
|
11053
11074
|
if (listEntry) {
|
|
11054
11075
|
const [listNode] = listEntry;
|
|
@@ -11071,11 +11092,11 @@ var setLink = (editor, link, selection) => {
|
|
|
11071
11092
|
const format = link ? "rgba(71, 120, 245, 1)" : "rgb(20, 21, 26)";
|
|
11072
11093
|
import_slate15.Editor.addMark(editor, "fontColor", format);
|
|
11073
11094
|
for (const [node, path2] of import_slate15.Editor.nodes(editor, {
|
|
11074
|
-
match: (n) => n.type === "text"
|
|
11095
|
+
match: (n) => !import_slate15.Editor.isEditor(n) && n.type === "text"
|
|
11075
11096
|
})) {
|
|
11076
11097
|
const nodeRange = import_slate15.Editor.range(editor, path2);
|
|
11077
11098
|
import_slate15.Transforms.select(editor, nodeRange);
|
|
11078
|
-
import_slate15.Transforms.setNodes(editor, { link }, { split: false, match: (n) => n.type === "text" });
|
|
11099
|
+
import_slate15.Transforms.setNodes(editor, { link }, { split: false, match: (n) => !import_slate15.Editor.isEditor(n) && n.type === "text" });
|
|
11079
11100
|
}
|
|
11080
11101
|
};
|
|
11081
11102
|
|
|
@@ -17465,7 +17486,7 @@ function getFirstSelectionLink(editor, selection) {
|
|
|
17465
17486
|
}
|
|
17466
17487
|
for (const [node2] of import_slate23.Editor.nodes(editor, {
|
|
17467
17488
|
at: selection,
|
|
17468
|
-
match: (n) => !!n.link
|
|
17489
|
+
match: (n) => ("link" in n) && !!n.link
|
|
17469
17490
|
})) {
|
|
17470
17491
|
return node2.link;
|
|
17471
17492
|
}
|
|
@@ -17771,15 +17792,17 @@ class EditorContainer {
|
|
|
17771
17792
|
if (isRecordingOperations) {
|
|
17772
17793
|
const isSettingNodeFontSize = operation.type === "set_node" && "fontSize" in operation.newProperties && "fontSize" in operation.properties;
|
|
17773
17794
|
if (isSettingNodeFontSize) {
|
|
17774
|
-
const
|
|
17795
|
+
const newProperties = operation.newProperties;
|
|
17796
|
+
const properties = operation.properties;
|
|
17797
|
+
const isSettingNodeFontSizeToAuto = newProperties.fontSize === "auto";
|
|
17775
17798
|
if (isSettingNodeFontSizeToAuto) {
|
|
17776
|
-
|
|
17777
|
-
|
|
17778
|
-
|
|
17799
|
+
newProperties.fontSize = 14;
|
|
17800
|
+
newProperties.enableAuto = true;
|
|
17801
|
+
properties.enableAuto = false;
|
|
17779
17802
|
} else {
|
|
17780
|
-
|
|
17803
|
+
newProperties.enableAuto = false;
|
|
17781
17804
|
if (this.getAutosize()) {
|
|
17782
|
-
|
|
17805
|
+
properties.enableAuto = true;
|
|
17783
17806
|
}
|
|
17784
17807
|
}
|
|
17785
17808
|
}
|
|
@@ -17862,7 +17885,7 @@ class EditorContainer {
|
|
|
17862
17885
|
stopOpRecordingAndGetOps() {
|
|
17863
17886
|
const op = this.recordedOps;
|
|
17864
17887
|
this.recordedOps = null;
|
|
17865
|
-
const opsArr = op
|
|
17888
|
+
const opsArr = op ? "ops" in op ? op.ops : op : [];
|
|
17866
17889
|
return opsArr.filter((op2) => op2.type !== "set_selection");
|
|
17867
17890
|
}
|
|
17868
17891
|
applyRichTextOp(op) {
|
|
@@ -17885,7 +17908,6 @@ class EditorContainer {
|
|
|
17885
17908
|
case "setSelectionHorizontalAlignment":
|
|
17886
17909
|
this.applySelectionOp(op);
|
|
17887
17910
|
break;
|
|
17888
|
-
case "setBlockType":
|
|
17889
17911
|
case "setFontStyle":
|
|
17890
17912
|
case "setFontColor":
|
|
17891
17913
|
case "setFontFamily":
|
|
@@ -17900,7 +17922,11 @@ class EditorContainer {
|
|
|
17900
17922
|
}
|
|
17901
17923
|
} catch (error) {
|
|
17902
17924
|
console.error("Error in applying RichText Operation in Item: ", this.id, error);
|
|
17903
|
-
|
|
17925
|
+
const operations2 = [];
|
|
17926
|
+
if ("ops" in op && Array.isArray(op.ops)) {
|
|
17927
|
+
operations2.push(...op.ops.map((op2) => op2.type));
|
|
17928
|
+
}
|
|
17929
|
+
console.error("Error applying this type operation: ", operations2);
|
|
17904
17930
|
}
|
|
17905
17931
|
}
|
|
17906
17932
|
applySelectionEdit(op) {
|
|
@@ -17930,7 +17956,6 @@ class EditorContainer {
|
|
|
17930
17956
|
this.setSelectionFontColor(op.fontColor);
|
|
17931
17957
|
break;
|
|
17932
17958
|
case "setFontFamily":
|
|
17933
|
-
this.setSelectionFontFamily(op.fontFamily);
|
|
17934
17959
|
break;
|
|
17935
17960
|
case "setFontSize":
|
|
17936
17961
|
this.textScale = Number(op.fontSize) / this.getScale() / this.initialTextStyles.fontSize;
|