@visactor/vrender-core 0.21.11 → 0.22.0-vstory.2

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 (376) hide show
  1. package/cjs/animate/Ticker/default-ticker.d.ts +2 -0
  2. package/cjs/animate/Ticker/default-ticker.js +7 -1
  3. package/cjs/animate/Ticker/default-ticker.js.map +1 -1
  4. package/cjs/animate/animate.js +2 -2
  5. package/cjs/animate/animate.js.map +1 -1
  6. package/cjs/animate/custom-animate.js +14 -25
  7. package/cjs/animate/custom-animate.js.map +1 -1
  8. package/cjs/animate/easing-func.d.ts +1 -0
  9. package/cjs/animate/easing-func.js +16 -0
  10. package/cjs/animate/easing-func.js.map +1 -0
  11. package/cjs/animate/easing.d.ts +4 -0
  12. package/cjs/animate/easing.js +24 -1
  13. package/cjs/animate/easing.js.map +1 -1
  14. package/cjs/animate/index.d.ts +1 -0
  15. package/cjs/animate/index.js +1 -1
  16. package/cjs/animate/index.js.map +1 -1
  17. package/cjs/color-string/store.js +1 -2
  18. package/cjs/common/3d-interceptor.js +2 -1
  19. package/cjs/common/bezier-utils.d.ts +3 -0
  20. package/cjs/common/bezier-utils.js +17 -2
  21. package/cjs/common/bezier-utils.js.map +1 -1
  22. package/cjs/common/custom-path2d.d.ts +4 -0
  23. package/cjs/common/custom-path2d.js +43 -11
  24. package/cjs/common/custom-path2d.js.map +1 -1
  25. package/cjs/common/render-area.d.ts +4 -0
  26. package/cjs/common/render-area.js +76 -17
  27. package/cjs/common/render-area.js.map +1 -1
  28. package/cjs/common/render-command-list.js +2 -1
  29. package/cjs/common/render-curve.d.ts +1 -1
  30. package/cjs/common/render-curve.js.map +1 -1
  31. package/cjs/common/segment/curve/arc.d.ts +4 -1
  32. package/cjs/common/segment/curve/arc.js +10 -1
  33. package/cjs/common/segment/curve/arc.js.map +1 -1
  34. package/cjs/common/segment/curve/base.d.ts +4 -1
  35. package/cjs/common/segment/curve/base.js.map +1 -1
  36. package/cjs/common/segment/curve/cubic-bezier.d.ts +5 -1
  37. package/cjs/common/segment/curve/cubic-bezier.js +24 -3
  38. package/cjs/common/segment/curve/cubic-bezier.js.map +1 -1
  39. package/cjs/common/segment/curve/curve-context.js +5 -4
  40. package/cjs/common/segment/curve/curve-context.js.map +1 -1
  41. package/cjs/common/segment/curve/ellipse.d.ts +4 -1
  42. package/cjs/common/segment/curve/ellipse.js +9 -0
  43. package/cjs/common/segment/curve/ellipse.js.map +1 -1
  44. package/cjs/common/segment/curve/line.d.ts +4 -1
  45. package/cjs/common/segment/curve/line.js +18 -0
  46. package/cjs/common/segment/curve/line.js.map +1 -1
  47. package/cjs/common/segment/curve/move.d.ts +4 -1
  48. package/cjs/common/segment/curve/move.js +9 -0
  49. package/cjs/common/segment/curve/move.js.map +1 -1
  50. package/cjs/common/segment/curve/path.d.ts +2 -1
  51. package/cjs/common/segment/curve/path.js +5 -2
  52. package/cjs/common/segment/curve/path.js.map +1 -1
  53. package/cjs/common/segment/curve/quadratic-bezier.d.ts +6 -2
  54. package/cjs/common/segment/curve/quadratic-bezier.js +23 -5
  55. package/cjs/common/segment/curve/quadratic-bezier.js.map +1 -1
  56. package/cjs/common/segment/step.js +1 -1
  57. package/cjs/common/segment/step.js.map +1 -1
  58. package/cjs/common/shape/rect.d.ts +1 -1
  59. package/cjs/common/shape/rect.js +30 -25
  60. package/cjs/common/shape/rect.js.map +1 -1
  61. package/cjs/common/store.js +1 -1
  62. package/cjs/core/contributions/env/base-contribution.d.ts +2 -0
  63. package/cjs/core/contributions/env/base-contribution.js +6 -0
  64. package/cjs/core/contributions/env/base-contribution.js.map +1 -1
  65. package/cjs/core/global.d.ts +2 -3
  66. package/cjs/core/global.js +7 -7
  67. package/cjs/core/global.js.map +1 -1
  68. package/cjs/graphic/builtin-symbol/rect.d.ts +2 -1
  69. package/cjs/graphic/builtin-symbol/rect.js +28 -0
  70. package/cjs/graphic/builtin-symbol/rect.js.map +1 -1
  71. package/cjs/graphic/builtin-symbol/utils.d.ts +2 -1
  72. package/cjs/graphic/builtin-symbol/utils.js +5 -0
  73. package/cjs/graphic/builtin-symbol/utils.js.map +1 -1
  74. package/cjs/graphic/config.js +20 -5
  75. package/cjs/graphic/config.js.map +1 -1
  76. package/cjs/graphic/graphic.d.ts +1 -1
  77. package/cjs/graphic/graphic.js +20 -6
  78. package/cjs/graphic/graphic.js.map +1 -1
  79. package/cjs/graphic/line.js +2 -2
  80. package/cjs/graphic/line.js.map +1 -1
  81. package/cjs/graphic/richtext/line.js +1 -1
  82. package/cjs/graphic/richtext/line.js.map +1 -1
  83. package/cjs/graphic/richtext/paragraph.d.ts +1 -1
  84. package/cjs/graphic/richtext/paragraph.js +37 -7
  85. package/cjs/graphic/richtext/paragraph.js.map +1 -1
  86. package/cjs/graphic/richtext/utils.d.ts +4 -0
  87. package/cjs/graphic/richtext/utils.js +19 -6
  88. package/cjs/graphic/richtext/utils.js.map +1 -1
  89. package/cjs/graphic/richtext/wrapper.d.ts +1 -0
  90. package/cjs/graphic/richtext/wrapper.js +1 -1
  91. package/cjs/graphic/richtext/wrapper.js.map +1 -1
  92. package/cjs/graphic/richtext.d.ts +7 -2
  93. package/cjs/graphic/richtext.js +37 -4
  94. package/cjs/graphic/richtext.js.map +1 -1
  95. package/cjs/index.d.ts +2 -0
  96. package/cjs/index.js +2 -1
  97. package/cjs/index.js.map +1 -1
  98. package/cjs/interface/animate.d.ts +5 -39
  99. package/cjs/interface/animate.js.map +1 -1
  100. package/cjs/interface/color.js.map +1 -1
  101. package/cjs/interface/context.d.ts +1 -0
  102. package/cjs/interface/context.js.map +1 -1
  103. package/cjs/interface/global.d.ts +4 -1
  104. package/cjs/interface/global.js.map +1 -1
  105. package/cjs/interface/graphic/group.d.ts +1 -0
  106. package/cjs/interface/graphic/group.js.map +1 -1
  107. package/cjs/interface/graphic/image.d.ts +1 -0
  108. package/cjs/interface/graphic/image.js.map +1 -1
  109. package/cjs/interface/graphic/path.d.ts +1 -0
  110. package/cjs/interface/graphic/path.js.map +1 -1
  111. package/cjs/interface/graphic/rect.d.ts +1 -0
  112. package/cjs/interface/graphic/rect.js.map +1 -1
  113. package/cjs/interface/graphic/richText.d.ts +12 -0
  114. package/cjs/interface/graphic/richText.js.map +1 -1
  115. package/cjs/interface/graphic/symbol.d.ts +2 -0
  116. package/cjs/interface/graphic/symbol.js.map +1 -1
  117. package/cjs/interface/graphic.d.ts +12 -3
  118. package/cjs/interface/graphic.js.map +1 -1
  119. package/cjs/interface/path.d.ts +5 -0
  120. package/cjs/interface/path.js.map +1 -1
  121. package/cjs/interface/picker.d.ts +13 -0
  122. package/cjs/interface/picker.js.map +1 -1
  123. package/cjs/picker/constants.d.ts +2 -0
  124. package/cjs/picker/constants.js +3 -2
  125. package/cjs/picker/constants.js.map +1 -1
  126. package/cjs/picker/pick-interceptor.d.ts +7 -2
  127. package/cjs/picker/pick-interceptor.js +19 -2
  128. package/cjs/picker/pick-interceptor.js.map +1 -1
  129. package/cjs/picker/pick-modules.js +7 -4
  130. package/cjs/picker/pick-modules.js.map +1 -1
  131. package/cjs/picker/picker-service.d.ts +4 -2
  132. package/cjs/picker/picker-service.js +13 -12
  133. package/cjs/picker/picker-service.js.map +1 -1
  134. package/cjs/plugins/builtin-plugin/edit-module.d.ts +17 -6
  135. package/cjs/plugins/builtin-plugin/edit-module.js +128 -42
  136. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  137. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  138. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  139. package/cjs/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  140. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +88 -31
  141. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +537 -229
  142. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  143. package/cjs/render/contributions/render/arc3d-render.js.map +1 -1
  144. package/cjs/render/contributions/render/area-render.d.ts +1 -1
  145. package/cjs/render/contributions/render/area-render.js +36 -16
  146. package/cjs/render/contributions/render/area-render.js.map +1 -1
  147. package/cjs/render/contributions/render/base-render.d.ts +1 -0
  148. package/cjs/render/contributions/render/base-render.js +20 -2
  149. package/cjs/render/contributions/render/base-render.js.map +1 -1
  150. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
  151. package/cjs/render/contributions/render/contributions/base-contribution-render.js +16 -8
  152. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  153. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  154. package/cjs/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  155. package/cjs/render/contributions/render/contributions/group-contribution-render.js +8 -3
  156. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  157. package/cjs/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  158. package/cjs/render/contributions/render/contributions/image-contribution-render.js +2 -2
  159. package/cjs/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  160. package/cjs/render/contributions/render/contributions/rect-contribution-render.js +4 -4
  161. package/cjs/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  162. package/cjs/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  163. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js +30 -2
  164. package/cjs/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  165. package/cjs/render/contributions/render/contributions/text-contribution-render.js +5 -3
  166. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  167. package/cjs/render/contributions/render/draw-contribution.js +2 -1
  168. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  169. package/cjs/render/contributions/render/group-render.js +2 -2
  170. package/cjs/render/contributions/render/group-render.js.map +1 -1
  171. package/cjs/render/contributions/render/image-render.js +3 -3
  172. package/cjs/render/contributions/render/image-render.js.map +1 -1
  173. package/cjs/render/contributions/render/line-render.js +31 -9
  174. package/cjs/render/contributions/render/line-render.js.map +1 -1
  175. package/cjs/render/contributions/render/path-render.js.map +1 -1
  176. package/cjs/render/contributions/render/polygon-render.js.map +1 -1
  177. package/cjs/render/contributions/render/rect-render.js +2 -2
  178. package/cjs/render/contributions/render/rect-render.js.map +1 -1
  179. package/cjs/render/contributions/render/richtext-render.js +1 -1
  180. package/cjs/render/contributions/render/richtext-render.js.map +1 -1
  181. package/cjs/render/contributions/render/symbol-render.js +15 -13
  182. package/cjs/render/contributions/render/symbol-render.js.map +1 -1
  183. package/cjs/render/contributions/render/utils.d.ts +1 -2
  184. package/cjs/render/contributions/render/utils.js +4 -20
  185. package/cjs/render/contributions/render/utils.js.map +1 -1
  186. package/cjs/resource-loader/loader.js +1 -1
  187. package/cjs/resource-loader/loader.js.map +1 -1
  188. package/dist/index.es.js +8962 -7480
  189. package/es/animate/Ticker/default-ticker.d.ts +2 -0
  190. package/es/animate/Ticker/default-ticker.js +7 -1
  191. package/es/animate/Ticker/default-ticker.js.map +1 -1
  192. package/es/animate/animate.js +4 -5
  193. package/es/animate/animate.js.map +1 -1
  194. package/es/animate/custom-animate.js +14 -25
  195. package/es/animate/custom-animate.js.map +1 -1
  196. package/es/animate/easing-func.d.ts +1 -0
  197. package/es/animate/easing-func.js +10 -0
  198. package/es/animate/easing-func.js.map +1 -0
  199. package/es/animate/easing.d.ts +4 -0
  200. package/es/animate/easing.js +24 -1
  201. package/es/animate/easing.js.map +1 -1
  202. package/es/animate/index.d.ts +1 -0
  203. package/es/animate/index.js +2 -0
  204. package/es/animate/index.js.map +1 -1
  205. package/es/color-string/store.js +1 -2
  206. package/es/common/3d-interceptor.js +2 -1
  207. package/es/common/bezier-utils.d.ts +3 -0
  208. package/es/common/bezier-utils.js +14 -0
  209. package/es/common/bezier-utils.js.map +1 -1
  210. package/es/common/custom-path2d.d.ts +4 -0
  211. package/es/common/custom-path2d.js +44 -12
  212. package/es/common/custom-path2d.js.map +1 -1
  213. package/es/common/render-area.d.ts +4 -0
  214. package/es/common/render-area.js +77 -18
  215. package/es/common/render-area.js.map +1 -1
  216. package/es/common/render-command-list.js +2 -1
  217. package/es/common/render-curve.d.ts +1 -1
  218. package/es/common/render-curve.js.map +1 -1
  219. package/es/common/segment/curve/arc.d.ts +4 -1
  220. package/es/common/segment/curve/arc.js +10 -1
  221. package/es/common/segment/curve/arc.js.map +1 -1
  222. package/es/common/segment/curve/base.d.ts +4 -1
  223. package/es/common/segment/curve/base.js.map +1 -1
  224. package/es/common/segment/curve/cubic-bezier.d.ts +5 -1
  225. package/es/common/segment/curve/cubic-bezier.js +22 -1
  226. package/es/common/segment/curve/cubic-bezier.js.map +1 -1
  227. package/es/common/segment/curve/curve-context.js +6 -3
  228. package/es/common/segment/curve/curve-context.js.map +1 -1
  229. package/es/common/segment/curve/ellipse.d.ts +4 -1
  230. package/es/common/segment/curve/ellipse.js +9 -0
  231. package/es/common/segment/curve/ellipse.js.map +1 -1
  232. package/es/common/segment/curve/line.d.ts +4 -1
  233. package/es/common/segment/curve/line.js +18 -0
  234. package/es/common/segment/curve/line.js.map +1 -1
  235. package/es/common/segment/curve/move.d.ts +4 -1
  236. package/es/common/segment/curve/move.js +9 -0
  237. package/es/common/segment/curve/move.js.map +1 -1
  238. package/es/common/segment/curve/path.d.ts +2 -1
  239. package/es/common/segment/curve/path.js +5 -2
  240. package/es/common/segment/curve/path.js.map +1 -1
  241. package/es/common/segment/curve/quadratic-bezier.d.ts +6 -2
  242. package/es/common/segment/curve/quadratic-bezier.js +28 -5
  243. package/es/common/segment/curve/quadratic-bezier.js.map +1 -1
  244. package/es/common/segment/step.js +1 -1
  245. package/es/common/segment/step.js.map +1 -1
  246. package/es/common/shape/rect.d.ts +1 -1
  247. package/es/common/shape/rect.js +30 -25
  248. package/es/common/shape/rect.js.map +1 -1
  249. package/es/common/store.js +1 -1
  250. package/es/core/contributions/env/base-contribution.d.ts +2 -0
  251. package/es/core/contributions/env/base-contribution.js +6 -0
  252. package/es/core/contributions/env/base-contribution.js.map +1 -1
  253. package/es/core/global.d.ts +2 -3
  254. package/es/core/global.js +7 -8
  255. package/es/core/global.js.map +1 -1
  256. package/es/graphic/builtin-symbol/rect.d.ts +2 -1
  257. package/es/graphic/builtin-symbol/rect.js +28 -0
  258. package/es/graphic/builtin-symbol/rect.js.map +1 -1
  259. package/es/graphic/builtin-symbol/utils.d.ts +2 -1
  260. package/es/graphic/builtin-symbol/utils.js +5 -0
  261. package/es/graphic/builtin-symbol/utils.js.map +1 -1
  262. package/es/graphic/config.js +20 -5
  263. package/es/graphic/config.js.map +1 -1
  264. package/es/graphic/graphic.d.ts +1 -1
  265. package/es/graphic/graphic.js +20 -6
  266. package/es/graphic/graphic.js.map +1 -1
  267. package/es/graphic/line.js +2 -2
  268. package/es/graphic/line.js.map +1 -1
  269. package/es/graphic/richtext/line.js +1 -1
  270. package/es/graphic/richtext/line.js.map +1 -1
  271. package/es/graphic/richtext/paragraph.d.ts +1 -1
  272. package/es/graphic/richtext/paragraph.js +37 -7
  273. package/es/graphic/richtext/paragraph.js.map +1 -1
  274. package/es/graphic/richtext/utils.d.ts +4 -0
  275. package/es/graphic/richtext/utils.js +15 -2
  276. package/es/graphic/richtext/utils.js.map +1 -1
  277. package/es/graphic/richtext/wrapper.d.ts +1 -0
  278. package/es/graphic/richtext/wrapper.js +1 -1
  279. package/es/graphic/richtext/wrapper.js.map +1 -1
  280. package/es/graphic/richtext.d.ts +7 -2
  281. package/es/graphic/richtext.js +37 -5
  282. package/es/graphic/richtext.js.map +1 -1
  283. package/es/index.d.ts +2 -0
  284. package/es/index.js +4 -0
  285. package/es/index.js.map +1 -1
  286. package/es/interface/animate.d.ts +5 -39
  287. package/es/interface/animate.js.map +1 -1
  288. package/es/interface/color.js.map +1 -1
  289. package/es/interface/context.d.ts +1 -0
  290. package/es/interface/context.js.map +1 -1
  291. package/es/interface/global.d.ts +4 -1
  292. package/es/interface/global.js.map +1 -1
  293. package/es/interface/graphic/group.d.ts +1 -0
  294. package/es/interface/graphic/group.js.map +1 -1
  295. package/es/interface/graphic/image.d.ts +1 -0
  296. package/es/interface/graphic/image.js.map +1 -1
  297. package/es/interface/graphic/path.d.ts +1 -0
  298. package/es/interface/graphic/path.js.map +1 -1
  299. package/es/interface/graphic/rect.d.ts +1 -0
  300. package/es/interface/graphic/rect.js.map +1 -1
  301. package/es/interface/graphic/richText.d.ts +12 -0
  302. package/es/interface/graphic/richText.js.map +1 -1
  303. package/es/interface/graphic/symbol.d.ts +2 -0
  304. package/es/interface/graphic/symbol.js.map +1 -1
  305. package/es/interface/graphic.d.ts +12 -3
  306. package/es/interface/graphic.js.map +1 -1
  307. package/es/interface/path.d.ts +5 -0
  308. package/es/interface/path.js.map +1 -1
  309. package/es/interface/picker.d.ts +13 -0
  310. package/es/interface/picker.js.map +1 -1
  311. package/es/picker/constants.d.ts +2 -0
  312. package/es/picker/constants.js +4 -0
  313. package/es/picker/constants.js.map +1 -1
  314. package/es/picker/pick-interceptor.d.ts +7 -2
  315. package/es/picker/pick-interceptor.js +19 -1
  316. package/es/picker/pick-interceptor.js.map +1 -1
  317. package/es/picker/pick-modules.js +5 -3
  318. package/es/picker/pick-modules.js.map +1 -1
  319. package/es/picker/picker-service.d.ts +4 -2
  320. package/es/picker/picker-service.js +13 -13
  321. package/es/picker/picker-service.js.map +1 -1
  322. package/es/plugins/builtin-plugin/edit-module.d.ts +17 -6
  323. package/es/plugins/builtin-plugin/edit-module.js +123 -40
  324. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  325. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.d.ts +1 -0
  326. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js +3 -0
  327. package/es/plugins/builtin-plugin/richtext-edit-plugin-old.js.map +1 -0
  328. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +88 -31
  329. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +538 -225
  330. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  331. package/es/render/contributions/render/arc3d-render.js.map +1 -1
  332. package/es/render/contributions/render/area-render.d.ts +1 -1
  333. package/es/render/contributions/render/area-render.js +36 -16
  334. package/es/render/contributions/render/area-render.js.map +1 -1
  335. package/es/render/contributions/render/base-render.d.ts +1 -0
  336. package/es/render/contributions/render/base-render.js +21 -2
  337. package/es/render/contributions/render/base-render.js.map +1 -1
  338. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +7 -1
  339. package/es/render/contributions/render/contributions/base-contribution-render.js +16 -8
  340. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  341. package/es/render/contributions/render/contributions/base-texture-contribution-render.js +29 -2
  342. package/es/render/contributions/render/contributions/base-texture-contribution-render.js.map +1 -1
  343. package/es/render/contributions/render/contributions/group-contribution-render.js +8 -3
  344. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  345. package/es/render/contributions/render/contributions/image-contribution-render.d.ts +1 -1
  346. package/es/render/contributions/render/contributions/image-contribution-render.js +2 -2
  347. package/es/render/contributions/render/contributions/image-contribution-render.js.map +1 -1
  348. package/es/render/contributions/render/contributions/rect-contribution-render.js +4 -4
  349. package/es/render/contributions/render/contributions/rect-contribution-render.js.map +1 -1
  350. package/es/render/contributions/render/contributions/symbol-contribution-render.d.ts +8 -1
  351. package/es/render/contributions/render/contributions/symbol-contribution-render.js +26 -0
  352. package/es/render/contributions/render/contributions/symbol-contribution-render.js.map +1 -1
  353. package/es/render/contributions/render/contributions/text-contribution-render.js +5 -3
  354. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  355. package/es/render/contributions/render/draw-contribution.js +1 -1
  356. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  357. package/es/render/contributions/render/group-render.js +2 -2
  358. package/es/render/contributions/render/group-render.js.map +1 -1
  359. package/es/render/contributions/render/image-render.js +3 -2
  360. package/es/render/contributions/render/image-render.js.map +1 -1
  361. package/es/render/contributions/render/line-render.js +31 -9
  362. package/es/render/contributions/render/line-render.js.map +1 -1
  363. package/es/render/contributions/render/path-render.js.map +1 -1
  364. package/es/render/contributions/render/polygon-render.js.map +1 -1
  365. package/es/render/contributions/render/rect-render.js +2 -2
  366. package/es/render/contributions/render/rect-render.js.map +1 -1
  367. package/es/render/contributions/render/richtext-render.js +1 -1
  368. package/es/render/contributions/render/richtext-render.js.map +1 -1
  369. package/es/render/contributions/render/symbol-render.js +16 -14
  370. package/es/render/contributions/render/symbol-render.js.map +1 -1
  371. package/es/render/contributions/render/utils.d.ts +1 -2
  372. package/es/render/contributions/render/utils.js +0 -18
  373. package/es/render/contributions/render/utils.js.map +1 -1
  374. package/es/resource-loader/loader.js +1 -1
  375. package/es/resource-loader/loader.js.map +1 -1
  376. package/package.json +1 -1
