@heycys/gallery 0.0.0-stage → 0.1.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 (785) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/THIRD-PARTY-NOTICES.md +3253 -0
  4. package/assets/writing-preferences.md +107 -0
  5. package/bin/gallery.mjs +10 -0
  6. package/browser/editor/components/bookmark/icons.mjs +6 -0
  7. package/browser/editor/components/bookmark/index.mjs +80 -0
  8. package/browser/editor/components/bookmark/page.mjs +147 -0
  9. package/browser/editor/components/builders.mjs +19 -0
  10. package/browser/editor/components/callout/index.mjs +39 -0
  11. package/browser/editor/components/callout/page.mjs +13 -0
  12. package/browser/editor/components/code/index.mjs +327 -0
  13. package/browser/editor/components/code/page.mjs +561 -0
  14. package/browser/editor/components/colors.mjs +50 -0
  15. package/browser/editor/components/columns/index.mjs +104 -0
  16. package/browser/editor/components/columns/page.mjs +297 -0
  17. package/browser/editor/components/details/index.mjs +72 -0
  18. package/browser/editor/components/details/page.mjs +86 -0
  19. package/browser/editor/components/dialog/index.mjs +83 -0
  20. package/browser/editor/components/dialog/page.mjs +219 -0
  21. package/browser/editor/components/divider/index.mjs +48 -0
  22. package/browser/editor/components/embed/icons.mjs +11 -0
  23. package/browser/editor/components/embed/index.mjs +123 -0
  24. package/browser/editor/components/embed/page.mjs +309 -0
  25. package/browser/editor/components/figure/index.mjs +87 -0
  26. package/browser/editor/components/figure/page.mjs +33 -0
  27. package/browser/editor/components/file/icons.mjs +14 -0
  28. package/browser/editor/components/file/index.mjs +77 -0
  29. package/browser/editor/components/file/page.mjs +114 -0
  30. package/browser/editor/components/flowchart/add.mjs +123 -0
  31. package/browser/editor/components/flowchart/index.mjs +246 -0
  32. package/browser/editor/components/flowchart/page.mjs +453 -0
  33. package/browser/editor/components/heading/index.mjs +51 -0
  34. package/browser/editor/components/highlight/index.mjs +79 -0
  35. package/browser/editor/components/icon/index.mjs +57 -0
  36. package/browser/editor/components/icon/page.mjs +286 -0
  37. package/browser/editor/components/icons.mjs +45 -0
  38. package/browser/editor/components/image/crop.mjs +189 -0
  39. package/browser/editor/components/image/index.mjs +104 -0
  40. package/browser/editor/components/image/page.mjs +385 -0
  41. package/browser/editor/components/image/viewer.mjs +213 -0
  42. package/browser/editor/components/installed/index.mjs +133 -0
  43. package/browser/editor/components/installed/page.mjs +422 -0
  44. package/browser/editor/components/installed/served.mjs +35 -0
  45. package/browser/editor/components/kit.mjs +64 -0
  46. package/browser/editor/components/list/index.mjs +194 -0
  47. package/browser/editor/components/list/join.mjs +68 -0
  48. package/browser/editor/components/list/numbers.mjs +107 -0
  49. package/browser/editor/components/list/page.mjs +632 -0
  50. package/browser/editor/components/math/index.mjs +88 -0
  51. package/browser/editor/components/math/page.mjs +236 -0
  52. package/browser/editor/components/math/tex-logo.mjs +6 -0
  53. package/browser/editor/components/media/icons.mjs +19 -0
  54. package/browser/editor/components/media/page.mjs +162 -0
  55. package/browser/editor/components/media/parts.mjs +60 -0
  56. package/browser/editor/components/media/size.mjs +20 -0
  57. package/browser/editor/components/media/toolbar.mjs +37 -0
  58. package/browser/editor/components/media/write.mjs +7 -0
  59. package/browser/editor/components/pages.mjs +46 -0
  60. package/browser/editor/components/paragraph/index.mjs +43 -0
  61. package/browser/editor/components/paragraph/page.mjs +52 -0
  62. package/browser/editor/components/placeholder-bar.mjs +17 -0
  63. package/browser/editor/components/placeholder.mjs +128 -0
  64. package/browser/editor/components/quote/index.mjs +33 -0
  65. package/browser/editor/components/registry.mjs +833 -0
  66. package/browser/editor/components/rows.mjs +16 -0
  67. package/browser/editor/components/section/index.mjs +41 -0
  68. package/browser/editor/components/section/page.mjs +141 -0
  69. package/browser/editor/components/sheets/index.mjs +137 -0
  70. package/browser/editor/components/sheets/page.mjs +227 -0
  71. package/browser/editor/components/sheets/pills.mjs +226 -0
  72. package/browser/editor/components/table/grid.mjs +73 -0
  73. package/browser/editor/components/table/index.mjs +306 -0
  74. package/browser/editor/components/table/page.mjs +672 -0
  75. package/browser/editor/components/table/slots.mjs +41 -0
  76. package/browser/editor/components/widget/index.mjs +50 -0
  77. package/browser/editor/page/annotate/anchors.mjs +229 -0
  78. package/browser/editor/page/annotate/card.mjs +102 -0
  79. package/browser/editor/page/annotate/index.mjs +1629 -0
  80. package/browser/editor/page/at-menu/index.mjs +317 -0
  81. package/browser/editor/page/autosave.mjs +977 -0
  82. package/browser/editor/page/beside.mjs +21 -0
  83. package/browser/editor/page/block-info.mjs +63 -0
  84. package/browser/editor/page/block-menu/colors.mjs +82 -0
  85. package/browser/editor/page/block-menu/index.mjs +215 -0
  86. package/browser/editor/page/blocks.mjs +246 -0
  87. package/browser/editor/page/caret.mjs +679 -0
  88. package/browser/editor/page/chip-fills.mjs +126 -0
  89. package/browser/editor/page/clipboard/import/colors.mjs +192 -0
  90. package/browser/editor/page/clipboard/import/html.mjs +792 -0
  91. package/browser/editor/page/clipboard/import/inline.mjs +232 -0
  92. package/browser/editor/page/clipboard/import/languages.mjs +42 -0
  93. package/browser/editor/page/clipboard/import/markdown.mjs +760 -0
  94. package/browser/editor/page/clipboard/import/math.mjs +100 -0
  95. package/browser/editor/page/clipboard/import/office.mjs +245 -0
  96. package/browser/editor/page/clipboard/import/read.mjs +120 -0
  97. package/browser/editor/page/clipboard/import/rich.mjs +29 -0
  98. package/browser/editor/page/clipboard/import/to-blocks.mjs +290 -0
  99. package/browser/editor/page/clipboard/index.mjs +797 -0
  100. package/browser/editor/page/clipboard/own/blocks.mjs +202 -0
  101. package/browser/editor/page/clipboard/own/chart-keys.mjs +58 -0
  102. package/browser/editor/page/clipboard/own/describe.mjs +115 -0
  103. package/browser/editor/page/clipboard/own/export.mjs +167 -0
  104. package/browser/editor/page/clipboard/own/ids.mjs +39 -0
  105. package/browser/editor/page/clipboard/own/index.mjs +13 -0
  106. package/browser/editor/page/clipboard/own/rules.mjs +44 -0
  107. package/browser/editor/page/clipboard/own/selection.mjs +159 -0
  108. package/browser/editor/page/clipboard/own/writers.mjs +326 -0
  109. package/browser/editor/page/columns/index.mjs +360 -0
  110. package/browser/editor/page/commit.mjs +1798 -0
  111. package/browser/editor/page/conflicts.mjs +269 -0
  112. package/browser/editor/page/convert.mjs +830 -0
  113. package/browser/editor/page/core.mjs +1655 -0
  114. package/browser/editor/page/drag/drop.mjs +307 -0
  115. package/browser/editor/page/drag/index.mjs +335 -0
  116. package/browser/editor/page/drag/preview.mjs +121 -0
  117. package/browser/editor/page/edge-scroll.mjs +50 -0
  118. package/browser/editor/page/editor.mjs +1725 -0
  119. package/browser/editor/page/emoji-picker/emoji-tab.mjs +278 -0
  120. package/browser/editor/page/emoji-picker/glyph-html.mjs +26 -0
  121. package/browser/editor/page/emoji-picker/grid.mjs +79 -0
  122. package/browser/editor/page/emoji-picker/icon-tab.mjs +217 -0
  123. package/browser/editor/page/emoji-picker/icons.mjs +32 -0
  124. package/browser/editor/page/emoji-picker/index.mjs +164 -0
  125. package/browser/editor/page/emoji-picker/styles.mjs +2 -0
  126. package/browser/editor/page/emoji-picker/support.mjs +202 -0
  127. package/browser/editor/page/emoji-picker/upload.mjs +235 -0
  128. package/browser/editor/page/export-report.mjs +23 -0
  129. package/browser/editor/page/fills.mjs +60 -0
  130. package/browser/editor/page/find/index.mjs +107 -0
  131. package/browser/editor/page/flags.mjs +70 -0
  132. package/browser/editor/page/format-bar/bar.mjs +448 -0
  133. package/browser/editor/page/format-bar/brush.mjs +77 -0
  134. package/browser/editor/page/format-bar/colors.mjs +46 -0
  135. package/browser/editor/page/format-bar/index.mjs +404 -0
  136. package/browser/editor/page/formula/index.mjs +236 -0
  137. package/browser/editor/page/formula/panel.mjs +336 -0
  138. package/browser/editor/page/formula/symbols.mjs +156 -0
  139. package/browser/editor/page/frame.mjs +74 -0
  140. package/browser/editor/page/frames.mjs +196 -0
  141. package/browser/editor/page/geometry.mjs +400 -0
  142. package/browser/editor/page/gesture.mjs +45 -0
  143. package/browser/editor/page/handle/index.mjs +639 -0
  144. package/browser/editor/page/handle-sizes.mjs +14 -0
  145. package/browser/editor/page/hints/index.mjs +84 -0
  146. package/browser/editor/page/history.mjs +401 -0
  147. package/browser/editor/page/insert/index.mjs +243 -0
  148. package/browser/editor/page/kept.mjs +38 -0
  149. package/browser/editor/page/links/address.mjs +40 -0
  150. package/browser/editor/page/links/index.mjs +866 -0
  151. package/browser/editor/page/links/pages.mjs +131 -0
  152. package/browser/editor/page/links/views.mjs +369 -0
  153. package/browser/editor/page/look.mjs +65 -0
  154. package/browser/editor/page/made.mjs +24 -0
  155. package/browser/editor/page/margin.mjs +352 -0
  156. package/browser/editor/page/markdown/index.mjs +88 -0
  157. package/browser/editor/page/markdown/rules.mjs +33 -0
  158. package/browser/editor/page/marks.mjs +377 -0
  159. package/browser/editor/page/media-menu/index.mjs +158 -0
  160. package/browser/editor/page/menu.mjs +500 -0
  161. package/browser/editor/page/merge.mjs +100 -0
  162. package/browser/editor/page/notices.mjs +142 -0
  163. package/browser/editor/page/offered.mjs +32 -0
  164. package/browser/editor/page/outline/folds.mjs +52 -0
  165. package/browser/editor/page/outline/index.mjs +697 -0
  166. package/browser/editor/page/outline/list.mjs +172 -0
  167. package/browser/editor/page/outline/read.mjs +201 -0
  168. package/browser/editor/page/outline/strip.mjs +281 -0
  169. package/browser/editor/page/outline/tree.mjs +248 -0
  170. package/browser/editor/page/overlay-layer.mjs +227 -0
  171. package/browser/editor/page/overlays.mjs +205 -0
  172. package/browser/editor/page/own.mjs +28 -0
  173. package/browser/editor/page/pads.mjs +71 -0
  174. package/browser/editor/page/page-objects.mjs +105 -0
  175. package/browser/editor/page/panel.mjs +64 -0
  176. package/browser/editor/page/placement.mjs +58 -0
  177. package/browser/editor/page/post.mjs +41 -0
  178. package/browser/editor/page/present-links.mjs +50 -0
  179. package/browser/editor/page/quiet.mjs +48 -0
  180. package/browser/editor/page/resize/index.mjs +327 -0
  181. package/browser/editor/page/select-all/index.mjs +262 -0
  182. package/browser/editor/page/selection/delete.mjs +59 -0
  183. package/browser/editor/page/selection/index.mjs +157 -0
  184. package/browser/editor/page/selection/marquee.mjs +174 -0
  185. package/browser/editor/page/session.mjs +117 -0
  186. package/browser/editor/page/slash-menu/index.mjs +291 -0
  187. package/browser/editor/page/storage.mjs +48 -0
  188. package/browser/editor/page/sync-state.mjs +267 -0
  189. package/browser/editor/page/table/aligns.mjs +29 -0
  190. package/browser/editor/page/table/cell-bar.mjs +138 -0
  191. package/browser/editor/page/table/cells.mjs +527 -0
  192. package/browser/editor/page/table/icons.mjs +40 -0
  193. package/browser/editor/page/table/index.mjs +985 -0
  194. package/browser/editor/page/table/lists.mjs +187 -0
  195. package/browser/editor/page/table/widths.mjs +308 -0
  196. package/browser/editor/page/tex.mjs +32 -0
  197. package/browser/editor/page/text-select/index.mjs +656 -0
  198. package/browser/editor/page/tooltip.mjs +98 -0
  199. package/browser/editor/page/type-grid.mjs +82 -0
  200. package/browser/editor/page/typing/code-edges.mjs +228 -0
  201. package/browser/editor/page/typing/index.mjs +276 -0
  202. package/browser/editor/page/typing/leave.mjs +68 -0
  203. package/browser/editor/page/ui.mjs +160 -0
  204. package/browser/shared/annotations.mjs +571 -0
  205. package/browser/shared/code-folds.mjs +10 -0
  206. package/browser/shared/code-languages.mjs +70 -0
  207. package/browser/shared/code-lines.mjs +30 -0
  208. package/browser/shared/colors.mjs +28 -0
  209. package/browser/shared/component-catalog.mjs +559 -0
  210. package/browser/shared/components/bookmark.mjs +26 -0
  211. package/browser/shared/components/callout.mjs +7 -0
  212. package/browser/shared/components/chart.mjs +20 -0
  213. package/browser/shared/components/code.mjs +37 -0
  214. package/browser/shared/components/columns.mjs +16 -0
  215. package/browser/shared/components/details.mjs +15 -0
  216. package/browser/shared/components/dialog.mjs +28 -0
  217. package/browser/shared/components/diff.mjs +18 -0
  218. package/browser/shared/components/divider.mjs +6 -0
  219. package/browser/shared/components/embed.mjs +25 -0
  220. package/browser/shared/components/figure.mjs +14 -0
  221. package/browser/shared/components/file.mjs +23 -0
  222. package/browser/shared/components/heading.mjs +6 -0
  223. package/browser/shared/components/highlight.mjs +9 -0
  224. package/browser/shared/components/icon.mjs +18 -0
  225. package/browser/shared/components/image.mjs +39 -0
  226. package/browser/shared/components/index.mjs +342 -0
  227. package/browser/shared/components/installed.mjs +162 -0
  228. package/browser/shared/components/list.mjs +146 -0
  229. package/browser/shared/components/math.mjs +49 -0
  230. package/browser/shared/components/mention.mjs +33 -0
  231. package/browser/shared/components/page.mjs +37 -0
  232. package/browser/shared/components/paragraph.mjs +9 -0
  233. package/browser/shared/components/quote.mjs +6 -0
  234. package/browser/shared/components/section.mjs +8 -0
  235. package/browser/shared/components/sheets.mjs +80 -0
  236. package/browser/shared/components/state.mjs +20 -0
  237. package/browser/shared/components/table.mjs +49 -0
  238. package/browser/shared/components/text.mjs +14 -0
  239. package/browser/shared/components/widget.mjs +10 -0
  240. package/browser/shared/copy-ids.mjs +72 -0
  241. package/browser/shared/css-references.mjs +110 -0
  242. package/browser/shared/emoji/custom.mjs +91 -0
  243. package/browser/shared/emoji/data/LICENSE-mingcute.txt +202 -0
  244. package/browser/shared/emoji/data/LICENSE-tabler.txt +21 -0
  245. package/browser/shared/emoji/data/README.md +26 -0
  246. package/browser/shared/emoji/data/categories.json +1 -0
  247. package/browser/shared/emoji/data/icons.json +1 -0
  248. package/browser/shared/emoji/data/keywords-en.json +1 -0
  249. package/browser/shared/emoji/data/keywords-zh.json +1 -0
  250. package/browser/shared/emoji/data/names.json +1 -0
  251. package/browser/shared/emoji/data/positions.json +1 -0
  252. package/browser/shared/emoji/data/twemoji-index.json +1 -0
  253. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  254. package/browser/shared/emoji/data.mjs +196 -0
  255. package/browser/shared/emoji/emoji.mjs +37 -0
  256. package/browser/shared/emoji/glyphs.mjs +134 -0
  257. package/browser/shared/emoji/icon-value.mjs +90 -0
  258. package/browser/shared/escape.mjs +20 -0
  259. package/browser/shared/export-wrap.mjs +89 -0
  260. package/browser/shared/files.mjs +33 -0
  261. package/browser/shared/html-tree.mjs +53 -0
  262. package/browser/shared/http.mjs +22 -0
  263. package/browser/shared/i18n/en.mjs +1164 -0
  264. package/browser/shared/i18n/index.mjs +132 -0
  265. package/browser/shared/ids.mjs +24 -0
  266. package/browser/shared/import-types.mjs +23 -0
  267. package/browser/shared/inline-spacing.mjs +97 -0
  268. package/browser/shared/layers.mjs +42 -0
  269. package/browser/shared/media.mjs +162 -0
  270. package/browser/shared/new-names.mjs +64 -0
  271. package/browser/shared/number-reading.mjs +92 -0
  272. package/browser/shared/old-names.mjs +143 -0
  273. package/browser/shared/page-address.mjs +140 -0
  274. package/browser/shared/page-links.mjs +86 -0
  275. package/browser/shared/paths.mjs +73 -0
  276. package/browser/shared/preferences.mjs +110 -0
  277. package/browser/shared/preview-server.mjs +247 -0
  278. package/browser/shared/qa-levels.mjs +93 -0
  279. package/browser/shared/reading-place.mjs +91 -0
  280. package/browser/shared/renamed-storage.mjs +220 -0
  281. package/browser/shared/reports.mjs +46 -0
  282. package/browser/shared/search.mjs +85 -0
  283. package/browser/shared/session.mjs +76 -0
  284. package/browser/shared/table-chart.mjs +113 -0
  285. package/browser/shared/table-hides.mjs +120 -0
  286. package/browser/shared/table-slots.mjs +75 -0
  287. package/browser/shared/words.mjs +23 -0
  288. package/browser/shared/workspace.mjs +535 -0
  289. package/browser/shared/writing-preferences.mjs +68 -0
  290. package/browser/shared/zoom.mjs +57 -0
  291. package/dist/chunk-2B5E4CDJ.mjs +2 -0
  292. package/dist/chunk-2PBALTR3.mjs +57 -0
  293. package/dist/chunk-342HXE3Q.mjs +2 -0
  294. package/dist/chunk-3LA3EMDE.mjs +15 -0
  295. package/dist/chunk-43B75J5T.mjs +2 -0
  296. package/dist/chunk-4K5KC6V2.mjs +2 -0
  297. package/dist/chunk-5FRMCDPY.mjs +16 -0
  298. package/dist/chunk-5L7RYZCL.mjs +2 -0
  299. package/dist/chunk-5LEK2CBS.mjs +2 -0
  300. package/dist/chunk-5OFN5AHC.mjs +2 -0
  301. package/dist/chunk-5SIYS5HN.mjs +2 -0
  302. package/dist/chunk-5TEK3RAD.mjs +2 -0
  303. package/dist/chunk-6CYG3Z4V.mjs +2 -0
  304. package/dist/chunk-6U2SLSDN.mjs +3 -0
  305. package/dist/chunk-742D2WWJ.mjs +19 -0
  306. package/dist/chunk-7GHT2UCA.mjs +15 -0
  307. package/dist/chunk-7QQBR7PB.mjs +2 -0
  308. package/dist/chunk-A55HN5OK.mjs +2 -0
  309. package/dist/chunk-ACOPDCNB.mjs +2 -0
  310. package/dist/chunk-AGDILNWB.mjs +2 -0
  311. package/dist/chunk-ATCJYAR4.mjs +2 -0
  312. package/dist/chunk-B3VTYBYR.mjs +960 -0
  313. package/dist/chunk-C564NU2H.mjs +77 -0
  314. package/dist/chunk-C7HWOBIF.mjs +2 -0
  315. package/dist/chunk-DB4WKGYF.mjs +7 -0
  316. package/dist/chunk-E7VYDG2X.mjs +2 -0
  317. package/dist/chunk-EUX7IC5J.mjs +48 -0
  318. package/dist/chunk-EVJ3BX3M.mjs +2 -0
  319. package/dist/chunk-EZY3WC6Z.mjs +15 -0
  320. package/dist/chunk-FQGQH4KM.mjs +2 -0
  321. package/dist/chunk-G7TOXONE.mjs +6 -0
  322. package/dist/chunk-GPF4YWWB.mjs +9 -0
  323. package/dist/chunk-GRAXKKG4.mjs +2 -0
  324. package/dist/chunk-GYQV7Y4J.mjs +120 -0
  325. package/dist/chunk-HMHK3EQ6.mjs +2 -0
  326. package/dist/chunk-HQQMJCQJ.mjs +10 -0
  327. package/dist/chunk-HYMEEXKN.mjs +4 -0
  328. package/dist/chunk-IERUOGC3.mjs +6 -0
  329. package/dist/chunk-ITNLYXXV.mjs +3 -0
  330. package/dist/chunk-L4DVONOG.mjs +2 -0
  331. package/dist/chunk-LAE5NQ4B.mjs +2 -0
  332. package/dist/chunk-LC7YNQFG.mjs +2 -0
  333. package/dist/chunk-LHTFLRB6.mjs +4 -0
  334. package/dist/chunk-LKX55H76.mjs +2 -0
  335. package/dist/chunk-MAFIGVXY.mjs +2 -0
  336. package/dist/chunk-NFIBI4IP.mjs +26 -0
  337. package/dist/chunk-NSKUTQ5J.mjs +5 -0
  338. package/dist/chunk-O52JMOCZ.mjs +2 -0
  339. package/dist/chunk-P2CAZPDP.mjs +3 -0
  340. package/dist/chunk-QAIHRH3I.mjs +13 -0
  341. package/dist/chunk-QMQUXTU4.mjs +12 -0
  342. package/dist/chunk-QR6A54KJ.mjs +3 -0
  343. package/dist/chunk-QVWVFC5K.mjs +6 -0
  344. package/dist/chunk-QYKCJ7FG.mjs +8 -0
  345. package/dist/chunk-QZY6Q64C.mjs +2 -0
  346. package/dist/chunk-TDQP3DKQ.mjs +10 -0
  347. package/dist/chunk-TMYZB6AV.mjs +2 -0
  348. package/dist/chunk-TX6JH7TR.mjs +2 -0
  349. package/dist/chunk-U3SSPL4K.mjs +8 -0
  350. package/dist/chunk-UH4SIXTR.mjs +2 -0
  351. package/dist/chunk-UNUEWH4S.mjs +2 -0
  352. package/dist/chunk-UXUK4PMC.mjs +27 -0
  353. package/dist/chunk-V4CPWKMZ.mjs +2 -0
  354. package/dist/chunk-V6XZ4VIR.mjs +2 -0
  355. package/dist/chunk-VACRB2NE.mjs +3 -0
  356. package/dist/chunk-W63L7367.mjs +7 -0
  357. package/dist/chunk-W7CXPCRV.mjs +6 -0
  358. package/dist/chunk-W7XHE4CT.mjs +2 -0
  359. package/dist/chunk-XINNG4F2.mjs +4 -0
  360. package/dist/chunk-Y34NR5JL.mjs +2 -0
  361. package/dist/chunk-YEY3RSFQ.mjs +2 -0
  362. package/dist/chunk-YL2DPWVS.mjs +4 -0
  363. package/dist/chunk-YXAUQPVK.mjs +8 -0
  364. package/dist/chunk-YZ5Z6H4W.mjs +4 -0
  365. package/dist/chunk-Z52HTUW7.mjs +4 -0
  366. package/dist/chunk-ZBIM6ARY.mjs +216 -0
  367. package/dist/cli.mjs +2 -0
  368. package/dist/server.mjs +2 -0
  369. package/dist/worker.mjs +5 -0
  370. package/kit/charts.js +355 -0
  371. package/kit/code.js +164 -0
  372. package/kit/dialogs.js +157 -0
  373. package/kit/math.js +1988 -0
  374. package/kit/report.css +2821 -0
  375. package/kit/runtime.js +1707 -0
  376. package/kit/sheets.js +123 -0
  377. package/kit/state.js +217 -0
  378. package/kit/tables.js +1449 -0
  379. package/kit/tokens.js +29 -0
  380. package/kit/ui.js +561 -0
  381. package/package.json +41 -4
  382. package/release.json +25 -0
  383. package/sdk/column-widths.d.ts +56 -0
  384. package/sdk/doc-charts.d.ts +82 -0
  385. package/sdk/doc-code.d.ts +28 -0
  386. package/sdk/doc-dialogs.d.ts +4 -0
  387. package/sdk/doc-kit.d.ts +141 -0
  388. package/sdk/doc-math.d.ts +3 -0
  389. package/sdk/doc-sheets.d.ts +15 -0
  390. package/sdk/doc-state.d.ts +41 -0
  391. package/sdk/doc-tables.d.ts +24 -0
  392. package/sdk/doc-tokens.d.ts +22 -0
  393. package/sdk/index.d.ts +30 -0
  394. package/skill/SKILL.md +138 -0
  395. package/skill/agents/openai.yaml +5 -0
  396. package/skill/references/building-components.md +327 -0
  397. package/skill/references/example-report.html +356 -0
  398. package/skill/references/writing-html.md +187 -0
  399. package/skill/sdk/column-widths.d.ts +56 -0
  400. package/skill/sdk/doc-charts.d.ts +82 -0
  401. package/skill/sdk/doc-code.d.ts +28 -0
  402. package/skill/sdk/doc-dialogs.d.ts +4 -0
  403. package/skill/sdk/doc-kit.d.ts +141 -0
  404. package/skill/sdk/doc-math.d.ts +3 -0
  405. package/skill/sdk/doc-sheets.d.ts +15 -0
  406. package/skill/sdk/doc-state.d.ts +41 -0
  407. package/skill/sdk/doc-tables.d.ts +24 -0
  408. package/skill/sdk/doc-tokens.d.ts +22 -0
  409. package/skill/sdk/index.d.ts +30 -0
  410. package/starter/doc.html +21 -0
  411. package/starter/doc.json +5 -0
  412. package/vendor/d3.v7.9.0.min.js +2 -0
  413. package/vendor/katex/auto-render.min.js +1 -0
  414. package/vendor/katex/contrib/mhchem.min.js +1 -0
  415. package/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  416. package/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  417. package/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  418. package/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  419. package/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  420. package/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  421. package/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  422. package/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  423. package/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  424. package/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  425. package/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  426. package/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  427. package/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  428. package/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  429. package/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  430. package/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  431. package/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  432. package/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  433. package/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  434. package/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  435. package/vendor/katex/katex.min.css +1 -0
  436. package/vendor/katex/katex.min.js +1 -0
  437. package/vendor/pdfjs/LICENSE +177 -0
  438. package/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  439. package/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  440. package/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  441. package/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  442. package/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  443. package/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  444. package/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  445. package/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  446. package/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  447. package/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  448. package/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  449. package/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  450. package/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  451. package/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  452. package/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  453. package/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  454. package/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  455. package/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  456. package/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  457. package/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  458. package/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  459. package/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  460. package/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  461. package/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  462. package/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  463. package/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  464. package/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  465. package/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  466. package/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  467. package/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  468. package/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  469. package/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  470. package/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  471. package/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  472. package/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  473. package/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  474. package/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  475. package/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  476. package/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  477. package/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  478. package/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  479. package/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  480. package/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  481. package/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  482. package/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  483. package/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  484. package/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  485. package/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  486. package/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  487. package/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  488. package/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  489. package/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  490. package/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  491. package/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  492. package/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  493. package/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  494. package/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  495. package/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  496. package/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  497. package/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  498. package/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  499. package/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  500. package/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  501. package/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  502. package/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  503. package/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  504. package/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  505. package/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  506. package/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  507. package/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  508. package/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  509. package/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  510. package/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  511. package/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  512. package/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  513. package/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  514. package/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  515. package/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  516. package/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  517. package/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  518. package/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  519. package/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  520. package/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  521. package/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  522. package/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  523. package/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  524. package/vendor/pdfjs/cmaps/H.bcmap +0 -0
  525. package/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  526. package/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  527. package/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  528. package/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  529. package/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  530. package/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  531. package/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  532. package/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  533. package/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  534. package/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  535. package/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  536. package/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  537. package/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  538. package/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  539. package/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  540. package/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  541. package/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  542. package/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  543. package/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  544. package/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  545. package/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  546. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  547. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  548. package/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  549. package/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  550. package/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  551. package/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  552. package/vendor/pdfjs/cmaps/LICENSE +36 -0
  553. package/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  554. package/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  555. package/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  556. package/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  557. package/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  558. package/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  559. package/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  560. package/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  561. package/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  562. package/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  563. package/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  564. package/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  565. package/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  566. package/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  567. package/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  568. package/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  569. package/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  570. package/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  571. package/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  572. package/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  573. package/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  574. package/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  575. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  576. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  577. package/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  578. package/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  579. package/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  580. package/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  581. package/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  582. package/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  583. package/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  584. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  585. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  586. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  587. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  588. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  589. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  590. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  591. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  592. package/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  593. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  594. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  595. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  596. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  597. package/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  598. package/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  599. package/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  600. package/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  601. package/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  602. package/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  603. package/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  604. package/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  605. package/vendor/pdfjs/cmaps/V.bcmap +0 -0
  606. package/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  607. package/vendor/pdfjs/legacy/build/pdf.min.mjs +27 -0
  608. package/vendor/pdfjs/legacy/build/pdf.worker.min.mjs +27 -0
  609. package/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  610. package/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  611. package/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  612. package/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  613. package/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  614. package/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  615. package/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  616. package/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  617. package/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  618. package/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  619. package/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  620. package/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  621. package/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  622. package/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  623. package/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  624. package/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  625. package/vendor/types/@types/d3/LICENSE +21 -0
  626. package/vendor/types/@types/d3/index.d.ts +39 -0
  627. package/vendor/types/@types/d3/package.json +81 -0
  628. package/vendor/types/@types/d3-array/LICENSE +21 -0
  629. package/vendor/types/@types/d3-array/index.d.ts +1118 -0
  630. package/vendor/types/@types/d3-array/package.json +56 -0
  631. package/vendor/types/@types/d3-axis/LICENSE +21 -0
  632. package/vendor/types/@types/d3-axis/index.d.ts +293 -0
  633. package/vendor/types/@types/d3-axis/package.json +47 -0
  634. package/vendor/types/@types/d3-brush/LICENSE +21 -0
  635. package/vendor/types/@types/d3-brush/index.d.ts +255 -0
  636. package/vendor/types/@types/d3-brush/package.json +42 -0
  637. package/vendor/types/@types/d3-chord/LICENSE +21 -0
  638. package/vendor/types/@types/d3-chord/index.d.ts +471 -0
  639. package/vendor/types/@types/d3-chord/package.json +40 -0
  640. package/vendor/types/@types/d3-color/LICENSE +21 -0
  641. package/vendor/types/@types/d3-color/index.d.ts +669 -0
  642. package/vendor/types/@types/d3-color/package.json +55 -0
  643. package/vendor/types/@types/d3-contour/LICENSE +21 -0
  644. package/vendor/types/@types/d3-contour/index.d.ts +222 -0
  645. package/vendor/types/@types/d3-contour/package.json +38 -0
  646. package/vendor/types/@types/d3-delaunay/LICENSE +21 -0
  647. package/vendor/types/@types/d3-delaunay/index.d.ts +316 -0
  648. package/vendor/types/@types/d3-delaunay/package.json +30 -0
  649. package/vendor/types/@types/d3-dispatch/LICENSE +21 -0
  650. package/vendor/types/@types/d3-dispatch/index.d.ts +96 -0
  651. package/vendor/types/@types/d3-dispatch/package.json +51 -0
  652. package/vendor/types/@types/d3-drag/LICENSE +21 -0
  653. package/vendor/types/@types/d3-drag/index.d.ts +395 -0
  654. package/vendor/types/@types/d3-drag/package.json +42 -0
  655. package/vendor/types/@types/d3-dsv/LICENSE +21 -0
  656. package/vendor/types/@types/d3-dsv/index.d.ts +482 -0
  657. package/vendor/types/@types/d3-dsv/package.json +45 -0
  658. package/vendor/types/@types/d3-ease/LICENSE +21 -0
  659. package/vendor/types/@types/d3-ease/index.d.ts +316 -0
  660. package/vendor/types/@types/d3-ease/package.json +40 -0
  661. package/vendor/types/@types/d3-fetch/LICENSE +21 -0
  662. package/vendor/types/@types/d3-fetch/index.d.ts +282 -0
  663. package/vendor/types/@types/d3-fetch/package.json +37 -0
  664. package/vendor/types/@types/d3-force/LICENSE +21 -0
  665. package/vendor/types/@types/d3-force/index.d.ts +899 -0
  666. package/vendor/types/@types/d3-force/package.json +45 -0
  667. package/vendor/types/@types/d3-format/LICENSE +21 -0
  668. package/vendor/types/@types/d3-format/index.d.ts +337 -0
  669. package/vendor/types/@types/d3-format/package.json +45 -0
  670. package/vendor/types/@types/d3-geo/LICENSE +21 -0
  671. package/vendor/types/@types/d3-geo/index.d.ts +1371 -0
  672. package/vendor/types/@types/d3-geo/package.json +48 -0
  673. package/vendor/types/@types/d3-hierarchy/LICENSE +21 -0
  674. package/vendor/types/@types/d3-hierarchy/index.d.ts +928 -0
  675. package/vendor/types/@types/d3-hierarchy/package.json +50 -0
  676. package/vendor/types/@types/d3-interpolate/LICENSE +21 -0
  677. package/vendor/types/@types/d3-interpolate/index.d.ts +387 -0
  678. package/vendor/types/@types/d3-interpolate/package.json +47 -0
  679. package/vendor/types/@types/d3-path/LICENSE +21 -0
  680. package/vendor/types/@types/d3-path/index.d.ts +108 -0
  681. package/vendor/types/@types/d3-path/package.json +41 -0
  682. package/vendor/types/@types/d3-polygon/LICENSE +21 -0
  683. package/vendor/types/@types/d3-polygon/index.d.ts +41 -0
  684. package/vendor/types/@types/d3-polygon/package.json +40 -0
  685. package/vendor/types/@types/d3-quadtree/LICENSE +21 -0
  686. package/vendor/types/@types/d3-quadtree/index.d.ts +204 -0
  687. package/vendor/types/@types/d3-quadtree/package.json +45 -0
  688. package/vendor/types/@types/d3-random/LICENSE +21 -0
  689. package/vendor/types/@types/d3-random/index.d.ts +313 -0
  690. package/vendor/types/@types/d3-random/package.json +41 -0
  691. package/vendor/types/@types/d3-scale/LICENSE +21 -0
  692. package/vendor/types/@types/d3-scale/index.d.ts +2669 -0
  693. package/vendor/types/@types/d3-scale/package.json +53 -0
  694. package/vendor/types/@types/d3-scale-chromatic/LICENSE +21 -0
  695. package/vendor/types/@types/d3-scale-chromatic/index.d.ts +520 -0
  696. package/vendor/types/@types/d3-scale-chromatic/package.json +46 -0
  697. package/vendor/types/@types/d3-selection/LICENSE +21 -0
  698. package/vendor/types/@types/d3-selection/index.d.ts +1210 -0
  699. package/vendor/types/@types/d3-selection/package.json +56 -0
  700. package/vendor/types/@types/d3-shape/LICENSE +21 -0
  701. package/vendor/types/@types/d3-shape/index.d.ts +2792 -0
  702. package/vendor/types/@types/d3-shape/package.json +53 -0
  703. package/vendor/types/@types/d3-time/LICENSE +21 -0
  704. package/vendor/types/@types/d3-time/index.d.ts +697 -0
  705. package/vendor/types/@types/d3-time/package.json +46 -0
  706. package/vendor/types/@types/d3-time-format/LICENSE +21 -0
  707. package/vendor/types/@types/d3-time-format/index.d.ts +202 -0
  708. package/vendor/types/@types/d3-time-format/package.json +40 -0
  709. package/vendor/types/@types/d3-timer/LICENSE +21 -0
  710. package/vendor/types/@types/d3-timer/index.d.ts +68 -0
  711. package/vendor/types/@types/d3-timer/package.json +45 -0
  712. package/vendor/types/@types/d3-transition/LICENSE +21 -0
  713. package/vendor/types/@types/d3-transition/index.d.ts +664 -0
  714. package/vendor/types/@types/d3-transition/package.json +47 -0
  715. package/vendor/types/@types/d3-zoom/LICENSE +21 -0
  716. package/vendor/types/@types/d3-zoom/index.d.ts +611 -0
  717. package/vendor/types/@types/d3-zoom/package.json +48 -0
  718. package/vendor/types/@types/geojson/LICENSE +21 -0
  719. package/vendor/types/@types/geojson/index.d.ts +202 -0
  720. package/vendor/types/@types/geojson/package.json +46 -0
  721. package/vendor/typescript/LICENSE.txt +55 -0
  722. package/vendor/typescript/lib.decorators.d.ts +384 -0
  723. package/vendor/typescript/lib.decorators.legacy.d.ts +22 -0
  724. package/vendor/typescript/lib.dom.d.ts +39429 -0
  725. package/vendor/typescript/lib.dom.iterable.d.ts +571 -0
  726. package/vendor/typescript/lib.es2015.collection.d.ts +147 -0
  727. package/vendor/typescript/lib.es2015.core.d.ts +597 -0
  728. package/vendor/typescript/lib.es2015.d.ts +28 -0
  729. package/vendor/typescript/lib.es2015.generator.d.ts +77 -0
  730. package/vendor/typescript/lib.es2015.iterable.d.ts +605 -0
  731. package/vendor/typescript/lib.es2015.promise.d.ts +81 -0
  732. package/vendor/typescript/lib.es2015.proxy.d.ts +128 -0
  733. package/vendor/typescript/lib.es2015.reflect.d.ts +144 -0
  734. package/vendor/typescript/lib.es2015.symbol.d.ts +46 -0
  735. package/vendor/typescript/lib.es2015.symbol.wellknown.d.ts +326 -0
  736. package/vendor/typescript/lib.es2016.array.include.d.ts +116 -0
  737. package/vendor/typescript/lib.es2016.d.ts +21 -0
  738. package/vendor/typescript/lib.es2016.intl.d.ts +31 -0
  739. package/vendor/typescript/lib.es2017.arraybuffer.d.ts +21 -0
  740. package/vendor/typescript/lib.es2017.d.ts +26 -0
  741. package/vendor/typescript/lib.es2017.date.d.ts +31 -0
  742. package/vendor/typescript/lib.es2017.intl.d.ts +44 -0
  743. package/vendor/typescript/lib.es2017.object.d.ts +49 -0
  744. package/vendor/typescript/lib.es2017.sharedmemory.d.ts +135 -0
  745. package/vendor/typescript/lib.es2017.string.d.ts +45 -0
  746. package/vendor/typescript/lib.es2017.typedarrays.d.ts +53 -0
  747. package/vendor/typescript/lib.es2018.asyncgenerator.d.ts +77 -0
  748. package/vendor/typescript/lib.es2018.asynciterable.d.ts +53 -0
  749. package/vendor/typescript/lib.es2018.d.ts +24 -0
  750. package/vendor/typescript/lib.es2018.intl.d.ts +83 -0
  751. package/vendor/typescript/lib.es2018.promise.d.ts +30 -0
  752. package/vendor/typescript/lib.es2018.regexp.d.ts +37 -0
  753. package/vendor/typescript/lib.es2019.array.d.ts +79 -0
  754. package/vendor/typescript/lib.es2019.d.ts +24 -0
  755. package/vendor/typescript/lib.es2019.intl.d.ts +23 -0
  756. package/vendor/typescript/lib.es2019.object.d.ts +33 -0
  757. package/vendor/typescript/lib.es2019.string.d.ts +37 -0
  758. package/vendor/typescript/lib.es2019.symbol.d.ts +24 -0
  759. package/vendor/typescript/lib.es2020.bigint.d.ts +765 -0
  760. package/vendor/typescript/lib.es2020.d.ts +27 -0
  761. package/vendor/typescript/lib.es2020.date.d.ts +42 -0
  762. package/vendor/typescript/lib.es2020.intl.d.ts +474 -0
  763. package/vendor/typescript/lib.es2020.number.d.ts +28 -0
  764. package/vendor/typescript/lib.es2020.promise.d.ts +47 -0
  765. package/vendor/typescript/lib.es2020.sharedmemory.d.ts +99 -0
  766. package/vendor/typescript/lib.es2020.string.d.ts +44 -0
  767. package/vendor/typescript/lib.es2020.symbol.wellknown.d.ts +41 -0
  768. package/vendor/typescript/lib.es2021.d.ts +23 -0
  769. package/vendor/typescript/lib.es2021.intl.d.ts +166 -0
  770. package/vendor/typescript/lib.es2021.promise.d.ts +48 -0
  771. package/vendor/typescript/lib.es2021.string.d.ts +33 -0
  772. package/vendor/typescript/lib.es2021.weakref.d.ts +78 -0
  773. package/vendor/typescript/lib.es2022.array.d.ts +121 -0
  774. package/vendor/typescript/lib.es2022.d.ts +25 -0
  775. package/vendor/typescript/lib.es2022.error.d.ts +75 -0
  776. package/vendor/typescript/lib.es2022.intl.d.ts +145 -0
  777. package/vendor/typescript/lib.es2022.object.d.ts +26 -0
  778. package/vendor/typescript/lib.es2022.regexp.d.ts +39 -0
  779. package/vendor/typescript/lib.es2022.string.d.ts +25 -0
  780. package/vendor/typescript/lib.es5.d.ts +4601 -0
  781. package/vendor/typescript/package.json +4 -0
  782. package/vendor/typescript/typescript.js +446 -0
  783. package/web/assets/index-B6Ai3wsa.js +13 -0
  784. package/web/assets/index-SYPC3EZy.css +1 -0
  785. package/web/index.html +14 -0
