@naersen/tts-rich-text 0.8.0 → 0.8.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/CHANGELOG.md +14 -0
- package/README.md +17 -1
- package/dist/base.css +1 -1
- package/dist/components/tts-editor-root/index.vue.d.ts +1 -0
- package/dist/components/tts-rich-text/editor/useRichTextEditor.d.ts +6 -0
- package/dist/components/tts-rich-text-editor/index.vue.d.ts +8 -2
- package/dist/core/estimate-tts-duration.d.ts +5 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core.js +212 -205
- package/dist/index.js +1841 -1827
- package/dist/type/index.d.ts +4 -0
- package/package.json +84 -86
package/dist/core.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const
|
|
1
|
+
const h = {
|
|
2
2
|
DELETE_NODE: "deleteNode",
|
|
3
3
|
CONVERT_TO_TEXT: "convertToText"
|
|
4
|
-
},
|
|
4
|
+
}, f = {
|
|
5
5
|
stop: {
|
|
6
6
|
label: "停顿",
|
|
7
7
|
icon: "editor-stop",
|
|
8
8
|
type: "stop",
|
|
9
|
-
deleteMode:
|
|
9
|
+
deleteMode: h.DELETE_NODE
|
|
10
10
|
},
|
|
11
11
|
customStop: {
|
|
12
12
|
label: "长停顿",
|
|
13
13
|
icon: "editor-stop-long",
|
|
14
14
|
type: "customStop",
|
|
15
|
-
deleteMode:
|
|
15
|
+
deleteMode: h.DELETE_NODE
|
|
16
16
|
},
|
|
17
17
|
continue: {
|
|
18
18
|
label: "连续",
|
|
19
19
|
icon: "editor-continue",
|
|
20
20
|
type: "continue",
|
|
21
|
-
deleteMode:
|
|
21
|
+
deleteMode: h.CONVERT_TO_TEXT
|
|
22
22
|
},
|
|
23
23
|
pinyin: {
|
|
24
24
|
label: "拼音标注",
|
|
25
25
|
icon: "editor-pinyin",
|
|
26
26
|
type: "pinyin",
|
|
27
|
-
deleteMode:
|
|
27
|
+
deleteMode: h.CONVERT_TO_TEXT
|
|
28
28
|
},
|
|
29
29
|
replace: {
|
|
30
30
|
label: "替换",
|
|
31
31
|
icon: "editor-replace",
|
|
32
32
|
type: "replace",
|
|
33
|
-
deleteMode:
|
|
33
|
+
deleteMode: h.CONVERT_TO_TEXT
|
|
34
34
|
},
|
|
35
35
|
language: {
|
|
36
36
|
label: "语种标记",
|
|
37
37
|
icon: "editor-language",
|
|
38
38
|
type: "language",
|
|
39
|
-
deleteMode:
|
|
39
|
+
deleteMode: h.CONVERT_TO_TEXT
|
|
40
40
|
},
|
|
41
41
|
number: {
|
|
42
42
|
label: "数字读法",
|
|
@@ -62,9 +62,9 @@ const f = {
|
|
|
62
62
|
label: "忽略读音",
|
|
63
63
|
icon: "editor-ingore",
|
|
64
64
|
type: "ignore",
|
|
65
|
-
deleteMode:
|
|
65
|
+
deleteMode: h.CONVERT_TO_TEXT
|
|
66
66
|
}
|
|
67
|
-
},
|
|
67
|
+
}, x = [
|
|
68
68
|
{ value: "zh", label: "中文" },
|
|
69
69
|
{ value: "en", label: "英语" },
|
|
70
70
|
{ value: "jp", label: "日语" },
|
|
@@ -75,12 +75,12 @@ const f = {
|
|
|
75
75
|
{ value: "it", label: "意大利语" },
|
|
76
76
|
{ value: "pt", label: "葡萄牙语" },
|
|
77
77
|
{ value: "ru", label: "俄语" }
|
|
78
|
-
],
|
|
78
|
+
], pe = [
|
|
79
79
|
{ label: "停顿 0.5 秒", value: 0.5 },
|
|
80
80
|
{ label: "停顿 1 秒", value: 1 }
|
|
81
|
-
], v = Object.keys(
|
|
81
|
+
], v = Object.keys(f), d = {
|
|
82
82
|
tools: v,
|
|
83
|
-
languages:
|
|
83
|
+
languages: x,
|
|
84
84
|
maxPinyinLength: 4,
|
|
85
85
|
maxNumberLength: 16,
|
|
86
86
|
enablePreview: !0
|
|
@@ -97,21 +97,21 @@ const f = {
|
|
|
97
97
|
"upload",
|
|
98
98
|
"ignore"
|
|
99
99
|
],
|
|
100
|
-
languages:
|
|
100
|
+
languages: x.filter(
|
|
101
101
|
(e) => ["zh", "en"].includes(e.value)
|
|
102
102
|
)
|
|
103
103
|
},
|
|
104
104
|
2: d
|
|
105
|
-
},
|
|
106
|
-
const
|
|
105
|
+
}, ge = (e, t = {}) => {
|
|
106
|
+
const n = D[e] ?? d;
|
|
107
107
|
return {
|
|
108
108
|
...d,
|
|
109
|
-
...t,
|
|
110
109
|
...n,
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
...t,
|
|
111
|
+
tools: t.tools ?? n.tools ?? d.tools,
|
|
112
|
+
languages: t.languages ?? n.languages ?? d.languages
|
|
113
113
|
};
|
|
114
|
-
},
|
|
114
|
+
}, fe = () => ({
|
|
115
115
|
type: "doc",
|
|
116
116
|
content: [
|
|
117
117
|
{
|
|
@@ -119,7 +119,13 @@ const f = {
|
|
|
119
119
|
content: []
|
|
120
120
|
}
|
|
121
121
|
]
|
|
122
|
-
}),
|
|
122
|
+
}), w = /[\u4e00-\u9fff]/, H = /\s/g, V = 0.28, $ = 0.14, he = (e, t = 1) => {
|
|
123
|
+
const n = Number.isFinite(t) && t > 0 ? t : 1;
|
|
124
|
+
return Array.from(e.replace(H, "")).reduce(
|
|
125
|
+
(s, a) => s + (w.test(a) ? V : $),
|
|
126
|
+
0
|
|
127
|
+
) / n;
|
|
128
|
+
}, R = {
|
|
123
129
|
0: "零",
|
|
124
130
|
1: "一",
|
|
125
131
|
2: "二",
|
|
@@ -130,7 +136,7 @@ const f = {
|
|
|
130
136
|
7: "七",
|
|
131
137
|
8: "八",
|
|
132
138
|
9: "九"
|
|
133
|
-
},
|
|
139
|
+
}, U = {
|
|
134
140
|
0: "洞",
|
|
135
141
|
1: "幺",
|
|
136
142
|
2: "二",
|
|
@@ -141,49 +147,49 @@ const f = {
|
|
|
141
147
|
7: "七",
|
|
142
148
|
8: "八",
|
|
143
149
|
9: "九"
|
|
144
|
-
},
|
|
145
|
-
function
|
|
146
|
-
return e ? e.split("").map((
|
|
150
|
+
}, B = ["", "十", "百", "千"], k = ["", "万", "亿", "万亿"];
|
|
151
|
+
function j(e) {
|
|
152
|
+
return e ? e.split("").map((t) => R[t] || t).join("") : "";
|
|
147
153
|
}
|
|
148
|
-
function
|
|
149
|
-
return e ? e.split("").map((
|
|
154
|
+
function de(e) {
|
|
155
|
+
return e ? e.split("").map((t) => U[t] || t).join("") : "";
|
|
150
156
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
let
|
|
154
|
-
for (let s = 0; s <
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
+
function X(e) {
|
|
158
|
+
const t = e.length;
|
|
159
|
+
let n = "", o = !1;
|
|
160
|
+
for (let s = 0; s < t; s++) {
|
|
161
|
+
const a = e[s], r = t - 1 - s;
|
|
162
|
+
a === "0" ? !o && n !== "" && (o = !0) : (o && (n += "零", o = !1), n += R[a] + B[r]);
|
|
157
163
|
}
|
|
158
|
-
return
|
|
164
|
+
return n.startsWith("一十") && n.length === 2 && (n = n.substring(1)), n;
|
|
159
165
|
}
|
|
160
|
-
function
|
|
166
|
+
function y(e) {
|
|
161
167
|
if (!e) return "";
|
|
162
168
|
if (e === "0" || (e = e.replace(/^0+/, "") || "0", e === "0")) return "零";
|
|
163
|
-
let
|
|
164
|
-
const
|
|
165
|
-
for (let s =
|
|
166
|
-
const
|
|
167
|
-
o.unshift(e.substring(
|
|
169
|
+
let t = "";
|
|
170
|
+
const n = e.length, o = [];
|
|
171
|
+
for (let s = n; s > 0; s -= 4) {
|
|
172
|
+
const a = Math.max(0, s - 4);
|
|
173
|
+
o.unshift(e.substring(a, s));
|
|
168
174
|
}
|
|
169
175
|
for (let s = 0; s < o.length; s++) {
|
|
170
|
-
const
|
|
176
|
+
const a = o[s], r = X(a);
|
|
171
177
|
if (r !== "") {
|
|
172
178
|
const i = o.length - 1 - s;
|
|
173
|
-
|
|
179
|
+
t += r + k[i];
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
|
-
return
|
|
182
|
+
return t;
|
|
177
183
|
}
|
|
178
|
-
function
|
|
179
|
-
return
|
|
184
|
+
function z(e) {
|
|
185
|
+
return y(e);
|
|
180
186
|
}
|
|
181
|
-
const
|
|
182
|
-
{ label: "基数读法", func:
|
|
187
|
+
const Te = [
|
|
188
|
+
{ label: "基数读法", func: j },
|
|
183
189
|
// { label: '位数读法', func: toPhoneReading },
|
|
184
|
-
{ label: "位数读法", func:
|
|
185
|
-
{ label: "口语读法", func:
|
|
186
|
-
],
|
|
190
|
+
{ label: "位数读法", func: y },
|
|
191
|
+
{ label: "口语读法", func: z }
|
|
192
|
+
], G = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, W = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, I = {
|
|
187
193
|
"‘": "'",
|
|
188
194
|
"’": "'",
|
|
189
195
|
"‚": "'",
|
|
@@ -215,161 +221,161 @@ const pe = [
|
|
|
215
221
|
"︔": ";",
|
|
216
222
|
"︕": "!",
|
|
217
223
|
"︖": "?"
|
|
218
|
-
},
|
|
219
|
-
`[${Object.keys(
|
|
224
|
+
}, Y = new RegExp(
|
|
225
|
+
`[${Object.keys(I).join("")}]`,
|
|
220
226
|
"g"
|
|
221
|
-
),
|
|
227
|
+
), K = (e) => e.replace(/[\uFF21-\uFF3A\uFF41-\uFF5A\uFF10-\uFF19]/g, (t) => String.fromCharCode(t.charCodeAt(0) - 65248)), q = (e) => K(e).replace(/\r\n?/g, `
|
|
222
228
|
`).replace(/[\u2028\u2029]/g, `
|
|
223
|
-
`).replace(
|
|
229
|
+
`).replace(G, "").replace(W, " ").replace(Y, (t) => I[t] || "").replace(/ *\n */g, `
|
|
224
230
|
`).replace(/\n{3,}/g, `
|
|
225
231
|
|
|
226
|
-
`),
|
|
232
|
+
`), Ee = (e) => {
|
|
227
233
|
if (typeof window > "u" || !e)
|
|
228
234
|
return e;
|
|
229
|
-
const
|
|
235
|
+
const n = new DOMParser().parseFromString(e, "text/html"), o = n.createTreeWalker(n.body, NodeFilter.SHOW_TEXT);
|
|
230
236
|
let s = o.nextNode();
|
|
231
237
|
for (; s; )
|
|
232
|
-
s.textContent =
|
|
233
|
-
return
|
|
234
|
-
},
|
|
238
|
+
s.textContent = q(s.textContent || ""), s = o.nextNode();
|
|
239
|
+
return n.body.innerHTML;
|
|
240
|
+
}, J = {
|
|
235
241
|
minSegmentLength: 32,
|
|
236
242
|
maxSegmentLength: 64,
|
|
237
243
|
rebalanceRatio: 0.4
|
|
238
|
-
},
|
|
239
|
-
let n = 0;
|
|
240
|
-
for (const t of e)
|
|
241
|
-
n += L.test(t) ? 2 : 1;
|
|
242
|
-
return n;
|
|
243
|
-
}, K = (e) => e.replace(/\r/g, "").split(`
|
|
244
|
-
`).map((n) => n.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), q = (e) => {
|
|
245
|
-
let n = e, t = "";
|
|
246
|
-
for (; t !== n; )
|
|
247
|
-
t = n, n = n.replace(/(\d),(\d)/g, `$1${R}$2`);
|
|
248
|
-
for (t = ""; t !== n; )
|
|
249
|
-
t = n, n = n.replace(/(\d)\.(\d)/g, `$1${S}$2`);
|
|
250
|
-
return n;
|
|
251
|
-
}, b = (e) => e.split(R).join(",").split(S).join("."), E = (e, n) => {
|
|
244
|
+
}, O = /[一-鿿㐀-䶿豈- -〿-]/, F = /[。!?!?\.]/, P = /[;;]/, C = /[,,::]/, Z = /[、]/, L = "", A = "", p = (e) => {
|
|
252
245
|
let t = 0;
|
|
246
|
+
for (const n of e)
|
|
247
|
+
t += O.test(n) ? 2 : 1;
|
|
248
|
+
return t;
|
|
249
|
+
}, Q = (e) => e.replace(/\r/g, "").split(`
|
|
250
|
+
`).map((t) => t.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), ee = (e) => {
|
|
251
|
+
let t = e, n = "";
|
|
252
|
+
for (; n !== t; )
|
|
253
|
+
n = t, t = t.replace(/(\d),(\d)/g, `$1${L}$2`);
|
|
254
|
+
for (n = ""; n !== t; )
|
|
255
|
+
n = t, t = t.replace(/(\d)\.(\d)/g, `$1${A}$2`);
|
|
256
|
+
return t;
|
|
257
|
+
}, b = (e) => e.split(L).join(",").split(A).join("."), m = (e, t) => {
|
|
258
|
+
let n = 0;
|
|
253
259
|
for (let o = 0; o < e.length; o += 1)
|
|
254
|
-
if (
|
|
260
|
+
if (n += O.test(e[o]) ? 2 : 1, n >= t)
|
|
255
261
|
return o + 1;
|
|
256
262
|
return e.length;
|
|
257
|
-
},
|
|
258
|
-
let
|
|
259
|
-
const i = Math.max(1,
|
|
260
|
-
for (let
|
|
261
|
-
if (!s.test(e[
|
|
263
|
+
}, _ = (e, t, n, o, s) => {
|
|
264
|
+
let a = -1, r = Number.POSITIVE_INFINITY;
|
|
265
|
+
const i = Math.max(1, n), c = Math.min(e.length - 1, o);
|
|
266
|
+
for (let l = i; l <= c; l += 1) {
|
|
267
|
+
if (!s.test(e[l - 1]))
|
|
262
268
|
continue;
|
|
263
|
-
const u = Math.abs(
|
|
264
|
-
if (u < r && (r = u,
|
|
269
|
+
const u = Math.abs(l - t);
|
|
270
|
+
if (u < r && (r = u, a = l), l > t && a >= 0)
|
|
265
271
|
break;
|
|
266
272
|
}
|
|
267
|
-
return
|
|
268
|
-
},
|
|
269
|
-
let s = -1,
|
|
270
|
-
const r = Math.max(1,
|
|
273
|
+
return a;
|
|
274
|
+
}, te = (e, t, n, o) => {
|
|
275
|
+
let s = -1, a = Number.POSITIVE_INFINITY;
|
|
276
|
+
const r = Math.max(1, n), i = Math.min(e.length - 1, o);
|
|
271
277
|
for (let c = r; c <= i; c += 1) {
|
|
272
278
|
if (e[c - 1] !== " ")
|
|
273
279
|
continue;
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
280
|
+
const l = Math.abs(c - t);
|
|
281
|
+
if (l < a && (a = l, s = c), c > t && s >= 0)
|
|
276
282
|
break;
|
|
277
283
|
}
|
|
278
284
|
return s;
|
|
279
|
-
},
|
|
285
|
+
}, S = (e, t, n, o, s) => {
|
|
280
286
|
for (const r of s) {
|
|
281
|
-
const i =
|
|
287
|
+
const i = _(
|
|
282
288
|
e,
|
|
283
|
-
n,
|
|
284
289
|
t,
|
|
290
|
+
n,
|
|
285
291
|
o,
|
|
286
292
|
r
|
|
287
293
|
);
|
|
288
294
|
if (i >= 0)
|
|
289
295
|
return i;
|
|
290
296
|
}
|
|
291
|
-
const
|
|
297
|
+
const a = te(
|
|
292
298
|
e,
|
|
293
|
-
n,
|
|
294
299
|
t,
|
|
300
|
+
n,
|
|
295
301
|
o
|
|
296
302
|
);
|
|
297
|
-
return
|
|
303
|
+
return a >= 0 ? a : _(
|
|
298
304
|
e,
|
|
299
|
-
n,
|
|
300
305
|
t,
|
|
306
|
+
n,
|
|
301
307
|
o,
|
|
302
|
-
|
|
308
|
+
Z
|
|
303
309
|
);
|
|
304
|
-
},
|
|
305
|
-
const
|
|
310
|
+
}, ne = (e, t) => {
|
|
311
|
+
const n = [];
|
|
306
312
|
let o = e.trim();
|
|
307
|
-
for (; o && p(o) >
|
|
308
|
-
const s = p(o),
|
|
313
|
+
for (; o && p(o) > t; ) {
|
|
314
|
+
const s = p(o), a = Math.min(
|
|
309
315
|
Math.floor(s / 2),
|
|
310
|
-
|
|
311
|
-
), r =
|
|
316
|
+
t
|
|
317
|
+
), r = m(o, a), i = Math.max(1, Math.floor(r / 3)), c = Math.max(
|
|
312
318
|
r + 1,
|
|
313
|
-
|
|
319
|
+
m(o, t)
|
|
314
320
|
);
|
|
315
|
-
let
|
|
321
|
+
let l = S(
|
|
316
322
|
o,
|
|
317
323
|
r,
|
|
318
324
|
i,
|
|
319
325
|
c,
|
|
320
|
-
[P,
|
|
326
|
+
[P, C]
|
|
321
327
|
);
|
|
322
|
-
(
|
|
328
|
+
(l < 0 || l >= o.length) && (l = r), n.push(o.slice(0, l).trim()), o = o.slice(l).trim();
|
|
323
329
|
}
|
|
324
|
-
return o &&
|
|
325
|
-
},
|
|
330
|
+
return o && n.push(o), n;
|
|
331
|
+
}, oe = (e, t) => {
|
|
326
332
|
if (e.length <= 1)
|
|
327
333
|
return e;
|
|
328
|
-
const
|
|
329
|
-
if (p(
|
|
334
|
+
const n = e[e.length - 1], o = e.reduce((T, E) => T + p(E), 0) / e.length, s = Math.floor(o * t);
|
|
335
|
+
if (p(n) >= s)
|
|
330
336
|
return e;
|
|
331
|
-
const r = `${e[e.length - 2]}${
|
|
332
|
-
let u =
|
|
337
|
+
const r = `${e[e.length - 2]}${n}`, i = Math.floor(p(r) / 2), c = m(r, i), l = Math.max(1, Math.floor(c / 3));
|
|
338
|
+
let u = S(
|
|
333
339
|
r,
|
|
334
340
|
c,
|
|
335
|
-
|
|
341
|
+
l,
|
|
336
342
|
r.length,
|
|
337
|
-
[
|
|
343
|
+
[F, P, C]
|
|
338
344
|
);
|
|
339
345
|
if (u <= 0 || u >= r.length)
|
|
340
346
|
return e;
|
|
341
347
|
const g = [...e];
|
|
342
348
|
return g[g.length - 2] = r.slice(0, u).trim(), g[g.length - 1] = r.slice(u).trim(), g.filter(Boolean);
|
|
343
|
-
},
|
|
344
|
-
const
|
|
345
|
-
...
|
|
346
|
-
...
|
|
347
|
-
}, o =
|
|
349
|
+
}, re = (e, t = {}) => {
|
|
350
|
+
const n = {
|
|
351
|
+
...J,
|
|
352
|
+
...t
|
|
353
|
+
}, o = Q(e);
|
|
348
354
|
if (!o)
|
|
349
355
|
return [];
|
|
350
|
-
const s =
|
|
351
|
-
if (p(s) <=
|
|
356
|
+
const s = ee(o);
|
|
357
|
+
if (p(s) <= n.minSegmentLength)
|
|
352
358
|
return [b(s)];
|
|
353
|
-
const
|
|
359
|
+
const a = [], r = s.split(new RegExp("(?<=[。!?!?\\.])"));
|
|
354
360
|
let i = "";
|
|
355
|
-
for (const
|
|
356
|
-
if (!
|
|
361
|
+
for (const l of r) {
|
|
362
|
+
if (!l)
|
|
357
363
|
continue;
|
|
358
|
-
i +=
|
|
364
|
+
i += l;
|
|
359
365
|
const u = i[i.length - 1] ?? "";
|
|
360
|
-
p(i) >=
|
|
366
|
+
p(i) >= n.minSegmentLength && F.test(u) && (a.push(i.trim()), i = "");
|
|
361
367
|
}
|
|
362
|
-
i && (
|
|
363
|
-
const c =
|
|
364
|
-
return
|
|
368
|
+
i && (a.length > 0 && p(i) < n.minSegmentLength ? a[a.length - 1] += i : a.push(i.trim()));
|
|
369
|
+
const c = a.flatMap((l) => p(l) <= n.maxSegmentLength ? [l] : ne(l, n.maxSegmentLength));
|
|
370
|
+
return oe(
|
|
365
371
|
c,
|
|
366
|
-
|
|
372
|
+
n.rebalanceRatio
|
|
367
373
|
).map(b);
|
|
368
|
-
},
|
|
369
|
-
const
|
|
370
|
-
let
|
|
371
|
-
const o = [], s = [],
|
|
372
|
-
[
|
|
374
|
+
}, M = (e) => e.type === "text" ? e.text || "" : (e.content || []).map(M).join(""), se = (e) => {
|
|
375
|
+
const t = e.content || [];
|
|
376
|
+
let n = "";
|
|
377
|
+
const o = [], s = [], a = {
|
|
378
|
+
[f.stop.type]: ({ position: r, actionCode: i }) => {
|
|
373
379
|
o.push({
|
|
374
380
|
action: "insert",
|
|
375
381
|
model: "control",
|
|
@@ -379,7 +385,7 @@ const pe = [
|
|
|
379
385
|
actionCode: i
|
|
380
386
|
});
|
|
381
387
|
},
|
|
382
|
-
[
|
|
388
|
+
[f.customStop.type]: ({ payload: r, position: i, actionCode: c }) => {
|
|
383
389
|
o.push({
|
|
384
390
|
action: "insert",
|
|
385
391
|
model: "control",
|
|
@@ -389,7 +395,7 @@ const pe = [
|
|
|
389
395
|
actionCode: c
|
|
390
396
|
});
|
|
391
397
|
},
|
|
392
|
-
[
|
|
398
|
+
[f.continue.type]: ({ position: r, text: i, actionCode: c }) => {
|
|
393
399
|
o.push({
|
|
394
400
|
action: "replace",
|
|
395
401
|
model: "replace",
|
|
@@ -399,11 +405,11 @@ const pe = [
|
|
|
399
405
|
actionCode: c
|
|
400
406
|
});
|
|
401
407
|
},
|
|
402
|
-
[
|
|
408
|
+
[f.replace.type]: ({
|
|
403
409
|
payload: r,
|
|
404
410
|
position: i,
|
|
405
411
|
text: c,
|
|
406
|
-
actionCode:
|
|
412
|
+
actionCode: l
|
|
407
413
|
}) => {
|
|
408
414
|
o.push({
|
|
409
415
|
action: "replace",
|
|
@@ -411,24 +417,24 @@ const pe = [
|
|
|
411
417
|
payload: `${r == null ? void 0 : r.text}`,
|
|
412
418
|
position: i,
|
|
413
419
|
text: c,
|
|
414
|
-
actionCode:
|
|
420
|
+
actionCode: l
|
|
415
421
|
});
|
|
416
422
|
},
|
|
417
|
-
[
|
|
423
|
+
[f.pinyin.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
|
|
418
424
|
o.push({
|
|
419
425
|
action: "replace",
|
|
420
426
|
model: "pinyin",
|
|
421
427
|
payload: `${r == null ? void 0 : r.text}`,
|
|
422
428
|
position: i,
|
|
423
429
|
text: c,
|
|
424
|
-
actionCode:
|
|
430
|
+
actionCode: l
|
|
425
431
|
});
|
|
426
432
|
},
|
|
427
|
-
[
|
|
433
|
+
[f.language.type]: ({
|
|
428
434
|
payload: r,
|
|
429
435
|
position: i,
|
|
430
436
|
text: c,
|
|
431
|
-
actionCode:
|
|
437
|
+
actionCode: l
|
|
432
438
|
}) => {
|
|
433
439
|
o.push({
|
|
434
440
|
action: "language",
|
|
@@ -436,10 +442,10 @@ const pe = [
|
|
|
436
442
|
payload: `${r == null ? void 0 : r.code}`,
|
|
437
443
|
position: i,
|
|
438
444
|
text: c,
|
|
439
|
-
actionCode:
|
|
445
|
+
actionCode: l
|
|
440
446
|
});
|
|
441
447
|
},
|
|
442
|
-
[
|
|
448
|
+
[f.ignore.type]: ({
|
|
443
449
|
position: r,
|
|
444
450
|
text: i,
|
|
445
451
|
actionCode: c
|
|
@@ -454,74 +460,74 @@ const pe = [
|
|
|
454
460
|
});
|
|
455
461
|
}
|
|
456
462
|
};
|
|
457
|
-
return
|
|
458
|
-
var T,
|
|
463
|
+
return t.forEach((r) => {
|
|
464
|
+
var T, E;
|
|
459
465
|
if (r.type === "text") {
|
|
460
|
-
|
|
466
|
+
n += r.text || "";
|
|
461
467
|
return;
|
|
462
468
|
}
|
|
463
469
|
if (r.type !== "customTag") return;
|
|
464
|
-
const i = (T = r.attrs) == null ? void 0 : T.categ, c = (
|
|
470
|
+
const i = (T = r.attrs) == null ? void 0 : T.categ, c = (E = r.attrs) == null ? void 0 : E.payload, l = n.length, u = M(r), g = a[i];
|
|
465
471
|
u && s.push({
|
|
466
|
-
start:
|
|
467
|
-
end:
|
|
472
|
+
start: l,
|
|
473
|
+
end: l + u.length
|
|
468
474
|
}), g && g({
|
|
469
475
|
payload: c,
|
|
470
|
-
position:
|
|
476
|
+
position: l,
|
|
471
477
|
text: u,
|
|
472
478
|
actionCode: i
|
|
473
|
-
}),
|
|
479
|
+
}), n += u;
|
|
474
480
|
}), {
|
|
475
|
-
text:
|
|
481
|
+
text: n,
|
|
476
482
|
protectedRanges: s,
|
|
477
483
|
playments: o
|
|
478
484
|
};
|
|
479
|
-
}, N = (e) => e.type === "text" || e.type === "customTag",
|
|
480
|
-
const
|
|
485
|
+
}, N = (e) => e.type === "text" || e.type === "customTag", ie = (e) => {
|
|
486
|
+
const t = e.content || [];
|
|
481
487
|
if (e.type === "paragraph") return [e];
|
|
482
488
|
if (e.type === "doc")
|
|
483
|
-
return
|
|
484
|
-
const
|
|
489
|
+
return t.filter((o) => o.type === "paragraph");
|
|
490
|
+
const n = t.filter(
|
|
485
491
|
(o) => o.type === "paragraph"
|
|
486
492
|
);
|
|
487
|
-
return
|
|
493
|
+
return n.length ? n : t.some(N) ? [
|
|
488
494
|
{
|
|
489
495
|
type: "paragraph",
|
|
490
|
-
content:
|
|
496
|
+
content: t.filter(N)
|
|
491
497
|
}
|
|
492
498
|
] : [];
|
|
493
|
-
},
|
|
494
|
-
let
|
|
495
|
-
return
|
|
496
|
-
const s = e.indexOf(o,
|
|
497
|
-
return
|
|
499
|
+
}, ae = (e, t) => {
|
|
500
|
+
let n = 0;
|
|
501
|
+
return t.map((o) => {
|
|
502
|
+
const s = e.indexOf(o, n), a = s >= 0 ? s : n, r = a + o.length;
|
|
503
|
+
return n = r, {
|
|
498
504
|
text: o,
|
|
499
|
-
start:
|
|
505
|
+
start: a,
|
|
500
506
|
end: r
|
|
501
507
|
};
|
|
502
508
|
});
|
|
503
|
-
},
|
|
504
|
-
if (
|
|
505
|
-
(
|
|
506
|
-
) &&
|
|
507
|
-
const
|
|
508
|
-
return
|
|
509
|
+
}, le = (e, t) => e.reduce((n, o) => {
|
|
510
|
+
if (t.some(
|
|
511
|
+
(a) => o.start > a.start && o.start < a.end
|
|
512
|
+
) && n.length) {
|
|
513
|
+
const a = n[n.length - 1];
|
|
514
|
+
return a.text += o.text, a.end = o.end, n;
|
|
509
515
|
}
|
|
510
|
-
return
|
|
511
|
-
}, []),
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
515
|
-
|
|
516
|
+
return n.push({ ...o }), n;
|
|
517
|
+
}, []), ce = (e, t, n, o) => e.position >= t && e.position < n ? !0 : !e.text && o && e.position === n, ue = (e) => {
|
|
518
|
+
const t = re(e.text);
|
|
519
|
+
if (t.length <= 1) return [e];
|
|
520
|
+
const n = le(
|
|
521
|
+
ae(e.text, t),
|
|
516
522
|
e.protectedRanges || []
|
|
517
523
|
);
|
|
518
|
-
return
|
|
519
|
-
const
|
|
520
|
-
(i) =>
|
|
524
|
+
return n.map((o, s) => {
|
|
525
|
+
const a = s === n.length - 1, r = e.playments.filter(
|
|
526
|
+
(i) => ce(
|
|
521
527
|
i,
|
|
522
528
|
o.start,
|
|
523
529
|
o.end,
|
|
524
|
-
|
|
530
|
+
a
|
|
525
531
|
)
|
|
526
532
|
).map((i) => ({
|
|
527
533
|
...i,
|
|
@@ -532,35 +538,36 @@ const pe = [
|
|
|
532
538
|
playments: r
|
|
533
539
|
};
|
|
534
540
|
});
|
|
535
|
-
},
|
|
536
|
-
const
|
|
541
|
+
}, me = (e) => {
|
|
542
|
+
const t = {
|
|
537
543
|
playments: [],
|
|
538
544
|
sentences: []
|
|
539
545
|
};
|
|
540
|
-
return
|
|
541
|
-
const s =
|
|
542
|
-
!s.text && !s.playments.length ||
|
|
543
|
-
|
|
546
|
+
return ie(e).forEach((o) => {
|
|
547
|
+
const s = se(o);
|
|
548
|
+
!s.text && !s.playments.length || ue(s).forEach(({ text: a, playments: r }) => {
|
|
549
|
+
t.sentences.push(a), t.playments.push(r);
|
|
544
550
|
});
|
|
545
|
-
}),
|
|
551
|
+
}), t;
|
|
546
552
|
};
|
|
547
553
|
export {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
554
|
+
h as DeleteMode,
|
|
555
|
+
x as LanguageOptions,
|
|
556
|
+
Te as NumberToTextTools,
|
|
557
|
+
pe as StopOptions,
|
|
558
|
+
f as ToolConfig,
|
|
553
559
|
v as allToolTypes,
|
|
554
|
-
|
|
555
|
-
|
|
560
|
+
me as convertToTtsFormat,
|
|
561
|
+
he as estimateTtsDuration,
|
|
562
|
+
fe as getInitContent,
|
|
556
563
|
p as getVisualLength,
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
564
|
+
ge as resolveTtsEditorFeatures,
|
|
565
|
+
Ee as sanitizePastedHtml,
|
|
566
|
+
q as sanitizePastedText,
|
|
567
|
+
re as splitTextToSentences,
|
|
568
|
+
j as toCardinal,
|
|
569
|
+
z as toColloquial,
|
|
570
|
+
de as toPhoneReading,
|
|
571
|
+
y as toPositional,
|
|
572
|
+
se as transformParagraph
|
|
566
573
|
};
|