@baasix/lexical 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,7 +67,7 @@ import { LexicalComposer as LexicalComposer2 } from "@lexical/react/LexicalCompo
|
|
|
67
67
|
import { OnChangePlugin as OnChangePlugin2 } from "@lexical/react/LexicalOnChangePlugin";
|
|
68
68
|
import { useLexicalComposerContext as useLexicalComposerContext46 } from "@lexical/react/LexicalComposerContext";
|
|
69
69
|
import { $generateHtmlFromNodes, $generateNodesFromDOM } from "@lexical/html";
|
|
70
|
-
import { $getRoot as $getRoot3, $insertNodes as $insertNodes6, $setSelection as $setSelection7 } from "lexical";
|
|
70
|
+
import { $createParagraphNode as $createParagraphNode12, $getRoot as $getRoot3, $insertNodes as $insertNodes6, $setSelection as $setSelection7, COMMAND_PRIORITY_LOW as COMMAND_PRIORITY_LOW11, FOCUS_COMMAND as FOCUS_COMMAND2 } from "lexical";
|
|
71
71
|
|
|
72
72
|
// src/Editor.tsx
|
|
73
73
|
import { CharacterLimitPlugin } from "@lexical/react/LexicalCharacterLimitPlugin";
|
|
@@ -15966,6 +15966,28 @@ function HtmlPlugin({
|
|
|
15966
15966
|
const lastSyncedValue = useRef18(null);
|
|
15967
15967
|
const hasUserEdited = useRef18(false);
|
|
15968
15968
|
const debounceTimer = useRef18(null);
|
|
15969
|
+
useEffect46(() => {
|
|
15970
|
+
return editor.registerCommand(
|
|
15971
|
+
FOCUS_COMMAND2,
|
|
15972
|
+
() => {
|
|
15973
|
+
if (editor.getEditorState()._selection === null) {
|
|
15974
|
+
Promise.resolve().then(() => {
|
|
15975
|
+
if (editor.getEditorState()._selection === null) {
|
|
15976
|
+
editor.update(() => {
|
|
15977
|
+
const root = $getRoot3();
|
|
15978
|
+
const firstChild = root.getFirstChild();
|
|
15979
|
+
if (firstChild) {
|
|
15980
|
+
firstChild.selectStart();
|
|
15981
|
+
}
|
|
15982
|
+
});
|
|
15983
|
+
}
|
|
15984
|
+
});
|
|
15985
|
+
}
|
|
15986
|
+
return false;
|
|
15987
|
+
},
|
|
15988
|
+
COMMAND_PRIORITY_LOW11
|
|
15989
|
+
);
|
|
15990
|
+
}, [editor]);
|
|
15969
15991
|
useEffect46(() => {
|
|
15970
15992
|
if (value === lastSyncedValue.current) {
|
|
15971
15993
|
return;
|
|
@@ -15974,12 +15996,14 @@ function HtmlPlugin({
|
|
|
15974
15996
|
hasUserEdited.current = false;
|
|
15975
15997
|
editor.update(
|
|
15976
15998
|
() => {
|
|
15977
|
-
$setSelection7(null);
|
|
15978
15999
|
const root = $getRoot3();
|
|
15979
16000
|
if (!value || value === "<p></p>" || value === "<p><br></p>") {
|
|
15980
16001
|
root.clear();
|
|
16002
|
+
root.append($createParagraphNode12());
|
|
16003
|
+
$setSelection7(null);
|
|
15981
16004
|
return;
|
|
15982
16005
|
}
|
|
16006
|
+
$setSelection7(null);
|
|
15983
16007
|
const parser = new DOMParser();
|
|
15984
16008
|
const dom = parser.parseFromString(value, "text/html");
|
|
15985
16009
|
const nodes = $generateNodesFromDOM(editor, dom);
|