officialblock 1.9.7 → 1.9.9
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-CRuBLZEJ.js → index-BQ5Isp7X.js} +1 -1
- package/dist/{index-B9zNnIJq.mjs → index-CKRMJwKd.mjs} +63 -56
- package/dist/{index-Bt2vc6cP.mjs → index-D2ooxtkM.mjs} +9171 -9462
- package/dist/index-DCjIaNzx.js +16 -0
- package/dist/official-block.cjs.js +1 -1
- package/dist/official-block.es.js +1 -1
- package/dist/official-block.umd.js +4 -4
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/index-CM74vUQ8.js +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _=Object.defineProperty;var U=(l,n,s)=>n in l?_(l,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[n]=s;var r=(l,n,s)=>U(l,typeof n!="symbol"?n+"":n,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("vue"),M=require("@wangeditor/editor-for-vue"),B=require("@wangeditor/editor"),E=require("./index-DCjIaNzx.js"),q={class:"rich-text-editor"},D=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(l,{expose:n,emit:s}){const a=l,d=s,o=t.shallowRef(),i=t.ref(""),S=t.computed(()=>typeof a.height=="number"?`${a.height}px`:a.height),p=t.inject("handleUpload",()=>{}),m=t.inject("fileUrl",null),g=t.inject("chooseName",null),f=t.ref(""),v=t.ref(null),b=()=>{if(!p){console.warn("Upload: handleUpload function not provided by ancestor");return}if(o.value)try{const e=o.value.selection;e&&(v.value={anchor:{path:[...e.anchor.path],offset:e.anchor.offset},focus:{path:[...e.focus.path],offset:e.focus.offset}})}catch(e){console.warn("保存光标位置失败:",e)}p(!0,a.name+"_"+f.value)};t.watch(()=>[m==null?void 0:m.value,g==null?void 0:g.value],([e,u])=>{!e||!u||u!==a.name+"_"+f.value||o.value&&t.nextTick(()=>{var c,V;if(o.value){try{if(o.value.focus(),v.value)try{o.value.select(v.value)}catch(h){console.warn("恢复光标位置失败,使用默认位置:",h)}}catch(h){console.warn("聚焦编辑器失败:",h)}if(f.value==="img"){const y=`<img src="${e}" alt="图片" style="max-width: 100%;">`;(c=o.value)==null||c.dangerouslyInsertHtml(y)}else{const y=`<video src="${e}" controls style="max-width: 100%;"></video>`;(V=o.value)==null||V.dangerouslyInsertHtml(y)}v.value=null}})},{immediate:!1});class w{constructor(){r(this,"title");r(this,"tag");r(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("点击了自定义上传图片菜单"),f.value="img",b()})}}class k{constructor(){r(this,"title");r(this,"tag");r(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(()=>{f.value="video",b()})}}const x={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:{}};let C=!1;const j=e=>{if(o.value=e,!C)try{const u={key:"CustomImageMenu",factory(){return new w}},c={key:"CustomVideoMenu",factory(){return new k}};B.Boot.registerMenu(u),B.Boot.registerMenu(c),C=!0,console.log("自定义菜单注册成功")}catch(u){console.warn("菜单注册失败(可能已注册):",u)}x.insertKeys={index:0,keys:["CustomImageMenu","CustomVideoMenu"]},d("created",e)};t.onBeforeUnmount(()=>{const e=o.value;e!=null&&e.destroy()}),t.watch(()=>a.modelValue,e=>{e!==i.value&&(i.value=e||"")},{immediate:!0});const z=e=>{d("update:modelValue",i.value),d("change",e)},I=()=>{o.value=void 0},O=e=>{d("focus",e)},T=e=>{d("blur",e)};return n({editor:o,getHtml:()=>i.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,u)=>(t.openBlock(),t.createElementBlock("div",q,[t.createVNode(t.unref(M.Toolbar),{class:"editor-toolbar",editor:o.value,defaultConfig:x,mode:l.mode},null,8,["editor","mode"]),t.createVNode(t.unref(M.Editor),{class:"editor-content",style:t.normalizeStyle({height:S.value}),modelValue:i.value,"onUpdate:modelValue":u[0]||(u[0]=c=>i.value=c),defaultConfig:H,mode:l.mode,onOnCreated:j,onOnChange:z,onOnDestroyed:I,onOnFocus:O,onOnBlur:T},null,8,["style","modelValue","mode"])]))}}),K=E._(D,[["__scopeId","data-v-71899034"]]);exports.default=K;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var u = (o, l, s) =>
|
|
4
|
-
import { defineComponent as
|
|
5
|
-
import { Toolbar as
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var L = (o, l, s) => l in o ? K(o, l, { enumerable: !0, configurable: !0, writable: !0, value: s }) : o[l] = s;
|
|
3
|
+
var u = (o, l, s) => L(o, typeof l != "symbol" ? l + "" : l, s);
|
|
4
|
+
import { defineComponent as R, shallowRef as A, ref as p, computed as $, inject as y, watch as S, nextTick as x, onBeforeUnmount as F, createElementBlock as N, openBlock as J, createVNode as _, unref as w, normalizeStyle as q } from "vue";
|
|
5
|
+
import { Toolbar as G, Editor as P } from "@wangeditor/editor-for-vue";
|
|
6
6
|
import { Boot as H } from "@wangeditor/editor";
|
|
7
|
-
import { _ as
|
|
8
|
-
const
|
|
7
|
+
import { _ as Q } from "./index-D2ooxtkM.mjs";
|
|
8
|
+
const W = { class: "rich-text-editor" }, X = /* @__PURE__ */ R({
|
|
9
9
|
__name: "index",
|
|
10
10
|
props: {
|
|
11
11
|
name: { default: "" },
|
|
@@ -20,8 +20,8 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
20
20
|
},
|
|
21
21
|
emits: ["update:modelValue", "change", "focus", "blur", "created", "upload-image", "upload-video"],
|
|
22
22
|
setup(o, { expose: l, emit: s }) {
|
|
23
|
-
const a = o,
|
|
24
|
-
}), h = y("fileUrl", null), v = y("chooseName", null),
|
|
23
|
+
const a = o, c = s, t = A(), r = p(""), z = $(() => typeof a.height == "number" ? `${a.height}px` : a.height), C = y("handleUpload", () => {
|
|
24
|
+
}), h = y("fileUrl", null), v = y("chooseName", null), d = p(""), m = p(null), b = () => {
|
|
25
25
|
if (!C) {
|
|
26
26
|
console.warn("Upload: handleUpload function not provided by ancestor");
|
|
27
27
|
return;
|
|
@@ -42,13 +42,13 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
42
42
|
} catch (e) {
|
|
43
43
|
console.warn("保存光标位置失败:", e);
|
|
44
44
|
}
|
|
45
|
-
C(!0, a.name + "_" +
|
|
45
|
+
C(!0, a.name + "_" + d.value);
|
|
46
46
|
};
|
|
47
|
-
|
|
47
|
+
S(
|
|
48
48
|
() => [h == null ? void 0 : h.value, v == null ? void 0 : v.value],
|
|
49
49
|
([e, n]) => {
|
|
50
|
-
!e || !n || n !== a.name + "_" +
|
|
51
|
-
var i,
|
|
50
|
+
!e || !n || n !== a.name + "_" + d.value || t.value && x(() => {
|
|
51
|
+
var i, B;
|
|
52
52
|
if (t.value) {
|
|
53
53
|
try {
|
|
54
54
|
if (t.value.focus(), m.value)
|
|
@@ -60,12 +60,12 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
60
60
|
} catch (f) {
|
|
61
61
|
console.warn("聚焦编辑器失败:", f);
|
|
62
62
|
}
|
|
63
|
-
if (
|
|
63
|
+
if (d.value === "img") {
|
|
64
64
|
const g = `<img src="${e}" alt="图片" style="max-width: 100%;">`;
|
|
65
65
|
(i = t.value) == null || i.dangerouslyInsertHtml(g);
|
|
66
66
|
} else {
|
|
67
67
|
const g = `<video src="${e}" controls style="max-width: 100%;"></video>`;
|
|
68
|
-
(
|
|
68
|
+
(B = t.value) == null || B.dangerouslyInsertHtml(g);
|
|
69
69
|
}
|
|
70
70
|
m.value = null;
|
|
71
71
|
}
|
|
@@ -73,7 +73,7 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
73
73
|
},
|
|
74
74
|
{ immediate: !1 }
|
|
75
75
|
);
|
|
76
|
-
class
|
|
76
|
+
class I {
|
|
77
77
|
constructor() {
|
|
78
78
|
u(this, "title");
|
|
79
79
|
u(this, "tag");
|
|
@@ -91,11 +91,11 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
91
91
|
}
|
|
92
92
|
exec() {
|
|
93
93
|
x(() => {
|
|
94
|
-
console.log("点击了自定义上传图片菜单"),
|
|
94
|
+
console.log("点击了自定义上传图片菜单"), d.value = "img", b();
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
class
|
|
98
|
+
class k {
|
|
99
99
|
constructor() {
|
|
100
100
|
u(this, "title");
|
|
101
101
|
u(this, "tag");
|
|
@@ -113,7 +113,7 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
113
113
|
}
|
|
114
114
|
exec() {
|
|
115
115
|
x(() => {
|
|
116
|
-
|
|
116
|
+
d.value = "video", b();
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -160,49 +160,56 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
160
160
|
"codeBlock"
|
|
161
161
|
//代码块
|
|
162
162
|
]
|
|
163
|
-
},
|
|
163
|
+
}, O = {
|
|
164
164
|
placeholder: a.placeholder,
|
|
165
165
|
readOnly: a.disabled,
|
|
166
166
|
maxLength: a.maxLength,
|
|
167
167
|
MENU_CONF: {}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
168
|
+
};
|
|
169
|
+
let V = !1;
|
|
170
|
+
const U = (e) => {
|
|
171
|
+
if (t.value = e, !V)
|
|
172
|
+
try {
|
|
173
|
+
const n = {
|
|
174
|
+
key: "CustomImageMenu",
|
|
175
|
+
// 定义 menu key :要保证唯一、不重复(重要)
|
|
176
|
+
factory() {
|
|
177
|
+
return new I();
|
|
178
|
+
}
|
|
179
|
+
}, i = {
|
|
180
|
+
key: "CustomVideoMenu",
|
|
181
|
+
// 定义 menu key :要保证唯一、不重复(重要)
|
|
182
|
+
factory() {
|
|
183
|
+
return new k();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
H.registerMenu(n), H.registerMenu(i), V = !0, console.log("自定义菜单注册成功");
|
|
187
|
+
} catch (n) {
|
|
188
|
+
console.warn("菜单注册失败(可能已注册):", n);
|
|
181
189
|
}
|
|
182
|
-
|
|
183
|
-
H.registerMenu(n), H.registerMenu(i), M.insertKeys = {
|
|
190
|
+
M.insertKeys = {
|
|
184
191
|
index: 0,
|
|
185
192
|
keys: ["CustomImageMenu", "CustomVideoMenu"]
|
|
186
|
-
},
|
|
193
|
+
}, c("created", e);
|
|
187
194
|
};
|
|
188
|
-
|
|
195
|
+
F(() => {
|
|
189
196
|
const e = t.value;
|
|
190
197
|
e != null && e.destroy();
|
|
191
|
-
}),
|
|
198
|
+
}), S(
|
|
192
199
|
() => a.modelValue,
|
|
193
200
|
(e) => {
|
|
194
201
|
e !== r.value && (r.value = e || "");
|
|
195
202
|
},
|
|
196
203
|
{ immediate: !0 }
|
|
197
204
|
);
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
},
|
|
205
|
+
const j = (e) => {
|
|
206
|
+
c("update:modelValue", r.value), c("change", e);
|
|
207
|
+
}, E = () => {
|
|
201
208
|
t.value = void 0;
|
|
202
|
-
}, E = (e) => {
|
|
203
|
-
d("focus", e);
|
|
204
209
|
}, T = (e) => {
|
|
205
|
-
|
|
210
|
+
c("focus", e);
|
|
211
|
+
}, D = (e) => {
|
|
212
|
+
c("blur", e);
|
|
206
213
|
};
|
|
207
214
|
return l({
|
|
208
215
|
editor: t,
|
|
@@ -235,29 +242,29 @@ const Q = { class: "rich-text-editor" }, W = /* @__PURE__ */ L({
|
|
|
235
242
|
var e;
|
|
236
243
|
return (e = t.value) == null ? void 0 : e.enable();
|
|
237
244
|
}
|
|
238
|
-
}), (e, n) => (
|
|
239
|
-
|
|
245
|
+
}), (e, n) => (J(), N("div", W, [
|
|
246
|
+
_(w(G), {
|
|
240
247
|
class: "editor-toolbar",
|
|
241
248
|
editor: t.value,
|
|
242
249
|
defaultConfig: M,
|
|
243
250
|
mode: o.mode
|
|
244
251
|
}, null, 8, ["editor", "mode"]),
|
|
245
|
-
|
|
252
|
+
_(w(P), {
|
|
246
253
|
class: "editor-content",
|
|
247
|
-
style:
|
|
254
|
+
style: q({ height: z.value }),
|
|
248
255
|
modelValue: r.value,
|
|
249
256
|
"onUpdate:modelValue": n[0] || (n[0] = (i) => r.value = i),
|
|
250
|
-
defaultConfig:
|
|
257
|
+
defaultConfig: O,
|
|
251
258
|
mode: o.mode,
|
|
252
|
-
onOnCreated:
|
|
253
|
-
onOnChange:
|
|
254
|
-
onOnDestroyed:
|
|
255
|
-
onOnFocus:
|
|
256
|
-
onOnBlur:
|
|
259
|
+
onOnCreated: U,
|
|
260
|
+
onOnChange: j,
|
|
261
|
+
onOnDestroyed: E,
|
|
262
|
+
onOnFocus: T,
|
|
263
|
+
onOnBlur: D
|
|
257
264
|
}, null, 8, ["style", "modelValue", "mode"])
|
|
258
265
|
]));
|
|
259
266
|
}
|
|
260
|
-
}),
|
|
267
|
+
}), le = /* @__PURE__ */ Q(X, [["__scopeId", "data-v-71899034"]]);
|
|
261
268
|
export {
|
|
262
|
-
|
|
269
|
+
le as default
|
|
263
270
|
};
|