@haklex/rich-editor 0.69.1 → 0.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{ColorSchemeContext-DLWz8vFw.js → ColorSchemeContext-g-0-suc1.js} +90 -13
- package/dist/{LinkCardRenderer-D4mQbUQo.js → LinkCardRenderer-D8n5tdHI.js} +19 -9
- package/dist/{RendererConfigProvider-BPYO0Ip0.js → RendererConfigProvider-Bt5fxwhg.js} +3 -3
- package/dist/{VirtualizationPlugin-CkNi6FW2.js → VirtualizationPlugin-BAImcSjr.js} +1 -1
- package/dist/{VirtualizationPlugin-DbAHlGBL.js → VirtualizationPlugin-CfABS8dF.js} +30 -24
- package/dist/{VirtualizedEditor-D099IYqN.js → VirtualizedEditor-MQBNGDZc.js} +19 -18
- package/dist/components/renderers/FootnoteRenderer.d.ts.map +1 -1
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts +6 -0
- package/dist/components/renderers/FootnoteStaticRenderer.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +62 -8
- package/dist/{node-registry-PtbiwsVu.js → node-registry-CX3ZzEuQ.js} +8 -4
- package/dist/nodes/AlertQuoteNode.d.ts +0 -1
- package/dist/nodes/AlertQuoteNode.d.ts.map +1 -1
- package/dist/nodes/BannerNode.d.ts +0 -1
- package/dist/nodes/BannerNode.d.ts.map +1 -1
- package/dist/nodes/CodeBlockNode.d.ts.map +1 -1
- package/dist/nodes/CommentNode.d.ts.map +1 -1
- package/dist/nodes/DetailsNode.d.ts.map +1 -1
- package/dist/nodes/FileNode.d.ts.map +1 -1
- package/dist/nodes/FootnoteNode.d.ts +1 -2
- package/dist/nodes/FootnoteNode.d.ts.map +1 -1
- package/dist/nodes/ImageNode.d.ts.map +1 -1
- package/dist/nodes/KaTeXBlockNode.d.ts.map +1 -1
- package/dist/nodes/LinkCardNode.d.ts.map +1 -1
- package/dist/nodes/MermaidNode.d.ts.map +1 -1
- package/dist/nodes/TagNode.d.ts.map +1 -1
- package/dist/nodes/VideoNode.d.ts.map +1 -1
- package/dist/nodes/shared.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +2 -2
- package/dist/{normalizeSerializedEditorState-CNUAQd3l.js → normalizeSerializedEditorState-C_JlVtWQ.js} +11 -5
- package/dist/plugins/BlockIdPlugin.d.ts.map +1 -1
- package/dist/plugins/OnChangePlugin.d.ts +1 -1
- package/dist/plugins/OnChangePlugin.d.ts.map +1 -1
- package/dist/plugins-entry.mjs +4 -4
- package/dist/recycler-entry.d.ts +1 -1
- package/dist/recycler-entry.d.ts.map +1 -1
- package/dist/recycler-entry.mjs +2 -2
- package/dist/renderers-entry.mjs +4 -27
- package/dist/static-entry.mjs +4 -4
- package/dist/utils/block-dom.d.ts +5 -0
- package/dist/utils/block-dom.d.ts.map +1 -0
- package/dist/utils/command-icons.d.ts +12 -0
- package/dist/utils/command-icons.d.ts.map +1 -0
- package/dist/utils/image-insertion.d.ts +0 -2
- package/dist/utils/image-insertion.d.ts.map +1 -1
- package/dist/utils/normalizeSerializedEditorState.d.ts.map +1 -1
- package/dist/{viewport-CFJHn_Y6.js → viewport-BllJyZ07.js} +31 -1
- package/dist/virtualization/controller.d.ts +0 -1
- package/dist/virtualization/controller.d.ts.map +1 -1
- package/dist/virtualization/viewport.d.ts +13 -0
- package/dist/virtualization/viewport.d.ts.map +1 -1
- package/dist/virtualization-entry.mjs +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ For read-only rendering, use `@haklex/rich-compose` (exports `RichRenderer` and
|
|
|
42
42
|
|
|
43
43
|
## Experimental editor recycler
|
|
44
44
|
|
|
45
|
-
Virtualization is **off by default**. The optional plugin keeps the full document in the main editor and projects visible blocks into editable Lexical instances. The recycler implementation loads on demand. Native selection currently spans one editing instance; collaboration and custom plugins still need compatibility work.
|
|
45
|
+
Virtualization is **off by default**. The optional plugin keeps the full document in the main editor and projects visible blocks into editable Lexical instances. The recycler implementation loads on demand. Native selection currently spans one editing instance; collaboration and custom plugins still need compatibility work.
|
|
46
46
|
|
|
47
47
|
```tsx
|
|
48
48
|
const scrollRef = useRef<HTMLDivElement>(null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as MERMAID_NODE_KEY, C as FILE_NODE_KEY, D as KATEX_NODE_KEY, E as IMAGE_NODE_KEY, N as VIDEO_NODE_KEY, O as LINK_CARD_NODE_KEY, S as CODE_BLOCK_NODE_KEY, T as FOOTNOTE_SECTION_NODE_KEY, b as ALERT_NODE_KEY, c as useFootnoteDefinitions, h as RendererWrapper, i as FootnoteStaticRenderer, k as MENTION_NODE_KEY, m as createRendererDecoration, r as decodeThumbHash, t as LinkCardRenderer, u as FileRenderer, w as FOOTNOTE_NODE_KEY, x as BANNER_NODE_KEY } from "./LinkCardRenderer-D8n5tdHI.js";
|
|
2
2
|
import { n as semanticClassNames, r as sharedStyles } from "./shared.css-DRoqE_U-.js";
|
|
3
3
|
import { a as OPEN_FILE_PICKER_COMMAND, i as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, o as extractTextContent, r as SpoilerNode } from "./SpoilerNode-D7Tgdo2K.js";
|
|
4
4
|
import { t as _defineProperty } from "./defineProperty-BYhxpJwd.js";
|
|
@@ -13,7 +13,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { CodeNode } from "@lexical/code-core";
|
|
14
14
|
import { ListItemNode, ListNode } from "@lexical/list";
|
|
15
15
|
import { $getTableCellNodeFromLexicalNode, TableCellNode, TableNode, TableRowNode } from "@lexical/table";
|
|
16
|
-
import {
|
|
16
|
+
import { Info, Lightbulb, MessageSquareWarning, OctagonAlert, TriangleAlert } from "lucide-react";
|
|
17
17
|
//#region src/plugins/inline-dnd-shared.ts
|
|
18
18
|
var INLINE_DRAG_ATTR = "data-inline-drag";
|
|
19
19
|
var INLINE_DRAG_MIME = "application/x-haklex-inline-node";
|
|
@@ -314,6 +314,82 @@ function $isBannerNode(node) {
|
|
|
314
314
|
return node instanceof BannerNode;
|
|
315
315
|
}
|
|
316
316
|
//#endregion
|
|
317
|
+
//#region src/utils/command-icons.ts
|
|
318
|
+
function commandIcon(name, node) {
|
|
319
|
+
return createElement("svg", {
|
|
320
|
+
"aria-hidden": true,
|
|
321
|
+
"className": `lucide lucide-${name}`,
|
|
322
|
+
"fill": "none",
|
|
323
|
+
"height": 20,
|
|
324
|
+
"stroke": "currentColor",
|
|
325
|
+
"strokeLinecap": "round",
|
|
326
|
+
"strokeLinejoin": "round",
|
|
327
|
+
"strokeWidth": 2,
|
|
328
|
+
"viewBox": "0 0 24 24",
|
|
329
|
+
"width": 20,
|
|
330
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
331
|
+
}, ...node.map(([tag, attrs], index) => createElement(tag, {
|
|
332
|
+
...attrs,
|
|
333
|
+
key: index
|
|
334
|
+
})));
|
|
335
|
+
}
|
|
336
|
+
var paperclipCommandIcon = commandIcon("paperclip", [["path", { d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551" }]]);
|
|
337
|
+
var chevronRightCommandIcon = commandIcon("chevron-right", [["path", { d: "m9 18 6-6-6-6" }]]);
|
|
338
|
+
var videoCommandIcon = commandIcon("video", [["path", { d: "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" }], ["rect", {
|
|
339
|
+
x: "2",
|
|
340
|
+
y: "6",
|
|
341
|
+
width: "14",
|
|
342
|
+
height: "12",
|
|
343
|
+
rx: "2"
|
|
344
|
+
}]]);
|
|
345
|
+
var messageSquareQuoteCommandIcon = commandIcon("message-square-quote", [
|
|
346
|
+
["path", { d: "M14 14a2 2 0 0 0 2-2V8h-2" }],
|
|
347
|
+
["path", { d: "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" }],
|
|
348
|
+
["path", { d: "M8 14a2 2 0 0 0 2-2V8H8" }]
|
|
349
|
+
]);
|
|
350
|
+
var imageCommandIcon = commandIcon("image", [
|
|
351
|
+
["rect", {
|
|
352
|
+
width: "18",
|
|
353
|
+
height: "18",
|
|
354
|
+
x: "3",
|
|
355
|
+
y: "3",
|
|
356
|
+
rx: "2",
|
|
357
|
+
ry: "2"
|
|
358
|
+
}],
|
|
359
|
+
["circle", {
|
|
360
|
+
cx: "9",
|
|
361
|
+
cy: "9",
|
|
362
|
+
r: "2"
|
|
363
|
+
}],
|
|
364
|
+
["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" }]
|
|
365
|
+
]);
|
|
366
|
+
var sigmaCommandIcon = commandIcon("sigma", [["path", { d: "M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" }]]);
|
|
367
|
+
var codeCommandIcon = commandIcon("code", [["path", { d: "m16 18 6-6-6-6" }], ["path", { d: "m8 6-6 6 6 6" }]]);
|
|
368
|
+
var linkCommandIcon = commandIcon("link", [["path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }], ["path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" }]]);
|
|
369
|
+
var tagCommandIcon = commandIcon("tag", [["path", { d: "M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z" }], ["circle", {
|
|
370
|
+
cx: "7.5",
|
|
371
|
+
cy: "7.5",
|
|
372
|
+
r: ".5",
|
|
373
|
+
fill: "currentColor"
|
|
374
|
+
}]]);
|
|
375
|
+
var workflowCommandIcon = commandIcon("workflow", [
|
|
376
|
+
["rect", {
|
|
377
|
+
width: "8",
|
|
378
|
+
height: "8",
|
|
379
|
+
x: "3",
|
|
380
|
+
y: "3",
|
|
381
|
+
rx: "2"
|
|
382
|
+
}],
|
|
383
|
+
["path", { d: "M7 11v4a2 2 0 0 0 2 2h4" }],
|
|
384
|
+
["rect", {
|
|
385
|
+
width: "8",
|
|
386
|
+
height: "8",
|
|
387
|
+
x: "13",
|
|
388
|
+
y: "13",
|
|
389
|
+
rx: "2"
|
|
390
|
+
}]
|
|
391
|
+
]);
|
|
392
|
+
//#endregion
|
|
317
393
|
//#region src/nodes/CodeBlockNode.ts
|
|
318
394
|
var CodeBlockNode = class CodeBlockNode extends DecoratorNode {
|
|
319
395
|
static getType() {
|
|
@@ -379,7 +455,7 @@ var CodeBlockNode = class CodeBlockNode extends DecoratorNode {
|
|
|
379
455
|
};
|
|
380
456
|
_defineProperty(CodeBlockNode, "commandItems", [{
|
|
381
457
|
title: "Code Block",
|
|
382
|
-
icon:
|
|
458
|
+
icon: codeCommandIcon,
|
|
383
459
|
description: "Syntax-highlighted code",
|
|
384
460
|
keywords: [
|
|
385
461
|
"code",
|
|
@@ -467,7 +543,7 @@ var CommentNode = class CommentNode extends TextNode {
|
|
|
467
543
|
};
|
|
468
544
|
_defineProperty(CommentNode, "commandItems", [{
|
|
469
545
|
title: "HTML Comment",
|
|
470
|
-
icon:
|
|
546
|
+
icon: messageSquareQuoteCommandIcon,
|
|
471
547
|
description: "Insert an HTML comment node",
|
|
472
548
|
keywords: [
|
|
473
549
|
"comment",
|
|
@@ -618,7 +694,7 @@ var DetailsNode = class DetailsNode extends ElementNode {
|
|
|
618
694
|
};
|
|
619
695
|
_defineProperty(DetailsNode, "slashMenuItems", [{
|
|
620
696
|
title: "Details",
|
|
621
|
-
icon:
|
|
697
|
+
icon: chevronRightCommandIcon,
|
|
622
698
|
description: "Collapsible content block",
|
|
623
699
|
keywords: [
|
|
624
700
|
"details",
|
|
@@ -761,7 +837,7 @@ var FileNode = class FileNode extends DecoratorNode {
|
|
|
761
837
|
};
|
|
762
838
|
_defineProperty(FileNode, "commandItems", [{
|
|
763
839
|
title: "File",
|
|
764
|
-
icon:
|
|
840
|
+
icon: paperclipCommandIcon,
|
|
765
841
|
description: "Attach a file",
|
|
766
842
|
keywords: [
|
|
767
843
|
"file",
|
|
@@ -1673,7 +1749,7 @@ var ImageNode = class ImageNode extends DecoratorNode {
|
|
|
1673
1749
|
};
|
|
1674
1750
|
_defineProperty(ImageNode, "commandItems", [{
|
|
1675
1751
|
title: "Image",
|
|
1676
|
-
icon:
|
|
1752
|
+
icon: imageCommandIcon,
|
|
1677
1753
|
description: "Upload or embed an image",
|
|
1678
1754
|
keywords: [
|
|
1679
1755
|
"image",
|
|
@@ -1783,7 +1859,7 @@ var KaTeXBlockNode = class KaTeXBlockNode extends DecoratorNode {
|
|
|
1783
1859
|
};
|
|
1784
1860
|
_defineProperty(KaTeXBlockNode, "slashMenuItems", [{
|
|
1785
1861
|
title: "Math Equation",
|
|
1786
|
-
icon:
|
|
1862
|
+
icon: sigmaCommandIcon,
|
|
1787
1863
|
description: "KaTeX block formula",
|
|
1788
1864
|
keywords: [
|
|
1789
1865
|
"math",
|
|
@@ -1994,7 +2070,7 @@ var LinkCardNode = class LinkCardNode extends DecoratorNode {
|
|
|
1994
2070
|
};
|
|
1995
2071
|
_defineProperty(LinkCardNode, "commandItems", [{
|
|
1996
2072
|
title: "Link Card",
|
|
1997
|
-
icon:
|
|
2073
|
+
icon: linkCommandIcon,
|
|
1998
2074
|
description: "Link preview card",
|
|
1999
2075
|
keywords: [
|
|
2000
2076
|
"link",
|
|
@@ -2186,7 +2262,7 @@ var MermaidNode = class MermaidNode extends DecoratorNode {
|
|
|
2186
2262
|
};
|
|
2187
2263
|
_defineProperty(MermaidNode, "commandItems", [{
|
|
2188
2264
|
title: "Mermaid Diagram",
|
|
2189
|
-
icon:
|
|
2265
|
+
icon: workflowCommandIcon,
|
|
2190
2266
|
description: "Flowchart, sequence diagram",
|
|
2191
2267
|
keywords: [
|
|
2192
2268
|
"mermaid",
|
|
@@ -2480,7 +2556,7 @@ var TagNode = class TagNode extends TextNode {
|
|
|
2480
2556
|
};
|
|
2481
2557
|
_defineProperty(TagNode, "commandItems", [{
|
|
2482
2558
|
title: "Tag",
|
|
2483
|
-
icon:
|
|
2559
|
+
icon: tagCommandIcon,
|
|
2484
2560
|
description: "Insert a tag",
|
|
2485
2561
|
keywords: [
|
|
2486
2562
|
"tag",
|
|
@@ -2595,7 +2671,7 @@ var VideoNode = class VideoNode extends DecoratorNode {
|
|
|
2595
2671
|
};
|
|
2596
2672
|
_defineProperty(VideoNode, "commandItems", [{
|
|
2597
2673
|
title: "Video",
|
|
2598
|
-
icon:
|
|
2674
|
+
icon: videoCommandIcon,
|
|
2599
2675
|
description: "Embed a video",
|
|
2600
2676
|
keywords: [
|
|
2601
2677
|
"video",
|
|
@@ -2622,7 +2698,8 @@ var builtinNodes = [
|
|
|
2622
2698
|
RichQuoteNode,
|
|
2623
2699
|
{
|
|
2624
2700
|
replace: QuoteNode,
|
|
2625
|
-
with: () => new RichQuoteNode()
|
|
2701
|
+
with: () => new RichQuoteNode(),
|
|
2702
|
+
withKlass: RichQuoteNode
|
|
2626
2703
|
},
|
|
2627
2704
|
ListNode,
|
|
2628
2705
|
ListItemNode,
|
|
@@ -151,7 +151,7 @@ function useFootnoteDisplayNumber(identifier) {
|
|
|
151
151
|
}
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/components/renderers/FootnoteStaticRenderer.tsx
|
|
154
|
-
function
|
|
154
|
+
function useFootnoteRef(identifier) {
|
|
155
155
|
const content = useFootnoteContent(identifier);
|
|
156
156
|
const displayNumber = useFootnoteDisplayNumber(identifier);
|
|
157
157
|
const referenceId = `footnote-ref-${identifier}`;
|
|
@@ -170,16 +170,26 @@ function FootnoteStaticRenderer({ identifier }) {
|
|
|
170
170
|
}, 1200);
|
|
171
171
|
}, [identifier, targetId]);
|
|
172
172
|
const label = displayNumber ?? identifier;
|
|
173
|
+
return {
|
|
174
|
+
content,
|
|
175
|
+
label,
|
|
176
|
+
anchorProps: {
|
|
177
|
+
"aria-label": content ? `Footnote ${label}: ${content}` : `Footnote ${label}`,
|
|
178
|
+
"className": clsx(semanticClassNames.footnoteRef, sharedStyles.footnoteRef),
|
|
179
|
+
"data-footnote-ref": identifier,
|
|
180
|
+
"href": `#${targetId}`,
|
|
181
|
+
"id": referenceId,
|
|
182
|
+
"onClick": handleClick,
|
|
183
|
+
"role": "doc-noteref"
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function FootnoteStaticRenderer({ identifier }) {
|
|
188
|
+
const { anchorProps, label } = useFootnoteRef(identifier);
|
|
173
189
|
return /* @__PURE__ */ jsx("span", {
|
|
174
190
|
className: clsx(semanticClassNames.footnoteRefWrapper, sharedStyles.footnoteRefWrapper),
|
|
175
191
|
children: /* @__PURE__ */ jsx("a", {
|
|
176
|
-
|
|
177
|
-
className: clsx(semanticClassNames.footnoteRef, sharedStyles.footnoteRef),
|
|
178
|
-
"data-footnote-ref": identifier,
|
|
179
|
-
href: `#${targetId}`,
|
|
180
|
-
id: referenceId,
|
|
181
|
-
role: "doc-noteref",
|
|
182
|
-
onClick: handleClick,
|
|
192
|
+
...anchorProps,
|
|
183
193
|
children: label
|
|
184
194
|
})
|
|
185
195
|
});
|
|
@@ -281,4 +291,4 @@ function LinkCardRenderer({ url, title, description, favicon, image }) {
|
|
|
281
291
|
});
|
|
282
292
|
}
|
|
283
293
|
//#endregion
|
|
284
|
-
export {
|
|
294
|
+
export { MERMAID_NODE_KEY as A, FILE_NODE_KEY as C, KATEX_NODE_KEY as D, IMAGE_NODE_KEY as E, TAG_NODE_KEY as M, VIDEO_NODE_KEY as N, LINK_CARD_NODE_KEY as O, CODE_BLOCK_NODE_KEY as S, FOOTNOTE_SECTION_NODE_KEY as T, useRendererConfig as _, useFootnoteRef as a, ALERT_NODE_KEY as b, useFootnoteDefinitions as c, fileExtension as d, fileMetaText as f, RendererConfigContext as g, RendererWrapper as h, FootnoteStaticRenderer as i, RUBY_NODE_KEY as j, MENTION_NODE_KEY as k, useFootnoteDisplayNumber as l, createRendererDecoration as m, computeImageMeta as n, FootnoteDefinitionsContext as o, formatFileSize as p, decodeThumbHash as r, useFootnoteContent as s, LinkCardRenderer as t, FileRenderer as u, useRendererMode as v, FOOTNOTE_NODE_KEY as w, BANNER_NODE_KEY as x, useVariant as y };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as ColorSchemeContext } from "./ColorSchemeContext-
|
|
2
|
-
import {
|
|
1
|
+
import { t as ColorSchemeContext } from "./ColorSchemeContext-g-0-suc1.js";
|
|
2
|
+
import { g as RendererConfigContext } from "./LinkCardRenderer-D8n5tdHI.js";
|
|
3
3
|
import { n as semanticClassNames, r as sharedStyles } from "./shared.css-DRoqE_U-.js";
|
|
4
4
|
import { t as clsx } from "./utils-i78C9io3.js";
|
|
5
|
-
import { i as probeFavicon, r as getHostname } from "./normalizeSerializedEditorState-
|
|
5
|
+
import { i as probeFavicon, r as getHostname } from "./normalizeSerializedEditorState-C_JlVtWQ.js";
|
|
6
6
|
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
8
|
import { Globe, Mail } from "lucide-react";
|
|
@@ -195,7 +195,7 @@ function ActiveEditorScope({ children }) {
|
|
|
195
195
|
}
|
|
196
196
|
//#endregion
|
|
197
197
|
//#region src/virtualization/VirtualizationPlugin.tsx
|
|
198
|
-
var VirtualizedEditor = lazy(() => import("./VirtualizedEditor-
|
|
198
|
+
var VirtualizedEditor = lazy(() => import("./VirtualizedEditor-MQBNGDZc.js").then((module) => ({ default: module.VirtualizedEditor })));
|
|
199
199
|
function VirtualizationPlugin({ scrollContainer, overscan, estimateBlockHeight, preserveCapacity, selectionMergeLimit, priority = 0 }) {
|
|
200
200
|
const surface = useMemo(() => {
|
|
201
201
|
const options = {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { c as $createAlertQuoteEditNode, h as setCodeBlockCursorIntent, m as PasteLinkPlugin, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-
|
|
1
|
+
import { c as $createAlertQuoteEditNode, h as setCodeBlockCursorIntent, m as PasteLinkPlugin, o as $createCodeBlockEditNode, s as $createBannerEditNode, t as getResolvedEditNodes } from "./node-registry-CX3ZzEuQ.js";
|
|
2
2
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
3
3
|
/* empty css */
|
|
4
|
-
import { $ as $isFootnoteSectionNode, A as KaTeXInlineNode, At as INLINE_DRAG_MIME, N as KaTeXBlockNode, O as $createKaTeXInlineNode, P as $createImageNode, Q as $createFootnoteSectionNode, R as $withAdaptiveImageDisplayWidth, S as $createMentionNode, Y as $isGridContainerNode, ct as DetailsNode, et as FootnoteSectionNode, ft as CommentNode, h as RubyNode, it as $isFileNode, j as $createKaTeXBlockNode, kt as INLINE_DRAG_ATTR, lt as $createCommentNode, mt as CodeBlockNode, nt as FootnoteNode, ot as fileExtFromName, p as $createRubyNode, rt as $createFileNode, s as $createVideoNode, st as $createDetailsNode, tt as $createFootnoteNode, ut as $createCommentPlaceholderNode, vt as BannerNode, w as MentionNode, wt as AlertQuoteNode, y as $createMermaidNode } from "./ColorSchemeContext-
|
|
5
|
-
import { n as computeImageMeta } from "./LinkCardRenderer-
|
|
4
|
+
import { $ as $isFootnoteSectionNode, A as KaTeXInlineNode, At as INLINE_DRAG_MIME, N as KaTeXBlockNode, O as $createKaTeXInlineNode, P as $createImageNode, Q as $createFootnoteSectionNode, R as $withAdaptiveImageDisplayWidth, S as $createMentionNode, Y as $isGridContainerNode, ct as DetailsNode, et as FootnoteSectionNode, ft as CommentNode, h as RubyNode, it as $isFileNode, j as $createKaTeXBlockNode, kt as INLINE_DRAG_ATTR, lt as $createCommentNode, mt as CodeBlockNode, nt as FootnoteNode, ot as fileExtFromName, p as $createRubyNode, rt as $createFileNode, s as $createVideoNode, st as $createDetailsNode, tt as $createFootnoteNode, ut as $createCommentPlaceholderNode, vt as BannerNode, w as MentionNode, wt as AlertQuoteNode, y as $createMermaidNode } from "./ColorSchemeContext-g-0-suc1.js";
|
|
5
|
+
import { n as computeImageMeta } from "./LinkCardRenderer-D8n5tdHI.js";
|
|
6
6
|
import { a as OPEN_FILE_PICKER_COMMAND, i as OPEN_IMAGE_UPLOAD_DIALOG_COMMAND, o as extractTextContent, r as SpoilerNode, t as $createSpoilerNode } from "./SpoilerNode-D7Tgdo2K.js";
|
|
7
|
-
import { i as probeFavicon, n as FootnoteDefinitionsProvider, r as getHostname, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-
|
|
8
|
-
import "./VirtualizationPlugin-
|
|
7
|
+
import { i as probeFavicon, n as FootnoteDefinitionsProvider, r as getHostname, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-C_JlVtWQ.js";
|
|
8
|
+
import "./VirtualizationPlugin-BAImcSjr.js";
|
|
9
9
|
import { a as INSERT_MERMAID_COMMAND, i as INSERT_KATEX_INLINE_COMMAND, n as INSERT_IMAGE_COMMAND, r as INSERT_KATEX_BLOCK_COMMAND, t as INSERT_ALERT_COMMAND } from "./insert-commands-CtLGoIz0.js";
|
|
10
10
|
import { t as blockIdState } from "./block-id-state-DfN32rR_.js";
|
|
11
11
|
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
@@ -1302,6 +1302,11 @@ function normalizeRootBlockIds(editor, previousIdIndex) {
|
|
|
1302
1302
|
}
|
|
1303
1303
|
}, { tag: NORMALIZATION_TAG });
|
|
1304
1304
|
}
|
|
1305
|
+
function $touchesRootChildren(dirtyElements, dirtyLeaves) {
|
|
1306
|
+
for (const [key, intentional] of dirtyElements) if (intentional && $getNodeByKey(key)?.getParent()?.getKey() === "root") return true;
|
|
1307
|
+
for (const key of dirtyLeaves) if ($getNodeByKey(key)?.getParent()?.getKey() === "root") return true;
|
|
1308
|
+
return false;
|
|
1309
|
+
}
|
|
1305
1310
|
function syncBlockIdAttributes(editor) {
|
|
1306
1311
|
editor.getEditorState().read(() => {
|
|
1307
1312
|
for (const child of $getRoot().getChildren()) {
|
|
@@ -1317,17 +1322,13 @@ function BlockIdPlugin() {
|
|
|
1317
1322
|
useEffect(() => {
|
|
1318
1323
|
if (hasDuplicateOrMissingId(collectRootChildren(editor.getEditorState()))) normalizeRootBlockIds(editor, /* @__PURE__ */ new Map());
|
|
1319
1324
|
syncBlockIdAttributes(editor);
|
|
1320
|
-
return editor.registerUpdateListener(({
|
|
1321
|
-
if (
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
}
|
|
1325
|
-
if (!hasDuplicateOrMissingId(collectRootChildren(editorState))) {
|
|
1326
|
-
syncBlockIdAttributes(editor);
|
|
1325
|
+
return editor.registerUpdateListener(({ dirtyElements, dirtyLeaves, editorState, prevEditorState }) => {
|
|
1326
|
+
if (!(editorState.read($getRoot) !== prevEditorState.read($getRoot) || editorState.read(() => $touchesRootChildren(dirtyElements, dirtyLeaves)))) return;
|
|
1327
|
+
if (hasDuplicateOrMissingId(collectRootChildren(editorState))) {
|
|
1328
|
+
normalizeRootBlockIds(editor, buildPreviousIdIndex(prevEditorState));
|
|
1327
1329
|
return;
|
|
1328
1330
|
}
|
|
1329
|
-
|
|
1330
|
-
normalizeRootBlockIds(editor, previousIdIndex);
|
|
1331
|
+
syncBlockIdAttributes(editor);
|
|
1331
1332
|
});
|
|
1332
1333
|
}, [editor]);
|
|
1333
1334
|
return null;
|
|
@@ -3415,25 +3416,30 @@ function FootnotePlugin({ children }) {
|
|
|
3415
3416
|
//#region src/plugins/OnChangePlugin.tsx
|
|
3416
3417
|
function OnChangePlugin({ onChange, debounceMs }) {
|
|
3417
3418
|
const [editor] = useLexicalComposerContext();
|
|
3418
|
-
const timerRef = useRef(void 0);
|
|
3419
3419
|
const onChangeRef = useRef(onChange);
|
|
3420
3420
|
useLayoutEffect(() => {
|
|
3421
3421
|
onChangeRef.current = onChange;
|
|
3422
3422
|
});
|
|
3423
3423
|
useEffect(() => {
|
|
3424
|
-
|
|
3424
|
+
let timer;
|
|
3425
|
+
let pending = null;
|
|
3426
|
+
const flush = () => {
|
|
3427
|
+
const state = pending;
|
|
3428
|
+
pending = null;
|
|
3425
3429
|
const fn = onChangeRef.current;
|
|
3426
|
-
if (
|
|
3427
|
-
|
|
3430
|
+
if (state && fn) fn(normalizeSerializedEditorState(state.toJSON()));
|
|
3431
|
+
};
|
|
3432
|
+
const unregister = editor.registerUpdateListener(({ dirtyElements, dirtyLeaves, editorState, prevEditorState }) => {
|
|
3433
|
+
if (!onChangeRef.current) return;
|
|
3434
|
+
if (dirtyElements.size === 0 && dirtyLeaves.size === 0 && editorState.read($getRoot) === prevEditorState.read($getRoot)) return;
|
|
3435
|
+
pending = editorState;
|
|
3428
3436
|
if (debounceMs && debounceMs > 0) {
|
|
3429
|
-
clearTimeout(
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
}, debounceMs);
|
|
3433
|
-
} else fn(serializedState);
|
|
3437
|
+
clearTimeout(timer);
|
|
3438
|
+
timer = setTimeout(flush, debounceMs);
|
|
3439
|
+
} else flush();
|
|
3434
3440
|
});
|
|
3435
3441
|
return () => {
|
|
3436
|
-
clearTimeout(
|
|
3442
|
+
clearTimeout(timer);
|
|
3437
3443
|
unregister();
|
|
3438
3444
|
};
|
|
3439
3445
|
}, [editor, debounceMs]);
|
|
@@ -3,7 +3,7 @@ import { t as _defineProperty } from "./defineProperty-BYhxpJwd.js";
|
|
|
3
3
|
import { n as useNestedEditorPlugins } from "./NestedEditorPluginsContext-DKFdozOE.js";
|
|
4
4
|
import { t as blockIdState } from "./block-id-state-DfN32rR_.js";
|
|
5
5
|
import { n as contentWrapper, t as content } from "./ContentEditable.css--lQ6ekTS.js";
|
|
6
|
-
import { a as
|
|
6
|
+
import { _ as estimateHeight, a as getViewportHeight, c as resolveScrollContainer, f as slot, h as TypePool, i as getScrollTop, l as setScrollTop, m as HeightIndex, n as findAnchorIndex, p as PreserveNodeManager, r as getCanvasTop, s as mountOrderedSlot, t as documentPrevTag, u as canvas, v as occupiedHeight } from "./viewport-BllJyZ07.js";
|
|
7
7
|
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
8
8
|
import { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
9
9
|
import { $exportNodeJSON, $getNodeByKey, $getRoot, $getSelection, $getSlot, $getSlotNames, $getState, $isElementNode, $isRangeSelection, $parseSerializedNode, $setSelection, $setState, COMMAND_PRIORITY_CRITICAL, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_LEFT_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, KEY_DELETE_COMMAND, REDO_COMMAND, SKIP_DOM_SELECTION_TAG, SKIP_SCROLL_INTO_VIEW_TAG, UNDO_COMMAND, createEditor } from "lexical";
|
|
@@ -357,20 +357,16 @@ var EditorRecycler = class {
|
|
|
357
357
|
return this.document.rows;
|
|
358
358
|
}
|
|
359
359
|
get scrollTop() {
|
|
360
|
-
return this.viewport
|
|
360
|
+
return getScrollTop(this.viewport);
|
|
361
361
|
}
|
|
362
362
|
setScrollTop(top) {
|
|
363
|
-
|
|
364
|
-
else window.scrollTo(window.scrollX, top);
|
|
365
|
-
}
|
|
366
|
-
viewportTop() {
|
|
367
|
-
return this.viewport instanceof HTMLElement ? this.viewport.getBoundingClientRect().top + this.viewport.clientTop : 0;
|
|
363
|
+
setScrollTop(this.viewport, top);
|
|
368
364
|
}
|
|
369
365
|
viewportHeight() {
|
|
370
|
-
return this.viewport
|
|
366
|
+
return getViewportHeight(this.viewport);
|
|
371
367
|
}
|
|
372
368
|
canvasTop() {
|
|
373
|
-
return this.canvas
|
|
369
|
+
return getCanvasTop(this.canvas, this.viewport);
|
|
374
370
|
}
|
|
375
371
|
buildHeights() {
|
|
376
372
|
return new HeightIndex(this.rows.map((row) => this.estimate(row.data)));
|
|
@@ -568,8 +564,7 @@ var EditorRecycler = class {
|
|
|
568
564
|
if (element) this.observer.observe(element);
|
|
569
565
|
}
|
|
570
566
|
mount(slot, host) {
|
|
571
|
-
|
|
572
|
-
this.preserve.mount(slot.id, host, slot.active ? this.canvas : null, next ?? null);
|
|
567
|
+
mountOrderedSlot(this.preserve, this.pool.slots, slot, this.canvas, host);
|
|
573
568
|
}
|
|
574
569
|
/** Commit a rendered slot: mount its portal host, bind or invalidate its island, set its release hook. */
|
|
575
570
|
commitSlot(slot, host, mounted, onRelease) {
|
|
@@ -641,9 +636,7 @@ var EditorRecycler = class {
|
|
|
641
636
|
});
|
|
642
637
|
}
|
|
643
638
|
anchor() {
|
|
644
|
-
const
|
|
645
|
-
const target = document.elementFromPoint(bounds.left + bounds.width / 2, Math.max(this.viewportTop() + 8, bounds.top + 1))?.closest("[data-virtual-editor-slot]");
|
|
646
|
-
const index = this.pool.slots.find((item) => item.active && item.element === target)?.index ?? this.heights.find(Math.max(0, this.scrollTop - this.canvasTop()));
|
|
639
|
+
const index = findAnchorIndex(this.canvas, this.viewport, this.pool.slots, this.heights, "[data-virtual-editor-slot]");
|
|
647
640
|
return {
|
|
648
641
|
id: this.previousRows[index]?.id ?? this.rows[index]?.id,
|
|
649
642
|
offset: this.scrollTop - this.canvasTop() - this.blockOffset(index)
|
|
@@ -682,6 +675,7 @@ var EditorRecycler = class {
|
|
|
682
675
|
changed = true;
|
|
683
676
|
}
|
|
684
677
|
const measured = /* @__PURE__ */ new Set();
|
|
678
|
+
const islands = [];
|
|
685
679
|
for (const slot of this.pool.slots) {
|
|
686
680
|
if (!slot.active) continue;
|
|
687
681
|
const island = this.islands.get(slot.id);
|
|
@@ -695,19 +689,26 @@ var EditorRecycler = class {
|
|
|
695
689
|
element.toggleAttribute("data-document-first", index === 0 && element === root.firstElementChild);
|
|
696
690
|
element.toggleAttribute("data-document-last", index === this.rows.length - 1 && element === root.lastElementChild);
|
|
697
691
|
element.toggleAttribute("data-document-first-paragraph", index === this.firstParagraph);
|
|
698
|
-
element.dataset.documentPrevTag = previous
|
|
692
|
+
element.dataset.documentPrevTag = documentPrevTag(previous);
|
|
693
|
+
if (index >= 0 && i < island.ids.length) element.dataset.blockId = island.ids[i];
|
|
694
|
+
});
|
|
695
|
+
islands.push({
|
|
696
|
+
elements,
|
|
697
|
+
ids: island.ids,
|
|
698
|
+
root
|
|
699
699
|
});
|
|
700
|
+
}
|
|
701
|
+
for (const { elements, ids, root } of islands) {
|
|
700
702
|
const bounds = root.getBoundingClientRect();
|
|
701
703
|
const rects = elements.map((element) => element?.getBoundingClientRect());
|
|
702
|
-
|
|
704
|
+
ids.forEach((id, i) => {
|
|
703
705
|
const index = this.indices.get(id) ?? -1;
|
|
704
706
|
const element = elements[i];
|
|
705
707
|
if (index < 0 || !element) return;
|
|
706
|
-
element.dataset.blockId = id;
|
|
707
708
|
const rect = rects[i];
|
|
708
709
|
const style = getComputedStyle(element);
|
|
709
710
|
const top = i === 0 ? rect.top - bounds.top : parseFloat(style.marginTop) || 0;
|
|
710
|
-
const bottom = i ===
|
|
711
|
+
const bottom = i === ids.length - 1 ? bounds.bottom - rect.bottom : parseFloat(style.marginBottom) || 0;
|
|
711
712
|
if (Math.abs(top - (this.metrics.get(id)?.top ?? 0)) > .1) changed = true;
|
|
712
713
|
this.metrics.set(id, {
|
|
713
714
|
height: rect.height,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FootnoteRenderer.d.ts","sources":["../../../src/components/renderers/FootnoteRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FootnoteRenderer.d.ts","sources":["../../../src/components/renderers/FootnoteRenderer.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,EAAE,qBAAqB,+BAiBrE"}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { AnchorHTMLAttributes } from 'react';
|
|
1
2
|
export interface FootnoteStaticRendererProps {
|
|
2
3
|
identifier: string;
|
|
3
4
|
}
|
|
5
|
+
export declare function useFootnoteRef(identifier: string): {
|
|
6
|
+
anchorProps: AnchorHTMLAttributes<HTMLAnchorElement>;
|
|
7
|
+
content: string | undefined;
|
|
8
|
+
label: number | string;
|
|
9
|
+
};
|
|
4
10
|
export declare function FootnoteStaticRenderer({ identifier }: FootnoteStaticRendererProps): import("react").JSX.Element;
|
|
5
11
|
//# sourceMappingURL=FootnoteStaticRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FootnoteStaticRenderer.d.ts","sources":["../../../src/components/renderers/FootnoteStaticRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FootnoteStaticRenderer.d.ts","sources":["../../../src/components/renderers/FootnoteStaticRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAc,MAAM,OAAO,CAAC;AAU9D,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG;IAClD,WAAW,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;IACrD,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CA0CA;AAED,wBAAgB,sBAAsB,CAAC,EAAE,UAAU,EAAE,EAAE,2BAA2B,+BAQjF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export * from './styles';
|
|
|
38
38
|
export type { RichEditorProps, RichEditorVariant } from './types';
|
|
39
39
|
export type { RendererConfig } from './types/renderer-config';
|
|
40
40
|
export { ALERT_NODE_KEY, BANNER_NODE_KEY, CODE_BLOCK_NODE_KEY, FILE_NODE_KEY, FOOTNOTE_NODE_KEY, FOOTNOTE_SECTION_NODE_KEY, IMAGE_NODE_KEY, KATEX_NODE_KEY, LINK_CARD_NODE_KEY, MENTION_NODE_KEY, MERMAID_NODE_KEY, RUBY_NODE_KEY, TAG_NODE_KEY, VIDEO_NODE_KEY, } from './types/renderer-keys';
|
|
41
|
+
export { getBlockElement, getDropTargetBlock, getNearestBlockByY } from './utils/block-dom';
|
|
41
42
|
export type { AnchorError, AnchorResult, BlockAnchor, CommentAnchor, RangeAnchor, } from './utils/comment-anchor';
|
|
42
43
|
export { $getRootBlock, $getTextOffsetInBlock, $resolveSelectionPoint, buildBlockAnchor, buildRangeAnchor, } from './utils/comment-anchor';
|
|
43
44
|
export { registerNestedEditorSync } from './utils/nested-editor-sync';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,YAAY,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,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AChB,aAAa,EACb,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,YAAY,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,aAAa,EACb,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,YAAY,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EACL,qBAAqB,EACrB,uCAAuC,EACvC,qBAAqB,EACrB,+BAA+B,EAC/B,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACjF,YAAY,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { $ as CorePlugins, B as FileUploadPlugin, C as createTextSelectionStore, D as LinkFaviconPlugin, E as MermaidPlugin, G as VideoUploadProvider, N as ImagePlugin, O as KaTeXPlugin, P as defaultImageUpload, S as TextSelectionStoreContext, T as useTextSelectionStore, U as BlockIdPlugin, W as AlertPlugin, Y as ImagePreprocessProvider, Z as FileUploadProvider, _ as $getRootBlock, a as EditorRefPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as FootnotePlugin, k as ImageUploadPlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, q as ImageUploadProvider, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint } from "./VirtualizationPlugin-
|
|
2
|
-
import { d as useNestedEditorSync, f as registerNestedEditorSync, l as NESTED_EDITOR_NODES, n as setResolvedEditNodes, p as NestedEditorCorePlugins, r as allEditNodes, u as createNestedEditor } from "./node-registry-
|
|
1
|
+
import { $ as CorePlugins, B as FileUploadPlugin, C as createTextSelectionStore, D as LinkFaviconPlugin, E as MermaidPlugin, G as VideoUploadProvider, N as ImagePlugin, O as KaTeXPlugin, P as defaultImageUpload, S as TextSelectionStoreContext, T as useTextSelectionStore, U as BlockIdPlugin, W as AlertPlugin, Y as ImagePreprocessProvider, Z as FileUploadProvider, _ as $getRootBlock, a as EditorRefPlugin, b as buildBlockAnchor, c as $captureTextSelection, d as createDOMRangeFromTextSelection, f as findDOMPointByTextOffset, g as TEXT_SELECTION_HIGHLIGHT_NAME, h as getTextOffsetFromDOMPoint, i as FootnotePlugin, k as ImageUploadPlugin, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, q as ImageUploadProvider, r as OnChangePlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, u as $restoreTextSelection, v as $getTextOffsetInBlock, w as useTextSelectionSnapshot, x as buildRangeAnchor, y as $resolveSelectionPoint } from "./VirtualizationPlugin-CfABS8dF.js";
|
|
2
|
+
import { d as useNestedEditorSync, f as registerNestedEditorSync, l as NESTED_EDITOR_NODES, n as setResolvedEditNodes, p as NestedEditorCorePlugins, r as allEditNodes, u as createNestedEditor } from "./node-registry-CX3ZzEuQ.js";
|
|
3
3
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
4
|
-
import { Dt as useNestedContentRenderer, Et as NestedContentRendererProvider, Ot as useOptionalNestedContentRenderer, n as useColorScheme, r as editorTheme } from "./ColorSchemeContext-
|
|
5
|
-
import { A as
|
|
4
|
+
import { Dt as useNestedContentRenderer, Et as NestedContentRendererProvider, Ot as useOptionalNestedContentRenderer, n as useColorScheme, r as editorTheme } from "./ColorSchemeContext-g-0-suc1.js";
|
|
5
|
+
import { A as MERMAID_NODE_KEY, C as FILE_NODE_KEY, D as KATEX_NODE_KEY, E as IMAGE_NODE_KEY, M as TAG_NODE_KEY, N as VIDEO_NODE_KEY, O as LINK_CARD_NODE_KEY, S as CODE_BLOCK_NODE_KEY, T as FOOTNOTE_SECTION_NODE_KEY, _ as useRendererConfig, b as ALERT_NODE_KEY, c as useFootnoteDefinitions, j as RUBY_NODE_KEY, k as MENTION_NODE_KEY, l as useFootnoteDisplayNumber, s as useFootnoteContent, v as useRendererMode, w as FOOTNOTE_NODE_KEY, x as BANNER_NODE_KEY, y as useVariant } from "./LinkCardRenderer-D8n5tdHI.js";
|
|
6
6
|
import { n as semanticClassNames, r as sharedStyles, t as richContent } from "./shared.css-DRoqE_U-.js";
|
|
7
7
|
import { a as chatVariant, i as commentVariant, n as getVariantClass, o as articleVariant, r as noteVariant, t as clsx } from "./utils-i78C9io3.js";
|
|
8
8
|
import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-DAMDDTZh.js";
|
|
9
9
|
import { n as useNestedEditorPlugins, t as NestedEditorPluginsContext } from "./NestedEditorPluginsContext-DKFdozOE.js";
|
|
10
|
-
import { n as FootnoteDefinitionsProvider, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-
|
|
11
|
-
import { a as LinkFavicon, i as useExtraNodes, n as ColorSchemeProvider, r as ExtraNodesProvider, t as RendererConfigProvider } from "./RendererConfigProvider-
|
|
12
|
-
import { a as EditorSurfaceProvider, i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, s as useEditorSurface, t as VirtualizationPlugin } from "./VirtualizationPlugin-
|
|
10
|
+
import { n as FootnoteDefinitionsProvider, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-C_JlVtWQ.js";
|
|
11
|
+
import { a as LinkFavicon, i as useExtraNodes, n as ColorSchemeProvider, r as ExtraNodesProvider, t as RendererConfigProvider } from "./RendererConfigProvider-Bt5fxwhg.js";
|
|
12
|
+
import { a as EditorSurfaceProvider, i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, s as useEditorSurface, t as VirtualizationPlugin } from "./VirtualizationPlugin-BAImcSjr.js";
|
|
13
13
|
import { t as blockIdState } from "./block-id-state-DfN32rR_.js";
|
|
14
14
|
import { n as contentWrapper, r as placeholder, t as content } from "./ContentEditable.css--lQ6ekTS.js";
|
|
15
15
|
import { n as katexStyles, t as katexClassNames } from "./katex.css-DJbW49pH.js";
|
|
@@ -208,4 +208,58 @@ function NestedEditorPluginsProvider({ children, plugins }) {
|
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
//#endregion
|
|
211
|
-
|
|
211
|
+
//#region src/utils/block-dom.ts
|
|
212
|
+
function getBlockElement(editor, target) {
|
|
213
|
+
const rootElement = editor.getRootElement();
|
|
214
|
+
if (!rootElement) return null;
|
|
215
|
+
let current = target;
|
|
216
|
+
while (current && current !== rootElement) {
|
|
217
|
+
if (current.parentElement === rootElement) return current;
|
|
218
|
+
current = current.parentElement;
|
|
219
|
+
}
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
function getNearestBlockByY(rootElement, clientY) {
|
|
223
|
+
const blocks = [...rootElement.children].filter((child) => child instanceof HTMLElement);
|
|
224
|
+
if (!blocks.length) return null;
|
|
225
|
+
let nearestBlock = null;
|
|
226
|
+
let nearestDistance = Number.POSITIVE_INFINITY;
|
|
227
|
+
for (const block of blocks) {
|
|
228
|
+
const rect = block.getBoundingClientRect();
|
|
229
|
+
if (rect.height <= 0) continue;
|
|
230
|
+
if (clientY >= rect.top && clientY <= rect.bottom) return block;
|
|
231
|
+
const distance = clientY < rect.top ? rect.top - clientY : clientY - rect.bottom;
|
|
232
|
+
if (distance < nearestDistance) {
|
|
233
|
+
nearestDistance = distance;
|
|
234
|
+
nearestBlock = block;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return nearestBlock;
|
|
238
|
+
}
|
|
239
|
+
function getDropTargetBlock(editor, rootElement, event) {
|
|
240
|
+
const rootRect = rootElement.getBoundingClientRect();
|
|
241
|
+
if (rootRect.width <= 0 || rootRect.height <= 0) return null;
|
|
242
|
+
if (event.clientY < rootRect.top || event.clientY > rootRect.bottom) return null;
|
|
243
|
+
const points = [{
|
|
244
|
+
x: event.clientX,
|
|
245
|
+
y: event.clientY
|
|
246
|
+
}];
|
|
247
|
+
const clampedX = Math.min(rootRect.right - 1, Math.max(rootRect.left + 1, event.clientX));
|
|
248
|
+
if (clampedX !== event.clientX) points.unshift({
|
|
249
|
+
x: clampedX,
|
|
250
|
+
y: event.clientY
|
|
251
|
+
});
|
|
252
|
+
for (const point of points) {
|
|
253
|
+
const element = document.elementFromPoint(point.x, point.y);
|
|
254
|
+
if (!(element instanceof HTMLElement)) continue;
|
|
255
|
+
const block = getBlockElement(editor, element);
|
|
256
|
+
if (block) return block;
|
|
257
|
+
}
|
|
258
|
+
if (event.target instanceof HTMLElement) {
|
|
259
|
+
const block = getBlockElement(editor, event.target);
|
|
260
|
+
if (block) return block;
|
|
261
|
+
}
|
|
262
|
+
return getNearestBlockByY(rootElement, event.clientY);
|
|
263
|
+
}
|
|
264
|
+
//#endregion
|
|
265
|
+
export { $captureTextSelection, $captureTextSelectionFromRangeSelection, $getRootBlock, $getTextOffsetInBlock, $resolveSelectionPoint, $restoreTextSelection, ALERT_NODE_KEY, ActiveEditorScope, BANNER_NODE_KEY, CODE_BLOCK_NODE_KEY, ColorSchemeProvider, CorePlugins, EditorSurfacePlugin, EditorSurfacePlugins, ExtraNodesProvider, FILE_NODE_KEY, FOOTNOTE_NODE_KEY, FOOTNOTE_SECTION_NODE_KEY, FootnoteDefinitionsProvider, IMAGE_NODE_KEY, KATEX_NODE_KEY, LINK_CARD_NODE_KEY, LinkFavicon, MENTION_NODE_KEY, MERMAID_NODE_KEY, NESTED_EDITOR_NODES, NestedContentRendererProvider, NestedEditorCorePlugins, NestedEditorPluginsProvider, RUBY_NODE_KEY, RendererConfigProvider, RichEditor, RichEditorShell, TAG_NODE_KEY, TEXT_SELECTION_HIGHLIGHT_NAME, TextSelectionStoreProvider, VIDEO_NODE_KEY, VirtualizationPlugin, articleTheme, articleVariant, blockIdState, buildBlockAnchor, buildRangeAnchor, chatTheme, chatVariant, commentTheme, commentVariant, createDOMRangeFromTextSelection, createNestedEditor, createTextSelectionStore, detailsClassNames, detailsStyles, editorTheme, findDOMPointByTextOffset, getBlockElement, getBlockElementById, getDOMRectFromTextSelection, getDropTargetBlock, getNearestBlockByY, getTextOffsetFromDOMPoint, getVariantClass, gridClassNames, gridStyles, katexClassNames, katexStyles, noteTheme, noteVariant, registerNestedEditorSync, richContent, semanticClassNames, sharedStyles, useActiveEditor, useColorScheme, useEditorBlock, useEditorBlock as useVirtualizedBlock, useExtraNodes, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, useNestedContentRenderer, useNestedEditorPlugins, useNestedEditorSync, useOptionalNestedContentRenderer, useRendererConfig, useRendererMode, useTextSelectionSnapshot, useTextSelectionStore, useVariant, vars };
|