@haklex/rich-editor 0.62.2 → 0.63.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/{VirtualizationPlugin-BA7YFDRN.js → VirtualizationPlugin-C7QlGX4x.js} +25 -4
- package/dist/{VirtualizationPlugin-CUMZnpuL.js → VirtualizationPlugin-fTFySAeb.js} +10 -4
- package/dist/context/EditorSurfaceContext.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/plugins/FootnotePlugin.d.ts.map +1 -1
- package/dist/plugins-entry.mjs +2 -2
- package/dist/virtualization-entry.mjs +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LexicalComposerContext, useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
|
-
import { Fragment, Suspense, createContext, lazy, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { Fragment, Suspense, createContext, lazy, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW } from "lexical";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region src/context/EditorSurfaceContext.tsx
|
|
@@ -116,13 +116,34 @@ function EditorSurfacePlugin({ surface, priority = 0 }) {
|
|
|
116
116
|
function EditorSurfacePlugins({ children }) {
|
|
117
117
|
const key = useId();
|
|
118
118
|
const { registerPlugins } = useEditorSurface();
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
const [slot] = useState(() => createPluginSlot(children));
|
|
120
|
+
useLayoutEffect(() => registerPlugins(key, /* @__PURE__ */ jsx(PluginSlotOutlet, { slot })), [
|
|
121
121
|
key,
|
|
122
|
-
registerPlugins
|
|
122
|
+
registerPlugins,
|
|
123
|
+
slot
|
|
123
124
|
]);
|
|
125
|
+
useLayoutEffect(() => slot.set(children), [children, slot]);
|
|
124
126
|
return null;
|
|
125
127
|
}
|
|
128
|
+
function createPluginSlot(initial) {
|
|
129
|
+
let current = initial;
|
|
130
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
131
|
+
return {
|
|
132
|
+
get: () => current,
|
|
133
|
+
set: (children) => {
|
|
134
|
+
if (children === current) return;
|
|
135
|
+
current = children;
|
|
136
|
+
listeners.forEach((listener) => listener());
|
|
137
|
+
},
|
|
138
|
+
subscribe: (listener) => {
|
|
139
|
+
listeners.add(listener);
|
|
140
|
+
return () => listeners.delete(listener);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function PluginSlotOutlet({ slot }) {
|
|
145
|
+
return useSyncExternalStore(slot.subscribe, slot.get, slot.get);
|
|
146
|
+
}
|
|
126
147
|
function useActiveEditor() {
|
|
127
148
|
return useEditorSurface().activeEditor;
|
|
128
149
|
}
|
|
@@ -5,7 +5,7 @@ import { i as FootnoteDefinitionsProvider, t as computeImageMeta } from "./thumb
|
|
|
5
5
|
import { C as fileExtFromName, D as $createCommentPlaceholderNode, E as $createCommentNode, F as BannerNode, T as DetailsNode, _ as $createFootnoteSectionNode, b as $createFileNode, c as $createRubyNode, h as $isGridContainerNode, j as CodeBlockNode, k as CommentNode, o as $createVideoNode, u as RubyNode, v as $isFootnoteSectionNode, w as $createDetailsNode, x as $isFileNode, y as FootnoteSectionNode } from "./ColorSchemeContext-Dc_HebHd.js";
|
|
6
6
|
import { c as PasteLinkPlugin, t as $createAlertQuoteEditNode } from "./AlertQuoteEditNode-Ck4v29Wg.js";
|
|
7
7
|
import { n as getHostname, r as probeFavicon, t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-VaI73T09.js";
|
|
8
|
-
import "./VirtualizationPlugin-
|
|
8
|
+
import "./VirtualizationPlugin-C7QlGX4x.js";
|
|
9
9
|
import { n as blockIdState } from "./BlockIdPlugin-Cwv8aV9g.js";
|
|
10
10
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
11
11
|
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
@@ -3065,6 +3065,12 @@ function EditorRefPlugin({ onEditorReady }) {
|
|
|
3065
3065
|
}
|
|
3066
3066
|
//#endregion
|
|
3067
3067
|
//#region src/plugins/FootnotePlugin.tsx
|
|
3068
|
+
function isSameRecord(a, b) {
|
|
3069
|
+
if (a === b) return true;
|
|
3070
|
+
const aKeys = Object.keys(a);
|
|
3071
|
+
if (aKeys.length !== Object.keys(b).length) return false;
|
|
3072
|
+
return aKeys.every((key) => key in b && a[key] === b[key]);
|
|
3073
|
+
}
|
|
3068
3074
|
function FootnotePlugin({ children }) {
|
|
3069
3075
|
const [editor] = useLexicalComposerContext();
|
|
3070
3076
|
const [definitions, setDefinitions] = useState({});
|
|
@@ -3084,10 +3090,10 @@ function FootnotePlugin({ children }) {
|
|
|
3084
3090
|
numberMap[id] = counter++;
|
|
3085
3091
|
}
|
|
3086
3092
|
}
|
|
3087
|
-
setDisplayNumberMap(numberMap);
|
|
3093
|
+
setDisplayNumberMap((prev) => isSameRecord(prev, numberMap) ? prev : numberMap);
|
|
3088
3094
|
const sectionNodes = $nodesOfType(FootnoteSectionNode);
|
|
3089
|
-
|
|
3090
|
-
|
|
3095
|
+
const nextDefinitions = sectionNodes.length > 0 ? sectionNodes[0].getDefinitions() : {};
|
|
3096
|
+
setDefinitions((prev) => isSameRecord(prev, nextDefinitions) ? prev : nextDefinitions);
|
|
3091
3097
|
if (!editor.isEditable() || pendingUpdateRef.current) return;
|
|
3092
3098
|
if (footnoteNodes.length === 0 && sectionNodes.length > 0) {
|
|
3093
3099
|
pendingUpdateRef.current = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSurfaceContext.d.ts","sourceRoot":"","sources":["../../src/context/EditorSurfaceContext.tsx"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,SAAS,CAAC;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SAAS,CAAA;CAAE,+BA2F1E;AACD,wBAAgB,gBAAgB,mBAI/B;AACD,iFAAiF;AACjF,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,QAAY,GACb,EAAE;IACD,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,QAQA;AACD,iFAAiF;AACjF,wBAAgB,oBAAoB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,QAUzE;AAyBD,wBAAgB,eAAe,yBAE9B;AACD,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAQtE"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as VideoUploadProvider, C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, H as ImageUploadProvider, J as CorePlugins, K as FileUploadProvider, L as FileUploadPlugin, O as defaultImageUpload, S as TextSelectionStoreProvider, T as useTextSelectionStore, W as ImagePreprocessProvider, _ 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, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, 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-
|
|
1
|
+
import { B as VideoUploadProvider, C as createTextSelectionStore, D as ImageUploadPlugin, E as LinkFaviconPlugin, H as ImageUploadProvider, J as CorePlugins, K as FileUploadProvider, L as FileUploadPlugin, O as defaultImageUpload, S as TextSelectionStoreProvider, T as useTextSelectionStore, W as ImagePreprocessProvider, _ 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, l as $captureTextSelectionFromRangeSelection, m as getDOMRectFromTextSelection, n as SubmitShortcutPlugin, o as VideoUploadPlugin, p as getBlockElementById, 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-fTFySAeb.js";
|
|
2
2
|
import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-8OWu2S8i.js";
|
|
3
3
|
import { J as NestedContentRendererProvider, X as useOptionalNestedContentRenderer, Y as useNestedContentRenderer, t as editorTheme } from "./theme-DH4xzxU-.js";
|
|
4
4
|
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, _ as FILE_NODE_KEY, a as useFootnoteContent, b as IMAGE_NODE_KEY, d as useRendererConfig, f as useRendererMode, g as CODE_BLOCK_NODE_KEY, h as BANNER_NODE_KEY, i as FootnoteDefinitionsProvider, 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";
|
|
@@ -9,7 +9,7 @@ import { n as useNestedEditorPlugins, t as NestedEditorPluginsProvider } from ".
|
|
|
9
9
|
import { a as useNestedEditorSync, i as createNestedEditor, o as registerNestedEditorSync, r as NESTED_EDITOR_NODES, s as NestedEditorCorePlugins } from "./AlertQuoteEditNode-Ck4v29Wg.js";
|
|
10
10
|
import { t as normalizeSerializedEditorState } from "./normalizeSerializedEditorState-VaI73T09.js";
|
|
11
11
|
import { n as useExtraNodes, r as LinkFavicon, t as ExtraNodesProvider } from "./ExtraNodesContext-xQ2RNsqH.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-
|
|
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-C7QlGX4x.js";
|
|
13
13
|
import { a as KaTeXPlugin, c as AlertPlugin, n as MermaidPlugin, s as ImagePlugin } from "./MermaidPlugin-BCoGsdi3.js";
|
|
14
14
|
import { n as blockIdState, t as BlockIdPlugin } from "./BlockIdPlugin-Cwv8aV9g.js";
|
|
15
15
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FootnotePlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/FootnotePlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FootnotePlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/FootnotePlugin.tsx"],"names":[],"mappings":"AAeA,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,+BA0F1E"}
|
package/dist/plugins-entry.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as HorizontalRulePlugin, A as presentImageDialog, B as VideoUploadProvider, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as registerImageEditor, G as useImagePreprocess, H as ImageUploadProvider, I as resolvePreprocessTargets, J as CorePlugins, K as FileUploadProvider, L as FileUploadPlugin, M as getImageEditor, N as keepsOriginal, O as defaultImageUpload, P as markKeepOriginal, Q as InlineDndPlugin, R as setFileUploadEntry, U as useImageUpload, V as useVideoUpload, W as ImagePreprocessProvider, X as MarkdownPastePlugin, Y as MarkdownShortcutsPlugin, Z as ALL_TRANSFORMERS, a as EditorRefPlugin, et as ClickBelowPlugin, i as FootnotePlugin, j as ImageDialog, k as uploadImageFile, n as SubmitShortcutPlugin, nt as BlockExitPlugin, o as VideoUploadPlugin, q as useFileUpload, r as OnChangePlugin, rt as AutoLinkPlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, tt as registerClickBelowCommand, z as useFileUploadEntry } from "./VirtualizationPlugin-
|
|
1
|
+
import { $ as HorizontalRulePlugin, A as presentImageDialog, B as VideoUploadProvider, D as ImageUploadPlugin, E as LinkFaviconPlugin, F as registerImageEditor, G as useImagePreprocess, H as ImageUploadProvider, I as resolvePreprocessTargets, J as CorePlugins, K as FileUploadProvider, L as FileUploadPlugin, M as getImageEditor, N as keepsOriginal, O as defaultImageUpload, P as markKeepOriginal, Q as InlineDndPlugin, R as setFileUploadEntry, U as useImageUpload, V as useVideoUpload, W as ImagePreprocessProvider, X as MarkdownPastePlugin, Y as MarkdownShortcutsPlugin, Z as ALL_TRANSFORMERS, a as EditorRefPlugin, et as ClickBelowPlugin, i as FootnotePlugin, j as ImageDialog, k as uploadImageFile, n as SubmitShortcutPlugin, nt as BlockExitPlugin, o as VideoUploadPlugin, q as useFileUpload, r as OnChangePlugin, rt as AutoLinkPlugin, s as TextSelectionPlugin, t as AutoFocusPlugin, tt as registerClickBelowCommand, z as useFileUploadEntry } from "./VirtualizationPlugin-fTFySAeb.js";
|
|
2
2
|
import { $ as markInlineDraggable, Z as INLINE_DRAG_ATTR } from "./theme-DH4xzxU-.js";
|
|
3
3
|
import { c as PasteLinkPlugin } from "./AlertQuoteEditNode-Ck4v29Wg.js";
|
|
4
|
-
import { i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, t as VirtualizationPlugin } from "./VirtualizationPlugin-
|
|
4
|
+
import { i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, t as VirtualizationPlugin } from "./VirtualizationPlugin-C7QlGX4x.js";
|
|
5
5
|
import { a as KaTeXPlugin, c as AlertPlugin, n as MermaidPlugin, s as ImagePlugin } from "./MermaidPlugin-BCoGsdi3.js";
|
|
6
6
|
import { n as blockIdState, t as BlockIdPlugin } from "./BlockIdPlugin-Cwv8aV9g.js";
|
|
7
7
|
export { ALL_TRANSFORMERS, ActiveEditorScope, AlertPlugin, AutoFocusPlugin, AutoLinkPlugin, BlockExitPlugin, BlockIdPlugin, ClickBelowPlugin, CorePlugins, EditorRefPlugin, EditorSurfacePlugin, EditorSurfacePlugins, FileUploadPlugin, FileUploadProvider, FootnotePlugin, HorizontalRulePlugin, INLINE_DRAG_ATTR, ImageDialog, ImagePlugin, ImagePreprocessProvider, ImageUploadPlugin, ImageUploadProvider, InlineDndPlugin, KaTeXPlugin, LinkFaviconPlugin, MarkdownPastePlugin, MarkdownShortcutsPlugin, MermaidPlugin, OnChangePlugin, PasteLinkPlugin, SubmitShortcutPlugin, TextSelectionPlugin, VideoUploadPlugin, VideoUploadProvider, VirtualizationPlugin, blockIdState, defaultImageUpload, getImageEditor, keepsOriginal, markInlineDraggable, markKeepOriginal, presentImageDialog, registerClickBelowCommand, registerImageEditor, resolvePreprocessTargets, setFileUploadEntry, uploadImageFile, useActiveEditor, useFileUpload, useFileUploadEntry, useImagePreprocess, useImageUpload, useVideoUpload };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as VirtualizationPlugin } from "./VirtualizationPlugin-
|
|
1
|
+
export { t as VirtualizationPlugin } from "./VirtualizationPlugin-C7QlGX4x.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"description": "Core rich text editor based on Lexical",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"dist"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@haklex/rich-editor-ui": "0.
|
|
61
|
-
"@haklex/rich-headless": "0.
|
|
62
|
-
"@haklex/rich-style-token": "0.
|
|
60
|
+
"@haklex/rich-editor-ui": "0.63.0",
|
|
61
|
+
"@haklex/rich-headless": "0.63.0",
|
|
62
|
+
"@haklex/rich-style-token": "0.63.0",
|
|
63
63
|
"@lexical/code-core": "^0.53.0",
|
|
64
64
|
"nanoid": "^6.0.2",
|
|
65
65
|
"thumbhash": "^0.1.1"
|