@ebiz/designer-components 0.1.124 → 0.1.126
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 +29 -29
- package/dist/designer-components.css +1 -1
- package/dist/index.mjs +35548 -33511
- package/dist/{pdf-C9oIcL2N.js → pdf-KomaE0u5.js} +891 -891
- package/package.json +1 -1
- package/src/App.vue +26 -26
- package/src/apiService/SIMPLE_DATA_SERVICE.md +284 -284
- package/src/apiService/mockDataService.js +115 -115
- package/src/apiService/simpleDataService.js +312 -312
- package/src/assets/base.css +86 -86
- package/src/assets/logo.svg +1 -1
- package/src/components/Button.vue +149 -149
- package/src/components/DataContainer.vue +40 -40
- package/src/components/EbizApproval.vue +366 -366
- package/src/components/EbizApprovalDetail.vue +169 -169
- package/src/components/EbizApprovalForm.vue +534 -534
- package/src/components/EbizApprovalV2.vue +713 -713
- package/src/components/EbizAutoForm.vue +596 -596
- package/src/components/EbizAvatar.vue +115 -115
- package/src/components/EbizCheckbox.vue +93 -93
- package/src/components/EbizCheckboxGroup.vue +69 -69
- package/src/components/EbizDepartmentSelector.vue +148 -148
- package/src/components/EbizDescriptions.vue +340 -340
- package/src/components/EbizDescriptionsItem.vue +47 -47
- package/src/components/EbizDetailBlock.vue +81 -81
- package/src/components/EbizDetailItem.vue +559 -559
- package/src/components/EbizDetailView.md +438 -438
- package/src/components/EbizDetailView.vue +355 -355
- package/src/components/EbizDialog.vue +260 -260
- package/src/components/EbizDictionarySelect.vue +229 -229
- package/src/components/EbizDiv.vue +40 -40
- package/src/components/EbizDivider.vue +96 -96
- package/src/components/EbizDormDashboard.vue +314 -314
- package/src/components/EbizDropdown.vue +135 -135
- package/src/components/EbizDropdownItem.vue +85 -85
- package/src/components/EbizEmployeeInfo.vue +144 -144
- package/src/components/EbizEmployeeSelector.vue +1160 -1160
- package/src/components/EbizFileList.vue +502 -502
- package/src/components/EbizMap.vue +541 -541
- package/src/components/EbizMeetingRoomSelector.vue +1149 -1149
- package/src/components/EbizMobileMeetingRoomSelector.vue +727 -727
- package/src/components/EbizOkrTree.vue +99 -99
- package/src/components/EbizPageHeader.vue +98 -98
- package/src/components/EbizPagination.vue +162 -162
- package/src/components/EbizParkingDashboard.vue +152 -152
- package/src/components/EbizPdfViewer.vue +540 -540
- package/src/components/EbizPopconfirm.vue +47 -47
- package/src/components/EbizQrCode.vue +167 -167
- package/src/components/EbizRadio.vue +86 -86
- package/src/components/EbizRadioGroup.vue +83 -83
- package/src/components/EbizRemoteSelect.vue +232 -232
- package/src/components/EbizRichTextEditor.vue +338 -338
- package/src/components/EbizRouteBreadcrumb.vue +46 -46
- package/src/components/EbizSApprovalProcess.vue +1456 -1426
- package/src/components/EbizSelect.vue +85 -85
- package/src/components/EbizSpace.vue +100 -100
- package/src/components/EbizStatistic.vue +149 -149
- package/src/components/EbizStatsCard.vue +113 -113
- package/src/components/EbizSwiper.vue +113 -113
- package/src/components/EbizSwiperItem.vue +13 -13
- package/src/components/EbizSwitch.vue +85 -85
- package/src/components/EbizTabHeader.vue +132 -132
- package/src/components/EbizTabPanel.vue +22 -22
- package/src/components/EbizTable.vue +469 -469
- package/src/components/EbizTableColumn.vue +116 -116
- package/src/components/EbizTableSort.vue +179 -179
- package/src/components/EbizTabs.vue +142 -142
- package/src/components/EbizTdesignButtonDialog.vue +332 -332
- package/src/components/EbizTdesignLoading.vue +107 -107
- package/src/components/EbizTimePicker.vue +143 -143
- package/src/components/EbizTitle.vue +91 -91
- package/src/components/EbizTree.vue +141 -141
- package/src/components/EbizTreeMergeTable.vue +1494 -1494
- package/src/components/EbizTreeSelector.vue +469 -469
- package/src/components/EbizVideo.vue +553 -553
- package/src/components/EbizVxeTable.vue +290 -290
- package/src/components/Form.vue +28 -28
- package/src/components/Home.vue +7 -7
- package/src/components/LaunchInterview.vue +526 -526
- package/src/components/MyComponent.vue +39 -39
- package/src/components/Table.vue +45 -45
- package/src/components/TdesignAlert.vue +115 -115
- package/src/components/TdesignButton.vue +135 -135
- package/src/components/TdesignCalendar/index.vue +145 -145
- package/src/components/TdesignCard.vue +195 -195
- package/src/components/TdesignCol.vue +101 -101
- package/src/components/TdesignCollapse.vue +142 -142
- package/src/components/TdesignCollapsePanel.vue +79 -79
- package/src/components/TdesignDatePicker.vue +124 -124
- package/src/components/TdesignDescriptions.vue +74 -74
- package/src/components/TdesignDescriptionsItem.vue +50 -50
- package/src/components/TdesignDialog.vue +225 -225
- package/src/components/TdesignForm.vue +138 -138
- package/src/components/TdesignFormItem.vue +105 -105
- package/src/components/TdesignGrid.vue +55 -55
- package/src/components/TdesignIcon.vue +67 -67
- package/src/components/TdesignImage.vue +162 -162
- package/src/components/TdesignImageViewer.vue +200 -200
- package/src/components/TdesignInput.vue +242 -242
- package/src/components/TdesignSelect.vue +446 -446
- package/src/components/TdesignTag.vue +117 -117
- package/src/components/TdesignTextarea.vue +142 -142
- package/src/components/TdesignTimeline.vue +58 -58
- package/src/components/TdesignTimelineItem.vue +71 -71
- package/src/components/TdesignUpload.vue +414 -414
- package/src/components/TdesignWatermark.vue +107 -107
- package/src/components/ebiz-form/components/cascader.vue +61 -61
- package/src/components/ebiz-form/components/checkbox.vue +37 -37
- package/src/components/ebiz-form/components/city.vue +137 -137
- package/src/components/ebiz-form/components/date-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range-panel.vue +52 -52
- package/src/components/ebiz-form/components/date-range.vue +56 -56
- package/src/components/ebiz-form/components/date.vue +52 -52
- package/src/components/ebiz-form/components/editor-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/editor.vue +78 -78
- package/src/components/ebiz-form/components/file-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/file.vue +149 -149
- package/src/components/ebiz-form/components/images-multi-language.vue +52 -52
- package/src/components/ebiz-form/components/images.vue +129 -129
- package/src/components/ebiz-form/components/img-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/img.vue +129 -129
- package/src/components/ebiz-form/components/number.vue +50 -50
- package/src/components/ebiz-form/components/radio.vue +28 -28
- package/src/components/ebiz-form/components/select.vue +119 -119
- package/src/components/ebiz-form/components/switch.vue +23 -23
- package/src/components/ebiz-form/components/text-multi-language.vue +47 -47
- package/src/components/ebiz-form/components/text.vue +52 -52
- package/src/components/ebiz-form/components/textarea-multi-language.vue +48 -48
- package/src/components/ebiz-form/components/textarea.vue +29 -29
- package/src/components/ebiz-form/components/video-multi-language.vue +51 -51
- package/src/components/ebiz-form/components/video.vue +97 -97
- package/src/components/ebiz-form/index.vue +157 -157
- package/src/components/examples/PopconfirmExample.vue +149 -149
- package/src/components/icons/IconCommunity.vue +7 -7
- package/src/components/icons/IconDocumentation.vue +7 -7
- package/src/components/icons/IconEcosystem.vue +7 -7
- package/src/components/icons/IconSupport.vue +7 -7
- package/src/components/icons/IconTooling.vue +19 -19
- package/src/components/mItems/UserInfo.vue +349 -349
- package/src/components/senior/EbizApprovalList/ApprovalList.vue +127 -127
- package/src/components/senior/EbizSData/index.vue +280 -280
- package/src/components/senior/EbizSDialog/index.vue +776 -776
- package/src/components/senior/EbizSForm/README.md +157 -157
- package/src/components/senior/EbizSForm/index.vue +667 -667
- package/src/components/senior/EbizSForm/item.vue +1011 -1011
- package/src/components/senior/EbizSForm/mItems/DateTimePicker.vue +51 -51
- package/src/components/senior/EbizSForm/mItems/Picker.vue +63 -63
- package/src/index.js +327 -327
- package/src/main.js +55 -55
- package/src/router/index.js +436 -436
- package/src/utils/formatCode.js +24 -24
- package/src/utils/generateImportStatement.js +52 -52
- package/src/utils/hasJsx.js +25 -25
- package/src/utils/index.js +166 -166
- package/src/utils/mergeOptions.js +29 -29
- package/src/utils/parseRequiredBlocks.js +18 -18
- package/src/utils/vue-sfc-validator.js +155 -155
- package/src/views/Button.vue +23 -23
- package/src/views/CheckboxDemo.vue +104 -104
- package/src/views/DataContainer.vue +19 -19
- package/src/views/DialogDemo.vue +125 -125
- package/src/views/EbizApprovalDemo.vue +87 -87
- package/src/views/EbizApprovalFormDemo.vue +207 -207
- package/src/views/EbizAutoFormDemo.vue +129 -129
- package/src/views/EbizAvatar.vue +223 -223
- package/src/views/EbizDepartmentSelectorDemo.vue +169 -169
- package/src/views/EbizDetailBlockDemo.vue +30 -30
- package/src/views/EbizDetailViewDemo.vue +412 -412
- package/src/views/EbizDormDashboardDemo.vue +87 -87
- package/src/views/EbizEmployeeInfo.vue +249 -249
- package/src/views/EbizEmployeeSelector.vue +85 -85
- package/src/views/EbizFileListDemo.vue +339 -339
- package/src/views/EbizMap.vue +201 -201
- package/src/views/EbizMeetingRoomSelectorDemo.vue +293 -293
- package/src/views/EbizMobileMeetingRoomSelectorDemo.vue +566 -566
- package/src/views/EbizParkingDashboardDemo.vue +28 -28
- package/src/views/EbizRadioDemo.vue +151 -151
- package/src/views/EbizSDataDemo.vue +136 -136
- package/src/views/EbizSDialogDemo.vue +303 -303
- package/src/views/EbizSForm/index.vue +352 -352
- package/src/views/EbizSFormDemo.vue +420 -420
- package/src/views/EbizSpace.vue +185 -185
- package/src/views/EbizSwiper.vue +157 -157
- package/src/views/EbizTdesignButtonDialogExample.vue +437 -437
- package/src/views/Form.vue +19 -19
- package/src/views/GridDemo.vue +238 -238
- package/src/views/Home.vue +156 -156
- package/src/views/LaunchInterviewDemo.vue +111 -111
- package/src/views/Mindmap.vue +17 -17
- package/src/views/MyComponent.vue +19 -19
- package/src/views/OkrTree.vue +19 -19
- package/src/views/PageHeaderDemo.vue +104 -104
- package/src/views/PaginationDemo.vue +96 -96
- package/src/views/PdfViewerDemo.vue +433 -433
- package/src/views/PermissionBoxDemo.vue +85 -85
- package/src/views/PopconfirmDemo.vue +80 -80
- package/src/views/RemoteSelect.vue +350 -350
- package/src/views/StatisticDemo.vue +190 -190
- package/src/views/SwitchDemo.vue +79 -79
- package/src/views/Table.vue +19 -19
- package/src/views/TableDemo.vue +334 -334
- package/src/views/TableSortDemo.vue +143 -143
- package/src/views/TableView.vue +68 -68
- package/src/views/TabsDemo.vue +282 -282
- package/src/views/TagDemo.vue +101 -101
- package/src/views/TdesignAlert.vue +98 -98
- package/src/views/TdesignButton.vue +190 -190
- package/src/views/TdesignCalendar.vue +94 -94
- package/src/views/TdesignCard.vue +296 -296
- package/src/views/TdesignCollapse.vue +293 -293
- package/src/views/TdesignDatePicker.vue +187 -187
- package/src/views/TdesignDescriptions.vue +101 -101
- package/src/views/TdesignForm.vue +248 -248
- package/src/views/TdesignIcon.vue +203 -203
- package/src/views/TdesignImage.vue +215 -215
- package/src/views/TdesignImageViewer.vue +198 -198
- package/src/views/TdesignInput.vue +252 -252
- package/src/views/TdesignSelect.vue +473 -473
- package/src/views/TdesignSwiper.vue +157 -157
- package/src/views/TextareaDemo.vue +93 -93
- package/src/views/TimePickerDemo.vue +146 -146
- package/src/views/TimelineDemo.vue +160 -160
- package/src/views/Title.vue +19 -19
- package/src/views/TreeDemo.vue +254 -254
- package/src/views/TreeMergeTableDemo.vue +239 -239
- package/src/views/TreeSelectorDemo.vue +245 -245
- package/src/views/UploadDemo.vue +128 -128
- package/src/views/VideoDemo.vue +245 -245
- package/src/views/VxeTableDemo.vue +279 -279
- package/src/views/WatermarkDemo.vue +85 -85
|
@@ -1,339 +1,339 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="ebiz-rich-text-editor" style="border: 1px solid #ccc">
|
|
3
|
-
<Toolbar
|
|
4
|
-
style="border-bottom: 1px solid #ccc"
|
|
5
|
-
:editor="editorRef"
|
|
6
|
-
:defaultConfig="mergedToolbarConfig"
|
|
7
|
-
:mode="mode"
|
|
8
|
-
/>
|
|
9
|
-
<Editor
|
|
10
|
-
:style="{height: `${height}px`, overflowY: 'hidden'}"
|
|
11
|
-
v-model="computedModelValue"
|
|
12
|
-
:defaultConfig="mergedEditorConfig"
|
|
13
|
-
:mode="mode"
|
|
14
|
-
@onCreated="handleCreated"
|
|
15
|
-
@onChange="handleChange"
|
|
16
|
-
@onDestroyed="handleDestroyed"
|
|
17
|
-
@onFocus="handleFocus"
|
|
18
|
-
@onBlur="handleBlur"
|
|
19
|
-
@customAlert="handleCustomAlert"
|
|
20
|
-
@customPaste="handleCustomPaste"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
|
-
<script>
|
|
26
|
-
/**
|
|
27
|
-
* @displayName 富文本编辑器
|
|
28
|
-
* @description 基于WangEditor的富文本编辑器组件,支持图片和视频上传
|
|
29
|
-
* @category 表单组件
|
|
30
|
-
* @name EbizRichTextEditor
|
|
31
|
-
*/
|
|
32
|
-
export default {
|
|
33
|
-
name: "EbizRichTextEditor"
|
|
34
|
-
}
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<script setup>
|
|
38
|
-
import '@wangeditor/editor/dist/css/style.css'
|
|
39
|
-
import { defineProps, defineEmits, computed, ref, shallowRef, onBeforeUnmount } from 'vue'
|
|
40
|
-
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
41
|
-
import dataService from '../apiService/simpleDataService'
|
|
42
|
-
|
|
43
|
-
// 编辑器实例,必须用 shallowRef
|
|
44
|
-
const editorRef = shallowRef()
|
|
45
|
-
|
|
46
|
-
// 编辑器内容
|
|
47
|
-
const _valueHtml = ref('')
|
|
48
|
-
|
|
49
|
-
// 编辑器模式
|
|
50
|
-
const mode = ref('default') // 或 'simple'
|
|
51
|
-
|
|
52
|
-
const props = defineProps({
|
|
53
|
-
/**
|
|
54
|
-
* 绑定的值
|
|
55
|
-
*/
|
|
56
|
-
modelValue: {
|
|
57
|
-
type: String,
|
|
58
|
-
default: ''
|
|
59
|
-
},
|
|
60
|
-
/**
|
|
61
|
-
* 是否禁用
|
|
62
|
-
*/
|
|
63
|
-
disabled: {
|
|
64
|
-
type: Boolean,
|
|
65
|
-
default: false
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* 是否只读
|
|
69
|
-
*/
|
|
70
|
-
readonly: {
|
|
71
|
-
type: Boolean,
|
|
72
|
-
default: false
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* 占位文本
|
|
76
|
-
*/
|
|
77
|
-
placeholder: {
|
|
78
|
-
type: String,
|
|
79
|
-
default: '请输入内容...'
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* 编辑器高度
|
|
83
|
-
*/
|
|
84
|
-
height: {
|
|
85
|
-
type: [String, Number],
|
|
86
|
-
default: 300
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* 工具栏配置
|
|
90
|
-
*/
|
|
91
|
-
toolbarConfig: {
|
|
92
|
-
type: Object,
|
|
93
|
-
default: () => ({})
|
|
94
|
-
},
|
|
95
|
-
/**
|
|
96
|
-
* 编辑器配置
|
|
97
|
-
*/
|
|
98
|
-
editorConfig: {
|
|
99
|
-
type: Object,
|
|
100
|
-
default: () => ({})
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* 图片上传路径
|
|
104
|
-
*/
|
|
105
|
-
imagePath: {
|
|
106
|
-
type: String,
|
|
107
|
-
default: 'editor'
|
|
108
|
-
},
|
|
109
|
-
/**
|
|
110
|
-
* 视频上传路径
|
|
111
|
-
*/
|
|
112
|
-
videoPath: {
|
|
113
|
-
type: String,
|
|
114
|
-
default: 'video'
|
|
115
|
-
},
|
|
116
|
-
/**
|
|
117
|
-
* 最大长度
|
|
118
|
-
*/
|
|
119
|
-
maxLength: {
|
|
120
|
-
type: Number,
|
|
121
|
-
default: undefined
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const emit = defineEmits([
|
|
126
|
-
'update:modelValue',
|
|
127
|
-
'change',
|
|
128
|
-
'focus',
|
|
129
|
-
'blur',
|
|
130
|
-
'created',
|
|
131
|
-
'destroyed',
|
|
132
|
-
'upload-success', // 文件上传成功事件
|
|
133
|
-
'upload-error' // 文件上传失败事件
|
|
134
|
-
]);
|
|
135
|
-
|
|
136
|
-
// 计算属性处理v-model双向绑定
|
|
137
|
-
const computedModelValue = computed({
|
|
138
|
-
get: () => props.modelValue,
|
|
139
|
-
set: (val) => {
|
|
140
|
-
emit('update:modelValue', val);
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
// 合并工具栏配置
|
|
145
|
-
const mergedToolbarConfig = computed(() => {
|
|
146
|
-
return {
|
|
147
|
-
...props.toolbarConfig
|
|
148
|
-
};
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// 合并编辑器配置
|
|
152
|
-
const mergedEditorConfig = computed(() => {
|
|
153
|
-
return {
|
|
154
|
-
placeholder: props.placeholder,
|
|
155
|
-
readOnly: props.disabled || props.readonly,
|
|
156
|
-
maxLength: props.maxLength,
|
|
157
|
-
MENU_CONF: {
|
|
158
|
-
uploadImage: {
|
|
159
|
-
customUpload(file, insertFn) {
|
|
160
|
-
// 创建FormData对象用于文件上传
|
|
161
|
-
const formData = new FormData();
|
|
162
|
-
formData.append('file', file);
|
|
163
|
-
|
|
164
|
-
// 如果提供了图片路径参数,添加到FormData中
|
|
165
|
-
if (props.imagePath) {
|
|
166
|
-
formData.append('path', props.imagePath);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// 使用dataService进行文件上传
|
|
170
|
-
dataService.upload('', formData, (_progress) => {
|
|
171
|
-
// 上传进度回调,可以在这里显示进度条
|
|
172
|
-
// console.log('图片上传进度:', _progress + '%');
|
|
173
|
-
})
|
|
174
|
-
.then((response) => {
|
|
175
|
-
// 上传成功,插入图片到编辑器
|
|
176
|
-
let imageUrl = response;
|
|
177
|
-
|
|
178
|
-
// 如果返回的是对象,尝试获取url字段
|
|
179
|
-
if (typeof response === 'object' && response.url) {
|
|
180
|
-
imageUrl = response.url;
|
|
181
|
-
} else if (typeof response === 'object' && response.data && response.data.url) {
|
|
182
|
-
imageUrl = response.data.url;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 插入图片到编辑器
|
|
186
|
-
insertFn(imageUrl, '', '');
|
|
187
|
-
|
|
188
|
-
// 触发成功事件
|
|
189
|
-
emit('upload-success', { type: 'image', file, url: imageUrl });
|
|
190
|
-
})
|
|
191
|
-
.catch((error) => {
|
|
192
|
-
// 上传失败处理
|
|
193
|
-
// console.error('图片上传失败:', error);
|
|
194
|
-
|
|
195
|
-
// 触发失败事件
|
|
196
|
-
emit('upload-error', { type: 'image', file, error: error.message || '图片上传失败' });
|
|
197
|
-
|
|
198
|
-
// 可以在这里显示错误提示
|
|
199
|
-
// 例如使用TDesign的Message组件显示错误信息
|
|
200
|
-
});
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
uploadVideo: {
|
|
204
|
-
customUpload(file, insertFn) {
|
|
205
|
-
// 创建FormData对象用于文件上传
|
|
206
|
-
const formData = new FormData();
|
|
207
|
-
formData.append('file', file);
|
|
208
|
-
|
|
209
|
-
// 如果提供了视频路径参数,添加到FormData中
|
|
210
|
-
if (props.videoPath) {
|
|
211
|
-
formData.append('path', props.videoPath);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// 使用dataService进行文件上传
|
|
215
|
-
dataService.upload('', formData, (_progress) => {
|
|
216
|
-
// 上传进度回调
|
|
217
|
-
// console.log('视频上传进度:', _progress + '%');
|
|
218
|
-
})
|
|
219
|
-
.then((response) => {
|
|
220
|
-
// 上传成功,插入视频到编辑器
|
|
221
|
-
let videoUrl = response;
|
|
222
|
-
|
|
223
|
-
// 如果返回的是对象,尝试获取url字段
|
|
224
|
-
if (typeof response === 'object' && response.url) {
|
|
225
|
-
videoUrl = response.url;
|
|
226
|
-
} else if (typeof response === 'object' && response.data && response.data.url) {
|
|
227
|
-
videoUrl = response.data.url;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// 插入视频到编辑器
|
|
231
|
-
insertFn(videoUrl, '', '');
|
|
232
|
-
|
|
233
|
-
// 触发成功事件
|
|
234
|
-
emit('upload-success', { type: 'video', file, url: videoUrl });
|
|
235
|
-
})
|
|
236
|
-
.catch((error) => {
|
|
237
|
-
// 上传失败处理
|
|
238
|
-
// console.error('视频上传失败:', error);
|
|
239
|
-
|
|
240
|
-
// 触发失败事件
|
|
241
|
-
emit('upload-error', { type: 'video', file, error: error.message || '视频上传失败' });
|
|
242
|
-
});
|
|
243
|
-
},
|
|
244
|
-
},
|
|
245
|
-
...props.editorConfig?.MENU_CONF
|
|
246
|
-
},
|
|
247
|
-
...props.editorConfig
|
|
248
|
-
};
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
// 编辑器创建完成回调
|
|
252
|
-
const handleCreated = (editor) => {
|
|
253
|
-
editorRef.value = editor; // 记录编辑器实例
|
|
254
|
-
emit('created', editor);
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
// 内容变化事件
|
|
258
|
-
const handleChange = (editor) => {
|
|
259
|
-
emit('change', editor.getHtml());
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
// 销毁事件
|
|
263
|
-
const handleDestroyed = (editor) => {
|
|
264
|
-
emit('destroyed', editor);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
// 获得焦点事件
|
|
268
|
-
const handleFocus = (editor) => {
|
|
269
|
-
emit('focus', editor);
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
// 失去焦点事件
|
|
273
|
-
const handleBlur = (editor) => {
|
|
274
|
-
emit('blur', editor);
|
|
275
|
-
};
|
|
276
|
-
|
|
277
|
-
// 自定义提示事件
|
|
278
|
-
const handleCustomAlert = (info, type) => {
|
|
279
|
-
// 可以在这里处理编辑器的提示信息
|
|
280
|
-
// 例如显示Toast或者其他提示组件
|
|
281
|
-
emit('alert', { info, type });
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
// 自定义粘贴事件
|
|
285
|
-
const handleCustomPaste = (editor, event, callback) => {
|
|
286
|
-
// 处理粘贴事件,可以在这里对粘贴内容进行预处理
|
|
287
|
-
emit('paste', { editor, event });
|
|
288
|
-
// 返回值(注意,vue 事件的返回值,不能用 return)
|
|
289
|
-
callback(true); // true 继续默认的粘贴行为
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
// 组件销毁时,销毁编辑器实例
|
|
293
|
-
onBeforeUnmount(() => {
|
|
294
|
-
const editor = editorRef.value;
|
|
295
|
-
if (editor === null) return;
|
|
296
|
-
editor.destroy();
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
// 暴露编辑器实例和方法
|
|
300
|
-
defineExpose({
|
|
301
|
-
editor: editorRef,
|
|
302
|
-
insertText: (text) => {
|
|
303
|
-
if (editorRef.value) {
|
|
304
|
-
editorRef.value.insertText(text);
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
getHtml: () => {
|
|
308
|
-
if (editorRef.value) {
|
|
309
|
-
return editorRef.value.getHtml();
|
|
310
|
-
}
|
|
311
|
-
return '';
|
|
312
|
-
},
|
|
313
|
-
getText: () => {
|
|
314
|
-
if (editorRef.value) {
|
|
315
|
-
return editorRef.value.getText();
|
|
316
|
-
}
|
|
317
|
-
return '';
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
</script>
|
|
321
|
-
|
|
322
|
-
<style scoped>
|
|
323
|
-
.ebiz-rich-text-editor {
|
|
324
|
-
border-radius: var(--td-radius-default);
|
|
325
|
-
overflow: hidden;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
.ebiz-rich-text-editor :deep(.w-e-text-container) {
|
|
329
|
-
z-index: 1; /* 避免编辑区域遮挡其他元素 */
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
.ebiz-rich-text-editor :deep(.w-e-toolbar) {
|
|
333
|
-
z-index: 2; /* 确保工具栏在编辑区域之上 */
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
.ebiz-rich-text-editor :deep(.w-e-text-placeholder) {
|
|
337
|
-
color: var(--td-text-color-placeholder);
|
|
338
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="ebiz-rich-text-editor" style="border: 1px solid #ccc">
|
|
3
|
+
<Toolbar
|
|
4
|
+
style="border-bottom: 1px solid #ccc"
|
|
5
|
+
:editor="editorRef"
|
|
6
|
+
:defaultConfig="mergedToolbarConfig"
|
|
7
|
+
:mode="mode"
|
|
8
|
+
/>
|
|
9
|
+
<Editor
|
|
10
|
+
:style="{height: `${height}px`, overflowY: 'hidden'}"
|
|
11
|
+
v-model="computedModelValue"
|
|
12
|
+
:defaultConfig="mergedEditorConfig"
|
|
13
|
+
:mode="mode"
|
|
14
|
+
@onCreated="handleCreated"
|
|
15
|
+
@onChange="handleChange"
|
|
16
|
+
@onDestroyed="handleDestroyed"
|
|
17
|
+
@onFocus="handleFocus"
|
|
18
|
+
@onBlur="handleBlur"
|
|
19
|
+
@customAlert="handleCustomAlert"
|
|
20
|
+
@customPaste="handleCustomPaste"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script>
|
|
26
|
+
/**
|
|
27
|
+
* @displayName 富文本编辑器
|
|
28
|
+
* @description 基于WangEditor的富文本编辑器组件,支持图片和视频上传
|
|
29
|
+
* @category 表单组件
|
|
30
|
+
* @name EbizRichTextEditor
|
|
31
|
+
*/
|
|
32
|
+
export default {
|
|
33
|
+
name: "EbizRichTextEditor"
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<script setup>
|
|
38
|
+
import '@wangeditor/editor/dist/css/style.css'
|
|
39
|
+
import { defineProps, defineEmits, computed, ref, shallowRef, onBeforeUnmount } from 'vue'
|
|
40
|
+
import { Editor, Toolbar } from '@wangeditor/editor-for-vue'
|
|
41
|
+
import dataService from '../apiService/simpleDataService'
|
|
42
|
+
|
|
43
|
+
// 编辑器实例,必须用 shallowRef
|
|
44
|
+
const editorRef = shallowRef()
|
|
45
|
+
|
|
46
|
+
// 编辑器内容
|
|
47
|
+
const _valueHtml = ref('')
|
|
48
|
+
|
|
49
|
+
// 编辑器模式
|
|
50
|
+
const mode = ref('default') // 或 'simple'
|
|
51
|
+
|
|
52
|
+
const props = defineProps({
|
|
53
|
+
/**
|
|
54
|
+
* 绑定的值
|
|
55
|
+
*/
|
|
56
|
+
modelValue: {
|
|
57
|
+
type: String,
|
|
58
|
+
default: ''
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* 是否禁用
|
|
62
|
+
*/
|
|
63
|
+
disabled: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: false
|
|
66
|
+
},
|
|
67
|
+
/**
|
|
68
|
+
* 是否只读
|
|
69
|
+
*/
|
|
70
|
+
readonly: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
74
|
+
/**
|
|
75
|
+
* 占位文本
|
|
76
|
+
*/
|
|
77
|
+
placeholder: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: '请输入内容...'
|
|
80
|
+
},
|
|
81
|
+
/**
|
|
82
|
+
* 编辑器高度
|
|
83
|
+
*/
|
|
84
|
+
height: {
|
|
85
|
+
type: [String, Number],
|
|
86
|
+
default: 300
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* 工具栏配置
|
|
90
|
+
*/
|
|
91
|
+
toolbarConfig: {
|
|
92
|
+
type: Object,
|
|
93
|
+
default: () => ({})
|
|
94
|
+
},
|
|
95
|
+
/**
|
|
96
|
+
* 编辑器配置
|
|
97
|
+
*/
|
|
98
|
+
editorConfig: {
|
|
99
|
+
type: Object,
|
|
100
|
+
default: () => ({})
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* 图片上传路径
|
|
104
|
+
*/
|
|
105
|
+
imagePath: {
|
|
106
|
+
type: String,
|
|
107
|
+
default: 'editor'
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* 视频上传路径
|
|
111
|
+
*/
|
|
112
|
+
videoPath: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: 'video'
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* 最大长度
|
|
118
|
+
*/
|
|
119
|
+
maxLength: {
|
|
120
|
+
type: Number,
|
|
121
|
+
default: undefined
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const emit = defineEmits([
|
|
126
|
+
'update:modelValue',
|
|
127
|
+
'change',
|
|
128
|
+
'focus',
|
|
129
|
+
'blur',
|
|
130
|
+
'created',
|
|
131
|
+
'destroyed',
|
|
132
|
+
'upload-success', // 文件上传成功事件
|
|
133
|
+
'upload-error' // 文件上传失败事件
|
|
134
|
+
]);
|
|
135
|
+
|
|
136
|
+
// 计算属性处理v-model双向绑定
|
|
137
|
+
const computedModelValue = computed({
|
|
138
|
+
get: () => props.modelValue,
|
|
139
|
+
set: (val) => {
|
|
140
|
+
emit('update:modelValue', val);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// 合并工具栏配置
|
|
145
|
+
const mergedToolbarConfig = computed(() => {
|
|
146
|
+
return {
|
|
147
|
+
...props.toolbarConfig
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// 合并编辑器配置
|
|
152
|
+
const mergedEditorConfig = computed(() => {
|
|
153
|
+
return {
|
|
154
|
+
placeholder: props.placeholder,
|
|
155
|
+
readOnly: props.disabled || props.readonly,
|
|
156
|
+
maxLength: props.maxLength,
|
|
157
|
+
MENU_CONF: {
|
|
158
|
+
uploadImage: {
|
|
159
|
+
customUpload(file, insertFn) {
|
|
160
|
+
// 创建FormData对象用于文件上传
|
|
161
|
+
const formData = new FormData();
|
|
162
|
+
formData.append('file', file);
|
|
163
|
+
|
|
164
|
+
// 如果提供了图片路径参数,添加到FormData中
|
|
165
|
+
if (props.imagePath) {
|
|
166
|
+
formData.append('path', props.imagePath);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 使用dataService进行文件上传
|
|
170
|
+
dataService.upload('', formData, (_progress) => {
|
|
171
|
+
// 上传进度回调,可以在这里显示进度条
|
|
172
|
+
// console.log('图片上传进度:', _progress + '%');
|
|
173
|
+
})
|
|
174
|
+
.then((response) => {
|
|
175
|
+
// 上传成功,插入图片到编辑器
|
|
176
|
+
let imageUrl = response;
|
|
177
|
+
|
|
178
|
+
// 如果返回的是对象,尝试获取url字段
|
|
179
|
+
if (typeof response === 'object' && response.url) {
|
|
180
|
+
imageUrl = response.url;
|
|
181
|
+
} else if (typeof response === 'object' && response.data && response.data.url) {
|
|
182
|
+
imageUrl = response.data.url;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 插入图片到编辑器
|
|
186
|
+
insertFn(imageUrl, '', '');
|
|
187
|
+
|
|
188
|
+
// 触发成功事件
|
|
189
|
+
emit('upload-success', { type: 'image', file, url: imageUrl });
|
|
190
|
+
})
|
|
191
|
+
.catch((error) => {
|
|
192
|
+
// 上传失败处理
|
|
193
|
+
// console.error('图片上传失败:', error);
|
|
194
|
+
|
|
195
|
+
// 触发失败事件
|
|
196
|
+
emit('upload-error', { type: 'image', file, error: error.message || '图片上传失败' });
|
|
197
|
+
|
|
198
|
+
// 可以在这里显示错误提示
|
|
199
|
+
// 例如使用TDesign的Message组件显示错误信息
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
uploadVideo: {
|
|
204
|
+
customUpload(file, insertFn) {
|
|
205
|
+
// 创建FormData对象用于文件上传
|
|
206
|
+
const formData = new FormData();
|
|
207
|
+
formData.append('file', file);
|
|
208
|
+
|
|
209
|
+
// 如果提供了视频路径参数,添加到FormData中
|
|
210
|
+
if (props.videoPath) {
|
|
211
|
+
formData.append('path', props.videoPath);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// 使用dataService进行文件上传
|
|
215
|
+
dataService.upload('', formData, (_progress) => {
|
|
216
|
+
// 上传进度回调
|
|
217
|
+
// console.log('视频上传进度:', _progress + '%');
|
|
218
|
+
})
|
|
219
|
+
.then((response) => {
|
|
220
|
+
// 上传成功,插入视频到编辑器
|
|
221
|
+
let videoUrl = response;
|
|
222
|
+
|
|
223
|
+
// 如果返回的是对象,尝试获取url字段
|
|
224
|
+
if (typeof response === 'object' && response.url) {
|
|
225
|
+
videoUrl = response.url;
|
|
226
|
+
} else if (typeof response === 'object' && response.data && response.data.url) {
|
|
227
|
+
videoUrl = response.data.url;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// 插入视频到编辑器
|
|
231
|
+
insertFn(videoUrl, '', '');
|
|
232
|
+
|
|
233
|
+
// 触发成功事件
|
|
234
|
+
emit('upload-success', { type: 'video', file, url: videoUrl });
|
|
235
|
+
})
|
|
236
|
+
.catch((error) => {
|
|
237
|
+
// 上传失败处理
|
|
238
|
+
// console.error('视频上传失败:', error);
|
|
239
|
+
|
|
240
|
+
// 触发失败事件
|
|
241
|
+
emit('upload-error', { type: 'video', file, error: error.message || '视频上传失败' });
|
|
242
|
+
});
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
...props.editorConfig?.MENU_CONF
|
|
246
|
+
},
|
|
247
|
+
...props.editorConfig
|
|
248
|
+
};
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
// 编辑器创建完成回调
|
|
252
|
+
const handleCreated = (editor) => {
|
|
253
|
+
editorRef.value = editor; // 记录编辑器实例
|
|
254
|
+
emit('created', editor);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
// 内容变化事件
|
|
258
|
+
const handleChange = (editor) => {
|
|
259
|
+
emit('change', editor.getHtml());
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// 销毁事件
|
|
263
|
+
const handleDestroyed = (editor) => {
|
|
264
|
+
emit('destroyed', editor);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// 获得焦点事件
|
|
268
|
+
const handleFocus = (editor) => {
|
|
269
|
+
emit('focus', editor);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// 失去焦点事件
|
|
273
|
+
const handleBlur = (editor) => {
|
|
274
|
+
emit('blur', editor);
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// 自定义提示事件
|
|
278
|
+
const handleCustomAlert = (info, type) => {
|
|
279
|
+
// 可以在这里处理编辑器的提示信息
|
|
280
|
+
// 例如显示Toast或者其他提示组件
|
|
281
|
+
emit('alert', { info, type });
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
// 自定义粘贴事件
|
|
285
|
+
const handleCustomPaste = (editor, event, callback) => {
|
|
286
|
+
// 处理粘贴事件,可以在这里对粘贴内容进行预处理
|
|
287
|
+
emit('paste', { editor, event });
|
|
288
|
+
// 返回值(注意,vue 事件的返回值,不能用 return)
|
|
289
|
+
callback(true); // true 继续默认的粘贴行为
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
// 组件销毁时,销毁编辑器实例
|
|
293
|
+
onBeforeUnmount(() => {
|
|
294
|
+
const editor = editorRef.value;
|
|
295
|
+
if (editor === null) return;
|
|
296
|
+
editor.destroy();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// 暴露编辑器实例和方法
|
|
300
|
+
defineExpose({
|
|
301
|
+
editor: editorRef,
|
|
302
|
+
insertText: (text) => {
|
|
303
|
+
if (editorRef.value) {
|
|
304
|
+
editorRef.value.insertText(text);
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
getHtml: () => {
|
|
308
|
+
if (editorRef.value) {
|
|
309
|
+
return editorRef.value.getHtml();
|
|
310
|
+
}
|
|
311
|
+
return '';
|
|
312
|
+
},
|
|
313
|
+
getText: () => {
|
|
314
|
+
if (editorRef.value) {
|
|
315
|
+
return editorRef.value.getText();
|
|
316
|
+
}
|
|
317
|
+
return '';
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
</script>
|
|
321
|
+
|
|
322
|
+
<style scoped>
|
|
323
|
+
.ebiz-rich-text-editor {
|
|
324
|
+
border-radius: var(--td-radius-default);
|
|
325
|
+
overflow: hidden;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.ebiz-rich-text-editor :deep(.w-e-text-container) {
|
|
329
|
+
z-index: 1; /* 避免编辑区域遮挡其他元素 */
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
.ebiz-rich-text-editor :deep(.w-e-toolbar) {
|
|
333
|
+
z-index: 2; /* 确保工具栏在编辑区域之上 */
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.ebiz-rich-text-editor :deep(.w-e-text-placeholder) {
|
|
337
|
+
color: var(--td-text-color-placeholder);
|
|
338
|
+
}
|
|
339
339
|
</style>
|