@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
package/es/event/event.js CHANGED
@@ -73,10 +73,14 @@ import { clearActiveCellRangeState, setActiveCellRangeState } from "../tools/sty
73
73
  export class EventManager {
74
74
  constructor(table) {
75
75
  this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0,
76
- this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationTime = 0,
77
- this.lastClipboardContent = "", this.cutCellRange = null, this.cutRanges = null,
78
- this.copySourceRange = null, this.table = table, this.handleTextStickBindId = [],
79
- this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env.mode || table.options.disableInteraction || (this.bindOuterEvent(),
76
+ this.cutWaitPaste = !1, this.clipboardCheckTimer = null, this.cutOperationId = 0,
77
+ this.clipboardOperationId = 0, this.pasteOperationId = 0, this.pasteWriteInProgress = !1,
78
+ this.pasteWritePromise = Promise.resolve(), this.clipboardWritePromise = Promise.resolve(),
79
+ this.lastCopiedClipboardData = null, this.internalFormulaHtmlMarkerId = 0, this.fieldKeyIds = new WeakMap,
80
+ this.fieldKeyId = 0, this.activeCutState = null, this.lastClipboardContent = "",
81
+ this.cutCellRange = null, this.cutRanges = null, this.copySourceRange = null, this.table = table,
82
+ this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager),
83
+ "node" === Env.mode || table.options.disableInteraction || (this.bindOuterEvent(),
80
84
  setTimeout((() => {
81
85
  this.bindSelfEvent();
82
86
  }), 0));
@@ -281,7 +285,8 @@ export class EventManager {
281
285
  }
282
286
  release() {
283
287
  var _a;
284
- null === (_a = this.gesture) || void 0 === _a || _a.release(), this.globalEventListeners.forEach((item => {
288
+ this.clipboardOperationId++, this.pasteOperationId++, this.resetCutState(), null === (_a = this.gesture) || void 0 === _a || _a.release(),
289
+ this.globalEventListeners.forEach((item => {
285
290
  "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 && vglobal.removeEventListener(item.name, item.callback);
286
291
  })), this.globalEventListeners = [];
287
292
  }
@@ -294,65 +299,328 @@ export class EventManager {
294
299
  handleCopy(e, isCut = !1) {
295
300
  var _a, _b, _c, _d, _e, _f;
296
301
  return __awaiter(this, void 0, void 0, (function*() {
297
- const table = this.table;
298
- !isCut && (this.cutWaitPaste = !1), this.copySourceRange = null;
299
- const sourceRanges = table.stateManager.select.ranges;
300
- if (sourceRanges && 1 === sourceRanges.length) {
301
- const sourceRange = sourceRanges[0];
302
- this.copySourceRange = {
303
- startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
304
- startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
305
- };
306
- } else if (!(null == sourceRanges ? void 0 : sourceRanges.length)) return void (this.copySourceRange = null);
302
+ const table = this.table, operationId = ++this.clipboardOperationId;
303
+ this.pasteOperationId++, isCut || this.resetCutState();
304
+ const copySnapshot = this.getCopySnapshot(isCut);
305
+ if (this.copySourceRange = null, this.lastCopiedClipboardData = null, !copySnapshot) return this.copySourceRange = null,
306
+ null;
307
307
  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);
308
- if (isValid(data)) {
308
+ if (!isValid(data)) return null;
309
+ {
309
310
  e.preventDefault();
311
+ let copySucceeded = !1, copiedClipboardData = null;
312
+ 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);
313
+ if (null === formulaClipboardData) return null;
314
+ 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;
315
+ if (eventClipboardWriteData) return copiedClipboardData = eventClipboardWriteData,
316
+ this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData),
317
+ copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
318
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !isCut),
319
+ isCut && (null === (_e = table.keyboardOptions) || void 0 === _e ? void 0 : _e.showCopyCellBorder) && window.setTimeout((() => {
320
+ this.isClipboardOperationCurrent(operationId) && (setActiveCellRangeState(table, copySnapshot.ranges),
321
+ table.clearSelected());
322
+ }), 0), copySnapshot;
310
323
  const element = table.getElement();
311
- element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
324
+ if (element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))),
325
+ !this.isClipboardOperationCurrent(operationId))) return null;
312
326
  try {
313
327
  if (navigator.clipboard && navigator.clipboard.writeText) {
314
328
  let hasPermission = !0;
315
329
  if (navigator.permissions && navigator.permissions.query) try {
316
- hasPermission = "granted" === (yield navigator.permissions.query({
330
+ if (hasPermission = "granted" === (yield navigator.permissions.query({
317
331
  name: "clipboard-write"
318
- })).state;
332
+ })).state, !this.isClipboardOperationCurrent(operationId)) return null;
319
333
  } catch (permissionError) {
320
334
  hasPermission = !0;
321
335
  }
322
336
  if (hasPermission) try {
323
- if (window.ClipboardItem) {
324
- let htmlValues = data;
325
- 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));
326
- const dataHTML = setDataToHTML(htmlValues);
327
- yield navigator.clipboard.write([ new ClipboardItem({
328
- "text/html": new Blob([ dataHTML ], {
337
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
338
+ copiedClipboardData = yield this.queueClipboardWrite((() => __awaiter(this, void 0, void 0, (function*() {
339
+ return this.isClipboardOperationCurrent(operationId) ? canWriteRichClipboard && clipboardHTML ? (yield navigator.clipboard.write([ new ClipboardItem({
340
+ "text/html": new Blob([ clipboardHTML ], {
329
341
  type: "text/html"
330
342
  }),
331
- "text/plain": new Blob([ data ], {
343
+ "text/plain": new Blob([ plainClipboardData ], {
332
344
  type: "text/plain"
333
345
  })
334
- }) ]);
335
- } else yield navigator.clipboard.writeText(data);
346
+ }) ]), {
347
+ html: clipboardHTML,
348
+ text: plainClipboardData,
349
+ hasHtml: !0,
350
+ hasText: !0,
351
+ internalFormulaText: internalFormulaText,
352
+ internalFormulaHtmlMarker: internalFormulaHtmlMarker
353
+ }) : (yield navigator.clipboard.writeText(plainClipboardData), {
354
+ html: "",
355
+ text: plainClipboardData,
356
+ hasText: !0,
357
+ internalFormulaText: internalFormulaText
358
+ }) : null;
359
+ })))), copiedClipboardData && (copySucceeded = !0);
336
360
  } catch (clipboardError) {
337
- this.fallbackCopyToClipboard(data, e);
338
- } else this.fallbackCopyToClipboard(data, e);
339
- } else this.fallbackCopyToClipboard(data, e);
340
- table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
341
- cellRange: table.stateManager.select.ranges,
342
- copyData: data,
343
- isCut: isCut
361
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
362
+ if (copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), !this.isClipboardOperationCurrent(operationId)) return null;
363
+ copySucceeded && (copiedClipboardData = {
364
+ html: "",
365
+ text: plainClipboardData,
366
+ hasText: !0,
367
+ internalFormulaText: internalFormulaText
368
+ });
369
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
370
+ html: "",
371
+ text: plainClipboardData,
372
+ hasText: !0,
373
+ internalFormulaText: internalFormulaText
374
+ });
375
+ } else copySucceeded = this.fallbackCopyToClipboard(plainClipboardData), copySucceeded && (copiedClipboardData = {
376
+ html: "",
377
+ text: plainClipboardData,
378
+ hasText: !0,
379
+ internalFormulaText: internalFormulaText
344
380
  });
381
+ if (!copySucceeded) return null;
382
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
383
+ this.lastCopiedClipboardData = copiedClipboardData, isCut && (this.lastClipboardContent = this.getClipboardSignature(copiedClipboardData),
384
+ copySnapshot.clipboardData = copiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
385
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
345
386
  } catch (error) {
346
- this.fallbackCopyToClipboard(data, e);
387
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
388
+ if (!this.fallbackCopyToClipboard(plainClipboardData)) return null;
389
+ if (!this.isClipboardOperationCurrent(operationId)) return null;
390
+ this.lastCopiedClipboardData = {
391
+ html: "",
392
+ text: plainClipboardData,
393
+ hasText: !0,
394
+ internalFormulaText: internalFormulaText
395
+ }, isCut && (this.lastClipboardContent = this.getClipboardSignature(this.lastCopiedClipboardData),
396
+ copySnapshot.clipboardData = this.lastCopiedClipboardData, copySnapshot.clipboardSignature = this.lastClipboardContent),
397
+ this.copySourceRange = copySnapshot.copySourceRange, this.afterCopyData(data, isCut, copySnapshot, !1);
347
398
  }
348
399
  }
349
- (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && (setActiveCellRangeState(table),
350
- table.clearSelected());
400
+ return (null === (_f = table.keyboardOptions) || void 0 === _f ? void 0 : _f.showCopyCellBorder) && (setActiveCellRangeState(table, copySnapshot.ranges),
401
+ table.clearSelected()), copySnapshot;
402
+ }));
403
+ }
404
+ afterCopyData(data, isCut, copySnapshot, updateCopyCellBorder = !0) {
405
+ var _a;
406
+ const table = this.table;
407
+ try {
408
+ table.fireListeners(TABLE_EVENT_TYPE.COPY_DATA, {
409
+ cellRange: this.cloneRanges(copySnapshot.ranges),
410
+ copyData: data,
411
+ isCut: isCut
412
+ });
413
+ } catch (error) {}
414
+ updateCopyCellBorder && (null === (_a = table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && (setActiveCellRangeState(table, copySnapshot.ranges),
415
+ table.clearSelected());
416
+ }
417
+ getCopySnapshot(includeCellInfos) {
418
+ const ranges = this.table.stateManager.select.ranges;
419
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
420
+ const clonedRanges = ranges.map((range => ({
421
+ start: {
422
+ col: range.start.col,
423
+ row: range.start.row
424
+ },
425
+ end: {
426
+ col: range.end.col,
427
+ row: range.end.row
428
+ }
429
+ }))), sourceRange = 1 === ranges.length ? ranges[0] : null, sourceCellMatrix = this.getSourceCellMatrix(clonedRanges), sourceCells = this.getSourceCells(sourceCellMatrix), sourceSize = this.getSourceSize(clonedRanges, sourceCellMatrix);
430
+ return {
431
+ ranges: clonedRanges,
432
+ copySourceRange: sourceRange ? {
433
+ startCol: Math.min(sourceRange.start.col, sourceRange.end.col),
434
+ startRow: Math.min(sourceRange.start.row, sourceRange.end.row)
435
+ } : null,
436
+ cellInfos: includeCellInfos ? this.table.getSelectedCellInfos() : null,
437
+ sourceCells: sourceCells,
438
+ sourceCellMatrix: sourceCellMatrix,
439
+ sourceColCount: sourceSize.colCount,
440
+ sourceRowCount: sourceSize.rowCount,
441
+ clipboardData: null,
442
+ clipboardSignature: ""
443
+ };
444
+ }
445
+ cloneRanges(ranges) {
446
+ return ranges.map((range => ({
447
+ start: {
448
+ col: range.start.col,
449
+ row: range.start.row
450
+ },
451
+ end: {
452
+ col: range.end.col,
453
+ row: range.end.row
454
+ }
455
+ })));
456
+ }
457
+ getSourceCellMatrix(ranges) {
458
+ const table = this.table, createSourceCell = (col, row) => {
459
+ var _a, _b, _c, _d, _e, _f, _g, _h;
460
+ const recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
461
+ return {
462
+ col: col,
463
+ row: row,
464
+ 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,
465
+ 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,
466
+ value: null === (_h = table.getCellOriginValue) || void 0 === _h ? void 0 : _h.call(table, col, row)
467
+ };
468
+ };
469
+ if (1 === ranges.length) {
470
+ 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 = [];
471
+ for (let row = startRow; row <= endRow; row++) {
472
+ const rowCells = [];
473
+ for (let col = startCol; col <= endCol; col++) rowCells.push(createSourceCell(col, row));
474
+ sourceCellMatrix.push(rowCells);
475
+ }
476
+ return sourceCellMatrix;
477
+ }
478
+ 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);
479
+ ranges.forEach((range => {
480
+ minCol = Math.min(minCol, range.start.col, range.end.col), maxCol = Math.max(maxCol, range.start.col, range.end.col),
481
+ minRow = Math.min(minRow, range.start.row, range.end.row), maxRow = Math.max(maxRow, range.start.row, range.end.row);
482
+ }));
483
+ const isExistDataInRow = row => ranges.some((range => {
484
+ const startRow = Math.min(range.start.row, range.end.row), endRow = Math.max(range.start.row, range.end.row);
485
+ return startRow <= row && endRow >= row;
486
+ })), isExistDataInCol = col => ranges.some((range => {
487
+ const startCol = Math.min(range.start.col, range.end.col), endCol = Math.max(range.start.col, range.end.col);
488
+ return startCol <= col && endCol >= col;
489
+ })), getRangeExistDataInCell = (col, row) => ranges.some((range => {
490
+ 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);
491
+ return startCol <= col && endCol >= col && startRow <= row && endRow >= row;
492
+ })), sourceCellMatrix = [];
493
+ for (let row = minRow; row <= maxRow; row++) {
494
+ if (!isExistDataInRow(row)) continue;
495
+ const rowCells = [];
496
+ for (let col = minCol; col <= maxCol; col++) isExistDataInCol(col) && rowCells.push(getRangeExistDataInCell(col, row) ? createSourceCell(col, row) : null);
497
+ sourceCellMatrix.push(rowCells);
498
+ }
499
+ return sourceCellMatrix;
500
+ }
501
+ getSourceCells(sourceCellMatrix) {
502
+ const sourceCells = [];
503
+ for (let row = 0; row < sourceCellMatrix.length; row++) for (let col = 0; col < sourceCellMatrix[row].length; col++) {
504
+ const sourceCell = sourceCellMatrix[row][col];
505
+ sourceCell && sourceCells.push(sourceCell);
506
+ }
507
+ return sourceCells;
508
+ }
509
+ getSourceSize(ranges, sourceCellMatrix) {
510
+ var _a, _b;
511
+ if (sourceCellMatrix.length) return {
512
+ colCount: null !== (_b = null === (_a = sourceCellMatrix[0]) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0,
513
+ rowCount: sourceCellMatrix.length
514
+ };
515
+ if (1 === ranges.length) {
516
+ const range = ranges[0];
517
+ return {
518
+ colCount: Math.abs(range.end.col - range.start.col) + 1,
519
+ rowCount: Math.abs(range.end.row - range.start.row) + 1
520
+ };
521
+ }
522
+ return {
523
+ colCount: 0,
524
+ rowCount: 0
525
+ };
526
+ }
527
+ getClipboardSignature(data) {
528
+ return data ? JSON.stringify({
529
+ html: data.hasHtml ? data.html : null,
530
+ text: data.hasText ? data.text : null
531
+ }) : "";
532
+ }
533
+ isClipboardOperationCurrent(operationId) {
534
+ return operationId === this.clipboardOperationId && !this.table.isReleased;
535
+ }
536
+ isPasteOperationCurrent(operationId) {
537
+ return (void 0 === operationId || operationId === this.pasteOperationId) && !this.table.isReleased;
538
+ }
539
+ queueClipboardWrite(write) {
540
+ return __awaiter(this, void 0, void 0, (function*() {
541
+ const previousWrite = this.clipboardWritePromise;
542
+ let settleCurrentWrite = () => {};
543
+ this.clipboardWritePromise = previousWrite.catch((() => {})).then((() => new Promise((resolve => {
544
+ settleCurrentWrite = resolve;
545
+ })))), yield previousWrite.catch((() => {}));
546
+ try {
547
+ return yield write();
548
+ } finally {
549
+ settleCurrentWrite();
550
+ }
351
551
  }));
352
552
  }
353
- fallbackCopyToClipboard(data, e) {
553
+ isClipboardDataChanged(clipboardData, cutState) {
554
+ if (!clipboardData || clipboardData.readFailed) return null;
555
+ const sourceData = cutState.clipboardData;
556
+ if (!sourceData) return this.getClipboardSignature(clipboardData) !== cutState.clipboardSignature;
557
+ if (sourceData.hasHtml && !clipboardData.hasHtml) return null;
558
+ if (sourceData.hasText && !clipboardData.hasText) return null;
559
+ let hasComparableType = !1;
560
+ return !(!clipboardData.hasHtml || !sourceData.hasHtml || (hasComparableType = !0,
561
+ clipboardData.html === sourceData.html)) || (!(!clipboardData.hasText || !sourceData.hasText || (hasComparableType = !0,
562
+ clipboardData.text === sourceData.text)) || !hasComparableType && null);
563
+ }
564
+ isClipboardDataSameAsLastCopy(clipboardData) {
565
+ const sourceData = this.lastCopiedClipboardData;
566
+ return !(!clipboardData || clipboardData.readFailed || !sourceData) && this.isClipboardDataSameBySignature(clipboardData, sourceData);
567
+ }
568
+ isClipboardDataSameBySignature(clipboardData, sourceData) {
569
+ return !(sourceData.hasHtml !== clipboardData.hasHtml || sourceData.hasText !== clipboardData.hasText || sourceData.hasHtml && sourceData.html !== clipboardData.html || sourceData.hasText && sourceData.text !== clipboardData.text);
570
+ }
571
+ getCopyFormulaPlainData(data, isCut) {
572
+ var _a, _b;
573
+ const table = this.table;
574
+ 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;
575
+ try {
576
+ return this.table.getCopyValue(table.options.keyboardOptions.getCopyCellValue.html);
577
+ } catch (error) {
578
+ return isCut ? null : data;
579
+ }
580
+ }
581
+ getCopyDataHTML(data) {
582
+ var _a, _b, _c;
583
+ const table = this.table;
584
+ let htmlValues = data;
585
+ try {
586
+ 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)),
587
+ setDataToHTML(htmlValues);
588
+ } catch (error) {
589
+ try {
590
+ return setDataToHTML(data);
591
+ } catch (fallbackError) {
592
+ return null;
593
+ }
594
+ }
595
+ }
596
+ createInternalFormulaHtmlMarker() {
597
+ return `vtable-formula-${Date.now()}-${++this.internalFormulaHtmlMarkerId}`;
598
+ }
599
+ attachInternalFormulaHtmlMarker(html, marker) {
600
+ return `${html}\x3c!--${marker}--\x3e`;
601
+ }
602
+ setCopyDataToEventClipboard(data, dataHTML, e, internalFormulaText, internalFormulaHtmlMarker) {
603
+ const clipboardData = e.clipboardData;
604
+ if (!clipboardData) return null;
605
+ try {
606
+ clipboardData.setData("text/plain", data);
607
+ const copiedClipboardData = {
608
+ html: "",
609
+ text: data,
610
+ hasText: !0,
611
+ internalFormulaText: internalFormulaText
612
+ };
613
+ if (dataHTML) try {
614
+ clipboardData.setData("text/html", dataHTML), copiedClipboardData.html = dataHTML,
615
+ copiedClipboardData.hasHtml = !0, copiedClipboardData.internalFormulaHtmlMarker = internalFormulaHtmlMarker;
616
+ } catch (error) {}
617
+ return copiedClipboardData;
618
+ } catch (error) {
619
+ return null;
620
+ }
621
+ }
622
+ fallbackCopyToClipboard(data) {
354
623
  try {
355
- if (e.clipboardData) return void e.clipboardData.setData("text/plain", data);
356
624
  document.activeElement && document.activeElement !== document.body && document.activeElement.blur();
357
625
  const textArea = document.createElement("textarea");
358
626
  textArea.value = data, textArea.style.position = "fixed", textArea.style.left = "-999999px",
@@ -360,197 +628,430 @@ export class EventManager {
360
628
  textArea.setAttribute("aria-hidden", "true"), document.body.appendChild(textArea),
361
629
  textArea.focus(), textArea.select(), textArea.setSelectionRange(0, data.length);
362
630
  try {
363
- document.execCommand("copy");
631
+ const successful = document.execCommand("copy");
632
+ return successful;
364
633
  } catch (execError) {} finally {
365
634
  document.body.removeChild(textArea);
366
635
  }
367
636
  } catch (error) {}
637
+ return !1;
368
638
  }
369
639
  handleCut(e) {
370
- var _a;
371
640
  return __awaiter(this, void 0, void 0, (function*() {
372
- this.handleCopy(e, !0), this.cutWaitPaste = !0, this.cutCellRange = this.table.getSelectedCellInfos(),
373
- this.cutRanges = null === (_a = this.table.stateManager.select.ranges) || void 0 === _a ? void 0 : _a.map((r => ({
374
- start: {
375
- col: r.start.col,
376
- row: r.start.row
377
- },
378
- end: {
379
- col: r.end.col,
380
- row: r.end.row
381
- }
382
- }))), this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = window.setTimeout((() => {
383
- this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null, this.cutRanges = null,
384
- this.clipboardCheckTimer = null);
385
- }), 3e4), this.saveClipboardContent();
641
+ const copySnapshot = yield this.handleCopy(e, !0);
642
+ if (!copySnapshot) return;
643
+ const cutState = {
644
+ id: ++this.cutOperationId,
645
+ ranges: this.cloneRanges(copySnapshot.ranges),
646
+ cellInfos: copySnapshot.cellInfos,
647
+ sourceCells: copySnapshot.sourceCells,
648
+ sourceCellMatrix: copySnapshot.sourceCellMatrix,
649
+ sourceColCount: copySnapshot.sourceColCount,
650
+ sourceRowCount: copySnapshot.sourceRowCount,
651
+ clipboardData: copySnapshot.clipboardData,
652
+ clipboardSignature: copySnapshot.clipboardSignature,
653
+ copySourceRange: copySnapshot.copySourceRange,
654
+ isSingleRange: 1 === copySnapshot.ranges.length
655
+ };
656
+ this.cutWaitPaste = !0, this.activeCutState = cutState, this.cutCellRange = cutState.cellInfos,
657
+ this.cutRanges = cutState.ranges, this.clipboardCheckTimer && clearTimeout(this.clipboardCheckTimer),
658
+ this.clipboardCheckTimer = window.setTimeout((() => {
659
+ this.cutWaitPaste && this.resetCutState();
660
+ }), 3e4), this.lastClipboardContent = cutState.clipboardSignature;
386
661
  }));
387
662
  }
