@lexical/react
Advanced tools
Comparing version 0.17.1-nightly.20240806.0 to 0.17.1-nightly.20240807.0
@@ -122,7 +122,7 @@ /** | ||
handleCheckItemEvent(event, () => { | ||
const domNode = event.target; | ||
const editor = findEditor(domNode); | ||
if (editor != null && editor.isEditable()) { | ||
editor.update(() => { | ||
if (event.target) { | ||
if (event.target instanceof HTMLElement) { | ||
const domNode = event.target; | ||
const editor = lexical.getNearestEditorFromDOMNode(domNode); | ||
if (editor != null && editor.isEditable()) { | ||
editor.update(() => { | ||
const node = lexical.$getNearestNodeFromDOMNode(domNode); | ||
@@ -133,4 +133,4 @@ if (list.$isListItemNode(node)) { | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -145,14 +145,2 @@ }); | ||
} | ||
function findEditor(target) { | ||
let node = target; | ||
while (node) { | ||
// @ts-ignore internal field | ||
if (node.__lexicalEditor) { | ||
// @ts-ignore internal field | ||
return node.__lexicalEditor; | ||
} | ||
node = node.parentNode; | ||
} | ||
return null; | ||
} | ||
function getActiveCheckListItem() { | ||
@@ -159,0 +147,0 @@ const activeElement = document.activeElement; |
@@ -10,7 +10,7 @@ /** | ||
'use strict';var e=require("@lexical/list"),g=require("@lexical/react/LexicalComposerContext"),k=require("@lexical/utils"),l=require("lexical"),m=require("react");function n(a,c){let b=a.target;if(null!==b&&k.isHTMLElement(b)){var d=b.firstChild;(null==d||!k.isHTMLElement(d)||"UL"!==d.tagName&&"OL"!==d.tagName)&&(d=b.parentNode)&&"check"===d.__lexicalListType&&(d=b.getBoundingClientRect(),a=a.pageX/k.calculateZoomLevel(b),("rtl"===b.dir?a<d.right&&a>d.right-20:a>d.left&&a<d.left+20)&&c())}} | ||
function p(a){n(a,()=>{let c=a.target,b=q(c);null!=b&&b.isEditable()&&b.update(()=>{if(a.target){let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())}})})}function r(a){n(a,()=>{a.preventDefault()})}function q(a){for(;a;){if(a.__lexicalEditor)return a.__lexicalEditor;a=a.parentNode}return null}function t(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null} | ||
function u(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null} | ||
function v(a,c,b){let d=t();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=u(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1} | ||
exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>v(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>v(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=t()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW), | ||
a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=t();return null!=b&&a.isEditable()?(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline()); | ||
if(e.$isListItemNode(f)){let h=f.getParent();if(e.$isListNode(h)&&"check"===h.getListType()&&(b||f.getFirstDescendant()===d)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),c.preventDefault(),!0}}}return!1}),l.COMMAND_PRIORITY_LOW),a.registerRootListener((c,b)=>{null!==c&&(c.addEventListener("click",p),c.addEventListener("pointerdown",r));null!==b&&(b.removeEventListener("click",p),b.removeEventListener("pointerdown",r))})));return null} | ||
function p(a){n(a,()=>{if(a.target instanceof HTMLElement){let c=a.target,b=l.getNearestEditorFromDOMNode(c);null!=b&&b.isEditable()&&b.update(()=>{let d=l.$getNearestNodeFromDOMNode(c);e.$isListItemNode(d)&&(c.focus(),d.toggleChecked())})}})}function q(a){n(a,()=>{a.preventDefault()})}function r(){let a=document.activeElement;return null!=a&&"LI"===a.tagName&&null!=a.parentNode&&"check"===a.parentNode.__lexicalListType?a:null} | ||
function t(a,c){let b=c?a.getPreviousSibling():a.getNextSibling();for(;null==b&&e.$isListItemNode(a);)a=a.getParentOrThrow().getParent(),null!=a&&(b=c?a.getPreviousSibling():a.getNextSibling());for(;e.$isListItemNode(b);){a=c?b.getLastChild():b.getFirstChild();if(!e.$isListNode(a))return b;b=c?a.getLastChild():a.getFirstChild()}return null} | ||
function u(a,c,b){let d=r();null!=d&&c.update(()=>{var f=l.$getNearestNodeFromDOMNode(d);if(e.$isListItemNode(f)&&(f=t(f,b),null!=f)){f.selectStart();let h=c.getElementByKey(f.__key);null!=h&&(a.preventDefault(),setTimeout(()=>{h.focus()},0))}});return!1} | ||
exports.CheckListPlugin=function(){let [a]=g.useLexicalComposerContext();m.useEffect(()=>k.mergeRegister(a.registerCommand(e.INSERT_CHECK_LIST_COMMAND,()=>{e.insertList(a,"check");return!0},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_DOWN_COMMAND,c=>u(c,a,!1),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_UP_COMMAND,c=>u(c,a,!0),l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ESCAPE_COMMAND,()=>{if(null!=r()){let c=a.getRootElement();null!=c&&c.focus();return!0}return!1},l.COMMAND_PRIORITY_LOW), | ||
a.registerCommand(l.KEY_SPACE_COMMAND,c=>{let b=r();return null!=b&&a.isEditable()?(a.update(()=>{let d=l.$getNearestNodeFromDOMNode(b);e.$isListItemNode(d)&&(c.preventDefault(),d.toggleChecked())}),!0):!1},l.COMMAND_PRIORITY_LOW),a.registerCommand(l.KEY_ARROW_LEFT_COMMAND,c=>a.getEditorState().read(()=>{var b=l.$getSelection();if(l.$isRangeSelection(b)&&b.isCollapsed()){var {anchor:d}=b;if((b="element"===d.type)||0===d.offset){d=d.getNode();let f=k.$findMatchingParent(d,h=>l.$isElementNode(h)&&!h.isInline()); | ||
if(e.$isListItemNode(f)){let h=f.getParent();if(e.$isListNode(h)&&"check"===h.getListType()&&(b||f.getFirstDescendant()===d)&&(b=a.getElementByKey(f.__key),null!=b&&document.activeElement!==b))return b.focus(),c.preventDefault(),!0}}}return!1}),l.COMMAND_PRIORITY_LOW),a.registerRootListener((c,b)=>{null!==c&&(c.addEventListener("click",p),c.addEventListener("pointerdown",q));null!==b&&(b.removeEventListener("click",p),b.removeEventListener("pointerdown",q))})));return null} |
@@ -11,23 +11,23 @@ { | ||
"license": "MIT", | ||
"version": "0.17.1-nightly.20240806.0", | ||
"version": "0.17.1-nightly.20240807.0", | ||
"dependencies": { | ||
"@lexical/clipboard": "0.17.1-nightly.20240806.0", | ||
"@lexical/code": "0.17.1-nightly.20240806.0", | ||
"@lexical/devtools-core": "0.17.1-nightly.20240806.0", | ||
"@lexical/dragon": "0.17.1-nightly.20240806.0", | ||
"@lexical/hashtag": "0.17.1-nightly.20240806.0", | ||
"@lexical/history": "0.17.1-nightly.20240806.0", | ||
"@lexical/link": "0.17.1-nightly.20240806.0", | ||
"@lexical/list": "0.17.1-nightly.20240806.0", | ||
"@lexical/mark": "0.17.1-nightly.20240806.0", | ||
"@lexical/markdown": "0.17.1-nightly.20240806.0", | ||
"@lexical/overflow": "0.17.1-nightly.20240806.0", | ||
"@lexical/plain-text": "0.17.1-nightly.20240806.0", | ||
"@lexical/rich-text": "0.17.1-nightly.20240806.0", | ||
"@lexical/selection": "0.17.1-nightly.20240806.0", | ||
"@lexical/table": "0.17.1-nightly.20240806.0", | ||
"@lexical/text": "0.17.1-nightly.20240806.0", | ||
"@lexical/utils": "0.17.1-nightly.20240806.0", | ||
"@lexical/yjs": "0.17.1-nightly.20240806.0", | ||
"lexical": "0.17.1-nightly.20240806.0", | ||
"@lexical/clipboard": "0.17.1-nightly.20240807.0", | ||
"@lexical/code": "0.17.1-nightly.20240807.0", | ||
"@lexical/devtools-core": "0.17.1-nightly.20240807.0", | ||
"@lexical/dragon": "0.17.1-nightly.20240807.0", | ||
"@lexical/hashtag": "0.17.1-nightly.20240807.0", | ||
"@lexical/history": "0.17.1-nightly.20240807.0", | ||
"@lexical/link": "0.17.1-nightly.20240807.0", | ||
"@lexical/list": "0.17.1-nightly.20240807.0", | ||
"@lexical/mark": "0.17.1-nightly.20240807.0", | ||
"@lexical/markdown": "0.17.1-nightly.20240807.0", | ||
"@lexical/overflow": "0.17.1-nightly.20240807.0", | ||
"@lexical/plain-text": "0.17.1-nightly.20240807.0", | ||
"@lexical/rich-text": "0.17.1-nightly.20240807.0", | ||
"@lexical/selection": "0.17.1-nightly.20240807.0", | ||
"@lexical/table": "0.17.1-nightly.20240807.0", | ||
"@lexical/text": "0.17.1-nightly.20240807.0", | ||
"@lexical/utils": "0.17.1-nightly.20240807.0", | ||
"@lexical/yjs": "0.17.1-nightly.20240807.0", | ||
"lexical": "0.17.1-nightly.20240807.0", | ||
"react-error-boundary": "^3.1.4" | ||
@@ -34,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
827651
16266
+ Added@lexical/clipboard@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/code@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/devtools-core@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/dragon@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/hashtag@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/history@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/html@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/link@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/list@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/mark@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/markdown@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/offset@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/overflow@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/plain-text@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/rich-text@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/selection@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/table@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/text@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/utils@0.17.1-nightly.20240807.0(transitive)
+ Added@lexical/yjs@0.17.1-nightly.20240807.0(transitive)
+ Addedlexical@0.17.1-nightly.20240807.0(transitive)
- Removed@lexical/clipboard@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/code@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/devtools-core@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/dragon@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/hashtag@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/history@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/html@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/link@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/list@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/mark@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/markdown@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/offset@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/overflow@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/plain-text@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/rich-text@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/selection@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/table@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/text@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/utils@0.17.1-nightly.20240806.0(transitive)
- Removed@lexical/yjs@0.17.1-nightly.20240806.0(transitive)
- Removedlexical@0.17.1-nightly.20240806.0(transitive)