@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,570 +1,245 @@
1
- import { ref, getCurrentScope, computed, reactive, onMounted, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, createVNode, createBlock, Teleport, normalizeStyle, renderList, toDisplayString, createCommentVNode } from 'vue';
1
+ import { defineComponent, ref, getCurrentScope, computed, reactive, onMounted, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, createVNode, createBlock, Teleport, normalizeStyle, renderList, toDisplayString, createCommentVNode } from 'vue';
2
2
  import { useNamespace, useService } from '@ctzy-web-client/web-base-client-vue';
3
3
  import TinyMCEEditor from '@tinymce/tinymce-vue';
4
4
  import 'quill/dist/quill.snow.css';
5
5
  import { Subject, Observable, map, filter, mergeMap, merge, from, delayWhen, timer, takeUntil, tap } from 'rxjs';
6
6
  import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
7
7
 
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
+ }
16
+ }
8
17
  const _hoisted_1 = ["onClick"];
9
- // import { useActiveElement } from '@vueuse/core';
10
- // import { filter, fromEvent } from 'rxjs';
11
-
12
-
13
- const _sfc_main = {
14
- __name: 'bwa-rich-text-tinymce',
15
- props: {
16
- placeholder: {
17
- type: String,
18
- default: '',
19
- },
20
- modelValue: {
21
- type: null,
22
- },
23
- disabled: {
24
- type: Boolean,
25
- default: false,
26
- },
27
- },
28
- emits: ['update:modelValue'],
29
- setup(__props, { emit }) {
30
-
31
- const props = __props;
32
-
33
- defineOptions({
34
- name: 'BwaRichText',
35
- });
36
-
37
-
38
-
39
- let resolve = null;
40
-
41
- const setupPromise = new Promise((relv) => {
42
- resolve = relv;
43
- });
44
-
45
- const initOptions = {
46
- promotion: false,
47
- language: 'zh-Hans',
48
- setup: resolve,
49
- };
50
-
51
- // const DIGIAL_LETTER_REGEXP = /^[\da-z]/i;
52
-
53
-
54
-
55
- const ns = useNamespace('rich-text');
56
-
57
- const fileService = useService('FileService');
58
-
59
- /** @type {import('vue').Ref<HTMLElement>} */
60
- const editorRef = ref(null);
61
- const tinyMCEEditorRef = ref(null);
62
-
63
- // const editing = computed(() => {
64
- // const element = unref(useActiveElement());
65
-
66
- // if (!element.classList.contains('ql-editor')) {
67
- // return false;
68
- // }
69
-
70
- // const el = unref(editorRef);
71
-
72
- // return el?.contains(element) ?? false;
73
- // });
74
-
75
- const currentScope = getCurrentScope();
76
-
77
- // const toolbarOptions = [
78
- // [{ header: [1, 2, 3, 4, 5, 6, false] }],
79
- // [{ font: [] }],
80
- // ['bold', 'italic', 'underline', 'strike'],
81
- // [{ align: [] }],
82
- // ['blockquote', 'code-block'],
83
- // [{ header: 1 }, { header: 2 }],
84
- // [{ list: 'ordered' }, { list: 'bullet' }],
85
- // [{ script: 'sub' }, { script: 'super' }],
86
- // [{ indent: '-1' }, { indent: '+1' }],
87
- // [{ color: [] }, { background: [] }],
88
- // ['clean'],
89
- // ];
90
-
91
- const value = computed({
92
- get: () => props.modelValue || '',
93
- set: (v) => {
94
- emit('update:modelValue', v);
95
- },
96
- });
97
-
98
- // const updateImage = async (file) => {
99
- // if (!unref(fileService)) {
100
- // return;
101
- // }
102
-
103
- // const uploadFileResult = await unref(fileService).uploadFile(file);
104
-
105
- // if (uploadFileResult.code != 0) {
106
- // return uploadFileResult;
107
- // }
108
-
109
- // const fileID = uploadFileResult.data.id;
110
-
111
- // const filePathResult = await unref(fileService).getFilePath(fileID);
112
-
113
- // if (filePathResult.code != 0) {
114
- // return filePathResult;
115
- // }
116
-
117
- // return {
118
- // ...filePathResult,
119
- // data: { id: fileID, path: filePathResult.data },
120
- // };
121
- // };
122
-
123
- const focusing = ref(false);
124
-
125
- const AT_REGEXP = /[^\da-zA-Z]@[^@]*$/;
126
-
127
- const atPersonInfos = reactive({
128
- node: null,
129
- content: '',
130
- selection: null,
131
- index: -1,
132
- style: null,
133
- });
134
-
135
- const selectPersonSubject = new Subject();
136
-
137
- const handlePersonSelect = selectPersonSubject.next.bind(selectPersonSubject);
138
-
139
- // const handlePersonSelect = () => {
140
- // if (!atPersonInfos.node) {
141
- // return;
142
- // }
143
-
144
- // const { node, index, content } = atPersonInfos;
145
-
146
- // const document = node.ownerDocument;
147
-
148
- // const documentFragment = document.createDocumentFragment();
149
-
150
- // if (index) {
151
- // const textNode = document.createTextNode(node.data.slice(0, index));
152
-
153
- // documentFragment.appendChild(textNode);
154
- // }
155
-
156
- // const span = document.createElement('span');
157
- // span.innerText = content;
158
-
159
- // documentFragment.appendChild(span);
160
-
161
- // const contentEndIndex = index + content.length;
162
- // if (contentEndIndex < node.data.length) {
163
- // const textNode = document.createTextNode(node.data.slice(contentEndIndex));
164
-
165
- // documentFragment.appendChild(textNode);
166
- // }
167
-
168
- // const parent = node.parentElement;
169
-
170
- // parent.insertBefore(documentFragment, node);
171
- // parent.removeChild(node);
172
-
173
- // // console.log(
174
- // // documentFragment
175
- // // atPersonInfos.node.data,
176
- // // atPersonInfos.index,
177
- // // atPersonInfos.content.length
178
- // // );
179
-
180
- // // atPersonInfos.node.data;
181
- // };
182
-
183
- window.atPersonInfos = atPersonInfos;
184
-
185
- onMounted(async () => {
186
- const editor = await setupPromise;
187
-
188
- window.editor = editor;
189
-
190
- // const focusObservable = new Observable((observer) => {
191
- // editor.on('focus', observer.next.bind(observer));
192
-
193
- // return () => {
194
- // editor.off('focus', observer.next.bind(observer));
195
- // };
196
- // });
197
-
198
- // const blurObservable = new Observable((observer) => {
199
- // editor.on('blur', observer.next.bind(observer));
200
-
201
- // return () => {
202
- // editor.off('blur', observer.next.bind(observer));
203
- // };
204
- // });
205
-
206
- const inputObservable = new Observable((observer) => {
207
- const next = observer.next.bind(observer);
208
- editor.on('input', next);
209
-
210
- return () => {
211
- editor.off('input', next);
212
- };
213
- });
214
-
215
- editor.on('change', (event) => {
216
- console.log(event);
217
- });
218
-
219
- const getSelection = (event) => {
220
- if (
221
- typeof event.target.nodeType === 'number' &&
222
- typeof event.target.tagName === 'string'
223
- ) {
224
- return event.target.ownerDocument.getSelection();
225
- }
226
-
227
- return event.target.iframeElement.contentDocument.getSelection();
228
- };
229
-
230
- const subject = new Subject();
231
-
232
- inputObservable
233
- .pipe(
234
- map((event) => {
235
- if (event.data !== '@') {
236
- return null;
237
- }
238
-
239
- const selection = event.currentTarget.ownerDocument.getSelection();
240
-
241
- const focusNode = selection.focusNode;
242
-
243
- if (focusNode.nodeType !== Node.TEXT_NODE) {
244
- return null;
245
- }
246
-
247
- const content = focusNode.data.slice(0, selection.focusOffset);
248
-
249
- const match = content.match(AT_REGEXP);
250
-
251
- if (!match) {
252
- return null;
253
- }
254
-
255
- return {
256
- event: event,
257
- selection,
258
- index: match[0].indexOf('@') + match.index,
259
- node: focusNode,
260
- content,
261
- range: selection.getRangeAt(0),
262
- };
263
- }),
264
- filter(Boolean),
265
- mergeMap(({ event, index, node, content, range }) => {
266
- const changeObservable = new Observable((observer) => {
267
- const next = observer.next.bind(observer);
268
- editor.on('change input undo redo', next);
269
-
270
- return () => {
271
- editor.off('change input undo redo', next);
272
- };
273
- });
274
-
275
- return merge(from([event]), changeObservable).pipe(
276
- delayWhen(() => timer(0)),
277
- map((event) => {
278
- const selection = getSelection(event);
279
-
280
- const content = node.data.slice(index, selection.focusOffset);
281
-
282
- console.log(content);
283
-
284
- if (!content) {
285
- subject.next();
286
- return null;
287
- }
288
-
289
- return {
290
- index,
291
- node,
292
- content,
293
- range: selection.getRangeAt(0),
294
- };
295
- }),
296
- filter(Boolean),
297
- takeUntil(
298
- merge(
299
- inputObservable.pipe(filter((event) => event.data === '@')),
300
- subject
301
- ).pipe(
302
- tap(() => {
303
- atPersonInfos.node = null;
304
- atPersonInfos.content = '';
305
- atPersonInfos.selection = null;
306
- atPersonInfos.index = -1;
307
- atPersonInfos.style = null;
308
- })
309
- )
310
- )
311
- );
312
- })
313
- )
314
- .subscribe(({ index, node, selection, content, range }) => {
315
- const searchContent = content.slice(1);
316
-
317
- const { x: offsetX, y: offsetY, height } = range.getBoundingClientRect();
318
-
319
- const iframeElement = editor.iframeElement;
320
- const { x: iframeX, y: iframeY } = iframeElement.getBoundingClientRect();
321
-
322
- atPersonInfos.node = node;
323
- atPersonInfos.content = content;
324
- atPersonInfos.selection = selection;
325
- atPersonInfos.index = index;
326
- atPersonInfos.style = {
327
- '--left': iframeX + offsetX + 'px',
328
- '--top': iframeY + offsetY + height + 'px',
329
- };
330
- });
331
-
332
- selectPersonSubject.subscribe(() => {
333
- if (!atPersonInfos.node) {
334
- return;
335
- }
336
-
337
- const { node, index, content } = atPersonInfos;
338
-
339
- const document = node.ownerDocument;
340
-
341
- const documentFragment = document.createDocumentFragment();
342
-
343
- if (index) {
344
- const textNode = document.createTextNode(node.data.slice(0, index));
345
-
346
- documentFragment.appendChild(textNode);
347
- }
348
-
349
- const span = document.createElement('span');
350
- span.innerText = content;
351
-
352
- documentFragment.appendChild(span);
353
-
354
- const contentEndIndex = index + content.length;
355
- if (contentEndIndex < node.data.length) {
356
- const textNode = document.createTextNode(
357
- node.data.slice(contentEndIndex)
358
- );
359
-
360
- documentFragment.appendChild(textNode);
361
- }
362
-
363
- const parent = node.parentElement;
364
-
365
- parent.insertBefore(documentFragment, node);
366
- parent.removeChild(node);
367
-
368
- subject.next();
369
- });
370
-
371
- // editor.on('keydown', (event) => {ƒ
372
-
373
- // editor.on('focus', () => {
374
- // focusing.value = true;
375
- // });
376
-
377
- // editor.on('blur', () => {
378
- // focusing.value = false;
379
- // });
380
-
381
- // editor.on('input', (event) => {
382
- // if (event.data !== '@') {
383
- // return;
384
- // }
385
-
386
- // /** @type {Selection} */
387
- // const selection = event.target.ownerDocument.getSelection();
388
-
389
- // console.dir(selection.focusNode);
390
-
391
- // const focusNode = selection.focusNode;
392
-
393
- // if (focusNode.nodeType !== Node.TEXT_NODE) {
394
- // return;
395
- // }
396
-
397
- // const content = focusNode.data.slice(0, selection.focusOffset);
398
-
399
- // const match = content.match(AT_REGEXP);
400
-
401
- // if (!match) {
402
- // return;
403
- // }
404
-
405
- // const index = match.index;
406
-
407
- // const range = selection.getRangeAt(0);
408
-
409
- // const boundary = range.getBoundingClientRect();
410
-
411
- // console.log(boundary);
412
- // });
413
-
414
- // editor.on('SelectionChange', (...args) => {
415
- // console.log(...args);
416
- // });
417
-
418
- // const editor = new Quill(unref(editorRef), {
419
- // modules: { toolbar: toolbarOptions },
420
- // theme: 'snow',
421
- // placeholder: props.placeholder,
422
- // });
423
-
424
- // window.aaa = editor;
425
-
426
- // watch(
427
- // value,
428
- // (value) => {
429
- // if (editor.root.innerHTML !== value) {
430
- // editor.root.innerHTML = value;
431
- // }
432
- // },
433
- // { immediate: true }
434
- // );
435
-
436
- // watch(
437
- // computed(() => props.disabled),
438
- // (disabled) => {
439
- // editor.enable(!disabled);
440
- // },
441
- // { immediate: true }
442
- // );
443
-
444
- // const atPersonSubcription = fromEvent(document, 'keydown')
445
- // .pipe(
446
- // filter(() => unref(editing)),
447
- // filter((/** @type {KeyboardEvent}*/ e) => e.key === '@')
448
- // )
449
- // .subscribe((/** @type {KeyboardEvent}*/ e) => {
450
- // const selection = editor.getSelection();
451
-
452
- // if (selection.index > 1) {
453
- // const preChar = editor.getContents(
454
- // selection.index - 1,
455
- // selection.index
456
- // );
457
-
458
- // if (
459
- // preChar.ops.length === 1 &&
460
- // DIGIAL_LETTER_REGEXP.test(preChar.ops[0].insert)
461
- // ) {
462
- // return;
463
- // }
464
- // }
465
-
466
- // e.preventDefault();
467
- // e.stopPropagation();
468
-
469
- // console.log(editor.getContents());
470
-
471
- // // atPersionInfo.value = {
472
- // // startIndex: selection.index,
473
- // // endIndex: selection.index + 1,
474
- // // };
475
- // });
476
-
477
- // const handleTextChange = () => {
478
- // value.value = editor.root.innerHTML;
479
- // };
480
-
481
- // const handlePaste = (evt) => {
482
- // if (
483
- // evt.clipboardData &&
484
- // evt.clipboardData.files &&
485
- // evt.clipboardData.files.length
486
- // ) {
487
- // evt.preventDefault();
488
- // [].forEach.call(evt.clipboardData.files, async (file) => {
489
- // if (file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
490
- // const filePathResult = await updateImage(file);
491
-
492
- // if (filePathResult.code != 0) {
493
- // return;
494
- // }
495
-
496
- // const fileData = filePathResult.data;
497
-
498
- // var range = editor.getSelection();
499
- // if (range && fileData) {
500
- // // 在当前光标位置插入图�?
501
- // editor.insertEmbed(range.index, 'image', fileData.path);
502
- // editor.formatText(range.index, 1, {
503
- // alt: fileData.id,
504
- // });
505
- // // 将光标移动到图片后面
506
- // editor.setSelection(range.index + 1);
507
- // }
508
- // }
509
- // });
510
- // }
511
- // };
512
-
513
- currentScope.run(() => {
514
- // editor.on('text-change', handleTextChange);
515
- // editor.root.addEventListener('paste', handlePaste);
516
- // onScopeDispose(() => {
517
- // editor.off('text-change', handleTextChange);
518
- // editor.root.removeEventListener('paste', handlePaste);
519
- // atPersonSubcription.unsubscribe();
520
- // });
521
- });
522
- });
523
-
524
- return (_ctx, _cache) => {
525
- return (openBlock(), createElementBlock(Fragment, null, [
526
- createElementVNode("div", {
527
- class: normalizeClass(unref(ns).b())
528
- }, [
529
- createElementVNode("div", {
530
- class: normalizeClass(unref(ns).e('editor')),
531
- ref_key: "editorRef",
532
- ref: editorRef
533
- }, [
534
- createVNode(unref(TinyMCEEditor), {
535
- init: initOptions,
536
- disabled: __props.disabled,
537
- tinymceScriptSrc: "/tinymce/tinymce.js",
538
- ref_key: "tinyMCEEditorRef",
539
- ref: tinyMCEEditorRef
540
- }, null, 8 /* PROPS */, ["disabled"])
541
- ], 2 /* CLASS */)
542
- ], 2 /* CLASS */),
543
- (openBlock(), createBlock(Teleport, { to: "body" }, [
544
- createElementVNode("div", {
545
- class: normalizeClass(unref(ns).e('at-list-wrapper'))
546
- }, [
547
- (atPersonInfos.style)
548
- ? (openBlock(), createElementBlock("div", {
18
+ const __default__ = defineComponent({
19
+ name: "BwaRichText"
20
+ });
21
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
22
+ props: {
23
+ placeholder: {
24
+ type: String,
25
+ default: ""
26
+ },
27
+ modelValue: {
28
+ type: null
29
+ },
30
+ disabled: {
31
+ type: Boolean,
32
+ default: false
33
+ }
34
+ },
35
+ emits: ["update:modelValue"],
36
+ setup(__props, { emit: __emit }) {
37
+ ;
38
+ const props = __props;
39
+ let resolve = null;
40
+ const setupPromise = new Promise((relv) => {
41
+ resolve = relv;
42
+ });
43
+ const initOptions = {
44
+ promotion: false,
45
+ language: "zh-Hans",
46
+ setup: resolve
47
+ };
48
+ const emit = __emit;
49
+ const ns = useNamespace("rich-text");
50
+ const fileService = useService("FileService");
51
+ const editorRef = ref(null);
52
+ const tinyMCEEditorRef = ref(null);
53
+ const currentScope = getCurrentScope();
54
+ const value = computed({
55
+ get: () => props.modelValue || "",
56
+ set: (v) => {
57
+ emit("update:modelValue", v);
58
+ }
59
+ });
60
+ const focusing = ref(false);
61
+ const AT_REGEXP = /[^\da-zA-Z]@[^@]*$/;
62
+ const atPersonInfos = reactive({
63
+ node: null,
64
+ content: "",
65
+ selection: null,
66
+ index: -1,
67
+ style: null
68
+ });
69
+ const selectPersonSubject = new Subject();
70
+ const handlePersonSelect = selectPersonSubject.next.bind(selectPersonSubject);
71
+ window.atPersonInfos = atPersonInfos;
72
+ onMounted(async () => {
73
+ const editor = await setupPromise;
74
+ window.editor = editor;
75
+ const inputObservable = new Observable((observer) => {
76
+ const next = observer.next.bind(observer);
77
+ editor.on("input", next);
78
+ return () => {
79
+ editor.off("input", next);
80
+ };
81
+ });
82
+ editor.on("change", (event) => {
83
+ console.log(event);
84
+ });
85
+ const getSelection = (event) => {
86
+ if (typeof event.target.nodeType === "number" && typeof event.target.tagName === "string") {
87
+ return event.target.ownerDocument.getSelection();
88
+ }
89
+ return event.target.iframeElement.contentDocument.getSelection();
90
+ };
91
+ const subject = new Subject();
92
+ inputObservable.pipe(
93
+ map((event) => {
94
+ if (event.data !== "@") {
95
+ return null;
96
+ }
97
+ const selection = event.currentTarget.ownerDocument.getSelection();
98
+ const focusNode = selection.focusNode;
99
+ if (focusNode.nodeType !== Node.TEXT_NODE) {
100
+ return null;
101
+ }
102
+ const content = focusNode.data.slice(0, selection.focusOffset);
103
+ const match = content.match(AT_REGEXP);
104
+ if (!match) {
105
+ return null;
106
+ }
107
+ return {
108
+ event,
109
+ selection,
110
+ index: match[0].indexOf("@") + match.index,
111
+ node: focusNode,
112
+ content,
113
+ range: selection.getRangeAt(0)
114
+ };
115
+ }),
116
+ filter(Boolean),
117
+ mergeMap(({ event, index, node, content, range }) => {
118
+ const changeObservable = new Observable((observer) => {
119
+ const next = observer.next.bind(observer);
120
+ editor.on("change input undo redo", next);
121
+ return () => {
122
+ editor.off("change input undo redo", next);
123
+ };
124
+ });
125
+ return merge(from([event]), changeObservable).pipe(
126
+ delayWhen(() => timer(0)),
127
+ map((event2) => {
128
+ const selection = getSelection(event2);
129
+ const content2 = node.data.slice(index, selection.focusOffset);
130
+ console.log(content2);
131
+ if (!content2) {
132
+ subject.next();
133
+ return null;
134
+ }
135
+ return {
136
+ index,
137
+ node,
138
+ content: content2,
139
+ range: selection.getRangeAt(0)
140
+ };
141
+ }),
142
+ filter(Boolean),
143
+ takeUntil(
144
+ merge(
145
+ inputObservable.pipe(filter((event2) => event2.data === "@")),
146
+ subject
147
+ ).pipe(
148
+ tap(() => {
149
+ atPersonInfos.node = null;
150
+ atPersonInfos.content = "";
151
+ atPersonInfos.selection = null;
152
+ atPersonInfos.index = -1;
153
+ atPersonInfos.style = null;
154
+ })
155
+ )
156
+ )
157
+ );
158
+ })
159
+ ).subscribe(({ index, node, selection, content, range }) => {
160
+ const searchContent = content.slice(1);
161
+ const { x: offsetX, y: offsetY, height } = range.getBoundingClientRect();
162
+ const iframeElement = editor.iframeElement;
163
+ const { x: iframeX, y: iframeY } = iframeElement.getBoundingClientRect();
164
+ atPersonInfos.node = node;
165
+ atPersonInfos.content = content;
166
+ atPersonInfos.selection = selection;
167
+ atPersonInfos.index = index;
168
+ atPersonInfos.style = {
169
+ "--left": iframeX + offsetX + "px",
170
+ "--top": iframeY + offsetY + height + "px"
171
+ };
172
+ });
173
+ selectPersonSubject.subscribe(() => {
174
+ if (!atPersonInfos.node) {
175
+ return;
176
+ }
177
+ const { node, index, content } = atPersonInfos;
178
+ const document = node.ownerDocument;
179
+ const documentFragment = document.createDocumentFragment();
180
+ if (index) {
181
+ const textNode = document.createTextNode(node.data.slice(0, index));
182
+ documentFragment.appendChild(textNode);
183
+ }
184
+ const span = document.createElement("span");
185
+ span.innerText = content;
186
+ documentFragment.appendChild(span);
187
+ const contentEndIndex = index + content.length;
188
+ if (contentEndIndex < node.data.length) {
189
+ const textNode = document.createTextNode(
190
+ node.data.slice(contentEndIndex)
191
+ );
192
+ documentFragment.appendChild(textNode);
193
+ }
194
+ const parent = node.parentElement;
195
+ parent.insertBefore(documentFragment, node);
196
+ parent.removeChild(node);
197
+ subject.next();
198
+ });
199
+ currentScope.run(() => {
200
+ });
201
+ });
202
+ return (_ctx, _cache) => {
203
+ return openBlock(), createElementBlock(Fragment, null, [
204
+ createElementVNode("div", {
205
+ class: normalizeClass(unref(ns).b())
206
+ }, [
207
+ createElementVNode("div", {
208
+ class: normalizeClass(unref(ns).e("editor")),
209
+ ref_key: "editorRef",
210
+ ref: editorRef
211
+ }, [
212
+ createVNode(unref(TinyMCEEditor), {
213
+ init: initOptions,
214
+ disabled: __props.disabled,
215
+ tinymceScriptSrc: "/tinymce/tinymce.js",
216
+ ref_key: "tinyMCEEditorRef",
217
+ ref: tinyMCEEditorRef
218
+ }, null, 8, ["disabled"])
219
+ ], 2)
220
+ ], 2),
221
+ (openBlock(), createBlock(Teleport, { to: "body" }, [
222
+ createElementVNode("div", {
223
+ class: normalizeClass(unref(ns).e("at-list-wrapper"))
224
+ }, [
225
+ atPersonInfos.style ? (openBlock(), createElementBlock("div", {
549
226
  key: 0,
550
- class: normalizeClass(unref(ns).e('at-list')),
227
+ class: normalizeClass(unref(ns).e("at-list")),
551
228
  style: normalizeStyle(atPersonInfos.style)
552
229
  }, [
553
230
  (openBlock(), createElementBlock(Fragment, null, renderList(4, (i) => {
554
231
  return createElementVNode("div", {
555
232
  key: i,
556
- onClick: $event => (unref(handlePersonSelect)(i))
557
- }, " 用户" + toDisplayString(i), 9 /* TEXT, PROPS */, _hoisted_1)
558
- }), 64 /* STABLE_FRAGMENT */))
559
- ], 6 /* CLASS, STYLE */))
560
- : createCommentVNode("v-if", true)
561
- ], 2 /* CLASS */)
562
- ]))
563
- ], 64 /* STABLE_FRAGMENT */))
564
- }
565
- }
566
-
567
- };
568
- var bwaRichTextTinymce = /*#__PURE__*/_export_sfc(_sfc_main, [['__file',"bwa-rich-text-tinymce.vue"]]);
233
+ onClick: ($event) => unref(handlePersonSelect)(i)
234
+ }, " \u7528\u6237" + toDisplayString(i), 9, _hoisted_1);
235
+ }), 64))
236
+ ], 6)) : createCommentVNode("v-if", true)
237
+ ], 2)
238
+ ]))
239
+ ], 64);
240
+ };
241
+ }
242
+ });
243
+ var bwaRichTextTinymce = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-rich-text-tinymce.vue"]]);
569
244
 
570
245
  export { bwaRichTextTinymce as default };