wysimark-lite 0.23.0 → 0.25.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/dist/index.js +186 -131
- package/dist/index.mjs +1337 -1021
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +5 -13
- package/dist/index.d.ts +0 -1074
package/dist/index.mjs
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
// src/index.tsx
|
|
4
4
|
import {
|
|
5
5
|
createRef,
|
|
6
|
-
useCallback as
|
|
6
|
+
useCallback as useCallback19,
|
|
7
7
|
useImperativeHandle,
|
|
8
|
-
useRef as
|
|
8
|
+
useRef as useRef15,
|
|
9
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
|
|
15
|
+
import { useCallback as useCallback18, useRef as useRef14, useState as useState13 } from "react";
|
|
16
16
|
import { Editor as Editor66, Transforms as Transforms48 } from "slate";
|
|
17
17
|
import { ReactEditor as ReactEditor18, Slate as Slate2 } from "slate-react";
|
|
18
18
|
|
|
@@ -87,17 +87,22 @@ function replace($0, $1) {
|
|
|
87
87
|
// src/convert/parse/custom-gfm.ts
|
|
88
88
|
import { gfm } from "micromark-extension-gfm";
|
|
89
89
|
import { gfmToMarkdown } from "mdast-util-gfm";
|
|
90
|
+
function wrapHandler(originalHandler) {
|
|
91
|
+
if (!originalHandler)
|
|
92
|
+
return void 0;
|
|
93
|
+
return function(token) {
|
|
94
|
+
if (!this.data) {
|
|
95
|
+
this.data = {};
|
|
96
|
+
}
|
|
97
|
+
return originalHandler.call(this, token);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
90
100
|
function customRemarkGfm() {
|
|
91
101
|
return function() {
|
|
92
102
|
if (!this) {
|
|
93
103
|
return;
|
|
94
104
|
}
|
|
95
|
-
|
|
96
|
-
this.data = {};
|
|
97
|
-
} else if (typeof this.data === "function") {
|
|
98
|
-
this.data();
|
|
99
|
-
}
|
|
100
|
-
const data = typeof this.data === "function" ? this.data() : this.data;
|
|
105
|
+
const data = this.data();
|
|
101
106
|
const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);
|
|
102
107
|
const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);
|
|
103
108
|
const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);
|
|
@@ -105,29 +110,13 @@ function customRemarkGfm() {
|
|
|
105
110
|
const patchedFromMarkdown = function() {
|
|
106
111
|
const extension = gfmTableFromMarkdown();
|
|
107
112
|
if (extension.enter) {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
extension.enter.table = function(token) {
|
|
111
|
-
if (!this.data) {
|
|
112
|
-
this.data = {};
|
|
113
|
-
}
|
|
114
|
-
originalEnterTable.call(this, token);
|
|
115
|
-
this.data.inTable = true;
|
|
116
|
-
};
|
|
113
|
+
for (const key2 of Object.keys(extension.enter)) {
|
|
114
|
+
extension.enter[key2] = wrapHandler(extension.enter[key2]);
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
if (extension.exit) {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
extension.exit.table = function(token) {
|
|
123
|
-
if (!this.data) {
|
|
124
|
-
this.data = {};
|
|
125
|
-
}
|
|
126
|
-
originalExitTable.call(this, token);
|
|
127
|
-
if (this.data) {
|
|
128
|
-
this.data.inTable = void 0;
|
|
129
|
-
}
|
|
130
|
-
};
|
|
118
|
+
for (const key2 of Object.keys(extension.exit)) {
|
|
119
|
+
extension.exit[key2] = wrapHandler(extension.exit[key2]);
|
|
131
120
|
}
|
|
132
121
|
}
|
|
133
122
|
return extension;
|
|
@@ -240,11 +229,12 @@ function isPlainSpace(segment) {
|
|
|
240
229
|
}
|
|
241
230
|
|
|
242
231
|
// src/convert/serialize/serialize-line/utils/mark-utils/mark-convert-utils.ts
|
|
243
|
-
var
|
|
232
|
+
var MARK_KEY_TO_OPEN_TOKEN = {
|
|
244
233
|
bold: "**",
|
|
245
234
|
italic: "_",
|
|
246
235
|
// ins: "++",
|
|
247
236
|
strike: "~~",
|
|
237
|
+
highlight: "<mark>",
|
|
248
238
|
/**
|
|
249
239
|
* IMPORTANT!
|
|
250
240
|
*
|
|
@@ -256,25 +246,41 @@ var MARK_KEY_TO_TOKEN = {
|
|
|
256
246
|
*
|
|
257
247
|
* This is handled in the `serializeLine` code.
|
|
258
248
|
*/
|
|
259
|
-
code: ""
|
|
260
|
-
/**
|
|
261
|
-
* Highlight is handled specially in `serializeLine` using <mark> tags.
|
|
262
|
-
*/
|
|
263
|
-
highlight: ""
|
|
249
|
+
code: ""
|
|
264
250
|
};
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
251
|
+
var MARK_KEY_TO_CLOSE_TOKEN = {
|
|
252
|
+
bold: "**",
|
|
253
|
+
italic: "_",
|
|
254
|
+
// ins: "++",
|
|
255
|
+
strike: "~~",
|
|
256
|
+
highlight: "</mark>",
|
|
257
|
+
code: ""
|
|
258
|
+
};
|
|
259
|
+
function convertMarkToOpenSymbol(mark) {
|
|
260
|
+
if (mark in MARK_KEY_TO_OPEN_TOKEN)
|
|
261
|
+
return MARK_KEY_TO_OPEN_TOKEN[mark];
|
|
262
|
+
throw new Error(
|
|
263
|
+
`Could not find mark ${JSON.stringify(mark)} in MARK_KEY_TO_OPEN_TOKEN lookup`
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function convertMarkToCloseSymbol(mark) {
|
|
267
|
+
if (mark in MARK_KEY_TO_CLOSE_TOKEN)
|
|
268
|
+
return MARK_KEY_TO_CLOSE_TOKEN[mark];
|
|
269
|
+
throw new Error(
|
|
270
|
+
`Could not find mark ${JSON.stringify(mark)} in MARK_KEY_TO_CLOSE_TOKEN lookup`
|
|
271
|
+
);
|
|
269
272
|
}
|
|
270
|
-
function
|
|
271
|
-
return marks.map(
|
|
273
|
+
function convertMarksToOpenSymbols(marks) {
|
|
274
|
+
return marks.map(convertMarkToOpenSymbol).join("");
|
|
275
|
+
}
|
|
276
|
+
function convertMarksToCloseSymbols(marks) {
|
|
277
|
+
return marks.map(convertMarkToCloseSymbol).join("");
|
|
272
278
|
}
|
|
273
279
|
|
|
274
280
|
// src/convert/serialize/serialize-line/utils/mark-utils/mark-get-utils.ts
|
|
275
281
|
import { Text as SlateText } from "slate";
|
|
276
282
|
function getMarksFromText(text) {
|
|
277
|
-
const { text:
|
|
283
|
+
const { text: _textContent, ...marks } = text;
|
|
278
284
|
return Object.keys(marks);
|
|
279
285
|
}
|
|
280
286
|
function getMarksFromSegment(segment) {
|
|
@@ -325,6 +331,7 @@ var ORDERED_MARK_KEYS = [
|
|
|
325
331
|
"italic",
|
|
326
332
|
"underline",
|
|
327
333
|
"strike",
|
|
334
|
+
"highlight",
|
|
328
335
|
"code"
|
|
329
336
|
];
|
|
330
337
|
function sortMarks(marks) {
|
|
@@ -559,6 +566,13 @@ function parseInlineImage(image) {
|
|
|
559
566
|
}
|
|
560
567
|
|
|
561
568
|
// src/convert/parse/parse-phrasing-content/parse-phrasing-content.ts
|
|
569
|
+
function parseInlineHtml(htmlValue, marks) {
|
|
570
|
+
const markMatch = htmlValue.match(/^<mark>(.+?)<\/mark>$/s);
|
|
571
|
+
if (markMatch) {
|
|
572
|
+
return [{ text: markMatch[1], ...marks, highlight: true }];
|
|
573
|
+
}
|
|
574
|
+
return [{ text: htmlValue, code: true }];
|
|
575
|
+
}
|
|
562
576
|
function parsePhrasingContents(phrasingContents, marks = {}) {
|
|
563
577
|
const segments = [];
|
|
564
578
|
for (const phrasingContent of phrasingContents) {
|
|
@@ -581,13 +595,8 @@ function parsePhrasingContent(phrasingContent, marks = {}) {
|
|
|
581
595
|
});
|
|
582
596
|
case "footnoteReference":
|
|
583
597
|
return [{ text: `[${phrasingContent.identifier}]` }];
|
|
584
|
-
case "html":
|
|
585
|
-
|
|
586
|
-
if (markMatch) {
|
|
587
|
-
return [{ text: markMatch[1], ...marks, highlight: true }];
|
|
588
|
-
}
|
|
589
|
-
return [{ text: phrasingContent.value, code: true }];
|
|
590
|
-
}
|
|
598
|
+
case "html":
|
|
599
|
+
return parseInlineHtml(phrasingContent.value, marks);
|
|
591
600
|
case "image":
|
|
592
601
|
return parseInlineImage(phrasingContent);
|
|
593
602
|
case "inlineCode": {
|
|
@@ -642,12 +651,9 @@ function parseHeading(content) {
|
|
|
642
651
|
function parseHTML(content) {
|
|
643
652
|
return [
|
|
644
653
|
{
|
|
645
|
-
type: "
|
|
646
|
-
|
|
647
|
-
children:
|
|
648
|
-
type: "code-block-line",
|
|
649
|
-
children: [{ text: line }]
|
|
650
|
-
}))
|
|
654
|
+
type: "html-block",
|
|
655
|
+
html: content.value,
|
|
656
|
+
children: [{ text: "" }]
|
|
651
657
|
}
|
|
652
658
|
];
|
|
653
659
|
}
|
|
@@ -1375,19 +1381,11 @@ function serializeLine(inputSegments, leadingMarks = [], trailingMarks = []) {
|
|
|
1375
1381
|
substrings.push(segment.text);
|
|
1376
1382
|
continue;
|
|
1377
1383
|
}
|
|
1378
|
-
substrings.push(
|
|
1379
|
-
const hasHighlightOpen = leadingDiff.add.includes("highlight");
|
|
1380
|
-
if (hasHighlightOpen) {
|
|
1381
|
-
substrings.push("<mark>");
|
|
1382
|
-
}
|
|
1384
|
+
substrings.push(convertMarksToOpenSymbols(leadingDiff.add));
|
|
1383
1385
|
substrings.push(serializeSegment(segment));
|
|
1384
1386
|
const nextMarks = getNextMarks(segments, i, trailingMarks);
|
|
1385
1387
|
const trailingDiff = diffMarks(leadingDiff.nextOrderedMarks, nextMarks);
|
|
1386
|
-
|
|
1387
|
-
if (hasHighlightClose) {
|
|
1388
|
-
substrings.push("</mark>");
|
|
1389
|
-
}
|
|
1390
|
-
substrings.push(convertMarksToSymbolsExceptCode(trailingDiff.remove));
|
|
1388
|
+
substrings.push(convertMarksToCloseSymbols(trailingDiff.remove));
|
|
1391
1389
|
leadingDiff = trailingDiff;
|
|
1392
1390
|
}
|
|
1393
1391
|
return substrings.join("");
|
|
@@ -1516,6 +1514,10 @@ function serializeElement(element, orders) {
|
|
|
1516
1514
|
throw new Error(
|
|
1517
1515
|
`Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.`
|
|
1518
1516
|
);
|
|
1517
|
+
case "html-block":
|
|
1518
|
+
return `${element.html}
|
|
1519
|
+
|
|
1520
|
+
`;
|
|
1519
1521
|
}
|
|
1520
1522
|
assertUnreachable(element);
|
|
1521
1523
|
}
|
|
@@ -1547,13 +1549,13 @@ function serializeElements(elements) {
|
|
|
1547
1549
|
return replaceConsecutiveNewlines(replaceLeadingNewlines(joined)).trim();
|
|
1548
1550
|
}
|
|
1549
1551
|
function replaceLeadingNewlines(input) {
|
|
1550
|
-
return input.replace(/^\n\n/g, "
|
|
1552
|
+
return input.replace(/^\n\n/g, "\\\n\n");
|
|
1551
1553
|
}
|
|
1552
1554
|
function replaceConsecutiveNewlines(input) {
|
|
1553
1555
|
return input.replace(/(\n{4,})/g, (match) => {
|
|
1554
1556
|
const newlineCount = match.length;
|
|
1555
1557
|
const count = Math.floor((newlineCount - 2) / 2);
|
|
1556
|
-
return "\n\n" + Array(count).fill("
|
|
1558
|
+
return "\n\n" + Array(count).fill("\\").join("\n\n") + "\n\n";
|
|
1557
1559
|
});
|
|
1558
1560
|
}
|
|
1559
1561
|
|
|
@@ -1611,7 +1613,10 @@ var translations = {
|
|
|
1611
1613
|
imageSourceUrl: "URL",
|
|
1612
1614
|
imageSourceFile: "\u30D5\u30A1\u30A4\u30EB",
|
|
1613
1615
|
selectFile: "\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",
|
|
1614
|
-
uploading: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D..."
|
|
1616
|
+
uploading: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",
|
|
1617
|
+
saving: "\u4FDD\u5B58\u4E2D...",
|
|
1618
|
+
vaultPath: "\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",
|
|
1619
|
+
vaultPathHint: "vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
1615
1620
|
},
|
|
1616
1621
|
en: {
|
|
1617
1622
|
bold: "Bold",
|
|
@@ -1659,7 +1664,10 @@ var translations = {
|
|
|
1659
1664
|
imageSourceUrl: "URL",
|
|
1660
1665
|
imageSourceFile: "File",
|
|
1661
1666
|
selectFile: "Select File",
|
|
1662
|
-
uploading: "Uploading..."
|
|
1667
|
+
uploading: "Uploading...",
|
|
1668
|
+
saving: "Saving...",
|
|
1669
|
+
vaultPath: "Save Path:",
|
|
1670
|
+
vaultPathHint: "Enter the path within the vault to save the file"
|
|
1663
1671
|
}
|
|
1664
1672
|
};
|
|
1665
1673
|
var getLanguage = () => {
|
|
@@ -1699,8 +1707,8 @@ function defined(value) {
|
|
|
1699
1707
|
}
|
|
1700
1708
|
|
|
1701
1709
|
// src/sink/editable/create-decorate.ts
|
|
1702
|
-
function createDecorate(originalFn,
|
|
1703
|
-
const fns =
|
|
1710
|
+
function createDecorate(originalFn, plugins2) {
|
|
1711
|
+
const fns = plugins2.map((plugin) => plugin.editableProps?.decorate).filter(defined);
|
|
1704
1712
|
return function(entry) {
|
|
1705
1713
|
const ranges = [];
|
|
1706
1714
|
for (const fn of fns) {
|
|
@@ -1716,8 +1724,8 @@ function createDecorate(originalFn, plugins) {
|
|
|
1716
1724
|
// src/sink/editable/create-editable.tsx
|
|
1717
1725
|
import { Editable } from "slate-react";
|
|
1718
1726
|
import { jsx } from "react/jsx-runtime";
|
|
1719
|
-
function createEditable(
|
|
1720
|
-
const fns =
|
|
1727
|
+
function createEditable(plugins2) {
|
|
1728
|
+
const fns = plugins2.map((plugin) => plugin.renderEditable).filter(defined);
|
|
1721
1729
|
let CurrentRenderEditable = (props) => /* @__PURE__ */ jsx(Editable, { ...props });
|
|
1722
1730
|
for (const fn of fns) {
|
|
1723
1731
|
const PrevRenderEditable = CurrentRenderEditable;
|
|
@@ -1732,9 +1740,9 @@ function createEditable(plugins) {
|
|
|
1732
1740
|
}
|
|
1733
1741
|
|
|
1734
1742
|
// src/sink/editable/create-handler.ts
|
|
1735
|
-
function extractEditableFns(
|
|
1743
|
+
function extractEditableFns(plugins2, key2) {
|
|
1736
1744
|
const fns = [];
|
|
1737
|
-
for (const plugin of
|
|
1745
|
+
for (const plugin of plugins2) {
|
|
1738
1746
|
const maybeFn = plugin.editableProps?.[key2];
|
|
1739
1747
|
if (maybeFn)
|
|
1740
1748
|
fns.push(maybeFn);
|
|
@@ -1750,26 +1758,26 @@ function createHandlerFn(fns, originalFn) {
|
|
|
1750
1758
|
originalFn?.(event);
|
|
1751
1759
|
};
|
|
1752
1760
|
}
|
|
1753
|
-
var createOnKeyDown = (originalFn,
|
|
1754
|
-
const fns = extractEditableFns(
|
|
1761
|
+
var createOnKeyDown = (originalFn, plugins2) => {
|
|
1762
|
+
const fns = extractEditableFns(plugins2, "onKeyDown");
|
|
1755
1763
|
return createHandlerFn(fns, originalFn);
|
|
1756
1764
|
};
|
|
1757
|
-
var createOnKeyUp = (originalFn,
|
|
1758
|
-
const fns = extractEditableFns(
|
|
1765
|
+
var createOnKeyUp = (originalFn, plugins2) => {
|
|
1766
|
+
const fns = extractEditableFns(plugins2, "onKeyUp");
|
|
1759
1767
|
return createHandlerFn(fns, originalFn);
|
|
1760
1768
|
};
|
|
1761
|
-
var createOnPaste = (originalFn,
|
|
1762
|
-
const fns = extractEditableFns(
|
|
1769
|
+
var createOnPaste = (originalFn, plugins2) => {
|
|
1770
|
+
const fns = extractEditableFns(plugins2, "onPaste");
|
|
1763
1771
|
return createHandlerFn(fns, originalFn);
|
|
1764
1772
|
};
|
|
1765
|
-
var createOnDrop = (originalFn,
|
|
1766
|
-
const fns = extractEditableFns(
|
|
1773
|
+
var createOnDrop = (originalFn, plugins2) => {
|
|
1774
|
+
const fns = extractEditableFns(plugins2, "onDrop");
|
|
1767
1775
|
return createHandlerFn(fns, originalFn);
|
|
1768
1776
|
};
|
|
1769
1777
|
|
|
1770
1778
|
// src/sink/editable/create-render-element.ts
|
|
1771
|
-
function createRenderElement(originalFn,
|
|
1772
|
-
const fns =
|
|
1779
|
+
function createRenderElement(originalFn, plugins2) {
|
|
1780
|
+
const fns = plugins2.map((plugin) => plugin.editableProps?.renderElement).filter(defined);
|
|
1773
1781
|
return function renderElement5(renderElementProps) {
|
|
1774
1782
|
for (const fn of fns) {
|
|
1775
1783
|
const result = fn(renderElementProps);
|
|
@@ -1787,11 +1795,11 @@ function createRenderElement(originalFn, plugins) {
|
|
|
1787
1795
|
|
|
1788
1796
|
// src/sink/editable/create-render-leaf.ts
|
|
1789
1797
|
import { cloneElement } from "react";
|
|
1790
|
-
function createRenderLeaf(originalFn,
|
|
1798
|
+
function createRenderLeaf(originalFn, plugins2) {
|
|
1791
1799
|
if (originalFn === void 0) {
|
|
1792
1800
|
throw new Error(`renderLeaf was not defined on SinkEditable`);
|
|
1793
1801
|
}
|
|
1794
|
-
const fns =
|
|
1802
|
+
const fns = plugins2.map((plugin) => plugin.editableProps?.renderLeaf).filter(defined).reverse();
|
|
1795
1803
|
return function(renderLeafProps) {
|
|
1796
1804
|
let value = originalFn({
|
|
1797
1805
|
...renderLeafProps,
|
|
@@ -1820,10 +1828,10 @@ function createRenderLeaf(originalFn, plugins) {
|
|
|
1820
1828
|
}
|
|
1821
1829
|
|
|
1822
1830
|
// src/sink/editable/create-render-placeholder.tsx
|
|
1823
|
-
function createRenderPlaceholder(originalFn,
|
|
1831
|
+
function createRenderPlaceholder(originalFn, plugins2) {
|
|
1824
1832
|
if (originalFn)
|
|
1825
1833
|
return originalFn;
|
|
1826
|
-
const fns =
|
|
1834
|
+
const fns = plugins2.map((plugin) => plugin.editableProps?.renderPlaceholder).filter(defined);
|
|
1827
1835
|
if (fns.length === 0)
|
|
1828
1836
|
return void 0;
|
|
1829
1837
|
return function(renderPlaceholderProps) {
|
|
@@ -1857,16 +1865,16 @@ function SinkEditable(originalProps) {
|
|
|
1857
1865
|
useEffect(() => {
|
|
1858
1866
|
Editor.normalize(editor, { force: true });
|
|
1859
1867
|
}, []);
|
|
1860
|
-
const { plugins } = editor.sink;
|
|
1868
|
+
const { plugins: plugins2 } = editor.sink;
|
|
1861
1869
|
const nextProps = useMemo(
|
|
1862
1870
|
() => ({
|
|
1863
1871
|
...originalProps,
|
|
1864
|
-
decorate: createDecorate(originalProps.decorate,
|
|
1865
|
-
renderElement: createRenderElement(originalProps.renderElement,
|
|
1866
|
-
renderLeaf: createRenderLeaf(originalProps.renderLeaf,
|
|
1872
|
+
decorate: createDecorate(originalProps.decorate, plugins2),
|
|
1873
|
+
renderElement: createRenderElement(originalProps.renderElement, plugins2),
|
|
1874
|
+
renderLeaf: createRenderLeaf(originalProps.renderLeaf, plugins2),
|
|
1867
1875
|
renderPlaceholder: createRenderPlaceholder(
|
|
1868
1876
|
originalProps.renderPlaceholder,
|
|
1869
|
-
|
|
1877
|
+
plugins2
|
|
1870
1878
|
),
|
|
1871
1879
|
/**
|
|
1872
1880
|
* NOTE: We skip `onKeyUp` as it is deprecated. If somebody needs it in new
|
|
@@ -1874,35 +1882,38 @@ function SinkEditable(originalProps) {
|
|
|
1874
1882
|
*
|
|
1875
1883
|
* https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event
|
|
1876
1884
|
*/
|
|
1877
|
-
onKeyDown: createOnKeyDown(originalProps.onKeyDown,
|
|
1878
|
-
onKeyUp: createOnKeyUp(originalProps.onKeyUp,
|
|
1879
|
-
onPaste: createOnPaste(originalProps.onPaste,
|
|
1880
|
-
onDrop: createOnDrop(originalProps.onDrop,
|
|
1885
|
+
onKeyDown: createOnKeyDown(originalProps.onKeyDown, plugins2),
|
|
1886
|
+
onKeyUp: createOnKeyUp(originalProps.onKeyUp, plugins2),
|
|
1887
|
+
onPaste: createOnPaste(originalProps.onPaste, plugins2),
|
|
1888
|
+
onDrop: createOnDrop(originalProps.onDrop, plugins2)
|
|
1881
1889
|
}),
|
|
1882
1890
|
Object.values(originalProps)
|
|
1883
1891
|
);
|
|
1884
|
-
const NextEditable = useMemo(() => createEditable(
|
|
1892
|
+
const NextEditable = useMemo(() => createEditable(plugins2), [plugins2]);
|
|
1885
1893
|
return /* @__PURE__ */ jsx2(NextEditable, { ...nextProps });
|
|
1886
1894
|
}
|
|
1887
1895
|
|
|
1888
1896
|
// src/sink/editor/create-boolean-action.ts
|
|
1889
|
-
function createBooleanAction(editor, actionKey,
|
|
1897
|
+
function createBooleanAction(editor, actionKey, plugins2) {
|
|
1890
1898
|
const originalAction = editor[actionKey];
|
|
1891
|
-
const actionPlugins =
|
|
1899
|
+
const actionPlugins = plugins2.filter((plugin) => plugin.editor?.[actionKey]);
|
|
1892
1900
|
return function nextBooleanAction(node) {
|
|
1893
1901
|
for (const plugin of actionPlugins) {
|
|
1894
|
-
const
|
|
1902
|
+
const editorPlugin = plugin.editor;
|
|
1903
|
+
const actionFn = editorPlugin?.[actionKey];
|
|
1904
|
+
const result = actionFn?.(node);
|
|
1895
1905
|
if (typeof result === "boolean")
|
|
1896
1906
|
return result;
|
|
1897
1907
|
}
|
|
1898
|
-
|
|
1908
|
+
const origFn = originalAction;
|
|
1909
|
+
return origFn(node);
|
|
1899
1910
|
};
|
|
1900
1911
|
}
|
|
1901
1912
|
|
|
1902
1913
|
// src/sink/editor/create-void-action.ts
|
|
1903
|
-
function createVoidAction(editor, actionKey,
|
|
1914
|
+
function createVoidAction(editor, actionKey, plugins2) {
|
|
1904
1915
|
const originalAction = editor[actionKey];
|
|
1905
|
-
const actionPlugins =
|
|
1916
|
+
const actionPlugins = plugins2.filter((plugin) => plugin.editor?.[actionKey]);
|
|
1906
1917
|
return function nextVoidAction(...args) {
|
|
1907
1918
|
let isHandled = false;
|
|
1908
1919
|
const afterHandledCallbacks = [];
|
|
@@ -1926,10 +1937,10 @@ function createVoidAction(editor, actionKey, plugins) {
|
|
|
1926
1937
|
function createWithSink(pluginFns) {
|
|
1927
1938
|
return (originalEditor, options) => {
|
|
1928
1939
|
const editor = originalEditor;
|
|
1929
|
-
const
|
|
1940
|
+
const plugins2 = pluginFns.map(
|
|
1930
1941
|
(plugin) => plugin(editor, options, { createPolicy: (x) => x })
|
|
1931
1942
|
);
|
|
1932
|
-
editor.sink = { plugins };
|
|
1943
|
+
editor.sink = { plugins: plugins2 };
|
|
1933
1944
|
editor.isMaster = "isMaster" in editor ? editor.isMaster : () => false;
|
|
1934
1945
|
editor.isSlave = "isSlave" in editor ? editor.isSlave : () => false;
|
|
1935
1946
|
editor.isStandalone = "isStandalone" in editor ? editor.isStandalone : () => false;
|
|
@@ -1937,22 +1948,22 @@ function createWithSink(pluginFns) {
|
|
|
1937
1948
|
/**
|
|
1938
1949
|
* void
|
|
1939
1950
|
*/
|
|
1940
|
-
normalizeNode: createVoidAction(editor, "normalizeNode",
|
|
1941
|
-
deleteBackward: createVoidAction(editor, "deleteBackward",
|
|
1942
|
-
deleteForward: createVoidAction(editor, "deleteForward",
|
|
1943
|
-
deleteFragment: createVoidAction(editor, "deleteFragment",
|
|
1944
|
-
insertBreak: createVoidAction(editor, "insertBreak",
|
|
1945
|
-
insertFragment: createVoidAction(editor, "insertFragment",
|
|
1946
|
-
insertNode: createVoidAction(editor, "insertNode",
|
|
1947
|
-
insertText: createVoidAction(editor, "insertText",
|
|
1951
|
+
normalizeNode: createVoidAction(editor, "normalizeNode", plugins2),
|
|
1952
|
+
deleteBackward: createVoidAction(editor, "deleteBackward", plugins2),
|
|
1953
|
+
deleteForward: createVoidAction(editor, "deleteForward", plugins2),
|
|
1954
|
+
deleteFragment: createVoidAction(editor, "deleteFragment", plugins2),
|
|
1955
|
+
insertBreak: createVoidAction(editor, "insertBreak", plugins2),
|
|
1956
|
+
insertFragment: createVoidAction(editor, "insertFragment", plugins2),
|
|
1957
|
+
insertNode: createVoidAction(editor, "insertNode", plugins2),
|
|
1958
|
+
insertText: createVoidAction(editor, "insertText", plugins2),
|
|
1948
1959
|
/**
|
|
1949
1960
|
* boolean
|
|
1950
1961
|
*/
|
|
1951
|
-
isInline: createBooleanAction(editor, "isInline",
|
|
1952
|
-
isVoid: createBooleanAction(editor, "isVoid",
|
|
1953
|
-
isMaster: createBooleanAction(editor, "isMaster",
|
|
1954
|
-
isSlave: createBooleanAction(editor, "isSlave",
|
|
1955
|
-
isStandalone: createBooleanAction(editor, "isStandalone",
|
|
1962
|
+
isInline: createBooleanAction(editor, "isInline", plugins2),
|
|
1963
|
+
isVoid: createBooleanAction(editor, "isVoid", plugins2),
|
|
1964
|
+
isMaster: createBooleanAction(editor, "isMaster", plugins2),
|
|
1965
|
+
isSlave: createBooleanAction(editor, "isSlave", plugins2),
|
|
1966
|
+
isStandalone: createBooleanAction(editor, "isStandalone", plugins2)
|
|
1956
1967
|
});
|
|
1957
1968
|
return editor;
|
|
1958
1969
|
};
|
|
@@ -2019,8 +2030,9 @@ function standardizeNodeMatcher(matchNode) {
|
|
|
2019
2030
|
return (node) => Element4.isElement(node) && node.type === matchNode;
|
|
2020
2031
|
if (Array.isArray(matchNode))
|
|
2021
2032
|
return (node) => Element4.isElement(node) && matchNode.includes(node.type);
|
|
2033
|
+
const exhaustiveCheck = matchNode;
|
|
2022
2034
|
throw new Error(
|
|
2023
|
-
`Expected matchNode to be a function, string or array but is ${
|
|
2035
|
+
`Expected matchNode to be a function, string or array but is ${exhaustiveCheck}`
|
|
2024
2036
|
);
|
|
2025
2037
|
}
|
|
2026
2038
|
|
|
@@ -2190,13 +2202,13 @@ function forceNormalizePath(editor, path) {
|
|
|
2190
2202
|
Editor8.withoutNormalizing(editor, () => {
|
|
2191
2203
|
Transforms2.setNodes(
|
|
2192
2204
|
editor,
|
|
2193
|
-
// @ts-
|
|
2205
|
+
// @ts-expect-error - intentional dummy property for normalization
|
|
2194
2206
|
{ __DOESNT_MATTER_JUST_TO_START_NORMALIZING__: "123" },
|
|
2195
2207
|
{ at: path }
|
|
2196
2208
|
);
|
|
2197
2209
|
Transforms2.setNodes(
|
|
2198
2210
|
editor,
|
|
2199
|
-
// @ts-
|
|
2211
|
+
// @ts-expect-error - intentional dummy property for normalization
|
|
2200
2212
|
{ __DOESNT_MATTER_JUST_TO_START_NORMALIZING__: null },
|
|
2201
2213
|
{ at: path }
|
|
2202
2214
|
);
|
|
@@ -2304,7 +2316,7 @@ function isUrl(s) {
|
|
|
2304
2316
|
let url;
|
|
2305
2317
|
try {
|
|
2306
2318
|
url = new URL(s);
|
|
2307
|
-
} catch
|
|
2319
|
+
} catch {
|
|
2308
2320
|
return false;
|
|
2309
2321
|
}
|
|
2310
2322
|
return url.protocol === "http:" || url.protocol === "https:" || url.protocol === "mailto:";
|
|
@@ -2406,7 +2418,7 @@ function normalizeNode(editor, entry) {
|
|
|
2406
2418
|
|
|
2407
2419
|
// src/anchor-plugin/render-element/anchor.tsx
|
|
2408
2420
|
import { clsx } from "clsx";
|
|
2409
|
-
import { useEffect as useEffect3, useRef as
|
|
2421
|
+
import { useEffect as useEffect3, useRef as useRef5 } from "react";
|
|
2410
2422
|
import { useSelected, useSlate } from "slate-react";
|
|
2411
2423
|
|
|
2412
2424
|
// src/use-layer/layers.tsx
|
|
@@ -2526,8 +2538,8 @@ var $ProgressBarFill = styled2("span")`
|
|
|
2526
2538
|
`;
|
|
2527
2539
|
|
|
2528
2540
|
// src/anchor-plugin/render-element/AnchorDialog.tsx
|
|
2529
|
-
import
|
|
2530
|
-
import { useCallback as
|
|
2541
|
+
import styled15 from "@emotion/styled";
|
|
2542
|
+
import { useCallback as useCallback5, useState as useState4 } from "react";
|
|
2531
2543
|
import { useSlateStatic as useSlateStatic4 } from "slate-react";
|
|
2532
2544
|
|
|
2533
2545
|
// src/shared-overlays/components/CloseMask/index.tsx
|
|
@@ -2737,10 +2749,21 @@ function useAbsoluteReposition(elementLikeRecord, fn) {
|
|
|
2737
2749
|
function positionInside(src, container, pos, { margin = 0 } = {}) {
|
|
2738
2750
|
if (src == null)
|
|
2739
2751
|
return { ...pos, left: -1024 };
|
|
2740
|
-
const
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
|
|
2752
|
+
const { top } = pos;
|
|
2753
|
+
let { left } = pos;
|
|
2754
|
+
const containerWidth = container.right - container.left - margin * 2;
|
|
2755
|
+
if (src.width >= containerWidth) {
|
|
2756
|
+
left = container.left + margin;
|
|
2757
|
+
} else {
|
|
2758
|
+
const right = left + src.width;
|
|
2759
|
+
if (right > container.right - margin) {
|
|
2760
|
+
left = container.right - src.width - margin;
|
|
2761
|
+
}
|
|
2762
|
+
if (left < container.left + margin) {
|
|
2763
|
+
left = container.left + margin;
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
return { left, top };
|
|
2744
2767
|
}
|
|
2745
2768
|
|
|
2746
2769
|
// src/toolbar-plugin/styles/anchor-dialog-styles.ts
|
|
@@ -2778,8 +2801,9 @@ var $Panel = styled4(SinkReset)`
|
|
|
2778
2801
|
|
|
2779
2802
|
// src/toolbar-plugin/styles/anchor-dialog-styles.ts
|
|
2780
2803
|
var $AnchorDialog = styled5($Panel)`
|
|
2781
|
-
padding: 1em;
|
|
2782
2804
|
width: 24em;
|
|
2805
|
+
padding: 0;
|
|
2806
|
+
overflow: hidden;
|
|
2783
2807
|
`;
|
|
2784
2808
|
var $AnchorDialogInputLine = styled5("div")`
|
|
2785
2809
|
display: flex;
|
|
@@ -2790,6 +2814,7 @@ var $AnchorDialogInput = styled5("input")`
|
|
|
2790
2814
|
padding: 0.5em 0.75em;
|
|
2791
2815
|
border-radius: 0.25em;
|
|
2792
2816
|
color: var(--shade-700);
|
|
2817
|
+
background: var(--shade-50);
|
|
2793
2818
|
border: 1px solid var(--shade-300);
|
|
2794
2819
|
font-size: 0.9375em;
|
|
2795
2820
|
&:focus {
|
|
@@ -2854,6 +2879,7 @@ var $Menu = styled8($Panel)`
|
|
|
2854
2879
|
padding-top: 0.5em;
|
|
2855
2880
|
padding-bottom: 0.5em;
|
|
2856
2881
|
transition: all 200ms;
|
|
2882
|
+
min-width: 12em;
|
|
2857
2883
|
/**
|
|
2858
2884
|
* Prevent clicks from stealing focus from the editor
|
|
2859
2885
|
*/
|
|
@@ -2883,9 +2909,10 @@ var $MenuItem = styled8("div")`
|
|
|
2883
2909
|
}
|
|
2884
2910
|
}
|
|
2885
2911
|
.--title {
|
|
2886
|
-
flex: 1
|
|
2912
|
+
flex: 1 1 auto;
|
|
2887
2913
|
font-size: 0.875em;
|
|
2888
2914
|
color: var(--shade-800);
|
|
2915
|
+
white-space: nowrap;
|
|
2889
2916
|
}
|
|
2890
2917
|
.--hotkey {
|
|
2891
2918
|
flex: 0 0;
|
|
@@ -3189,8 +3216,8 @@ function useTooltip({
|
|
|
3189
3216
|
}
|
|
3190
3217
|
|
|
3191
3218
|
// src/anchor-plugin/render-element/AnchorEditDialog.tsx
|
|
3192
|
-
import
|
|
3193
|
-
import { useCallback as
|
|
3219
|
+
import styled14 from "@emotion/styled";
|
|
3220
|
+
import { useCallback as useCallback4, useRef as useRef4, useState as useState3 } from "react";
|
|
3194
3221
|
import { Node as Node6 } from "slate";
|
|
3195
3222
|
import { useSlateStatic as useSlateStatic3 } from "slate-react";
|
|
3196
3223
|
|
|
@@ -3222,6 +3249,7 @@ var $Textarea = styled12("input")`
|
|
|
3222
3249
|
padding: 0.5em 0.75em;
|
|
3223
3250
|
border-radius: 0.25em;
|
|
3224
3251
|
color: var(--shade-700);
|
|
3252
|
+
background: var(--shade-50);
|
|
3225
3253
|
font-family: inherit;
|
|
3226
3254
|
border: 1px solid var(--shade-300);
|
|
3227
3255
|
font-size: 0.9375em;
|
|
@@ -3235,6 +3263,7 @@ var $Input = styled12("input")`
|
|
|
3235
3263
|
padding: 0.5em 0.75em;
|
|
3236
3264
|
border-radius: 0.25em;
|
|
3237
3265
|
color: var(--shade-700);
|
|
3266
|
+
background: var(--shade-50);
|
|
3238
3267
|
border: 1px solid var(--shade-300);
|
|
3239
3268
|
font-size: 0.9375em;
|
|
3240
3269
|
&:focus {
|
|
@@ -3283,12 +3312,96 @@ var $CancelButton = styled12($BaseButton)`
|
|
|
3283
3312
|
}
|
|
3284
3313
|
`;
|
|
3285
3314
|
|
|
3315
|
+
// src/toolbar-plugin/components/dialog/DraggableHeader.tsx
|
|
3316
|
+
import { useRef as useRef3, useCallback as useCallback3 } from "react";
|
|
3317
|
+
import styled13 from "@emotion/styled";
|
|
3318
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
3319
|
+
var $DragHandle = styled13.div`
|
|
3320
|
+
display: flex;
|
|
3321
|
+
align-items: center;
|
|
3322
|
+
justify-content: center;
|
|
3323
|
+
padding: 6px 0;
|
|
3324
|
+
cursor: grab;
|
|
3325
|
+
background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
|
|
3326
|
+
border-bottom: 1px solid #ddd;
|
|
3327
|
+
border-radius: 4px 4px 0 0;
|
|
3328
|
+
user-select: none;
|
|
3329
|
+
touch-action: none;
|
|
3330
|
+
|
|
3331
|
+
&:active {
|
|
3332
|
+
cursor: grabbing;
|
|
3333
|
+
}
|
|
3334
|
+
`;
|
|
3335
|
+
var $DragIndicator = styled13.div`
|
|
3336
|
+
width: 32px;
|
|
3337
|
+
height: 4px;
|
|
3338
|
+
background: #ccc;
|
|
3339
|
+
border-radius: 2px;
|
|
3340
|
+
`;
|
|
3341
|
+
function DraggableHeader({ onDrag }) {
|
|
3342
|
+
const startPos = useRef3(null);
|
|
3343
|
+
const handleStart = useCallback3((clientX, clientY) => {
|
|
3344
|
+
startPos.current = { x: clientX, y: clientY };
|
|
3345
|
+
}, []);
|
|
3346
|
+
const handleMove = useCallback3((clientX, clientY) => {
|
|
3347
|
+
if (!startPos.current)
|
|
3348
|
+
return;
|
|
3349
|
+
const deltaX = clientX - startPos.current.x;
|
|
3350
|
+
const deltaY = clientY - startPos.current.y;
|
|
3351
|
+
startPos.current = { x: clientX, y: clientY };
|
|
3352
|
+
onDrag(deltaX, deltaY);
|
|
3353
|
+
}, [onDrag]);
|
|
3354
|
+
const handleEnd = useCallback3(() => {
|
|
3355
|
+
startPos.current = null;
|
|
3356
|
+
}, []);
|
|
3357
|
+
const onMouseDown = useCallback3((e) => {
|
|
3358
|
+
e.preventDefault();
|
|
3359
|
+
handleStart(e.clientX, e.clientY);
|
|
3360
|
+
const onMouseMove = (e2) => {
|
|
3361
|
+
handleMove(e2.clientX, e2.clientY);
|
|
3362
|
+
};
|
|
3363
|
+
const onMouseUp = () => {
|
|
3364
|
+
handleEnd();
|
|
3365
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
3366
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
3367
|
+
};
|
|
3368
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
3369
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
3370
|
+
}, [handleStart, handleMove, handleEnd]);
|
|
3371
|
+
const onTouchStart = useCallback3((e) => {
|
|
3372
|
+
if (e.touches.length !== 1)
|
|
3373
|
+
return;
|
|
3374
|
+
const touch = e.touches[0];
|
|
3375
|
+
handleStart(touch.clientX, touch.clientY);
|
|
3376
|
+
}, [handleStart]);
|
|
3377
|
+
const onTouchMove = useCallback3((e) => {
|
|
3378
|
+
if (e.touches.length !== 1)
|
|
3379
|
+
return;
|
|
3380
|
+
const touch = e.touches[0];
|
|
3381
|
+
handleMove(touch.clientX, touch.clientY);
|
|
3382
|
+
}, [handleMove]);
|
|
3383
|
+
const onTouchEnd = useCallback3(() => {
|
|
3384
|
+
handleEnd();
|
|
3385
|
+
}, [handleEnd]);
|
|
3386
|
+
return /* @__PURE__ */ jsx11(
|
|
3387
|
+
$DragHandle,
|
|
3388
|
+
{
|
|
3389
|
+
onMouseDown,
|
|
3390
|
+
onTouchStart,
|
|
3391
|
+
onTouchMove,
|
|
3392
|
+
onTouchEnd,
|
|
3393
|
+
children: /* @__PURE__ */ jsx11($DragIndicator, {})
|
|
3394
|
+
}
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3397
|
+
|
|
3286
3398
|
// src/anchor-plugin/render-element/AnchorEditDialog.tsx
|
|
3287
|
-
import { jsx as
|
|
3288
|
-
var $AnchorEditDialog =
|
|
3399
|
+
import { jsx as jsx12, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3400
|
+
var $AnchorEditDialog = styled14($Panel)`
|
|
3289
3401
|
position: absolute;
|
|
3290
3402
|
width: 20em;
|
|
3291
|
-
padding:
|
|
3403
|
+
padding: 0;
|
|
3404
|
+
overflow: hidden;
|
|
3292
3405
|
`;
|
|
3293
3406
|
function AnchorEditDialog({
|
|
3294
3407
|
destAnchor,
|
|
@@ -3296,7 +3409,11 @@ function AnchorEditDialog({
|
|
|
3296
3409
|
element
|
|
3297
3410
|
}) {
|
|
3298
3411
|
const dialog = useLayer("dialog");
|
|
3299
|
-
const
|
|
3412
|
+
const [dragOffset, setDragOffset] = useState3({ x: 0, y: 0 });
|
|
3413
|
+
const handleDrag = useCallback4((deltaX, deltaY) => {
|
|
3414
|
+
setDragOffset((prev) => ({ x: prev.x + deltaX, y: prev.y + deltaY }));
|
|
3415
|
+
}, []);
|
|
3416
|
+
const baseStyle = useAbsoluteReposition(
|
|
3300
3417
|
{ destAnchor, destStartEdge },
|
|
3301
3418
|
({ destAnchor: destAnchor2, destStartEdge: destStartEdge2 }) => {
|
|
3302
3419
|
return {
|
|
@@ -3305,23 +3422,28 @@ function AnchorEditDialog({
|
|
|
3305
3422
|
};
|
|
3306
3423
|
}
|
|
3307
3424
|
);
|
|
3425
|
+
const style = {
|
|
3426
|
+
...baseStyle,
|
|
3427
|
+
left: baseStyle.left + dragOffset.x,
|
|
3428
|
+
top: baseStyle.top + dragOffset.y
|
|
3429
|
+
};
|
|
3308
3430
|
const editor = useSlateStatic3();
|
|
3309
3431
|
const [href, setHref] = useState3(element.href);
|
|
3310
3432
|
const [text, setText] = useState3(Node6.string(element));
|
|
3311
3433
|
const [title, setTitle] = useState3(element.title || "");
|
|
3312
|
-
const formRef =
|
|
3434
|
+
const formRef = useRef4({ href, text, title });
|
|
3313
3435
|
formRef.current = { href, text, title };
|
|
3314
|
-
const handleHrefChange =
|
|
3436
|
+
const handleHrefChange = useCallback4((e) => {
|
|
3315
3437
|
setHref(e.target.value);
|
|
3316
3438
|
}, []);
|
|
3317
|
-
const handleTextChange =
|
|
3439
|
+
const handleTextChange = useCallback4((e) => {
|
|
3318
3440
|
setText(e.target.value);
|
|
3319
3441
|
}, []);
|
|
3320
|
-
const handleTitleChange =
|
|
3442
|
+
const handleTitleChange = useCallback4((e) => {
|
|
3321
3443
|
setTitle(e.target.value);
|
|
3322
3444
|
}, []);
|
|
3323
|
-
const openAnchorDialog =
|
|
3324
|
-
dialog.open(() => /* @__PURE__ */
|
|
3445
|
+
const openAnchorDialog = useCallback4(() => {
|
|
3446
|
+
dialog.open(() => /* @__PURE__ */ jsx12(
|
|
3325
3447
|
AnchorDialog,
|
|
3326
3448
|
{
|
|
3327
3449
|
destAnchor,
|
|
@@ -3330,45 +3452,49 @@ function AnchorEditDialog({
|
|
|
3330
3452
|
}
|
|
3331
3453
|
));
|
|
3332
3454
|
}, [destAnchor, destStartEdge, element]);
|
|
3333
|
-
const handleSubmit =
|
|
3455
|
+
const handleSubmit = useCallback4(() => {
|
|
3334
3456
|
const { href: href2, text: text2, title: title2 } = formRef.current;
|
|
3335
3457
|
editor.anchor.editLink({ href: href2, text: text2, title: title2 }, { at: element });
|
|
3336
3458
|
openAnchorDialog();
|
|
3337
3459
|
}, [openAnchorDialog]);
|
|
3338
3460
|
return /* @__PURE__ */ jsxs5($AnchorEditDialog, { contentEditable: false, style, children: [
|
|
3339
|
-
/* @__PURE__ */
|
|
3340
|
-
|
|
3341
|
-
/* @__PURE__ */
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
/* @__PURE__ */
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
/* @__PURE__ */
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3461
|
+
/* @__PURE__ */ jsx12(DraggableHeader, { onDrag: handleDrag }),
|
|
3462
|
+
/* @__PURE__ */ jsxs5("div", { style: { padding: "1em" }, children: [
|
|
3463
|
+
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3464
|
+
/* @__PURE__ */ jsx12($FormCaption, { children: t("linkUrl") }),
|
|
3465
|
+
/* @__PURE__ */ jsx12($Textarea, { as: "textarea", value: href, onChange: handleHrefChange })
|
|
3466
|
+
] }),
|
|
3467
|
+
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3468
|
+
/* @__PURE__ */ jsx12($FormCaption, { children: t("linkText") }),
|
|
3469
|
+
/* @__PURE__ */ jsx12($Input, { type: "text", value: text, onChange: handleTextChange }),
|
|
3470
|
+
/* @__PURE__ */ jsx12($FormHint, { children: t("linkTextHint") })
|
|
3471
|
+
] }),
|
|
3472
|
+
/* @__PURE__ */ jsxs5($FormGroup, { children: [
|
|
3473
|
+
/* @__PURE__ */ jsx12($FormCaption, { children: t("tooltipText") }),
|
|
3474
|
+
/* @__PURE__ */ jsx12($Input, { type: "text", value: title, onChange: handleTitleChange }),
|
|
3475
|
+
/* @__PURE__ */ jsx12($FormHint, { children: t("tooltipHint") })
|
|
3476
|
+
] }),
|
|
3477
|
+
/* @__PURE__ */ jsx12($FormGroup, { children: /* @__PURE__ */ jsx12($PrimaryButton, { onClick: handleSubmit, children: t("apply") }) }),
|
|
3478
|
+
/* @__PURE__ */ jsx12($FormGroup, { children: /* @__PURE__ */ jsx12($CancelButton, { onClick: openAnchorDialog, children: t("cancel") }) })
|
|
3479
|
+
] })
|
|
3355
3480
|
] });
|
|
3356
3481
|
}
|
|
3357
3482
|
|
|
3358
3483
|
// src/anchor-plugin/render-element/icons.tsx
|
|
3359
|
-
import { jsx as
|
|
3360
|
-
var ExternalLinkIcon = (props) => /* @__PURE__ */
|
|
3361
|
-
var LinkOffIcon = (props) => /* @__PURE__ */
|
|
3362
|
-
var PencilIcon = (props) => /* @__PURE__ */
|
|
3484
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
3485
|
+
var ExternalLinkIcon = (props) => /* @__PURE__ */ jsx13(TablerIcon, { ...props, children: /* @__PURE__ */ jsx13("path", { d: "M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5" }) });
|
|
3486
|
+
var LinkOffIcon = (props) => /* @__PURE__ */ jsx13(TablerIcon, { ...props, children: /* @__PURE__ */ jsx13("path", { d: "m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11" }) });
|
|
3487
|
+
var PencilIcon = (props) => /* @__PURE__ */ jsx13(TablerIcon, { ...props, children: /* @__PURE__ */ jsx13("path", { d: "M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4" }) });
|
|
3488
|
+
var CloseIcon = (props) => /* @__PURE__ */ jsx13(TablerIcon, { ...props, children: /* @__PURE__ */ jsx13("path", { d: "M18 6L6 18M6 6l12 12" }) });
|
|
3363
3489
|
|
|
3364
3490
|
// src/anchor-plugin/render-element/AnchorDialog.tsx
|
|
3365
|
-
import { jsx as
|
|
3366
|
-
var $AnchorDialog2 =
|
|
3491
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
3492
|
+
var $AnchorDialog2 = styled15($Panel)`
|
|
3367
3493
|
position: absolute;
|
|
3368
|
-
display: flex;
|
|
3369
3494
|
width: 20em;
|
|
3370
|
-
z-index:
|
|
3371
|
-
padding:
|
|
3495
|
+
z-index: 1000;
|
|
3496
|
+
padding: 0;
|
|
3497
|
+
overflow: hidden;
|
|
3372
3498
|
color: var(--shade-400);
|
|
3373
3499
|
|
|
3374
3500
|
.--icons {
|
|
@@ -3464,7 +3590,11 @@ function AnchorDialog({
|
|
|
3464
3590
|
const dialog = useLayer("dialog");
|
|
3465
3591
|
const editor = useSlateStatic4();
|
|
3466
3592
|
const url = parseUrl2(element.href);
|
|
3467
|
-
const
|
|
3593
|
+
const [dragOffset, setDragOffset] = useState4({ x: 0, y: 0 });
|
|
3594
|
+
const handleDrag = useCallback5((deltaX, deltaY) => {
|
|
3595
|
+
setDragOffset((prev) => ({ x: prev.x + deltaX, y: prev.y + deltaY }));
|
|
3596
|
+
}, []);
|
|
3597
|
+
const baseStyle = useAbsoluteReposition(
|
|
3468
3598
|
{ destAnchor, destStartEdge },
|
|
3469
3599
|
({ destAnchor: destAnchor2, destStartEdge: destStartEdge2 }) => {
|
|
3470
3600
|
return {
|
|
@@ -3473,16 +3603,25 @@ function AnchorDialog({
|
|
|
3473
3603
|
};
|
|
3474
3604
|
}
|
|
3475
3605
|
);
|
|
3606
|
+
const style = {
|
|
3607
|
+
...baseStyle,
|
|
3608
|
+
left: baseStyle.left + dragOffset.x,
|
|
3609
|
+
top: baseStyle.top + dragOffset.y
|
|
3610
|
+
};
|
|
3476
3611
|
const removeTooltip = useTooltip({ title: "\u30EA\u30F3\u30AF\u3092\u524A\u9664" });
|
|
3477
3612
|
const editTooltip = useTooltip({ title: "\u30EA\u30F3\u30AF\u3092\u7DE8\u96C6" });
|
|
3478
|
-
const
|
|
3613
|
+
const closeTooltip = useTooltip({ title: "\u9589\u3058\u308B" });
|
|
3614
|
+
const closeDialog = useCallback5(() => {
|
|
3615
|
+
dialog.close();
|
|
3616
|
+
}, [dialog]);
|
|
3617
|
+
const removeLink2 = useCallback5(() => {
|
|
3479
3618
|
editor.anchor.removeLink({ at: element });
|
|
3480
3619
|
dialog.close();
|
|
3481
3620
|
}, [editor, dialog]);
|
|
3482
|
-
const openEditDialog =
|
|
3621
|
+
const openEditDialog = useCallback5(() => {
|
|
3483
3622
|
editTooltip.onMouseLeave();
|
|
3484
3623
|
dialog.open(() => {
|
|
3485
|
-
return /* @__PURE__ */
|
|
3624
|
+
return /* @__PURE__ */ jsx14(
|
|
3486
3625
|
AnchorEditDialog,
|
|
3487
3626
|
{
|
|
3488
3627
|
destAnchor,
|
|
@@ -3493,57 +3632,70 @@ function AnchorDialog({
|
|
|
3493
3632
|
});
|
|
3494
3633
|
}, [destAnchor, destStartEdge, element]);
|
|
3495
3634
|
return /* @__PURE__ */ jsxs6($AnchorDialog2, { contentEditable: false, style, children: [
|
|
3496
|
-
/* @__PURE__ */
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
href: element.href,
|
|
3501
|
-
target: "_blank",
|
|
3502
|
-
rel: "noreferrer",
|
|
3503
|
-
children: [
|
|
3504
|
-
/* @__PURE__ */ jsx13(ExternalLinkIcon, {}),
|
|
3505
|
-
/* @__PURE__ */ jsxs6("div", { className: "--url", children: [
|
|
3506
|
-
/* @__PURE__ */ jsx13("div", { className: "--hostname", children: url.hostname }),
|
|
3507
|
-
url.pathname === "" || url.pathname === "/" ? null : /* @__PURE__ */ jsx13("div", { className: "--pathname", children: url.pathname }),
|
|
3508
|
-
element.title == null || element.title === "" ? null : /* @__PURE__ */ jsx13("div", { className: "--tooltip", children: element.title })
|
|
3509
|
-
] })
|
|
3510
|
-
]
|
|
3511
|
-
}
|
|
3512
|
-
),
|
|
3513
|
-
/* @__PURE__ */ jsxs6("span", { className: "--icons", children: [
|
|
3514
|
-
/* @__PURE__ */ jsx13(
|
|
3515
|
-
"span",
|
|
3635
|
+
/* @__PURE__ */ jsx14(DraggableHeader, { onDrag: handleDrag }),
|
|
3636
|
+
/* @__PURE__ */ jsxs6("div", { style: { display: "flex", padding: "1em" }, children: [
|
|
3637
|
+
/* @__PURE__ */ jsxs6(
|
|
3638
|
+
"a",
|
|
3516
3639
|
{
|
|
3517
|
-
className: "--
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
children:
|
|
3640
|
+
className: "--link",
|
|
3641
|
+
href: element.href,
|
|
3642
|
+
target: "_blank",
|
|
3643
|
+
rel: "noreferrer",
|
|
3644
|
+
children: [
|
|
3645
|
+
/* @__PURE__ */ jsx14(ExternalLinkIcon, {}),
|
|
3646
|
+
/* @__PURE__ */ jsxs6("div", { className: "--url", children: [
|
|
3647
|
+
/* @__PURE__ */ jsx14("div", { className: "--hostname", children: url.hostname }),
|
|
3648
|
+
url.pathname === "" || url.pathname === "/" ? null : /* @__PURE__ */ jsx14("div", { className: "--pathname", children: url.pathname }),
|
|
3649
|
+
element.title == null || element.title === "" ? null : /* @__PURE__ */ jsx14("div", { className: "--tooltip", children: element.title })
|
|
3650
|
+
] })
|
|
3651
|
+
]
|
|
3522
3652
|
}
|
|
3523
3653
|
),
|
|
3524
|
-
/* @__PURE__ */
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3654
|
+
/* @__PURE__ */ jsxs6("span", { className: "--icons", children: [
|
|
3655
|
+
/* @__PURE__ */ jsx14(
|
|
3656
|
+
"span",
|
|
3657
|
+
{
|
|
3658
|
+
className: "--icon",
|
|
3659
|
+
onClick: removeLink2,
|
|
3660
|
+
onMouseEnter: removeTooltip.onMouseEnter,
|
|
3661
|
+
onMouseLeave: removeTooltip.onMouseLeave,
|
|
3662
|
+
children: /* @__PURE__ */ jsx14(LinkOffIcon, {})
|
|
3663
|
+
}
|
|
3664
|
+
),
|
|
3665
|
+
/* @__PURE__ */ jsx14(
|
|
3666
|
+
"span",
|
|
3667
|
+
{
|
|
3668
|
+
className: "--icon",
|
|
3669
|
+
onMouseEnter: editTooltip.onMouseEnter,
|
|
3670
|
+
onMouseLeave: editTooltip.onMouseLeave,
|
|
3671
|
+
onClick: openEditDialog,
|
|
3672
|
+
children: /* @__PURE__ */ jsx14(PencilIcon, {})
|
|
3673
|
+
}
|
|
3674
|
+
),
|
|
3675
|
+
/* @__PURE__ */ jsx14(
|
|
3676
|
+
"span",
|
|
3677
|
+
{
|
|
3678
|
+
className: "--icon",
|
|
3679
|
+
onClick: closeDialog,
|
|
3680
|
+
onMouseEnter: closeTooltip.onMouseEnter,
|
|
3681
|
+
onMouseLeave: closeTooltip.onMouseLeave,
|
|
3682
|
+
children: /* @__PURE__ */ jsx14(CloseIcon, {})
|
|
3683
|
+
}
|
|
3684
|
+
)
|
|
3685
|
+
] })
|
|
3534
3686
|
] })
|
|
3535
3687
|
] });
|
|
3536
3688
|
}
|
|
3537
3689
|
|
|
3538
3690
|
// src/anchor-plugin/render-element/anchor.tsx
|
|
3539
|
-
import { jsx as
|
|
3691
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3540
3692
|
function Anchor({
|
|
3541
3693
|
element,
|
|
3542
3694
|
attributes,
|
|
3543
3695
|
children
|
|
3544
3696
|
}) {
|
|
3545
|
-
const startEdgeRef =
|
|
3546
|
-
const anchorRef =
|
|
3697
|
+
const startEdgeRef = useRef5(null);
|
|
3698
|
+
const anchorRef = useRef5(null);
|
|
3547
3699
|
const selected = useSelected();
|
|
3548
3700
|
const editor = useSlate();
|
|
3549
3701
|
const dialog = useLayer("dialog");
|
|
@@ -3555,7 +3707,7 @@ function Anchor({
|
|
|
3555
3707
|
const hasSelection = editor.selection && editor.selection.anchor.offset !== editor.selection.focus.offset;
|
|
3556
3708
|
if (selected && !hasSelection) {
|
|
3557
3709
|
setTimeout(() => {
|
|
3558
|
-
dialog.open(() => /* @__PURE__ */
|
|
3710
|
+
dialog.open(() => /* @__PURE__ */ jsx15(
|
|
3559
3711
|
AnchorDialog,
|
|
3560
3712
|
{
|
|
3561
3713
|
destAnchor: anchor,
|
|
@@ -3577,16 +3729,16 @@ function Anchor({
|
|
|
3577
3729
|
...attributes,
|
|
3578
3730
|
ref: anchorRef,
|
|
3579
3731
|
children: [
|
|
3580
|
-
/* @__PURE__ */
|
|
3581
|
-
/* @__PURE__ */
|
|
3582
|
-
/* @__PURE__ */
|
|
3732
|
+
/* @__PURE__ */ jsx15($Edge, { ref: startEdgeRef, contentEditable: false }),
|
|
3733
|
+
/* @__PURE__ */ jsx15("span", { children }),
|
|
3734
|
+
/* @__PURE__ */ jsx15($Edge, { contentEditable: false })
|
|
3583
3735
|
]
|
|
3584
3736
|
}
|
|
3585
3737
|
);
|
|
3586
3738
|
}
|
|
3587
3739
|
|
|
3588
3740
|
// src/anchor-plugin/index.tsx
|
|
3589
|
-
import { jsx as
|
|
3741
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
3590
3742
|
var AnchorPlugin = createPlugin(
|
|
3591
3743
|
(editor, _options, { createPolicy }) => {
|
|
3592
3744
|
editor.anchor = createAnchorMethods(editor);
|
|
@@ -3603,7 +3755,7 @@ var AnchorPlugin = createPlugin(
|
|
|
3603
3755
|
onPaste: curryOne(onPaste, editor),
|
|
3604
3756
|
renderElement: ({ element, attributes, children }) => {
|
|
3605
3757
|
if (element.type === "anchor") {
|
|
3606
|
-
return /* @__PURE__ */
|
|
3758
|
+
return /* @__PURE__ */ jsx16(Anchor, { element, attributes, children });
|
|
3607
3759
|
}
|
|
3608
3760
|
}
|
|
3609
3761
|
}
|
|
@@ -3679,8 +3831,7 @@ import { ReactEditor as ReactEditor9 } from "slate-react";
|
|
|
3679
3831
|
// src/image-plugin/methods/index.ts
|
|
3680
3832
|
import { Editor as Editor20, Transforms as Transforms12 } from "slate";
|
|
3681
3833
|
import { ReactEditor as ReactEditor3 } from "slate-react";
|
|
3682
|
-
function noop(
|
|
3683
|
-
editor;
|
|
3834
|
+
function noop(_editor) {
|
|
3684
3835
|
}
|
|
3685
3836
|
function insertImageFromUrl(editor, url, alt, title) {
|
|
3686
3837
|
const { selection } = editor;
|
|
@@ -3707,9 +3858,7 @@ function createImageMethods(editor) {
|
|
|
3707
3858
|
}
|
|
3708
3859
|
|
|
3709
3860
|
// src/image-plugin/normalize-node/index.ts
|
|
3710
|
-
function normalizeNode2(
|
|
3711
|
-
editor;
|
|
3712
|
-
entry;
|
|
3861
|
+
function normalizeNode2(_editor, _entry) {
|
|
3713
3862
|
return false;
|
|
3714
3863
|
}
|
|
3715
3864
|
|
|
@@ -3717,20 +3866,20 @@ function normalizeNode2(editor, entry) {
|
|
|
3717
3866
|
import { useSlateStatic as useSlateStatic9 } from "slate-react";
|
|
3718
3867
|
|
|
3719
3868
|
// src/image-plugin/styles/image-block-styles.tsx
|
|
3720
|
-
import
|
|
3721
|
-
var $ImageBlock =
|
|
3869
|
+
import styled16 from "@emotion/styled";
|
|
3870
|
+
var $ImageBlock = styled16("div")`
|
|
3722
3871
|
display: block;
|
|
3723
3872
|
margin: 1em 0;
|
|
3724
3873
|
`;
|
|
3725
3874
|
|
|
3726
3875
|
// src/image-plugin/render-element/image-with-controls/index.tsx
|
|
3727
3876
|
import { clsx as clsx4 } from "clsx";
|
|
3728
|
-
import { useState as
|
|
3877
|
+
import { useState as useState5 } from "react";
|
|
3729
3878
|
import { useSelected as useSelected2 } from "slate-react";
|
|
3730
3879
|
|
|
3731
3880
|
// src/image-plugin/styles/image-with-controls-styles/image-with-controls-styles.tsx
|
|
3732
|
-
import
|
|
3733
|
-
var $ImageContainer =
|
|
3881
|
+
import styled17 from "@emotion/styled";
|
|
3882
|
+
var $ImageContainer = styled17("span")`
|
|
3734
3883
|
/**
|
|
3735
3884
|
* In order for this container to wrap tightly (without space), it needs to be
|
|
3736
3885
|
* an "inline-block". If it's just an "inline" we end up with spacing
|
|
@@ -3743,7 +3892,7 @@ var $ImageContainer = styled16("span")`
|
|
|
3743
3892
|
*/
|
|
3744
3893
|
position: relative;
|
|
3745
3894
|
`;
|
|
3746
|
-
var $Image =
|
|
3895
|
+
var $Image = styled17("img")`
|
|
3747
3896
|
/**
|
|
3748
3897
|
* TODO:
|
|
3749
3898
|
*
|
|
@@ -3809,7 +3958,7 @@ var $Image = styled16("img")`
|
|
|
3809
3958
|
|
|
3810
3959
|
// src/image-plugin/render-element/image-with-controls/image-resize-controls/image-resize-control.tsx
|
|
3811
3960
|
import { clsx as clsx2 } from "clsx";
|
|
3812
|
-
import { useCallback as
|
|
3961
|
+
import { useCallback as useCallback6 } from "react";
|
|
3813
3962
|
import { Transforms as Transforms13 } from "slate";
|
|
3814
3963
|
import { ReactEditor as ReactEditor5, useSlateStatic as useSlateStatic5 } from "slate-react";
|
|
3815
3964
|
|
|
@@ -3828,8 +3977,8 @@ function useResizeBrowser() {
|
|
|
3828
3977
|
}
|
|
3829
3978
|
|
|
3830
3979
|
// src/image-plugin/styles/image-with-controls-styles/image-resize-handle-styles.tsx
|
|
3831
|
-
import
|
|
3832
|
-
var $ImageResizeInvisibleHandle =
|
|
3980
|
+
import styled18 from "@emotion/styled";
|
|
3981
|
+
var $ImageResizeInvisibleHandle = styled18("span")`
|
|
3833
3982
|
position: absolute;
|
|
3834
3983
|
display: block;
|
|
3835
3984
|
/**
|
|
@@ -3857,7 +4006,7 @@ var $ImageResizeInvisibleHandle = styled17("span")`
|
|
|
3857
4006
|
width: 1.25em;
|
|
3858
4007
|
}
|
|
3859
4008
|
`;
|
|
3860
|
-
var $ImageResizeHandle =
|
|
4009
|
+
var $ImageResizeHandle = styled18("span")`
|
|
3861
4010
|
position: absolute;
|
|
3862
4011
|
display: block;
|
|
3863
4012
|
background: var(--select-color);
|
|
@@ -4008,7 +4157,7 @@ function getEditorWidth(editor) {
|
|
|
4008
4157
|
}
|
|
4009
4158
|
|
|
4010
4159
|
// src/image-plugin/render-element/image-with-controls/image-resize-controls/image-resize-control.tsx
|
|
4011
|
-
import { Fragment as Fragment3, jsx as
|
|
4160
|
+
import { Fragment as Fragment3, jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4012
4161
|
function getImageBoundsFromSlateElement(editor, element) {
|
|
4013
4162
|
const imageContainerDOMNode = ReactEditor5.toDOMNode(editor, element);
|
|
4014
4163
|
const imgDOMNode = imageContainerDOMNode.querySelector("img");
|
|
@@ -4030,7 +4179,7 @@ function ImageResizeControl({
|
|
|
4030
4179
|
const width = size.width;
|
|
4031
4180
|
const maxWidth = Math.min(srcSize.width, editorWidth);
|
|
4032
4181
|
const minWidth = Math.min(12, srcSize.width);
|
|
4033
|
-
const onMouseDown =
|
|
4182
|
+
const onMouseDown = useCallback6(
|
|
4034
4183
|
(e) => {
|
|
4035
4184
|
stopEvent(e);
|
|
4036
4185
|
setIsDragging(true);
|
|
@@ -4064,7 +4213,7 @@ function ImageResizeControl({
|
|
|
4064
4213
|
},
|
|
4065
4214
|
[srcSize.width, srcSize.height, size.width, element]
|
|
4066
4215
|
);
|
|
4067
|
-
const onTouchStart =
|
|
4216
|
+
const onTouchStart = useCallback6(
|
|
4068
4217
|
(e) => {
|
|
4069
4218
|
stopEvent(e);
|
|
4070
4219
|
setIsDragging(true);
|
|
@@ -4104,24 +4253,24 @@ function ImageResizeControl({
|
|
|
4104
4253
|
"--dragging": isDragging,
|
|
4105
4254
|
"--small": width <= 64 || size.height <= 64
|
|
4106
4255
|
});
|
|
4107
|
-
return /* @__PURE__ */
|
|
4256
|
+
return /* @__PURE__ */ jsx17(Fragment3, { children: /* @__PURE__ */ jsx17(
|
|
4108
4257
|
$ImageResizeInvisibleHandle,
|
|
4109
4258
|
{
|
|
4110
4259
|
className,
|
|
4111
4260
|
onMouseDown,
|
|
4112
4261
|
onTouchStart,
|
|
4113
4262
|
children: /* @__PURE__ */ jsxs8($ImageResizeHandle, { children: [
|
|
4114
|
-
/* @__PURE__ */
|
|
4115
|
-
/* @__PURE__ */
|
|
4116
|
-
/* @__PURE__ */
|
|
4263
|
+
/* @__PURE__ */ jsx17("span", { className: "--bar --bar-left" }),
|
|
4264
|
+
/* @__PURE__ */ jsx17("span", { className: "--bar --bar-center" }),
|
|
4265
|
+
/* @__PURE__ */ jsx17("span", { className: "--bar --bar-right" })
|
|
4117
4266
|
] })
|
|
4118
4267
|
}
|
|
4119
4268
|
) });
|
|
4120
4269
|
}
|
|
4121
4270
|
|
|
4122
4271
|
// src/image-plugin/styles/image-with-controls-styles/image-size-status-styles.tsx
|
|
4123
|
-
import
|
|
4124
|
-
var $ImageSizeStatus =
|
|
4272
|
+
import styled19 from "@emotion/styled";
|
|
4273
|
+
var $ImageSizeStatus = styled19("span")`
|
|
4125
4274
|
position: absolute;
|
|
4126
4275
|
/**
|
|
4127
4276
|
* The status appears with a 1px gap from the outline.
|
|
@@ -4156,8 +4305,8 @@ function ImageSizeStatus({ size }) {
|
|
|
4156
4305
|
}
|
|
4157
4306
|
|
|
4158
4307
|
// src/image-plugin/styles/image-with-controls-styles/image-toolbar-styles.tsx
|
|
4159
|
-
import
|
|
4160
|
-
var $ImageToolbar =
|
|
4308
|
+
import styled20 from "@emotion/styled";
|
|
4309
|
+
var $ImageToolbar = styled20("span")`
|
|
4161
4310
|
position: absolute;
|
|
4162
4311
|
/**
|
|
4163
4312
|
* On top of the image +1 for space inside outline, +2 for outline,
|
|
@@ -4191,8 +4340,8 @@ var $ImageToolbar = styled19("span")`
|
|
|
4191
4340
|
`;
|
|
4192
4341
|
|
|
4193
4342
|
// src/image-plugin/styles/image-with-controls-styles/image-buttons-styles.tsx
|
|
4194
|
-
import
|
|
4195
|
-
var $ImageButtonGroup =
|
|
4343
|
+
import styled21 from "@emotion/styled";
|
|
4344
|
+
var $ImageButtonGroup = styled21("span")`
|
|
4196
4345
|
/* font-size: 0.75em; */
|
|
4197
4346
|
border-radius: 0.5em;
|
|
4198
4347
|
display: flex;
|
|
@@ -4206,7 +4355,7 @@ var $ImageButtonGroup = styled20("span")`
|
|
|
4206
4355
|
*/
|
|
4207
4356
|
outline: 1px solid white;
|
|
4208
4357
|
`;
|
|
4209
|
-
var $ImageButton =
|
|
4358
|
+
var $ImageButton = styled21("span")`
|
|
4210
4359
|
font-size: 0.75em;
|
|
4211
4360
|
line-height: 2em;
|
|
4212
4361
|
padding: 0 0.625em;
|
|
@@ -4264,10 +4413,10 @@ var $ImageButton = styled20("span")`
|
|
|
4264
4413
|
|
|
4265
4414
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-preset-buttons/image-preset-button.tsx
|
|
4266
4415
|
import { clsx as clsx3 } from "clsx";
|
|
4267
|
-
import { useCallback as
|
|
4416
|
+
import { useCallback as useCallback7 } from "react";
|
|
4268
4417
|
import { Transforms as Transforms14 } from "slate";
|
|
4269
4418
|
import { ReactEditor as ReactEditor6, useSlateStatic as useSlateStatic6 } from "slate-react";
|
|
4270
|
-
import { jsx as
|
|
4419
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
4271
4420
|
function ImagePresetButton({
|
|
4272
4421
|
element,
|
|
4273
4422
|
preset,
|
|
@@ -4281,7 +4430,7 @@ function ImagePresetButton({
|
|
|
4281
4430
|
title: preset.title,
|
|
4282
4431
|
hotkey: `${presetSize.width}x${presetSize.height}`
|
|
4283
4432
|
});
|
|
4284
|
-
const onClick =
|
|
4433
|
+
const onClick = useCallback7(() => {
|
|
4285
4434
|
const path = ReactEditor6.findPath(editor, element);
|
|
4286
4435
|
const nextSize = resizeInPreset(size, srcSize, preset);
|
|
4287
4436
|
setSize(nextSize);
|
|
@@ -4294,7 +4443,7 @@ function ImagePresetButton({
|
|
|
4294
4443
|
"--disabled": isDisabled,
|
|
4295
4444
|
"--selected": !isDisabled && isSelected
|
|
4296
4445
|
});
|
|
4297
|
-
return /* @__PURE__ */
|
|
4446
|
+
return /* @__PURE__ */ jsx18(
|
|
4298
4447
|
$ImageButton,
|
|
4299
4448
|
{
|
|
4300
4449
|
className,
|
|
@@ -4307,7 +4456,7 @@ function ImagePresetButton({
|
|
|
4307
4456
|
}
|
|
4308
4457
|
|
|
4309
4458
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-preset-buttons/image-preset-button-group.tsx
|
|
4310
|
-
import { jsx as
|
|
4459
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
4311
4460
|
function ImagePresetButtonGroup({
|
|
4312
4461
|
element,
|
|
4313
4462
|
size,
|
|
@@ -4315,8 +4464,8 @@ function ImagePresetButtonGroup({
|
|
|
4315
4464
|
srcSize,
|
|
4316
4465
|
presets
|
|
4317
4466
|
}) {
|
|
4318
|
-
return /* @__PURE__ */
|
|
4319
|
-
return /* @__PURE__ */
|
|
4467
|
+
return /* @__PURE__ */ jsx19($ImageButtonGroup, { children: presets.map((preset, i) => {
|
|
4468
|
+
return /* @__PURE__ */ jsx19(
|
|
4320
4469
|
ImagePresetButton,
|
|
4321
4470
|
{
|
|
4322
4471
|
element,
|
|
@@ -4331,18 +4480,18 @@ function ImagePresetButtonGroup({
|
|
|
4331
4480
|
}
|
|
4332
4481
|
|
|
4333
4482
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/block-image-type-button.tsx
|
|
4334
|
-
import { useCallback as
|
|
4483
|
+
import { useCallback as useCallback8 } from "react";
|
|
4335
4484
|
import { useSlateStatic as useSlateStatic7 } from "slate-react";
|
|
4336
4485
|
|
|
4337
4486
|
// src/image-plugin/render-element/icons.tsx
|
|
4338
|
-
import { jsx as
|
|
4487
|
+
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4339
4488
|
var BlockIcon = (props) => /* @__PURE__ */ jsxs10(TablerIcon, { ...props, children: [
|
|
4340
|
-
/* @__PURE__ */
|
|
4341
|
-
/* @__PURE__ */
|
|
4489
|
+
/* @__PURE__ */ jsx20("rect", { width: 6, height: 6, x: 4, y: 5, rx: 1 }),
|
|
4490
|
+
/* @__PURE__ */ jsx20("path", { d: "M4 15h16M4 19h16" })
|
|
4342
4491
|
] });
|
|
4343
4492
|
var InlineIcon = (props) => /* @__PURE__ */ jsxs10(TablerIcon, { ...props, children: [
|
|
4344
|
-
/* @__PURE__ */
|
|
4345
|
-
/* @__PURE__ */
|
|
4493
|
+
/* @__PURE__ */ jsx20("rect", { width: 6, height: 6, x: 9, y: 5, rx: 1 }),
|
|
4494
|
+
/* @__PURE__ */ jsx20("path", { d: "M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16" })
|
|
4346
4495
|
] });
|
|
4347
4496
|
|
|
4348
4497
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-inline-image.tsx
|
|
@@ -4376,7 +4525,7 @@ function convertToInlineImage(editor, element) {
|
|
|
4376
4525
|
}
|
|
4377
4526
|
|
|
4378
4527
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/block-image-type-button.tsx
|
|
4379
|
-
import { jsx as
|
|
4528
|
+
import { jsx as jsx21 } from "react/jsx-runtime";
|
|
4380
4529
|
function BlockImageTypeButton({
|
|
4381
4530
|
element
|
|
4382
4531
|
}) {
|
|
@@ -4385,25 +4534,25 @@ function BlockImageTypeButton({
|
|
|
4385
4534
|
title: "Inline Image",
|
|
4386
4535
|
hotkey: "In a line with text"
|
|
4387
4536
|
});
|
|
4388
|
-
const onClickInline =
|
|
4537
|
+
const onClickInline = useCallback8(() => {
|
|
4389
4538
|
if (element.type !== "image-block")
|
|
4390
4539
|
return;
|
|
4391
4540
|
convertToInlineImage(editor, element);
|
|
4392
4541
|
}, [editor, element]);
|
|
4393
|
-
return /* @__PURE__ */
|
|
4542
|
+
return /* @__PURE__ */ jsx21(
|
|
4394
4543
|
$ImageButton,
|
|
4395
4544
|
{
|
|
4396
4545
|
className: element.type === "image-inline" ? "--selected" : "",
|
|
4397
4546
|
onClick: element.type === "image-inline" ? void 0 : onClickInline,
|
|
4398
4547
|
onMouseEnter: tooltip.onMouseEnter,
|
|
4399
4548
|
onMouseLeave: tooltip.onMouseLeave,
|
|
4400
|
-
children: /* @__PURE__ */
|
|
4549
|
+
children: /* @__PURE__ */ jsx21(InlineIcon, {})
|
|
4401
4550
|
}
|
|
4402
4551
|
);
|
|
4403
4552
|
}
|
|
4404
4553
|
|
|
4405
4554
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/inline-image-type-button.tsx
|
|
4406
|
-
import { useCallback as
|
|
4555
|
+
import { useCallback as useCallback9 } from "react";
|
|
4407
4556
|
import { useSlateStatic as useSlateStatic8 } from "slate-react";
|
|
4408
4557
|
|
|
4409
4558
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-block-image.tsx
|
|
@@ -4456,7 +4605,7 @@ function convertToBlockImage(editor, element) {
|
|
|
4456
4605
|
}
|
|
4457
4606
|
|
|
4458
4607
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/inline-image-type-button.tsx
|
|
4459
|
-
import { jsx as
|
|
4608
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
4460
4609
|
function InlineImageTypeButton({
|
|
4461
4610
|
element
|
|
4462
4611
|
}) {
|
|
@@ -4465,36 +4614,36 @@ function InlineImageTypeButton({
|
|
|
4465
4614
|
title: "Block Image",
|
|
4466
4615
|
hotkey: "On a line by itself"
|
|
4467
4616
|
});
|
|
4468
|
-
const onClickBlock =
|
|
4617
|
+
const onClickBlock = useCallback9(() => {
|
|
4469
4618
|
if (element.type !== "image-inline")
|
|
4470
4619
|
return;
|
|
4471
4620
|
convertToBlockImage(editor, element);
|
|
4472
4621
|
}, [editor, element]);
|
|
4473
|
-
return /* @__PURE__ */
|
|
4622
|
+
return /* @__PURE__ */ jsx22(
|
|
4474
4623
|
$ImageButton,
|
|
4475
4624
|
{
|
|
4476
4625
|
className: element.type === "image-block" ? "--selected" : "",
|
|
4477
4626
|
onClick: element.type === "image-block" ? void 0 : onClickBlock,
|
|
4478
4627
|
onMouseEnter: tooltip.onMouseEnter,
|
|
4479
4628
|
onMouseLeave: tooltip.onMouseLeave,
|
|
4480
|
-
children: /* @__PURE__ */
|
|
4629
|
+
children: /* @__PURE__ */ jsx22(BlockIcon, {})
|
|
4481
4630
|
}
|
|
4482
4631
|
);
|
|
4483
4632
|
}
|
|
4484
4633
|
|
|
4485
4634
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/image-type-button-group.tsx
|
|
4486
|
-
import { jsx as
|
|
4635
|
+
import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4487
4636
|
function ImageTypeButtonGroup({
|
|
4488
4637
|
element
|
|
4489
4638
|
}) {
|
|
4490
4639
|
return /* @__PURE__ */ jsxs11($ImageButtonGroup, { children: [
|
|
4491
|
-
/* @__PURE__ */
|
|
4492
|
-
/* @__PURE__ */
|
|
4640
|
+
/* @__PURE__ */ jsx23(InlineImageTypeButton, { element }),
|
|
4641
|
+
/* @__PURE__ */ jsx23(BlockImageTypeButton, { element })
|
|
4493
4642
|
] });
|
|
4494
4643
|
}
|
|
4495
4644
|
|
|
4496
4645
|
// src/image-plugin/render-element/image-with-controls/image-toolbar/image-toolbar.tsx
|
|
4497
|
-
import { jsx as
|
|
4646
|
+
import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4498
4647
|
function ImageToolbar({
|
|
4499
4648
|
element,
|
|
4500
4649
|
size,
|
|
@@ -4503,8 +4652,8 @@ function ImageToolbar({
|
|
|
4503
4652
|
presets
|
|
4504
4653
|
}) {
|
|
4505
4654
|
return /* @__PURE__ */ jsxs12($ImageToolbar, { children: [
|
|
4506
|
-
/* @__PURE__ */
|
|
4507
|
-
/* @__PURE__ */
|
|
4655
|
+
/* @__PURE__ */ jsx24(ImageTypeButtonGroup, { element }),
|
|
4656
|
+
/* @__PURE__ */ jsx24(
|
|
4508
4657
|
ImagePresetButtonGroup,
|
|
4509
4658
|
{
|
|
4510
4659
|
element,
|
|
@@ -4518,15 +4667,15 @@ function ImageToolbar({
|
|
|
4518
4667
|
}
|
|
4519
4668
|
|
|
4520
4669
|
// src/image-plugin/render-element/image-with-controls/index.tsx
|
|
4521
|
-
import { jsx as
|
|
4670
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
4522
4671
|
function ImageWithControls({
|
|
4523
4672
|
element,
|
|
4524
4673
|
presets
|
|
4525
4674
|
}) {
|
|
4526
4675
|
const url = element.url;
|
|
4527
4676
|
const selected = useSelected2();
|
|
4528
|
-
const [isDragging, setIsDragging] =
|
|
4529
|
-
const [size, setSize] =
|
|
4677
|
+
const [isDragging, setIsDragging] = useState5(false);
|
|
4678
|
+
const [size, setSize] = useState5(
|
|
4530
4679
|
element.srcWidth && element.srcHeight && element.width && element.height ? { width: element.width, height: element.height } : null
|
|
4531
4680
|
);
|
|
4532
4681
|
const srcSize = element.srcWidth && element.srcHeight ? { width: element.srcWidth, height: element.srcHeight } : null;
|
|
@@ -4537,8 +4686,8 @@ function ImageWithControls({
|
|
|
4537
4686
|
"--small": size && (size.width <= 64 || size.height <= 64)
|
|
4538
4687
|
});
|
|
4539
4688
|
return /* @__PURE__ */ jsxs13($ImageContainer, { className, children: [
|
|
4540
|
-
/* @__PURE__ */
|
|
4541
|
-
showControls ? /* @__PURE__ */
|
|
4689
|
+
/* @__PURE__ */ jsx25($Image, { src: url, width: size?.width, height: size?.height }),
|
|
4690
|
+
showControls ? /* @__PURE__ */ jsx25(
|
|
4542
4691
|
ImageToolbar,
|
|
4543
4692
|
{
|
|
4544
4693
|
element,
|
|
@@ -4548,8 +4697,8 @@ function ImageWithControls({
|
|
|
4548
4697
|
presets
|
|
4549
4698
|
}
|
|
4550
4699
|
) : null,
|
|
4551
|
-
isDragging && size ? /* @__PURE__ */
|
|
4552
|
-
showControls ? /* @__PURE__ */
|
|
4700
|
+
isDragging && size ? /* @__PURE__ */ jsx25(ImageSizeStatus, { size }) : null,
|
|
4701
|
+
showControls ? /* @__PURE__ */ jsx25(
|
|
4553
4702
|
ImageResizeControl,
|
|
4554
4703
|
{
|
|
4555
4704
|
element,
|
|
@@ -4564,7 +4713,7 @@ function ImageWithControls({
|
|
|
4564
4713
|
}
|
|
4565
4714
|
|
|
4566
4715
|
// src/image-plugin/render-element/image-block.tsx
|
|
4567
|
-
import { jsx as
|
|
4716
|
+
import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
4568
4717
|
function ImageBlock({
|
|
4569
4718
|
element,
|
|
4570
4719
|
attributes,
|
|
@@ -4572,7 +4721,7 @@ function ImageBlock({
|
|
|
4572
4721
|
}) {
|
|
4573
4722
|
const editor = useSlateStatic9();
|
|
4574
4723
|
return /* @__PURE__ */ jsxs14("div", { ...attributes, children: [
|
|
4575
|
-
/* @__PURE__ */
|
|
4724
|
+
/* @__PURE__ */ jsx26($ImageBlock, { contentEditable: false, children: /* @__PURE__ */ jsx26(
|
|
4576
4725
|
ImageWithControls,
|
|
4577
4726
|
{
|
|
4578
4727
|
element,
|
|
@@ -4587,13 +4736,13 @@ function ImageBlock({
|
|
|
4587
4736
|
import { useSlateStatic as useSlateStatic10 } from "slate-react";
|
|
4588
4737
|
|
|
4589
4738
|
// src/image-plugin/styles/image-inline-styles.tsx
|
|
4590
|
-
import
|
|
4591
|
-
var $ImageInline =
|
|
4739
|
+
import styled22 from "@emotion/styled";
|
|
4740
|
+
var $ImageInline = styled22("span")`
|
|
4592
4741
|
display: inline;
|
|
4593
4742
|
`;
|
|
4594
4743
|
|
|
4595
4744
|
// src/image-plugin/render-element/image-inline.tsx
|
|
4596
|
-
import { jsx as
|
|
4745
|
+
import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
4597
4746
|
function ImageInline({
|
|
4598
4747
|
element,
|
|
4599
4748
|
attributes,
|
|
@@ -4601,7 +4750,7 @@ function ImageInline({
|
|
|
4601
4750
|
}) {
|
|
4602
4751
|
const editor = useSlateStatic10();
|
|
4603
4752
|
return /* @__PURE__ */ jsxs15("span", { ...attributes, style: { display: "inline-block" }, children: [
|
|
4604
|
-
/* @__PURE__ */
|
|
4753
|
+
/* @__PURE__ */ jsx27($ImageInline, { contentEditable: false, children: /* @__PURE__ */ jsx27(
|
|
4605
4754
|
ImageWithControls,
|
|
4606
4755
|
{
|
|
4607
4756
|
element,
|
|
@@ -4613,7 +4762,7 @@ function ImageInline({
|
|
|
4613
4762
|
}
|
|
4614
4763
|
|
|
4615
4764
|
// src/image-plugin/render-element/index.tsx
|
|
4616
|
-
import { jsx as
|
|
4765
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
4617
4766
|
function renderElement({
|
|
4618
4767
|
element,
|
|
4619
4768
|
attributes,
|
|
@@ -4621,9 +4770,9 @@ function renderElement({
|
|
|
4621
4770
|
}) {
|
|
4622
4771
|
switch (element.type) {
|
|
4623
4772
|
case "image-block":
|
|
4624
|
-
return /* @__PURE__ */
|
|
4773
|
+
return /* @__PURE__ */ jsx28(ImageBlock, { element, attributes, children });
|
|
4625
4774
|
case "image-inline":
|
|
4626
|
-
return /* @__PURE__ */
|
|
4775
|
+
return /* @__PURE__ */ jsx28(ImageInline, { element, attributes, children });
|
|
4627
4776
|
}
|
|
4628
4777
|
}
|
|
4629
4778
|
|
|
@@ -4761,8 +4910,8 @@ var ImagePlugin = (
|
|
|
4761
4910
|
import { Editor as Editor25, Element as Element11, Transforms as Transforms18 } from "slate";
|
|
4762
4911
|
|
|
4763
4912
|
// src/block-quote-plugin/styles.tsx
|
|
4764
|
-
import
|
|
4765
|
-
var $BlockQuote =
|
|
4913
|
+
import styled23 from "@emotion/styled";
|
|
4914
|
+
var $BlockQuote = styled23("blockquote")`
|
|
4766
4915
|
position: relative;
|
|
4767
4916
|
margin-top: 1em;
|
|
4768
4917
|
margin-bottom: 1em;
|
|
@@ -4772,7 +4921,7 @@ var $BlockQuote = styled22("blockquote")`
|
|
|
4772
4921
|
`;
|
|
4773
4922
|
|
|
4774
4923
|
// src/block-quote-plugin/index.tsx
|
|
4775
|
-
import { jsx as
|
|
4924
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
4776
4925
|
function matchBlockQuoteSafe(node) {
|
|
4777
4926
|
return Element11.isElement(node) && /**
|
|
4778
4927
|
* TODO:
|
|
@@ -4885,7 +5034,7 @@ var BlockQuotePlugin = createPlugin(
|
|
|
4885
5034
|
editableProps: {
|
|
4886
5035
|
renderElement: ({ element, attributes, children }) => {
|
|
4887
5036
|
if (element.type === "block-quote") {
|
|
4888
|
-
return /* @__PURE__ */
|
|
5037
|
+
return /* @__PURE__ */ jsx29($BlockQuote, { ...attributes, children });
|
|
4889
5038
|
}
|
|
4890
5039
|
},
|
|
4891
5040
|
onKeyDown: createHotkeyHandler({
|
|
@@ -5033,6 +5182,17 @@ var tokenStyles = {
|
|
|
5033
5182
|
italic: italicStyle
|
|
5034
5183
|
};
|
|
5035
5184
|
|
|
5185
|
+
// src/code-block-plugin/types.tsx
|
|
5186
|
+
var LanguageList = [
|
|
5187
|
+
"text",
|
|
5188
|
+
"html",
|
|
5189
|
+
"css",
|
|
5190
|
+
"svg",
|
|
5191
|
+
"javascript",
|
|
5192
|
+
"java",
|
|
5193
|
+
"c"
|
|
5194
|
+
];
|
|
5195
|
+
|
|
5036
5196
|
// src/code-block-plugin/normalizeNode.tsx
|
|
5037
5197
|
import { Element as Element14, Node as Node9, Transforms as Transforms20 } from "slate";
|
|
5038
5198
|
function normalizeNode3(editor, entry) {
|
|
@@ -5077,12 +5237,16 @@ function normalizeNode3(editor, entry) {
|
|
|
5077
5237
|
}
|
|
5078
5238
|
|
|
5079
5239
|
// src/code-block-plugin/render-element/CodeBlock.tsx
|
|
5080
|
-
import { useCallback as
|
|
5081
|
-
import { useSelected as useSelected3
|
|
5240
|
+
import { useCallback as useCallback10, useRef as useRef6 } from "react";
|
|
5241
|
+
import { useSelected as useSelected3 } from "slate-react";
|
|
5242
|
+
|
|
5243
|
+
// src/code-block-plugin/icons/ChevronDownIcon.tsx
|
|
5244
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
5245
|
+
var ChevronDownIcon = (props) => /* @__PURE__ */ jsx30(TablerIcon, { ...props, children: /* @__PURE__ */ jsx30("path", { d: "m6 9 6 6 6-6" }) });
|
|
5082
5246
|
|
|
5083
5247
|
// src/code-block-plugin/styles.ts
|
|
5084
|
-
import
|
|
5085
|
-
var $CodeBlock =
|
|
5248
|
+
import styled24 from "@emotion/styled";
|
|
5249
|
+
var $CodeBlock = styled24("div")`
|
|
5086
5250
|
position: relative;
|
|
5087
5251
|
background: var(--code-block-bgcolor);
|
|
5088
5252
|
margin: 1em 0;
|
|
@@ -5102,12 +5266,12 @@ var $CodeBlock = styled23("div")`
|
|
|
5102
5266
|
*/
|
|
5103
5267
|
overflow-x: hidden;
|
|
5104
5268
|
`;
|
|
5105
|
-
var $CodeBlockScroller =
|
|
5269
|
+
var $CodeBlockScroller = styled24("div")`
|
|
5106
5270
|
padding: 2.25em 1em 1.5em 1em;
|
|
5107
5271
|
border-radius: 0.5em;
|
|
5108
5272
|
overflow-x: auto;
|
|
5109
5273
|
`;
|
|
5110
|
-
var $CodeBlockLanguage =
|
|
5274
|
+
var $CodeBlockLanguage = styled24("span")`
|
|
5111
5275
|
cursor: pointer;
|
|
5112
5276
|
position: absolute;
|
|
5113
5277
|
top: 0.25em;
|
|
@@ -5134,7 +5298,7 @@ var $CodeBlockLanguage = styled23("span")`
|
|
|
5134
5298
|
background: var(--shade-300);
|
|
5135
5299
|
}
|
|
5136
5300
|
`;
|
|
5137
|
-
var $CodeBlockLine =
|
|
5301
|
+
var $CodeBlockLine = styled24("div")`
|
|
5138
5302
|
white-space: pre;
|
|
5139
5303
|
line-height: 1.5em;
|
|
5140
5304
|
counter-increment: line;
|
|
@@ -5160,70 +5324,50 @@ var $CodeBlockLine = styled23("div")`
|
|
|
5160
5324
|
`;
|
|
5161
5325
|
|
|
5162
5326
|
// src/code-block-plugin/render-element/CodeBlock.tsx
|
|
5163
|
-
import { jsx as
|
|
5327
|
+
import { jsx as jsx31, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
5164
5328
|
function CodeBlock({
|
|
5165
5329
|
element,
|
|
5166
5330
|
attributes,
|
|
5167
5331
|
children
|
|
5168
5332
|
}) {
|
|
5169
|
-
const
|
|
5333
|
+
const ref = useRef6(null);
|
|
5170
5334
|
const selected = useSelected3();
|
|
5171
|
-
const
|
|
5172
|
-
const
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
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]);
|
|
5192
|
-
return /* @__PURE__ */ jsxs16($CodeBlock, { className: selected ? "--selected" : "", ...attributes, children: [
|
|
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"
|
|
5335
|
+
const dropdown = useLayer("code-block-dropdown");
|
|
5336
|
+
const onClick = useCallback10(() => {
|
|
5337
|
+
if (dropdown.layer)
|
|
5338
|
+
dropdown.close();
|
|
5339
|
+
const dest = ref.current;
|
|
5340
|
+
if (dest === null)
|
|
5341
|
+
return;
|
|
5342
|
+
const items = LanguageList.map((language) => {
|
|
5343
|
+
return {
|
|
5344
|
+
icon: () => /* @__PURE__ */ jsx31("span", {}),
|
|
5345
|
+
title: language,
|
|
5346
|
+
action: (editor) => {
|
|
5347
|
+
editor.codeBlock.setCodeBlockLanguage(language, { at: element });
|
|
5211
5348
|
}
|
|
5212
|
-
}
|
|
5213
|
-
|
|
5214
|
-
/* @__PURE__ */
|
|
5349
|
+
};
|
|
5350
|
+
});
|
|
5351
|
+
dropdown.open(() => /* @__PURE__ */ jsx31(Menu, { dest, items, close: dropdown.close }));
|
|
5352
|
+
}, [element]);
|
|
5353
|
+
return /* @__PURE__ */ jsxs16($CodeBlock, { className: selected ? "--selected" : "", ...attributes, children: [
|
|
5354
|
+
/* @__PURE__ */ jsxs16($CodeBlockLanguage, { contentEditable: false, onClick, ref, children: [
|
|
5355
|
+
/* @__PURE__ */ jsx31("span", { children: element.language }),
|
|
5356
|
+
/* @__PURE__ */ jsx31(ChevronDownIcon, {})
|
|
5357
|
+
] }),
|
|
5358
|
+
/* @__PURE__ */ jsx31($CodeBlockScroller, { children })
|
|
5215
5359
|
] });
|
|
5216
5360
|
}
|
|
5217
5361
|
|
|
5218
5362
|
// src/code-block-plugin/render-element/CodeBlockLine.tsx
|
|
5219
5363
|
import { useSelected as useSelected4 } from "slate-react";
|
|
5220
|
-
import { jsx as
|
|
5364
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
5221
5365
|
function CodeBlockLine({
|
|
5222
5366
|
attributes,
|
|
5223
5367
|
children
|
|
5224
5368
|
}) {
|
|
5225
5369
|
const selected = useSelected4();
|
|
5226
|
-
return /* @__PURE__ */
|
|
5370
|
+
return /* @__PURE__ */ jsx32(
|
|
5227
5371
|
$CodeBlockLine,
|
|
5228
5372
|
{
|
|
5229
5373
|
className: selected ? "--selected" : "",
|
|
@@ -5235,21 +5379,21 @@ function CodeBlockLine({
|
|
|
5235
5379
|
}
|
|
5236
5380
|
|
|
5237
5381
|
// src/code-block-plugin/render-element/index.tsx
|
|
5238
|
-
import { jsx as
|
|
5382
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
5239
5383
|
function renderElement2({
|
|
5240
5384
|
element,
|
|
5241
5385
|
attributes,
|
|
5242
5386
|
children
|
|
5243
5387
|
}) {
|
|
5244
5388
|
if (element.type === "code-block") {
|
|
5245
|
-
return /* @__PURE__ */
|
|
5389
|
+
return /* @__PURE__ */ jsx33(CodeBlock, { element, attributes, children });
|
|
5246
5390
|
} else if (element.type === "code-block-line") {
|
|
5247
|
-
return /* @__PURE__ */
|
|
5391
|
+
return /* @__PURE__ */ jsx33(CodeBlockLine, { element, attributes, children });
|
|
5248
5392
|
}
|
|
5249
5393
|
}
|
|
5250
5394
|
|
|
5251
5395
|
// src/code-block-plugin/index.tsx
|
|
5252
|
-
import { jsx as
|
|
5396
|
+
import { jsx as jsx34 } from "react/jsx-runtime";
|
|
5253
5397
|
var CodeBlockPlugin = createPlugin(
|
|
5254
5398
|
(editor, _options, { createPolicy }) => {
|
|
5255
5399
|
editor.codeBlock = createCodeBlockMethods(editor);
|
|
@@ -5307,7 +5451,98 @@ var CodeBlockPlugin = createPlugin(
|
|
|
5307
5451
|
if (style === null) {
|
|
5308
5452
|
return children;
|
|
5309
5453
|
} else {
|
|
5310
|
-
return /* @__PURE__ */
|
|
5454
|
+
return /* @__PURE__ */ jsx34("span", { style, children });
|
|
5455
|
+
}
|
|
5456
|
+
}
|
|
5457
|
+
}
|
|
5458
|
+
});
|
|
5459
|
+
}
|
|
5460
|
+
);
|
|
5461
|
+
|
|
5462
|
+
// src/html-block-plugin/index.tsx
|
|
5463
|
+
import { Transforms as Transforms22 } from "slate";
|
|
5464
|
+
|
|
5465
|
+
// src/html-block-plugin/styles.ts
|
|
5466
|
+
import styled25 from "@emotion/styled";
|
|
5467
|
+
var $HtmlBlock = styled25("div")`
|
|
5468
|
+
position: relative;
|
|
5469
|
+
background-color: var(--shade-100);
|
|
5470
|
+
border: 1px solid var(--shade-300);
|
|
5471
|
+
border-radius: 0.5em;
|
|
5472
|
+
padding: 2em 1em 1em 1em;
|
|
5473
|
+
margin: 1em 0;
|
|
5474
|
+
font-family: "andale mono", AndaleMono, monospace;
|
|
5475
|
+
font-size: 0.875em;
|
|
5476
|
+
line-height: 1.5;
|
|
5477
|
+
white-space: pre-wrap;
|
|
5478
|
+
word-break: break-word;
|
|
5479
|
+
color: var(--shade-700);
|
|
5480
|
+
overflow-x: auto;
|
|
5481
|
+
|
|
5482
|
+
&.--selected {
|
|
5483
|
+
outline: 2px solid var(--select-color);
|
|
5484
|
+
}
|
|
5485
|
+
`;
|
|
5486
|
+
var $HtmlBlockLabel = styled25("span")`
|
|
5487
|
+
position: absolute;
|
|
5488
|
+
top: 0.25em;
|
|
5489
|
+
right: 0.5em;
|
|
5490
|
+
font-size: 0.625em;
|
|
5491
|
+
color: var(--shade-500);
|
|
5492
|
+
text-transform: uppercase;
|
|
5493
|
+
letter-spacing: 0.5px;
|
|
5494
|
+
`;
|
|
5495
|
+
|
|
5496
|
+
// src/html-block-plugin/render-element.tsx
|
|
5497
|
+
import { jsx as jsx35, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5498
|
+
function HtmlBlock({
|
|
5499
|
+
attributes,
|
|
5500
|
+
children,
|
|
5501
|
+
element
|
|
5502
|
+
}) {
|
|
5503
|
+
return /* @__PURE__ */ jsxs17($HtmlBlock, { ...attributes, contentEditable: false, children: [
|
|
5504
|
+
/* @__PURE__ */ jsx35($HtmlBlockLabel, { children: "HTML" }),
|
|
5505
|
+
/* @__PURE__ */ jsx35("div", { children: unescapeUrlSlashes(element.html) }),
|
|
5506
|
+
children
|
|
5507
|
+
] });
|
|
5508
|
+
}
|
|
5509
|
+
|
|
5510
|
+
// src/html-block-plugin/index.tsx
|
|
5511
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
5512
|
+
var HtmlBlockPlugin = createPlugin(
|
|
5513
|
+
(editor, _options, { createPolicy }) => {
|
|
5514
|
+
function onDelete() {
|
|
5515
|
+
const { selection } = editor;
|
|
5516
|
+
if (!isCollapsed(selection))
|
|
5517
|
+
return false;
|
|
5518
|
+
const htmlBlockEntry = findElementUp(editor, "html-block");
|
|
5519
|
+
if (htmlBlockEntry == null)
|
|
5520
|
+
return false;
|
|
5521
|
+
Transforms22.removeNodes(editor, { at: htmlBlockEntry[1] });
|
|
5522
|
+
return true;
|
|
5523
|
+
}
|
|
5524
|
+
return createPolicy({
|
|
5525
|
+
name: "html-block",
|
|
5526
|
+
editor: {
|
|
5527
|
+
deleteBackward: onDelete,
|
|
5528
|
+
deleteForward: onDelete,
|
|
5529
|
+
isInline(element) {
|
|
5530
|
+
if (element.type === "html-block")
|
|
5531
|
+
return false;
|
|
5532
|
+
},
|
|
5533
|
+
isVoid(element) {
|
|
5534
|
+
if (element.type === "html-block")
|
|
5535
|
+
return true;
|
|
5536
|
+
},
|
|
5537
|
+
isMaster(element) {
|
|
5538
|
+
if (element.type === "html-block")
|
|
5539
|
+
return true;
|
|
5540
|
+
}
|
|
5541
|
+
},
|
|
5542
|
+
editableProps: {
|
|
5543
|
+
renderElement: ({ element, attributes, children }) => {
|
|
5544
|
+
if (element.type === "html-block") {
|
|
5545
|
+
return /* @__PURE__ */ jsx36(HtmlBlock, { element, attributes, children });
|
|
5311
5546
|
}
|
|
5312
5547
|
}
|
|
5313
5548
|
}
|
|
@@ -5322,7 +5557,7 @@ import { Editor as Editor32 } from "slate";
|
|
|
5322
5557
|
import { Element as Element18 } from "slate";
|
|
5323
5558
|
|
|
5324
5559
|
// src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-paragraphs.ts
|
|
5325
|
-
import { Element as Element16, Transforms as
|
|
5560
|
+
import { Element as Element16, Transforms as Transforms23 } from "slate";
|
|
5326
5561
|
function isParagraph(node) {
|
|
5327
5562
|
return Element16.isElement(node) && node.type === "paragraph";
|
|
5328
5563
|
}
|
|
@@ -5331,7 +5566,7 @@ function normalizeSiblingParagraphs(editor, entry) {
|
|
|
5331
5566
|
if (!isParagraph(a[0]) || !isParagraph(b[0]))
|
|
5332
5567
|
return false;
|
|
5333
5568
|
if (a[0].__collapsible && b[0].__collapsible) {
|
|
5334
|
-
|
|
5569
|
+
Transforms23.removeNodes(editor, { at: a[1] });
|
|
5335
5570
|
return true;
|
|
5336
5571
|
}
|
|
5337
5572
|
return false;
|
|
@@ -5339,7 +5574,7 @@ function normalizeSiblingParagraphs(editor, entry) {
|
|
|
5339
5574
|
}
|
|
5340
5575
|
|
|
5341
5576
|
// src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-walls.ts
|
|
5342
|
-
import { Element as Element17, Transforms as
|
|
5577
|
+
import { Element as Element17, Transforms as Transforms24 } from "slate";
|
|
5343
5578
|
function isWall(editor, node) {
|
|
5344
5579
|
if (!Element17.isElement(node))
|
|
5345
5580
|
return false;
|
|
@@ -5351,7 +5586,7 @@ function normalizeSiblingWalls(editor, entry) {
|
|
|
5351
5586
|
return normalizeSiblings(editor, entry, (a, b) => {
|
|
5352
5587
|
if (!isWall(editor, a[0]) || !isWall(editor, b[0]))
|
|
5353
5588
|
return false;
|
|
5354
|
-
|
|
5589
|
+
Transforms24.insertNodes(
|
|
5355
5590
|
editor,
|
|
5356
5591
|
{
|
|
5357
5592
|
type: "paragraph",
|
|
@@ -5381,8 +5616,8 @@ import { clsx as clsx5 } from "clsx";
|
|
|
5381
5616
|
import { useSelected as useSelected5 } from "slate-react";
|
|
5382
5617
|
|
|
5383
5618
|
// src/collapsible-paragraph-plugin/render-element/styles.ts
|
|
5384
|
-
import
|
|
5385
|
-
var $Paragraph =
|
|
5619
|
+
import styled26 from "@emotion/styled";
|
|
5620
|
+
var $Paragraph = styled26("p")`
|
|
5386
5621
|
padding: 0;
|
|
5387
5622
|
margin: 0;
|
|
5388
5623
|
&:first-child {
|
|
@@ -5421,7 +5656,7 @@ function getIsEmpty(element) {
|
|
|
5421
5656
|
}
|
|
5422
5657
|
|
|
5423
5658
|
// src/collapsible-paragraph-plugin/render-element/paragraph.tsx
|
|
5424
|
-
import { jsx as
|
|
5659
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
5425
5660
|
function Paragraph({
|
|
5426
5661
|
element,
|
|
5427
5662
|
attributes,
|
|
@@ -5429,7 +5664,7 @@ function Paragraph({
|
|
|
5429
5664
|
}) {
|
|
5430
5665
|
const selected = useSelected5();
|
|
5431
5666
|
const isEmpty = getIsEmpty(element);
|
|
5432
|
-
return /* @__PURE__ */
|
|
5667
|
+
return /* @__PURE__ */ jsx37(
|
|
5433
5668
|
$Paragraph,
|
|
5434
5669
|
{
|
|
5435
5670
|
...attributes,
|
|
@@ -5444,7 +5679,7 @@ function Paragraph({
|
|
|
5444
5679
|
}
|
|
5445
5680
|
|
|
5446
5681
|
// src/collapsible-paragraph-plugin/index.tsx
|
|
5447
|
-
import { jsx as
|
|
5682
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
5448
5683
|
var CollapsibleParagraphPlugin = createPlugin((editor) => {
|
|
5449
5684
|
const { insertBreak: insertBreak3 } = editor;
|
|
5450
5685
|
editor.insertBreak = () => {
|
|
@@ -5491,7 +5726,7 @@ var CollapsibleParagraphPlugin = createPlugin((editor) => {
|
|
|
5491
5726
|
renderElement: ({ element, attributes, children }) => {
|
|
5492
5727
|
switch (element.type) {
|
|
5493
5728
|
case "paragraph": {
|
|
5494
|
-
return /* @__PURE__ */
|
|
5729
|
+
return /* @__PURE__ */ jsx38(Paragraph, { element, attributes, children });
|
|
5495
5730
|
}
|
|
5496
5731
|
}
|
|
5497
5732
|
},
|
|
@@ -5512,7 +5747,7 @@ function addConvertElementType(editor, type) {
|
|
|
5512
5747
|
}
|
|
5513
5748
|
|
|
5514
5749
|
// src/convert-element-plugin/methods/convert-elements.ts
|
|
5515
|
-
import { Editor as Editor33, Element as Element20, Node as Node13, Point, Range as Range5, Transforms as
|
|
5750
|
+
import { Editor as Editor33, Element as Element20, Node as Node13, Point, Range as Range5, Transforms as Transforms25 } from "slate";
|
|
5516
5751
|
function getOffsetInElement(editor, point, elementPath) {
|
|
5517
5752
|
try {
|
|
5518
5753
|
const elementStart = Editor33.start(editor, elementPath);
|
|
@@ -5547,7 +5782,7 @@ function restoreSelectionInElement(editor, elementPath, offset) {
|
|
|
5547
5782
|
currentOffset += nodeLength;
|
|
5548
5783
|
}
|
|
5549
5784
|
const point = { path: targetPath, offset: targetOffset };
|
|
5550
|
-
|
|
5785
|
+
Transforms25.select(editor, { anchor: point, focus: point });
|
|
5551
5786
|
} catch {
|
|
5552
5787
|
}
|
|
5553
5788
|
}
|
|
@@ -5618,16 +5853,16 @@ function splitElementAtSelectedLines(editor, element, path, selection) {
|
|
|
5618
5853
|
...element,
|
|
5619
5854
|
children: [{ text: afterText }]
|
|
5620
5855
|
};
|
|
5621
|
-
|
|
5856
|
+
Transforms25.insertNodes(editor, afterElement, {
|
|
5622
5857
|
at: [...basePath, baseIndex + 1]
|
|
5623
5858
|
});
|
|
5624
5859
|
}
|
|
5625
5860
|
const childrenCount = element.children.length;
|
|
5626
5861
|
for (let j = childrenCount - 1; j >= 0; j--) {
|
|
5627
|
-
|
|
5862
|
+
Transforms25.removeNodes(editor, { at: [...path, j] });
|
|
5628
5863
|
}
|
|
5629
5864
|
if (beforeLines.length > 0) {
|
|
5630
|
-
|
|
5865
|
+
Transforms25.insertNodes(
|
|
5631
5866
|
editor,
|
|
5632
5867
|
{ text: beforeLines.join("\n") },
|
|
5633
5868
|
{ at: [...path, 0] }
|
|
@@ -5637,11 +5872,11 @@ function splitElementAtSelectedLines(editor, element, path, selection) {
|
|
|
5637
5872
|
type: "paragraph",
|
|
5638
5873
|
children: [{ text: selectedText }]
|
|
5639
5874
|
};
|
|
5640
|
-
|
|
5875
|
+
Transforms25.insertNodes(editor, selectedElement, {
|
|
5641
5876
|
at: [...basePath, baseIndex + 1]
|
|
5642
5877
|
});
|
|
5643
5878
|
} else {
|
|
5644
|
-
|
|
5879
|
+
Transforms25.insertNodes(
|
|
5645
5880
|
editor,
|
|
5646
5881
|
{ text: selectedLines.join("\n") },
|
|
5647
5882
|
{ at: [...path, 0] }
|
|
@@ -5657,21 +5892,21 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5657
5892
|
const { selection } = editor;
|
|
5658
5893
|
if (!selection)
|
|
5659
5894
|
return false;
|
|
5895
|
+
let savedAnchorOffset = -1;
|
|
5896
|
+
let savedFocusOffset = -1;
|
|
5897
|
+
const isCollapsed2 = Range5.isCollapsed(selection);
|
|
5660
5898
|
const entries = Array.from(
|
|
5661
5899
|
Editor33.nodes(editor, {
|
|
5662
5900
|
match: (node) => Element20.isElement(node) && editor.convertElement.isConvertibleElement(node)
|
|
5663
5901
|
})
|
|
5664
5902
|
);
|
|
5665
|
-
if (entries.length === 0)
|
|
5666
|
-
return false;
|
|
5667
|
-
let savedAnchorOffset = -1;
|
|
5668
|
-
let savedFocusOffset = -1;
|
|
5669
|
-
let isCollapsed2 = Range5.isCollapsed(selection);
|
|
5670
5903
|
if (entries.length > 0) {
|
|
5671
5904
|
const [, firstPath] = entries[0];
|
|
5672
5905
|
savedAnchorOffset = getOffsetInElement(editor, selection.anchor, firstPath);
|
|
5673
5906
|
savedFocusOffset = getOffsetInElement(editor, selection.focus, firstPath);
|
|
5674
5907
|
}
|
|
5908
|
+
if (entries.length === 0)
|
|
5909
|
+
return false;
|
|
5675
5910
|
const allPaths = [];
|
|
5676
5911
|
Editor33.withoutNormalizing(editor, () => {
|
|
5677
5912
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -5752,7 +5987,7 @@ function convertElements(editor, matchForToggle, targetElement, allowToggle) {
|
|
|
5752
5987
|
}
|
|
5753
5988
|
currentOffset += nodeLength;
|
|
5754
5989
|
}
|
|
5755
|
-
|
|
5990
|
+
Transforms25.select(editor, {
|
|
5756
5991
|
anchor: { path: anchorPath, offset: anchorOffset },
|
|
5757
5992
|
focus: { path: focusPath, offset: focusOffset }
|
|
5758
5993
|
});
|
|
@@ -5792,7 +6027,7 @@ var ConvertElementPlugin = createPlugin((editor) => {
|
|
|
5792
6027
|
});
|
|
5793
6028
|
|
|
5794
6029
|
// src/heading-plugin/insert-break.ts
|
|
5795
|
-
import { Editor as Editor34, Path as Path9, Range as Range6, Transforms as
|
|
6030
|
+
import { Editor as Editor34, Path as Path9, Range as Range6, Transforms as Transforms26 } from "slate";
|
|
5796
6031
|
function insertBreak(editor) {
|
|
5797
6032
|
const entry = findElementUp(editor, "heading");
|
|
5798
6033
|
if (!entry)
|
|
@@ -5804,12 +6039,12 @@ function insertBreak(editor) {
|
|
|
5804
6039
|
if (!Editor34.isEnd(editor, editor.selection.anchor, entry[1]))
|
|
5805
6040
|
return false;
|
|
5806
6041
|
const nextPath = Path9.next(entry[1]);
|
|
5807
|
-
|
|
6042
|
+
Transforms26.insertNodes(
|
|
5808
6043
|
editor,
|
|
5809
6044
|
{ type: "paragraph", children: [{ text: "" }] },
|
|
5810
6045
|
{ at: nextPath }
|
|
5811
6046
|
);
|
|
5812
|
-
|
|
6047
|
+
Transforms26.select(editor, {
|
|
5813
6048
|
anchor: Editor34.start(editor, nextPath),
|
|
5814
6049
|
focus: Editor34.start(editor, nextPath)
|
|
5815
6050
|
});
|
|
@@ -5842,7 +6077,7 @@ function createHeadingMethods(editor) {
|
|
|
5842
6077
|
|
|
5843
6078
|
// src/heading-plugin/styles.ts
|
|
5844
6079
|
import { css } from "@emotion/react";
|
|
5845
|
-
import
|
|
6080
|
+
import styled27 from "@emotion/styled";
|
|
5846
6081
|
var headingStyles = css`
|
|
5847
6082
|
margin-top: 1em;
|
|
5848
6083
|
&:first-child {
|
|
@@ -5850,34 +6085,34 @@ var headingStyles = css`
|
|
|
5850
6085
|
}
|
|
5851
6086
|
font-weight: bold;
|
|
5852
6087
|
`;
|
|
5853
|
-
var $H1 =
|
|
6088
|
+
var $H1 = styled27("h1")`
|
|
5854
6089
|
${headingStyles}
|
|
5855
6090
|
font-size: 2.25em;
|
|
5856
6091
|
letter-spacing: -0.01em;
|
|
5857
6092
|
`;
|
|
5858
|
-
var $H2 =
|
|
6093
|
+
var $H2 = styled27("h2")`
|
|
5859
6094
|
${headingStyles}
|
|
5860
6095
|
font-size: 1.5em;
|
|
5861
6096
|
`;
|
|
5862
|
-
var $H3 =
|
|
6097
|
+
var $H3 = styled27("h3")`
|
|
5863
6098
|
${headingStyles}
|
|
5864
6099
|
font-size: 1.25em;
|
|
5865
6100
|
`;
|
|
5866
|
-
var $H4 =
|
|
6101
|
+
var $H4 = styled27("h4")`
|
|
5867
6102
|
${headingStyles}
|
|
5868
6103
|
font-size: 1em;
|
|
5869
6104
|
`;
|
|
5870
|
-
var $H5 =
|
|
6105
|
+
var $H5 = styled27("h5")`
|
|
5871
6106
|
${headingStyles}
|
|
5872
6107
|
font-size: 1em;
|
|
5873
6108
|
`;
|
|
5874
|
-
var $H6 =
|
|
6109
|
+
var $H6 = styled27("h6")`
|
|
5875
6110
|
${headingStyles}
|
|
5876
6111
|
font-size: 1em;
|
|
5877
6112
|
`;
|
|
5878
6113
|
|
|
5879
6114
|
// src/heading-plugin/index.tsx
|
|
5880
|
-
import { jsx as
|
|
6115
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
5881
6116
|
var HeadingPlugin = createPlugin(
|
|
5882
6117
|
(editor) => {
|
|
5883
6118
|
editor.convertElement.addConvertElementType("heading");
|
|
@@ -5908,17 +6143,17 @@ var HeadingPlugin = createPlugin(
|
|
|
5908
6143
|
if (element.type === "heading") {
|
|
5909
6144
|
switch (element.level) {
|
|
5910
6145
|
case 1:
|
|
5911
|
-
return /* @__PURE__ */
|
|
6146
|
+
return /* @__PURE__ */ jsx39($H1, { ...attributes, children });
|
|
5912
6147
|
case 2:
|
|
5913
|
-
return /* @__PURE__ */
|
|
6148
|
+
return /* @__PURE__ */ jsx39($H2, { ...attributes, children });
|
|
5914
6149
|
case 3:
|
|
5915
|
-
return /* @__PURE__ */
|
|
6150
|
+
return /* @__PURE__ */ jsx39($H3, { ...attributes, children });
|
|
5916
6151
|
case 4:
|
|
5917
|
-
return /* @__PURE__ */
|
|
6152
|
+
return /* @__PURE__ */ jsx39($H4, { ...attributes, children });
|
|
5918
6153
|
case 5:
|
|
5919
|
-
return /* @__PURE__ */
|
|
6154
|
+
return /* @__PURE__ */ jsx39($H5, { ...attributes, children });
|
|
5920
6155
|
case 6:
|
|
5921
|
-
return /* @__PURE__ */
|
|
6156
|
+
return /* @__PURE__ */ jsx39($H6, { ...attributes, children });
|
|
5922
6157
|
default: {
|
|
5923
6158
|
const exhaustiveCheck = element.level;
|
|
5924
6159
|
throw new Error(
|
|
@@ -5944,8 +6179,8 @@ var HeadingPlugin = createPlugin(
|
|
|
5944
6179
|
import { useSelected as useSelected6 } from "slate-react";
|
|
5945
6180
|
|
|
5946
6181
|
// src/horizontal-rule-plugin/styles.tsx
|
|
5947
|
-
import
|
|
5948
|
-
var $HorizontalRule =
|
|
6182
|
+
import styled28 from "@emotion/styled";
|
|
6183
|
+
var $HorizontalRule = styled28("hr")`
|
|
5949
6184
|
position: relative;
|
|
5950
6185
|
height: 1em;
|
|
5951
6186
|
/* background-color: var(--hr-color); */
|
|
@@ -5978,15 +6213,15 @@ var $HorizontalRule = styled26("hr")`
|
|
|
5978
6213
|
`;
|
|
5979
6214
|
|
|
5980
6215
|
// src/horizontal-rule-plugin/horizontal-rule.tsx
|
|
5981
|
-
import { jsx as
|
|
6216
|
+
import { jsx as jsx40, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
5982
6217
|
function HorizontalRule({
|
|
5983
6218
|
attributes,
|
|
5984
6219
|
children
|
|
5985
6220
|
}) {
|
|
5986
6221
|
const selected = useSelected6();
|
|
5987
|
-
return /* @__PURE__ */
|
|
6222
|
+
return /* @__PURE__ */ jsxs18("div", { ...attributes, draggable: true, children: [
|
|
5988
6223
|
children,
|
|
5989
|
-
/* @__PURE__ */
|
|
6224
|
+
/* @__PURE__ */ jsx40("div", { contentEditable: false, children: /* @__PURE__ */ jsx40($HorizontalRule, { className: selected ? "--selected" : "" }) })
|
|
5990
6225
|
] });
|
|
5991
6226
|
}
|
|
5992
6227
|
|
|
@@ -6004,7 +6239,7 @@ function createHorizontalRuleMethods(editor) {
|
|
|
6004
6239
|
}
|
|
6005
6240
|
|
|
6006
6241
|
// src/horizontal-rule-plugin/index.tsx
|
|
6007
|
-
import { jsx as
|
|
6242
|
+
import { jsx as jsx41 } from "react/jsx-runtime";
|
|
6008
6243
|
var HorizontalRulePlugin = createPlugin(
|
|
6009
6244
|
(editor, _options, { createPolicy }) => {
|
|
6010
6245
|
editor.horizontalRule = createHorizontalRuleMethods(editor);
|
|
@@ -6019,7 +6254,7 @@ var HorizontalRulePlugin = createPlugin(
|
|
|
6019
6254
|
editableProps: {
|
|
6020
6255
|
renderElement: (props) => {
|
|
6021
6256
|
if (props.element.type === "horizontal-rule") {
|
|
6022
|
-
return /* @__PURE__ */
|
|
6257
|
+
return /* @__PURE__ */ jsx41(HorizontalRule, { ...props });
|
|
6023
6258
|
}
|
|
6024
6259
|
},
|
|
6025
6260
|
onKeyDown: createHotkeyHandler({
|
|
@@ -6031,8 +6266,8 @@ var HorizontalRulePlugin = createPlugin(
|
|
|
6031
6266
|
);
|
|
6032
6267
|
|
|
6033
6268
|
// src/inline-code-plugin/styles.ts
|
|
6034
|
-
import
|
|
6035
|
-
var $InlineCode =
|
|
6269
|
+
import styled29 from "@emotion/styled";
|
|
6270
|
+
var $InlineCode = styled29("code")`
|
|
6036
6271
|
color: var(--shade-600);
|
|
6037
6272
|
background-color: var(--inline-code-bgcolor);
|
|
6038
6273
|
border: 1px solid var(--inline-code-border-color);
|
|
@@ -6054,7 +6289,7 @@ var $InlineCode = styled27("code")`
|
|
|
6054
6289
|
font-size: 0.75em;
|
|
6055
6290
|
vertical-align: baseline;
|
|
6056
6291
|
`;
|
|
6057
|
-
var $InvisibleSpan =
|
|
6292
|
+
var $InvisibleSpan = styled29("span")`
|
|
6058
6293
|
display: inline-block;
|
|
6059
6294
|
opacity: 0;
|
|
6060
6295
|
width: 1px;
|
|
@@ -6062,7 +6297,7 @@ var $InvisibleSpan = styled27("span")`
|
|
|
6062
6297
|
`;
|
|
6063
6298
|
|
|
6064
6299
|
// src/inline-code-plugin/index.tsx
|
|
6065
|
-
import { jsx as
|
|
6300
|
+
import { jsx as jsx42, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
6066
6301
|
var InlineCodePlugin = createPlugin(
|
|
6067
6302
|
(editor) => {
|
|
6068
6303
|
if (!editor.marksPlugin)
|
|
@@ -6081,10 +6316,10 @@ var InlineCodePlugin = createPlugin(
|
|
|
6081
6316
|
/**
|
|
6082
6317
|
* Disable spellCheck because it's computer code usually.
|
|
6083
6318
|
*/
|
|
6084
|
-
/* @__PURE__ */
|
|
6085
|
-
/* @__PURE__ */
|
|
6319
|
+
/* @__PURE__ */ jsxs19($InlineCode, { spellCheck: false, children: [
|
|
6320
|
+
/* @__PURE__ */ jsx42($InvisibleSpan, { contentEditable: false, children: "|" }),
|
|
6086
6321
|
children,
|
|
6087
|
-
/* @__PURE__ */
|
|
6322
|
+
/* @__PURE__ */ jsx42($InvisibleSpan, { contentEditable: false, children: "|" })
|
|
6088
6323
|
] })
|
|
6089
6324
|
);
|
|
6090
6325
|
} else {
|
|
@@ -6184,7 +6419,7 @@ function indent(editor) {
|
|
|
6184
6419
|
}
|
|
6185
6420
|
|
|
6186
6421
|
// src/list-plugin/methods/insert-break.ts
|
|
6187
|
-
import { Editor as Editor36, Transforms as
|
|
6422
|
+
import { Editor as Editor36, Transforms as Transforms27 } from "slate";
|
|
6188
6423
|
function insertBreak2(editor) {
|
|
6189
6424
|
const entry = findElementUp(editor, isListItem);
|
|
6190
6425
|
if (!entry)
|
|
@@ -6192,19 +6427,19 @@ function insertBreak2(editor) {
|
|
|
6192
6427
|
const [element, path] = entry;
|
|
6193
6428
|
if (Editor36.isEmpty(editor, element)) {
|
|
6194
6429
|
if (element.depth > 0) {
|
|
6195
|
-
|
|
6430
|
+
Transforms27.setNodes(editor, { depth: element.depth - 1 }, { at: path });
|
|
6196
6431
|
return true;
|
|
6197
6432
|
} else {
|
|
6198
6433
|
rewrapElement(editor, { type: "paragraph" }, path);
|
|
6199
6434
|
return true;
|
|
6200
6435
|
}
|
|
6201
6436
|
}
|
|
6202
|
-
|
|
6437
|
+
Transforms27.splitNodes(editor, { always: true });
|
|
6203
6438
|
const nextEntry = findElementUp(editor, isListItem);
|
|
6204
6439
|
if (!nextEntry)
|
|
6205
6440
|
return true;
|
|
6206
6441
|
if (nextEntry[0].type === "task-list-item" && nextEntry[0].checked === true) {
|
|
6207
|
-
|
|
6442
|
+
Transforms27.setNodes(editor, { checked: false }, { at: nextEntry[1] });
|
|
6208
6443
|
}
|
|
6209
6444
|
return true;
|
|
6210
6445
|
}
|
|
@@ -6231,7 +6466,7 @@ function outdent(editor) {
|
|
|
6231
6466
|
}
|
|
6232
6467
|
|
|
6233
6468
|
// src/list-plugin/methods/toggleTaskListItem.ts
|
|
6234
|
-
import { Transforms as
|
|
6469
|
+
import { Transforms as Transforms28 } from "slate";
|
|
6235
6470
|
function toggleTaskListItem(editor, { at = editor.selection } = {}) {
|
|
6236
6471
|
const taskListItem = findElementUp(
|
|
6237
6472
|
editor,
|
|
@@ -6241,7 +6476,7 @@ function toggleTaskListItem(editor, { at = editor.selection } = {}) {
|
|
|
6241
6476
|
if (!taskListItem)
|
|
6242
6477
|
return false;
|
|
6243
6478
|
const nextChecked = !taskListItem[0].checked;
|
|
6244
|
-
|
|
6479
|
+
Transforms28.setNodes(
|
|
6245
6480
|
editor,
|
|
6246
6481
|
{ checked: nextChecked },
|
|
6247
6482
|
{ at: taskListItem[1] }
|
|
@@ -6267,7 +6502,7 @@ function createListMethods(editor) {
|
|
|
6267
6502
|
}
|
|
6268
6503
|
|
|
6269
6504
|
// src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts
|
|
6270
|
-
import { Element as Element21, Transforms as
|
|
6505
|
+
import { Element as Element21, Transforms as Transforms29 } from "slate";
|
|
6271
6506
|
var isOrderedListItem = createIsElementType([
|
|
6272
6507
|
"ordered-list-item"
|
|
6273
6508
|
]);
|
|
@@ -6280,7 +6515,7 @@ function normalizeOrderedFirstAtDepth(editor, entry) {
|
|
|
6280
6515
|
return false;
|
|
6281
6516
|
const __firstAtDepth = isOrderedListItem(a[0]) ? b[0].depth > a[0].depth : isListItem(a[0]) ? b[0].depth > a[0].depth : true;
|
|
6282
6517
|
if (b[0].__firstAtDepth !== __firstAtDepth) {
|
|
6283
|
-
|
|
6518
|
+
Transforms29.setNodes(editor, { __firstAtDepth }, { at: b[1] });
|
|
6284
6519
|
return true;
|
|
6285
6520
|
}
|
|
6286
6521
|
return false;
|
|
@@ -6298,16 +6533,16 @@ function normalizeNode5(editor, entry) {
|
|
|
6298
6533
|
// src/list-plugin/render-element/ordered-list-item.tsx
|
|
6299
6534
|
import { clsx as clsx6 } from "clsx";
|
|
6300
6535
|
import { useEffect as useEffect5 } from "react";
|
|
6301
|
-
import { ReactEditor as ReactEditor10, useSlateStatic as
|
|
6536
|
+
import { ReactEditor as ReactEditor10, useSlateStatic as useSlateStatic11 } from "slate-react";
|
|
6302
6537
|
|
|
6303
6538
|
// src/list-plugin/render-element/styles.ts
|
|
6304
|
-
import
|
|
6305
|
-
var $ListItem =
|
|
6539
|
+
import styled30 from "@emotion/styled";
|
|
6540
|
+
var $ListItem = styled30("li")`
|
|
6306
6541
|
margin-top: 0.5em;
|
|
6307
6542
|
margin-bottom: 0.5em;
|
|
6308
6543
|
list-style-position: outside;
|
|
6309
6544
|
`;
|
|
6310
|
-
var $UnorderedListItem =
|
|
6545
|
+
var $UnorderedListItem = styled30($ListItem)`
|
|
6311
6546
|
position: relative;
|
|
6312
6547
|
list-style-type: none;
|
|
6313
6548
|
.--list-item-icon {
|
|
@@ -6318,7 +6553,7 @@ var $UnorderedListItem = styled28($ListItem)`
|
|
|
6318
6553
|
color: var(--shade-600);
|
|
6319
6554
|
}
|
|
6320
6555
|
`;
|
|
6321
|
-
var $OrderedListItem =
|
|
6556
|
+
var $OrderedListItem = styled30($ListItem)`
|
|
6322
6557
|
position: relative;
|
|
6323
6558
|
list-style-type: none;
|
|
6324
6559
|
counter-increment: var(--list-item-var);
|
|
@@ -6344,7 +6579,7 @@ var $OrderedListItem = styled28($ListItem)`
|
|
|
6344
6579
|
font-variant-numeric: tabular-nums;
|
|
6345
6580
|
}
|
|
6346
6581
|
`;
|
|
6347
|
-
var $TaskListItem =
|
|
6582
|
+
var $TaskListItem = styled30($ListItem)`
|
|
6348
6583
|
position: relative;
|
|
6349
6584
|
list-style-type: none;
|
|
6350
6585
|
.--list-item-icon {
|
|
@@ -6361,13 +6596,13 @@ var $TaskListItem = styled28($ListItem)`
|
|
|
6361
6596
|
`;
|
|
6362
6597
|
|
|
6363
6598
|
// src/list-plugin/render-element/ordered-list-item.tsx
|
|
6364
|
-
import { jsx as
|
|
6599
|
+
import { jsx as jsx43 } from "react/jsx-runtime";
|
|
6365
6600
|
function OrderedListItem({
|
|
6366
6601
|
element,
|
|
6367
6602
|
attributes,
|
|
6368
6603
|
children
|
|
6369
6604
|
}) {
|
|
6370
|
-
const editor =
|
|
6605
|
+
const editor = useSlateStatic11();
|
|
6371
6606
|
useEffect5(() => {
|
|
6372
6607
|
const path = ReactEditor10.findPath(editor, element);
|
|
6373
6608
|
normalizeOrderedFirstAtDepth(editor, [element, path]);
|
|
@@ -6377,16 +6612,16 @@ function OrderedListItem({
|
|
|
6377
6612
|
"--list-item-var": `list-item-depth-${element.depth}`
|
|
6378
6613
|
};
|
|
6379
6614
|
const className = clsx6({ "--first-at-depth": element.__firstAtDepth });
|
|
6380
|
-
return /* @__PURE__ */
|
|
6615
|
+
return /* @__PURE__ */ jsx43($OrderedListItem, { ...attributes, className, style, children });
|
|
6381
6616
|
}
|
|
6382
6617
|
|
|
6383
6618
|
// src/list-plugin/render-element/task-list-item.tsx
|
|
6384
|
-
import { useCallback as
|
|
6385
|
-
import { useSlateStatic as
|
|
6619
|
+
import { useCallback as useCallback11 } from "react";
|
|
6620
|
+
import { useSlateStatic as useSlateStatic12 } from "slate-react";
|
|
6386
6621
|
|
|
6387
6622
|
// src/list-plugin/render-element/list-icons.tsx
|
|
6388
|
-
import { jsx as
|
|
6389
|
-
var UncheckedIcon = (props) => /* @__PURE__ */
|
|
6623
|
+
import { jsx as jsx44, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
6624
|
+
var UncheckedIcon = (props) => /* @__PURE__ */ jsxs20(
|
|
6390
6625
|
"svg",
|
|
6391
6626
|
{
|
|
6392
6627
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6400,12 +6635,12 @@ var UncheckedIcon = (props) => /* @__PURE__ */ jsxs19(
|
|
|
6400
6635
|
viewBox: "0 0 24 24",
|
|
6401
6636
|
...props,
|
|
6402
6637
|
children: [
|
|
6403
|
-
/* @__PURE__ */
|
|
6404
|
-
/* @__PURE__ */
|
|
6638
|
+
/* @__PURE__ */ jsx44("path", { d: "M0 0h24v24H0z", stroke: "none" }),
|
|
6639
|
+
/* @__PURE__ */ jsx44("rect", { x: 4, y: 4, width: 16, height: 16, rx: 2 })
|
|
6405
6640
|
]
|
|
6406
6641
|
}
|
|
6407
6642
|
);
|
|
6408
|
-
var CheckedIcon = (props) => /* @__PURE__ */
|
|
6643
|
+
var CheckedIcon = (props) => /* @__PURE__ */ jsxs20(
|
|
6409
6644
|
"svg",
|
|
6410
6645
|
{
|
|
6411
6646
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6420,13 +6655,13 @@ var CheckedIcon = (props) => /* @__PURE__ */ jsxs19(
|
|
|
6420
6655
|
viewBox: "0 0 24 24",
|
|
6421
6656
|
...props,
|
|
6422
6657
|
children: [
|
|
6423
|
-
/* @__PURE__ */
|
|
6424
|
-
/* @__PURE__ */
|
|
6425
|
-
/* @__PURE__ */
|
|
6658
|
+
/* @__PURE__ */ jsx44("path", { d: "M0 0h24v24H0z", stroke: "none" }),
|
|
6659
|
+
/* @__PURE__ */ jsx44("path", { d: "m9 11 3 3 8-8", className: "--checkmark" }),
|
|
6660
|
+
/* @__PURE__ */ jsx44("path", { d: "M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9" })
|
|
6426
6661
|
]
|
|
6427
6662
|
}
|
|
6428
6663
|
);
|
|
6429
|
-
var BulletIcon = (props) => /* @__PURE__ */
|
|
6664
|
+
var BulletIcon = (props) => /* @__PURE__ */ jsx44(
|
|
6430
6665
|
"svg",
|
|
6431
6666
|
{
|
|
6432
6667
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -6435,44 +6670,44 @@ var BulletIcon = (props) => /* @__PURE__ */ jsx40(
|
|
|
6435
6670
|
width: "1em",
|
|
6436
6671
|
height: "1em",
|
|
6437
6672
|
...props,
|
|
6438
|
-
children: /* @__PURE__ */
|
|
6673
|
+
children: /* @__PURE__ */ jsx44("path", { d: "M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z" })
|
|
6439
6674
|
}
|
|
6440
6675
|
);
|
|
6441
6676
|
|
|
6442
6677
|
// src/list-plugin/render-element/task-list-item.tsx
|
|
6443
|
-
import { jsx as
|
|
6678
|
+
import { jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6444
6679
|
function TaskListItem({
|
|
6445
6680
|
element,
|
|
6446
6681
|
attributes,
|
|
6447
6682
|
children
|
|
6448
6683
|
}) {
|
|
6449
|
-
const editor =
|
|
6450
|
-
const toggle =
|
|
6684
|
+
const editor = useSlateStatic12();
|
|
6685
|
+
const toggle = useCallback11(() => {
|
|
6451
6686
|
editor.list.toggleTaskListItem({ at: element });
|
|
6452
6687
|
}, [editor, element]);
|
|
6453
6688
|
const marginLeft = `${2 + element.depth * 2}em`;
|
|
6454
|
-
return /* @__PURE__ */
|
|
6455
|
-
/* @__PURE__ */
|
|
6689
|
+
return /* @__PURE__ */ jsxs21($TaskListItem, { ...attributes, style: { marginLeft }, children: [
|
|
6690
|
+
/* @__PURE__ */ jsx45("div", { className: "--list-item-icon", contentEditable: false, children: element.checked ? /* @__PURE__ */ jsx45(CheckedIcon, { onClick: toggle, style: { cursor: "pointer" } }) : /* @__PURE__ */ jsx45(UncheckedIcon, { onClick: toggle, style: { cursor: "pointer" } }) }),
|
|
6456
6691
|
children
|
|
6457
6692
|
] });
|
|
6458
6693
|
}
|
|
6459
6694
|
|
|
6460
6695
|
// src/list-plugin/render-element/unordered-list-item.tsx
|
|
6461
|
-
import { jsx as
|
|
6696
|
+
import { jsx as jsx46, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6462
6697
|
function UnorderedListItem({
|
|
6463
6698
|
element,
|
|
6464
6699
|
attributes,
|
|
6465
6700
|
children
|
|
6466
6701
|
}) {
|
|
6467
6702
|
const marginLeft = `${2 + element.depth * 2}em`;
|
|
6468
|
-
return /* @__PURE__ */
|
|
6469
|
-
/* @__PURE__ */
|
|
6703
|
+
return /* @__PURE__ */ jsxs22($UnorderedListItem, { ...attributes, style: { marginLeft }, children: [
|
|
6704
|
+
/* @__PURE__ */ jsx46("div", { className: "--list-item-icon", contentEditable: false, children: /* @__PURE__ */ jsx46(BulletIcon, {}) }),
|
|
6470
6705
|
children
|
|
6471
6706
|
] });
|
|
6472
6707
|
}
|
|
6473
6708
|
|
|
6474
6709
|
// src/list-plugin/render-element/index.tsx
|
|
6475
|
-
import { jsx as
|
|
6710
|
+
import { jsx as jsx47 } from "react/jsx-runtime";
|
|
6476
6711
|
function renderElement3({
|
|
6477
6712
|
element,
|
|
6478
6713
|
attributes,
|
|
@@ -6480,11 +6715,11 @@ function renderElement3({
|
|
|
6480
6715
|
}) {
|
|
6481
6716
|
switch (element.type) {
|
|
6482
6717
|
case "ordered-list-item":
|
|
6483
|
-
return /* @__PURE__ */
|
|
6718
|
+
return /* @__PURE__ */ jsx47(OrderedListItem, { element, attributes, children });
|
|
6484
6719
|
case "unordered-list-item":
|
|
6485
|
-
return /* @__PURE__ */
|
|
6720
|
+
return /* @__PURE__ */ jsx47(UnorderedListItem, { element, attributes, children });
|
|
6486
6721
|
case "task-list-item":
|
|
6487
|
-
return /* @__PURE__ */
|
|
6722
|
+
return /* @__PURE__ */ jsx47(TaskListItem, { element, attributes, children });
|
|
6488
6723
|
}
|
|
6489
6724
|
}
|
|
6490
6725
|
|
|
@@ -6549,7 +6784,7 @@ import { clsx as clsx7 } from "clsx";
|
|
|
6549
6784
|
import { Editor as Editor43, Point as Point3, Range as Range8 } from "slate";
|
|
6550
6785
|
|
|
6551
6786
|
// src/marks-plugin/methods/removeMarks.ts
|
|
6552
|
-
import { Editor as Editor41, Text as Text4, Transforms as
|
|
6787
|
+
import { Editor as Editor41, Text as Text4, Transforms as Transforms30 } from "slate";
|
|
6553
6788
|
function removeMarks(editor, { at = editor.selection } = {}) {
|
|
6554
6789
|
if (at == null)
|
|
6555
6790
|
return;
|
|
@@ -6567,7 +6802,7 @@ function removeMarks(editor, { at = editor.selection } = {}) {
|
|
|
6567
6802
|
setter[key2] = null;
|
|
6568
6803
|
}
|
|
6569
6804
|
}
|
|
6570
|
-
|
|
6805
|
+
Transforms30.setNodes(editor, setter, {
|
|
6571
6806
|
match: (n) => Text4.isText(n),
|
|
6572
6807
|
split: true,
|
|
6573
6808
|
at
|
|
@@ -6591,7 +6826,7 @@ function toggleMark(editor, markKey, unsetKey, { at = editor.selection } = {}) {
|
|
|
6591
6826
|
[validMarkKey]: true
|
|
6592
6827
|
};
|
|
6593
6828
|
} else {
|
|
6594
|
-
const { [validMarkKey]:
|
|
6829
|
+
const { [validMarkKey]: _unused, ...remainingMarks } = editor.activeMarks || {};
|
|
6595
6830
|
editor.activeMarks = remainingMarks;
|
|
6596
6831
|
}
|
|
6597
6832
|
}
|
|
@@ -6619,8 +6854,8 @@ function createMarksMethods(editor) {
|
|
|
6619
6854
|
}
|
|
6620
6855
|
|
|
6621
6856
|
// src/marks-plugin/styles.tsx
|
|
6622
|
-
import
|
|
6623
|
-
var $MarksSpan =
|
|
6857
|
+
import styled31 from "@emotion/styled";
|
|
6858
|
+
var $MarksSpan = styled31("span")`
|
|
6624
6859
|
&.--bold {
|
|
6625
6860
|
font-weight: bold;
|
|
6626
6861
|
}
|
|
@@ -6641,12 +6876,12 @@ var $MarksSpan = styled29("span")`
|
|
|
6641
6876
|
text-decoration: underline line-through;
|
|
6642
6877
|
}
|
|
6643
6878
|
&.--highlight {
|
|
6644
|
-
background-color: #
|
|
6879
|
+
background-color: #ffff00;
|
|
6645
6880
|
}
|
|
6646
6881
|
`;
|
|
6647
6882
|
|
|
6648
6883
|
// src/marks-plugin/index.tsx
|
|
6649
|
-
import { jsx as
|
|
6884
|
+
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
6650
6885
|
var MarksPlugin = createPlugin((editor) => {
|
|
6651
6886
|
editor.marksPlugin = createMarksMethods(editor);
|
|
6652
6887
|
editor.activeMarks = {};
|
|
@@ -6655,7 +6890,8 @@ var MarksPlugin = createPlugin((editor) => {
|
|
|
6655
6890
|
"mod+i": editor.marksPlugin.toggleItalic,
|
|
6656
6891
|
"mod+u": editor.marksPlugin.toggleUnderline,
|
|
6657
6892
|
"super+0": editor.marksPlugin.removeMarks,
|
|
6658
|
-
"super+k": editor.marksPlugin.toggleStrike
|
|
6893
|
+
"super+k": editor.marksPlugin.toggleStrike,
|
|
6894
|
+
"mod+h": editor.marksPlugin.toggleHighlight
|
|
6659
6895
|
});
|
|
6660
6896
|
const { insertText: defaultInsertText } = editor;
|
|
6661
6897
|
editor.insertText = (text) => {
|
|
@@ -6686,7 +6922,7 @@ var MarksPlugin = createPlugin((editor) => {
|
|
|
6686
6922
|
name: "marks",
|
|
6687
6923
|
editableProps: {
|
|
6688
6924
|
renderLeaf: ({ leaf, children }) => {
|
|
6689
|
-
return /* @__PURE__ */
|
|
6925
|
+
return /* @__PURE__ */ jsx48(
|
|
6690
6926
|
$MarksSpan,
|
|
6691
6927
|
{
|
|
6692
6928
|
className: clsx7({
|
|
@@ -6980,7 +7216,7 @@ function selectElementBelow(editor, t2) {
|
|
|
6980
7216
|
try {
|
|
6981
7217
|
selectStartOfElement(editor, Path14.next(tablePath));
|
|
6982
7218
|
return true;
|
|
6983
|
-
} catch
|
|
7219
|
+
} catch {
|
|
6984
7220
|
return false;
|
|
6985
7221
|
}
|
|
6986
7222
|
}
|
|
@@ -6993,7 +7229,7 @@ function selectElementAbove(editor, t2) {
|
|
|
6993
7229
|
try {
|
|
6994
7230
|
selectEndOfElement(editor, Path14.previous(tablePath));
|
|
6995
7231
|
return true;
|
|
6996
|
-
} catch
|
|
7232
|
+
} catch {
|
|
6997
7233
|
return false;
|
|
6998
7234
|
}
|
|
6999
7235
|
}
|
|
@@ -7249,14 +7485,14 @@ function normalizeTableCell(editor, entry) {
|
|
|
7249
7485
|
|
|
7250
7486
|
// src/table-plugin/render-element/table.tsx
|
|
7251
7487
|
import { useEffect as useEffect6 } from "react";
|
|
7252
|
-
import { ReactEditor as ReactEditor12, useSelected as useSelected7, useSlateStatic as
|
|
7488
|
+
import { ReactEditor as ReactEditor12, useSelected as useSelected7, useSlateStatic as useSlateStatic13 } from "slate-react";
|
|
7253
7489
|
|
|
7254
7490
|
// src/table-plugin/render-element/styles/index.ts
|
|
7255
|
-
import
|
|
7491
|
+
import styled33 from "@emotion/styled";
|
|
7256
7492
|
|
|
7257
7493
|
// src/table-plugin/render-element/styles/table-menu-styles.ts
|
|
7258
|
-
import
|
|
7259
|
-
var $BaseMenu =
|
|
7494
|
+
import styled32 from "@emotion/styled";
|
|
7495
|
+
var $BaseMenu = styled32("div")`
|
|
7260
7496
|
position: absolute;
|
|
7261
7497
|
/**
|
|
7262
7498
|
* very slightly shaded
|
|
@@ -7281,7 +7517,7 @@ var $BaseMenu = styled30("div")`
|
|
|
7281
7517
|
}
|
|
7282
7518
|
}
|
|
7283
7519
|
`;
|
|
7284
|
-
var $ColumnMenu =
|
|
7520
|
+
var $ColumnMenu = styled32($BaseMenu)`
|
|
7285
7521
|
cursor: pointer;
|
|
7286
7522
|
/**
|
|
7287
7523
|
* hangs out on top
|
|
@@ -7292,7 +7528,7 @@ var $ColumnMenu = styled30($BaseMenu)`
|
|
|
7292
7528
|
height: 3em;
|
|
7293
7529
|
top: -3em;
|
|
7294
7530
|
`;
|
|
7295
|
-
var $RowMenu =
|
|
7531
|
+
var $RowMenu = styled32($BaseMenu)`
|
|
7296
7532
|
/**
|
|
7297
7533
|
* hangs out on left
|
|
7298
7534
|
*/
|
|
@@ -7301,7 +7537,7 @@ var $RowMenu = styled30($BaseMenu)`
|
|
|
7301
7537
|
width: 3em;
|
|
7302
7538
|
left: -3em;
|
|
7303
7539
|
`;
|
|
7304
|
-
var $MenuTile =
|
|
7540
|
+
var $MenuTile = styled32("div")`
|
|
7305
7541
|
position: absolute;
|
|
7306
7542
|
background: rgba(0, 0, 0, 0.05);
|
|
7307
7543
|
border: 1px solid rgba(0, 0, 0, 0.05);
|
|
@@ -7314,7 +7550,7 @@ var $MenuTile = styled30("div")`
|
|
|
7314
7550
|
right: 0;
|
|
7315
7551
|
bottom: 0;
|
|
7316
7552
|
`;
|
|
7317
|
-
var $ColumnMenuTile =
|
|
7553
|
+
var $ColumnMenuTile = styled32($MenuTile)`
|
|
7318
7554
|
top: 50%;
|
|
7319
7555
|
border-bottom: none;
|
|
7320
7556
|
border-right: none;
|
|
@@ -7341,7 +7577,7 @@ var $ColumnMenuTile = styled30($MenuTile)`
|
|
|
7341
7577
|
/* border-top-left-radius: 0.5em;
|
|
7342
7578
|
border-top-right-radius: 0.5em; */
|
|
7343
7579
|
`;
|
|
7344
|
-
var $RowMenuTile =
|
|
7580
|
+
var $RowMenuTile = styled32($MenuTile)`
|
|
7345
7581
|
left: 50%;
|
|
7346
7582
|
border-right: none;
|
|
7347
7583
|
border-bottom: none;
|
|
@@ -7368,7 +7604,7 @@ var $RowMenuTile = styled30($MenuTile)`
|
|
|
7368
7604
|
/* border-top-left-radius: 0.5em;
|
|
7369
7605
|
border-bottom-left-radius: 0.5em; */
|
|
7370
7606
|
`;
|
|
7371
|
-
var $MenuButton =
|
|
7607
|
+
var $MenuButton = styled32("div")`
|
|
7372
7608
|
position: absolute;
|
|
7373
7609
|
font-size: 1.5em;
|
|
7374
7610
|
background: white;
|
|
@@ -7378,13 +7614,13 @@ var $MenuButton = styled30("div")`
|
|
|
7378
7614
|
display: block;
|
|
7379
7615
|
}
|
|
7380
7616
|
`;
|
|
7381
|
-
var $AddMenuButton =
|
|
7617
|
+
var $AddMenuButton = styled32($MenuButton)`
|
|
7382
7618
|
color: #c0c0c0;
|
|
7383
7619
|
&:hover {
|
|
7384
7620
|
color: royalblue;
|
|
7385
7621
|
}
|
|
7386
7622
|
`;
|
|
7387
|
-
var $RemoveMenuButton =
|
|
7623
|
+
var $RemoveMenuButton = styled32($MenuButton)`
|
|
7388
7624
|
color: #c0c0c0;
|
|
7389
7625
|
&:hover {
|
|
7390
7626
|
color: firebrick;
|
|
@@ -7392,20 +7628,20 @@ var $RemoveMenuButton = styled30($MenuButton)`
|
|
|
7392
7628
|
`;
|
|
7393
7629
|
|
|
7394
7630
|
// src/table-plugin/render-element/styles/index.ts
|
|
7395
|
-
var $Table =
|
|
7631
|
+
var $Table = styled33("table")`
|
|
7396
7632
|
border-collapse: collapse;
|
|
7397
7633
|
margin: 1em 0;
|
|
7398
7634
|
${({ columns }) => columns.map(
|
|
7399
7635
|
(column, index) => `td:nth-of-type(${index + 1}) { text-align: ${column.align}; }`
|
|
7400
7636
|
).join("\n")}
|
|
7401
7637
|
`;
|
|
7402
|
-
var $TableRow =
|
|
7638
|
+
var $TableRow = styled33("tr")`
|
|
7403
7639
|
position: relative;
|
|
7404
7640
|
&:first-of-type {
|
|
7405
7641
|
background: var(--table-head-bgcolor);
|
|
7406
7642
|
}
|
|
7407
7643
|
`;
|
|
7408
|
-
var $TableCell =
|
|
7644
|
+
var $TableCell = styled33("td")`
|
|
7409
7645
|
position: relative;
|
|
7410
7646
|
border-width: 1px;
|
|
7411
7647
|
border-style: solid;
|
|
@@ -7426,7 +7662,7 @@ var $TableCell = styled31("td")`
|
|
|
7426
7662
|
border-right-color: var(--table-border-color);
|
|
7427
7663
|
}
|
|
7428
7664
|
`;
|
|
7429
|
-
var $TableContent =
|
|
7665
|
+
var $TableContent = styled33("div")`
|
|
7430
7666
|
/**
|
|
7431
7667
|
* Smaller font inside a table than outside of it
|
|
7432
7668
|
*/
|
|
@@ -7447,19 +7683,19 @@ var TableContext = createContext2({
|
|
|
7447
7683
|
});
|
|
7448
7684
|
|
|
7449
7685
|
// src/table-plugin/render-element/table.tsx
|
|
7450
|
-
import { jsx as
|
|
7686
|
+
import { jsx as jsx49 } from "react/jsx-runtime";
|
|
7451
7687
|
function Table({
|
|
7452
7688
|
element,
|
|
7453
7689
|
attributes,
|
|
7454
7690
|
children
|
|
7455
7691
|
}) {
|
|
7456
|
-
const editor =
|
|
7692
|
+
const editor = useSlateStatic13();
|
|
7457
7693
|
const isSelected = useSelected7();
|
|
7458
7694
|
useEffect6(() => {
|
|
7459
7695
|
const path = ReactEditor12.findPath(editor, element);
|
|
7460
7696
|
normalizeTableIndexes(editor, [element, path]);
|
|
7461
7697
|
}, []);
|
|
7462
|
-
return /* @__PURE__ */
|
|
7698
|
+
return /* @__PURE__ */ jsx49(TableContext.Provider, { value: { isSelected }, children: /* @__PURE__ */ jsx49($Table, { ...attributes, columns: element.columns, children: /* @__PURE__ */ jsx49("tbody", { children }) }) });
|
|
7463
7699
|
}
|
|
7464
7700
|
|
|
7465
7701
|
// src/table-plugin/render-element/table-cell/index.tsx
|
|
@@ -7467,12 +7703,12 @@ import { useContext as useContext2 } from "react";
|
|
|
7467
7703
|
import { useSelected as useSelected8 } from "slate-react";
|
|
7468
7704
|
|
|
7469
7705
|
// src/table-plugin/render-element/table-cell/column-menu/index.tsx
|
|
7470
|
-
import { useCallback as
|
|
7471
|
-
import { useSlateStatic as
|
|
7706
|
+
import { useCallback as useCallback12, useRef as useRef7, useState as useState6 } from "react";
|
|
7707
|
+
import { useSlateStatic as useSlateStatic14 } from "slate-react";
|
|
7472
7708
|
|
|
7473
7709
|
// src/table-plugin/icons.tsx
|
|
7474
|
-
import { jsx as
|
|
7475
|
-
var PlusIcon = (props) => /* @__PURE__ */
|
|
7710
|
+
import { jsx as jsx50 } from "react/jsx-runtime";
|
|
7711
|
+
var PlusIcon = (props) => /* @__PURE__ */ jsx50(
|
|
7476
7712
|
"svg",
|
|
7477
7713
|
{
|
|
7478
7714
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7481,7 +7717,7 @@ var PlusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
|
7481
7717
|
width: "1em",
|
|
7482
7718
|
height: "1em",
|
|
7483
7719
|
...props,
|
|
7484
|
-
children: /* @__PURE__ */
|
|
7720
|
+
children: /* @__PURE__ */ jsx50(
|
|
7485
7721
|
"path",
|
|
7486
7722
|
{
|
|
7487
7723
|
fillRule: "evenodd",
|
|
@@ -7491,7 +7727,7 @@ var PlusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
|
7491
7727
|
)
|
|
7492
7728
|
}
|
|
7493
7729
|
);
|
|
7494
|
-
var MinusIcon = (props) => /* @__PURE__ */
|
|
7730
|
+
var MinusIcon = (props) => /* @__PURE__ */ jsx50(
|
|
7495
7731
|
"svg",
|
|
7496
7732
|
{
|
|
7497
7733
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -7500,7 +7736,7 @@ var MinusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
|
7500
7736
|
width: "1em",
|
|
7501
7737
|
height: "1em",
|
|
7502
7738
|
...props,
|
|
7503
|
-
children: /* @__PURE__ */
|
|
7739
|
+
children: /* @__PURE__ */ jsx50(
|
|
7504
7740
|
"path",
|
|
7505
7741
|
{
|
|
7506
7742
|
fillRule: "evenodd",
|
|
@@ -7510,25 +7746,25 @@ var MinusIcon = (props) => /* @__PURE__ */ jsx46(
|
|
|
7510
7746
|
)
|
|
7511
7747
|
}
|
|
7512
7748
|
);
|
|
7513
|
-
var BarsIcon = () => /* @__PURE__ */
|
|
7514
|
-
var AlignLeft = () => /* @__PURE__ */
|
|
7515
|
-
var AlignCenter = () => /* @__PURE__ */
|
|
7516
|
-
var AlignRight = () => /* @__PURE__ */
|
|
7749
|
+
var BarsIcon = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M4 12h16M4 18h16" }) });
|
|
7750
|
+
var AlignLeft = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M4 12h10M4 18h14" }) });
|
|
7751
|
+
var AlignCenter = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M8 12h8M6 18h12" }) });
|
|
7752
|
+
var AlignRight = () => /* @__PURE__ */ jsx50(TablerIcon, { children: /* @__PURE__ */ jsx50("path", { d: "M4 6h16M10 12h10M6 18h14" }) });
|
|
7517
7753
|
|
|
7518
7754
|
// src/table-plugin/render-element/table-cell/column-menu/index.tsx
|
|
7519
|
-
import { Fragment as Fragment4, jsx as
|
|
7755
|
+
import { Fragment as Fragment4, jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7520
7756
|
function ColumnMenu({ cellElement }) {
|
|
7521
|
-
const editor =
|
|
7757
|
+
const editor = useSlateStatic14();
|
|
7522
7758
|
const menu = useLayer("column-menu");
|
|
7523
|
-
const buttonRef =
|
|
7759
|
+
const buttonRef = useRef7(null);
|
|
7524
7760
|
const [hover, setHover] = useState6(false);
|
|
7525
|
-
const onMouseEnter =
|
|
7761
|
+
const onMouseEnter = useCallback12(() => {
|
|
7526
7762
|
setHover(true);
|
|
7527
7763
|
}, []);
|
|
7528
|
-
const onMouseLeave =
|
|
7764
|
+
const onMouseLeave = useCallback12(() => {
|
|
7529
7765
|
setHover(false);
|
|
7530
7766
|
}, []);
|
|
7531
|
-
const onClick =
|
|
7767
|
+
const onClick = useCallback12(() => {
|
|
7532
7768
|
if (menu.layer)
|
|
7533
7769
|
menu.close();
|
|
7534
7770
|
const dest = buttonRef.current;
|
|
@@ -7557,9 +7793,9 @@ function ColumnMenu({ cellElement }) {
|
|
|
7557
7793
|
}
|
|
7558
7794
|
}
|
|
7559
7795
|
];
|
|
7560
|
-
menu.open(() => /* @__PURE__ */
|
|
7796
|
+
menu.open(() => /* @__PURE__ */ jsx51(Menu, { dest, items, close: menu.close }));
|
|
7561
7797
|
}, []);
|
|
7562
|
-
return /* @__PURE__ */
|
|
7798
|
+
return /* @__PURE__ */ jsxs23(
|
|
7563
7799
|
$ColumnMenu,
|
|
7564
7800
|
{
|
|
7565
7801
|
ref: buttonRef,
|
|
@@ -7568,9 +7804,9 @@ function ColumnMenu({ cellElement }) {
|
|
|
7568
7804
|
onMouseEnter,
|
|
7569
7805
|
onMouseLeave,
|
|
7570
7806
|
children: [
|
|
7571
|
-
/* @__PURE__ */
|
|
7572
|
-
hover ? /* @__PURE__ */
|
|
7573
|
-
/* @__PURE__ */
|
|
7807
|
+
/* @__PURE__ */ jsx51($ColumnMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx51(BarsIcon, {}) }),
|
|
7808
|
+
hover ? /* @__PURE__ */ jsxs23(Fragment4, { children: [
|
|
7809
|
+
/* @__PURE__ */ jsx51(
|
|
7574
7810
|
$RemoveMenuButton,
|
|
7575
7811
|
{
|
|
7576
7812
|
style: {
|
|
@@ -7579,23 +7815,23 @@ function ColumnMenu({ cellElement }) {
|
|
|
7579
7815
|
marginLeft: "-0.5em"
|
|
7580
7816
|
},
|
|
7581
7817
|
onMouseDown: () => editor.tablePlugin.removeColumn({ at: cellElement }),
|
|
7582
|
-
children: /* @__PURE__ */
|
|
7818
|
+
children: /* @__PURE__ */ jsx51(MinusIcon, {})
|
|
7583
7819
|
}
|
|
7584
7820
|
),
|
|
7585
|
-
/* @__PURE__ */
|
|
7821
|
+
/* @__PURE__ */ jsx51(
|
|
7586
7822
|
$AddMenuButton,
|
|
7587
7823
|
{
|
|
7588
7824
|
style: { left: "-0.5em", top: 0 },
|
|
7589
7825
|
onMouseDown: () => editor.tablePlugin.insertColumn({ at: cellElement }),
|
|
7590
|
-
children: /* @__PURE__ */
|
|
7826
|
+
children: /* @__PURE__ */ jsx51(PlusIcon, {})
|
|
7591
7827
|
}
|
|
7592
7828
|
),
|
|
7593
|
-
/* @__PURE__ */
|
|
7829
|
+
/* @__PURE__ */ jsx51(
|
|
7594
7830
|
$AddMenuButton,
|
|
7595
7831
|
{
|
|
7596
7832
|
style: { right: "-0.5em", top: 0 },
|
|
7597
7833
|
onMouseDown: () => editor.tablePlugin.insertColumn({ at: cellElement, offset: 1 }),
|
|
7598
|
-
children: /* @__PURE__ */
|
|
7834
|
+
children: /* @__PURE__ */ jsx51(PlusIcon, {})
|
|
7599
7835
|
}
|
|
7600
7836
|
)
|
|
7601
7837
|
] }) : null
|
|
@@ -7606,21 +7842,21 @@ function ColumnMenu({ cellElement }) {
|
|
|
7606
7842
|
|
|
7607
7843
|
// src/table-plugin/render-element/table-cell/row-menu/index.tsx
|
|
7608
7844
|
import { useState as useState7 } from "react";
|
|
7609
|
-
import { useSlateStatic as
|
|
7610
|
-
import { Fragment as Fragment5, jsx as
|
|
7845
|
+
import { useSlateStatic as useSlateStatic15 } from "slate-react";
|
|
7846
|
+
import { Fragment as Fragment5, jsx as jsx52, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
7611
7847
|
function RowMenu({ cellElement }) {
|
|
7612
|
-
const editor =
|
|
7848
|
+
const editor = useSlateStatic15();
|
|
7613
7849
|
const [hover, setHover] = useState7(false);
|
|
7614
|
-
return /* @__PURE__ */
|
|
7850
|
+
return /* @__PURE__ */ jsxs24(
|
|
7615
7851
|
$RowMenu,
|
|
7616
7852
|
{
|
|
7617
7853
|
contentEditable: false,
|
|
7618
7854
|
onMouseEnter: () => setHover(true),
|
|
7619
7855
|
onMouseLeave: () => setHover(false),
|
|
7620
7856
|
children: [
|
|
7621
|
-
/* @__PURE__ */
|
|
7622
|
-
hover ? /* @__PURE__ */
|
|
7623
|
-
/* @__PURE__ */
|
|
7857
|
+
/* @__PURE__ */ jsx52($RowMenuTile, { className: "--tile", children: /* @__PURE__ */ jsx52(BarsIcon, {}) }),
|
|
7858
|
+
hover ? /* @__PURE__ */ jsxs24(Fragment5, { children: [
|
|
7859
|
+
/* @__PURE__ */ jsx52(
|
|
7624
7860
|
$RemoveMenuButton,
|
|
7625
7861
|
{
|
|
7626
7862
|
style: {
|
|
@@ -7629,23 +7865,23 @@ function RowMenu({ cellElement }) {
|
|
|
7629
7865
|
marginTop: "-0.5em"
|
|
7630
7866
|
},
|
|
7631
7867
|
onMouseDown: () => editor.tablePlugin.removeRow({ at: cellElement }),
|
|
7632
|
-
children: /* @__PURE__ */
|
|
7868
|
+
children: /* @__PURE__ */ jsx52(MinusIcon, {})
|
|
7633
7869
|
}
|
|
7634
7870
|
),
|
|
7635
|
-
/* @__PURE__ */
|
|
7871
|
+
/* @__PURE__ */ jsx52(
|
|
7636
7872
|
$AddMenuButton,
|
|
7637
7873
|
{
|
|
7638
7874
|
style: { top: "-0.5em", left: "0.5em" },
|
|
7639
7875
|
onMouseDown: () => editor.tablePlugin.insertRow({ at: cellElement }),
|
|
7640
|
-
children: /* @__PURE__ */
|
|
7876
|
+
children: /* @__PURE__ */ jsx52(PlusIcon, {})
|
|
7641
7877
|
}
|
|
7642
7878
|
),
|
|
7643
|
-
/* @__PURE__ */
|
|
7879
|
+
/* @__PURE__ */ jsx52(
|
|
7644
7880
|
$AddMenuButton,
|
|
7645
7881
|
{
|
|
7646
7882
|
style: { bottom: "-0.5em", left: "0.5em" },
|
|
7647
7883
|
onMouseDown: () => editor.tablePlugin.insertRow({ at: cellElement, offset: 1 }),
|
|
7648
|
-
children: /* @__PURE__ */
|
|
7884
|
+
children: /* @__PURE__ */ jsx52(PlusIcon, {})
|
|
7649
7885
|
}
|
|
7650
7886
|
)
|
|
7651
7887
|
] }) : null
|
|
@@ -7655,8 +7891,8 @@ function RowMenu({ cellElement }) {
|
|
|
7655
7891
|
}
|
|
7656
7892
|
|
|
7657
7893
|
// src/table-plugin/render-element/table-cell/table-menu/$table-menu.tsx
|
|
7658
|
-
import
|
|
7659
|
-
var $TableMenu =
|
|
7894
|
+
import styled34 from "@emotion/styled";
|
|
7895
|
+
var $TableMenu = styled34("div")`
|
|
7660
7896
|
position: absolute;
|
|
7661
7897
|
/**
|
|
7662
7898
|
* very slightly shaded
|
|
@@ -7689,7 +7925,7 @@ var $TableMenu = styled32("div")`
|
|
|
7689
7925
|
}
|
|
7690
7926
|
}
|
|
7691
7927
|
`;
|
|
7692
|
-
var $TableMenuTile =
|
|
7928
|
+
var $TableMenuTile = styled34("div")`
|
|
7693
7929
|
position: absolute;
|
|
7694
7930
|
left: 0;
|
|
7695
7931
|
top: 0;
|
|
@@ -7700,13 +7936,13 @@ var $TableMenuTile = styled32("div")`
|
|
|
7700
7936
|
`;
|
|
7701
7937
|
|
|
7702
7938
|
// src/table-plugin/render-element/table-cell/table-menu/index.tsx
|
|
7703
|
-
import { jsx as
|
|
7939
|
+
import { jsx as jsx53 } from "react/jsx-runtime";
|
|
7704
7940
|
function TableMenu() {
|
|
7705
|
-
return /* @__PURE__ */
|
|
7941
|
+
return /* @__PURE__ */ jsx53($TableMenu, { contentEditable: false, children: /* @__PURE__ */ jsx53($TableMenuTile, { className: "--table-menu-tile" }) });
|
|
7706
7942
|
}
|
|
7707
7943
|
|
|
7708
7944
|
// src/table-plugin/render-element/table-cell/index.tsx
|
|
7709
|
-
import { jsx as
|
|
7945
|
+
import { jsx as jsx54, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
7710
7946
|
function TableCell({
|
|
7711
7947
|
element,
|
|
7712
7948
|
attributes,
|
|
@@ -7717,7 +7953,7 @@ function TableCell({
|
|
|
7717
7953
|
const showTableMenu = tableContext.isSelected && element.x === 0 && element.y === 0;
|
|
7718
7954
|
const showRowMenu = tableContext.isSelected && element.x === 0;
|
|
7719
7955
|
const showColumnMenu = tableContext.isSelected && element.y === 0;
|
|
7720
|
-
return /* @__PURE__ */
|
|
7956
|
+
return /* @__PURE__ */ jsxs25(
|
|
7721
7957
|
$TableCell,
|
|
7722
7958
|
{
|
|
7723
7959
|
className: selected ? "--selected" : "",
|
|
@@ -7726,34 +7962,34 @@ function TableCell({
|
|
|
7726
7962
|
"data-y": element.y,
|
|
7727
7963
|
children: [
|
|
7728
7964
|
children,
|
|
7729
|
-
showTableMenu ? /* @__PURE__ */
|
|
7730
|
-
showRowMenu ? /* @__PURE__ */
|
|
7731
|
-
showColumnMenu ? /* @__PURE__ */
|
|
7965
|
+
showTableMenu ? /* @__PURE__ */ jsx54(TableMenu, {}) : null,
|
|
7966
|
+
showRowMenu ? /* @__PURE__ */ jsx54(RowMenu, { cellElement: element }) : null,
|
|
7967
|
+
showColumnMenu ? /* @__PURE__ */ jsx54(ColumnMenu, { cellElement: element }) : null
|
|
7732
7968
|
]
|
|
7733
7969
|
}
|
|
7734
7970
|
);
|
|
7735
7971
|
}
|
|
7736
7972
|
|
|
7737
7973
|
// src/table-plugin/render-element/table-content.tsx
|
|
7738
|
-
import { jsx as
|
|
7974
|
+
import { jsx as jsx55 } from "react/jsx-runtime";
|
|
7739
7975
|
function TableContent({
|
|
7740
7976
|
attributes,
|
|
7741
7977
|
children
|
|
7742
7978
|
}) {
|
|
7743
|
-
return /* @__PURE__ */
|
|
7979
|
+
return /* @__PURE__ */ jsx55($TableContent, { ...attributes, children });
|
|
7744
7980
|
}
|
|
7745
7981
|
|
|
7746
7982
|
// src/table-plugin/render-element/table-row.tsx
|
|
7747
|
-
import { jsx as
|
|
7983
|
+
import { jsx as jsx56 } from "react/jsx-runtime";
|
|
7748
7984
|
function TableRow({
|
|
7749
7985
|
attributes,
|
|
7750
7986
|
children
|
|
7751
7987
|
}) {
|
|
7752
|
-
return /* @__PURE__ */
|
|
7988
|
+
return /* @__PURE__ */ jsx56($TableRow, { ...attributes, children });
|
|
7753
7989
|
}
|
|
7754
7990
|
|
|
7755
7991
|
// src/table-plugin/render-element/index.tsx
|
|
7756
|
-
import { jsx as
|
|
7992
|
+
import { jsx as jsx57 } from "react/jsx-runtime";
|
|
7757
7993
|
function renderElement4({
|
|
7758
7994
|
element,
|
|
7759
7995
|
attributes,
|
|
@@ -7761,13 +7997,13 @@ function renderElement4({
|
|
|
7761
7997
|
}) {
|
|
7762
7998
|
switch (element.type) {
|
|
7763
7999
|
case "table":
|
|
7764
|
-
return /* @__PURE__ */
|
|
8000
|
+
return /* @__PURE__ */ jsx57(Table, { element, attributes, children });
|
|
7765
8001
|
case "table-row":
|
|
7766
|
-
return /* @__PURE__ */
|
|
8002
|
+
return /* @__PURE__ */ jsx57(TableRow, { element, attributes, children });
|
|
7767
8003
|
case "table-cell":
|
|
7768
|
-
return /* @__PURE__ */
|
|
8004
|
+
return /* @__PURE__ */ jsx57(TableCell, { element, attributes, children });
|
|
7769
8005
|
case "table-content":
|
|
7770
|
-
return /* @__PURE__ */
|
|
8006
|
+
return /* @__PURE__ */ jsx57(TableContent, { element, attributes, children });
|
|
7771
8007
|
}
|
|
7772
8008
|
}
|
|
7773
8009
|
|
|
@@ -7911,16 +8147,16 @@ var globalStyles = css2`
|
|
|
7911
8147
|
`;
|
|
7912
8148
|
|
|
7913
8149
|
// src/theme-plugin/index.tsx
|
|
7914
|
-
import { Fragment as Fragment6, jsx as
|
|
8150
|
+
import { Fragment as Fragment6, jsx as jsx58, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
7915
8151
|
var ThemePlugin = createPlugin((editor) => {
|
|
7916
8152
|
editor.theme = true;
|
|
7917
8153
|
return {
|
|
7918
8154
|
name: "theme",
|
|
7919
8155
|
editor: {},
|
|
7920
8156
|
renderEditable: ({ attributes, Editable: Editable3 }) => {
|
|
7921
|
-
return /* @__PURE__ */
|
|
7922
|
-
/* @__PURE__ */
|
|
7923
|
-
/* @__PURE__ */
|
|
8157
|
+
return /* @__PURE__ */ jsxs26(Fragment6, { children: [
|
|
8158
|
+
/* @__PURE__ */ jsx58(Global, { styles: globalStyles }),
|
|
8159
|
+
/* @__PURE__ */ jsx58(Editable3, { ...attributes })
|
|
7924
8160
|
] });
|
|
7925
8161
|
},
|
|
7926
8162
|
editableProps: {}
|
|
@@ -7929,27 +8165,27 @@ var ThemePlugin = createPlugin((editor) => {
|
|
|
7929
8165
|
|
|
7930
8166
|
// src/toolbar-plugin/render-editable/index.tsx
|
|
7931
8167
|
import { clsx as clsx10 } from "clsx";
|
|
7932
|
-
import { useCallback as
|
|
8168
|
+
import { useCallback as useCallback17, useRef as useRef13 } from "react";
|
|
7933
8169
|
import { Editor as Editor62, Transforms as Transforms44 } from "slate";
|
|
7934
|
-
import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as
|
|
8170
|
+
import { ReactEditor as ReactEditor16, useFocused, useSlateStatic as useSlateStatic21 } from "slate-react";
|
|
7935
8171
|
|
|
7936
8172
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
7937
8173
|
import { clsx as clsx8 } from "clsx";
|
|
7938
|
-
import { useCallback as
|
|
7939
|
-
import { ReactEditor as ReactEditor13, useSlateStatic as
|
|
8174
|
+
import { useCallback as useCallback13, useRef as useRef8, useState as useState8 } from "react";
|
|
8175
|
+
import { ReactEditor as ReactEditor13, useSlateStatic as useSlateStatic16 } from "slate-react";
|
|
7940
8176
|
|
|
7941
8177
|
// src/toolbar-plugin/styles/table-styles.ts
|
|
7942
|
-
import
|
|
7943
|
-
var $TableDialog =
|
|
8178
|
+
import styled35 from "@emotion/styled";
|
|
8179
|
+
var $TableDialog = styled35($Panel)`
|
|
7944
8180
|
padding: 0.5em;
|
|
7945
8181
|
`;
|
|
7946
|
-
var $TableDialogGrid =
|
|
8182
|
+
var $TableDialogGrid = styled35("div")`
|
|
7947
8183
|
display: grid;
|
|
7948
8184
|
grid-template-columns: repeat(5, 1.75em);
|
|
7949
8185
|
grid-template-rows: 1.5em;
|
|
7950
8186
|
/* grid-gap: 1px; */
|
|
7951
8187
|
`;
|
|
7952
|
-
var $TableDialogGridCell =
|
|
8188
|
+
var $TableDialogGridCell = styled35("div")`
|
|
7953
8189
|
background: var(--shade-100);
|
|
7954
8190
|
height: 1.5em;
|
|
7955
8191
|
border-radius: 0.125em;
|
|
@@ -7962,7 +8198,7 @@ var $TableDialogGridCell = styled33("div")`
|
|
|
7962
8198
|
`;
|
|
7963
8199
|
|
|
7964
8200
|
// src/toolbar-plugin/components/dialog/table-dialog.tsx
|
|
7965
|
-
import { Fragment as Fragment7, jsx as
|
|
8201
|
+
import { Fragment as Fragment7, jsx as jsx59, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
7966
8202
|
function createRange2(size) {
|
|
7967
8203
|
return [...Array(size).keys()];
|
|
7968
8204
|
}
|
|
@@ -7971,20 +8207,20 @@ function TableDialog({
|
|
|
7971
8207
|
close
|
|
7972
8208
|
}) {
|
|
7973
8209
|
const [hover, setHover] = useState8({ x: 0, y: 0 });
|
|
7974
|
-
const editor =
|
|
7975
|
-
const ref =
|
|
8210
|
+
const editor = useSlateStatic16();
|
|
8211
|
+
const ref = useRef8(null);
|
|
7976
8212
|
const style = useAbsoluteReposition({ src: ref, dest }, ({ dest: dest2 }) => {
|
|
7977
8213
|
return { left: dest2.left - 8, top: dest2.top + dest2.height };
|
|
7978
8214
|
});
|
|
7979
8215
|
const rows = createRange2(5).map((i) => i + 1);
|
|
7980
8216
|
const cols = createRange2(5).map((i) => i + 1);
|
|
7981
|
-
const hoverCell =
|
|
8217
|
+
const hoverCell = useCallback13(
|
|
7982
8218
|
(x, y) => {
|
|
7983
8219
|
setHover({ x, y });
|
|
7984
8220
|
},
|
|
7985
8221
|
[setHover]
|
|
7986
8222
|
);
|
|
7987
|
-
const createTable2 =
|
|
8223
|
+
const createTable2 = useCallback13(
|
|
7988
8224
|
(x, y) => {
|
|
7989
8225
|
editor.tablePlugin.insertTable(x, y);
|
|
7990
8226
|
ReactEditor13.focus(editor);
|
|
@@ -7992,12 +8228,12 @@ function TableDialog({
|
|
|
7992
8228
|
},
|
|
7993
8229
|
[editor]
|
|
7994
8230
|
);
|
|
7995
|
-
return /* @__PURE__ */
|
|
7996
|
-
/* @__PURE__ */
|
|
7997
|
-
/* @__PURE__ */
|
|
8231
|
+
return /* @__PURE__ */ jsxs27(Fragment7, { children: [
|
|
8232
|
+
/* @__PURE__ */ jsx59(CloseMask, { close }),
|
|
8233
|
+
/* @__PURE__ */ jsx59($TableDialog, { ref, style, children: /* @__PURE__ */ jsx59($TableDialogGrid, { onMouseLeave: () => hoverCell(0, 0), children: rows.map((y) => {
|
|
7998
8234
|
return cols.map((x) => {
|
|
7999
8235
|
const selected = x <= hover.x && y <= hover.y;
|
|
8000
|
-
return /* @__PURE__ */
|
|
8236
|
+
return /* @__PURE__ */ jsx59(
|
|
8001
8237
|
$TableDialogGridCell,
|
|
8002
8238
|
{
|
|
8003
8239
|
className: clsx8({ "--selected": selected }),
|
|
@@ -8013,66 +8249,57 @@ function TableDialog({
|
|
|
8013
8249
|
|
|
8014
8250
|
// src/toolbar-plugin/components/toolbar/toolbar.tsx
|
|
8015
8251
|
import throttle2 from "lodash.throttle";
|
|
8016
|
-
import { useEffect as useEffect8, useRef as
|
|
8017
|
-
import { useSlateStatic as
|
|
8252
|
+
import { useEffect as useEffect8, useRef as useRef12, useState as useState11 } from "react";
|
|
8253
|
+
import { useSlateStatic as useSlateStatic20 } from "slate-react";
|
|
8018
8254
|
|
|
8019
8255
|
// src/toolbar-plugin/icons.tsx
|
|
8020
|
-
import { jsx as
|
|
8021
|
-
var H = () => /* @__PURE__ */
|
|
8022
|
-
var More = () => /* @__PURE__ */
|
|
8023
|
-
var LinkPlus = () => /* @__PURE__ */
|
|
8024
|
-
var H1 = () => /* @__PURE__ */
|
|
8025
|
-
var H2 = () => /* @__PURE__ */
|
|
8026
|
-
var H3 = () => /* @__PURE__ */
|
|
8027
|
-
var Normal = () => /* @__PURE__ */
|
|
8028
|
-
var Bold = () => /* @__PURE__ */
|
|
8029
|
-
var Italic = () => /* @__PURE__ */
|
|
8030
|
-
var Link = () => /* @__PURE__ */
|
|
8031
|
-
/* @__PURE__ */
|
|
8032
|
-
/* @__PURE__ */
|
|
8033
|
-
] });
|
|
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" }) });
|
|
8035
|
-
var DoubleQuote = () => /* @__PURE__ */ jsxs27(TablerIcon, { children: [
|
|
8036
|
-
/* @__PURE__ */ jsx56("path", { d: "M10 9l4 3-4 3" }),
|
|
8037
|
-
/* @__PURE__ */ jsx56("path", { d: "M16 9l4 3-4 3" })
|
|
8256
|
+
import { jsx as jsx60, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
8257
|
+
var H = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4" }) });
|
|
8258
|
+
var More = () => /* @__PURE__ */ jsx60(TablerIcon, { className: "--more-icon", width: "0.5em", viewBox: "0 0 12 24", children: /* @__PURE__ */ jsx60("path", { d: "m2 12 4 4 4-4" }) });
|
|
8259
|
+
var LinkPlus = () => /* @__PURE__ */ jsx60(TablerIcon, { width: "0.5em", viewBox: "6 0 12 24", children: /* @__PURE__ */ jsx60("path", { d: "M9 12h6M12 9v6" }) });
|
|
8260
|
+
var H1 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
|
|
8261
|
+
var H2 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("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" }) });
|
|
8262
|
+
var H3 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2" }) });
|
|
8263
|
+
var Normal = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z" }) });
|
|
8264
|
+
var Bold = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7" }) });
|
|
8265
|
+
var Italic = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M11 5h6M7 19h6M14 5l-4 14" }) });
|
|
8266
|
+
var Link = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8267
|
+
/* @__PURE__ */ jsx60("path", { d: "M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5" }),
|
|
8268
|
+
/* @__PURE__ */ jsx60("path", { d: "M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5" })
|
|
8038
8269
|
] });
|
|
8039
|
-
var
|
|
8040
|
-
var
|
|
8041
|
-
/* @__PURE__ */
|
|
8042
|
-
/* @__PURE__ */
|
|
8270
|
+
var Quote = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("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" }) });
|
|
8271
|
+
var DoubleQuote = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8272
|
+
/* @__PURE__ */ jsx60("path", { d: "M10 9l4 3-4 3" }),
|
|
8273
|
+
/* @__PURE__ */ jsx60("path", { d: "M16 9l4 3-4 3" })
|
|
8043
8274
|
] });
|
|
8044
|
-
var
|
|
8045
|
-
var
|
|
8046
|
-
|
|
8047
|
-
/* @__PURE__ */
|
|
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" })
|
|
8275
|
+
var BulletList = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01" }) });
|
|
8276
|
+
var Table2 = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8277
|
+
/* @__PURE__ */ jsx60("rect", { x: 4, y: 4, width: 16, height: 16, rx: 2 }),
|
|
8278
|
+
/* @__PURE__ */ jsx60("path", { d: "M4 10h16M10 4v16" })
|
|
8051
8279
|
] });
|
|
8052
|
-
var
|
|
8053
|
-
var
|
|
8054
|
-
var
|
|
8055
|
-
|
|
8056
|
-
/* @__PURE__ */
|
|
8057
|
-
/* @__PURE__ */
|
|
8280
|
+
var Code = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16" }) });
|
|
8281
|
+
var CodeBlock2 = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M9 8L5 12L9 16M15 8L19 12L15 16" }) });
|
|
8282
|
+
var Image = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8283
|
+
/* @__PURE__ */ jsx60("path", { d: "M15 8h.01" }),
|
|
8284
|
+
/* @__PURE__ */ jsx60("rect", { x: 4, y: 4, width: 16, height: 16, rx: 3 }),
|
|
8285
|
+
/* @__PURE__ */ jsx60("path", { d: "m4 15 4-4a3 5 0 0 1 3 0l5 5" }),
|
|
8286
|
+
/* @__PURE__ */ jsx60("path", { d: "m14 14 1-1a3 5 0 0 1 3 0l2 2" })
|
|
8058
8287
|
] });
|
|
8059
|
-
var
|
|
8060
|
-
var
|
|
8061
|
-
var
|
|
8062
|
-
var
|
|
8063
|
-
/* @__PURE__ */
|
|
8064
|
-
/* @__PURE__ */
|
|
8288
|
+
var Plus = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M12 5v14M5 12h14" }) });
|
|
8289
|
+
var Strikethrough = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("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" }) });
|
|
8290
|
+
var Underline = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M7 5v5a5 5 0 0 0 10 0V5M5 19h14" }) });
|
|
8291
|
+
var ListCheck = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8292
|
+
/* @__PURE__ */ jsx60("path", { d: "m9 11 3 3 8-8" }),
|
|
8293
|
+
/* @__PURE__ */ jsx60("path", { d: "M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9" })
|
|
8065
8294
|
] });
|
|
8066
|
-
var
|
|
8067
|
-
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
/* @__PURE__ */
|
|
8073
|
-
/* @__PURE__ */
|
|
8074
|
-
/* @__PURE__ */ jsx56("path", { d: "M3 21h7" }),
|
|
8075
|
-
/* @__PURE__ */ jsx56("path", { d: "M18 19h3M19.5 17.5v3" })
|
|
8295
|
+
var ListNumbers = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6" }) });
|
|
8296
|
+
var IncreaseDepth = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3" }) });
|
|
8297
|
+
var DecreaseDepth = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3" }) });
|
|
8298
|
+
var Close = () => /* @__PURE__ */ jsx60(TablerIcon, { children: /* @__PURE__ */ jsx60("path", { d: "M18 6L6 18M6 6l12 12" }) });
|
|
8299
|
+
var Highlight = () => /* @__PURE__ */ jsxs28(TablerIcon, { children: [
|
|
8300
|
+
/* @__PURE__ */ jsx60("path", { d: "M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4" }),
|
|
8301
|
+
/* @__PURE__ */ jsx60("path", { d: "M13.5 6.5l4 4" }),
|
|
8302
|
+
/* @__PURE__ */ jsx60("path", { d: "m14 19 6-6M18 15l2 2M5 21h4" })
|
|
8076
8303
|
] });
|
|
8077
8304
|
|
|
8078
8305
|
// src/toolbar-plugin/items/block-items.tsx
|
|
@@ -8081,17 +8308,15 @@ var listDepthItems = [
|
|
|
8081
8308
|
icon: IncreaseDepth,
|
|
8082
8309
|
title: t("increaseDepth"),
|
|
8083
8310
|
hotkey: "tab",
|
|
8084
|
-
action: (editor) => editor.list
|
|
8085
|
-
active: (editor) => editor.list
|
|
8086
|
-
show: (editor) => !!editor.list
|
|
8311
|
+
action: (editor) => editor.list.increaseDepth(),
|
|
8312
|
+
active: (editor) => editor.list.canIncreaseDepth()
|
|
8087
8313
|
},
|
|
8088
8314
|
{
|
|
8089
8315
|
icon: DecreaseDepth,
|
|
8090
8316
|
title: t("decreaseDepth"),
|
|
8091
8317
|
hotkey: "shift+tab",
|
|
8092
|
-
action: (editor) => editor.list
|
|
8093
|
-
active: (editor) => editor.list
|
|
8094
|
-
show: (editor) => !!editor.list
|
|
8318
|
+
action: (editor) => editor.list.decreaseDepth(),
|
|
8319
|
+
active: (editor) => editor.list.canDecreaseDepth()
|
|
8095
8320
|
}
|
|
8096
8321
|
];
|
|
8097
8322
|
var blockItems = [
|
|
@@ -8136,49 +8361,77 @@ var compactBlockItems = [
|
|
|
8136
8361
|
];
|
|
8137
8362
|
|
|
8138
8363
|
// src/toolbar-plugin/components/dialog/image-url-dialog.tsx
|
|
8139
|
-
import { useState as useState9, useRef as
|
|
8140
|
-
import { useSlateStatic as
|
|
8364
|
+
import { useState as useState9, useRef as useRef9, useEffect as useEffect7, useCallback as useCallback14 } from "react";
|
|
8365
|
+
import { useSlateStatic as useSlateStatic17 } from "slate-react";
|
|
8141
8366
|
|
|
8142
8367
|
// src/toolbar-plugin/styles/file-dialog-styles.ts
|
|
8143
|
-
import
|
|
8144
|
-
var $FileDialog =
|
|
8145
|
-
padding: 1em;
|
|
8368
|
+
import styled36 from "@emotion/styled";
|
|
8369
|
+
var $FileDialog = styled36($Panel)`
|
|
8146
8370
|
width: 18em;
|
|
8371
|
+
padding: 0;
|
|
8372
|
+
overflow: hidden;
|
|
8147
8373
|
`;
|
|
8148
8374
|
|
|
8149
8375
|
// src/toolbar-plugin/components/dialog/image-url-dialog.tsx
|
|
8150
|
-
import { Fragment as Fragment8, jsx as
|
|
8376
|
+
import { Fragment as Fragment8, jsx as jsx61, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
8151
8377
|
function ImageUrlDialog({
|
|
8152
8378
|
dest,
|
|
8153
8379
|
close
|
|
8154
8380
|
}) {
|
|
8155
|
-
const editor =
|
|
8156
|
-
const ref =
|
|
8157
|
-
const fileInputRef =
|
|
8381
|
+
const editor = useSlateStatic17();
|
|
8382
|
+
const ref = useRef9(void 0);
|
|
8383
|
+
const fileInputRef = useRef9(null);
|
|
8384
|
+
const [dragOffset, setDragOffset] = useState9({ x: 0, y: 0 });
|
|
8385
|
+
const handleDrag = useCallback14((deltaX, deltaY) => {
|
|
8386
|
+
setDragOffset((prev) => ({ x: prev.x + deltaX, y: prev.y + deltaY }));
|
|
8387
|
+
}, []);
|
|
8158
8388
|
const savedState = editor.wysimark?.imageDialogState;
|
|
8159
|
-
const
|
|
8389
|
+
const hasOnImageSave = !!editor.wysimark?.onImageSave;
|
|
8160
8390
|
const [url, setUrl] = useState9(savedState?.url ?? "");
|
|
8161
8391
|
const [alt, setAlt] = useState9(savedState?.alt ?? "");
|
|
8162
8392
|
const [title, setTitle] = useState9(savedState?.title ?? "");
|
|
8163
|
-
const [
|
|
8164
|
-
const [
|
|
8165
|
-
const [
|
|
8393
|
+
const [titleManuallyEdited, setTitleManuallyEdited] = useState9(false);
|
|
8394
|
+
const [imageSource, setImageSource] = useState9(savedState?.imageSource ?? (hasOnImageSave ? "file" : "url"));
|
|
8395
|
+
const [vaultPath, setVaultPath] = useState9(savedState?.vaultPath ?? "");
|
|
8396
|
+
const [selectedFile, setSelectedFile] = useState9(savedState?.selectedFile);
|
|
8397
|
+
const [isSaving, setIsSaving] = useState9(false);
|
|
8398
|
+
const [previewUrl, setPreviewUrl] = useState9(null);
|
|
8399
|
+
const handleAltChange = useCallback14((e) => {
|
|
8400
|
+
const newAlt = e.target.value;
|
|
8401
|
+
setAlt(newAlt);
|
|
8402
|
+
if (!titleManuallyEdited) {
|
|
8403
|
+
setTitle(newAlt);
|
|
8404
|
+
}
|
|
8405
|
+
}, [titleManuallyEdited]);
|
|
8406
|
+
const handleTitleChange = useCallback14((e) => {
|
|
8407
|
+
setTitle(e.target.value);
|
|
8408
|
+
setTitleManuallyEdited(true);
|
|
8409
|
+
}, []);
|
|
8410
|
+
useEffect7(() => {
|
|
8411
|
+
if (selectedFile) {
|
|
8412
|
+
const url2 = URL.createObjectURL(selectedFile);
|
|
8413
|
+
setPreviewUrl(url2);
|
|
8414
|
+
return () => URL.revokeObjectURL(url2);
|
|
8415
|
+
} else {
|
|
8416
|
+
setPreviewUrl(null);
|
|
8417
|
+
}
|
|
8418
|
+
}, [selectedFile]);
|
|
8166
8419
|
useEffect7(() => {
|
|
8167
8420
|
if (editor.wysimark) {
|
|
8168
|
-
editor.wysimark.imageDialogState = { url, alt, title, imageSource,
|
|
8421
|
+
editor.wysimark.imageDialogState = { url, alt, title, imageSource, vaultPath, selectedFile };
|
|
8169
8422
|
}
|
|
8170
|
-
}, [url, alt, title, imageSource,
|
|
8423
|
+
}, [url, alt, title, imageSource, vaultPath, selectedFile]);
|
|
8171
8424
|
const clearState = () => {
|
|
8172
8425
|
if (editor.wysimark) {
|
|
8173
8426
|
editor.wysimark.imageDialogState = void 0;
|
|
8174
8427
|
}
|
|
8175
8428
|
};
|
|
8176
|
-
const
|
|
8429
|
+
const baseStyle = useAbsoluteReposition(
|
|
8177
8430
|
{ src: ref, dest },
|
|
8178
|
-
({ src, dest: dest2 }) => {
|
|
8431
|
+
({ src, dest: dest2 }, viewport) => {
|
|
8179
8432
|
return positionInside(
|
|
8180
8433
|
src,
|
|
8181
|
-
|
|
8434
|
+
viewport,
|
|
8182
8435
|
{
|
|
8183
8436
|
left: dest2.left - 16,
|
|
8184
8437
|
top: dest2.top + dest2.height
|
|
@@ -8187,230 +8440,291 @@ function ImageUrlDialog({
|
|
|
8187
8440
|
);
|
|
8188
8441
|
}
|
|
8189
8442
|
);
|
|
8190
|
-
|
|
8443
|
+
const style = {
|
|
8444
|
+
...baseStyle,
|
|
8445
|
+
left: baseStyle.left + dragOffset.x,
|
|
8446
|
+
top: baseStyle.top + dragOffset.y
|
|
8447
|
+
};
|
|
8448
|
+
async function handleSubmit(e) {
|
|
8191
8449
|
e.preventDefault();
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8450
|
+
if (imageSource === "file" && selectedFile && editor.wysimark?.onImageSave) {
|
|
8451
|
+
if (vaultPath.trim() === "")
|
|
8452
|
+
return;
|
|
8453
|
+
setIsSaving(true);
|
|
8454
|
+
try {
|
|
8455
|
+
const resultPath = await editor.wysimark.onImageSave(selectedFile, vaultPath);
|
|
8456
|
+
editor.image.insertImageFromUrl(resultPath, alt, title);
|
|
8457
|
+
clearState();
|
|
8458
|
+
close();
|
|
8459
|
+
} finally {
|
|
8460
|
+
setIsSaving(false);
|
|
8461
|
+
}
|
|
8462
|
+
} else if (imageSource === "url") {
|
|
8463
|
+
if (url.trim() === "")
|
|
8464
|
+
return;
|
|
8465
|
+
editor.image.insertImageFromUrl(url, alt, title);
|
|
8466
|
+
clearState();
|
|
8467
|
+
close();
|
|
8468
|
+
}
|
|
8198
8469
|
}
|
|
8199
8470
|
function handleCancel() {
|
|
8200
8471
|
clearState();
|
|
8201
8472
|
close();
|
|
8202
8473
|
}
|
|
8203
|
-
|
|
8474
|
+
function handleFileSelect(e) {
|
|
8204
8475
|
const file = e.target.files?.[0];
|
|
8205
|
-
if (!file
|
|
8476
|
+
if (!file)
|
|
8206
8477
|
return;
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
setUploadedUrl(resultUrl);
|
|
8211
|
-
} catch (error) {
|
|
8212
|
-
console.error("Failed to upload image:", error);
|
|
8213
|
-
} finally {
|
|
8214
|
-
setIsUploading(false);
|
|
8478
|
+
setSelectedFile(file);
|
|
8479
|
+
if (!vaultPath) {
|
|
8480
|
+
setVaultPath(`attachments/${file.name}`);
|
|
8215
8481
|
}
|
|
8216
8482
|
}
|
|
8217
8483
|
function handleSelectFileClick() {
|
|
8218
8484
|
fileInputRef.current?.click();
|
|
8219
8485
|
}
|
|
8220
|
-
const isSubmitDisabled = imageSource === "file" ?
|
|
8221
|
-
return /* @__PURE__ */
|
|
8222
|
-
/* @__PURE__ */
|
|
8223
|
-
/* @__PURE__ */
|
|
8224
|
-
|
|
8225
|
-
|
|
8226
|
-
|
|
8486
|
+
const isSubmitDisabled = imageSource === "file" ? !selectedFile || vaultPath.trim() === "" || isSaving : url.trim() === "";
|
|
8487
|
+
return /* @__PURE__ */ jsxs29(Fragment8, { children: [
|
|
8488
|
+
/* @__PURE__ */ jsx61(CloseMask, { close }),
|
|
8489
|
+
/* @__PURE__ */ jsxs29($FileDialog, { ref, style, children: [
|
|
8490
|
+
/* @__PURE__ */ jsx61(DraggableHeader, { onDrag: handleDrag }),
|
|
8491
|
+
/* @__PURE__ */ jsxs29("form", { onSubmit: (e) => void handleSubmit(e), style: { padding: "8px" }, children: [
|
|
8492
|
+
hasOnImageSave && /* @__PURE__ */ jsxs29("div", { style: { marginBottom: "12px" }, children: [
|
|
8493
|
+
/* @__PURE__ */ jsxs29("label", { style: { display: "inline-flex", alignItems: "center", marginRight: "16px", cursor: "pointer" }, children: [
|
|
8494
|
+
/* @__PURE__ */ jsx61(
|
|
8495
|
+
"input",
|
|
8496
|
+
{
|
|
8497
|
+
type: "radio",
|
|
8498
|
+
name: "imageSource",
|
|
8499
|
+
value: "file",
|
|
8500
|
+
checked: imageSource === "file",
|
|
8501
|
+
onChange: () => setImageSource("file"),
|
|
8502
|
+
style: { marginRight: "4px" }
|
|
8503
|
+
}
|
|
8504
|
+
),
|
|
8505
|
+
t("imageSourceFile")
|
|
8506
|
+
] }),
|
|
8507
|
+
/* @__PURE__ */ jsxs29("label", { style: { display: "inline-flex", alignItems: "center", cursor: "pointer" }, children: [
|
|
8508
|
+
/* @__PURE__ */ jsx61(
|
|
8509
|
+
"input",
|
|
8510
|
+
{
|
|
8511
|
+
type: "radio",
|
|
8512
|
+
name: "imageSource",
|
|
8513
|
+
value: "url",
|
|
8514
|
+
checked: imageSource === "url",
|
|
8515
|
+
onChange: () => setImageSource("url"),
|
|
8516
|
+
style: { marginRight: "4px" }
|
|
8517
|
+
}
|
|
8518
|
+
),
|
|
8519
|
+
t("imageSourceUrl")
|
|
8520
|
+
] })
|
|
8521
|
+
] }),
|
|
8522
|
+
imageSource === "url" ? /* @__PURE__ */ jsxs29("div", { style: { marginBottom: "8px" }, children: [
|
|
8523
|
+
/* @__PURE__ */ jsx61("label", { style: { display: "block", marginBottom: "4px" }, children: t("imageUrlRequired") }),
|
|
8524
|
+
/* @__PURE__ */ jsx61(
|
|
8525
|
+
"input",
|
|
8526
|
+
{
|
|
8527
|
+
type: "text",
|
|
8528
|
+
value: url,
|
|
8529
|
+
onChange: (e) => setUrl(e.target.value),
|
|
8530
|
+
style: {
|
|
8531
|
+
width: "100%",
|
|
8532
|
+
padding: "6px",
|
|
8533
|
+
boxSizing: "border-box",
|
|
8534
|
+
border: "1px solid var(--shade-300)",
|
|
8535
|
+
borderRadius: "4px",
|
|
8536
|
+
backgroundColor: "var(--shade-50)",
|
|
8537
|
+
color: "var(--shade-700)"
|
|
8538
|
+
},
|
|
8539
|
+
placeholder: "https://example.com/image.jpg"
|
|
8540
|
+
}
|
|
8541
|
+
)
|
|
8542
|
+
] }) : /* @__PURE__ */ jsxs29("div", { style: { marginBottom: "8px" }, children: [
|
|
8543
|
+
/* @__PURE__ */ jsx61(
|
|
8227
8544
|
"input",
|
|
8228
8545
|
{
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
style: { marginRight: "4px" }
|
|
8546
|
+
ref: fileInputRef,
|
|
8547
|
+
type: "file",
|
|
8548
|
+
accept: "image/*",
|
|
8549
|
+
onChange: handleFileSelect,
|
|
8550
|
+
style: { display: "none" }
|
|
8235
8551
|
}
|
|
8236
8552
|
),
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
/* @__PURE__ */ jsxs28("label", { style: { display: "inline-flex", alignItems: "center", cursor: "pointer" }, children: [
|
|
8240
|
-
/* @__PURE__ */ jsx57(
|
|
8241
|
-
"input",
|
|
8553
|
+
/* @__PURE__ */ jsx61(
|
|
8554
|
+
"button",
|
|
8242
8555
|
{
|
|
8243
|
-
type: "
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8556
|
+
type: "button",
|
|
8557
|
+
onClick: handleSelectFileClick,
|
|
8558
|
+
disabled: isSaving,
|
|
8559
|
+
style: {
|
|
8560
|
+
padding: "8px 16px",
|
|
8561
|
+
backgroundColor: isSaving ? "#ccc" : "#0078d4",
|
|
8562
|
+
color: isSaving ? "#666" : "white",
|
|
8563
|
+
border: "none",
|
|
8564
|
+
borderRadius: "4px",
|
|
8565
|
+
cursor: isSaving ? "not-allowed" : "pointer",
|
|
8566
|
+
marginBottom: "8px",
|
|
8567
|
+
fontWeight: "bold"
|
|
8568
|
+
},
|
|
8569
|
+
children: t("selectFile")
|
|
8249
8570
|
}
|
|
8250
8571
|
),
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
{
|
|
8259
|
-
type: "text",
|
|
8260
|
-
value: url,
|
|
8261
|
-
onChange: (e) => setUrl(e.target.value),
|
|
8262
|
-
style: {
|
|
8263
|
-
width: "100%",
|
|
8264
|
-
padding: "6px",
|
|
8265
|
-
boxSizing: "border-box",
|
|
8266
|
-
border: "1px solid #ccc",
|
|
8267
|
-
borderRadius: "4px"
|
|
8268
|
-
},
|
|
8269
|
-
placeholder: "https://example.com/image.jpg"
|
|
8270
|
-
}
|
|
8271
|
-
)
|
|
8272
|
-
] }) : /* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8273
|
-
/* @__PURE__ */ jsx57(
|
|
8274
|
-
"input",
|
|
8275
|
-
{
|
|
8276
|
-
ref: fileInputRef,
|
|
8277
|
-
type: "file",
|
|
8278
|
-
accept: "image/*",
|
|
8279
|
-
onChange: handleFileSelect,
|
|
8280
|
-
style: { display: "none" }
|
|
8281
|
-
}
|
|
8282
|
-
),
|
|
8283
|
-
/* @__PURE__ */ jsx57(
|
|
8284
|
-
"button",
|
|
8285
|
-
{
|
|
8286
|
-
type: "button",
|
|
8287
|
-
onClick: handleSelectFileClick,
|
|
8288
|
-
disabled: isUploading,
|
|
8289
|
-
style: {
|
|
8290
|
-
padding: "8px 16px",
|
|
8291
|
-
backgroundColor: isUploading ? "#ccc" : "#f0f0f0",
|
|
8292
|
-
border: "1px solid #ccc",
|
|
8572
|
+
selectedFile && /* @__PURE__ */ jsxs29("div", { style: { marginTop: "8px" }, children: [
|
|
8573
|
+
/* @__PURE__ */ jsxs29("div", { style: {
|
|
8574
|
+
display: "flex",
|
|
8575
|
+
alignItems: "center",
|
|
8576
|
+
gap: "8px",
|
|
8577
|
+
padding: "8px",
|
|
8578
|
+
backgroundColor: "var(--shade-100)",
|
|
8293
8579
|
borderRadius: "4px",
|
|
8294
|
-
cursor: isUploading ? "not-allowed" : "pointer",
|
|
8295
8580
|
marginBottom: "8px"
|
|
8296
|
-
},
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8581
|
+
}, children: [
|
|
8582
|
+
previewUrl && /* @__PURE__ */ jsx61(
|
|
8583
|
+
"img",
|
|
8584
|
+
{
|
|
8585
|
+
src: previewUrl,
|
|
8586
|
+
alt: "Preview",
|
|
8587
|
+
style: {
|
|
8588
|
+
maxWidth: "60px",
|
|
8589
|
+
maxHeight: "60px",
|
|
8590
|
+
objectFit: "contain",
|
|
8591
|
+
borderRadius: "4px"
|
|
8592
|
+
}
|
|
8593
|
+
}
|
|
8594
|
+
),
|
|
8595
|
+
/* @__PURE__ */ jsxs29("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
8596
|
+
/* @__PURE__ */ jsx61("div", { style: {
|
|
8597
|
+
fontWeight: "bold",
|
|
8598
|
+
overflow: "hidden",
|
|
8599
|
+
textOverflow: "ellipsis",
|
|
8600
|
+
whiteSpace: "nowrap"
|
|
8601
|
+
}, children: selectedFile.name }),
|
|
8602
|
+
/* @__PURE__ */ jsxs29("div", { style: { fontSize: "12px", color: "var(--shade-500)" }, children: [
|
|
8603
|
+
(selectedFile.size / 1024).toFixed(1),
|
|
8604
|
+
" KB"
|
|
8605
|
+
] })
|
|
8606
|
+
] })
|
|
8607
|
+
] }),
|
|
8608
|
+
/* @__PURE__ */ jsx61("label", { style: { display: "block", marginBottom: "4px" }, children: t("vaultPath") }),
|
|
8609
|
+
/* @__PURE__ */ jsx61(
|
|
8610
|
+
"input",
|
|
8611
|
+
{
|
|
8612
|
+
type: "text",
|
|
8613
|
+
value: vaultPath,
|
|
8614
|
+
onChange: (e) => setVaultPath(e.target.value),
|
|
8615
|
+
style: {
|
|
8616
|
+
width: "100%",
|
|
8617
|
+
padding: "6px",
|
|
8618
|
+
boxSizing: "border-box",
|
|
8619
|
+
border: "1px solid var(--shade-300)",
|
|
8620
|
+
borderRadius: "4px",
|
|
8621
|
+
backgroundColor: "var(--shade-50)",
|
|
8622
|
+
color: "var(--shade-700)"
|
|
8623
|
+
},
|
|
8624
|
+
placeholder: "attachments/image.png"
|
|
8625
|
+
}
|
|
8626
|
+
),
|
|
8627
|
+
/* @__PURE__ */ jsx61("div", { style: { fontSize: "12px", color: "var(--shade-500)", marginTop: "4px" }, children: t("vaultPathHint") })
|
|
8628
|
+
] })
|
|
8629
|
+
] }),
|
|
8630
|
+
/* @__PURE__ */ jsxs29("div", { style: { marginBottom: "8px" }, children: [
|
|
8631
|
+
/* @__PURE__ */ jsx61("label", { style: { display: "block", marginBottom: "4px" }, children: t("altText") }),
|
|
8632
|
+
/* @__PURE__ */ jsx61(
|
|
8303
8633
|
"input",
|
|
8304
8634
|
{
|
|
8305
8635
|
type: "text",
|
|
8306
|
-
value:
|
|
8307
|
-
|
|
8636
|
+
value: alt,
|
|
8637
|
+
onChange: handleAltChange,
|
|
8308
8638
|
style: {
|
|
8309
8639
|
width: "100%",
|
|
8310
8640
|
padding: "6px",
|
|
8311
8641
|
boxSizing: "border-box",
|
|
8312
|
-
border: "1px solid
|
|
8642
|
+
border: "1px solid var(--shade-300)",
|
|
8313
8643
|
borderRadius: "4px",
|
|
8314
|
-
backgroundColor: "
|
|
8315
|
-
color: "
|
|
8316
|
-
}
|
|
8644
|
+
backgroundColor: "var(--shade-50)",
|
|
8645
|
+
color: "var(--shade-700)"
|
|
8646
|
+
},
|
|
8647
|
+
placeholder: t("imageDescription")
|
|
8648
|
+
}
|
|
8649
|
+
)
|
|
8650
|
+
] }),
|
|
8651
|
+
/* @__PURE__ */ jsxs29("div", { style: { marginBottom: "8px" }, children: [
|
|
8652
|
+
/* @__PURE__ */ jsx61("label", { style: { display: "block", marginBottom: "4px" }, children: t("title") }),
|
|
8653
|
+
/* @__PURE__ */ jsx61(
|
|
8654
|
+
"input",
|
|
8655
|
+
{
|
|
8656
|
+
type: "text",
|
|
8657
|
+
value: title,
|
|
8658
|
+
onChange: handleTitleChange,
|
|
8659
|
+
style: {
|
|
8660
|
+
width: "100%",
|
|
8661
|
+
padding: "6px",
|
|
8662
|
+
boxSizing: "border-box",
|
|
8663
|
+
border: "1px solid var(--shade-300)",
|
|
8664
|
+
borderRadius: "4px",
|
|
8665
|
+
backgroundColor: "var(--shade-50)",
|
|
8666
|
+
color: "var(--shade-700)"
|
|
8667
|
+
},
|
|
8668
|
+
placeholder: t("imageTitle")
|
|
8669
|
+
}
|
|
8670
|
+
)
|
|
8671
|
+
] }),
|
|
8672
|
+
/* @__PURE__ */ jsxs29("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
8673
|
+
/* @__PURE__ */ jsx61(
|
|
8674
|
+
"button",
|
|
8675
|
+
{
|
|
8676
|
+
type: "submit",
|
|
8677
|
+
disabled: isSubmitDisabled,
|
|
8678
|
+
style: {
|
|
8679
|
+
display: "flex",
|
|
8680
|
+
alignItems: "center",
|
|
8681
|
+
padding: "8px 16px",
|
|
8682
|
+
backgroundColor: isSubmitDisabled ? "#ccc" : "#0078d4",
|
|
8683
|
+
color: "white",
|
|
8684
|
+
border: "none",
|
|
8685
|
+
borderRadius: "4px",
|
|
8686
|
+
cursor: isSubmitDisabled ? "not-allowed" : "pointer",
|
|
8687
|
+
fontWeight: "bold"
|
|
8688
|
+
},
|
|
8689
|
+
children: isSaving ? t("saving") : t("register")
|
|
8690
|
+
}
|
|
8691
|
+
),
|
|
8692
|
+
/* @__PURE__ */ jsx61(
|
|
8693
|
+
"button",
|
|
8694
|
+
{
|
|
8695
|
+
type: "button",
|
|
8696
|
+
onClick: handleCancel,
|
|
8697
|
+
style: {
|
|
8698
|
+
padding: "8px 16px",
|
|
8699
|
+
backgroundColor: "var(--shade-100)",
|
|
8700
|
+
color: "var(--shade-700)",
|
|
8701
|
+
border: "1px solid var(--shade-300)",
|
|
8702
|
+
borderRadius: "4px",
|
|
8703
|
+
cursor: "pointer"
|
|
8704
|
+
},
|
|
8705
|
+
children: t("cancel")
|
|
8317
8706
|
}
|
|
8318
8707
|
)
|
|
8319
8708
|
] })
|
|
8320
|
-
] }),
|
|
8321
|
-
/* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8322
|
-
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("altText") }),
|
|
8323
|
-
/* @__PURE__ */ jsx57(
|
|
8324
|
-
"input",
|
|
8325
|
-
{
|
|
8326
|
-
type: "text",
|
|
8327
|
-
value: alt,
|
|
8328
|
-
onChange: (e) => setAlt(e.target.value),
|
|
8329
|
-
style: {
|
|
8330
|
-
width: "100%",
|
|
8331
|
-
padding: "6px",
|
|
8332
|
-
boxSizing: "border-box",
|
|
8333
|
-
border: "1px solid #ccc",
|
|
8334
|
-
borderRadius: "4px"
|
|
8335
|
-
},
|
|
8336
|
-
placeholder: t("imageDescription")
|
|
8337
|
-
}
|
|
8338
|
-
)
|
|
8339
|
-
] }),
|
|
8340
|
-
/* @__PURE__ */ jsxs28("div", { style: { marginBottom: "8px" }, children: [
|
|
8341
|
-
/* @__PURE__ */ jsx57("label", { style: { display: "block", marginBottom: "4px" }, children: t("title") }),
|
|
8342
|
-
/* @__PURE__ */ jsx57(
|
|
8343
|
-
"input",
|
|
8344
|
-
{
|
|
8345
|
-
type: "text",
|
|
8346
|
-
value: title,
|
|
8347
|
-
onChange: (e) => setTitle(e.target.value),
|
|
8348
|
-
style: {
|
|
8349
|
-
width: "100%",
|
|
8350
|
-
padding: "6px",
|
|
8351
|
-
boxSizing: "border-box",
|
|
8352
|
-
border: "1px solid #ccc",
|
|
8353
|
-
borderRadius: "4px"
|
|
8354
|
-
},
|
|
8355
|
-
placeholder: t("imageTitle")
|
|
8356
|
-
}
|
|
8357
|
-
)
|
|
8358
|
-
] }),
|
|
8359
|
-
/* @__PURE__ */ jsxs28("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
8360
|
-
/* @__PURE__ */ jsx57(
|
|
8361
|
-
"button",
|
|
8362
|
-
{
|
|
8363
|
-
type: "submit",
|
|
8364
|
-
disabled: isSubmitDisabled,
|
|
8365
|
-
style: {
|
|
8366
|
-
display: "flex",
|
|
8367
|
-
alignItems: "center",
|
|
8368
|
-
padding: "8px 16px",
|
|
8369
|
-
backgroundColor: isSubmitDisabled ? "#ccc" : "#0078d4",
|
|
8370
|
-
color: "white",
|
|
8371
|
-
border: "none",
|
|
8372
|
-
borderRadius: "4px",
|
|
8373
|
-
cursor: isSubmitDisabled ? "not-allowed" : "pointer",
|
|
8374
|
-
fontWeight: "bold"
|
|
8375
|
-
},
|
|
8376
|
-
children: t("register")
|
|
8377
|
-
}
|
|
8378
|
-
),
|
|
8379
|
-
/* @__PURE__ */ jsx57(
|
|
8380
|
-
"button",
|
|
8381
|
-
{
|
|
8382
|
-
type: "button",
|
|
8383
|
-
onClick: handleCancel,
|
|
8384
|
-
style: {
|
|
8385
|
-
padding: "8px 16px",
|
|
8386
|
-
backgroundColor: "#f0f0f0",
|
|
8387
|
-
color: "#333",
|
|
8388
|
-
border: "1px solid #ccc",
|
|
8389
|
-
borderRadius: "4px",
|
|
8390
|
-
cursor: "pointer"
|
|
8391
|
-
},
|
|
8392
|
-
children: t("cancel")
|
|
8393
|
-
}
|
|
8394
|
-
)
|
|
8395
8709
|
] })
|
|
8396
|
-
] })
|
|
8710
|
+
] })
|
|
8397
8711
|
] });
|
|
8398
8712
|
}
|
|
8399
8713
|
|
|
8400
8714
|
// src/toolbar-plugin/components/dialog/anchor-dialog.tsx
|
|
8401
8715
|
import { isHotkey as isHotkey3 } from "is-hotkey";
|
|
8402
8716
|
import {
|
|
8403
|
-
useCallback as
|
|
8717
|
+
useCallback as useCallback15,
|
|
8404
8718
|
useMemo as useMemo2,
|
|
8405
|
-
useRef as
|
|
8719
|
+
useRef as useRef10,
|
|
8406
8720
|
useState as useState10
|
|
8407
8721
|
} from "react";
|
|
8408
8722
|
import { Editor as Editor59, Range as Range10 } from "slate";
|
|
8409
|
-
import { ReactEditor as ReactEditor14, useSlateStatic as
|
|
8723
|
+
import { ReactEditor as ReactEditor14, useSlateStatic as useSlateStatic18 } from "slate-react";
|
|
8410
8724
|
|
|
8411
8725
|
// src/toolbar-plugin/styles/dialog-shared-styles.ts
|
|
8412
|
-
import
|
|
8413
|
-
var $DialogButton =
|
|
8726
|
+
import styled37 from "@emotion/styled";
|
|
8727
|
+
var $DialogButton = styled37("div")`
|
|
8414
8728
|
/* Center vertically and horizontally */
|
|
8415
8729
|
display: flex;
|
|
8416
8730
|
align-items: center;
|
|
@@ -8435,7 +8749,7 @@ var $DialogButton = styled35("div")`
|
|
|
8435
8749
|
stroke-width: 2px;
|
|
8436
8750
|
}
|
|
8437
8751
|
`;
|
|
8438
|
-
var $DialogHint =
|
|
8752
|
+
var $DialogHint = styled37("div")`
|
|
8439
8753
|
font-size: 0.875em;
|
|
8440
8754
|
margin-top: 0.5em;
|
|
8441
8755
|
color: var(--shade-500);
|
|
@@ -8443,15 +8757,19 @@ var $DialogHint = styled35("div")`
|
|
|
8443
8757
|
`;
|
|
8444
8758
|
|
|
8445
8759
|
// src/toolbar-plugin/components/dialog/anchor-dialog.tsx
|
|
8446
|
-
import { Fragment as Fragment9, jsx as
|
|
8760
|
+
import { Fragment as Fragment9, jsx as jsx62, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
8447
8761
|
var isEnter = isHotkey3("enter");
|
|
8448
8762
|
function AnchorDialog2({
|
|
8449
8763
|
dest,
|
|
8450
8764
|
close
|
|
8451
8765
|
}) {
|
|
8452
|
-
const editor =
|
|
8453
|
-
const ref =
|
|
8454
|
-
const
|
|
8766
|
+
const editor = useSlateStatic18();
|
|
8767
|
+
const ref = useRef10(null);
|
|
8768
|
+
const [dragOffset, setDragOffset] = useState10({ x: 0, y: 0 });
|
|
8769
|
+
const handleDrag = useCallback15((deltaX, deltaY) => {
|
|
8770
|
+
setDragOffset((prev) => ({ x: prev.x + deltaX, y: prev.y + deltaY }));
|
|
8771
|
+
}, []);
|
|
8772
|
+
const baseStyle = useAbsoluteReposition(
|
|
8455
8773
|
{ src: ref, dest },
|
|
8456
8774
|
({ src, dest: dest2 }, viewport) => {
|
|
8457
8775
|
return positionInside(
|
|
@@ -8465,6 +8783,11 @@ function AnchorDialog2({
|
|
|
8465
8783
|
);
|
|
8466
8784
|
}
|
|
8467
8785
|
);
|
|
8786
|
+
const style = {
|
|
8787
|
+
...baseStyle,
|
|
8788
|
+
left: baseStyle.left + dragOffset.x,
|
|
8789
|
+
top: baseStyle.top + dragOffset.y
|
|
8790
|
+
};
|
|
8468
8791
|
const initialText = useMemo2(() => {
|
|
8469
8792
|
const { selection } = editor;
|
|
8470
8793
|
if (selection && !Range10.isCollapsed(selection)) {
|
|
@@ -8483,13 +8806,13 @@ function AnchorDialog2({
|
|
|
8483
8806
|
ReactEditor14.focus(editor);
|
|
8484
8807
|
close();
|
|
8485
8808
|
};
|
|
8486
|
-
const onChangeUrl =
|
|
8809
|
+
const onChangeUrl = useCallback15(
|
|
8487
8810
|
(e) => {
|
|
8488
8811
|
setUrl(e.currentTarget.value);
|
|
8489
8812
|
},
|
|
8490
8813
|
[setUrl]
|
|
8491
8814
|
);
|
|
8492
|
-
const onChangeText =
|
|
8815
|
+
const onChangeText = useCallback15(
|
|
8493
8816
|
(e) => {
|
|
8494
8817
|
const newText = e.currentTarget.value;
|
|
8495
8818
|
setText(newText);
|
|
@@ -8499,7 +8822,7 @@ function AnchorDialog2({
|
|
|
8499
8822
|
},
|
|
8500
8823
|
[setText, setTitle, titleManuallyEdited]
|
|
8501
8824
|
);
|
|
8502
|
-
const onChangeTitle =
|
|
8825
|
+
const onChangeTitle = useCallback15(
|
|
8503
8826
|
(e) => {
|
|
8504
8827
|
setTitle(e.currentTarget.value);
|
|
8505
8828
|
setTitleManuallyEdited(true);
|
|
@@ -8513,47 +8836,51 @@ function AnchorDialog2({
|
|
|
8513
8836
|
e.stopPropagation();
|
|
8514
8837
|
insertLink2();
|
|
8515
8838
|
};
|
|
8516
|
-
return /* @__PURE__ */
|
|
8517
|
-
/* @__PURE__ */
|
|
8518
|
-
/* @__PURE__ */
|
|
8519
|
-
/* @__PURE__ */
|
|
8520
|
-
|
|
8521
|
-
{
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8527
|
-
|
|
8528
|
-
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
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(
|
|
8839
|
+
return /* @__PURE__ */ jsxs30(Fragment9, { children: [
|
|
8840
|
+
/* @__PURE__ */ jsx62(CloseMask, { close }),
|
|
8841
|
+
/* @__PURE__ */ jsxs30($AnchorDialog, { ref, style, children: [
|
|
8842
|
+
/* @__PURE__ */ jsx62(DraggableHeader, { onDrag: handleDrag }),
|
|
8843
|
+
/* @__PURE__ */ jsxs30("div", { style: { padding: "0.75em" }, children: [
|
|
8844
|
+
/* @__PURE__ */ jsx62($AnchorDialogInputLine, { children: /* @__PURE__ */ jsx62(
|
|
8845
|
+
$AnchorDialogInput,
|
|
8846
|
+
{
|
|
8847
|
+
type: "text",
|
|
8848
|
+
value: url,
|
|
8849
|
+
autoFocus: true,
|
|
8850
|
+
placeholder: t("linkUrl"),
|
|
8851
|
+
onChange: onChangeUrl,
|
|
8852
|
+
onKeyDown
|
|
8853
|
+
}
|
|
8854
|
+
) }),
|
|
8855
|
+
/* @__PURE__ */ jsx62($AnchorDialogInputLine, { style: { marginTop: "0.5em" }, children: /* @__PURE__ */ jsx62(
|
|
8542
8856
|
$AnchorDialogInput,
|
|
8543
8857
|
{
|
|
8544
8858
|
type: "text",
|
|
8545
|
-
value:
|
|
8546
|
-
placeholder: t("
|
|
8547
|
-
onChange:
|
|
8859
|
+
value: text,
|
|
8860
|
+
placeholder: t("linkText"),
|
|
8861
|
+
onChange: onChangeText,
|
|
8548
8862
|
onKeyDown
|
|
8549
8863
|
}
|
|
8550
|
-
),
|
|
8551
|
-
/* @__PURE__ */
|
|
8552
|
-
/* @__PURE__ */
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8556
|
-
|
|
8864
|
+
) }),
|
|
8865
|
+
/* @__PURE__ */ jsxs30($AnchorDialogInputLine, { style: { marginTop: "0.5em" }, children: [
|
|
8866
|
+
/* @__PURE__ */ jsx62(
|
|
8867
|
+
$AnchorDialogInput,
|
|
8868
|
+
{
|
|
8869
|
+
type: "text",
|
|
8870
|
+
value: title,
|
|
8871
|
+
placeholder: t("tooltipText"),
|
|
8872
|
+
onChange: onChangeTitle,
|
|
8873
|
+
onKeyDown
|
|
8874
|
+
}
|
|
8875
|
+
),
|
|
8876
|
+
/* @__PURE__ */ jsxs30($DialogButton, { onClick: insertLink2, children: [
|
|
8877
|
+
/* @__PURE__ */ jsx62(Link, {}),
|
|
8878
|
+
/* @__PURE__ */ jsx62(LinkPlus, {})
|
|
8879
|
+
] }),
|
|
8880
|
+
/* @__PURE__ */ jsx62($DialogButton, { onClick: close, style: { marginLeft: "0.25em", background: "var(--shade-400)" }, children: /* @__PURE__ */ jsx62(Close, {}) })
|
|
8881
|
+
] }),
|
|
8882
|
+
/* @__PURE__ */ jsx62($DialogHint, { children: t("tooltipHint") })
|
|
8883
|
+
] })
|
|
8557
8884
|
] })
|
|
8558
8885
|
] });
|
|
8559
8886
|
}
|
|
@@ -8643,9 +8970,10 @@ var primaryMarkItems = [
|
|
|
8643
8970
|
{
|
|
8644
8971
|
icon: Highlight,
|
|
8645
8972
|
title: t("highlight"),
|
|
8973
|
+
hotkey: "mod+h",
|
|
8646
8974
|
action: (editor) => editor.marksPlugin.toggleHighlight(),
|
|
8647
8975
|
active: (editor) => getMarks(editor).highlight,
|
|
8648
|
-
show: (editor) => !editor.wysimark
|
|
8976
|
+
show: (editor) => !editor.wysimark.disableHighlight
|
|
8649
8977
|
}
|
|
8650
8978
|
];
|
|
8651
8979
|
var expandedMarkItems = primaryMarkItems;
|
|
@@ -8664,22 +8992,20 @@ var listItems = [
|
|
|
8664
8992
|
icon: BulletList,
|
|
8665
8993
|
title: t("bulletList"),
|
|
8666
8994
|
hotkey: "super+8",
|
|
8667
|
-
action: (editor) => editor.list
|
|
8668
|
-
show: (editor) => !!editor.list
|
|
8995
|
+
action: (editor) => editor.list.convertUnorderedList(true)
|
|
8669
8996
|
},
|
|
8670
8997
|
{
|
|
8671
8998
|
icon: ListNumbers,
|
|
8672
8999
|
title: t("numberedList"),
|
|
8673
9000
|
hotkey: "super+7",
|
|
8674
|
-
action: (editor) => editor.list
|
|
8675
|
-
show: (editor) => !!editor.list
|
|
9001
|
+
action: (editor) => editor.list.convertOrderedList(true)
|
|
8676
9002
|
},
|
|
8677
9003
|
{
|
|
8678
9004
|
icon: ListCheck,
|
|
8679
9005
|
title: t("checkList"),
|
|
8680
9006
|
hotkey: "super+9",
|
|
8681
|
-
action: (editor) => editor.list
|
|
8682
|
-
show: (editor) =>
|
|
9007
|
+
action: (editor) => editor.list.convertTaskList(true),
|
|
9008
|
+
show: (editor) => !editor.wysimark.disableTaskList
|
|
8683
9009
|
}
|
|
8684
9010
|
];
|
|
8685
9011
|
var expandedListItems = [...listItems, "divider", ...listDepthItems];
|
|
@@ -8688,8 +9014,7 @@ var compactListItems = [
|
|
|
8688
9014
|
icon: ListNumbers,
|
|
8689
9015
|
title: t("list"),
|
|
8690
9016
|
more: true,
|
|
8691
|
-
children: [...listItems, "divider", ...listDepthItems]
|
|
8692
|
-
show: (editor) => !!editor.list
|
|
9017
|
+
children: [...listItems, "divider", ...listDepthItems]
|
|
8693
9018
|
}
|
|
8694
9019
|
];
|
|
8695
9020
|
|
|
@@ -8722,7 +9047,7 @@ var quoteItemsList = [
|
|
|
8722
9047
|
const { selection } = editor;
|
|
8723
9048
|
const codeBlockEntry = findElementUp(editor, "code-block");
|
|
8724
9049
|
if (codeBlockEntry) {
|
|
8725
|
-
const [
|
|
9050
|
+
const [, path] = codeBlockEntry;
|
|
8726
9051
|
const textContent = Editor61.string(editor, path);
|
|
8727
9052
|
Transforms43.removeNodes(editor, { at: path });
|
|
8728
9053
|
Transforms43.insertNodes(
|
|
@@ -8736,7 +9061,7 @@ var quoteItemsList = [
|
|
|
8736
9061
|
return;
|
|
8737
9062
|
}
|
|
8738
9063
|
if (selection && JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path)) {
|
|
8739
|
-
editor.codeBlock
|
|
9064
|
+
editor.codeBlock.createCodeBlock({ language: "text" });
|
|
8740
9065
|
return;
|
|
8741
9066
|
}
|
|
8742
9067
|
if (selection && (selection.anchor.offset !== selection.focus.offset || JSON.stringify(selection.anchor.path) !== JSON.stringify(selection.focus.path))) {
|
|
@@ -8757,10 +9082,10 @@ var quoteItemsList = [
|
|
|
8757
9082
|
);
|
|
8758
9083
|
return;
|
|
8759
9084
|
}
|
|
8760
|
-
editor.codeBlock
|
|
9085
|
+
editor.codeBlock.createCodeBlock({ language: "text" });
|
|
8761
9086
|
},
|
|
8762
9087
|
active: (editor) => !!findElementUp(editor, "code-block"),
|
|
8763
|
-
show: (editor) =>
|
|
9088
|
+
show: (editor) => !editor.wysimark.disableCodeBlock
|
|
8764
9089
|
}
|
|
8765
9090
|
];
|
|
8766
9091
|
var expandedQuoteItems = quoteItemsList;
|
|
@@ -8773,38 +9098,6 @@ var compactQuoteItems = [
|
|
|
8773
9098
|
}
|
|
8774
9099
|
];
|
|
8775
9100
|
|
|
8776
|
-
// src/toolbar-plugin/items/raw-mode-item.tsx
|
|
8777
|
-
var rawModeItem = {
|
|
8778
|
-
icon: Markdown,
|
|
8779
|
-
title: t("switchToRawMarkdown"),
|
|
8780
|
-
action: (editor) => {
|
|
8781
|
-
if (editor.wysimark && typeof editor.wysimark.toggleRawMode === "function") {
|
|
8782
|
-
editor.wysimark.toggleRawMode();
|
|
8783
|
-
}
|
|
8784
|
-
},
|
|
8785
|
-
// Only show in the toolbar when not in Raw mode and toggleRawMode is available
|
|
8786
|
-
show: (editor) => {
|
|
8787
|
-
return editor.wysimark && typeof editor.wysimark.toggleRawMode === "function" && !editor.wysimark.isRawMode;
|
|
8788
|
-
},
|
|
8789
|
-
active: () => false
|
|
8790
|
-
// Never show as active in the toolbar
|
|
8791
|
-
};
|
|
8792
|
-
var visualModeItem = {
|
|
8793
|
-
icon: VisualEditor,
|
|
8794
|
-
title: t("switchToVisualEditor"),
|
|
8795
|
-
action: (editor) => {
|
|
8796
|
-
if (editor.wysimark && typeof editor.wysimark.toggleRawMode === "function") {
|
|
8797
|
-
editor.wysimark.toggleRawMode();
|
|
8798
|
-
}
|
|
8799
|
-
},
|
|
8800
|
-
// Only show in the toolbar when in Raw mode
|
|
8801
|
-
show: (editor) => {
|
|
8802
|
-
return !!(editor.wysimark && editor.wysimark.isRawMode);
|
|
8803
|
-
},
|
|
8804
|
-
active: () => false
|
|
8805
|
-
// Never show as active in the toolbar
|
|
8806
|
-
};
|
|
8807
|
-
|
|
8808
9101
|
// src/toolbar-plugin/items/index.tsx
|
|
8809
9102
|
var largeItems = [
|
|
8810
9103
|
...expandedBlockItems,
|
|
@@ -8815,10 +9108,7 @@ var largeItems = [
|
|
|
8815
9108
|
"divider",
|
|
8816
9109
|
...expandedDialogItems,
|
|
8817
9110
|
"divider",
|
|
8818
|
-
...expandedQuoteItems
|
|
8819
|
-
"divider",
|
|
8820
|
-
rawModeItem,
|
|
8821
|
-
visualModeItem
|
|
9111
|
+
...expandedQuoteItems
|
|
8822
9112
|
];
|
|
8823
9113
|
var mediumItems = [
|
|
8824
9114
|
...compactBlockItems,
|
|
@@ -8829,10 +9119,7 @@ var mediumItems = [
|
|
|
8829
9119
|
"divider",
|
|
8830
9120
|
...compactDialogItems,
|
|
8831
9121
|
"divider",
|
|
8832
|
-
...expandedQuoteItems
|
|
8833
|
-
"divider",
|
|
8834
|
-
rawModeItem,
|
|
8835
|
-
visualModeItem
|
|
9122
|
+
...expandedQuoteItems
|
|
8836
9123
|
];
|
|
8837
9124
|
var smallItems = [
|
|
8838
9125
|
...compactBlockItems,
|
|
@@ -8843,44 +9130,41 @@ var smallItems = [
|
|
|
8843
9130
|
"divider",
|
|
8844
9131
|
...smallDialogItems,
|
|
8845
9132
|
"divider",
|
|
8846
|
-
...compactQuoteItems
|
|
8847
|
-
"divider",
|
|
8848
|
-
rawModeItem,
|
|
8849
|
-
visualModeItem
|
|
9133
|
+
...compactQuoteItems
|
|
8850
9134
|
];
|
|
8851
9135
|
var initialItems = smallItems;
|
|
8852
9136
|
var itemSets = [largeItems, mediumItems, smallItems];
|
|
8853
9137
|
|
|
8854
9138
|
// src/toolbar-plugin/components/toolbar/toolbar-button.tsx
|
|
8855
9139
|
import { clsx as clsx9 } from "clsx";
|
|
8856
|
-
import { useCallback as
|
|
8857
|
-
import { ReactEditor as ReactEditor15, useSlate as useSlate2, useSlateStatic as
|
|
8858
|
-
import { jsx as
|
|
9140
|
+
import { useCallback as useCallback16, useRef as useRef11 } from "react";
|
|
9141
|
+
import { ReactEditor as ReactEditor15, useSlate as useSlate2, useSlateStatic as useSlateStatic19 } from "slate-react";
|
|
9142
|
+
import { jsx as jsx63, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
8859
9143
|
function ToolbarButton({
|
|
8860
9144
|
item
|
|
8861
9145
|
}) {
|
|
8862
|
-
const staticEditor =
|
|
9146
|
+
const staticEditor = useSlateStatic19();
|
|
8863
9147
|
const editor = useSlate2();
|
|
8864
9148
|
const isActive = item.active ? item.active(editor) : false;
|
|
8865
|
-
const ref =
|
|
9149
|
+
const ref = useRef11(null);
|
|
8866
9150
|
const tooltip = useTooltip({
|
|
8867
9151
|
title: item.title,
|
|
8868
9152
|
hotkey: () => item.hotkey ? formatHotkey(item.hotkey) : void 0
|
|
8869
9153
|
});
|
|
8870
9154
|
const menuLayer = useLayer("menu");
|
|
8871
|
-
const openMenu =
|
|
9155
|
+
const openMenu = useCallback16(() => {
|
|
8872
9156
|
const dest = ref.current;
|
|
8873
9157
|
const items = item.children;
|
|
8874
9158
|
const Component = item.Component;
|
|
8875
9159
|
if (!dest)
|
|
8876
9160
|
return;
|
|
8877
9161
|
if (items) {
|
|
8878
|
-
menuLayer.open(() => /* @__PURE__ */
|
|
9162
|
+
menuLayer.open(() => /* @__PURE__ */ jsx63(Menu, { dest, items, close: menuLayer.close }));
|
|
8879
9163
|
} else if (Component) {
|
|
8880
|
-
menuLayer.open(() => /* @__PURE__ */
|
|
9164
|
+
menuLayer.open(() => /* @__PURE__ */ jsx63(Component, { dest, close: menuLayer.close }));
|
|
8881
9165
|
}
|
|
8882
9166
|
}, [item]);
|
|
8883
|
-
const onClick =
|
|
9167
|
+
const onClick = useCallback16(() => {
|
|
8884
9168
|
if (item.action) {
|
|
8885
9169
|
item.action(staticEditor);
|
|
8886
9170
|
ReactEditor15.focus(staticEditor);
|
|
@@ -8892,7 +9176,7 @@ function ToolbarButton({
|
|
|
8892
9176
|
openMenu();
|
|
8893
9177
|
}
|
|
8894
9178
|
}, [menuLayer.layer, item]);
|
|
8895
|
-
const onMouseEnter =
|
|
9179
|
+
const onMouseEnter = useCallback16(
|
|
8896
9180
|
(e) => {
|
|
8897
9181
|
tooltip.onMouseEnter(e);
|
|
8898
9182
|
if (menuLayer.layer)
|
|
@@ -8900,7 +9184,7 @@ function ToolbarButton({
|
|
|
8900
9184
|
},
|
|
8901
9185
|
[menuLayer.layer]
|
|
8902
9186
|
);
|
|
8903
|
-
return /* @__PURE__ */
|
|
9187
|
+
return /* @__PURE__ */ jsxs31(
|
|
8904
9188
|
$ToolbarButton,
|
|
8905
9189
|
{
|
|
8906
9190
|
"data-item-type": "button",
|
|
@@ -8914,24 +9198,24 @@ function ToolbarButton({
|
|
|
8914
9198
|
"--disabled": !isActive && r(item?.title)?.includes("Depth")
|
|
8915
9199
|
}),
|
|
8916
9200
|
children: [
|
|
8917
|
-
/* @__PURE__ */
|
|
8918
|
-
item.more ? /* @__PURE__ */
|
|
9201
|
+
/* @__PURE__ */ jsx63(item.icon, {}),
|
|
9202
|
+
item.more ? /* @__PURE__ */ jsx63(More, {}) : null
|
|
8919
9203
|
]
|
|
8920
9204
|
}
|
|
8921
9205
|
);
|
|
8922
9206
|
}
|
|
8923
9207
|
|
|
8924
9208
|
// src/toolbar-plugin/components/toolbar/toolbar.tsx
|
|
8925
|
-
import { jsx as
|
|
9209
|
+
import { jsx as jsx64 } from "react/jsx-runtime";
|
|
8926
9210
|
function ToolbarItem({ item }) {
|
|
8927
|
-
const editor =
|
|
9211
|
+
const editor = useSlateStatic20();
|
|
8928
9212
|
if (item === "divider") {
|
|
8929
|
-
return /* @__PURE__ */
|
|
9213
|
+
return /* @__PURE__ */ jsx64($ToolbarDividerContainer, { "data-item-type": "divider", children: /* @__PURE__ */ jsx64($ToolbarDivider, {}) });
|
|
8930
9214
|
}
|
|
8931
9215
|
const show = item.show === void 0 ? true : item.show(editor);
|
|
8932
9216
|
if (!show)
|
|
8933
9217
|
return null;
|
|
8934
|
-
return /* @__PURE__ */
|
|
9218
|
+
return /* @__PURE__ */ jsx64(ToolbarButton, { item });
|
|
8935
9219
|
}
|
|
8936
9220
|
function getWidths(toolbar) {
|
|
8937
9221
|
const button = toolbar.querySelector(
|
|
@@ -8957,7 +9241,7 @@ function measureItemSetWidth(items, buttonWidth, dividerWidth) {
|
|
|
8957
9241
|
}
|
|
8958
9242
|
var WIDTH_BUFFER_PX = 48;
|
|
8959
9243
|
function Toolbar() {
|
|
8960
|
-
const ref =
|
|
9244
|
+
const ref = useRef12(null);
|
|
8961
9245
|
const [items, setItems] = useState11(initialItems);
|
|
8962
9246
|
useEffect8(() => {
|
|
8963
9247
|
const refresh = throttle2(
|
|
@@ -8989,7 +9273,7 @@ function Toolbar() {
|
|
|
8989
9273
|
window.removeEventListener("resize", refresh);
|
|
8990
9274
|
};
|
|
8991
9275
|
}, []);
|
|
8992
|
-
return /* @__PURE__ */
|
|
9276
|
+
return /* @__PURE__ */ jsx64($ToolbarContainer, { ref, children: /* @__PURE__ */ jsx64($Toolbar, { children: items.map((item, index) => /* @__PURE__ */ jsx64(
|
|
8993
9277
|
ToolbarItem,
|
|
8994
9278
|
{
|
|
8995
9279
|
item
|
|
@@ -8999,12 +9283,12 @@ function Toolbar() {
|
|
|
8999
9283
|
}
|
|
9000
9284
|
|
|
9001
9285
|
// src/toolbar-plugin/render-editable/index.tsx
|
|
9002
|
-
import { jsx as
|
|
9286
|
+
import { jsx as jsx65, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
9003
9287
|
function renderEditable({ attributes, Editable: Editable3 }) {
|
|
9004
|
-
const outerContainerRef =
|
|
9005
|
-
const editor =
|
|
9288
|
+
const outerContainerRef = useRef13(null);
|
|
9289
|
+
const editor = useSlateStatic21();
|
|
9006
9290
|
const focused = useFocused();
|
|
9007
|
-
const onClickOuterContainer =
|
|
9291
|
+
const onClickOuterContainer = useCallback17(
|
|
9008
9292
|
(e) => {
|
|
9009
9293
|
if (e.target !== e.currentTarget)
|
|
9010
9294
|
return;
|
|
@@ -9013,7 +9297,7 @@ function renderEditable({ attributes, Editable: Editable3 }) {
|
|
|
9013
9297
|
},
|
|
9014
9298
|
[editor]
|
|
9015
9299
|
);
|
|
9016
|
-
return /* @__PURE__ */
|
|
9300
|
+
return /* @__PURE__ */ jsx65(Layers, { children: /* @__PURE__ */ jsxs32(
|
|
9017
9301
|
$OuterContainer,
|
|
9018
9302
|
{
|
|
9019
9303
|
ref: outerContainerRef,
|
|
@@ -9025,8 +9309,8 @@ function renderEditable({ attributes, Editable: Editable3 }) {
|
|
|
9025
9309
|
},
|
|
9026
9310
|
onClick: onClickOuterContainer,
|
|
9027
9311
|
children: [
|
|
9028
|
-
/* @__PURE__ */
|
|
9029
|
-
/* @__PURE__ */
|
|
9312
|
+
/* @__PURE__ */ jsx65(Toolbar, {}),
|
|
9313
|
+
/* @__PURE__ */ jsx65(
|
|
9030
9314
|
Editable3,
|
|
9031
9315
|
{
|
|
9032
9316
|
as: $Editable,
|
|
@@ -9126,7 +9410,7 @@ var PasteMarkdownPlugin = createPlugin(
|
|
|
9126
9410
|
);
|
|
9127
9411
|
|
|
9128
9412
|
// src/placeholder-plugin/index.tsx
|
|
9129
|
-
import { jsx as
|
|
9413
|
+
import { jsx as jsx66 } from "react/jsx-runtime";
|
|
9130
9414
|
function renderPlaceholder(props) {
|
|
9131
9415
|
const nextAttributes = {
|
|
9132
9416
|
...props.attributes,
|
|
@@ -9136,7 +9420,7 @@ function renderPlaceholder(props) {
|
|
|
9136
9420
|
maxWidth: void 0
|
|
9137
9421
|
}
|
|
9138
9422
|
};
|
|
9139
|
-
return /* @__PURE__ */
|
|
9423
|
+
return /* @__PURE__ */ jsx66("span", { ...nextAttributes, children: props.children });
|
|
9140
9424
|
}
|
|
9141
9425
|
var PlaceholderPlugin = createPlugin(
|
|
9142
9426
|
(editor, _options, { createPolicy }) => {
|
|
@@ -9151,7 +9435,7 @@ var PlaceholderPlugin = createPlugin(
|
|
|
9151
9435
|
);
|
|
9152
9436
|
|
|
9153
9437
|
// src/entry/plugins.ts
|
|
9154
|
-
var
|
|
9438
|
+
var plugins = [
|
|
9155
9439
|
PasteMarkdownPlugin,
|
|
9156
9440
|
ConvertElementPlugin,
|
|
9157
9441
|
AnchorPlugin,
|
|
@@ -9160,6 +9444,7 @@ var defaultPlugins = [
|
|
|
9160
9444
|
InlineCodePlugin,
|
|
9161
9445
|
BlockQuotePlugin,
|
|
9162
9446
|
CodeBlockPlugin,
|
|
9447
|
+
HtmlBlockPlugin,
|
|
9163
9448
|
TablePlugin,
|
|
9164
9449
|
HorizontalRulePlugin,
|
|
9165
9450
|
TrailingBlockPlugin,
|
|
@@ -9174,7 +9459,8 @@ var defaultPlugins = [
|
|
|
9174
9459
|
];
|
|
9175
9460
|
|
|
9176
9461
|
// src/entry/SinkEditable.tsx
|
|
9177
|
-
var
|
|
9462
|
+
var Sink = createSink(plugins);
|
|
9463
|
+
var { withSink, SinkEditable: SinkEditable2 } = Sink;
|
|
9178
9464
|
|
|
9179
9465
|
// src/entry/useEditor.tsx
|
|
9180
9466
|
import { useState as useState12 } from "react";
|
|
@@ -9232,9 +9518,9 @@ function useEditor({
|
|
|
9232
9518
|
}
|
|
9233
9519
|
|
|
9234
9520
|
// src/entry/index.tsx
|
|
9235
|
-
import { jsx as
|
|
9521
|
+
import { jsx as jsx67, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
9236
9522
|
function renderLeaf({ children, attributes }) {
|
|
9237
|
-
return /* @__PURE__ */
|
|
9523
|
+
return /* @__PURE__ */ jsx67("span", { ...attributes, children });
|
|
9238
9524
|
}
|
|
9239
9525
|
function Editable2({
|
|
9240
9526
|
editor,
|
|
@@ -9248,11 +9534,11 @@ function Editable2({
|
|
|
9248
9534
|
}) {
|
|
9249
9535
|
const [isRawMode, setIsRawMode] = useState13(false);
|
|
9250
9536
|
const [rawText, setRawText] = useState13(value);
|
|
9251
|
-
const ignoreNextChangeRef =
|
|
9252
|
-
const initialValueRef =
|
|
9253
|
-
const prevValueRef =
|
|
9254
|
-
const
|
|
9255
|
-
const onThrottledSlateChange =
|
|
9537
|
+
const ignoreNextChangeRef = useRef14(false);
|
|
9538
|
+
const initialValueRef = useRef14(void 0);
|
|
9539
|
+
const prevValueRef = useRef14(void 0);
|
|
9540
|
+
const pendingRawTextRef = useRef14(null);
|
|
9541
|
+
const onThrottledSlateChange = useCallback18(
|
|
9256
9542
|
throttle3(
|
|
9257
9543
|
() => {
|
|
9258
9544
|
const markdown = serialize(editor.children);
|
|
@@ -9260,7 +9546,6 @@ function Editable2({
|
|
|
9260
9546
|
markdown,
|
|
9261
9547
|
children: editor.children
|
|
9262
9548
|
};
|
|
9263
|
-
lastEmittedValueRef.current = markdown;
|
|
9264
9549
|
onChange(markdown);
|
|
9265
9550
|
},
|
|
9266
9551
|
throttleInMs,
|
|
@@ -9268,40 +9553,32 @@ function Editable2({
|
|
|
9268
9553
|
),
|
|
9269
9554
|
[editor, onChange, throttleInMs]
|
|
9270
9555
|
);
|
|
9271
|
-
const onSlateChange =
|
|
9272
|
-
(
|
|
9273
|
-
|
|
9274
|
-
|
|
9275
|
-
|
|
9276
|
-
|
|
9277
|
-
|
|
9278
|
-
|
|
9279
|
-
|
|
9280
|
-
|
|
9281
|
-
|
|
9282
|
-
|
|
9283
|
-
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9288
|
-
|
|
9289
|
-
|
|
9290
|
-
|
|
9291
|
-
|
|
9292
|
-
|
|
9293
|
-
};
|
|
9294
|
-
lastEmittedValueRef.current = value;
|
|
9295
|
-
} else {
|
|
9296
|
-
if (isRawMode) {
|
|
9297
|
-
editor.wysimark.prevValue.markdown = value;
|
|
9298
|
-
lastEmittedValueRef.current = value;
|
|
9556
|
+
const onSlateChange = useCallback18(() => {
|
|
9557
|
+
if (prevValueRef.current === editor.children) {
|
|
9558
|
+
return;
|
|
9559
|
+
}
|
|
9560
|
+
prevValueRef.current = editor.children;
|
|
9561
|
+
onThrottledSlateChange();
|
|
9562
|
+
}, [onThrottledSlateChange]);
|
|
9563
|
+
if (!isRawMode) {
|
|
9564
|
+
const markdownToUse = pendingRawTextRef.current ?? value;
|
|
9565
|
+
if (pendingRawTextRef.current !== null) {
|
|
9566
|
+
pendingRawTextRef.current = null;
|
|
9567
|
+
}
|
|
9568
|
+
if (editor.wysimark.prevValue == null || initialValueRef.current == null) {
|
|
9569
|
+
ignoreNextChangeRef.current = true;
|
|
9570
|
+
const valueToProcess = escapeUrlSlashes(markdownToUse);
|
|
9571
|
+
const children = parse(valueToProcess);
|
|
9572
|
+
editor.children = children;
|
|
9573
|
+
prevValueRef.current = initialValueRef.current = children;
|
|
9574
|
+
editor.wysimark.prevValue = {
|
|
9575
|
+
markdown: markdownToUse,
|
|
9576
|
+
children
|
|
9577
|
+
};
|
|
9299
9578
|
} else {
|
|
9300
|
-
|
|
9301
|
-
const diffFromLastEmitted = value !== lastEmittedValueRef.current;
|
|
9302
|
-
if (diffFromPrevValue && diffFromLastEmitted) {
|
|
9579
|
+
if (markdownToUse !== editor.wysimark.prevValue.markdown) {
|
|
9303
9580
|
ignoreNextChangeRef.current = true;
|
|
9304
|
-
const valueToProcess = escapeUrlSlashes(
|
|
9581
|
+
const valueToProcess = escapeUrlSlashes(markdownToUse);
|
|
9305
9582
|
const documentValue = parse(valueToProcess);
|
|
9306
9583
|
editor.children = documentValue;
|
|
9307
9584
|
editor.selection = null;
|
|
@@ -9309,12 +9586,12 @@ function Editable2({
|
|
|
9309
9586
|
}
|
|
9310
9587
|
}
|
|
9311
9588
|
}
|
|
9312
|
-
const onSinkeEditableMouseDown =
|
|
9589
|
+
const onSinkeEditableMouseDown = useCallback18(() => {
|
|
9313
9590
|
if (navigator.userAgent.toLowerCase().includes("firefox")) {
|
|
9314
9591
|
ReactEditor18.focus(editor);
|
|
9315
9592
|
}
|
|
9316
9593
|
}, [editor]);
|
|
9317
|
-
const onBlur =
|
|
9594
|
+
const onBlur = useCallback18(() => {
|
|
9318
9595
|
onThrottledSlateChange.flush();
|
|
9319
9596
|
}, [onThrottledSlateChange]);
|
|
9320
9597
|
const handleRawTextChange = (e) => {
|
|
@@ -9322,46 +9599,43 @@ function Editable2({
|
|
|
9322
9599
|
setRawText(newText);
|
|
9323
9600
|
onChange(newText);
|
|
9324
9601
|
};
|
|
9325
|
-
const
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9330
|
-
const updateRawTextFromEditor = useCallback16(() => {
|
|
9331
|
-
setRawText(value);
|
|
9332
|
-
}, [value]);
|
|
9333
|
-
const handleRawModeToggle = useCallback16(() => {
|
|
9602
|
+
const updateRawTextFromEditor = useCallback18(() => {
|
|
9603
|
+
const currentMarkdown = editor.getMarkdown();
|
|
9604
|
+
setRawText(currentMarkdown);
|
|
9605
|
+
}, [editor]);
|
|
9606
|
+
const handleRawModeToggle = () => {
|
|
9334
9607
|
if (isRawMode) {
|
|
9335
|
-
|
|
9608
|
+
pendingRawTextRef.current = rawText;
|
|
9609
|
+
editor.wysimark.prevValue = void 0;
|
|
9610
|
+
initialValueRef.current = void 0;
|
|
9611
|
+
prevValueRef.current = void 0;
|
|
9336
9612
|
} else {
|
|
9337
9613
|
updateRawTextFromEditor();
|
|
9338
9614
|
}
|
|
9339
9615
|
setIsRawMode(!isRawMode);
|
|
9340
|
-
}
|
|
9341
|
-
editor.wysimark.isRawMode = isRawMode;
|
|
9342
|
-
if (!editor.wysimark.disableRawMode) {
|
|
9343
|
-
editor.wysimark.toggleRawMode = handleRawModeToggle;
|
|
9344
|
-
}
|
|
9616
|
+
};
|
|
9345
9617
|
editor.wysimark.onImageChange = onImageChange;
|
|
9346
|
-
|
|
9347
|
-
|
|
9618
|
+
editor.wysimark.onChange = onChange;
|
|
9619
|
+
const disableRawMode = editor.wysimark.disableRawMode;
|
|
9620
|
+
return /* @__PURE__ */ jsxs33("div", { style: { position: "relative" }, children: [
|
|
9621
|
+
!disableRawMode && /* @__PURE__ */ jsx67("div", { style: { position: "absolute", top: "5px", right: "25px", zIndex: 10 }, children: /* @__PURE__ */ jsx67(
|
|
9348
9622
|
"div",
|
|
9349
9623
|
{
|
|
9350
9624
|
onClick: handleRawModeToggle,
|
|
9351
9625
|
style: {
|
|
9352
9626
|
background: "none",
|
|
9353
|
-
border: "1px solid #4a90e2",
|
|
9627
|
+
border: isRawMode ? "1px solid #4a90e2" : "1px solid transparent",
|
|
9354
9628
|
cursor: "pointer",
|
|
9355
9629
|
padding: "6px",
|
|
9356
9630
|
borderRadius: "4px",
|
|
9357
|
-
backgroundColor: "rgba(74, 144, 226, 0.1)",
|
|
9358
|
-
boxShadow: "0 1px 3px rgba(0, 0, 0, 0.1)",
|
|
9631
|
+
backgroundColor: isRawMode ? "rgba(74, 144, 226, 0.1)" : "transparent",
|
|
9632
|
+
boxShadow: isRawMode ? "0 1px 3px rgba(0, 0, 0, 0.1)" : "none",
|
|
9359
9633
|
transition: "all 0.2s ease-in-out",
|
|
9360
9634
|
display: "flex",
|
|
9361
9635
|
alignItems: "center",
|
|
9362
9636
|
justifyContent: "center"
|
|
9363
9637
|
},
|
|
9364
|
-
title: t("switchToVisualEditor"),
|
|
9638
|
+
title: isRawMode ? t("switchToVisualEditor") : t("switchToRawMarkdown"),
|
|
9365
9639
|
role: "button",
|
|
9366
9640
|
tabIndex: 0,
|
|
9367
9641
|
onKeyDown: (e) => {
|
|
@@ -9370,10 +9644,54 @@ function Editable2({
|
|
|
9370
9644
|
e.preventDefault();
|
|
9371
9645
|
}
|
|
9372
9646
|
},
|
|
9373
|
-
children: /* @__PURE__ */
|
|
9647
|
+
children: /* @__PURE__ */ jsxs33("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
9648
|
+
/* @__PURE__ */ jsx67(
|
|
9649
|
+
"rect",
|
|
9650
|
+
{
|
|
9651
|
+
x: "3",
|
|
9652
|
+
y: "3",
|
|
9653
|
+
width: "18",
|
|
9654
|
+
height: "18",
|
|
9655
|
+
rx: "2",
|
|
9656
|
+
stroke: isRawMode ? "#4a90e2" : "currentColor",
|
|
9657
|
+
strokeWidth: "1.5",
|
|
9658
|
+
fill: isRawMode ? "rgba(74, 144, 226, 0.05)" : "transparent"
|
|
9659
|
+
}
|
|
9660
|
+
),
|
|
9661
|
+
/* @__PURE__ */ jsx67(
|
|
9662
|
+
"path",
|
|
9663
|
+
{
|
|
9664
|
+
d: "M7 15V9L10 12L13 9V15",
|
|
9665
|
+
stroke: isRawMode ? "#4a90e2" : "currentColor",
|
|
9666
|
+
strokeWidth: "1.5",
|
|
9667
|
+
strokeLinecap: "round",
|
|
9668
|
+
strokeLinejoin: "round"
|
|
9669
|
+
}
|
|
9670
|
+
),
|
|
9671
|
+
/* @__PURE__ */ jsx67(
|
|
9672
|
+
"path",
|
|
9673
|
+
{
|
|
9674
|
+
d: "M16 9H18V15",
|
|
9675
|
+
stroke: isRawMode ? "#4a90e2" : "currentColor",
|
|
9676
|
+
strokeWidth: "1.5",
|
|
9677
|
+
strokeLinecap: "round",
|
|
9678
|
+
strokeLinejoin: "round"
|
|
9679
|
+
}
|
|
9680
|
+
),
|
|
9681
|
+
/* @__PURE__ */ jsx67(
|
|
9682
|
+
"path",
|
|
9683
|
+
{
|
|
9684
|
+
d: "M16 12H18",
|
|
9685
|
+
stroke: isRawMode ? "#4a90e2" : "currentColor",
|
|
9686
|
+
strokeWidth: "1.5",
|
|
9687
|
+
strokeLinecap: "round",
|
|
9688
|
+
strokeLinejoin: "round"
|
|
9689
|
+
}
|
|
9690
|
+
)
|
|
9691
|
+
] })
|
|
9374
9692
|
}
|
|
9375
9693
|
) }),
|
|
9376
|
-
/* @__PURE__ */
|
|
9694
|
+
/* @__PURE__ */ jsx67("div", { style: { display: isRawMode ? "block" : "none", textAlign: "center" }, children: /* @__PURE__ */ jsx67(
|
|
9377
9695
|
"textarea",
|
|
9378
9696
|
{
|
|
9379
9697
|
value: unescapeUrlSlashes(rawText).replace(/ /g, ""),
|
|
@@ -9382,9 +9700,7 @@ function Editable2({
|
|
|
9382
9700
|
className,
|
|
9383
9701
|
style: {
|
|
9384
9702
|
width: "calc(100% - 60px)",
|
|
9385
|
-
/* Full width minus 200px on each side */
|
|
9386
9703
|
margin: "0 auto",
|
|
9387
|
-
/* Center the textarea */
|
|
9388
9704
|
minHeight: "200px",
|
|
9389
9705
|
padding: "20px",
|
|
9390
9706
|
fontFamily: "monospace",
|
|
@@ -9398,13 +9714,13 @@ function Editable2({
|
|
|
9398
9714
|
}
|
|
9399
9715
|
}
|
|
9400
9716
|
) }),
|
|
9401
|
-
/* @__PURE__ */
|
|
9717
|
+
/* @__PURE__ */ jsx67("div", { style: { display: isRawMode ? "none" : "block" }, children: /* @__PURE__ */ jsx67(
|
|
9402
9718
|
Slate2,
|
|
9403
9719
|
{
|
|
9404
9720
|
editor,
|
|
9405
|
-
initialValue: initialValueRef.current
|
|
9721
|
+
initialValue: initialValueRef.current,
|
|
9406
9722
|
onChange: onSlateChange,
|
|
9407
|
-
children: /* @__PURE__ */
|
|
9723
|
+
children: /* @__PURE__ */ jsx67(
|
|
9408
9724
|
SinkEditable2,
|
|
9409
9725
|
{
|
|
9410
9726
|
renderLeaf,
|
|
@@ -9421,13 +9737,13 @@ function Editable2({
|
|
|
9421
9737
|
}
|
|
9422
9738
|
|
|
9423
9739
|
// src/index.tsx
|
|
9424
|
-
import { jsx as
|
|
9740
|
+
import { jsx as jsx68 } from "react/jsx-runtime";
|
|
9425
9741
|
function StandaloneEditor({
|
|
9426
9742
|
standaloneOptions: { onChange, placeholder, className, ...options },
|
|
9427
9743
|
standaloneMethodsRef
|
|
9428
9744
|
}) {
|
|
9429
9745
|
const [markdown, setMarkdown] = useState14(options.initialMarkdown || "");
|
|
9430
|
-
const markdownRef =
|
|
9746
|
+
const markdownRef = useRef15(markdown);
|
|
9431
9747
|
const editor = useEditor(options);
|
|
9432
9748
|
markdownRef.current = markdown;
|
|
9433
9749
|
useImperativeHandle(
|
|
@@ -9445,7 +9761,7 @@ function StandaloneEditor({
|
|
|
9445
9761
|
},
|
|
9446
9762
|
[markdownRef, setMarkdown]
|
|
9447
9763
|
);
|
|
9448
|
-
const onChangeEditable =
|
|
9764
|
+
const onChangeEditable = useCallback19(
|
|
9449
9765
|
(markdown2) => {
|
|
9450
9766
|
markdownRef.current = markdown2;
|
|
9451
9767
|
setMarkdown(markdown2);
|
|
@@ -9453,7 +9769,7 @@ function StandaloneEditor({
|
|
|
9453
9769
|
},
|
|
9454
9770
|
[editor]
|
|
9455
9771
|
);
|
|
9456
|
-
return /* @__PURE__ */
|
|
9772
|
+
return /* @__PURE__ */ jsx68(
|
|
9457
9773
|
Editable2,
|
|
9458
9774
|
{
|
|
9459
9775
|
editor,
|
|
@@ -9468,7 +9784,7 @@ function createWysimark(containerElement, options) {
|
|
|
9468
9784
|
const standaloneMethodsRef = createRef();
|
|
9469
9785
|
const root = createRoot(containerElement);
|
|
9470
9786
|
root.render(
|
|
9471
|
-
/* @__PURE__ */
|
|
9787
|
+
/* @__PURE__ */ jsx68(
|
|
9472
9788
|
StandaloneEditor,
|
|
9473
9789
|
{
|
|
9474
9790
|
standaloneMethodsRef,
|
|
@@ -9480,7 +9796,7 @@ function createWysimark(containerElement, options) {
|
|
|
9480
9796
|
unmount() {
|
|
9481
9797
|
try {
|
|
9482
9798
|
root.unmount();
|
|
9483
|
-
} catch
|
|
9799
|
+
} catch {
|
|
9484
9800
|
}
|
|
9485
9801
|
},
|
|
9486
9802
|
getMarkdown() {
|