@linker-design-plus/tiny-peony 1.3.0 → 1.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.
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  var GE = Object.defineProperty;
2
2
  var kE = (C, e, Q) => e in C ? GE(C, e, { enumerable: !0, configurable: !0, writable: !0, value: Q }) : C[e] = Q;
3
3
  var X = (C, e, Q) => kE(C, typeof e != "symbol" ? e + "" : e, Q);
4
- import { getCurrentScope as LE, onScopeDispose as UE, isRef as SE, ref as cA, toValue as Dg, readonly as ME, watch as oI, computed as FA, shallowRef as VC, getCurrentInstance as CB, onMounted as Mg, toRaw as pE, defineComponent as MA, withDirectives as iI, openBlock as iA, createElementBlock as nA, normalizeClass as RA, unref as sA, withModifiers as BC, Fragment as $A, renderList as BB, createElementVNode as QA, toDisplayString as Ug, vShow as nI, createVNode as y, render as QC, createBlock as JE, withCtx as Cg, createTextVNode as LA, inject as Ag, normalizeStyle as yg, h as CI, nextTick as YE, resolveComponent as YA, mergeProps as rI, onBeforeUnmount as QB, reactive as HE, toRefs as mE, onUnmounted as EB, provide as eB, Teleport as KE } from "vue";
4
+ import { getCurrentScope as LE, onScopeDispose as UE, isRef as SE, ref as cA, toValue as Dg, readonly as ME, watch as oI, computed as FA, shallowRef as VC, getCurrentInstance as CB, onMounted as Mg, toRaw as pE, defineComponent as MA, withDirectives as iI, openBlock as iA, createElementBlock as nA, normalizeClass as RA, unref as sA, withModifiers as BC, Fragment as $A, renderList as BB, createElementVNode as QA, toDisplayString as Ug, vShow as nI, createVNode as y, render as QC, createBlock as JE, withCtx as Cg, createTextVNode as UA, inject as Ag, normalizeStyle as yg, h as CI, nextTick as YE, resolveComponent as YA, mergeProps as rI, onBeforeUnmount as QB, reactive as HE, toRefs as mE, onUnmounted as EB, provide as eB, Teleport as KE } from "vue";
5
5
  import { Message as Sg, Row as qE, Col as BI, Input as OC, Space as vE, Button as ZI, Modal as XC, Tooltip as xE } from "@arco-design/web-vue";
