@visactor/vrender-core 0.21.0-alpha.3 → 0.21.0-vstory.1

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 (430) hide show
  1. package/cjs/animate/Ticker/default-ticker.d.ts +4 -1
  2. package/cjs/animate/Ticker/default-ticker.js +9 -3
  3. package/cjs/animate/Ticker/default-ticker.js.map +1 -1
  4. package/cjs/animate/animate.js +1 -1
  5. package/cjs/animate/animate.js.map +1 -1
  6. package/cjs/animate/easing-func.d.ts +1 -0
  7. package/cjs/animate/easing-func.js +16 -0
  8. package/cjs/animate/easing-func.js.map +1 -0
  9. package/cjs/animate/easing.d.ts +3 -0
  10. package/cjs/animate/easing.js +9 -1
  11. package/cjs/animate/easing.js.map +1 -1
  12. package/cjs/color-string/store.js +1 -2
  13. package/cjs/common/bezier-utils.d.ts +3 -0
  14. package/cjs/common/bezier-utils.js +17 -2
  15. package/cjs/common/bezier-utils.js.map +1 -1
  16. package/cjs/common/bounds-context.js +2 -1
  17. package/cjs/common/custom-path2d.d.ts +4 -0
  18. package/cjs/common/custom-path2d.js +43 -11
  19. package/cjs/common/custom-path2d.js.map +1 -1
  20. package/cjs/common/morphing-utils.js +1 -1
  21. package/cjs/common/path-svg.js +1 -1
  22. package/cjs/common/polygon.js +2 -2
  23. package/cjs/common/rect-utils.js +1 -1
  24. package/cjs/common/render-area.js +1 -2
  25. package/cjs/common/render-command-list.js +1 -1
  26. package/cjs/common/render-curve.js +1 -1
  27. package/cjs/common/render-utils.js +1 -1
  28. package/cjs/common/seg-context.js +1 -1
  29. package/cjs/common/segment/curve/arc.d.ts +4 -1
  30. package/cjs/common/segment/curve/arc.js +10 -1
  31. package/cjs/common/segment/curve/arc.js.map +1 -1
  32. package/cjs/common/segment/curve/base.d.ts +4 -1
  33. package/cjs/common/segment/curve/base.js.map +1 -1
  34. package/cjs/common/segment/curve/cubic-bezier.d.ts +5 -1
  35. package/cjs/common/segment/curve/cubic-bezier.js +24 -3
  36. package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
  37. package/cjs/common/segment/curve/curve-context.js +5 -4
  38. package/cjs/common/segment/curve/curve-context.js.map +1 -1
  39. package/cjs/common/segment/curve/ellipse.d.ts +4 -1
  40. package/cjs/common/segment/curve/ellipse.js +9 -0
  41. package/cjs/common/segment/curve/ellipse.js.map +1 -1
  42. package/cjs/common/segment/curve/line.d.ts +4 -1
  43. package/cjs/common/segment/curve/line.js +18 -0
  44. package/cjs/common/segment/curve/line.js.map +1 -1
  45. package/cjs/common/segment/curve/move.d.ts +4 -1
  46. package/cjs/common/segment/curve/move.js +9 -0
  47. package/cjs/common/segment/curve/move.js.map +1 -1
  48. package/cjs/common/segment/curve/path.d.ts +2 -1
  49. package/cjs/common/segment/curve/path.js +5 -2
  50. package/cjs/common/segment/curve/path.js.map +1 -1
  51. package/cjs/common/segment/curve/quadratic-bezier.d.ts +6 -2
  52. package/cjs/common/segment/curve/quadratic-bezier.js +23 -5
  53. package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
  54. package/cjs/common/simplify.js +1 -1
  55. package/cjs/common/sort.js +1 -1
  56. package/cjs/common/split-path.js +1 -1
  57. package/cjs/common/text.js.map +1 -1
  58. package/cjs/core/application.js +2 -1
  59. package/cjs/core/camera.js +1 -1
  60. package/cjs/core/constants.js +1 -1
  61. package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +4 -55
  62. package/cjs/core/contributions/textMeasure/AtextMeasure.js +18 -105
  63. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  64. package/cjs/core/contributions/textMeasure/layout.d.ts +1 -0
  65. package/cjs/core/contributions/textMeasure/layout.js +30 -20
  66. package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
  67. package/cjs/core/core-modules.js +1 -1
  68. package/cjs/core/global-module.js +2 -0
  69. package/cjs/core/global.js +1 -1
  70. package/cjs/core/graphic-utils.js +1 -1
  71. package/cjs/core/index.js +1 -1
  72. package/cjs/core/layer-service.js +1 -1
  73. package/cjs/core/layer.js +1 -1
  74. package/cjs/core/light.js +1 -1
  75. package/cjs/core/stage.d.ts +0 -3
  76. package/cjs/core/stage.js +3 -12
  77. package/cjs/core/stage.js.map +1 -1
  78. package/cjs/core/window.js +1 -1
  79. package/cjs/event/event-manager.d.ts +0 -1
  80. package/cjs/event/event-manager.js +1 -1
  81. package/cjs/event/event-manager.js.map +1 -1
  82. package/cjs/event/event-system.js +1 -2
  83. package/cjs/event/event-system.js.map +1 -1
  84. package/cjs/graphic/builtin-symbol/arrow.js +2 -2
  85. package/cjs/graphic/builtin-symbol/arrow.js.map +1 -1
  86. package/cjs/graphic/builtin-symbol/arrow2-down.js +2 -2
  87. package/cjs/graphic/builtin-symbol/arrow2-down.js.map +1 -1
  88. package/cjs/graphic/builtin-symbol/arrow2-left.js +2 -2
  89. package/cjs/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  90. package/cjs/graphic/builtin-symbol/arrow2-right.js +2 -2
  91. package/cjs/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  92. package/cjs/graphic/builtin-symbol/arrow2-up.js +2 -2
  93. package/cjs/graphic/builtin-symbol/arrow2-up.js.map +1 -1
  94. package/cjs/graphic/builtin-symbol/base.d.ts +1 -0
  95. package/cjs/graphic/builtin-symbol/base.js +3 -0
  96. package/cjs/graphic/builtin-symbol/base.js.map +1 -1
  97. package/cjs/graphic/builtin-symbol/circle.js +3 -3
  98. package/cjs/graphic/builtin-symbol/circle.js.map +1 -1
  99. package/cjs/graphic/builtin-symbol/close.js +3 -3
  100. package/cjs/graphic/builtin-symbol/close.js.map +1 -1
  101. package/cjs/graphic/builtin-symbol/cross.js +2 -2
  102. package/cjs/graphic/builtin-symbol/cross.js.map +1 -1
  103. package/cjs/graphic/builtin-symbol/diamond.js +3 -3
  104. package/cjs/graphic/builtin-symbol/diamond.js.map +1 -1
  105. package/cjs/graphic/builtin-symbol/line-h.js +3 -3
  106. package/cjs/graphic/builtin-symbol/line-h.js.map +1 -1
  107. package/cjs/graphic/builtin-symbol/line-v.js +3 -3
  108. package/cjs/graphic/builtin-symbol/line-v.js.map +1 -1
  109. package/cjs/graphic/builtin-symbol/rect.d.ts +2 -1
  110. package/cjs/graphic/builtin-symbol/rect.js +28 -0
  111. package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
  112. package/cjs/graphic/builtin-symbol/square.js +2 -2
  113. package/cjs/graphic/builtin-symbol/square.js.map +1 -1
  114. package/cjs/graphic/builtin-symbol/star.js +2 -2
  115. package/cjs/graphic/builtin-symbol/star.js.map +1 -1
  116. package/cjs/graphic/builtin-symbol/stroke.js +2 -2
  117. package/cjs/graphic/builtin-symbol/stroke.js.map +1 -1
  118. package/cjs/graphic/builtin-symbol/thin-triangle.js +2 -2
  119. package/cjs/graphic/builtin-symbol/thin-triangle.js.map +1 -1
  120. package/cjs/graphic/builtin-symbol/triangle-down.js +2 -2
  121. package/cjs/graphic/builtin-symbol/triangle-down.js.map +1 -1
  122. package/cjs/graphic/builtin-symbol/triangle-left.js +2 -2
  123. package/cjs/graphic/builtin-symbol/triangle-left.js.map +1 -1
  124. package/cjs/graphic/builtin-symbol/triangle-right.js +2 -2
  125. package/cjs/graphic/builtin-symbol/triangle-right.js.map +1 -1
  126. package/cjs/graphic/builtin-symbol/triangle-up.js +2 -2
  127. package/cjs/graphic/builtin-symbol/triangle-up.js.map +1 -1
  128. package/cjs/graphic/builtin-symbol/utils.d.ts +3 -1
  129. package/cjs/graphic/builtin-symbol/utils.js +11 -3
  130. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  131. package/cjs/graphic/builtin-symbol/wedge.js +2 -2
  132. package/cjs/graphic/builtin-symbol/wedge.js.map +1 -1
  133. package/cjs/graphic/builtin-symbol/wye.js +2 -2
  134. package/cjs/graphic/builtin-symbol/wye.js.map +1 -1
  135. package/cjs/graphic/config.js +6 -2
  136. package/cjs/graphic/config.js.map +1 -1
  137. package/cjs/graphic/graphic.js +2 -1
  138. package/cjs/graphic/graphic.js.map +1 -1
  139. package/cjs/graphic/richtext/wrapper.d.ts +1 -0
  140. package/cjs/graphic/richtext/wrapper.js +1 -1
  141. package/cjs/graphic/richtext/wrapper.js.map +1 -1
  142. package/cjs/graphic/richtext.js +2 -1
  143. package/cjs/graphic/richtext.js.map +1 -1
  144. package/cjs/graphic/text.d.ts +11 -10
  145. package/cjs/graphic/text.js +174 -91
  146. package/cjs/graphic/text.js.map +1 -1
  147. package/cjs/graphic/wrap-text.js +4 -12
  148. package/cjs/graphic/wrap-text.js.map +1 -1
  149. package/cjs/index.d.ts +1 -0
  150. package/cjs/index.js +1 -1
  151. package/cjs/index.js.map +1 -1
  152. package/cjs/interface/animate.d.ts +7 -2
  153. package/cjs/interface/animate.js.map +1 -1
  154. package/cjs/interface/graphic/path.d.ts +1 -0
  155. package/cjs/interface/graphic/path.js.map +1 -1
  156. package/cjs/interface/graphic/symbol.d.ts +2 -0
  157. package/cjs/interface/graphic/symbol.js.map +1 -1
  158. package/cjs/interface/graphic/text.d.ts +3 -3
  159. package/cjs/interface/graphic/text.js.map +1 -1
  160. package/cjs/interface/graphic.d.ts +6 -2
  161. package/cjs/interface/graphic.js.map +1 -1
  162. package/cjs/interface/path.d.ts +5 -0
  163. package/cjs/interface/path.js.map +1 -1
  164. package/cjs/interface/picker.d.ts +13 -0
  165. package/cjs/interface/picker.js.map +1 -1
  166. package/cjs/interface/stage.d.ts +0 -1
  167. package/cjs/interface/stage.js.map +1 -1
  168. package/cjs/interface/text.d.ts +1 -6
  169. package/cjs/interface/text.js.map +1 -1
  170. package/cjs/picker/constants.d.ts +2 -0
  171. package/cjs/picker/constants.js +3 -2
  172. package/cjs/picker/constants.js.map +1 -1
  173. package/cjs/picker/pick-interceptor.d.ts +7 -2
  174. package/cjs/picker/pick-interceptor.js +19 -2
  175. package/cjs/picker/pick-interceptor.js.map +1 -1
  176. package/cjs/picker/pick-modules.js +7 -4
  177. package/cjs/picker/pick-modules.js.map +1 -1
  178. package/cjs/picker/picker-service.d.ts +4 -2
  179. package/cjs/picker/picker-service.js +13 -12
  180. package/cjs/picker/picker-service.js.map +1 -1
  181. package/cjs/plugins/builtin-plugin/edit-module.d.ts +6 -5
  182. package/cjs/plugins/builtin-plugin/edit-module.js +84 -28
  183. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  184. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  185. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  186. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  187. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +49 -30
  188. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +280 -217
  189. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  190. package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
  191. package/cjs/render/contributions/render/base-render.d.ts +1 -0
  192. package/cjs/render/contributions/render/base-render.js +20 -2
  193. package/cjs/render/contributions/render/base-render.js.map +1 -1
  194. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  195. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  196. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  197. package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  198. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +30 -2
  199. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  200. package/cjs/render/contributions/render/path-render.js.map +1 -1
  201. package/cjs/render/contributions/render/polygon-render.js.map +1 -1
  202. package/cjs/render/contributions/render/symbol-render.js +15 -12
  203. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  204. package/cjs/render/contributions/render/text-render.js +23 -1
  205. package/cjs/render/contributions/render/text-render.js.map +1 -1
  206. package/cjs/render/contributions/render/utils.d.ts +1 -2
  207. package/cjs/render/contributions/render/utils.js +4 -20
  208. package/cjs/render/contributions/render/utils.js.map +1 -1
  209. package/dist/index.es.js +8796 -8187
  210. package/es/animate/Ticker/default-ticker.d.ts +4 -1
  211. package/es/animate/Ticker/default-ticker.js +10 -4
  212. package/es/animate/Ticker/default-ticker.js.map +1 -1
  213. package/es/animate/animate.js +1 -1
  214. package/es/animate/animate.js.map +1 -1
  215. package/es/animate/easing-func.d.ts +1 -0
  216. package/es/animate/easing-func.js +10 -0
  217. package/es/animate/easing-func.js.map +1 -0
  218. package/es/animate/easing.d.ts +3 -0
  219. package/es/animate/easing.js +9 -1
  220. package/es/animate/easing.js.map +1 -1
  221. package/es/color-string/store.js +1 -2
  222. package/es/common/bezier-utils.d.ts +3 -0
  223. package/es/common/bezier-utils.js +14 -0
  224. package/es/common/bezier-utils.js.map +1 -1
  225. package/es/common/bounds-context.js +2 -1
  226. package/es/common/custom-path2d.d.ts +4 -0
  227. package/es/common/custom-path2d.js +44 -12
  228. package/es/common/custom-path2d.js.map +1 -1
  229. package/es/common/morphing-utils.js +1 -1
  230. package/es/common/path-svg.js +1 -1
  231. package/es/common/polygon.js +1 -1
  232. package/es/common/rect-utils.js +1 -1
  233. package/es/common/render-area.js +1 -2
  234. package/es/common/render-command-list.js +1 -1
  235. package/es/common/render-curve.js +1 -1
  236. package/es/common/render-utils.js +1 -1
  237. package/es/common/seg-context.js +1 -1
  238. package/es/common/segment/curve/arc.d.ts +4 -1
  239. package/es/common/segment/curve/arc.js +10 -1
  240. package/es/common/segment/curve/arc.js.map +1 -1
  241. package/es/common/segment/curve/base.d.ts +4 -1
  242. package/es/common/segment/curve/base.js.map +1 -1
  243. package/es/common/segment/curve/cubic-bezier.d.ts +5 -1
  244. package/es/common/segment/curve/cubic-bezier.js +22 -1
  245. package/es/common/segment/curve/cubic-bezier.js.map +1 -1
  246. package/es/common/segment/curve/curve-context.js +6 -3
  247. package/es/common/segment/curve/curve-context.js.map +1 -1
  248. package/es/common/segment/curve/ellipse.d.ts +4 -1
  249. package/es/common/segment/curve/ellipse.js +9 -0
  250. package/es/common/segment/curve/ellipse.js.map +1 -1
  251. package/es/common/segment/curve/line.d.ts +4 -1
  252. package/es/common/segment/curve/line.js +18 -0
  253. package/es/common/segment/curve/line.js.map +1 -1
  254. package/es/common/segment/curve/move.d.ts +4 -1
  255. package/es/common/segment/curve/move.js +9 -0
  256. package/es/common/segment/curve/move.js.map +1 -1
  257. package/es/common/segment/curve/path.d.ts +2 -1
  258. package/es/common/segment/curve/path.js +5 -2
  259. package/es/common/segment/curve/path.js.map +1 -1
  260. package/es/common/segment/curve/quadratic-bezier.d.ts +6 -2
  261. package/es/common/segment/curve/quadratic-bezier.js +28 -5
  262. package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
  263. package/es/common/simplify.js +1 -1
  264. package/es/common/sort.js +1 -1
  265. package/es/common/split-path.js +1 -1
  266. package/es/common/text.js.map +1 -1
  267. package/es/core/application.js +2 -1
  268. package/es/core/camera.js +1 -1
  269. package/es/core/constants.js +1 -1
  270. package/es/core/contributions/textMeasure/AtextMeasure.d.ts +4 -55
  271. package/es/core/contributions/textMeasure/AtextMeasure.js +17 -106
  272. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  273. package/es/core/contributions/textMeasure/layout.d.ts +1 -0
  274. package/es/core/contributions/textMeasure/layout.js +30 -20
  275. package/es/core/contributions/textMeasure/layout.js.map +1 -1
  276. package/es/core/core-modules.js +1 -1
  277. package/es/core/global-module.js +2 -0
  278. package/es/core/global.js +1 -1
  279. package/es/core/graphic-utils.js +1 -1
  280. package/es/core/index.js +1 -1
  281. package/es/core/layer-service.js +1 -1
  282. package/es/core/layer.js +1 -1
  283. package/es/core/light.js +1 -1
  284. package/es/core/stage.d.ts +0 -3
  285. package/es/core/stage.js +2 -13
  286. package/es/core/stage.js.map +1 -1
  287. package/es/core/window.js +1 -1
  288. package/es/event/event-manager.d.ts +0 -1
  289. package/es/event/event-manager.js +1 -1
  290. package/es/event/event-manager.js.map +1 -1
  291. package/es/event/event-system.js +1 -2
  292. package/es/event/event-system.js.map +1 -1
  293. package/es/graphic/builtin-symbol/arrow.js +2 -2
  294. package/es/graphic/builtin-symbol/arrow.js.map +1 -1
  295. package/es/graphic/builtin-symbol/arrow2-down.js +2 -2
  296. package/es/graphic/builtin-symbol/arrow2-down.js.map +1 -1
  297. package/es/graphic/builtin-symbol/arrow2-left.js +2 -2
  298. package/es/graphic/builtin-symbol/arrow2-left.js.map +1 -1
  299. package/es/graphic/builtin-symbol/arrow2-right.js +2 -2
  300. package/es/graphic/builtin-symbol/arrow2-right.js.map +1 -1
  301. package/es/graphic/builtin-symbol/arrow2-up.js +2 -2
  302. package/es/graphic/builtin-symbol/arrow2-up.js.map +1 -1
  303. package/es/graphic/builtin-symbol/base.d.ts +1 -0
  304. package/es/graphic/builtin-symbol/base.js +3 -0
  305. package/es/graphic/builtin-symbol/base.js.map +1 -1
  306. package/es/graphic/builtin-symbol/circle.js +3 -3
  307. package/es/graphic/builtin-symbol/circle.js.map +1 -1
  308. package/es/graphic/builtin-symbol/close.js +3 -3
  309. package/es/graphic/builtin-symbol/close.js.map +1 -1
  310. package/es/graphic/builtin-symbol/cross.js +2 -2
  311. package/es/graphic/builtin-symbol/cross.js.map +1 -1
  312. package/es/graphic/builtin-symbol/diamond.js +3 -3
  313. package/es/graphic/builtin-symbol/diamond.js.map +1 -1
  314. package/es/graphic/builtin-symbol/line-h.js +3 -3
  315. package/es/graphic/builtin-symbol/line-h.js.map +1 -1
  316. package/es/graphic/builtin-symbol/line-v.js +3 -3
  317. package/es/graphic/builtin-symbol/line-v.js.map +1 -1
  318. package/es/graphic/builtin-symbol/rect.d.ts +2 -1
  319. package/es/graphic/builtin-symbol/rect.js +28 -0
  320. package/es/graphic/builtin-symbol/rect.js.map +1 -1
  321. package/es/graphic/builtin-symbol/square.js +2 -2
  322. package/es/graphic/builtin-symbol/square.js.map +1 -1
  323. package/es/graphic/builtin-symbol/star.js +2 -2
  324. package/es/graphic/builtin-symbol/star.js.map +1 -1
  325. package/es/graphic/builtin-symbol/stroke.js +2 -2
  326. package/es/graphic/builtin-symbol/stroke.js.map +1 -1
  327. package/es/graphic/builtin-symbol/thin-triangle.js +2 -2
  328. package/es/graphic/builtin-symbol/thin-triangle.js.map +1 -1
  329. package/es/graphic/builtin-symbol/triangle-down.js +2 -2
  330. package/es/graphic/builtin-symbol/triangle-down.js.map +1 -1
  331. package/es/graphic/builtin-symbol/triangle-left.js +2 -2
  332. package/es/graphic/builtin-symbol/triangle-left.js.map +1 -1
  333. package/es/graphic/builtin-symbol/triangle-right.js +2 -2
  334. package/es/graphic/builtin-symbol/triangle-right.js.map +1 -1
  335. package/es/graphic/builtin-symbol/triangle-up.js +2 -2
  336. package/es/graphic/builtin-symbol/triangle-up.js.map +1 -1
  337. package/es/graphic/builtin-symbol/utils.d.ts +3 -1
  338. package/es/graphic/builtin-symbol/utils.js +12 -4
  339. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  340. package/es/graphic/builtin-symbol/wedge.js +2 -2
  341. package/es/graphic/builtin-symbol/wedge.js.map +1 -1
  342. package/es/graphic/builtin-symbol/wye.js +2 -2
  343. package/es/graphic/builtin-symbol/wye.js.map +1 -1
  344. package/es/graphic/config.js +6 -2
  345. package/es/graphic/config.js.map +1 -1
  346. package/es/graphic/graphic.js +2 -1
  347. package/es/graphic/graphic.js.map +1 -1
  348. package/es/graphic/richtext/wrapper.d.ts +1 -0
  349. package/es/graphic/richtext/wrapper.js +1 -1
  350. package/es/graphic/richtext/wrapper.js.map +1 -1
  351. package/es/graphic/richtext.js +2 -1
  352. package/es/graphic/richtext.js.map +1 -1
  353. package/es/graphic/text.d.ts +11 -10
  354. package/es/graphic/text.js +169 -90
  355. package/es/graphic/text.js.map +1 -1
  356. package/es/graphic/wrap-text.js +4 -12
  357. package/es/graphic/wrap-text.js.map +1 -1
  358. package/es/index.d.ts +1 -0
  359. package/es/index.js +2 -0
  360. package/es/index.js.map +1 -1
  361. package/es/interface/animate.d.ts +7 -2
  362. package/es/interface/animate.js.map +1 -1
  363. package/es/interface/graphic/path.d.ts +1 -0
  364. package/es/interface/graphic/path.js.map +1 -1
  365. package/es/interface/graphic/symbol.d.ts +2 -0
  366. package/es/interface/graphic/symbol.js.map +1 -1
  367. package/es/interface/graphic/text.d.ts +3 -3
  368. package/es/interface/graphic/text.js.map +1 -1
  369. package/es/interface/graphic.d.ts +6 -2
  370. package/es/interface/graphic.js.map +1 -1
  371. package/es/interface/path.d.ts +5 -0
  372. package/es/interface/path.js.map +1 -1
  373. package/es/interface/picker.d.ts +13 -0
  374. package/es/interface/picker.js.map +1 -1
  375. package/es/interface/stage.d.ts +0 -1
  376. package/es/interface/stage.js.map +1 -1
  377. package/es/interface/text.d.ts +1 -6
  378. package/es/interface/text.js.map +1 -1
  379. package/es/picker/constants.d.ts +2 -0
  380. package/es/picker/constants.js +4 -0
  381. package/es/picker/constants.js.map +1 -1
  382. package/es/picker/pick-interceptor.d.ts +7 -2
  383. package/es/picker/pick-interceptor.js +19 -1
  384. package/es/picker/pick-interceptor.js.map +1 -1
  385. package/es/picker/pick-modules.js +5 -3
  386. package/es/picker/pick-modules.js.map +1 -1
  387. package/es/picker/picker-service.d.ts +4 -2
  388. package/es/picker/picker-service.js +13 -13
  389. package/es/picker/picker-service.js.map +1 -1
  390. package/es/plugins/builtin-plugin/edit-module.d.ts +6 -5
  391. package/es/plugins/builtin-plugin/edit-module.js +79 -25
  392. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  393. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  394. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  395. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  396. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +49 -30
  397. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +283 -214
  398. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  399. package/es/render/contributions/render/arc3d-render.js.map +1 -1
  400. package/es/render/contributions/render/base-render.d.ts +1 -0
  401. package/es/render/contributions/render/base-render.js +21 -2
  402. package/es/render/contributions/render/base-render.js.map +1 -1
  403. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  404. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  405. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  406. package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  407. package/es/render/contributions/render/contributions/symbol-contribution-render.js +26 -0
  408. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  409. package/es/render/contributions/render/path-render.js.map +1 -1
  410. package/es/render/contributions/render/polygon-render.js.map +1 -1
  411. package/es/render/contributions/render/symbol-render.js +16 -13
  412. package/es/render/contributions/render/symbol-render.js.map +1 -1
  413. package/es/render/contributions/render/text-render.js +23 -1
  414. package/es/render/contributions/render/text-render.js.map +1 -1
  415. package/es/render/contributions/render/utils.d.ts +1 -2
  416. package/es/render/contributions/render/utils.js +0 -18
  417. package/es/render/contributions/render/utils.js.map +1 -1
  418. package/package.json +3 -3
  419. package/cjs/graphic/text2.d.ts +0 -81
  420. package/cjs/graphic/text2.js +0 -288
  421. package/cjs/graphic/text2.js.map +0 -1
  422. package/cjs/plugins/builtin-plugin/auto-refresh-plugin.d.ts +0 -16
  423. package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js +0 -48
  424. package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js.map +0 -1
  425. package/es/graphic/text2.d.ts +0 -81
  426. package/es/graphic/text2.js +0 -293
  427. package/es/graphic/text2.js.map +0 -1
  428. package/es/plugins/builtin-plugin/auto-refresh-plugin.d.ts +0 -16
  429. package/es/plugins/builtin-plugin/auto-refresh-plugin.js +0 -41
  430. package/es/plugins/builtin-plugin/auto-refresh-plugin.js.map +0 -1
