@hailin-zheng/editor-core 1.0.18 → 1.0.20

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 (291) hide show
  1. package/lib/doc-ruler.d.ts +1 -0
  2. package/lib/doc-ruler.d.ts.map +1 -0
  3. package/lib/framework/common-util.d.ts +1 -0
  4. package/lib/framework/common-util.d.ts.map +1 -0
  5. package/lib/framework/document-change.d.ts +1 -0
  6. package/lib/framework/document-change.d.ts.map +1 -0
  7. package/lib/framework/document-combine.d.ts +1 -0
  8. package/lib/framework/document-combine.d.ts.map +1 -0
  9. package/lib/framework/document-comment.d.ts +1 -0
  10. package/lib/framework/document-comment.d.ts.map +1 -0
  11. package/lib/framework/document-context.d.ts +1 -0
  12. package/lib/framework/document-context.d.ts.map +1 -0
  13. package/lib/framework/document-eval-func.d.ts +1 -0
  14. package/lib/framework/document-eval-func.d.ts.map +1 -0
  15. package/lib/framework/document-event.d.ts +1 -0
  16. package/lib/framework/document-event.d.ts.map +1 -0
  17. package/lib/framework/document-history.d.ts +1 -0
  18. package/lib/framework/document-history.d.ts.map +1 -0
  19. package/lib/framework/document-images-loader.d.ts +1 -0
  20. package/lib/framework/document-images-loader.d.ts.map +1 -0
  21. package/lib/framework/document-input-cursor.d.ts +1 -0
  22. package/lib/framework/document-input-cursor.d.ts.map +1 -0
  23. package/lib/framework/document-paint.d.ts +1 -0
  24. package/lib/framework/document-paint.d.ts.map +1 -0
  25. package/lib/framework/document-print-offscreen.d.ts +1 -0
  26. package/lib/framework/document-print-offscreen.d.ts.map +1 -0
  27. package/lib/framework/document-print.d.ts +1 -0
  28. package/lib/framework/document-print.d.ts.map +1 -0
  29. package/lib/framework/document-segmenter.d.ts +1 -0
  30. package/lib/framework/document-segmenter.d.ts.map +1 -0
  31. package/lib/framework/document-selection.d.ts +1 -0
  32. package/lib/framework/document-selection.d.ts.map +1 -0
  33. package/lib/framework/document-template.d.ts +1 -0
  34. package/lib/framework/document-template.d.ts.map +1 -0
  35. package/lib/framework/document-textline-mode.d.ts +1 -0
  36. package/lib/framework/document-textline-mode.d.ts.map +1 -0
  37. package/lib/framework/element-define.d.ts +1 -0
  38. package/lib/framework/element-define.d.ts.map +1 -0
  39. package/lib/framework/element-event-define.d.ts +1 -0
  40. package/lib/framework/element-event-define.d.ts.map +1 -0
  41. package/lib/framework/element-measure.d.ts +1 -0
  42. package/lib/framework/element-measure.d.ts.map +1 -0
  43. package/lib/framework/element-paint.d.ts +1 -0
  44. package/lib/framework/element-paint.d.ts.map +1 -0
  45. package/lib/framework/element-props.d.ts +2 -1
  46. package/lib/framework/element-props.d.ts.map +1 -0
  47. package/lib/framework/element-reader.d.ts +1 -0
  48. package/lib/framework/element-reader.d.ts.map +1 -0
  49. package/lib/framework/element-render-cut.d.ts +1 -0
  50. package/lib/framework/element-render-cut.d.ts.map +1 -0
  51. package/lib/framework/element-serialize.d.ts +1 -0
  52. package/lib/framework/element-serialize.d.ts.map +1 -0
  53. package/lib/framework/element-util.d.ts +1 -0
  54. package/lib/framework/element-util.d.ts.map +1 -0
  55. package/lib/framework/impl/checkbox/checkbox-impl.d.ts +1 -0
  56. package/lib/framework/impl/checkbox/checkbox-impl.d.ts.map +1 -0
  57. package/lib/framework/impl/comments/comment-content-impl.d.ts +1 -0
  58. package/lib/framework/impl/comments/comment-content-impl.d.ts.map +1 -0
  59. package/lib/framework/impl/comments/comment-element-impl.d.ts +1 -0
  60. package/lib/framework/impl/comments/comment-element-impl.d.ts.map +1 -0
  61. package/lib/framework/impl/comments/comments-container-impl.d.ts +1 -0
  62. package/lib/framework/impl/comments/comments-container-impl.d.ts.map +1 -0
  63. package/lib/framework/impl/comments/comments-util.d.ts +1 -0
  64. package/lib/framework/impl/comments/comments-util.d.ts.map +1 -0
  65. package/lib/framework/impl/comments/validate-msg-impl.d.ts +1 -0
  66. package/lib/framework/impl/comments/validate-msg-impl.d.ts.map +1 -0
  67. package/lib/framework/impl/data-element/data-decorate-impl.d.ts +1 -0
  68. package/lib/framework/impl/data-element/data-decorate-impl.d.ts.map +1 -0
  69. package/lib/framework/impl/data-element/data-element-barcode.d.ts +1 -0
  70. package/lib/framework/impl/data-element/data-element-barcode.d.ts.map +1 -0
  71. package/lib/framework/impl/data-element/data-element-base-impl.d.ts +1 -0
  72. package/lib/framework/impl/data-element/data-element-base-impl.d.ts.map +1 -0
  73. package/lib/framework/impl/data-element/data-element-check-impl.d.ts +1 -0
  74. package/lib/framework/impl/data-element/data-element-check-impl.d.ts.map +1 -0
  75. package/lib/framework/impl/data-element/data-element-date-impl.d.ts +1 -0
  76. package/lib/framework/impl/data-element/data-element-date-impl.d.ts.map +1 -0
  77. package/lib/framework/impl/data-element/data-element-group-impl.d.ts +1 -0
  78. package/lib/framework/impl/data-element/data-element-group-impl.d.ts.map +1 -0
  79. package/lib/framework/impl/data-element/data-element-image-impl.d.ts +1 -0
  80. package/lib/framework/impl/data-element/data-element-image-impl.d.ts.map +1 -0
  81. package/lib/framework/impl/data-element/data-element-list-impl.d.ts +1 -0
  82. package/lib/framework/impl/data-element/data-element-list-impl.d.ts.map +1 -0
  83. package/lib/framework/impl/data-element/data-element-text-impl.d.ts +1 -0
  84. package/lib/framework/impl/data-element/data-element-text-impl.d.ts.map +1 -0
  85. package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +1 -0
  86. package/lib/framework/impl/decorate/fill-null-space-imple.d.ts.map +1 -0
  87. package/lib/framework/impl/document/doc-body-impl.d.ts +1 -0
  88. package/lib/framework/impl/document/doc-body-impl.d.ts.map +1 -0
  89. package/lib/framework/impl/document/doc-body-part-impl.d.ts +1 -0
  90. package/lib/framework/impl/document/doc-body-part-impl.d.ts.map +1 -0
  91. package/lib/framework/impl/document/doc-container-impl.d.ts +1 -0
  92. package/lib/framework/impl/document/doc-container-impl.d.ts.map +1 -0
  93. package/lib/framework/impl/document/doc-footer-impl.d.ts +1 -0
  94. package/lib/framework/impl/document/doc-footer-impl.d.ts.map +1 -0
  95. package/lib/framework/impl/document/doc-header-impl.d.ts +1 -0
  96. package/lib/framework/impl/document/doc-header-impl.d.ts.map +1 -0
  97. package/lib/framework/impl/document/doc-impl.d.ts +1 -0
  98. package/lib/framework/impl/document/doc-impl.d.ts.map +1 -0
  99. package/lib/framework/impl/index.d.ts +37 -0
  100. package/lib/framework/impl/index.d.ts.map +1 -0
  101. package/lib/framework/impl/media-formula/menstrual-history.d.ts +1 -0
  102. package/lib/framework/impl/media-formula/menstrual-history.d.ts.map +1 -0
  103. package/lib/framework/impl/paragraph/p-impl.d.ts +1 -0
  104. package/lib/framework/impl/paragraph/p-impl.d.ts.map +1 -0
  105. package/lib/framework/impl/picture/image-impl.d.ts +1 -0
  106. package/lib/framework/impl/picture/image-impl.d.ts.map +1 -0
  107. package/lib/framework/impl/radio/radio-impl.d.ts +1 -0
  108. package/lib/framework/impl/radio/radio-impl.d.ts.map +1 -0
  109. package/lib/framework/impl/symbol/br-symbol-impl.d.ts +1 -0
  110. package/lib/framework/impl/symbol/br-symbol-impl.d.ts.map +1 -0
  111. package/lib/framework/impl/symbol/p-symbol-impl.d.ts +1 -0
  112. package/lib/framework/impl/symbol/p-symbol-impl.d.ts.map +1 -0
  113. package/lib/framework/impl/table/table-cell-impl.d.ts +1 -0
  114. package/lib/framework/impl/table/table-cell-impl.d.ts.map +1 -0
  115. package/lib/framework/impl/table/table-impl.d.ts +1 -0
  116. package/lib/framework/impl/table/table-impl.d.ts.map +1 -0
  117. package/lib/framework/impl/table/table-row-impl.d.ts +1 -0
  118. package/lib/framework/impl/table/table-row-impl.d.ts.map +1 -0
  119. package/lib/framework/impl/table/table-split-cell-patch.d.ts +1 -0
  120. package/lib/framework/impl/table/table-split-cell-patch.d.ts.map +1 -0
  121. package/lib/framework/impl/table/table-split-cell.d.ts +1 -0
  122. package/lib/framework/impl/table/table-split-cell.d.ts.map +1 -0
  123. package/lib/framework/impl/table/table-util.d.ts +1 -0
  124. package/lib/framework/impl/table/table-util.d.ts.map +1 -0
  125. package/lib/framework/impl/text/text-impl.d.ts +1 -0
  126. package/lib/framework/impl/text/text-impl.d.ts.map +1 -0
  127. package/lib/framework/impl/text/track-run-impl.d.ts +1 -0
  128. package/lib/framework/impl/text/track-run-impl.d.ts.map +1 -0
  129. package/lib/framework/notify.d.ts +1 -0
  130. package/lib/framework/notify.d.ts.map +1 -0
  131. package/lib/framework/range-util.d.ts +1 -0
  132. package/lib/framework/range-util.d.ts.map +1 -0
  133. package/lib/framework/render-context.d.ts +1 -0
  134. package/lib/framework/render-context.d.ts.map +1 -0
  135. package/lib/framework/render-define.d.ts +1 -0
  136. package/lib/framework/render-define.d.ts.map +1 -0
  137. package/lib/framework/selection-overlays.d.ts +1 -0
  138. package/lib/framework/selection-overlays.d.ts.map +1 -0
  139. package/lib/index.d.ts +35 -0
  140. package/lib/index.d.ts.map +1 -0
  141. package/lib/index.js +15671 -0
  142. package/lib/texteditor.d.ts +3 -2
  143. package/lib/texteditor.d.ts.map +1 -0
  144. package/lib/util/subject.d.ts +1 -0
  145. package/lib/util/subject.d.ts.map +1 -0
  146. package/lib/util/table-bind.d.ts +1 -0
  147. package/lib/util/table-bind.d.ts.map +1 -0
  148. package/package.json +32 -23
  149. package/README.md +0 -1613
  150. package/lib/doc-ruler.js +0 -313
  151. package/lib/doc-ruler.js.map +0 -1
  152. package/lib/framework/common-util.js +0 -178
  153. package/lib/framework/common-util.js.map +0 -1
  154. package/lib/framework/document-change.js +0 -1342
  155. package/lib/framework/document-change.js.map +0 -1
  156. package/lib/framework/document-combine.js +0 -40
  157. package/lib/framework/document-combine.js.map +0 -1
  158. package/lib/framework/document-comment.js +0 -148
  159. package/lib/framework/document-comment.js.map +0 -1
  160. package/lib/framework/document-context.js +0 -330
  161. package/lib/framework/document-context.js.map +0 -1
  162. package/lib/framework/document-eval-func.js +0 -48
  163. package/lib/framework/document-eval-func.js.map +0 -1
  164. package/lib/framework/document-event.js +0 -1054
  165. package/lib/framework/document-event.js.map +0 -1
  166. package/lib/framework/document-history.js +0 -65
  167. package/lib/framework/document-history.js.map +0 -1
  168. package/lib/framework/document-images-loader.js +0 -66
  169. package/lib/framework/document-images-loader.js.map +0 -1
  170. package/lib/framework/document-input-cursor.js +0 -239
  171. package/lib/framework/document-input-cursor.js.map +0 -1
  172. package/lib/framework/document-paint.js +0 -103
  173. package/lib/framework/document-paint.js.map +0 -1
  174. package/lib/framework/document-print-offscreen.js +0 -128
  175. package/lib/framework/document-print-offscreen.js.map +0 -1
  176. package/lib/framework/document-print.js +0 -203
  177. package/lib/framework/document-print.js.map +0 -1
  178. package/lib/framework/document-segmenter.js +0 -106
  179. package/lib/framework/document-segmenter.js.map +0 -1
  180. package/lib/framework/document-selection.js +0 -358
  181. package/lib/framework/document-selection.js.map +0 -1
  182. package/lib/framework/document-template.js +0 -20
  183. package/lib/framework/document-template.js.map +0 -1
  184. package/lib/framework/document-textline-mode.js +0 -30
  185. package/lib/framework/document-textline-mode.js.map +0 -1
  186. package/lib/framework/element-define.js +0 -579
  187. package/lib/framework/element-define.js.map +0 -1
  188. package/lib/framework/element-event-define.js +0 -108
  189. package/lib/framework/element-event-define.js.map +0 -1
  190. package/lib/framework/element-measure.js +0 -551
  191. package/lib/framework/element-measure.js.map +0 -1
  192. package/lib/framework/element-paint.js +0 -170
  193. package/lib/framework/element-paint.js.map +0 -1
  194. package/lib/framework/element-props.js +0 -809
  195. package/lib/framework/element-props.js.map +0 -1
  196. package/lib/framework/element-reader.js +0 -151
  197. package/lib/framework/element-reader.js.map +0 -1
  198. package/lib/framework/element-render-cut.js +0 -449
  199. package/lib/framework/element-render-cut.js.map +0 -1
  200. package/lib/framework/element-serialize.js +0 -113
  201. package/lib/framework/element-serialize.js.map +0 -1
  202. package/lib/framework/element-util.js +0 -1463
  203. package/lib/framework/element-util.js.map +0 -1
  204. package/lib/framework/impl/checkbox/checkbox-impl.js +0 -64
  205. package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
  206. package/lib/framework/impl/comments/comment-content-impl.js +0 -105
  207. package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
  208. package/lib/framework/impl/comments/comment-element-impl.js +0 -62
  209. package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
  210. package/lib/framework/impl/comments/comments-container-impl.js +0 -62
  211. package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
  212. package/lib/framework/impl/comments/comments-util.js +0 -67
  213. package/lib/framework/impl/comments/comments-util.js.map +0 -1
  214. package/lib/framework/impl/comments/validate-msg-impl.js +0 -83
  215. package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
  216. package/lib/framework/impl/data-element/data-decorate-impl.js +0 -91
  217. package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
  218. package/lib/framework/impl/data-element/data-element-barcode.js +0 -115
  219. package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
  220. package/lib/framework/impl/data-element/data-element-base-impl.js +0 -205
  221. package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
  222. package/lib/framework/impl/data-element/data-element-check-impl.js +0 -133
  223. package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
  224. package/lib/framework/impl/data-element/data-element-date-impl.js +0 -111
  225. package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
  226. package/lib/framework/impl/data-element/data-element-group-impl.js +0 -130
  227. package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
  228. package/lib/framework/impl/data-element/data-element-image-impl.js +0 -137
  229. package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
  230. package/lib/framework/impl/data-element/data-element-list-impl.js +0 -131
  231. package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
  232. package/lib/framework/impl/data-element/data-element-text-impl.js +0 -103
  233. package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
  234. package/lib/framework/impl/decorate/fill-null-space-imple.js +0 -43
  235. package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
  236. package/lib/framework/impl/document/doc-body-impl.js +0 -79
  237. package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
  238. package/lib/framework/impl/document/doc-body-part-impl.js +0 -94
  239. package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
  240. package/lib/framework/impl/document/doc-container-impl.js +0 -21
  241. package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
  242. package/lib/framework/impl/document/doc-footer-impl.js +0 -77
  243. package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
  244. package/lib/framework/impl/document/doc-header-impl.js +0 -83
  245. package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
  246. package/lib/framework/impl/document/doc-impl.js +0 -209
  247. package/lib/framework/impl/document/doc-impl.js.map +0 -1
  248. package/lib/framework/impl/media-formula/menstrual-history.js +0 -153
  249. package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
  250. package/lib/framework/impl/paragraph/p-impl.js +0 -156
  251. package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
  252. package/lib/framework/impl/picture/image-impl.js +0 -124
  253. package/lib/framework/impl/picture/image-impl.js.map +0 -1
  254. package/lib/framework/impl/radio/radio-impl.js +0 -72
  255. package/lib/framework/impl/radio/radio-impl.js.map +0 -1
  256. package/lib/framework/impl/symbol/br-symbol-impl.js +0 -54
  257. package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
  258. package/lib/framework/impl/symbol/p-symbol-impl.js +0 -54
  259. package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
  260. package/lib/framework/impl/table/table-cell-impl.js +0 -145
  261. package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
  262. package/lib/framework/impl/table/table-impl.js +0 -363
  263. package/lib/framework/impl/table/table-impl.js.map +0 -1
  264. package/lib/framework/impl/table/table-row-impl.js +0 -75
  265. package/lib/framework/impl/table/table-row-impl.js.map +0 -1
  266. package/lib/framework/impl/table/table-split-cell-patch.js +0 -89
  267. package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
  268. package/lib/framework/impl/table/table-split-cell.js +0 -464
  269. package/lib/framework/impl/table/table-split-cell.js.map +0 -1
  270. package/lib/framework/impl/table/table-util.js +0 -678
  271. package/lib/framework/impl/table/table-util.js.map +0 -1
  272. package/lib/framework/impl/text/text-impl.js +0 -149
  273. package/lib/framework/impl/text/text-impl.js.map +0 -1
  274. package/lib/framework/impl/text/track-run-impl.js +0 -112
  275. package/lib/framework/impl/text/track-run-impl.js.map +0 -1
  276. package/lib/framework/notify.js +0 -116
  277. package/lib/framework/notify.js.map +0 -1
  278. package/lib/framework/range-util.js +0 -312
  279. package/lib/framework/range-util.js.map +0 -1
  280. package/lib/framework/render-context.js +0 -384
  281. package/lib/framework/render-context.js.map +0 -1
  282. package/lib/framework/render-define.js +0 -195
  283. package/lib/framework/render-define.js.map +0 -1
  284. package/lib/framework/selection-overlays.js +0 -124
  285. package/lib/framework/selection-overlays.js.map +0 -1
  286. package/lib/texteditor.js +0 -913
  287. package/lib/texteditor.js.map +0 -1
  288. package/lib/util/subject.js +0 -88
  289. package/lib/util/subject.js.map +0 -1
  290. package/lib/util/table-bind.js +0 -6
  291. package/lib/util/table-bind.js.map +0 -1
