officialblock 2.0.0 → 2.0.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.
@@ -1,10 +1,10 @@
1
1
  var D = Object.defineProperty;
2
2
  var L = (a, u, c) => u in a ? D(a, u, { enumerable: !0, configurable: !0, writable: !0, value: c }) : a[u] = c;
3
3
  var r = (a, u, c) => L(a, typeof u != "symbol" ? u + "" : u, c);
4
- import { defineComponent as A, shallowRef as R, ref as p, computed as F, inject as y, watch as C, nextTick as b, onBeforeUnmount as q, createElementBlock as J, openBlock as G, createVNode as I, unref as H, normalizeStyle as P } from "vue";
4
+ import { defineComponent as A, shallowRef as R, ref as b, computed as q, inject as x, watch as M, nextTick as V, onBeforeUnmount as F, createElementBlock as J, openBlock as G, createVNode as w, unref as H, normalizeStyle as P } from "vue";
5
5
  import { Toolbar as Q, Editor as W } from "@wangeditor/editor-for-vue";
6
6
  import { Boot as z } from "@wangeditor/editor";
7
- import { _ as X } from "./index-BgNLic9D.mjs";
7
+ import { _ as X } from "./index-VBxjGI6P.mjs";
8
8
  const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
9
9
  __name: "index",
10
10
  props: {
@@ -20,39 +20,39 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
20
20
  },
21
21
  emits: ["update:modelValue", "change", "focus", "blur", "created", "upload-image", "upload-video"],
