@dooc-dev/dooc 0.0.22 → 0.0.23
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.
- package/dist/client.global.js +1 -1
- package/dist/edit.global.js +269 -263
- package/dist/engine/compiler/check.js +17 -0
- package/dist/engine/compiler/export.js +18 -1
- package/dist/engine/compiler/files.js +13 -2
- package/dist/engine/compiler/manifest.js +4 -0
- package/dist/engine/compiler/skills.d.ts +10 -0
- package/dist/engine/compiler/skills.js +95 -0
- package/dist/engine/core/content-metadata.d.ts +7 -1
- package/dist/engine/core/content-metadata.js +52 -18
- package/dist/engine/core/files.d.ts +1 -0
- package/dist/engine/core/files.js +3 -0
- package/dist/frontend/document-application.d.ts +11 -2
- package/dist/frontend/document-application.js +356 -130
- package/dist/frontend/language-picker.js +1 -0
- package/dist/frontend/locales/eng.json +17 -1
- package/dist/frontend/locales/jpn.json +17 -1
- package/dist/frontend/locales/zho.json +17 -1
- package/dist/frontend/mcp-operations.js +57 -1
- package/dist/frontend/nav-focus.d.ts +1 -1
- package/dist/frontend/nav-focus.js +25 -2
- package/dist/frontend/nav-update.js +12 -0
- package/dist/frontend/page-jump.d.ts +3 -0
- package/dist/frontend/page-jump.js +130 -0
- package/dist/frontend/resource-download.d.ts +1 -1
- package/dist/frontend/resource-download.js +118 -28
- package/dist/frontend/resource-library.js +16 -7
- package/dist/frontend/search.js +18 -5
- package/dist/frontend/theme-picker.js +11 -0
- package/dist/manifest.global.js +349 -0
- package/dist/mcp-relay.mjs +71 -1
- package/dist/plugins.global.js +4 -4
- package/dist/server/assets.d.ts +1 -0
- package/dist/server/assets.js +4 -1
- package/dist/server/build-media.d.ts +6 -0
- package/dist/server/build-media.js +136 -0
- package/dist/server/build-output.d.ts +2 -1
- package/dist/server/build-output.js +32 -2
- package/dist/server/build-split.d.ts +15 -0
- package/dist/server/build-split.js +160 -0
- package/dist/server/build.d.ts +6 -1
- package/dist/server/build.js +37 -10
- package/dist/server/cli.js +20 -2
- package/dist/server/mcp.js +14 -1
- package/dist/server/serve.d.ts +21 -2
- package/dist/server/serve.js +26 -20
- package/dist/server/static-client.js +2 -1
- package/dist/server/workspace-server.d.ts +1 -1
- package/dist/server/workspace-server.js +24 -4
- package/dist/subformats.global.js +38 -38
- package/dist/ui.global.js +68 -68
- package/dist/workspace/client.d.ts +1 -1
- package/dist/workspace/client.js +22 -3
- package/dist/workspace/mcp-tools.js +32 -0
- package/dist/workspace/mcp.js +50 -1
- package/dist/workspace/protocol.d.ts +3 -0
- package/dist/workspace/server.d.ts +1 -1
- package/dist/workspace/server.js +14 -3
- package/dist/workspace/site-icon.js +17 -12
- package/dist/workspace/textfile.js +16 -4
- package/dist/workspace-mcp-worker.global.js +234 -119
- package/dist/workspace-reader-mcp-worker.global.js +234 -119
- package/dist/workspace-reader-worker.global.js +234 -119
- package/dist/workspace-worker.global.js +234 -119
- package/package.json +2 -2
|
@@ -4,14 +4,14 @@ import { figureName } from "../engine/compiler/figures.js";
|
|
|
4
4
|
import { filesSnapshot, updateFiles } from "../engine/compiler/files.js";
|
|
5
5
|
import { loadProjectFonts } from "../engine/compiler/fonts.js";
|
|
6
6
|
import { createHash, dirname, existsSync, join, mkdirSync, readFileSync, statSync, unlinkSync, writeFileSync, } from "../engine/compiler/host.js";
|
|
7
|
-
import { ICONS_DIR, ownsDocIcon, squareSvg } from "../engine/compiler/icons.js";
|
|
7
|
+
import { ICONS_DIR, loadIcons, ownsDocIcon, squareSvg } from "../engine/compiler/icons.js";
|
|
8
8
|
import { ignoredFiles, withIgnoredFilesCache } from "../engine/compiler/ignored-files.js";
|
|
9
9
|
import { contentLanguageCode, contentLanguages, isContentLanguage, webLanguage, } from "../engine/compiler/language-codes.js";
|
|
10
10
|
import { setDocTranslation, siteContentLanguages, translationFile, translationFiles, } from "../engine/compiler/locales.js";
|
|
11
|
-
import { readManifest, writeManifest } from "../engine/compiler/manifest.js";
|
|
11
|
+
import { manifestFile, readManifest, writeManifest } from "../engine/compiler/manifest.js";
|
|
12
12
|
import { assembleDoc, createDocOps, isOpError, } from "../engine/compiler/ops.js";
|
|
13
13
|
import { isRemoteSourceFile } from "../engine/compiler/remote-manifests.js";
|
|
14
|
-
import { compileSubformatSchema, subformatResponse, validateSubformatFile, } from "../engine/compiler/subformats.js";
|
|
14
|
+
import { compileSubformatSchema, subformatIconSvg, subformatResponse, validateSubformatFile, } from "../engine/compiler/subformats.js";
|
|
15
15
|
import { readTextfile, textfilePath, writeTextfile } from "../engine/compiler/textfile.js";
|
|
16
16
|
import { walkBlocks } from "../engine/core/blocks.js";
|
|
17
17
|
import { selectCodeGrammars, subformatCodeGrammars } from "../engine/core/code-grammars.js";
|
|
@@ -48,6 +48,7 @@ import { jsonSchemaHtml } from "./json-schema.js";
|
|
|
48
48
|
import { loadPreviewScript } from "./lazy-preview.js";
|
|
49
49
|
import { focusNavTree } from "./nav-focus.js";
|
|
50
50
|
import { updateNav } from "./nav-update.js";
|
|
51
|
+
import { mountPageJump } from "./page-jump.js";
|
|
51
52
|
import { PLUGIN_BLOCK_CSS } from "./plugin-style.js";
|
|
52
53
|
import { mountPanelResize } from "./resize.js";
|
|
53
54
|
import { mountDownloadBlock, mountResourceDownloads, mountResourceExpand, } from "./resource-download.js";
|
|
@@ -237,6 +238,81 @@ export const createDocumentApplication = (root, host) => {
|
|
|
237
238
|
contentLanguage: locale,
|
|
238
239
|
};
|
|
239
240
|
});
|
|
241
|
+
const loadNavigation = (locale, currentId) => withIgnoredFilesCache(() => {
|
|
242
|
+
const manifest = readManifest(root);
|
|
243
|
+
const title = manifest.titles?.[locale] ?? manifest.title;
|
|
244
|
+
const nodes = flattenTree(manifest.tree);
|
|
245
|
+
const { icons } = loadIcons(root, new Set(nodes.map(({ id }) => id)), manifest.icon, manifest.files);
|
|
246
|
+
const entries = nodes.map((node) => {
|
|
247
|
+
const format = manifest.subformats?.find(({ ext }) => ext === node.subformat);
|
|
248
|
+
let iconSvg;
|
|
249
|
+
if (format) {
|
|
250
|
+
try {
|
|
251
|
+
iconSvg = subformatIconSvg(root, format);
|
|
252
|
+
}
|
|
253
|
+
catch { }
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
...node,
|
|
257
|
+
included: !!node.resolved,
|
|
258
|
+
file: `${node.id}.md`,
|
|
259
|
+
sourceFile: isContentPage(node)
|
|
260
|
+
? sourceDocFile(node.id, manifest.files)
|
|
261
|
+
: undefined,
|
|
262
|
+
frontmatter: {
|
|
263
|
+
title: node.title ??
|
|
264
|
+
node.library ??
|
|
265
|
+
node.subformat ??
|
|
266
|
+
(isContentPage(node)
|
|
267
|
+
? (sourceDocFile(node.id, manifest.files).split("/").pop() ??
|
|
268
|
+
node.id).replace(/\.md$/i, "")
|
|
269
|
+
: ((node.root ? title : node.name) ?? "Contents")),
|
|
270
|
+
},
|
|
271
|
+
icon: icons.get(node.id),
|
|
272
|
+
subformat: format ? { ...format, fields: [], records: [], iconSvg } : undefined,
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
if (!entries.some((entry) => entry.root)) {
|
|
276
|
+
let id = "document-root";
|
|
277
|
+
while (entries.some((entry) => entry.id === id))
|
|
278
|
+
id += "-root";
|
|
279
|
+
for (const entry of entries)
|
|
280
|
+
entry.parent ??= id;
|
|
281
|
+
entries.unshift({
|
|
282
|
+
id,
|
|
283
|
+
root: true,
|
|
284
|
+
url: "",
|
|
285
|
+
file: "",
|
|
286
|
+
frontmatter: { title: title ?? "Contents" },
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
const current = entries.find(({ id }) => id === currentId);
|
|
290
|
+
if (current) {
|
|
291
|
+
const source = contentLanguageCode(manifest.defaultLang ?? DEFAULT_LANG);
|
|
292
|
+
const translated = new Set(translationFiles(root));
|
|
293
|
+
current.translatedLanguages = [
|
|
294
|
+
source,
|
|
295
|
+
...siteContentLanguages(root, manifest).filter((language) => language !== source &&
|
|
296
|
+
isContentPage(current) &&
|
|
297
|
+
translated.has(translationFile(sourceDocFile(current.id, manifest.files), language, current.origin))),
|
|
298
|
+
];
|
|
299
|
+
}
|
|
300
|
+
let icon;
|
|
301
|
+
if (manifest.icon) {
|
|
302
|
+
try {
|
|
303
|
+
icon = squareSvg(readTextfile(root, manifest.icon));
|
|
304
|
+
}
|
|
305
|
+
catch { }
|
|
306
|
+
}
|
|
307
|
+
return {
|
|
308
|
+
entries,
|
|
309
|
+
title,
|
|
310
|
+
icon,
|
|
311
|
+
subformats: manifest.subformats,
|
|
312
|
+
contentLanguage: locale,
|
|
313
|
+
workspace: workspaceSource ?? readWorkspaceSource(root),
|
|
314
|
+
};
|
|
315
|
+
});
|
|
240
316
|
const draftContext = (site) => ({
|
|
241
317
|
previews: site.previews,
|
|
242
318
|
root,
|
|
@@ -645,8 +721,11 @@ body:has(#doc-search.search-docked[open]) #panel { flex-shrink: 100; min-width:
|
|
|
645
721
|
/* ── sidebar ── */
|
|
646
722
|
#sidebar { width: var(--sidebar-width, 260px); height: 100vh; position: sticky; top: 0; flex: none;
|
|
647
723
|
display: flex; flex-direction: column; background: var(--c-bg1);
|
|
648
|
-
border-right: 1px solid var(--c-line); overflow: hidden; }
|
|
724
|
+
border-right: 1px solid var(--c-line); overflow: hidden; transition: width 220ms cubic-bezier(.2, .8, .2, 1); }
|
|
725
|
+
body.resizing #sidebar, #sidebar:has(> #sidebar-resize:focus) { transition: none; }
|
|
649
726
|
body.sidebar-closed #sidebar { width: 52px; }
|
|
727
|
+
#sidebar-head, #sidebar-content { width: calc(var(--sidebar-width, 260px) - 1px); }
|
|
728
|
+
body.sidebar-closed :is(#sidebar-head, #sidebar-content) { width: 51px; }
|
|
650
729
|
body.sidebar-closed #sidebar-resize { display: none; }
|
|
651
730
|
.panel-resize { position: absolute; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 6;
|
|
652
731
|
touch-action: none; }
|
|
@@ -746,16 +825,18 @@ body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site
|
|
|
746
825
|
.nav-row { position: relative; display: flex; align-items: center; min-width: 0; }
|
|
747
826
|
.nav-row > .nav-link { flex: 1; min-width: 0; padding: 9px 16px; }
|
|
748
827
|
.nav-row > .nav-link.cur { background: var(--c-raised); }
|
|
749
|
-
.nav-
|
|
828
|
+
.nav-list > .nav-item { display: grid; grid-template-rows: auto 0fr; transition: grid-template-rows var(--nav-motion); }
|
|
829
|
+
.nav-list > .nav-item.open { grid-template-rows: auto 1fr; }
|
|
830
|
+
.nav-item > .nav-list { min-height: 0; overflow: hidden; visibility: hidden; transition: visibility 0s 260ms; }
|
|
831
|
+
.nav-item.open > .nav-list { visibility: visible; transition-delay: 0s; }
|
|
750
832
|
.nav-tree-toggle { flex: none; display: flex; align-items: center; justify-content: center;
|
|
751
833
|
width: 28px; height: 28px; margin-right: 6px; padding: 0; background: transparent; border: none;
|
|
752
834
|
border-radius: 4px; color: var(--c-fg-faint); cursor: pointer; }
|
|
753
835
|
.nav-tree-toggle:hover { color: var(--c-fg); background: var(--c-raised); }
|
|
754
|
-
.nav-tree-toggle svg { transition: transform
|
|
836
|
+
.nav-tree-toggle svg { transition: transform var(--nav-motion); }
|
|
755
837
|
.nav-item.open > .nav-row > .nav-tree-toggle svg { transform: rotate(90deg); }
|
|
756
838
|
.nav-tree { --nav-pad: calc(48px + (var(--nav-depth, 2) - 2) * 29px);
|
|
757
|
-
--nav-line: calc(var(--nav-pad) - 23px); margin: 0;
|
|
758
|
-
.nav-tree:empty { padding-bottom: 0; }
|
|
839
|
+
--nav-line: calc(var(--nav-pad) - 23px); margin: 0; }
|
|
759
840
|
.nav-tree > .nav-item { position: relative; }
|
|
760
841
|
.nav-tree > .nav-item:not(:last-child)::before, .nav-tree > .nav-item > .nav-row::before,
|
|
761
842
|
.nav-tree > .nav-item:last-child > .nav-row::after, .nav-tree > .nav-item:has(.cur) > .nav-row::after {
|
|
@@ -772,13 +853,17 @@ body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site
|
|
|
772
853
|
.nav-ancestor { --nav-pad: 12px; --nav-line: var(--nav-rail, 21px); }
|
|
773
854
|
.nav-list:has(> .nav-ancestor) > .nav-item:not(.nav-ancestor) { height: 0; opacity: 0; overflow: hidden; visibility: hidden; }
|
|
774
855
|
#nav-groups { --nav-motion: 260ms cubic-bezier(.2, .8, .2, 1); }
|
|
856
|
+
body.sidebar-toggling #nav-groups { --nav-motion: 0s; }
|
|
775
857
|
#nav-groups :is(.nav-tree-link, .nav-doc-row) { transition: padding-left var(--nav-motion); }
|
|
776
858
|
#nav-groups :is(.nav-create, .nav-new) { transition: margin-left var(--nav-motion); }
|
|
777
859
|
#nav-groups .nav-item::before, #nav-groups .nav-row::before, #nav-groups .nav-row::after {
|
|
778
860
|
transition: left var(--nav-motion), width var(--nav-motion), height var(--nav-motion), top var(--nav-motion); }
|
|
779
861
|
/* A connector changing orientation must stay 1px thick instead of morphing into a rectangle. */
|
|
780
862
|
#nav-groups .nav-row::before { transition-property: left, top; }
|
|
781
|
-
@media (prefers-reduced-motion: reduce) {
|
|
863
|
+
@media (prefers-reduced-motion: reduce) {
|
|
864
|
+
#nav-groups { --nav-motion: 0s; }
|
|
865
|
+
#sidebar, .nav-item > .nav-list { transition: none; }
|
|
866
|
+
}
|
|
782
867
|
.nav-ancestor > .nav-tree > .nav-item::before,
|
|
783
868
|
.nav-ancestor > .nav-tree > .nav-item > .nav-row::before,
|
|
784
869
|
.nav-ancestor > .nav-tree > .nav-item > .nav-row::after { display: none; }
|
|
@@ -882,6 +967,8 @@ body[data-download="normal"] a[download], body[data-download="block"] a[download
|
|
|
882
967
|
.resource-stage > * { margin: 0; }
|
|
883
968
|
.resource-surface { position: absolute; inset: 0; touch-action: none; }
|
|
884
969
|
.resource-modal-bar { position: absolute; top: 8px; right: 8px; display: flex; align-items: center; gap: 8px; padding-left: 8px; border-radius: 4px; background: var(--doc-panel); font: 12px/1.5 var(--font-sans); color: var(--doc-fg-2); }
|
|
970
|
+
.resource-modal-bar button { min-width: 32px; min-height: 32px; padding: 4px; border: 0; border-radius: 4px; background: none; color: inherit; cursor: pointer; font: inherit; }
|
|
971
|
+
.resource-modal-bar button:hover { background: var(--doc-bg-2); }
|
|
885
972
|
.res-file-page h1 > .resource-download { margin-left: 8px; vertical-align: middle; }
|
|
886
973
|
.resource-download-tools [role="status"] { font: 12px/1.5 var(--font-sans); color: var(--doc-fg-2); }
|
|
887
974
|
.plugin { position: relative; min-width: 0; border: 2px solid var(--doc-border); border-top: 0; }
|
|
@@ -1141,7 +1228,7 @@ main:has(> article > .document-web) > .page-actions { display: none; }
|
|
|
1141
1228
|
.document-web { position: absolute; inset: 0; }
|
|
1142
1229
|
.document-web-notice { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: var(--doc-bg); text-align: center; }
|
|
1143
1230
|
.document-web-notice[hidden] { display: none; }
|
|
1144
|
-
.document-web-frame { display: block; width: 100%; height: 100%; border: 0; background:
|
|
1231
|
+
.document-web-frame { display: block; width: 100%; height: 100%; border: 0; background: Canvas; }
|
|
1145
1232
|
details summary { cursor: pointer; opacity: .8; }
|
|
1146
1233
|
/* Figure and term file links show previews on hover. */
|
|
1147
1234
|
.figref, .dictref { color: var(--doc-accent-2); text-decoration: none;
|
|
@@ -1218,6 +1305,54 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1218
1305
|
|
|
1219
1306
|
|
|
1220
1307
|
.resource-library { width: 100%; max-width: none; }
|
|
1308
|
+
.manifest-page { container-type: inline-size; font: 12px/1.55 var(--font-sans); color: var(--c-fg); }
|
|
1309
|
+
#manifest-manager { max-width: 760px; margin-inline: auto; }
|
|
1310
|
+
.manifest-toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-block: 8px; background: var(--c-bg1); }
|
|
1311
|
+
.manifest-toolbar h1 { flex: 1; min-width: 0; margin: 0; padding: 0; border: 0; font: 500 14px/1.5 var(--font-sans); overflow-wrap: anywhere; }
|
|
1312
|
+
.manifest-toolbar [role="status"] { color: var(--c-fg-muted); font-size: 11px; }
|
|
1313
|
+
.manifest-page :is(input, select, button) { box-sizing: border-box; min-width: 0; max-width: 100%; min-height: 30px; border: 1px solid var(--c-line); border-radius: 4px; padding: 4px 8px; background: var(--c-bg1); color: var(--c-fg); font: inherit; }
|
|
1314
|
+
.manifest-page button { cursor: pointer; }
|
|
1315
|
+
.manifest-page button:hover { background: var(--c-raised); }
|
|
1316
|
+
.manifest-page button:disabled { opacity: .5; cursor: default; }
|
|
1317
|
+
.manifest-page [data-save]:not(:disabled) { color: var(--c-accent); border-color: currentColor; }
|
|
1318
|
+
.manifest-page :is(input, select, button, summary, a):focus-visible { outline: 2px solid var(--c-accent); outline-offset: 2px; }
|
|
1319
|
+
.manifest-page .manifest-path-input { font-family: var(--doc-mono); }
|
|
1320
|
+
.manifest-completions { inset: auto; box-sizing: border-box; font: 12px/1.6 var(--doc-mono); }
|
|
1321
|
+
.manifest-completions .language-options { overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
|
|
1322
|
+
.manifest-completions button { border: 0; border-radius: 0; background: transparent; }
|
|
1323
|
+
.resources-pane .manifest-tabs { margin: 0 0 4px; padding: 0; }
|
|
1324
|
+
.manifest-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 14px; background: transparent; color: var(--c-fg-muted); }
|
|
1325
|
+
.manifest-tabs button[aria-selected="true"] { color: var(--c-accent); border-bottom-color: currentColor; }
|
|
1326
|
+
.manifest-fields { min-width: 0; margin: 0; padding: 12px 0; border: 0; }
|
|
1327
|
+
.manifest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; min-width: 0; }
|
|
1328
|
+
.manifest-group { grid-column: 1 / -1; min-width: 0; }
|
|
1329
|
+
.manifest-group > summary { display: flex; align-items: center; gap: 8px; min-height: 30px; padding-inline: 4px; list-style: none; opacity: 1; font-weight: 500; }
|
|
1330
|
+
.manifest-group > summary::-webkit-details-marker { display: none; }
|
|
1331
|
+
.manifest-group > summary::before { content: ""; flex: none; width: 5px; height: 5px; margin-inline: 2px 4px; border-right: 1px solid var(--c-fg-muted); border-bottom: 1px solid var(--c-fg-muted); transform: rotate(-45deg); }
|
|
1332
|
+
.manifest-group[open] > summary::before { transform: rotate(45deg); }
|
|
1333
|
+
.manifest-group > summary:hover { background: var(--c-raised); }
|
|
1334
|
+
.manifest-group > .manifest-grid { margin-left: 8px; padding: 12px 0 2px 16px; border-left: 1px solid var(--c-line); }
|
|
1335
|
+
.manifest-field { position: relative; display: block; min-width: 0; align-self: start; }
|
|
1336
|
+
.manifest-field :is(input, select) { min-height: 34px; padding-top: 6px; }
|
|
1337
|
+
.manifest-grid :is(input, select) { width: 100%; }
|
|
1338
|
+
.manifest-paths { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 8px; border: 1px solid var(--c-line); border-radius: 4px; }
|
|
1339
|
+
.manifest-paths > legend { padding-inline: 4px; color: var(--c-fg-muted); font: 11px/14px var(--font-sans); }
|
|
1340
|
+
.manifest-paths button { display: inline-grid; place-items: center; width: 30px; padding: 0; }
|
|
1341
|
+
.manifest-path-row { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
|
|
1342
|
+
.manifest-path-row input { flex: 1; }
|
|
1343
|
+
.manifest-path-row button { flex: none; border-color: transparent; background: transparent; color: var(--c-fg-muted); }
|
|
1344
|
+
.manifest-schema-link { align-self: center; justify-self: start; color: var(--c-fg-muted); text-underline-offset: 3px; }
|
|
1345
|
+
.manifest-error { white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1346
|
+
.manifest-source { margin-top: 14px; border: 1px solid var(--c-line); border-radius: 4px; overflow: hidden; }
|
|
1347
|
+
.manifest-source .cm-editor { height: 65dvh; background: var(--c-bg1); color: var(--c-fg); }
|
|
1348
|
+
.manifest-source .cm-scroller { overflow: auto; font: 12px/1.65 var(--doc-mono); scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
|
|
1349
|
+
.manifest-source .cm-gutters { background: transparent; color: var(--c-fg-muted); border: 0; }
|
|
1350
|
+
@container (max-width: 540px) { .manifest-grid { grid-template-columns: minmax(0, 1fr); } }
|
|
1351
|
+
@media (max-width: 600px) {
|
|
1352
|
+
.manifest-page :is(input, select, button, summary, .manifest-schema-link) { min-height: 44px; }
|
|
1353
|
+
.manifest-paths button { width: 44px; }
|
|
1354
|
+
.manifest-schema-link { display: inline-flex; align-items: center; }
|
|
1355
|
+
}
|
|
1221
1356
|
.git-page { padding-top: 8px; font: 12px/1.55 var(--font-sans); }
|
|
1222
1357
|
.git-page > #git-manager { max-width: 880px; margin-inline: auto; }
|
|
1223
1358
|
.git-toolbar { gap: 8px; padding-block: 6px; }
|
|
@@ -1440,24 +1575,26 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1440
1575
|
[data-subformat-view="list"] .subformat-columns { flex-direction: column; gap: 20px; overflow-x: visible; }
|
|
1441
1576
|
[data-subformat-view="list"] .subformat-column { flex: none; }
|
|
1442
1577
|
[data-subformat-view="list"] .subformat-cards { min-height: 40px; }
|
|
1443
|
-
.subformat-list-record { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr) auto; align-items:
|
|
1578
|
+
.subformat-list-record { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(180px, 2fr) auto; align-items: center; gap: 4px 12px; margin: 0; padding: 6px 2px; border: 0; border-bottom: 1px solid var(--c-line); border-radius: 0; }
|
|
1444
1579
|
.subformat-list-record > h3 { grid-column: 1; grid-row: 1; }
|
|
1445
1580
|
.subformat-list-record .subformat-card-open { display: block; max-width: 100%; white-space: nowrap; text-overflow: ellipsis; }
|
|
1446
|
-
.subformat-list-record > .subformat-card-tools { grid-column: 3; grid-row: 1; margin: 0; padding: 0; background: transparent; }
|
|
1447
|
-
.subformat-list-record
|
|
1448
|
-
.subformat-list-record
|
|
1581
|
+
.subformat-list-record > .subformat-card-tools { grid-column: 3; grid-row: 1; gap: 0; height: 24px; margin: 0; padding: 0; background: transparent; }
|
|
1582
|
+
.subformat-list-record .subformat-card-file { margin-top: 8px; font-family: var(--font-sans); white-space: normal; }
|
|
1583
|
+
.subformat-list-record :is(.subformat-card-toggle, .subformat-card-copy, .resource-download) { width: 24px; height: 24px; }
|
|
1584
|
+
.subformat-list-record :is(.subformat-card-toggle, .subformat-card-copy, .resource-download) svg { width: 12px; height: 12px; }
|
|
1585
|
+
.subformat-list-record > .subformat-card-meta { flex-wrap: nowrap; grid-column: 2; grid-row: 1; min-width: 0; margin: 0; padding: 0; border: 0; gap: 16px; overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--c-line) transparent; }
|
|
1586
|
+
.subformat-list-record > .subformat-card-meta > div { display: flex; align-items: baseline; gap: 6px; flex: none; min-width: 0; max-width: 32ch; }
|
|
1449
1587
|
.subformat-list-record > .subformat-card-meta dt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1588
|
+
.subformat-list-record > .subformat-card-meta dd { margin: 0; }
|
|
1450
1589
|
.subformat-list-record > .subformat-card-details { grid-column: 1 / -1; margin: 0; }
|
|
1451
|
-
@
|
|
1452
|
-
.subformat-list-record
|
|
1453
|
-
.subformat-list-record
|
|
1454
|
-
.subformat-list-record > .subformat-card-meta { grid-column: 1 / -1; grid-row: 2; }
|
|
1455
|
-
.subformat-list-record .subformat-card-file { max-width: 90px; }
|
|
1456
|
-
}
|
|
1457
|
-
@container (max-width: 420px) {
|
|
1458
|
-
.subformat-list-record .subformat-card-file { display: none; }
|
|
1590
|
+
@media (hover: hover) and (pointer: fine) {
|
|
1591
|
+
.subformat-list-record :is(.subformat-card-copy, .resource-download) { opacity: 0; }
|
|
1592
|
+
.subformat-list-record:is(:hover, :focus-within) :is(.subformat-card-copy, .resource-download) { opacity: 1; }
|
|
1459
1593
|
}
|
|
1460
1594
|
@container (max-width: 600px) {
|
|
1595
|
+
.subformat-list-record { grid-template-columns: minmax(0, 1fr) auto; }
|
|
1596
|
+
.subformat-list-record > .subformat-card-tools { grid-column: 2; grid-row: 1; }
|
|
1597
|
+
.subformat-list-record > .subformat-card-meta { grid-column: 1 / -1; grid-row: 2; }
|
|
1461
1598
|
.subformat-filter-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
1462
1599
|
.subformat-filter-row > label:nth-child(3) { grid-column: 1; }
|
|
1463
1600
|
.subformat-embed-toolbar .subformat-control { flex: 1 1 120px; max-width: none; }
|
|
@@ -2103,7 +2240,7 @@ body.corr main article > [data-ln].corr-hi {
|
|
|
2103
2240
|
body.edit .nav-row { cursor: grab; }
|
|
2104
2241
|
.nav-item.dragging { opacity: .35; }
|
|
2105
2242
|
.nav-row.drop-before { box-shadow: inset 0 2px 0 var(--c-accent); }
|
|
2106
|
-
.nav-row.drop-after { box-shadow: inset 0 -2px 0 var(--c-accent); }
|
|
2243
|
+
.nav-row.drop-after, #sidebar-head.drop-after { box-shadow: inset 0 -2px 0 var(--c-accent); }
|
|
2107
2244
|
.nav-row.drop-into > a { background: color-mix(in srgb, var(--c-accent) 18%, transparent); }
|
|
2108
2245
|
`;
|
|
2109
2246
|
// Contents of #nav-groups (the doc tree). Used by both page()'s initial render and
|
|
@@ -2217,7 +2354,7 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2217
2354
|
: "";
|
|
2218
2355
|
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>`;
|
|
2219
2356
|
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>`;
|
|
2220
|
-
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" && !library ? " 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-library"><div class="nav-item" data-node-id="_library"><div class="nav-row"><a class="nav-link${library ? " cur" : ""}" href="/_library" title="Library" data-i18n-title="Library">${STATICS_ICON}<span class="nav-label" data-i18n="Library">Library</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`;
|
|
2357
|
+
return `<details id="nav-tools" open>${location}<div class="nav-tool-cards"><div class="nav-resources" id="nav-manifest"><div class="nav-item" data-node-id="_manifest"><div class="nav-row"><a class="nav-link${currentRes === "_manifest" ? " cur" : ""}" href="/_manifest" title="dooc.yaml">${GEAR_ICON}<span class="nav-label">dooc.yaml</span></a></div></div></div><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 !== "_manifest" && currentRes !== "_git" && currentRes !== "_extensions" && currentRes !== "_subformats" && !library ? " 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-library"><div class="nav-item" data-node-id="_library"><div class="nav-row"><a class="nav-link${library ? " cur" : ""}" href="/_library" title="Library" data-i18n-title="Library">${STATICS_ICON}<span class="nav-label" data-i18n="Library">Library</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`;
|
|
2221
2358
|
};
|
|
2222
2359
|
const formatSize = (bytes) => bytes < 1024
|
|
2223
2360
|
? `${bytes} B`
|
|
@@ -2369,6 +2506,13 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2369
2506
|
const href = site.ctx.downloads?.get(file);
|
|
2370
2507
|
return href ? resourceDownloadHtml(file, href) : "";
|
|
2371
2508
|
};
|
|
2509
|
+
if (rest === "_manifest") {
|
|
2510
|
+
const file = manifestFile(site.root ?? root);
|
|
2511
|
+
return {
|
|
2512
|
+
title: file,
|
|
2513
|
+
main: `<article class="res-page resource-library manifest-page"><div id="manifest-manager" data-file="${escapeHtml(file)}"></div></article>`,
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2372
2516
|
if (rest === "_extensions")
|
|
2373
2517
|
return {
|
|
2374
2518
|
title: "Plugins",
|
|
@@ -2523,7 +2667,11 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2523
2667
|
};
|
|
2524
2668
|
};
|
|
2525
2669
|
// Browser tab title — shared by page() and `/api/page` (doc switching via client-side navigation).
|
|
2526
|
-
const pageTitle = (mode, title,
|
|
2670
|
+
const pageTitle = (mode, title, site) => mode === "preview"
|
|
2671
|
+
? (site.entries.find((entry) => entry.root)?.frontmatter?.title ?? site.title ?? title)
|
|
2672
|
+
: title === site.title
|
|
2673
|
+
? title
|
|
2674
|
+
: `${title} — ${site.title ?? "dooc edit"}`;
|
|
2527
2675
|
// Navigation follows the manifest hierarchy via routing.docPath.
|
|
2528
2676
|
const page = (mode, site, opts) => {
|
|
2529
2677
|
const currentDocument = site.entries.find((entry) => entry.id === opts.currentId);
|
|
@@ -2534,19 +2682,36 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2534
2682
|
const siteTitle = escapeHtml(site.title ?? "dooc");
|
|
2535
2683
|
const iconImg = `<img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>`;
|
|
2536
2684
|
const iconVariants = Object.entries(site.iconVariants ?? {});
|
|
2685
|
+
const tabIcons = { "": site.icon, ...site.iconVariants };
|
|
2686
|
+
const favicons = mode === "preview"
|
|
2687
|
+
? Object.entries(tabIcons)
|
|
2688
|
+
.flatMap(([theme, svg]) => svg && ["", "light", "dark"].includes(theme)
|
|
2689
|
+
? `<link data-document-icon="${theme}" rel="icon" type="image/svg+xml" href="${svgDataUri(squareSvg(svg) ?? svg)}"${theme ? ` media="(prefers-color-scheme: ${theme})"` : ""}>`
|
|
2690
|
+
: [])
|
|
2691
|
+
.join("\n")
|
|
2692
|
+
: "";
|
|
2537
2693
|
// The base image sits in a wrapper so theme switching and edit-client's #site-icon.hidden never fight.
|
|
2538
2694
|
const iconHtml = iconVariants.length
|
|
2539
2695
|
? `<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>`
|
|
2540
2696
|
: iconImg;
|
|
2541
2697
|
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>`;
|
|
2698
|
+
const output = opts.publish?.output;
|
|
2699
|
+
const script = (js) => output
|
|
2700
|
+
? `<script src="${escapeHtml(output.asset(js, "js"))}"></script>`
|
|
2701
|
+
: `<script>${inlineScript(js)}</script>`;
|
|
2702
|
+
const css = `${fontCss(Boolean(opts.publish))}${CSS}${mode === "edit" ? EDIT_CSS : ""}`;
|
|
2703
|
+
const stylesheet = output
|
|
2704
|
+
? `<link rel="stylesheet" href="${escapeHtml(output.asset(css, "css"))}">`
|
|
2705
|
+
: `<style>${css}</style>`;
|
|
2706
|
+
const self = output ? "'self' " : "";
|
|
2542
2707
|
const bootScripts = opts.boot != null
|
|
2543
2708
|
? `<script id="boot" type="application/json">${JSON.stringify(opts.boot).replace(/</g, "\\u003c")}</script>
|
|
2544
2709
|
<script src="/assets/edit.js"></script>
|
|
2545
2710
|
<script src="/assets/client.js"></script>`
|
|
2546
2711
|
: !opts.publish
|
|
2547
|
-
?
|
|
2712
|
+
? `<script src="/assets/${mode === "edit" && opts.currentRes === "_manifest" ? "manifest" : "ui"}.js"></script>`
|
|
2548
2713
|
: opts.publish.subformatJs
|
|
2549
|
-
?
|
|
2714
|
+
? script(opts.publish.subformatJs)
|
|
2550
2715
|
: "";
|
|
2551
2716
|
// Interaction layer of the schema graph (zoom / pan / box drag / enlarged view). Shared by
|
|
2552
2717
|
// preview / edit. Figures are readable without JS, so defer is enough (= progressive
|
|
@@ -2560,29 +2725,32 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2560
2725
|
: mode === "edit" && opts.currentRes !== undefined
|
|
2561
2726
|
? `<main class="resources-pane">${opts.main}</main>`
|
|
2562
2727
|
: `<main><div class="page-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("reader")}</div>${opts.main}</main>`;
|
|
2563
|
-
const graphScript =
|
|
2564
|
-
? `<script
|
|
2565
|
-
:
|
|
2728
|
+
const graphScript = output?.graph
|
|
2729
|
+
? `<script type="module" src="${escapeHtml(output.graph)}"></script>`
|
|
2730
|
+
: opts.publish
|
|
2731
|
+
? script(opts.publish.graphJs)
|
|
2732
|
+
: `<script>(${loadPreviewScript.toString()})("/assets/graph.js", "svg[data-sg-layout], [data-mermaid]", "module");</script>`;
|
|
2566
2733
|
return `<!doctype html><html lang="en"><head><meta charset="utf-8">
|
|
2567
|
-
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline' data:; img-src data: blob:; media-src data: blob:; object-src data:; font-src data: blob:; frame-src data: blob:; connect-src 'none'; base-uri 'none'; form-action 'none'">`}` : ""}
|
|
2734
|
+
${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 ${self}'unsafe-inline'; style-src ${self}'unsafe-inline' data:; img-src ${self}data: blob:; media-src ${self}data: blob:; object-src ${self}data:; font-src ${self}data: blob:; frame-src ${self}data: blob:; connect-src ${output ? "'self'" : "'none'"}; base-uri 'none'; form-action 'none'">`}` : ""}
|
|
2568
2735
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2569
|
-
<title>${escapeHtml(pageTitle(mode, opts.title, site
|
|
2570
|
-
|
|
2736
|
+
<title>${escapeHtml(pageTitle(mode, opts.title, site))}</title>
|
|
2737
|
+
${favicons}
|
|
2738
|
+
${script(`var __name = (f) => f;
|
|
2571
2739
|
(${initializeThemes.toString()})(${JSON.stringify(site.themes)});
|
|
2572
|
-
(${mountFigureFrames.toString()})(document)
|
|
2573
|
-
|
|
2574
|
-
<body data-document-manifest="${escapeHtml(currentDocument?.origin ?? "")}" data-document-path="${escapeHtml(currentDocument ? docPath(site.entries, currentDocument.id) : "/")}"${mode === "edit" ? ' class="edit"' : ""}${site.download ? ` data-download="${site.download}"` : ""}${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}<a id="site-title" class="site-title${rootCurrent ? " cur" : ""}" href="/"${/^https?:\/\//i.test(rootJump) ? ` data-jump-url="${escapeHtml(rootJump)}"` : ""} title="${siteTitle}"${rootCurrent ? ' aria-current="page"' : ""}${mode === "edit" ? ` data-title="${escapeHtml(site.title ?? "")}" aria-keyshortcuts="F2"` : ""}>${siteTitle}</a><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 ?? ""}
|
|
2575
|
-
|
|
2740
|
+
(${mountFigureFrames.toString()})(document);`)}
|
|
2741
|
+
${stylesheet}</head>
|
|
2742
|
+
<body data-content-language="${escapeHtml(site.contentLanguage ?? site.defaultLang)}" data-document-manifest="${escapeHtml(currentDocument?.origin ?? "")}" data-document-path="${escapeHtml(currentDocument ? docPath(site.entries, currentDocument.id) : "/")}"${mode === "edit" ? ' class="edit"' : ""}${site.download ? ` data-download="${site.download}"` : ""}${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}<a id="site-title" class="site-title${rootCurrent ? " cur" : ""}" href="/"${/^https?:\/\//i.test(rootJump) ? ` data-jump-url="${escapeHtml(rootJump)}"` : ""} title="${siteTitle}"${rootCurrent ? ' aria-current="page"' : ""}${mode === "edit" ? ` data-title="${escapeHtml(site.title ?? "")}" aria-keyshortcuts="F2"` : ""}>${siteTitle}</a><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 ?? ""}
|
|
2743
|
+
${script(`
|
|
2576
2744
|
(${mountDocumentLinks.toString()})(${showDialog.toString()}, ${!opts.publish || !!opts.publish.network}${opts.publish ? "" : `, ${workspaceFetch.toString()}`});
|
|
2577
2745
|
(${mountThemePickers.toString()})(${JSON.stringify(THEME_ICONS)}, ${JSON.stringify(site.themes)});
|
|
2578
2746
|
(${mountThemeVariants.toString()})(document);
|
|
2579
2747
|
${site.download === "block" ? `(${inlineScript(mountDownloadBlock.toString())})();` : ""}
|
|
2580
2748
|
${site.ctx.downloads ? `(${mountResourceDownloads.toString()})(${workspaceFetch.toString()});(${mountResourceExpand.toString()})();` : ""}
|
|
2581
|
-
|
|
2749
|
+
`)}
|
|
2582
2750
|
${bootScripts}${graphScript}
|
|
2583
2751
|
<script id="code-grammars" type="application/json"${opts.publish ? "" : ' data-src="/assets/code-grammars.json"'}>${opts.publish ? JSON.stringify(site.codeGrammars ?? []).replace(/</g, "\\u003c") : "[]"}</script>
|
|
2584
|
-
${opts.publish ?
|
|
2585
|
-
|
|
2752
|
+
${opts.publish ? script(opts.publish.codeJs) : `<script>(${loadPreviewScript.toString()})("/assets/code.js", ".codeblk");</script>`}
|
|
2753
|
+
${script(`
|
|
2586
2754
|
(() => {
|
|
2587
2755
|
// Functions toString'd under tsx (esbuild keepNames) contain __name(...) calls; define a no-op.
|
|
2588
2756
|
var __name = (f) => f;
|
|
@@ -2599,8 +2767,19 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
|
|
|
2599
2767
|
const KEY = "docs:sidebar-open";
|
|
2600
2768
|
const toggle = document.getElementById("sidebar-toggle");
|
|
2601
2769
|
if (!toggle) return;
|
|
2602
|
-
|
|
2770
|
+
let motionTimer;
|
|
2771
|
+
let motionRevision = 0;
|
|
2772
|
+
const apply = (open, animate = false) => {
|
|
2773
|
+
const revision = ++motionRevision;
|
|
2774
|
+
clearTimeout(motionTimer);
|
|
2775
|
+
document.body.classList.toggle("sidebar-toggling", animate);
|
|
2603
2776
|
document.body.classList.toggle("sidebar-closed", !open);
|
|
2777
|
+
if (animate) {
|
|
2778
|
+
const finish = () => { if (revision === motionRevision) document.body.classList.remove("sidebar-toggling"); };
|
|
2779
|
+
const motion = document.getElementById("sidebar").getAnimations().find((animation) => animation.transitionProperty === "width");
|
|
2780
|
+
if (motion) { void motion.finished.then(finish, () => {}); motionTimer = setTimeout(finish, 240); }
|
|
2781
|
+
else finish();
|
|
2782
|
+
}
|
|
2604
2783
|
toggle.setAttribute("aria-expanded", String(open));
|
|
2605
2784
|
toggle.dataset.i18nTitle = open ? "Close sidebar" : "Open sidebar";
|
|
2606
2785
|
toggle.title = window.__docsTranslate ? window.__docsTranslate(toggle.dataset.i18nTitle) : toggle.dataset.i18nTitle;
|
|
@@ -2615,10 +2794,10 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
|
|
|
2615
2794
|
open = !open;
|
|
2616
2795
|
preferred = open;
|
|
2617
2796
|
try { localStorage.setItem(KEY, open ? "1" : "0"); } catch {}
|
|
2618
|
-
apply(open);
|
|
2797
|
+
apply(open, true);
|
|
2619
2798
|
});
|
|
2620
2799
|
document.getElementById("sidebar-content")?.addEventListener("click", (event) => {
|
|
2621
|
-
if (open || !(event.target instanceof Element) || !event.target.closest(".nav-row")) return;
|
|
2800
|
+
if (open || !event.isTrusted || !(event.target instanceof Element) || !event.target.closest(".nav-row")) return;
|
|
2622
2801
|
event.preventDefault();
|
|
2623
2802
|
event.stopImmediatePropagation();
|
|
2624
2803
|
toggle.click();
|
|
@@ -2664,6 +2843,7 @@ void (${mountFontPickers.toString()})(${createFontSettings.toString()}, ${JSON.s
|
|
|
2664
2843
|
const nav = document.getElementById("nav-groups");
|
|
2665
2844
|
new ResizeObserver(() => (${focusNavTree.toString()})(nav)).observe(nav);
|
|
2666
2845
|
})();
|
|
2846
|
+
(${mountPageJump.toString()})(${focusNavTree.toString()});
|
|
2667
2847
|
${mode === "edit"
|
|
2668
2848
|
? `(() => {
|
|
2669
2849
|
// Sidebar tree editing stays delegated while navigation nodes are reconciled.
|
|
@@ -2684,7 +2864,7 @@ ${mode === "edit"
|
|
|
2684
2864
|
const cur = document.querySelector("#nav-groups .nav-row a.cur");
|
|
2685
2865
|
const id = (cur && cur.closest(".nav-item").dataset.docId) || "";
|
|
2686
2866
|
const pathname = location.pathname.slice((globalThis.__doocClientBase ?? "").length) || "/";
|
|
2687
|
-
const rp = pathname.startsWith("/_library") ? pathname.slice(1) : ["/_git", "/_extensions", "/_subformats"].includes(pathname) ? pathname.slice(1) : pathname.startsWith("/_files") ? pathname.slice(8).replace(/^\\/|\\/$/g, "") : null;
|
|
2867
|
+
const rp = pathname.startsWith("/_library") ? pathname.slice(1) : ["/_manifest", "/_git", "/_extensions", "/_subformats"].includes(pathname) ? pathname.slice(1) : pathname.startsWith("/_files") ? pathname.slice(8).replace(/^\\/|\\/$/g, "") : null;
|
|
2688
2868
|
const res = await localeFetch("/api/nav?current=" + encodeURIComponent(id) + (rp == null ? "" : "&res=" + encodeURIComponent(rp)));
|
|
2689
2869
|
if (res.ok) {
|
|
2690
2870
|
const data = await res.json();
|
|
@@ -2872,73 +3052,97 @@ ${mode === "edit"
|
|
|
2872
3052
|
|
|
2873
3053
|
let dragContext;
|
|
2874
3054
|
let dragged = null;
|
|
2875
|
-
let drop = null;
|
|
3055
|
+
let drop = null;
|
|
3056
|
+
let moving = false;
|
|
3057
|
+
let hoverTimer;
|
|
3058
|
+
let hovered;
|
|
2876
3059
|
const clearMarker = () => {
|
|
2877
|
-
for (const
|
|
2878
|
-
|
|
2879
|
-
|
|
3060
|
+
for (const row of document.querySelectorAll("#sidebar .drop-before, #sidebar .drop-after, #sidebar .drop-into"))
|
|
3061
|
+
row.classList.remove("drop-before", "drop-after", "drop-into");
|
|
3062
|
+
};
|
|
3063
|
+
const clearDrag = () => {
|
|
3064
|
+
clearTimeout(hoverTimer);
|
|
3065
|
+
hovered = undefined;
|
|
3066
|
+
dragged?.classList.remove("dragging");
|
|
3067
|
+
dragged = drop = null;
|
|
3068
|
+
clearMarker();
|
|
2880
3069
|
};
|
|
2881
3070
|
document.addEventListener("dragstart", (event) => {
|
|
2882
|
-
const row = event.target instanceof Element ? event.target.closest(".nav-row") : null;
|
|
3071
|
+
const row = event.target instanceof Element ? event.target.closest("#nav-groups .nav-row") : null;
|
|
2883
3072
|
if (!row || !event.dataTransfer) return;
|
|
2884
|
-
if (event.target.closest("input, button, .nav-doc-icon") || row.classList.contains("renaming")) {
|
|
3073
|
+
if (moving || document.body.dataset.versionReadOnly === "true" || row.getAttribute("draggable") !== "true" || event.target.closest("input, button, .nav-doc-icon") || row.classList.contains("renaming")) {
|
|
2885
3074
|
event.preventDefault();
|
|
2886
3075
|
return;
|
|
2887
3076
|
}
|
|
3077
|
+
clearDrag();
|
|
2888
3078
|
dragContext = context();
|
|
2889
|
-
dragged = row.closest(".nav-item");
|
|
3079
|
+
dragged = row.closest(".nav-item[data-doc-id]");
|
|
3080
|
+
if (!dragged) { event.preventDefault(); return; }
|
|
2890
3081
|
dragged.classList.add("dragging");
|
|
2891
3082
|
event.dataTransfer.effectAllowed = "move";
|
|
2892
|
-
event.dataTransfer.setData("application/x-doc-id", dragged.dataset.docId
|
|
3083
|
+
event.dataTransfer.setData("application/x-doc-id", dragged.dataset.docId);
|
|
2893
3084
|
});
|
|
2894
|
-
|
|
2895
|
-
|
|
3085
|
+
const cancelDrag = () => {
|
|
3086
|
+
const wasDragging = !!dragged;
|
|
3087
|
+
clearDrag();
|
|
3088
|
+
if (wasDragging && !moving) void refresh();
|
|
3089
|
+
};
|
|
3090
|
+
document.addEventListener("dragend", cancelDrag);
|
|
3091
|
+
window.addEventListener("blur", cancelDrag);
|
|
3092
|
+
document.addEventListener("dooc:workspace-changed", clearDrag);
|
|
3093
|
+
document.addEventListener("dragover", (event) => {
|
|
3094
|
+
if (!dragged || !event.dataTransfer || !current(dragContext)) return;
|
|
3095
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
3096
|
+
const root = document.querySelector("#nav-groups > .nav-root");
|
|
3097
|
+
const row = target?.closest("#nav-groups .nav-row, #sidebar-head");
|
|
3098
|
+
const item = row?.closest(".nav-item");
|
|
3099
|
+
const rootDrop = root && (row?.id === "sidebar-head" || item?.classList.contains("nav-placeholder") || target === root);
|
|
2896
3100
|
clearMarker();
|
|
2897
|
-
dragged = null;
|
|
2898
3101
|
drop = null;
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
3102
|
+
if (rootDrop) {
|
|
3103
|
+
const marker = row ?? root.querySelector(".nav-placeholder > .nav-row");
|
|
3104
|
+
if (marker) drop = { row: marker, zone: "after", parent: root.dataset.parent || undefined, index: [...root.children].filter((node) => node.dataset.docId && node !== dragged).length };
|
|
3105
|
+
} else if (item?.dataset.docId && !dragged.contains(item)) {
|
|
3106
|
+
const rect = row.getBoundingClientRect();
|
|
3107
|
+
const y = (event.clientY - rect.top) / rect.height;
|
|
3108
|
+
const zone = y < 0.25 ? "before" : y > 0.75 ? "after" : "into";
|
|
3109
|
+
const list = zone === "into" ? item.querySelector(":scope > .nav-list") : item.parentElement;
|
|
3110
|
+
if (list && (zone !== "into" || row.getAttribute("draggable") === "true")) {
|
|
3111
|
+
const siblings = [...list.children].filter((node) => node.dataset.docId && node !== dragged);
|
|
3112
|
+
drop = { row, zone, parent: list.dataset.parent || undefined, index: zone === "into" ? siblings.length : siblings.indexOf(item) + (zone === "after" ? 1 : 0) };
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
const nextHover = drop?.zone === "into" && !item.classList.contains("open") ? item : undefined;
|
|
3116
|
+
if (hovered !== nextHover) {
|
|
3117
|
+
clearTimeout(hoverTimer);
|
|
3118
|
+
hovered = nextHover;
|
|
3119
|
+
if (hovered) hoverTimer = setTimeout(() => { if (dragged && hovered) window.__docsNavOpen?.(hovered.dataset.docId, true); }, 500);
|
|
3120
|
+
}
|
|
3121
|
+
if (!drop) return;
|
|
2906
3122
|
event.preventDefault();
|
|
2907
3123
|
event.dataTransfer.dropEffect = "move";
|
|
2908
|
-
|
|
2909
|
-
const y = (event.clientY - rect.top) / rect.height;
|
|
2910
|
-
const zone = y < 0.25 ? "before" : y > 0.75 ? "after" : "into";
|
|
2911
|
-
clearMarker();
|
|
2912
|
-
row.classList.add("drop-" + zone);
|
|
2913
|
-
drop = { row, zone };
|
|
3124
|
+
drop.row.classList.add("drop-" + drop.zone);
|
|
2914
3125
|
});
|
|
2915
3126
|
document.addEventListener("drop", async (event) => {
|
|
2916
|
-
if (!dragged || !drop) return;
|
|
3127
|
+
if (!dragged || !drop || !current(dragContext)) return;
|
|
2917
3128
|
event.preventDefault();
|
|
3129
|
+
const target = dragContext;
|
|
2918
3130
|
const id = dragged.dataset.docId;
|
|
2919
|
-
const
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
if (drop.zone === "into") {
|
|
2923
|
-
parent = item.dataset.docId;
|
|
2924
|
-
index = [...item.querySelector(":scope > .nav-list").children].filter((n) => n.dataset.docId && n !== dragged).length;
|
|
2925
|
-
if (window.__docsNavOpen) window.__docsNavOpen(parent, true);
|
|
2926
|
-
} else {
|
|
2927
|
-
const list = item.parentElement;
|
|
2928
|
-
parent = list.dataset.parent || undefined;
|
|
2929
|
-
const siblings = [...list.children].filter((n) => n.dataset.docId && n !== dragged);
|
|
2930
|
-
index = siblings.indexOf(item) + (drop.zone === "after" ? 1 : 0);
|
|
2931
|
-
}
|
|
2932
|
-
clearMarker();
|
|
3131
|
+
const { parent, index, zone } = drop;
|
|
3132
|
+
clearDrag();
|
|
3133
|
+
moving = true;
|
|
2933
3134
|
setStatus("Moving…", false);
|
|
2934
3135
|
try {
|
|
2935
|
-
await post("/api/move", { id, parent, index },
|
|
2936
|
-
if (!current(
|
|
3136
|
+
await post("/api/move", { id, parent, index }, target);
|
|
3137
|
+
if (!current(target)) return;
|
|
3138
|
+
if (zone === "into") window.__docsNavOpen?.(parent, true);
|
|
2937
3139
|
setStatus("Moved", false);
|
|
2938
3140
|
} catch (error) {
|
|
2939
|
-
setStatus("Failed to move: " + error.message, true);
|
|
3141
|
+
if (current(target)) setStatus("Failed to move: " + error.message, true);
|
|
3142
|
+
} finally {
|
|
3143
|
+
moving = false;
|
|
3144
|
+
if (current(target)) await refresh();
|
|
2940
3145
|
}
|
|
2941
|
-
await refresh();
|
|
2942
3146
|
});
|
|
2943
3147
|
|
|
2944
3148
|
document.addEventListener("docs:files-changed", () => { void refresh(); });
|
|
@@ -3198,9 +3402,9 @@ document.addEventListener("click", (ev) => {
|
|
|
3198
3402
|
}
|
|
3199
3403
|
});
|
|
3200
3404
|
})();
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
${opts.publish ? `${opts.publish.pages}
|
|
3405
|
+
`)}
|
|
3406
|
+
${script(`(${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)}, ${workspaceFetch.toString()});`)}
|
|
3407
|
+
${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publish.first)}${opts.publish.network && !opts.publish.pluginJs ? `\n(${mountBundleNetwork.toString()})();` : ""}`)}${opts.publish.pluginJs ? script(opts.publish.pluginJs) : ""}` : ""}</body></html>`;
|
|
3204
3408
|
};
|
|
3205
3409
|
// A `</script` inside an inline <script> would close the script early, so escape it.
|
|
3206
3410
|
const inlineScript = (js) => js.replace(/<\/(script)/gi, "<\\/$1");
|
|
@@ -3211,7 +3415,9 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3211
3415
|
const FIRST = ${JSON.stringify(first)};
|
|
3212
3416
|
const main = document.querySelector("main");
|
|
3213
3417
|
const pages = new Map([...document.querySelectorAll("template[data-route]")].map((t) => [t.dataset.route, t]));
|
|
3214
|
-
|
|
3418
|
+
let navigation = 0;
|
|
3419
|
+
const show = async () => {
|
|
3420
|
+
const request = ++navigation;
|
|
3215
3421
|
const [path, rawAnchor] = location.hash.slice(1).split("#");
|
|
3216
3422
|
let anchor = "";
|
|
3217
3423
|
try { anchor = decodeURIComponent(rawAnchor || ""); } catch {}
|
|
@@ -3224,22 +3430,33 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3224
3430
|
location.replace(target.startsWith("/") ? "#" + target : target);
|
|
3225
3431
|
return;
|
|
3226
3432
|
}
|
|
3433
|
+
(${focusNavTree.toString()})(document.getElementById("nav-groups"), "#/" + route);
|
|
3434
|
+
document.title = page.dataset.title;
|
|
3227
3435
|
const actions = main.querySelector(":scope > .page-actions");
|
|
3436
|
+
if (page.dataset.src) {
|
|
3437
|
+
main.setAttribute("aria-busy", "true");
|
|
3438
|
+
try {
|
|
3439
|
+
if (location.protocol === "file:") throw new Error("Serve split builds over HTTP(S).");
|
|
3440
|
+
const response = await fetch(page.dataset.src);
|
|
3441
|
+
if (!response.ok) throw new Error("Page request failed: " + response.status);
|
|
3442
|
+
page.innerHTML = await response.text();
|
|
3443
|
+
delete page.dataset.src;
|
|
3444
|
+
} catch (error) {
|
|
3445
|
+
if (request !== navigation) return;
|
|
3446
|
+
const notice = document.createElement("p");
|
|
3447
|
+
notice.setAttribute("role", "alert");
|
|
3448
|
+
notice.textContent = "Could not load page. " + error.message;
|
|
3449
|
+
main.replaceChildren(notice);
|
|
3450
|
+
if (actions) main.prepend(actions);
|
|
3451
|
+
main.removeAttribute("aria-busy");
|
|
3452
|
+
return;
|
|
3453
|
+
}
|
|
3454
|
+
}
|
|
3455
|
+
if (request !== navigation) return;
|
|
3456
|
+
main.removeAttribute("aria-busy");
|
|
3228
3457
|
main.innerHTML = page.innerHTML;
|
|
3229
3458
|
document.dispatchEvent(new Event("docs:page-shown"));
|
|
3230
3459
|
if (actions) main.prepend(actions);
|
|
3231
|
-
document.title = page.dataset.title;
|
|
3232
|
-
for (const a of document.querySelectorAll("#site-title, #nav-groups a")) {
|
|
3233
|
-
const current = a.getAttribute("href").split("?")[0] === "#/" + route;
|
|
3234
|
-
a.classList.toggle("cur", current);
|
|
3235
|
-
if (current) a.setAttribute("aria-current", "page");
|
|
3236
|
-
else a.removeAttribute("aria-current");
|
|
3237
|
-
}
|
|
3238
|
-
const cur = document.querySelector("#nav-groups a.cur");
|
|
3239
|
-
for (let it = cur && cur.closest(".nav-item").parentElement.closest(".nav-item"); it; it = it.parentElement.closest(".nav-item")) {
|
|
3240
|
-
it.classList.add("open");
|
|
3241
|
-
}
|
|
3242
|
-
(${focusNavTree.toString()})(document.getElementById("nav-groups"));
|
|
3243
3460
|
const target = anchor && document.getElementById(anchor);
|
|
3244
3461
|
requestAnimationFrame(() => {
|
|
3245
3462
|
if (target) target.scrollIntoView(); else main.scrollTo(0, 0);
|
|
@@ -3254,11 +3471,10 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3254
3471
|
.replace(/(href|data-section-url)="\/(?!\/)/g, '$1="#/')
|
|
3255
3472
|
.replace(/href="#(?!\/)/g, `href="#/${route}#`);
|
|
3256
3473
|
/**
|
|
3257
|
-
*
|
|
3258
|
-
* down to figures / terms / schema graph JS). Each doc is held in a
|
|
3259
|
-
* <template> and switched via hash routes.
|
|
3474
|
+
* Publish the Site with hash routes, either inline or through an external asset sink.
|
|
3260
3475
|
*/
|
|
3261
|
-
const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static", pluginJs = "", subformatJs = "") => {
|
|
3476
|
+
const publishHtml = (site, graphJs, title = site.title ?? "dooc", codeJs = "", mode = "static", pluginJs = "", subformatJs = "", output) => {
|
|
3477
|
+
const publishedSite = { ...site, title };
|
|
3262
3478
|
const pages = site.entries.map((e) => ({
|
|
3263
3479
|
route: docPath(site.entries, e.id).slice(1),
|
|
3264
3480
|
title: docDisplayName(e.frontmatter, e.id),
|
|
@@ -3302,9 +3518,13 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3302
3518
|
pages.push({ route: encoded, ...linked });
|
|
3303
3519
|
}
|
|
3304
3520
|
const templates = pages
|
|
3305
|
-
.map((p) =>
|
|
3521
|
+
.map((p) => {
|
|
3522
|
+
const content = toHashLinks(p.main, p.route);
|
|
3523
|
+
const source = output?.asset(content, "html");
|
|
3524
|
+
return `<template data-route="${escapeHtml(p.route)}" data-title="${escapeHtml(pageTitle("preview", p.title, publishedSite))}"${p.redirect ? ` data-redirect="${escapeHtml(p.redirect)}"` : ""}${source ? ` data-src="${escapeHtml(source)}"` : ""}>${source ? "" : content}</template>`;
|
|
3525
|
+
})
|
|
3306
3526
|
.join("");
|
|
3307
|
-
return toHashLinks(page("preview",
|
|
3527
|
+
return toHashLinks(page("preview", publishedSite, {
|
|
3308
3528
|
title,
|
|
3309
3529
|
main: "",
|
|
3310
3530
|
publish: {
|
|
@@ -3315,6 +3535,7 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3315
3535
|
network: mode !== "static",
|
|
3316
3536
|
pluginJs: mode === "live" ? pluginJs : undefined,
|
|
3317
3537
|
subformatJs,
|
|
3538
|
+
output,
|
|
3318
3539
|
},
|
|
3319
3540
|
}), first);
|
|
3320
3541
|
};
|
|
@@ -3428,6 +3649,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3428
3649
|
<label><input type="checkbox" id="opt-corr"><span data-i18n="Source mapping">Source mapping</span></label>
|
|
3429
3650
|
<label><input type="checkbox" id="opt-git-diff"><span data-i18n="Show Git changes">Show Git changes</span></label>
|
|
3430
3651
|
<label><input type="checkbox" id="opt-line-wrap" checked><span data-i18n="Wrap lines">Wrap lines</span></label>
|
|
3652
|
+
<label><input type="checkbox" id="opt-page-jump" checked><span data-i18n="Space + arrow page jump">space+arrow page jump</span></label>
|
|
3431
3653
|
</div></div>
|
|
3432
3654
|
<button id="editor-open-workspace" class="pbtn" type="button" aria-label="Open workspace" data-i18n-aria-label="Open workspace" title="Open workspace" data-i18n-title="Open workspace">${icon('<path d="M2 5h6l2 2h8v10H2zM2 5V3h6l2 2"/>')}</button>
|
|
3433
3655
|
</div></div>
|
|
@@ -3448,7 +3670,8 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3448
3670
|
if (typeof path !== "string" || !path.startsWith("/")) {
|
|
3449
3671
|
return { status: 400, body: { error: "route must be /<docId>" } };
|
|
3450
3672
|
}
|
|
3451
|
-
if (path === "/
|
|
3673
|
+
if (path === "/_manifest" ||
|
|
3674
|
+
path === "/_extensions" ||
|
|
3452
3675
|
path === "/_subformats" ||
|
|
3453
3676
|
path === "/_git" ||
|
|
3454
3677
|
path === "/_library" ||
|
|
@@ -3458,7 +3681,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3458
3681
|
try {
|
|
3459
3682
|
const resource = resourcesMain(site, path.startsWith("/_library")
|
|
3460
3683
|
? path.slice(1)
|
|
3461
|
-
: ["/_git", "/_extensions", "/_subformats"].includes(path)
|
|
3684
|
+
: ["/_manifest", "/_git", "/_extensions", "/_subformats"].includes(path)
|
|
3462
3685
|
? path.slice(1)
|
|
3463
3686
|
: path.slice("/_files".length).replace(/^\/|\/$/g, ""));
|
|
3464
3687
|
return resource
|
|
@@ -3467,7 +3690,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3467
3690
|
body: {
|
|
3468
3691
|
resource: true,
|
|
3469
3692
|
path,
|
|
3470
|
-
title: pageTitle("edit", resource.title, site
|
|
3693
|
+
title: pageTitle("edit", resource.title, site),
|
|
3471
3694
|
html: docLinks(site, resource.main),
|
|
3472
3695
|
sourceFile: resource.sourceFile,
|
|
3473
3696
|
},
|
|
@@ -3494,7 +3717,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3494
3717
|
resource: true,
|
|
3495
3718
|
versionManifest: doc.origin ?? "",
|
|
3496
3719
|
path,
|
|
3497
|
-
title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site
|
|
3720
|
+
title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site),
|
|
3498
3721
|
html,
|
|
3499
3722
|
},
|
|
3500
3723
|
};
|
|
@@ -3502,7 +3725,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3502
3725
|
return {
|
|
3503
3726
|
status: 200,
|
|
3504
3727
|
body: {
|
|
3505
|
-
title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site
|
|
3728
|
+
title: pageTitle("edit", docDisplayName(doc.frontmatter, doc.id), site),
|
|
3506
3729
|
file: doc.file,
|
|
3507
3730
|
html,
|
|
3508
3731
|
errors,
|
|
@@ -3821,8 +4044,9 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3821
4044
|
});
|
|
3822
4045
|
};
|
|
3823
4046
|
const handle = async (mode, req, res) => {
|
|
3824
|
-
await host.prepareSources?.(root);
|
|
3825
4047
|
const requestUrl = new URL(req.url ?? "/", "http://localhost");
|
|
4048
|
+
if (requestUrl.pathname !== "/api/nav")
|
|
4049
|
+
await host.prepareSources?.(root);
|
|
3826
4050
|
const requestedLanguage = req.headers["x-docs-language"] ??
|
|
3827
4051
|
requestUrl.searchParams.get("lang") ??
|
|
3828
4052
|
contentLanguageCode(readManifest(root).defaultLang ?? DEFAULT_LANG);
|
|
@@ -4037,6 +4261,18 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4037
4261
|
res.end(req.headers["if-none-match"] === etag ? undefined : json);
|
|
4038
4262
|
return;
|
|
4039
4263
|
}
|
|
4264
|
+
if (mode === "edit" && req.method === "GET" && path === "/api/nav") {
|
|
4265
|
+
const site = loadNavigation(locale, requestUrl.searchParams.get("current"));
|
|
4266
|
+
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
4267
|
+
sendJson(res, 200, {
|
|
4268
|
+
siteTitle: site.title,
|
|
4269
|
+
siteIcon: site.icon ? svgDataUri(site.icon) : undefined,
|
|
4270
|
+
rootJump: docHref(site.entries, site.entries.find((entry) => entry.root)?.id ?? ""),
|
|
4271
|
+
translatedLanguages: site.entries.find((entry) => entry.id === requestUrl.searchParams.get("current"))?.translatedLanguages,
|
|
4272
|
+
html: navGroupsHtml(mode, site, params.get("current") || undefined, params.get("res") ?? undefined),
|
|
4273
|
+
});
|
|
4274
|
+
return;
|
|
4275
|
+
}
|
|
4040
4276
|
const site = loadSite(locale);
|
|
4041
4277
|
if (req.method === "GET" && path === "/api/figure-preview") {
|
|
4042
4278
|
const figure = [...site.ctx.figures.values()].find((figure) => figure.file === requestUrl.searchParams.get("file"));
|
|
@@ -4070,17 +4306,6 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4070
4306
|
}
|
|
4071
4307
|
// edit-mode-only APIs (used by edit-client.ts). handle() strips the query from path, so
|
|
4072
4308
|
// the query is read from req.url via URL/URLSearchParams.
|
|
4073
|
-
if (mode === "edit" && req.method === "GET" && path === "/api/nav") {
|
|
4074
|
-
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
4075
|
-
sendJson(res, 200, {
|
|
4076
|
-
siteTitle: site.title,
|
|
4077
|
-
siteIcon: site.icon ? svgDataUri(site.icon) : undefined,
|
|
4078
|
-
rootJump: docHref(site.entries, site.entries.find((entry) => entry.root)?.id ?? ""),
|
|
4079
|
-
translatedLanguages: site.entries.find((entry) => entry.id === requestUrl.searchParams.get("current"))?.translatedLanguages,
|
|
4080
|
-
html: navGroupsHtml(mode, site, params.get("current") || undefined, params.get("res") ?? undefined),
|
|
4081
|
-
});
|
|
4082
|
-
return;
|
|
4083
|
-
}
|
|
4084
4309
|
if (mode === "edit" && req.method === "GET" && path === "/api/page") {
|
|
4085
4310
|
const params = new URL(req.url ?? "/", "http://localhost").searchParams;
|
|
4086
4311
|
const { status, body } = pageDataResponse(site, params.get("route"));
|
|
@@ -4101,7 +4326,8 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4101
4326
|
return;
|
|
4102
4327
|
}
|
|
4103
4328
|
if ((mode === "edit" &&
|
|
4104
|
-
(path === "/
|
|
4329
|
+
(path === "/_manifest" ||
|
|
4330
|
+
path === "/_extensions" ||
|
|
4105
4331
|
path === "/_subformats" ||
|
|
4106
4332
|
path === "/_git" ||
|
|
4107
4333
|
path === "/_library" ||
|
|
@@ -4112,7 +4338,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4112
4338
|
path.startsWith("/_files/schema/")) {
|
|
4113
4339
|
const rest = path.startsWith("/_library")
|
|
4114
4340
|
? path.slice(1)
|
|
4115
|
-
: ["/_git", "/_extensions", "/_subformats"].includes(path)
|
|
4341
|
+
: ["/_manifest", "/_git", "/_extensions", "/_subformats"].includes(path)
|
|
4116
4342
|
? path.slice(1)
|
|
4117
4343
|
: requestUrl.pathname.slice("/_files".length).replace(/^\/|\/$/g, "");
|
|
4118
4344
|
const page = resourcesMain(site, rest);
|
|
@@ -4137,7 +4363,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4137
4363
|
...boot,
|
|
4138
4364
|
resource: {
|
|
4139
4365
|
path,
|
|
4140
|
-
title: pageTitle(mode, page.title, site
|
|
4366
|
+
title: pageTitle(mode, page.title, site),
|
|
4141
4367
|
html: docLinks(site, page.main),
|
|
4142
4368
|
sourceFile: page.sourceFile,
|
|
4143
4369
|
},
|
|
@@ -4189,7 +4415,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4189
4415
|
...boot,
|
|
4190
4416
|
resource: {
|
|
4191
4417
|
path,
|
|
4192
|
-
title: pageTitle(mode, opts.title, site
|
|
4418
|
+
title: pageTitle(mode, opts.title, site),
|
|
4193
4419
|
html: entryMain(site, doc),
|
|
4194
4420
|
versionManifest: doc.origin ?? "",
|
|
4195
4421
|
},
|