@ctzy-web-client/plugin-component-vue 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/es/_virtual/_plugin-vue_export-helper.mjs +11 -0
  2. package/es/advance-select/advance-operation.mjs +48 -51
  3. package/es/advance-select/advance-option.mjs +128 -163
  4. package/es/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.mjs +11 -5
  5. package/es/advance-select/advance-select.mjs +323 -370
  6. package/es/advance-select/events-helpers.mjs +9 -0
  7. package/es/advance-select/index.mjs +9 -0
  8. package/es/advance-select/use-advance-option.mjs +9 -0
  9. package/es/advance-select/use-advance-select.mjs +9 -0
  10. package/es/application-slot/application-slot.mjs +9 -0
  11. package/es/application-slot/breadcrumb-item.mjs +26 -20
  12. package/es/application-slot/header-tools-item.mjs +26 -20
  13. package/es/application-slot/index.mjs +9 -0
  14. package/es/breadcrumb-select/breadcrumb-select.mjs +123 -137
  15. package/es/breadcrumb-select/index.mjs +9 -0
  16. package/es/components.mjs +9 -0
  17. package/es/contextmenu/contextmenu-item.mjs +24 -19
  18. package/es/contextmenu/contextmenu.mjs +68 -73
  19. package/es/contextmenu/index.mjs +9 -0
  20. package/es/contextmenu/use-contextmenu.mjs +10 -1
  21. package/es/data-form/data-form-item.mjs +41 -49
  22. package/es/data-form/data-form.mjs +176 -213
  23. package/es/data-form/dynamic-component.mjs +9 -0
  24. package/es/data-form/form-components/Blots/AtBlot.mjs +9 -0
  25. package/es/data-form/form-components/bwa-date-picker.mjs +50 -51
  26. package/es/data-form/form-components/bwa-date-time-picker.mjs +55 -56
  27. package/es/data-form/form-components/bwa-input-float.mjs +48 -48
  28. package/es/data-form/form-components/bwa-input-integer.mjs +61 -68
  29. package/es/data-form/form-components/bwa-input.mjs +43 -43
  30. package/es/data-form/form-components/bwa-multi-select.mjs +40 -40
  31. package/es/data-form/form-components/bwa-rich-text-tinymce.mjs +230 -555
  32. package/es/data-form/form-components/bwa-rich-text.mjs +326 -404
  33. package/es/data-form/form-components/bwa-select.mjs +81 -84
  34. package/es/data-form/form-components/bwa-textarea.mjs +38 -38
  35. package/es/data-form/form-components/bwa-upload.mjs +160 -173
  36. package/es/data-form/form-components/bwa-user-multi-select.mjs +35 -35
  37. package/es/data-form/form-components/bwa-user-select.mjs +72 -86
  38. package/es/data-form/index.mjs +9 -0
  39. package/es/data-table/data-column-view.mjs +124 -146
  40. package/es/data-table/data-table-card.mjs +49 -48
  41. package/es/data-table/data-table-column.mjs +55 -58
  42. package/es/data-table/data-table.mjs +328 -404
  43. package/es/data-table/dynamic-component.mjs +9 -0
  44. package/es/data-table/index.mjs +9 -0
  45. package/es/data-table/use-datatable-drag.mjs +9 -0
  46. package/es/datatable-settings/datatable-settings.mjs +286 -328
  47. package/es/datatable-settings/index.mjs +9 -0
  48. package/es/date-range/date-picker.mjs +125 -131
  49. package/es/date-range/date-range.mjs +173 -216
  50. package/es/date-range/index.mjs +9 -0
  51. package/es/drag-list/constants.mjs +10 -0
  52. package/es/drag-list/drag-item.mjs +51 -56
  53. package/es/drag-list/drag-list.mjs +58 -60
  54. package/es/drag-list/index.mjs +9 -0
  55. package/es/drag-list/use-drag-list.mjs +10 -1
  56. package/es/dragable/constants.mjs +10 -0
  57. package/es/dragable/dragable-item.mjs +27 -23
  58. package/es/dragable/dragable-operation.mjs +33 -32
  59. package/es/dragable/dragable.mjs +33 -32
  60. package/es/dragable/index.mjs +9 -0
  61. package/es/dragable/use-dragable.mjs +9 -0
  62. package/es/filter-panel/conditions/condition.mjs +9 -0
  63. package/es/filter-panel/conditions/date-range-condition.mjs +51 -50
  64. package/es/filter-panel/conditions/department-condition/department-condition.mjs +82 -99
  65. package/es/filter-panel/conditions/department-condition/department-node.mjs +69 -73
  66. package/es/filter-panel/conditions/index.mjs +9 -0
  67. package/es/filter-panel/conditions/input-condition.mjs +88 -91
  68. package/es/filter-panel/conditions/multi-user-condition.mjs +66 -67
  69. package/es/filter-panel/conditions/multiple-menu-condition.mjs +44 -54
  70. package/es/filter-panel/conditions/single-menu-condition.mjs +71 -65
  71. package/es/filter-panel/conditions/single-user-condition.mjs +66 -67
  72. package/es/filter-panel/filter-panel-item.mjs +51 -55
  73. package/es/filter-panel/filter-panel.mjs +147 -156
  74. package/es/filter-panel/index.mjs +9 -0
  75. package/es/filter-panel/use-filter-panel-item.mjs +9 -0
  76. package/es/filter-panel/use-filter-panel.mjs +9 -0
  77. package/es/hooks/use-data/index.mjs +9 -0
  78. package/es/index.mjs +9 -0
  79. package/es/layout/index.mjs +9 -0
  80. package/es/layout/layout.mjs +87 -85
  81. package/es/make-installer.mjs +9 -0
  82. package/es/math/Rectangle.mjs +10 -0
  83. package/es/menu/index.mjs +9 -0
  84. package/es/menu/menu-item.mjs +65 -70
  85. package/es/menu/menu.mjs +64 -70
  86. package/es/node_modules/.pnpm/{@vueuse_core@9.6.0_vue@3.2.41 → @vueuse_core@9.13.0_vue@3.5.29_typescript@4.9.5_}/node_modules/@vueuse/core/index.mjs +680 -454
  87. package/es/node_modules/.pnpm/{@vueuse_shared@9.6.0_vue@3.2.41 → @vueuse_shared@9.13.0_vue@3.5.29_typescript@4.9.5_}/node_modules/@vueuse/shared/index.mjs +108 -46
  88. package/es/panel/index.mjs +9 -0
  89. package/es/panel/panel.mjs +49 -53
  90. package/es/panel-tabs/index.mjs +9 -0
  91. package/es/panel-tabs/panel-tabs.mjs +9 -0
  92. package/es/pct-filter-panel/index.mjs +9 -0
  93. package/es/pct-filter-panel/pct-compents/index.mjs +9 -0
  94. package/es/pct-filter-panel/pct-compents/pct-Input-condition.mjs +73 -75
  95. package/es/pct-filter-panel/pct-compents/pct-date-range-condition.mjs +77 -77
  96. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +345 -374
  97. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +149 -154
  98. package/es/pct-filter-panel/pct-filter-panel-item.mjs +52 -56
  99. package/es/pct-filter-panel/pct-filter-panel.mjs +235 -248
  100. package/es/pct-filter-panel/use-filter-panel-item.mjs +9 -0
  101. package/es/pct-filter-panel/use-filter-panel.mjs +9 -0
  102. package/es/plugins.mjs +9 -0
  103. package/es/progress/index.mjs +9 -0
  104. package/es/progress/progress-item.mjs +71 -81
  105. package/es/progress/progress.mjs +74 -78
  106. package/es/progress/use-progress.mjs +9 -0
  107. package/es/utils/db.mjs +9 -0
  108. package/es/utils.css +1 -0
  109. package/es/utils.mjs +9 -0
  110. package/es/where-filter-panel/index.mjs +9 -1
  111. package/es/where-filter-panel/use-where-filter-panel.mjs +9 -0
  112. package/es/where-filter-panel/where-filter-panel.mjs +21 -15
  113. package/lib/_virtual/_plugin-vue_export-helper.js +11 -0
  114. package/lib/advance-select/advance-operation.js +47 -50
  115. package/lib/advance-select/advance-option.js +127 -162
  116. package/lib/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.js +11 -6
  117. package/lib/advance-select/advance-select.js +322 -369
  118. package/lib/advance-select/events-helpers.js +9 -0
  119. package/lib/advance-select/index.js +9 -0
  120. package/lib/advance-select/use-advance-option.js +9 -0
  121. package/lib/advance-select/use-advance-select.js +9 -0
  122. package/lib/application-slot/application-slot.js +9 -0
  123. package/lib/application-slot/breadcrumb-item.js +25 -19
  124. package/lib/application-slot/header-tools-item.js +25 -19
  125. package/lib/application-slot/index.js +9 -0
  126. package/lib/breadcrumb-select/breadcrumb-select.js +122 -136
  127. package/lib/breadcrumb-select/index.js +9 -0
  128. package/lib/components.js +9 -0
  129. package/lib/contextmenu/contextmenu-item.js +23 -18
  130. package/lib/contextmenu/contextmenu.js +67 -72
  131. package/lib/contextmenu/index.js +9 -0
  132. package/lib/contextmenu/use-contextmenu.js +10 -1
  133. package/lib/data-form/data-form-item.js +40 -48
  134. package/lib/data-form/data-form.js +175 -212
  135. package/lib/data-form/dynamic-component.js +9 -0
  136. package/lib/data-form/form-components/Blots/AtBlot.js +9 -0
  137. package/lib/data-form/form-components/bwa-date-picker.js +49 -50
  138. package/lib/data-form/form-components/bwa-date-time-picker.js +54 -55
  139. package/lib/data-form/form-components/bwa-input-float.js +47 -47
  140. package/lib/data-form/form-components/bwa-input-integer.js +60 -67
  141. package/lib/data-form/form-components/bwa-input.js +42 -42
  142. package/lib/data-form/form-components/bwa-multi-select.js +39 -39
  143. package/lib/data-form/form-components/bwa-rich-text-tinymce.js +229 -554
  144. package/lib/data-form/form-components/bwa-rich-text.js +325 -403
  145. package/lib/data-form/form-components/bwa-select.js +80 -83
  146. package/lib/data-form/form-components/bwa-textarea.js +37 -37
  147. package/lib/data-form/form-components/bwa-upload.js +159 -172
  148. package/lib/data-form/form-components/bwa-user-multi-select.js +34 -34
  149. package/lib/data-form/form-components/bwa-user-select.js +71 -85
  150. package/lib/data-form/index.js +9 -0
  151. package/lib/data-table/data-column-view.js +124 -146
  152. package/lib/data-table/data-table-card.js +49 -48
  153. package/lib/data-table/data-table-column.js +54 -57
  154. package/lib/data-table/data-table.js +327 -403
  155. package/lib/data-table/dynamic-component.js +9 -0
  156. package/lib/data-table/index.js +9 -0
  157. package/lib/data-table/use-datatable-drag.js +9 -0
  158. package/lib/datatable-settings/datatable-settings.js +285 -327
  159. package/lib/datatable-settings/index.js +9 -0
  160. package/lib/date-range/date-picker.js +124 -130
  161. package/lib/date-range/date-range.js +172 -215
  162. package/lib/date-range/index.js +9 -0
  163. package/lib/drag-list/constants.js +10 -0
  164. package/lib/drag-list/drag-item.js +50 -55
  165. package/lib/drag-list/drag-list.js +57 -59
  166. package/lib/drag-list/index.js +9 -0
  167. package/lib/drag-list/use-drag-list.js +10 -1
  168. package/lib/dragable/constants.js +10 -0
  169. package/lib/dragable/dragable-item.js +26 -22
  170. package/lib/dragable/dragable-operation.js +32 -31
  171. package/lib/dragable/dragable.js +32 -31
  172. package/lib/dragable/index.js +9 -0
  173. package/lib/dragable/use-dragable.js +9 -0
  174. package/lib/filter-panel/conditions/condition.js +9 -0
  175. package/lib/filter-panel/conditions/date-range-condition.js +50 -49
  176. package/lib/filter-panel/conditions/department-condition/department-condition.js +81 -98
  177. package/lib/filter-panel/conditions/department-condition/department-node.js +68 -72
  178. package/lib/filter-panel/conditions/index.js +9 -0
  179. package/lib/filter-panel/conditions/input-condition.js +87 -90
  180. package/lib/filter-panel/conditions/multi-user-condition.js +65 -66
  181. package/lib/filter-panel/conditions/multiple-menu-condition.js +43 -53
  182. package/lib/filter-panel/conditions/single-menu-condition.js +70 -64
  183. package/lib/filter-panel/conditions/single-user-condition.js +65 -66
  184. package/lib/filter-panel/filter-panel-item.js +50 -54
  185. package/lib/filter-panel/filter-panel.js +146 -155
  186. package/lib/filter-panel/index.js +9 -0
  187. package/lib/filter-panel/use-filter-panel-item.js +9 -0
  188. package/lib/filter-panel/use-filter-panel.js +9 -0
  189. package/lib/hooks/use-data/index.js +9 -0
  190. package/lib/index.js +9 -0
  191. package/lib/layout/index.js +9 -0
  192. package/lib/layout/layout.js +86 -84
  193. package/lib/make-installer.js +9 -0
  194. package/lib/math/Rectangle.js +10 -0
  195. package/lib/menu/index.js +9 -0
  196. package/lib/menu/menu-item.js +64 -69
  197. package/lib/menu/menu.js +63 -69
  198. package/lib/node_modules/.pnpm/{@vueuse_core@9.6.0_vue@3.2.41 → @vueuse_core@9.13.0_vue@3.5.29_typescript@4.9.5_}/node_modules/@vueuse/core/index.js +685 -451
  199. package/lib/node_modules/.pnpm/{@vueuse_shared@9.6.0_vue@3.2.41 → @vueuse_shared@9.13.0_vue@3.5.29_typescript@4.9.5_}/node_modules/@vueuse/shared/index.js +109 -44
  200. package/lib/panel/index.js +9 -0
  201. package/lib/panel/panel.js +48 -52
  202. package/lib/panel-tabs/index.js +9 -0
  203. package/lib/panel-tabs/panel-tabs.js +9 -0
  204. package/lib/pct-filter-panel/index.js +9 -0
  205. package/lib/pct-filter-panel/pct-compents/index.js +9 -0
  206. package/lib/pct-filter-panel/pct-compents/pct-Input-condition.js +72 -74
  207. package/lib/pct-filter-panel/pct-compents/pct-date-range-condition.js +76 -76
  208. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +344 -373
  209. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +148 -153
  210. package/lib/pct-filter-panel/pct-filter-panel-item.js +51 -55
  211. package/lib/pct-filter-panel/pct-filter-panel.js +234 -247
  212. package/lib/pct-filter-panel/use-filter-panel-item.js +9 -0
  213. package/lib/pct-filter-panel/use-filter-panel.js +9 -0
  214. package/lib/plugins.js +9 -0
  215. package/lib/progress/index.js +9 -0
  216. package/lib/progress/progress-item.js +70 -80
  217. package/lib/progress/progress.js +73 -77
  218. package/lib/progress/use-progress.js +9 -0
  219. package/lib/utils/db.js +9 -0
  220. package/lib/utils.css +1 -0
  221. package/lib/utils.js +9 -0
  222. package/lib/where-filter-panel/index.js +9 -0
  223. package/lib/where-filter-panel/use-where-filter-panel.js +9 -0
  224. package/lib/where-filter-panel/where-filter-panel.js +20 -14
  225. package/package.json +1 -1
  226. package/style/index.css +1 -1
  227. package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs +0 -28
  228. package/lib/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +0 -32
