officialblock 2.9.6 → 2.9.8

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,16 +1,16 @@
1
- var T = Object.defineProperty;
2
- var $ = (u, s, i) => s in u ? T(u, s, { enumerable: !0, configurable: !0, writable: !0, value: i }) : u[s] = i;
3
- var c = (u, s, i) => $(u, typeof s != "symbol" ? s + "" : s, i);
4
- import { defineComponent as R, shallowRef as q, ref as C, computed as J, inject as p, watch as y, nextTick as D, onBeforeUnmount as G, createElementBlock as P, openBlock as Q, createVNode as _, unref as w, normalizeStyle as W } from "vue";
5
- import { Toolbar as X, Editor as Y } from "@wangeditor/editor-for-vue";
6
- import { Boot as I } from "@wangeditor/editor";
7
- import { a as Z } from "./index-BdAKIdHU.mjs";
8
- const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
1
+ var j = Object.defineProperty;
2
+ var T = (a, u, c) => u in a ? j(a, u, { enumerable: !0, configurable: !0, writable: !0, value: c }) : a[u] = c;
3
+ var r = (a, u, c) => T(a, typeof u != "symbol" ? u + "" : u, c);
4
+ import { defineComponent as $, shallowRef as R, ref as g, computed as q, inject as C, watch as p, nextTick as y, onBeforeUnmount as J, createElementBlock as P, openBlock as G, createVNode as S, unref as _, normalizeStyle as Q } from "vue";
5
+ import { Toolbar as W, Editor as X } from "@wangeditor/editor-for-vue";
6
+ import { Boot as w } from "@wangeditor/editor";
7
+ import { a as Y } from "./index-DzaQCQTY.mjs";
8
+ const Z = { class: "rich-text-editor" }, ee = /* @__PURE__ */ $({
9
9
  __name: "index",
10
10
  props: {
11
11
  name: { default: "" },
12
12
  modelValue: { default: "" },
13
- placeholder: { default: t("placeholder.please_input_content") },
13
+ placeholder: { default: "Please input content..." },
14
14
  height: { default: "400px" },
15
15
  mode: { default: "default" },
16
16
  disabled: { type: Boolean, default: !1 },
@@ -19,70 +19,70 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
19
19
  includeKeys: { default: () => [] }
20
20
  },
21
21
  emits: ["update:modelValue", "change", "focus", "blur", "created", "upload-image", "upload-video"],
22
- setup(u, { expose: s, emit: i }) {
23
- const a = u, m = i, o = q(), d = C(""), H = J(() => typeof a.height == "number" ? `${a.height}px` : a.height), E = p("handleUpload", () => {
24
- }), F = p("fileUrl", null), b = p("chooseName", null), f = C(""), h = C(null), B = (e) => {
25
- if (!E) {
22
+ setup(a, { expose: u, emit: c }) {
23
+ const n = a, d = c, t = R(), i = g(""), I = q(() => typeof n.height == "number" ? `${n.height}px` : n.height), D = C("handleUpload", () => {
24
+ }), m = C("fileUrl", null), E = C("chooseName", null), F = g(""), f = g(null), b = (e) => {
25
+ if (!D) {
26
26
  console.warn("Upload: handleUpload function not provided by ancestor");
27
27
  return;
28
28
  }
29
- if (f.value = e, o.value)
29
+ if (F.value = e, t.value)
30
30
  try {
31
- const l = o.value.selection;
32
- l && (h.value = {
31
+ const o = t.value.selection;
32
+ o && (f.value = {
33
33
  anchor: {
34
- path: [...l.anchor.path],
35
- offset: l.anchor.offset
34
+ path: [...o.anchor.path],
35
+ offset: o.anchor.offset
36
36
  },
37
37
  focus: {
38
- path: [...l.focus.path],
39
- offset: l.focus.offset
38
+ path: [...o.focus.path],
39
+ offset: o.focus.offset
40
40
  }
41
41
  });
42
- } catch (l) {
43
- console.warn("保存光标位置失败:", l);
42
+ } catch (o) {
43
+ console.warn("保存光标位置失败:", o);
44
44
  }
45
- const n = a.name + "_" + e;
46
- E(!0, n);
45
+ const l = n.name + "_" + e;
46
+ D(!0, l);
47
47
  };
48
- y(() => a.name, () => {
49
- F.value = null;
50
- }, { deep: !0, immediate: !0 }), y(
51
- () => [F == null ? void 0 : F.value],
48
+ p(() => n.name, () => {
49
+ m.value = null;
50
+ }, { deep: !0, immediate: !0 }), p(
51
+ () => [m == null ? void 0 : m.value],
52
52
  ([e]) => {
53
- const n = a.name + "_" + f.value;
54
- !e || !b.value || b.value !== n || o.value && D(() => {
55
- var l, v;
56
- if (o.value) {
53
+ const l = n.name + "_" + F.value;
54
+ !e || !E.value || E.value !== l || t.value && y(() => {
55
+ var o, h;
56
+ if (t.value) {
57
57
  try {
58
- if (o.value.focus(), h.value)
58
+ if (t.value.focus(), f.value)
59
59
  try {
60
- o.value.select(h.value);
61
- } catch (r) {
62
- console.warn("恢复光标位置失败,使用默认位置:", r);
60
+ t.value.select(f.value);
61
+ } catch (s) {
62
+ console.warn("恢复光标位置失败,使用默认位置:", s);
63
63
  }
64
- } catch (r) {
65
- console.warn("聚焦编辑器失败:", r);
64
+ } catch (s) {
65
+ console.warn("聚焦编辑器失败:", s);
66
66
  }
67
- if (f.value === "img") {
68
- const g = `<img src="${e}" alt="图片" style="max-width: 100%;">`;
69
- (l = o.value) == null || l.dangerouslyInsertHtml(g);
67
+ if (F.value === "img") {
68
+ const v = `<img src="${e}" alt="图片" style="max-width: 100%;">`;
69
+ (o = t.value) == null || o.dangerouslyInsertHtml(v);
70
70
  } else {
71
- const g = `<video src="${e}" controls style="max-width: 100%;"></video>`;
72
- (v = o.value) == null || v.dangerouslyInsertHtml(g);
71
+ const v = `<video src="${e}" controls style="max-width: 100%;"></video>`;
72
+ (h = t.value) == null || h.dangerouslyInsertHtml(v);
73
73
  }
74
- h.value = null, f.value = "";
74
+ f.value = null, F.value = "";
75
75
  }
76
76
  });
77
77
  },
78
78
  { immediate: !1 }
79
79
  );
80
- function k(e) {
80
+ function H(e) {
81
81
  return class {
82
82
  constructor() {
83
- c(this, "title");
84
- c(this, "tag");
85
- c(this, "iconSvg");
83
+ r(this, "title");
84
+ r(this, "tag");
85
+ r(this, "iconSvg");
86
86
  this.title = "上传图片", this.tag = "button", this.iconSvg = '<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>';
87
87
  }
88
88
  isActive() {
@@ -95,18 +95,18 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
95
95
  return !1;
96
96
  }
97
97
  exec() {
98
- D(() => {
98
+ y(() => {
99
99
  console.log("点击了自定义上传图片菜单"), e("img");
100
100
  });
101
101
  }
102
102
  };
103
103
  }
104
- function z(e) {
104
+ function k(e) {
105
105
  return class {
106
106
  constructor() {
107
- c(this, "title");
108
- c(this, "tag");
109
- c(this, "iconSvg");
107
+ r(this, "title");
108
+ r(this, "tag");
109
+ r(this, "iconSvg");
110
110
  this.title = "上传视频", this.tag = "button", this.iconSvg = '<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>';
111
111
  }
112
112
  getValue() {
@@ -119,13 +119,13 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
119
119
  return !1;
120
120
  }
121
121
  exec() {
122
- D(() => {
122
+ y(() => {
123
123
  console.log("点击了自定义上传视频菜单"), e("video");
124
124
  });
125
125
  }
126
126
  };
127
127
  }
128
- const x = {
128
+ const B = {
129
129
  toolbarKeys: [
130
130
  // 菜单 key
131
131
  "headerSelect",
@@ -171,7 +171,7 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
171
171
  "codeBlock"
172
172
  //代码块
173
173
  ]
174
- }, M = [
174
+ }, x = [
175
175
  // 5个品牌默认颜色
176
176
  "#0032A0",
177
177
  "#FF0044",
@@ -248,16 +248,16 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
248
248
  "#061178",
249
249
  "#22075E",
250
250
  "#780650"
251
- ], K = {
252
- placeholder: a.placeholder,
253
- readOnly: a.disabled,
254
- maxLength: a.maxLength,
251
+ ], z = {
252
+ placeholder: n.placeholder,
253
+ readOnly: n.disabled,
254
+ maxLength: n.maxLength,
255
255
  MENU_CONF: {
256
256
  color: {
257
- colors: M
257
+ colors: x
258
258
  },
259
259
  bgColor: {
260
- colors: M
260
+ colors: x
261
261
  }
262
262
  },
263
263
  // --- 新增:自定义选中文字时的气泡菜单 ---
@@ -279,104 +279,104 @@ const ee = { class: "rich-text-editor" }, te = /* @__PURE__ */ R({
279
279
  ]
280
280
  }
281
281
  }
282
- }, A = Math.random().toString(36).substring(2, 9), V = `CustomImageMenu_${A}`, S = `CustomVideoMenu_${A}`, L = (e) => {
283
- o.value = e;
282
+ }, M = Math.random().toString(36).substring(2, 9), A = `CustomImageMenu_${M}`, V = `CustomVideoMenu_${M}`, K = (e) => {
283
+ t.value = e;
284
284
  try {
285
- const n = k(B), l = z(B), v = {
286
- key: V,
285
+ const l = H(b), o = k(b), h = {
286
+ key: A,
287
287
  // 使用唯一的 key
288
288
  factory() {
289
- return new n();
289
+ return new l();
290
290
  }
291
- }, r = {
292
- key: S,
291
+ }, s = {
292
+ key: V,
293
293
  // 使用唯一的 key
294
294
  factory() {
295
- return new l();
295
+ return new o();
296
296
  }
297
297
  };
298
- I.registerMenu(v), I.registerMenu(r);
299
- } catch (n) {
300
- console.warn("菜单注册失败:", n);
298
+ w.registerMenu(h), w.registerMenu(s);
299
+ } catch (l) {
300
+ console.warn("菜单注册失败:", l);
301
301
  }
302
- x.insertKeys = {
302
+ B.insertKeys = {
303
303
  index: 0,
304
- keys: [V, S]
305
- }, m("created", e);
304
+ keys: [A, V]
305
+ }, d("created", e);
306
306
  };
307
- G(() => {
308
- const e = o.value;
307
+ J(() => {
308
+ const e = t.value;
309
309
  e != null && e.destroy();
310
- }), y(
311
- () => a.modelValue,
310
+ }), p(
311
+ () => n.modelValue,
312
312
  (e) => {
313
- e !== d.value && (d.value = e || "");
313
+ e !== i.value && (i.value = e || "");
314
314
  },
315
315
  { immediate: !0 }
316
316
  );
317
- const N = (e) => {
318
- m("update:modelValue", d.value), m("change", e);
319
- }, O = () => {
320
- o.value = void 0;
317
+ const L = (e) => {
318
+ d("update:modelValue", i.value), d("change", e);
319
+ }, N = () => {
320
+ t.value = void 0;
321
+ }, O = (e) => {
322
+ d("focus", e);
321
323
  }, U = (e) => {
322
- m("focus", e);
323
- }, j = (e) => {
324
- m("blur", e);
324
+ d("blur", e);
325
325
  };
326
- return s({
327
- editor: o,
328
- getHtml: () => d.value,
326
+ return u({
327
+ editor: t,
328
+ getHtml: () => i.value,
329
329
  getText: () => {
330
330
  var e;
331
- return ((e = o.value) == null ? void 0 : e.getText()) || "";
331
+ return ((e = t.value) == null ? void 0 : e.getText()) || "";
332
332
  },
333
333
  isEmpty: () => {
334
334
  var e;
335
- return ((e = o.value) == null ? void 0 : e.isEmpty()) || !0;
335
+ return ((e = t.value) == null ? void 0 : e.isEmpty()) || !0;
336
336
  },
337
337
  clear: () => {
338
338
  var e;
339
- return (e = o.value) == null ? void 0 : e.clear();
339
+ return (e = t.value) == null ? void 0 : e.clear();
340
340
  },
341
341
  focus: () => {
342
342
  var e;
343
- return (e = o.value) == null ? void 0 : e.focus();
343
+ return (e = t.value) == null ? void 0 : e.focus();
344
344
  },
345
345
  blur: () => {
346
346
  var e;
347
- return (e = o.value) == null ? void 0 : e.blur();
347
+ return (e = t.value) == null ? void 0 : e.blur();
348
348
  },
349
349
  disable: () => {
350
350
  var e;
351
- return (e = o.value) == null ? void 0 : e.disable();
351
+ return (e = t.value) == null ? void 0 : e.disable();
352
352
  },
353
353
  enable: () => {
354
354
  var e;
355
- return (e = o.value) == null ? void 0 : e.enable();
355
+ return (e = t.value) == null ? void 0 : e.enable();
356
356
  }
357
- }), (e, n) => (Q(), P("div", ee, [
358
- _(w(X), {
357
+ }), (e, l) => (G(), P("div", Z, [
358
+ S(_(W), {
359
359
  class: "editor-toolbar",
360
- editor: o.value,
361
- defaultConfig: x,
362
- mode: u.mode
360
+ editor: t.value,
361
+ defaultConfig: B,
362
+ mode: a.mode
363
363
  }, null, 8, ["editor", "mode"]),
364
- _(w(Y), {
364
+ S(_(X), {
365
365
  class: "editor-content",
366
- style: W({ height: H.value }),
367
- modelValue: d.value,
368
- "onUpdate:modelValue": n[0] || (n[0] = (l) => d.value = l),
369
- defaultConfig: K,
370
- mode: u.mode,
371
- onOnCreated: L,
372
- onOnChange: N,
373
- onOnDestroyed: O,
374
- onOnFocus: U,
375
- onOnBlur: j
366
+ style: Q({ height: I.value }),
367
+ modelValue: i.value,
368
+ "onUpdate:modelValue": l[0] || (l[0] = (o) => i.value = o),
369
+ defaultConfig: z,
370
+ mode: a.mode,
371
+ onOnCreated: K,
372
+ onOnChange: L,
373
+ onOnDestroyed: N,
374
+ onOnFocus: O,
375
+ onOnBlur: U
376
376
  }, null, 8, ["style", "modelValue", "mode"])
377
377
  ]));
378
378
  }
379
- }), ce = /* @__PURE__ */ Z(te, [["__scopeId", "data-v-c3852efa"]]);
379
+ }), re = /* @__PURE__ */ Y(ee, [["__scopeId", "data-v-e97d4bf7"]]);
380
380
  export {
381
- ce as default
381
+ re as default
382
382
  };
@@ -0,0 +1 @@
1
+ "use strict";var K=Object.defineProperty;var N=(u,r,i)=>r in u?K(u,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[r]=i;var c=(u,r,i)=>N(u,typeof r!="symbol"?r+"":r,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),M=require("@wangeditor/editor-for-vue"),A=require("@wangeditor/editor"),O=require("./index-dKy0JrnP.js"),T={class:"rich-text-editor"},L=t.defineComponent({__name:"index",props:{name:{default:""},modelValue:{default:""},placeholder:{default:"Please input content..."},height:{default:"400px"},mode:{default:"default"},disabled:{type:Boolean,default:!1},maxLength:{default:1e4},excludeKeys:{default:()=>[]},includeKeys:{default:()=>[]}},emits:["update:modelValue","change","focus","blur","created","upload-image","upload-video"],setup(u,{expose:r,emit:i}){const a=u,F=i,o=t.shallowRef(),d=t.ref(""),V=t.computed(()=>typeof a.height=="number"?`${a.height}px`:a.height),C=t.inject("handleUpload",()=>{}),m=t.inject("fileUrl",null),y=t.inject("chooseName",null),f=t.ref(""),h=t.ref(null),p=e=>{if(!C){console.warn("Upload: handleUpload function not provided by ancestor");return}if(f.value=e,o.value)try{const l=o.value.selection;l&&(h.value={anchor:{path:[...l.anchor.path],offset:l.anchor.offset},focus:{path:[...l.focus.path],offset:l.focus.offset}})}catch(l){console.warn("保存光标位置失败:",l)}const n=a.name+"_"+e;C(!0,n)};t.watch(()=>a.name,()=>{m.value=null},{deep:!0,immediate:!0}),t.watch(()=>[m==null?void 0:m.value],([e])=>{const n=a.name+"_"+f.value;!e||!y.value||y.value!==n||o.value&&t.nextTick(()=>{var l,v;if(o.value){try{if(o.value.focus(),h.value)try{o.value.select(h.value)}catch(s){console.warn("恢复光标位置失败,使用默认位置:",s)}}catch(s){console.warn("聚焦编辑器失败:",s)}if(f.value==="img"){const g=`<img src="${e}" alt="图片" style="max-width: 100%;">`;(l=o.value)==null||l.dangerouslyInsertHtml(g)}else{const g=`<video src="${e}" controls style="max-width: 100%;"></video>`;(v=o.value)==null||v.dangerouslyInsertHtml(g)}h.value=null,f.value=""}})},{immediate:!1});function S(e){return class{constructor(){c(this,"title");c(this,"tag");c(this,"iconSvg");this.title="上传图片",this.tag="button",this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M959.877 128l0.123 0.123v767.775l-0.123 0.122H64.102l-0.122-0.122V128.123l0.122-0.123h895.775zM960 64H64C28.795 64 0 92.795 0 128v768c0 35.205 28.795 64 64 64h896c35.205 0 64-28.795 64-64V128c0-35.205-28.795-64-64-64zM832 288.01c0 53.023-42.988 96.01-96.01 96.01s-96.01-42.987-96.01-96.01S682.967 192 735.99 192 832 234.988 832 288.01zM896 832H128V704l224.01-384 256 320h64l224.01-192z"></path></svg>'}isActive(){return!1}getValue(){return""}isDisabled(){return!1}exec(){t.nextTick(()=>{console.log("点击了自定义上传图片菜单"),e("img")})}}}function w(e){return class{constructor(){c(this,"title");c(this,"tag");c(this,"iconSvg");this.title="上传视频",this.tag="button",this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>'}getValue(){return""}isActive(){return!1}isDisabled(){return!1}exec(){t.nextTick(()=>{console.log("点击了自定义上传视频菜单"),e("video")})}}}const D={toolbarKeys:["headerSelect","bold","italic","through","underline","color","fontSize","lineHeight","delIndent","indent","divider","insertTable","justifyCenter","justifyJustify","justifyLeft","justifyRight","bulletedList","numberedList","undo","redo","clearStyle","codeBlock"]},E=["#0032A0","#FF0044","#FF8200","#001E60","#E3E3E6","#000000","#262626","#595959","#8C8C8C","#BFBFBF","#D9D9D9","#E8E8E8","#F5F5F5","#FFFFFF","#F5222D","#FA541C","#FA8C16","#FADB14","#52C41A","#13C2C2","#1890FF","#2F54EB","#722ED1","#EB2F96","#FFE8E6","#FFECE0","#FFEFD1","#FCFCCA","#E4F7D2","#D3F5F0","#D4EEFC","#DEE8FC","#EFE1FA","#FAE1EB","#FFA39E","#FFBB96","#FFD591","#FFFB8F","#B7EB8F","#87E8DE","#91D5FF","#ADC6FF","#D3ADF7","#FFADD2","#FF4D4F","#FF7A45","#FFA940","#FFEC3D","#73D13D","#36CFC9","#40A9FF","#597EF7","#9254DE","#F759AB","#CF1322","#D4380D","#D46B08","#D4B106","#389E0D","#08979C","#096DD9","#1D39C4","#531DAB","#C41D7F","#820014","#871400","#873800","#614700","#135200","#00474F","#003A8C","#061178","#22075E","#780650"],k={placeholder:a.placeholder,readOnly:a.disabled,maxLength:a.maxLength,MENU_CONF:{color:{colors:E},bgColor:{colors:E}},hoverbarKeys:{text:{menuKeys:["headerSelect","insertLink","bold","italic","underline","through","clearStyle"]}}},b=Math.random().toString(36).substring(2,9),B=`CustomImageMenu_${b}`,x=`CustomVideoMenu_${b}`,I=e=>{o.value=e;try{const n=S(p),l=w(p),v={key:B,factory(){return new n}},s={key:x,factory(){return new l}};A.Boot.registerMenu(v),A.Boot.registerMenu(s)}catch(n){console.warn("菜单注册失败:",n)}D.insertKeys={index:0,keys:[B,x]},F("created",e)};t.onBeforeUnmount(()=>{const e=o.value;e!=null&&e.destroy()}),t.watch(()=>a.modelValue,e=>{e!==d.value&&(d.value=e||"")},{immediate:!0});const H=e=>{F("update:modelValue",d.value),F("change",e)},_=()=>{o.value=void 0},j=e=>{F("focus",e)},z=e=>{F("blur",e)};return r({editor:o,getHtml:()=>d.value,getText:()=>{var e;return((e=o.value)==null?void 0:e.getText())||""},isEmpty:()=>{var e;return((e=o.value)==null?void 0:e.isEmpty())||!0},clear:()=>{var e;return(e=o.value)==null?void 0:e.clear()},focus:()=>{var e;return(e=o.value)==null?void 0:e.focus()},blur:()=>{var e;return(e=o.value)==null?void 0:e.blur()},disable:()=>{var e;return(e=o.value)==null?void 0:e.disable()},enable:()=>{var e;return(e=o.value)==null?void 0:e.enable()}}),(e,n)=>(t.openBlock(),t.createElementBlock("div",T,[t.createVNode(t.unref(M.Toolbar),{class:"editor-toolbar",editor:o.value,defaultConfig:D,mode:u.mode},null,8,["editor","mode"]),t.createVNode(t.unref(M.Editor),{class:"editor-content",style:t.normalizeStyle({height:V.value}),modelValue:d.value,"onUpdate:modelValue":n[0]||(n[0]=l=>d.value=l),defaultConfig:k,mode:u.mode,onOnCreated:I,onOnChange:H,onOnDestroyed:_,onOnFocus:j,onOnBlur:z},null,8,["style","modelValue","mode"])]))}}),U=O.a(L,[["__scopeId","data-v-e97d4bf7"]]);exports.default=U;