@heycys/gallery 0.0.0-stage → 0.1.1

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 (806) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +50 -2
  3. package/THIRD-PARTY-NOTICES.md +3303 -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 +64 -0
  11. package/browser/editor/components/code/index.mjs +327 -0
  12. package/browser/editor/components/code/page.mjs +561 -0
  13. package/browser/editor/components/colors.mjs +50 -0
  14. package/browser/editor/components/columns/index.mjs +104 -0
  15. package/browser/editor/components/columns/page.mjs +310 -0
  16. package/browser/editor/components/details/index.mjs +73 -0
  17. package/browser/editor/components/details/page.mjs +86 -0
  18. package/browser/editor/components/dialog/index.mjs +84 -0
  19. package/browser/editor/components/dialog/page.mjs +201 -0
  20. package/browser/editor/components/divider/index.mjs +48 -0
  21. package/browser/editor/components/embed/icons.mjs +11 -0
  22. package/browser/editor/components/embed/index.mjs +123 -0
  23. package/browser/editor/components/embed/page.mjs +309 -0
  24. package/browser/editor/components/figure/index.mjs +87 -0
  25. package/browser/editor/components/figure/page.mjs +42 -0
  26. package/browser/editor/components/file/icons.mjs +14 -0
  27. package/browser/editor/components/file/index.mjs +77 -0
  28. package/browser/editor/components/file/page.mjs +114 -0
  29. package/browser/editor/components/flowchart/add.mjs +123 -0
  30. package/browser/editor/components/flowchart/index.mjs +246 -0
  31. package/browser/editor/components/flowchart/page.mjs +453 -0
  32. package/browser/editor/components/heading/index.mjs +53 -0
  33. package/browser/editor/components/heading/page.mjs +6 -0
  34. package/browser/editor/components/highlight/index.mjs +63 -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 +48 -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 +179 -0
  43. package/browser/editor/components/installed/page.mjs +523 -0
  44. package/browser/editor/components/installed/served.mjs +35 -0
  45. package/browser/editor/components/kit.mjs +67 -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 +192 -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 +859 -0
  66. package/browser/editor/components/rows.mjs +16 -0
  67. package/browser/editor/components/section/index.mjs +42 -0
  68. package/browser/editor/components/section/page.mjs +141 -0
  69. package/browser/editor/components/set-apart.mjs +24 -0
  70. package/browser/editor/components/sheets/index.mjs +137 -0
  71. package/browser/editor/components/sheets/page.mjs +227 -0
  72. package/browser/editor/components/sheets/pills.mjs +226 -0
  73. package/browser/editor/components/table/grid.mjs +73 -0
  74. package/browser/editor/components/table/index.mjs +308 -0
  75. package/browser/editor/components/table/page.mjs +683 -0
  76. package/browser/editor/components/table/slots.mjs +41 -0
  77. package/browser/editor/components/widget/index.mjs +50 -0
  78. package/browser/editor/page/annotate/anchors.mjs +230 -0
  79. package/browser/editor/page/annotate/card.mjs +102 -0
  80. package/browser/editor/page/annotate/index.mjs +1656 -0
  81. package/browser/editor/page/at-menu/index.mjs +317 -0
  82. package/browser/editor/page/autosave.mjs +1023 -0
  83. package/browser/editor/page/beside.mjs +21 -0
  84. package/browser/editor/page/block-info.mjs +63 -0
  85. package/browser/editor/page/block-menu/colors.mjs +84 -0
  86. package/browser/editor/page/block-menu/index.mjs +217 -0
  87. package/browser/editor/page/blocks.mjs +255 -0
  88. package/browser/editor/page/caret.mjs +682 -0
  89. package/browser/editor/page/changes/bar.mjs +102 -0
  90. package/browser/editor/page/changes/ghost.mjs +206 -0
  91. package/browser/editor/page/changes/gone-words.mjs +94 -0
  92. package/browser/editor/page/changes/index.mjs +447 -0
  93. package/browser/editor/page/changes/words.mjs +27 -0
  94. package/browser/editor/page/chip-fills.mjs +126 -0
  95. package/browser/editor/page/clipboard/import/colors.mjs +192 -0
  96. package/browser/editor/page/clipboard/import/html.mjs +792 -0
  97. package/browser/editor/page/clipboard/import/inline.mjs +232 -0
  98. package/browser/editor/page/clipboard/import/languages.mjs +42 -0
  99. package/browser/editor/page/clipboard/import/markdown.mjs +760 -0
  100. package/browser/editor/page/clipboard/import/math.mjs +100 -0
  101. package/browser/editor/page/clipboard/import/office.mjs +245 -0
  102. package/browser/editor/page/clipboard/import/read.mjs +120 -0
  103. package/browser/editor/page/clipboard/import/rich.mjs +29 -0
  104. package/browser/editor/page/clipboard/import/to-blocks.mjs +290 -0
  105. package/browser/editor/page/clipboard/index.mjs +816 -0
  106. package/browser/editor/page/clipboard/own/blocks.mjs +211 -0
  107. package/browser/editor/page/clipboard/own/chart-keys.mjs +58 -0
  108. package/browser/editor/page/clipboard/own/describe.mjs +124 -0
  109. package/browser/editor/page/clipboard/own/export.mjs +167 -0
  110. package/browser/editor/page/clipboard/own/ids.mjs +39 -0
  111. package/browser/editor/page/clipboard/own/index.mjs +13 -0
  112. package/browser/editor/page/clipboard/own/rules.mjs +44 -0
  113. package/browser/editor/page/clipboard/own/selection.mjs +159 -0
  114. package/browser/editor/page/clipboard/own/writers.mjs +315 -0
  115. package/browser/editor/page/columns/index.mjs +360 -0
  116. package/browser/editor/page/commit.mjs +1813 -0
  117. package/browser/editor/page/conflicts.mjs +249 -0
  118. package/browser/editor/page/convert.mjs +831 -0
  119. package/browser/editor/page/core.mjs +1693 -0
  120. package/browser/editor/page/drag/drop.mjs +307 -0
  121. package/browser/editor/page/drag/index.mjs +351 -0
  122. package/browser/editor/page/drag/preview.mjs +126 -0
  123. package/browser/editor/page/edge-scroll.mjs +50 -0
  124. package/browser/editor/page/editor.mjs +1780 -0
  125. package/browser/editor/page/emoji-picker/emoji-tab.mjs +287 -0
  126. package/browser/editor/page/emoji-picker/glyph-html.mjs +26 -0
  127. package/browser/editor/page/emoji-picker/grid.mjs +81 -0
  128. package/browser/editor/page/emoji-picker/icon-tab.mjs +217 -0
  129. package/browser/editor/page/emoji-picker/icons.mjs +31 -0
  130. package/browser/editor/page/emoji-picker/index.mjs +166 -0
  131. package/browser/editor/page/emoji-picker/styles.mjs +161 -0
  132. package/browser/editor/page/emoji-picker/support.mjs +204 -0
  133. package/browser/editor/page/emoji-picker/upload.mjs +236 -0
  134. package/browser/editor/page/export-report.mjs +23 -0
  135. package/browser/editor/page/fills.mjs +62 -0
  136. package/browser/editor/page/find/index.mjs +107 -0
  137. package/browser/editor/page/flags.mjs +70 -0
  138. package/browser/editor/page/fold/index.mjs +348 -0
  139. package/browser/editor/page/fold/rule.mjs +125 -0
  140. package/browser/editor/page/folded.mjs +23 -0
  141. package/browser/editor/page/format-bar/bar.mjs +449 -0
  142. package/browser/editor/page/format-bar/brush.mjs +77 -0
  143. package/browser/editor/page/format-bar/colors.mjs +46 -0
  144. package/browser/editor/page/format-bar/index.mjs +404 -0
  145. package/browser/editor/page/formula/index.mjs +236 -0
  146. package/browser/editor/page/formula/panel.mjs +336 -0
  147. package/browser/editor/page/formula/symbols.mjs +156 -0
  148. package/browser/editor/page/frame.mjs +74 -0
  149. package/browser/editor/page/frames.mjs +196 -0
  150. package/browser/editor/page/geometry.mjs +402 -0
  151. package/browser/editor/page/gesture.mjs +45 -0
  152. package/browser/editor/page/handle/index.mjs +650 -0
  153. package/browser/editor/page/handle-sizes.mjs +14 -0
  154. package/browser/editor/page/hints/index.mjs +84 -0
  155. package/browser/editor/page/history.mjs +401 -0
  156. package/browser/editor/page/insert/index.mjs +256 -0
  157. package/browser/editor/page/kept.mjs +38 -0
  158. package/browser/editor/page/links/address.mjs +40 -0
  159. package/browser/editor/page/links/index.mjs +866 -0
  160. package/browser/editor/page/links/pages.mjs +131 -0
  161. package/browser/editor/page/links/views.mjs +369 -0
  162. package/browser/editor/page/long-runs.mjs +75 -0
  163. package/browser/editor/page/look.mjs +77 -0
  164. package/browser/editor/page/made.mjs +24 -0
  165. package/browser/editor/page/margin.mjs +373 -0
  166. package/browser/editor/page/markdown/index.mjs +88 -0
  167. package/browser/editor/page/markdown/rules.mjs +33 -0
  168. package/browser/editor/page/marks.mjs +377 -0
  169. package/browser/editor/page/media-menu/index.mjs +158 -0
  170. package/browser/editor/page/menu.mjs +544 -0
  171. package/browser/editor/page/merge.mjs +124 -0
  172. package/browser/editor/page/notices.mjs +142 -0
  173. package/browser/editor/page/offered.mjs +32 -0
  174. package/browser/editor/page/outline/folds.mjs +53 -0
  175. package/browser/editor/page/outline/index.mjs +783 -0
  176. package/browser/editor/page/outline/list.mjs +184 -0
  177. package/browser/editor/page/outline/read.mjs +201 -0
  178. package/browser/editor/page/outline/strip.mjs +287 -0
  179. package/browser/editor/page/outline/tree.mjs +248 -0
  180. package/browser/editor/page/overlay-layer.mjs +227 -0
  181. package/browser/editor/page/overlays.mjs +205 -0
  182. package/browser/editor/page/own.mjs +28 -0
  183. package/browser/editor/page/pads.mjs +71 -0
  184. package/browser/editor/page/page-objects.mjs +105 -0
  185. package/browser/editor/page/panel.mjs +65 -0
  186. package/browser/editor/page/placement.mjs +58 -0
  187. package/browser/editor/page/post.mjs +41 -0
  188. package/browser/editor/page/present-links.mjs +50 -0
  189. package/browser/editor/page/quiet.mjs +48 -0
  190. package/browser/editor/page/resize/index.mjs +327 -0
  191. package/browser/editor/page/select-all/index.mjs +262 -0
  192. package/browser/editor/page/selection/delete.mjs +61 -0
  193. package/browser/editor/page/selection/index.mjs +164 -0
  194. package/browser/editor/page/selection/marquee.mjs +174 -0
  195. package/browser/editor/page/session.mjs +168 -0
  196. package/browser/editor/page/slash-menu/index.mjs +291 -0
  197. package/browser/editor/page/storage.mjs +48 -0
  198. package/browser/editor/page/sync-state.mjs +267 -0
  199. package/browser/editor/page/table/aligns.mjs +29 -0
  200. package/browser/editor/page/table/cell-bar.mjs +141 -0
  201. package/browser/editor/page/table/cells.mjs +527 -0
  202. package/browser/editor/page/table/icons.mjs +40 -0
  203. package/browser/editor/page/table/index.mjs +990 -0
  204. package/browser/editor/page/table/lists.mjs +187 -0
  205. package/browser/editor/page/table/widths.mjs +313 -0
  206. package/browser/editor/page/tex.mjs +32 -0
  207. package/browser/editor/page/text-select/index.mjs +671 -0
  208. package/browser/editor/page/tooltip.mjs +98 -0
  209. package/browser/editor/page/type-grid.mjs +83 -0
  210. package/browser/editor/page/typing/code-edges.mjs +274 -0
  211. package/browser/editor/page/typing/index.mjs +282 -0
  212. package/browser/editor/page/typing/leave.mjs +68 -0
  213. package/browser/editor/page/ui.mjs +160 -0
  214. package/browser/shared/annotations.mjs +569 -0
  215. package/browser/shared/code-folds.mjs +14 -0
  216. package/browser/shared/code-languages.mjs +70 -0
  217. package/browser/shared/code-lines.mjs +30 -0
  218. package/browser/shared/colors.mjs +30 -0
  219. package/browser/shared/component-catalog.mjs +573 -0
  220. package/browser/shared/components/bookmark.mjs +26 -0
  221. package/browser/shared/components/callout.mjs +9 -0
  222. package/browser/shared/components/chart.mjs +20 -0
  223. package/browser/shared/components/code.mjs +37 -0
  224. package/browser/shared/components/columns.mjs +16 -0
  225. package/browser/shared/components/details.mjs +15 -0
  226. package/browser/shared/components/dialog.mjs +28 -0
  227. package/browser/shared/components/diff.mjs +18 -0
  228. package/browser/shared/components/divider.mjs +6 -0
  229. package/browser/shared/components/embed.mjs +25 -0
  230. package/browser/shared/components/figure.mjs +14 -0
  231. package/browser/shared/components/file.mjs +23 -0
  232. package/browser/shared/components/heading.mjs +6 -0
  233. package/browser/shared/components/highlight.mjs +9 -0
  234. package/browser/shared/components/icon.mjs +18 -0
  235. package/browser/shared/components/image.mjs +39 -0
  236. package/browser/shared/components/index.mjs +396 -0
  237. package/browser/shared/components/installed.mjs +232 -0
  238. package/browser/shared/components/list.mjs +146 -0
  239. package/browser/shared/components/math.mjs +49 -0
  240. package/browser/shared/components/mention.mjs +33 -0
  241. package/browser/shared/components/page.mjs +46 -0
  242. package/browser/shared/components/paragraph.mjs +9 -0
  243. package/browser/shared/components/quote.mjs +6 -0
  244. package/browser/shared/components/section.mjs +8 -0
  245. package/browser/shared/components/sheets.mjs +80 -0
  246. package/browser/shared/components/state.mjs +20 -0
  247. package/browser/shared/components/table.mjs +49 -0
  248. package/browser/shared/components/text.mjs +14 -0
  249. package/browser/shared/components/widget.mjs +10 -0
  250. package/browser/shared/copy-ids.mjs +72 -0
  251. package/browser/shared/css-references.mjs +110 -0
  252. package/browser/shared/document-look.mjs +178 -0
  253. package/browser/shared/emoji/custom.mjs +91 -0
  254. package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
  255. package/browser/shared/emoji/data/LICENSE-mingcute.txt +202 -0
  256. package/browser/shared/emoji/data/LICENSE-tabler.txt +21 -0
  257. package/browser/shared/emoji/data/README.md +28 -0
  258. package/browser/shared/emoji/data/categories.json +1 -0
  259. package/browser/shared/emoji/data/icons.json +1 -0
  260. package/browser/shared/emoji/data/keywords-en.json +1 -0
  261. package/browser/shared/emoji/data/keywords-zh.json +1 -0
  262. package/browser/shared/emoji/data/names.json +1 -0
  263. package/browser/shared/emoji/data/positions.json +1 -0
  264. package/browser/shared/emoji/data/twemoji-index.json +1 -0
  265. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  266. package/browser/shared/emoji/data.mjs +194 -0
  267. package/browser/shared/emoji/emoji.mjs +38 -0
  268. package/browser/shared/emoji/glyphs.mjs +134 -0
  269. package/browser/shared/emoji/icon-value.mjs +91 -0
  270. package/browser/shared/escape.mjs +20 -0
  271. package/browser/shared/export-wrap.mjs +89 -0
  272. package/browser/shared/files.mjs +33 -0
  273. package/browser/shared/html-tree.mjs +59 -0
  274. package/browser/shared/http.mjs +22 -0
  275. package/browser/shared/i18n/en.mjs +1223 -0
  276. package/browser/shared/i18n/index.mjs +132 -0
  277. package/browser/shared/ids.mjs +24 -0
  278. package/browser/shared/import-types.mjs +23 -0
  279. package/browser/shared/inline-spacing.mjs +97 -0
  280. package/browser/shared/layers.mjs +42 -0
  281. package/browser/shared/long-runs.mjs +39 -0
  282. package/browser/shared/media.mjs +162 -0
  283. package/browser/shared/new-names.mjs +67 -0
  284. package/browser/shared/number-reading.mjs +92 -0
  285. package/browser/shared/old-names.mjs +143 -0
  286. package/browser/shared/outline.mjs +194 -0
  287. package/browser/shared/page-address.mjs +140 -0
  288. package/browser/shared/page-links.mjs +86 -0
  289. package/browser/shared/paths.mjs +73 -0
  290. package/browser/shared/preferences.mjs +116 -0
  291. package/browser/shared/preview-server.mjs +247 -0
  292. package/browser/shared/qa-levels.mjs +93 -0
  293. package/browser/shared/reading-place.mjs +91 -0
  294. package/browser/shared/renamed-storage.mjs +220 -0
  295. package/browser/shared/reports.mjs +46 -0
  296. package/browser/shared/search.mjs +85 -0
  297. package/browser/shared/session.mjs +77 -0
  298. package/browser/shared/table-chart.mjs +113 -0
  299. package/browser/shared/table-hides.mjs +120 -0
  300. package/browser/shared/table-slots.mjs +75 -0
  301. package/browser/shared/words.mjs +23 -0
  302. package/browser/shared/workspace-look.mjs +91 -0
  303. package/browser/shared/workspace.mjs +535 -0
  304. package/browser/shared/writing-preferences.mjs +68 -0
  305. package/browser/shared/zoom.mjs +57 -0
  306. package/dist/chunk-2B5E4CDJ.mjs +2 -0
  307. package/dist/chunk-342HXE3Q.mjs +2 -0
  308. package/dist/chunk-3HIRPVLU.mjs +2 -0
  309. package/dist/chunk-43B75J5T.mjs +2 -0
  310. package/dist/chunk-4FS7Z7WR.mjs +2 -0
  311. package/dist/chunk-4K5KC6V2.mjs +2 -0
  312. package/dist/chunk-5L7RYZCL.mjs +2 -0
  313. package/dist/chunk-5MHMDLZD.mjs +4 -0
  314. package/dist/chunk-5ZKJ3H4P.mjs +8 -0
  315. package/dist/chunk-64K7IPLO.mjs +255 -0
  316. package/dist/chunk-6QXGZM36.mjs +8 -0
  317. package/dist/chunk-6RGJOMJP.mjs +16 -0
  318. package/dist/chunk-742D2WWJ.mjs +19 -0
  319. package/dist/chunk-7DTINW6U.mjs +48 -0
  320. package/dist/chunk-A55HN5OK.mjs +2 -0
  321. package/dist/chunk-AGDILNWB.mjs +2 -0
  322. package/dist/chunk-AJ73XJF3.mjs +2 -0
  323. package/dist/chunk-AUZGSZJH.mjs +13 -0
  324. package/dist/chunk-BFE45AKL.mjs +2 -0
  325. package/dist/chunk-BGGDRNYQ.mjs +10 -0
  326. package/dist/chunk-BXO2ZY5P.mjs +2 -0
  327. package/dist/chunk-C564NU2H.mjs +77 -0
  328. package/dist/chunk-CEH4MRCC.mjs +2 -0
  329. package/dist/chunk-CY2FNNAB.mjs +16 -0
  330. package/dist/chunk-DFUDV4LX.mjs +2 -0
  331. package/dist/chunk-DKXG4XDG.mjs +2 -0
  332. package/dist/chunk-E7LWZRXY.mjs +4 -0
  333. package/dist/chunk-EZQ34M3F.mjs +124 -0
  334. package/dist/chunk-EZY3WC6Z.mjs +15 -0
  335. package/dist/chunk-FDLXYYG4.mjs +4 -0
  336. package/dist/chunk-FUKQNOQS.mjs +9 -0
  337. package/dist/chunk-GB5SOYQJ.mjs +7 -0
  338. package/dist/chunk-GRAXKKG4.mjs +2 -0
  339. package/dist/chunk-HYMEEXKN.mjs +4 -0
  340. package/dist/chunk-IVDLMMBD.mjs +2 -0
  341. package/dist/chunk-JPOSLGOC.mjs +6 -0
  342. package/dist/chunk-JVHHHGEA.mjs +3 -0
  343. package/dist/chunk-L3QKH4OK.mjs +26 -0
  344. package/dist/chunk-LAE5NQ4B.mjs +2 -0
  345. package/dist/chunk-LCTHTZIL.mjs +960 -0
  346. package/dist/chunk-LEF6DRCK.mjs +59 -0
  347. package/dist/chunk-LKX55H76.mjs +2 -0
  348. package/dist/chunk-LS4F7JUM.mjs +2 -0
  349. package/dist/chunk-MAFIGVXY.mjs +2 -0
  350. package/dist/chunk-NO5NJCHO.mjs +2 -0
  351. package/dist/chunk-NQPVAU63.mjs +2 -0
  352. package/dist/chunk-NSKUTQ5J.mjs +5 -0
  353. package/dist/chunk-O35FIXRB.mjs +2 -0
  354. package/dist/chunk-P2CAZPDP.mjs +3 -0
  355. package/dist/chunk-PL6GHLGD.mjs +15 -0
  356. package/dist/chunk-QAIHRH3I.mjs +13 -0
  357. package/dist/chunk-QJIR2BLP.mjs +6 -0
  358. package/dist/chunk-QR6A54KJ.mjs +3 -0
  359. package/dist/chunk-QUPLVPB2.mjs +7 -0
  360. package/dist/chunk-R7BNENLY.mjs +4 -0
  361. package/dist/chunk-S6O4UHLC.mjs +2 -0
  362. package/dist/chunk-SGJWQKEI.mjs +2 -0
  363. package/dist/chunk-SYGN7GLU.mjs +2 -0
  364. package/dist/chunk-TMYZB6AV.mjs +2 -0
  365. package/dist/chunk-TX6JH7TR.mjs +2 -0
  366. package/dist/chunk-TYK6VNAB.mjs +10 -0
  367. package/dist/chunk-U3SSPL4K.mjs +8 -0
  368. package/dist/chunk-U6KNPJPR.mjs +2 -0
  369. package/dist/chunk-UALRNVSE.mjs +4 -0
  370. package/dist/chunk-UH4SIXTR.mjs +2 -0
  371. package/dist/chunk-UMHUSOPJ.mjs +2 -0
  372. package/dist/chunk-V3HXVQEM.mjs +2 -0
  373. package/dist/chunk-V5JTW2LH.mjs +27 -0
  374. package/dist/chunk-V5VXUJKG.mjs +2 -0
  375. package/dist/chunk-V6XZ4VIR.mjs +2 -0
  376. package/dist/chunk-VBXMADMP.mjs +2 -0
  377. package/dist/chunk-VNV55RUA.mjs +2 -0
  378. package/dist/chunk-VPD2PS35.mjs +2 -0
  379. package/dist/chunk-W3BGBJQW.mjs +2 -0
  380. package/dist/chunk-W4VKN3GF.mjs +7 -0
  381. package/dist/chunk-W5BXXPDJ.mjs +3 -0
  382. package/dist/chunk-W7XHE4CT.mjs +2 -0
  383. package/dist/chunk-XNROSH2T.mjs +4 -0
  384. package/dist/chunk-XUNHRCOG.mjs +6 -0
  385. package/dist/chunk-Y34NR5JL.mjs +2 -0
  386. package/dist/chunk-Y6RLRPG3.mjs +3 -0
  387. package/dist/chunk-YEY3RSFQ.mjs +2 -0
  388. package/dist/cli.mjs +2 -0
  389. package/dist/server.mjs +2 -0
  390. package/dist/worker.mjs +5 -0
  391. package/kit/charts.js +355 -0
  392. package/kit/code.js +164 -0
  393. package/kit/dialogs.js +157 -0
  394. package/kit/math.js +2004 -0
  395. package/kit/report.css +2932 -0
  396. package/kit/runtime.js +1782 -0
  397. package/kit/sheets.js +123 -0
  398. package/kit/state.js +217 -0
  399. package/kit/tables.js +1499 -0
  400. package/kit/tokens.js +29 -0
  401. package/kit/ui.js +658 -0
  402. package/package.json +41 -4
  403. package/release.json +25 -0
  404. package/sdk/column-widths.d.ts +56 -0
  405. package/sdk/doc-charts.d.ts +82 -0
  406. package/sdk/doc-code.d.ts +28 -0
  407. package/sdk/doc-dialogs.d.ts +4 -0
  408. package/sdk/doc-kit.d.ts +147 -0
  409. package/sdk/doc-math.d.ts +3 -0
  410. package/sdk/doc-sheets.d.ts +15 -0
  411. package/sdk/doc-state.d.ts +41 -0
  412. package/sdk/doc-tables.d.ts +24 -0
  413. package/sdk/doc-tokens.d.ts +22 -0
  414. package/sdk/index.d.ts +30 -0
  415. package/skill/SKILL.md +150 -0
  416. package/skill/agents/openai.yaml +5 -0
  417. package/skill/references/building-components.md +367 -0
  418. package/skill/references/example-report.html +356 -0
  419. package/skill/references/writing-html.md +187 -0
  420. package/skill/sdk/column-widths.d.ts +56 -0
  421. package/skill/sdk/doc-charts.d.ts +82 -0
  422. package/skill/sdk/doc-code.d.ts +28 -0
  423. package/skill/sdk/doc-dialogs.d.ts +4 -0
  424. package/skill/sdk/doc-kit.d.ts +147 -0
  425. package/skill/sdk/doc-math.d.ts +3 -0
  426. package/skill/sdk/doc-sheets.d.ts +15 -0
  427. package/skill/sdk/doc-state.d.ts +41 -0
  428. package/skill/sdk/doc-tables.d.ts +24 -0
  429. package/skill/sdk/doc-tokens.d.ts +22 -0
  430. package/skill/sdk/index.d.ts +30 -0
  431. package/starter/doc.html +21 -0
  432. package/starter/doc.json +5 -0
  433. package/vendor/d3.v7.9.0.min.js +2 -0
  434. package/vendor/katex/auto-render.min.js +1 -0
  435. package/vendor/katex/contrib/mhchem.min.js +1 -0
  436. package/vendor/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  437. package/vendor/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  438. package/vendor/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  439. package/vendor/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  440. package/vendor/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  441. package/vendor/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  442. package/vendor/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  443. package/vendor/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  444. package/vendor/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  445. package/vendor/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  446. package/vendor/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  447. package/vendor/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  448. package/vendor/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  449. package/vendor/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  450. package/vendor/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  451. package/vendor/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  452. package/vendor/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  453. package/vendor/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  454. package/vendor/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  455. package/vendor/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  456. package/vendor/katex/katex.min.css +1 -0
  457. package/vendor/katex/katex.min.js +1 -0
  458. package/vendor/pdfjs/LICENSE +177 -0
  459. package/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  460. package/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  461. package/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  462. package/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  463. package/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  464. package/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  465. package/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  466. package/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  467. package/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  468. package/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  469. package/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  470. package/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  471. package/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  472. package/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  473. package/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  474. package/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  475. package/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  476. package/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  477. package/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  478. package/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  479. package/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  480. package/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  481. package/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  482. package/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  483. package/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  484. package/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  485. package/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  486. package/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  487. package/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  488. package/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  489. package/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  490. package/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  491. package/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  492. package/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  493. package/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  494. package/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  495. package/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  496. package/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  497. package/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  498. package/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  499. package/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  500. package/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  501. package/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  502. package/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  503. package/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  504. package/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  505. package/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  506. package/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  507. package/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  508. package/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  509. package/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  510. package/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  511. package/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  512. package/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  513. package/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  514. package/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  515. package/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  516. package/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  517. package/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  518. package/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  519. package/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  520. package/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  521. package/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  522. package/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  523. package/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  524. package/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  525. package/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  526. package/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  527. package/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  528. package/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  529. package/vendor/pdfjs/cmaps/GB-H.bcmap +4 -0
  530. package/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  531. package/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  532. package/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  533. package/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  534. package/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  535. package/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  536. package/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  537. package/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  538. package/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  539. package/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  540. package/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  541. package/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  542. package/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  543. package/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  544. package/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  545. package/vendor/pdfjs/cmaps/H.bcmap +0 -0
  546. package/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  547. package/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  548. package/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  549. package/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  550. package/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  551. package/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  552. package/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  553. package/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  554. package/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  555. package/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  556. package/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  557. package/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  558. package/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  559. package/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  560. package/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  561. package/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  562. package/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  563. package/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  564. package/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  565. package/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  566. package/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  567. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  568. package/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  569. package/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  570. package/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  571. package/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  572. package/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  573. package/vendor/pdfjs/cmaps/LICENSE +36 -0
  574. package/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  575. package/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  576. package/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  577. package/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  578. package/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  579. package/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  580. package/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  581. package/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  582. package/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  583. package/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  584. package/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  585. package/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  586. package/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  587. package/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  588. package/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  589. package/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  590. package/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  591. package/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  592. package/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  593. package/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  594. package/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  595. package/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  596. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  597. package/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  598. package/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  599. package/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  600. package/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  601. package/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  602. package/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  603. package/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  604. package/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  605. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  606. package/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  607. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  608. package/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  609. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  610. package/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  611. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  612. package/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  613. package/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  614. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  615. package/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  616. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  617. package/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  618. package/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  619. package/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  620. package/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  621. package/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  622. package/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  623. package/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  624. package/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  625. package/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  626. package/vendor/pdfjs/cmaps/V.bcmap +0 -0
  627. package/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  628. package/vendor/pdfjs/legacy/build/pdf.min.mjs +27 -0
  629. package/vendor/pdfjs/legacy/build/pdf.worker.min.mjs +27 -0
  630. package/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  631. package/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  632. package/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  633. package/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  634. package/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  635. package/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  636. package/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  637. package/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  638. package/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  639. package/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  640. package/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  641. package/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  642. package/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  643. package/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  644. package/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  645. package/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  646. package/vendor/types/@types/d3/LICENSE +21 -0
  647. package/vendor/types/@types/d3/index.d.ts +39 -0
  648. package/vendor/types/@types/d3/package.json +81 -0
  649. package/vendor/types/@types/d3-array/LICENSE +21 -0
  650. package/vendor/types/@types/d3-array/index.d.ts +1118 -0
  651. package/vendor/types/@types/d3-array/package.json +56 -0
  652. package/vendor/types/@types/d3-axis/LICENSE +21 -0
  653. package/vendor/types/@types/d3-axis/index.d.ts +293 -0
  654. package/vendor/types/@types/d3-axis/package.json +47 -0
  655. package/vendor/types/@types/d3-brush/LICENSE +21 -0
  656. package/vendor/types/@types/d3-brush/index.d.ts +255 -0
  657. package/vendor/types/@types/d3-brush/package.json +42 -0
  658. package/vendor/types/@types/d3-chord/LICENSE +21 -0
  659. package/vendor/types/@types/d3-chord/index.d.ts +471 -0
  660. package/vendor/types/@types/d3-chord/package.json +40 -0
  661. package/vendor/types/@types/d3-color/LICENSE +21 -0
  662. package/vendor/types/@types/d3-color/index.d.ts +669 -0
  663. package/vendor/types/@types/d3-color/package.json +55 -0
  664. package/vendor/types/@types/d3-contour/LICENSE +21 -0
  665. package/vendor/types/@types/d3-contour/index.d.ts +222 -0
  666. package/vendor/types/@types/d3-contour/package.json +38 -0
  667. package/vendor/types/@types/d3-delaunay/LICENSE +21 -0
  668. package/vendor/types/@types/d3-delaunay/index.d.ts +316 -0
  669. package/vendor/types/@types/d3-delaunay/package.json +30 -0
  670. package/vendor/types/@types/d3-dispatch/LICENSE +21 -0
  671. package/vendor/types/@types/d3-dispatch/index.d.ts +96 -0
  672. package/vendor/types/@types/d3-dispatch/package.json +51 -0
  673. package/vendor/types/@types/d3-drag/LICENSE +21 -0
  674. package/vendor/types/@types/d3-drag/index.d.ts +395 -0
  675. package/vendor/types/@types/d3-drag/package.json +42 -0
  676. package/vendor/types/@types/d3-dsv/LICENSE +21 -0
  677. package/vendor/types/@types/d3-dsv/index.d.ts +482 -0
  678. package/vendor/types/@types/d3-dsv/package.json +45 -0
  679. package/vendor/types/@types/d3-ease/LICENSE +21 -0
  680. package/vendor/types/@types/d3-ease/index.d.ts +316 -0
  681. package/vendor/types/@types/d3-ease/package.json +40 -0
  682. package/vendor/types/@types/d3-fetch/LICENSE +21 -0
  683. package/vendor/types/@types/d3-fetch/index.d.ts +282 -0
  684. package/vendor/types/@types/d3-fetch/package.json +37 -0
  685. package/vendor/types/@types/d3-force/LICENSE +21 -0
  686. package/vendor/types/@types/d3-force/index.d.ts +899 -0
  687. package/vendor/types/@types/d3-force/package.json +45 -0
  688. package/vendor/types/@types/d3-format/LICENSE +21 -0
  689. package/vendor/types/@types/d3-format/index.d.ts +337 -0
  690. package/vendor/types/@types/d3-format/package.json +45 -0
  691. package/vendor/types/@types/d3-geo/LICENSE +21 -0
  692. package/vendor/types/@types/d3-geo/index.d.ts +1371 -0
  693. package/vendor/types/@types/d3-geo/package.json +48 -0
  694. package/vendor/types/@types/d3-hierarchy/LICENSE +21 -0
  695. package/vendor/types/@types/d3-hierarchy/index.d.ts +928 -0
  696. package/vendor/types/@types/d3-hierarchy/package.json +50 -0
  697. package/vendor/types/@types/d3-interpolate/LICENSE +21 -0
  698. package/vendor/types/@types/d3-interpolate/index.d.ts +387 -0
  699. package/vendor/types/@types/d3-interpolate/package.json +47 -0
  700. package/vendor/types/@types/d3-path/LICENSE +21 -0
  701. package/vendor/types/@types/d3-path/index.d.ts +108 -0
  702. package/vendor/types/@types/d3-path/package.json +41 -0
  703. package/vendor/types/@types/d3-polygon/LICENSE +21 -0
  704. package/vendor/types/@types/d3-polygon/index.d.ts +41 -0
  705. package/vendor/types/@types/d3-polygon/package.json +40 -0
  706. package/vendor/types/@types/d3-quadtree/LICENSE +21 -0
  707. package/vendor/types/@types/d3-quadtree/index.d.ts +204 -0
  708. package/vendor/types/@types/d3-quadtree/package.json +45 -0
  709. package/vendor/types/@types/d3-random/LICENSE +21 -0
  710. package/vendor/types/@types/d3-random/index.d.ts +313 -0
  711. package/vendor/types/@types/d3-random/package.json +41 -0
  712. package/vendor/types/@types/d3-scale/LICENSE +21 -0
  713. package/vendor/types/@types/d3-scale/index.d.ts +2669 -0
  714. package/vendor/types/@types/d3-scale/package.json +53 -0
  715. package/vendor/types/@types/d3-scale-chromatic/LICENSE +21 -0
  716. package/vendor/types/@types/d3-scale-chromatic/index.d.ts +520 -0
  717. package/vendor/types/@types/d3-scale-chromatic/package.json +46 -0
  718. package/vendor/types/@types/d3-selection/LICENSE +21 -0
  719. package/vendor/types/@types/d3-selection/index.d.ts +1210 -0
  720. package/vendor/types/@types/d3-selection/package.json +56 -0
  721. package/vendor/types/@types/d3-shape/LICENSE +21 -0
  722. package/vendor/types/@types/d3-shape/index.d.ts +2792 -0
  723. package/vendor/types/@types/d3-shape/package.json +53 -0
  724. package/vendor/types/@types/d3-time/LICENSE +21 -0
  725. package/vendor/types/@types/d3-time/index.d.ts +697 -0
  726. package/vendor/types/@types/d3-time/package.json +46 -0
  727. package/vendor/types/@types/d3-time-format/LICENSE +21 -0
  728. package/vendor/types/@types/d3-time-format/index.d.ts +202 -0
  729. package/vendor/types/@types/d3-time-format/package.json +40 -0
  730. package/vendor/types/@types/d3-timer/LICENSE +21 -0
  731. package/vendor/types/@types/d3-timer/index.d.ts +68 -0
  732. package/vendor/types/@types/d3-timer/package.json +45 -0
  733. package/vendor/types/@types/d3-transition/LICENSE +21 -0
  734. package/vendor/types/@types/d3-transition/index.d.ts +664 -0
  735. package/vendor/types/@types/d3-transition/package.json +47 -0
  736. package/vendor/types/@types/d3-zoom/LICENSE +21 -0
  737. package/vendor/types/@types/d3-zoom/index.d.ts +611 -0
  738. package/vendor/types/@types/d3-zoom/package.json +48 -0
  739. package/vendor/types/@types/geojson/LICENSE +21 -0
  740. package/vendor/types/@types/geojson/index.d.ts +202 -0
  741. package/vendor/types/@types/geojson/package.json +46 -0
  742. package/vendor/typescript/LICENSE.txt +55 -0
  743. package/vendor/typescript/lib.decorators.d.ts +384 -0
  744. package/vendor/typescript/lib.decorators.legacy.d.ts +22 -0
  745. package/vendor/typescript/lib.dom.d.ts +39429 -0
  746. package/vendor/typescript/lib.dom.iterable.d.ts +571 -0
  747. package/vendor/typescript/lib.es2015.collection.d.ts +147 -0
  748. package/vendor/typescript/lib.es2015.core.d.ts +597 -0
  749. package/vendor/typescript/lib.es2015.d.ts +28 -0
  750. package/vendor/typescript/lib.es2015.generator.d.ts +77 -0
  751. package/vendor/typescript/lib.es2015.iterable.d.ts +605 -0
  752. package/vendor/typescript/lib.es2015.promise.d.ts +81 -0
  753. package/vendor/typescript/lib.es2015.proxy.d.ts +128 -0
  754. package/vendor/typescript/lib.es2015.reflect.d.ts +144 -0
  755. package/vendor/typescript/lib.es2015.symbol.d.ts +46 -0
  756. package/vendor/typescript/lib.es2015.symbol.wellknown.d.ts +326 -0
  757. package/vendor/typescript/lib.es2016.array.include.d.ts +116 -0
  758. package/vendor/typescript/lib.es2016.d.ts +21 -0
  759. package/vendor/typescript/lib.es2016.intl.d.ts +31 -0
  760. package/vendor/typescript/lib.es2017.arraybuffer.d.ts +21 -0
  761. package/vendor/typescript/lib.es2017.d.ts +26 -0
  762. package/vendor/typescript/lib.es2017.date.d.ts +31 -0
  763. package/vendor/typescript/lib.es2017.intl.d.ts +44 -0
  764. package/vendor/typescript/lib.es2017.object.d.ts +49 -0
  765. package/vendor/typescript/lib.es2017.sharedmemory.d.ts +135 -0
  766. package/vendor/typescript/lib.es2017.string.d.ts +45 -0
  767. package/vendor/typescript/lib.es2017.typedarrays.d.ts +53 -0
  768. package/vendor/typescript/lib.es2018.asyncgenerator.d.ts +77 -0
  769. package/vendor/typescript/lib.es2018.asynciterable.d.ts +53 -0
  770. package/vendor/typescript/lib.es2018.d.ts +24 -0
  771. package/vendor/typescript/lib.es2018.intl.d.ts +83 -0
  772. package/vendor/typescript/lib.es2018.promise.d.ts +30 -0
  773. package/vendor/typescript/lib.es2018.regexp.d.ts +37 -0
  774. package/vendor/typescript/lib.es2019.array.d.ts +79 -0
  775. package/vendor/typescript/lib.es2019.d.ts +24 -0
  776. package/vendor/typescript/lib.es2019.intl.d.ts +23 -0
  777. package/vendor/typescript/lib.es2019.object.d.ts +33 -0
  778. package/vendor/typescript/lib.es2019.string.d.ts +37 -0
  779. package/vendor/typescript/lib.es2019.symbol.d.ts +24 -0
  780. package/vendor/typescript/lib.es2020.bigint.d.ts +765 -0
  781. package/vendor/typescript/lib.es2020.d.ts +27 -0
  782. package/vendor/typescript/lib.es2020.date.d.ts +42 -0
  783. package/vendor/typescript/lib.es2020.intl.d.ts +474 -0
  784. package/vendor/typescript/lib.es2020.number.d.ts +28 -0
  785. package/vendor/typescript/lib.es2020.promise.d.ts +47 -0
  786. package/vendor/typescript/lib.es2020.sharedmemory.d.ts +99 -0
  787. package/vendor/typescript/lib.es2020.string.d.ts +44 -0
  788. package/vendor/typescript/lib.es2020.symbol.wellknown.d.ts +41 -0
  789. package/vendor/typescript/lib.es2021.d.ts +23 -0
  790. package/vendor/typescript/lib.es2021.intl.d.ts +166 -0
  791. package/vendor/typescript/lib.es2021.promise.d.ts +48 -0
  792. package/vendor/typescript/lib.es2021.string.d.ts +33 -0
  793. package/vendor/typescript/lib.es2021.weakref.d.ts +78 -0
  794. package/vendor/typescript/lib.es2022.array.d.ts +121 -0
  795. package/vendor/typescript/lib.es2022.d.ts +25 -0
  796. package/vendor/typescript/lib.es2022.error.d.ts +75 -0
  797. package/vendor/typescript/lib.es2022.intl.d.ts +145 -0
  798. package/vendor/typescript/lib.es2022.object.d.ts +26 -0
  799. package/vendor/typescript/lib.es2022.regexp.d.ts +39 -0
  800. package/vendor/typescript/lib.es2022.string.d.ts +25 -0
  801. package/vendor/typescript/lib.es5.d.ts +4601 -0
  802. package/vendor/typescript/package.json +4 -0
  803. package/vendor/typescript/typescript.js +446 -0
  804. package/web/assets/index-Bh74DfsV.css +1 -0
  805. package/web/assets/index-UW0RyFFt.js +13 -0
  806. package/web/index.html +14 -0
