@fileverse-dev/fortune-core 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (346) hide show
  1. package/{dist/packages/core/src → es}/api/cell.d.ts +10 -10
  2. package/es/api/cell.js +204 -0
  3. package/{dist/packages/core/src → es}/api/common.d.ts +66 -66
  4. package/es/api/common.js +79 -0
  5. package/{dist/packages/core/src → es}/api/errors.d.ts +2 -2
  6. package/es/api/errors.js +2 -0
  7. package/{dist/packages/core/src → es}/api/index.d.ts +9 -9
  8. package/es/api/index.js +8 -0
  9. package/{dist/packages/core/src → es}/api/merge.d.ts +5 -5
  10. package/es/api/merge.js +15 -0
  11. package/{dist/packages/core/src → es}/api/range.d.ts +22 -22
  12. package/es/api/range.js +123 -0
  13. package/{dist/packages/core/src → es}/api/rowcol.d.ts +14 -14
  14. package/es/api/rowcol.js +207 -0
  15. package/{dist/packages/core/src → es}/api/sheet.d.ts +10 -10
  16. package/es/api/sheet.js +128 -0
  17. package/{dist/packages/core/src → es}/api/workbook.d.ts +15 -15
  18. package/es/api/workbook.js +85 -0
  19. package/{dist/packages/core/src → es}/canvas.d.ts +46 -46
  20. package/es/canvas.js +1350 -0
  21. package/{dist/packages/core/src → es}/context.d.ts +197 -197
  22. package/es/context.js +380 -0
  23. package/{dist/packages/core/src → es}/events/copy.d.ts +2 -2
  24. package/es/events/copy.js +78 -0
  25. package/{dist/packages/core/src → es}/events/index.d.ts +4 -4
  26. package/es/events/index.js +4 -0
  27. package/{dist/packages/core/src → es}/events/keyboard.d.ts +6 -6
  28. package/es/events/keyboard.js +332 -0
  29. package/{dist/packages/core/src → es}/events/mouse.d.ts +22 -22
  30. package/es/events/mouse.js +1725 -0
  31. package/{dist/packages/core/src → es}/events/paste.d.ts +3 -3
  32. package/es/events/paste.js +1358 -0
  33. package/{dist/packages/core/src → es}/index.d.ts +10 -10
  34. package/es/index.js +10 -0
  35. package/{dist/packages/core/src → es}/locale/en.d.ts +992 -992
  36. package/es/locale/en.js +10564 -0
  37. package/{dist/packages/core/src → es}/locale/es.d.ts +1134 -1134
  38. package/es/locale/es.js +10010 -0
  39. package/{dist/packages/core/src → es}/locale/hi.d.ts +1030 -1030
  40. package/es/locale/hi.js +10550 -0
  41. package/{dist/packages/core/src → es}/locale/index.d.ts +1049 -1049
  42. package/es/locale/index.js +23 -0
  43. package/{dist/packages/core/src → es}/locale/zh.d.ts +1048 -1048
  44. package/es/locale/zh.js +10568 -0
  45. package/{dist/packages/core/src → es}/locale/zh_tw.d.ts +1187 -1187
  46. package/es/locale/zh_tw.js +10072 -0
  47. package/{dist/packages/core/src → es}/modules/ConditionFormat.d.ts +17 -17
  48. package/es/modules/ConditionFormat.js +1258 -0
  49. package/{dist/packages/core/src → es}/modules/border.d.ts +3 -3
  50. package/es/modules/border.js +1240 -0
  51. package/{dist/packages/core/src → es}/modules/cell.d.ts +32 -32
  52. package/es/modules/cell.js +1055 -0
  53. package/{dist/packages/core/src → es}/modules/clipboard.d.ts +3 -3
  54. package/es/modules/clipboard.js +36 -0
  55. package/{dist/packages/core/src → es}/modules/color.d.ts +1 -1
  56. package/es/modules/color.js +1 -0
  57. package/{dist/packages/core/src → es}/modules/comment.d.ts +97 -97
  58. package/es/modules/comment.js +597 -0
  59. package/{dist/packages/core/src → es}/modules/conditionalFormat.d.ts +2 -2
  60. package/es/modules/conditionalFormat.js +441 -0
  61. package/{dist/packages/core/src → es}/modules/cursor.d.ts +3 -3
  62. package/es/modules/cursor.js +62 -0
  63. package/{dist/packages/core/src → es}/modules/dataVerification.d.ts +11 -11
  64. package/es/modules/dataVerification.js +700 -0
  65. package/{dist/packages/core/src → es}/modules/dropCell.d.ts +10 -10
  66. package/es/modules/dropCell.js +2266 -0
  67. package/{dist/packages/core/src → es}/modules/filter.d.ts +45 -45
  68. package/es/modules/filter.js +434 -0
  69. package/{dist/packages/core/src → es}/modules/format.d.ts +6 -6
  70. package/es/modules/format.js +323 -0
  71. package/{dist/packages/core/src → es}/modules/formula.d.ts +54 -54
  72. package/es/modules/formula.js +2301 -0
  73. package/{dist/packages/core/src → es}/modules/freeze.d.ts +5 -5
  74. package/es/modules/freeze.js +148 -0
  75. package/{dist/packages/core/src → es}/modules/hyperlink.d.ts +21 -21
  76. package/es/modules/hyperlink.js +216 -0
  77. package/{dist/packages/core/src → es}/modules/iframe.d.ts +12 -12
  78. package/es/modules/iframe.js +220 -0
  79. package/{dist/packages/core/src → es}/modules/image.d.ts +31 -31
  80. package/es/modules/image.js +253 -0
  81. package/{dist/packages/core/src → es}/modules/index.d.ts +36 -36
  82. package/es/modules/index.js +36 -0
  83. package/{dist/packages/core/src → es}/modules/inline-string.d.ts +36 -36
  84. package/es/modules/inline-string.js +437 -0
  85. package/{dist/packages/core/src → es}/modules/location.d.ts +6 -6
  86. package/es/modules/location.js +46 -0
  87. package/{dist/packages/core/src → es}/modules/locationCondition.d.ts +21 -21
  88. package/es/modules/locationCondition.js +218 -0
  89. package/{dist/packages/core/src → es}/modules/merge.d.ts +3 -3
  90. package/es/modules/merge.js +216 -0
  91. package/{dist/packages/core/src → es}/modules/mobile.d.ts +5 -5
  92. package/es/modules/mobile.js +33 -0
  93. package/{dist/packages/core/src → es}/modules/moveCells.d.ts +5 -5
  94. package/es/modules/moveCells.js +348 -0
  95. package/{dist/packages/core/src → es}/modules/protection.d.ts +5 -5
  96. package/es/modules/protection.js +96 -0
  97. package/{dist/packages/core/src → es}/modules/refresh.d.ts +3 -3
  98. package/es/modules/refresh.js +34 -0
  99. package/{dist/packages/core/src → es}/modules/rowcol.d.ts +19 -19
  100. package/es/modules/rowcol.js +1922 -0
  101. package/{dist/packages/core/src → es}/modules/screenshot.d.ts +2 -2
  102. package/es/modules/screenshot.js +90 -0
  103. package/{dist/packages/core/src → es}/modules/searchReplace.d.ts +36 -36
  104. package/es/modules/searchReplace.js +388 -0
  105. package/{dist/packages/core/src → es}/modules/selection.d.ts +46 -46
  106. package/es/modules/selection.js +1674 -0
  107. package/{dist/packages/core/src → es}/modules/sheet.d.ts +10 -10
  108. package/es/modules/sheet.js +237 -0
  109. package/{dist/packages/core/src → es}/modules/sort.d.ts +7 -7
  110. package/es/modules/sort.js +150 -0
  111. package/{dist/packages/core/src → es}/modules/splitColumn.d.ts +5 -5
  112. package/es/modules/splitColumn.js +126 -0
  113. package/es/modules/ssf.js +1533 -0
  114. package/{dist/packages/core/src → es}/modules/text.d.ts +10 -10
  115. package/es/modules/text.js +1207 -0
  116. package/{dist/packages/core/src → es}/modules/toolbar.d.ts +32 -32
  117. package/es/modules/toolbar.js +970 -0
  118. package/{dist/packages/core/src → es}/modules/validation.d.ts +19 -19
  119. package/es/modules/validation.js +190 -0
  120. package/{dist/packages/core/src → es}/modules/zoom.d.ts +3 -3
  121. package/es/modules/zoom.js +29 -0
  122. package/{dist/packages/core/src → es}/settings.d.ts +100 -100
  123. package/es/settings.js +36 -0
  124. package/{dist/packages/core/src → es}/types.d.ts +371 -371
  125. package/es/types.js +1 -0
  126. package/{dist/packages/core/src → es}/utils/freeze.d.ts +7 -7
  127. package/es/utils/freeze.js +86 -0
  128. package/{dist/packages/core/src → es}/utils/index.d.ts +18 -18
  129. package/es/utils/index.js +173 -0
  130. package/{dist/packages/core/src → es}/utils/patch.d.ts +37 -37
  131. package/es/utils/patch.js +381 -0
  132. package/lib/api/cell.d.ts +10 -0
  133. package/lib/api/cell.js +215 -0
  134. package/lib/api/common.d.ts +66 -0
  135. package/lib/api/common.js +88 -0
  136. package/lib/api/errors.d.ts +2 -0
  137. package/lib/api/errors.js +8 -0
  138. package/lib/api/index.d.ts +9 -0
  139. package/lib/api/index.js +101 -0
  140. package/lib/api/merge.d.ts +5 -0
  141. package/lib/api/merge.js +22 -0
  142. package/lib/api/range.d.ts +22 -0
  143. package/lib/api/range.js +138 -0
  144. package/lib/api/rowcol.d.ts +14 -0
  145. package/lib/api/rowcol.js +222 -0
  146. package/lib/api/sheet.d.ts +10 -0
  147. package/lib/api/sheet.js +145 -0
  148. package/lib/api/workbook.d.ts +15 -0
  149. package/lib/api/workbook.js +98 -0
  150. package/lib/canvas.d.ts +46 -0
  151. package/lib/canvas.js +1356 -0
  152. package/lib/context.d.ts +197 -0
  153. package/lib/context.js +392 -0
  154. package/lib/events/copy.d.ts +2 -0
  155. package/lib/events/copy.js +85 -0
  156. package/lib/events/index.d.ts +4 -0
  157. package/lib/events/index.js +49 -0
  158. package/lib/events/keyboard.d.ts +6 -0
  159. package/lib/events/keyboard.js +342 -0
  160. package/lib/events/mouse.d.ts +22 -0
  161. package/lib/events/mouse.js +1744 -0
  162. package/lib/events/paste.d.ts +3 -0
  163. package/lib/events/paste.js +1366 -0
  164. package/lib/index.d.ts +10 -0
  165. package/lib/index.js +109 -0
  166. package/lib/locale/en.d.ts +992 -0
  167. package/lib/locale/en.js +10570 -0
  168. package/lib/locale/es.d.ts +1134 -0
  169. package/lib/locale/es.js +10016 -0
  170. package/lib/locale/hi.d.ts +1030 -0
  171. package/lib/locale/hi.js +10556 -0
  172. package/lib/locale/index.d.ts +1049 -0
  173. package/lib/locale/index.js +29 -0
  174. package/lib/locale/zh.d.ts +1048 -0
  175. package/lib/locale/zh.js +10574 -0
  176. package/lib/locale/zh_tw.d.ts +1187 -0
  177. package/lib/locale/zh_tw.js +10078 -0
  178. package/lib/modules/ConditionFormat.d.ts +17 -0
  179. package/lib/modules/ConditionFormat.js +1273 -0
  180. package/lib/modules/border.d.ts +3 -0
  181. package/lib/modules/border.js +1248 -0
  182. package/lib/modules/cell.d.ts +32 -0
  183. package/lib/modules/cell.js +1085 -0
  184. package/lib/modules/clipboard.d.ts +3 -0
  185. package/lib/modules/clipboard.js +42 -0
  186. package/lib/modules/color.d.ts +1 -0
  187. package/lib/modules/color.js +7 -0
  188. package/lib/modules/comment.d.ts +97 -0
  189. package/lib/modules/comment.js +625 -0
  190. package/lib/modules/conditionalFormat.d.ts +2 -0
  191. package/lib/modules/conditionalFormat.js +447 -0
  192. package/lib/modules/cursor.d.ts +3 -0
  193. package/lib/modules/cursor.js +70 -0
  194. package/lib/modules/dataVerification.d.ts +11 -0
  195. package/lib/modules/dataVerification.js +715 -0
  196. package/lib/modules/dropCell.d.ts +10 -0
  197. package/lib/modules/dropCell.js +2282 -0
  198. package/lib/modules/filter.d.ts +45 -0
  199. package/lib/modules/filter.js +448 -0
  200. package/lib/modules/format.d.ts +6 -0
  201. package/lib/modules/format.js +334 -0
  202. package/lib/modules/formula.d.ts +54 -0
  203. package/lib/modules/formula.js +2330 -0
  204. package/lib/modules/freeze.d.ts +5 -0
  205. package/lib/modules/freeze.js +158 -0
  206. package/lib/modules/hyperlink.d.ts +21 -0
  207. package/lib/modules/hyperlink.js +232 -0
  208. package/lib/modules/iframe.d.ts +12 -0
  209. package/lib/modules/iframe.js +236 -0
  210. package/lib/modules/image.d.ts +31 -0
  211. package/lib/modules/image.js +272 -0
  212. package/lib/modules/index.d.ts +36 -0
  213. package/lib/modules/index.js +401 -0
  214. package/lib/modules/inline-string.d.ts +36 -0
  215. package/lib/modules/inline-string.js +452 -0
  216. package/lib/modules/location.d.ts +6 -0
  217. package/lib/modules/location.js +57 -0
  218. package/lib/modules/locationCondition.d.ts +21 -0
  219. package/lib/modules/locationCondition.js +229 -0
  220. package/lib/modules/merge.d.ts +3 -0
  221. package/lib/modules/merge.js +223 -0
  222. package/lib/modules/mobile.d.ts +5 -0
  223. package/lib/modules/mobile.js +41 -0
  224. package/lib/modules/moveCells.d.ts +5 -0
  225. package/lib/modules/moveCells.js +357 -0
  226. package/lib/modules/protection.d.ts +5 -0
  227. package/lib/modules/protection.js +106 -0
  228. package/lib/modules/refresh.d.ts +3 -0
  229. package/lib/modules/refresh.js +40 -0
  230. package/lib/modules/rowcol.d.ts +19 -0
  231. package/lib/modules/rowcol.js +1935 -0
  232. package/lib/modules/screenshot.d.ts +2 -0
  233. package/lib/modules/screenshot.js +96 -0
  234. package/lib/modules/searchReplace.d.ts +36 -0
  235. package/lib/modules/searchReplace.js +402 -0
  236. package/lib/modules/selection.d.ts +46 -0
  237. package/lib/modules/selection.js +1703 -0
  238. package/lib/modules/sheet.d.ts +10 -0
  239. package/lib/modules/sheet.js +250 -0
  240. package/lib/modules/sort.d.ts +7 -0
  241. package/lib/modules/sort.js +159 -0
  242. package/lib/modules/splitColumn.d.ts +5 -0
  243. package/lib/modules/splitColumn.js +136 -0
  244. package/lib/modules/ssf.js +1539 -0
  245. package/lib/modules/text.d.ts +10 -0
  246. package/lib/modules/text.js +1221 -0
  247. package/lib/modules/toolbar.d.ts +32 -0
  248. package/lib/modules/toolbar.js +1003 -0
  249. package/lib/modules/validation.d.ts +19 -0
  250. package/lib/modules/validation.js +205 -0
  251. package/lib/modules/zoom.d.ts +3 -0
  252. package/lib/modules/zoom.js +36 -0
  253. package/lib/settings.d.ts +100 -0
  254. package/lib/settings.js +42 -0
  255. package/lib/types.d.ts +371 -0
  256. package/lib/types.js +5 -0
  257. package/lib/utils/freeze.d.ts +7 -0
  258. package/lib/utils/freeze.js +92 -0
  259. package/lib/utils/index.d.ts +18 -0
  260. package/lib/utils/index.js +231 -0
  261. package/lib/utils/patch.d.ts +37 -0
  262. package/lib/utils/patch.js +392 -0
  263. package/package.json +7 -6
  264. package/dist/index.esm.js +0 -80255
  265. package/dist/index.js +0 -80601
  266. package/dist/packages/react/src/components/ChangeColor/index.d.ts +0 -7
  267. package/dist/packages/react/src/components/ConditionFormat/ConditionRules.d.ts +0 -6
  268. package/dist/packages/react/src/components/ConditionFormat/index.d.ts +0 -7
  269. package/dist/packages/react/src/components/ContextMenu/Divider.d.ts +0 -3
  270. package/dist/packages/react/src/components/ContextMenu/FilterMenu.d.ts +0 -3
  271. package/dist/packages/react/src/components/ContextMenu/Menu.d.ts +0 -8
  272. package/dist/packages/react/src/components/ContextMenu/SheetTab.d.ts +0 -4
  273. package/dist/packages/react/src/components/ContextMenu/index.d.ts +0 -5
  274. package/dist/packages/react/src/components/CustomSort/index.d.ts +0 -4
  275. package/dist/packages/react/src/components/DataVerification/DropdownList.d.ts +0 -4
  276. package/dist/packages/react/src/components/DataVerification/RangeDialog.d.ts +0 -4
  277. package/dist/packages/react/src/components/DataVerification/getDisplayedRangeTxt.d.ts +0 -2
  278. package/dist/packages/react/src/components/DataVerification/index.d.ts +0 -4
  279. package/dist/packages/react/src/components/Dialog/index.d.ts +0 -15
  280. package/dist/packages/react/src/components/DuneChartsInputModal/DuneChartsInputModal.d.ts +0 -11
  281. package/dist/packages/react/src/components/DunePreview/DunePreview.d.ts +0 -13
  282. package/dist/packages/react/src/components/FilterOption/index.d.ts +0 -5
  283. package/dist/packages/react/src/components/FormatSearch/index.d.ts +0 -6
  284. package/dist/packages/react/src/components/FormulaSearch/index.d.ts +0 -5
  285. package/dist/packages/react/src/components/FxEditor/NameBox.d.ts +0 -3
  286. package/dist/packages/react/src/components/FxEditor/index.d.ts +0 -4
  287. package/dist/packages/react/src/components/IFrameBoxs/iFrameBoxs.d.ts +0 -4
  288. package/dist/packages/react/src/components/ImgBoxs/index.d.ts +0 -3
  289. package/dist/packages/react/src/components/LinkEidtCard/index.d.ts +0 -5
  290. package/dist/packages/react/src/components/LocationCondition/index.d.ts +0 -3
  291. package/dist/packages/react/src/components/MessageBox/index.d.ts +0 -9
  292. package/dist/packages/react/src/components/NotationBoxes/index.d.ts +0 -3
  293. package/dist/packages/react/src/components/ResetColumnWidth/index.d.ts +0 -2
  294. package/dist/packages/react/src/components/SVGDefines.d.ts +0 -5
  295. package/dist/packages/react/src/components/SVGIcon.d.ts +0 -9
  296. package/dist/packages/react/src/components/SearchReplace/index.d.ts +0 -6
  297. package/dist/packages/react/src/components/Sheet/index.d.ts +0 -8
  298. package/dist/packages/react/src/components/SheetList/SheetHiddenButton.d.ts +0 -8
  299. package/dist/packages/react/src/components/SheetList/SheetListItem.d.ts +0 -9
  300. package/dist/packages/react/src/components/SheetList/index.d.ts +0 -4
  301. package/dist/packages/react/src/components/SheetOverlay/ColumnHeader.d.ts +0 -3
  302. package/dist/packages/react/src/components/SheetOverlay/ContentEditable.d.ts +0 -11
  303. package/dist/packages/react/src/components/SheetOverlay/FormulaHint/index.d.ts +0 -4
  304. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/constant.d.ts +0 -63
  305. package/dist/packages/react/src/components/SheetOverlay/FormulaSearch/index.d.ts +0 -4
  306. package/dist/packages/react/src/components/SheetOverlay/InputBox.d.ts +0 -3
  307. package/dist/packages/react/src/components/SheetOverlay/RowHeader.d.ts +0 -3
  308. package/dist/packages/react/src/components/SheetOverlay/ScrollBar/index.d.ts +0 -7
  309. package/dist/packages/react/src/components/SheetOverlay/index.d.ts +0 -4
  310. package/dist/packages/react/src/components/SheetTab/SheetItem.d.ts +0 -8
  311. package/dist/packages/react/src/components/SheetTab/index.d.ts +0 -4
  312. package/dist/packages/react/src/components/SplitColumn/index.d.ts +0 -3
  313. package/dist/packages/react/src/components/Toolbar/Button.d.ts +0 -12
  314. package/dist/packages/react/src/components/Toolbar/ColorPicker.d.ts +0 -6
  315. package/dist/packages/react/src/components/Toolbar/Combo.d.ts +0 -12
  316. package/dist/packages/react/src/components/Toolbar/CustomBorder.d.ts +0 -7
  317. package/dist/packages/react/src/components/Toolbar/CustomButton.d.ts +0 -11
  318. package/dist/packages/react/src/components/Toolbar/CustomColor.d.ts +0 -8
  319. package/dist/packages/react/src/components/Toolbar/CustomIcon.d.ts +0 -9
  320. package/dist/packages/react/src/components/Toolbar/Divider.d.ts +0 -4
  321. package/dist/packages/react/src/components/Toolbar/MoreItemsContainer.d.ts +0 -6
  322. package/dist/packages/react/src/components/Toolbar/Select.d.ts +0 -14
  323. package/dist/packages/react/src/components/Toolbar/index.d.ts +0 -10
  324. package/dist/packages/react/src/components/Workbook/api.d.ts +0 -1177
  325. package/dist/packages/react/src/components/Workbook/index.d.ts +0 -1185
  326. package/dist/packages/react/src/components/ZoomControl/index.d.ts +0 -4
  327. package/dist/packages/react/src/components/index.d.ts +0 -4
  328. package/dist/packages/react/src/constants.d.ts +0 -1
  329. package/dist/packages/react/src/context/index.d.ts +0 -25
  330. package/dist/packages/react/src/context/modal.d.ts +0 -10
  331. package/dist/packages/react/src/hooks/useAlert.d.ts +0 -4
  332. package/dist/packages/react/src/hooks/useDialog.d.ts +0 -5
  333. package/dist/packages/react/src/hooks/useOutsideClick.d.ts +0 -2
  334. package/dist/packages/react/src/hooks/usePrevious.d.ts +0 -2
  335. package/dist/packages/react/src/index.d.ts +0 -1
  336. package/dist/packages/react/src/utils/datepickerStyles.d.ts +0 -2
  337. package/dist/stories/API.stories.d.ts +0 -1210
  338. package/dist/stories/Collabration.stories.d.ts +0 -2359
  339. package/dist/stories/Features.stories.d.ts +0 -9430
  340. package/dist/stories/data/cell.d.ts +0 -983
  341. package/dist/stories/data/dataVerification.d.ts +0 -131
  342. package/dist/stories/data/empty.d.ts +0 -10
  343. package/dist/stories/data/formula.d.ts +0 -362
  344. package/dist/stories/data/freeze.d.ts +0 -34
  345. package/dist/stories/data/protected.d.ts +0 -40
  346. package/dist/stories/utils.d.ts +0 -1
