@visactor/vtable 1.26.6 → 1.26.8

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 (367) hide show
  1. package/cjs/ListTable-all.js +5 -5
  2. package/cjs/ListTable-all.js.map +1 -1
  3. package/cjs/ListTable.d.ts +2 -2
  4. package/cjs/ListTable.js +26 -16
  5. package/cjs/ListTable.js.map +1 -1
  6. package/cjs/PivotChart.js +21 -20
  7. package/cjs/PivotChart.js.map +1 -1
  8. package/cjs/PivotTable-all.js +4 -3
  9. package/cjs/PivotTable-all.js.map +1 -1
  10. package/cjs/PivotTable.d.ts +1 -1
  11. package/cjs/PivotTable.js +65 -63
  12. package/cjs/PivotTable.js.map +1 -1
  13. package/cjs/body-helper/body-helper.d.ts +1 -1
  14. package/cjs/body-helper/body-helper.js +3 -1
  15. package/cjs/body-helper/body-helper.js.map +1 -1
  16. package/cjs/components/index.js +1 -2
  17. package/cjs/components/tooltip/TooltipHandler.d.ts +4 -0
  18. package/cjs/components/tooltip/TooltipHandler.js +32 -7
  19. package/cjs/components/tooltip/TooltipHandler.js.map +1 -1
  20. package/cjs/core/BaseTable.js +8 -5
  21. package/cjs/core/BaseTable.js.map +1 -1
  22. package/cjs/core/TABLE_EVENT_TYPE.d.ts +1 -0
  23. package/cjs/core/TABLE_EVENT_TYPE.js +1 -0
  24. package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
  25. package/cjs/core/record-helper.d.ts +1 -1
  26. package/cjs/core/record-helper.js +60 -12
  27. package/cjs/core/record-helper.js.map +1 -1
  28. package/cjs/data/DataSource.d.ts +3 -1
  29. package/cjs/data/DataSource.js +70 -21
  30. package/cjs/data/DataSource.js.map +1 -1
  31. package/cjs/dataset/dataset.d.ts +9 -1
  32. package/cjs/dataset/dataset.js +344 -187
  33. package/cjs/dataset/dataset.js.map +1 -1
  34. package/cjs/event/event.d.ts +94 -8
  35. package/cjs/event/event.js +697 -190
  36. package/cjs/event/event.js.map +1 -1
  37. package/cjs/event/media-click.js +147 -12
  38. package/cjs/event/media-click.js.map +1 -1
  39. package/cjs/event/sparkline-event.js +1 -2
  40. package/cjs/event/util.js +1 -1
  41. package/cjs/event/util.js.map +1 -1
  42. package/cjs/header-helper/header-helper.js +3 -1
  43. package/cjs/header-helper/header-helper.js.map +1 -1
  44. package/cjs/index.d.ts +3 -3
  45. package/cjs/index.js +1 -1
  46. package/cjs/index.js.map +1 -1
  47. package/cjs/layout/pivot-header-layout.js +33 -17
  48. package/cjs/layout/pivot-header-layout.js.map +1 -1
  49. package/cjs/scenegraph/group-creater/cell-helper.d.ts +4 -2
  50. package/cjs/scenegraph/group-creater/cell-helper.js +93 -51
  51. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  52. package/cjs/scenegraph/group-creater/cell-type/audio-cell.d.ts +7 -0
  53. package/cjs/scenegraph/group-creater/cell-type/audio-cell.js +83 -0
  54. package/cjs/scenegraph/group-creater/cell-type/audio-cell.js.map +1 -0
  55. package/cjs/scenegraph/group-creater/cell-type/button-cell.d.ts +1 -1
  56. package/cjs/scenegraph/group-creater/cell-type/button-cell.js +5 -4
  57. package/cjs/scenegraph/group-creater/cell-type/button-cell.js.map +1 -1
  58. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  59. package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  60. package/cjs/scenegraph/group-creater/cell-type/checkbox-cell.d.ts +1 -1
  61. package/cjs/scenegraph/group-creater/cell-type/checkbox-cell.js +5 -4
  62. package/cjs/scenegraph/group-creater/cell-type/checkbox-cell.js.map +1 -1
  63. package/cjs/scenegraph/group-creater/cell-type/image-cell.d.ts +1 -1
  64. package/cjs/scenegraph/group-creater/cell-type/image-cell.js +43 -15
  65. package/cjs/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  66. package/cjs/scenegraph/group-creater/cell-type/index.d.ts +1 -0
  67. package/cjs/scenegraph/group-creater/cell-type/index.js +8 -2
  68. package/cjs/scenegraph/group-creater/cell-type/index.js.map +1 -1
  69. package/cjs/scenegraph/group-creater/cell-type/media-cell-helper.d.ts +13 -0
  70. package/cjs/scenegraph/group-creater/cell-type/media-cell-helper.js +64 -0
  71. package/cjs/scenegraph/group-creater/cell-type/media-cell-helper.js.map +1 -0
  72. package/cjs/scenegraph/group-creater/cell-type/radio-cell.d.ts +1 -1
  73. package/cjs/scenegraph/group-creater/cell-type/radio-cell.js +23 -7
  74. package/cjs/scenegraph/group-creater/cell-type/radio-cell.js.map +1 -1
  75. package/cjs/scenegraph/group-creater/cell-type/spark-line-cell.d.ts +1 -1
  76. package/cjs/scenegraph/group-creater/cell-type/spark-line-cell.js +6 -5
  77. package/cjs/scenegraph/group-creater/cell-type/spark-line-cell.js.map +1 -1
  78. package/cjs/scenegraph/group-creater/cell-type/switch-cell.d.ts +1 -1
  79. package/cjs/scenegraph/group-creater/cell-type/switch-cell.js +5 -4
  80. package/cjs/scenegraph/group-creater/cell-type/switch-cell.js.map +1 -1
  81. package/cjs/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  82. package/cjs/scenegraph/group-creater/cell-type/text-cell.js +14 -10
  83. package/cjs/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  84. package/cjs/scenegraph/group-creater/cell-type/video-cell.d.ts +1 -1
  85. package/cjs/scenegraph/group-creater/cell-type/video-cell.js +44 -23
  86. package/cjs/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  87. package/cjs/scenegraph/group-creater/column-helper.js +14 -7
  88. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  89. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -4
  90. package/cjs/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  91. package/cjs/scenegraph/group-creater/progress/proxy.d.ts +1 -0
  92. package/cjs/scenegraph/group-creater/progress/proxy.js +11 -5
  93. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  94. package/cjs/scenegraph/icon/icon-update.js +1 -0
  95. package/cjs/scenegraph/icon/icon-update.js.map +1 -1
  96. package/cjs/scenegraph/layout/compute-col-width.js +14 -4
  97. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  98. package/cjs/scenegraph/layout/compute-row-height.js +29 -8
  99. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  100. package/cjs/scenegraph/layout/update-height.d.ts +4 -3
  101. package/cjs/scenegraph/layout/update-height.js +44 -30
  102. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  103. package/cjs/scenegraph/layout/update-width.d.ts +2 -1
  104. package/cjs/scenegraph/layout/update-width.js +50 -38
  105. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  106. package/cjs/scenegraph/scenegraph.d.ts +3 -2
  107. package/cjs/scenegraph/scenegraph.js +60 -52
  108. package/cjs/scenegraph/scenegraph.js.map +1 -1
  109. package/cjs/scenegraph/stick-text/index.js +46 -20
  110. package/cjs/scenegraph/stick-text/index.js.map +1 -1
  111. package/cjs/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  112. package/cjs/scenegraph/utils/corner-custom-merge.js +68 -0
  113. package/cjs/scenegraph/utils/corner-custom-merge.js.map +1 -0
  114. package/cjs/scenegraph/utils/deal-promise-data.d.ts +1 -1
  115. package/cjs/scenegraph/utils/deal-promise-data.js +2 -2
  116. package/cjs/scenegraph/utils/deal-promise-data.js.map +1 -1
  117. package/cjs/state/cell-move/index.js +6 -3
  118. package/cjs/state/cell-move/index.js.map +1 -1
  119. package/cjs/state/checkbox/checkbox.d.ts +3 -1
  120. package/cjs/state/checkbox/checkbox.js +53 -34
  121. package/cjs/state/checkbox/checkbox.js.map +1 -1
  122. package/cjs/state/radio/radio.d.ts +3 -1
  123. package/cjs/state/radio/radio.js +69 -12
  124. package/cjs/state/radio/radio.js.map +1 -1
  125. package/cjs/state/resize/update-resize-column.js +25 -13
  126. package/cjs/state/resize/update-resize-column.js.map +1 -1
  127. package/cjs/state/resize/update-resize-row.js +24 -12
  128. package/cjs/state/resize/update-resize-row.js.map +1 -1
  129. package/cjs/state/state.d.ts +3 -2
  130. package/cjs/state/state.js +6 -3
  131. package/cjs/state/state.js.map +1 -1
  132. package/cjs/themes.d.ts +4 -2
  133. package/cjs/themes.js +12 -4
  134. package/cjs/themes.js.map +1 -1
  135. package/cjs/tools/get-data-path/create-dataset.js +4 -4
  136. package/cjs/tools/get-data-path/create-dataset.js.map +1 -1
  137. package/cjs/tools/get-data-path/index.js +4 -4
  138. package/cjs/tools/get-data-path/index.js.map +1 -1
  139. package/cjs/tools/media.d.ts +1 -0
  140. package/cjs/tools/media.js +19 -0
  141. package/cjs/tools/media.js.map +1 -0
  142. package/cjs/tools/style.d.ts +3 -1
  143. package/cjs/tools/style.js +2 -2
  144. package/cjs/tools/style.js.map +1 -1
  145. package/cjs/ts-types/base-table.d.ts +1 -0
  146. package/cjs/ts-types/base-table.js.map +1 -1
  147. package/cjs/ts-types/column/type.d.ts +2 -2
  148. package/cjs/ts-types/column/type.js.map +1 -1
  149. package/cjs/ts-types/common.d.ts +1 -0
  150. package/cjs/ts-types/common.js.map +1 -1
  151. package/cjs/ts-types/dataset/aggregation.d.ts +1 -0
  152. package/cjs/ts-types/dataset/aggregation.js +21 -3
  153. package/cjs/ts-types/dataset/aggregation.js.map +1 -1
  154. package/cjs/ts-types/events.d.ts +3 -1
  155. package/cjs/ts-types/events.js.map +1 -1
  156. package/cjs/ts-types/icon.d.ts +1 -0
  157. package/cjs/ts-types/icon.js.map +1 -1
  158. package/cjs/ts-types/list-table/define/image-define.d.ts +10 -0
  159. package/cjs/ts-types/list-table/define/image-define.js.map +1 -1
  160. package/cjs/ts-types/list-table/define/index.d.ts +5 -4
  161. package/cjs/ts-types/list-table/define/index.js.map +1 -1
  162. package/cjs/ts-types/list-table/layout-map/api.d.ts +4 -4
  163. package/cjs/ts-types/list-table/layout-map/api.js.map +1 -1
  164. package/cjs/ts-types/list-table/layout-map/index.d.ts +1 -1
  165. package/cjs/ts-types/list-table/layout-map/index.js.map +1 -1
  166. package/cjs/ts-types/menu.d.ts +12 -0
  167. package/cjs/ts-types/menu.js.map +1 -1
  168. package/cjs/ts-types/new-data-set.d.ts +1 -0
  169. package/cjs/ts-types/new-data-set.js.map +1 -1
  170. package/cjs/ts-types/pivot-table/dimension/image-dimension.d.ts +5 -0
  171. package/cjs/ts-types/pivot-table/dimension/image-dimension.js.map +1 -1
  172. package/cjs/ts-types/pivot-table/dimension/index.d.ts +5 -3
  173. package/cjs/ts-types/pivot-table/dimension/index.js.map +1 -1
  174. package/cjs/ts-types/pivot-table/indicator/image-indicator.d.ts +10 -0
  175. package/cjs/ts-types/pivot-table/indicator/image-indicator.js.map +1 -1
  176. package/cjs/ts-types/pivot-table/indicator/index.d.ts +3 -3
  177. package/cjs/ts-types/pivot-table/indicator/index.js.map +1 -1
  178. package/cjs/ts-types/table-engine.d.ts +9 -5
  179. package/cjs/ts-types/table-engine.js.map +1 -1
  180. package/cjs/ts-types/tooltip.d.ts +1 -0
  181. package/cjs/ts-types/tooltip.js.map +1 -1
  182. package/cjs/vrender.js.map +1 -1
  183. package/dist/vtable.js +3346 -1099
  184. package/dist/vtable.min.js +1 -1
  185. package/es/ListTable-all.js +4 -4
  186. package/es/ListTable-all.js.map +1 -1
  187. package/es/ListTable.d.ts +2 -2
  188. package/es/ListTable.js +26 -18
  189. package/es/ListTable.js.map +1 -1
  190. package/es/PivotChart.js +20 -20
  191. package/es/PivotChart.js.map +1 -1
  192. package/es/PivotTable-all.js +4 -4
  193. package/es/PivotTable-all.js.map +1 -1
  194. package/es/PivotTable.d.ts +1 -1
  195. package/es/PivotTable.js +65 -63
  196. package/es/PivotTable.js.map +1 -1
  197. package/es/body-helper/body-helper.d.ts +1 -1
  198. package/es/body-helper/body-helper.js +3 -1
  199. package/es/body-helper/body-helper.js.map +1 -1
  200. package/es/components/index.js +1 -2
  201. package/es/components/tooltip/TooltipHandler.d.ts +4 -0
  202. package/es/components/tooltip/TooltipHandler.js +32 -7
  203. package/es/components/tooltip/TooltipHandler.js.map +1 -1
  204. package/es/core/BaseTable.js +8 -5
  205. package/es/core/BaseTable.js.map +1 -1
  206. package/es/core/TABLE_EVENT_TYPE.d.ts +1 -0
  207. package/es/core/TABLE_EVENT_TYPE.js +1 -0
  208. package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
  209. package/es/core/record-helper.d.ts +1 -1
  210. package/es/core/record-helper.js +60 -12
  211. package/es/core/record-helper.js.map +1 -1
  212. package/es/data/DataSource.d.ts +3 -1
  213. package/es/data/DataSource.js +69 -21
  214. package/es/data/DataSource.js.map +1 -1
  215. package/es/dataset/dataset.d.ts +9 -1
  216. package/es/dataset/dataset.js +341 -187
  217. package/es/dataset/dataset.js.map +1 -1
  218. package/es/event/event.d.ts +94 -8
  219. package/es/event/event.js +695 -190
  220. package/es/event/event.js.map +1 -1
  221. package/es/event/media-click.js +150 -11
  222. package/es/event/media-click.js.map +1 -1
  223. package/es/event/sparkline-event.js +1 -2
  224. package/es/event/util.js +1 -1
  225. package/es/event/util.js.map +1 -1
  226. package/es/header-helper/header-helper.js +3 -1
  227. package/es/header-helper/header-helper.js.map +1 -1
  228. package/es/index.d.ts +3 -3
  229. package/es/index.js +1 -1
  230. package/es/index.js.map +1 -1
  231. package/es/layout/pivot-header-layout.js +29 -17
  232. package/es/layout/pivot-header-layout.js.map +1 -1
  233. package/es/scenegraph/group-creater/cell-helper.d.ts +4 -2
  234. package/es/scenegraph/group-creater/cell-helper.js +90 -49
  235. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  236. package/es/scenegraph/group-creater/cell-type/audio-cell.d.ts +7 -0
  237. package/es/scenegraph/group-creater/cell-type/audio-cell.js +89 -0
  238. package/es/scenegraph/group-creater/cell-type/audio-cell.js.map +1 -0
  239. package/es/scenegraph/group-creater/cell-type/button-cell.d.ts +1 -1
  240. package/es/scenegraph/group-creater/cell-type/button-cell.js +5 -4
  241. package/es/scenegraph/group-creater/cell-type/button-cell.js.map +1 -1
  242. package/es/scenegraph/group-creater/cell-type/chart-cell.js +2 -2
  243. package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
  244. package/es/scenegraph/group-creater/cell-type/checkbox-cell.d.ts +1 -1
  245. package/es/scenegraph/group-creater/cell-type/checkbox-cell.js +5 -4
  246. package/es/scenegraph/group-creater/cell-type/checkbox-cell.js.map +1 -1
  247. package/es/scenegraph/group-creater/cell-type/image-cell.d.ts +1 -1
  248. package/es/scenegraph/group-creater/cell-type/image-cell.js +43 -14
  249. package/es/scenegraph/group-creater/cell-type/image-cell.js.map +1 -1
  250. package/es/scenegraph/group-creater/cell-type/index.d.ts +1 -0
  251. package/es/scenegraph/group-creater/cell-type/index.js +6 -0
  252. package/es/scenegraph/group-creater/cell-type/index.js.map +1 -1
  253. package/es/scenegraph/group-creater/cell-type/media-cell-helper.d.ts +13 -0
  254. package/es/scenegraph/group-creater/cell-type/media-cell-helper.js +56 -0
  255. package/es/scenegraph/group-creater/cell-type/media-cell-helper.js.map +1 -0
  256. package/es/scenegraph/group-creater/cell-type/radio-cell.d.ts +1 -1
  257. package/es/scenegraph/group-creater/cell-type/radio-cell.js +23 -7
  258. package/es/scenegraph/group-creater/cell-type/radio-cell.js.map +1 -1
  259. package/es/scenegraph/group-creater/cell-type/spark-line-cell.d.ts +1 -1
  260. package/es/scenegraph/group-creater/cell-type/spark-line-cell.js +6 -5
  261. package/es/scenegraph/group-creater/cell-type/spark-line-cell.js.map +1 -1
  262. package/es/scenegraph/group-creater/cell-type/switch-cell.d.ts +1 -1
  263. package/es/scenegraph/group-creater/cell-type/switch-cell.js +5 -4
  264. package/es/scenegraph/group-creater/cell-type/switch-cell.js.map +1 -1
  265. package/es/scenegraph/group-creater/cell-type/text-cell.d.ts +1 -1
  266. package/es/scenegraph/group-creater/cell-type/text-cell.js +13 -8
  267. package/es/scenegraph/group-creater/cell-type/text-cell.js.map +1 -1
  268. package/es/scenegraph/group-creater/cell-type/video-cell.d.ts +1 -1
  269. package/es/scenegraph/group-creater/cell-type/video-cell.js +47 -22
  270. package/es/scenegraph/group-creater/cell-type/video-cell.js.map +1 -1
  271. package/es/scenegraph/group-creater/column-helper.js +14 -8
  272. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  273. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js +17 -5
  274. package/es/scenegraph/group-creater/progress/create-group-for-first-screen.js.map +1 -1
  275. package/es/scenegraph/group-creater/progress/proxy.d.ts +1 -0
  276. package/es/scenegraph/group-creater/progress/proxy.js +11 -5
  277. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  278. package/es/scenegraph/icon/icon-update.js +1 -0
  279. package/es/scenegraph/icon/icon-update.js.map +1 -1
  280. package/es/scenegraph/layout/compute-col-width.js +14 -4
  281. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  282. package/es/scenegraph/layout/compute-row-height.js +28 -8
  283. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  284. package/es/scenegraph/layout/update-height.d.ts +4 -3
  285. package/es/scenegraph/layout/update-height.js +41 -27
  286. package/es/scenegraph/layout/update-height.js.map +1 -1
  287. package/es/scenegraph/layout/update-width.d.ts +2 -1
  288. package/es/scenegraph/layout/update-width.js +47 -35
  289. package/es/scenegraph/layout/update-width.js.map +1 -1
  290. package/es/scenegraph/scenegraph.d.ts +3 -2
  291. package/es/scenegraph/scenegraph.js +61 -52
  292. package/es/scenegraph/scenegraph.js.map +1 -1
  293. package/es/scenegraph/stick-text/index.js +46 -18
  294. package/es/scenegraph/stick-text/index.js.map +1 -1
  295. package/es/scenegraph/utils/corner-custom-merge.d.ts +10 -0
  296. package/es/scenegraph/utils/corner-custom-merge.js +59 -0
  297. package/es/scenegraph/utils/corner-custom-merge.js.map +1 -0
  298. package/es/scenegraph/utils/deal-promise-data.d.ts +1 -1
  299. package/es/scenegraph/utils/deal-promise-data.js +2 -2
  300. package/es/scenegraph/utils/deal-promise-data.js.map +1 -1
  301. package/es/state/cell-move/index.js +6 -3
  302. package/es/state/cell-move/index.js.map +1 -1
  303. package/es/state/checkbox/checkbox.d.ts +3 -1
  304. package/es/state/checkbox/checkbox.js +53 -34
  305. package/es/state/checkbox/checkbox.js.map +1 -1
  306. package/es/state/radio/radio.d.ts +3 -1
  307. package/es/state/radio/radio.js +70 -13
  308. package/es/state/radio/radio.js.map +1 -1
  309. package/es/state/resize/update-resize-column.js +19 -10
  310. package/es/state/resize/update-resize-column.js.map +1 -1
  311. package/es/state/resize/update-resize-row.js +19 -9
  312. package/es/state/resize/update-resize-row.js.map +1 -1
  313. package/es/state/state.d.ts +3 -2
  314. package/es/state/state.js +6 -2
  315. package/es/state/state.js.map +1 -1
  316. package/es/themes.d.ts +4 -2
  317. package/es/themes.js +11 -3
  318. package/es/themes.js.map +1 -1
  319. package/es/tools/get-data-path/create-dataset.js +4 -4
  320. package/es/tools/get-data-path/create-dataset.js.map +1 -1
  321. package/es/tools/get-data-path/index.js +4 -4
  322. package/es/tools/get-data-path/index.js.map +1 -1
  323. package/es/tools/media.d.ts +1 -0
  324. package/es/tools/media.js +11 -0
  325. package/es/tools/media.js.map +1 -0
  326. package/es/tools/style.d.ts +3 -1
  327. package/es/tools/style.js +2 -2
  328. package/es/tools/style.js.map +1 -1
  329. package/es/ts-types/base-table.d.ts +1 -0
  330. package/es/ts-types/base-table.js.map +1 -1
  331. package/es/ts-types/column/type.d.ts +2 -2
  332. package/es/ts-types/column/type.js.map +1 -1
  333. package/es/ts-types/common.d.ts +1 -0
  334. package/es/ts-types/common.js.map +1 -1
  335. package/es/ts-types/dataset/aggregation.d.ts +1 -0
  336. package/es/ts-types/dataset/aggregation.js +21 -3
  337. package/es/ts-types/dataset/aggregation.js.map +1 -1
  338. package/es/ts-types/events.d.ts +3 -1
  339. package/es/ts-types/events.js.map +1 -1
  340. package/es/ts-types/icon.d.ts +1 -0
  341. package/es/ts-types/icon.js.map +1 -1
  342. package/es/ts-types/list-table/define/image-define.d.ts +10 -0
  343. package/es/ts-types/list-table/define/image-define.js.map +1 -1
  344. package/es/ts-types/list-table/define/index.d.ts +5 -4
  345. package/es/ts-types/list-table/define/index.js.map +1 -1
  346. package/es/ts-types/list-table/layout-map/api.d.ts +4 -4
  347. package/es/ts-types/list-table/layout-map/api.js.map +1 -1
  348. package/es/ts-types/list-table/layout-map/index.d.ts +1 -1
  349. package/es/ts-types/list-table/layout-map/index.js.map +1 -1
  350. package/es/ts-types/menu.d.ts +12 -0
  351. package/es/ts-types/menu.js.map +1 -1
  352. package/es/ts-types/new-data-set.d.ts +1 -0
  353. package/es/ts-types/new-data-set.js.map +1 -1
  354. package/es/ts-types/pivot-table/dimension/image-dimension.d.ts +5 -0
  355. package/es/ts-types/pivot-table/dimension/image-dimension.js.map +1 -1
  356. package/es/ts-types/pivot-table/dimension/index.d.ts +5 -3
  357. package/es/ts-types/pivot-table/dimension/index.js.map +1 -1
  358. package/es/ts-types/pivot-table/indicator/image-indicator.d.ts +10 -0
  359. package/es/ts-types/pivot-table/indicator/image-indicator.js.map +1 -1
  360. package/es/ts-types/pivot-table/indicator/index.d.ts +3 -3
  361. package/es/ts-types/pivot-table/indicator/index.js.map +1 -1
  362. package/es/ts-types/table-engine.d.ts +9 -5
  363. package/es/ts-types/table-engine.js.map +1 -1
  364. package/es/ts-types/tooltip.d.ts +1 -0
  365. package/es/ts-types/tooltip.js.map +1 -1
  366. package/es/vrender.js.map +1 -1
  367. package/package.json +10 -9
