@ctzy-web-client/plugin-component-vue 1.0.0 → 1.0.1

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 (272) hide show
  1. package/es/_virtual/_plugin-vue_export-helper.mjs +9 -0
  2. package/es/advance-select/advance-operation.mjs +43 -0
  3. package/es/advance-select/advance-option.mjs +125 -0
  4. package/es/advance-select/advance-select.mjs +359 -0
  5. package/es/advance-select/events-helpers.mjs +29 -0
  6. package/es/advance-select/index.mjs +13 -0
  7. package/es/advance-select/use-advance-option.mjs +43 -0
  8. package/es/advance-select/use-advance-select.mjs +117 -0
  9. package/es/application-slot/application-slot.mjs +51 -0
  10. package/es/application-slot/breadcrumb-item.mjs +23 -0
  11. package/es/application-slot/header-tools-item.mjs +23 -0
  12. package/es/application-slot/index.mjs +16 -0
  13. package/es/breadcrumb-select/breadcrumb-select.mjs +155 -0
  14. package/es/breadcrumb-select/index.mjs +6 -0
  15. package/es/components.mjs +22 -0
  16. package/es/contextmenu/contextmenu-item.mjs +21 -0
  17. package/es/contextmenu/contextmenu.mjs +64 -0
  18. package/es/contextmenu/index.mjs +10 -0
  19. package/es/contextmenu/use-contextmenu.mjs +85 -0
  20. package/es/data-form/data-form-item.mjs +53 -0
  21. package/es/data-form/data-form.mjs +175 -0
  22. package/es/data-form/dynamic-component.mjs +23 -0
  23. package/es/data-form/form-components/Blots/AtBlot.mjs +25 -0
  24. package/es/data-form/form-components/bwa-date-picker.mjs +45 -0
  25. package/es/data-form/form-components/bwa-date-time-picker.mjs +50 -0
  26. package/es/data-form/form-components/bwa-input-float.mjs +43 -0
  27. package/es/data-form/form-components/bwa-input-integer.mjs +56 -0
  28. package/es/data-form/form-components/bwa-input.mjs +38 -0
  29. package/es/data-form/form-components/bwa-multi-select.mjs +35 -0
  30. package/es/data-form/form-components/bwa-rich-text-tinymce.mjs +234 -0
  31. package/es/data-form/form-components/bwa-rich-text.mjs +325 -0
  32. package/es/data-form/form-components/bwa-select.mjs +76 -0
  33. package/es/data-form/form-components/bwa-textarea.mjs +33 -0
  34. package/es/data-form/form-components/bwa-upload.mjs +159 -0
  35. package/es/data-form/form-components/bwa-user-multi-select.mjs +30 -0
  36. package/es/data-form/form-components/bwa-user-select.mjs +69 -0
  37. package/es/data-form/index.mjs +34 -0
  38. package/es/data-table/data-column-view.mjs +131 -0
  39. package/es/data-table/data-table-card.mjs +118 -0
  40. package/es/data-table/data-table-column.mjs +56 -0
  41. package/es/data-table/data-table.mjs +369 -0
  42. package/es/data-table/dynamic-component.mjs +48 -0
  43. package/es/data-table/index.mjs +13 -0
  44. package/es/data-table/use-datatable-drag.mjs +110 -0
  45. package/es/datatable-settings/datatable-settings.mjs +309 -0
  46. package/es/datatable-settings/index.mjs +6 -0
  47. package/es/date-range/date-picker.mjs +128 -0
  48. package/es/date-range/date-range.mjs +181 -0
  49. package/es/date-range/index.mjs +6 -0
  50. package/es/drag-list/constants.mjs +3 -0
  51. package/es/drag-list/drag-item.mjs +49 -0
  52. package/es/drag-list/drag-list.mjs +56 -0
  53. package/es/drag-list/index.mjs +6 -0
  54. package/es/drag-list/use-drag-list.mjs +154 -0
  55. package/es/dragable/constants.mjs +4 -0
  56. package/es/dragable/dragable-item.mjs +25 -0
  57. package/es/dragable/dragable-operation.mjs +32 -0
  58. package/es/dragable/dragable.mjs +31 -0
  59. package/es/dragable/index.mjs +15 -0
  60. package/es/dragable/use-dragable.mjs +134 -0
  61. package/es/filter-panel/conditions/condition.mjs +30 -0
  62. package/es/filter-panel/conditions/date-range-condition.mjs +46 -0
  63. package/es/filter-panel/conditions/department-condition/department-condition.mjs +81 -0
  64. package/es/filter-panel/conditions/department-condition/department-node.mjs +74 -0
  65. package/es/filter-panel/conditions/index.mjs +21 -0
  66. package/es/filter-panel/conditions/input-condition.mjs +83 -0
  67. package/es/filter-panel/conditions/multi-user-condition.mjs +64 -0
  68. package/es/filter-panel/conditions/multiple-menu-condition.mjs +41 -0
  69. package/es/filter-panel/conditions/single-menu-condition.mjs +68 -0
  70. package/es/filter-panel/conditions/single-user-condition.mjs +64 -0
  71. package/es/filter-panel/filter-panel-item.mjs +47 -0
  72. package/es/filter-panel/filter-panel.mjs +180 -0
  73. package/es/filter-panel/index.mjs +15 -0
  74. package/es/filter-panel/use-filter-panel-item.mjs +52 -0
  75. package/es/filter-panel/use-filter-panel.mjs +135 -0
  76. package/es/hooks/use-data/index.mjs +152 -0
  77. package/es/index.mjs +27 -0
  78. package/es/layout/index.mjs +6 -0
  79. package/es/layout/layout.mjs +86 -0
  80. package/es/make-installer.mjs +34 -0
  81. package/es/math/Rectangle.mjs +25 -0
  82. package/es/menu/index.mjs +6 -0
  83. package/es/menu/menu-item.mjs +75 -0
  84. package/es/menu/menu.mjs +60 -0
  85. package/es/node_modules/.pnpm/@vueuse_core@9.6.0_vue@3.2.41/node_modules/@vueuse/core/index.mjs +6372 -0
  86. package/es/node_modules/.pnpm/@vueuse_shared@9.6.0_vue@3.2.41/node_modules/@vueuse/shared/index.mjs +1517 -0
  87. package/es/panel/index.mjs +6 -0
  88. package/es/panel/panel.mjs +55 -0
  89. package/es/panel-tabs/index.mjs +6 -0
  90. package/es/panel-tabs/panel-tabs.mjs +66 -0
  91. package/es/pct-filter-panel/index.mjs +10 -0
  92. package/es/pct-filter-panel/pct-compents/index.mjs +10 -0
  93. package/es/pct-filter-panel/pct-compents/pct-Input-condition.mjs +71 -0
  94. package/es/pct-filter-panel/pct-compents/pct-date-range-condition.mjs +74 -0
  95. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +186 -0
  96. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +147 -0
  97. package/es/pct-filter-panel/pct-filter-panel-item.mjs +48 -0
  98. package/es/pct-filter-panel/pct-filter-panel.mjs +251 -0
  99. package/es/pct-filter-panel/use-filter-panel-item.mjs +56 -0
  100. package/es/pct-filter-panel/use-filter-panel.mjs +127 -0
  101. package/es/plugins.mjs +5 -0
  102. package/es/progress/index.mjs +10 -0
  103. package/es/progress/progress-item.mjs +68 -0
  104. package/es/progress/progress.mjs +74 -0
  105. package/es/progress/use-progress.mjs +46 -0
  106. package/es/utils/db.mjs +9 -0
  107. package/es/utils.mjs +99 -0
  108. package/es/where-filter-panel/index.mjs +1 -0
  109. package/es/where-filter-panel/use-where-filter-panel.mjs +18 -0
  110. package/es/where-filter-panel/where-filter-panel.mjs +17 -0
  111. package/lib/_virtual/_plugin-vue_export-helper.js +13 -0
  112. package/lib/advance-select/advance-operation.js +47 -0
  113. package/lib/advance-select/advance-option.js +129 -0
  114. package/lib/advance-select/advance-select.js +363 -0
  115. package/lib/advance-select/events-helpers.js +33 -0
  116. package/lib/advance-select/index.js +20 -0
  117. package/lib/advance-select/use-advance-option.js +47 -0
  118. package/lib/advance-select/use-advance-select.js +122 -0
  119. package/lib/application-slot/application-slot.js +55 -0
  120. package/lib/application-slot/breadcrumb-item.js +27 -0
  121. package/lib/application-slot/header-tools-item.js +27 -0
  122. package/lib/application-slot/index.js +23 -0
  123. package/lib/breadcrumb-select/breadcrumb-select.js +159 -0
  124. package/lib/breadcrumb-select/index.js +11 -0
  125. package/lib/components.js +26 -0
  126. package/lib/contextmenu/contextmenu-item.js +25 -0
  127. package/lib/contextmenu/contextmenu.js +68 -0
  128. package/lib/contextmenu/index.js +16 -0
  129. package/lib/contextmenu/use-contextmenu.js +89 -0
  130. package/lib/data-form/data-form-item.js +57 -0
  131. package/lib/data-form/data-form.js +179 -0
  132. package/lib/data-form/dynamic-component.js +27 -0
  133. package/lib/data-form/form-components/Blots/AtBlot.js +31 -0
  134. package/lib/data-form/form-components/bwa-date-picker.js +49 -0
  135. package/lib/data-form/form-components/bwa-date-time-picker.js +54 -0
  136. package/lib/data-form/form-components/bwa-input-float.js +47 -0
  137. package/lib/data-form/form-components/bwa-input-integer.js +60 -0
  138. package/lib/data-form/form-components/bwa-input.js +42 -0
  139. package/lib/data-form/form-components/bwa-multi-select.js +39 -0
  140. package/lib/data-form/form-components/bwa-rich-text-tinymce.js +242 -0
  141. package/lib/data-form/form-components/bwa-rich-text.js +333 -0
  142. package/lib/data-form/form-components/bwa-select.js +80 -0
  143. package/lib/data-form/form-components/bwa-textarea.js +37 -0
  144. package/lib/data-form/form-components/bwa-upload.js +163 -0
  145. package/lib/data-form/form-components/bwa-user-multi-select.js +34 -0
  146. package/lib/data-form/form-components/bwa-user-select.js +73 -0
  147. package/lib/data-form/index.js +40 -0
  148. package/lib/data-table/data-column-view.js +135 -0
  149. package/lib/data-table/data-table-card.js +122 -0
  150. package/lib/data-table/data-table-column.js +60 -0
  151. package/lib/data-table/data-table.js +373 -0
  152. package/lib/data-table/dynamic-component.js +56 -0
  153. package/lib/data-table/index.js +20 -0
  154. package/lib/data-table/use-datatable-drag.js +114 -0
  155. package/lib/datatable-settings/datatable-settings.js +313 -0
  156. package/lib/datatable-settings/index.js +11 -0
  157. package/lib/date-range/date-picker.js +136 -0
  158. package/lib/date-range/date-range.js +189 -0
  159. package/lib/date-range/index.js +11 -0
  160. package/lib/drag-list/constants.js +7 -0
  161. package/lib/drag-list/drag-item.js +53 -0
  162. package/lib/drag-list/drag-list.js +60 -0
  163. package/lib/drag-list/index.js +11 -0
  164. package/lib/drag-list/use-drag-list.js +158 -0
  165. package/lib/dragable/constants.js +9 -0
  166. package/lib/dragable/dragable-item.js +29 -0
  167. package/lib/dragable/dragable-operation.js +36 -0
  168. package/lib/dragable/dragable.js +35 -0
  169. package/lib/dragable/index.js +22 -0
  170. package/lib/dragable/use-dragable.js +138 -0
  171. package/lib/filter-panel/conditions/condition.js +34 -0
  172. package/lib/filter-panel/conditions/date-range-condition.js +50 -0
  173. package/lib/filter-panel/conditions/department-condition/department-condition.js +85 -0
  174. package/lib/filter-panel/conditions/department-condition/department-node.js +78 -0
  175. package/lib/filter-panel/conditions/index.js +26 -0
  176. package/lib/filter-panel/conditions/input-condition.js +87 -0
  177. package/lib/filter-panel/conditions/multi-user-condition.js +68 -0
  178. package/lib/filter-panel/conditions/multiple-menu-condition.js +45 -0
  179. package/lib/filter-panel/conditions/single-menu-condition.js +72 -0
  180. package/lib/filter-panel/conditions/single-user-condition.js +68 -0
  181. package/lib/filter-panel/filter-panel-item.js +51 -0
  182. package/lib/filter-panel/filter-panel.js +184 -0
  183. package/lib/filter-panel/index.js +20 -0
  184. package/lib/filter-panel/use-filter-panel-item.js +56 -0
  185. package/lib/filter-panel/use-filter-panel.js +139 -0
  186. package/lib/hooks/use-data/index.js +157 -0
  187. package/lib/index.js +60 -0
  188. package/lib/layout/index.js +11 -0
  189. package/lib/layout/layout.js +90 -0
  190. package/lib/make-installer.js +62 -0
  191. package/lib/math/Rectangle.js +29 -0
  192. package/lib/menu/index.js +11 -0
  193. package/lib/menu/menu-item.js +79 -0
  194. package/lib/menu/menu.js +64 -0
  195. package/lib/node_modules/.pnpm/@vueuse_core@9.6.0_vue@3.2.41/node_modules/@vueuse/core/index.js +6635 -0
  196. package/lib/node_modules/.pnpm/@vueuse_shared@9.6.0_vue@3.2.41/node_modules/@vueuse/shared/index.js +1628 -0
  197. package/lib/panel/index.js +11 -0
  198. package/lib/panel/panel.js +59 -0
  199. package/lib/panel-tabs/index.js +11 -0
  200. package/lib/panel-tabs/panel-tabs.js +70 -0
  201. package/lib/pct-filter-panel/index.js +14 -0
  202. package/lib/pct-filter-panel/pct-compents/index.js +16 -0
  203. package/lib/pct-filter-panel/pct-compents/pct-Input-condition.js +75 -0
  204. package/lib/pct-filter-panel/pct-compents/pct-date-range-condition.js +78 -0
  205. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +190 -0
  206. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +151 -0
  207. package/lib/pct-filter-panel/pct-filter-panel-item.js +52 -0
  208. package/lib/pct-filter-panel/pct-filter-panel.js +255 -0
  209. package/lib/pct-filter-panel/use-filter-panel-item.js +60 -0
  210. package/lib/pct-filter-panel/use-filter-panel.js +131 -0
  211. package/lib/plugins.js +9 -0
  212. package/lib/progress/index.js +16 -0
  213. package/lib/progress/progress-item.js +72 -0
  214. package/lib/progress/progress.js +78 -0
  215. package/lib/progress/use-progress.js +51 -0
  216. package/lib/utils/db.js +17 -0
  217. package/lib/utils.js +110 -0
  218. package/lib/where-filter-panel/index.js +2 -0
  219. package/lib/where-filter-panel/use-where-filter-panel.js +22 -0
  220. package/lib/where-filter-panel/where-filter-panel.js +21 -0
  221. package/package.json +1 -1
  222. package/style/advance-select.css +1 -0
  223. package/style/breadcrumb-select.css +1 -0
  224. package/style/common.css +1 -0
  225. package/style/contextmenu.css +1 -0
  226. package/style/data-form.css +1 -0
  227. package/style/data-table.css +1 -0
  228. package/style/datatable-settings.css +1 -0
  229. package/style/date-range.css +1 -0
  230. package/style/department-condition.css +1 -0
  231. package/style/drag-list.css +1 -0
  232. package/style/dragable.css +1 -0
  233. package/style/filter-panel.css +1 -0
  234. package/style/index.css +1 -0
  235. package/style/input-condition.css +1 -0
  236. package/style/layout.css +1 -0
  237. package/style/menu.css +1 -0
  238. package/style/panel-tabs.css +1 -0
  239. package/style/panel.css +1 -0
  240. package/style/pct-filter-panel.css +1 -0
  241. package/style/progress.css +1 -0
  242. package/style/rich-text.css +1 -0
  243. package/style/var.css +1 -0
  244. /package/style/{advance-select.scss → src/advance-select.scss} +0 -0
  245. /package/style/{breadcrumb-select.scss → src/breadcrumb-select.scss} +0 -0
  246. /package/style/{common → src/common}/var.scss +0 -0
  247. /package/style/{common.scss → src/common.scss} +0 -0
  248. /package/style/{contextmenu.scss → src/contextmenu.scss} +0 -0
  249. /package/style/{data-form.scss → src/data-form.scss} +0 -0
  250. /package/style/{data-table.scss → src/data-table.scss} +0 -0
  251. /package/style/{datatable-settings.scss → src/datatable-settings.scss} +0 -0
  252. /package/style/{date-range.scss → src/date-range.scss} +0 -0
  253. /package/style/{department-condition.scss → src/department-condition.scss} +0 -0
  254. /package/style/{drag-list.scss → src/drag-list.scss} +0 -0
  255. /package/style/{dragable.scss → src/dragable.scss} +0 -0
  256. /package/style/{filter-panel.scss → src/filter-panel.scss} +0 -0
  257. /package/style/{index.scss → src/index.scss} +0 -0
  258. /package/style/{input-condition.scss → src/input-condition.scss} +0 -0
  259. /package/style/{layout.scss → src/layout.scss} +0 -0
  260. /package/style/{menu.scss → src/menu.scss} +0 -0
  261. /package/style/{mixins → src/mixins}/_var.scss +0 -0
  262. /package/style/{mixins → src/mixins}/config.scss +0 -0
  263. /package/style/{mixins → src/mixins}/function.scss +0 -0
  264. /package/style/{mixins → src/mixins}/mixins.scss +0 -0
  265. /package/style/{panel-tabs.scss → src/panel-tabs.scss} +0 -0
  266. /package/style/{panel.scss → src/panel.scss} +0 -0
  267. /package/style/{pct-filter-panel.scss → src/pct-filter-panel.scss} +0 -0
  268. /package/style/{progress.scss → src/progress.scss} +0 -0
  269. /package/style/{rich-text.scss → src/rich-text.scss} +0 -0
  270. /package/style/{theme → src/theme}/theme.scss +0 -0
  271. /package/style/{theme → src/theme}/var.scss +0 -0
  272. /package/style/{var.scss → src/var.scss} +0 -0