@@ -1,81 +1,135 @@
1
- import { isObject, isString, merge } from "@visactor/vutils";
1
+ import { isObject, merge } from "@visactor/vutils";
2
2
 
3
3
  import { Generator } from "../../common/generator";
4
4
 
5
- import { createGroup, createLine, createRect } from "../../graphic";
5
+ import { createGroup, createLine, createRect, createRichText, getRichTextBounds, RichText } from "../../graphic";
6
6
 
7
- import { EditModule, findCursorIndexIgnoreLinebreak } from "./edit-module";
7
+ import { DefaultTicker, DefaultTimeline } from "../../animate";
8
+
9
+ import { EditModule, findConfigIndexByCursorIdx, getDefaultCharacterConfig } from "./edit-module";
10
+
11
+ import { application } from "../../application";
12
+
13
+ import { getWordStartEndIdx } from "../../graphic/richtext/utils";
8
14
 
9
15
  class Selection {
10
- constructor(cacheSelectionStartCursorIdx, cacheCurCursorIdx, selectionStartCursorIdx, curCursorIdx, rt) {
16
+ constructor(selectionStartCursorIdx, curCursorIdx, rt) {
11
17
  this.curCursorIdx = curCursorIdx, this.selectionStartCursorIdx = selectionStartCursorIdx,
12
- this.cacheCurCursorIdx = cacheCurCursorIdx, this.cacheSelectionStartCursorIdx = cacheSelectionStartCursorIdx,
13
18
  this.rt = rt;
14
19
  }
20
+ isEmpty() {
21
+ return this.selectionStartCursorIdx === this.curCursorIdx;
22
+ }
23
+ getSelectionPureText() {
24
+ const minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
25
+ if (minCursorIdx === maxCursorIdx) return "";
26
+ const config = this.rt.attribute.textConfig, startIdx = findConfigIndexByCursorIdx(config, Math.ceil(minCursorIdx)), endIdx = findConfigIndexByCursorIdx(config, Math.floor(maxCursorIdx));
27
+ let str = "";
28
+ for (let i = startIdx; i <= endIdx; i++) str += config[i].text;
29
+ return str;
30
+ }
15
31
  hasFormat(key) {
16
32
  return null != this.getFormat(key);
17
33
  }
18
- getFormat(key) {
34
+ _getFormat(key, cursorIdx) {
35
+ var _a;
19
36
  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;
37
+ let idx = Math.round(cursorIdx);
38
+ const config = this.rt.attribute.textConfig;
39
+ if (!config.length) return null;
40
+ for (let i = 0; i < config.length; i++) if ("\n" !== config[i].text && (idx--, idx < 0)) return config[i][key];
41
+ return null !== (_a = config[Math.min(idx, config.length - 1)][key]) && void 0 !== _a ? _a : this.rt.attribute[key];
42
+ }
43
+ getFormat(key) {
44
+ return this.getAllFormat(key)[0];
26
45
  }
27
46
  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]);
47
+ const valSet = new Set, minCursorIdx = Math.min(this.selectionStartCursorIdx, this.curCursorIdx), maxCursorIdx = Math.max(this.selectionStartCursorIdx, this.curCursorIdx);
48
+ if (minCursorIdx === maxCursorIdx) return [ this._getFormat(key, minCursorIdx) ];
49
+ for (let i = Math.ceil(minCursorIdx); i <= Math.floor(maxCursorIdx); i++) {
50
+ const val = this._getFormat(key, i);
51
+ val && valSet.add(val);
34
52
  }
35
- return Array.from(set.values());
53
+ return Array.from(valSet.values());
36
54
  }
