hy-dispatch-ui-v3 0.2.81 → 0.2.83
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/tailwind.css +4 -0
- package/es/api/file.mjs +19 -0
- package/es/components/hyKindEditor/index.mjs +7 -0
- package/es/components/hyKindEditor/kindEditor.vue.mjs +285 -0
- package/es/components/hyKindEditor/style/kindEditor.scss +18 -0
- package/es/components/hyUserAvatar/userAvatar.vue.mjs +2 -2
- package/es/components/index.mjs +1 -0
- package/es/index.mjs +2 -1
- package/es/utils/file.mjs +7 -1
- package/es/utils/index.mjs +1 -1
- package/es/utils/permission.mjs +5 -1
- package/es/version.mjs +1 -1
- package/lib/api/file.js +21 -0
- package/lib/components/hyKindEditor/index.js +12 -0
- package/lib/components/hyKindEditor/kindEditor.vue.js +289 -0
- package/lib/components/hyKindEditor/style/kindEditor.scss +18 -0
- package/lib/components/hyUserAvatar/userAvatar.vue.js +2 -2
- package/lib/components/index.js +32 -30
- package/lib/index.js +51 -48
- package/lib/utils/file.js +7 -0
- package/lib/utils/index.js +1 -0
- package/lib/utils/permission.js +5 -1
- package/lib/version.js +1 -1
- package/package.json +3 -1
package/dist/tailwind.css
CHANGED
package/es/api/file.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { unref } from 'vue';
|
|
2
|
+
import '../hooks/index.mjs';
|
|
3
|
+
import { useApi } from '../hooks/useApi.mjs';
|
|
4
|
+
|
|
5
|
+
function preSignedUrlGetApi(params) {
|
|
6
|
+
return new Promise((resolve, reject) => {
|
|
7
|
+
const { api } = useApi();
|
|
8
|
+
const http = unref(api);
|
|
9
|
+
http.post("file/preSignedUrlGet", params, {
|
|
10
|
+
isJSON: true
|
|
11
|
+
}).then((res) => {
|
|
12
|
+
resolve(res);
|
|
13
|
+
}).catch((res) => {
|
|
14
|
+
resolve(res);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { preSignedUrlGetApi };
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import { defineComponent, useModel, shallowRef, computed, watch, onBeforeUnmount, openBlock, createElementBlock, normalizeClass, createBlock, unref, createCommentVNode, createVNode, normalizeStyle, mergeModels } from 'vue';
|
|
2
|
+
import { ElMessage } from 'element-plus';
|
|
3
|
+
import { Toolbar, Editor } from '@wangeditor/editor-for-vue';
|
|
4
|
+
import { SlateTransforms } from '@wangeditor/editor';
|
|
5
|
+
import '../../utils/index.mjs';
|
|
6
|
+
import { preSignedUrlGetApi, fileUpload } from '../../utils/file.mjs';
|
|
7
|
+
|
|
8
|
+
import "@wangeditor/editor/dist/css/style.css";
|
|
9
|
+
|
|
10
|
+
import "./style/kindEditor.scss";
|
|
11
|
+
|
|
12
|
+
const __default__ = defineComponent({
|
|
13
|
+
name: "HyKindEditor"
|
|
14
|
+
});
|
|
15
|
+
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
16
|
+
props: /* @__PURE__ */ mergeModels({
|
|
17
|
+
mode: { type: String, default: "default" },
|
|
18
|
+
// 'default' | 'simple'
|
|
19
|
+
height: { type: [String, Number], default: 300 },
|
|
20
|
+
// 编辑区高度
|
|
21
|
+
placeholder: { type: String, default: "\u8BF7\u8F93\u5165\u5185\u5BB9..." },
|
|
22
|
+
disabled: { type: Boolean, default: false },
|
|
23
|
+
// 只读
|
|
24
|
+
showToolbar: { type: Boolean, default: true },
|
|
25
|
+
toolbarConfig: { type: Object, default: () => ({}) },
|
|
26
|
+
// 透传 wangEditor toolbarConfig
|
|
27
|
+
editorConfig: { type: Object, default: () => ({}) },
|
|
28
|
+
// 透传 wangEditor editorConfig
|
|
29
|
+
maxImageSize: { type: Number, default: 10 },
|
|
30
|
+
// 图片大小限制,单位 MB
|
|
31
|
+
maxVideoSize: { type: Number, default: 100 },
|
|
32
|
+
// 视频大小限制,单位 MB
|
|
33
|
+
pasteImageFilter: { type: Function }
|
|
34
|
+
// (src: string) => boolean,返回 false 的图片不转存(如自家 OSS 域名)
|
|
35
|
+
}, {
|
|
36
|
+
"modelValue": { type: String, default: "" },
|
|
37
|
+
"modelModifiers": {}
|
|
38
|
+
}),
|
|
39
|
+
emits: /* @__PURE__ */ mergeModels(["created", "change", "focus", "blur"], ["update:modelValue"]),
|
|
40
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
41
|
+
const props = __props;
|
|
42
|
+
const emits = __emit;
|
|
43
|
+
const modelValue = useModel(__props, "modelValue");
|
|
44
|
+
const editorRef = shallowRef();
|
|
45
|
+
const editorHeight = computed(() => typeof props.height === "number" ? `${props.height}px` : props.height);
|
|
46
|
+
const fileURLList = [];
|
|
47
|
+
const rememberFile = ({ key, url }) => {
|
|
48
|
+
if (!key || !url) return;
|
|
49
|
+
if (fileURLList.some((item) => item.url === url)) return;
|
|
50
|
+
fileURLList.push({ key, url });
|
|
51
|
+
};
|
|
52
|
+
const isKnownUrl = (url) => fileURLList.some((item) => item.url === url);
|
|
53
|
+
const getMediaSrcList = (html) => {
|
|
54
|
+
const list = [];
|
|
55
|
+
const tags = html.match(/<(img|video|source)\b[^>]*>/gi) || [];
|
|
56
|
+
tags.forEach((tag) => {
|
|
57
|
+
for (const [, value] of tag.matchAll(/\s(?:src|poster)="([^"]*)"/gi)) {
|
|
58
|
+
value && list.push(value);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return [...new Set(list)];
|
|
62
|
+
};
|
|
63
|
+
const isUrl = (value) => /^(https?:|blob:|data:)/i.test(value);
|
|
64
|
+
const replaceSrc = (html, from, to) => html.replaceAll(`"${from}"`, `"${to}"`);
|
|
65
|
+
const keyToUrl = async (html) => {
|
|
66
|
+
if (!html) return "";
|
|
67
|
+
const keyList = getMediaSrcList(html).filter((value) => !isUrl(value));
|
|
68
|
+
if (!keyList.length) return html;
|
|
69
|
+
try {
|
|
70
|
+
const res = await preSignedUrlGetApi(keyList);
|
|
71
|
+
const data = res?.data || [];
|
|
72
|
+
data.forEach(({ key, url }) => {
|
|
73
|
+
if (!key || !url) return;
|
|
74
|
+
html = replaceSrc(html, key, url);
|
|
75
|
+
rememberFile({ key, url });
|
|
76
|
+
});
|
|
77
|
+
const failCount = keyList.filter((key) => !data.some((item) => item.key === key && item.url)).length;
|
|
78
|
+
if (failCount) {
|
|
79
|
+
ElMessage.warning(`\u5185\u5BB9\u4E2D\u6709 ${failCount} \u4E2A\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25`);
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
console.warn("[HyKindEditor] key \u6362 url \u5931\u8D25\uFF0C\u4FDD\u7559\u539F\u5185\u5BB9", e);
|
|
83
|
+
ElMessage.error(e?.msg || e?.message || "\u5185\u5BB9\u4E2D\u7684\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25");
|
|
84
|
+
}
|
|
85
|
+
return html;
|
|
86
|
+
};
|
|
87
|
+
const urlToKey = (html) => {
|
|
88
|
+
if (!html) return "";
|
|
89
|
+
fileURLList.forEach(({ key, url }) => {
|
|
90
|
+
html = replaceSrc(html, url, key);
|
|
91
|
+
});
|
|
92
|
+
return html;
|
|
93
|
+
};
|
|
94
|
+
const FILE_TYPES = {
|
|
95
|
+
image: {
|
|
96
|
+
name: "\u56FE\u7247",
|
|
97
|
+
types: ["image/jpeg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
98
|
+
typesText: "jpg\u3001png\u3001gif\u3001bmp\u3001webp",
|
|
99
|
+
getMaxSize: () => props.maxImageSize
|
|
100
|
+
},
|
|
101
|
+
video: {
|
|
102
|
+
name: "\u89C6\u9891",
|
|
103
|
+
types: ["video/*"],
|
|
104
|
+
getMaxSize: () => props.maxVideoSize
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const isAllowedType = (file, types) => types.some((type) => type.endsWith("/*") ? file.type.startsWith(type.slice(0, -1)) : file.type === type);
|
|
108
|
+
const checkFile = (file, fileType) => {
|
|
109
|
+
const { name, types, typesText, getMaxSize } = FILE_TYPES[fileType];
|
|
110
|
+
if (!isAllowedType(file, types)) {
|
|
111
|
+
throw new Error(typesText ? `${name}\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4EC5\u652F\u6301 ${typesText}` : `\u8BF7\u9009\u62E9${name}\u6587\u4EF6`);
|
|
112
|
+
}
|
|
113
|
+
if (file.size === 0) {
|
|
114
|
+
throw new Error("\u65E0\u6CD5\u53D1\u9001\u7A7A\u6587\u4EF6(0KB)\uFF0C\u8BF7\u9009\u62E9\u5305\u542B\u5185\u5BB9\u7684\u6587\u4EF6");
|
|
115
|
+
}
|
|
116
|
+
const maxSize = getMaxSize();
|
|
117
|
+
if (file.size / 1024 / 1024 > maxSize) {
|
|
118
|
+
throw new Error(`\u4E0A\u4F20\u7684\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236(${maxSize}MB)`);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const uploadFile = async (file, fileType) => {
|
|
122
|
+
checkFile(file, fileType);
|
|
123
|
+
const fileUploadRes = await fileUpload(file);
|
|
124
|
+
if (fileUploadRes?.code !== 200) throw fileUploadRes;
|
|
125
|
+
const preSignedUrlGetApiRes = await preSignedUrlGetApi([fileUploadRes.data.key]);
|
|
126
|
+
const item = preSignedUrlGetApiRes?.data?.[0];
|
|
127
|
+
if (!item?.url) throw new Error("\u83B7\u53D6\u6587\u4EF6\u5730\u5740\u5931\u8D25");
|
|
128
|
+
rememberFile(item);
|
|
129
|
+
return item.url;
|
|
130
|
+
};
|
|
131
|
+
const createUploader = (fileType) => ({
|
|
132
|
+
allowedFileTypes: FILE_TYPES[fileType].types,
|
|
133
|
+
async customUpload(file, insertFn) {
|
|
134
|
+
try {
|
|
135
|
+
insertFn(await uploadFile(file, fileType));
|
|
136
|
+
} catch (e) {
|
|
137
|
+
ElMessage.error(e?.msg || e?.message || `${FILE_TYPES[fileType].name}\u4E0A\u4F20\u5931\u8D25`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
const DEFAULT_EXCLUDE_KEYS = ["emotion", "insertLink", "insertImage", "insertVideo", "fullScreen"];
|
|
142
|
+
const toolbarOptions = computed(() => {
|
|
143
|
+
const { excludeKeys = [], ...rest } = props.toolbarConfig;
|
|
144
|
+
return {
|
|
145
|
+
...rest,
|
|
146
|
+
excludeKeys: [.../* @__PURE__ */ new Set([...DEFAULT_EXCLUDE_KEYS, ...excludeKeys])]
|
|
147
|
+
};
|
|
148
|
+
});
|
|
149
|
+
const getPasteImageSrcs = (html) => {
|
|
150
|
+
if (!html || !/<img/i.test(html)) return [];
|
|
151
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
152
|
+
const srcs = [...doc.querySelectorAll("img")].map((img) => img.getAttribute("src") || "");
|
|
153
|
+
return [...new Set(srcs)].filter(
|
|
154
|
+
(src) => /^(https?:|data:image\/)/i.test(src) && !isKnownUrl(src) && (!props.pasteImageFilter || props.pasteImageFilter(src) !== false)
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
const srcToFile = async (src) => {
|
|
158
|
+
const res = await fetch(src, { mode: "cors", credentials: "omit" }).catch(() => {
|
|
159
|
+
throw new Error("\u6765\u6E90\u7F51\u7AD9\u4E0D\u5141\u8BB8\u4E0B\u8F7D\u8BE5\u56FE\u7247");
|
|
160
|
+
});
|
|
161
|
+
if (!res.ok) throw new Error(`\u4E0B\u8F7D\u5931\u8D25\uFF1A${res.status}`);
|
|
162
|
+
const blob = await res.blob();
|
|
163
|
+
const ext = blob.type.split("/")[1]?.split("+")[0] || "png";
|
|
164
|
+
return new File([blob], `paste-${Date.now()}.${ext}`, { type: blob.type });
|
|
165
|
+
};
|
|
166
|
+
const updateImage = (oldSrc, attrs) => {
|
|
167
|
+
const editor = editorRef.value;
|
|
168
|
+
if (!editor || editor.isDestroyed) return;
|
|
169
|
+
SlateTransforms.setNodes(editor, attrs, {
|
|
170
|
+
at: [],
|
|
171
|
+
voids: true,
|
|
172
|
+
match: (node) => node.type === "image" && node.src === oldSrc
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
const hasImageInEditor = (src) => !!editorRef.value?.getElemsByType("image").some((node) => node.src === src);
|
|
176
|
+
const transferPasteImages = async (pasteSrcs) => {
|
|
177
|
+
const srcs = pasteSrcs.filter(hasImageInEditor);
|
|
178
|
+
const reasons = [];
|
|
179
|
+
await Promise.all(
|
|
180
|
+
srcs.map(async (src) => {
|
|
181
|
+
try {
|
|
182
|
+
const url = await uploadFile(await srcToFile(src), "image");
|
|
183
|
+
updateImage(src, { src: url });
|
|
184
|
+
} catch (e) {
|
|
185
|
+
reasons.push(e?.msg || e?.message || "\u672A\u77E5\u539F\u56E0");
|
|
186
|
+
updateImage(src, { src: "", alt: "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" });
|
|
187
|
+
console.warn("[HyKindEditor] \u7C98\u8D34\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF0C\u5DF2\u6E05\u7A7A\u5730\u5740\uFF1A", src, e);
|
|
188
|
+
}
|
|
189
|
+
})
|
|
190
|
+
);
|
|
191
|
+
if (reasons.length) {
|
|
192
|
+
ElMessage.error(`${reasons.length} \u5F20\u7C98\u8D34\u7684\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF08${reasons[0]}\uFF09\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const handleCustomPaste = (editor, event, callback) => {
|
|
196
|
+
if (props.editorConfig.customPaste?.(editor, event) === false) {
|
|
197
|
+
callback(false);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const srcs = getPasteImageSrcs(event.clipboardData?.getData("text/html"));
|
|
201
|
+
srcs.length && setTimeout(() => transferPasteImages(srcs));
|
|
202
|
+
callback(true);
|
|
203
|
+
};
|
|
204
|
+
const DEFAULT_HOVERBAR_KEYS = {
|
|
205
|
+
image: { menuKeys: ["imageWidth30", "imageWidth50", "imageWidth100", "deleteImage"] }
|
|
206
|
+
};
|
|
207
|
+
const editorOptions = computed(() => {
|
|
208
|
+
const { MENU_CONF = {}, customPaste, hoverbarKeys = {}, ...rest } = props.editorConfig;
|
|
209
|
+
return {
|
|
210
|
+
placeholder: props.placeholder,
|
|
211
|
+
readOnly: props.disabled,
|
|
212
|
+
...rest,
|
|
213
|
+
hoverbarKeys: { ...DEFAULT_HOVERBAR_KEYS, ...hoverbarKeys },
|
|
214
|
+
MENU_CONF: {
|
|
215
|
+
uploadImage: createUploader("image"),
|
|
216
|
+
uploadVideo: createUploader("video"),
|
|
217
|
+
...MENU_CONF
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
const handleCreated = (editor) => {
|
|
222
|
+
editorRef.value = editor;
|
|
223
|
+
emits("created", editor);
|
|
224
|
+
};
|
|
225
|
+
watch(
|
|
226
|
+
() => props.disabled,
|
|
227
|
+
(val) => {
|
|
228
|
+
const editor = editorRef.value;
|
|
229
|
+
if (!editor) return;
|
|
230
|
+
val ? editor.disable() : editor.enable();
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
onBeforeUnmount(() => {
|
|
234
|
+
editorRef.value?.destroy();
|
|
235
|
+
editorRef.value = null;
|
|
236
|
+
});
|
|
237
|
+
__expose({
|
|
238
|
+
getEditor: () => editorRef.value,
|
|
239
|
+
getHtml: () => editorRef.value?.getHtml() ?? "",
|
|
240
|
+
getText: () => editorRef.value?.getText() ?? "",
|
|
241
|
+
isEmpty: () => editorRef.value?.isEmpty() ?? true,
|
|
242
|
+
clear: () => editorRef.value?.clear(),
|
|
243
|
+
focus: () => editorRef.value?.focus(),
|
|
244
|
+
insertHtml: (html) => editorRef.value?.dangerouslyInsertHtml(html),
|
|
245
|
+
// 回显:把内容中图片 / 视频的 key 换成 url,返回新内容
|
|
246
|
+
keyToUrl,
|
|
247
|
+
// 保存:把内容中图片 / 视频的 url 换回 key,返回新内容
|
|
248
|
+
urlToKey
|
|
249
|
+
});
|
|
250
|
+
return (_ctx, _cache) => {
|
|
251
|
+
return openBlock(), createElementBlock(
|
|
252
|
+
"div",
|
|
253
|
+
{
|
|
254
|
+
class: normalizeClass(["hy-kind-editor z-[10000]", { "is-disabled": __props.disabled }])
|
|
255
|
+
},
|
|
256
|
+
[
|
|
257
|
+
__props.showToolbar ? (openBlock(), createBlock(unref(Toolbar), {
|
|
258
|
+
key: 0,
|
|
259
|
+
class: "hy-kind-editor__toolbar",
|
|
260
|
+
editor: editorRef.value,
|
|
261
|
+
"default-config": toolbarOptions.value,
|
|
262
|
+
mode: __props.mode
|
|
263
|
+
}, null, 8, ["editor", "default-config", "mode"])) : createCommentVNode("v-if", true),
|
|
264
|
+
createVNode(unref(Editor), {
|
|
265
|
+
modelValue: modelValue.value,
|
|
266
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
267
|
+
class: "hy-kind-editor__content",
|
|
268
|
+
style: normalizeStyle({ height: editorHeight.value }),
|
|
269
|
+
"default-config": editorOptions.value,
|
|
270
|
+
mode: __props.mode,
|
|
271
|
+
onOnCreated: handleCreated,
|
|
272
|
+
onCustomPaste: handleCustomPaste,
|
|
273
|
+
onOnChange: (editor) => emits("change", editor),
|
|
274
|
+
onOnFocus: (editor) => emits("focus", editor),
|
|
275
|
+
onOnBlur: (editor) => emits("blur", editor)
|
|
276
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "default-config", "mode", "onOnChange", "onOnFocus", "onOnBlur"])
|
|
277
|
+
],
|
|
278
|
+
2
|
|
279
|
+
/* CLASS */
|
|
280
|
+
);
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
export { _sfc_main as default };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.hy-kind-editor {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border: 1px solid var(--el-border-color);
|
|
4
|
+
border-radius: var(--el-border-radius-base);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
&__toolbar {
|
|
8
|
+
border-bottom: 1px solid var(--el-border-color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&__content {
|
|
12
|
+
overflow-y: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.is-disabled {
|
|
16
|
+
background-color: var(--el-disabled-bg-color);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -17,13 +17,13 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
17
17
|
initSelectSvgName: {
|
|
18
18
|
type: String,
|
|
19
19
|
default: () => {
|
|
20
|
-
return "dispatch-share1-user-
|
|
20
|
+
return "dispatch-share1-user-off";
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
initSvgName: {
|
|
24
24
|
type: String,
|
|
25
25
|
default: () => {
|
|
26
|
-
return "dispatch-share1-user-
|
|
26
|
+
return "dispatch-share1-user-high";
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
device: {
|
package/es/components/index.mjs
CHANGED
|
@@ -31,6 +31,7 @@ export { HyDrawer } from './hyDrawer/index.mjs';
|
|
|
31
31
|
export { HyStatus } from './hyStatus/index.mjs';
|
|
32
32
|
export { HyCheckboxGroup } from './hyCheckboxGroup/index.mjs';
|
|
33
33
|
export { HyLocationMap } from './hyLocationMap/index.mjs';
|
|
34
|
+
export { HyKindEditor } from './hyKindEditor/index.mjs';
|
|
34
35
|
export { resetAppFormValue, useAppForm } from './hyForm/js/useAppForm.mjs';
|
|
35
36
|
export { resetAppSearchValue, useAppSearch } from './hySearch/js/useAppSearch.mjs';
|
|
36
37
|
export { useAppTable } from './hyTable/js/useAppTable.mjs';
|
package/es/index.mjs
CHANGED
|
@@ -28,6 +28,7 @@ export { HyFilePlayback } from './bussiness/hyFilePlayback/index.mjs';
|
|
|
28
28
|
export { HyForm } from './components/hyForm/index.mjs';
|
|
29
29
|
export { HyIcon } from './components/hyIcon/index.mjs';
|
|
30
30
|
export { HyIconBox } from './components/hyIconBox/index.mjs';
|
|
31
|
+
export { HyKindEditor } from './components/hyKindEditor/index.mjs';
|
|
31
32
|
export { HyLocationMap } from './components/hyLocationMap/index.mjs';
|
|
32
33
|
export { HyMap } from './components/hyMap/index.mjs';
|
|
33
34
|
export { HyMapAearchPlace } from './bussiness/hyMapAearchPlace/index.mjs';
|
|
@@ -51,7 +52,7 @@ export { HyVideoPlayer } from './components/hyVideoPlayer/index.mjs';
|
|
|
51
52
|
export { InitMap, setMapServer, setPoiServer } from './utils/map/index.mjs';
|
|
52
53
|
export { PERMISSION } from './utils/permission.mjs';
|
|
53
54
|
export { base64Decrypt, encryptToBase64, generateRandomCode } from './utils/crypto.mjs';
|
|
54
|
-
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, presignedUrl, sizeToTextHandler } from './utils/file.mjs';
|
|
55
|
+
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, preSignedUrlGetApi, presignedUrl, sizeToTextHandler } from './utils/file.mjs';
|
|
55
56
|
export { bus, usePublish, useSubscribe } from './hooks/useSubscribe.mjs';
|
|
56
57
|
export { clearResizeObserver, useResizeObserver } from './hooks/useResizeObserver.mjs';
|
|
57
58
|
export { clearSpace, columnDefaultValueHandler, columnHelpHandler, columnLabelHandler, columnPlaceholderHandler, columnRuleHandler, columnTimeRangeOptionsHandler, columnnoDataTextHandler, genColumnDefaultLabel, genColumnShortcuts, genRuleRequiredMsgHandler, genValueByProp, getValueByProp, setValueByProp } from './utils/form.mjs';
|
package/es/utils/file.mjs
CHANGED
|
@@ -33,6 +33,12 @@ async function fileJsonUplaod(file) {
|
|
|
33
33
|
});
|
|
34
34
|
return result;
|
|
35
35
|
}
|
|
36
|
+
async function preSignedUrlGetApi(keyList) {
|
|
37
|
+
const { api } = useApi();
|
|
38
|
+
return await unref(api).post("file/preSignedUrlGet", { keyList }, {
|
|
39
|
+
isJSON: true
|
|
40
|
+
});
|
|
41
|
+
}
|
|
36
42
|
async function fileFormUpload(file) {
|
|
37
43
|
const { api } = useApi();
|
|
38
44
|
try {
|
|
@@ -66,4 +72,4 @@ async function sizeToTextHandler(size) {
|
|
|
66
72
|
return `${Math.floor(size / Math.pow(1024, 4) / 100) * 100}TB`;
|
|
67
73
|
}
|
|
68
74
|
|
|
69
|
-
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, presignedUrl, sizeToTextHandler };
|
|
75
|
+
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, preSignedUrlGetApi, presignedUrl, sizeToTextHandler };
|
package/es/utils/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ export { base64Decrypt, encryptToBase64, generateRandomCode } from './crypto.mjs
|
|
|
3
3
|
export { isArray, isBoolean, isEmpty, isFile, isFunction, isNull, isNumber, isObject, isOverflowing, isPermission, isString, isSupportH265, isSymbol, isUndefined, isVueProxy } from './is.mjs';
|
|
4
4
|
export { cloneDeep, copyText, createUniqueId, funRunHandler, mergeDeep, withInstall } from './handler.mjs';
|
|
5
5
|
export { formatDuration, getDefaultValueFormatByType } from './date.mjs';
|
|
6
|
-
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, presignedUrl, sizeToTextHandler } from './file.mjs';
|
|
6
|
+
export { blobToDataURL, fileFormUpload, fileJsonUplaod, fileUpload, preSignedUrlGetApi, presignedUrl, sizeToTextHandler } from './file.mjs';
|
|
7
7
|
export { clearSpace, columnDefaultValueHandler, columnHelpHandler, columnLabelHandler, columnPlaceholderHandler, columnRuleHandler, columnTimeRangeOptionsHandler, columnnoDataTextHandler, genColumnDefaultLabel, genColumnShortcuts, genRuleRequiredMsgHandler, genValueByProp, getValueByProp, setValueByProp } from './form.mjs';
|
|
8
8
|
export { enterNumbersRrLetters, enterTheMumber, filterSpaces, formatTimeFn, getPublicFileSize, inputForbidden, keepTwoDecimalPlaces, onlyNumber } from './input.mjs';
|
|
9
9
|
export { PERMISSION } from './permission.mjs';
|
package/es/utils/permission.mjs
CHANGED
|
@@ -494,7 +494,11 @@ const PERMISSION = {
|
|
|
494
494
|
// 工单系统
|
|
495
495
|
headerNavigation_policeticketSyncShangrao: "headerNavigation_policeticketSyncShangrao",
|
|
496
496
|
// 采集站管理 - 非全链路模式 - 同步数据
|
|
497
|
-
operator_acquisitionStation_nonFullChainMode_manualDataSynchronization: "operator_acquisitionStation_nonFullChainMode_manualDataSynchronization"
|
|
497
|
+
operator_acquisitionStation_nonFullChainMode_manualDataSynchronization: "operator_acquisitionStation_nonFullChainMode_manualDataSynchronization",
|
|
498
|
+
// 设置中心 - 采集站授权
|
|
499
|
+
setting_modifyCsAuth: "setting_modifyCsAuth",
|
|
500
|
+
// 设置中心 - 采集站授权 - 上传文件
|
|
501
|
+
setting_modifyCsAuth_uploadAuthorizationFile: "setting_modifyCsAuth_uploadAuthorizationFile"
|
|
498
502
|
};
|
|
499
503
|
|
|
500
504
|
export { PERMISSION };
|
package/es/version.mjs
CHANGED
package/lib/api/file.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
require('../hooks/index.js');
|
|
5
|
+
var useApi = require('../hooks/useApi.js');
|
|
6
|
+
|
|
7
|
+
function preSignedUrlGetApi(params) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const { api } = useApi.useApi();
|
|
10
|
+
const http = vue.unref(api);
|
|
11
|
+
http.post("file/preSignedUrlGet", params, {
|
|
12
|
+
isJSON: true
|
|
13
|
+
}).then((res) => {
|
|
14
|
+
resolve(res);
|
|
15
|
+
}).catch((res) => {
|
|
16
|
+
resolve(res);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
exports.preSignedUrlGetApi = preSignedUrlGetApi;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('../../utils/index.js');
|
|
6
|
+
var kindEditor = require('./kindEditor.vue.js');
|
|
7
|
+
var handler = require('../../utils/handler.js');
|
|
8
|
+
|
|
9
|
+
const HyKindEditor = handler.withInstall(kindEditor.default);
|
|
10
|
+
|
|
11
|
+
exports.HyKindEditor = HyKindEditor;
|
|
12
|
+
exports.default = HyKindEditor;
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
var elementPlus = require('element-plus');
|
|
7
|
+
var editorForVue = require('@wangeditor/editor-for-vue');
|
|
8
|
+
var editor = require('@wangeditor/editor');
|
|
9
|
+
require('../../utils/index.js');
|
|
10
|
+
var file = require('../../utils/file.js');
|
|
11
|
+
|
|
12
|
+
import "@wangeditor/editor/dist/css/style.css";
|
|
13
|
+
|
|
14
|
+
import "./style/kindEditor.scss";
|
|
15
|
+
|
|
16
|
+
const __default__ = vue.defineComponent({
|
|
17
|
+
name: "HyKindEditor"
|
|
18
|
+
});
|
|
19
|
+
const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
20
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
21
|
+
mode: { type: String, default: "default" },
|
|
22
|
+
// 'default' | 'simple'
|
|
23
|
+
height: { type: [String, Number], default: 300 },
|
|
24
|
+
// 编辑区高度
|
|
25
|
+
placeholder: { type: String, default: "\u8BF7\u8F93\u5165\u5185\u5BB9..." },
|
|
26
|
+
disabled: { type: Boolean, default: false },
|
|
27
|
+
// 只读
|
|
28
|
+
showToolbar: { type: Boolean, default: true },
|
|
29
|
+
toolbarConfig: { type: Object, default: () => ({}) },
|
|
30
|
+
// 透传 wangEditor toolbarConfig
|
|
31
|
+
editorConfig: { type: Object, default: () => ({}) },
|
|
32
|
+
// 透传 wangEditor editorConfig
|
|
33
|
+
maxImageSize: { type: Number, default: 10 },
|
|
34
|
+
// 图片大小限制,单位 MB
|
|
35
|
+
maxVideoSize: { type: Number, default: 100 },
|
|
36
|
+
// 视频大小限制,单位 MB
|
|
37
|
+
pasteImageFilter: { type: Function }
|
|
38
|
+
// (src: string) => boolean,返回 false 的图片不转存(如自家 OSS 域名)
|
|
39
|
+
}, {
|
|
40
|
+
"modelValue": { type: String, default: "" },
|
|
41
|
+
"modelModifiers": {}
|
|
42
|
+
}),
|
|
43
|
+
emits: /* @__PURE__ */ vue.mergeModels(["created", "change", "focus", "blur"], ["update:modelValue"]),
|
|
44
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
45
|
+
const props = __props;
|
|
46
|
+
const emits = __emit;
|
|
47
|
+
const modelValue = vue.useModel(__props, "modelValue");
|
|
48
|
+
const editorRef = vue.shallowRef();
|
|
49
|
+
const editorHeight = vue.computed(() => typeof props.height === "number" ? `${props.height}px` : props.height);
|
|
50
|
+
const fileURLList = [];
|
|
51
|
+
const rememberFile = ({ key, url }) => {
|
|
52
|
+
if (!key || !url) return;
|
|
53
|
+
if (fileURLList.some((item) => item.url === url)) return;
|
|
54
|
+
fileURLList.push({ key, url });
|
|
55
|
+
};
|
|
56
|
+
const isKnownUrl = (url) => fileURLList.some((item) => item.url === url);
|
|
57
|
+
const getMediaSrcList = (html) => {
|
|
58
|
+
const list = [];
|
|
59
|
+
const tags = html.match(/<(img|video|source)\b[^>]*>/gi) || [];
|
|
60
|
+
tags.forEach((tag) => {
|
|
61
|
+
for (const [, value] of tag.matchAll(/\s(?:src|poster)="([^"]*)"/gi)) {
|
|
62
|
+
value && list.push(value);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return [...new Set(list)];
|
|
66
|
+
};
|
|
67
|
+
const isUrl = (value) => /^(https?:|blob:|data:)/i.test(value);
|
|
68
|
+
const replaceSrc = (html, from, to) => html.replaceAll(`"${from}"`, `"${to}"`);
|
|
69
|
+
const keyToUrl = async (html) => {
|
|
70
|
+
if (!html) return "";
|
|
71
|
+
const keyList = getMediaSrcList(html).filter((value) => !isUrl(value));
|
|
72
|
+
if (!keyList.length) return html;
|
|
73
|
+
try {
|
|
74
|
+
const res = await file.preSignedUrlGetApi(keyList);
|
|
75
|
+
const data = res?.data || [];
|
|
76
|
+
data.forEach(({ key, url }) => {
|
|
77
|
+
if (!key || !url) return;
|
|
78
|
+
html = replaceSrc(html, key, url);
|
|
79
|
+
rememberFile({ key, url });
|
|
80
|
+
});
|
|
81
|
+
const failCount = keyList.filter((key) => !data.some((item) => item.key === key && item.url)).length;
|
|
82
|
+
if (failCount) {
|
|
83
|
+
elementPlus.ElMessage.warning(`\u5185\u5BB9\u4E2D\u6709 ${failCount} \u4E2A\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25`);
|
|
84
|
+
}
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.warn("[HyKindEditor] key \u6362 url \u5931\u8D25\uFF0C\u4FDD\u7559\u539F\u5185\u5BB9", e);
|
|
87
|
+
elementPlus.ElMessage.error(e?.msg || e?.message || "\u5185\u5BB9\u4E2D\u7684\u56FE\u7247/\u89C6\u9891\u52A0\u8F7D\u5931\u8D25");
|
|
88
|
+
}
|
|
89
|
+
return html;
|
|
90
|
+
};
|
|
91
|
+
const urlToKey = (html) => {
|
|
92
|
+
if (!html) return "";
|
|
93
|
+
fileURLList.forEach(({ key, url }) => {
|
|
94
|
+
html = replaceSrc(html, url, key);
|
|
95
|
+
});
|
|
96
|
+
return html;
|
|
97
|
+
};
|
|
98
|
+
const FILE_TYPES = {
|
|
99
|
+
image: {
|
|
100
|
+
name: "\u56FE\u7247",
|
|
101
|
+
types: ["image/jpeg", "image/png", "image/gif", "image/bmp", "image/webp"],
|
|
102
|
+
typesText: "jpg\u3001png\u3001gif\u3001bmp\u3001webp",
|
|
103
|
+
getMaxSize: () => props.maxImageSize
|
|
104
|
+
},
|
|
105
|
+
video: {
|
|
106
|
+
name: "\u89C6\u9891",
|
|
107
|
+
types: ["video/*"],
|
|
108
|
+
getMaxSize: () => props.maxVideoSize
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const isAllowedType = (file, types) => types.some((type) => type.endsWith("/*") ? file.type.startsWith(type.slice(0, -1)) : file.type === type);
|
|
112
|
+
const checkFile = (file, fileType) => {
|
|
113
|
+
const { name, types, typesText, getMaxSize } = FILE_TYPES[fileType];
|
|
114
|
+
if (!isAllowedType(file, types)) {
|
|
115
|
+
throw new Error(typesText ? `${name}\u683C\u5F0F\u4E0D\u6B63\u786E\uFF0C\u4EC5\u652F\u6301 ${typesText}` : `\u8BF7\u9009\u62E9${name}\u6587\u4EF6`);
|
|
116
|
+
}
|
|
117
|
+
if (file.size === 0) {
|
|
118
|
+
throw new Error("\u65E0\u6CD5\u53D1\u9001\u7A7A\u6587\u4EF6(0KB)\uFF0C\u8BF7\u9009\u62E9\u5305\u542B\u5185\u5BB9\u7684\u6587\u4EF6");
|
|
119
|
+
}
|
|
120
|
+
const maxSize = getMaxSize();
|
|
121
|
+
if (file.size / 1024 / 1024 > maxSize) {
|
|
122
|
+
throw new Error(`\u4E0A\u4F20\u7684\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236(${maxSize}MB)`);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const uploadFile = async (file$1, fileType) => {
|
|
126
|
+
checkFile(file$1, fileType);
|
|
127
|
+
const fileUploadRes = await file.fileUpload(file$1);
|
|
128
|
+
if (fileUploadRes?.code !== 200) throw fileUploadRes;
|
|
129
|
+
const preSignedUrlGetApiRes = await file.preSignedUrlGetApi([fileUploadRes.data.key]);
|
|
130
|
+
const item = preSignedUrlGetApiRes?.data?.[0];
|
|
131
|
+
if (!item?.url) throw new Error("\u83B7\u53D6\u6587\u4EF6\u5730\u5740\u5931\u8D25");
|
|
132
|
+
rememberFile(item);
|
|
133
|
+
return item.url;
|
|
134
|
+
};
|
|
135
|
+
const createUploader = (fileType) => ({
|
|
136
|
+
allowedFileTypes: FILE_TYPES[fileType].types,
|
|
137
|
+
async customUpload(file, insertFn) {
|
|
138
|
+
try {
|
|
139
|
+
insertFn(await uploadFile(file, fileType));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
elementPlus.ElMessage.error(e?.msg || e?.message || `${FILE_TYPES[fileType].name}\u4E0A\u4F20\u5931\u8D25`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
const DEFAULT_EXCLUDE_KEYS = ["emotion", "insertLink", "insertImage", "insertVideo", "fullScreen"];
|
|
146
|
+
const toolbarOptions = vue.computed(() => {
|
|
147
|
+
const { excludeKeys = [], ...rest } = props.toolbarConfig;
|
|
148
|
+
return {
|
|
149
|
+
...rest,
|
|
150
|
+
excludeKeys: [.../* @__PURE__ */ new Set([...DEFAULT_EXCLUDE_KEYS, ...excludeKeys])]
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
const getPasteImageSrcs = (html) => {
|
|
154
|
+
if (!html || !/<img/i.test(html)) return [];
|
|
155
|
+
const doc = new DOMParser().parseFromString(html, "text/html");
|
|
156
|
+
const srcs = [...doc.querySelectorAll("img")].map((img) => img.getAttribute("src") || "");
|
|
157
|
+
return [...new Set(srcs)].filter(
|
|
158
|
+
(src) => /^(https?:|data:image\/)/i.test(src) && !isKnownUrl(src) && (!props.pasteImageFilter || props.pasteImageFilter(src) !== false)
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
const srcToFile = async (src) => {
|
|
162
|
+
const res = await fetch(src, { mode: "cors", credentials: "omit" }).catch(() => {
|
|
163
|
+
throw new Error("\u6765\u6E90\u7F51\u7AD9\u4E0D\u5141\u8BB8\u4E0B\u8F7D\u8BE5\u56FE\u7247");
|
|
164
|
+
});
|
|
165
|
+
if (!res.ok) throw new Error(`\u4E0B\u8F7D\u5931\u8D25\uFF1A${res.status}`);
|
|
166
|
+
const blob = await res.blob();
|
|
167
|
+
const ext = blob.type.split("/")[1]?.split("+")[0] || "png";
|
|
168
|
+
return new File([blob], `paste-${Date.now()}.${ext}`, { type: blob.type });
|
|
169
|
+
};
|
|
170
|
+
const updateImage = (oldSrc, attrs) => {
|
|
171
|
+
const editor$1 = editorRef.value;
|
|
172
|
+
if (!editor$1 || editor$1.isDestroyed) return;
|
|
173
|
+
editor.SlateTransforms.setNodes(editor$1, attrs, {
|
|
174
|
+
at: [],
|
|
175
|
+
voids: true,
|
|
176
|
+
match: (node) => node.type === "image" && node.src === oldSrc
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
const hasImageInEditor = (src) => !!editorRef.value?.getElemsByType("image").some((node) => node.src === src);
|
|
180
|
+
const transferPasteImages = async (pasteSrcs) => {
|
|
181
|
+
const srcs = pasteSrcs.filter(hasImageInEditor);
|
|
182
|
+
const reasons = [];
|
|
183
|
+
await Promise.all(
|
|
184
|
+
srcs.map(async (src) => {
|
|
185
|
+
try {
|
|
186
|
+
const url = await uploadFile(await srcToFile(src), "image");
|
|
187
|
+
updateImage(src, { src: url });
|
|
188
|
+
} catch (e) {
|
|
189
|
+
reasons.push(e?.msg || e?.message || "\u672A\u77E5\u539F\u56E0");
|
|
190
|
+
updateImage(src, { src: "", alt: "\u56FE\u7247\u52A0\u8F7D\u5931\u8D25" });
|
|
191
|
+
console.warn("[HyKindEditor] \u7C98\u8D34\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF0C\u5DF2\u6E05\u7A7A\u5730\u5740\uFF1A", src, e);
|
|
192
|
+
}
|
|
193
|
+
})
|
|
194
|
+
);
|
|
195
|
+
if (reasons.length) {
|
|
196
|
+
elementPlus.ElMessage.error(`${reasons.length} \u5F20\u7C98\u8D34\u7684\u56FE\u7247\u8F6C\u5B58\u5931\u8D25\uFF08${reasons[0]}\uFF09\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20`);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
const handleCustomPaste = (editor, event, callback) => {
|
|
200
|
+
if (props.editorConfig.customPaste?.(editor, event) === false) {
|
|
201
|
+
callback(false);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
const srcs = getPasteImageSrcs(event.clipboardData?.getData("text/html"));
|
|
205
|
+
srcs.length && setTimeout(() => transferPasteImages(srcs));
|
|
206
|
+
callback(true);
|
|
207
|
+
};
|
|
208
|
+
const DEFAULT_HOVERBAR_KEYS = {
|
|
209
|
+
image: { menuKeys: ["imageWidth30", "imageWidth50", "imageWidth100", "deleteImage"] }
|
|
210
|
+
};
|
|
211
|
+
const editorOptions = vue.computed(() => {
|
|
212
|
+
const { MENU_CONF = {}, customPaste, hoverbarKeys = {}, ...rest } = props.editorConfig;
|
|
213
|
+
return {
|
|
214
|
+
placeholder: props.placeholder,
|
|
215
|
+
readOnly: props.disabled,
|
|
216
|
+
...rest,
|
|
217
|
+
hoverbarKeys: { ...DEFAULT_HOVERBAR_KEYS, ...hoverbarKeys },
|
|
218
|
+
MENU_CONF: {
|
|
219
|
+
uploadImage: createUploader("image"),
|
|
220
|
+
uploadVideo: createUploader("video"),
|
|
221
|
+
...MENU_CONF
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
const handleCreated = (editor) => {
|
|
226
|
+
editorRef.value = editor;
|
|
227
|
+
emits("created", editor);
|
|
228
|
+
};
|
|
229
|
+
vue.watch(
|
|
230
|
+
() => props.disabled,
|
|
231
|
+
(val) => {
|
|
232
|
+
const editor = editorRef.value;
|
|
233
|
+
if (!editor) return;
|
|
234
|
+
val ? editor.disable() : editor.enable();
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
vue.onBeforeUnmount(() => {
|
|
238
|
+
editorRef.value?.destroy();
|
|
239
|
+
editorRef.value = null;
|
|
240
|
+
});
|
|
241
|
+
__expose({
|
|
242
|
+
getEditor: () => editorRef.value,
|
|
243
|
+
getHtml: () => editorRef.value?.getHtml() ?? "",
|
|
244
|
+
getText: () => editorRef.value?.getText() ?? "",
|
|
245
|
+
isEmpty: () => editorRef.value?.isEmpty() ?? true,
|
|
246
|
+
clear: () => editorRef.value?.clear(),
|
|
247
|
+
focus: () => editorRef.value?.focus(),
|
|
248
|
+
insertHtml: (html) => editorRef.value?.dangerouslyInsertHtml(html),
|
|
249
|
+
// 回显:把内容中图片 / 视频的 key 换成 url,返回新内容
|
|
250
|
+
keyToUrl,
|
|
251
|
+
// 保存:把内容中图片 / 视频的 url 换回 key,返回新内容
|
|
252
|
+
urlToKey
|
|
253
|
+
});
|
|
254
|
+
return (_ctx, _cache) => {
|
|
255
|
+
return vue.openBlock(), vue.createElementBlock(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
class: vue.normalizeClass(["hy-kind-editor z-[10000]", { "is-disabled": __props.disabled }])
|
|
259
|
+
},
|
|
260
|
+
[
|
|
261
|
+
__props.showToolbar ? (vue.openBlock(), vue.createBlock(vue.unref(editorForVue.Toolbar), {
|
|
262
|
+
key: 0,
|
|
263
|
+
class: "hy-kind-editor__toolbar",
|
|
264
|
+
editor: editorRef.value,
|
|
265
|
+
"default-config": toolbarOptions.value,
|
|
266
|
+
mode: __props.mode
|
|
267
|
+
}, null, 8, ["editor", "default-config", "mode"])) : vue.createCommentVNode("v-if", true),
|
|
268
|
+
vue.createVNode(vue.unref(editorForVue.Editor), {
|
|
269
|
+
modelValue: modelValue.value,
|
|
270
|
+
"onUpdate:modelValue": ($event) => modelValue.value = $event,
|
|
271
|
+
class: "hy-kind-editor__content",
|
|
272
|
+
style: vue.normalizeStyle({ height: editorHeight.value }),
|
|
273
|
+
"default-config": editorOptions.value,
|
|
274
|
+
mode: __props.mode,
|
|
275
|
+
onOnCreated: handleCreated,
|
|
276
|
+
onCustomPaste: handleCustomPaste,
|
|
277
|
+
onOnChange: (editor) => emits("change", editor),
|
|
278
|
+
onOnFocus: (editor) => emits("focus", editor),
|
|
279
|
+
onOnBlur: (editor) => emits("blur", editor)
|
|
280
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "style", "default-config", "mode", "onOnChange", "onOnFocus", "onOnBlur"])
|
|
281
|
+
],
|
|
282
|
+
2
|
|
283
|
+
/* CLASS */
|
|
284
|
+
);
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
exports.default = _sfc_main;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.hy-kind-editor {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border: 1px solid var(--el-border-color);
|
|
4
|
+
border-radius: var(--el-border-radius-base);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
|
|
7
|
+
&__toolbar {
|
|
8
|
+
border-bottom: 1px solid var(--el-border-color);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
&__content {
|
|
12
|
+
overflow-y: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&.is-disabled {
|
|
16
|
+
background-color: var(--el-disabled-bg-color);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -21,13 +21,13 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
|
|
|
21
21
|
initSelectSvgName: {
|
|
22
22
|
type: String,
|
|
23
23
|
default: () => {
|
|
24
|
-
return "dispatch-share1-user-
|
|
24
|
+
return "dispatch-share1-user-off";
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
initSvgName: {
|
|
28
28
|
type: String,
|
|
29
29
|
default: () => {
|
|
30
|
-
return "dispatch-share1-user-
|
|
30
|
+
return "dispatch-share1-user-high";
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
device: {
|
package/lib/components/index.js
CHANGED
|
@@ -1,38 +1,39 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index$
|
|
3
|
+
var index$o = require('./hyOrgCascader/index.js');
|
|
4
4
|
var index$b = require('./hyConfirmDialog/index.js');
|
|
5
5
|
var index = require('./hyDatePicker/index.js');
|
|
6
6
|
var index$f = require('./hyForm/index.js');
|
|
7
7
|
var index$g = require('./hyIcon/index.js');
|
|
8
8
|
var index$h = require('./hyIconBox/index.js');
|
|
9
|
-
var index$
|
|
10
|
-
var index$
|
|
9
|
+
var index$q = require('./hySearch/index.js');
|
|
10
|
+
var index$s = require('./hyTable/index.js');
|
|
11
11
|
var index$4 = require('./hyTooltip/index.js');
|
|
12
12
|
var index$a = require('./hyConfigProvider/index.js');
|
|
13
13
|
var index$8 = require('./hyButton/index.js');
|
|
14
|
-
var index$
|
|
15
|
-
var index$
|
|
16
|
-
var index$
|
|
14
|
+
var index$w = require('./hyUserAvatar/index.js');
|
|
15
|
+
var index$m = require('./hyNoPermissions/index.js');
|
|
16
|
+
var index$n = require('./hyNoPermissionsMap/index.js');
|
|
17
17
|
var index$c = require('./hyCutter/index.js');
|
|
18
18
|
var index$d = require('./hyDialog/index.js');
|
|
19
|
-
var index$
|
|
20
|
-
var index$
|
|
21
|
-
var index$
|
|
19
|
+
var index$l = require('./hyMenu/index.js');
|
|
20
|
+
var index$v = require('./hyTree/index.js');
|
|
21
|
+
var index$x = require('./hyVideoPlayer/index.js');
|
|
22
22
|
var index$5 = require('./hyAudioPlayer/index.js');
|
|
23
23
|
var index$1 = require('./hyInput/index.js');
|
|
24
24
|
var index$3 = require('./hyTimePicker/index.js');
|
|
25
25
|
var index$6 = require('./hyTableForm/index.js');
|
|
26
|
-
var index$
|
|
26
|
+
var index$t = require('./hyTableActionButton/index.js');
|
|
27
27
|
var index$7 = require('./hyBatchUploadDialog/index.js');
|
|
28
|
-
var index$
|
|
29
|
-
var index$
|
|
28
|
+
var index$k = require('./hyMap/index.js');
|
|
29
|
+
var index$p = require('./hyRadioGroup/index.js');
|
|
30
30
|
var index$2 = require('./hyLoading/index.js');
|
|
31
|
-
var index$
|
|
31
|
+
var index$u = require('./hyTour/index.js');
|
|
32
32
|
var index$e = require('./hyDrawer/index.js');
|
|
33
|
-
var index$
|
|
33
|
+
var index$r = require('./hyStatus/index.js');
|
|
34
34
|
var index$9 = require('./hyCheckboxGroup/index.js');
|
|
35
|
-
var index$
|
|
35
|
+
var index$j = require('./hyLocationMap/index.js');
|
|
36
|
+
var index$i = require('./hyKindEditor/index.js');
|
|
36
37
|
var useAppForm = require('./hyForm/js/useAppForm.js');
|
|
37
38
|
var useAppSearch = require('./hySearch/js/useAppSearch.js');
|
|
38
39
|
var useAppTable = require('./hyTable/js/useAppTable.js');
|
|
@@ -40,27 +41,27 @@ var useAppTableForm = require('./hyTableForm/js/useAppTableForm.js');
|
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
|
|
43
|
-
exports.HyOrgCascader = index$
|
|
44
|
+
exports.HyOrgCascader = index$o.HyOrgCascader;
|
|
44
45
|
exports.HyConfirmDialog = index$b.HyConfirmDialog;
|
|
45
46
|
exports.ElDatePicker = index.ElDatePicker;
|
|
46
47
|
exports.HyDatePicker = index.HyDatePicker;
|
|
47
48
|
exports.HyForm = index$f.HyForm;
|
|
48
49
|
exports.HyIcon = index$g.HyIcon;
|
|
49
50
|
exports.HyIconBox = index$h.HyIconBox;
|
|
50
|
-
exports.HySearch = index$
|
|
51
|
-
exports.HyTable = index$
|
|
51
|
+
exports.HySearch = index$q.HySearch;
|
|
52
|
+
exports.HyTable = index$s.HyTable;
|
|
52
53
|
exports.ElTooltip = index$4.ElTooltip;
|
|
53
54
|
exports.HyTooltip = index$4.HyTooltip;
|
|
54
55
|
exports.HyConfigProvider = index$a.HyConfigProvider;
|
|
55
56
|
exports.HyButton = index$8.HyButton;
|
|
56
|
-
exports.HyUserAvatar = index$
|
|
57
|
-
exports.HyNoPermissions = index$
|
|
58
|
-
exports.HyNoPermissionsMap = index$
|
|
57
|
+
exports.HyUserAvatar = index$w.HyUserAvatar;
|
|
58
|
+
exports.HyNoPermissions = index$m.HyNoPermissions;
|
|
59
|
+
exports.HyNoPermissionsMap = index$n.HyNoPermissionsMap;
|
|
59
60
|
exports.HyCutter = index$c.HyCutter;
|
|
60
61
|
exports.HyDialog = index$d.HyDialog;
|
|
61
|
-
exports.HyMenu = index$
|
|
62
|
-
exports.HyTree = index$
|
|
63
|
-
exports.HyVideoPlayer = index$
|
|
62
|
+
exports.HyMenu = index$l.HyMenu;
|
|
63
|
+
exports.HyTree = index$v.HyTree;
|
|
64
|
+
exports.HyVideoPlayer = index$x.HyVideoPlayer;
|
|
64
65
|
exports.HyAudioPlayer = index$5.HyAudioPlayer;
|
|
65
66
|
exports.ElInput = index$1.ElInput;
|
|
66
67
|
exports.HyInput = index$1.HyInput;
|
|
@@ -69,17 +70,18 @@ exports.ElTimePicker = index$3.ElTimePicker;
|
|
|
69
70
|
exports.HyTimePicker = index$3.HyTimePicker;
|
|
70
71
|
exports.HyBatchTableForm = index$6.HyBatchTableForm;
|
|
71
72
|
exports.HyTableForm = index$6.HyTableForm;
|
|
72
|
-
exports.HyTableActionButton = index$
|
|
73
|
+
exports.HyTableActionButton = index$t.HyTableActionButton;
|
|
73
74
|
exports.HyBatchUploadDialog = index$7.HyBatchUploadDialog;
|
|
74
|
-
exports.HyMap = index$
|
|
75
|
-
exports.HyRadioGroup = index$
|
|
75
|
+
exports.HyMap = index$k.HyMap;
|
|
76
|
+
exports.HyRadioGroup = index$p.HyRadioGroup;
|
|
76
77
|
exports.ElLoading = index$2.ElLoading;
|
|
77
78
|
exports.HyLoading = index$2.ElLoading;
|
|
78
|
-
exports.HyTour = index$
|
|
79
|
+
exports.HyTour = index$u.HyTour;
|
|
79
80
|
exports.HyDrawer = index$e.HyDrawer;
|
|
80
|
-
exports.HyStatus = index$
|
|
81
|
+
exports.HyStatus = index$r.HyStatus;
|
|
81
82
|
exports.HyCheckboxGroup = index$9.HyCheckboxGroup;
|
|
82
|
-
exports.HyLocationMap = index$
|
|
83
|
+
exports.HyLocationMap = index$j.HyLocationMap;
|
|
84
|
+
exports.HyKindEditor = index$i.HyKindEditor;
|
|
83
85
|
exports.resetAppFormValue = useAppForm.resetAppFormValue;
|
|
84
86
|
exports.useAppForm = useAppForm.useAppForm;
|
|
85
87
|
exports.resetAppSearchValue = useAppSearch.resetAppSearchValue;
|
package/lib/index.js
CHANGED
|
@@ -32,27 +32,28 @@ var index$k = require('./bussiness/hyFilePlayback/index.js');
|
|
|
32
32
|
var index$l = require('./components/hyForm/index.js');
|
|
33
33
|
var index$m = require('./components/hyIcon/index.js');
|
|
34
34
|
var index$n = require('./components/hyIconBox/index.js');
|
|
35
|
-
var index$o = require('./components/
|
|
36
|
-
var index$p = require('./components/
|
|
37
|
-
var index$q = require('./
|
|
38
|
-
var index$r = require('./
|
|
39
|
-
var index$s = require('./components/
|
|
40
|
-
var index$t = require('./components/
|
|
41
|
-
var index$u = require('./components/
|
|
42
|
-
var index$v = require('./
|
|
43
|
-
var index$w = require('./bussiness/
|
|
44
|
-
var index$x = require('./
|
|
45
|
-
var index$y = require('./
|
|
46
|
-
var index$z = require('./
|
|
47
|
-
var index$A = require('./components/
|
|
48
|
-
var index$B = require('./components/
|
|
49
|
-
var index$C = require('./components/
|
|
50
|
-
var index$D = require('./components/
|
|
51
|
-
var index$E = require('./components/
|
|
52
|
-
var index$F = require('./components/
|
|
53
|
-
var index$G = require('./
|
|
54
|
-
var index$H = require('./
|
|
55
|
-
var index$I = require('./
|
|
35
|
+
var index$o = require('./components/hyKindEditor/index.js');
|
|
36
|
+
var index$p = require('./components/hyLocationMap/index.js');
|
|
37
|
+
var index$q = require('./components/hyMap/index.js');
|
|
38
|
+
var index$r = require('./bussiness/hyMapAearchPlace/index.js');
|
|
39
|
+
var index$s = require('./components/hyMenu/index.js');
|
|
40
|
+
var index$t = require('./components/hyNoPermissions/index.js');
|
|
41
|
+
var index$u = require('./components/hyNoPermissionsMap/index.js');
|
|
42
|
+
var index$v = require('./components/hyOrgCascader/index.js');
|
|
43
|
+
var index$w = require('./bussiness/hyOrgGroupTree/index.js');
|
|
44
|
+
var index$x = require('./bussiness/hyPlanGroupDeviceTree/index.js');
|
|
45
|
+
var index$y = require('./components/hyRadioGroup/index.js');
|
|
46
|
+
var index$z = require('./bussiness/hyRuleSetting/index.js');
|
|
47
|
+
var index$A = require('./components/hySearch/index.js');
|
|
48
|
+
var index$B = require('./components/hyStatus/index.js');
|
|
49
|
+
var index$C = require('./components/hyTable/index.js');
|
|
50
|
+
var index$D = require('./components/hyTableActionButton/index.js');
|
|
51
|
+
var index$E = require('./components/hyTour/index.js');
|
|
52
|
+
var index$F = require('./components/hyTree/index.js');
|
|
53
|
+
var index$G = require('./components/hyUserAvatar/index.js');
|
|
54
|
+
var index$H = require('./bussiness/hyUserTree/index.js');
|
|
55
|
+
var index$I = require('./components/hyVideoPlayer/index.js');
|
|
56
|
+
var index$J = require('./utils/map/index.js');
|
|
56
57
|
var permission = require('./utils/permission.js');
|
|
57
58
|
var crypto = require('./utils/crypto.js');
|
|
58
59
|
var file = require('./utils/file.js');
|
|
@@ -139,33 +140,34 @@ exports.HyFilePlayback = index$k.HyFilePlayback;
|
|
|
139
140
|
exports.HyForm = index$l.HyForm;
|
|
140
141
|
exports.HyIcon = index$m.HyIcon;
|
|
141
142
|
exports.HyIconBox = index$n.HyIconBox;
|
|
142
|
-
exports.
|
|
143
|
-
exports.
|
|
144
|
-
exports.
|
|
145
|
-
exports.
|
|
146
|
-
exports.
|
|
147
|
-
exports.
|
|
148
|
-
exports.
|
|
149
|
-
exports.
|
|
150
|
-
exports.
|
|
151
|
-
exports.
|
|
152
|
-
exports.
|
|
153
|
-
exports.
|
|
154
|
-
exports.
|
|
155
|
-
exports.
|
|
156
|
-
exports.
|
|
157
|
-
exports.
|
|
158
|
-
exports.
|
|
159
|
-
exports.
|
|
160
|
-
exports.
|
|
161
|
-
exports.
|
|
162
|
-
exports.
|
|
163
|
-
exports.
|
|
164
|
-
exports.
|
|
165
|
-
exports.
|
|
166
|
-
exports.
|
|
167
|
-
exports.
|
|
168
|
-
exports.
|
|
143
|
+
exports.HyKindEditor = index$o.HyKindEditor;
|
|
144
|
+
exports.HyLocationMap = index$p.HyLocationMap;
|
|
145
|
+
exports.HyMap = index$q.HyMap;
|
|
146
|
+
exports.HyMapAearchPlace = index$r.HyMapAearchPlace;
|
|
147
|
+
exports.HyMenu = index$s.HyMenu;
|
|
148
|
+
exports.HyNoPermissions = index$t.HyNoPermissions;
|
|
149
|
+
exports.HyNoPermissionsMap = index$u.HyNoPermissionsMap;
|
|
150
|
+
exports.HyOrgCascader = index$v.HyOrgCascader;
|
|
151
|
+
exports.HyOrgGroupTree = index$w.HyOrgGroupTree;
|
|
152
|
+
exports.HyPlanGroupDeviceTree = index$x.HyPlanGroupDeviceTree;
|
|
153
|
+
exports.HyRadioGroup = index$y.HyRadioGroup;
|
|
154
|
+
exports.HyRuleAssignDialog = index$z.HyRuleAssignDialog;
|
|
155
|
+
exports.HyRuleFenceDialog = index$z.HyRuleFenceDialog;
|
|
156
|
+
exports.HyRuleSetting = index$z.HyRuleSetting;
|
|
157
|
+
exports.HyRuleSettingDialog = index$z.HyRuleSettingDialog;
|
|
158
|
+
exports.HySetRuleAggregationAlarmDialog = index$z.HySetRuleAggregationAlarmDialog;
|
|
159
|
+
exports.HySearch = index$A.HySearch;
|
|
160
|
+
exports.HyStatus = index$B.HyStatus;
|
|
161
|
+
exports.HyTable = index$C.HyTable;
|
|
162
|
+
exports.HyTableActionButton = index$D.HyTableActionButton;
|
|
163
|
+
exports.HyTour = index$E.HyTour;
|
|
164
|
+
exports.HyTree = index$F.HyTree;
|
|
165
|
+
exports.HyUserAvatar = index$G.HyUserAvatar;
|
|
166
|
+
exports.HyUserTree = index$H.HyUserTree;
|
|
167
|
+
exports.HyVideoPlayer = index$I.HyVideoPlayer;
|
|
168
|
+
exports.InitMap = index$J.InitMap;
|
|
169
|
+
exports.setMapServer = index$J.setMapServer;
|
|
170
|
+
exports.setPoiServer = index$J.setPoiServer;
|
|
169
171
|
exports.PERMISSION = permission.PERMISSION;
|
|
170
172
|
exports.base64Decrypt = crypto.base64Decrypt;
|
|
171
173
|
exports.encryptToBase64 = crypto.encryptToBase64;
|
|
@@ -174,6 +176,7 @@ exports.blobToDataURL = file.blobToDataURL;
|
|
|
174
176
|
exports.fileFormUpload = file.fileFormUpload;
|
|
175
177
|
exports.fileJsonUplaod = file.fileJsonUplaod;
|
|
176
178
|
exports.fileUpload = file.fileUpload;
|
|
179
|
+
exports.preSignedUrlGetApi = file.preSignedUrlGetApi;
|
|
177
180
|
exports.presignedUrl = file.presignedUrl;
|
|
178
181
|
exports.sizeToTextHandler = file.sizeToTextHandler;
|
|
179
182
|
exports.bus = useSubscribe.bus;
|
package/lib/utils/file.js
CHANGED
|
@@ -35,6 +35,12 @@ async function fileJsonUplaod(file) {
|
|
|
35
35
|
});
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
38
|
+
async function preSignedUrlGetApi(keyList) {
|
|
39
|
+
const { api } = useApi.useApi();
|
|
40
|
+
return await vue.unref(api).post("file/preSignedUrlGet", { keyList }, {
|
|
41
|
+
isJSON: true
|
|
42
|
+
});
|
|
43
|
+
}
|
|
38
44
|
async function fileFormUpload(file) {
|
|
39
45
|
const { api } = useApi.useApi();
|
|
40
46
|
try {
|
|
@@ -72,5 +78,6 @@ exports.blobToDataURL = blobToDataURL;
|
|
|
72
78
|
exports.fileFormUpload = fileFormUpload;
|
|
73
79
|
exports.fileJsonUplaod = fileJsonUplaod;
|
|
74
80
|
exports.fileUpload = fileUpload;
|
|
81
|
+
exports.preSignedUrlGetApi = preSignedUrlGetApi;
|
|
75
82
|
exports.presignedUrl = presignedUrl;
|
|
76
83
|
exports.sizeToTextHandler = sizeToTextHandler;
|
package/lib/utils/index.js
CHANGED
|
@@ -51,6 +51,7 @@ exports.blobToDataURL = file.blobToDataURL;
|
|
|
51
51
|
exports.fileFormUpload = file.fileFormUpload;
|
|
52
52
|
exports.fileJsonUplaod = file.fileJsonUplaod;
|
|
53
53
|
exports.fileUpload = file.fileUpload;
|
|
54
|
+
exports.preSignedUrlGetApi = file.preSignedUrlGetApi;
|
|
54
55
|
exports.presignedUrl = file.presignedUrl;
|
|
55
56
|
exports.sizeToTextHandler = file.sizeToTextHandler;
|
|
56
57
|
exports.clearSpace = form.clearSpace;
|
package/lib/utils/permission.js
CHANGED
|
@@ -496,7 +496,11 @@ const PERMISSION = {
|
|
|
496
496
|
// 工单系统
|
|
497
497
|
headerNavigation_policeticketSyncShangrao: "headerNavigation_policeticketSyncShangrao",
|
|
498
498
|
// 采集站管理 - 非全链路模式 - 同步数据
|
|
499
|
-
operator_acquisitionStation_nonFullChainMode_manualDataSynchronization: "operator_acquisitionStation_nonFullChainMode_manualDataSynchronization"
|
|
499
|
+
operator_acquisitionStation_nonFullChainMode_manualDataSynchronization: "operator_acquisitionStation_nonFullChainMode_manualDataSynchronization",
|
|
500
|
+
// 设置中心 - 采集站授权
|
|
501
|
+
setting_modifyCsAuth: "setting_modifyCsAuth",
|
|
502
|
+
// 设置中心 - 采集站授权 - 上传文件
|
|
503
|
+
setting_modifyCsAuth_uploadAuthorizationFile: "setting_modifyCsAuth_uploadAuthorizationFile"
|
|
500
504
|
};
|
|
501
505
|
|
|
502
506
|
exports.PERMISSION = PERMISSION;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hy-dispatch-ui-v3",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.83",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "es/index.mjs",
|
|
6
6
|
"scripts": {
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@element-plus/icons-vue": "^2.3.2",
|
|
21
|
+
"@wangeditor/editor": "^5.1.23",
|
|
22
|
+
"@wangeditor/editor-for-vue": "^5.1.12",
|
|
21
23
|
"async-validator": "^4.2.5",
|
|
22
24
|
"body-parser": "^2.3.0",
|
|
23
25
|
"crypto-js": "^4.2.0",
|