@fileverse-dev/fortune-core 1.0.26 → 2.0.0

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