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