@dooc-dev/dooc 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. package/dist/cli.js +157 -58
  2. package/dist/code-worker.global.js +152 -0
  3. package/dist/code.global.js +101 -101
  4. package/dist/compiler/asset-references.d.ts +4 -0
  5. package/dist/compiler/asset-references.js +117 -0
  6. package/dist/compiler/bundle-urls.d.ts +1 -1
  7. package/dist/compiler/bundle-urls.js +17 -5
  8. package/dist/compiler/check.js +10 -5
  9. package/dist/compiler/code-languages.js +7 -2
  10. package/dist/compiler/compile.d.ts +5 -0
  11. package/dist/compiler/compile.js +117 -12
  12. package/dist/compiler/config.js +2 -1
  13. package/dist/compiler/dxf.d.ts +1 -0
  14. package/dist/compiler/dxf.js +81 -0
  15. package/dist/compiler/export.d.ts +4 -0
  16. package/dist/compiler/export.js +147 -0
  17. package/dist/compiler/figures.js +43 -10
  18. package/dist/compiler/files.js +82 -41
  19. package/dist/compiler/fonts.js +4 -1
  20. package/dist/compiler/icons.d.ts +1 -1
  21. package/dist/compiler/icons.js +11 -2
  22. package/dist/compiler/ignored-files.d.ts +5 -0
  23. package/dist/compiler/ignored-files.js +98 -0
  24. package/dist/compiler/locales.js +13 -8
  25. package/dist/compiler/ops.d.ts +6 -0
  26. package/dist/compiler/ops.js +99 -8
  27. package/dist/compiler/subformat-schema.d.ts +14 -0
  28. package/dist/compiler/subformat-schema.js +92 -0
  29. package/dist/compiler/subformats.d.ts +22 -0
  30. package/dist/compiler/subformats.js +339 -0
  31. package/dist/compiler/textfile.js +3 -0
  32. package/dist/compiler/theme-variants.js +5 -2
  33. package/dist/core/code-file.js +7 -5
  34. package/dist/core/code-grammars.d.ts +5 -0
  35. package/dist/core/code-grammars.js +34 -0
  36. package/dist/core/content-metadata.d.ts +16 -6
  37. package/dist/core/content-metadata.js +283 -17
  38. package/dist/core/content-types.d.ts +4 -2
  39. package/dist/core/escape-html.d.ts +1 -0
  40. package/dist/core/escape-html.js +1 -0
  41. package/dist/core/figure-frame.js +20 -2
  42. package/dist/core/file-embed.js +7 -3
  43. package/dist/core/files.d.ts +2 -1
  44. package/dist/core/files.js +6 -8
  45. package/dist/core/flow-base-css.generated.js +1 -1
  46. package/dist/core/html.d.ts +4 -1
  47. package/dist/core/html.js +11 -10
  48. package/dist/core/icons.d.ts +3 -0
  49. package/dist/core/icons.js +3 -0
  50. package/dist/core/json-tools.d.ts +1 -0
  51. package/dist/core/json-tools.js +12 -0
  52. package/dist/core/language.js +5 -2
  53. package/dist/core/markdown.js +3 -1
  54. package/dist/core/previewers.d.ts +8 -0
  55. package/dist/core/previewers.js +2 -0
  56. package/dist/core/routing.d.ts +5 -2
  57. package/dist/core/routing.js +17 -5
  58. package/dist/core/schema-fields.d.ts +13 -0
  59. package/dist/core/schema-fields.js +175 -0
  60. package/dist/core/schema-graph-mount.js +26 -3
  61. package/dist/core/schema-refs.d.ts +8 -0
  62. package/dist/core/schema-refs.js +82 -0
  63. package/dist/core/subformat-record.d.ts +3 -0
  64. package/dist/core/subformat-record.js +131 -0
  65. package/dist/core/subformats.d.ts +43 -0
  66. package/dist/core/subformats.js +81 -0
  67. package/dist/core/toc-ui.js +26 -24
  68. package/dist/edit.global.js +326 -118
  69. package/dist/flow.global.js +3 -3
  70. package/dist/graph/abnfDiagram-S7VZAUFO-ASBULSKE.js +1 -0
  71. package/dist/graph/architecture-WOLXFQ4H-V57EDXXY.js +1 -0
  72. package/dist/graph/architectureDiagram-YGSQEFNW-GIMP347N.js +36 -0
  73. package/dist/graph/blockDiagram-APKKGZFW-RDL2T4JW.js +140 -0
  74. package/dist/graph/bpmnIcons-APHXDYXF-TWOSQNUQ.js +1 -0
  75. package/dist/graph/c4Diagram-KJ2TOQU5-75LIUC4F.js +38 -0
  76. package/dist/graph/chunk-26TUJSYJ.js +1 -0
  77. package/dist/graph/chunk-3LU66YMI.js +1 -0
  78. package/dist/graph/chunk-3RNHDNP5.js +1 -0
  79. package/dist/graph/chunk-3Y2PDVDE.js +1 -0
  80. package/dist/graph/chunk-3YJHMOOA.js +3 -0
  81. package/dist/graph/chunk-4KILFWYV.js +339 -0
  82. package/dist/graph/chunk-4QDE4SUK.js +1 -0
  83. package/dist/graph/chunk-5OO6DATX.js +1 -0
  84. package/dist/graph/chunk-5UUEAHTN.js +1 -0
  85. package/dist/graph/chunk-6T55RVVR.js +1 -0
  86. package/dist/graph/chunk-ARAJTKOH.js +2 -0
  87. package/dist/graph/chunk-BBD5CEDC.js +72 -0
  88. package/dist/graph/chunk-BVXT562I.js +1 -0
  89. package/dist/graph/chunk-BZAMCJ6B.js +32 -0
  90. package/dist/graph/chunk-C6J4A356.js +15 -0
  91. package/dist/graph/chunk-EG5UVNOC.js +213 -0
  92. package/dist/graph/chunk-GF4TOPUK.js +1 -0
  93. package/dist/graph/chunk-GYT4IYBZ.js +1 -0
  94. package/dist/graph/chunk-HJG2HUYJ.js +88 -0
  95. package/dist/graph/chunk-HOPPTA6H.js +62 -0
  96. package/dist/graph/chunk-I3DMZIHV.js +1 -0
  97. package/dist/graph/chunk-IC23EEF6.js +1 -0
  98. package/dist/graph/chunk-ISO77HML.js +1 -0
  99. package/dist/graph/chunk-JD7ZBJD2.js +1 -0
  100. package/dist/graph/chunk-JRSH5GNS.js +1 -0
  101. package/dist/graph/chunk-JSHWCPFJ.js +1 -0
  102. package/dist/graph/chunk-K2KLZU7M.js +10 -0
  103. package/dist/graph/chunk-K4I76XBX.js +14 -0
  104. package/dist/graph/chunk-KT4VPQD5.js +135 -0
  105. package/dist/graph/chunk-KU6GTEMS.js +1 -0
  106. package/dist/graph/chunk-LT6LXKCR.js +136 -0
  107. package/dist/graph/chunk-MPR575IN.js +1 -0
  108. package/dist/graph/chunk-N3OHKGRZ.js +1 -0
  109. package/dist/graph/chunk-O656ZI37.js +1 -0
  110. package/dist/graph/chunk-OFZLK5G4.js +1 -0
  111. package/dist/graph/chunk-PDH25ALM.js +2 -0
  112. package/dist/graph/chunk-PW2RGZ3O.js +1 -0
  113. package/dist/graph/chunk-QCJUF4YA.js +1 -0
  114. package/dist/graph/chunk-QEEA3KYY.js +2 -0
  115. package/dist/graph/chunk-QYAXYFNI.js +1 -0
  116. package/dist/graph/chunk-QYTM6GY3.js +1 -0
  117. package/dist/graph/chunk-R63JUMUK.js +1 -0
  118. package/dist/graph/chunk-SCEY3ZPT.js +1 -0
  119. package/dist/graph/chunk-VM2H7G2R.js +1 -0
  120. package/dist/graph/chunk-XQS73SBQ.js +1 -0
  121. package/dist/graph/chunk-YCRLJT2S.js +1 -0
  122. package/dist/graph/chunk-Z4FIZ7CR.js +1 -0
  123. package/dist/graph/chunk-ZMCB7VP2.js +1 -0
  124. package/dist/graph/chunk-ZSZXN4BT.js +2 -0
  125. package/dist/graph/classDiagram-v2-L25IHNXF-JL7LVDZH.js +217 -0
  126. package/dist/graph/cose-bilkent-JH36ORCC-PNM3EYPB.js +1 -0
  127. package/dist/graph/cynefin-EF2NZ3EQ-PSXP3DXL.js +1 -0
  128. package/dist/graph/cynefinDiagram-L36ESFBY-QVY54CXO.js +62 -0
  129. package/dist/graph/dagre-SPEB5RXH-HPGQXBZJ.js +4 -0
  130. package/dist/graph/diagram-3B7GL73J-DWH5WS2P.js +200 -0
  131. package/dist/graph/diagram-DNEMPZML-TEGH2U5I.js +24 -0
  132. package/dist/graph/diagram-L3MUGCDN-X4MREUWR.js +41 -0
  133. package/dist/graph/diagram-LA4NIPWU-NXT746HG.js +24 -0
  134. package/dist/graph/diagram-MHCOC4E2-JGHXSAGS.js +3 -0
  135. package/dist/graph/diagram-XPFHEONP-ZHZPBLT4.js +30 -0
  136. package/dist/graph/ebnfDiagram-UZSYDL2S-SMF6KJ43.js +1 -0
  137. package/dist/graph/elk-XV6XMXQE-AZ4HLCWI.js +27 -0
  138. package/dist/graph/erDiagram-EYBAPDEH-B3JNJ357.js +99 -0
  139. package/dist/graph/eventmodeling-K75KTNOO-WG6DDYMC.js +1 -0
  140. package/dist/graph/flowDiagram-MALGAFMO-2R7EYAQI.js +1 -0
  141. package/dist/graph/ganttDiagram-23REXITY-YXBYWFOJ.js +292 -0
  142. package/dist/graph/gitGraph-VSP46ZUC-VBFWJBBT.js +1 -0
  143. package/dist/graph/gitGraphDiagram-STJD7YCW-4FZDCFGV.js +106 -0
  144. package/dist/graph/info-OHQRW6UA-ALVDUVYV.js +1 -0
  145. package/dist/graph/infoDiagram-KBXO4MBG-7EHX2GQG.js +2 -0
  146. package/dist/graph/ishikawaDiagram-M35NCXHK-FRZD2PWQ.js +70 -0
  147. package/dist/graph/journeyDiagram-OPLOXDXO-7Z66JCPR.js +139 -0
  148. package/dist/graph/kanban-definition-BZKZHSQY-NN5AIKTE.js +89 -0
  149. package/dist/graph/katex-DXDNVO6V.js +257 -0
  150. package/dist/graph/mindmap-definition-I2QAS2VK-HDPCABN2.js +98 -0
  151. package/dist/graph/packet-JDAUHWVQ-5MQIBWAH.js +1 -0
  152. package/dist/graph/pegDiagram-FD4XPPHP-H2BFNCKT.js +1 -0
  153. package/dist/graph/pie-XZMESJXO-T5VRKHVT.js +1 -0
  154. package/dist/graph/pieDiagram-J4AKIIQI-O3NJSVD3.js +39 -0
  155. package/dist/graph/quadrantDiagram-XTYBLID2-TMTZJI3P.js +7 -0
  156. package/dist/graph/radar-ABXABTNO-C6FXIBYW.js +1 -0
  157. package/dist/graph/railroad-I3PHUGI6-ZSO5JXB3.js +1 -0
  158. package/dist/graph/railroad-abnf-LNEFI6M7-CI4GQRHB.js +1 -0
  159. package/dist/graph/railroad-ebnf-DWYD2UWJ-MUENNCGK.js +1 -0
  160. package/dist/graph/railroad-peg-JR7BVNR7-N3X5GGIX.js +1 -0
  161. package/dist/graph/railroadDiagram-MRQ6NCDL-JHWS23UO.js +1 -0
  162. package/dist/graph/requirementDiagram-Y7LWUY3S-7DVLPO4B.js +84 -0
  163. package/dist/graph/sankeyDiagram-WGJFYUXA-Z5L4R5TR.js +40 -0
  164. package/dist/graph/schema-graph-global.js +639 -0
  165. package/dist/graph/sequenceDiagram-5NDRBG5M-RCTU25NT.js +169 -0
  166. package/dist/graph/sizeCapture-INFHLROL-RROY32P5.js +1 -0
  167. package/dist/graph/stateDiagram-v2-FJ4FJNEA-BXUSPWDK.js +291 -0
  168. package/dist/graph/swimlanes-UMQ2AFYF-LDD74Q2S.js +1 -0
  169. package/dist/graph/swimlanesDiagram-OMPLPG4O-ZYULLJSU.js +8 -0
  170. package/dist/graph/timeline-definition-SEUHKTQE-ZQSMIVAS.js +120 -0
  171. package/dist/graph/treeView-D4JQ5SDB-42S7U73N.js +1 -0
  172. package/dist/graph/treemap-SAJKECNS-RUBYQ7XF.js +1 -0
  173. package/dist/graph/usecaseDiagram-AFA6YXN4-57RDRYXF.js +370 -0
  174. package/dist/graph/vennDiagram-NNMJR3RB-5C3LVAV6.js +34 -0
  175. package/dist/graph/wardley-7MLQ67FV-NV5HXTTC.js +1 -0
  176. package/dist/graph/wardleyDiagram-S7YFUSEH-6D5BKXHM.js +78 -0
  177. package/dist/graph/xychartDiagram-GGNKY7IX-6ET3ZM67.js +7 -0
  178. package/dist/mcp.js +54 -12
  179. package/dist/plugins/index.d.ts +1 -0
  180. package/dist/plugins/transport.d.ts +22 -0
  181. package/dist/plugins/transport.js +1 -0
  182. package/dist/plugins.global.js +95 -0
  183. package/dist/subformats.global.js +21 -0
  184. package/dist/ui.global.js +80 -60
  185. package/dist/viewer/build-plugins.d.ts +7 -0
  186. package/dist/viewer/build-plugins.js +70 -0
  187. package/dist/viewer/build.d.ts +11 -0
  188. package/dist/viewer/build.js +52 -11
  189. package/dist/viewer/code-file.js +7 -2
  190. package/dist/viewer/editor-tools.d.ts +7 -7
  191. package/dist/viewer/editor-tools.js +36 -5
  192. package/dist/viewer/figure-preview.d.ts +4 -0
  193. package/dist/viewer/figure-preview.js +54 -0
  194. package/dist/viewer/font-picker.js +5 -1
  195. package/dist/viewer/git-diff.d.ts +3 -0
  196. package/dist/viewer/git-diff.js +47 -0
  197. package/dist/viewer/hmr.js +8 -4
  198. package/dist/viewer/i18n.js +7 -5
  199. package/dist/viewer/language-picker.d.ts +2 -2
  200. package/dist/viewer/language-picker.js +26 -9
  201. package/dist/viewer/lazy-preview.d.ts +2 -0
  202. package/dist/viewer/lazy-preview.js +43 -0
  203. package/dist/viewer/locales/eng.json +95 -10
  204. package/dist/viewer/locales/jpn.json +96 -11
  205. package/dist/viewer/locales/zho.json +96 -11
  206. package/dist/viewer/nav-focus.js +8 -1
  207. package/dist/viewer/nav-update.d.ts +2 -0
  208. package/dist/viewer/nav-update.js +117 -0
  209. package/dist/viewer/plugin-blocks.js +1 -1
  210. package/dist/viewer/plugin-style.d.ts +1 -0
  211. package/dist/viewer/plugin-style.js +82 -0
  212. package/dist/viewer/plugins.js +1 -1
  213. package/dist/viewer/resize.d.ts +0 -2
  214. package/dist/viewer/resize.js +2 -98
  215. package/dist/viewer/resource-library.d.ts +11 -9
  216. package/dist/viewer/resource-library.js +181 -31
  217. package/dist/viewer/search.d.ts +4 -2
  218. package/dist/viewer/search.js +252 -53
  219. package/dist/viewer/serve.d.ts +11 -5
  220. package/dist/viewer/serve.js +913 -295
  221. package/dist/viewer/site-icon.js +13 -6
  222. package/dist/viewer/site-title.js +15 -2
  223. package/dist/viewer/textfile.d.ts +5 -0
  224. package/dist/viewer/textfile.js +34 -2
  225. package/dist/viewer/theme-picker.d.ts +2 -0
  226. package/dist/viewer/theme-picker.js +24 -8
  227. package/dist/viewer/workspace.d.ts +2 -0
  228. package/dist/viewer/workspace.js +46 -1
  229. package/package.json +27 -10
  230. package/dist/compiler/bundle.d.ts +0 -2
  231. package/dist/compiler/bundle.js +0 -100
