@lexical/link 0.11.0 → 0.11.2
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/LexicalLink.dev.js +1 -1
- package/LexicalLink.prod.js +2 -2
- package/index.d.ts +3 -3
- package/package.json +3 -3
package/LexicalLink.dev.js
CHANGED
|
@@ -357,7 +357,7 @@ function toggleLink(url, attributes = {}) {
|
|
|
357
357
|
target,
|
|
358
358
|
title
|
|
359
359
|
} = attributes;
|
|
360
|
-
const rel = attributes.rel === undefined ? '
|
|
360
|
+
const rel = attributes.rel === undefined ? 'noreferrer' : attributes.rel;
|
|
361
361
|
const selection = lexical.$getSelection();
|
|
362
362
|
|
|
363
363
|
if (!lexical.$isRangeSelection(selection)) {
|
package/LexicalLink.prod.js
CHANGED
|
@@ -12,5 +12,5 @@ a}insertNewAfter(a,b=!0){a=this.getParentOrThrow().insertNewAfter(a,b);return n.
|
|
|
12
12
|
function r(a){let b=null;if(k.isHTMLAnchorElement(a)){let d=a.textContent;null!==d&&""!==d&&(b=t(a.getAttribute("href")||"",{rel:a.getAttribute("rel"),target:a.getAttribute("target"),title:a.getAttribute("title")}))}return{node:b}}function t(a,b){return n.$applyNodeReplacement(new q(a,b))}function v(a){return a instanceof q}
|
|
13
13
|
class w extends q{static getType(){return"autolink"}static clone(a){return new w(a.__url,{rel:a.__rel,target:a.__target,title:a.__title},a.__key)}static importJSON(a){let b=x(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 n.$isElementNode(a)?
|
|
14
14
|
(b=x(this.__url,{rel:this._rel,target:this.__target,title:this.__title}),a.append(b),b):null}}function x(a,b){return n.$applyNodeReplacement(new w(a,b))}let y=n.createCommand("TOGGLE_LINK_COMMAND");function z(a,b){for(;null!==a&&null!==(a=a.getParent())&&!b(a););return a}exports.$createAutoLinkNode=x;exports.$createLinkNode=t;exports.$isAutoLinkNode=function(a){return a instanceof w};exports.$isLinkNode=v;exports.AutoLinkNode=w;exports.LinkNode=q;exports.TOGGLE_LINK_COMMAND=y;
|
|
15
|
-
exports.toggleLink=function(a,b={}){let {target:d,title:l}=b,h=void 0===b.rel?"
|
|
16
|
-
c&&null!==g&&(!n.$isElementNode(f)||f.isInline()))if(v(g))c=g,g.setURL(a),void 0!==d&&g.setTarget(d),null!==h&&c.setRel(h),void 0!==l&&c.setTitle(l);else if(g.is(m)||(m=g,c=t(a,{rel:h,target:d}),v(g)?null===f.getPreviousSibling()?g.insertBefore(c):g.insertAfter(c):f.insertBefore(c)),v(f)){if(!f.is(c)){if(null!==c){g=f.getChildren();for(let u=0;u<g.length;u++)c.append(g[u])}f.remove()}}else null!==c&&c.append(f)})}}
|
|
15
|
+
exports.toggleLink=function(a,b={}){let {target:d,title:l}=b,h=void 0===b.rel?"noreferrer":b.rel;b=n.$getSelection();if(n.$isRangeSelection(b))if(b=b.extract(),null===a)b.forEach(m=>{m=m.getParent();if(v(m)){let c=m.getChildren();for(let f=0;f<c.length;f++)m.insertBefore(c[f]);m.remove()}});else{if(1===b.length){var e=b[0];e=v(e)?e:z(e,v);if(null!==e){e.setURL(a);void 0!==d&&e.setTarget(d);null!==h&&e.setRel(h);void 0!==l&&e.setTitle(l);return}}let m=null,c=null;b.forEach(f=>{var g=f.getParent();
|
|
16
|
+
if(g!==c&&null!==g&&(!n.$isElementNode(f)||f.isInline()))if(v(g))c=g,g.setURL(a),void 0!==d&&g.setTarget(d),null!==h&&c.setRel(h),void 0!==l&&c.setTitle(l);else if(g.is(m)||(m=g,c=t(a,{rel:h,target:d}),v(g)?null===f.getPreviousSibling()?g.insertBefore(c):g.insertAfter(c):f.insertBefore(c)),v(f)){if(!f.is(c)){if(null!==c){g=f.getChildren();for(let u=0;u<g.length;u++)c.append(g[u])}f.remove()}}else null!==c&&c.append(f)})}}
|
package/index.d.ts
CHANGED
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { DOMConversionMap, EditorConfig, GridSelection, LexicalCommand, LexicalNode, NodeKey, NodeSelection, RangeSelection, SerializedElementNode } from 'lexical';
|
|
10
10
|
import { ElementNode, Spread } from 'lexical';
|
|
11
|
-
export
|
|
11
|
+
export type LinkAttributes = {
|
|
12
12
|
rel?: null | string;
|
|
13
13
|
target?: null | string;
|
|
14
14
|
title?: null | string;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
16
|
+
export type SerializedLinkNode = Spread<{
|
|
17
17
|
url: string;
|
|
18
18
|
}, Spread<LinkAttributes, SerializedElementNode>>;
|
|
19
19
|
/** @noInheritDoc */
|
|
@@ -63,7 +63,7 @@ export declare function $createLinkNode(url: string, attributes?: LinkAttributes
|
|
|
63
63
|
* @returns true if node is a LinkNode, false otherwise.
|
|
64
64
|
*/
|
|
65
65
|
export declare function $isLinkNode(node: LexicalNode | null | undefined): node is LinkNode;
|
|
66
|
-
export
|
|
66
|
+
export type SerializedAutoLinkNode = SerializedLinkNode;
|
|
67
67
|
export declare class AutoLinkNode extends LinkNode {
|
|
68
68
|
static getType(): string;
|
|
69
69
|
static clone(node: AutoLinkNode): AutoLinkNode;
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"link"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.11.
|
|
11
|
+
"version": "0.11.2",
|
|
12
12
|
"main": "LexicalLink.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.11.
|
|
14
|
+
"lexical": "0.11.2"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.11.
|
|
17
|
+
"@lexical/utils": "0.11.2"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|