@lexical/link
Advanced tools
Comparing version 0.21.1-nightly.20241223.0 to 0.22.0
@@ -141,5 +141,3 @@ /** | ||
title: this.getTitle(), | ||
type: 'link', | ||
url: this.getURL(), | ||
version: 1 | ||
url: this.getURL() | ||
}; | ||
@@ -304,5 +302,3 @@ } | ||
...super.exportJSON(), | ||
isUnlinked: this.__isUnlinked, | ||
type: 'autolink', | ||
version: 1 | ||
isUnlinked: this.__isUnlinked | ||
}; | ||
@@ -309,0 +305,0 @@ } |
@@ -13,8 +13,8 @@ /** | ||
a.theme.link);return b}updateDOM(a,b){if(f.isHTMLAnchorElement(b)){let c=this.__url,g=this.__target,h=this.__rel,k=this.__title;c!==a.__url&&(b.href=c);g!==a.__target&&(g?b.target=g:b.removeAttribute("target"));h!==a.__rel&&(h?b.rel=h:b.removeAttribute("rel"));k!==a.__title&&(k?b.title=k:b.removeAttribute("title"))}return!1}static importDOM(){return{a:()=>({conversion:t,priority:1})}}static importJSON(a){let b=u(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}sanitizeUrl(a){try{let b=new URL(a);if(!q.has(b.protocol))return"about:blank"}catch(b){}return a}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}getTarget(){return this.getLatest().__target}setTarget(a){this.getWritable().__target=a}getRel(){return this.getLatest().__rel}setRel(a){this.getWritable().__rel= | ||
a}getTitle(){return this.getLatest().__title}setTitle(a){this.getWritable().__title=a}insertNewAfter(a,b=!0){a=u(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 c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&0<b.getTextContent().length}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")|| | ||
b.setDirection(a.direction);return b}sanitizeUrl(a){try{let b=new URL(a);if(!q.has(b.protocol))return"about:blank"}catch(b){}return a}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(a){this.getWritable().__url=a}getTarget(){return this.getLatest().__target}setTarget(a){this.getWritable().__target=a}getRel(){return this.getLatest().__rel}setRel(a){this.getWritable().__rel=a}getTitle(){return this.getLatest().__title}setTitle(a){this.getWritable().__title= | ||
a}insertNewAfter(a,b=!0){a=u(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 c=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(c)&&0<b.getTextContent().length}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")|| | ||
this.__url.startsWith("http://")}}function t(a){let b=null;if(f.isHTMLAnchorElement(a)){let c=a.textContent;if(null!==c&&""!==c||0<a.children.length)b=u(a.getAttribute("href")||"",{rel:a.getAttribute("rel"),target:a.getAttribute("target"),title:a.getAttribute("title")})}return{node:b}}function u(a,b){return m.$applyNodeReplacement(new r(a,b))}function v(a){return a instanceof r} | ||
class x extends r{constructor(a,b={},c){super(a,b,c);this.__isUnlinked=void 0!==b.isUnlinked&&null!==b.isUnlinked?b.isUnlinked:!1}static getType(){return"autolink"}static clone(a){return new x(a.__url,{isUnlinked:a.__isUnlinked,rel:a.__rel,target:a.__target,title:a.__title},a.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(a){let b=this.getWritable();b.__isUnlinked=a;return b}createDOM(a){return this.__isUnlinked?document.createElement("span"):super.createDOM(a)}updateDOM(a,b,c){return super.updateDOM(a, | ||
b,c)||a.__isUnlinked!==this.__isUnlinked}static importJSON(a){let b=y(a.url,{isUnlinked:a.isUnlinked,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(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(a,b=!0){a=this.getParentOrThrow().insertNewAfter(a,b);return m.$isElementNode(a)?(b=y(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel, | ||
target:this.__target,title:this.__title}),a.append(b),b):null}}function y(a,b){return m.$applyNodeReplacement(new x(a,b))}function z(a){return a instanceof x}let B=m.createCommand("TOGGLE_LINK_COMMAND");function C(a,b){if("element"===a.type){let c=a.getNode();m.$isElementNode(c)||n(252);return c.getChildren()[a.offset+b]||null}return null} | ||
b,c)||a.__isUnlinked!==this.__isUnlinked}static importJSON(a){let b=y(a.url,{isUnlinked:a.isUnlinked,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(),isUnlinked:this.__isUnlinked}}insertNewAfter(a,b=!0){a=this.getParentOrThrow().insertNewAfter(a,b);return m.$isElementNode(a)?(b=y(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target, | ||
title:this.__title}),a.append(b),b):null}}function y(a,b){return m.$applyNodeReplacement(new x(a,b))}function z(a){return a instanceof x}let B=m.createCommand("TOGGLE_LINK_COMMAND");function C(a,b){if("element"===a.type){let c=a.getNode();m.$isElementNode(c)||n(252);return c.getChildren()[a.offset+b]||null}return null} | ||
function D(a){var b=m.$getSelection();if(!m.$isRangeSelection(b))return a();var c=m.$normalizeSelection__EXPERIMENTAL(b);b=c.isBackward();var g=C(c.anchor,b?-1:0);c=C(c.focus,b?0:-1);a=a();if(g||c){var h=m.$getSelection();if(m.$isRangeSelection(h)){h=h.clone();if(g){let k=g.getParent();k&&h.anchor.set(k.getKey(),g.getIndexWithinParent()+(b?1:0),"element")}c&&(g=c.getParent())&&h.focus.set(g.getKey(),c.getIndexWithinParent()+(b?0:1),"element");m.$setSelection(m.$normalizeSelection__EXPERIMENTAL(h))}}return a} | ||
@@ -21,0 +21,0 @@ function E(a,b={}){let {target:c,title:g}=b,h=void 0===b.rel?"noreferrer":b.rel;b=m.$getSelection();if(m.$isRangeSelection(b)){var k=b.extract();if(null===a)k.forEach(d=>{if(d=f.$findMatchingParent(d,l=>!z(l)&&v(l))){let l=d.getChildren();for(let e=0;e<l.length;e++)d.insertBefore(l[e]);d.remove()}});else{var A=new Set,w=d=>{A.has(d.getKey())||(A.add(d.getKey()),d.setURL(a),void 0!==c&&d.setTarget(c),void 0!==h&&d.setRel(h),void 0!==g&&d.setTitle(g))};if(1===k.length&&(b=F(k[0],v),null!==b))return w(b); |
@@ -11,8 +11,8 @@ { | ||
"license": "MIT", | ||
"version": "0.21.1-nightly.20241223.0", | ||
"version": "0.22.0", | ||
"main": "LexicalLink.js", | ||
"types": "index.d.ts", | ||
"dependencies": { | ||
"@lexical/utils": "0.21.1-nightly.20241223.0", | ||
"lexical": "0.21.1-nightly.20241223.0" | ||
"@lexical/utils": "0.22.0", | ||
"lexical": "0.22.0" | ||
}, | ||
@@ -19,0 +19,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
54159
1214
+ Added@lexical/clipboard@0.22.0(transitive)
+ Added@lexical/html@0.22.0(transitive)
+ Added@lexical/list@0.22.0(transitive)
+ Added@lexical/selection@0.22.0(transitive)
+ Added@lexical/table@0.22.0(transitive)
+ Added@lexical/utils@0.22.0(transitive)
+ Addedlexical@0.22.0(transitive)
- Removed@lexical/clipboard@0.21.1-nightly.20241223.0(transitive)
- Removed@lexical/html@0.21.1-nightly.20241223.0(transitive)
- Removed@lexical/list@0.21.1-nightly.20241223.0(transitive)
- Removed@lexical/selection@0.21.1-nightly.20241223.0(transitive)
- Removed@lexical/table@0.21.1-nightly.20241223.0(transitive)
- Removed@lexical/utils@0.21.1-nightly.20241223.0(transitive)
- Removedlexical@0.21.1-nightly.20241223.0(transitive)
Updated@lexical/utils@0.22.0
Updatedlexical@0.22.0