@react-fabric/lexical 1.0.0-beta.60 → 1.0.0-beta.61
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/dist/cjs/{packages/lexical/src/components → components}/StickyComponent.js +2 -3
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +5 -5
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +101 -95
- package/dist/cjs/i18n/ar.json.js +24 -0
- package/dist/cjs/i18n/en.json.js +24 -0
- package/dist/cjs/i18n/index.js +33 -0
- package/dist/cjs/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +5 -5
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +35 -22
- package/dist/esm/{packages/lexical/src/components → components}/StickyComponent.js +2 -3
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +4 -4
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +43 -37
- package/dist/esm/i18n/ar.json.js +21 -0
- package/dist/esm/i18n/en.json.js +21 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/{packages/lexical/src/index.js → index.js} +1 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +2 -2
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +36 -23
- package/dist/types/hooks/useFormatWatcher.d.ts +1 -0
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +5 -5
- package/src/components/StickyComponent.tsx +2 -3
- package/src/hooks/useFormatWatcher.ts +3 -0
- package/src/i18n/ar.json +16 -0
- package/src/i18n/en.json +16 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +2 -0
- package/src/plugins/ToolbarPlugin.tsx +34 -23
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -474
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1537
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -57
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -252
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -572
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -25
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1614
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -36
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -838
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1057
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -39
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -45
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -4207
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -68
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1166
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -47
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -81
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -465
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1512
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -251
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -563
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1595
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -830
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -1028
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -28
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -4156
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -1102
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -32
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/cjs/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
- /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
- /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/esm/{packages/lexical/src/nodes → nodes}/StickyNode.js +0 -0
- /package/dist/esm/{packages/lexical/src/plugins → plugins}/StickyPlugin.js +0 -0
- /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
|
@@ -1,572 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var LexicalUtils = require('../utils/LexicalUtils.js');
|
|
4
|
-
var lexical = require('lexical');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
17
|
-
*
|
|
18
|
-
* This source code is licensed under the MIT license found in the
|
|
19
|
-
* LICENSE file in the root directory of this source tree.
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
// Do not require this module directly! Use normal `invariant` calls.
|
|
24
|
-
|
|
25
|
-
function formatDevErrorMessage(message) {
|
|
26
|
-
throw new Error(message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const SUPPORTED_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'sms:', 'tel:']);
|
|
30
|
-
|
|
31
|
-
/** @noInheritDoc */
|
|
32
|
-
class LinkNode extends lexical.ElementNode {
|
|
33
|
-
/** @internal */
|
|
34
|
-
|
|
35
|
-
/** @internal */
|
|
36
|
-
|
|
37
|
-
/** @internal */
|
|
38
|
-
|
|
39
|
-
/** @internal */
|
|
40
|
-
|
|
41
|
-
static getType() {
|
|
42
|
-
return 'link';
|
|
43
|
-
}
|
|
44
|
-
static clone(node) {
|
|
45
|
-
return new LinkNode(node.__url, {
|
|
46
|
-
rel: node.__rel,
|
|
47
|
-
target: node.__target,
|
|
48
|
-
title: node.__title
|
|
49
|
-
}, node.__key);
|
|
50
|
-
}
|
|
51
|
-
constructor(url = '', attributes = {}, key) {
|
|
52
|
-
super(key);
|
|
53
|
-
const {
|
|
54
|
-
target = null,
|
|
55
|
-
rel = null,
|
|
56
|
-
title = null
|
|
57
|
-
} = attributes;
|
|
58
|
-
this.__url = url;
|
|
59
|
-
this.__target = target;
|
|
60
|
-
this.__rel = rel;
|
|
61
|
-
this.__title = title;
|
|
62
|
-
}
|
|
63
|
-
createDOM(config) {
|
|
64
|
-
const element = document.createElement('a');
|
|
65
|
-
this.updateLinkDOM(null, element, config);
|
|
66
|
-
LexicalUtils.addClassNamesToElement(element, config.theme.link);
|
|
67
|
-
return element;
|
|
68
|
-
}
|
|
69
|
-
updateLinkDOM(prevNode, anchor, config) {
|
|
70
|
-
if (LexicalUtils.isHTMLAnchorElement(anchor)) {
|
|
71
|
-
if (!prevNode || prevNode.__url !== this.__url) {
|
|
72
|
-
anchor.href = this.sanitizeUrl(this.__url);
|
|
73
|
-
}
|
|
74
|
-
for (const attr of ['target', 'rel', 'title']) {
|
|
75
|
-
const key = `__${attr}`;
|
|
76
|
-
const value = this[key];
|
|
77
|
-
if (!prevNode || prevNode[key] !== value) {
|
|
78
|
-
if (value) {
|
|
79
|
-
anchor[attr] = value;
|
|
80
|
-
} else {
|
|
81
|
-
anchor.removeAttribute(attr);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
updateDOM(prevNode, anchor, config) {
|
|
88
|
-
this.updateLinkDOM(prevNode, anchor, config);
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
static importDOM() {
|
|
92
|
-
return {
|
|
93
|
-
a: node => ({
|
|
94
|
-
conversion: $convertAnchorElement,
|
|
95
|
-
priority: 1
|
|
96
|
-
})
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
static importJSON(serializedNode) {
|
|
100
|
-
return $createLinkNode().updateFromJSON(serializedNode);
|
|
101
|
-
}
|
|
102
|
-
updateFromJSON(serializedNode) {
|
|
103
|
-
return super.updateFromJSON(serializedNode).setURL(serializedNode.url).setRel(serializedNode.rel || null).setTarget(serializedNode.target || null).setTitle(serializedNode.title || null);
|
|
104
|
-
}
|
|
105
|
-
sanitizeUrl(url) {
|
|
106
|
-
url = formatUrl(url);
|
|
107
|
-
try {
|
|
108
|
-
const parsedUrl = new URL(formatUrl(url));
|
|
109
|
-
// eslint-disable-next-line no-script-url
|
|
110
|
-
if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) {
|
|
111
|
-
return 'about:blank';
|
|
112
|
-
}
|
|
113
|
-
} catch (_unused) {
|
|
114
|
-
return url;
|
|
115
|
-
}
|
|
116
|
-
return url;
|
|
117
|
-
}
|
|
118
|
-
exportJSON() {
|
|
119
|
-
return {
|
|
120
|
-
...super.exportJSON(),
|
|
121
|
-
rel: this.getRel(),
|
|
122
|
-
target: this.getTarget(),
|
|
123
|
-
title: this.getTitle(),
|
|
124
|
-
url: this.getURL()
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
getURL() {
|
|
128
|
-
return this.getLatest().__url;
|
|
129
|
-
}
|
|
130
|
-
setURL(url) {
|
|
131
|
-
const writable = this.getWritable();
|
|
132
|
-
writable.__url = url;
|
|
133
|
-
return writable;
|
|
134
|
-
}
|
|
135
|
-
getTarget() {
|
|
136
|
-
return this.getLatest().__target;
|
|
137
|
-
}
|
|
138
|
-
setTarget(target) {
|
|
139
|
-
const writable = this.getWritable();
|
|
140
|
-
writable.__target = target;
|
|
141
|
-
return writable;
|
|
142
|
-
}
|
|
143
|
-
getRel() {
|
|
144
|
-
return this.getLatest().__rel;
|
|
145
|
-
}
|
|
146
|
-
setRel(rel) {
|
|
147
|
-
const writable = this.getWritable();
|
|
148
|
-
writable.__rel = rel;
|
|
149
|
-
return writable;
|
|
150
|
-
}
|
|
151
|
-
getTitle() {
|
|
152
|
-
return this.getLatest().__title;
|
|
153
|
-
}
|
|
154
|
-
setTitle(title) {
|
|
155
|
-
const writable = this.getWritable();
|
|
156
|
-
writable.__title = title;
|
|
157
|
-
return writable;
|
|
158
|
-
}
|
|
159
|
-
insertNewAfter(_, restoreSelection = true) {
|
|
160
|
-
const linkNode = $createLinkNode(this.__url, {
|
|
161
|
-
rel: this.__rel,
|
|
162
|
-
target: this.__target,
|
|
163
|
-
title: this.__title
|
|
164
|
-
});
|
|
165
|
-
this.insertAfter(linkNode, restoreSelection);
|
|
166
|
-
return linkNode;
|
|
167
|
-
}
|
|
168
|
-
canInsertTextBefore() {
|
|
169
|
-
return false;
|
|
170
|
-
}
|
|
171
|
-
canInsertTextAfter() {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
canBeEmpty() {
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
isInline() {
|
|
178
|
-
return true;
|
|
179
|
-
}
|
|
180
|
-
extractWithChild(child, selection, destination) {
|
|
181
|
-
if (!lexical.$isRangeSelection(selection)) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
const anchorNode = selection.anchor.getNode();
|
|
185
|
-
const focusNode = selection.focus.getNode();
|
|
186
|
-
return this.isParentOf(anchorNode) && this.isParentOf(focusNode) && selection.getTextContent().length > 0;
|
|
187
|
-
}
|
|
188
|
-
isEmailURI() {
|
|
189
|
-
return this.__url.startsWith('mailto:');
|
|
190
|
-
}
|
|
191
|
-
isWebSiteURI() {
|
|
192
|
-
return this.__url.startsWith('https://') || this.__url.startsWith('http://');
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function $convertAnchorElement(domNode) {
|
|
196
|
-
let node = null;
|
|
197
|
-
if (LexicalUtils.isHTMLAnchorElement(domNode)) {
|
|
198
|
-
const content = domNode.textContent;
|
|
199
|
-
if (content !== null && content !== '' || domNode.children.length > 0) {
|
|
200
|
-
node = $createLinkNode(domNode.getAttribute('href') || '', {
|
|
201
|
-
rel: domNode.getAttribute('rel'),
|
|
202
|
-
target: domNode.getAttribute('target'),
|
|
203
|
-
title: domNode.getAttribute('title')
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
return {
|
|
208
|
-
node
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Takes a URL and creates a LinkNode.
|
|
214
|
-
* @param url - The URL the LinkNode should direct to.
|
|
215
|
-
* @param attributes - Optional HTML a tag attributes \\{ target, rel, title \\}
|
|
216
|
-
* @returns The LinkNode.
|
|
217
|
-
*/
|
|
218
|
-
function $createLinkNode(url = '', attributes) {
|
|
219
|
-
return lexical.$applyNodeReplacement(new LinkNode(url, attributes));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Determines if node is a LinkNode.
|
|
224
|
-
* @param node - The node to be checked.
|
|
225
|
-
* @returns true if node is a LinkNode, false otherwise.
|
|
226
|
-
*/
|
|
227
|
-
function $isLinkNode(node) {
|
|
228
|
-
return node instanceof LinkNode;
|
|
229
|
-
}
|
|
230
|
-
// Custom node type to override `canInsertTextAfter` that will
|
|
231
|
-
// allow typing within the link
|
|
232
|
-
class AutoLinkNode extends LinkNode {
|
|
233
|
-
/** @internal */
|
|
234
|
-
/** Indicates whether the autolink was ever unlinked. **/
|
|
235
|
-
|
|
236
|
-
constructor(url = '', attributes = {}, key) {
|
|
237
|
-
super(url, attributes, key);
|
|
238
|
-
this.__isUnlinked = attributes.isUnlinked !== undefined && attributes.isUnlinked !== null ? attributes.isUnlinked : false;
|
|
239
|
-
}
|
|
240
|
-
static getType() {
|
|
241
|
-
return 'autolink';
|
|
242
|
-
}
|
|
243
|
-
static clone(node) {
|
|
244
|
-
return new AutoLinkNode(node.__url, {
|
|
245
|
-
isUnlinked: node.__isUnlinked,
|
|
246
|
-
rel: node.__rel,
|
|
247
|
-
target: node.__target,
|
|
248
|
-
title: node.__title
|
|
249
|
-
}, node.__key);
|
|
250
|
-
}
|
|
251
|
-
getIsUnlinked() {
|
|
252
|
-
return this.__isUnlinked;
|
|
253
|
-
}
|
|
254
|
-
setIsUnlinked(value) {
|
|
255
|
-
const self = this.getWritable();
|
|
256
|
-
self.__isUnlinked = value;
|
|
257
|
-
return self;
|
|
258
|
-
}
|
|
259
|
-
createDOM(config) {
|
|
260
|
-
if (this.__isUnlinked) {
|
|
261
|
-
return document.createElement('span');
|
|
262
|
-
} else {
|
|
263
|
-
return super.createDOM(config);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
updateDOM(prevNode, anchor, config) {
|
|
267
|
-
return super.updateDOM(prevNode, anchor, config) || prevNode.__isUnlinked !== this.__isUnlinked;
|
|
268
|
-
}
|
|
269
|
-
static importJSON(serializedNode) {
|
|
270
|
-
return $createAutoLinkNode().updateFromJSON(serializedNode);
|
|
271
|
-
}
|
|
272
|
-
updateFromJSON(serializedNode) {
|
|
273
|
-
return super.updateFromJSON(serializedNode).setIsUnlinked(serializedNode.isUnlinked || false);
|
|
274
|
-
}
|
|
275
|
-
static importDOM() {
|
|
276
|
-
// TODO: Should link node should handle the import over autolink?
|
|
277
|
-
return null;
|
|
278
|
-
}
|
|
279
|
-
exportJSON() {
|
|
280
|
-
return {
|
|
281
|
-
...super.exportJSON(),
|
|
282
|
-
isUnlinked: this.__isUnlinked
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
insertNewAfter(selection, restoreSelection = true) {
|
|
286
|
-
const element = this.getParentOrThrow().insertNewAfter(selection, restoreSelection);
|
|
287
|
-
if (lexical.$isElementNode(element)) {
|
|
288
|
-
const linkNode = $createAutoLinkNode(this.__url, {
|
|
289
|
-
isUnlinked: this.__isUnlinked,
|
|
290
|
-
rel: this.__rel,
|
|
291
|
-
target: this.__target,
|
|
292
|
-
title: this.__title
|
|
293
|
-
});
|
|
294
|
-
element.append(linkNode);
|
|
295
|
-
return linkNode;
|
|
296
|
-
}
|
|
297
|
-
return null;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Takes a URL and creates an AutoLinkNode. AutoLinkNodes are generally automatically generated
|
|
303
|
-
* during typing, which is especially useful when a button to generate a LinkNode is not practical.
|
|
304
|
-
* @param url - The URL the LinkNode should direct to.
|
|
305
|
-
* @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
|
|
306
|
-
* @returns The LinkNode.
|
|
307
|
-
*/
|
|
308
|
-
function $createAutoLinkNode(url = '', attributes) {
|
|
309
|
-
return lexical.$applyNodeReplacement(new AutoLinkNode(url, attributes));
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Determines if node is an AutoLinkNode.
|
|
314
|
-
* @param node - The node to be checked.
|
|
315
|
-
* @returns true if node is an AutoLinkNode, false otherwise.
|
|
316
|
-
*/
|
|
317
|
-
function $isAutoLinkNode(node) {
|
|
318
|
-
return node instanceof AutoLinkNode;
|
|
319
|
-
}
|
|
320
|
-
const TOGGLE_LINK_COMMAND = lexical.createCommand('TOGGLE_LINK_COMMAND');
|
|
321
|
-
function $getPointNode(point, offset) {
|
|
322
|
-
if (point.type === 'element') {
|
|
323
|
-
const node = point.getNode();
|
|
324
|
-
if (!lexical.$isElementNode(node)) {
|
|
325
|
-
formatDevErrorMessage(`$getPointNode: element point is not an ElementNode`);
|
|
326
|
-
}
|
|
327
|
-
const childNode = node.getChildren()[point.offset + offset];
|
|
328
|
-
return childNode || null;
|
|
329
|
-
}
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* Preserve the logical start/end of a RangeSelection in situations where
|
|
335
|
-
* the point is an element that may be reparented in the callback.
|
|
336
|
-
*
|
|
337
|
-
* @param $fn The function to run
|
|
338
|
-
* @returns The result of the callback
|
|
339
|
-
*/
|
|
340
|
-
function $withSelectedNodes($fn) {
|
|
341
|
-
const initialSelection = lexical.$getSelection();
|
|
342
|
-
if (!lexical.$isRangeSelection(initialSelection)) {
|
|
343
|
-
return $fn();
|
|
344
|
-
}
|
|
345
|
-
const normalized = lexical.$normalizeSelection__EXPERIMENTAL(initialSelection);
|
|
346
|
-
const isBackwards = normalized.isBackward();
|
|
347
|
-
const anchorNode = $getPointNode(normalized.anchor, isBackwards ? -1 : 0);
|
|
348
|
-
const focusNode = $getPointNode(normalized.focus, isBackwards ? 0 : -1);
|
|
349
|
-
const rval = $fn();
|
|
350
|
-
if (anchorNode || focusNode) {
|
|
351
|
-
const updatedSelection = lexical.$getSelection();
|
|
352
|
-
if (lexical.$isRangeSelection(updatedSelection)) {
|
|
353
|
-
const finalSelection = updatedSelection.clone();
|
|
354
|
-
if (anchorNode) {
|
|
355
|
-
const anchorParent = anchorNode.getParent();
|
|
356
|
-
if (anchorParent) {
|
|
357
|
-
finalSelection.anchor.set(anchorParent.getKey(), anchorNode.getIndexWithinParent() + (isBackwards ? 1 : 0), 'element');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
if (focusNode) {
|
|
361
|
-
const focusParent = focusNode.getParent();
|
|
362
|
-
if (focusParent) {
|
|
363
|
-
finalSelection.focus.set(focusParent.getKey(), focusNode.getIndexWithinParent() + (isBackwards ? 0 : 1), 'element');
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
lexical.$setSelection(lexical.$normalizeSelection__EXPERIMENTAL(finalSelection));
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return rval;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* Generates or updates a LinkNode. It can also delete a LinkNode if the URL is null,
|
|
374
|
-
* but saves any children and brings them up to the parent node.
|
|
375
|
-
* @param url - The URL the link directs to.
|
|
376
|
-
* @param attributes - Optional HTML a tag attributes. \\{ target, rel, title \\}
|
|
377
|
-
*/
|
|
378
|
-
function $toggleLink(url, attributes = {}) {
|
|
379
|
-
const {
|
|
380
|
-
target,
|
|
381
|
-
title
|
|
382
|
-
} = attributes;
|
|
383
|
-
const rel = attributes.rel === undefined ? 'noreferrer' : attributes.rel;
|
|
384
|
-
const selection = lexical.$getSelection();
|
|
385
|
-
if (selection === null || !lexical.$isRangeSelection(selection) && !lexical.$isNodeSelection(selection)) {
|
|
386
|
-
return;
|
|
387
|
-
}
|
|
388
|
-
if (lexical.$isNodeSelection(selection)) {
|
|
389
|
-
const nodes = selection.getNodes();
|
|
390
|
-
if (nodes.length === 0) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Handle all selected nodes
|
|
395
|
-
nodes.forEach(node => {
|
|
396
|
-
if (url === null) {
|
|
397
|
-
// Remove link
|
|
398
|
-
const linkParent = LexicalUtils.$findMatchingParent(node, parent => !$isAutoLinkNode(parent) && $isLinkNode(parent));
|
|
399
|
-
if (linkParent) {
|
|
400
|
-
linkParent.insertBefore(node);
|
|
401
|
-
if (linkParent.getChildren().length === 0) {
|
|
402
|
-
linkParent.remove();
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
} else {
|
|
406
|
-
// Add/Update link
|
|
407
|
-
const existingLink = LexicalUtils.$findMatchingParent(node, parent => !$isAutoLinkNode(parent) && $isLinkNode(parent));
|
|
408
|
-
if (existingLink) {
|
|
409
|
-
existingLink.setURL(url);
|
|
410
|
-
if (target !== undefined) {
|
|
411
|
-
existingLink.setTarget(target);
|
|
412
|
-
}
|
|
413
|
-
if (rel !== undefined) {
|
|
414
|
-
existingLink.setRel(rel);
|
|
415
|
-
}
|
|
416
|
-
} else {
|
|
417
|
-
const linkNode = $createLinkNode(url, {
|
|
418
|
-
rel,
|
|
419
|
-
target
|
|
420
|
-
});
|
|
421
|
-
node.insertBefore(linkNode);
|
|
422
|
-
linkNode.append(node);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Handle RangeSelection
|
|
430
|
-
const nodes = selection.extract();
|
|
431
|
-
if (url === null) {
|
|
432
|
-
// Remove LinkNodes
|
|
433
|
-
nodes.forEach(node => {
|
|
434
|
-
const parentLink = LexicalUtils.$findMatchingParent(node, parent => !$isAutoLinkNode(parent) && $isLinkNode(parent));
|
|
435
|
-
if (parentLink) {
|
|
436
|
-
const children = parentLink.getChildren();
|
|
437
|
-
for (let i = 0; i < children.length; i++) {
|
|
438
|
-
parentLink.insertBefore(children[i]);
|
|
439
|
-
}
|
|
440
|
-
parentLink.remove();
|
|
441
|
-
}
|
|
442
|
-
});
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
const updatedNodes = new Set();
|
|
446
|
-
const updateLinkNode = linkNode => {
|
|
447
|
-
if (updatedNodes.has(linkNode.getKey())) {
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
updatedNodes.add(linkNode.getKey());
|
|
451
|
-
linkNode.setURL(url);
|
|
452
|
-
if (target !== undefined) {
|
|
453
|
-
linkNode.setTarget(target);
|
|
454
|
-
}
|
|
455
|
-
if (rel !== undefined) {
|
|
456
|
-
linkNode.setRel(rel);
|
|
457
|
-
}
|
|
458
|
-
if (title !== undefined) {
|
|
459
|
-
linkNode.setTitle(title);
|
|
460
|
-
}
|
|
461
|
-
};
|
|
462
|
-
// Add or merge LinkNodes
|
|
463
|
-
if (nodes.length === 1) {
|
|
464
|
-
const firstNode = nodes[0];
|
|
465
|
-
// if the first node is a LinkNode or if its
|
|
466
|
-
// parent is a LinkNode, we update the URL, target and rel.
|
|
467
|
-
const linkNode = $getAncestor(firstNode, $isLinkNode);
|
|
468
|
-
if (linkNode !== null) {
|
|
469
|
-
return updateLinkNode(linkNode);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
$withSelectedNodes(() => {
|
|
473
|
-
let linkNode = null;
|
|
474
|
-
for (const node of nodes) {
|
|
475
|
-
if (!node.isAttached()) {
|
|
476
|
-
continue;
|
|
477
|
-
}
|
|
478
|
-
const parentLinkNode = $getAncestor(node, $isLinkNode);
|
|
479
|
-
if (parentLinkNode) {
|
|
480
|
-
updateLinkNode(parentLinkNode);
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
if (lexical.$isElementNode(node)) {
|
|
484
|
-
if (!node.isInline()) {
|
|
485
|
-
// Ignore block nodes, if there are any children we will see them
|
|
486
|
-
// later and wrap in a new LinkNode
|
|
487
|
-
continue;
|
|
488
|
-
}
|
|
489
|
-
if ($isLinkNode(node)) {
|
|
490
|
-
// If it's not an autolink node and we don't already have a LinkNode
|
|
491
|
-
// in this block then we can update it and re-use it
|
|
492
|
-
if (!$isAutoLinkNode(node) && (linkNode === null || !linkNode.getParentOrThrow().isParentOf(node))) {
|
|
493
|
-
updateLinkNode(node);
|
|
494
|
-
linkNode = node;
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
497
|
-
// Unwrap LinkNode, we already have one or it's an AutoLinkNode
|
|
498
|
-
for (const child of node.getChildren()) {
|
|
499
|
-
node.insertBefore(child);
|
|
500
|
-
}
|
|
501
|
-
node.remove();
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
const prevLinkNode = node.getPreviousSibling();
|
|
506
|
-
if ($isLinkNode(prevLinkNode) && prevLinkNode.is(linkNode)) {
|
|
507
|
-
prevLinkNode.append(node);
|
|
508
|
-
continue;
|
|
509
|
-
}
|
|
510
|
-
linkNode = $createLinkNode(url, {
|
|
511
|
-
rel,
|
|
512
|
-
target,
|
|
513
|
-
title
|
|
514
|
-
});
|
|
515
|
-
node.insertAfter(linkNode);
|
|
516
|
-
linkNode.append(node);
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
}
|
|
520
|
-
/** @deprecated renamed to {@link $toggleLink} by @lexical/eslint-plugin rules-of-lexical */
|
|
521
|
-
const toggleLink = $toggleLink;
|
|
522
|
-
function $getAncestor(node, predicate) {
|
|
523
|
-
let parent = node;
|
|
524
|
-
while (parent !== null && parent.getParent() !== null && !predicate(parent)) {
|
|
525
|
-
parent = parent.getParentOrThrow();
|
|
526
|
-
}
|
|
527
|
-
return predicate(parent) ? parent : null;
|
|
528
|
-
}
|
|
529
|
-
const PHONE_NUMBER_REGEX = /^\+?[0-9\s()-]{5,}$/;
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Formats a URL string by adding appropriate protocol if missing
|
|
533
|
-
*
|
|
534
|
-
* @param url - URL to format
|
|
535
|
-
* @returns Formatted URL with appropriate protocol
|
|
536
|
-
*/
|
|
537
|
-
function formatUrl(url) {
|
|
538
|
-
// Check if URL already has a protocol
|
|
539
|
-
if (url.match(/^[a-z][a-z0-9+.-]*:/i)) {
|
|
540
|
-
// URL already has a protocol, leave it as is
|
|
541
|
-
return url;
|
|
542
|
-
}
|
|
543
|
-
// Check if it's a relative path (starting with '/', '.', or '#')
|
|
544
|
-
else if (url.match(/^[/#.]/)) {
|
|
545
|
-
// Relative path, leave it as is
|
|
546
|
-
return url;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// Check for email address
|
|
550
|
-
else if (url.includes('@')) {
|
|
551
|
-
return `mailto:${url}`;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
// Check for phone number
|
|
555
|
-
else if (PHONE_NUMBER_REGEX.test(url)) {
|
|
556
|
-
return `tel:${url}`;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
// For everything else, return with https:// prefix
|
|
560
|
-
return `https://${url}`;
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
exports.$createAutoLinkNode = $createAutoLinkNode;
|
|
564
|
-
exports.$createLinkNode = $createLinkNode;
|
|
565
|
-
exports.$isAutoLinkNode = $isAutoLinkNode;
|
|
566
|
-
exports.$isLinkNode = $isLinkNode;
|
|
567
|
-
exports.$toggleLink = $toggleLink;
|
|
568
|
-
exports.AutoLinkNode = AutoLinkNode;
|
|
569
|
-
exports.LinkNode = LinkNode;
|
|
570
|
-
exports.TOGGLE_LINK_COMMAND = TOGGLE_LINK_COMMAND;
|
|
571
|
-
exports.formatUrl = formatUrl;
|
|
572
|
-
exports.toggleLink = toggleLink;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var LexicalLink_dev = require('./LexicalLink.dev.js');
|
|
4
|
-
var LexicalLink_prod = require('./LexicalLink.prod.js');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const mod = process.env.NODE_ENV !== 'production' ? LexicalLink_dev : LexicalLink_prod;
|
|
15
|
-
const $isLinkNode = mod.$isLinkNode;
|
|
16
|
-
|
|
17
|
-
exports.$isLinkNode = $isLinkNode;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var LexicalUtils = require('../utils/LexicalUtils.js');
|
|
4
|
-
var lexical = require('lexical');
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the MIT license found in the
|
|
10
|
-
* LICENSE file in the root directory of this source tree.
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const h=new Set(["http:","https:","mailto:","sms:","tel:"]);class g extends lexical.ElementNode{static getType(){return "link"}static clone(t){return new g(t.__url,{rel:t.__rel,target:t.__target,title:t.__title},t.__key)}constructor(t="",e={},r){super(r);const{target:n=null,rel:i=null,title:s=null}=e;this.__url=t,this.__target=n,this.__rel=i,this.__title=s;}createDOM(e){const r=document.createElement("a");return this.updateLinkDOM(null,r,e),LexicalUtils.addClassNamesToElement(r,e.theme.link),r}updateLinkDOM(t,r,n){if(LexicalUtils.isHTMLAnchorElement(r)){t&&t.__url===this.__url||(r.href=this.sanitizeUrl(this.__url));for(const e of ["target","rel","title"]){const n=`__${e}`,i=this[n];t&&t[n]===i||(i?r[e]=i:r.removeAttribute(e));}}}updateDOM(t,e,r){return this.updateLinkDOM(t,e,r),!1}static importDOM(){return {a:t=>({conversion:f,priority:1})}}static importJSON(t){return d().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setURL(t.url).setRel(t.rel||null).setTarget(t.target||null).setTitle(t.title||null)}sanitizeUrl(t){t=S(t);try{const e=new URL(S(t));if(!h.has(e.protocol))return "about:blank"}catch(e){return t}return t}exportJSON(){return {...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(t){const e=this.getWritable();return e.__url=t,e}getTarget(){return this.getLatest().__target}setTarget(t){const e=this.getWritable();return e.__target=t,e}getRel(){return this.getLatest().__rel}setRel(t){const e=this.getWritable();return e.__rel=t,e}getTitle(){return this.getLatest().__title}setTitle(t){const e=this.getWritable();return e.__title=t,e}insertNewAfter(t,e=!0){const r=d(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,e),r}canInsertTextBefore(){return !1}canInsertTextAfter(){return !1}canBeEmpty(){return !1}isInline(){return !0}extractWithChild(t,e,r){if(!lexical.$isRangeSelection(e))return !1;const n=e.anchor.getNode(),i=e.focus.getNode();return this.isParentOf(n)&&this.isParentOf(i)&&e.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function f(t){let r=null;if(LexicalUtils.isHTMLAnchorElement(t)){const e=t.textContent;(null!==e&&""!==e||t.children.length>0)&&(r=d(t.getAttribute("href")||"",{rel:t.getAttribute("rel"),target:t.getAttribute("target"),title:t.getAttribute("title")}));}return {node:r}}function d(t="",e){return lexical.$applyNodeReplacement(new g(t,e))}function p(t){return t instanceof g}class m extends g{constructor(t="",e={},r){super(t,e,r),this.__isUnlinked=void 0!==e.isUnlinked&&null!==e.isUnlinked&&e.isUnlinked;}static getType(){return "autolink"}static clone(t){return new m(t.__url,{isUnlinked:t.__isUnlinked,rel:t.__rel,target:t.__target,title:t.__title},t.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(t){const e=this.getWritable();return e.__isUnlinked=t,e}createDOM(t){return this.__isUnlinked?document.createElement("span"):super.createDOM(t)}updateDOM(t,e,r){return super.updateDOM(t,e,r)||t.__isUnlinked!==this.__isUnlinked}static importJSON(t){return U().updateFromJSON(t)}updateFromJSON(t){return super.updateFromJSON(t).setIsUnlinked(t.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return {...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(t,e=!0){const r=this.getParentOrThrow().insertNewAfter(t,e);if(lexical.$isElementNode(r)){const t=U(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return r.append(t),t}return null}}function U(t="",e){return lexical.$applyNodeReplacement(new m(t,e))}function O(t){return t instanceof m}const k=lexical.createCommand("TOGGLE_LINK_COMMAND");function N(t,e){if("element"===t.type){const r=t.getNode();lexical.$isElementNode(r)||function(t,...e){const r=new URL("https://lexical.dev/docs/error"),n=new URLSearchParams;n.append("code",t);for(const t of e)n.append("v",t);throw r.search=n.toString(),Error(`Minified Lexical error #${t}; visit ${r.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252);return r.getChildren()[t.offset+e]||null}return null}function v(t,e={}){const{target:n,title:i}=e,l=void 0===e.rel?"noreferrer":e.rel,h=lexical.$getSelection();if(null===h||!lexical.$isRangeSelection(h)&&!lexical.$isNodeSelection(h))return;if(lexical.$isNodeSelection(h)){const e=h.getNodes();if(0===e.length)return;return void e.forEach((e=>{if(null===t){const t=LexicalUtils.$findMatchingParent(e,(t=>!O(t)&&p(t)));t&&(t.insertBefore(e),0===t.getChildren().length&&t.remove());}else {const i=LexicalUtils.$findMatchingParent(e,(t=>!O(t)&&p(t)));if(i)i.setURL(t),void 0!==n&&i.setTarget(n),void 0!==l&&i.setRel(l);else {const r=d(t,{rel:l,target:n});e.insertBefore(r),r.append(e);}}}))}const g=h.extract();if(null===t)return void g.forEach((t=>{const e=LexicalUtils.$findMatchingParent(t,(t=>!O(t)&&p(t)));if(e){const t=e.getChildren();for(let r=0;r<t.length;r++)e.insertBefore(t[r]);e.remove();}}));const f=new Set,m=e=>{f.has(e.getKey())||(f.add(e.getKey()),e.setURL(t),void 0!==n&&e.setTarget(n),void 0!==l&&e.setRel(l),void 0!==i&&e.setTitle(i));};if(1===g.length){const t=x(g[0],p);if(null!==t)return m(t)}!function(t){const e=lexical.$getSelection();if(!lexical.$isRangeSelection(e))return t();const r=lexical.$normalizeSelection__EXPERIMENTAL(e),n=r.isBackward(),i=N(r.anchor,n?-1:0),l=N(r.focus,n?0:-1);t();if(i||l){const t=lexical.$getSelection();if(lexical.$isRangeSelection(t)){const e=t.clone();if(i){const t=i.getParent();t&&e.anchor.set(t.getKey(),i.getIndexWithinParent()+(n?1:0),"element");}if(l){const t=l.getParent();t&&e.focus.set(t.getKey(),l.getIndexWithinParent()+(n?0:1),"element");}lexical.$setSelection(lexical.$normalizeSelection__EXPERIMENTAL(e));}}}((()=>{let e=null;for(const r of g){if(!r.isAttached())continue;const s=x(r,p);if(s){m(s);continue}if(lexical.$isElementNode(r)){if(!r.isInline())continue;if(p(r)){if(!(O(r)||null!==e&&e.getParentOrThrow().isParentOf(r))){m(r),e=r;continue}for(const t of r.getChildren())r.insertBefore(t);r.remove();continue}}const u=r.getPreviousSibling();p(u)&&u.is(e)?u.append(r):(e=d(t,{rel:l,target:n,title:i}),r.insertAfter(e),e.append(r));}}));}const T=v;function x(t,e){let r=t;for(;null!==r&&null!==r.getParent()&&!e(r);)r=r.getParentOrThrow();return e(r)?r:null}const L=/^\+?[0-9\s()-]{5,}$/;function S(t){return t.match(/^[a-z][a-z0-9+.-]*:/i)||t.match(/^[/#.]/)?t:t.includes("@")?`mailto:${t}`:L.test(t)?`tel:${t}`:`https://${t}`}
|
|
15
|
-
|
|
16
|
-
exports.$createAutoLinkNode = U;
|
|
17
|
-
exports.$createLinkNode = d;
|
|
18
|
-
exports.$isAutoLinkNode = O;
|
|
19
|
-
exports.$isLinkNode = p;
|
|
20
|
-
exports.$toggleLink = v;
|
|
21
|
-
exports.AutoLinkNode = m;
|
|
22
|
-
exports.LinkNode = g;
|
|
23
|
-
exports.TOGGLE_LINK_COMMAND = k;
|
|
24
|
-
exports.formatUrl = S;
|
|
25
|
-
exports.toggleLink = T;
|