37
55
  }
38
56
 
39
57
  export const FORMAT_TEXT_COMMAND = "FORMAT_TEXT_COMMAND";
40
58
 
59
+ export const FORMAT_ALL_TEXT_COMMAND = "FORMAT_ALL_TEXT_COMMAND";
60
+
41
61
  export const FORMAT_ELEMENT_COMMAND = "FORMAT_ELEMENT_COMMAND";
42
62
 
43
63
  export class RichTextEditPlugin {
64
+ static tryUpdateRichtext(richtext) {
65
+ const cache = richtext.getFrameCache();
66
+ if (!RichText.AllSingleCharacter(cache)) {
67
+ const tc = RichText.TransformTextConfig2SingleCharacter(richtext.attribute.textConfig);
68
+ richtext.setAttributes({
69
+ textConfig: tc
70
+ }), richtext.doUpdateFrameCache(tc);
71
+ }
72
+ }
73
+ static CreateSelection(rt) {
74
+ if (!rt) return null;
75
+ const {textConfig: textConfig = []} = rt.attribute;
76
+ return new Selection(0, textConfig.length - 1, rt);
77
+ }
44
78
  constructor() {
45
79
  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)));
80
+ this.key = this.name + this._uid, this.editing = !1, this.focusing = !1, this.pointerDown = !1,
81
+ this.formatTextCommandCb = (payload, p) => {
82
+ const rt = p.currRt;
83
+ if (!rt) return;
84
+ const selectionData = p.getSelection();
85
+ if (!selectionData) return;
86
+ const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, minCursorIdx = Math.min(selectionStartCursorIdx, curCursorIdx), maxCursorIdx = Math.max(selectionStartCursorIdx, curCursorIdx), minConfigIdx = findConfigIndexByCursorIdx(rt.attribute.textConfig, minCursorIdx), maxConfigIdx = findConfigIndexByCursorIdx(rt.attribute.textConfig, maxCursorIdx), config = rt.attribute.textConfig.slice(minConfigIdx, maxConfigIdx);
87
+ this._formatTextCommand(payload, config, rt);
88
+ }, this.formatAllTextCommandCb = (payload, p) => {
89
+ const rt = p.currRt;
90
+ if (!rt) return;
91
+ const config = rt.attribute.textConfig;
92
+ this._formatTextCommand(payload, config, rt);
93
+ }, this.handleKeyDown = e => {
94
+ this.currRt && this.editing && (this.copyToClipboard(e) || this.fullSelection(e) || this.directKey(e));
95
+ }, this.handleInput = (text, isComposing, cursorIdx, rt) => {
96
+ this.currRt && (this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.hideSelection(),
97
+ this.updateCbs.forEach((cb => cb("input", this))));
98
+ }, this.handleChange = (text, isComposing, cursorIdx, rt) => {
99
+ if (!this.currRt) return;
100
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.curCursorIdx = cursorIdx,
101
+ this.selectionStartCursorIdx = cursorIdx;
102
+ const p = this.computedCursorPosByCursorIdx(cursorIdx, rt);
103
+ this.setCursorAndTextArea(p.x, p.y1, p.y2, rt), this.hideSelection(), this.updateCbs.forEach((cb => cb("change", this)));
104
+ }, this.handleFocusIn = () => {
105
+ throw new Error("不会走到这里 handleFocusIn");
106
+ }, this.handleFocusOut = () => {
107
+ throw new Error("不会走到这里 handleFocusOut");
53
108
  }, this.handleMove = e => {
54
109
  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;
110
+ this.tryShowSelection(e, !1));
61
111
  }, this.handleEnter = e => {
62
112
  this.editing = !0, this.pluginService.stage.setCursor("text");
63
113
  }, this.handleLeave = e => {
64
114
  this.editing = !1, this.pluginService.stage.setCursor("default");
115
+ }, this.handlePointerDown = e => {
116
+ this.editing ? this.onFocus(e) : this.deFocus(!0), this.triggerRender(), this.pointerDown = !0,
117
+ this.updateCbs.forEach((cb => cb(this.editing ? "onfocus" : "defocus", this)));
118
+ }, this.handlePointerUp = e => {
119
+ this.pointerDown = !1;
120
+ }, this.handleDBLClick = e => {
121
+ this.editing && this.tryShowSelection(e, !0);
65
122
  }, 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;