@@ -0,0 +1,307 @@
1
+ // Where dragged blocks go (docs/editor.md, "Moving blocks"): a pure function of the tree
2
+ // geometry.mjs measure() reads (no DOM is read here: an empty box's place is its `content` rect), so
3
+ // the rules are tested without a browser (tests/unit/geometry.mjs).
4
+ // Geometry proposes, the page's structure (boxes, units) decides the level, and accepts() decides
5
+ // what may go where (`takes`, from drag/index.mjs); nothing here changes the page. The tree's shape
6
+ // is described in geometry.mjs.
7
+
8
+ import { MAX_COLUMNS } from "../../components/columns/index.mjs";
9
+ import { BLOCK_TYPES, firstBlockOf, isLead } from "../../components/registry.mjs";
10
+ import { ADD, HANDLE } from "../handle-sizes.mjs";
11
+
12
+ const STEP = 12; // past edges that coincide, each step this far out leaves one more container
13
+ const NEAR = 3 * STEP; // how far past its edge a container left behind still counts
14
+ const SAME = 4; // edges this close are one edge
15
+ const NEST = 24; // list items a step right of the item above go under it
16
+ const LEAVE = 20; // and leave a list only past its markers, this far left of where its items start
17
+ // Beside a block (分栏, as Feishu's and Notion's): the right third of a block and right of it (no
18
+ // further than REACH), or left of it, a band as Notion's, REACH out from the block, but starting past
19
+ // all of its handle (OUT: the grip and the "+" column left of it) where Notion's starts at the grip's
20
+ // edge; a framed Sheet panel's blocks, set in from the page by its padding, take that start from the
21
+ // page's left edge, the handle of a page block going by there. In a row of columns: within SIDE of the
22
+ // last column's right edge (Feishu's) and past it, left of the first by the same band, or left of the
23
+ // handle of a column past the first (BETWEEN wide, OUT from that column; the gap, narrower than the
24
+ // handle standing in it, leaves the band only the end of the column before). Over a block's text and
25
+ // down the handles, whichever way a hand drifts on a drag that goes up or down, a drop goes between
26
+ // blocks as ever. Where the band would fall off the window, its start stays in it, as far from where
27
+ // the grip then stands as SLACK (FIRST).
28
+ const REACH = 200; // the farthest from a block a drop still goes beside it (Notion's)
29
+ const OUT = HANDLE.gap + HANDLE.width + ADD.width; // where the band left of a block starts, from its left edge
30
+ const SLACK = 16; // the least between the grip's left edge and that start
31
+ const FIRST = ADD.edge + ADD.width - SLACK; // the same from the window's left edge, the grip kept in from it there (handle/)
32
+ const SIDE = 16; // near a column's edge (Feishu's)
33
+ const BETWEEN = 2 * SIDE; // how wide the band for a new column between two is, as wide as within SIDE of an edge either way
34
+
35
+ // How many of a box's units come before its places: its lead (a highlight block's icon, a flowchart
36
+ // node's) is its own, no block to fall between, so a place before it is the place after it; so is a
37
+ // node's first line, its title (`firstBlock`): nothing lands before it, a place there is the place after it.
38
+ const headOf = (box, units) => {
39
+ const lead = isLead(box.kind, units[0]?.kind) ? 1 : 0;
40
+ const first = firstBlockOf(box.kind);
41
+ return lead + (first && units[lead]?.kind === BLOCK_TYPES[first]?.kind ? 1 : 0);
42
+ };
43
+
44
+ // Where a list's items start (their text; the markers stand left of it).
45
+ const itemsLeft = (list) => Math.min(list.rect.left + NEST, ...list.children.filter((child) => child.type === "unit").map((item) => item.start));
46
+
47
+ // In a box whose rows wrap (geometry.mjs sideBySide: a flowchart's nodes), a block alone in its row
48
+ // (no other of `rects` at its height: a node holding a picture, a node of a 纵向 flowchart) is one of
49
+ // a column there: the places before and after it are above and below it, by its middle height, the
50
+ // line across it. In a row of several, the places go across, by their middles, as in any row.
51
+ const alone = (box, rects, rect) => box.row === "wrap" && !rects.some((other) => other !== rect && Math.abs(other.top - rect.top) < SAME);
52
+
53
+ const isRow = (node) => node.kind === "columns";
54
+
55
+ // The x a point at (x, y) counts at: over the handle of a column's blocks (OUT left of a column past
56
+ // the first), at that column's left edge, as one left of the page counts at the page's, so that a drag
57
+ // by that handle that goes up or down stays among that column's blocks.
58
+ function overHandle(node, x, y) {
59
+ const next = node.children.find(({ rect }) => x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom);
60
+ if (!next) return x;
61
+ const column = isRow(next) ? next.children.find(({ rect }) => x < rect.left && x >= rect.left - OUT) : null;
62
+ return overHandle(column ?? next, column ? column.rect.left + 1 : x, y);
63
+ }
64
+
65
+ /**
66
+ * Where dragged blocks go with the pointer at (x, y) (page coordinates; beside the page counts as
67
+ * the page), or null where nothing takes them (over a Sheet's tab row, anything but its own tabs):
68
+ * { box, slot, nest, same, line, halo }. `box` takes them before its `slot`-th block (dragged ones
69
+ * not counted), or, with `nest`, at the end of that list item's lists; `same`: that is where they
70
+ * are already; `line`: where to show the place, `halo`: the container to tint (none for the page
71
+ * itself), both { left, top, right, bottom } in page coordinates.
72
+ *
73
+ * The box is the innermost one around the point that takes the blocks (`takes(box)`), the place in
74
+ * it between two of its blocks by their middles (in a row: by rows, then across). How deep a drop
75
+ * goes follows each container's own layout. Containers with edges (sections, panels, disclosures,
76
+ * Sheet panels) go by those edges: inside one, its places; past its edge, the container around it.
77
+ * Where edges coincide (the last section of a Sheet panel ends where the panel does), each further
78
+ * STEP past them leaves one more container, so every one of those places can be reached; the
79
+ * innermost one is reached from inside. Lists go by indentation, as their items show it: at a
80
+ * list's end, left of its markers (LEAVE past where its items start) the blocks leave it for the list around it (after the
81
+ * item holding it), and a step right of the item above they go under that item (`items`: every
82
+ * block dragged is a list item). Blocks of other kinds (a paragraph, an image…: notion-lite's children
83
+ * of a list item) go under an item too: among the blocks it holds, below its own line, or a step
84
+ * right of the item above the place (over a list, or right after one: the deepest item so reached),
85
+ * at the end of what it holds. `dragged(unit)`: a unit being dragged (`count` of them), which
86
+ * nothing goes into.
87
+ *
88
+ * With `aside(unit)` (the blocks may go into a column; whether a unit may: asideOf), beside a block they go beside it, the
89
+ * two side by side in a new row of columns, and at a column's edge into a new column there:
90
+ * { aside: { target, side } } or { aside: { row, index, whole } } (`whole`: the dragged blocks are
91
+ * all of one column of that row, which then moves instead). `edge`: the window's left edge, in page
92
+ * coordinates, which the band left of a block keeps some of.
93
+ */
94
+ export function resolveDrop(tree, x, y, { takes, dragged = () => false, count = 1, items = false, aside = false, edge = -Infinity }) {
95
+ const px = overHandle(tree, Math.min(Math.max(x, tree.rect.left + 1), tree.rect.right - 1), y);
96
+ const holds = (rect, at = px) => at >= rect.left && at <= rect.right && y >= rect.top && y <= rect.bottom;
97
+ const units = (box) => box.children.filter((child) => child.type === "unit" && !dragged(child));
98
+ // An item's box for what it holds ("nest") takes list items through its lists only; other blocks
99
+ // go into it among the blocks it holds, below the item's own line.
100
+ const open = (node) => node.type === "box" && takes(node) && (node.kind !== "nest" || (!items && units(node).length > 0 && y >= units(node)[0].rect.top - SAME));
101
+ const placeIn = (box) => {
102
+ const here = units(box);
103
+ const rects = here.map((unit) => unit.rect);
104
+ const slot = here.findIndex(({ rect }) => (box.row
105
+ ? y < rect.top || (y <= rect.bottom && (alone(box, rects, rect) ? y < (rect.top + rect.bottom) / 2 : px < (rect.left + rect.right) / 2))
106
+ : y < (rect.top + rect.bottom) / 2));
107
+ return Math.max(headOf(box, here), slot < 0 ? here.length : slot);
108
+ };
109
+
110
+ // The boxes and units around the point, from the page down, never into a dragged block. `flush`: a
111
+ // point left of the blocks of a detail card or a Sheet panel counts as at their left edge, as one left
112
+ // of the page's does: the padding between leaves them no less at that side.
113
+ const around = (flush) => {
114
+ const nodes = [tree];
115
+ let at = flush ? Math.max(px, tree.content.left + 1) : px;
116
+ for (let node = tree, next; (next = node.children.find((child) => holds(child.rect, at) && !(child.type === "unit" && dragged(child)))); node = next) {
117
+ nodes.push(next);
118
+ if (flush && next.type === "box" && next.role === "root") at = Math.max(at, next.content.left + 1);
119
+ }
120
+ return nodes;
121
+ };
122
+ const path = around(false);
123
+ if (path.some((node) => node.type === "box" && node.role === "tabs" && !takes(node))) return null; // resting there switches Sheets
124
+ if (aside) {
125
+ const beside = asideOf(around(true), x, dragged, count, aside, edge);
126
+ if (beside) return beside;
127
+ }
128
+ let box = path.findLast(open) ?? null;
129
+ let slot = box ? placeIn(box) : 0;
130
+
131
+ // Edges just passed: the containers that take the blocks inside the blocks either side of the
132
+ // place and end (above it) or start (below it) flush with that block, when the point has left
133
+ // that edge by at most NEAR.
134
+ const outer = box ?? path.findLast((node) => node.type === "box");
135
+ const near = units(outer);
136
+ const at = box ? slot : placeIn(outer);
137
+ const passed = [];
138
+ const collect = (unit, side) => {
139
+ const flush = unit && (side === "bottom" ? unit.rect.bottom : unit.rect.top);
140
+ const visit = (node, depth) => {
141
+ for (const inner of node.children) {
142
+ if (inner.type === "unit") {
143
+ if (!dragged(inner)) visit(inner, depth);
144
+ continue;
145
+ }
146
+ const edge = side === "bottom" ? inner.rect.bottom : inner.rect.top;
147
+ const past = side === "bottom" ? y - edge : edge - y;
148
+ if (open(inner) && Math.abs(edge - flush) <= SAME && px >= inner.rect.left && px <= inner.rect.right && past > 0 && past <= NEAR) passed.push({ box: inner, edge, side, depth });
149
+ visit(inner, depth + 1);
150
+ }
151
+ };
152
+ if (unit) visit(unit, 0);
153
+ };
154
+ collect(near[at - 1], "bottom");
155
+ collect(near[at], "top");
156
+ if (passed.length > 0) {
157
+ const nearest = passed.reduce((best, entry) => (Math.abs(y - entry.edge) < Math.abs(y - best.edge) ? entry : best));
158
+ const stack = passed.filter((entry) => entry.side === nearest.side && Math.abs(entry.edge - nearest.edge) <= SAME).sort((a, b) => b.depth - a.depth);
159
+ let chosen = null;
160
+ if (stack.every((entry) => entry.box.kind === "list")) {
161
+ // Lists by indentation: the deepest whose markers start left of the pointer, else the outermost.
162
+ chosen = (stack.find((entry) => itemsLeft(entry.box) - LEAVE <= px) ?? stack.at(-1)).box;
163
+ } else {
164
+ const levels = [...stack.slice(1).map((entry) => entry.box), ...(box ? [box] : [])];
165
+ if (levels.length > 0) chosen = levels[Math.min(Math.floor(Math.abs(y - nearest.edge) / STEP), levels.length - 1)];
166
+ }
167
+ if (chosen && chosen !== box) {
168
+ box = chosen;
169
+ slot = nearest.side === "bottom" ? units(box).length : headOf(box, units(box));
170
+ }
171
+ }
172
+ if (!box) return null;
173
+
174
+ // At a list's end, left of its markers (past where its items start, by LEAVE): the list around it, after the item holding it
175
+ // (on the path: that list, the item, the item's own box for lists, this list). Having left it,
176
+ // they do not go back under that item.
177
+ let left = false;
178
+ for (let index = path.indexOf(box); box.kind === "list" && index >= 4 && slot === units(box).length && px < itemsLeft(box) - LEAVE; index = path.indexOf(box)) {
179
+ const [list, item, lists] = [path[index - 4], path[index - 3], path[index - 2]];
180
+ if (lists.kind !== "nest" || !open(list)) break;
181
+ box = list;
182
+ slot = units(box).indexOf(item) + 1;
183
+ left = true;
184
+ }
185
+ const others = units(box);
186
+ const above = others[slot - 1];
187
+ const nest = items ? (!left && box.kind === "list" && !box.row && above?.nestable && px > above.start + NEST ? above : null) : held(path, box, above);
188
+
189
+ // Where they are already: next to each other in this box, all of them, at this place.
190
+ const all = box.children.filter((child) => child.type === "unit");
191
+ const first = all.findIndex(dragged);
192
+ const run = first < 0 ? 0 : all.slice(first).findIndex((child) => !dragged(child));
193
+ const same = !nest && first >= 0 && (run < 0 ? all.length - first : run) === count && slot === first;
194
+ const line = nest && !items ? { left: nest.start, top: nest.rect.bottom + 2, right: nest.rect.right, bottom: nest.rect.bottom + 5 } : lineOf(box, others, slot, nest, y);
195
+ return { box: box.el, slot, nest: nest?.el ?? null, same, line, halo: nest ? nest.rect : box === tree ? null : box.rect };
196
+
197
+ // The item blocks of other kinds go under (at the end of what it holds), or null: over a list the
198
+ // pointer is in (deeper than `box`), the item above the pointer; else, right after a list, its last
199
+ // item; then, down the last lists they hold, the deepest item whose text starts a step (NEST) left
200
+ // of the pointer. Only an item that takes them (`nestable`, its box taking every kind dragged).
201
+ function held(path, box, above) {
202
+ const list = path.findLast((node) => node.type === "box" && node.kind === "list");
203
+ const inside = list && path.indexOf(list) > path.indexOf(box);
204
+ let item = inside ? units(list)[placeIn(list) - 1] : above?.kind === "list" ? lastItem(above) : null;
205
+ let found = null;
206
+ while (item && px > item.start + NEST) {
207
+ if (item.nestable && takes({ kind: "nest", el: item.el })) found = item;
208
+ const nested = item.children.find((child) => child.type === "box" && child.kind === "nest");
209
+ const last = nested ? units(nested).at(-1) : null;
210
+ item = last?.kind === "list" ? lastItem(last) : null;
211
+ }
212
+ return found;
213
+ }
214
+ function lastItem(listUnit) {
215
+ const box = listUnit.children.find((child) => child.type === "box" && child.kind === "list");
216
+ return box ? units(box).at(-1) ?? null : null;
217
+ }
218
+ }
219
+
220
+ // Beside a block (the units on `path`, from the page down, at height y): in the innermost row of
221
+ // columns on it, a new column at the row's ends or left of a column's handle; elsewhere the innermost
222
+ // block of a flow that may stand in a column, beside it. The line stands down that side, the block (or
223
+ // the column beside the line) tinted. Null where the drop goes between blocks as ever.
224
+ const FLOW_ROLES = new Set(["root", "flow"]);
225
+ function asideOf(path, x, dragged, count, fits, edge) {
226
+ const down = (rect, at) => ({ left: at - 1.5, top: rect.top - 8, right: at + 1.5, bottom: rect.bottom + 8 });
227
+ const leftOf = (left) => x >= left - REACH && x < Math.max(Math.min(left, path[0].content.left) - OUT, edge + FIRST);
228
+ const row = path.findLast((node) => node.type === "unit" && isRow(node) && !dragged(node));
229
+ if (row) {
230
+ const box = row.children.find((child) => child.type === "box");
231
+ const columns = box?.children.filter((child) => child.type === "unit") ?? [];
232
+ if (columns.length === 0) return null;
233
+ // The column whose blocks are all of those dragged (and only they), which moves instead.
234
+ const own = (column) => column.children.flatMap((inner) => inner.children.filter((child) => child.type === "unit"));
235
+ const whole = columns.find((column) => own(column).length === count && own(column).every(dragged)) ?? null;
236
+ const after = columns.findIndex(({ rect }, at) => {
237
+ const next = columns[at + 1]?.rect;
238
+ return next ? x >= next.left - OUT - BETWEEN && x < next.left - OUT
239
+ : x > rect.left + (2 * (rect.right - rect.left)) / 3 && x > rect.right - SIDE && x < rect.right + REACH;
240
+ });
241
+ const index = leftOf(columns[0].rect.left) ? 0 : after < 0 ? -1 : after + 1;
242
+ if (index < 0) return null;
243
+ const from = whole ? columns.indexOf(whole) : -1;
244
+ const same = from >= 0 && (index === from || index === from + 1);
245
+ if (!whole && columns.length >= MAX_COLUMNS) return null;
246
+ const at = index === 0 ? columns[0].rect.left - 6 : index === columns.length ? columns.at(-1).rect.right + 6 : (columns[index - 1].rect.right + columns[index].rect.left) / 2;
247
+ return { box: box.el, slot: 0, nest: null, same, aside: { row: row.el, index, whole: whole?.el ?? null }, line: down(row.rect, at), halo: columns[Math.max(0, index - 1)].rect };
248
+ }
249
+ // The innermost block of a flow, one that may stand in a column and holds none of those dragged.
250
+ let target = null;
251
+ for (let index = 1; index < path.length; index++) {
252
+ const node = path[index];
253
+ if (node.type !== "unit") continue;
254
+ if (FLOW_ROLES.has(path[index - 1].role)) target = node;
255
+ }
256
+ const holdsDragged = (node) => node.children.some((inner) => inner.children.some((unit) => dragged(unit) || holdsDragged(unit)));
257
+ if (!target || !fits(target) || holdsDragged(target)) return null;
258
+ const { rect } = target;
259
+ const side = x > rect.left + (2 * (rect.right - rect.left)) / 3 && x <= rect.right + REACH ? "right"
260
+ : leftOf(rect.left) ? "left" : null;
261
+ if (!side) return null;
262
+ const box = path[path.indexOf(target) - 1];
263
+ return { box: box.el, slot: 0, nest: null, same: false, aside: { target: target.el, side }, line: down(rect, side === "right" ? rect.right + 6 : rect.left - 6), halo: rect };
264
+ }
265
+
266
+ // The line showing a place: across the box between two of its blocks (under an item, from its
267
+ // text, where the markers of a list in it would stand; before the first and after the last, from
268
+ // no further out than the box's edge, which a divider's band may pass), down between two blocks of
269
+ // a row or at the end of the row the pointer is in (across a block alone in its row of a box whose
270
+ // rows wrap, above or below it), or along the bottom of an empty box.
271
+ function lineOf(box, others, slot, nest, y) {
272
+ // A box's lead (a highlight block's icon) is no block to fall between: the line spans the blocks
273
+ // after it, from the icon's right (notion-lite's).
274
+ const head = headOf(box, others);
275
+ slot -= head;
276
+ const rects = others.slice(head).map((unit) => unit.rect);
277
+ if (rects.length === 0) {
278
+ // An empty box: across its content, inside its padding (an empty Sheet panel's 16px).
279
+ const { left, top, right, bottom } = box.content;
280
+ const at = bottom > top ? (top + bottom) / 2 : box.rect.bottom - 6;
281
+ return { left, top: at - 1.5, right, bottom: at + 1.5 };
282
+ }
283
+ if (box.row) {
284
+ const next = rects[slot];
285
+ const previous = rects[slot - 1];
286
+ const sameRow = next && previous && Math.abs(next.top - previous.top) < 4;
287
+ const endOfRow = previous && !sameRow && (!next || (y >= previous.top && y <= previous.bottom));
288
+ const rect = sameRow || !endOfRow ? next ?? previous : previous;
289
+ // Before or after a block alone in its row of a box whose rows wrap (or with the pointer between
290
+ // its row and the next, either of the two alone): across it, between the rows (halfway to the row
291
+ // above or below), or just past it at the box's start or end.
292
+ const between = previous && next && !sameRow && y > previous.bottom && y < next.top;
293
+ const lone = sameRow ? null : [rect, ...(between ? [previous, next] : [])].find((each) => alone(box, rects, each));
294
+ if (lone) {
295
+ const at = lone === previous ? (next ? (previous.bottom + next.top) / 2 : previous.bottom + 6) : previous ? (previous.bottom + next.top) / 2 : next.top - 6;
296
+ return { left: lone.left, top: at - 1.5, right: lone.right, bottom: at + 1.5 };
297
+ }
298
+ const at = sameRow ? (previous.right + next.left) / 2 : endOfRow ? previous.right + 8 : next.left - 8;
299
+ return { left: at - 1.5, top: rect.top, right: at + 1.5, bottom: rect.bottom };
300
+ }
301
+ const left = nest ? nest.start : Math.min(...rects.map((rect) => rect.left));
302
+ const right = Math.max(...rects.map((rect) => rect.right));
303
+ const at = slot === 0 ? Math.max(rects[0].top, box.rect.top) - 6
304
+ : slot === rects.length ? Math.min(rects.at(-1).bottom, box.rect.bottom) + 6
305
+ : (rects[slot - 1].bottom + rects[slot].top) / 2;
306
+ return { left, top: at - 1.5, right, bottom: at + 1.5 };
307
+ }
@@ -0,0 +1,335 @@
1
+ import { IN_LAYER } from "../../../shared/layers.mjs";
2
+ import { gestureLock } from "../gesture.mjs";
3
+ import { nestedBlocks, newContainer, placeBefore, removalTarget, unitsOf, withLeads } from "../core.mjs";
4
+ import { accepts, isLead } from "../../components/registry.mjs";
5
+ import { columnOps } from "../page-objects.mjs";
6
+ import { DIALOG, SHEETS } from "../../components/kit.mjs";
7
+ import { heldListType, listType } from "../../components/list/index.mjs";
8
+ import { extentOf, measure } from "../geometry.mjs";
9
+ import { edgeScroll } from "../edge-scroll.mjs";
10
+ import { alive, ordered } from "../block-info.mjs";
11
+ import { resolveDrop } from "./drop.mjs";
12
+ import { describe, note, own } from "../overlays.mjs";
13
+ import { drawBox, layerOf } from "../overlay-layer.mjs";
14
+ import { createPreview } from "./preview.mjs";
15
+ import { addStyle, element } from "../ui.mjs";
16
+ import { t } from "../../../shared/i18n/index.mjs";
17
+
18
+ // Moving blocks (docs/editor.md, "Moving blocks"). Dragging a block's handle (handle/ starts it once
19
+ // the press has moved a few pixels) moves it, with the others selected when it is one of them,
20
+ // anywhere it may go (accepts(): any flow of the document, a column, a list, the chapters): where
21
+ // is drop.mjs resolveDrop (containers by their edges, a step out per 12px past edges that coincide;
22
+ // lists by indentation, a step right of the item above going under it; beside a block, side by side
23
+ // with it in a new row of columns, and at a column's edge, a new column: 分栏), shown by a blue line and
24
+ // the container tinted (no label: the line and the tint say where); a faded copy of the blocks
25
+ // follows the pointer (preview.mjs, as Notion's). Resting on a Sheet tab switches
26
+ // to its Sheet, resting on a closed disclosure's title opens it; near the window's edges the page
27
+ // scrolls. Releasing moves the very same nodes there as one undo step that keeps them selected; Esc
28
+ // cancels, and so does anything that ends the press another way (the handle losing the pointer
29
+ // capture, the window losing the focus, the page hidden): never a drop. Ending is idempotent, and
30
+ // the line, tint and copy belong to their drag (overlays.mjs). Ctrl+Shift+arrows move selected blocks standing next to each other by one place (moveBy).
31
+
32
+ const STYLE = `
33
+ ${gestureLock("data-ge-drag", { cursor: "grabbing", select: true })}
34
+ [data-ge-dragging] { opacity: .5; }
35
+ .ge-drop-line { position: absolute; left: 0; top: 0; z-index: ${IN_LAYER.drop}; border-radius: 2px; background: rgb(151 197 241); pointer-events: none; }
36
+ /* The container the dragged blocks would go into (not the page itself). */
37
+ .ge-drop-tint { position: absolute; left: 0; top: 0; z-index: ${IN_LAYER.tint}; border-radius: 6px; background: color-mix(in srgb, var(--ge-halo) 50%, transparent); pointer-events: none; }
38
+ .ge-drop-tint[hidden], .ge-drop-line[hidden] { display: none; }
39
+ `;
40
+
41
+
42
+ /**
43
+ * info: block-info.mjs. selection: selection/index.mjs. struct(parents, touched, mutate): the
44
+ * editor's undoable structural change (history.mjs). say: the status line. closeMenu(): the block
45
+ * menu closes. schedule(): the block tools' next frame (blocks.mjs), which calls step() while a
46
+ * drag lasts.
47
+ */
48
+ export function createDrag({ info, selection, struct, say, closeMenu, schedule }) {
49
+ addStyle(STYLE);
50
+ const { addColumn, columnsOf, rowAround } = columnOps() ?? {};
51
+ const { kindOf, nameOf, named, fixedText, boxKindOf } = info;
52
+ let drag = null; // blocks being dragged: { targets, target (the one pressed), from (their container), x, y, line, tint, preview, drop: { container, slot } | null, rest, opened, tree, measured }
53
+
54
+ // The containers moving `targets` out leaves empty, which go with them (as when the last block of one
55
+ // is deleted), except those holding `place` (where they go) or being targets themselves.
56
+ function leftoversOf(targets, place) {
57
+ const gone = new Set(targets.flatMap(withLeads));
58
+ return [...new Set(targets.map((target) => removalTarget(target, gone)))].filter((node) => !targets.includes(node) && !node.contains(place));
59
+ }
60
+
61
+ // Put blocks (with their leads, in their order) into `container` before `reference`, as one undo
62
+ // step that keeps them selected. A container they leave empty goes too, as when its last block
63
+ // is deleted. Returns whether an emptied
64
+ // container went. `container` may be a list item: list items go to the end of its last list (when
65
+ // it is the last block it holds), or of a new list (of the kind their own list is) put at the end
66
+ // of the item; other blocks among the blocks it holds, before `reference` (at the end without one).
67
+ // A flowchart's nodes go among blocks as list items do: into the flowchart they land right beside,
68
+ // else a flowchart of their own (their list's type, "flowchart"); dropAt never puts them under an item.
69
+ function moveTo(targets, container, reference) {
70
+ const parts = targets.flatMap(withLeads);
71
+ const leftovers = leftoversOf(targets, container);
72
+ const item = container.tagName === "LI" && targets.every((target) => kindOf(target) === "item") ? container : null;
73
+ const last = item ? nestedBlocks(item).at(-1) : null;
74
+ const list = last?.matches("ul, ol") && last.hasAttribute("data-ge-box") ? last : null;
75
+ // List items dropped among blocks (Feishu's and Notion's: an item goes anywhere): they join a list
76
+ // of their kind right before or after the place, else they make one there.
77
+ const kind = listType(targets[0].parentElement); // items join a list of their own type
78
+ const sameKind = (node) => Boolean(node?.matches?.("ul, ol")) && listType(node) === kind;
79
+ const loose = !item && targets.every((target) => target.tagName === "LI") && !container.matches("ul, ol");
80
+ const before = loose ? (reference ? reference.previousElementSibling : container.lastElementChild) : null;
81
+ // Never the list they leave empty, which goes (it would take them with it).
82
+ const joins = (node) => sameKind(node) && node.hasAttribute("data-ge-box") && !targets.includes(node) && !leftovers.includes(node);
83
+ const join = !loose ? null : joins(before) ? { list: before, at: null }
84
+ : joins(reference) ? { list: reference, at: reference.firstChild } : null;
85
+ const parents = [...new Set([...targets.map((target) => target.parentNode), list ?? container, join?.list, ...leftovers.map((node) => node.parentNode)].filter(Boolean))];
86
+ struct(parents, [], () => {
87
+ let into = list ?? container;
88
+ const created = [];
89
+ if (item && !list) {
90
+ into = newContainer(document, heldListType(listType(targets[0].parentElement))); // a 流程图's steps a numbered list there
91
+ item.append(into);
92
+ created.push(into);
93
+ }
94
+ if (loose && join) placeBefore(join.list, parts, join.at);
95
+ else if (loose) {
96
+ const wrapper = newContainer(document, kind);
97
+ container.insertBefore(wrapper, reference);
98
+ created.push(wrapper);
99
+ placeBefore(wrapper, parts, null);
100
+ } else placeBefore(into, parts, item ? null : reference);
101
+ leftovers.forEach((node) => node.remove());
102
+ return { touched: [], focus: null, select: targets, reselect: true, created };
103
+ });
104
+ return leftovers.length > 0;
105
+ }
106
+
107
+ // Put blocks beside a block (drop.mjs `aside`): { target, side }, the two side by side in a new
108
+ // row of columns; { row, index, whole }, a new column of that row at `index` holding them, or,
109
+ // when they are all of one column of it (`whole`), that column moved there. One undo step that
110
+ // keeps them selected; a container they leave empty goes, as when they move (and a row left
111
+ // with one column gives its blocks back: history.mjs).
112
+ function besideTo(targets, aside) {
113
+ if (aside.whole) {
114
+ const row = aside.row;
115
+ struct([row], [], () => {
116
+ row.insertBefore(aside.whole, columnsOf(row)[aside.index] ?? null);
117
+ return { touched: [], focus: null, select: targets, reselect: true };
118
+ });
119
+ return;
120
+ }
121
+ const parts = targets.flatMap(withLeads);
122
+ const leftovers = leftoversOf(targets, aside.row ?? aside.target);
123
+ const parents = [...new Set([...targets.map((target) => target.parentNode), aside.row ?? aside.target.parentElement, ...leftovers.map((node) => node.parentNode)].filter(Boolean))];
124
+ struct(parents, [], () => {
125
+ const { created } = aside.row ? addColumn(aside.row, aside.index, parts) : rowAround(aside.target, [parts], aside.side);
126
+ leftovers.forEach((node) => node.remove());
127
+ return { touched: [], focus: null, select: targets, reselect: true, created };
128
+ });
129
+ }
130
+
131
+ /**
132
+ * Move a block, or selected blocks standing next to each other, one place back (-1) or on (+1)
133
+ * among their container's blocks. Returns whether they moved.
134
+ */
135
+ function moveBy(targets, delta, { keepFocus = false } = {}) {
136
+ closeMenu();
137
+ targets = ordered([targets].flat().filter(alive));
138
+ if (targets.length === 0) return false;
139
+ const reason = targets.map(fixedText).find(Boolean);
140
+ if (reason) {
141
+ say(reason);
142
+ return false;
143
+ }
144
+ // The blocks to move among: not a box's lead (a highlight block's icon stays first in it).
145
+ const boxKind = boxKindOf(targets[0].parentElement);
146
+ const list = unitsOf(targets[0].parentElement).filter((unit) => !isLead(boxKind, kindOf(unit)));
147
+ const first = list.indexOf(targets[0]);
148
+ if (!targets.every((target, index) => list[first + index] === target)) {
149
+ say(t("选中的块不相邻,不能一起上下移动;可以拖动其中一块的手柄,把它们一起移到别处。"));
150
+ return false;
151
+ }
152
+ const neighbour = list[delta < 0 ? first - 1 : first + targets.length];
153
+ if (!neighbour) {
154
+ say(list.length === targets.length ? t("这里只有{0};可以拖动手柄移到别处。", targets.length === 1 ? t("这一个{0}", nameOf(targets[0])) : t("这几块")) : t("{0}已经在{1}。", named(targets), delta < 0 ? t("最前面") : t("最后面")));
155
+ return false;
156
+ }
157
+ moveTo(targets, targets[0].parentElement, delta < 0 ? withLeads(neighbour)[0] : neighbour.nextSibling);
158
+ if (!keepFocus) selection.select(targets, { quiet: true });
159
+ targets[delta < 0 ? 0 : targets.length - 1].scrollIntoView({ block: "nearest", inline: "nearest" });
160
+ say(t("已移动{0} · Ctrl+Z 撤销", named(targets)));
161
+ return true;
162
+ }
163
+
164
+ // Dragging the handle of `target`: it goes with the others selected, or alone. Returns whether
165
+ // the drag started (a block that cannot move says why).
166
+ function start(target, x, y) {
167
+ const picked = selection.picked;
168
+ const targets = picked.length > 1 && picked.includes(target) ? [...picked] : [target];
169
+ const reason = targets.map(fixedText).find(Boolean);
170
+ if (reason) {
171
+ say(reason);
172
+ return false;
173
+ }
174
+ closeMenu();
175
+ selection.select(targets, { quiet: true });
176
+ const session = {
177
+ targets, target, from: target.parentElement, x, y, drop: null, rest: null, opened: new Set(),
178
+ line: element("div", { class: "ge-drop-line", hidden: "" }),
179
+ tint: element("div", { class: "ge-drop-tint", hidden: "" }),
180
+ preview: null,
181
+ tree: null, measured: 0,
182
+ };
183
+ const alive = () => drag === session;
184
+ // The line and the tint go in the layer of where the blocks would go
185
+ // (overlay-layer.mjs), when there is one; the copy follows the pointer in the window.
186
+ for (const kind of ["line", "tint"]) own(session[kind], `drag ${kind}`, { owner: target, alive });
187
+ session.preview = createPreview(targets, x, y, { owner: target, alive });
188
+ drag = session;
189
+ note("drag", `start ${targets.map(describe).join(", ")}`);
190
+ targets.flatMap(withLeads).forEach((part) => part.setAttribute("data-ge-dragging", ""));
191
+ document.documentElement.setAttribute("data-ge-drag", "");
192
+ say(t("正在移动{0} · 拖到要放的位置后松开 · 停在选项卡上切换,停在折叠块标题上展开 · Esc 取消", named(targets)), "prompt");
193
+ update();
194
+ schedule();
195
+ return true;
196
+ }
197
+
198
+ // Where dragged blocks go (drop.mjs resolveDrop), from the page's boxes as they are: measured
199
+ // again at most every 100ms (resting on a tab or a disclosure's title changes them), in an open
200
+ // modal dialog from its content. The tree is in page coordinates, so scrolling leaves it valid.
201
+ function dropAt(x, y) {
202
+ const now = performance.now();
203
+ if (!drag.tree || now - drag.measured > 100) {
204
+ const root = drag.target.closest(`${DIALOG.openContent}[data-ge-box]`) ?? document.querySelector(`${DIALOG.openContent}[data-ge-box]`) ?? document.querySelector("main");
205
+ drag.tree = root && measure(root);
206
+ drag.measured = now;
207
+ }
208
+ if (!drag.tree) return null;
209
+ const { targets } = drag;
210
+ const kinds = new Set(targets.map(kindOf));
211
+ const tabs = kinds.has("tab");
212
+ // Tabs stay in their row; list items go wherever a list may (among blocks, in a list of their kind
213
+ // or a new one); a flowchart's nodes into a flowchart, or wherever a flowchart may go outside any
214
+ // (among blocks: a flowchart of their own there, or the one they land beside: moveTo), never into a
215
+ // node or under an item (nodes never nest); anything else goes where its box takes every one of them.
216
+ const items = [...kinds].every((kind) => kind === "item");
217
+ const steps = [...kinds].every((kind) => kind === "step");
218
+ const takes = (box) => (tabs ? kinds.size === 1 && targets.every((target) => target.parentElement === box.el)
219
+ : items ? accepts(box.kind, "item") || accepts(box.kind, "list")
220
+ : steps ? accepts(box.kind, "step") || (accepts(box.kind, "flowchart") && box.kind !== "nest" && !box.el.closest("ol.doc-flow"))
221
+ : [...kinds].every((kind) => accepts(box.kind, kind)));
222
+ // Blocks a column takes may go beside a block, into a column (分栏).
223
+ const aside = !tabs && [...kinds].every((kind) => accepts("column", kind)) && ((unit) => accepts("column", unit.kind));
224
+ return resolveDrop(drag.tree, x + scrollX, y + scrollY, { takes, dragged: (unit) => targets.includes(unit.el), count: targets.length, items, aside, edge: scrollX });
225
+ }
226
+
227
+ // Resting on a Sheet tab while dragging switches to that Sheet; resting on the title of a
228
+ // closed disclosure opens it, so the block can go in (end() closes it again if it did not).
229
+ function restOn(x, y) {
230
+ const hit = document.elementFromPoint(x, y);
231
+ const tab = drag.targets.some((target) => kindOf(target) === "tab") ? null : hit?.closest(SHEETS.tabIn) ?? null;
232
+ const closed = tab ? null : hit?.closest("details:not([open]) > summary")?.parentElement ?? null;
233
+ const node = tab ?? (closed && !drag.targets.some((target) => target.contains(closed)) ? closed : null);
234
+ if (node === (drag.rest?.node ?? null)) return;
235
+ clearTimeout(drag.rest?.timer);
236
+ if (!node || (tab && tab.getAttribute("aria-selected") === "true")) {
237
+ drag.rest = node ? { node, timer: 0 } : null;
238
+ return;
239
+ }
240
+ drag.rest = {
241
+ node,
242
+ timer: setTimeout(() => {
243
+ if (tab) tab.click();
244
+ else {
245
+ node.open = true;
246
+ drag.opened.add(node);
247
+ }
248
+ }, 450),
249
+ };
250
+ }
251
+
252
+ // Where the dragged blocks would go (drag.drop), shown as a line (none where they already are or
253
+ // where nothing takes them) and the container they would go into tinted (not the page itself).
254
+ function update() {
255
+ const { x, y, line, tint } = drag;
256
+ drag.preview.move(x, y);
257
+ restOn(x, y);
258
+ const found = dropAt(x, y);
259
+ drag.drop = found && { container: found.box, slot: found.slot, nest: found.nest, same: found.same, aside: found.aside ?? null };
260
+ line.hidden = !found || found.same;
261
+ tint.hidden = line.hidden || !found.halo;
262
+ if (line.hidden) return;
263
+ // The drop's rectangles are in page coordinates (drop.mjs), drawn in the layer of the container
264
+ // the blocks would go into (overlay-layer.mjs).
265
+ const layer = layerOf(found.box);
266
+ const client = (rect) => ({ left: rect.left - scrollX, top: rect.top - scrollY, right: rect.right - scrollX, bottom: rect.bottom - scrollY });
267
+ const at = client(found.line);
268
+ drawBox(line, layer, at);
269
+ if (found.halo) drawBox(tint, layer, client(found.halo), 2);
270
+ }
271
+
272
+ // Releasing (commit) or cancelling: the blocks go where the line showed, or stay.
273
+ function end(commit) {
274
+ if (!drag) return;
275
+ const { targets, target, drop, line, tint, preview, opened } = drag;
276
+ clearTimeout(drag.rest?.timer);
277
+ drag = null;
278
+ line.remove();
279
+ tint.remove();
280
+ preview.node.remove();
281
+ targets.flatMap(withLeads).forEach((part) => part.removeAttribute("data-ge-dragging"));
282
+ document.documentElement.removeAttribute("data-ge-drag");
283
+ const lands = commit && drop && !drop.same && targets.every(alive) && drop.container.isConnected && (!drop.aside || (drop.aside.row ?? drop.aside.target).isConnected);
284
+ note("drag", lands ? "dropped" : commit ? "released in place" : "cancelled");
285
+ // Disclosures opened on the way close again, unless the blocks went into one of them.
286
+ for (const details of opened) if (!(lands && details.contains(drop.container))) details.open = false;
287
+ if (!lands) {
288
+ selection.select(targets.filter(alive), { quiet: true });
289
+ say(!commit ? t("已取消移动。") : t("位置没有变化。"));
290
+ return;
291
+ }
292
+ if (drop.aside) {
293
+ besideTo(targets, drop.aside);
294
+ selection.select(targets, { quiet: true });
295
+ target.scrollIntoView({ block: "nearest", inline: "nearest" });
296
+ say(t("{0} · 拖动栏间的竖线调宽度 · Ctrl+Z 撤销", drop.aside.whole ? t("已移动这一栏") : drop.aside.row ? t("已把{0}放进新的一栏", named(targets)) : t("已把{0}并排分栏", named(targets))));
297
+ return;
298
+ }
299
+ const others = unitsOf(drop.container).filter((unit) => !targets.includes(unit) && extentOf(unit));
300
+ // The place is never before a box's lead (a highlight block's icon): drop.mjs.
301
+ const reference = drop.slot < others.length ? withLeads(others[drop.slot])[0] : others.length > 0 ? others.at(-1).nextSibling : null;
302
+ const emptied = moveTo(targets, drop.nest ?? drop.container, drop.nest ? null : reference);
303
+ selection.select(targets, { quiet: true });
304
+ target.scrollIntoView({ block: "nearest", inline: "nearest" });
305
+ say(t("已移动{0}{1}{2} · Ctrl+Z 撤销", named(targets), drop.nest ? t("到上一项下面") : "", emptied ? t("(原来的外层已空,一并去掉)") : ""));
306
+ }
307
+
308
+ // The window losing the focus, or the page going out of sight, ends a drag: cancelled.
309
+ addEventListener("blur", () => end(false));
310
+ document.addEventListener("visibilitychange", () => { if (document.hidden) end(false); });
311
+
312
+ return {
313
+ start,
314
+ /** The pointer moved while dragging. */
315
+ move(x, y) {
316
+ if (!drag) return;
317
+ drag.x = x;
318
+ drag.y = y;
319
+ update();
320
+ },
321
+ end,
322
+ /** A frame while dragging: the page scrolls near the window's edges, the drop follows. */
323
+ step() {
324
+ if (!drag) return;
325
+ edgeScroll(drag.x, drag.y, drag.target.closest(DIALOG.openContent)); // the card it started in, else the window
326
+ update();
327
+ },
328
+ moveBy,
329
+ /** Blocks are being dragged. */
330
+ get active() { return Boolean(drag); },
331
+ /** The block whose handle was pressed (its handle stays), while dragging. */
332
+ get target() { return drag?.target ?? null; },
333
+ get nodes() { return drag ? [drag.preview.node] : []; },
334
+ };
335
+ }