@ctzy-web-client/plugin-component-vue 1.0.22 → 1.0.24

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 (132) hide show
  1. package/es/advance-select/advance-operation.mjs +51 -37
  2. package/es/advance-select/advance-option.mjs +167 -97
  3. package/es/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.mjs +7 -0
  4. package/es/advance-select/advance-select.mjs +368 -310
  5. package/es/advance-select/index.mjs +5 -5
  6. package/es/application-slot/breadcrumb-item.mjs +20 -17
  7. package/es/application-slot/header-tools-item.mjs +20 -17
  8. package/es/breadcrumb-select/breadcrumb-select.mjs +134 -112
  9. package/es/contextmenu/contextmenu-item.mjs +19 -15
  10. package/es/contextmenu/contextmenu.mjs +72 -56
  11. package/es/data-form/data-form-item.mjs +48 -30
  12. package/es/data-form/data-form.mjs +213 -166
  13. package/es/data-form/form-components/bwa-date-picker.mjs +51 -39
  14. package/es/data-form/form-components/bwa-date-time-picker.mjs +56 -44
  15. package/es/data-form/form-components/bwa-input-float.mjs +48 -37
  16. package/es/data-form/form-components/bwa-input-integer.mjs +68 -50
  17. package/es/data-form/form-components/bwa-input.mjs +43 -32
  18. package/es/data-form/form-components/bwa-multi-select.mjs +40 -29
  19. package/es/data-form/form-components/bwa-rich-text-tinymce.mjs +554 -218
  20. package/es/data-form/form-components/bwa-rich-text.mjs +404 -316
  21. package/es/data-form/form-components/bwa-select.mjs +84 -70
  22. package/es/data-form/form-components/bwa-textarea.mjs +38 -27
  23. package/es/data-form/form-components/bwa-upload.mjs +172 -148
  24. package/es/data-form/form-components/bwa-user-multi-select.mjs +35 -24
  25. package/es/data-form/form-components/bwa-user-select.mjs +86 -61
  26. package/es/data-table/data-column-view.mjs +146 -115
  27. package/es/data-table/data-table-card.mjs +48 -40
  28. package/es/data-table/data-table-column.mjs +58 -45
  29. package/es/data-table/data-table.mjs +402 -316
  30. package/es/datatable-settings/datatable-settings.mjs +329 -254
  31. package/es/date-range/date-picker.mjs +130 -116
  32. package/es/date-range/date-range.mjs +215 -168
  33. package/es/drag-list/drag-item.mjs +56 -42
  34. package/es/drag-list/drag-list.mjs +60 -47
  35. package/es/dragable/dragable-item.mjs +23 -18
  36. package/es/dragable/dragable-operation.mjs +32 -24
  37. package/es/dragable/dragable.mjs +32 -23
  38. package/es/filter-panel/conditions/date-range-condition.mjs +50 -40
  39. package/es/filter-panel/conditions/department-condition/department-condition.mjs +99 -72
  40. package/es/filter-panel/conditions/department-condition/department-node.mjs +73 -59
  41. package/es/filter-panel/conditions/input-condition.mjs +90 -76
  42. package/es/filter-panel/conditions/multi-user-condition.mjs +67 -57
  43. package/es/filter-panel/conditions/multiple-menu-condition.mjs +54 -35
  44. package/es/filter-panel/conditions/single-menu-condition.mjs +65 -60
  45. package/es/filter-panel/conditions/single-user-condition.mjs +67 -57
  46. package/es/filter-panel/filter-panel-item.mjs +54 -39
  47. package/es/filter-panel/filter-panel.mjs +153 -135
  48. package/es/layout/layout.mjs +85 -78
  49. package/es/menu/menu-item.mjs +67 -52
  50. package/es/menu/menu.mjs +70 -53
  51. package/es/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.mjs +28 -0
  52. package/es/panel/panel.mjs +53 -40
  53. package/es/pct-filter-panel/pct-compents/pct-Input-condition.mjs +74 -63
  54. package/es/pct-filter-panel/pct-compents/pct-date-range-condition.mjs +76 -67
  55. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +406 -178
  56. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +153 -138
  57. package/es/pct-filter-panel/pct-filter-panel-item.mjs +55 -40
  58. package/es/pct-filter-panel/pct-filter-panel.mjs +247 -227
  59. package/es/progress/progress-item.mjs +81 -61
  60. package/es/progress/progress.mjs +78 -64
  61. package/es/where-filter-panel/where-filter-panel.mjs +15 -12
  62. package/lib/advance-select/advance-operation.js +50 -36
  63. package/lib/advance-select/advance-option.js +166 -96
  64. package/lib/advance-select/advance-option.vue_vue_type_style_index_0_scoped_bc8f5626_lang.js +12 -0
  65. package/lib/advance-select/advance-select.js +366 -308
  66. package/lib/application-slot/breadcrumb-item.js +19 -16
  67. package/lib/application-slot/header-tools-item.js +19 -16
  68. package/lib/breadcrumb-select/breadcrumb-select.js +133 -111
  69. package/lib/contextmenu/contextmenu-item.js +18 -14
  70. package/lib/contextmenu/contextmenu.js +71 -55
  71. package/lib/data-form/data-form-item.js +47 -29
  72. package/lib/data-form/data-form.js +212 -165
  73. package/lib/data-form/form-components/bwa-date-picker.js +50 -38
  74. package/lib/data-form/form-components/bwa-date-time-picker.js +55 -43
  75. package/lib/data-form/form-components/bwa-input-float.js +47 -36
  76. package/lib/data-form/form-components/bwa-input-integer.js +67 -49
  77. package/lib/data-form/form-components/bwa-input.js +42 -31
  78. package/lib/data-form/form-components/bwa-multi-select.js +39 -28
  79. package/lib/data-form/form-components/bwa-rich-text-tinymce.js +553 -217
  80. package/lib/data-form/form-components/bwa-rich-text.js +403 -315
  81. package/lib/data-form/form-components/bwa-select.js +83 -69
  82. package/lib/data-form/form-components/bwa-textarea.js +37 -26
  83. package/lib/data-form/form-components/bwa-upload.js +171 -147
  84. package/lib/data-form/form-components/bwa-user-multi-select.js +34 -23
  85. package/lib/data-form/form-components/bwa-user-select.js +85 -60
  86. package/lib/data-table/data-column-view.js +146 -115
  87. package/lib/data-table/data-table-card.js +48 -40
  88. package/lib/data-table/data-table-column.js +57 -44
  89. package/lib/data-table/data-table.js +401 -315
  90. package/lib/datatable-settings/datatable-settings.js +328 -253
  91. package/lib/date-range/date-picker.js +129 -115
  92. package/lib/date-range/date-range.js +213 -170
  93. package/lib/drag-list/drag-item.js +55 -41
  94. package/lib/drag-list/drag-list.js +59 -46
  95. package/lib/dragable/dragable-item.js +22 -17
  96. package/lib/dragable/dragable-operation.js +31 -23
  97. package/lib/dragable/dragable.js +31 -22
  98. package/lib/filter-panel/conditions/date-range-condition.js +49 -39
  99. package/lib/filter-panel/conditions/department-condition/department-condition.js +98 -71
  100. package/lib/filter-panel/conditions/department-condition/department-node.js +72 -58
  101. package/lib/filter-panel/conditions/input-condition.js +89 -75
  102. package/lib/filter-panel/conditions/multi-user-condition.js +66 -56
  103. package/lib/filter-panel/conditions/multiple-menu-condition.js +53 -34
  104. package/lib/filter-panel/conditions/single-menu-condition.js +64 -59
  105. package/lib/filter-panel/conditions/single-user-condition.js +66 -56
  106. package/lib/filter-panel/filter-panel-item.js +53 -38
  107. package/lib/filter-panel/filter-panel.js +152 -134
  108. package/lib/layout/layout.js +84 -77
  109. package/lib/menu/menu-item.js +66 -51
  110. package/lib/menu/menu.js +69 -52
  111. package/lib/node_modules/.pnpm/style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js +32 -0
  112. package/lib/panel/panel.js +52 -39
  113. package/lib/pct-filter-panel/pct-compents/pct-Input-condition.js +73 -62
  114. package/lib/pct-filter-panel/pct-compents/pct-date-range-condition.js +75 -66
  115. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +405 -177
  116. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +152 -137
  117. package/lib/pct-filter-panel/pct-filter-panel-item.js +54 -39
  118. package/lib/pct-filter-panel/pct-filter-panel.js +246 -226
  119. package/lib/progress/progress-item.js +80 -60
  120. package/lib/progress/progress.js +77 -63
  121. package/lib/where-filter-panel/where-filter-panel.js +14 -11
  122. package/package.json +2 -1
  123. package/src/advance-select/advance-option.vue +64 -13
  124. package/src/data-form/form-components/bwa-rich-text-tinymce.vue +1 -1
  125. package/src/datatable-settings/datatable-settings.vue +33 -3
  126. package/src/date-range/date-picker.vue +1 -1
  127. package/src/date-range/date-range.vue +3 -3
  128. package/src/filter-panel/filter-panel.vue +2 -2
  129. package/src/pct-filter-panel/pct-compents/pct-Input-condition.vue +64 -64
  130. package/src/pct-filter-panel/pct-compents/pct-date-range-condition.vue +61 -61
  131. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +302 -178
  132. package/src/pct-filter-panel/pct-filter-panel.vue +4 -4
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, getCurrentScope, computed, reactive, onMounted, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, createVNode, createBlock, Teleport, normalizeStyle, renderList, toDisplayString, createCommentVNode } from 'vue';
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
- const __default__ = defineComponent({
10
- name: "BwaRichText"
11
- });
12
- const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
13
- props: {
14
- placeholder: {
15
- type: String,
16
- default: ""
17
- },
18
- modelValue: {
19
- type: null
20
- },
21
- disabled: {
22
- type: Boolean,
23
- default: false
24
- }
25
- },
26
- emits: ["update:modelValue"],
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
- const props = __props;
29
- let resolve = null;
30
- const setupPromise = new Promise((relv) => {
31
- resolve = relv;
32
- });
33
- const initOptions = {
34
- promotion: false,
35
- language: "zh-Hans",
36
- setup: resolve
37
- };
38
- const ns = useNamespace("rich-text");
39
- const fileService = useService("FileService");
40
- const editorRef = ref(null);
41
- const tinyMCEEditorRef = ref(null);
42
- const currentScope = getCurrentScope();
43
- const value = computed({
44
- get: () => props.modelValue || "",
45
- set: (v) => {
46
- emit("update:modelValue", v);
47
- }
48
- });
49
- const focusing = ref(false);
50
- const AT_REGEXP = /[^\da-zA-Z]@[^@]*$/;
51
- const atPersonInfos = reactive({
52
- node: null,
53
- content: "",
54
- selection: null,
55
- index: -1,
56
- style: null
57
- });
58
- const selectPersonSubject = new Subject();
59
- const handlePersonSelect = selectPersonSubject.next.bind(selectPersonSubject);
60
- window.atPersonInfos = atPersonInfos;
61
- onMounted(async () => {
62
- const editor = await setupPromise;
63
- window.editor = editor;
64
- const inputObservable = new Observable((observer) => {
65
- const next = observer.next.bind(observer);
66
- editor.on("input", next);
67
- return () => {
68
- editor.off("input", next);
69
- };
70
- });
71
- editor.on("change", (event) => {
72
- console.log(event);
73
- });
74
- const getSelection = (event) => {
75
- if (typeof event.target.nodeType === "number" && typeof event.target.tagName === "string") {
76
- return event.target.ownerDocument.getSelection();
77
- }
78
- return event.target.iframeElement.contentDocument.getSelection();
79
- };
80
- const subject = new Subject();
81
- inputObservable.pipe(
82
- map((event) => {
83
- if (event.data !== "@") {
84
- return null;
85
- }
86
- const selection = event.currentTarget.ownerDocument.getSelection();
87
- const focusNode = selection.focusNode;
88
- if (focusNode.nodeType !== Node.TEXT_NODE) {
89
- return null;
90
- }
91
- const content = focusNode.data.slice(0, selection.focusOffset);
92
- const match = content.match(AT_REGEXP);
93
- if (!match) {
94
- return null;
95
- }
96
- return {
97
- event,
98
- selection,
99
- index: match[0].indexOf("@") + match.index,
100
- node: focusNode,
101
- content,
102
- range: selection.getRangeAt(0)
103
- };
104
- }),
105
- filter(Boolean),
106
- mergeMap(({ event, index, node, content, range }) => {
107
- const changeObservable = new Observable((observer) => {
108
- const next = observer.next.bind(observer);
109
- editor.on("change input undo redo", next);
110
- return () => {
111
- editor.off("change input undo redo", next);
112
- };
113
- });
114
- return merge(from([event]), changeObservable).pipe(
115
- delayWhen(() => timer(0)),
116
- map((event2) => {
117
- const selection = getSelection(event2);
118
- const content2 = node.data.slice(index, selection.focusOffset);
119
- console.log(content2);
120
- if (!content2) {
121
- subject.next();
122
- return null;
123
- }
124
- return {
125
- index,
126
- node,
127
- content: content2,
128
- range: selection.getRangeAt(0)
129
- };
130
- }),
131
- filter(Boolean),
132
- takeUntil(
133
- merge(
134
- inputObservable.pipe(filter((event2) => event2.data === "@")),
135
- subject
136
- ).pipe(
137
- tap(() => {
138
- atPersonInfos.node = null;
139
- atPersonInfos.content = "";
140
- atPersonInfos.selection = null;
141
- atPersonInfos.index = -1;
142
- atPersonInfos.style = null;
143
- })
144
- )
145
- )
146
- );
147
- })
148
- ).subscribe(({ index, node, selection, content, range }) => {
149
- const searchContent = content.slice(1);
150
- const { x: offsetX, y: offsetY, height } = range.getBoundingClientRect();
151
- const iframeElement = editor.iframeElement;
152
- const { x: iframeX, y: iframeY } = iframeElement.getBoundingClientRect();
153
- atPersonInfos.node = node;
154
- atPersonInfos.content = content;
155
- atPersonInfos.selection = selection;
156
- atPersonInfos.index = index;
157
- atPersonInfos.style = {
158
- "--left": iframeX + offsetX + "px",
159
- "--top": iframeY + offsetY + height + "px"
160
- };
161
- });
162
- selectPersonSubject.subscribe(() => {
163
- if (!atPersonInfos.node) {
164
- return;
165
- }
166
- const { node, index, content } = atPersonInfos;
167
- const document = node.ownerDocument;
168
- const documentFragment = document.createDocumentFragment();
169
- if (index) {
170
- const textNode = document.createTextNode(node.data.slice(0, index));
171
- documentFragment.appendChild(textNode);
172
- }
173
- const span = document.createElement("span");
174
- span.innerText = content;
175
- documentFragment.appendChild(span);
176
- const contentEndIndex = index + content.length;
177
- if (contentEndIndex < node.data.length) {
178
- const textNode = document.createTextNode(
179
- node.data.slice(contentEndIndex)
180
- );
181
- documentFragment.appendChild(textNode);
182
- }
183
- const parent = node.parentElement;
184
- parent.insertBefore(documentFragment, node);
185
- parent.removeChild(node);
186
- subject.next();
187
- });
188
- currentScope.run(() => {
189
- });
190
- });
191
- return (_ctx, _cache) => {
192
- return openBlock(), createElementBlock(Fragment, null, [
193
- createElementVNode("div", {
194
- class: normalizeClass(unref(ns).b())
195
- }, [
196
- createElementVNode("div", {
197
- class: normalizeClass(unref(ns).e("editor")),
198
- ref_key: "editorRef",
199
- ref: editorRef
200
- }, [
201
- createVNode(unref(TinyMCEEditor), {
202
- init: initOptions,
203
- disabled: __props.disabled,
204
- tinymceScriptSrc: "/tinymce/tinymce.js",
205
- ref_key: "tinyMCEEditorRef",
206
- ref: tinyMCEEditorRef
207
- }, null, 8, ["disabled"])
208
- ], 2)
209
- ], 2),
210
- (openBlock(), createBlock(Teleport, { to: "body" }, [
211
- createElementVNode("div", {
212
- class: normalizeClass(unref(ns).e("at-list-wrapper"))
213
- }, [
214
- atPersonInfos.style ? (openBlock(), createElementBlock("div", {
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("at-list")),
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: ($event) => unref(handlePersonSelect)(i)
223
- }, " \u7528\u6237" + toDisplayString(i), 9, _hoisted_1);
224
- }), 64))
225
- ], 6)) : createCommentVNode("v-if", true)
226
- ], 2)
227
- ]))
228
- ], 64);
229
- };
230
- }
231
- });
232
- var bwaRichTextTinymce = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-rich-text-tinymce.vue"]]);
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 };