@opentiny/fluent-editor 3.25.4 → 4.0.0-alpha.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 (247) hide show
  1. package/es/attributors/font-style.es.js +1 -1
  2. package/es/attributors/font-style.es.js.map +1 -1
  3. package/es/attributors/line-height.es.js +1 -1
  4. package/es/attributors/line-height.es.js.map +1 -1
  5. package/es/config/editor.config.es.js +0 -7
  6. package/es/config/editor.config.es.js.map +1 -1
  7. package/es/config/editor.utils.es.js +0 -9
  8. package/es/config/editor.utils.es.js.map +1 -1
  9. package/es/config/i18n/en-us.es.js +33 -17
  10. package/es/config/i18n/en-us.es.js.map +1 -1
  11. package/es/config/i18n/zh-cn.es.js +33 -17
  12. package/es/config/i18n/zh-cn.es.js.map +1 -1
  13. package/es/config/index.es.js +7 -13
  14. package/es/config/index.es.js.map +1 -1
  15. package/es/core/fluent-editor.es.js +6 -4
  16. package/es/core/fluent-editor.es.js.map +1 -1
  17. package/es/fluent-editor.es.js +24 -12
  18. package/es/fluent-editor.es.js.map +1 -1
  19. package/es/formats/video.es.js +2 -2
  20. package/es/formats/video.es.js.map +1 -1
  21. package/es/index.es.js +8 -4
  22. package/es/index.es.js.map +1 -1
  23. package/es/modules/custom-clipboard.es.js +3 -61
  24. package/es/modules/custom-clipboard.es.js.map +1 -1
  25. package/es/modules/custom-image/BlotFormatter.es.js +1 -2
  26. package/es/modules/custom-image/BlotFormatter.es.js.map +1 -1
  27. package/es/modules/custom-image/image.es.js +4 -16
  28. package/es/modules/custom-image/image.es.js.map +1 -1
  29. package/es/modules/custom-uploader.es.js +60 -193
  30. package/es/modules/custom-uploader.es.js.map +1 -1
  31. package/es/modules/file/formats/file.es.js +12 -14
  32. package/es/modules/file/formats/file.es.js.map +1 -1
  33. package/es/modules/file/index.es.js +6 -7
  34. package/es/modules/file/index.es.js.map +1 -1
  35. package/es/modules/i18n.es.js +32 -12
  36. package/es/modules/i18n.es.js.map +1 -1
  37. package/es/modules/link/index.es.js +0 -17
  38. package/es/modules/link/index.es.js.map +1 -1
  39. package/es/modules/link/modules/tooltip.es.js +3 -2
  40. package/es/modules/link/modules/tooltip.es.js.map +1 -1
  41. package/es/modules/shortcut-key/index.es.js +229 -0
  42. package/es/modules/shortcut-key/index.es.js.map +1 -0
  43. package/es/modules/table-up/index.es.js +64 -0
  44. package/es/modules/table-up/index.es.js.map +1 -0
  45. package/es/modules/toolbar/better-picker.es.js +21 -269
  46. package/es/modules/toolbar/better-picker.es.js.map +1 -1
  47. package/es/modules/toolbar/index.es.js +0 -1
  48. package/es/modules/toolbar/index.es.js.map +1 -1
  49. package/es/modules/toolbar/toolbar-tip.es.js +44 -9
  50. package/es/modules/toolbar/toolbar-tip.es.js.map +1 -1
  51. package/es/themes/snow.es.js +198 -50
  52. package/es/themes/snow.es.js.map +1 -1
  53. package/es/ui/icons.config.es.js +6 -5
  54. package/es/ui/icons.config.es.js.map +1 -1
  55. package/es/ui/icons.es.js +3 -12
  56. package/es/ui/icons.es.js.map +1 -1
  57. package/es/utils/is.es.js +4 -0
  58. package/es/utils/is.es.js.map +1 -1
  59. package/lib/attributors/font-style.cjs.js +1 -1
  60. package/lib/attributors/font-style.cjs.js.map +1 -1
  61. package/lib/attributors/line-height.cjs.js +1 -1
  62. package/lib/attributors/line-height.cjs.js.map +1 -1
  63. package/lib/config/editor.config.cjs.js +0 -7
  64. package/lib/config/editor.config.cjs.js.map +1 -1
  65. package/lib/config/editor.utils.cjs.js +0 -9
  66. package/lib/config/editor.utils.cjs.js.map +1 -1
  67. package/lib/config/i18n/en-us.cjs.js +33 -17
  68. package/lib/config/i18n/en-us.cjs.js.map +1 -1
  69. package/lib/config/i18n/zh-cn.cjs.js +33 -17
  70. package/lib/config/i18n/zh-cn.cjs.js.map +1 -1
  71. package/lib/config/index.cjs.js +5 -11
  72. package/lib/config/index.cjs.js.map +1 -1
  73. package/lib/core/fluent-editor.cjs.js +5 -3
  74. package/lib/core/fluent-editor.cjs.js.map +1 -1
  75. package/lib/fluent-editor.cjs.js +23 -11
  76. package/lib/fluent-editor.cjs.js.map +1 -1
  77. package/lib/formats/video.cjs.js +2 -2
  78. package/lib/formats/video.cjs.js.map +1 -1
  79. package/lib/index.cjs.js +9 -2
  80. package/lib/index.cjs.js.map +1 -1
  81. package/lib/modules/custom-clipboard.cjs.js +2 -60
  82. package/lib/modules/custom-clipboard.cjs.js.map +1 -1
  83. package/lib/modules/custom-image/BlotFormatter.cjs.js +0 -1
  84. package/lib/modules/custom-image/BlotFormatter.cjs.js.map +1 -1
  85. package/lib/modules/custom-image/image.cjs.js +4 -16
  86. package/lib/modules/custom-image/image.cjs.js.map +1 -1
  87. package/lib/modules/custom-uploader.cjs.js +61 -194
  88. package/lib/modules/custom-uploader.cjs.js.map +1 -1
  89. package/lib/modules/file/formats/file.cjs.js +12 -14
  90. package/lib/modules/file/formats/file.cjs.js.map +1 -1
  91. package/lib/modules/file/index.cjs.js +6 -7
  92. package/lib/modules/file/index.cjs.js.map +1 -1
  93. package/lib/modules/i18n.cjs.js +31 -11
  94. package/lib/modules/i18n.cjs.js.map +1 -1
  95. package/lib/modules/link/index.cjs.js +0 -17
  96. package/lib/modules/link/index.cjs.js.map +1 -1
  97. package/lib/modules/link/modules/tooltip.cjs.js +2 -1
  98. package/lib/modules/link/modules/tooltip.cjs.js.map +1 -1
  99. package/lib/modules/shortcut-key/index.cjs.js +229 -0
  100. package/lib/modules/shortcut-key/index.cjs.js.map +1 -0
  101. package/lib/modules/table-up/index.cjs.js +64 -0
  102. package/lib/modules/table-up/index.cjs.js.map +1 -0
  103. package/lib/modules/toolbar/better-picker.cjs.js +21 -270
  104. package/lib/modules/toolbar/better-picker.cjs.js.map +1 -1
  105. package/lib/modules/toolbar/index.cjs.js +0 -1
  106. package/lib/modules/toolbar/index.cjs.js.map +1 -1
  107. package/lib/modules/toolbar/toolbar-tip.cjs.js +44 -9
  108. package/lib/modules/toolbar/toolbar-tip.cjs.js.map +1 -1
  109. package/lib/themes/snow.cjs.js +200 -52
  110. package/lib/themes/snow.cjs.js.map +1 -1
  111. package/lib/ui/icons.cjs.js +2 -11
  112. package/lib/ui/icons.cjs.js.map +1 -1
  113. package/lib/ui/icons.config.cjs.js +6 -5
  114. package/lib/ui/icons.config.cjs.js.map +1 -1
  115. package/lib/utils/is.cjs.js +4 -0
  116. package/lib/utils/is.cjs.js.map +1 -1
  117. package/package.json +4 -2
  118. package/style.css +316 -2149
  119. package/types/attributors/font-style.d.ts +1 -1
  120. package/types/config/editor.config.d.ts +0 -218
  121. package/types/config/editor.utils.d.ts +0 -1
  122. package/types/config/i18n/en-us.d.ts +31 -16
  123. package/types/config/i18n/zh-cn.d.ts +31 -16
  124. package/types/config/index.d.ts +1 -1
  125. package/types/config/types/editor-config.interface.d.ts +0 -19
  126. package/types/config/types/editor-modules.interface.d.ts +2 -0
  127. package/types/config/types/toolbar-item.interface.d.ts +11 -11
  128. package/types/core/fluent-editor.d.ts +4 -1
  129. package/types/index.d.ts +3 -0
  130. package/types/modules/counter.d.ts +1 -1
  131. package/types/modules/custom-clipboard.d.ts +1 -1
  132. package/types/modules/custom-image/image.d.ts +8 -11
  133. package/types/modules/file/formats/file.d.ts +12 -8
  134. package/types/modules/file/index.d.ts +5 -5
  135. package/types/modules/i18n.d.ts +4 -4
  136. package/types/modules/shortcut-key/index.d.ts +68 -0
  137. package/types/modules/table-up/index.d.ts +66 -0
  138. package/types/modules/toolbar/better-picker.d.ts +15 -0
  139. package/types/themes/snow.d.ts +10 -2
  140. package/types/ui/icons.config.d.ts +2 -2
  141. package/types/utils/is.d.ts +2 -0
  142. package/es/modules/global-link/constants.es.js +0 -9
  143. package/es/modules/global-link/constants.es.js.map +0 -1
  144. package/es/modules/global-link/formats/customer-widget-link.es.js +0 -28
  145. package/es/modules/global-link/formats/customer-widget-link.es.js.map +0 -1
  146. package/es/modules/global-link/formats/doc-link.es.js +0 -42
  147. package/es/modules/global-link/formats/doc-link.es.js.map +0 -1
  148. package/es/modules/global-link/formats/wiki-link.es.js +0 -34
  149. package/es/modules/global-link/formats/wiki-link.es.js.map +0 -1
  150. package/es/modules/global-link/formats/work-item-link.es.js +0 -36
  151. package/es/modules/global-link/formats/work-item-link.es.js.map +0 -1
  152. package/es/modules/global-link/global-link-panel.es.js +0 -2
  153. package/es/modules/global-link/global-link-panel.es.js.map +0 -1
  154. package/es/modules/global-link/index.es.js +0 -139
  155. package/es/modules/global-link/index.es.js.map +0 -1
  156. package/es/modules/global-link/utils/createTable.es.js +0 -50
  157. package/es/modules/global-link/utils/createTable.es.js.map +0 -1
  158. package/es/modules/quick-menu.es.js +0 -82
  159. package/es/modules/quick-menu.es.js.map +0 -1
  160. package/es/modules/table/better-table.es.js +0 -485
  161. package/es/modules/table/better-table.es.js.map +0 -1
  162. package/es/modules/table/formats/header.es.js +0 -94
  163. package/es/modules/table/formats/header.es.js.map +0 -1
  164. package/es/modules/table/formats/list.es.js +0 -163
  165. package/es/modules/table/formats/list.es.js.map +0 -1
  166. package/es/modules/table/formats/table.es.js +0 -969
  167. package/es/modules/table/formats/table.es.js.map +0 -1
  168. package/es/modules/table/modules/table-column-tool.es.js +0 -400
  169. package/es/modules/table/modules/table-column-tool.es.js.map +0 -1
  170. package/es/modules/table/modules/table-operation-menu.es.js +0 -475
  171. package/es/modules/table/modules/table-operation-menu.es.js.map +0 -1
  172. package/es/modules/table/modules/table-scroll-bar.es.js +0 -190
  173. package/es/modules/table/modules/table-scroll-bar.es.js.map +0 -1
  174. package/es/modules/table/modules/table-selection.es.js +0 -305
  175. package/es/modules/table/modules/table-selection.es.js.map +0 -1
  176. package/es/modules/table/modules/table-selector.es.js +0 -158
  177. package/es/modules/table/modules/table-selector.es.js.map +0 -1
  178. package/es/modules/table/table-config.es.js +0 -74
  179. package/es/modules/table/table-config.es.js.map +0 -1
  180. package/es/modules/table/utils/index.es.js +0 -54
  181. package/es/modules/table/utils/index.es.js.map +0 -1
  182. package/es/modules/table/utils/node-matchers.es.js +0 -292
  183. package/es/modules/table/utils/node-matchers.es.js.map +0 -1
  184. package/lib/modules/global-link/constants.cjs.js +0 -9
  185. package/lib/modules/global-link/constants.cjs.js.map +0 -1
  186. package/lib/modules/global-link/formats/customer-widget-link.cjs.js +0 -28
  187. package/lib/modules/global-link/formats/customer-widget-link.cjs.js.map +0 -1
  188. package/lib/modules/global-link/formats/doc-link.cjs.js +0 -42
  189. package/lib/modules/global-link/formats/doc-link.cjs.js.map +0 -1
  190. package/lib/modules/global-link/formats/wiki-link.cjs.js +0 -34
  191. package/lib/modules/global-link/formats/wiki-link.cjs.js.map +0 -1
  192. package/lib/modules/global-link/formats/work-item-link.cjs.js +0 -36
  193. package/lib/modules/global-link/formats/work-item-link.cjs.js.map +0 -1
  194. package/lib/modules/global-link/global-link-panel.cjs.js +0 -2
  195. package/lib/modules/global-link/global-link-panel.cjs.js.map +0 -1
  196. package/lib/modules/global-link/index.cjs.js +0 -139
  197. package/lib/modules/global-link/index.cjs.js.map +0 -1
  198. package/lib/modules/global-link/utils/createTable.cjs.js +0 -50
  199. package/lib/modules/global-link/utils/createTable.cjs.js.map +0 -1
  200. package/lib/modules/quick-menu.cjs.js +0 -82
  201. package/lib/modules/quick-menu.cjs.js.map +0 -1
  202. package/lib/modules/table/better-table.cjs.js +0 -485
  203. package/lib/modules/table/better-table.cjs.js.map +0 -1
  204. package/lib/modules/table/formats/header.cjs.js +0 -94
  205. package/lib/modules/table/formats/header.cjs.js.map +0 -1
  206. package/lib/modules/table/formats/list.cjs.js +0 -163
  207. package/lib/modules/table/formats/list.cjs.js.map +0 -1
  208. package/lib/modules/table/formats/table.cjs.js +0 -969
  209. package/lib/modules/table/formats/table.cjs.js.map +0 -1
  210. package/lib/modules/table/modules/table-column-tool.cjs.js +0 -400
  211. package/lib/modules/table/modules/table-column-tool.cjs.js.map +0 -1
  212. package/lib/modules/table/modules/table-operation-menu.cjs.js +0 -475
  213. package/lib/modules/table/modules/table-operation-menu.cjs.js.map +0 -1
  214. package/lib/modules/table/modules/table-scroll-bar.cjs.js +0 -190
  215. package/lib/modules/table/modules/table-scroll-bar.cjs.js.map +0 -1
  216. package/lib/modules/table/modules/table-selection.cjs.js +0 -305
  217. package/lib/modules/table/modules/table-selection.cjs.js.map +0 -1
  218. package/lib/modules/table/modules/table-selector.cjs.js +0 -158
  219. package/lib/modules/table/modules/table-selector.cjs.js.map +0 -1
  220. package/lib/modules/table/table-config.cjs.js +0 -74
  221. package/lib/modules/table/table-config.cjs.js.map +0 -1
  222. package/lib/modules/table/utils/index.cjs.js +0 -54
  223. package/lib/modules/table/utils/index.cjs.js.map +0 -1
  224. package/lib/modules/table/utils/node-matchers.cjs.js +0 -292
  225. package/lib/modules/table/utils/node-matchers.cjs.js.map +0 -1
  226. package/types/modules/custom-uploader.d.ts +0 -31
  227. package/types/modules/global-link/constants.d.ts +0 -3
  228. package/types/modules/global-link/formats/customer-widget-link.d.ts +0 -14
  229. package/types/modules/global-link/formats/doc-link.d.ts +0 -17
  230. package/types/modules/global-link/formats/wiki-link.d.ts +0 -16
  231. package/types/modules/global-link/formats/work-item-link.d.ts +0 -16
  232. package/types/modules/global-link/global-link-panel.d.ts +0 -19
  233. package/types/modules/global-link/index.d.ts +0 -18
  234. package/types/modules/global-link/utils/createTable.d.ts +0 -1
  235. package/types/modules/quick-menu.d.ts +0 -22
  236. package/types/modules/table/better-table.d.ts +0 -35
  237. package/types/modules/table/formats/header.d.ts +0 -23
  238. package/types/modules/table/formats/list.d.ts +0 -34
  239. package/types/modules/table/formats/table.d.ts +0 -147
  240. package/types/modules/table/modules/table-column-tool.d.ts +0 -23
  241. package/types/modules/table/modules/table-operation-menu.d.ts +0 -38
  242. package/types/modules/table/modules/table-scroll-bar.d.ts +0 -33
  243. package/types/modules/table/modules/table-selection.d.ts +0 -37
  244. package/types/modules/table/modules/table-selector.d.ts +0 -22
  245. package/types/modules/table/table-config.d.ts +0 -38
  246. package/types/modules/table/utils/index.d.ts +0 -17
  247. package/types/modules/table/utils/node-matchers.d.ts +0 -9