388
663
  handlePaste(e) {
389
- this.cutWaitPaste ? this.checkClipboardChanged().then((changed => {
390
- this.executePaste(e), changed || this.clearCutArea(this.table), this.cutWaitPaste && (this.cutWaitPaste = !1,
391
- this.cutCellRange = null, this.cutRanges = null, this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer),
392
- this.clipboardCheckTimer = null));
393
- })).catch((() => {
394
- this.executePaste(e), this.cutWaitPaste && (this.cutWaitPaste = !1, this.cutCellRange = null,
395
- this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null));
396
- })) : this.executePaste(e);
397
- }
398
- executePaste(e) {
399
- var _a, _b, _c;
664
+ const pasteOperationId = ++this.pasteOperationId, pasteRange = this.getPasteRange();
665
+ if (!pasteRange) return;
666
+ const eventClipboardData = this.getEventClipboardData(e), pasteCopySourceRange = this.copySourceRange;
667
+ if (!this.cutWaitPaste) return void this.readClipboardDataForPaste(eventClipboardData).then((clipboardData => {
668
+ if (!this.isPasteOperationCurrent(pasteOperationId)) return;
669
+ const copySourceRange = this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null;
670
+ this.executePaste(clipboardData, {
671
+ pasteRange: pasteRange,
672
+ copySourceRange: copySourceRange,
673
+ pasteOperationId: pasteOperationId
674
+ });
675
+ })).catch((error => {}));
676
+ const cutState = this.activeCutState;
677
+ cutState ? this.readClipboardDataForPaste(eventClipboardData).then((clipboardData => __awaiter(this, void 0, void 0, (function*() {
678
+ var _a, _b, _c, _d, _e;
679
+ if (!this.isPasteOperationCurrent(pasteOperationId) || (null === (_a = this.activeCutState) || void 0 === _a ? void 0 : _a.id) !== cutState.id) return;
680
+ const changed = this.isClipboardDataChanged(clipboardData, cutState);
681
+ if (null === changed) return void (yield this.executePaste(clipboardData, {
682
+ pasteRange: pasteRange,
683
+ copySourceRange: this.isClipboardDataSameAsLastCopy(clipboardData) ? pasteCopySourceRange : null,
684
+ pasteOperationId: pasteOperationId
685
+ }));
686
+ const pasteResult = yield this.executePaste(clipboardData, {
687
+ pasteRange: pasteRange,
688
+ copySourceRange: changed ? null : cutState.copySourceRange,
689
+ cutState: changed ? null : cutState,
690
+ pasteOperationId: pasteOperationId
691
+ });
692
+ 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) {
693
+ if (!(yield this.clearCutArea(pasteResult.migratedSourceCells, pasteResult.changedCells))) return void this.resetCutState();
694
+ (null === (_d = this.activeCutState) || void 0 === _d ? void 0 : _d.id) === cutState.id && this.resetCutState();
695
+ }
696
+ })))).catch((() => __awaiter(this, void 0, void 0, (function*() {
697
+ this.isPasteOperationCurrent(pasteOperationId) && (yield this.executePaste(eventClipboardData, {
698
+ pasteRange: pasteRange,
699
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
700
+ pasteOperationId: pasteOperationId
701
+ }));
702
+ })))) : this.executePaste(eventClipboardData, {
703
+ pasteRange: pasteRange,
704
+ copySourceRange: this.isClipboardDataSameAsLastCopy(eventClipboardData) ? pasteCopySourceRange : null,
705
+ pasteOperationId: pasteOperationId
706
+ });
707
+ }
708
+ executePaste(clipboardData, pasteContext) {
709
+ var _a, _b, _c, _d;
400
710
  return __awaiter(this, void 0, void 0, (function*() {
401
- const table = this.table;
402
- if (!(null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) {
403
- if (table.changeCellValues && (null === (_b = table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 0) try {
404
- if (navigator.clipboard && navigator.clipboard.read) try {
405
- const clipboardItems = yield navigator.clipboard.read();
406
- let handled = !1;
407
- for (const item of clipboardItems) {
408
- if (item.types.includes("text/html")) {
409
- yield this.pasteHtmlToTable(item), handled = !0;
410
- break;
411
- }
412
- if (item.types.includes("text/plain")) {
413
- yield this.pasteTextToTable(item), handled = !0;
414
- break;
415
- }
416
- }
417
- handled || (yield this.fallbackPasteFromClipboard(e));
418
- } catch (clipboardError) {
419
- yield this.fallbackPasteFromClipboard(e);
420
- } else yield this.fallbackPasteFromClipboard(e);
711
+ const table = this.table, emptyResult = this.getEmptyPasteResult(), pasteClipboardData = this.getPasteClipboardData(clipboardData, pasteContext);
712
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_a = table.editorManager) || void 0 === _a ? void 0 : _a.editingEditor)) return emptyResult;
713
+ if (this.pasteWriteInProgress && (yield this.pasteWritePromise.catch((() => {})),
714
+ !this.isPasteOperationCurrent(pasteContext.pasteOperationId) || (null === (_b = table.editorManager) || void 0 === _b ? void 0 : _b.editingEditor))) return emptyResult;
715
+ let pasteResult = emptyResult, settlePasteWrite = () => {};
716
+ this.pasteWritePromise = new Promise((resolve => {
717
+ settlePasteWrite = resolve;
718
+ })), this.pasteWriteInProgress = !0;
719
+ try {
720
+ if (table.changeCellValues) try {
721
+ if (null == pasteClipboardData ? void 0 : pasteClipboardData.html) try {
722
+ const htmlResult = yield this.processPastedHTML(pasteClipboardData.html, pasteContext);
723
+ if (htmlResult.pasted) return pasteResult = htmlResult, pasteResult;
724
+ } catch (error) {
725
+ if (/<table\b/i.test(pasteClipboardData.html)) return emptyResult;
726
+ }
727
+ 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),
728
+ pasteResult;
421
729
  } catch (error) {
422
- yield this.fallbackPasteFromClipboard(e);
730
+ pasteContext.cutState && this.resetCutState();
423
731
  }
424
- (null === (_c = table.keyboardOptions) || void 0 === _c ? void 0 : _c.showCopyCellBorder) && clearActiveCellRangeState(table);
732
+ return pasteResult;
733
+ } finally {
734
+ this.pasteWriteInProgress = !1, settlePasteWrite(), !pasteContext.cutState && (null === (_d = table.keyboardOptions) || void 0 === _d ? void 0 : _d.showCopyCellBorder) && clearActiveCellRangeState(table);
425
735
  }
426
736
  }));
427
737
  }
428
- fallbackPasteFromClipboard(e) {
738
+ getPasteClipboardData(clipboardData, pasteContext) {
739
+ var _a, _b;
740
+ if (!clipboardData || !pasteContext.copySourceRange) return clipboardData;
741
+ const sourceData = null !== (_b = null === (_a = pasteContext.cutState) || void 0 === _a ? void 0 : _a.clipboardData) && void 0 !== _b ? _b : this.lastCopiedClipboardData;
742
+ 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), {
743
+ internalFormulaText: sourceData.internalFormulaText
744
+ }) : clipboardData;
745
+ }
746
+ getPasteRange() {
747
+ const ranges = this.table.stateManager.select.ranges;
748
+ if (!(null == ranges ? void 0 : ranges.length)) return null;
749
+ const range = ranges[ranges.length - 1];
750
+ return {
751
+ col: Math.min(range.start.col, range.end.col),
752
+ row: Math.min(range.start.row, range.end.row),
753
+ maxCol: Math.max(range.start.col, range.end.col),
754
+ maxRow: Math.max(range.start.row, range.end.row)
755
+ };
756
+ }
757
+ getEventClipboardData(e) {
758
+ var _a;
759
+ const clipboardData = e.clipboardData || window.clipboardData;
760
+ if (!clipboardData) return null;
761
+ try {
762
+ 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;
763
+ return {
764
+ html: html,
765
+ text: text,
766
+ hasHtml: hasHtml,
767
+ hasText: types.includes("text/plain") || types.includes("text") || types.includes("Text") || !!text
768
+ };
769
+ } catch (error) {
770
+ return {
771
+ html: "",
772
+ text: "",
773
+ readFailed: !0
774
+ };
775
+ }
776
+ }
777
+ readClipboardDataForPaste(eventClipboardData) {
778
+ var _a, _b;
429
779
  return __awaiter(this, void 0, void 0, (function*() {
430
- 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);
431
- try {
432
- const element = table.getElement();
433
- element && element !== document.activeElement && (element.focus(), yield new Promise((resolve => setTimeout(resolve, 10))));
434
- const clipboardData = e.clipboardData || window.clipboardData || window.Clipboard;
435
- if (clipboardData) {
436
- const pastedData = clipboardData.getData("text") || clipboardData.getData("Text");
437
- if (pastedData) return void (yield this.processPastedText(pastedData, col, row));
780
+ if ((null == eventClipboardData ? void 0 : eventClipboardData.readFailed) || (null == eventClipboardData ? void 0 : eventClipboardData.hasHtml) || (null == eventClipboardData ? void 0 : eventClipboardData.hasText)) return eventClipboardData;
781
+ if (null === (_a = navigator.clipboard) || void 0 === _a ? void 0 : _a.read) try {
782
+ const clipboardItems = yield navigator.clipboard.read(), clipboardData = {
783
+ html: "",
784
+ text: ""
785
+ };
786
+ for (const item of clipboardItems) {
787
+ if (!clipboardData.html && item.types.includes("text/html")) try {
788
+ clipboardData.html = yield (yield item.getType("text/html")).text(), clipboardData.hasHtml = !0;
789
+ } catch (error) {}
790
+ if (!clipboardData.text && item.types.includes("text/plain")) try {
791
+ clipboardData.text = yield (yield item.getType("text/plain")).text(), clipboardData.hasText = !0;
792
+ } catch (error) {}
438
793
  }
794
+ if (clipboardData.hasHtml || clipboardData.hasText) return clipboardData;
439
795
  } catch (error) {}
796
+ if (null === (_b = navigator.clipboard) || void 0 === _b ? void 0 : _b.readText) try {
797
+ return {
798
+ html: "",
799
+ text: yield navigator.clipboard.readText(),
800
+ hasText: !0
801
+ };
802
+ } catch (error) {}
803
+ return null != eventClipboardData ? eventClipboardData : {
804
+ html: "",
805
+ text: "",
806
+ readFailed: !0
807
+ };
440
808
  }));
441
809
  }
442
- processPastedText(pastedData, col, row) {
810
+ decodeHTMLCellValue(cellHTML) {
443
811
  var _a;
444
- return __awaiter(this, void 0, void 0, (function*() {
445
- const table = this.table, rows = pastedData.split("\n"), values = [];
446
- let processedValues;
447
- rows.forEach((function(rowCells) {
448
- const cells = rowCells.split("\t"), rowValues = [];
449
- values.push(rowValues), cells.forEach((function(cell, cellIndex) {
450
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
451
- }));
452
- })), (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));
453
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
454
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
455
- col: col,
456
- row: row,
457
- pasteData: processedValues || values,
458
- changedCellResults: changedCellResults
459
- });
460
- }));
812
+ const template = document.createElement("template");
813
+ return template.innerHTML = cellHTML.replace(/<br\b[^>]*>(?:\r\n|\r|\n)?/gim, "\n").replace(/&nbsp;/gi, " "),
814
+ null !== (_a = template.content.textContent) && void 0 !== _a ? _a : "";
461
815
  }