@@ -4,35 +4,40 @@ import { Generator } from "../../common/generator";
4
4
 
5
5
  import { createGroup, createLine, createRect } from "../../graphic";
6
6
 
7
- import { EditModule, findCursorIndexIgnoreLinebreak } from "./edit-module";
7
+ import { DefaultTicker, DefaultTimeline } from "../../animate";
8
+
9
+ import { EditModule } from "./edit-module";
10
+
11
+ import { application } from "../../application";
8
12
 
9
13
  class Selection {
10
- constructor(cacheSelectionStartCursorIdx, cacheCurCursorIdx, selectionStartCursorIdx, curCursorIdx, rt) {
14
+ constructor(selectionStartCursorIdx, curCursorIdx, rt) {
11
15
  this.curCursorIdx = curCursorIdx, this.selectionStartCursorIdx = selectionStartCursorIdx,
12
- this.cacheCurCursorIdx = cacheCurCursorIdx, this.cacheSelectionStartCursorIdx = cacheSelectionStartCursorIdx,
13
16
  this.rt = rt;
14
17
  }
18
+ isEmpty() {
19
+ return this.selectionStartCursorIdx === this.curCursorIdx;
20
+ }
15
21
  hasFormat(key) {
16
22
  return null != this.getFormat(key);
17
23
  }
18
- getFormat(key) {
24
+ _getFormat(key, cursorIdx) {
25
+ var _a;
19
26
  if (!this.rt) return null;
20
- const config = this.rt.attribute.textConfig, val = config[this.selectionStartCursorIdx + 1][key];
21
- if (null == val) return null;
22
- for (let i = this.selectionStartCursorIdx + 2; i <= this.curCursorIdx; i++) {
23
- if (val !== config[i][key]) return null;
24
- }
25
- return val;
27
+ const idx = Math.round(cursorIdx), config = this.rt.attribute.textConfig;
28
+ return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
29
+ }
30
+ getFormat(key) {
31
+ return this.getAllFormat(key)[0];
26
32
  }
27
33
  getAllFormat(key) {
28
- if (!this.rt) return [];
29
- const config = this.rt.attribute.textConfig, val = config[this.selectionStartCursorIdx + 1][key], set = new Set;
30
- set.add(val);
31
- for (let i = this.selectionStartCursorIdx + 2; i <= this.curCursorIdx; i++) {
32
- const item = config[i];
33
- set.add(item[key]);
34
+ const valSet = new Set, minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
35
+ if (minCursorIdx === maxCursorIdx) return [ this._getFormat(key, minCursorIdx) ];
36
+ for (let i = minCursorIdx; i < maxCursorIdx; i++) {
37
+ const val = this._getFormat(key, i);
38
+ val && valSet.add(val);
34
39
  }
35
- return Array.from(set.values());
40
+ return Array.from(valSet.values());
36
41
  }
37
42
  }
38
43
 
@@ -41,39 +46,88 @@ export const FORMAT_TEXT_COMMAND = "FORMAT_TEXT_COMMAND";
41
46
  export const FORMAT_ELEMENT_COMMAND = "FORMAT_ELEMENT_COMMAND";
42
47
 
43
48
  export class RichTextEditPlugin {
49
+ static splitText(text) {
50
+ return Array.from(text);
51
+ }
52
+ static tryUpdateRichtext(richtext) {
53
+ if (!richtext.getFrameCache().lines.every((line => line.paragraphs.every((item => !(item.text && isString(item.text) && RichTextEditPlugin.splitText(item.text).length > 1)))))) {
54
+ const tc = [];
55
+ richtext.attribute.textConfig.forEach((item => {
56
+ const textList = RichTextEditPlugin.splitText(item.text.toString());
57
+ if (isString(item.text) && textList.length > 1) for (let i = 0; i < textList.length; i++) {
58
+ const t = textList[i];
59
+ tc.push(Object.assign(Object.assign({}, item), {
60
+ text: t
61
+ }));
62
+ } else tc.push(item);
63
+ })), richtext.setAttributes({
64
+ textConfig: tc
65
+ }), richtext.doUpdateFrameCache(tc);
66
+ }
67
+ }
68
+ static CreateSelection(rt) {
69
+ if (!rt) return null;
70
+ const {textConfig: textConfig = []} = rt.attribute;
71
+ return new Selection(0, textConfig.length - 1, rt);
72
+ }
44
73
  constructor() {
45
74
  this.name = "RichTextEditPlugin", this.activeEvent = "onRegister", this._uid = Generator.GenAutoIncrementId(),
46
- this.key = this.name + this._uid, this.editing = !1, this.pointerDown = !1, this.handleInput = (text, isComposing, cursorIdx, rt, orient) => {
47
- const p = this.getPointByColumnIdx(cursorIdx, rt, orient);
48
- this.hideSelection(), this.setCursor(p.x, p.y1, p.y2), this.updateCbs.forEach((cb => cb("input", this)));
49
- }, this.handleChange = (text, isComposing, cursorIdx, rt, orient) => {
50
- const p = this.getPointByColumnIdx(cursorIdx, rt, orient);
51
- this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx, this.setCursorAndTextArea(p.x, p.y1, p.y2, rt),
52
- this.hideSelection(), this.updateCbs.forEach((cb => cb("change", this)));
75
+ this.key = this.name + this._uid, this.editing = !1, this.pointerDown = !1, this.handleKeyDown = e => {
76
+ if (!this.currRt || !this.editing) return;
77
+ const cache = this.currRt.getFrameCache();
78
+ if (!cache) return;
79
+ let x = 0, y = 0;
80
+ "ArrowUp" === e.key ? y = -1 : "ArrowDown" === e.key ? y = 1 : "ArrowLeft" === e.key ? x = -1 : "ArrowRight" === e.key && (x = 1);
81
+ const {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, Math.round(this.curCursorIdx));
82
+ if (x) {
83
+ x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 2] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + .2 : x > 0 && columnInfo === lineInfo.paragraphs[lineInfo.paragraphs.length - 1] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx + 1 - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx > Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - .2 : x < 0 && columnInfo === lineInfo.paragraphs[0] && this.curCursorIdx < Math.round(this.curCursorIdx) ? this.curCursorIdx = this.curCursorIdx - 1 + .2 : this.curCursorIdx += x;
84
+ const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
85
+ this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
86
+ }
87
+ if (y) {
88
+ if (y > 0 && lineInfo === cache.lines[cache.lines.length - 1]) return;
89
+ if (y < 0 && lineInfo === cache.lines[0]) return;
90
+ const lineIdx = cache.lines.findIndex((item => item === lineInfo)) + y;
91
+ if (lineIdx < 0 || lineIdx >= cache.lines.length) return;
92
+ const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt), posX = pos.x;
93
+ let posY = (pos.y1 + pos.y2) / 2;
94
+ posY += y * lineInfo.height;
95
+ const nextLineInfo = cache.lines[lineIdx], {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(nextLineInfo, {
96
+ x: posX,
97
+ y: posY
98
+ });
99
+ if (!columnInfo) return;
100
+ const cursorIdx = this.getColumnIndex(cache, columnInfo) + delta, data = this.computedCursorPosByCursorIdx(cursorIdx, this.currRt);
101
+ this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx, this.setCursorAndTextArea(data.x, data.y1, data.y2, this.currRt);
102
+ }
103
+ }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
104
+ this.hideSelection(), this.updateCbs.forEach((cb => cb("input", this)));
105
+ }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
106
+ this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx;
107
+ const p = this.computedCursorPosByCursorIdx(cursorIdx, rt);
108
+ this.setCursorAndTextArea(p.x, p.y1, p.y2, rt), this.hideSelection(), this.updateCbs.forEach((cb => cb("change", this)));
53
109
  }, this.handleMove = e => {
54
110
  this.isRichtext(e) && (this.currRt = e.target, this.handleEnter(e), e.target.once("pointerleave", this.handleLeave),
55
- this.showSelection(e));
56
- }, this.handlePointerDown = e => {
57
- this.editing ? this.onFocus(e) : this.deFocus(e), this.applyUpdate(), this.pointerDown = !0,
58
- this.updateCbs.forEach((cb => cb(this.editing ? "onfocus" : "defocus", this)));
59
- }, this.handlePointerUp = e => {
60
- this.pointerDown = !1;
111
+ this.tryShowSelection(e));
61
112
  }, this.handleEnter = e => {
62
113
  this.editing = !0, this.pluginService.stage.setCursor("text");
63
114
  }, this.handleLeave = e => {
64
115
  this.editing = !1, this.pluginService.stage.setCursor("default");
116
+ }, this.handlePointerDown = e => {
117
+ this.editing ? this.onFocus(e) : this.deFocus(e), this.triggerRender(), this.pointerDown = !0,
118
+ this.updateCbs.forEach((cb => cb(this.editing ? "onfocus" : "defocus", this)));
119
+ }, this.handlePointerUp = e => {
120
+ this.pointerDown = !1;
65
121
  }, this.commandCbs = new Map, this.commandCbs.set(FORMAT_TEXT_COMMAND, [ this.formatTextCommandCb ]),
66
- this.updateCbs = [];
67
- }
68
- getSelection() {
69
- return this.selectionStartCursorIdx && this.curCursorIdx && this.selectionStartCursorIdx !== this.curCursorIdx && this.currRt ? new Selection(this.selectionStartCursorIdx, this.curCursorIdx, findCursorIndexIgnoreLinebreak(this.currRt.attribute.textConfig, this.selectionStartCursorIdx), findCursorIndexIgnoreLinebreak(this.currRt.attribute.textConfig, this.curCursorIdx), this.currRt) : null;
122
+ this.updateCbs = [], this.timeline = new DefaultTimeline, this.ticker = new DefaultTicker([ this.timeline ]),
123
+ this.deltaX = 0, this.deltaY = 0;
70
124
  }
71
125
  formatTextCommandCb(payload, p) {
72
126
  const rt = p.currRt;
73
127
  if (!rt) return;
74
128
  const selectionData = p.getSelection();
75
129
  if (!selectionData) return;
76
- const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, config = rt.attribute.textConfig.slice(selectionStartCursorIdx + 1, curCursorIdx + 1);
130
+ const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, minCursorIdx = Math.min(selectionStartCursorIdx, curCursorIdx), maxCursorIdx = Math.max(selectionStartCursorIdx, curCursorIdx), config = rt.attribute.textConfig.slice(minCursorIdx + 1, maxCursorIdx + 1);
77
131
  "bold" === payload ? config.forEach((item => item.fontWeight = "bold")) : "italic" === payload ? config.forEach((item => item.fontStyle = "italic")) : "underline" === payload ? config.forEach((item => item.underline = !0)) : "lineThrough" === payload ? config.forEach((item => item.lineThrough = !0)) : isObject(payload) && config.forEach((item => merge(item, payload))),
78
132
  rt.setAttributes(rt.attribute);
79
133
  }
@@ -90,125 +144,32 @@ export class RichTextEditPlugin {
90
144
  activate(context) {
91
145
  this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove),
92
146
  context.stage.on("pointerdown", this.handlePointerDown), context.stage.on("pointerup", this.handlePointerUp),
93
- context.stage.on("pointerleave", this.handlePointerUp), this.editModule.onInput(this.handleInput),
94
- this.editModule.onChange(this.handleChange);
95
- }
96
- showSelection(e) {
97
- const cache = e.target.getFrameCache();
98
- if (cache && this.editBg && this.pointerDown) {
99
- let p0 = this.lastPoint, p1 = this.getEventPosition(e), line1Info = this.getLineByPoint(cache, p1);
100
- const column1 = this.getColumnByLinePoint(line1Info, p1), y1 = line1Info.top, y2 = line1Info.top + line1Info.height;
101
- let x = column1.left + column1.width, cursorIndex = this.getColumnIndex(cache, column1);
102
- p1.x < column1.left + column1.width / 2 && (x = column1.left, cursorIndex -= 1),
103
- p1.x = x, p1.y = (y1 + y2) / 2;
104
- let line0Info = this.getLineByPoint(cache, p0);
105
- if ((p0.y > p1.y || p0.y === p1.y && p0.x > p1.x) && ([p0, p1] = [ p1, p0 ], [line1Info, line0Info] = [ line0Info, line1Info ]),
106
- this.editBg.removeAllChild(), line0Info === line1Info) {
107
- const column0 = this.getColumnByLinePoint(line0Info, p0);
108
- this.editBg.setAttributes({
109
- x: p0.x,
110
- y: line0Info.top,
111
- width: p1.x - p0.x,
112
- height: column0.height,
113
- fill: "#336df4",
114
- fillOpacity: .2
115
- });
116
- } else {
117
- this.editBg.setAttributes({
118
- x: 0,
119
- y: line0Info.top,
120
- width: 0,
121
- height: 0
122
- });
123
- const startIdx = cache.lines.findIndex((item => item === line0Info)), endIdx = cache.lines.findIndex((item => item === line1Info));
124
- let y = 0;
125
- for (let i = startIdx; i <= endIdx; i++) {
126
- const line = cache.lines[i];
127
- if (i === startIdx) {
128
- const p = line.paragraphs[line.paragraphs.length - 1];
129
- this.editBg.add(createRect({
130
- x: p0.x,
131
- y: y,
132
- width: p.left + p.width - p0.x,
133
- height: line.height,
134
- fill: "#336df4",
135
- fillOpacity: .2
136
- }));
137
- } else if (i === endIdx) {
138
- const p = line.paragraphs[0];
139
- this.editBg.add(createRect({
140
- x: p.left,
141
- y: y,
142
- width: p1.x - p.left,
143
- height: line.height,
144
- fill: "#336df4",
145
- fillOpacity: .2
146
- }));
147
- } else {
148
- const p0 = line.paragraphs[0], p1 = line.paragraphs[line.paragraphs.length - 1];
149
- this.editBg.add(createRect({
150
- x: p0.left,
151
- y: y,
152
- width: p1.left + p1.width - p0.left,
153
- height: line.height,
154
- fill: "#336df4",
155
- fillOpacity: .2
156
- }));
157
- }
158
- y += line.height;
159
- }
160
- }
161
- this.curCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1 + 2, y2 - 2, e.target),
162
- this.applyUpdate(), this.updateCbs.forEach((cb => cb("selection", this)));
163
- }
164
- }
165
- hideSelection() {
166
- this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
167
- fill: "transparent"
168
- }));
169
- }
170
- isRichtext(e) {
171
- return !(!e.target || "richtext" !== e.target.type || !e.target.attribute.editable);
172
- }
173
- getEventPosition(e) {
174
- const p = this.pluginService.stage.eventPointTransform(e), p1 = {
175
- x: 0,
176
- y: 0
177
- };
178
- return e.target.globalTransMatrix.transformPoint(p, p1), p1;
179
- }
180
- getLineByPoint(cache, p1) {
181
- let lineInfo = cache.lines[0];
182
- for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
183
- return lineInfo;
147
+ context.stage.on("pointerleave", this.handlePointerUp), application.global.addEventListener("keydown", this.handleKeyDown),
148
+ this.editModule.onInput(this.handleInput), this.editModule.onChange(this.handleChange);
184
149
  }
