@ctzy-web-client/plugin-component-vue 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/advance-select/advance-operation.mjs +51 -37
- package/es/advance-select/advance-option.mjs +167 -97
- package/es/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.mjs +7 -0
- package/es/advance-select/advance-select.mjs +368 -310
- package/es/advance-select/index.mjs +5 -5
- package/es/application-slot/breadcrumb-item.mjs +20 -17
- package/es/application-slot/header-tools-item.mjs +20 -17
- package/es/breadcrumb-select/breadcrumb-select.mjs +134 -112
- package/es/contextmenu/contextmenu-item.mjs +19 -15
- package/es/contextmenu/contextmenu.mjs +72 -56
- package/es/data-form/data-form-item.mjs +48 -30
- package/es/data-form/data-form.mjs +213 -166
- package/es/data-form/form-components/bwa-date-picker.mjs +51 -39
- package/es/data-form/form-components/bwa-date-time-picker.mjs +56 -44
- package/es/data-form/form-components/bwa-input-float.mjs +48 -37
- package/es/data-form/form-components/bwa-input-integer.mjs +68 -50
- package/es/data-form/form-components/bwa-input.mjs +43 -32
- package/es/data-form/form-components/bwa-multi-select.mjs +40 -29
- package/es/data-form/form-components/bwa-rich-text-tinymce.mjs +554 -218
- package/es/data-form/form-components/bwa-rich-text.mjs +404 -316
- package/es/data-form/form-components/bwa-select.mjs +84 -70
- package/es/data-form/form-components/bwa-textarea.mjs +38 -27
- package/es/data-form/form-components/bwa-upload.mjs +172 -148
- package/es/data-form/form-components/bwa-user-multi-select.mjs +35 -24
- package/es/data-form/form-components/bwa-user-select.mjs +86 -61
- package/es/data-table/data-column-view.mjs +146 -115
- package/es/data-table/data-table-card.mjs +48 -40
- package/es/data-table/data-table-column.mjs +58 -45
- package/es/data-table/data-table.mjs +402 -316
- package/es/datatable-settings/datatable-settings.mjs +329 -254
- package/es/date-range/date-picker.mjs +130 -116
- package/es/date-range/date-range.mjs +215 -161
- package/es/drag-list/drag-item.mjs +56 -42
- package/es/drag-list/drag-list.mjs +60 -47
- package/es/dragable/dragable-item.mjs +23 -18
- package/es/dragable/dragable-operation.mjs +32 -24
- package/es/dragable/dragable.mjs +32 -23
- package/es/filter-panel/conditions/date-range-condition.mjs +50 -40
- package/es/filter-panel/conditions/department-condition/department-condition.mjs +99 -72
- package/es/filter-panel/conditions/department-condition/department-node.mjs +73 -59
- package/es/filter-panel/conditions/input-condition.mjs +90 -76
- package/es/filter-panel/conditions/multi-user-condition.mjs +67 -57
- package/es/filter-panel/conditions/multiple-menu-condition.mjs +54 -35
- package/es/filter-panel/conditions/single-menu-condition.mjs +65 -60
- package/es/filter-panel/conditions/single-user-condition.mjs +67 -57
- package/es/filter-panel/filter-panel-item.mjs +54 -39
- package/es/filter-panel/filter-panel.mjs +153 -135
- package/es/layout/layout.mjs +85 -78
- package/es/menu/menu-item.mjs +67 -52
- package/es/menu/menu.mjs +70 -53
- package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs +28 -0
- package/es/panel/panel.mjs +53 -40
- package/es/pct-filter-panel/pct-compents/pct-Input-condition.mjs +74 -63
- package/es/pct-filter-panel/pct-compents/pct-date-range-condition.mjs +76 -67
- package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +406 -178
- package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +153 -138
- package/es/pct-filter-panel/pct-filter-panel-item.mjs +55 -40
- package/es/pct-filter-panel/pct-filter-panel.mjs +247 -227
- package/es/progress/progress-item.mjs +81 -61
- package/es/progress/progress.mjs +78 -64
- package/es/where-filter-panel/where-filter-panel.mjs +15 -12
- package/lib/advance-select/advance-operation.js +50 -36
- package/lib/advance-select/advance-option.js +166 -96
- package/lib/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.js +12 -0
- package/lib/advance-select/advance-select.js +366 -308
- package/lib/application-slot/breadcrumb-item.js +19 -16
- package/lib/application-slot/header-tools-item.js +19 -16
- package/lib/breadcrumb-select/breadcrumb-select.js +133 -111
- package/lib/contextmenu/contextmenu-item.js +18 -14
- package/lib/contextmenu/contextmenu.js +71 -55
- package/lib/data-form/data-form-item.js +47 -29
- package/lib/data-form/data-form.js +212 -165
- package/lib/data-form/form-components/bwa-date-picker.js +50 -38
- package/lib/data-form/form-components/bwa-date-time-picker.js +55 -43
- package/lib/data-form/form-components/bwa-input-float.js +47 -36
- package/lib/data-form/form-components/bwa-input-integer.js +67 -49
- package/lib/data-form/form-components/bwa-input.js +42 -31
- package/lib/data-form/form-components/bwa-multi-select.js +39 -28
- package/lib/data-form/form-components/bwa-rich-text-tinymce.js +553 -217
- package/lib/data-form/form-components/bwa-rich-text.js +403 -315
- package/lib/data-form/form-components/bwa-select.js +83 -69
- package/lib/data-form/form-components/bwa-textarea.js +37 -26
- package/lib/data-form/form-components/bwa-upload.js +171 -147
- package/lib/data-form/form-components/bwa-user-multi-select.js +34 -23
- package/lib/data-form/form-components/bwa-user-select.js +85 -60
- package/lib/data-table/data-column-view.js +146 -115
- package/lib/data-table/data-table-card.js +48 -40
- package/lib/data-table/data-table-column.js +57 -44
- package/lib/data-table/data-table.js +401 -315
- package/lib/datatable-settings/datatable-settings.js +328 -253
- package/lib/date-range/date-picker.js +129 -115
- package/lib/date-range/date-range.js +214 -160
- package/lib/drag-list/drag-item.js +55 -41
- package/lib/drag-list/drag-list.js +59 -46
- package/lib/dragable/dragable-item.js +22 -17
- package/lib/dragable/dragable-operation.js +31 -23
- package/lib/dragable/dragable.js +31 -22
- package/lib/filter-panel/conditions/date-range-condition.js +49 -39
- package/lib/filter-panel/conditions/department-condition/department-condition.js +98 -71
- package/lib/filter-panel/conditions/department-condition/department-node.js +72 -58
- package/lib/filter-panel/conditions/input-condition.js +89 -75
- package/lib/filter-panel/conditions/multi-user-condition.js +66 -56
- package/lib/filter-panel/conditions/multiple-menu-condition.js +53 -34
- package/lib/filter-panel/conditions/single-menu-condition.js +64 -59
- package/lib/filter-panel/conditions/single-user-condition.js +66 -56
- package/lib/filter-panel/filter-panel-item.js +53 -38
- package/lib/filter-panel/filter-panel.js +152 -134
- package/lib/layout/layout.js +84 -77
- package/lib/menu/menu-item.js +66 -51
- package/lib/menu/menu.js +69 -52
- package/lib/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +32 -0
- package/lib/panel/panel.js +52 -39
- package/lib/pct-filter-panel/pct-compents/pct-Input-condition.js +73 -62
- package/lib/pct-filter-panel/pct-compents/pct-date-range-condition.js +75 -66
- package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +405 -177
- package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +152 -137
- package/lib/pct-filter-panel/pct-filter-panel-item.js +54 -39
- package/lib/pct-filter-panel/pct-filter-panel.js +246 -226
- package/lib/progress/progress-item.js +80 -60
- package/lib/progress/progress.js +77 -63
- package/lib/where-filter-panel/where-filter-panel.js +14 -11
- package/package.json +2 -1
- package/src/advance-select/advance-option.vue +64 -13
- package/src/data-form/form-components/bwa-rich-text-tinymce.vue +1 -1
- package/src/datatable-settings/datatable-settings.vue +33 -3
- package/src/date-range/date-picker.vue +1 -1
- package/src/filter-panel/filter-panel.vue +2 -2
- package/src/pct-filter-panel/pct-compents/pct-Input-condition.vue +64 -64
- package/src/pct-filter-panel/pct-compents/pct-date-range-condition.vue +61 -61
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +302 -178
- package/src/pct-filter-panel/pct-filter-panel.vue +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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';
|
|
@@ -6,229 +6,565 @@ import { Subject, Observable, map, filter, mergeMap, merge, from, delayWhen, tim
|
|
|
6
6
|
import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
|
|
7
7
|
|
|
8
8
|
const _hoisted_1 = ["onClick"];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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'],
|
|
27
29
|
setup(__props, { emit }) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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", {
|
|
215
549
|
key: 0,
|
|
216
|
-
class: normalizeClass(unref(ns).e(
|
|
550
|
+
class: normalizeClass(unref(ns).e('at-list')),
|
|
217
551
|
style: normalizeStyle(atPersonInfos.style)
|
|
218
552
|
}, [
|
|
219
553
|
(openBlock(), createElementBlock(Fragment, null, renderList(4, (i) => {
|
|
220
554
|
return createElementVNode("div", {
|
|
221
555
|
key: i,
|
|
222
|
-
onClick:
|
|
223
|
-
}, "
|
|
224
|
-
}), 64))
|
|
225
|
-
], 6
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
|
|
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
569
|
|
|
234
570
|
export { bwaRichTextTinymce as default };
|