462
- clearCutArea(table) {
463
- try {
464
- const ranges = this.cutRanges;
465
- if (!ranges || 0 === ranges.length) return;
466
- table.changeCellValuesByRanges(ranges, "");
467
- } catch (error) {}
468
- }
469
- checkClipboardChanged() {
816
+ processPastedHTML(pastedData, pasteContext) {
817
+ var _a, _b, _c;
470
818
  return __awaiter(this, void 0, void 0, (function*() {
471
- if (!navigator.clipboard || !navigator.clipboard.readText) return !1;
472
- try {
473
- return (yield navigator.clipboard.readText()) !== this.lastClipboardContent;
474
- } catch (err) {
475
- return !1;
819
+ const cellRegex = /<t[dh][^>]*>([\s\S]*?)<\/t[dh]>/gi, table = this.table, pasteRange = pasteContext.pasteRange, {col: col, row: row, maxCol: maxCol, maxRow: maxRow} = pasteRange;
820
+ let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
821
+ if (!pastedData || !/<table\b/i.test(pastedData)) return this.getEmptyPasteResult();
822
+ const matches = Array.from(pastedData.matchAll(/<tr[^>]*>([\s\S]*?)<\/tr>/gi));
823
+ for (const match of matches) {
824
+ const rowContent = match[1], cellMatches = Array.from(rowContent.matchAll(cellRegex));
825
+ if (!cellMatches.length) continue;
826
+ const rowValues = cellMatches.map((cellMatch => this.decodeHTMLCellValue(cellMatch[1])));
827
+ values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
476
828
  }
829
+ if (pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0,
830
+ !pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
831
+ let processedValues;
832
+ values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
833
+ (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));
834
+ const valuesToPaste = processedValues || values, targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
835
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
836
+ if (pasteContext.cutState) {
837
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
838
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
839
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
840
+ }
841
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, (() => !this.isPasteOperationCurrent(pasteContext.pasteOperationId)));
842
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
843
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste), changedCells = this.getChangedCells(targetCells, changedCellResults), migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
844
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults),
845
+ {
846
+ pasted: !0,
847
+ changedCellResults: changedCellResults,
848
+ changedCells: changedCells,
849
+ migratedSourceCells: migratedSourceCells
850
+ }) : this.getEmptyPasteResult(changedCellResults);
477
851
  }));
