md-editor-v3 4.12.0-beta.2 → 4.12.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.
Files changed (43) hide show
  1. package/README.md +12 -0
  2. package/lib/cjs/DropdownToolbar.cjs +3 -1
  3. package/lib/cjs/MdCatalog.cjs +270 -1
  4. package/lib/cjs/MdEditor.cjs +3101 -58
  5. package/lib/cjs/MdModal.cjs +3 -1
  6. package/lib/cjs/MdPreview.cjs +3 -1
  7. package/lib/cjs/ModalToolbar.cjs +124 -1
  8. package/lib/cjs/NormalToolbar.cjs +61 -1
  9. package/lib/cjs/chunks/config.cjs +290 -1
  10. package/lib/cjs/chunks/dom.cjs +64 -1
  11. package/lib/cjs/chunks/index.cjs +1863 -8
  12. package/lib/cjs/chunks/index2.cjs +198 -1
  13. package/lib/cjs/chunks/index3.cjs +270 -1
  14. package/lib/cjs/chunks/index4.cjs +141 -2
  15. package/lib/cjs/chunks/vue-tsx.cjs +10 -1
  16. package/lib/cjs/config.cjs +12 -1
  17. package/lib/cjs/index.cjs +25 -1
  18. package/lib/es/DropdownToolbar.mjs +2 -2
  19. package/lib/es/MdCatalog.mjs +164 -114
  20. package/lib/es/MdEditor.mjs +2297 -1654
  21. package/lib/es/MdModal.mjs +2 -2
  22. package/lib/es/MdPreview.mjs +2 -2
  23. package/lib/es/ModalToolbar.mjs +55 -38
  24. package/lib/es/NormalToolbar.mjs +26 -18
  25. package/lib/es/chunks/config.mjs +73 -54
  26. package/lib/es/chunks/dom.mjs +57 -24
  27. package/lib/es/chunks/index.mjs +1099 -609
  28. package/lib/es/chunks/index2.mjs +126 -78
  29. package/lib/es/chunks/index3.mjs +185 -111
  30. package/lib/es/chunks/index4.mjs +124 -72
  31. package/lib/es/chunks/vue-tsx.mjs +8 -8
  32. package/lib/es/config.mjs +11 -10
  33. package/lib/es/index.mjs +23 -23
  34. package/lib/preview.css +200 -1
  35. package/lib/style.css +592 -1
  36. package/lib/types/MdEditor/components/Modal/Modal.d.ts +1 -1
  37. package/lib/types/MdEditor/components/Modal/index.d.ts +3 -3
  38. package/lib/types/MdEditor/layouts/Content/index.d.ts +9 -0
  39. package/lib/types/MdEditor/layouts/Content/props.d.ts +4 -0
  40. package/lib/types/MdEditor/static/event-name.d.ts +1 -0
  41. package/lib/types/MdEditor/type.d.ts +10 -1
  42. package/lib/umd/index.js +75625 -114
  43. package/package.json +1 -1