@@ -18,22 +18,25 @@ import { defaultFilePath, docIconFile, MAX_FILE_UPLOAD_BYTES, parseFileLayout, d
18
18
  import { createHash } from "node:crypto";
19
19
  import { existsSync, mkdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
20
20
  import { createServer } from "node:http";
21
- import { dirname, join, resolve } from "node:path";
21
+ import { basename, dirname, join, resolve } from "node:path";
22
22
  import { fileURLToPath } from "node:url";
23
23
  import { parseContentSource } from "../compiler/code-blocks.js";
24
24
  import { compileDraft, createCompiler, } from "../compiler/compile.js";
25
25
  import { figureName } from "../compiler/figures.js";
26
26
  import { ICONS_DIR, squareSvg } from "../compiler/icons.js";
27
+ import { ignoredFiles, withIgnoredFilesCache } from "../compiler/ignored-files.js";
27
28
  import { contentLanguageCode, contentLanguages, isContentLanguage, webLanguage, } from "../compiler/language-codes.js";
28
29
  import { setDocTranslation, siteContentLanguages, translationFile, translationFiles, } from "../compiler/locales.js";
29
30
  import { readManifest, writeManifest } from "../compiler/manifest.js";
30
31
  import { assembleDoc, createDocOps, isOpError } from "../compiler/ops.js";
32
+ import { subformatResponse, validateSubformatFile } from "../compiler/subformats.js";
31
33
  import { walkBlocks } from "../core/blocks.js";
32
- import { docIdOfFile } from "../core/content-metadata.js";
34
+ import { selectCodeGrammars, subformatCodeGrammars } from "../core/code-grammars.js";
35
+ import { docIdOfFile, flattenTree } from "../core/content-metadata.js";
33
36
  import { MAX_EXTENSION_BYTES } from "../core/extension-package.js";
34
37
  import { figureFrameHtml, mountFigureFrames } from "../core/figure-frame.js";
35
38
  import { blocksHtml, docHtml, escapeHtml, termsHtml } from "../core/html.js";
36
- import { PLUGINS_ICON } from "../core/icons.js";
39
+ import { FOLDER_ICON_PATH, PLUGINS_ICON } from "../core/icons.js";
37
40
  import { DEFAULT_LANG, isLangTag, resolveLanguage, } from "../core/language.js";
38
41
  import { defaultPreviewSettings, parsePreviewSettings, } from "../core/previewers.js";
39
42
  import { ancestorsOf, childrenOf, docPath, resolveDocPath } from "../core/routing.js";
@@ -52,26 +55,30 @@ import { mountBundleNetwork } from "./bundle-network.js";
52
55
  import { codeFileResponse } from "./code-file.js";
53
56
  import { isLocalToolRequest, runCodeTool, validateCodeTools, validateTextfileCode, } from "./editor-tools.js";
54
57
  import { createExtensionManager, EXTENSIONS_DIR } from "./extensions.js";
58
+ import { deferredFigureHtml, mountFigurePreviews } from "./figure-preview.js";
55
59
  import { fileReferences } from "./file-references.js";
56
60
  import { mountFontPickers } from "./font-picker.js";
57
61
  import { createFontSettings } from "./font-settings.js";
58
62
  import { fontCss, readFont } from "./fonts.js";
59
63
  import { createGitHandler, validateGitOrigin } from "./git.js";
60
- import { gitBaseBody, gitBaseText } from "./git-diff.js";
64
+ import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
61
65
  import { createHmrHub, HMR_PATH, hmrClientScript, watchProject } from "./hmr.js";
62
66
  import { translate } from "./i18n.js";
63
67
  import { DEFAULT_SITE_LANGUAGES, loadSiteLanguages } from "./languages.js";
68
+ import { loadPreviewScript } from "./lazy-preview.js";
64
69
  import { focusNavTree } from "./nav-focus.js";
70
+ import { updateNav } from "./nav-update.js";
65
71
  import { loadViewerPlugins } from "./plugin-config.js";
72
+ import { PLUGIN_BLOCK_CSS } from "./plugin-style.js";
66
73
  import { createPluginHandler } from "./plugins.js";
67
- import { mountPanelResize, mountToolsResize } from "./resize.js";
74
+ import { mountPanelResize } from "./resize.js";
68
75
  import { resourceIndex, resourceLibraryHtml, resourceTabs } from "./resource-library.js";
69
76
  import { mountSearch, SEARCH_LABELS, searchIndex, searchSections } from "./search.js";
70
77
  import { siteIconResponse } from "./site-icon.js";
71
78
  import { siteTitleResponse } from "./site-title.js";
72
79
  import { previewTextfiles, textfileResponse } from "./textfile.js";
73
- import { mountThemePickers } from "./theme-picker.js";
74
- import { readWorkspaceSource } from "./workspace.js";
80
+ import { initializeThemes, mountThemePickers } from "./theme-picker.js";
81
+ import { readWorkspaceSource, sourceFileBase } from "./workspace.js";
75
82
  // pkgRoot = the viewer itself (src/ for the client bundles). docsRoot = the docs folder that
76
83
  // follows the layout convention (content/ figures/).
77
84
  const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
@@ -79,6 +86,7 @@ const root = resolve(process.env.DOCS_ROOT ?? process.cwd());
79
86
  const CONTENT_PREFIX = "content/";
80
87
  const toEntry = (doc, source) => ({
81
88
  id: doc.id,
89
+ ...(doc.subformat ? { subformat: doc.subformat } : {}),
82
90
  ...(doc.parent == null ? {} : { parent: doc.parent }),
83
91
  file: `${doc.id}.md`,
84
92
  sourceFile: doc.file,
@@ -94,6 +102,7 @@ const toEntry = (doc, source) => ({
94
102
  figureRefs: doc.refs.figures,
95
103
  termRefs: doc.refs.terms,
96
104
  terms: source.terms,
105
+ referencedFiles: source.referencedFiles,
97
106
  });
98
107
  // Recompile source files on every request. The compiler's cache
99
108
  // skips re-parsing files unchanged on disk, so it stays cheap even when called on every keystroke
@@ -103,13 +112,22 @@ let siteLanguages = DEFAULT_SITE_LANGUAGES;
103
112
  let compiler = createCompiler(root);
104
113
  const ops = createDocOps(root);
105
114
  /** Compile result → viewer Site (shared by the server's per-request path and one-off publish). */
106
- export const siteFrom = ({ title, icon, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, }, languages = DEFAULT_SITE_LANGUAGES.languages) => {
115
+ export const siteFrom = ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages, code = {}) => {
107
116
  return {
108
117
  previews,
118
+ subformats,
119
+ codeLanguages: [
120
+ ...new Set([
121
+ ...(code.codeLanguages ?? CODE_LANGS),
122
+ ...(subformats ?? []).map(({ ext }) => `.${ext}`),
123
+ ]),
124
+ ],
125
+ codeGrammars: subformatCodeGrammars(code.codeGrammars ?? [], subformats),
109
126
  ...(contentLanguages ? { contentLanguages } : {}),
110
127
  ...(themes ? { themes } : {}),
111
128
  ...(title === undefined ? {} : { title }),
112
129
  ...(icon === undefined ? {} : { icon }),
130
+ ...(iconVariants === undefined ? {} : { iconVariants }),
113
131
  entries: docs.flatMap((doc) => {
114
132
  const source = sources.get(doc.file);
115
133
  return source ? [toEntry(doc, source)] : [];
@@ -143,12 +161,14 @@ let workspaceSource;
143
161
  let applicationPreviews = defaultPreviewSettings();
144
162
  let watchTextfiles;
145
163
  const watchEntryTextfiles = (entries) => {
146
- watchTextfiles?.(entries.flatMap((entry) => [
164
+ watchTextfiles?.(entries
165
+ .filter((entry) => !entry.subformat)
166
+ .flatMap((entry) => [
147
167
  entry.sourceFile ?? CONTENT_PREFIX + entry.file,
148
- ...fileReferences(entry.body).map((reference) => reference.file),
168
+ ...(entry.referencedFiles ?? []),
149
169
  ]));
150
170
  };
151
- const loadSite = (locale) => {
171
+ const loadSite = (locale) => withIgnoredFilesCache(() => {
152
172
  const previews = applicationPreviews;
153
173
  const manifest = readManifest(root);
154
174
  const source = contentLanguageCode(manifest.defaultLang ?? DEFAULT_LANG);
@@ -158,7 +178,7 @@ const loadSite = (locale) => {
158
178
  selected = localeCompilers.get(locale) ?? createCompiler(root, { locale, previews });
159
179
  localeCompilers.set(locale, selected);
160
180
  }
161
- const site = siteFrom(selected.compile(), siteLanguages.languages);
181
+ const site = siteFrom(selected.compile(), siteLanguages.languages, siteLanguages);
162
182
  const sourceLanguage = contentLanguageCode(site.defaultLang);
163
183
  for (const entry of site.entries) {
164
184
  entry.translatedLanguages = [sourceLanguage];
@@ -177,25 +197,29 @@ const loadSite = (locale) => {
177
197
  site.errors.push(String(error));
178
198
  }
179
199
  watchEntryTextfiles(site.entries);
180
- const siteIconFile = manifest.icon;
181
- if (siteIconFile)
182
- watchTextfiles?.([siteIconFile]);
200
+ watchTextfiles?.([manifest.icon, ...Object.values(manifest.themeIcons ?? {})].filter((file) => !!file));
201
+ const workspace = workspaceSource ?? readWorkspaceSource(root);
202
+ const subformats = site.entries.flatMap((entry) => entry.subformat ? [entry.subformat] : []);
203
+ if (workspace?.protocol === "git" && subformats.length)
204
+ setSubformatChanges(root, subformats);
183
205
  return {
184
206
  ...site,
207
+ ctx: { ...site.ctx, figurePreview: deferredFigureHtml },
185
208
  fonts: loadProjectFonts(root),
186
- workspace: workspaceSource ?? readWorkspaceSource(root),
209
+ workspace,
210
+ sourceBase: sourceFileBase(root),
187
211
  filePaths: manifest.errors.length
188
212
  ? undefined
189
213
  : filesSnapshot(root).files.map((file) => file.path),
190
- codeLanguages: siteLanguages.codeLanguages,
191
- codeGrammars: siteLanguages.codeGrammars,
192
214
  contentLanguage: locale,
193
215
  };
194
- };
216
+ });
195
217
  const draftContext = (site) => ({
196
218
  previews: site.previews,
197
219
  root,
198
- docs: site.entries.map((e) => ({
220
+ docs: site.entries
221
+ .filter((e) => !e.subformat)
222
+ .map((e) => ({
199
223
  id: e.id,
200
224
  ...(e.parent == null ? {} : { parent: e.parent }),
201
225
  file: e.sourceFile ?? CONTENT_PREFIX + e.file,
@@ -284,12 +308,24 @@ const renderSignature = (site, entry) => JSON.stringify([site.ctx.terms, site.er
284
308
  const entryHtmlCache = new Map();
285
309
  /** Renders only the requested doc, not every doc in site.entries. */
286
310
  export const renderEntryHtml = (site, entry) => {
311
+ if (entry.subformat)
312
+ return {
313
+ html: `<article class="res-page resource-library subformat-page">${resourceLibraryHtml({
314
+ codeblocks: [],
315
+ urls: [],
316
+ urlPreviews: [],
317
+ subformats: [entry.subformat],
318
+ errors: [...site.errors, ...entry.errors],
319
+ }, "subformats", docDisplayName(entry.frontmatter, entry.id))}</article>`,
320
+ errors: [...site.errors, ...entry.errors],
321
+ };
287
322
  const sig = renderSignature(site, entry);
288
323
  const cached = entryHtmlCache.get(entry.file);
289
324
  if (cached &&
290
325
  cached.blocks === entry.blocks &&
291
326
  cached.sig === sig &&
292
- cached.figures === site.ctx.figures) {
327
+ cached.figures === site.ctx.figures &&
328
+ cached.figurePreview === site.ctx.figurePreview) {
293
329
  return cached.value;
294
330
  }
295
331
  const value = {
@@ -300,6 +336,7 @@ export const renderEntryHtml = (site, entry) => {
300
336
  blocks: entry.blocks,
301
337
  sig,
302
338
  figures: site.ctx.figures,
339
+ figurePreview: site.ctx.figurePreview,
303
340
  value,
304
341
  });
305
342
  return value;
@@ -357,12 +394,15 @@ export const isExternallyModified = (baseRaw, currentRaw) => typeof baseRaw ===
357
394
  */
358
395
  export const resolveContentFile = (rel) => {
359
396
  const id = typeof rel === "string" ? docIdOfFile(rel) : undefined;
360
- return id == null
397
+ if (flattenTree(readManifest(root).tree).some((node) => node.id === id && node.subformat))
398
+ return undefined;
399
+ const file = id == null ? undefined : sourceDocFile(id, readManifest(root).files);
400
+ return id == null || !file || ignoredFiles(root, [file]).has(file)
361
401
  ? undefined
362
402
  : {
363
403
  id,
364
404
  name: `${id}.md`,
365
- abs: textfilePath(root, sourceDocFile(id, readManifest(root).files)),
405
+ abs: textfilePath(root, file),
366
406
  };
367
407
  };
368
408
  // Default palette — resolves the figures' var(--doc-*) and color-mix() following the theme. The
@@ -382,7 +422,7 @@ const LIGHT_C = `
382
422
  color-scheme: light;
383
423
  --c-bg0:#ffffff; --c-bg1:#f5f7f9; --c-surface:#fbfcfd; --c-raised:#e9edf2;
384
424
  --c-line:#d5dae0; --c-line-soft:#e4e8ec;
385
- --c-fg:#1a1e23; --c-fg-muted:#5a636c; --c-fg-faint:#7b848e; --fw-body:300;
425
+ --c-fg:#1a1e23; --c-fg-muted:#5a636c; --c-fg-faint:#687079; --fw-body:300;
386
426
  --c-accent:#c24800; --c-ok:#2f7d4f; --c-danger:#b23c31; --c-warn:#8a6516; --c-info:#3a6ea5;
387
427
  --c-shadow:rgba(15,23,32,.14);
388
428
  --doc-fg-4:#9099a8; --doc-accent-2:#0277bd; --doc-accent-fg:#ffffff;
@@ -405,13 +445,15 @@ const CHEVRON_ICON = icon('<path d="M8 5.5 12.5 10 8 14.5"/>', 14);
405
445
  const GLOBE_ICON = icon('<circle cx="10" cy="10" r="7"/><ellipse cx="10" cy="10" rx="3" ry="7"/><path d="M3 10h14"/>');
406
446
  const BOX_ICON = icon('<path d="M3.5 6.5 10 3l6.5 3.5v7L10 17l-6.5-3.5v-7Z"/><path d="M3.5 6.5 10 10l6.5-3.5M10 10v7"/>');
407
447
  const STATICS_ICON = icon('<path d="M3 3v14h14M7 13V9m4 4V5m4 8V7"/>');
448
+ const SUBFORMATS_ICON = icon('<rect x="3" y="3" width="14" height="14" rx="1"/><rect x="6" y="8" width="6" height="6" rx="1"/>');
408
449
  const GIT_ICON = icon('<path d="M5.5 6.5v7M14.5 6.5v1a4 4 0 0 1-4 4h-5"/><circle cx="5.5" cy="4.5" r="2"/><circle cx="5.5" cy="15.5" r="2"/><circle cx="14.5" cy="4.5" r="2"/>');
409
450
  const STORAGE_ICON = icon('<path d="m3 12 2-8h10l2 8"/><rect x="3" y="12" width="14" height="5" rx="1"/><path d="M13 14.5h1"/>');
451
+ const FOLDER_ICON = icon(`<path d="${FOLDER_ICON_PATH}"/>`);
410
452
  const workspaceName = (site) => site.workspace?.protocol === "storage" ? workspaceLabel(site.workspace) : "Files";
411
453
  const workspaceText = (site) => `<span${site.workspace?.protocol === "storage" ? "" : ' data-i18n="Files"'}>${escapeHtml(workspaceName(site))}</span>`;
412
454
  const workspaceIcon = (site) => {
413
455
  if (site.workspace?.protocol === "git")
414
- return icon('<path d="M2 5h6l2 2h8v10H2Z"/>');
456
+ return FOLDER_ICON;
415
457
  return site.workspace?.icon
416
458
  ? svgImg(site.workspace.icon, "nav-icon workspace-icon")
417
459
  : STORAGE_ICON;
@@ -437,20 +479,23 @@ const THEME_ICONS = {
437
479
  light: icon('<circle cx="10" cy="10" r="3.4"/><path d="M10 2.6v1.8M10 15.6v1.8M2.6 10h1.8M15.6 10h1.8M4.8 4.8l1.3 1.3M13.9 13.9l1.3 1.3M15.2 4.8l-1.3 1.3M6.1 13.9l-1.3 1.3"/>'),
438
480
  dark: icon('<path d="M15.5 12.4A6.2 6.2 0 0 1 7.6 4.5a6.5 6.5 0 1 0 7.9 7.9Z"/>'),
439
481
  };
482
+ const FONT_ICON = icon('<path d="M2.5 15 7 4l4.5 11M4 11h6M13 10.5c0-2.5 5-2.5 5 0V15M18 12h-2.5c-3.5 0-3.5 4 0 3L18 13.5"/>');
483
+ const SELECT_ICON = icon('<path d="m5 7 5 5 5-5"/>', 12);
440
484
  const fontButton = (target) => {
441
485
  const label = target === "editor" ? "Editor font" : "Viewer font";
442
- return `<button class="pbtn font-control" type="button" data-font-picker="${target}" aria-haspopup="menu" aria-expanded="false" aria-label="${label}" title="${label}" disabled>${icon('<path d="M2.5 15 7 4l4.5 11M4 11h6M13 10.5c0-2.5 5-2.5 5 0V15M18 12h-2.5c-3.5 0-3.5 4 0 3L18 13.5"/>')}</button>`;
486
+ return `<button class="pbtn font-control${target === "editor" ? " setting-picker" : ""}" type="button" data-font-picker="${target}" aria-haspopup="menu" aria-expanded="false" aria-label="${label}" title="${label}" disabled>${target === "editor" ? `<span data-picker-value></span>${SELECT_ICON}` : FONT_ICON}</button>`;
443
487
  };
444
488
  const CSS = `
445
489
  :root { ${DARK_C} ${DOC_FROM_C} --doc-mono: ${MONO_FONT}; --font-sans: ${SANS_FONT}; }
490
+ html[data-theme] iframe[data-doc-figure-frame]:not([data-theme-ready]) { visibility: hidden; }
446
491
  @media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { ${LIGHT_C} } }
447
492
  :root[data-theme="light"] { ${LIGHT_C} }
448
- body.edit :is(#sidebar, #panel, .resources-pane), .preview-pane[data-theme], .theme-picker[data-theme] { ${DARK_C} ${DOC_FROM_C} }
493
+ body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast), .preview-pane[data-theme], .theme-picker[data-theme] { ${DARK_C} ${DOC_FROM_C} }
449
494
  @media (prefers-color-scheme: light) {
450
- :root:not([data-editor-theme="dark"]) body.edit :is(#sidebar, #panel, .resources-pane),
495
+ :root:not([data-editor-theme="dark"]) body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast),
451
496
  :is(.preview-pane, .theme-picker)[data-theme="auto"] { ${LIGHT_C} }
452
497
  }
453
- :root[data-editor-theme="light"] body.edit :is(#sidebar, #panel, .resources-pane),
498
+ :root[data-editor-theme="light"] body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast),
454
499
  :is(.preview-pane, .theme-picker)[data-theme="light"] { ${LIGHT_C} }
455
500
  .preview-pane { background: var(--c-bg0); color: var(--c-fg); }
456
501
  .theme-picker { position: fixed; margin: 0; padding: 5px; width: 148px; border: 1px solid var(--c-line);
@@ -469,8 +514,9 @@ body.edit :is(#sidebar, #panel, .resources-pane), .preview-pane[data-theme], .th
469
514
  main { --doc-mono: var(--viewer-font, ${MONO_FONT}); }
470
515
  .resources-pane { --doc-mono: var(--editor-font, ${MONO_FONT}); background: var(--c-bg1); color: var(--c-fg); font-family: var(--doc-mono); }
471
516
  .page-actions, .pane-actions { position: sticky; display: flex; align-items: center; justify-content: flex-end;
472
- gap: 2px; height: 36px; padding: 0 24px; border-bottom: 1px solid var(--c-line); background: var(--c-bg0); z-index: 5; }
473
- .page-actions { top: 0; margin: -20px -24px 20px; }
517
+ gap: 2px; height: 36px; padding: 0 24px; pointer-events: none; z-index: 5; }
518
+ :is(.page-actions, .pane-actions) > .pbtn { pointer-events: auto; background: var(--c-bg0); }
519
+ .page-actions { top: 0; margin: -20px -24px -36px; }
474
520
  .pbtn { flex: none; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
475
521
  padding: 0; color: var(--c-fg-faint); background: none; border: none; border-radius: 5px; cursor: pointer;
476
522
  transition: color 120ms ease, background 120ms ease; }
@@ -495,44 +541,78 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
495
541
  :focus-visible { outline: 1px solid var(--c-accent); outline-offset: 1px; }
496
542
 
497
543
  #doc-search { position: fixed; top: 12px; left: 0; right: 0; z-index: 20;
498
- width: min(600px, calc(100vw - 24px)); min-height: 56px; max-height: min(420px, calc(100dvh - 24px)); margin: 0 auto;
499
- padding: 0 10px 10px; color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 82%, transparent);
544
+ width: min(420px, calc(100vw - 24px)); min-height: 44px; max-height: min(420px, calc(100dvh - 24px)); margin: 0 auto;
545
+ padding: 0 8px 6px; color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 82%, transparent);
500
546
  border: 1px solid color-mix(in srgb, var(--c-fg-muted) 55%, transparent);
501
547
  backdrop-filter: blur(16px); border-radius: 8px; box-shadow: 0 8px 24px #0003; overflow: hidden; }
502
548
  #doc-search[open] { display: flex; flex-direction: column; }
503
549
  #doc-search :focus-visible { outline-color: var(--c-fg-muted); }
504
- .search-head { display: flex; flex: none; align-items: center; gap: 10px; padding: 8px;
550
+ .search-grip { position: relative; flex: none; height: 8px; margin: 0 -8px; cursor: grab; touch-action: none; }
551
+ .search-grip:active { cursor: grabbing; }
552
+ .search-grip::after { content: ""; position: absolute; top: 50%; left: 50%; width: 36px; height: 4px;
553
+ margin: -2px 0 0 -18px; border-radius: 2px; background: var(--c-line); }
554
+ .search-grip:hover::after, .search-grip:focus-visible::after { background: var(--c-fg-muted); }
555
+ .search-head { display: flex; flex: none; align-items: center; gap: 8px; padding: 0 0 0 4px;
505
556
  color: var(--c-fg-muted); }
506
557
  .search-head svg { flex: none; }
507
- #doc-search.search-filled .search-head svg { display: none; }
508
- #doc-search-input { width: 100%; min-width: 0; padding: 4px 0; font: inherit; font-size: 15px;
558
+ #doc-search.search-filled .search-head > svg { display: none; }
559
+ .search-head button, .search-copy { display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
560
+ color: var(--c-fg-muted); background: none; border: 0; border-radius: 4px; cursor: pointer; }
561
+ .search-head button { flex: none; }
562
+ .search-head button + button { margin-left: -8px; }
563
+ .search-head button:hover, .search-copy:hover { color: var(--c-fg); background: color-mix(in srgb, var(--c-fg-muted) 18%, transparent); }
564
+ #doc-search-input { width: 100%; min-width: 0; padding: 3px 0; font: inherit; font-size: 14px;
509
565
  color: var(--c-fg); background: none; border: 0; outline: none; }
510
566
  #doc-search-input::-webkit-search-cancel-button { appearance: none; }
511
- .search-status { padding: 8px 16px; color: var(--c-fg-muted); font-size: 12px; }
567
+ .search-status { padding: 6px 8px; color: var(--c-fg-muted); font-size: 12px; }
512
568
  .search-status:empty { display: none; }
513
569
  .search-count { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
514
570
  clip-path: inset(50%); white-space: nowrap; }
515
- #doc-search-results { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
571
+ #doc-search-results { position: relative; z-index: 1; overflow-y: auto; overscroll-behavior: contain;
572
+ scrollbar-gutter: stable; margin-right: -8px; padding-right: 8px;
573
+ min-height: 0; display: flex; flex-direction: column; gap: 8px; }
574
+ #doc-search-results:not(:empty) { margin-top: 6px; }
516
575
  #doc-search-results a { display: flex; flex: none; flex-direction: column; gap: 6px;
517
576
  border: 1px solid var(--c-line); border-radius: 5px; color: var(--c-fg); text-decoration: none;
518
577
  background: color-mix(in srgb, var(--c-bg0) 50%, transparent); overflow-wrap: anywhere; }
519
578
  #doc-search-results a:hover, #doc-search-results a[aria-selected="true"] { border-color: var(--c-fg-muted); }
520
- .search-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px;
579
+ #doc-search-results mark { color: inherit; background: color-mix(in srgb, var(--c-accent) 32%, transparent);
580
+ border-radius: 2px; }
581
+ .search-meta { display: flex; align-items: center; gap: 6px;
521
582
  padding: 5px 10px; border-bottom: 1px solid var(--c-line); color: var(--c-fg-muted); }
522
- .search-path { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
583
+ .search-kind { display: grid; flex: none; }
584
+ .search-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
523
585
  #doc-search-results strong { margin: 2px 10px 0; font-weight: 500; }
524
- #doc-search-results span { margin: 0 10px 10px; color: var(--c-fg-muted); }
525
- .search-grip { position: absolute; top: 8px; bottom: 18px; width: 10px; cursor: grab; touch-action: none; }
526
- .search-grip-left { left: 0; }
527
- .search-grip-right { right: 0; }
528
- .search-grip:active { cursor: grabbing; }
529
- .search-grip::after { content: ""; position: absolute; top: 35%; bottom: 35%; left: 4px;
530
- width: 2px; border-radius: 2px; background: var(--c-line); }
531
- .search-grip:hover::after, .search-grip:focus-visible::after { background: var(--c-fg-muted); }
532
- .search-resize { position: absolute; bottom: 0; right: 0; width: 18px; height: 18px;
533
- cursor: nwse-resize; touch-action: none; }
534
- .search-resize::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px;
535
- border-right: 1px solid var(--c-fg-muted); border-bottom: 1px solid var(--c-fg-muted); }
586
+ #doc-search-results strong:last-child { margin-bottom: 10px; }
587
+ .search-snippet { margin: 0 10px 10px; color: var(--c-fg-muted); }
588
+ .search-hit { position: relative; flex: none; }
589
+ .search-name + .search-name { margin-top: -4px; }
590
+ .search-name .search-meta { padding-right: 40px; border-bottom: 0; }
591
+ .search-name .search-path { color: var(--c-fg); }
592
+ .search-copy { position: absolute; top: 50%; right: 6px; margin-top: -12px; }
593
+ .search-flash { animation: search-flash 2.6s ease-out; }
594
+ @keyframes search-flash {
595
+ 0%, 35% { background-color: color-mix(in srgb, var(--c-accent) 18%, transparent);
596
+ box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-accent) 18%, transparent); }
597
+ 100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; } }
598
+ /* Docked, the panel is a right sidebar like #panel. */
599
+ #doc-search.search-docked { position: sticky; top: 0; left: auto; right: auto; z-index: auto; flex: 0 1 auto;
600
+ align-self: flex-start; width: 320px; min-width: 240px; height: 100vh; min-height: 0; max-height: none; margin: 0;
601
+ padding: 8px 10px 10px; border: 0; border-left: 1px solid var(--c-line); border-radius: 0;
602
+ background: var(--c-bg1); box-shadow: none; backdrop-filter: none; }
603
+ .search-docked #doc-search-results { margin-right: -10px; padding-right: 10px; }
604
+ /* Keep the preview readable; the editor panel gives up width before the search sidebar does. */
605
+ body:has(#doc-search.search-docked[open]) main { min-width: 240px; }
606
+ body:has(#doc-search.search-docked[open]) #panel { flex-shrink: 100; min-width: 240px; }
607
+ .search-docked :is(.search-grip, .search-resize-x, .search-resize-y, .search-resize-xy),
608
+ #doc-search:not(.search-docked) .search-resize-w { display: none; }
609
+ /* Invisible edges: the right and bottom borders resize the window. */
610
+ .search-resize { position: absolute; touch-action: none; }
611
+ .search-resize:focus-visible { outline-offset: -2px; }
612
+ .search-resize-x { top: 0; right: 0; bottom: 0; width: 6px; cursor: ew-resize; }
613
+ .search-resize-y { left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
614
+ .search-resize-xy { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; }
615
+ .search-resize-w { top: 0; left: 0; bottom: 0; width: 6px; cursor: ew-resize; }
536
616
 
537
617
  /* ── sidebar ── */
538
618
  #sidebar { width: var(--sidebar-width, 260px); height: 100vh; position: sticky; top: 0; flex: none;
@@ -541,11 +621,16 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
541
621
  body.sidebar-closed #sidebar { width: 52px; }
542
622
  body.sidebar-closed #sidebar-resize { display: none; }
543
623
  .panel-resize { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 6;
544
- touch-action: none; transition: background 120ms ease; }
624
+ touch-action: none; }
625
+ .panel-resize::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; border-radius: 1px;
626
+ transition: background 120ms ease; }
545
627
  #sidebar-resize { right: 0; }
628
+ #sidebar-resize::before { right: -1px; }
546
629
  #resize { left: 0; }
547
- .panel-resize:hover, .panel-resize:focus-visible, .panel-resize.drag {
630
+ #resize::before { left: -1px; }
631
+ .panel-resize:hover::before, .panel-resize:focus-visible::before, .panel-resize.drag::before {
548
632
  background: color-mix(in srgb, var(--c-accent) 60%, transparent); }
633
+ .panel-resize.drag { outline: none; }
549
634
  body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
550
635
  body.sidebar-closed .site-title { display: none; }
551
636
  #sidebar-head { position: relative; flex: none; display: flex; align-items: center; min-width: 0; min-height: 36px;
@@ -554,8 +639,9 @@ body.sidebar-closed .site-title { display: none; }
554
639
  background: transparent; border: none; color: var(--c-fg-muted); cursor: pointer; }
555
640
  #sidebar-toggle:hover { color: var(--c-fg); }
556
641
  #site-icon-slot { position: relative; flex: none; width: 24px; height: 24px; margin: 0 8px 0 16px; color: var(--c-fg-muted); }
557
- #site-icon, #site-icon-slot > .nav-icon { display: block; width: 100%; height: 100%; object-fit: contain; }
558
- #site-icon[hidden], #site-icon-slot:has(#site-icon:not([hidden])) > .nav-icon { display: none; }
642
+ #site-icon, #site-icon-slot > .nav-icon, .site-icon-variants > img { display: block; width: 100%; height: 100%; object-fit: contain; }
643
+ .site-icon-variants, .site-icon-variants > span { display: contents; }
644
+ #site-icon[hidden], .site-icon-variants > [hidden], #site-icon-slot:has(#site-icon:not([hidden])) > .nav-icon { display: none; }
559
645
  body.sidebar-closed #site-icon-slot { margin: 0 auto; }
560
646
  body.sidebar-closed #sidebar-toggle { position: absolute; inset: 0; width: 100%; justify-content: center; padding: 0; }
561
647
  body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
@@ -574,6 +660,7 @@ body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
574
660
  .nav-link.cur { color: var(--c-fg); }
575
661
  .nav-link.cur::before { background: var(--c-accent); }
576
662
  .nav-icon { flex: none; }
663
+ .nav-row :is(svg.nav-icon, .doc-icon-frame) { translate: 0 1px; }
577
664
  .workspace-icon { width: 18px; height: 18px; object-fit: contain; }
578
665
  .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
579
666
  /* The doc tree. Top-level docs are .nav-link with an icon,
@@ -650,33 +737,37 @@ img.doc-icon { flex: none; width: 18px; height: 18px; object-fit: contain; }
650
737
  .nav-row > a.cur .doc-icon-frame > img, .nav-doc-row:has(> a.cur) > .nav-doc-icon .doc-icon-frame > img { visibility: hidden; }
651
738
  .nav-row > a.cur .doc-icon-frame::after, .nav-doc-row:has(> a.cur) > .nav-doc-icon .doc-icon-frame::after {
652
739
  content: ""; position: absolute; inset: 0; background: currentColor; mask: var(--doc-icon) center / contain no-repeat; }
653
- body.sidebar-closed #sidebar-content { display: block; overflow-y: auto; scrollbar-width: none; padding: 6px 0; }
654
- body.sidebar-closed #nav-groups { display: block; }
655
- body.sidebar-closed #nav-docs { scrollbar-width: none; }
656
- body.sidebar-closed #nav-groups :is(.nav-label, .nav-toc, .nav-tree-toggle, .nav-tree-spacer, .nav-placeholder, .new, .nav-delete, .files-upload-status, .files-drop-hint, .extensions-drop-hint, input, .nav-icon-clear),
657
- body.sidebar-closed #nav-status { display: none; }
658
- body.sidebar-closed #nav-groups .nav-tree { display: block; padding: 0; margin: 0; }
659
- body.sidebar-closed #nav-groups .nav-row { position: relative; padding: 0; gap: 0; min-height: 36px; }
660
- body.sidebar-closed #nav-groups .nav-row > a { width: 100%; height: 36px; padding: 0; justify-content: center; }
661
- body.sidebar-closed #nav-groups .nav-doc-icon { position: absolute; left: 16px; z-index: 1; pointer-events: none; }
662
- body.sidebar-closed #nav-groups .nav-row > a .nav-icon, body.sidebar-closed #nav-groups .nav-row > a .doc-icon-frame { margin: 0; width: 18px; height: 18px; }
663
- body.sidebar-closed #nav-groups :is(.nav-item, .nav-tree, .nav-row, a)::before,
664
- body.sidebar-closed #nav-groups :is(.nav-item, .nav-tree, .nav-row, a)::after { display: none; }
665
- body.sidebar-closed :is(#nav-files, #nav-git) { border: 0; border-top: 1px solid var(--c-line); border-radius: 0; margin: 6px 0 0; padding: 6px 0 0; overflow: visible; }
740
+ body.sidebar-closed :is(#sidebar-content, #nav-docs) { scrollbar-width: none; scrollbar-gutter: auto; }
741
+ body.sidebar-closed #nav-groups { --nav-rail: 8px; }
742
+ body.sidebar-closed #nav-groups .nav-label, body.sidebar-closed #nav-status { opacity: 0; pointer-events: none; }
743
+ body.sidebar-closed #nav-groups .nav-placeholder { visibility: hidden; pointer-events: none; }
744
+ body.sidebar-closed #nav-groups :is(.nav-tree-toggle, .nav-tree-spacer, .new, .nav-delete, .files-upload-status, .files-drop-hint, .extensions-drop-hint, input, .nav-icon-clear) { display: none; }
745
+ body.sidebar-closed #nav-groups .nav-tree { --nav-pad: 18px; --nav-line: 8px; }
746
+ body.sidebar-closed #nav-groups .nav-tree > .nav-item:not(.nav-ancestor) > .nav-row::before { width: calc(var(--nav-pad) - var(--nav-line) - 2px); }
747
+ body.sidebar-closed #nav-groups .nav-ancestor.open > .nav-row::after { top: 50%; }
748
+ body.sidebar-closed #nav-groups .nav-ancestor > .nav-tree > .nav-ancestor > .nav-row::before { height: 50%; }
749
+ body.sidebar-closed #nav-groups :is(.nav-row > .nav-link, .nav-tree-link) { padding-left: 0; padding-right: 0; gap: 0; }
750
+ body.sidebar-closed #nav-groups .nav-doc-row { padding-left: 0; gap: 0; }
751
+ body.sidebar-closed #nav-groups .nav-doc-row > a { padding-left: 0; }
752
+ body.sidebar-closed #nav-groups :is(.nav-doc-icon, .nav-row > a > .nav-icon, .nav-row > a > .doc-icon-frame) { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0; }
753
+ body.sidebar-closed #nav-groups .nav-doc-icon { z-index: 1; pointer-events: none; }
666
754
  body.edit #sidebar-content { display: flex; flex-direction: column; overflow: hidden; scrollbar-gutter: auto; }
667
755
  body.edit #nav-groups { flex: 1; min-height: 0; display: flex; flex-direction: column; }
668
756
  #nav-docs { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
669
- #nav-tools { position: relative; flex: none; display: flex; flex-direction: column; min-height: 0; height: var(--tools-height, 220px); margin: 10px 8px 4px; padding: 12px 4px 4px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-bg1); }
670
- #tools-resize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; z-index: 2; cursor: row-resize; touch-action: none; border-radius: 6px; }
671
- #tools-resize:hover, #tools-resize:focus-visible, body.resizing-tools #tools-resize { background: color-mix(in srgb, var(--c-fg-muted) 20%, transparent); }
672
- body.resizing-tools, body.resizing-tools * { cursor: row-resize !important; user-select: none !important; }
673
- .nav-tool-cards { flex: 1; min-height: 0; overflow: auto; }
757
+ #nav-tools { position: relative; flex: none; margin: 10px 8px 4px; padding: 12px 4px 4px; border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-bg1); }
758
+ .nav-tool-cards { max-height: max(36px, calc(50dvh - 40px)); overflow: auto; }
674
759
  #nav-tools .nav-resources { height: 36px; margin: 0; border: 0; border-radius: 4px; }
675
- .workspace-location { position: absolute; top: -1px; left: 10px; z-index: 3; transform: translateY(-50%); display: flex; align-items: center; gap: 4px; max-width: calc(100% - 32px); color: var(--c-fg-muted); font: 400 10px/16px var(--font-sans); cursor: default; }
676
- .workspace-location > .nav-icon { flex: none; width: 14px; height: 14px; padding: 1px; background: var(--c-bg1); }
677
- .workspace-address { min-width: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--c-bg1); }
678
- body.sidebar-closed #nav-tools { height: auto; margin: 4px 0; padding: 0; border: 0; }
679
- body.sidebar-closed :is(#tools-resize, .workspace-location) { display: none; }
760
+ .workspace-location { position: absolute; top: -1px; left: 10px; right: 6px; z-index: 3; transform: translateY(-50%); display: flex; align-items: center; gap: 4px; padding: 0 2px; color: var(--c-fg-muted); font: 600 10px/16px var(--font-sans); cursor: pointer; list-style: none; border-radius: 4px; }
761
+ #nav-tools:not([open]) { padding-bottom: 0; border-color: transparent; border-top-color: var(--c-line); border-radius: 0; }
762
+ .workspace-location::-webkit-details-marker { display: none; }
763
+ .workspace-location:hover { color: var(--c-fg); }
764
+ .workspace-location > .nav-icon { flex: none; width: 14px; height: 14px; background: var(--c-bg1); }
765
+ .workspace-location > .nav-icon:last-child { margin-left: auto; }
766
+ #nav-tools[open] > .workspace-location > .nav-icon:last-child { transform: rotate(90deg); }
767
+ .workspace-address { min-width: 0; padding: 0 2px; background: var(--c-bg1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
768
+ body.sidebar-closed #nav-tools { margin-left: 4px; margin-right: 4px; padding-left: 0; padding-right: 0; }
769
+ body.sidebar-closed .workspace-location { left: 2px; right: 2px; min-height: 16px; }
770
+ body.sidebar-closed .workspace-address { display: none; }
680
771
  .nav-resources { position: relative; container-type: size; flex: none; height: 42px; margin: 8px 8px 4px;
681
772
  border: 1px solid var(--c-line); border-radius: 8px; overflow: hidden;
682
773
  background: var(--c-bg1); font-family: var(--font-sans); }
@@ -704,6 +795,7 @@ body.files-over #nav-files { background: color-mix(in srgb, var(--c-accent) 10%,
704
795
 
705
796
  /* ── main (document body) ── */
706
797
  main { flex: 1; min-width: 0; padding: 20px 24px 50vh; }
798
+ main:not(.editor-workspace) { height: 100vh; overflow: auto; overscroll-behavior: contain; }
707
799
  article { max-width: 860px; margin: 0 auto; font-family: var(--viewer-font, system-ui, sans-serif); }
708
800
  .external-embed { margin: 18px 0; overflow-wrap: anywhere; }
709
801
  .plugin { position: relative; min-width: 0; border: 2px solid var(--doc-border); border-top: 0; }
@@ -738,15 +830,13 @@ article { max-width: 860px; margin: 0 auto; font-family: var(--viewer-font, syst
738
830
  [data-plugin-controls] button:disabled { opacity: .55; cursor: wait; }
739
831
  .plugin-content { padding: 12px; overflow: auto; }
740
832
  .plugin-content:empty { display: none; }
741
- .plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border); }
742
- .plugin-content th { background: var(--doc-bg-2); color: var(--doc-fg-2); font-size: 12px; font-weight: 600; }
743
- .plugin-content tr:last-child td { border-bottom: 0; }
744
833
  .plugin-resize { display: none; height: 12px; align-items: center; justify-content: center;
745
834
  cursor: row-resize; touch-action: none; user-select: none; }
746
835
  .plugin[data-ready="true"]:not(.collapsed) > .plugin-resize { display: flex; }
747
- .plugin-resize::before { content: ""; width: 32px; height: 3px; border-radius: 2px; background: var(--doc-border); }
836
+ .plugin-resize::before { content: ""; width: 32px; height: 2px; border-radius: 1px; background: var(--doc-border); }
748
837
  .plugin-resize:hover::before, .plugin-resize:focus-visible::before, .plugin-resize.drag::before { background: var(--doc-accent); }
749
838
  .plugin-resize:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: -2px; }
839
+ .plugin-resize.drag { outline: none; }
750
840
  body:has(.plugin-resize.drag), body:has(.plugin-resize.drag) * { cursor: row-resize !important; user-select: none !important; }
751
841
  body:has(.plugin-resize.drag) iframe { pointer-events: none; }
752
842
 
@@ -764,83 +854,7 @@ body:has(.plugin-resize.drag) iframe { pointer-events: none; }
764
854
  .plugin-heading img { display: block; width: 16px; height: 16px; }
765
855
  .plugin-heading-context { color: var(--doc-fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
766
856
  .plugin-heading button { font: inherit; color: var(--doc-fg-2); background: transparent; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
767
- .plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
768
- .plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }
769
- .plugin-blocks .plugin-block-heading { margin: 0 0 8px; padding: 0; border: 0; font: inherit; font-size: 17px; font-weight: 600; line-height: 1.4; color: var(--doc-fg); }
770
- .plugin-block-text { margin: 8px 0; white-space: pre-wrap; }
771
- .plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }
772
- .plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }
773
- .plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }
774
- .plugin-blocks > :last-child { margin-bottom: 0; }
775
- .plugin-blocks strong { font-weight: 600; }
776
- .plugin-blocks a { color: var(--doc-accent); text-underline-offset: 3px; }
777
- .plugin-blocks code { font-family: var(--doc-mono); }
778
- .plugin-block-context { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; margin: 6px 0; color: var(--doc-fg-3); font-size: 11px; }
779
- .plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }
780
- .plugin-block-fields > div { min-width: 0; }
781
- .plugin-block-fields dt { color: var(--doc-fg-3); font-size: 10px; margin-bottom: 1px; }
782
- .plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }
783
- .plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }
784
- .plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }
785
- .plugin-block-columns aside { border-left: 1px solid var(--doc-border); padding-left: 12px; }
786
- .plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }
787
- .plugin-block-section { border-top: 1px solid var(--doc-border); padding-top: 6px; margin: 10px 0 0; min-width: 0; }
788
- .plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2); padding: 4px 0; }
789
- .plugin-block-note { color: var(--doc-warn); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }
790
- .plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }
791
- .plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
792
- .plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }
793
- .plugin-blocks .plugin-block-code { font: 12px/1.65 var(--doc-mono); padding: 12px; margin: 10px 0; border: 1px solid var(--doc-border); border-radius: 6px; max-height: 400px; overflow: auto; white-space: pre-wrap; }
794
- .plugin-block-diff code > span { display: inline-block; min-width: 100%; }
795
- .plugin-block-diff [data-tone="success"] { color: var(--doc-ok); background: color-mix(in srgb, var(--doc-ok) 8%, transparent); }
796
- .plugin-block-diff [data-tone="danger"] { color: var(--doc-danger); background: color-mix(in srgb, var(--doc-danger) 8%, transparent); }
797
- .plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border); }
798
- .plugin-block-message:last-child { border-bottom: 0; }
799
- .plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
800
- .plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3); font-size: 10px; }
801
- .plugin-avatar { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 7px; color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 12%, var(--doc-bg)); font-size: 10px; }
802
- .plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }
803
- .plugin-message-actions svg { display: block; width: 14px; height: 14px; }
804
- .plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3); }
805
- .plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }
806
- .plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }
807
- .plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }
808
- .plugin-reactions button { font: inherit; padding: 2px 8px; border: 1px solid var(--doc-border); border-radius: 12px; background: transparent; color: var(--doc-fg-2); cursor: pointer; }
809
- .plugin-reactions [aria-pressed="true"] { border-color: var(--doc-accent); color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 8%, transparent); }
810
- .plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2); background: var(--doc-bg-2); }
811
- .plugin-badge[data-tone="accent"] { color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 10%, var(--doc-bg)); }
812
- .plugin-badge[data-tone="success"] { color: var(--doc-ok); background: color-mix(in srgb, var(--doc-ok) 10%, var(--doc-bg)); }
813
- .plugin-badge[data-tone="warning"] { color: var(--doc-warn); background: color-mix(in srgb, var(--doc-warn) 10%, var(--doc-bg)); }
814
- .plugin-badge[data-tone="danger"] { color: var(--doc-danger); background: color-mix(in srgb, var(--doc-danger) 10%, var(--doc-bg)); }
815
- .plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }
816
- .plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3); cursor: pointer; flex: none; }
817
- .plugin-copy svg { width: 14px; height: 14px; }
818
- .plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3); margin: 12px 0; }
819
- .plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent); }
820
- .plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
821
- .plugin-block-actions:has([data-block-composer]) { display: block; }
822
- .plugin-block-button { font: inherit; font-size: 12px; padding: 5px 10px; border: 1px solid var(--doc-border); border-radius: 5px; color: var(--doc-fg); background: transparent; cursor: pointer; }
823
- .plugin-block-button:hover { background: var(--doc-bg-2); }
824
- .plugin-block-button:disabled { opacity: .5; cursor: wait; }
825
- .plugin-action[aria-pressed="true"] { color: var(--doc-accent); background: var(--doc-bg-2); }
826
- .plugin-danger { color: var(--doc-danger); }
827
- .plugin [data-plugin-edit-trigger]:focus-visible, .plugin :is(button, summary, input, select, textarea):focus-visible, .plugin-block-table:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: 2px; }
828
- .plugin-editor { display: grid; gap: 6px; margin: 0; padding: 0; border: 0; font: inherit; font-size: 12px; line-height: 1.5; color: var(--doc-fg); background: var(--doc-bg); min-width: 0; }
829
- .plugin-editor label { display: grid; gap: 0; font-size: 0; }
830
- .plugin-editor :is(input, textarea, select) { box-sizing: border-box; width: 100%; min-width: 0; max-width: 100%; padding: 3px 6px; border: 1px solid var(--doc-border); border-radius: 4px; color: var(--doc-fg); background: var(--doc-bg); font: inherit; font-size: 12px; line-height: 1.5; }
831
- .plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }
832
- .plugin-editor .plugin-submit { background: var(--doc-accent); color: var(--doc-accent-fg); border-color: transparent; }
833
- .plugin-editor-notice { color: var(--doc-danger); font-size: 11px; }
834
- .plugin-editor-notice:empty { display: none; }
835
- .plugin [hidden] { display: none !important; }
836
- @container (max-width: 600px) {
837
- .plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }
838
- .plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border); padding: 14px 0 0; }
839
- .plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
840
- .plugin-heading-context { display: none; }
841
- .plugin-blocks .plugin-block-heading { font-size: 16px; }
842
- .plugin-message-body, .plugin-reactions { margin-left: 0; }
843
- }
857
+ ${PLUGIN_BLOCK_CSS}
844
858
 
