@haklex/rich-editor 0.57.0 → 0.59.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 +35 -0
- package/dist/{AlertQuoteEditNode-DQt5pIZ8.js → AlertQuoteEditNode-Ck4v29Wg.js} +9 -20
- package/dist/BlockIdPlugin-Cwv8aV9g.js +106 -0
- package/dist/{ColorSchemeContext-RLg0uDRt.js → ColorSchemeContext-Dc_HebHd.js} +5 -4
- package/dist/ContentEditable.css--lQ6ekTS.js +7 -0
- package/dist/EditorBlockContext-DytAx9Tg.js +9 -0
- package/dist/{ExtraNodesContext-DdU7MZwS.js → ExtraNodesContext-xQ2RNsqH.js} +1 -1
- package/dist/{MermaidPlugin-BpoGXa9D.js → MermaidPlugin-BCoGsdi3.js} +3 -3
- package/dist/NestedEditorPluginsContext-D78UZkmx.js +16 -0
- package/dist/{RubyRenderer-CnTFvt0b.js → RubyRenderer-8HMSMaZz.js} +1 -1
- package/dist/VirtualizationPlugin-C8TJ4HJN.js +178 -0
- package/dist/{SubmitShortcutPlugin-BuRxU6WD.js → VirtualizationPlugin-Crc0cLUx.js} +969 -532
- package/dist/VirtualizedEditor-CIGYcIfr.js +818 -0
- package/dist/command-registry-entry.d.ts +3 -0
- package/dist/command-registry-entry.d.ts.map +1 -0
- package/dist/command-registry-entry.mjs +343 -0
- package/dist/commands/registry.d.ts +24 -0
- package/dist/commands/registry.d.ts.map +1 -0
- package/dist/commands-entry.mjs +2 -2
- package/dist/components/EditorSurfaceHost.d.ts +3 -0
- package/dist/components/EditorSurfaceHost.d.ts.map +1 -0
- package/dist/components/RichEditor.d.ts.map +1 -1
- package/dist/components/RichEditorShell.d.ts +3 -1
- package/dist/components/RichEditorShell.d.ts.map +1 -1
- package/dist/components/VirtualizationFromProps.d.ts +6 -0
- package/dist/components/VirtualizationFromProps.d.ts.map +1 -0
- package/dist/components/decorators/GridEditDecorator.d.ts.map +1 -1
- package/dist/components/renderers/ImageRenderer.d.ts +1 -0
- package/dist/components/renderers/ImageRenderer.d.ts.map +1 -1
- package/dist/context/EditorBlockContext.d.ts +12 -0
- package/dist/context/EditorBlockContext.d.ts.map +1 -0
- package/dist/context/EditorSurfaceContext.d.ts +42 -0
- package/dist/context/EditorSurfaceContext.d.ts.map +1 -0
- package/dist/defineProperty-BYhxpJwd.js +39 -0
- package/dist/{grid.css-CUb_icKZ.js → grid.css-DJWKdYpz.js} +2 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +95 -43
- package/dist/{katex.css-9tq8FN8h.js → katex.css-9crOcnIa.js} +2 -1
- package/dist/{node-registry-CH2oHfO4.js → node-registry-jRE4LqH-.js} +37 -21
- package/dist/nodes/ImageNode.d.ts +7 -1
- package/dist/nodes/ImageNode.d.ts.map +1 -1
- package/dist/nodes/RichQuoteNode.d.ts +4 -1
- package/dist/nodes/RichQuoteNode.d.ts.map +1 -1
- package/dist/nodes-entry.mjs +4 -4
- package/dist/plugins/FileUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/ImageDialog.d.ts +13 -0
- package/dist/plugins/ImageDialog.d.ts.map +1 -0
- package/dist/plugins/ImageDialogReview.d.ts +13 -0
- package/dist/plugins/ImageDialogReview.d.ts.map +1 -0
- package/dist/plugins/ImageDialogSource.d.ts +12 -0
- package/dist/plugins/ImageDialogSource.d.ts.map +1 -0
- package/dist/plugins/ImagePlugin.d.ts.map +1 -1
- package/dist/plugins/ImageUploadPlugin.d.ts +1 -1
- package/dist/plugins/ImageUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/VideoUploadPlugin.d.ts +1 -1
- package/dist/plugins/VideoUploadPlugin.d.ts.map +1 -1
- package/dist/plugins/VirtualizationPlugin.d.ts +2 -0
- package/dist/plugins/VirtualizationPlugin.d.ts.map +1 -0
- package/dist/plugins/image-dialog-model.d.ts +65 -0
- package/dist/plugins/image-dialog-model.d.ts.map +1 -0
- package/dist/plugins/image-dialog.css.d.ts +30 -0
- package/dist/plugins/image-dialog.css.d.ts.map +1 -0
- package/dist/plugins/image-upload-toast.d.ts +2 -0
- package/dist/plugins/image-upload-toast.d.ts.map +1 -0
- package/dist/plugins/image-upload.css.d.ts +0 -23
- package/dist/plugins/image-upload.css.d.ts.map +1 -1
- package/dist/plugins/insertion-cursor.d.ts +20 -0
- package/dist/plugins/insertion-cursor.d.ts.map +1 -0
- package/dist/plugins/present-image-dialog.d.ts +14 -0
- package/dist/plugins/present-image-dialog.d.ts.map +1 -0
- package/dist/plugins-entry.d.ts +5 -0
- package/dist/plugins-entry.d.ts.map +1 -1
- package/dist/plugins-entry.mjs +7 -5
- package/dist/recycler-entry.d.ts +8 -0
- package/dist/recycler-entry.d.ts.map +1 -0
- package/dist/recycler-entry.mjs +3 -0
- package/dist/renderers-entry.mjs +4 -4
- package/dist/rich-editor.css +1 -1
- package/dist/static-entry.d.ts +1 -0
- package/dist/static-entry.d.ts.map +1 -1
- package/dist/static-entry.mjs +10 -9
- package/dist/styles/grid.css.d.ts.map +1 -1
- package/dist/styles/shared.css.d.ts.map +1 -1
- package/dist/styles-entry.mjs +3 -3
- package/dist/{theme-Blq1EG_t.js → theme-DH4xzxU-.js} +63 -48
- package/dist/{thumbhash-DHHqtr0c.js → thumbhash-GjK8OYAb.js} +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/{utils-CdxPji5z.js → utils-E6qVk-NR.js} +1 -0
- package/dist/viewport-BvO92tse.js +210 -0
- package/dist/virtualization/VirtualizationPlugin.d.ts +5 -0
- package/dist/virtualization/VirtualizationPlugin.d.ts.map +1 -0
- package/dist/virtualization/VirtualizedEditor.d.ts +6 -0
- package/dist/virtualization/VirtualizedEditor.d.ts.map +1 -0
- package/dist/virtualization/controller.d.ts +73 -0
- package/dist/virtualization/controller.d.ts.map +1 -0
- package/dist/virtualization/document.d.ts +26 -0
- package/dist/virtualization/document.d.ts.map +1 -0
- package/dist/virtualization/layout.d.ts +42 -0
- package/dist/virtualization/layout.d.ts.map +1 -0
- package/dist/virtualization/preserve.d.ts +21 -0
- package/dist/virtualization/preserve.d.ts.map +1 -0
- package/dist/virtualization/style.css.d.ts +4 -0
- package/dist/virtualization/style.css.d.ts.map +1 -0
- package/dist/virtualization/sync.d.ts +4 -0
- package/dist/virtualization/sync.d.ts.map +1 -0
- package/dist/virtualization/types.d.ts +13 -0
- package/dist/virtualization/types.d.ts.map +1 -0
- package/dist/virtualization/viewport.d.ts +3 -0
- package/dist/virtualization/viewport.d.ts.map +1 -0
- package/dist/virtualization-entry.d.ts +3 -0
- package/dist/virtualization-entry.d.ts.map +1 -0
- package/dist/virtualization-entry.mjs +1 -0
- package/package.json +17 -5
package/dist/static-entry.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { a as customNodes, i as builtinNodes, n as useColorScheme, r as allNodes, t as ColorSchemeProvider } from "./ColorSchemeContext-
|
|
5
|
-
import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-
|
|
1
|
+
import { J as NestedContentRendererProvider, K as extractTextContent, X as useOptionalNestedContentRenderer, Y as useNestedContentRenderer, a as getTagBgColor, t as editorTheme } from "./theme-DH4xzxU-.js";
|
|
2
|
+
import { C as MENTION_NODE_KEY, D as VIDEO_NODE_KEY, E as TAG_NODE_KEY, S as LINK_CARD_NODE_KEY, T as RUBY_NODE_KEY, a as useFootnoteContent, b as IMAGE_NODE_KEY, c as RendererWrapper, d as useRendererConfig, f as useRendererMode, g as CODE_BLOCK_NODE_KEY, h as BANNER_NODE_KEY, i as FootnoteDefinitionsProvider, l as createRendererDecoration, m as ALERT_NODE_KEY, o as useFootnoteDefinitions, p as useVariant, s as useFootnoteDisplayNumber, u as RendererConfigProvider, v as FOOTNOTE_NODE_KEY, w as MERMAID_NODE_KEY, x as KATEX_NODE_KEY, y as FOOTNOTE_SECTION_NODE_KEY } from "./thumbhash-GjK8OYAb.js";
|
|
3
|
+
import { a as chatVariant, c as semanticClassNames, i as commentVariant, l as sharedStyles, n as getVariantClass, o as articleVariant, r as noteVariant, s as richContent, t as clsx } from "./utils-E6qVk-NR.js";
|
|
4
|
+
import { a as customNodes, i as builtinNodes, n as useColorScheme, r as allNodes, t as ColorSchemeProvider } from "./ColorSchemeContext-Dc_HebHd.js";
|
|
5
|
+
import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-DJWKdYpz.js";
|
|
6
6
|
import { t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-VaI73T09.js";
|
|
7
|
-
import { n as useExtraNodes, r as LinkFavicon, t as ExtraNodesProvider } from "./ExtraNodesContext-
|
|
8
|
-
import { n as
|
|
9
|
-
import { t as
|
|
7
|
+
import { n as useExtraNodes, r as LinkFavicon, t as ExtraNodesProvider } from "./ExtraNodesContext-xQ2RNsqH.js";
|
|
8
|
+
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
9
|
+
import { n as katexStyles, t as katexClassNames } from "./katex.css-9crOcnIa.js";
|
|
10
|
+
import { t as RubyRenderer } from "./RubyRenderer-8HMSMaZz.js";
|
|
10
11
|
import { jsx } from "react/jsx-runtime";
|
|
11
12
|
import { articleTheme, chatTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
|
|
12
13
|
//#region src/components/renderers/TagRenderer.tsx
|
|
@@ -18,4 +19,4 @@ function TagRenderer({ text }) {
|
|
|
18
19
|
});
|
|
19
20
|
}
|
|
20
21
|
//#endregion
|
|
21
|
-
export { ALERT_NODE_KEY, BANNER_NODE_KEY, CODE_BLOCK_NODE_KEY, ColorSchemeProvider, ExtraNodesProvider, 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, NestedContentRendererProvider, RUBY_NODE_KEY, RendererConfigProvider, RendererWrapper, RubyRenderer, TAG_NODE_KEY, TagRenderer, VIDEO_NODE_KEY, allNodes, articleTheme, articleVariant, builtinNodes, chatTheme, chatVariant, commentTheme, commentVariant, createRendererDecoration, customNodes, detailsClassNames, detailsStyles, editorTheme, extractTextContent, getTagBgColor, getVariantClass, gridClassNames, gridStyles, katexClassNames, katexStyles, normalizeSerializedEditorState, noteTheme, noteVariant, richContent, semanticClassNames, sharedStyles, useColorScheme, useExtraNodes, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, useNestedContentRenderer, useOptionalNestedContentRenderer, useRendererConfig, useRendererMode, useVariant, vars };
|
|
22
|
+
export { ALERT_NODE_KEY, BANNER_NODE_KEY, CODE_BLOCK_NODE_KEY, ColorSchemeProvider, ExtraNodesProvider, 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, NestedContentRendererProvider, RUBY_NODE_KEY, RendererConfigProvider, RendererWrapper, RubyRenderer, TAG_NODE_KEY, TagRenderer, VIDEO_NODE_KEY, allNodes, articleTheme, articleVariant, builtinNodes, chatTheme, chatVariant, commentTheme, commentVariant, createRendererDecoration, customNodes, detailsClassNames, detailsStyles, editorTheme, extractTextContent, getTagBgColor, getVariantClass, gridClassNames, gridStyles, katexClassNames, katexStyles, normalizeSerializedEditorState, noteTheme, noteVariant, richContent, semanticClassNames, sharedStyles, useColorScheme, useEditorBlock, useEditorBlock as useVirtualizedBlock, useExtraNodes, useFootnoteContent, useFootnoteDefinitions, useFootnoteDisplayNumber, useNestedContentRenderer, useOptionalNestedContentRenderer, useRendererConfig, useRendererMode, useVariant, vars };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.css.d.ts","sourceRoot":"","sources":["../../src/styles/grid.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX,eAAO,MAAM,SAAS,QAGpB,CAAC;AAEH,eAAO,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"grid.css.d.ts","sourceRoot":"","sources":["../../src/styles/grid.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX,eAAO,MAAM,SAAS,QAGpB,CAAC;AAEH,eAAO,MAAM,OAAO,QAoBlB,CAAC;AAEH,eAAO,MAAM,WAAW,QAQtB,CAAC;AAEH,eAAO,MAAM,SAAS,QA2BpB,CAAC;AAEH,eAAO,MAAM,eAAe,QAI1B,CAAC;AAEH,eAAO,MAAM,cAAc,QAMzB,CAAC;AAEH,eAAO,MAAM,YAAY,QAuBvB,CAAC;AAEH,eAAO,MAAM,KAAK,QAGhB,CAAC;AAEH,eAAO,MAAM,IAAI,QAEf,CAAC;AAEH,eAAO,MAAM,YAAY,QAGvB,CAAC;AAOH,eAAO,MAAM,UAAU;;;;;;;;;;;CAWb,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.css.d.ts","sourceRoot":"","sources":["../../src/styles/shared.css.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDrB,CAAC;AA0BX,eAAO,MAAM,WAAW,QAStB,CAAC;AAEH,eAAO,MAAM,SAAS,QAIpB,CAAC;AAEH,eAAO,MAAM,QAAQ,QAEnB,CAAC;AAEH,eAAO,MAAM,UAAU,QAErB,CAAC;AAEH,eAAO,MAAM,aAAa,QAExB,CAAC;AAEH,eAAO,MAAM,iBAAiB,QAI5B,CAAC;AAIH,eAAO,MAAM,eAAe,QAM1B,CAAC;AAEH,eAAO,MAAM,aAAa,QAMxB,CAAC;AAEH,eAAO,MAAM,Q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AAyB,QAoBpC,CAAC;AAEH,eAAO,MAAM,UAAU,QAsBrB,CAAC;AAEH,eAAO,MAAM,aAAa,QAOxB,CAAC;AAEH,eAAO,MAAM,KAAK,QAKhB,CAAC;AAyPH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDkC,CAAC;AAE5D,MAAM,MAAM,cAAc,GAAG,MAAM,OAAO,YAAY,CAAC"}
|
package/dist/styles-entry.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as chatVariant, c as semanticClassNames, i as commentVariant, l as sharedStyles, n as getVariantClass, o as articleVariant, r as noteVariant, s as richContent } from "./utils-
|
|
2
|
-
import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-
|
|
3
|
-
import { n as katexStyles, t as katexClassNames } from "./katex.css-
|
|
1
|
+
import { a as chatVariant, c as semanticClassNames, i as commentVariant, l as sharedStyles, n as getVariantClass, o as articleVariant, r as noteVariant, s as richContent } from "./utils-E6qVk-NR.js";
|
|
2
|
+
import { i as detailsStyles, n as gridStyles, r as detailsClassNames, t as gridClassNames } from "./grid.css-DJWKdYpz.js";
|
|
3
|
+
import { n as katexStyles, t as katexClassNames } from "./katex.css-9crOcnIa.js";
|
|
4
4
|
import { articleTheme, chatTheme, commentTheme, noteTheme, vars } from "@haklex/rich-style-token/styles";
|
|
5
5
|
export { articleTheme, articleVariant, chatTheme, chatVariant, commentTheme, commentVariant, detailsClassNames, detailsStyles, getVariantClass, gridClassNames, gridStyles, katexClassNames, katexStyles, noteTheme, noteVariant, richContent, semanticClassNames, sharedStyles, vars };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { c as
|
|
2
|
-
import {
|
|
1
|
+
import { C as MENTION_NODE_KEY, b as IMAGE_NODE_KEY, c as RendererWrapper, l as createRendererDecoration, m as ALERT_NODE_KEY, n as decodeThumbHash, r as FootnoteStaticRenderer, v as FOOTNOTE_NODE_KEY, w as MERMAID_NODE_KEY, x as KATEX_NODE_KEY } from "./thumbhash-GjK8OYAb.js";
|
|
2
|
+
import { c as semanticClassNames, l as sharedStyles } from "./utils-E6qVk-NR.js";
|
|
3
|
+
import { t as _defineProperty } from "./defineProperty-BYhxpJwd.js";
|
|
3
4
|
import { createContext, createElement, use, useCallback, useEffect, useMemo, useState } from "react";
|
|
4
5
|
import { QuoteNode } from "@lexical/rich-text";
|
|
5
|
-
import { $getEditor, $getNodeByKey, $getSelection, $insertNodes, $isNodeSelection, $isRangeSelection, DecoratorNode, ElementNode, TextNode, createCommand, getRegisteredNode } from "lexical";
|
|
6
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { $getEditor, $getNodeByKey, $getSelection, $insertNodes, $isNodeSelection, $isRangeSelection, DecoratorNode, ElementNode, TextNode, createCommand, getRegisteredNode, isHTMLElement, setDOMUnmanaged } from "lexical";
|
|
7
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { $getTableCellNodeFromLexicalNode } from "@lexical/table";
|
|
8
9
|
import { ImageIcon, Info, Lightbulb, MessageSquareWarning, OctagonAlert, Sigma, Tag, TriangleAlert, Workflow } from "lucide-react";
|
|
9
10
|
//#region src/plugins/inline-dnd-shared.ts
|
|
@@ -56,7 +57,7 @@ var AlertRenderer = ({ type }) => {
|
|
|
56
57
|
//#region src/components/renderers/AlertStaticDecorator.tsx
|
|
57
58
|
function AlertStaticDecorator({ alertType, contentState }) {
|
|
58
59
|
const renderContent = useNestedContentRenderer();
|
|
59
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(RendererWrapper, {
|
|
60
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(RendererWrapper, {
|
|
60
61
|
defaultRenderer: AlertRenderer,
|
|
61
62
|
props: { type: alertType },
|
|
62
63
|
rendererKey: ALERT_NODE_KEY
|
|
@@ -77,44 +78,6 @@ function extractTextContent(state) {
|
|
|
77
78
|
return walk(state);
|
|
78
79
|
}
|
|
79
80
|
//#endregion
|
|
80
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/typeof.js
|
|
81
|
-
function _typeof(o) {
|
|
82
|
-
"@babel/helpers - typeof";
|
|
83
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
84
|
-
return typeof o;
|
|
85
|
-
} : function(o) {
|
|
86
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
87
|
-
}, _typeof(o);
|
|
88
|
-
}
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPrimitive.js
|
|
91
|
-
function toPrimitive(t, r) {
|
|
92
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
93
|
-
var e = t[Symbol.toPrimitive];
|
|
94
|
-
if (void 0 !== e) {
|
|
95
|
-
var i = e.call(t, r || "default");
|
|
96
|
-
if ("object" != _typeof(i)) return i;
|
|
97
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
98
|
-
}
|
|
99
|
-
return ("string" === r ? String : Number)(t);
|
|
100
|
-
}
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/toPropertyKey.js
|
|
103
|
-
function toPropertyKey(t) {
|
|
104
|
-
var i = toPrimitive(t, "string");
|
|
105
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
106
|
-
}
|
|
107
|
-
//#endregion
|
|
108
|
-
//#region \0@oxc-project+runtime@0.154.0/helpers/esm/defineProperty.js
|
|
109
|
-
function _defineProperty(e, r, t) {
|
|
110
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
111
|
-
value: t,
|
|
112
|
-
enumerable: !0,
|
|
113
|
-
configurable: !0,
|
|
114
|
-
writable: !0
|
|
115
|
-
}) : e[r] = t, e;
|
|
116
|
-
}
|
|
117
|
-
//#endregion
|
|
118
81
|
//#region src/nodes/AlertQuoteNode.ts
|
|
119
82
|
var ALERT_TYPES = [
|
|
120
83
|
"note",
|
|
@@ -595,6 +558,7 @@ var ImageNode = class ImageNode extends DecoratorNode {
|
|
|
595
558
|
_defineProperty(this, "__fixedHeight", void 0);
|
|
596
559
|
_defineProperty(this, "__fixedWidth", void 0);
|
|
597
560
|
_defineProperty(this, "__layout", void 0);
|
|
561
|
+
_defineProperty(this, "__autoOpenOnMount", false);
|
|
598
562
|
this.__src = sanitizeImageSrc(payload.src);
|
|
599
563
|
this.__altText = payload.altText;
|
|
600
564
|
this.__width = payload.width;
|
|
@@ -608,6 +572,10 @@ var ImageNode = class ImageNode extends DecoratorNode {
|
|
|
608
572
|
this.__fixedHeight = display.fixedHeight;
|
|
609
573
|
this.__layout = sanitizeImageLayout(payload.layout);
|
|
610
574
|
}
|
|
575
|
+
afterCloneFrom(prevNode) {
|
|
576
|
+
super.afterCloneFrom(prevNode);
|
|
577
|
+
this.__autoOpenOnMount = prevNode.__autoOpenOnMount;
|
|
578
|
+
}
|
|
611
579
|
createDOM(_config) {
|
|
612
580
|
const div = document.createElement("div");
|
|
613
581
|
div.className = "rich-image-wrapper";
|
|
@@ -752,6 +720,13 @@ var ImageNode = class ImageNode extends DecoratorNode {
|
|
|
752
720
|
getLayout() {
|
|
753
721
|
return this.__layout;
|
|
754
722
|
}
|
|
723
|
+
getShouldAutoOpenOnMount() {
|
|
724
|
+
return this.getLatest().__autoOpenOnMount;
|
|
725
|
+
}
|
|
726
|
+
setShouldAutoOpenOnMount(autoOpenOnMount) {
|
|
727
|
+
const writable = this.getWritable();
|
|
728
|
+
writable.__autoOpenOnMount = autoOpenOnMount;
|
|
729
|
+
}
|
|
755
730
|
decorate(_editor, _config) {
|
|
756
731
|
return createRendererDecoration(IMAGE_NODE_KEY, ImageRenderer, {
|
|
757
732
|
src: this.__src,
|
|
@@ -764,7 +739,8 @@ var ImageNode = class ImageNode extends DecoratorNode {
|
|
|
764
739
|
displayWidth: this.__displayWidth,
|
|
765
740
|
fixedWidth: this.__fixedWidth,
|
|
766
741
|
fixedHeight: this.__fixedHeight,
|
|
767
|
-
layout: this.__layout
|
|
742
|
+
layout: this.__layout,
|
|
743
|
+
...this.__autoOpenOnMount ? { autoOpenOnMount: true } : {}
|
|
768
744
|
});
|
|
769
745
|
}
|
|
770
746
|
};
|
|
@@ -786,12 +762,14 @@ _defineProperty(ImageNode, "commandItems", [{
|
|
|
786
762
|
$insertNodes([$createImageNode($withAdaptiveImageDisplayWidth({
|
|
787
763
|
src: "",
|
|
788
764
|
altText: ""
|
|
789
|
-
}))]);
|
|
765
|
+
}), { autoOpenOnMount: true })]);
|
|
790
766
|
});
|
|
791
767
|
}
|
|
792
768
|
}]);
|
|
793
|
-
function $createImageNode(payload) {
|
|
794
|
-
|
|
769
|
+
function $createImageNode(payload, options) {
|
|
770
|
+
const node = new ImageNode(payload);
|
|
771
|
+
if (options?.autoOpenOnMount) node.setShouldAutoOpenOnMount(true);
|
|
772
|
+
return node;
|
|
795
773
|
}
|
|
796
774
|
function $isImageNode(node) {
|
|
797
775
|
return node instanceof ImageNode;
|
|
@@ -1177,6 +1155,11 @@ function $isMermaidNode(node) {
|
|
|
1177
1155
|
}
|
|
1178
1156
|
//#endregion
|
|
1179
1157
|
//#region src/nodes/RichQuoteNode.ts
|
|
1158
|
+
var ATTRIBUTION_SLOT_ATTR = "data-quote-attribution-slot";
|
|
1159
|
+
function findAttributionSlot(element) {
|
|
1160
|
+
for (const child of element.children) if (child.hasAttribute(ATTRIBUTION_SLOT_ATTR)) return child;
|
|
1161
|
+
return null;
|
|
1162
|
+
}
|
|
1180
1163
|
function normalizeAttribution(value) {
|
|
1181
1164
|
if (value == null) return null;
|
|
1182
1165
|
return value.trim() || null;
|
|
@@ -1197,6 +1180,38 @@ var RichQuoteNode = class RichQuoteNode extends QuoteNode {
|
|
|
1197
1180
|
const serializedNode = _serializedNode;
|
|
1198
1181
|
return $createRichQuoteNode(serializedNode.attribution ?? null).updateFromJSON(serializedNode);
|
|
1199
1182
|
}
|
|
1183
|
+
createDOM(config) {
|
|
1184
|
+
const dom = super.createDOM(config);
|
|
1185
|
+
const slot = document.createElement("div");
|
|
1186
|
+
slot.setAttribute(ATTRIBUTION_SLOT_ATTR, "");
|
|
1187
|
+
slot.contentEditable = "false";
|
|
1188
|
+
setDOMUnmanaged(slot, { captureSelection: true });
|
|
1189
|
+
dom.append(slot);
|
|
1190
|
+
return dom;
|
|
1191
|
+
}
|
|
1192
|
+
getDOMSlot(element) {
|
|
1193
|
+
return super.getDOMSlot(element).withBefore(findAttributionSlot(element));
|
|
1194
|
+
}
|
|
1195
|
+
exportDOM(editor) {
|
|
1196
|
+
const output = super.exportDOM(editor);
|
|
1197
|
+
const { element } = output;
|
|
1198
|
+
if (!isHTMLElement(element)) return output;
|
|
1199
|
+
findAttributionSlot(element)?.remove();
|
|
1200
|
+
const attribution = this.getAttribution();
|
|
1201
|
+
if (!attribution) return output;
|
|
1202
|
+
return {
|
|
1203
|
+
...output,
|
|
1204
|
+
after: (generated) => {
|
|
1205
|
+
const target = output.after ? output.after(generated) : generated;
|
|
1206
|
+
if (isHTMLElement(target)) {
|
|
1207
|
+
const footer = document.createElement("footer");
|
|
1208
|
+
footer.textContent = `— ${attribution}`;
|
|
1209
|
+
target.append(footer);
|
|
1210
|
+
}
|
|
1211
|
+
return target;
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1200
1215
|
exportJSON() {
|
|
1201
1216
|
return {
|
|
1202
1217
|
...super.exportJSON(),
|
|
@@ -1433,4 +1448,4 @@ var editorTheme = {
|
|
|
1433
1448
|
hr: shared("hr")
|
|
1434
1449
|
};
|
|
1435
1450
|
//#endregion
|
|
1436
|
-
export {
|
|
1451
|
+
export { markInlineDraggable as $, computeImageDisplayPixels as A, FootnoteNode as B, KaTeXBlockNode as C, sanitizeImageLayout as D, ImageNode as E, imageDisplaySizeAfterResize as F, AlertQuoteNode as G, $isAlertQuoteNode as H, resolveImageDisplaySize as I, NestedContentRendererProvider as J, extractTextContent as K, sanitizeImageDisplayWidth as L, imageDisplayCssVars as M, imageDisplayDataAttr as N, $withAdaptiveImageDisplayWidth as O, imageDisplayFieldsFromSize as P, INLINE_DRAG_MIME as Q, sanitizeImageFixedPx as R, $isKaTeXBlockNode as S, $isImageNode as T, ALERT_LABELS as U, OPEN_FILE_PICKER_COMMAND as V, ALERT_TYPES as W, useOptionalNestedContentRenderer as X, useNestedContentRenderer as Y, INLINE_DRAG_ATTR as Z, MentionNode as _, getTagBgColor as a, KaTeXInlineNode as b, SpoilerNode as c, RichQuoteNode as d, $createMermaidNode as f, $isMentionNode as g, $createMentionNode as h, TagNode as i, convertImageDisplaySize as j, OPEN_IMAGE_UPLOAD_DIALOG_COMMAND as k, $createRichQuoteNode as l, MermaidNode as m, $createTagNode as n, $createSpoilerNode as o, $isMermaidNode as p, AlertRenderer as q, $isTagNode as r, $isSpoilerNode as s, editorTheme as t, $isRichQuoteNode as u, $createKaTeXInlineNode as v, $createImageNode as w, $createKaTeXBlockNode as x, $isKaTeXInlineNode as y, $createFootnoteNode as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as semanticClassNames, l as sharedStyles, t as clsx } from "./utils-
|
|
1
|
+
import { c as semanticClassNames, l as sharedStyles, t as clsx } from "./utils-E6qVk-NR.js";
|
|
2
2
|
import { createContext, createElement, use, useCallback, useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import { rgbaToThumbHash, thumbHashToDataURL } from "thumbhash";
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Klass, LexicalEditor, LexicalNode, SerializedEditorState } from 'lexica
|
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
import { ColorScheme } from './context/ColorSchemeContext';
|
|
4
4
|
import { RendererConfig } from './types/renderer-config';
|
|
5
|
+
import { EditorVirtualization } from './virtualization/types';
|
|
5
6
|
export type RichEditorVariant = 'article' | 'chat' | 'comment' | 'note';
|
|
6
7
|
export interface RichEditorProps {
|
|
7
8
|
actions?: ReactNode;
|
|
@@ -38,5 +39,7 @@ export interface RichEditorProps {
|
|
|
38
39
|
}) => Promise<{
|
|
39
40
|
src: string;
|
|
40
41
|
}>;
|
|
42
|
+
/** Experimental editor recycler. Disabled unless explicitly enabled or injected by a plugin. */
|
|
43
|
+
virtualization?: EditorVirtualization;
|
|
41
44
|
}
|
|
42
45
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,MAA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AC,EAAE,iBAAiB,CAAC;IAC5B,WAAW,CAAC,EAAE,CACZ,IAAI,EAAE,IAAI,EACV,IAAI,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;KAAE,KAC9C,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9B,gGAAgG;IAChG,cAAc,CAAC,EAAE,oBAAoB,CAAC;CACvC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { t as _defineProperty } from "./defineProperty-BYhxpJwd.js";
|
|
2
|
+
//#region src/virtualization/layout.ts
|
|
3
|
+
function collapsedMargin(a, b) {
|
|
4
|
+
return Math.max(0, a, b) + Math.min(0, a, b);
|
|
5
|
+
}
|
|
6
|
+
function occupiedHeight(current, next) {
|
|
7
|
+
return current.height + (current.gap ?? collapsedMargin(current.bottom, next?.top ?? 0));
|
|
8
|
+
}
|
|
9
|
+
var HeightIndex = class {
|
|
10
|
+
constructor(values) {
|
|
11
|
+
_defineProperty(this, "tree", void 0);
|
|
12
|
+
_defineProperty(this, "values", void 0);
|
|
13
|
+
this.values = [...values];
|
|
14
|
+
this.tree = new Float64Array(values.length + 1);
|
|
15
|
+
for (let i = 1; i <= values.length; i++) {
|
|
16
|
+
this.tree[i] += values[i - 1];
|
|
17
|
+
const parent = i + (i & -i);
|
|
18
|
+
if (parent < this.tree.length) this.tree[parent] += this.tree[i];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
offset(index) {
|
|
22
|
+
let sum = 0;
|
|
23
|
+
for (let i = index; i > 0; i -= i & -i) sum += this.tree[i];
|
|
24
|
+
return sum;
|
|
25
|
+
}
|
|
26
|
+
get total() {
|
|
27
|
+
return this.offset(this.values.length);
|
|
28
|
+
}
|
|
29
|
+
update(index, height) {
|
|
30
|
+
const delta = height - this.values[index];
|
|
31
|
+
this.values[index] = height;
|
|
32
|
+
for (let i = index + 1; i < this.tree.length; i += i & -i) this.tree[i] += delta;
|
|
33
|
+
}
|
|
34
|
+
find(offset) {
|
|
35
|
+
let index = 0;
|
|
36
|
+
let bit = 1;
|
|
37
|
+
while (bit * 2 < this.tree.length) bit *= 2;
|
|
38
|
+
for (; bit; bit >>= 1) {
|
|
39
|
+
const next = index + bit;
|
|
40
|
+
if (next < this.tree.length && this.tree[next] <= offset) {
|
|
41
|
+
index = next;
|
|
42
|
+
offset -= this.tree[next];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Math.min(index, Math.max(0, this.values.length - 1));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var TypePool = class {
|
|
49
|
+
constructor() {
|
|
50
|
+
_defineProperty(this, "slots", []);
|
|
51
|
+
_defineProperty(this, "created", 0);
|
|
52
|
+
_defineProperty(this, "reused", 0);
|
|
53
|
+
_defineProperty(this, "disposed", 0);
|
|
54
|
+
}
|
|
55
|
+
update(indices, typeOf, pinned = /* @__PURE__ */ new Set(), preserved = /* @__PURE__ */ new Set()) {
|
|
56
|
+
const wanted = new Set(indices);
|
|
57
|
+
let changed = false;
|
|
58
|
+
for (const slot of this.slots) if (slot.active && !wanted.has(slot.index) && !pinned.has(slot.id)) {
|
|
59
|
+
slot.beforeRelease?.();
|
|
60
|
+
slot.active = false;
|
|
61
|
+
changed = true;
|
|
62
|
+
}
|
|
63
|
+
const bound = new Set(this.slots.filter((slot) => slot.active).map((slot) => slot.index));
|
|
64
|
+
const idle = /* @__PURE__ */ new Map();
|
|
65
|
+
const owned = new Map(this.slots.filter((slot) => !slot.active && preserved.has(slot.id)).map((slot) => [slot.index, slot]));
|
|
66
|
+
for (const slot of this.slots) if (!slot.active && !preserved.has(slot.id)) {
|
|
67
|
+
const bucket = idle.get(slot.pool) ?? [];
|
|
68
|
+
bucket.push(slot);
|
|
69
|
+
idle.set(slot.pool, bucket);
|
|
70
|
+
}
|
|
71
|
+
for (const index of indices) {
|
|
72
|
+
if (bound.has(index)) continue;
|
|
73
|
+
const pool = typeOf(index);
|
|
74
|
+
let slot = owned.get(index) ?? idle.get(pool)?.pop();
|
|
75
|
+
if (!slot) {
|
|
76
|
+
slot = {
|
|
77
|
+
id: ++this.created,
|
|
78
|
+
index: -1,
|
|
79
|
+
pool,
|
|
80
|
+
active: false,
|
|
81
|
+
generation: 0,
|
|
82
|
+
committed: -1
|
|
83
|
+
};
|
|
84
|
+
this.slots.push(slot);
|
|
85
|
+
}
|
|
86
|
+
if (slot.index !== index) {
|
|
87
|
+
if (slot.index >= 0) this.reused++;
|
|
88
|
+
slot.index = index;
|
|
89
|
+
slot.generation++;
|
|
90
|
+
}
|
|
91
|
+
slot.active = true;
|
|
92
|
+
changed = true;
|
|
93
|
+
}
|
|
94
|
+
const parked = this.slots.filter((slot) => !slot.active && preserved.has(slot.id)).length;
|
|
95
|
+
let excess = this.slots.length - Math.max(16, indices.length * 2 + pinned.size) - parked;
|
|
96
|
+
if (excess > 0) {
|
|
97
|
+
this.slots = this.slots.filter((slot) => {
|
|
98
|
+
if (!slot.active && !preserved.has(slot.id) && excess-- > 0) {
|
|
99
|
+
this.disposed++;
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
});
|
|
104
|
+
changed = true;
|
|
105
|
+
}
|
|
106
|
+
return changed;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
var weights = /* @__PURE__ */ new WeakMap();
|
|
110
|
+
function textUnits(node) {
|
|
111
|
+
const cached = weights.get(node);
|
|
112
|
+
if (cached !== void 0) return cached;
|
|
113
|
+
const value = typeof node.text === "string" ? node.text.replaceAll(/[\u0080-\uFFFF]/g, "xx").length : (node.children ?? []).reduce((sum, child) => sum + textUnits(child), 0);
|
|
114
|
+
weights.set(node, value);
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
function estimateHeight(node, width, state, path = "0") {
|
|
118
|
+
const children = () => (node.children ?? []).reduce((sum, child, i) => sum + estimateHeight(child, width - (node.type === "details" ? 40 : 0), state, `${path}.${i}`), 0);
|
|
119
|
+
switch (node.type) {
|
|
120
|
+
case "paragraph": return Math.max(1, Math.ceil(textUnits(node) * 8 / Math.max(80, width))) * 28 + 16;
|
|
121
|
+
case "image": return node.width && node.height ? Math.min(width, node.width) * node.height / node.width + 64 : 220;
|
|
122
|
+
case "details": return 64 + (state?.details[path] ?? node.open ? children() + 32 : 0);
|
|
123
|
+
case "dynamic": return (node.initialHeight ?? 320) + 40;
|
|
124
|
+
case "table": return (node.children ?? []).reduce((sum, row) => sum + Math.max(48, ...(row.children ?? []).map((cell) => estimateHeight(cell, width / Math.max(1, row.children?.length ?? 1), state))) + 20, 0) + 32;
|
|
125
|
+
case "code": return 280;
|
|
126
|
+
default: return Math.max(24, children() + 16);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
//#region src/virtualization/preserve.ts
|
|
131
|
+
/** Owns parked mounts. Eviction hands their latest state back to the recycler. */
|
|
132
|
+
var PreserveNodeManager = class {
|
|
133
|
+
constructor(capacity, evict) {
|
|
134
|
+
_defineProperty(this, "capacity", void 0);
|
|
135
|
+
_defineProperty(this, "evict", void 0);
|
|
136
|
+
_defineProperty(this, "parked", /* @__PURE__ */ new Map());
|
|
137
|
+
_defineProperty(this, "hosts", /* @__PURE__ */ new Map());
|
|
138
|
+
_defineProperty(this, "parking", void 0);
|
|
139
|
+
_defineProperty(this, "hits", 0);
|
|
140
|
+
_defineProperty(this, "evictions", 0);
|
|
141
|
+
this.capacity = capacity;
|
|
142
|
+
this.evict = evict;
|
|
143
|
+
if (!Number.isInteger(capacity) || capacity < 0) throw new Error("preserveCapacity must be a nonnegative integer");
|
|
144
|
+
}
|
|
145
|
+
get size() {
|
|
146
|
+
return this.parked.size;
|
|
147
|
+
}
|
|
148
|
+
has(slot) {
|
|
149
|
+
return this.parked.has(slot);
|
|
150
|
+
}
|
|
151
|
+
ids() {
|
|
152
|
+
return new Set(this.parked.keys());
|
|
153
|
+
}
|
|
154
|
+
park(slot, owner) {
|
|
155
|
+
this.parked.delete(slot);
|
|
156
|
+
this.parked.set(slot, owner);
|
|
157
|
+
while (this.parked.size > this.capacity) {
|
|
158
|
+
const [oldest, key] = this.parked.entries().next().value;
|
|
159
|
+
this.parked.delete(oldest);
|
|
160
|
+
this.evict(oldest, key);
|
|
161
|
+
this.evictions++;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
activate(slot) {
|
|
165
|
+
if (!this.parked.delete(slot)) return false;
|
|
166
|
+
this.hits++;
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
host(slot) {
|
|
170
|
+
return this.hosts.get(slot);
|
|
171
|
+
}
|
|
172
|
+
mount(slot, host, parent, before = null) {
|
|
173
|
+
this.hosts.set(slot, host);
|
|
174
|
+
if (parent) {
|
|
175
|
+
if (host.parentNode !== parent || host.nextSibling !== before) parent.insertBefore(host, before);
|
|
176
|
+
} else {
|
|
177
|
+
this.parking ?? (this.parking = host.ownerDocument.createDocumentFragment());
|
|
178
|
+
if (host.parentNode !== this.parking) this.parking.append(host);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
forget(slot) {
|
|
182
|
+
this.parked.delete(slot);
|
|
183
|
+
this.hosts.get(slot)?.remove();
|
|
184
|
+
this.hosts.delete(slot);
|
|
185
|
+
}
|
|
186
|
+
clear() {
|
|
187
|
+
for (const host of this.hosts.values()) host.remove();
|
|
188
|
+
this.hosts.clear();
|
|
189
|
+
this.parked.clear();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/virtualization/style.css.ts
|
|
194
|
+
var canvas = "qi8t60";
|
|
195
|
+
var slot = "qi8t61";
|
|
196
|
+
var editable = "qi8t62";
|
|
197
|
+
//#endregion
|
|
198
|
+
//#region src/virtualization/viewport.ts
|
|
199
|
+
function resolveScrollContainer(canvas, configured) {
|
|
200
|
+
const element = typeof configured === "function" ? configured() : configured && "current" in configured ? configured.current : configured;
|
|
201
|
+
if (configured) {
|
|
202
|
+
if (!element) throw new Error("Virtual scrollContainer is not mounted");
|
|
203
|
+
if (!element.contains(canvas)) throw new Error("Virtual scrollContainer must contain the content");
|
|
204
|
+
return element;
|
|
205
|
+
}
|
|
206
|
+
for (let parent = canvas.parentElement; parent; parent = parent.parentElement) if (/auto|scroll/.test(getComputedStyle(parent).overflowY)) return parent;
|
|
207
|
+
return window;
|
|
208
|
+
}
|
|
209
|
+
//#endregion
|
|
210
|
+
export { PreserveNodeManager as a, collapsedMargin as c, slot as i, estimateHeight as l, canvas as n, HeightIndex as o, editable as r, TypePool as s, resolveScrollContainer as t, occupiedHeight as u };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EditorVirtualizationOptions } from './types';
|
|
2
|
+
export declare function VirtualizationPlugin({ scrollContainer, overscan, estimateBlockHeight, preserveCapacity, priority, }: EditorVirtualizationOptions & {
|
|
3
|
+
priority?: number;
|
|
4
|
+
}): import('react').JSX.Element;
|
|
5
|
+
//# sourceMappingURL=VirtualizationPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualizationPlugin.d.ts","sourceRoot":"","sources":["../../src/virtualization/VirtualizationPlugin.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAM3D,wBAAgB,oBAAoB,CAAC,EACnC,eAAe,EACf,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,QAAY,GACb,EAAE,2BAA2B,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,+BAYrD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EditorSurfaceProps } from '../context/EditorSurfaceContext';
|
|
2
|
+
import { EditorVirtualizationOptions } from './types';
|
|
3
|
+
export declare function VirtualizedEditor({ options, className, plugins, autoFocus, hasHeader, onActiveEditorChange, retainSurface, placeholder, }: EditorSurfaceProps & {
|
|
4
|
+
options: EditorVirtualizationOptions;
|
|
5
|
+
}): import('react').JSX.Element;
|
|
6
|
+
//# sourceMappingURL=VirtualizedEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VirtualizedEditor.d.ts","sourceRoot":"","sources":["../../src/virtualization/VirtualizedEditor.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAK1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AA+O3D,wBAAgB,iBAAiB,CAAC,EAChC,OAAO,EACP,SAAS,EACT,OAAO,EACP,SAAS,EACT,SAAS,EACT,oBAAoB,EACpB,aAAa,EACb,WAAW,GACZ,EAAE,kBAAkB,GAAG;IAAE,OAAO,EAAE,2BAA2B,CAAA;CAAE,+BAoE/D"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { LexicalEditor, NodeKey } from 'lexical';
|
|
2
|
+
import { VirtualDocument } from './document';
|
|
3
|
+
import { HeightIndex, Slot, TypePool } from './layout';
|
|
4
|
+
import { PreserveNodeManager } from './preserve';
|
|
5
|
+
import { EditorVirtualizationOptions } from './types';
|
|
6
|
+
export interface Island {
|
|
7
|
+
data: string;
|
|
8
|
+
editor: LexicalEditor;
|
|
9
|
+
generation: number;
|
|
10
|
+
ids: string[];
|
|
11
|
+
loading: boolean;
|
|
12
|
+
retained: number;
|
|
13
|
+
source: boolean;
|
|
14
|
+
unsubscribe: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare class EditorRecycler {
|
|
17
|
+
readonly master: LexicalEditor;
|
|
18
|
+
readonly canvas: HTMLElement;
|
|
19
|
+
readonly options: EditorVirtualizationOptions;
|
|
20
|
+
readonly document: VirtualDocument;
|
|
21
|
+
readonly pool: TypePool;
|
|
22
|
+
readonly islands: Map<number, Island>;
|
|
23
|
+
readonly states: Map<string, Map<string, unknown>>;
|
|
24
|
+
readonly viewport: HTMLElement | Window;
|
|
25
|
+
readonly preserve: PreserveNodeManager;
|
|
26
|
+
heights: HeightIndex;
|
|
27
|
+
revision: number;
|
|
28
|
+
private indices;
|
|
29
|
+
private listeners;
|
|
30
|
+
private observer;
|
|
31
|
+
private frame;
|
|
32
|
+
private dead;
|
|
33
|
+
private width;
|
|
34
|
+
private metrics;
|
|
35
|
+
private firstParagraph;
|
|
36
|
+
constructor(master: LexicalEditor, canvas: HTMLElement, options: EditorVirtualizationOptions);
|
|
37
|
+
private previousRows;
|
|
38
|
+
get rows(): import('./document').DocumentRow[];
|
|
39
|
+
get scrollTop(): number;
|
|
40
|
+
private setScrollTop;
|
|
41
|
+
private viewportTop;
|
|
42
|
+
private viewportHeight;
|
|
43
|
+
private canvasTop;
|
|
44
|
+
private buildHeights;
|
|
45
|
+
private estimate;
|
|
46
|
+
private reconcileDocument;
|
|
47
|
+
subscribe(listener: () => void): () => void;
|
|
48
|
+
private publish;
|
|
49
|
+
private onScroll;
|
|
50
|
+
refresh(sync?: boolean): void;
|
|
51
|
+
island(slot: Slot): Island;
|
|
52
|
+
bind(slot: Slot): void;
|
|
53
|
+
attach(slot: Slot, element: HTMLElement | null): void;
|
|
54
|
+
mount(slot: Slot, host: HTMLElement): void;
|
|
55
|
+
state(id: string): Map<string, unknown>;
|
|
56
|
+
nodeState(slot: Slot, key: NodeKey | undefined, expectedId: string): Map<string, unknown>;
|
|
57
|
+
capturePanels(slot: Slot): void;
|
|
58
|
+
restorePanels(slot: Slot): void;
|
|
59
|
+
private panels;
|
|
60
|
+
private anchor;
|
|
61
|
+
private restore;
|
|
62
|
+
private queueMeasure;
|
|
63
|
+
slotOffset(slot: Slot): number;
|
|
64
|
+
private get leadingMargin();
|
|
65
|
+
blockOffset(index: number): number;
|
|
66
|
+
commitLayout(): void;
|
|
67
|
+
private measure;
|
|
68
|
+
scrollTo(index: number): void;
|
|
69
|
+
focusBlock(index: number, end?: boolean, scroll?: boolean): void;
|
|
70
|
+
joinNeighbor(slot: Slot, backward: boolean): boolean;
|
|
71
|
+
dispose(): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/virtualization/controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,aAAa,EAElB,KAAK,OAAO,EAGb,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAwB,eAAe,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAGL,WAAW,EAEX,KAAK,IAAI,EACT,QAAQ,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAG3D,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,qBAAa,cAAc;IAmBvB,QAAQ,CAAC,MAAM,EAAE,aAAa;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW;IAC5B,QAAQ,CAAC,OAAO,EAAE,2BAA2B;IApB/C,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,QAAQ,CAAC,IAAI,WAAkB;IAC/B,QAAQ,CAAC,OAAO,sBAA6B;IAC7C,QAAQ,CAAC,MAAM,oCAA2C;IAC1D,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAAC;IACxC,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAC;IACvC,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,SAAK;IACb,OAAO,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,UAAU,CAAC,IAAI,EAAE,IAAI;IAGrB,OAAO,KAAK,aAAa,GAExB;IACD,WAAW,CAAC,KAAK,EAAE,MAAM;IAGzB,YAAY;IAIZ,OAAO,CAAC,OAAO;IAqFf,QAAQ,CAAC,KAAK,EAAE,MAAM;IAMtB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAQ,EAAE,MAAM,UAAO;IAiBpD,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO;IAwB1C,OAAO;CAWR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LexicalEditor, LexicalNode, SerializedLexicalNode } from 'lexical';
|
|
2
|
+
export interface SerializedBlock extends SerializedLexicalNode {
|
|
3
|
+
$?: Record<string, any>;
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
children?: SerializedBlock[];
|
|
6
|
+
}
|
|
7
|
+
export interface DocumentRow {
|
|
8
|
+
data: SerializedBlock;
|
|
9
|
+
id: string;
|
|
10
|
+
key: string;
|
|
11
|
+
node: LexicalNode;
|
|
12
|
+
pool: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function $serializeBlock(node: LexicalNode): SerializedBlock;
|
|
15
|
+
export declare class VirtualDocument {
|
|
16
|
+
readonly editor: LexicalEditor;
|
|
17
|
+
rows: DocumentRow[];
|
|
18
|
+
onChange?: (source?: string) => void;
|
|
19
|
+
private unsubscribe;
|
|
20
|
+
private lastEdit?;
|
|
21
|
+
constructor(editor: LexicalEditor);
|
|
22
|
+
private read;
|
|
23
|
+
replace(ids: string[], children: SerializedBlock[], source: string): void;
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/virtualization/document.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC3B,MAAM,SAAS,CAAC;AAIjB,MAAM,WAAW,eAAgB,SAAQ,qBAAqB;IAC5D,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IACnB,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;CAC9B;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe,CAQlE;AAED,qBAAa,eAAe;IAMd,QAAQ,CAAC,MAAM,EAAE,aAAa;IAL1C,IAAI,EAAE,WAAW,EAAE,CAAM;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,QAAQ,CAAC,CAA+D;gBAE3D,MAAM,EAAE,aAAa;IAW1C,OAAO,CAAC,IAAI;IAqBZ,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM;IAiClE,OAAO;CAGR"}
|