@@ -0,0 +1,831 @@
1
+ import { ELEMENT_ID, blocksIn, boxKind, dropIfEmpty, firstLineOf, heldIn, identityOf, isEmpty, isFirstLine, isHost, nestedBlocks, newContainer, newHost, newTail, ownHTML, placeBefore, removalTarget, unitElement, withLeads } from "./core.mjs";
2
+ import { begin, done, made } from "./made.mjs";
3
+ import { menuEntry, pageOfType, variantKeys } from "./page-objects.mjs";
4
+ import { ATTRIBUTES, BLOCK_TYPES, FRESH, HEADING_TYPES, HOLDERS, IDENTITY, TEXT_TYPES, TOGGLES, TURN_INTO, accepts, blockTypeOf, textTypeOf, turnsEmpty } from "../components/registry.mjs";
5
+ import { pageBuild } from "../components/builders.mjs";
6
+ import { iconElement } from "../components/icon/index.mjs";
7
+ import { retagList } from "../components/list/page.mjs";
8
+ import { joins } from "../components/list/join.mjs";
9
+ import { LIST_TYPES } from "../components/list/index.mjs";
10
+ import { isStep } from "../components/flowchart/index.mjs";
11
+ import { asTitle, flowchartFromList, flowchartFromPanel, itemFromStep, listFromFlowchart, newStep, panelColors } from "../components/flowchart/page.mjs";
12
+
13
+ // Turning blocks into other types on the page (DOM only; tested with jsdom): text, small text
14
+ // (小字, the kit's .doc-note), four heading levels, bulleted, numbered and to-do lists and flow charts (流程图), disclosures
15
+ // (折叠列表), highlight panels (高亮块: a container with the opening summary's look, whose blocks keep
16
+ // their own types, lists and headings among them) and callouts (提示块: the same kind of container, its
17
+ // look its own; a block turned into either, or into a disclosure, goes into it as it is), code blocks, quotes and
18
+ // dividers; the types are the components' (src/editor/components/, registry.mjs), and so is how a
19
+ // type that is no text block is made (its `create`). The "/" menu,
20
+ // Markdown shortcuts, the block menu and its "在下方新建一块" all come here (editor.mjs:
21
+ // slash-menu/, markdown/, block-menu/, insert/). A converted block is a new element with the identity of the one it stands
22
+ // for (core.mjs ELEMENT_ID; data-ge-convert and data-ge-unit carry the unit's id), so the save turns it into a conversion
23
+ // in place, and undo putting the old element back turns it back (commit.mjs compares types); a block that
24
+ // keeps its tag (a quote's paragraph taken out of the quote) is moved as it is. New containers
25
+ // (lists, quotes, panels, sections) are boxes of their own (newContainer); a list, quote or panel
26
+ // goes when its last block leaves it, and one split by taking a block out of its middle leaves a
27
+ // new container with the blocks after it. A flowchart (components/flowchart/) is no list of items
28
+ // here: a block turned into one is a node of it (its text the node's title, bold), a whole list turned
29
+ // into one has its items made nodes and back (what each holds the node's content), a step turned
30
+ // into a list's item or a highlight block leaves its flowchart (split around it), and a node's first
31
+ // line, its title, is turned into nothing.
32
+
33
+ // The containers a type puts a block in: its tag (and class). A list item or a quote's paragraph
34
+ // is of its container's type; the blocks of a panel keep their own.
35
+ // (Each type's `container`, `wraps` and `leaf` in its component's description.)
36
+ const typesWith = (field) => Object.fromEntries(Object.entries(BLOCK_TYPES).filter(([, spec]) => spec[field]).map(([type, spec]) => [type, spec[field]]));
37
+ const CONTAINERS = typesWith("container");
38
+ const WRAPS = typesWith("wraps");
39
+ // The text block of each type.
40
+ const LEAF = typesWith("leaf");
41
+ const MARKER = /^(contenteditable|data-ge-|spellcheck$)/;
42
+ // What a converted block carries over: every attribute but the editor's markers, its class (which
43
+ // tells its type) and its identity (which the save keeps on its own).
44
+ const carried = (attribute) => !MARKER.test(attribute.name) && attribute.name !== "class" && attribute.name !== IDENTITY;
45
+
46
+ // An attribute a block's kind sets (a to-do item's checked state): its own, never carried to another type.
47
+ const ownAttribute = (host, name) => Boolean(ATTRIBUTES[host.getAttribute("data-ge-unit-kind") ?? (host.localName === "li" ? "item" : "")]?.[name]);
48
+
49
+ // The types a block, or a group of blocks, goes into as it is (each keeping its type: `takesAsIs`): a
50
+ // highlight block (notion-lite's callout, whose body is its children: transformBlocks moves the blocks
51
+ // into a new one), a callout (the same kind of block) and, as the reader asked, a disclosure (into its
52
+ // content; its title left empty to type).
53
+ const TAKES_AS_IS = new Set(Object.keys(typesWith("takesAsIs")));
54
+
55
+ // Whether a box takes the block of a type: what its role accepts, and none of a type that does not
56
+ // nest (`nests`) in a box of its own kind. Kept here (not in `accepts`, which the server and the drop
57
+ // check share): a drop or a file may still nest one.
58
+ const takesType = (box, type) => accepts(box, BLOCK_TYPES[type].kind) && (BLOCK_TYPES[type].nests !== false || BLOCK_TYPES[type].box !== box);
59
+
60
+ const wraps = (node, type) => Boolean(CONTAINERS[type]) && node?.nodeType === 1 && node.matches(CONTAINERS[type]);
61
+
62
+ /** The type a text block shows as (TURN_INTO, or heading4 and a classed leaf of the author's); null for others. */
63
+ export function typeOf(host) {
64
+ const wrapper = host.parentElement;
65
+ if (host.tagName === "LI") return LIST_TYPES.find((type) => wraps(wrapper, type)) ?? null;
66
+ if (host.tagName === "P") return wraps(wrapper, "quote") ? "quote" : textTypeOf(host);
67
+ if (HEADING_TYPES[host.tagName]) return HEADING_TYPES[host.tagName];
68
+ if (host.getAttribute("data-ge-kind") === "code") return "code";
69
+ const own = blockTypeOf(host);
70
+ return TEXT_TYPES.has(own) ? own : null;
71
+ }
72
+
73
+ // The list or quote a text block sits in, or null.
74
+ const wrapperOf = (host) => WRAPS[typeOf(host)] ? host.parentElement : null;
75
+
76
+ /**
77
+ * Whether a text block can be turned into another type: a block of its own in a box (a panel's
78
+ * block among them, or the item or paragraph of a list or quote that is a box), made on the page or
79
+ * in the file. Its attributes go with it (an id stays where links find it); only a block the
80
+ * report's script refers to keeps its type, since the script may count on its element. A code
81
+ * block keeps its type.
82
+ */
83
+ export function convertible(host) {
84
+ // An item holding blocks (or that held them in the file) stays an item: what it holds goes with it.
85
+ // A flowchart node's first line is its title, always a paragraph (core.mjs firstLineOf).
86
+ return standing(host) && nestedBlocks(host).length === 0 && !host.hasAttribute("data-ge-nested") && !isFirstLine(host);
87
+ }
88
+
89
+ // A text block of a type, a block of its own in a box (or the item or paragraph of a list or quote
90
+ // that is a box) that the report's script does not refer to: what convertible asks but whether it
91
+ // holds blocks.
92
+ function standing(host) {
93
+ const type = isHost(host) ? typeOf(host) : null;
94
+ if (!type || type === "code" || host.closest("summary")) return false;
95
+ if (host.hasAttribute("data-ge-block") && (!host.hasAttribute("data-ge-unit") || host.getAttribute("data-ge-keep") === "script")) return false;
96
+ const wrapper = wrapperOf(host);
97
+ if (wrapper && !wrapper.hasAttribute("data-ge-box")) return false;
98
+ return Boolean((wrapper ?? host).parentElement?.hasAttribute("data-ge-box"));
99
+ }
100
+
101
+ /**
102
+ * The types a text block can be turned into (its own type among them), in menu order; a panel not
103
+ * inside a panel.
104
+ */
105
+ export function targetsOf(host) {
106
+ if (!convertible(host)) return [];
107
+ const box = boxKind((wrapperOf(host) ?? host).parentElement);
108
+ return TURN_INTO.filter((type) => takesType(box, type));
109
+ }
110
+
111
+ /**
112
+ * The types a text block can be turned into from its block menu or the format bar (its own among
113
+ * them): targetsOf, or for a list item holding blocks (or that held them in the file), which stays an
114
+ * item, what it holds going with it, another kind of list, a highlight block or a disclosure
115
+ * (notion-lite's turnInto keeps a block's children where the new type has them; an item from the
116
+ * middle of its list goes as convertBlock takes it: the list split around it). Wherever the item
117
+ * stands in its list, the first or not.
118
+ */
119
+ export function turnTargets(host) {
120
+ if (convertible(host)) return targetsOf(host);
121
+ if (host?.localName !== "li" || !standing(host)) return [];
122
+ const box = boxKind(host.parentElement.parentElement);
123
+ return TURN_INTO.filter((type) => (LIST_TYPES.includes(type) || TAKES_AS_IS.has(type)) && takesType(box, type));
124
+ }
125
+
126
+ // The types made as an empty block standing for an empty one (FRESH) that a box takes, after `types`.
127
+ const withFresh = (types, box) => [...types, ...FRESH.filter((type) => !types.includes(type) && takesType(box, type))];
128
+
129
+ // The variants a box takes (notion-lite's "type:variant"): what is a whole block goes where a block of
130
+ // its own stands.
131
+ const variantsIn = (box) => variantKeys().filter((key) => takesType(box, menuEntry(key).type));
132
+
133
+ /**
134
+ * The types a block made below `target` may be ("/" in a block with text, the block menu's
135
+ * 在下方新建): those its box takes, a divider, the media blocks, a table, a Sheet area and a formula
136
+ * block among them, and the variants it takes. Below a list's item or a quote's line that box is the
137
+ * list's or the quote's, and the new block takes it apart there (convertBlock).
138
+ */
139
+ export function belowTargets(target) {
140
+ const own = isHost(target) ? wrapperOf(target) ?? target : target;
141
+ const box = boxKind(own.parentElement);
142
+ return [...withFresh(TURN_INTO.filter((type) => takesType(box, type)), box), ...variantsIn(box)];
143
+ }
144
+
145
+ // A unit that holds nothing to carry (`turnsEmpty`: a divider line): what it is turned into is an
146
+ // empty block in its place. Its own type is the one of its kind.
147
+ const turnedEmpty = (unit) => turnsEmpty(unit?.getAttribute("data-ge-unit-kind"));
148
+ const ownEmptyType = (unit) => Object.keys(BLOCK_TYPES).find((type) => BLOCK_TYPES[type].kind === unit.getAttribute("data-ge-unit-kind")) ?? null;
149
+
150
+ /** The types such a unit can be turned into (its own among them): the types its box takes, as an empty block of it. */
151
+ export function emptyTargets(unit) {
152
+ if (!turnedEmpty(unit) || !unit.parentElement?.hasAttribute("data-ge-box") || unit.hasAttribute("data-ge-keep")) return [];
153
+ const box = boxKind(unit.parentElement);
154
+ return TURN_INTO.filter((type) => takesType(box, type));
155
+ }
156
+
157
+ /**
158
+ * The type an element is of itself, as a conversion changes it (wherever it stands: a quote's
159
+ * paragraph taken out of its quote is the same paragraph): a list item "item", a flowchart's step "step"
160
+ * (a container: one undo puts back is made again around its blocks, sync-state.mjs), a code block "code",
161
+ * a container its own, a text block its text's; any other unit its tag. Two elements of one
162
+ * identity (a block and the one it was turned into) differ in it (commit.mjs).
163
+ */
164
+ export function ownTypeOf(unit) {
165
+ // (A step told by its list, or by its kind where it stands in none: a copy of its start tag, as a layout keeps one.)
166
+ if (unit.localName === "li") return isStep(unit) || unit.getAttribute("data-ge-unit-kind") === "step" ? "step" : "item";
167
+ if (unit.matches(".doc-code")) return "code";
168
+ const container = containerType(unit);
169
+ if (container) return container;
170
+ if (unit.localName === "p") return textTypeOf(unit);
171
+ if (HEADING_TYPES[unit.tagName]) return HEADING_TYPES[unit.tagName];
172
+ const own = blockTypeOf(unit);
173
+ return TEXT_TYPES.has(own) ? own : unit.localName;
174
+ }
175
+
176
+ /** The type a whole container shows as: a list, quote, panel or disclosure. */
177
+ export function containerType(unit) {
178
+ return Object.keys(CONTAINERS).find((type) => wraps(unit, type)) ?? null;
179
+ }
180
+
181
+ // Where a container holds its blocks: the content region of a type that has one (`content`: a disclosure's), else itself.
182
+ const contentOf = (unit) => BLOCK_TYPES[containerType(unit)]?.content?.(unit) ?? unit;
183
+
184
+ // The containers that turn into one another, what they hold carried along (Notion's: HOLDERS): a
185
+ // disclosure, a quote, a highlight block, a callout. Each is the kind of box it is, as well as of block.
186
+
187
+ // The blocks a disclosure, quote or highlight block holds (a highlight block's icon not among them).
188
+ const heldBy = (unit) => heldIn(contentOf(unit));
189
+
190
+ // The disclosure, quote and highlight block `unit` (one of them) can become: those its box takes,
191
+ // which take every block it holds (a disclosure's title a paragraph).
192
+ const holderTargets = (unit, type) => HOLDERS.filter((other) => other !== type
193
+ && takesType(boxKind(unit.parentElement), other)
194
+ && heldBy(unit).every((child) => accepts(other, child.getAttribute("data-ge-unit-kind") ?? unitKindOf(child))));
195
+ const unitKindOf = (node) => (node.localName === "p" ? "paragraph" : /^h[1-4]$/.test(node.localName) ? "heading" : node.localName === "li" ? "item" : null);
196
+ const kindOf = (node) => node.getAttribute("data-ge-unit-kind") ?? unitKindOf(node);
197
+
198
+ // Whether a node can leave its flowchart as a list's item (itemFromStep): its title a block the page
199
+ // may take out (no script refers to it), what it holds after its title blocks an item holds (no row
200
+ // of columns).
201
+ function itemable(step) {
202
+ const first = firstLineOf(step);
203
+ if (first?.hasAttribute("data-ge-keep")) return false;
204
+ return heldIn(step).filter((block) => block !== first).every((child) => accepts("nest", kindOf(child)));
205
+ }
206
+
207
+ // Whether a list's items can each be a node (stepFromItem): no script refers to one (it goes, a new
208
+ // paragraph its words), and what it holds a node takes.
209
+ const steppable = (list) => [...list.children].every((item) => item.localName !== "li" || (!item.hasAttribute("data-ge-keep") && nestedBlocks(item).every((child) => accepts("node", kindOf(child)))));
210
+
211
+ /**
212
+ * The types a flowchart's step can be turned into from its menu (步骤流程图, its own, among them): the
213
+ * other kinds of list (an item of a list of that kind, the flowchart split around it: its title's
214
+ * words the item's, what it holds after its title the item's blocks) and a highlight block (its
215
+ * blocks as they are, its icon too), where its flowchart's box takes them.
216
+ */
217
+ export function stepTargets(step) {
218
+ const flow = step?.parentElement;
219
+ if (!isStep(step) || !step.hasAttribute("data-ge-box") || step.hasAttribute("data-ge-keep") || !flow?.hasAttribute("data-ge-box") || flow.hasAttribute("data-ge-keep")) return [];
220
+ const box = flow.parentElement?.hasAttribute("data-ge-box") ? boxKind(flow.parentElement) : null;
221
+ return TURN_INTO.filter((type) => type === "flowchart" || (box && LIST_TYPES.includes(type) && itemable(step) && takesType(box, type)) || (box && type === "highlight" && takesType(box, type)));
222
+ }
223
+
224
+ /**
225
+ * The types a whole list, quote, panel or disclosure can be turned into: the other kind of list;
226
+ * a disclosure, quote or highlight block another of them, what it holds carried along; or plain
227
+ * blocks (its items or paragraphs become paragraphs, a disclosure's title a paragraph followed by
228
+ * its content).
229
+ */
230
+ export function containerTargets(unit) {
231
+ const type = containerType(unit);
232
+ if (!type || unit.hasAttribute("data-ge-keep") || !unit.parentElement?.hasAttribute("data-ge-box")) return [];
233
+ if (!contentOf(unit).hasAttribute("data-ge-box")) return [];
234
+ const flat = accepts(boxKind(unit.parentElement), "paragraph");
235
+ // A highlight block turns into a flowchart of one node holding its blocks, as they are.
236
+ const flows = type === "highlight" && takesType(boxKind(unit.parentElement), "flowchart") && heldIn(unit).every((child) => accepts("node", kindOf(child))) ? ["flowchart"] : [];
237
+ if (TAKES_AS_IS.has(type)) return [type, ...holderTargets(unit, type), ...flows, ...(flat ? ["paragraph"] : [])];
238
+ const all = blocksIn(unit).every((child) => convertible(child));
239
+ if (type === "quote") return [type, ...holderTargets(unit, type), ...(all && flat ? ["paragraph"] : [])];
240
+ // A flowchart: the kinds of list, its nodes their items, when each node can be one.
241
+ if (type === "flowchart") return [...LIST_TYPES].filter((other) => other === type || [...unit.children].filter(isStep).every(itemable));
242
+ const lists = unit.hasAttribute("data-ge-new") || unit.getAttribute("data-ge-box-kind") === "list" ? LIST_TYPES.filter((other) => other !== "flowchart" || steppable(unit)) : [];
243
+ return all && flat ? [...lists, "paragraph"] : lists;
244
+ }
245
+
246
+ // ---------- the conversions ----------
247
+ // Each returns { focus, created } (made.mjs): the text block that now holds the text (null when
248
+ // nothing changed) and the containers it made, whose child lists undo records too (editor.mjs
249
+ // `struct`, over touchedBy(...) and created).
250
+
251
+ // The original unit a block stands for, if any: its own, or the one it was converted from.
252
+ const unitOf = (host) => host.getAttribute("data-ge-convert") ?? (host.hasAttribute("data-ge-block") ? host.getAttribute("data-ge-unit") : null);
253
+
254
+ // A block standing for `host`, so that the save converts the unit it stands for in place: it takes
255
+ // the host's identity (one made on the page too: what a commit makes of it, this is).
256
+ function standsFor(block, host) {
257
+ block.setAttribute(ELEMENT_ID, identityOf(host));
258
+ const unit = unitOf(host);
259
+ if (unit !== null) {
260
+ block.setAttribute("data-ge-unit", unit);
261
+ block.setAttribute("data-ge-convert", unit);
262
+ }
263
+ return block;
264
+ }
265
+
266
+ // A text block of `type` standing for `host`, with its content, its attributes and the class
267
+ // switches the new type takes too (its color, as Notion's turn into keeps a block's color).
268
+ function standIn(host, type) {
269
+ const next = newHost(host.ownerDocument, type, host);
270
+ next.innerHTML = ownHTML(host);
271
+ for (const attribute of host.attributes) if (carried(attribute) && !ownAttribute(host, attribute.name)) next.setAttribute(attribute.name, attribute.value);
272
+ for (const name of TOGGLES[BLOCK_TYPES[type].kind] ?? []) if (host.classList.contains(name)) next.classList.add(name);
273
+ return standsFor(next, host);
274
+ }
275
+
276
+ // Whether a block already is the text block of a type: its tag, and its class where its type has
277
+ // one; of the paragraph types, the one its class makes it.
278
+ function isOfType(host, type) {
279
+ const spec = BLOCK_TYPES[type];
280
+ if (host.localName !== spec.tag) return false;
281
+ if (spec.kind === "paragraph") return textTypeOf(host) === type;
282
+ return spec.className ? host.classList.contains(spec.className) : true;
283
+ }
284
+
285
+ // Take a text block out of its list, quote or panel. Returns the place it held in the box around
286
+ // it, { parent, before } (before: the node it goes before, null for the end): before the container
287
+ // when it was the first block, after it when it was the last; from the middle, the blocks after it
288
+ // move into a new container of the same kind, and the place is between the two.
289
+ function takeOut(host) {
290
+ const wrapper = host.parentElement;
291
+ const parent = wrapper.parentElement;
292
+ const siblings = blocksIn(wrapper);
293
+ const index = siblings.indexOf(host);
294
+ const rest = siblings.slice(index + 1);
295
+ host.remove();
296
+ if (index === 0) {
297
+ const next = wrapper.nextSibling;
298
+ dropIfEmpty(wrapper);
299
+ return { parent, before: wrapper.isConnected ? wrapper : next };
300
+ }
301
+ if (rest.length === 0) return { parent, before: wrapper.nextSibling };
302
+ // A numbered list split there: the items after the block start at 1 again (notion-lite's runs).
303
+ const tail = made(newTail(wrapper, containerType(wrapper)));
304
+ placeBefore(tail, rest, null);
305
+ wrapper.after(tail);
306
+ return { parent, before: tail };
307
+ }
308
+
309
+ // The element right before or after a place, skipping text.
310
+ function elementAt(place, forward) {
311
+ let node = forward ? place.before : place.before ? place.before.previousSibling : place.parent.lastChild;
312
+ while (node && node.nodeType !== 1) node = forward ? node.nextSibling : node.previousSibling;
313
+ return node ?? null;
314
+ }
315
+
316
+ // A list, quote or panel next to a place that a text block can join: of that type, a box nothing refers to.
317
+ const joinable = (node, type) => wraps(node, type) && node.hasAttribute("data-ge-box") && !node.hasAttribute("data-ge-keep")
318
+ && (node.hasAttribute("data-ge-new") || node.hasAttribute("data-ge-pure"));
319
+
320
+ // Put a block at a place; for a type that puts it in a list, quote or panel, it joins the one right
321
+ // before the place, else the one right after it, else a new one made there.
322
+ function putAt(place, block, type) {
323
+ if (!CONTAINERS[type]) return place.parent.insertBefore(block, place.before);
324
+ const previous = elementAt(place, false);
325
+ const next = elementAt(place, true);
326
+ const { joins = true, leadIcon } = BLOCK_TYPES[type];
327
+ if (joins && joinable(previous, type)) return previous.append(block);
328
+ if (joins && joinable(next, type)) return next.prepend(block);
329
+ const wrapper = made(newContainer(block.ownerDocument, type));
330
+ wrapper.append(block);
331
+ if (leadIcon) wrapper.prepend(iconElement(block.ownerDocument, leadIcon));
332
+ place.parent.insertBefore(wrapper, place.before);
333
+ }
334
+
335
+ /** The containers whose child lists a conversion of this text block or container may change. */
336
+ export function touchedBy(node) {
337
+ const wrapper = isHost(node) ? wrapperOf(node) : null;
338
+ const block = wrapper ?? node;
339
+ const box = block.parentElement;
340
+ const content = contentOf(node);
341
+ // A list or flowchart turned into the other: the blocks its items or nodes hold go into what stands for them.
342
+ const members = isList(node) ? [...node.children].filter((child) => child.localName === "li") : [];
343
+ return [...new Set([node, content, node.parentElement, box, wrapper, block.previousElementSibling, block.nextElementSibling, box?.parentElement, ...members]
344
+ .filter((entry) => entry?.nodeType === 1))];
345
+ }
346
+
347
+ // The plain text of a text block, formulas as their source.
348
+ function plainTextOf(host) {
349
+ const copy = host.cloneNode(true);
350
+ copy.querySelectorAll("br").forEach((line) => line.replaceWith("\n"));
351
+ return copy.textContent.replace(/ /g, " ");
352
+ }
353
+
354
+ // How a type that is no text block of its own is made: its definition's `create`, or its page
355
+ // object's (registry.mjs, `create`), a variant's being its own. Every other type is a text block (a
356
+ // leaf, in a container of its type when it has one), made by standIn below.
357
+ const makerOf = (key) => menuEntry(key).variant?.create ?? BLOCK_TYPES[key]?.create ?? pageOfType(key)?.create;
358
+
359
+ // A new block of a type with a content region of its own (`content`: a disclosure), as its page
360
+ // module makes one, its title empty.
361
+ const newHolder = (doc, type) => made(pageBuild(type)({ doc, block: { html: "", blocks: [] }, inline: () => [], inner: () => [] }));
362
+
363
+ // Such a block at `place`, its content holding `blocks` (none of its own empty paragraph): it and its
364
+ // content are containers the change made (undo records their child lists).
365
+ function holderAt(place, type, blocks) {
366
+ const holder = newHolder(place.parent.ownerDocument, type);
367
+ made(BLOCK_TYPES[type].content(holder)).replaceChildren(...blocks);
368
+ place.parent.insertBefore(holder, place.before);
369
+ return holder;
370
+ }
371
+
372
+ // The empty paragraph a new disclosure or highlight block holds in place of empty block `host`
373
+ // (already taken off the page): the host itself when it is one, else one standing for it.
374
+ const paragraphFor = (host) => (isOfType(host, "paragraph") ? host : standIn(host, "paragraph"));
375
+
376
+ /**
377
+ * Turn a text block into `type` (TURN_INTO). A block keeps its element when its tag stays (a
378
+ * quote's paragraph becoming a paragraph, an item going to the other kind of list); otherwise a
379
+ * new element stands for it; a type with a `create` is made by it, from `host` off the page, its
380
+ * text and emptiness still readable. A highlight block and a disclosure take the block into them as it is (TAKES_AS_IS), unless it
381
+ * is `fresh`: an empty block the "/" menu or 在下方新建 makes the new block of (notion-lite's
382
+ * insertTypedBlock turns the empty block itself into a toggle, and a callout it makes of one
383
+ * holds a text block of its own), which the new one stands for, an empty paragraph in it.
384
+ */
385
+ export function convertBlock(host, type, { fresh = false } = {}) {
386
+ begin();
387
+ const from = typeOf(host);
388
+ if (type === from) return done(null);
389
+ const doc = host.ownerDocument;
390
+ const wrapper = WRAPS[from] ? host.parentElement : null;
391
+ const place = wrapper ? takeOut(host) : { parent: host.parentElement, before: host.nextSibling };
392
+ host.remove();
393
+ const make = makerOf(type);
394
+ if (make) {
395
+ return done(make({
396
+ type, doc, text: plainTextOf(host),
397
+ put: (node) => place.parent.insertBefore(node, place.before),
398
+ stand: (block) => standsFor(block, host),
399
+ paragraph: () => newHost(doc, "paragraph"),
400
+ }));
401
+ }
402
+ // A node of a flowchart (the one before or after the place when there is one, else a new one): an
403
+ // item's words its title and what it held its content, any other block's text its title (the block
404
+ // itself when it is a paragraph), bold; its color the node's.
405
+ if (type === "flowchart") {
406
+ const item = host.localName === "li";
407
+ const title = item ? newHost(doc, "paragraph") : isOfType(host, "paragraph") ? host : standIn(host, "paragraph");
408
+ if (item) title.innerHTML = ownHTML(host);
409
+ const colors = [...host.classList].filter((name) => (TOGGLES.step ?? []).includes(name));
410
+ colors.forEach((name) => title.classList.remove(name));
411
+ if (title.getAttribute("class") === "") title.removeAttribute("class");
412
+ const step = newStep(doc, [asTitle(title), ...(item ? nestedBlocks(host) : [])], colors);
413
+ putAt(place, step, type);
414
+ return done(title);
415
+ }
416
+ const stands = fresh && TAKES_AS_IS.has(type) && isEmpty(host) && nestedBlocks(host).length === 0;
417
+ // A disclosure takes the block into its content as it is (a list's item or a quote's paragraph in
418
+ // a new list or quote of its kind there), as a highlight block does; its title is empty, the caret
419
+ // there to type it (the reader's rule: what is turned into a disclosure is what it folds).
420
+ const { content, title } = BLOCK_TYPES[type];
421
+ if (content) {
422
+ if (stands) return done(title(holderAt(place, type, [paragraphFor(host)])));
423
+ const own = wrapper ? made(newTail(wrapper, from)) : host;
424
+ if (wrapper) own.append(host);
425
+ return done(title(holderAt(place, type, [own])));
426
+ }
427
+ if (stands) {
428
+ const paragraph = paragraphFor(host);
429
+ putAt(place, paragraph, type);
430
+ return done(paragraph);
431
+ }
432
+ // A panel takes a block as it is (notion-lite's transformBlocks into a callout, for one block as for
433
+ // several): a list's item or a quote's paragraph in a new list or quote of its kind there.
434
+ if (TAKES_AS_IS.has(type) && wrapper) {
435
+ const own = made(newTail(wrapper, from));
436
+ own.append(host);
437
+ putAt(place, own, type);
438
+ return done(host);
439
+ }
440
+ const leaf = TAKES_AS_IS.has(type) ? from : LEAF[type];
441
+ const block = isOfType(host, leaf) ? host : standIn(host, leaf);
442
+ putAt(place, block, type);
443
+ return done(block);
444
+ }
445
+
446
+ /**
447
+ * A flowchart's step turned into `type` (stepTargets): it leaves its flowchart, split around it (the
448
+ * steps after it a flowchart of their own, its direction kept), as a list's item (itemFromStep) that
449
+ * joins the list of that kind before or after it, else one of its own; or as a highlight block
450
+ * holding its blocks as they are (its icon too, its background the block's). Returns { focus, created }.
451
+ */
452
+ export function convertStep(step, type) {
453
+ begin();
454
+ if (type === "flowchart") return done(null);
455
+ const place = takeOut(step);
456
+ if (type === "highlight") {
457
+ const panel = made(newContainer(step.ownerDocument, "highlight"));
458
+ for (const name of panelColors(step)) panel.classList.add(name);
459
+ panel.append(...blocksIn(step));
460
+ place.parent.insertBefore(panel, place.before);
461
+ return done([...panel.children].find(isHost) ?? null);
462
+ }
463
+ const item = itemFromStep(step);
464
+ putAt(place, item, type);
465
+ return done(item);
466
+ }
467
+
468
+ /** A unit that holds nothing to carry turned into an empty block of `type` in its place. Returns { focus, created }. */
469
+ export function convertEmpty(unit, type) {
470
+ if (type === ownEmptyType(unit)) return done(null);
471
+ const paragraph = newHost(unit.ownerDocument, "paragraph");
472
+ unit.replaceWith(paragraph);
473
+ return type === "paragraph" ? done(paragraph) : convertBlock(paragraph, type);
474
+ }
475
+
476
+ /**
477
+ * What a block can be turned into from its menu: { current, types }, its type and the types, or null
478
+ * for none. A text block (a list item holding blocks among them, wherever it stands in its list:
479
+ * turnTargets), a unit that holds nothing to carry (as an empty block of the type), a flowchart's
480
+ * step (stepTargets: 步骤流程图 its own), or a whole list, quote, panel or disclosure.
481
+ */
482
+ export function turnInto(unit) {
483
+ if (isStep(unit)) {
484
+ const types = stepTargets(unit);
485
+ return types.length > 0 ? { current: "flowchart", types } : null;
486
+ }
487
+ const empty = turnedEmpty(unit);
488
+ const types = isHost(unit) ? turnTargets(unit) : empty ? emptyTargets(unit) : containerTargets(unit);
489
+ return types.length > 0 ? { current: isHost(unit) ? typeOf(unit) : empty ? ownEmptyType(unit) : containerType(unit), types } : null;
490
+ }
491
+
492
+ /** The containers whose child lists turning a block from its menu may change. */
493
+ export const turnParents = (unit) => (turnedEmpty(unit) ? [unit.parentElement] : touchedBy(unit));
494
+
495
+ /** Whether a block turned from its menu has no text to carry into its new type: a divider line, an empty text block. */
496
+ export const noTextToCarry = (unit) => turnedEmpty(unit) || (isHost(unit) && !unit.textContent.trim());
497
+
498
+ /**
499
+ * Turn a block from its menu into `type` (turnInto). Returns { focus, created }, and `emptied` when
500
+ * the block is gone for an empty one to write in, with nothing of it to select again.
501
+ */
502
+ export function turnUnit(unit, type) {
503
+ if (turnedEmpty(unit)) return { ...convertEmpty(unit, type), emptied: true };
504
+ return isHost(unit) ? convertBlock(unit, type) : isStep(unit) ? convertStep(unit, type) : convertContainer(unit, type);
505
+ }
506
+
507
+ /**
508
+ * Turn a whole list into another kind of list; a list, quote, panel or disclosure into plain
509
+ * blocks in its place (items and paragraphs become paragraphs, a disclosure's title a paragraph).
510
+ */
511
+ export function convertContainer(unit, type) {
512
+ begin();
513
+ const from = containerType(unit);
514
+ if (type === from) return done(null);
515
+ // A flowchart and a list (or a highlight block) are made of each other, node by item (components/flowchart/page.mjs).
516
+ if (from === "flowchart" && LIST_TYPES.includes(type)) return done(blocksIn(listFromFlowchart(unit, type))[0] ?? null);
517
+ if (type === "flowchart") return done(firstLineOf(blocksIn(from === "highlight" ? flowchartFromPanel(unit) : flowchartFromList(unit))[0]) ?? null);
518
+ if (LIST_TYPES.includes(type)) {
519
+ const next = made(retagList(unit, type));
520
+ return done(blocksIn(next)[0] ?? null);
521
+ }
522
+ const doc = unit.ownerDocument;
523
+ let blocks;
524
+ if (BLOCK_TYPES[from]?.content) {
525
+ const title = newHost(doc, "paragraph");
526
+ title.innerHTML = BLOCK_TYPES[from].title(unit)?.innerHTML ?? "";
527
+ blocks = [title, ...blocksIn(contentOf(unit)).filter((child) => !(child.hasAttribute("data-ge-new") && isHost(child) && isEmpty(child)))];
528
+ } else {
529
+ // A highlight block's icon goes with it.
530
+ blocks = heldIn(unit).map((child) => child.localName === "li" ? standIn(child, "paragraph") : child);
531
+ }
532
+ // Another disclosure, quote or highlight block, holding what this one held: a disclosure's title
533
+ // the first paragraph of a quote or highlight block made of it; a disclosure made of a quote or a
534
+ // highlight block holds all its blocks in its content, its title empty to type (the reader's rule,
535
+ // as for the blocks of a group); a new highlight block has 💡. An empty paragraph made on the page
536
+ // is left behind (the new one has its own when nothing else is left).
537
+ if (HOLDERS.includes(type) && HOLDERS.includes(containerType(unit))) {
538
+ const kept = blocks.filter((block) => !(block.hasAttribute("data-ge-new") && isHost(block) && isEmpty(block)));
539
+ const { content, title } = BLOCK_TYPES[type];
540
+ let next;
541
+ if (content) {
542
+ next = newHolder(doc, type);
543
+ // Its content is a container the change made too: undo and redo move the blocks out of it and back.
544
+ if (kept.length > 0) made(content(next)).replaceChildren(...kept);
545
+ } else {
546
+ next = made(newContainer(doc, type));
547
+ next.append(...(kept.length > 0 ? kept : [newHost(doc, "paragraph")]));
548
+ if (BLOCK_TYPES[type].leadIcon) next.prepend(iconElement(doc, BLOCK_TYPES[type].leadIcon));
549
+ }
550
+ unit.replaceWith(next);
551
+ const focus = content ? title(next) : [...next.children].find((child) => isHost(child));
552
+ return done(focus ?? null);
553
+ }
554
+ placeBefore(unit.parentElement, blocks, unit);
555
+ unit.remove();
556
+ return done(blocks.find((block) => isHost(block)) ?? blocks[0] ?? null);
557
+ }
558
+
559
+ /**
560
+ * What a block can become from what was typed into it (the "/" menu, Markdown at its start): the
561
+ * types it can be turned into, and those made as an empty block (a divider, an image...) only when the block held nothing else (`whole`).
562
+ */
563
+ export function typedTargets(host, whole) {
564
+ const types = targetsOf(host);
565
+ if (!whole || !convertible(host)) return types;
566
+ const box = host.parentElement?.getAttribute("data-ge-box-kind");
567
+ return [...withFresh(types, box), ...variantsIn(box)];
568
+ }
569
+
570
+ // ---------- several blocks at once ----------
571
+ // notion-lite's transformBlocks (commands/turn-into.js), for the block menu of several selected
572
+ // blocks (menus/block-menu/index.js) and the format bar over text across blocks
573
+ // (inline/format/toolbar.js): the types every block of the group can be turned into, offered only
574
+ // when each of them can be turned (all or nothing); a pick turns them in document order, a block
575
+ // already of the type left as it is. A block of a group is a text block (an item among them), a
576
+ // whole list, whose items turn item by item into a type that is no list, as notion-lite's items are
577
+ // blocks of their own, or a whole quote, whose paragraphs turn one by one (each a text block of its
578
+ // own, as text across them gives them). A block inside another of the group goes with it (a step's
579
+ // content with the step). An item holding blocks stays an item, what it holds going with it: to another
580
+ // kind of list (a flowchart's step with its content), never to another type (the file keeps such an
581
+ // item's type: turnTargets, as for one). Every item of a list in the group, turned into another kind of list, is that list
582
+ // turned (its nesting, first number and direction kept). Into a highlight block (notion-lite's
583
+ // callout) or a disclosure (TAKES_AS_IS): one new highlight block, or disclosure with an empty title, at
584
+ // the first block's place, every block moved into it (a disclosure's content) keeping its type (an
585
+ // item in a list of its kind, a quote's paragraph in a quote), the containers they all leave going
586
+ // as when they are moved away. Turned items join the lists beside them as one turned item
587
+ // does (putAt), and the lists the group turned into the type that then stand side by side are one
588
+ // (join.mjs joins: notion-lite's consecutive items are one run), but two it found side by side and
589
+ // left as they were (join.mjs keeps a pair written apart).
590
+
591
+ const itemsIn = (list) => [...list.children].filter((child) => child.localName === "li");
592
+ const isList = (node) => node?.localName === "ul" || node?.localName === "ol";
593
+ const inOrder = (nodes) => [...nodes].sort((a, b) => (a.compareDocumentPosition(b) & 4 ? -1 : 1)); // 4: DOCUMENT_POSITION_FOLLOWING
594
+ // Those not inside another of them.
595
+ const outermost = (nodes) => nodes.filter((node) => !nodes.some((other) => other !== node && other.contains(node)));
596
+
597
+ // What one block of a group can be turned into, as convertGroup turns it (in menu order): a text
598
+ // block its targets; an item holding blocks another kind of
599
+ // list, a highlight block or a disclosure; a whole list another kind of list or paragraphs
600
+ // (containerTargets), a highlight block or a disclosure, or a type each of its items can be turned
601
+ // into; a whole quote what each of its paragraphs can; anything else nothing.
602
+ function memberTargets(unit, group = []) {
603
+ if (isHost(unit)) return turnTargets(unit);
604
+ // A flowchart's step: the kinds of list (each its own item); with every step of its flowchart in the
605
+ // group, also a highlight block or a disclosure (the flowchart going into it whole: membersOf).
606
+ if (isStep(unit)) {
607
+ const whole = [...unit.parentElement.children].filter(isStep).every((step) => group.includes(step));
608
+ const box = boxKind(unit.parentElement.parentElement);
609
+ return TURN_INTO.filter((type) => (LIST_TYPES.includes(type) && stepTargets(unit).includes(type)) || (whole && TAKES_AS_IS.has(type) && takesType(box, type)));
610
+ }
611
+ const own = containerType(unit);
612
+ if (own === "quote") {
613
+ const each = containerTargets(unit).length > 0 ? blocksIn(unit).map(memberTargets) : [];
614
+ return each.length > 0 ? TURN_INTO.filter((type) => each.every((types) => types.includes(type))) : [];
615
+ }
616
+ if (!LIST_TYPES.includes(own ?? "")) return [];
617
+ const whole = containerTargets(unit);
618
+ if (whole.length === 0) return [];
619
+ const each = itemsIn(unit).map(memberTargets);
620
+ const box = boxKind(unit.parentElement);
621
+ return TURN_INTO.filter((type) => whole.includes(type) || (TAKES_AS_IS.has(type) && takesType(box, type)) || (each.length > 0 && each.every((types) => types.includes(type))));
622
+ }
623
+
624
+ // The type a block of a group shows as.
625
+ const shownType = (unit) => (isHost(unit) ? typeOf(unit) : isStep(unit) ? "flowchart" : containerType(unit));
626
+
627
+ /**
628
+ * What a group of blocks (text blocks, items, whole lists and quotes) can be turned into together:
629
+ * { types, current, first }, types being those every one of them can (menu order), current the type
630
+ * they all are (null for a mix: none is marked), first the first one's. Null when one of them can be
631
+ * turned into nothing (a card, a table, a code block, a divider, a disclosure, a highlight block…).
632
+ */
633
+ export function groupTargets(units) {
634
+ if (units.length === 0) return null;
635
+ const each = units.map((unit) => memberTargets(unit, units));
636
+ if (each.some((types) => types.length === 0)) return null;
637
+ const types = TURN_INTO.filter((type) => each.every((list) => list.includes(type)));
638
+ if (types.length === 0) return null;
639
+ const shown = units.map(shownType);
640
+ return { types, current: shown.every((type) => type === shown[0]) ? shown[0] : null, first: shown[0] };
641
+ }
642
+
643
+ // The list right after a list, past the editor's own nodes, or null.
644
+ function listAfter(list) {
645
+ let next = list.nextElementSibling;
646
+ while (next?.hasAttribute("data-doc-dev")) next = next.nextElementSibling;
647
+ return isList(next) ? next : null;
648
+ }
649
+
650
+ // The blocks of a group as convertGroup turns them, in document order, none inside another (a block
651
+ // inside one goes with it): every item of a list in it, for another kind of list or a highlight
652
+ // block, that list (turned or moved whole; `whole` names them). { members, whole }.
653
+ function membersOf(units, type) {
654
+ const all = outermost(inOrder(units));
655
+ const whole = new Set();
656
+ const members = [];
657
+ for (const unit of all) {
658
+ const list = unit.localName === "li" && (LIST_TYPES.includes(type) || TAKES_AS_IS.has(type)) ? unit.parentElement : null;
659
+ const fits = list && LIST_TYPES.includes(containerType(list) ?? "") && (TAKES_AS_IS.has(type) ? containerTargets(list).length > 0 : containerTargets(list).includes(type));
660
+ if (fits && itemsIn(list).every((item) => all.includes(item))) {
661
+ if (!whole.has(list)) members.push(list);
662
+ whole.add(list);
663
+ } else members.push(unit);
664
+ }
665
+ return { members, whole };
666
+ }
667
+
668
+ // Where a group's highlight block or disclosure goes: the box the first of its blocks is in (an
669
+ // item's or a quote paragraph's list or quote split there).
670
+ const homeOf = (first) => (isHost(first) && WRAPS[typeOf(first)] ? first.parentElement.parentElement : first.parentElement);
671
+
672
+ // The containers the blocks of a group leave empty as they go into a highlight block or a
673
+ // disclosure, which go with them (as when they are deleted or dragged away: removalTarget), but one
674
+ // holding `home`.
675
+ function leftoversOf(outer, home) {
676
+ const gone = new Set(outer.flatMap(withLeads));
677
+ return [...new Set(outer.map((member) => removalTarget(member, gone)))].filter((node) => !outer.includes(node) && !node.contains(home));
678
+ }
679
+
680
+ /**
681
+ * The containers whose child lists turning a group into `type` may change (editor.mjs `struct`
682
+ * records them): each block's (touchedBy), and into a highlight block or a disclosure, those
683
+ * holding the containers its blocks leave empty.
684
+ */
685
+ export function groupParents(units, type) {
686
+ const parents = units.flatMap(touchedBy);
687
+ if (TAKES_AS_IS.has(type)) {
688
+ const outer = membersOf(units, type).members;
689
+ parents.push(...leftoversOf(outer, homeOf(outer[0])).map((node) => node.parentElement));
690
+ }
691
+ return [...new Set(parents.filter(Boolean))];
692
+ }
693
+
694
+ /**
695
+ * Turn a group of blocks (groupTargets) into `type`, in document order. Returns { changed, created,
696
+ * units, hosts }: whether anything changed; the containers it made (editor.mjs `struct` records
697
+ * them); the blocks standing for the group now, to select (a turned block's own, a list turned whole
698
+ * the list, the items of a list given whole its items again, the items of a list joined to another,
699
+ * a new highlight block or disclosure); and where each text block's text is now (Map: text block
700
+ * before -> text block after).
701
+ */
702
+ export function convertGroup(units, type) {
703
+ const created = [];
704
+ const hosts = new Map();
705
+ const after = [];
706
+ let changed = false;
707
+ const take = ({ focus, created: made }) => {
708
+ created.push(...made);
709
+ changed = true;
710
+ return focus;
711
+ };
712
+ const turn = (host) => {
713
+ const focus = take(convertBlock(host, type));
714
+ hosts.set(host, focus); // one by one (no TAKES_AS_IS type): its text is in the text block convertBlock gives
715
+ after.push(isFirstLine(focus) ? focus.parentElement : unitElement(focus)); // made a node: the node, which joins its flowchart's neighbours
716
+ };
717
+ const { members, whole } = membersOf(units, type);
718
+
719
+ if (TAKES_AS_IS.has(type)) {
720
+ // One highlight block (or disclosure, its title empty) at the first block's place; each block in
721
+ // it as it is, an item or a quote's paragraph in a list or quote of its kind (the one before it
722
+ // there when that is of its kind). What is inside a block of the group goes with it; a container
723
+ // they all leave goes.
724
+ const outer = outermost(members);
725
+ const doc = outer[0].ownerDocument;
726
+ const kinds = outer.map((member) => (isHost(member) && WRAPS[typeOf(member)] ? typeOf(member) : null));
727
+ const wrappers = outer.map((member) => member.parentElement);
728
+ const leftovers = leftoversOf(outer, homeOf(outer[0]));
729
+ begin();
730
+ const place = kinds[0] ? takeOut(outer[0]) : { parent: outer[0].parentElement, before: outer[0] };
731
+ let unit;
732
+ let holder;
733
+ if (BLOCK_TYPES[type].content) {
734
+ unit = holderAt(place, type, []);
735
+ holder = contentOf(unit);
736
+ } else {
737
+ unit = holder = made(newContainer(doc, type));
738
+ if (BLOCK_TYPES[type].leadIcon) holder.append(iconElement(doc, BLOCK_TYPES[type].leadIcon));
739
+ place.parent.insertBefore(unit, place.before);
740
+ }
741
+ outer.forEach((member, index) => {
742
+ const kind = kinds[index];
743
+ if (!kind) return void holder.append(member);
744
+ if (index > 0) takeOut(member);
745
+ const last = holder.lastElementChild;
746
+ (joinable(last, kind) ? last : holder.appendChild(made(newTail(wrappers[index], kind)))).append(member);
747
+ });
748
+ leftovers.forEach((node) => node.remove());
749
+ created.push(...done(null).created);
750
+ for (const member of members) {
751
+ for (const host of whole.has(member) ? itemsIn(member) : isHost(member) ? [member] : []) hosts.set(host, host);
752
+ }
753
+ return { changed: true, created, units: [unit], hosts };
754
+ }
755
+
756
+ // The lists side by side before (the first -> the one after it): a pair the group leaves as it was stays two.
757
+ const apart = new Map();
758
+ for (const flow of new Set(members.map((member) => (member.localName === "li" ? member.parentElement : member).parentElement))) {
759
+ for (const child of flow?.children ?? []) if (isList(child)) apart.set(child, listAfter(child));
760
+ }
761
+ // A whole list or flowchart turned: its items (or nodes) now, and where each one's text went (a list
762
+ // retagged keeps its items; a list made a flowchart has a node for each item, its title the item's
763
+ // text, and back).
764
+ const turnWhole = (member) => {
765
+ const before = itemsIn(member);
766
+ const focus = containerType(member) !== type ? take(convertContainer(member, type)) : null;
767
+ const now = member.isConnected ? member : !focus ? null : isFirstLine(focus) ? focus.parentElement.parentElement : focus.parentElement;
768
+ const items = now ? itemsIn(now) : [];
769
+ before.forEach((item, index) => {
770
+ const text = (node) => (isStep(node) ? firstLineOf(node) : node);
771
+ if (text(item)) hosts.set(text(item), text(items[index]) ?? null);
772
+ });
773
+ return { items, focus };
774
+ };
775
+ for (const member of members) {
776
+ if (whole.has(member)) after.push(...turnWhole(member).items);
777
+ else if (isHost(member)) {
778
+ if (typeOf(member) !== type) turn(member);
779
+ else {
780
+ hosts.set(member, member);
781
+ after.push(member);
782
+ }
783
+ } else if (isStep(member)) {
784
+ // A step: an item of a list of the type (convertStep), or a step still.
785
+ if (type === "flowchart") after.push(member);
786
+ else {
787
+ const title = firstLineOf(member);
788
+ const focus = take(convertStep(member, type));
789
+ if (title) hosts.set(title, focus);
790
+ after.push(focus);
791
+ }
792
+ } else if (containerType(member) === type) after.push(member);
793
+ else if (containerType(member) === "quote") blocksIn(member).forEach(turn); // a whole quote: paragraph by paragraph
794
+ else if (LIST_TYPES.includes(type) || type === "paragraph") {
795
+ // A whole list chosen as a block: another kind of list, or paragraphs in its place.
796
+ const items = itemsIn(member);
797
+ const parent = member.parentElement;
798
+ const focus = take(convertContainer(member, type));
799
+ if (type === "paragraph") {
800
+ for (const item of items) {
801
+ const id = item.getAttribute(ELEMENT_ID);
802
+ const paragraph = [...parent.children].find((child) => child !== item && child.getAttribute(ELEMENT_ID) === id) ?? null;
803
+ hosts.set(item, paragraph);
804
+ after.push(paragraph);
805
+ }
806
+ } else {
807
+ for (const item of items) hosts.set(item, item);
808
+ after.push(focus && isFirstLine(focus) ? focus.parentElement.parentElement : focus?.parentElement ?? null); // the list now, or the flowchart made of it
809
+ }
810
+ } else itemsIn(member).forEach(turn); // any other type: item by item
811
+ }
812
+
813
+ // The lists the group turned into the type, side by side now, are one (the items of the one taken
814
+ // in selected with the rest); two it found side by side and left as they were stay two.
815
+ if (LIST_TYPES.includes(type)) {
816
+ const fresh = new Set(created);
817
+ const kept = (list, next) => apart.get(list) === next && !fresh.has(list) && !fresh.has(next);
818
+ const lists = new Set(after.filter((node) => node?.isConnected).map((node) => (node.localName === "li" ? node.parentElement : node)).filter((node) => wraps(node, type)));
819
+ for (const list of inOrder(lists)) {
820
+ for (let next = listAfter(list); list.isConnected && next && lists.has(next) && joins(list, next) && !kept(list, next); next = listAfter(list)) {
821
+ const items = itemsIn(next);
822
+ placeBefore(list, items, null);
823
+ const at = after.indexOf(next);
824
+ if (at >= 0) after.splice(at, 1, ...items);
825
+ next.remove();
826
+ changed = true;
827
+ }
828
+ }
829
+ }
830
+ return { changed, created, units: [...new Set(after.filter((node) => node?.isConnected))], hosts };
831
+ }