6
6
  var tB = (C) => Object.prototype.toString.call(C), bE = (C) => tB(C) === "[object Null]", TE = (C) => tB(C) === "[object Number]", _I = (C, e) => e ? typeof e == "string" ? ` ${C}--${e}` : Array.isArray(e) ? e.reduce((Q, o) => Q + _I(C, o), "") : Object.keys(e).reduce((Q, o) => Q + (e[o] ? _I(C, o) : ""), "") : "", PE = (C) => (e, Q) => (e && typeof e != "string" && (Q = e, e = ""), e = e ? `${C}__${e}` : C, `${e}${_I(e, Q)}`), oB = (C) => (e) => {
7
7
  const Q = `${C}-${e}`;
@@ -92,7 +92,7 @@ class Ie extends XE {
92
92
  const i = EC(this._editor, nB(Q) ? Q : [Q]), s = this.getParas()[0], a = (n = s.textContent) != null && n.length ? void 0 : i.shift();
93
93
  a && (s.innerHTML = a, o == null || o(s)), i.forEach((w) => {
94
94
  const h = document.createElement("p");
95
- h.innerHTML = w, h.classList.add(UA), this._editorElement.appendChild(h), o == null || o(h);
95
+ h.innerHTML = w, h.classList.add(kA), this._editorElement.appendChild(h), o == null || o(h);
96
96
  });
97
97
  }
98
98
  // 增加内容
@@ -110,7 +110,7 @@ class Ie extends XE {
110
110
  // 获取段落节点
111
111
  getParas() {
112
112
  return Array.from(
113
- this._editorElement.querySelectorAll(`.${UA}`)
113
+ this._editorElement.querySelectorAll(`.${kA}`)
114
114
  );
115
115
  }
116
116
  // 获取纯文本内容(段落划分)
@@ -141,7 +141,11 @@ class Ie extends XE {
141
141
  } else
142
142
  s.appendChild(Q);
143
143
  const a = s.lastChild;
144
- i.insertNode(s);
144
+ if (i.commonAncestorContainer.tagName === "DIV") {
145
+ const w = document.createElement("p");
146
+ w.classList.add(kA), w.appendChild(s), i.insertNode(w);
147
+ } else
148
+ i.insertNode(s);
145
149
  const n = document.createRange();
146
150
  n.setStartAfter(a), n.setEndAfter(a), o.removeAllRanges(), o.addRange(n);
147
151
  }
@@ -220,7 +224,7 @@ class Be extends ZE {
220
224
  let i = Q;
221
225
  for (; i && i.parentElement; ) {
222
226
  const a = Array.from(i.parentElement.childNodes).indexOf(i);
223
- if (o.unshift({ index: a }), oA(i) && i.tagName === "P" && i.classList.contains(UA))
227
+ if (o.unshift({ index: a }), oA(i) && i.tagName === "P" && i.classList.contains(kA))
224
228
  break;
225
229
  i = i.parentElement;
226
230
  }
@@ -326,7 +330,7 @@ const EI = (C, e) => {
326
330
  n = window.getSelection().getRangeAt(0), n = yA(n.commonAncestorContainer) && n.commonAncestorContainer.textContent === "粘贴文本" ? o : n;
327
331
  const [f] = SA(
328
332
  n.commonAncestorContainer,
329
- (T) => T.tagName === "P" && T.classList.contains(UA)
333
+ (T) => T.tagName === "P" && T.classList.contains(kA)
330
334
  ), [R] = SA(n.startContainer, (T) => T.tagName === "SPAN" && T.dataset.type === q.anchor), G = document.createRange(), U = !!R;
331
335
  G.setStart(n.startContainer, n.startOffset), G.setEndAfter(f.lastChild);
332
336
  const L = G.extractContents();
@@ -347,13 +351,13 @@ const EI = (C, e) => {
347
351
  if (a.forEach((T) => {
348
352
  var lA;
349
353
  const $ = document.createElement("p");
350
- if ($.classList.add(UA), $.textContent = T, (lA = f == null ? void 0 : f.parentNode) == null || lA.insertBefore($, J), J = $.nextSibling, EI(C, $), U) {
354
+ if ($.classList.add(kA), $.textContent = T, (lA = f == null ? void 0 : f.parentNode) == null || lA.insertBefore($, J), J = $.nextSibling, EI(C, $), U) {
351
355
  const V = R.cloneNode(!1);
352
356
  V.innerHTML = $.innerHTML, $.innerHTML = V.outerHTML;
353
357
  }
354
358
  }), !s) return;
355
359
  const M = document.createElement("p");
356
- if (M.classList.add(UA), M.appendChild(L), !M.textContent)
360
+ if (M.classList.add(kA), M.appendChild(L), !M.textContent)
357
361
  M.innerHTML = s;
358
362
  else if (yA(M.firstChild))
359
363
  M.firstChild.textContent = s + M.firstChild.textContent;
@@ -366,7 +370,7 @@ const EI = (C, e) => {
366
370
  var $;
367
371
  return !(($ = M.textContent) != null && $.trim().endsWith(`停顿: ${T}S`));
368
372
  }) && EI(C, M);
369
- }, [oe] = vA("paragraph"), UA = oe(), ie = `<p class="${UA}"><br /></p>`;
373
+ }, [oe] = vA("paragraph"), kA = oe(), ie = `<p class="${kA}"><br /></p>`;
370
374
  class ne extends OE {
371
375
  constructor(Q, o) {
372
376
  super();
@@ -413,7 +417,7 @@ class ne extends OE {
413
417
  }
414
418
  }
415
419
  Q.addedNodes.forEach((i) => {
416
- oA(i) && i.tagName === "P" && !i.classList.contains(UA) && i.classList.add(UA);
420
+ oA(i) && i.tagName === "P" && !i.classList.contains(kA) && i.classList.add(kA);
417
421
  }), Q.removedNodes.length && !this.content.getParas().length && this.content.insertEmptyPara(), (o = this._onchange) == null || o.call(this, this.content.calcTextCount()), Array.from(document.querySelectorAll("p span")).forEach((i) => {
418
422
  var D;
419
423
  const s = i.parentNode, a = i.firstChild, n = i && i.style.textIndent === "20px" && i.style.fontSize && i.style.color, w = i && i.style.backgroundColor && ((D = i.parentElement) == null ? void 0 : D.style.textIndent) === "0px", h = i && Array.from(i.childNodes).every((u) => yA(u) && !u.textContent || oA(u) && u.tagName === "BR");
@@ -446,7 +450,7 @@ class ne extends OE {
446
450
  var s;
447
451
  const o = window.getSelection(), i = o.getRangeAt(0);
448
452
  if (Q.key === "Backspace" && i.startOffset === 0 && i.collapsed) {
449
- const [a] = SA(i.startContainer, (w) => w.tagName === "P" && w.classList.contains(UA)), n = a == null ? void 0 : a.previousElementSibling;
453
+ const [a] = SA(i.startContainer, (w) => w.tagName === "P" && w.classList.contains(kA)), n = a == null ? void 0 : a.previousElementSibling;
450
454
  if (n) {
451
455
  Q.preventDefault();
452
456
  const w = n.childNodes, h = n.childNodes[0];
@@ -536,7 +540,7 @@ const Jg = (C, e, Q, o) => {
536
540
  }, _A = (C) => {
537
541
  const [e] = SA(
538
542
  C,
539
- (Q) => Q.tagName === "P" && Q.classList.contains(UA)
543
+ (Q) => Q.tagName === "P" && Q.classList.contains(kA)
540
544
  );
541
545
  return e;
542
546
  }, re = (C, e) => {
@@ -1005,7 +1009,7 @@ const Me = { style: { display: "none" } }, pe = /* @__PURE__ */ MA({
1005
1009
  class: RA(sA(i)("title"))
1006
1010
  }, {
1007
1011
  default: Cg(() => h[2] || (h[2] = [
1008
- LA("读音替换")
1012
+ UA("读音替换")
1009
1013
  ])),
1010
1014
  _: 1
1011
1015
  }, 8, ["class"]),
@@ -1052,7 +1056,7 @@ const Me = { style: { display: "none" } }, pe = /* @__PURE__ */ MA({
1052
1056
  return [
1053
1057
  y(sA(ZI), { onClick: a }, {
1054
1058
  default: Cg(() => h[3] || (h[3] = [
1055
- LA("取消")
1059
+ UA("取消")
1056
1060
  ])),
1057
1061
  _: 1
1058
1062
  }),
@@ -1062,7 +1066,7 @@ const Me = { style: { display: "none" } }, pe = /* @__PURE__ */ MA({
1062
1066
  onClick: s
1063
1067
  }, {
1064
1068
  default: Cg(() => h[4] || (h[4] = [
1065
- LA("替换")
1069
+ UA("替换")
1066
1070
  ])),
1067
1071
  _: 1
1068
1072
  }, 8, ["disabled"])
@@ -2162,7 +2166,7 @@ var mt = Object.create, RB = Object.defineProperty, Kt = Object.getOwnPropertyDe
2162
2166
  function KB() {
2163
2167
  var A = mB();
2164
2168
  function g(B, t) {
2165
- return kA = B.exports, mA = kA.F, IA(), cC = kA.I, LB(kA.G), vg(), kA;
2169
+ return LA = B.exports, mA = LA.F, IA(), cC = LA.I, LB(LA.G), vg(), LA;
2166
2170
  }
2167
2171
  wI();
2168
2172
  function I(B) {
@@ -3992,8 +3996,8 @@ return ret;
3992
3996
  super(A), this.name = "InternalError";
3993
3997
  }
3994
3998
  }, IQ(), _B(), nQ(), fC = n.UnboundTypeError = lQ(Error, "UnboundTypeError"), NQ(), E.createPreloadedFile = rE, E.staticInit();
3995
- var NE = { t: qB, f: xB, x: bB, p: TB, k: WB, j: wQ, d: yQ, o: uQ, c: fQ, E: GC, i: LQ, b: SQ, a: MQ, y: pQ, h: JQ, e: xQ, l: bQ, v: TQ, w: PQ, u: jQ, m: VQ, r: _Q, s: AE, B: IE, C: CE, A: sE, z: lE, n: hE, g: dE, D: YC, q: FE }, kA = KB(), xC = (A) => (xC = kA.H)(A), JI = (A) => (JI = kA.J)(A), ZA = (A) => (ZA = kA.K)(A), bC = (A, g) => (bC = kA.L)(A, g), TC = (A, g) => (TC = kA.M)(A, g), PC = (A) => (PC = kA.N)(A);
3996
- n.dynCall_jiji = (A, g, I, B, t) => (n.dynCall_jiji = kA.O)(A, g, I, B, t), n.dynCall_viijii = (A, g, I, B, t, r, c) => (n.dynCall_viijii = kA.P)(A, g, I, B, t, r, c), n.dynCall_iiiiij = (A, g, I, B, t, r, c) => (n.dynCall_iiiiij = kA.Q)(A, g, I, B, t, r, c), n.dynCall_iiiiijj = (A, g, I, B, t, r, c, l, d) => (n.dynCall_iiiiijj = kA.R)(A, g, I, B, t, r, c, l, d), n.dynCall_iiiiiijj = (A, g, I, B, t, r, c, l, d, F) => (n.dynCall_iiiiiijj = kA.S)(A, g, I, B, t, r, c, l, d, F);
3999
+ var NE = { t: qB, f: xB, x: bB, p: TB, k: WB, j: wQ, d: yQ, o: uQ, c: fQ, E: GC, i: LQ, b: SQ, a: MQ, y: pQ, h: JQ, e: xQ, l: bQ, v: TQ, w: PQ, u: jQ, m: VQ, r: _Q, s: AE, B: IE, C: CE, A: sE, z: lE, n: hE, g: dE, D: YC, q: FE }, LA = KB(), xC = (A) => (xC = LA.H)(A), JI = (A) => (JI = LA.J)(A), ZA = (A) => (ZA = LA.K)(A), bC = (A, g) => (bC = LA.L)(A, g), TC = (A, g) => (TC = LA.M)(A, g), PC = (A) => (PC = LA.N)(A);
4000
+ n.dynCall_jiji = (A, g, I, B, t) => (n.dynCall_jiji = LA.O)(A, g, I, B, t), n.dynCall_viijii = (A, g, I, B, t, r, c) => (n.dynCall_viijii = LA.P)(A, g, I, B, t, r, c), n.dynCall_iiiiij = (A, g, I, B, t, r, c) => (n.dynCall_iiiiij = LA.Q)(A, g, I, B, t, r, c), n.dynCall_iiiiijj = (A, g, I, B, t, r, c, l, d) => (n.dynCall_iiiiijj = LA.R)(A, g, I, B, t, r, c, l, d), n.dynCall_iiiiiijj = (A, g, I, B, t, r, c, l, d, F) => (n.dynCall_iiiiiijj = LA.S)(A, g, I, B, t, r, c, l, d, F);
3997
4001
  var II;
3998
4002
  ug = function A() {
3999
4003
  II || jC(), II || (ug = A);
@@ -4221,7 +4225,7 @@ const zt = [
4221
4225
  var j;
4222
4226
  const S = (j = i.value) == null ? void 0 : j.base.cursor.range;
4223
4227
  if (v(S)) return !1;
4224
- const [Y] = SA(S.startContainer, (Z) => Z.tagName === "P" && Z.classList.contains(UA)), [x] = SA(S.endContainer, (Z) => Z.tagName === "P" && Z.classList.contains(UA));
4228
+ const [Y] = SA(S.startContainer, (Z) => Z.tagName === "P" && Z.classList.contains(kA)), [x] = SA(S.endContainer, (Z) => Z.tagName === "P" && Z.classList.contains(kA));
4225
4229
  return !(v(Y) || v(x) || Y === x);
4226
4230
  }, lA = (S) => {
4227
4231
  var Z, P;
@@ -4282,7 +4286,7 @@ const zt = [
4282
4286
  R(""), setTimeout(() => {
4283
4287
  var Z, P;
4284
4288
  const S = window.getSelection(), Y = S != null && S.rangeCount ? S == null ? void 0 : S.getRangeAt(0) : null;
4285
- if (v(S) || Y && oA(Y.commonAncestorContainer) && Y.commonAncestorContainer.classList.contains(UA))
4289
+ if (v(S) || Y && oA(Y.commonAncestorContainer) && Y.commonAncestorContainer.classList.contains(kA))
4286
4290
  return;
4287
4291
  const x = document.createRange(), j = (P = (Z = o.value) == null ? void 0 : Z.content.getParas()) == null ? void 0 : P[0];
4288
4292
  v(j) || (x.selectNodeContents(j), x.collapse(!1), S.removeAllRanges(), S.addRange(x));
@@ -4919,7 +4923,7 @@ const GB = /* @__PURE__ */ uA(_o, [["render", Ai]]), [AB] = vA("refine-input"),
4919
4923
  color: "rgba(var(--primary-6))",
4920
4924
  fontSize: "16px"
4921
4925
  }
4922
- }, null), LA("AI改写")]), y(YA("a-divider"), {
4926
+ }, null), UA("AI改写")]), y(YA("a-divider"), {
4923
4927
  direction: "vertical",
4924
4928
  margin: "4px"
4925
4929
  }, null), y("div", {
@@ -4929,7 +4933,7 @@ const GB = /* @__PURE__ */ uA(_o, [["render", Ai]]), [AB] = vA("refine-input"),
4929
4933
  style: {
4930
4934
  fontSize: "16px"
4931
4935
  }
4932
- }, null), LA("复制")])]);
4936
+ }, null), UA("复制")])]);
4933
4937
  }
