@heycys/gallery 0.1.0 → 0.1.2

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 (465) hide show
  1. package/THIRD-PARTY-NOTICES.md +51 -1
  2. package/browser/editor/components/callout/index.mjs +40 -15
  3. package/browser/editor/components/columns/page.mjs +45 -32
  4. package/browser/editor/components/details/index.mjs +2 -1
  5. package/browser/editor/components/dialog/index.mjs +2 -1
  6. package/browser/editor/components/dialog/page.mjs +0 -18
  7. package/browser/editor/components/divider/index.mjs +1 -1
  8. package/browser/editor/components/embed/index.mjs +2 -2
  9. package/browser/editor/components/figure/page.mjs +10 -1
  10. package/browser/editor/components/file/page.mjs +2 -2
  11. package/browser/editor/components/flowchart/add.mjs +7 -6
  12. package/browser/editor/components/flowchart/page.mjs +1 -1
  13. package/browser/editor/components/heading/index.mjs +2 -0
  14. package/browser/editor/components/heading/page.mjs +6 -0
  15. package/browser/editor/components/highlight/index.mjs +4 -20
  16. package/browser/editor/components/icons.mjs +13 -2
  17. package/browser/editor/components/image/crop.mjs +6 -9
  18. package/browser/editor/components/image/page.mjs +2 -2
  19. package/browser/editor/components/installed/index.mjs +82 -29
  20. package/browser/editor/components/installed/page.mjs +146 -34
  21. package/browser/editor/components/installed/served.mjs +6 -5
  22. package/browser/editor/components/instances.mjs +18 -0
  23. package/browser/editor/components/kit.mjs +3 -0
  24. package/browser/editor/components/list/page.mjs +3 -6
  25. package/browser/editor/components/media/page.mjs +44 -14
  26. package/browser/editor/components/pages.mjs +2 -2
  27. package/browser/editor/components/registry.mjs +68 -33
  28. package/browser/editor/components/section/index.mjs +2 -1
  29. package/browser/editor/components/set-apart.mjs +24 -0
  30. package/browser/editor/components/table/index.mjs +64 -5
  31. package/browser/editor/components/table/page.mjs +30 -19
  32. package/browser/editor/page/annotate/anchors.mjs +4 -3
  33. package/browser/editor/page/annotate/card.mjs +3 -6
  34. package/browser/editor/page/annotate/index.mjs +61 -34
  35. package/browser/editor/page/autosave.mjs +357 -38
  36. package/browser/editor/page/beside.mjs +5 -5
  37. package/browser/editor/page/block-menu/colors.mjs +3 -1
  38. package/browser/editor/page/block-menu/index.mjs +8 -6
  39. package/browser/editor/page/blocks.mjs +16 -7
  40. package/browser/editor/page/board/client.mjs +57 -0
  41. package/browser/editor/page/board/hint.mjs +145 -0
  42. package/browser/editor/page/board/history.mjs +119 -0
  43. package/browser/editor/page/board/index.mjs +970 -0
  44. package/browser/editor/page/board/settings.mjs +209 -0
  45. package/browser/editor/page/caret.mjs +5 -2
  46. package/browser/editor/page/changes/bar.mjs +94 -0
  47. package/browser/editor/page/changes/ghost.mjs +206 -0
  48. package/browser/editor/page/changes/gone-words.mjs +94 -0
  49. package/browser/editor/page/changes/index.mjs +447 -0
  50. package/browser/editor/page/changes/words.mjs +27 -0
  51. package/browser/editor/page/clipboard/import/colors.mjs +3 -3
  52. package/browser/editor/page/clipboard/import/html.mjs +29 -6
  53. package/browser/editor/page/clipboard/import/inline.mjs +32 -0
  54. package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
  55. package/browser/editor/page/clipboard/import/read.mjs +6 -1
  56. package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
  57. package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
  58. package/browser/editor/page/clipboard/index.mjs +156 -26
  59. package/browser/editor/page/clipboard/own/blocks.mjs +25 -16
  60. package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
  61. package/browser/editor/page/clipboard/own/describe.mjs +16 -7
  62. package/browser/editor/page/clipboard/own/export.mjs +6 -6
  63. package/browser/editor/page/clipboard/own/selection.mjs +3 -3
  64. package/browser/editor/page/clipboard/own/writers.mjs +0 -11
  65. package/browser/editor/page/columns/index.mjs +48 -46
  66. package/browser/editor/page/commit.mjs +98 -25
  67. package/browser/editor/page/conflicts.mjs +13 -33
  68. package/browser/editor/page/convert.mjs +8 -7
  69. package/browser/editor/page/core.mjs +81 -27
  70. package/browser/editor/page/custom-page.mjs +106 -0
  71. package/browser/editor/page/drag/index.mjs +40 -24
  72. package/browser/editor/page/drag/preview.mjs +9 -4
  73. package/browser/editor/page/editor.mjs +120 -28
  74. package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
  75. package/browser/editor/page/emoji-picker/grid.mjs +7 -5
  76. package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
  77. package/browser/editor/page/emoji-picker/icons.mjs +0 -1
  78. package/browser/editor/page/emoji-picker/index.mjs +11 -9
  79. package/browser/editor/page/emoji-picker/styles.mjs +156 -2
  80. package/browser/editor/page/emoji-picker/support.mjs +6 -4
  81. package/browser/editor/page/emoji-picker/upload.mjs +14 -13
  82. package/browser/editor/page/fills.mjs +5 -3
  83. package/browser/editor/page/fold/index.mjs +348 -0
  84. package/browser/editor/page/fold/rule.mjs +125 -0
  85. package/browser/editor/page/folded.mjs +23 -0
  86. package/browser/editor/page/format-bar/bar.mjs +2 -1
  87. package/browser/editor/page/format-bar/index.mjs +1 -1
  88. package/browser/editor/page/geometry.mjs +8 -6
  89. package/browser/editor/page/handle/index.mjs +22 -14
  90. package/browser/editor/page/hints/index.mjs +1 -1
  91. package/browser/editor/page/history.mjs +24 -4
  92. package/browser/editor/page/insert/index.mjs +30 -17
  93. package/browser/editor/page/links/index.mjs +5 -3
  94. package/browser/editor/page/links/pages.mjs +27 -9
  95. package/browser/editor/page/long-runs.mjs +75 -0
  96. package/browser/editor/page/look.mjs +69 -6
  97. package/browser/editor/page/margin.mjs +63 -27
  98. package/browser/editor/page/media-menu/index.mjs +6 -7
  99. package/browser/editor/page/menu.mjs +86 -31
  100. package/browser/editor/page/merge.mjs +24 -0
  101. package/browser/editor/page/notices.mjs +3 -3
  102. package/browser/editor/page/offered.mjs +1 -1
  103. package/browser/editor/page/outline/folds.mjs +11 -10
  104. package/browser/editor/page/outline/index.mjs +131 -45
  105. package/browser/editor/page/outline/list.mjs +23 -11
  106. package/browser/editor/page/outline/read.mjs +1 -1
  107. package/browser/editor/page/outline/strip.mjs +7 -1
  108. package/browser/editor/page/page-objects.mjs +13 -2
  109. package/browser/editor/page/panel.mjs +9 -13
  110. package/browser/editor/page/present-links.mjs +11 -2
  111. package/browser/editor/page/resize/index.mjs +42 -29
  112. package/browser/editor/page/selection/delete.mjs +8 -6
  113. package/browser/editor/page/selection/index.mjs +10 -3
  114. package/browser/editor/page/served.mjs +14 -0
  115. package/browser/editor/page/session.mjs +101 -6
  116. package/browser/editor/page/slash-menu/index.mjs +3 -3
  117. package/browser/editor/page/table/cell-bar.mjs +4 -1
  118. package/browser/editor/page/table/cells.mjs +103 -47
  119. package/browser/editor/page/table/icons.mjs +3 -1
  120. package/browser/editor/page/table/index.mjs +40 -16
  121. package/browser/editor/page/table/pictures.mjs +299 -0
  122. package/browser/editor/page/table/views.mjs +150 -0
  123. package/browser/editor/page/table/widths.mjs +9 -4
  124. package/browser/editor/page/text-select/index.mjs +43 -14
  125. package/browser/editor/page/todo-writes.mjs +75 -0
  126. package/browser/editor/page/tooltip.mjs +1 -1
  127. package/browser/editor/page/type-grid.mjs +4 -3
  128. package/browser/editor/page/typing/code-edges.mjs +63 -17
  129. package/browser/editor/page/typing/index.mjs +65 -9
  130. package/browser/editor/page/typing/leave.mjs +1 -1
  131. package/browser/editor/page/ui.mjs +13 -0
  132. package/browser/shared/annotations.mjs +8 -10
  133. package/browser/shared/block-packs.mjs +404 -0
  134. package/browser/shared/board-places.mjs +224 -0
  135. package/browser/shared/card-size.mjs +59 -0
  136. package/browser/shared/code-folds.mjs +5 -1
  137. package/browser/shared/colors.mjs +17 -14
  138. package/browser/shared/component-catalog.mjs +345 -54
  139. package/browser/shared/component-source.mjs +37 -0
  140. package/browser/shared/components/callout.mjs +4 -2
  141. package/browser/shared/components/index.mjs +72 -9
  142. package/browser/shared/components/installed.mjs +110 -8
  143. package/browser/shared/components/page.mjs +22 -3
  144. package/browser/shared/components/state.mjs +5 -1
  145. package/browser/shared/components/table.mjs +1 -1
  146. package/browser/shared/components/text.mjs +2 -2
  147. package/browser/shared/document-look.mjs +183 -0
  148. package/browser/shared/drafts.mjs +432 -0
  149. package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
  150. package/browser/shared/emoji/data/README.md +4 -2
  151. package/browser/shared/emoji/data/categories.json +1 -1
  152. package/browser/shared/emoji/data/keywords-en.json +1 -1
  153. package/browser/shared/emoji/data/keywords-zh.json +1 -1
  154. package/browser/shared/emoji/data/names.json +1 -1
  155. package/browser/shared/emoji/data/positions.json +1 -1
  156. package/browser/shared/emoji/data/twemoji-index.json +1 -1
  157. package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
  158. package/browser/shared/emoji/data.mjs +10 -12
  159. package/browser/shared/emoji/emoji.mjs +8 -7
  160. package/browser/shared/emoji/icon-value.mjs +4 -3
  161. package/browser/shared/extension-sidebar.mjs +126 -0
  162. package/browser/shared/extensions.mjs +79 -0
  163. package/browser/shared/file-table.mjs +101 -0
  164. package/browser/shared/html-tree.mjs +11 -5
  165. package/browser/shared/i18n/en.mjs +374 -35
  166. package/browser/shared/json-layout.mjs +47 -0
  167. package/browser/shared/long-runs.mjs +39 -0
  168. package/browser/shared/net-cache.mjs +133 -0
  169. package/browser/shared/net-keys.mjs +32 -0
  170. package/browser/shared/net-policy.mjs +177 -0
  171. package/browser/shared/new-names.mjs +5 -2
  172. package/browser/shared/outline-shape.mjs +128 -0
  173. package/browser/shared/outline.mjs +458 -0
  174. package/browser/shared/pack-manifest.mjs +77 -0
  175. package/browser/shared/page-address.mjs +6 -3
  176. package/browser/shared/page-cards.mjs +308 -0
  177. package/browser/shared/page-links.mjs +69 -6
  178. package/browser/shared/pages.mjs +388 -0
  179. package/browser/shared/paths.mjs +6 -0
  180. package/browser/shared/preferences.mjs +10 -4
  181. package/browser/shared/preview-server.mjs +3 -7
  182. package/browser/shared/session.mjs +13 -5
  183. package/browser/shared/shipped-blocks.mjs +299 -0
  184. package/browser/shared/table-chart.mjs +33 -1
  185. package/browser/shared/todos.mjs +83 -0
  186. package/browser/shared/user-directory.mjs +24 -0
  187. package/browser/shared/versions.mjs +14 -0
  188. package/browser/shared/web-links.mjs +134 -0
  189. package/browser/shared/workspace-columns.mjs +120 -0
  190. package/browser/shared/workspace-look.mjs +91 -0
  191. package/browser/shared/workspace-name.mjs +154 -0
  192. package/browser/shared/workspace-query.mjs +125 -0
  193. package/browser/shared/workspace-registry.mjs +272 -0
  194. package/browser/shared/workspace.mjs +171 -20
  195. package/browser/shared/zoom.mjs +5 -5
  196. package/dist/chunk-2NRBY6AJ.mjs +2 -0
  197. package/dist/chunk-32ZUEFZ7.mjs +2 -0
  198. package/dist/chunk-35NQ4PLQ.mjs +2 -0
  199. package/dist/chunk-3KJHLHUO.mjs +2 -0
  200. package/dist/chunk-3NJACR4W.mjs +2 -0
  201. package/dist/chunk-4AV456RQ.mjs +2 -0
  202. package/dist/chunk-4OZWXZE5.mjs +5 -0
  203. package/dist/chunk-5XYHDBJ5.mjs +2 -0
  204. package/dist/chunk-5ZJA7CXT.mjs +2 -0
  205. package/dist/chunk-6A53MZYZ.mjs +2 -0
  206. package/dist/chunk-6EXH3ORZ.mjs +166 -0
  207. package/dist/chunk-6EZ7FNIK.mjs +3 -0
  208. package/dist/{chunk-UXUK4PMC.mjs → chunk-6QBHU4DF.mjs} +1 -1
  209. package/dist/{chunk-6U2SLSDN.mjs → chunk-6VTU6KEO.mjs} +1 -1
  210. package/dist/chunk-B4P2CM2J.mjs +3 -0
  211. package/dist/chunk-BPL64HGA.mjs +4 -0
  212. package/dist/chunk-BVEFGE4B.mjs +2 -0
  213. package/dist/chunk-BZ5RAF7L.mjs +2 -0
  214. package/dist/chunk-CRJEG7MT.mjs +2 -0
  215. package/dist/{chunk-B3VTYBYR.mjs → chunk-D4CKRD3V.mjs} +91 -91
  216. package/dist/chunk-D4EURAX4.mjs +4 -0
  217. package/dist/chunk-DQCE7TJY.mjs +5 -0
  218. package/dist/chunk-DR73Y2UJ.mjs +3 -0
  219. package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
  220. package/dist/{chunk-DB4WKGYF.mjs → chunk-ERLAIBOA.mjs} +2 -2
  221. package/dist/chunk-EURLTOTZ.mjs +4 -0
  222. package/dist/chunk-FJYN7RTH.mjs +4 -0
  223. package/dist/chunk-FWNRPMCJ.mjs +12 -0
  224. package/dist/chunk-FWW4CSAZ.mjs +2 -0
  225. package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
  226. package/dist/chunk-GY3FAUVM.mjs +2 -0
  227. package/dist/chunk-HLYV7RIH.mjs +2 -0
  228. package/dist/chunk-HMYTM3GT.mjs +15 -0
  229. package/dist/chunk-IA4PSIMD.mjs +2 -0
  230. package/dist/chunk-JEUK3ZO7.mjs +2 -0
  231. package/dist/chunk-JVHHHGEA.mjs +3 -0
  232. package/dist/chunk-KTKHRC6H.mjs +2 -0
  233. package/dist/chunk-L7UP52JO.mjs +2 -0
  234. package/dist/chunk-MHW7ZKOU.mjs +2 -0
  235. package/dist/chunk-N76HWBA3.mjs +10 -0
  236. package/dist/chunk-N7AZZLGT.mjs +548 -0
  237. package/dist/chunk-NAMN3RAF.mjs +2 -0
  238. package/dist/{chunk-YXAUQPVK.mjs → chunk-NFMCP2HI.mjs} +3 -3
  239. package/dist/chunk-NG375ILQ.mjs +2 -0
  240. package/dist/chunk-NVRNLK25.mjs +6 -0
  241. package/dist/chunk-NWFBE2YA.mjs +2 -0
  242. package/dist/chunk-NWR2LT5B.mjs +2 -0
  243. package/dist/chunk-OJKMINIU.mjs +20 -0
  244. package/dist/chunk-OUUP3WKT.mjs +2 -0
  245. package/dist/chunk-OW5NWPOJ.mjs +10 -0
  246. package/dist/chunk-PAREWQGB.mjs +4 -0
  247. package/dist/chunk-POQSE4C2.mjs +2 -0
  248. package/dist/chunk-PUOQ65NC.mjs +2 -0
  249. package/dist/{chunk-Z52HTUW7.mjs → chunk-PVER7LSC.mjs} +2 -2
  250. package/dist/chunk-PZDLJJTJ.mjs +3 -0
  251. package/dist/chunk-Q47PLKIJ.mjs +15 -0
  252. package/dist/chunk-Q4UEPUWF.mjs +2 -0
  253. package/dist/chunk-QKXMPUXC.mjs +2 -0
  254. package/dist/chunk-QOUEFUCH.mjs +16 -0
  255. package/dist/chunk-RFDZXFJF.mjs +13 -0
  256. package/dist/chunk-RKPWLGZ3.mjs +4 -0
  257. package/dist/chunk-RMECZA2K.mjs +2 -0
  258. package/dist/{chunk-EUX7IC5J.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
  259. package/dist/chunk-SX4LJYT6.mjs +8 -0
  260. package/dist/chunk-SXHBYZST.mjs +16 -0
  261. package/dist/chunk-TANZRINB.mjs +2 -0
  262. package/dist/chunk-TEZAWDSQ.mjs +2 -0
  263. package/dist/chunk-UBBRTJ2R.mjs +24 -0
  264. package/dist/chunk-UFNYFFKO.mjs +20 -0
  265. package/dist/chunk-UGWYKHBL.mjs +170 -0
  266. package/dist/chunk-UKSHDZZ6.mjs +2 -0
  267. package/dist/chunk-UMHUSOPJ.mjs +2 -0
  268. package/dist/chunk-UNOYVIYR.mjs +2 -0
  269. package/dist/chunk-V6RIYQZZ.mjs +4 -0
  270. package/dist/chunk-VJPFVNNW.mjs +15 -0
  271. package/dist/chunk-VS3ZMVGX.mjs +5 -0
  272. package/dist/chunk-VTKNEYT3.mjs +6 -0
  273. package/dist/chunk-VXACTLO3.mjs +3 -0
  274. package/dist/chunk-W3BGBJQW.mjs +2 -0
  275. package/dist/chunk-YI43RG4P.mjs +2 -0
  276. package/dist/chunk-YQGT4AB2.mjs +6 -0
  277. package/dist/chunk-ZB4H7ZN4.mjs +2 -0
  278. package/dist/{chunk-ACOPDCNB.mjs → chunk-ZHEHPMBK.mjs} +1 -1
  279. package/dist/chunk-ZTHICSSF.mjs +2 -0
  280. package/dist/chunk-ZUNVAXLH.mjs +2 -0
  281. package/dist/chunk-ZWPMCK7P.mjs +2 -0
  282. package/dist/cli.mjs +1 -1
  283. package/dist/server.mjs +1 -1
  284. package/dist/{chunk-EVJ3BX3M.mjs → update-fetch.mjs} +1 -1
  285. package/dist/worker.mjs +1 -1
  286. package/kit/board.css +95 -0
  287. package/kit/board.js +250 -0
  288. package/kit/charts.js +5 -71
  289. package/kit/code.js +14 -14
  290. package/kit/math.js +18 -2
  291. package/kit/report.css +500 -151
  292. package/kit/runtime.js +1720 -170
  293. package/kit/state.js +10 -1
  294. package/kit/tables.js +172 -37
  295. package/kit/ui.js +166 -27
  296. package/package.json +2 -1
  297. package/packs/gallery/card/component.json +14 -0
  298. package/packs/gallery/card/example.html +10 -0
  299. package/packs/gallery/card/preview.svg +1 -0
  300. package/packs/gallery/card/style.css +6 -0
  301. package/packs/gallery/card/template.html +6 -0
  302. package/packs/gallery/card/writing.md +14 -0
  303. package/packs/gallery/chart-card/component.json +15 -0
  304. package/packs/gallery/chart-card/example.html +14 -0
  305. package/packs/gallery/chart-card/kit.js +130 -0
  306. package/packs/gallery/chart-card/preview.svg +1 -0
  307. package/packs/gallery/chart-card/style.css +42 -0
  308. package/packs/gallery/chart-card/template.html +13 -0
  309. package/packs/gallery/chart-card/writing.md +20 -0
  310. package/packs/gallery/chart-view/component.json +20 -0
  311. package/packs/gallery/chart-view/example.html +13 -0
  312. package/packs/gallery/chart-view/kit.js +355 -0
  313. package/packs/gallery/chart-view/preview.svg +1 -0
  314. package/packs/gallery/chart-view/style.css +94 -0
  315. package/packs/gallery/chart-view/template.html +3 -0
  316. package/packs/gallery/chart-view/writing.md +22 -0
  317. package/packs/gallery/countdown/component.json +18 -0
  318. package/packs/gallery/countdown/example.html +3 -0
  319. package/packs/gallery/countdown/kit.js +156 -0
  320. package/packs/gallery/countdown/preview.svg +1 -0
  321. package/packs/gallery/countdown/style.css +130 -0
  322. package/packs/gallery/countdown/template.html +3 -0
  323. package/packs/gallery/countdown/writing.md +22 -0
  324. package/packs/gallery/habit/component.json +14 -0
  325. package/packs/gallery/habit/example.html +3 -0
  326. package/packs/gallery/habit/kit.js +295 -0
  327. package/packs/gallery/habit/preview.svg +1 -0
  328. package/packs/gallery/habit/style.css +246 -0
  329. package/packs/gallery/habit/template.html +3 -0
  330. package/packs/gallery/habit/writing.md +21 -0
  331. package/packs/gallery/heatmap/component.json +18 -0
  332. package/packs/gallery/heatmap/example.html +3 -0
  333. package/packs/gallery/heatmap/kit.js +351 -0
  334. package/packs/gallery/heatmap/preview.svg +1 -0
  335. package/packs/gallery/heatmap/style.css +201 -0
  336. package/packs/gallery/heatmap/template.html +3 -0
  337. package/packs/gallery/heatmap/writing.md +21 -0
  338. package/packs/gallery/kanban/component.json +18 -0
  339. package/packs/gallery/kanban/example.html +12 -0
  340. package/packs/gallery/kanban/kit.js +540 -0
  341. package/packs/gallery/kanban/preview.svg +1 -0
  342. package/packs/gallery/kanban/style.css +212 -0
  343. package/packs/gallery/kanban/template.html +3 -0
  344. package/packs/gallery/kanban/writing.md +20 -0
  345. package/packs/gallery/metric/component.json +22 -0
  346. package/packs/gallery/metric/example.html +15 -0
  347. package/packs/gallery/metric/kit.js +248 -0
  348. package/packs/gallery/metric/preview.svg +1 -0
  349. package/packs/gallery/metric/style.css +92 -0
  350. package/packs/gallery/metric/template.html +3 -0
  351. package/packs/gallery/metric/writing.md +23 -0
  352. package/packs/gallery/note/component.json +14 -0
  353. package/packs/gallery/note/example.html +3 -0
  354. package/packs/gallery/note/kit.js +102 -0
  355. package/packs/gallery/note/preview.svg +1 -0
  356. package/packs/gallery/note/style.css +76 -0
  357. package/packs/gallery/note/template.html +3 -0
  358. package/packs/gallery/note/writing.md +18 -0
  359. package/packs/gallery/pack.json +8 -0
  360. package/packs/gallery/recent/component.json +13 -0
  361. package/packs/gallery/recent/example.html +1 -0
  362. package/packs/gallery/recent/kit.js +238 -0
  363. package/packs/gallery/recent/preview.svg +1 -0
  364. package/packs/gallery/recent/style.css +158 -0
  365. package/packs/gallery/recent/template.html +1 -0
  366. package/packs/gallery/recent/writing.md +15 -0
  367. package/packs/gallery/static/component.json +13 -0
  368. package/packs/gallery/static/example.html +11 -0
  369. package/packs/gallery/static/preview.svg +1 -0
  370. package/packs/gallery/static/style.css +138 -0
  371. package/packs/gallery/static/template.html +1 -0
  372. package/packs/gallery/static/writing.md +18 -0
  373. package/packs/gallery/stats/component.json +13 -0
  374. package/packs/gallery/stats/example.html +1 -0
  375. package/packs/gallery/stats/kit.js +166 -0
  376. package/packs/gallery/stats/preview.svg +1 -0
  377. package/packs/gallery/stats/style.css +151 -0
  378. package/packs/gallery/stats/template.html +1 -0
  379. package/packs/gallery/stats/writing.md +11 -0
  380. package/packs/gallery/today/component.json +12 -0
  381. package/packs/gallery/today/example.html +1 -0
  382. package/packs/gallery/today/kit.js +185 -0
  383. package/packs/gallery/today/preview.svg +1 -0
  384. package/packs/gallery/today/style.css +120 -0
  385. package/packs/gallery/today/template.html +1 -0
  386. package/packs/gallery/today/writing.md +14 -0
  387. package/packs/gallery/todos/component.json +19 -0
  388. package/packs/gallery/todos/example.html +3 -0
  389. package/packs/gallery/todos/kit.js +342 -0
  390. package/packs/gallery/todos/preview.svg +1 -0
  391. package/packs/gallery/todos/style.css +267 -0
  392. package/packs/gallery/todos/template.html +3 -0
  393. package/packs/gallery/todos/writing.md +30 -0
  394. package/packs/gallery/weather/component.json +19 -0
  395. package/packs/gallery/weather/example.html +3 -0
  396. package/packs/gallery/weather/kit.js +312 -0
  397. package/packs/gallery/weather/preview.svg +1 -0
  398. package/packs/gallery/weather/style.css +258 -0
  399. package/packs/gallery/weather/template.html +3 -0
  400. package/packs/gallery/weather/writing.md +26 -0
  401. package/packs/gallery-soft/pack.json +8 -0
  402. package/release.json +13 -11
  403. package/sdk/doc-kit.d.ts +404 -7
  404. package/sdk/doc-state.d.ts +2 -0
  405. package/skill/SKILL.md +71 -26
  406. package/skill/references/block-script.md +140 -0
  407. package/skill/references/building-blocks.md +257 -0
  408. package/skill/references/example-report.html +1 -1
  409. package/skill/references/extensions.md +59 -0
  410. package/skill/references/pages-and-data.md +221 -0
  411. package/skill/references/writing-html.md +9 -7
  412. package/skill/sdk/doc-kit.d.ts +404 -7
  413. package/skill/sdk/doc-state.d.ts +2 -0
  414. package/web/assets/index-BK2e_07w.js +13 -0
  415. package/web/assets/index-CWFI83mF.css +1 -0
  416. package/web/index.html +2 -2
  417. package/browser/editor/components/callout/page.mjs +0 -13
  418. package/dist/chunk-2PBALTR3.mjs +0 -57
  419. package/dist/chunk-3LA3EMDE.mjs +0 -15
  420. package/dist/chunk-5FRMCDPY.mjs +0 -16
  421. package/dist/chunk-5LEK2CBS.mjs +0 -2
  422. package/dist/chunk-5OFN5AHC.mjs +0 -2
  423. package/dist/chunk-5SIYS5HN.mjs +0 -2
  424. package/dist/chunk-5TEK3RAD.mjs +0 -2
  425. package/dist/chunk-6CYG3Z4V.mjs +0 -2
  426. package/dist/chunk-7GHT2UCA.mjs +0 -15
  427. package/dist/chunk-7QQBR7PB.mjs +0 -2
  428. package/dist/chunk-ATCJYAR4.mjs +0 -2
  429. package/dist/chunk-C7HWOBIF.mjs +0 -2
  430. package/dist/chunk-E7VYDG2X.mjs +0 -2
  431. package/dist/chunk-EZY3WC6Z.mjs +0 -15
  432. package/dist/chunk-FQGQH4KM.mjs +0 -2
  433. package/dist/chunk-G7TOXONE.mjs +0 -6
  434. package/dist/chunk-GPF4YWWB.mjs +0 -9
  435. package/dist/chunk-GYQV7Y4J.mjs +0 -120
  436. package/dist/chunk-HMHK3EQ6.mjs +0 -2
  437. package/dist/chunk-HQQMJCQJ.mjs +0 -10
  438. package/dist/chunk-IERUOGC3.mjs +0 -6
  439. package/dist/chunk-ITNLYXXV.mjs +0 -3
  440. package/dist/chunk-L4DVONOG.mjs +0 -2
  441. package/dist/chunk-LAE5NQ4B.mjs +0 -2
  442. package/dist/chunk-LC7YNQFG.mjs +0 -2
  443. package/dist/chunk-LHTFLRB6.mjs +0 -4
  444. package/dist/chunk-NFIBI4IP.mjs +0 -26
  445. package/dist/chunk-NSKUTQ5J.mjs +0 -5
  446. package/dist/chunk-O52JMOCZ.mjs +0 -2
  447. package/dist/chunk-P2CAZPDP.mjs +0 -3
  448. package/dist/chunk-QMQUXTU4.mjs +0 -12
  449. package/dist/chunk-QVWVFC5K.mjs +0 -6
  450. package/dist/chunk-QYKCJ7FG.mjs +0 -8
  451. package/dist/chunk-QZY6Q64C.mjs +0 -2
  452. package/dist/chunk-TDQP3DKQ.mjs +0 -10
  453. package/dist/chunk-TX6JH7TR.mjs +0 -2
  454. package/dist/chunk-UNUEWH4S.mjs +0 -2
  455. package/dist/chunk-V4CPWKMZ.mjs +0 -2
  456. package/dist/chunk-VACRB2NE.mjs +0 -3
  457. package/dist/chunk-W63L7367.mjs +0 -7
  458. package/dist/chunk-W7CXPCRV.mjs +0 -6
  459. package/dist/chunk-XINNG4F2.mjs +0 -4
  460. package/dist/chunk-YL2DPWVS.mjs +0 -4
  461. package/dist/chunk-YZ5Z6H4W.mjs +0 -4
  462. package/dist/chunk-ZBIM6ARY.mjs +0 -216
  463. package/skill/references/building-components.md +0 -327
  464. package/web/assets/index-B6Ai3wsa.js +0 -13
  465. package/web/assets/index-SYPC3EZy.css +0 -1
@@ -0,0 +1,37 @@
1
+ // What a component that hears `source` hears of attributes (src/render/kit/runtime/kernel.js;
2
+ // docs/render.md "A custom block on a page"): a change of an attribute in a part or a slot that says
3
+ // something of the file, and of a class only where a look class changes, so that what the kit and the
4
+ // editor toggle as they lay the page out is no change of the file's.
5
+
6
+ import { COLOR_NAMES } from "./colors.mjs";
7
+
8
+ /**
9
+ * The attributes that say something of the file in a part or a slot, which a component hearing
10
+ * `source` hears change (runtime/kernel.js): a to-do item checked, a cell's spans, what a table's
11
+ * header and cells say of its sort (the table description's data-sort-*, listed one by one, as an
12
+ * observer takes them). A class is one only where a look class changes (lookChanged); `hidden` and
13
+ * `open` are the reader's, which `reveal` tells.
14
+ */
15
+ export const SOURCE_ATTRIBUTES = ["data-checked", "rowspan", "colspan", "data-sort-status", "data-sort-type", "data-sort-key", "data-sort-default", "data-sort-ignore", "data-sort-value", "data-sort-rank"];
16
+
17
+ /**
18
+ * The classes that are a block's or a cell's look, which a reader sets and the file keeps: a text color
19
+ * or a fill (doc-text-<color>, doc-highlight-<color>), a cell's alignments and its bold (table.mjs's
20
+ * CELL_ALIGN_CLASSES, CELL_VALIGN_CLASSES, CELL_BOLD_CLASS, the editor's CELL_LOOKS). What the kit and
21
+ * the editor toggle as they lay a page out (a table's number and doc-table--auto, a code block's
22
+ * folds) is none, so that no component hears its own layout as a change of the file, and draws again
23
+ * for ever.
24
+ */
25
+ export const LOOK_CLASSES = new Set([
26
+ ...COLOR_NAMES.flatMap((name) => [`doc-text-${name}`, `doc-highlight-${name}`]),
27
+ // table.mjs's CELL_ALIGN_CLASSES, CELL_VALIGN_CLASSES and CELL_BOLD_CLASS, written out: an import of that
28
+ // file would bring its description, prose and all, into the kit's runtime (tests/unit/installed.mjs
29
+ // holds the two lists together).
30
+ "doc-align-left", "doc-align-center", "doc-align-right", "doc-valign-top", "doc-valign-middle", "doc-valign-bottom", "doc-bold",
31
+ ]);
32
+
33
+ /** Whether a class attribute's look classes (LOOK_CLASSES) differ from `before` to `after`, either null for none. */
34
+ export function lookChanged(before, after) {
35
+ const looks = (value) => [...new Set(String(value ?? "").split(/\s+/).filter((name) => LOOK_CLASSES.has(name)))].sort().join(" ");
36
+ return looks(before) !== looks(after);
37
+ }
@@ -1,7 +1,9 @@
1
- // A callout (提示块): a basic block.
1
+ // A callout (提示块), a container of blocks set apart on a fill, a line at its left; one written the
2
+ // old way, words straight in it, holds them as one paragraph (the editor's natural HTML).
2
3
  export default {
3
4
  id: "callout",
4
- category: "block",
5
+ category: "container",
5
6
  match: ".doc-callout",
7
+ flow: ".doc-callout",
6
8
  classes: ["doc-callout"],
7
9
  };
@@ -28,7 +28,7 @@ import table from "./table.mjs";
28
28
  import text from "./text.mjs";
29
29
  import widget from "./widget.mjs";
30
30
  import { attr, elementsOf, walk } from "../html-tree.mjs";
31
- import { ATTRIBUTE, INSTANCE } from "./installed.mjs";
31
+ import { ATTRIBUTE, INSTANCE, SLOT, SLOT_PART } from "./installed.mjs";
32
32
 
33
33
  // The kit's components as every system sees them (docs/internals.md, "Components"): what each is
34
34
  // in a report's markup, one plain-data description each, shared by the kit (how it runs), the
@@ -95,8 +95,8 @@ import { ATTRIBUTE, INSTANCE } from "./installed.mjs";
95
95
 
96
96
  export const COMPONENTS = [
97
97
  page, text, mention, // the page; inline marks, links shown with their icon
98
- paragraph, heading, list, quote, callout, code, divider, math, // basic blocks
99
- section, highlight, details, dialog, sheets, table, columns, // containers
98
+ paragraph, heading, list, quote, code, divider, math, // basic blocks
99
+ section, highlight, callout, details, dialog, sheets, table, columns, // containers
100
100
  figure, chart, image, file, bookmark, embed, // cards (a figure: a chart or a drawing of the report's own; an image, a file, a bookmark, an embed)
101
101
  widget, diff, icon, installed, // whole blocks (the page's icon one, in the header; an instance of a component package)
102
102
  state, // reading state, bound to blocks of any kind
@@ -135,9 +135,18 @@ export const CATEGORIES = {
135
135
  export const EVENTS = {
136
136
  "doc-theme-change": "the theme shown changed (ui.js): the reader chose one, the workbench asked for one, or the system's changed while none is chosen",
137
137
  "doc-theme-request": "a workbench asks for a theme (ui.js listens)",
138
- "doc-layout-change": "a card's size changed where widths do not tell (the editor)",
138
+ "doc-look-request": "the document's look is asked of the page (字体与布局: the page's session for the workbench, the preview's live reload for doc.json written again; ui.js puts it on <html>, src/shared/document-look.mjs)",
139
+ "doc-look-change": "the look the page shows changed (ui.js): the page editor's session tells the workbench",
140
+ "doc-layout-change": "a card's size changed where widths do not tell (the editor, a custom page's canvas), or the document's look changed (ui.js)",
141
+ "doc-workspace-change": "what the workspace holds changed, the kind its detail (the page's live script, as the server's \"data <kind>\" says it): the kit tells the instances that hear data and read that kind",
142
+ "doc-todo-set": "a block's context.workspace.setTodo asks whoever shows the page to check a to-do of a document (cancelable: a custom page's board or a document's editor cancels it and answers from the workspace's service)",
143
+ "doc-open-request": "a block's context.workspace.open asks to open a document or a custom page (cancelable: the page's session for the workbench answers it, else the kit goes there)",
139
144
  "doc-editable": "the page takes what a component writes from now on (the editor)",
140
145
  "doc-component-edit": "a component's context.edit asks to write a part: the editor cancels it to say it took the edit, the kit writing no file (on the instance)",
146
+ "doc-table-intent": "a view's context.table() asks to change the table it reads (set a cell, move, add or take out a row), or whether it would take such a change now (canEdit, op check): the editor cancels it to say it made the change (or would), one undo step, the kit writing nothing (on the instance)",
147
+ "doc-settings-changed": "what gallery.json says of the components changed (the page's event stream, its settings line: hidden, disabled, shown, the consents to the net, unlisted and the packs off): the editor's menus follow it, and the kit starts again an instance whose block's consent changed (runtime/net.js)",
148
+ "doc-net-fetch": "a block's context.fetch asks whoever serves the page to fetch for it (runtime/net.js sends it; the server's live script cancels it and answers from its net route)",
149
+ "doc-net-consent": "a block's 允许访问 asks the reader to let it online (runtime/net.js sends it; the page's session cancels it and the workbench opens its consent dialog)",
141
150
  "doc-export-copy-done": "导出当前视图副本 finished (ui.js)",
142
151
  "doc-table-sort": "a table's sort changed (tables/, on the table)",
143
152
  "doc-jump-request": "演示视图 asks the kit to go to a block of its own page, a step of the history (runtime/reveal.js listens, editor/page/present-links.mjs sends)",
@@ -169,9 +178,11 @@ export const FLOW_BLOCKS = `${FLOWS.join(", ")}, :is(${GROUPING_FLOWS.join(", ")
169
178
  * What the kit's runtime reads of the descriptions (runtime/kernel.js): where each component's
170
179
  * instances are (`match`) and what it leaves on the page (`runtime`), of the components that say
171
180
  * either. /kit/runtime.js carries these alone (assets.mjs, `define`), so an export holds no prose.
172
- * A field the kernel starts reading is added to RUNTIME_FIELDS (tests/unit/runtime.mjs checks it).
181
+ * A field the kernel starts reading is added to RUNTIME_FIELDS (tests/unit/runtime.mjs checks it):
182
+ * `needs`, what a custom block uses (its context.workspace), which only a package describes (no
183
+ * component of the kit has it, so the runtime carries none).
173
184
  */
174
- export const RUNTIME_FIELDS = ["match", "runtime", "schema"];
185
+ export const RUNTIME_FIELDS = ["match", "runtime", "schema", "needs"];
175
186
  export const runtimeDescriptions = (components = COMPONENTS) => components
176
187
  .filter((component) => RUNTIME_FIELDS.some((field) => component[field] !== undefined))
177
188
  .map((component) => Object.fromEntries([["id", component.id], ...RUNTIME_FIELDS.filter((field) => component[field] !== undefined).map((field) => [field, component[field]])]));
@@ -239,6 +250,58 @@ export function matchesNode(node, selector) {
239
250
  /** Whether a parsed node is an instance of a component package (installed.mjs): asked of every element by every walk, so by its attribute first, which few have. */
240
251
  export const isInstance = (node) => attr(node, ATTRIBUTE) !== undefined && matchesNode(node, INSTANCE);
241
252
 
253
+ /** Whether a parsed node is a slot of an instance (installed.mjs SLOT): a block-level div or section marked so, wherever it stands. */
254
+ export const isSlot = (node) => attr(node, SLOT) !== undefined && matchesNode(node, SLOT_PART);
255
+
256
+ // The nearest edge of a region around a parsed node (an instance or a slot, itself left out), or null.
257
+ const edgeAround = (node) => {
258
+ let around = node.parentNode;
259
+ while (around && !(isInstance(around) || isSlot(around))) around = around.parentNode;
260
+ return around ?? null;
261
+ };
262
+
263
+ /**
264
+ * The instance whose own region a parsed node stands in, or null where it is the document's: the rule
265
+ * of installed.mjs heldBy, on parse5's tree (the edges folded from the outermost in: an instance's own
266
+ * slot opens the document's again, what stands in a component's region stays its).
267
+ */
268
+ export function heldByNode(node) {
269
+ const edge = edgeAround(node);
270
+ if (!edge) return null;
271
+ const owner = heldByNode(edge);
272
+ if (isInstance(edge)) return owner ?? edge;
273
+ return owner !== null && edgeAround(edge) === owner ? null : owner;
274
+ }
275
+
276
+ /**
277
+ * Every slot of an instance's own markup, in document order (none of an instance in it, none in
278
+ * another slot), whatever its name: what the checks hold to its manifest.
279
+ */
280
+ export function ownSlots(instance) {
281
+ const found = [];
282
+ const look = (node) => {
283
+ for (const child of elementsOf(node)) {
284
+ if (isSlot(child)) found.push(child);
285
+ else if (!isInstance(child)) look(child);
286
+ }
287
+ };
288
+ look(instance);
289
+ return found;
290
+ }
291
+
292
+ /** The slots of an instance, the first of each name: where what it holds is the document's (a second of a name is a failure of the checks). */
293
+ export function instanceSlots(instance) {
294
+ const named = new Set();
295
+ return ownSlots(instance).filter((slot) => !named.has(attr(slot, SLOT)) && named.add(attr(slot, SLOT)));
296
+ }
297
+
298
+ /**
299
+ * How a walk (html-tree.mjs) goes through what is the document's own: it stops at an instance of a
300
+ * component package and goes on in its slots, never handing a slot itself to the visit (its tag is
301
+ * the component's, what it holds the document's).
302
+ */
303
+ export const BODY = Object.freeze({ stop: isInstance, through: instanceSlots });
304
+
242
305
  /** A part's elements in a parsed host, each once, in document order. */
243
306
  export function partOf(host, at) {
244
307
  const pieces = piecesOf(at);
@@ -254,12 +317,12 @@ export function partOf(host, at) {
254
317
 
255
318
  /**
256
319
  * Each instance of a component in a parsed tree, in document order. What stands in an instance of a
257
- * component package is its component's and no other's, and such an element is of its own package
258
- * alone, whatever class it carries.
320
+ * component package is its component's and no other's, but for what its slots hold, which is the
321
+ * document's (BODY), and such an element is of its own package alone, whatever class it carries.
259
322
  */
260
323
  export function instancesOf(root, component) {
261
324
  const found = [];
262
- if (component.match) walk(root, (element) => { if (matchesNode(element, component.match) && (!isInstance(element) || attr(element, ATTRIBUTE) === component.id)) found.push(element); }, { stop: isInstance });
325
+ if (component.match) walk(root, (element) => { if (matchesNode(element, component.match) && (!isInstance(element) || attr(element, ATTRIBUTE) === component.id)) found.push(element); }, BODY);
263
326
  return found;
264
327
  }
265
328
 
@@ -2,11 +2,16 @@
2
2
  // src/shared/component-catalog.mjs): a block-level div or section naming its package, which is all a
3
3
  // system needs to tell where the instance stands. The boundary depends on no catalog, so it holds in
4
4
  // a file sent to someone who has no such package, or that has lost it: nothing of Gallery's goes into
5
- // an instance, whatever it holds (the scan and naturalize, the kit's other components, formulas,
6
- // spacing and a picture's viewer), but the parts its manifest gives the editor. The rest of it is
7
- // the component's, its events too. One of no package is shown as it stands, read-only, and the kit marks
8
- // it so (FALLBACK), a note beside what it holds in a preview, and what a script of data in it holds,
9
- // which no reader would see, drawn as the kit draws any (DATA_SHOWN).
5
+ // an instance's own region, whatever it holds (the scan and naturalize, the kit's other components,
6
+ // formulas, spacing and a picture's viewer), but the parts its manifest gives the editor. The rest of
7
+ // it is the component's, its events too, but for its slots (SLOT: a div or section of its own markup
8
+ // marked data-doc-slot, its manifest's part edited as "flow"), whose insides are the document's again:
9
+ // its blocks, read, edited, checked and drawn as anywhere in a flow, by the same mark and no catalog
10
+ // either. One rule tells whose an element is (heldBy), the same on the server (components/index.mjs
11
+ // heldByNode), in the kit and on the page. One of no package is shown as it stands, read-only, and the
12
+ // kit marks it so (FALLBACK), a note beside what it holds in a preview, and what a script of data in
13
+ // it holds, which no reader would see, drawn as the kit draws any (DATA_SHOWN); its slots stay the
14
+ // document's, and editable.
10
15
 
11
16
  /** The attribute that makes an element an instance, its value the package's id: <scope>/<name>. */
12
17
  export const ATTRIBUTE = "data-doc-component";
@@ -17,6 +22,79 @@ export const PACKAGE_ID = /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/;
17
22
  /** Where a document's instances are: what stops every system at the edge of one. */
18
23
  export const INSTANCE = `div[${ATTRIBUTE}], section[${ATTRIBUTE}]`;
19
24
 
25
+ /** The attribute that makes an element of an instance's own markup a slot, its value the name of the part its manifest edits as "flow". */
26
+ export const SLOT = "data-doc-slot";
27
+
28
+ /** Where slots are: a block-level div or section so marked. */
29
+ export const SLOT_PART = `div[${SLOT}], section[${SLOT}]`;
30
+
31
+ // The edges of a region: an instance, where the component's begins, and a slot, where the document's may again.
32
+ const REGION = `${INSTANCE}, ${SLOT_PART}`;
33
+
34
+ // The nearest edge of a region around a node (itself left out), or null.
35
+ const edgeAround = (node) => node?.parentElement?.closest(REGION) ?? null;
36
+
37
+ /**
38
+ * The instance whose own region a node of a page stands in, or null where it is the document's: the
39
+ * edges around it folded from the outermost in. An instance met in the document's region opens its
40
+ * component's; its own slot (one whose nearest edge is that instance) opens the document's again; an
41
+ * instance or a slot met in a component's region stays that component's. A slot itself is its
42
+ * instance's (the component places it), and an instance itself stands in the region around it (its
43
+ * frame and its handle are Gallery's). For a page's DOM; the server's is heldByNode.
44
+ */
45
+ export function heldBy(node) {
46
+ const edge = edgeAround(node);
47
+ if (!edge) return null;
48
+ const owner = heldBy(edge);
49
+ if (edge.matches(INSTANCE)) return owner ?? edge;
50
+ return owner !== null && edgeAround(edge) === owner ? null : owner;
51
+ }
52
+
53
+ /**
54
+ * The region what an element holds stands in (its children, its words): the instance itself for an
55
+ * instance, the document's (null) inside a slot that opens it again, and otherwise the region the
56
+ * element stands in, as heldBy says it. heldBy for a child the element does not have yet, or has lost:
57
+ * where a change of what it holds happened.
58
+ */
59
+ export function heldWithin(element) {
60
+ if (!element.matches(REGION)) return heldBy(element);
61
+ const owner = heldBy(element);
62
+ if (element.matches(INSTANCE)) return owner ?? element;
63
+ return owner !== null && edgeAround(element) === owner ? null : owner;
64
+ }
65
+
66
+ /** Whether an element is a slot that opens the document's region again: one of an instance that stands in the document's. */
67
+ const opensDocument = (node) => node.matches(SLOT_PART) && heldBy(node) !== null && edgeAround(node) === heldBy(node);
68
+
69
+ /**
70
+ * Whether what happens on an element (a press, a key, a change of what it holds) is a component's: it
71
+ * stands in an instance's own region. Not a slot that opens the document's (its blank is the page's
72
+ * box), nor an instance itself (its frame is Gallery's).
73
+ */
74
+ export const componentAt = (node) => node?.nodeType === 1 && heldBy(node) !== null && !opensDocument(node);
75
+
76
+ /**
77
+ * The slot whose inside is the document's region a node stands in (one of an instance that stands in
78
+ * the document's, opening it again), the nearest, or null for the page around it: where what is one
79
+ * block of the page's is looked for (the editor's registry.mjs ownerOf).
80
+ */
81
+ export function slotAround(node) {
82
+ for (let at = node; at;) {
83
+ const owner = heldBy(at);
84
+ if (owner) {
85
+ at = owner;
86
+ continue;
87
+ }
88
+ const edge = edgeAround(at); // a slot, or none: no instance holds it
89
+ if (!edge || opensDocument(edge)) return edge;
90
+ at = edge; // a slot of no instance's: the region around it
91
+ }
92
+ return null;
93
+ }
94
+
95
+ /** The slots of an instance: those of its own markup (no other instance's, nor one in another slot), in document order. */
96
+ export const slotsIn = (instance) => [...instance.querySelectorAll(SLOT_PART)].filter((slot) => edgeAround(slot) === instance);
97
+
20
98
  /** The kit's mark on an instance of no package, for its look (styles/installed.css). */
21
99
  export const FALLBACK = "data-doc-fallback";
22
100
 
@@ -45,8 +123,24 @@ export const PACKAGE_MARK = "data-doc-package";
45
123
  */
46
124
  export const ARRIVING = "data-ge-arriving";
47
125
 
48
- /** What gallery.json's lists make of a package that loads: "disabled", "hidden" or "normal". */
49
- export const settingState = (id, { hidden, disabled }) => (disabled.includes(id) ? "disabled" : hidden.includes(id) ? "hidden" : "normal");
126
+ /**
127
+ * Whether the document's insert entries ("/", 在下方新建, the handle's grid, a table's 视图 ›) offer the
128
+ * block `id` whose manifest's `places` are those (left out: ["document"]), by gallery.json's lists
129
+ * (`settings`: hidden, shown, disabled, unlisted, packsOff, each left out for none): one that says it stands in a
130
+ * document is offered unless hidden; one that does not, only where shown; one disabled never, as it does
131
+ * not load, nor one unlisted (设置 › 组件列表's master switch off: no menu and no library offers it, what
132
+ * is written of it shows as ever), nor one of a pack switched off (packsOff, the ids of the packs off: the
133
+ * scope of its id; the same as unlisted, for a whole pack). The one rule, which the server and the page
134
+ * both run (notes/plans/custom-blocks-spec-2026-11-07.md section 2, block-packs-plan-2026-11-09.md §1).
135
+ */
136
+ export function inDocumentMenus(places, settings, id) {
137
+ const { hidden = [], shown = [], disabled = [], unlisted = [], packsOff = [] } = settings ?? {};
138
+ if (disabled.includes(id) || unlisted.includes(id) || packsOff.includes(String(id).split("/")[0])) return false;
139
+ return (places ?? ["document"]).includes("document") ? !hidden.includes(id) : shown.includes(id);
140
+ }
141
+
142
+ /** What gallery.json's lists make of a package that loads, its manifest's `places` with them: "disabled", "hidden" (no document's menu offers it: inDocumentMenus, which a block unlisted is too) or "normal". */
143
+ export const settingState = (id, settings, places) => (settings.disabled.includes(id) ? "disabled" : inDocumentMenus(places, settings, id) ? "normal" : "hidden");
50
144
 
51
145
  /** The class of the kit's note in such an instance, in a preview alone. */
52
146
  export const NOTE = "doc-component-note";
@@ -150,13 +244,21 @@ export default {
150
244
  id: "installed",
151
245
  category: "whole",
152
246
  match: INSTANCE,
247
+ // An instance's slots are flows: what they hold is the document's blocks (FLOWS, styles/flow.css). A
248
+ // plain string, [SLOT]: an expression here would keep this description in every bundle that imports a
249
+ // constant of this file (the runtime takes none of its prose).
250
+ flow: "[data-doc-slot]",
153
251
  attrs: {
154
252
  "data-doc-component": "the package an instance is of: <scope>/<name>, on a block-level div or section",
155
253
  "data-doc-schema": "the shape an instance holds its content in: a whole number its component chooses, read-only past its manifest's schema",
254
+ "data-doc-slot": "a slot of an instance: the part of its manifest edited as flow, by name, on a block-level div or section in the instance's own region; what it holds is the document's blocks",
255
+ "data-doc-from": "on an instance of a custom block whose needs hold tables: the key of the table it is a view of, which the table's frame carries as data-doc-chart-source",
156
256
  },
157
257
  runtime: {
158
258
  generated: [".doc-component-note", ".doc-component-data"],
159
259
  attrs: { "[data-doc-fallback]": ["data-doc-fallback"], "[data-doc-fallback-control]": ["data-doc-fallback-control", "inert"] },
160
- internal: [PACKAGE_MARK, "doc-component-more", DATA_ONE, DATA_LINE, DATA_SHORT], // of what the kit drew of a script of data: a line saying what it left out, and its marks
260
+ // Of what the kit drew of a script of data: a line saying what it left out, and its marks; and the mark
261
+ // DocKit.drag (runtime/gestures.js) puts on what a component draws while it is dragged, a class.
262
+ internal: [PACKAGE_MARK, "doc-component-more", DATA_ONE, DATA_LINE, DATA_SHORT, "doc-dragging"],
161
263
  },
162
264
  };
@@ -13,6 +13,15 @@ export function pageLanguage(html) {
13
13
  return /\slang\s*=\s*["']?en(?:-[^"'\s>]*)?(?=["'\s>]|$)/i.test(tag) ? "en" : "zh";
14
14
  }
15
15
 
16
+ /**
17
+ * A document's look on its <html> (字体与布局: its doc.json's look, which the render puts on and the kit's
18
+ * tokens read; src/shared/document-look.mjs), the attribute of each choice. The 正文宽度's is
19
+ * data-doc-measure (a column's measure, its line length); 全宽 (the top bar's 更多, under 目录) is
20
+ * data-doc-width="full", the one attribute the kit's page, the editor's room and the display menu's
21
+ * 全宽显示 (the reader's own switch in an export) all read: one way to be wide, not two.
22
+ */
23
+ export const LOOK_ATTRIBUTES = Object.freeze({ font: "data-doc-font", size: "data-doc-size", spacing: "data-doc-spacing", width: "data-doc-measure", full: "data-doc-width" });
24
+
16
25
  export default {
17
26
  id: "page",
18
27
  match: "main.doc-page",
@@ -30,8 +39,18 @@ export default {
30
39
  classes: ["doc-page", "doc-header", "doc-kicker", "doc-title", "doc-button"],
31
40
  runtime: {
32
41
  generated: [".doc-display", "script[data-doc-state]"],
33
- root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls"] },
34
- state: { html: ["data-doc-theme", "data-doc-width"] },
35
- internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error"],
42
+ // data-doc-effective-theme: the theme the page shows now (ui.js), "light" or "dark", which a custom page's own colors go by.
43
+ // data-doc-platform: "mac" on an Apple platform (runtime/index.js sets it as the page opens), the text's color and smoothing go by it; a copy of the view lets it go, its reader's machine judges anew.
44
+ root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls", "data-doc-effective-theme", "data-doc-platform"] },
45
+ // The reader's theme (ui.js) and the document's look (字体与布局 and 全宽: its doc.json's, put on by
46
+ // the render, src/shared/document-look.mjs; the reader's own 全宽显示 is the same data-doc-width), which
47
+ // a copy of the view keeps; never written in doc.html.
48
+ state: { html: ["data-doc-theme", ...Object.values(LOOK_ATTRIBUTES)] },
49
+ internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error", "doc-net-consent*", "data-doc-snapshot",
50
+ // The time an export's snapshot was made (its data-doc-snapshot tag's: render/net-snapshot.mjs), which context.workspace.query answers as `at`.
51
+ "data-at",
52
+ // A custom page's (no document's: src/render/page-html.mjs, the kit's board/): its cards' cells, the Agent's
53
+ // (data-x, data-y, data-w, data-h), and its boards' columns now (data-columns, board.js's).
54
+ "data-x", "data-y", "data-w", "data-h", "data-columns"],
36
55
  },
37
56
  };
@@ -2,7 +2,9 @@
2
2
  // a key (data-doc-bind), elements shown for a key's value (data-doc-show),
3
3
  // keys forgotten when the page is left (data-doc-transient); and the kit's styles of such
4
4
  // controls (styles/state.css). A filter (.doc-filter) is one block: its row of buttons and what
5
- // they filter below it (a list, say), together.
5
+ // they filter below it (a list, say), together. A <select> of any control or block, bound or not, opens
6
+ // the kit's menu of choices (runtime/choice.js, styles/choice.css), never the browser's popup: a card at
7
+ // the end of <body> while it is open, nothing an author writes, which an export of the view leaves out.
6
8
  export default {
7
9
  id: "state",
8
10
  match: "[data-doc-bind], [data-doc-show]",
@@ -14,7 +16,9 @@ export default {
14
16
  classes: ["doc-state-fields", "doc-state-field", "doc-state-actions", "doc-filter", "doc-filter-row", "doc-filter-button", "doc-state-list"],
15
17
  wholes: ["doc-filter", "doc-filter-row", "doc-state-fields", "doc-state-list"], // the classes above that are a whole block of their own (the others are parts inside one)
16
18
  runtime: {
19
+ generated: [".doc-choice"],
17
20
  attrs: { "[data-doc-show]": ["hidden"] },
18
21
  state: { "button[data-doc-bind]": ["aria-pressed"] },
22
+ internal: ["doc-choice-*"], // the menu's rows, their words, the check and the group headings
19
23
  },
20
24
  };
@@ -31,7 +31,7 @@ export default {
31
31
  "data-doc-chart-source": "on its frame: the key a chart drawn from it reads it by (data-doc-chart-data on the chart's host)",
32
32
  },
33
33
  // A cell may also be given a text color or a fill (doc-text-*, doc-highlight-*: text.mjs), an alignment, a vertical one and bold
34
- // (doc-bold); a header cell's look is doc-bold doc-highlight-gray, as the page editor gives it.
34
+ // (doc-bold); a header row's cell's look is doc-bold doc-highlight-gray, as the page editor gives it (a header column's th scope="row" none).
35
35
  classes: ["doc-table", "doc-table-wrap", "doc-table-meta", "doc-table--sticky-first", ...CELL_ALIGN_CLASSES, ...CELL_VALIGN_CLASSES, CELL_BOLD_CLASS],
36
36
  fills: { "th": ["data-sort-type"] },
37
37
  runtime: {
@@ -9,6 +9,6 @@ export default {
9
9
  ...COLORS.map((color) => `doc-highlight-${color}`),
10
10
  ...["orange", "blue", "purple", "plain", "thin", "thick"].map((kind) => `doc-underline-${kind}`),
11
11
  ],
12
- // A number range in the text (3–13, 1–3B), held on one line (runtime/spacing.js).
13
- runtime: { classes: { ".doc-range": ["doc-range"] } },
12
+ // A number range in the text (3–13, 1–3B), held on one line, and a long run (a path, a URL: src/shared/long-runs.mjs) held in a span that breaks anywhere (runtime/spacing.js).
13
+ runtime: { classes: { ".doc-range": ["doc-range"], ".doc-long-run": ["doc-long-run"] } },
14
14
  };
@@ -0,0 +1,183 @@
1
+ // A document's look (字体与布局 and 全宽, under the workbench's 更多: Notion's page format, notion-lite's
2
+ // view/frame/page-format.js, whose page_full_width is a field of the page as ours is of the document):
3
+ // its font, the size of its text, the spacing of its lines and blocks, the width of its reading column
4
+ // and whether it is shown at the full width of the page whatever that is (全宽). The document's own, as
5
+ // Notion keeps it on the page: `look` in its
6
+ // doc.json (report.json in a document made before Gallery 0.1), over the workspace's default look,
7
+ // `look` in its gallery.json (which the card's 应用到全部文档 writes, every document's own taken away:
8
+ // ./workspace-look.mjs), choice by choice (effectiveLook). The workspace's keeps each choice that is
9
+ // not the default, the field gone when none is; a doc.json each choice that is not the workspace's,
10
+ // the field gone when none is:
11
+ //
12
+ // "look": { "font": "serif" | "mixed", "size": "small" | "large", "spacing": "compact" | "loose", "width": "narrow" | "wide", "full": "full" }
13
+ //
14
+ // A doc.json may say a default too ("font": "sans", "size": "default"…): 默认 chosen on a page while
15
+ // the workspace's default says otherwise. The look a document shows is never written in doc.html: the
16
+ // render puts it on the page's <html> as data attributes
17
+ // (withLook, render/report-html.mjs: the preview, 演示视图, a build, an export, its PDF), which the
18
+ // kit's tokens read (styles/tokens.css, @kit-look, written by render/look-css.mjs); a page takes a
19
+ // change at once (`doc-look-request`, the kit's ui.js: the workbench's choice, sent by the page's
20
+ // session, and doc.json changed, said by the preview's live reload). A value it does not know is the
21
+ // default. docs/render.md "A document's look" says what each choice does.
22
+
23
+ import { LOOK_ATTRIBUTES } from "./components/page.mjs";
24
+
25
+ /** Each choice and its values, the default first. */
26
+ export const LOOK = Object.freeze({
27
+ font: Object.freeze(["sans", "serif", "mixed"]), // 等线体, 衬线体, 混合体 (the title and headings serif)
28
+ size: Object.freeze(["default", "small", "large"]), // 字体大小: 小号, 默认, 大号
29
+ spacing: Object.freeze(["default", "compact", "loose"]), // 正文间距: 紧凑, 默认, 宽松
30
+ width: Object.freeze(["default", "narrow", "wide"]), // 正文宽度: 偏窄, 默认, 偏宽
31
+ // 全宽 (the 更多 menu's switch under 目录): the page at the full width of its area, whatever its 正文宽度 is; its attribute is
32
+ // the kit's own data-doc-width="full", the reader's display menu's 全宽显示 too (components/page.mjs LOOK_ATTRIBUTES)
33
+ full: Object.freeze(["default", "full"]),
34
+ });
35
+
36
+ /** The attribute each choice is on <html> by: the page's description says them (components/page.mjs). */
37
+ export { LOOK_ATTRIBUTES };
38
+
39
+ /**
40
+ * 字体大小: the factor every size of the text takes, and its line height with it (body text 15px, 16px,
41
+ * 18px): the type alone, not the gaps between blocks (正文间距's) nor the column's width (正文宽度's).
42
+ * 14px (Notion's small text) set small text and captions at 11px, too small for Chinese; 17px was hard
43
+ * to tell from 16px.
44
+ */
45
+ export const SIZE_FACTOR = Object.freeze({ default: 1, small: 15 / 16, large: 18 / 16 });
46
+
47
+ /**
48
+ * 正文间距: what a line's leading (its line height less its font size) and the gaps between blocks
49
+ * are taken at (body text's line 24px, 26px, 28px at 16px; a paragraph's gap 9px, 12px, 15px at any
50
+ * 字体大小).
51
+ */
52
+ export const SPACING = Object.freeze({
53
+ default: Object.freeze({ leading: 1, gaps: 1 }),
54
+ compact: Object.freeze({ leading: 0.8, gaps: 0.75 }),
55
+ loose: Object.freeze({ leading: 1.2, gaps: 1.25 }),
56
+ });
57
+
58
+ /**
59
+ * 正文宽度: the reading column in px, whatever the 字体大小 (which changes the type alone): 默认 the
60
+ * kit's 712px (tokens.css --doc-content-max-width), 44 characters of Chinese body text to a line at the
61
+ * default 16px; 偏窄 and 偏宽 the widths of 40 and 48 of them (40.5 and 48.5 times 16px, as 712 is 44.5
62
+ * times it). The user counted a line in characters only to fix these widths (2026-11-07: until then
63
+ * they were counted at the size chosen, so 大号 widened the column too). A narrow window narrows it as
64
+ * ever.
65
+ */
66
+ export const WIDTH = Object.freeze({ default: 712, narrow: 648, wide: 776 });
67
+
68
+ /**
69
+ * The serif (衬线体, and 混合体's title and headings): the system's own book serifs, nothing to download
70
+ * (the sidebar's Gallery wordmark is set in the first of them), then the Chinese serifs: Songti SC
71
+ * (macOS), Noto or Source Han Serif where installed, SimSun (Windows).
72
+ */
73
+ export const SERIF_FONT = '"Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif';
74
+
75
+ const isPlain = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
76
+
77
+ /** A look as kept: the choices `value` makes that are known and not the default, {} for none. */
78
+ export function lookOf(value) {
79
+ const look = {};
80
+ if (!isPlain(value)) return look;
81
+ for (const [key, choices] of Object.entries(LOOK)) {
82
+ const chosen = value[key];
83
+ if (typeof chosen === "string" && choices.includes(chosen) && chosen !== choices[0]) look[key] = chosen;
84
+ }
85
+ return look;
86
+ }
87
+
88
+ /** Each choice of a look, the default where it makes none: { font, size, spacing, width, full }. */
89
+ export const fullLook = (value) => ({ ...Object.fromEntries(Object.entries(LOOK).map(([key, [first]]) => [key, first])), ...lookOf(value) });
90
+
91
+ /** Whether two looks are the same. */
92
+ export const sameLook = (a, b) => JSON.stringify(lookOf(a)) === JSON.stringify(lookOf(b));
93
+
94
+ /**
95
+ * A document's own look as its doc.json keeps it: each known choice `value` makes, the default too
96
+ * ("sans", "default": 默认 chosen on a page while the workspace's default look says otherwise), {} for
97
+ * none. lookOf is what it shows of that alone.
98
+ */
99
+ export function ownLookOf(value) {
100
+ const look = {};
101
+ if (!isPlain(value)) return look;
102
+ for (const [key, choices] of Object.entries(LOOK)) {
103
+ const chosen = value[key];
104
+ if (typeof chosen === "string" && choices.includes(chosen)) look[key] = chosen;
105
+ }
106
+ return look;
107
+ }
108
+
109
+ /**
110
+ * The look a document shows (lookOf's form: the defaults left out), choice by choice: its own (doc.json's
111
+ * `look`, ownLookOf), else the workspace's default look (gallery.json's `look`, 应用到全部文档), else the
112
+ * default.
113
+ */
114
+ export const effectiveLook = (own, workspace) => lookOf({ ...lookOf(workspace), ...ownLookOf(own) });
115
+
116
+ /**
117
+ * What a document's doc.json keeps for it to show `look` under the workspace's default look
118
+ * `workspace`: each choice that is not the workspace's, a default too (ownLookOf), {} when it shows
119
+ * the workspace's own.
120
+ */
121
+ export function ownLookFor(look, workspace) {
122
+ const [shown, base] = [fullLook(look), fullLook(workspace)];
123
+ return Object.fromEntries(Object.keys(LOOK).filter((key) => shown[key] !== base[key]).map((key) => [key, shown[key]]));
124
+ }
125
+
126
+ /**
127
+ * A document's doc.json (its parsed object) with its own look as given (ownLookOf: an explicit default
128
+ * kept): in the field's place when it had one, else last; the field gone when it makes no choice.
129
+ * Every other field stays as it is.
130
+ */
131
+ export function withLookField(metadata, look) {
132
+ const next = ownLookOf(look);
133
+ const keep = Object.keys(next).length > 0;
134
+ const base = isPlain(metadata) ? metadata : {};
135
+ if (!Object.hasOwn(base, "look")) return keep ? { ...base, look: next } : { ...base };
136
+ return Object.fromEntries(Object.entries(base).flatMap(([key, value]) => (key !== "look" ? [[key, value]] : keep ? [[key, next]] : [])));
137
+ }
138
+
139
+ /** The look's attributes on <html>: [name, value] for each choice that is not the default. */
140
+ export const lookAttributes = (look) => Object.entries(lookOf(look)).map(([key, value]) => [LOOK_ATTRIBUTES[key], value]);
141
+
142
+ const ATTRIBUTE_VALUE = String.raw`(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?`;
143
+
144
+ /**
145
+ * A page's text with the look on its <html> start tag (the first one), as the render serves and
146
+ * exports it: whatever look attributes the file writes there taken off (doc.json is their one home),
147
+ * the look's put on. A page without an <html> tag is returned as it is.
148
+ */
149
+ export function withLook(html, look) {
150
+ const text = String(html ?? "");
151
+ const found = /<html\b[^>]*>/i.exec(text);
152
+ if (!found) return text;
153
+ let tag = found[0];
154
+ for (const name of Object.values(LOOK_ATTRIBUTES)) tag = tag.replace(new RegExp(String.raw`\s${name}${ATTRIBUTE_VALUE}(?=[\s/>])`, "gi"), "");
155
+ const added = lookAttributes(look).map(([name, value]) => ` ${name}="${value}"`).join("");
156
+ if (added) tag = tag.replace(/\s*>$/, (end) => `${added}${end.trimStart()}`);
157
+ return text.slice(0, found.index) + tag + text.slice(found.index + found[0].length);
158
+ }
159
+
160
+ /** The look an element (the page's <html>) carries by its attributes. */
161
+ export function lookOfElement(element) {
162
+ return lookOf(Object.fromEntries(Object.entries(LOOK_ATTRIBUTES).map(([key, name]) => [key, element?.getAttribute?.(name) ?? undefined])));
163
+ }
164
+
165
+ /** Put a look on an element (the page's <html>) by its attributes; whether anything changed. */
166
+ export function setLookOn(element, look) {
167
+ const next = lookOf(look);
168
+ let changed = false;
169
+ for (const [key, name] of Object.entries(LOOK_ATTRIBUTES)) {
170
+ const value = next[key] ?? null;
171
+ if (element.getAttribute(name) === value) continue;
172
+ if (value === null) element.removeAttribute(name);
173
+ else element.setAttribute(name, value);
174
+ changed = true;
175
+ }
176
+ return changed;
177
+ }
178
+
179
+ /** A look as a line's word (the preview's live reload says "look <word>"): "font=serif&size=small", "" for the default. */
180
+ export const lookWord = (look) => Object.entries(lookOf(look)).map(([key, value]) => `${key}=${value}`).join("&");
181
+
182
+ /** The look a word says (lookWord's inverse; anything else the default). */
183
+ export const lookOfWord = (word) => lookOf(Object.fromEntries(new URLSearchParams(String(word ?? ""))));