478
852
  }
479
- saveClipboardContent() {
480
- navigator.clipboard && navigator.clipboard.readText && setTimeout((() => {
481
- navigator.clipboard.readText().then((text => {
482
- this.lastClipboardContent = text;
483
- })).catch((err => {}));
484
- }), 50);
485
- }
486
- pasteHtmlToTable(item) {
487
- 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);
488
- let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
489
- item.getType("text/html").then((blob => {
490
- blob.text().then((pastedData => __awaiter(this, void 0, void 0, (function*() {
491
- var _a, _b, _c;
492
- if (pastedData && /(<table)|(<TABLE)/g.test(pastedData)) {
493
- const matches = Array.from(pastedData.matchAll(regex));
494
- for (const match of matches) {
495
- 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, " ")));
496
- values.push(rowValues), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
497
- }
498
- let processedValues;
499
- pasteValuesRowCount = null !== (_b = values.length) && void 0 !== _b ? _b : 0, values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
500
- (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));
501
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
502
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
503
- col: col,
504
- row: row,
505
- pasteData: processedValues || values,
506
- changedCellResults: changedCellResults
507
- });
508
- } else navigator.clipboard.read().then((clipboardItems => {
509
- for (const item of clipboardItems) item.types.includes("text/plain") && item.getType("text/plain").then((blob => {
510
- blob.text().then((data => this._pasteValue(data)));
511
- }));
512
- }));
513
- }))));
514
- }));
515
- }
516
- _pasteValue(pastedData) {
517
- var _a, _b;
853
+ processPastedText(pastedData, pasteContext) {
854
+ var _a;
518
855
  return __awaiter(this, void 0, void 0, (function*() {
519
- 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);
520
- let pasteValuesColCount = 0, pasteValuesRowCount = 0, values = [];
856
+ const table = this.table, pasteRange = pasteContext.pasteRange, {col: col, row: row, maxCol: maxCol, maxRow: maxRow} = pasteRange;
857
+ let values = this.parsePlainTextPastedData(pastedData);
858
+ const pasteValuesRowCount = values.length, pasteValuesColCount = Math.max(...values.map((rowValues => rowValues.length)));
859
+ if (!pasteValuesRowCount || !pasteValuesColCount) return this.getEmptyPasteResult();
521
860
  let processedValues;
522
- pastedData.split("\n").forEach((function(rowCells, rowIndex) {
523
- var _a;
524
- const cells = rowCells.split("\t"), rowValues = [];
525
- values.push(rowValues), cells.forEach((function(cell, cellIndex) {
526
- cellIndex === cells.length - 1 && (cell = cell.trim()), rowValues.push(cell);
527
- })), pasteValuesColCount = Math.max(pasteValuesColCount, null !== (_a = null == rowValues ? void 0 : rowValues.length) && void 0 !== _a ? _a : 0);
528
- })), pasteValuesRowCount = null !== (_a = values.length) && void 0 !== _a ? _a : 0,
529
861
  values = this.handlePasteValues(values, pasteValuesRowCount, pasteValuesColCount, maxRow - row + 1, maxCol - col + 1),
530
- (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));
531
- const changedCellResults = yield table.changeCellValues(col, row, processedValues || values, !0);
532
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
862
+ (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));
863
+ const valuesToPaste = processedValues || values, targetCells = this.getPasteTargetCells(pasteRange, valuesToPaste);
864
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
865
+ if (pasteContext.cutState) {
866
+ const validatedCellResults = yield this.validatePasteTargetCells(pasteRange, valuesToPaste);
867
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
868
+ if (!this.isFullPasteAllowed(valuesToPaste, validatedCellResults)) return this.getEmptyPasteResult(validatedCellResults);
869
+ }
870
+ const rawChangedCellResults = yield table.changeCellValues(col, row, valuesToPaste, !pasteContext.cutState, !0, void 0, (() => !this.isPasteOperationCurrent(pasteContext.pasteOperationId)));
871
+ if (!this.isPasteOperationCurrent(pasteContext.pasteOperationId)) return this.getEmptyPasteResult();
872
+ const changedCellResults = this.normalizeChangedCellResults(rawChangedCellResults, pasteRange, valuesToPaste), changedCells = this.getChangedCells(targetCells, changedCellResults), migratedSourceCells = this.getMigratedSourceCells(pasteContext.cutState, changedCellResults);
873
+ return changedCells.length ? (this.firePastedDataEvent(col, row, valuesToPaste, changedCellResults),
874
+ {
875
+ pasted: !0,
876
+ changedCellResults: changedCellResults,
877
+ changedCells: changedCells,
878
+ migratedSourceCells: migratedSourceCells
879
+ }) : this.getEmptyPasteResult(changedCellResults);
880
+ }));
881
+ }
882
+ firePastedDataEvent(col, row, pasteData, changedCellResults) {
883
+ const table = this.table;
884
+ if (table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA)) try {
885
+ table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
533
886
  col: col,
534
887
  row: row,
535
- pasteData: processedValues || values,
888
+ pasteData: pasteData,
536
889
  changedCellResults: changedCellResults
537
890
  });