@@ -1 +1,198 @@
1
- "use strict";const o=require("vue"),d=require("./config.cjs"),g=require("./vue-tsx.cjs"),L={overlay:{type:[String,Object],default:""},visible:{type:Boolean,default:!1},onChange:{type:Function,default:()=>{}},relative:{type:String,default:"html"}},S=o.defineComponent({props:L,setup(e,i){const s=`${d.prefix}-dropdown-hidden`,t=o.reactive({overlayClass:[s],overlayStyle:{},triggerHover:!1,overlayHover:!1}),n=o.ref(),l=o.ref(),v=()=>{var h;t.triggerHover=!0;const r=n.value,a=l.value;if(!r||!a)return;const u=r.getBoundingClientRect(),y=r.offsetTop,C=r.offsetLeft,b=u.height,w=u.width,H=((h=document.querySelector(e.relative))==null?void 0:h.scrollLeft)||0;t.overlayStyle={...t.overlayStyle,top:y+b+"px",left:C-a.offsetWidth/2+w/2-H+"px"},e.onChange(!0)},m=()=>{t.overlayHover=!0};o.watch(()=>e.visible,r=>{r?t.overlayClass=t.overlayClass.filter(a=>a!==s):t.overlayClass.push(s)});let p=-1;const c=r=>{n.value===r.target?t.triggerHover=!1:t.overlayHover=!1,clearTimeout(p),p=window.setTimeout(()=>{!t.overlayHover&&!t.triggerHover&&e.onChange(!1)},10)};return o.onMounted(()=>{n.value.addEventListener("mouseenter",v),n.value.addEventListener("mouseleave",c),l.value.addEventListener("mouseenter",m),l.value.addEventListener("mouseleave",c)}),o.onBeforeUnmount(()=>{n.value.removeEventListener("mouseenter",v),n.value.removeEventListener("mouseleave",c),l.value.removeEventListener("mouseenter",m),l.value.removeEventListener("mouseleave",c)}),()=>{const r=g.getSlot({ctx:i}),a=g.getSlot({props:e,ctx:i},"overlay"),u=o.cloneVNode(r instanceof Array?r[0]:r,{ref:n}),y=o.createVNode("div",{class:[`${d.prefix}-dropdown`,t.overlayClass],style:t.overlayStyle,ref:l},[o.createVNode("div",{class:`${d.prefix}-dropdown-overlay`},[a instanceof Array?a[0]:a])]);return[u,y]}}}),E={title:{type:String,default:""},visible:{type:Boolean},trigger:{type:[String,Object]},onChange:{type:Function},overlay:{type:[String,Object]},insert:{type:Function},language:{type:String},theme:{type:String},default:{type:[String,Object]}},f=o.defineComponent({name:"DropdownToolbar",props:E,emits:["onChange"],setup(e,i){const s=o.inject("editorId");return()=>{const t=g.getSlot({props:e,ctx:i},"trigger"),n=g.getSlot({props:e,ctx:i},"overlay"),l=g.getSlot({props:e,ctx:i});return o.createVNode(S,{relative:`#${s}-toolbar-wrapper`,visible:e.visible,onChange:v=>{e.onChange instanceof Function?e.onChange(v):i.emit("onChange",v)},overlay:n},{default:()=>[o.createVNode("div",{class:`${d.prefix}-toolbar-item`,title:e.title||""},[t,l])]})}}});f.install=e=>(e.component(f.name,f),e);exports.Dropdown=S;exports.DropdownToolbar=f;
1
+ "use strict";
2
+ const vue = require("vue");
3
+ const config = require("./config.cjs");
4
+ const vueTsx = require("./vue-tsx.cjs");
5
+ const props$1 = {
6
+ overlay: {
7
+ type: [String, Object],
8
+ default: ""
9
+ },
10
+ visible: {
11
+ type: Boolean,
12
+ default: false
13
+ },
14
+ onChange: {
15
+ type: Function,
16
+ default: () => {
17
+ }
18
+ },
19
+ // 相对滚动的元素选择器
20
+ relative: {
21
+ type: String,
22
+ default: "html"
23
+ }
24
+ };
25
+ const Dropdown = /* @__PURE__ */ vue.defineComponent({
26
+ props: props$1,
27
+ setup(props2, ctx) {
28
+ const HIDDEN_CLASS = `${config.prefix}-dropdown-hidden`;
29
+ const ctl = vue.reactive({
30
+ overlayClass: [HIDDEN_CLASS],
31
+ overlayStyle: {},
32
+ triggerHover: false,
33
+ overlayHover: false
34
+ });
35
+ const triggerRef = vue.ref();
36
+ const overlayRef = vue.ref();
37
+ const triggerHandler = () => {
38
+ var _a;
39
+ ctl.triggerHover = true;
40
+ const triggerEle = triggerRef.value;
41
+ const overlayEle = overlayRef.value;
42
+ if (!triggerEle || !overlayEle) {
43
+ return;
44
+ }
45
+ const triggerInfo = triggerEle.getBoundingClientRect();
46
+ const triggerTop = triggerEle.offsetTop;
47
+ const triggerLeft = triggerEle.offsetLeft;
48
+ const triggerHeight = triggerInfo.height;
49
+ const triggerWidth = triggerInfo.width;
50
+ const relativecrollLeft = ((_a = document.querySelector(props2.relative)) == null ? void 0 : _a.scrollLeft) || 0;
51
+ ctl.overlayStyle = {
52
+ ...ctl.overlayStyle,
53
+ top: triggerTop + triggerHeight + "px",
54
+ left: triggerLeft - overlayEle.offsetWidth / 2 + triggerWidth / 2 - relativecrollLeft + "px"
55
+ };
56
+ props2.onChange(true);
57
+ };
58
+ const overlayHandler = () => {
59
+ ctl.overlayHover = true;
60
+ };
61
+ vue.watch(() => props2.visible, (newV) => {
62
+ if (newV) {
63
+ ctl.overlayClass = ctl.overlayClass.filter((classItem) => classItem !== HIDDEN_CLASS);
64
+ } else {
65
+ ctl.overlayClass.push(HIDDEN_CLASS);
66
+ }
67
+ });
68
+ let hiddenTimer = -1;
69
+ const leaveHidden = (e) => {
70
+ if (triggerRef.value === e.target) {
71
+ ctl.triggerHover = false;
72
+ } else {
73
+ ctl.overlayHover = false;
74
+ }
75
+ clearTimeout(hiddenTimer);
76
+ hiddenTimer = window.setTimeout(() => {
77
+ if (!ctl.overlayHover && !ctl.triggerHover) {
78
+ props2.onChange(false);
79
+ }
80
+ }, 10);
81
+ };
82
+ vue.onMounted(() => {
83
+ triggerRef.value.addEventListener("mouseenter", triggerHandler);
84
+ triggerRef.value.addEventListener("mouseleave", leaveHidden);
85
+ overlayRef.value.addEventListener("mouseenter", overlayHandler);
86
+ overlayRef.value.addEventListener("mouseleave", leaveHidden);
87
+ });
88
+ vue.onBeforeUnmount(() => {
89
+ triggerRef.value.removeEventListener("mouseenter", triggerHandler);
90
+ triggerRef.value.removeEventListener("mouseleave", leaveHidden);
91
+ overlayRef.value.removeEventListener("mouseenter", overlayHandler);
92
+ overlayRef.value.removeEventListener("mouseleave", leaveHidden);
93
+ });
94
+ return () => {
95
+ const slotDefault = vueTsx.getSlot({
96
+ ctx
97
+ });
98
+ const slotOverlay = vueTsx.getSlot({
99
+ props: props2,
100
+ ctx
101
+ }, "overlay");
102
+ const trigger = vue.cloneVNode(slotDefault instanceof Array ? slotDefault[0] : slotDefault, {
103
+ ref: triggerRef
104
+ });
105
+ const overlay = vue.createVNode("div", {
106
+ "class": [`${config.prefix}-dropdown`, ctl.overlayClass],
107
+ "style": ctl.overlayStyle,
108
+ "ref": overlayRef
109
+ }, [vue.createVNode("div", {
110
+ "class": `${config.prefix}-dropdown-overlay`
111
+ }, [slotOverlay instanceof Array ? slotOverlay[0] : slotOverlay])]);
112
+ return [trigger, overlay];
113
+ };
114
+ }
115
+ });
116
+ const props = {
117
+ title: {
118
+ type: String,
119
+ default: ""
120
+ },
121
+ visible: {
122
+ type: Boolean
123
+ },
124
+ // 展示在工具栏的内容,通常是个图标
125
+ trigger: {
126
+ type: [String, Object]
127
+ },
128
+ onChange: {
129
+ type: Function
130
+ },
131
+ // 下拉框中的内容
132
+ overlay: {
133
+ type: [String, Object]
134
+ },
135
+ /**
136
+ * ==没有意义,仅用于规避克隆组件自动嵌入insert方法时,传入的是该组件而产生的waring
137
+ */
138
+ insert: {
139
+ type: Function
140
+ },
141
+ language: {
142
+ type: String
143
+ },
144
+ theme: {
145
+ type: String
146
+ },
147
+ /**
148
+ * ==结束
149
+ */
150
+ default: {
151
+ type: [String, Object]
152
+ }
153
+ };
154
+ const DropdownToolbar = /* @__PURE__ */ vue.defineComponent({
155
+ name: "DropdownToolbar",
156
+ props,
157
+ emits: ["onChange"],
158
+ setup(props2, ctx) {
159
+ const editorId = vue.inject("editorId");
160
+ return () => {
161
+ const Trigger = vueTsx.getSlot({
162
+ props: props2,
163
+ ctx
164
+ }, "trigger");
165
+ const Overlay = vueTsx.getSlot({
166
+ props: props2,
167
+ ctx
168
+ }, "overlay");
169
+ const Default = vueTsx.getSlot({
170
+ props: props2,
171
+ ctx
172
+ });
173
+ return vue.createVNode(Dropdown, {
174
+ "relative": `#${editorId}-toolbar-wrapper`,
175
+ "visible": props2.visible,
176
+ "onChange": (v) => {
177
+ if (props2.onChange instanceof Function) {
178
+ props2.onChange(v);
179
+ } else {
180
+ ctx.emit("onChange", v);
181
+ }
182
+ },
183
+ "overlay": Overlay
184
+ }, {
185
+ default: () => [vue.createVNode("div", {
186
+ "class": `${config.prefix}-toolbar-item`,
187
+ "title": props2.title || ""
188
+ }, [Trigger, Default])]
189
+ });
190
+ };
191
+ }
192
+ });
193
+ DropdownToolbar.install = (app) => {
194
+ app.component(DropdownToolbar.name, DropdownToolbar);
195
+ return app;
196
+ };
197
+ exports.Dropdown = Dropdown;
198
+ exports.DropdownToolbar = DropdownToolbar;
@@ -1 +1,270 @@
1
- "use strict";const e=require("vue"),n=require("./config.cjs"),y=require("./vue-tsx.cjs"),x=require("./dom.cjs"),$=e.defineComponent({props:{name:{type:String,default:""}},setup(t){return()=>n.configOption.iconfontType==="svg"?e.createVNode("svg",{class:`${n.prefix}-icon`,"aria-hidden":"true"},[e.createVNode("use",{"xlink:href":`#${n.prefix}-icon-${t.name}`},null)]):e.createVNode("i",{class:`${n.prefix}-iconfont ${n.prefix}-icon-${t.name}`},null)}}),v=e.defineComponent({props:{name:{type:String,default:""}},setup(t){const d=e.inject("customIcon");return()=>{const i=d.value[t.name];return typeof i=="object"?typeof i.component=="object"?e.h(i.component,i.props):e.createVNode("span",{innerHTML:i.component},null):e.createVNode($,{name:t.name},null)}}}),k={title:{type:String,default:""},visible:{type:Boolean,default:!1},width:{type:String,default:"auto"},height:{type:String,default:"auto"},onClose:{type:Function},showAdjust:{type:Boolean,default:!1},isFullscreen:{type:Boolean,default:!1},onAdjust:{type:Function,default:()=>{}},class:{type:String},style:{type:Object,default:()=>({})}},I=`${n.prefix}-modal-container`,p=(()=>{let t=2e4;return()=>++t})(),r=e.defineComponent({name:"MdModal",props:k,emits:["onClose"],setup(t,d){const i=e.inject("theme"),f=e.ref(t.visible),s=e.ref([`${n.prefix}-modal`]),m=e.ref(),h=e.ref(),g=e.shallowRef();let u=()=>{};const o=e.reactive({maskStyle:{zIndex:-1},modalStyle:{zIndex:-1},initPos:{left:"0px",top:"0px"},historyPos:{left:"0px",top:"0px"}}),C=e.computed(()=>t.isFullscreen?{width:"100%",height:"100%"}:{width:t.width,height:t.height});return e.watch(()=>t.isFullscreen,a=>{a?u():e.nextTick(()=>{u=x.keyMove(h.value,(l,c)=>{o.initPos.left=l+"px",o.initPos.top=c+"px"})})}),e.watch(()=>t.visible,a=>{a?(o.maskStyle.zIndex=p(),o.modalStyle.zIndex=p(),s.value.push("zoom-in"),f.value=a,e.nextTick(()=>{const l=m.value.offsetWidth/2,c=m.value.offsetHeight/2,N=document.documentElement.clientWidth/2,P=document.documentElement.clientHeight/2;o.initPos.left=N-l+"px",o.initPos.top=P-c+"px",t.isFullscreen||(u=x.keyMove(h.value,(V,S)=>{o.initPos.left=V+"px",o.initPos.top=S+"px"}))}),setTimeout(()=>{s.value=s.value.filter(l=>l!=="zoom-in")},140)):(s.value.push("zoom-out"),u(),setTimeout(()=>{s.value=s.value.filter(l=>l!=="zoom-out"),f.value=a},130))}),()=>{const a=y.getSlot({ctx:d}),l=y.getSlot({props:t,ctx:d},"title");return e.createVNode(e.Teleport,{to:document.body},{default:()=>[e.createVNode("div",{ref:g,class:I,"data-theme":i.value},[e.createVNode("div",{class:t.class,style:{...t.style,display:f.value?"block":"none"}},[e.createVNode("div",{class:`${n.prefix}-modal-mask`,style:o.maskStyle,onClick:()=>{t.onClose?t.onClose():d.emit("onClose")}},null),e.createVNode("div",{class:s.value,style:{...o.modalStyle,...o.initPos,...C.value},ref:m},[e.createVNode("div",{class:`${n.prefix}-modal-header`,ref:h},[l||""]),e.createVNode("div",{class:`${n.prefix}-modal-body`},[a]),e.createVNode("div",{class:`${n.prefix}-modal-func`},[t.showAdjust&&e.createVNode("div",{class:`${n.prefix}-modal-adjust`,onClick:c=>{c.stopPropagation(),t.isFullscreen?o.initPos=o.historyPos:(o.historyPos=o.initPos,o.initPos={left:"0",top:"0"}),t.onAdjust(!t.isFullscreen)}},[e.createVNode(v,{name:t.isFullscreen?"suoxiao":"fangda"},null)]),e.createVNode("div",{class:`${n.prefix}-modal-close`,onClick:c=>{c.stopPropagation(),t.onClose?t.onClose():d.emit("onClose")}},[e.createVNode(v,{name:"close"},null)])])])])])]})}}});r.install=t=>(t.component(r.name,r),t);exports.Icon=v;exports.MdModal=r;
1
+ "use strict";
2
+ const vue = require("vue");
3
+ const config = require("./config.cjs");
4
+ const vueTsx = require("./vue-tsx.cjs");
5
+ const dom = require("./dom.cjs");
6
+ const Icon$1 = /* @__PURE__ */ vue.defineComponent({
7
+ props: {
8
+ name: {
9
+ type: String,
10
+ default: ""
11
+ }
12
+ },
13
+ setup(props2) {
14
+ return () => {
15
+ return config.configOption.iconfontType === "svg" ? vue.createVNode("svg", {
16
+ "class": `${config.prefix}-icon`,
17
+ "aria-hidden": "true"
18
+ }, [vue.createVNode("use", {
19
+ "xlink:href": `#${config.prefix}-icon-${props2.name}`
20
+ }, null)]) : vue.createVNode("i", {
21
+ "class": `${config.prefix}-iconfont ${config.prefix}-icon-${props2.name}`
22
+ }, null);
23
+ };
24
+ }
25
+ });
26
+ const Icon = /* @__PURE__ */ vue.defineComponent({
27
+ props: {
28
+ name: {
29
+ type: String,
30
+ default: ""
31
+ }
32
+ },
33
+ setup(props2) {
34
+ const customIcon = vue.inject("customIcon");
35
+ return () => {
36
+ const item = customIcon.value[props2.name];
37
+ if (typeof item === "object") {
38
+ return typeof item.component === "object" ? vue.h(item.component, item.props) : vue.createVNode("span", {
39
+ "innerHTML": item.component
40
+ }, null);
41
+ }
42
+ return vue.createVNode(Icon$1, {
43
+ "name": props2.name
44
+ }, null);
45
+ };
46
+ }
47
+ });
48
+ const props = {
49
+ title: {
50
+ type: String,
51
+ default: ""
52
+ },
53
+ visible: {
54
+ type: Boolean,
55
+ default: false
56
+ },
57
+ width: {
58
+ type: String,
59
+ default: "auto"
60
+ },
61
+ height: {
62
+ type: String,
63
+ default: "auto"
64
+ },
65
+ onClose: {
66
+ type: Function
67
+ },
68
+ showAdjust: {
69
+ type: Boolean,
70
+ default: false
71
+ },
72
+ isFullscreen: {
73
+ type: Boolean,
74
+ default: false
75
+ },
76
+ onAdjust: {
77
+ type: Function,
78
+ default: () => {
79
+ }
80
+ },
81
+ class: {
82
+ type: String
83
+ },
84
+ style: {
85
+ type: Object,
86
+ default: () => ({})
87
+ }
88
+ };
89
+ const getNextIndex = /* @__PURE__ */ (() => {
90
+ let startIndex = 2e4;
91
+ return () => {
92
+ return ++startIndex;
93
+ };
94
+ })();
95
+ const MdModal = /* @__PURE__ */ vue.defineComponent({
96
+ name: "MdModal",
97
+ props,
98
+ emits: ["onClose"],
99
+ setup(props2, ctx) {
100
+ const themeRef = vue.inject("theme");
101
+ const modalVisible = vue.ref(props2.visible);
102
+ const modalClass = vue.ref([`${config.prefix}-modal`]);
103
+ const modalRef = vue.ref();
104
+ const modalHeaderRef = vue.ref();
105
+ const bodyRef = vue.ref();
106
+ const containerRef = vue.shallowRef();
107
+ let keyMoveClear = () => {
108
+ };
109
+ const state = vue.reactive({
110
+ maskStyle: {
111
+ zIndex: -1
112
+ },
113
+ modalStyle: {
114
+ zIndex: -1
115
+ },
116
+ initPos: {
117
+ left: "0px",
118
+ top: "0px"
119
+ },
120
+ historyPos: {
121
+ left: "0px",
122
+ top: "0px"
123
+ }
124
+ });
125
+ const innerSize = vue.computed(() => {
126
+ if (props2.isFullscreen) {
127
+ return {
128
+ width: "100%",
129
+ height: "100%"
130
+ };
131
+ } else {
132
+ return {
133
+ width: props2.width,
134
+ height: props2.height
135
+ };
136
+ }
137
+ });
138
+ vue.watch(() => props2.isFullscreen, (nVal) => {
139
+ if (nVal) {
140
+ keyMoveClear();
141
+ } else {
142
+ vue.nextTick(() => {
143
+ keyMoveClear = dom.keyMove(modalHeaderRef.value, (left, top) => {
144
+ state.initPos.left = left + "px";
145
+ state.initPos.top = top + "px";
146
+ });
147
+ });
148
+ }
149
+ });
150
+ vue.watch(() => props2.visible, (nVal) => {
151
+ if (nVal) {
152
+ state.maskStyle.zIndex = getNextIndex();
153
+ state.modalStyle.zIndex = getNextIndex();
154
+ modalClass.value.push("zoom-in");
155
+ modalVisible.value = nVal;
156
+ vue.nextTick(() => {
157
+ const halfWidth = modalRef.value.offsetWidth / 2;
158
+ const halfHeight = modalRef.value.offsetHeight / 2;
159
+ const halfClientWidth = document.documentElement.clientWidth / 2;
160
+ const halfClientHeight = document.documentElement.clientHeight / 2;
161
+ state.initPos.left = halfClientWidth - halfWidth + "px";
162
+ state.initPos.top = halfClientHeight - halfHeight + "px";
163
+ if (!props2.isFullscreen) {
164
+ keyMoveClear = dom.keyMove(modalHeaderRef.value, (left, top) => {
165
+ state.initPos.left = left + "px";
166
+ state.initPos.top = top + "px";
167
+ });
168
+ }
169
+ });
170
+ setTimeout(() => {
171
+ modalClass.value = modalClass.value.filter((item) => item !== "zoom-in");
172
+ }, 140);
173
+ } else {
174
+ modalClass.value.push("zoom-out");
175
+ keyMoveClear();
176
+ setTimeout(() => {
177
+ modalClass.value = modalClass.value.filter((item) => item !== "zoom-out");
178
+ modalVisible.value = nVal;
179
+ }, 130);
180
+ }
181
+ });
182
+ vue.onMounted(() => {
183
+ bodyRef.value = document.body;
184
+ });
185
+ return () => {
186
+ const slotDefault = vueTsx.getSlot({
187
+ ctx
188
+ });
189
+ const slotTitle = vueTsx.getSlot({
190
+ props: props2,
191
+ ctx
192
+ }, "title");
193
+ return bodyRef.value ? vue.createVNode(vue.Teleport, {
194
+ "to": bodyRef.value
195
+ }, {
196
+ default: () => [vue.createVNode("div", {
197
+ "ref": containerRef,
198
+ "class": `${config.prefix}-modal-container`,
199
+ "data-theme": themeRef.value
200
+ }, [vue.createVNode("div", {
201
+ "class": props2.class,
202
+ "style": {
203
+ ...props2.style,
204
+ display: modalVisible.value ? "block" : "none"
205
+ }
206
+ }, [vue.createVNode("div", {
207
+ "class": `${config.prefix}-modal-mask`,
208
+ "style": state.maskStyle,
209
+ "onClick": () => {
210
+ if (props2.onClose) {
211
+ props2.onClose();
212
+ } else {
213
+ ctx.emit("onClose");
214
+ }
215
+ }
216
+ }, null), vue.createVNode("div", {
217
+ "class": modalClass.value,
218
+ "style": {
219
+ ...state.modalStyle,
220
+ ...state.initPos,
221
+ ...innerSize.value
222
+ },
223
+ "ref": modalRef
224
+ }, [vue.createVNode("div", {
225
+ "class": `${config.prefix}-modal-header`,
226
+ "ref": modalHeaderRef
227
+ }, [slotTitle || ""]), vue.createVNode("div", {
228
+ "class": `${config.prefix}-modal-body`
229
+ }, [slotDefault]), vue.createVNode("div", {
230
+ "class": `${config.prefix}-modal-func`
231
+ }, [props2.showAdjust && vue.createVNode("div", {
232
+ "class": `${config.prefix}-modal-adjust`,
233
+ "onClick": (e) => {
234
+ e.stopPropagation();
235
+ if (!props2.isFullscreen) {
236
+ state.historyPos = state.initPos;
237
+ state.initPos = {
238
+ left: "0",
239
+ top: "0"
240
+ };
241
+ } else {
242
+ state.initPos = state.historyPos;
243
+ }
244
+ props2.onAdjust(!props2.isFullscreen);
245
+ }
246
+ }, [vue.createVNode(Icon, {
247
+ "name": props2.isFullscreen ? "suoxiao" : "fangda"
248
+ }, null)]), vue.createVNode("div", {
249
+ "class": `${config.prefix}-modal-close`,
250
+ "onClick": (e) => {
251
+ e.stopPropagation();
252
+ if (props2.onClose) {
253
+ props2.onClose();
254
+ } else {
255
+ ctx.emit("onClose");
256
+ }
257
+ }
258
+ }, [vue.createVNode(Icon, {
259
+ "name": "close"
260
+ }, null)])])])])])]
261
+ }) : "";
262
+ };
263
+ }
264
+ });
265
+ MdModal.install = (app) => {
266
+ app.component(MdModal.name, MdModal);
267
+ return app;
268
+ };
269
+ exports.Icon = Icon;
270
+ exports.MdModal = MdModal;
@@ -1,2 +1,141 @@
1
- "use strict";var C=Object.defineProperty;var i=(o,t,s)=>t in o?C(o,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[t]=s;var r=(o,t,s)=>(i(o,typeof t!="symbol"?t+"":t,s),s);class a{constructor(){r(this,"pools",{})}remove(t,s,e){const n=this.pools[t]&&this.pools[t][s];n&&(this.pools[t][s]=n.filter(E=>E!==e))}clear(t){this.pools[t]={}}on(t,s){return this.pools[t]||(this.pools[t]={}),this.pools[t][s.name]||(this.pools[t][s.name]=[]),this.pools[t][s.name].push(s.callback),this.pools[t][s.name].includes(s.callback)}emit(t,s,...e){this.pools[t]||(this.pools[t]={});const n=this.pools[t][s];n&&n.forEach(E=>{try{E(...e)}catch(c){console.error(`${s} monitor event exception!`,c)}})}}const A=new a,_="onSave",R="changeCatalogVisible",p="changeFullscreen",L="pageFullscreenChanged",h="fullscreenChanged",u="previewChanged",N="htmlPreviewChanged",g="catalogVisibleChanged",G="buildFinished",H="errorCatcher",I="replace",D="uploadImage",S="openModals",d="ctrlZ",T="ctrlShiftZ",O="catalogChanged",F="pushCatalog",b="rerender",P=(o,t="image.png")=>{const s=o.split(","),e=s[0].match(/:(.*?);/);if(e){const l=e[1],n=atob(s[1]);let E=n.length;const c=new Uint8Array(E);for(;E--;)c[E]=n.charCodeAt(E);return new File([c],t,{type:l})}return null},f=o=>{if(!o)return o;const t=o.split(`
2
- `),s=['<span rn-wrapper aria-hidden="true">'];return t.forEach(()=>{s.push("<span></span>")}),s.push("</span>"),`<span class="code-block">${o}</span>${s.join("")}`},U=(o,t)=>{if(!o||!t)return 0;const s=o==null?void 0:o.getBoundingClientRect();if(t===document.documentElement)return s.top-t.clientTop;const e=t==null?void 0:t.getBoundingClientRect();return s.top-e.top},m=(()=>{let o=0;return t=>t+ ++o})();exports.BUILD_FINISHED=G;exports.CATALOG_CHANGED=O;exports.CATALOG_VISIBLE_CHANGED=g;exports.CHANGE_CATALOG_VISIBLE=R;exports.CHANGE_FULL_SCREEN=p;exports.CTRL_SHIFT_Z=T;exports.CTRL_Z=d;exports.ERROR_CATCHER=H;exports.FULL_SCREEN_CHANGED=h;exports.HTML_PREVIEW_CHANGED=N;exports.ON_SAVE=_;exports.OPEN_MODALS=S;exports.PAGE_FULL_SCREEN_CHANGED=L;exports.PREVIEW_CHANGED=u;exports.PUSH_CATALOG=F;exports.REPLACE=I;exports.RERENDER=b;exports.UPLOAD_IMAGE=D;exports.base642File=P;exports.bus=A;exports.generateCodeRowNumber=f;exports.getNextId=m;exports.getRelativeTop=U;
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
+ var __publicField = (obj, key, value) => {
5
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6
+ return value;
7
+ };
8
+ class Bus {
9
+ constructor() {
10
+ // 事件池
11
+ __publicField(this, "pools", {});
12
+ }
13
+ // 移除事件监听
14
+ remove(race, name, func) {
15
+ const targetRace = this.pools[race];
16
+ const events = targetRace && this.pools[race][name];
17
+ if (events) {
18
+ this.pools[race][name] = events.filter((item) => item !== func);
19
+ }
20
+ }
21
+ // 清空全部事件,由于单一实例,多次注册会被共享内容
22
+ clear(race) {
23
+ this.pools[race] = {};
24
+ }
25
+ // 注册事件监听
26
+ on(race, event) {
27
+ if (!this.pools[race]) {
28
+ this.pools[race] = {};
29
+ }
30
+ if (!this.pools[race][event.name]) {
31
+ this.pools[race][event.name] = [];
32
+ }
33
+ this.pools[race][event.name].push(event.callback);
34
+ return this.pools[race][event.name].includes(event.callback);
35
+ }
36
+ // 触发事件
37
+ emit(race, name, ...params) {
38
+ if (!this.pools[race]) {
39
+ this.pools[race] = {};
40
+ }
41
+ const targetRace = this.pools[race];
42
+ const events = targetRace[name];
43
+ if (events) {
44
+ events.forEach((item) => {
45
+ try {
46
+ item(...params);
47
+ } catch (error) {
48
+ console.error(`${name} monitor event exception!`, error);
49
+ }
50
+ });
51
+ }
52
+ }
53
+ }
54
+ const bus = new Bus();
55
+ const ON_SAVE = "onSave";
56
+ const CHANGE_CATALOG_VISIBLE = "changeCatalogVisible";
57
+ const CHANGE_FULL_SCREEN = "changeFullscreen";
58
+ const PAGE_FULL_SCREEN_CHANGED = "pageFullscreenChanged";
59
+ const FULL_SCREEN_CHANGED = "fullscreenChanged";
60
+ const PREVIEW_CHANGED = "previewChanged";
61
+ const HTML_PREVIEW_CHANGED = "htmlPreviewChanged";
62
+ const CATALOG_VISIBLE_CHANGED = "catalogVisibleChanged";
63
+ const BUILD_FINISHED = "buildFinished";
64
+ const ERROR_CATCHER = "errorCatcher";
65
+ const REPLACE = "replace";
66
+ const UPLOAD_IMAGE = "uploadImage";
67
+ const OPEN_MODALS = "openModals";
68
+ const CTRL_Z = "ctrlZ";
69
+ const CTRL_SHIFT_Z = "ctrlShiftZ";
70
+ const CATALOG_CHANGED = "catalogChanged";
71
+ const PUSH_CATALOG = "pushCatalog";
72
+ const RERENDER = "rerender";
73
+ const EVENT_LISTENER = "eventListener";
74
+ const base642File = (base64, fileName = "image.png") => {
75
+ const arr = base64.split(",");
76
+ const regResult = arr[0].match(/:(.*?);/);
77
+ if (regResult) {
78
+ const mime = regResult[1];
79
+ const bstr = atob(arr[1]);
80
+ let n = bstr.length;
81
+ const u8arr = new Uint8Array(n);
82
+ while (n--) {
83
+ u8arr[n] = bstr.charCodeAt(n);
84
+ }
85
+ return new File([u8arr], fileName, { type: mime });
86
+ }
87
+ return null;
88
+ };
89
+ const generateCodeRowNumber = (code) => {
90
+ if (!code) {
91
+ return code;
92
+ }
93
+ const list = code.split("\n");
94
+ const rowNumberList = ['<span rn-wrapper aria-hidden="true">'];
95
+ list.forEach(() => {
96
+ rowNumberList.push("<span></span>");
97
+ });
98
+ rowNumberList.push("</span>");
99
+ return `<span class="code-block">${code}</span>${rowNumberList.join("")}`;
100
+ };
101
+ const getRelativeTop = (element, container) => {
102
+ if (!element || !container) {
103
+ return 0;
104
+ }
105
+ const eleRect = element == null ? void 0 : element.getBoundingClientRect();
106
+ if (container === document.documentElement) {
107
+ return eleRect.top - container.clientTop;
108
+ }
109
+ const conRect = container == null ? void 0 : container.getBoundingClientRect();
110
+ return eleRect.top - conRect.top;
111
+ };
112
+ const getNextId = /* @__PURE__ */ (() => {
113
+ let count = 0;
114
+ return (prefix) => {
115
+ return prefix + ++count;
116
+ };
117
+ })();
118
+ exports.BUILD_FINISHED = BUILD_FINISHED;
119
+ exports.CATALOG_CHANGED = CATALOG_CHANGED;
120
+ exports.CATALOG_VISIBLE_CHANGED = CATALOG_VISIBLE_CHANGED;
121
+ exports.CHANGE_CATALOG_VISIBLE = CHANGE_CATALOG_VISIBLE;
122
+ exports.CHANGE_FULL_SCREEN = CHANGE_FULL_SCREEN;
123
+ exports.CTRL_SHIFT_Z = CTRL_SHIFT_Z;
124
+ exports.CTRL_Z = CTRL_Z;
125
+ exports.ERROR_CATCHER = ERROR_CATCHER;
126
+ exports.EVENT_LISTENER = EVENT_LISTENER;
127
+ exports.FULL_SCREEN_CHANGED = FULL_SCREEN_CHANGED;
128
+ exports.HTML_PREVIEW_CHANGED = HTML_PREVIEW_CHANGED;
129
+ exports.ON_SAVE = ON_SAVE;
130
+ exports.OPEN_MODALS = OPEN_MODALS;
131
+ exports.PAGE_FULL_SCREEN_CHANGED = PAGE_FULL_SCREEN_CHANGED;
132
+ exports.PREVIEW_CHANGED = PREVIEW_CHANGED;
133
+ exports.PUSH_CATALOG = PUSH_CATALOG;
134
+ exports.REPLACE = REPLACE;
135
+ exports.RERENDER = RERENDER;
136
+ exports.UPLOAD_IMAGE = UPLOAD_IMAGE;
137
+ exports.base642File = base642File;
138
+ exports.bus = bus;
139
+ exports.generateCodeRowNumber = generateCodeRowNumber;
140
+ exports.getNextId = getNextId;
141
+ exports.getRelativeTop = getRelativeTop;
@@ -1 +1,10 @@
1
- "use strict";const s=({instance:o,ctx:l,props:g={}},t="default")=>{const r=(o==null?void 0:o.$slots[t])||(l==null?void 0:l.slots[t]);return(r?r(o):"")||g[t]};exports.getSlot=s;
1
+ "use strict";
2
+ const getSlot = ({
3
+ instance,
4
+ ctx,
5
+ props = {}
6
+ }, name = "default") => {
7
+ const targetSlot = (instance == null ? void 0 : instance.$slots[name]) || (ctx == null ? void 0 : ctx.slots[name]);
8
+ return (targetSlot ? targetSlot(instance) : "") || props[name];
9
+ };
10
+ exports.getSlot = getSlot;
@@ -1 +1,12 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./chunks/config.cjs"),t=o.staticTextDefault["zh-CN"],l=o.staticTextDefault["en-US"];exports.allFooter=o.allFooter;exports.allToolbar=o.allToolbar;exports.config=o.config;exports.iconfontClassUrl=o.iconfontClassUrl;exports.iconfontSvgUrl=o.iconfontSvgUrl;exports.en_US=l;exports.zh_CN=t;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const config = require("./chunks/config.cjs");
4
+ const zh_CN = config.staticTextDefault["zh-CN"];
5
+ const en_US = config.staticTextDefault["en-US"];
6
+ exports.allFooter = config.allFooter;
7
+ exports.allToolbar = config.allToolbar;
8
+ exports.config = config.config;
9
+ exports.iconfontClassUrl = config.iconfontClassUrl;
10
+ exports.iconfontSvgUrl = config.iconfontSvgUrl;
11
+ exports.en_US = en_US;
12
+ exports.zh_CN = zh_CN;
package/lib/cjs/index.cjs CHANGED
@@ -1 +1,25 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MdEditor.cjs"),l=require("./chunks/index.cjs"),a=require("./NormalToolbar.cjs"),n=require("./chunks/index2.cjs"),i=require("./ModalToolbar.cjs"),t=require("./MdCatalog.cjs"),d=require("./chunks/index3.cjs"),r=require("./config.cjs"),o=require("./chunks/config.cjs");exports.MdEditor=e;exports.MdPreview=l.MdPreview;exports.NormalToolbar=a;exports.DropdownToolbar=n.DropdownToolbar;exports.ModalToolbar=i;exports.MdCatalog=t;exports.MdModal=d.MdModal;exports.en_US=r.en_US;exports.zh_CN=r.zh_CN;exports.allFooter=o.allFooter;exports.allToolbar=o.allToolbar;exports.config=o.config;exports.iconfontClassUrl=o.iconfontClassUrl;exports.iconfontSvgUrl=o.iconfontSvgUrl;
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const MdEditor = require("./MdEditor.cjs");
4
+ const MdPreview = require("./chunks/index.cjs");
5
+ const NormalToolbar = require("./NormalToolbar.cjs");
6
+ const DropdownToolbar = require("./chunks/index2.cjs");
7
+ const ModalToolbar = require("./ModalToolbar.cjs");
8
+ const MdCatalog = require("./MdCatalog.cjs");
9
+ const MdModal = require("./chunks/index3.cjs");
10
+ const config = require("./config.cjs");
11
+ const config$1 = require("./chunks/config.cjs");
12
+ exports.MdEditor = MdEditor;
13
+ exports.MdPreview = MdPreview.MdPreview;
14
+ exports.NormalToolbar = NormalToolbar;
15
+ exports.DropdownToolbar = DropdownToolbar.DropdownToolbar;
16
+ exports.ModalToolbar = ModalToolbar;
17
+ exports.MdCatalog = MdCatalog;
18
+ exports.MdModal = MdModal.MdModal;
19
+ exports.en_US = config.en_US;
20
+ exports.zh_CN = config.zh_CN;
21
+ exports.allFooter = config$1.allFooter;
22
+ exports.allToolbar = config$1.allToolbar;
23
+ exports.config = config$1.config;
24
+ exports.iconfontClassUrl = config$1.iconfontClassUrl;
25
+ exports.iconfontSvgUrl = config$1.iconfontSvgUrl;
@@ -1,4 +1,4 @@
1
- import { D as f } from "./chunks/index2.mjs";
1
+ import { D } from "./chunks/index2.mjs";
2
2
  export {
3
- f as default
3
+ D as default
4
4
  };