md-editor-v3 3.0.1 → 4.0.0
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/README.md +131 -95
- package/lib/cjs/DropdownToolbar.cjs +1 -0
- package/lib/cjs/MdCatalog.cjs +1 -0
- package/lib/cjs/MdEditor.cjs +60 -0
- package/lib/cjs/MdPreview.cjs +1 -0
- package/lib/cjs/ModalToolbar.cjs +1 -0
- package/lib/cjs/NormalToolbar.cjs +1 -0
- package/lib/cjs/chunks/config.cjs +1 -0
- package/lib/cjs/chunks/dom.cjs +1 -0
- package/lib/cjs/chunks/event-bus.cjs +1 -0
- package/lib/cjs/chunks/index.cjs +8 -0
- package/lib/cjs/chunks/index2.cjs +1 -0
- package/lib/cjs/chunks/index3.cjs +1 -0
- package/lib/cjs/chunks/index4.cjs +2 -0
- package/lib/cjs/chunks/vue-tsx.cjs +1 -0
- package/lib/cjs/config.cjs +1 -0
- package/lib/cjs/index.cjs +1 -0
- package/lib/es/DropdownToolbar.mjs +7 -0
- package/lib/es/MdCatalog.mjs +215 -0
- package/lib/es/MdEditor.mjs +2286 -0
- package/lib/es/MdPreview.mjs +15 -0
- package/lib/es/ModalToolbar.mjs +9 -0
- package/lib/es/NormalToolbar.mjs +39 -0
- package/lib/es/chunks/config.mjs +271 -0
- package/lib/es/chunks/dom.mjs +32 -0
- package/lib/es/chunks/event-bus.mjs +38 -0
- package/lib/es/chunks/index.mjs +1061 -0
- package/lib/es/chunks/index2.mjs +135 -0
- package/lib/es/chunks/index3.mjs +229 -0
- package/lib/es/chunks/index4.mjs +57 -0
- package/lib/es/chunks/vue-tsx.mjs +11 -0
- package/lib/es/config.mjs +4 -0
- package/lib/es/index.mjs +35 -0
- package/lib/preview.css +1 -0
- package/lib/style.css +1 -1
- package/lib/types/DropdownToolbar/index.d.ts +129 -0
- package/lib/{MdEditor/extensions → types}/MdCatalog/CatalogLink.d.ts +4 -4
- package/lib/{MdEditor/extensions/MdCatalog/index.d.ts → types/MdCatalog/MdCatalog.d.ts} +3 -3
- package/lib/types/MdCatalog/index.d.ts +193 -0
- package/lib/{MdEditor → types/MdEditor}/Editor.d.ts +153 -162
- package/lib/types/MdEditor/components/Checkbox/index.d.ts +24 -0
- package/lib/types/MdEditor/components/Divider/index.d.ts +2 -0
- package/lib/types/MdEditor/components/Dropdown/index.d.ts +53 -0
- package/lib/types/MdEditor/components/Modal/index.d.ts +84 -0
- package/lib/types/MdEditor/composition.d.ts +66 -0
- package/lib/{MdEditor → types/MdEditor}/index.d.ts +343 -388
- package/lib/types/MdEditor/layouts/Content/ContentPreview.d.ts +154 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/commands.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/index.d.ts +56 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeLight.d.ts +23 -0
- package/lib/types/MdEditor/layouts/Content/codemirror/themeOneDark.d.ts +26 -0
- package/lib/types/MdEditor/layouts/Content/composition/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAttach.d.ts +7 -0
- package/lib/types/MdEditor/layouts/Content/composition/useAutoScroll.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCodeMirror.d.ts +13 -0
- package/lib/types/MdEditor/layouts/Content/composition/useCopyCode.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Content/composition/useHighlight.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useKatex.d.ts +8 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMarkdownIt.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/composition/useMermaid.d.ts +11 -0
- package/lib/types/MdEditor/layouts/Content/composition/usePasteUpload.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/composition/userZoom.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/index.d.ts +173 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/admonition/index.d.ts +5 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/codetabs/index.d.ts +14 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/heading/index.d.ts +9 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/katex/index.d.ts +10 -0
- package/lib/types/MdEditor/layouts/Content/markdownIt/mermaid/index.d.ts +6 -0
- package/lib/types/MdEditor/layouts/Content/props.d.ts +89 -0
- package/lib/types/MdEditor/layouts/Footer/MarkdownTotal.d.ts +15 -0
- package/lib/types/MdEditor/layouts/Footer/ScrollAuto.d.ts +21 -0
- package/lib/types/MdEditor/layouts/Footer/index.d.ts +50 -0
- package/lib/types/MdEditor/layouts/Modals/Clip.d.ts +33 -0
- package/lib/types/MdEditor/layouts/Modals/Link.d.ts +42 -0
- package/lib/types/MdEditor/layouts/Modals/index.d.ts +51 -0
- package/lib/types/MdEditor/layouts/Toolbar/TableShape.d.ts +28 -0
- package/lib/types/MdEditor/layouts/Toolbar/composition.d.ts +4 -0
- package/lib/types/MdEditor/layouts/Toolbar/index.d.ts +91 -0
- package/lib/types/MdEditor/layouts/Toolbar/props.d.ts +45 -0
- package/lib/types/MdEditor/props.d.ts +546 -0
- package/lib/types/MdEditor/static/event-name.d.ts +9 -0
- package/lib/{MdEditor → types/MdEditor}/type.d.ts +2 -1
- package/lib/types/MdEditor/utils/content-help.d.ts +19 -0
- package/lib/types/MdEditor/utils/dom.d.ts +22 -0
- package/lib/types/MdEditor/utils/event-bus.d.ts +17 -0
- package/lib/types/MdEditor/utils/index.d.ts +66 -0
- package/lib/types/MdEditor/utils/scroll-auto.d.ts +18 -0
- package/lib/types/MdEditor/utils/smooth-scroll.d.ts +8 -0
- package/lib/types/MdEditor/utils/vue-tsx.d.ts +23 -0
- package/lib/types/MdPreview/MdPreview.d.ts +186 -0
- package/lib/types/MdPreview/index.d.ts +453 -0
- package/lib/types/ModalToolbar/index.d.ts +244 -0
- package/lib/types/NormalToolbar/index.d.ts +105 -0
- package/lib/types/config.d.ts +1 -0
- package/lib/types/index.d.ts +8 -0
- package/lib/{md-editor-v3.umd.js → umd/index.js} +38 -38
- package/package.json +16 -20
- package/lib/md-editor-v3.cjs +0 -63
- package/lib/md-editor-v3.mjs +0 -4143
- /package/lib/{MdEditor/extensions → types/DropdownToolbar}/DropdownToolbar.d.ts +0 -0
- /package/lib/{MdEditor → types/MdEditor}/config.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/ModalToolbar}/ModalToolbar.d.ts +0 -0
- /package/lib/{MdEditor/extensions → types/NormalToolbar}/NormalToolbar.d.ts +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { M as x } from "./chunks/index.mjs";
|
|
2
|
+
import "vue";
|
|
3
|
+
import "./chunks/config.mjs";
|
|
4
|
+
import "./chunks/event-bus.mjs";
|
|
5
|
+
import "./chunks/dom.mjs";
|
|
6
|
+
import "./chunks/index4.mjs";
|
|
7
|
+
import "medium-zoom";
|
|
8
|
+
import "copy-to-clipboard";
|
|
9
|
+
import "markdown-it";
|
|
10
|
+
import "markdown-it-image-figures";
|
|
11
|
+
import "markdown-it-task-lists";
|
|
12
|
+
import "lru-cache";
|
|
13
|
+
export {
|
|
14
|
+
x as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineComponent as r, createVNode as l } from "vue";
|
|
2
|
+
import { p as a } from "./chunks/config.mjs";
|
|
3
|
+
import { g as c } from "./chunks/vue-tsx.mjs";
|
|
4
|
+
const m = {
|
|
5
|
+
title: {
|
|
6
|
+
type: String,
|
|
7
|
+
default: ""
|
|
8
|
+
},
|
|
9
|
+
// 展示在工具栏的内容,通常是个图标
|
|
10
|
+
trigger: {
|
|
11
|
+
type: [String, Object]
|
|
12
|
+
},
|
|
13
|
+
onClick: {
|
|
14
|
+
type: Function
|
|
15
|
+
}
|
|
16
|
+
}, e = /* @__PURE__ */ r({
|
|
17
|
+
name: "NormalToolbar",
|
|
18
|
+
props: m,
|
|
19
|
+
emits: ["onClick"],
|
|
20
|
+
setup(t, o) {
|
|
21
|
+
return () => {
|
|
22
|
+
const n = c({
|
|
23
|
+
props: t,
|
|
24
|
+
ctx: o
|
|
25
|
+
}, "trigger");
|
|
26
|
+
return l("div", {
|
|
27
|
+
class: `${a}-toolbar-item`,
|
|
28
|
+
title: t.title,
|
|
29
|
+
onClick: (i) => {
|
|
30
|
+
t.onClick instanceof Function ? t.onClick(i) : o.emit("onClick", i);
|
|
31
|
+
}
|
|
32
|
+
}, [n]);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
e.install = (t) => (t.component(e.name, e), t);
|
|
37
|
+
export {
|
|
38
|
+
e as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
const a = "md-editor", o = "md-editor-v3", r = "https://at.alicdn.com/t/c/font_2605852_u82y61ve02.js", e = "https://cdnjs.cloudflare.com/ajax/libs", n = `${e}/highlight.js/11.7.0/highlight.min.js`, c = {
|
|
2
|
+
main: `${e}/prettier/2.8.0/standalone.js`,
|
|
3
|
+
markdown: `${e}/prettier/2.8.0/parser-markdown.js`
|
|
4
|
+
}, d = {
|
|
5
|
+
css: `${e}/cropperjs/1.5.13/cropper.min.css`,
|
|
6
|
+
js: `${e}/cropperjs/1.5.13/cropper.min.js`
|
|
7
|
+
}, h = `${e}/screenfull.js/5.2.0/screenfull.min.js`, g = [
|
|
8
|
+
"bold",
|
|
9
|
+
"underline",
|
|
10
|
+
"italic",
|
|
11
|
+
"strikeThrough",
|
|
12
|
+
"-",
|
|
13
|
+
"title",
|
|
14
|
+
"sub",
|
|
15
|
+
"sup",
|
|
16
|
+
"quote",
|
|
17
|
+
"unorderedList",
|
|
18
|
+
"orderedList",
|
|
19
|
+
"task",
|
|
20
|
+
"-",
|
|
21
|
+
"codeRow",
|
|
22
|
+
"code",
|
|
23
|
+
"link",
|
|
24
|
+
"image",
|
|
25
|
+
"table",
|
|
26
|
+
"mermaid",
|
|
27
|
+
"katex",
|
|
28
|
+
"-",
|
|
29
|
+
"revoke",
|
|
30
|
+
"next",
|
|
31
|
+
"save",
|
|
32
|
+
"=",
|
|
33
|
+
"prettier",
|
|
34
|
+
"pageFullscreen",
|
|
35
|
+
"fullscreen",
|
|
36
|
+
"preview",
|
|
37
|
+
"htmlPreview",
|
|
38
|
+
"catalog",
|
|
39
|
+
"github"
|
|
40
|
+
], m = ["markdownTotal", "=", "scrollSwitch"], p = {
|
|
41
|
+
"zh-CN": {
|
|
42
|
+
toolbarTips: {
|
|
43
|
+
bold: "加粗",
|
|
44
|
+
underline: "下划线",
|
|
45
|
+
italic: "斜体",
|
|
46
|
+
strikeThrough: "删除线",
|
|
47
|
+
title: "标题",
|
|
48
|
+
sub: "下标",
|
|
49
|
+
sup: "上标",
|
|
50
|
+
quote: "引用",
|
|
51
|
+
unorderedList: "无序列表",
|
|
52
|
+
orderedList: "有序列表",
|
|
53
|
+
task: "任务列表",
|
|
54
|
+
codeRow: "行内代码",
|
|
55
|
+
code: "块级代码",
|
|
56
|
+
link: "链接",
|
|
57
|
+
image: "图片",
|
|
58
|
+
table: "表格",
|
|
59
|
+
mermaid: "mermaid图",
|
|
60
|
+
katex: "katex公式",
|
|
61
|
+
revoke: "后退",
|
|
62
|
+
next: "前进",
|
|
63
|
+
save: "保存",
|
|
64
|
+
prettier: "美化",
|
|
65
|
+
pageFullscreen: "浏览器全屏",
|
|
66
|
+
fullscreen: "屏幕全屏",
|
|
67
|
+
preview: "预览",
|
|
68
|
+
htmlPreview: "html代码预览",
|
|
69
|
+
catalog: "目录",
|
|
70
|
+
github: "源码地址"
|
|
71
|
+
},
|
|
72
|
+
titleItem: {
|
|
73
|
+
h1: "一级标题",
|
|
74
|
+
h2: "二级标题",
|
|
75
|
+
h3: "三级标题",
|
|
76
|
+
h4: "四级标题",
|
|
77
|
+
h5: "五级标题",
|
|
78
|
+
h6: "六级标题"
|
|
79
|
+
},
|
|
80
|
+
imgTitleItem: {
|
|
81
|
+
link: "添加链接",
|
|
82
|
+
upload: "上传图片",
|
|
83
|
+
clip2upload: "裁剪上传"
|
|
84
|
+
},
|
|
85
|
+
linkModalTips: {
|
|
86
|
+
linkTitle: "添加链接",
|
|
87
|
+
imageTitle: "添加图片",
|
|
88
|
+
descLabel: "链接描述:",
|
|
89
|
+
descLabelPlaceHolder: "请输入描述...",
|
|
90
|
+
urlLabel: "链接地址:",
|
|
91
|
+
urlLabelPlaceHolder: "请输入链接...",
|
|
92
|
+
buttonOK: "确定"
|
|
93
|
+
},
|
|
94
|
+
clipModalTips: {
|
|
95
|
+
title: "裁剪图片上传",
|
|
96
|
+
buttonUpload: "上传"
|
|
97
|
+
},
|
|
98
|
+
copyCode: {
|
|
99
|
+
text: "复制代码",
|
|
100
|
+
successTips: "已复制!",
|
|
101
|
+
failTips: "复制失败!"
|
|
102
|
+
},
|
|
103
|
+
mermaid: {
|
|
104
|
+
flow: "流程图",
|
|
105
|
+
sequence: "时序图",
|
|
106
|
+
gantt: "甘特图",
|
|
107
|
+
class: "类图",
|
|
108
|
+
state: "状态图",
|
|
109
|
+
pie: "饼图",
|
|
110
|
+
relationship: "关系图",
|
|
111
|
+
journey: "旅程图"
|
|
112
|
+
},
|
|
113
|
+
katex: {
|
|
114
|
+
inline: "行内公式",
|
|
115
|
+
block: "块级公式"
|
|
116
|
+
},
|
|
117
|
+
footer: {
|
|
118
|
+
markdownTotal: "字数",
|
|
119
|
+
scrollAuto: "同步滚动"
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"en-US": {
|
|
123
|
+
toolbarTips: {
|
|
124
|
+
bold: "bold",
|
|
125
|
+
underline: "underline",
|
|
126
|
+
italic: "italic",
|
|
127
|
+
strikeThrough: "strikeThrough",
|
|
128
|
+
title: "title",
|
|
129
|
+
sub: "subscript",
|
|
130
|
+
sup: "superscript",
|
|
131
|
+
quote: "quote",
|
|
132
|
+
unorderedList: "unordered list",
|
|
133
|
+
orderedList: "ordered list",
|
|
134
|
+
task: "task list",
|
|
135
|
+
codeRow: "inline code",
|
|
136
|
+
code: "block-level code",
|
|
137
|
+
link: "link",
|
|
138
|
+
image: "image",
|
|
139
|
+
table: "table",
|
|
140
|
+
mermaid: "mermaid",
|
|
141
|
+
katex: "formula",
|
|
142
|
+
revoke: "revoke",
|
|
143
|
+
next: "undo revoke",
|
|
144
|
+
save: "save",
|
|
145
|
+
prettier: "prettier",
|
|
146
|
+
pageFullscreen: "fullscreen in page",
|
|
147
|
+
fullscreen: "fullscreen",
|
|
148
|
+
preview: "preview",
|
|
149
|
+
htmlPreview: "html preview",
|
|
150
|
+
catalog: "catalog",
|
|
151
|
+
github: "source code"
|
|
152
|
+
},
|
|
153
|
+
titleItem: {
|
|
154
|
+
h1: "Lv1 Heading",
|
|
155
|
+
h2: "Lv2 Heading",
|
|
156
|
+
h3: "Lv3 Heading",
|
|
157
|
+
h4: "Lv4 Heading",
|
|
158
|
+
h5: "Lv5 Heading",
|
|
159
|
+
h6: "Lv6 Heading"
|
|
160
|
+
},
|
|
161
|
+
imgTitleItem: {
|
|
162
|
+
link: "Add Img Link",
|
|
163
|
+
upload: "Upload Img",
|
|
164
|
+
clip2upload: "Clip Upload"
|
|
165
|
+
},
|
|
166
|
+
linkModalTips: {
|
|
167
|
+
linkTitle: "Add Link",
|
|
168
|
+
imageTitle: "Add Image",
|
|
169
|
+
descLabel: "Desc:",
|
|
170
|
+
descLabelPlaceHolder: "Enter a description...",
|
|
171
|
+
urlLabel: "Link:",
|
|
172
|
+
urlLabelPlaceHolder: "Enter a link...",
|
|
173
|
+
buttonOK: "OK"
|
|
174
|
+
},
|
|
175
|
+
clipModalTips: {
|
|
176
|
+
title: "Crop Image",
|
|
177
|
+
buttonUpload: "Upload"
|
|
178
|
+
},
|
|
179
|
+
copyCode: {
|
|
180
|
+
text: "Copy",
|
|
181
|
+
successTips: "Copied!",
|
|
182
|
+
failTips: "Copy failed!"
|
|
183
|
+
},
|
|
184
|
+
mermaid: {
|
|
185
|
+
flow: "flow",
|
|
186
|
+
sequence: "sequence",
|
|
187
|
+
gantt: "gantt",
|
|
188
|
+
class: "class",
|
|
189
|
+
state: "state",
|
|
190
|
+
pie: "pie",
|
|
191
|
+
relationship: "relationship",
|
|
192
|
+
journey: "journey"
|
|
193
|
+
},
|
|
194
|
+
katex: {
|
|
195
|
+
inline: "inline",
|
|
196
|
+
block: "block"
|
|
197
|
+
},
|
|
198
|
+
footer: {
|
|
199
|
+
markdownTotal: "Word Count",
|
|
200
|
+
scrollAuto: "Scroll Auto"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}, u = `${e}/mermaid/9.4.0/mermaid.min.js`, k = {
|
|
204
|
+
js: `${e}/KaTeX/0.16.3/katex.min.js`,
|
|
205
|
+
css: `${e}/KaTeX/0.16.3/katex.min.css`
|
|
206
|
+
}, b = {
|
|
207
|
+
a11y: {
|
|
208
|
+
light: `${e}/highlight.js/11.7.0/styles/a11y-light.min.css`,
|
|
209
|
+
dark: `${e}/highlight.js/11.7.0/styles/a11y-dark.min.css`
|
|
210
|
+
},
|
|
211
|
+
atom: {
|
|
212
|
+
light: `${e}/highlight.js/11.7.0/styles/atom-one-light.min.css`,
|
|
213
|
+
dark: `${e}/highlight.js/11.7.0/styles/atom-one-dark.min.css`
|
|
214
|
+
},
|
|
215
|
+
github: {
|
|
216
|
+
light: `${e}/highlight.js/11.7.0/styles/github.min.css`,
|
|
217
|
+
dark: `${e}/highlight.js/11.7.0/styles/github-dark.min.css`
|
|
218
|
+
},
|
|
219
|
+
gradient: {
|
|
220
|
+
light: `${e}/highlight.js/11.7.0/styles/gradient-light.min.css`,
|
|
221
|
+
dark: `${e}/highlight.js/11.7.0/styles/gradient-dark.min.css`
|
|
222
|
+
},
|
|
223
|
+
kimbie: {
|
|
224
|
+
light: `${e}/highlight.js/11.7.0/styles/kimbie-light.min.css`,
|
|
225
|
+
dark: `${e}/highlight.js/11.7.0/styles/kimbie-dark.min.css`
|
|
226
|
+
},
|
|
227
|
+
paraiso: {
|
|
228
|
+
light: `${e}/highlight.js/11.7.0/styles/paraiso-light.min.css`,
|
|
229
|
+
dark: `${e}/highlight.js/11.7.0/styles/paraiso-dark.min.css`
|
|
230
|
+
},
|
|
231
|
+
qtcreator: {
|
|
232
|
+
light: `${e}/highlight.js/11.7.0/styles/qtcreator-light.min.css`,
|
|
233
|
+
dark: `${e}/highlight.js/11.7.0/styles/qtcreator-dark.min.css`
|
|
234
|
+
},
|
|
235
|
+
stackoverflow: {
|
|
236
|
+
light: `${e}/highlight.js/11.7.0/styles/stackoverflow-light.min.css`,
|
|
237
|
+
dark: `${e}/highlight.js/11.7.0/styles/stackoverflow-dark.min.css`
|
|
238
|
+
}
|
|
239
|
+
}, l = {
|
|
240
|
+
// markedRenderer: (r) => r,
|
|
241
|
+
// markedExtensions: [],
|
|
242
|
+
// markedOptions: {},
|
|
243
|
+
editorExtensions: {},
|
|
244
|
+
editorConfig: {},
|
|
245
|
+
codeMirrorExtensions: (i, t) => t,
|
|
246
|
+
markdownItConfig: () => {
|
|
247
|
+
}
|
|
248
|
+
}, j = (i) => {
|
|
249
|
+
if (i)
|
|
250
|
+
for (const t in i) {
|
|
251
|
+
const s = i[t];
|
|
252
|
+
s && (l[t] = s);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
export {
|
|
256
|
+
l as a,
|
|
257
|
+
g as b,
|
|
258
|
+
j as c,
|
|
259
|
+
m as d,
|
|
260
|
+
b as e,
|
|
261
|
+
p as f,
|
|
262
|
+
c as g,
|
|
263
|
+
n as h,
|
|
264
|
+
r as i,
|
|
265
|
+
d as j,
|
|
266
|
+
k,
|
|
267
|
+
o as l,
|
|
268
|
+
u as m,
|
|
269
|
+
a as p,
|
|
270
|
+
h as s
|
|
271
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { d as E } from "./index4.mjs";
|
|
2
|
+
const L = (e, d) => {
|
|
3
|
+
const t = (n) => {
|
|
4
|
+
const o = e.parentElement || document.body, i = o.offsetWidth, m = o.offsetHeight, { clientWidth: u } = document.documentElement, { clientHeight: l } = document.documentElement, p = n.offsetX, v = n.offsetY, a = (f) => {
|
|
5
|
+
let s = f.x + document.body.scrollLeft - document.body.clientLeft - p, c = f.y + document.body.scrollTop - document.body.clientTop - v;
|
|
6
|
+
s = s < 1 ? 1 : s < u - i - 1 ? s : u - i - 1, c = c < 1 ? 1 : c < l - m - 1 ? c : l - m - 1, d ? d(s, c) : (o.style.left = `${s}px`, o.style.top = `${c}px`);
|
|
7
|
+
};
|
|
8
|
+
document.addEventListener("mousemove", a);
|
|
9
|
+
const r = () => {
|
|
10
|
+
document.removeEventListener("mousemove", a), document.removeEventListener("mouseup", r);
|
|
11
|
+
};
|
|
12
|
+
document.addEventListener("mouseup", r);
|
|
13
|
+
};
|
|
14
|
+
return e.addEventListener("mousedown", t), () => {
|
|
15
|
+
e.removeEventListener("mousedown", t);
|
|
16
|
+
};
|
|
17
|
+
}, h = (e, d = "") => {
|
|
18
|
+
const t = document.getElementById(e.id), n = e.onload;
|
|
19
|
+
e.onload = null;
|
|
20
|
+
const o = function(i) {
|
|
21
|
+
typeof n == "function" && n.bind(this)(i), e.removeEventListener("load", o);
|
|
22
|
+
};
|
|
23
|
+
t ? d !== "" && (t.addEventListener("load", o), Reflect.get(window, d) && t.dispatchEvent(new Event("load"))) : (e.addEventListener("load", o), document.head.appendChild(e));
|
|
24
|
+
}, b = E((e, d, t) => {
|
|
25
|
+
const n = document.getElementById(e);
|
|
26
|
+
n && n.setAttribute(d, t);
|
|
27
|
+
}, 10);
|
|
28
|
+
export {
|
|
29
|
+
h as a,
|
|
30
|
+
L as k,
|
|
31
|
+
b as u
|
|
32
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var e = Object.defineProperty;
|
|
2
|
+
var a = (t, o, s) => o in t ? e(t, o, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[o] = s;
|
|
3
|
+
var h = (t, o, s) => (a(t, typeof o != "symbol" ? o + "" : o, s), s);
|
|
4
|
+
class r {
|
|
5
|
+
constructor() {
|
|
6
|
+
// 事件池
|
|
7
|
+
h(this, "pools", {});
|
|
8
|
+
}
|
|
9
|
+
// 移除事件监听
|
|
10
|
+
remove(o, s, l) {
|
|
11
|
+
const i = this.pools[o] && this.pools[o][s];
|
|
12
|
+
i && (this.pools[o][s] = i.filter((p) => p !== l));
|
|
13
|
+
}
|
|
14
|
+
// 清空全部事件,由于单一实例,多次注册会被共享内容
|
|
15
|
+
clear(o) {
|
|
16
|
+
this.pools[o] = {};
|
|
17
|
+
}
|
|
18
|
+
// 注册事件监听
|
|
19
|
+
on(o, s) {
|
|
20
|
+
return this.pools[o] || (this.pools[o] = {}), this.pools[o][s.name] || (this.pools[o][s.name] = []), this.pools[o][s.name].push(s.callback), this.pools[o][s.name].includes(s.callback);
|
|
21
|
+
}
|
|
22
|
+
// 触发事件
|
|
23
|
+
emit(o, s, ...l) {
|
|
24
|
+
this.pools[o] || (this.pools[o] = {});
|
|
25
|
+
const i = this.pools[o][s];
|
|
26
|
+
i && i.forEach((p) => {
|
|
27
|
+
try {
|
|
28
|
+
p(...l);
|
|
29
|
+
} catch (n) {
|
|
30
|
+
console.error(`${s} monitor event exception!`, n);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const m = new r();
|
|
36
|
+
export {
|
|
37
|
+
m as b
|
|
38
|
+
};
|