@nextblock-cms/cortex 0.20.1 → 0.21.0
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/client.cjs.js +1 -1
- package/client.es.js +3 -7
- package/index.cjs.js +1 -1
- package/index.es.js +24 -277
- package/lib/ai-block-generation.cjs.js +3 -4
- package/lib/ai-block-generation.es.js +143 -182
- package/lib/ai-client.cjs.js +1 -1
- package/lib/ai-client.d.ts +1 -1
- package/lib/ai-client.es.js +101 -135
- package/lib/ai-config.cjs.js +1 -1
- package/lib/ai-config.es.js +89 -108
- package/lib/ai-cortex-widget-builder.cjs.js +1 -1
- package/lib/ai-cortex-widget-builder.es.js +56 -70
- package/lib/ai-global-agent-content-ops-tools.cjs.js +1 -1
- package/lib/ai-global-agent-content-ops-tools.d.ts +1943 -68
- package/lib/ai-global-agent-content-ops-tools.es.js +185 -199
- package/lib/ai-global-agent-custom-block-tools.cjs.js +1 -1
- package/lib/ai-global-agent-custom-block-tools.d.ts +2160 -95
- package/lib/ai-global-agent-custom-block-tools.es.js +226 -223
- package/lib/ai-global-agent-db-tools.cjs.js +1 -1
- package/lib/ai-global-agent-db-tools.d.ts +2708 -98
- package/lib/ai-global-agent-db-tools.es.js +1013 -986
- package/lib/ai-global-agent-ecommerce.cjs.js +1 -1
- package/lib/ai-global-agent-ecommerce.es.js +3 -7
- package/lib/ai-global-agent-site-tools.cjs.js +2 -3
- package/lib/ai-global-agent-site-tools.d.ts +10695 -500
- package/lib/ai-global-agent-site-tools.es.js +750 -757
- package/lib/ai-global-agent-theming-tools.cjs.js +1 -3
- package/lib/ai-global-agent-theming-tools.d.ts +2905 -105
- package/lib/ai-global-agent-theming-tools.es.js +326 -396
- package/lib/ai-global-agent-tools.cjs.js +2 -2
- package/lib/ai-global-agent-tools.d.ts +4 -2230
- package/lib/ai-global-agent-tools.es.js +3899 -4328
- package/lib/ai-key-crypto.cjs.js +1 -1
- package/lib/ai-key-crypto.es.js +63 -82
- package/lib/ai-key-verification.cjs.js +1 -1
- package/lib/ai-key-verification.es.js +74 -63
- package/lib/ai-model-catalog.cjs.js +1 -1
- package/lib/ai-model-catalog.es.js +18 -22
- package/lib/ai-model-registry.cjs.js +2 -2
- package/lib/ai-model-registry.es.js +246 -309
- package/lib/ai-seo-metadata.cjs.js +2 -3
- package/lib/ai-seo-metadata.es.js +143 -185
- package/lib/ai-vision.cjs.js +2 -2
- package/lib/ai-vision.d.ts +6 -6
- package/lib/ai-vision.es.js +161 -215
- package/lib/block-content-schemas.cjs.js +1 -1
- package/lib/block-content-schemas.es.js +324 -254
- package/lib/cortex-widget-registry.cjs.js +1 -1
- package/lib/cortex-widget-registry.es.js +35 -43
- package/lib/cortex-widget-schema.cjs.js +2 -3
- package/lib/cortex-widget-schema.es.js +280 -309
- package/lib/editor-document-from-html.cjs.js +1 -1
- package/lib/editor-document-from-html.es.js +334 -278
- package/lib/fetch-host-guard.cjs.js +1 -0
- package/lib/fetch-host-guard.d.ts +2 -0
- package/lib/fetch-host-guard.es.js +30 -0
- package/lib/mcp-server.cjs.js +1 -1
- package/lib/mcp-server.es.js +155 -173
- package/lib/mcp-tokens.cjs.js +1 -1
- package/lib/mcp-tokens.es.js +95 -107
- package/lib/mcp-tool-registry.cjs.js +5 -6
- package/lib/mcp-tool-registry.es.js +533 -411
- package/lib/site-brief.cjs.js +2 -2
- package/lib/site-brief.es.js +102 -108
- package/lib/vision-image-download.cjs.js +1 -0
- package/lib/vision-image-download.d.ts +43 -0
- package/lib/vision-image-download.es.js +120 -0
- package/lib/zod-config.cjs.js +1 -1
- package/lib/zod-config.es.js +5 -6
- package/package.json +8 -8
|
@@ -1,290 +1,346 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
1
|
+
//#region libs/cortex/src/lib/editor-document-from-html.ts
|
|
2
|
+
var e = /* @__PURE__ */ new Set([
|
|
3
|
+
"area",
|
|
4
|
+
"base",
|
|
5
|
+
"br",
|
|
6
|
+
"col",
|
|
7
|
+
"embed",
|
|
8
|
+
"hr",
|
|
9
|
+
"img",
|
|
10
|
+
"input",
|
|
11
|
+
"link",
|
|
12
|
+
"meta",
|
|
13
|
+
"param",
|
|
14
|
+
"source",
|
|
15
|
+
"track",
|
|
16
|
+
"wbr"
|
|
17
|
+
]), t = {
|
|
18
|
+
b: "bold",
|
|
19
|
+
code: "code",
|
|
20
|
+
del: "strike",
|
|
21
|
+
em: "italic",
|
|
22
|
+
i: "italic",
|
|
23
|
+
mark: "highlight",
|
|
24
|
+
s: "strike",
|
|
25
|
+
strike: "strike",
|
|
26
|
+
strong: "bold",
|
|
27
|
+
sub: "subscript",
|
|
28
|
+
sup: "superscript"
|
|
29
|
+
}, n = /* @__PURE__ */ new Set([
|
|
30
|
+
"article",
|
|
31
|
+
"aside",
|
|
32
|
+
"body",
|
|
33
|
+
"div",
|
|
34
|
+
"footer",
|
|
35
|
+
"header",
|
|
36
|
+
"html",
|
|
37
|
+
"main",
|
|
38
|
+
"nav",
|
|
39
|
+
"section"
|
|
40
|
+
]), r = /* @__PURE__ */ new Set([
|
|
41
|
+
"script",
|
|
42
|
+
"style",
|
|
43
|
+
"noscript",
|
|
44
|
+
"svg",
|
|
45
|
+
"template",
|
|
46
|
+
"iframe",
|
|
47
|
+
"form"
|
|
48
|
+
]), i = 12;
|
|
49
|
+
function a(e) {
|
|
50
|
+
return e.replace(/ /gi, " ").replace(/</gi, "<").replace(/>/gi, ">").replace(/"/gi, "\"").replace(/�?39;/g, "'").replace(/'/gi, "'").replace(/&#(\d+);/g, (e, t) => String.fromCodePoint(Number(t))).replace(/&#x([0-9a-f]+);/gi, (e, t) => String.fromCodePoint(Number.parseInt(t, 16))).replace(/&/gi, "&");
|
|
42
51
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
47
|
-
return t ? u(t[1] ?? t[2] ?? t[3] ?? "") : null;
|
|
52
|
+
function o(e, t) {
|
|
53
|
+
let n = e.match(RegExp(`\\b${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
|
54
|
+
return n ? a(n[1] ?? n[2] ?? n[3] ?? "") : null;
|
|
48
55
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
56
|
+
function s(e, t, n) {
|
|
57
|
+
let r = RegExp(`<${n}\\b`, "gi"), i = RegExp(`</${n}\\s*>`, "gi"), a = 1, o = t;
|
|
58
|
+
for (; a > 0;) {
|
|
59
|
+
i.lastIndex = o;
|
|
60
|
+
let n = i.exec(e);
|
|
61
|
+
if (!n) return {
|
|
62
|
+
end: e.length,
|
|
63
|
+
inner: e.slice(t)
|
|
64
|
+
};
|
|
65
|
+
r.lastIndex = o;
|
|
66
|
+
let s = r.exec(e);
|
|
67
|
+
if (s && s.index < n.index) {
|
|
68
|
+
a += 1, o = s.index + s[0].length;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (--a, o = n.index + n[0].length, a === 0) return {
|
|
72
|
+
end: o,
|
|
73
|
+
inner: e.slice(t, n.index)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
end: o,
|
|
78
|
+
inner: e.slice(t)
|
|
79
|
+
};
|
|
67
80
|
}
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
81
|
+
function c(t) {
|
|
82
|
+
let n = [], r = 0;
|
|
83
|
+
for (; r < t.length;) {
|
|
84
|
+
let i = t.indexOf("<", r);
|
|
85
|
+
if (i === -1) {
|
|
86
|
+
n.push({
|
|
87
|
+
text: t.slice(r),
|
|
88
|
+
type: "text"
|
|
89
|
+
});
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
i > r && n.push({
|
|
93
|
+
text: t.slice(r, i),
|
|
94
|
+
type: "text"
|
|
95
|
+
});
|
|
96
|
+
let a = t.indexOf(">", i);
|
|
97
|
+
if (a === -1) {
|
|
98
|
+
n.push({
|
|
99
|
+
text: t.slice(i),
|
|
100
|
+
type: "text"
|
|
101
|
+
});
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
let o = t.slice(i + 1, a);
|
|
105
|
+
if (o.startsWith("!") || o.startsWith("/") || o.startsWith("?")) {
|
|
106
|
+
r = a + 1;
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
let c = o.match(/^([a-zA-Z][a-zA-Z0-9-]*)/);
|
|
110
|
+
if (!c) {
|
|
111
|
+
r = a + 1;
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
let l = c[1].toLowerCase();
|
|
115
|
+
if (e.has(l) || o.trimEnd().endsWith("/")) {
|
|
116
|
+
n.push({
|
|
117
|
+
attrs: o,
|
|
118
|
+
inner: "",
|
|
119
|
+
tag: l,
|
|
120
|
+
type: "element"
|
|
121
|
+
}), r = a + 1;
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
let u = s(t, a + 1, l);
|
|
125
|
+
n.push({
|
|
126
|
+
attrs: o,
|
|
127
|
+
inner: u.inner,
|
|
128
|
+
tag: l,
|
|
129
|
+
type: "element"
|
|
130
|
+
}), r = u.end;
|
|
131
|
+
}
|
|
132
|
+
return n;
|
|
102
133
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
134
|
+
function l(e, t, n) {
|
|
135
|
+
if (!t) return;
|
|
136
|
+
let r = e[e.length - 1];
|
|
137
|
+
if (r && r.type === "text" && JSON.stringify(r.marks ?? []) === JSON.stringify(n)) {
|
|
138
|
+
r.text += t;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
e.push(n.length > 0 ? {
|
|
142
|
+
marks: n,
|
|
143
|
+
text: t,
|
|
144
|
+
type: "text"
|
|
145
|
+
} : {
|
|
146
|
+
text: t,
|
|
147
|
+
type: "text"
|
|
148
|
+
});
|
|
112
149
|
}
|
|
113
|
-
function
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
function u(e, n, s) {
|
|
151
|
+
let d = [];
|
|
152
|
+
if (s > i) return l(d, a(e.replace(/<[^>]*>/g, "")).replace(/\s+/g, " "), n), d;
|
|
153
|
+
for (let i of c(e)) {
|
|
154
|
+
if (i.type === "text") {
|
|
155
|
+
l(d, a(i.text).replace(/\s+/g, " "), n);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (r.has(i.tag)) continue;
|
|
159
|
+
if (i.tag === "br") {
|
|
160
|
+
d.push({ type: "hardBreak" });
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (i.tag === "a") {
|
|
164
|
+
let e = o(i.attrs, "href"), t = e ? [...n, {
|
|
165
|
+
attrs: {
|
|
166
|
+
href: e,
|
|
167
|
+
target: "_blank"
|
|
168
|
+
},
|
|
169
|
+
type: "link"
|
|
170
|
+
}] : n;
|
|
171
|
+
d.push(...u(i.inner, t, s + 1));
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
let e = t[i.tag];
|
|
175
|
+
if (e) {
|
|
176
|
+
let t = n.some((t) => t.type === e) ? n : [...n, { type: e }];
|
|
177
|
+
d.push(...u(i.inner, t, s + 1));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
d.push(...u(i.inner, n, s + 1));
|
|
181
|
+
}
|
|
182
|
+
return d;
|
|
142
183
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
function d(e) {
|
|
185
|
+
let t = [...e];
|
|
186
|
+
for (; t.length > 0;) {
|
|
187
|
+
let e = t[0];
|
|
188
|
+
if (e.type === "hardBreak") {
|
|
189
|
+
t.shift();
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
let n = e.text.replace(/^\s+/, "");
|
|
193
|
+
if (!n) {
|
|
194
|
+
t.shift();
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
t[0] = {
|
|
198
|
+
...e,
|
|
199
|
+
text: n
|
|
200
|
+
};
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
for (; t.length > 0;) {
|
|
204
|
+
let e = t[t.length - 1];
|
|
205
|
+
if (e.type === "hardBreak") {
|
|
206
|
+
t.pop();
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
let n = e.text.replace(/\s+$/, "");
|
|
210
|
+
if (!n) {
|
|
211
|
+
t.pop();
|
|
212
|
+
continue;
|
|
213
|
+
}
|
|
214
|
+
t[t.length - 1] = {
|
|
215
|
+
...e,
|
|
216
|
+
text: n
|
|
217
|
+
};
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
return t;
|
|
174
221
|
}
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
222
|
+
function f(e) {
|
|
223
|
+
let t = d(e);
|
|
224
|
+
return t.length > 0 ? {
|
|
225
|
+
content: t,
|
|
226
|
+
type: "paragraph"
|
|
227
|
+
} : null;
|
|
178
228
|
}
|
|
179
|
-
function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return t;
|
|
229
|
+
function p(e, t) {
|
|
230
|
+
let n = [];
|
|
231
|
+
for (let r of c(e)) {
|
|
232
|
+
if (r.type !== "element" || r.tag !== "li") continue;
|
|
233
|
+
let e = m(r.inner, t + 1);
|
|
234
|
+
n.push({
|
|
235
|
+
content: e.length > 0 ? e : [{ type: "paragraph" }],
|
|
236
|
+
type: "listItem"
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
return n;
|
|
191
240
|
}
|
|
192
|
-
function
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
241
|
+
function m(e, t) {
|
|
242
|
+
let o = [];
|
|
243
|
+
if (t > i) return o;
|
|
244
|
+
let s = [], h = () => {
|
|
245
|
+
let e = f(s);
|
|
246
|
+
e && o.push(e), s = [];
|
|
247
|
+
};
|
|
248
|
+
for (let i of c(e)) {
|
|
249
|
+
if (i.type === "text") {
|
|
250
|
+
l(s, a(i.text).replace(/\s+/g, " "), []);
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
let { attrs: e, inner: c, tag: g } = i;
|
|
254
|
+
if (r.has(g)) continue;
|
|
255
|
+
let _ = g.match(/^h([1-6])$/);
|
|
256
|
+
if (_) {
|
|
257
|
+
h();
|
|
258
|
+
let e = d(u(c, [], t + 1));
|
|
259
|
+
e.length > 0 && o.push({
|
|
260
|
+
attrs: { level: Number(_[1]) },
|
|
261
|
+
content: e,
|
|
262
|
+
type: "heading"
|
|
263
|
+
});
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (g === "p") {
|
|
267
|
+
h();
|
|
268
|
+
let e = f(u(c, [], t + 1));
|
|
269
|
+
e && o.push(e);
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
if (g === "ul" || g === "ol") {
|
|
273
|
+
h();
|
|
274
|
+
let e = p(c, t);
|
|
275
|
+
e.length > 0 && o.push({
|
|
276
|
+
content: e,
|
|
277
|
+
type: g === "ul" ? "bulletList" : "orderedList"
|
|
278
|
+
});
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
if (g === "blockquote") {
|
|
282
|
+
h();
|
|
283
|
+
let e = m(c, t + 1);
|
|
284
|
+
e.length > 0 && o.push({
|
|
285
|
+
content: e,
|
|
286
|
+
type: "blockquote"
|
|
287
|
+
});
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
if (g === "pre") {
|
|
291
|
+
h();
|
|
292
|
+
let e = a(c.replace(/<[^>]*>/g, "")).replace(/^\n+|\n+$/g, "");
|
|
293
|
+
e && o.push({
|
|
294
|
+
content: [{
|
|
295
|
+
text: e,
|
|
296
|
+
type: "text"
|
|
297
|
+
}],
|
|
298
|
+
type: "codeBlock"
|
|
299
|
+
});
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if (g === "hr") {
|
|
303
|
+
h(), o.push({ type: "horizontalRule" });
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (g === "br") {
|
|
307
|
+
s.push({ type: "hardBreak" });
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (n.has(g) || g === "li" || g === "table") {
|
|
311
|
+
h(), o.push(...m(c, t + 1));
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
s.push(...u(`<${e}>${c}</${g}>`, [], t + 1));
|
|
315
|
+
}
|
|
316
|
+
return h(), o;
|
|
262
317
|
}
|
|
263
|
-
function
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
318
|
+
function h(e) {
|
|
319
|
+
return e.split(/\n\s*\n/).map((e) => e.trim()).filter(Boolean).map((e) => ({
|
|
320
|
+
content: [{
|
|
321
|
+
text: e.replace(/\s*\n\s*/g, " "),
|
|
322
|
+
type: "text"
|
|
323
|
+
}],
|
|
324
|
+
type: "paragraph"
|
|
325
|
+
}));
|
|
268
326
|
}
|
|
269
|
-
function
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
return { content: o, type: "doc" };
|
|
327
|
+
function g(e) {
|
|
328
|
+
let t = (typeof e == "string" ? e : "").trim().replace(/^```(?:html|xml)?\s*\n?/i, "").replace(/\n?```$/, "").trim();
|
|
329
|
+
if (!t) return null;
|
|
330
|
+
let n = [...r].reduce((e, t) => e.replace(RegExp(`<${t}\\b[\\s\\S]*?</${t}\\s*>`, "gi"), " "), t).trim();
|
|
331
|
+
if (!n) return null;
|
|
332
|
+
let i = /<[a-zA-Z!/]/.test(n) ? m(n, 0) : h(n);
|
|
333
|
+
if (i.length === 0) {
|
|
334
|
+
let e = h(a(n.replace(/<[^>]*>/g, " ")).replace(/[ \t]+/g, " "));
|
|
335
|
+
return e.length > 0 ? {
|
|
336
|
+
content: e,
|
|
337
|
+
type: "doc"
|
|
338
|
+
} : null;
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
content: i,
|
|
342
|
+
type: "doc"
|
|
343
|
+
};
|
|
287
344
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
};
|
|
345
|
+
//#endregion
|
|
346
|
+
export { g as editorDocumentFromHtml };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){let t=e.match(/^::ffff:(.+)$/i);if(!t)return null;let n=t[1];if(/^\d{1,3}(\.\d{1,3}){3}$/.test(n))return n;let r=n.match(/^([0-9a-f]{1,4}):([0-9a-f]{1,4})$/i);if(!r)return null;let i=Number.parseInt(r[1],16),a=Number.parseInt(r[2],16);return[i>>8&255,i&255,a>>8&255,a&255].join(`.`)}function t(n){let r=n.trim().toLowerCase().replace(/\.$/,``).replace(/^\[|\]$/g,``);if(!r||r===`localhost`||r.endsWith(`.localhost`)||r.endsWith(`.local`)||r.endsWith(`.internal`)||r===`metadata.google.internal`||r===`0.0.0.0`||r===`::`||r===`::1`||r.startsWith(`fe80:`)||r.startsWith(`fc`)||r.startsWith(`fd`))return!0;let i=e(r);if(i)return t(i);let a=r.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);if(a){let e=Number(a[1]),t=Number(a[2]);if(e===10||e===127||e===0||e===192&&t===168||e===169&&t===254||e===172&&t>=16&&t<=31)return!0}return!1}exports.isBlockedFetchHost=t;
|