185
- getColumnByLinePoint(lineInfo, p1) {
186
- let columnInfo = lineInfo.paragraphs[0];
187
- for (let i = 0; i < lineInfo.paragraphs.length && !(columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x); i++) columnInfo = lineInfo.paragraphs[i];
188
- return columnInfo;
150
+ deactivate(context) {
151
+ context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown),
152
+ context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp),
153
+ application.global.addEventListener("keydown", this.handleKeyDown);
189
154
  }
190
155
  onFocus(e) {
191
- this.deFocus(e);
156
+ this.deFocus(e), this.currRt = e.target;
192
157
  const target = e.target;
193
- this.tryUpdateRichtext(target);
194
- const shadowRoot = target.attachShadow();
195
- shadowRoot.setAttributes({
196
- shadowRootIdx: -1
197
- });
198
- const cache = target.getFrameCache();
158
+ RichTextEditPlugin.tryUpdateRichtext(target);
159
+ const shadowRoot = target.attachShadow(), cache = target.getFrameCache();
199
160
  if (!cache) return;
200
- if (!this.editLine) {
161
+ if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
162
+ shadowRootIdx: -1,
163
+ x: this.deltaX,
164
+ y: this.deltaY
165
+ }), !this.editLine) {
201
166
  const line = createLine({
202
167
  x: 0,
203
168
  y: 0,
204
169
  lineWidth: 1,
205
170
  stroke: "black"
206
171
  });
207
- line.animate().to({
208
- opacity: 1
209
- }, 10, "linear").wait(700).to({
210
- opacity: 0
211
- }, 10, "linear").wait(700).loop(1 / 0), this.editLine = line;
172
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
212
173
  const g = createGroup({
213
174
  x: 0,
214
175
  y: 0,
@@ -217,28 +178,125 @@ export class RichTextEditPlugin {
217
178
  });
218
179
  this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
219
180
  }
220
- const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
221
- if (lineInfo) {
222
- const columnInfo = this.getColumnByLinePoint(lineInfo, p1);
223
- if (!columnInfo) return;
224
- let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height, x = columnInfo.left + columnInfo.width;
225
- y1 += 2, y2 -= 2;
226
- let cursorIndex = this.getColumnIndex(cache, columnInfo);
227
- p1.x < columnInfo.left + columnInfo.width / 2 && (x = columnInfo.left, cursorIndex -= 1),
228
- this.lastPoint = {
181
+ const data = this.computedCursorPosByEvent(e, cache);
182
+ if (data) {
183
+ const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
184
+ this.startCursorPos = {
229
185
  x: x,
230
186
  y: (y1 + y2) / 2
231
187
  }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
232
188
  this.setCursorAndTextArea(x, y1, y2, target);
233
189
  }
234
190
  }
235
- getPointByColumnIdx(idx, rt, orient) {
236
- const cache = rt.getFrameCache(), {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, idx);
237
- let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
238
- return y1 += 2, y2 -= 2, {
239
- x: columnInfo.left + ("left" === orient ? 0 : columnInfo.width),
240
- y1: y1,
241
- y2: y2
191
+ deFocus(e) {
192
+ const target = this.currRt;
193
+ target && (target.detachShadow(), this.currRt = null, this.editLine && (this.editLine.parent.removeChild(this.editLine),
194
+ this.editLine.release(), this.editLine = null, this.editBg.parent.removeChild(this.editBg),
195
+ this.editBg.release(), this.editBg = null));
196
+ }
197
+ addAnimateToLine(line) {
198
+ line.animates && line.animates.forEach((animate => {
199
+ animate.stop(), animate.release();
200
+ }));
201
+ const animate = line.animate();
202
+ animate.setTimeline(this.timeline), animate.to({
203
+ opacity: 1
204
+ }, 10, "linear").wait(700).to({
205
+ opacity: 0
206
+ }, 10, "linear").wait(700).loop(1 / 0);
207
+ }
208
+ tryShowSelection(e) {
209
+ const cache = e.target.getFrameCache();
210
+ if (!(cache && this.editBg && this.pointerDown && this.startCursorPos)) return;
211
+ let startCursorPos = this.startCursorPos;
212
+ const currCursorData = this.computedCursorPosByEvent(e, cache);
213
+ if (!currCursorData) return;
214
+ this.curCursorIdx = currCursorData.cursorIndex;
215
+ let endCursorPos = {
216
+ x: currCursorData.x,
217
+ y: (currCursorData.y1 + currCursorData.y2) / 2
218
+ }, line0Info = this.getLineByPoint(cache, startCursorPos), line1Info = this.getLineByPoint(cache, endCursorPos);
219
+ if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [ endCursorPos, startCursorPos ],
220
+ [line1Info, line0Info] = [ line0Info, line1Info ]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
221
+ x: startCursorPos.x,
222
+ y: line0Info.top,
223
+ width: endCursorPos.x - startCursorPos.x,
224
+ height: line0Info.height,
225
+ fill: "#336df4",
226
+ fillOpacity: .2
227
+ }); else {
228
+ this.editBg.setAttributes({
229
+ x: 0,
230
+ y: line0Info.top,
231
+ width: 0,
232
+ height: 0
233
+ });
234
+ const startIdx = cache.lines.findIndex((item => item === line0Info)), endIdx = cache.lines.findIndex((item => item === line1Info));
235
+ let y = 0;
236
+ for (let i = startIdx; i <= endIdx; i++) {
237
+ const line = cache.lines[i];
238
+ if (i === startIdx) {
239
+ const p = line.paragraphs[line.paragraphs.length - 1];
240
+ this.editBg.add(createRect({
241
+ x: startCursorPos.x,
242
+ y: y,
243
+ width: p.left + p.width - startCursorPos.x,
244
+ height: line.height,
245
+ fill: "#336df4",
246
+ fillOpacity: .2
247
+ }));
248
+ } else if (i === endIdx) {
249
+ const p = line.paragraphs[0];
250
+ this.editBg.add(createRect({
251
+ x: p.left,
252
+ y: y,
253
+ width: endCursorPos.x - p.left,
254
+ height: line.height,
255
+ fill: "#336df4",
256
+ fillOpacity: .2
257
+ }));
258
+ } else {
259
+ const p0 = line.paragraphs[0], p1 = line.paragraphs[line.paragraphs.length - 1];
260
+ this.editBg.add(createRect({
261
+ x: p0.left,
262
+ y: y,
263
+ width: p1.left + p1.width - p0.left,
264
+ height: line.height,
265
+ fill: "#336df4",
266
+ fillOpacity: .2
267
+ }));
268
+ }
269
+ y += line.height;
270
+ }
271
+ }
272
+ this.setCursorAndTextArea(currCursorData.x, currCursorData.y1 + 2, currCursorData.y2 - 2, e.target),
273
+ this.triggerRender(), this.updateCbs.forEach((cb => cb("selection", this)));
274
+ }
275
+ hideSelection() {
276
+ this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
277
+ fill: "transparent"
278
+ }));
279
+ }
280
+ getLineByPoint(cache, p1) {
281
+ let lineInfo = cache.lines[0];
282
+ for (let i = 0; i < cache.lines.length && !(lineInfo.top <= p1.y && lineInfo.top + lineInfo.height >= p1.y); i++) lineInfo = cache.lines[i + 1];
283
+ return lineInfo;
284
+ }
285
+ getColumnAndIndexByLinePoint(lineInfo, p1) {
286
+ let columnInfo = lineInfo.paragraphs[0], delta = 0;
287
+ if (lineInfo.paragraphs.length) {
288
+ const start = lineInfo.paragraphs[0], end = lineInfo.paragraphs[lineInfo.paragraphs.length - 1];
289
+ p1.x <= start.left ? (delta = -.1, columnInfo = start) : p1.x >= end.left + end.width && (delta = .1,
290
+ columnInfo = end);
291
+ }
292
+ if (!delta) for (let i = 0; i < lineInfo.paragraphs.length; i++) if (columnInfo = lineInfo.paragraphs[i],
293
+ columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x) {
294
+ delta = p1.x > columnInfo.left + columnInfo.width / 2 ? .1 : -.1;
295
+ break;
296
+ }
297
+ return {
298
+ columnInfo: columnInfo,
299
+ delta: delta
242
300
  };
243
301
  }
