@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,485 +0,0 @@
1
- import Quill from "quill";
2
- import { getEventComposedPath, isNullOrUndefined, isPureIE, insideTable } from "../../config/editor.utils.es.js";
3
- import Header from "./formats/header.es.js";
4
- import ListItem from "./formats/list.es.js";
5
- import { TableCol, TableColGroup, TableCellLine, TableCell, TableRow, TableBody, TableContainer, TableViewWrapper, rowId, cellId } from "./formats/table.es.js";
6
- import TableColumnTool from "./modules/table-column-tool.es.js";
7
- import TableOperationMenu from "./modules/table-operation-menu.es.js";
8
- import TableScrollBar from "./modules/table-scroll-bar.es.js";
9
- import TableSelection from "./modules/table-selection.es.js";
10
- import TableSelector from "./modules/table-selector.es.js";
11
- import { css } from "./utils/index.es.js";
12
- import { matchTableCell, matchTableHeader, matchTable, matchHeader, matchList, matchMentionLink, matchWordShapeImage, matchInline, matchTableRow } from "./utils/node-matchers.es.js";
13
- const Block = Quill.imports["blots/block"];
14
- const Delta = Quill.imports.delta;
15
- const Module = Quill.imports["core/module"];
16
- class BetterTable extends Module {
17
- static register() {
18
- Quill.register(TableCol, true);
19
- Quill.register(TableColGroup, true);
20
- Quill.register(TableCellLine, true);
21
- Quill.register(TableCell, true);
22
- Quill.register(TableRow, true);
23
- Quill.register(TableBody, true);
24
- Quill.register(TableContainer, true);
25
- Quill.register(TableViewWrapper, true);
26
- Quill.register("formats/header", Header, true);
27
- Quill.register("formats/list", ListItem, true);
28
- }
29
- constructor(quill, options) {
30
- super(quill, options);
31
- this.isComposition = false;
32
- this.isTableSelectorVisible = false;
33
- this.quill.root.addEventListener("mousedown", (event) => this.handleMouseDown(event, quill), false);
34
- this.quill.root.addEventListener("compositionend", () => this.handleCompositionend(quill), false);
35
- this.quill.root.addEventListener("compositionstart", () => this.handleCompositionstart(quill), false);
36
- this.quill.root.addEventListener("keypress", (event) => this.handleKeyDown(event, quill), false);
37
- this.quill.root.addEventListener(
38
- "contextmenu",
39
- (evt) => {
40
- if (!this.table) return true;
41
- evt.preventDefault();
42
- const path = getEventComposedPath(evt);
43
- if (!path || path.length <= 0) return;
44
- const tableNode = path.filter((node) => {
45
- return node.tagName && node.tagName.toUpperCase() === "TABLE" && node.classList.contains("quill-better-table");
46
- })[0];
47
- const rowNode = path.filter((node) => {
48
- return node.tagName && node.tagName.toUpperCase() === "TR" && node.getAttribute("data-row");
49
- })[0];
50
- const cellNode = path.filter((node) => {
51
- return node.tagName && node.tagName.toUpperCase() === "TD" && node.getAttribute("data-row");
52
- })[0];
53
- const isTargetCellSelected = this.tableSelection.selectedTds.map((tableCell) => tableCell.domNode).includes(cellNode);
54
- if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {
55
- this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect());
56
- }
57
- if (this.tableOperationMenu) {
58
- this.tableOperationMenu = this.tableOperationMenu.destroy();
59
- }
60
- if (tableNode) {
61
- this.tableOperationMenu = new TableOperationMenu(
62
- {
63
- table: tableNode,
64
- row: rowNode,
65
- cell: cellNode,
66
- left: evt.x + 15,
67
- top: evt.y
68
- },
69
- quill,
70
- options.operationMenu
71
- );
72
- }
73
- },
74
- false
75
- );
76
- quill.keyboard.addBinding({ key: "Backspace" }, {}, (range, context) => {
77
- if (range.index === 0 || this.quill.getLength() <= 1) return true;
78
- if (context.offset === 0 && range.length === 0) {
79
- const [prev] = this.quill.getLine(range.index - 1);
80
- const [line] = this.quill.getLine(range.index);
81
- if (!isNullOrUndefined(prev)) {
82
- if (prev.statics.blotName === "table-cell-line" && line.statics.blotName !== "table-cell-line") {
83
- const betterTableModule = this.quill.getModule("better-table");
84
- let tableBlot;
85
- try {
86
- tableBlot = prev.parent.parent.parent.parent;
87
- } catch (_e) {
88
- }
89
- if (tableBlot && tableBlot.domNode !== betterTableModule.table) {
90
- betterTableModule.hideTableTools();
91
- tableBlot.remove();
92
- this.quill.update(Quill.sources.USER);
93
- }
94
- return false;
95
- }
96
- }
97
- }
98
- return true;
99
- });
100
- const thisBinding = quill.keyboard.bindings.Backspace.pop();
101
- quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding);
102
- quill.clipboard.addMatcher("td", matchTableCell);
103
- quill.clipboard.addMatcher("th", matchTableHeader);
104
- quill.clipboard.addMatcher("table", matchTable);
105
- quill.clipboard.addMatcher("h1, h2, h3, h4, h5, h6", matchHeader);
106
- quill.clipboard.addMatcher("ol, ul", matchList);
107
- quill.clipboard.addMatcher("span", matchMentionLink);
108
- quill.clipboard.addMatcher("v:imageData", matchWordShapeImage);
109
- quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline);
110
- quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {
111
- return matcher[0] !== "tr";
112
- });
113
- quill.clipboard.addMatcher("tr", matchTableRow);
114
- this.quill.on(Quill.events.EDITOR_CHANGE, () => {
115
- const tableContainer = Quill.find(this.table);
116
- if (!tableContainer) {
117
- this.hideTableTools();
118
- }
119
- });
120
- this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {
121
- if (!range) return;
122
- const selectionStart = range.index;
123
- const selectionEnd = range.index + range.length;
124
- if (source === Quill.sources.USER) {
125
- const tables = this.quill.root.getElementsByTagName("table");
126
- if (tables && tables.length) {
127
- [].forEach.call(tables, (table) => {
128
- const tableContainer = Quill.find(table);
129
- if (tableContainer) {
130
- const tableStart = tableContainer.offset(this.quill.scroll);
131
- const tableEnd = tableStart + tableContainer.length();
132
- const classes = Array.from(table.parentNode.classList);
133
- if (selectionStart <= tableStart && tableEnd <= selectionEnd) {
134
- table.parentNode.classList.add("quill-better-table-selected");
135
- } else if (classes.includes("quill-better-table-selected")) {
136
- table.parentNode.classList.remove("quill-better-table-selected");
137
- }
138
- }
139
- });
140
- }
141
- }
142
- });
143
- this.initTableSelector();
144
- }
145
- initTableSelector() {
146
- const toolbar = this.quill.getModule("toolbar");
147
- if (!toolbar) return;
148
- const tableButton = toolbar.container.querySelector(".ql-better-table");
149
- if (!tableButton) return;
150
- const tableSelectorWrapper = this.tableSelectorWrapperCreator();
151
- tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton);
152
- tableSelectorWrapper.appendChild(tableButton);
153
- this.tableSelectorWrapper = tableSelectorWrapper;
154
- tableSelectorWrapper.addEventListener("mouseenter", this.handleTableSelectorHover.bind(this), false);
155
- tableSelectorWrapper.addEventListener("mouseleave", this.handleTableSelectorMouseOut.bind(this), false);
156
- }
157
- tableSelectorWrapperCreator() {
158
- const wrapper = document.createElement("div");
159
- wrapper.className = "ql-better-table-wrapper";
160
- const cssContent = {
161
- position: "relative",
162
- display: "flex",
163
- alignItems: "center",
164
- justifyContent: "center",
165
- boxSizing: "border-box"
166
- };
167
- css(wrapper, cssContent);
168
- return wrapper;
169
- }
170
- handleMouseDown(evt, quill) {
171
- const path = getEventComposedPath(evt);
172
- if (!path || path.length <= 0) return;
173
- const tableNode = path.filter((node) => {
174
- return node.tagName && node.tagName.toUpperCase() === "TABLE" && node.classList.contains("quill-better-table");
175
- })[0];
176
- if (tableNode) {
177
- tableNode.parentNode.classList.remove("quill-better-table-selected");
178
- if (this.table === tableNode) return;
179
- if (this.table) {
180
- this.hideTableTools();
181
- }
182
- if (!quill.options.readOnly) {
183
- this.showTableTools(tableNode, quill);
184
- }
185
- } else if (this.table) {
186
- this.hideTableTools();
187
- }
188
- }
189
- handleKeyDown(evt, quill) {
190
- const key = evt.key;
191
- const range = quill.getSelection();
192
- if (this.isComposition || !range) return;
193
- const [col] = quill.getLine(range.index);
194
- const [td] = quill.getLine(range.index - 1);
195
- if (key && key !== "Delete" && col && range) {
196
- if (col.statics.blotName === "table-col") {
197
- const betterTableModule = this.quill.getModule("better-table");
198
- betterTableModule.hideTableTools();
199
- quill.insertText(range.index - 1, "\n", Quill.sources.USER);
200
- quill.setSelection(range.index, 0, Quill.sources.USER);
201
- } else if (td && td.statics.blotName === "table-cell-line" && col.statics.blotName === "block") {
202
- quill.insertText(range.index, "\n", Quill.sources.USER);
203
- quill.setSelection(range.index, 0, Quill.sources.USER);
204
- }
205
- }
206
- }
207
- handleCompositionstart(quill) {
208
- this.isComposition = true;
209
- const range = quill.getSelection();
210
- const [col] = quill.getLine(range.index);
211
- const [td] = quill.getLine(range.index - 1);
212
- if (col && range) {
213
- if (col.statics.blotName === "table-col") {
214
- const betterTableModule = this.quill.getModule("better-table");
215
- betterTableModule.hideTableTools();
216
- quill.insertText(range.index - 1, "\n ", Quill.sources.USER);
217
- quill.setSelection(range.index, 0, Quill.sources.USER);
218
- } else if (td && td.statics.blotName === "table-cell-line" && col.statics.blotName === "block") {
219
- quill.setSelection(range.index, 0, Quill.sources.USER);
220
- }
221
- }
222
- }
223
- handleCompositionend(quill) {
224
- const range = quill.getSelection();
225
- const [line] = quill.getLine(range.index);
226
- const domNode = line.domNode;
227
- const isInParagraph = domNode.nodeName === "P";
228
- const isInTableCell = line.statics.blotName === "table-cell-line";
229
- if ((isInParagraph || isInTableCell) && domNode.childNodes.length > 1 && domNode.childNodes[0].nodeName === "BR") {
230
- domNode.childNodes[0].remove();
231
- }
232
- if (isPureIE && line instanceof Block) {
233
- quill.setSelection(range.index, 0, Quill.sources.SILENT);
234
- }
235
- this.isComposition = false;
236
- }
237
- // 触发table selector
238
- handleTableSelectorHover() {
239
- if (this.isTableSelectorVisible) return;
240
- if (!this.tableSelectorWrapper) return;
241
- this.isTableSelectorVisible = true;
242
- this.tableSelector = new TableSelector({
243
- onSelect: (rows, cols) => this.insertTable(rows, cols)
244
- });
245
- this.tableSelectorWrapper.appendChild(this.tableSelector.container);
246
- const buttonRect = this.tableSelectorWrapper.getBoundingClientRect();
247
- this.tableSelector.show(
248
- 0,
249
- buttonRect.height
250
- );
251
- }
252
- // table selector 鼠标离开
253
- handleTableSelectorMouseOut() {
254
- if (this.tableSelector) {
255
- this.tableSelector.destroy();
256
- }
257
- this.tableSelector = null;
258
- this.isTableSelectorVisible = false;
259
- }
260
- getTable(range = this.quill.getSelection()) {
261
- if (isNullOrUndefined(range)) return [null, null, null, -1];
262
- const [cellLine, offset] = this.quill.getLine(range.index);
263
- if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {
264
- return [null, null, null, -1];
265
- }
266
- const cell = cellLine.tableCell();
267
- const row = cell.row();
268
- const table = row.table();
269
- return [table, row, cell, offset];
270
- }
271
- insertTable(rows, columns) {
272
- const range = this.quill.getSelection(true);
273
- const isInsideTable = insideTable(range, this.quill);
274
- if (isNullOrUndefined(range) || isInsideTable) return;
275
- let delta = new Delta().retain(range.index);
276
- delta.insert("\n");
277
- delta = new Array(columns).fill("\n").reduce((memo, text) => {
278
- memo.insert(text, { "table-col": true });
279
- return memo;
280
- }, delta);
281
- delta = new Array(rows).fill(0).reduce((memo) => {
282
- const tableRowId = rowId();
283
- return new Array(columns).fill("\n").reduce((op, text) => {
284
- op.insert(text, { "table-cell-line": { row: tableRowId, cell: cellId() } });
285
- return op;
286
- }, memo);
287
- }, delta);
288
- const [col] = this.quill.getLine(range.index);
289
- if (col && col.statics.blotName === "table-col") {
290
- delta.insert("\n");
291
- }
292
- this.quill.updateContents(delta, Quill.sources.USER);
293
- const [cellLine] = this.quill.getLine(range.index + columns + 1);
294
- if (cellLine) {
295
- const cell = cellLine.tableCell();
296
- const td = cell.domNode;
297
- const mousedownEvent = document.createEvent("MouseEvent");
298
- const mouseupEvent = document.createEvent("MouseEvent");
299
- const keyEvent = document.createEvent("Event");
300
- mousedownEvent.initEvent("mousedown", true, false);
301
- mouseupEvent.initEvent("mouseup", true, false);
302
- keyEvent.initEvent("keypress", true, false);
303
- td.dispatchEvent(mousedownEvent);
304
- td.dispatchEvent(mouseupEvent);
305
- td.dispatchEvent(keyEvent);
306
- this.tableSelection.endTd = td;
307
- }
308
- }
309
- showTableTools(table, quill) {
310
- this.table = table;
311
- this.modulesContainer = document.createElement("div");
312
- this.modulesContainer.classList.add("qlbt-modules-container");
313
- const linkContainer = this.quill.root.parentNode.querySelector(".ql-tooltip ");
314
- this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer);
315
- this.tableSelection = new TableSelection(table, quill, this.modulesContainer);
316
- this.columnTool = new TableColumnTool(table, quill, this.modulesContainer);
317
- this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer);
318
- let timeoutID;
319
- this.subscriber = () => {
320
- clearTimeout(timeoutID);
321
- timeoutID = setTimeout(this.hideTableTools, 300);
322
- };
323
- window.addEventListener("resize", this.subscriber, false);
324
- }
325
- hideTableTools() {
326
- if (this.columnTool) {
327
- this.columnTool.destroy();
328
- }
329
- if (this.tableSelection) {
330
- this.tableSelection.destroy();
331
- }
332
- if (this.tableOperationMenu) {
333
- this.tableOperationMenu.destroy();
334
- }
335
- if (this.tableScrollBar) {
336
- this.tableScrollBar.destroy();
337
- }
338
- if (this.modulesContainer) {
339
- this.modulesContainer.remove();
340
- }
341
- this.columnTool = null;
342
- this.tableSelection = null;
343
- this.tableOperationMenu = null;
344
- this.tableScrollBar = null;
345
- this.modulesContainer = null;
346
- this.table = null;
347
- if (this.subscriber) {
348
- window.removeEventListener("resize", this.subscriber);
349
- }
350
- }
351
- }
352
- BetterTable.keyboardBindings = {
353
- "line delete": {
354
- key: "Delete",
355
- shiftKey: null,
356
- format: { "table-col": false, "table-cell-line": false },
357
- collapsed: true,
358
- offset: 0,
359
- handler(range, context) {
360
- if (range.index === 0 && context.line.next && context.line.next.statics.blotName === "table-view") {
361
- const [p] = this.quill.getLine(range.index - 1);
362
- const [col] = this.quill.getLine(range.index + 1);
363
- if (p && p.statics.blotName === "block" && col && col.statics.blotName === "table-col") {
364
- return false;
365
- }
366
- }
367
- return true;
368
- }
369
- },
370
- "table-col enter": {
371
- key: "Enter",
372
- shiftKey: null,
373
- format: ["table-col"],
374
- collapsed: true,
375
- offset: 0,
376
- handler(range, context) {
377
- if (context.offset === 0 && range.length === 0) {
378
- const [col] = this.quill.getLine(range.index);
379
- if (col && col.statics.blotName === "table-col") {
380
- const betterTableModule = this.quill.getModule("better-table");
381
- betterTableModule.hideTableTools();
382
- this.quill.insertText(range.index - 1, "\n", Quill.sources.USER);
383
- this.quill.setSelection(range.index, 0, Quill.sources.USER);
384
- }
385
- }
386
- }
387
- },
388
- "table-col delete": {
389
- key: "Delete",
390
- shiftKey: null,
391
- format: ["table-col"],
392
- collapsed: true,
393
- offset: 0,
394
- handler(range, context) {
395
- if (context.offset === 0 && range.length === 0) {
396
- const [col] = this.quill.getLine(range.index);
397
- if (col && col.statics.blotName === "table-col") {
398
- const betterTableModule = this.quill.getModule("better-table");
399
- let tableBlot;
400
- try {
401
- tableBlot = col.parent.parent.parent;
402
- } catch (_e) {
403
- }
404
- if (tableBlot && tableBlot.domNode !== betterTableModule.table) {
405
- betterTableModule.hideTableTools();
406
- tableBlot.remove();
407
- this.quill.update(Quill.sources.USER);
408
- }
409
- }
410
- }
411
- }
412
- },
413
- "table-col backspace": {
414
- key: "Backspace",
415
- shiftKey: null,
416
- format: ["table-col"],
417
- collapsed: true,
418
- offset: 0,
419
- handler() {
420
- }
421
- },
422
- "table-cell-line backspace": {
423
- key: "Backspace",
424
- format: ["table-cell-line"],
425
- collapsed: true,
426
- offset: 0,
427
- handler(range) {
428
- const [line] = this.quill.getLine(range.index);
429
- if (!line.prev) {
430
- return false;
431
- }
432
- return true;
433
- }
434
- },
435
- "table-cell-line delete": {
436
- key: "Delete",
437
- format: ["table-cell-line"],
438
- handler(range, _context) {
439
- const [line] = this.quill.getLine(range.index);
440
- const index = this.quill.getIndex(line);
441
- const length = line.length();
442
- if (!line.next && (!line.prev && length === 1 || range.index !== index && range.index + 1 >= index + length)) {
443
- return false;
444
- }
445
- return true;
446
- }
447
- },
448
- "table-cell-line enter": {
449
- key: "Enter",
450
- shiftKey: null,
451
- format: ["table-cell-line"],
452
- handler(range, context) {
453
- const node = window.getSelection().anchorNode;
454
- if (node instanceof HTMLDivElement && node.classList.contains("quill-better-table-wrapper")) {
455
- this.quill.setSelection(range.index + 1, 0, Quill.sources.USER);
456
- this.quill.focus();
457
- return;
458
- }
459
- if (this.quill.selection && this.quill.selection.composing) return;
460
- const Scope = Quill.imports.parchment.Scope;
461
- if (range.length > 0) {
462
- this.quill.scroll.deleteAt(range.index, range.length);
463
- }
464
- const lineFormats = Object.keys(context.format).reduce((formats, format) => {
465
- if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {
466
- formats[format] = context.format[format];
467
- }
468
- return formats;
469
- }, {});
470
- this.quill.insertText(range.index, "\n", lineFormats["table-cell-line"], Quill.sources.USER);
471
- this.quill.setSelection(range.index + 1, Quill.sources.SILENT);
472
- this.quill.focus();
473
- Object.keys(context.format).forEach((name) => {
474
- if (!isNullOrUndefined(lineFormats[name])) return;
475
- if (Array.isArray(context.format[name])) return;
476
- if (name === "link") return;
477
- this.quill.format(name, context.format[name], Quill.sources.USER);
478
- });
479
- }
480
- }
481
- };
482
- export {
483
- BetterTable as default
484
- };
485
- //# sourceMappingURL=better-table.es.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"better-table.es.js","sources":["../../../../src/modules/table/better-table.ts"],"sourcesContent":["import Quill from 'quill'\r\nimport {\r\n getEventComposedPath,\r\n insideTable,\r\n isNullOrUndefined,\r\n isPureIE,\r\n} from '../../config/editor.utils'\r\nimport Header from './formats/header'\r\nimport List from './formats/list'\r\nimport {\r\n cellId,\r\n rowId,\r\n TableBody,\r\n TableCell,\r\n TableCellLine,\r\n TableCol,\r\n TableColGroup,\r\n TableContainer,\r\n TableRow,\r\n TableViewWrapper,\r\n} from './formats/table'\r\nimport TableColumnTool from './modules/table-column-tool'\r\nimport TableOperationMenu from './modules/table-operation-menu'\r\nimport TableScrollBar from './modules/table-scroll-bar'\r\nimport TableSelection from './modules/table-selection'\r\nimport TableSelector from './modules/table-selector'\r\nimport { css } from './utils'\r\n// import table node matchers\r\nimport {\r\n matchHeader,\r\n matchInline,\r\n matchList,\r\n matchMentionLink,\r\n matchTable,\r\n matchTableCell,\r\n matchTableHeader,\r\n matchTableRow,\r\n matchWordShapeImage,\r\n} from './utils/node-matchers'\r\n\r\nconst Block = Quill.imports['blots/block']\r\nconst Delta = Quill.imports.delta\r\nconst Module = Quill.imports['core/module']\r\n\r\n// @dynamic\r\nclass BetterTable extends Module {\r\n static keyboardBindings: any\r\n isComposition: boolean\r\n quill: any\r\n table: any\r\n modulesContainer: any\r\n tableSelection: any\r\n subscriber: any\r\n tableOperationMenu: any\r\n columnTool: TableColumnTool\r\n tableScrollBar: TableScrollBar\r\n tableSelector: TableSelector\r\n isTableSelectorVisible: boolean\r\n tableSelectorWrapper: HTMLDivElement\r\n\r\n static register() {\r\n Quill.register(TableCol, true)\r\n Quill.register(TableColGroup, true)\r\n Quill.register(TableCellLine, true)\r\n Quill.register(TableCell, true)\r\n Quill.register(TableRow, true)\r\n Quill.register(TableBody, true)\r\n Quill.register(TableContainer, true)\r\n Quill.register(TableViewWrapper, true)\r\n // register customized Header, overwriting quill built-in Header\r\n Quill.register('formats/header', Header, true)\r\n // register customized List, overwriting quill built-in Header\r\n Quill.register('formats/list', List, true)\r\n }\r\n\r\n constructor(quill, options) {\r\n super(quill, options)\r\n\r\n // handle click on quill-better-table\r\n this.isComposition = false\r\n this.isTableSelectorVisible = false\r\n this.quill.root.addEventListener('mousedown', event => this.handleMouseDown(event, quill), false)\r\n this.quill.root.addEventListener('compositionend', () => this.handleCompositionend(quill), false)\r\n this.quill.root.addEventListener('compositionstart', () => this.handleCompositionstart(quill), false)\r\n this.quill.root.addEventListener('keypress', event => this.handleKeyDown(event, quill), false)\r\n\r\n // handle right click on quill-better-table\r\n this.quill.root.addEventListener(\r\n 'contextmenu',\r\n (evt) => {\r\n if (!this.table) return true\r\n evt.preventDefault()\r\n\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n\r\n const tableNode = path.filter((node) => {\r\n return (\r\n node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n )\r\n })[0]\r\n\r\n const rowNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TR' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const cellNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TD' && node.getAttribute('data-row')\r\n })[0]\r\n\r\n const isTargetCellSelected = this.tableSelection.selectedTds\r\n .map(tableCell => tableCell.domNode)\r\n .includes(cellNode)\r\n\r\n if (this.tableSelection.selectedTds.length <= 0 || !isTargetCellSelected) {\r\n this.tableSelection.setSelection(cellNode.getBoundingClientRect(), cellNode.getBoundingClientRect())\r\n }\r\n\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu = this.tableOperationMenu.destroy()\r\n }\r\n\r\n if (tableNode) {\r\n this.tableOperationMenu = new TableOperationMenu(\r\n {\r\n table: tableNode,\r\n row: rowNode,\r\n cell: cellNode,\r\n left: evt.x + 15,\r\n top: evt.y,\r\n },\r\n quill,\r\n options.operationMenu,\r\n )\r\n }\r\n },\r\n false,\r\n )\r\n\r\n // add keyboard binding:Backspace\r\n // prevent user hits backspace to delete table cell\r\n quill.keyboard.addBinding({ key: 'Backspace' }, {}, (range, context) => {\r\n if (range.index === 0 || this.quill.getLength() <= 1) return true\r\n if (context.offset === 0 && range.length === 0) {\r\n const [prev] = this.quill.getLine(range.index - 1)\r\n const [line] = this.quill.getLine(range.index)\r\n if (!isNullOrUndefined(prev)) {\r\n if (prev.statics.blotName === 'table-cell-line' && line.statics.blotName !== 'table-cell-line') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = prev.parent.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n return false\r\n }\r\n }\r\n }\r\n return true\r\n })\r\n // since only one matched bindings callback will execute.\r\n // expected my binding callback execute first\r\n // I changed the order of binding callbacks\r\n const thisBinding = quill.keyboard.bindings.Backspace.pop()\r\n quill.keyboard.bindings.Backspace.splice(1, 0, thisBinding)\r\n\r\n // add Matchers to match and render quill-better-table for initialization\r\n // or pasting\r\n quill.clipboard.addMatcher('td', matchTableCell)\r\n quill.clipboard.addMatcher('th', matchTableHeader)\r\n quill.clipboard.addMatcher('table', matchTable)\r\n quill.clipboard.addMatcher('h1, h2, h3, h4, h5, h6', matchHeader)\r\n quill.clipboard.addMatcher('ol, ul', matchList)\r\n quill.clipboard.addMatcher('span', matchMentionLink)\r\n quill.clipboard.addMatcher('v:imageData', matchWordShapeImage)\r\n quill.clipboard.addMatcher(Node.ELEMENT_NODE, matchInline)\r\n\r\n // remove matcher for tr tag\r\n quill.clipboard.matchers = quill.clipboard.matchers.filter((matcher) => {\r\n return matcher[0] !== 'tr'\r\n })\r\n\r\n // fix: 处理空<tr>标签被忽略的情况\r\n quill.clipboard.addMatcher('tr', matchTableRow)\r\n\r\n this.quill.on(Quill.events.EDITOR_CHANGE, () => {\r\n const tableContainer = Quill.find(this.table)\r\n if (!tableContainer) {\r\n this.hideTableTools()\r\n }\r\n })\r\n\r\n this.quill.on(Quill.events.SELECTION_CHANGE, (range, _oldRange, source) => {\r\n if (!range) return\r\n const selectionStart = range.index\r\n const selectionEnd = range.index + range.length\r\n if (source === Quill.sources.USER) {\r\n const tables = this.quill.root.getElementsByTagName('table')\r\n if (tables && tables.length) {\r\n [].forEach.call(tables, (table) => {\r\n const tableContainer = Quill.find(table)\r\n if (tableContainer) {\r\n const tableStart = tableContainer.offset(this.quill.scroll)\r\n const tableEnd = tableStart + tableContainer.length()\r\n // @ts-ignore\r\n const classes = Array.from(table.parentNode.classList)\r\n\r\n if (selectionStart <= tableStart && tableEnd <= selectionEnd) {\r\n // @ts-ignore\r\n table.parentNode.classList.add('quill-better-table-selected')\r\n }\r\n else if (classes.includes('quill-better-table-selected')) {\r\n // @ts-ignore\r\n table.parentNode.classList.remove('quill-better-table-selected')\r\n }\r\n }\r\n })\r\n }\r\n }\r\n })\r\n this.initTableSelector()\r\n }\r\n\r\n initTableSelector() {\r\n // feat table selector ,在better-table按钮上套一层容器,往容器添加table selector\r\n const toolbar = this.quill.getModule('toolbar')\r\n if (!toolbar) return\r\n const tableButton = toolbar.container.querySelector('.ql-better-table')\r\n if (!tableButton) return\r\n const tableSelectorWrapper = this.tableSelectorWrapperCreator()\r\n tableButton.parentNode.insertBefore(tableSelectorWrapper, tableButton)\r\n tableSelectorWrapper.appendChild(tableButton)\r\n this.tableSelectorWrapper = tableSelectorWrapper\r\n tableSelectorWrapper.addEventListener('mouseenter', this.handleTableSelectorHover.bind(this), false)\r\n tableSelectorWrapper.addEventListener('mouseleave', this.handleTableSelectorMouseOut.bind(this), false)\r\n }\r\n\r\n tableSelectorWrapperCreator() {\r\n const wrapper = document.createElement('div')\r\n wrapper.className = 'ql-better-table-wrapper'\r\n const cssContent = {\r\n position: 'relative',\r\n display: 'flex',\r\n alignItems: 'center',\r\n justifyContent: 'center',\r\n boxSizing: 'border-box',\r\n }\r\n css(wrapper, cssContent)\r\n return wrapper\r\n }\r\n\r\n handleMouseDown(evt, quill) {\r\n // bugfix: evt.path is undefined in Safari, FF, Micro Edge\r\n const path = getEventComposedPath(evt)\r\n if (!path || path.length <= 0) return\r\n const tableNode = path.filter((node) => {\r\n return node.tagName && node.tagName.toUpperCase() === 'TABLE' && node.classList.contains('quill-better-table')\r\n })[0]\r\n if (tableNode) {\r\n tableNode.parentNode.classList.remove('quill-better-table-selected')\r\n // current table clicked\r\n if (this.table === tableNode) return\r\n // other table clicked\r\n if (this.table) {\r\n this.hideTableTools()\r\n }\r\n if (!quill.options.readOnly) { // not show table tool in readonly mode\r\n this.showTableTools(tableNode, quill)\r\n }\r\n }\r\n else if (this.table) {\r\n // other clicked\r\n this.hideTableTools()\r\n }\r\n }\r\n\r\n handleKeyDown(evt, quill) {\r\n const key = evt.key\r\n const range = quill.getSelection()\r\n if (this.isComposition || !range) return\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (key && key !== 'Delete' && col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.insertText(range.index, '\\n', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionstart(quill) {\r\n this.isComposition = true\r\n const range = quill.getSelection()\r\n const [col] = quill.getLine(range.index)\r\n const [td] = quill.getLine(range.index - 1)\r\n if (col && range) {\r\n if (col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n quill.insertText(range.index - 1, '\\n\\t', Quill.sources.USER)\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n else if (td && td.statics.blotName === 'table-cell-line' && col.statics.blotName === 'block') {\r\n quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n }\r\n\r\n handleCompositionend(quill) {\r\n // fix: 解决在空行行首用中文输入法输入字符,然后按退格导致插入多余空行的问题\r\n const range = quill.getSelection()\r\n const [line] = quill.getLine(range.index)\r\n const domNode = line.domNode\r\n const isInParagraph = domNode.nodeName === 'P'\r\n const isInTableCell = line.statics.blotName === 'table-cell-line'\r\n if ((isInParagraph || isInTableCell)\r\n && domNode.childNodes.length > 1\r\n && domNode.childNodes[0].nodeName === 'BR') {\r\n domNode.childNodes[0].remove()\r\n }\r\n\r\n if (isPureIE && line instanceof Block) {\r\n // 设置光标位置防止跳入下一行\r\n quill.setSelection(range.index, 0, Quill.sources.SILENT)\r\n }\r\n\r\n this.isComposition = false\r\n }\r\n\r\n // 触发table selector\r\n handleTableSelectorHover() {\r\n if (this.isTableSelectorVisible) return\r\n if (!this.tableSelectorWrapper) return\r\n this.isTableSelectorVisible = true\r\n this.tableSelector = new TableSelector({\r\n onSelect: (rows, cols) => this.insertTable(rows, cols),\r\n })\r\n this.tableSelectorWrapper.appendChild(this.tableSelector.container)\r\n const buttonRect = this.tableSelectorWrapper.getBoundingClientRect()\r\n this.tableSelector.show(\r\n 0,\r\n buttonRect.height,\r\n )\r\n }\r\n\r\n // table selector 鼠标离开\r\n handleTableSelectorMouseOut() {\r\n if (this.tableSelector) {\r\n this.tableSelector.destroy()\r\n }\r\n this.tableSelector = null\r\n this.isTableSelectorVisible = false\r\n }\r\n\r\n getTable(range = this.quill.getSelection()) {\r\n if (isNullOrUndefined(range)) return [null, null, null, -1]\r\n const [cellLine, offset] = this.quill.getLine(range.index)\r\n if (isNullOrUndefined(cellLine) || cellLine.statics.blotName !== TableCellLine.blotName) {\r\n return [null, null, null, -1]\r\n }\r\n const cell = cellLine.tableCell()\r\n const row = cell.row()\r\n const table = row.table()\r\n return [table, row, cell, offset]\r\n }\r\n\r\n insertTable(rows, columns) {\r\n const range = this.quill.getSelection(true)\r\n const isInsideTable = insideTable(range, this.quill)\r\n if (isNullOrUndefined(range) || isInsideTable) return\r\n // let currentBlot = this.quill.getLeaf(range.index)[0]\r\n // let nextBlot = this.quill.getLeaf(range.index + 1)[0]\r\n let delta = new Delta().retain(range.index)\r\n\r\n delta.insert('\\n')\r\n // insert table column\r\n delta = new Array(columns).fill('\\n').reduce((memo, text) => {\r\n memo.insert(text, { 'table-col': true })\r\n return memo\r\n }, delta)\r\n // insert table cell line with empty line\r\n delta = new Array(rows).fill(0).reduce((memo) => {\r\n const tableRowId = rowId()\r\n return new Array(columns).fill('\\n').reduce((op, text) => {\r\n op.insert(text, { 'table-cell-line': { row: tableRowId, cell: cellId() } })\r\n return op\r\n }, memo)\r\n }, delta)\r\n\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n delta.insert('\\n')\r\n }\r\n\r\n this.quill.updateContents(delta, Quill.sources.USER)\r\n\r\n // feature: 新增表格后首格自动激活编辑状态,initEvent兼容IE\r\n const [cellLine] = this.quill.getLine(range.index + columns + 1)\r\n if (cellLine) {\r\n const cell = cellLine.tableCell()\r\n const td = cell.domNode\r\n const mousedownEvent = document.createEvent('MouseEvent')\r\n const mouseupEvent = document.createEvent('MouseEvent')\r\n const keyEvent = document.createEvent('Event')\r\n mousedownEvent.initEvent('mousedown', true, false)\r\n mouseupEvent.initEvent('mouseup', true, false)\r\n keyEvent.initEvent('keypress', true, false)\r\n td.dispatchEvent(mousedownEvent)\r\n td.dispatchEvent(mouseupEvent)\r\n td.dispatchEvent(keyEvent)\r\n this.tableSelection.endTd = td\r\n }\r\n }\r\n\r\n showTableTools(table, quill) {\r\n this.table = table\r\n this.modulesContainer = document.createElement('div')\r\n this.modulesContainer.classList.add('qlbt-modules-container')\r\n // fix:表格容器插入时获取ql-tooltip容器,用insertBefore插入到它前面,避免遮挡链接浮窗\r\n const linkContainer = this.quill.root.parentNode.querySelector('.ql-tooltip ')\r\n this.quill.root.parentNode.insertBefore(this.modulesContainer, linkContainer)\r\n this.tableSelection = new TableSelection(table, quill, this.modulesContainer)\r\n this.columnTool = new TableColumnTool(table, quill, this.modulesContainer)\r\n this.tableScrollBar = new TableScrollBar(table, quill, this.modulesContainer)\r\n let timeoutID\r\n this.subscriber = () => {\r\n clearTimeout(timeoutID)\r\n timeoutID = setTimeout(this.hideTableTools, 300)\r\n }\r\n window.addEventListener('resize', this.subscriber, false)\r\n }\r\n\r\n hideTableTools() {\r\n if (this.columnTool) {\r\n this.columnTool.destroy()\r\n }\r\n if (this.tableSelection) {\r\n this.tableSelection.destroy()\r\n }\r\n if (this.tableOperationMenu) {\r\n this.tableOperationMenu.destroy()\r\n }\r\n if (this.tableScrollBar) {\r\n this.tableScrollBar.destroy()\r\n }\r\n if (this.modulesContainer) {\r\n this.modulesContainer.remove()\r\n }\r\n this.columnTool = null\r\n this.tableSelection = null\r\n this.tableOperationMenu = null\r\n this.tableScrollBar = null\r\n this.modulesContainer = null\r\n this.table = null\r\n if (this.subscriber) {\r\n window.removeEventListener('resize', this.subscriber)\r\n }\r\n }\r\n}\r\n\r\nBetterTable.keyboardBindings = {\r\n 'line delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: { 'table-col': false, 'table-cell-line': false },\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n // fix: 当光标在编辑器最前且之后为表格时按delete不执行操作\r\n if (range.index === 0 && context.line.next && context.line.next.statics.blotName === 'table-view') {\r\n const [p] = this.quill.getLine(range.index - 1)\r\n const [col] = this.quill.getLine(range.index + 1)\r\n if (p && p.statics.blotName === 'block' && col && col.statics.blotName === 'table-col') {\r\n return false\r\n }\r\n }\r\n return true\r\n },\r\n },\r\n 'table-col enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n betterTableModule.hideTableTools()\r\n this.quill.insertText(range.index - 1, '\\n', Quill.sources.USER)\r\n this.quill.setSelection(range.index, 0, Quill.sources.USER)\r\n }\r\n }\r\n },\r\n },\r\n 'table-col delete': {\r\n key: 'Delete',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range, context) {\r\n if (context.offset === 0 && range.length === 0) {\r\n const [col] = this.quill.getLine(range.index)\r\n if (col && col.statics.blotName === 'table-col') {\r\n const betterTableModule = this.quill.getModule('better-table')\r\n let tableBlot\r\n try {\r\n tableBlot = col.parent.parent.parent\r\n }\r\n catch (_e) { }\r\n if (tableBlot && tableBlot.domNode !== betterTableModule.table) {\r\n betterTableModule.hideTableTools()\r\n tableBlot.remove()\r\n this.quill.update(Quill.sources.USER)\r\n }\r\n }\r\n }\r\n },\r\n },\r\n 'table-col backspace': {\r\n key: 'Backspace',\r\n shiftKey: null,\r\n format: ['table-col'],\r\n collapsed: true,\r\n offset: 0,\r\n handler() { },\r\n },\r\n 'table-cell-line backspace': {\r\n key: 'Backspace',\r\n format: ['table-cell-line'],\r\n collapsed: true,\r\n offset: 0,\r\n handler(range) {\r\n const [line] = this.quill.getLine(range.index)\r\n // 移除原有对非table-cell-line的阻止条件,使table-cell-line前的list等内容可以被删除\r\n if (!line.prev) {\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line delete': {\r\n key: 'Delete',\r\n format: ['table-cell-line'],\r\n handler(range, _context) {\r\n // 获取table-cell-line的索引和长度\r\n const [line] = this.quill.getLine(range.index)\r\n const index = this.quill.getIndex(line)\r\n const length = line.length()\r\n if (!line.next // 当无下一个元素且满足以下情况阻止删除操作\r\n && ((!line.prev && length === 1) // 单元格内只有一个table-cell-line且无内容\r\n || (range.index !== index && range.index + 1 >= index + length))) { // 光标在有内容的table-cell-line最后\r\n return false\r\n }\r\n return true\r\n },\r\n },\r\n 'table-cell-line enter': {\r\n key: 'Enter',\r\n shiftKey: null,\r\n format: ['table-cell-line'],\r\n handler(range, context) {\r\n // fix:通过window的光标选区当前指向判断,如果为HTMLElement且为表格容器则定位至下一行\r\n const node = window.getSelection().anchorNode\r\n if (node instanceof HTMLDivElement && node.classList.contains('quill-better-table-wrapper')) {\r\n this.quill.setSelection(range.index + 1, 0, Quill.sources.USER)\r\n this.quill.focus()\r\n return\r\n }\r\n // bugfix: a unexpected new line inserted when user compositionend with hitting Enter\r\n if (this.quill.selection && this.quill.selection.composing) return\r\n const Scope = Quill.imports.parchment.Scope\r\n if (range.length > 0) {\r\n this.quill.scroll.deleteAt(range.index, range.length) // So we do not trigger text-change\r\n }\r\n const lineFormats = Object.keys(context.format).reduce((formats, format) => {\r\n if (this.quill.scroll.query(format, Scope.BLOCK) && !Array.isArray(context.format[format])) {\r\n formats[format] = context.format[format]\r\n }\r\n return formats\r\n }, {})\r\n // insert new cellLine with lineFormats\r\n this.quill.insertText(range.index, '\\n', lineFormats['table-cell-line'], Quill.sources.USER)\r\n // Earlier scroll.deleteAt might have messed up our selection,\r\n // so insertText's built in selection preservation is not reliable\r\n this.quill.setSelection(range.index + 1, Quill.sources.SILENT)\r\n this.quill.focus()\r\n Object.keys(context.format).forEach((name) => {\r\n if (!isNullOrUndefined(lineFormats[name])) return\r\n if (Array.isArray(context.format[name])) return\r\n if (name === 'link') return\r\n this.quill.format(name, context.format[name], Quill.sources.USER)\r\n })\r\n },\r\n },\r\n}\r\n\r\nexport default BetterTable\r\n"],"names":["List"],"mappings":";;;;;;;;;;;;AAwCA,MAAM,QAAQ,MAAM,QAAQ,aAAa;AACzC,MAAM,QAAQ,MAAM,QAAQ;AAC5B,MAAM,SAAS,MAAM,QAAQ,aAAa;AAG1C,MAAM,oBAAoB,OAAO;AAAA,EAe/B,OAAO,WAAW;AACV,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,eAAe,IAAI;AAC5B,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,UAAU,IAAI;AACvB,UAAA,SAAS,WAAW,IAAI;AACxB,UAAA,SAAS,gBAAgB,IAAI;AAC7B,UAAA,SAAS,kBAAkB,IAAI;AAE/B,UAAA,SAAS,kBAAkB,QAAQ,IAAI;AAEvC,UAAA,SAAS,gBAAgBA,UAAM,IAAI;AAAA,EAAA;AAAA,EAG3C,YAAY,OAAO,SAAS;AAC1B,UAAM,OAAO,OAAO;AAGpB,SAAK,gBAAgB;AACrB,SAAK,yBAAyB;AACzB,SAAA,MAAM,KAAK,iBAAiB,aAAa,CAAA,UAAS,KAAK,gBAAgB,OAAO,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,kBAAkB,MAAM,KAAK,qBAAqB,KAAK,GAAG,KAAK;AAC3F,SAAA,MAAM,KAAK,iBAAiB,oBAAoB,MAAM,KAAK,uBAAuB,KAAK,GAAG,KA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eAAA;AAAA,MACT,GAAG,EAAE;AAEA,WAAA,MAAM,WAAW,MAAM,OAAO,MAAM,YAAY,iBAAiB,GAAG,MAAM,QAAQ,IAAI;AAG3F,WAAK,MAAM,aAAa,MAAM,QAAQ,GAAG,MAAM,QAAQ,MAAM;AAC7D,WAAK,MAAM,MAAM;AACjB,aAAO,KAAK,QAAQ,MAAM,EAAE,QAAQ,CAAC,SAAS;AAC5C,YAAI,CAAC,kBAAkB,YAAY,IAAI,CAAC,EAAG;AAC3C,YAAI,MAAM,QAAQ,QAAQ,OAAO,IAAI,CAAC,EAAG;AACzC,YAAI,SAAS,OAAQ;AAChB,aAAA,MAAM,OAAO,MAAM,QAAQ,OAAO,IAAI,GAAG,MAAM,QAAQ,IAAI;AAAA,MAAA,CACjE;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1,94 +0,0 @@
1
- import Quill from "quill";
2
- import { isNullOrUndefined } from "../../../config/editor.utils.es.js";
3
- import { CELL_IDENTITY_KEYS, CELL_ATTRIBUTES } from "../table-config.es.js";
4
- const OriginHeader = Quill.import("formats/header");
5
- class Header extends OriginHeader {
6
- static create(value) {
7
- if (typeof value === "string") {
8
- value = { value };
9
- }
10
- const node = super.create(value.value);
11
- CELL_IDENTITY_KEYS.forEach((key) => {
12
- if (value[key]) {
13
- node.setAttribute(`data-${key}`, value[key]);
14
- }
15
- });
16
- CELL_ATTRIBUTES.forEach((key) => {
17
- if (value[key]) {
18
- node.setAttribute(`data-${key}`, value[key]);
19
- }
20
- });
21
- return node;
22
- }
23
- static formats(domNode) {
24
- const formats = {};
25
- formats.value = this.tagName.indexOf(domNode.tagName) + 1;
26
- return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).reduce((tableFormats, attribute) => {
27
- if (domNode.hasAttribute(`data-${attribute}`)) {
28
- tableFormats[attribute] = domNode.getAttribute(`data-${attribute}`) || void 0;
29
- }
30
- return tableFormats;
31
- }, formats);
32
- }
33
- format(name, value) {
34
- if (Object.prototype.toString.call(value) === "[object Object]") {
35
- value = value.value;
36
- }
37
- const headerDom = Header.formats(this.domNode);
38
- const { row, cell, rowspan, colspan } = headerDom;
39
- if (name === Header.blotName) {
40
- if (value) {
41
- super.format(name, {
42
- value,
43
- row,
44
- cell,
45
- rowspan,
46
- colspan
47
- });
48
- } else {
49
- if (row) {
50
- this.replaceWith("table-cell-line", {
51
- row,
52
- cell,
53
- rowspan,
54
- colspan
55
- });
56
- } else {
57
- super.format(name, value);
58
- }
59
- }
60
- } else {
61
- super.format(name, value);
62
- }
63
- }
64
- optimize(_context) {
65
- const { row, cell, rowspan, colspan } = Header.formats(this.domNode);
66
- if (row && this.parent.statics.blotName !== "table") {
67
- this.wrap("table", {
68
- row,
69
- cell,
70
- colspan,
71
- rowspan
72
- });
73
- }
74
- this.enforceAllowedChildren();
75
- if (!isNullOrUndefined(this.uiNode) && this.uiNode !== this.domNode.firstChild) {
76
- this.domNode.insertBefore(this.uiNode, this.domNode.firstChild);
77
- }
78
- if (this.children.length === 0) {
79
- if (!isNullOrUndefined(this.statics.defaultChild)) {
80
- const child = this.scroll.create(this.statics.defaultChild.blotName);
81
- this.appendChild(child);
82
- } else {
83
- this.remove();
84
- }
85
- }
86
- this.cache = {};
87
- }
88
- }
89
- Header.blotName = "header";
90
- Header.tagName = ["H1", "H2", "H3", "H4", "H5", "H6"];
91
- export {
92
- Header as default
93
- };
94
- //# sourceMappingURL=header.es.js.map