845
859
  article, article * { font-weight: 400; }
846
860
  h1, h2, h3 { font-weight: 400; }
@@ -859,7 +873,7 @@ article h2 { font-size: 20px; margin-top: 24px; margin-bottom: 8px; border-botto
859
873
  article h3 { font-size: 16px; margin-top: 16px; margin-bottom: 4px; }
860
874
  h2[id], h3[id] { scroll-margin-top: 12px; }
861
875
  p { margin: 8px 0; }
862
- ul, ol { margin: 4px 0; line-height: 1.3; }
876
+ ul, ol { margin: 4px 0; }
863
877
  li { margin: 0; }
864
878
  li > ul, li > ol { margin: 0; }
865
879
  .fullname { opacity: .7; margin-bottom: 8px; }
@@ -912,6 +926,10 @@ pre code.code-foldable { display: block; padding-left: 18px; }
912
926
  .video-player [hidden] { display: none; }
913
927
  @container (max-width: 420px) { .video-controls .video-volume { display: none; } }
914
928
  .fig-frame { display: block; max-width: 100%; border: 0; background: transparent; }
929
+ .figure-placeholder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; min-height: 120px; padding: 20px; border: 1px solid var(--doc-border); background: var(--doc-bg-2); color: var(--doc-fg-2); overflow-wrap: anywhere; }
930
+ .figure-placeholder button { font: inherit; padding: 6px 12px; border: 1px solid var(--doc-border); border-radius: 4px; background: var(--doc-bg); color: var(--doc-fg); cursor: pointer; }
931
+ .figure-placeholder button:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: 2px; }
932
+ .figure-placeholder button:disabled { cursor: wait; }
915
933
  /* Code and file blocks share a border label; clicking it collapses the content. */
916
934
  .codeblk { position: relative; margin: 12px 0; border: 2px solid var(--doc-border); border-top: 0; }
917
935
  .codeblk > pre { margin: 0; background: transparent; padding: 8px 12px 6px; }
@@ -942,8 +960,10 @@ pre code.code-foldable { display: block; padding-left: 18px; }
942
960
  .textfile-unavailable { margin: 0; padding: 12px; color: var(--doc-fg-2); font-size: 12px; }
943
961
  .textfile.unavailable .codeblk-head { cursor: default; }
944
962
  .codeblk .codecopy.ok .ic-ok { display: block; color: var(--doc-ok); }
945
- table { border-collapse: collapse; font-size: 14px; }
963
+ table { border-collapse: collapse; }
946
964
  th, td { border: 1px solid color-mix(in srgb, currentColor 25%, transparent); padding: 4px 10px; }
965
+ th { text-align: start; }
966
+ article thead th { background: var(--doc-bg-2); color: var(--doc-fg-2); font-weight: 500; }
947
967
  .data-table { position: relative; min-width: 0; width: 100%; margin: 12px 0; }
948
968
  .data-table button { color: inherit; background: transparent; font: inherit; cursor: pointer; }
949
969
  .data-table button:focus-visible, .data-table-scroll:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: -2px; }
@@ -986,8 +1006,10 @@ article a { color: var(--doc-accent); }
986
1006
  .callout-body > :last-child { margin-bottom: 0; }
987
1007
  .errors { border: 1px solid var(--doc-danger); border-radius: 8px; padding: 10px 16px;
988
1008
  margin-bottom: 16px; color: var(--doc-danger); font-size: 13px; }
989
- .in-toc { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; margin: 0 10px 0 0; }
990
- .toc-current { position: relative; flex: none; width: 120px; min-width: 0; max-width: calc(100% - 36px); padding: 4px 20px 4px 4px;
1009
+ .doc-title { display: flex; align-items: baseline; gap: 12px; max-width: calc(100% - 100px); padding-top: 8px; margin-bottom: 2px; }
1010
+ .doc-title > h1 { min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
1011
+ .in-toc { min-width: 28px; max-width: 100%; }
1012
+ .toc-current { position: relative; display: block; max-width: min(240px, 100%); padding: 4px 20px 4px 6px;
991
1013
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 0; border-radius: 4px;
992
1014
  background: transparent; color: var(--doc-fg-2); font: 12px/20px var(--font-sans); text-align: left; cursor: pointer; }
993
1015
  .toc-current::after { content: ""; position: absolute; right: 6px; top: 10px; width: 5px; height: 5px;
@@ -1001,15 +1023,12 @@ article a { color: var(--doc-accent); }
1001
1023
  .in-toc .lvl2 a { padding-left: 20px; }
1002
1024
  .in-toc .lvl3 a { padding-left: 30px; }
1003
1025
  .in-toc a:hover, .in-toc a[aria-current] { color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 8%, transparent); }
1004
- .toc-seek { flex: 1; appearance: none; width: 0; min-width: 24px; height: 24px; margin: 0; padding: 0; background: transparent; cursor: ew-resize; }
1005
- .toc-seek::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, var(--doc-accent) var(--toc-progress, 0%), var(--doc-border) var(--toc-progress, 0%)); }
1006
- .toc-seek::-moz-range-track { height: 2px; background: linear-gradient(to right, var(--doc-accent) var(--toc-progress, 0%), var(--doc-border) var(--toc-progress, 0%)); }
1007
- .toc-seek::-webkit-slider-thumb { appearance: none; width: 8px; height: 8px; margin-top: -3px; border: 0; border-radius: 50%; background: var(--doc-accent); }
1008
- .toc-seek::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--doc-accent); }
1009
- .toc-seek:disabled { opacity: .35; cursor: default; }
1010
- html:has(.page-actions .toc-seek), .preview-pane:has(> .pane-actions .toc-seek) { scrollbar-width: none; }
1011
- html:has(.page-actions .toc-seek)::-webkit-scrollbar,
1012
- .preview-pane:has(> .pane-actions .toc-seek)::-webkit-scrollbar { display: none; }
1026
+ .doc-title:has(.toc-card) { display: block; max-width: none; }
1027
+ .doc-title:has(.toc-card) > h1 { max-width: calc(100% - 100px); }
1028
+ .toc-card { margin: 10px 0 14px; padding: 10px; border: 1px solid var(--doc-border); border-radius: 6px; }
1029
+ .toc-card::before { content: attr(aria-label); display: block; margin: 0 10px 6px; color: var(--doc-fg-3); font: 12px/1.5 var(--font-sans); }
1030
+ .toc-card .toc-current { display: none; }
1031
+ .toc-card .toc-options { position: static; padding: 0; border: 0; background: transparent; box-shadow: none; }
1013
1032
  main :is(h1, h2, h3)[id] { scroll-margin-top: 52px; }
