@dooc-dev/dooc 0.0.3 → 0.0.5

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 (106) hide show
  1. package/dist/cli.js +98 -56
  2. package/dist/compiler/asset-references.d.ts +4 -0
  3. package/dist/compiler/asset-references.js +117 -0
  4. package/dist/compiler/bundle-urls.d.ts +1 -1
  5. package/dist/compiler/bundle-urls.js +15 -5
  6. package/dist/compiler/check.js +8 -5
  7. package/dist/compiler/code-languages.js +7 -2
  8. package/dist/compiler/compile.d.ts +5 -0
  9. package/dist/compiler/compile.js +105 -10
  10. package/dist/compiler/config.js +2 -1
  11. package/dist/compiler/export.d.ts +4 -0
  12. package/dist/compiler/export.js +140 -0
  13. package/dist/compiler/figures.js +4 -0
  14. package/dist/compiler/files.d.ts +1 -0
  15. package/dist/compiler/files.js +96 -38
  16. package/dist/compiler/fonts.js +4 -1
  17. package/dist/compiler/icons.d.ts +1 -1
  18. package/dist/compiler/icons.js +11 -2
  19. package/dist/compiler/ignored-files.d.ts +3 -0
  20. package/dist/compiler/ignored-files.js +68 -0
  21. package/dist/compiler/locales.js +13 -8
  22. package/dist/compiler/manifest.d.ts +2 -0
  23. package/dist/compiler/manifest.js +9 -2
  24. package/dist/compiler/ops.d.ts +6 -0
  25. package/dist/compiler/ops.js +98 -7
  26. package/dist/compiler/subformats.d.ts +24 -0
  27. package/dist/compiler/subformats.js +299 -0
  28. package/dist/compiler/textfile.js +3 -0
  29. package/dist/compiler/theme-variants.js +5 -2
  30. package/dist/core/content-metadata.d.ts +15 -6
  31. package/dist/core/content-metadata.js +278 -17
  32. package/dist/core/content-types.d.ts +3 -1
  33. package/dist/core/figure-frame.js +19 -1
  34. package/dist/core/files.d.ts +2 -1
  35. package/dist/core/files.js +6 -8
  36. package/dist/core/flow-base-css.generated.js +1 -1
  37. package/dist/core/html.js +3 -3
  38. package/dist/core/icons.d.ts +3 -0
  39. package/dist/core/icons.js +3 -0
  40. package/dist/core/json-tools.d.ts +1 -0
  41. package/dist/core/json-tools.js +12 -0
  42. package/dist/core/routing.d.ts +5 -2
  43. package/dist/core/routing.js +17 -5
  44. package/dist/core/subformat-record.d.ts +3 -0
  45. package/dist/core/subformat-record.js +131 -0
  46. package/dist/core/subformats.d.ts +43 -0
  47. package/dist/core/subformats.js +81 -0
  48. package/dist/core/toc-ui.js +25 -23
  49. package/dist/edit.global.js +322 -95
  50. package/dist/mcp.js +50 -9
  51. package/dist/plugins/index.d.ts +1 -0
  52. package/dist/plugins/local-storage.js +3 -0
  53. package/dist/plugins/oauth.d.ts +1 -1
  54. package/dist/plugins/oauth.js +8 -2
  55. package/dist/plugins/runtime.d.ts +6 -0
  56. package/dist/plugins/runtime.js +166 -34
  57. package/dist/plugins/transport.d.ts +22 -0
  58. package/dist/plugins/transport.js +1 -0
  59. package/dist/plugins/types.d.ts +3 -1
  60. package/dist/plugins.global.js +128 -0
  61. package/dist/subformats.global.js +127 -0
  62. package/dist/ui.global.js +91 -38
  63. package/dist/viewer/build-plugins.d.ts +7 -0
  64. package/dist/viewer/build-plugins.js +70 -0
  65. package/dist/viewer/build.d.ts +9 -0
  66. package/dist/viewer/build.js +32 -5
  67. package/dist/viewer/editor-tools.d.ts +7 -7
  68. package/dist/viewer/editor-tools.js +36 -5
  69. package/dist/viewer/font-picker.js +5 -1
  70. package/dist/viewer/git-diff.d.ts +3 -0
  71. package/dist/viewer/git-diff.js +47 -0
  72. package/dist/viewer/hmr.js +4 -1
  73. package/dist/viewer/i18n.js +7 -5
  74. package/dist/viewer/language-picker.d.ts +2 -2
  75. package/dist/viewer/language-picker.js +26 -9
  76. package/dist/viewer/lazy-graph.d.ts +2 -0
  77. package/dist/viewer/lazy-graph.js +30 -0
  78. package/dist/viewer/locales/eng.json +74 -10
  79. package/dist/viewer/locales/jpn.json +75 -11
  80. package/dist/viewer/locales/zho.json +75 -11
  81. package/dist/viewer/nav-focus.js +8 -1
  82. package/dist/viewer/nav-update.d.ts +2 -0
  83. package/dist/viewer/nav-update.js +117 -0
  84. package/dist/viewer/plugin-style.d.ts +1 -0
  85. package/dist/viewer/plugin-style.js +82 -0
  86. package/dist/viewer/plugins.js +46 -3
  87. package/dist/viewer/resize.d.ts +0 -2
  88. package/dist/viewer/resize.js +2 -98
  89. package/dist/viewer/resource-library.d.ts +10 -8
  90. package/dist/viewer/resource-library.js +179 -30
  91. package/dist/viewer/search.d.ts +4 -2
  92. package/dist/viewer/search.js +252 -53
  93. package/dist/viewer/serve.d.ts +10 -5
  94. package/dist/viewer/serve.js +882 -287
  95. package/dist/viewer/site-icon.js +13 -6
  96. package/dist/viewer/site-title.d.ts +13 -0
  97. package/dist/viewer/site-title.js +50 -0
  98. package/dist/viewer/textfile.d.ts +3 -0
  99. package/dist/viewer/textfile.js +19 -2
  100. package/dist/viewer/theme-picker.d.ts +2 -0
  101. package/dist/viewer/theme-picker.js +24 -8
  102. package/dist/viewer/workspace.d.ts +2 -0
  103. package/dist/viewer/workspace.js +46 -1
  104. package/package.json +24 -9
  105. package/dist/compiler/bundle.d.ts +0 -2
  106. package/dist/compiler/bundle.js +0 -100
@@ -1,4 +1,4 @@
1
- import { filesSnapshot, updateFiles, uploadFile } from "../compiler/files.js";
1
+ import { completeFilePaths, filesSnapshot, updateFiles, uploadFile } from "../compiler/files.js";
2
2
  import { loadProjectFonts } from "../compiler/fonts.js";
3
3
  import { textfilePath, writeTextfile } from "../compiler/textfile.js";
4
4
  import { defaultFilePath, docIconFile, MAX_FILE_UPLOAD_BYTES, parseFileLayout, docFile as sourceDocFile, suggestDocFileName, } from "../core/files.js";
@@ -24,16 +24,18 @@ 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 } 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 { docIdOfFile, flattenTree } from "../core/content-metadata.js";
33
35
  import { MAX_EXTENSION_BYTES } from "../core/extension-package.js";
34
36
  import { figureFrameHtml, mountFigureFrames } from "../core/figure-frame.js";
35
37
  import { blocksHtml, docHtml, escapeHtml, termsHtml } from "../core/html.js";
36
- import { PLUGINS_ICON } from "../core/icons.js";
38
+ import { FOLDER_ICON_PATH, PLUGINS_ICON } from "../core/icons.js";
37
39
  import { DEFAULT_LANG, isLangTag, resolveLanguage, } from "../core/language.js";
38
40
  import { defaultPreviewSettings, parsePreviewSettings, } from "../core/previewers.js";
39
41
  import { ancestorsOf, childrenOf, docPath, resolveDocPath } from "../core/routing.js";
@@ -57,20 +59,24 @@ import { mountFontPickers } from "./font-picker.js";
57
59
  import { createFontSettings } from "./font-settings.js";
58
60
  import { fontCss, readFont } from "./fonts.js";
59
61
  import { createGitHandler, validateGitOrigin } from "./git.js";
60
- import { gitBaseBody, gitBaseText } from "./git-diff.js";
62
+ import { gitBaseBody, gitBaseText, setSubformatChanges } from "./git-diff.js";
61
63
  import { createHmrHub, HMR_PATH, hmrClientScript, watchProject } from "./hmr.js";
62
64
  import { translate } from "./i18n.js";
63
65
  import { DEFAULT_SITE_LANGUAGES, loadSiteLanguages } from "./languages.js";
66
+ import { loadGraphScript } from "./lazy-graph.js";
64
67
  import { focusNavTree } from "./nav-focus.js";
68
+ import { updateNav } from "./nav-update.js";
65
69
  import { loadViewerPlugins } from "./plugin-config.js";
70
+ import { PLUGIN_BLOCK_CSS } from "./plugin-style.js";
66
71
  import { createPluginHandler } from "./plugins.js";
67
- import { mountPanelResize, mountToolsResize } from "./resize.js";
72
+ import { mountPanelResize } from "./resize.js";
68
73
  import { resourceIndex, resourceLibraryHtml, resourceTabs } from "./resource-library.js";
69
74
  import { mountSearch, SEARCH_LABELS, searchIndex, searchSections } from "./search.js";
70
75
  import { siteIconResponse } from "./site-icon.js";
76
+ import { siteTitleResponse } from "./site-title.js";
71
77
  import { previewTextfiles, textfileResponse } from "./textfile.js";
72
- import { mountThemePickers } from "./theme-picker.js";
73
- import { readWorkspaceSource } from "./workspace.js";
78
+ import { initializeThemes, mountThemePickers } from "./theme-picker.js";
79
+ import { readWorkspaceSource, sourceFileBase } from "./workspace.js";
74
80
  // pkgRoot = the viewer itself (src/ for the client bundles). docsRoot = the docs folder that
75
81
  // follows the layout convention (content/ figures/).
76
82
  const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
@@ -78,6 +84,7 @@ const root = resolve(process.env.DOCS_ROOT ?? process.cwd());
78
84
  const CONTENT_PREFIX = "content/";
