@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,970 +0,0 @@
1
- import _ from "lodash";
2
- import { mergeCells } from "./merge";
3
- import { getFlowdata } from "../context";
4
- import { getSheetIndex, isAllowEdit } from "../utils";
5
- import { getRangetxt, isAllSelectedCellsInStatus, normalizedAttr, setCellValue } from "./cell";
6
- import { colors } from "./color";
7
- import { genarate, is_date, update } from "./format";
8
- import { execfunction, execFunctionGroup, israngeseleciton, rangeSetValue, setCaretPosition, createFormulaRangeSelect } from "./formula";
9
- import { inlineStyleAffectAttribute, updateInlineStringFormat, updateInlineStringFormatOutside } from "./inline-string";
10
- import { colLocationByIndex, rowLocationByIndex } from "./location";
11
- import { normalizeSelection, selectionCopyShow, selectIsOverlap } from "./selection";
12
- import { sortSelection } from "./sort";
13
- import { hasPartMC, isdatatypemulti, isRealNull, isRealNum } from "./validation";
14
- import { showLinkCard } from "./hyperlink";
15
- import { cfSplitRange } from "./conditionalFormat";
16
- import { getCellTextInfo } from "./text";
17
- export function updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas) {
18
- var _a, _b;
19
- var _c;
20
- if (_.isNil(d) || _.isNil(attr)) {
21
- return;
22
- }
23
- if (attr === "ct") {
24
- for (var r = row_st; r <= row_ed; r += 1) {
25
- if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
26
- continue;
27
- }
28
- for (var c = col_st; c <= col_ed; c += 1) {
29
- var cell = d[r][c];
30
- var value = void 0;
31
- if (_.isPlainObject(cell)) {
32
- value = cell === null || cell === void 0 ? void 0 : cell.v;
33
- } else {
34
- value = cell;
35
- }
36
- if (foucsStatus !== "@" && isRealNum(value)) {
37
- value = Number(value);
38
- }
39
- var mask = update(foucsStatus, value);
40
- var type = "n";
41
- if (is_date(foucsStatus) || foucsStatus === 14 || foucsStatus === 15 || foucsStatus === 16 || foucsStatus === 17 || foucsStatus === 18 || foucsStatus === 19 || foucsStatus === 20 || foucsStatus === 21 || foucsStatus === 22 || foucsStatus === 45 || foucsStatus === 46 || foucsStatus === 47) {
42
- type = "d";
43
- } else if (foucsStatus === "@" || foucsStatus === 49) {
44
- type = "s";
45
- } else if (foucsStatus === "General" || foucsStatus === 0) {
46
- type = isRealNum(value) ? "n" : "g";
47
- }
48
- if (cell && _.isPlainObject(cell)) {
49
- cell.m = "".concat(mask);
50
- if (_.isNil(cell.ct)) {
51
- cell.ct = {};
52
- }
53
- cell.ct.fa = foucsStatus;
54
- cell.ct.t = type;
55
- } else {
56
- d[r][c] = {
57
- ct: {
58
- fa: foucsStatus,
59
- t: type
60
- },
61
- v: value,
62
- m: mask
63
- };
64
- }
65
- }
66
- }
67
- } else {
68
- if (attr === "ht") {
69
- if (foucsStatus === "left") {
70
- foucsStatus = "1";
71
- } else if (foucsStatus === "center") {
72
- foucsStatus = "0";
73
- } else if (foucsStatus === "right") {
74
- foucsStatus = "2";
75
- }
76
- } else if (attr === "vt") {
77
- if (foucsStatus === "top") {
78
- foucsStatus = "1";
79
- } else if (foucsStatus === "middle") {
80
- foucsStatus = "0";
81
- } else if (foucsStatus === "bottom") {
82
- foucsStatus = "2";
83
- }
84
- } else if (attr === "tb") {
85
- if (foucsStatus === "overflow") {
86
- foucsStatus = "1";
87
- } else if (foucsStatus === "clip") {
88
- foucsStatus = "0";
89
- } else if (foucsStatus === "wrap") {
90
- foucsStatus = "2";
91
- }
92
- } else if (attr === "tr") {
93
- if (foucsStatus === "none") {
94
- foucsStatus = "0";
95
- } else if (foucsStatus === "angleup") {
96
- foucsStatus = "1";
97
- } else if (foucsStatus === "angledown") {
98
- foucsStatus = "2";
99
- } else if (foucsStatus === "vertical") {
100
- foucsStatus = "3";
101
- } else if (foucsStatus === "rotation-up") {
102
- foucsStatus = "4";
103
- } else if (foucsStatus === "rotation-down") {
104
- foucsStatus = "5";
105
- }
106
- }
107
- var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
108
- if (sheetIndex == null) {
109
- return;
110
- }
111
- for (var r = row_st; r <= row_ed; r += 1) {
112
- if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
113
- continue;
114
- }
115
- for (var c = col_st; c <= col_ed; c += 1) {
116
- var value = d[r][c];
117
- if (value && _.isPlainObject(value)) {
118
- updateInlineStringFormatOutside(value, attr, foucsStatus);
119
- value[attr] = foucsStatus;
120
- (_c = ctx.luckysheetfile[sheetIndex]).config || (_c.config = {});
121
- var cfg = ctx.luckysheetfile[sheetIndex].config;
122
- var cellWidth = ((_a = cfg.columnlen) === null || _a === void 0 ? void 0 : _a[c]) || ctx.luckysheetfile[sheetIndex].defaultColWidth;
123
- if (attr === "fs" && canvas) {
124
- var textInfo = getCellTextInfo(d[r][c], canvas, ctx, {
125
- r: r,
126
- c: c,
127
- cellWidth: cellWidth
128
- });
129
- if (!textInfo) continue;
130
- var rowHeight = _.round(textInfo.textHeightAll);
131
- var currentRowHeight = ((_b = cfg.rowlen) === null || _b === void 0 ? void 0 : _b[r]) || ctx.luckysheetfile[sheetIndex].defaultRowHeight || 19;
132
- if (!_.isUndefined(rowHeight) && rowHeight > currentRowHeight && (!cfg.customHeight || cfg.customHeight[r] !== 1)) {
133
- if (_.isUndefined(cfg.rowlen)) cfg.rowlen = {};
134
- _.set(cfg, "rowlen.".concat(r), rowHeight);
135
- }
136
- }
137
- } else {
138
- d[r][c] = {
139
- v: value
140
- };
141
- d[r][c][attr] = foucsStatus;
142
- }
143
- }
144
- }
145
- }
146
- }
147
- export function updateFormat(ctx, $input, d, attr, foucsStatus, canvas) {
148
- var allowEdit = isAllowEdit(ctx);
149
- if (!allowEdit) return;
150
- if (attr in inlineStyleAffectAttribute) {
151
- if (ctx.luckysheetCellUpdate.length > 0) {
152
- var value = $input.innerText;
153
- if (value.substring(0, 1) !== "=") {
154
- var cell = d[ctx.luckysheetCellUpdate[0]][ctx.luckysheetCellUpdate[1]];
155
- if (cell) {
156
- updateInlineStringFormat(ctx, cell, attr, foucsStatus, $input);
157
- }
158
- return;
159
- }
160
- }
161
- }
162
- var cfg = _.cloneDeep(ctx.config);
163
- if (_.isNil(cfg.rowlen)) {
164
- cfg.rowlen = {};
165
- }
166
- _.forEach(ctx.luckysheet_select_save, function (selection) {
167
- var _a = selection.row,
168
- row_st = _a[0],
169
- row_ed = _a[1];
170
- var _b = selection.column,
171
- col_st = _b[0],
172
- col_ed = _b[1];
173
- updateFormatCell(ctx, d, attr, foucsStatus, row_st, row_ed, col_st, col_ed, canvas);
174
- });
175
- }
176
- function toggleAttr(ctx, cellInput, attr) {
177
- var flowdata = getFlowdata(ctx);
178
- if (!flowdata) return;
179
- var flag = isAllSelectedCellsInStatus(ctx, attr, 1);
180
- var foucsStatus = flag ? 0 : 1;
181
- updateFormat(ctx, cellInput, flowdata, attr, foucsStatus);
182
- }
183
- function setAttr(ctx, cellInput, attr, value, canvas) {
184
- var flowdata = getFlowdata(ctx);
185
- if (!flowdata) return;
186
- updateFormat(ctx, cellInput, flowdata, attr, value, canvas);
187
- }
188
- function checkNoNullValue(cell) {
189
- var v = cell;
190
- if (_.isPlainObject(v)) {
191
- v = v.v;
192
- }
193
- if (!isRealNull(v) && isdatatypemulti(v).num && (cell.ct == null || cell.ct.t == null || cell.ct.t === "n" || cell.ct.t === "g")) {
194
- return true;
195
- }
196
- return false;
197
- }
198
- function checkNoNullValueAll(cell) {
199
- var v = cell;
200
- if (_.isPlainObject(v)) {
201
- v = v.v;
202
- }
203
- if (!isRealNull(v)) {
204
- return true;
205
- }
206
- return false;
207
- }
208
- function getNoNullValue(d, st_x, ed, type) {
209
- var hasValueStart = null;
210
- var nullNum = 0;
211
- var nullTime = 0;
212
- for (var r = ed - 1; r >= 0; r -= 1) {
213
- var cell = void 0;
214
- if (type === "c") {
215
- cell = d[st_x][r];
216
- } else {
217
- cell = d[r][st_x];
218
- }
219
- if (checkNoNullValue(cell)) {
220
- hasValueStart = r;
221
- } else if (cell == null || cell.v == null || cell.v === "") {
222
- nullNum += 1;
223
- if (nullNum >= 40) {
224
- if (nullTime <= 0) {
225
- nullTime = 1;
226
- } else {
227
- break;
228
- }
229
- }
230
- } else {
231
- break;
232
- }
233
- }
234
- return hasValueStart;
235
- }
236
- function activeFormulaInput(cellInput, fxInput, ctx, row_index, col_index, rowh, columnh, formula, cache, isnull) {
237
- if (isnull == null) {
238
- isnull = false;
239
- }
240
- ctx.luckysheetCellUpdate = [row_index, col_index];
241
- cache.doNotUpdateCell = true;
242
- if (isnull) {
243
- var formulaTxt_1 = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">".concat(formula.toUpperCase(), "</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">(</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">)</span>");
244
- cellInput.innerHTML = formulaTxt_1;
245
- var spanList = cellInput.querySelectorAll("span");
246
- setCaretPosition(ctx, spanList[spanList.length - 2], 0, 1);
247
- return;
248
- }
249
- var row_pre = rowLocationByIndex(rowh[0], ctx.visibledatarow)[0];
250
- var row = rowLocationByIndex(rowh[1], ctx.visibledatarow)[1];
251
- var col_pre = colLocationByIndex(columnh[0], ctx.visibledatacolumn)[0];
252
- var col = colLocationByIndex(columnh[1], ctx.visibledatacolumn)[1];
253
- var formulaTxt = "<span dir=\"auto\" class=\"luckysheet-formula-text-color\">=</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">".concat(formula.toUpperCase(), "</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">(</span><span class=\"fortune-formula-functionrange-cell\" rangeindex=\"0\" dir=\"auto\" style=\"color:").concat(colors[0], ";\">").concat(getRangetxt(ctx, ctx.currentSheetId, {
254
- row: rowh,
255
- column: columnh
256
- }, ctx.currentSheetId), "</span><span dir=\"auto\" class=\"luckysheet-formula-text-color\">)</span>");
257
- cellInput.innerHTML = formulaTxt;
258
- israngeseleciton(ctx);
259
- ctx.formulaCache.rangestart = true;
260
- ctx.formulaCache.rangedrag_column_start = false;
261
- ctx.formulaCache.rangedrag_row_start = false;
262
- ctx.formulaCache.rangechangeindex = 0;
263
- rangeSetValue(ctx, cellInput, {
264
- row: rowh,
265
- column: columnh
266
- }, fxInput);
267
- ctx.formulaCache.func_selectedrange = {
268
- left: col_pre,
269
- width: col - col_pre - 1,
270
- top: row_pre,
271
- height: row - row_pre - 1,
272
- left_move: col_pre,
273
- width_move: col - col_pre - 1,
274
- top_move: row_pre,
275
- height_move: row - row_pre - 1,
276
- row: [row_index, row_index],
277
- column: [col_index, col_index]
278
- };
279
- createFormulaRangeSelect(ctx, {
280
- rangeIndex: ctx.formulaCache.rangeIndex || 0,
281
- left: col_pre,
282
- width: col - col_pre - 1,
283
- top: row_pre,
284
- height: row - row_pre - 1
285
- });
286
- }
287
- function backFormulaInput(d, r, c, rowh, columnh, formula, ctx) {
288
- var _a;
289
- var f = "=".concat(formula.toUpperCase(), "(").concat(getRangetxt(ctx, ctx.currentSheetId, {
290
- row: rowh,
291
- column: columnh
292
- }, ctx.currentSheetId), ")");
293
- var v = execfunction(ctx, f, r, c);
294
- var value = {
295
- v: v[1],
296
- f: v[2]
297
- };
298
- setCellValue(ctx, r, c, d, value);
299
- (_a = ctx.formulaCache).execFunctionExist || (_a.execFunctionExist = []);
300
- ctx.formulaCache.execFunctionExist.push({
301
- r: r,
302
- c: c,
303
- i: ctx.currentSheetId
304
- });
305
- }
306
- function singleFormulaInput(cellInput, fxInput, ctx, d, _index, fix, st_m, ed_m, formula, type, cache, noNum, noNull) {
307
- if (type == null) {
308
- type = "r";
309
- }
310
- if (noNum == null) {
311
- noNum = true;
312
- }
313
- if (noNull == null) {
314
- noNull = true;
315
- }
316
- var isNull = true;
317
- var isNum = false;
318
- for (var c = st_m; c <= ed_m; c += 1) {
319
- var cell = null;
320
- if (type === "c") {
321
- cell = d[c][fix];
322
- } else {
323
- cell = d[fix][c];
324
- }
325
- if (checkNoNullValue(cell)) {
326
- isNull = false;
327
- isNum = true;
328
- } else if (checkNoNullValueAll(cell)) {
329
- isNull = false;
330
- }
331
- }
332
- if (isNull && noNull) {
333
- var st_r_r = getNoNullValue(d, _index, fix, type);
334
- if (st_r_r == null) {
335
- if (type === "c") {
336
- activeFormulaInput(cellInput, fxInput, ctx, _index, fix, null, null, formula, cache, true);
337
- } else {
338
- activeFormulaInput(cellInput, fxInput, ctx, fix, _index, null, null, formula, cache, true);
339
- }
340
- } else {
341
- if (_index === st_m) {
342
- for (var c = st_m; c <= ed_m; c += 1) {
343
- st_r_r = getNoNullValue(d, c, fix, type);
344
- if (st_r_r == null) {
345
- break;
346
- }
347
- if (type === "c") {
348
- backFormulaInput(d, c, fix, [c, c], [st_r_r, fix - 1], formula, ctx);
349
- } else {
350
- backFormulaInput(d, fix, c, [st_r_r, fix - 1], [c, c], formula, ctx);
351
- }
352
- }
353
- } else {
354
- for (var c = ed_m; c >= st_m; c -= 1) {
355
- st_r_r = getNoNullValue(d, c, fix, type);
356
- if (st_r_r == null) {
357
- break;
358
- }
359
- if (type === "c") {
360
- backFormulaInput(d, c, fix, [c, c], [st_r_r, fix - 1], formula, ctx);
361
- } else {
362
- backFormulaInput(d, fix, c, [st_r_r, fix - 1], [c, c], formula, ctx);
363
- }
364
- }
365
- }
366
- }
367
- return false;
368
- }
369
- if (isNum && noNum) {
370
- var cell = null;
371
- if (type === "c") {
372
- cell = d[ed_m + 1][fix];
373
- } else {
374
- cell = d[fix][ed_m + 1];
375
- }
376
- if (cell != null && cell.v != null && cell.v.toString().length > 0) {
377
- var c = ed_m + 1;
378
- if (type === "c") {
379
- cell = d[ed_m + 1][fix];
380
- } else {
381
- cell = d[fix][ed_m + 1];
382
- }
383
- while (cell != null && cell.v != null && cell.v.toString().length > 0) {
384
- c += 1;
385
- var len = null;
386
- if (type === "c") {
387
- len = d.length;
388
- } else {
389
- len = d[0].length;
390
- }
391
- if (c >= len) {
392
- return false;
393
- }
394
- if (type === "c") {
395
- cell = d[c][fix];
396
- } else {
397
- cell = d[fix][c];
398
- }
399
- }
400
- if (type === "c") {
401
- backFormulaInput(d, c, fix, [st_m, ed_m], [fix, fix], formula, ctx);
402
- } else {
403
- backFormulaInput(d, fix, c, [fix, fix], [st_m, ed_m], formula, ctx);
404
- }
405
- } else {
406
- if (type === "c") {
407
- backFormulaInput(d, ed_m + 1, fix, [st_m, ed_m], [fix, fix], formula, ctx);
408
- } else {
409
- backFormulaInput(d, fix, ed_m + 1, [fix, fix], [st_m, ed_m], formula, ctx);
410
- }
411
- }
412
- return false;
413
- }
414
- return true;
415
- }
416
- export function autoSelectionFormula(ctx, cellInput, fxInput, formula, cache) {
417
- var allowEdit = isAllowEdit(ctx);
418
- if (!allowEdit) return;
419
- var flowdata = getFlowdata(ctx);
420
- if (flowdata == null) return;
421
- var isfalse = true;
422
- ctx.formulaCache.execFunctionExist = [];
423
- function execFormulaInput_c(d, st_r, ed_r, st_c, ed_c, _formula) {
424
- var st_c_c = getNoNullValue(d, st_r, ed_c, "c");
425
- if (st_c_c == null) {
426
- activeFormulaInput(cellInput, fxInput, ctx, st_r, st_c, null, null, _formula, cache, true);
427
- } else {
428
- activeFormulaInput(cellInput, fxInput, ctx, st_r, st_c, [st_r, ed_r], [st_c_c, ed_c - 1], _formula, cache);
429
- }
430
- }
431
- function execFormulaInput(d, st_r, ed_r, st_c, ed_c, _formula) {
432
- var st_r_c = getNoNullValue(d, st_c, ed_r, "r");
433
- if (st_r_c == null) {
434
- execFormulaInput_c(d, st_r, ed_r, st_c, ed_c, _formula);
435
- } else {
436
- activeFormulaInput(cellInput, fxInput, ctx, st_r, st_c, [st_r_c, ed_r - 1], [st_c, ed_c], _formula, cache);
437
- }
438
- }
439
- if (!ctx.luckysheet_select_save) return;
440
- _.forEach(ctx.luckysheet_select_save, function (selection) {
441
- var _a = selection.row,
442
- st_r = _a[0],
443
- ed_r = _a[1];
444
- var _b = selection.column,
445
- st_c = _b[0],
446
- ed_c = _b[1];
447
- var row_index = selection.row_focus;
448
- var col_index = selection.column_focus;
449
- if (st_r === ed_r && st_c === ed_c) {
450
- if (ed_r - 1 < 0 && ed_c - 1 < 0) {
451
- activeFormulaInput(cellInput, fxInput, ctx, st_r, st_c, null, null, formula, cache, true);
452
- return;
453
- }
454
- if (ed_r - 1 >= 0 && checkNoNullValue(flowdata[ed_r - 1][st_c])) {
455
- execFormulaInput(flowdata, st_r, ed_r, st_c, ed_c, formula);
456
- } else if (ed_c - 1 >= 0 && checkNoNullValue(flowdata[st_r][ed_c - 1])) {
457
- execFormulaInput_c(flowdata, st_r, ed_r, st_c, ed_c, formula);
458
- } else {
459
- execFormulaInput(flowdata, st_r, ed_r, st_c, ed_c, formula);
460
- }
461
- } else if (st_r === ed_r) {
462
- isfalse = singleFormulaInput(cellInput, fxInput, ctx, flowdata, col_index, st_r, st_c, ed_c, formula, "r", cache);
463
- } else if (st_c === ed_c) {
464
- isfalse = singleFormulaInput(cellInput, fxInput, ctx, flowdata, row_index, st_c, st_r, ed_r, formula, "c", cache);
465
- } else {
466
- var r_false = true;
467
- for (var r = st_r; r <= ed_r; r += 1) {
468
- r_false = singleFormulaInput(cellInput, fxInput, ctx, flowdata, col_index, r, st_c, ed_c, formula, "r", cache, true, false) && r_false;
469
- }
470
- var c_false = true;
471
- for (var c = st_c; c <= ed_c; c += 1) {
472
- c_false = singleFormulaInput(cellInput, fxInput, ctx, flowdata, row_index, c, st_r, ed_r, formula, "c", cache, true, false) && c_false;
473
- }
474
- isfalse = !!r_false && !!c_false;
475
- }
476
- isfalse = isfalse && isfalse;
477
- });
478
- if (!isfalse) {
479
- ctx.formulaCache.execFunctionExist.reverse();
480
- execFunctionGroup(ctx, null, null, null, null, flowdata);
481
- ctx.formulaCache.execFunctionGlobalData = null;
482
- }
483
- }
484
- export function cancelPaintModel(ctx) {
485
- var _a;
486
- if (ctx.luckysheet_copy_save === null) return;
487
- if (((_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.dataSheetId) === ctx.currentSheetId) {
488
- ctx.luckysheet_selection_range = [];
489
- selectionCopyShow(ctx.luckysheet_selection_range, ctx);
490
- } else {
491
- if (!ctx.luckysheet_copy_save) return;
492
- var index = getSheetIndex(ctx, ctx.luckysheet_copy_save.dataSheetId);
493
- if (!index) return;
494
- ctx.luckysheetfile[index].luckysheet_selection_range = [];
495
- }
496
- ctx.luckysheet_copy_save = {
497
- dataSheetId: "",
498
- copyRange: [{
499
- row: [0],
500
- column: [0]
501
- }],
502
- RowlChange: false,
503
- HasMC: false
504
- };
505
- ctx.luckysheetPaintModelOn = false;
506
- }
507
- export function handleCurrencyFormat(ctx, cellInput) {
508
- var flowdata = getFlowdata(ctx);
509
- if (!flowdata) return;
510
- var currency = ctx.currency || "¥";
511
- updateFormat(ctx, cellInput, flowdata, "ct", "".concat(currency, " #,##0.00"));
512
- }
513
- export function handlePercentageFormat(ctx, cellInput) {
514
- var flowdata = getFlowdata(ctx);
515
- if (!flowdata) return;
516
- updateFormat(ctx, cellInput, flowdata, "ct", "0.00%");
517
- }
518
- export function handleNumberDecrease(ctx, cellInput) {
519
- var flowdata = getFlowdata(ctx);
520
- if (!flowdata || !ctx.luckysheet_select_save) return;
521
- var row_index = ctx.luckysheet_select_save[0].row_focus;
522
- var col_index = ctx.luckysheet_select_save[0].column_focus;
523
- if (row_index === undefined || col_index === undefined) return;
524
- var foucsStatus = normalizedAttr(flowdata, row_index, col_index, "ct");
525
- var cell = flowdata[row_index][col_index];
526
- if (foucsStatus == null || foucsStatus.t !== "n") {
527
- return;
528
- }
529
- if (foucsStatus.fa === "General") {
530
- if (!cell || !cell.v) return;
531
- var mask = genarate(cell.v);
532
- if (!mask || mask.length < 2) return;
533
- foucsStatus = mask[1];
534
- }
535
- var reg = /^(w|W)((0?)|(0\.0+))$/;
536
- if (reg.test(foucsStatus.fa)) {
537
- if (foucsStatus.fa.indexOf(".") > -1) {
538
- if (foucsStatus.fa.substr(-2) === ".0") {
539
- updateFormat(ctx, cellInput, flowdata, "ct", foucsStatus.fa.split(".")[0]);
540
- } else {
541
- updateFormat(ctx, cellInput, flowdata, "ct", foucsStatus.fa.substr(0, foucsStatus.fa.length - 1));
542
- }
543
- } else {
544
- updateFormat(ctx, cellInput, flowdata, "ct", foucsStatus.fa);
545
- }
546
- return;
547
- }
548
- var prefix = "";
549
- var main = "";
550
- var fa = [];
551
- if (foucsStatus.fa.indexOf(".") > -1) {
552
- fa = foucsStatus.fa.split(".");
553
- prefix = fa[0], main = fa[1];
554
- } else {
555
- return;
556
- }
557
- fa = main.split("");
558
- var tail = "";
559
- for (var i = fa.length - 1; i >= 0; i -= 1) {
560
- var c = fa[i];
561
- if (c !== "#" && c !== "0" && c !== "," && Number.isNaN(parseInt(c, 10))) {
562
- tail = c + tail;
563
- } else {
564
- break;
565
- }
566
- }
567
- var fmt = "";
568
- if (foucsStatus.fa.indexOf(".") > -1) {
569
- var suffix = main;
570
- if (tail.length > 0) {
571
- suffix = main.replace(tail, "");
572
- }
573
- var pos = suffix.replace(/#/g, "0");
574
- pos = pos.substr(0, pos.length - 1);
575
- if (pos === "") {
576
- fmt = prefix + tail;
577
- } else {
578
- fmt = "".concat(prefix, ".").concat(pos).concat(tail);
579
- }
580
- }
581
- updateFormat(ctx, cellInput, flowdata, "ct", fmt);
582
- }
583
- export function handleNumberIncrease(ctx, cellInput) {
584
- var flowdata = getFlowdata(ctx);
585
- if (!flowdata) return;
586
- if (!ctx.luckysheet_select_save) return;
587
- var row_index = ctx.luckysheet_select_save[0].row_focus;
588
- var col_index = ctx.luckysheet_select_save[0].column_focus;
589
- if (row_index === undefined || col_index === undefined) return;
590
- var foucsStatus = normalizedAttr(flowdata, row_index, col_index, "ct");
591
- var cell = flowdata[row_index][col_index];
592
- if (foucsStatus == null || foucsStatus.t !== "n") {
593
- return;
594
- }
595
- if (foucsStatus.fa === "General") {
596
- if (!cell || !cell.v) return;
597
- var mask = genarate(cell.v);
598
- if (!mask || mask.length < 2) return;
599
- foucsStatus = mask[1];
600
- }
601
- if (foucsStatus.fa === "General") {
602
- updateFormat(ctx, cellInput, flowdata, "ct", "#.0");
603
- return;
604
- }
605
- var reg = /^(w|W)((0?)|(0\.0+))$/;
606
- if (reg.test(foucsStatus.fa)) {
607
- if (foucsStatus.fa.indexOf(".") > -1) {
608
- updateFormat(ctx, cellInput, flowdata, "ct", "".concat(foucsStatus.fa, "0"));
609
- } else {
610
- if (foucsStatus.fa.substr(-1) === "0") {
611
- updateFormat(ctx, cellInput, flowdata, "ct", "".concat(foucsStatus.fa, ".0"));
612
- } else {
613
- updateFormat(ctx, cellInput, flowdata, "ct", "".concat(foucsStatus.fa, "0.0"));
614
- }
615
- }
616
- return;
617
- }
618
- var prefix = "";
619
- var main = "";
620
- var fa = [];
621
- if (foucsStatus.fa.indexOf(".") > -1) {
622
- fa = foucsStatus.fa.split(".");
623
- prefix = fa[0], main = fa[1];
624
- } else {
625
- main = foucsStatus.fa;
626
- }
627
- fa = main.split("");
628
- var tail = "";
629
- for (var i = fa.length - 1; i >= 0; i -= 1) {
630
- var c = fa[i];
631
- if (c !== "#" && c !== "0" && c !== "," && Number.isNaN(parseInt(c, 10))) {
632
- tail = c + tail;
633
- } else {
634
- break;
635
- }
636
- }
637
- var fmt = "";
638
- if (foucsStatus.fa.indexOf(".") > -1) {
639
- var suffix = main;
640
- if (tail.length > 0) {
641
- suffix = main.replace(tail, "");
642
- }
643
- var pos = suffix.replace(/#/g, "0");
644
- pos += "0";
645
- fmt = "".concat(prefix, ".").concat(pos).concat(tail);
646
- } else {
647
- if (tail.length > 0) {
648
- fmt = "".concat(main.replace(tail, ""), ".0").concat(tail);
649
- } else {
650
- fmt = "".concat(main, ".0").concat(tail);
651
- }
652
- }
653
- updateFormat(ctx, cellInput, flowdata, "ct", fmt);
654
- }
655
- export function handleBold(ctx, cellInput) {
656
- toggleAttr(ctx, cellInput, "bl");
657
- }
658
- export function handleItalic(ctx, cellInput) {
659
- toggleAttr(ctx, cellInput, "it");
660
- }
661
- export function handleStrikeThrough(ctx, cellInput) {
662
- toggleAttr(ctx, cellInput, "cl");
663
- }
664
- export function handleUnderline(ctx, cellInput) {
665
- toggleAttr(ctx, cellInput, "un");
666
- }
667
- export function handleHorizontalAlign(ctx, cellInput, value) {
668
- setAttr(ctx, cellInput, "ht", value);
669
- }
670
- export function handleVerticalAlign(ctx, cellInput, value) {
671
- setAttr(ctx, cellInput, "vt", value);
672
- }
673
- export function handleFormatPainter(ctx) {
674
- var allowEdit = isAllowEdit(ctx);
675
- if (!allowEdit) return;
676
- if (ctx.luckysheet_select_save == null || ctx.luckysheet_select_save.length === 0) {
677
- return;
678
- }
679
- if (ctx.luckysheet_select_save.length > 1) {
680
- return;
681
- }
682
- var has_PartMC = false;
683
- var r1 = ctx.luckysheet_select_save[0].row[0];
684
- var r2 = ctx.luckysheet_select_save[0].row[1];
685
- var c1 = ctx.luckysheet_select_save[0].column[0];
686
- var c2 = ctx.luckysheet_select_save[0].column[1];
687
- has_PartMC = hasPartMC(ctx, ctx.config, r1, r2, c1, c2);
688
- if (has_PartMC) {
689
- return;
690
- }
691
- cancelPaintModel(ctx);
692
- ctx.luckysheet_selection_range = [{
693
- row: ctx.luckysheet_select_save[0].row,
694
- column: ctx.luckysheet_select_save[0].column
695
- }];
696
- selectionCopyShow(ctx.luckysheet_selection_range, ctx);
697
- var RowlChange = false;
698
- var HasMC = false;
699
- for (var r = ctx.luckysheet_select_save[0].row[0]; r <= ctx.luckysheet_select_save[0].row[1]; r += 1) {
700
- if (ctx.config.rowhidden != null && ctx.config.rowhidden[r] != null) {
701
- continue;
702
- }
703
- if (ctx.config.rowlen != null && r in ctx.config.rowlen) {
704
- RowlChange = true;
705
- }
706
- for (var c = ctx.luckysheet_select_save[0].column[0]; c <= ctx.luckysheet_select_save[0].column[1]; c += 1) {
707
- var flowdata = getFlowdata(ctx);
708
- if (!flowdata) return;
709
- var cell = flowdata[r][c];
710
- if (cell != null && cell.mc != null && cell.mc.rs != null) {
711
- HasMC = true;
712
- }
713
- }
714
- }
715
- ctx.luckysheet_copy_save = {
716
- dataSheetId: ctx.currentSheetId,
717
- copyRange: [{
718
- row: ctx.luckysheet_select_save[0].row,
719
- column: ctx.luckysheet_select_save[0].column
720
- }],
721
- RowlChange: RowlChange,
722
- HasMC: HasMC
723
- };
724
- ctx.luckysheetPaintModelOn = true;
725
- ctx.luckysheetPaintSingle = true;
726
- }
727
- export function handleClearFormat(ctx) {
728
- var _a;
729
- if (ctx.allowEdit === false) return;
730
- var flowdata = getFlowdata(ctx);
731
- if (!flowdata) return;
732
- (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a.every(function (selection) {
733
- var _a = selection.row,
734
- rowSt = _a[0],
735
- rowEd = _a[1];
736
- var _b = selection.column,
737
- colSt = _b[0],
738
- colEd = _b[1];
739
- for (var r = rowSt; r <= rowEd; r += 1) {
740
- if (!_.isNil(ctx.config.rowhidden) && !_.isNil(ctx.config.rowhidden[r])) {
741
- continue;
742
- }
743
- for (var c = colSt; c <= colEd; c += 1) {
744
- var cell = flowdata[r][c];
745
- if (!cell) continue;
746
- flowdata[r][c] = _.pick(cell, "v", "m", "mc", "f", "ct");
747
- }
748
- }
749
- var index = getSheetIndex(ctx, ctx.currentSheetId);
750
- if (index == null) return false;
751
- if (ctx.config.borderInfo == null) return false;
752
- var cfg = ctx.config || {};
753
- if (cfg.borderInfo && cfg.borderInfo.length > 0) {
754
- var source_borderInfo = [];
755
- for (var i = 0; i < cfg.borderInfo.length; i += 1) {
756
- var bd_rangeType = cfg.borderInfo[i].rangeType;
757
- if (bd_rangeType === "range" && cfg.borderInfo[i].borderType !== "border-slash") {
758
- var bd_range = cfg.borderInfo[i].range;
759
- var bd_emptyRange = [];
760
- for (var j = 0; j < bd_range.length; j += 1) {
761
- bd_emptyRange = bd_emptyRange.concat(cfSplitRange(bd_range[j], {
762
- row: [rowSt, rowEd],
763
- column: [colSt, colEd]
764
- }, {
765
- row: [rowSt, rowEd],
766
- column: [colSt, colEd]
767
- }, "restPart"));
768
- }
769
- cfg.borderInfo[i].range = bd_emptyRange;
770
- source_borderInfo.push(cfg.borderInfo[i]);
771
- } else if (bd_rangeType === "cell") {
772
- var bd_r = cfg.borderInfo[i].value.row_index;
773
- var bd_c = cfg.borderInfo[i].value.col_index;
774
- if (!(bd_r >= rowSt && bd_r <= rowEd && bd_c >= colSt && bd_c <= colEd)) {
775
- source_borderInfo.push(cfg.borderInfo[i]);
776
- }
777
- } else if (bd_rangeType === "range" && cfg.borderInfo[i].borderType === "border-slash" && !(cfg.borderInfo[i].range[0].row[0] >= rowSt && cfg.borderInfo[i].range[0].row[0] <= rowEd && cfg.borderInfo[i].range[0].column[0] >= colSt && cfg.borderInfo[i].range[0].column[0] <= colEd)) {
778
- source_borderInfo.push(cfg.borderInfo[i]);
779
- }
780
- }
781
- ctx.luckysheetfile[index].config.borderInfo = source_borderInfo;
782
- }
783
- return true;
784
- });
785
- }
786
- export function handleTextColor(ctx, cellInput, color) {
787
- setAttr(ctx, cellInput, "fc", color);
788
- }
789
- export function handleTextBackground(ctx, cellInput, color) {
790
- setAttr(ctx, cellInput, "bg", color);
791
- }
792
- export function handleBorder(ctx, type, borderColor, borderStyle) {
793
- var allowEdit = isAllowEdit(ctx);
794
- if (!allowEdit) return;
795
- if (type == null) {
796
- type = "border-all";
797
- }
798
- var color = borderColor;
799
- var style = borderStyle;
800
- if (color == null || color === "") {
801
- color = "#000";
802
- }
803
- if (style == null || style === "") {
804
- style = "1";
805
- }
806
- var cfg = ctx.config;
807
- if (cfg.borderInfo == null) {
808
- cfg.borderInfo = [];
809
- }
810
- if (type !== "border-slash") {
811
- var borderInfo = {
812
- rangeType: "range",
813
- borderType: type,
814
- color: color,
815
- style: style,
816
- range: _.cloneDeep(ctx.luckysheet_select_save) || []
817
- };
818
- cfg.borderInfo.push(borderInfo);
819
- } else {
820
- var rangeList_1 = [];
821
- _.forEach(ctx.luckysheet_select_save, function (selection) {
822
- for (var r = selection.row[0]; r <= selection.row[1]; r += 1) {
823
- for (var c = selection.column[0]; c <= selection.column[1]; c += 1) {
824
- var range = "".concat(r, "_").concat(c);
825
- if (_.includes(rangeList_1, range)) continue;
826
- var borderInfo = {
827
- rangeType: "range",
828
- borderType: type,
829
- color: color,
830
- style: style,
831
- range: normalizeSelection(ctx, [{
832
- row: [r, r],
833
- column: [c, c]
834
- }])
835
- };
836
- cfg.borderInfo.push(borderInfo);
837
- rangeList_1.push(range);
838
- }
839
- }
840
- });
841
- }
842
- var index = getSheetIndex(ctx, ctx.currentSheetId);
843
- if (index == null) return;
844
- ctx.luckysheetfile[index].config = ctx.config;
845
- }
846
- export function handleMerge(ctx, type) {
847
- var allowEdit = isAllowEdit(ctx);
848
- if (!allowEdit) return;
849
- if (selectIsOverlap(ctx)) {
850
- return;
851
- }
852
- if (ctx.config.merge != null) {
853
- var has_PartMC = false;
854
- if (!ctx.luckysheet_select_save) return;
855
- for (var s = 0; s < ctx.luckysheet_select_save.length; s += 1) {
856
- var r1 = ctx.luckysheet_select_save[s].row[0];
857
- var r2 = ctx.luckysheet_select_save[s].row[1];
858
- var c1 = ctx.luckysheet_select_save[s].column[0];
859
- var c2 = ctx.luckysheet_select_save[s].column[1];
860
- has_PartMC = hasPartMC(ctx, ctx.config, r1, r2, c1, c2);
861
- if (has_PartMC) {
862
- break;
863
- }
864
- }
865
- if (has_PartMC) {
866
- return;
867
- }
868
- }
869
- var flowdata = getFlowdata(ctx);
870
- if (!flowdata) return;
871
- if (!ctx.luckysheet_select_save) return;
872
- mergeCells(ctx, ctx.currentSheetId, ctx.luckysheet_select_save, type);
873
- }
874
- export function handleSort(ctx, isAsc) {
875
- sortSelection(ctx, isAsc);
876
- }
877
- export function handleFreeze(ctx, type) {
878
- var _a, _b;
879
- var allowEdit = isAllowEdit(ctx);
880
- if (!allowEdit) return;
881
- var file = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)];
882
- if (!file) return;
883
- if (type === "freeze-cancel") {
884
- delete file.frozen;
885
- return;
886
- }
887
- var firstSelection = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
888
- if (!firstSelection) return;
889
- var row_focus = firstSelection.row_focus,
890
- column_focus = firstSelection.column_focus;
891
- if (row_focus == null || column_focus == null) return;
892
- var m = (_b = ctx.config.merge) === null || _b === void 0 ? void 0 : _b["".concat(row_focus, "_").concat(column_focus)];
893
- if (m) {
894
- row_focus = m.r + m.rs - 1;
895
- column_focus = m.c + m.cs - 1;
896
- }
897
- file.frozen = {
898
- type: "both",
899
- range: {
900
- row_focus: row_focus,
901
- column_focus: column_focus
902
- }
903
- };
904
- if (type === "freeze-row") {
905
- file.frozen.type = "rangeRow";
906
- } else if (type === "freeze-col") {
907
- file.frozen.type = "rangeColumn";
908
- }
909
- }
910
- export function handleTextSize(ctx, cellInput, size, canvas) {
911
- setAttr(ctx, cellInput, "fs", size, canvas);
912
- }
913
- export function handleSum(ctx, cellInput, fxInput, cache) {
914
- autoSelectionFormula(ctx, cellInput, fxInput, "SUM", cache);
915
- }
916
- export function handleLink(ctx) {
917
- var _a;
918
- var allowEdit = isAllowEdit(ctx);
919
- if (!allowEdit) return;
920
- var selection = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[0];
921
- var flowdata = getFlowdata(ctx);
922
- if (flowdata != null && selection != null) {
923
- showLinkCard(ctx, selection.row[0], selection.column[0], true);
924
- }
925
- }
926
- var handlerMap = {
927
- "currency-format": handleCurrencyFormat,
928
- "percentage-format": handlePercentageFormat,
929
- "number-decrease": handleNumberDecrease,
930
- "number-increase": handleNumberIncrease,
931
- "sort-cell": function sortCell(ctx) {
932
- return handleSort(ctx, true);
933
- },
934
- "merge-all": function mergeAll(ctx) {
935
- return handleMerge(ctx, "mergeAll");
936
- },
937
- "border-all": function borderAll(ctx) {
938
- return handleBorder(ctx, "border-all");
939
- },
940
- bold: handleBold,
941
- italic: handleItalic,
942
- "strike-through": handleStrikeThrough,
943
- underline: handleUnderline,
944
- "clear-format": handleClearFormat,
945
- "format-painter": handleFormatPainter,
946
- search: function search(ctx) {
947
- ctx.showSearch = true;
948
- },
949
- link: handleLink
950
- };
951
- var selectedMap = {
952
- bold: function bold(cell) {
953
- return (cell === null || cell === void 0 ? void 0 : cell.bl) === 1;
954
- },
955
- italic: function italic(cell) {
956
- return (cell === null || cell === void 0 ? void 0 : cell.it) === 1;
957
- },
958
- "strike-through": function strikeThrough(cell) {
959
- return (cell === null || cell === void 0 ? void 0 : cell.cl) === 1;
960
- },
961
- underline: function underline(cell) {
962
- return (cell === null || cell === void 0 ? void 0 : cell.un) === 1;
963
- }
964
- };
965
- export function toolbarItemClickHandler(name) {
966
- return handlerMap[name];
967
- }
968
- export function toolbarItemSelectedFunc(name) {
969
- return selectedMap[name];
970
- }