wysimark-lite 0.21.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -2
- package/dist/index.d.ts +80 -3
- package/dist/index.js +131 -127
- package/dist/index.mjs +722 -463
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
createRef,
|
|
6
6
|
useCallback as useCallback17,
|
|
7
7
|
useImperativeHandle,
|
|
8
|
-
useRef as
|
|
9
|
-
useState as
|
|
8
|
+
useRef as useRef13,
|
|
9
|
+
useState as useState14
|
|
10
10
|
} from "react";
|
|
11
11
|
import { createRoot } from "react-dom/client";
|
|
12
12
|
|
|
13
13
|
// src/entry/index.tsx
|
|
14
14
|
import throttle3 from "lodash.throttle";
|
|
15
|
-
import { useCallback as useCallback16, useRef as
|
|
16
|
-
import { Editor as
|
|
15
|
+
import { useCallback as useCallback16, useRef as useRef12, useState as useState13 } from "react";
|
|
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
|
|
@@ -256,14 +256,16 @@ var MARK_KEY_TO_TOKEN = {
|
|
|
256
256
|
*
|
|
257
257
|
* This is handled in the `serializeLine` code.
|
|
258
258
|
*/
|
|
259
|
-
code: ""
|
|
259
|
+
code: "",
|
|
260
|
+
/**
|
|
261
|
+
* Highlight is handled specially in `serializeLine` using <mark> tags.
|
|
262
|
+
*/
|
|
263
|
+
highlight: ""
|
|
260
264
|
};
|
|
261
265
|
function convertMarkToSymbol(mark) {
|
|
262
266
|
if (mark in MARK_KEY_TO_TOKEN)
|
|
263
267
|
return MARK_KEY_TO_TOKEN[mark];
|
|
264
|
-
|
|
265
|
-
`Could not find mark ${JSON.stringify(mark)} in MARK_KEY_TO_TOKEN lookup`
|
|
266
|
-
);
|
|
268
|
+
return "";
|
|
267
269
|
}
|
|
268
270
|
function convertMarksToSymbolsExceptCode(marks) {
|
|
269
271
|
return marks.map(convertMarkToSymbol).join("");
|
|
@@ -458,11 +460,11 @@ function parseUrl(url) {
|
|
|
458
460
|
searchParams: urlData.searchParams,
|
|
459
461
|
hash: urlData.hash
|
|
460
462
|
};
|
|
461
|
-
} catch
|
|
463
|
+
} catch {
|
|
462
464
|
const matchdata = url.match(URL_REGEX);
|
|
463
465
|
if (matchdata === null)
|
|
464
466
|
throw new Error(`Invalid format should not happen: ${url}`);
|
|
465
|
-
const [
|
|
467
|
+
const [, pathname, searchParams, hash] = [...matchdata];
|
|
466
468
|
return {
|
|
467
469
|
origin: "",
|
|
468
470
|
hostname: "",
|
|
@@ -579,8 +581,13 @@ function parsePhrasingContent(phrasingContent, marks = {}) {
|
|
|
579
581
|
});
|
|
580
582
|
case "footnoteReference":
|
|
581
583
|
return [{ text: `[${phrasingContent.identifier}]` }];
|
|
582
|
-
case "html":
|
|
584
|
+
case "html": {
|
|
585
|
+
const markMatch = phrasingContent.value.match(/^<mark>(.*)<\/mark>$/s);
|
|
586
|
+
if (markMatch) {
|
|
587
|
+
return [{ text: markMatch[1], ...marks, highlight: true }];
|
|
588
|
+
}
|
|
583
589
|
return [{ text: phrasingContent.value, code: true }];
|
|
590
|
+
}
|
|
584
591
|
case "image":
|
|
585
592
|
return parseInlineImage(phrasingContent);
|
|
586
593
|
case "inlineCode": {
|
|
@@ -1054,7 +1061,6 @@ function moveSpacesAtStartOfAnchor({
|
|
|
1054
1061
|
return false;
|
|
1055
1062
|
if (node.type !== "anchor")
|
|
1056
1063
|
return false;
|
|
1057
|
-
node;
|
|
1058
1064
|
const firstChild = node.children[0];
|
|
1059
1065
|
if (isText(firstChild) && isPlainSpace(firstChild)) {
|
|
1060
1066
|
node.children.splice(0, 1);
|
|
@@ -1077,7 +1083,6 @@ function moveSpacesAtEndOfAnchor({
|
|
|
1077
1083
|
return false;
|
|
1078
1084
|
if (node.type !== "anchor")
|
|
1079
1085
|
return false;
|
|
1080
|
-
node;
|
|
1081
1086
|
const lastChild = node.children[node.children.length - 1];
|
|
1082
1087
|
if (isText(lastChild) && isPlainSpace(lastChild)) {
|
|
1083
1088
|
node.children.splice(node.children.length - 1, 1);
|
|
@@ -1371,9 +1376,17 @@ function serializeLine(inputSegments, leadingMarks = [], trailingMarks = []) {
|
|
|
1371
1376
|
continue;
|
|
1372
1377
|
}
|
|
1373
1378
|
substrings.push(convertMarksToSymbolsExceptCode(leadingDiff.add));
|
|
1379
|
+
const hasHighlightOpen = leadingDiff.add.includes("highlight");
|
|
1380
|
+
if (hasHighlightOpen) {
|
|
1381
|
+
substrings.push("<mark>");
|
|
1382
|
+
}
|
|
1374
1383
|
substrings.push(serializeSegment(segment));
|
|
1375
1384
|
const nextMarks = getNextMarks(segments, i, trailingMarks);
|
|
1376
1385
|
const trailingDiff = diffMarks(leadingDiff.nextOrderedMarks, nextMarks);
|
|
1386
|
+
const hasHighlightClose = trailingDiff.remove.includes("highlight");
|
|
1387
|
+
if (hasHighlightClose) {
|
|
1388
|
+
substrings.push("</mark>");
|
|
1389
|
+
}
|
|
1377
1390
|
substrings.push(convertMarksToSymbolsExceptCode(trailingDiff.remove));
|
|
1378
1391
|
leadingDiff = trailingDiff;
|
|
1379
1392
|
}
|
|
@@ -1558,6 +1571,7 @@ var translations = {
|
|
|
1558
1571
|
strike: "\u53D6\u308A\u6D88\u3057\u7DDA",
|
|
1559
1572
|
inlineCode: "\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",
|
|
1560
1573
|
underline: "\u4E0B\u7DDA",
|
|
1574
|
+
highlight: "\u30CF\u30A4\u30E9\u30A4\u30C8",
|
|
1561
1575
|
increaseDepth: "\u968E\u5C64\u3092\u6DF1\u304F\u3059\u308B",
|
|
1562
1576
|
decreaseDepth: "\u968E\u5C64\u3092\u6D45\u304F\u3059\u308B",
|
|
1563
1577
|
heading1: "\u898B\u51FA\u30571",
|
|
@@ -1571,6 +1585,8 @@ var translations = {
|
|
|
1571
1585
|
checkList: "\u30C1\u30A7\u30C3\u30AF\u30EA\u30B9\u30C8",
|
|
1572
1586
|
list: "\u30EA\u30B9\u30C8",
|
|
1573
1587
|
linkUrl: "\u30EA\u30F3\u30AF\u306EURL",
|
|
1588
|
+
linkText: "\u30EA\u30F3\u30AF\u30C6\u30AD\u30B9\u30C8",
|
|
1589
|
+
linkTextHint: "\u30EA\u30F3\u30AF\u3068\u3057\u3066\u8868\u793A\u3055\u308C\u308B\u30C6\u30AD\u30B9\u30C8",
|
|
1574
1590
|
tooltipText: "\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7\u30C6\u30AD\u30B9\u30C8",
|
|
1575
1591
|
tooltipHint: "\u30DE\u30A6\u30B9\u30DB\u30D0\u30FC\u6642\u306B\u8868\u793A\u3055\u308C\u308B\u30C4\u30FC\u30EB\u30C1\u30C3\u30D7",
|
|
1576
1592
|
apply: "\u9069\u7528",
|
|
@@ -1603,6 +1619,7 @@ var translations = {
|
|
|
1603
1619
|
strike: "Strikethrough",
|
|
1604
1620
|
inlineCode: "Inline Code",
|
|
1605
1621
|
underline: "Underline",
|
|
1622
|
+
highlight: "Highlight",
|
|
1606
1623
|
increaseDepth: "Increase Depth",
|
|
1607
1624
|
decreaseDepth: "Decrease Depth",
|
|
1608
1625
|
heading1: "Heading 1",
|
|
@@ -1616,6 +1633,8 @@ var translations = {
|
|
|
1616
1633
|
checkList: "Check List",
|
|
1617
1634
|
list: "List",
|
|
1618
1635
|
linkUrl: "Link URL",
|
|
1636
|
+
linkText: "Link Text",
|
|
1637
|
+
linkTextHint: "Text displayed as the link",
|
|
1619
1638
|
tooltipText: "Tooltip Text",
|
|
1620
1639
|
tooltipHint: "Tooltip shown on mouse hover",
|
|
1621
1640
|
apply: "Apply",
|
|
@@ -1648,7 +1667,7 @@ var getLanguage = () => {
|
|
|
1648
1667
|
if (typeof window !== "undefined" && window.navigator) {
|
|
1649
1668
|
return window.navigator.language.split("-")[0];
|
|
1650
1669
|
}
|
|
1651
|
-
} catch
|
|
1670
|
+
} catch {
|
|
1652
1671
|
}
|
|
1653
1672
|
return "en";
|
|
1654
1673
|
};
|
|
@@ -1680,8 +1699,8 @@ function defined(value) {
|
|
|
1680
1699
|
}
|
|
1681
1700
|
|
|
1682
1701
|
// src/sink/editable/create-decorate.ts
|
|
1683
|
-
function createDecorate(originalFn,
|
|
1684
|
-
const fns =
|
|
1702
|
+
function createDecorate(originalFn, plugins) {
|
|
1703
|
+
const fns = plugins.map((plugin) => plugin.editableProps?.decorate).filter(defined);
|
|
1685
1704
|
return function(entry) {
|
|
1686
1705
|
const ranges = [];
|
|
1687
1706
|
for (const fn of fns) {
|
|
@@ -1697,8 +1716,8 @@ function createDecorate(originalFn, plugins2) {
|
|
|
1697
1716
|
// src/sink/editable/create-editable.tsx
|
|
1698
1717
|
import { Editable } from "slate-react";
|
|
1699
1718
|
import { jsx } from "react/jsx-runtime";
|
|
1700
|
-
function createEditable(
|
|
1701
|
-
const fns =
|
|
1719
|
+
function createEditable(plugins) {
|
|
1720
|
+
const fns = plugins.map((plugin) => plugin.renderEditable).filter(defined);
|
|
1702
1721
|
let CurrentRenderEditable = (props) => /* @__PURE__ */ jsx(Editable, { ...props });
|
|
1703
1722
|
for (const fn of fns) {
|
|
1704
1723
|
const PrevRenderEditable = CurrentRenderEditable;
|
|
@@ -1713,9 +1732,9 @@ function createEditable(plugins2) {
|
|
|
1713
1732
|
}
|
|
1714
1733
|
|
|
1715
1734
|
// src/sink/editable/create-handler.ts
|
|
1716
|
-
function extractEditableFns(
|
|
1735
|
+
function extractEditableFns(plugins, key2) {
|
|
1717
1736
|
const fns = [];
|
|
1718
|
-
for (const plugin of
|
|
1737
|
+
for (const plugin of plugins) {
|
|
1719
1738
|
const maybeFn = plugin.editableProps?.[key2];
|
|
1720
1739
|
if (maybeFn)
|
|
1721
1740
|
fns.push(maybeFn);
|
|
@@ -1731,26 +1750,26 @@ function createHandlerFn(fns, originalFn) {
|
|
|
1731
1750
|
originalFn?.(event);
|
|
1732
1751
|
};
|
|
1733
1752
|
}
|
|
1734
|
-
var createOnKeyDown = (originalFn,
|
|
1735
|
-
const fns = extractEditableFns(
|
|
1753
|
+
var createOnKeyDown = (originalFn, plugins) => {
|
|
1754
|
+
const fns = extractEditableFns(plugins, "onKeyDown");
|
|
1736
1755
|
return createHandlerFn(fns, originalFn);
|
|
1737
1756
|
};
|
|
1738
|
-
var createOnKeyUp = (originalFn,
|
|
1739
|
-
const fns = extractEditableFns(
|
|
1757
|
+
var createOnKeyUp = (originalFn, plugins) => {
|
|
1758
|
+
const fns = extractEditableFns(plugins, "onKeyUp");
|
|
1740
1759
|
return createHandlerFn(fns, originalFn);
|
|
1741
1760
|
};
|
|
1742
|
-
var createOnPaste = (originalFn,
|
|
1743
|
-
const fns = extractEditableFns(
|
|
1761
|
+
var createOnPaste = (originalFn, plugins) => {
|
|
1762
|
+
const fns = extractEditableFns(plugins, "onPaste");
|
|
1744
1763
|
return createHandlerFn(fns, originalFn);
|
|
1745
1764
|
};
|
|
1746
|
-
var createOnDrop = (originalFn,
|
|
1747
|
-
const fns = extractEditableFns(
|
|
1765
|
+
var createOnDrop = (originalFn, plugins) => {
|
|
1766
|
+
const fns = extractEditableFns(plugins, "onDrop");
|
|
1748
1767
|
return createHandlerFn(fns, originalFn);
|
|
1749
1768
|
};
|
|
1750
1769
|
|
|
1751
1770
|
// src/sink/editable/create-render-element.ts
|
|
1752
|
-
function createRenderElement(originalFn,
|
|
1753
|
-
const fns =
|
|
1771
|
+
function createRenderElement(originalFn, plugins) {
|
|
1772
|
+
const fns = plugins.map((plugin) => plugin.editableProps?.renderElement).filter(defined);
|
|
1754
1773
|
return function renderElement5(renderElementProps) {
|
|
1755
1774
|
for (const fn of fns) {
|
|
1756
1775
|
const result = fn(renderElementProps);
|
|
@@ -1768,11 +1787,11 @@ function createRenderElement(originalFn, plugins2) {
|
|
|
1768
1787
|
|
|
1769
1788
|
// src/sink/editable/create-render-leaf.ts
|
|
1770
1789
|
import { cloneElement } from "react";
|
|
1771
|
-
function createRenderLeaf(originalFn,
|
|
1790
|
+
function createRenderLeaf(originalFn, plugins) {
|
|
1772
1791
|
if (originalFn === void 0) {
|
|
1773
1792
|
throw new Error(`renderLeaf was not defined on SinkEditable`);
|
|
1774
1793
|
}
|
|
1775
|
-
const fns =
|
|
1794
|
+
const fns = plugins.map((plugin) => plugin.editableProps?.renderLeaf).filter(defined).reverse();
|
|
1776
1795
|
return function(renderLeafProps) {
|
|
1777
1796
|
let value = originalFn({
|
|
1778
1797
|
...renderLeafProps,
|
|
@@ -1801,10 +1820,10 @@ function createRenderLeaf(originalFn, plugins2) {
|
|
|
1801
1820
|
}
|
|
1802
1821
|
|
|
1803
1822
|
// src/sink/editable/create-render-placeholder.tsx
|
|
1804
|
-
function createRenderPlaceholder(originalFn,
|
|
1823
|
+
function createRenderPlaceholder(originalFn, plugins) {
|
|
1805
1824
|
if (originalFn)
|
|
1806
1825
|
return originalFn;
|
|
1807
|
-
const fns =
|
|
1826
|
+
const fns = plugins.map((plugin) => plugin.editableProps?.renderPlaceholder).filter(defined);
|
|
1808
1827
|
if (fns.length === 0)
|
|
1809
1828
|
return void 0;
|
|
1810
1829
|
return function(renderPlaceholderProps) {
|
|
@@ -1838,16 +1857,16 @@ function SinkEditable(originalProps) {
|
|
|
1838
1857
|
useEffect(() => {
|
|
1839
1858
|
Editor.normalize(editor, { force: true });
|
|
1840
1859
|
}, []);
|
|
1841
|
-
const { plugins
|
|
1860
|
+
const { plugins } = editor.sink;
|
|
1842
1861
|
const nextProps = useMemo(
|
|
1843
1862
|
() => ({
|
|
1844
1863
|
...originalProps,
|
|
1845
|
-
decorate: createDecorate(originalProps.decorate,
|
|
1846
|
-
renderElement: createRenderElement(originalProps.renderElement,
|
|
1847
|
-
renderLeaf: createRenderLeaf(originalProps.renderLeaf,
|
|
1864
|
+
decorate: createDecorate(originalProps.decorate, plugins),
|
|
1865
|
+
renderElement: createRenderElement(originalProps.renderElement, plugins),
|
|
1866
|
+
renderLeaf: createRenderLeaf(originalProps.renderLeaf, plugins),
|
|
1848
1867
|
renderPlaceholder: createRenderPlaceholder(
|
|
1849
1868
|
originalProps.renderPlaceholder,
|
|
1850
|
-
|
|
1869
|
+
plugins
|
|
1851
1870
|
),
|
|
1852
1871
|
/**
|
|
1853
1872
|
* NOTE: We skip `onKeyUp` as it is deprecated. If somebody needs it in new
|
|
@@ -1855,21 +1874,21 @@ function SinkEditable(originalProps) {
|
|
|
1855
1874
|
*
|
|
1856
1875
|
* https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event
|
|
1857
1876
|
*/
|
|
1858
|
-
onKeyDown: createOnKeyDown(originalProps.onKeyDown,
|
|
1859
|
-
onKeyUp: createOnKeyUp(originalProps.onKeyUp,
|
|
1860
|
-
onPaste: createOnPaste(originalProps.onPaste,
|
|
1861
|
-
onDrop: createOnDrop(originalProps.onDrop,
|
|
1877
|
+
onKeyDown: createOnKeyDown(originalProps.onKeyDown, plugins),
|
|
1878
|
+
onKeyUp: createOnKeyUp(originalProps.onKeyUp, plugins),
|
|
1879
|
+
onPaste: createOnPaste(originalProps.onPaste, plugins),
|
|
1880
|
+
onDrop: createOnDrop(originalProps.onDrop, plugins)
|
|
1862
1881
|
}),
|
|
1863
1882
|
Object.values(originalProps)
|
|
1864
1883
|
);
|
|
1865
|
-
const NextEditable = useMemo(() => createEditable(
|
|
1884
|
+
const NextEditable = useMemo(() => createEditable(plugins), [plugins]);
|
|
1866
1885
|
return /* @__PURE__ */ jsx2(NextEditable, { ...nextProps });
|
|
1867
1886
|
}
|
|
1868
1887
|
|
|
1869
1888
|
// src/sink/editor/create-boolean-action.ts
|
|
1870
|
-
function createBooleanAction(editor, actionKey,
|
|
1889
|
+
function createBooleanAction(editor, actionKey, plugins) {
|
|
1871
1890
|
const originalAction = editor[actionKey];
|
|
1872
|
-
const actionPlugins =
|
|
1891
|
+
const actionPlugins = plugins.filter((plugin) => plugin.editor?.[actionKey]);
|
|
1873
1892
|
return function nextBooleanAction(node) {
|
|
1874
1893
|
for (const plugin of actionPlugins) {
|
|
1875
1894
|
const result = plugin.editor?.[actionKey]?.(node);
|
|
@@ -1881,9 +1900,9 @@ function createBooleanAction(editor, actionKey, plugins2) {
|
|
|
1881
1900
|
}
|
|
1882
1901
|
|
|
1883
1902
|
// src/sink/editor/create-void-action.ts
|
|
1884
|
-
function createVoidAction(editor, actionKey,
|
|
1903
|
+
function createVoidAction(editor, actionKey, plugins) {
|
|
1885
1904
|
const originalAction = editor[actionKey];
|
|
1886
|
-
const actionPlugins =
|
|
1905
|
+
const actionPlugins = plugins.filter((plugin) => plugin.editor?.[actionKey]);
|
|
1887
1906
|
return function nextVoidAction(...args) {
|
|
1888
1907
|
let isHandled = false;
|
|
1889
1908
|
const afterHandledCallbacks = [];
|
|
@@ -1907,10 +1926,10 @@ function createVoidAction(editor, actionKey, plugins2) {
|
|
|
1907
1926
|
function createWithSink(pluginFns) {
|
|
1908
1927
|
return (originalEditor, options) => {
|
|
1909
1928
|
const editor = originalEditor;
|
|
1910
|
-
const
|
|
1929
|
+
const plugins = pluginFns.map(
|
|
1911
1930
|
(plugin) => plugin(editor, options, { createPolicy: (x) => x })
|
|
1912
1931
|
);
|
|
1913
|
-
editor.sink = { plugins
|
|
1932
|
+
editor.sink = { plugins };
|
|
1914
1933
|
editor.isMaster = "isMaster" in editor ? editor.isMaster : () => false;
|
|
1915
1934
|
editor.isSlave = "isSlave" in editor ? editor.isSlave : () => false;
|
|
1916
1935
|
editor.isStandalone = "isStandalone" in editor ? editor.isStandalone : () => false;
|
|
@@ -1918,22 +1937,22 @@ function createWithSink(pluginFns) {
|
|
|
1918
1937
|
/**
|
|
1919
1938
|
* void
|
|
1920
1939
|
*/
|
|
1921
|
-
normalizeNode: createVoidAction(editor, "normalizeNode",
|
|
1922
|
-
deleteBackward: createVoidAction(editor, "deleteBackward",
|
|
1923
|
-
deleteForward: createVoidAction(editor, "deleteForward",
|
|
1924
|
-
deleteFragment: createVoidAction(editor, "deleteFragment",
|
|
1925
|
-
insertBreak: createVoidAction(editor, "insertBreak",
|
|
1926
|
-
insertFragment: createVoidAction(editor, "insertFragment",
|
|
1927
|
-
insertNode: createVoidAction(editor, "insertNode",
|
|
1928
|
-
insertText: createVoidAction(editor, "insertText",
|
|
1940
|
+
normalizeNode: createVoidAction(editor, "normalizeNode", plugins),
|
|
1941
|
+
deleteBackward: createVoidAction(editor, "deleteBackward", plugins),
|
|
1942
|
+
deleteForward: createVoidAction(editor, "deleteForward", plugins),
|
|
1943
|
+
deleteFragment: createVoidAction(editor, "deleteFragment", plugins),
|
|
1944
|
+
insertBreak: createVoidAction(editor, "insertBreak", plugins),
|
|
1945
|
+
insertFragment: createVoidAction(editor, "insertFragment", plugins),
|
|
1946
|
+
insertNode: createVoidAction(editor, "insertNode", plugins),
|
|
1947
|
+
insertText: createVoidAction(editor, "insertText", plugins),
|
|
1929
1948
|
/**
|
|
1930
1949
|
* boolean
|
|
1931
1950
|
*/
|
|
1932
|
-
isInline: createBooleanAction(editor, "isInline",
|
|
1933
|
-
isVoid: createBooleanAction(editor, "isVoid",
|
|
1934
|
-
isMaster: createBooleanAction(editor, "isMaster",
|
|
1935
|
-
isSlave: createBooleanAction(editor, "isSlave",
|
|
1936
|
-
isStandalone: createBooleanAction(editor, "isStandalone",
|
|
1951
|
+
isInline: createBooleanAction(editor, "isInline", plugins),
|
|
1952
|
+
isVoid: createBooleanAction(editor, "isVoid", plugins),
|
|
1953
|
+
isMaster: createBooleanAction(editor, "isMaster", plugins),
|
|
1954
|
+
isSlave: createBooleanAction(editor, "isSlave", plugins),
|
|
1955
|
+
isStandalone: createBooleanAction(editor, "isStandalone", plugins)
|
|
1937
1956
|
});
|
|
1938
1957
|
return editor;
|
|
1939
1958
|
};
|
|
@@ -2292,18 +2311,31 @@ function isUrl(s) {
|
|
|
2292
2311
|
}
|
|
2293
2312
|
|
|
2294
2313
|
// src/anchor-plugin/methods/editLink.ts
|
|
2295
|
-
import { Transforms as Transforms7 } from "slate";
|
|
2296
|
-
function editLink(editor, { href, title }, { at }) {
|
|
2314
|
+
import { Editor as Editor14, Node as Node4, Transforms as Transforms7 } from "slate";
|
|
2315
|
+
function editLink(editor, { href, title, text }, { at }) {
|
|
2297
2316
|
const link = findElementUp(editor, "anchor", { at });
|
|
2298
2317
|
if (!link)
|
|
2299
2318
|
return false;
|
|
2300
|
-
|
|
2319
|
+
const [element, path] = link;
|
|
2320
|
+
Transforms7.setNodes(editor, { href, title }, { at: path });
|
|
2321
|
+
if (text !== void 0) {
|
|
2322
|
+
const currentText = Node4.string(element);
|
|
2323
|
+
if (text !== currentText) {
|
|
2324
|
+
Editor14.withoutNormalizing(editor, () => {
|
|
2325
|
+
const childCount = element.children.length;
|
|
2326
|
+
for (let i = childCount - 1; i >= 0; i--) {
|
|
2327
|
+
Transforms7.removeNodes(editor, { at: [...path, i] });
|
|
2328
|
+
}
|
|
2329
|
+
Transforms7.insertNodes(editor, { text }, { at: [...path, 0] });
|
|
2330
|
+
});
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2301
2333
|
return true;
|
|
2302
2334
|
}
|
|
2303
2335
|
|
|
2304
2336
|
// src/anchor-plugin/methods/insertLink.ts
|
|
2305
2337
|
import { Editor as Editor15, Range as Range3, Text as Text2, Transforms as Transforms8 } from "slate";
|
|
2306
|
-
function insertLink(editor, href, text = href, { select = true } = {}) {
|
|
2338
|
+
function insertLink(editor, href, text = href, { select = true, title } = {}) {
|
|
2307
2339
|
const selection = editor.selection || {
|
|
2308
2340
|
anchor: Editor15.start(editor, [0]),
|
|
2309
2341
|
focus: Editor15.start(editor, [0])
|
|
@@ -2314,6 +2346,7 @@ function insertLink(editor, href, text = href, { select = true } = {}) {
|
|
|
2314
2346
|
{
|
|
2315
2347
|
type: "anchor",
|
|
2316
2348
|
href,
|
|
2349
|
+
title,
|
|
2317
2350
|
children: [{ text }]
|
|
2318
2351
|
},
|
|
2319
2352
|
{ select, at: selection }
|
|
@@ -2325,7 +2358,7 @@ function insertLink(editor, href, text = href, { select = true } = {}) {
|
|
|
2325
2358
|
} else {
|
|
2326
2359
|
Transforms8.wrapNodes(
|
|
2327
2360
|
editor,
|
|
2328
|
-
{ type: "anchor", href, children: [] },
|
|
2361
|
+
{ type: "anchor", href, title, children: [] },
|
|
2329
2362
|
{
|
|
2330
2363
|
split: true,
|
|
2331
2364
|
match: (node) => Text2.isText(node) || Editor15.isInline(editor, node)
|
|
@@ -3158,6 +3191,7 @@ function useTooltip({
|
|
|
3158
3191
|
// src/anchor-plugin/render-element/AnchorEditDialog.tsx
|
|
3159
3192
|
import styled13 from "@emotion/styled";
|
|
3160
3193
|
import { useCallback as useCallback3, useRef as useRef3, useState as useState3 } from "react";
|
|
3194
|
+
import { Node as Node6 } from "slate";
|
|
3161
3195
|
import { useSlateStatic as useSlateStatic3 } from "slate-react";
|
|
3162
3196
|
|
|
3163
3197
|
// src/shared-styles/index.ts
|
|
@@ -3273,12 +3307,16 @@ function AnchorEditDialog({
|
|
|
3273
3307
|
);
|
|
3274
3308
|
const editor = useSlateStatic3();
|
|
3275
3309
|
const [href, setHref] = useState3(element.href);
|
|
3310
|
+
const [text, setText] = useState3(Node6.string(element));
|
|
3276
3311
|
const [title, setTitle] = useState3(element.title || "");
|
|
3277
|
-
const formRef = useRef3({ href, title });
|
|
3278
|
-
formRef.current = { href, title };
|
|
3312
|
+
const formRef = useRef3({ href, text, title });
|
|
3313
|
+
formRef.current = { href, text, title };
|
|
3279
3314
|
const handleHrefChange = useCallback3((e) => {
|
|
3280
3315
|
setHref(e.target.value);
|
|
3281
3316
|
}, []);
|
|
3317
|
+
const handleTextChange = useCallback3((e) => {
|
|
3318
|
+
setText(e.target.value);
|
|
3319
|
+
}, []);
|
|
3282
3320
|
const handleTitleChange = useCallback3((e) => {
|
|
3283
3321
|
setTitle(e.target.value);
|
|
3284
3322
|
}, []);
|
|
@@ -3293,14 +3331,19 @@ function AnchorEditDialog({
|
|
|
3293
3331
|
));
|
|
3294
3332
|
}, [destAnchor, destStartEdge, element]);
|
|
3295
3333
|
const handleSubmit = useCallback3(() => {
|
|
3296
|
-
const { href: href2, title: title2 } = formRef.current;
|
|
3297
|
-
editor.anchor.editLink({ href: href2, title: title2 }, { at: element });
|
|
3334
|
+
const { href: href2, text: text2, title: title2 } = formRef.current;
|
|
3335
|
+
editor.anchor.editLink({ href: href2, text: text2, title: title2 }, { at: element });
|
|
3298
3336
|
openAnchorDialog();
|
|
3299
3337
|
}, [openAnchorDialog]);
|
|
3300
3338
|
return /* @__PURE__ */ jsxs5($AnchorEditDialog, { contentEditable: false, style, children: [
|
|
3301
3339
|
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3302
3340
|
/* @__PURE__ */ jsx11($FormCaption, { children: t("linkUrl") }),
|
|
3303
|
-
/* @__PURE__ */ jsx11($
|
|
3341
|
+
/* @__PURE__ */ jsx11($Input, { type: "text", value: href, onChange: handleHrefChange })
|
|
3342
|
+
] }),
|
|
3343
|
+
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3344
|
+
/* @__PURE__ */ jsx11($FormCaption, { children: t("linkText") }),
|
|
3345
|
+
/* @__PURE__ */ jsx11($Input, { type: "text", value: text, onChange: handleTextChange }),
|
|
3346
|
+
/* @__PURE__ */ jsx11($FormHint, { children: t("linkTextHint") })
|
|
3304
3347
|
] }),
|
|
3305
3348
|
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3306
3349
|
/* @__PURE__ */ jsx11($FormCaption, { children: t("tooltipText") }),
|
|
@@ -3409,7 +3452,7 @@ function parseUrl2(s) {
|
|
|
3409
3452
|
try {
|
|
3410
3453
|
const url = new URL(s);
|
|
3411
3454
|
return { hostname: url.hostname, pathname: url.pathname };
|
|
3412
|
-
} catch
|
|
3455
|
+
} catch {
|
|
3413
3456
|
return { hostname: "", pathname: "" };
|
|
3414
3457
|
}
|
|
3415
3458
|
}
|
|
@@ -4604,16 +4647,14 @@ function createOnDrop2(editor) {
|
|
|
4604
4647
|
Transforms17.select(editor, range);
|
|
4605
4648
|
}
|
|
4606
4649
|
const onImageChange = editor.wysimark?.onImageChange;
|
|
4607
|
-
|
|
4650
|
+
for (const file of imageFiles) {
|
|
4608
4651
|
if (onImageChange) {
|
|
4609
|
-
|
|
4610
|
-
const url = await onImageChange(file);
|
|
4652
|
+
onImageChange(file).then((url) => {
|
|
4611
4653
|
if (url) {
|
|
4612
4654
|
editor.image.insertImageFromUrl(url, file.name, "");
|
|
4613
4655
|
}
|
|
4614
|
-
}
|
|
4615
|
-
|
|
4616
|
-
}
|
|
4656
|
+
}).catch(() => {
|
|
4657
|
+
});
|
|
4617
4658
|
} else {
|
|
4618
4659
|
const reader = new FileReader();
|
|
4619
4660
|
reader.onload = () => {
|
|
@@ -4622,7 +4663,7 @@ function createOnDrop2(editor) {
|
|
|
4622
4663
|
};
|
|
4623
4664
|
reader.readAsDataURL(file);
|
|
4624
4665
|
}
|
|
4625
|
-
}
|
|
4666
|
+
}
|
|
4626
4667
|
return true;
|
|
4627
4668
|
};
|
|
4628
4669
|
}
|
|
@@ -4861,7 +4902,7 @@ import { Editor as Editor28, Element as Element15, Transforms as Transforms21 }
|
|
|
4861
4902
|
|
|
4862
4903
|
// src/code-block-plugin/decorate.tsx
|
|
4863
4904
|
import Prism from "prismjs";
|
|
4864
|
-
import { Element as Element12, Node as
|
|
4905
|
+
import { Element as Element12, Node as Node8 } from "slate";
|
|
4865
4906
|
var { languages, tokenize } = Prism;
|
|
4866
4907
|
function getLineOffsets(lines) {
|
|
4867
4908
|
let offset = 0;
|
|
@@ -4882,7 +4923,7 @@ function decorate(nodeEntry) {
|
|
|
4882
4923
|
if (lang === void 0)
|
|
4883
4924
|
return [];
|
|
4884
4925
|
const codeLineElements = node.children;
|
|
4885
|
-
const textLines = codeLineElements.map((node2) => `${
|
|
4926
|
+
const textLines = codeLineElements.map((node2) => `${Node8.string(node2)}
|
|
4886
4927
|
`);
|
|
4887
4928
|
const text = textLines.join("");
|
|
4888
4929
|
const lineOffsets = getLineOffsets(textLines);
|
|
@@ -4992,24 +5033,13 @@ var tokenStyles = {
|
|
|
4992
5033
|
italic: italicStyle
|
|
4993
5034
|
};
|
|
4994
5035
|
|
|
4995
|
-
// src/code-block-plugin/types.tsx
|
|
4996
|
-
var LanguageList = [
|
|
4997
|
-
"text",
|
|
4998
|
-
"html",
|
|
4999
|
-
"css",
|
|
5000
|
-
"svg",
|
|
5001
|
-
"javascript",
|
|
5002
|
-
"java",
|
|
5003
|
-
"c"
|
|
5004
|
-
];
|
|
5005
|
-
|
|
5006
5036
|
// src/code-block-plugin/normalizeNode.tsx
|
|
5007
|
-
import { Element as Element14, Node as
|
|
5037
|
+
import { Element as Element14, Node as Node9, Transforms as Transforms20 } from "slate";
|
|
5008
5038
|
function normalizeNode3(editor, entry) {
|
|
5009
5039
|
if (!Element14.isElement(entry[0]))
|
|
5010
5040
|
return false;
|
|
5011
5041
|
if (entry[0].type === "code-block-line") {
|
|
5012
|
-
for (const [child, path] of
|
|
5042
|
+
for (const [child, path] of Node9.children(editor, entry[1])) {
|
|
5013
5043
|
if (!Element14.isElement(child))
|
|
5014
5044
|
continue;
|
|
5015
5045
|
if (editor.isVoid(child)) {
|
|
@@ -5022,7 +5052,7 @@ function normalizeNode3(editor, entry) {
|
|
|
5022
5052
|
}
|
|
5023
5053
|
}
|
|
5024
5054
|
if (entry[0].type === "code-block") {
|
|
5025
|
-
for (const [child, path] of
|
|
5055
|
+
for (const [child, path] of Node9.children(editor, entry[1])) {
|
|
5026
5056
|
if (!Element14.isElement(child))
|
|
5027
5057
|
continue;
|
|
5028
5058
|
if (child.type === "code-block-line")
|
|
@@ -5037,7 +5067,7 @@ function normalizeNode3(editor, entry) {
|
|
|
5037
5067
|
Transforms20.removeNodes(editor, { at: path });
|
|
5038
5068
|
Transforms20.insertNodes(editor, {
|
|
5039
5069
|
type: "code-block-line",
|
|
5040
|
-
children: [{ text:
|
|
5070
|
+
children: [{ text: Node9.string(child) }]
|
|
5041
5071
|
});
|
|
5042
5072
|
return true;
|
|
5043
5073
|
}
|
|
@@ -5047,12 +5077,8 @@ function normalizeNode3(editor, entry) {
|
|
|
5047
5077
|
}
|
|
5048
5078
|
|
|
5049
5079
|
// src/code-block-plugin/render-element/CodeBlock.tsx
|
|
5050
|
-
import { useCallback as useCallback9,
|
|
5051
|
-
import { useSelected as useSelected3 } from "slate-react";
|
|
5052
|
-
|
|
5053
|
-
// src/code-block-plugin/icons/ChevronDownIcon.tsx
|
|
5054
|
-
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
5055
|
-
var ChevronDownIcon = (props) => /* @__PURE__ */ jsx29(TablerIcon, { ...props, children: /* @__PURE__ */ jsx29("path", { d: "m6 9 6 6 6-6" }) });
|
|
5080
|
+
import { useCallback as useCallback9, useState as useState5 } from "react";
|
|
5081
|
+
import { useSelected as useSelected3, useSlateStatic as useSlateStatic11 } from "slate-react";
|
|
5056
5082
|
|
|
5057
5083
|
// src/code-block-plugin/styles.ts
|
|
5058
5084
|
import styled23 from "@emotion/styled";
|
|
@@ -5134,50 +5160,70 @@ var $CodeBlockLine = styled23("div")`
|
|
|
5134
5160
|
`;
|
|
5135
5161
|
|
|
5136
5162
|
// src/code-block-plugin/render-element/CodeBlock.tsx
|
|
5137
|
-
import { jsx as
|
|
5163
|
+
import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5138
5164
|
function CodeBlock({
|
|
5139
5165
|
element,
|
|
5140
5166
|
attributes,
|
|
5141
5167
|
children
|
|
5142
5168
|
}) {
|
|
5143
|
-
const
|
|
5169
|
+
const editor = useSlateStatic11();
|
|
5144
5170
|
const selected = useSelected3();
|
|
5145
|
-
const
|
|
5146
|
-
const
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5171
|
+
const [isEditing, setIsEditing] = useState5(false);
|
|
5172
|
+
const [inputValue, setInputValue] = useState5(element.language);
|
|
5173
|
+
const handleClick = useCallback9(() => {
|
|
5174
|
+
setInputValue(element.language);
|
|
5175
|
+
setIsEditing(true);
|
|
5176
|
+
}, [element.language]);
|
|
5177
|
+
const handleBlur = useCallback9(() => {
|
|
5178
|
+
setIsEditing(false);
|
|
5179
|
+
if (inputValue !== element.language) {
|
|
5180
|
+
editor.codeBlock.setCodeBlockLanguage(inputValue || "text", { at: element });
|
|
5181
|
+
}
|
|
5182
|
+
}, [editor, element, inputValue]);
|
|
5183
|
+
const handleKeyDown = useCallback9((e) => {
|
|
5184
|
+
if (e.key === "Enter") {
|
|
5185
|
+
e.preventDefault();
|
|
5186
|
+
e.target.blur();
|
|
5187
|
+
} else if (e.key === "Escape") {
|
|
5188
|
+
setInputValue(element.language);
|
|
5189
|
+
setIsEditing(false);
|
|
5190
|
+
}
|
|
5191
|
+
}, [element.language]);
|
|
5163
5192
|
return /* @__PURE__ */ jsxs16($CodeBlock, { className: selected ? "--selected" : "", ...attributes, children: [
|
|
5164
|
-
/* @__PURE__ */
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
|
|
5193
|
+
/* @__PURE__ */ jsx29($CodeBlockLanguage, { contentEditable: false, children: isEditing ? /* @__PURE__ */ jsx29(
|
|
5194
|
+
"input",
|
|
5195
|
+
{
|
|
5196
|
+
type: "text",
|
|
5197
|
+
value: inputValue,
|
|
5198
|
+
onChange: (e) => setInputValue(e.target.value),
|
|
5199
|
+
onBlur: handleBlur,
|
|
5200
|
+
onKeyDown: handleKeyDown,
|
|
5201
|
+
autoFocus: true,
|
|
5202
|
+
style: {
|
|
5203
|
+
width: "100%",
|
|
5204
|
+
border: "none",
|
|
5205
|
+
background: "transparent",
|
|
5206
|
+
font: "inherit",
|
|
5207
|
+
color: "inherit",
|
|
5208
|
+
padding: 0,
|
|
5209
|
+
outline: "none",
|
|
5210
|
+
textAlign: "right"
|
|
5211
|
+
}
|
|
5212
|
+
}
|
|
5213
|
+
) : /* @__PURE__ */ jsx29("span", { onClick: handleClick, style: { cursor: "pointer", width: "100%" }, children: element.language || "text" }) }),
|
|
5214
|
+
/* @__PURE__ */ jsx29($CodeBlockScroller, { children })
|
|
5169
5215
|
] });
|
|
5170
5216
|
}
|
|
5171
5217
|
|
|
5172
5218
|
// src/code-block-plugin/render-element/CodeBlockLine.tsx
|
|
5173
5219
|
import { useSelected as useSelected4 } from "slate-react";
|
|
5174
|
-
import { jsx as
|
|
5220
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
5175
5221
|
function CodeBlockLine({
|
|
5176
5222
|
attributes,
|
|
5177
5223
|
children
|
|
5178
5224
|
}) {
|
|
5179
5225
|
const selected = useSelected4();
|
|
5180
|
-
return /* @__PURE__ */
|
|
5226
|
+
return /* @__PURE__ */ jsx30(
|
|
5181
5227
|
$CodeBlockLine,
|
|
5182
5228
|
{
|
|
5183
5229
|
className: selected ? "--selected" : "",
|
|
@@ -5189,21 +5235,21 @@ function CodeBlockLine({
|
|
|
5189
5235
|
}
|
|
5190
5236
|
|
|
5191
5237
|
// src/code-block-plugin/render-element/index.tsx
|
|
5192
|
-
import { jsx as
|
|
5238
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
5193
5239
|
function renderElement2({
|
|
5194
5240
|
element,
|
|
5195
5241
|
attributes,
|
|
5196
5242
|
children
|
|
5197
5243
|
}) {
|
|
5198
5244
|
if (element.type === "code-block") {
|
|
5199
|
-
return /* @__PURE__ */
|
|
5245
|
+
return /* @__PURE__ */ jsx31(CodeBlock, { element, attributes, children });
|
|
5200
5246
|
} else if (element.type === "code-block-line") {
|
|
5201
|
-
return /* @__PURE__ */
|
|
5247
|
+
return /* @__PURE__ */ jsx31(CodeBlockLine, { element, attributes, children });
|
|
5202
5248
|
}
|
|
5203
5249
|
}
|
|
5204
5250
|
|
|
5205
5251
|
// src/code-block-plugin/index.tsx
|
|
5206
|
-
import { jsx as
|
|
5252
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
5207
5253
|
var CodeBlockPlugin = createPlugin(
|
|
5208
5254
|
(editor, _options, { createPolicy }) => {
|
|
5209
5255
|
editor.codeBlock = createCodeBlockMethods(editor);
|
|
@@ -5261,7 +5307,7 @@ var CodeBlockPlugin = createPlugin(
|
|
|
5261
5307
|
if (style === null) {
|
|
5262
5308
|
return children;
|
|
5263
5309
|
} else {
|
|
5264
|
-
return /* @__PURE__ */
|
|
5310
|
+
return /* @__PURE__ */ jsx32("span", { style, children });
|
|
5265
5311
|
}
|
|
5266
5312
|
}
|
|
5267
5313
|
}
|
|
@@ -5338,7 +5384,7 @@ import { useSelected as useSelected5 } from "slate-react";
|
|
|
5338
5384
|
import styled24 from "@emotion/styled";
|
|
5339
5385
|
var $Paragraph = styled24("p")`
|
|
5340
5386
|
padding: 0;
|
|
5341
|
-
margin:
|
|
5387
|
+
margin: 0;
|
|
5342
5388
|
&:first-child {
|
|
5343
5389
|
margin-top: 0;
|
|
5344
5390
|
}
|
|
@@ -5348,8 +5394,8 @@ var $Paragraph = styled24("p")`
|
|
|
5348
5394
|
|
|
5349
5395
|
&.--collapsible&.--empty {
|
|
5350
5396
|
font-size: 0.25em; /* font-size is collapsed to 1/4 of regular em */
|
|
5351
|
-
margin: -4em 0;
|
|
5352
|
-
padding: 1em 0; /* this is kind of eye-balling it */
|
|
5397
|
+
margin: -0.4em 0;
|
|
5398
|
+
padding: 0.1em 0; /* this is kind of eye-balling it */
|
|
5353
5399
|
border-radius: 1em;
|
|
5354
5400
|
&:hover {
|
|
5355
5401
|
background: rgba(0, 127, 255, 0.1);
|
|
@@ -5359,7 +5405,7 @@ var $Paragraph = styled24("p")`
|
|
|
5359
5405
|
&.--collapsible&.--empty&.--selected {
|
|
5360
5406
|
font-size: 1em;
|
|
5361
5407
|
padding: 0;
|
|
5362
|
-
margin:
|
|
5408
|
+
margin: 0;
|
|
5363
5409
|
&:hover {
|
|
5364
5410
|
background: none;
|
|
5365
5411
|
cursor: default;
|
|
@@ -5369,13 +5415,13 @@ var $Paragraph = styled24("p")`
|
|
|
5369
5415
|
`;
|
|
5370
5416
|
|
|
5371
5417
|
// src/collapsible-paragraph-plugin/render-element/utils.ts
|
|
5372
|
-
import { Node as
|
|
5418
|
+
import { Node as Node12 } from "slate";
|
|
5373
5419
|
function getIsEmpty(element) {
|
|
5374
|
-
return element.children.length === 1 &&
|
|
5420
|
+
return element.children.length === 1 && Node12.string(element.children[0]).length === 0;
|
|
5375
5421
|
}
|
|
5376
5422
|
|
|
5377
5423
|
// src/collapsible-paragraph-plugin/render-element/paragraph.tsx
|
|
5378
|
-
import { jsx as
|
|
5424
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
5379
5425
|
function Paragraph({
|
|
5380
5426
|
element,
|
|
5381
5427
|
attributes,
|
|
@@ -5383,7 +5429,7 @@ function Paragraph({
|
|
|
5383
5429
|
}) {
|
|
5384
5430
|
const selected = useSelected5();
|
|
5385
5431
|
const isEmpty = getIsEmpty(element);
|
|
5386
|
-
return /* @__PURE__ */
|
|
5432
|
+
return /* @__PURE__ */ jsx33(
|
|
5387
5433
|
$Paragraph,
|
|
5388
5434
|
{
|
|
5389
5435
|
...attributes,
|
|
@@ -5398,14 +5444,19 @@ function Paragraph({
|
|
|
5398
5444
|
}
|
|
5399
5445
|
|
|
5400
5446
|
// src/collapsible-paragraph-plugin/index.tsx
|
|
5401
|
-
import { jsx as
|
|
5447
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
5402
5448
|
var CollapsibleParagraphPlugin = createPlugin((editor) => {
|
|
5403
5449
|
const { insertBreak: insertBreak3 } = editor;
|
|
5404
5450
|
editor.insertBreak = () => {
|
|
5405
5451
|
const { selection } = editor;
|
|
5406
5452
|
if (selection && selection.anchor.path[0] === selection.focus.path[0]) {
|
|
5407
|
-
const
|
|
5408
|
-
|
|
5453
|
+
const blockPath = [selection.anchor.path[0]];
|
|
5454
|
+
const blockStart = Editor32.start(editor, blockPath);
|
|
5455
|
+
const textBeforeCursor = Editor32.string(editor, {
|
|
5456
|
+
anchor: blockStart,
|
|
5457
|
+
focus: selection.anchor
|
|
5458
|
+
});
|
|
5459
|
+
if (textBeforeCursor.endsWith("\n")) {
|
|
5409
5460
|
insertBreak3();
|
|
5410
5461
|
} else {
|
|
5411
5462
|
editor.insertText("\n");
|
|
@@ -5440,7 +5491,7 @@ var CollapsibleParagraphPlugin = createPlugin((editor) => {
|
|
|
5440
5491
|
renderElement: ({ element, attributes, children }) => {
|
|
5441
5492
|
switch (element.type) {
|
|
5442
5493
|
case "paragraph": {
|
|
5443
|
-
return /* @__PURE__ */
|
|
5494
|
+
return /* @__PURE__ */ jsx34(Paragraph, { element, attributes, children });
|
|
5444
5495
|
}
|
|
5445
5496
|
}
|
|
5446
5497
|
},
|
|
@@ -5461,13 +5512,51 @@ function addConvertElementType(editor, type) {
|
|
|
5461
5512
|
}
|
|
5462
5513
|
|
|
5463
5514
|
// src/convert-element-plugin/methods/convert-elements.ts
|
|
5464
|
-
import { Editor as Editor33, Element as Element20, Node as
|
|
5515
|
+
import { Editor as Editor33, Element as Element20, Node as Node13, Point, Range as Range5, Transforms as Transforms24 } from "slate";
|
|
5516
|
+
function getOffsetInElement(editor, point, elementPath) {
|
|
5517
|
+
try {
|
|
5518
|
+
const elementStart = Editor33.start(editor, elementPath);
|
|
5519
|
+
const elementEnd = Editor33.end(editor, elementPath);
|
|
5520
|
+
if (Point.isBefore(point, elementStart) || Point.isAfter(point, elementEnd)) {
|
|
5521
|
+
return -1;
|
|
5522
|
+
}
|
|
5523
|
+
const range = { anchor: elementStart, focus: point };
|
|
5524
|
+
return Editor33.string(editor, range).length;
|
|
5525
|
+
} catch {
|
|
5526
|
+
return -1;
|
|
5527
|
+
}
|
|
5528
|
+
}
|
|
5529
|
+
function restoreSelectionInElement(editor, elementPath, offset) {
|
|
5530
|
+
try {
|
|
5531
|
+
const element = Node13.get(editor, elementPath);
|
|
5532
|
+
if (!Element20.isElement(element))
|
|
5533
|
+
return;
|
|
5534
|
+
const text = Node13.string(element);
|
|
5535
|
+
const safeOffset = Math.min(offset, text.length);
|
|
5536
|
+
const elementStart = Editor33.start(editor, elementPath);
|
|
5537
|
+
let currentOffset = 0;
|
|
5538
|
+
let targetPath = elementStart.path;
|
|
5539
|
+
let targetOffset = 0;
|
|
5540
|
+
for (const [node, path] of Node13.texts(element)) {
|
|
5541
|
+
const nodeLength = node.text.length;
|
|
5542
|
+
if (currentOffset + nodeLength >= safeOffset) {
|
|
5543
|
+
targetPath = [...elementPath, ...path];
|
|
5544
|
+
targetOffset = safeOffset - currentOffset;
|
|
5545
|
+
break;
|
|
5546
|
+
}
|
|
5547
|
+
currentOffset += nodeLength;
|
|
5548
|
+
}
|
|
5549
|
+
const point = { path: targetPath, offset: targetOffset };
|
|
5550
|
+
Transforms24.select(editor, { anchor: point, focus: point });
|
|
5551
|
+
} catch {
|
|
5552
|
+
}
|
|
5553
|
+
}
|
|
5465
5554
|
function elementContainsNewlines(element) {
|
|
5466
|
-
const text =
|
|
5555
|
+
const text = Node13.string(element);
|
|
5467
5556
|
return text.includes("\n");
|
|
5468
5557
|
}
|
|
5469
5558
|
function getSelectedLineIndices(editor, element, elementPath, selection) {
|
|
5470
|
-
const text =
|
|
5559
|
+
const text = Node13.string(element);
|
|
5471
5560
|
const lines = text.split("\n");
|
|
5472
5561
|
const elementStart = Editor33.start(editor, elementPath);
|
|
5473
5562
|
const elementEnd = Editor33.end(editor, elementPath);
|
|
@@ -5500,7 +5589,7 @@ function getSelectedLineIndices(editor, element, elementPath, selection) {
|
|
|
5500
5589
|
return { startLineIndex, endLineIndex };
|
|
5501
5590
|
}
|
|
5502
5591
|
function splitElementAtSelectedLines(editor, element, path, selection) {
|
|
5503
|
-
const text =
|
|
5592
|
+
const text = Node13.string(element);
|
|
5504
5593
|
if (!text.includes("\n")) {
|
|
5505
5594
|
return path;
|
|
5506
5595
|
}
|
|
@@ -5575,6 +5664,14 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5575
5664
|
);
|
|
5576
5665
|
if (entries.length === 0)
|
|
5577
5666
|
return false;
|
|
5667
|
+
let savedAnchorOffset = -1;
|
|
5668
|
+
let savedFocusOffset = -1;
|
|
5669
|
+
let isCollapsed2 = Range5.isCollapsed(selection);
|
|
5670
|
+
if (entries.length > 0) {
|
|
5671
|
+
const [, firstPath] = entries[0];
|
|
5672
|
+
savedAnchorOffset = getOffsetInElement(editor, selection.anchor, firstPath);
|
|
5673
|
+
savedFocusOffset = getOffsetInElement(editor, selection.focus, firstPath);
|
|
5674
|
+
}
|
|
5578
5675
|
const allPaths = [];
|
|
5579
5676
|
Editor33.withoutNormalizing(editor, () => {
|
|
5580
5677
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -5594,7 +5691,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5594
5691
|
});
|
|
5595
5692
|
const updatedEntries = allPaths.map((path) => {
|
|
5596
5693
|
try {
|
|
5597
|
-
const node =
|
|
5694
|
+
const node = Node13.get(editor, path);
|
|
5598
5695
|
if (Element20.isElement(node)) {
|
|
5599
5696
|
return [node, path];
|
|
5600
5697
|
}
|
|
@@ -5619,6 +5716,52 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5619
5716
|
}
|
|
5620
5717
|
});
|
|
5621
5718
|
}
|
|
5719
|
+
if (updatedEntries.length > 0 && savedAnchorOffset >= 0) {
|
|
5720
|
+
const [, firstPath] = updatedEntries[0];
|
|
5721
|
+
if (isCollapsed2) {
|
|
5722
|
+
restoreSelectionInElement(editor, firstPath, savedAnchorOffset);
|
|
5723
|
+
} else if (savedFocusOffset >= 0) {
|
|
5724
|
+
try {
|
|
5725
|
+
const element = Node13.get(editor, firstPath);
|
|
5726
|
+
if (Element20.isElement(element)) {
|
|
5727
|
+
const text = Node13.string(element);
|
|
5728
|
+
const safeAnchorOffset = Math.min(savedAnchorOffset, text.length);
|
|
5729
|
+
const safeFocusOffset = Math.min(savedFocusOffset, text.length);
|
|
5730
|
+
const elementStart = Editor33.start(editor, firstPath);
|
|
5731
|
+
let anchorPath = elementStart.path;
|
|
5732
|
+
let anchorOffset = safeAnchorOffset;
|
|
5733
|
+
let currentOffset = 0;
|
|
5734
|
+
for (const [node, path] of Node13.texts(element)) {
|
|
5735
|
+
const nodeLength = node.text.length;
|
|
5736
|
+
if (currentOffset + nodeLength >= safeAnchorOffset) {
|
|
5737
|
+
anchorPath = [...firstPath, ...path];
|
|
5738
|
+
anchorOffset = safeAnchorOffset - currentOffset;
|
|
5739
|
+
break;
|
|
5740
|
+
}
|
|
5741
|
+
currentOffset += nodeLength;
|
|
5742
|
+
}
|
|
5743
|
+
let focusPath = elementStart.path;
|
|
5744
|
+
let focusOffset = safeFocusOffset;
|
|
5745
|
+
currentOffset = 0;
|
|
5746
|
+
for (const [node, path] of Node13.texts(element)) {
|
|
5747
|
+
const nodeLength = node.text.length;
|
|
5748
|
+
if (currentOffset + nodeLength >= safeFocusOffset) {
|
|
5749
|
+
focusPath = [...firstPath, ...path];
|
|
5750
|
+
focusOffset = safeFocusOffset - currentOffset;
|
|
5751
|
+
break;
|
|
5752
|
+
}
|
|
5753
|
+
currentOffset += nodeLength;
|
|
5754
|
+
}
|
|
5755
|
+
Transforms24.select(editor, {
|
|
5756
|
+
anchor: { path: anchorPath, offset: anchorOffset },
|
|
5757
|
+
focus: { path: focusPath, offset: focusOffset }
|
|
5758
|
+
});
|
|
5759
|
+
}
|
|
5760
|
+
} catch {
|
|
5761
|
+
restoreSelectionInElement(editor, firstPath, savedAnchorOffset);
|
|
5762
|
+
}
|
|
5763
|
+
}
|
|
5764
|
+
}
|
|
5622
5765
|
return true;
|
|
5623
5766
|
}
|
|
5624
5767
|
|
|
@@ -5734,7 +5877,7 @@ var $H6 = styled25("h6")`
|
|
|
5734
5877
|
`;
|
|
5735
5878
|
|
|
5736
5879
|
// src/heading-plugin/index.tsx
|
|
5737
|
-
import { jsx as
|
|
5880
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
5738
5881
|
var HeadingPlugin = createPlugin(
|
|
5739
5882
|
(editor) => {
|
|
5740
5883
|
editor.convertElement.addConvertElementType("heading");
|
|
@@ -5765,21 +5908,23 @@ var HeadingPlugin = createPlugin(
|
|
|
5765
5908
|
if (element.type === "heading") {
|
|
5766
5909
|
switch (element.level) {
|
|
5767
5910
|
case 1:
|
|
5768
|
-
return /* @__PURE__ */
|
|
5911
|
+
return /* @__PURE__ */ jsx35($H1, { ...attributes, children });
|
|
5769
5912
|
case 2:
|
|
5770
|
-
return /* @__PURE__ */
|
|
5913
|
+
return /* @__PURE__ */ jsx35($H2, { ...attributes, children });
|
|
5771
5914
|
case 3:
|
|
5772
|
-
return /* @__PURE__ */
|
|
5915
|
+
return /* @__PURE__ */ jsx35($H3, { ...attributes, children });
|
|
5773
5916
|
case 4:
|
|
5774
|
-
return /* @__PURE__ */
|
|
5917
|
+
return /* @__PURE__ */ jsx35($H4, { ...attributes, children });
|
|
5775
5918
|
case 5:
|
|
5776
|
-
return /* @__PURE__ */
|
|
5919
|
+
return /* @__PURE__ */ jsx35($H5, { ...attributes, children });
|
|
5777
5920
|
case 6:
|
|
5778
|
-
return /* @__PURE__ */
|
|
5779
|
-
default:
|
|
5921
|
+
return /* @__PURE__ */ jsx35($H6, { ...attributes, children });
|
|
5922
|
+
default: {
|
|
5923
|
+
const exhaustiveCheck = element.level;
|
|
5780
5924
|
throw new Error(
|
|
5781
|
-
`Expected element.level to be 1-6 but got ${
|
|
5925
|
+
`Expected element.level to be 1-6 but got ${exhaustiveCheck}`
|
|
5782
5926
|
);
|
|
5927
|
+
}
|
|
5783
5928
|
}
|
|
5784
5929
|
}
|
|
5785
5930
|
},
|
|
@@ -5833,7 +5978,7 @@ var $HorizontalRule = styled26("hr")`
|
|
|
5833
5978
|
`;
|
|
5834
5979
|
|
|
5835
5980
|
// src/horizontal-rule-plugin/horizontal-rule.tsx
|
|
5836
|
-
import { jsx as
|
|
5981
|
+
import { jsx as jsx36, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5837
5982
|
function HorizontalRule({
|
|
5838
5983
|
attributes,
|
|
5839
5984
|
children
|
|
@@ -5841,7 +5986,7 @@ function HorizontalRule({
|
|
|
5841
5986
|
const selected = useSelected6();
|
|
5842
5987
|
return /* @__PURE__ */ jsxs17("div", { ...attributes, draggable: true, children: [
|
|
5843
5988
|
children,
|
|
5844
|
-
/* @__PURE__ */
|
|
5989
|
+
/* @__PURE__ */ jsx36("div", { contentEditable: false, children: /* @__PURE__ */ jsx36($HorizontalRule, { className: selected ? "--selected" : "" }) })
|
|
5845
5990
|
] });
|
|
5846
5991
|
}
|
|
5847
5992
|
|
|
@@ -5859,7 +6004,7 @@ function createHorizontalRuleMethods(editor) {
|
|
|
5859
6004
|
}
|
|
5860
6005
|
|
|
5861
6006
|
// src/horizontal-rule-plugin/index.tsx
|
|
5862
|
-
import { jsx as
|
|
6007
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
5863
6008
|
var HorizontalRulePlugin = createPlugin(
|
|
5864
6009
|
(editor, _options, { createPolicy }) => {
|
|
5865
6010
|
editor.horizontalRule = createHorizontalRuleMethods(editor);
|
|
@@ -5874,7 +6019,7 @@ var HorizontalRulePlugin = createPlugin(
|
|
|
5874
6019
|
editableProps: {
|
|
5875
6020
|
renderElement: (props) => {
|
|
5876
6021
|
if (props.element.type === "horizontal-rule") {
|
|
5877
|
-
return /* @__PURE__ */
|
|
6022
|
+
return /* @__PURE__ */ jsx37(HorizontalRule, { ...props });
|
|
5878
6023
|
}
|
|
5879
6024
|
},
|
|
5880
6025
|
onKeyDown: createHotkeyHandler({
|
|
@@ -5917,7 +6062,7 @@ var $InvisibleSpan = styled27("span")`
|
|
|
5917
6062
|
`;
|
|
5918
6063
|
|
|
5919
6064
|
// src/inline-code-plugin/index.tsx
|
|
5920
|
-
import { jsx as
|
|
6065
|
+
import { jsx as jsx38, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
5921
6066
|
var InlineCodePlugin = createPlugin(
|
|
5922
6067
|
(editor) => {
|
|
5923
6068
|
if (!editor.marksPlugin)
|
|
@@ -5937,9 +6082,9 @@ var InlineCodePlugin = createPlugin(
|
|
|
5937
6082
|
* Disable spellCheck because it's computer code usually.
|
|
5938
6083
|
*/
|
|
5939
6084
|
/* @__PURE__ */ jsxs18($InlineCode, { spellCheck: false, children: [
|
|
5940
|
-
/* @__PURE__ */
|
|
6085
|
+
/* @__PURE__ */ jsx38($InvisibleSpan, { contentEditable: false, children: "|" }),
|
|
5941
6086
|
children,
|
|
5942
|
-
/* @__PURE__ */
|
|
6087
|
+
/* @__PURE__ */ jsx38($InvisibleSpan, { contentEditable: false, children: "|" })
|
|
5943
6088
|
] })
|
|
5944
6089
|
);
|
|
5945
6090
|
} else {
|
|
@@ -6153,7 +6298,7 @@ function normalizeNode5(editor, entry) {
|
|
|
6153
6298
|
// src/list-plugin/render-element/ordered-list-item.tsx
|
|
6154
6299
|
import { clsx as clsx6 } from "clsx";
|
|
6155
6300
|
import { useEffect as useEffect5 } from "react";
|
|
6156
|
-
import { ReactEditor as ReactEditor10, useSlateStatic as
|
|
6301
|
+
import { ReactEditor as ReactEditor10, useSlateStatic as useSlateStatic12 } from "slate-react";
|
|
6157
6302
|
|
|
6158
6303
|
// src/list-plugin/render-element/styles.ts
|
|
6159
6304
|
import styled28 from "@emotion/styled";
|
|
@@ -6161,7 +6306,6 @@ var $ListItem = styled28("li")`
|
|
|
6161
6306
|
margin-top: 0.5em;
|
|
6162
6307
|
margin-bottom: 0.5em;
|
|
6163
6308
|
list-style-position: outside;
|
|
6164
|
-
margin-left: calc(2em + var(--list-item-depth) * 2em);
|
|
6165
6309
|
`;
|
|
6166
6310
|
var $UnorderedListItem = styled28($ListItem)`
|
|
6167
6311
|
position: relative;
|
|
@@ -6217,31 +6361,31 @@ var $TaskListItem = styled28($ListItem)`
|
|
|
6217
6361
|
`;
|
|
6218
6362
|
|
|
6219
6363
|
// src/list-plugin/render-element/ordered-list-item.tsx
|
|
6220
|
-
import { jsx as
|
|
6364
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
6221
6365
|
function OrderedListItem({
|
|
6222
6366
|
element,
|
|
6223
6367
|
attributes,
|
|
6224
6368
|
children
|
|
6225
6369
|
}) {
|
|
6226
|
-
const editor =
|
|
6370
|
+
const editor = useSlateStatic12();
|
|
6227
6371
|
useEffect5(() => {
|
|
6228
6372
|
const path = ReactEditor10.findPath(editor, element);
|
|
6229
6373
|
normalizeOrderedFirstAtDepth(editor, [element, path]);
|
|
6230
6374
|
}, []);
|
|
6231
6375
|
const style = {
|
|
6232
|
-
|
|
6376
|
+
marginLeft: `${2 + element.depth * 2}em`,
|
|
6233
6377
|
"--list-item-var": `list-item-depth-${element.depth}`
|
|
6234
6378
|
};
|
|
6235
6379
|
const className = clsx6({ "--first-at-depth": element.__firstAtDepth });
|
|
6236
|
-
return /* @__PURE__ */
|
|
6380
|
+
return /* @__PURE__ */ jsx39($OrderedListItem, { ...attributes, className, style, children });
|
|
6237
6381
|
}
|
|
6238
6382
|
|
|
6239
6383
|
// src/list-plugin/render-element/task-list-item.tsx
|
|
6240
6384
|
import { useCallback as useCallback10 } from "react";
|
|
6241
|
-
import { useSlateStatic as
|
|
6385
|
+
import { useSlateStatic as useSlateStatic13 } from "slate-react";
|
|
6242
6386
|
|
|
6243
6387
|
// src/list-plugin/render-element/list-icons.tsx
|
|
6244
|
-
import { jsx as
|
|
6388
|
+
import { jsx as jsx40, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
6245
6389
|
var UncheckedIcon = (props) => /* @__PURE__ */ jsxs19(
|
|
6246
6390
|
"svg",
|
|
6247
6391
|
{
|
|
@@ -6256,8 +6400,8 @@ var UncheckedIcon = (props) => /* @__PURE__ */ jsxs19(
|
|
|
6256
6400
|
viewBox: "0 0 24 24",
|
|
6257
6401
|
...props,
|
|
6258
6402
|
children: [
|
|
6259
|
-
/* @__PURE__ */
|
|
6260
|
-
/* @__PURE__ */
|
|
6403
|
+
/* @__PURE__ */ jsx40("path", { d: "M0 0h24v24H0z", stroke: "none" }),
|
|
6404
|
+
/* @__PURE__ */ jsx40("rect", { x: 4, y: 4, width: 16, height: 16, rx: 2 })
|
|
6261
6405
|
]
|
|
6262
6406
|
}
|
|
6263
6407
|
);
|
|
@@ -6276,13 +6420,13 @@ var CheckedIcon = (props) => /* @__PURE__ */ jsxs19(
|
|
|
6276
6420
|
viewBox: "0 0 24 24",
|
|
6277
6421
|
...props,
|
|
6278
6422
|
children: [
|
|
6279
|
-
/* @__PURE__ */
|
|
6280
|
-
/* @__PURE__ */
|
|
6281
|
-
/* @__PURE__ */
|
|
6423
|
+
/* @__PURE__ */ jsx40("path", { d: "M0 0h24v24H0z", stroke: "none" }),
|
|
6424
|
+
/* @__PURE__ */ jsx40("path", { d: "m9 11 3 3 8-8", className: "--checkmark" }),
|
|
6425
|
+
/* @__PURE__ */ jsx40("path", { d: "M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9" })
|
|
6282
6426
|
]
|
|
6283
6427
|
}
|
|
6284
6428
|
);
|
|
6285
|
-
var BulletIcon = (props) => /* @__PURE__ */
|
|
6429
|
+
var BulletIcon = (props) => /* @__PURE__ */ jsx40(
|
|
6286
6430
|
"svg",
|
|
6287
6431
|
{
|
|
6288
6432
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6291,44 +6435,44 @@ var BulletIcon = (props) => /* @__PURE__ */ jsx41(
|
|
|
6291
6435
|
width: "1em",
|
|
6292
6436
|
height: "1em",
|
|
6293
6437
|
...props,
|
|
6294
|
-
children: /* @__PURE__ */
|
|
6438
|
+
children: /* @__PURE__ */ jsx40("path", { d: "M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z" })
|
|
6295
6439
|
}
|
|
6296
6440
|
);
|
|
6297
6441
|
|
|
6298
6442
|
// src/list-plugin/render-element/task-list-item.tsx
|
|
6299
|
-
import { jsx as
|
|
6443
|
+
import { jsx as jsx41, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
6300
6444
|
function TaskListItem({
|
|
6301
6445
|
element,
|
|
6302
6446
|
attributes,
|
|
6303
6447
|
children
|
|
6304
6448
|
}) {
|
|
6305
|
-
const editor =
|
|
6449
|
+
const editor = useSlateStatic13();
|
|
6306
6450
|
const toggle = useCallback10(() => {
|
|
6307
6451
|
editor.list.toggleTaskListItem({ at: element });
|
|
6308
6452
|
}, [editor, element]);
|
|
6309
|
-
const
|
|
6310
|
-
return /* @__PURE__ */ jsxs20($TaskListItem, { ...attributes, style, children: [
|
|
6311
|
-
/* @__PURE__ */
|
|
6453
|
+
const marginLeft = `${2 + element.depth * 2}em`;
|
|
6454
|
+
return /* @__PURE__ */ jsxs20($TaskListItem, { ...attributes, style: { marginLeft }, children: [
|
|
6455
|
+
/* @__PURE__ */ jsx41("div", { className: "--list-item-icon", contentEditable: false, children: element.checked ? /* @__PURE__ */ jsx41(CheckedIcon, { onClick: toggle, style: { cursor: "pointer" } }) : /* @__PURE__ */ jsx41(UncheckedIcon, { onClick: toggle, style: { cursor: "pointer" } }) }),
|
|
6312
6456
|
children
|
|
6313
6457
|
] });
|
|
6314
6458
|
}
|
|
6315
6459
|
|
|
6316
6460
|
// src/list-plugin/render-element/unordered-list-item.tsx
|
|
6317
|
-
import { jsx as
|
|
6461
|
+
import { jsx as jsx42, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6318
6462
|
function UnorderedListItem({
|
|
6319
6463
|
element,
|
|
6320
6464
|
attributes,
|
|
6321
6465
|
children
|
|
6322
6466
|
}) {
|
|
6323
|
-
const
|
|
6324
|
-
return /* @__PURE__ */ jsxs21($UnorderedListItem, { ...attributes, style, children: [
|
|
6325
|
-
/* @__PURE__ */
|
|
6467
|
+
const marginLeft = `${2 + element.depth * 2}em`;
|
|
6468
|
+
return /* @__PURE__ */ jsxs21($UnorderedListItem, { ...attributes, style: { marginLeft }, children: [
|
|
6469
|
+
/* @__PURE__ */ jsx42("div", { className: "--list-item-icon", contentEditable: false, children: /* @__PURE__ */ jsx42(BulletIcon, {}) }),
|
|
6326
6470
|
children
|
|
6327
6471
|
] });
|
|
6328
6472
|
}
|
|
6329
6473
|
|
|
6330
6474
|
// src/list-plugin/render-element/index.tsx
|
|
6331
|
-
import { jsx as
|
|
6475
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
6332
6476
|
function renderElement3({
|
|
6333
6477
|
element,
|
|
6334
6478
|
attributes,
|
|
@@ -6336,11 +6480,11 @@ function renderElement3({
|
|
|
6336
6480
|
}) {
|
|
6337
6481
|
switch (element.type) {
|
|
6338
6482
|
case "ordered-list-item":
|
|
6339
|
-
return /* @__PURE__ */
|
|
6483
|
+
return /* @__PURE__ */ jsx43(OrderedListItem, { element, attributes, children });
|
|
6340
6484
|
case "unordered-list-item":
|
|
6341
|
-
return /* @__PURE__ */
|
|
6485
|
+
return /* @__PURE__ */ jsx43(UnorderedListItem, { element, attributes, children });
|
|
6342
6486
|
case "task-list-item":
|
|
6343
|
-
return /* @__PURE__ */
|
|
6487
|
+
return /* @__PURE__ */ jsx43(TaskListItem, { element, attributes, children });
|
|
6344
6488
|
}
|
|
6345
6489
|
}
|
|
6346
6490
|
|
|
@@ -6469,7 +6613,8 @@ function createMarksMethods(editor) {
|
|
|
6469
6613
|
toggleBold: () => toggleMark(editor, "bold"),
|
|
6470
6614
|
toggleItalic: () => toggleMark(editor, "italic"),
|
|
6471
6615
|
toggleUnderline: () => toggleMark(editor, "underline"),
|
|
6472
|
-
toggleStrike: () => toggleMark(editor, "strike")
|
|
6616
|
+
toggleStrike: () => toggleMark(editor, "strike"),
|
|
6617
|
+
toggleHighlight: () => toggleMark(editor, "highlight")
|
|
6473
6618
|
};
|
|
6474
6619
|
}
|
|
6475
6620
|
|
|
@@ -6495,10 +6640,13 @@ var $MarksSpan = styled29("span")`
|
|
|
6495
6640
|
&.--underline.--strike {
|
|
6496
6641
|
text-decoration: underline line-through;
|
|
6497
6642
|
}
|
|
6643
|
+
&.--highlight {
|
|
6644
|
+
background-color: #ffeb3b;
|
|
6645
|
+
}
|
|
6498
6646
|
`;
|
|
6499
6647
|
|
|
6500
6648
|
// src/marks-plugin/index.tsx
|
|
6501
|
-
import { jsx as
|
|
6649
|
+
import { jsx as jsx44 } from "react/jsx-runtime";
|
|
6502
6650
|
var MarksPlugin = createPlugin((editor) => {
|
|
6503
6651
|
editor.marksPlugin = createMarksMethods(editor);
|
|
6504
6652
|
editor.activeMarks = {};
|
|
@@ -6538,14 +6686,15 @@ var MarksPlugin = createPlugin((editor) => {
|
|
|
6538
6686
|
name: "marks",
|
|
6539
6687
|
editableProps: {
|
|
6540
6688
|
renderLeaf: ({ leaf, children }) => {
|
|
6541
|
-
return /* @__PURE__ */
|
|
6689
|
+
return /* @__PURE__ */ jsx44(
|
|
6542
6690
|
$MarksSpan,
|
|
6543
6691
|
{
|
|
6544
6692
|
className: clsx7({
|
|
6545
6693
|
"--bold": leaf.bold,
|
|
6546
6694
|
"--italic": leaf.italic,
|
|
6547
6695
|
"--underline": leaf.underline,
|
|
6548
|
-
"--strike": leaf.strike
|
|
6696
|
+
"--strike": leaf.strike,
|
|
6697
|
+
"--highlight": leaf.highlight
|
|
6549
6698
|
}),
|
|
6550
6699
|
children
|
|
6551
6700
|
}
|
|
@@ -6673,7 +6822,7 @@ function deleteFragmentWithProtectedTypes(editor, protectedTypes) {
|
|
|
6673
6822
|
}
|
|
6674
6823
|
|
|
6675
6824
|
// src/table-plugin/methods/index.ts
|
|
6676
|
-
import { Transforms as
|
|
6825
|
+
import { Transforms as Transforms40 } from "slate";
|
|
6677
6826
|
|
|
6678
6827
|
// src/table-plugin/methods/get-table-info.ts
|
|
6679
6828
|
function getTableInfo(editor, { at = editor.selection } = {}) {
|
|
@@ -6971,6 +7120,7 @@ function setTableColumnAlign(editor, options) {
|
|
|
6971
7120
|
}
|
|
6972
7121
|
|
|
6973
7122
|
// src/table-plugin/methods/tab.ts
|
|
7123
|
+
import { Path as Path15, Transforms as Transforms39 } from "slate";
|
|
6974
7124
|
function tabForward(editor) {
|
|
6975
7125
|
const t2 = getTableInfo(editor);
|
|
6976
7126
|
if (!t2)
|
|
@@ -6984,8 +7134,13 @@ function tabForward(editor) {
|
|
|
6984
7134
|
selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0]);
|
|
6985
7135
|
return true;
|
|
6986
7136
|
}
|
|
6987
|
-
|
|
6988
|
-
|
|
7137
|
+
const nextPath = Path15.next(tablePath);
|
|
7138
|
+
Transforms39.insertNodes(
|
|
7139
|
+
editor,
|
|
7140
|
+
{ type: "paragraph", children: [{ text: "" }] },
|
|
7141
|
+
{ at: nextPath }
|
|
7142
|
+
);
|
|
7143
|
+
selectStartOfElement(editor, nextPath);
|
|
6989
7144
|
return true;
|
|
6990
7145
|
}
|
|
6991
7146
|
function tabBackward(editor) {
|
|
@@ -7002,6 +7157,23 @@ function tabBackward(editor) {
|
|
|
7002
7157
|
return true;
|
|
7003
7158
|
}
|
|
7004
7159
|
}
|
|
7160
|
+
function shiftEnterForward(editor) {
|
|
7161
|
+
const t2 = getTableInfo(editor);
|
|
7162
|
+
if (!t2)
|
|
7163
|
+
return false;
|
|
7164
|
+
const { cellIndex, cellCount, rowIndex, rowCount, tablePath } = t2;
|
|
7165
|
+
if (cellIndex < cellCount - 1) {
|
|
7166
|
+
selectStartOfElement(editor, [...tablePath, rowIndex, cellIndex + 1]);
|
|
7167
|
+
return true;
|
|
7168
|
+
}
|
|
7169
|
+
if (rowIndex < rowCount - 1) {
|
|
7170
|
+
selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0]);
|
|
7171
|
+
return true;
|
|
7172
|
+
}
|
|
7173
|
+
insertRowBelow(editor);
|
|
7174
|
+
selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0]);
|
|
7175
|
+
return true;
|
|
7176
|
+
}
|
|
7005
7177
|
|
|
7006
7178
|
// src/table-plugin/methods/index.ts
|
|
7007
7179
|
function createTableMethods(editor) {
|
|
@@ -7015,6 +7187,7 @@ function createTableMethods(editor) {
|
|
|
7015
7187
|
removeRow: curryOne(removeRow, editor),
|
|
7016
7188
|
tabForward: curryOne(tabForward, editor),
|
|
7017
7189
|
tabBackward: curryOne(tabBackward, editor),
|
|
7190
|
+
shiftEnterForward: curryOne(shiftEnterForward, editor),
|
|
7018
7191
|
selectCell: curryOne(selectCell, editor),
|
|
7019
7192
|
down: curryOne(down, editor),
|
|
7020
7193
|
up: curryOne(up, editor),
|
|
@@ -7026,12 +7199,12 @@ function selectCell(editor, { at = editor.selection } = {}) {
|
|
|
7026
7199
|
if (t2 === void 0)
|
|
7027
7200
|
return false;
|
|
7028
7201
|
const { cellPath } = t2;
|
|
7029
|
-
|
|
7202
|
+
Transforms40.select(editor, cellPath);
|
|
7030
7203
|
return true;
|
|
7031
7204
|
}
|
|
7032
7205
|
|
|
7033
7206
|
// src/table-plugin/normalize/normalize-table.ts
|
|
7034
|
-
import { Transforms as
|
|
7207
|
+
import { Transforms as Transforms41 } from "slate";
|
|
7035
7208
|
function normalizeTableIndexes(editor, entry) {
|
|
7036
7209
|
let isTransformed = false;
|
|
7037
7210
|
const rowElements = entry[0].children;
|
|
@@ -7039,7 +7212,7 @@ function normalizeTableIndexes(editor, entry) {
|
|
|
7039
7212
|
const cellElements = rowElement.children;
|
|
7040
7213
|
cellElements.forEach((cellElement, x) => {
|
|
7041
7214
|
if (cellElement.x !== x || cellElement.y !== y) {
|
|
7042
|
-
|
|
7215
|
+
Transforms41.setNodes(editor, { x, y }, { at: [...entry[1], y, x] });
|
|
7043
7216
|
isTransformed = true;
|
|
7044
7217
|
}
|
|
7045
7218
|
});
|
|
@@ -7048,14 +7221,14 @@ function normalizeTableIndexes(editor, entry) {
|
|
|
7048
7221
|
}
|
|
7049
7222
|
|
|
7050
7223
|
// src/table-plugin/normalize/normalize-table-cell.ts
|
|
7051
|
-
import { Editor as
|
|
7224
|
+
import { Editor as Editor58, Transforms as Transforms42 } from "slate";
|
|
7052
7225
|
function normalizeTableCell(editor, entry) {
|
|
7053
7226
|
const [node, path] = entry;
|
|
7054
7227
|
if (node.children.length === 1 && node.children[0].type === "table-content") {
|
|
7055
7228
|
return false;
|
|
7056
7229
|
}
|
|
7057
|
-
|
|
7058
|
-
|
|
7230
|
+
Editor58.withoutNormalizing(editor, () => {
|
|
7231
|
+
Transforms42.insertNodes(
|
|
7059
7232
|
editor,
|
|
7060
7233
|
{
|
|
7061
7234
|
type: "table-content",
|
|
@@ -7064,9 +7237,9 @@ function normalizeTableCell(editor, entry) {
|
|
|
7064
7237
|
{ at: [...entry[1], 0] }
|
|
7065
7238
|
);
|
|
7066
7239
|
for (let i = node.children.length; i >= 0; i--) {
|
|
7067
|
-
|
|
7240
|
+
Transforms42.mergeNodes(editor, { at: [...path, i] });
|
|
7068
7241
|
}
|
|
7069
|
-
|
|
7242
|
+
Transforms42.delete(editor, {
|
|
7070
7243
|
at: { path: [...path, 0, 0], offset: 0 },
|
|
7071
7244
|
unit: "character"
|
|
7072
7245
|
});
|
|
@@ -7076,7 +7249,7 @@ function normalizeTableCell(editor, entry) {
|
|
|
7076
7249
|
|
|
7077
7250
|
// src/table-plugin/render-element/table.tsx
|
|
7078
7251
|
import { useEffect as useEffect6 } from "react";
|
|
7079
|
-
import { ReactEditor as ReactEditor12, useSelected as useSelected7, useSlateStatic as
|
|
7252
|
+
import { ReactEditor as ReactEditor12, useSelected as useSelected7, useSlateStatic as useSlateStatic14 } from "slate-react";
|
|
7080
7253
|
|
|
7081
7254
|
// src/table-plugin/render-element/styles/index.ts
|
|
7082
7255
|
import styled31 from "@emotion/styled";
|
|
@@ -7274,19 +7447,19 @@ var TableContext = createContext2({
|
|
|
7274
7447
|
});
|
|
7275
7448
|
|
|
7276
7449
|
// src/table-plugin/render-element/table.tsx
|
|
7277
|
-
import { jsx as
|
|
7450
|
+
import { jsx as jsx45 } from "react/jsx-runtime";
|
|
7278
7451
|
function Table({
|
|
7279
7452
|
element,
|
|
7280
7453
|
attributes,
|
|
7281
7454
|
children
|
|
7282
7455
|
}) {
|
|
7283
|
-
const editor =
|
|
7456
|
+
const editor = useSlateStatic14();
|
|
7284
7457
|
const isSelected = useSelected7();
|
|
7285
7458
|
useEffect6(() => {
|
|
7286
7459
|
const path = ReactEditor12.findPath(editor, element);
|
|
7287
7460
|
normalizeTableIndexes(editor, [element, path]);
|
|
7288
7461
|
}, []);
|
|
7289
|
-
return /* @__PURE__ */
|
|
7462
|
+
return /* @__PURE__ */ jsx45(TableContext.Provider, { value: { isSelected }, children: /* @__PURE__ */ jsx45($Table, { ...attributes, columns: element.columns, children: /* @__PURE__ */ jsx45("tbody", { children }) }) });
|
|
7290
7463
|
}
|
|
7291
7464
|
|
|
7292
7465
|
// src/table-plugin/render-element/table-cell/index.tsx
|
|
@@ -7294,12 +7467,12 @@ import { useContext as useContext2 } from "react";
|
|
|
7294
7467
|
import { useSelected as useSelected8 } from "slate-react";
|
|
7295
7468
|
|
|
7296
7469
|
// src/table-plugin/render-element/table-cell/column-menu/index.tsx
|
|
7297
|
-
import { useCallback as useCallback11, useRef as
|
|
7298
|
-
import { useSlateStatic as
|
|
7470
|
+
import { useCallback as useCallback11, useRef as useRef5, useState as useState6 } from "react";
|
|
7471
|
+
import { useSlateStatic as useSlateStatic15 } from "slate-react";
|
|
7299
7472
|
|
|
7300
7473
|
// src/table-plugin/icons.tsx
|
|
7301
|
-
import { jsx as
|
|
7302
|
-
var PlusIcon = (props) => /* @__PURE__ */
|
|
7474
|
+
import { jsx as jsx46 } from "react/jsx-runtime";
|
|
7475
|
+
var PlusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
7303
7476
|
"svg",
|
|
7304
7477
|
{
|
|
7305
7478
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7308,7 +7481,7 @@ var PlusIcon = (props) => /* @__PURE__ */ jsx47(
|
|
|
7308
7481
|
width: "1em",
|
|
7309
7482
|
height: "1em",
|
|
7310
7483
|
...props,
|
|
7311
|
-
children: /* @__PURE__ */
|
|
7484
|
+
children: /* @__PURE__ */ jsx46(
|
|
7312
7485
|
"path",
|
|
7313
7486
|
{
|
|
7314
7487
|
fillRule: "evenodd",
|
|
@@ -7318,7 +7491,7 @@ var PlusIcon = (props) => /* @__PURE__ */ jsx47(
|
|
|
7318
7491
|
)
|
|
7319
7492
|
}
|
|
7320
7493
|
);
|
|
7321
|
-
var MinusIcon = (props) => /* @__PURE__ */
|
|
7494
|
+
var MinusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
7322
7495
|
"svg",
|
|
7323
7496
|
{
|
|
7324
7497
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7327,7 +7500,7 @@ var MinusIcon = (props) => /* @__PURE__ */ jsx47(
|
|
|
7327
7500
|
width: "1em",
|
|
7328
7501
|
height: "1em",
|
|
7329
7502
|
...props,
|
|
7330
|
-
children: /* @__PURE__ */
|
|
7503
|
+
children: /* @__PURE__ */ jsx46(
|
|
7331
7504
|
"path",
|
|
7332
7505
|
{
|
|
7333
7506
|
fillRule: "evenodd",
|
|
@@ -7337,18 +7510,18 @@ var MinusIcon = (props) => /* @__PURE__ */ jsx47(
|
|
|
7337
7510
|
)
|
|
7338
7511
|
}
|
|
7339
7512
|
);
|
|
7340
|
-
var BarsIcon = () => /* @__PURE__ */
|
|
7341
|
-
var AlignLeft = () => /* @__PURE__ */
|
|
7342
|
-
var AlignCenter = () => /* @__PURE__ */
|
|
7343
|
-
var AlignRight = () => /* @__PURE__ */
|
|
7513
|
+
var BarsIcon = () => /* @__PURE__ */ jsx46(TablerIcon, { children: /* @__PURE__ */ jsx46("path", { d: "M4 6h16M4 12h16M4 18h16" }) });
|
|
7514
|
+
var AlignLeft = () => /* @__PURE__ */ jsx46(TablerIcon, { children: /* @__PURE__ */ jsx46("path", { d: "M4 6h16M4 12h10M4 18h14" }) });
|
|
7515
|
+
var AlignCenter = () => /* @__PURE__ */ jsx46(TablerIcon, { children: /* @__PURE__ */ jsx46("path", { d: "M4 6h16M8 12h8M6 18h12" }) });
|
|
7516
|
+
var AlignRight = () => /* @__PURE__ */ jsx46(TablerIcon, { children: /* @__PURE__ */ jsx46("path", { d: "M4 6h16M10 12h10M6 18h14" }) });
|
|
7344
7517
|
|
|
7345
7518
|
// src/table-plugin/render-element/table-cell/column-menu/index.tsx
|
|
7346
|
-
import { Fragment as Fragment4, jsx as
|
|
7519
|
+
import { Fragment as Fragment4, jsx as jsx47, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
7347
7520
|
function ColumnMenu({ cellElement }) {
|
|
7348
|
-
const editor =
|
|
7521
|
+
const editor = useSlateStatic15();
|
|
7349
7522
|
const menu = useLayer("column-menu");
|
|
7350
|
-
const buttonRef =
|
|
7351
|
-
const [hover, setHover] =
|
|
7523
|
+
const buttonRef = useRef5(null);
|
|
7524
|
+
const [hover, setHover] = useState6(false);
|
|
7352
7525
|
const onMouseEnter = useCallback11(() => {
|
|
7353
7526
|
setHover(true);
|
|
7354
7527
|
}, []);
|
|
@@ -7384,7 +7557,7 @@ function ColumnMenu({ cellElement }) {
|
|
|
7384
7557
|
}
|
|
7385
7558
|
}
|
|
7386
7559
|
];
|
|
7387
|
-
menu.open(() => /* @__PURE__ */
|
|
7560
|
+
menu.open(() => /* @__PURE__ */ jsx47(Menu, { dest, items, close: menu.close }));
|
|
7388
7561
|
}, []);
|
|
7389
7562
|
return /* @__PURE__ */ jsxs22(
|
|
7390
7563
|
$ColumnMenu,
|
|
@@ -7395,9 +7568,9 @@ function ColumnMenu({ cellElement }) {
|
|
|
7395
7568
|
onMouseEnter,
|
|
7396
7569
|
onMouseLeave,
|
|
7397
7570
|
children: [
|
|
7398
|
-
/* @__PURE__ */
|
|
7571
|
+
/* @__PURE__ */ jsx47($ColumnMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx47(BarsIcon, {}) }),
|
|
7399
7572
|
hover ? /* @__PURE__ */ jsxs22(Fragment4, { children: [
|
|
7400
|
-
/* @__PURE__ */
|
|
7573
|
+
/* @__PURE__ */ jsx47(
|
|
7401
7574
|
$RemoveMenuButton,
|
|
7402
7575
|
{
|
|
7403
7576
|
style: {
|
|
@@ -7406,23 +7579,23 @@ function ColumnMenu({ cellElement }) {
|
|
|
7406
7579
|
marginLeft: "-0.5em"
|
|
7407
7580
|
},
|
|
7408
7581
|
onMouseDown: () => editor.tablePlugin.removeColumn({ at: cellElement }),
|
|
7409
|
-
children: /* @__PURE__ */
|
|
7582
|
+
children: /* @__PURE__ */ jsx47(MinusIcon, {})
|
|
7410
7583
|
}
|
|
7411
7584
|
),
|
|
7412
|
-
/* @__PURE__ */
|
|
7585
|
+
/* @__PURE__ */ jsx47(
|
|
7413
7586
|
$AddMenuButton,
|
|
7414
7587
|
{
|
|
7415
7588
|
style: { left: "-0.5em", top: 0 },
|
|
7416
7589
|
onMouseDown: () => editor.tablePlugin.insertColumn({ at: cellElement }),
|
|
7417
|
-
children: /* @__PURE__ */
|
|
7590
|
+
children: /* @__PURE__ */ jsx47(PlusIcon, {})
|
|
7418
7591
|
}
|
|
7419
7592
|
),
|
|
7420
|
-
/* @__PURE__ */
|
|
7593
|
+
/* @__PURE__ */ jsx47(
|
|
7421
7594
|
$AddMenuButton,
|
|
7422
7595
|
{
|
|
7423
7596
|
style: { right: "-0.5em", top: 0 },
|
|
7424
7597
|
onMouseDown: () => editor.tablePlugin.insertColumn({ at: cellElement, offset: 1 }),
|
|
7425
|
-
children: /* @__PURE__ */
|
|
7598
|
+
children: /* @__PURE__ */ jsx47(PlusIcon, {})
|
|
7426
7599
|
}
|
|
7427
7600
|
)
|
|
7428
7601
|
] }) : null
|
|
@@ -7432,12 +7605,12 @@ function ColumnMenu({ cellElement }) {
|
|
|
7432
7605
|
}
|
|
7433
7606
|
|
|
7434
7607
|
// src/table-plugin/render-element/table-cell/row-menu/index.tsx
|
|
7435
|
-
import { useState as
|
|
7436
|
-
import { useSlateStatic as
|
|
7437
|
-
import { Fragment as Fragment5, jsx as
|
|
7608
|
+
import { useState as useState7 } from "react";
|
|
7609
|
+
import { useSlateStatic as useSlateStatic16 } from "slate-react";
|
|
7610
|
+
import { Fragment as Fragment5, jsx as jsx48, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7438
7611
|
function RowMenu({ cellElement }) {
|
|
7439
|
-
const editor =
|
|
7440
|
-
const [hover, setHover] =
|
|
7612
|
+
const editor = useSlateStatic16();
|
|
7613
|
+
const [hover, setHover] = useState7(false);
|
|
7441
7614
|
return /* @__PURE__ */ jsxs23(
|
|
7442
7615
|
$RowMenu,
|
|
7443
7616
|
{
|
|
@@ -7445,9 +7618,9 @@ function RowMenu({ cellElement }) {
|
|
|
7445
7618
|
onMouseEnter: () => setHover(true),
|
|
7446
7619
|
onMouseLeave: () => setHover(false),
|
|
7447
7620
|
children: [
|
|
7448
|
-
/* @__PURE__ */
|
|
7621
|
+
/* @__PURE__ */ jsx48($RowMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx48(BarsIcon, {}) }),
|
|
7449
7622
|
hover ? /* @__PURE__ */ jsxs23(Fragment5, { children: [
|
|
7450
|
-
/* @__PURE__ */
|
|
7623
|
+
/* @__PURE__ */ jsx48(
|
|
7451
7624
|
$RemoveMenuButton,
|
|
7452
7625
|
{
|
|
7453
7626
|
style: {
|
|
@@ -7456,23 +7629,23 @@ function RowMenu({ cellElement }) {
|
|
|
7456
7629
|
marginTop: "-0.5em"
|
|
7457
7630
|
},
|
|
7458
7631
|
onMouseDown: () => editor.tablePlugin.removeRow({ at: cellElement }),
|
|
7459
|
-
children: /* @__PURE__ */
|
|
7632
|
+
children: /* @__PURE__ */ jsx48(MinusIcon, {})
|
|
7460
7633
|
}
|
|
7461
7634
|
),
|
|
7462
|
-
/* @__PURE__ */
|
|
7635
|
+
/* @__PURE__ */ jsx48(
|
|
7463
7636
|
$AddMenuButton,
|
|
7464
7637
|
{
|
|
7465
7638
|
style: { top: "-0.5em", left: "0.5em" },
|
|
7466
7639
|
onMouseDown: () => editor.tablePlugin.insertRow({ at: cellElement }),
|
|
7467
|
-
children: /* @__PURE__ */
|
|
7640
|
+
children: /* @__PURE__ */ jsx48(PlusIcon, {})
|
|
7468
7641
|
}
|
|
7469
7642
|
),
|
|
7470
|
-
/* @__PURE__ */
|
|
7643
|
+
/* @__PURE__ */ jsx48(
|
|
7471
7644
|
$AddMenuButton,
|
|
7472
7645
|
{
|
|
7473
7646
|
style: { bottom: "-0.5em", left: "0.5em" },
|
|
7474
7647
|
onMouseDown: () => editor.tablePlugin.insertRow({ at: cellElement, offset: 1 }),
|
|
7475
|
-
children: /* @__PURE__ */
|
|
7648
|
+
children: /* @__PURE__ */ jsx48(PlusIcon, {})
|
|
7476
7649
|
}
|
|
7477
7650
|
)
|
|
7478
7651
|
] }) : null
|
|
@@ -7527,13 +7700,13 @@ var $TableMenuTile = styled32("div")`
|
|
|
7527
7700
|
`;
|
|
7528
7701
|
|
|
7529
7702
|
// src/table-plugin/render-element/table-cell/table-menu/index.tsx
|
|
7530
|
-
import { jsx as
|
|
7703
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
7531
7704
|
function TableMenu() {
|
|
7532
|
-
return /* @__PURE__ */
|
|
7705
|
+
return /* @__PURE__ */ jsx49($TableMenu, { contentEditable: false, children: /* @__PURE__ */ jsx49($TableMenuTile, { className: "--table-menu-tile" }) });
|
|
7533
7706
|
}
|
|
7534
7707
|
|
|
7535
7708
|
// src/table-plugin/render-element/table-cell/index.tsx
|
|
7536
|
-
import { jsx as
|
|
7709
|
+
import { jsx as jsx50, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
7537
7710
|
function TableCell({
|
|
7538
7711
|
element,
|
|
7539
7712
|
attributes,
|
|
@@ -7553,34 +7726,34 @@ function TableCell({
|
|
|
7553
7726
|
"data-y": element.y,
|
|
7554
7727
|
children: [
|
|
7555
7728
|
children,
|
|
7556
|
-
showTableMenu ? /* @__PURE__ */
|
|
7557
|
-
showRowMenu ? /* @__PURE__ */
|
|
7558
|
-
showColumnMenu ? /* @__PURE__ */
|
|
7729
|
+
showTableMenu ? /* @__PURE__ */ jsx50(TableMenu, {}) : null,
|
|
7730
|
+
showRowMenu ? /* @__PURE__ */ jsx50(RowMenu, { cellElement: element }) : null,
|
|
7731
|
+
showColumnMenu ? /* @__PURE__ */ jsx50(ColumnMenu, { cellElement: element }) : null
|
|
7559
7732
|
]
|
|
7560
7733
|
}
|
|
7561
7734
|
);
|
|
7562
7735
|
}
|
|
7563
7736
|
|
|
7564
7737
|
// src/table-plugin/render-element/table-content.tsx
|
|
7565
|
-
import { jsx as
|
|
7738
|
+
import { jsx as jsx51 } from "react/jsx-runtime";
|
|
7566
7739
|
function TableContent({
|
|
7567
7740
|
attributes,
|
|
7568
7741
|
children
|
|
7569
7742
|
}) {
|
|
7570
|
-
return /* @__PURE__ */
|
|
7743
|
+
return /* @__PURE__ */ jsx51($TableContent, { ...attributes, children });
|
|
7571
7744
|
}
|
|
7572
7745
|
|
|
7573
7746
|
// src/table-plugin/render-element/table-row.tsx
|
|
7574
|
-
import { jsx as
|
|
7747
|
+
import { jsx as jsx52 } from "react/jsx-runtime";
|
|
7575
7748
|
function TableRow({
|
|
7576
7749
|
attributes,
|
|
7577
7750
|
children
|
|
7578
7751
|
}) {
|
|
7579
|
-
return /* @__PURE__ */
|
|
7752
|
+
return /* @__PURE__ */ jsx52($TableRow, { ...attributes, children });
|
|
7580
7753
|
}
|
|
7581
7754
|
|
|
7582
7755
|
// src/table-plugin/render-element/index.tsx
|
|
7583
|
-
import { jsx as
|
|
7756
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
7584
7757
|
function renderElement4({
|
|
7585
7758
|
element,
|
|
7586
7759
|
attributes,
|
|
@@ -7588,13 +7761,13 @@ function renderElement4({
|
|
|
7588
7761
|
}) {
|
|
7589
7762
|
switch (element.type) {
|
|
7590
7763
|
case "table":
|
|
7591
|
-
return /* @__PURE__ */
|
|
7764
|
+
return /* @__PURE__ */ jsx53(Table, { element, attributes, children });
|
|
7592
7765
|
case "table-row":
|
|
7593
|
-
return /* @__PURE__ */
|
|
7766
|
+
return /* @__PURE__ */ jsx53(TableRow, { element, attributes, children });
|
|
7594
7767
|
case "table-cell":
|
|
7595
|
-
return /* @__PURE__ */
|
|
7768
|
+
return /* @__PURE__ */ jsx53(TableCell, { element, attributes, children });
|
|
7596
7769
|
case "table-content":
|
|
7597
|
-
return /* @__PURE__ */
|
|
7770
|
+
return /* @__PURE__ */ jsx53(TableContent, { element, attributes, children });
|
|
7598
7771
|
}
|
|
7599
7772
|
}
|
|
7600
7773
|
|
|
@@ -7615,7 +7788,11 @@ var TablePlugin = createPlugin(
|
|
|
7615
7788
|
deleteFragment: () => deleteFragmentWithProtectedTypes(editor, ["table-cell"]),
|
|
7616
7789
|
insertBreak: () => {
|
|
7617
7790
|
const entry = findElementUp(editor, "table-cell");
|
|
7618
|
-
|
|
7791
|
+
if (entry) {
|
|
7792
|
+
editor.insertText("\n");
|
|
7793
|
+
return true;
|
|
7794
|
+
}
|
|
7795
|
+
return false;
|
|
7619
7796
|
},
|
|
7620
7797
|
isMaster(element) {
|
|
7621
7798
|
if (element.type === "table")
|
|
@@ -7649,6 +7826,7 @@ var TablePlugin = createPlugin(
|
|
|
7649
7826
|
*/
|
|
7650
7827
|
tab: editor.tablePlugin.tabForward,
|
|
7651
7828
|
"shift+tab": editor.tablePlugin.tabBackward,
|
|
7829
|
+
"shift+enter": editor.tablePlugin.shiftEnterForward,
|
|
7652
7830
|
down: editor.tablePlugin.down,
|
|
7653
7831
|
up: editor.tablePlugin.up,
|
|
7654
7832
|
/**
|
|
@@ -7733,7 +7911,7 @@ var globalStyles = css2`
|
|
|
7733
7911
|
`;
|
|
7734
7912
|
|
|
7735
7913
|
// src/theme-plugin/index.tsx
|
|
7736
|
-
import { Fragment as Fragment6, jsx as
|
|
7914
|
+
import { Fragment as Fragment6, jsx as jsx54, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
7737
7915
|
var ThemePlugin = createPlugin((editor) => {
|
|
7738
7916
|
editor.theme = true;
|
|
7739
7917
|
return {
|
|
@@ -7741,8 +7919,8 @@ var ThemePlugin = createPlugin((editor) => {
|
|
|
7741
7919
|
editor: {},
|
|
7742
7920
|
renderEditable: ({ attributes, Editable: Editable3 }) => {
|
|
7743
7921
|
return /* @__PURE__ */ jsxs25(Fragment6, { children: [
|
|
7744
|
-
/* @__PURE__ */
|
|
7745
|
-
/* @__PURE__ */
|
|
7922
|
+
/* @__PURE__ */ jsx54(Global, { styles: globalStyles }),
|
|
7923
|
+
/* @__PURE__ */ jsx54(Editable3, { ...attributes })
|
|
7746
7924
|
] });
|
|
7747
7925
|
},
|
|
7748
7926
|
editableProps: {}
|
|
@@ -7751,14 +7929,14 @@ var ThemePlugin = createPlugin((editor) => {
|
|
|
7751
7929
|
|
|
7752
7930
|
// src/toolbar-plugin/render-editable/index.tsx
|
|
7753
7931
|
import { clsx as clsx10 } from "clsx";
|
|
7754
|
-
import { useCallback as useCallback15, useRef as
|
|
7755
|
-
import { Editor as
|
|
7756
|
-
import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as
|
|
7932
|
+
import { useCallback as useCallback15, useRef as useRef11 } from "react";
|
|
7933
|
+
import { Editor as Editor62, Transforms as Transforms44 } from "slate";
|
|
7934
|
+
import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as useSlateStatic22 } from "slate-react";
|
|
7757
7935
|
|
|
7758
7936
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
7759
7937
|
import { clsx as clsx8 } from "clsx";
|
|
7760
|
-
import { useCallback as useCallback12, useRef as
|
|
7761
|
-
import { ReactEditor as ReactEditor13, useSlateStatic as
|
|
7938
|
+
import { useCallback as useCallback12, useRef as useRef6, useState as useState8 } from "react";
|
|
7939
|
+
import { ReactEditor as ReactEditor13, useSlateStatic as useSlateStatic17 } from "slate-react";
|
|
7762
7940
|
|
|
7763
7941
|
// src/toolbar-plugin/styles/table-styles.ts
|
|
7764
7942
|
import styled33 from "@emotion/styled";
|
|
@@ -7784,7 +7962,7 @@ var $TableDialogGridCell = styled33("div")`
|
|
|
7784
7962
|
`;
|
|
7785
7963
|
|
|
7786
7964
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
7787
|
-
import { Fragment as Fragment7, jsx as
|
|
7965
|
+
import { Fragment as Fragment7, jsx as jsx55, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
7788
7966
|
function createRange2(size) {
|
|
7789
7967
|
return [...Array(size).keys()];
|
|
7790
7968
|
}
|
|
@@ -7792,9 +7970,9 @@ function TableDialog({
|
|
|
7792
7970
|
dest,
|
|
7793
7971
|
close
|
|
7794
7972
|
}) {
|
|
7795
|
-
const [hover, setHover] =
|
|
7796
|
-
const editor =
|
|
7797
|
-
const ref =
|
|
7973
|
+
const [hover, setHover] = useState8({ x: 0, y: 0 });
|
|
7974
|
+
const editor = useSlateStatic17();
|
|
7975
|
+
const ref = useRef6(null);
|
|
7798
7976
|
const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
|
|
7799
7977
|
return { left: dest2.left - 8, top: dest2.top + dest2.height };
|
|
7800
7978
|
});
|
|
@@ -7815,11 +7993,11 @@ function TableDialog({
|
|
|
7815
7993
|
[editor]
|
|
7816
7994
|
);
|
|
7817
7995
|
return /* @__PURE__ */ jsxs26(Fragment7, { children: [
|
|
7818
|
-
/* @__PURE__ */
|
|
7819
|
-
/* @__PURE__ */
|
|
7996
|
+
/* @__PURE__ */ jsx55(CloseMask, { close }),
|
|
7997
|
+
/* @__PURE__ */ jsx55($TableDialog, { ref, style, children: /* @__PURE__ */ jsx55($TableDialogGrid, { onMouseLeave: () => hoverCell(0, 0), children: rows.map((y) => {
|
|
7820
7998
|
return cols.map((x) => {
|
|
7821
7999
|
const selected = x <= hover.x && y <= hover.y;
|
|
7822
|
-
return /* @__PURE__ */
|
|
8000
|
+
return /* @__PURE__ */ jsx55(
|
|
7823
8001
|
$TableDialogGridCell,
|
|
7824
8002
|
{
|
|
7825
8003
|
className: clsx8({ "--selected": selected }),
|
|
@@ -7835,60 +8013,66 @@ function TableDialog({
|
|
|
7835
8013
|
|
|
7836
8014
|
// src/toolbar-plugin/components/toolbar/toolbar.tsx
|
|
7837
8015
|
import throttle2 from "lodash.throttle";
|
|
7838
|
-
import { useEffect as useEffect8, useRef as
|
|
7839
|
-
import { useSlateStatic as
|
|
8016
|
+
import { useEffect as useEffect8, useRef as useRef10, useState as useState11 } from "react";
|
|
8017
|
+
import { useSlateStatic as useSlateStatic21 } from "slate-react";
|
|
7840
8018
|
|
|
7841
8019
|
// src/toolbar-plugin/icons.tsx
|
|
7842
|
-
import { jsx as
|
|
7843
|
-
var H = () => /* @__PURE__ */
|
|
7844
|
-
var More = () => /* @__PURE__ */
|
|
7845
|
-
var LinkPlus = () => /* @__PURE__ */
|
|
7846
|
-
var H1 = () => /* @__PURE__ */
|
|
7847
|
-
var H2 = () => /* @__PURE__ */
|
|
7848
|
-
var H3 = () => /* @__PURE__ */
|
|
7849
|
-
var Normal = () => /* @__PURE__ */
|
|
7850
|
-
var Bold = () => /* @__PURE__ */
|
|
7851
|
-
var Italic = () => /* @__PURE__ */
|
|
8020
|
+
import { jsx as jsx56, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
8021
|
+
var H = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4" }) });
|
|
8022
|
+
var More = () => /* @__PURE__ */ jsx56(TablerIcon, { className: "--more-icon", width: "0.5em", viewBox: "0 0 12 24", children: /* @__PURE__ */ jsx56("path", { d: "m2 12 4 4 4-4" }) });
|
|
8023
|
+
var LinkPlus = () => /* @__PURE__ */ jsx56(TablerIcon, { width: "0.5em", viewBox: "6 0 12 24", children: /* @__PURE__ */ jsx56("path", { d: "M9 12h6M12 9v6" }) });
|
|
8024
|
+
var H1 = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
|
|
8025
|
+
var H2 = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
|
|
8026
|
+
var H3 = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
|
|
8027
|
+
var Normal = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z" }) });
|
|
8028
|
+
var Bold = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7" }) });
|
|
8029
|
+
var Italic = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M11 5h6M7 19h6M14 5l-4 14" }) });
|
|
7852
8030
|
var Link = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7853
|
-
/* @__PURE__ */
|
|
7854
|
-
/* @__PURE__ */
|
|
8031
|
+
/* @__PURE__ */ jsx56("path", { d: "M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5" }),
|
|
8032
|
+
/* @__PURE__ */ jsx56("path", { d: "M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5" })
|
|
7855
8033
|
] });
|
|
7856
|
-
var Quote = () => /* @__PURE__ */
|
|
8034
|
+
var Quote = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5" }) });
|
|
7857
8035
|
var DoubleQuote = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7858
|
-
/* @__PURE__ */
|
|
7859
|
-
/* @__PURE__ */
|
|
8036
|
+
/* @__PURE__ */ jsx56("path", { d: "M10 9l4 3-4 3" }),
|
|
8037
|
+
/* @__PURE__ */ jsx56("path", { d: "M16 9l4 3-4 3" })
|
|
7860
8038
|
] });
|
|
7861
|
-
var BulletList = () => /* @__PURE__ */
|
|
8039
|
+
var BulletList = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01" }) });
|
|
7862
8040
|
var Table2 = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7863
|
-
/* @__PURE__ */
|
|
7864
|
-
/* @__PURE__ */
|
|
8041
|
+
/* @__PURE__ */ jsx56("rect", { x: 4, y: 4, width: 16, height: 16, rx: 2 }),
|
|
8042
|
+
/* @__PURE__ */ jsx56("path", { d: "M4 10h16M10 4v16" })
|
|
7865
8043
|
] });
|
|
7866
|
-
var Code = () => /* @__PURE__ */
|
|
7867
|
-
var CodeBlock2 = () => /* @__PURE__ */
|
|
8044
|
+
var Code = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16" }) });
|
|
8045
|
+
var CodeBlock2 = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M9 8L5 12L9 16M15 8L19 12L15 16" }) });
|
|
7868
8046
|
var Image = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7869
|
-
/* @__PURE__ */
|
|
7870
|
-
/* @__PURE__ */
|
|
7871
|
-
/* @__PURE__ */
|
|
7872
|
-
/* @__PURE__ */
|
|
8047
|
+
/* @__PURE__ */ jsx56("path", { d: "M15 8h.01" }),
|
|
8048
|
+
/* @__PURE__ */ jsx56("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3 }),
|
|
8049
|
+
/* @__PURE__ */ jsx56("path", { d: "m4 15 4-4a3 5 0 0 1 3 0l5 5" }),
|
|
8050
|
+
/* @__PURE__ */ jsx56("path", { d: "m14 14 1-1a3 5 0 0 1 3 0l2 2" })
|
|
7873
8051
|
] });
|
|
7874
|
-
var Plus = () => /* @__PURE__ */
|
|
7875
|
-
var Strikethrough = () => /* @__PURE__ */
|
|
7876
|
-
var Underline = () => /* @__PURE__ */
|
|
8052
|
+
var Plus = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M12 5v14M5 12h14" }) });
|
|
8053
|
+
var Strikethrough = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5" }) });
|
|
8054
|
+
var Underline = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M7 5v5a5 5 0 0 0 10 0V5M5 19h14" }) });
|
|
7877
8055
|
var ListCheck = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7878
|
-
/* @__PURE__ */
|
|
7879
|
-
/* @__PURE__ */
|
|
8056
|
+
/* @__PURE__ */ jsx56("path", { d: "m9 11 3 3 8-8" }),
|
|
8057
|
+
/* @__PURE__ */ jsx56("path", { d: "M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9" })
|
|
7880
8058
|
] });
|
|
7881
|
-
var ListNumbers = () => /* @__PURE__ */
|
|
7882
|
-
var IncreaseDepth = () => /* @__PURE__ */
|
|
7883
|
-
var DecreaseDepth = () => /* @__PURE__ */
|
|
8059
|
+
var ListNumbers = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6" }) });
|
|
8060
|
+
var IncreaseDepth = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3" }) });
|
|
8061
|
+
var DecreaseDepth = () => /* @__PURE__ */ jsx56(TablerIcon, { children: /* @__PURE__ */ jsx56("path", { d: "M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3" }) });
|
|
7884
8062
|
var Markdown = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7885
|
-
/* @__PURE__ */
|
|
7886
|
-
/* @__PURE__ */
|
|
8063
|
+
/* @__PURE__ */ jsx56("path", { d: "M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z" }),
|
|
8064
|
+
/* @__PURE__ */ jsx56("path", { d: "M7 15V9l2 2 2-2v6M14 9v6h4M14 13h2" })
|
|
7887
8065
|
] });
|
|
7888
8066
|
var VisualEditor = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
7889
|
-
/* @__PURE__ */
|
|
7890
|
-
/* @__PURE__ */
|
|
7891
|
-
/* @__PURE__ */
|
|
8067
|
+
/* @__PURE__ */ jsx56("path", { d: "M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z" }),
|
|
8068
|
+
/* @__PURE__ */ jsx56("path", { d: "M8 8h8M8 12h8M8 16h5" }),
|
|
8069
|
+
/* @__PURE__ */ jsx56("path", { d: "M16 16h1" })
|
|
8070
|
+
] });
|
|
8071
|
+
var Highlight = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
8072
|
+
/* @__PURE__ */ jsx56("path", { d: "M3 19h4L17.5 8.5a2.828 2.828 0 1 0-4-4L3 15v4" }),
|
|
8073
|
+
/* @__PURE__ */ jsx56("path", { d: "m12.5 5.5 4 4" }),
|
|
8074
|
+
/* @__PURE__ */ jsx56("path", { d: "M3 21h7" }),
|
|
8075
|
+
/* @__PURE__ */ jsx56("path", { d: "M18 19h3M19.5 17.5v3" })
|
|
7892
8076
|
] });
|
|
7893
8077
|
|
|
7894
8078
|
// src/toolbar-plugin/items/block-items.tsx
|
|
@@ -7897,15 +8081,17 @@ var listDepthItems = [
|
|
|
7897
8081
|
icon: IncreaseDepth,
|
|
7898
8082
|
title: t("increaseDepth"),
|
|
7899
8083
|
hotkey: "tab",
|
|
7900
|
-
action: (editor) => editor.list
|
|
7901
|
-
active: (editor) => editor.list
|
|
8084
|
+
action: (editor) => editor.list?.increaseDepth(),
|
|
8085
|
+
active: (editor) => editor.list?.canIncreaseDepth() ?? false,
|
|
8086
|
+
show: (editor) => !!editor.list
|
|
7902
8087
|
},
|
|
7903
8088
|
{
|
|
7904
8089
|
icon: DecreaseDepth,
|
|
7905
8090
|
title: t("decreaseDepth"),
|
|
7906
8091
|
hotkey: "shift+tab",
|
|
7907
|
-
action: (editor) => editor.list
|
|
7908
|
-
active: (editor) => editor.list
|
|
8092
|
+
action: (editor) => editor.list?.decreaseDepth(),
|
|
8093
|
+
active: (editor) => editor.list?.canDecreaseDepth() ?? false,
|
|
8094
|
+
show: (editor) => !!editor.list
|
|
7909
8095
|
}
|
|
7910
8096
|
];
|
|
7911
8097
|
var blockItems = [
|
|
@@ -7950,8 +8136,8 @@ var compactBlockItems = [
|
|
|
7950
8136
|
];
|
|
7951
8137
|
|
|
7952
8138
|
// src/toolbar-plugin/components/dialog/image-url-dialog.tsx
|
|
7953
|
-
import { useState as
|
|
7954
|
-
import { useSlateStatic as
|
|
8139
|
+
import { useState as useState9, useRef as useRef7, useEffect as useEffect7 } from "react";
|
|
8140
|
+
import { useSlateStatic as useSlateStatic18 } from "slate-react";
|
|
7955
8141
|
|
|
7956
8142
|
// src/toolbar-plugin/styles/file-dialog-styles.ts
|
|
7957
8143
|
import styled34 from "@emotion/styled";
|
|
@@ -7961,22 +8147,22 @@ var $FileDialog = styled34($Panel)`
|
|
|
7961
8147
|
`;
|
|
7962
8148
|
|
|
7963
8149
|
// src/toolbar-plugin/components/dialog/image-url-dialog.tsx
|
|
7964
|
-
import { Fragment as Fragment8, jsx as
|
|
8150
|
+
import { Fragment as Fragment8, jsx as jsx57, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
7965
8151
|
function ImageUrlDialog({
|
|
7966
8152
|
dest,
|
|
7967
8153
|
close
|
|
7968
8154
|
}) {
|
|
7969
|
-
const editor =
|
|
7970
|
-
const ref =
|
|
7971
|
-
const fileInputRef =
|
|
8155
|
+
const editor = useSlateStatic18();
|
|
8156
|
+
const ref = useRef7(void 0);
|
|
8157
|
+
const fileInputRef = useRef7(null);
|
|
7972
8158
|
const savedState = editor.wysimark?.imageDialogState;
|
|
7973
8159
|
const hasOnImageChange = !!editor.wysimark?.onImageChange;
|
|
7974
|
-
const [url, setUrl] =
|
|
7975
|
-
const [alt, setAlt] =
|
|
7976
|
-
const [title, setTitle] =
|
|
7977
|
-
const [imageSource, setImageSource] =
|
|
7978
|
-
const [isUploading, setIsUploading] =
|
|
7979
|
-
const [uploadedUrl, setUploadedUrl] =
|
|
8160
|
+
const [url, setUrl] = useState9(savedState?.url ?? "");
|
|
8161
|
+
const [alt, setAlt] = useState9(savedState?.alt ?? "");
|
|
8162
|
+
const [title, setTitle] = useState9(savedState?.title ?? "");
|
|
8163
|
+
const [imageSource, setImageSource] = useState9(savedState?.imageSource ?? (hasOnImageChange ? "file" : "url"));
|
|
8164
|
+
const [isUploading, setIsUploading] = useState9(false);
|
|
8165
|
+
const [uploadedUrl, setUploadedUrl] = useState9(savedState?.uploadedUrl ?? "");
|
|
7980
8166
|
useEffect7(() => {
|
|
7981
8167
|
if (editor.wysimark) {
|
|
7982
8168
|
editor.wysimark.imageDialogState = { url, alt, title, imageSource, uploadedUrl };
|
|
@@ -8033,11 +8219,11 @@ function ImageUrlDialog({
|
|
|
8033
8219
|
}
|
|
8034
8220
|
const isSubmitDisabled = imageSource === "file" ? uploadedUrl.trim() === "" || isUploading : url.trim() === "";
|
|
8035
8221
|
return /* @__PURE__ */ jsxs28(Fragment8, { children: [
|
|
8036
|
-
/* @__PURE__ */
|
|
8037
|
-
/* @__PURE__ */
|
|
8222
|
+
/* @__PURE__ */ jsx57(CloseMask, { close }),
|
|
8223
|
+
/* @__PURE__ */ jsx57($FileDialog, { ref, style, children: /* @__PURE__ */ jsxs28("form", { onSubmit: handleSubmit, style: { padding: "8px" }, children: [
|
|
8038
8224
|
hasOnImageChange && /* @__PURE__ */ jsxs28("div", { style: { marginBottom: "12px" }, children: [
|
|
8039
8225
|
/* @__PURE__ */ jsxs28("label", { style: { display: "inline-flex", alignItems: "center", marginRight: "16px", cursor: "pointer" }, children: [
|
|
8040
|
-
/* @__PURE__ */
|
|
8226
|
+
/* @__PURE__ */ jsx57(
|
|
8041
8227
|
"input",
|
|
8042
8228
|
{
|
|
8043
8229
|
type: "radio",
|
|
@@ -8051,7 +8237,7 @@ function ImageUrlDialog({
|
|
|
8051
8237
|
t("imageSourceFile")
|
|
8052
8238
|
] }),
|
|
8053
8239
|
/* @__PURE__ */ jsxs28("label", { style: { display: "inline-flex", alignItems: "center", cursor: "pointer" }, children: [
|
|
8054
|
-
/* @__PURE__ */
|
|
8240
|
+
/* @__PURE__ */ jsx57(
|
|
8055
8241
|
"input",
|
|
8056
8242
|
{
|
|
8057
8243
|
type: "radio",
|
|
@@ -8066,8 +8252,8 @@ function ImageUrlDialog({
|
|
|
8066
8252
|
] })
|
|
8067
8253
|
] }),
|
|
8068
8254
|
imageSource === "url" ? /* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8069
|
-
/* @__PURE__ */
|
|
8070
|
-
/* @__PURE__ */
|
|
8255
|
+
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("imageUrlRequired") }),
|
|
8256
|
+
/* @__PURE__ */ jsx57(
|
|
8071
8257
|
"input",
|
|
8072
8258
|
{
|
|
8073
8259
|
type: "text",
|
|
@@ -8084,7 +8270,7 @@ function ImageUrlDialog({
|
|
|
8084
8270
|
}
|
|
8085
8271
|
)
|
|
8086
8272
|
] }) : /* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8087
|
-
/* @__PURE__ */
|
|
8273
|
+
/* @__PURE__ */ jsx57(
|
|
8088
8274
|
"input",
|
|
8089
8275
|
{
|
|
8090
8276
|
ref: fileInputRef,
|
|
@@ -8094,7 +8280,7 @@ function ImageUrlDialog({
|
|
|
8094
8280
|
style: { display: "none" }
|
|
8095
8281
|
}
|
|
8096
8282
|
),
|
|
8097
|
-
/* @__PURE__ */
|
|
8283
|
+
/* @__PURE__ */ jsx57(
|
|
8098
8284
|
"button",
|
|
8099
8285
|
{
|
|
8100
8286
|
type: "button",
|
|
@@ -8112,8 +8298,8 @@ function ImageUrlDialog({
|
|
|
8112
8298
|
}
|
|
8113
8299
|
),
|
|
8114
8300
|
uploadedUrl && /* @__PURE__ */ jsxs28("div", { style: { marginTop: "8px" }, children: [
|
|
8115
|
-
/* @__PURE__ */
|
|
8116
|
-
/* @__PURE__ */
|
|
8301
|
+
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("imageUrlRequired") }),
|
|
8302
|
+
/* @__PURE__ */ jsx57(
|
|
8117
8303
|
"input",
|
|
8118
8304
|
{
|
|
8119
8305
|
type: "text",
|
|
@@ -8133,8 +8319,8 @@ function ImageUrlDialog({
|
|
|
8133
8319
|
] })
|
|
8134
8320
|
] }),
|
|
8135
8321
|
/* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8136
|
-
/* @__PURE__ */
|
|
8137
|
-
/* @__PURE__ */
|
|
8322
|
+
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("altText") }),
|
|
8323
|
+
/* @__PURE__ */ jsx57(
|
|
8138
8324
|
"input",
|
|
8139
8325
|
{
|
|
8140
8326
|
type: "text",
|
|
@@ -8152,8 +8338,8 @@ function ImageUrlDialog({
|
|
|
8152
8338
|
)
|
|
8153
8339
|
] }),
|
|
8154
8340
|
/* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8155
|
-
/* @__PURE__ */
|
|
8156
|
-
/* @__PURE__ */
|
|
8341
|
+
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("title") }),
|
|
8342
|
+
/* @__PURE__ */ jsx57(
|
|
8157
8343
|
"input",
|
|
8158
8344
|
{
|
|
8159
8345
|
type: "text",
|
|
@@ -8171,7 +8357,7 @@ function ImageUrlDialog({
|
|
|
8171
8357
|
)
|
|
8172
8358
|
] }),
|
|
8173
8359
|
/* @__PURE__ */ jsxs28("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
8174
|
-
/* @__PURE__ */
|
|
8360
|
+
/* @__PURE__ */ jsx57(
|
|
8175
8361
|
"button",
|
|
8176
8362
|
{
|
|
8177
8363
|
type: "submit",
|
|
@@ -8190,7 +8376,7 @@ function ImageUrlDialog({
|
|
|
8190
8376
|
children: t("register")
|
|
8191
8377
|
}
|
|
8192
8378
|
),
|
|
8193
|
-
/* @__PURE__ */
|
|
8379
|
+
/* @__PURE__ */ jsx57(
|
|
8194
8380
|
"button",
|
|
8195
8381
|
{
|
|
8196
8382
|
type: "button",
|
|
@@ -8215,10 +8401,12 @@ function ImageUrlDialog({
|
|
|
8215
8401
|
import { isHotkey as isHotkey3 } from "is-hotkey";
|
|
8216
8402
|
import {
|
|
8217
8403
|
useCallback as useCallback13,
|
|
8218
|
-
|
|
8219
|
-
|
|
8404
|
+
useMemo as useMemo2,
|
|
8405
|
+
useRef as useRef8,
|
|
8406
|
+
useState as useState10
|
|
8220
8407
|
} from "react";
|
|
8221
|
-
import {
|
|
8408
|
+
import { Editor as Editor59, Range as Range10 } from "slate";
|
|
8409
|
+
import { ReactEditor as ReactEditor14, useSlateStatic as useSlateStatic19 } from "slate-react";
|
|
8222
8410
|
|
|
8223
8411
|
// src/toolbar-plugin/styles/dialog-shared-styles.ts
|
|
8224
8412
|
import styled35 from "@emotion/styled";
|
|
@@ -8255,14 +8443,14 @@ var $DialogHint = styled35("div")`
|
|
|
8255
8443
|
`;
|
|
8256
8444
|
|
|
8257
8445
|
// src/toolbar-plugin/components/dialog/anchor-dialog.tsx
|
|
8258
|
-
import { Fragment as Fragment9, jsx as
|
|
8446
|
+
import { Fragment as Fragment9, jsx as jsx58, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
8259
8447
|
var isEnter = isHotkey3("enter");
|
|
8260
8448
|
function AnchorDialog2({
|
|
8261
8449
|
dest,
|
|
8262
8450
|
close
|
|
8263
8451
|
}) {
|
|
8264
|
-
const editor =
|
|
8265
|
-
const ref =
|
|
8452
|
+
const editor = useSlateStatic19();
|
|
8453
|
+
const ref = useRef8(null);
|
|
8266
8454
|
const style = useAbsoluteReposition(
|
|
8267
8455
|
{ src: ref, dest },
|
|
8268
8456
|
({ src, dest: dest2 }, viewport) => {
|
|
@@ -8277,18 +8465,47 @@ function AnchorDialog2({
|
|
|
8277
8465
|
);
|
|
8278
8466
|
}
|
|
8279
8467
|
);
|
|
8280
|
-
const
|
|
8468
|
+
const initialText = useMemo2(() => {
|
|
8469
|
+
const { selection } = editor;
|
|
8470
|
+
if (selection && !Range10.isCollapsed(selection)) {
|
|
8471
|
+
return Editor59.string(editor, selection);
|
|
8472
|
+
}
|
|
8473
|
+
return "";
|
|
8474
|
+
}, []);
|
|
8475
|
+
const [url, setUrl] = useState10("");
|
|
8476
|
+
const [text, setText] = useState10(initialText);
|
|
8477
|
+
const [title, setTitle] = useState10(initialText);
|
|
8478
|
+
const [titleManuallyEdited, setTitleManuallyEdited] = useState10(false);
|
|
8281
8479
|
const insertLink2 = () => {
|
|
8282
|
-
|
|
8480
|
+
const linkText = text.trim() || url;
|
|
8481
|
+
const linkTitle = title.trim() || void 0;
|
|
8482
|
+
editor.anchor.insertLink(url, linkText, { select: true, title: linkTitle });
|
|
8283
8483
|
ReactEditor14.focus(editor);
|
|
8284
8484
|
close();
|
|
8285
8485
|
};
|
|
8286
|
-
const
|
|
8486
|
+
const onChangeUrl = useCallback13(
|
|
8287
8487
|
(e) => {
|
|
8288
8488
|
setUrl(e.currentTarget.value);
|
|
8289
8489
|
},
|
|
8290
8490
|
[setUrl]
|
|
8291
8491
|
);
|
|
8492
|
+
const onChangeText = useCallback13(
|
|
8493
|
+
(e) => {
|
|
8494
|
+
const newText = e.currentTarget.value;
|
|
8495
|
+
setText(newText);
|
|
8496
|
+
if (!titleManuallyEdited) {
|
|
8497
|
+
setTitle(newText);
|
|
8498
|
+
}
|
|
8499
|
+
},
|
|
8500
|
+
[setText, setTitle, titleManuallyEdited]
|
|
8501
|
+
);
|
|
8502
|
+
const onChangeTitle = useCallback13(
|
|
8503
|
+
(e) => {
|
|
8504
|
+
setTitle(e.currentTarget.value);
|
|
8505
|
+
setTitleManuallyEdited(true);
|
|
8506
|
+
},
|
|
8507
|
+
[setTitle]
|
|
8508
|
+
);
|
|
8292
8509
|
const onKeyDown = (e) => {
|
|
8293
8510
|
if (!isEnter(e))
|
|
8294
8511
|
return;
|
|
@@ -8297,25 +8514,46 @@ function AnchorDialog2({
|
|
|
8297
8514
|
insertLink2();
|
|
8298
8515
|
};
|
|
8299
8516
|
return /* @__PURE__ */ jsxs29(Fragment9, { children: [
|
|
8300
|
-
/* @__PURE__ */
|
|
8517
|
+
/* @__PURE__ */ jsx58(CloseMask, { close }),
|
|
8301
8518
|
/* @__PURE__ */ jsxs29($AnchorDialog, { ref, style, children: [
|
|
8302
|
-
/* @__PURE__ */
|
|
8303
|
-
|
|
8519
|
+
/* @__PURE__ */ jsx58($AnchorDialogInputLine, { children: /* @__PURE__ */ jsx58(
|
|
8520
|
+
$AnchorDialogInput,
|
|
8521
|
+
{
|
|
8522
|
+
type: "text",
|
|
8523
|
+
value: url,
|
|
8524
|
+
autoFocus: true,
|
|
8525
|
+
placeholder: t("linkUrl"),
|
|
8526
|
+
onChange: onChangeUrl,
|
|
8527
|
+
onKeyDown
|
|
8528
|
+
}
|
|
8529
|
+
) }),
|
|
8530
|
+
/* @__PURE__ */ jsx58($AnchorDialogInputLine, { style: { marginTop: "0.5em" }, children: /* @__PURE__ */ jsx58(
|
|
8531
|
+
$AnchorDialogInput,
|
|
8532
|
+
{
|
|
8533
|
+
type: "text",
|
|
8534
|
+
value: text,
|
|
8535
|
+
placeholder: t("linkText"),
|
|
8536
|
+
onChange: onChangeText,
|
|
8537
|
+
onKeyDown
|
|
8538
|
+
}
|
|
8539
|
+
) }),
|
|
8540
|
+
/* @__PURE__ */ jsxs29($AnchorDialogInputLine, { style: { marginTop: "0.5em" }, children: [
|
|
8541
|
+
/* @__PURE__ */ jsx58(
|
|
8304
8542
|
$AnchorDialogInput,
|
|
8305
8543
|
{
|
|
8306
8544
|
type: "text",
|
|
8307
|
-
value:
|
|
8308
|
-
|
|
8309
|
-
onChange:
|
|
8545
|
+
value: title,
|
|
8546
|
+
placeholder: t("tooltipText"),
|
|
8547
|
+
onChange: onChangeTitle,
|
|
8310
8548
|
onKeyDown
|
|
8311
8549
|
}
|
|
8312
8550
|
),
|
|
8313
8551
|
/* @__PURE__ */ jsxs29($DialogButton, { onClick: insertLink2, children: [
|
|
8314
|
-
/* @__PURE__ */
|
|
8315
|
-
/* @__PURE__ */
|
|
8552
|
+
/* @__PURE__ */ jsx58(Link, {}),
|
|
8553
|
+
/* @__PURE__ */ jsx58(LinkPlus, {})
|
|
8316
8554
|
] })
|
|
8317
8555
|
] }),
|
|
8318
|
-
/* @__PURE__ */
|
|
8556
|
+
/* @__PURE__ */ jsx58($DialogHint, { children: t("tooltipHint") })
|
|
8319
8557
|
] })
|
|
8320
8558
|
] });
|
|
8321
8559
|
}
|
|
@@ -8329,17 +8567,17 @@ var dialogItems = [
|
|
|
8329
8567
|
hotkey: "mod+k",
|
|
8330
8568
|
Component: AnchorDialog2
|
|
8331
8569
|
},
|
|
8332
|
-
{
|
|
8333
|
-
icon: Table2,
|
|
8334
|
-
title: t("insertTable"),
|
|
8335
|
-
more: true,
|
|
8336
|
-
Component: TableDialog
|
|
8337
|
-
},
|
|
8338
8570
|
{
|
|
8339
8571
|
icon: Image,
|
|
8340
8572
|
title: t("insertImageFromUrl"),
|
|
8341
8573
|
more: true,
|
|
8342
8574
|
Component: ImageUrlDialog
|
|
8575
|
+
},
|
|
8576
|
+
{
|
|
8577
|
+
icon: Table2,
|
|
8578
|
+
title: t("insertTable"),
|
|
8579
|
+
more: true,
|
|
8580
|
+
Component: TableDialog
|
|
8343
8581
|
}
|
|
8344
8582
|
];
|
|
8345
8583
|
var expandedDialogItems = dialogItems;
|
|
@@ -8354,15 +8592,16 @@ var smallDialogItems = [
|
|
|
8354
8592
|
];
|
|
8355
8593
|
|
|
8356
8594
|
// src/toolbar-plugin/items/mark-items.tsx
|
|
8357
|
-
import { Editor as
|
|
8595
|
+
import { Editor as Editor60 } from "slate";
|
|
8358
8596
|
function getMarks(editor) {
|
|
8359
|
-
const marks =
|
|
8597
|
+
const marks = Editor60.marks(editor);
|
|
8360
8598
|
return {
|
|
8361
8599
|
bold: marks?.bold || false,
|
|
8362
8600
|
italic: marks?.italic || false,
|
|
8363
8601
|
strike: marks?.strike || false,
|
|
8364
8602
|
code: marks?.code || false,
|
|
8365
|
-
underline: marks?.underline || false
|
|
8603
|
+
underline: marks?.underline || false,
|
|
8604
|
+
highlight: marks?.highlight || false
|
|
8366
8605
|
};
|
|
8367
8606
|
}
|
|
8368
8607
|
var primaryMarkItems = [
|
|
@@ -8400,6 +8639,13 @@ var primaryMarkItems = [
|
|
|
8400
8639
|
hotkey: "mod+u",
|
|
8401
8640
|
action: (editor) => editor.marksPlugin.toggleUnderline(),
|
|
8402
8641
|
active: (editor) => getMarks(editor).underline
|
|
8642
|
+
},
|
|
8643
|
+
{
|
|
8644
|
+
icon: Highlight,
|
|
8645
|
+
title: t("highlight"),
|
|
8646
|
+
action: (editor) => editor.marksPlugin.toggleHighlight(),
|
|
8647
|
+
active: (editor) => getMarks(editor).highlight,
|
|
8648
|
+
show: (editor) => !editor.wysimark?.disableHighlight
|
|
8403
8649
|
}
|
|
8404
8650
|
];
|
|
8405
8651
|
var expandedMarkItems = primaryMarkItems;
|
|
@@ -8418,19 +8664,22 @@ var listItems = [
|
|
|
8418
8664
|
icon: BulletList,
|
|
8419
8665
|
title: t("bulletList"),
|
|
8420
8666
|
hotkey: "super+8",
|
|
8421
|
-
action: (editor) => editor.list
|
|
8667
|
+
action: (editor) => editor.list?.convertUnorderedList(true),
|
|
8668
|
+
show: (editor) => !!editor.list
|
|
8422
8669
|
},
|
|
8423
8670
|
{
|
|
8424
8671
|
icon: ListNumbers,
|
|
8425
8672
|
title: t("numberedList"),
|
|
8426
8673
|
hotkey: "super+7",
|
|
8427
|
-
action: (editor) => editor.list
|
|
8674
|
+
action: (editor) => editor.list?.convertOrderedList(true),
|
|
8675
|
+
show: (editor) => !!editor.list
|
|
8428
8676
|
},
|
|
8429
8677
|
{
|
|
8430
8678
|
icon: ListCheck,
|
|
8431
8679
|
title: t("checkList"),
|
|
8432
8680
|
hotkey: "super+9",
|
|
8433
|
-
action: (editor) => editor.list
|
|
8681
|
+
action: (editor) => editor.list?.convertTaskList(true),
|
|
8682
|
+
show: (editor) => !!editor.list && !editor.wysimark?.disableTaskList
|
|
8434
8683
|
}
|
|
8435
8684
|
];
|
|
8436
8685
|
var expandedListItems = [...listItems, "divider", ...listDepthItems];
|
|
@@ -8439,12 +8688,13 @@ var compactListItems = [
|
|
|
8439
8688
|
icon: ListNumbers,
|
|
8440
8689
|
title: t("list"),
|
|
8441
8690
|
more: true,
|
|
8442
|
-
children: [...listItems, "divider", ...listDepthItems]
|
|
8691
|
+
children: [...listItems, "divider", ...listDepthItems],
|
|
8692
|
+
show: (editor) => !!editor.list
|
|
8443
8693
|
}
|
|
8444
8694
|
];
|
|
8445
8695
|
|
|
8446
8696
|
// src/toolbar-plugin/items/quote-items.tsx
|
|
8447
|
-
import { Editor as
|
|
8697
|
+
import { Editor as Editor61, Transforms as Transforms43 } from "slate";
|
|
8448
8698
|
var quoteItemsList = [
|
|
8449
8699
|
{
|
|
8450
8700
|
icon: Quote,
|
|
@@ -8473,9 +8723,9 @@ var quoteItemsList = [
|
|
|
8473
8723
|
const codeBlockEntry = findElementUp(editor, "code-block");
|
|
8474
8724
|
if (codeBlockEntry) {
|
|
8475
8725
|
const [codeBlock, path] = codeBlockEntry;
|
|
8476
|
-
const textContent =
|
|
8477
|
-
|
|
8478
|
-
|
|
8726
|
+
const textContent = Editor61.string(editor, path);
|
|
8727
|
+
Transforms43.removeNodes(editor, { at: path });
|
|
8728
|
+
Transforms43.insertNodes(
|
|
8479
8729
|
editor,
|
|
8480
8730
|
{
|
|
8481
8731
|
type: "paragraph",
|
|
@@ -8486,13 +8736,13 @@ var quoteItemsList = [
|
|
|
8486
8736
|
return;
|
|
8487
8737
|
}
|
|
8488
8738
|
if (selection && JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path)) {
|
|
8489
|
-
editor.codeBlock
|
|
8739
|
+
editor.codeBlock?.createCodeBlock({ language: "text" });
|
|
8490
8740
|
return;
|
|
8491
8741
|
}
|
|
8492
8742
|
if (selection && (selection.anchor.offset !== selection.focus.offset || JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path))) {
|
|
8493
|
-
const selectedText =
|
|
8494
|
-
|
|
8495
|
-
|
|
8743
|
+
const selectedText = Editor61.string(editor, selection);
|
|
8744
|
+
Transforms43.delete(editor);
|
|
8745
|
+
Transforms43.insertNodes(
|
|
8496
8746
|
editor,
|
|
8497
8747
|
{
|
|
8498
8748
|
type: "code-block",
|
|
@@ -8507,9 +8757,10 @@ var quoteItemsList = [
|
|
|
8507
8757
|
);
|
|
8508
8758
|
return;
|
|
8509
8759
|
}
|
|
8510
|
-
editor.codeBlock
|
|
8760
|
+
editor.codeBlock?.createCodeBlock({ language: "text" });
|
|
8511
8761
|
},
|
|
8512
|
-
active: (editor) => !!findElementUp(editor, "code-block")
|
|
8762
|
+
active: (editor) => !!findElementUp(editor, "code-block"),
|
|
8763
|
+
show: (editor) => !!editor.codeBlock && !editor.wysimark?.disableCodeBlock
|
|
8513
8764
|
}
|
|
8514
8765
|
];
|
|
8515
8766
|
var expandedQuoteItems = quoteItemsList;
|
|
@@ -8531,9 +8782,9 @@ var rawModeItem = {
|
|
|
8531
8782
|
editor.wysimark.toggleRawMode();
|
|
8532
8783
|
}
|
|
8533
8784
|
},
|
|
8534
|
-
// Only show in the toolbar when not in Raw mode
|
|
8785
|
+
// Only show in the toolbar when not in Raw mode and toggleRawMode is available
|
|
8535
8786
|
show: (editor) => {
|
|
8536
|
-
return editor.wysimark && !editor.wysimark.isRawMode;
|
|
8787
|
+
return editor.wysimark && typeof editor.wysimark.toggleRawMode === "function" && !editor.wysimark.isRawMode;
|
|
8537
8788
|
},
|
|
8538
8789
|
active: () => false
|
|
8539
8790
|
// Never show as active in the toolbar
|
|
@@ -8602,16 +8853,16 @@ var itemSets = [largeItems, mediumItems, smallItems];
|
|
|
8602
8853
|
|
|
8603
8854
|
// src/toolbar-plugin/components/toolbar/toolbar-button.tsx
|
|
8604
8855
|
import { clsx as clsx9 } from "clsx";
|
|
8605
|
-
import { useCallback as useCallback14, useRef as
|
|
8606
|
-
import { ReactEditor as ReactEditor15, useSlate as useSlate2, useSlateStatic as
|
|
8607
|
-
import { jsx as
|
|
8856
|
+
import { useCallback as useCallback14, useRef as useRef9 } from "react";
|
|
8857
|
+
import { ReactEditor as ReactEditor15, useSlate as useSlate2, useSlateStatic as useSlateStatic20 } from "slate-react";
|
|
8858
|
+
import { jsx as jsx59, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
8608
8859
|
function ToolbarButton({
|
|
8609
8860
|
item
|
|
8610
8861
|
}) {
|
|
8611
|
-
const staticEditor =
|
|
8862
|
+
const staticEditor = useSlateStatic20();
|
|
8612
8863
|
const editor = useSlate2();
|
|
8613
8864
|
const isActive = item.active ? item.active(editor) : false;
|
|
8614
|
-
const ref =
|
|
8865
|
+
const ref = useRef9(null);
|
|
8615
8866
|
const tooltip = useTooltip({
|
|
8616
8867
|
title: item.title,
|
|
8617
8868
|
hotkey: () => item.hotkey ? formatHotkey(item.hotkey) : void 0
|
|
@@ -8624,9 +8875,9 @@ function ToolbarButton({
|
|
|
8624
8875
|
if (!dest)
|
|
8625
8876
|
return;
|
|
8626
8877
|
if (items) {
|
|
8627
|
-
menuLayer.open(() => /* @__PURE__ */
|
|
8878
|
+
menuLayer.open(() => /* @__PURE__ */ jsx59(Menu, { dest, items, close: menuLayer.close }));
|
|
8628
8879
|
} else if (Component) {
|
|
8629
|
-
menuLayer.open(() => /* @__PURE__ */
|
|
8880
|
+
menuLayer.open(() => /* @__PURE__ */ jsx59(Component, { dest, close: menuLayer.close }));
|
|
8630
8881
|
}
|
|
8631
8882
|
}, [item]);
|
|
8632
8883
|
const onClick = useCallback14(() => {
|
|
@@ -8663,24 +8914,24 @@ function ToolbarButton({
|
|
|
8663
8914
|
"--disabled": !isActive && r(item?.title)?.includes("Depth")
|
|
8664
8915
|
}),
|
|
8665
8916
|
children: [
|
|
8666
|
-
/* @__PURE__ */
|
|
8667
|
-
item.more ? /* @__PURE__ */
|
|
8917
|
+
/* @__PURE__ */ jsx59(item.icon, {}),
|
|
8918
|
+
item.more ? /* @__PURE__ */ jsx59(More, {}) : null
|
|
8668
8919
|
]
|
|
8669
8920
|
}
|
|
8670
8921
|
);
|
|
8671
8922
|
}
|
|
8672
8923
|
|
|
8673
8924
|
// src/toolbar-plugin/components/toolbar/toolbar.tsx
|
|
8674
|
-
import { jsx as
|
|
8925
|
+
import { jsx as jsx60 } from "react/jsx-runtime";
|
|
8675
8926
|
function ToolbarItem({ item }) {
|
|
8676
|
-
const editor =
|
|
8927
|
+
const editor = useSlateStatic21();
|
|
8677
8928
|
if (item === "divider") {
|
|
8678
|
-
return /* @__PURE__ */
|
|
8929
|
+
return /* @__PURE__ */ jsx60($ToolbarDividerContainer, { "data-item-type": "divider", children: /* @__PURE__ */ jsx60($ToolbarDivider, {}) });
|
|
8679
8930
|
}
|
|
8680
8931
|
const show = item.show === void 0 ? true : item.show(editor);
|
|
8681
8932
|
if (!show)
|
|
8682
8933
|
return null;
|
|
8683
|
-
return /* @__PURE__ */
|
|
8934
|
+
return /* @__PURE__ */ jsx60(ToolbarButton, { item });
|
|
8684
8935
|
}
|
|
8685
8936
|
function getWidths(toolbar) {
|
|
8686
8937
|
const button = toolbar.querySelector(
|
|
@@ -8706,8 +8957,8 @@ function measureItemSetWidth(items, buttonWidth, dividerWidth) {
|
|
|
8706
8957
|
}
|
|
8707
8958
|
var WIDTH_BUFFER_PX = 48;
|
|
8708
8959
|
function Toolbar() {
|
|
8709
|
-
const ref =
|
|
8710
|
-
const [items, setItems] =
|
|
8960
|
+
const ref = useRef10(null);
|
|
8961
|
+
const [items, setItems] = useState11(initialItems);
|
|
8711
8962
|
useEffect8(() => {
|
|
8712
8963
|
const refresh = throttle2(
|
|
8713
8964
|
() => {
|
|
@@ -8738,7 +8989,7 @@ function Toolbar() {
|
|
|
8738
8989
|
window.removeEventListener("resize", refresh);
|
|
8739
8990
|
};
|
|
8740
8991
|
}, []);
|
|
8741
|
-
return /* @__PURE__ */
|
|
8992
|
+
return /* @__PURE__ */ jsx60($ToolbarContainer, { ref, children: /* @__PURE__ */ jsx60($Toolbar, { children: items.map((item, index) => /* @__PURE__ */ jsx60(
|
|
8742
8993
|
ToolbarItem,
|
|
8743
8994
|
{
|
|
8744
8995
|
item
|
|
@@ -8748,21 +8999,21 @@ function Toolbar() {
|
|
|
8748
8999
|
}
|
|
8749
9000
|
|
|
8750
9001
|
// src/toolbar-plugin/render-editable/index.tsx
|
|
8751
|
-
import { jsx as
|
|
9002
|
+
import { jsx as jsx61, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
8752
9003
|
function renderEditable({ attributes, Editable: Editable3 }) {
|
|
8753
|
-
const outerContainerRef =
|
|
8754
|
-
const editor =
|
|
9004
|
+
const outerContainerRef = useRef11(null);
|
|
9005
|
+
const editor = useSlateStatic22();
|
|
8755
9006
|
const focused = useFocused();
|
|
8756
9007
|
const onClickOuterContainer = useCallback15(
|
|
8757
9008
|
(e) => {
|
|
8758
9009
|
if (e.target !== e.currentTarget)
|
|
8759
9010
|
return;
|
|
8760
|
-
|
|
9011
|
+
Transforms44.select(editor, Editor62.end(editor, []));
|
|
8761
9012
|
ReactEditor16.focus(editor);
|
|
8762
9013
|
},
|
|
8763
9014
|
[editor]
|
|
8764
9015
|
);
|
|
8765
|
-
return /* @__PURE__ */
|
|
9016
|
+
return /* @__PURE__ */ jsx61(Layers, { children: /* @__PURE__ */ jsxs31(
|
|
8766
9017
|
$OuterContainer,
|
|
8767
9018
|
{
|
|
8768
9019
|
ref: outerContainerRef,
|
|
@@ -8774,8 +9025,8 @@ function renderEditable({ attributes, Editable: Editable3 }) {
|
|
|
8774
9025
|
},
|
|
8775
9026
|
onClick: onClickOuterContainer,
|
|
8776
9027
|
children: [
|
|
8777
|
-
/* @__PURE__ */
|
|
8778
|
-
/* @__PURE__ */
|
|
9028
|
+
/* @__PURE__ */ jsx61(Toolbar, {}),
|
|
9029
|
+
/* @__PURE__ */ jsx61(
|
|
8779
9030
|
Editable3,
|
|
8780
9031
|
{
|
|
8781
9032
|
as: $Editable,
|
|
@@ -8807,7 +9058,7 @@ var ToolbarPlugin = createPlugin(
|
|
|
8807
9058
|
);
|
|
8808
9059
|
|
|
8809
9060
|
// src/trailing-block-plugin/index.tsx
|
|
8810
|
-
import { Editor as
|
|
9061
|
+
import { Editor as Editor63, Node as Node15, Path as Path16, Transforms as Transforms45 } from "slate";
|
|
8811
9062
|
var TrailingBlockPlugin = createPlugin(
|
|
8812
9063
|
(editor) => {
|
|
8813
9064
|
editor.allowTrailingBlock = true;
|
|
@@ -8815,19 +9066,19 @@ var TrailingBlockPlugin = createPlugin(
|
|
|
8815
9066
|
name: "trailing-block",
|
|
8816
9067
|
editor: {
|
|
8817
9068
|
normalizeNode: (entry) => {
|
|
8818
|
-
if (!
|
|
9069
|
+
if (!Editor63.isEditor(entry[0]))
|
|
8819
9070
|
return false;
|
|
8820
9071
|
const lastPath = [editor.children.length - 1];
|
|
8821
|
-
const lastElement =
|
|
9072
|
+
const lastElement = Node15.child(
|
|
8822
9073
|
editor,
|
|
8823
9074
|
editor.children.length - 1
|
|
8824
9075
|
);
|
|
8825
|
-
if (
|
|
8826
|
-
|
|
9076
|
+
if (Editor63.hasBlocks(editor, lastElement) || Editor63.isVoid(editor, lastElement)) {
|
|
9077
|
+
Transforms45.insertNodes(
|
|
8827
9078
|
editor,
|
|
8828
9079
|
{ type: "paragraph", children: [{ text: "" }] },
|
|
8829
9080
|
{
|
|
8830
|
-
at:
|
|
9081
|
+
at: Path16.next(lastPath)
|
|
8831
9082
|
}
|
|
8832
9083
|
);
|
|
8833
9084
|
}
|
|
@@ -8839,11 +9090,11 @@ var TrailingBlockPlugin = createPlugin(
|
|
|
8839
9090
|
);
|
|
8840
9091
|
|
|
8841
9092
|
// src/paste-markdown-plugin/methods/index.ts
|
|
8842
|
-
import { Transforms as
|
|
9093
|
+
import { Transforms as Transforms46 } from "slate";
|
|
8843
9094
|
function pasteMarkdown(editor, markdown) {
|
|
8844
9095
|
const escapedMarkdown = escapeUrlSlashes(markdown);
|
|
8845
9096
|
const fragment = parse(escapedMarkdown);
|
|
8846
|
-
|
|
9097
|
+
Transforms46.insertNodes(editor, fragment);
|
|
8847
9098
|
}
|
|
8848
9099
|
function createPasteMarkdownMethods(editor) {
|
|
8849
9100
|
return {
|
|
@@ -8875,7 +9126,7 @@ var PasteMarkdownPlugin = createPlugin(
|
|
|
8875
9126
|
);
|
|
8876
9127
|
|
|
8877
9128
|
// src/placeholder-plugin/index.tsx
|
|
8878
|
-
import { jsx as
|
|
9129
|
+
import { jsx as jsx62 } from "react/jsx-runtime";
|
|
8879
9130
|
function renderPlaceholder(props) {
|
|
8880
9131
|
const nextAttributes = {
|
|
8881
9132
|
...props.attributes,
|
|
@@ -8885,7 +9136,7 @@ function renderPlaceholder(props) {
|
|
|
8885
9136
|
maxWidth: void 0
|
|
8886
9137
|
}
|
|
8887
9138
|
};
|
|
8888
|
-
return /* @__PURE__ */
|
|
9139
|
+
return /* @__PURE__ */ jsx62("span", { ...nextAttributes, children: props.children });
|
|
8889
9140
|
}
|
|
8890
9141
|
var PlaceholderPlugin = createPlugin(
|
|
8891
9142
|
(editor, _options, { createPolicy }) => {
|
|
@@ -8900,7 +9151,7 @@ var PlaceholderPlugin = createPlugin(
|
|
|
8900
9151
|
);
|
|
8901
9152
|
|
|
8902
9153
|
// src/entry/plugins.ts
|
|
8903
|
-
var
|
|
9154
|
+
var defaultPlugins = [
|
|
8904
9155
|
PasteMarkdownPlugin,
|
|
8905
9156
|
ConvertElementPlugin,
|
|
8906
9157
|
AnchorPlugin,
|
|
@@ -8923,21 +9174,24 @@ var plugins = [
|
|
|
8923
9174
|
];
|
|
8924
9175
|
|
|
8925
9176
|
// src/entry/SinkEditable.tsx
|
|
8926
|
-
var
|
|
8927
|
-
var { withSink, SinkEditable: SinkEditable2 } = Sink;
|
|
9177
|
+
var { withSink, SinkEditable: SinkEditable2 } = createSink(defaultPlugins);
|
|
8928
9178
|
|
|
8929
9179
|
// src/entry/useEditor.tsx
|
|
8930
|
-
import { useState as
|
|
8931
|
-
import { createEditor, Editor as
|
|
9180
|
+
import { useState as useState12 } from "react";
|
|
9181
|
+
import { createEditor, Editor as Editor65, Transforms as Transforms47 } from "slate";
|
|
8932
9182
|
import { withHistory } from "slate-history";
|
|
8933
9183
|
import { withReact } from "slate-react";
|
|
8934
9184
|
function useEditor({
|
|
8935
9185
|
authToken,
|
|
8936
9186
|
height,
|
|
8937
9187
|
minHeight,
|
|
8938
|
-
maxHeight
|
|
8939
|
-
|
|
8940
|
-
|
|
9188
|
+
maxHeight,
|
|
9189
|
+
disableRawMode,
|
|
9190
|
+
disableTaskList,
|
|
9191
|
+
disableCodeBlock,
|
|
9192
|
+
disableHighlight
|
|
9193
|
+
} = {}) {
|
|
9194
|
+
const [editor] = useState12(() => {
|
|
8941
9195
|
const editor2 = createEditor();
|
|
8942
9196
|
const nextEditor = withSink(withReact(withHistory(editor2)), {
|
|
8943
9197
|
toolbar: {
|
|
@@ -8953,8 +9207,14 @@ function useEditor({
|
|
|
8953
9207
|
});
|
|
8954
9208
|
nextEditor.convertElement.addConvertElementType("paragraph");
|
|
8955
9209
|
editor2.wysimark = {
|
|
8956
|
-
//
|
|
8957
|
-
|
|
9210
|
+
// Disable raw mode (defaults to true)
|
|
9211
|
+
disableRawMode: disableRawMode ?? true,
|
|
9212
|
+
// Disable task list if specified
|
|
9213
|
+
disableTaskList,
|
|
9214
|
+
// Disable code block if specified
|
|
9215
|
+
disableCodeBlock,
|
|
9216
|
+
// Disable highlight (defaults to true)
|
|
9217
|
+
disableHighlight: disableHighlight ?? true
|
|
8958
9218
|
};
|
|
8959
9219
|
editor2.getMarkdown = () => {
|
|
8960
9220
|
return serialize(editor2.children);
|
|
@@ -8964,7 +9224,7 @@ function useEditor({
|
|
|
8964
9224
|
const documentValue = parse(escapedMarkdown);
|
|
8965
9225
|
editor2.children = documentValue;
|
|
8966
9226
|
editor2.selection = null;
|
|
8967
|
-
|
|
9227
|
+
Transforms47.select(editor2, Editor65.start(editor2, [0]));
|
|
8968
9228
|
};
|
|
8969
9229
|
return nextEditor;
|
|
8970
9230
|
});
|
|
@@ -8972,9 +9232,9 @@ function useEditor({
|
|
|
8972
9232
|
}
|
|
8973
9233
|
|
|
8974
9234
|
// src/entry/index.tsx
|
|
8975
|
-
import { jsx as
|
|
9235
|
+
import { jsx as jsx63, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
8976
9236
|
function renderLeaf({ children, attributes }) {
|
|
8977
|
-
return /* @__PURE__ */
|
|
9237
|
+
return /* @__PURE__ */ jsx63("span", { ...attributes, children });
|
|
8978
9238
|
}
|
|
8979
9239
|
function Editable2({
|
|
8980
9240
|
editor,
|
|
@@ -8986,12 +9246,12 @@ function Editable2({
|
|
|
8986
9246
|
style,
|
|
8987
9247
|
onImageChange
|
|
8988
9248
|
}) {
|
|
8989
|
-
const [isRawMode, setIsRawMode] =
|
|
8990
|
-
const [rawText, setRawText] =
|
|
8991
|
-
const ignoreNextChangeRef =
|
|
8992
|
-
const initialValueRef =
|
|
8993
|
-
const prevValueRef =
|
|
8994
|
-
const lastEmittedValueRef =
|
|
9249
|
+
const [isRawMode, setIsRawMode] = useState13(false);
|
|
9250
|
+
const [rawText, setRawText] = useState13(value);
|
|
9251
|
+
const ignoreNextChangeRef = useRef12(false);
|
|
9252
|
+
const initialValueRef = useRef12(void 0);
|
|
9253
|
+
const prevValueRef = useRef12(void 0);
|
|
9254
|
+
const lastEmittedValueRef = useRef12(void 0);
|
|
8995
9255
|
const onThrottledSlateChange = useCallback16(
|
|
8996
9256
|
throttle3(
|
|
8997
9257
|
() => {
|
|
@@ -9015,9 +9275,6 @@ function Editable2({
|
|
|
9015
9275
|
prevValueRef.current = nextValue;
|
|
9016
9276
|
return;
|
|
9017
9277
|
}
|
|
9018
|
-
if (prevValueRef.current === nextValue) {
|
|
9019
|
-
return;
|
|
9020
|
-
}
|
|
9021
9278
|
prevValueRef.current = nextValue;
|
|
9022
9279
|
onThrottledSlateChange();
|
|
9023
9280
|
},
|
|
@@ -9048,7 +9305,7 @@ function Editable2({
|
|
|
9048
9305
|
const documentValue = parse(valueToProcess);
|
|
9049
9306
|
editor.children = documentValue;
|
|
9050
9307
|
editor.selection = null;
|
|
9051
|
-
|
|
9308
|
+
Transforms48.select(editor, Editor66.start(editor, [0]));
|
|
9052
9309
|
}
|
|
9053
9310
|
}
|
|
9054
9311
|
}
|
|
@@ -9082,10 +9339,12 @@ function Editable2({
|
|
|
9082
9339
|
setIsRawMode(!isRawMode);
|
|
9083
9340
|
}, [isRawMode, applyRawTextToEditor, updateRawTextFromEditor]);
|
|
9084
9341
|
editor.wysimark.isRawMode = isRawMode;
|
|
9085
|
-
editor.wysimark.
|
|
9342
|
+
if (!editor.wysimark.disableRawMode) {
|
|
9343
|
+
editor.wysimark.toggleRawMode = handleRawModeToggle;
|
|
9344
|
+
}
|
|
9086
9345
|
editor.wysimark.onImageChange = onImageChange;
|
|
9087
9346
|
return /* @__PURE__ */ jsxs32("div", { style: { position: "relative" }, children: [
|
|
9088
|
-
isRawMode && /* @__PURE__ */
|
|
9347
|
+
isRawMode && /* @__PURE__ */ jsx63("div", { style: { position: "absolute", top: "5px", right: "25px", zIndex: 10 }, children: /* @__PURE__ */ jsx63(
|
|
9089
9348
|
"div",
|
|
9090
9349
|
{
|
|
9091
9350
|
onClick: handleRawModeToggle,
|
|
@@ -9111,10 +9370,10 @@ function Editable2({
|
|
|
9111
9370
|
e.preventDefault();
|
|
9112
9371
|
}
|
|
9113
9372
|
},
|
|
9114
|
-
children: /* @__PURE__ */
|
|
9373
|
+
children: /* @__PURE__ */ jsx63("span", { style: { color: "#4a90e2", fontSize: "1.25em" }, children: /* @__PURE__ */ jsx63(VisualEditor, {}) })
|
|
9115
9374
|
}
|
|
9116
9375
|
) }),
|
|
9117
|
-
/* @__PURE__ */
|
|
9376
|
+
/* @__PURE__ */ jsx63("div", { style: { display: isRawMode ? "block" : "none", textAlign: "center" }, children: /* @__PURE__ */ jsx63(
|
|
9118
9377
|
"textarea",
|
|
9119
9378
|
{
|
|
9120
9379
|
value: unescapeUrlSlashes(rawText).replace(/ /g, ""),
|
|
@@ -9139,13 +9398,13 @@ function Editable2({
|
|
|
9139
9398
|
}
|
|
9140
9399
|
}
|
|
9141
9400
|
) }),
|
|
9142
|
-
/* @__PURE__ */
|
|
9401
|
+
/* @__PURE__ */ jsx63("div", { style: { display: isRawMode ? "none" : "block" }, children: /* @__PURE__ */ jsx63(
|
|
9143
9402
|
Slate2,
|
|
9144
9403
|
{
|
|
9145
9404
|
editor,
|
|
9146
9405
|
initialValue: initialValueRef.current ?? editor.children,
|
|
9147
9406
|
onChange: onSlateChange,
|
|
9148
|
-
children: /* @__PURE__ */
|
|
9407
|
+
children: /* @__PURE__ */ jsx63(
|
|
9149
9408
|
SinkEditable2,
|
|
9150
9409
|
{
|
|
9151
9410
|
renderLeaf,
|
|
@@ -9162,13 +9421,13 @@ function Editable2({
|
|
|
9162
9421
|
}
|
|
9163
9422
|
|
|
9164
9423
|
// src/index.tsx
|
|
9165
|
-
import { jsx as
|
|
9424
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
9166
9425
|
function StandaloneEditor({
|
|
9167
9426
|
standaloneOptions: { onChange, placeholder, className, ...options },
|
|
9168
9427
|
standaloneMethodsRef
|
|
9169
9428
|
}) {
|
|
9170
|
-
const [markdown, setMarkdown] =
|
|
9171
|
-
const markdownRef =
|
|
9429
|
+
const [markdown, setMarkdown] = useState14(options.initialMarkdown || "");
|
|
9430
|
+
const markdownRef = useRef13(markdown);
|
|
9172
9431
|
const editor = useEditor(options);
|
|
9173
9432
|
markdownRef.current = markdown;
|
|
9174
9433
|
useImperativeHandle(
|
|
@@ -9194,7 +9453,7 @@ function StandaloneEditor({
|
|
|
9194
9453
|
},
|
|
9195
9454
|
[editor]
|
|
9196
9455
|
);
|
|
9197
|
-
return /* @__PURE__ */
|
|
9456
|
+
return /* @__PURE__ */ jsx64(
|
|
9198
9457
|
Editable2,
|
|
9199
9458
|
{
|
|
9200
9459
|
editor,
|
|
@@ -9209,7 +9468,7 @@ function createWysimark(containerElement, options) {
|
|
|
9209
9468
|
const standaloneMethodsRef = createRef();
|
|
9210
9469
|
const root = createRoot(containerElement);
|
|
9211
9470
|
root.render(
|
|
9212
|
-
/* @__PURE__ */
|
|
9471
|
+
/* @__PURE__ */ jsx64(
|
|
9213
9472
|
StandaloneEditor,
|
|
9214
9473
|
{
|
|
9215
9474
|
standaloneMethodsRef,
|