244
302
  getColumnIndex(cache, cInfo) {
@@ -249,19 +307,25 @@ export class RichTextEditPlugin {
249
307
  }
250
308
  return -1;
251
309
  }
252
- getColumnByIndex(cache, index) {
253
- let inputIndex = -1;
254
- for (let i = 0; i < cache.lines.length; i++) {
255
- const lineInfo = cache.lines[i];
256
- for (let j = 0; j < lineInfo.paragraphs.length; j++) {
257
- const columnInfo = lineInfo.paragraphs[j];
258
- if (inputIndex++, inputIndex === index) return {
259
- lineInfo: lineInfo,
260
- columnInfo: columnInfo
261
- };
262
- }
263
- }
264
- return null;
310
+ isRichtext(e) {
311
+ return !(!e.target || "richtext" !== e.target.type || !e.target.attribute.editable);
312
+ }
313
+ triggerRender() {
314
+ this.pluginService.stage.renderNextFrame();
315
+ }
316
+ computeGlobalDelta(cache) {
317
+ this.deltaX = 0, this.deltaY = 0;
318
+ const height = cache.height, actualHeight = cache.actualHeight, width = cache.lines.reduce(((w, item) => Math.max(w, item.actualWidth)), 0);
319
+ "center" === cache.globalAlign ? this.deltaX = -width / 2 : "right" === cache.globalAlign && (this.deltaX = -width),
320
+ "middle" === cache.verticalDirection ? this.deltaY = height / 2 - actualHeight / 2 : "bottom" === cache.verticalDirection && (this.deltaY = height - actualHeight);
321
+ }
322
+ getEventPosition(e) {
323
+ const p = this.pluginService.stage.eventPointTransform(e), p1 = {
324
+ x: 0,
325
+ y: 0
326
+ };
327
+ return e.target.globalTransMatrix.transformPoint(p, p1), p1.x -= this.deltaX, p1.y -= this.deltaY,
328
+ p1;
265
329
  }
266
330
  setCursorAndTextArea(x, y1, y2, rt) {
267
331
  this.editLine.setAttributes({
@@ -272,7 +336,7 @@ export class RichTextEditPlugin {
272
336
  x: x,
273
337
  y: y2
274
338
  } ]
275
- });
339
+ }), this.addAnimateToLine(this.editLine);
276
340
  const out = {
277
341
  x: 0,
278
342
  y: 0
@@ -284,52 +348,57 @@ export class RichTextEditPlugin {
284
348
  const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
285
349
  out.x += left, out.y += top, this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
286
350
  }
287
- setCursor(x, y1, y2) {
288
- this.editLine.setAttributes({
289
- points: [ {
290
- x: x,
291
- y: y1
292
- }, {
293
- x: x,
294
- y: y2
295
- } ]
296
- });
297
- }
298
- applyUpdate() {
299
- this.pluginService.stage.renderNextFrame();
300
- }
301
- deFocus(e) {
302
- const target = this.currRt;
303
- target && (target.detachShadow(), this.currRt = null, this.editLine && (this.editLine.parent.removeChild(this.editLine),
304
- this.editLine.release(), this.editLine = null, this.editBg.parent.removeChild(this.editBg),
305
- this.editBg.release(), this.editBg = null));
351
+ computedCursorPosByEvent(e, cache) {
352
+ const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
353
+ if (!lineInfo) return;
354
+ const {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(lineInfo, p1);
355
+ if (!columnInfo) return;
356
+ let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
357
+ y1 += 2, y2 -= 2;
358
+ let cursorIndex = this.getColumnIndex(cache, columnInfo);
359
+ cursorIndex += delta;
360
+ return {
361
+ x: columnInfo.left + (delta > 0 ? columnInfo.width : 0),
362
+ y1: y1,
363
+ y2: y2,
364
+ cursorIndex: cursorIndex
365
+ };
306
366
  }
307
- splitText(text) {
308
- return Array.from(text);
367
+ computedCursorPosByCursorIdx(cursorIdx, rt) {
368
+ var _a, _b, _c;
369
+ const idx = Math.round(cursorIdx), leftRight = cursorIdx - idx, cache = rt.getFrameCache(), column = this.getColumnByIndex(cache, idx), height = null !== (_a = rt.attribute.fontSize) && void 0 !== _a ? _a : null === (_c = null === (_b = rt.attribute.textConfig) || void 0 === _b ? void 0 : _b[0]) || void 0 === _c ? void 0 : _c.fontSize;
370
+ if (!column) return {
371
+ x: 0,
372
+ y1: 0,
373
+ y2: height
374
+ };
375
+ const {lineInfo: lineInfo, columnInfo: columnInfo} = column;
376
+ let y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
377
+ return y1 += 2, y2 -= 2, {
378
+ x: columnInfo.left + (leftRight < 0 ? 0 : columnInfo.width),
379
+ y1: y1,
380
+ y2: y2
381
+ };
309
382
  }
310
- tryUpdateRichtext(richtext) {
311
- if (!richtext.getFrameCache().lines.every((line => line.paragraphs.every((item => !(item.text && isString(item.text) && this.splitText(item.text).length > 1)))))) {
312
- const tc = [];
313
- richtext.attribute.textConfig.forEach((item => {
314
- const textList = this.splitText(item.text.toString());
315
- if (isString(item.text) && textList.length > 1) for (let i = 0; i < textList.length; i++) {
316
- const t = textList[i];
317
- tc.push(Object.assign(Object.assign({}, item), {
318
- text: t
319
- }));
320
- } else tc.push(item);
321
- })), richtext.setAttributes({
322
- textConfig: tc
323
- }), richtext.doUpdateFrameCache(tc);
383
+ getColumnByIndex(cache, index) {
384
+ for (let i = 0, inputIndex = 0; i < cache.lines.length; i++) {
385
+ const lineInfo = cache.lines[i];
386
+ for (let j = 0; j < lineInfo.paragraphs.length; j++) {
387
+ const columnInfo = lineInfo.paragraphs[j];
388
+ if (inputIndex === index) return {
389
+ lineInfo: lineInfo,
390
+ columnInfo: columnInfo
391
+ };
392
+ inputIndex++;
393
+ }
324
394
  }
325
- }
326
- onSelect() {}
327
- deactivate(context) {
328
- context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown),
329
- context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp);
395
+ return null;
330
396
  }
331
397
  release() {
332
- this.editModule.release();
398
+ this.deactivate(this.pluginService), this.editModule.release();
399
+ }
400
+ getSelection(defaultAll = !1) {
401
+ return this.currRt ? null != this.selectionStartCursorIdx && null != this.curCursorIdx ? new Selection(this.selectionStartCursorIdx, this.curCursorIdx, this.currRt) : defaultAll ? RichTextEditPlugin.CreateSelection(this.currRt) : null : null;
333
402
  }
334
403
  }
335
404
  //# sourceMappingURL=richtext-edit-plugin.js.map