@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,200 +0,0 @@
1
- import moment from "moment";
2
- import { Rect } from "./element-define";
3
- import { BorderType } from "./render-define";
4
- interface Position {
5
- x: number;
6
- y: number;
7
- }
8
-
9
- export class CommonUtil {
10
-
11
- /**
12
- * 判断坐标是否在矩形框内
13
- * @param rect
14
- * @param position
15
- * @returns
16
- */
17
- static isInsideRectByPosition(rect: Rect, position: Position): boolean {
18
- return position.x >= rect.x
19
- &&
20
- position.x <= rect.x + rect.width
21
- &&
22
- position.y >= rect.y
23
- &&
24
- position.y <= rect.y + rect.height;
25
- }
26
-
27
- static isInsideRectByRect(rect: Rect, position: Rect): boolean {
28
- return position.x >= rect.x
29
- &&
30
- position.x <= rect.x + rect.width
31
- &&
32
- position.y >= rect.y
33
- &&
34
- position.y <= rect.y + rect.height
35
- &&
36
- position.y + position.height <= rect.y + rect.height
37
- &&
38
- position.x + position.width <= rect.x + rect.width;
39
- }
40
-
41
- /**
42
- * 判断坐标是否在矩形的边框上
43
- * @param rect
44
- * @param borderWidth
45
- * @param position
46
- */
47
- static isInRectBorder(rect: Rect, borderWidth: number, position: Position): { borderType: BorderType } {
48
- const leftBorderRect: Rect = { x: 0, y: 0, width: borderWidth, height: rect.height, maxWidth: 0, maxHeight: 0 };
49
- const rightBorderRect: Rect = { x: rect.width - borderWidth, y: 0, width: borderWidth, height: rect.height, maxWidth: 0, maxHeight: 0 };
50
- const topBorderRect: Rect = { x: 0, y: 0, width: rect.width, height: borderWidth, maxWidth: 0, maxHeight: 0 };
51
- const bottomBorderRect: Rect = { x: 0, y: rect.height - borderWidth, width: rect.width, height: borderWidth, maxWidth: 0, maxHeight: 0 };
52
- let borderType: BorderType = 'none';
53
- if (this.isInsideRectByPosition(leftBorderRect, position)) {
54
- borderType = 'left';
55
- } else if (this.isInsideRectByPosition(rightBorderRect, position)) {
56
- borderType = 'right';
57
- } else if (this.isInsideRectByPosition(topBorderRect, position)) {
58
- borderType = 'top';
59
- } else if (this.isInsideRectByPosition(bottomBorderRect, position)) {
60
- borderType = 'bottom';
61
- }
62
- return { borderType };
63
- }
64
-
65
- /**
66
- * 判断坐标是否在图片的缩放操作点上
67
- */
68
- static isInPictureResizePoint(rect: Rect, pos: Position, r: number): { borderType: BorderType } | null {
69
- const { width, height } = rect;
70
- const x = 0;
71
- const y = 0;
72
- const points: Array<{ x: number, y: number, type: BorderType }> = [{ x, y, type: 'left-top' }, { x: x + width, y, type: 'right-top' }, { x: x + (Math.floor(width / 2)), y: y, type: 'top-middle' }, { x, y: y + Math.floor(height / 2), type: 'left-middle' }, { x, y: y + height, type: 'left-bottom' }, { x: width, y: Math.floor(height / 2), type: 'right-middle' }, { x: x + width, y: y + height, type: 'right-bottom' }, { x: x + (Math.floor(width / 2)), y: y + height, type: 'bottom-middle' }];
73
- for (let i = 0; i < points.length; i++) {
74
- const point = points[i];
75
- const { x: px, y: py } = point;
76
- if (((px - pos.x) * (px - pos.x) + (py - pos.y) * (py - pos.y)) < r * r) {
77
- return { borderType: point.type };
78
- }
79
- }
80
- return null;
81
- }
82
-
83
-
84
- /**
85
- * 整形符合连线要求
86
- * @param points
87
- * @param width
88
- * @param strokeColor
89
- */
90
- static resharpPoints(points: Array<Position>): Array<Position> {
91
- let prevPoint: Position = points[0];
92
- const array: Array<Position> = [];
93
- array.push(prevPoint);
94
- for (let i = 1; i < points.length; i++) {
95
- const currPoint = points[i];
96
- //不在同一水平线
97
- if (currPoint.y !== prevPoint.y && currPoint.x !== prevPoint.x) {
98
- array.push({ x: currPoint.x, y: prevPoint.y });
99
- }
100
- array.push(currPoint);
101
- prevPoint = currPoint;
102
- }
103
- return array;
104
- }
105
-
106
- static getOffsetX(node: HTMLElement): number {
107
- if (!node.parentElement) {
108
- throw new Error('node.parentElement is null')
109
- }
110
- const parent = node.parentElement.getBoundingClientRect().left;
111
- const curr = node.getBoundingClientRect().left;
112
- return curr - parent;
113
- }
114
-
115
- static randomColor() {
116
- let str = "#";
117
- for (let i = 0; i < 6; i++) {
118
- str += Math.floor(Math.random() * 16).toString(16);
119
- }
120
- return str;
121
- }
122
-
123
- /**
124
- * 判断一个数值是否在另一个数值的增益区间中
125
- * @param val
126
- * @param offset
127
- * @param compareValue
128
- * @returns
129
- */
130
- static ApproxmateValueInRange(val: number, offset: number, compareValue: number): boolean {
131
- return (val - offset) <= compareValue && (val + offset) >= compareValue;
132
- }
133
-
134
-
135
- static getEmptyValue<T>(val: T, emptyVal: T): T {
136
- if (!val) {
137
- return emptyVal;
138
- }
139
- return val;
140
- }
141
-
142
- /**
143
- * 移除并集
144
- * @param array
145
- * @param deleteItems
146
- * @returns
147
- */
148
- static removeUnionSet<T>(array: Array<T>, deleteItems: Array<T>): Array<T> {
149
- const arraySet = new Set(array);
150
- for (let i = 0; i < deleteItems.length; i++) {
151
- const item = deleteItems[i];
152
- if (arraySet.has(item)) {
153
- arraySet.delete(item)
154
- }
155
- }
156
- return Array.from(arraySet);
157
- }
158
-
159
- static nullToString(val: any): string {
160
- if (val === null || val === undefined) {
161
- return '';
162
- }
163
- return val;
164
- }
165
-
166
- static formatDate(date: Date, format: string): string {
167
- return moment(date).format(format);
168
- }
169
-
170
- static formatNow(format: string): string {
171
- return this.formatDate(new Date(), format);
172
- }
173
-
174
- static parseText(text: string, data: object): string {
175
- const reg = /\{(.*?)\}/g;
176
- let result = text;
177
- let match;
178
- while (match = reg.exec(text)) {
179
- const key = match[1];
180
- const value = data[key];
181
- result = result.replace(match[0], value);
182
- }
183
- return result;
184
- }
185
-
186
- //获取和当前日期相差的秒数
187
- static getNowDiffSeconds(date: Date | string): number {
188
- date = typeof date === 'string' ? new Date(date) : date;
189
- const now = new Date();
190
- const diff = now.getTime() - date.getTime();
191
- return diff / 1000;
192
- }
193
-
194
- //验证当前字符串是否为日期格式
195
- static isDate(str: string): boolean {
196
- const reg = /^\d{4}-\d{2}-\d{2}$/;
197
- return reg.test(str);
198
- }
199
-
200
- }