@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,164 +0,0 @@
1
- import { CommonUtil } from "@/med_editor/framework/common-util";
2
- import { SelectionRange } from "@/med_editor/framework/document-selection";
3
- import { ContextMenuElementEvent } from "@/med_editor/framework/element-event-define";
4
- import { TextProps } from "@/med_editor/framework/element-props";
5
- import { ElementUtil } from "@/med_editor/framework/element-util";
6
- import { LeafRenderObject, RenderObject } from "@/med_editor/framework/render-define";
7
- import { LeafElement, ElementFactory, Element, SerializeProps, ViewOptions, ModifyFlag } from "../../element-define";
8
- import { watchChanged } from "../../notify";
9
- import { RenderContenxtType, TextUnits } from "../../render-context";
10
-
11
- export class TextGroupElement extends LeafElement<TextProps> {
12
- //props: TextProps;
13
- textMeasures: Array<TextUnits> = [];
14
- isMeasure: boolean = false;
15
- constructor() {
16
- super('text');
17
- this.props = new TextProps();
18
- watchChanged(this.props, () => {
19
- this.isMeasure = false;
20
- this.props.clearCache();
21
- });
22
- //this.addPropValueChangedSub(this.props);
23
- //this.addsubscribe(this, this.props.onPropertyChangedSubject.subscribe(() => { this.clearTextCache() }));
24
- this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
25
- const ss = evt.selectionState;
26
- evt.menus.push({
27
- icon: "EditStyle", caption: "选中样式组合", eventObj: {
28
- onClick: (cevt) => {
29
- const range = new SelectionRange();
30
- range.setStart(this, 0);
31
- range.setEnd(this, -1);
32
- ss.addRange(range);
33
- }
34
- }
35
- })
36
- });
37
- }
38
- set text(val: string) {
39
- this.splice(0, this.textMeasures.length, val);
40
- }
41
-
42
- splice(index: number, deleteCount: number, addText: string | null = null): void {
43
- this.isMeasure = false;
44
- addText = addText ?? '';
45
- const addTextUnits = addText.split('').map(char => ({ sourceSize: 0, actualSize: 0, char }));
46
- if (this.textMeasures.length === 0) {
47
- this.textMeasures = addTextUnits;
48
- } else {
49
- this.textMeasures.splice(index, deleteCount, ...addTextUnits);
50
- }
51
- this.pubOnChange('self');
52
- }
53
-
54
- get text() {
55
- return this.textMeasures.map(item => item.char).join('');
56
- }
57
-
58
- createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject {
59
- if (!this.isMeasure || this.modifyFlag !== ModifyFlag.None) {
60
- renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
61
- this.isMeasure = true;
62
- }
63
- const render = new TextGroupRenderObject(this);
64
- render.disableClick = this.disableClick;
65
- render.textMeasures = [...this.textMeasures];
66
- render.measure();
67
- return render;
68
- }
69
-
70
- serialize(viewOptions: ViewOptions): SerializeProps & any {
71
- //修饰元素不序列化
72
- if (this.isDecorate) {
73
- return null;
74
- }
75
- return {
76
- type: 'text',
77
- props: {
78
- ...this.props.getSerializeProps(viewOptions)
79
- },
80
- content: this.text,
81
- complete: true
82
- }
83
- }
84
-
85
- clone(data: boolean): TextGroupElement {
86
- const clone = new TextGroupElement();
87
- this.props.clone(clone.props);
88
- clone.text = this.text;
89
- return clone;
90
- }
91
-
92
- destroy(): void {
93
- super.destroy();
94
- }
95
-
96
- spliceText(startOffset: number, endOffset: number, xCopy: boolean): TextGroupElement | null {
97
- endOffset = endOffset === -1 ? this.textMeasures.length : endOffset;
98
- if (endOffset === startOffset) {
99
- return null;
100
- }
101
- const clone = new TextGroupElement();
102
- this.props.clone(clone.props);
103
- if (xCopy) {
104
- clone.textMeasures = this.textMeasures.splice(startOffset, endOffset - startOffset);
105
- } else {
106
- clone.textMeasures = this.textMeasures.filter((item, index) => index >= startOffset && index < endOffset);
107
- }
108
- clone.textMeasures = clone.textMeasures.map(item => ({ sourceSize: 0, actualSize: 0, char: item.char }));
109
- return clone;
110
- }
111
-
112
- clearTextCache(): void {
113
- this.isMeasure = false;
114
- }
115
- }
116
-
117
-
118
- export class TextGroupRenderObject extends LeafRenderObject<TextGroupElement> {
119
- textMeasures!: Array<TextUnits>;
120
- render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
121
- //null-text不打印
122
- if (ctx.drawMode === 'print' && this.element.isDecorate) {
123
- return;
124
- }
125
- if (this.element.props.border) {
126
- ctx.contentContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height);
127
- }
128
- ctx.contentContext.drawTextUnits(this, position.x, position.y);
129
- // if (this.element.isMouseenter) {
130
- // ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, CommonUtil.randomColor());
131
- // }
132
-
133
- }
134
- constructor(element: TextGroupElement) {
135
- super(element);
136
- }
137
- clone(): RenderObject {
138
- const cloneRender = new TextGroupRenderObject(this.element);
139
- cloneRender.disableClick = this.disableClick;
140
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
141
- cloneRender.textMeasures = [...this.textMeasures];
142
- return cloneRender;
143
- }
144
-
145
- measure(): void {
146
- this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
147
- this.rect.height = this.element.props.fontSize;
148
- }
149
- }
150
-
151
- export class TextGroupFactory extends ElementFactory<null> {
152
- match(type: string): boolean {
153
- return type === 'text';
154
- }
155
- createElement(data: any, renderCtx: RenderContenxtType): Element {
156
- const props = data.props as TextProps;
157
- const text = data.content as string;
158
- const textGroup = new TextGroupElement();
159
- textGroup.text = text;
160
- ElementUtil.readTextProps(textGroup.props, props, this.options);
161
- return textGroup;
162
- }
163
-
164
- }
@@ -1,135 +0,0 @@
1
- import {
2
- InlineGroupElement,
3
- Position,
4
- SerializeProps,
5
- ViewOptions,
6
- Element,
7
- ElementFactory, readElementProps
8
- } from "@/med_editor/framework/element-define";
9
- import { RenderContenxtType } from "@/med_editor/framework/render-context";
10
- import { InlineGroupRenderObject, RenderObject } from "@/med_editor/framework/render-define";
11
- import { TrackRunProps } from "@/med_editor/framework/element-props";
12
- import { ElementUtil } from "@/med_editor/framework/element-util";
13
- import { ElementSerialize } from "../../element-serialize";
14
- import { GetTrackTipsEvent } from "../../element-event-define";
15
- import { nanoid } from "nanoid";
16
- export enum TrackRunTypeEnum {
17
- Inserted = 'ins-run',
18
- Deleted = 'del-run',
19
- }
20
- type NullableType<T> = T | null;
21
- export class TrackRunElement extends InlineGroupElement<TrackRunProps> {
22
- constructor(trackType: TrackRunTypeEnum) {
23
- super(trackType);
24
- this.props = new TrackRunProps(trackType);
25
- this.addEvent<GetTrackTipsEvent>('GetTrackTips', (evt) => {
26
- evt.trackTips = {
27
- trackRunType: this.type as TrackRunTypeEnum,
28
- name: this.props.userName,
29
- date: this.props.date,
30
- content: ElementSerialize.serializeString(this, { all: true })
31
- };
32
- console.log(evt.trackTips.content);
33
-
34
- evt.isCancel = true;
35
- });
36
- }
37
-
38
- clone(data: boolean): Element {
39
- const clone = new TrackRunElement(this.type as TrackRunTypeEnum);
40
- this.props.clone(clone.props);
41
- if (data) {
42
- const length = this.length;
43
- for (let i = 0; i < length; i++) {
44
- clone.addChild(this.getChild(i).clone(true));
45
- }
46
- }
47
- return clone;
48
- }
49
-
50
- createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): NullableType<RenderObject> {
51
- if (!options.showTrackChanges && this.type === TrackRunTypeEnum.Deleted) {
52
- return null;
53
- }
54
- return new TrackRunRenderObject(this);
55
- }
56
-
57
- serialize(viewOptions: ViewOptions): SerializeProps | null {
58
- return {
59
- type: this.type,
60
- props: this.props.getSerializeProps()
61
- };
62
- }
63
-
64
- split(index: number): TrackRunElement | null {
65
- if (index === 0 || index === this.length) {
66
- return null;
67
- }
68
- const clone = new TrackRunElement(this.type as TrackRunTypeEnum);
69
- this.props.clone(clone.props);
70
- const items: Array<Element> = [];
71
- for (let i = index; i < this.length; i++) {
72
- const child = this.getChild(i);
73
- items.push(child);
74
- }
75
- items.forEach(item => {
76
- item.remove();
77
- clone.addChild(item);
78
- });
79
- return clone;
80
- }
81
- }
82
-
83
- export class TrackRunRenderObject extends InlineGroupRenderObject<TrackRunElement> {
84
- constructor(ele: TrackRunElement) {
85
- super(ele);
86
- }
87
-
88
- beginRender(ctx: RenderContenxtType, position: Position): void {
89
- const color = this.element.type === 'ins-run' ? 'green' : 'red';
90
- //ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, color);
91
- }
92
-
93
- clone(): RenderObject {
94
- const cloneRender = new TrackRunRenderObject(this.element);
95
- cloneRender.rect = ElementUtil.cloneRect(this.rect);
96
- for (let i = 0; i < this.length; i++) {
97
- cloneRender.addChild(this.getChild(i).clone());
98
- }
99
- return cloneRender;
100
- }
101
-
102
- endRender(ctx: RenderContenxtType, position: Position): void {
103
- const { x, y } = position;
104
- const color = this.element.type === 'ins-run' ? 'green' : 'red';
105
- for (let i = 0; i < this.length; i++) {
106
- const childRender = this.getChild(i);
107
- const { rect } = childRender;
108
- if (childRender.element && childRender.element.type === 'del-run') {
109
- continue;
110
- }
111
- let lineY = y + rect.y + rect.height;
112
- lineY = this.element.type === 'ins-run' ? lineY : lineY - rect.height / 2;
113
- ctx.contentContext.drawLine(x + rect.x, lineY, rect.width, color, 1);
114
- }
115
- }
116
- }
117
-
118
- export class RunElementFactory extends ElementFactory<TrackRunProps>{
119
-
120
- createElement(data: readElementProps<TrackRunProps>, renderCtx: RenderContenxtType): TrackRunElement {
121
- const ele = new TrackRunElement(data.type as TrackRunTypeEnum);
122
- ele.props.userId = data.props?.userId ?? '';
123
- ele.props.userName = data.props?.userName ?? '';
124
- ele.props.date = data.props?.date ?? '';
125
- ele.props.id = data.props?.id ?? nanoid(5);
126
- return ele;
127
- }
128
-
129
- match(type: string): boolean {
130
- return type === TrackRunTypeEnum.Inserted || type === TrackRunTypeEnum.Deleted;
131
- }
132
-
133
-
134
- }
135
-
@@ -1,130 +0,0 @@
1
- const EDITOR_REACTIVE = '__editor_reactive';
2
- const ITERATOR_KEY = Symbol('iterator-key')
3
- export const reactiveMap = new WeakMap<object, object>();
4
- export const targetMaps = new WeakMap<object, Map<propType, Set<notifyCallback>>>();
5
- type propType = string | number | symbol;
6
- interface notifyCallback {
7
- (target: object, p: propType, oldValue: any, newValue: any): string | undefined | void;
8
- }
9
-
10
-
11
- const activeFns: Array<notifyCallback> = [];
12
- function track(target: object, p: propType) {
13
- const activeFn = activeFns[activeFns.length - 1];
14
- if (!activeFn) {
15
- return;
16
- }
17
- let targetMap = targetMaps.get(target)
18
- if (!targetMap) {
19
- targetMaps.set(target, (targetMap = new Map()))
20
- }
21
- let effectFns = targetMap.get(p);
22
- if (!effectFns) {
23
- targetMap.set(p, (effectFns = new Set()))
24
- }
25
- effectFns.add(activeFn)
26
- }
27
-
28
- function trigger(target: object, p: propType, oldValue: any, newValue: any): void {
29
- //不需要触发
30
- if (p.toString().startsWith('__')) {
31
- return;
32
- }
33
- const targetMap = targetMaps.get(target);
34
- if (!targetMap) {
35
- return;
36
- }
37
- const effectFns = targetMap.get(p);
38
- const iteratorFns = targetMap.get(ITERATOR_KEY);
39
- const fns = new Set<notifyCallback>();
40
- effectFns && effectFns.forEach(item => fns.add(item));
41
- iteratorFns && iteratorFns.forEach(item => fns.add(item));
42
- const activeFn = activeFns[activeFns.length - 1];
43
- //防止死循环,过滤正在运行的副作用
44
- if (activeFn) {
45
- fns.delete(activeFn)
46
- }
47
- fns.forEach(fn => {
48
- fn(target, p, oldValue, newValue)
49
- });
50
- }
51
-
52
- export function watchChanged<T extends object>(source: T, cb: notifyCallback): T {
53
- if ((<any>source)[EDITOR_REACTIVE]) {
54
- addToTrack((<any>source)['raw'], source, cb);
55
- return source;
56
- }
57
- if (isDate(source)) {
58
- return source;
59
- }
60
- const existProxy = reactiveMap.get(source);
61
- if (existProxy) {
62
- return existProxy as T;
63
- }
64
- const proxy = new Proxy(source, {
65
- get(target, p, receiver) {
66
- if (p === 'raw') {
67
- return target;
68
- }
69
- if (p === EDITOR_REACTIVE) {
70
- return true;
71
- }
72
- const res = Reflect.get(target, p, receiver)
73
- if (typeof res === 'object' && res) {
74
- return watchChanged(res, cb);
75
- }
76
- return res;
77
- },
78
- set(target, p, newValue, receiver) {
79
- //console.log('设置' + p.toString())
80
- const oldValue = (<any>target)[p];
81
- const res = Reflect.set(target, p, newValue, receiver);
82
- if ((<any>receiver).raw === target) {
83
- if (oldValue !== newValue && (oldValue === oldValue || newValue === newValue)) {
84
- trigger(target, p, oldValue, newValue);
85
- }
86
- }
87
- return res;
88
- },
89
- deleteProperty(target, p) {
90
- const res = Reflect.deleteProperty(target, p);
91
- trigger(target, p, null, null);
92
- return res;
93
- },
94
- defineProperty(target, p, attributes) {
95
- const res = Reflect.defineProperty(target, p, attributes)
96
- trigger(target, p, null, null);
97
- return res;
98
- }
99
- })
100
- addToTrack(source, proxy, cb);
101
- return proxy;
102
- }
103
-
104
- function addToTrack(source: object, proxy: object, cb: notifyCallback): void {
105
- activeFns.push(cb);
106
- track(source, ITERATOR_KEY);
107
- activeFns.pop();
108
- reactiveMap.set(source, proxy);
109
- }
110
-
111
-
112
- export function setNotifyChangedCallback(target: object, p: propType, cb: notifyCallback): void {
113
- let trackTarget: any = target;
114
- if ((<any>target)[EDITOR_REACTIVE]) {
115
- trackTarget = (<any>target)['raw'];
116
- }
117
- activeFns.push(cb)
118
- track(trackTarget, p);
119
- activeFns.pop()
120
- }
121
-
122
- export const isDate = (val: unknown): val is Date => val instanceof Date
123
-
124
- export const objectToString = Object.prototype.toString
125
- export const toTypeString = (value: unknown): string =>
126
- objectToString.call(value)
127
-
128
- export const toRawType = (value: unknown): string => {
129
- return toTypeString(value).slice(8, -1)
130
- }