123
+ this.commandCbs.set(FORMAT_ALL_TEXT_COMMAND, [ this.formatAllTextCommandCb ]), this.updateCbs = [],
124
+ this.timeline = new DefaultTimeline, this.ticker = new DefaultTicker([ this.timeline ]),
125
+ this.deltaX = 0, this.deltaY = 0;
70
126
  }
71
- formatTextCommandCb(payload, p) {
72
- const rt = p.currRt;
73
- if (!rt) return;
74
- const selectionData = p.getSelection();
75
- if (!selectionData) return;
76
- const {selectionStartCursorIdx: selectionStartCursorIdx, curCursorIdx: curCursorIdx} = selectionData, config = rt.attribute.textConfig.slice(selectionStartCursorIdx + 1, curCursorIdx + 1);
127
+ _formatTextCommand(payload, config, rt) {
77
128
  "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
129
  rt.setAttributes(rt.attribute);
130
+ const cache = rt.getFrameCache();
131
+ cache && (this.selectionRangeByCursorIdx(this.selectionStartCursorIdx, this.curCursorIdx, cache),
132
+ this.tryShowInputBounds());
79
133
  }
80
134
  dispatchCommand(command, payload) {
81
135
  const cbs = this.commandCbs.get(command);
@@ -84,161 +138,363 @@ export class RichTextEditPlugin {
84
138
  registerCommand(command, cb) {
85
139
  (this.commandCbs.get(command) || []).push(cb);
86
140
  }
141
+ removeCommand(command, cb) {
142
+ const cbs = this.commandCbs.get(command) || [], idx = cbs.indexOf(cb);
143
+ idx > -1 && cbs.splice(idx, 1);
144
+ }
87
145
  registerUpdateListener(cb) {
88
146
  (this.updateCbs || []).push(cb);
89
147
  }
148
+ removeUpdateListener(cb) {
149
+ const cbs = this.updateCbs || [], idx = cbs.indexOf(cb);
150
+ idx > -1 && cbs.splice(idx, 1);
151
+ }
90
152
  activate(context) {
91
153
  this.pluginService = context, this.editModule = new EditModule, context.stage.on("pointermove", this.handleMove),
92
154
  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);
155
+ context.stage.on("pointerleave", this.handlePointerUp), context.stage.on("dblclick", this.handleDBLClick),
156
+ application.global.addEventListener("keydown", this.handleKeyDown), this.editModule.onInput(this.handleInput),
157
+ this.editModule.onChange(this.handleChange), this.editModule.onFocusOut(this.handleFocusOut);
95
158
  }
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
159
+ copyToClipboard(e) {
160
+ if (application.global.isMacOS() && e.metaKey && "c" === e.key || !application.global.isMacOS() && e.ctrlKey && "c" === e.key) {
161
+ const text = this.getSelection().getSelectionPureText();
162
+ return application.global.copyToClipBoard(text), e.preventDefault(), !0;
163
+ }
164
+ return !1;
165
+ }
166
+ selectionRange(startIdx, endIdx) {
167
+ const currRt = this.currRt;
168
+ if (!currRt) return;
169
+ const cache = currRt.getFrameCache();
170
+ if (!cache) return;
171
+ const {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
172
+ startIdx > endIdx && ([startIdx, endIdx] = [ endIdx, startIdx ]), startIdx = Math.min(Math.max(startIdx, -.1), totalCursorCount + .1),
173
+ endIdx = Math.min(Math.max(endIdx, -.1), totalCursorCount + .1), this.selectionRangeByCursorIdx(startIdx, endIdx, cache);
174
+ }
175
+ selectionRangeByCursorIdx(startCursorIdx, endCursorIdx, cache) {
176
+ this.curCursorIdx = endCursorIdx, this.selectionStartCursorIdx = startCursorIdx;
177
+ const {x: x, y1: y1, y2: y2} = this.computedCursorPosByCursorIdx(this.selectionStartCursorIdx, this.currRt);
178
+ this.startCursorPos = {
179
+ x: x,
180
+ y: (y1 + y2) / 2
181
+ };
182
+ const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
183
+ this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this._tryShowSelection(pos, cache);
184
+ }
185
+ fullSelection(e) {
186
+ if (application.global.isMacOS() && e.metaKey && "a" === e.key || !application.global.isMacOS() && e.ctrlKey && "a" === e.key) {
187
+ const currRt = this.currRt;
188
+ if (!currRt) return;
189
+ const cache = currRt.getFrameCache();
190
+ if (!cache) return;
191
+ const {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
192
+ return this.selectionRange(-.1, totalCursorCount + .1), e.preventDefault(), !0;
193
+ }
194
+ return !1;
195
+ }
196
+ directKey(e) {
197
+ if ("ArrowUp" !== e.key && "ArrowDown" !== e.key && "ArrowLeft" !== e.key && "ArrowRight" !== e.key) return !1;
198
+ const cache = this.currRt.getFrameCache();
199
+ if (!cache) return !1;
200
+ let x = 0, y = 0;
201
+ "ArrowUp" === e.key ? y = -1 : "ArrowDown" === e.key ? y = 1 : "ArrowLeft" === e.key ? x = -1 : "ArrowRight" === e.key && (x = 1);
202
+ const {lineInfo: lineInfo, columnInfo: columnInfo} = this.getColumnByIndex(cache, Math.round(this.curCursorIdx)), {lines: lines} = cache, totalCursorCount = lines.reduce(((total, line) => total + line.paragraphs.length), 0) - 1;
203
+ if (x) {
204
+ 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,
205
+ this.curCursorIdx < -.1 ? this.curCursorIdx = -.1 : this.curCursorIdx > totalCursorCount + .1 && (this.curCursorIdx = totalCursorCount + .1);
206
+ const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt);
207
+ this.setCursorAndTextArea(pos.x, pos.y1, pos.y2, this.currRt), this.hideSelection();
208
+ }
209
+ if (y) {
210
+ if (y > 0 && lineInfo === cache.lines[cache.lines.length - 1]) return;
211
+ if (y < 0 && lineInfo === cache.lines[0]) return;
212
+ const lineIdx = cache.lines.findIndex((item => item === lineInfo)) + y;
213
+ if (lineIdx < 0 || lineIdx >= cache.lines.length) return;
214
+ const pos = this.computedCursorPosByCursorIdx(this.curCursorIdx, this.currRt), posX = pos.x;
215
+ let posY = (pos.y1 + pos.y2) / 2;
216
+ posY += y * lineInfo.height;
217
+ const nextLineInfo = cache.lines[lineIdx], {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(nextLineInfo, {
218
+ x: posX,
219
+ y: posY
220
+ });
221
+ if (!columnInfo) return;
222
+ let cursorIdx = this.getColumnIndex(cache, columnInfo) + delta;
223
+ const data = this.computedCursorPosByCursorIdx(cursorIdx, this.currRt);
224
+ cursorIdx < -.1 ? cursorIdx = -.1 : cursorIdx > totalCursorCount + .1 && (cursorIdx = totalCursorCount + .1),
225
+ this.curCursorIdx = cursorIdx, this.selectionStartCursorIdx = cursorIdx, this.setCursorAndTextArea(data.x, data.y1, data.y2, this.currRt);
226
+ }
227
+ return !0;
228
+ }
229
+ tryShowShadowPlaceholder() {
230
+ if (!this.currRt) return;
231
+ const shadowRoot = this.currRt.shadowRoot;
232
+ if (shadowRoot) {
233
+ const placeholder = shadowRoot.getElementsByType("richtext")[0];
234
+ placeholder && shadowRoot.removeChild(placeholder);
235
+ }
236
+ const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
237
+ if (textConfig && textConfig.length) return;
238
+ if (!editOptions || !editOptions.placeholder) return;
239
+ const {placeholder: placeholder, placeholderColor: placeholderColor = "rgba(0, 0, 0, 0.6)", placeholderFontFamily: placeholderFontFamily, placeholderFontSize: placeholderFontSize} = editOptions, shadow = this.currRt.shadowRoot || this.currRt.attachShadow();
240
+ this.shadowPlaceHolder = createRichText(Object.assign(Object.assign({}, this.currRt.attribute), {
241
+ x: 0,
242
+ y: 0,
243
+ angle: 0,
244
+ _debug_bounds: !1,
245
+ textConfig: [ {
246
+ text: placeholder,
247
+ fill: placeholderColor,
248
+ fontFamily: placeholderFontFamily,
249
+ fontSize: placeholderFontSize
250
+ } ]
251
+ })), shadow.add(this.shadowPlaceHolder);
252
+ }
253
+ tryShowInputBounds() {
254
+ if (!this.currRt || !this.focusing) return;
255
+ const {editOptions: editOptions = {}} = this.currRt.attribute, {boundsStrokeWhenInput: boundsStrokeWhenInput} = editOptions;
256
+ if (!editOptions || !boundsStrokeWhenInput) return;
257
+ const {attribute: attribute} = this.currRt, b = this.currRt.AABBBounds;
258
+ let h = b.height();
259
+ if (!attribute.textConfig.length && this.editLine) {
260
+ const {points: points} = this.editLine.attribute;
261
+ h = points[1].y - points[0].y;
262
+ }
263
+ this.shadowBounds = this.shadowBounds || createRect({}), this.shadowBounds.setAttributes({
264
+ x: 0,
265
+ y: 0,
266
+ width: b.width(),
267
+ height: h,
268
+ fill: !1,
269
+ stroke: boundsStrokeWhenInput,
270
+ lineWidth: 1,
271
+ boundsMode: "empty",
272
+ zIndex: -1
273
+ });
274
+ (this.currRt.shadowRoot || this.currRt.attachShadow()).add(this.shadowBounds), this.offsetLineBgAndShadowBounds();
275
+ }
276
+ trySyncPlaceholderToTextConfig() {
277
+ if (!this.currRt) return;
278
+ const {textConfig: textConfig, editOptions: editOptions} = this.currRt.attribute;
279
+ if (textConfig && textConfig.length) return;
280
+ if (!editOptions || !editOptions.placeholder) return;
281
+ const {placeholder: placeholder} = editOptions;
282
+ this.currRt.setAttributes({
283
+ textConfig: [ Object.assign({
284
+ text: placeholder
285
+ }, getDefaultCharacterConfig(this.currRt.attribute)) ]
286
+ });
287
+ }
288
+ deactivate(context) {
289
+ context.stage.off("pointermove", this.handleMove), context.stage.off("pointerdown", this.handlePointerDown),
290
+ context.stage.off("pointerup", this.handlePointerUp), context.stage.off("pointerleave", this.handlePointerUp),
291
+ context.stage.off("dblclick", this.handleDBLClick), application.global.addEventListener("keydown", this.handleKeyDown);
292
+ }
293
+ onFocus(e, data) {
294
+ this.deFocus(!1), this.focusing = !0;
295
+ const target = e.target;
296
+ if (!target || "richtext" !== target.type) return;
297
+ this.currRt = target, RichTextEditPlugin.tryUpdateRichtext(target);
298
+ const shadowRoot = target.shadowRoot || target.attachShadow(), cache = target.getFrameCache();
299
+ if (cache) {
300
+ if (this.computeGlobalDelta(cache), shadowRoot.setAttributes({
301
+ shadowRootIdx: 1,
302
+ pickable: !1,
303
+ x: this.deltaX,
304
+ y: this.deltaY
305
+ }), !this.editLine) {
306
+ const line = createLine({
307
+ x: 0,
308
+ y: 0,
309
+ lineWidth: 1,
310
+ stroke: "black",
311
+ boundsMode: "empty"
115
312
  });
116
- } else {
117
- this.editBg.setAttributes({
313
+ this.addAnimateToLine(line), this.editLine = line, this.ticker.start(!0);
314
+ const g = createGroup({
118
315
  x: 0,
119
- y: line0Info.top,
316
+ y: 0,
120
317
  width: 0,
121
- height: 0
318
+ height: 0,
319
+ boundsMode: "empty"
122
320
  });
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;
321
+ this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
322
+ }
323
+ if (data = data || this.computedCursorPosByEvent(e, cache)) {
324
+ const {x: x, y1: y1, y2: y2, cursorIndex: cursorIndex} = data;
325
+ this.startCursorPos = {
326
+ x: x,
327
+ y: (y1 + y2) / 2
328
+ }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
329
+ this.setCursorAndTextArea(x, y1, y2, target);
330
+ } else {
331
+ const x = 0, y1 = 0, y2 = getRichTextBounds(Object.assign(Object.assign({}, target.attribute), {
332
+ textConfig: [ {
333
+ text: "a"
334
+ } ]
335
+ })).height();
336
+ this.startCursorPos = {
337
+ x: x,
338
+ y: (y1 + y2) / 2
339
+ }, this.curCursorIdx = -.1, this.selectionStartCursorIdx = -.1, this.setCursorAndTextArea(x, y1, y2, target);
340
+ }
341
+ this.tryShowShadowPlaceholder(), this.tryShowInputBounds(), this.currRt.addUpdateBoundTag();
342
+ }
343
+ }
344
+ offsetLineBgAndShadowBounds() {
345
+ const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
346
+ let b, dy = 0, attr = rt.attribute;
347
+ "middle" !== textBaseline && "bottom" !== textBaseline || (attr.textConfig.length || (attr = Object.assign(Object.assign({}, attr), {
348
+ textConfig: [ {
349
+ text: "a"
350
+ } ]
351
+ })), b = getRichTextBounds(attr)), "middle" === textBaseline ? dy = -b.height() / 2 : "bottom" === textBaseline && (dy = -b.height()),
352
+ this.editLine && this.editLine.setAttributes({
353
+ dy: dy
354
+ }), this.editBg && this.editBg.setAttributes({
355
+ dy: dy
356
+ }), this.shadowBounds && this.shadowBounds.setAttributes({
357
+ dy: dy
358
+ });
359
+ }
360
+ deFocus(trulyDeFocus = !1) {
361
+ const target = this.currRt;
362
+ if (!target) return;
363
+ trulyDeFocus && (this.trySyncPlaceholderToTextConfig(), target.detachShadow());
364
+ const currRt = this.currRt;
365
+ this.currRt = null, this.editLine && (this.editLine.parent && this.editLine.parent.removeChild(this.editLine),
366
+ this.editLine.release(), this.editLine = null, this.editBg.parent && this.editBg.parent.removeChild(this.editBg),
367
+ this.editBg.release(), this.editBg = null), trulyDeFocus && (this.shadowBounds && (this.shadowBounds.parent && this.shadowBounds.parent.removeChild(this.shadowBounds),
368
+ this.shadowBounds.release(), this.shadowBounds = null), this.shadowPlaceHolder && (this.shadowPlaceHolder.parent && this.shadowPlaceHolder.parent.removeChild(this.shadowPlaceHolder),
369
+ this.shadowPlaceHolder.release(), this.shadowPlaceHolder = null)), this.focusing = !1;
370
+ const textConfig = currRt.attribute.textConfig;
371
+ let lastConfig = textConfig[textConfig.length - 1], cleared = !1;
372
+ for (;lastConfig && "\n" === lastConfig.text; ) textConfig.pop(), lastConfig = textConfig[textConfig.length - 1],
373
+ cleared = !0;
374
+ cleared && currRt.setAttributes({
375
+ textConfig: textConfig
376
+ });
377
+ }
378
+ addAnimateToLine(line) {
379
+ line.animates && line.animates.forEach((animate => {
380
+ animate.stop(), animate.release();
381
+ }));
382
+ line.animate({
383
+ timeline: this.timeline
384
+ }).to({
385
+ opacity: 1
386
+ }, 10, "linear").wait(700).to({
387
+ opacity: 0
388
+ }, 10, "linear").wait(700).loop(1 / 0);
389
+ }
390
+ tryShowSelection(e, dblclick) {
391
+ const cache = e.target.getFrameCache();
392
+ if (cache && this.editBg && this.startCursorPos) if (dblclick) {
393
+ const currCursorData = this.computedCursorPosByEvent(e, cache);
394
+ if (!currCursorData) return;
395
+ const lineInfo = currCursorData.lineInfo, columnIndex = lineInfo.paragraphs.findIndex((item => item === currCursorData.columnInfo));
396
+ if (columnIndex < 0) return;
397
+ const str = lineInfo.paragraphs.reduce(((str, item) => str + item.text), "");
398
+ let idx = 0;
399
+ for (let i = 0; i < cache.lines.length; i++) {
400
+ const line = cache.lines[i];
401
+ if (line === lineInfo) break;
402
+ idx += line.paragraphs.length;
403
+ }
404
+ const {startIdx: startIdx, endIdx: endIdx} = getWordStartEndIdx(str, columnIndex);
405
+ this.selectionRange(idx + startIdx - .1, idx + endIdx - .1);
406
+ } else if (this.pointerDown) {
407
+ const currCursorData = this.computedCursorPosByEvent(e, cache);
408
+ if (!currCursorData) return;
409
+ this.curCursorIdx = currCursorData.cursorIndex, this._tryShowSelection(currCursorData, cache);
410
+ }
411
+ }
412
+ _tryShowSelection(currCursorData, cache) {
413
+ let startCursorPos = this.startCursorPos, endCursorPos = {
414
+ x: currCursorData.x,
415
+ y: (currCursorData.y1 + currCursorData.y2) / 2
416
+ }, line0Info = this.getLineByPoint(cache, startCursorPos), line1Info = this.getLineByPoint(cache, endCursorPos);
417
+ if ((startCursorPos.y > endCursorPos.y || startCursorPos.y === endCursorPos.y && startCursorPos.x > endCursorPos.x) && ([startCursorPos, endCursorPos] = [ endCursorPos, startCursorPos ],
418
+ [line1Info, line0Info] = [ line0Info, line1Info ]), this.hideSelection(), line0Info === line1Info) this.editBg.setAttributes({
419
+ x: startCursorPos.x,
420
+ y: line0Info.top,
421
+ width: endCursorPos.x - startCursorPos.x,
422
+ height: line0Info.height,
423
+ fill: "#336df4",
424
+ fillOpacity: .2
425
+ }); else {
426
+ this.editBg.setAttributes({
427
+ x: 0,
428
+ y: line0Info.top,
429
+ width: 0,
430
+ height: 0
431
+ });
432
+ const startIdx = cache.lines.findIndex((item => item === line0Info)), endIdx = cache.lines.findIndex((item => item === line1Info));
433
+ let y = 0;
434
+ for (let i = startIdx; i <= endIdx; i++) {
435
+ const line = cache.lines[i];
436
+ if (i === startIdx) {
437
+ const p = line.paragraphs[line.paragraphs.length - 1];
438
+ this.editBg.add(createRect({
439
+ x: startCursorPos.x,
440
+ y: y,
441
+ width: p.left + p.width - startCursorPos.x,
442
+ height: line.height,
443
+ fill: "#336df4",
444
+ fillOpacity: .2
445
+ }));
446
+ } else if (i === endIdx) {
447
+ const p = line.paragraphs[0];
448
+ this.editBg.add(createRect({
449
+ x: p.left,
450
+ y: y,
451
+ width: endCursorPos.x - p.left,
452
+ height: line.height,
453
+ fill: "#336df4",
454
+ fillOpacity: .2
455
+ }));
456
+ } else {
457
+ const p0 = line.paragraphs[0], p1 = line.paragraphs[line.paragraphs.length - 1];
458
+ this.editBg.add(createRect({
459
+ x: p0.left,
460
+ y: y,
461
+ width: p1.left + p1.width - p0.left,
462
+ height: line.height,
463
+ fill: "#336df4",
464
+ fillOpacity: .2
465
+ }));
159
466
  }
467
+ y += line.height;
160
468
  }
161
- this.curCursorIdx = cursorIndex, this.setCursorAndTextArea(x, y1 + 2, y2 - 2, e.target),
162
- this.applyUpdate(), this.updateCbs.forEach((cb => cb("selection", this)));
163
469
  }
470
+ this.setCursorAndTextArea(currCursorData.x, currCursorData.y1, currCursorData.y2, this.currRt),
471
+ this.triggerRender(), this.updateCbs.forEach((cb => cb("selection", this)));
164
472
  }
165
473
  hideSelection() {
166
474
  this.editBg && (this.editBg.removeAllChild(), this.editBg.setAttributes({
167
475
  fill: "transparent"
168
476
  }));
169
477
  }
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
478
  getLineByPoint(cache, p1) {
181
479
  let lineInfo = cache.lines[0];
182
480
  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
481
  return lineInfo;
184
482
  }
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;
189
- }
190
- onFocus(e) {
191
- this.deFocus(e);
192
- 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();
199
- if (!cache) return;
200
- if (!this.editLine) {
201
- const line = createLine({
202
- x: 0,
203
- y: 0,
204
- lineWidth: 1,
205
- stroke: "black"
206
- });
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;
212
- const g = createGroup({
213
- x: 0,
214
- y: 0,
215
- width: 0,
216
- height: 0
217
- });
218
- this.editBg = g, shadowRoot.add(this.editLine), shadowRoot.add(this.editBg);
483
+ getColumnAndIndexByLinePoint(lineInfo, p1) {
484
+ let columnInfo = lineInfo.paragraphs[0], delta = 0;
485
+ if (lineInfo.paragraphs.length) {
486
+ const start = lineInfo.paragraphs[0], end = lineInfo.paragraphs[lineInfo.paragraphs.length - 1];
487
+ p1.x <= start.left ? (delta = -.1, columnInfo = start) : p1.x >= end.left + end.width && (delta = .1,
488
+ columnInfo = end);
219
489
  }
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 = {
229
- x: x,
230
- y: (y1 + y2) / 2
231
- }, this.curCursorIdx = cursorIndex, this.selectionStartCursorIdx = cursorIndex,
232
- this.setCursorAndTextArea(x, y1, y2, target);
490
+ if (!delta) for (let i = 0; i < lineInfo.paragraphs.length; i++) if (columnInfo = lineInfo.paragraphs[i],
491
+ columnInfo.left <= p1.x && columnInfo.left + columnInfo.width >= p1.x) {
492
+ delta = p1.x > columnInfo.left + columnInfo.width / 2 ? .1 : -.1;
493
+ break;
233
494
  }
234
- }
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
495
+ return {
496
+ columnInfo: columnInfo,
497
+ delta: delta
242
498
  };
243
499
  }
244
500
  getColumnIndex(cache, cInfo) {
@@ -249,19 +505,32 @@ export class RichTextEditPlugin {
249
505
  }
250
506
  return -1;
251
507
  }
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
- }
508
+ isRichtext(e) {
509
+ return !(!e.target || "richtext" !== e.target.type || !e.target.attribute.editable);
510
+ }
511
+ triggerRender() {
512
+ this.pluginService.stage.renderNextFrame();
513
+ }
514
+ computeGlobalDelta(cache) {
515
+ this.deltaX = 0, this.deltaY = 0;
516
+ const height = cache.height, actualHeight = cache.actualHeight, width = cache.lines.reduce(((w, item) => Math.max(w, item.actualWidth)), 0);
517
+ "center" === cache.globalAlign ? this.deltaX = -width / 2 : "right" === cache.globalAlign && (this.deltaX = -width),
518
+ "middle" === cache.verticalDirection ? this.deltaY = height / 2 - actualHeight / 2 : "bottom" === cache.verticalDirection && (this.deltaY = height - actualHeight);
519
+ }
520
+ getEventPosition(e) {
521
+ const p = this.pluginService.stage.eventPointTransform(e), p1 = {
522
+ x: 0,
523
+ y: 0
524
+ };
525
+ e.target.globalTransMatrix.transformPoint(p, p1), p1.x -= this.deltaX, p1.y -= this.deltaY;
526
+ const rt = this.currRt, {textBaseline: textBaseline} = rt.attribute;
527
+ let dy = 0;
528
+ if ("middle" === textBaseline) {
529
+ dy = getRichTextBounds(rt.attribute).height() / 2;
530
+ } else if ("bottom" === textBaseline) {
531
+ dy = getRichTextBounds(rt.attribute).height();
263
532
  }
264
- return null;
533
+ return p1.y += dy, p1;
265
534
  }
266
535
  setCursorAndTextArea(x, y1, y2, rt) {
267
536
  this.editLine.setAttributes({
@@ -272,7 +541,7 @@ export class RichTextEditPlugin {
272
541
  x: x,
273
542
  y: y2
274
543
  } ]
275
- });
544
+ }), this.addAnimateToLine(this.editLine);
276
545
  const out = {
277
546
  x: 0,
278
547
  y: 0
@@ -282,54 +551,98 @@ export class RichTextEditPlugin {
282
551
  y: y1
283
552
  }, out);
284
553
  const {left: left, top: top} = this.pluginService.stage.window.getBoundingClientRect();
285
- out.x += left, out.y += top, this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
554
+ out.x += left, out.y += top, this.offsetLineBgAndShadowBounds(), this.editModule.moveTo(out.x, out.y, rt, this.curCursorIdx, this.selectionStartCursorIdx);
286
555
  }
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();
556
+ computedCursorPosByEvent(e, cache) {
557
+ const p1 = this.getEventPosition(e), lineInfo = this.getLineByPoint(cache, p1);
558
+ if (!lineInfo) return;
559
+ const {columnInfo: columnInfo, delta: delta} = this.getColumnAndIndexByLinePoint(lineInfo, p1);
560
+ if (!columnInfo) return;
561
+ const y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
562
+ let cursorIndex = this.getColumnIndex(cache, columnInfo);
563
+ cursorIndex += delta;
564
+ return {
565
+ x: columnInfo.left + (delta > 0 ? columnInfo.width : 0),
566
+ y1: y1,
567
+ y2: y2,
568
+ cursorIndex: cursorIndex,
569
+ lineInfo: lineInfo,
570
+ columnInfo: columnInfo
571
+ };
300
572
  }
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));
306
- }
307
- splitText(text) {
308
- return Array.from(text);
309
- }
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);
573
+ computedCursorPosByCursorIdx(cursorIdx, rt) {
574
+ var _a, _b, _c;
575
+ 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;
576
+ if (!column) {
577
+ if (!cache.lines.length) {
578
+ return {
579
+ x: 0,
580
+ y1: 0,
581
+ y2: getRichTextBounds(Object.assign(Object.assign({}, rt.attribute), {
582
+ textConfig: [ {
583
+ text: "a"
584
+ } ]
585
+ })).height()
586
+ };
587
+ }
588
+ return {
589
+ x: 0,
590
+ y1: 0,
591
+ y2: height
592
+ };
324
593
  }
594
+ const {lineInfo: lineInfo, columnInfo: columnInfo} = column, y1 = lineInfo.top, y2 = lineInfo.top + lineInfo.height;
595
+ return {
596
+ x: columnInfo.left + (leftRight < 0 ? 0 : columnInfo.width),
597
+ y1: y1,
598
+ y2: y2,
599
+ lineInfo: lineInfo,
600
+ columnInfo: columnInfo
601
+ };
325
602
  }
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);
603
+ getColumnByIndex(cache, index) {
604
+ for (let i = 0, inputIndex = 0; i < cache.lines.length; i++) {
605
+ const lineInfo = cache.lines[i];
606
+ for (let j = 0; j < lineInfo.paragraphs.length; j++) {
607
+ const columnInfo = lineInfo.paragraphs[j];
608
+ if (inputIndex === index) return {
609
+ lineInfo: lineInfo,
610
+ columnInfo: columnInfo
611
+ };
612
+ inputIndex++;
613
+ }
614
+ }
615
+ return null;
330
616
  }
