@lexical/link
Advanced tools
Comparing version 0.12.3 to 0.12.4
@@ -334,3 +334,3 @@ /** | ||
// parent is a LinkNode, we update the URL, target and rel. | ||
const linkNode = utils.$getAncestor(firstNode, $isLinkNode); | ||
const linkNode = $getAncestor(firstNode, $isLinkNode); | ||
if (linkNode !== null) { | ||
@@ -407,2 +407,9 @@ linkNode.setURL(url); | ||
} | ||
function $getAncestor(node, predicate) { | ||
let parent = node; | ||
while (parent !== null && parent.getParent() !== null && !predicate(parent)) { | ||
parent = parent.getParentOrThrow(); | ||
} | ||
return predicate(parent) ? parent : null; | ||
} | ||
@@ -409,0 +416,0 @@ exports.$createAutoLinkNode = $createAutoLinkNode; |
@@ -12,6 +12,7 @@ /** | ||
a}insertNewAfter(a,b=!0){a=r(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});this.insertAfter(a,b);return a}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b){if(!m.$isRangeSelection(b))return!1;a=b.anchor.getNode();let e=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(e)&&0<b.getTextContent().length}} | ||
function q(a){let b=null;if(l.isHTMLAnchorElement(a)){let e=a.textContent;if(null!==e&&""!==e||0<a.children.length)b=r(a.getAttribute("href")||"",{rel:a.getAttribute("rel"),target:a.getAttribute("target"),title:a.getAttribute("title")})}return{node:b}}function r(a,b){return m.$applyNodeReplacement(new p(a,b))}function t(a){return a instanceof p} | ||
function q(a){let b=null;if(l.isHTMLAnchorElement(a)){let e=a.textContent;if(null!==e&&""!==e||0<a.children.length)b=r(a.getAttribute("href")||"",{rel:a.getAttribute("rel"),target:a.getAttribute("target"),title:a.getAttribute("title")})}return{node:b}}function r(a,b){return m.$applyNodeReplacement(new p(a,b))}function u(a){return a instanceof p} | ||
class v extends p{static getType(){return"autolink"}static clone(a){return new v(a.__url,{rel:a.__rel,target:a.__target,title:a.__title},a.__key)}static importJSON(a){let b=w(a.url,{rel:a.rel,target:a.target,title:a.title});b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);return b}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),type:"autolink",version:1}}insertNewAfter(a,b=!0){a=this.getParentOrThrow().insertNewAfter(a,b);return m.$isElementNode(a)? | ||
(b=w(this.__url,{rel:this.__rel,target:this.__target,title:this.__title}),a.append(b),b):null}}function w(a,b){return m.$applyNodeReplacement(new v(a,b))}let x=m.createCommand("TOGGLE_LINK_COMMAND");exports.$createAutoLinkNode=w;exports.$createLinkNode=r;exports.$isAutoLinkNode=function(a){return a instanceof v};exports.$isLinkNode=t;exports.AutoLinkNode=v;exports.LinkNode=p;exports.TOGGLE_LINK_COMMAND=x; | ||
exports.toggleLink=function(a,b={}){let {target:e,title:h}=b,k=void 0===b.rel?"noreferrer":b.rel;b=m.$getSelection();if(m.$isRangeSelection(b))if(b=b.extract(),null===a)b.forEach(f=>{f=f.getParent();if(t(f)){let d=f.getChildren();for(let c=0;c<d.length;c++)f.insertBefore(d[c]);f.remove()}});else{if(1===b.length){let c=l.$getAncestor(b[0],t);if(null!==c){c.setURL(a);void 0!==e&&c.setTarget(e);null!==k&&c.setRel(k);void 0!==h&&c.setTitle(h);return}}let f=null,d=null;b.forEach(c=>{var g=c.getParent(); | ||
if(g!==d&&null!==g&&(!m.$isElementNode(c)||c.isInline()))if(t(g))d=g,g.setURL(a),void 0!==e&&g.setTarget(e),null!==k&&d.setRel(k),void 0!==h&&d.setTitle(h);else if(g.is(f)||(f=g,d=r(a,{rel:k,target:e,title:h}),t(g)?null===c.getPreviousSibling()?g.insertBefore(d):g.insertAfter(d):c.insertBefore(d)),t(c)){if(!c.is(d)){if(null!==d){g=c.getChildren();for(let u=0;u<g.length;u++)d.append(g[u])}c.remove()}}else null!==d&&d.append(c)})}} | ||
(b=w(this.__url,{rel:this.__rel,target:this.__target,title:this.__title}),a.append(b),b):null}}function w(a,b){return m.$applyNodeReplacement(new v(a,b))}let x=m.createCommand("TOGGLE_LINK_COMMAND");function y(a,b){for(;null!==a&&null!==a.getParent()&&!b(a);)a=a.getParentOrThrow();return b(a)?a:null}exports.$createAutoLinkNode=w;exports.$createLinkNode=r;exports.$isAutoLinkNode=function(a){return a instanceof v};exports.$isLinkNode=u;exports.AutoLinkNode=v;exports.LinkNode=p; | ||
exports.TOGGLE_LINK_COMMAND=x; | ||
exports.toggleLink=function(a,b={}){let {target:e,title:h}=b,k=void 0===b.rel?"noreferrer":b.rel;b=m.$getSelection();if(m.$isRangeSelection(b))if(b=b.extract(),null===a)b.forEach(f=>{f=f.getParent();if(u(f)){let d=f.getChildren();for(let c=0;c<d.length;c++)f.insertBefore(d[c]);f.remove()}});else{if(1===b.length){let c=y(b[0],u);if(null!==c){c.setURL(a);void 0!==e&&c.setTarget(e);null!==k&&c.setRel(k);void 0!==h&&c.setTitle(h);return}}let f=null,d=null;b.forEach(c=>{var g=c.getParent();if(g!==d&&null!== | ||
g&&(!m.$isElementNode(c)||c.isInline()))if(u(g))d=g,g.setURL(a),void 0!==e&&g.setTarget(e),null!==k&&d.setRel(k),void 0!==h&&d.setTitle(h);else if(g.is(f)||(f=g,d=r(a,{rel:k,target:e,title:h}),u(g)?null===c.getPreviousSibling()?g.insertBefore(d):g.insertAfter(d):c.insertBefore(d)),u(c)){if(!c.is(d)){if(null!==d){g=c.getChildren();for(let t=0;t<g.length;t++)d.append(g[t])}c.remove()}}else null!==d&&d.append(c)})}} |
@@ -11,9 +11,9 @@ { | ||
"license": "MIT", | ||
"version": "0.12.3", | ||
"version": "0.12.4", | ||
"main": "LexicalLink.js", | ||
"peerDependencies": { | ||
"lexical": "0.12.3" | ||
"lexical": "0.12.4" | ||
}, | ||
"dependencies": { | ||
"@lexical/utils": "0.12.3" | ||
"@lexical/utils": "0.12.4" | ||
}, | ||
@@ -20,0 +20,0 @@ "repository": { |
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
24590
542
+ Added@lexical/list@0.12.4(transitive)
+ Added@lexical/selection@0.12.4(transitive)
+ Added@lexical/table@0.12.4(transitive)
+ Added@lexical/utils@0.12.4(transitive)
+ Addedlexical@0.12.4(transitive)
- Removed@lexical/list@0.12.3(transitive)
- Removed@lexical/selection@0.12.3(transitive)
- Removed@lexical/table@0.12.3(transitive)
- Removed@lexical/utils@0.12.3(transitive)
- Removedlexical@0.12.3(transitive)
Updated@lexical/utils@0.12.4