officialblock 1.8.3 → 1.8.5

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,11 +1,11 @@
1
- var T = Object.defineProperty;
2
- var F = (l, a, u) => a in l ? T(l, a, { enumerable: !0, configurable: !0, writable: !0, value: u }) : l[a] = u;
3
- var i = (l, a, u) => F(l, typeof a != "symbol" ? a + "" : a, u);
4
- import { defineComponent as N, shallowRef as R, ref as x, computed as D, inject as g, watch as C, onBeforeUnmount as K, resolveComponent as L, createBlock as A, openBlock as $, withCtx as J, createElementVNode as q, createVNode as M, unref as V, normalizeStyle as G, nextTick as _ } from "vue";
5
- import { Toolbar as P, Editor as Q } from "@wangeditor/editor-for-vue";
6
- import { Boot as w } from "@wangeditor/editor";
7
- import { _ as W } from "./index-BanCcN3S.mjs";
8
- const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
1
+ var D = Object.defineProperty;
2
+ var F = (l, a, i) => a in l ? D(l, a, { enumerable: !0, configurable: !0, writable: !0, value: i }) : l[a] = i;
3
+ var s = (l, a, i) => F(l, typeof a != "symbol" ? a + "" : a, i);
4
+ import { defineComponent as K, shallowRef as A, ref as f, computed as $, inject as g, watch as w, onBeforeUnmount as N, createElementBlock as P, openBlock as J, createVNode as M, unref as V, normalizeStyle as q, nextTick as _ } from "vue";
5
+ import "@wangeditor/editor-for-vue";
6
+ import { Boot as B } from "@wangeditor/editor";
7
+ import { _ as G } from "./index-B52dNYDa.mjs";
8
+ const Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), W = { class: "rich-text-editor" }, X = /* @__PURE__ */ K({
9
9
  __name: "RichTextEditor",
10
10
  props: {
11
11
  name: { default: "" },
@@ -19,28 +19,28 @@ const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
19
19
  includeKeys: { default: () => [] }
20
20
  },
21
21
  emits: ["update:modelValue", "change", "focus", "blur", "created", "upload-image", "upload-video"],
22
- setup(l, { expose: a, emit: u }) {
23
- const n = l, d = u, o = R(), r = x(""), B = D(() => typeof n.height == "number" ? `${n.height}px` : n.height), v = g("handleUpload", () => {
24
- }), h = g("fileUrl", null), f = g("chooseName", null), c = x(""), y = () => {
22
+ setup(l, { expose: a, emit: i }) {
23
+ const n = l, d = i, o = A(), u = f(""), S = f(!1), j = $(() => typeof n.height == "number" ? `${n.height}px` : n.height), v = g("handleUpload", () => {
24
+ }), m = g("fileUrl", null), h = g("chooseName", null), c = f(""), y = () => {
25
25
  if (!v) {
26
26
  console.warn("Upload: handleUpload function not provided by ancestor");
27
27
  return;
28
28
  }
29
29
  v(!0, n.name + c.value);
30
30
  };
31
- C(
32
- () => [h == null ? void 0 : h.value, f == null ? void 0 : f.value],
31
+ w(
32
+ () => [m == null ? void 0 : m.value, h == null ? void 0 : h.value],
33
33
  ([e, t]) => {
34
- var s, m;
35
- !e || !t || t !== n.name + c.value || (c.value === "img" ? (s = o.value) == null || s.dangerouslyInsertHtml('<img src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" alt="图片" style="max-width: 100%;">') : (m = o.value) == null || m.dangerouslyInsertHtml('<video src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" controls style="max-width: 100%;"></video>'));
34
+ var r, C;
35
+ !e || !t || t !== n.name + c.value || (c.value === "img" ? (r = o.value) == null || r.dangerouslyInsertHtml('<img src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" alt="图片" style="max-width: 100%;">') : (C = o.value) == null || C.dangerouslyInsertHtml('<video src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" controls style="max-width: 100%;"></video>'));
36
36
  },
37
37
  { immediate: !1 }
38
38
  );
39
- class S {
39
+ class z {
40
40
  constructor() {
41
- i(this, "title");
42
- i(this, "tag");
43
- i(this, "iconSvg");
41
+ s(this, "title");
42
+ s(this, "tag");
43
+ s(this, "iconSvg");
44
44
  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>';
45
45
  }
46
46
  isActive(t) {
@@ -52,17 +52,17 @@ const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
52
52
  isDisabled(t) {
53
53
  return !1;
54
54
  }
55
- exec(t, s) {
55
+ exec(t, r) {
56
56
  _(() => {
57
57
  console.log("点击了自定义上传图片菜单"), c.value = "img", y();
58
58
  });
59
59
  }
60
60
  }
61
- class j {
61
+ class E {
62
62
  constructor() {
63
- i(this, "title");
64
- i(this, "tag");
65
- i(this, "iconSvg");
63
+ s(this, "title");
64
+ s(this, "tag");
65
+ s(this, "iconSvg");
66
66
  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>';
67
67
  }
68
68
  getValue(t) {
@@ -74,7 +74,7 @@ const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
74
74
  isDisabled(t) {
75
75
  return !1;
76
76
  }
77
- exec(t, s) {
77
+ exec(t, r) {
78
78
  _(() => {
79
79
  c.value = "video", y();
80
80
  });
@@ -123,55 +123,62 @@ const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
123
123
  "codeBlock"
124
124
  //代码块
125
125
  ]
126
- }, b = {
126
+ }, H = {
127
127
  placeholder: n.placeholder,
128
128
  readOnly: n.disabled,
129
129
  maxLength: n.maxLength,
130
130
  MENU_CONF: {}
131
- };
132
- b.MENU_CONF = {};
133
- const H = (e) => {
131
+ }, O = (e) => {
134
132
  o.value = e;
135
133
  const t = {
136
134
  key: "CustomImageMenu",
137
135
  // 定义 menu key :要保证唯一、不重复(重要)
138
136
  factory() {
139
- return new S();
137
+ return new z();
140
138
  }
141
- }, s = {
139
+ }, r = {
142
140
  key: "CustomVideoMenu",
143
141
  // 定义 menu key :要保证唯一、不重复(重要)
144
142
  factory() {
145
- return new j();
143
+ return new E();
146
144
  }
147
145
  };
148
- w.registerMenu(t), w.registerMenu(s), p.insertKeys = {
146
+ B.registerMenu(t), B.registerMenu(r), p.insertKeys = {
149
147
  index: 0,
150
148
  keys: ["CustomImageMenu", "CustomVideoMenu"]
151
149
  }, d("created", e);
152
150
  };
153
- K(() => {
151
+ N(() => {
154
152
  const e = o.value;
155
153
  e != null && e.destroy();
156
- }), C(
154
+ }), w(
157
155
  () => n.modelValue,
158
156
  (e) => {
159
- e !== r.value && (r.value = e || "");
157
+ e !== u.value && (u.value = e || "");
160
158
  },
161
159
  { immediate: !0 }
162
160
  );
163
- const U = (e) => {
164
- d("update:modelValue", r.value), d("change", e);
165
- }, z = () => {
161
+ const T = (e) => {
162
+ d("update:modelValue", u.value), d("change", e);
163
+ }, I = () => {
166
164
  o.value = void 0;
167
- }, E = (e) => {
165
+ }, U = (e) => {
168
166
  d("focus", e);
169
- }, I = (e) => {
167
+ }, k = (e) => {
170
168
  d("blur", e);
171
169
  };
172
- return a({
170
+ let b = null, x = null;
171
+ return onMounted(async () => {
172
+ if (typeof window < "u")
173
+ try {
174
+ const e = await import("@wangeditor/editor-for-vue");
175
+ b = e.Editor, x = e.Toolbar, await Promise.resolve().then(() => Q), S.value = !0;
176
+ } catch (e) {
177
+ console.error("编辑器加载失败:", e);
178
+ }
179
+ }), a({
173
180
  editor: o,
174
- getHtml: () => r.value,
181
+ getHtml: () => u.value,
175
182
  getText: () => {
176
183
  var e;
177
184
  return ((e = o.value) == null ? void 0 : e.getText()) || "";
@@ -200,38 +207,30 @@ const X = { class: "rich-text-editor" }, Y = /* @__PURE__ */ N({
200
207
  var e;
201
208
  return (e = o.value) == null ? void 0 : e.enable();
202
209
  }
203
- }), (e, t) => {
204
- const s = L("client-only");
205
- return $(), A(s, null, {
206
- default: J(() => [
207
- q("div", X, [
208
- M(V(P), {
209
- class: "editor-toolbar",
210
- editor: o.value,
211
- defaultConfig: p,
212
- mode: l.mode
213
- }, null, 8, ["editor", "mode"]),
214
- M(V(Q), {
215
- class: "editor-content",
216
- style: G({ height: B.value }),
217
- modelValue: r.value,
218
- "onUpdate:modelValue": t[0] || (t[0] = (m) => r.value = m),
219
- defaultConfig: b,
220
- mode: l.mode,
221
- onOnCreated: H,
222
- onOnChange: U,
223
- onOnDestroyed: z,
224
- onOnFocus: E,
225
- onOnBlur: I
226
- }, null, 8, ["style", "modelValue", "mode"])
227
- ])
228
- ]),
229
- _: 1
230
- });
231
- };
210
+ }), (e, t) => (J(), P("div", W, [
211
+ M(V(x), {
212
+ class: "editor-toolbar",
213
+ editor: o.value,
214
+ defaultConfig: p,
215
+ mode: l.mode
216
+ }, null, 8, ["editor", "mode"]),
217
+ M(V(b), {
218
+ class: "editor-content",
219
+ style: q({ height: j.value }),
220
+ modelValue: u.value,
221
+ "onUpdate:modelValue": t[0] || (t[0] = (r) => u.value = r),
222
+ defaultConfig: H,
223
+ mode: l.mode,
224
+ onOnCreated: O,
225
+ onOnChange: T,
226
+ onOnDestroyed: I,
227
+ onOnFocus: U,
228
+ onOnBlur: k
229
+ }, null, 8, ["style", "modelValue", "mode"])
230
+ ]));
232
231
  }
233
- }), ae = /* @__PURE__ */ W(Y, [["__scopeId", "data-v-5810ba54"]]);
232
+ }), le = /* @__PURE__ */ G(X, [["__scopeId", "data-v-44814993"]]);
234
233
  export {
235
- ae as RichTextEditor,
236
- ae as default
234
+ le as RichTextEditor,
235
+ le as default
237
236
  };
@@ -0,0 +1 @@
1
+ "use strict";var U=Object.create;var g=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var F=(o,l,r)=>l in o?g(o,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[l]=r;var K=(o,l,r,i)=>{if(l&&typeof l=="object"||typeof l=="function")for(let u of L(l))!D.call(o,u)&&u!==r&&g(o,u,{get:()=>l[u],enumerable:!(i=R(l,u))||i.enumerable});return o};var A=(o,l,r)=>(r=o!=null?U(q(o)):{},K(l||!o||!o.__esModule?g(r,"default",{value:o,enumerable:!0}):r,o));var d=(o,l,r)=>F(o,typeof l!="symbol"?l+"":l,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue");require("@wangeditor/editor-for-vue");const w=require("@wangeditor/editor"),N=require("./index-g9CqbItW.js"),P=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),$={class:"rich-text-editor"},J=t.defineComponent({__name:"RichTextEditor",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(o,{expose:l,emit:r}){const i=o,u=r,a=t.shallowRef(),c=t.ref(""),V=t.ref(!1),j=t.computed(()=>typeof i.height=="number"?`${i.height}px`:i.height),v=t.inject("handleUpload",()=>{}),h=t.inject("fileUrl",null),f=t.inject("chooseName",null),m=t.ref(""),y=()=>{if(!v){console.warn("Upload: handleUpload function not provided by ancestor");return}v(!0,i.name+m.value)};t.watch(()=>[h==null?void 0:h.value,f==null?void 0:f.value],([e,n])=>{var s,C;!e||!n||n!==i.name+m.value||(m.value==="img"?(s=a.value)==null||s.dangerouslyInsertHtml('<img src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" alt="图片" style="max-width: 100%;">'):(C=a.value)==null||C.dangerouslyInsertHtml('<video src="https://osswebsite.ycyw.com/media-library/ywies-bj/images/home/ywies-tx.jpg" controls style="max-width: 100%;"></video>'))},{immediate:!1});class S{constructor(){d(this,"title");d(this,"tag");d(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(n){return!1}getValue(n){return""}isDisabled(n){return!1}exec(n,s){t.nextTick(()=>{console.log("点击了自定义上传图片菜单"),m.value="img",y()})}}class _{constructor(){d(this,"title");d(this,"tag");d(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(n){return""}isActive(n){return!1}isDisabled(n){return!1}exec(n,s){t.nextTick(()=>{m.value="video",y()})}}const p={toolbarKeys:["headerSelect","bold","italic","through","underline","color","fontSize","lineHeight","delIndent","indent","divider","insertTable","justifyCenter","justifyJustify","justifyLeft","justifyRight","undo","redo","clearStyle","codeBlock"]},B={placeholder:i.placeholder,readOnly:i.disabled,maxLength:i.maxLength,MENU_CONF:{}},T=e=>{a.value=e;const n={key:"CustomImageMenu",factory(){return new S}},s={key:"CustomVideoMenu",factory(){return new _}};w.Boot.registerMenu(n),w.Boot.registerMenu(s),p.insertKeys={index:0,keys:["CustomImageMenu","CustomVideoMenu"]},u("created",e)};t.onBeforeUnmount(()=>{const e=a.value;e!=null&&e.destroy()}),t.watch(()=>i.modelValue,e=>{e!==c.value&&(c.value=e||"")},{immediate:!0});const E=e=>{u("update:modelValue",c.value),u("change",e)},O=()=>{a.value=void 0},z=e=>{u("focus",e)},H=e=>{u("blur",e)};let b=null,x=null;return onMounted(async()=>{if(typeof window<"u")try{const e=await import("@wangeditor/editor-for-vue");b=e.Editor,x=e.Toolbar,await Promise.resolve().then(()=>P),V.value=!0}catch(e){console.error("编辑器加载失败:",e)}}),l({editor:a,getHtml:()=>c.value,getText:()=>{var e;return((e=a.value)==null?void 0:e.getText())||""},isEmpty:()=>{var e;return((e=a.value)==null?void 0:e.isEmpty())||!0},clear:()=>{var e;return(e=a.value)==null?void 0:e.clear()},focus:()=>{var e;return(e=a.value)==null?void 0:e.focus()},blur:()=>{var e;return(e=a.value)==null?void 0:e.blur()},disable:()=>{var e;return(e=a.value)==null?void 0:e.disable()},enable:()=>{var e;return(e=a.value)==null?void 0:e.enable()}}),(e,n)=>(t.openBlock(),t.createElementBlock("div",$,[t.createVNode(t.unref(x),{class:"editor-toolbar",editor:a.value,defaultConfig:p,mode:o.mode},null,8,["editor","mode"]),t.createVNode(t.unref(b),{class:"editor-content",style:t.normalizeStyle({height:j.value}),modelValue:c.value,"onUpdate:modelValue":n[0]||(n[0]=s=>c.value=s),defaultConfig:B,mode:o.mode,onOnCreated:T,onOnChange:E,onOnDestroyed:O,onOnFocus:z,onOnBlur:H},null,8,["style","modelValue","mode"])]))}}),M=N._(J,[["__scopeId","data-v-44814993"]]);exports.RichTextEditor=M;exports.default=M;