1014
1033
  article strong { font-weight: 700; }
1015
1034
  article em { font-style: italic; }
@@ -1127,7 +1146,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1127
1146
  .resource-tabs a { padding: 9px 15px; color: var(--doc-fg-3); text-decoration: none; white-space: nowrap; font-size: 13px; border-bottom: 2px solid transparent; }
1128
1147
  .resource-tabs a:hover { color: var(--doc-fg); background: color-mix(in srgb, var(--doc-fg) 4%, transparent); }
1129
1148
  .resource-tabs a[aria-current] { color: var(--doc-accent); border-bottom-color: currentColor; }
1130
- .resource-toolbar { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px;
1149
+ .resource-toolbar { position: relative; display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px;
1131
1150
  border-bottom: 1px solid var(--c-line); color: var(--c-fg-muted); font-size: 11px; }
1132
1151
  .resource-toolbar > span { flex: none; }
1133
1152
  .resource-search {display:flex;align-items:center;gap:5px;flex:0 1 140px;min-width:0;height:24px;border-bottom:1px solid transparent;color:var(--c-fg-faint);}
@@ -1141,6 +1160,144 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1141
1160
  .resource-toolbar select option { background: var(--c-bg1); color: var(--c-fg); }
1142
1161
  .resource-count { margin-left: auto; color: var(--doc-fg-3); font-variant-numeric: tabular-nums; }
1143
1162
  .resource-items { display: flex; flex-direction: column; }
1163
+ .resource-items[hidden], [data-subformat-board][hidden] { display: none; }
1164
+ .resource-results:has([data-subformat-board]:not([hidden])) { min-width: 0; font-family: var(--font-sans); }
1165
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-toolbar { position: relative; height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 8px 0 12px; }
1166
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-toolbar > [data-i18n="Name"] { display: none; }
1167
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-search { flex: 1 1 160px; max-width: 260px; height: 30px; box-sizing: border-box; gap: 8px; padding: 0 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg0); }
1168
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-search:focus-within { border-color: var(--c-accent); }
1169
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-count { display: none; }
1170
+ .resources-pane:has([data-subformat-board]:not([hidden])) :is(.preview-content, .resource-library, .resource-results, [data-subformat-board]) { display: flex; flex-direction: column; flex: 1; }
1171
+ .resources-pane:has([data-subformat-board]:not([hidden])) .preview-content { min-height: 100%; }
1172
+ .resource-results:has(> .resource-empty:not([hidden])) [data-subformat-board] { flex: none; }
1173
+ .resource-results:has(> .resource-empty:not([hidden])) .subformat-columns { display: none; }
1174
+ .resource-query { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; max-width: 400px; }
1175
+ .resource-query > select { flex: 0 1 auto; min-width: 64px; max-width: 140px; height: 30px; padding: 4px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); color: var(--c-fg); cursor: pointer; }
1176
+ .resource-query > select:focus-visible { outline-color: var(--c-fg-muted); }
1177
+ .subformat-picker { flex: 0 1 auto; min-width: 0; max-width: 220px; }
1178
+ [data-subformat-trigger] { display: block; max-width: 100%; height: 32px; padding: 0 2px; border: 0; border-bottom: 1px solid var(--c-line); background: transparent; color: var(--c-fg); font: 500 18px/30px var(--font-sans); text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
1179
+ [data-subformat-trigger]:is(:hover, :focus-visible) { border-bottom-color: var(--c-fg-muted); outline: none; }
1180
+ [data-subformat-trigger]:disabled { cursor: default; }
1181
+ .subformat-picker-menu { position: fixed; margin: 0; box-sizing: border-box; width: min(260px, calc(100vw - 16px)); padding: 4px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); color: var(--c-fg); overflow-y: auto; font: 15px/1.6 var(--font-sans); }
1182
+ .subformat-picker-menu button { display: block; width: 100%; padding: 7px 10px; border: 0; background: transparent; color: var(--c-fg); font: inherit; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
1183
+ .subformat-picker-menu button:is(:hover, :focus-visible, [aria-checked="true"]) { background: var(--c-raised); outline: none; }
1184
+ .subformat-picker-menu [data-subformat-add] { margin-top: 4px; border-top: 1px solid var(--c-line); font-size: 13px; }
1185
+ .subformat-picker-option { display: flex; }
1186
+ .subformat-picker-option > button:first-child { flex: 1; min-width: 0; }
1187
+ .subformat-picker-option > [data-subformat-action] { flex: none; display: grid; place-items: center; width: 32px; padding: 0; }
1188
+ .subformat-picker-option > [data-subformat-action="delete"] { color: var(--c-danger); }
1189
+ .subformat-picker-option > button:disabled { opacity: .55; cursor: default; }
1190
+
1191
+ .resource-results [data-subformat-change="added"] { color: var(--c-ok); }
1192
+ .resource-results [data-subformat-change="modified"] { color: var(--c-accent); }
1193
+ .subformat-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; min-width: 0; max-width: 100%; margin-left: auto; }
1194
+ .subformat-control { position: relative; min-width: 80px; max-width: 160px; margin-top: 6px; }
1195
+ .subformat-control-label { position: absolute; z-index: 1; top: -7px; left: 7px; padding: 0 4px; background: var(--c-bg1); color: var(--c-fg-muted); font: 11px/14px var(--font-sans); white-space: nowrap; pointer-events: none; }
1196
+ .subformat-control > button { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 34px; padding-top: 6px; text-align: left; }
1197
+ .subformat-control > button > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1198
+ .subformat-control > button > svg { flex: none; }
1199
+ .subformat-setting-menu { font-size: 13px; }
1200
+ .subformat-setting-option { display: flex; align-items: stretch; }
1201
+ .subformat-setting-option > button:first-child { flex: 1; min-width: 0; max-width: none; border: 0; border-radius: 0; text-align: left; background: transparent; }
1202
+ .subformat-setting-option > button[aria-checked="true"] { background: var(--c-raised); }
1203
+ .subformat-setting-option > .subformat-default { display: grid; flex: none; place-items: center; width: 32px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--c-fg-muted); }
1204
+ .subformat-default[data-is-default="false"] svg { opacity: .25; }
1205
+ .subformat-default[data-is-default="true"], .subformat-default:is(:hover, :focus-visible) { color: var(--c-fg); }
1206
+ .subformat-setting-option > .subformat-default[data-layout-changed="true"] { color: var(--c-ok); }
1207
+ .subformat-default:is(:hover, :focus-visible) svg { opacity: 1; }
1208
+ .subformat-default:disabled { cursor: default; }
1209
+ .subformat-controls label { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; white-space: nowrap; }
1210
+ .subformat-card label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--c-fg-muted); }
1211
+ .subformat-controls select, .subformat-controls button, .subformat-create-form select, .subformat-create-form button, .subformat-card select { box-sizing: border-box; min-width: 0; max-width: 100%; min-height: 30px; padding: 4px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); color: var(--c-fg); font: inherit; }
1212
+ .subformat-controls select { max-width: 140px; }
1213
+ .subformat-controls [data-subformat-direction] { display: grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0; }
1214
+ .subformat-controls :is(select, button) { cursor: pointer; }
1215
+ .subformat-controls :is(select, button):hover, .subformat-card select:enabled:hover { background: var(--c-raised); }
1216
+ .subformat-controls :is(select, button):focus-visible, .subformat-card select:focus-visible { outline-color: var(--c-fg-muted); }
1217
+ .subformat-card select:disabled { opacity: .55; cursor: default; }
1218
+ .subformat-toast { position: fixed; z-index: 1000; right: 20px; bottom: 20px; box-sizing: border-box;
1219
+ max-width: min(420px, calc(100vw - 40px)); max-height: 40vh; overflow: auto; padding: 12px 16px;
1220
+ border: 1px solid var(--c-danger); border-radius: 6px; background: var(--c-bg1); color: var(--c-danger);
1221
+ font: 13px/1.5 var(--font-sans); white-space: pre-wrap; overflow-wrap: anywhere; }
1222
+ .subformat-columns { display: flex; flex: 1; gap: 20px; min-width: 0; overflow-x: auto; padding: 16px 2px 12px; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
1223
+ .subformat-column { display: flex; flex-direction: column; flex: 1 0 248px; min-width: 0; }
1224
+ .subformat-cards { flex: 1; min-height: 100px; border-radius: 6px; transition: background-color 100ms ease-out; }
1225
+ .subformat-cards.is-drop-target { background: var(--c-raised); }
1226
+ .subformat-column > h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; padding: 0 2px 10px; border-bottom: 1px solid var(--c-line); color: var(--c-fg); font: 500 12px/20px var(--font-sans); overflow-wrap: anywhere; }
1227
+ .subformat-count > span { flex: none; min-width: 10px; padding: 0 5px; border-radius: 4px; background: var(--c-raised); color: var(--c-fg-muted); font-size: 11px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
1228
+ .subformat-card { max-width: none; margin: 0 0 12px; padding: 14px; border: 1px solid var(--c-line); border-radius: 6px; background: transparent; color: var(--c-fg); font-family: var(--font-sans); overflow-wrap: anywhere; }
1229
+ .subformat-card:hover, .subformat-card:focus-within { border-color: var(--c-fg-faint); }
1230
+ .subformat-count { display: inline-flex; align-items: center; gap: 4px; }
1231
+ .resource-results [data-record-change="added"] { --record-color: var(--c-ok); }
1232
+ .resource-results [data-record-change="modified"] { --record-color: var(--c-accent); }
1233
+ .resource-results span[data-record-change] { color: var(--record-color); }
1234
+ .subformat-card[data-record-change] { border-color: var(--record-color); }
1235
+ .subformat-controls [data-subformat-create] { height: 30px; padding-inline: 12px; }
1236
+ .subformat-create-form { position: absolute; z-index: 5; top: calc(100% + 8px); right: 0; box-sizing: border-box; width: min(420px, 100%); max-height: 70vh; overflow: auto; padding: 16px; border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-bg1); }
1237
+ .subformat-create-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
1238
+ .subformat-create-form label { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 12px; }
1239
+ .subformat-create-form :is(input, textarea) { box-sizing: border-box; width: 100%; min-width: 0; padding: 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg0); color: var(--c-fg); font: 12px/1.6 var(--doc-mono); }
1240
+ .subformat-create-form :is(input, textarea, select, button):focus-visible { outline-color: var(--c-fg-muted); }
1241
+ .subformat-create-form textarea { resize: vertical; }
1242
+ .subformat-create-actions { display: flex; justify-content: flex-end; gap: 8px; }
1243
+ .subformat-card[draggable="true"] { cursor: grab; user-select: none; }
1244
+ .subformat-card[draggable="true"] :is(.subformat-card-open, .subformat-card-toggle) { cursor: inherit; }
1245
+ .subformat-card.is-dragging { visibility: hidden; }
1246
+ .subformat-card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; box-sizing: border-box; width: fit-content; max-width: 100%; height: 20px; margin: -25px -4px 8px auto; padding: 0 6px; background: var(--c-bg1); }
1247
+ .subformat-card h3 { min-width: 0; margin: 0; font-size: 13px; line-height: 1.55; }
1248
+ .subformat-card-open, .subformat-card-toggle, .subformat-card-copy { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
1249
+ .subformat-card :focus-visible { outline-color: var(--c-fg-muted); }
1250
+ .subformat-card .subformat-card-open:focus { outline: none; }
1251
+ .subformat-card-open:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
1252
+ .subformat-card-open { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: left; font-weight: 500; overflow-wrap: anywhere; }
1253
+ .subformat-card-toggle, .subformat-card-copy { flex: none; display: grid; place-items: center; width: 20px; height: 20px; margin: 0; border-radius: 4px; color: var(--c-fg-muted); }
1254
+ .subformat-card-toggle:hover, .subformat-card-copy:hover { background: var(--c-raised); color: var(--c-fg); }
1255
+ .subformat-card-copy .ic-ok, .subformat-card-copy[data-copied] svg:not(.ic-ok) { display: none; }
1256
+ .subformat-card-copy[data-copied] .ic-ok { display: block; }
1257
+ .subformat-card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
1258
+ .subformat-card .subformat-card-file { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-fg-faint); font-family: var(--doc-mono); font-size: 11px; }
1259
+ .subformat-card-tools .subformat-card-file { flex: 1; max-width: 170px; }
1260
+ .subformat-card-references { padding: 2px 0; border: 0; background: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--record-color, var(--c-fg-faint)); font-size: 11px; font-variant-numeric: tabular-nums; }
1261
+ .subformat-card-references:disabled { cursor: default; }
1262
+ .subformat-reference-list { position: fixed; margin: 0; box-sizing: border-box; width: min(320px, calc(100vw - 16px)); padding: 4px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); color: var(--c-fg); overflow-y: auto; font: 12px/1.6 var(--font-sans); }
1263
+ .subformat-reference-list ul { margin: 0; padding: 0; list-style: none; }
1264
+ .subformat-reference-list a { display: flex; align-items: baseline; gap: 12px; padding: 7px 8px; color: inherit; text-decoration: none; }
1265
+ .subformat-reference-list a > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
1266
+ .subformat-reference-list a > span:last-child { flex: none; color: var(--c-fg-muted); font-variant-numeric: tabular-nums; }
1267
+ .subformat-reference-list a:is(:hover, :focus-visible) { background: var(--c-raised); outline-color: var(--c-fg-muted); }
1268
+ .subformat-card dl { margin: 12px 0 0; font-size: 12px; }
1269
+ .subformat-card dt, .subformat-detail dt { color: var(--c-fg-muted); font-size: 11px; }
1270
+ .subformat-card dd, .subformat-detail dd { margin: 4px 0 0; }
1271
+ .subformat-card-meta { display: flex; flex-wrap: wrap; gap: 12px 16px; padding-top: 12px; border-top: 1px solid var(--c-line-soft); }
1272
+ .subformat-card-meta:empty { display: none; }
1273
+ .subformat-card-meta > div { flex: 1 1 auto; min-width: 0; max-width: 100%; }
1274
+ .subformat-card-meta dd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
1275
+ .subformat-card-details { margin-top: 12px; border-top: 1px solid var(--c-line-soft); }
1276
+ .subformat-card-details dl { display: grid; gap: 12px; }
1277
+ .subformat-card-details dd, .subformat-detail dd { white-space: pre-wrap; overflow-wrap: anywhere; }
1278
+ .subformat-card-details label { margin-top: 12px; }
1279
+ .subformat-card [hidden] { display: none; }
1280
+ .subformat-drag-preview { position: fixed; z-index: 1000; box-sizing: border-box; pointer-events: none; background: var(--c-bg1); will-change: transform; }
1281
+ .app-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
1282
+ color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 90%, transparent);
1283
+ border: 1px solid var(--c-fg-faint); border-radius: 10px; box-shadow: 0 16px 48px #0004; backdrop-filter: blur(16px); }
1284
+ .app-dialog::backdrop { background: #0005; backdrop-filter: blur(2px); }
1285
+ .app-dialog h2 { margin: 0 0 14px; font-size: 16px; overflow-wrap: anywhere; }
1286
+ .app-dialog p { margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-fg-muted); }
1287
+ .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
1288
+ .app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
1289
+ .app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
1290
+ .app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
1291
+ .app-dialog button.danger { color: var(--c-danger); }
1292
+ .subformat-page-name { display: block; box-sizing: border-box; width: 100%; margin: 8px 0 20px; padding: 8px; color: var(--c-fg); background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 4px; font: inherit; }
1293
+ .subformat-page .resource-query { flex-wrap: wrap; max-width: none; }
1294
+ .subformat-page-title { flex: 1 1 100%; margin: 0 0 12px; color: var(--c-fg); font: 500 24px/1.3 var(--font-sans); overflow-wrap: anywhere; }
1295
+ .subformat-page .resource-toolbar { align-items: flex-end; }
1296
+ .subformat-page .subformat-columns { padding-top: 20px; }
1297
+ body:not(.edit) .subformat-page { padding-top: 64px; }
1298
+ .subformat-detail-path { color: var(--c-fg-muted); font: 11px var(--doc-mono); overflow-wrap: anywhere; }
1299
+ .subformat-detail dl { display: grid; gap: 14px; margin: 20px 0; }
1300
+ .subformat-detail dt { font-size: 12px; }
1144
1301
  .resource-item { min-width: 0; margin: 0; padding: 0; border: 0; }
1145
1302
  .resource-item[hidden], .resource-empty[hidden] { display: none; }
1146
1303
  .resource-item > summary { display: flex; align-items: center; gap: 8px; min-width: 0; height: 28px; padding: 0 6px;
@@ -1161,8 +1318,6 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1161
1318
  .resource-source span { flex: none; opacity: .7; }
1162
1319
  .resource-source .resource-source-file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; opacity: 1; }
1163
1320
  .resource-badge { flex: none; color: var(--doc-fg-2); font: 11px var(--doc-mono); }
1164
- .resource-item .term-definition { margin: 0; white-space: pre-wrap; font-size: 13px; }
1165
- .resource-description { color: var(--doc-fg-3); white-space: pre-wrap; font-size: 12px; margin: 6px 0 0; }
1166
1321
  .resource-item .codeblk { margin: 0; }
1167
1322
  .resource-item .codeblk > pre { max-height: 260px; overflow: auto; }
1168
1323
  .resource-usage { flex: none; margin-left: auto; color: var(--doc-fg-3); font-size: 11px; font-variant-numeric: tabular-nums; }
@@ -1181,6 +1336,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1181
1336
  // (autosave / correspondence display / fm visibility) are gathered in the header gear's hover
1182
1337
  // menu. Width is drag-resizable.