4934
4938
  }), [Bi] = vA("refine-generator"), Qi = /* @__PURE__ */ MA({
4935
4939
  name: "RefineGenerator",
@@ -4968,8 +4972,7 @@ const GB = /* @__PURE__ */ uA(_o, [["render", Ai]]), [AB] = vA("refine-input"),
4968
4972
  const BA = b.range.getBoundingClientRect();
4969
4973
  R({
4970
4974
  top: `${BA.bottom + 10}px`,
4971
- left: `${BA.left}px`,
4972
- // left: 0,
4975
+ left: `${e.editorCore.value._editorElement.getBoundingClientRect().left - 4}px`,
4973
4976
  width: `${e.editorCore.value._editorElement.offsetWidth}px`
4974
4977
  }), U(!0);
4975
4978
  }, J = (b) => {
@@ -5313,7 +5316,7 @@ const gB = /* @__PURE__ */ uA(ri, [["render", ai]]), [pA] = vA("editor-container
5313
5316
  default: lI,
5314
5317
  content: () => y("section", {
5315
5318
  class: qA("tooltip")
5316
- }, [y("p", null, [LA("主播: "), AA.name]), y("p", null, [LA("情绪: "), AA.activeEmotion]), AA.activeRole && AA.activeRole !== "无" ? y("p", null, [LA("角色: "), AA.activeRole || "--"]) : null, y("p", null, [LA("语速: "), AA.speed]), y("p", null, [LA("音量: "), AA.volume])])
5319
+ }, [y("p", null, [UA("主播: "), AA.name]), y("p", null, [UA("情绪: "), AA.activeEmotion]), AA.activeRole && AA.activeRole !== "无" ? y("p", null, [UA("角色: "), AA.activeRole || "--"]) : null, y("p", null, [UA("语速: "), AA.speed]), y("p", null, [UA("音量: "), AA.volume])])
5317
5320
  }))(() => y("section", {
5318
5321
  class: qA(),
5319
5322
  style: {
@@ -5332,7 +5335,7 @@ const gB = /* @__PURE__ */ uA(ri, [["render", ai]]), [pA] = vA("editor-container
5332
5335
  title: AA.name
5333
5336
  }, [AA.name]), y("label", {
5334
5337
  class: qA("info-speed-volume")
5335
- }, [LA("语速: "), AA.speed, LA(", 音量: "), AA.volume]), y("div", {
5338
+ }, [UA("语速: "), AA.speed, UA(", 音量: "), AA.volume]), y("div", {
5336
5339
  onClick: () => S(b, BA, AA)
5337
5340
  }, [y(gB, {
5338
5341
  class: qA("info-rem")
@@ -5359,16 +5362,16 @@ const gB = /* @__PURE__ */ uA(ri, [["render", ai]]), [pA] = vA("editor-container
5359
5362
  class: pA("status-clear"),
5360
5363
  onClick: EA
5361
5364
  }, {
5362
- default: () => [LA("清空")]
5365
+ default: () => [UA("清空")]
5363
5366
  })), y("div", {
5364
5367
  class: pA("status-info")
5365
5368
  }, [C.simple ? null : y($A, null, [y("label", {
5366
5369
  class: pA("status-info-label")
5367
- }, [y("span", null, [LA("预计时长:")]), y("span", null, [C.preTime || "00:00:00"])]), y("label", {
5370
+ }, [y("span", null, [UA("预计时长:")]), y("span", null, [C.preTime || "00:00:00"])]), y("label", {
5368
5371
  class: pA("status-info-label")
5369
- }, [y("span", null, [LA("实际时长:")]), y("span", null, [C.realTime || "00:00:00"])])]), C.showWordLimit ? y("label", {
5372
+ }, [y("span", null, [UA("实际时长:")]), y("span", null, [C.realTime || "00:00:00"])])]), C.showWordLimit ? y("label", {
5370
5373
  class: pA("status-info-length")
5371
- }, [y("span", null, [n.value <= C.maxLength ? n.value : C.maxLength]), y("span", null, [LA(" / ")]), y("span", null, [C.maxLength, C.simple ? "" : "字"])]) : null])]);
5374
+ }, [y("span", null, [n.value <= C.maxLength ? n.value : C.maxLength]), y("span", null, [UA(" / ")]), y("span", null, [C.maxLength, C.simple ? "" : "字"])]) : null])]);
5372
5375
  }, P = cA();
5373
5376
  return {
5374
5377
  action: a,
@@ -5397,7 +5400,7 @@ const gB = /* @__PURE__ */ uA(ri, [["render", ai]]), [pA] = vA("editor-container
5397
5400
  onDragover: (IA) => IA.preventDefault(),
5398
5401
  onDrop: (IA) => IA.preventDefault()
5399
5402
  }, [y("p", {
5400
- class: UA
5403
+ class: kA
5401
5404
  }, [y("br", null, null)])])])]), C.simple ? null : y("div", {
5402
5405
  ref: i,
5403
5406
  class: pA("core-anchor")
@@ -5489,7 +5492,7 @@ const gB = /* @__PURE__ */ uA(ri, [["render", ai]]), [pA] = vA("editor-container
5489
5492
  return this.innerClearContent();
5490
5493
  },
5491
5494
  clear() {
5492
- return this.setContent(`<p class="${UA}"><br /></p>`);
5495
+ return this.setContent(`<p class="${kA}"><br /></p>`);
5493
5496
  },
5494
5497
  renderHighlight(C) {
5495
5498
  return this.innerRenderHightlight(C);