@@ -1,5 +1,5 @@
1
- import { Context, Freezen, GlobalCache } from "..";
2
- export declare function initFreeze(ctx: Context, cache: GlobalCache, sheetId: string): void;
3
- export declare function scrollToFrozenRowCol(ctx: Context, freeze: Freezen | undefined): void;
4
- export declare function getFrozenHandleTop(ctx: Context): number;
5
- export declare function getFrozenHandleLeft(ctx: Context): number;
1
+ import { Context, Freezen, GlobalCache } from "..";
2
+ export declare function initFreeze(ctx: Context, cache: GlobalCache, sheetId: string): void;
3
+ export declare function scrollToFrozenRowCol(ctx: Context, freeze: Freezen | undefined): void;
4
+ export declare function getFrozenHandleTop(ctx: Context): number;
5
+ export declare function getFrozenHandleLeft(ctx: Context): number;
@@ -0,0 +1,148 @@
1
+ import _ from "lodash";
2
+ import { colLocationByIndex, getSheetIndex, rowLocationByIndex } from "..";
3
+ function cutVolumn(arr, cutindex) {
4
+ if (cutindex <= 0) {
5
+ return arr;
6
+ }
7
+ var ret = arr.slice(cutindex);
8
+ return ret;
9
+ }
10
+ function frozenTofreezen(ctx, cache, sheetId) {
11
+ var file = ctx.luckysheetfile[getSheetIndex(ctx, sheetId)];
12
+ var frozen = file.frozen;
13
+ if (frozen == null) {
14
+ delete cache.freezen;
15
+ return;
16
+ }
17
+ var freezen = {};
18
+ var range = frozen.range;
19
+ if (!range) {
20
+ range = {
21
+ row_focus: 0,
22
+ column_focus: 0
23
+ };
24
+ }
25
+ var type = frozen.type;
26
+ if (type === "row") {
27
+ type = "rangeRow";
28
+ } else if (type === "column") {
29
+ type = "rangeColumn";
30
+ } else if (type === "both") {
31
+ type = "rangeBoth";
32
+ }
33
+ if (type === "rangeRow" || type === "rangeBoth") {
34
+ var scrollTop = 0;
35
+ var row_st = _.sortedIndex(ctx.visibledatarow, scrollTop);
36
+ var row_focus = range.row_focus;
37
+ if (row_focus > row_st) {
38
+ row_st = row_focus;
39
+ }
40
+ if (row_st === -1) {
41
+ row_st = 0;
42
+ }
43
+ var top_1 = ctx.visibledatarow[row_st] - 2 - scrollTop + ctx.columnHeaderHeight;
44
+ var freezenhorizontaldata = [ctx.visibledatarow[row_st], row_st + 1, scrollTop, cutVolumn(ctx.visibledatarow, row_st + 1), top_1];
45
+ freezen.horizontal = {
46
+ freezenhorizontaldata: freezenhorizontaldata,
47
+ top: top_1
48
+ };
49
+ }
50
+ if (type === "rangeColumn" || type === "rangeBoth") {
51
+ var scrollLeft = 0;
52
+ var col_st = _.sortedIndex(ctx.visibledatacolumn, scrollLeft);
53
+ var column_focus = range.column_focus;
54
+ if (column_focus > col_st) {
55
+ col_st = column_focus;
56
+ }
57
+ if (col_st === -1) {
58
+ col_st = 0;
59
+ }
60
+ var left = ctx.visibledatacolumn[col_st] - 2 - scrollLeft + ctx.rowHeaderWidth;
61
+ var freezenverticaldata = [ctx.visibledatacolumn[col_st], col_st + 1, scrollLeft, cutVolumn(ctx.visibledatacolumn, col_st + 1), left];
62
+ freezen.vertical = {
63
+ freezenverticaldata: freezenverticaldata,
64
+ left: left
65
+ };
66
+ }
67
+ cache.freezen || (cache.freezen = {});
68
+ cache.freezen[ctx.currentSheetId] = freezen;
69
+ }
70
+ export function initFreeze(ctx, cache, sheetId) {
71
+ frozenTofreezen(ctx, cache, sheetId);
72
+ }
73
+ export function scrollToFrozenRowCol(ctx, freeze) {
74
+ var _a, _b;
75
+ var _c, _d;
76
+ var select_save = ctx.luckysheet_select_save;
77
+ if (!select_save) return;
78
+ var row;
79
+ var row_focus = select_save[0].row_focus;
80
+ if (row_focus === select_save[0].row[0]) {
81
+ _a = select_save[0].row, row = _a[1];
82
+ } else if (row_focus === select_save[0].row[1]) {
83
+ row = select_save[0].row[0];
84
+ }
85
+ var column;
86
+ var column_focus = select_save[0].column_focus;
87
+ if (column_focus === select_save[0].column[0]) {
88
+ _b = select_save[0].column, column = _b[1];
89
+ } else if (column_focus === select_save[0].column[1]) {
90
+ column = select_save[0].column[0];
91
+ }
92
+ var freezenverticaldata = (_c = freeze === null || freeze === void 0 ? void 0 : freeze.vertical) === null || _c === void 0 ? void 0 : _c.freezenverticaldata;
93
+ var freezenhorizontaldata = (_d = freeze === null || freeze === void 0 ? void 0 : freeze.horizontal) === null || _d === void 0 ? void 0 : _d.freezenhorizontaldata;
94
+ if (freezenverticaldata != null && column != null) {
95
+ var freezen_colindex = freezenverticaldata[1];
96
+ var offset = _.sortedIndex(freezenverticaldata[3], ctx.scrollLeft);
97
+ var top_2 = freezenverticaldata[4];
98
+ freezen_colindex += offset;
99
+ if (column >= ctx.visibledatacolumn.length) {
100
+ column = ctx.visibledatacolumn.length - 1;
101
+ }
102
+ if (freezen_colindex >= ctx.visibledatacolumn.length) {
103
+ freezen_colindex = ctx.visibledatacolumn.length - 1;
104
+ }
105
+ var column_px = ctx.visibledatacolumn[column];
106
+ var freezen_px = ctx.visibledatacolumn[freezen_colindex];
107
+ if (column_px <= freezen_px + top_2) {
108
+ ctx.scrollLeft = 0;
109
+ }
110
+ }
111
+ if (freezenhorizontaldata != null && row != null) {
112
+ var freezen_rowindex = freezenhorizontaldata[1];
113
+ var offset = _.sortedIndex(freezenhorizontaldata[3], ctx.scrollTop);
114
+ var left = freezenhorizontaldata[4];
115
+ freezen_rowindex += offset;
116
+ if (row >= ctx.visibledatarow.length) {
117
+ row = ctx.visibledatarow.length - 1;
118
+ }
119
+ if (freezen_rowindex >= ctx.visibledatarow.length) {
120
+ freezen_rowindex = ctx.visibledatarow.length - 1;
121
+ }
122
+ var row_px = ctx.visibledatarow[row];
123
+ var freezen_px = ctx.visibledatarow[freezen_rowindex];
124
+ if (row_px <= freezen_px + left) {
125
+ ctx.scrollTop = 0;
126
+ }
127
+ }
128
+ }
129
+ export function getFrozenHandleTop(ctx) {
130
+ var _a, _b, _c, _d, _e, _f;
131
+ var idx = getSheetIndex(ctx, ctx.currentSheetId);
132
+ if (idx == null) return ctx.scrollTop;
133
+ var sheet = ctx.luckysheetfile[idx];
134
+ if (((_a = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _a === void 0 ? void 0 : _a.type) === "row" || ((_b = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _b === void 0 ? void 0 : _b.type) === "rangeRow" || ((_c = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _c === void 0 ? void 0 : _c.type) === "rangeBoth" || ((_d = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _d === void 0 ? void 0 : _d.type) === "both") {
135
+ return rowLocationByIndex(((_f = (_e = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _e === void 0 ? void 0 : _e.range) === null || _f === void 0 ? void 0 : _f.row_focus) || 0, ctx.visibledatarow)[1] + ctx.scrollTop;
136
+ }
137
+ return ctx.scrollTop;
138
+ }
139
+ export function getFrozenHandleLeft(ctx) {
140
+ var _a, _b, _c, _d, _e, _f;
141
+ var idx = getSheetIndex(ctx, ctx.currentSheetId);
142
+ if (idx == null) return ctx.scrollLeft;
143
+ var sheet = ctx.luckysheetfile[idx];
144
+ if (((_a = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _a === void 0 ? void 0 : _a.type) === "column" || ((_b = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _b === void 0 ? void 0 : _b.type) === "rangeColumn" || ((_c = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _c === void 0 ? void 0 : _c.type) === "rangeBoth" || ((_d = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _d === void 0 ? void 0 : _d.type) === "both") {
145
+ return colLocationByIndex(((_f = (_e = sheet === null || sheet === void 0 ? void 0 : sheet.frozen) === null || _e === void 0 ? void 0 : _e.range) === null || _f === void 0 ? void 0 : _f.column_focus) || 0, ctx.visibledatacolumn)[1] - 2 + ctx.scrollLeft;
146
+ }
147
+ return ctx.scrollLeft;
148
+ }
@@ -1,21 +1,21 @@
1
- import { Context } from "../context";
2
- import { GlobalCache } from "../types";
3
- export declare function getCellRowColumn(ctx: Context, e: MouseEvent, container: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement): {
4
- r: number;
5
- c: number;
6
- } | undefined;
7
- export declare function getCellHyperlink(ctx: Context, r: number, c: number): {
8
- linkType: string;
9
- linkAddress: string;
10
- } | undefined;
11
- export declare function saveHyperlink(ctx: Context, r: number, c: number, linkText: string, linkType: string, linkAddress: string): void;
12
- export declare function removeHyperlink(ctx: Context, r: number, c: number): void;
13
- export declare function showLinkCard(ctx: Context, r: number, c: number, isEditing?: boolean, isMouseDown?: boolean): void;
14
- export declare function goToLink(ctx: Context, r: number, c: number, linkType: string, linkAddress: string, scrollbarX: HTMLDivElement, scrollbarY: HTMLDivElement): void;
15
- export declare function isLinkValid(ctx: Context, linkType: string, linkAddress: string): {
16
- isValid: boolean;
17
- tooltip: string;
18
- };
19
- export declare function onRangeSelectionModalMoveStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent): void;
20
- export declare function onRangeSelectionModalMove(globalCache: GlobalCache, e: MouseEvent): void;
21
- export declare function onRangeSelectionModalMoveEnd(globalCache: GlobalCache): void;
1
+ import { Context } from "../context";
2
+ import { GlobalCache } from "../types";
3
+ export declare function getCellRowColumn(ctx: Context, e: MouseEvent, container: HTMLDivElement, scrollX: HTMLDivElement, scrollY: HTMLDivElement): {
4
+ r: number;
5
+ c: number;
6
+ } | undefined;
7
+ export declare function getCellHyperlink(ctx: Context, r: number, c: number): {
8
+ linkType: string;
9
+ linkAddress: string;
10
+ } | undefined;
11
+ export declare function saveHyperlink(ctx: Context, r: number, c: number, linkText: string, linkType: string, linkAddress: string): void;
12
+ export declare function removeHyperlink(ctx: Context, r: number, c: number): void;
13
+ export declare function showLinkCard(ctx: Context, r: number, c: number, isEditing?: boolean, isMouseDown?: boolean): void;
14
+ export declare function goToLink(ctx: Context, r: number, c: number, linkType: string, linkAddress: string, scrollbarX: HTMLDivElement, scrollbarY: HTMLDivElement): void;
15
+ export declare function isLinkValid(ctx: Context, linkType: string, linkAddress: string): {
16
+ isValid: boolean;
17
+ tooltip: string;
18
+ };
19
+ export declare function onRangeSelectionModalMoveStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent): void;
20
+ export declare function onRangeSelectionModalMove(globalCache: GlobalCache, e: MouseEvent): void;
21
+ export declare function onRangeSelectionModalMoveEnd(globalCache: GlobalCache): void;
@@ -0,0 +1,216 @@
1
+ import _ from "lodash";
2
+ import { getFlowdata } from "../context";
3
+ import { getSheetIndex, isAllowEdit } from "../utils";
4
+ import { mergeBorder } from "./cell";
5
+ import { getcellrange, iscelldata } from "./formula";
6
+ import { colLocation, rowLocation } from "./location";
7
+ import { normalizeSelection } from "./selection";
8
+ import { changeSheet } from "./sheet";
9
+ import { locale } from "../locale";
10
+ export function getCellRowColumn(ctx, e, container, scrollX, scrollY) {
11
+ var _a, _b;
12
+ var flowdata = getFlowdata(ctx);
13
+ if (flowdata == null) return undefined;
14
+ var scrollLeft = scrollX.scrollLeft;
15
+ var scrollTop = scrollY.scrollTop;
16
+ var rect = container.getBoundingClientRect();
17
+ var x = e.pageX - rect.left - ctx.rowHeaderWidth;
18
+ var y = e.pageY - rect.top - ctx.columnHeaderHeight;
19
+ x += scrollLeft;
20
+ y += scrollTop;
21
+ var r = rowLocation(y, ctx.visibledatarow)[2];
22
+ var c = colLocation(x, ctx.visibledatacolumn)[2];
23
+ var margeset = mergeBorder(ctx, flowdata, r, c);
24
+ if (margeset) {
25
+ _a = margeset.row, r = _a[2];
26
+ _b = margeset.column, c = _b[2];
27
+ }
28
+ return {
29
+ r: r,
30
+ c: c
31
+ };
32
+ }
33
+ export function getCellHyperlink(ctx, r, c) {
34
+ var _a;
35
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
36
+ if (sheetIndex != null) {
37
+ return (_a = ctx.luckysheetfile[sheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)];
38
+ }
39
+ return undefined;
40
+ }
41
+ export function saveHyperlink(ctx, r, c, linkText, linkType, linkAddress) {
42
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
43
+ var flowdata = getFlowdata(ctx);
44
+ if (sheetIndex != null && flowdata != null && linkType && linkAddress) {
45
+ var cell = flowdata[r][c];
46
+ if (cell == null) cell = {};
47
+ _.set(ctx.luckysheetfile[sheetIndex], ["hyperlink", "".concat(r, "_").concat(c)], {
48
+ linkType: linkType,
49
+ linkAddress: linkAddress
50
+ });
51
+ cell.fc = "rgb(0, 0, 255)";
52
+ cell.un = 1;
53
+ cell.v = linkText || linkAddress;
54
+ cell.m = linkText || linkAddress;
55
+ cell.hl = {
56
+ r: r,
57
+ c: c,
58
+ id: ctx.currentSheetId
59
+ };
60
+ flowdata[r][c] = cell;
61
+ ctx.linkCard = undefined;
62
+ }
63
+ }
64
+ export function removeHyperlink(ctx, r, c) {
65
+ var allowEdit = isAllowEdit(ctx);
66
+ if (!allowEdit) return;
67
+ var sheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
68
+ var flowdata = getFlowdata(ctx);
69
+ if (flowdata != null && sheetIndex != null) {
70
+ var hyperlink = _.omit(ctx.luckysheetfile[sheetIndex].hyperlink, "".concat(r, "_").concat(c));
71
+ _.set(ctx.luckysheetfile[sheetIndex], "hyperlink", hyperlink);
72
+ var cell = flowdata[r][c];
73
+ if (cell != null) {
74
+ flowdata[r][c] = {
75
+ v: cell.v,
76
+ m: cell.m
77
+ };
78
+ }
79
+ }
80
+ ctx.linkCard = undefined;
81
+ }
82
+ export function showLinkCard(ctx, r, c, isEditing, isMouseDown) {
83
+ var _a, _b, _c, _d, _e, _f, _g;
84
+ if (isEditing === void 0) {
85
+ isEditing = false;
86
+ }
87
+ if (isMouseDown === void 0) {
88
+ isMouseDown = false;
89
+ }
90
+ if ((_a = ctx.linkCard) === null || _a === void 0 ? void 0 : _a.selectingCellRange) return;
91
+ if ("".concat(r, "_").concat(c) === ((_b = ctx.linkCard) === null || _b === void 0 ? void 0 : _b.rc)) return;
92
+ var link = getCellHyperlink(ctx, r, c);
93
+ var cell = (_d = (_c = getFlowdata(ctx)) === null || _c === void 0 ? void 0 : _c[r]) === null || _d === void 0 ? void 0 : _d[c];
94
+ if (!isEditing && link == null && (isMouseDown || !((_e = ctx.linkCard) === null || _e === void 0 ? void 0 : _e.isEditing) || ctx.linkCard.sheetId !== ctx.currentSheetId)) {
95
+ ctx.linkCard = undefined;
96
+ return;
97
+ }
98
+ if (isEditing || link != null && (!((_f = ctx.linkCard) === null || _f === void 0 ? void 0 : _f.isEditing) || isMouseDown) || ((_g = ctx.linkCard) === null || _g === void 0 ? void 0 : _g.sheetId) !== ctx.currentSheetId) {
99
+ var col_pre = c - 1 === -1 ? 0 : ctx.visibledatacolumn[c - 1];
100
+ var row = ctx.visibledatarow[r];
101
+ ctx.linkCard = {
102
+ sheetId: ctx.currentSheetId,
103
+ r: r,
104
+ c: c,
105
+ rc: "".concat(r, "_").concat(c),
106
+ originText: (cell === null || cell === void 0 ? void 0 : cell.v) == null ? "" : "".concat(cell.v),
107
+ originType: (link === null || link === void 0 ? void 0 : link.linkType) || "webpage",
108
+ originAddress: (link === null || link === void 0 ? void 0 : link.linkAddress) || "",
109
+ position: {
110
+ cellLeft: col_pre,
111
+ cellBottom: row
112
+ },
113
+ isEditing: isEditing
114
+ };
115
+ }
116
+ }
117
+ export function goToLink(ctx, r, c, linkType, linkAddress, scrollbarX, scrollbarY) {
118
+ var _a;
119
+ var currSheetIndex = getSheetIndex(ctx, ctx.currentSheetId);
120
+ if (currSheetIndex == null) return;
121
+ if (((_a = ctx.luckysheetfile[currSheetIndex].hyperlink) === null || _a === void 0 ? void 0 : _a["".concat(r, "_").concat(c)]) == null) {
122
+ return;
123
+ }
124
+ if (linkType === "webpage") {
125
+ if (!/^http[s]?:\/\//.test(linkAddress)) {
126
+ linkAddress = "https://".concat(linkAddress);
127
+ }
128
+ window.open(linkAddress);
129
+ } else if (linkType === "sheet") {
130
+ var sheetId_1;
131
+ _.forEach(ctx.luckysheetfile, function (f) {
132
+ if (linkAddress === f.name) {
133
+ sheetId_1 = f.id;
134
+ }
135
+ });
136
+ if (sheetId_1 != null) changeSheet(ctx, sheetId_1);
137
+ } else {
138
+ var range = _.cloneDeep(getcellrange(ctx, linkAddress));
139
+ if (range == null) return;
140
+ var row_pre = range.row[0] - 1 === -1 ? 0 : ctx.visibledatarow[range.row[0] - 1];
141
+ var col_pre = range.column[0] - 1 === -1 ? 0 : ctx.visibledatacolumn[range.column[0] - 1];
142
+ scrollbarX.scrollLeft = col_pre;
143
+ scrollbarY.scrollLeft = row_pre;
144
+ ctx.luckysheet_select_save = normalizeSelection(ctx, [range]);
145
+ changeSheet(ctx, range.sheetId);
146
+ }
147
+ ctx.linkCard = undefined;
148
+ }
149
+ export function isLinkValid(ctx, linkType, linkAddress) {
150
+ if (!linkAddress) return {
151
+ isValid: false,
152
+ tooltip: ""
153
+ };
154
+ var insertLink = locale(ctx).insertLink;
155
+ if (linkType === "webpage") {
156
+ if (!/^http[s]?:\/\//.test(linkAddress)) {
157
+ linkAddress = "https://".concat(linkAddress);
158
+ }
159
+ if (!/^http[s]?:\/\/([\w\-\.]+)+[\w-]*([\w\-\.\/\?%&=]+)?$/gi.test(linkAddress)) return {
160
+ isValid: false,
161
+ tooltip: insertLink.tooltipInfo1
162
+ };
163
+ }
164
+ if (linkType === "cellrange" && !iscelldata(linkAddress)) {
165
+ return {
166
+ isValid: false,
167
+ tooltip: insertLink.invalidCellRangeTip
168
+ };
169
+ }
170
+ return {
171
+ isValid: true,
172
+ tooltip: ""
173
+ };
174
+ }
175
+ export function onRangeSelectionModalMoveStart(ctx, globalCache, e) {
176
+ var box = document.querySelector("div.fortune-link-modify-modal.range-selection-modal");
177
+ if (!box) return;
178
+ var _a = box.getBoundingClientRect(),
179
+ width = _a.width,
180
+ height = _a.height;
181
+ var left = box.offsetLeft;
182
+ var top = box.offsetTop;
183
+ var initialPosition = {
184
+ left: left,
185
+ top: top,
186
+ width: width,
187
+ height: height
188
+ };
189
+ _.set(globalCache, "linkCard.rangeSelectionModal", {
190
+ cursorMoveStartPosition: {
191
+ x: e.pageX,
192
+ y: e.pageY
193
+ },
194
+ initialPosition: initialPosition
195
+ });
196
+ }
197
+ export function onRangeSelectionModalMove(globalCache, e) {
198
+ var _a;
199
+ var moveProps = (_a = globalCache.linkCard) === null || _a === void 0 ? void 0 : _a.rangeSelectionModal;
200
+ if (moveProps == null) return;
201
+ var modal = document.querySelector("div.fortune-link-modify-modal.range-selection-modal");
202
+ var _b = moveProps.cursorMoveStartPosition,
203
+ startX = _b.x,
204
+ startY = _b.y;
205
+ var _c = moveProps.initialPosition,
206
+ top = _c.top,
207
+ left = _c.left;
208
+ left += e.pageX - startX;
209
+ top += e.pageY - startY;
210
+ if (top < 0) top = 0;
211
+ modal.style.left = "".concat(left, "px");
212
+ modal.style.top = "".concat(top, "px");
213
+ }
214
+ export function onRangeSelectionModalMoveEnd(globalCache) {
215
+ _.set(globalCache, "linkCard.rangeSelectionModal", undefined);
216
+ }
@@ -1,12 +1,12 @@
1
- import { Context } from "../context";
2
- import { GlobalCache } from "../types";
3
- export declare function sanitizeDuneUrl(input: string): string | null;
4
- export declare function saveIframe(ctx: Context): void;
5
- export declare function insertIframe(ctx: Context, src: string): void;
6
- export declare function insertDuneChart(ctx: Context, input: string): void;
7
- export declare function onIframeResizeEnd(ctx: Context, globalCache: GlobalCache): void;
8
- export declare function onIframeMove(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
9
- export declare function onIframeMoveEnd(ctx: Context, globalCache: GlobalCache): void;
10
- export declare function onIframeMoveStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent): void;
11
- export declare function onIframeResize(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
12
- export declare function onIframeResizeStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent, resizingSide: string): void;
1
+ import { Context } from "../context";
2
+ import { GlobalCache } from "../types";
3
+ export declare function sanitizeDuneUrl(input: string): string | null;
4
+ export declare function saveIframe(ctx: Context): void;
5
+ export declare function insertIframe(ctx: Context, src: string): void;
6
+ export declare function insertDuneChart(ctx: Context, input: string): void;
7
+ export declare function onIframeResizeEnd(ctx: Context, globalCache: GlobalCache): void;
8
+ export declare function onIframeMove(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
9
+ export declare function onIframeMoveEnd(ctx: Context, globalCache: GlobalCache): void;
10
+ export declare function onIframeMoveStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent): void;
11
+ export declare function onIframeResize(ctx: Context, globalCache: GlobalCache, e: MouseEvent): boolean;
12
+ export declare function onIframeResizeStart(ctx: Context, globalCache: GlobalCache, e: MouseEvent, resizingSide: string): void;
@@ -0,0 +1,220 @@
1
+ import _ from "lodash";
2
+ import { getFlowdata } from "../context";
3
+ import { getSheetIndex } from "../utils";
4
+ import { mergeBorder } from "./cell";
5
+ import { generateRandomId } from "./image";
6
+ export function sanitizeDuneUrl(input) {
7
+ var trimmed = input.trim();
8
+ var iframeMatch = trimmed.match(/src=["']?(https:\/\/dune\.com\/embeds\/\d+\/\d+)/);
9
+ if (iframeMatch) {
10
+ return iframeMatch[1];
11
+ }
12
+ var queryMatch = trimmed.match(/^https:\/\/dune\.com\/queries\/(\d+)\/(\d+)/);
13
+ if (queryMatch) {
14
+ var queryId = queryMatch[1],
15
+ vizId = queryMatch[2];
16
+ return "https://dune.com/embeds/".concat(queryId, "/").concat(vizId);
17
+ }
18
+ return null;
19
+ }
20
+ export function saveIframe(ctx) {
21
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
22
+ if (index == null) return;
23
+ var file = ctx.luckysheetfile[index];
24
+ file.iframes = ctx.insertedIframes;
25
+ }
26
+ export function insertIframe(ctx, src) {
27
+ var _a, _b, _c, _d, _e, _f, _g;
28
+ try {
29
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
30
+ var rowIndex = (_d = (_b = last === null || last === void 0 ? void 0 : last.row_focus) !== null && _b !== void 0 ? _b : (_c = last === null || last === void 0 ? void 0 : last.row) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0;
31
+ var colIndex = (_g = (_e = last === null || last === void 0 ? void 0 : last.column_focus) !== null && _e !== void 0 ? _e : (_f = last === null || last === void 0 ? void 0 : last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
32
+ var flowdata = getFlowdata(ctx);
33
+ var left = colIndex === 0 ? 0 : ctx.visibledatacolumn[colIndex - 1];
34
+ var top_1 = rowIndex === 0 ? 0 : ctx.visibledatarow[rowIndex - 1];
35
+ if (flowdata) {
36
+ var margeset = mergeBorder(ctx, flowdata, rowIndex, colIndex);
37
+ if (margeset) {
38
+ top_1 = margeset.row[0];
39
+ left = margeset.column[0];
40
+ }
41
+ }
42
+ var iframe = {
43
+ id: generateRandomId("iframe"),
44
+ src: src,
45
+ left: left,
46
+ top: top_1,
47
+ width: 400,
48
+ height: 300
49
+ };
50
+ var index = getSheetIndex(ctx, ctx.currentSheetId);
51
+ if (index == null) return;
52
+ var file = ctx.luckysheetfile[index];
53
+ file.iframes = (file.iframes || []).concat(iframe);
54
+ ctx.insertedIframes = file.iframes;
55
+ } catch (err) {
56
+ console.info(err);
57
+ }
58
+ }
59
+ export function insertDuneChart(ctx, input) {
60
+ var embedUrl = sanitizeDuneUrl(input);
61
+ if (!embedUrl) {
62
+ console.warn("Unsupported Dune chart URL:", input);
63
+ return;
64
+ }
65
+ insertIframe(ctx, embedUrl);
66
+ }
67
+ function getIframePosition() {
68
+ var box = document.getElementById("fortune-modal-dialog-activeIframe");
69
+ if (!box) return undefined;
70
+ var _a = box.getBoundingClientRect(),
71
+ width = _a.width,
72
+ height = _a.height;
73
+ var left = box.offsetLeft;
74
+ var top = box.offsetTop;
75
+ return {
76
+ left: left,
77
+ top: top,
78
+ width: width,
79
+ height: height
80
+ };
81
+ }
82
+ export function onIframeResizeEnd(ctx, globalCache) {
83
+ var _a;
84
+ if ((_a = globalCache.iframe) === null || _a === void 0 ? void 0 : _a.resizingSide) {
85
+ globalCache.iframe = undefined;
86
+ var position = getIframePosition();
87
+ if (position) {
88
+ var iframe = _.find(ctx.insertedIframes, function (v) {
89
+ return v.id === ctx.activeIframe;
90
+ });
91
+ if (iframe) {
92
+ iframe.left = position.left / ctx.zoomRatio;
93
+ iframe.top = position.top / ctx.zoomRatio;
94
+ iframe.width = position.width / ctx.zoomRatio;
95
+ iframe.height = position.height / ctx.zoomRatio;
96
+ saveIframe(ctx);
97
+ }
98
+ }
99
+ }
100
+ }
101
+ export function onIframeMove(ctx, globalCache, e) {
102
+ if (ctx.allowEdit === false) return false;
103
+ var iframe = globalCache === null || globalCache === void 0 ? void 0 : globalCache.iframe;
104
+ var el = document.getElementById("fortune-modal-dialog-activeIframe");
105
+ if (el && iframe && !iframe.resizingSide) {
106
+ var _a = iframe.cursorMoveStartPosition,
107
+ startX = _a.x,
108
+ startY = _a.y;
109
+ var _b = iframe.iframeInitialPosition,
110
+ top_2 = _b.top,
111
+ left = _b.left;
112
+ left += e.pageX - startX;
113
+ top_2 += e.pageY - startY;
114
+ if (top_2 < 0) top_2 = 0;
115
+ el.style.left = "".concat(left, "px");
116
+ el.style.top = "".concat(top_2, "px");
117
+ return true;
118
+ }
119
+ return false;
120
+ }
121
+ export function onIframeMoveEnd(ctx, globalCache) {
122
+ var _a;
123
+ var position = getIframePosition();
124
+ if (!((_a = globalCache.iframe) === null || _a === void 0 ? void 0 : _a.resizingSide)) {
125
+ globalCache.iframe = undefined;
126
+ if (position) {
127
+ var iframe = _.find(ctx.insertedIframes, function (v) {
128
+ return v.id === ctx.activeIframe;
129
+ });
130
+ if (iframe) {
131
+ iframe.left = position.left / ctx.zoomRatio;
132
+ iframe.top = position.top / ctx.zoomRatio;
133
+ saveIframe(ctx);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ export function onIframeMoveStart(ctx, globalCache, e) {
139
+ var position = getIframePosition();
140
+ if (position) {
141
+ var top_3 = position.top,
142
+ left = position.left;
143
+ _.set(globalCache, "iframe", {
144
+ cursorMoveStartPosition: {
145
+ x: e.pageX,
146
+ y: e.pageY
147
+ },
148
+ iframeInitialPosition: {
149
+ left: left,
150
+ top: top_3
151
+ }
152
+ });
153
+ }
154
+ }
155
+ export function onIframeResize(ctx, globalCache, e) {
156
+ if (ctx.allowEdit === false) return false;
157
+ var iframe = globalCache === null || globalCache === void 0 ? void 0 : globalCache.iframe;
158
+ if (!(iframe === null || iframe === void 0 ? void 0 : iframe.resizingSide)) return false;
159
+ var container = document.getElementById("fortune-modal-dialog-activeIframe");
160
+ var content = container === null || container === void 0 ? void 0 : container.querySelector(".luckysheet-modal-dialog-content");
161
+ if (!container || !content) return false;
162
+ var _a = iframe.cursorMoveStartPosition,
163
+ startX = _a.x,
164
+ startY = _a.y;
165
+ var _b = iframe.iframeInitialPosition,
166
+ top = _b.top,
167
+ left = _b.left,
168
+ width = _b.width,
169
+ height = _b.height;
170
+ var dx = e.pageX - startX;
171
+ var dy = e.pageY - startY;
172
+ var minHeight = 60 * ctx.zoomRatio;
173
+ var minWidth = 90 * ctx.zoomRatio;
174
+ if (["lm", "lt", "lb"].includes(iframe.resizingSide)) {
175
+ if (width - dx < minWidth) {
176
+ left += width - minWidth;
177
+ width = minWidth;
178
+ } else {
179
+ left += dx;
180
+ width -= dx;
181
+ }
182
+ if (left < 0) left = 0;
183
+ container.style.left = "".concat(left, "px");
184
+ }
185
+ if (["rm", "rt", "rb"].includes(iframe.resizingSide)) {
186
+ width = width + dx < minWidth ? minWidth : width + dx;
187
+ }
188
+ if (["mt", "lt", "rt"].includes(iframe.resizingSide)) {
189
+ if (height - dy < minHeight) {
190
+ top += height - minHeight;
191
+ height = minHeight;
192
+ } else {
193
+ top += dy;
194
+ height -= dy;
195
+ }
196
+ if (top < 0) top = 0;
197
+ container.style.top = "".concat(top, "px");
198
+ }
199
+ if (["mb", "lb", "rb"].includes(iframe.resizingSide)) {
200
+ height = height + dy < minHeight ? minHeight : height + dy;
201
+ }
202
+ container.style.width = "".concat(width, "px");
203
+ container.style.height = "".concat(height, "px");
204
+ content.style.width = "".concat(width, "px");
205
+ content.style.height = "".concat(height, "px");
206
+ return true;
207
+ }
208
+ export function onIframeResizeStart(ctx, globalCache, e, resizingSide) {
209
+ var position = getIframePosition();
210
+ if (position) {
211
+ _.set(globalCache, "iframe", {
212
+ cursorMoveStartPosition: {
213
+ x: e.pageX,
214
+ y: e.pageY
215
+ },
216
+ resizingSide: resizingSide,
217
+ iframeInitialPosition: position
218
+ });
219
+ }
220
+ }