1183
1338
  const EDIT_CSS = `
1339
+ body.line-wrap-off .cm-content { white-space: pre; }
1184
1340
  body.git-diff-hidden .cm-lineNumbers :is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { box-shadow: none; }
1185
1341
  body.git-diff-hidden .cm-line:is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { background-color: transparent; }
1186
1342
  #site-title[role="button"] { cursor: text; position: relative; }
@@ -1210,6 +1366,142 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
1210
1366
  #file-editor .cm-textfile-status { padding: 8px 12px; white-space: pre-wrap; }
1211
1367
  #file-editor .cm-textfile-status[hidden] { display: none; }
1212
1368
  #file-editor .cm-textfile-status.error { color: var(--doc-danger); }
1369
+ #file-editor:is([data-subformat-register], [data-subformat-record]) { position: static; width: auto; max-height: none; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
1370
+ #file-editor:is([data-subformat-register], [data-subformat-record]) fieldset { display: flex; flex-direction: column; flex: 1; min-height: 0; }
1371
+ .subformat-register-fields { display: grid; flex: 1; min-width: 0; grid-template-columns: minmax(36px, .5fr) 60px minmax(50px, 1.5fr); gap: 6px; margin: 0; padding: 0; border: 0; }
1372
+ .subformat-register-fields :is(input, select) { width: 100%; min-width: 0; height: 28px; padding: 4px; background: transparent; color: var(--c-fg); border: 0; border-bottom: 1px solid var(--c-line); border-radius: 0; font: 12px/18px var(--font-sans); }
1373
+ .subformat-register-fields input:hover, .subformat-register-fields input:focus-visible { background: transparent; outline: none; border-bottom-color: var(--c-fg-muted); }
1374
+ .subformat-register-fields .language-select { min-width: 0; }
1375
+ .subformat-register-fields .subformat-control { align-self: center; min-width: 0; max-width: none; margin: 3px 0 0; }
1376
+ .subformat-register-fields .subformat-control-label { top: -5px; left: 5px; padding: 0 3px; font-size: 9px; line-height: 10px; }
1377
+ .subformat-register-fields .language-select-input { height: 24px; padding: 4px 18px 1px 6px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); font-size: 11px; line-height: 16px; }
1378
+ .subformat-register-fields .language-select::after { right: 6px; top: 9px; width: 4px; height: 4px; }
1379
+ .subformat-register-fields :disabled { opacity: .5; }
1380
+ .subformat-register-fields > input[name="file"] { grid-column: 1 / -1; }
1381
+ .subformat-register-fields input::placeholder { color: var(--c-fg-muted); opacity: 1; }
1382
+ .subformat-register-fields input[name="schema"]:not([placeholder="path"])::placeholder { opacity: .55; }
1383
+ #phead:has(.subformat-register-fields) { padding-inline: 6px; }
1384
+ .file-editor-heading:has(.subformat-register-fields) { gap: 4px; margin-left: 2px; }
1385
+ [data-subformat-schema-editor] { flex: 1; min-height: 0; }
1386
+ #file-editor:is([data-subformat-register], [data-subformat-record]) .subformat-create-actions { flex: none; padding: 10px 14px; border-top: 1px solid var(--c-line); }
1387
+ #file-editor:is([data-subformat-register], [data-subformat-record]) [hidden] { display: none; }
1388
+ .schema-editor-host { display: flex; flex-direction: column; min-height: 0; }
1389
+ .schema-editor-host > .cm-editor { flex: 1; min-height: 0; }
1390
+ .schema-editor-host > [hidden] { display: none !important; }
1391
+ .schema-mode-switch:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 1px; }
1392
+ .schema-builder { flex: 1; min-height: 0; overflow: auto; container-type: inline-size; padding: 8px 12px 24px; color: var(--c-fg); font: 12px/1.6 var(--font-sans); }
1393
+ .schema-builder label { display: flex; align-items: stretch; flex-direction: column; gap: 4px; min-width: 0; margin: 0; color: var(--c-fg-muted); font-size: 11px; }
1394
+ .schema-builder :is(input, select, textarea, button) { box-sizing: border-box; min-width: 0; min-height: 0; max-width: 100%; padding: 6px 7px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg0); color: var(--c-fg); font: 12px/1.5 var(--font-sans); }
1395
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea) { padding: 4px 6px; border: 0; border-radius: 3px; background: var(--c-bg1); }
1396
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea):hover { background: var(--c-raised); }
1397
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea):focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 1px; }
1398
+ .schema-builder .schema-type-control { display: block; min-width: 0; max-width: none; margin: 0; }
1399
+ .schema-builder .schema-type-control .language-select-input { height: 28px; padding: 5px 22px 2px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg1); }
1400
+ .schema-type-control .language-select::after { right: 8px; top: 10px; width: 5px; height: 5px; }
1401
+ .schema-builder .schema-type-control > .subformat-control-label { padding: 0 4px; }
1402
+ .schema-builder :is(input, textarea) { width: 100%; }
1403
+ .schema-builder textarea { resize: vertical; }
1404
+ .schema-builder input[type="checkbox"] { flex: none; width: 14px; height: 14px; margin: 0; padding: 0; border-color: var(--c-fg-muted); border-radius: 3px; background: transparent; }
1405
+ .schema-builder input[type="checkbox"]:checked { border-color: var(--c-fg-muted); }
1406
+ .schema-builder input[type="checkbox"]:checked::after { left: 4px; top: 1px; width: 3px; height: 7px; border-color: var(--c-fg); border-width: 0 1.5px 1.5px 0; }
1407
+ .schema-builder input[type="checkbox"]:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 3px; }
1408
+ .schema-builder button { cursor: pointer; }
1409
+ .schema-builder button:hover { background: var(--c-raised); }
1410
+ .schema-builder button:disabled { opacity: .45; cursor: default; }
1411
+ .schema-field { position: relative; min-width: 0; }
1412
+ .schema-builder > :is(.schema-field, .schema-add-field, .schema-draft-details) { max-width: 560px; }
1413
+ .schema-builder > .schema-field { margin-bottom: 12px; }
1414
+ .schema-root-settings { max-width: 560px; margin-block: 12px; }
1415
+ .schema-root-settings > summary { cursor: pointer; }
1416
+ .schema-field-row, .schema-add-field { position: relative; display: grid; grid-template-columns: minmax(0, 260px) 112px minmax(128px, 1fr); align-items: center; gap: 8px; padding: 6px 0 2px; }
1417
+ .schema-field-name { display: flex; align-items: center; gap: 2px; min-width: 0; }
1418
+ .schema-field-name > :first-child { flex: 1; min-width: 0; }
1419
+ .schema-field-name > label:first-child > span, .schema-add-field > label:first-child > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
1420
+ .schema-builder .schema-required { flex: none; display: flex; flex-direction: row-reverse; align-items: center; gap: 4px; padding-inline: 4px; white-space: nowrap; cursor: pointer; }
1421
+ .schema-field-row .language-select, .schema-add-field .language-select { flex: 1; min-width: 0; }
1422
+ .schema-children { container-type: inline-size; margin: 2px 0 0 8px; padding-left: 13px; }
1423
+ .schema-children > .schema-field::before { content: ""; position: absolute; left: -13px; top: 0; height: 20px; border-left: 1px solid var(--c-line-soft); }
1424
+ .schema-children > .schema-field:has(~ .schema-field, ~ .schema-add-field)::before { height: auto; bottom: 0; }
1425
+ .schema-children > .schema-field > .schema-field-row::before { content: ""; position: absolute; left: -13px; top: 20px; width: 9px; border-top: 1px solid var(--c-line-soft); }
1426
+ .schema-children > .schema-add-field::before { content: ""; position: absolute; left: -13px; top: 0; width: 8px; height: 22px; border-left: 1px solid var(--c-line-soft); border-bottom: 1px solid var(--c-line-soft); }
1427
+ .schema-builder .schema-extra-fields { flex-direction: row-reverse; align-items: center; justify-content: flex-end; gap: 8px; min-height: 28px; width: fit-content; cursor: pointer; }
1428
+ .schema-expand[aria-expanded="true"] svg { transform: rotate(180deg); }
1429
+ .schema-field-details { container-type: inline-size; }
1430
+ .schema-field-details[hidden] { display: none; }
1431
+ .schema-field-actions { justify-self: end; display: flex; gap: 2px; }
1432
+ .schema-field-actions button, .schema-field-name button { display: grid; place-items: center; width: 24px; height: 28px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--c-fg-muted); }
1433
+ .schema-field-name > button, .schema-field-name > div { flex: none; }
1434
+ .schema-expand:disabled { visibility: hidden; }
1435
+ .schema-item-name { padding-left: 6px; height: 28px; line-height: 28px; color: var(--c-fg-muted); }
1436
+ .schema-parameter-menu { width: 184px; overflow-y: auto; }
1437
+ .schema-parameter-menu .language-options button { height: auto; min-height: 28px; width: 100%; display: block; padding: 5px 8px; text-align: left; }
1438
+ .schema-parameter-menu .language-options button:focus-visible { background: var(--c-raised); outline: none; }
1439
+ .schema-parameter-group { margin: 10px 0 16px 24px; }
1440
+ .schema-parameter { display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 2px; min-width: 0; grid-column: 1 / -1; }
1441
+ .schema-parameter[data-schema-bound="min"] { grid-column: 1; }
1442
+ .schema-parameter[data-schema-bound="max"] { grid-column: 2; }
1443
+ .schema-parameter label { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 8px; }
1444
+ .schema-parameter label > span { overflow-wrap: anywhere; }
1445
+ .schema-parameter-help { grid-column: 1 / -1; color: var(--c-fg-muted); overflow-wrap: anywhere; }
1446
+ .schema-parameter label:has(> textarea) { align-items: start; }
1447
+ .schema-parameter label:has(> input[type="checkbox"]) { display: flex; flex-direction: row-reverse; align-items: center; justify-content: flex-end; gap: 8px; min-height: 28px; cursor: pointer; }
1448
+ .schema-parameter > button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--c-fg-muted); }
1449
+ .schema-parameter:has(textarea) > button { align-self: start; }
1450
+ .schema-builder [hidden] { display: none; }
1451
+ .schema-parameters { display: grid; gap: 6px; }
1452
+ .schema-parameter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
1453
+ .schema-parameter-row:not(.schema-range) > .schema-parameter { grid-column: 1 / -1; }
1454
+ .schema-range { grid-template-columns: minmax(0, 1fr) minmax(48px, .7fr) minmax(0, 1fr); align-items: center; }
1455
+ .schema-range .schema-parameter { grid-row: 1; }
1456
+ .schema-range [data-schema-bound="max"] { grid-column: 3; }
1457
+ .schema-range .schema-parameter label { grid-template-columns: minmax(0, 1fr) 60px; gap: 4px; }
1458
+ .schema-range .schema-parameter input { font-variant-numeric: tabular-nums; }
1459
+ .schema-range-track { position: relative; grid-column: 1 / -1; height: 24px; }
1460
+ .schema-range > .schema-range-track { grid-column: 2; grid-row: 1; }
1461
+ .schema-range-track::before, .schema-range-track > span { content: ""; position: absolute; top: 11px; left: 5px; right: 5px; height: 2px; background: var(--c-line); }
1462
+ .schema-range-track > span { left: calc(5px + (100% - 10px) * var(--range-min)); right: calc(5px + (100% - 10px) * (1 - var(--range-max))); background: var(--c-fg-muted); }
1463
+ .schema-builder .schema-range-track input { appearance: none; position: absolute; inset: 0; width: 100%; height: 24px; margin: 0; padding: 0; border: 0; background: transparent; pointer-events: none; }
1464
+ .schema-range-track input::-webkit-slider-runnable-track { height: 2px; background: transparent; }
1465
+ .schema-range-track input::-webkit-slider-thumb { appearance: none; width: 10px; height: 10px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--c-fg-muted); pointer-events: auto; cursor: ew-resize; }
1466
+ .schema-range-track input::-moz-range-track { height: 2px; background: transparent; }
1467
+ .schema-range-track input::-moz-range-thumb { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--c-fg-muted); pointer-events: auto; cursor: ew-resize; }
1468
+ .schema-range-track input:focus-visible { z-index: 1; }
1469
+ .schema-range-track input:disabled { opacity: .45; }
1470
+ .schema-range-track input:disabled::-webkit-slider-thumb { pointer-events: none; }
1471
+ .schema-range-track input:disabled::-moz-range-thumb { pointer-events: none; }
1472
+ .schema-add-field { padding: 8px 0 4px; }
1473
+ .schema-add-actions { justify-self: end; display: flex; align-items: center; }
1474
+ .schema-add-actions > button { min-height: 28px; padding: 4px; white-space: nowrap; }
1475
+ .schema-add-actions > button + button { margin-left: 4px; border: 0; background: transparent; color: var(--c-fg-muted); }
1476
+ .schema-builder input[aria-invalid="true"], .schema-builder input[aria-invalid="true"]:focus-visible, .subformat-register-fields input:user-invalid { outline: 1px solid var(--c-danger); outline-offset: 1px; }
1477
+ .schema-json-note { margin: 8px 0 0; color: var(--c-fg-muted); font-size: 11px; }
1478
+ .schema-builder .schema-extra-fields { margin: 6px 0; }
1479
+ .subformat-value-form > label, .subformat-value-form fieldset > label { margin-block: 12px; }
1480
+ .subformat-value-form fieldset { min-width: 0; margin: 12px 0; padding: 0 12px; border: 1px solid var(--c-line); }
1481
+ .subformat-value-form legend { padding-inline: 4px; }
1482
+ .subformat-value-form small { overflow-wrap: anywhere; }
1483
+ .date-control { position: relative; }
1484
+ .schema-builder .date-control > input { padding-right: 34px; font-variant-numeric: tabular-nums; }
1485
+ .schema-builder .date-trigger { position: absolute; top: 0; right: 0; display: grid; place-items: center; width: 30px; height: 100%; padding: 0; border: 0; background: transparent; color: var(--c-fg-muted); }
1486
+ .schema-builder .date-picker { box-sizing: border-box; width: min(272px, calc(100vw - 16px)); padding: 10px; overflow-y: auto; }
1487
+ .date-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
1488
+ .date-picker-header > span { color: var(--c-fg); font-weight: 500; }
1489
+ .schema-builder .date-picker button { display: grid; place-items: center; height: 32px; padding: 0; border: 0; border-radius: 3px; background: transparent; color: var(--c-fg); font: inherit; font-variant-numeric: tabular-nums; }
1490
+ .schema-builder .date-picker button:is(:hover, :focus-visible) { background: var(--c-raised); }
1491
+ .schema-builder .date-picker button:focus-visible { outline: 1px solid var(--c-accent); outline-offset: -1px; }
1492
+ .date-picker-header button { width: 32px; }
1493
+ .date-picker table { width: 100%; margin: 0; border: 0; border-collapse: collapse; table-layout: fixed; }
1494
+ .date-picker :is(th, td) { padding: 0; border: 0; text-align: center; }
1495
+ .date-picker th { height: 28px; color: var(--c-fg-muted); font-size: 11px; font-weight: inherit; }
1496
+ .date-picker td button { position: relative; width: 100%; }
1497
+ .schema-builder .date-picker [data-outside="true"] { color: var(--c-fg-muted); }
1498
+ .schema-builder .date-picker [aria-selected="true"] button { background: var(--c-raised); box-shadow: inset 0 0 0 1px var(--c-accent); }
1499
+ .date-picker [aria-current="date"]::after { content: ""; position: absolute; bottom: 3px; width: 3px; height: 3px; border-radius: 50%; background: var(--c-accent); }
1500
+ .date-picker-footer { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--c-line); }
1501
+ .schema-builder .date-picker-footer button { padding-inline: 8px; color: var(--c-fg-muted); }
1502
+ @container(max-width:440px) { .schema-field-row, .schema-add-field { grid-template-columns: minmax(0, 1fr) 128px; } .schema-field-row > :first-child, .schema-add-field > :first-child { grid-column: 1 / -1; } }
1503
+ @container(max-width:440px) { .schema-add-field { grid-template-columns: minmax(0, 1fr) auto; } }
1504
+ @container(max-width:440px) { .schema-range { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; } .schema-range [data-schema-bound="max"] { grid-column: 2; } .schema-range > .schema-range-track { grid-column: 1 / -1; grid-row: 2; } .schema-range .schema-parameter label { grid-template-columns: minmax(0, 1fr); gap: 0; } }
1213
1505
 
1214
1506
  /* header band (same height and rule as sidebar-head) */
1215
1507
  #phead { flex: none; display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 10px 0 14px;
@@ -1253,17 +1545,6 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1253
1545
  .cm-file-preview[data-state="loading"] svg { animation: preview-spin 1s linear infinite; }
1254
1546
  @keyframes preview-spin { to { transform: rotate(360deg); } }
1255
1547
  @media (prefers-reduced-motion: reduce) { .cm-file-preview[data-state="loading"] svg { animation: none; } }
1256
- .app-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
1257
- color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 90%, transparent);
1258
- border: 1px solid var(--c-fg-faint); border-radius: 10px; box-shadow: 0 16px 48px #0004; backdrop-filter: blur(16px); }
1259
- .app-dialog::backdrop { background: #0005; backdrop-filter: blur(2px); }
1260
- .app-dialog h2 { margin: 0 0 14px; font-size: 16px; overflow-wrap: anywhere; }
1261
- .app-dialog p { margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-fg-muted); }
1262
- .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
1263
- .app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
1264
- .app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
1265
- .app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
1266
- .app-dialog button.danger { color: var(--c-danger); }
1267
1548
  .app-dialog:has(.conflict-columns) { width: min(1000px, calc(100vw - 32px)); }
1268
1549
  .conflict-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
1269
1550
  .conflict-columns h3 { font-size: 13px; margin: 0; }
@@ -1274,11 +1555,22 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1274
1555
  min-width: 220px; padding: 4px; flex-direction: column; gap: 1px; color: var(--c-fg);
1275
1556
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 6px;
1276
1557
  box-shadow: 0 10px 28px var(--c-shadow); font-size: 12.5px; }
1277
- #gear:hover #gearmenu, #gear:focus-within #gearmenu, #gear.open #gearmenu { display: flex; }
1558
+ #gear:hover #gearmenu, #gear:focus-within #gearmenu, #gear.open #gearmenu, #gear:has([aria-expanded="true"]) #gearmenu { display: flex; }
1278
1559
  #gearmenu label { display: flex; gap: 10px; align-items: center; cursor: pointer;
1279
1560
  padding: 7px 10px; border-radius: 4px; }
1280
1561
  #gearmenu label:hover { background: var(--c-raised); }
1281
1562
  #gearmenu input { accent-color: var(--c-accent); margin: 0; }
1563
+ .editor-setting { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px 8px 4px; }
1564
+ .editor-setting > .nav-icon, .editor-setting-icon { color: var(--c-fg-muted); }
1565
+ .editor-setting-icon { display: grid; place-items: center; }
1566
+ .editor-setting .subformat-control { min-width: 0; max-width: none; margin: 0; }
1567
+ .editor-setting .subformat-control-label { background: var(--c-surface); }
1568
+ .editor-setting .setting-picker, .editor-setting .language-select-input { box-sizing: border-box; width: 100%; min-width: 0; height: 30px; min-height: 30px; padding: 4px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-surface); color: var(--c-fg); font: 12px/18px var(--font-sans); }
1569
+ .editor-setting .setting-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
1570
+ .editor-setting .setting-picker > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1571
+ .editor-setting .setting-picker > svg { flex: none; }
1572
+ .editor-setting .language-select-input { padding-right: 26px; }
1573
+ .editor-setting .setting-picker:hover { background: var(--c-raised); }
1282
1574
 
1283
1575
  .fm-language { display: flex; align-items: center; flex: 0 1 220px; min-width: 0; gap: 4px; }
1284
1576
  .fm-language > .language-select { flex: 1; width: 0; min-width: 0; }
@@ -1314,7 +1606,7 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1314
1606
 
1315
1607
  main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction: column; position: sticky; top: 0; }
1316
1608
  #split-preview[aria-pressed="true"] { color: var(--c-accent); background: var(--c-raised); }
1317
- .pane-actions { top: -20px; margin: -20px -24px 20px; }
1609
+ .pane-actions { top: -20px; margin: -20px -24px -36px; }
1318
1610
  #preview-panes { display: flex; flex: 1; min-height: 0; }
1319
1611
  #preview-panes[hidden] { display: none; }
1320
1612
  .preview-pane.resources-pane { min-height: 0; padding-bottom: 24px; }
@@ -1322,7 +1614,7 @@ main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction
1322
1614
  .resources-pane .resource-tabs { margin-inline: -24px; padding: 0 12px; }
1323
1615
  .preview-pane { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px 50vh; border-top: 2px solid transparent; }
1324
1616
  #preview-panes.split .preview-pane { padding: 16px; }
1325
- #preview-panes.split .pane-actions { top: -16px; margin: -16px -16px 16px; padding-inline: 10px; }
1617
+ #preview-panes.split .pane-actions { top: -16px; margin: -16px -16px -36px; padding-inline: 10px; }
1326
1618
  #preview-panes.split .preview-pane + .preview-pane { border-left: 1px solid var(--c-line); }
1327
1619
  #preview-panes.split .preview-pane.active { border-top-color: var(--c-accent); }
1328
1620
  .preview-pane:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
@@ -1333,8 +1625,8 @@ main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction
1333
1625
  .language-option[aria-checked="true"]::before { content: "✓"; }
1334
1626
  .language-option:hover, .language-option:focus-visible { background: var(--c-raised); outline: none; }
1335
1627
  .language-option:disabled { opacity: .5; cursor: wait; }
1336
- #language-setting { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--c-line); }
1337
- #language-setting .language-select { width: 160px; }
1628
+ #language-setting { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--c-line); }
1629
+ #language-setting .language-select { width: 100%; }
1338
1630
  .cm-code-diagnostic { text-decoration:underline wavy var(--c-warn); text-underline-offset:3px; }
1339
1631
  #validate[data-state="error"], .cm-textfile-validate[data-state="error"] { color:var(--c-danger); }
1340
1632
  #validate[data-state="valid"], .cm-textfile-validate[data-state="valid"] { color:var(--c-ok); }
@@ -1406,7 +1698,7 @@ body.corr main article > [data-ln].corr-hi {
1406
1698
  .files-copy svg {width:14px;height:14px;color:var(--c-fg-faint);}
1407
1699
  .files-table tr:hover .files-copy,.files-table tr:focus-within .files-copy {opacity:1;}
1408
1700
  @media(hover:none){.files-copy{opacity:1;}}
1409
- .files-table [data-drop=before] {box-shadow:inset 0 2px var(--c-accent);}.files-table [data-drop=after] {box-shadow:inset 0 -2px var(--c-accent);}.files-table [data-drop=into] {outline:2px solid var(--c-accent);outline-offset:-2px;}
1701
+ .files-table [data-drop=into], .files-viewport[data-drop=into] {outline:2px solid var(--c-accent);outline-offset:-2px;}
1410
1702
  .files-table .files-placeholder {height:96px;text-align:center;vertical-align:middle;}
1411
1703
  .app-dialog textarea {display:block;box-sizing:border-box;width:100%;min-height:64px;max-height:65vh;resize:both;font:inherit;}
1412
1704
  @media(max-width:600px){.files-table {min-width:0;}.files-table th:nth-child(2){width:65px;}.files-name{max-width:100%;}}
@@ -1419,8 +1711,6 @@ body.corr main article > [data-ln].corr-hi {
1419
1711
  .res-crumbs { color: var(--c-fg-faint); font-size: 12.5px; margin: 0 0 20px; }
1420
1712
  .res-crumbs a { color: var(--c-fg-muted); text-decoration: none; }
1421
1713
  .res-crumbs a:hover { color: var(--c-fg); }
1422
- .res-section h2 { font-size: 15px; border: 0; margin: 28px 0 10px; }
1423
- .res-section h2 a { color: inherit; text-decoration: none; }
1424
1714
  .res-sub { color: var(--c-fg-faint); font-size: 11.5px; font-weight: 400; }
1425
1715
  .res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
1426
1716
  .res-card { display: flex; flex-direction: column; border: 1px solid var(--c-line); border-radius: 6px;
@@ -1435,18 +1725,15 @@ body.corr main article > [data-ln].corr-hi {
1435
1725
  pointer-events: none; }
1436
1726
  .res-preview .res-svg { max-height: 480px; }
1437
1727
  .res-preview .res-html { width: 100% !important; }
1438
- .res-thumb .res-frame { width: 100%; height: 100%; border: 0; pointer-events: none; background: #fff; }
1439
1728
  .res-meta { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-top: 1px solid var(--c-line); }
1440
1729
  .res-name { font-family: var(--doc-mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1441
1730
  .res-preview { display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 16px;
1442
1731
  border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-bg0); }
1443
1732
  .res-preview .res-img { max-width: 100%; max-height: 480px; }
1444
1733
  .res-preview.square .res-img { width: 160px; height: 160px; outline: 1px dashed var(--c-line); }
1445
- .res-preview .res-frame { width: 100%; height: 420px; border: 0; background: #fff; }
1446
1734
  .res-markdown { width: 100%; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
1447
1735
  .res-thumb .res-markdown { max-height: 100%; overflow: hidden; font-size: 11px; }
1448
1736
  .res-preview .res-markdown { max-height: 480px; overflow: auto; }
1449
- .res-empty { color: var(--c-fg-faint); }
1450
1737
  .res-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 0; font-size: 13px; }
1451
1738
  .res-dl dt { color: var(--c-fg-faint); }
1452
1739
  .res-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@@ -1473,14 +1760,31 @@ body.corr main article > [data-ln].corr-hi {
1473
1760
  .nav-tree-spacer { flex: none; height: 28px; }
1474
1761
  @media (hover: none) { .nav-row :is(.new, .nav-delete) { opacity: 1; } }
1475
1762
  .nav-row > .nav-create { margin: 7px 12px; opacity: 1; }
1476
- .nav-add-hover { visibility: hidden; }
1477
- #sidebar:hover .nav-add-hover, #sidebar:focus-within .nav-add-hover { visibility: visible; }
1478
1763
  #sidebar .nav-list:has(> .nav-new-item) > .nav-placeholder { display: none; }
1764
+ .nav-page-menu { position: fixed; inset: auto; margin: 0; padding: 4px; width: 200px;
1765
+ max-width: calc(100vw - 16px); box-sizing: border-box; overflow: auto;
1766
+ border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-surface); color: var(--c-fg);
1767
+ box-shadow: 0 8px 24px var(--c-shadow); font: 12px/1.5 var(--font-sans); }
1768
+ .nav-page-menu > button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px;
1769
+ padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: inherit;
1770
+ font: inherit; text-align: left; cursor: pointer; }
1771
+ .nav-page-menu > button svg { width: 16px; height: 16px; flex: none; color: var(--c-fg-muted); }
1772
+ .nav-page-menu > button:not(:disabled):hover { background: var(--c-raised); }
1773
+ .nav-page-menu :focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: -2px; }
1774
+ .nav-page-menu button:disabled { color: var(--c-fg-muted); cursor: default; }
1775
+ .nav-page-menu .nav-page-chevron { display: flex; margin-left: auto; transform: rotate(90deg); }
1776
+ .nav-page-menu .nav-page-chevron svg { width: 12px; height: 12px; }
1777
+ .nav-page-menu .subformat-setting-option > button:is(:hover, :focus-visible) { background: var(--c-raised); }
1778
+ .nav-page-menu .err { margin: 0; padding: 4px 10px; color: var(--c-danger); overflow-wrap: anywhere; }
1779
+ .nav-page-menu .err:empty { display: none; }
1479
1780
  /* Keep the title and filename together in a compact create form. */
1480
1781
  .nav-row > .nav-new { position: relative; display: flex; flex: 1; min-width: 0;
1481
1782
  flex-direction: column; justify-content: center; align-items: stretch; cursor: auto;
1482
- margin: 4px 0; height: 42px; padding: 5px 38px 5px 36px;
1483
- border: 1px dashed var(--c-line); border-radius: 6px; background: var(--c-raised); }
1783
+ margin: 4px 0; gap: 10px; padding: 12px;
1784
+ border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-raised); }
1785
+ .nav-new-heading { margin: 0; color: var(--c-fg-muted); font-size: 11px; }
1786
+ .nav-new :is(input, button):focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 2px; }
1787
+ .nav-new [hidden] { display: none; }
1484
1788
  .nav-tree .nav-new { margin-left: calc(var(--nav-pad) - 12px); }
1485
1789
  .nav-new > .nav-icon { position: absolute; left: 12px; top: 10px; color: var(--c-fg-faint); }
1486
1790
  .nav-new input { font: inherit; color: var(--c-fg); background: transparent; border: none;
@@ -1490,9 +1794,10 @@ body.corr main article > [data-ln].corr-hi {
1490
1794
  .nav-new-file { display: flex; align-items: center; color: var(--c-fg-faint);
1491
1795
  font: 10px/12px var(--doc-mono); }
1492
1796
  .nav-new-file input { flex: 1; font-family: inherit; font-size: inherit; color: var(--c-fg-muted); }
1493
- .nav-new-go { position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
1494
- display: flex; align-items: center; justify-content: center; width: 24px;
1495
- height: 24px; padding: 0; font-size: 11px; color: var(--c-fg-faint); background: none;
1797
+ .nav-new-actions { display: flex; justify-content: flex-end; gap: 8px; }
1798
+ .nav-new-cancel { padding: 4px 8px; color: var(--c-fg-muted); background: none; border: 0; border-radius: 4px; font: inherit; cursor: pointer; }
1799
+ .nav-new-go { flex: none; display: flex; align-items: center; justify-content: center;
1800
+ min-height: 30px; padding: 4px 10px; font: inherit; color: var(--c-fg); background: var(--c-bg0);
1496
1801
  border: 1px solid var(--c-line); border-radius: 4px; cursor: pointer; }
1497
1802
  .nav-new-go:hover { color: var(--c-accent); border-color: var(--c-accent); }
1498
1803
  .nav-new .err { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; padding: 4px;
@@ -1511,7 +1816,7 @@ body.edit .nav-row { cursor: grab; }
1511
1816
  .nav-row.drop-into > a { background: color-mix(in srgb, var(--c-accent) 18%, transparent); }
1512
1817
  `;