331
617
  release() {
332
- this.editModule.release();
618
+ this.deactivate(this.pluginService), this.editModule.release();
619
+ }
620
+ getSelection(defaultAll = !1) {
621
+ return this.currRt ? null != this.selectionStartCursorIdx && null != this.curCursorIdx ? new Selection(this.selectionStartCursorIdx, this.curCursorIdx, this.currRt) : defaultAll ? RichTextEditPlugin.CreateSelection(this.currRt) : null : null;
622
+ }
623
+ forceFocus(params) {
624
+ const {target: target, e: e, cursorIndex: cursorIndex} = params;
625
+ target && (this.currRt = target, e ? this._forceFocusByEvent(e) : this._forceFocusByCursorIndex(null != cursorIndex ? cursorIndex : -.1));
626
+ }
627
+ _forceFocusByEvent(e) {
628
+ this.handleEnter(e), this.handlePointerDown(e), this.handlePointerUp(e);
629
+ }
630
+ _forceFocusByCursorIndex(cursorIndex) {
631
+ const richtext = this.currRt;
632
+ if (!richtext) return;
633
+ let x = 0, y1 = 0, y2 = 2, lineInfo = null, columnInfo = null;
634
+ const data = this.computedCursorPosByCursorIdx(cursorIndex, richtext);
635
+ x = data.x, y1 = data.y1, y2 = data.y2, lineInfo = data.lineInfo, columnInfo = data.columnInfo,
636
+ this.onFocus({
637
+ target: this.currRt
638
+ }, {
639
+ x: x,
640
+ y1: y1,
641
+ y2: y2,
642
+ cursorIndex: cursorIndex,
643
+ lineInfo: lineInfo,
644
+ columnInfo: columnInfo
645
+ });
333
646
  }
334
647
  }
335
648
  //# sourceMappingURL=richtext-edit-plugin.js.map