@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,391 +0,0 @@
1
- import { Subject } from "rxjs";
2
- import { BranchElement, LeafElement, Rect, Element, SelectionContentRange, Position } from "./element-define";
3
- import { HitEventInfo, HitRegion } from "./element-event-define";
4
- import { ElementUtil } from "./element-util";
5
- import { DocumentContainerRender } from "./impl/document/doc-container-impl";
6
- import { DocumentRenderObject } from "./impl/document/doc-impl";
7
- import { TextGroupElement, TextGroupRenderObject } from "./impl/text/text-impl";
8
- import { RenderObject } from "./render-define";
9
- import { DocumentBodyElement } from "@/med_editor/framework/impl/document/doc-body-impl";
10
- import { DataElementInlineGroup } from "./impl/data-element/data-element-base-impl";
11
- import { DataDecorateElement } from "./impl/data-element/data-decorate-impl";
12
-
13
- export class DocumentSelection {
14
- constructor() {
15
- this.selectionState = new SelectionState();
16
- }
17
-
18
- selectionState: SelectionState;
19
- snapshotSelectionState!: SelectionState | null;
20
- setSelectionState(hitInfo: { startHitInfo: HitEventInfo, endHitInfo: HitEventInfo }): void {
21
- const { startHitInfo, endHitInfo } = hitInfo;
22
- this.selectionState.clear();
23
- this.selectionState.startHitInfo = startHitInfo;
24
- if (!startHitInfo) {
25
- return;
26
- }
27
- const startRange = new SelectionRange();
28
- startRange.setStart(startHitInfo.element, startHitInfo.offset);
29
- if (endHitInfo) {
30
- startRange.setEnd(endHitInfo.element, endHitInfo.offset);
31
- } else {
32
- startRange.setEnd(startHitInfo.element, startHitInfo.offset);
33
- }
34
- this.selectionState.addRange(startRange);
35
- }
36
-
37
- /**
38
- * 获取选区共同的祖先控件
39
- */
40
- static getAncestorCommonControl(startControl: LeafElement, endControl: LeafElement): BranchElement {
41
- const startNestParents = this.getNestParents(startControl.parent);
42
- const ancestorCommonControl = this.getCommonParenet(endControl.parent, startNestParents);
43
- if (!ancestorCommonControl) {
44
- throw new Error('未找到公共的祖先组件');
45
- }
46
- return ancestorCommonControl;
47
- }
48
-
49
- /**
50
- * 获取向上的嵌套父级节点集合
51
- * @param control
52
- * @param array
53
- */
54
- static getNestParents(control: BranchElement | null): Array<BranchElement> {
55
- if (control) {
56
- return [control, ...this.getNestParents(control.parent)];
57
- }
58
- return [];
59
-
60
- }
61
-
62
- static getCommonParenet(control: BranchElement | null, array: Array<BranchElement>): BranchElement | null {
63
- if (!control) {
64
- return null;
65
- }
66
- if (array.some(item => item === control)) {
67
- return control;
68
- }
69
- return this.getCommonParenet(control?.parent, array);
70
- }
71
-
72
- updateSelectionState(): boolean {
73
- if (this.compareSelectionEquals()) {
74
- return false;
75
- }
76
- const range = this.selectionState.range;
77
- this.transformRange();
78
- if (!range) {
79
- return false;
80
- }
81
- const startControlIndex = ElementUtil.getControlIndex(range.startControl);
82
- const endControlIndex = ElementUtil.getControlIndex(range.endControl);
83
- if (endControlIndex < startControlIndex) {
84
- const clone = range.clone();
85
- clone.startControl = range.endControl;
86
- clone.startOffset = range.endOffset;
87
- clone.endControl = range.startControl;
88
- clone.endOffset = range.startOffset;
89
- clone.editable = range.editable;
90
- this.selectionState.addRange(clone);
91
- }
92
- this.selectionState.editable = range.editable;
93
-
94
- this.selectionState.startControl = range.startControl as LeafElement;
95
- this.selectionState.startOffset = range.startOffset;
96
- this.selectionState.startControlIndex = ElementUtil.getControlIndex(range.startControl);
97
-
98
- this.selectionState.endControl = range.endControl as LeafElement;
99
- this.selectionState.endOffset = range.endOffset;
100
- this.selectionState.endControlIndex = ElementUtil.getControlIndex(range.endControl);
101
-
102
- this.selectionState.ancestorCommonControl = DocumentSelection.getAncestorCommonControl(this.selectionState.startControl, this.selectionState.endControl);
103
-
104
- this.selectionState.enableTrackChanges = this.getEnableTrackChanges(range.startControl);
105
- return true;
106
- }
107
-
108
- /**
109
- * 获取当前选区区域内是否支持留痕
110
- * @private
111
- */
112
- private getEnableTrackChanges(ele: Element): boolean {
113
- const body = ElementUtil.getParentByType(ele, DocumentBodyElement);
114
- return body?.trackChanges || false;
115
- }
116
-
117
- private compareSelectionEquals(): boolean {
118
- const range = this.selectionState.range;
119
- const snap = this.snapshotSelectionState;
120
- if (snap && range) {
121
- return range.startControl === snap.startControl
122
- && range.startOffset === snap.startOffset
123
- && range.endControl === snap.endControl
124
- && range.endOffset === snap.endOffset;
125
- }
126
- return false;
127
- }
128
-
129
- /**
130
- * 转换选区内容
131
- * 处理结束选区在开始选区之前
132
- */
133
- private transformRange(): void {
134
- let range = this.selectionState.range;
135
- if (!range) {
136
- return;
137
- }
138
- const { startControl, startOffset, endControl, endOffset } = range;
139
- const startControlIndex = ElementUtil.getControlIndex(startControl);
140
- const endControlIndex = ElementUtil.getControlIndex(endControl);
141
- if ((endControlIndex < startControlIndex)) {
142
- const clone = range.clone();
143
- clone.startControl = endControl;
144
- clone.startOffset = endOffset;
145
- clone.endControl = startControl;
146
- clone.endOffset = startOffset;
147
- this.selectionState.addRange(clone);
148
- }
149
- range = this.selectionState.range;
150
- if (!range) {
151
- throw new Error('range is null')
152
- }
153
- range.calcRange();
154
- if ((range.startControl === range.endControl && range.startOffset > range.endOffset)) {
155
- const { startOffset, endOffset } = range;
156
- range.startOffset = endOffset;
157
- range.endOffset = startOffset;
158
- }
159
- range.calcRange();
160
- }
161
-
162
- takeSnapshot(): void {
163
- this.snapshotSelectionState = this.selectionState.clone();
164
- }
165
-
166
- clearSnapshot(): void {
167
- this.snapshotSelectionState = null;
168
- }
169
-
170
- }
171
-
172
- export class SelectionState {
173
- get startControl(): LeafElement {
174
- return this._startControl as LeafElement;
175
- }
176
-
177
- set startControl(value: LeafElement | null) {
178
- this._startControl = value;
179
- }
180
-
181
- get endControl(): LeafElement {
182
- return this._endControl as LeafElement;
183
- }
184
-
185
- set endControl(value: LeafElement | null) {
186
- this._endControl = value;
187
- }
188
- onChangedEvent: Subject<void> = new Subject();
189
- startControlIndex!: number;
190
- startOffset!: number;
191
- endControlIndex!: number;
192
- endOffset!: number;
193
- get collapsed() {
194
- const { startControlIndex, startOffset, endControlIndex, endOffset } = this;
195
- return !(startControlIndex !== endControlIndex || (startControlIndex === endControlIndex && startOffset !== endOffset));
196
- }
197
- private _startControl!: LeafElement | null;
198
- private _endControl!: LeafElement | null;
199
- ancestorCommonControl!: BranchElement | null;
200
- range!: SelectionRange | null;
201
- startHitInfo!: HitEventInfo | null;
202
- selectedRange!: SelectionContentRange | null;
203
- editable: boolean = true;
204
- renderContainer!: DocumentContainerRender;
205
- cursorPos!: Rect | null;
206
- //选区重新计算,触发函数
207
- afterSelectionChanged: ((newVal: SelectionState) => boolean) | null = null;
208
- //当前选区的上下文是否支持留痕修改
209
- enableTrackChanges: boolean = false;
210
- constructor() {
211
- this.clear();
212
- }
213
- clear(): void {
214
- this.range = null;
215
- this.startOffset = -1;
216
- this.endOffset = -1;
217
- this._startControl = null;
218
- this._endControl = null;
219
- this.ancestorCommonControl = null;
220
- this.startControlIndex = -1;
221
- this.endControlIndex = -1;
222
- this.selectedRange = null;
223
- this.cursorPos = null;
224
- }
225
-
226
- addRange(range: SelectionRange): void {
227
- this.clear();
228
- this.range = range;
229
- this.onChangedEvent.next();
230
- }
231
- resetRange(startControl: Element, startOffset: number): SelectionRange {
232
- const range = new SelectionRange();
233
- range.setStart(startControl, startOffset);
234
- range.setEnd(startControl, startOffset);
235
- this.addRange(range);
236
- return range;
237
- }
238
-
239
- surround(ele: Element): void {
240
- const range = new SelectionRange();
241
- range.setStart(ele, 0);
242
- range.setEnd(ele, -1);
243
- this.addRange(range);
244
- }
245
-
246
- clone(): SelectionState {
247
- const clone = new SelectionState();
248
- clone._startControl = this._startControl;
249
- clone.startOffset = this.startOffset;
250
- clone._endControl = this._endControl;
251
- clone.endOffset = this.endOffset;
252
- clone.ancestorCommonControl = this.ancestorCommonControl;
253
- clone.startControlIndex = this.startControlIndex;
254
- clone.endControlIndex = this.endControlIndex;
255
- clone.selectedRange = this.selectedRange;
256
- return clone;
257
- }
258
-
259
-
260
- }
261
-
262
-
263
-
264
- export class SelectionRange {
265
- startControl!: Element;
266
- startOffset!: number;
267
- endControl!: Element;
268
- endOffset!: number;
269
- editable: boolean = true;
270
- setStart(control: Element, offset: number): void {
271
- this.startControl = control;
272
- this.startOffset = offset;
273
- }
274
- setEnd(control: Element, offset: number): void {
275
- this.endControl = control;
276
- this.endOffset = offset;
277
- }
278
-
279
- private calcStart(): void {
280
- const res = this.setInfo(this.startControl, this.startOffset);
281
- this.setStart(res.control, res.offset);
282
- }
283
-
284
- private calcEnd(): void {
285
- const res = this.setInfo(this.endControl, this.endOffset);
286
- this.setEnd(res.control, res.offset);
287
- }
288
-
289
- calcRange(): void {
290
- this.calcStart();
291
- this.calcEnd();
292
- }
293
-
294
- private setInfo(control: Element, offset: number): { control: LeafElement, offset: number } {
295
- if (control instanceof LeafElement) {
296
- if (control instanceof TextGroupElement) {
297
- offset = offset === -1 ? control.text.length : offset;
298
- }
299
- offset = offset === -1 ? 1 : offset;
300
- return { control, offset };
301
- } else if (control instanceof BranchElement) {
302
- if (offset > control.length) {
303
- throw new Error('超索引');
304
- }
305
- if (offset === control.length) {
306
- const child = control.getChild(offset - 1);
307
- return this.setInfo(child, 1);
308
- } else if (offset === -1) {
309
- const child = control.getChild(control.length - 1);
310
- return this.setInfo(child, -1);
311
- } else {
312
- const child = control.getChild(offset);
313
- return this.setInfo(child, 0);
314
- }
315
- } else {
316
- throw new Error('未实现');
317
- }
318
- }
319
-
320
- clone(): SelectionRange {
321
- const clone = new SelectionRange();
322
- clone.startControl = this.startControl;
323
- clone.startOffset = this.startOffset;
324
- clone.endControl = this.endControl;
325
- clone.endOffset = this.endOffset;
326
- return clone;
327
- }
328
-
329
- }
330
-
331
- export class DocumentCursor {
332
- static getElementCursorPos(ele: LeafElement, offset: number, hitRegion: HitRegion | undefined, docNum: number): { render: RenderObject, rect: Rect } {
333
- if (hitRegion === 'body' || hitRegion === 'review') {
334
- return this.getElementRenderPos(ele, offset, ele.paintRenders);
335
- } else if (hitRegion === 'footer' || hitRegion === 'header') {
336
- const docContainer = ElementUtil.getParentRender(ele.paintRenders[0], DocumentContainerRender);
337
- if (!docContainer) {
338
- throw new Error('docContainer is null')
339
- }
340
- const docRender = docContainer.getChild(docNum) as DocumentRenderObject;
341
- const currDocPaintRenders = ele.paintRenders.filter(item => ElementUtil.getParentRender(item, DocumentRenderObject) === docRender);
342
- return this.getElementRenderPos(ele, offset, currDocPaintRenders);
343
- }
344
- debugger;
345
- throw new Error('未找到元素偏移量对应的光标位置')
346
- }
347
-
348
- private static getElementRenderPos(ele: LeafElement, offset: number, paints: Array<RenderObject>): { render: RenderObject, rect: Rect } {
349
- if (ele instanceof TextGroupElement) {
350
- let count = 0;
351
- for (let i = 0; i < paints.length; i++) {
352
- const paintRender = paints[i] as TextGroupRenderObject;
353
- let horX = 0;
354
- if (paintRender.textMeasures.length + count < offset) {
355
- count += paintRender.textMeasures.length;
356
- continue;
357
- }
358
- for (let i = 0; i <= paintRender.textMeasures.length; i++) {
359
- if (count === offset || (i === 0 && count + 0.5 === offset)) {
360
- const rect = ElementUtil.getRenderAbsolutePaintRect(paintRender, { x: 0, y: 0 })
361
- //上标、下标位置处理
362
- if (['superscript', 'subscript'].indexOf(ele.props.vertAlign) >= 0) {
363
- rect.height -= ele.props.fontSize / 2;
364
- if (ele.props.vertAlign === 'subscript') {
365
- rect.y += rect.height;
366
- }
367
- }
368
- rect.x += horX;
369
- return {
370
- render: paintRender,
371
- rect
372
- }
373
- }
374
- count++;
375
- horX += paintRender.textMeasures[i].actualSize;
376
- }
377
- }
378
- } else {
379
- const paintRender = paints[0];
380
- const rect = ElementUtil.getRenderAbsolutePaintRect(paintRender, { x: 0, y: 0 })
381
- if (offset === 1) {
382
- rect.x += rect.width;
383
- }
384
- return {
385
- render: paintRender,
386
- rect
387
- }
388
- }
389
- throw new Error('未能定位到元素位置')
390
- }
391
- }
@@ -1,20 +0,0 @@
1
- import { PaddingProps } from "./element-define";
2
- import { DocumentProps } from "./element-props";
3
- import { DocumentBodyElement } from "./impl/document/doc-body-impl";
4
- import { DocumentFooterElement } from "./impl/document/doc-footer-impl";
5
- import { DocumentHeaderElement } from "./impl/document/doc-header-impl";
6
- import { DocumentElement } from "./impl/document/doc-impl";
7
-
8
- export class DocumentTemplate {
9
- static createA4Doc(): DocumentElement {
10
- const doc = new DocumentElement();
11
- doc.props = new DocumentProps();
12
- doc.props.width = 210;
13
- doc.props.height = 297;
14
- doc.props.padding = new PaddingProps(25.4, 25.4, 19.1, 19.1);
15
- doc.addChild(new DocumentHeaderElement());
16
- doc.addChild(new DocumentBodyElement());
17
- doc.addChild(new DocumentFooterElement());
18
- return doc;
19
- }
20
- }
@@ -1,34 +0,0 @@
1
- import { BranchElement, ViewOptions, Element } from "./element-define";
2
- import { ElementUtil } from "./element-util";
3
- import { TableElement, textLineRenderMode } from "./impl/table/table-impl";
4
- import { RenderContenxtType } from "./render-context";
5
- import { BlockContainerRenderObject, RenderObject } from "./render-define";
6
-
7
- /**
8
- * 文字行渲染模式
9
- 用于医嘱打印模式
10
- */
11
- export function runTextLineRender(ele: Element, options: ViewOptions, renderCtx: RenderContenxtType): void {
12
- if (!options.textRowLineMode) {
13
- return;
14
- }
15
- if (ele instanceof TableElement) {
16
- textLineRenderMode(ele, options, renderCtx);
17
- remeasureParentRenders(ele.measureRender)
18
- return;
19
- }
20
- if (ele instanceof BranchElement) {
21
- for (let i = 0; i < ele.length; i++) {
22
- runTextLineRender(ele.getChild(i), options, renderCtx);
23
- }
24
- }
25
- }
26
-
27
- function remeasureParentRenders(render: RenderObject | null): void {
28
- if (!render) {
29
- return
30
- }
31
- ElementUtil.remeasure(render as BlockContainerRenderObject)
32
- remeasureParentRenders(render.parent)
33
-
34
- }