@lobehub/editor 4.2.0 → 4.3.1
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export * from './plugin';
|
|
2
2
|
export * from './react';
|
|
3
|
-
export type { ISlashService, SlashOptions } from './service/i-slash-service';
|
|
3
|
+
export type { ISlashMenuOption, ISlashService, SlashOptions } from './service/i-slash-service';
|
|
4
|
+
export type { ISlashOption } from './service/i-slash-service';
|
|
@@ -14,6 +14,27 @@ function sanitizeUrl(url) {
|
|
|
14
14
|
}
|
|
15
15
|
return url;
|
|
16
16
|
}
|
|
17
|
+
function formatLinkHighlightUrl(url) {
|
|
18
|
+
if (/^[a-z][\d+.a-z-]*:/i.test(url)) {
|
|
19
|
+
return url;
|
|
20
|
+
}
|
|
21
|
+
if (/^[#./]/.test(url)) {
|
|
22
|
+
return url;
|
|
23
|
+
}
|
|
24
|
+
if (url.includes('@') && !url.startsWith('mailto:')) {
|
|
25
|
+
return "mailto:".concat(url);
|
|
26
|
+
}
|
|
27
|
+
if (/^\+?[\d\s()-]{5,}$/.test(url)) {
|
|
28
|
+
return "tel:".concat(url);
|
|
29
|
+
}
|
|
30
|
+
if (url.startsWith('www.')) {
|
|
31
|
+
return "https://".concat(url);
|
|
32
|
+
}
|
|
33
|
+
if (!url.includes('://')) {
|
|
34
|
+
return "https://".concat(url);
|
|
35
|
+
}
|
|
36
|
+
return url;
|
|
37
|
+
}
|
|
17
38
|
function textToSlug(text) {
|
|
18
39
|
return text.toLowerCase().trim().replaceAll(/[^\s\w\u3000-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF-]/g, '').replaceAll(/[\s_]+/g, '-').replaceAll(/^-+|-+$/g, '');
|
|
19
40
|
}
|
|
@@ -101,6 +122,16 @@ export function renderBuiltinNode(node, key, children, headingSlugs, textContent
|
|
|
101
122
|
children: children
|
|
102
123
|
}, key);
|
|
103
124
|
}
|
|
125
|
+
case 'linkHighlight':
|
|
126
|
+
{
|
|
127
|
+
var url = textContent ? sanitizeUrl(formatLinkHighlightUrl(textContent)) : undefined;
|
|
128
|
+
return /*#__PURE__*/_jsx("a", {
|
|
129
|
+
href: url,
|
|
130
|
+
rel: "noopener noreferrer",
|
|
131
|
+
target: "_blank",
|
|
132
|
+
children: children
|
|
133
|
+
}, key);
|
|
134
|
+
}
|
|
104
135
|
case 'table':
|
|
105
136
|
{
|
|
106
137
|
return /*#__PURE__*/_jsx("div", {
|
package/package.json
CHANGED