@hailin-zheng/editor-core 1.0.3 → 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 (303) hide show
  1. package/package.json +6 -2
  2. package/dist/doc-ruler.d.ts +0 -51
  3. package/dist/doc-ruler.js +0 -313
  4. package/dist/doc-ruler.js.map +0 -1
  5. package/dist/framework/common-util.d.ts +0 -63
  6. package/dist/framework/common-util.js +0 -178
  7. package/dist/framework/common-util.js.map +0 -1
  8. package/dist/framework/document-change.d.ts +0 -265
  9. package/dist/framework/document-change.js +0 -1342
  10. package/dist/framework/document-change.js.map +0 -1
  11. package/dist/framework/document-combine.d.ts +0 -24
  12. package/dist/framework/document-combine.js +0 -40
  13. package/dist/framework/document-combine.js.map +0 -1
  14. package/dist/framework/document-comment.d.ts +0 -46
  15. package/dist/framework/document-comment.js +0 -148
  16. package/dist/framework/document-comment.js.map +0 -1
  17. package/dist/framework/document-context.d.ts +0 -149
  18. package/dist/framework/document-context.js +0 -330
  19. package/dist/framework/document-context.js.map +0 -1
  20. package/dist/framework/document-eval-func.d.ts +0 -18
  21. package/dist/framework/document-eval-func.js +0 -48
  22. package/dist/framework/document-eval-func.js.map +0 -1
  23. package/dist/framework/document-event.d.ts +0 -213
  24. package/dist/framework/document-event.js +0 -1054
  25. package/dist/framework/document-event.js.map +0 -1
  26. package/dist/framework/document-history.d.ts +0 -26
  27. package/dist/framework/document-history.js +0 -65
  28. package/dist/framework/document-history.js.map +0 -1
  29. package/dist/framework/document-images-loader.d.ts +0 -16
  30. package/dist/framework/document-images-loader.js +0 -66
  31. package/dist/framework/document-images-loader.js.map +0 -1
  32. package/dist/framework/document-input-cursor.d.ts +0 -78
  33. package/dist/framework/document-input-cursor.js +0 -239
  34. package/dist/framework/document-input-cursor.js.map +0 -1
  35. package/dist/framework/document-paint.d.ts +0 -34
  36. package/dist/framework/document-paint.js +0 -103
  37. package/dist/framework/document-paint.js.map +0 -1
  38. package/dist/framework/document-print-offscreen.d.ts +0 -38
  39. package/dist/framework/document-print-offscreen.js +0 -128
  40. package/dist/framework/document-print-offscreen.js.map +0 -1
  41. package/dist/framework/document-print.d.ts +0 -60
  42. package/dist/framework/document-print.js +0 -203
  43. package/dist/framework/document-print.js.map +0 -1
  44. package/dist/framework/document-segmenter.d.ts +0 -2
  45. package/dist/framework/document-segmenter.js +0 -106
  46. package/dist/framework/document-segmenter.js.map +0 -1
  47. package/dist/framework/document-selection.d.ts +0 -89
  48. package/dist/framework/document-selection.js +0 -358
  49. package/dist/framework/document-selection.js.map +0 -1
  50. package/dist/framework/document-template.d.ts +0 -4
  51. package/dist/framework/document-template.js +0 -20
  52. package/dist/framework/document-template.js.map +0 -1
  53. package/dist/framework/document-textline-mode.d.ts +0 -7
  54. package/dist/framework/document-textline-mode.js +0 -30
  55. package/dist/framework/document-textline-mode.js.map +0 -1
  56. package/dist/framework/element-define.d.ts +0 -319
  57. package/dist/framework/element-define.js +0 -579
  58. package/dist/framework/element-define.js.map +0 -1
  59. package/dist/framework/element-event-define.d.ts +0 -99
  60. package/dist/framework/element-event-define.js +0 -108
  61. package/dist/framework/element-event-define.js.map +0 -1
  62. package/dist/framework/element-measure.d.ts +0 -97
  63. package/dist/framework/element-measure.js +0 -551
  64. package/dist/framework/element-measure.js.map +0 -1
  65. package/dist/framework/element-paint.d.ts +0 -42
  66. package/dist/framework/element-paint.js +0 -170
  67. package/dist/framework/element-paint.js.map +0 -1
  68. package/dist/framework/element-props.d.ts +0 -301
  69. package/dist/framework/element-props.js +0 -809
  70. package/dist/framework/element-props.js.map +0 -1
  71. package/dist/framework/element-reader.d.ts +0 -19
  72. package/dist/framework/element-reader.js +0 -151
  73. package/dist/framework/element-reader.js.map +0 -1
  74. package/dist/framework/element-render-cut.d.ts +0 -55
  75. package/dist/framework/element-render-cut.js +0 -449
  76. package/dist/framework/element-render-cut.js.map +0 -1
  77. package/dist/framework/element-serialize.d.ts +0 -30
  78. package/dist/framework/element-serialize.js +0 -113
  79. package/dist/framework/element-serialize.js.map +0 -1
  80. package/dist/framework/element-util.d.ts +0 -369
  81. package/dist/framework/element-util.js +0 -1463
  82. package/dist/framework/element-util.js.map +0 -1
  83. package/dist/framework/impl/checkbox/checkbox-impl.d.ts +0 -24
  84. package/dist/framework/impl/checkbox/checkbox-impl.js +0 -64
  85. package/dist/framework/impl/checkbox/checkbox-impl.js.map +0 -1
  86. package/dist/framework/impl/comments/comment-content-impl.d.ts +0 -40
  87. package/dist/framework/impl/comments/comment-content-impl.js +0 -105
  88. package/dist/framework/impl/comments/comment-content-impl.js.map +0 -1
  89. package/dist/framework/impl/comments/comment-element-impl.d.ts +0 -21
  90. package/dist/framework/impl/comments/comment-element-impl.js +0 -62
  91. package/dist/framework/impl/comments/comment-element-impl.js.map +0 -1
  92. package/dist/framework/impl/comments/comments-container-impl.d.ts +0 -22
  93. package/dist/framework/impl/comments/comments-container-impl.js +0 -62
  94. package/dist/framework/impl/comments/comments-container-impl.js.map +0 -1
  95. package/dist/framework/impl/comments/comments-util.d.ts +0 -12
  96. package/dist/framework/impl/comments/comments-util.js +0 -67
  97. package/dist/framework/impl/comments/comments-util.js.map +0 -1
  98. package/dist/framework/impl/comments/validate-msg-impl.d.ts +0 -21
  99. package/dist/framework/impl/comments/validate-msg-impl.js +0 -83
  100. package/dist/framework/impl/comments/validate-msg-impl.js.map +0 -1
  101. package/dist/framework/impl/data-element/data-decorate-impl.d.ts +0 -30
  102. package/dist/framework/impl/data-element/data-decorate-impl.js +0 -91
  103. package/dist/framework/impl/data-element/data-decorate-impl.js.map +0 -1
  104. package/dist/framework/impl/data-element/data-element-barcode.d.ts +0 -31
  105. package/dist/framework/impl/data-element/data-element-barcode.js +0 -115
  106. package/dist/framework/impl/data-element/data-element-barcode.js.map +0 -1
  107. package/dist/framework/impl/data-element/data-element-base-impl.d.ts +0 -68
  108. package/dist/framework/impl/data-element/data-element-base-impl.js +0 -205
  109. package/dist/framework/impl/data-element/data-element-base-impl.js.map +0 -1
  110. package/dist/framework/impl/data-element/data-element-check-impl.d.ts +0 -35
  111. package/dist/framework/impl/data-element/data-element-check-impl.js +0 -133
  112. package/dist/framework/impl/data-element/data-element-check-impl.js.map +0 -1
  113. package/dist/framework/impl/data-element/data-element-date-impl.d.ts +0 -23
  114. package/dist/framework/impl/data-element/data-element-date-impl.js +0 -111
  115. package/dist/framework/impl/data-element/data-element-date-impl.js.map +0 -1
  116. package/dist/framework/impl/data-element/data-element-group-impl.d.ts +0 -23
  117. package/dist/framework/impl/data-element/data-element-group-impl.js +0 -130
  118. package/dist/framework/impl/data-element/data-element-group-impl.js.map +0 -1
  119. package/dist/framework/impl/data-element/data-element-image-impl.d.ts +0 -30
  120. package/dist/framework/impl/data-element/data-element-image-impl.js +0 -137
  121. package/dist/framework/impl/data-element/data-element-image-impl.js.map +0 -1
  122. package/dist/framework/impl/data-element/data-element-list-impl.d.ts +0 -22
  123. package/dist/framework/impl/data-element/data-element-list-impl.js +0 -131
  124. package/dist/framework/impl/data-element/data-element-list-impl.js.map +0 -1
  125. package/dist/framework/impl/data-element/data-element-text-impl.d.ts +0 -23
  126. package/dist/framework/impl/data-element/data-element-text-impl.js +0 -103
  127. package/dist/framework/impl/data-element/data-element-text-impl.js.map +0 -1
  128. package/dist/framework/impl/decorate/fill-null-space-imple.d.ts +0 -21
  129. package/dist/framework/impl/decorate/fill-null-space-imple.js +0 -43
  130. package/dist/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
  131. package/dist/framework/impl/document/doc-body-impl.d.ts +0 -27
  132. package/dist/framework/impl/document/doc-body-impl.js +0 -79
  133. package/dist/framework/impl/document/doc-body-impl.js.map +0 -1
  134. package/dist/framework/impl/document/doc-body-part-impl.d.ts +0 -30
  135. package/dist/framework/impl/document/doc-body-part-impl.js +0 -94
  136. package/dist/framework/impl/document/doc-body-part-impl.js.map +0 -1
  137. package/dist/framework/impl/document/doc-container-impl.d.ts +0 -16
  138. package/dist/framework/impl/document/doc-container-impl.js +0 -21
  139. package/dist/framework/impl/document/doc-container-impl.js.map +0 -1
  140. package/dist/framework/impl/document/doc-footer-impl.d.ts +0 -26
  141. package/dist/framework/impl/document/doc-footer-impl.js +0 -77
  142. package/dist/framework/impl/document/doc-footer-impl.js.map +0 -1
  143. package/dist/framework/impl/document/doc-header-impl.d.ts +0 -26
  144. package/dist/framework/impl/document/doc-header-impl.js +0 -83
  145. package/dist/framework/impl/document/doc-header-impl.js.map +0 -1
  146. package/dist/framework/impl/document/doc-impl.d.ts +0 -61
  147. package/dist/framework/impl/document/doc-impl.js +0 -209
  148. package/dist/framework/impl/document/doc-impl.js.map +0 -1
  149. package/dist/framework/impl/media-formula/menstrual-history.d.ts +0 -35
  150. package/dist/framework/impl/media-formula/menstrual-history.js +0 -153
  151. package/dist/framework/impl/media-formula/menstrual-history.js.map +0 -1
  152. package/dist/framework/impl/paragraph/p-impl.d.ts +0 -45
  153. package/dist/framework/impl/paragraph/p-impl.js +0 -156
  154. package/dist/framework/impl/paragraph/p-impl.js.map +0 -1
  155. package/dist/framework/impl/picture/image-impl.d.ts +0 -31
  156. package/dist/framework/impl/picture/image-impl.js +0 -124
  157. package/dist/framework/impl/picture/image-impl.js.map +0 -1
  158. package/dist/framework/impl/radio/radio-impl.d.ts +0 -22
  159. package/dist/framework/impl/radio/radio-impl.js +0 -72
  160. package/dist/framework/impl/radio/radio-impl.js.map +0 -1
  161. package/dist/framework/impl/symbol/br-symbol-impl.d.ts +0 -22
  162. package/dist/framework/impl/symbol/br-symbol-impl.js +0 -54
  163. package/dist/framework/impl/symbol/br-symbol-impl.js.map +0 -1
  164. package/dist/framework/impl/symbol/p-symbol-impl.d.ts +0 -19
  165. package/dist/framework/impl/symbol/p-symbol-impl.js +0 -54
  166. package/dist/framework/impl/symbol/p-symbol-impl.js.map +0 -1
  167. package/dist/framework/impl/table/table-cell-impl.d.ts +0 -37
  168. package/dist/framework/impl/table/table-cell-impl.js +0 -145
  169. package/dist/framework/impl/table/table-cell-impl.js.map +0 -1
  170. package/dist/framework/impl/table/table-impl.d.ts +0 -55
  171. package/dist/framework/impl/table/table-impl.js +0 -363
  172. package/dist/framework/impl/table/table-impl.js.map +0 -1
  173. package/dist/framework/impl/table/table-row-impl.d.ts +0 -26
  174. package/dist/framework/impl/table/table-row-impl.js +0 -75
  175. package/dist/framework/impl/table/table-row-impl.js.map +0 -1
  176. package/dist/framework/impl/table/table-split-cell-patch.d.ts +0 -20
  177. package/dist/framework/impl/table/table-split-cell-patch.js +0 -89
  178. package/dist/framework/impl/table/table-split-cell-patch.js.map +0 -1
  179. package/dist/framework/impl/table/table-split-cell.d.ts +0 -90
  180. package/dist/framework/impl/table/table-split-cell.js +0 -464
  181. package/dist/framework/impl/table/table-split-cell.js.map +0 -1
  182. package/dist/framework/impl/table/table-util.d.ts +0 -150
  183. package/dist/framework/impl/table/table-util.js +0 -678
  184. package/dist/framework/impl/table/table-util.js.map +0 -1
  185. package/dist/framework/impl/text/text-impl.d.ts +0 -32
  186. package/dist/framework/impl/text/text-impl.js +0 -149
  187. package/dist/framework/impl/text/text-impl.js.map +0 -1
  188. package/dist/framework/impl/text/track-run-impl.d.ts +0 -27
  189. package/dist/framework/impl/text/track-run-impl.js +0 -112
  190. package/dist/framework/impl/text/track-run-impl.js.map +0 -1
  191. package/dist/framework/notify.d.ts +0 -13
  192. package/dist/framework/notify.js +0 -116
  193. package/dist/framework/notify.js.map +0 -1
  194. package/dist/framework/range-util.d.ts +0 -40
  195. package/dist/framework/range-util.js +0 -312
  196. package/dist/framework/range-util.js.map +0 -1
  197. package/dist/framework/render-context.d.ts +0 -91
  198. package/dist/framework/render-context.js +0 -384
  199. package/dist/framework/render-context.js.map +0 -1
  200. package/dist/framework/render-define.d.ts +0 -109
  201. package/dist/framework/render-define.js +0 -195
  202. package/dist/framework/render-define.js.map +0 -1
  203. package/dist/framework/selection-overlays.d.ts +0 -30
  204. package/dist/framework/selection-overlays.js +0 -124
  205. package/dist/framework/selection-overlays.js.map +0 -1
  206. package/dist/texteditor.d.ts +0 -318
  207. package/dist/texteditor.js +0 -913
  208. package/dist/texteditor.js.map +0 -1
  209. package/dist/util/subject.d.ts +0 -34
  210. package/dist/util/subject.js +0 -88
  211. package/dist/util/subject.js.map +0 -1
  212. package/dist/util/table-bind.d.ts +0 -5
  213. package/dist/util/table-bind.js +0 -6
  214. package/dist/util/table-bind.js.map +0 -1
  215. package/src/med_editor/doc-ruler.ts +0 -340
  216. package/src/med_editor/framework/common-util.ts +0 -200
  217. package/src/med_editor/framework/document-change.ts +0 -1392
  218. package/src/med_editor/framework/document-combine.ts +0 -44
  219. package/src/med_editor/framework/document-comment.ts +0 -168
  220. package/src/med_editor/framework/document-context.ts +0 -410
  221. package/src/med_editor/framework/document-eval-func.ts +0 -53
  222. package/src/med_editor/framework/document-event.ts +0 -1082
  223. package/src/med_editor/framework/document-history.ts +0 -76
  224. package/src/med_editor/framework/document-images-loader.ts +0 -74
  225. package/src/med_editor/framework/document-input-cursor.ts +0 -244
  226. package/src/med_editor/framework/document-paint.ts +0 -110
  227. package/src/med_editor/framework/document-print-offscreen.ts +0 -134
  228. package/src/med_editor/framework/document-print.ts +0 -219
  229. package/src/med_editor/framework/document-segmenter.ts +0 -211
  230. package/src/med_editor/framework/document-selection.ts +0 -391
  231. package/src/med_editor/framework/document-template.ts +0 -20
  232. package/src/med_editor/framework/document-textline-mode.ts +0 -34
  233. package/src/med_editor/framework/element-define.ts +0 -674
  234. package/src/med_editor/framework/element-event-define.ts +0 -142
  235. package/src/med_editor/framework/element-measure.ts +0 -573
  236. package/src/med_editor/framework/element-paint.ts +0 -176
  237. package/src/med_editor/framework/element-props.ts +0 -938
  238. package/src/med_editor/framework/element-reader.ts +0 -159
  239. package/src/med_editor/framework/element-render-cut.ts +0 -456
  240. package/src/med_editor/framework/element-serialize.ts +0 -128
  241. package/src/med_editor/framework/element-util.ts +0 -1565
  242. package/src/med_editor/framework/impl/checkbox/checkbox-impl.ts +0 -71
  243. package/src/med_editor/framework/impl/comments/comment-content-impl.ts +0 -119
  244. package/src/med_editor/framework/impl/comments/comment-element-impl.ts +0 -65
  245. package/src/med_editor/framework/impl/comments/comments-container-impl.ts +0 -68
  246. package/src/med_editor/framework/impl/comments/comments-util.ts +0 -84
  247. package/src/med_editor/framework/impl/comments/validate-msg-impl.ts +0 -94
  248. package/src/med_editor/framework/impl/data-element/data-decorate-impl.ts +0 -95
  249. package/src/med_editor/framework/impl/data-element/data-element-barcode.ts +0 -127
  250. package/src/med_editor/framework/impl/data-element/data-element-base-impl.ts +0 -234
  251. package/src/med_editor/framework/impl/data-element/data-element-check-impl.ts +0 -146
  252. package/src/med_editor/framework/impl/data-element/data-element-date-impl.ts +0 -128
  253. package/src/med_editor/framework/impl/data-element/data-element-group-impl.ts +0 -150
  254. package/src/med_editor/framework/impl/data-element/data-element-image-impl.ts +0 -147
  255. package/src/med_editor/framework/impl/data-element/data-element-list-impl.ts +0 -142
  256. package/src/med_editor/framework/impl/data-element/data-element-text-impl.ts +0 -117
  257. package/src/med_editor/framework/impl/decorate/fill-null-space-imple.ts +0 -48
  258. package/src/med_editor/framework/impl/document/doc-body-impl.ts +0 -95
  259. package/src/med_editor/framework/impl/document/doc-body-part-impl.ts +0 -104
  260. package/src/med_editor/framework/impl/document/doc-container-impl.ts +0 -24
  261. package/src/med_editor/framework/impl/document/doc-footer-impl.ts +0 -88
  262. package/src/med_editor/framework/impl/document/doc-header-impl.ts +0 -100
  263. package/src/med_editor/framework/impl/document/doc-impl.ts +0 -226
  264. package/src/med_editor/framework/impl/media-formula/menstrual-history.ts +0 -175
  265. package/src/med_editor/framework/impl/paragraph/p-impl.ts +0 -190
  266. package/src/med_editor/framework/impl/picture/image-impl.ts +0 -136
  267. package/src/med_editor/framework/impl/radio/radio-impl.ts +0 -79
  268. package/src/med_editor/framework/impl/symbol/br-symbol-impl.ts +0 -60
  269. package/src/med_editor/framework/impl/symbol/p-symbol-impl.ts +0 -57
  270. package/src/med_editor/framework/impl/table/table-cell-impl.ts +0 -156
  271. package/src/med_editor/framework/impl/table/table-impl.ts +0 -401
  272. package/src/med_editor/framework/impl/table/table-row-impl.ts +0 -83
  273. package/src/med_editor/framework/impl/table/table-split-cell-patch.ts +0 -98
  274. package/src/med_editor/framework/impl/table/table-split-cell.ts +0 -475
  275. package/src/med_editor/framework/impl/table/table-util.ts +0 -716
  276. package/src/med_editor/framework/impl/text/text-impl.ts +0 -164
  277. package/src/med_editor/framework/impl/text/track-run-impl.ts +0 -135
  278. package/src/med_editor/framework/notify.ts +0 -130
  279. package/src/med_editor/framework/range-util.ts +0 -321
  280. package/src/med_editor/framework/render-context.ts +0 -431
  281. package/src/med_editor/framework/render-define.ts +0 -224
  282. package/src/med_editor/framework/selection-overlays.ts +0 -134
  283. package/src/med_editor/texteditor.ts +0 -1011
  284. package/src/med_editor/util/subject.ts +0 -118
  285. package/src/med_editor/util/table-bind.ts +0 -6
  286. package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +0 -3573
  287. 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
  288. 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
  289. 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
  290. 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
  291. 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
  292. package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +0 -2874
  293. package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +0 -341
  294. package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +0 -2201
  295. package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +0 -1069
  296. 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
  297. 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
  298. 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
  299. 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
  300. 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
  301. package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +0 -1070
  302. package/tsconfig.json +0 -25
  303. package/webpack.config.js +0 -46
