@visactor/vrender-core 0.21.14 → 0.22.0-vstory.10

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