79
85
  const toEntry = (doc, source) => ({
80
86
  id: doc.id,
87
+ ...(doc.subformat ? { subformat: doc.subformat } : {}),
81
88
  ...(doc.parent == null ? {} : { parent: doc.parent }),
82
89
  file: `${doc.id}.md`,
83
90
  sourceFile: doc.file,
@@ -93,6 +100,7 @@ const toEntry = (doc, source) => ({
93
100
  figureRefs: doc.refs.figures,
94
101
  termRefs: doc.refs.terms,
95
102
  terms: source.terms,
103
+ referencedFiles: source.referencedFiles,
96
104
  });
97
105
  // Recompile source files on every request. The compiler's cache
98
106
  // skips re-parsing files unchanged on disk, so it stays cheap even when called on every keystroke
@@ -102,13 +110,15 @@ let siteLanguages = DEFAULT_SITE_LANGUAGES;
102
110
  let compiler = createCompiler(root);
103
111
  const ops = createDocOps(root);
104
112
  /** Compile result → viewer Site (shared by the server's per-request path and one-off publish). */
105
- export const siteFrom = ({ title, icon, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, }, languages = DEFAULT_SITE_LANGUAGES.languages) => {
113
+ export const siteFrom = ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages) => {
106
114
  return {
107
115
  previews,
116
+ subformats,
108
117
  ...(contentLanguages ? { contentLanguages } : {}),
109
118
  ...(themes ? { themes } : {}),
110
119
  ...(title === undefined ? {} : { title }),
111
120
  ...(icon === undefined ? {} : { icon }),
121
+ ...(iconVariants === undefined ? {} : { iconVariants }),
112
122
  entries: docs.flatMap((doc) => {
113
123
  const source = sources.get(doc.file);
114
124
  return source ? [toEntry(doc, source)] : [];
@@ -142,9 +152,11 @@ let workspaceSource;
142
152
  let applicationPreviews = defaultPreviewSettings();
143
153
  let watchTextfiles;
144
154
  const watchEntryTextfiles = (entries) => {
145
- watchTextfiles?.(entries.flatMap((entry) => [
155
+ watchTextfiles?.(entries
156
+ .filter((entry) => !entry.subformat)
157
+ .flatMap((entry) => [
146
158
  entry.sourceFile ?? CONTENT_PREFIX + entry.file,
147
- ...fileReferences(entry.body).map((reference) => reference.file),
159
+ ...(entry.referencedFiles ?? []),
148
160
  ]));
149
161
  };
150
162
  const loadSite = (locale) => {
@@ -176,13 +188,16 @@ const loadSite = (locale) => {
176
188
  site.errors.push(String(error));
177
189
  }
178
190
  watchEntryTextfiles(site.entries);
179
- const siteIconFile = manifest.icon;
180
- if (siteIconFile)
181
- watchTextfiles?.([siteIconFile]);
191
+ watchTextfiles?.([manifest.icon, ...Object.values(manifest.themeIcons ?? {})].filter((file) => !!file));
192
+ const workspace = workspaceSource ?? readWorkspaceSource(root);
193
+ const subformats = site.entries.flatMap((entry) => (entry.subformat ? [entry.subformat] : []));
194
+ if (workspace?.protocol === "git" && subformats.length)
195
+ setSubformatChanges(root, subformats);
182
196
  return {
183
197
  ...site,
184
198
  fonts: loadProjectFonts(root),
185
- workspace: workspaceSource ?? readWorkspaceSource(root),
199
+ workspace,
200
+ sourceBase: sourceFileBase(root),
186
201
  filePaths: manifest.errors.length
187
202
  ? undefined
188
203
  : filesSnapshot(root).files.map((file) => file.path),
@@ -194,7 +209,9 @@ const loadSite = (locale) => {
194
209
  const draftContext = (site) => ({
195
210
  previews: site.previews,
196
211
  root,
197
- docs: site.entries.map((e) => ({
212
+ docs: site.entries
213
+ .filter((e) => !e.subformat)
214
+ .map((e) => ({
198
215
  id: e.id,
199
216
  ...(e.parent == null ? {} : { parent: e.parent }),
200
217
  file: e.sourceFile ?? CONTENT_PREFIX + e.file,
@@ -283,6 +300,17 @@ const renderSignature = (site, entry) => JSON.stringify([site.ctx.terms, site.er
283
300
  const entryHtmlCache = new Map();
284
301
  /** Renders only the requested doc, not every doc in site.entries. */
285
302
  export const renderEntryHtml = (site, entry) => {
303
+ if (entry.subformat)
304
+ return {
305
+ html: `<article class="res-page resource-library subformat-page">${resourceLibraryHtml({
306
+ codeblocks: [],
307
+ urls: [],
308
+ urlPreviews: [],
309
+ subformats: [entry.subformat],
310
+ errors: [...site.errors, ...entry.errors],
311
+ }, "subformats", docDisplayName(entry.frontmatter, entry.id))}</article>`,
312
+ errors: [...site.errors, ...entry.errors],
313
+ };
286
314
  const sig = renderSignature(site, entry);
287
315
  const cached = entryHtmlCache.get(entry.file);
288
316
  if (cached &&
@@ -356,12 +384,15 @@ export const isExternallyModified = (baseRaw, currentRaw) => typeof baseRaw ===
356
384
  */
357
385
  export const resolveContentFile = (rel) => {
358
386
  const id = typeof rel === "string" ? docIdOfFile(rel) : undefined;
359
- return id == null
387
+ if (flattenTree(readManifest(root).tree).some((node) => node.id === id && node.subformat))
388
+ return undefined;
389
+ const file = id == null ? undefined : sourceDocFile(id, readManifest(root).files);
390
+ return id == null || !file || ignoredFiles(root, [file]).has(file)
360
391
  ? undefined
361
392
  : {
362
393
  id,
363
394
  name: `${id}.md`,
364
- abs: textfilePath(root, sourceDocFile(id, readManifest(root).files)),
395
+ abs: textfilePath(root, file),
365
396
  };
366
397
  };
367
398
  // Default palette — resolves the figures' var(--doc-*) and color-mix() following the theme. The
@@ -381,7 +412,7 @@ const LIGHT_C = `
381
412
  color-scheme: light;
382
413
  --c-bg0:#ffffff; --c-bg1:#f5f7f9; --c-surface:#fbfcfd; --c-raised:#e9edf2;
383
414
  --c-line:#d5dae0; --c-line-soft:#e4e8ec;
384
- --c-fg:#1a1e23; --c-fg-muted:#5a636c; --c-fg-faint:#7b848e; --fw-body:300;
415
+ --c-fg:#1a1e23; --c-fg-muted:#5a636c; --c-fg-faint:#687079; --fw-body:300;
385
416
  --c-accent:#c24800; --c-ok:#2f7d4f; --c-danger:#b23c31; --c-warn:#8a6516; --c-info:#3a6ea5;
386
417
  --c-shadow:rgba(15,23,32,.14);
387
418
  --doc-fg-4:#9099a8; --doc-accent-2:#0277bd; --doc-accent-fg:#ffffff;
@@ -404,13 +435,15 @@ const CHEVRON_ICON = icon('<path d="M8 5.5 12.5 10 8 14.5"/>', 14);
404
435
  const GLOBE_ICON = icon('<circle cx="10" cy="10" r="7"/><ellipse cx="10" cy="10" rx="3" ry="7"/><path d="M3 10h14"/>');
405
436
  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"/>');
406
437
  const STATICS_ICON = icon('<path d="M3 3v14h14M7 13V9m4 4V5m4 8V7"/>');
438
+ 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"/>');
407
439
  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"/>');
408
440
  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"/>');
441
+ const FOLDER_ICON = icon(`<path d="${FOLDER_ICON_PATH}"/>`);
409
442
  const workspaceName = (site) => site.workspace?.protocol === "storage" ? workspaceLabel(site.workspace) : "Files";
410
443
  const workspaceText = (site) => `<span${site.workspace?.protocol === "storage" ? "" : ' data-i18n="Files"'}>${escapeHtml(workspaceName(site))}</span>`;
411
444
  const workspaceIcon = (site) => {
412
445
  if (site.workspace?.protocol === "git")
413
- return icon('<path d="M2 5h6l2 2h8v10H2Z"/>');
446
+ return FOLDER_ICON;
414
447
  return site.workspace?.icon
415
448
  ? svgImg(site.workspace.icon, "nav-icon workspace-icon")
416
449
  : STORAGE_ICON;
@@ -436,20 +469,23 @@ const THEME_ICONS = {
436
469
  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"/>'),
437
470
  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"/>'),
438
471
  };
472
+ 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"/>');
473
+ const SELECT_ICON = icon('<path d="m5 7 5 5 5-5"/>', 12);
439
474
  const fontButton = (target) => {
440
475
  const label = target === "editor" ? "Editor font" : "Viewer font";
441
- 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>`;
476
+ 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>`;
442
477
  };
443
478
  const CSS = `
444
479
  :root { ${DARK_C} ${DOC_FROM_C} --doc-mono: ${MONO_FONT}; --font-sans: ${SANS_FONT}; }
480
+ html[data-theme] iframe[data-doc-figure-frame]:not([data-theme-ready]) { visibility: hidden; }
445
481
  @media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { ${LIGHT_C} } }
446
482
  :root[data-theme="light"] { ${LIGHT_C} }
447
- body.edit :is(#sidebar, #panel, .resources-pane), .preview-pane[data-theme], .theme-picker[data-theme] { ${DARK_C} ${DOC_FROM_C} }
483
+ body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast), .preview-pane[data-theme], .theme-picker[data-theme] { ${DARK_C} ${DOC_FROM_C} }
448
484
  @media (prefers-color-scheme: light) {
449
- :root:not([data-editor-theme="dark"]) body.edit :is(#sidebar, #panel, .resources-pane),
485
+ :root:not([data-editor-theme="dark"]) body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast),
450
486
  :is(.preview-pane, .theme-picker)[data-theme="auto"] { ${LIGHT_C} }
451
487
  }
452
- :root[data-editor-theme="light"] body.edit :is(#sidebar, #panel, .resources-pane),
488
+ :root[data-editor-theme="light"] body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast),
453
489
  :is(.preview-pane, .theme-picker)[data-theme="light"] { ${LIGHT_C} }
454
490
  .preview-pane { background: var(--c-bg0); color: var(--c-fg); }
455
491
  .theme-picker { position: fixed; margin: 0; padding: 5px; width: 148px; border: 1px solid var(--c-line);
@@ -468,8 +504,9 @@ body.edit :is(#sidebar, #panel, .resources-pane), .preview-pane[data-theme], .th
468
504
  main { --doc-mono: var(--viewer-font, ${MONO_FONT}); }
469
505
  .resources-pane { --doc-mono: var(--editor-font, ${MONO_FONT}); background: var(--c-bg1); color: var(--c-fg); font-family: var(--doc-mono); }
470
506
  .page-actions, .pane-actions { position: sticky; display: flex; align-items: center; justify-content: flex-end;
471
- gap: 2px; height: 36px; padding: 0 24px; border-bottom: 1px solid var(--c-line); background: var(--c-bg0); z-index: 5; }
472
- .page-actions { top: 0; margin: -20px -24px 20px; }
507
+ gap: 2px; height: 36px; padding: 0 24px; pointer-events: none; z-index: 5; }
508
+ :is(.page-actions, .pane-actions) > .pbtn { pointer-events: auto; background: var(--c-bg0); }
509
+ .page-actions { top: 0; margin: -20px -24px -36px; }
473
510
  .pbtn { flex: none; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px;
474
511
  padding: 0; color: var(--c-fg-faint); background: none; border: none; border-radius: 5px; cursor: pointer;
475
512
  transition: color 120ms ease, background 120ms ease; }
@@ -494,44 +531,77 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
494
531
  :focus-visible { outline: 1px solid var(--c-accent); outline-offset: 1px; }
495
532
 
496
533
  #doc-search { position: fixed; top: 12px; left: 0; right: 0; z-index: 20;
497
- width: min(600px, calc(100vw - 24px)); min-height: 56px; max-height: min(420px, calc(100dvh - 24px)); margin: 0 auto;
498
- padding: 0 10px 10px; color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 82%, transparent);
534
+ width: min(420px, calc(100vw - 24px)); min-height: 44px; max-height: min(420px, calc(100dvh - 24px)); margin: 0 auto;
535
+ padding: 0 8px 6px; color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 82%, transparent);
499
536
  border: 1px solid color-mix(in srgb, var(--c-fg-muted) 55%, transparent);
500
537
  backdrop-filter: blur(16px); border-radius: 8px; box-shadow: 0 8px 24px #0003; overflow: hidden; }
501
538
  #doc-search[open] { display: flex; flex-direction: column; }
502
539
  #doc-search :focus-visible { outline-color: var(--c-fg-muted); }
503
- .search-head { display: flex; flex: none; align-items: center; gap: 10px; padding: 8px;
540
+ .search-grip { position: relative; flex: none; height: 8px; margin: 0 -8px; cursor: grab; touch-action: none; }
541
+ .search-grip:active { cursor: grabbing; }
542
+ .search-grip::after { content: ""; position: absolute; top: 50%; left: 50%; width: 36px; height: 4px;
543
+ margin: -2px 0 0 -18px; border-radius: 2px; background: var(--c-line); }
544
+ .search-grip:hover::after, .search-grip:focus-visible::after { background: var(--c-fg-muted); }
545
+ .search-head { display: flex; flex: none; align-items: center; gap: 8px; padding: 0 0 0 4px;
504
546
  color: var(--c-fg-muted); }
505
547
  .search-head svg { flex: none; }
506
- #doc-search.search-filled .search-head svg { display: none; }
507
- #doc-search-input { width: 100%; min-width: 0; padding: 4px 0; font: inherit; font-size: 15px;
548
+ #doc-search.search-filled .search-head > svg { display: none; }
549
+ .search-head button, .search-copy { display: grid; place-items: center; width: 24px; height: 24px; padding: 0;
550
+ color: var(--c-fg-muted); background: none; border: 0; border-radius: 4px; cursor: pointer; }
551
+ .search-head button { flex: none; }
552
+ .search-head button + button { margin-left: -8px; }
553
+ .search-head button:hover, .search-copy:hover { color: var(--c-fg); background: color-mix(in srgb, var(--c-fg-muted) 18%, transparent); }
554
+ #doc-search-input { width: 100%; min-width: 0; padding: 3px 0; font: inherit; font-size: 14px;
508
555
  color: var(--c-fg); background: none; border: 0; outline: none; }
509
556
  #doc-search-input::-webkit-search-cancel-button { appearance: none; }
510
- .search-status { padding: 8px 16px; color: var(--c-fg-muted); font-size: 12px; }
557
+ .search-status { padding: 6px 8px; color: var(--c-fg-muted); font-size: 12px; }
511
558
  .search-status:empty { display: none; }
512
559
  .search-count { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden;
513
560
  clip-path: inset(50%); white-space: nowrap; }
514
- #doc-search-results { overflow-y: auto; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
561
+ #doc-search-results { overflow-y: auto; scrollbar-gutter: stable; margin-right: -2px; padding-right: 2px;
562
+ min-height: 0; display: flex; flex-direction: column; gap: 8px; }
563
+ #doc-search-results:not(:empty) { margin-top: 6px; }
515
564
  #doc-search-results a { display: flex; flex: none; flex-direction: column; gap: 6px;
516
565
  border: 1px solid var(--c-line); border-radius: 5px; color: var(--c-fg); text-decoration: none;
517
566
  background: color-mix(in srgb, var(--c-bg0) 50%, transparent); overflow-wrap: anywhere; }
518
567
  #doc-search-results a:hover, #doc-search-results a[aria-selected="true"] { border-color: var(--c-fg-muted); }
519
- .search-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px;
568
+ #doc-search-results mark { color: inherit; background: color-mix(in srgb, var(--c-accent) 32%, transparent);
569
+ border-radius: 2px; }
570
+ .search-meta { display: flex; align-items: center; gap: 6px;
520
571
  padding: 5px 10px; border-bottom: 1px solid var(--c-line); color: var(--c-fg-muted); }
521
- .search-path { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
572
+ .search-kind { display: grid; flex: none; }
573
+ .search-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
522
574
  #doc-search-results strong { margin: 2px 10px 0; font-weight: 500; }
523
- #doc-search-results span { margin: 0 10px 10px; color: var(--c-fg-muted); }
524
- .search-grip { position: absolute; top: 8px; bottom: 18px; width: 10px; cursor: grab; touch-action: none; }
525
- .search-grip-left { left: 0; }
526
- .search-grip-right { right: 0; }
527
- .search-grip:active { cursor: grabbing; }
528
- .search-grip::after { content: ""; position: absolute; top: 35%; bottom: 35%; left: 4px;
529
- width: 2px; border-radius: 2px; background: var(--c-line); }
530
- .search-grip:hover::after, .search-grip:focus-visible::after { background: var(--c-fg-muted); }
531
- .search-resize { position: absolute; bottom: 0; right: 0; width: 18px; height: 18px;
532
- cursor: nwse-resize; touch-action: none; }
533
- .search-resize::after { content: ""; position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px;
534
- border-right: 1px solid var(--c-fg-muted); border-bottom: 1px solid var(--c-fg-muted); }
575
+ #doc-search-results strong:last-child { margin-bottom: 10px; }
576
+ .search-snippet { margin: 0 10px 10px; color: var(--c-fg-muted); }
577
+ .search-hit { position: relative; flex: none; }
578
+ .search-name + .search-name { margin-top: -4px; }
579
+ .search-name .search-meta { padding-right: 40px; border-bottom: 0; }
580
+ .search-name .search-path { color: var(--c-fg); }
581
+ .search-copy { position: absolute; top: 50%; right: 6px; margin-top: -12px; }
582
+ .search-flash { animation: search-flash 2.6s ease-out; }
583
+ @keyframes search-flash {
584
+ 0%, 35% { background-color: color-mix(in srgb, var(--c-accent) 18%, transparent);
585
+ box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-accent) 18%, transparent); }
586
+ 100% { background-color: transparent; box-shadow: 0 0 0 4px transparent; } }
587
+ /* Docked, the panel is a right sidebar like #panel. */
588
+ #doc-search.search-docked { position: sticky; top: 0; left: auto; right: auto; z-index: auto; flex: 0 1 auto;
589
+ align-self: flex-start; width: 320px; min-width: 240px; height: 100vh; min-height: 0; max-height: none; margin: 0;
590
+ padding: 8px 10px 10px; border: 0; border-left: 1px solid var(--c-line); border-radius: 0;
591
+ background: var(--c-bg1); box-shadow: none; backdrop-filter: none; }
592
+ .search-docked #doc-search-results { margin-right: -8px; padding-right: 8px; }
593
+ /* Keep the preview readable; the editor panel gives up width before the search sidebar does. */
594
+ body:has(#doc-search.search-docked[open]) main { min-width: 240px; }
595
+ body:has(#doc-search.search-docked[open]) #panel { flex-shrink: 100; min-width: 240px; }
596
+ .search-docked :is(.search-grip, .search-resize-x, .search-resize-y, .search-resize-xy),
597
+ #doc-search:not(.search-docked) .search-resize-w { display: none; }
598
+ /* Invisible edges: the right and bottom borders resize the window. */
599
+ .search-resize { position: absolute; touch-action: none; }
600
+ .search-resize:focus-visible { outline-offset: -2px; }
601
+ .search-resize-x { top: 0; right: 0; bottom: 0; width: 6px; cursor: ew-resize; }
602
+ .search-resize-y { left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
603
+ .search-resize-xy { right: 0; bottom: 0; width: 12px; height: 12px; cursor: nwse-resize; }
604
+ .search-resize-w { top: 0; left: 0; bottom: 0; width: 6px; cursor: ew-resize; }
535
605
 
536
606
  /* ── sidebar ── */
537
607
  #sidebar { width: var(--sidebar-width, 260px); height: 100vh; position: sticky; top: 0; flex: none;
@@ -540,11 +610,16 @@ button { font-family: inherit; font-size: inherit; font-weight: var(--fw-body);
540
610
  body.sidebar-closed #sidebar { width: 52px; }
541
611
  body.sidebar-closed #sidebar-resize { display: none; }
542
612
  .panel-resize { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 6;
543
- touch-action: none; transition: background 120ms ease; }
613
+ touch-action: none; }
614
+ .panel-resize::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; border-radius: 1px;
615
+ transition: background 120ms ease; }
544
616
  #sidebar-resize { right: 0; }
617
+ #sidebar-resize::before { right: -1px; }
545
618
  #resize { left: 0; }
546
- .panel-resize:hover, .panel-resize:focus-visible, .panel-resize.drag {
619
+ #resize::before { left: -1px; }
620
+ .panel-resize:hover::before, .panel-resize:focus-visible::before, .panel-resize.drag::before {
547
621
  background: color-mix(in srgb, var(--c-accent) 60%, transparent); }
622
+ .panel-resize.drag { outline: none; }
548
623
  body.resizing, body.resizing * { cursor: col-resize !important; user-select: none !important; }
549
624
  body.sidebar-closed .site-title { display: none; }
550
625
  #sidebar-head { position: relative; flex: none; display: flex; align-items: center; min-width: 0; min-height: 36px;
@@ -553,8 +628,9 @@ body.sidebar-closed .site-title { display: none; }
553
628
  background: transparent; border: none; color: var(--c-fg-muted); cursor: pointer; }
554
629
  #sidebar-toggle:hover { color: var(--c-fg); }
555
630
  #site-icon-slot { position: relative; flex: none; width: 24px; height: 24px; margin: 0 8px 0 16px; color: var(--c-fg-muted); }
556
- #site-icon, #site-icon-slot > .nav-icon { display: block; width: 100%; height: 100%; object-fit: contain; }
557
- #site-icon[hidden], #site-icon-slot:has(#site-icon:not([hidden])) > .nav-icon { display: none; }
631
+ #site-icon, #site-icon-slot > .nav-icon, .site-icon-variants > img { display: block; width: 100%; height: 100%; object-fit: contain; }
632
+ .site-icon-variants, .site-icon-variants > span { display: contents; }
633
+ #site-icon[hidden], .site-icon-variants > [hidden], #site-icon-slot:has(#site-icon:not([hidden])) > .nav-icon { display: none; }
558
634
  body.sidebar-closed #site-icon-slot { margin: 0 auto; }
559
635
  body.sidebar-closed #sidebar-toggle { position: absolute; inset: 0; width: 100%; justify-content: center; padding: 0; }
560
636
  body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
@@ -573,6 +649,7 @@ body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
573
649
  .nav-link.cur { color: var(--c-fg); }
574
650
  .nav-link.cur::before { background: var(--c-accent); }
575
651
  .nav-icon { flex: none; }
652
+ .nav-row :is(svg.nav-icon, .doc-icon-frame) { translate: 0 1px; }
576
653
  .workspace-icon { width: 18px; height: 18px; object-fit: contain; }
577
654
  .nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
578
655
  /* The doc tree. Top-level docs are .nav-link with an icon,
@@ -649,33 +726,37 @@ img.doc-icon { flex: none; width: 18px; height: 18px; object-fit: contain; }
649
726
  .nav-row > a.cur .doc-icon-frame > img, .nav-doc-row:has(> a.cur) > .nav-doc-icon .doc-icon-frame > img { visibility: hidden; }
650
727
  .nav-row > a.cur .doc-icon-frame::after, .nav-doc-row:has(> a.cur) > .nav-doc-icon .doc-icon-frame::after {
651
728
  content: ""; position: absolute; inset: 0; background: currentColor; mask: var(--doc-icon) center / contain no-repeat; }
652
- body.sidebar-closed #sidebar-content { display: block; overflow-y: auto; scrollbar-width: none; padding: 6px 0; }
653
- body.sidebar-closed #nav-groups { display: block; }
654
- body.sidebar-closed #nav-docs { scrollbar-width: none; }
655
- 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),
656
- body.sidebar-closed #nav-status { display: none; }
657
- body.sidebar-closed #nav-groups .nav-tree { display: block; padding: 0; margin: 0; }
658
- body.sidebar-closed #nav-groups .nav-row { position: relative; padding: 0; gap: 0; min-height: 36px; }
659
- body.sidebar-closed #nav-groups .nav-row > a { width: 100%; height: 36px; padding: 0; justify-content: center; }
660
- body.sidebar-closed #nav-groups .nav-doc-icon { position: absolute; left: 16px; z-index: 1; pointer-events: none; }
661
- 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; }
662
- body.sidebar-closed #nav-groups :is(.nav-item, .nav-tree, .nav-row, a)::before,
663
- body.sidebar-closed #nav-groups :is(.nav-item, .nav-tree, .nav-row, a)::after { display: none; }
664
- 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; }
729
+ body.sidebar-closed :is(#sidebar-content, #nav-docs) { scrollbar-width: none; scrollbar-gutter: auto; }
730
+ body.sidebar-closed #nav-groups { --nav-rail: 8px; }
731
+ body.sidebar-closed #nav-groups .nav-label, body.sidebar-closed #nav-status { opacity: 0; pointer-events: none; }
732
+ body.sidebar-closed #nav-groups .nav-placeholder { visibility: hidden; pointer-events: none; }
733
+ 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; }
734
+ body.sidebar-closed #nav-groups .nav-tree { --nav-pad: 18px; --nav-line: 8px; }
735
+ body.sidebar-closed #nav-groups .nav-tree > .nav-item:not(.nav-ancestor) > .nav-row::before { width: calc(var(--nav-pad) - var(--nav-line) - 2px); }
736
+ body.sidebar-closed #nav-groups .nav-ancestor.open > .nav-row::after { top: 50%; }
737
+ body.sidebar-closed #nav-groups .nav-ancestor > .nav-tree > .nav-ancestor > .nav-row::before { height: 50%; }
738
+ body.sidebar-closed #nav-groups :is(.nav-row > .nav-link, .nav-tree-link) { padding-left: 0; padding-right: 0; gap: 0; }
739
+ body.sidebar-closed #nav-groups .nav-doc-row { padding-left: 0; gap: 0; }
740
+ body.sidebar-closed #nav-groups .nav-doc-row > a { padding-left: 0; }
741
+ 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; }
742
+ body.sidebar-closed #nav-groups .nav-doc-icon { z-index: 1; pointer-events: none; }
665
743
  body.edit #sidebar-content { display: flex; flex-direction: column; overflow: hidden; scrollbar-gutter: auto; }
666
744
  body.edit #nav-groups { flex: 1; min-height: 0; display: flex; flex-direction: column; }
667
745
  #nav-docs { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
668
- #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); }
669
- #tools-resize { position: absolute; top: -4px; left: 0; right: 0; height: 8px; z-index: 2; cursor: row-resize; touch-action: none; border-radius: 6px; }
670
- #tools-resize:hover, #tools-resize:focus-visible, body.resizing-tools #tools-resize { background: color-mix(in srgb, var(--c-fg-muted) 20%, transparent); }
671
- body.resizing-tools, body.resizing-tools * { cursor: row-resize !important; user-select: none !important; }
672
- .nav-tool-cards { flex: 1; min-height: 0; overflow: auto; }
746
+ #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); }
747
+ .nav-tool-cards { max-height: max(36px, calc(50dvh - 40px)); overflow: auto; }
673
748
  #nav-tools .nav-resources { height: 36px; margin: 0; border: 0; border-radius: 4px; }
674
- .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; }
675
- .workspace-location > .nav-icon { flex: none; width: 14px; height: 14px; padding: 1px; background: var(--c-bg1); }
676
- .workspace-address { min-width: 0; padding: 0 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--c-bg1); }
677
- body.sidebar-closed #nav-tools { height: auto; margin: 4px 0; padding: 0; border: 0; }
678
- body.sidebar-closed :is(#tools-resize, .workspace-location) { display: none; }
749
+ .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; }
750
+ #nav-tools:not([open]) { padding-bottom: 0; border-color: transparent; border-top-color: var(--c-line); border-radius: 0; }
751
+ .workspace-location::-webkit-details-marker { display: none; }
752
+ .workspace-location:hover { color: var(--c-fg); }
753
+ .workspace-location > .nav-icon { flex: none; width: 14px; height: 14px; background: var(--c-bg1); }
754
+ .workspace-location > .nav-icon:last-child { margin-left: auto; }
755
+ #nav-tools[open] > .workspace-location > .nav-icon:last-child { transform: rotate(90deg); }
756
+ .workspace-address { min-width: 0; padding: 0 2px; background: var(--c-bg1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
757
+ body.sidebar-closed #nav-tools { margin-left: 4px; margin-right: 4px; padding-left: 0; padding-right: 0; }
758
+ body.sidebar-closed .workspace-location { left: 2px; right: 2px; min-height: 16px; }
759
+ body.sidebar-closed .workspace-address { display: none; }
679
760
  .nav-resources { position: relative; container-type: size; flex: none; height: 42px; margin: 8px 8px 4px;
680
761
  border: 1px solid var(--c-line); border-radius: 8px; overflow: hidden;
681
762
  background: var(--c-bg1); font-family: var(--font-sans); }
@@ -737,15 +818,13 @@ article { max-width: 860px; margin: 0 auto; font-family: var(--viewer-font, syst
737
818
  [data-plugin-controls] button:disabled { opacity: .55; cursor: wait; }
738
819
  .plugin-content { padding: 12px; overflow: auto; }
739
820
  .plugin-content:empty { display: none; }
740
- .plugin-content :is(th, td) { padding: 6px 8px; text-align: start; border-bottom: 1px solid var(--doc-border); }
741
- .plugin-content th { background: var(--doc-bg-2); color: var(--doc-fg-2); font-size: 12px; font-weight: 600; }
742
- .plugin-content tr:last-child td { border-bottom: 0; }
743
821
  .plugin-resize { display: none; height: 12px; align-items: center; justify-content: center;
744
822
  cursor: row-resize; touch-action: none; user-select: none; }
745
823
  .plugin[data-ready="true"]:not(.collapsed) > .plugin-resize { display: flex; }
746
- .plugin-resize::before { content: ""; width: 32px; height: 3px; border-radius: 2px; background: var(--doc-border); }
824
+ .plugin-resize::before { content: ""; width: 32px; height: 2px; border-radius: 1px; background: var(--doc-border); }
747
825
  .plugin-resize:hover::before, .plugin-resize:focus-visible::before, .plugin-resize.drag::before { background: var(--doc-accent); }
748
826
  .plugin-resize:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: -2px; }
827
+ .plugin-resize.drag { outline: none; }
749
828
  body:has(.plugin-resize.drag), body:has(.plugin-resize.drag) * { cursor: row-resize !important; user-select: none !important; }
750
829
  body:has(.plugin-resize.drag) iframe { pointer-events: none; }
751
830
 
@@ -763,83 +842,7 @@ body:has(.plugin-resize.drag) iframe { pointer-events: none; }
763
842
  .plugin-heading img { display: block; width: 16px; height: 16px; }
764
843
  .plugin-heading-context { color: var(--doc-fg-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
765
844
  .plugin-heading button { font: inherit; color: var(--doc-fg-2); background: transparent; border: 0; padding: 0; cursor: pointer; white-space: nowrap; }
766
- .plugin-blocks { font: inherit; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
767
- .plugin-blocks > :first-child, .plugin-block-columns > div > :first-child { margin-top: 0; }
768
- .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); }
769
- .plugin-block-text { margin: 8px 0; white-space: pre-wrap; }
770
- .plugin-block-text:has(p, pre, ul, ol) { white-space: normal; }
771
- .plugin-blocks p { margin: 4px 0; white-space: pre-wrap; }
772
- .plugin-blocks :is(ul, ol) { margin: 6px 0; padding-left: 22px; }
773
- .plugin-blocks > :last-child { margin-bottom: 0; }
774
- .plugin-blocks strong { font-weight: 600; }
775
- .plugin-blocks a { color: var(--doc-accent); text-underline-offset: 3px; }
776
- .plugin-blocks code { font-family: var(--doc-mono); }
777
- .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; }
778
- .plugin-block-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 16px; margin: 8px 0; }
779
- .plugin-block-fields > div { min-width: 0; }
780
- .plugin-block-fields dt { color: var(--doc-fg-3); font-size: 10px; margin-bottom: 1px; }
781
- .plugin-block-fields dd { margin: 0; min-height: 20px; font-size: 12px; }
782
- .plugin-block-columns { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px; }
783
- .plugin-block-columns > div, .plugin-block-columns aside { min-width: 0; }
784
- .plugin-block-columns aside { border-left: 1px solid var(--doc-border); padding-left: 12px; }
785
- .plugin-block-columns aside .plugin-block-fields { grid-template-columns: 1fr; margin-top: 0; }
786
- .plugin-block-section { border-top: 1px solid var(--doc-border); padding-top: 6px; margin: 10px 0 0; min-width: 0; }
787
- .plugin-block-section > summary { cursor: pointer; font-size: 12px; font-weight: 600; color: var(--doc-fg-2); padding: 4px 0; }
788
- .plugin-block-note { color: var(--doc-warn); font-size: 11px; border-left: 2px solid currentColor; padding-left: 10px; }
789
- .plugin-block-table { overflow: auto; width: 100%; margin: 8px 0; }
790
- .plugin-block-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
791
- .plugin-block-table :is(th, td) { padding: 5px 8px; min-width: 72px; max-width: 320px; vertical-align: top; }
792
- .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; }
793
- .plugin-block-diff code > span { display: inline-block; min-width: 100%; }
794
- .plugin-block-diff [data-tone="success"] { color: var(--doc-ok); background: color-mix(in srgb, var(--doc-ok) 8%, transparent); }
795
- .plugin-block-diff [data-tone="danger"] { color: var(--doc-danger); background: color-mix(in srgb, var(--doc-danger) 8%, transparent); }
796
- .plugin-block-message { padding: 8px 0; border-bottom: 1px solid var(--doc-border); }
797
- .plugin-block-message:last-child { border-bottom: 0; }
798
- .plugin-message-byline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
799
- .plugin-message-byline > span:not(.plugin-avatar, .plugin-message-actions) { color: var(--doc-fg-3); font-size: 10px; }
800
- .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; }
801
- .plugin-task { display: flex; align-items: baseline; gap: 8px; list-style: none; }
802
- .plugin-message-actions svg { display: block; width: 14px; height: 14px; }
803
- .plugin-message-actions .plugin-block-button { padding: 4px; border: 0; color: var(--doc-fg-3); }
804
- .plugin-message-actions { margin-left: auto; display: flex; gap: 4px; }
805
- .plugin-message-body, .plugin-reactions { margin: 4px 0 0 32px; }
806
- .plugin-reactions { display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; }
807
- .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; }
808
- .plugin-reactions [aria-pressed="true"] { border-color: var(--doc-accent); color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 8%, transparent); }
809
- .plugin-badge { display: inline-flex; padding: 1px 7px; border-radius: 5px; font-size: 11px; color: var(--doc-fg-2); background: var(--doc-bg-2); }
810
- .plugin-badge[data-tone="accent"] { color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 10%, var(--doc-bg)); }
811
- .plugin-badge[data-tone="success"] { color: var(--doc-ok); background: color-mix(in srgb, var(--doc-ok) 10%, var(--doc-bg)); }
812
- .plugin-badge[data-tone="warning"] { color: var(--doc-warn); background: color-mix(in srgb, var(--doc-warn) 10%, var(--doc-bg)); }
813
- .plugin-badge[data-tone="danger"] { color: var(--doc-danger); background: color-mix(in srgb, var(--doc-danger) 10%, var(--doc-bg)); }
814
- .plugin-copy-value { display: inline-flex; align-items: center; gap: 3px; max-width: 100%; }
815
- .plugin-copy { width: 22px; height: 22px; padding: 3px; border: 0; background: transparent; color: var(--doc-fg-3); cursor: pointer; flex: none; }
816
- .plugin-copy svg { width: 14px; height: 14px; }
817
- .plugin-block-progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--doc-fg-3); margin: 12px 0; }
818
- .plugin-block-progress progress { flex: 1; width: 0; height: 6px; accent-color: var(--doc-accent); }
819
- .plugin-block-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
820
- .plugin-block-actions:has([data-block-composer]) { display: block; }
821
- .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; }
822
- .plugin-block-button:hover { background: var(--doc-bg-2); }
823
- .plugin-block-button:disabled { opacity: .5; cursor: wait; }
824
- .plugin-action[aria-pressed="true"] { color: var(--doc-accent); background: var(--doc-bg-2); }
825
- .plugin-danger { color: var(--doc-danger); }
826
- .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; }
827
- .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; }
828
- .plugin-editor label { display: grid; gap: 0; font-size: 0; }
829
- .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; }
830
- .plugin-editor textarea { resize: vertical; min-height: 54px; max-height: 40vh; }
831
- .plugin-editor .plugin-submit { background: var(--doc-accent); color: var(--doc-accent-fg); border-color: transparent; }
832
- .plugin-editor-notice { color: var(--doc-danger); font-size: 11px; }
833
- .plugin-editor-notice:empty { display: none; }
834
- .plugin [hidden] { display: none !important; }
835
- @container (max-width: 600px) {
836
- .plugin-block-columns { grid-template-columns: minmax(0, 1fr); gap: 14px; }
837
- .plugin-block-columns aside { border-left: 0; border-top: 1px solid var(--doc-border); padding: 14px 0 0; }
838
- .plugin-block-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
839
- .plugin-heading-context { display: none; }
840
- .plugin-blocks .plugin-block-heading { font-size: 16px; }
841
- .plugin-message-body, .plugin-reactions { margin-left: 0; }
842
- }
845
+ ${PLUGIN_BLOCK_CSS}
843
846
 
844
847
  article, article * { font-weight: 400; }
845
848
  h1, h2, h3 { font-weight: 400; }
@@ -858,7 +861,7 @@ article h2 { font-size: 20px; margin-top: 24px; margin-bottom: 8px; border-botto
858
861
  article h3 { font-size: 16px; margin-top: 16px; margin-bottom: 4px; }
859
862
  h2[id], h3[id] { scroll-margin-top: 12px; }
860
863
  p { margin: 8px 0; }
861
- ul, ol { margin: 4px 0; line-height: 1.3; }
864
+ ul, ol { margin: 4px 0; }
862
865
  li { margin: 0; }
863
866
  li > ul, li > ol { margin: 0; }
864
867
  .fullname { opacity: .7; margin-bottom: 8px; }
@@ -941,8 +944,10 @@ pre code.code-foldable { display: block; padding-left: 18px; }
941
944
  .textfile-unavailable { margin: 0; padding: 12px; color: var(--doc-fg-2); font-size: 12px; }
942
945
  .textfile.unavailable .codeblk-head { cursor: default; }
943
946
  .codeblk .codecopy.ok .ic-ok { display: block; color: var(--doc-ok); }
944
- table { border-collapse: collapse; font-size: 14px; }
947
+ table { border-collapse: collapse; }
945
948
  th, td { border: 1px solid color-mix(in srgb, currentColor 25%, transparent); padding: 4px 10px; }
949
+ th { text-align: start; }
950
+ article thead th { background: var(--doc-bg-2); color: var(--doc-fg-2); font-weight: 500; }
946
951
  .data-table { position: relative; min-width: 0; width: 100%; margin: 12px 0; }
947
952
  .data-table button { color: inherit; background: transparent; font: inherit; cursor: pointer; }
948
953
  .data-table button:focus-visible, .data-table-scroll:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: -2px; }
@@ -985,8 +990,10 @@ article a { color: var(--doc-accent); }
985
990
  .callout-body > :last-child { margin-bottom: 0; }
986
991
  .errors { border: 1px solid var(--doc-danger); border-radius: 8px; padding: 10px 16px;
987
992
  margin-bottom: 16px; color: var(--doc-danger); font-size: 13px; }
988
- .in-toc { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; margin: 0 10px 0 0; }
989
- .toc-current { position: relative; flex: none; width: 120px; min-width: 0; max-width: calc(100% - 36px); padding: 4px 20px 4px 4px;
993
+ .doc-title { display: flex; align-items: baseline; gap: 12px; max-width: calc(100% - 100px); padding-top: 8px; margin-bottom: 2px; }
994
+ .doc-title > h1 { min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
995
+ .in-toc { min-width: 28px; max-width: 100%; }
996
+ .toc-current { position: relative; display: block; max-width: min(240px, 100%); padding: 4px 20px 4px 6px;
990
997
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 0; border-radius: 4px;
991
998
  background: transparent; color: var(--doc-fg-2); font: 12px/20px var(--font-sans); text-align: left; cursor: pointer; }
992
999
  .toc-current::after { content: ""; position: absolute; right: 6px; top: 10px; width: 5px; height: 5px;
@@ -1000,15 +1007,12 @@ article a { color: var(--doc-accent); }
1000
1007
  .in-toc .lvl2 a { padding-left: 20px; }
1001
1008
  .in-toc .lvl3 a { padding-left: 30px; }
1002
1009
  .in-toc a:hover, .in-toc a[aria-current] { color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 8%, transparent); }
1003
- .toc-seek { flex: 1; appearance: none; width: 0; min-width: 24px; height: 24px; margin: 0; padding: 0; background: transparent; cursor: ew-resize; }
1004
- .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%)); }
1005
- .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%)); }
1006
- .toc-seek::-webkit-slider-thumb { appearance: none; width: 8px; height: 8px; margin-top: -3px; border: 0; border-radius: 50%; background: var(--doc-accent); }
1007
- .toc-seek::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--doc-accent); }
1008
- .toc-seek:disabled { opacity: .35; cursor: default; }
1009
- html:has(.page-actions .toc-seek), .preview-pane:has(> .pane-actions .toc-seek) { scrollbar-width: none; }
1010
- html:has(.page-actions .toc-seek)::-webkit-scrollbar,
1011
- .preview-pane:has(> .pane-actions .toc-seek)::-webkit-scrollbar { display: none; }
1010
+ .doc-title:has(.toc-card) { display: block; max-width: none; }
1011
+ .doc-title:has(.toc-card) > h1 { max-width: calc(100% - 100px); }
1012
+ .toc-card { margin: 10px 0 14px; padding: 10px; border: 1px solid var(--doc-border); border-radius: 6px; }
1013
+ .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); }
1014
+ .toc-card .toc-current { display: none; }
1015
+ .toc-card .toc-options { position: static; padding: 0; border: 0; background: transparent; box-shadow: none; }
1012
1016
  main :is(h1, h2, h3)[id] { scroll-margin-top: 52px; }
1013
1017
  article strong { font-weight: 700; }
1014
1018
  article em { font-style: italic; }
@@ -1126,7 +1130,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1126
1130
  .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; }
1127
1131
  .resource-tabs a:hover { color: var(--doc-fg); background: color-mix(in srgb, var(--doc-fg) 4%, transparent); }
1128
1132
  .resource-tabs a[aria-current] { color: var(--doc-accent); border-bottom-color: currentColor; }
1129
- .resource-toolbar { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px;
1133
+ .resource-toolbar { position: relative; display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 6px;
1130
1134
  border-bottom: 1px solid var(--c-line); color: var(--c-fg-muted); font-size: 11px; }
1131
1135
  .resource-toolbar > span { flex: none; }
1132
1136
  .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);}
@@ -1140,6 +1144,141 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1140
1144
  .resource-toolbar select option { background: var(--c-bg1); color: var(--c-fg); }
1141
1145
  .resource-count { margin-left: auto; color: var(--doc-fg-3); font-variant-numeric: tabular-nums; }
1142
1146
  .resource-items { display: flex; flex-direction: column; }
1147
+ .resource-items[hidden], [data-subformat-board][hidden] { display: none; }
1148
+ .resource-results:has([data-subformat-board]:not([hidden])) { min-width: 0; font-family: var(--font-sans); }
1149
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-toolbar { position: relative; height: auto; flex-wrap: wrap; gap: 8px 12px; padding: 8px 0 12px; }
1150
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-toolbar > [data-i18n="Name"] { display: none; }
1151
+ .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); }
1152
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-search:focus-within { border-color: var(--c-accent); }
1153
+ .resource-results:has([data-subformat-board]:not([hidden])) .resource-count { display: none; }
1154
+ .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; }
1155
+ .resources-pane:has([data-subformat-board]:not([hidden])) .preview-content { min-height: 100%; }
1156
+ .resource-results:has(> .resource-empty:not([hidden])) [data-subformat-board] { flex: none; }
1157
+ .resource-results:has(> .resource-empty:not([hidden])) .subformat-columns { display: none; }
1158
+ .resource-query { display: flex; align-items: center; gap: 8px; flex: 0 1 auto; min-width: 0; max-width: 400px; }
1159
+ .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; }
1160
+ .resource-query > select:focus-visible { outline-color: var(--c-fg-muted); }
1161
+ .subformat-picker { flex: 0 1 auto; min-width: 0; max-width: 220px; }
1162
+ [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; }
1163
+ [data-subformat-trigger]:is(:hover, :focus-visible) { border-bottom-color: var(--c-fg-muted); outline: none; }
1164
+ [data-subformat-trigger]:disabled { cursor: default; }
1165
+ .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); }
1166
+ .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; }
1167
+ .subformat-picker-menu button:is(:hover, :focus-visible, [aria-checked="true"]) { background: var(--c-raised); outline: none; }
1168
+ .subformat-picker-menu [data-subformat-add] { margin-top: 4px; border-top: 1px solid var(--c-line); font-size: 13px; }
1169
+
1170
+ .resource-results [data-subformat-change="added"] { color: var(--c-ok); }
1171
+ .resource-results [data-subformat-change="modified"] { color: var(--c-accent); }
1172
+ .subformat-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; min-width: 0; max-width: 100%; margin-left: auto; }
1173
+ .subformat-control { position: relative; min-width: 80px; max-width: 160px; margin-top: 6px; }
1174
+ .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; }
1175
+ .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; }
1176
+ .subformat-control > button > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1177
+ .subformat-control > button > svg { flex: none; }
1178
+ .subformat-setting-menu { font-size: 13px; }
1179
+ .subformat-setting-option { display: flex; align-items: stretch; }
1180
+ .subformat-setting-option > button:first-child { flex: 1; min-width: 0; max-width: none; border: 0; border-radius: 0; text-align: left; background: transparent; }
1181
+ .subformat-setting-option > button[aria-checked="true"] { background: var(--c-raised); }
1182
+ .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); }
1183
+ .subformat-default[data-is-default="false"] svg { opacity: .25; }
1184
+ .subformat-default[data-is-default="true"], .subformat-default:is(:hover, :focus-visible) { color: var(--c-fg); }
1185
+ .subformat-setting-option > .subformat-default[data-layout-changed="true"] { color: var(--c-ok); }
1186
+ .subformat-default:is(:hover, :focus-visible) svg { opacity: 1; }
1187
+ .subformat-default:disabled { cursor: default; }
1188
+ .subformat-controls label { display: flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; white-space: nowrap; }
1189
+ .subformat-card label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--c-fg-muted); }
1190
+ .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; }
1191
+ .subformat-controls select { max-width: 140px; }
1192
+ .subformat-controls [data-subformat-direction] { display: grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0; }
1193
+ .subformat-controls :is(select, button) { cursor: pointer; }
1194
+ .subformat-controls :is(select, button):hover, .subformat-card select:enabled:hover { background: var(--c-raised); }
1195
+ .subformat-controls :is(select, button):focus-visible, .subformat-card select:focus-visible { outline-color: var(--c-fg-muted); }
1196
+ .subformat-card select:disabled { opacity: .55; cursor: default; }
1197
+ .subformat-toast { position: fixed; z-index: 1000; right: 20px; bottom: 20px; box-sizing: border-box;
1198
+ max-width: min(420px, calc(100vw - 40px)); max-height: 40vh; overflow: auto; padding: 12px 16px;
1199
+ border: 1px solid var(--c-danger); border-radius: 6px; background: var(--c-bg1); color: var(--c-danger);
1200
+ font: 13px/1.5 var(--font-sans); white-space: pre-wrap; overflow-wrap: anywhere; }
1201
+ .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; }
1202
+ .subformat-column { display: flex; flex-direction: column; flex: 1 0 248px; min-width: 0; }
1203
+ .subformat-cards { flex: 1; min-height: 100px; border-radius: 6px; }
1204
+ .subformat-cards.is-drop-target { background: var(--c-raised); }
1205
+ .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; }
1206
+ .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; }
1207
+ .subformat-card { max-width: none; margin: 0 0 12px; padding: 14px; border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-bg0); color: var(--c-fg); font-family: var(--font-sans); overflow-wrap: anywhere; }
1208
+ .subformat-card:hover, .subformat-card:focus-within { border-color: var(--c-fg-faint); }
1209
+ .subformat-count { display: inline-flex; align-items: center; gap: 4px; }
1210
+ .resource-results [data-record-change="added"] { --record-color: var(--c-ok); }
1211
+ .resource-results [data-record-change="modified"] { --record-color: var(--c-accent); }
1212
+ .resource-results span[data-record-change] { color: var(--record-color); }
1213
+ .subformat-card[data-record-change] { border-color: var(--record-color); }
1214
+ .subformat-controls [data-subformat-create] { height: 30px; padding-inline: 12px; }
1215
+ .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); }
1216
+ .subformat-create-form fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
1217
+ .subformat-create-form label { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-bottom: 12px; }
1218
+ .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); }
1219
+ .subformat-create-form :is(input, textarea, select, button):focus-visible { outline-color: var(--c-fg-muted); }
1220
+ .subformat-create-form textarea { resize: vertical; }
1221
+ .subformat-create-actions { display: flex; justify-content: flex-end; gap: 8px; }
1222
+ .subformat-card[draggable="true"] { cursor: grab; user-select: none; }
1223
+ .subformat-card[draggable="true"] :is(.subformat-card-open, .subformat-card-toggle) { cursor: inherit; }
1224
+ .subformat-card.is-dragging { opacity: .4; border-style: dashed; }
1225
+ .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-bg0); }
1226
+ .subformat-card h3 { min-width: 0; margin: 0; font-size: 13px; line-height: 1.55; }
1227
+ .subformat-card-open, .subformat-card-toggle, .subformat-card-copy { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
1228
+ .subformat-card :focus-visible { outline-color: var(--c-fg-muted); }
1229
+ .subformat-card .subformat-card-open:focus { outline: none; }
1230
+ .subformat-card-open:focus-visible { text-decoration: underline; text-underline-offset: 3px; }
1231
+ .subformat-card-open, .subformat-drag-preview strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; text-align: left; font-weight: 500; overflow-wrap: anywhere; }
1232
+ .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); }
1233
+ .subformat-card-toggle:hover, .subformat-card-copy:hover { background: var(--c-raised); color: var(--c-fg); }
1234
+ .subformat-card-copy .ic-ok, .subformat-card-copy[data-copied] svg:not(.ic-ok) { display: none; }
1235
+ .subformat-card-copy[data-copied] .ic-ok { display: block; }
1236
+ .subformat-card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
1237
+ .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; }
1238
+ .subformat-card-tools .subformat-card-file { flex: 1; max-width: 170px; }
1239
+ .subformat-drag-preview .subformat-card-file { margin-top: 6px; }
1240
+ .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; }
1241
+ .subformat-card-references:disabled { cursor: default; }
1242
+ .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); }
1243
+ .subformat-reference-list ul { margin: 0; padding: 0; list-style: none; }
1244
+ .subformat-reference-list a { display: flex; align-items: baseline; gap: 12px; padding: 7px 8px; color: inherit; text-decoration: none; }
1245
+ .subformat-reference-list a > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
1246
+ .subformat-reference-list a > span:last-child { flex: none; color: var(--c-fg-muted); font-variant-numeric: tabular-nums; }
1247
+ .subformat-reference-list a:is(:hover, :focus-visible) { background: var(--c-raised); outline-color: var(--c-fg-muted); }
1248
+ .subformat-card dl { margin: 12px 0 0; font-size: 12px; }
1249
+ .subformat-card dt, .subformat-detail dt { color: var(--c-fg-muted); font-size: 11px; }
1250
+ .subformat-card dd, .subformat-detail dd { margin: 4px 0 0; }
1251
+ .subformat-card-meta { display: flex; flex-wrap: wrap; gap: 12px 16px; padding-top: 12px; border-top: 1px solid var(--c-line-soft); }
1252
+ .subformat-card-meta:empty { display: none; }
1253
+ .subformat-card-meta > div { flex: 1 1 auto; min-width: 0; max-width: 100%; }
1254
+ .subformat-card-meta dd { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
1255
+ .subformat-card-details { margin-top: 12px; border-top: 1px solid var(--c-line-soft); }
1256
+ .subformat-card-details dl { display: grid; gap: 12px; }
1257
+ .subformat-card-details dd, .subformat-detail dd { white-space: pre-wrap; overflow-wrap: anywhere; }
1258
+ .subformat-card-details label { margin-top: 12px; }
1259
+ .subformat-card [hidden] { display: none; }
1260
+ .subformat-drag-preview { position: fixed; left: -10000px; top: 0; box-sizing: border-box; pointer-events: none; border-color: var(--c-fg-faint); box-shadow: 0 8px 24px var(--c-shadow); }
1261
+ .subformat-drag-preview strong { font-size: 13px; }
1262
+ .app-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
1263
+ color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 90%, transparent);
1264
+ border: 1px solid var(--c-fg-faint); border-radius: 10px; box-shadow: 0 16px 48px #0004; backdrop-filter: blur(16px); }
1265
+ .app-dialog::backdrop { background: #0005; backdrop-filter: blur(2px); }
1266
+ .app-dialog h2 { margin: 0 0 14px; font-size: 16px; overflow-wrap: anywhere; }
1267
+ .app-dialog p { margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-fg-muted); }
1268
+ .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
1269
+ .app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
1270
+ .app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
1271
+ .app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
1272
+ .app-dialog button.danger { color: var(--c-danger); }
1273
+ .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; }
1274
+ .subformat-page .resource-query { flex-wrap: wrap; max-width: none; }
1275
+ .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; }
1276
+ .subformat-page .resource-toolbar { align-items: flex-end; }
1277
+ .subformat-page .subformat-columns { padding-top: 20px; }
1278
+ body:not(.edit) .subformat-page { padding-top: 64px; }
1279
+ .subformat-detail-path { color: var(--c-fg-muted); font: 11px var(--doc-mono); overflow-wrap: anywhere; }
1280
+ .subformat-detail dl { display: grid; gap: 14px; margin: 20px 0; }
1281
+ .subformat-detail dt { font-size: 12px; }
1143
1282
  .resource-item { min-width: 0; margin: 0; padding: 0; border: 0; }
1144
1283
  .resource-item[hidden], .resource-empty[hidden] { display: none; }
1145
1284
  .resource-item > summary { display: flex; align-items: center; gap: 8px; min-width: 0; height: 28px; padding: 0 6px;
@@ -1160,8 +1299,6 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1160
1299
  .resource-source span { flex: none; opacity: .7; }
1161
1300
  .resource-source .resource-source-file { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; opacity: 1; }
1162
1301
  .resource-badge { flex: none; color: var(--doc-fg-2); font: 11px var(--doc-mono); }
1163
- .resource-item .term-definition { margin: 0; white-space: pre-wrap; font-size: 13px; }
1164
- .resource-description { color: var(--doc-fg-3); white-space: pre-wrap; font-size: 12px; margin: 6px 0 0; }
1165
1302
  .resource-item .codeblk { margin: 0; }
1166
1303
  .resource-item .codeblk > pre { max-height: 260px; overflow: auto; }
1167
1304
  .resource-usage { flex: none; margin-left: auto; color: var(--doc-fg-3); font-size: 11px; font-variant-numeric: tabular-nums; }
@@ -1182,6 +1319,9 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
1182
1319
  const EDIT_CSS = `
1183
1320
  body.git-diff-hidden .cm-lineNumbers :is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { box-shadow: none; }
1184
1321
  body.git-diff-hidden .cm-line:is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { background-color: transparent; }
1322
+ #site-title[role="button"] { cursor: text; position: relative; }
1323
+ #site-title:focus-visible { outline: 1px solid var(--c-line); }
1324
+ #site-title .nav-rename-form { inset: 0; padding: 0; }
1185
1325
  #site-icon-slot input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
1186
1326
  #site-icon-slot:hover, #site-icon-slot:focus-within, #sidebar-head.over #site-icon-slot { background: var(--c-line); border-radius: 3px; }
1187
1327
  #site-icon-slot:focus-within, #sidebar-head.over #site-icon-slot { outline: 1px solid var(--c-fg-muted); outline-offset: 2px; }
@@ -1206,6 +1346,119 @@ body.textfile-open #phead :is(.fm-language, #status, #validate, #save, #split-pr
1206
1346
  #file-editor .cm-textfile-status { padding: 8px 12px; white-space: pre-wrap; }
1207
1347
  #file-editor .cm-textfile-status[hidden] { display: none; }
1208
1348
  #file-editor .cm-textfile-status.error { color: var(--doc-danger); }
1349
+ #file-editor[data-subformat-register] { position: static; width: auto; max-height: none; padding: 0; border: 0; border-radius: 0; overflow: hidden; }
1350
+ #file-editor[data-subformat-register] fieldset { display: flex; flex-direction: column; flex: 1; min-height: 0; }
1351
+ .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; }
1352
+ .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); }
1353
+ .subformat-register-fields input:hover, .subformat-register-fields input:focus-visible { background: transparent; outline: none; border-bottom-color: var(--c-fg-muted); }
1354
+ .subformat-register-fields .language-select { min-width: 0; }
1355
+ .subformat-register-fields .subformat-control { align-self: center; min-width: 0; max-width: none; margin: 3px 0 0; }
1356
+ .subformat-register-fields .subformat-control-label { top: -5px; left: 5px; padding: 0 3px; font-size: 9px; line-height: 10px; }
1357
+ .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; }
1358
+ .subformat-register-fields .language-select::after { right: 6px; top: 9px; width: 4px; height: 4px; }
1359
+ .subformat-register-fields :disabled { opacity: .5; }
1360
+ .subformat-register-fields input::placeholder { color: var(--c-fg-muted); opacity: 1; }
1361
+ .subformat-register-fields input[name="schema"]:not([placeholder="path"])::placeholder { opacity: .55; }
1362
+ #phead:has(.subformat-register-fields) { padding-inline: 6px; }
1363
+ .file-editor-heading:has(.subformat-register-fields) { gap: 4px; margin-left: 2px; }
1364
+ [data-subformat-schema-editor] { flex: 1; min-height: 0; }
1365
+ #file-editor[data-subformat-register] .subformat-create-actions { flex: none; padding: 10px 14px; border-top: 1px solid var(--c-line); }
1366
+ #file-editor[data-subformat-register] [hidden] { display: none; }
1367
+ .schema-editor-host { display: flex; flex-direction: column; min-height: 0; }
1368
+ .schema-editor-host > .cm-editor { flex: 1; min-height: 0; }
1369
+ .schema-editor-host > [hidden] { display: none !important; }
1370
+ .schema-mode-switch:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 1px; }
1371
+ .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); }
1372
+ .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; }
1373
+ .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); }
1374
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea) { padding: 4px 6px; border: 0; border-radius: 3px; background: var(--c-bg1); }
1375
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea):hover { background: var(--c-raised); }
1376
+ .schema-builder :is(input:not([type="checkbox"]), select, textarea):focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 1px; }
1377
+ .schema-builder .schema-type-control { display: block; min-width: 0; max-width: none; margin: 0; }
1378
+ .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); }
1379
+ .schema-type-control .language-select::after { right: 8px; top: 10px; width: 5px; height: 5px; }
1380
+ .schema-builder .schema-type-control > .subformat-control-label { padding: 0 4px; }
1381
+ .schema-builder :is(input, textarea) { width: 100%; }
1382
+ .schema-builder textarea { resize: vertical; }
1383
+ .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; }
1384
+ .schema-builder input[type="checkbox"]:checked { border-color: var(--c-fg-muted); }
1385
+ .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; }
1386
+ .schema-builder input[type="checkbox"]:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 3px; }
1387
+ .schema-builder button { cursor: pointer; }
1388
+ .schema-builder button:hover { background: var(--c-raised); }
1389
+ .schema-builder button:disabled { opacity: .45; cursor: default; }
1390
+ .schema-field { position: relative; min-width: 0; }
1391
+ .schema-builder > :is(.schema-field, .schema-add-field, .schema-draft-details) { max-width: 560px; }
1392
+ .schema-builder > .schema-field { margin-bottom: 8px; }
1393
+ .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; }
1394
+ .schema-field-name { display: flex; align-items: center; gap: 2px; min-width: 0; }
1395
+ .schema-field-name > :first-child { flex: 1; min-width: 0; }
1396
+ .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; }
1397
+ .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; }
1398
+ .schema-field-row .language-select, .schema-add-field .language-select { flex: 1; min-width: 0; }
1399
+ .schema-children { container-type: inline-size; margin: 2px 0 0 8px; padding-left: 13px; }
1400
+ .schema-children > .schema-field::before { content: ""; position: absolute; left: -13px; top: 0; height: 20px; border-left: 1px solid var(--c-line-soft); }
1401
+ .schema-children > .schema-field:has(~ .schema-field, ~ .schema-add-field)::before { height: auto; bottom: 0; }
1402
+ .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); }
1403
+ .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); }
1404
+ .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; }
1405
+ .schema-expand[aria-expanded="true"] svg { transform: rotate(180deg); }
1406
+ .schema-field-details { container-type: inline-size; }
1407
+ .schema-field-details[hidden] { display: none; }
1408
+ .schema-field-actions { justify-self: end; display: flex; gap: 2px; }
1409
+ .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); }
1410
+ .schema-field-name > button, .schema-field-name > div { flex: none; }
1411
+ .schema-expand:disabled { visibility: hidden; }
1412
+ .schema-item-name { padding-left: 6px; height: 28px; line-height: 28px; color: var(--c-fg-muted); }
1413
+ .schema-parameter-menu { width: 184px; overflow-y: auto; }
1414
+ .schema-parameter-menu .language-options button { height: auto; min-height: 28px; width: 100%; display: block; padding: 5px 8px; text-align: left; }
1415
+ .schema-parameter-menu .language-options button:focus-visible { background: var(--c-raised); outline: none; }
1416
+ .schema-parameter-group { margin: 4px 0 8px 6px; }
1417
+ .schema-parameter { display: grid; grid-template-columns: minmax(0, 1fr) 24px; align-items: center; gap: 2px; min-width: 0; grid-column: 1 / -1; }
1418
+ .schema-parameter[data-schema-bound="min"] { grid-column: 1; }
1419
+ .schema-parameter[data-schema-bound="max"] { grid-column: 2; }
1420
+ .schema-parameter label { display: grid; grid-template-columns: 100px minmax(0, 1fr); align-items: center; gap: 8px; }
1421
+ .schema-parameter label > span { overflow-wrap: anywhere; }
1422
+ .schema-parameter label:has(> textarea) { align-items: start; }
1423
+ .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; }
1424
+ .schema-parameter > button { display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; background: transparent; color: var(--c-fg-muted); }
1425
+ .schema-parameter:has(textarea) > button { align-self: start; }
1426
+ .schema-builder [hidden] { display: none; }
1427
+ .schema-constraints { display: grid; gap: 4px; }
1428
+ .schema-parameter-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
1429
+ .schema-parameter-row:not(.schema-range) > .schema-parameter { grid-column: 1 / -1; }
1430
+ .schema-range { grid-template-columns: minmax(0, 1fr) minmax(48px, .7fr) minmax(0, 1fr); align-items: center; }
1431
+ .schema-range .schema-parameter { grid-row: 1; }
1432
+ .schema-range [data-schema-bound="max"] { grid-column: 3; }
1433
+ .schema-range .schema-parameter label { grid-template-columns: minmax(0, 1fr) 60px; gap: 4px; }
1434
+ .schema-range .schema-parameter input { font-variant-numeric: tabular-nums; }
1435
+ .schema-range-track { position: relative; grid-column: 1 / -1; height: 24px; }
1436
+ .schema-range > .schema-range-track { grid-column: 2; grid-row: 1; }
1437
+ .schema-range-track::before, .schema-range-track > span { content: ""; position: absolute; top: 11px; left: 5px; right: 5px; height: 2px; background: var(--c-line); }
1438
+ .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); }
1439
+ .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; }
1440
+ .schema-range-track input::-webkit-slider-runnable-track { height: 2px; background: transparent; }
1441
+ .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; }
1442
+ .schema-range-track input::-moz-range-track { height: 2px; background: transparent; }
1443
+ .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; }
1444
+ .schema-range-track input:focus-visible { z-index: 1; }
1445
+ .schema-range-track input:disabled { opacity: .45; }
1446
+ .schema-range-track input:disabled::-webkit-slider-thumb { pointer-events: none; }
1447
+ .schema-range-track input:disabled::-moz-range-thumb { pointer-events: none; }
1448
+ .schema-add-field { padding: 8px 0 4px; }
1449
+ .schema-add-actions { justify-self: end; display: flex; align-items: center; }
1450
+ .schema-add-actions > button { min-height: 28px; padding: 4px; white-space: nowrap; }
1451
+ .schema-add-actions > button + button { margin-left: 4px; border: 0; background: transparent; color: var(--c-fg-muted); }
1452
+ .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; }
1453
+ .schema-json-note { margin: 8px 0 0; color: var(--c-fg-muted); font-size: 11px; }
1454
+ .schema-builder .schema-extra-fields { margin: 6px 0; }
1455
+ .subformat-value-form > label, .subformat-value-form fieldset > label { margin-block: 12px; }
1456
+ .subformat-value-form fieldset { min-width: 0; margin: 12px 0; padding: 0 12px; border: 1px solid var(--c-line); }
1457
+ .subformat-value-form legend { padding-inline: 4px; }
1458
+ .subformat-value-form small { overflow-wrap: anywhere; }
1459
+ @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; } }
1460
+ @container(max-width:440px) { .schema-add-field { grid-template-columns: minmax(0, 1fr) auto; } }
1461
+ @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; } }
1209
1462
 
1210
1463
  /* header band (same height and rule as sidebar-head) */
1211
1464
  #phead { flex: none; display: flex; align-items: center; gap: 2px; height: 36px; padding: 0 10px 0 14px;
@@ -1249,17 +1502,6 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1249
1502
  .cm-file-preview[data-state="loading"] svg { animation: preview-spin 1s linear infinite; }
1250
1503
  @keyframes preview-spin { to { transform: rotate(360deg); } }
1251
1504
  @media (prefers-reduced-motion: reduce) { .cm-file-preview[data-state="loading"] svg { animation: none; } }
1252
- .app-dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
1253
- color: var(--c-fg); background: color-mix(in srgb, var(--c-bg1) 90%, transparent);
1254
- border: 1px solid var(--c-fg-faint); border-radius: 10px; box-shadow: 0 16px 48px #0004; backdrop-filter: blur(16px); }
1255
- .app-dialog::backdrop { background: #0005; backdrop-filter: blur(2px); }
1256
- .app-dialog h2 { margin: 0 0 14px; font-size: 16px; overflow-wrap: anywhere; }
1257
- .app-dialog p { margin: 0 0 22px; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--c-fg-muted); }
1258
- .dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
1259
- .app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
1260
- .app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
1261
- .app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
1262
- .app-dialog button.danger { color: var(--c-danger); }
1263
1505
  .app-dialog:has(.conflict-columns) { width: min(1000px, calc(100vw - 32px)); }
1264
1506
  .conflict-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
1265
1507
  .conflict-columns h3 { font-size: 13px; margin: 0; }
@@ -1270,11 +1512,22 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1270
1512
  min-width: 220px; padding: 4px; flex-direction: column; gap: 1px; color: var(--c-fg);
1271
1513
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 6px;
1272
1514
  box-shadow: 0 10px 28px var(--c-shadow); font-size: 12.5px; }
1273
- #gear:hover #gearmenu, #gear:focus-within #gearmenu, #gear.open #gearmenu { display: flex; }
1515
+ #gear:hover #gearmenu, #gear:focus-within #gearmenu, #gear.open #gearmenu, #gear:has([aria-expanded="true"]) #gearmenu { display: flex; }
1274
1516
  #gearmenu label { display: flex; gap: 10px; align-items: center; cursor: pointer;
1275
1517
  padding: 7px 10px; border-radius: 4px; }
1276
1518
  #gearmenu label:hover { background: var(--c-raised); }
1277
1519
  #gearmenu input { accent-color: var(--c-accent); margin: 0; }
1520
+ .editor-setting { display: grid; grid-template-columns: 20px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px 8px 4px; }
1521
+ .editor-setting > .nav-icon, .editor-setting-icon { color: var(--c-fg-muted); }
1522
+ .editor-setting-icon { display: grid; place-items: center; }
1523
+ .editor-setting .subformat-control { min-width: 0; max-width: none; margin: 0; }
1524
+ .editor-setting .subformat-control-label { background: var(--c-surface); }
1525
+ .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); }
1526
+ .editor-setting .setting-picker { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; }
1527
+ .editor-setting .setting-picker > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1528
+ .editor-setting .setting-picker > svg { flex: none; }
1529
+ .editor-setting .language-select-input { padding-right: 26px; }
1530
+ .editor-setting .setting-picker:hover { background: var(--c-raised); }
1278
1531
 
1279
1532
  .fm-language { display: flex; align-items: center; flex: 0 1 220px; min-width: 0; gap: 4px; }
1280
1533
  .fm-language > .language-select { flex: 1; width: 0; min-width: 0; }
@@ -1310,7 +1563,7 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
1310
1563
 
1311
1564
  main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction: column; position: sticky; top: 0; }
1312
1565
  #split-preview[aria-pressed="true"] { color: var(--c-accent); background: var(--c-raised); }
1313
- .pane-actions { top: -20px; margin: -20px -24px 20px; }
1566
+ .pane-actions { top: -20px; margin: -20px -24px -36px; }
1314
1567
  #preview-panes { display: flex; flex: 1; min-height: 0; }
1315
1568
  #preview-panes[hidden] { display: none; }
1316
1569
  .preview-pane.resources-pane { min-height: 0; padding-bottom: 24px; }
@@ -1318,7 +1571,7 @@ main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction
1318
1571
  .resources-pane .resource-tabs { margin-inline: -24px; padding: 0 12px; }
1319
1572
  .preview-pane { flex: 1; min-width: 0; overflow: auto; padding: 20px 24px 50vh; border-top: 2px solid transparent; }
1320
1573
  #preview-panes.split .preview-pane { padding: 16px; }
1321
- #preview-panes.split .pane-actions { top: -16px; margin: -16px -16px 16px; padding-inline: 10px; }
1574
+ #preview-panes.split .pane-actions { top: -16px; margin: -16px -16px -36px; padding-inline: 10px; }
1322
1575
  #preview-panes.split .preview-pane + .preview-pane { border-left: 1px solid var(--c-line); }
1323
1576
  #preview-panes.split .preview-pane.active { border-top-color: var(--c-accent); }
1324
1577
  .preview-pane:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
@@ -1329,8 +1582,8 @@ main.editor-workspace { padding: 0; height: 100vh; display: flex; flex-direction
1329
1582
  .language-option[aria-checked="true"]::before { content: "✓"; }
1330
1583
  .language-option:hover, .language-option:focus-visible { background: var(--c-raised); outline: none; }
1331
1584
  .language-option:disabled { opacity: .5; cursor: wait; }
1332
- #language-setting { flex: none; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--c-line); }
1333
- #language-setting .language-select { width: 160px; }
1585
+ #language-setting { padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--c-line); }
1586
+ #language-setting .language-select { width: 100%; }
1334
1587
  .cm-code-diagnostic { text-decoration:underline wavy var(--c-warn); text-underline-offset:3px; }
1335
1588
  #validate[data-state="error"], .cm-textfile-validate[data-state="error"] { color:var(--c-danger); }
1336
1589
  #validate[data-state="valid"], .cm-textfile-validate[data-state="valid"] { color:var(--c-ok); }
@@ -1402,7 +1655,7 @@ body.corr main article > [data-ln].corr-hi {
1402
1655
  .files-copy svg {width:14px;height:14px;color:var(--c-fg-faint);}
1403
1656
  .files-table tr:hover .files-copy,.files-table tr:focus-within .files-copy {opacity:1;}
1404
1657
  @media(hover:none){.files-copy{opacity:1;}}
1405
- .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;}
1658
+ .files-table [data-drop=into], .files-viewport[data-drop=into] {outline:2px solid var(--c-accent);outline-offset:-2px;}
1406
1659
  .files-table .files-placeholder {height:96px;text-align:center;vertical-align:middle;}
1407
1660
  .app-dialog textarea {display:block;box-sizing:border-box;width:100%;min-height:64px;max-height:65vh;resize:both;font:inherit;}
1408
1661
  @media(max-width:600px){.files-table {min-width:0;}.files-table th:nth-child(2){width:65px;}.files-name{max-width:100%;}}
@@ -1415,8 +1668,6 @@ body.corr main article > [data-ln].corr-hi {
1415
1668
  .res-crumbs { color: var(--c-fg-faint); font-size: 12.5px; margin: 0 0 20px; }
1416
1669
  .res-crumbs a { color: var(--c-fg-muted); text-decoration: none; }
1417
1670
  .res-crumbs a:hover { color: var(--c-fg); }
1418
- .res-section h2 { font-size: 15px; border: 0; margin: 28px 0 10px; }
1419
- .res-section h2 a { color: inherit; text-decoration: none; }
1420
1671
  .res-sub { color: var(--c-fg-faint); font-size: 11.5px; font-weight: 400; }
1421
1672
  .res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
1422
1673
  .res-card { display: flex; flex-direction: column; border: 1px solid var(--c-line); border-radius: 6px;
@@ -1431,18 +1682,15 @@ body.corr main article > [data-ln].corr-hi {
1431
1682
  pointer-events: none; }
1432
1683
  .res-preview .res-svg { max-height: 480px; }
1433
1684
  .res-preview .res-html { width: 100% !important; }
1434
- .res-thumb .res-frame { width: 100%; height: 100%; border: 0; pointer-events: none; background: #fff; }
1435
1685
  .res-meta { display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-top: 1px solid var(--c-line); }
1436
1686
  .res-name { font-family: var(--doc-mono); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1437
1687
  .res-preview { display: flex; align-items: center; justify-content: center; min-height: 160px; padding: 16px;
1438
1688
  border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-bg0); }
1439
1689
  .res-preview .res-img { max-width: 100%; max-height: 480px; }
1440
1690
  .res-preview.square .res-img { width: 160px; height: 160px; outline: 1px dashed var(--c-line); }
1441
- .res-preview .res-frame { width: 100%; height: 420px; border: 0; background: #fff; }
1442
1691
  .res-markdown { width: 100%; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
1443
1692
  .res-thumb .res-markdown { max-height: 100%; overflow: hidden; font-size: 11px; }
1444
1693
  .res-preview .res-markdown { max-height: 480px; overflow: auto; }
1445
- .res-empty { color: var(--c-fg-faint); }
1446
1694
  .res-dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 16px 0 0; font-size: 13px; }
1447
1695
  .res-dl dt { color: var(--c-fg-faint); }
1448
1696
  .res-dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@@ -1469,14 +1717,31 @@ body.corr main article > [data-ln].corr-hi {
1469
1717
  .nav-tree-spacer { flex: none; height: 28px; }
1470
1718
  @media (hover: none) { .nav-row :is(.new, .nav-delete) { opacity: 1; } }
1471
1719
  .nav-row > .nav-create { margin: 7px 12px; opacity: 1; }
1472
- .nav-add-hover { visibility: hidden; }
1473
- #sidebar:hover .nav-add-hover, #sidebar:focus-within .nav-add-hover { visibility: visible; }
1474
1720
  #sidebar .nav-list:has(> .nav-new-item) > .nav-placeholder { display: none; }
1721
+ .nav-page-menu { position: fixed; inset: auto; margin: 0; padding: 4px; width: 200px;
1722
+ max-width: calc(100vw - 16px); box-sizing: border-box; overflow: auto;
1723
+ border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-surface); color: var(--c-fg);
1724
+ box-shadow: 0 8px 24px var(--c-shadow); font: 12px/1.5 var(--font-sans); }
1725
+ .nav-page-menu > button { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px;
1726
+ padding: 7px 10px; border: 0; border-radius: 4px; background: transparent; color: inherit;
1727
+ font: inherit; text-align: left; cursor: pointer; }
1728
+ .nav-page-menu > button svg { width: 16px; height: 16px; flex: none; color: var(--c-fg-muted); }
1729
+ .nav-page-menu > button:not(:disabled):hover { background: var(--c-raised); }
1730
+ .nav-page-menu :focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: -2px; }
1731
+ .nav-page-menu button:disabled { color: var(--c-fg-muted); cursor: default; }
1732
+ .nav-page-menu .nav-page-chevron { display: flex; margin-left: auto; transform: rotate(90deg); }
1733
+ .nav-page-menu .nav-page-chevron svg { width: 12px; height: 12px; }
1734
+ .nav-page-menu .subformat-setting-option > button:is(:hover, :focus-visible) { background: var(--c-raised); }
1735
+ .nav-page-menu .err { margin: 0; padding: 4px 10px; color: var(--c-danger); overflow-wrap: anywhere; }
1736
+ .nav-page-menu .err:empty { display: none; }
1475
1737
  /* Keep the title and filename together in a compact create form. */
1476
1738
  .nav-row > .nav-new { position: relative; display: flex; flex: 1; min-width: 0;
1477
1739
  flex-direction: column; justify-content: center; align-items: stretch; cursor: auto;
1478
- margin: 4px 0; height: 42px; padding: 5px 38px 5px 36px;
1479
- border: 1px dashed var(--c-line); border-radius: 6px; background: var(--c-raised); }
1740
+ margin: 4px 0; gap: 10px; padding: 12px;
1741
+ border: 1px solid var(--c-line); border-radius: 6px; background: var(--c-raised); }
1742
+ .nav-new-heading { margin: 0; color: var(--c-fg-muted); font-size: 11px; }
1743
+ .nav-new :is(input, button):focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 2px; }
1744
+ .nav-new [hidden] { display: none; }
1480
1745
  .nav-tree .nav-new { margin-left: calc(var(--nav-pad) - 12px); }
1481
1746
  .nav-new > .nav-icon { position: absolute; left: 12px; top: 10px; color: var(--c-fg-faint); }
1482
1747
  .nav-new input { font: inherit; color: var(--c-fg); background: transparent; border: none;
@@ -1486,9 +1751,10 @@ body.corr main article > [data-ln].corr-hi {
1486
1751
  .nav-new-file { display: flex; align-items: center; color: var(--c-fg-faint);
1487
1752
  font: 10px/12px var(--doc-mono); }
1488
1753
  .nav-new-file input { flex: 1; font-family: inherit; font-size: inherit; color: var(--c-fg-muted); }
1489
- .nav-new-go { position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
1490
- display: flex; align-items: center; justify-content: center; width: 24px;
1491
- height: 24px; padding: 0; font-size: 11px; color: var(--c-fg-faint); background: none;
1754
+ .nav-new-actions { display: flex; justify-content: flex-end; gap: 8px; }
1755
+ .nav-new-cancel { padding: 4px 8px; color: var(--c-fg-muted); background: none; border: 0; border-radius: 4px; font: inherit; cursor: pointer; }
1756
+ .nav-new-go { flex: none; display: flex; align-items: center; justify-content: center;
1757
+ min-height: 30px; padding: 4px 10px; font: inherit; color: var(--c-fg); background: var(--c-bg0);
1492
1758
  border: 1px solid var(--c-line); border-radius: 4px; cursor: pointer; }
1493
1759
  .nav-new-go:hover { color: var(--c-accent); border-color: var(--c-accent); }
1494
1760
  .nav-new .err { position: absolute; top: 100%; left: 0; right: 0; z-index: 5; padding: 4px;
@@ -1507,7 +1773,7 @@ body.edit .nav-row { cursor: grab; }
1507
1773
  .nav-row.drop-into > a { background: color-mix(in srgb, var(--c-accent) 18%, transparent); }
1508
1774
  `;
1509
1775
  // Contents of #nav-groups (the doc tree). Used by both page()'s initial render and
1510
- // `GET /api/nav` (edit mode; the client replaces just the innerHTML after an md change)
1776
+ // `GET /api/nav` (edit mode; the client reconciles changed nodes after an md change)
1511
1777
  // (= the same value isn't declared in two places).
1512
1778
  // Each item is a page row and its children list, emitted even when empty
1513
1779
  // (it's the insertion target for the sidebar create form / drag).
@@ -1524,14 +1790,14 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1524
1790
  // A doc-specific icon (icons/<id>.svg), if any, replaces the book icon at top
1525
1791
  // level and goes before the label below that.
1526
1792
  let link = depth === 0
1527
- ? `<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>`
1528
- : `<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>`;
1793
+ ? `<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>`
1794
+ : `<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>`;
1529
1795
  let actions = "";
1530
1796
  let editableIcon = "";
1531
1797
  if (mode === "edit") {
1532
1798
  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>`;
1533
- 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>`;
1534
- 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>`;
1799
+ 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>`;
1800
+ 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>`;
1535
1801
  }
1536
1802
  const branch = childrenOf(site.entries, e.id).length > 0;
1537
1803
  const toggle = branch
@@ -1539,17 +1805,20 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1539
1805
  : mode === "edit"
1540
1806
  ? '<span class="nav-tree-spacer" aria-hidden="true"></span>'
1541
1807
  : "";
1542
- 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>`;
1808
+ 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>`;
1543
1809
  })
1544
1810
  .join("");
1545
1811
  const placeholder = mode === "edit" && depth === 0
1546
- ? `<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>`
1812
+ ? `<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>`
1547
1813
  : "";
1548
1814
  return depth === 0
1549
1815
  ? `<div class="nav-list nav-root" data-parent=""${mode === "edit" ? ' id="nav-docs"' : ""}>${items}${placeholder}</div>`
1550
1816
  : `<div class="nav-list nav-tree" data-parent="${escapeHtml(parent ?? "")}" style="--nav-depth:${depth + 1}">${items}${placeholder}</div>`;
1551
1817
  };
1552
- const html = list(undefined, 0) + (mode === "edit" ? navFilesHtml(site, currentRes) : "");
1818
+ const html = list(undefined, 0) +
1819
+ (mode === "edit"
1820
+ ? `<template data-page-subformats>${escapeHtml(JSON.stringify((site.subformats ?? []).filter((format) => !site.entries.some((entry) => entry.subformat?.ext === format.ext))))}</template>${navFilesHtml(site, currentRes)}`
1821
+ : "");
1553
1822
  return docLinks(site, site.contentLanguage ? languageLinks(html, site.contentLanguage) : html);
1554
1823
  };
1555
1824
  // ── Resources (file management in edit mode; linked figures and terms also in preview) ──
@@ -1557,7 +1826,9 @@ export const navGroupsHtml = (mode, site, currentId, currentRes) => {
1557
1826
  // Route is `/_files[/<kind>[/<file>]]` (doc ids can't start with `_`, so no collision).
1558
1827
  const RESOURCE_KINDS = ["markdown", "figures", "html", "icons", "terms"];
1559
1828
  const siteResources = (site) => [
1560
- ...site.entries.map((entry) => ({
1829
+ ...site.entries
1830
+ .filter((entry) => !entry.subformat)
1831
+ .map((entry) => ({
1561
1832
  kind: "markdown",
1562
1833
  file: entry.file,
1563
1834
  path: entry.sourceFile ?? CONTENT_PREFIX + entry.file,
@@ -1587,17 +1858,17 @@ const resourceHref = (kind, file) => `/_files${kind ? `/${kind}` : ""}${file ? `
1587
1858
  const navFilesHtml = (site, currentRes) => {
1588
1859
  const source = site.workspace;
1589
1860
  const statics = currentRes?.startsWith("_statics") ||
1590
- ["dictionary", "code", "urls"].includes(currentRes ?? "");
1591
- const folderIcon = icon('<path d="M2 5h6l2 2h8v10H2Z"/>');
1861
+ ["codeblocks", "urls", "url-previews", "dictionary", "code"].includes(currentRes ?? "");
1592
1862
  const hint = `<div class="files-drop-hint" aria-hidden="true">${UPLOAD_ICON}<span data-i18n="Upload files">Upload files</span></div>`;
1593
1863
  const location = source?.protocol === "git"
1594
- ? `<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>`
1595
- : `<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>`;
1864
+ ? `<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>`
1865
+ : `<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>`;
1596
1866
  const git = source?.protocol === "git"
1597
1867
  ? `<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>`
1598
1868
  : "";
1599
1869
  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>`;
1600
- 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>`;
1870
+ 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>`;
1871
+ 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>`;
1601
1872
  };
1602
1873
  const formatSize = (bytes) => bytes < 1024
1603
1874
  ? `${bytes} B`
@@ -1678,6 +1949,12 @@ export const textfilePreviewHtml = (site, file, source) => {
1678
1949
  };
1679
1950
  export const textfilePreviewErrors = (site, file, source) => {
1680
1951
  const errors = textfilePreview(site, file, source).errors;
1952
+ try {
1953
+ validateSubformatFile(root, file, source);
1954
+ }
1955
+ catch (error) {
1956
+ errors.push(error instanceof Error ? error.message : String(error));
1957
+ }
1681
1958
  if (/\.(md|markdown)$/i.test(file)) {
1682
1959
  const { doc, source: parsed } = compileDraft(draftContext(site), file, source);
1683
1960
  errors.push(...parsed.errors);
@@ -1704,8 +1981,8 @@ export const resourcesMain = (site, rest) => {
1704
1981
  }
1705
1982
  : undefined;
1706
1983
  if (rest === "_statics" || rest.startsWith("_statics/")) {
1707
- const view = rest.slice("_statics".length).replace(/^\//, "") || "dictionary";
1708
- return ["dictionary", "code", "urls"].includes(view)
1984
+ const view = rest.slice("_statics".length).replace(/^\//, "") || "codeblocks";
1985
+ return ["codeblocks", "urls", "url-previews", "dictionary", "code"].includes(view)
1709
1986
  ? resourcesMain(site, view)
1710
1987
  : undefined;
1711
1988
  }
@@ -1718,11 +1995,19 @@ export const resourcesMain = (site, rest) => {
1718
1995
  main: `<article class="res-page files-page resource-library"><div id="files-manager"></div></article>`,
1719
1996
  };
1720
1997
  }
1721
- if (!file && (kind === "dictionary" || kind === "code" || kind === "urls")) {
1998
+ if (!file && (kind === "dictionary" || kind === "code"))
1999
+ return resourcesMain(site, "codeblocks");
2000
+ if (!file &&
2001
+ (kind === "codeblocks" ||
2002
+ kind === "urls" ||
2003
+ kind === "url-previews" ||
2004
+ kind === "_subformats")) {
1722
2005
  const index = resourceIndex(root, site.filePaths ?? filesSnapshot(root).files.map((item) => item.path));
2006
+ if (site.workspace?.protocol === "git" && index.subformats.length)
2007
+ setSubformatChanges(root, index.subformats);
1723
2008
  return {
1724
- title: "Statics",
1725
- main: `<article class="res-page files-page resource-library">${resourceTabs(kind)}${resourceLibraryHtml(index, kind)}</article>`,
2009
+ title: kind === "_subformats" ? "Subformats" : "Statics",
2010
+ main: `<article class="res-page files-page resource-library">${kind === "_subformats" ? "" : resourceTabs(kind)}${resourceLibraryHtml(index, kind === "_subformats" ? "subformats" : kind)}</article>`,
1726
2011
  };
1727
2012
  }
1728
2013
  if (kind === "file" && file) {
@@ -1828,13 +2113,21 @@ const pageTitle = (mode, title, siteTitle) => title === siteTitle ? title : `${t
1828
2113
  const page = (mode, site, opts) => {
1829
2114
  const nav = navGroupsHtml(mode, site, opts.currentId, opts.currentRes);
1830
2115
  const siteTitle = escapeHtml(site.title ?? "dooc");
1831
- 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>`;
2116
+ const iconImg = `<img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>`;
2117
+ const iconVariants = Object.entries(site.iconVariants ?? {});
2118
+ // The base image sits in a wrapper so theme switching and edit-client's #site-icon.hidden never fight.
2119
+ const iconHtml = iconVariants.length
2120
+ ? `<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>`
2121
+ : iconImg;
2122
+ 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>`;
1832
2123
  const bootScripts = opts.boot != null
1833
2124
  ? `<script id="boot" type="application/json">${JSON.stringify(opts.boot).replace(/</g, "\\u003c")}</script>
1834
2125
  <script src="/assets/edit.js"></script>`
1835
2126
  : !opts.publish
1836
2127
  ? '<script src="/assets/ui.js"></script>'
1837
- : "";
2128
+ : opts.publish.subformatJs
2129
+ ? `<script>${inlineScript(opts.publish.subformatJs)}</script>`
2130
+ : "";
1838
2131
  // Interaction layer of the schema graph (zoom / pan / box drag / enlarged view). Shared by
1839
2132
  // preview / edit. Figures are readable without JS, so defer is enough (= progressive
1840
2133
  // enhancement).
@@ -1843,20 +2136,26 @@ const page = (mode, site, opts) => {
1843
2136
 
1844
2137
 
1845
2138
  <div id="preview-language-menu" role="menu" aria-label="Change language" data-i18n-aria-label="Change language" hidden></div>
1846
- <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>`
2139
+ <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>`
1847
2140
  : mode === "edit" && opts.currentRes !== undefined
1848
2141
  ? `<main class="resources-pane">${opts.main}</main>`
1849
2142
  : `<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>`;
1850
2143
  const graphScript = opts.publish
1851
2144
  ? `<script>${inlineScript(opts.publish.graphJs)}</script>`
1852
- : '<script src="/assets/graph.js" defer></script>';
2145
+ : `<script>(${loadGraphScript.toString()})();</script>`;
1853
2146
  return `<!doctype html><html lang="en"><head><meta charset="utf-8">
1854
2147
  ${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'">`}` : ""}
1855
2148
  <meta name="viewport" content="width=device-width, initial-scale=1">
1856
2149
  <title>${escapeHtml(pageTitle(mode, opts.title, site.title))}</title>
1857
- <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>
2150
+ <script>var __name = (f) => f;
2151
+ (${initializeThemes.toString()})(${JSON.stringify(site.themes)});
2152
+ (${mountFigureFrames.toString()})(document);</script>
1858
2153
  <style>${fontCss(Boolean(opts.publish))}${CSS}${mode === "edit" ? EDIT_CSS : ""}</style></head>
1859
- <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}">${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 ?? ""}
2154
+ <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 ?? ""}
2155
+ <script>
2156
+ (${mountThemePickers.toString()})(${JSON.stringify(THEME_ICONS)}, ${JSON.stringify(site.themes)});
2157
+ (${mountThemeVariants.toString()})(document);
2158
+ </script>
1860
2159
  ${bootScripts}${graphScript}
1861
2160
  <script id="code-grammars" type="application/json">${JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c")}</script>
1862
2161
  ${opts.publish ? `<script>${inlineScript(opts.publish.codeJs)}</script>` : '<script src="/assets/code.js" defer></script>'}
@@ -1869,9 +2168,6 @@ const localeFetch = (url, init = {}) => fetch(url, { ...init, headers: { ...init
1869
2168
  (${mountTables.toString()})(document);
1870
2169
  (${mountToc.toString()})(document);
1871
2170
  (${mountVideos.toString()})(document);
1872
- (${mountFigureFrames.toString()})(document);
1873
- (${mountThemeVariants.toString()})(document);
1874
- (${mountThemePickers.toString()})(${JSON.stringify(THEME_ICONS)}, ${JSON.stringify(site.themes)});
1875
2171
  void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.stringify(site.fonts ?? []).replace(/</g, "\\u003c")});
1876
2172
  (() => {
1877
2173
  const KEY = "docs:sidebar-open";
@@ -1903,7 +2199,6 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1903
2199
  }, true);
1904
2200
  })();
1905
2201
  (${mountPanelResize.toString()})();
1906
- (${mountToolsResize.toString()})();
1907
2202
  (() => {
1908
2203
  // Open/close: by default "the branch containing the current doc is open" (the server adds
1909
2204
  // .open), overridden by explicit user actions (sessionStorage = per tab only).
@@ -1911,6 +2206,8 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1911
2206
  const readOpen = () => { try { return JSON.parse(sessionStorage.getItem(OPEN_KEY) || "{}"); } catch { return {}; } };
1912
2207
  const applyOpen = () => {
1913
2208
  const o = readOpen();
2209
+ const tools = document.getElementById("nav-tools");
2210
+ if (tools) tools.open = o._tools !== false;
1914
2211
  for (const it of document.querySelectorAll("#nav-groups .nav-item")) {
1915
2212
  const key = it.dataset.docId || it.dataset.nodeId;
1916
2213
  if (key in o) it.classList.toggle("open", o[key]);
@@ -1931,6 +2228,11 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1931
2228
  const it = t.closest(".nav-item");
1932
2229
  window.__docsNavOpen(it.dataset.docId || it.dataset.nodeId, !it.classList.contains("open"));
1933
2230
  });
2231
+ document.addEventListener("toggle", (event) => {
2232
+ const tools = event.target;
2233
+ if (tools instanceof HTMLDetailsElement && tools.id === "nav-tools" && tools.isConnected)
2234
+ window.__docsNavOpen("_tools", tools.open);
2235
+ }, true);
1934
2236
  applyOpen();
1935
2237
  window.__docsNavRestore = applyOpen;
1936
2238
  const nav = document.getElementById("nav-groups");
@@ -1938,12 +2240,13 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
1938
2240
  })();
1939
2241
  ${mode === "edit"
1940
2242
  ? `(() => {
1941
- // Sidebar tree editing (delegated to document — keeps working when HMR swaps #nav-groups).
2243
+ // Sidebar tree editing stays delegated while navigation nodes are reconciled.
1942
2244
  // drag: top 1/4 of a row = before, bottom 1/4 = after, middle = move into that doc's children
1943
2245
  // (at the end). The DOM isn't moved, only a marker is shown; on drop, POST /api/move →
1944
2246
  // re-fetch the nav regardless of the outcome (= the display is always a copy of
1945
2247
  // dooc.yaml; no rollback logic).
1946
- // The root placeholder and row buttons open the create form.
2248
+ // The root placeholder and row buttons open the page type menu.
2249
+ const t = (key) => window.__docsTranslate?.(key) ?? key;
1947
2250
  const status = document.getElementById("nav-status");
1948
2251
  const setStatus = (message, error) => {
1949
2252
  if (!status) return;
@@ -1954,9 +2257,17 @@ ${mode === "edit"
1954
2257
  if (window.__docsRefreshNav) return window.__docsRefreshNav();
1955
2258
  const cur = document.querySelector("#nav-groups .nav-row a.cur");
1956
2259
  const id = (cur && cur.closest(".nav-item").dataset.docId) || "";
1957
- 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;
2260
+ 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;
1958
2261
  const res = await localeFetch("/api/nav?current=" + encodeURIComponent(id) + (rp == null ? "" : "&res=" + encodeURIComponent(rp)));
1959
- if (res.ok) document.getElementById("nav-groups").innerHTML = (await res.json()).html;
2262
+ if (res.ok) {
2263
+ const data = await res.json();
2264
+ (${updateNav.toString()})(document.getElementById("nav-groups"), data.html);
2265
+ const currentPage = document.querySelector('[data-subformat-nav][data-doc-id="' + CSS.escape(id) + '"] > .nav-row > a');
2266
+ if (currentPage && currentPage.pathname !== location.pathname) history.replaceState(null, "", currentPage.href);
2267
+ const label = document.getElementById("site-title");
2268
+ if (!label.querySelector("form")) label.textContent = label.title = data.siteTitle || "dooc";
2269
+ label.dataset.title = data.siteTitle || "";
2270
+ }
1960
2271
  if (window.__docsNavRestore) window.__docsNavRestore();
1961
2272
  document.dispatchEvent(new Event("docs:ui-refresh"));
1962
2273
  };
@@ -1969,6 +2280,10 @@ ${mode === "edit"
1969
2280
  };
1970
2281
 
1971
2282
  const docAction = (item, action) => {
2283
+ if (item.hasAttribute("data-subformat-nav")) {
2284
+ document.dispatchEvent(new CustomEvent("docs:subformat-page-action", { detail: { id: item.dataset.docId, action } }));
2285
+ return;
2286
+ }
1972
2287
  if (window.__docsDocAction) {
1973
2288
  void window.__docsDocAction(item.dataset.docId, action);
1974
2289
  } else {
@@ -1983,17 +2298,85 @@ ${mode === "edit"
1983
2298
  event.preventDefault();
1984
2299
  docAction(button.closest(".nav-item"), button.dataset.docAction);
1985
2300
  });
2301
+ const editSiteTitle = (label) => {
2302
+ if (document.querySelector(".nav-rename-form")) return;
2303
+ const original = label.textContent;
2304
+ const baseTitle = label.dataset.title || null;
2305
+ const form = document.createElement("form");
2306
+ form.className = "nav-rename-form";
2307
+ form.title = t("Enter to save / Esc to cancel");
2308
+ const input = document.createElement("input");
2309
+ input.name = "title";
2310
+ input.value = original;
2311
+ input.required = true;
2312
+ input.maxLength = 256;
2313
+ input.setAttribute("aria-label", t("Site title"));
2314
+ form.append(input);
2315
+ label.replaceChildren(form);
2316
+ input.select();
2317
+ let busy = false;
2318
+ let closed = false;
2319
+ const close = () => {
2320
+ if (closed) return;
2321
+ closed = true;
2322
+ form.remove();
2323
+ label.textContent = original;
2324
+ void refresh();
2325
+ };
2326
+ form.addEventListener("focusout", (event) => {
2327
+ if (!busy && !form.contains(event.relatedTarget)) close();
2328
+ });
2329
+ form.addEventListener("keydown", (event) => {
2330
+ if (event.isComposing) return;
2331
+ if (event.key === "Escape" && !busy) {
2332
+ event.preventDefault();
2333
+ close();
2334
+ label.focus();
2335
+ } else if (event.key === "Enter") {
2336
+ event.preventDefault();
2337
+ form.requestSubmit();
2338
+ }
2339
+ });
2340
+ form.addEventListener("submit", async (event) => {
2341
+ event.preventDefault();
2342
+ if (busy || closed || !input.value.trim()) return;
2343
+ busy = true;
2344
+ input.readOnly = true;
2345
+ try {
2346
+ const result = await post("/api/site-title", { title: input.value, baseTitle, language: new URL(location.href).searchParams.get("lang") });
2347
+ closed = true;
2348
+ form.remove();
2349
+ label.textContent = label.title = result.title;
2350
+ label.dataset.title = result.title;
2351
+ await refresh();
2352
+ label.focus();
2353
+ setStatus("", false);
2354
+ } catch (error) {
2355
+ setStatus(error.message, true);
2356
+ input.focus();
2357
+ } finally {
2358
+ busy = false;
2359
+ input.readOnly = false;
2360
+ }
2361
+ });
2362
+ };
1986
2363
  const editLabel = (event) => {
1987
2364
  if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;
1988
2365
  const target = event.target instanceof Element ? event.target : null;
1989
2366
  if (!target || target.closest("button, input, form, .nav-doc-icon")) return;
2367
+ const label = target.closest("#site-title");
2368
+ if (label) {
2369
+ event.preventDefault();
2370
+ editSiteTitle(label);
2371
+ return;
2372
+ }
1990
2373
  const row = target.closest("#nav-groups [data-doc-id] > .nav-row");
1991
2374
  if (!row) return;
1992
2375
  event.preventDefault();
1993
2376
  docAction(row.closest("[data-doc-id]"), "rename");
1994
2377
  };
1995
2378
  document.addEventListener("dblclick", editLabel);
1996
- document.addEventListener("keydown", (event) => { if (event.key === "F2") editLabel(event); });
2379
+ document.addEventListener("keydown", (event) => { if (event.key === "F2" || (event.key === "Enter" && event.target.id === "site-title")) editLabel(event); });
1997
2380
  const setIcon = async (slot, file) => {
1998
2381
  if (file && !/\\.svg$/i.test(file.name) && file.type !== "image/svg+xml") {
1999
2382
  setStatus("Icon must be svg", true);
@@ -2002,7 +2385,7 @@ ${mode === "edit"
2002
2385
  const id = slot.closest(".nav-item")?.dataset.docId;
2003
2386
  try {
2004
2387
  const data = file ? btoa(Array.from(new Uint8Array(await file.arrayBuffer()), (byte) => String.fromCharCode(byte)).join("")) : null;
2005
- const result = await post(id ? "/api/icon" : "/api/site-icon", { file: id ? id + ".md" : undefined, data });
2388
+ const result = await post(id ? "/api/icon" : "/api/site-icon", { file: id ? id + ".md" : undefined, data, theme: getComputedStyle(document.documentElement).colorScheme === "dark" ? "dark" : "light" });
2006
2389
  if (!id) {
2007
2390
  const logo = document.getElementById("site-icon");
2008
2391
  logo.src = result.icon;
@@ -2116,18 +2499,18 @@ ${mode === "edit"
2116
2499
 
2117
2500
  document.addEventListener("docs:files-changed", () => { void refresh(); });
2118
2501
 
2119
- // ── In-sidebar create form ──
2502
+ // ── Page type menu and in-sidebar create form ──
2120
2503
  const suggestFileName = ${suggestDocFileName.toString()};
2504
+ const availableSubformats = () => JSON.parse(document.querySelector("[data-page-subformats]")?.content.textContent || "[]");
2121
2505
  const closeForm = () => { for (const f of document.querySelectorAll(".nav-new-item")) f.remove(); };
2122
- const openForm = (parent) => {
2506
+ const openForm = (trigger) => {
2123
2507
  closeForm();
2508
+ const parent = trigger.dataset.parent || "";
2124
2509
  const host = parent
2125
2510
  ? document.querySelector('#nav-groups .nav-item[data-doc-id="' + CSS.escape(parent) + '"] > .nav-list')
2126
2511
  : document.querySelector("#nav-groups > .nav-list");
2127
2512
  if (!host) return;
2128
- if (parent) {
2129
- window.__docsNavOpen(parent, true);
2130
- }
2513
+ if (parent) window.__docsNavOpen(parent, true);
2131
2514
  const item = document.createElement("div");
2132
2515
  item.className = "nav-item nav-new-item";
2133
2516
  const row = document.createElement("div");
@@ -2135,11 +2518,11 @@ ${mode === "edit"
2135
2518
  const form = document.createElement("form");
2136
2519
  form.className = "nav-new";
2137
2520
  form.innerHTML =
2138
- ${JSON.stringify(DOCS_ICON)} +
2139
- '<input name="title" placeholder="title" data-i18n-placeholder="title" required autocomplete="off">' +
2140
- '<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">' +
2141
- '<button class="nav-new-go" type="submit" title="Create" data-i18n-title="Create" aria-label="Create" data-i18n-aria-label="Create">↵</button></div>' +
2142
- '<div class="err"></div>';
2521
+ '<p class="nav-new-heading" data-i18n="Markdown page">Markdown page</p>' +
2522
+ '<input name="title" placeholder="title" data-i18n-placeholder="title" aria-label="title" data-i18n-aria-label="title" required autocomplete="off">' +
2523
+ '<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>' +
2524
+ '<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>' +
2525
+ '<div class="err" role="alert"></div>';
2143
2526
  row.append(form);
2144
2527
  item.append(row);
2145
2528
  host.append(item);
@@ -2150,11 +2533,18 @@ ${mode === "edit"
2150
2533
  const err = form.querySelector(".err");
2151
2534
  let nameTouched = false;
2152
2535
  let busy = false;
2536
+ const cancel = () => {
2537
+ if (busy) return;
2538
+ closeForm();
2539
+ trigger.focus();
2540
+ };
2541
+ form.querySelector(".nav-new-cancel").addEventListener("click", cancel);
2153
2542
  title.addEventListener("input", () => { if (!nameTouched) nameInput.value = suggestFileName(title.value); });
2154
2543
  nameInput.addEventListener("input", () => { nameTouched = true; });
2155
- form.addEventListener("keydown", (e) => { if (e.key === "Escape" && !busy) closeForm(); });
2156
- // Close when focus moves out with nothing typed (keep partially filled forms).
2157
- // (remove itself fires focusout, so defer one tick and close only if still there)
2544
+ form.addEventListener("keydown", (e) => {
2545
+ if (e.key === "Escape") { e.preventDefault(); cancel(); }
2546
+ });
2547
+ // Keep partially filled forms when focus moves elsewhere.
2158
2548
  form.addEventListener("focusout", (e) => {
2159
2549
  if (busy || form.contains(e.relatedTarget) || title.value.trim() || nameInput.value.trim()) return;
2160
2550
  setTimeout(() => { if (item.isConnected && !item.contains(document.activeElement)) item.remove(); }, 0);
@@ -2166,7 +2556,7 @@ ${mode === "edit"
2166
2556
  submit.setAttribute("aria-busy", "true");
2167
2557
  err.textContent = "";
2168
2558
  try {
2169
- await post("/api/create", { parent: parent || undefined, name: nameInput.value.trim(), title: title.value.trim() });
2559
+ await post("/api/create", { parent: parent || undefined, title: title.value.trim(), name: nameInput.value.trim() });
2170
2560
  closeForm();
2171
2561
  await refresh();
2172
2562
  } catch (error) {
@@ -2179,11 +2569,121 @@ ${mode === "edit"
2179
2569
  item.scrollIntoView({ block: "nearest" });
2180
2570
  title.focus();
2181
2571
  };
2572
+ const menu = document.createElement("div");
2573
+ menu.id = "nav-page-menu";
2574
+ menu.className = "nav-page-menu";
2575
+ menu.popover = "auto";
2576
+ menu.setAttribute("role", "menu");
2577
+ menu.setAttribute("aria-label", t("Page type"));
2578
+ menu.dataset.i18nAriaLabel = "Page type";
2579
+ 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>';
2580
+ document.body.append(menu);
2581
+ const formatsMenu = menu.querySelector("#nav-subformat-menu");
2582
+ const formatTrigger = menu.querySelector('[data-page-type="subformat"]');
2583
+ const markdownTrigger = menu.querySelector('[data-page-type="markdown"]');
2584
+ const menuError = menu.querySelector(".err");
2585
+ let menuTrigger;
2586
+ let addingPage = false;
2587
+ const showMenu = (popup, trigger) => {
2588
+ popup.style.maxHeight = "";
2589
+ popup.showPopover();
2590
+ const rect = trigger.getBoundingClientRect();
2591
+ const top = popup === menu ? rect.top : rect.bottom + 4;
2592
+ const bottom = popup === menu ? rect.bottom : rect.top - 4;
2593
+ const above = innerHeight - top < popup.offsetHeight + 8 && bottom > innerHeight - top;
2594
+ Object.assign(popup.style, {
2595
+ left: Math.max(8, Math.min(rect.left, innerWidth - popup.offsetWidth - 8)) + "px",
2596
+ top: above ? "auto" : top + "px",
2597
+ bottom: above ? innerHeight - bottom + "px" : "auto",
2598
+ maxHeight: Math.max(80, (above ? bottom : innerHeight - top) - 8) + "px",
2599
+ });
2600
+ popup.querySelector("button:not(:disabled)")?.focus();
2601
+ };
2602
+ markdownTrigger.addEventListener("click", () => {
2603
+ if (addingPage) return;
2604
+ menu.hidePopover();
2605
+ openForm(menuTrigger);
2606
+ });
2607
+ formatTrigger.addEventListener("click", (event) => {
2608
+ event.preventDefault();
2609
+ if (addingPage) return;
2610
+ if (formatsMenu.matches(":popover-open")) { formatsMenu.hidePopover(); return; }
2611
+ formatsMenu.replaceChildren();
2612
+ for (const format of availableSubformats()) {
2613
+ const row = document.createElement("div");
2614
+ row.className = "subformat-setting-option";
2615
+ row.setAttribute("role", "none");
2616
+ const option = document.createElement("button");
2617
+ option.type = "button";
2618
+ option.tabIndex = -1;
2619
+ option.setAttribute("role", "menuitem");
2620
+ option.dataset.subformat = format.ext;
2621
+ option.textContent = format.ext;
2622
+ row.append(option);
2623
+ formatsMenu.append(row);
2624
+ }
2625
+ showMenu(formatsMenu, formatTrigger);
2626
+ });
2627
+ formatsMenu.addEventListener("click", async (event) => {
2628
+ const option = event.target.closest("button[data-subformat]");
2629
+ if (!option || addingPage) return;
2630
+ const parent = menuTrigger.dataset.parent || undefined;
2631
+ const subformat = option.dataset.subformat;
2632
+ addingPage = markdownTrigger.disabled = formatTrigger.disabled = true;
2633
+ menu.setAttribute("aria-busy", "true");
2634
+ menuError.textContent = "";
2635
+ setStatus("", false);
2636
+ formatsMenu.hidePopover();
2637
+ try {
2638
+ const result = await post("/api/create", { parent, subformat, title: subformat });
2639
+ menu.hidePopover();
2640
+ await refresh();
2641
+ if (result.path) {
2642
+ if (window.__docsNavigate) await window.__docsNavigate(result.path);
2643
+ else location.href = result.path;
2644
+ }
2645
+ } catch (error) {
2646
+ menuError.textContent = error.message;
2647
+ if (!menu.matches(":popover-open")) setStatus(error.message, true);
2648
+ } finally {
2649
+ addingPage = markdownTrigger.disabled = false;
2650
+ formatTrigger.disabled = !availableSubformats().length;
2651
+ menu.removeAttribute("aria-busy");
2652
+ if (menu.matches(":popover-open")) formatTrigger.focus();
2653
+ }
2654
+ });
2655
+ menu.addEventListener("keydown", (event) => {
2656
+ const popup = event.target.closest('[role="menu"]');
2657
+ const options = [...popup.querySelectorAll("button:not(:disabled)")].filter((button) => button.closest('[role="menu"]') === popup);
2658
+ const index = options.indexOf(document.activeElement);
2659
+ if (["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) {
2660
+ event.preventDefault();
2661
+ const next = event.key === "Home" ? 0 : event.key === "End" ? options.length - 1 : (index + (event.key === "ArrowDown" ? 1 : options.length - 1)) % options.length;
2662
+ options[next]?.focus();
2663
+ }
2664
+ if (event.key === "Escape" || event.key === "Tab") {
2665
+ const dismiss = event.key === "Tab" ? menu : popup;
2666
+ dismiss.hidePopover();
2667
+ (dismiss === menu ? menuTrigger : formatTrigger)?.focus();
2668
+ if (event.key === "Escape") event.preventDefault();
2669
+ }
2670
+ });
2182
2671
  document.addEventListener("click", (event) => {
2183
2672
  const btn = event.target instanceof Element ? event.target.closest("#sidebar .new, #sidebar .nav-create") : null;
2184
2673
  if (!btn) return;
2185
2674
  event.preventDefault();
2186
- openForm(btn.dataset.parent || "");
2675
+ if (addingPage) return;
2676
+ if (menu.matches(":popover-open")) {
2677
+ menu.hidePopover();
2678
+ if (menuTrigger === btn) return;
2679
+ }
2680
+ menuTrigger = btn;
2681
+ const unavailable = !availableSubformats().length;
2682
+ formatTrigger.disabled = unavailable;
2683
+ formatTrigger.title = unavailable ? t("No subformats available to add.") : "";
2684
+ menuError.textContent = "";
2685
+ menu.setAttribute("aria-label", t("Page type"));
2686
+ showMenu(menu, btn);
2187
2687
  });
2188
2688
  })();`
2189
2689
  : ""}
@@ -2238,7 +2738,7 @@ document.addEventListener("click", (ev) => {
2238
2738
  });
2239
2739
  </script>
2240
2740
  <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>
2241
- ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publish.first)}${opts.publish.network ? `\n(${mountBundleNetwork.toString()})();` : ""}</script>` : `<script>${hmrClientScript(mode)}</script>`}</body></html>`;
2741
+ ${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>`;
2242
2742
  };
2243
2743
  // A `</script` inside an inline <script> would close the script early, so escape it.
2244
2744
  const inlineScript = (js) => js.replace(/<\/(script)/gi, "<\\/$1");
@@ -2258,6 +2758,7 @@ const publishRouterScript = (first) => `
2258
2758
  const page = pages.get(route);
2259
2759
  const actions = main.querySelector(":scope > .page-actions");
2260
2760
  main.innerHTML = page.innerHTML;
2761
+ document.dispatchEvent(new Event("docs:page-shown"));
2261
2762
  if (actions) main.prepend(actions);
2262
2763
  document.title = page.dataset.title;
2263
2764
  for (const a of document.querySelectorAll("#nav-groups a")) {
@@ -2286,7 +2787,7 @@ const toHashLinks = (html, route) => html
2286
2787
  * down to figures / terms / schema graph JS). Each doc is held in a
2287
2788
  * <template> and switched via hash routes.
2288
2789
  */
2289
- export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static") => {
2790
+ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static", pluginJs = "", subformatJs = "") => {
2290
2791
  const pages = site.entries.map((e) => ({
2291
2792
  route: docPath(site.entries, e.id).slice(1),
2292
2793
  title: docDisplayName(e.frontmatter, e.id),
@@ -2312,7 +2813,15 @@ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs
2312
2813
  return toHashLinks(page("preview", { ...site, title }, {
2313
2814
  title,
2314
2815
  main: "",
2315
- publish: { graphJs, codeJs, pages: templates, first, network: mode === "network" },
2816
+ publish: {
2817
+ graphJs,
2818
+ codeJs,
2819
+ pages: templates,
2820
+ first,
2821
+ network: mode !== "static",
2822
+ pluginJs: mode === "live" ? pluginJs : undefined,
2823
+ subformatJs,
2824
+ },
2316
2825
  }), first);
2317
2826
  };
2318
2827
  // A doc's main content. A doc with an empty body and children (a chapter-heading-only doc) shows
@@ -2320,7 +2829,7 @@ export const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs
2320
2829
  const entryMain = (site, e) => {
2321
2830
  const html = renderEntryHtml(site, e).html;
2322
2831
  const kids = childrenOf(site.entries, e.id);
2323
- if (e.blocks.length > 0 || kids.length === 0) {
2832
+ if (e.subformat || e.blocks.length > 0 || kids.length === 0) {
2324
2833
  return html;
2325
2834
  }
2326
2835
  const items = kids
@@ -2342,7 +2851,9 @@ export const languageFieldHtml = (defaultLang, language = contentLanguageCode(de
2342
2851
  export const editorBoot = (entry, site) => {
2343
2852
  // Completion candidates are files in the figures/ catalog.
2344
2853
  const figures = [...site.ctx.figures.values()].map((f) => f.file);
2345
- const docs = site.entries.map((e) => ({
2854
+ const docs = site.entries
2855
+ .filter((e) => !e.subformat)
2856
+ .map((e) => ({
2346
2857
  ref: e.sourceFile ?? CONTENT_PREFIX + e.file,
2347
2858
  title: docDisplayName(e.frontmatter, e.id),
2348
2859
  }));
@@ -2381,15 +2892,15 @@ export const editorBoot = (entry, site) => {
2381
2892
  const editorAside = (entry, site) => {
2382
2893
  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>
2383
2894
  <div id="phead">
2384
- <button class="pbtn" type="button" data-theme-picker="editor" aria-label="Editor theme"></button>
2385
- ${fontButton("editor")}
2386
2895
  ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLanguages, site.contentLanguages)}
2387
2896
  <span id="status"></span>
2388
2897
  <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>
2389
2898
  <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>
2390
2899
  <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>
2391
2900
  <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">
2392
- <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>
2901
+ <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>
2902
+ <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>
2903
+ <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>
2393
2904
  <label><input type="checkbox" id="opt-autovalidate"><span data-i18n="Auto validate">Auto validate</span></label>
2394
2905
  <label><input type="checkbox" id="opt-autosave"><span data-i18n="Auto save">Auto save</span></label>
2395
2906
  <label><input type="checkbox" id="opt-corr"><span data-i18n="Source mapping">Source mapping</span></label>
@@ -2414,6 +2925,7 @@ export const pageDataResponse = (site, path) => {
2414
2925
  return { status: 400, body: { error: "route must be /<docId>" } };
2415
2926
  }
2416
2927
  if (path === "/_extensions" ||
2928
+ path === "/_subformats" ||
2417
2929
  path === "/_git" ||
2418
2930
  path === "/_statics" ||
2419
2931
  path.startsWith("/_statics/") ||
@@ -2422,7 +2934,7 @@ export const pageDataResponse = (site, path) => {
2422
2934
  try {
2423
2935
  const resource = resourcesMain(site, path.startsWith("/_statics")
2424
2936
  ? path.slice(1)
2425
- : ["/_git", "/_extensions"].includes(path)
2937
+ : ["/_git", "/_extensions", "/_subformats"].includes(path)
2426
2938
  ? path.slice(1)
2427
2939
  : path.slice("/_files".length).replace(/^\/|\/$/g, ""));
2428
2940
  return resource
@@ -2448,6 +2960,16 @@ export const pageDataResponse = (site, path) => {
2448
2960
  return { status: 404, body: { error: `${path} is not a doc route` } };
2449
2961
  }
2450
2962
  const html = entryMain(site, doc);
2963
+ if (doc.subformat)
2964
+ return {
2965
+ status: 200,
2966
+ body: {
2967
+ resource: true,
2968
+ path,
2969
+ title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site.title),
2970
+ html,
2971
+ },
2972
+ };
2451
2973
  const errors = [...site.errors, ...doc.errors];
2452
2974
  return {
2453
2975
  status: 200,
@@ -2567,7 +3089,7 @@ const handleDraft = async (req, res, save, locale) => {
2567
3089
  }
2568
3090
  }
2569
3091
  }
2570
- const draft = renderDraft(loadSite(locale), target.name, raw, fileDrafts);
3092
+ const draft = renderDraft(save ? loadSite(locale) : site, target.name, raw, fileDrafts);
2571
3093
  sendJson(res, 200, { ...draft, saved: save, conflict: false, raw });
2572
3094
  };
2573
3095
  // Prose lint (/api/lint) = the `lint` of the doc language's adapter (language socket); languages
@@ -2596,7 +3118,9 @@ const handleCreate = async (req, res) => {
2596
3118
  const name = typeof body?.name === "string" ? body.name.trim() : "";
2597
3119
  const title = typeof body?.title === "string" ? body.title.trim() : "";
2598
3120
  const parent = typeof body?.parent === "string" && body.parent !== "" ? body.parent : undefined;
2599
- const result = ops.addFile(name, title, parent);
3121
+ const result = typeof body?.subformat === "string"
3122
+ ? ops.addSubformat(body.subformat, title, parent)
3123
+ : ops.addFile(name, title, parent);
2600
3124
  sendOp(res, isOpError(result) ? result : { ...result, path: docPath(loadSite().entries, result.id) });
2601
3125
  };
2602
3126
  // Add a figure (sidebar file picker / drag-and-drop). Returns the written file name
@@ -2614,27 +3138,35 @@ const handleFigure = async (req, res) => {
2614
3138
  // writes icons/<id>.svg. Response icon = the new data URI (null if removed).
2615
3139
  const handleIcon = async (req, res) => {
2616
3140
  const body = await readJson(req);
2617
- const target = resolveContentFile(body?.file);
2618
- if (!target || !existsSync(target.abs)) {
2619
- sendJson(res, 404, { error: "target doc not found" });
2620
- return;
2621
- }
2622
3141
  const manifest = readManifest(root);
2623
3142
  if (manifest.errors.length) {
2624
3143
  sendJson(res, 409, { error: manifest.errors.join("\n") });
2625
3144
  return;
2626
3145
  }
2627
- const previous = docIconFile(target.id, manifest.files);
2628
- const file = manifest.files?.defaultLayout !== false &&
2629
- !Object.hasOwn(manifest.files?.icons ?? {}, target.id) &&
3146
+ const requestedId = typeof body?.file === "string" ? docIdOfFile(body.file) : undefined;
3147
+ const page = flattenTree(manifest.tree).find((node) => node.id === requestedId && node.subformat);
3148
+ const target = page ? undefined : resolveContentFile(body?.file);
3149
+ const id = page?.id ?? (target && existsSync(target.abs) ? target.id : undefined);
3150
+ if (!id) {
3151
+ sendJson(res, 404, { error: "target doc not found" });
3152
+ return;
3153
+ }
3154
+ const previous = docIconFile(id, manifest.files);
3155
+ const file = manifest.format !== "nested" &&
3156
+ manifest.files?.defaultLayout !== false &&
3157
+ !Object.hasOwn(manifest.files?.icons ?? {}, id) &&
2630
3158
  !existsSync(textfilePath(root, previous))
2631
- ? defaultFilePath(`${target.id}-icon.svg`)
3159
+ ? defaultFilePath(`${id}-icon.svg`)
2632
3160
  : previous;
2633
3161
  const path = textfilePath(root, file);
2634
3162
  if (body?.data == null) {
2635
3163
  if (existsSync(path)) {
2636
3164
  unlinkSync(path);
2637
3165
  }
3166
+ if (manifest.files?.icons && Object.hasOwn(manifest.files.icons, id)) {
3167
+ delete manifest.files.icons[id];
3168
+ writeManifest(root, manifest.tree, manifest);
3169
+ }
2638
3170
  sendJson(res, 200, { ok: true, icon: null });
2639
3171
  return;
2640
3172
  }
@@ -2654,7 +3186,7 @@ const handleIcon = async (req, res) => {
2654
3186
  if (file !== previous) {
2655
3187
  manifest.files ??= parseFileLayout({});
2656
3188
  manifest.files.icons ??= {};
2657
- manifest.files.icons[target.id] = file;
3189
+ manifest.files.icons[id] = file;
2658
3190
  writeManifest(root, manifest.tree, manifest);
2659
3191
  }
2660
3192
  sendJson(res, 200, { ok: true, icon: svgDataUri(svg) });
@@ -2739,9 +3271,11 @@ const PREBUILT = {
2739
3271
  "viewer/edit-client.ts": "edit.global.js",
2740
3272
  "viewer/ui-client.ts": "ui.global.js",
2741
3273
  "viewer/code-highlight.ts": "code.global.js",
3274
+ "viewer/published-plugins.ts": "plugins.global.js",
3275
+ "viewer/published-subformats.ts": "subformats.global.js",
2742
3276
  };
2743
- /** Client bundle (src/<entry> as an IIFE). Sourcemap for the server, minified for publish. */
2744
- export const bundleClient = async (entry, publish = false) => {
3277
+ /** Minified client bundle shared by local viewing and published HTML. */
3278
+ export const bundleClient = async (entry) => {
2745
3279
  const prebuilt = PREBUILT[entry];
2746
3280
  if (usePrebuiltAssets && prebuilt) {
2747
3281
  return readViewerAsset(prebuilt).toString("utf8");
@@ -2753,7 +3287,7 @@ export const bundleClient = async (entry, publish = false) => {
2753
3287
  format: "iife",
2754
3288
  target: "es2022",
2755
3289
  write: false,
2756
- ...(publish ? { minify: true } : { sourcemap: "inline" }),
3290
+ minify: true,
2757
3291
  });
2758
3292
  return out.outputFiles?.[0]?.text ?? "";
2759
3293
  };
@@ -2961,11 +3495,13 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
2961
3495
  const input = await readJson(req, Math.ceil((MAX_FILE_UPLOAD_BYTES * 4) / 3) + 16_384);
2962
3496
  if (!input)
2963
3497
  throw new Error("Invalid file request");
2964
- const result = input.action === "read"
2965
- ? filesSnapshot(root)
2966
- : input.action === "upload"
2967
- ? uploadFile(root, input)
2968
- : updateFiles(root, input);
3498
+ const result = input.action === "complete"
3499
+ ? completeFilePaths(root, input.prefix)
3500
+ : input.action === "read"
3501
+ ? filesSnapshot(root)
3502
+ : input.action === "upload"
3503
+ ? uploadFile(root, input)
3504
+ : updateFiles(root, input);
2969
3505
  sendJson(res, 200, result);
2970
3506
  }
2971
3507
  catch (error) {
@@ -2975,6 +3511,17 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
2975
3511
  }
2976
3512
  return;
2977
3513
  }
3514
+ if (path === "/api/subformat") {
3515
+ if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3516
+ sendJson(res, 403, {
3517
+ error: "Record changes require a same-origin local editor request",
3518
+ });
3519
+ return;
3520
+ }
3521
+ const result = subformatResponse(root, await readJson(req));
3522
+ sendJson(res, result.status, result.body);
3523
+ return;
3524
+ }
2978
3525
  if (path === "/api/code-file") {
2979
3526
  if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
2980
3527
  sendJson(res, 403, {
@@ -3023,7 +3570,9 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3023
3570
  const grammar = siteLanguages.codeGrammars?.find((entry) => entry.name === extension || entry.aliases?.includes(extension));
3024
3571
  const language = existsSync(join(root, ".dooc/editor-tools", `${extension}.json`))
3025
3572
  ? extension
3026
- : (grammar?.name ?? extension);
3573
+ : (readManifest(root).subformats?.find((config) => config.ext === extension)?.format ??
3574
+ grammar?.name ??
3575
+ extension);
3027
3576
  const result = await validateTextfileCode(root, language, input.content);
3028
3577
  for (const message of textfilePreviewErrors(loadSite(locale), input.file, result.content))
3029
3578
  result.findings.push({
@@ -3121,18 +3670,41 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3121
3670
  await handleCreate(req, res);
3122
3671
  return;
3123
3672
  }
3673
+ if (path === "/api/subformat-page") {
3674
+ if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3675
+ sendJson(res, 403, {
3676
+ error: "Page changes require a same-origin local editor request",
3677
+ });
3678
+ return;
3679
+ }
3680
+ const body = await readJson(req);
3681
+ const id = typeof body?.id === "string" ? body.id : "";
3682
+ if (!loadSite().entries.some((entry) => entry.id === id && entry.subformat)) {
3683
+ sendJson(res, 404, { error: "Subformat page not found" });
3684
+ return;
3685
+ }
3686
+ sendOp(res, body?.action === "delete"
3687
+ ? ops.remove(id)
3688
+ : body?.action === "rename" && typeof body.title === "string"
3689
+ ? ops.renameSubformat(id, body.title)
3690
+ : { status: 400, error: "Unknown page action" });
3691
+ return;
3692
+ }
3124
3693
  if (path === "/api/icon") {
3125
3694
  await handleIcon(req, res);
3126
3695
  return;
3127
3696
  }
3128
- if (path === "/api/site-icon") {
3697
+ if (path === "/api/site-icon" || path === "/api/site-title") {
3129
3698
  if (!isLocalToolRequest(req.headers.host ?? "", req.headers.origin, req.headers["content-type"])) {
3130
3699
  sendJson(res, 403, {
3131
- error: "Site icons require a same-origin local editor request",
3700
+ error: "Site settings require a same-origin local editor request",
3132
3701
  });
3133
3702
  return;
3134
3703
  }
3135
- const result = siteIconResponse(root, await readJson(req));
3704
+ const input = await readJson(req);
3705
+ const result = path === "/api/site-title"
3706
+ ? siteTitleResponse(root, input)
3707
+ : siteIconResponse(root, input);
3136
3708
  sendJson(res, result.status, result.body);
3137
3709
  return;
3138
3710
  }
@@ -3155,7 +3727,9 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3155
3727
  }
3156
3728
  const site = loadSite(locale);
3157
3729
  if (req.method === "GET" && path === "/api/search") {
3158
- sendJson(res, 200, searchIndex(site));
3730
+ sendJson(res, 200, searchIndex(site, mode === "edit"
3731
+ ? (site.filePaths ?? filesSnapshot(root).files.map((file) => file.path))
3732
+ : []));
3159
3733
  return;
3160
3734
  }
3161
3735
  // edit-mode-only APIs (used by edit-client.ts). handle() strips the query from path, so
@@ -3212,6 +3786,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3212
3786
  }
3213
3787
  if ((mode === "edit" &&
3214
3788
  (path === "/_extensions" ||
3789
+ path === "/_subformats" ||
3215
3790
  path === "/_git" ||
3216
3791
  path === "/_statics" ||
3217
3792
  path.startsWith("/_statics/") ||
@@ -3220,7 +3795,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3220
3795
  path === "/_files/terms") {
3221
3796
  const rest = path.startsWith("/_statics")
3222
3797
  ? path.slice(1)
3223
- : ["/_git", "/_extensions"].includes(path)
3798
+ : ["/_git", "/_extensions", "/_subformats"].includes(path)
3224
3799
  ? path.slice(1)
3225
3800
  : requestUrl.pathname.slice("/_files".length).replace(/^\/|\/$/g, "");
3226
3801
  const page = resourcesMain(site, rest);
@@ -3229,7 +3804,8 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3229
3804
  return;
3230
3805
  }
3231
3806
  const editor = mode === "edit"
3232
- ? (site.entries.find((entry) => entry.id === requestUrl.searchParams.get("editor")) ?? site.entries[0])
3807
+ ? (site.entries.find((entry) => !entry.subformat &&
3808
+ entry.id === requestUrl.searchParams.get("editor")) ?? site.entries.find((entry) => !entry.subformat))
3233
3809
  : undefined;
3234
3810
  if (editor) {
3235
3811
  const { aside, boot } = editorAside(editor, site);
@@ -3254,7 +3830,7 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3254
3830
  sendPage(res, mode, site, { ...page, currentRes: rest });
3255
3831
  return;
3256
3832
  }
3257
- const id = resolveDocPath(site.entries, path);
3833
+ const id = resolveDocPath(site.entries, requestUrl.pathname);
3258
3834
  const doc = site.entries.find((e) => e.id === id);
3259
3835
  if (!doc) {
3260
3836
  notFound(res, path);
@@ -3265,9 +3841,28 @@ export const startServer = async (mode, port = 5179, pluginModule, startup) => {
3265
3841
  main: entryMain(site, doc),
3266
3842
  currentId: doc.id,
3267
3843
  };
3268
- if (mode === "edit") {
3844
+ if (mode === "edit" && !doc.subformat) {
3269
3845
  Object.assign(opts, editorAside(doc, site));
3270
3846
  }
3847
+ if (mode === "edit" && doc.subformat) {
3848
+ const editor = site.entries.find((entry) => !entry.subformat);
3849
+ if (editor) {
3850
+ const { aside, boot } = editorAside(editor, site);
3851
+ Object.assign(opts, {
3852
+ aside,
3853
+ main: entryMain(site, editor),
3854
+ currentRes: path,
3855
+ boot: {
3856
+ ...boot,
3857
+ resource: {
3858
+ path,
3859
+ title: pageTitle(mode, opts.title, site.title),
3860
+ html: entryMain(site, doc),
3861
+ },
3862
+ },
3863
+ });
3864
+ }
3865
+ }
3271
3866
  sendPage(res, mode, site, opts);
3272
3867
  };
3273
3868
  const server = createServer((req, res) => {