@@ -1,75 +0,0 @@
1
- import { BlockContainerElement, ElementFactory, ModifyFlag } from "../../element-define";
2
- import { TableRowProps } from "../../element-props";
3
- import { ElementUtil } from "../../element-util";
4
- import { MuiltBlockLineRenderObject } from "../../render-define";
5
- import { TableCellElement } from "./table-cell-impl";
6
- export class TableRowElement extends BlockContainerElement {
7
- //props: TableRowProps;
8
- constructor() {
9
- super('tr');
10
- this.props = new TableRowProps();
11
- //在差异更新中,由于行内单元格存在合并行的情况,需要将当前行内存在合并的单元格,将其修改标志改为修改
12
- const changeSub = this.onChangeSubject.subscribe(() => {
13
- if (this.modifyFlag === ModifyFlag.Track) {
14
- //this.checkRowModifyState();
15
- this.pubOnChange('to-child');
16
- }
17
- });
18
- this.addsubscribe(this, changeSub);
19
- }
20
- createRenderObject() {
21
- return new TableRowRenderObject(this);
22
- }
23
- serialize(viewOptions) {
24
- return {
25
- type: 'tr',
26
- props: {
27
- ...this.props?.getSerializeProps(viewOptions)
28
- }
29
- };
30
- }
31
- clone(data) {
32
- const clone = new TableRowElement();
33
- this.props.clone(clone.props);
34
- if (data) {
35
- for (let i = 0; i < this.length; i++) {
36
- clone.addChild(this.getChild(i).clone(true));
37
- }
38
- }
39
- return clone;
40
- }
41
- static createRow(cols) {
42
- const tr = new TableRowElement();
43
- for (let i = 0; i < cols; i++) {
44
- tr.addChild(TableCellElement.createCell());
45
- }
46
- return tr;
47
- }
48
- }
49
- export class TableRowRenderObject extends MuiltBlockLineRenderObject {
50
- beginRender(ctx, position) {
51
- }
52
- endRender(ctx, position) {
53
- }
54
- clone() {
55
- const cloneRender = new TableRowRenderObject(this.element);
56
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
57
- for (let i = 0; i < this.length; i++) {
58
- cloneRender.addChild(this.getChild(i).clone());
59
- }
60
- return cloneRender;
61
- }
62
- }
63
- export class TableRowFactory extends ElementFactory {
64
- match(type) {
65
- return type === 'tr';
66
- }
67
- createElement(data, renderCtx) {
68
- const props = data.props;
69
- const tr = new TableRowElement();
70
- tr.props.minHeight = props?.minHeight ?? -1;
71
- tr.props.headerRow = props?.headerRow;
72
- return tr;
73
- }
74
- }
75
- //# sourceMappingURL=table-row-impl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-row-impl.js","sourceRoot":"lib/","sources":["framework/impl/table/table-row-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAW,cAAc,EAAE,UAAU,EAAiD,MAAM,sBAAsB,CAAC;AACjJ,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,0BAA0B,EAAgB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,OAAO,eAAgB,SAAQ,q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IAAI,EAAE,CAAC,EAAE,EAAE;YAC3B,EAAE,CAAC,QAAQ,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAC,CAAC;SAC9C;QACD,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAED,MAAM,OAAO,oBAAqB,SAAQ,0BAA2C;IACjF,WAAW,CAAC,GAAuB,EAAE,QAAmC;IACxE,CAAC;IACD,SAAS,CAAC,GAAuB,EAAE,QAAmC;IACtE,CAAC;IAED,KAAK;QACD,MAAM,WAAW,GAAG,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,WAAW,CAAC,IAAI,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAClC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;SAClD;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;CACJ;AAED,MAAM,OAAO,eAAgB,SAAQ,cAA6B;IAC9D,KAAK,CAAC,IAAY;QACd,OAAO,IAAI,KAAK,IAAI,CAAC;IACzB,CAAC;IACD,aAAa,CAAC,IAAqC,EAAE,SAA6B;QAC9E,MAAM,KAAK,GAAG,IAAI,CAAC,KAAsB,CAAC;QAC1C,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QACjC,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC;QAC5C,EAAE,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,EAAE,SAAS,CAAC;QACtC,OAAO,EAAE,CAAC;IACd,CAAC;CAEJ","sourcesContent":["import { BlockContainerElement, Element, ElementFactory, ModifyFlag, readElementProps, SerializeProps, ViewOptions } from \"../../element-define\";\nimport { TableRowProps } from \"../../element-props\";\nimport { ElementUtil } from \"../../element-util\";\nimport { RenderContenxtType } from \"../../render-context\";\nimport { MuiltBlockLineRenderObject, RenderObject } from \"../../render-define\";\nimport { TableCellElement } from \"./table-cell-impl\";\n\nexport class TableRowElement extends BlockContainerElement<TableRowProps> {\n //props: TableRowProps;\n constructor() {\n super('tr');\n this.props = new TableRowProps();\n //在差异更新中,由于行内单元格存在合并行的情况,需要将当前行内存在合并的单元格,将其修改标志改为修改\n const changeSub = this.onChangeSubject.subscribe(() => {\n if (this.modifyFlag === ModifyFlag.Track) {\n //this.checkRowModifyState();\n this.pubOnChange('to-child');\n }\n });\n this.addsubscribe(this, changeSub);\n }\n\n createRenderObject(): RenderObject {\n return new TableRowRenderObject(this);\n }\n\n serialize(viewOptions: ViewOptions): SerializeProps {\n return {\n type: 'tr',\n props: {\n ...this.props?.getSerializeProps(viewOptions)\n }\n };\n }\n clone(data: boolean): Element {\n const clone = new TableRowElement();\n this.props.clone(clone.props);\n if (data) {\n for (let i = 0; i < this.length; i++) {\n clone.addChild(this.getChild(i).clone(true));\n }\n }\n return clone;\n }\n\n static createRow(cols: number): TableRowElement {\n const tr = new TableRowElement();\n for (let i = 0; i < cols; i++) {\n tr.addChild(TableCellElement.createCell());\n }\n return tr;\n }\n}\n\nexport class TableRowRenderObject extends MuiltBlockLineRenderObject<TableRowElement> {\n beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n }\n endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {\n }\n\n clone(): RenderObject {\n const cloneRender = new TableRowRenderObject(this.element);\n cloneRender.rect = ElementUtil.cloneRect(this.rect);\n for (let i = 0; i < this.length; i++) {\n cloneRender.addChild(this.getChild(i).clone());\n }\n return cloneRender;\n }\n}\n\nexport class TableRowFactory extends ElementFactory<TableRowProps> {\n match(type: string): boolean {\n return type === 'tr';\n }\n createElement(data: readElementProps<TableRowProps>, renderCtx: RenderContenxtType): Element {\n const props = data.props as TableRowProps;\n const tr = new TableRowElement();\n tr.props.minHeight = props?.minHeight ?? -1;\n tr.props.headerRow = props?.headerRow;\n return tr;\n }\n\n}\n"]}
@@ -1,89 +0,0 @@
1
- export class ColumnPatchUtil {
2
- static getPatchPacks(cols, splitCols) {
3
- const oldLinePointMap = this.getLinePointMap(cols);
4
- //要分割的列坐标
5
- const newLinePointMap = this.getLinePointMap(splitCols);
6
- const resArray = new Set();
7
- const allPointMap = oldLinePointMap.concat(newLinePointMap);
8
- for (let i = 0; i < allPointMap.length; i++) {
9
- const part = allPointMap[i];
10
- resArray.add(part.offset);
11
- resArray.add(part.offset + part.width);
12
- }
13
- const points = Array.from(resArray).sort((first, second) => first - second);
14
- const patchs = [];
15
- //获取其他行的拆分补丁
16
- for (let i = 0; i < points.length - 1; i++) {
17
- const partStartOffset = points[i];
18
- const partEndOffset = points[i + 1];
19
- const joinPart = oldLinePointMap.find(item => {
20
- const startOffset = item.offset;
21
- const endOffset = item.offset + item.width;
22
- return ((startOffset >= partStartOffset && startOffset < partEndOffset)
23
- ||
24
- (endOffset > partStartOffset && endOffset <= partEndOffset)
25
- ||
26
- (startOffset <= partStartOffset && endOffset >= partEndOffset));
27
- });
28
- if (joinPart) {
29
- if (joinPart.offset === partStartOffset && joinPart.offset + joinPart.width === partEndOffset) {
30
- continue;
31
- }
32
- const patch = patchs.find(item => item.part === joinPart);
33
- if (patch) {
34
- patch.patchs.push({ type: 'insert', data: { width: partEndOffset - partStartOffset, index: joinPart.index } });
35
- }
36
- else {
37
- patchs.push({
38
- part: joinPart,
39
- patchs: [{ type: 'modify', data: { width: partEndOffset - partStartOffset, index: joinPart.index } }]
40
- });
41
- }
42
- }
43
- }
44
- //获取当前行的拆分补丁
45
- const currRowPaths = [];
46
- const allColumnMap = this.getLinePointMap(this.getColumn(points));
47
- for (let i = 0; i < newLinePointMap.length; i++) {
48
- const partStartOffset = newLinePointMap[i].offset;
49
- const partEndOffset = newLinePointMap[i].offset + newLinePointMap[i].width;
50
- const joinParts = allColumnMap.filter(item => {
51
- const startOffset = item.offset;
52
- const endOffset = item.offset + item.width;
53
- return ((startOffset >= partStartOffset && startOffset < partEndOffset)
54
- ||
55
- (endOffset > partStartOffset && endOffset <= partEndOffset)
56
- ||
57
- (startOffset <= partStartOffset && endOffset >= partEndOffset));
58
- });
59
- currRowPaths.push(joinParts);
60
- }
61
- return [patchs, currRowPaths];
62
- }
63
- static getColumn(points) {
64
- const items = [];
65
- for (let index = 0; index < points.length - 1; index++) {
66
- items.push({ index, width: points[index + 1] - points[index] });
67
- }
68
- return items;
69
- }
70
- static getSplitCols(width, cols) {
71
- const items = [];
72
- for (let i = 0; i < cols; i++) {
73
- items.push({ width: Math.floor(width / cols), index: i });
74
- }
75
- items[items.length - 1].width += width - items.reduce((prev, curr) => prev + curr.width, 0);
76
- return items;
77
- }
78
- static getLinePointMap(hMergeCols) {
79
- const linePointMap = [];
80
- let x = 0;
81
- for (let i = 0; i < hMergeCols.length; i++) {
82
- const col = hMergeCols[i];
83
- linePointMap.push({ index: col.index, width: col.width, offset: x });
84
- x += col.width;
85
- }
86
- return linePointMap;
87
- }
88
- }
89
- //# sourceMappingURL=table-split-cell-patch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table-split-cell-patch.js","sourceRoot":"lib/","sources":["framework/impl/table/table-split-cell-patch.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,eAAe;IACxB,MAAM,CAAC,aAAa,CAAC,IAAuB,EAAE,SAA4B;QACtE,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACnD,SAAS;QACT,MAAM,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACxD,MAAM,QAAQ,GAAgB,IAAI,GAAG,EAAE,CAAC;QACxC,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;QAC5D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MA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O,KAAK,CAAC;IACjB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,UAA6B;QACxD,MAAM,YAAY,GAA4B,EAAE,CAAC;QACjD,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxC,MAAM,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;YAC1B,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACrE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC;SAClB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ","sourcesContent":["export interface ColumnPartOffset extends ColumnPart { offset: number }\nexport interface ColumnPart { index: number, width: number }\nexport interface ColumnPatch { type: 'modify' | 'insert', data: ColumnPart }\nexport class ColumnPatchUtil {\n static getPatchPacks(cols: Array<ColumnPart>, splitCols: Array<ColumnPart>): [Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }>, Array<Array<ColumnPart>>] {\n const oldLinePointMap = this.getLinePointMap(cols);\n //要分割的列坐标\n const newLinePointMap = this.getLinePointMap(splitCols);\n const resArray: Set<number> = new Set();\n const allPointMap = oldLinePointMap.concat(newLinePointMap);\n for (let i = 0; i < allPointMap.length; i++) {\n const part = allPointMap[i];\n resArray.add(part.offset);\n resArray.add(part.offset + part.width);\n }\n const points = Array.from(resArray).sort((first, second) => first - second);\n const patchs: Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }> = [];\n //获取其他行的拆分补丁\n for (let i = 0; i < points.length - 1; i++) {\n const partStartOffset = points[i];\n const partEndOffset = points[i + 1];\n const joinPart = oldLinePointMap.find(item => {\n const startOffset = item.offset;\n const endOffset = item.offset + item.width;\n return (\n (startOffset >= partStartOffset && startOffset < partEndOffset)\n ||\n (endOffset > partStartOffset && endOffset <= partEndOffset)\n ||\n (startOffset <= partStartOffset && endOffset >= partEndOffset)\n )\n });\n if (joinPart) {\n if (joinPart.offset === partStartOffset && joinPart.offset + joinPart.width === partEndOffset) {\n continue;\n }\n const patch = patchs.find(item => item.part === joinPart);\n if (patch) {\n patch.patchs.push({ type: 'insert', data: { width: partEndOffset - partStartOffset, index: joinPart.index } })\n } else {\n patchs.push({\n part: joinPart,\n patchs: [{ type: 'modify', data: { width: partEndOffset - partStartOffset, index: joinPart.index } }]\n })\n }\n }\n }\n //获取当前行的拆分补丁\n const currRowPaths: Array<Array<ColumnPart>> = [];\n const allColumnMap = this.getLinePointMap(this.getColumn(points));\n for (let i = 0; i < newLinePointMap.length; i++) {\n const partStartOffset = newLinePointMap[i].offset;\n const partEndOffset = newLinePointMap[i].offset + newLinePointMap[i].width;\n const joinParts = allColumnMap.filter(item => {\n const startOffset = item.offset;\n const endOffset = item.offset + item.width;\n return (\n (startOffset >= partStartOffset && startOffset < partEndOffset)\n ||\n (endOffset > partStartOffset && endOffset <= partEndOffset)\n ||\n (startOffset <= partStartOffset && endOffset >= partEndOffset)\n )\n });\n currRowPaths.push(joinParts);\n }\n return [patchs, currRowPaths];\n }\n\n\n private static getColumn(points: Array<number>): Array<ColumnPart> {\n const items: Array<ColumnPart> = [];\n for (let index = 0; index < points.length - 1; index++) {\n items.push({ index, width: points[index + 1] - points[index] });\n }\n return items;\n }\n\n private static getSplitCols(width: number, cols: number): Array<ColumnPart> {\n const items: Array<ColumnPart> = [];\n for (let i = 0; i < cols; i++) {\n items.push({ width: Math.floor(width / cols), index: i });\n }\n items[items.length - 1].width += width - items.reduce((prev, curr) => prev + curr.width, 0);\n return items;\n }\n\n private static getLinePointMap(hMergeCols: Array<ColumnPart>): Array<ColumnPartOffset> {\n const linePointMap: Array<ColumnPartOffset> = [];\n let x = 0;\n for (let i = 0; i < hMergeCols.length; i++) {\n const col = hMergeCols[i];\n linePointMap.push({ index: col.index, width: col.width, offset: x });\n x += col.width;\n }\n return linePointMap;\n }\n}"]}
@@ -1,464 +0,0 @@
1
- import { ElementUtil } from "../../element-util";
2
- import { TableCellElement } from "./table-cell-impl";
3
- import { TableElement } from "./table-impl";
4
- import { TableRowElement } from "./table-row-impl";
5
- import { ColumnPatchUtil } from "./table-split-cell-patch";
6
- import { TableUtil } from "./table-util";
7
- /**
8
- * 拆分单元格
9
- * 蜀道难,难于上青天;拆分单元格,头发秃,精神衰,眼睛昏,身体废。
10
- *
11
- * 1.拆分为多列规则:不影响其他列宽度,将当前列宽度均分
12
- */
13
- export class TableSplitCell {
14
- /**
15
- *
16
- * 普通单元格可以任意拆分行和列
17
- * 已合并的单元格,可以拆分任意数量的列;可以拆分的数量必须为合并单元格数量的约数
18
- */
19
- static splitCell(ss, rows, cols) {
20
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
21
- if (!focusCell) {
22
- throw new Error('focusCell is null');
23
- }
24
- if (!focusCell.props.hMerge && !focusCell.props.vMerge) {
25
- this.splitNormalCell(ss, rows, cols);
26
- }
27
- else {
28
- this.splitMergeCell(ss, rows, cols);
29
- }
30
- // else if (!focusCell.cellProps.hMerge) {
31
- // const { endColIndex } = this.horSplitHorNormalCell(ss, rows, cols);
32
- // this.verSplitVerMergeCell(ss, rows, endColIndex);
33
- // }
34
- // //当前单元格为横向合并单元格
35
- // else {
36
- // const { endColIndex } = this.horSplitHorMergeCell(ss, rows, cols);
37
- // this.verSplitVerMergeCell(ss, rows, endColIndex);
38
- // }
39
- }
40
- /**
41
- * 拆分普通的单元格
42
- */
43
- static splitNormalCell(ss, rows, cols) {
44
- rows = rows < 1 ? 1 : rows;
45
- cols = cols < 1 ? 1 : cols;
46
- if (rows === 1 && cols === 1) {
47
- return;
48
- }
49
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
50
- const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
51
- const tb = ElementUtil.getParentByType(focusRow, TableElement);
52
- if (!focusCell || !focusRow || !tb) {
53
- throw new Error('focusCell | focusRow | tb is null');
54
- }
55
- const focusCellIndex = focusRow.getChildIndex(focusCell);
56
- const focusRowIndex = focusRow.getIndex();
57
- const cellWidth = tb.getCellWidth(focusCellIndex);
58
- if (focusCell.props.hMerge || focusCell.props.vMerge) {
59
- return;
60
- }
61
- //拆分为多列
62
- if (cols > 1) {
63
- const splitCellWidths = this.getSplitCols(cellWidth, cols);
64
- tb.setCellWidth(focusCellIndex, splitCellWidths[0].width);
65
- for (let i = 1; i < splitCellWidths.length; i++) {
66
- tb.insertCol(focusCellIndex + i, splitCellWidths[i].width);
67
- }
68
- for (let i = 0; i < tb.length; i++) {
69
- const row = tb.getChild(i);
70
- //获取主单元格
71
- const masterCell = row.getChild(focusCellIndex);
72
- for (let j = 1; j < cols; j++) {
73
- const newCell = new TableCellElement();
74
- row.addChild(newCell, focusCellIndex + j);
75
- if (i < focusRowIndex || i > focusRowIndex) {
76
- //由普通单元格转向合并单元格
77
- if (!masterCell.props.hMerge) {
78
- masterCell.props.hMerge = 'restart';
79
- }
80
- newCell.props.hMerge = 'continue';
81
- }
82
- }
83
- }
84
- }
85
- if (rows > 1) {
86
- for (let i = 1; i < rows; i++) {
87
- const newRow = TableRowElement.createRow(tb.getColsCount());
88
- tb.addChild(newRow, focusRowIndex + i);
89
- for (let j = 0; j < newRow.length; j++) {
90
- const cell = newRow.getChild(j);
91
- const masterCell = focusRow.getChild(j);
92
- if (j < focusCellIndex || j > focusCellIndex + cols - 1)
93
- //紧挨上级的单元格存在横向合并
94
- if (masterCell.props.hMerge) {
95
- if (masterCell.props.hMerge === 'restart') {
96
- if (!masterCell.props.vMerge) {
97
- masterCell.props.vMerge = 'restart';
98
- }
99
- cell.props.vMerge = 'continue';
100
- }
101
- }
102
- else {
103
- if (!masterCell.props.vMerge) {
104
- masterCell.props.vMerge = 'restart';
105
- }
106
- cell.props.vMerge = 'continue';
107
- }
108
- }
109
- }
110
- }
111
- tb.pubOnChange('self');
112
- tb.refreshView();
113
- }
114
- /**
115
- * 拆分合并的单元格
116
- * @param ss
117
- * @param rows
118
- * @param cols
119
- */
120
- static splitMergeCell(ss, rows, cols) {
121
- rows = rows < 1 ? 1 : rows;
122
- cols = cols < 1 ? 1 : cols;
123
- if (rows === 1 && cols === 1) {
124
- return;
125
- }
126
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
127
- const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
128
- const tb = ElementUtil.getParentByType(focusRow, TableElement);
129
- if (!focusCell || !focusRow || !tb) {
130
- throw new Error('focusCell | focusRow | tb is null');
131
- }
132
- const focusCellIndex = focusRow.getChildIndex(focusCell);
133
- const focusRowIndex = focusRow.getIndex();
134
- const cellWidth = tb.getCellWidth(focusCellIndex);
135
- if (!focusCell.props.hMerge && !focusCell.props.vMerge) {
136
- return;
137
- }
138
- const mergeRows = this.getVMergeRowsCount(tb, focusRowIndex, focusCellIndex);
139
- const mergeCols = this.getHMergeColsCount(tb, focusRowIndex, focusCellIndex);
140
- //只有拆分的行数需要满足此条件
141
- if (mergeRows > 1 && rows > 1) {
142
- if (rows % mergeRows !== 0) {
143
- throw new Error(`当前合并的行数为:${mergeRows},当前可拆分的行数是${mergeRows}的约数`);
144
- }
145
- }
146
- //拆分的行数、列数等于合并的行数、列数
147
- //执行还原
148
- if (mergeCols === cols && mergeRows === rows) {
149
- TableUtil.restoreCell(ss);
150
- return;
151
- }
152
- if (mergeCols === 1) {
153
- const { endColIndex } = this.horSplitHorNormalCell(ss, rows, cols);
154
- this.verSplitVerMergeCell(ss, rows, endColIndex);
155
- }
156
- //当前单元格为横向合并单元格
157
- else {
158
- const { endColIndex } = this.horSplitHorMergeCell(ss, rows, cols);
159
- this.verSplitVerMergeCell(ss, rows, endColIndex);
160
- }
161
- }
162
- /**
163
- * 拆分横向正常的单元格
164
- * @param ss
165
- * @param rows
166
- * @param cols
167
- */
168
- static horSplitHorNormalCell(ss, rows, cols) {
169
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
170
- const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
171
- const tb = ElementUtil.getParentByType(focusRow, TableElement);
172
- if (!focusCell || !focusRow || !tb) {
173
- throw new Error('focusCell | focusRow | tb is null');
174
- }
175
- const focusCellIndex = focusRow.getChildIndex(focusCell);
176
- const focusRowIndex = focusRow.getIndex();
177
- const cellWidth = tb.getCellWidth(focusCellIndex);
178
- const splitCellWidths = this.getSplitCols(cellWidth, cols);
179
- tb.setCellWidth(focusCellIndex, splitCellWidths[0].width);
180
- for (let i = 1; i < splitCellWidths.length; i++) {
181
- tb.insertCol(focusCellIndex + i, splitCellWidths[i].width);
182
- }
183
- const mergeRows = this.getVMergeRowsCount(tb, focusRowIndex, focusCellIndex);
184
- rows = rows < mergeRows ? mergeRows : rows;
185
- //向指定的列插入拆分单元格
186
- if (cols > 1) {
187
- for (let i = 0; i < tb.length; i++) {
188
- const currRow = tb.getChild(i);
189
- //获取主单元格
190
- const masterCell = currRow.getChild(focusCellIndex);
191
- for (let j = 1; j < cols; j++) {
192
- const newCell = new TableCellElement();
193
- currRow.addChild(newCell, focusCellIndex + j);
194
- if (i < focusRowIndex || i >= focusRowIndex + rows) {
195
- //由普通单元格转向合并单元格
196
- if (!masterCell.props.hMerge) {
197
- masterCell.props.hMerge = 'restart';
198
- }
199
- newCell.props.hMerge = 'continue';
200
- }
201
- else {
202
- newCell.props.vMerge = masterCell.props.vMerge;
203
- }
204
- }
205
- }
206
- }
207
- //在选中行下插入拆分行
208
- //如果当前是普通单元格
209
- if (!focusCell.props.vMerge) {
210
- debugger;
211
- for (let i = 1; i < rows; i++) {
212
- const newRow = TableRowElement.createRow(tb.getColsCount());
213
- tb.addChild(newRow, focusRowIndex + i);
214
- }
215
- }
216
- tb.pubOnChange('to-child');
217
- tb.refreshView();
218
- return {
219
- startColIndex: focusCellIndex,
220
- endColIndex: focusCellIndex + cols - 1
221
- };
222
- }
223
- /**
224
- * 横向拆分合并的单元格
225
- * @param ss
226
- * @param rows
227
- * @param cols
228
- */
229
- static horSplitHorMergeCell(ss, rows, cols) {
230
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
231
- const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
232
- const tb = ElementUtil.getParentByType(focusRow, TableElement);
233
- if (!focusCell || !focusRow || !tb) {
234
- throw new Error('focusCell | focusRow | tb is null');
235
- }
236
- const focusCellIndex = focusRow.getChildIndex(focusCell);
237
- const focusRowIndex = focusRow.getIndex();
238
- const hMergeCols = this.getHMergeCols(tb, focusRowIndex, focusCellIndex, cols);
239
- const colsWidth = hMergeCols.reduce((prev, curr) => prev + curr.width, 0);
240
- const splitCols = this.getSplitCols(colsWidth, cols);
241
- const [otherPacks, currPacks] = ColumnPatchUtil.getPatchPacks(hMergeCols, splitCols);
242
- this.applyHorSplitColumnPatchPacks(tb, focusRowIndex, 1, otherPacks);
243
- this.applyHorSplitColumnCurrPatchPacks(tb, focusRowIndex, focusCellIndex, rows, currPacks);
244
- tb.pubOnChange('to-child');
245
- tb.refreshView();
246
- return {
247
- startColIndex: focusCellIndex,
248
- endColIndex: this.getPrepareNewColCounts(otherPacks, hMergeCols)
249
- };
250
- }
251
- /**
252
- * 获取需要新创建的列数量
253
- */
254
- static getPrepareNewColCounts(packs, hMergeCols) {
255
- const lastColIndex = hMergeCols[hMergeCols.length - 1].index;
256
- if (packs.length === 0) {
257
- return lastColIndex;
258
- }
259
- const lastColPack = packs.find(pack => pack.part.index === lastColIndex);
260
- if (!lastColPack) {
261
- return lastColIndex;
262
- }
263
- return lastColIndex + lastColPack.patchs.filter(item => item.type === 'insert').length;
264
- }
265
- /**
266
- * 应用横向拆分单元格补丁
267
- */
268
- static applyHorSplitColumnPatchPacks(tb, focusRowIndex, splitRows, packs) {
269
- for (let i = packs.length - 1; i >= 0; i--) {
270
- const pack = packs[i];
271
- const colIndex = pack.part.index;
272
- for (let j = pack.patchs.length - 1; j >= 0; j--) {
273
- const patch = pack.patchs[j];
274
- if (patch.type === 'modify') {
275
- tb.setCellWidth(colIndex, patch.data.width);
276
- }
277
- else if (patch.type === 'insert') {
278
- tb.insertCol(colIndex + 1, patch.data.width);
279
- //向指定的列插入拆分单元格
280
- for (let i = 0; i < tb.length; i++) {
281
- const currRow = tb.getChild(i);
282
- //获取主单元格
283
- const masterCell = currRow.getChild(colIndex);
284
- const newCell = new TableCellElement();
285
- currRow.addChild(newCell, colIndex + 1);
286
- if (!masterCell.props.hMerge) {
287
- masterCell.props.hMerge = 'restart';
288
- }
289
- newCell.props.hMerge = 'continue';
290
- }
291
- }
292
- }
293
- }
294
- }
295
- /**
296
- * 存在横向合并的单元格,进行单元格分拆,打补丁
297
- * @param tb
298
- * @param focusRowIndex
299
- * @param focusColInex
300
- * @param splitRows
301
- * @param packs
302
- */
303
- static applyHorSplitColumnCurrPatchPacks(tb, focusRowIndex, focusColInex, splitRows, packs) {
304
- //获取当前列的合并行数
305
- let vMergeRows = this.getVMergeRowsCount(tb, focusRowIndex, focusColInex);
306
- vMergeRows = vMergeRows === 1 ? 0 : vMergeRows;
307
- const startRow = tb.getChild(focusRowIndex);
308
- const endRow = tb.getChild(focusRowIndex + vMergeRows - 1);
309
- for (let i = 0; i < packs.length; i++) {
310
- const mergeCols = packs[i];
311
- if (mergeCols.length === 1) {
312
- const startCell = startRow.getChild(focusColInex + mergeCols[0].index);
313
- const endCell = endRow.getChild(focusColInex + mergeCols[0].index);
314
- TableUtil.combineCells(tb, startCell, endCell);
315
- }
316
- else {
317
- // for (let j = 0; j < mergeCols.length; j++) {
318
- // const cell = focusRow.getChild(focusColInex + mergeCols[j].index) as TableCellElement;
319
- // cell.cellProps.hMerge = j === 0 ? 'restart' : 'continue';
320
- // }
321
- const startCell = startRow.getChild(focusColInex + mergeCols[0].index);
322
- const endCell = endRow.getChild(focusColInex + mergeCols[mergeCols.length - 1].index);
323
- TableUtil.combineCells(tb, startCell, endCell);
324
- }
325
- }
326
- }
327
- /**
328
- * 纵向拆分合并的单元格
329
- * 在指定行下插入复制行
330
- * 存在
331
- */
332
- static verSplitVerMergeCell(ss, rows, endColIndex) {
333
- if (rows === 1) {
334
- return;
335
- }
336
- const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
337
- const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
338
- const tb = ElementUtil.getParentByType(focusRow, TableElement);
339
- if (!focusCell || !focusRow || !tb) {
340
- throw new Error('focusCell | focusRow | tb is null');
341
- }
342
- const focusCellIndex = focusRow.getChildIndex(focusCell);
343
- const focusRowIndex = focusRow.getIndex();
344
- let mergeRows = 0;
345
- if (focusCell.props.vMerge === 'restart') {
346
- mergeRows = this.getVMergeRowsCount(tb, focusRowIndex, focusCellIndex);
347
- if (mergeRows % rows !== 0) {
348
- throw new Error(`可拆分的行数必须是${mergeRows}的约数`);
349
- }
350
- }
351
- //不存在合并行,则向下新增行
352
- if (mergeRows === 0) {
353
- for (let i = 0; i < rows - 1; i++) {
354
- const newRow = new TableRowElement();
355
- for (let i = 0; i < focusRow.length; i++) {
356
- const focusRowCell = focusRow.getChild(i);
357
- const cell = new TableCellElement();
358
- //其他列要纵向合并
359
- if (i < focusCellIndex || i > endColIndex) {
360
- if (!focusRowCell.props.vMerge) {
361
- focusRowCell.props.vMerge = 'restart';
362
- }
363
- cell.props.vMerge = 'continue';
364
- }
365
- cell.props.hMerge = focusRowCell.props.hMerge;
366
- newRow.addChild(cell);
367
- }
368
- tb.addChild(newRow, focusRowIndex + i + 1);
369
- }
370
- }
371
- //存在合并行,则按照约数单个合并分拆为多个合并
372
- else {
373
- //拆分行和合并行相等,则执行还原
374
- if (rows === mergeRows) {
375
- for (let i = 0; i < mergeRows; i++) {
376
- const row = tb.getChild(focusRowIndex + i);
377
- for (let j = focusCellIndex; j <= endColIndex; j++) {
378
- const cell = row.getChild(j);
379
- cell.props.vMerge = null;
380
- }
381
- }
382
- }
383
- else {
384
- for (let i = 0; i < mergeRows; i++) {
385
- if (i % rows === 0) {
386
- const row = tb.getChild(focusRowIndex + i);
387
- const cell = row.getChild(focusCellIndex);
388
- cell.props.vMerge = 'restart';
389
- }
390
- }
391
- }
392
- }
393
- }
394
- static getSplitCols(width, cols) {
395
- const items = [];
396
- for (let i = 0; i < cols; i++) {
397
- items.push({ width: Math.floor(width / cols), index: i });
398
- }
399
- items[items.length - 1].width += width - items.reduce((prev, curr) => prev + curr.width, 0);
400
- return items;
401
- }
402
- /**
403
- * 获取横向合并的列
404
- * @param tb
405
- * @param currRowIndex
406
- * @param currColIndex
407
- * @param splitCols
408
- */
409
- static getHMergeCols(tb, currRowIndex, currColIndex, splitCols) {
410
- const row = tb.getChild(currRowIndex);
411
- const items = [{ width: tb.getCellWidth(currColIndex), index: currColIndex }];
412
- for (let i = currColIndex + 1; i < tb.getColsCount(); i++) {
413
- const cell = row.getChild(i);
414
- if (cell.props.hMerge === 'continue') {
415
- items.push({ width: tb.getCellWidth(i), index: i });
416
- }
417
- else {
418
- break;
419
- }
420
- }
421
- return items;
422
- }
423
- /**
424
- * 获取纵向合并的行数
425
- * @param tb
426
- * @param currRowIndex
427
- */
428
- static getVMergeRowsCount(tb, rowIndex, colIndex) {
429
- const startCell = tb.getChild(rowIndex).getChild(colIndex);
430
- if (startCell.props.vMerge !== 'restart') {
431
- return 1;
432
- }
433
- let i = 0;
434
- for (i = rowIndex + 1; i < tb.length; i++) {
435
- const row = tb.getChild(i);
436
- const cell = row.getChild(colIndex);
437
- if (cell.props.vMerge !== 'continue') {
438
- return i - rowIndex;
439
- }
440
- }
441
- return i - rowIndex;
442
- }
443
- /**
444
- * 获取纵向合并的行数
445
- * @param tb
446
- * @param currRowIndex
447
- */
448
- static getHMergeColsCount(tb, rowIndex, colIndex) {
449
- const row = tb.getChild(rowIndex);
450
- const startCell = row.getChild(colIndex);
451
- if (startCell.props.hMerge !== 'restart') {
452
- return 1;
453
- }
454
- let i = 0;
455
- for (i = colIndex + 1; i < row.length; i++) {
456
- const cell = row.getChild(i);
457
- if (cell.props.hMerge !== 'continue') {
458
- return i - colIndex;
459
- }
460
- }
461
- return i - colIndex;
462
- }
463
- }
464
- //# sourceMappingURL=table-split-cell.js.map