@hailin-zheng/editor-core 1.0.5 → 1.0.6

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 (238) hide show
  1. package/lib/doc-ruler.d.ts +51 -0
  2. package/{src/med_editor/doc-ruler.ts → lib/doc-ruler.js} +73 -100
  3. package/lib/doc-ruler.js.map +1 -0
  4. package/lib/framework/common-util.d.ts +63 -0
  5. package/lib/framework/common-util.js +178 -0
  6. package/lib/framework/common-util.js.map +1 -0
  7. package/lib/framework/document-change.d.ts +265 -0
  8. package/{src/med_editor/framework/document-change.ts → lib/framework/document-change.js} +257 -307
  9. package/lib/framework/document-change.js.map +1 -0
  10. package/lib/framework/document-combine.d.ts +24 -0
  11. package/{src/med_editor/framework/document-combine.ts → lib/framework/document-combine.js} +11 -15
  12. package/lib/framework/document-combine.js.map +1 -0
  13. package/lib/framework/document-comment.d.ts +46 -0
  14. package/{src/med_editor/framework/document-comment.ts → lib/framework/document-comment.js} +37 -57
  15. package/lib/framework/document-comment.js.map +1 -0
  16. package/lib/framework/document-context.d.ts +149 -0
  17. package/{src/med_editor/framework/document-context.ts → lib/framework/document-context.js} +101 -181
  18. package/lib/framework/document-context.js.map +1 -0
  19. package/lib/framework/document-eval-func.d.ts +18 -0
  20. package/{src/med_editor/framework/document-eval-func.ts → lib/framework/document-eval-func.js} +11 -16
  21. package/lib/framework/document-eval-func.js.map +1 -0
  22. package/lib/framework/document-event.d.ts +213 -0
  23. package/{src/med_editor/framework/document-event.ts → lib/framework/document-event.js} +216 -244
  24. package/lib/framework/document-event.js.map +1 -0
  25. package/lib/framework/document-history.d.ts +26 -0
  26. package/{src/med_editor/framework/document-history.ts → lib/framework/document-history.js} +14 -25
  27. package/lib/framework/document-history.js.map +1 -0
  28. package/lib/framework/document-images-loader.d.ts +16 -0
  29. package/{src/med_editor/framework/document-images-loader.ts → lib/framework/document-images-loader.js} +17 -25
  30. package/lib/framework/document-images-loader.js.map +1 -0
  31. package/lib/framework/document-input-cursor.d.ts +78 -0
  32. package/{src/med_editor/framework/document-input-cursor.ts → lib/framework/document-input-cursor.js} +71 -76
  33. package/lib/framework/document-input-cursor.js.map +1 -0
  34. package/lib/framework/document-paint.d.ts +34 -0
  35. package/{src/med_editor/framework/document-paint.ts → lib/framework/document-paint.js} +28 -35
  36. package/lib/framework/document-paint.js.map +1 -0
  37. package/lib/framework/document-print-offscreen.d.ts +38 -0
  38. package/{src/med_editor/framework/document-print-offscreen.ts → lib/framework/document-print-offscreen.js} +19 -25
  39. package/lib/framework/document-print-offscreen.js.map +1 -0
  40. package/lib/framework/document-print.d.ts +60 -0
  41. package/{src/med_editor/framework/document-print.ts → lib/framework/document-print.js} +41 -57
  42. package/lib/framework/document-print.js.map +1 -0
  43. package/lib/framework/document-segmenter.d.ts +2 -0
  44. package/lib/framework/document-segmenter.js +106 -0
  45. package/lib/framework/document-segmenter.js.map +1 -0
  46. package/lib/framework/document-selection.d.ts +89 -0
  47. package/{src/med_editor/framework/document-selection.ts → lib/framework/document-selection.js} +84 -117
  48. package/lib/framework/document-selection.js.map +1 -0
  49. package/lib/framework/document-template.d.ts +4 -0
  50. package/{src/med_editor/framework/document-template.ts → lib/framework/document-template.js} +3 -3
  51. package/lib/framework/document-template.js.map +1 -0
  52. package/lib/framework/document-textline-mode.d.ts +7 -0
  53. package/lib/framework/document-textline-mode.js +30 -0
  54. package/lib/framework/document-textline-mode.js.map +1 -0
  55. package/lib/framework/element-define.d.ts +319 -0
  56. package/{src/med_editor/framework/element-define.ts → lib/framework/element-define.js} +206 -301
  57. package/lib/framework/element-define.js.map +1 -0
  58. package/lib/framework/element-event-define.d.ts +99 -0
  59. package/lib/framework/element-event-define.js +108 -0
  60. package/lib/framework/element-event-define.js.map +1 -0
  61. package/lib/framework/element-measure.d.ts +97 -0
  62. package/{src/med_editor/framework/element-measure.ts → lib/framework/element-measure.js} +121 -143
  63. package/lib/framework/element-measure.js.map +1 -0
  64. package/lib/framework/element-paint.d.ts +42 -0
  65. package/{src/med_editor/framework/element-paint.ts → lib/framework/element-paint.js} +37 -43
  66. package/lib/framework/element-paint.js.map +1 -0
  67. package/lib/framework/element-props.d.ts +301 -0
  68. package/{src/med_editor/framework/element-props.ts → lib/framework/element-props.js} +202 -331
  69. package/lib/framework/element-props.js.map +1 -0
  70. package/lib/framework/element-reader.d.ts +19 -0
  71. package/{src/med_editor/framework/element-reader.ts → lib/framework/element-reader.js} +30 -38
  72. package/lib/framework/element-reader.js.map +1 -0
  73. package/lib/framework/element-render-cut.d.ts +55 -0
  74. package/{src/med_editor/framework/element-render-cut.ts → lib/framework/element-render-cut.js} +106 -113
  75. package/lib/framework/element-render-cut.js.map +1 -0
  76. package/lib/framework/element-serialize.d.ts +30 -0
  77. package/{src/med_editor/framework/element-serialize.ts → lib/framework/element-serialize.js} +25 -40
  78. package/lib/framework/element-serialize.js.map +1 -0
  79. package/lib/framework/element-util.d.ts +369 -0
  80. package/{src/med_editor/framework/element-util.ts → lib/framework/element-util.js} +216 -318
  81. package/lib/framework/element-util.js.map +1 -0
  82. package/lib/framework/impl/checkbox/checkbox-impl.d.ts +24 -0
  83. package/{src/med_editor/framework/impl/checkbox/checkbox-impl.ts → lib/framework/impl/checkbox/checkbox-impl.js} +18 -25
  84. package/lib/framework/impl/checkbox/checkbox-impl.js.map +1 -0
  85. package/lib/framework/impl/comments/comment-content-impl.d.ts +40 -0
  86. package/{src/med_editor/framework/impl/comments/comment-content-impl.ts → lib/framework/impl/comments/comment-content-impl.js} +31 -45
  87. package/lib/framework/impl/comments/comment-content-impl.js.map +1 -0
  88. package/lib/framework/impl/comments/comment-element-impl.d.ts +21 -0
  89. package/{src/med_editor/framework/impl/comments/comment-element-impl.ts → lib/framework/impl/comments/comment-element-impl.js} +18 -21
  90. package/lib/framework/impl/comments/comment-element-impl.js.map +1 -0
  91. package/lib/framework/impl/comments/comments-container-impl.d.ts +22 -0
  92. package/{src/med_editor/framework/impl/comments/comments-container-impl.ts → lib/framework/impl/comments/comments-container-impl.js} +15 -21
  93. package/lib/framework/impl/comments/comments-container-impl.js.map +1 -0
  94. package/lib/framework/impl/comments/comments-util.d.ts +12 -0
  95. package/{src/med_editor/framework/impl/comments/comments-util.ts → lib/framework/impl/comments/comments-util.js} +17 -34
  96. package/lib/framework/impl/comments/comments-util.js.map +1 -0
  97. package/lib/framework/impl/comments/validate-msg-impl.d.ts +21 -0
  98. package/{src/med_editor/framework/impl/comments/validate-msg-impl.ts → lib/framework/impl/comments/validate-msg-impl.js} +15 -26
  99. package/lib/framework/impl/comments/validate-msg-impl.js.map +1 -0
  100. package/lib/framework/impl/data-element/data-decorate-impl.d.ts +30 -0
  101. package/{src/med_editor/framework/impl/data-element/data-decorate-impl.ts → lib/framework/impl/data-element/data-decorate-impl.js} +21 -25
  102. package/lib/framework/impl/data-element/data-decorate-impl.js.map +1 -0
  103. package/lib/framework/impl/data-element/data-element-barcode.d.ts +31 -0
  104. package/{src/med_editor/framework/impl/data-element/data-element-barcode.ts → lib/framework/impl/data-element/data-element-barcode.js} +27 -39
  105. package/lib/framework/impl/data-element/data-element-barcode.js.map +1 -0
  106. package/lib/framework/impl/data-element/data-element-base-impl.d.ts +68 -0
  107. package/{src/med_editor/framework/impl/data-element/data-element-base-impl.ts → lib/framework/impl/data-element/data-element-base-impl.js} +44 -73
  108. package/lib/framework/impl/data-element/data-element-base-impl.js.map +1 -0
  109. package/lib/framework/impl/data-element/data-element-check-impl.d.ts +35 -0
  110. package/{src/med_editor/framework/impl/data-element/data-element-check-impl.ts → lib/framework/impl/data-element/data-element-check-impl.js} +33 -46
  111. package/lib/framework/impl/data-element/data-element-check-impl.js.map +1 -0
  112. package/lib/framework/impl/data-element/data-element-date-impl.d.ts +23 -0
  113. package/{src/med_editor/framework/impl/data-element/data-element-date-impl.ts → lib/framework/impl/data-element/data-element-date-impl.js} +22 -39
  114. package/lib/framework/impl/data-element/data-element-date-impl.js.map +1 -0
  115. package/lib/framework/impl/data-element/data-element-group-impl.d.ts +23 -0
  116. package/{src/med_editor/framework/impl/data-element/data-element-group-impl.ts → lib/framework/impl/data-element/data-element-group-impl.js} +29 -49
  117. package/lib/framework/impl/data-element/data-element-group-impl.js.map +1 -0
  118. package/lib/framework/impl/data-element/data-element-image-impl.d.ts +30 -0
  119. package/{src/med_editor/framework/impl/data-element/data-element-image-impl.ts → lib/framework/impl/data-element/data-element-image-impl.js} +26 -36
  120. package/lib/framework/impl/data-element/data-element-image-impl.js.map +1 -0
  121. package/lib/framework/impl/data-element/data-element-list-impl.d.ts +22 -0
  122. package/{src/med_editor/framework/impl/data-element/data-element-list-impl.ts → lib/framework/impl/data-element/data-element-list-impl.js} +30 -41
  123. package/lib/framework/impl/data-element/data-element-list-impl.js.map +1 -0
  124. package/lib/framework/impl/data-element/data-element-text-impl.d.ts +23 -0
  125. package/{src/med_editor/framework/impl/data-element/data-element-text-impl.ts → lib/framework/impl/data-element/data-element-text-impl.js} +20 -34
  126. package/lib/framework/impl/data-element/data-element-text-impl.js.map +1 -0
  127. package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +21 -0
  128. package/{src/med_editor/framework/impl/decorate/fill-null-space-imple.ts → lib/framework/impl/decorate/fill-null-space-imple.js} +10 -15
  129. package/lib/framework/impl/decorate/fill-null-space-imple.js.map +1 -0
  130. package/lib/framework/impl/document/doc-body-impl.d.ts +27 -0
  131. package/{src/med_editor/framework/impl/document/doc-body-impl.ts → lib/framework/impl/document/doc-body-impl.js} +15 -31
  132. package/lib/framework/impl/document/doc-body-impl.js.map +1 -0
  133. package/lib/framework/impl/document/doc-body-part-impl.d.ts +30 -0
  134. package/{src/med_editor/framework/impl/document/doc-body-part-impl.ts → lib/framework/impl/document/doc-body-part-impl.js} +16 -26
  135. package/lib/framework/impl/document/doc-body-part-impl.js.map +1 -0
  136. package/lib/framework/impl/document/doc-container-impl.d.ts +16 -0
  137. package/lib/framework/impl/document/doc-container-impl.js +21 -0
  138. package/lib/framework/impl/document/doc-container-impl.js.map +1 -0
  139. package/lib/framework/impl/document/doc-footer-impl.d.ts +26 -0
  140. package/{src/med_editor/framework/impl/document/doc-footer-impl.ts → lib/framework/impl/document/doc-footer-impl.js} +18 -29
  141. package/lib/framework/impl/document/doc-footer-impl.js.map +1 -0
  142. package/lib/framework/impl/document/doc-header-impl.d.ts +26 -0
  143. package/{src/med_editor/framework/impl/document/doc-header-impl.ts → lib/framework/impl/document/doc-header-impl.js} +16 -33
  144. package/lib/framework/impl/document/doc-header-impl.js.map +1 -0
  145. package/lib/framework/impl/document/doc-impl.d.ts +61 -0
  146. package/{src/med_editor/framework/impl/document/doc-impl.ts → lib/framework/impl/document/doc-impl.js} +42 -59
  147. package/lib/framework/impl/document/doc-impl.js.map +1 -0
  148. package/lib/framework/impl/media-formula/menstrual-history.d.ts +35 -0
  149. package/{src/med_editor/framework/impl/media-formula/menstrual-history.ts → lib/framework/impl/media-formula/menstrual-history.js} +35 -57
  150. package/lib/framework/impl/media-formula/menstrual-history.js.map +1 -0
  151. package/lib/framework/impl/paragraph/p-impl.d.ts +45 -0
  152. package/{src/med_editor/framework/impl/paragraph/p-impl.ts → lib/framework/impl/paragraph/p-impl.js} +28 -62
  153. package/lib/framework/impl/paragraph/p-impl.js.map +1 -0
  154. package/lib/framework/impl/picture/image-impl.d.ts +31 -0
  155. package/{src/med_editor/framework/impl/picture/image-impl.ts → lib/framework/impl/picture/image-impl.js} +23 -35
  156. package/lib/framework/impl/picture/image-impl.js.map +1 -0
  157. package/lib/framework/impl/radio/radio-impl.d.ts +22 -0
  158. package/{src/med_editor/framework/impl/radio/radio-impl.ts → lib/framework/impl/radio/radio-impl.js} +19 -26
  159. package/lib/framework/impl/radio/radio-impl.js.map +1 -0
  160. package/lib/framework/impl/symbol/br-symbol-impl.d.ts +22 -0
  161. package/{src/med_editor/framework/impl/symbol/br-symbol-impl.ts → lib/framework/impl/symbol/br-symbol-impl.js} +14 -20
  162. package/lib/framework/impl/symbol/br-symbol-impl.js.map +1 -0
  163. package/lib/framework/impl/symbol/p-symbol-impl.d.ts +19 -0
  164. package/{src/med_editor/framework/impl/symbol/p-symbol-impl.ts → lib/framework/impl/symbol/p-symbol-impl.js} +11 -14
  165. package/lib/framework/impl/symbol/p-symbol-impl.js.map +1 -0
  166. package/lib/framework/impl/table/table-cell-impl.d.ts +37 -0
  167. package/{src/med_editor/framework/impl/table/table-cell-impl.ts → lib/framework/impl/table/table-cell-impl.js} +28 -39
  168. package/lib/framework/impl/table/table-cell-impl.js.map +1 -0
  169. package/lib/framework/impl/table/table-impl.d.ts +55 -0
  170. package/{src/med_editor/framework/impl/table/table-impl.ts → lib/framework/impl/table/table-impl.js} +82 -120
  171. package/lib/framework/impl/table/table-impl.js.map +1 -0
  172. package/lib/framework/impl/table/table-row-impl.d.ts +26 -0
  173. package/{src/med_editor/framework/impl/table/table-row-impl.ts → lib/framework/impl/table/table-row-impl.js} +16 -24
  174. package/lib/framework/impl/table/table-row-impl.js.map +1 -0
  175. package/lib/framework/impl/table/table-split-cell-patch.d.ts +20 -0
  176. package/{src/med_editor/framework/impl/table/table-split-cell-patch.ts → lib/framework/impl/table/table-split-cell-patch.js} +22 -31
  177. package/lib/framework/impl/table/table-split-cell-patch.js.map +1 -0
  178. package/lib/framework/impl/table/table-split-cell.d.ts +90 -0
  179. package/{src/med_editor/framework/impl/table/table-split-cell.ts → lib/framework/impl/table/table-split-cell.js} +94 -105
  180. package/lib/framework/impl/table/table-split-cell.js.map +1 -0
  181. package/lib/framework/impl/table/table-util.d.ts +150 -0
  182. package/{src/med_editor/framework/impl/table/table-util.ts → lib/framework/impl/table/table-util.js} +157 -195
  183. package/lib/framework/impl/table/table-util.js.map +1 -0
  184. package/lib/framework/impl/text/text-impl.d.ts +32 -0
  185. package/{src/med_editor/framework/impl/text/text-impl.ts → lib/framework/impl/text/text-impl.js} +32 -47
  186. package/lib/framework/impl/text/text-impl.js.map +1 -0
  187. package/lib/framework/impl/text/track-run-impl.d.ts +27 -0
  188. package/{src/med_editor/framework/impl/text/track-run-impl.ts → lib/framework/impl/text/track-run-impl.js} +28 -51
  189. package/lib/framework/impl/text/track-run-impl.js.map +1 -0
  190. package/lib/framework/notify.d.ts +13 -0
  191. package/{src/med_editor/framework/notify.ts → lib/framework/notify.js} +36 -50
  192. package/lib/framework/notify.js.map +1 -0
  193. package/lib/framework/range-util.d.ts +40 -0
  194. package/{src/med_editor/framework/range-util.ts → lib/framework/range-util.js} +71 -80
  195. package/lib/framework/range-util.js.map +1 -0
  196. package/lib/framework/render-context.d.ts +91 -0
  197. package/{src/med_editor/framework/render-context.ts → lib/framework/render-context.js} +64 -111
  198. package/lib/framework/render-context.js.map +1 -0
  199. package/lib/framework/render-define.d.ts +109 -0
  200. package/{src/med_editor/framework/render-define.ts → lib/framework/render-define.js} +61 -90
  201. package/lib/framework/render-define.js.map +1 -0
  202. package/lib/framework/selection-overlays.d.ts +30 -0
  203. package/{src/med_editor/framework/selection-overlays.ts → lib/framework/selection-overlays.js} +16 -26
  204. package/lib/framework/selection-overlays.js.map +1 -0
  205. package/lib/texteditor.d.ts +318 -0
  206. package/{src/med_editor/texteditor.ts → lib/texteditor.js} +189 -287
  207. package/lib/texteditor.js.map +1 -0
  208. package/lib/util/subject.d.ts +34 -0
  209. package/lib/util/subject.js +88 -0
  210. package/lib/util/subject.js.map +1 -0
  211. package/lib/util/table-bind.d.ts +5 -0
  212. package/{src/med_editor/util/table-bind.ts → lib/util/table-bind.js} +2 -2
  213. package/lib/util/table-bind.js.map +1 -0
  214. package/package.json +6 -2
  215. package/src/med_editor/framework/common-util.ts +0 -200
  216. package/src/med_editor/framework/document-segmenter.ts +0 -211
  217. package/src/med_editor/framework/document-textline-mode.ts +0 -34
  218. package/src/med_editor/framework/element-event-define.ts +0 -142
  219. package/src/med_editor/framework/impl/document/doc-container-impl.ts +0 -24
  220. package/src/med_editor/util/subject.ts +0 -118
  221. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +0 -3573
  222. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +0 -3573
  223. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +0 -315
  224. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/211/271/346/263/250.json +0 -122
  225. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/226/207/346/241/243/351/252/214/350/257/201.json +0 -3599
  226. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/351/225/277/346/226/207/346/234/254.json +0 -24586
  227. package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +0 -2874
  228. package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +0 -341
  229. package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +0 -2201
  230. package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +0 -1069
  231. package/src/med_editor//347/227/205/347/250/213/345/275/225//345/206/205/351/225/234/344/270/213/346/262/273/347/226/227/350/256/260/345/275/225.json +0 -125
  232. package/src/med_editor//347/227/205/347/250/213/345/275/225//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225/346/250/241/346/235/277.json +0 -86
  233. package/src/med_editor//347/227/205/347/250/213/345/275/225//346/227/245/345/270/270/347/227/205/347/250/213/350/256/260/345/275/225.json +0 -115
  234. package/src/med_editor//347/227/205/347/250/213/345/275/225//346/237/245/346/210/277/350/256/260/345/275/2251.json +0 -108
  235. package/src/med_editor//347/227/205/347/250/213/345/275/225//351/246/226/346/254/241/344/270/212/347/272/247/345/214/273/345/270/210/346/237/245/346/210/277/350/256/260/345/275/225.json +0 -272
  236. package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +0 -1070
  237. package/tsconfig.json +0 -25
  238. package/webpack.config.js +0 -46