@@ -1,190 +0,0 @@
1
- import { SCROLL_BAR_PANEL_HEIGHT } from "../table-config.es.js";
2
- import { css } from "../utils/index.es.js";
3
- class TableScrollBar {
4
- // 表格是否溢出开关,判断开关值后只改变样式一次,不重复修改
5
- constructor(table, quill, dom) {
6
- if (!table) {
7
- return;
8
- }
9
- this.table = table;
10
- this.quill = quill;
11
- this.modulesContainer = dom;
12
- this.domNode = null;
13
- this.oldRootScrollTop = this.quill.root.scrollTop;
14
- this.prev = 0;
15
- const betterTableModule = this.quill.getModule("better-table");
16
- const tableColumnTool = betterTableModule.columnTool;
17
- this.columnToolDomNode = tableColumnTool.domNode;
18
- this.columnCtrlPanel = tableColumnTool.columnCtrlPanel;
19
- this.leftMask = tableColumnTool.leftMask;
20
- this.updateScrollBar();
21
- if (this.quill.root === this.quill.scrollingContainer) {
22
- this.quill.root.addEventListener("scroll", this.handleQuillRootScroll.bind(this));
23
- }
24
- }
25
- handleQuillRootScroll() {
26
- if (!this.domNode) {
27
- return;
28
- }
29
- const curTableRect = this.table.getBoundingClientRect();
30
- const curContainerRect = this.quill.root.parentNode.getBoundingClientRect();
31
- const tableTop = curTableRect.top + SCROLL_BAR_PANEL_HEIGHT;
32
- const tableBottom = curTableRect.top + curTableRect.height - 1;
33
- const containerBottom = curContainerRect.top + curContainerRect.height;
34
- if (containerBottom < tableBottom && containerBottom > tableTop) {
35
- if (!this.isTableOverflow) {
36
- this.isTableOverflow = true;
37
- css(this.domNode, {
38
- display: "block",
39
- top: `${this.containerRect.height - SCROLL_BAR_PANEL_HEIGHT}px`,
40
- marginTop: "0px"
41
- });
42
- }
43
- } else if (containerBottom <= tableTop) {
44
- this.isTableOverflow = false;
45
- this.domNode.style.display = "none";
46
- } else {
47
- this.setScrollBarToBottom();
48
- css(this.domNode, { marginTop: `${this.oldRootScrollTop - this.quill.root.scrollTop}px` });
49
- }
50
- }
51
- setScrollBarToBottom() {
52
- if (this.isTableOverflow) {
53
- this.isTableOverflow = false;
54
- const barPos = this.tableRect.top + this.tableRect.height - this.containerRect.top - 1;
55
- css(this.domNode, { display: "block", top: `${barPos}px` });
56
- }
57
- }
58
- resetTableHeight(table) {
59
- if (this.domNode) {
60
- this.tableRect.height = table.getBoundingClientRect().height;
61
- this.isTableOverflow = !this.isTableOverflow;
62
- this.handleQuillRootScroll();
63
- }
64
- }
65
- setScrollBarMove(pos, isMouse) {
66
- const currentBarLeft = Number.parseInt(getComputedStyle(this.scrollBar).left, 10);
67
- let left = isMouse ? pos - this.prev + currentBarLeft : currentBarLeft + pos;
68
- this.showMask(left);
69
- left = this.getLimitedDistance(left);
70
- const scale = this.tableViewRect.width / this.tableRect.width;
71
- const move = left / scale;
72
- const columnCtrlPanelLeft = this.tableViewRect.left - this.containerRect.left - move;
73
- css(this.scrollBar, { left: `${left}px` });
74
- css(this.columnCtrlPanel, { left: `${columnCtrlPanelLeft}px` });
75
- this.table.parentNode.scrollLeft = move;
76
- if (isMouse) {
77
- this.prev = pos;
78
- }
79
- const tableSelection = this.quill.getModule("better-table").tableSelection;
80
- if (tableSelection && tableSelection.selectedTds.length) {
81
- tableSelection.refreshHelpLinesPosition();
82
- }
83
- }
84
- handleScrollBarMouseDown(mouseDownEvent) {
85
- mouseDownEvent.preventDefault();
86
- this.prev = mouseDownEvent.clientX;
87
- this.subscriber = (mouseMoveEvent) => {
88
- mouseMoveEvent.preventDefault();
89
- mouseMoveEvent.stopPropagation();
90
- this.setScrollBarMove(mouseMoveEvent.clientX, true);
91
- };
92
- this.quill.root.parentNode.addEventListener("mousemove", this.subscriber, false);
93
- document.addEventListener("mouseup", this.handleScrollBarMouseup.bind(this), false);
94
- }
95
- handleScrollBarMouseup(event) {
96
- event.preventDefault();
97
- this.quill.root.parentNode.removeEventListener("mousemove", this.subscriber);
98
- document.removeEventListener("mouseup", this.handleScrollBarMouseup.bind(this), false);
99
- }
100
- handleWheel(event) {
101
- if (event.shiftKey) {
102
- const { deltaY } = event;
103
- this.setScrollBarMove(deltaY, false);
104
- }
105
- }
106
- showMask(distance) {
107
- if (distance >= Math.floor(this.maxBarLeft)) {
108
- css(this.leftMask, { display: "block" });
109
- } else if (distance <= 0) {
110
- css(this.leftMask, { display: "none" });
111
- } else {
112
- css(this.leftMask, { display: "block" });
113
- }
114
- }
115
- getLimitedDistance(distance) {
116
- if (distance >= Math.floor(this.maxBarLeft)) {
117
- distance = this.maxBarLeft;
118
- } else if (distance <= 0) {
119
- distance = 0;
120
- }
121
- return distance;
122
- }
123
- updateScrollBar() {
124
- var _a;
125
- if (!((_a = this.table) == null ? void 0 : _a.parentNode)) {
126
- return;
127
- }
128
- const tableRect = this.table.getBoundingClientRect();
129
- const tableViewRect = this.table.parentNode.getBoundingClientRect();
130
- const tableMoveDistance = tableRect.width - tableViewRect.width;
131
- this.tableRect = tableRect;
132
- this.tableViewRect = tableViewRect;
133
- this.tableMoveDistance = tableMoveDistance;
134
- this.oldRootScrollTop = this.quill.root.scrollTop;
135
- if (tableMoveDistance > 0) {
136
- this.createScrollBar();
137
- } else {
138
- this.destroyScrollBar();
139
- }
140
- }
141
- createScrollBar() {
142
- const parent = this.quill.root.parentNode;
143
- const containerRect = parent.getBoundingClientRect();
144
- this.containerRect = containerRect;
145
- css(this.columnCtrlPanel, {
146
- left: `${this.tableViewRect.left - containerRect.left - this.table.parentNode.scrollLeft}px`
147
- });
148
- if (this.domNode) {
149
- this.domNode.remove();
150
- }
151
- this.domNode = document.createElement("div");
152
- this.domNode.classList.add("qlbt-table-scroll-bar-panel");
153
- this.scrollBar = document.createElement("div");
154
- this.scrollBar.classList.add("qlbt-table-scroll-bar");
155
- this.scrollBar.addEventListener("mousedown", this.handleScrollBarMouseDown.bind(this), false);
156
- const scale = this.tableViewRect.width / this.tableRect.width;
157
- const barWidth = this.tableViewRect.width - this.tableMoveDistance * scale;
158
- css(this.scrollBar, { width: `${barWidth}px` });
159
- this.domNode.appendChild(this.scrollBar);
160
- const tableScrollLeft = this.table.parentNode.scrollLeft;
161
- this.maxBarLeft = this.tableMoveDistance * scale;
162
- if (tableScrollLeft) {
163
- const barLeft = tableScrollLeft * scale;
164
- this.showMask(barLeft);
165
- css(this.scrollBar, { left: `${this.getLimitedDistance(barLeft)}px` });
166
- }
167
- const barPos = this.tableRect.top + this.tableRect.height - containerRect.top - 1;
168
- this.isTableOverflow = containerRect.top + containerRect.height < this.tableRect.top + this.tableRect.height;
169
- this.modulesContainer.appendChild(this.domNode);
170
- css(this.domNode, { top: `${Math.min(containerRect.height - SCROLL_BAR_PANEL_HEIGHT, barPos)}px` });
171
- document.addEventListener("wheel", this.handleWheel.bind(this));
172
- }
173
- destroyScrollBar() {
174
- css(this.leftMask, { display: "none" });
175
- this.columnCtrlPanel.removeAttribute("style");
176
- this.maxBarLeft = null;
177
- this.destroy();
178
- }
179
- destroy() {
180
- if (this.domNode) {
181
- this.domNode.remove();
182
- }
183
- this.quill.root.removeEventListener("scroll", this.handleQuillRootScroll.bind(this));
184
- document.removeEventListener("wheel", this.handleWheel.bind(this));
185
- }
186
- }
187
- export {
188
- TableScrollBar as default
189
- };
190
- //# sourceMappingURL=table-scroll-bar.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-scroll-bar.es.js","sources":["../../../../../src/modules/table/modules/table-scroll-bar.ts"],"sourcesContent":["import { SCROLL_BAR_PANEL_HEIGHT } from '../table-config'\r\nimport { css } from '../utils'\r\n\r\nexport default class TableScrollBar {\r\n table: any\r\n quill: any\r\n modulesContainer: any\r\n domNode: any\r\n oldRootScrollTop: any\r\n // @ts-ignore\r\n prev: number\r\n columnToolDomNode: any\r\n columnCtrlPanel: any\r\n leftMask: any\r\n tableViewRect: any\r\n tableRect: any\r\n containerRect: any\r\n subscriber: any\r\n // @ts-ignore\r\n tableMoveDistance: number\r\n // @ts-ignore\r\n maxBarLeft: number\r\n // @ts-ignore\r\n scrollBar: Element\r\n // @ts-ignore\r\n isTableOverflow: boolean // 表格是否溢出开关,判断开关值后只改变样式一次,不重复修改\r\n\r\n constructor(table, quill, dom) {\r\n if (!table) {\r\n return\r\n }\r\n this.table = table\r\n this.quill = quill\r\n this.modulesContainer = dom\r\n this.domNode = null\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n this.prev = 0\r\n\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n this.columnToolDomNode = tableColumnTool.domNode\r\n this.columnCtrlPanel = tableColumnTool.columnCtrlPanel\r\n this.leftMask = tableColumnTool.leftMask\r\n\r\n this.updateScrollBar()\r\n\r\n if (this.quill.root === this.quill.scrollingContainer) {\r\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n }\r\n }\r\n\r\n handleQuillRootScroll() {\r\n if (!this.domNode) {\r\n return\r\n }\r\n const curTableRect = this.table.getBoundingClientRect()\r\n const curContainerRect = this.quill.root.parentNode.getBoundingClientRect()\r\n const tableTop = curTableRect.top + SCROLL_BAR_PANEL_HEIGHT\r\n const tableBottom = curTableRect.top + curTableRect.height - 1\r\n const containerBottom = curContainerRect.top + curContainerRect.height\r\n if (containerBottom < tableBottom && containerBottom > tableTop) { // 表格下端溢出容器下端\r\n if (!this.isTableOverflow) {\r\n this.isTableOverflow = true\r\n css(this.domNode, {\r\n display: 'block',\r\n top: `${this.containerRect.height - SCROLL_BAR_PANEL_HEIGHT}px`,\r\n marginTop: '0px',\r\n })\r\n }\r\n }\r\n else if (containerBottom <= tableTop) { // 表格上端溢出容器下端\r\n this.isTableOverflow = false\r\n this.domNode.style.display = 'none'\r\n }\r\n else { // 表格下端在容器内\r\n this.setScrollBarToBottom()\r\n css(this.domNode, { marginTop: `${this.oldRootScrollTop - this.quill.root.scrollTop}px` })\r\n }\r\n }\r\n\r\n setScrollBarToBottom() {\r\n if (this.isTableOverflow) {\r\n this.isTableOverflow = false\r\n const barPos = this.tableRect.top + this.tableRect.height - this.containerRect.top - 1\r\n css(this.domNode, { display: 'block', top: `${barPos}px` })\r\n }\r\n }\r\n\r\n resetTableHeight(table) {\r\n if (this.domNode) {\r\n // 表格的高度改变,重置初始化tableRect的高度,但不重置其他坐标值\r\n this.tableRect.height = table.getBoundingClientRect().height\r\n this.isTableOverflow = !this.isTableOverflow\r\n this.handleQuillRootScroll()\r\n }\r\n }\r\n\r\n setScrollBarMove(pos, isMouse) {\r\n // 获取当前滑块左边距和鼠标两次事件节点之间的位移差,计算当前滑块位置及是否显示左右遮罩层,通过比例计算表格位移并赋值\r\n const currentBarLeft = Number.parseInt(getComputedStyle(this.scrollBar).left, 10)\r\n let left = isMouse ? pos - this.prev + currentBarLeft : currentBarLeft + pos\r\n this.showMask(left)\r\n left = this.getLimitedDistance(left)\r\n const scale = this.tableViewRect.width / this.tableRect.width\r\n const move = left / scale\r\n const columnCtrlPanelLeft = this.tableViewRect.left - this.containerRect.left - move\r\n css(this.scrollBar, { left: `${left}px` }) // 移动表格滚动条\r\n css(this.columnCtrlPanel, { left: `${columnCtrlPanelLeft}px` }) // 移动顶部列宽控制条\r\n this.table.parentNode.scrollLeft = move // 移动表格\r\n if (isMouse) {\r\n this.prev = pos\r\n }\r\n\r\n // fix: 拖动滚动条时修正选区位置\r\n const tableSelection = this.quill.getModule('better-table').tableSelection\r\n if (tableSelection && tableSelection.selectedTds.length) {\r\n tableSelection.refreshHelpLinesPosition()\r\n }\r\n }\r\n\r\n handleScrollBarMouseDown(mouseDownEvent) {\r\n mouseDownEvent.preventDefault()\r\n\r\n this.prev = mouseDownEvent.clientX\r\n this.subscriber = (mouseMoveEvent: any) => {\r\n mouseMoveEvent.preventDefault()\r\n mouseMoveEvent.stopPropagation()\r\n this.setScrollBarMove(mouseMoveEvent.clientX, true)\r\n }\r\n this.quill.root.parentNode.addEventListener('mousemove', this.subscriber, false)\r\n document.addEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\r\n }\r\n\r\n handleScrollBarMouseup(event) {\r\n event.preventDefault()\r\n this.quill.root.parentNode.removeEventListener('mousemove', this.subscriber)\r\n document.removeEventListener('mouseup', this.handleScrollBarMouseup.bind(this), false)\r\n }\r\n\r\n handleWheel(event) {\r\n // 按住 Shift 滚动鼠标滚轮,可以对表格进行横向滚动\r\n if (event.shiftKey) {\r\n const { deltaY } = event // 每次滚动鼠标滚轮移动的距离\r\n this.setScrollBarMove(deltaY, false)\r\n }\r\n }\r\n\r\n showMask(distance) {\r\n // 根据当前滑块左边距判断是否显示左右遮罩层\r\n if (distance >= Math.floor(this.maxBarLeft)) {\r\n css(this.leftMask, { display: 'block' })\r\n }\r\n else if (distance <= 0) {\r\n css(this.leftMask, { display: 'none' })\r\n }\r\n else {\r\n css(this.leftMask, { display: 'block' })\r\n }\r\n }\r\n\r\n getLimitedDistance(distance) {\r\n if (distance >= Math.floor(this.maxBarLeft)) {\r\n distance = this.maxBarLeft\r\n }\r\n else if (distance <= 0) {\r\n distance = 0\r\n }\r\n return distance\r\n }\r\n\r\n updateScrollBar() {\r\n if (!this.table?.parentNode) {\r\n return\r\n }\r\n // 获取表格尺寸和表格容器尺寸\r\n const tableRect = this.table.getBoundingClientRect()\r\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\r\n const tableMoveDistance = tableRect.width - tableViewRect.width // 表格最大移动距离\r\n this.tableRect = tableRect\r\n this.tableViewRect = tableViewRect\r\n this.tableMoveDistance = tableMoveDistance\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n\r\n if (tableMoveDistance > 0) {\r\n this.createScrollBar()\r\n }\r\n else {\r\n this.destroyScrollBar()\r\n }\r\n }\r\n\r\n createScrollBar() {\r\n // 列控制条增加表格相应位移\r\n const parent = this.quill.root.parentNode\r\n const containerRect = parent.getBoundingClientRect() // 编辑器容器宽度\r\n this.containerRect = containerRect\r\n css(this.columnCtrlPanel, {\r\n left: `${this.tableViewRect.left - containerRect.left - this.table.parentNode.scrollLeft}px`,\r\n })\r\n\r\n // 创建滚动条\r\n if (this.domNode) {\r\n this.domNode.remove()\r\n }\r\n this.domNode = document.createElement('div')\r\n this.domNode.classList.add('qlbt-table-scroll-bar-panel')\r\n this.scrollBar = document.createElement('div')\r\n this.scrollBar.classList.add('qlbt-table-scroll-bar')\r\n this.scrollBar.addEventListener('mousedown', this.handleScrollBarMouseDown.bind(this), false)\r\n const scale = this.tableViewRect.width / this.tableRect.width\r\n const barWidth = this.tableViewRect.width - this.tableMoveDistance * scale // 滑块宽度\r\n css(this.scrollBar, { width: `${barWidth}px` })\r\n this.domNode.appendChild(this.scrollBar)\r\n\r\n // 判断当前表格是否存在位移,如存在通过比例计算滑块当前位移并赋值\r\n const tableScrollLeft = this.table.parentNode.scrollLeft\r\n this.maxBarLeft = this.tableMoveDistance * scale // 滑块最大移动距离\r\n if (tableScrollLeft) {\r\n const barLeft = tableScrollLeft * scale\r\n this.showMask(barLeft)\r\n css(this.scrollBar, { left: `${this.getLimitedDistance(barLeft)}px` })\r\n }\r\n\r\n // 将滚动条插入到 table control panel 中\r\n const barPos = this.tableRect.top + this.tableRect.height - containerRect.top - 1\r\n this.isTableOverflow = containerRect.top + containerRect.height < this.tableRect.top + this.tableRect.height\r\n this.modulesContainer.appendChild(this.domNode)\r\n css(this.domNode, { top: `${Math.min(containerRect.height - SCROLL_BAR_PANEL_HEIGHT, barPos)}px` })\r\n\r\n // 绑定鼠标滚轮事件:Shift+鼠标滚轮,滚动表格横向滚动条\r\n document.addEventListener('wheel', this.handleWheel.bind(this))\r\n }\r\n\r\n destroyScrollBar() {\r\n css(this.leftMask, { display: 'none' })\r\n this.columnCtrlPanel.removeAttribute('style')\r\n this.maxBarLeft = null\r\n this.destroy()\r\n }\r\n\r\n destroy() {\r\n if (this.domNode) {\r\n this.domNode.remove()\r\n }\r\n this.quill.root.removeEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n document.removeEventListener('wheel', this.handleWheel.bind(this))\r\n }\r\n}\r\n"],"names":[],"mappings":";;AAGA,MAAqB,eAAe;AAAA;AAAA,EAwBlC,YAAY,OAAO,OAAO,KAAK;AAC7B,QAAI,CAAC,OAAO;AACV;AAAA,IAAA;AAEF,S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KAAK,OAAO;AAC9C,QAAI,KAAK,SAAS,EAAE,KAAK,GAAG,KAAK,IAAI,cAAc,SAAS,yBAAyB,MAAM,CAAC,MAAM;AAGlG,aAAS,iBAAiB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAAA,EAGhE,mBAAmB;AACjB,QAAI,KAAK,UAAU,EAAE,SAAS,QAAQ;AACjC,SAAA,gBAAgB,gBAAgB,OAAO;AAC5C,SAAK,aAAa;AAClB,SAAK,QAAQ;AAAA,EAAA;AAAA,EAGf,UAAU;AACR,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,OAAO;AAAA,IAAA;AAEjB,SAAA,MAAM,KAAK,oBAAoB,UAAU,KAAK,sBAAsB,KAAK,IAAI,CAAC;AACnF,aAAS,oBAAoB,SAAS,KAAK,YAAY,KAAK,IAAI,CAAC;AAAA,EAAA;AAErE;"}
@@ -1,305 +0,0 @@
1
- import Quill from "quill";
2
- import { TableCell } from "../formats/table.es.js";
3
- import { LINE_POSITIONS, PRIMARY_COLOR, ERROR_LIMIT } from "../table-config.es.js";
4
- import { css, getRelativeRect } from "../utils/index.es.js";
5
- class TableSelection {
6
- constructor(table, quill, dom) {
7
- if (!table) {
8
- return null;
9
- }
10
- this.table = table;
11
- this.quill = quill;
12
- this.modulesContainer = dom;
13
- this.parent = this.quill.root.parentNode;
14
- this.boundary = {};
15
- this.selectedTds = [];
16
- this.dragging = false;
17
- this.preSelectedTable = null;
18
- this.oldRootScrollTop = this.quill.root.scrollTop;
19
- this.selectingHandler = this.mouseDownHandler.bind(this);
20
- this.tdEditHandler = this.setTdEditable.bind(this);
21
- this.tdResizeHandler = this.resizeTd.bind(this);
22
- this.helpLinesInitial();
23
- this.isEditorHasScrollBar();
24
- this.quill.root.parentNode.addEventListener("mousedown", this.selectingHandler, false);
25
- this.quill.on("text-change", this.tdResizeHandler);
26
- if (this.quill.root === this.quill.scrollingContainer) {
27
- this.quill.root.addEventListener("scroll", this.handleQuillRootScroll.bind(this));
28
- }
29
- }
30
- handleQuillRootScroll() {
31
- LINE_POSITIONS.forEach((direction) => {
32
- const selectionLine = this[direction];
33
- if (selectionLine) {
34
- selectionLine.style.marginTop = `${this.oldRootScrollTop - this.quill.root.scrollTop}px`;
35
- }
36
- });
37
- }
38
- isEditorHasScrollBar() {
39
- if (this.quill.root.scrollHeight > this.quill.root.clientHeight) {
40
- css(this.modulesContainer, { width: "calc(100% - 23px)" });
41
- } else {
42
- this.modulesContainer.removeAttribute("style");
43
- }
44
- }
45
- helpLinesInitial() {
46
- LINE_POSITIONS.forEach((direction) => {
47
- this[direction] = document.createElement("div");
48
- this[direction].classList.add("qlbt-selection-line");
49
- if (direction === "left") {
50
- this[direction].classList.add("qlbt-selection-line-first");
51
- const ctrlPointLeft = document.createElement("div");
52
- this[direction].appendChild(ctrlPointLeft);
53
- }
54
- if (direction === "bottom") {
55
- this[direction].classList.add("qlbt-selection-line-last");
56
- const ctrlPointRight = document.createElement("div");
57
- this[direction].appendChild(ctrlPointRight);
58
- }
59
- css(this[direction], {
60
- "position": "absolute",
61
- "display": "none",
62
- "background-color": PRIMARY_COLOR
63
- });
64
- this.modulesContainer.appendChild(this[direction]);
65
- });
66
- }
67
- mouseDownHandler(e) {
68
- if (e.button !== 0) {
69
- return;
70
- }
71
- const self = this;
72
- const betterTableModule = this.quill.getModule("better-table");
73
- const tableColumnTool = betterTableModule.columnTool;
74
- if (tableColumnTool.activeToolCell) {
75
- tableColumnTool.activeToolCell.classList.remove("qlbt-tool-cell-on");
76
- tableColumnTool.activeToolCell = null;
77
- }
78
- if (e.target.closest(".quill-better-table")) {
79
- if (e.shiftKey) {
80
- this.endTd = e.target.closest("td[data-row]");
81
- this.drawSelection(this, true);
82
- if (this.startTd !== this.endTd) {
83
- this.quill.blur();
84
- }
85
- } else {
86
- this.startTd = e.target.closest("td[data-row]");
87
- this.drawSelection(this, false);
88
- this.dragging = true;
89
- this.parent.addEventListener("mousemove", mouseMoveHandler, false);
90
- document.addEventListener("mouseup", mouseUpHandler, false);
91
- }
92
- } else if (e.target.closest(".qlbt-selection-line")) {
93
- this.parent.addEventListener("mousemove", mouseMoveHandler, false);
94
- document.addEventListener("mouseup", mouseUpHandler, false);
95
- }
96
- function mouseMoveHandler(event) {
97
- event.stopPropagation();
98
- if (event.button !== 0 || !event.target.closest(".quill-better-table")) {
99
- return;
100
- }
101
- self.endTd = event.target.closest("td[data-row]");
102
- if (!self.endTd) {
103
- return;
104
- }
105
- self.drawSelection(self, true);
106
- if (self.startTd !== self.endTd) {
107
- self.quill.blur();
108
- }
109
- }
110
- function mouseUpHandler() {
111
- self.parent.removeEventListener("mousemove", mouseMoveHandler, false);
112
- document.removeEventListener("mouseup", mouseUpHandler, false);
113
- self.dragging = false;
114
- }
115
- }
116
- drawSelection(self, end) {
117
- self.startTdRect = getRelativeRect(self.startTd.getBoundingClientRect(), self.quill.root.parentNode);
118
- let endTdRect = self.startTdRect;
119
- if (end) {
120
- self.endTdRect = getRelativeRect(self.endTd.getBoundingClientRect(), self.quill.root.parentNode);
121
- endTdRect = self.endTdRect;
122
- }
123
- self.boundary = computeBoundaryFromRects(self.startTdRect, endTdRect);
124
- self.selectedTds = self.computeSelectedTds();
125
- self.repositionHelpLines();
126
- }
127
- setTdEditable(e) {
128
- if (!this.editTd) {
129
- return;
130
- }
131
- this.parent.removeEventListener("keypress", this.tdEditHandler, false);
132
- const dom = this.editTd.domNode;
133
- dom.removeEventListener("click", this.tdEditHandler, false);
134
- dom.classList.add("editing-select-able");
135
- dom.setAttribute("contenteditable", true);
136
- if (e.type === "keypress") {
137
- if (dom.childNodes.length > 1 || dom.firstChild.innerHTML !== "<br>") {
138
- const blank = dom.firstChild.cloneNode();
139
- blank.innerHTML = "<br>";
140
- dom.innerHTML = "";
141
- dom.appendChild(blank);
142
- }
143
- dom.focus();
144
- }
145
- }
146
- resizeTd() {
147
- if (!this.editTd || this.left && !this.left.offsetParent) {
148
- return;
149
- }
150
- if (this.selectedTds.length > 1) {
151
- this.refreshHelpLinesPosition();
152
- } else {
153
- const dom = this.editTd.domNode;
154
- const domRect = getRelativeRect(dom.getBoundingClientRect(), this.quill.root.parentNode);
155
- this.boundary = computeBoundaryFromRects(domRect, domRect);
156
- this.repositionHelpLines();
157
- }
158
- this.isEditorHasScrollBar();
159
- const betterTableModule = this.quill.getModule("better-table");
160
- const tableColumnTool = betterTableModule.columnTool;
161
- if (tableColumnTool) {
162
- tableColumnTool.updateRowToolCells();
163
- const tableViewRect = this.table.parentNode.getBoundingClientRect();
164
- if (tableColumnTool.leftMask) {
165
- css(tableColumnTool.leftMask, { height: `${tableViewRect.height + 50}px` });
166
- }
167
- }
168
- const tableScrollBar = betterTableModule.tableScrollBar;
169
- tableScrollBar.resetTableHeight(this.table);
170
- }
171
- resetTd(e) {
172
- const dom = e.target;
173
- dom.classList.remove("editing-select-able");
174
- dom.setAttribute("contenteditable", false);
175
- dom.removeAttribute("contenteditable");
176
- }
177
- correctBoundary() {
178
- const tableContainer = Quill.find(this.table);
179
- const tableCells = tableContainer.descendants(TableCell);
180
- tableCells.forEach((tableCell) => {
181
- const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode);
182
- const isCellIntersected = (x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1 || x - ERROR_LIMIT + width >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1) && (y + ERROR_LIMIT >= this.boundary.y && y + ERROR_LIMIT <= this.boundary.y1 || y - ERROR_LIMIT + height >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1);
183
- if (isCellIntersected) {
184
- this.boundary = computeBoundaryFromRects(this.boundary, { x, y, width, height });
185
- }
186
- });
187
- }
188
- computeSelectedTds() {
189
- const tableContainer = Quill.find(this.table);
190
- const tableCells = tableContainer.descendants(TableCell);
191
- const result = tableCells.reduce((selectedCells, tableCell) => {
192
- const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode);
193
- const isCellIncluded = x + ERROR_LIMIT >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1 && y + ERROR_LIMIT >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1;
194
- if (isCellIncluded) {
195
- selectedCells.push(tableCell);
196
- }
197
- return selectedCells;
198
- }, []);
199
- if (result.length === 1 && this.editTd !== result[0]) {
200
- const resetTds = this.table.querySelectorAll("td[contenteditable=true]");
201
- resetTds.forEach((td) => this.resetTd({ target: td }));
202
- this.editTd = result[0];
203
- this.editTd.domNode.addEventListener("mousedown", this.tdEditHandler, false);
204
- this.parent.addEventListener("keypress", this.tdEditHandler, false);
205
- }
206
- return result;
207
- }
208
- repositionHelpLines() {
209
- this.oldRootScrollTop = this.quill.root.scrollTop;
210
- if (!this.left) {
211
- return;
212
- }
213
- css(this.left, {
214
- "display": "block",
215
- "left": `${this.boundary.x - 1}px`,
216
- "top": `${this.boundary.y}px`,
217
- "height": `${this.boundary.height + 1}px`,
218
- "width": "1px",
219
- "margin-top": "0px"
220
- });
221
- css(this.right, {
222
- "display": "block",
223
- "left": `${this.boundary.x1}px`,
224
- "top": `${this.boundary.y - 1}px`,
225
- "height": `${this.boundary.height + 1}px`,
226
- "width": "1px",
227
- "margin-top": "0px"
228
- });
229
- css(this.top, {
230
- "display": "block",
231
- "left": `${this.boundary.x - 1}px`,
232
- "top": `${this.boundary.y - 1}px`,
233
- "width": `${this.boundary.width + 1}px`,
234
- "height": "1px",
235
- "margin-top": "0px"
236
- });
237
- css(this.bottom, {
238
- "display": "block",
239
- "left": `${this.boundary.x - 1}px`,
240
- "top": `${this.boundary.y1}px`,
241
- "width": `${this.boundary.width + 1}px`,
242
- "height": "1px",
243
- "margin-top": "0px"
244
- });
245
- }
246
- // based on selectedTds compute positions of help lines
247
- // It is useful when selectedTds are not changed
248
- refreshHelpLinesPosition() {
249
- const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode);
250
- const endRect = getRelativeRect(
251
- this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(),
252
- this.quill.root.parentNode
253
- );
254
- this.boundary = computeBoundaryFromRects(startRect, endRect);
255
- this.repositionHelpLines();
256
- }
257
- destroy() {
258
- const resetTds = this.table.querySelectorAll("td[contenteditable=true]");
259
- resetTds.forEach((td) => this.resetTd({ target: td }));
260
- LINE_POSITIONS.forEach((direction) => {
261
- if (this[direction]) {
262
- this[direction].remove();
263
- this[direction] = null;
264
- }
265
- });
266
- this.quill.root.parentNode.removeEventListener("mousedown", this.selectingHandler, false);
267
- delete this.editTd;
268
- return null;
269
- }
270
- setSelection(startRect, endRect) {
271
- this.boundary = computeBoundaryFromRects(
272
- getRelativeRect(startRect, this.quill.root.parentNode),
273
- getRelativeRect(endRect, this.quill.root.parentNode)
274
- );
275
- this.correctBoundary();
276
- this.selectedTds = this.computeSelectedTds();
277
- this.repositionHelpLines();
278
- }
279
- clearSelection() {
280
- const resetTds = this.table.querySelectorAll("td[contenteditable=true]");
281
- resetTds.forEach((td) => this.resetTd({ target: td }));
282
- this.boundary = {};
283
- this.selectedTds = [];
284
- LINE_POSITIONS.forEach((direction) => {
285
- if (this[direction]) {
286
- css(this[direction], {
287
- display: "none"
288
- });
289
- }
290
- });
291
- }
292
- }
293
- function computeBoundaryFromRects(startRect, endRect) {
294
- const x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1);
295
- const x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1);
296
- const y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1);
297
- const y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1);
298
- const width = x1 - x;
299
- const height = y1 - y;
300
- return { x, x1, y, y1, width, height };
301
- }
302
- export {
303
- TableSelection as default
304
- };
305
- //# sourceMappingURL=table-selection.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-selection.es.js","sources":["../../../../../src/modules/table/modules/table-selection.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport { TableCell } from '../formats/table'\r\nimport { ERROR_LIMIT, LINE_POSITIONS, PRIMARY_COLOR } from '../table-config'\r\nimport { css, getRelativeRect } from '../utils'\r\n\r\nexport default class TableSelection {\r\n table: any\r\n quill: any\r\n modulesContainer: any\r\n parent: any\r\n boundary: any\r\n // @ts-ignore\r\n selectedTds: any[]\r\n // @ts-ignore\r\n dragging: boolean\r\n preSelectedTable: any\r\n oldRootScrollTop: any\r\n selectingHandler: any\r\n tdEditHandler: any\r\n tdResizeHandler: any\r\n endTd: any\r\n startTd: any\r\n editTd: any\r\n left: any\r\n bottom: any\r\n top: any\r\n right: any\r\n\r\n constructor(table, quill, dom) {\r\n if (!table) {\r\n return null\r\n }\r\n this.table = table\r\n this.quill = quill\r\n this.modulesContainer = dom\r\n this.parent = this.quill.root.parentNode\r\n this.boundary = {} // params for selected square\r\n this.selectedTds = [] // array for selected table-cells\r\n this.dragging = false\r\n this.preSelectedTable = null\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n\r\n this.selectingHandler = this.mouseDownHandler.bind(this)\r\n\r\n this.tdEditHandler = this.setTdEditable.bind(this)\r\n this.tdResizeHandler = this.resizeTd.bind(this)\r\n\r\n this.helpLinesInitial()\r\n this.isEditorHasScrollBar()\r\n\r\n this.quill.root.parentNode.addEventListener('mousedown', this.selectingHandler, false)\r\n this.quill.on('text-change', this.tdResizeHandler)\r\n if (this.quill.root === this.quill.scrollingContainer) {\r\n this.quill.root.addEventListener('scroll', this.handleQuillRootScroll.bind(this))\r\n }\r\n }\r\n\r\n handleQuillRootScroll() {\r\n LINE_POSITIONS.forEach((direction) => {\r\n const selectionLine = this[direction]\r\n if (selectionLine) {\r\n selectionLine.style.marginTop = `${this.oldRootScrollTop - this.quill.root.scrollTop}px`\r\n }\r\n })\r\n }\r\n\r\n isEditorHasScrollBar() {\r\n if (this.quill.root.scrollHeight > this.quill.root.clientHeight) {\r\n css(this.modulesContainer, { width: 'calc(100% - 23px)' })\r\n }\r\n else {\r\n this.modulesContainer.removeAttribute('style')\r\n }\r\n }\r\n\r\n helpLinesInitial() {\r\n LINE_POSITIONS.forEach((direction) => {\r\n this[direction] = document.createElement('div')\r\n this[direction].classList.add('qlbt-selection-line')\r\n if (direction === 'left') {\r\n this[direction].classList.add('qlbt-selection-line-first')\r\n const ctrlPointLeft = document.createElement('div')\r\n this[direction].appendChild(ctrlPointLeft)\r\n }\r\n if (direction === 'bottom') {\r\n this[direction].classList.add('qlbt-selection-line-last')\r\n const ctrlPointRight = document.createElement('div')\r\n this[direction].appendChild(ctrlPointRight)\r\n }\r\n css(this[direction], {\r\n 'position': 'absolute',\r\n 'display': 'none',\r\n 'background-color': PRIMARY_COLOR,\r\n })\r\n this.modulesContainer.appendChild(this[direction])\r\n })\r\n }\r\n\r\n mouseDownHandler(e) {\r\n if (e.button !== 0) {\r\n return\r\n }\r\n const self: any = this\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n if (tableColumnTool.activeToolCell) {\r\n tableColumnTool.activeToolCell.classList.remove('qlbt-tool-cell-on')\r\n tableColumnTool.activeToolCell = null\r\n }\r\n if (e.target.closest('.quill-better-table')) {\r\n if (e.shiftKey) {\r\n this.endTd = e.target.closest('td[data-row]')\r\n this.drawSelection(this, true)\r\n // avoid select text in multiple table-cell\r\n if (this.startTd !== this.endTd) {\r\n this.quill.blur()\r\n }\r\n }\r\n else {\r\n this.startTd = e.target.closest('td[data-row]')\r\n this.drawSelection(this, false)\r\n this.dragging = true\r\n\r\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\r\n document.addEventListener('mouseup', mouseUpHandler, false)\r\n }\r\n }\r\n else if (e.target.closest('.qlbt-selection-line')) {\r\n this.parent.addEventListener('mousemove', mouseMoveHandler, false)\r\n document.addEventListener('mouseup', mouseUpHandler, false)\r\n }\r\n\r\n function mouseMoveHandler(event) {\r\n event.stopPropagation()\r\n\r\n if (event.button !== 0 || !event.target.closest('.quill-better-table')) {\r\n return\r\n }\r\n self.endTd = event.target.closest('td[data-row]')\r\n if (!self.endTd) {\r\n return\r\n }\r\n self.drawSelection(self, true)\r\n // avoid select text in multiple table-cell\r\n if (self.startTd !== self.endTd) {\r\n self.quill.blur()\r\n }\r\n }\r\n\r\n function mouseUpHandler() {\r\n self.parent.removeEventListener('mousemove', mouseMoveHandler, false)\r\n document.removeEventListener('mouseup', mouseUpHandler, false)\r\n self.dragging = false\r\n }\r\n }\r\n\r\n drawSelection(self, end) {\r\n // fix: 如果滚动条拖动,startTd的位置已经改变了,需要重置startTdRect\r\n self.startTdRect = getRelativeRect(self.startTd.getBoundingClientRect(), self.quill.root.parentNode)\r\n let endTdRect = self.startTdRect\r\n if (end) {\r\n self.endTdRect = getRelativeRect(self.endTd.getBoundingClientRect(), self.quill.root.parentNode)\r\n endTdRect = self.endTdRect\r\n }\r\n self.boundary = computeBoundaryFromRects(self.startTdRect, endTdRect)\r\n self.selectedTds = self.computeSelectedTds()\r\n self.repositionHelpLines()\r\n }\r\n\r\n setTdEditable(e) {\r\n if (!this.editTd) {\r\n return\r\n }\r\n this.parent.removeEventListener('keypress', this.tdEditHandler, false)\r\n const dom = this.editTd.domNode\r\n dom.removeEventListener('click', this.tdEditHandler, false)\r\n dom.classList.add('editing-select-able')\r\n dom.setAttribute('contenteditable', true)\r\n if (e.type === 'keypress') {\r\n if (dom.childNodes.length > 1 || dom.firstChild.innerHTML !== '<br>') {\r\n const blank = dom.firstChild.cloneNode()\r\n blank.innerHTML = '<br>'\r\n dom.innerHTML = ''\r\n dom.appendChild(blank)\r\n }\r\n dom.focus()\r\n }\r\n }\r\n\r\n resizeTd() {\r\n if (!this.editTd || (this.left && !this.left.offsetParent)) {\r\n return\r\n }\r\n if (this.selectedTds.length > 1) {\r\n this.refreshHelpLinesPosition()\r\n }\r\n else {\r\n const dom = this.editTd.domNode\r\n const domRect = getRelativeRect(dom.getBoundingClientRect(), this.quill.root.parentNode)\r\n this.boundary = computeBoundaryFromRects(domRect, domRect)\r\n this.repositionHelpLines()\r\n }\r\n\r\n // 判断编辑器是否有滚动条,调整遮罩宽度\r\n this.isEditorHasScrollBar()\r\n\r\n // 更新行高 更新滑块位置\r\n const betterTableModule = this.quill.getModule('better-table')\r\n const tableColumnTool = betterTableModule.columnTool\r\n if (tableColumnTool) {\r\n tableColumnTool.updateRowToolCells()\r\n const tableViewRect = this.table.parentNode.getBoundingClientRect()\r\n if (tableColumnTool.leftMask) {\r\n css(tableColumnTool.leftMask, { height: `${tableViewRect.height + 50}px` })\r\n }\r\n }\r\n\r\n const tableScrollBar = betterTableModule.tableScrollBar\r\n tableScrollBar.resetTableHeight(this.table)\r\n }\r\n\r\n resetTd(e) {\r\n const dom = e.target\r\n dom.classList.remove('editing-select-able')\r\n dom.setAttribute('contenteditable', false)\r\n dom.removeAttribute('contenteditable')\r\n }\r\n\r\n correctBoundary() {\r\n const tableContainer = Quill.find(this.table)\r\n const tableCells = tableContainer.descendants(TableCell)\r\n\r\n tableCells.forEach((tableCell) => {\r\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const isCellIntersected\r\n = ((x + ERROR_LIMIT >= this.boundary.x && x + ERROR_LIMIT <= this.boundary.x1)\r\n || (x - ERROR_LIMIT + width >= this.boundary.x && x - ERROR_LIMIT + width <= this.boundary.x1))\r\n && ((y + ERROR_LIMIT >= this.boundary.y && y + ERROR_LIMIT <= this.boundary.y1)\r\n || (y - ERROR_LIMIT + height >= this.boundary.y && y - ERROR_LIMIT + height <= this.boundary.y1))\r\n if (isCellIntersected) {\r\n this.boundary = computeBoundaryFromRects(this.boundary, { x, y, width, height })\r\n }\r\n })\r\n }\r\n\r\n computeSelectedTds() {\r\n const tableContainer = Quill.find(this.table)\r\n const tableCells = tableContainer.descendants(TableCell)\r\n\r\n const result = tableCells.reduce((selectedCells, tableCell) => {\r\n const { x, y, width, height } = getRelativeRect(tableCell.domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const isCellIncluded\r\n = x + ERROR_LIMIT >= this.boundary.x\r\n && x - ERROR_LIMIT + width <= this.boundary.x1\r\n && y + ERROR_LIMIT >= this.boundary.y\r\n && y - ERROR_LIMIT + height <= this.boundary.y1\r\n\r\n if (isCellIncluded) {\r\n selectedCells.push(tableCell)\r\n }\r\n\r\n return selectedCells\r\n }, [])\r\n\r\n if (result.length === 1 && this.editTd !== result[0]) {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n this.editTd = result[0]\r\n this.editTd.domNode.addEventListener('mousedown', this.tdEditHandler, false)\r\n this.parent.addEventListener('keypress', this.tdEditHandler, false)\r\n }\r\n\r\n return result\r\n }\r\n\r\n repositionHelpLines() {\r\n this.oldRootScrollTop = this.quill.root.scrollTop\r\n if (!this.left) {\r\n return\r\n }\r\n\r\n css(this.left, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y}px`,\r\n 'height': `${this.boundary.height + 1}px`,\r\n 'width': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.right, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x1}px`,\r\n 'top': `${this.boundary.y - 1}px`,\r\n 'height': `${this.boundary.height + 1}px`,\r\n 'width': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.top, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y - 1}px`,\r\n 'width': `${this.boundary.width + 1}px`,\r\n 'height': '1px',\r\n 'margin-top': '0px',\r\n })\r\n\r\n css(this.bottom, {\r\n 'display': 'block',\r\n 'left': `${this.boundary.x - 1}px`,\r\n 'top': `${this.boundary.y1}px`,\r\n 'width': `${this.boundary.width + 1}px`,\r\n 'height': '1px',\r\n 'margin-top': '0px',\r\n })\r\n }\r\n\r\n // based on selectedTds compute positions of help lines\r\n // It is useful when selectedTds are not changed\r\n refreshHelpLinesPosition() {\r\n const startRect = getRelativeRect(this.selectedTds[0].domNode.getBoundingClientRect(), this.quill.root.parentNode)\r\n const endRect = getRelativeRect(\r\n this.selectedTds[this.selectedTds.length - 1].domNode.getBoundingClientRect(),\r\n this.quill.root.parentNode,\r\n )\r\n this.boundary = computeBoundaryFromRects(startRect, endRect)\r\n this.repositionHelpLines()\r\n }\r\n\r\n destroy() {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n\r\n LINE_POSITIONS.forEach((direction) => {\r\n if (this[direction]) {\r\n this[direction].remove()\r\n this[direction] = null\r\n }\r\n })\r\n\r\n this.quill.root.parentNode.removeEventListener('mousedown', this.selectingHandler, false)\r\n\r\n delete this.editTd\r\n\r\n return null\r\n }\r\n\r\n setSelection(startRect, endRect) {\r\n this.boundary = computeBoundaryFromRects(\r\n getRelativeRect(startRect, this.quill.root.parentNode),\r\n getRelativeRect(endRect, this.quill.root.parentNode),\r\n )\r\n this.correctBoundary()\r\n this.selectedTds = this.computeSelectedTds()\r\n this.repositionHelpLines()\r\n }\r\n\r\n clearSelection() {\r\n const resetTds = this.table.querySelectorAll('td[contenteditable=true]')\r\n resetTds.forEach(td => this.resetTd({ target: td }))\r\n this.boundary = {}\r\n this.selectedTds = []\r\n LINE_POSITIONS.forEach((direction) => {\r\n if (this[direction]) {\r\n css(this[direction], {\r\n display: 'none',\r\n })\r\n }\r\n })\r\n }\r\n}\r\n\r\nfunction computeBoundaryFromRects(startRect, endRect) {\r\n const x = Math.min(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\r\n\r\n const x1 = Math.max(startRect.x, endRect.x, startRect.x + startRect.width - 1, endRect.x + endRect.width - 1)\r\n\r\n const y = Math.min(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\r\n\r\n const y1 = Math.max(startRect.y, endRect.y, startRect.y + startRect.height - 1, endRect.y + endRect.height - 1)\r\n\r\n const width = x1 - x\r\n const height = y1 - y\r\n\r\n return { x, x1, y, y1, width, height }\r\n}\r\n"],"names":[],"mappings":";;;;AAKA,MAAqB,eAAe;AAAA,EAuBlC,YAAY,OAAO,OAAO,KAAK;AAC7B,QAAI,CAAC,OAAO;AACH,aAAA;AAAA,IAAA;AAET,SAAK,QAAQ;AACb,SAAK,QAAQ;AACb,SAAK,mBAAmB;AACnB,SAAA,SAAS,KAAK,MAAM,KAAK;AAC9B,SAAK,WAAW,CAAC;AACjB,SAAK,cAAc,CAAC;AACpB,SAAK,WAAW;AAChB,SAAK,mBAAmB;AACnB,SAAA,mBAAmB,KAAK,MAAM,KAAK;AAExC,SAAK,mBAAmB,KAAK,iBAAiB,KAAK,IAAI;AAEvD,SAAK,gBAAgB,KAAK,cAAc,KAAK,IAAI;AACjD,SAAK,kBAAkB,KAAK,SAAS,KAAK,IAAI;AAE9C,SAAK,iBAAiB;AACtB,SAAK,qBAAqB;AAE1B,SAAK,MAAM,KAAK,WAAW,iBAAiB,aAAa,KAAK,kBAAkB,KAAK;AACrF,SAAK,MAAM,GAAG,eAAe,KAAK,eAAe;AACjD,QAAI,KAAK,MAAM,SAAS,KAAK,MAAM,oBAAoB;AAChD,WAAA,MAAM,KAAK,iBAAiB,UAAU,KAAK,sBAAsB,KAAK,IAAI,CAAC;AAAA,IAAA;AAAA,EAClF;AAAA,EAGF,wBAAwB;AACP,mBAAA,QAAQ,CAAC,cAAc;AAC9B,YAAA,gBAAgB,KAAK,SAAS;AACpC,UAAI,eAAe;AACH,sBAAA,MAAM,YAAY,GAAG,KAAK,mBAAmB,KAAK,MAAM,KAAK,SAAS;AAAA,MAAA;AAAA,IACtF,CACD;AAAA,EAAA;AAAA,EAGH,uBAAuB;AACrB,QAAI,KAAK,MAAM,KAAK,eAAe,KAAK,MAAM,KAAK,cAAc;AAC/D,UAAI,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