@fileverse-dev/fortune-core 1.0.5 → 1.0.7

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 (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +6 -5
  264. package/dist/index.esm.js +0 -80253
  265. package/dist/index.js +0 -80599
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -0,0 +1,1358 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var __assign = this && this.__assign || function () {
3
+ __assign = Object.assign || function (t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import _ from "lodash";
13
+ import { getFlowdata } from "../context";
14
+ import { locale } from "../locale";
15
+ import { delFunctionGroup, execfunction, execFunctionGroup, functionCopy } from "../modules/formula";
16
+ import { getdatabyselection, getQKBorder } from "../modules/cell";
17
+ import { genarate, update } from "../modules/format";
18
+ import { normalizeSelection, selectionCache } from "../modules/selection";
19
+ import { getSheetIndex, isAllowEdit } from "../utils";
20
+ import { hasPartMC, isRealNum } from "../modules/validation";
21
+ import { getBorderInfoCompute } from "../modules/border";
22
+ import { expandRowsAndColumns, storeSheetParamALL } from "../modules/sheet";
23
+ import { jfrefreshgrid } from "../modules/refresh";
24
+ import { setRowHeight } from "../api";
25
+ import { CFSplitRange, sanitizeDuneUrl } from "../modules";
26
+ import clipboard from "../modules/clipboard";
27
+ function postPasteCut(ctx, source, target, RowlChange) {
28
+ var execF_rc = {};
29
+ ctx.formulaCache.execFunctionExist = [];
30
+ for (var r = source.range.row[0]; r <= source.range.row[1]; r += 1) {
31
+ for (var c = source.range.column[0]; c <= source.range.column[1]; c += 1) {
32
+ if ("".concat(r, "_").concat(c, "_").concat(source.sheetId) in execF_rc) {
33
+ continue;
34
+ }
35
+ execF_rc["".concat(r, "_").concat(c, "_").concat(source.sheetId)] = 0;
36
+ ctx.formulaCache.execFunctionExist.push({
37
+ r: r,
38
+ c: c,
39
+ i: source.sheetId
40
+ });
41
+ }
42
+ }
43
+ for (var r = target.range.row[0]; r <= target.range.row[1]; r += 1) {
44
+ for (var c = target.range.column[0]; c <= target.range.column[1]; c += 1) {
45
+ if ("".concat(r, "_").concat(c, "_").concat(target.sheetId) in execF_rc) {
46
+ continue;
47
+ }
48
+ execF_rc["".concat(r, "_").concat(c, "_").concat(target.sheetId)] = 0;
49
+ ctx.formulaCache.execFunctionExist.push({
50
+ r: r,
51
+ c: c,
52
+ i: target.sheetId
53
+ });
54
+ }
55
+ }
56
+ var rowHeight;
57
+ if (ctx.currentSheetId === source.sheetId) {
58
+ ctx.config = source.curConfig;
59
+ rowHeight = source.curData.length;
60
+ ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].config = target.curConfig;
61
+ } else if (ctx.currentSheetId === target.sheetId) {
62
+ ctx.config = target.curConfig;
63
+ rowHeight = target.curData.length;
64
+ ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].config = source.curConfig;
65
+ }
66
+ if (RowlChange) {
67
+ ctx.visibledatarow = [];
68
+ ctx.rh_height = 0;
69
+ for (var i = 0; i < rowHeight; i += 1) {
70
+ var rowlen = ctx.defaultrowlen;
71
+ if (ctx.config.rowlen != null && ctx.config.rowlen[i] != null) {
72
+ rowlen = ctx.config.rowlen[i];
73
+ }
74
+ if (ctx.config.rowhidden != null && ctx.config.rowhidden[i] != null) {
75
+ rowlen = ctx.config.rowhidden[i];
76
+ ctx.visibledatarow.push(ctx.rh_height);
77
+ continue;
78
+ } else {
79
+ ctx.rh_height += rowlen + 1;
80
+ }
81
+ ctx.visibledatarow.push(ctx.rh_height);
82
+ }
83
+ ctx.rh_height += 80;
84
+ if (ctx.currentSheetId === source.sheetId) {} else if (ctx.currentSheetId === target.sheetId) {}
85
+ }
86
+ if (ctx.currentSheetId === source.sheetId) {
87
+ ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].data = target.curData;
88
+ } else if (ctx.currentSheetId === target.sheetId) {
89
+ ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].data = source.curData;
90
+ }
91
+ if (ctx.currentSheetId === target.sheetId) {
92
+ ctx.luckysheet_select_save = [{
93
+ row: target.range.row,
94
+ column: target.range.column
95
+ }];
96
+ } else {
97
+ ctx.luckysheet_select_save = [{
98
+ row: source.range.row,
99
+ column: source.range.column
100
+ }];
101
+ }
102
+ if (ctx.luckysheet_select_save.length > 0) {}
103
+ ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].luckysheet_conditionformat_save = source.curCdformat;
104
+ ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].luckysheet_conditionformat_save = target.curCdformat;
105
+ ctx.luckysheetfile[getSheetIndex(ctx, source.sheetId)].dataVerification = source.curDataVerification;
106
+ ctx.luckysheetfile[getSheetIndex(ctx, target.sheetId)].dataVerification = target.curDataVerification;
107
+ ctx.formulaCache.execFunctionExist.reverse();
108
+ execFunctionGroup(ctx, null, null, null, null, target.curData);
109
+ ctx.formulaCache.execFunctionGlobalData = null;
110
+ storeSheetParamALL(ctx);
111
+ }
112
+ function pasteHandler(ctx, data, borderInfo) {
113
+ var _a;
114
+ var _b, _c, _d, _e, _f, _g;
115
+ var allowEdit = isAllowEdit(ctx);
116
+ if (!allowEdit) return;
117
+ if (((_c = (_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0) !== 1) {
118
+ return;
119
+ }
120
+ if (_typeof(data) === "object") {
121
+ if (data.length === 0) {
122
+ return;
123
+ }
124
+ var cfg = ctx.config || {};
125
+ if (cfg.merge == null) {
126
+ cfg.merge = {};
127
+ }
128
+ if (JSON.stringify(borderInfo).length > 2 && cfg.borderInfo == null) {
129
+ cfg.borderInfo = [];
130
+ }
131
+ var copyh = data.length;
132
+ var copyc = data[0].length;
133
+ var minh = ctx.luckysheet_select_save[0].row[0];
134
+ var maxh = minh + copyh - 1;
135
+ var minc = ctx.luckysheet_select_save[0].column[0];
136
+ var maxc = minc + copyc - 1;
137
+ var has_PartMC = false;
138
+ if (cfg.merge != null) {
139
+ has_PartMC = hasPartMC(ctx, cfg, minh, maxh, minc, maxc);
140
+ }
141
+ if (has_PartMC) {
142
+ return;
143
+ }
144
+ var d = getFlowdata(ctx);
145
+ if (!d) return;
146
+ var rowMaxLength = d.length;
147
+ var cellMaxLength = d[0].length;
148
+ var addr = maxh - rowMaxLength + 1;
149
+ var addc = maxc - cellMaxLength + 1;
150
+ if (addr > 0 || addc > 0) {
151
+ expandRowsAndColumns(d, addr, addc);
152
+ }
153
+ if (!d) return;
154
+ if (cfg.rowlen == null) {
155
+ cfg.rowlen = {};
156
+ }
157
+ var RowlChange = false;
158
+ var offsetMC = {};
159
+ for (var h = minh; h <= maxh; h += 1) {
160
+ var x = d[h];
161
+ var currentRowLen = ctx.defaultrowlen;
162
+ if (cfg.rowlen[h] != null) {
163
+ currentRowLen = cfg.rowlen[h];
164
+ }
165
+ for (var c = minc; c <= maxc; c += 1) {
166
+ if ((_d = x === null || x === void 0 ? void 0 : x[c]) === null || _d === void 0 ? void 0 : _d.mc) {
167
+ if ("rs" in x[c].mc) {
168
+ delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
169
+ }
170
+ delete x[c].mc;
171
+ }
172
+ var value = null;
173
+ if (data[h - minh] != null && data[h - minh][c - minc] != null) {
174
+ value = data[h - minh][c - minc];
175
+ }
176
+ x[c] = value;
177
+ if (value != null && ((_e = x === null || x === void 0 ? void 0 : x[c]) === null || _e === void 0 ? void 0 : _e.mc)) {
178
+ if (x[c].mc.rs != null) {
179
+ x[c].mc.r = h;
180
+ x[c].mc.c = c;
181
+ cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)] = x[c].mc;
182
+ offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)] = [x[c].mc.r, x[c].mc.c];
183
+ } else {
184
+ x[c] = {
185
+ mc: {
186
+ r: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][0],
187
+ c: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][1]
188
+ }
189
+ };
190
+ }
191
+ }
192
+ if (borderInfo["".concat(h - minh, "_").concat(c - minc)]) {
193
+ var bd_obj = {
194
+ rangeType: "cell",
195
+ value: {
196
+ row_index: h,
197
+ col_index: c,
198
+ l: borderInfo["".concat(h - minh, "_").concat(c - minc)].l,
199
+ r: borderInfo["".concat(h - minh, "_").concat(c - minc)].r,
200
+ t: borderInfo["".concat(h - minh, "_").concat(c - minc)].t,
201
+ b: borderInfo["".concat(h - minh, "_").concat(c - minc)].b
202
+ }
203
+ };
204
+ (_f = cfg.borderInfo) === null || _f === void 0 ? void 0 : _f.push(bd_obj);
205
+ }
206
+ }
207
+ d[h] = x;
208
+ if (currentRowLen !== ctx.defaultrowlen) {
209
+ cfg.rowlen[h] = currentRowLen;
210
+ }
211
+ }
212
+ ctx.luckysheet_select_save = [{
213
+ row: [minh, maxh],
214
+ column: [minc, maxc]
215
+ }];
216
+ if (addr > 0 || addc > 0 || RowlChange) {
217
+ ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config = cfg;
218
+ } else {
219
+ ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].config = cfg;
220
+ }
221
+ jfrefreshgrid(ctx, null, undefined);
222
+ } else {
223
+ data = data.replace(/\r/g, "");
224
+ var dataChe = [];
225
+ var che = data.split("\n");
226
+ var colchelen = che[0].split("\t").length;
227
+ for (var i = 0; i < che.length; i += 1) {
228
+ if (che[i].split("\t").length < colchelen) {
229
+ continue;
230
+ }
231
+ dataChe.push(che[i].split("\t"));
232
+ }
233
+ var d = getFlowdata(ctx);
234
+ if (!d) return;
235
+ var last = (_g = ctx.luckysheet_select_save) === null || _g === void 0 ? void 0 : _g[ctx.luckysheet_select_save.length - 1];
236
+ if (!last) return;
237
+ var curR = last.row == null ? 0 : last.row[0];
238
+ var curC = last.column == null ? 0 : last.column[0];
239
+ var rlen = dataChe.length;
240
+ var clen = dataChe[0].length;
241
+ var has_PartMC = false;
242
+ if (ctx.config.merge != null) {
243
+ has_PartMC = hasPartMC(ctx, ctx.config, curR, curR + rlen - 1, curC, curC + clen - 1);
244
+ }
245
+ if (has_PartMC) {
246
+ return;
247
+ }
248
+ var addr = curR + rlen - d.length;
249
+ var addc = curC + clen - d[0].length;
250
+ if (addr > 0 || addc > 0) {
251
+ expandRowsAndColumns(d, addr, addc);
252
+ }
253
+ if (!d) return;
254
+ for (var r = 0; r < rlen; r += 1) {
255
+ var x = d[r + curR];
256
+ for (var c = 0; c < clen; c += 1) {
257
+ var originCell = x[c + curC];
258
+ var value = dataChe[r][c];
259
+ if (isRealNum(value)) {
260
+ if (originCell && originCell.ct && originCell.ct.fa === "@") {
261
+ value = String(value);
262
+ } else {
263
+ value = parseFloat(value);
264
+ }
265
+ }
266
+ if (originCell) {
267
+ originCell.v = value;
268
+ if (originCell.ct != null && originCell.ct.fa != null) {
269
+ originCell.m = update(originCell.ct.fa, value);
270
+ } else {
271
+ originCell.m = value;
272
+ }
273
+ if (originCell.f != null && originCell.f.length > 0) {
274
+ originCell.f = "";
275
+ delFunctionGroup(ctx, r + curR, c + curC, ctx.currentSheetId);
276
+ }
277
+ } else {
278
+ var cell = {};
279
+ var mask = genarate(value);
280
+ _a = mask, cell.m = _a[0], cell.ct = _a[1], cell.v = _a[2];
281
+ x[c + curC] = cell;
282
+ }
283
+ }
284
+ d[r + curR] = x;
285
+ }
286
+ last.row = [curR, curR + rlen - 1];
287
+ last.column = [curC, curC + clen - 1];
288
+ jfrefreshgrid(ctx, null, undefined);
289
+ }
290
+ }
291
+ function setCellHyperlink(ctx, id, r, c, link) {
292
+ var index = getSheetIndex(ctx, id);
293
+ if (!ctx.luckysheetfile[index].hyperlink) {
294
+ ctx.luckysheetfile[index].hyperlink = {};
295
+ }
296
+ ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)] = link;
297
+ }
298
+ function pasteHandlerOfCutPaste(ctx, copyRange) {
299
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
300
+ var allowEdit = isAllowEdit(ctx);
301
+ if (!allowEdit) return;
302
+ if (!copyRange) return;
303
+ var cfg = ctx.config || {};
304
+ if (cfg.merge == null) {
305
+ cfg.merge = {};
306
+ }
307
+ var copyHasMC = copyRange.HasMC;
308
+ var copyRowlChange = copyRange.RowlChange;
309
+ var copySheetId = copyRange.dataSheetId;
310
+ var c_r1 = copyRange.copyRange[0].row[0];
311
+ var c_r2 = copyRange.copyRange[0].row[1];
312
+ var c_c1 = copyRange.copyRange[0].column[0];
313
+ var c_c2 = copyRange.copyRange[0].column[1];
314
+ var copyData = _.cloneDeep(getdatabyselection(ctx, {
315
+ row: [c_r1, c_r2],
316
+ column: [c_c1, c_c2]
317
+ }, copySheetId));
318
+ var copyh = copyData.length;
319
+ var copyc = copyData[0].length;
320
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
321
+ if (!last || last.row_focus == null || last.column_focus == null) return;
322
+ var minh = last.row_focus;
323
+ var maxh = minh + copyh - 1;
324
+ var minc = last.column_focus;
325
+ var maxc = minc + copyc - 1;
326
+ var has_PartMC = false;
327
+ if (cfg.merge != null) {
328
+ has_PartMC = hasPartMC(ctx, cfg, minh, maxh, minc, maxc);
329
+ }
330
+ if (has_PartMC) {
331
+ return;
332
+ }
333
+ var d = getFlowdata(ctx);
334
+ if (!d) return;
335
+ var rowMaxLength = d.length;
336
+ var cellMaxLength = d[0].length;
337
+ var addr = copyh + minh - rowMaxLength;
338
+ var addc = copyc + minc - cellMaxLength;
339
+ if (addr > 0 || addc > 0) {
340
+ expandRowsAndColumns(d, addr, addc);
341
+ }
342
+ var borderInfoCompute = getBorderInfoCompute(ctx, copySheetId);
343
+ var c_dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].dataVerification) || {};
344
+ var dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification) || {};
345
+ if (((_b = ctx.luckysheet_select_save) === null || _b === void 0 ? void 0 : _b.length) === 1 && ((_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.copyRange.length) === 1) {
346
+ _.forEach((_d = ctx.luckysheet_copy_save) === null || _d === void 0 ? void 0 : _d.copyRange, function (range) {
347
+ var _a, _b, _c;
348
+ for (var r = 0; r <= range.row[1] - range.row[0]; r += 1) {
349
+ for (var c = 0; c <= range.column[1] - range.column[0]; c += 1) {
350
+ var index = getSheetIndex(ctx, (_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.dataSheetId);
351
+ if (((_b = ctx.luckysheetfile[index].data[r + range.row[0]][c + range.column[0]]) === null || _b === void 0 ? void 0 : _b.hl) && ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)]) {
352
+ setCellHyperlink(ctx, (_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.dataSheetId, r + ctx.luckysheet_select_save[0].row[0], c + ctx.luckysheet_select_save[0].column[0], ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)]);
353
+ }
354
+ }
355
+ }
356
+ });
357
+ }
358
+ if (ctx.currentSheetId === copySheetId) {
359
+ for (var i = c_r1; i <= c_r2; i += 1) {
360
+ for (var j = c_c1; j <= c_c2; j += 1) {
361
+ var cell = d[i][j];
362
+ if (cell && _.isPlainObject(cell) && "mc" in cell) {
363
+ if (((_e = cell.mc) === null || _e === void 0 ? void 0 : _e.rs) != null) {
364
+ delete cfg.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
365
+ }
366
+ delete cell.mc;
367
+ }
368
+ d[i][j] = null;
369
+ delete dataVerification["".concat(i, "_").concat(j)];
370
+ (_f = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink) === null || _f === void 0 ? true : delete _f["".concat(i, "_").concat(j)];
371
+ }
372
+ }
373
+ if (cfg.borderInfo && cfg.borderInfo.length > 0) {
374
+ var source_borderInfo = [];
375
+ for (var i = 0; i < cfg.borderInfo.length; i += 1) {
376
+ var bd_rangeType = cfg.borderInfo[i].rangeType;
377
+ if (bd_rangeType === "range") {
378
+ var bd_range = cfg.borderInfo[i].range;
379
+ var bd_emptyRange = [];
380
+ for (var j = 0; j < bd_range.length; j += 1) {
381
+ bd_emptyRange = bd_emptyRange.concat(CFSplitRange(bd_range[j], {
382
+ row: [c_r1, c_r2],
383
+ column: [c_c1, c_c2]
384
+ }, {
385
+ row: [minh, maxh],
386
+ column: [minc, maxc]
387
+ }, "restPart"));
388
+ }
389
+ cfg.borderInfo[i].range = bd_emptyRange;
390
+ source_borderInfo.push(cfg.borderInfo[i]);
391
+ } else if (bd_rangeType === "cell") {
392
+ var bd_r = cfg.borderInfo[i].value.row_index;
393
+ var bd_c = cfg.borderInfo[i].value.col_index;
394
+ if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
395
+ source_borderInfo.push(cfg.borderInfo[i]);
396
+ }
397
+ }
398
+ }
399
+ cfg.borderInfo = source_borderInfo;
400
+ }
401
+ }
402
+ var offsetMC = {};
403
+ for (var h = minh; h <= maxh; h += 1) {
404
+ var x = d[h];
405
+ for (var c = minc; c <= maxc; c += 1) {
406
+ if (borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)] && !borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].s) {
407
+ var bd_obj = {
408
+ rangeType: "cell",
409
+ value: {
410
+ row_index: h,
411
+ col_index: c,
412
+ l: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].l,
413
+ r: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].r,
414
+ t: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].t,
415
+ b: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].b
416
+ }
417
+ };
418
+ if (cfg.borderInfo == null) {
419
+ cfg.borderInfo = [];
420
+ }
421
+ cfg.borderInfo.push(bd_obj);
422
+ } else if (borderInfoCompute["".concat(h, "_").concat(c)]) {
423
+ var bd_obj = {
424
+ rangeType: "cell",
425
+ value: {
426
+ row_index: h,
427
+ col_index: c,
428
+ l: null,
429
+ r: null,
430
+ t: null,
431
+ b: null
432
+ }
433
+ };
434
+ if (cfg.borderInfo == null) {
435
+ cfg.borderInfo = [];
436
+ }
437
+ cfg.borderInfo.push(bd_obj);
438
+ } else if (borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)]) {
439
+ var bd_obj = {
440
+ rangeType: "range",
441
+ borderType: "border-slash",
442
+ color: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].s.color,
443
+ style: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].s.style,
444
+ range: normalizeSelection(ctx, [{
445
+ row: [h, h],
446
+ column: [c, c]
447
+ }])
448
+ };
449
+ if (cfg.borderInfo == null) {
450
+ cfg.borderInfo = [];
451
+ }
452
+ cfg.borderInfo.push(bd_obj);
453
+ }
454
+ if (c_dataVerification["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)]) {
455
+ dataVerification["".concat(h, "_").concat(c)] = c_dataVerification["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)];
456
+ }
457
+ if ((_g = x[c]) === null || _g === void 0 ? void 0 : _g.mc) {
458
+ if (((_j = (_h = x[c]) === null || _h === void 0 ? void 0 : _h.mc) === null || _j === void 0 ? void 0 : _j.rs) != null) {
459
+ delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
460
+ }
461
+ delete x[c].mc;
462
+ }
463
+ var value = null;
464
+ if (copyData[h - minh] != null && copyData[h - minh][c - minc] != null) {
465
+ value = copyData[h - minh][c - minc];
466
+ }
467
+ x[c] = _.cloneDeep(value);
468
+ if (value != null && copyHasMC && ((_k = x[c]) === null || _k === void 0 ? void 0 : _k.mc)) {
469
+ if (x[c].mc.rs != null) {
470
+ x[c].mc.r = h;
471
+ x[c].mc.c = c;
472
+ cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)] = x[c].mc;
473
+ offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)] = [x[c].mc.r, x[c].mc.c];
474
+ } else {
475
+ x[c] = {
476
+ mc: {
477
+ r: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][0],
478
+ c: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][1]
479
+ }
480
+ };
481
+ }
482
+ }
483
+ }
484
+ d[h] = x;
485
+ }
486
+ last.row = [minh, maxh];
487
+ last.column = [minc, maxc];
488
+ if (copyRowlChange) {}
489
+ var source;
490
+ var target;
491
+ if (ctx.currentSheetId !== copySheetId) {
492
+ var sourceData = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].data);
493
+ var sourceConfig = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].config);
494
+ var sourceCurData = _.cloneDeep(sourceData);
495
+ var sourceCurConfig = _.cloneDeep(sourceConfig) || {};
496
+ if (sourceCurConfig.merge == null) {
497
+ sourceCurConfig.merge = {};
498
+ }
499
+ for (var source_r = c_r1; source_r <= c_r2; source_r += 1) {
500
+ for (var source_c = c_c1; source_c <= c_c2; source_c += 1) {
501
+ var cell = sourceCurData[source_r][source_c];
502
+ if (cell === null || cell === void 0 ? void 0 : cell.mc) {
503
+ if ("rs" in cell.mc) {
504
+ delete sourceCurConfig.merge["".concat(cell.mc.r, "_").concat(cell.mc.c)];
505
+ }
506
+ delete cell.mc;
507
+ }
508
+ sourceCurData[source_r][source_c] = null;
509
+ }
510
+ }
511
+ if (copyRowlChange) {}
512
+ if (sourceCurConfig.borderInfo && sourceCurConfig.borderInfo.length > 0) {
513
+ var source_borderInfo = [];
514
+ for (var i = 0; i < sourceCurConfig.borderInfo.length; i += 1) {
515
+ var bd_rangeType = sourceCurConfig.borderInfo[i].rangeType;
516
+ if (bd_rangeType === "range") {
517
+ var bd_range = sourceCurConfig.borderInfo[i].range;
518
+ var bd_emptyRange = [];
519
+ for (var j = 0; j < bd_range.length; j += 1) {
520
+ bd_emptyRange = bd_emptyRange.concat(CFSplitRange(bd_range[j], {
521
+ row: [c_r1, c_r2],
522
+ column: [c_c1, c_c2]
523
+ }, {
524
+ row: [minh, maxh],
525
+ column: [minc, maxc]
526
+ }, "restPart"));
527
+ }
528
+ sourceCurConfig.borderInfo[i].range = bd_emptyRange;
529
+ source_borderInfo.push(sourceCurConfig.borderInfo[i]);
530
+ } else if (bd_rangeType === "cell") {
531
+ var bd_r = sourceCurConfig.borderInfo[i].value.row_index;
532
+ var bd_c = sourceCurConfig.borderInfo[i].value.col_index;
533
+ if (!(bd_r >= c_r1 && bd_r <= c_r2 && bd_c >= c_c1 && bd_c <= c_c2)) {
534
+ source_borderInfo.push(sourceCurConfig.borderInfo[i]);
535
+ }
536
+ }
537
+ }
538
+ sourceCurConfig.borderInfo = source_borderInfo;
539
+ }
540
+ var source_cdformat = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].luckysheet_conditionformat_save);
541
+ var source_curCdformat = _.cloneDeep(source_cdformat);
542
+ var ruleArr = [];
543
+ if (source_curCdformat != null && source_curCdformat.length > 0) {
544
+ for (var i = 0; i < source_curCdformat.length; i += 1) {
545
+ var source_curCdformat_cellrange = source_curCdformat[i].cellrange;
546
+ var emptyRange = [];
547
+ var emptyRange2 = [];
548
+ for (var j = 0; j < source_curCdformat_cellrange.length; j += 1) {
549
+ var range = CFSplitRange(source_curCdformat_cellrange[j], {
550
+ row: [c_r1, c_r2],
551
+ column: [c_c1, c_c2]
552
+ }, {
553
+ row: [minh, maxh],
554
+ column: [minc, maxc]
555
+ }, "restPart");
556
+ emptyRange = emptyRange.concat(range);
557
+ var range2 = CFSplitRange(source_curCdformat_cellrange[j], {
558
+ row: [c_r1, c_r2],
559
+ column: [c_c1, c_c2]
560
+ }, {
561
+ row: [minh, maxh],
562
+ column: [minc, maxc]
563
+ }, "operatePart");
564
+ if (range2.length > 0) {
565
+ emptyRange2 = emptyRange2.concat(range2);
566
+ }
567
+ }
568
+ source_curCdformat[i].cellrange = emptyRange;
569
+ if (emptyRange2.length > 0) {
570
+ var ruleObj = (_l = source_curCdformat[i]) !== null && _l !== void 0 ? _l : {};
571
+ ruleObj.cellrange = emptyRange2;
572
+ ruleArr.push(ruleObj);
573
+ }
574
+ }
575
+ }
576
+ var target_cdformat = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].luckysheet_conditionformat_save);
577
+ var target_curCdformat = _.cloneDeep(target_cdformat);
578
+ if (ruleArr.length > 0) {
579
+ target_curCdformat = target_curCdformat === null || target_curCdformat === void 0 ? void 0 : target_curCdformat.concat(ruleArr);
580
+ }
581
+ for (var i = c_r1; i <= c_r2; i += 1) {
582
+ for (var j = c_c1; j <= c_c2; j += 1) {
583
+ delete c_dataVerification["".concat(i, "_").concat(j)];
584
+ }
585
+ }
586
+ source = {
587
+ sheetId: copySheetId,
588
+ data: sourceData,
589
+ curData: sourceCurData,
590
+ config: sourceConfig,
591
+ curConfig: sourceCurConfig,
592
+ cdformat: source_cdformat,
593
+ curCdformat: source_curCdformat,
594
+ dataVerification: _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetId)].dataVerification),
595
+ curDataVerification: c_dataVerification,
596
+ range: {
597
+ row: [c_r1, c_r2],
598
+ column: [c_c1, c_c2]
599
+ }
600
+ };
601
+ target = {
602
+ sheetId: ctx.currentSheetId,
603
+ data: getFlowdata(ctx),
604
+ curData: d,
605
+ config: _.cloneDeep(ctx.config),
606
+ curConfig: cfg,
607
+ cdformat: target_cdformat,
608
+ curCdformat: target_curCdformat,
609
+ dataVerification: _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification),
610
+ curDataVerification: dataVerification,
611
+ range: {
612
+ row: [minh, maxh],
613
+ column: [minc, maxc]
614
+ }
615
+ };
616
+ } else {
617
+ var cdformat = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].luckysheet_conditionformat_save);
618
+ var curCdformat = _.cloneDeep(cdformat);
619
+ if (curCdformat != null && curCdformat.length > 0) {
620
+ for (var i = 0; i < curCdformat.length; i += 1) {
621
+ var cellrange = curCdformat[i].cellrange;
622
+ var emptyRange = [];
623
+ for (var j = 0; j < cellrange.length; j += 1) {
624
+ var range = CFSplitRange(cellrange[j], {
625
+ row: [c_r1, c_r2],
626
+ column: [c_c1, c_c2]
627
+ }, {
628
+ row: [minh, maxh],
629
+ column: [minc, maxc]
630
+ }, "allPart");
631
+ emptyRange = emptyRange.concat(range);
632
+ }
633
+ curCdformat[i].cellrange = emptyRange;
634
+ }
635
+ }
636
+ source = {
637
+ sheetId: ctx.currentSheetId,
638
+ data: getFlowdata(ctx),
639
+ curData: d,
640
+ config: _.cloneDeep(ctx.config),
641
+ curConfig: cfg,
642
+ cdformat: cdformat,
643
+ curCdformat: curCdformat,
644
+ dataVerification: _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification),
645
+ curDataVerification: dataVerification,
646
+ range: {
647
+ row: [c_r1, c_r2],
648
+ column: [c_c1, c_c2]
649
+ }
650
+ };
651
+ target = {
652
+ sheetId: ctx.currentSheetId,
653
+ data: getFlowdata(ctx),
654
+ curData: d,
655
+ config: _.cloneDeep(ctx.config),
656
+ curConfig: cfg,
657
+ cdformat: cdformat,
658
+ curCdformat: curCdformat,
659
+ dataVerification: _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].dataVerification),
660
+ curDataVerification: dataVerification,
661
+ range: {
662
+ row: [minh, maxh],
663
+ column: [minc, maxc]
664
+ }
665
+ };
666
+ }
667
+ if (addr > 0 || addc > 0) {
668
+ postPasteCut(ctx, source, target, true);
669
+ } else {
670
+ postPasteCut(ctx, source, target, copyRowlChange);
671
+ }
672
+ }
673
+ function pasteHandlerOfCopyPaste(ctx, copyRange) {
674
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
675
+ var allowEdit = isAllowEdit(ctx);
676
+ if (!allowEdit) return;
677
+ if (!copyRange) return;
678
+ var cfg = ctx.config;
679
+ if (_.isNil(cfg.merge)) {
680
+ cfg.merge = {};
681
+ }
682
+ var copyHasMC = copyRange.HasMC;
683
+ var copyRowlChange = copyRange.RowlChange;
684
+ var copySheetIndex = copyRange.dataSheetId;
685
+ var c_r1 = copyRange.copyRange[0].row[0];
686
+ var c_r2 = copyRange.copyRange[0].row[1];
687
+ var c_c1 = copyRange.copyRange[0].column[0];
688
+ var c_c2 = copyRange.copyRange[0].column[1];
689
+ var arr = [];
690
+ var isSameRow = false;
691
+ var _loop_1 = function _loop_1(i) {
692
+ var arrData = getdatabyselection(ctx, {
693
+ row: copyRange.copyRange[i].row,
694
+ column: copyRange.copyRange[i].column
695
+ }, copySheetIndex);
696
+ if (copyRange.copyRange.length > 1) {
697
+ if (c_r1 === copyRange.copyRange[1].row[0] && c_r2 === copyRange.copyRange[1].row[1]) {
698
+ arrData = arrData[0].map(function (col, a) {
699
+ return arrData.map(function (row) {
700
+ return row[a];
701
+ });
702
+ });
703
+ arr = arr.concat(arrData);
704
+ isSameRow = true;
705
+ } else if (c_c1 === copyRange.copyRange[1].column[0] && c_c2 === copyRange.copyRange[1].column[1]) {
706
+ arr = arr.concat(arrData);
707
+ }
708
+ } else {
709
+ arr = arrData;
710
+ }
711
+ };
712
+ for (var i = 0; i < copyRange.copyRange.length; i += 1) {
713
+ _loop_1(i);
714
+ }
715
+ if (isSameRow) {
716
+ arr = arr[0].map(function (col, b) {
717
+ return arr.map(function (row) {
718
+ return row[b];
719
+ });
720
+ });
721
+ }
722
+ var copyData = _.cloneDeep(arr);
723
+ if (copyRange.copyRange.length > 1) {
724
+ for (var i = 0; i < copyData.length; i += 1) {
725
+ for (var j = 0; j < copyData[i].length; j += 1) {
726
+ if (copyData[i][j] != null && copyData[i][j].f != null) {
727
+ delete copyData[i][j].f;
728
+ delete copyData[i][j].spl;
729
+ }
730
+ }
731
+ }
732
+ }
733
+ var copyh = copyData.length;
734
+ var copyc = copyData[0].length;
735
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
736
+ if (!last) return;
737
+ var minh = last.row[0];
738
+ var maxh = last.row[1];
739
+ var minc = last.column[0];
740
+ var maxc = last.column[1];
741
+ var mh = (maxh - minh + 1) % copyh;
742
+ var mc = (maxc - minc + 1) % copyc;
743
+ if (mh !== 0 || mc !== 0) {
744
+ maxh = minh + copyh - 1;
745
+ maxc = minc + copyc - 1;
746
+ }
747
+ var has_PartMC = false;
748
+ if (!_.isNil(cfg.merge)) {
749
+ has_PartMC = hasPartMC(ctx, cfg, minh, maxh, minc, maxc);
750
+ }
751
+ if (has_PartMC) {
752
+ return;
753
+ }
754
+ var timesH = (maxh - minh + 1) / copyh;
755
+ var timesC = (maxc - minc + 1) / copyc;
756
+ var d = getFlowdata(ctx);
757
+ if (!d) return;
758
+ var rowMaxLength = d.length;
759
+ var cellMaxLength = d[0].length;
760
+ var addr = copyh + minh - rowMaxLength;
761
+ var addc = copyc + minc - cellMaxLength;
762
+ if (addr > 0 || addc > 0) {
763
+ expandRowsAndColumns(d, addr, addc);
764
+ }
765
+ var borderInfoCompute = getBorderInfoCompute(ctx, copySheetIndex);
766
+ var c_dataVerification = _.cloneDeep(ctx.luckysheetfile[getSheetIndex(ctx, copySheetIndex)].dataVerification) || {};
767
+ var dataVerification = null;
768
+ var mth = 0;
769
+ var mtc = 0;
770
+ var maxcellCahe = 0;
771
+ var maxrowCache = 0;
772
+ var file = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
773
+ var hiddenRows = new Set(Object.keys(((_b = file.config) === null || _b === void 0 ? void 0 : _b.rowhidden) || {}));
774
+ var hiddenCols = new Set(Object.keys(((_c = file.config) === null || _c === void 0 ? void 0 : _c.colhidden) || {}));
775
+ for (var th = 1; th <= timesH; th += 1) {
776
+ for (var tc = 1; tc <= timesC; tc += 1) {
777
+ mth = minh + (th - 1) * copyh;
778
+ mtc = minc + (tc - 1) * copyc;
779
+ maxrowCache = minh + th * copyh;
780
+ maxcellCahe = minc + tc * copyc;
781
+ var offsetRow = mth - c_r1;
782
+ var offsetCol = mtc - c_c1;
783
+ var offsetMC = {};
784
+ for (var h = mth; h < maxrowCache; h += 1) {
785
+ if (hiddenRows === null || hiddenRows === void 0 ? void 0 : hiddenRows.has(h.toString())) continue;
786
+ var x = d[h];
787
+ for (var c = mtc; c < maxcellCahe; c += 1) {
788
+ if (hiddenCols === null || hiddenCols === void 0 ? void 0 : hiddenCols.has(c.toString())) continue;
789
+ if (borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)] && !borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].s) {
790
+ var bd_obj = {
791
+ rangeType: "cell",
792
+ value: {
793
+ row_index: h,
794
+ col_index: c,
795
+ l: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].l,
796
+ r: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].r,
797
+ t: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].t,
798
+ b: borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)].b
799
+ }
800
+ };
801
+ if (_.isNil(cfg.borderInfo)) {
802
+ cfg.borderInfo = [];
803
+ }
804
+ cfg.borderInfo.push(bd_obj);
805
+ } else if (borderInfoCompute["".concat(h, "_").concat(c)]) {
806
+ var bd_obj = {
807
+ rangeType: "cell",
808
+ value: {
809
+ row_index: h,
810
+ col_index: c,
811
+ l: null,
812
+ r: null,
813
+ t: null,
814
+ b: null
815
+ }
816
+ };
817
+ if (_.isNil(cfg.borderInfo)) {
818
+ cfg.borderInfo = [];
819
+ }
820
+ cfg.borderInfo.push(bd_obj);
821
+ } else if (borderInfoCompute["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)]) {
822
+ var bd_obj = {
823
+ rangeType: "range",
824
+ borderType: "border-slash",
825
+ color: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].s.color,
826
+ style: borderInfoCompute["".concat(c_r1 + h - minh, "_").concat(c_c1 + c - minc)].s.style,
827
+ range: normalizeSelection(ctx, [{
828
+ row: [h, h],
829
+ column: [c, c]
830
+ }])
831
+ };
832
+ if (cfg.borderInfo == null) {
833
+ cfg.borderInfo = [];
834
+ }
835
+ cfg.borderInfo.push(bd_obj);
836
+ }
837
+ if (c_dataVerification["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)]) {
838
+ if (_.isNil(dataVerification)) {
839
+ dataVerification = _.cloneDeep(((_d = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)]) === null || _d === void 0 ? void 0 : _d.dataVerification) || {});
840
+ }
841
+ dataVerification["".concat(h, "_").concat(c)] = c_dataVerification["".concat(c_r1 + h - mth, "_").concat(c_c1 + c - mtc)];
842
+ }
843
+ if (((_e = x[c]) === null || _e === void 0 ? void 0 : _e.mc) != null) {
844
+ if ("rs" in x[c].mc) {
845
+ delete cfg.merge["".concat(x[c].mc.r, "_").concat(x[c].mc.c)];
846
+ }
847
+ delete x[c].mc;
848
+ }
849
+ var value = null;
850
+ if ((_f = copyData[h - mth]) === null || _f === void 0 ? void 0 : _f[c - mtc]) {
851
+ value = _.cloneDeep(copyData[h - mth][c - mtc]);
852
+ }
853
+ if (!_.isNil(value) && !_.isNil(value.f)) {
854
+ var func = value.f;
855
+ if (offsetRow > 0) {
856
+ func = "=".concat(functionCopy(ctx, func, "down", offsetRow));
857
+ }
858
+ if (offsetRow < 0) {
859
+ func = "=".concat(functionCopy(ctx, func, "up", Math.abs(offsetRow)));
860
+ }
861
+ if (offsetCol > 0) {
862
+ func = "=".concat(functionCopy(ctx, func, "right", offsetCol));
863
+ }
864
+ if (offsetCol < 0) {
865
+ func = "=".concat(functionCopy(ctx, func, "left", Math.abs(offsetCol)));
866
+ }
867
+ var funcV = execfunction(ctx, func, h, c, undefined, undefined, true);
868
+ if (!_.isNil(value.spl)) {} else {
869
+ value.v = funcV[1], value.f = funcV[2];
870
+ if (!_.isNil(value.ct) && !_.isNil(value.ct.fa)) {
871
+ value.m = update(value.ct.fa, funcV[1]);
872
+ } else {
873
+ value.m = update("General", funcV[1]);
874
+ }
875
+ }
876
+ }
877
+ x[c] = _.cloneDeep(value);
878
+ if (value != null && copyHasMC && ((_g = x === null || x === void 0 ? void 0 : x[c]) === null || _g === void 0 ? void 0 : _g.mc)) {
879
+ if (((_j = (_h = x === null || x === void 0 ? void 0 : x[c]) === null || _h === void 0 ? void 0 : _h.mc) === null || _j === void 0 ? void 0 : _j.rs) != null) {
880
+ x[c].mc.r = h;
881
+ x[c].mc.c = c;
882
+ cfg.merge["".concat(h, "_").concat(c)] = x[c].mc;
883
+ offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)] = [x[c].mc.r, x[c].mc.c];
884
+ } else {
885
+ x[c] = {
886
+ mc: {
887
+ r: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][0],
888
+ c: offsetMC["".concat(value.mc.r, "_").concat(value.mc.c)][1]
889
+ }
890
+ };
891
+ }
892
+ }
893
+ }
894
+ d[h] = x;
895
+ }
896
+ }
897
+ }
898
+ var cdformat = null;
899
+ if (copyRange.copyRange.length === 1) {
900
+ var c_file = ctx.luckysheetfile[getSheetIndex(ctx, copySheetIndex)];
901
+ var a_file = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
902
+ var ruleArr_cf = _.cloneDeep(c_file.luckysheet_conditionformat_save);
903
+ if (!_.isNil(ruleArr_cf) && ruleArr_cf.length > 0) {
904
+ cdformat = (_k = _.cloneDeep(a_file.luckysheet_conditionformat_save)) !== null && _k !== void 0 ? _k : [];
905
+ for (var i = 0; i < ruleArr_cf.length; i += 1) {
906
+ var cf_range = ruleArr_cf[i].cellrange;
907
+ var emptyRange = [];
908
+ for (var th = 1; th <= timesH; th += 1) {
909
+ for (var tc = 1; tc <= timesC; tc += 1) {
910
+ mth = minh + (th - 1) * copyh;
911
+ mtc = minc + (tc - 1) * copyc;
912
+ maxrowCache = minh + th * copyh;
913
+ maxcellCahe = minc + tc * copyc;
914
+ for (var j = 0; j < cf_range.length; j += 1) {
915
+ var range = CFSplitRange(cf_range[j], {
916
+ row: [c_r1, c_r2],
917
+ column: [c_c1, c_c2]
918
+ }, {
919
+ row: [mth, maxrowCache - 1],
920
+ column: [mtc, maxcellCahe - 1]
921
+ }, "operatePart");
922
+ if (range.length > 0) {
923
+ emptyRange = emptyRange.concat(range);
924
+ }
925
+ }
926
+ }
927
+ }
928
+ if (emptyRange.length > 0) {
929
+ ruleArr_cf[i].cellrange = emptyRange;
930
+ cdformat.push(ruleArr_cf[i]);
931
+ }
932
+ }
933
+ }
934
+ }
935
+ last.row = [minh, maxh];
936
+ last.column = [minc, maxc];
937
+ file.config = cfg;
938
+ file.luckysheet_conditionformat_save = cdformat;
939
+ file.dataVerification = __assign(__assign({}, file.dataVerification), dataVerification);
940
+ if (((_l = ctx.luckysheet_select_save) === null || _l === void 0 ? void 0 : _l.length) === 1 && ((_m = ctx.luckysheet_copy_save) === null || _m === void 0 ? void 0 : _m.copyRange.length) === 1) {
941
+ _.forEach((_o = ctx.luckysheet_copy_save) === null || _o === void 0 ? void 0 : _o.copyRange, function (range) {
942
+ var _a, _b, _c;
943
+ for (var r = 0; r <= range.row[1] - range.row[0]; r += 1) {
944
+ for (var c = 0; c <= range.column[1] - range.column[0]; c += 1) {
945
+ var index = getSheetIndex(ctx, (_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.dataSheetId);
946
+ if (((_b = ctx.luckysheetfile[index].data[r + range.row[0]][c + range.column[0]]) === null || _b === void 0 ? void 0 : _b.hl) && ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)]) {
947
+ setCellHyperlink(ctx, (_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.dataSheetId, r + ctx.luckysheet_select_save[0].row[0], c + ctx.luckysheet_select_save[0].column[0], ctx.luckysheetfile[index].hyperlink["".concat(r, "_").concat(c)]);
948
+ }
949
+ }
950
+ }
951
+ });
952
+ }
953
+ if (copyRowlChange || addr > 0 || addc > 0) {
954
+ jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
955
+ } else {
956
+ jfrefreshgrid(ctx, d, ctx.luckysheet_select_save);
957
+ }
958
+ }
959
+ function handleFormulaStringPaste(ctx, formulaStr) {
960
+ var r = ctx.luckysheet_select_save[0].row[0];
961
+ var c = ctx.luckysheet_select_save[0].column[0];
962
+ var funcV = execfunction(ctx, formulaStr, r, c, undefined, undefined, true);
963
+ var val = funcV[1];
964
+ var d = getFlowdata(ctx);
965
+ if (!d) return;
966
+ if (!d[r][c]) d[r][c] = {};
967
+ d[r][c].m = val.toString();
968
+ d[r][c].v = val;
969
+ d[r][c].f = formulaStr;
970
+ }
971
+ export function handlePaste(ctx, e) {
972
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
973
+ var allowEdit = isAllowEdit(ctx);
974
+ if (!allowEdit) return;
975
+ if (selectionCache.isPasteAction) {
976
+ ctx.luckysheetCellUpdate = [];
977
+ selectionCache.isPasteAction = false;
978
+ var clipboardData = e.clipboardData;
979
+ if (!clipboardData) {
980
+ clipboardData = window.clipboardData;
981
+ }
982
+ if (!clipboardData) return;
983
+ var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
984
+ var isEqual = true;
985
+ if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0) {
986
+ var cpDataArr = [];
987
+ var reg = /<tr.*?>(.*?)<\/tr>/g;
988
+ var reg2 = /<td.*?>(.*?)<\/td>/g;
989
+ var regArr = txtdata.match(reg) || [];
990
+ for (var i = 0; i < regArr.length; i += 1) {
991
+ var cpRowArr = [];
992
+ var reg2Arr = regArr[i].match(reg2);
993
+ if (!_.isNil(reg2Arr)) {
994
+ for (var j = 0; j < reg2Arr.length; j += 1) {
995
+ var cpValue = reg2Arr[j].replace(/<td.*?>/g, "").replace(/<\/td>/g, "");
996
+ cpRowArr.push(cpValue);
997
+ }
998
+ }
999
+ cpDataArr.push(cpRowArr);
1000
+ }
1001
+ var copy_r1 = ctx.luckysheet_copy_save.copyRange[0].row[0];
1002
+ var copy_r2 = ctx.luckysheet_copy_save.copyRange[0].row[1];
1003
+ var copy_c1 = ctx.luckysheet_copy_save.copyRange[0].column[0];
1004
+ var copy_c2 = ctx.luckysheet_copy_save.copyRange[0].column[1];
1005
+ var copy_index = ctx.luckysheet_copy_save.dataSheetId;
1006
+ var d = void 0;
1007
+ if (copy_index === ctx.currentSheetId) {
1008
+ d = getFlowdata(ctx);
1009
+ } else {
1010
+ var index = getSheetIndex(ctx, copy_index);
1011
+ if (_.isNil(index)) return;
1012
+ d = ctx.luckysheetfile[index].data;
1013
+ }
1014
+ if (!d) return;
1015
+ for (var r = copy_r1; r <= copy_r2; r += 1) {
1016
+ if (r - copy_r1 > cpDataArr.length - 1) {
1017
+ break;
1018
+ }
1019
+ for (var c = copy_c1; c <= copy_c2; c += 1) {
1020
+ var cell = d[r][c];
1021
+ var isInlineStr = false;
1022
+ if (!_.isNil(cell) && !_.isNil(cell.mc) && _.isNil(cell.mc.rs)) {
1023
+ continue;
1024
+ }
1025
+ var v = void 0;
1026
+ if (!_.isNil(cell)) {
1027
+ if (((_d = (_c = (_b = cell.ct) === null || _b === void 0 ? void 0 : _b.fa) === null || _c === void 0 ? void 0 : _c.indexOf("w")) !== null && _d !== void 0 ? _d : -1) > -1) {
1028
+ v = (_f = (_e = d[r]) === null || _e === void 0 ? void 0 : _e[c]) === null || _f === void 0 ? void 0 : _f.v;
1029
+ } else {
1030
+ v = (_h = (_g = d[r]) === null || _g === void 0 ? void 0 : _g[c]) === null || _h === void 0 ? void 0 : _h.m;
1031
+ }
1032
+ } else {
1033
+ v = "";
1034
+ }
1035
+ if (_.isNil(v) && ((_l = (_k = (_j = d[r]) === null || _j === void 0 ? void 0 : _j[c]) === null || _k === void 0 ? void 0 : _k.ct) === null || _l === void 0 ? void 0 : _l.t) === "inlineStr") {
1036
+ v = d[r][c].ct.s.map(function (val) {
1037
+ return val.v;
1038
+ }).join("");
1039
+ isInlineStr = true;
1040
+ }
1041
+ if (_.isNil(v)) {
1042
+ v = "";
1043
+ }
1044
+ if (isInlineStr) {} else {
1045
+ if (_.trim(cpDataArr[r - copy_r1][c - copy_c1]) !== _.trim(v)) {
1046
+ isEqual = false;
1047
+ break;
1048
+ }
1049
+ }
1050
+ }
1051
+ }
1052
+ }
1053
+ var locale_fontjson_1 = locale(ctx).fontjson;
1054
+ if (((_o = (_m = ctx.hooks).beforePaste) === null || _o === void 0 ? void 0 : _o.call(_m, ctx.luckysheet_select_save, txtdata)) === false) {
1055
+ return;
1056
+ }
1057
+ if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_p = ctx.luckysheet_copy_save) === null || _p === void 0 ? void 0 : _p.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0 && isEqual) {
1058
+ if (ctx.luckysheet_paste_iscut) {
1059
+ ctx.luckysheet_paste_iscut = false;
1060
+ pasteHandlerOfCutPaste(ctx, ctx.luckysheet_copy_save);
1061
+ ctx.luckysheet_selection_range = [];
1062
+ } else {
1063
+ pasteHandlerOfCopyPaste(ctx, ctx.luckysheet_copy_save);
1064
+ }
1065
+ } else if (txtdata.indexOf("fortune-copy-action-image") > -1) {} else {
1066
+ if (txtdata.indexOf("table") > -1) {
1067
+ var ele = document.createElement("div");
1068
+ ele.innerHTML = txtdata;
1069
+ var trList = ele.querySelectorAll("table tr");
1070
+ if (trList.length === 0) {
1071
+ ele.remove();
1072
+ return;
1073
+ }
1074
+ var data_1 = new Array(trList.length);
1075
+ var colLen_1 = 0;
1076
+ _.forEach(trList[0].querySelectorAll("td"), function (td) {
1077
+ var colspan = td.colSpan;
1078
+ if (Number.isNaN(colspan)) {
1079
+ colspan = 1;
1080
+ }
1081
+ colLen_1 += colspan;
1082
+ });
1083
+ for (var i = 0; i < data_1.length; i += 1) {
1084
+ data_1[i] = new Array(colLen_1);
1085
+ }
1086
+ var r_1 = 0;
1087
+ var borderInfo_1 = {};
1088
+ var styleInner = ((_q = ele.querySelectorAll("style")[0]) === null || _q === void 0 ? void 0 : _q.innerHTML) || "";
1089
+ var patternReg = /{([^}]*)}/g;
1090
+ var patternStyle = styleInner.match(patternReg);
1091
+ var nameReg = /^[^\t].*/gm;
1092
+ var patternName = _.initial(styleInner.match(nameReg));
1093
+ var allStyleList_1 = patternName.length === (patternStyle === null || patternStyle === void 0 ? void 0 : patternStyle.length) && _typeof(patternName) === _typeof(patternStyle) ? _.fromPairs(_.zip(patternName, patternStyle)) : {};
1094
+ var index_1 = getSheetIndex(ctx, ctx.currentSheetId);
1095
+ if (!_.isNil(index_1)) {
1096
+ if (_.isNil(ctx.luckysheetfile[index_1].config)) {
1097
+ ctx.luckysheetfile[index_1].config = {};
1098
+ }
1099
+ if (_.isNil(ctx.luckysheetfile[index_1].config.rowlen)) {
1100
+ ctx.luckysheetfile[index_1].config.rowlen = {};
1101
+ }
1102
+ var rowHeightList_1 = ctx.luckysheetfile[index_1].config.rowlen;
1103
+ _.forEach(trList, function (tr) {
1104
+ var c = 0;
1105
+ var targetR = ctx.luckysheet_select_save[0].row[0] + r_1;
1106
+ var targetRowHeight = !_.isNil(tr.getAttribute("height")) ? parseInt(tr.getAttribute("height"), 10) : null;
1107
+ if (_.has(ctx.luckysheetfile[index_1].config.rowlen, targetR) && ctx.luckysheetfile[index_1].config.rowlen[targetR] !== targetRowHeight || !_.has(ctx.luckysheetfile[index_1].config.rowlen, targetR) && ctx.luckysheetfile[index_1].defaultRowHeight !== targetRowHeight) {
1108
+ rowHeightList_1[targetR] = targetRowHeight;
1109
+ }
1110
+ _.forEach(tr.querySelectorAll("td"), function (td) {
1111
+ var className = td.className;
1112
+ var cell = {};
1113
+ var txt = td.innerText || td.innerHTML;
1114
+ if (_.trim(txt).length === 0) {
1115
+ cell.v = undefined;
1116
+ cell.m = "";
1117
+ } else {
1118
+ var mask = genarate(txt);
1119
+ cell.m = mask[0], cell.ct = mask[1], cell.v = mask[2];
1120
+ }
1121
+ var styleString = typeof allStyleList_1[".".concat(className)] === "string" ? allStyleList_1[".".concat(className)].substring(1, allStyleList_1[".".concat(className)].length - 1).split("\n\t") : [];
1122
+ var styles = {};
1123
+ _.forEach(styleString, function (s) {
1124
+ var styleList = s.split(":");
1125
+ styles[styleList[0]] = styleList === null || styleList === void 0 ? void 0 : styleList[1].replace(";", "");
1126
+ });
1127
+ if (!_.isNil(styles.border)) td.style.border = styles.border;
1128
+ var bg = td.style.backgroundColor || styles.background;
1129
+ if (bg === "rgba(0, 0, 0, 0)" || _.isEmpty(bg)) {
1130
+ bg = undefined;
1131
+ }
1132
+ cell.bg = bg;
1133
+ var fontWight = td.style.fontWeight;
1134
+ cell.bl = (fontWight.toString() === "400" || fontWight === "normal" || _.isEmpty(fontWight)) && !_.includes(styles["font-style"], "bold") && (!styles["font-weight"] || styles["font-weight"] === "400") ? 0 : 1;
1135
+ cell.it = (td.style.fontStyle === "normal" || _.isEmpty(td.style.fontStyle)) && !_.includes(styles["font-style"], "italic") ? 0 : 1;
1136
+ cell.un = !_.includes(styles["text-decoration"], "underline") ? undefined : 1;
1137
+ cell.cl = !_.includes(td.innerHTML, "<s>") ? undefined : 1;
1138
+ var ff = td.style.fontFamily || styles["font-family"] || "";
1139
+ var ffs = ff.split(",");
1140
+ for (var i = 0; i < ffs.length; i += 1) {
1141
+ var fa = _.trim(ffs[i].toLowerCase());
1142
+ fa = locale_fontjson_1[fa];
1143
+ if (_.isNil(fa)) {
1144
+ cell.ff = 0;
1145
+ } else {
1146
+ cell.ff = fa;
1147
+ break;
1148
+ }
1149
+ }
1150
+ var fs = Math.round(styles["font-size"] ? parseInt(styles["font-size"].replace("pt", ""), 10) : parseInt(td.style.fontSize || "13", 10) * 72 / 96);
1151
+ cell.fs = fs;
1152
+ cell.fc = td.style.color || styles.color;
1153
+ var ht = td.style.textAlign || styles["text-align"] || "left";
1154
+ if (ht === "center") {
1155
+ cell.ht = 0;
1156
+ } else if (ht === "right") {
1157
+ cell.ht = 2;
1158
+ } else {
1159
+ cell.ht = 1;
1160
+ }
1161
+ var regex = /vertical-align:\s*(.*?);/;
1162
+ var vt = td.style.verticalAlign || styles["vertical-align"] || !_.isNil(allStyleList_1.td) && allStyleList_1.td.match(regex).length > 0 && allStyleList_1.td.match(regex)[1] || "top";
1163
+ if (vt === "middle") {
1164
+ cell.vt = 0;
1165
+ } else if (vt === "top" || vt === "text-top") {
1166
+ cell.vt = 1;
1167
+ } else {
1168
+ cell.vt = 2;
1169
+ }
1170
+ if ("mso-rotate" in styles) {
1171
+ var rt = styles["mso-rotate"];
1172
+ cell.rt = parseFloat(rt);
1173
+ }
1174
+ while (c < colLen_1 && !_.isNil(data_1[r_1][c])) {
1175
+ c += 1;
1176
+ }
1177
+ if (c === colLen_1) {
1178
+ return true;
1179
+ }
1180
+ if (_.isNil(data_1[r_1][c])) {
1181
+ data_1[r_1][c] = cell;
1182
+ var rowspan = parseInt(td.getAttribute("rowspan"), 10);
1183
+ var colspan = parseInt(td.getAttribute("colspan"), 10);
1184
+ if (Number.isNaN(rowspan)) {
1185
+ rowspan = 1;
1186
+ }
1187
+ if (Number.isNaN(colspan)) {
1188
+ colspan = 1;
1189
+ }
1190
+ var r_ab = ctx.luckysheet_select_save[0].row[0] + r_1;
1191
+ var c_ab = ctx.luckysheet_select_save[0].column[0] + c;
1192
+ for (var rp = 0; rp < rowspan; rp += 1) {
1193
+ for (var cp = 0; cp < colspan; cp += 1) {
1194
+ if (rp === 0) {
1195
+ var bt = td.style.borderTop;
1196
+ if (!_.isEmpty(bt) && bt.substring(0, 3).toLowerCase() !== "0px") {
1197
+ var width = td.style.borderTopWidth;
1198
+ var type = td.style.borderTopStyle;
1199
+ var color = td.style.borderTopColor;
1200
+ var borderconfig = getQKBorder(width, type, color);
1201
+ if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1202
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1203
+ }
1204
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].t = {
1205
+ style: borderconfig[0],
1206
+ color: borderconfig[1]
1207
+ };
1208
+ }
1209
+ }
1210
+ if (rp === rowspan - 1) {
1211
+ var bb = td.style.borderBottom;
1212
+ if (!_.isEmpty(bb) && bb.substring(0, 3).toLowerCase() !== "0px") {
1213
+ var width = td.style.borderBottomWidth;
1214
+ var type = td.style.borderBottomStyle;
1215
+ var color = td.style.borderBottomColor;
1216
+ var borderconfig = getQKBorder(width, type, color);
1217
+ if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1218
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1219
+ }
1220
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].b = {
1221
+ style: borderconfig[0],
1222
+ color: borderconfig[1]
1223
+ };
1224
+ }
1225
+ }
1226
+ if (cp === 0) {
1227
+ var bl = td.style.borderLeft;
1228
+ if (!_.isEmpty(bl) && bl.substring(0, 3).toLowerCase() !== "0px") {
1229
+ var width = td.style.borderLeftWidth;
1230
+ var type = td.style.borderLeftStyle;
1231
+ var color = td.style.borderLeftColor;
1232
+ var borderconfig = getQKBorder(width, type, color);
1233
+ if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1234
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1235
+ }
1236
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].l = {
1237
+ style: borderconfig[0],
1238
+ color: borderconfig[1]
1239
+ };
1240
+ }
1241
+ }
1242
+ if (cp === colspan - 1) {
1243
+ var br = td.style.borderLeft;
1244
+ if (!_.isEmpty(br) && br.substring(0, 3).toLowerCase() !== "0px") {
1245
+ var width = td.style.borderRightWidth;
1246
+ var type = td.style.borderRightStyle;
1247
+ var color = td.style.borderRightColor;
1248
+ var borderconfig = getQKBorder(width, type, color);
1249
+ if (!borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)]) {
1250
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)] = {};
1251
+ }
1252
+ borderInfo_1["".concat(r_1 + rp, "_").concat(c + cp)].r = {
1253
+ style: borderconfig[0],
1254
+ color: borderconfig[1]
1255
+ };
1256
+ }
1257
+ }
1258
+ if (rp === 0 && cp === 0) {
1259
+ continue;
1260
+ }
1261
+ data_1[r_1 + rp][c + cp] = {
1262
+ mc: {
1263
+ r: r_ab,
1264
+ c: c_ab
1265
+ }
1266
+ };
1267
+ }
1268
+ }
1269
+ if (rowspan > 1 || colspan > 1) {
1270
+ var first = {
1271
+ rs: rowspan,
1272
+ cs: colspan,
1273
+ r: r_ab,
1274
+ c: c_ab
1275
+ };
1276
+ data_1[r_1][c].mc = first;
1277
+ }
1278
+ }
1279
+ c += 1;
1280
+ if (c === colLen_1) {
1281
+ return true;
1282
+ }
1283
+ return true;
1284
+ });
1285
+ r_1 += 1;
1286
+ });
1287
+ setRowHeight(ctx, rowHeightList_1);
1288
+ }
1289
+ ctx.luckysheet_selection_range = [];
1290
+ pasteHandler(ctx, data_1, borderInfo_1);
1291
+ ele.remove();
1292
+ } else if (clipboardData.files.length === 1 && clipboardData.files[0].type.indexOf("image") > -1) {} else {
1293
+ txtdata = clipboardData.getData("text/plain");
1294
+ var isExcelFormula = txtdata.startsWith("=");
1295
+ if (isExcelFormula) {
1296
+ handleFormulaStringPaste(ctx, txtdata);
1297
+ } else {
1298
+ pasteHandler(ctx, txtdata);
1299
+ var _txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1300
+ var embedUrl = sanitizeDuneUrl(_txtdata);
1301
+ if (embedUrl) {
1302
+ var last = (_r = ctx.luckysheet_select_save) === null || _r === void 0 ? void 0 : _r[ctx.luckysheet_select_save.length - 1];
1303
+ if (last) {
1304
+ var rowIndex = (_u = (_s = last.row_focus) !== null && _s !== void 0 ? _s : (_t = last.row) === null || _t === void 0 ? void 0 : _t[0]) !== null && _u !== void 0 ? _u : 0;
1305
+ var colIndex = (_x = (_v = last.column_focus) !== null && _v !== void 0 ? _v : (_w = last.column) === null || _w === void 0 ? void 0 : _w[0]) !== null && _x !== void 0 ? _x : 0;
1306
+ var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
1307
+ var top_1 = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex + 5];
1308
+ ctx.showDunePreview = {
1309
+ url: txtdata,
1310
+ position: {
1311
+ left: left,
1312
+ top: top_1
1313
+ }
1314
+ };
1315
+ }
1316
+ }
1317
+ }
1318
+ }
1319
+ }
1320
+ } else if (ctx.luckysheetCellUpdate.length > 0) {
1321
+ e.preventDefault();
1322
+ var clipboardData = e.clipboardData;
1323
+ if (!clipboardData) {
1324
+ clipboardData = window.clipboardData;
1325
+ }
1326
+ var text = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData("text/plain");
1327
+ if (text) {
1328
+ document.execCommand("insertText", false, text);
1329
+ }
1330
+ }
1331
+ }
1332
+ export function handlePasteByClick(ctx, clipboardData, triggerType) {
1333
+ var _a, _b, _c;
1334
+ var allowEdit = isAllowEdit(ctx);
1335
+ if (!allowEdit) return;
1336
+ if (clipboardData) clipboard.writeHtml(clipboardData);
1337
+ var textarea = document.querySelector("#fortune-copy-content");
1338
+ var data = (textarea === null || textarea === void 0 ? void 0 : textarea.innerHTML) || (textarea === null || textarea === void 0 ? void 0 : textarea.textContent);
1339
+ if (!data) return;
1340
+ if (((_b = (_a = ctx.hooks).beforePaste) === null || _b === void 0 ? void 0 : _b.call(_a, ctx.luckysheet_select_save, data)) === false) {
1341
+ return;
1342
+ }
1343
+ if (data.indexOf("fortune-copy-action-table") > -1 && ((_c = ctx.luckysheet_copy_save) === null || _c === void 0 ? void 0 : _c.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0) {
1344
+ if (ctx.luckysheet_paste_iscut) {
1345
+ ctx.luckysheet_paste_iscut = false;
1346
+ pasteHandlerOfCutPaste(ctx, ctx.luckysheet_copy_save);
1347
+ } else {
1348
+ pasteHandlerOfCopyPaste(ctx, ctx.luckysheet_copy_save);
1349
+ }
1350
+ } else if (data.indexOf("fortune-copy-action-image") > -1) {} else if (triggerType !== "btn") {
1351
+ var isExcelFormula = clipboardData.startsWith("=");
1352
+ if (isExcelFormula) {
1353
+ handleFormulaStringPaste(ctx, clipboardData);
1354
+ } else {
1355
+ pasteHandler(ctx, clipboardData);
1356
+ }
1357
+ } else {}
1358
+ }