wysimark-lite 0.25.3 → 0.25.4

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/index.mjs CHANGED
@@ -13,7 +13,7 @@ import { createRoot } from "react-dom/client";
13
13
  // src/entry/index.tsx
14
14
  import throttle3 from "lodash.throttle";
15
15
  import { useCallback as useCallback18, useRef as useRef14, useState as useState13 } from "react";
16
- import { Editor as Editor67, Transforms as Transforms49 } from "slate";
16
+ import { Editor as Editor66, Transforms as Transforms48 } from "slate";
17
17
  import { ReactEditor as ReactEditor18, Slate as Slate2 } from "slate-react";
18
18
 
19
19
  // src/convert/parse/index.ts
@@ -132,15 +132,24 @@ function escapeUrlSlashes(text) {
132
132
  const markdownLinkPattern = /\[([^\]]+)\]\(([^)]+)\)/g;
133
133
  const links = [];
134
134
  let linkIndex = 0;
135
- const textWithoutLinks = text.replace(markdownLinkPattern, (match) => {
135
+ let result = text.replace(markdownLinkPattern, (match) => {
136
136
  links.push(match);
137
137
  return `__MARKDOWN_LINK_${linkIndex++}__`;
138
138
  });
139
+ const htmlBlocks = [];
140
+ let htmlIndex = 0;
141
+ const htmlBlockPattern = /<[a-zA-Z][^>]*>[\s\S]*?<\/[a-zA-Z]+>|<[a-zA-Z][^>]*\/?>|<\/[a-zA-Z]+>/g;
142
+ result = result.replace(htmlBlockPattern, (match) => {
143
+ htmlBlocks.push(match);
144
+ return `__HTML_BLOCK_${htmlIndex++}__`;
145
+ });
139
146
  const urlPattern = /(https?:\/\/[^\s]+)/g;
140
- const textWithEscapedUrls = textWithoutLinks.replace(urlPattern, (url) => {
147
+ result = result.replace(urlPattern, (url) => {
141
148
  return url.replace(/\//g, "\\/");
142
149
  });
143
- let result = textWithEscapedUrls;
150
+ for (let i = 0; i < htmlBlocks.length; i++) {
151
+ result = result.replace(`__HTML_BLOCK_${i}__`, htmlBlocks[i]);
152
+ }
144
153
  for (let i = 0; i < links.length; i++) {
145
154
  result = result.replace(`__MARKDOWN_LINK_${i}__`, links[i]);
146
155
  }
@@ -1546,7 +1555,17 @@ function serializeElements(elements) {
1546
1555
  const joined = segments.join("");
1547
1556
  if (joined.trim() === "")
1548
1557
  return "";
1549
- return joined.replace(/^\n+/, "").trim();
1558
+ return replaceConsecutiveNewlines(replaceLeadingNewlines(joined)).trim();
1559
+ }
1560
+ function replaceLeadingNewlines(input) {
1561
+ return input.replace(/^\n\n/g, "\\\n\n");
1562
+ }
1563
+ function replaceConsecutiveNewlines(input) {
1564
+ return input.replace(/(\n{4,})/g, (match) => {
1565
+ const newlineCount = match.length;
1566
+ const count = Math.floor((newlineCount - 2) / 2);
1567
+ return "\n\n" + Array(count).fill("\\").join("\n\n") + "\n\n";
1568
+ });
1550
1569
  }
1551
1570
 
1552
1571
  // src/convert/serialize/index.ts
@@ -1599,7 +1618,6 @@ var translations = {
1599
1618
  switchToRawMarkdown: "\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",
1600
1619
  codeBlock: "\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",
1601
1620
  increaseQuoteDepth: "\u5F15\u7528\u3092\u91CD\u306D\u308B",
1602
- horizontalRule: "\u533A\u5207\u308A\u7DDA",
1603
1621
  register: "\u767B\u9332",
1604
1622
  imageSourceUrl: "URL",
1605
1623
  imageSourceFile: "\u30D5\u30A1\u30A4\u30EB",
@@ -1652,7 +1670,6 @@ var translations = {
1652
1670
  switchToRawMarkdown: "Switch to raw markdown",
1653
1671
  codeBlock: "Code Block",
1654
1672
  increaseQuoteDepth: "Increase Quote Depth",
1655
- horizontalRule: "Horizontal Rule",
1656
1673
  register: "Register",
1657
1674
  imageSourceUrl: "URL",
1658
1675
  imageSourceFile: "File",
@@ -6220,37 +6237,11 @@ function HorizontalRule({
6220
6237
  }
6221
6238
 
6222
6239
  // src/horizontal-rule-plugin/methods/index.ts
6223
- import { Editor as Editor36, Element as Element21, Path as Path10, Transforms as Transforms27 } from "slate";
6224
6240
  function insertHorizontalRule(editor) {
6225
- const { selection } = editor;
6226
- if (!selection)
6227
- return false;
6228
- const entry = findElementUp(
6229
- editor,
6230
- (node) => Element21.isElement(node) && editor.isMaster(node)
6231
- );
6232
- const hrElement = {
6241
+ return insertRootElement(editor, {
6233
6242
  type: "horizontal-rule",
6234
6243
  children: [{ text: "" }]
6235
- };
6236
- const paragraphElement = {
6237
- type: "paragraph",
6238
- children: [{ text: "" }]
6239
- };
6240
- if (entry == null) {
6241
- Editor36.withoutNormalizing(editor, () => {
6242
- Transforms27.insertNodes(editor, [hrElement, paragraphElement]);
6243
- Transforms27.move(editor);
6244
- });
6245
- } else {
6246
- const nextPath = Path10.next(entry[1]);
6247
- Editor36.withoutNormalizing(editor, () => {
6248
- Transforms27.insertNodes(editor, [hrElement, paragraphElement], { at: nextPath });
6249
- const paragraphPath = Path10.next(nextPath);
6250
- Transforms27.select(editor, Editor36.start(editor, paragraphPath));
6251
- });
6252
- }
6253
- return true;
6244
+ });
6254
6245
  }
6255
6246
  function createHorizontalRuleMethods(editor) {
6256
6247
  return {
@@ -6355,7 +6346,7 @@ var InlineCodePlugin = createPlugin(
6355
6346
  );
6356
6347
 
6357
6348
  // src/list-plugin/index.tsx
6358
- import { Editor as Editor41, Path as Path11 } from "slate";
6349
+ import { Editor as Editor40, Path as Path10 } from "slate";
6359
6350
 
6360
6351
  // src/list-plugin/methods/convert-list-item.ts
6361
6352
  function convertOrderedList(editor, allowToggle) {
@@ -6439,36 +6430,36 @@ function indent(editor) {
6439
6430
  }
6440
6431
 
6441
6432
  // src/list-plugin/methods/insert-break.ts
6442
- import { Editor as Editor37, Transforms as Transforms28 } from "slate";
6433
+ import { Editor as Editor36, Transforms as Transforms27 } from "slate";
6443
6434
  function insertBreak2(editor) {
6444
6435
  const entry = findElementUp(editor, isListItem);
6445
6436
  if (!entry)
6446
6437
  return false;
6447
6438
  const [element, path] = entry;
6448
- if (Editor37.isEmpty(editor, element)) {
6439
+ if (Editor36.isEmpty(editor, element)) {
6449
6440
  if (element.depth > 0) {
6450
- Transforms28.setNodes(editor, { depth: element.depth - 1 }, { at: path });
6441
+ Transforms27.setNodes(editor, { depth: element.depth - 1 }, { at: path });
6451
6442
  return true;
6452
6443
  } else {
6453
6444
  rewrapElement(editor, { type: "paragraph" }, path);
6454
6445
  return true;
6455
6446
  }
6456
6447
  }
6457
- Transforms28.splitNodes(editor, { always: true });
6448
+ Transforms27.splitNodes(editor, { always: true });
6458
6449
  const nextEntry = findElementUp(editor, isListItem);
6459
6450
  if (!nextEntry)
6460
6451
  return true;
6461
6452
  if (nextEntry[0].type === "task-list-item" && nextEntry[0].checked === true) {
6462
- Transforms28.setNodes(editor, { checked: false }, { at: nextEntry[1] });
6453
+ Transforms27.setNodes(editor, { checked: false }, { at: nextEntry[1] });
6463
6454
  }
6464
6455
  return true;
6465
6456
  }
6466
6457
 
6467
6458
  // src/list-plugin/methods/outdent.ts
6468
- import { Editor as Editor38 } from "slate";
6459
+ import { Editor as Editor37 } from "slate";
6469
6460
  function outdent(editor) {
6470
6461
  const entries = Array.from(
6471
- Editor38.nodes(editor, {
6462
+ Editor37.nodes(editor, {
6472
6463
  match: isListItem
6473
6464
  })
6474
6465
  );
@@ -6486,7 +6477,7 @@ function outdent(editor) {
6486
6477
  }
6487
6478
 
6488
6479
  // src/list-plugin/methods/toggleTaskListItem.ts
6489
- import { Transforms as Transforms29 } from "slate";
6480
+ import { Transforms as Transforms28 } from "slate";
6490
6481
  function toggleTaskListItem(editor, { at = editor.selection } = {}) {
6491
6482
  const taskListItem = findElementUp(
6492
6483
  editor,
@@ -6496,7 +6487,7 @@ function toggleTaskListItem(editor, { at = editor.selection } = {}) {
6496
6487
  if (!taskListItem)
6497
6488
  return false;
6498
6489
  const nextChecked = !taskListItem[0].checked;
6499
- Transforms29.setNodes(
6490
+ Transforms28.setNodes(
6500
6491
  editor,
6501
6492
  { checked: nextChecked },
6502
6493
  { at: taskListItem[1] }
@@ -6522,20 +6513,20 @@ function createListMethods(editor) {
6522
6513
  }
6523
6514
 
6524
6515
  // src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts
6525
- import { Element as Element22, Transforms as Transforms30 } from "slate";
6516
+ import { Element as Element21, Transforms as Transforms29 } from "slate";
6526
6517
  var isOrderedListItem = createIsElementType([
6527
6518
  "ordered-list-item"
6528
6519
  ]);
6529
6520
  function normalizeOrderedFirstAtDepth(editor, entry) {
6530
6521
  const [node, path] = entry;
6531
- if (!Element22.isElement(node))
6522
+ if (!Element21.isElement(node))
6532
6523
  return false;
6533
6524
  return normalizeSiblings(editor, [node, path], (a, b) => {
6534
6525
  if (!isOrderedListItem(b[0]))
6535
6526
  return false;
6536
6527
  const __firstAtDepth = isOrderedListItem(a[0]) ? b[0].depth > a[0].depth : isListItem(a[0]) ? b[0].depth > a[0].depth : true;
6537
6528
  if (b[0].__firstAtDepth !== __firstAtDepth) {
6538
- Transforms30.setNodes(editor, { __firstAtDepth }, { at: b[1] });
6529
+ Transforms29.setNodes(editor, { __firstAtDepth }, { at: b[1] });
6539
6530
  return true;
6540
6531
  }
6541
6532
  return false;
@@ -6775,12 +6766,12 @@ var ListPlugin = createPlugin(
6775
6766
  if (!listItem)
6776
6767
  return false;
6777
6768
  const listItemPath = listItem[1];
6778
- if (!Path11.hasPrevious(listItemPath)) {
6769
+ if (!Path10.hasPrevious(listItemPath)) {
6779
6770
  editor.collapsibleParagraph.convertParagraph();
6780
6771
  return true;
6781
6772
  }
6782
- const prevElementPath = Path11.previous(listItemPath);
6783
- const prevElementEntry = Editor41.node(editor, prevElementPath);
6773
+ const prevElementPath = Path10.previous(listItemPath);
6774
+ const prevElementEntry = Editor40.node(editor, prevElementPath);
6784
6775
  if (isListItem(prevElementEntry[0]))
6785
6776
  return false;
6786
6777
  editor.collapsibleParagraph.convertParagraph();
@@ -6790,7 +6781,7 @@ var ListPlugin = createPlugin(
6790
6781
  editableProps: {
6791
6782
  renderElement: renderElement3,
6792
6783
  onKeyDown(e) {
6793
- if (!Editor41.nodes(editor, { match: isListItem }))
6784
+ if (!Editor40.nodes(editor, { match: isListItem }))
6794
6785
  return false;
6795
6786
  return hotkeyHandler(e);
6796
6787
  }
@@ -6801,15 +6792,15 @@ var ListPlugin = createPlugin(
6801
6792
 
6802
6793
  // src/marks-plugin/index.tsx
6803
6794
  import { clsx as clsx7 } from "clsx";
6804
- import { Editor as Editor44, Point as Point3, Range as Range8 } from "slate";
6795
+ import { Editor as Editor43, Point as Point3, Range as Range8 } from "slate";
6805
6796
 
6806
6797
  // src/marks-plugin/methods/removeMarks.ts
6807
- import { Editor as Editor42, Text as Text4, Transforms as Transforms31 } from "slate";
6798
+ import { Editor as Editor41, Text as Text4, Transforms as Transforms30 } from "slate";
6808
6799
  function removeMarks(editor, { at = editor.selection } = {}) {
6809
6800
  if (at == null)
6810
6801
  return;
6811
6802
  const nodeEntries = [
6812
- ...Editor42.nodes(editor, {
6803
+ ...Editor41.nodes(editor, {
6813
6804
  match: (n) => Text4.isText(n),
6814
6805
  at
6815
6806
  })
@@ -6822,7 +6813,7 @@ function removeMarks(editor, { at = editor.selection } = {}) {
6822
6813
  setter[key2] = null;
6823
6814
  }
6824
6815
  }
6825
- Transforms31.setNodes(editor, setter, {
6816
+ Transforms30.setNodes(editor, setter, {
6826
6817
  match: (n) => Text4.isText(n),
6827
6818
  split: true,
6828
6819
  at
@@ -6830,14 +6821,14 @@ function removeMarks(editor, { at = editor.selection } = {}) {
6830
6821
  }
6831
6822
 
6832
6823
  // src/marks-plugin/methods/toggle-mark.ts
6833
- import { Editor as Editor43, Point as Point2, Range as Range7 } from "slate";
6824
+ import { Editor as Editor42, Point as Point2, Range as Range7 } from "slate";
6834
6825
  function toggleMark(editor, markKey, unsetKey, { at = editor.selection } = {}) {
6835
6826
  if (at == null)
6836
6827
  return;
6837
6828
  const point = Range7.isRange(at) ? at.focus : at;
6838
- const isAtLineEnd = Point2.isPoint(point) && (Editor43.after(editor, point) === null || Editor43.isEnd(editor, point, Editor43.end(editor, [])));
6829
+ const isAtLineEnd = Point2.isPoint(point) && (Editor42.after(editor, point) === null || Editor42.isEnd(editor, point, Editor42.end(editor, [])));
6839
6830
  const validMarkKey = markKey;
6840
- const marks = Editor43.marks(editor) || {};
6831
+ const marks = Editor42.marks(editor) || {};
6841
6832
  const isActive = marks[validMarkKey] === true;
6842
6833
  if (isAtLineEnd) {
6843
6834
  if (!isActive) {
@@ -6851,12 +6842,12 @@ function toggleMark(editor, markKey, unsetKey, { at = editor.selection } = {}) {
6851
6842
  }
6852
6843
  }
6853
6844
  if (isActive) {
6854
- Editor43.removeMark(editor, validMarkKey);
6845
+ Editor42.removeMark(editor, validMarkKey);
6855
6846
  } else {
6856
- Editor43.addMark(editor, validMarkKey, true);
6847
+ Editor42.addMark(editor, validMarkKey, true);
6857
6848
  }
6858
6849
  if (typeof unsetKey === "string") {
6859
- Editor43.removeMark(editor, unsetKey);
6850
+ Editor42.removeMark(editor, unsetKey);
6860
6851
  }
6861
6852
  }
6862
6853
 
@@ -6931,7 +6922,7 @@ var MarksPlugin = createPlugin((editor) => {
6931
6922
  if (editor.selection) {
6932
6923
  const point = Range8.isRange(editor.selection) ? editor.selection.focus : editor.selection;
6933
6924
  if (Point3.isPoint(point)) {
6934
- const isAtLineEnd = Editor44.after(editor, point) === null || Editor44.isEnd(editor, point, Editor44.end(editor, []));
6925
+ const isAtLineEnd = Editor43.after(editor, point) === null || Editor43.isEnd(editor, point, Editor43.end(editor, []));
6935
6926
  if (isAtLineEnd) {
6936
6927
  editor.activeMarks = {};
6937
6928
  }
@@ -6966,11 +6957,11 @@ var MarksPlugin = createPlugin((editor) => {
6966
6957
  });
6967
6958
 
6968
6959
  // src/normalize-after-delete-plugin/index.tsx
6969
- import { Editor as Editor45, Point as Point4 } from "slate";
6960
+ import { Editor as Editor44, Point as Point4 } from "slate";
6970
6961
  function forceNormalizeNearestElement(editor) {
6971
6962
  if (!editor.selection)
6972
6963
  return;
6973
- const entry = Editor45.parent(editor, editor.selection);
6964
+ const entry = Editor44.parent(editor, editor.selection);
6974
6965
  forceNormalizePath(editor, entry[1]);
6975
6966
  }
6976
6967
  var NormalizeAfterDeletePlugin = createPlugin((editor) => {
@@ -6981,9 +6972,9 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
6981
6972
  deleteBackward() {
6982
6973
  if (!editor.selection)
6983
6974
  return false;
6984
- const entry = Editor45.parent(editor, editor.selection);
6975
+ const entry = Editor44.parent(editor, editor.selection);
6985
6976
  const isStart = Point4.equals(
6986
- Editor45.start(editor, entry[1]),
6977
+ Editor44.start(editor, entry[1]),
6987
6978
  editor.selection.anchor
6988
6979
  );
6989
6980
  if (!isStart)
@@ -6995,9 +6986,9 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
6995
6986
  deleteForward() {
6996
6987
  if (!editor.selection)
6997
6988
  return false;
6998
- const entry = Editor45.parent(editor, editor.selection);
6989
+ const entry = Editor44.parent(editor, editor.selection);
6999
6990
  const isEnd = Point4.equals(
7000
- Editor45.end(editor, entry[1]),
6991
+ Editor44.end(editor, entry[1]),
7001
6992
  editor.selection.anchor
7002
6993
  );
7003
6994
  if (!isEnd)
@@ -7012,15 +7003,15 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
7012
7003
  });
7013
7004
 
7014
7005
  // src/table-plugin/index.tsx
7015
- import { Element as Element24 } from "slate";
7006
+ import { Element as Element23 } from "slate";
7016
7007
 
7017
7008
  // src/table-plugin/delete-fragment/index.ts
7018
- import { Editor as Editor47, Path as Path13, Transforms as Transforms32 } from "slate";
7009
+ import { Editor as Editor46, Path as Path12, Transforms as Transforms31 } from "slate";
7019
7010
 
7020
7011
  // src/table-plugin/delete-fragment/get-reversed-delete-safe-ranges.ts
7021
- import { Editor as Editor46, Path as Path12 } from "slate";
7012
+ import { Editor as Editor45, Path as Path11 } from "slate";
7022
7013
  function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7023
- const positions = [...Editor46.positions(editor, { at: deleteRange })];
7014
+ const positions = [...Editor45.positions(editor, { at: deleteRange })];
7024
7015
  const deleteSafeRanges = [];
7025
7016
  let startPos, prevPos, startTdPath;
7026
7017
  startPos = prevPos = positions[0];
@@ -7031,7 +7022,7 @@ function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7031
7022
  const tdPath = findElementUpPath(editor, protectedTypes, {
7032
7023
  at: pos
7033
7024
  });
7034
- if (startTdPath && tdPath && Path12.equals(startTdPath, tdPath) || startTdPath == void 0 && tdPath == void 0) {
7025
+ if (startTdPath && tdPath && Path11.equals(startTdPath, tdPath) || startTdPath == void 0 && tdPath == void 0) {
7035
7026
  prevPos = pos;
7036
7027
  } else {
7037
7028
  const range2 = { anchor: startPos, focus: prevPos };
@@ -7050,7 +7041,7 @@ function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7050
7041
  function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7051
7042
  if (editor.selection == null)
7052
7043
  return false;
7053
- const [start, end] = Editor47.edges(editor, editor.selection);
7044
+ const [start, end] = Editor46.edges(editor, editor.selection);
7054
7045
  const startProtectedPath = findElementUpPath(editor, protectedTypes, {
7055
7046
  at: start
7056
7047
  });
@@ -7060,7 +7051,7 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7060
7051
  if (!startProtectedPath && !endProtectedPath) {
7061
7052
  return false;
7062
7053
  }
7063
- if (startProtectedPath && endProtectedPath && Path13.equals(startProtectedPath, endProtectedPath)) {
7054
+ if (startProtectedPath && endProtectedPath && Path12.equals(startProtectedPath, endProtectedPath)) {
7064
7055
  return false;
7065
7056
  }
7066
7057
  const reversedRanges = getReversedDeleteSafeRanges(
@@ -7068,17 +7059,17 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7068
7059
  editor.selection,
7069
7060
  protectedTypes
7070
7061
  );
7071
- Editor47.withoutNormalizing(editor, () => {
7062
+ Editor46.withoutNormalizing(editor, () => {
7072
7063
  for (const range of reversedRanges) {
7073
- Transforms32.delete(editor, { at: range });
7064
+ Transforms31.delete(editor, { at: range });
7074
7065
  }
7075
- Transforms32.collapse(editor, { edge: "start" });
7066
+ Transforms31.collapse(editor, { edge: "start" });
7076
7067
  });
7077
7068
  return true;
7078
7069
  }
7079
7070
 
7080
7071
  // src/table-plugin/methods/index.ts
7081
- import { Transforms as Transforms41 } from "slate";
7072
+ import { Transforms as Transforms40 } from "slate";
7082
7073
 
7083
7074
  // src/table-plugin/methods/get-table-info.ts
7084
7075
  function getTableInfo(editor, { at = editor.selection } = {}) {
@@ -7116,7 +7107,7 @@ function getTableInfo(editor, { at = editor.selection } = {}) {
7116
7107
  }
7117
7108
 
7118
7109
  // src/table-plugin/methods/insert-column.ts
7119
- import { Editor as Editor48, Transforms as Transforms33 } from "slate";
7110
+ import { Editor as Editor47, Transforms as Transforms32 } from "slate";
7120
7111
 
7121
7112
  // src/table-plugin/methods/utils.ts
7122
7113
  function createCell(index, children = [
@@ -7138,13 +7129,13 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
7138
7129
  return false;
7139
7130
  const { tableElement, tablePath, cellIndex } = t2;
7140
7131
  const nextCellIndex = cellIndex + offset;
7141
- Editor48.withoutNormalizing(editor, () => {
7132
+ Editor47.withoutNormalizing(editor, () => {
7142
7133
  const { columns } = tableElement;
7143
7134
  const nextColumns = [...columns];
7144
7135
  nextColumns.splice(nextCellIndex, 0, columns[nextCellIndex]);
7145
- Transforms33.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7136
+ Transforms32.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7146
7137
  tableElement.children.forEach((rowElement, i) => {
7147
- Transforms33.insertNodes(editor, createCell(nextCellIndex), {
7138
+ Transforms32.insertNodes(editor, createCell(nextCellIndex), {
7148
7139
  at: [...tablePath, i, nextCellIndex]
7149
7140
  });
7150
7141
  });
@@ -7153,7 +7144,7 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
7153
7144
  }
7154
7145
 
7155
7146
  // src/table-plugin/methods/insert-row.ts
7156
- import { Transforms as Transforms34 } from "slate";
7147
+ import { Transforms as Transforms33 } from "slate";
7157
7148
  function createRow(columnCount) {
7158
7149
  return {
7159
7150
  type: "table-row",
@@ -7165,7 +7156,7 @@ function insertRow(editor, { at = editor.selection, offset = 0 } = {}) {
7165
7156
  if (!t2)
7166
7157
  return false;
7167
7158
  const nextRowElement = createRow(t2.tableElement.columns.length);
7168
- Transforms34.insertNodes(editor, nextRowElement, {
7159
+ Transforms33.insertNodes(editor, nextRowElement, {
7169
7160
  at: [...t2.tablePath, t2.rowIndex + offset]
7170
7161
  });
7171
7162
  return true;
@@ -7175,7 +7166,7 @@ function insertRowBelow(editor, { at } = {}) {
7175
7166
  }
7176
7167
 
7177
7168
  // src/table-plugin/methods/insert-table.ts
7178
- import { Editor as Editor50, Element as Element23, Path as Path14, Transforms as Transforms35 } from "slate";
7169
+ import { Editor as Editor49, Element as Element22, Path as Path13, Transforms as Transforms34 } from "slate";
7179
7170
  function createRange(size) {
7180
7171
  return [...Array(size).keys()];
7181
7172
  }
@@ -7204,29 +7195,29 @@ function insertRootElement2(editor, element, { at = editor.selection } = {}) {
7204
7195
  return false;
7205
7196
  const entry = findElementUp(
7206
7197
  editor,
7207
- (node) => Element23.isElement(node) && editor.isMaster(node)
7198
+ (node) => Element22.isElement(node) && editor.isMaster(node)
7208
7199
  );
7209
7200
  if (entry == null) {
7210
7201
  const selection = editor.selection;
7211
- Editor50.withoutNormalizing(editor, () => {
7212
- Transforms35.insertNodes(editor, element, { at });
7202
+ Editor49.withoutNormalizing(editor, () => {
7203
+ Transforms34.insertNodes(editor, element, { at });
7213
7204
  if (selection) {
7214
- Transforms35.select(editor, selection);
7215
- Transforms35.move(editor);
7205
+ Transforms34.select(editor, selection);
7206
+ Transforms34.move(editor);
7216
7207
  }
7217
7208
  });
7218
7209
  } else {
7219
- const nextPath = Path14.next(entry[1]);
7220
- Editor50.withoutNormalizing(editor, () => {
7221
- Transforms35.insertNodes(editor, element, { at: nextPath });
7222
- Transforms35.select(editor, Editor50.start(editor, nextPath));
7210
+ const nextPath = Path13.next(entry[1]);
7211
+ Editor49.withoutNormalizing(editor, () => {
7212
+ Transforms34.insertNodes(editor, element, { at: nextPath });
7213
+ Transforms34.select(editor, Editor49.start(editor, nextPath));
7223
7214
  });
7224
7215
  }
7225
7216
  return true;
7226
7217
  }
7227
7218
 
7228
7219
  // src/table-plugin/methods/navigation/select-element.ts
7229
- import { Path as Path15 } from "slate";
7220
+ import { Path as Path14 } from "slate";
7230
7221
  function selectElementBelow(editor, t2) {
7231
7222
  const { cellIndex, rowIndex, rowCount, tablePath } = t2;
7232
7223
  if (rowIndex < rowCount - 1) {
@@ -7234,7 +7225,7 @@ function selectElementBelow(editor, t2) {
7234
7225
  return true;
7235
7226
  }
7236
7227
  try {
7237
- selectStartOfElement(editor, Path15.next(tablePath));
7228
+ selectStartOfElement(editor, Path14.next(tablePath));
7238
7229
  return true;
7239
7230
  } catch {
7240
7231
  return false;
@@ -7247,7 +7238,7 @@ function selectElementAbove(editor, t2) {
7247
7238
  return true;
7248
7239
  }
7249
7240
  try {
7250
- selectEndOfElement(editor, Path15.previous(tablePath));
7241
+ selectEndOfElement(editor, Path14.previous(tablePath));
7251
7242
  return true;
7252
7243
  } catch {
7253
7244
  return false;
@@ -7299,15 +7290,15 @@ function up(editor) {
7299
7290
  }
7300
7291
 
7301
7292
  // src/table-plugin/methods/remove-column.ts
7302
- import { Editor as Editor53, Transforms as Transforms37 } from "slate";
7293
+ import { Editor as Editor52, Transforms as Transforms36 } from "slate";
7303
7294
 
7304
7295
  // src/table-plugin/methods/remove-table.ts
7305
- import { Transforms as Transforms36 } from "slate";
7296
+ import { Transforms as Transforms35 } from "slate";
7306
7297
  function removeTable(editor) {
7307
7298
  const t2 = editor.tablePlugin.getTableInfo();
7308
7299
  if (t2 === void 0)
7309
7300
  return false;
7310
- Transforms36.removeNodes(editor, { at: t2.tablePath });
7301
+ Transforms35.removeNodes(editor, { at: t2.tablePath });
7311
7302
  return true;
7312
7303
  }
7313
7304
 
@@ -7320,26 +7311,26 @@ function removeColumn(editor, { at = editor.selection } = {}) {
7320
7311
  if (cellCount === 1) {
7321
7312
  return removeTable(editor);
7322
7313
  }
7323
- Editor53.withoutNormalizing(editor, () => {
7314
+ Editor52.withoutNormalizing(editor, () => {
7324
7315
  const columns = [...tableElement.columns];
7325
7316
  columns.splice(cellIndex, 1);
7326
- Transforms37.setNodes(editor, { columns }, { at: tablePath });
7317
+ Transforms36.setNodes(editor, { columns }, { at: tablePath });
7327
7318
  tableElement.children.forEach((rowElement, rowIndex2) => {
7328
- Transforms37.removeNodes(editor, {
7319
+ Transforms36.removeNodes(editor, {
7329
7320
  at: [...tablePath, rowIndex2, cellIndex]
7330
7321
  });
7331
7322
  });
7332
- const selection = Editor53.start(editor, [
7323
+ const selection = Editor52.start(editor, [
7333
7324
  ...tablePath,
7334
7325
  rowIndex,
7335
7326
  Math.min(cellIndex, cellCount - 2)
7336
7327
  ]);
7337
- Transforms37.select(editor, selection);
7328
+ Transforms36.select(editor, selection);
7338
7329
  });
7339
7330
  }
7340
7331
 
7341
7332
  // src/table-plugin/methods/remove-row.ts
7342
- import { Editor as Editor54, Transforms as Transforms38 } from "slate";
7333
+ import { Editor as Editor53, Transforms as Transforms37 } from "slate";
7343
7334
  function removeRow(editor, { at = editor.selection } = {}) {
7344
7335
  const t2 = getTableInfo(editor, { at });
7345
7336
  if (t2 === void 0)
@@ -7348,11 +7339,11 @@ function removeRow(editor, { at = editor.selection } = {}) {
7348
7339
  removeTable(editor);
7349
7340
  return true;
7350
7341
  }
7351
- Editor54.withoutNormalizing(editor, () => {
7352
- Transforms38.removeNodes(editor, { at: t2.rowPath });
7353
- Transforms38.select(
7342
+ Editor53.withoutNormalizing(editor, () => {
7343
+ Transforms37.removeNodes(editor, { at: t2.rowPath });
7344
+ Transforms37.select(
7354
7345
  editor,
7355
- Editor54.start(editor, [
7346
+ Editor53.start(editor, [
7356
7347
  ...t2.tablePath,
7357
7348
  Math.min(t2.rowIndex, t2.rowCount - 2),
7358
7349
  t2.cellIndex
@@ -7363,7 +7354,7 @@ function removeRow(editor, { at = editor.selection } = {}) {
7363
7354
  }
7364
7355
 
7365
7356
  // src/table-plugin/methods/setTableColumnAlign.ts
7366
- import { Transforms as Transforms39 } from "slate";
7357
+ import { Transforms as Transforms38 } from "slate";
7367
7358
  function setTableColumnAlign(editor, options) {
7368
7359
  const t2 = getTableInfo(editor);
7369
7360
  if (t2 === void 0)
@@ -7371,12 +7362,12 @@ function setTableColumnAlign(editor, options) {
7371
7362
  const { tableElement, tablePath, cellIndex } = t2;
7372
7363
  const nextColumns = tableElement.columns.slice();
7373
7364
  nextColumns.splice(cellIndex, 1, { align: options.align });
7374
- Transforms39.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7365
+ Transforms38.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7375
7366
  return true;
7376
7367
  }
7377
7368
 
7378
7369
  // src/table-plugin/methods/tab.ts
7379
- import { Path as Path16, Transforms as Transforms40 } from "slate";
7370
+ import { Path as Path15, Transforms as Transforms39 } from "slate";
7380
7371
  function tabForward(editor) {
7381
7372
  const t2 = getTableInfo(editor);
7382
7373
  if (!t2)
@@ -7390,8 +7381,8 @@ function tabForward(editor) {
7390
7381
  selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0]);
7391
7382
  return true;
7392
7383
  }
7393
- const nextPath = Path16.next(tablePath);
7394
- Transforms40.insertNodes(
7384
+ const nextPath = Path15.next(tablePath);
7385
+ Transforms39.insertNodes(
7395
7386
  editor,
7396
7387
  { type: "paragraph", children: [{ text: "" }] },
7397
7388
  { at: nextPath }
@@ -7455,12 +7446,12 @@ function selectCell(editor, { at = editor.selection } = {}) {
7455
7446
  if (t2 === void 0)
7456
7447
  return false;
7457
7448
  const { cellPath } = t2;
7458
- Transforms41.select(editor, cellPath);
7449
+ Transforms40.select(editor, cellPath);
7459
7450
  return true;
7460
7451
  }
7461
7452
 
7462
7453
  // src/table-plugin/normalize/normalize-table.ts
7463
- import { Transforms as Transforms42 } from "slate";
7454
+ import { Transforms as Transforms41 } from "slate";
7464
7455
  function normalizeTableIndexes(editor, entry) {
7465
7456
  let isTransformed = false;
7466
7457
  const rowElements = entry[0].children;
@@ -7468,7 +7459,7 @@ function normalizeTableIndexes(editor, entry) {
7468
7459
  const cellElements = rowElement.children;
7469
7460
  cellElements.forEach((cellElement, x) => {
7470
7461
  if (cellElement.x !== x || cellElement.y !== y) {
7471
- Transforms42.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
7462
+ Transforms41.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
7472
7463
  isTransformed = true;
7473
7464
  }
7474
7465
  });
@@ -7477,14 +7468,14 @@ function normalizeTableIndexes(editor, entry) {
7477
7468
  }
7478
7469
 
7479
7470
  // src/table-plugin/normalize/normalize-table-cell.ts
7480
- import { Editor as Editor59, Transforms as Transforms43 } from "slate";
7471
+ import { Editor as Editor58, Transforms as Transforms42 } from "slate";
7481
7472
  function normalizeTableCell(editor, entry) {
7482
7473
  const [node, path] = entry;
7483
7474
  if (node.children.length === 1 && node.children[0].type === "table-content") {
7484
7475
  return false;
7485
7476
  }
7486
- Editor59.withoutNormalizing(editor, () => {
7487
- Transforms43.insertNodes(
7477
+ Editor58.withoutNormalizing(editor, () => {
7478
+ Transforms42.insertNodes(
7488
7479
  editor,
7489
7480
  {
7490
7481
  type: "table-content",
@@ -7493,9 +7484,9 @@ function normalizeTableCell(editor, entry) {
7493
7484
  { at: [...entry[1], 0] }
7494
7485
  );
7495
7486
  for (let i = node.children.length; i >= 0; i--) {
7496
- Transforms43.mergeNodes(editor, { at: [...path, i] });
7487
+ Transforms42.mergeNodes(editor, { at: [...path, i] });
7497
7488
  }
7498
- Transforms43.delete(editor, {
7489
+ Transforms42.delete(editor, {
7499
7490
  at: { path: [...path, 0, 0], offset: 0 },
7500
7491
  unit: "character"
7501
7492
  });
@@ -8056,7 +8047,7 @@ var TablePlugin = createPlugin(
8056
8047
  },
8057
8048
  normalizeNode: (entry) => {
8058
8049
  const [node] = entry;
8059
- if (!Element24.isElement(node))
8050
+ if (!Element23.isElement(node))
8060
8051
  return false;
8061
8052
  switch (node.type) {
8062
8053
  case "table":
@@ -8186,7 +8177,7 @@ var ThemePlugin = createPlugin((editor) => {
8186
8177
  // src/toolbar-plugin/render-editable/index.tsx
8187
8178
  import { clsx as clsx10 } from "clsx";
8188
8179
  import { useCallback as useCallback17, useRef as useRef13 } from "react";
8189
- import { Editor as Editor63, Transforms as Transforms45 } from "slate";
8180
+ import { Editor as Editor62, Transforms as Transforms44 } from "slate";
8190
8181
  import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as useSlateStatic21 } from "slate-react";
8191
8182
 
8192
8183
  // src/toolbar-plugin/components/dialog/table-dialog.tsx
@@ -8321,7 +8312,6 @@ var Highlight = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
8321
8312
  /* @__PURE__ */ jsx60("path", { d: "M13.5 6.5l4 4" }),
8322
8313
  /* @__PURE__ */ jsx60("path", { d: "m14 19 6-6M18 15l2 2M5 21h4" })
8323
8314
  ] });
8324
- var HorizontalRule2 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M5 12h14" }) });
8325
8315
 
8326
8316
  // src/toolbar-plugin/items/block-items.tsx
8327
8317
  var listDepthItems = [
@@ -8673,7 +8663,7 @@ import {
8673
8663
  useRef as useRef10,
8674
8664
  useState as useState10
8675
8665
  } from "react";
8676
- import { Editor as Editor60, Range as Range10 } from "slate";
8666
+ import { Editor as Editor59, Range as Range10 } from "slate";
8677
8667
  import { ReactEditor as ReactEditor14, useSlateStatic as useSlateStatic18 } from "slate-react";
8678
8668
 
8679
8669
  // src/toolbar-plugin/styles/dialog-shared-styles.ts
@@ -8745,7 +8735,7 @@ function AnchorDialog2({
8745
8735
  const initialText = useMemo2(() => {
8746
8736
  const { selection } = editor;
8747
8737
  if (selection && !Range10.isCollapsed(selection)) {
8748
- return Editor60.string(editor, selection);
8738
+ return Editor59.string(editor, selection);
8749
8739
  }
8750
8740
  return "";
8751
8741
  }, []);
@@ -8859,12 +8849,6 @@ var dialogItems = [
8859
8849
  title: t("insertTable"),
8860
8850
  more: true,
8861
8851
  Component: TableDialog
8862
- },
8863
- {
8864
- icon: HorizontalRule2,
8865
- title: t("horizontalRule"),
8866
- hotkey: "super+-",
8867
- action: (editor) => editor.horizontalRule.insertHorizontalRule()
8868
8852
  }
8869
8853
  ];
8870
8854
  var expandedDialogItems = dialogItems;
@@ -8879,9 +8863,9 @@ var smallDialogItems = [
8879
8863
  ];
8880
8864
 
8881
8865
  // src/toolbar-plugin/items/mark-items.tsx
8882
- import { Editor as Editor61 } from "slate";
8866
+ import { Editor as Editor60 } from "slate";
8883
8867
  function getMarks(editor) {
8884
- const marks = Editor61.marks(editor);
8868
+ const marks = Editor60.marks(editor);
8885
8869
  return {
8886
8870
  bold: marks?.bold || false,
8887
8871
  italic: marks?.italic || false,
@@ -8979,7 +8963,7 @@ var compactListItems = [
8979
8963
  ];
8980
8964
 
8981
8965
  // src/toolbar-plugin/items/quote-items.tsx
8982
- import { Editor as Editor62, Transforms as Transforms44 } from "slate";
8966
+ import { Editor as Editor61, Transforms as Transforms43 } from "slate";
8983
8967
  var quoteItemsList = [
8984
8968
  {
8985
8969
  icon: Quote,
@@ -9008,9 +8992,9 @@ var quoteItemsList = [
9008
8992
  const codeBlockEntry = findElementUp(editor, "code-block");
9009
8993
  if (codeBlockEntry) {
9010
8994
  const [, path] = codeBlockEntry;
9011
- const textContent = Editor62.string(editor, path);
9012
- Transforms44.removeNodes(editor, { at: path });
9013
- Transforms44.insertNodes(
8995
+ const textContent = Editor61.string(editor, path);
8996
+ Transforms43.removeNodes(editor, { at: path });
8997
+ Transforms43.insertNodes(
9014
8998
  editor,
9015
8999
  {
9016
9000
  type: "paragraph",
@@ -9025,9 +9009,9 @@ var quoteItemsList = [
9025
9009
  return;
9026
9010
  }
9027
9011
  if (selection && (selection.anchor.offset !== selection.focus.offset || JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path))) {
9028
- const selectedText = Editor62.string(editor, selection);
9029
- Transforms44.delete(editor);
9030
- Transforms44.insertNodes(
9012
+ const selectedText = Editor61.string(editor, selection);
9013
+ Transforms43.delete(editor);
9014
+ Transforms43.insertNodes(
9031
9015
  editor,
9032
9016
  {
9033
9017
  type: "code-block",
@@ -9252,7 +9236,7 @@ function renderEditable({ attributes, Editable: Editable3 }) {
9252
9236
  (e) => {
9253
9237
  if (e.target !== e.currentTarget)
9254
9238
  return;
9255
- Transforms45.select(editor, Editor63.end(editor, []));
9239
+ Transforms44.select(editor, Editor62.end(editor, []));
9256
9240
  ReactEditor16.focus(editor);
9257
9241
  },
9258
9242
  [editor]
@@ -9302,7 +9286,7 @@ var ToolbarPlugin = createPlugin(
9302
9286
  );
9303
9287
 
9304
9288
  // src/trailing-block-plugin/index.tsx
9305
- import { Editor as Editor64, Node as Node15, Path as Path17, Transforms as Transforms46 } from "slate";
9289
+ import { Editor as Editor63, Node as Node15, Path as Path16, Transforms as Transforms45 } from "slate";
9306
9290
  var TrailingBlockPlugin = createPlugin(
9307
9291
  (editor) => {
9308
9292
  editor.allowTrailingBlock = true;
@@ -9310,19 +9294,19 @@ var TrailingBlockPlugin = createPlugin(
9310
9294
  name: "trailing-block",
9311
9295
  editor: {
9312
9296
  normalizeNode: (entry) => {
9313
- if (!Editor64.isEditor(entry[0]))
9297
+ if (!Editor63.isEditor(entry[0]))
9314
9298
  return false;
9315
9299
  const lastPath = [editor.children.length - 1];
9316
9300
  const lastElement = Node15.child(
9317
9301
  editor,
9318
9302
  editor.children.length - 1
9319
9303
  );
9320
- if (Editor64.hasBlocks(editor, lastElement) || Editor64.isVoid(editor, lastElement)) {
9321
- Transforms46.insertNodes(
9304
+ if (Editor63.hasBlocks(editor, lastElement) || Editor63.isVoid(editor, lastElement)) {
9305
+ Transforms45.insertNodes(
9322
9306
  editor,
9323
9307
  { type: "paragraph", children: [{ text: "" }] },
9324
9308
  {
9325
- at: Path17.next(lastPath)
9309
+ at: Path16.next(lastPath)
9326
9310
  }
9327
9311
  );
9328
9312
  }
@@ -9334,11 +9318,11 @@ var TrailingBlockPlugin = createPlugin(
9334
9318
  );
9335
9319
 
9336
9320
  // src/paste-markdown-plugin/methods/index.ts
9337
- import { Transforms as Transforms47 } from "slate";
9321
+ import { Transforms as Transforms46 } from "slate";
9338
9322
  function pasteMarkdown(editor, markdown) {
9339
9323
  const escapedMarkdown = escapeUrlSlashes(markdown);
9340
9324
  const fragment = parse(escapedMarkdown);
9341
- Transforms47.insertNodes(editor, fragment);
9325
+ Transforms46.insertNodes(editor, fragment);
9342
9326
  }
9343
9327
  function createPasteMarkdownMethods(editor) {
9344
9328
  return {
@@ -9424,7 +9408,7 @@ var { withSink, SinkEditable: SinkEditable2 } = Sink;
9424
9408
 
9425
9409
  // src/entry/useEditor.tsx
9426
9410
  import { useState as useState12 } from "react";
9427
- import { createEditor, Editor as Editor66, Transforms as Transforms48 } from "slate";
9411
+ import { createEditor, Editor as Editor65, Transforms as Transforms47 } from "slate";
9428
9412
  import { withHistory } from "slate-history";
9429
9413
  import { withReact } from "slate-react";
9430
9414
  function useEditor({
@@ -9470,7 +9454,7 @@ function useEditor({
9470
9454
  const documentValue = parse(escapedMarkdown);
9471
9455
  editor2.children = documentValue;
9472
9456
  editor2.selection = null;
9473
- Transforms48.select(editor2, Editor66.start(editor2, [0]));
9457
+ Transforms47.select(editor2, Editor65.start(editor2, [0]));
9474
9458
  };
9475
9459
  return nextEditor;
9476
9460
  });
@@ -9542,7 +9526,7 @@ function Editable2({
9542
9526
  const documentValue = parse(valueToProcess);
9543
9527
  editor.children = documentValue;
9544
9528
  editor.selection = null;
9545
- Transforms49.select(editor, Editor67.start(editor, [0]));
9529
+ Transforms48.select(editor, Editor66.start(editor, [0]));
9546
9530
  }
9547
9531
  }
9548
9532
  }