891
+ } catch (error) {}
892
+ }
893
+ getEmptyPasteResult(changedCellResults = []) {
894
+ return {
895
+ pasted: !1,
896
+ changedCellResults: changedCellResults,
897
+ changedCells: [],
898
+ migratedSourceCells: []
899
+ };
900
+ }
901
+ getPasteTargetCells(pasteRange, values) {
902
+ const targetCells = [];
903
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
904
+ targetCells[rowIndex] = [];
905
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) targetCells[rowIndex][colIndex] = this.getCellIdentity(pasteRange.col + colIndex, pasteRange.row + rowIndex);
906
+ }
907
+ return targetCells;
908
+ }
909
+ getChangedCells(targetCells, changedCellResults) {
910
+ var _a, _b, _c;
911
+ const changedCells = [];
912
+ 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]);
913
+ return changedCells;
914
+ }
915
+ normalizeChangedCellResults(changedCellResults, pasteRange, values) {
916
+ if (Array.isArray(changedCellResults)) return changedCellResults;
917
+ const table = this.table;
918
+ return values.map(((rowValues, rowIndex) => rowValues.map(((_value, colIndex) => {
919
+ const targetCol = pasteRange.col + colIndex, targetRow = pasteRange.row + rowIndex;
920
+ return targetCol < table.colCount && targetRow < table.rowCount && (!table.isHasEditorDefine || table.isHasEditorDefine(targetCol, targetRow));
921
+ }))));
922
+ }
923
+ validatePasteTargetCells(pasteRange, values) {
924
+ var _a, _b, _c, _d;
925
+ return __awaiter(this, void 0, void 0, (function*() {
926
+ const table = this.table, changedCellResults = [];
927
+ for (let rowIndex = 0; rowIndex < values.length; rowIndex++) {
928
+ changedCellResults[rowIndex] = [];
929
+ for (let colIndex = 0; colIndex < values[rowIndex].length; colIndex++) {
930
+ const targetCol = pasteRange.col + colIndex, targetRow = pasteRange.row + rowIndex, tableAny = table;
931
+ let canChange = targetCol < tableAny.colCount && targetRow < tableAny.rowCount && (!tableAny.isHasEditorDefine || tableAny.isHasEditorDefine(targetCol, targetRow));
932
+ if (canChange) {
933
+ 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, {
934
+ col: targetCol,
935
+ row: targetRow
936
+ }, table)) || void 0 === _d || _d, resolvedValidateResult = validateResult && "function" == typeof validateResult.then ? yield validateResult : validateResult;
937
+ canChange = !0 === resolvedValidateResult || "validate-exit" === resolvedValidateResult || "validate-not-exit" === resolvedValidateResult;
938
+ }
939
+ changedCellResults[rowIndex][colIndex] = canChange;
940
+ }
941
+ }
942
+ return changedCellResults;
538
943
  }));
