@lexical/react 0.6.4 → 0.6.5
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.
|
@@ -29,7 +29,7 @@ function AutoFocusPlugin({
|
|
|
29
29
|
const activeElement = document.activeElement;
|
|
30
30
|
const rootElement = editor.getRootElement();
|
|
31
31
|
|
|
32
|
-
if (
|
|
32
|
+
if (rootElement !== null && (activeElement === null || !rootElement.contains(activeElement))) {
|
|
33
33
|
// Note: preventScroll won't work in Webkit.
|
|
34
34
|
rootElement.focus({
|
|
35
35
|
preventScroll: true
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react");exports.AutoFocusPlugin=function({defaultSelection:c}){let [a]=e.useLexicalComposerContext();f.useEffect(()=>{a.focus(()=>{let d=document.activeElement,b=a.getRootElement();b.contains(d)
|
|
7
|
+
'use strict';var e=require("@lexical/react/LexicalComposerContext"),f=require("react");exports.AutoFocusPlugin=function({defaultSelection:c}){let [a]=e.useLexicalComposerContext();f.useEffect(()=>{a.focus(()=>{let d=document.activeElement,b=a.getRootElement();null===b||null!==d&&b.contains(d)||b.focus({preventScroll:!0})},{defaultSelection:c})},[c,a]);return null}
|
|
@@ -45,11 +45,15 @@ function NodeEventPlugin({
|
|
|
45
45
|
listenerRef.current = eventListener;
|
|
46
46
|
useLayoutEffect(() => {
|
|
47
47
|
return editor.registerMutationListener(nodeType, mutations => {
|
|
48
|
+
const registedElements = new WeakSet();
|
|
48
49
|
editor.getEditorState().read(() => {
|
|
49
50
|
for (const [key, mutation] of mutations) {
|
|
50
51
|
const element = editor.getElementByKey(key);
|
|
51
52
|
|
|
52
|
-
if (
|
|
53
|
+
if ( // Updated might be a move, so that might mean a new DOM element
|
|
54
|
+
// is created. In this case, we need to add and event listener too.
|
|
55
|
+
(mutation === 'created' || mutation === 'updated') && element !== null && !registedElements.has(element)) {
|
|
56
|
+
registedElements.add(element);
|
|
53
57
|
element.addEventListener(eventType, event => {
|
|
54
58
|
listenerRef.current(event, editor, key);
|
|
55
59
|
});
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
'use strict';var
|
|
8
|
-
exports.NodeEventPlugin=function({nodeType:
|
|
7
|
+
'use strict';var c=require("@lexical/react/LexicalComposerContext"),l=require("react"),m="undefined"!==typeof window&&"undefined"!==typeof window.document&&"undefined"!==typeof window.document.createElement?l.useLayoutEffect:l.useEffect;
|
|
8
|
+
exports.NodeEventPlugin=function({nodeType:d,eventType:n,eventListener:e}){let [a]=c.useLexicalComposerContext(),f=l.useRef(e);f.current=e;m(()=>a.registerMutationListener(d,p=>{let g=new WeakSet;a.getEditorState().read(()=>{for(let [h,k]of p){let b=a.getElementByKey(h);"created"!==k&&"updated"!==k||null===b||g.has(b)||(g.add(b),b.addEventListener(n,q=>{f.current(q,a,h)}))}})}),[a,d]);return null}
|
package/package.json
CHANGED
|
@@ -8,29 +8,29 @@
|
|
|
8
8
|
"rich-text"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.6.
|
|
11
|
+
"version": "0.6.5",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@lexical/clipboard": "0.6.
|
|
14
|
-
"@lexical/code": "0.6.
|
|
15
|
-
"@lexical/dragon": "0.6.
|
|
16
|
-
"@lexical/hashtag": "0.6.
|
|
17
|
-
"@lexical/history": "0.6.
|
|
18
|
-
"@lexical/link": "0.6.
|
|
19
|
-
"@lexical/list": "0.6.
|
|
20
|
-
"@lexical/mark": "0.6.
|
|
21
|
-
"@lexical/markdown": "0.6.
|
|
22
|
-
"@lexical/overflow": "0.6.
|
|
23
|
-
"@lexical/plain-text": "0.6.
|
|
24
|
-
"@lexical/rich-text": "0.6.
|
|
25
|
-
"@lexical/selection": "0.6.
|
|
26
|
-
"@lexical/table": "0.6.
|
|
27
|
-
"@lexical/text": "0.6.
|
|
28
|
-
"@lexical/utils": "0.6.
|
|
29
|
-
"@lexical/yjs": "0.6.
|
|
13
|
+
"@lexical/clipboard": "0.6.5",
|
|
14
|
+
"@lexical/code": "0.6.5",
|
|
15
|
+
"@lexical/dragon": "0.6.5",
|
|
16
|
+
"@lexical/hashtag": "0.6.5",
|
|
17
|
+
"@lexical/history": "0.6.5",
|
|
18
|
+
"@lexical/link": "0.6.5",
|
|
19
|
+
"@lexical/list": "0.6.5",
|
|
20
|
+
"@lexical/mark": "0.6.5",
|
|
21
|
+
"@lexical/markdown": "0.6.5",
|
|
22
|
+
"@lexical/overflow": "0.6.5",
|
|
23
|
+
"@lexical/plain-text": "0.6.5",
|
|
24
|
+
"@lexical/rich-text": "0.6.5",
|
|
25
|
+
"@lexical/selection": "0.6.5",
|
|
26
|
+
"@lexical/table": "0.6.5",
|
|
27
|
+
"@lexical/text": "0.6.5",
|
|
28
|
+
"@lexical/utils": "0.6.5",
|
|
29
|
+
"@lexical/yjs": "0.6.5",
|
|
30
30
|
"react-error-boundary": "^3.1.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"lexical": "0.6.
|
|
33
|
+
"lexical": "0.6.5",
|
|
34
34
|
"react": ">=17.x",
|
|
35
35
|
"react-dom": ">=17.x"
|
|
36
36
|
},
|