@@ -0,0 +1,234 @@
1
+ import { defineComponent, ref, getCurrentScope, computed, reactive, onMounted, openBlock, createElementBlock, Fragment, createElementVNode, normalizeClass, unref, createVNode, createBlock, Teleport, normalizeStyle, renderList, toDisplayString, createCommentVNode } from 'vue';
2
+ import { useNamespace, useService } from 'web-base-client-vue';
3
+ import TinyMCEEditor from '@tinymce/tinymce-vue';
4
+ import 'quill/dist/quill.snow.css';
5
+ import { Subject, Observable, map, filter, mergeMap, merge, from, delayWhen, timer, takeUntil, tap } from 'rxjs';
6
+ import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
7
+
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"],
27
+ 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", {
215
+ key: 0,
216
+ class: normalizeClass(unref(ns).e("at-list")),
217
+ style: normalizeStyle(atPersonInfos.style)
218
+ }, [
219
+ (openBlock(), createElementBlock(Fragment, null, renderList(4, (i) => {
220
+ return createElementVNode("div", {
221
+ 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"]]);
233
+
234
+ export { bwaRichTextTinymce as default };
@@ -0,0 +1,325 @@
1
+ import { defineComponent, ref, unref, getCurrentScope, computed, onMounted, markRaw, watch, onScopeDispose, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, createVNode, withCtx, Fragment, renderList, createBlock } from 'vue';
2
+ import { useService, useNamespace } from 'web-base-client-vue';
3
+ import Quill from 'quill';
4
+ import 'quill/dist/quill.snow.css';
5
+ import { ElMessage } from 'element-plus';
6
+ import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
7
+
8
+ const __default__ = defineComponent({
9
+ name: "BwaRichText"
10
+ });
11
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
12
+ props: {
13
+ placeholder: {
14
+ type: String,
15
+ default: ""
16
+ },
17
+ modelValue: {
18
+ type: null
19
+ },
20
+ disabled: {
21
+ type: Boolean,
22
+ default: false
23
+ },
24
+ showAt: {
25
+ type: Boolean,
26
+ default: false
27
+ },
28
+ userIds: {
29
+ typee: Array,
30
+ default: () => []
31
+ }
32
+ },
33
+ emits: ["update:modelValue", "update:userIds"],
34
+ setup(__props, { expose, emit }) {
35
+ const props = __props;
36
+ let editor = null;
37
+ const userService = useService("UserService");
38
+ const loading = ref(false);
39
+ const userList = ref([
40
+ { value: "1", label: "\u7528\u62371" },
41
+ { value: "2", label: "\u7528\u62372" },
42
+ { value: "3", label: "\u7528\u62373" }
43
+ ]);
44
+ const handleChange = ([userId]) => {
45
+ if (!editor || !userId) {
46
+ return;
47
+ }
48
+ const userInfo = unref(userList).find((item) => item.value === userId);
49
+ if (!userInfo) {
50
+ return;
51
+ }
52
+ editor.focus();
53
+ let length = editor.getSelection() ? editor.getSelection().index || 0 : editor.getLength();
54
+ editor.insertEmbed(
55
+ length,
56
+ "at",
57
+ { id: userInfo.value, desc: userInfo.label },
58
+ "user"
59
+ );
60
+ editor.insertText(length + 1, " ");
61
+ editor.setSelection(length + 2);
62
+ };
63
+ const loadUserList = async (search = "") => {
64
+ try {
65
+ if (unref(loading)) {
66
+ return;
67
+ }
68
+ loading.value = true;
69
+ if (!unref(userService)) {
70
+ ElMessage.error("\u65E0\u6CD5\u83B7\u53D6\u7528\u6237");
71
+ return;
72
+ }
73
+ const userListResult = await unref(userService).getUserList({
74
+ name: search
75
+ });
76
+ if (userListResult.code != 0) {
77
+ ElMessage.error(userListResult.msg);
78
+ return;
79
+ }
80
+ userList.value = userListResult.data;
81
+ } finally {
82
+ loading.value = false;
83
+ }
84
+ };
85
+ const handleVisibleChange = (visible) => {
86
+ if (!visible) {
87
+ return;
88
+ }
89
+ loadUserList();
90
+ };
91
+ const virtualRef = ref(null);
92
+ ;
93
+ const ns = useNamespace("rich-text");
94
+ const fileService = useService("FileService");
95
+ const quillEditorContainer = ref(null);
96
+ const quillEditorRef = ref(null);
97
+ const currentScope = getCurrentScope();
98
+ const editorInstance = ref(null);
99
+ const toolbarOptions = [
100
+ [{ header: [1, 2, 3, 4, 5, 6, false] }],
101
+ [{ font: [] }],
102
+ ["bold", "italic", "underline", "strike"],
103
+ [{ align: [] }],
104
+ ["blockquote", "code-block"],
105
+ [{ header: 1 }, { header: 2 }],
106
+ [{ list: "ordered" }, { list: "bullet" }],
107
+ [{ script: "sub" }, { script: "super" }],
108
+ [{ indent: "-1" }, { indent: "+1" }],
109
+ [{ color: [] }, { background: [] }],
110
+ ["clean"].concat(props.showAt ? ["at"] : [])
111
+ ];
112
+ const value = computed({
113
+ get: () => props.modelValue || "",
114
+ set: (v) => {
115
+ let str = "";
116
+ if (!v && editor && editor.root.innerHTML && editor.root.innerHTML.indexOf("<img") != -1) {
117
+ str = editor.root.innerHTML;
118
+ }
119
+ emit("update:modelValue", v || str);
120
+ }
121
+ });
122
+ const userIds = computed({
123
+ get: () => props.userIds,
124
+ set: (v) => {
125
+ emit("update:userIds", v);
126
+ }
127
+ });
128
+ const updateImage = async (file) => {
129
+ if (!unref(fileService)) {
130
+ return;
131
+ }
132
+ const uploadFileResult = await unref(fileService).uploadFile(file);
133
+ if (uploadFileResult.code != 0) {
134
+ return uploadFileResult;
135
+ }
136
+ const fileID = uploadFileResult.data.id;
137
+ const filePathResult = await unref(fileService).getFilePath(fileID);
138
+ if (filePathResult.code != 0) {
139
+ return filePathResult;
140
+ }
141
+ return {
142
+ ...filePathResult,
143
+ data: { id: fileID, path: filePathResult.data }
144
+ };
145
+ };
146
+ const quillEditorRefClick = () => {
147
+ if (!editor) {
148
+ return;
149
+ }
150
+ editor.focus();
151
+ };
152
+ onMounted(() => {
153
+ editor = new Quill(unref(quillEditorRef), {
154
+ theme: "snow",
155
+ placeholder: props.placeholder,
156
+ modules: {
157
+ toolbar: {
158
+ container: toolbarOptions,
159
+ handlers: {
160
+ at: function(value2) {
161
+ }
162
+ }
163
+ }
164
+ }
165
+ });
166
+ virtualRef.value = quillEditorContainer.value.querySelector("button.ql-at");
167
+ editorInstance.value = markRaw(editor);
168
+ const el = document.createElement("div");
169
+ const getUserIds = (html) => {
170
+ el.innerHTML = html;
171
+ const items = Array.from(el.querySelectorAll("span.ptp-at-item"));
172
+ userIds.value = [
173
+ ...new Set(items.map((item) => item.getAttribute("d-id")))
174
+ ];
175
+ };
176
+ getUserIds(unref(value));
177
+ const handleTextChange = (delta, oldDelta, source) => {
178
+ const _value = editor.getText() === "\n" ? "" : editor.root.innerHTML;
179
+ value.value = _value;
180
+ getUserIds(_value);
181
+ };
182
+ const handlePaste = (evt) => {
183
+ if (evt.clipboardData && evt.clipboardData.files && evt.clipboardData.files.length) {
184
+ evt.preventDefault();
185
+ [].forEach.call(evt.clipboardData.files, async (file) => {
186
+ console.log(file);
187
+ if (file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) {
188
+ const filePathResult = await updateImage(file);
189
+ if (filePathResult.code != 0) {
190
+ return;
191
+ }
192
+ const fileData = filePathResult.data;
193
+ var range = editor.getSelection();
194
+ if (range && fileData) {
195
+ editor.insertEmbed(range.index, "image", fileData.path);
196
+ editor.formatText(range.index, 1, {
197
+ alt: fileData.id
198
+ });
199
+ setTimeout(() => {
200
+ editor.setSelection(range.index + 1);
201
+ }, 300);
202
+ }
203
+ }
204
+ });
205
+ }
206
+ };
207
+ currentScope.run(() => {
208
+ watch(
209
+ computed(() => props.disabled),
210
+ (disabled) => {
211
+ editor.enable(!disabled);
212
+ },
213
+ { immediate: true }
214
+ );
215
+ const getFilePaths = async (alt) => {
216
+ const filePathResult = await unref(fileService).getFilePath(alt);
217
+ return filePathResult;
218
+ };
219
+ let artArr2 = [];
220
+ watch(
221
+ value,
222
+ async () => {
223
+ if (unref(value).indexOf("data:image/png") != -1 || unref(value).indexOf("base64") != -1) {
224
+ editor.root.innerHTML = unref(value);
225
+ return;
226
+ }
227
+ if (!unref(value)) {
228
+ artArr2 = [];
229
+ }
230
+ let afterHtml = "";
231
+ let artArr = [];
232
+ let artArrOption = [];
233
+ if (unref(value).indexOf("<img") != -1) {
234
+ unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
235
+ if (!artArr2.includes(alt)) {
236
+ artArr.push(alt);
237
+ }
238
+ });
239
+ for (const alt of artArr) {
240
+ artArrOption.push({
241
+ alt,
242
+ src: await getFilePaths(alt)
243
+ });
244
+ }
245
+ afterHtml = unref(value).replace(/<img [^>]*alt=['"]([^'"]+)[^>]*>/gi, (img, alt) => {
246
+ var _a;
247
+ if (artArr.includes(alt)) {
248
+ return `<img src="${(_a = artArrOption.find((a) => a.alt === alt)) == null ? void 0 : _a.src.data}" alt="${alt}">`;
249
+ } else {
250
+ return img;
251
+ }
252
+ });
253
+ }
254
+ console.log("afterHtml =>", afterHtml);
255
+ artArr2 = [...artArr2, ...artArr];
256
+ artArr = [];
257
+ artArrOption = [];
258
+ if (editor.root.innerHTML === (afterHtml || unref(value))) {
259
+ return;
260
+ }
261
+ const range = editor.getSelection();
262
+ editor.root.innerHTML = afterHtml || unref(value);
263
+ setTimeout(() => {
264
+ if (range) {
265
+ editor.setSelection(range.index + 1);
266
+ editor.focus();
267
+ }
268
+ }, 100);
269
+ },
270
+ { immediate: true }
271
+ );
272
+ editor.on("text-change", handleTextChange);
273
+ editor.root.addEventListener("paste", handlePaste);
274
+ onScopeDispose(() => {
275
+ editor.off("text-change", handleTextChange);
276
+ editor.root.removeEventListener("paste", handlePaste);
277
+ });
278
+ });
279
+ });
280
+ expose({
281
+ getEditorInstance() {
282
+ return unref(editorInstance);
283
+ }
284
+ });
285
+ return (_ctx, _cache) => {
286
+ const _component_BwaAdvanceOption = resolveComponent("BwaAdvanceOption");
287
+ const _component_BwaAdvanceSelect = resolveComponent("BwaAdvanceSelect");
288
+ return openBlock(), createElementBlock("div", {
289
+ class: normalizeClass(unref(ns).b()),
290
+ ref_key: "quillEditorContainer",
291
+ ref: quillEditorContainer
292
+ }, [
293
+ createElementVNode("div", {
294
+ class: normalizeClass(unref(ns).e("editor")),
295
+ ref_key: "quillEditorRef",
296
+ ref: quillEditorRef,
297
+ onClick: quillEditorRefClick
298
+ }, null, 2),
299
+ createVNode(_component_BwaAdvanceSelect, {
300
+ showSelection: false,
301
+ "virtual-triggering": true,
302
+ "virtual-ref": virtualRef.value,
303
+ loading: loading.value,
304
+ onSearch: loadUserList,
305
+ "onUpdate:modelValue": handleChange,
306
+ onVisibleChange: handleVisibleChange
307
+ }, {
308
+ default: withCtx(() => [
309
+ (openBlock(true), createElementBlock(Fragment, null, renderList(userList.value, (item) => {
310
+ return openBlock(), createBlock(_component_BwaAdvanceOption, {
311
+ key: item.value,
312
+ value: item.value,
313
+ label: item.label
314
+ }, null, 8, ["value", "label"]);
315
+ }), 128))
316
+ ]),
317
+ _: 1
318
+ }, 8, ["virtual-ref", "loading"])
319
+ ], 2);
320
+ };
321
+ }
322
+ });
323
+ var RichText = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-rich-text.vue"]]);
324
+
325
+ export { RichText as default };
@@ -0,0 +1,76 @@
1
+ import { defineComponent, computed, useAttrs, openBlock, createBlock, unref, mergeProps, isRef, withCtx, renderSlot, createElementBlock, Fragment, renderList } from 'vue';
2
+ import { ElSelect, ElOption } from 'element-plus';
3
+ import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
4
+
5
+ const __default__ = defineComponent({
6
+ name: "BwaSelect"
7
+ });
8
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
9
+ props: {
10
+ modelValue: {
11
+ type: null
12
+ },
13
+ options: {
14
+ type: Array,
15
+ default: () => []
16
+ },
17
+ labelProp: {
18
+ type: String,
19
+ default: "label"
20
+ },
21
+ valueProp: {
22
+ type: String,
23
+ default: "value"
24
+ },
25
+ multiple: {
26
+ type: Boolean,
27
+ default: false
28
+ }
29
+ },
30
+ emits: ["update:modelValue"],
31
+ setup(__props, { emit }) {
32
+ const props = __props;
33
+ const options = computed(
34
+ () => (props.options || []).map((item) => ({
35
+ ...item,
36
+ value: item.value + ""
37
+ }))
38
+ );
39
+ const attrs = useAttrs();
40
+ const modelValue = computed({
41
+ get: () => {
42
+ if (props.multiple) {
43
+ return Array.isArray(props.modelValue) ? props.modelValue.map((item) => item + "") : [];
44
+ } else {
45
+ return props.modelValue == null ? "" : props.modelValue + "";
46
+ }
47
+ },
48
+ set: (v) => emit("update:modelValue", v)
49
+ });
50
+ return (_ctx, _cache) => {
51
+ return openBlock(), createBlock(unref(ElSelect), mergeProps(unref(attrs), {
52
+ modelValue: unref(modelValue),
53
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(modelValue) ? modelValue.value = $event : null),
54
+ clearable: "",
55
+ multiple: __props.multiple,
56
+ teleported: false
57
+ }), {
58
+ default: withCtx(() => [
59
+ renderSlot(_ctx.$slots, "default", {}, () => [
60
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(options), (item) => {
61
+ return openBlock(), createBlock(unref(ElOption), {
62
+ key: item.value,
63
+ value: item.value,
64
+ label: item.label
65
+ }, null, 8, ["value", "label"]);
66
+ }), 128))
67
+ ])
68
+ ]),
69
+ _: 3
70
+ }, 16, ["modelValue", "multiple"]);
71
+ };
72
+ }
73
+ });
74
+ var Select = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-select.vue"]]);
75
+
76
+ export { Select as default };
@@ -0,0 +1,33 @@
1
+ import { defineComponent, useAttrs, computed, openBlock, createBlock, unref, mergeProps, isRef } from 'vue';
2
+ import { ElInput } from 'element-plus';
3
+ import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
4
+
5
+ const __default__ = defineComponent({
6
+ name: "BwaTextarea"
7
+ });
8
+ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
9
+ props: {
10
+ value: {
11
+ type: [String, Number],
12
+ default: ""
13
+ }
14
+ },
15
+ emits: ["update:model-value"],
16
+ setup(__props, { emit }) {
17
+ const props = __props;
18
+ const attrs = useAttrs();
19
+ const modelValue = computed({
20
+ get: () => props.modelValue,
21
+ set: (v) => emit("update:model-value", v)
22
+ });
23
+ return (_ctx, _cache) => {
24
+ return openBlock(), createBlock(unref(ElInput), mergeProps({ type: "textarea" }, unref(attrs), {
25
+ modelValue: unref(modelValue),
26
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(modelValue) ? modelValue.value = $event : null)
27
+ }), null, 16, ["modelValue"]);
28
+ };
29
+ }
30
+ });
31
+ var Textarea = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "bwa-textarea.vue"]]);
32
+
33
+ export { Textarea as default };