1513
1818
  // Contents of #nav-groups (the doc tree). Used by both page()'s initial render and
1514
- // `GET /api/nav` (edit mode; the client replaces just the innerHTML after an md change)
1819
+ // `GET /api/nav` (edit mode; the client reconciles changed nodes after an md change)
1515
1820
  // (= the same value isn't declared in two places).
1516
1821
  // Each item is a page row and its children list, emitted even when empty
1517
1822
  // (it's the insertion target for the sidebar create form / drag).
@@ -1528,14 +1833,14 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1528
1833
  // A doc-specific icon (icons/<id>.svg), if any, replaces the book icon at top
1529
1834
  // level and goes before the label below that.
1530
1835
  let link = depth === 0
1531
- ? `<a class="nav-link${cur}" href="/${e.id}" title="${label}">${e.icon ? svgImg(e.icon, "nav-icon doc-icon") : DOCS_ICON}<span class="nav-label">${label}</span></a>`
1532
- : `<a class="nav-tree-link${cur}" href="/${e.id}" title="${label}">${e.icon ? svgImg(e.icon, "doc-icon") : DOCS_ICON}<span class="nav-label">${label}</span></a>`;
1836
+ ? `<a class="nav-link${cur}" href="/${e.id}" title="${label}">${e.icon ? svgImg(e.icon, "nav-icon doc-icon") : e.subformat ? SUBFORMATS_ICON : DOCS_ICON}<span class="nav-label">${label}</span></a>`
1837
+ : `<a class="nav-tree-link${cur}" href="/${e.id}" title="${label}">${e.icon ? svgImg(e.icon, "doc-icon") : e.subformat ? SUBFORMATS_ICON : DOCS_ICON}<span class="nav-label">${label}</span></a>`;
1533
1838
  let actions = "";
1534
1839
  let editableIcon = "";
1535
1840
  if (mode === "edit") {
1536
1841
  link = `<a class="${depth === 0 ? "nav-link" : "nav-tree-link"}${cur}" href="/${e.id}" title="${label}" aria-keyshortcuts="F2"><span class="nav-doc-name"><span class="nav-label">${label}</span></span></a>`;
1537
- editableIcon = `<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${e.icon ? svgImg(e.icon, "doc-icon") : DOCS_ICON}<input type="file" accept=".svg,image/svg+xml" aria-label="icon" data-i18n-aria-label="icon">${e.icon ? '<button class="nav-icon-clear" type="button" title="Remove icon" data-i18n-title="Remove icon" aria-label="Remove icon" data-i18n-aria-label="Remove icon">×</button>' : ""}</span>`;
1538
- actions = `<button class="new" type="button" data-parent="${escapeHtml(e.id)}" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button><button class="nav-delete" type="button" data-doc-action="delete" title="Delete doc" data-i18n-title="Delete doc" aria-label="Delete doc" data-i18n-aria-label="Delete doc">${DELETE_ICON}</button>`;
1842
+ editableIcon = `<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${e.icon ? svgImg(e.icon, "doc-icon") : e.subformat ? SUBFORMATS_ICON : DOCS_ICON}<input type="file" accept=".svg,image/svg+xml" aria-label="icon" data-i18n-aria-label="icon">${e.icon ? '<button class="nav-icon-clear" type="button" title="Remove icon" data-i18n-title="Remove icon" aria-label="Remove icon" data-i18n-aria-label="Remove icon">×</button>' : ""}</span>`;
1843
+ actions = `<button class="new" type="button" data-parent="${escapeHtml(e.id)}" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button><button class="nav-delete" type="button" data-doc-action="delete" title="Delete doc" data-i18n-title="Delete doc" aria-label="Delete doc" data-i18n-aria-label="Delete doc">${DELETE_ICON}</button>`;
1539
1844
  }
1540
1845
  const branch = childrenOf(site.entries, e.id).length > 0;
1541
1846
  const toggle = branch
@@ -1543,17 +1848,20 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1543
1848
  : mode === "edit"
1544
1849
  ? '<span class="nav-tree-spacer" aria-hidden="true"></span>'
1545
1850
  : "";
1546
- return `<div class="nav-item${open.has(e.id) ? " open" : ""}" data-doc-id="${escapeHtml(e.id)}"><div class="nav-row${mode === "edit" ? " nav-doc-row" : ""}"${mode === "edit" ? ' draggable="true"' : ""}>${editableIcon}${link}${actions}${toggle}</div>${list(e.id, depth + 1)}</div>`;
1851
+ return `<div class="nav-item${open.has(e.id) ? " open" : ""}" data-doc-id="${escapeHtml(e.id)}"${e.subformat ? " data-subformat-nav" : ""}><div class="nav-row${mode === "edit" ? " nav-doc-row" : ""}"${mode === "edit" ? ' draggable="true"' : ""}>${editableIcon}${link}${actions}${toggle}</div>${list(e.id, depth + 1)}</div>`;
1547
1852
  })
1548
1853
  .join("");
1549
1854
  const placeholder = mode === "edit" && depth === 0
1550
- ? `<div class="nav-item nav-placeholder${items ? " nav-add-hover" : ""}"><div class="nav-row"><button class="nav-create" type="button" data-parent="" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button></div></div>`
1855
+ ? `<div class="nav-item nav-placeholder"><div class="nav-row"><button class="nav-create" type="button" data-parent="" popovertarget="nav-page-menu" aria-haspopup="menu" title="Add doc" data-i18n-title="Add doc" aria-label="Add doc" data-i18n-aria-label="Add doc">${PLUS_ICON}</button></div></div>`
1551
1856
  : "";
1552
1857
  return depth === 0
1553
1858
  ? `<div class="nav-list nav-root" data-parent=""${mode === "edit" ? ' id="nav-docs"' : ""}>${items}${placeholder}</div>`
1554
1859
  : `<div class="nav-list nav-tree" data-parent="${escapeHtml(parent ?? "")}" style="--nav-depth:${depth + 1}">${items}${placeholder}</div>`;
1555
1860
  };
1556
- const html = list(undefined, 0) + (mode === "edit" ? navFilesHtml(site, currentRes) : "");
1861
+ const html = list(undefined, 0) +
1862
+ (mode === "edit"
1863
+ ? `<template data-page-subformats>${escapeHtml(JSON.stringify((site.subformats ?? []).filter((format) => !site.entries.some((entry) => entry.subformat?.ext === format.ext))))}</template>${navFilesHtml(site, currentRes)}`
1864
+ : "");
1557
1865
  return docLinks(site, site.contentLanguage ? languageLinks(html, site.contentLanguage) : html);
1558
1866
  };
1559
1867
  // ── Resources (file management in edit mode; linked figures and terms also in preview) ──
@@ -1561,7 +1869,9 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1561
1869
  // Route is `/_files[/<kind>[/<file>]]` (doc ids can't start with `_`, so no collision).
1562
1870
  const RESOURCE_KINDS = ["markdown", "figures", "html", "icons", "terms"];