539
944
  }
540
- pasteTextToTable(item) {
945
+ isFullPasteAllowed(values, changedCellResults) {
946
+ return values.every(((rowValues, rowIndex) => rowValues.every(((_value, colIndex) => {
947
+ var _a;
948
+ return !0 === (null === (_a = changedCellResults[rowIndex]) || void 0 === _a ? void 0 : _a[colIndex]);
949
+ }))));
950
+ }
951
+ getMigratedSourceCells(cutState, changedCellResults) {
952
+ var _a, _b, _c, _d, _e;
953
+ if (!(null == cutState ? void 0 : cutState.sourceCells.length) || !cutState.sourceColCount || !cutState.sourceRowCount) return [];
954
+ const migratedSourceCells = [], migratedKeys = new Set;
955
+ if (!cutState.isSingleRange) {
956
+ 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++) {
957
+ if (!changedCellResults[rowIndex][colIndex]) continue;
958
+ const sourceRow = rowIndex % cutState.sourceRowCount, sourceCol = colIndex % cutState.sourceColCount, sourceCell = null === (_c = cutState.sourceCellMatrix[sourceRow]) || void 0 === _c ? void 0 : _c[sourceCol];
959
+ if (!sourceCell) continue;
960
+ const sourceKey = this.getCellKey(sourceCell);
961
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
962
+ }
963
+ return migratedSourceCells.length === cutState.sourceCells.length ? migratedSourceCells : [];
964
+ }
965
+ 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++) {
966
+ if (!changedCellResults[rowIndex][colIndex]) continue;
967
+ const sourceRow = rowIndex % cutState.sourceRowCount, sourceCol = colIndex % cutState.sourceColCount, sourceIndex = sourceRow * cutState.sourceColCount + sourceCol, sourceCell = cutState.sourceCells[sourceIndex];
968
+ if (!sourceCell) continue;
969
+ const sourceKey = this.getCellKey(sourceCell);
970
+ migratedKeys.has(sourceKey) || (migratedKeys.add(sourceKey), migratedSourceCells.push(sourceCell));
971
+ }
972
+ return migratedSourceCells;
973
+ }
974
+ getCellIdentity(col, row) {
975
+ var _a, _b, _c, _d, _e, _f, _g;
976
+ const table = this.table, recordShowIndex = null === (_a = table.getRecordShowIndexByCell) || void 0 === _a ? void 0 : _a.call(table, col, row);
977
+ return {
978
+ col: col,
979
+ row: row,
980
+ 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,
981
+ 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
982
+ };
983
+ }
984
+ clearCutArea(migratedSourceCells, changedTargetCells) {
985
+ var _a, _b;
541
986
  return __awaiter(this, void 0, void 0, (function*() {
542
- 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);
543
987
  try {
544
- 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);
545
- table.hasListeners(TABLE_EVENT_TYPE.PASTED_DATA) && table.fireListeners(TABLE_EVENT_TYPE.PASTED_DATA, {
546
- col: col,
547
- row: row,
548
- pasteData: processedValues,
549
- changedCellResults: changedCellResults
988
+ const table = this.table, changedTargetKeys = new Set;
989
+ changedTargetCells.forEach((cell => {
990
+ changedTargetKeys.add(this.getCellKey(cell)), changedTargetKeys.add(this.getCoordKey(cell));
991
+ }));
992
+ const clearedKeys = new Set, sourceChanges = [], coordChanges = [];
993
+ for (let i = 0; i < migratedSourceCells.length; i++) {
994
+ const sourceCell = migratedSourceCells[i], sourceKey = this.getCellKey(sourceCell);
995
+ if (clearedKeys.has(sourceKey) || changedTargetKeys.has(sourceKey) || changedTargetKeys.has(this.getCoordKey(sourceCell))) continue;
996
+ const currentAddress = this.getCurrentCellAddress(sourceCell);
997
+ currentAddress && (this.isSourceCellUnchanged(sourceCell, currentAddress) && (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.changeCellValuesByRecords ? sourceChanges.push({
998
+ recordIndex: sourceCell.recordIndex,
999
+ field: sourceCell.field,
1000
+ value: ""
1001
+ }) : coordChanges.push(currentAddress), clearedKeys.add(sourceKey)));
1002
+ }
1003
+ sourceChanges.length && table.changeCellValuesByRecords(sourceChanges, {
1004
+ triggerEvent: !0,
1005
+ autoRefresh: !1
550
1006
  });
551
- } catch (error) {}
1007
+ for (let i = 0; i < coordChanges.length; i++) yield table.changeCellValues(coordChanges[i].col, coordChanges[i].row, [ [ "" ] ], !1);
1008
+ return sourceChanges.length && (null === (_b = (_a = table).refreshAfterSourceChange) || void 0 === _b || _b.call(_a)),
1009
+ !0;
1010
+ } catch (error) {
1011
+ return !1;
1012
+ }
552
1013
  }));