@@ -1,413 +1,335 @@
1
- import { ref, unref, getCurrentScope, computed, onMounted, markRaw, watch, onScopeDispose, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, Fragment, renderList, createBlock } from 'vue';
1
+ import { defineComponent, ref, unref, getCurrentScope, computed, onMounted, markRaw, watch, onScopeDispose, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, Fragment, renderList, createBlock } from 'vue';
2
2
  import { useService, useNamespace } from '@ctzy-web-client/web-base-client-vue';
3
3
  import Quill from 'quill';
4
4
  import 'quill/dist/quill.snow.css';
5
5
  import { ElMessage } from 'element-plus';
6
6
  import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
7
7
 
8
- const _sfc_main = {
9
- __name: 'bwa-rich-text',
10
- props: {
11
- placeholder: {
12
- type: String,
13
- default: '',
14
- },
15
- modelValue: {
16
- type: null,
17
- },
18
- disabled: {
19
- type: Boolean,
20
- default: false,
21
- },
22
- showAt: {
23
- type: Boolean,
24
- default: false,
25
- },
26
- userIds: {
27
- typee: Array,
28
- default: () => [],
29
- },
30
- },
31
- emits: ['update:modelValue', 'update:userIds'],
32
- setup(__props, { expose, emit }) {
33
-
34
- const props = __props;
35
-
36
- let editor = null;
37
-
38
- const userService = useService('UserService');
39
-
40
- const loading = ref(false);
41
- const userList = ref([
42
- { value: '1', label: '用户1' },
43
- { value: '2', label: '用户2' },
44
- { value: '3', label: '用户3' },
45
- ]);
46
-
47
- const handleChange = ([userId]) => {
48
- if (!editor || !userId) {
49
- return;
50
- }
51
-
52
- const userInfo = unref(userList).find((item) => item.value === userId);
53
-
54
- if (!userInfo) {
55
- return;
56
- }
57
-
58
- editor.focus();
59
-
60
- //获取当前光标位置
61
- let length = editor.getSelection()
62
- ? editor.getSelection().index || 0
63
- : editor.getLength();
64
-
65
- // 设置@
66
- editor.insertEmbed(
67
- length,
68
- 'at',
69
- { id: userInfo.value, desc: userInfo.label },
70
- 'user'
71
- );
72
-
73
- editor.insertText(length + 1, ' ');
74
-
75
- //设置光标
76
- editor.setSelection(length + 2);
77
- };
78
-
79
- const loadUserList = async (search = '') => {
80
- try {
81
- if (unref(loading)) {
82
- return;
83
- }
84
-
85
- loading.value = true;
86
- if (!unref(userService)) {
87
- ElMessage.error('无法获取用户');
88
- return;
89
- }
90
-
91
- const userListResult = await unref(userService).getUserList({
92
- name: search,
93
- });
94
-
95
- if (userListResult.code != 0) {
96
- ElMessage.error(userListResult.msg);
97
- return;
98
- }
99
-
100
- userList.value = userListResult.data;
101
- } finally {
102
- loading.value = false;
103
- }
104
- };
105
-
106
- const handleVisibleChange = (visible) => {
107
- if (!visible) {
108
- return;
109
- }
110
-
111
- loadUserList();
112
- };
113
-
114
-
115
-
116
- const virtualRef = ref(null);
117
-
118
-
119
-
120
- defineOptions({
121
- name: 'BwaRichText',
122
- });
123
-
124
- const ns = useNamespace('rich-text');
125
-
126
- const fileService = useService('FileService');
127
-
128
- const quillEditorContainer = ref(null);
129
- const quillEditorRef = ref(null);
130
-
131
- const currentScope = getCurrentScope();
132
-
133
- const editorInstance = ref(null);
134
-
135
- const toolbarOptions = [
136
- [{ header: [1, 2, 3, 4, 5, 6, false] }],
137
- [{ font: [] }],
138
- ['bold', 'italic', 'underline', 'strike'],
139
- [{ align: [] }],
140
- ['blockquote', 'code-block'],
141
- [{ header: 1 }, { header: 2 }],
142
- [{ list: 'ordered' }, { list: 'bullet' }],
143
- [{ script: 'sub' }, { script: 'super' }],
144
- [{ indent: '-1' }, { indent: '+1' }],
145
- [{ color: [] }, { background: [] }],
146
- ['clean'].concat(props.showAt ? ['at'] : []),
147
- ];
148
-
149
- const value = computed({
150
- get: () => props.modelValue || '',
151
- set: (v) => {
152
- // 解决当只有一张图片的时候 回显html报文异常
153
- let str = '';
154
- if (!v && editor && editor.root.innerHTML && editor.root.innerHTML.indexOf('<img') != -1) {
155
- str = editor.root.innerHTML;
156
- }
157
- emit('update:modelValue', v || str);
158
- },
159
- });
160
-
161
- const userIds = computed({
162
- get: () => props.userIds,
163
- set: (v) => {
164
- emit('update:userIds', v);
165
- },
166
- });
167
-
168
- const updateImage = async (file) => {
169
- if (!unref(fileService)) {
170
- return;
171
- }
172
-
173
- const uploadFileResult = await unref(fileService).uploadFile(file);
174
-
175
- if (uploadFileResult.code != 0) {
176
- return uploadFileResult;
177
- }
178
-
179
- const fileID = uploadFileResult.data.id;
180
-
181
- const filePathResult = await unref(fileService).getFilePath(fileID);
182
-
183
- if (filePathResult.code != 0) {
184
- return filePathResult;
185
- }
186
-
187
- return {
188
- ...filePathResult,
189
- data: { id: fileID, path: filePathResult.data },
190
- };
191
- };
192
- const quillEditorRefClick = () => {
193
- if (!editor) {
194
- return;
195
- }
196
- editor.focus();
197
- };
198
- onMounted(() => {
199
- editor = new Quill(unref(quillEditorRef), {
200
- theme: 'snow',
201
- placeholder: props.placeholder,
202
- modules: {
203
- toolbar: {
204
- container: toolbarOptions,
205
- handlers: {
206
- at: function (value) {},
207
- },
208
- },
209
- },
210
- });
211
-
212
- virtualRef.value = quillEditorContainer.value.querySelector('button.ql-at');
213
-
214
- editorInstance.value = markRaw(editor);
215
-
216
- const el = document.createElement('div');
217
-
218
- const getUserIds = (html) => {
219
- el.innerHTML = html;
220
-
221
- const items = Array.from(el.querySelectorAll('span.ptp-at-item'));
222
-
223
- userIds.value = [
224
- ...new Set(items.map((item) => item.getAttribute('d-id'))),
225
- ];
226
- };
227
-
228
- getUserIds(unref(value));
229
-
230
- const handleTextChange = (delta, oldDelta, source) => {
231
- const _value = editor.getText() === '\n' ? '' : editor.root.innerHTML;
232
-
233
- value.value = _value;
234
-
235
- getUserIds(_value);
236
- // if (source === 'user') {
237
- // var range = editor.getLength();
238
- // console.log(range)
239
- // // if (range != null) {
240
- // // setTimeout(() => {
241
- // // editor.setSelection(range.index, range.length); // 重新设置选区
242
- // // }, 300)
243
- // // }
244
- // }
245
- };
246
-
247
- const handlePaste = (evt) => {
248
- if (
249
- evt.clipboardData &&
250
- evt.clipboardData.files &&
251
- evt.clipboardData.files.length
252
- ) {
253
- evt.preventDefault();
254
- [].forEach.call(evt.clipboardData.files, async (file) => {
255
- console.log(file);
256
- if (file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
257
- const filePathResult = await updateImage(file);
258
-
259
- if (filePathResult.code != 0) {
260
- return;
261
- }
262
-
263
- const fileData = filePathResult.data;
264
- // const fileData = { id: 1, path: 'https://img1.baidu.com/it/u=2335299816,3552592887&fm=253&fmt=auto&app=138&f=JPEG?w=126&h=189' }
265
- var range = editor.getSelection();
266
- if (range && fileData) {
267
- // 在当前光标位置插入图片
268
- editor.insertEmbed(range.index, 'image', fileData.path);
269
- editor.formatText(range.index, 1, {
270
- alt: fileData.id,
271
- });
272
- // 将光标移动到图片后面
273
- setTimeout(() => {
274
- editor.setSelection(range.index + 1);
275
- // console.log(editor.getSelection(), editor.getLength())
276
- // editor.setSelection(editor.getSelection().index, editor.getSelection().length);
277
- }, 300);
278
- }
279
- }
280
- });
281
- }
282
- };
283
-
284
- currentScope.run(() => {
285
- watch(
286
- computed(() => props.disabled),
287
- (disabled) => {
288
- editor.enable(!disabled);
289
- },
290
- { immediate: true }
291
- );
292
- const getFilePaths = async (alt) => {
293
- const filePathResult = await unref(fileService).getFilePath(alt);
294
- return filePathResult
295
- };
296
- let artArr2 = []; // 防止重复加载图片
297
- watch(
298
- value,
299
- async () => {
300
- if ((unref(value).indexOf('data:image/png') != -1 || unref(value).indexOf('base64') != -1)) {
301
- editor.root.innerHTML = unref(value);
302
- return
303
- }
304
- // console.log(unref(value))
305
- if (!unref(value)) {
306
- artArr2 = [];
307
- }
308
- let afterHtml = '';
309
- let artArr = [];
310
- let artArrOption = [];
311
- if (unref(value).indexOf('<img') != -1) {
312
- unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
313
- if (!artArr2.includes(alt)) {
314
- artArr.push(alt);
315
- }
316
- });
317
- for (const alt of artArr) {
318
- artArrOption.push({
319
- alt,
320
- src: await getFilePaths(alt)
321
- // src: 'https://img1.baidu.com/it/u=2335299816,3552592887&fm=253&fmt=auto&app=138&f=JPEG?w=126&h=189'
322
- });
323
- }
324
- // console.log(artArrOption)
325
- afterHtml = unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
326
- if (artArr.includes(alt)) {
327
- return `<img src="${artArrOption.find(a => a.alt === alt)?.src.data}" alt="${alt}">`
328
- } else {
329
- return img
330
- }
331
-
332
- });
333
- }
334
- console.log('afterHtml =>', afterHtml);
335
- artArr2 = [...artArr2, ...artArr];
336
- artArr = [];
337
- artArrOption = [];
338
- if (editor.root.innerHTML === (afterHtml || unref(value))) {
339
- return;
340
- }
341
- const range = editor.getSelection();
342
- editor.root.innerHTML = afterHtml || unref(value);
343
- setTimeout(() => {
344
- if (range) {
345
- editor.setSelection(range.index + 1);
346
- editor.focus();
347
- }
348
- }, 100);
349
- },
350
- { immediate: true }
351
- );
352
-
353
- editor.on('text-change', handleTextChange);
354
-
355
- editor.root.addEventListener('paste', handlePaste);
356
-
357
- onScopeDispose(() => {
358
- editor.off('text-change', handleTextChange);
359
-
360
- editor.root.removeEventListener('paste', handlePaste);
361
- });
362
- });
363
- });
364
-
365
- expose({
366
- getEditorInstance() {
367
- return unref(editorInstance);
368
- },
369
- });
370
-
371
- return (_ctx, _cache) => {
372
- const _component_BwaAdvanceOption = resolveComponent("BwaAdvanceOption");
373
- const _component_BwaAdvanceSelect = resolveComponent("BwaAdvanceSelect");
374
-
375
- return (openBlock(), createElementBlock("div", {
376
- class: normalizeClass(unref(ns).b()),
377
- ref_key: "quillEditorContainer",
378
- ref: quillEditorContainer
379
- }, [
380
- createElementVNode("div", {
381
- class: normalizeClass(unref(ns).e('editor')),
382
- ref_key: "quillEditorRef",
383
- ref: quillEditorRef,
384
- onClick: quillEditorRefClick
385
- }, null, 2 /* CLASS */),
386
- createVNode(_component_BwaAdvanceSelect, {
387
- showSelection: false,
388
- "virtual-triggering": true,
389
- "virtual-ref": virtualRef.value,
390
- loading: loading.value,
391
- onSearch: loadUserList,
392
- "onUpdate:modelValue": handleChange,
393
- onVisibleChange: handleVisibleChange
394
- }, {
395
- default: withCtx(() => [
396
- (openBlock(true), createElementBlock(Fragment, null, renderList(userList.value, (item) => {
397
- return (openBlock(), createBlock(_component_BwaAdvanceOption, {
398
- key: item.value,
399
- value: item.value,
400
- label: item.label
401
- }, null, 8 /* PROPS */, ["value", "label"]))
402
- }), 128 /* KEYED_FRAGMENT */))
403
- ]),
404
- _: 1 /* STABLE */
405
- }, 8 /* PROPS */, ["virtual-ref", "loading"])
406
- ], 2 /* CLASS */))
8
+ // Inject __name helper
9
+ if (typeof __name === 'undefined') {
10
+ function __name(obj, name) {
11
+ Object.defineProperty(obj, "name", {
12
+ value: name,
13
+ configurable: true
14
+ });
15
+ }
407
16
  }
408
- }
409
-
410
- };
411
- var RichText = /*#__PURE__*/_export_sfc(_sfc_main, [['__file',"bwa-rich-text.vue"]]);
17
+ const __default__ = defineComponent({
18
+ name: "BwaRichText"
19
+ });
20
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
21
+ props: {
22
+ placeholder: {
23
+ type: String,
24
+ default: ""
25
+ },
26
+ modelValue: {
27
+ type: null
28
+ },
29
+ disabled: {
30
+ type: Boolean,
31
+ default: false
32
+ },
33
+ showAt: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ userIds: {
38
+ typee: Array,
39
+ default: () => []
40
+ }
41
+ },
42
+ emits: ["update:modelValue", "update:userIds"],
43
+ setup(__props, { expose: __expose, emit: __emit }) {
44
+ let editor = null;
45
+ const userService = useService("UserService");
46
+ const loading = ref(false);
47
+ const userList = ref([
48
+ { value: "1", label: "\u7528\u62371" },
49
+ { value: "2", label: "\u7528\u62372" },
50
+ { value: "3", label: "\u7528\u62373" }
51
+ ]);
52
+ const handleChange = ([userId]) => {
53
+ if (!editor || !userId) {
54
+ return;
55
+ }
56
+ const userInfo = unref(userList).find((item) => item.value === userId);
57
+ if (!userInfo) {
58
+ return;
59
+ }
60
+ editor.focus();
61
+ let length = editor.getSelection() ? editor.getSelection().index || 0 : editor.getLength();
62
+ editor.insertEmbed(
63
+ length,
64
+ "at",
65
+ { id: userInfo.value, desc: userInfo.label },
66
+ "user"
67
+ );
68
+ editor.insertText(length + 1, " ");
69
+ editor.setSelection(length + 2);
70
+ };
71
+ const loadUserList = async (search = "") => {
72
+ try {
73
+ if (unref(loading)) {
74
+ return;
75
+ }
76
+ loading.value = true;
77
+ if (!unref(userService)) {
78
+ ElMessage.error("\u65E0\u6CD5\u83B7\u53D6\u7528\u6237");
79
+ return;
80
+ }
81
+ const userListResult = await unref(userService).getUserList({
82
+ name: search
83
+ });
84
+ if (userListResult.code != 0) {
85
+ ElMessage.error(userListResult.msg);
86
+ return;
87
+ }
88
+ userList.value = userListResult.data;
89
+ } finally {
90
+ loading.value = false;
91
+ }
92
+ };
93
+ const handleVisibleChange = (visible) => {
94
+ if (!visible) {
95
+ return;
96
+ }
97
+ loadUserList();
98
+ };
99
+ const props = __props;
100
+ const virtualRef = ref(null);
101
+ const emit = __emit;
102
+ ;
103
+ const ns = useNamespace("rich-text");
104
+ const fileService = useService("FileService");
105
+ const quillEditorContainer = ref(null);
106
+ const quillEditorRef = ref(null);
107
+ const currentScope = getCurrentScope();
108
+ const editorInstance = ref(null);
109
+ const toolbarOptions = [
110
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
111
+ [{ font: [] }],
112
+ ["bold", "italic", "underline", "strike"],
113
+ [{ align: [] }],
114
+ ["blockquote", "code-block"],
115
+ [{ header: 1 }, { header: 2 }],
116
+ [{ list: "ordered" }, { list: "bullet" }],
117
+ [{ script: "sub" }, { script: "super" }],
118
+ [{ indent: "-1" }, { indent: "+1" }],
119
+ [{ color: [] }, { background: [] }],
120
+ ["clean"].concat(props.showAt ? ["at"] : [])
121
+ ];
122
+ const value = computed({
123
+ get: () => props.modelValue || "",
124
+ set: (v) => {
125
+ let str = "";
126
+ if (!v && editor && editor.root.innerHTML && editor.root.innerHTML.indexOf("<img") != -1) {
127
+ str = editor.root.innerHTML;
128
+ }
129
+ emit("update:modelValue", v || str);
130
+ }
131
+ });
132
+ const userIds = computed({
133
+ get: () => props.userIds,
134
+ set: (v) => {
135
+ emit("update:userIds", v);
136
+ }
137
+ });
138
+ const updateImage = async (file) => {
139
+ if (!unref(fileService)) {
140
+ return;
141
+ }
142
+ const uploadFileResult = await unref(fileService).uploadFile(file);
143
+ if (uploadFileResult.code != 0) {
144
+ return uploadFileResult;
145
+ }
146
+ const fileID = uploadFileResult.data.id;
147
+ const filePathResult = await unref(fileService).getFilePath(fileID);
148
+ if (filePathResult.code != 0) {
149
+ return filePathResult;
150
+ }
151
+ return {
152
+ ...filePathResult,
153
+ data: { id: fileID, path: filePathResult.data }
154
+ };
155
+ };
156
+ const quillEditorRefClick = () => {
157
+ if (!editor) {
158
+ return;
159
+ }
160
+ editor.focus();
161
+ };
162
+ onMounted(() => {
163
+ editor = new Quill(unref(quillEditorRef), {
164
+ theme: "snow",
165
+ placeholder: props.placeholder,
166
+ modules: {
167
+ toolbar: {
168
+ container: toolbarOptions,
169
+ handlers: {
170
+ at: function(value2) {
171
+ }
172
+ }
173
+ }
174
+ }
175
+ });
176
+ virtualRef.value = quillEditorContainer.value.querySelector("button.ql-at");
177
+ editorInstance.value = markRaw(editor);
178
+ const el = document.createElement("div");
179
+ const getUserIds = (html) => {
180
+ el.innerHTML = html;
181
+ const items = Array.from(el.querySelectorAll("span.ptp-at-item"));
182
+ userIds.value = [
183
+ ...new Set(items.map((item) => item.getAttribute("d-id")))
184
+ ];
185
+ };
186
+ getUserIds(unref(value));
187
+ const handleTextChange = (delta, oldDelta, source) => {
188
+ const _value = editor.getText() === "\n" ? "" : editor.root.innerHTML;
189
+ value.value = _value;
190
+ getUserIds(_value);
191
+ };
192
+ const handlePaste = (evt) => {
193
+ if (evt.clipboardData && evt.clipboardData.files && evt.clipboardData.files.length) {
194
+ evt.preventDefault();
195
+ [].forEach.call(evt.clipboardData.files, async (file) => {
196
+ console.log(file);
197
+ if (file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
198
+ const filePathResult = await updateImage(file);
199
+ if (filePathResult.code != 0) {
200
+ return;
201
+ }
202
+ const fileData = filePathResult.data;
203
+ var range = editor.getSelection();
204
+ if (range && fileData) {
205
+ editor.insertEmbed(range.index, "image", fileData.path);
206
+ editor.formatText(range.index, 1, {
207
+ alt: fileData.id
208
+ });
209
+ setTimeout(() => {
210
+ editor.setSelection(range.index + 1);
211
+ }, 300);
212
+ }
213
+ }
214
+ });
215
+ }
216
+ };
217
+ currentScope.run(() => {
218
+ watch(
219
+ computed(() => props.disabled),
220
+ (disabled) => {
221
+ editor.enable(!disabled);
222
+ },
223
+ { immediate: true }
224
+ );
225
+ const getFilePaths = async (alt) => {
226
+ const filePathResult = await unref(fileService).getFilePath(alt);
227
+ return filePathResult;
228
+ };
229
+ let artArr2 = [];
230
+ watch(
231
+ value,
232
+ async () => {
233
+ if (unref(value).indexOf("data:image/png") != -1 || unref(value).indexOf("base64") != -1) {
234
+ editor.root.innerHTML = unref(value);
235
+ return;
236
+ }
237
+ if (!unref(value)) {
238
+ artArr2 = [];
239
+ }
240
+ let afterHtml = "";
241
+ let artArr = [];
242
+ let artArrOption = [];
243
+ if (unref(value).indexOf("<img") != -1) {
244
+ unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
245
+ if (!artArr2.includes(alt)) {
246
+ artArr.push(alt);
247
+ }
248
+ });
249
+ for (const alt of artArr) {
250
+ artArrOption.push({
251
+ alt,
252
+ src: await getFilePaths(alt)
253
+ });
254
+ }
255
+ afterHtml = unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
256
+ var _a;
257
+ if (artArr.includes(alt)) {
258
+ return `<img src="${(_a = artArrOption.find((a) => a.alt === alt)) == null ? void 0 : _a.src.data}" alt="${alt}">`;
259
+ } else {
260
+ return img;
261
+ }
262
+ });
263
+ }
264
+ console.log("afterHtml =>", afterHtml);
265
+ artArr2 = [...artArr2, ...artArr];
266
+ artArr = [];
267
+ artArrOption = [];
268
+ if (editor.root.innerHTML === (afterHtml || unref(value))) {
269
+ return;
270
+ }
271
+ const range = editor.getSelection();
272
+ editor.root.innerHTML = afterHtml || unref(value);
273
+ setTimeout(() => {
274
+ if (range) {
275
+ editor.setSelection(range.index + 1);
276
+ editor.focus();
277
+ }
278
+ }, 100);
279
+ },
280
+ { immediate: true }
281
+ );
282
+ editor.on("text-change", handleTextChange);
283
+ editor.root.addEventListener("paste", handlePaste);
284
+ onScopeDispose(() => {
285
+ editor.off("text-change", handleTextChange);
286
+ editor.root.removeEventListener("paste", handlePaste);
287
+ });
288
+ });
289
+ });
290
+ __expose({
291
+ getEditorInstance() {
292
+ return unref(editorInstance);
293
+ }
294
+ });
295
+ return (_ctx, _cache) => {
296
+ const _component_BwaAdvanceOption = resolveComponent("BwaAdvanceOption");
297
+ const _component_BwaAdvanceSelect = resolveComponent("BwaAdvanceSelect");
298
+ return openBlock(), createElementBlock("div", {
299
+ class: normalizeClass(unref(ns).b()),
300
+ ref_key: "quillEditorContainer",
301
+ ref: quillEditorContainer
302
+ }, [
303
+ createElementVNode("div", {
304
+ class: normalizeClass(unref(ns).e("editor")),
305
+ ref_key: "quillEditorRef",
306
+ ref: quillEditorRef,
307
+ onClick: quillEditorRefClick
308
+ }, null, 2),
309
+ createVNode(_component_BwaAdvanceSelect, {
310
+ showSelection: false,
311
+ "virtual-triggering": true,
312
+ "virtual-ref": virtualRef.value,
313
+ loading: loading.value,
314
+ onSearch: loadUserList,
315
+ "onUpdate:modelValue": handleChange,
316
+ onVisibleChange: handleVisibleChange
317
+ }, {
318
+ default: withCtx(() => [
319
+ (openBlock(true), createElementBlock(Fragment, null, renderList(userList.value, (item) => {
320
+ return openBlock(), createBlock(_component_BwaAdvanceOption, {
321
+ key: item.value,
322
+ value: item.value,
323
+ label: item.label
324
+ }, null, 8, ["value", "label"]);
325
+ }), 128))
326
+ ]),
327
+ _: 1
328
+ }, 8, ["virtual-ref", "loading"])
329
+ ], 2);
330
+ };
331
+ }
332
+ });
333
+ var RichText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-rich-text.vue"]]);
412
334
 
413
335
  export { RichText as default };