@haklex/rich-editor 0.65.4 → 0.65.6
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.
|
@@ -2887,6 +2887,7 @@ function TextSelectionPlugin() {
|
|
|
2887
2887
|
const store = useTextSelectionStore();
|
|
2888
2888
|
const snapshot = useTextSelectionSnapshot();
|
|
2889
2889
|
const [isEditorFocused, setIsEditorFocused] = useState(false);
|
|
2890
|
+
const [rootHasFocus, setRootHasFocus] = useState(false);
|
|
2890
2891
|
const frameRef = useRef(null);
|
|
2891
2892
|
const focusFrameRef = useRef(null);
|
|
2892
2893
|
useEffect(() => {
|
|
@@ -2902,6 +2903,7 @@ function TextSelectionPlugin() {
|
|
|
2902
2903
|
const rootElement = editor.getRootElement();
|
|
2903
2904
|
const activeElement = rootElement?.ownerDocument.activeElement;
|
|
2904
2905
|
setIsEditorFocused(Boolean(rootElement && activeElement && rootElement.contains(activeElement)));
|
|
2906
|
+
setRootHasFocus(Boolean(rootElement && activeElement === rootElement));
|
|
2905
2907
|
};
|
|
2906
2908
|
const scheduleFocusStateSync = () => {
|
|
2907
2909
|
if (focusFrameRef.current !== null) cancelAnimationFrame(focusFrameRef.current);
|
|
@@ -2981,6 +2983,14 @@ function TextSelectionPlugin() {
|
|
|
2981
2983
|
return;
|
|
2982
2984
|
}
|
|
2983
2985
|
if (!snapshot) {
|
|
2986
|
+
const domSelection = rootElement.ownerDocument.getSelection();
|
|
2987
|
+
if (rootHasFocus && (!domSelection || domSelection.isCollapsed)) {
|
|
2988
|
+
if (activeHighlightOwner === rootElement) {
|
|
2989
|
+
registry?.delete(TEXT_SELECTION_HIGHLIGHT_NAME);
|
|
2990
|
+
registry?.delete(TEXT_SELECTION_INACTIVE_HIGHLIGHT_NAME);
|
|
2991
|
+
}
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2984
2994
|
clearManagedHighlight(rootElement);
|
|
2985
2995
|
return;
|
|
2986
2996
|
}
|
|
@@ -3002,15 +3012,14 @@ function TextSelectionPlugin() {
|
|
|
3002
3012
|
});
|
|
3003
3013
|
};
|
|
3004
3014
|
syncManagedHighlight();
|
|
3005
|
-
return
|
|
3006
|
-
cancelScheduledSync();
|
|
3007
|
-
clearManagedHighlight(editor.getRootElement());
|
|
3008
|
-
};
|
|
3015
|
+
return cancelScheduledSync;
|
|
3009
3016
|
}, [
|
|
3010
3017
|
editor,
|
|
3011
3018
|
isEditorFocused,
|
|
3019
|
+
rootHasFocus,
|
|
3012
3020
|
snapshot
|
|
3013
3021
|
]);
|
|
3022
|
+
useEffect(() => () => clearManagedHighlight(editor.getRootElement()), [editor]);
|
|
3014
3023
|
return null;
|
|
3015
3024
|
}
|
|
3016
3025
|
//#endregion
|
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-Dv6V39nq.js";
|
|
2
2
|
import { n as setResolvedEditNodes, r as allEditNodes } from "./node-registry-8OWu2S8i.js";
|
|
3
3
|
import { n as useEditorBlock } from "./EditorBlockContext-DytAx9Tg.js";
|
|
4
4
|
import { J as NestedContentRendererProvider, X as useOptionalNestedContentRenderer, Y as useNestedContentRenderer, t as editorTheme } from "./theme-DH4xzxU-.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextSelectionPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/TextSelectionPlugin.tsx"],"names":[],"mappings":"AA2CA,wBAAgB,mBAAmB,
|
|
1
|
+
{"version":3,"file":"TextSelectionPlugin.d.ts","sourceRoot":"","sources":["../../src/plugins/TextSelectionPlugin.tsx"],"names":[],"mappings":"AA2CA,wBAAgB,mBAAmB,SAgMlC"}
|
package/dist/plugins-entry.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-Dv6V39nq.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
4
|
import { i as EditorSurfacePlugins, n as ActiveEditorScope, o as useActiveEditor, r as EditorSurfacePlugin, t as VirtualizationPlugin } from "./VirtualizationPlugin-nD_x-4yR.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-editor",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.6",
|
|
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.65.
|
|
61
|
-
"@haklex/rich-headless": "0.65.
|
|
62
|
-
"@haklex/rich-style-token": "0.65.
|
|
60
|
+
"@haklex/rich-editor-ui": "0.65.6",
|
|
61
|
+
"@haklex/rich-headless": "0.65.6",
|
|
62
|
+
"@haklex/rich-style-token": "0.65.6",
|
|
63
63
|
"@lexical/code-core": "^0.53.0",
|
|
64
64
|
"nanoid": "^6.0.2",
|
|
65
65
|
"thumbhash": "^0.1.1"
|