553
1014
  }
1015
+ isSourceCellUnchanged(sourceCell, currentAddress) {
1016
+ var _a;
1017
+ const table = this.table;
1018
+ return Object.is(null === (_a = table.getCellOriginValue) || void 0 === _a ? void 0 : _a.call(table, currentAddress.col, currentAddress.row), sourceCell.value);
1019
+ }
1020
+ getCurrentCellAddress(sourceCell) {
1021
+ const table = this.table;
1022
+ if (void 0 !== sourceCell.recordIndex && void 0 !== sourceCell.field && table.getCellAddrByFieldRecord) {
1023
+ const address = table.getCellAddrByFieldRecord(sourceCell.field, sourceCell.recordIndex);
1024
+ return address && address.col >= 0 && address.row >= 0 ? address : null;
1025
+ }
1026
+ return {
1027
+ col: sourceCell.col,
1028
+ row: sourceCell.row
1029
+ };
1030
+ }
1031
+ getCellKey(cell) {
1032
+ return void 0 !== cell.recordIndex && void 0 !== cell.field ? `record:${this.getStableKeyPart(cell.recordIndex)}:${this.getStableKeyPart(cell.field)}` : this.getCoordKey(cell);
1033
+ }
1034
+ getCoordKey(cell) {
1035
+ return `coord:${cell.col}:${cell.row}`;
1036
+ }
1037
+ getStableKeyPart(value) {
1038
+ if (null === value) return "null";
1039
+ const valueType = typeof value;
1040
+ if ("string" === valueType || "number" === valueType || "boolean" === valueType) return `${valueType}:${JSON.stringify(value)}`;
1041
+ if (Array.isArray(value)) return `array:[${value.map((item => this.getStableKeyPart(item))).join(",")}]`;
1042
+ if ("object" === valueType || "function" === valueType) {
1043
+ let id = this.fieldKeyIds.get(value);
1044
+ return void 0 === id && (id = ++this.fieldKeyId, this.fieldKeyIds.set(value, id)),
1045
+ `${valueType}:#${id}`;
1046
+ }
1047
+ return `${valueType}:${String(value)}`;
1048
+ }
1049
+ resetCutState() {
1050
+ var _a;
1051
+ this.cutWaitPaste = !1, this.activeCutState = null, this.cutCellRange = null, this.cutRanges = null,
1052
+ (null === (_a = this.table.keyboardOptions) || void 0 === _a ? void 0 : _a.showCopyCellBorder) && clearActiveCellRangeState(this.table),
1053
+ this.clipboardCheckTimer && (clearTimeout(this.clipboardCheckTimer), this.clipboardCheckTimer = null);
1054
+ }
554
1055
  parsePastedData(pastedData) {
555
1056
  const rows = pastedData.replace(/\r(?!\n)/g, "\r\n").split("\r\n"), values = [];
556
1057
  return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.forEach((rowCells => {
@@ -558,6 +1059,10 @@ export class EventManager {
558
1059
  values.push(rowValues);
559
1060
  })), values;
560
1061
  }
1062
+ parsePlainTextPastedData(pastedData) {
1063
+ const rows = pastedData.replace(/\r\n|\r/g, "\n").split("\n");
1064
+ return rows.length > 1 && "" === rows[rows.length - 1] && rows.pop(), rows.map((rowCells => rowCells.split("\t")));
1065
+ }
561
1066
  processCellValue(cell) {
562
1067
  cell.includes("\n") && (cell = cell.replace(/^"(.*)"$/, "$1").replace(/["]*/g, (match => new Array(Math.floor(match.length / 2)).fill('"').join(""))));
563
1068
  const numValue = Number(cell);