@naersen/tts-rich-text 0.8.3 → 0.9.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/dist/core.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const h = {
2
2
  DELETE_NODE: "deleteNode",
3
3
  CONVERT_TO_TEXT: "convertToText"
4
- }, f = {
4
+ }, p = {
5
5
  stop: {
6
6
  label: "停顿",
7
7
  icon: "editor-stop",
@@ -75,16 +75,27 @@ const h = {
75
75
  { value: "it", label: "意大利语" },
76
76
  { value: "pt", label: "葡萄牙语" },
77
77
  { value: "ru", label: "俄语" }
78
- ], pe = [
78
+ ], v = [
79
79
  { label: "停顿 0.5 秒", value: 0.5 },
80
80
  { label: "停顿 1 秒", value: 1 }
81
- ], v = Object.keys(f), d = {
82
- tools: v,
81
+ ], gt = {
82
+ SENTENCE: "sentence",
83
+ CUSTOM_TAG: "customTag",
84
+ /**
85
+ * 选中文本时浮出的气泡菜单插件 key。
86
+ * 工具栏与右键面板都要用它来主动收起气泡,避免两个浮层叠在一起。
87
+ */
88
+ BUBBLE_MENU_KEY: "ttsRichTextBubbleMenu"
89
+ }, ft = (t) => {
90
+ var e;
91
+ return ((e = p[t]) == null ? void 0 : e.deleteMode) === h.DELETE_NODE;
92
+ }, ht = (t) => t === p.customStop.type ? { time: v[0].value } : {}, dt = (t, e) => t === p.customStop.type ? `${e == null ? void 0 : e.time} 秒` : "", D = Object.keys(p), d = {
93
+ tools: D,
83
94
  languages: x,
84
95
  maxPinyinLength: 4,
85
96
  maxNumberLength: 16,
86
97
  enablePreview: !0
87
- }, D = {
98
+ }, w = {
88
99
  1: {
89
100
  tools: [
90
101
  "customStop",
@@ -97,21 +108,19 @@ const h = {
97
108
  "upload",
98
109
  "ignore"
99
110
  ],
100
- languages: x.filter(
101
- (e) => ["zh", "en"].includes(e.value)
102
- )
111
+ languages: x.filter((t) => ["zh", "en"].includes(t.value))
103
112
  },
104
113
  2: d
105
- }, ge = (e, t = {}) => {
106
- const n = D[e] ?? d;
114
+ }, Tt = (t, e = {}) => {
115
+ const n = w[t] ?? d;
107
116
  return {
108
117
  ...d,
109
118
  ...n,
110
- ...t,
111
- tools: t.tools ?? n.tools ?? d.tools,
112
- languages: t.languages ?? n.languages ?? d.languages
119
+ ...e,
120
+ tools: e.tools ?? n.tools ?? d.tools,
121
+ languages: e.languages ?? n.languages ?? d.languages
113
122
  };
114
- }, fe = () => ({
123
+ }, Et = () => ({
115
124
  type: "doc",
116
125
  content: [
117
126
  {
@@ -119,10 +128,10 @@ const h = {
119
128
  content: []
120
129
  }
121
130
  ]
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 : $),
131
+ }), B = /[\u4e00-\u9fff]/, H = /\s/g, U = 0.28, V = 0.14, mt = (t, e = 1) => {
132
+ const n = Number.isFinite(e) && e > 0 ? e : 1;
133
+ return Array.from(t.replace(H, "")).reduce(
134
+ (s, a) => s + (B.test(a) ? U : V),
126
135
  0
127
136
  ) / n;
128
137
  }, R = {
@@ -136,7 +145,7 @@ const h = {
136
145
  7: "七",
137
146
  8: "八",
138
147
  9: "九"
139
- }, U = {
148
+ }, $ = {
140
149
  0: "洞",
141
150
  1: "幺",
142
151
  2: "二",
@@ -147,49 +156,49 @@ const h = {
147
156
  7: "七",
148
157
  8: "八",
149
158
  9: "九"
150
- }, B = ["", "十", "百", "千"], k = ["", "万", "亿", "万亿"];
151
- function j(e) {
152
- return e ? e.split("").map((t) => R[t] || t).join("") : "";
159
+ }, k = ["", "十", "百", "千"], j = ["", "万", "亿", "万亿"];
160
+ function X(t) {
161
+ return t ? t.split("").map((e) => R[e] || e).join("") : "";
153
162
  }
154
- function de(e) {
155
- return e ? e.split("").map((t) => U[t] || t).join("") : "";
163
+ function bt(t) {
164
+ return t ? t.split("").map((e) => $[e] || e).join("") : "";
156
165
  }
157
- function X(e) {
158
- const t = e.length;
166
+ function z(t) {
167
+ const e = t.length;
159
168
  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]);
169
+ for (let s = 0; s < e; s++) {
170
+ const a = t[s], r = e - 1 - s;
171
+ a === "0" ? !o && n !== "" && (o = !0) : (o && (n += "零", o = !1), n += R[a] + k[r]);
163
172
  }
164
173
  return n.startsWith("一十") && n.length === 2 && (n = n.substring(1)), n;
165
174
  }
166
- function y(e) {
167
- if (!e) return "";
168
- if (e === "0" || (e = e.replace(/^0+/, "") || "0", e === "0")) return "零";
169
- let t = "";
170
- const n = e.length, o = [];
175
+ function y(t) {
176
+ if (!t) return "";
177
+ if (t === "0" || (t = t.replace(/^0+/, "") || "0", t === "0")) return "零";
178
+ let e = "";
179
+ const n = t.length, o = [];
171
180
  for (let s = n; s > 0; s -= 4) {
172
181
  const a = Math.max(0, s - 4);
173
- o.unshift(e.substring(a, s));
182
+ o.unshift(t.substring(a, s));
174
183
  }
175
184
  for (let s = 0; s < o.length; s++) {
176
- const a = o[s], r = X(a);
185
+ const a = o[s], r = z(a);
177
186
  if (r !== "") {
178
187
  const i = o.length - 1 - s;
179
- t += r + k[i];
188
+ e += r + j[i];
180
189
  }
181
190
  }
182
- return t;
191
+ return e;
183
192
  }
184
- function z(e) {
185
- return y(e);
193
+ function G(t) {
194
+ return y(t);
186
195
  }
187
- const Te = [
188
- { label: "基数读法", func: j },
196
+ const _t = [
197
+ { label: "基数读法", func: X },
189
198
  // { label: '位数读法', func: toPhoneReading },
190
199
  { 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 = {
200
+ { label: "口语读法", func: G }
201
+ ], W = /[\u0000-\u0008\u000B-\u001F\u007F-\u009F\u00AD\u200B-\u200F\u202A-\u202E\u2060-\u206F\uFE00-\uFE0F\uFEFF\uFFFD\uE000-\uF8FF]/g, Y = /[\t\f\v\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g, O = {
193
202
  "‘": "'",
194
203
  "’": "'",
195
204
  "‚": "'",
@@ -221,72 +230,69 @@ const Te = [
221
230
  "︔": ";",
222
231
  "︕": "!",
223
232
  "︖": "?"
224
- }, Y = new RegExp(
225
- `[${Object.keys(I).join("")}]`,
226
- "g"
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, `
233
+ }, K = new RegExp(`[${Object.keys(O).join("")}]`, "g"), q = (t) => t.replace(/[\uFF21-\uFF3A\uFF41-\uFF5A\uFF10-\uFF19]/g, (e) => String.fromCharCode(e.charCodeAt(0) - 65248)), J = (t) => q(t).replace(/\r\n?/g, `
228
234
  `).replace(/[\u2028\u2029]/g, `
229
- `).replace(G, "").replace(W, " ").replace(Y, (t) => I[t] || "").replace(/ *\n */g, `
235
+ `).replace(W, "").replace(Y, " ").replace(K, (e) => O[e] || "").replace(/ *\n */g, `
230
236
  `).replace(/\n{3,}/g, `
231
237
 
232
- `), Ee = (e) => {
233
- if (typeof window > "u" || !e)
234
- return e;
235
- const n = new DOMParser().parseFromString(e, "text/html"), o = n.createTreeWalker(n.body, NodeFilter.SHOW_TEXT);
238
+ `), Nt = (t) => {
239
+ if (typeof window > "u" || !t)
240
+ return t;
241
+ const n = new DOMParser().parseFromString(t, "text/html"), o = n.createTreeWalker(n.body, NodeFilter.SHOW_TEXT);
236
242
  let s = o.nextNode();
237
243
  for (; s; )
238
- s.textContent = q(s.textContent || ""), s = o.nextNode();
244
+ s.textContent = J(s.textContent || ""), s = o.nextNode();
239
245
  return n.body.innerHTML;
240
- }, J = {
246
+ }, Z = {
241
247
  minSegmentLength: 32,
242
248
  maxSegmentLength: 64,
243
249
  rebalanceRatio: 0.4
244
- }, O = /[一-鿿㐀-䶿豈-﫿 -〿＀-￯]/, F = /[。!?!?\.]/, P = /[;;]/, C = /[,,::]/, Z = /[、]/, L = "", A = "", p = (e) => {
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) => {
250
+ }, I = /[一-鿿㐀-䶿豈-﫿 -〿＀-￯]/, L = /[。!?!?\.]/, C = /[;;]/, P = /[,,::]/, Q = /[、]/, F = "", S = "", g = (t) => {
251
+ let e = 0;
252
+ for (const n of t)
253
+ e += I.test(n) ? 2 : 1;
254
+ return e;
255
+ }, tt = (t) => t.replace(/\r/g, "").split(`
256
+ `).map((e) => e.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim(), et = (t) => {
257
+ let e = t, n = "";
258
+ for (; n !== e; )
259
+ n = e, e = e.replace(/(\d),(\d)/g, `$1${F}$2`);
260
+ for (n = ""; n !== e; )
261
+ n = e, e = e.replace(/(\d)\.(\d)/g, `$1${S}$2`);
262
+ return e;
263
+ }, b = (t) => t.split(F).join(",").split(S).join("."), m = (t, e) => {
258
264
  let n = 0;
259
- for (let o = 0; o < e.length; o += 1)
260
- if (n += O.test(e[o]) ? 2 : 1, n >= t)
265
+ for (let o = 0; o < t.length; o += 1)
266
+ if (n += I.test(t[o]) ? 2 : 1, n >= e)
261
267
  return o + 1;
262
- return e.length;
263
- }, _ = (e, t, n, o, s) => {
268
+ return t.length;
269
+ }, _ = (t, e, n, o, s) => {
264
270
  let a = -1, r = Number.POSITIVE_INFINITY;
265
- const i = Math.max(1, n), c = Math.min(e.length - 1, o);
271
+ const i = Math.max(1, n), c = Math.min(t.length - 1, o);
266
272
  for (let l = i; l <= c; l += 1) {
267
- if (!s.test(e[l - 1]))
273
+ if (!s.test(t[l - 1]))
268
274
  continue;
269
- const u = Math.abs(l - t);
270
- if (u < r && (r = u, a = l), l > t && a >= 0)
275
+ const u = Math.abs(l - e);
276
+ if (u < r && (r = u, a = l), l > e && a >= 0)
271
277
  break;
272
278
  }
273
279
  return a;
274
- }, te = (e, t, n, o) => {
280
+ }, nt = (t, e, n, o) => {
275
281
  let s = -1, a = Number.POSITIVE_INFINITY;
276
- const r = Math.max(1, n), i = Math.min(e.length - 1, o);
282
+ const r = Math.max(1, n), i = Math.min(t.length - 1, o);
277
283
  for (let c = r; c <= i; c += 1) {
278
- if (e[c - 1] !== " ")
284
+ if (t[c - 1] !== " ")
279
285
  continue;
280
- const l = Math.abs(c - t);
281
- if (l < a && (a = l, s = c), c > t && s >= 0)
286
+ const l = Math.abs(c - e);
287
+ if (l < a && (a = l, s = c), c > e && s >= 0)
282
288
  break;
283
289
  }
284
290
  return s;
285
- }, S = (e, t, n, o, s) => {
291
+ }, M = (t, e, n, o, s) => {
286
292
  for (const r of s) {
287
293
  const i = _(
288
- e,
289
294
  t,
295
+ e,
290
296
  n,
291
297
  o,
292
298
  r
@@ -294,67 +300,54 @@ const Te = [
294
300
  if (i >= 0)
295
301
  return i;
296
302
  }
297
- const a = te(
298
- e,
299
- t,
300
- n,
301
- o
302
- );
303
+ const a = nt(t, e, n, o);
303
304
  return a >= 0 ? a : _(
304
- e,
305
305
  t,
306
+ e,
306
307
  n,
307
308
  o,
308
- Z
309
+ Q
309
310
  );
310
- }, ne = (e, t) => {
311
+ }, ot = (t, e) => {
311
312
  const n = [];
312
- let o = e.trim();
313
- for (; o && p(o) > t; ) {
314
- const s = p(o), a = Math.min(
315
- Math.floor(s / 2),
316
- t
317
- ), r = m(o, a), i = Math.max(1, Math.floor(r / 3)), c = Math.max(
313
+ let o = t.trim();
314
+ for (; o && g(o) > e; ) {
315
+ const s = g(o), a = Math.min(Math.floor(s / 2), e), r = m(o, a), i = Math.max(1, Math.floor(r / 3)), c = Math.max(
318
316
  r + 1,
319
- m(o, t)
320
- );
321
- let l = S(
322
- o,
323
- r,
324
- i,
325
- c,
326
- [P, C]
317
+ m(o, e)
327
318
  );
319
+ let l = M(o, r, i, c, [
320
+ C,
321
+ P
322
+ ]);
328
323
  (l < 0 || l >= o.length) && (l = r), n.push(o.slice(0, l).trim()), o = o.slice(l).trim();
329
324
  }
330
325
  return o && n.push(o), n;
331
- }, oe = (e, t) => {
332
- if (e.length <= 1)
333
- return e;
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)
336
- return e;
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(
339
- r,
340
- c,
341
- l,
342
- r.length,
343
- [F, P, C]
344
- );
326
+ }, rt = (t, e) => {
327
+ if (t.length <= 1)
328
+ return t;
329
+ const n = t[t.length - 1], o = t.reduce((T, E) => T + g(E), 0) / t.length, s = Math.floor(o * e);
330
+ if (g(n) >= s)
331
+ return t;
332
+ const r = `${t[t.length - 2]}${n}`, i = Math.floor(g(r) / 2), c = m(r, i), l = Math.max(1, Math.floor(c / 3));
333
+ let u = M(r, c, l, r.length, [
334
+ L,
335
+ C,
336
+ P
337
+ ]);
345
338
  if (u <= 0 || u >= r.length)
346
- return e;
347
- const g = [...e];
348
- return g[g.length - 2] = r.slice(0, u).trim(), g[g.length - 1] = r.slice(u).trim(), g.filter(Boolean);
349
- }, re = (e, t = {}) => {
339
+ return t;
340
+ const f = [...t];
341
+ return f[f.length - 2] = r.slice(0, u).trim(), f[f.length - 1] = r.slice(u).trim(), f.filter(Boolean);
342
+ }, st = (t, e = {}) => {
350
343
  const n = {
351
- ...J,
352
- ...t
353
- }, o = Q(e);
344
+ ...Z,
345
+ ...e
346
+ }, o = tt(t);
354
347
  if (!o)
355
348
  return [];
356
- const s = ee(o);
357
- if (p(s) <= n.minSegmentLength)
349
+ const s = et(o);
350
+ if (g(s) <= n.minSegmentLength)
358
351
  return [b(s)];
359
352
  const a = [], r = s.split(new RegExp("(?<=[。!?!?\\.])"));
360
353
  let i = "";
@@ -363,19 +356,18 @@ const Te = [
363
356
  continue;
364
357
  i += l;
365
358
  const u = i[i.length - 1] ?? "";
366
- p(i) >= n.minSegmentLength && F.test(u) && (a.push(i.trim()), i = "");
359
+ g(i) >= n.minSegmentLength && L.test(u) && (a.push(i.trim()), i = "");
367
360
  }
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(
371
- c,
372
- n.rebalanceRatio
373
- ).map(b);
374
- }, M = (e) => e.type === "text" ? e.text || "" : (e.content || []).map(M).join(""), se = (e) => {
375
- const t = e.content || [];
361
+ i && (a.length > 0 && g(i) < n.minSegmentLength ? a[a.length - 1] += i : a.push(i.trim()));
362
+ const c = a.flatMap((l) => g(l) <= n.maxSegmentLength ? [l] : ot(l, n.maxSegmentLength));
363
+ return rt(c, n.rebalanceRatio).map(
364
+ b
365
+ );
366
+ }, A = (t) => t.type === "text" ? t.text || "" : (t.content || []).map(A).join(""), it = (t) => {
367
+ const e = t.content || [];
376
368
  let n = "";
377
369
  const o = [], s = [], a = {
378
- [f.stop.type]: ({ position: r, actionCode: i }) => {
370
+ [p.stop.type]: ({ position: r, actionCode: i }) => {
379
371
  o.push({
380
372
  action: "insert",
381
373
  model: "control",
@@ -385,7 +377,7 @@ const Te = [
385
377
  actionCode: i
386
378
  });
387
379
  },
388
- [f.customStop.type]: ({ payload: r, position: i, actionCode: c }) => {
380
+ [p.customStop.type]: ({ payload: r, position: i, actionCode: c }) => {
389
381
  o.push({
390
382
  action: "insert",
391
383
  model: "control",
@@ -395,7 +387,7 @@ const Te = [
395
387
  actionCode: c
396
388
  });
397
389
  },
398
- [f.continue.type]: ({ position: r, text: i, actionCode: c }) => {
390
+ [p.continue.type]: ({ position: r, text: i, actionCode: c }) => {
399
391
  o.push({
400
392
  action: "replace",
401
393
  model: "replace",
@@ -405,12 +397,7 @@ const Te = [
405
397
  actionCode: c
406
398
  });
407
399
  },
408
- [f.replace.type]: ({
409
- payload: r,
410
- position: i,
411
- text: c,
412
- actionCode: l
413
- }) => {
400
+ [p.replace.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
414
401
  o.push({
415
402
  action: "replace",
416
403
  model: "replace",
@@ -420,7 +407,7 @@ const Te = [
420
407
  actionCode: l
421
408
  });
422
409
  },
423
- [f.pinyin.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
410
+ [p.pinyin.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
424
411
  o.push({
425
412
  action: "replace",
426
413
  model: "pinyin",
@@ -430,12 +417,7 @@ const Te = [
430
417
  actionCode: l
431
418
  });
432
419
  },
433
- [f.language.type]: ({
434
- payload: r,
435
- position: i,
436
- text: c,
437
- actionCode: l
438
- }) => {
420
+ [p.language.type]: ({ payload: r, position: i, text: c, actionCode: l }) => {
439
421
  o.push({
440
422
  action: "language",
441
423
  model: "language",
@@ -445,11 +427,7 @@ const Te = [
445
427
  actionCode: l
446
428
  });
447
429
  },
448
- [f.ignore.type]: ({
449
- position: r,
450
- text: i,
451
- actionCode: c
452
- }) => {
430
+ [p.ignore.type]: ({ position: r, text: i, actionCode: c }) => {
453
431
  o.push({
454
432
  action: "replace",
455
433
  model: "replace",
@@ -460,18 +438,18 @@ const Te = [
460
438
  });
461
439
  }
462
440
  };
463
- return t.forEach((r) => {
441
+ return e.forEach((r) => {
464
442
  var T, E;
465
443
  if (r.type === "text") {
466
444
  n += r.text || "";
467
445
  return;
468
446
  }
469
447
  if (r.type !== "customTag") return;
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];
448
+ const i = (T = r.attrs) == null ? void 0 : T.categ, c = (E = r.attrs) == null ? void 0 : E.payload, l = n.length, u = A(r), f = a[i];
471
449
  u && s.push({
472
450
  start: l,
473
451
  end: l + u.length
474
- }), g && g({
452
+ }), f && f({
475
453
  payload: c,
476
454
  position: l,
477
455
  text: u,
@@ -482,53 +460,46 @@ const Te = [
482
460
  protectedRanges: s,
483
461
  playments: o
484
462
  };
485
- }, N = (e) => e.type === "text" || e.type === "customTag", ie = (e) => {
486
- const t = e.content || [];
487
- if (e.type === "paragraph") return [e];
488
- if (e.type === "doc")
489
- return t.filter((o) => o.type === "paragraph");
490
- const n = t.filter(
491
- (o) => o.type === "paragraph"
492
- );
493
- return n.length ? n : t.some(N) ? [
463
+ }, N = (t) => t.type === "text" || t.type === "customTag", at = (t) => {
464
+ const e = t.content || [];
465
+ if (t.type === "paragraph") return [t];
466
+ if (t.type === "doc")
467
+ return e.filter((o) => o.type === "paragraph");
468
+ const n = e.filter((o) => o.type === "paragraph");
469
+ return n.length ? n : e.some(N) ? [
494
470
  {
495
471
  type: "paragraph",
496
- content: t.filter(N)
472
+ content: e.filter(N)
497
473
  }
498
474
  ] : [];
499
- }, ae = (e, t) => {
475
+ }, lt = (t, e) => {
500
476
  let n = 0;
501
- return t.map((o) => {
502
- const s = e.indexOf(o, n), a = s >= 0 ? s : n, r = a + o.length;
477
+ return e.map((o) => {
478
+ const s = t.indexOf(o, n), a = s >= 0 ? s : n, r = a + o.length;
503
479
  return n = r, {
504
480
  text: o,
505
481
  start: a,
506
482
  end: r
507
483
  };
508
484
  });
509
- }, le = (e, t) => e.reduce((n, o) => {
510
- if (t.some(
485
+ }, ct = (t, e) => t.reduce((n, o) => {
486
+ if (e.some(
511
487
  (a) => o.start > a.start && o.start < a.end
512
488
  ) && n.length) {
513
489
  const a = n[n.length - 1];
514
490
  return a.text += o.text, a.end = o.end, n;
515
491
  }
516
492
  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),
522
- e.protectedRanges || []
493
+ }, []), ut = (t, e, n, o) => t.position >= e && t.position < n ? !0 : !t.text && o && t.position === n, pt = (t) => {
494
+ const e = st(t.text);
495
+ if (e.length <= 1) return [t];
496
+ const n = ct(
497
+ lt(t.text, e),
498
+ t.protectedRanges || []
523
499
  );
524
500
  return n.map((o, s) => {
525
- const a = s === n.length - 1, r = e.playments.filter(
526
- (i) => ce(
527
- i,
528
- o.start,
529
- o.end,
530
- a
531
- )
501
+ const a = s === n.length - 1, r = t.playments.filter(
502
+ (i) => ut(i, o.start, o.end, a)
532
503
  ).map((i) => ({
533
504
  ...i,
534
505
  position: i.position - o.start
@@ -538,36 +509,40 @@ const Te = [
538
509
  playments: r
539
510
  };
540
511
  });
541
- }, me = (e) => {
542
- const t = {
512
+ }, xt = (t) => {
513
+ const e = {
543
514
  playments: [],
544
515
  sentences: []
545
516
  };
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);
517
+ return at(t).forEach((o) => {
518
+ const s = it(o);
519
+ !s.text && !s.playments.length || pt(s).forEach(({ text: a, playments: r }) => {
520
+ e.sentences.push(a), e.playments.push(r);
550
521
  });
551
- }), t;
522
+ }), e;
552
523
  };
553
524
  export {
554
525
  h as DeleteMode,
526
+ gt as EditorConst,
555
527
  x as LanguageOptions,
556
- Te as NumberToTextTools,
557
- pe as StopOptions,
558
- f as ToolConfig,
559
- v as allToolTypes,
560
- me as convertToTtsFormat,
561
- he as estimateTtsDuration,
562
- fe as getInitContent,
563
- p as getVisualLength,
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,
528
+ _t as NumberToTextTools,
529
+ v as StopOptions,
530
+ p as ToolConfig,
531
+ D as allToolTypes,
532
+ xt as convertToTtsFormat,
533
+ mt as estimateTtsDuration,
534
+ ht as getDefaultLockPayload,
535
+ Et as getInitContent,
536
+ dt as getLockPayloadLabel,
537
+ g as getVisualLength,
538
+ ft as isInsertTagType,
539
+ Tt as resolveTtsEditorFeatures,
540
+ Nt as sanitizePastedHtml,
541
+ J as sanitizePastedText,
542
+ st as splitTextToSentences,
543
+ X as toCardinal,
544
+ G as toColloquial,
545
+ bt as toPhoneReading,
571
546
  y as toPositional,
572
- se as transformParagraph
547
+ it as transformParagraph
573
548
  };
@@ -1,4 +1,7 @@
1
1
  export { useEditorContext, useEditorProvider, useRichTextEditor, type RichTextEditor, type UseRichTextEditorOptions } from '../components/tts-rich-text/editor/useRichTextEditor';
2
+ export { useEditorToolkit, type EditorToolkit } from '../components/tts-rich-text/editor/useEditorToolkit';
3
+ export { useEditorToolbar, type ToolbarItem } from '../components/tts-rich-text/editor/useEditorToolbar';
4
+ export { type EditorContextMenuState, type ToolMenuItem, type ToolModalOpeners } from '../components/tts-rich-text/editor/type';
2
5
  export { createCustomTagNode, CustomTagName } from '../components/tts-rich-text/editor/nodes/tag-node';
3
6
  export { createTtsCharacterCount } from '../components/tts-rich-text/editor/plugins/tts-character-count';
4
7
  export { useSSETool, type UseSseToolOptions } from '../components/tts-rich-text/editor/useSSETool';