22
22
  setup(a, { expose: u, emit: c }) {
23
- const n = a, d = c, t = R(), i = p(""), k = F(() => typeof n.height == "number" ? `${n.height}px` : n.height), x = y("handleUpload", () => {
24
- }), m = y("fileUrl", null), M = y("chooseName", null), f = p(""), h = p(null), V = (e) => {
25
- if (!x) {
23
+ const n = a, d = c, t = R(), i = b(""), k = q(() => typeof n.height == "number" ? `${n.height}px` : n.height), B = x("handleUpload", () => {
24
+ }), m = x("fileUrl", null), g = x("chooseName", null), f = b(""), h = b(null), S = (e) => {
25
+ if (!B) {
26
26
  console.warn("Upload: handleUpload function not provided by ancestor");
27
27
  return;
28
28
  }
29
29
  if (f.value = e, t.value)
30
30
  try {
31
- const o = t.value.selection;
32
- o && (h.value = {
31
+ const l = t.value.selection;
32
+ l && (h.value = {
33
33
  anchor: {
34
- path: [...o.anchor.path],
35
- offset: o.anchor.offset
34
+ path: [...l.anchor.path],
35
+ offset: l.anchor.offset
36
36
  },
37
37
  focus: {
38
- path: [...o.focus.path],
39
- offset: o.focus.offset
38
+ path: [...l.focus.path],
39
+ offset: l.focus.offset
40
40
  }
41
41
  });
42
- } catch (o) {
43
- console.warn("保存光标位置失败:", o);
42
+ } catch (l) {
43
+ console.warn("保存光标位置失败:", l);
44
44
  }
45
- const l = n.name + "_" + e;
46
- x(!0, l);
45
+ const o = n.name + "_" + e;
46
+ console.log("🚀 富文本编辑器传递name:", o, "props.name:", n.name), B(!0, o);
47
47
  };
48
- C(() => n.name, () => {
49
- m.value = null;
50
- }, { deep: !0, immediate: !0 }), C(
48
+ M(() => n.name, (e) => {
49
+ console.log("🚀 富文本编辑器name变化:", e), m.value = null;
50
+ }, { deep: !0, immediate: !0 }), M(
51
51
  () => [m == null ? void 0 : m.value],
52
52
  ([e]) => {
53
- const l = n.name + "_" + f.value;
54
- !e || !M.value || M.value !== l || t.value && b(() => {
55
- var o, v;
53
+ const o = n.name + "_" + f.value;
54
+ console.log("🚀 富文本编辑器获取信息:", g.value, e, o), !(!e || !g.value || g.value !== o) && (console.log("🚀 富文本编辑器ref:", t.value), t.value && V(() => {
55
+ var l, v;
56
56
  if (t.value) {
57
57
  try {
58
58
  if (t.value.focus(), h.value)
@@ -65,15 +65,15 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
65
65
  console.warn("聚焦编辑器失败:", s);
66
66
  }
67
67
  if (f.value === "img") {
68
- const g = `<img src="${e}" alt="图片" style="max-width: 100%;">`;
69
- (o = t.value) == null || o.dangerouslyInsertHtml(g);
68
+ const C = `<img src="${e}" alt="图片" style="max-width: 100%;">`;
69
+ (l = t.value) == null || l.dangerouslyInsertHtml(C);
70
70
  } else {
71
- const g = `<video src="${e}" controls style="max-width: 100%;"></video>`;
72
- (v = t.value) == null || v.dangerouslyInsertHtml(g);
71
+ const C = `<video src="${e}" controls style="max-width: 100%;"></video>`;
72
+ (v = t.value) == null || v.dangerouslyInsertHtml(C);
73
73
  }
74
74
  h.value = null, f.value = "";
75
75
  }
76
- });
76
+ }));
77
77
  },
78
78
  { immediate: !1 }
79
79
  );
@@ -95,7 +95,7 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
95
95
  return !1;
96
96
  }
97
97
  exec() {
98
- b(() => {
98
+ V(() => {
99
99
  console.log("点击了自定义上传图片菜单"), e("img");
100
100
  });
101
101
  }
@@ -119,13 +119,13 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
119
119
  return !1;
120
120
  }
121
121
  exec() {
122
- b(() => {
122
+ V(() => {
123
123
  console.log("点击了自定义上传视频菜单"), e("video");
124
124
  });
125
125
  }
126
126
  };
127
127
  }
128
- const B = {
128
+ const _ = {
129
129
  toolbarKeys: [
130
130
  // 菜单 key
131
131
  "headerSelect",
@@ -168,40 +168,40 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
168
168
  "codeBlock"
169
169
  //代码块
170
170
  ]
171
- }, U = {
171
+ }, K = {
172
172
  placeholder: n.placeholder,
173
173
  readOnly: n.disabled,
174
174
  maxLength: n.maxLength,
175
175
  MENU_CONF: {}
176
- }, S = Math.random().toString(36).substring(2, 9), _ = `CustomImageMenu_${S}`, w = `CustomVideoMenu_${S}`, K = (e) => {
176
+ }, I = Math.random().toString(36).substring(2, 9), p = `CustomImageMenu_${I}`, y = `CustomVideoMenu_${I}`, U = (e) => {
177
177
  t.value = e;
178
178
  try {
179
- const l = N(V), o = O(V), v = {
180
- key: _,
179
+ const o = N(S), l = O(S), v = {
180
+ key: p,
181
181
  // 使用唯一的 key
182
182
  factory() {
183
- return new l();
183
+ return new o();
184
184
  }
185
185
  }, s = {
186
- key: w,
186
+ key: y,
187
187
  // 使用唯一的 key
188
188
  factory() {
189
- return new o();
189
+ return new l();
190
190
  }
191
191
  };
192
- z.registerMenu(v), z.registerMenu(s);
193
- } catch (l) {
194
- console.warn("菜单注册失败:", l);
192
+ z.registerMenu(v), z.registerMenu(s), console.log("自定义菜单注册成功:", p, y);
193
+ } catch (o) {
194
+ console.warn("菜单注册失败:", o);
195
195
  }
196
- B.insertKeys = {
196
+ _.insertKeys = {
197
197
  index: 0,
198
- keys: [_, w]
198
+ keys: [p, y]
199
199
  }, d("created", e);
200
200
  };
201
- q(() => {
201
+ F(() => {
202
202
  const e = t.value;
203
203
  e != null && e.destroy();
204
- }), C(
204
+ }), M(
205
205
  () => n.modelValue,
206
206
  (e) => {
207
207
  e !== i.value && (i.value = e || "");
@@ -248,21 +248,21 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
248
248
  var e;
249
249
  return (e = t.value) == null ? void 0 : e.enable();
250
250
  }
251
- }), (e, l) => (G(), J("div", Y, [
252
- I(H(Q), {
251
+ }), (e, o) => (G(), J("div", Y, [
252
+ w(H(Q), {
253
253
  class: "editor-toolbar",
254
254
  editor: t.value,
255
- defaultConfig: B,
255
+ defaultConfig: _,
256
256
  mode: a.mode
257
257
  }, null, 8, ["editor", "mode"]),
258
- I(H(W), {
258
+ w(H(W), {
259
259
  class: "editor-content",
260
260
  style: P({ height: k.value }),
261
261
  modelValue: i.value,
262
- "onUpdate:modelValue": l[0] || (l[0] = (o) => i.value = o),
263
- defaultConfig: U,
262
+ "onUpdate:modelValue": o[0] || (o[0] = (l) => i.value = l),
263
+ defaultConfig: K,
264
264
  mode: a.mode,
265
- onOnCreated: K,
265
+ onOnCreated: U,
266
266
  onOnChange: j,
267
267
  onOnDestroyed: E,
268
268
  onOnFocus: T,
@@ -270,7 +270,7 @@ const Y = { class: "rich-text-editor" }, Z = /* @__PURE__ */ A({
270
270
  }, null, 8, ["style", "modelValue", "mode"])
271
271
  ]));
272
272
  }
273
- }), se = /* @__PURE__ */ X(Z, [["__scopeId", "data-v-a63bc21f"]]);
273
+ }), se = /* @__PURE__ */ X(Z, [["__scopeId", "data-v-b85f2258"]]);
274
274
  export {
275
275
  se as default
276
276
  };
@@ -0,0 +1 @@
1
+ "use strict";var K=Object.defineProperty;var U=(u,s,i)=>s in u?K(u,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[s]=i;var c=(u,s,i)=>U(u,typeof s!="symbol"?s+"":s,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),B=require("@wangeditor/editor-for-vue"),w=require("@wangeditor/editor"),q=require("./index-LnEd-7FK.js"),E={class:"rich-text-editor"},$=t.defineComponent({__name:"index",props:{name:{default:""},modelValue:{default:""},placeholder:{default:"请输入内容..."},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:s,emit:i}){const a=u,m=i,o=t.shallowRef(),d=t.ref(""),I=t.computed(()=>typeof a.height=="number"?`${a.height}px`:a.height),x=t.inject("handleUpload",()=>{}),f=t.inject("fileUrl",null),p=t.inject("chooseName",null),h=t.ref(""),v=t.ref(null),M=e=>{if(!x){console.warn("Upload: handleUpload function not provided by ancestor");return}if(h.value=e,o.value)try{const n=o.value.selection;n&&(v.value={anchor:{path:[...n.anchor.path],offset:n.anchor.offset},focus:{path:[...n.focus.path],offset:n.focus.offset}})}catch(n){console.warn("保存光标位置失败:",n)}const l=a.name+"_"+e;console.log("🚀 富文本编辑器传递name:",l,"props.name:",a.name),x(!0,l)};t.watch(()=>a.name,e=>{console.log("🚀 富文本编辑器name变化:",e),f.value=null},{deep:!0,immediate:!0}),t.watch(()=>[f==null?void 0:f.value],([e])=>{const l=a.name+"_"+h.value;console.log("🚀 富文本编辑器获取信息:",p.value,e,l),!(!e||!p.value||p.value!==l)&&(console.log("🚀 富文本编辑器ref:",o.value),o.value&&t.nextTick(()=>{var n,g;if(o.value){try{if(o.value.focus(),v.value)try{o.value.select(v.value)}catch(r){console.warn("恢复光标位置失败,使用默认位置:",r)}}catch(r){console.warn("聚焦编辑器失败:",r)}if(h.value==="img"){const b=`<img src="${e}" alt="图片" style="max-width: 100%;">`;(n=o.value)==null||n.dangerouslyInsertHtml(b)}else{const b=`<video src="${e}" controls style="max-width: 100%;"></video>`;(g=o.value)==null||g.dangerouslyInsertHtml(b)}v.value=null,h.value=""}}))},{immediate:!1});function _(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 k(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 V={toolbarKeys:["headerSelect","bold","italic","through","underline","color","fontSize","lineHeight","delIndent","indent","divider","insertTable","justifyCenter","justifyJustify","justifyLeft","justifyRight","undo","redo","clearStyle","codeBlock"]},H={placeholder:a.placeholder,readOnly:a.disabled,maxLength:a.maxLength,MENU_CONF:{}},S=Math.random().toString(36).substring(2,9),y=`CustomImageMenu_${S}`,C=`CustomVideoMenu_${S}`,j=e=>{o.value=e;try{const l=_(M),n=k(M),g={key:y,factory(){return new l}},r={key:C,factory(){return new n}};w.Boot.registerMenu(g),w.Boot.registerMenu(r),console.log("自定义菜单注册成功:",y,C)}catch(l){console.warn("菜单注册失败:",l)}V.insertKeys={index:0,keys:[y,C]},m("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 z=e=>{m("update:modelValue",d.value),m("change",e)},N=()=>{o.value=void 0},O=e=>{m("focus",e)},T=e=>{m("blur",e)};return s({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,l)=>(t.openBlock(),t.createElementBlock("div",E,[t.createVNode(t.unref(B.Toolbar),{class:"editor-toolbar",editor:o.value,defaultConfig:V,mode:u.mode},null,8,["editor","mode"]),t.createVNode(t.unref(B.Editor),{class:"editor-content",style:t.normalizeStyle({height:I.value}),modelValue:d.value,"onUpdate:modelValue":l[0]||(l[0]=n=>d.value=n),defaultConfig:H,mode:u.mode,onOnCreated:j,onOnChange:z,onOnDestroyed:N,onOnFocus:O,onOnBlur:T},null,8,["style","modelValue","mode"])]))}}),D=q._($,[["__scopeId","data-v-b85f2258"]]);exports.default=D;