wysimark-lite 0.25.4 → 0.25.5

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 Editor66, Transforms as Transforms48 } from "slate";
16
+ import { Editor as Editor67, Transforms as Transforms49 } from "slate";
17
17
  import { ReactEditor as ReactEditor18, Slate as Slate2 } from "slate-react";
18
18
 
19
19
  // src/convert/parse/index.ts
@@ -137,12 +137,8 @@ function escapeUrlSlashes(text) {
137
137
  return `__MARKDOWN_LINK_${linkIndex++}__`;
138
138
  });
139
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
- });
140
+ const masked = maskHtmlBlocks(result, htmlBlocks);
141
+ result = masked;
146
142
  const urlPattern = /(https?:\/\/[^\s]+)/g;
147
143
  result = result.replace(urlPattern, (url) => {
148
144
  return url.replace(/\//g, "\\/");
@@ -156,10 +152,179 @@ function escapeUrlSlashes(text) {
156
152
  return result;
157
153
  }
158
154
  function unescapeUrlSlashes(text) {
159
- return text.replace(/\\(.)/g, (match, char) => {
155
+ return text.replace(/\\(.)/g, (_match, char) => {
160
156
  return char;
161
157
  });
162
158
  }
159
+ var RAW_TEXT_TAGS = /* @__PURE__ */ new Set(["script", "style"]);
160
+ function maskHtmlBlocks(text, htmlBlocks) {
161
+ let output = "";
162
+ let index = 0;
163
+ while (index < text.length) {
164
+ const ltIndex = text.indexOf("<", index);
165
+ if (ltIndex === -1) {
166
+ output += text.slice(index);
167
+ break;
168
+ }
169
+ output += text.slice(index, ltIndex);
170
+ if (text.startsWith("<!--", ltIndex)) {
171
+ const end = text.indexOf("-->", ltIndex + 4);
172
+ if (end === -1) {
173
+ output += text.slice(ltIndex);
174
+ break;
175
+ }
176
+ const block2 = text.slice(ltIndex, end + 3);
177
+ htmlBlocks.push(block2);
178
+ output += `__HTML_BLOCK_${htmlBlocks.length - 1}__`;
179
+ index = end + 3;
180
+ continue;
181
+ }
182
+ if (text.startsWith("<![CDATA[", ltIndex)) {
183
+ const end = text.indexOf("]]>", ltIndex + 9);
184
+ if (end === -1) {
185
+ output += text.slice(ltIndex);
186
+ break;
187
+ }
188
+ const block2 = text.slice(ltIndex, end + 3);
189
+ htmlBlocks.push(block2);
190
+ output += `__HTML_BLOCK_${htmlBlocks.length - 1}__`;
191
+ index = end + 3;
192
+ continue;
193
+ }
194
+ const tag = parseTag(text, ltIndex);
195
+ if (!tag) {
196
+ output += "<";
197
+ index = ltIndex + 1;
198
+ continue;
199
+ }
200
+ const blockIndex = htmlBlocks.length;
201
+ const placeholder = `__HTML_BLOCK_${blockIndex}__`;
202
+ if (!tag.name) {
203
+ const block2 = text.slice(ltIndex, tag.endIndex + 1);
204
+ htmlBlocks.push(block2);
205
+ output += placeholder;
206
+ index = tag.endIndex + 1;
207
+ continue;
208
+ }
209
+ const tagName = tag.name.toLowerCase();
210
+ if (tag.isClosing || tag.isSelfClosing) {
211
+ const block2 = text.slice(ltIndex, tag.endIndex + 1);
212
+ htmlBlocks.push(block2);
213
+ output += placeholder;
214
+ index = tag.endIndex + 1;
215
+ continue;
216
+ }
217
+ if (RAW_TEXT_TAGS.has(tagName)) {
218
+ const closeStart = text.toLowerCase().indexOf(`</${tagName}`, tag.endIndex + 1);
219
+ if (closeStart !== -1) {
220
+ const closeTag = parseTag(text, closeStart);
221
+ if (closeTag) {
222
+ const block2 = text.slice(ltIndex, closeTag.endIndex + 1);
223
+ htmlBlocks.push(block2);
224
+ output += placeholder;
225
+ index = closeTag.endIndex + 1;
226
+ continue;
227
+ }
228
+ }
229
+ }
230
+ const closingTagEnd = findClosingTagEnd(text, tagName, tag.endIndex + 1);
231
+ if (closingTagEnd !== null) {
232
+ const block2 = text.slice(ltIndex, closingTagEnd + 1);
233
+ htmlBlocks.push(block2);
234
+ output += placeholder;
235
+ index = closingTagEnd + 1;
236
+ continue;
237
+ }
238
+ const block = text.slice(ltIndex, tag.endIndex + 1);
239
+ htmlBlocks.push(block);
240
+ output += placeholder;
241
+ index = tag.endIndex + 1;
242
+ }
243
+ return output;
244
+ }
245
+ function parseTag(text, startIndex) {
246
+ if (text[startIndex] !== "<")
247
+ return null;
248
+ const endIndex = findTagEnd(text, startIndex);
249
+ if (endIndex === -1)
250
+ return null;
251
+ let cursor = startIndex + 1;
252
+ if (cursor >= text.length)
253
+ return null;
254
+ const firstChar = text[cursor];
255
+ if (firstChar === "!" || firstChar === "?") {
256
+ return {
257
+ name: null,
258
+ endIndex,
259
+ isClosing: false,
260
+ isSelfClosing: true
261
+ };
262
+ }
263
+ let isClosing = false;
264
+ if (firstChar === "/") {
265
+ isClosing = true;
266
+ cursor += 1;
267
+ }
268
+ const nameMatch = /^[A-Za-z][A-Za-z0-9-]*/.exec(text.slice(cursor));
269
+ if (!nameMatch)
270
+ return null;
271
+ const name = nameMatch[0];
272
+ const tagText = text.slice(startIndex, endIndex + 1);
273
+ const isSelfClosing = /\/\s*>$/.test(tagText);
274
+ return {
275
+ name,
276
+ endIndex,
277
+ isClosing,
278
+ isSelfClosing
279
+ };
280
+ }
281
+ function findTagEnd(text, startIndex) {
282
+ let quote = null;
283
+ for (let i = startIndex + 1; i < text.length; i++) {
284
+ const char = text[i];
285
+ if (quote) {
286
+ if (char === quote) {
287
+ quote = null;
288
+ }
289
+ continue;
290
+ }
291
+ if (char === "'" || char === '"') {
292
+ quote = char;
293
+ continue;
294
+ }
295
+ if (char === ">") {
296
+ return i;
297
+ }
298
+ }
299
+ return -1;
300
+ }
301
+ function findClosingTagEnd(text, tagName, startIndex) {
302
+ let depth = 1;
303
+ let cursor = startIndex;
304
+ const lowerTag = tagName.toLowerCase();
305
+ while (cursor < text.length) {
306
+ const ltIndex = text.indexOf("<", cursor);
307
+ if (ltIndex === -1)
308
+ return null;
309
+ const tag = parseTag(text, ltIndex);
310
+ if (!tag || !tag.name) {
311
+ cursor = ltIndex + 1;
312
+ continue;
313
+ }
314
+ if (tag.name.toLowerCase() === lowerTag) {
315
+ if (tag.isClosing) {
316
+ depth -= 1;
317
+ } else if (!tag.isSelfClosing) {
318
+ depth += 1;
319
+ }
320
+ if (depth === 0) {
321
+ return tag.endIndex;
322
+ }
323
+ }
324
+ cursor = tag.endIndex + 1;
325
+ }
326
+ return null;
327
+ }
163
328
  function assert(pass, message) {
164
329
  if (!pass)
165
330
  throw new Error(`${message}`);
@@ -348,71 +513,36 @@ function sortMarks(marks) {
348
513
  }
349
514
 
350
515
  // src/convert/serialize/serialize-line/utils/text-utils.ts
351
- var ESCAPES = [
516
+ var INLINE_ESCAPES = [
352
517
  "\\",
353
- // escape
518
+ // escape character
354
519
  "`",
355
- // code
520
+ // inline code
356
521
  "*",
357
- // bold/italic/hr
522
+ // emphasis/bold
358
523
  "_",
359
- // bold/italic/hr
524
+ // emphasis/bold
360
525
  "[",
361
- // link/list
526
+ // link start
362
527
  "]",
363
- // link/list
364
- "(",
365
- // link
366
- ")",
367
- // link
368
- "#",
369
- // headings
370
- "+",
371
- // list
372
- "-",
373
- // hr/list
374
- ".",
375
- // numbered list
376
- "!",
377
- // image
378
- "|",
379
- // table
380
- "^",
381
- // sup
528
+ // link end
382
529
  "~",
383
- // sub/strikethrough
384
- "<",
385
- // link/html
386
- ">",
387
- // link/html
388
- /**
389
- * Includes all the characters in the list of Backslash escapes in the example
390
- * for GitHub Flavored Markdown.
391
- *
392
- * https://github.github.com/gfm/#backslash-escapes
393
- */
394
- "{",
395
- "}",
396
- "=",
397
- ":",
398
- ";",
399
- "$",
400
- "%",
401
- "&",
402
- "?",
403
- '"',
404
- "'",
405
- ",",
406
- "\\",
407
- "/",
408
- "@"
530
+ // strikethrough (GFM)
531
+ "|",
532
+ // table cell (GFM)
533
+ "<"
534
+ // HTML tag
409
535
  ];
410
- var ESCAPES_REGEXP = new RegExp(
411
- `(${ESCAPES.map((symbol) => `\\${symbol}`).join("|")})`,
536
+ var INLINE_ESCAPES_REGEXP = new RegExp(
537
+ `(${INLINE_ESCAPES.map((symbol) => `\\${symbol}`).join("|")})`,
412
538
  "g"
413
539
  );
414
540
  function escapeText(s) {
415
- return s.replace(ESCAPES_REGEXP, (s2) => `\\${s2}`);
541
+ let result = s.replace(INLINE_ESCAPES_REGEXP, (s2) => `\\${s2}`);
542
+ result = result.replace(/^(#{1,6})(\s)/m, "\\$1$2");
543
+ result = result.replace(/^(\d+)([.)]\s)/m, "$1\\$2");
544
+ result = result.replace(/^([-+>])\s/m, "\\$1 ");
545
+ return result;
416
546
  }
417
547
 
418
548
  // src/convert/parse/parse-phrasing-content/normalize-segment.ts
@@ -465,7 +595,7 @@ function parseGenericImage(image) {
465
595
  }
466
596
 
467
597
  // src/convert/parseUrl.ts
468
- var URL_REGEX = /^(\/[^?#]*)(?:\?([^#]*))?(#.*)?$/;
598
+ var URL_REGEX = /^([^?#]*)(?:\?([^#]*))?(#.*)?$/;
469
599
  function parseUrl(url) {
470
600
  try {
471
601
  const urlData = new URL(url);
@@ -499,8 +629,8 @@ function parseSize(s) {
499
629
  if (sizeMatch === null)
500
630
  return null;
501
631
  return {
502
- width: parseInt(sizeMatch[1]),
503
- height: parseInt(sizeMatch[2])
632
+ width: parseInt(sizeMatch[1], 10),
633
+ height: parseInt(sizeMatch[2], 10)
504
634
  };
505
635
  }
506
636
 
@@ -524,8 +654,8 @@ function parsePortiveImage(image) {
524
654
  alt: image.alt || void 0,
525
655
  width: size.width,
526
656
  height: size.height,
527
- srcWidth: parseInt(srcSizeMatch[1]),
528
- srcHeight: parseInt(srcSizeMatch[2])
657
+ srcWidth: parseInt(srcSizeMatch[1], 10),
658
+ srcHeight: parseInt(srcSizeMatch[2], 10)
529
659
  };
530
660
  }
531
661
 
@@ -1059,7 +1189,7 @@ function mergeAdjacentSpaces({
1059
1189
  }) {
1060
1190
  if (!isText(node) || !isPlainSpace(node) || node.code)
1061
1191
  return false;
1062
- if (!isText(nextNode) || !isPlainSpace(nextNode) || node.code)
1192
+ if (!isText(nextNode) || !isPlainSpace(nextNode) || nextNode.code)
1063
1193
  return false;
1064
1194
  nodes.splice(index, 2, { text: `${node.text}${nextNode.text}` });
1065
1195
  return true;
@@ -1455,7 +1585,7 @@ function serializeTableCell(element) {
1455
1585
  element.children
1456
1586
  )}`
1457
1587
  );
1458
- return element.children.map(serializeTableContent).join();
1588
+ return element.children.map(serializeTableContent).join("");
1459
1589
  }
1460
1590
  function serializeTableContent(element) {
1461
1591
  assertElementType(element, "table-content");
@@ -1470,7 +1600,7 @@ function serializeElement(element, orders) {
1470
1600
  return `[${serializeLine(element.children)}](${element.href})`;
1471
1601
  case "block-quote": {
1472
1602
  const lines = serializeElements(element.children);
1473
- return `${lines.split("\n").map((line) => `> ${line}`.trim()).join("\n")}
1603
+ return `${lines.split("\n").map((line) => line ? `> ${line}` : ">").join("\n")}
1474
1604
 
1475
1605
  `;
1476
1606
  }
@@ -1517,6 +1647,8 @@ function serializeElement(element, orders) {
1517
1647
  }
1518
1648
  case "image-block":
1519
1649
  return serializeImageBlock(element);
1650
+ case "image-inline":
1651
+ return `![${element.alt || ""}](${element.url})`;
1520
1652
  case "code-block":
1521
1653
  return serializeCodeBlock(element);
1522
1654
  case "code-block-line":
@@ -1555,17 +1687,7 @@ function serializeElements(elements) {
1555
1687
  const joined = segments.join("");
1556
1688
  if (joined.trim() === "")
1557
1689
  return "";
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
- });
1690
+ return joined.replace(/^\n+/, "").trim();
1569
1691
  }
1570
1692
 
1571
1693
  // src/convert/serialize/index.ts
@@ -1618,6 +1740,7 @@ var translations = {
1618
1740
  switchToRawMarkdown: "\u30DE\u30FC\u30AF\u30C0\u30A6\u30F3\u8868\u793A\u306B\u5207\u308A\u66FF\u3048",
1619
1741
  codeBlock: "\u30B3\u30FC\u30C9\u30D6\u30ED\u30C3\u30AF",
1620
1742
  increaseQuoteDepth: "\u5F15\u7528\u3092\u91CD\u306D\u308B",
1743
+ horizontalRule: "\u533A\u5207\u308A\u7DDA",
1621
1744
  register: "\u767B\u9332",
1622
1745
  imageSourceUrl: "URL",
1623
1746
  imageSourceFile: "\u30D5\u30A1\u30A4\u30EB",
@@ -1670,6 +1793,7 @@ var translations = {
1670
1793
  switchToRawMarkdown: "Switch to raw markdown",
1671
1794
  codeBlock: "Code Block",
1672
1795
  increaseQuoteDepth: "Increase Quote Depth",
1796
+ horizontalRule: "Horizontal Rule",
1673
1797
  register: "Register",
1674
1798
  imageSourceUrl: "URL",
1675
1799
  imageSourceFile: "File",
@@ -1875,7 +1999,7 @@ function SinkEditable(originalProps) {
1875
1999
  const editor = useSlateStatic();
1876
2000
  useEffect(() => {
1877
2001
  Editor.normalize(editor, { force: true });
1878
- }, []);
2002
+ }, [editor]);
1879
2003
  const { plugins: plugins2 } = editor.sink;
1880
2004
  const nextProps = useMemo(
1881
2005
  () => ({
@@ -1898,7 +2022,19 @@ function SinkEditable(originalProps) {
1898
2022
  onPaste: createOnPaste(originalProps.onPaste, plugins2),
1899
2023
  onDrop: createOnDrop(originalProps.onDrop, plugins2)
1900
2024
  }),
1901
- Object.values(originalProps)
2025
+ [
2026
+ originalProps.decorate,
2027
+ originalProps.renderElement,
2028
+ originalProps.renderLeaf,
2029
+ originalProps.renderPlaceholder,
2030
+ originalProps.onKeyDown,
2031
+ originalProps.onKeyUp,
2032
+ originalProps.onPaste,
2033
+ originalProps.onDrop,
2034
+ originalProps.placeholder,
2035
+ originalProps.className,
2036
+ plugins2
2037
+ ]
1902
2038
  );
1903
2039
  const NextEditable = useMemo(() => createEditable(plugins2), [plugins2]);
1904
2040
  return /* @__PURE__ */ jsx2(NextEditable, { ...nextProps });
@@ -2357,7 +2493,7 @@ function editLink(editor, { href, title, text }, { at }) {
2357
2493
  }
2358
2494
 
2359
2495
  // src/anchor-plugin/methods/insertLink.ts
2360
- import { Editor as Editor15, Range as Range3, Text as Text2, Transforms as Transforms8 } from "slate";
2496
+ import { Editor as Editor15, Element as Element9, Range as Range3, Text as Text2, Transforms as Transforms8 } from "slate";
2361
2497
  function insertLink(editor, href, text = href, { select = true, title } = {}) {
2362
2498
  const selection = editor.selection || {
2363
2499
  anchor: Editor15.start(editor, [0]),
@@ -2384,7 +2520,7 @@ function insertLink(editor, href, text = href, { select = true, title } = {}) {
2384
2520
  { type: "anchor", href, title, children: [] },
2385
2521
  {
2386
2522
  split: true,
2387
- match: (node) => Text2.isText(node) || Editor15.isInline(editor, node)
2523
+ match: (node) => Text2.isText(node) || Element9.isElement(node) && Editor15.isInline(editor, node)
2388
2524
  }
2389
2525
  );
2390
2526
  }
@@ -2410,16 +2546,16 @@ function createAnchorMethods(editor) {
2410
2546
  }
2411
2547
 
2412
2548
  // src/anchor-plugin/normalize-node/index.ts
2413
- import { Element as Element9, Transforms as Transforms10 } from "slate";
2549
+ import { Element as Element10, Transforms as Transforms10 } from "slate";
2414
2550
  function normalizeNode(editor, entry) {
2415
- if (!Element9.isElement(entry[0]))
2551
+ if (!Element10.isElement(entry[0]))
2416
2552
  return false;
2417
2553
  if (entry[0].type !== "anchor")
2418
2554
  return false;
2419
2555
  const children = entry[0].children;
2420
2556
  for (let i = 0; i < children.length; i++) {
2421
2557
  const child = children[i];
2422
- if (!Element9.isElement(child) || child.type !== "anchor")
2558
+ if (!Element10.isElement(child) || child.type !== "anchor")
2423
2559
  continue;
2424
2560
  Transforms10.unwrapNodes(editor, { at: [...entry[1], i] });
2425
2561
  return true;
@@ -2718,15 +2854,18 @@ import { useEffect as useEffect2 } from "react";
2718
2854
 
2719
2855
  // src/use-reposition/hooks/use-throttled-refresh.ts
2720
2856
  import throttle from "lodash.throttle";
2721
- import { useState as useState2 } from "react";
2857
+ import { useMemo as useMemo2, useState as useState2 } from "react";
2722
2858
  function useThrottledRefresh(intervalInMs = 100) {
2723
2859
  const [counter, setState] = useState2(0);
2724
- const refresh = throttle(
2725
- () => {
2726
- setState((counter2) => counter2 + 1);
2727
- },
2728
- intervalInMs,
2729
- { trailing: true }
2860
+ const refresh = useMemo2(
2861
+ () => throttle(
2862
+ () => {
2863
+ setState((counter2) => counter2 + 1);
2864
+ },
2865
+ intervalInMs,
2866
+ { trailing: true }
2867
+ ),
2868
+ [intervalInMs]
2730
2869
  );
2731
2870
  return Object.assign(refresh, { counter });
2732
2871
  }
@@ -3094,6 +3233,8 @@ function Menu({
3094
3233
  const editor = useSlateStatic2();
3095
3234
  const ref = useRef2(null);
3096
3235
  const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
3236
+ if (!dest2)
3237
+ return { left: 0, top: 0 };
3097
3238
  return { left: dest2.left - 8, top: dest2.top + dest2.height };
3098
3239
  });
3099
3240
  return /* @__PURE__ */ jsxs3(Fragment2, { children: [
@@ -3778,7 +3919,7 @@ var AnchorPlugin = createPlugin(
3778
3919
  import { Editor as Editor19, Transforms as Transforms11 } from "slate";
3779
3920
 
3780
3921
  // src/atomic-delete-plugin/is-safe-delete.ts
3781
- import { Element as Element10, Path as Path6 } from "slate";
3922
+ import { Element as Element11, Path as Path6 } from "slate";
3782
3923
  function isSafeDelete(editor, a, b) {
3783
3924
  if (!a || !b)
3784
3925
  return true;
@@ -3786,13 +3927,13 @@ function isSafeDelete(editor, a, b) {
3786
3927
  return true;
3787
3928
  const masterEntryA = findElementUp(
3788
3929
  editor,
3789
- (el) => Element10.isElement(el) && editor.isMaster(el),
3930
+ (el) => Element11.isElement(el) && editor.isMaster(el),
3790
3931
  { at: a[1] }
3791
3932
  );
3792
3933
  const masterEntryB = findElementUp(
3793
3934
  editor,
3794
3935
  (el) => {
3795
- return Element10.isElement(el) && editor.isMaster(el);
3936
+ return Element11.isElement(el) && editor.isMaster(el);
3796
3937
  },
3797
3938
  { at: b[1] }
3798
3939
  );
@@ -4149,7 +4290,7 @@ function resizeInBounds(size, bounds) {
4149
4290
  }
4150
4291
  return size;
4151
4292
  }
4152
- function resizeInPreset(size, srcSize, preset) {
4293
+ function resizeInPreset(_size, srcSize, preset) {
4153
4294
  switch (preset.type) {
4154
4295
  case "bounds":
4155
4296
  return resizeInBounds(srcSize, preset);
@@ -4163,7 +4304,7 @@ function resizeInPreset(size, srcSize, preset) {
4163
4304
  function getEditorWidth(editor) {
4164
4305
  const element = ReactEditor4.toDOMNode(editor, editor);
4165
4306
  const computed = getComputedStyle(element);
4166
- const padding = parseInt(computed.paddingLeft) + parseInt(computed.paddingRight);
4307
+ const padding = parseInt(computed.paddingLeft, 10) + parseInt(computed.paddingRight, 10);
4167
4308
  return element.clientWidth - padding;
4168
4309
  }
4169
4310
 
@@ -4567,7 +4708,7 @@ import { useCallback as useCallback9 } from "react";
4567
4708
  import { useSlateStatic as useSlateStatic8 } from "slate-react";
4568
4709
 
4569
4710
  // src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-block-image.tsx
4570
- import { Editor as Editor23, Text as Text3, Transforms as Transforms16 } from "slate";
4711
+ import { Editor as Editor23, Element as Element12, Text as Text3, Transforms as Transforms16 } from "slate";
4571
4712
  import { ReactEditor as ReactEditor8 } from "slate-react";
4572
4713
  function convertToBlockImage(editor, element) {
4573
4714
  if (!element.width || !element.height || !element.srcWidth || !element.srcHeight)
@@ -4590,7 +4731,7 @@ function convertToBlockImage(editor, element) {
4590
4731
  );
4591
4732
  const parentEntry = findElementUp(
4592
4733
  editor,
4593
- (node) => Editor23.isBlock(editor, node) && node.type !== "image-block"
4734
+ (node) => Element12.isElement(node) && Editor23.isBlock(editor, node) && node.type !== "image-block"
4594
4735
  );
4595
4736
  if (!parentEntry)
4596
4737
  throw new Error("This shouldn't happen");
@@ -4918,7 +5059,7 @@ var ImagePlugin = (
4918
5059
  );
4919
5060
 
4920
5061
  // src/block-quote-plugin/index.tsx
4921
- import { Editor as Editor25, Element as Element11, Transforms as Transforms18 } from "slate";
5062
+ import { Editor as Editor25, Element as Element13, Transforms as Transforms18 } from "slate";
4922
5063
 
4923
5064
  // src/block-quote-plugin/styles.tsx
4924
5065
  import styled23 from "@emotion/styled";
@@ -4934,7 +5075,7 @@ var $BlockQuote = styled23("blockquote")`
4934
5075
  // src/block-quote-plugin/index.tsx
4935
5076
  import { jsx as jsx29 } from "react/jsx-runtime";
4936
5077
  function matchBlockQuoteSafe(node) {
4937
- return Element11.isElement(node) && /**
5078
+ return Element13.isElement(node) && /**
4938
5079
  * TODO:
4939
5080
  *
4940
5081
  * This is probably:
@@ -4962,13 +5103,13 @@ var BlockQuotePlugin = createPlugin(
4962
5103
  },
4963
5104
  isActive: () => {
4964
5105
  const [match] = Editor25.nodes(editor, {
4965
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5106
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
4966
5107
  });
4967
5108
  return !!match;
4968
5109
  },
4969
5110
  increaseDepth: () => {
4970
5111
  const [match] = Editor25.nodes(editor, {
4971
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5112
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
4972
5113
  });
4973
5114
  if (!match)
4974
5115
  return;
@@ -4984,7 +5125,7 @@ var BlockQuotePlugin = createPlugin(
4984
5125
  },
4985
5126
  decreaseDepth: () => {
4986
5127
  const [match] = Editor25.nodes(editor, {
4987
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5128
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
4988
5129
  });
4989
5130
  if (!match)
4990
5131
  return;
@@ -4992,24 +5133,24 @@ var BlockQuotePlugin = createPlugin(
4992
5133
  return;
4993
5134
  const [node, path] = match;
4994
5135
  const children = node.children;
4995
- if (children.length === 1 && Element11.isElement(children[0]) && children[0].type === "block-quote") {
5136
+ if (children.length === 1 && Element13.isElement(children[0]) && children[0].type === "block-quote") {
4996
5137
  Transforms18.unwrapNodes(editor, {
4997
5138
  at: [...path, 0],
4998
5139
  // Path to the nested block-quote
4999
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5140
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
5000
5141
  });
5001
5142
  }
5002
5143
  },
5003
5144
  canIncreaseDepth: () => {
5004
5145
  const [match] = Editor25.nodes(editor, {
5005
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5146
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
5006
5147
  });
5007
5148
  if (!match)
5008
5149
  return false;
5009
5150
  const [node] = match;
5010
5151
  let depth = 0;
5011
5152
  let current = node;
5012
- while (current.children.length === 1 && Element11.isElement(current.children[0]) && current.children[0] && current.children[0] && current.children[0].type === "block-quote") {
5153
+ while (current.children.length === 1 && Element13.isElement(current.children[0]) && current.children[0] && current.children[0] && current.children[0].type === "block-quote") {
5013
5154
  depth++;
5014
5155
  current = current.children[0];
5015
5156
  }
@@ -5017,12 +5158,12 @@ var BlockQuotePlugin = createPlugin(
5017
5158
  },
5018
5159
  canDecreaseDepth: () => {
5019
5160
  const [match] = Editor25.nodes(editor, {
5020
- match: (n) => Element11.isElement(n) && n.type === "block-quote"
5161
+ match: (n) => Element13.isElement(n) && n.type === "block-quote"
5021
5162
  });
5022
5163
  if (!match)
5023
5164
  return false;
5024
5165
  const [node] = match;
5025
- return node.children.length === 1 && Element11.isElement(node.children[0]) && node.children[0] && node.children[0].type === "block-quote";
5166
+ return node.children.length === 1 && Element13.isElement(node.children[0]) && node.children[0] && node.children[0].type === "block-quote";
5026
5167
  }
5027
5168
  };
5028
5169
  return {
@@ -5030,12 +5171,12 @@ var BlockQuotePlugin = createPlugin(
5030
5171
  editor: {
5031
5172
  normalizeNode(entry) {
5032
5173
  const [node, path] = entry;
5033
- if (!Element11.isElement(node))
5174
+ if (!Element13.isElement(node))
5034
5175
  return false;
5035
5176
  if (node.type !== "block-quote")
5036
5177
  return false;
5037
5178
  return normalizeSiblings(editor, [node, path], (a, b) => {
5038
- if (Element11.isElement(a[0]) && Element11.isElement(b[0]) && a[0].type === "block-quote" && b[0].type === "block-quote") {
5179
+ if (Element13.isElement(a[0]) && Element13.isElement(b[0]) && a[0].type === "block-quote" && b[0].type === "block-quote") {
5039
5180
  Transforms18.mergeNodes(editor, { at: b[1] });
5040
5181
  }
5041
5182
  return true;
@@ -5058,11 +5199,11 @@ var BlockQuotePlugin = createPlugin(
5058
5199
  );
5059
5200
 
5060
5201
  // src/code-block-plugin/index.tsx
5061
- import { Editor as Editor28, Element as Element15, Transforms as Transforms21 } from "slate";
5202
+ import { Editor as Editor28, Element as Element17, Transforms as Transforms21 } from "slate";
5062
5203
 
5063
5204
  // src/code-block-plugin/decorate.tsx
5064
5205
  import Prism from "prismjs";
5065
- import { Element as Element12, Node as Node8 } from "slate";
5206
+ import { Element as Element14, Node as Node8 } from "slate";
5066
5207
  var { languages, tokenize } = Prism;
5067
5208
  function getLineOffsets(lines) {
5068
5209
  let offset = 0;
@@ -5075,7 +5216,7 @@ function getLineOffsets(lines) {
5075
5216
  }
5076
5217
  function decorate(nodeEntry) {
5077
5218
  const [node, path] = nodeEntry;
5078
- if (!Element12.isElement(node))
5219
+ if (!Element14.isElement(node))
5079
5220
  return [];
5080
5221
  if (node.type !== "code-block")
5081
5222
  return [];
@@ -5129,11 +5270,11 @@ function createCodeBlock(editor, { language }) {
5129
5270
  }
5130
5271
 
5131
5272
  // src/code-block-plugin/methods/setCodeBlockLanguage.ts
5132
- import { Element as Element13, Transforms as Transforms19 } from "slate";
5273
+ import { Element as Element15, Transforms as Transforms19 } from "slate";
5133
5274
  function setCodeBlockLanguage(editor, language, options = {}) {
5134
5275
  const entry = findElementUp(
5135
5276
  editor,
5136
- (el) => Element13.isElement(el) && el.type === "code-block",
5277
+ (el) => Element15.isElement(el) && el.type === "code-block",
5137
5278
  { at: options.at }
5138
5279
  );
5139
5280
  if (!entry)
@@ -5205,13 +5346,13 @@ var LanguageList = [
5205
5346
  ];
5206
5347
 
5207
5348
  // src/code-block-plugin/normalizeNode.tsx
5208
- import { Element as Element14, Node as Node9, Transforms as Transforms20 } from "slate";
5349
+ import { Element as Element16, Node as Node9, Transforms as Transforms20 } from "slate";
5209
5350
  function normalizeNode3(editor, entry) {
5210
- if (!Element14.isElement(entry[0]))
5351
+ if (!Element16.isElement(entry[0]))
5211
5352
  return false;
5212
5353
  if (entry[0].type === "code-block-line") {
5213
5354
  for (const [child, path] of Node9.children(editor, entry[1])) {
5214
- if (!Element14.isElement(child))
5355
+ if (!Element16.isElement(child))
5215
5356
  continue;
5216
5357
  if (editor.isVoid(child)) {
5217
5358
  Transforms20.removeNodes(editor, { at: path });
@@ -5224,7 +5365,7 @@ function normalizeNode3(editor, entry) {
5224
5365
  }
5225
5366
  if (entry[0].type === "code-block") {
5226
5367
  for (const [child, path] of Node9.children(editor, entry[1])) {
5227
- if (!Element14.isElement(child))
5368
+ if (!Element16.isElement(child))
5228
5369
  continue;
5229
5370
  if (child.type === "code-block-line")
5230
5371
  continue;
@@ -5404,7 +5545,7 @@ function renderElement2({
5404
5545
  }
5405
5546
 
5406
5547
  // src/code-block-plugin/index.tsx
5407
- import { jsx as jsx34 } from "react/jsx-runtime";
5548
+ import { Fragment as Fragment4, jsx as jsx34 } from "react/jsx-runtime";
5408
5549
  var CodeBlockPlugin = createPlugin(
5409
5550
  (editor, _options, { createPolicy }) => {
5410
5551
  editor.codeBlock = createCodeBlockMethods(editor);
@@ -5432,7 +5573,7 @@ var CodeBlockPlugin = createPlugin(
5432
5573
  return false;
5433
5574
  },
5434
5575
  isVoid(element) {
5435
- if (element.type === "code-block" || element.type == "code-block-line")
5576
+ if (element.type === "code-block" || element.type === "code-block-line")
5436
5577
  return false;
5437
5578
  },
5438
5579
  isMaster(element) {
@@ -5448,7 +5589,7 @@ var CodeBlockPlugin = createPlugin(
5448
5589
  "mod+a": () => {
5449
5590
  const entry = findElementUp(
5450
5591
  editor,
5451
- (el) => Element15.isElement(el) && el.type === "code-block"
5592
+ (el) => Element17.isElement(el) && el.type === "code-block"
5452
5593
  );
5453
5594
  if (!entry)
5454
5595
  return false;
@@ -5460,7 +5601,7 @@ var CodeBlockPlugin = createPlugin(
5460
5601
  renderLeaf: ({ leaf, children }) => {
5461
5602
  const style = leaf.prismToken ? tokenStyles[leaf.prismToken] || null : null;
5462
5603
  if (style === null) {
5463
- return children;
5604
+ return /* @__PURE__ */ jsx34(Fragment4, { children });
5464
5605
  } else {
5465
5606
  return /* @__PURE__ */ jsx34("span", { style, children });
5466
5607
  }
@@ -5565,12 +5706,12 @@ var HtmlBlockPlugin = createPlugin(
5565
5706
  import { Editor as Editor32 } from "slate";
5566
5707
 
5567
5708
  // src/collapsible-paragraph-plugin/normalize-node/index.ts
5568
- import { Element as Element18 } from "slate";
5709
+ import { Element as Element20 } from "slate";
5569
5710
 
5570
5711
  // src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-paragraphs.ts
5571
- import { Element as Element16, Transforms as Transforms23 } from "slate";
5712
+ import { Element as Element18, Transforms as Transforms23 } from "slate";
5572
5713
  function isParagraph(node) {
5573
- return Element16.isElement(node) && node.type === "paragraph";
5714
+ return Element18.isElement(node) && node.type === "paragraph";
5574
5715
  }
5575
5716
  function normalizeSiblingParagraphs(editor, entry) {
5576
5717
  return normalizeSiblings(editor, entry, (a, b) => {
@@ -5585,9 +5726,9 @@ function normalizeSiblingParagraphs(editor, entry) {
5585
5726
  }
5586
5727
 
5587
5728
  // src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-walls.ts
5588
- import { Element as Element17, Transforms as Transforms24 } from "slate";
5729
+ import { Element as Element19, Transforms as Transforms24 } from "slate";
5589
5730
  function isWall(editor, node) {
5590
- if (!Element17.isElement(node))
5731
+ if (!Element19.isElement(node))
5591
5732
  return false;
5592
5733
  return editor.isVoid(node) || editor.isMaster(node);
5593
5734
  }
@@ -5613,7 +5754,7 @@ function normalizeSiblingWalls(editor, entry) {
5613
5754
  // src/collapsible-paragraph-plugin/normalize-node/index.ts
5614
5755
  function normalizeNode4(editor, entry) {
5615
5756
  const [node, path] = entry;
5616
- if (!Element18.isElement(node))
5757
+ if (!Element20.isElement(node))
5617
5758
  return false;
5618
5759
  if (normalizeSiblingWalls(editor, [node, path]))
5619
5760
  return true;
@@ -5758,7 +5899,7 @@ function addConvertElementType(editor, type) {
5758
5899
  }
5759
5900
 
5760
5901
  // src/convert-element-plugin/methods/convert-elements.ts
5761
- import { Editor as Editor33, Element as Element20, Node as Node13, Point, Range as Range5, Transforms as Transforms25 } from "slate";
5902
+ import { Editor as Editor33, Element as Element22, Node as Node13, Point, Range as Range5, Transforms as Transforms25 } from "slate";
5762
5903
  function getOffsetInElement(editor, point, elementPath) {
5763
5904
  try {
5764
5905
  const elementStart = Editor33.start(editor, elementPath);
@@ -5775,7 +5916,7 @@ function getOffsetInElement(editor, point, elementPath) {
5775
5916
  function restoreSelectionInElement(editor, elementPath, offset) {
5776
5917
  try {
5777
5918
  const element = Node13.get(editor, elementPath);
5778
- if (!Element20.isElement(element))
5919
+ if (!Element22.isElement(element))
5779
5920
  return;
5780
5921
  const text = Node13.string(element);
5781
5922
  const safeOffset = Math.min(offset, text.length);
@@ -5908,7 +6049,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
5908
6049
  const isCollapsed2 = Range5.isCollapsed(selection);
5909
6050
  const entries = Array.from(
5910
6051
  Editor33.nodes(editor, {
5911
- match: (node) => Element20.isElement(node) && editor.convertElement.isConvertibleElement(node)
6052
+ match: (node) => Element22.isElement(node) && editor.convertElement.isConvertibleElement(node)
5912
6053
  })
5913
6054
  );
5914
6055
  if (entries.length > 0) {
@@ -5938,7 +6079,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
5938
6079
  const updatedEntries = allPaths.map((path) => {
5939
6080
  try {
5940
6081
  const node = Node13.get(editor, path);
5941
- if (Element20.isElement(node)) {
6082
+ if (Element22.isElement(node)) {
5942
6083
  return [node, path];
5943
6084
  }
5944
6085
  return null;
@@ -5969,7 +6110,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
5969
6110
  } else if (savedFocusOffset >= 0) {
5970
6111
  try {
5971
6112
  const element = Node13.get(editor, firstPath);
5972
- if (Element20.isElement(element)) {
6113
+ if (Element22.isElement(element)) {
5973
6114
  const text = Node13.string(element);
5974
6115
  const safeAnchorOffset = Math.min(savedAnchorOffset, text.length);
5975
6116
  const safeFocusOffset = Math.min(savedFocusOffset, text.length);
@@ -6237,11 +6378,37 @@ function HorizontalRule({
6237
6378
  }
6238
6379
 
6239
6380
  // src/horizontal-rule-plugin/methods/index.ts
6381
+ import { Editor as Editor36, Element as Element23, Path as Path10, Transforms as Transforms27 } from "slate";
6240
6382
  function insertHorizontalRule(editor) {
6241
- return insertRootElement(editor, {
6383
+ const { selection } = editor;
6384
+ if (!selection)
6385
+ return false;
6386
+ const entry = findElementUp(
6387
+ editor,
6388
+ (node) => Element23.isElement(node) && editor.isMaster(node)
6389
+ );
6390
+ const hrElement = {
6242
6391
  type: "horizontal-rule",
6243
6392
  children: [{ text: "" }]
6244
- });
6393
+ };
6394
+ const paragraphElement = {
6395
+ type: "paragraph",
6396
+ children: [{ text: "" }]
6397
+ };
6398
+ if (entry == null) {
6399
+ Editor36.withoutNormalizing(editor, () => {
6400
+ Transforms27.insertNodes(editor, [hrElement, paragraphElement]);
6401
+ Transforms27.move(editor);
6402
+ });
6403
+ } else {
6404
+ const nextPath = Path10.next(entry[1]);
6405
+ Editor36.withoutNormalizing(editor, () => {
6406
+ Transforms27.insertNodes(editor, [hrElement, paragraphElement], { at: nextPath });
6407
+ const paragraphPath = Path10.next(nextPath);
6408
+ Transforms27.select(editor, Editor36.start(editor, paragraphPath));
6409
+ });
6410
+ }
6411
+ return true;
6245
6412
  }
6246
6413
  function createHorizontalRuleMethods(editor) {
6247
6414
  return {
@@ -6346,7 +6513,7 @@ var InlineCodePlugin = createPlugin(
6346
6513
  );
6347
6514
 
6348
6515
  // src/list-plugin/index.tsx
6349
- import { Editor as Editor40, Path as Path10 } from "slate";
6516
+ import { Editor as Editor41, Path as Path11 } from "slate";
6350
6517
 
6351
6518
  // src/list-plugin/methods/convert-list-item.ts
6352
6519
  function convertOrderedList(editor, allowToggle) {
@@ -6430,36 +6597,36 @@ function indent(editor) {
6430
6597
  }
6431
6598
 
6432
6599
  // src/list-plugin/methods/insert-break.ts
6433
- import { Editor as Editor36, Transforms as Transforms27 } from "slate";
6600
+ import { Editor as Editor37, Transforms as Transforms28 } from "slate";
6434
6601
  function insertBreak2(editor) {
6435
6602
  const entry = findElementUp(editor, isListItem);
6436
6603
  if (!entry)
6437
6604
  return false;
6438
6605
  const [element, path] = entry;
6439
- if (Editor36.isEmpty(editor, element)) {
6606
+ if (Editor37.isEmpty(editor, element)) {
6440
6607
  if (element.depth > 0) {
6441
- Transforms27.setNodes(editor, { depth: element.depth - 1 }, { at: path });
6608
+ Transforms28.setNodes(editor, { depth: element.depth - 1 }, { at: path });
6442
6609
  return true;
6443
6610
  } else {
6444
6611
  rewrapElement(editor, { type: "paragraph" }, path);
6445
6612
  return true;
6446
6613
  }
6447
6614
  }
6448
- Transforms27.splitNodes(editor, { always: true });
6615
+ Transforms28.splitNodes(editor, { always: true });
6449
6616
  const nextEntry = findElementUp(editor, isListItem);
6450
6617
  if (!nextEntry)
6451
6618
  return true;
6452
6619
  if (nextEntry[0].type === "task-list-item" && nextEntry[0].checked === true) {
6453
- Transforms27.setNodes(editor, { checked: false }, { at: nextEntry[1] });
6620
+ Transforms28.setNodes(editor, { checked: false }, { at: nextEntry[1] });
6454
6621
  }
6455
6622
  return true;
6456
6623
  }
6457
6624
 
6458
6625
  // src/list-plugin/methods/outdent.ts
6459
- import { Editor as Editor37 } from "slate";
6626
+ import { Editor as Editor38 } from "slate";
6460
6627
  function outdent(editor) {
6461
6628
  const entries = Array.from(
6462
- Editor37.nodes(editor, {
6629
+ Editor38.nodes(editor, {
6463
6630
  match: isListItem
6464
6631
  })
6465
6632
  );
@@ -6477,7 +6644,7 @@ function outdent(editor) {
6477
6644
  }
6478
6645
 
6479
6646
  // src/list-plugin/methods/toggleTaskListItem.ts
6480
- import { Transforms as Transforms28 } from "slate";
6647
+ import { Transforms as Transforms29 } from "slate";
6481
6648
  function toggleTaskListItem(editor, { at = editor.selection } = {}) {
6482
6649
  const taskListItem = findElementUp(
6483
6650
  editor,
@@ -6487,7 +6654,7 @@ function toggleTaskListItem(editor, { at = editor.selection } = {}) {
6487
6654
  if (!taskListItem)
6488
6655
  return false;
6489
6656
  const nextChecked = !taskListItem[0].checked;
6490
- Transforms28.setNodes(
6657
+ Transforms29.setNodes(
6491
6658
  editor,
6492
6659
  { checked: nextChecked },
6493
6660
  { at: taskListItem[1] }
@@ -6513,20 +6680,20 @@ function createListMethods(editor) {
6513
6680
  }
6514
6681
 
6515
6682
  // src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts
6516
- import { Element as Element21, Transforms as Transforms29 } from "slate";
6683
+ import { Element as Element24, Transforms as Transforms30 } from "slate";
6517
6684
  var isOrderedListItem = createIsElementType([
6518
6685
  "ordered-list-item"
6519
6686
  ]);
6520
6687
  function normalizeOrderedFirstAtDepth(editor, entry) {
6521
6688
  const [node, path] = entry;
6522
- if (!Element21.isElement(node))
6689
+ if (!Element24.isElement(node))
6523
6690
  return false;
6524
6691
  return normalizeSiblings(editor, [node, path], (a, b) => {
6525
6692
  if (!isOrderedListItem(b[0]))
6526
6693
  return false;
6527
6694
  const __firstAtDepth = isOrderedListItem(a[0]) ? b[0].depth > a[0].depth : isListItem(a[0]) ? b[0].depth > a[0].depth : true;
6528
6695
  if (b[0].__firstAtDepth !== __firstAtDepth) {
6529
- Transforms29.setNodes(editor, { __firstAtDepth }, { at: b[1] });
6696
+ Transforms30.setNodes(editor, { __firstAtDepth }, { at: b[1] });
6530
6697
  return true;
6531
6698
  }
6532
6699
  return false;
@@ -6766,12 +6933,12 @@ var ListPlugin = createPlugin(
6766
6933
  if (!listItem)
6767
6934
  return false;
6768
6935
  const listItemPath = listItem[1];
6769
- if (!Path10.hasPrevious(listItemPath)) {
6936
+ if (!Path11.hasPrevious(listItemPath)) {
6770
6937
  editor.collapsibleParagraph.convertParagraph();
6771
6938
  return true;
6772
6939
  }
6773
- const prevElementPath = Path10.previous(listItemPath);
6774
- const prevElementEntry = Editor40.node(editor, prevElementPath);
6940
+ const prevElementPath = Path11.previous(listItemPath);
6941
+ const prevElementEntry = Editor41.node(editor, prevElementPath);
6775
6942
  if (isListItem(prevElementEntry[0]))
6776
6943
  return false;
6777
6944
  editor.collapsibleParagraph.convertParagraph();
@@ -6781,7 +6948,7 @@ var ListPlugin = createPlugin(
6781
6948
  editableProps: {
6782
6949
  renderElement: renderElement3,
6783
6950
  onKeyDown(e) {
6784
- if (!Editor40.nodes(editor, { match: isListItem }))
6951
+ if (!Editor41.nodes(editor, { match: isListItem }))
6785
6952
  return false;
6786
6953
  return hotkeyHandler(e);
6787
6954
  }
@@ -6792,15 +6959,15 @@ var ListPlugin = createPlugin(
6792
6959
 
6793
6960
  // src/marks-plugin/index.tsx
6794
6961
  import { clsx as clsx7 } from "clsx";
6795
- import { Editor as Editor43, Point as Point3, Range as Range8 } from "slate";
6962
+ import { Editor as Editor44, Range as Range8 } from "slate";
6796
6963
 
6797
6964
  // src/marks-plugin/methods/removeMarks.ts
6798
- import { Editor as Editor41, Text as Text4, Transforms as Transforms30 } from "slate";
6965
+ import { Editor as Editor42, Text as Text4, Transforms as Transforms31 } from "slate";
6799
6966
  function removeMarks(editor, { at = editor.selection } = {}) {
6800
6967
  if (at == null)
6801
6968
  return;
6802
6969
  const nodeEntries = [
6803
- ...Editor41.nodes(editor, {
6970
+ ...Editor42.nodes(editor, {
6804
6971
  match: (n) => Text4.isText(n),
6805
6972
  at
6806
6973
  })
@@ -6813,7 +6980,7 @@ function removeMarks(editor, { at = editor.selection } = {}) {
6813
6980
  setter[key2] = null;
6814
6981
  }
6815
6982
  }
6816
- Transforms30.setNodes(editor, setter, {
6983
+ Transforms31.setNodes(editor, setter, {
6817
6984
  match: (n) => Text4.isText(n),
6818
6985
  split: true,
6819
6986
  at
@@ -6821,14 +6988,14 @@ function removeMarks(editor, { at = editor.selection } = {}) {
6821
6988
  }
6822
6989
 
6823
6990
  // src/marks-plugin/methods/toggle-mark.ts
6824
- import { Editor as Editor42, Point as Point2, Range as Range7 } from "slate";
6991
+ import { Editor as Editor43, Point as Point2, Range as Range7 } from "slate";
6825
6992
  function toggleMark(editor, markKey, unsetKey, { at = editor.selection } = {}) {
6826
6993
  if (at == null)
6827
6994
  return;
6828
6995
  const point = Range7.isRange(at) ? at.focus : at;
6829
- const isAtLineEnd = Point2.isPoint(point) && (Editor42.after(editor, point) === null || Editor42.isEnd(editor, point, Editor42.end(editor, [])));
6996
+ const isAtLineEnd = Point2.isPoint(point) && (Editor43.after(editor, point) === null || Editor43.isEnd(editor, point, Editor43.end(editor, [])));
6830
6997
  const validMarkKey = markKey;
6831
- const marks = Editor42.marks(editor) || {};
6998
+ const marks = Editor43.marks(editor) || {};
6832
6999
  const isActive = marks[validMarkKey] === true;
6833
7000
  if (isAtLineEnd) {
6834
7001
  if (!isActive) {
@@ -6842,12 +7009,12 @@ function toggleMark(editor, markKey, unsetKey, { at = editor.selection } = {}) {
6842
7009
  }
6843
7010
  }
6844
7011
  if (isActive) {
6845
- Editor42.removeMark(editor, validMarkKey);
7012
+ Editor43.removeMark(editor, validMarkKey);
6846
7013
  } else {
6847
- Editor42.addMark(editor, validMarkKey, true);
7014
+ Editor43.addMark(editor, validMarkKey, true);
6848
7015
  }
6849
7016
  if (typeof unsetKey === "string") {
6850
- Editor42.removeMark(editor, unsetKey);
7017
+ Editor43.removeMark(editor, unsetKey);
6851
7018
  }
6852
7019
  }
6853
7020
 
@@ -6919,13 +7086,11 @@ var MarksPlugin = createPlugin((editor) => {
6919
7086
  const { removeMarks: removeMarks2 } = editor.marksPlugin;
6920
7087
  editor.marksPlugin.removeMarks = () => {
6921
7088
  removeMarks2();
6922
- if (editor.selection) {
6923
- const point = Range8.isRange(editor.selection) ? editor.selection.focus : editor.selection;
6924
- if (Point3.isPoint(point)) {
6925
- const isAtLineEnd = Editor43.after(editor, point) === null || Editor43.isEnd(editor, point, Editor43.end(editor, []));
6926
- if (isAtLineEnd) {
6927
- editor.activeMarks = {};
6928
- }
7089
+ if (editor.selection && Range8.isRange(editor.selection)) {
7090
+ const point = editor.selection.focus;
7091
+ const isAtLineEnd = Editor44.after(editor, point) === null || Editor44.isEnd(editor, point, Editor44.end(editor, []));
7092
+ if (isAtLineEnd) {
7093
+ editor.activeMarks = {};
6929
7094
  }
6930
7095
  }
6931
7096
  };
@@ -6957,11 +7122,11 @@ var MarksPlugin = createPlugin((editor) => {
6957
7122
  });
6958
7123
 
6959
7124
  // src/normalize-after-delete-plugin/index.tsx
6960
- import { Editor as Editor44, Point as Point4 } from "slate";
7125
+ import { Editor as Editor45, Point as Point3 } from "slate";
6961
7126
  function forceNormalizeNearestElement(editor) {
6962
7127
  if (!editor.selection)
6963
7128
  return;
6964
- const entry = Editor44.parent(editor, editor.selection);
7129
+ const entry = Editor45.parent(editor, editor.selection);
6965
7130
  forceNormalizePath(editor, entry[1]);
6966
7131
  }
6967
7132
  var NormalizeAfterDeletePlugin = createPlugin((editor) => {
@@ -6972,9 +7137,9 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
6972
7137
  deleteBackward() {
6973
7138
  if (!editor.selection)
6974
7139
  return false;
6975
- const entry = Editor44.parent(editor, editor.selection);
6976
- const isStart = Point4.equals(
6977
- Editor44.start(editor, entry[1]),
7140
+ const entry = Editor45.parent(editor, editor.selection);
7141
+ const isStart = Point3.equals(
7142
+ Editor45.start(editor, entry[1]),
6978
7143
  editor.selection.anchor
6979
7144
  );
6980
7145
  if (!isStart)
@@ -6986,9 +7151,9 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
6986
7151
  deleteForward() {
6987
7152
  if (!editor.selection)
6988
7153
  return false;
6989
- const entry = Editor44.parent(editor, editor.selection);
6990
- const isEnd = Point4.equals(
6991
- Editor44.end(editor, entry[1]),
7154
+ const entry = Editor45.parent(editor, editor.selection);
7155
+ const isEnd = Point3.equals(
7156
+ Editor45.end(editor, entry[1]),
6992
7157
  editor.selection.anchor
6993
7158
  );
6994
7159
  if (!isEnd)
@@ -7003,15 +7168,15 @@ var NormalizeAfterDeletePlugin = createPlugin((editor) => {
7003
7168
  });
7004
7169
 
7005
7170
  // src/table-plugin/index.tsx
7006
- import { Element as Element23 } from "slate";
7171
+ import { Element as Element26 } from "slate";
7007
7172
 
7008
7173
  // src/table-plugin/delete-fragment/index.ts
7009
- import { Editor as Editor46, Path as Path12, Transforms as Transforms31 } from "slate";
7174
+ import { Editor as Editor47, Path as Path13, Transforms as Transforms32 } from "slate";
7010
7175
 
7011
7176
  // src/table-plugin/delete-fragment/get-reversed-delete-safe-ranges.ts
7012
- import { Editor as Editor45, Path as Path11 } from "slate";
7177
+ import { Editor as Editor46, Path as Path12 } from "slate";
7013
7178
  function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7014
- const positions = [...Editor45.positions(editor, { at: deleteRange })];
7179
+ const positions = [...Editor46.positions(editor, { at: deleteRange })];
7015
7180
  const deleteSafeRanges = [];
7016
7181
  let startPos, prevPos, startTdPath;
7017
7182
  startPos = prevPos = positions[0];
@@ -7022,7 +7187,7 @@ function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7022
7187
  const tdPath = findElementUpPath(editor, protectedTypes, {
7023
7188
  at: pos
7024
7189
  });
7025
- if (startTdPath && tdPath && Path11.equals(startTdPath, tdPath) || startTdPath == void 0 && tdPath == void 0) {
7190
+ if (startTdPath && tdPath && Path12.equals(startTdPath, tdPath) || startTdPath == void 0 && tdPath == void 0) {
7026
7191
  prevPos = pos;
7027
7192
  } else {
7028
7193
  const range2 = { anchor: startPos, focus: prevPos };
@@ -7041,7 +7206,7 @@ function getReversedDeleteSafeRanges(editor, deleteRange, protectedTypes) {
7041
7206
  function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7042
7207
  if (editor.selection == null)
7043
7208
  return false;
7044
- const [start, end] = Editor46.edges(editor, editor.selection);
7209
+ const [start, end] = Editor47.edges(editor, editor.selection);
7045
7210
  const startProtectedPath = findElementUpPath(editor, protectedTypes, {
7046
7211
  at: start
7047
7212
  });
@@ -7051,7 +7216,7 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7051
7216
  if (!startProtectedPath && !endProtectedPath) {
7052
7217
  return false;
7053
7218
  }
7054
- if (startProtectedPath && endProtectedPath && Path12.equals(startProtectedPath, endProtectedPath)) {
7219
+ if (startProtectedPath && endProtectedPath && Path13.equals(startProtectedPath, endProtectedPath)) {
7055
7220
  return false;
7056
7221
  }
7057
7222
  const reversedRanges = getReversedDeleteSafeRanges(
@@ -7059,17 +7224,17 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
7059
7224
  editor.selection,
7060
7225
  protectedTypes
7061
7226
  );
7062
- Editor46.withoutNormalizing(editor, () => {
7227
+ Editor47.withoutNormalizing(editor, () => {
7063
7228
  for (const range of reversedRanges) {
7064
- Transforms31.delete(editor, { at: range });
7229
+ Transforms32.delete(editor, { at: range });
7065
7230
  }
7066
- Transforms31.collapse(editor, { edge: "start" });
7231
+ Transforms32.collapse(editor, { edge: "start" });
7067
7232
  });
7068
7233
  return true;
7069
7234
  }
7070
7235
 
7071
7236
  // src/table-plugin/methods/index.ts
7072
- import { Transforms as Transforms40 } from "slate";
7237
+ import { Transforms as Transforms41 } from "slate";
7073
7238
 
7074
7239
  // src/table-plugin/methods/get-table-info.ts
7075
7240
  function getTableInfo(editor, { at = editor.selection } = {}) {
@@ -7107,10 +7272,10 @@ function getTableInfo(editor, { at = editor.selection } = {}) {
7107
7272
  }
7108
7273
 
7109
7274
  // src/table-plugin/methods/insert-column.ts
7110
- import { Editor as Editor47, Transforms as Transforms32 } from "slate";
7275
+ import { Editor as Editor48, Transforms as Transforms33 } from "slate";
7111
7276
 
7112
7277
  // src/table-plugin/methods/utils.ts
7113
- function createCell(index, children = [
7278
+ function createCell(_index, children = [
7114
7279
  {
7115
7280
  type: "table-content",
7116
7281
  children: [{ text: "" }]
@@ -7129,13 +7294,14 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
7129
7294
  return false;
7130
7295
  const { tableElement, tablePath, cellIndex } = t2;
7131
7296
  const nextCellIndex = cellIndex + offset;
7132
- Editor47.withoutNormalizing(editor, () => {
7297
+ Editor48.withoutNormalizing(editor, () => {
7133
7298
  const { columns } = tableElement;
7134
7299
  const nextColumns = [...columns];
7135
- nextColumns.splice(nextCellIndex, 0, columns[nextCellIndex]);
7136
- Transforms32.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7137
- tableElement.children.forEach((rowElement, i) => {
7138
- Transforms32.insertNodes(editor, createCell(nextCellIndex), {
7300
+ const sourceIndex = Math.min(nextCellIndex, columns.length - 1);
7301
+ nextColumns.splice(nextCellIndex, 0, columns[sourceIndex]);
7302
+ Transforms33.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7303
+ tableElement.children.forEach((_rowElement, i) => {
7304
+ Transforms33.insertNodes(editor, createCell(nextCellIndex), {
7139
7305
  at: [...tablePath, i, nextCellIndex]
7140
7306
  });
7141
7307
  });
@@ -7144,7 +7310,7 @@ function insertColumn(editor, { offset = 0, at = editor.selection } = {}) {
7144
7310
  }
7145
7311
 
7146
7312
  // src/table-plugin/methods/insert-row.ts
7147
- import { Transforms as Transforms33 } from "slate";
7313
+ import { Transforms as Transforms34 } from "slate";
7148
7314
  function createRow(columnCount) {
7149
7315
  return {
7150
7316
  type: "table-row",
@@ -7156,7 +7322,7 @@ function insertRow(editor, { at = editor.selection, offset = 0 } = {}) {
7156
7322
  if (!t2)
7157
7323
  return false;
7158
7324
  const nextRowElement = createRow(t2.tableElement.columns.length);
7159
- Transforms33.insertNodes(editor, nextRowElement, {
7325
+ Transforms34.insertNodes(editor, nextRowElement, {
7160
7326
  at: [...t2.tablePath, t2.rowIndex + offset]
7161
7327
  });
7162
7328
  return true;
@@ -7166,7 +7332,7 @@ function insertRowBelow(editor, { at } = {}) {
7166
7332
  }
7167
7333
 
7168
7334
  // src/table-plugin/methods/insert-table.ts
7169
- import { Editor as Editor49, Element as Element22, Path as Path13, Transforms as Transforms34 } from "slate";
7335
+ import { Editor as Editor50, Element as Element25, Path as Path14, Transforms as Transforms35 } from "slate";
7170
7336
  function createRange(size) {
7171
7337
  return [...Array(size).keys()];
7172
7338
  }
@@ -7195,29 +7361,29 @@ function insertRootElement2(editor, element, { at = editor.selection } = {}) {
7195
7361
  return false;
7196
7362
  const entry = findElementUp(
7197
7363
  editor,
7198
- (node) => Element22.isElement(node) && editor.isMaster(node)
7364
+ (node) => Element25.isElement(node) && editor.isMaster(node)
7199
7365
  );
7200
7366
  if (entry == null) {
7201
7367
  const selection = editor.selection;
7202
- Editor49.withoutNormalizing(editor, () => {
7203
- Transforms34.insertNodes(editor, element, { at });
7368
+ Editor50.withoutNormalizing(editor, () => {
7369
+ Transforms35.insertNodes(editor, element, { at });
7204
7370
  if (selection) {
7205
- Transforms34.select(editor, selection);
7206
- Transforms34.move(editor);
7371
+ Transforms35.select(editor, selection);
7372
+ Transforms35.move(editor);
7207
7373
  }
7208
7374
  });
7209
7375
  } else {
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));
7376
+ const nextPath = Path14.next(entry[1]);
7377
+ Editor50.withoutNormalizing(editor, () => {
7378
+ Transforms35.insertNodes(editor, element, { at: nextPath });
7379
+ Transforms35.select(editor, Editor50.start(editor, nextPath));
7214
7380
  });
7215
7381
  }
7216
7382
  return true;
7217
7383
  }
7218
7384
 
7219
7385
  // src/table-plugin/methods/navigation/select-element.ts
7220
- import { Path as Path14 } from "slate";
7386
+ import { Path as Path15 } from "slate";
7221
7387
  function selectElementBelow(editor, t2) {
7222
7388
  const { cellIndex, rowIndex, rowCount, tablePath } = t2;
7223
7389
  if (rowIndex < rowCount - 1) {
@@ -7225,7 +7391,7 @@ function selectElementBelow(editor, t2) {
7225
7391
  return true;
7226
7392
  }
7227
7393
  try {
7228
- selectStartOfElement(editor, Path14.next(tablePath));
7394
+ selectStartOfElement(editor, Path15.next(tablePath));
7229
7395
  return true;
7230
7396
  } catch {
7231
7397
  return false;
@@ -7238,7 +7404,7 @@ function selectElementAbove(editor, t2) {
7238
7404
  return true;
7239
7405
  }
7240
7406
  try {
7241
- selectEndOfElement(editor, Path14.previous(tablePath));
7407
+ selectEndOfElement(editor, Path15.previous(tablePath));
7242
7408
  return true;
7243
7409
  } catch {
7244
7410
  return false;
@@ -7290,15 +7456,15 @@ function up(editor) {
7290
7456
  }
7291
7457
 
7292
7458
  // src/table-plugin/methods/remove-column.ts
7293
- import { Editor as Editor52, Transforms as Transforms36 } from "slate";
7459
+ import { Editor as Editor53, Transforms as Transforms37 } from "slate";
7294
7460
 
7295
7461
  // src/table-plugin/methods/remove-table.ts
7296
- import { Transforms as Transforms35 } from "slate";
7462
+ import { Transforms as Transforms36 } from "slate";
7297
7463
  function removeTable(editor) {
7298
7464
  const t2 = editor.tablePlugin.getTableInfo();
7299
7465
  if (t2 === void 0)
7300
7466
  return false;
7301
- Transforms35.removeNodes(editor, { at: t2.tablePath });
7467
+ Transforms36.removeNodes(editor, { at: t2.tablePath });
7302
7468
  return true;
7303
7469
  }
7304
7470
 
@@ -7311,26 +7477,26 @@ function removeColumn(editor, { at = editor.selection } = {}) {
7311
7477
  if (cellCount === 1) {
7312
7478
  return removeTable(editor);
7313
7479
  }
7314
- Editor52.withoutNormalizing(editor, () => {
7480
+ Editor53.withoutNormalizing(editor, () => {
7315
7481
  const columns = [...tableElement.columns];
7316
7482
  columns.splice(cellIndex, 1);
7317
- Transforms36.setNodes(editor, { columns }, { at: tablePath });
7318
- tableElement.children.forEach((rowElement, rowIndex2) => {
7319
- Transforms36.removeNodes(editor, {
7483
+ Transforms37.setNodes(editor, { columns }, { at: tablePath });
7484
+ tableElement.children.forEach((_rowElement, rowIndex2) => {
7485
+ Transforms37.removeNodes(editor, {
7320
7486
  at: [...tablePath, rowIndex2, cellIndex]
7321
7487
  });
7322
7488
  });
7323
- const selection = Editor52.start(editor, [
7489
+ const selection = Editor53.start(editor, [
7324
7490
  ...tablePath,
7325
7491
  rowIndex,
7326
7492
  Math.min(cellIndex, cellCount - 2)
7327
7493
  ]);
7328
- Transforms36.select(editor, selection);
7494
+ Transforms37.select(editor, selection);
7329
7495
  });
7330
7496
  }
7331
7497
 
7332
7498
  // src/table-plugin/methods/remove-row.ts
7333
- import { Editor as Editor53, Transforms as Transforms37 } from "slate";
7499
+ import { Editor as Editor54, Transforms as Transforms38 } from "slate";
7334
7500
  function removeRow(editor, { at = editor.selection } = {}) {
7335
7501
  const t2 = getTableInfo(editor, { at });
7336
7502
  if (t2 === void 0)
@@ -7339,11 +7505,11 @@ function removeRow(editor, { at = editor.selection } = {}) {
7339
7505
  removeTable(editor);
7340
7506
  return true;
7341
7507
  }
7342
- Editor53.withoutNormalizing(editor, () => {
7343
- Transforms37.removeNodes(editor, { at: t2.rowPath });
7344
- Transforms37.select(
7508
+ Editor54.withoutNormalizing(editor, () => {
7509
+ Transforms38.removeNodes(editor, { at: t2.rowPath });
7510
+ Transforms38.select(
7345
7511
  editor,
7346
- Editor53.start(editor, [
7512
+ Editor54.start(editor, [
7347
7513
  ...t2.tablePath,
7348
7514
  Math.min(t2.rowIndex, t2.rowCount - 2),
7349
7515
  t2.cellIndex
@@ -7354,7 +7520,7 @@ function removeRow(editor, { at = editor.selection } = {}) {
7354
7520
  }
7355
7521
 
7356
7522
  // src/table-plugin/methods/setTableColumnAlign.ts
7357
- import { Transforms as Transforms38 } from "slate";
7523
+ import { Transforms as Transforms39 } from "slate";
7358
7524
  function setTableColumnAlign(editor, options) {
7359
7525
  const t2 = getTableInfo(editor);
7360
7526
  if (t2 === void 0)
@@ -7362,12 +7528,12 @@ function setTableColumnAlign(editor, options) {
7362
7528
  const { tableElement, tablePath, cellIndex } = t2;
7363
7529
  const nextColumns = tableElement.columns.slice();
7364
7530
  nextColumns.splice(cellIndex, 1, { align: options.align });
7365
- Transforms38.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7531
+ Transforms39.setNodes(editor, { columns: nextColumns }, { at: tablePath });
7366
7532
  return true;
7367
7533
  }
7368
7534
 
7369
7535
  // src/table-plugin/methods/tab.ts
7370
- import { Path as Path15, Transforms as Transforms39 } from "slate";
7536
+ import { Path as Path16, Transforms as Transforms40 } from "slate";
7371
7537
  function tabForward(editor) {
7372
7538
  const t2 = getTableInfo(editor);
7373
7539
  if (!t2)
@@ -7381,8 +7547,8 @@ function tabForward(editor) {
7381
7547
  selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0]);
7382
7548
  return true;
7383
7549
  }
7384
- const nextPath = Path15.next(tablePath);
7385
- Transforms39.insertNodes(
7550
+ const nextPath = Path16.next(tablePath);
7551
+ Transforms40.insertNodes(
7386
7552
  editor,
7387
7553
  { type: "paragraph", children: [{ text: "" }] },
7388
7554
  { at: nextPath }
@@ -7446,12 +7612,12 @@ function selectCell(editor, { at = editor.selection } = {}) {
7446
7612
  if (t2 === void 0)
7447
7613
  return false;
7448
7614
  const { cellPath } = t2;
7449
- Transforms40.select(editor, cellPath);
7615
+ Transforms41.select(editor, cellPath);
7450
7616
  return true;
7451
7617
  }
7452
7618
 
7453
7619
  // src/table-plugin/normalize/normalize-table.ts
7454
- import { Transforms as Transforms41 } from "slate";
7620
+ import { Transforms as Transforms42 } from "slate";
7455
7621
  function normalizeTableIndexes(editor, entry) {
7456
7622
  let isTransformed = false;
7457
7623
  const rowElements = entry[0].children;
@@ -7459,7 +7625,7 @@ function normalizeTableIndexes(editor, entry) {
7459
7625
  const cellElements = rowElement.children;
7460
7626
  cellElements.forEach((cellElement, x) => {
7461
7627
  if (cellElement.x !== x || cellElement.y !== y) {
7462
- Transforms41.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
7628
+ Transforms42.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
7463
7629
  isTransformed = true;
7464
7630
  }
7465
7631
  });
@@ -7468,14 +7634,14 @@ function normalizeTableIndexes(editor, entry) {
7468
7634
  }
7469
7635
 
7470
7636
  // src/table-plugin/normalize/normalize-table-cell.ts
7471
- import { Editor as Editor58, Transforms as Transforms42 } from "slate";
7637
+ import { Editor as Editor59, Transforms as Transforms43 } from "slate";
7472
7638
  function normalizeTableCell(editor, entry) {
7473
7639
  const [node, path] = entry;
7474
7640
  if (node.children.length === 1 && node.children[0].type === "table-content") {
7475
7641
  return false;
7476
7642
  }
7477
- Editor58.withoutNormalizing(editor, () => {
7478
- Transforms42.insertNodes(
7643
+ Editor59.withoutNormalizing(editor, () => {
7644
+ Transforms43.insertNodes(
7479
7645
  editor,
7480
7646
  {
7481
7647
  type: "table-content",
@@ -7484,9 +7650,9 @@ function normalizeTableCell(editor, entry) {
7484
7650
  { at: [...entry[1], 0] }
7485
7651
  );
7486
7652
  for (let i = node.children.length; i >= 0; i--) {
7487
- Transforms42.mergeNodes(editor, { at: [...path, i] });
7653
+ Transforms43.mergeNodes(editor, { at: [...path, i] });
7488
7654
  }
7489
- Transforms42.delete(editor, {
7655
+ Transforms43.delete(editor, {
7490
7656
  at: { path: [...path, 0, 0], offset: 0 },
7491
7657
  unit: "character"
7492
7658
  });
@@ -7763,7 +7929,7 @@ var AlignCenter = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE
7763
7929
  var AlignRight = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M10 12h10M6 18h14" }) });
7764
7930
 
7765
7931
  // src/table-plugin/render-element/table-cell/column-menu/index.tsx
7766
- import { Fragment as Fragment4, jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
7932
+ import { Fragment as Fragment5, jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
7767
7933
  function ColumnMenu({ cellElement }) {
7768
7934
  const editor = useSlateStatic14();
7769
7935
  const menu = useLayer("column-menu");
@@ -7816,7 +7982,7 @@ function ColumnMenu({ cellElement }) {
7816
7982
  onMouseLeave,
7817
7983
  children: [
7818
7984
  /* @__PURE__ */ jsx51($ColumnMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx51(BarsIcon, {}) }),
7819
- hover ? /* @__PURE__ */ jsxs23(Fragment4, { children: [
7985
+ hover ? /* @__PURE__ */ jsxs23(Fragment5, { children: [
7820
7986
  /* @__PURE__ */ jsx51(
7821
7987
  $RemoveMenuButton,
7822
7988
  {
@@ -7854,7 +8020,7 @@ function ColumnMenu({ cellElement }) {
7854
8020
  // src/table-plugin/render-element/table-cell/row-menu/index.tsx
7855
8021
  import { useState as useState7 } from "react";
7856
8022
  import { useSlateStatic as useSlateStatic15 } from "slate-react";
7857
- import { Fragment as Fragment5, jsx as jsx52, jsxs as jsxs24 } from "react/jsx-runtime";
8023
+ import { Fragment as Fragment6, jsx as jsx52, jsxs as jsxs24 } from "react/jsx-runtime";
7858
8024
  function RowMenu({ cellElement }) {
7859
8025
  const editor = useSlateStatic15();
7860
8026
  const [hover, setHover] = useState7(false);
@@ -7866,7 +8032,7 @@ function RowMenu({ cellElement }) {
7866
8032
  onMouseLeave: () => setHover(false),
7867
8033
  children: [
7868
8034
  /* @__PURE__ */ jsx52($RowMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx52(BarsIcon, {}) }),
7869
- hover ? /* @__PURE__ */ jsxs24(Fragment5, { children: [
8035
+ hover ? /* @__PURE__ */ jsxs24(Fragment6, { children: [
7870
8036
  /* @__PURE__ */ jsx52(
7871
8037
  $RemoveMenuButton,
7872
8038
  {
@@ -8047,7 +8213,7 @@ var TablePlugin = createPlugin(
8047
8213
  },
8048
8214
  normalizeNode: (entry) => {
8049
8215
  const [node] = entry;
8050
- if (!Element23.isElement(node))
8216
+ if (!Element26.isElement(node))
8051
8217
  return false;
8052
8218
  switch (node.type) {
8053
8219
  case "table":
@@ -8158,14 +8324,14 @@ var globalStyles = css2`
8158
8324
  `;
8159
8325
 
8160
8326
  // src/theme-plugin/index.tsx
8161
- import { Fragment as Fragment6, jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
8327
+ import { Fragment as Fragment7, jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
8162
8328
  var ThemePlugin = createPlugin((editor) => {
8163
8329
  editor.theme = true;
8164
8330
  return {
8165
8331
  name: "theme",
8166
8332
  editor: {},
8167
8333
  renderEditable: ({ attributes, Editable: Editable3 }) => {
8168
- return /* @__PURE__ */ jsxs26(Fragment6, { children: [
8334
+ return /* @__PURE__ */ jsxs26(Fragment7, { children: [
8169
8335
  /* @__PURE__ */ jsx58(Global, { styles: globalStyles }),
8170
8336
  /* @__PURE__ */ jsx58(Editable3, { ...attributes })
8171
8337
  ] });
@@ -8177,7 +8343,7 @@ var ThemePlugin = createPlugin((editor) => {
8177
8343
  // src/toolbar-plugin/render-editable/index.tsx
8178
8344
  import { clsx as clsx10 } from "clsx";
8179
8345
  import { useCallback as useCallback17, useRef as useRef13 } from "react";
8180
- import { Editor as Editor62, Transforms as Transforms44 } from "slate";
8346
+ import { Editor as Editor63, Transforms as Transforms45 } from "slate";
8181
8347
  import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as useSlateStatic21 } from "slate-react";
8182
8348
 
8183
8349
  // src/toolbar-plugin/components/dialog/table-dialog.tsx
@@ -8209,7 +8375,7 @@ var $TableDialogGridCell = styled35("div")`
8209
8375
  `;
8210
8376
 
8211
8377
  // src/toolbar-plugin/components/dialog/table-dialog.tsx
8212
- import { Fragment as Fragment7, jsx as jsx59, jsxs as jsxs27 } from "react/jsx-runtime";
8378
+ import { Fragment as Fragment8, jsx as jsx59, jsxs as jsxs27 } from "react/jsx-runtime";
8213
8379
  function createRange2(size) {
8214
8380
  return [...Array(size).keys()];
8215
8381
  }
@@ -8221,6 +8387,8 @@ function TableDialog({
8221
8387
  const editor = useSlateStatic16();
8222
8388
  const ref = useRef8(null);
8223
8389
  const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
8390
+ if (!dest2)
8391
+ return { left: 0, top: 0 };
8224
8392
  return { left: dest2.left - 8, top: dest2.top + dest2.height };
8225
8393
  });
8226
8394
  const rows = createRange2(5).map((i) => i + 1);
@@ -8239,7 +8407,7 @@ function TableDialog({
8239
8407
  },
8240
8408
  [editor]
8241
8409
  );
8242
- return /* @__PURE__ */ jsxs27(Fragment7, { children: [
8410
+ return /* @__PURE__ */ jsxs27(Fragment8, { children: [
8243
8411
  /* @__PURE__ */ jsx59(CloseMask, { close }),
8244
8412
  /* @__PURE__ */ jsx59($TableDialog, { ref, style, children: /* @__PURE__ */ jsx59($TableDialogGrid, { onMouseLeave: () => hoverCell(0, 0), children: rows.map((y) => {
8245
8413
  return cols.map((x) => {
@@ -8312,6 +8480,7 @@ var Highlight = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
8312
8480
  /* @__PURE__ */ jsx60("path", { d: "M13.5 6.5l4 4" }),
8313
8481
  /* @__PURE__ */ jsx60("path", { d: "m14 19 6-6M18 15l2 2M5 21h4" })
8314
8482
  ] });
8483
+ var HorizontalRule2 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M5 12h14" }) });
8315
8484
 
8316
8485
  // src/toolbar-plugin/items/block-items.tsx
8317
8486
  var listDepthItems = [
@@ -8384,13 +8553,13 @@ var $FileDialog = styled36($Panel)`
8384
8553
  `;
8385
8554
 
8386
8555
  // src/toolbar-plugin/components/dialog/image-url-dialog.tsx
8387
- import { Fragment as Fragment8, jsx as jsx61, jsxs as jsxs29 } from "react/jsx-runtime";
8556
+ import { Fragment as Fragment9, jsx as jsx61, jsxs as jsxs29 } from "react/jsx-runtime";
8388
8557
  function ImageUrlDialog({
8389
8558
  dest,
8390
8559
  close
8391
8560
  }) {
8392
8561
  const editor = useSlateStatic17();
8393
- const ref = useRef9(void 0);
8562
+ const ref = useRef9(null);
8394
8563
  const fileInputRef = useRef9(null);
8395
8564
  const [dragOffset, setDragOffset] = useState9({ x: 0, y: 0 });
8396
8565
  const handleDrag = useCallback14((deltaX, deltaY) => {
@@ -8469,7 +8638,6 @@ function ImageUrlDialog({
8469
8638
  const resultUrl = await editor.wysimark.onImageChange(file);
8470
8639
  setUploadedUrl(resultUrl);
8471
8640
  } catch (error) {
8472
- console.error("Failed to upload image:", error);
8473
8641
  } finally {
8474
8642
  setIsUploading(false);
8475
8643
  }
@@ -8478,7 +8646,7 @@ function ImageUrlDialog({
8478
8646
  fileInputRef.current?.click();
8479
8647
  }
8480
8648
  const isSubmitDisabled = imageSource === "file" ? uploadedUrl.trim() === "" || isUploading : url.trim() === "";
8481
- return /* @__PURE__ */ jsxs29(Fragment8, { children: [
8649
+ return /* @__PURE__ */ jsxs29(Fragment9, { children: [
8482
8650
  /* @__PURE__ */ jsx61(CloseMask, { close }),
8483
8651
  /* @__PURE__ */ jsxs29($FileDialog, { ref, style, children: [
8484
8652
  /* @__PURE__ */ jsx61(DraggableHeader, { onDrag: handleDrag }),
@@ -8659,11 +8827,11 @@ function ImageUrlDialog({
8659
8827
  import { isHotkey as isHotkey3 } from "is-hotkey";
8660
8828
  import {
8661
8829
  useCallback as useCallback15,
8662
- useMemo as useMemo2,
8830
+ useMemo as useMemo3,
8663
8831
  useRef as useRef10,
8664
8832
  useState as useState10
8665
8833
  } from "react";
8666
- import { Editor as Editor59, Range as Range10 } from "slate";
8834
+ import { Editor as Editor60, Range as Range10 } from "slate";
8667
8835
  import { ReactEditor as ReactEditor14, useSlateStatic as useSlateStatic18 } from "slate-react";
8668
8836
 
8669
8837
  // src/toolbar-plugin/styles/dialog-shared-styles.ts
@@ -8701,7 +8869,7 @@ var $DialogHint = styled37("div")`
8701
8869
  `;
8702
8870
 
8703
8871
  // src/toolbar-plugin/components/dialog/anchor-dialog.tsx
8704
- import { Fragment as Fragment9, jsx as jsx62, jsxs as jsxs30 } from "react/jsx-runtime";
8872
+ import { Fragment as Fragment10, jsx as jsx62, jsxs as jsxs30 } from "react/jsx-runtime";
8705
8873
  var isEnter = isHotkey3("enter");
8706
8874
  function AnchorDialog2({
8707
8875
  dest,
@@ -8716,6 +8884,8 @@ function AnchorDialog2({
8716
8884
  const baseStyle = useAbsoluteReposition(
8717
8885
  { src: ref, dest },
8718
8886
  ({ src, dest: dest2 }, viewport) => {
8887
+ if (!src || !dest2)
8888
+ return { left: 0, top: 0 };
8719
8889
  return positionInside(
8720
8890
  src,
8721
8891
  viewport,
@@ -8732,10 +8902,10 @@ function AnchorDialog2({
8732
8902
  left: baseStyle.left + dragOffset.x,
8733
8903
  top: baseStyle.top + dragOffset.y
8734
8904
  };
8735
- const initialText = useMemo2(() => {
8905
+ const initialText = useMemo3(() => {
8736
8906
  const { selection } = editor;
8737
8907
  if (selection && !Range10.isCollapsed(selection)) {
8738
- return Editor59.string(editor, selection);
8908
+ return Editor60.string(editor, selection);
8739
8909
  }
8740
8910
  return "";
8741
8911
  }, []);
@@ -8780,7 +8950,7 @@ function AnchorDialog2({
8780
8950
  e.stopPropagation();
8781
8951
  insertLink2();
8782
8952
  };
8783
- return /* @__PURE__ */ jsxs30(Fragment9, { children: [
8953
+ return /* @__PURE__ */ jsxs30(Fragment10, { children: [
8784
8954
  /* @__PURE__ */ jsx62(CloseMask, { close }),
8785
8955
  /* @__PURE__ */ jsxs30($AnchorDialog, { ref, style, children: [
8786
8956
  /* @__PURE__ */ jsx62(DraggableHeader, { onDrag: handleDrag }),
@@ -8849,6 +9019,12 @@ var dialogItems = [
8849
9019
  title: t("insertTable"),
8850
9020
  more: true,
8851
9021
  Component: TableDialog
9022
+ },
9023
+ {
9024
+ icon: HorizontalRule2,
9025
+ title: t("horizontalRule"),
9026
+ hotkey: "super+-",
9027
+ action: (editor) => editor.horizontalRule.insertHorizontalRule()
8852
9028
  }
8853
9029
  ];
8854
9030
  var expandedDialogItems = dialogItems;
@@ -8863,9 +9039,9 @@ var smallDialogItems = [
8863
9039
  ];
8864
9040
 
8865
9041
  // src/toolbar-plugin/items/mark-items.tsx
8866
- import { Editor as Editor60 } from "slate";
9042
+ import { Editor as Editor61 } from "slate";
8867
9043
  function getMarks(editor) {
8868
- const marks = Editor60.marks(editor);
9044
+ const marks = Editor61.marks(editor);
8869
9045
  return {
8870
9046
  bold: marks?.bold || false,
8871
9047
  italic: marks?.italic || false,
@@ -8963,7 +9139,7 @@ var compactListItems = [
8963
9139
  ];
8964
9140
 
8965
9141
  // src/toolbar-plugin/items/quote-items.tsx
8966
- import { Editor as Editor61, Transforms as Transforms43 } from "slate";
9142
+ import { Editor as Editor62, Transforms as Transforms44 } from "slate";
8967
9143
  var quoteItemsList = [
8968
9144
  {
8969
9145
  icon: Quote,
@@ -8992,9 +9168,9 @@ var quoteItemsList = [
8992
9168
  const codeBlockEntry = findElementUp(editor, "code-block");
8993
9169
  if (codeBlockEntry) {
8994
9170
  const [, path] = codeBlockEntry;
8995
- const textContent = Editor61.string(editor, path);
8996
- Transforms43.removeNodes(editor, { at: path });
8997
- Transforms43.insertNodes(
9171
+ const textContent = Editor62.string(editor, path);
9172
+ Transforms44.removeNodes(editor, { at: path });
9173
+ Transforms44.insertNodes(
8998
9174
  editor,
8999
9175
  {
9000
9176
  type: "paragraph",
@@ -9009,9 +9185,9 @@ var quoteItemsList = [
9009
9185
  return;
9010
9186
  }
9011
9187
  if (selection && (selection.anchor.offset !== selection.focus.offset || JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path))) {
9012
- const selectedText = Editor61.string(editor, selection);
9013
- Transforms43.delete(editor);
9014
- Transforms43.insertNodes(
9188
+ const selectedText = Editor62.string(editor, selection);
9189
+ Transforms44.delete(editor);
9190
+ Transforms44.insertNodes(
9015
9191
  editor,
9016
9192
  {
9017
9193
  type: "code-block",
@@ -9236,7 +9412,7 @@ function renderEditable({ attributes, Editable: Editable3 }) {
9236
9412
  (e) => {
9237
9413
  if (e.target !== e.currentTarget)
9238
9414
  return;
9239
- Transforms44.select(editor, Editor62.end(editor, []));
9415
+ Transforms45.select(editor, Editor63.end(editor, []));
9240
9416
  ReactEditor16.focus(editor);
9241
9417
  },
9242
9418
  [editor]
@@ -9286,7 +9462,7 @@ var ToolbarPlugin = createPlugin(
9286
9462
  );
9287
9463
 
9288
9464
  // src/trailing-block-plugin/index.tsx
9289
- import { Editor as Editor63, Node as Node15, Path as Path16, Transforms as Transforms45 } from "slate";
9465
+ import { Editor as Editor64, Node as Node15, Path as Path17, Transforms as Transforms46 } from "slate";
9290
9466
  var TrailingBlockPlugin = createPlugin(
9291
9467
  (editor) => {
9292
9468
  editor.allowTrailingBlock = true;
@@ -9294,19 +9470,19 @@ var TrailingBlockPlugin = createPlugin(
9294
9470
  name: "trailing-block",
9295
9471
  editor: {
9296
9472
  normalizeNode: (entry) => {
9297
- if (!Editor63.isEditor(entry[0]))
9473
+ if (!Editor64.isEditor(entry[0]))
9298
9474
  return false;
9299
9475
  const lastPath = [editor.children.length - 1];
9300
9476
  const lastElement = Node15.child(
9301
9477
  editor,
9302
9478
  editor.children.length - 1
9303
9479
  );
9304
- if (Editor63.hasBlocks(editor, lastElement) || Editor63.isVoid(editor, lastElement)) {
9305
- Transforms45.insertNodes(
9480
+ if (Editor64.hasBlocks(editor, lastElement) || Editor64.isVoid(editor, lastElement)) {
9481
+ Transforms46.insertNodes(
9306
9482
  editor,
9307
9483
  { type: "paragraph", children: [{ text: "" }] },
9308
9484
  {
9309
- at: Path16.next(lastPath)
9485
+ at: Path17.next(lastPath)
9310
9486
  }
9311
9487
  );
9312
9488
  }
@@ -9318,11 +9494,11 @@ var TrailingBlockPlugin = createPlugin(
9318
9494
  );
9319
9495
 
9320
9496
  // src/paste-markdown-plugin/methods/index.ts
9321
- import { Transforms as Transforms46 } from "slate";
9497
+ import { Transforms as Transforms47 } from "slate";
9322
9498
  function pasteMarkdown(editor, markdown) {
9323
9499
  const escapedMarkdown = escapeUrlSlashes(markdown);
9324
9500
  const fragment = parse(escapedMarkdown);
9325
- Transforms46.insertNodes(editor, fragment);
9501
+ Transforms47.insertNodes(editor, fragment);
9326
9502
  }
9327
9503
  function createPasteMarkdownMethods(editor) {
9328
9504
  return {
@@ -9408,7 +9584,7 @@ var { withSink, SinkEditable: SinkEditable2 } = Sink;
9408
9584
 
9409
9585
  // src/entry/useEditor.tsx
9410
9586
  import { useState as useState12 } from "react";
9411
- import { createEditor, Editor as Editor65, Transforms as Transforms47 } from "slate";
9587
+ import { createEditor, Editor as Editor66, Transforms as Transforms48 } from "slate";
9412
9588
  import { withHistory } from "slate-history";
9413
9589
  import { withReact } from "slate-react";
9414
9590
  function useEditor({
@@ -9454,7 +9630,7 @@ function useEditor({
9454
9630
  const documentValue = parse(escapedMarkdown);
9455
9631
  editor2.children = documentValue;
9456
9632
  editor2.selection = null;
9457
- Transforms47.select(editor2, Editor65.start(editor2, [0]));
9633
+ Transforms48.select(editor2, Editor66.start(editor2, [0]));
9458
9634
  };
9459
9635
  return nextEditor;
9460
9636
  });
@@ -9482,6 +9658,8 @@ function Editable2({
9482
9658
  const initialValueRef = useRef14(void 0);
9483
9659
  const prevValueRef = useRef14(void 0);
9484
9660
  const pendingRawTextRef = useRef14(null);
9661
+ const onChangeRef = useRef14(onChange);
9662
+ onChangeRef.current = onChange;
9485
9663
  const onThrottledSlateChange = useCallback18(
9486
9664
  throttle3(
9487
9665
  () => {
@@ -9490,12 +9668,13 @@ function Editable2({
9490
9668
  markdown,
9491
9669
  children: editor.children
9492
9670
  };
9493
- onChange(markdown);
9671
+ onChangeRef.current(markdown);
9494
9672
  },
9495
9673
  throttleInMs,
9496
9674
  { leading: false, trailing: true }
9497
9675
  ),
9498
- [editor, onChange, throttleInMs]
9676
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9677
+ [editor, throttleInMs]
9499
9678
  );
9500
9679
  const onSlateChange = useCallback18(() => {
9501
9680
  if (prevValueRef.current === editor.children) {
@@ -9526,7 +9705,7 @@ function Editable2({
9526
9705
  const documentValue = parse(valueToProcess);
9527
9706
  editor.children = documentValue;
9528
9707
  editor.selection = null;
9529
- Transforms48.select(editor, Editor66.start(editor, [0]));
9708
+ Transforms49.select(editor, Editor67.start(editor, [0]));
9530
9709
  }
9531
9710
  }
9532
9711
  }