1563
1871
  const siteResources = (site) => [
1564
- ...site.entries.map((entry) => ({
1872
+ ...site.entries
1873
+ .filter((entry) => !entry.subformat)
1874
+ .map((entry) => ({
1565
1875
  kind: "markdown",
1566
1876
  file: entry.file,
1567
1877
  path: entry.sourceFile ?? CONTENT_PREFIX + entry.file,
@@ -1591,17 +1901,17 @@ const resourceHref = (kind, file) => `/_files${kind ? `/${kind}` : ""}${file ? `
1591
1901
  const navFilesHtml = (site, currentRes) => {
1592
1902
  const source = site.workspace;
1593
1903
  const statics = currentRes?.startsWith("_statics") ||
1594
- ["dictionary", "code", "urls"].includes(currentRes ?? "");
1595
- const folderIcon = icon('<path d="M2 5h6l2 2h8v10H2Z"/>');
1904
+ ["codeblocks", "urls", "url-previews", "dictionary", "code"].includes(currentRes ?? "");
1596
1905
  const hint = `<div class="files-drop-hint" aria-hidden="true">${UPLOAD_ICON}<span data-i18n="Upload files">Upload files</span></div>`;
1597
1906
  const location = source?.protocol === "git"
1598
- ? `<div class="workspace-location" data-workspace-protocol="git" title="${escapeHtml(`${source.repo ?? "repo"}[${source.branch}]`)}">${GIT_ICON}<span class="workspace-address"><span class="git-repo-name">${escapeHtml(source.repo ?? "repo")}</span><span class="git-branch-caption">[${escapeHtml(source.branch)}]</span></span></div>`
1599
- : `<div class="workspace-location" id="nav-storage" data-workspace-protocol="storage" title="${escapeHtml(workspaceName(site))}">${workspaceIcon(site)}<span class="workspace-address">${escapeHtml(source?.folder ?? "Files")} / ${escapeHtml(source?.service ?? "Local")}</span></div>`;
1907
+ ? `<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" data-workspace-protocol="git" title="${escapeHtml(`${source.repo ?? "repo"}[${source.branch}]`)}">${GIT_ICON}<span class="workspace-address"><span class="git-repo-name">${escapeHtml(source.repo ?? "repo")}</span><span class="git-branch-caption">[${escapeHtml(source.branch)}]</span></span>${CHEVRON_ICON}</summary>`
1908
+ : `<summary class="workspace-location" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools" id="nav-storage" data-workspace-protocol="storage" title="${escapeHtml(workspaceName(site))}">${workspaceIcon(site)}<span class="workspace-address">${escapeHtml(source?.folder ?? "Files")} / ${escapeHtml(source?.service ?? "Local")}</span>${CHEVRON_ICON}</summary>`;
1600
1909
  const git = source?.protocol === "git"
1601
1910
  ? `<div class="nav-resources" id="nav-git"><div class="nav-item" data-node-id="_git"><div class="nav-row"><a class="nav-link${currentRes === "_git" ? " cur" : ""}" href="/_git" title="Git controls" data-i18n-title="Git controls">${GIT_ICON}<span class="nav-label">Git</span></a></div></div></div>`
1602
1911
  : "";
1603
1912
  const extensions = `<div class="nav-resources" id="nav-extensions" data-scope="${createHash("sha256").update(root).digest("hex")}"><div class="nav-item" data-node-id="_extensions"><div class="nav-row"><a class="nav-link${currentRes === "_extensions" ? " cur" : ""}" href="/_extensions" title="Plugins" data-i18n-title="Plugins">${PLUGINS_ICON}<span class="nav-label" data-i18n="Plugins">Plugins</span></a></div></div><div class="extensions-drop-hint" aria-hidden="true">${PLUGINS_ICON}<span data-i18n="Add plugins">Add plugins</span></div></div>`;
1604
- return `<section id="nav-tools" aria-label="Workspace tools" data-i18n-aria-label="Workspace tools"><div id="tools-resize" role="separator" tabindex="0" aria-orientation="horizontal" aria-controls="nav-tools" aria-label="Resize workspace tools" data-i18n-aria-label="Resize workspace tools"></div>${location}<div class="nav-tool-cards"><div class="nav-resources" id="nav-files"><div class="nav-item" data-node-id="_files"><div class="nav-row"><a class="nav-link${currentRes !== undefined && currentRes !== "_git" && currentRes !== "_extensions" && !statics ? " cur" : ""}" href="/_files" title="Files" data-i18n-title="Files">${folderIcon}<span class="nav-label" data-i18n="Files">Files</span></a><span class="files-upload-status" role="status"></span></div></div>${hint}</div><div class="nav-resources" id="nav-statics"><div class="nav-item" data-node-id="_statics"><div class="nav-row"><a class="nav-link${statics ? " cur" : ""}" href="/_statics" title="Statics" data-i18n-title="Statics">${STATICS_ICON}<span class="nav-label" data-i18n="Statics">Statics</span></a></div></div></div>${git}${extensions}</div></section>`;
1913
+ const subformats = `<div class="nav-resources" id="nav-subformats"><div class="nav-item" data-node-id="_subformats"><div class="nav-row"><a class="nav-link${currentRes === "_subformats" ? " cur" : ""}" href="/_subformats" title="Subformats" data-i18n-title="Subformats">${SUBFORMATS_ICON}<span class="nav-label" data-i18n="Subformats">Subformats</span></a></div></div></div>`;
1914
+ return `<details id="nav-tools" open>${location}<div class="nav-tool-cards"><div class="nav-resources" id="nav-files"><div class="nav-item" data-node-id="_files"><div class="nav-row"><a class="nav-link${currentRes !== undefined && currentRes !== "_git" && currentRes !== "_extensions" && currentRes !== "_subformats" && !statics ? " cur" : ""}" href="/_files" title="Files" data-i18n-title="Files">${FOLDER_ICON}<span class="nav-label" data-i18n="Files">Files</span></a><span class="files-upload-status" role="status"></span></div></div>${hint}</div><div class="nav-resources" id="nav-statics"><div class="nav-item" data-node-id="_statics"><div class="nav-row"><a class="nav-link${statics ? " cur" : ""}" href="/_statics" title="Statics" data-i18n-title="Statics">${STATICS_ICON}<span class="nav-label" data-i18n="Statics">Statics</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`;
1605
1915
  };
1606
1916
  const formatSize = (bytes) => bytes < 1024
1607
1917
  ? `${bytes} B`
@@ -1635,7 +1945,7 @@ const resourcePreview = (site, r) => {
1635
1945
  // embedded the theme).
1636
1946
  return f.kind === "image"
1637
1947
  ? f.markup.replace("<img ", '<img class="res-img" ')
1638
- : figureFrameHtml(f, `fig-frame res-${f.kind}`);
1948
+ : (site.ctx.figurePreview ?? figureFrameHtml)(f, `fig-frame res-${f.kind}`);
1639
1949
  }
1640
1950
  const e = site.entries.find((x) => `${x.id}.svg` === r.file);
1641
1951
  return e?.icon ? svgImg(e.icon, "res-img res-icon") : "";
@@ -1682,6 +1992,12 @@ export const textfilePreviewHtml = (site, file, source) => {
1682
1992
  };
1683
1993
  export const textfilePreviewErrors = (site, file, source) => {
1684
1994
  const errors = textfilePreview(site, file, source).errors;
1995
+ try {
1996
+ validateSubformatFile(root, file, source, site.previews?.domains);
1997
+ }
1998
+ catch (error) {
1999
+ errors.push(error instanceof Error ? error.message : String(error));
2000
+ }
1685
2001
  if (/\.(md|markdown)$/i.test(file)) {
1686
2002
  const { doc, source: parsed } = compileDraft(draftContext(site), file, source);
1687
2003
  errors.push(...parsed.errors);
@@ -1708,8 +2024,8 @@ export const resourcesMain = (site, rest) => {
1708
2024
  }
1709
2025
  : undefined;
1710
2026
  if (rest === "_statics" || rest.startsWith("_statics/")) {
1711
- const view = rest.slice("_statics".length).replace(/^\//, "") || "dictionary";
1712
- return ["dictionary", "code", "urls"].includes(view)
2027
+ const view = rest.slice("_statics".length).replace(/^\//, "") || "codeblocks";
2028
+ return ["codeblocks", "urls", "url-previews", "dictionary", "code"].includes(view)
1713
2029
  ? resourcesMain(site, view)
1714
2030
  : undefined;
1715
2031
  }
@@ -1722,11 +2038,19 @@ export const resourcesMain = (site, rest) => {
1722
2038
  main: `<article class="res-page files-page resource-library"><div id="files-manager"></div></article>`,
1723
2039
  };
1724
2040
  }
1725
- if (!file && (kind === "dictionary" || kind === "code" || kind === "urls")) {
1726
- const index = resourceIndex(root, site.filePaths ?? filesSnapshot(root).files.map((item) => item.path));
2041
+ if (!file && (kind === "dictionary" || kind === "code"))
2042
+ return resourcesMain(site, "codeblocks");
2043
+ if (!file &&
2044
+ (kind === "codeblocks" ||
2045
+ kind === "urls" ||
2046
+ kind === "url-previews" ||
2047
+ kind === "_subformats")) {
2048
+ const index = resourceIndex(root, site.filePaths ?? filesSnapshot(root).files.map((item) => item.path), site.previews?.domains);
2049
+ if (site.workspace?.protocol === "git" && index.subformats.length)
2050
+ setSubformatChanges(root, index.subformats);
1727
2051
  return {
1728
- title: "Statics",
1729
- main: `<article class="res-page files-page resource-library">${resourceTabs(kind)}${resourceLibraryHtml(index, kind)}</article>`,
2052
+ title: kind === "_subformats" ? "Subformats" : "Statics",
2053
+ main: `<article class="res-page files-page resource-library">${kind === "_subformats" ? "" : resourceTabs(kind)}${resourceLibraryHtml(index, kind === "_subformats" ? "subformats" : kind)}</article>`,
1730
2054
  };
1731
2055
  }
1732
2056
  if (kind === "file" && file) {
@@ -1832,13 +2156,21 @@ const pageTitle = (mode, title, siteTitle) => title === siteTitle ? title : `${t
1832
2156
  const page = (mode, site, opts) => {
1833
2157
  const nav = navGroupsHtml(mode, site, opts.currentId, opts.currentRes);
1834
2158
  const siteTitle = escapeHtml(site.title ?? "dooc");
1835
- const siteIcon = `<span id="site-icon-slot"${mode === "edit" ? ' title="Change site icon" data-i18n-title="Change site icon"' : ""}><img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>${DOCS_ICON}${mode === "edit" ? '<input type="file" accept=".svg,image/svg+xml" aria-label="Change site icon" data-i18n-aria-label="Change site icon">' : ""}</span>`;
2159
+ const iconImg = `<img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>`;
2160
+ const iconVariants = Object.entries(site.iconVariants ?? {});
2161
+ // The base image sits in a wrapper so theme switching and edit-client's #site-icon.hidden never fight.
2162
+ const iconHtml = iconVariants.length
2163
+ ? `<span class="site-icon-variants" data-theme-variants><span data-theme-variant="">${iconImg}</span>${iconVariants.map(([theme, svg]) => `<img data-theme-variant="${escapeHtml(theme)}" alt="" src="${svgDataUri(svg)}" hidden>`).join("")}</span>`
2164
+ : iconImg;
2165
+ const siteIcon = `<span id="site-icon-slot"${mode === "edit" ? ' title="Change site icon" data-i18n-title="Change site icon"' : ""}>${iconHtml}${DOCS_ICON}${mode === "edit" ? '<input type="file" accept=".svg,image/svg+xml" aria-label="Change site icon" data-i18n-aria-label="Change site icon">' : ""}</span>`;
1836
2166
  const bootScripts = opts.boot != null
1837
2167
  ? `<script id="boot" type="application/json">${JSON.stringify(opts.boot).replace(/</g, "\\u003c")}</script>
1838
2168
  <script src="/assets/edit.js"></script>`
1839
2169
  : !opts.publish
1840
2170
  ? '<script src="/assets/ui.js"></script>'
1841
- : "";
2171
+ : opts.publish.subformatJs
2172
+ ? `<script>${inlineScript(opts.publish.subformatJs)}</script>`
2173
+ : "";
1842
2174
  // Interaction layer of the schema graph (zoom / pan / box drag / enlarged view). Shared by
1843
2175
  // preview / edit. Figures are readable without JS, so defer is enough (= progressive
1844
2176
  // enhancement).
@@ -1847,23 +2179,29 @@ const page = (mode, site, opts) => {
1847
2179
 
1848
2180
 
1849
2181
  <div id="preview-language-menu" role="menu" aria-label="Change language" data-i18n-aria-label="Change language" hidden></div>
1850
- <div id="preview-panes"><section class="preview-pane active" tabindex="0" aria-label="Active pane" data-i18n-aria-label="Active pane"><div class="pane-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("viewer")}<button class="pbtn pane-language" type="button" aria-haspopup="menu" aria-expanded="false" aria-controls="preview-language-menu" aria-label="Change language" data-i18n-aria-label="Change language" title="Change language" data-i18n-title="Change language">${GLOBE_ICON}</button></div><div class="preview-content">${opts.main}</div></section></div></main>`
2182
+ <div id="preview-panes"${opts.currentRes !== undefined ? " hidden" : ""}><section class="preview-pane active" tabindex="0" aria-label="Active pane" data-i18n-aria-label="Active pane"><div class="pane-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("viewer")}<button class="pbtn pane-language" type="button" aria-haspopup="menu" aria-expanded="false" aria-controls="preview-language-menu" aria-label="Change language" data-i18n-aria-label="Change language" title="Change language" data-i18n-title="Change language">${GLOBE_ICON}</button></div><div class="preview-content">${opts.main}</div></section></div></main>`
1851
2183
  : mode === "edit" && opts.currentRes !== undefined
1852
2184
  ? `<main class="resources-pane">${opts.main}</main>`
1853
2185
  : `<main><div class="page-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("viewer")}</div>${opts.main}</main>`;
1854
2186
  const graphScript = opts.publish
1855
2187
  ? `<script>${inlineScript(opts.publish.graphJs)}</script>`
1856
- : '<script src="/assets/graph.js" defer></script>';
2188
+ : `<script>(${loadPreviewScript.toString()})("/assets/graph.js", "svg[data-sg-layout], [data-mermaid]", "module");</script>`;
1857
2189
  return `<!doctype html><html lang="en"><head><meta charset="utf-8">
1858
- ${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline' data:; img-src data: blob:; media-src data: blob:; font-src data: blob:; frame-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'">`}` : ""}
2190
+ ${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline' data:; img-src data: blob:; media-src data: blob:; object-src data:; font-src data: blob:; frame-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'">`}` : ""}
1859
2191
  <meta name="viewport" content="width=device-width, initial-scale=1">
1860
2192
  <title>${escapeHtml(pageTitle(mode, opts.title, site.title))}</title>
1861
- <script>try{const t=localStorage.getItem("docs-preview:theme");if(t)document.documentElement.dataset.theme=t;const e=localStorage.getItem("docs-editor:theme");if(e)document.documentElement.dataset.editorTheme=e}catch{}</script>
2193
+ <script>var __name = (f) => f;
2194
+ (${initializeThemes.toString()})(${JSON.stringify(site.themes)});
2195
+ (${mountFigureFrames.toString()})(document);</script>
1862
2196
  <style>${fontCss(Boolean(opts.publish))}${CSS}${mode === "edit" ? EDIT_CSS : ""}</style></head>
1863
- <body${mode === "edit" ? ' class="edit"' : ""}><nav id="sidebar"><div id="sidebar-resize" class="panel-resize" role="separator" tabindex="0" aria-orientation="vertical" aria-controls="sidebar" aria-label="Resize sidebar" data-i18n-aria-label="Resize sidebar" title="Resize sidebar" data-i18n-title="Resize sidebar"></div><div id="sidebar-head">${siteIcon}<div id="site-title" class="site-title" title="${siteTitle}"${mode === "edit" ? ` data-title="${escapeHtml(site.title ?? "")}" tabindex="0" role="button" aria-label="Edit site title" data-i18n-aria-label="Edit site title"` : ""}>${siteTitle}</div><button id="sidebar-toggle" type="button" aria-controls="sidebar-content" aria-expanded="true" title="Close sidebar" data-i18n-title="Close sidebar">${SIDEBAR_ICON}</button></div><div id="sidebar-content"><div id="nav-groups">${nav}</div><div id="nav-status" role="status" aria-live="polite"></div></div></nav>${main}${opts.aside ?? ""}
2197
+ <body${mode === "edit" ? ' class="edit"' : ""}${site.sourceBase ? ` data-source-base="${escapeHtml(site.sourceBase)}"` : ""}><nav id="sidebar"><div id="sidebar-resize" class="panel-resize" role="separator" tabindex="0" aria-orientation="vertical" aria-controls="sidebar" aria-label="Resize sidebar" data-i18n-aria-label="Resize sidebar" title="Resize sidebar" data-i18n-title="Resize sidebar"></div><div id="sidebar-head">${siteIcon}<div id="site-title" class="site-title" title="${siteTitle}"${mode === "edit" ? ` data-title="${escapeHtml(site.title ?? "")}" tabindex="0" role="button" aria-label="Edit site title" data-i18n-aria-label="Edit site title"` : ""}>${siteTitle}</div><button id="sidebar-toggle" type="button" aria-controls="sidebar-content" aria-expanded="true" title="Close sidebar" data-i18n-title="Close sidebar">${SIDEBAR_ICON}</button></div><div id="sidebar-content"><div id="nav-groups">${nav}</div><div id="nav-status" role="status" aria-live="polite"></div></div></nav>${main}${opts.aside ?? ""}
2198
+ <script>
2199
+ (${mountThemePickers.toString()})(${JSON.stringify(THEME_ICONS)}, ${JSON.stringify(site.themes)});
2200
+ (${mountThemeVariants.toString()})(document);
2201
+ </script>
1864
2202
  ${bootScripts}${graphScript}
1865
- <script id="code-grammars" type="application/json">${JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c")}</script>
1866
- ${opts.publish ? `<script>${inlineScript(opts.publish.codeJs)}</script>` : '<script src="/assets/code.js" defer></script>'}
2203
+ <script id="code-grammars" type="application/json"${opts.publish ? "" : ' data-src="/assets/code-grammars.json"'}>${opts.publish ? JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c") : "[]"}</script>
2204
+ ${opts.publish ? `<script>${inlineScript(opts.publish.codeJs)}</script>` : `<script>(${loadPreviewScript.toString()})("/assets/code.js", ".codeblk");</script>`}
1867
2205
  <script>
1868
2206
  // Functions toString'd under tsx (esbuild keepNames) contain __name(...) calls; define a no-op.
1869
2207
  var __name = (f) => f;
@@ -1873,9 +2211,7 @@ const localeFetch = (url, init = {}) => fetch(url, { ...init, headers: { ...init
1873
2211
  (${mountTables.toString()})(document);
1874
2212
  (${mountToc.toString()})(document);
1875
2213
  (${mountVideos.toString()})(document);
1876
- (${mountFigureFrames.toString()})(document);
1877
- (${mountThemeVariants.toString()})(document);
1878
- (${mountThemePickers.toString()})(${JSON.stringify(THEME_ICONS)}, ${JSON.stringify(site.themes)});
2214
+ ${opts.publish ? "" : `(${mountFigurePreviews.toString()})();`}
1879
2215
  void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.stringify(site.fonts ?? []).replace(/</g, "\\u003c")});
1880
2216
  (() => {
1881
2217
  const KEY = "docs:sidebar-open";
@@ -1907,7 +2243,6 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1907
2243
  }, true);
1908
2244
  })();
1909
2245
  (${mountPanelResize.toString()})();
1910
- (${mountToolsResize.toString()})();
1911
2246
  (() => {
1912
2247
  // Open/close: by default "the branch containing the current doc is open" (the server adds
1913
2248
  // .open), overridden by explicit user actions (sessionStorage = per tab only).
@@ -1915,6 +2250,8 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1915
2250
  const readOpen = () => { try { return JSON.parse(sessionStorage.getItem(OPEN_KEY) || "{}"); } catch { return {}; } };
1916
2251
  const applyOpen = () => {
1917
2252
  const o = readOpen();
2253
+ const tools = document.getElementById("nav-tools");
2254
+ if (tools) tools.open = o._tools !== false;
1918
2255
  for (const it of document.querySelectorAll("#nav-groups .nav-item")) {
1919
2256
  const key = it.dataset.docId || it.dataset.nodeId;
1920
2257
  if (key in o) it.classList.toggle("open", o[key]);
@@ -1935,6 +2272,11 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1935
2272
  const it = t.closest(".nav-item");
1936
2273
  window.__docsNavOpen(it.dataset.docId || it.dataset.nodeId, !it.classList.contains("open"));
1937
2274
  });
2275
+ document.addEventListener("toggle", (event) => {
2276
+ const tools = event.target;
2277
+ if (tools instanceof HTMLDetailsElement && tools.id === "nav-tools" && tools.isConnected)
2278
+ window.__docsNavOpen("_tools", tools.open);
2279
+ }, true);
1938
2280
  applyOpen();
1939
2281
  window.__docsNavRestore = applyOpen;
1940
2282
  const nav = document.getElementById("nav-groups");
@@ -1942,12 +2284,12 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1942
2284
  })();
1943
2285
  ${mode === "edit"
1944
2286
  ? `(() => {
1945
- // Sidebar tree editing (delegated to document — keeps working when HMR swaps #nav-groups).
2287
+ // Sidebar tree editing stays delegated while navigation nodes are reconciled.
1946
2288
  // drag: top 1/4 of a row = before, bottom 1/4 = after, middle = move into that doc's children
1947
2289
  // (at the end). The DOM isn't moved, only a marker is shown; on drop, POST /api/move →
1948
2290
  // re-fetch the nav regardless of the outcome (= the display is always a copy of
1949
2291
  // dooc.yaml; no rollback logic).
1950
- // The root placeholder and row buttons open the create form.
2292
+ // The root placeholder and row buttons open the page type menu.
1951
2293
  const t = (key) => window.__docsTranslate?.(key) ?? key;
1952
2294
  const status = document.getElementById("nav-status");
1953
2295
  const setStatus = (message, error) => {
@@ -1959,11 +2301,13 @@ ${mode === "edit"
1959
2301
  if (window.__docsRefreshNav) return window.__docsRefreshNav();
1960
2302
  const cur = document.querySelector("#nav-groups .nav-row a.cur");
1961
2303
  const id = (cur && cur.closest(".nav-item").dataset.docId) || "";
1962
- const rp = location.pathname.startsWith("/_statics") ? location.pathname.slice(1) : ["/_git", "/_extensions"].includes(location.pathname) ? location.pathname.slice(1) : location.pathname.startsWith("/_files") ? location.pathname.slice(8).replace(/^\\/|\\/$/g, "") : null;
2304
+ const rp = location.pathname.startsWith("/_statics") ? location.pathname.slice(1) : ["/_git", "/_extensions", "/_subformats"].includes(location.pathname) ? location.pathname.slice(1) : location.pathname.startsWith("/_files") ? location.pathname.slice(8).replace(/^\\/|\\/$/g, "") : null;
1963
2305
  const res = await localeFetch("/api/nav?current=" + encodeURIComponent(id) + (rp == null ? "" : "&res=" + encodeURIComponent(rp)));
1964
2306
  if (res.ok) {
1965
2307
  const data = await res.json();
1966
- document.getElementById("nav-groups").innerHTML = data.html;
2308
+ (${updateNav.toString()})(document.getElementById("nav-groups"), data.html);
2309
+ const currentPage = document.querySelector('[data-subformat-nav][data-doc-id="' + CSS.escape(id) + '"] > .nav-row > a');
2310
+ if (currentPage && currentPage.pathname !== location.pathname) history.replaceState(null, "", currentPage.href);
1967
2311
  const label = document.getElementById("site-title");
1968
2312
  if (!label.querySelector("form")) label.textContent = label.title = data.siteTitle || "dooc";
1969
2313
  label.dataset.title = data.siteTitle || "";
@@ -1980,6 +2324,10 @@ ${mode === "edit"
1980
2324
  };
1981
2325
 
1982
2326
  const docAction = (item, action) => {
2327
+ if (item.hasAttribute("data-subformat-nav")) {
2328
+ document.dispatchEvent(new CustomEvent("docs:subformat-page-action", { detail: { id: item.dataset.docId, action } }));
2329
+ return;
2330
+ }
1983
2331
  if (window.__docsDocAction) {
1984
2332
  void window.__docsDocAction(item.dataset.docId, action);
1985
2333
  } else {
@@ -2039,7 +2387,7 @@ ${mode === "edit"
2039
2387
  busy = true;
2040
2388
  input.readOnly = true;
2041
2389
  try {
2042
- const result = await post("/api/site-title", { title: input.value, baseTitle });
2390
+ const result = await post("/api/site-title", { title: input.value, baseTitle, language: new URL(location.href).searchParams.get("lang") });
2043
2391
  closed = true;
2044
2392
  form.remove();
2045
2393
  label.textContent = label.title = result.title;
@@ -2081,7 +2429,7 @@ ${mode === "edit"
2081
2429
  const id = slot.closest(".nav-item")?.dataset.docId;
2082
2430
  try {
2083
2431
  const data = file ? btoa(Array.from(new Uint8Array(await file.arrayBuffer()), (byte) => String.fromCharCode(byte)).join("")) : null;
2084
- const result = await post(id ? "/api/icon" : "/api/site-icon", { file: id ? id + ".md" : undefined, data });
2432
+ const result = await post(id ? "/api/icon" : "/api/site-icon", { file: id ? id + ".md" : undefined, data, theme: getComputedStyle(document.documentElement).colorScheme === "dark" ? "dark" : "light" });
2085
2433
  if (!id) {
2086
2434
  const logo = document.getElementById("site-icon");
2087
2435
  logo.src = result.icon;
@@ -2195,18 +2543,18 @@ ${mode === "edit"
2195
2543
 
2196
2544
  document.addEventListener("docs:files-changed", () => { void refresh(); });
2197
2545
 
2198
- // ── In-sidebar create form ──
2546
+ // ── Page type menu and in-sidebar create form ──
2199
2547
  const suggestFileName = ${suggestDocFileName.toString()};
2548
+ const availableSubformats = () => JSON.parse(document.querySelector("[data-page-subformats]")?.content.textContent || "[]");
2200
2549
  const closeForm = () => { for (const f of document.querySelectorAll(".nav-new-item")) f.remove(); };
2201
- const openForm = (parent) => {
2550
+ const openForm = (trigger) => {
2202
2551
  closeForm();
2552
+ const parent = trigger.dataset.parent || "";
2203
2553
  const host = parent
2204
2554
  ? document.querySelector('#nav-groups .nav-item[data-doc-id="' + CSS.escape(parent) + '"] > .nav-list')
2205
2555
  : document.querySelector("#nav-groups > .nav-list");
2206
2556
  if (!host) return;
2207
- if (parent) {
2208
- window.__docsNavOpen(parent, true);
2209
- }
2557
+ if (parent) window.__docsNavOpen(parent, true);
2210
2558
  const item = document.createElement("div");
2211
2559
  item.className = "nav-item nav-new-item";
2212
2560
  const row = document.createElement("div");
@@ -2214,11 +2562,11 @@ ${mode === "edit"
2214
2562
  const form = document.createElement("form");
2215
2563
  form.className = "nav-new";
2216
2564
  form.innerHTML =
2217
- ${JSON.stringify(DOCS_ICON)} +
2218
- '<input name="title" placeholder="title" data-i18n-placeholder="title" required autocomplete="off">' +
2219
- '<div class="nav-new-file"><input name="name" placeholder="File name" data-i18n-placeholder="File name" aria-label="File name" data-i18n-aria-label="File name" required autocomplete="off" spellcheck="false">' +
2220
- '<button class="nav-new-go" type="submit" title="Create" data-i18n-title="Create" aria-label="Create" data-i18n-aria-label="Create">↵</button></div>' +
2221
- '<div class="err"></div>';
2565
+ '<p class="nav-new-heading" data-i18n="Markdown page">Markdown page</p>' +
2566
+ '<input name="title" placeholder="title" data-i18n-placeholder="title" aria-label="title" data-i18n-aria-label="title" required autocomplete="off">' +
2567
+ '<div class="nav-new-file"><input name="name" placeholder="File name" data-i18n-placeholder="File name" aria-label="File name" data-i18n-aria-label="File name" required autocomplete="off" spellcheck="false"></div>' +
2568
+ '<div class="nav-new-actions"><button type="button" class="nav-new-cancel" data-i18n="Cancel">Cancel</button><button class="nav-new-go" type="submit" data-i18n="Create">Create</button></div>' +
2569
+ '<div class="err" role="alert"></div>';
2222
2570
  row.append(form);
2223
2571
  item.append(row);
2224
2572
  host.append(item);
@@ -2229,11 +2577,18 @@ ${mode === "edit"
2229
2577
  const err = form.querySelector(".err");
2230
2578
  let nameTouched = false;
2231
2579
  let busy = false;
2580
+ const cancel = () => {
2581
+ if (busy) return;
2582
+ closeForm();
2583
+ trigger.focus();
2584
+ };
2585
+ form.querySelector(".nav-new-cancel").addEventListener("click", cancel);
2232
2586
  title.addEventListener("input", () => { if (!nameTouched) nameInput.value = suggestFileName(title.value); });
2233
2587
  nameInput.addEventListener("input", () => { nameTouched = true; });
2234
- form.addEventListener("keydown", (e) => { if (e.key === "Escape" && !busy) closeForm(); });
2235
- // Close when focus moves out with nothing typed (keep partially filled forms).
2236
- // (remove itself fires focusout, so defer one tick and close only if still there)
2588
+ form.addEventListener("keydown", (e) => {
2589
+ if (e.key === "Escape") { e.preventDefault(); cancel(); }
2590
+ });
2591
+ // Keep partially filled forms when focus moves elsewhere.
2237
2592
  form.addEventListener("focusout", (e) => {
2238
2593
  if (busy || form.contains(e.relatedTarget) || title.value.trim() || nameInput.value.trim()) return;
2239
2594
  setTimeout(() => { if (item.isConnected && !item.contains(document.activeElement)) item.remove(); }, 0);
@@ -2245,7 +2600,7 @@ ${mode === "edit"
2245
2600
  submit.setAttribute("aria-busy", "true");
2246
2601
  err.textContent = "";
2247
2602
  try {
2248
- await post("/api/create", { parent: parent || undefined, name: nameInput.value.trim(), title: title.value.trim() });
2603
+ await post("/api/create", { parent: parent || undefined, title: title.value.trim(), name: nameInput.value.trim() });
2249
2604
  closeForm();
2250
2605
  await refresh();
2251
2606
  } catch (error) {
@@ -2258,11 +2613,121 @@ ${mode === "edit"
2258
2613
  item.scrollIntoView({ block: "nearest" });
2259
2614
  title.focus();
2260
2615
  };
2616
+ const menu = document.createElement("div");
2617
+ menu.id = "nav-page-menu";
2618
+ menu.className = "nav-page-menu";
2619
+ menu.popover = "auto";
2620
+ menu.setAttribute("role", "menu");
2621
+ menu.setAttribute("aria-label", t("Page type"));
2622
+ menu.dataset.i18nAriaLabel = "Page type";
2623
+ menu.innerHTML = '<button type="button" role="menuitem" tabindex="-1" data-page-type="markdown">${DOCS_ICON}Markdown</button><button type="button" role="menuitem" tabindex="-1" data-page-type="subformat" aria-haspopup="menu" popovertarget="nav-subformat-menu">${SUBFORMATS_ICON}Subformat<span class="nav-page-chevron">${CHEVRON_ICON}</span></button><div id="nav-subformat-menu" class="subformat-picker-menu subformat-setting-menu" role="menu" aria-label="Subformat" popover="auto"></div><p class="err" role="alert"></p>';
2624
+ document.body.append(menu);
2625
+ const formatsMenu = menu.querySelector("#nav-subformat-menu");
2626
+ const formatTrigger = menu.querySelector('[data-page-type="subformat"]');
2627
+ const markdownTrigger = menu.querySelector('[data-page-type="markdown"]');
2628
+ const menuError = menu.querySelector(".err");
2629
+ let menuTrigger;
2630
+ let addingPage = false;
2631
+ const showMenu = (popup, trigger) => {
2632
+ popup.style.maxHeight = "";
2633
+ popup.showPopover();
2634
+ const rect = trigger.getBoundingClientRect();
2635
+ const top = popup === menu ? rect.top : rect.bottom + 4;
2636
+ const bottom = popup === menu ? rect.bottom : rect.top - 4;
2637
+ const above = innerHeight - top < popup.offsetHeight + 8 && bottom > innerHeight - top;
2638
+ Object.assign(popup.style, {
2639
+ left: Math.max(8, Math.min(rect.left, innerWidth - popup.offsetWidth - 8)) + "px",
2640
+ top: above ? "auto" : top + "px",
2641
+ bottom: above ? innerHeight - bottom + "px" : "auto",
2642
+ maxHeight: Math.max(80, (above ? bottom : innerHeight - top) - 8) + "px",
2643
+ });
2644
+ popup.querySelector("button:not(:disabled)")?.focus();
2645
+ };
2646
+ markdownTrigger.addEventListener("click", () => {
2647
+ if (addingPage) return;
2648
+ menu.hidePopover();
2649
+ openForm(menuTrigger);
2650
+ });
2651
+ formatTrigger.addEventListener("click", (event) => {
2652
+ event.preventDefault();
2653
+ if (addingPage) return;
2654
+ if (formatsMenu.matches(":popover-open")) { formatsMenu.hidePopover(); return; }
2655
+ formatsMenu.replaceChildren();
2656
+ for (const format of availableSubformats()) {
2657
+ const row = document.createElement("div");
2658
+ row.className = "subformat-setting-option";
2659
+ row.setAttribute("role", "none");
2660
+ const option = document.createElement("button");
2661
+ option.type = "button";
2662
+ option.tabIndex = -1;
2663
+ option.setAttribute("role", "menuitem");
2664
+ option.dataset.subformat = format.ext;
2665
+ option.textContent = format.ext;
2666
+ row.append(option);
2667
+ formatsMenu.append(row);
2668
+ }
2669
+ showMenu(formatsMenu, formatTrigger);
2670
+ });
2671
+ formatsMenu.addEventListener("click", async (event) => {
2672
+ const option = event.target.closest("button[data-subformat]");
2673
+ if (!option || addingPage) return;
2674
+ const parent = menuTrigger.dataset.parent || undefined;
2675
+ const subformat = option.dataset.subformat;
2676
+ addingPage = markdownTrigger.disabled = formatTrigger.disabled = true;
2677
+ menu.setAttribute("aria-busy", "true");
2678
+ menuError.textContent = "";
2679
+ setStatus("", false);
2680
+ formatsMenu.hidePopover();
2681
+ try {
2682
+ const result = await post("/api/create", { parent, subformat, title: subformat });
2683
+ menu.hidePopover();
2684
+ await refresh();
2685
+ if (result.path) {
2686
+ if (window.__docsNavigate) await window.__docsNavigate(result.path);
2687
+ else location.href = result.path;
2688
+ }
2689
+ } catch (error) {
2690
+ menuError.textContent = error.message;
2691
+ if (!menu.matches(":popover-open")) setStatus(error.message, true);
2692
+ } finally {
2693
+ addingPage = markdownTrigger.disabled = false;
2694
+ formatTrigger.disabled = !availableSubformats().length;
2695
+ menu.removeAttribute("aria-busy");
2696
+ if (menu.matches(":popover-open")) formatTrigger.focus();
2697
+ }
2698
+ });
2699
+ menu.addEventListener("keydown", (event) => {
2700
+ const popup = event.target.closest('[role="menu"]');
2701
+ const options = [...popup.querySelectorAll("button:not(:disabled)")].filter((button) => button.closest('[role="menu"]') === popup);
2702
+ const index = options.indexOf(document.activeElement);
2703
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
2704
+ event.preventDefault();
2705
+ const next = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : (index + (event.key === "ArrowDown" ? 1 : options.length - 1)) % options.length;
2706
+ options[next]?.focus();
2707
+ }
2708
+ if (event.key === "Escape" || event.key === "Tab") {
2709
+ const dismiss = event.key === "Tab" ? menu : popup;
2710
+ dismiss.hidePopover();
2711
+ (dismiss === menu ? menuTrigger : formatTrigger)?.focus();
2712
+ if (event.key === "Escape") event.preventDefault();
2713
+ }
2714
+ });
2261
2715
  document.addEventListener("click", (event) => {
2262
2716
  const btn = event.target instanceof Element ? event.target.closest("#sidebar .new, #sidebar .nav-create") : null;
2263
2717
  if (!btn) return;
2264
2718
  event.preventDefault();
2265
- openForm(btn.dataset.parent || "");
2719
+ if (addingPage) return;
2720
+ if (menu.matches(":popover-open")) {
2721
+ menu.hidePopover();
2722
+ if (menuTrigger === btn) return;
2723
+ }
2724
+ menuTrigger = btn;
2725
+ const unavailable = !availableSubformats().length;
2726
+ formatTrigger.disabled = unavailable;
2727
+ formatTrigger.title = unavailable ? t("No subformats available to add.") : "";
2728
+ menuError.textContent = "";
2729
+ menu.setAttribute("aria-label", t("Page type"));
2730
+ showMenu(menu, btn);
2266
2731
  });
2267
2732
  })();`
2268
2733
  : ""}
@@ -2317,7 +2782,7 @@ document.addEventListener("click", (ev) => {
2317
2782
  });
2318
2783
  </script>
2319
2784
  <script>${inlineScript(`(${mountSearch.toString()})(${JSON.stringify(opts.publish ? searchIndex(site) : []).replace(/</g, "\\u003c")}, ${searchSections.toString()}, ${JSON.stringify(Object.fromEntries(SEARCH_LABELS.map((key) => [key, translate(site.defaultLang, key)]))).replace(/</g, "\\u003c")}, ${Boolean(opts.publish)});`)}</script>
2320
- ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publish.first)}${opts.publish.network ? `\n(${mountBundleNetwork.toString()})();` : ""}</script>` : `<script>${hmrClientScript(mode)}</script>`}</body></html>`;
2785
+ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publish.first)}${opts.publish.network && !opts.publish.pluginJs ? `\n(${mountBundleNetwork.toString()})();` : ""}</script>${opts.publish.pluginJs ? `<script>${inlineScript(opts.publish.pluginJs)}</script>` : ""}` : `<script>${hmrClientScript(mode)}</script>`}</body></html>`;
2321
2786
  };
2322
2787
  // A `</script` inside an inline <script> would close the script early, so escape it.
2323
2788
  const inlineScript = (js) => js.replace(/<\/(script)/gi, "<\\/$1");
@@ -2337,6 +2802,7 @@ const publishRouterScript = (first) => `
2337
2802
  const page = pages.get(route);
2338
2803
  const actions = main.querySelector(":scope > .page-actions");
2339
2804
  main.innerHTML = page.innerHTML;
2805
+ document.dispatchEvent(new Event("docs:page-shown"));
2340
2806
  if (actions) main.prepend(actions);
2341
2807
  document.title = page.dataset.title;
2342
2808
  for (const a of document.querySelectorAll("#nav-groups a")) {
@@ -2349,7 +2815,7 @@ const publishRouterScript = (first) => `
2349
2815
  (${focusNavTree.toString()})(document.getElementById("nav-groups"));
2350
2816
  const target = anchor && document.getElementById(anchor);
2351
2817
  requestAnimationFrame(() => {
2352
- if (target) target.scrollIntoView(); else window.scrollTo(0, 0);
2818
+ if (target) target.scrollIntoView(); else main.scrollTo(0, 0);
2353
2819
  });
2354
2820
  };
2355
2821
  window.addEventListener("hashchange", show);
@@ -2365,7 +2831,7 @@ const toHashLinks = (html, route) => html
2365
2831
  * down to figures / terms / schema graph JS). Each doc is held in a
2366
2832
  * <template> and switched via hash routes.
2367
2833
  */
2368
- export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static") => {
2834
+ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static", pluginJs = "", subformatJs = "") => {
2369
2835
  const pages = site.entries.map((e) => ({
2370
2836
  route: docPath(site.entries, e.id).slice(1),
2371
2837
  title: docDisplayName(e.frontmatter, e.id),
@@ -2391,7 +2857,15 @@ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs
2391
2857
  return toHashLinks(page("preview", { ...site, title }, {
2392
2858
  title,
2393
2859
  main: "",
2394
- publish: { graphJs, codeJs, pages: templates, first, network: mode === "network" },
2860
+ publish: {
2861
+ graphJs,
2862
+ codeJs,
2863
+ pages: templates,
2864
+ first,
2865
+ network: mode !== "static",
2866
+ pluginJs: mode === "live" ? pluginJs : undefined,
2867
+ subformatJs,
2868
+ },
2395
2869
  }), first);
2396
2870
  };
2397
2871
  // A doc's main content. A doc with an empty body and children (a chapter-heading-only doc) shows
@@ -2399,7 +2873,7 @@ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs
2399
2873
  const entryMain = (site, e) => {
2400
2874
  const html = renderEntryHtml(site, e).html;
2401
2875
  const kids = childrenOf(site.entries, e.id);
2402
- if (e.blocks.length > 0 || kids.length === 0) {
2876
+ if (e.subformat || e.blocks.length > 0 || kids.length === 0) {
2403
2877
  return html;
2404
2878
  }
2405
2879
  const items = kids
@@ -2421,7 +2895,9 @@ export const languageFieldHtml = (defaultLang, language = contentLanguageCode(de
2421
2895
  export const editorBoot = (entry, site) => {
2422
2896
  // Completion candidates are files in the figures/ catalog.
2423
2897
  const figures = [...site.ctx.figures.values()].map((f) => f.file);
2424
- const docs = site.entries.map((e) => ({
2898
+ const docs = site.entries
2899
+ .filter((e) => !e.subformat)
2900
+ .map((e) => ({
2425
2901
  ref: e.sourceFile ?? CONTENT_PREFIX + e.file,
2426
2902
  title: docDisplayName(e.frontmatter, e.id),
2427
2903
  }));
@@ -2460,19 +2936,20 @@ export const editorBoot = (entry, site) => {
2460
2936
  const editorAside = (entry, site) => {
2461
2937
  const aside = `<aside id="panel"><div id="resize" class="panel-resize" role="separator" tabindex="0" aria-orientation="vertical" aria-controls="panel" aria-label="Resize editor" data-i18n-aria-label="Resize editor" title="Resize editor" data-i18n-title="Resize editor"></div>
2462
2938
  <div id="phead">
2463
- <button class="pbtn" type="button" data-theme-picker="editor" aria-label="Editor theme"></button>
2464
- ${fontButton("editor")}
2465
2939
  ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLanguages, site.contentLanguages)}
2466
2940
  <span id="status"></span>
2467
2941
  <button id="validate" class="pbtn" type="button" title="Validate and apply" data-i18n-title="Validate and apply" aria-label="Validate and apply" data-i18n-aria-label="Validate and apply">${icon('<path d="M5 5l-4 5 4 5M15 5l4 5-4 5M7 10l2 2 4-5"/>')}</button>
2468
2942
  <button id="save" class="pbtn" data-state="saved" type="button" title="Save (Ctrl+S)" data-i18n-title="Save (Ctrl+S)" aria-label="Save" data-i18n-aria-label="Save">${icon('<path d="M3 3h11l3 3v11H3z"/><path d="M6 3v5h7V3M6 17v-6h8v6"/>')}</button>
2469
2943
  <button id="split-preview" class="pbtn" type="button" aria-pressed="false" aria-label="Split view" data-i18n-aria-label="Split view" title="Split view" data-i18n-title="Split view">${icon('<rect x="3" y="3" width="14" height="14" rx="2"/><path d="M10 3v14"/>')}</button>
2470
2944
  <div id="gear"><button class="pbtn" type="button" aria-haspopup="true" aria-label="View settings" data-i18n-aria-label="View settings" title="View settings" data-i18n-title="View settings">${GEAR_ICON}</button><div id="gearmenu">
2471
- <div id="language-setting"><select id="ui-language" aria-label="Editor language" data-i18n-aria-label="Language"><option value="eng">English</option><option value="jpn">日本語</option><option value="zho">中文</option></select></div>
2945
+ <div class="editor-setting"><span class="editor-setting-icon" data-setting-theme-icon aria-hidden="true"></span><div class="subformat-control"><span class="subformat-control-label" data-i18n="Editor theme">Editor theme</span><button class="setting-picker" type="button" data-theme-picker="editor" aria-label="Editor theme"><span data-picker-value></span>${SELECT_ICON}</button></div></div>
2946
+ <div class="editor-setting"><span class="editor-setting-icon" aria-hidden="true">${FONT_ICON}</span><div class="subformat-control"><span class="subformat-control-label" data-i18n="Editor font">Editor font</span>${fontButton("editor")}</div></div>
2947
+ <div id="language-setting" class="editor-setting">${GLOBE_ICON}<div class="subformat-control"><span class="subformat-control-label" data-i18n="Language">Editor language</span><select id="ui-language" aria-label="Editor language" data-i18n-aria-label="Language"><option value="eng">English</option><option value="jpn">日本語</option><option value="zho">中文</option></select></div></div>
2472
2948
  <label><input type="checkbox" id="opt-autovalidate"><span data-i18n="Auto validate">Auto validate</span></label>
2473
2949
  <label><input type="checkbox" id="opt-autosave"><span data-i18n="Auto save">Auto save</span></label>
2474
2950
  <label><input type="checkbox" id="opt-corr"><span data-i18n="Source mapping">Source mapping</span></label>
2475
2951
  <label><input type="checkbox" id="opt-git-diff"><span data-i18n="Show Git changes">Show Git changes</span></label>
2952
+ <label><input type="checkbox" id="opt-line-wrap" checked><span data-i18n="Wrap lines">Wrap lines</span></label>
2476
2953
  </div></div>
2477
2954
  </div>
2478
2955
 
@@ -2493,6 +2970,7 @@ export const pageDataResponse = (site, path) => {
2493
2970
  return { status: 400, body: { error: "route must be /<docId>" } };
2494
2971
  }
2495
2972
  if (path === "/_extensions" ||
2973
+ path === "/_subformats" ||
2496
2974
  path === "/_git" ||
2497
2975
  path === "/_statics" ||
2498
2976
  path.startsWith("/_statics/") ||
@@ -2501,7 +2979,7 @@ export const pageDataResponse = (site, path) => {
2501
2979
  try {
2502
2980
  const resource = resourcesMain(site, path.startsWith("/_statics")
2503
2981
  ? path.slice(1)
2504
- : ["/_git", "/_extensions"].includes(path)
2982
+ : ["/_git", "/_extensions", "/_subformats"].includes(path)
2505
2983
  ? path.slice(1)
2506
2984
  : path.slice("/_files".length).replace(/^\/|\/$/g, ""));
2507
2985
  return resource
@@ -2527,6 +3005,16 @@ export const pageDataResponse = (site, path) => {
2527
3005
  return { status: 404, body: { error: `${path} is not a doc route` } };
2528
3006
  }
2529
3007
  const html = entryMain(site, doc);
3008
+ if (doc.subformat)
3009
+ return {
3010
+ status: 200,
3011
+ body: {
3012
+ resource: true,
3013
+ path,
3014
+ title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site.title),
3015
+ html,
3016
+ },
3017
+ };
2530
3018
  const errors = [...site.errors, ...doc.errors];
2531
3019
  return {
2532
3020
  status: 200,
@@ -2646,7 +3134,7 @@ const handleDraft = async (req, res, save, locale) => {
2646
3134
  }
2647
3135
  }
2648
3136
  }
2649
- const draft = renderDraft(loadSite(locale), target.name, raw, fileDrafts);
3137
+ const draft = renderDraft(save ? loadSite(locale) : site, target.name, raw, fileDrafts);
2650
3138
  sendJson(res, 200, { ...draft, saved: save, conflict: false, raw });
2651
3139
  };
2652
3140
  // Prose lint (/api/lint) = the `lint` of the doc language's adapter (language socket); languages
@@ -2675,7 +3163,9 @@ const handleCreate = async (req, res) => {
2675
3163
  const name = typeof body?.name === "string" ? body.name.trim() : "";
2676
3164
  const title = typeof body?.title === "string" ? body.title.trim() : "";
2677
3165
  const parent = typeof body?.parent === "string" && body.parent !== "" ? body.parent : undefined;
2678
- const result = ops.addFile(name, title, parent);
3166
+ const result = typeof body?.subformat === "string"
3167
+ ? ops.addSubformat(body.subformat, title, parent)
3168
+ : ops.addFile(name, title, parent);
2679
3169
  sendOp(res, isOpError(result) ? result : { ...result, path: docPath(loadSite().entries, result.id) });
2680
3170
  };
2681
3171
  // Add a figure (sidebar file picker / drag-and-drop). Returns the written file name
@@ -2693,27 +3183,35 @@ const handleFigure = async (req, res) => {
2693
3183
  // writes icons/<id>.svg. Response icon = the new data URI (null if removed).
2694
3184
  const handleIcon = async (req, res) => {
2695
3185
  const body = await readJson(req);
2696
- const target = resolveContentFile(body?.file);
2697
- if (!target || !existsSync(target.abs)) {
2698
- sendJson(res, 404, { error: "target doc not found" });
2699
- return;
2700
- }
2701
3186
  const manifest = readManifest(root);
2702
3187
  if (manifest.errors.length) {
2703
3188
  sendJson(res, 409, { error: manifest.errors.join("\n") });
2704
3189
  return;
2705
3190
  }
2706
- const previous = docIconFile(target.id, manifest.files);
2707
- const file = manifest.files?.defaultLayout !== false &&
2708
- !Object.hasOwn(manifest.files?.icons ?? {}, target.id) &&
3191
+ const requestedId = typeof body?.file === "string" ? docIdOfFile(body.file) : undefined;
3192
+ const page = flattenTree(manifest.tree).find((node) => node.id === requestedId && node.subformat);
3193
+ const target = page ? undefined : resolveContentFile(body?.file);
3194
+ const id = page?.id ?? (target && existsSync(target.abs) ? target.id : undefined);
3195
+ if (!id) {
3196
+ sendJson(res, 404, { error: "target doc not found" });
3197
+ return;
3198
+ }
3199
+ const previous = docIconFile(id, manifest.files);
3200
+ const file = manifest.format !== "nested" &&
3201
+ manifest.files?.defaultLayout !== false &&
3202
+ !Object.hasOwn(manifest.files?.icons ?? {}, id) &&
2709
3203
  !existsSync(textfilePath(root, previous))
2710
- ? defaultFilePath(`${target.id}-icon.svg`)
3204
+ ? defaultFilePath(`${id}-icon.svg`)
2711
3205
  : previous;
2712
3206
  const path = textfilePath(root, file);
2713
3207
  if (body?.data == null) {
2714
3208
  if (existsSync(path)) {
2715
3209
  unlinkSync(path);
2716
3210
  }
3211
+ if (manifest.files?.icons && Object.hasOwn(manifest.files.icons, id)) {
3212
+ delete manifest.files.icons[id];
3213
+ writeManifest(root, manifest.tree, manifest);
3214
+ }
2717
3215
  sendJson(res, 200, { ok: true, icon: null });
2718
3216
  return;
2719
3217
  }
@@ -2733,7 +3231,7 @@ const handleIcon = async (req, res) => {
2733
3231
  if (file !== previous) {
2734
3232
  manifest.files ??= parseFileLayout({});
2735
3233
  manifest.files.icons ??= {};
2736
- manifest.files.icons[target.id] = file;
3234
+ manifest.files.icons[id] = file;
2737
3235
  writeManifest(root, manifest.tree, manifest);
2738
3236
  }
2739
3237
  sendJson(res, 200, { ok: true, icon: svgDataUri(svg) });
@@ -2818,9 +3316,12 @@ const PREBUILT = {
2818
3316
  "viewer/edit-client.ts": "edit.global.js",
2819
3317
  "viewer/ui-client.ts": "ui.global.js",
2820
3318
  "viewer/code-highlight.ts": "code.global.js",
3319
+ "viewer/code-worker.ts": "code-worker.global.js",
3320
+ "viewer/published-plugins.ts": "plugins.global.js",
3321
+ "viewer/published-subformats.ts": "subformats.global.js",
2821
3322
  };
2822
- /** Client bundle (src/<entry> as an IIFE). Sourcemap for the server, minified for publish. */
2823
- export const bundleClient = async (entry, publish = false) => {
3323
+ /** Minified client bundle shared by local viewing and published HTML. */
3324
+ export const bundleClient = async (entry) => {
2824
3325
  const prebuilt = PREBUILT[entry];
2825
3326
  if (usePrebuiltAssets && prebuilt) {
2826
3327
  return readViewerAsset(prebuilt).toString("utf8");
@@ -2832,7 +3333,7 @@ export const bundleClient = async (entry, publish = false) => {
2832
3333
  format: "iife",
2833
3334
  target: "es2022",
2834
3335
  write: false,
2835
- ...(publish ? { minify: true } : { sourcemap: "inline" }),
3336
+ minify: true,
2836
3337
  });
2837
3338
  return out.outputFiles?.[0]?.text ?? "";
2838
3339
  };
@@ -2857,6 +3358,33 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
2857
3358
  // invalidate explicitly on the watcher's "client" notification (changes to edit-client.ts /
2858
3359
  // the schema graph interaction layer's src/*.tsx).
2859
3360
  const bundleCache = createBundleCache();
3361
+ let graphChunks;
3362
+ const graphAsset = async (name) => {
3363
+ if (usePrebuiltAssets)
3364
+ return readViewerAsset(`graph/${name}`).toString("utf8");
3365
+ graphChunks ??= import("esbuild")
3366
+ .then(async (esbuild) => {
3367
+ const output = await esbuild.build({
3368
+ entryPoints: [join(pkgRoot, "src/core/schema-graph-global.tsx")],
3369
+ bundle: true,
3370
+ splitting: true,
3371
+ format: "esm",
3372
+ target: "es2022",
3373
+ outdir: join(pkgRoot, "dist/graph"),
3374
+ write: false,
3375
+ minify: true,
3376
+ });
3377
+ return new Map(output.outputFiles.map((file) => [basename(file.path), file.text]));
3378
+ })
3379
+ .catch((error) => {
3380
+ graphChunks = undefined;
3381
+ throw error;
3382
+ });
3383
+ const js = (await graphChunks).get(name);
3384
+ if (js === undefined)
3385
+ throw new Error("Diagram asset not found");
3386
+ return js;
3387
+ };
2860
3388
  // HMR — bootId changes on every process start. It's how the client detects a tsx watch
2861
3389
  // restart.
2862
3390
  const hub = createHmrHub(`${process.pid}-${Date.now()}`);
@@ -2903,6 +3431,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
2903
3431
  console.log(`hmr: ${kind} (${files.join(", ")})`);
2904
3432
  if (kind === "client") {
2905
3433
  bundleCache.clear();
3434
+ graphChunks = undefined;
2906
3435
  }
2907
3436
  hub.broadcast(kind, files);
2908
3437
  });
@@ -2949,15 +3478,22 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
2949
3478
  // preview / edit, edit.js is for the editing UI only.
2950
3479
  const clientEntry = path === "/assets/code.js"
2951
3480
  ? "viewer/code-highlight.ts"
2952
- : path === "/assets/graph.js"
2953
- ? "core/schema-graph-global.tsx"
3481
+ : path === "/assets/code-worker.js"
3482
+ ? "viewer/code-worker.ts"
2954
3483
  : mode === "edit" && path === "/assets/edit.js"
2955
3484
  ? "viewer/edit-client.ts"
2956
3485
  : path === "/assets/ui.js"
2957
3486
  ? "viewer/ui-client.ts"
2958
3487
  : undefined;
2959
- if (req.method === "GET" && clientEntry != null) {
2960
- const { js, etag } = await bundleCache.get(clientEntry, () => bundleClient(clientEntry));
3488
+ const graphName = path === "/assets/graph.js"
3489
+ ? "schema-graph-global.js"
3490
+ : /^\/assets\/graph\/([\w-]+\.js)$/.exec(path)?.[1];
3491
+ if (req.method === "GET" && (clientEntry != null || graphName)) {
3492
+ const { js, etag } = await bundleCache.get(graphName ? path : (clientEntry ?? ""), () => graphName
3493
+ ? path === "/assets/graph.js"
3494
+ ? Promise.resolve('import "/assets/graph/schema-graph-global.js";')
3495
+ : graphAsset(graphName)
3496
+ : bundleClient(clientEntry ?? ""));
2961
3497
  if (req.headers["if-none-match"] === etag) {
2962
3498
  res.writeHead(304, { etag, "cache-control": "no-cache" });
2963
3499
  res.end();
@@ -3056,6 +3592,17 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3056
3592
  }
3057
3593
  return;
3058
3594
  }
3595
+ if (path === "/api/subformat") {
3596
+ if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3597
+ sendJson(res, 403, {
3598
+ error: "Record changes require a same-origin local editor request",
3599
+ });
3600
+ return;
3601
+ }
3602
+ const result = subformatResponse(root, await readJson(req), applicationPreviews.domains);
3603
+ sendJson(res, result.status, result.body);
3604
+ return;
3605
+ }
3059
3606
  if (path === "/api/code-file") {
3060
3607
  if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3061
3608
  sendJson(res, 403, {
@@ -3104,7 +3651,9 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3104
3651
  const grammar = siteLanguages.codeGrammars?.find((entry) => entry.name === extension || entry.aliases?.includes(extension));
3105
3652
  const language = existsSync(join(root, ".dooc/editor-tools", `${extension}.json`))
3106
3653
  ? extension
3107
- : (grammar?.name ?? extension);
3654
+ : (readManifest(root).subformats?.find((config) => config.ext === extension)?.format ??
3655
+ grammar?.name ??
3656
+ extension);
3108
3657
  const result = await validateTextfileCode(root, language, input.content);
3109
3658
  for (const message of textfilePreviewErrors(loadSite(locale), input.file, result.content))
3110
3659
  result.findings.push({
@@ -3202,6 +3751,26 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3202
3751
  await handleCreate(req, res);
3203
3752
  return;
3204
3753
  }
3754
+ if (path === "/api/subformat-page") {
3755
+ if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3756
+ sendJson(res, 403, {
3757
+ error: "Page changes require a same-origin local editor request",
3758
+ });
3759
+ return;
3760
+ }
3761
+ const body = await readJson(req);
3762
+ const id = typeof body?.id === "string" ? body.id : "";
3763
+ if (!loadSite().entries.some((entry) => entry.id === id && entry.subformat)) {
3764
+ sendJson(res, 404, { error: "Subformat page not found" });
3765
+ return;
3766
+ }
3767
+ sendOp(res, body?.action === "delete"
3768
+ ? ops.remove(id)
3769
+ : body?.action === "rename" && typeof body.title === "string"
3770
+ ? ops.renameSubformat(id, body.title)
3771
+ : { status: 400, error: "Unknown page action" });
3772
+ return;
3773
+ }
3205
3774
  if (path === "/api/icon") {
3206
3775
  await handleIcon(req, res);
3207
3776
  return;
@@ -3237,9 +3806,37 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3237
3806
  return;
3238
3807
  }
3239
3808
  }
3809
+ if (req.method === "GET" && path === "/assets/code-grammars.json") {
3810
+ const grammars = subformatCodeGrammars(siteLanguages.codeGrammars ?? [], readManifest(root).subformats);
3811
+ const language = requestUrl.searchParams.get("language");
3812
+ const json = JSON.stringify(language === null ? grammars : selectCodeGrammars(grammars, [language]));
3813
+ const etag = `"${createHash("sha256").update(json).digest("hex")}"`;
3814
+ res.writeHead(req.headers["if-none-match"] === etag ? 304 : 200, {
3815
+ "content-type": "application/json; charset=utf-8",
3816
+ "cache-control": "no-cache",
3817
+ etag,
3818
+ });
3819
+ res.end(req.headers["if-none-match"] === etag ? undefined : json);
3820
+ return;
3821
+ }
3240
3822
  const site = loadSite(locale);
3823
+ if (req.method === "GET" && path === "/api/figure-preview") {
3824
+ const figure = [...site.ctx.figures.values()].find((figure) => figure.file === requestUrl.searchParams.get("file"));
3825
+ if (!figure) {
3826
+ notFound(res, path);
3827
+ return;
3828
+ }
3829
+ res.writeHead(200, {
3830
+ "content-type": "text/html; charset=utf-8",
3831
+ "cache-control": "no-store",
3832
+ });
3833
+ res.end(figureFrameHtml(figure, `fig-frame res-${figure.kind}`, requestUrl.searchParams.get("label") ?? undefined));
3834
+ return;
3835
+ }
3241
3836
  if (req.method === "GET" && path === "/api/search") {
3242
- sendJson(res, 200, searchIndex(site));
3837
+ sendJson(res, 200, searchIndex(site, mode === "edit"
3838
+ ? (site.filePaths ?? filesSnapshot(root).files.map((file) => file.path))
3839
+ : []));
3243
3840
  return;
3244
3841
  }
3245
3842
  // edit-mode-only APIs (used by edit-client.ts). handle() strips the query from path, so
@@ -3296,6 +3893,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3296
3893
  }
3297
3894
  if ((mode === "edit" &&
3298
3895
  (path === "/_extensions" ||
3896
+ path === "/_subformats" ||
3299
3897
  path === "/_git" ||
3300
3898
  path === "/_statics" ||
3301
3899
  path.startsWith("/_statics/") ||
@@ -3304,7 +3902,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3304
3902
  path === "/_files/terms") {
3305
3903
  const rest = path.startsWith("/_statics")
3306
3904
  ? path.slice(1)
3307
- : ["/_git", "/_extensions"].includes(path)
3905
+ : ["/_git", "/_extensions", "/_subformats"].includes(path)
3308
3906
  ? path.slice(1)
3309
3907
  : requestUrl.pathname.slice("/_files".length).replace(/^\/|\/$/g, "");
3310
3908
  const page = resourcesMain(site, rest);
@@ -3313,7 +3911,8 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3313
3911
  return;
3314
3912
  }
3315
3913
  const editor = mode === "edit"
3316
- ? (site.entries.find((entry) => entry.id === requestUrl.searchParams.get("editor")) ?? site.entries[0])
3914
+ ? (site.entries.find((entry) => !entry.subformat &&
3915
+ entry.id === requestUrl.searchParams.get("editor")) ?? site.entries.find((entry) => !entry.subformat))
3317
3916
  : undefined;
3318
3917
  if (editor) {
3319
3918
  const { aside, boot } = editorAside(editor, site);
@@ -3338,7 +3937,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3338
3937
  sendPage(res, mode, site, { ...page, currentRes: rest });
3339
3938
  return;
3340
3939
  }
3341
- const id = resolveDocPath(site.entries, path);
3940
+ const id = resolveDocPath(site.entries, requestUrl.pathname);
3342
3941
  const doc = site.entries.find((e) => e.id === id);
3343
3942
  if (!doc) {
3344
3943
  notFound(res, path);
@@ -3349,9 +3948,28 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3349
3948
  main: entryMain(site, doc),
3350
3949
  currentId: doc.id,
3351
3950
  };
3352
- if (mode === "edit") {
3951
+ if (mode === "edit" && !doc.subformat) {
3353
3952
  Object.assign(opts, editorAside(doc, site));
3354
3953
  }
3954
+ if (mode === "edit" && doc.subformat) {
3955
+ const editor = site.entries.find((entry) => !entry.subformat);
3956
+ if (editor) {
3957
+ const { aside, boot } = editorAside(editor, site);
3958
+ Object.assign(opts, {
3959
+ aside,
3960
+ main: entryMain(site, editor),
3961
+ currentRes: path,
3962
+ boot: {
3963
+ ...boot,
3964
+ resource: {
3965
+ path,
3966
+ title: pageTitle(mode, opts.title, site.title),
3967
+ html: entryMain(site, doc),
3968
+ },
3969
+ },
3970
+ });
3971
+ }
3972
+ }
3355
3973
  sendPage(res, mode, site, opts);
3356
3974
  };
3357
3975
  const server = createServer((req, res) => {