@baasix/lexical 0.0.6 → 0.0.7
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 +22 -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,24 @@ 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
|
+
editor.update(() => {
|
|
15975
|
+
const root = $getRoot3();
|
|
15976
|
+
const firstChild = root.getFirstChild();
|
|
15977
|
+
if (firstChild) {
|
|
15978
|
+
firstChild.selectStart();
|
|
15979
|
+
}
|
|
15980
|
+
}, { discrete: true });
|
|
15981
|
+
}
|
|
15982
|
+
return false;
|
|
15983
|
+
},
|
|
15984
|
+
COMMAND_PRIORITY_LOW11
|
|
15985
|
+
);
|
|
15986
|
+
}, [editor]);
|
|
15969
15987
|
useEffect46(() => {
|
|
15970
15988
|
if (value === lastSyncedValue.current) {
|
|
15971
15989
|
return;
|
|
@@ -15974,12 +15992,14 @@ function HtmlPlugin({
|
|
|
15974
15992
|
hasUserEdited.current = false;
|
|
15975
15993
|
editor.update(
|
|
15976
15994
|
() => {
|
|
15977
|
-
$setSelection7(null);
|
|
15978
15995
|
const root = $getRoot3();
|
|
15979
15996
|
if (!value || value === "<p></p>" || value === "<p><br></p>") {
|
|
15980
15997
|
root.clear();
|
|
15998
|
+
root.append($createParagraphNode12());
|
|
15999
|
+
$setSelection7(null);
|
|
15981
16000
|
return;
|
|
15982
16001
|
}
|
|
16002
|
+
$setSelection7(null);
|
|
15983
16003
|
const parser = new DOMParser();
|
|
15984
16004
|
const dom = parser.parseFromString(value, "text/html");
|
|
15985
16005
|
const nodes = $generateNodesFromDOM(editor, dom);
|