@kaitify/vue 0.0.1-beta.10 → 0.0.1-beta.11

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.
@@ -1403,16 +1403,17 @@ const kebabToCamel = (val) => {
1403
1403
  return val.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1404
1404
  };
1405
1405
  const getDomAttributes = (dom) => {
1406
- let o = {};
1407
- const length = dom.attributes.length;
1406
+ const attributes = Array.from(dom.attributes);
1407
+ const length = attributes.length;
1408
+ const regExp = new RegExp(`(^on)|(^style$)|(^${NODE_MARK}$)`, "g");
1409
+ const result = {};
1408
1410
  for (let i = 0; i < length; i++) {
1409
- const attribute = dom.attributes[i];
1410
- const regExp = new RegExp(`(^on)|(^style$)|(^${NODE_MARK}$)`, "g");
1411
- if (!regExp.test(attribute.nodeName)) {
1412
- o[attribute.nodeName] = attribute.nodeValue || "";
1411
+ const { nodeName, nodeValue } = attributes[i];
1412
+ if (!regExp.test(nodeName)) {
1413
+ result[nodeName] = nodeValue ?? "";
1413
1414
  }
1414
1415
  }
1415
- return o;
1416
+ return result;
1416
1417
  };
1417
1418
  const getDomStyles = (dom) => {
1418
1419
  let o = {};
@@ -1505,19 +1506,15 @@ class KNode {
1505
1506
  void: this.void
1506
1507
  });
1507
1508
  if (deep && this.hasChildren()) {
1508
- this.children.forEach((child) => {
1509
+ newNode2.children = this.children.map((child) => {
1509
1510
  const newChild = child.clone(deep);
1510
- if (newNode2.hasChildren()) {
1511
- newNode2.children.push(newChild);
1512
- } else {
1513
- newNode2.children = [newChild];
1514
- }
1515
1511
  newChild.parent = newNode2;
1512
+ return newChild;
1516
1513
  });
1517
1514
  }
1518
1515
  return newNode2;
1519
1516
  });
1520
- __publicField(this, "firstTextClosedInNode", (node) => {
1517
+ __publicField(this, "firstInTargetNode", (node) => {
1521
1518
  if (!this.isText() && !this.isClosed()) {
1522
1519
  return false;
1523
1520
  }
@@ -1526,24 +1523,21 @@ class KNode {
1526
1523
  }
1527
1524
  if (node.isContains(this) && node.hasChildren()) {
1528
1525
  const firstChild = node.children[0];
1529
- return this.firstTextClosedInNode(firstChild);
1526
+ return this.firstInTargetNode(firstChild);
1530
1527
  }
1531
1528
  return false;
1532
1529
  });
1533
1530
  __publicField(this, "getFocusNodes", (type = "all") => {
1534
- const nodes = [];
1535
1531
  if (this.isClosed() && (type == "all" || type == "closed")) {
1536
- nodes.push(this);
1532
+ return [this];
1537
1533
  }
1538
1534
  if (this.isText() && (type == "all" || type == "text")) {
1539
- nodes.push(this);
1535
+ return [this];
1540
1536
  }
1541
1537
  if (this.hasChildren()) {
1542
- this.children.forEach((item) => {
1543
- nodes.push(...item.getFocusNodes(type));
1544
- });
1538
+ return this.children.flatMap((item) => item.getFocusNodes(type));
1545
1539
  }
1546
- return nodes;
1540
+ return [];
1547
1541
  });
1548
1542
  }
1549
1543
  /**
@@ -1617,7 +1611,10 @@ class KNode {
1617
1611
  return !this.textContent;
1618
1612
  }
1619
1613
  if (this.isInline() || this.isBlock()) {
1620
- return !this.hasChildren() || this.children.every((item) => {
1614
+ if (!this.hasChildren()) {
1615
+ return true;
1616
+ }
1617
+ return this.children.every((item) => {
1621
1618
  return item.isEmpty();
1622
1619
  });
1623
1620
  }
@@ -1728,7 +1725,7 @@ class KNode {
1728
1725
  return false;
1729
1726
  }
1730
1727
  /**
1731
- * 【API】判断当前节点是否在拥有代码块样式的块级节点内(包括自身)
1728
+ * 【API】判断当前节点是否在拥有代码块样式的块级节点内(包括自身),是的话返回该块级节点,否则返回null
1732
1729
  */
1733
1730
  isInCodeBlockStyle() {
1734
1731
  const block = this.getBlock();
@@ -1783,14 +1780,10 @@ class KNode {
1783
1780
  });
1784
1781
  newNode2.key = this.key;
1785
1782
  if (this.hasChildren()) {
1786
- this.children.forEach((child) => {
1783
+ newNode2.children = this.children.map((child) => {
1787
1784
  const newChild = child.fullClone();
1788
- if (newNode2.hasChildren()) {
1789
- newNode2.children.push(newChild);
1790
- } else {
1791
- newNode2.children = [newChild];
1792
- }
1793
1785
  newChild.parent = newNode2;
1786
+ return newChild;
1794
1787
  });
1795
1788
  }
1796
1789
  return newNode2;
@@ -1798,7 +1791,7 @@ class KNode {
1798
1791
  /**
1799
1792
  * 【API】如果当前节点是文本节点或者闭合节点,则判断是不是指定节点后代中所有文本节点和闭合节点中的最后一个
1800
1793
  */
1801
- lastTextClosedInNode(node) {
1794
+ lastInTargetNode(node) {
1802
1795
  if (!this.isText() && !this.isClosed()) {
1803
1796
  return false;
1804
1797
  }
@@ -1807,7 +1800,7 @@ class KNode {
1807
1800
  }
1808
1801
  if (node.isContains(this) && node.hasChildren()) {
1809
1802
  const lastChild = node.children[node.children.length - 1];
1810
- return this.lastTextClosedInNode(lastChild);
1803
+ return this.lastInTargetNode(lastChild);
1811
1804
  }
1812
1805
  return false;
1813
1806
  }
@@ -1821,7 +1814,7 @@ class KNode {
1821
1814
  }
1822
1815
  const previousNode = nodes[index - 1];
1823
1816
  if (previousNode.isEmpty()) {
1824
- return index - 1 == 0 ? null : previousNode.getPrevious(nodes);
1817
+ return previousNode.getPrevious(nodes);
1825
1818
  }
1826
1819
  return previousNode;
1827
1820
  }
@@ -1835,7 +1828,7 @@ class KNode {
1835
1828
  }
1836
1829
  const nextNode = nodes[index + 1];
1837
1830
  if (nextNode.isEmpty()) {
1838
- return index + 1 == nodes.length - 1 ? null : nextNode.getNext(nodes);
1831
+ return nextNode.getNext(nodes);
1839
1832
  }
1840
1833
  return nextNode;
1841
1834
  }
@@ -1897,13 +1890,13 @@ class KNode {
1897
1890
  knode.type = options.type;
1898
1891
  knode.tag = options.tag;
1899
1892
  knode.textContent = options.textContent;
1900
- knode.fixed = options.fixed || false;
1901
- knode.locked = options.locked || false;
1902
- knode.nested = options.nested || false;
1903
- knode.void = options.void || false;
1893
+ knode.fixed = options.fixed ?? false;
1894
+ knode.locked = options.locked ?? false;
1895
+ knode.nested = options.nested ?? false;
1896
+ knode.void = options.void ?? false;
1904
1897
  knode.marks = common$1.clone(options.marks);
1905
1898
  knode.styles = common$1.clone(options.styles);
1906
- knode.namespace = options.namespace;
1899
+ knode.namespace = options.namespace ?? "";
1907
1900
  knode.children = (_a = options.children) == null ? void 0 : _a.map((item) => {
1908
1901
  const childNode = KNode.create(item);
1909
1902
  childNode.parent = knode;
@@ -1943,38 +1936,33 @@ class KNode {
1943
1936
  * 【API】将某个节点数组扁平化处理后返回
1944
1937
  */
1945
1938
  static flat(nodes) {
1946
- const newNodes = [];
1947
- const length = nodes.length;
1948
- for (let i = 0; i < length; i++) {
1949
- newNodes.push(nodes[i]);
1950
- if (nodes[i].hasChildren()) {
1951
- const childResult = KNode.flat(nodes[i].children);
1952
- newNodes.push(...childResult);
1939
+ const result = [];
1940
+ const stack = nodes.slice().reverse();
1941
+ while (stack.length > 0) {
1942
+ const node = stack.pop();
1943
+ result.push(node);
1944
+ if (node.hasChildren()) {
1945
+ stack.push(...node.children.slice().reverse());
1953
1946
  }
1954
1947
  }
1955
- return newNodes;
1948
+ return result;
1956
1949
  }
1957
1950
  /**
1958
1951
  * 【API】在指定的节点数组中根据key查找节点
1959
1952
  */
1960
1953
  static searchByKey(key, nodes) {
1961
- let node = null;
1962
- const length = nodes.length;
1963
- for (let i = 0; i < length; i++) {
1964
- const item = nodes[i];
1965
- if (item && item.key == Number(key)) {
1966
- node = item;
1967
- break;
1954
+ const stack = nodes.slice().reverse();
1955
+ const targetKey = Number(key);
1956
+ while (stack.length > 0) {
1957
+ const node = stack.pop();
1958
+ if (node.key === targetKey) {
1959
+ return node;
1968
1960
  }
1969
- if (item && item.hasChildren()) {
1970
- const n = KNode.searchByKey(key, item.children);
1971
- if (n) {
1972
- node = n;
1973
- break;
1974
- }
1961
+ if (node.hasChildren()) {
1962
+ stack.push(...node.children.slice().reverse());
1975
1963
  }
1976
1964
  }
1977
- return node;
1965
+ return null;
1978
1966
  }
1979
1967
  }
1980
1968
  class Selection {
@@ -2103,21 +2091,24 @@ const splitNodeToNodes = function(node) {
2103
2091
  }
2104
2092
  };
2105
2093
  const emptyFixedBlock = function(node) {
2094
+ var _a;
2106
2095
  if (!node.isBlock()) {
2107
2096
  return;
2108
2097
  }
2109
2098
  if (node.hasChildren()) {
2110
- node.children.forEach((item) => {
2099
+ node.children = (_a = node.children) == null ? void 0 : _a.filter((item) => {
2111
2100
  if (item.isBlock() && item.fixed) {
2112
2101
  emptyFixedBlock.apply(this, [item]);
2102
+ return true;
2113
2103
  } else {
2114
2104
  item.toEmpty();
2115
- if (item.parent.isEmpty()) {
2116
- const placeholderNode = KNode.createPlaceholder();
2117
- this.addNode(placeholderNode, item.parent);
2118
- }
2105
+ return false;
2119
2106
  }
2120
2107
  });
2108
+ if (node.isEmpty()) {
2109
+ const placeholderNode = KNode.createPlaceholder();
2110
+ this.addNode(placeholderNode, node);
2111
+ }
2121
2112
  }
2122
2113
  };
2123
2114
  const mergeBlock = function(node, target) {
@@ -2211,10 +2202,10 @@ const applyMergeNode = function(node, type) {
2211
2202
  }
2212
2203
  if (type == "prevSibling") {
2213
2204
  if (node.isText()) {
2214
- if (this.isSelectionInNode(targetNode, "start")) {
2205
+ if (this.isSelectionInTargetNode(targetNode, "start")) {
2215
2206
  this.selection.start.node = node;
2216
2207
  }
2217
- if (this.isSelectionInNode(targetNode, "end")) {
2208
+ if (this.isSelectionInTargetNode(targetNode, "end")) {
2218
2209
  this.selection.end.node = node;
2219
2210
  }
2220
2211
  node.textContent = targetNode.textContent + node.textContent;
@@ -2249,11 +2240,11 @@ const applyMergeNode = function(node, type) {
2249
2240
  }
2250
2241
  if (type == "nextSibling") {
2251
2242
  if (node.isText()) {
2252
- if (this.isSelectionInNode(targetNode, "start")) {
2243
+ if (this.isSelectionInTargetNode(targetNode, "start")) {
2253
2244
  this.selection.start.node = node;
2254
2245
  this.selection.start.offset = node.textContent.length + this.selection.start.offset;
2255
2246
  }
2256
- if (this.isSelectionInNode(targetNode, "end")) {
2247
+ if (this.isSelectionInTargetNode(targetNode, "end")) {
2257
2248
  this.selection.end.node = node;
2258
2249
  this.selection.end.offset = node.textContent.length + this.selection.end.offset;
2259
2250
  }
@@ -2307,10 +2298,10 @@ const applyMergeNode = function(node, type) {
2307
2298
  }
2308
2299
  targetNode.textContent = node.textContent;
2309
2300
  targetNode.children = void 0;
2310
- if (this.isSelectionInNode(node, "start")) {
2301
+ if (this.isSelectionInTargetNode(node, "start")) {
2311
2302
  this.selection.start.node = targetNode;
2312
2303
  }
2313
- if (this.isSelectionInNode(node, "end")) {
2304
+ if (this.isSelectionInTargetNode(node, "end")) {
2314
2305
  this.selection.end.node = targetNode;
2315
2306
  }
2316
2307
  } else {
@@ -2351,32 +2342,31 @@ const convertToBlock = function(node) {
2351
2342
  if (node.isBlock()) {
2352
2343
  return;
2353
2344
  }
2354
- const newNode2 = node.clone(true);
2355
2345
  if (node.isText() || node.isClosed()) {
2356
- if (this.isSelectionInNode(node, "start")) {
2357
- this.selection.start.node = newNode2;
2358
- }
2359
- if (this.isSelectionInNode(node, "end")) {
2360
- this.selection.end.node = newNode2;
2346
+ const index = node.parent ? node.parent.children.findIndex((item) => item.isEqual(node)) : this.stackNodes.findIndex((item) => item.isEqual(node));
2347
+ const paragraph = KNode.create({
2348
+ type: "block",
2349
+ tag: this.blockRenderTag
2350
+ });
2351
+ if (node.parent) {
2352
+ paragraph.parent = node.parent;
2361
2353
  }
2354
+ node.parent ? node.parent.children.splice(index, 1, paragraph) : this.stackNodes.splice(index, 1, paragraph);
2355
+ paragraph.children = [node];
2356
+ node.parent = paragraph;
2357
+ } else if (node.isInline()) {
2358
+ node.type = "block";
2362
2359
  }
2363
- node.type = "block";
2364
- node.tag = this.blockRenderTag;
2365
- node.marks = void 0;
2366
- node.styles = void 0;
2367
- node.textContent = void 0;
2368
- node.children = [newNode2];
2369
- newNode2.parent = node;
2370
2360
  };
2371
2361
  const formatNodes = function(rule, nodes, sourceNodes) {
2372
2362
  let i = 0;
2373
2363
  while (i < nodes.length) {
2374
2364
  const node = nodes[i];
2375
2365
  if (node.isEmpty()) {
2376
- if (this.isSelectionInNode(node, "start")) {
2366
+ if (this.isSelectionInTargetNode(node, "start")) {
2377
2367
  this.updateSelectionRecently("start");
2378
2368
  }
2379
- if (this.isSelectionInNode(node, "end")) {
2369
+ if (this.isSelectionInTargetNode(node, "end")) {
2380
2370
  this.updateSelectionRecently("end");
2381
2371
  }
2382
2372
  const index = sourceNodes.findIndex((item) => item.isEqual(node));
@@ -2384,10 +2374,10 @@ const formatNodes = function(rule, nodes, sourceNodes) {
2384
2374
  } else {
2385
2375
  rule({ editor: this, node });
2386
2376
  if (node.isEmpty()) {
2387
- if (this.isSelectionInNode(node, "start")) {
2377
+ if (this.isSelectionInTargetNode(node, "start")) {
2388
2378
  this.updateSelectionRecently("start");
2389
2379
  }
2390
- if (this.isSelectionInNode(node, "end")) {
2380
+ if (this.isSelectionInTargetNode(node, "end")) {
2391
2381
  this.updateSelectionRecently("end");
2392
2382
  }
2393
2383
  const index = sourceNodes.findIndex((item) => item.isEqual(node));
@@ -2400,10 +2390,10 @@ const formatNodes = function(rule, nodes, sourceNodes) {
2400
2390
  formatNodes.apply(this, [rule, node.children, node.children]);
2401
2391
  }
2402
2392
  if (node.isEmpty()) {
2403
- if (this.isSelectionInNode(node, "start")) {
2393
+ if (this.isSelectionInTargetNode(node, "start")) {
2404
2394
  this.updateSelectionRecently("start");
2405
2395
  }
2406
- if (this.isSelectionInNode(node, "end")) {
2396
+ if (this.isSelectionInTargetNode(node, "end")) {
2407
2397
  this.updateSelectionRecently("end");
2408
2398
  }
2409
2399
  const index = sourceNodes.findIndex((item) => item.isEqual(node));
@@ -2639,7 +2629,9 @@ const checkNodes = function() {
2639
2629
  }
2640
2630
  };
2641
2631
  const handlerForPasteKeepMarksAndStyles = function(nodes) {
2642
- nodes.forEach((node) => {
2632
+ const length = nodes.length;
2633
+ for (let i = 0; i < length; i++) {
2634
+ const node = nodes[i];
2643
2635
  const marks = {};
2644
2636
  const styles2 = {};
2645
2637
  if (node.hasMarks()) {
@@ -2666,55 +2658,56 @@ const handlerForPasteKeepMarksAndStyles = function(nodes) {
2666
2658
  if (node.hasChildren()) {
2667
2659
  handlerForPasteKeepMarksAndStyles.apply(this, [node.children]);
2668
2660
  }
2669
- });
2661
+ }
2670
2662
  };
2671
2663
  const handlerForPasteFiles = async function(files) {
2672
2664
  const length = files.length;
2673
2665
  for (let i = 0; i < length; i++) {
2674
- if (files[i].type.startsWith("image/")) {
2675
- const useDefault = typeof this.onPasteImage == "function" ? await this.onPasteImage.apply(this, [files[i]]) : true;
2666
+ const file$1$1 = files[i];
2667
+ if (file$1$1.type.startsWith("image/")) {
2668
+ const useDefault = typeof this.onPasteImage == "function" ? await this.onPasteImage.apply(this, [file$1$1]) : true;
2676
2669
  if (useDefault) {
2677
- const url = await file$1.dataFileToBase64(files[i]);
2670
+ const url = await file$1.dataFileToBase64(file$1$1);
2678
2671
  const image2 = KNode.create({
2679
2672
  type: "closed",
2680
2673
  tag: "img",
2681
2674
  marks: {
2682
2675
  src: url,
2683
- alt: files[i].name || ""
2676
+ alt: file$1$1.name || ""
2684
2677
  }
2685
2678
  });
2686
2679
  this.insertNode(image2);
2687
2680
  }
2688
- } else if (files[i].type.startsWith("video/")) {
2689
- const useDefault = typeof this.onPasteVideo == "function" ? await this.onPasteVideo.apply(this, [files[i]]) : true;
2681
+ } else if (file$1$1.type.startsWith("video/")) {
2682
+ const useDefault = typeof this.onPasteVideo == "function" ? await this.onPasteVideo.apply(this, [file$1$1]) : true;
2690
2683
  if (useDefault) {
2691
- const url = await file$1.dataFileToBase64(files[i]);
2684
+ const url = await file$1.dataFileToBase64(file$1$1);
2692
2685
  const video2 = KNode.create({
2693
2686
  type: "closed",
2694
2687
  tag: "video",
2695
2688
  marks: {
2696
2689
  src: url,
2697
- alt: files[i].name || ""
2690
+ alt: file$1$1.name || ""
2698
2691
  }
2699
2692
  });
2700
2693
  this.insertNode(video2);
2701
2694
  }
2702
2695
  } else if (typeof this.onPasteFile == "function") {
2703
- this.onPasteFile.apply(this, [files[i]]);
2696
+ this.onPasteFile.apply(this, [file$1$1]);
2704
2697
  }
2705
2698
  }
2706
2699
  };
2707
2700
  const fillPlaceholderToEmptyBlock = function(nodes) {
2708
- const length = nodes.length;
2709
- for (let i = 0; i < length; i++) {
2710
- if (nodes[i].isBlock()) {
2711
- if (nodes[i].isEmpty()) {
2712
- const placeholderNode = KNode.createPlaceholder();
2713
- nodes[i].children = [placeholderNode];
2714
- placeholderNode.parent = nodes[i];
2715
- } else if (nodes[i].hasChildren()) {
2716
- fillPlaceholderToEmptyBlock.apply(this, [nodes[i].children]);
2717
- }
2701
+ const stack = nodes.slice().reverse();
2702
+ while (stack.length > 0) {
2703
+ const node = stack.pop();
2704
+ if (!node.isBlock()) continue;
2705
+ if (node.isEmpty()) {
2706
+ const placeholderNode = KNode.createPlaceholder();
2707
+ node.children = [placeholderNode];
2708
+ placeholderNode.parent = node;
2709
+ } else if (node.hasChildren()) {
2710
+ stack.push(...node.children.slice().reverse());
2718
2711
  }
2719
2712
  }
2720
2713
  };
@@ -2772,8 +2765,8 @@ const handlerForNormalInsertParagraph = function() {
2772
2765
  const node = this.selection.start.node;
2773
2766
  const offset2 = this.selection.start.offset;
2774
2767
  const blockNode = node.getBlock();
2775
- const firstSelectionNode = this.getFirstSelectionNodeInChildren(blockNode);
2776
- const lastSelectionNode = this.getLastSelectionNodeInChildren(blockNode);
2768
+ const firstSelectionNode = this.getFirstSelectionNode(blockNode);
2769
+ const lastSelectionNode = this.getLastSelectionNode(blockNode);
2777
2770
  if (firstSelectionNode.isEqual(node) && offset2 == 0) {
2778
2771
  const newBlockNode = blockNode.clone(false);
2779
2772
  const placeholderNode = KNode.createPlaceholder();
@@ -2833,8 +2826,8 @@ const fomratBlockTagParse = ({ editor, node }) => {
2833
2826
  };
2834
2827
  const formatBlockInChildren = ({ editor, node }) => {
2835
2828
  if (node.hasChildren() && !node.isEmpty()) {
2836
- const hasBlock = node.children.some((item) => item.isBlock() && !item.isEmpty());
2837
- if (hasBlock) {
2829
+ const hasNonEmptyBlock = node.children.some((item) => item.isBlock() && !item.isEmpty());
2830
+ if (hasNonEmptyBlock) {
2838
2831
  node.children.forEach((item) => {
2839
2832
  if (!item.isEmpty() && !item.isBlock()) {
2840
2833
  convertToBlock.apply(editor, [item]);
@@ -2860,11 +2853,11 @@ const formatUneditableNoodes = ({ editor, node }) => {
2860
2853
  editor.addNodeAfter(zeroWidthText, uneditableNode);
2861
2854
  }
2862
2855
  if (editor.isUserDelection) {
2863
- if (editor.isSelectionInNode(uneditableNode, "all")) {
2856
+ if (editor.isSelectionInTargetNode(uneditableNode, "all")) {
2864
2857
  const previousSelectionNode = editor.getPreviousSelectionNode(uneditableNode);
2865
2858
  const nexteSelectionNode = editor.getNextSelectionNode(uneditableNode);
2866
2859
  if (editor.selection.collapsed()) {
2867
- const firstNode = editor.getFirstSelectionNodeInChildren(uneditableNode);
2860
+ const firstNode = editor.getFirstSelectionNode(uneditableNode);
2868
2861
  if (firstNode.isEqual(editor.selection.start.node) && editor.selection.start.offset == 0) {
2869
2862
  editor.setSelectionAfter(previousSelectionNode, "all");
2870
2863
  } else {
@@ -2874,10 +2867,10 @@ const formatUneditableNoodes = ({ editor, node }) => {
2874
2867
  editor.setSelectionAfter(previousSelectionNode, "start");
2875
2868
  editor.setSelectionBefore(nexteSelectionNode, "end");
2876
2869
  }
2877
- } else if (editor.isSelectionInNode(uneditableNode, "start")) {
2870
+ } else if (editor.isSelectionInTargetNode(uneditableNode, "start")) {
2878
2871
  const nexteSelectionNode = editor.getNextSelectionNode(uneditableNode);
2879
2872
  editor.setSelectionBefore(nexteSelectionNode, "start");
2880
- } else if (editor.isSelectionInNode(uneditableNode, "end")) {
2873
+ } else if (editor.isSelectionInTargetNode(uneditableNode, "end")) {
2881
2874
  const previousSelectionNode = editor.getPreviousSelectionNode(uneditableNode);
2882
2875
  editor.setSelectionAfter(previousSelectionNode, "end");
2883
2876
  }
@@ -2920,10 +2913,10 @@ const formatZeroWidthTextMerge = ({ editor, node }) => {
2920
2913
  while (i < val.length) {
2921
2914
  const chart = val.charAt(i);
2922
2915
  if (i > 0 && isZeroWidthText(chart) && isZeroWidthText(val.charAt(i - 1))) {
2923
- if (editor.isSelectionInNode(node, "start") && editor.selection.start.offset >= i + 1) {
2916
+ if (editor.isSelectionInTargetNode(node, "start") && editor.selection.start.offset >= i + 1) {
2924
2917
  editor.selection.start.offset -= 1;
2925
2918
  }
2926
- if (editor.isSelectionInNode(node, "end") && editor.selection.end.offset >= i + 1) {
2919
+ if (editor.isSelectionInTargetNode(node, "end") && editor.selection.end.offset >= i + 1) {
2927
2920
  editor.selection.end.offset -= 1;
2928
2921
  }
2929
2922
  val = string.delete(val, i, 1);
@@ -2934,6 +2927,11 @@ const formatZeroWidthTextMerge = ({ editor, node }) => {
2934
2927
  node.textContent = val;
2935
2928
  }
2936
2929
  };
2930
+ const formatLineBreakText = ({ node }) => {
2931
+ if (node.isText() && !node.isEmpty()) {
2932
+ node.textContent = node.textContent.replace(/\r\n/g, "\n");
2933
+ }
2934
+ };
2937
2935
  const formatSiblingNodesMerge = ({ editor, node }) => {
2938
2936
  if ((node.isBlock() || node.isInline()) && node.hasChildren() && node.children.length > 1) {
2939
2937
  let index = 0;
@@ -3185,7 +3183,7 @@ const onComposition = async function(e) {
3185
3183
  if (parentNode.isText() && parentNode.textContent != element2.textContent) {
3186
3184
  const textContent = parentNode.textContent || "";
3187
3185
  parentNode.textContent = element2.textContent || "";
3188
- if (this.isSelectionInNode(parentNode)) {
3186
+ if (this.isSelectionInTargetNode(parentNode)) {
3189
3187
  updateSelection$1.apply(this);
3190
3188
  }
3191
3189
  element2.textContent = textContent;
@@ -3303,7 +3301,7 @@ const setDomObserve = (editor) => {
3303
3301
  if (parentNode.isText() && parentNode.textContent != mutationRecord.target.textContent) {
3304
3302
  const textContent = parentNode.textContent || "";
3305
3303
  parentNode.textContent = mutationRecord.target.textContent || "";
3306
- if (editor.isSelectionInNode(parentNode)) {
3304
+ if (editor.isSelectionInTargetNode(parentNode)) {
3307
3305
  updateSelection$1.apply(editor);
3308
3306
  }
3309
3307
  removeDomObserve(editor);
@@ -6800,10 +6798,10 @@ const CodeExtension = () => Extension.create({
6800
6798
  node.textContent = void 0;
6801
6799
  node.children = [newNode2];
6802
6800
  newNode2.parent = node;
6803
- if (this.isSelectionInNode(node, "start")) {
6801
+ if (this.isSelectionInTargetNode(node, "start")) {
6804
6802
  this.selection.start.node = newNode2;
6805
6803
  }
6806
- if (this.isSelectionInNode(node, "end")) {
6804
+ if (this.isSelectionInTargetNode(node, "end")) {
6807
6805
  this.selection.end.node = newNode2;
6808
6806
  }
6809
6807
  }
@@ -6820,8 +6818,8 @@ const CodeExtension = () => Extension.create({
6820
6818
  const codeNode = node.getMatchNode({
6821
6819
  tag: "code"
6822
6820
  });
6823
- const firstSelectionNode = this.getFirstSelectionNodeInChildren(codeNode);
6824
- const lastSelectionNode = this.getLastSelectionNodeInChildren(codeNode);
6821
+ const firstSelectionNode = this.getFirstSelectionNode(codeNode);
6822
+ const lastSelectionNode = this.getLastSelectionNode(codeNode);
6825
6823
  if (firstSelectionNode.isEqual(node) && offset2 == 0) {
6826
6824
  const zeroWidthText = KNode.createZeroWidthText();
6827
6825
  this.addNodeBefore(zeroWidthText, codeNode);
@@ -6891,7 +6889,7 @@ const CodeExtension = () => Extension.create({
6891
6889
  }
6892
6890
  } else {
6893
6891
  const startOffset = this.selection.start.offset;
6894
- const firstStartSelectionNode = this.getFirstSelectionNodeInChildren(startCodeNode);
6892
+ const firstStartSelectionNode = this.getFirstSelectionNode(startCodeNode);
6895
6893
  const focusNodes = this.getFocusSplitNodesBySelection("all");
6896
6894
  const length = focusNodes.length;
6897
6895
  const map = {};
@@ -6913,7 +6911,7 @@ const CodeExtension = () => Extension.create({
6913
6911
  }
6914
6912
  }
6915
6913
  Object.values(map).forEach((item) => {
6916
- item.nodes.reverse().forEach((node) => {
6914
+ item.nodes.slice().reverse().forEach((node) => {
6917
6915
  this.addNodeAfter(node, item.code);
6918
6916
  });
6919
6917
  });
@@ -22756,11 +22754,11 @@ const MathExtension = () => Extension.create({
22756
22754
  const zeroWidthText = KNode.createZeroWidthText();
22757
22755
  editor.addNodeAfter(zeroWidthText, node);
22758
22756
  }
22759
- if (editor.isSelectionInNode(node, "start")) {
22757
+ if (editor.isSelectionInTargetNode(node, "start")) {
22760
22758
  const newTextNode = node.getNext(node.parent ? node.parent.children : editor.stackNodes);
22761
22759
  if (newTextNode) editor.setSelectionBefore(newTextNode, "start");
22762
22760
  }
22763
- if (editor.isSelectionInNode(node, "end")) {
22761
+ if (editor.isSelectionInTargetNode(node, "end")) {
22764
22762
  const newTextNode = node.getNext(node.parent ? node.parent.children : editor.stackNodes);
22765
22763
  if (newTextNode) editor.setSelectionBefore(newTextNode, "end");
22766
22764
  }
@@ -35021,7 +35019,7 @@ const updateSelection = (editor, node, textNodes, newNodes) => {
35021
35019
  if (!editor.selection.focused()) {
35022
35020
  return;
35023
35021
  }
35024
- if (editor.isSelectionInNode(node, "start")) {
35022
+ if (editor.isSelectionInTargetNode(node, "start")) {
35025
35023
  const startIndex = textNodes.findIndex((n) => editor.selection.start.node.isEqual(n));
35026
35024
  const offset2 = textNodes.filter((_n, i2) => i2 < startIndex).reduce((total, item) => total + item.textContent.length, 0) + editor.selection.start.offset;
35027
35025
  const newTextNodes = KNode.flat(newNodes).filter((n) => n.isText() && !n.isEmpty());
@@ -35038,7 +35036,7 @@ const updateSelection = (editor, node, textNodes, newNodes) => {
35038
35036
  index = newIndex;
35039
35037
  }
35040
35038
  }
35041
- if (editor.isSelectionInNode(node, "end")) {
35039
+ if (editor.isSelectionInTargetNode(node, "end")) {
35042
35040
  const endIndex = textNodes.findIndex((n) => editor.selection.end.node.isEqual(n));
35043
35041
  const offset2 = textNodes.filter((_n, i2) => i2 < endIndex).reduce((total, item) => total + item.textContent.length, 0) + editor.selection.end.offset;
35044
35042
  const newTextNodes = KNode.flat(newNodes).filter((n) => n.isText() && !n.isEmpty());
@@ -35126,8 +35124,8 @@ const CodeBlockExtension = () => Extension.create({
35126
35124
  });
35127
35125
  updateSelection(editor, node, textNodes, nodes);
35128
35126
  } else {
35129
- const selectionStartInNode = editor.isSelectionInNode(node, "start");
35130
- const selectionEndInNode = editor.isSelectionInNode(node, "end");
35127
+ const selectionStartInNode = editor.isSelectionInTargetNode(node, "start");
35128
+ const selectionEndInNode = editor.isSelectionInTargetNode(node, "end");
35131
35129
  const placeholderNode = KNode.createPlaceholder();
35132
35130
  node.children = [placeholderNode];
35133
35131
  placeholderNode.parent = node;
@@ -35331,11 +35329,11 @@ const AttachmentExtension = (props) => Extension.create({
35331
35329
  const zeroWidthText = KNode.createZeroWidthText();
35332
35330
  editor.addNodeAfter(zeroWidthText, node);
35333
35331
  }
35334
- if (editor.isSelectionInNode(node, "start")) {
35332
+ if (editor.isSelectionInTargetNode(node, "start")) {
35335
35333
  const newTextNode = node.getNext(node.parent ? node.parent.children : editor.stackNodes);
35336
35334
  if (newTextNode) editor.setSelectionBefore(newTextNode, "start");
35337
35335
  }
35338
- if (editor.isSelectionInNode(node, "end")) {
35336
+ if (editor.isSelectionInTargetNode(node, "end")) {
35339
35337
  const newTextNode = node.getNext(node.parent ? node.parent.children : editor.stackNodes);
35340
35338
  if (newTextNode) editor.setSelectionBefore(newTextNode, "end");
35341
35339
  }
@@ -36660,7 +36658,7 @@ class Editor {
36660
36658
  __publicField(this, "emptyRenderTags", ["meta", "link", "style", "script", "title", "base", "noscript", "template", "annotation", "input", "form", "button"]);
36661
36659
  __publicField(this, "extraKeepTags", []);
36662
36660
  __publicField(this, "extensions", [TextExtension(), ImageExtension(), VideoExtension(), HistoryExtension(), BoldExtension(), ItalicExtension(), StrikethroughExtension(), UnderlineExtension(), SuperscriptExtension(), SubscriptExtension(), CodeExtension(), FontSizeExtension(), FontFamilyExtension(), ColorExtension(), BackColorExtension(), LinkExtension(), AlignExtension(), LineHeightExtension(), IndentExtension(), HorizontalExtension(), BlockquoteExtension(), HeadingExtension(), ListExtension(), TaskExtension(), MathExtension(), CodeBlockExtension(), AttachmentExtension(), TableExtension()]);
36663
- __publicField(this, "formatRules", [fomratBlockTagParse, formatBlockInChildren, formatUneditableNoodes, formatPlaceholderMerge, formatZeroWidthTextMerge, formatSiblingNodesMerge, formatParentNodeMerge]);
36661
+ __publicField(this, "formatRules", [fomratBlockTagParse, formatBlockInChildren, formatUneditableNoodes, formatPlaceholderMerge, formatZeroWidthTextMerge, formatLineBreakText, formatSiblingNodesMerge, formatParentNodeMerge]);
36664
36662
  __publicField(this, "domParseNodeCallback");
36665
36663
  __publicField(this, "onUpdateView");
36666
36664
  __publicField(this, "onPasteText");
@@ -36850,7 +36848,7 @@ class Editor {
36850
36848
  if (dom.nodeType == 3) {
36851
36849
  return KNode.create({
36852
36850
  type: "text",
36853
- textContent: dom.textContent || ""
36851
+ textContent: dom.textContent ?? ""
36854
36852
  });
36855
36853
  }
36856
36854
  const marks = getDomAttributes(dom);
@@ -36875,7 +36873,7 @@ class Editor {
36875
36873
  tag,
36876
36874
  marks,
36877
36875
  styles: styles2,
36878
- namespace: namespace || ""
36876
+ namespace: namespace ?? ""
36879
36877
  };
36880
36878
  if (["p", "div", "address", "article", "aside", "nav", "section"].includes(tag)) {
36881
36879
  config.type = "block";
@@ -36919,8 +36917,7 @@ class Editor {
36919
36917
  const nodes = [];
36920
36918
  template.content.childNodes.forEach((item) => {
36921
36919
  if (item.nodeType == 1 || item.nodeType == 3) {
36922
- const node = this.domParseNode(item);
36923
- nodes.push(node);
36920
+ nodes.push(this.domParseNode(item));
36924
36921
  }
36925
36922
  });
36926
36923
  return nodes;
@@ -36974,14 +36971,10 @@ class Editor {
36974
36971
  */
36975
36972
  addNodeBefore(node, target) {
36976
36973
  if (target.parent) {
36977
- const index = target.parent.children.findIndex((item) => {
36978
- return target.isEqual(item);
36979
- });
36974
+ const index = target.parent.children.findIndex((item) => target.isEqual(item));
36980
36975
  this.addNode(node, target.parent, index);
36981
36976
  } else {
36982
- const index = this.stackNodes.findIndex((item) => {
36983
- return target.isEqual(item);
36984
- });
36977
+ const index = this.stackNodes.findIndex((item) => target.isEqual(item));
36985
36978
  this.stackNodes.splice(index, 0, node);
36986
36979
  node.parent = void 0;
36987
36980
  }
@@ -36991,14 +36984,10 @@ class Editor {
36991
36984
  */
36992
36985
  addNodeAfter(node, target) {
36993
36986
  if (target.parent) {
36994
- const index = target.parent.children.findIndex((item) => {
36995
- return target.isEqual(item);
36996
- });
36987
+ const index = target.parent.children.findIndex((item) => target.isEqual(item));
36997
36988
  this.addNode(node, target.parent, index + 1);
36998
36989
  } else {
36999
- const index = this.stackNodes.findIndex((item) => {
37000
- return target.isEqual(item);
37001
- });
36990
+ const index = this.stackNodes.findIndex((item) => target.isEqual(item));
37002
36991
  this.stackNodes.splice(index + 1, 0, node);
37003
36992
  node.parent = void 0;
37004
36993
  }
@@ -37006,97 +36995,93 @@ class Editor {
37006
36995
  /**
37007
36996
  * 获取某个节点内的最后一个可以设置光标点的节点,包括自身
37008
36997
  */
37009
- getLastSelectionNodeInChildren(node) {
37010
- if (node.isEmpty()) {
37011
- return null;
37012
- }
37013
- if (node.void) {
37014
- return null;
37015
- }
37016
- if (node.isText() || node.isClosed()) {
37017
- return node;
37018
- }
37019
- let selectionNode = null;
37020
- const length = node.children.length;
37021
- for (let i = length - 1; i >= 0; i--) {
37022
- const child = node.children[i];
37023
- selectionNode = this.getLastSelectionNodeInChildren(child);
37024
- if (selectionNode) {
37025
- break;
36998
+ getLastSelectionNode(node) {
36999
+ const stack = [node];
37000
+ while (stack.length > 0) {
37001
+ const currentNode = stack.pop();
37002
+ if (currentNode.isEmpty() || currentNode.void) {
37003
+ continue;
37004
+ }
37005
+ if (currentNode.isText() || currentNode.isClosed()) {
37006
+ return currentNode;
37007
+ }
37008
+ if (currentNode.hasChildren()) {
37009
+ stack.push(...currentNode.children);
37026
37010
  }
37027
37011
  }
37028
- return selectionNode;
37012
+ return null;
37029
37013
  }
37030
37014
  /**
37031
37015
  * 获取某个节点内的第一个可以设置光标点的节点,包括自身
37032
37016
  */
37033
- getFirstSelectionNodeInChildren(node) {
37034
- if (node.isEmpty()) {
37035
- return null;
37036
- }
37037
- if (node.void) {
37038
- return null;
37039
- }
37040
- if (node.isText() || node.isClosed()) {
37041
- return node;
37042
- }
37043
- let selectionNode = null;
37044
- const length = node.children.length;
37045
- for (let i = 0; i < length; i++) {
37046
- const child = node.children[i];
37047
- selectionNode = this.getFirstSelectionNodeInChildren(child);
37048
- if (selectionNode) {
37049
- break;
37017
+ getFirstSelectionNode(node) {
37018
+ const stack = [node];
37019
+ while (stack.length > 0) {
37020
+ const currentNode = stack.pop();
37021
+ if (currentNode.isEmpty() || currentNode.void) {
37022
+ continue;
37023
+ }
37024
+ if (currentNode.isText() || currentNode.isClosed()) {
37025
+ return currentNode;
37026
+ }
37027
+ if (currentNode.hasChildren()) {
37028
+ stack.push(...currentNode.children.slice().reverse());
37050
37029
  }
37051
37030
  }
37052
- return selectionNode;
37031
+ return null;
37053
37032
  }
37054
37033
  /**
37055
37034
  * 查找指定节点之前可以设置为光标点的非空节点,不包括自身
37056
37035
  */
37057
37036
  getPreviousSelectionNode(node) {
37058
- const nodes = node.parent ? node.parent.children : this.stackNodes;
37059
- const previousNode = node.getPrevious(nodes);
37060
- if (previousNode) {
37061
- if (previousNode.isEmpty()) {
37062
- return this.getPreviousSelectionNode(previousNode);
37037
+ let currentNode = node;
37038
+ while (currentNode) {
37039
+ const nodes = currentNode.parent ? currentNode.parent.children : this.stackNodes;
37040
+ const previousNode = currentNode.getPrevious(nodes);
37041
+ if (!previousNode) {
37042
+ currentNode = currentNode.parent;
37043
+ continue;
37063
37044
  }
37064
- if (previousNode.void) {
37065
- return this.getPreviousSelectionNode(previousNode);
37045
+ if (previousNode.isEmpty() || previousNode.void) {
37046
+ currentNode = previousNode;
37047
+ continue;
37066
37048
  }
37067
37049
  if (previousNode.isText() || previousNode.isClosed()) {
37068
37050
  return previousNode;
37069
37051
  }
37070
- return this.getLastSelectionNodeInChildren(previousNode);
37052
+ return this.getLastSelectionNode(previousNode);
37071
37053
  }
37072
- return node.parent ? this.getPreviousSelectionNode(node.parent) : null;
37054
+ return null;
37073
37055
  }
37074
37056
  /**
37075
37057
  * 查找指定节点之后可以设置为光标点的非空节点,不包括自身
37076
37058
  */
37077
37059
  getNextSelectionNode(node) {
37078
- const nodes = node.parent ? node.parent.children : this.stackNodes;
37079
- const nextNode = node.getNext(nodes);
37080
- if (nextNode) {
37081
- if (nextNode.isEmpty()) {
37082
- return this.getNextSelectionNode(nextNode);
37060
+ let currentNode = node;
37061
+ while (currentNode) {
37062
+ const nodes = currentNode.parent ? currentNode.parent.children : this.stackNodes;
37063
+ const nextNode = currentNode.getNext(nodes);
37064
+ if (!nextNode) {
37065
+ currentNode = currentNode.parent;
37066
+ continue;
37083
37067
  }
37084
- if (nextNode.void) {
37085
- return this.getNextSelectionNode(nextNode);
37068
+ if (nextNode.isEmpty() || nextNode.void) {
37069
+ currentNode = nextNode;
37070
+ continue;
37086
37071
  }
37087
37072
  if (nextNode.isText() || nextNode.isClosed()) {
37088
37073
  return nextNode;
37089
37074
  }
37090
- return this.getFirstSelectionNodeInChildren(nextNode);
37075
+ return this.getFirstSelectionNode(nextNode);
37091
37076
  }
37092
- return node.parent ? this.getNextSelectionNode(node.parent) : null;
37077
+ return null;
37093
37078
  }
37094
37079
  /**
37095
37080
  * 设置光标到指定节点内部的起始处,如果没有指定节点则设置光标到编辑器起始处,start表示只设置起点,end表示只设置终点,all表示起点和终点都设置
37096
37081
  */
37097
37082
  setSelectionBefore(node, type = "all") {
37098
37083
  if (node) {
37099
- const selectionNode = this.getFirstSelectionNodeInChildren(node);
37084
+ const selectionNode = this.getFirstSelectionNode(node);
37100
37085
  if (selectionNode) {
37101
37086
  if (type == "start" || type == "all") {
37102
37087
  this.selection.start = {
@@ -37113,7 +37098,7 @@ class Editor {
37113
37098
  }
37114
37099
  } else {
37115
37100
  const firstNode = this.stackNodes[0];
37116
- let selectionNode = this.getFirstSelectionNodeInChildren(firstNode);
37101
+ let selectionNode = this.getFirstSelectionNode(firstNode);
37117
37102
  if (!selectionNode) selectionNode = this.getNextSelectionNode(firstNode);
37118
37103
  if (selectionNode) {
37119
37104
  if (type == "start" || type == "all") {
@@ -37136,7 +37121,7 @@ class Editor {
37136
37121
  */
37137
37122
  setSelectionAfter(node, type = "all") {
37138
37123
  if (node) {
37139
- const selectionNode = this.getLastSelectionNodeInChildren(node);
37124
+ const selectionNode = this.getLastSelectionNode(node);
37140
37125
  if (selectionNode) {
37141
37126
  if (type == "start" || type == "all") {
37142
37127
  this.selection.start = {
@@ -37153,7 +37138,7 @@ class Editor {
37153
37138
  }
37154
37139
  } else {
37155
37140
  const lastNode = this.stackNodes[this.stackNodes.length - 1];
37156
- let selectionNode = this.getLastSelectionNodeInChildren(lastNode);
37141
+ let selectionNode = this.getLastSelectionNode(lastNode);
37157
37142
  if (!selectionNode) selectionNode = this.getPreviousSelectionNode(lastNode);
37158
37143
  if (selectionNode) {
37159
37144
  if (type == "start" || type == "all") {
@@ -37218,7 +37203,7 @@ class Editor {
37218
37203
  /**
37219
37204
  * 判断光标是否在某个节点内,start表示只判断起点,end表示只判断终点,all表示起点和终点都判断
37220
37205
  */
37221
- isSelectionInNode(node, type = "all") {
37206
+ isSelectionInTargetNode(node, type = "all") {
37222
37207
  if (!this.selection.focused()) {
37223
37208
  return false;
37224
37209
  }
@@ -37290,7 +37275,7 @@ class Editor {
37290
37275
  break;
37291
37276
  } else {
37292
37277
  if (node.isContains(endNode)) {
37293
- const lastSelectionNode = this.getLastSelectionNodeInChildren(node);
37278
+ const lastSelectionNode = this.getLastSelectionNode(node);
37294
37279
  if (endNode.isEqual(lastSelectionNode) && endOffset == (endNode.isText() ? endNode.textContent.length : 1)) {
37295
37280
  result.push({
37296
37281
  node,
@@ -37382,11 +37367,7 @@ class Editor {
37382
37367
  if (!this.selection.focused() || this.selection.collapsed()) {
37383
37368
  return [];
37384
37369
  }
37385
- const nodes = [];
37386
- this.getSelectedNodes().forEach((item) => {
37387
- nodes.push(...item.node.getFocusNodes(type));
37388
- });
37389
- return nodes;
37370
+ return this.getSelectedNodes().flatMap((item) => item.node.getFocusNodes(type));
37390
37371
  }
37391
37372
  /**
37392
37373
  * 获取所有在光标范围内的可聚焦节点,该方法可能会切割部分文本节点,摒弃其不在光标范围内的部分,所以也可能会更新光标的位置
@@ -37422,10 +37403,10 @@ class Editor {
37422
37403
  newAfterTextNode.textContent = textContent.substring(item.offset[1]);
37423
37404
  nodes.push(item.node);
37424
37405
  }
37425
- if (this.isSelectionInNode(item.node, "start")) {
37406
+ if (this.isSelectionInTargetNode(item.node, "start")) {
37426
37407
  this.setSelectionBefore(item.node, "start");
37427
37408
  }
37428
- if (this.isSelectionInNode(item.node, "end")) {
37409
+ if (this.isSelectionInTargetNode(item.node, "end")) {
37429
37410
  this.setSelectionAfter(item.node, "end");
37430
37411
  }
37431
37412
  } else {
@@ -37449,7 +37430,6 @@ class Editor {
37449
37430
  if (!this.selection.focused()) {
37450
37431
  return;
37451
37432
  }
37452
- text2 = text2.replace(/\r\n/g, "\n");
37453
37433
  if (this.selection.collapsed()) {
37454
37434
  const node = this.selection.start.node;
37455
37435
  const offset2 = this.selection.start.offset;
@@ -37477,7 +37457,12 @@ class Editor {
37477
37457
  }
37478
37458
  }
37479
37459
  /**
37480
- * 向选区进行换行,如果所在块节点只有占位符并且块节点不是段落则会转为段落
37460
+ * 向选区进行换行
37461
+ * 1. 所在块节点只有占位符并且块节点不是段落则会转为段落
37462
+ * 2. 非代码块样式内换行是插入换行符\n
37463
+ * 2. 光标所在块节点是固定块节点,则无法换行
37464
+ * 3. 光标所在块节点只有占位符,并且其存在父节点,且父节点不是固定块节点,会从父节点抽离到与父节点同级
37465
+ * 4. 光标所在块节点只有占位符,并且不存在父节点,且不是段落,则会转为段落
37481
37466
  */
37482
37467
  insertParagraph() {
37483
37468
  if (!this.selection.focused()) {
@@ -37532,8 +37517,8 @@ class Editor {
37532
37517
  const selectionNode = this.selection.start.node;
37533
37518
  const offset2 = this.selection.start.offset;
37534
37519
  const blockNode = selectionNode.getBlock();
37535
- const firstSelectionNode = this.getFirstSelectionNodeInChildren(blockNode);
37536
- const lastSelectionNode = this.getLastSelectionNodeInChildren(blockNode);
37520
+ const firstSelectionNode = this.getFirstSelectionNode(blockNode);
37521
+ const lastSelectionNode = this.getLastSelectionNode(blockNode);
37537
37522
  if (!blockNode.fixed && node.isBlock() && !node.fixed) {
37538
37523
  if (!!selectionNode.isInCodeBlockStyle()) {
37539
37524
  node.type = "inline";