@@ -35,10 +35,14 @@ const vrender_1 = require("./../vrender"), TABLE_EVENT_TYPE_1 = require("../core
35
35
  class EventManager {
36
36
  constructor(table) {
37
37
  this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0,
38
- this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0,
39
- this.lastClipboardContent = "", this.cutCellRange = null, this.cutRanges = null,
40
- this.copySourceRange = null, this.table = table, this.handleTextStickBindId = [],
41
- this.inertiaScroll = new scroll_1.InertiaScroll(table.stateManager), "node" === env_1.Env.mode || table.options.disableInteraction || (this.bindOuterEvent(),
38
+ this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationId = 0,
39
+ this.clipboardOperationId = 0, this.pasteOperationId = 0, this.pasteWriteInProgress = !1,
40
+ this.pasteWritePromise = Promise.resolve(), this.clipboardWritePromise = Promise.resolve(),
41
+ this.lastCopiedClipboardData = null, this.internalFormulaHtmlMarkerId = 0, this.fieldKeyIds = new WeakMap,
42
+ this.fieldKeyId = 0, this.activeCutState = null, this.lastClipboardContent = "",
43
+ this.cutCellRange = null, this.cutRanges = null, this.copySourceRange = null, this.table = table,
44
+ this.handleTextStickBindId = [], this.inertiaScroll = new scroll_1.InertiaScroll(table.stateManager),
45
+ "node" === env_1.Env.mode || table.options.disableInteraction || (this.bindOuterEvent(),
42
46
  setTimeout((() => {
43
47
  this.bindSelfEvent();
44
48
  }), 0));
@@ -245,7 +249,8 @@ class EventManager {
245
249
  }
246
250
  release() {
247
251
  var _a;
248
- null === (_a = this.gesture) || void 0 === _a || _a.release(), this.globalEventListeners.forEach((item => {
252
+ this.clipboardOperationId++, this.pasteOperationId++, this.resetCutState(), null === (_a = this.gesture) || void 0 === _a || _a.release(),
253
+ this.globalEventListeners.forEach((item => {
249
254
  "document" === item.env ? document.removeEventListener(item.name, item.callback) : "body" === item.env ? document.body.removeEventListener(item.name, item.callback) : "window" === item.env ? window.removeEventListener(item.name, item.callback) : "vglobal" === item.env && vrender_1.vglobal.removeEventListener(item.name, item.callback);
250
255
  })), this.globalEventListeners = [];
251
256
  }
@@ -258,65 +263,329 @@ class EventManager {
258
263
  handleCopy(e, isCut = !1) {
259
264
  var _a, _b, _c, _d, _e, _f;
260
265
  return __awaiter(this, void 0, void 0, (function*() {
261
- const table = this.table;
262
- !isCut && (this.cutWaitPaste = !1), this.copySourceRange = null;
263
- const sourceRanges = table.stateManager.select.ranges;
264
- if (sourceRanges && 1 === sourceRanges.length) {
265
- const sourceRange = sourceRanges[0];
266
- this.copySourceRange = {
267
- startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
268
- startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
269
- };
270
- } else if (!(null == sourceRanges ? void 0 : sourceRanges.length)) return void (this.copySourceRange = null);
266
+ const table = this.table, operationId = ++this.clipboardOperationId;
267
+ this.pasteOperationId++, isCut || this.resetCutState();
268
+ const copySnapshot = this.getCopySnapshot(isCut);
269
+ if (this.copySourceRange = null, this.lastCopiedClipboardData = null, !copySnapshot) return this.copySourceRange = null,
270
+ null;
271
271
  const data = this.table.getCopyValue(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.value);
272
- if ((0, vutils_1.isValid)(data)) {
272
+ if (!(0, vutils_1.isValid)(data)) return null;
273
+ {
273
274
  e.preventDefault();
275
+ let copySucceeded = !1, copiedClipboardData = null;
276
+ const canUseAsyncClipboard = window.isSecureContext && !!(null === (_c = navigator.clipboard) || void 0 === _c ? void 0 : _c.writeText), canWriteRichClipboard = window.isSecureContext && !!(null === (_d = navigator.clipboard) || void 0 === _d ? void 0 : _d.write) && !!window.ClipboardItem, hasEventClipboard = !!e.clipboardData, dataHTML = !canUseAsyncClipboard || canWriteRichClipboard || hasEventClipboard ? this.getCopyDataHTML(data) : null, formulaClipboardData = this.getCopyFormulaPlainData(data, isCut);
277
+ if (null === formulaClipboardData) return null;
278
+ const plainClipboardData = data, internalFormulaText = formulaClipboardData !== plainClipboardData ? formulaClipboardData : void 0, internalFormulaHtmlMarker = internalFormulaText ? this.createInternalFormulaHtmlMarker() : void 0, clipboardHTML = dataHTML && internalFormulaHtmlMarker ? this.attachInternalFormulaHtmlMarker(dataHTML, internalFormulaHtmlMarker) : dataHTML, eventClipboardWriteData = hasEventClipboard ? this.setCopyDataToEventClipboard(plainClipboardData, clipboardHTML, e, internalFormulaText, internalFormulaHtmlMarker) : null;
279
+ if (eventClipboardWriteData) return copiedClipboardData = eventClipboardWriteData,
280
+ this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData),
281
+ copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
282
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !isCut),
283
+ isCut && (null === (_e = table.keyboardOptions) || void 0 === _e ? void 0 : _e.showCopyCellBorder) && window.setTimeout((() => {
284
+ this.isClipboardOperationCurrent(operationId) && ((0, style_1.setActiveCellRangeState)(table, copySnapshot.ranges),
285
+ table.clearSelected());
286
+ }), 0), copySnapshot;
274
287
  const element = table.getElement();
275
- element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
288
+ if (element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))),
289
+ !this.isClipboardOperationCurrent(operationId))) return null;
276
290
  try {
277
291
  if (navigator.clipboard && navigator.clipboard.writeText) {
278
292
  let hasPermission = !0;
279
293
  if (navigator.permissions && navigator.permissions.query) try {
280
- hasPermission = "granted" === (yield navigator.permissions.query({
294
+ if (hasPermission = "granted" === (yield navigator.permissions.query({
281
295
  name: "clipboard-write"
282
- })).state;
296
+ })).state, !this.isClipboardOperationCurrent(operationId)) return null;
283
297
  } catch (permissionError) {
284
298
  hasPermission = !0;
285
299
  }
286
300
  if (hasPermission) try {
287
- if (window.ClipboardItem) {
288
- let htmlValues = data;
289
- 1 === table.stateManager.select.ranges.length && (null === (_d = null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue) || void 0 === _d ? void 0 : _d.html) && (htmlValues = this.table.getCopyValue(null === (_e = table.options.keyboardOptions) || void 0 === _e ? void 0 : _e.getCopyCellValue.html));
290
- const dataHTML = (0, util_1.setDataToHTML)(htmlValues);
291
- yield navigator.clipboard.write([ new ClipboardItem({
292
- "text/html": new Blob([ dataHTML ], {
301
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
302
+ copiedClipboardData = yield this.queueClipboardWrite((() => __awaiter(this, void 0, void 0, (function*() {
303
+ return this.isClipboardOperationCurrent(operationId) ? canWriteRichClipboard && clipboardHTML ? (yield navigator.clipboard.write([ new ClipboardItem({
304
+ "text/html": new Blob([ clipboardHTML ], {
293
305
  type: "text/html"
294
306
  }),
295
- "text/plain": new Blob([ data ], {
307
+ "text/plain": new Blob([ plainClipboardData ], {
296
308
  type: "text/plain"
297
309
  })
298
- }) ]);
299
- } else yield navigator.clipboard.writeText(data);
310
+ }) ]), {
311
+ html: clipboardHTML,
312
+ text: plainClipboardData,
313
+ hasHtml: !0,
314
+ hasText: !0,
315
+ internalFormulaText: internalFormulaText,
316
+ internalFormulaHtmlMarker: internalFormulaHtmlMarker
317
+ }) : (yield navigator.clipboard.writeText(plainClipboardData), {
318
+ html: "",
319
+ text: plainClipboardData,
320
+ hasText: !0,
321
+ internalFormulaText: internalFormulaText
322
+ }) : null;
323
+ })))), copiedClipboardData && (copySucceeded = !0);
300
324
  } catch (clipboardError) {
301
- this.fallbackCopyToClipboard(data, e);
302
- } else this.fallbackCopyToClipboard(data, e);
303
- } else this.fallbackCopyToClipboard(data, e);
304
- table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.COPY_DATA, {
305
- cellRange: table.stateManager.select.ranges,
306
- copyData: data,
307
- isCut: isCut
325
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
326
+ if (copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), !this.isClipboardOperationCurrent(operationId)) return null;
327
+ copySucceeded && (copiedClipboardData = {
328
+ html: "",
329
+ text: plainClipboardData,
330
+ hasText: !0,
331
+ internalFormulaText: internalFormulaText
332
+ });
333
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
334
+ html: "",
335
+ text: plainClipboardData,
336
+ hasText: !0,
337
+ internalFormulaText: internalFormulaText
338
+ });
339
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
340
+ html: "",
341
+ text: plainClipboardData,
342
+ hasText: !0,
343
+ internalFormulaText: internalFormulaText
308
344
  });
345
+ if (!copySucceeded) return null;
346
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
347
+ this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData),
348
+ copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
349
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
309
350
  } catch (error) {
310
- this.fallbackCopyToClipboard(data, e);
351
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
352
+ if (!this.fallbackCopyToClipboard(plainClipboardData)) return null;
353
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
354
+ this.lastCopiedClipboardData = {
355
+ html: "",
356
+ text: plainClipboardData,
357
+ hasText: !0,
358
+ internalFormulaText: internalFormulaText
359
+ }, isCut && (this.lastClipboardContent = this.getClipboardSignature(this.lastCopiedClipboardData),
360
+ copySnapshot.clipboardData = this.lastCopiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
361
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
311
362
  }
312
363
  }
313
- (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && ((0,
314
- style_1.setActiveCellRangeState)(table), table.clearSelected());
364
+ return (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && ((0,
365
+ style_1.setActiveCellRangeState)(table, copySnapshot.ranges), table.clearSelected()),
366
+ copySnapshot;
367
+ }));
368
+ }
369
+ afterCopyData(data, isCut, copySnapshot, updateCopyCellBorder = !0) {
370
+ var _a;
371
+ const table = this.table;
372
+ try {
373
+ table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.COPY_DATA, {
374
+ cellRange: this.cloneRanges(copySnapshot.ranges),
375
+ copyData: data,
376
+ isCut: isCut
377
+ });
378
+ } catch (error) {}
379
+ updateCopyCellBorder && (null === (_a = table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && ((0,
380
+ style_1.setActiveCellRangeState)(table, copySnapshot.ranges), table.clearSelected());
381
+ }
382
+ getCopySnapshot(includeCellInfos) {
383
+ const ranges = this.table.stateManager.select.ranges;
384
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
385
+ const clonedRanges = ranges.map((range => ({
386
+ start: {
387
+ col: range.start.col,
388
+ row: range.start.row
389
+ },
390
+ end: {
391
+ col: range.end.col,
392
+ row: range.end.row
393
+ }
394
+ }))), sourceRange = 1 === ranges.length ? ranges[0] : null, sourceCellMatrix = this.getSourceCellMatrix(clonedRanges), sourceCells = this.getSourceCells(sourceCellMatrix), sourceSize = this.getSourceSize(clonedRanges, sourceCellMatrix);
395
+ return {
396
+ ranges: clonedRanges,
397
+ copySourceRange: sourceRange ? {
398
+ startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
399
+ startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
400
+ } : null,
401
+ cellInfos: includeCellInfos ? this.table.getSelectedCellInfos() : null,
402
+ sourceCells: sourceCells,
403
+ sourceCellMatrix: sourceCellMatrix,
404
+ sourceColCount: sourceSize.colCount,
405
+ sourceRowCount: sourceSize.rowCount,
406
+ clipboardData: null,
407
+ clipboardSignature: ""
408
+ };
409
+ }
410
+ cloneRanges(ranges) {
411
+ return ranges.map((range => ({
412
+ start: {
413
+ col: range.start.col,
414
+ row: range.start.row
415
+ },
416
+ end: {
417
+ col: range.end.col,
418
+ row: range.end.row
419
+ }
420
+ })));
421
+ }
422
+ getSourceCellMatrix(ranges) {
423
+ const table = this.table, createSourceCell = (col, row) => {
424
+ var _a, _b, _c, _d, _e, _f, _g, _h;
425
+ const recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
426
+ return {
427
+ col: col,
428
+ row: row,
429
+ recordIndex: recordShowIndex >= 0 ? null === (_c = null === (_b = table.dataSource) || void 0 === _b ? void 0 : _b.getIndexKey) || void 0 === _c ? void 0 : _c.call(_b, recordShowIndex) : void 0,
430
+ field: null === (_g = null === (_f = null === (_e = null === (_d = table.internalProps) || void 0 === _d ? void 0 : _d.layoutMap) || void 0 === _e ? void 0 : _e.getBody) || void 0 === _f ? void 0 : _f.call(_e, col, row)) || void 0 === _g ? void 0 : _g.field,
431
+ value: null === (_h = table.getCellOriginValue) || void 0 === _h ? void 0 : _h.call(table, col, row)
432
+ };
433
+ };
434
+ if (1 === ranges.length) {
435
+ const range = ranges[0], startCol = Math.min(range.start.col, range.end.col), endCol = Math.max(range.start.col, range.end.col), startRow = Math.min(range.start.row, range.end.row), endRow = Math.max(range.start.row, range.end.row), sourceCellMatrix = [];
436
+ for (let row = startRow; row <= endRow; row++) {
437
+ const rowCells = [];
438
+ for (let col = startCol; col <= endCol; col++) rowCells.push(createSourceCell(col, row));
439
+ sourceCellMatrix.push(rowCells);
440
+ }
441
+ return sourceCellMatrix;
442
+ }
443
+ let minCol = Math.min(ranges[0].start.col, ranges[0].end.col), maxCol = Math.max(ranges[0].start.col, ranges[0].end.col), minRow = Math.min(ranges[0].start.row, ranges[0].end.row), maxRow = Math.max(ranges[0].start.row, ranges[0].end.row);
444
+ ranges.forEach((range => {
445
+ minCol = Math.min(minCol, range.start.col, range.end.col), maxCol = Math.max(maxCol, range.start.col, range.end.col),
446
+ minRow = Math.min(minRow, range.start.row, range.end.row), maxRow = Math.max(maxRow, range.start.row, range.end.row);
447
+ }));
448
+ const isExistDataInRow = row => ranges.some((range => {
449
+ const startRow = Math.min(range.start.row, range.end.row), endRow = Math.max(range.start.row, range.end.row);
450
+ return startRow <= row && endRow >= row;
451
+ })), isExistDataInCol = col => ranges.some((range => {
452
+ const startCol = Math.min(range.start.col, range.end.col), endCol = Math.max(range.start.col, range.end.col);
453
+ return startCol <= col && endCol >= col;
454
+ })), getRangeExistDataInCell = (col, row) => ranges.some((range => {
455
+ const startRow = Math.min(range.start.row, range.end.row), endRow = Math.max(range.start.row, range.end.row), startCol = Math.min(range.start.col, range.end.col), endCol = Math.max(range.start.col, range.end.col);
456
+ return startCol <= col && endCol >= col && startRow <= row && endRow >= row;
457
+ })), sourceCellMatrix = [];
458
+ for (let row = minRow; row <= maxRow; row++) {
459
+ if (!isExistDataInRow(row)) continue;
460
+ const rowCells = [];
461
+ for (let col = minCol; col <= maxCol; col++) isExistDataInCol(col) && rowCells.push(getRangeExistDataInCell(col, row) ? createSourceCell(col, row) : null);
462
+ sourceCellMatrix.push(rowCells);
463
+ }
464
+ return sourceCellMatrix;
465
+ }
466
+ getSourceCells(sourceCellMatrix) {
467
+ const sourceCells = [];
468
+ for (let row = 0; row < sourceCellMatrix.length; row++) for (let col = 0; col < sourceCellMatrix[row].length; col++) {
469
+ const sourceCell = sourceCellMatrix[row][col];
470
+ sourceCell && sourceCells.push(sourceCell);
471
+ }
472
+ return sourceCells;
473
+ }
474
+ getSourceSize(ranges, sourceCellMatrix) {
475
+ var _a, _b;
476
+ if (sourceCellMatrix.length) return {
477
+ colCount: null !== (_b = null === (_a = sourceCellMatrix[0]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0,
478
+ rowCount: sourceCellMatrix.length
479
+ };
480
+ if (1 === ranges.length) {
481
+ const range = ranges[0];
482
+ return {
483
+ colCount: Math.abs(range.end.col - range.start.col) + 1,
484
+ rowCount: Math.abs(range.end.row - range.start.row) + 1
485
+ };
486
+ }
487
+ return {
488
+ colCount: 0,
489
+ rowCount: 0
490
+ };
491
+ }
492
+ getClipboardSignature(data) {
493
+ return data ? JSON.stringify({
494
+ html: data.hasHtml ? data.html : null,
495
+ text: data.hasText ? data.text : null
496
+ }) : "";
497
+ }
498
+ isClipboardOperationCurrent(operationId) {
499
+ return operationId === this.clipboardOperationId && !this.table.isReleased;
500
+ }
501
+ isPasteOperationCurrent(operationId) {
502
+ return (void 0 === operationId || operationId === this.pasteOperationId) && !this.table.isReleased;
503
+ }
504
+ queueClipboardWrite(write) {
505
+ return __awaiter(this, void 0, void 0, (function*() {
506
+ const previousWrite = this.clipboardWritePromise;
507
+ let settleCurrentWrite = () => {};
508
+ this.clipboardWritePromise = previousWrite.catch((() => {})).then((() => new Promise((resolve => {
509
+ settleCurrentWrite = resolve;
510
+ })))), yield previousWrite.catch((() => {}));
511
+ try {
512
+ return yield write();
513
+ } finally {
514
+ settleCurrentWrite();
515
+ }
315
516
  }));
316
517
  }
317
- fallbackCopyToClipboard(data, e) {
518
+ isClipboardDataChanged(clipboardData, cutState) {
519
+ if (!clipboardData || clipboardData.readFailed) return null;
520
+ const sourceData = cutState.clipboardData;
521
+ if (!sourceData) return this.getClipboardSignature(clipboardData) !== cutState.clipboardSignature;
522
+ if (sourceData.hasHtml && !clipboardData.hasHtml) return null;
523
+ if (sourceData.hasText && !clipboardData.hasText) return null;
524
+ let hasComparableType = !1;
525
+ return !(!clipboardData.hasHtml || !sourceData.hasHtml || (hasComparableType = !0,
526
+ clipboardData.html === sourceData.html)) || (!(!clipboardData.hasText || !sourceData.hasText || (hasComparableType = !0,
527
+ clipboardData.text === sourceData.text)) || !hasComparableType && null);
528
+ }
529
+ isClipboardDataSameAsLastCopy(clipboardData) {
530
+ const sourceData = this.lastCopiedClipboardData;
531
+ return !(!clipboardData || clipboardData.readFailed || !sourceData) && this.isClipboardDataSameBySignature(clipboardData, sourceData);
532
+ }
533
+ isClipboardDataSameBySignature(clipboardData, sourceData) {
534
+ return !(sourceData.hasHtml !== clipboardData.hasHtml || sourceData.hasText !== clipboardData.hasText || sourceData.hasHtml && sourceData.html !== clipboardData.html || sourceData.hasText && sourceData.text !== clipboardData.text);
535
+ }
536
+ getCopyFormulaPlainData(data, isCut) {
537
+ var _a, _b;
538
+ const table = this.table;
539
+ if (1 !== table.stateManager.select.ranges.length || !(null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.html)) return data;
540
+ try {
541
+ return this.table.getCopyValue(table.options.keyboardOptions.getCopyCellValue.html);
542
+ } catch (error) {
543
+ return isCut ? null : data;
544
+ }
545
+ }
546
+ getCopyDataHTML(data) {
547
+ var _a, _b, _c;
548
+ const table = this.table;
549
+ let htmlValues = data;
550
+ try {
551
+ return 1 === table.stateManager.select.ranges.length && (null === (_b = null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.getCopyCellValue) || void 0 === _b ? void 0 : _b.html) && (htmlValues = this.table.getCopyValue(null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.getCopyCellValue.html)),
552
+ (0, util_1.setDataToHTML)(htmlValues);
553
+ } catch (error) {
554
+ try {
555
+ return (0, util_1.setDataToHTML)(data);
556
+ } catch (fallbackError) {
557
+ return null;
558
+ }
559
+ }
560
+ }
561
+ createInternalFormulaHtmlMarker() {
562
+ return `vtable-formula-${Date.now()}-${++this.internalFormulaHtmlMarkerId}`;
563
+ }
564
+ attachInternalFormulaHtmlMarker(html, marker) {
565
+ return `${html}\x3c!--${marker}--\x3e`;
566
+ }
567
+ setCopyDataToEventClipboard(data, dataHTML, e, internalFormulaText, internalFormulaHtmlMarker) {
568
+ const clipboardData = e.clipboardData;
569
+ if (!clipboardData) return null;
570
+ try {
571
+ clipboardData.setData("text/plain", data);
572
+ const copiedClipboardData = {
573
+ html: "",
574
+ text: data,
575
+ hasText: !0,
576
+ internalFormulaText: internalFormulaText
577
+ };
578
+ if (dataHTML) try {
579
+ clipboardData.setData("text/html", dataHTML), copiedClipboardData.html = dataHTML,
580
+ copiedClipboardData.hasHtml = !0, copiedClipboardData.internalFormulaHtmlMarker = internalFormulaHtmlMarker;
581
+ } catch (error) {}
582
+ return copiedClipboardData;
583
+ } catch (error) {
584
+ return null;
585
+ }
586
+ }
587
+ fallbackCopyToClipboard(data) {
318
588
  try {
319
- if (e.clipboardData) return void e.clipboardData.setData("text/plain", data);
320
589
  document.activeElement && document.activeElement !== document.body && document.activeElement.blur();
321
590
  const textArea = document.createElement("textarea");
322
591
  textArea.value = data, textArea.style.position = "fixed", textArea.style.left = "-999999px",
@@ -324,198 +593,432 @@ class EventManager {
324
593
  textArea.setAttribute("aria-hidden", "true"), document.body.appendChild(textArea),
325
594
  textArea.focus(), textArea.select(), textArea.setSelectionRange(0, data.length);
326
595
  try {
327
- document.execCommand("copy");
596
+ const successful = document.execCommand("copy");
597
+ return successful;
328
598
  } catch (execError) {} finally {
329
599
  document.body.removeChild(textArea);
330
600
  }
331
601
  } catch (error) {}
602
+ return !1;
332
603
  }
333
604
  handleCut(e) {
334
- var _a;
335
605
  return __awaiter(this, void 0, void 0, (function*() {
336
- this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(),
337
- this.cutRanges = null === (_a = this.table.stateManager.select.ranges) || void 0 === _a ? void 0 : _a.map((r => ({
338
- start: {
339
- col: r.start.col,
340
- row: r.start.row
341
- },
342
- end: {
343
- col: r.end.col,
344
- row: r.end.row
345
- }
346
- }))), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout((() => {
347
- this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.cutRanges = null,
348
- this.clipboardCheckTimer = null);
349
- }), 3e4), this.saveClipboardContent();
606
+ const copySnapshot = yield this.handleCopy(e, !0);
607
+ if (!copySnapshot) return;
608
+ const cutState = {
609
+ id: ++this.cutOperationId,
610
+ ranges: this.cloneRanges(copySnapshot.ranges),
611
+ cellInfos: copySnapshot.cellInfos,
612
+ sourceCells: copySnapshot.sourceCells,
613
+ sourceCellMatrix: copySnapshot.sourceCellMatrix,
614
+ sourceColCount: copySnapshot.sourceColCount,
615
+ sourceRowCount: copySnapshot.sourceRowCount,
616
+ clipboardData: copySnapshot.clipboardData,
617
+ clipboardSignature: copySnapshot.clipboardSignature,
618
+ copySourceRange: copySnapshot.copySourceRange,
619
+ isSingleRange: 1 === copySnapshot.ranges.length
620
+ };
621
+ this.cutWaitPaste = !0, this.activeCutState = cutState, this.cutCellRange = cutState.cellInfos,
622
+ this.cutRanges = cutState.ranges, this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer),
623
+ this.clipboardCheckTimer = window.setTimeout((() => {
624
+ this.cutWaitPaste && this.resetCutState();
625
+ }), 3e4), this.lastClipboardContent = cutState.clipboardSignature;
350
626
  }));
351
627
  }
352
628
  handlePaste(e) {
353
- this.cutWaitPaste ? this.checkClipboardChanged().then((changed => {
354
- this.executePaste(e), changed || this.clearCutArea(this.table), this.cutWaitPaste && (this.cutWaitPaste = !1,
355
- this.cutCellRange = null, this.cutRanges = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer),
356
- this.clipboardCheckTimer = null));
357
- })).catch((() => {
358
- this.executePaste(e), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null,
359
- this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
360
- })) : this.executePaste(e);
361
- }
362
- executePaste(e) {
363
- var _a, _b, _c;
629
+ const pasteOperationId = ++this.pasteOperationId, pasteRange = this.getPasteRange();
630
+ if (!pasteRange) return;
631
+ const eventClipboardData = this.getEventClipboardData(e), pasteCopySourceRange = this.copySourceRange;
632
+ if (!this.cutWaitPaste) return void this.readClipboardDataForPaste(eventClipboardData).then((clipboardData => {
633
+ if (!this.isPasteOperationCurrent(pasteOperationId)) return;
634
+ const copySourceRange = this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null;
635
+ this.executePaste(clipboardData, {
636
+ pasteRange: pasteRange,
637
+ copySourceRange: copySourceRange,
638
+ pasteOperationId: pasteOperationId
639
+ });
640
+ })).catch((error => {}));
641
+ const cutState = this.activeCutState;
642
+ cutState ? this.readClipboardDataForPaste(eventClipboardData).then((clipboardData => __awaiter(this, void 0, void 0, (function*() {
643
+ var _a, _b, _c, _d, _e;
644
+ if (!this.isPasteOperationCurrent(pasteOperationId) || (null === (_a = this.activeCutState) || void 0 === _a ? void 0 : _a.id) !== cutState.id) return;
645
+ const changed = this.isClipboardDataChanged(clipboardData, cutState);
646
+ if (null === changed) return void (yield this.executePaste(clipboardData, {
647
+ pasteRange: pasteRange,
648
+ copySourceRange: this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null,
649
+ pasteOperationId: pasteOperationId
650
+ }));
651
+ const pasteResult = yield this.executePaste(clipboardData, {
652
+ pasteRange: pasteRange,
653
+ copySourceRange: changed ? null : cutState.copySourceRange,
654
+ cutState: changed ? null : cutState,
655
+ pasteOperationId: pasteOperationId
656
+ });
657
+ if (this.isPasteOperationCurrent(pasteOperationId) && (null === (_b = this.activeCutState) || void 0 === _b ? void 0 : _b.id) === cutState.id) if (changed || !pasteResult.pasted || (null === (_c = this.activeCutState) || void 0 === _c ? void 0 : _c.id) !== cutState.id) changed && (null === (_e = this.activeCutState) || void 0 === _e ? void 0 : _e.id) === cutState.id && this.resetCutState(); else if (pasteResult.migratedSourceCells.length === cutState.sourceCells.length) {
658
+ if (!(yield this.clearCutArea(pasteResult.migratedSourceCells, pasteResult.changedCells))) return void this.resetCutState();
659
+ (null === (_d = this.activeCutState) || void 0 === _d ? void 0 : _d.id) === cutState.id && this.resetCutState();
660
+ }
661
+ })))).catch((() => __awaiter(this, void 0, void 0, (function*() {
662
+ this.isPasteOperationCurrent(pasteOperationId) && (yield this.executePaste(eventClipboardData, {
663
+ pasteRange: pasteRange,
664
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
665
+ pasteOperationId: pasteOperationId
666
+ }));
667
+ })))) : this.executePaste(eventClipboardData, {
668
+ pasteRange: pasteRange,
669
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
670
+ pasteOperationId: pasteOperationId
671
+ });
672
+ }
673
+ executePaste(clipboardData, pasteContext) {
674
+ var _a, _b, _c, _d;
364
675
  return __awaiter(this, void 0, void 0, (function*() {
365
- const table = this.table;
366
- if (!(null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) {
367
- if (table.changeCellValues && (null === (_b = table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 0) try {
368
- if (navigator.clipboard && navigator.clipboard.read) try {
369
- const clipboardItems = yield navigator.clipboard.read();
370
- let handled = !1;
371
- for (const item of clipboardItems) {
372
- if (item.types.includes("text/html")) {
373
- yield this.pasteHtmlToTable(item), handled = !0;
374
- break;
375
- }
376
- if (item.types.includes("text/plain")) {
377
- yield this.pasteTextToTable(item), handled = !0;
378
- break;
379
- }
380
- }
381
- handled || (yield this.fallbackPasteFromClipboard(e));
382
- } catch (clipboardError) {
383
- yield this.fallbackPasteFromClipboard(e);
384
- } else yield this.fallbackPasteFromClipboard(e);
676
+ const table = this.table, emptyResult = this.getEmptyPasteResult(), pasteClipboardData = this.getPasteClipboardData(clipboardData, pasteContext);
677
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) return emptyResult;
678
+ if (this.pasteWriteInProgress && (yield this.pasteWritePromise.catch((() => {})),
679
+ !this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_b = table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor))) return emptyResult;
680
+ let pasteResult = emptyResult, settlePasteWrite = () => {};
681
+ this.pasteWritePromise = new Promise((resolve => {
682
+ settlePasteWrite = resolve;
683
+ })), this.pasteWriteInProgress = !0;
684
+ try {
685
+ if (table.changeCellValues) try {
686
+ if (null == pasteClipboardData ? void 0 : pasteClipboardData.html) try {
687
+ const htmlResult = yield this.processPastedHTML(pasteClipboardData.html, pasteContext);
688
+ if (htmlResult.pasted) return pasteResult = htmlResult, pasteResult;
689
+ } catch (error) {
690
+ if (/<table\b/i.test(pasteClipboardData.html)) return emptyResult;
691
+ }
692
+ if ((null == pasteClipboardData ? void 0 : pasteClipboardData.hasText) || (null == pasteClipboardData ? void 0 : pasteClipboardData.text)) return pasteResult = yield this.processPastedText(null !== (_c = pasteClipboardData.internalFormulaText) && void 0 !== _c ? _c : pasteClipboardData.text, pasteContext),
693
+ pasteResult;
385
694
  } catch (error) {
386
- yield this.fallbackPasteFromClipboard(e);
695
+ pasteContext.cutState && this.resetCutState();
387
696
  }
388
- (null === (_c = table.keyboardOptions) || void 0 === _c ? void 0 : _c.showCopyCellBorder) && (0,
697
+ return pasteResult;
698
+ } finally {
699
+ this.pasteWriteInProgress = !1, settlePasteWrite(), !pasteContext.cutState && (null === (_d = table.keyboardOptions) || void 0 === _d ? void 0 : _d.showCopyCellBorder) && (0,
389
700
  style_1.clearActiveCellRangeState)(table);
390
701
  }
391
702
  }));
392
703
  }
393
- fallbackPasteFromClipboard(e) {
704
+ getPasteClipboardData(clipboardData, pasteContext) {
705
+ var _a, _b;
706
+ if (!clipboardData || !pasteContext.copySourceRange) return clipboardData;
707
+ const sourceData = null !== (_b = null === (_a = pasteContext.cutState) || void 0 === _a ? void 0 : _a.clipboardData) && void 0 !== _b ? _b : this.lastCopiedClipboardData;
708
+ return (null == sourceData ? void 0 : sourceData.internalFormulaText) && sourceData.internalFormulaHtmlMarker && sourceData.hasHtml && clipboardData.hasHtml && this.isClipboardDataSameBySignature(clipboardData, sourceData) && clipboardData.html.includes(sourceData.internalFormulaHtmlMarker) ? Object.assign(Object.assign({}, clipboardData), {
709
+ internalFormulaText: sourceData.internalFormulaText
710
+ }) : clipboardData;
711
+ }
712
+ getPasteRange() {
713
+ const ranges = this.table.stateManager.select.ranges;
714
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
715
+ const range = ranges[ranges.length - 1];
716
+ return {
717
+ col: Math.min(range.start.col, range.end.col),
718
+ row: Math.min(range.start.row, range.end.row),
719
+ maxCol: Math.max(range.start.col, range.end.col),
720
+ maxRow: Math.max(range.start.row, range.end.row)
721
+ };
722
+ }
723
+ getEventClipboardData(e) {
724
+ var _a;
725
+ const clipboardData = e.clipboardData || window.clipboardData;
726
+ if (!clipboardData) return null;
727
+ try {
728
+ const types = Array.from(null !== (_a = clipboardData.types) && void 0 !== _a ? _a : []), html = clipboardData.getData("text/html") || "", text = clipboardData.getData("text/plain") || clipboardData.getData("text") || clipboardData.getData("Text") || "", hasHtml = types.includes("text/html") || !!html;
729
+ return {
730
+ html: html,
731
+ text: text,
732
+ hasHtml: hasHtml,
733
+ hasText: types.includes("text/plain") || types.includes("text") || types.includes("Text") || !!text
734
+ };
735
+ } catch (error) {
736
+ return {
737
+ html: "",
738
+ text: "",
739
+ readFailed: !0
740
+ };
741
+ }
742
+ }
743
+ readClipboardDataForPaste(eventClipboardData) {
744
+ var _a, _b;
394
745
  return __awaiter(this, void 0, void 0, (function*() {
395
- const table = this.table, ranges = table.stateManager.select.ranges, col = Math.min(ranges[0].start.col, ranges[0].end.col), row = Math.min(ranges[0].start.row, ranges[0].end.row);
396
- try {
397
- const element = table.getElement();
398
- element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
399
- const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
400
- if (clipboardData) {
401
- const pastedData = clipboardData.getData("text") || clipboardData.getData("Text");
402
- if (pastedData) return void (yield this.processPastedText(pastedData, col, row));
746
+ if ((null == eventClipboardData ? void 0 : eventClipboardData.readFailed) || (null == eventClipboardData ? void 0 : eventClipboardData.hasHtml) || (null == eventClipboardData ? void 0 : eventClipboardData.hasText)) return eventClipboardData;
747
+ if (null === (_a = navigator.clipboard) || void 0 === _a ? void 0 : _a.read) try {
748
+ const clipboardItems = yield navigator.clipboard.read(), clipboardData = {
749
+ html: "",
750
+ text: ""
751
+ };
752
+ for (const item of clipboardItems) {
753
+ if (!clipboardData.html && item.types.includes("text/html")) try {
754
+ clipboardData.html = yield (yield item.getType("text/html")).text(), clipboardData.hasHtml = !0;
755
+ } catch (error) {}
756
+ if (!clipboardData.text && item.types.includes("text/plain")) try {
757
+ clipboardData.text = yield (yield item.getType("text/plain")).text(), clipboardData.hasText = !0;
758
+ } catch (error) {}
403
759
  }
760
+ if (clipboardData.hasHtml || clipboardData.hasText) return clipboardData;
404
761
  } catch (error) {}
762
+ if (null === (_b = navigator.clipboard) || void 0 === _b ? void 0 : _b.readText) try {
763
+ return {
764
+ html: "",
765
+ text: yield navigator.clipboard.readText(),
766
+ hasText: !0
767
+ };
768
+ } catch (error) {}
769
+ return null != eventClipboardData ? eventClipboardData : {
770
+ html: "",
771
+ text: "",
772
+ readFailed: !0
773
+ };
405
774
  }));
406
775
  }
407
- processPastedText(pastedData, col, row) {
776
+ decodeHTMLCellValue(cellHTML) {
408
777
  var _a;
409
- return __awaiter(this, void 0, void 0, (function*() {
410
- const table = this.table, rows = pastedData.split("\n"), values = [];
411
- let processedValues;
412
- rows.forEach((function(rowCells) {
413
- const cells = rowCells.split("\t"), rowValues = [];
414
- values.push(rowValues), cells.forEach((function(cell, cellIndex) {
415
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
416
- }));
417
- })), (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
418
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
419
- table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
420
- col: col,
421
- row: row,
422
- pasteData: processedValues || values,
423
- changedCellResults: changedCellResults
424
- });
425
- }));
778
+ const template = document.createElement("template");
779
+ return template.innerHTML = cellHTML.replace(/<br\b[^>]*>(?:\r\n|\r|\n)?/gim, "\n").replace(/&nbsp;/gi, " "),
780
+ null !== (_a = template.content.textContent) && void 0 !== _a ? _a : "";
426
781
  }
427
- clearCutArea(table) {
428
- try {
429
- const ranges = this.cutRanges;
430
- if (!ranges || 0 === ranges.length) return;
431
- table.changeCellValuesByRanges(ranges, "");
432
- } catch (error) {}
433
- }
434
- checkClipboardChanged() {
782
+ processPastedHTML(pastedData, pasteContext) {
783
+ var _a, _b, _c;
435
784
  return __awaiter(this, void 0, void 0, (function*() {
436
- if (!navigator.clipboard || !navigator.clipboard.readText) return !1;
437
- try {
438
- return (yield navigator.clipboard.readText()) !== this.lastClipboardContent;
439
- } catch (err) {
440
- return !1;
785
+ const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi, table = this.table, pasteRange = pasteContext.pasteRange, {col: col, row: row, maxCol: maxCol, maxRow: maxRow} = pasteRange;
786
+ let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
787
+ if (!pastedData || !/<table\b/i.test(pastedData)) return this.getEmptyPasteResult();
788
+ const matches = Array.from(pastedData.matchAll(/<tr[^>]*>([\s\S]*?)<\/tr>/gi));
789
+ for (const match of matches) {
790
+ const rowContent = match[1], cellMatches = Array.from(rowContent.matchAll(cellRegex));
791
+ if (!cellMatches.length) continue;
792
+ const rowValues = cellMatches.map((cellMatch => this.decodeHTMLCellValue(cellMatch[1])));
793
+ values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
441
794
  }
795
+ if (pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0,
796
+ !pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
797
+ let processedValues;
798
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
799
+ (null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && pasteContext.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row));
800
+ const valuesToPaste = processedValues || values, targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
801
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
802
+ if (pasteContext.cutState) {
803
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
804
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
805
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
806
+ }
807
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, (() => !this.isPasteOperationCurrent(pasteContext.pasteOperationId)));
808
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
809
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste), changedCells = this.getChangedCells(targetCells, changedCellResults), migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
810
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults),
811
+ {
812
+ pasted: !0,
813
+ changedCellResults: changedCellResults,
814
+ changedCells: changedCells,
815
+ migratedSourceCells: migratedSourceCells
816
+ }) : this.getEmptyPasteResult(changedCellResults);
442
817
  }));
443
818
  }
444
- saveClipboardContent() {
445
- navigator.clipboard && navigator.clipboard.readText && setTimeout((() => {
446
- navigator.clipboard.readText().then((text => {
447
- this.lastClipboardContent = text;
448
- })).catch((err => {}));
449
- }), 50);
450
- }
451
- pasteHtmlToTable(item) {
452
- const regex = /<tr[^>]*>([\s\S]*?)<\/tr>/g, cellRegex = /<td[^>]*>([\s\S]*?)<\/td>/g, table = this.table, ranges = table.stateManager.select.ranges, selectRangeLength = ranges.length, col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row), maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
453
- let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
454
- item.getType("text/html").then((blob => {
455
- blob.text().then((pastedData => __awaiter(this, void 0, void 0, (function*() {
456
- var _a, _b, _c;
457
- if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
458
- const matches = Array.from(pastedData.matchAll(regex));
459
- for (const match of matches) {
460
- const rowContent = match[1], rowValues = Array.from(rowContent.matchAll(cellRegex)).map((cellMatch => cellMatch[1].replace(/(<(?!br)([^>]+)>)/gi, "").replace(/<br(\s*|\/)>[\r\n]?/gim, "\n").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&#9;/gi, "\t").replace(/&nbsp;/g, " ")));
461
- values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
462
- }
463
- let processedValues;
464
- pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
465
- (null === (_c = table.options.keyboardOptions) || void 0 === _c ? void 0 : _c.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
466
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
467
- table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
468
- col: col,
469
- row: row,
470
- pasteData: processedValues || values,
471
- changedCellResults: changedCellResults
472
- });
473
- } else navigator.clipboard.read().then((clipboardItems => {
474
- for (const item of clipboardItems) item.types.includes("text/plain") && item.getType("text/plain").then((blob => {
475
- blob.text().then((data => this._pasteValue(data)));
476
- }));
477
- }));
478
- }))));
479
- }));
480
- }
481
- _pasteValue(pastedData) {
482
- var _a, _b;
819
+ processPastedText(pastedData, pasteContext) {
820
+ var _a;
483
821
  return __awaiter(this, void 0, void 0, (function*() {
484
- const table = this.table, ranges = table.stateManager.select.ranges, selectRangeLength = ranges.length, col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row), maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
485
- let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
822
+ const table = this.table, pasteRange = pasteContext.pasteRange, {col: col, row: row, maxCol: maxCol, maxRow: maxRow} = pasteRange;
823
+ let values = this.parsePlainTextPastedData(pastedData);
824
+ const pasteValuesRowCount = values.length, pasteValuesColCount = Math.max(...values.map((rowValues => rowValues.length)));
825
+ if (!pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
486
826
  let processedValues;
487
- pastedData.split("\n").forEach((function(rowCells, rowIndex) {
488
- var _a;
489
- const cells = rowCells.split("\t"), rowValues = [];
490
- values.push(rowValues), cells.forEach((function(cell, cellIndex) {
491
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
492
- })), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
493
- })), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0,
494
827
  values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
495
- (null === (_b = table.options.keyboardOptions) || void 0 === _b ? void 0 : _b.processFormulaBeforePaste) && this.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, this.copySourceRange.startCol, this.copySourceRange.startRow, col, row));
496
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
497
- table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
828
+ (null === (_a = table.options.keyboardOptions) || void 0 === _a ? void 0 : _a.processFormulaBeforePaste) && pasteContext.copySourceRange && (processedValues = table.options.keyboardOptions.processFormulaBeforePaste(values, pasteContext.copySourceRange.startCol, pasteContext.copySourceRange.startRow, col, row));
829
+ const valuesToPaste = processedValues || values, targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
830
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
831
+ if (pasteContext.cutState) {
832
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
833
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
834
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
835
+ }
836
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, (() => !this.isPasteOperationCurrent(pasteContext.pasteOperationId)));
837
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
838
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste), changedCells = this.getChangedCells(targetCells, changedCellResults), migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
839
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults),
840
+ {
841
+ pasted: !0,
842
+ changedCellResults: changedCellResults,
843
+ changedCells: changedCells,
844
+ migratedSourceCells: migratedSourceCells
845
+ }) : this.getEmptyPasteResult(changedCellResults);
846
+ }));
847
+ }
848
+ firePastedDataEvent(col, row, pasteData, changedCellResults) {
849
+ const table = this.table;
850
+ if (table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA)) try {
851
+ table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
498
852
  col: col,
499
853
  row: row,
500
- pasteData: processedValues || values,
854
+ pasteData: pasteData,
501
855
  changedCellResults: changedCellResults
502
856
  });
857
+ } catch (error) {}
858
+ }
859
+ getEmptyPasteResult(changedCellResults = []) {
860
+ return {
861
+ pasted: !1,
862
+ changedCellResults: changedCellResults,
863
+ changedCells: [],
864
+ migratedSourceCells: []
865
+ };
866
+ }
867
+ getPasteTargetCells(pasteRange, values) {
868
+ const targetCells = [];
869
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
870
+ targetCells[rowIndex] = [];
871
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) targetCells[rowIndex][colIndex] = this.getCellIdentity(pasteRange.col + colIndex, pasteRange.row + rowIndex);
872
+ }
873
+ return targetCells;
874
+ }
875
+ getChangedCells(targetCells, changedCellResults) {
876
+ var _a, _b, _c;
877
+ const changedCells = [];
878
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_b = null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); colIndex++) changedCellResults[rowIndex][colIndex] && (null === (_c = targetCells[rowIndex]) || void 0 === _c ? void 0 : _c[colIndex]) && changedCells.push(targetCells[rowIndex][colIndex]);
879
+ return changedCells;
880
+ }
881
+ normalizeChangedCellResults(changedCellResults, pasteRange, values) {
882
+ if (Array.isArray(changedCellResults)) return changedCellResults;
883
+ const table = this.table;
884
+ return values.map(((rowValues, rowIndex) => rowValues.map(((_value, colIndex) => {
885
+ const targetCol = pasteRange.col + colIndex, targetRow = pasteRange.row + rowIndex;
886
+ return targetCol < table.colCount && targetRow < table.rowCount && (!table.isHasEditorDefine || table.isHasEditorDefine(targetCol, targetRow));
887
+ }))));
888
+ }
889
+ validatePasteTargetCells(pasteRange, values) {
890
+ var _a, _b, _c, _d;
891
+ return __awaiter(this, void 0, void 0, (function*() {
892
+ const table = this.table, changedCellResults = [];
893
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
894
+ changedCellResults[rowIndex] = [];
895
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) {
896
+ const targetCol = pasteRange.col + colIndex, targetRow = pasteRange.row + rowIndex, tableAny = table;
897
+ let canChange = targetCol < tableAny.colCount && targetRow < tableAny.rowCount && (!tableAny.isHasEditorDefine || tableAny.isHasEditorDefine(targetCol, targetRow));
898
+ if (canChange) {
899
+ const editor = null === (_a = tableAny.getEditor) || void 0 === _a ? void 0 : _a.call(tableAny, targetCol, targetRow), oldValue = null === (_b = table.getCellOriginValue) || void 0 === _b ? void 0 : _b.call(table, targetCol, targetRow), validateResult = null === (_d = null === (_c = null == editor ? void 0 : editor.validateValue) || void 0 === _c ? void 0 : _c.call(editor, values[rowIndex][colIndex], oldValue, {
900
+ col: targetCol,
901
+ row: targetRow
902
+ }, table)) || void 0 === _d || _d, resolvedValidateResult = validateResult && "function" == typeof validateResult.then ? yield validateResult : validateResult;
903
+ canChange = !0 === resolvedValidateResult || "validate-exit" === resolvedValidateResult || "validate-not-exit" === resolvedValidateResult;
904
+ }
905
+ changedCellResults[rowIndex][colIndex] = canChange;
906
+ }
907
+ }
908
+ return changedCellResults;
503
909
  }));