@@ -1,15 +1,10 @@
1
- import { SelectionState } from "@/med_editor/framework/document-selection";
2
1
  import { ElementUtil } from "@/med_editor/framework/element-util";
3
- import { Element } from "../../element-define";
4
2
  import { ParagraphElement } from "../paragraph/p-impl";
5
3
  import { TableCellElement } from "./table-cell-impl";
6
4
  import { TableElement } from "./table-impl";
7
5
  import { TableRowElement } from "./table-row-impl";
8
-
9
-
10
6
  export class TableUtil {
11
-
12
- static canDeleteTable(ss: SelectionState): boolean {
7
+ static canDeleteTable(ss) {
13
8
  const { startControl } = ss;
14
9
  if (!startControl) {
15
10
  return false;
@@ -19,27 +14,27 @@ export class TableUtil {
19
14
  }
20
15
  /**
21
16
  * 校验当前选区是否可以执行合并单元格操作
22
- * @param ss
23
- * @returns
17
+ * @param ss
18
+ * @returns
24
19
  */
25
- static canMergeCells(ss: SelectionState): boolean {
20
+ static canMergeCells(ss) {
26
21
  const { ancestorCommonControl, startControl, endControl, collapsed, selectedRange } = ss;
27
22
  if (collapsed) {
28
23
  return false;
29
24
  }
30
25
  if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
31
- const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent as TableElement;
26
+ const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
32
27
  const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
33
28
  const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
34
29
  if (startCell?.parent?.parent === tbElement && endCell?.parent?.parent === tbElement) {
35
30
  const tbRegion = this.getTableRectSelectedRegion(tbElement, startCell, endCell);
36
31
  if (selectedRange && selectedRange.target === tbElement) {
37
- const selectedCells: Array<TableCellElement> = [];
38
- selectedRange.selectedChildren.every(item => item.selectedChildren.every(cell => selectedCells.push(cell.target as TableCellElement)));
32
+ const selectedCells = [];
33
+ selectedRange.selectedChildren.every(item => item.selectedChildren.every(cell => selectedCells.push(cell.target)));
39
34
  for (let i = tbRegion.startRow; i <= tbRegion.endRow; i++) {
40
- const currRow = tbElement.getChild<TableRowElement>(i);
35
+ const currRow = tbElement.getChild(i);
41
36
  for (let j = tbRegion.startCol; j <= tbRegion.endCol; j++) {
42
- const currCell = currRow.getChild<TableCellElement>(j);
37
+ const currCell = currRow.getChild(j);
43
38
  if (currCell.isNotBeMergedCell() && selectedCells.indexOf(currCell) < 0) {
44
39
  return false;
45
40
  }
@@ -51,93 +46,90 @@ export class TableUtil {
51
46
  }
52
47
  return false;
53
48
  }
54
-
55
49
  /**
56
50
  * 获取横向合并当前单元格合并结束索引位置
57
- * @param tb
58
- * @param rowIndex
59
- * @param colIndex
51
+ * @param tb
52
+ * @param rowIndex
53
+ * @param colIndex
60
54
  */
61
- static getHMergeEndIndex(tb: TableElement, rowIndex: number, colIndex: number): number {
62
- const currRow = tb.getChild(rowIndex) as TableRowElement;
55
+ static getHMergeEndIndex(tb, rowIndex, colIndex) {
56
+ const currRow = tb.getChild(rowIndex);
63
57
  let index = colIndex;
64
58
  for (let i = colIndex + 1; i < tb.getColsCount(); i++) {
65
- const cell = currRow.getChild(i) as TableCellElement;
59
+ const cell = currRow.getChild(i);
66
60
  if (cell.props.hMerge === 'continue') {
67
61
  index = i;
68
- } else {
62
+ }
63
+ else {
69
64
  break;
70
65
  }
71
66
  }
72
67
  return index;
73
68
  }
74
-
75
69
  /**
76
70
  * 获取横向合并当前单元格合并开始索引位置
77
- * @param tb
78
- * @param rowIndex
79
- * @param colIndex
71
+ * @param tb
72
+ * @param rowIndex
73
+ * @param colIndex
80
74
  */
81
- static getHMergeStartIndex(tb: TableElement, rowIndex: number, colIndex: number): number {
82
- const row = tb.getChild(rowIndex) as TableRowElement;
75
+ static getHMergeStartIndex(tb, rowIndex, colIndex) {
76
+ const row = tb.getChild(rowIndex);
83
77
  for (let i = colIndex - 1; i >= 0; i--) {
84
- const cell = row.getChild(i) as TableCellElement;
78
+ const cell = row.getChild(i);
85
79
  if (cell.props.hMerge === 'restart') {
86
80
  return i;
87
81
  }
88
82
  }
89
83
  throw new Error('未找到主合并单元格');
90
84
  }
91
-
92
85
  /**
93
86
  * 获取纵向合并当前单元格合并结束索引位置
94
- * @param tb
95
- * @param rowIndex
87
+ * @param tb
88
+ * @param rowIndex
96
89
  * @param colIndex i
97
90
  */
98
- static getVMergeEndIndex(tb: TableElement, rowIndex: number, colIndex: number): number {
91
+ static getVMergeEndIndex(tb, rowIndex, colIndex) {
99
92
  let index = rowIndex;
100
93
  for (let i = rowIndex + 1; i < tb.length; i++) {
101
- const currRow = tb.getChild(i) as TableRowElement;
102
- const cell = currRow.getChild(colIndex) as TableCellElement;
94
+ const currRow = tb.getChild(i);
95
+ const cell = currRow.getChild(colIndex);
103
96
  if (cell.props.vMerge === 'continue') {
104
97
  index = i;
105
- } else {
98
+ }
99
+ else {
106
100
  break;
107
101
  }
108
102
  }
109
103
  return index;
110
104
  }
111
-
112
105
  /**
113
106
  * 获取纵向合并当前单元格合并开始索引位置
114
- * @param tb
115
- * @param rowIndex
107
+ * @param tb
108
+ * @param rowIndex
116
109
  * @param colIndex i
117
110
  */
118
- static getVMergeStartIndex(tb: TableElement, rowIndex: number, colIndex: number): number {
111
+ static getVMergeStartIndex(tb, rowIndex, colIndex) {
119
112
  for (let i = rowIndex - 1; i >= 0; i--) {
120
- const currRow = tb.getChild(i) as TableRowElement;
121
- const cell = currRow.getChild(colIndex) as TableCellElement;
113
+ const currRow = tb.getChild(i);
114
+ const cell = currRow.getChild(colIndex);
122
115
  if (cell.props.vMerge === 'restart') {
123
116
  return i;
124
117
  }
125
118
  }
126
119
  throw new Error('未找到主合并单元格');
127
120
  }
128
-
129
121
  /**
130
122
  * 合并单元格
131
- * @param ss
132
- * @returns
123
+ * @param ss
124
+ * @returns
133
125
  */
134
- static mergeCells(ss: SelectionState): void {
126
+ static mergeCells(ss) {
135
127
  const { ancestorCommonControl, startControl, endControl, collapsed } = ss;
136
128
  if (collapsed) {
137
129
  return;
138
130
  }
139
131
  if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
140
- const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent as TableElement;
132
+ const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
141
133
  const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
142
134
  const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
143
135
  if (startCell?.parent?.parent === tbElement && endCell?.parent?.parent === tbElement) {
@@ -148,50 +140,51 @@ export class TableUtil {
148
140
  ss.clear();
149
141
  }
150
142
  }
151
-
152
143
  /**
153
144
  * 在合并单元格后需要校验
154
145
  * 1.如果某个行的所有单元格都不是normal,则需要删除当前行
155
146
  * 2.如果某个列的所有的单元格都不是normal,则需要删除当前列
156
147
  */
157
- private static checkRowBeMerged(ss: SelectionState): void {
148
+ static checkRowBeMerged(ss) {
158
149
  const tb = ElementUtil.getParentByType(ss.startControl, TableElement);
159
- if (!tb) { return }
150
+ if (!tb) {
151
+ return;
152
+ }
160
153
  const colsCount = tb.getColsCount();
161
- const fullMergeRows: Array<TableRowElement> = [];
154
+ const fullMergeRows = [];
162
155
  for (let i = 0; i < tb.length; i++) {
163
- const row = tb.getChild(i) as TableRowElement;
156
+ const row = tb.getChild(i);
164
157
  let count = 0;
165
158
  for (let j = 0; j < colsCount; j++) {
166
- const cell = row.getChild(j) as TableCellElement;
159
+ const cell = row.getChild(j);
167
160
  if (!cell.isNotBeMergedCell()) {
168
161
  count++;
169
162
  }
170
163
  }
171
164
  //当前行所有的单元格都被合并,需要删除
172
165
  if (count === colsCount) {
173
- fullMergeRows.push(row)
166
+ fullMergeRows.push(row);
174
167
  }
175
168
  }
176
169
  fullMergeRows.forEach(row => this.removeRow(row));
177
170
  }
178
-
179
171
  /**
180
172
  * 移除行
181
- * @param row
173
+ * @param row
182
174
  */
183
- private static removeRow(row: TableRowElement): void {
175
+ static removeRow(row) {
184
176
  const rowIndex = row.getIndex();
185
- const tb = row.parent as TableElement;
177
+ const tb = row.parent;
186
178
  for (let i = 0; i < row.length; i++) {
187
- const cell = row.getChild<TableCellElement>(i);
179
+ const cell = row.getChild(i);
188
180
  if (cell.props.vMerge === 'restart') {
189
181
  const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
190
182
  if (vMergeEndIndex > rowIndex) {
191
- const nextRow = tb.getChild<TableRowElement>(rowIndex + 1);
192
- nextRow.getChild<TableCellElement>(i).props.vMerge = vMergeEndIndex - rowIndex > 2 ? 'restart' : null;
183
+ const nextRow = tb.getChild(rowIndex + 1);
184
+ nextRow.getChild(i).props.vMerge = vMergeEndIndex - rowIndex > 2 ? 'restart' : null;
193
185
  }
194
- } else if (cell.props.vMerge === 'continue') {
186
+ }
187
+ else if (cell.props.vMerge === 'continue') {
195
188
  // const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
196
189
  // if (vMergeEndIndex > rowIndex) {
197
190
  // const nextRow = tb.getChild<TableRowElement>(rowIndex + 1);
@@ -201,79 +194,76 @@ export class TableUtil {
201
194
  const vMergeEndIndex = this.getVMergeEndIndex(tb, rowIndex, i);
202
195
  //当前单元格处于合并行的最后一行,并且合并的行数为2行
203
196
  if (vMergeEndIndex === rowIndex && vMergeEndIndex - vMergeStartIndex === 1) {
204
- const aboveCell = tb.getChild<TableRowElement>(vMergeStartIndex).getChild<TableCellElement>(i)
197
+ const aboveCell = tb.getChild(vMergeStartIndex).getChild(i);
205
198
  aboveCell.props.vMerge = null;
206
199
  }
207
200
  }
208
201
  }
209
202
  tb.removeChild(row);
210
203
  }
211
-
212
204
  /**
213
205
  * 移除列
214
- * @param tb
215
- * @param colIndex
206
+ * @param tb
207
+ * @param colIndex
216
208
  */
217
- private static removeCol(tb: TableElement, colIndex: number): void {
209
+ static removeCol(tb, colIndex) {
218
210
  for (let i = 0; i < tb.length; i++) {
219
- const row = tb.getChild<TableRowElement>(i);
220
- const cell = row.getChild<TableCellElement>(colIndex);
211
+ const row = tb.getChild(i);
212
+ const cell = row.getChild(colIndex);
221
213
  if (cell.props.hMerge === 'restart') {
222
214
  const hMergeEndIndex = this.getHMergeEndIndex(tb, i, colIndex);
223
215
  if (hMergeEndIndex > colIndex) {
224
- const nextCell = row.getChild<TableCellElement>(colIndex + 1);
216
+ const nextCell = row.getChild(colIndex + 1);
225
217
  nextCell.props.hMerge = hMergeEndIndex - colIndex > 2 ? 'restart' : null;
226
218
  }
227
- } else if (cell.props.hMerge === 'continue') {
219
+ }
220
+ else if (cell.props.hMerge === 'continue') {
228
221
  const hMergeStartIndex = this.getHMergeStartIndex(tb, i, colIndex);
229
222
  const hMergeEndIndex = this.getHMergeEndIndex(tb, i, colIndex);
230
223
  //当前单元格处于合并行的最后一行,并且合并的行数为2行
231
224
  if (hMergeEndIndex === colIndex && hMergeEndIndex - hMergeStartIndex === 1) {
232
- const masterVMergeCell = tb.getChild<TableRowElement>(hMergeStartIndex).getChild<TableCellElement>(i)
225
+ const masterVMergeCell = tb.getChild(hMergeStartIndex).getChild(i);
233
226
  masterVMergeCell.props.hMerge = null;
234
227
  }
235
-
236
228
  }
237
229
  row.removeChild(cell);
238
230
  }
239
231
  tb.removeCol(colIndex);
240
232
  }
241
-
242
233
  /**
243
234
  * 移除光标所在的当前行
244
- * @param ss
235
+ * @param ss
245
236
  */
246
- static removeCurrRow(ss: SelectionState): void {
237
+ static removeCurrRow(ss) {
247
238
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
248
239
  if (!startCell?.parent) {
249
- throw new Error('parent is null')
240
+ throw new Error('parent is null');
250
241
  }
251
- const currRow = startCell.parent as TableRowElement;
252
- const tb = currRow.parent as TableElement;
242
+ const currRow = startCell.parent;
243
+ const tb = currRow.parent;
253
244
  this.removeRow(currRow);
254
245
  tb.pubOnChange('self');
255
246
  tb.refreshView();
256
247
  }
257
-
258
248
  /**
259
249
  * 移除光标所在的当前列
260
- * @param ss
250
+ * @param ss
261
251
  */
262
- static removeCurrCol(ss: SelectionState): void {
252
+ static removeCurrCol(ss) {
263
253
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
264
254
  if (!startCell?.parent) {
265
- throw new Error('parent is null')
255
+ throw new Error('parent is null');
266
256
  }
267
257
  if (ss.collapsed) {
268
- const currRow = startCell.parent as TableRowElement;
269
- const tb = currRow.parent as TableElement;
258
+ const currRow = startCell.parent;
259
+ const tb = currRow.parent;
270
260
  this.removeCol(tb, startCell.getIndex());
271
261
  ss.clear();
272
262
  return;
273
263
  }
274
264
  const { ancestorCommonControl, startControl, endControl } = ss;
275
265
  if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
276
- const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent as TableElement;
266
+ const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
277
267
  const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
278
268
  const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
279
269
  if (startCell?.parent?.parent === tbElement && endCell?.parent?.parent === tbElement) {
@@ -288,17 +278,16 @@ export class TableUtil {
288
278
  }
289
279
  ss.clear();
290
280
  }
291
-
292
281
  /**
293
282
  * 合并单元格
294
283
  */
295
- static combineCells(tbElement: TableElement, startCell: TableCellElement, endCell: TableCellElement): void {
284
+ static combineCells(tbElement, startCell, endCell) {
296
285
  const tbRegion = this.getTableRectSelectedRegion(tbElement, startCell, endCell);
297
- const cellContents: Array<Element> = [];
286
+ const cellContents = [];
298
287
  for (let i = tbRegion.startRow; i <= tbRegion.endRow; i++) {
299
- const currRow = tbElement.getChild<TableRowElement>(i);
288
+ const currRow = tbElement.getChild(i);
300
289
  for (let j = tbRegion.startCol; j <= tbRegion.endCol; j++) {
301
- const currCell = currRow.getChild<TableCellElement>(j);
290
+ const currCell = currRow.getChild(j);
302
291
  currCell.props.vMerge = null;
303
292
  currCell.props.hMerge = 'continue';
304
293
  if (j === tbRegion.startCol) {
@@ -318,9 +307,7 @@ export class TableUtil {
318
307
  }
319
308
  }
320
309
  }
321
-
322
-
323
- static canSplitCell(ss: SelectionState): boolean {
310
+ static canSplitCell(ss) {
324
311
  const { ancestorCommonControl, startControl, endControl, collapsed } = ss;
325
312
  if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
326
313
  const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent;
@@ -331,7 +318,8 @@ export class TableUtil {
331
318
  return startCell.props.hMerge === 'restart' || startCell.props.vMerge === 'restart';
332
319
  }
333
320
  }
334
- } else {
321
+ }
322
+ else {
335
323
  const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
336
324
  if (!startCell) {
337
325
  throw new Error('startCell is null');
@@ -339,15 +327,13 @@ export class TableUtil {
339
327
  const { hMerge, vMerge } = startCell?.props;
340
328
  return hMerge === 'restart' || vMerge === 'restart' || !hMerge || !vMerge;
341
329
  }
342
-
343
330
  return false;
344
331
  }
345
-
346
332
  /**
347
333
  * 将合并的单元格合并还原
348
- * @param ss
334
+ * @param ss
349
335
  */
350
- static restoreCell(ss: SelectionState): void {
336
+ static restoreCell(ss) {
351
337
  const { ancestorCommonControl, startControl, endControl, collapsed } = ss;
352
338
  const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
353
339
  if (startCell) {
@@ -356,17 +342,16 @@ export class TableUtil {
356
342
  startCell.refreshView();
357
343
  }
358
344
  }
359
-
360
- private static restoreCellMerge(cell: TableCellElement): void {
345
+ static restoreCellMerge(cell) {
361
346
  const { vMerge, hMerge } = cell.props;
362
- const row = cell.parent as TableRowElement;
363
- const tb = row.parent as TableElement;
347
+ const row = cell.parent;
348
+ const tb = row.parent;
364
349
  const rowIndex = row.getIndex();
365
350
  const colIndex = cell.getIndex();
366
351
  if (vMerge === 'restart') {
367
352
  for (let i = rowIndex + 1; i < tb.length; i++) {
368
- const row = tb.getChild(i) as TableRowElement;
369
- const cell = row.getChild(colIndex) as TableCellElement;
353
+ const row = tb.getChild(i);
354
+ const cell = row.getChild(colIndex);
370
355
  if (cell.props.vMerge === "continue") {
371
356
  cell.props.vMerge = null;
372
357
  if (cell.props.hMerge === "restart") {
@@ -377,7 +362,7 @@ export class TableUtil {
377
362
  }
378
363
  if (hMerge === 'restart') {
379
364
  for (let i = colIndex + 1; i < row.length; i++) {
380
- const cell = row.getChild(i) as TableCellElement;
365
+ const cell = row.getChild(i);
381
366
  if (cell.props.hMerge === "continue") {
382
367
  cell.props.hMerge = null;
383
368
  if (cell.props.vMerge === "restart") {
@@ -389,30 +374,27 @@ export class TableUtil {
389
374
  cell.props.hMerge = null;
390
375
  cell.props.vMerge = null;
391
376
  }
392
-
393
-
394
- private static getVMergeRows(tb: TableElement, masterRowIndex: number, masterColIndex: number): Array<TableRowElement> {
395
- const items: Array<TableRowElement> = [];
377
+ static getVMergeRows(tb, masterRowIndex, masterColIndex) {
378
+ const items = [];
396
379
  for (let i = masterRowIndex + 1; i < tb.length; i++) {
397
- const row = <TableRowElement>tb.getChild(i);
398
- const cell = row.getChild(masterColIndex) as TableCellElement;
380
+ const row = tb.getChild(i);
381
+ const cell = row.getChild(masterColIndex);
399
382
  if (cell.props.vMerge === 'continue') {
400
383
  items.push(row);
401
- } else {
384
+ }
385
+ else {
402
386
  return items;
403
387
  }
404
388
  }
405
389
  return items;
406
390
  }
407
-
408
-
409
- static insertCol(ss: SelectionState, insertColIndex: number): void {
391
+ static insertCol(ss, insertColIndex) {
410
392
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
411
393
  if (!startCell?.parent) {
412
- throw new Error('parent is null')
394
+ throw new Error('parent is null');
413
395
  }
414
- const startRow = startCell.parent as TableRowElement;
415
- const tb = startRow.parent as TableElement;
396
+ const startRow = startCell.parent;
397
+ const tb = startRow.parent;
416
398
  const currColIndex = startCell.getIndex();
417
399
  const colsCount = tb.getColsCount();
418
400
  insertColIndex = insertColIndex < 0 ? 0 : insertColIndex;
@@ -421,17 +403,17 @@ export class TableUtil {
421
403
  const insertColWidth = insertColIndex === colsCount ? tb.getCellWidth(colsCount - 1) : tb.getCellWidth(insertColIndex);
422
404
  const newColWidth = Math.floor(insertColWidth / 2);
423
405
  if (newColWidth < 20) {
424
- console.warn('插入列的最小宽度不能小于20,当前为:' + newColWidth)
406
+ console.warn('插入列的最小宽度不能小于20,当前为:' + newColWidth);
425
407
  return;
426
408
  }
427
409
  for (let i = 0; i < tb.length; i++) {
428
- const row = tb.getChild<TableRowElement>(i)
410
+ const row = tb.getChild(i);
429
411
  const newCell = new TableCellElement();
430
412
  if (insertColIndex === 0 || insertColIndex === colsCount) {
431
413
  row.addChild(newCell, insertColIndex);
432
414
  continue;
433
415
  }
434
- const focusCell = row.getChild<TableCellElement>(insertColIndex);
416
+ const focusCell = row.getChild(insertColIndex);
435
417
  if (focusCell) {
436
418
  if (focusCell.props.hMerge === 'continue') {
437
419
  //获取合并行的最后的行索引
@@ -439,26 +421,25 @@ export class TableUtil {
439
421
  if (hMergeEndColIndex > insertColIndex || (hMergeEndColIndex === insertColIndex && currColIndex < insertColIndex)) {
440
422
  newCell.props.hMerge = 'continue';
441
423
  }
442
- } else if (focusCell.props.hMerge === 'restart' && currColIndex > insertColIndex) {
424
+ }
425
+ else if (focusCell.props.hMerge === 'restart' && currColIndex > insertColIndex) {
443
426
  newCell.props.hMerge = 'continue';
444
427
  }
445
428
  }
446
429
  row.addChild(newCell, insertColIndex);
447
430
  }
448
-
449
431
  tb.setCellWidth(insertColIndex === colsCount ? insertColIndex - 1 : insertColIndex, insertColWidth - newColWidth);
450
432
  tb.insertCol(insertColIndex, newColWidth);
451
433
  tb.pubOnChange('self');
452
434
  tb.refreshView();
453
435
  }
454
-
455
- static insertRow(ss: SelectionState, insertRowIndex: number): TableRowElement {
436
+ static insertRow(ss, insertRowIndex) {
456
437
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
457
438
  if (!startCell?.parent) {
458
- throw new Error('parent is null')
439
+ throw new Error('parent is null');
459
440
  }
460
- const startRow = startCell.parent as TableRowElement;
461
- const tb = startRow.parent as TableElement;
441
+ const startRow = startCell.parent;
442
+ const tb = startRow.parent;
462
443
  const currRowIndex = startRow.getIndex();
463
444
  insertRowIndex = insertRowIndex < 0 ? 0 : insertRowIndex;
464
445
  insertRowIndex = insertRowIndex > tb.length ? tb.length : insertRowIndex;
@@ -469,10 +450,10 @@ export class TableUtil {
469
450
  tb.refreshView();
470
451
  return newRow;
471
452
  }
472
- const destRow = tb.getChild(insertRowIndex) as TableRowElement;
453
+ const destRow = tb.getChild(insertRowIndex);
473
454
  for (let i = 0; i < destRow.length; i++) {
474
- const destCell = destRow.getChild(i) as TableCellElement;
475
- const newCell = newRow.getChild(i) as TableCellElement;
455
+ const destCell = destRow.getChild(i);
456
+ const newCell = newRow.getChild(i);
476
457
  //如果当前单元格是普通单元格或者合并列的最后一个单元格,则不做处理
477
458
  if (destCell.props.vMerge === 'continue') {
478
459
  //获取合并列的最后的行索引
@@ -481,76 +462,71 @@ export class TableUtil {
481
462
  newCell.props.vMerge = 'continue';
482
463
  //newCell.cellProps.hMerge = destCell.cellProps.hMerge;
483
464
  }
484
- } else if (destCell.props.vMerge === 'restart' && currRowIndex > insertRowIndex) {
465
+ }
466
+ else if (destCell.props.vMerge === 'restart' && currRowIndex > insertRowIndex) {
485
467
  //在上方新增行,目标行单元格属于合并的起点
486
468
  newCell.props.vMerge = 'continue';
487
469
  //newCell.cellProps.hMerge = destCell.cellProps.hMerge;
488
470
  }
489
-
490
471
  }
491
472
  tb.addChild(newRow, insertRowIndex);
492
473
  tb.refreshView();
493
474
  return newRow;
494
475
  }
495
-
496
476
  /**
497
477
  * 在下方插入行
498
478
  */
499
- static insertRowBelow(ss: SelectionState): void {
479
+ static insertRowBelow(ss) {
500
480
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
501
481
  if (!startCell?.parent) {
502
- throw new Error('parent is null')
482
+ throw new Error('parent is null');
503
483
  }
504
- const startRow = startCell.parent as TableRowElement;
484
+ const startRow = startCell.parent;
505
485
  const currRowIndex = startRow.getIndex();
506
486
  this.insertRow(ss, currRowIndex + 1);
507
487
  }
508
-
509
488
  /**
510
489
  * 在上方插入行
511
490
  */
512
- static insertRowAbove(ss: SelectionState): void {
491
+ static insertRowAbove(ss) {
513
492
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
514
493
  if (!startCell?.parent) {
515
- throw new Error('parent is null')
494
+ throw new Error('parent is null');
516
495
  }
517
- const startRow = startCell.parent as TableRowElement;
496
+ const startRow = startCell.parent;
518
497
  const currRowIndex = startRow.getIndex();
519
498
  this.insertRow(ss, currRowIndex);
520
499
  }
521
-
522
500
  /**
523
501
  * 在右侧插入列
524
502
  */
525
- static insertColToRight(ss: SelectionState): void {
503
+ static insertColToRight(ss) {
526
504
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
527
505
  if (!startCell?.parent) {
528
- throw new Error('parent is null')
506
+ throw new Error('parent is null');
529
507
  }
530
508
  const currColIndex = startCell.getIndex();
531
509
  this.insertCol(ss, currColIndex + 1);
532
510
  }
533
-
534
511
  /**
535
512
  * 在左侧插入列
536
513
  */
537
- static insertColToLeft(ss: SelectionState): void {
514
+ static insertColToLeft(ss) {
538
515
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
539
516
  if (!startCell?.parent) {
540
- throw new Error('parent is null')
517
+ throw new Error('parent is null');
541
518
  }
542
519
  const currColIndex = startCell.getIndex();
543
520
  this.insertCol(ss, currColIndex);
544
521
  }
545
-
546
522
  /**
547
523
  * 跳转到下一个单元格中
548
- * @param ss
524
+ * @param ss
549
525
  */
550
- static moveNextCell(ss: SelectionState): void {
526
+ static moveNextCell(ss) {
551
527
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
552
528
  if (!startCell?.parent) {
553
- throw new Error('parent is null')
529
+ throw new Error('parent is null');
554
530
  }
555
531
  const rowIndex = startCell.parent.getIndex();
556
532
  const nextCell = this.getNextCell(ss);
@@ -564,26 +540,24 @@ export class TableUtil {
564
540
  ss.resetRange(newRow, 0);
565
541
  newRow.refreshView();
566
542
  }
567
-
568
-
569
543
  /**
570
544
  * 获取下一个可定位的单元格
571
- * @param ss
572
- * @returns
545
+ * @param ss
546
+ * @returns
573
547
  */
574
- static getNextCell(ss: SelectionState): TableCellElement | undefined {
548
+ static getNextCell(ss) {
575
549
  const startCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
576
550
  if (!startCell?.parent) {
577
- throw new Error('parent is null')
551
+ throw new Error('parent is null');
578
552
  }
579
553
  const rowIndex = startCell.parent.getIndex();
580
554
  const colIndex = startCell.getIndex();
581
- const tb = startCell.parent.parent as TableElement;
555
+ const tb = startCell.parent.parent;
582
556
  for (let i = rowIndex; i < tb.length; i++) {
583
557
  let j = i === rowIndex ? colIndex + 1 : 0;
584
- const currRow = tb.getChild(i) as TableRowElement;
558
+ const currRow = tb.getChild(i);
585
559
  for (; j < tb.getColsCount(); j++) {
586
- const currCell = currRow.getChild(j) as TableCellElement;
560
+ const currCell = currRow.getChild(j);
587
561
  if (currCell.isNotBeMergedCell()) {
588
562
  return currCell;
589
563
  }
@@ -591,19 +565,16 @@ export class TableUtil {
591
565
  }
592
566
  //throw new Error('getNextCell is null')
593
567
  }
594
-
595
568
  /**
596
569
  * 当前光标是否在最后一个单元格中
597
570
  */
598
- static isLastVisiableCell(ss: SelectionState): boolean {
571
+ static isLastVisiableCell(ss) {
599
572
  return !this.getNextCell(ss);
600
573
  }
601
-
602
-
603
574
  /**
604
575
  * 移除当前table
605
576
  */
606
- static removeTable(ss: SelectionState): void {
577
+ static removeTable(ss) {
607
578
  const tb = ElementUtil.getParentByType(ss.startControl, TableElement);
608
579
  if (!tb) {
609
580
  console.warn('当前位置不存在表格');
@@ -612,37 +583,36 @@ export class TableUtil {
612
583
  tb.parent.refreshView();
613
584
  tb.remove();
614
585
  }
615
-
616
586
  /**
617
587
  * 设置表格单元格对角线
618
- * @param ss
619
- * @param diagonal
620
- * @returns
588
+ * @param ss
589
+ * @param diagonal
590
+ * @returns
621
591
  */
622
- static setTableCellDiagonal(ss: SelectionState, diagonal: 'main' | 'sub'): void {
592
+ static setTableCellDiagonal(ss, diagonal) {
623
593
  const tc = ElementUtil.getParentByType(ss.startControl, TableCellElement);
624
594
  if (!tc) {
625
595
  console.warn('当前位置不存在表格');
626
- return
596
+ return;
627
597
  }
628
598
  if (!tc.props.diagonal || tc.props.diagonal !== diagonal) {
629
599
  tc.props.diagonal = diagonal;
630
- } else if (tc.props.diagonal === diagonal) {
600
+ }
601
+ else if (tc.props.diagonal === diagonal) {
631
602
  tc.props.diagonal = null;
632
603
  }
633
604
  tc.refreshView();
634
605
  }
635
-
636
606
  /**
637
607
  * 将当前表格截断成两个相邻的表格
638
- * @param tb
639
- * @param rowIndex
608
+ * @param tb
609
+ * @param rowIndex
640
610
  */
641
- static cutTable(tb: TableElement, rowIndex: number): void {
611
+ static cutTable(tb, rowIndex) {
642
612
  if (rowIndex === 0 || rowIndex === tb.length - 1) {
643
613
  return;
644
614
  }
645
- const newTb = tb.clone(false) as TableElement;
615
+ const newTb = tb.clone(false);
646
616
  const len = tb.length - 1;
647
617
  while (len > rowIndex) {
648
618
  const child = tb.getChild(len);
@@ -653,15 +623,14 @@ export class TableUtil {
653
623
  tb.parent.addChild(newTb, tb.getIndex() + 1);
654
624
  }
655
625
  }
656
-
657
626
  /**
658
627
  * 获取表格选区区域最大的矩形区域
659
- * @param tb
660
- * @param startCell
661
- * @param endCell
662
- * @returns
628
+ * @param tb
629
+ * @param startCell
630
+ * @param endCell
631
+ * @returns
663
632
  */
664
- static getTableRectSelectedRegion(tb: TableElement, startCell: TableCellElement, endCell: TableCellElement): ITableSelectedRegion {
633
+ static getTableRectSelectedRegion(tb, startCell, endCell) {
665
634
  let startRow = startCell.parent.getIndex();
666
635
  let startCol = startCell.getIndex();
667
636
  let endRow = endCell.parent.getIndex();
@@ -673,9 +642,9 @@ export class TableUtil {
673
642
  [endCol, startCol] = [startCol, endCol];
674
643
  }
675
644
  for (let i = startRow; i <= endRow; i++) {
676
- const row = tb.getChild(i) as TableRowElement;
645
+ const row = tb.getChild(i);
677
646
  for (let j = startCol; j <= endCol; j++) {
678
- const cell = row.getChild(j) as TableCellElement;
647
+ const cell = row.getChild(j);
679
648
  const { hMerge, vMerge } = cell.props;
680
649
  if (hMerge === 'continue') {
681
650
  const startColIndex = TableUtil.getHMergeStartIndex(tb, i, j);
@@ -703,14 +672,7 @@ export class TableUtil {
703
672
  }
704
673
  }
705
674
  }
706
- return { startRow, endRow, startCol, endCol }
675
+ return { startRow, endRow, startCol, endCol };
707
676
  }
708
677
  }
709
-
710
-
711
- export interface ITableSelectedRegion {
712
- startRow: number;
713
- endRow: number;
714
- startCol: number;
715
- endCol: number;
716
- }
678
+ //# sourceMappingURL=table-util.js.map