@lexical/link 0.9.0 → 0.9.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 +87 -10
- package/LexicalLink.js.flow +6 -9
- package/LexicalLink.prod.js +10 -9
- package/index.d.ts +35 -6
- package/package.json +3 -3
package/LexicalLink.dev.js
CHANGED
|
@@ -17,6 +17,8 @@ class LinkNode extends lexical.ElementNode {
|
|
|
17
17
|
|
|
18
18
|
/** @internal */
|
|
19
19
|
|
|
20
|
+
/** @internal */
|
|
21
|
+
|
|
20
22
|
/** @internal */
|
|
21
23
|
static getType() {
|
|
22
24
|
return 'link';
|
|
@@ -25,7 +27,8 @@ class LinkNode extends lexical.ElementNode {
|
|
|
25
27
|
static clone(node) {
|
|
26
28
|
return new LinkNode(node.__url, {
|
|
27
29
|
rel: node.__rel,
|
|
28
|
-
target: node.__target
|
|
30
|
+
target: node.__target,
|
|
31
|
+
title: node.__title
|
|
29
32
|
}, node.__key);
|
|
30
33
|
}
|
|
31
34
|
|
|
@@ -33,11 +36,13 @@ class LinkNode extends lexical.ElementNode {
|
|
|
33
36
|
super(key);
|
|
34
37
|
const {
|
|
35
38
|
target = null,
|
|
36
|
-
rel = null
|
|
39
|
+
rel = null,
|
|
40
|
+
title = null
|
|
37
41
|
} = attributes;
|
|
38
42
|
this.__url = url;
|
|
39
43
|
this.__target = target;
|
|
40
44
|
this.__rel = rel;
|
|
45
|
+
this.__title = title;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
createDOM(config) {
|
|
@@ -52,6 +57,10 @@ class LinkNode extends lexical.ElementNode {
|
|
|
52
57
|
element.rel = this.__rel;
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
if (this.__title !== null) {
|
|
61
|
+
element.title = this.__title;
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
utils.addClassNamesToElement(element, config.theme.link);
|
|
56
65
|
return element;
|
|
57
66
|
}
|
|
@@ -60,6 +69,7 @@ class LinkNode extends lexical.ElementNode {
|
|
|
60
69
|
const url = this.__url;
|
|
61
70
|
const target = this.__target;
|
|
62
71
|
const rel = this.__rel;
|
|
72
|
+
const title = this.__title;
|
|
63
73
|
|
|
64
74
|
if (url !== prevNode.__url) {
|
|
65
75
|
anchor.href = url;
|
|
@@ -81,6 +91,14 @@ class LinkNode extends lexical.ElementNode {
|
|
|
81
91
|
}
|
|
82
92
|
}
|
|
83
93
|
|
|
94
|
+
if (title !== prevNode.__title) {
|
|
95
|
+
if (title) {
|
|
96
|
+
anchor.title = title;
|
|
97
|
+
} else {
|
|
98
|
+
anchor.removeAttribute('title');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
84
102
|
return false;
|
|
85
103
|
}
|
|
86
104
|
|
|
@@ -96,7 +114,8 @@ class LinkNode extends lexical.ElementNode {
|
|
|
96
114
|
static importJSON(serializedNode) {
|
|
97
115
|
const node = $createLinkNode(serializedNode.url, {
|
|
98
116
|
rel: serializedNode.rel,
|
|
99
|
-
target: serializedNode.target
|
|
117
|
+
target: serializedNode.target,
|
|
118
|
+
title: serializedNode.title
|
|
100
119
|
});
|
|
101
120
|
node.setFormat(serializedNode.format);
|
|
102
121
|
node.setIndent(serializedNode.indent);
|
|
@@ -108,6 +127,7 @@ class LinkNode extends lexical.ElementNode {
|
|
|
108
127
|
return { ...super.exportJSON(),
|
|
109
128
|
rel: this.getRel(),
|
|
110
129
|
target: this.getTarget(),
|
|
130
|
+
title: this.getTitle(),
|
|
111
131
|
type: 'link',
|
|
112
132
|
url: this.getURL(),
|
|
113
133
|
version: 1
|
|
@@ -141,13 +161,23 @@ class LinkNode extends lexical.ElementNode {
|
|
|
141
161
|
writable.__rel = rel;
|
|
142
162
|
}
|
|
143
163
|
|
|
164
|
+
getTitle() {
|
|
165
|
+
return this.getLatest().__title;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
setTitle(title) {
|
|
169
|
+
const writable = this.getWritable();
|
|
170
|
+
writable.__title = title;
|
|
171
|
+
}
|
|
172
|
+
|
|
144
173
|
insertNewAfter(selection, restoreSelection = true) {
|
|
145
174
|
const element = this.getParentOrThrow().insertNewAfter(selection, restoreSelection);
|
|
146
175
|
|
|
147
176
|
if (lexical.$isElementNode(element)) {
|
|
148
177
|
const linkNode = $createLinkNode(this.__url, {
|
|
149
178
|
rel: this.__rel,
|
|
150
|
-
target: this.__target
|
|
179
|
+
target: this.__target,
|
|
180
|
+
title: this.__title
|
|
151
181
|
});
|
|
152
182
|
element.append(linkNode);
|
|
153
183
|
return linkNode;
|
|
@@ -193,7 +223,8 @@ function convertAnchorElement(domNode) {
|
|
|
193
223
|
if (content !== null && content !== '') {
|
|
194
224
|
node = $createLinkNode(domNode.getAttribute('href') || '', {
|
|
195
225
|
rel: domNode.getAttribute('rel'),
|
|
196
|
-
target: domNode.getAttribute('target')
|
|
226
|
+
target: domNode.getAttribute('target'),
|
|
227
|
+
title: domNode.getAttribute('title')
|
|
197
228
|
});
|
|
198
229
|
}
|
|
199
230
|
}
|
|
@@ -202,10 +233,23 @@ function convertAnchorElement(domNode) {
|
|
|
202
233
|
node
|
|
203
234
|
};
|
|
204
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Takes a URL and creates a LinkNode.
|
|
238
|
+
* @param url - The URL the LinkNode should direct to.
|
|
239
|
+
* @param attributes - Optional HTML a tag attributes { target, rel, title }
|
|
240
|
+
* @returns The LinkNode.
|
|
241
|
+
*/
|
|
242
|
+
|
|
205
243
|
|
|
206
244
|
function $createLinkNode(url, attributes) {
|
|
207
245
|
return lexical.$applyNodeReplacement(new LinkNode(url, attributes));
|
|
208
246
|
}
|
|
247
|
+
/**
|
|
248
|
+
* Determines if node is a LinkNode.
|
|
249
|
+
* @param node - The node to be checked.
|
|
250
|
+
* @returns true if node is a LinkNode, false otherwise.
|
|
251
|
+
*/
|
|
252
|
+
|
|
209
253
|
function $isLinkNode(node) {
|
|
210
254
|
return node instanceof LinkNode;
|
|
211
255
|
}
|
|
@@ -219,14 +263,16 @@ class AutoLinkNode extends LinkNode {
|
|
|
219
263
|
static clone(node) {
|
|
220
264
|
return new AutoLinkNode(node.__url, {
|
|
221
265
|
rel: node.__rel,
|
|
222
|
-
target: node.__target
|
|
266
|
+
target: node.__target,
|
|
267
|
+
title: node.__title
|
|
223
268
|
}, node.__key);
|
|
224
269
|
}
|
|
225
270
|
|
|
226
271
|
static importJSON(serializedNode) {
|
|
227
272
|
const node = $createAutoLinkNode(serializedNode.url, {
|
|
228
273
|
rel: serializedNode.rel,
|
|
229
|
-
target: serializedNode.target
|
|
274
|
+
target: serializedNode.target,
|
|
275
|
+
title: serializedNode.title
|
|
230
276
|
});
|
|
231
277
|
node.setFormat(serializedNode.format);
|
|
232
278
|
node.setIndent(serializedNode.indent);
|
|
@@ -252,7 +298,8 @@ class AutoLinkNode extends LinkNode {
|
|
|
252
298
|
if (lexical.$isElementNode(element)) {
|
|
253
299
|
const linkNode = $createAutoLinkNode(this.__url, {
|
|
254
300
|
rel: this._rel,
|
|
255
|
-
target: this.__target
|
|
301
|
+
target: this.__target,
|
|
302
|
+
title: this.__title
|
|
256
303
|
});
|
|
257
304
|
element.append(linkNode);
|
|
258
305
|
return linkNode;
|
|
@@ -262,16 +309,38 @@ class AutoLinkNode extends LinkNode {
|
|
|
262
309
|
}
|
|
263
310
|
|
|
264
311
|
}
|
|
312
|
+
/**
|
|
313
|
+
* Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated
|
|
314
|
+
* during typing, which is especially useful when a button to generate a LinkNode is not practical.
|
|
315
|
+
* @param url - The URL the LinkNode should direct to.
|
|
316
|
+
* @param attributes - Optional HTML a tag attributes. { target, rel, title }
|
|
317
|
+
* @returns The LinkNode.
|
|
318
|
+
*/
|
|
319
|
+
|
|
265
320
|
function $createAutoLinkNode(url, attributes) {
|
|
266
321
|
return lexical.$applyNodeReplacement(new AutoLinkNode(url, attributes));
|
|
267
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Determines if node is an AutoLinkNode.
|
|
325
|
+
* @param node - The node to be checked.
|
|
326
|
+
* @returns true if node is an AutoLinkNode, false otherwise.
|
|
327
|
+
*/
|
|
328
|
+
|
|
268
329
|
function $isAutoLinkNode(node) {
|
|
269
330
|
return node instanceof AutoLinkNode;
|
|
270
331
|
}
|
|
271
332
|
const TOGGLE_LINK_COMMAND = lexical.createCommand('TOGGLE_LINK_COMMAND');
|
|
333
|
+
/**
|
|
334
|
+
* Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null,
|
|
335
|
+
* but saves any children and brings them up to the parent node.
|
|
336
|
+
* @param url - The URL the link directs to.
|
|
337
|
+
* @param attributes - Optional HTML a tag attributes. { target, rel, title }
|
|
338
|
+
*/
|
|
339
|
+
|
|
272
340
|
function toggleLink(url, attributes = {}) {
|
|
273
341
|
const {
|
|
274
|
-
target
|
|
342
|
+
target,
|
|
343
|
+
title
|
|
275
344
|
} = attributes;
|
|
276
345
|
const rel = attributes.rel === undefined ? 'noopener' : attributes.rel;
|
|
277
346
|
const selection = lexical.$getSelection();
|
|
@@ -316,6 +385,10 @@ function toggleLink(url, attributes = {}) {
|
|
|
316
385
|
linkNode.setRel(rel);
|
|
317
386
|
}
|
|
318
387
|
|
|
388
|
+
if (title !== undefined) {
|
|
389
|
+
linkNode.setTitle(title);
|
|
390
|
+
}
|
|
391
|
+
|
|
319
392
|
return;
|
|
320
393
|
}
|
|
321
394
|
}
|
|
@@ -341,6 +414,10 @@ function toggleLink(url, attributes = {}) {
|
|
|
341
414
|
linkNode.setRel(rel);
|
|
342
415
|
}
|
|
343
416
|
|
|
417
|
+
if (title !== undefined) {
|
|
418
|
+
linkNode.setTitle(title);
|
|
419
|
+
}
|
|
420
|
+
|
|
344
421
|
return;
|
|
345
422
|
}
|
|
346
423
|
|
|
@@ -387,7 +464,7 @@ function toggleLink(url, attributes = {}) {
|
|
|
387
464
|
}
|
|
388
465
|
|
|
389
466
|
function $getLinkAncestor(node) {
|
|
390
|
-
return $getAncestor(node,
|
|
467
|
+
return $getAncestor(node, $isLinkNode);
|
|
391
468
|
}
|
|
392
469
|
|
|
393
470
|
function $getAncestor(node, predicate) {
|
package/LexicalLink.js.flow
CHANGED
|
@@ -19,21 +19,16 @@ import {$isElementNode, ElementNode} from 'lexical';
|
|
|
19
19
|
export type LinkAttributes = {
|
|
20
20
|
rel?: null | string,
|
|
21
21
|
target?: null | string,
|
|
22
|
+
title?: null | string,
|
|
22
23
|
};
|
|
23
24
|
declare export class LinkNode extends ElementNode {
|
|
24
25
|
__url: string;
|
|
25
26
|
__target: null | string;
|
|
26
27
|
__rel: null | string;
|
|
28
|
+
__title: null | string;
|
|
27
29
|
static getType(): string;
|
|
28
30
|
static clone(node: LinkNode): LinkNode;
|
|
29
|
-
constructor(
|
|
30
|
-
url: string,
|
|
31
|
-
attributes?: {
|
|
32
|
-
rel?: null | string,
|
|
33
|
-
target?: null | string,
|
|
34
|
-
},
|
|
35
|
-
key?: NodeKey,
|
|
36
|
-
): void;
|
|
31
|
+
constructor(url: string, attributes?: LinkAttributes, key?: NodeKey): void;
|
|
37
32
|
createDOM(config: EditorConfig): HTMLElement;
|
|
38
33
|
updateDOM(
|
|
39
34
|
prevNode: LinkNode,
|
|
@@ -47,6 +42,8 @@ declare export class LinkNode extends ElementNode {
|
|
|
47
42
|
setTarget(target: null | string): void;
|
|
48
43
|
getRel(): null | string;
|
|
49
44
|
setRel(rel: null | string): void;
|
|
45
|
+
getTitle(): null | string;
|
|
46
|
+
setTitle(title: null | string): void;
|
|
50
47
|
insertNewAfter(
|
|
51
48
|
selection: RangeSelection,
|
|
52
49
|
restoreSelection?: boolean,
|
|
@@ -85,5 +82,5 @@ declare export var TOGGLE_LINK_COMMAND: LexicalCommand<
|
|
|
85
82
|
>;
|
|
86
83
|
declare export function toggleLink(
|
|
87
84
|
url: null | string,
|
|
88
|
-
attributes:
|
|
85
|
+
attributes: LinkAttributes,
|
|
89
86
|
): void;
|
package/LexicalLink.prod.js
CHANGED
|
@@ -4,12 +4,13 @@
|
|
|
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 k=require("@lexical/utils"),
|
|
8
|
-
class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
target:
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
'use strict';var k=require("@lexical/utils"),n=require("lexical");
|
|
8
|
+
class p extends n.ElementNode{static getType(){return"link"}static clone(a){return new p(a.__url,{rel:a.__rel,target:a.__target,title:a.__title},a.__key)}constructor(a,b={},d){super(d);let {target:l=null,rel:h=null,title:e=null}=b;this.__url=a;this.__target=l;this.__rel=h;this.__title=e}createDOM(a){let b=document.createElement("a");b.href=this.__url;null!==this.__target&&(b.target=this.__target);null!==this.__rel&&(b.rel=this.__rel);null!==this.__title&&(b.title=this.__title);k.addClassNamesToElement(b,
|
|
9
|
+
a.theme.link);return b}updateDOM(a,b){let d=this.__url,l=this.__target,h=this.__rel,e=this.__title;d!==a.__url&&(b.href=d);l!==a.__target&&(l?b.target=l:b.removeAttribute("target"));h!==a.__rel&&(h?b.rel=h:b.removeAttribute("rel"));e!==a.__title&&(e?b.title=e:b.removeAttribute("title"));return!1}static importDOM(){return{a:()=>({conversion:q,priority:1})}}static importJSON(a){let b=r(a.url,{rel:a.rel,target:a.target,title:a.title});b.setFormat(a.format);b.setIndent(a.indent);b.setDirection(a.direction);
|
|
10
|
+
return b}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=
|
|
11
|
+
this.getParentOrThrow().insertNewAfter(a,b);return n.$isElementNode(a)?(b=r(this.__url,{rel:this.__rel,target:this.__target,title:this.__title}),a.append(b),b):null}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(a,b){if(!n.$isRangeSelection(b))return!1;a=b.anchor.getNode();let d=b.focus.getNode();return this.isParentOf(a)&&this.isParentOf(d)&&0<b.getTextContent().length}}
|
|
12
|
+
function q(a){let b=null;if(k.isHTMLAnchorElement(a)){let d=a.textContent;null!==d&&""!==d&&(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 n.$applyNodeReplacement(new p(a,b))}function t(a){return a instanceof p}
|
|
13
|
+
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 n.$isElementNode(a)?
|
|
14
|
+
(b=w(this.__url,{rel:this._rel,target:this.__target,title:this.__title}),a.append(b),b):null}}function w(a,b){return n.$applyNodeReplacement(new v(a,b))}let x=n.createCommand("TOGGLE_LINK_COMMAND");function y(a,b){for(;null!==a&&null!==(a=a.getParent())&&!b(a););return a}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;
|
|
15
|
+
exports.toggleLink=function(a,b={}){let {target:d,title:l}=b,h=void 0===b.rel?"noopener":b.rel;b=n.$getSelection();if(n.$isRangeSelection(b))if(b=b.extract(),null===a)b.forEach(m=>{m=m.getParent();if(t(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=t(e)?e:y(e,t);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();if(g!==
|
|
16
|
+
c&&null!==g&&(!n.$isElementNode(f)||f.isInline()))if(t(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=r(a,{rel:h,target:d}),t(g)?null===f.getPreviousSibling()?g.insertBefore(c):g.insertAfter(c):f.insertBefore(c)),t(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
|
@@ -11,11 +11,10 @@ import { ElementNode, Spread } from 'lexical';
|
|
|
11
11
|
export declare type LinkAttributes = {
|
|
12
12
|
rel?: null | string;
|
|
13
13
|
target?: null | string;
|
|
14
|
+
title?: null | string;
|
|
14
15
|
};
|
|
15
16
|
export declare type SerializedLinkNode = Spread<{
|
|
16
|
-
type: 'link';
|
|
17
17
|
url: string;
|
|
18
|
-
version: 1;
|
|
19
18
|
}, Spread<LinkAttributes, SerializedElementNode>>;
|
|
20
19
|
/** @noInheritDoc */
|
|
21
20
|
export declare class LinkNode extends ElementNode {
|
|
@@ -25,6 +24,8 @@ export declare class LinkNode extends ElementNode {
|
|
|
25
24
|
__target: null | string;
|
|
26
25
|
/** @internal */
|
|
27
26
|
__rel: null | string;
|
|
27
|
+
/** @internal */
|
|
28
|
+
__title: null | string;
|
|
28
29
|
static getType(): string;
|
|
29
30
|
static clone(node: LinkNode): LinkNode;
|
|
30
31
|
constructor(url: string, attributes?: LinkAttributes, key?: NodeKey);
|
|
@@ -39,6 +40,8 @@ export declare class LinkNode extends ElementNode {
|
|
|
39
40
|
setTarget(target: null | string): void;
|
|
40
41
|
getRel(): null | string;
|
|
41
42
|
setRel(rel: null | string): void;
|
|
43
|
+
getTitle(): null | string;
|
|
44
|
+
setTitle(title: null | string): void;
|
|
42
45
|
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | ElementNode;
|
|
43
46
|
canInsertTextBefore(): false;
|
|
44
47
|
canInsertTextAfter(): false;
|
|
@@ -46,12 +49,20 @@ export declare class LinkNode extends ElementNode {
|
|
|
46
49
|
isInline(): true;
|
|
47
50
|
extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection, destination: 'clone' | 'html'): boolean;
|
|
48
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Takes a URL and creates a LinkNode.
|
|
54
|
+
* @param url - The URL the LinkNode should direct to.
|
|
55
|
+
* @param attributes - Optional HTML a tag attributes { target, rel, title }
|
|
56
|
+
* @returns The LinkNode.
|
|
57
|
+
*/
|
|
49
58
|
export declare function $createLinkNode(url: string, attributes?: LinkAttributes): LinkNode;
|
|
59
|
+
/**
|
|
60
|
+
* Determines if node is a LinkNode.
|
|
61
|
+
* @param node - The node to be checked.
|
|
62
|
+
* @returns true if node is a LinkNode, false otherwise.
|
|
63
|
+
*/
|
|
50
64
|
export declare function $isLinkNode(node: LexicalNode | null | undefined): node is LinkNode;
|
|
51
|
-
export declare type SerializedAutoLinkNode =
|
|
52
|
-
type: 'autolink';
|
|
53
|
-
version: 1;
|
|
54
|
-
}, SerializedLinkNode>;
|
|
65
|
+
export declare type SerializedAutoLinkNode = SerializedLinkNode;
|
|
55
66
|
export declare class AutoLinkNode extends LinkNode {
|
|
56
67
|
static getType(): string;
|
|
57
68
|
static clone(node: AutoLinkNode): AutoLinkNode;
|
|
@@ -60,9 +71,27 @@ export declare class AutoLinkNode extends LinkNode {
|
|
|
60
71
|
exportJSON(): SerializedAutoLinkNode;
|
|
61
72
|
insertNewAfter(selection: RangeSelection, restoreSelection?: boolean): null | ElementNode;
|
|
62
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated
|
|
76
|
+
* during typing, which is especially useful when a button to generate a LinkNode is not practical.
|
|
77
|
+
* @param url - The URL the LinkNode should direct to.
|
|
78
|
+
* @param attributes - Optional HTML a tag attributes. { target, rel, title }
|
|
79
|
+
* @returns The LinkNode.
|
|
80
|
+
*/
|
|
63
81
|
export declare function $createAutoLinkNode(url: string, attributes?: LinkAttributes): AutoLinkNode;
|
|
82
|
+
/**
|
|
83
|
+
* Determines if node is an AutoLinkNode.
|
|
84
|
+
* @param node - The node to be checked.
|
|
85
|
+
* @returns true if node is an AutoLinkNode, false otherwise.
|
|
86
|
+
*/
|
|
64
87
|
export declare function $isAutoLinkNode(node: LexicalNode | null | undefined): node is AutoLinkNode;
|
|
65
88
|
export declare const TOGGLE_LINK_COMMAND: LexicalCommand<string | ({
|
|
66
89
|
url: string;
|
|
67
90
|
} & LinkAttributes) | null>;
|
|
91
|
+
/**
|
|
92
|
+
* Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null,
|
|
93
|
+
* but saves any children and brings them up to the parent node.
|
|
94
|
+
* @param url - The URL the link directs to.
|
|
95
|
+
* @param attributes - Optional HTML a tag attributes. { target, rel, title }
|
|
96
|
+
*/
|
|
68
97
|
export declare function toggleLink(url: null | string, attributes?: LinkAttributes): void;
|
package/package.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"link"
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"version": "0.9.
|
|
11
|
+
"version": "0.9.2",
|
|
12
12
|
"main": "LexicalLink.js",
|
|
13
13
|
"peerDependencies": {
|
|
14
|
-
"lexical": "0.9.
|
|
14
|
+
"lexical": "0.9.2"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lexical/utils": "0.9.
|
|
17
|
+
"@lexical/utils": "0.9.2"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|