504
910
  }
505
- pasteTextToTable(item) {
911
+ isFullPasteAllowed(values, changedCellResults) {
912
+ return values.every(((rowValues, rowIndex) => rowValues.every(((_value, colIndex) => {
913
+ var _a;
914
+ return !0 === (null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex]);
915
+ }))));
916
+ }
917
+ getMigratedSourceCells(cutState, changedCellResults) {
918
+ var _a, _b, _c, _d, _e;
919
+ if (!(null == cutState ? void 0 : cutState.sourceCells.length) || !cutState.sourceColCount || !cutState.sourceRowCount) return [];
920
+ const migratedSourceCells = [], migratedKeys = new Set;
921
+ if (!cutState.isSingleRange) {
922
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_b = null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); colIndex++) {
923
+ if (!changedCellResults[rowIndex][colIndex]) continue;
924
+ const sourceRow = rowIndex % cutState.sourceRowCount, sourceCol = colIndex % cutState.sourceColCount, sourceCell = null === (_c = cutState.sourceCellMatrix[sourceRow]) || void 0 === _c ? void 0 : _c[sourceCol];
925
+ if (!sourceCell) continue;
926
+ const sourceKey = this.getCellKey(sourceCell);
927
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
928
+ }
929
+ return migratedSourceCells.length === cutState.sourceCells.length ? migratedSourceCells : [];
930
+ }
931
+ for (let rowIndex = 0; rowIndex < changedCellResults.length; rowIndex++) for (let colIndex = 0; colIndex < (null !== (_e = null === (_d = changedCellResults[rowIndex]) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0); colIndex++) {
932
+ if (!changedCellResults[rowIndex][colIndex]) continue;
933
+ const sourceRow = rowIndex % cutState.sourceRowCount, sourceCol = colIndex % cutState.sourceColCount, sourceIndex = sourceRow * cutState.sourceColCount + sourceCol, sourceCell = cutState.sourceCells[sourceIndex];
934
+ if (!sourceCell) continue;
935
+ const sourceKey = this.getCellKey(sourceCell);
936
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
937
+ }
938
+ return migratedSourceCells;
939
+ }
940
+ getCellIdentity(col, row) {
941
+ var _a, _b, _c, _d, _e, _f, _g;
942
+ const table = this.table, recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
943
+ return {
944
+ col: col,
945
+ row: row,
946
+ recordIndex: recordShowIndex >= 0 ? null === (_c = null === (_b = table.dataSource) || void 0 === _b ? void 0 : _b.getIndexKey) || void 0 === _c ? void 0 : _c.call(_b, recordShowIndex) : void 0,
947
+ field: null === (_g = null === (_f = null === (_e = null === (_d = table.internalProps) || void 0 === _d ? void 0 : _d.layoutMap) || void 0 === _e ? void 0 : _e.getBody) || void 0 === _f ? void 0 : _f.call(_e, col, row)) || void 0 === _g ? void 0 : _g.field
948
+ };
949
+ }
950
+ clearCutArea(migratedSourceCells, changedTargetCells) {
951
+ var _a, _b;
506
952
  return __awaiter(this, void 0, void 0, (function*() {
507
- const table = this.table, ranges = table.stateManager.select.ranges, selectRangeLength = ranges.length, col = Math.min(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), row = Math.min(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row), maxCol = Math.max(ranges[selectRangeLength - 1].start.col, ranges[selectRangeLength - 1].end.col), maxRow = Math.max(ranges[selectRangeLength - 1].start.row, ranges[selectRangeLength - 1].end.row);
508
953
  try {
509
- const blob = yield item.getType("text/plain"), pastedData = yield blob.text(), values = this.parsePastedData(pastedData), pasteValuesRowCount = values.length, pasteValuesColCount = Math.max(...values.map((row => row.length)), 0), processedValues = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1), changedCellResults = yield table.changeCellValues(col, row, processedValues, !0);
510
- table.hasListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.PASTED_DATA, {
511
- col: col,
512
- row: row,
513
- pasteData: processedValues,
514
- changedCellResults: changedCellResults
954
+ const table = this.table, changedTargetKeys = new Set;
955
+ changedTargetCells.forEach((cell => {
956
+ changedTargetKeys.add(this.getCellKey(cell)), changedTargetKeys.add(this.getCoordKey(cell));
957
+ }));
958
+ const clearedKeys = new Set, sourceChanges = [], coordChanges = [];
959
+ for (let i = 0; i < migratedSourceCells.length; i++) {
960
+ const sourceCell = migratedSourceCells[i], sourceKey = this.getCellKey(sourceCell);
961
+ if (clearedKeys.has(sourceKey) || changedTargetKeys.has(sourceKey) || changedTargetKeys.has(this.getCoordKey(sourceCell))) continue;
962
+ const currentAddress = this.getCurrentCellAddress(sourceCell);
963
+ currentAddress && (this.isSourceCellUnchanged(sourceCell, currentAddress) && (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.changeCellValuesByRecords ? sourceChanges.push({
964
+ recordIndex: sourceCell.recordIndex,
965
+ field: sourceCell.field,
966
+ value: ""
967
+ }) : coordChanges.push(currentAddress), clearedKeys.add(sourceKey)));
968
+ }
969
+ sourceChanges.length && table.changeCellValuesByRecords(sourceChanges, {
970
+ triggerEvent: !0,
971
+ autoRefresh: !1
515
972
  });
516
- } catch (error) {}
973
+ for (let i = 0; i < coordChanges.length; i++) yield table.changeCellValues(coordChanges[i].col, coordChanges[i].row, [ [ "" ] ], !1);
974
+ return sourceChanges.length && (null === (_b = (_a = table).refreshAfterSourceChange) || void 0 === _b || _b.call(_a)),
975
+ !0;
976
+ } catch (error) {
977
+ return !1;
978
+ }
517
979
  }));