@@ -1,57 +0,0 @@
1
- import { Element, LeafElement, SerializeProps } from "@/med_editor/framework/element-define";
2
- import { ElementUtil } from "@/med_editor/framework/element-util";
3
- import { RenderContenxtType } from "@/med_editor/framework/render-context";
4
- import { LeafRenderObject, RenderObject } from "@/med_editor/framework/render-define";
5
- import { TextProps } from "../../element-props";
6
- export class PSymbolElement extends LeafElement {
7
- textProps: TextProps;
8
- defaultHeight = 14;
9
- constructor() {
10
- super('psym');
11
- this.addEvent('GotCursor', evt => {
12
- const { selectionState: ss } = evt;
13
- //强制光标定位到段落符号之前
14
- //offset=1,段落回车时,导致合并的bug
15
- if (ss.collapsed) {
16
- if (ss.startControl === this && ss.startOffset === 1) {
17
- evt.isCancel = true;
18
- evt.selectionState.resetRange(this, 0);
19
- }
20
- }
21
- })
22
- this.textProps = new TextProps();
23
- this.textProps.fontSize = this.defaultHeight;
24
- this.textProps.fontName = '宋体';
25
- this.textProps.color = '#8c8c8c';
26
- }
27
- createRenderObject(): LeafRenderObject {
28
- const symbol = new PSymbolRenderObject(this);
29
- symbol.rect.height = this.defaultHeight;
30
- symbol.rect.width = 7;
31
- return symbol;
32
- }
33
- serialize(): SerializeProps | null {
34
- return null;
35
- }
36
- clone(): Element {
37
- const clone = new PSymbolElement();
38
- return clone;
39
- }
40
- }
41
-
42
- export class PSymbolRenderObject extends LeafRenderObject<PSymbolElement> {
43
- render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
44
- if (ctx.drawMode === 'print') {
45
- return;
46
- }
47
- ctx.contentContext.drawText('⤶', this.element.textProps, position.x, position.y, 20, this.rect.height);
48
- }
49
- //绘制段落符号
50
- clone(): RenderObject {
51
- const render = new PSymbolRenderObject(this.element);
52
- render.rect = ElementUtil.cloneRect(this.rect);
53
- return render;
54
- }
55
-
56
- }
57
-
@@ -1,156 +0,0 @@
1
- import { BlockContainerElement, Element, ElementFactory, PaddingProps, readElementProps, SerializeProps, ViewOptions } from "@/med_editor/framework/element-define";
2
- import { TableCellProps } from "@/med_editor/framework/element-props";
3
- import { ElementUtil } from "@/med_editor/framework/element-util";
4
- import { RenderContenxtType } from "@/med_editor/framework/render-context";
5
- import { InlineMuiltBlockLineRenderObject, RenderObject } from "@/med_editor/framework/render-define";
6
- import { TableElement } from "./table-impl";
7
-
8
- export class TableCellElement extends BlockContainerElement<TableCellProps> {
9
- //props: TableCellProps;
10
- constructor() {
11
- super('tbc');
12
- this.props = new TableCellProps();
13
- //this.addPropValueChangedSub(this.props);
14
- }
15
-
16
- beginMeasure(): void {
17
- super.beginMeasure();
18
- this.disableClick = !this.isNotBeMergedCell();
19
- }
20
-
21
- /**
22
- * 不被合并单元格的单元格
23
- * @returns
24
- */
25
- isNotBeMergedCell(): boolean {
26
- return this.props.hMerge !== 'continue' && this.props.vMerge !== 'continue';
27
- }
28
-
29
- createRenderObject(): RenderObject | null {
30
- if (!this.isNotBeMergedCell()) {
31
- return null;
32
- }
33
- const { cellWidth, cellOffset } = this.getCellWidth();
34
- const cellRender = new TableCellRenderObject(this);
35
- cellRender.rect.width = cellWidth;
36
- cellRender.rect.maxWidth = cellWidth;
37
- cellRender.padding = new PaddingProps(0, 0, 5, 5);
38
- cellRender.rect.x = cellOffset;
39
- return cellRender;
40
- }
41
- serialize(options: ViewOptions): SerializeProps {
42
- return {
43
- type: 'tbc',
44
- props: {
45
- ...this.props.getSerializeProps(options)
46
- }
47
- };
48
- }
49
- clone(data: boolean): Element {
50
- const clone = new TableCellElement();
51
- this.props.clone(clone.props);
52
- if (data) {
53
- for (let i = 0; i < this.length; i++) {
54
- clone.addChild(this.getChild(i).clone(true));
55
- }
56
- }
57
- return clone;
58
- }
59
- getCellWidth(): { cellWidth: number, cellOffset: number } {
60
- const row = this.parent;
61
- if (!row) {
62
- throw new Error('row is null');
63
- }
64
- const table = row.parent as TableElement;
65
- const cellIndex = row.getChildIndex(this);
66
- let cellWidth = table.getCellWidth(cellIndex);
67
- const cellOffset = table.getCellOffsetX(cellIndex);
68
- if (this.props.hMerge === 'restart') {
69
- for (let i = cellIndex + 1; i < table.getColsCount(); i++) {
70
- const nextCell = row.getChild(i) as TableCellElement;
71
- if (nextCell.props.hMerge === 'continue') {
72
- cellWidth += table.getCellWidth(i);
73
- } else {
74
- break;
75
- }
76
- }
77
- }
78
- return { cellWidth, cellOffset };
79
- }
80
-
81
- static createCell(): TableCellElement {
82
- const tc = new TableCellElement();
83
- return tc;
84
- }
85
-
86
- }
87
-
88
- export class TableCellRenderObject extends InlineMuiltBlockLineRenderObject {
89
- private prevGlobalAlpha = 1;
90
- beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
91
- ctx.contentContext.clip(position.x, position.y, this.rect.width, this.rect.height);
92
- const { hMerge, vMerge, backgroundColor, diagonal } = (<TableCellElement>this.element).props;
93
- if (hMerge === 'continue' || vMerge === 'continue') {
94
- this.prevGlobalAlpha = ctx.contentContext.getGlobalAlpha();
95
- ctx.contentContext.setGlobalAlpha(0);
96
- ctx.overlaysContext.setGlobalAlpha(0);
97
- }
98
- if (backgroundColor && this.rect.width && this.rect.height) {
99
- ctx.contentContext.fillRect(position.x, position.y, this.rect.width, this.rect.height, backgroundColor)
100
- }
101
- if (diagonal && this.rect.width && this.rect.height) {
102
- let diagonalStartX = diagonal === 'main' ? position.x : position.x + this.rect.width;
103
- let diagonalStartY = position.y;
104
- let diagonalEndX = diagonal === 'main' ? position.x + this.rect.width : position.x;
105
- let diagonalEndY = position.y + this.rect.height;
106
- ctx.contentContext.strokeLines([{ x: diagonalStartX, y: diagonalStartY }, { x: diagonalEndX, y: diagonalEndY }])
107
- }
108
- }
109
-
110
- endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
111
- ctx.contentContext.ctx.restore();
112
- if (!this.element.parent) {
113
- throw new Error('parent is null');
114
- }
115
- const tb = this.element.parent.parent as TableElement;
116
- const tbProps = tb.props;
117
- if (tbProps.border === 'all') {
118
- //ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, '#000', 1);
119
- //ctx.contentContext.roundRect(position.x, position.y, this.rect.width, this.rect.height, 5, false, true);
120
- }
121
- const { hMerge, vMerge } = (<TableCellElement>this.element).props;
122
- if (hMerge === 'continue' || vMerge === 'continue') {
123
- ctx.contentContext.setGlobalAlpha(1);
124
- ctx.overlaysContext.setGlobalAlpha(1);
125
- }
126
- }
127
-
128
- clone(): RenderObject {
129
- const cloneRender = new TableCellRenderObject(this.element);
130
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
131
- cloneRender.padding = this.padding?.clone();
132
- cloneRender.margin = this.margin?.clone();
133
- for (let i = 0; i < this.length; i++) {
134
- cloneRender.addChild(this.getChild(i).clone());
135
- }
136
- return cloneRender;
137
- }
138
- }
139
-
140
- export class TableCellFactory extends ElementFactory<TableCellProps> {
141
- match(type: string): boolean {
142
- return type === 'tbc';
143
- }
144
- createElement(data: readElementProps<TableCellProps>, renderCtx: RenderContenxtType): Element {
145
- const tc = new TableCellElement();
146
- const props = data.props;
147
- tc.props.vMerge = props?.vMerge ?? null;
148
- tc.props.hMerge = props?.hMerge ?? null;
149
- tc.props.vAlign = props?.vAlign ?? null;
150
- tc.props.backgroundColor = props?.backgroundColor ?? null;
151
- tc.props.diagonal = props?.diagonal ?? null;
152
- //tc.renderCtx = renderCtx;
153
- return tc;
154
- }
155
-
156
- }
@@ -1,401 +0,0 @@
1
- import {
2
- BlockContainerElement,
3
- Element,
4
- ElementFactory,
5
- Position,
6
- SerializeProps,
7
- ViewOptions
8
- } from "@/med_editor/framework/element-define";
9
- import { ContentMenuItem, ContextMenuElementEvent, KeyboradElementEvent } from "@/med_editor/framework/element-event-define";
10
- import { TableProps } from "@/med_editor/framework/element-props";
11
- import { ElementUtil } from "@/med_editor/framework/element-util";
12
- import { RenderContenxtType } from "@/med_editor/framework/render-context";
13
- import { MuiltBlockLineRenderObject, RenderObject } from "@/med_editor/framework/render-define";
14
- import { ParagraphElement, ParagraphRenderObject } from "../paragraph/p-impl";
15
- import { TableCellRenderObject } from "./table-cell-impl";
16
- import { TableRowElement, TableRowRenderObject } from "./table-row-impl";
17
- import { TableSplitCell } from "./table-split-cell";
18
- import { TableUtil } from "./table-util";
19
-
20
- /**
21
- * 计算表格列
22
- */
23
- function calcTableCols(element: TableElement): Array<{ width: number, offset: number }> {
24
- const percentCols: Array<{ width: string | number }> = [];
25
- let sum = 0;
26
- let percentSum = 0;
27
- for (const col of element.props.cols) {
28
- if (typeof col.width === 'string') {
29
- percentCols.push(col);
30
- percentSum += Number.parseFloat(col.width);
31
- } else {
32
- sum += col.width as number;
33
- }
34
- }
35
- const measureRender = element.measureRender as RenderObject;
36
- const tbWidth = measureRender.rect.maxWidth as number;
37
- if (percentCols.length > 0) {
38
- const remainWidth = tbWidth - sum;
39
- let remainSum = 0;
40
- for (const percentCol of percentCols) {
41
- const percentWidth = Number.parseFloat(percentCol.width.toString());
42
-
43
- percentCol.width = Math.floor(remainWidth * percentWidth / percentSum);
44
- remainSum += percentCol.width as number;
45
- }
46
- if (remainWidth - remainSum > 0) {
47
- const colWidth = percentCols[percentCols.length - 1].width as number;
48
- percentCols[percentCols.length - 1].width = colWidth + (remainWidth - remainSum);
49
- }
50
- }
51
- const array: Array<{ width: number, offset: number }> = [];
52
- let offset = 0;
53
- for (let i = 0; i < element.props.cols.length; i++) {
54
- const width = element.props.cols[i].width as number;
55
- array.push({ width, offset });
56
- offset += width;
57
- }
58
- return array;
59
- }
60
-
61
- export class TableElement extends BlockContainerElement<TableProps> {
62
- //props: TableProps;
63
- private _actualColsProps!: Array<{ width: number, offset: number }> | null;
64
- constructor() {
65
- super('tb');
66
- this.props = new TableProps();
67
- //this.addPropValueChangedSub(this.props);
68
- this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
69
- const { selectionState } = evt;
70
- if (TableUtil.canDeleteTable(selectionState)) {
71
- evt.menus.push({
72
- icon: 'DeleteTable', caption: '删除表格', eventObj: {
73
- onClick: (cevt) => {
74
- selectionState.clear();
75
- const prevEle = ElementUtil.getRecursionPrevSiblingElement(this, false, true);
76
- if (prevEle) {
77
- selectionState.resetRange(prevEle, -1);
78
- }
79
- this.remove();
80
- this.destroy();
81
- }
82
- }
83
- });
84
- }
85
- if (TableUtil.canMergeCells(selectionState)) {
86
- evt.menus.push({ icon: 'MergeDuplicate', caption: '合并单元格', eventObj: { onClick: (cevt) => { TableUtil.mergeCells(selectionState) } } });
87
- }
88
- if (TableUtil.canSplitCell(selectionState)) {
89
- evt.menus.push({ icon: 'Split', caption: '拆分单元格', eventObj: { onClick: (cevt) => { TableSplitCell.splitCell(selectionState, 0, 2) } } });
90
- evt.menus.push({ icon: 'Combine', caption: '合并单元格还原', eventObj: { onClick: (cevt) => { TableUtil.restoreCell(selectionState) } } });
91
-
92
- }
93
- evt.menus.push({ icon: "Insert", caption: '上方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex()); this.refreshView() } } });
94
- evt.menus.push({ icon: "Insert", caption: '下方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex() + 1); this.refreshView() } } });
95
-
96
-
97
- evt.menus = removeDuplicatesEvent(evt.menus);
98
- }, true);
99
- this.addEvent<KeyboradElementEvent>('ElementKeyDown', (evt) => {
100
- //console.log('表格ElementKeyDown', evt);
101
- const sourceEvent = evt.sourceEvent;
102
- //按下tab键
103
- if (sourceEvent.keyCode === 9 && !sourceEvent.shiftKey) {
104
- evt.isCancel = true;
105
- sourceEvent.preventDefault();
106
- TableUtil.moveNextCell(evt.selectionState);
107
- }
108
- }, true);
109
- }
110
- /**
111
- * 获取实际测量的宽度,将auto、百分比列宽度进行转化为 number 类型
112
- */
113
- get actualColsProps() {
114
- if (!this._actualColsProps) {
115
- this._actualColsProps = calcTableCols(this);
116
- }
117
- return this._actualColsProps;
118
- }
119
-
120
- getCellWidth(cellIndex: number): number {
121
- if (cellIndex >= this.actualColsProps.length || cellIndex < 0) {
122
- return -1;
123
- }
124
- return this.actualColsProps[cellIndex].width;
125
- }
126
-
127
- getCellOffsetX(cellIndex: number): number {
128
- return this.actualColsProps[cellIndex].offset;
129
- }
130
-
131
- setCellWidth(cellIndex: number, width: number): void {
132
- //this.actualColsProps[index].width = width;
133
- if (cellIndex >= this.actualColsProps.length || cellIndex < 0) {
134
- return;
135
- }
136
- this.props.cols[cellIndex].width = width;
137
- }
138
-
139
- /**
140
- * 插入列的定义
141
- * @param index
142
- * @param width
143
- */
144
- insertCol(index: number, width: number | string): void {
145
- this.props.cols.splice(index, 0, { width });
146
- this._actualColsProps = null;
147
- }
148
-
149
- /**
150
- * 移除列的定义
151
- * @param index
152
- */
153
- removeCol(index: number): void {
154
- this.props.cols.splice(index, 1);
155
- }
156
-
157
- getColsCount(): number {
158
- return this.actualColsProps.length;
159
- }
160
- clone(data: boolean): Element {
161
- const clone = new TableElement();
162
- this.props.clone(clone.props);
163
- if (data) {
164
- for (let i = 0; i < this.length; i++) {
165
- clone.addChild(this.getChild(i).clone(true));
166
- }
167
- }
168
- return clone;
169
- }
170
-
171
- createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject {
172
- return new TableRenderObject(this);
173
- }
174
-
175
- beginMeasure(): void {
176
- super.beginMeasure();
177
- this._actualColsProps = null;
178
- }
179
-
180
- serialize(options: ViewOptions): SerializeProps {
181
- //this.props.width = this.measureRender?.rect.width as number;
182
- const props = {
183
- type: 'tb',
184
- props: { ...this.props.getSerializeProps(options) }
185
- }
186
- props.props.width = this.measureRender?.rect.width as number;
187
- return props;
188
- }
189
-
190
- static createTable(rows: number, cols: number): TableElement {
191
- const table = new TableElement();
192
- const tbProps = new TableProps();
193
- table.props = tbProps;
194
- tbProps.border = 'all';
195
- tbProps.cols = [];
196
- for (let i = 0; i < cols; i++) {
197
- tbProps.cols.push({ width: "1" });
198
- }
199
- for (let i = 0; i < rows; i++) {
200
- table.addChild(TableRowElement.createRow(cols));
201
- }
202
- return table;
203
- }
204
- }
205
-
206
- function removeDuplicatesEvent(events: ContentMenuItem[]): ContentMenuItem[] {
207
- let arr: ContentMenuItem[] = [];
208
- for (let i = events.length - 1; i >= 0; i--) {
209
- let keys = arr.map(item => item.caption);
210
- if (!keys.includes(events[i].caption)) {
211
- arr.unshift(events[i]);
212
- }
213
- }
214
- return arr;
215
- }
216
-
217
- export class TableRenderObject extends MuiltBlockLineRenderObject<TableElement> {
218
- setRenderWidth(maxWidth: number): void {
219
- super.setRenderWidth(maxWidth);
220
- }
221
-
222
- beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
223
- //绘制表格线
224
- if (this.element.props.border !== 'all') {
225
- return;
226
- }
227
- for (let i = 0; i < this.length; i++) {
228
- const rowRender = this.getChild(i) as TableRowRenderObject;
229
- const rowPos: Position = { x: rowRender.rect.x + position.x, y: rowRender.rect.y + position.y };
230
- for (let j = 0; j < rowRender.length; j++) {
231
- const cellRender = rowRender.getChild(j) as TableCellRenderObject;
232
- const cellPos: Position = { x: cellRender.rect.x + rowPos.x, y: cellRender.rect.y + rowPos.y };
233
- //绘制单元格上边框
234
- if (i === 0) {
235
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, cellRender.rect.width, 1);
236
- ctx.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y }]);
237
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y });
238
- }
239
- //绘制左边框
240
- if (j === 0) {
241
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y, 1, cellRender.rect.height);
242
- ctx.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y }, { x: cellPos.x, y: cellPos.y + cellRender.rect.height }]);
243
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y }, { x: cellPos.x, y: cellPos.y + cellRender.rect.height });
244
- }
245
- //绘制右边框
246
- //ctx.contentContext.fillRect(cellPos.x + cellRender.rect.width, cellPos.y, 1, cellRender.rect.height);
247
- ctx.contentContext.fillLines([{ x: cellPos.x + cellRender.rect.width, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }]);
248
- //this.drawLine(ctx, { x: cellPos.x + cellRender.rect.width, y: cellPos.y }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
249
- //绘制下边框
250
- //ctx.contentContext.fillRect(cellPos.x, cellPos.y + cellRender.rect.height, cellRender.rect.width, 1);
251
- ctx.contentContext.fillLines([{ x: cellPos.x, y: cellPos.y + cellRender.rect.height }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height }]);
252
- //this.drawLine(ctx, { x: cellPos.x, y: cellPos.y + cellRender.rect.height }, { x: cellPos.x + cellRender.rect.width, y: cellPos.y + cellRender.rect.height });
253
- //cellRender.beginRender(ctx, { x: position.x + cellRender.offsetX, y: position.y + cellRender.offsetY });
254
- }
255
- }
256
- }
257
-
258
- endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
259
- }
260
- clone(): RenderObject {
261
- const cloneRender = new TableRenderObject(this.element);
262
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
263
- for (let i = 0; i < this.length; i++) {
264
- cloneRender.addChild(this.getChild(i).clone());
265
- }
266
- return cloneRender;
267
- }
268
- }
269
-
270
-
271
- export class TableFactory extends ElementFactory<TableProps> {
272
- match(type: string): boolean {
273
- return type === 'tb';
274
- }
275
- createElement(data: any, renderCtx: RenderContenxtType): Element {
276
- const props = data.props as TableProps;
277
- const tb = new TableElement();
278
- const cols = props.cols;
279
- const tbProps = tb.props;
280
- tbProps.border = props.border || 'all';
281
- tbProps.cols = [];
282
- for (const col of cols) {
283
- tbProps.cols.push({
284
- width: col.width
285
- });
286
- }
287
- tb.props = tbProps;
288
- return tb;
289
- }
290
-
291
- }
292
-
293
- /**
294
- * 行-表格渲染模式
295
- */
296
- export function textLineRenderMode(ele: TableElement, options: ViewOptions, renderCtx: RenderContenxtType): boolean {
297
- const tb = ele.measureRender as TableRenderObject;
298
- const rows: Array<TableRowRenderObject> = []
299
- for (let i = 0; i < tb.length; i++) {
300
- const row = tb.getChild(i) as TableRowRenderObject;
301
- //表格头不做处理
302
- if ((<TableRowElement>row.element).props.headerRow) {
303
- continue;
304
- }
305
- rows.push(row);
306
- }
307
- for (let i = 0; i < rows.length; i++) {
308
- const row = rows[i];
309
- //获取当前行的文字行数
310
- const maxLinesCount = getRowMaxTextLines(row);
311
- if (maxLinesCount > 1) {
312
- for (let j = 1; j < maxLinesCount; j++) {
313
- const newRow = row.element.createRenderObject() as TableRowRenderObject;
314
- newRow.rect = ElementUtil.cloneRect(row.rect);
315
- tb.insertChild(newRow, row.getIndex() + 1);
316
- //复制行文字到新行中
317
- for (let k = 0; k < row.length; k++) {
318
- const cell = row.getChild(k) as TableCellRenderObject;
319
- const newCell = cell.element.createRenderObject(options, renderCtx) as TableCellRenderObject
320
- newCell.rect = ElementUtil.cloneRect(cell.rect);
321
- if (newCell) {
322
- newRow.addChild(newCell)
323
- }
324
- }
325
- }
326
- }
327
- splitTextlineToNewRow(row, maxLinesCount, options, renderCtx);
328
- }
329
- ElementUtil.remeasure(tb);
330
- return true;
331
- }
332
-
333
- /**
334
- * 获取当前行的文字行数
335
- * @param row
336
- * @returns
337
- */
338
- function getRowMaxTextLines(row: TableRowRenderObject): number {
339
- let count = 0;
340
- for (let j = 0; j < row.length; j++) {
341
- const cell = row.getChild(j) as TableCellRenderObject;
342
- let cellMaxLines = 0;
343
- for (let k = 0; k < cell.length; k++) {
344
- const paraRender = cell.getChild(k) as ParagraphRenderObject;
345
- cellMaxLines += paraRender.length;
346
- }
347
- count = cellMaxLines > count ? cellMaxLines : count;
348
- }
349
- return count;
350
- }
351
-
352
- /**
353
- * 将多行文本移动到新行中
354
- * @param row
355
- * @param maxLinesCount
356
- * @returns
357
- */
358
- function splitTextlineToNewRow(row: TableRowRenderObject, maxLinesCount: number, options: ViewOptions, renderCtx: RenderContenxtType): void {
359
- if (maxLinesCount === 1) {
360
- return;
361
- }
362
- for (let i = 0; i < row.length; i++) {
363
- const cell = row.getChild(i) as TableCellRenderObject;
364
- const paraLines = ElementUtil.getCellParaLines(cell);
365
- if (paraLines.length === 1) {
366
- continue;
367
- }
368
- for (let j = 1; j < paraLines.length; j++) {
369
- const outterLineRect = paraLines[j];
370
- const paraRender = outterLineRect.parent as ParagraphRenderObject;
371
-
372
- const newParaRender = paraRender.element.createRenderObject(options, renderCtx) as ParagraphRenderObject;
373
- newParaRender.rect = ElementUtil.cloneRect(paraRender.rect);
374
-
375
- const newOutterLineRect = outterLineRect.clone();
376
- newOutterLineRect.rect = ElementUtil.cloneRect(outterLineRect.rect);
377
- newParaRender.addChild(newOutterLineRect);
378
-
379
- paraRender.removeChild(outterLineRect);
380
- ElementUtil.remeasure(paraRender);
381
-
382
- if (paraRender.length === 0) {
383
- cell.removeChild(paraRender);
384
- }
385
- const splitRow = row.parent.getChild(row.getIndex() + j) as TableRowRenderObject;
386
- const splitCell = splitRow.getChild(i) as TableCellRenderObject;
387
- splitCell.addChild(newParaRender);
388
- ElementUtil.remeasure(newParaRender);
389
- }
390
- }
391
- const tb = row.parent as TableRenderObject;
392
- const rowIndex = row.getIndex();
393
- for (let i = 0; i < maxLinesCount; i++) {
394
- const row = tb.getChild(rowIndex + i) as TableRowRenderObject;
395
- for (let j = 0; j < row.length; j++) {
396
- const cell = row.getChild(j) as TableCellRenderObject;
397
- ElementUtil.remeasure(cell);
398
- }
399
- ElementUtil.remeasure(row);
400
- }
401
- }
@@ -1,83 +0,0 @@
1
- import { BlockContainerElement, Element, ElementFactory, ModifyFlag, readElementProps, SerializeProps, ViewOptions } from "@/med_editor/framework/element-define";
2
- import { TableRowProps } from "@/med_editor/framework/element-props";
3
- import { ElementUtil } from "@/med_editor/framework/element-util";
4
- import { RenderContenxtType } from "@/med_editor/framework/render-context";
5
- import { MuiltBlockLineRenderObject, RenderObject } from "@/med_editor/framework/render-define";
6
- import { TableCellElement } from "./table-cell-impl";
7
-
8
- export class TableRowElement extends BlockContainerElement<TableRowProps> {
9
- //props: TableRowProps;
10
- constructor() {
11
- super('tr');
12
- this.props = new TableRowProps();
13
- //在差异更新中,由于行内单元格存在合并行的情况,需要将当前行内存在合并的单元格,将其修改标志改为修改
14
- const changeSub = this.onChangeSubject.subscribe(() => {
15
- if (this.modifyFlag === ModifyFlag.Track) {
16
- //this.checkRowModifyState();
17
- this.pubOnChange('to-child');
18
- }
19
- });
20
- this.addsubscribe(this, changeSub);
21
- }
22
-
23
- createRenderObject(): RenderObject {
24
- return new TableRowRenderObject(this);
25
- }
26
-
27
- serialize(viewOptions: ViewOptions): SerializeProps {
28
- return {
29
- type: 'tr',
30
- props: {
31
- ...this.props?.getSerializeProps(viewOptions)
32
- }
33
- };
34
- }
35
- clone(data: boolean): Element {
36
- const clone = new TableRowElement();
37
- this.props.clone(clone.props);
38
- if (data) {
39
- for (let i = 0; i < this.length; i++) {
40
- clone.addChild(this.getChild(i).clone(true));
41
- }
42
- }
43
- return clone;
44
- }
45
-
46
- static createRow(cols: number): TableRowElement {
47
- const tr = new TableRowElement();
48
- for (let i = 0; i < cols; i++) {
49
- tr.addChild(TableCellElement.createCell());
50
- }
51
- return tr;
52
- }
53
- }
54
-
55
- export class TableRowRenderObject extends MuiltBlockLineRenderObject<TableRowElement> {
56
- beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
57
- }
58
- endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
59
- }
60
-
61
- clone(): RenderObject {
62
- const cloneRender = new TableRowRenderObject(this.element);
63
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
64
- for (let i = 0; i < this.length; i++) {
65
- cloneRender.addChild(this.getChild(i).clone());
66
- }
67
- return cloneRender;
68
- }
69
- }
70
-
71
- export class TableRowFactory extends ElementFactory<TableRowProps> {
72
- match(type: string): boolean {
73
- return type === 'tr';
74
- }
75
- createElement(data: readElementProps<TableRowProps>, renderCtx: RenderContenxtType): Element {
76
- const props = data.props as TableRowProps;
77
- const tr = new TableRowElement();
78
- tr.props.minHeight = props?.minHeight ?? -1;
79
- tr.props.headerRow = props?.headerRow;
80
- return tr;
81
- }
82
-
83
- }