518
980
  }
981
+ isSourceCellUnchanged(sourceCell, currentAddress) {
982
+ var _a;
983
+ const table = this.table;
984
+ return Object.is(null === (_a = table.getCellOriginValue) || void 0 === _a ? void 0 : _a.call(table, currentAddress.col, currentAddress.row), sourceCell.value);
985
+ }
986
+ getCurrentCellAddress(sourceCell) {
987
+ const table = this.table;
988
+ if (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.getCellAddrByFieldRecord) {
989
+ const address = table.getCellAddrByFieldRecord(sourceCell.field, sourceCell.recordIndex);
990
+ return address && address.col >= 0 && address.row >= 0 ? address : null;
991
+ }
992
+ return {
993
+ col: sourceCell.col,
994
+ row: sourceCell.row
995
+ };
996
+ }
997
+ getCellKey(cell) {
998
+ return void 0 !== cell.recordIndex && void 0 !== cell.field ? `record:${this.getStableKeyPart(cell.recordIndex)}:${this.getStableKeyPart(cell.field)}` : this.getCoordKey(cell);
999
+ }
1000
+ getCoordKey(cell) {
1001
+ return `coord:${cell.col}:${cell.row}`;
1002
+ }
1003
+ getStableKeyPart(value) {
1004
+ if (null === value) return "null";
1005
+ const valueType = typeof value;
1006
+ if ("string" === valueType || "number" === valueType || "boolean" === valueType) return `${valueType}:${JSON.stringify(value)}`;
1007
+ if (Array.isArray(value)) return `array:[${value.map((item => this.getStableKeyPart(item))).join(",")}]`;
1008
+ if ("object" === valueType || "function" === valueType) {
1009
+ let id = this.fieldKeyIds.get(value);
1010
+ return void 0 === id && (id = ++this.fieldKeyId, this.fieldKeyIds.set(value, id)),
1011
+ `${valueType}:#${id}`;
1012
+ }
1013
+ return `${valueType}:${String(value)}`;
1014
+ }
1015
+ resetCutState() {
1016
+ var _a;
1017
+ this.cutWaitPaste = !1, this.activeCutState = null, this.cutCellRange = null, this.cutRanges = null,
1018
+ (null === (_a = this.table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && (0,
1019
+ style_1.clearActiveCellRangeState)(this.table), this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer),
1020
+ this.clipboardCheckTimer = null);
1021
+ }
519
1022
  parsePastedData(pastedData) {
520
1023
  const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n"), values = [];
521
1024
  return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.forEach((rowCells => {
@@ -523,6 +1026,10 @@ class EventManager {
523
1026
  values.push(rowValues);
524
1027
  })), values;
525
1028
  }
1029
+ parsePlainTextPastedData(pastedData) {
1030
+ const rows = pastedData.replace(/\r\n|\r/g, "\n").split("\n");
1031
+ return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.map((rowCells => rowCells.split("\t")));
1032
+ }
526
1033
  processCellValue(cell) {
527
1034
  cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, (match => new Array(Math.floor(match.length / 2)).fill('"').join(""))));
528
1035
  const numValue = Number(cell);