@dooc-dev/dooc 0.0.28 → 0.0.30
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 +220 -221
- package/dist/engine/compiler/check.js +5 -3
- package/dist/engine/compiler/compile.d.ts +5 -0
- package/dist/engine/compiler/compile.js +44 -23
- package/dist/engine/compiler/dialect.js +1 -1
- package/dist/engine/compiler/document-diff.d.ts +53 -0
- package/dist/engine/compiler/document-diff.js +92 -0
- package/dist/engine/compiler/export.js +11 -3
- package/dist/engine/compiler/files.d.ts +1 -0
- package/dist/engine/compiler/files.js +75 -14
- package/dist/engine/compiler/from-mdast.js +12 -1
- package/dist/engine/compiler/icons.d.ts +7 -7
- package/dist/engine/compiler/icons.js +35 -37
- package/dist/engine/compiler/manifest.d.ts +1 -0
- package/dist/engine/compiler/manifest.js +25 -0
- package/dist/engine/compiler/ops.d.ts +2 -2
- package/dist/engine/compiler/ops.js +55 -112
- package/dist/engine/compiler/resource-index.js +4 -4
- package/dist/engine/compiler/root-page.d.ts +13 -0
- package/dist/engine/compiler/root-page.js +96 -0
- package/dist/engine/compiler/sidebar-removal.d.ts +63 -0
- package/dist/engine/compiler/sidebar-removal.js +317 -0
- package/dist/engine/compiler/subformats.d.ts +3 -0
- package/dist/engine/compiler/subformats.js +126 -32
- package/dist/engine/core/blocks.d.ts +5 -0
- package/dist/engine/core/content-metadata.d.ts +9 -4
- package/dist/engine/core/content-metadata.js +100 -16
- package/dist/engine/core/file-embed.d.ts +2 -1
- package/dist/engine/core/file-embed.js +4 -0
- package/dist/engine/core/files.d.ts +1 -0
- package/dist/engine/core/files.js +6 -1
- package/dist/engine/core/format-collections.js +2 -2
- package/dist/engine/core/formats.d.ts +1 -1
- package/dist/engine/core/formats.js +1 -1
- package/dist/engine/core/html.d.ts +4 -1
- package/dist/engine/core/html.js +13 -6
- package/dist/engine/core/icons.d.ts +7 -0
- package/dist/engine/core/icons.js +38 -0
- package/dist/engine/core/subformats.d.ts +2 -1
- package/dist/engine/core/subformats.js +6 -1
- package/dist/engine/core/toc-library.d.ts +5 -0
- package/dist/engine/core/toc-library.js +27 -0
- package/dist/frontend/document-application.d.ts +5 -2
- package/dist/frontend/document-application.js +477 -189
- package/dist/frontend/edit-dialog.d.ts +1 -0
- package/dist/frontend/edit-dialog.js +12 -8
- package/dist/frontend/file-references.js +1 -1
- package/dist/frontend/locales/eng.json +63 -1
- package/dist/frontend/locales/jpn.json +63 -1
- package/dist/frontend/locales/zho.json +63 -1
- package/dist/frontend/page-jump.js +17 -10
- package/dist/frontend/resize.js +38 -12
- package/dist/frontend/resource-download.js +7 -1
- package/dist/frontend/resource-library.js +1 -0
- package/dist/frontend/search.js +2 -0
- package/dist/frontend/theme-picker.d.ts +2 -2
- package/dist/frontend/theme-picker.js +2 -2
- package/dist/frontend/toc-ui.js +13 -0
- package/dist/manifest.global.js +193 -192
- package/dist/mcp-relay.mjs +8 -4
- package/dist/plugins.global.js +49 -49
- package/dist/server/cli.js +12 -0
- package/dist/server/document-diff-cli.d.ts +1 -0
- package/dist/server/document-diff-cli.js +193 -0
- package/dist/server/document-diff-report.d.ts +3 -0
- package/dist/server/document-diff-report.js +124 -0
- package/dist/server/document-diff-sources.d.ts +40 -0
- package/dist/server/document-diff-sources.js +128 -0
- package/dist/server/document-versions.d.ts +3 -1
- package/dist/server/document-versions.js +19 -70
- package/dist/server/git-diff.d.ts +1 -0
- package/dist/server/git-diff.js +22 -2
- package/dist/server/git-document-snapshot.d.ts +2 -0
- package/dist/server/git-document-snapshot.js +63 -0
- package/dist/server/operation-log.js +2 -0
- package/dist/server/serve.d.ts +2 -2
- package/dist/server/serve.js +4 -9
- package/dist/server/workspace-server.js +6 -10
- package/dist/subformats.global.js +478 -74
- package/dist/ui.global.js +435 -80
- package/dist/workspace/file-operation.d.ts +10 -0
- package/dist/workspace/file-operation.js +47 -0
- package/dist/workspace/mcp-tools.js +8 -4
- package/dist/workspace/site-icon.js +30 -23
- package/dist/workspace/textfile.js +8 -8
- package/dist/workspace-worker.global.js +261 -202
- package/package.json +2 -2
|
@@ -5,15 +5,17 @@ import { filesSnapshot, updateFiles } from "../engine/compiler/files.js";
|
|
|
5
5
|
import { loadProjectFonts } from "../engine/compiler/fonts.js";
|
|
6
6
|
import { formatCollectionBlock, readFormatCollection, } from "../engine/compiler/format-collections.js";
|
|
7
7
|
import { createHash, dirname, existsSync, join, mkdirSync, readFileSync, statSync, unlinkSync, writeFileSync, } from "../engine/compiler/host.js";
|
|
8
|
-
import { ICONS_DIR, loadIcons, ownsDocIcon, squareSvg } from "../engine/compiler/icons.js";
|
|
8
|
+
import { ICONS_DIR, loadIcons, ownsDocIcon, projectIcon, siteIconAssets, squareSvg, } from "../engine/compiler/icons.js";
|
|
9
9
|
import { ignoredFiles, withIgnoredFilesCache } from "../engine/compiler/ignored-files.js";
|
|
10
10
|
import { contentLanguageCode, contentLanguages, isContentLanguage, webLanguage, } from "../engine/compiler/language-codes.js";
|
|
11
11
|
import { setDocTranslation, siteContentLanguages, translationFile, translationFiles, } from "../engine/compiler/locales.js";
|
|
12
12
|
import { manifestFile, readManifest, writeManifest } from "../engine/compiler/manifest.js";
|
|
13
13
|
import { assembleDoc, createDocOps, isOpError, } from "../engine/compiler/ops.js";
|
|
14
14
|
import { isRemoteSourceFile } from "../engine/compiler/remote-manifests.js";
|
|
15
|
+
import { rootPageSource } from "../engine/compiler/root-page.js";
|
|
16
|
+
import { previewSidebarRemoval, removeSidebarEntry, reviewSidebarRemoval, } from "../engine/compiler/sidebar-removal.js";
|
|
15
17
|
import { readProjectSkills } from "../engine/compiler/skills.js";
|
|
16
|
-
import { compileSubformatSchema, subformatIconSvg, subformatResponse, validateSubformatFile, } from "../engine/compiler/subformats.js";
|
|
18
|
+
import { compileSubformatSchema, recordSubformat, subformatIconSvg, subformatResponse, validateSubformatFile, } from "../engine/compiler/subformats.js";
|
|
17
19
|
import { readTextfile, textfilePath, writeTextfile } from "../engine/compiler/textfile.js";
|
|
18
20
|
import { walkBlocks } from "../engine/core/blocks.js";
|
|
19
21
|
import { selectCodeGrammars, subformatCodeGrammars } from "../engine/core/code-grammars.js";
|
|
@@ -22,7 +24,7 @@ import { figureFrameHtml, mountFigureFrames } from "../engine/core/figure-frame.
|
|
|
22
24
|
import { defaultFilePath, docIconFile, isSkillFile, manifestDirectory, parseFileLayout, docFile as sourceDocFile, suggestDocFileName, } from "../engine/core/files.js";
|
|
23
25
|
import { FORMAT_TRAITS, formatSelector, matchesFormat, parseFormatQuery, } from "../engine/core/format-collections.js";
|
|
24
26
|
import { fenceFormat, fileFormat, isReferenceLibrary, REFERENCE_LIBRARIES, } from "../engine/core/formats.js";
|
|
25
|
-
import { blocksHtml, docHtml, escapeHtml, resourceDownloadHtml, termsHtml, } from "../engine/core/html.js";
|
|
27
|
+
import { blocksHtml, docHtml, escapeHtml, pageHtmlFilename, resourceDownloadHtml, termsHtml, } from "../engine/core/html.js";
|
|
26
28
|
import { FOLDER_ICON_PATH, LIBRARY_ICONS, LLM_ICON, libraryIcon, PLUGINS_ICON, SUBFORMATS_ICON, } from "../engine/core/icons.js";
|
|
27
29
|
import { DEFAULT_LANG, isLangTag, resolveLanguage, } from "../engine/core/language.js";
|
|
28
30
|
import { ja } from "../engine/core/languages/ja.js";
|
|
@@ -32,6 +34,7 @@ import { CODE_LANGS, docDisplayName } from "../engine/core/taxonomy.js";
|
|
|
32
34
|
import { isTermFile, termAnchor, termFileUrl } from "../engine/core/term-reference.js";
|
|
33
35
|
import { isRemoteTextfile, textfileName } from "../engine/core/textfile.js";
|
|
34
36
|
import { mountThemeVariants } from "../engine/core/theme-variants.js";
|
|
37
|
+
import { tocReference, tocUrl } from "../engine/core/toc-library.js";
|
|
35
38
|
import { workspaceLabel } from "../engine/core/workspace.js";
|
|
36
39
|
import { clientPath } from "../workspace/client-path.js";
|
|
37
40
|
import { codeFileResponse } from "../workspace/code-file.js";
|
|
@@ -108,7 +111,7 @@ export const createDocumentApplication = (root, host) => {
|
|
|
108
111
|
let compiler = createCompiler(root);
|
|
109
112
|
const ops = createDocOps(root);
|
|
110
113
|
/** Compile result → reader Site (shared by the server's per-request path and one-off publish). */
|
|
111
|
-
const siteFrom = ({ title, icon, iconVariants, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages, code = {}) => {
|
|
114
|
+
const siteFrom = ({ title, icon, iconVariants, accentColor, docs, terms, figures, sources, siteErrors, defaultLang, previews, contentLanguages, themes, subformats, }, languages = DEFAULT_SITE_LANGUAGES.languages, code = {}) => {
|
|
112
115
|
const entries = docs.flatMap((doc) => {
|
|
113
116
|
const source = sources.get(doc.file);
|
|
114
117
|
return source ? [toEntry(doc, source)] : [];
|
|
@@ -149,6 +152,7 @@ export const createDocumentApplication = (root, host) => {
|
|
|
149
152
|
...(title === undefined ? {} : { title }),
|
|
150
153
|
...(icon === undefined ? {} : { icon }),
|
|
151
154
|
...(iconVariants === undefined ? {} : { iconVariants }),
|
|
155
|
+
...(accentColor ? { accentColor } : {}),
|
|
152
156
|
entries,
|
|
153
157
|
ctx: {
|
|
154
158
|
docLinks: new Map(docs.filter(isContentPage).map((doc) => [doc.file, docHref(docs, doc.id)])),
|
|
@@ -258,6 +262,7 @@ export const createDocumentApplication = (root, host) => {
|
|
|
258
262
|
fonts: loadProjectFonts(root),
|
|
259
263
|
workspace,
|
|
260
264
|
sourceBase: sourceFileBase(root),
|
|
265
|
+
uploadDirectory: manifest.files?.uploadDirectory,
|
|
261
266
|
filePaths: snapshot?.files.map((file) => file.path),
|
|
262
267
|
contentLanguage: locale,
|
|
263
268
|
};
|
|
@@ -322,26 +327,26 @@ export const createDocumentApplication = (root, host) => {
|
|
|
322
327
|
translated.has(translationFile(sourceDocFile(current.id, manifest.files), language, current.origin))),
|
|
323
328
|
];
|
|
324
329
|
}
|
|
325
|
-
let
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
icon = squareSvg(readTextfile(root, manifest.icon));
|
|
329
|
-
}
|
|
330
|
-
catch { }
|
|
330
|
+
let siteIcons = {};
|
|
331
|
+
try {
|
|
332
|
+
siteIcons = siteIconAssets(root, manifest);
|
|
331
333
|
}
|
|
334
|
+
catch { }
|
|
332
335
|
return {
|
|
333
336
|
entries,
|
|
334
337
|
title,
|
|
335
|
-
|
|
338
|
+
...siteIcons,
|
|
336
339
|
subformats: manifest.subformats,
|
|
340
|
+
uploadDirectory: manifest.files?.uploadDirectory,
|
|
337
341
|
contentLanguage: locale,
|
|
338
342
|
themes: manifest.themes,
|
|
343
|
+
accentColor: manifest.accentColor,
|
|
339
344
|
workspace: workspaceSource ?? readWorkspaceSource(root),
|
|
340
345
|
};
|
|
341
346
|
});
|
|
342
347
|
const draftContext = (site) => ({
|
|
343
348
|
previews: site.previews,
|
|
344
|
-
root,
|
|
349
|
+
root: site.root ?? root,
|
|
345
350
|
docs: site.entries.filter(isContentPage).map((e) => ({
|
|
346
351
|
id: e.id,
|
|
347
352
|
url: e.url,
|
|
@@ -366,20 +371,76 @@ export const createDocumentApplication = (root, host) => {
|
|
|
366
371
|
const jump = docHref(site.entries, id);
|
|
367
372
|
return `${isLinkedEntry(entry) ? "data-document-link " : ""}${/^https?:\/\//i.test(jump) ? `data-jump-url="${escapeHtml(jump)}" ` : ""}href="${escapeHtml(docHref(site.entries, id, true))}`;
|
|
368
373
|
});
|
|
369
|
-
|
|
374
|
+
const pageContext = (site, entry) => ({
|
|
375
|
+
...site.ctx,
|
|
376
|
+
pageContents: (file, recursive, title) => contentsLibrary(site, file, recursive, title),
|
|
377
|
+
terms: entry.terms ?? site.ctx.terms,
|
|
378
|
+
lang: webLanguage(entry.lang),
|
|
379
|
+
language: resolveLanguage(entry.lang, site.languages),
|
|
380
|
+
});
|
|
381
|
+
const offlinePolicy = (split = false) => {
|
|
382
|
+
const self = split ? "'self' " : "";
|
|
383
|
+
return `<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 ${split ? "'self'" : "'none'"}; base-uri 'none'; form-action 'none'">`;
|
|
384
|
+
};
|
|
385
|
+
const standalonePageHtml = (site, entry) => {
|
|
386
|
+
const ctx = pageContext(site, entry);
|
|
387
|
+
const body = blocksHtml(entry.blocks, { ...ctx, downloads: undefined, figurePreview: undefined }) ||
|
|
388
|
+
(!entry.root && childrenOf(site.entries, entry.id).length
|
|
389
|
+
? contentsTree(site, entry, true)
|
|
390
|
+
: "");
|
|
391
|
+
const pages = new Map(Array.from(site.ctx.docLinks ?? [], ([file, route]) => [route, file]));
|
|
392
|
+
const source = entry.sourceFile ?? CONTENT_PREFIX + entry.file;
|
|
393
|
+
const content = docLinks(site, body).replace(/href="(\/[^"#?]*)(#[^"]*)?"/g, (original, path, hash = "") => {
|
|
394
|
+
const target = pages.get(path);
|
|
395
|
+
if (target === source)
|
|
396
|
+
return `href="${hash || "#"}"`;
|
|
397
|
+
if (target)
|
|
398
|
+
return `href="./${encodeURIComponent(pageHtmlFilename(target))}${hash}"`;
|
|
399
|
+
if (path.startsWith("/_files/file/"))
|
|
400
|
+
return `href="./${path.slice("/_files/file/".length).split(/%2F/i).at(-1)}${hash}"`;
|
|
401
|
+
return original;
|
|
402
|
+
});
|
|
403
|
+
const frames = content.includes("data-doc-figure-frame=")
|
|
404
|
+
? `<script>var __name = (f) => f; (${inlineScript(mountFigureFrames.toString())})(document);</script>`
|
|
405
|
+
: "";
|
|
406
|
+
return `<!doctype html><html lang="${escapeHtml(ctx.lang ?? "en")}"><head><meta charset="utf-8">${offlinePolicy()}<meta name="viewport" content="width=device-width, initial-scale=1"><meta name="referrer" content="no-referrer"><title>${escapeHtml(docDisplayName(entry.frontmatter, entry.id))}</title>
|
|
407
|
+
<style>
|
|
408
|
+
:root { ${LIGHT_C} ${DOC_FROM_C} }
|
|
409
|
+
@media (prefers-color-scheme: dark) { :root { ${DARK_C} } }
|
|
410
|
+
body { max-width: 75ch; margin: auto; padding: 1.5rem; color: var(--doc-fg); background: var(--doc-bg);
|
|
411
|
+
font: 1rem/1.6 system-ui, sans-serif; overflow-wrap: anywhere; }
|
|
412
|
+
a { color: var(--doc-accent-2); }
|
|
413
|
+
img, video, iframe, object, svg { max-width: 100%; }
|
|
414
|
+
iframe { border: 0; }
|
|
415
|
+
pre, .data-table-scroll { overflow: auto; }
|
|
416
|
+
table { border-collapse: collapse; }
|
|
417
|
+
th, td { padding: .3em .6em; border: 1px solid var(--doc-border); }
|
|
418
|
+
figure { margin: 1em 0; }
|
|
419
|
+
.cap { white-space: pre-line; }
|
|
420
|
+
.codecopy, .codefold, .figpop, .dictpop, .dict-toolbar, .data-table-resize, .subformat-embed-toolbar { display: none; }
|
|
421
|
+
.codeblk-head { display: flex; gap: .5em; }
|
|
422
|
+
.doc-icon { width: 1em; height: 1em; margin-right: .4em; }
|
|
423
|
+
</style>${frames}</head><body><article>${content}</article></body></html>`;
|
|
424
|
+
};
|
|
370
425
|
const pageDownload = (site, entry) => {
|
|
371
426
|
const file = entry.sourceFile ?? CONTENT_PREFIX + entry.file;
|
|
372
|
-
const
|
|
373
|
-
|
|
427
|
+
const source = site.ctx.downloads?.get(file);
|
|
428
|
+
if (!source)
|
|
429
|
+
return {};
|
|
430
|
+
const language = contentLanguageCode(site.defaultLang);
|
|
431
|
+
const locale = site.contentLanguage ?? language;
|
|
432
|
+
const url = `/api/download?page=${encodeURIComponent(docPath(site.entries, entry.id))}&lang=${encodeURIComponent(locale)}`;
|
|
433
|
+
const href = site.download !== "easy" && locale !== language ? `${url}&format=md` : source;
|
|
434
|
+
const htmlHref = site.download === "easy"
|
|
435
|
+
? `data:application/octet-stream;base64,${Buffer.from(standalonePageHtml(site, entry)).toString("base64")}`
|
|
436
|
+
: `${url}&format=html`;
|
|
437
|
+
return { pageDownload: { file, href, htmlHref } };
|
|
374
438
|
};
|
|
375
439
|
const renderEntry = (site, entry, fallbackTitle) => docLinks(site, docHtml(entry.frontmatter ?? { title: fallbackTitle }, entry.blocks, [...site.errors, ...entry.errors], {
|
|
376
|
-
...site
|
|
440
|
+
...pageContext(site, entry),
|
|
377
441
|
...pageDownload(site, entry),
|
|
378
|
-
terms: entry.terms ?? site.ctx.terms,
|
|
379
|
-
lang: webLanguage(entry.lang),
|
|
380
442
|
tocTitle: translate(entry.lang, "Contents"),
|
|
381
443
|
sectionUrl: `${docPath(site.entries, entry.id)}?lang=${encodeURIComponent(site.contentLanguage ?? entry.lang)}`,
|
|
382
|
-
language: resolveLanguage(entry.lang, site.languages),
|
|
383
444
|
}, entry.toc));
|
|
384
445
|
/** Compiles one source (unsaved or on disk; file = `<id>.md`) in the site context into an Entry. */
|
|
385
446
|
const draftEntry = (site, file, raw, textfiles) => {
|
|
@@ -444,12 +505,27 @@ export const createDocumentApplication = (root, host) => {
|
|
|
444
505
|
// changed. Rebuild if any of them did.
|
|
445
506
|
const renderSignature = (site, entry) => JSON.stringify([site.ctx.terms, site.errors, entry.errors, entry.frontmatter, entry.lang]) +
|
|
446
507
|
site.entries
|
|
447
|
-
.map((e) => [
|
|
448
|
-
.
|
|
508
|
+
.map((e) => [
|
|
509
|
+
e.sourceFile ?? CONTENT_PREFIX + e.file,
|
|
510
|
+
docPath(site.entries, e.id),
|
|
511
|
+
e.frontmatter?.title,
|
|
512
|
+
e.url,
|
|
513
|
+
e.icon,
|
|
514
|
+
])
|
|
449
515
|
.join("\n");
|
|
450
516
|
const entryHtmlCache = new Map();
|
|
451
517
|
/** Renders only the requested doc, not every doc in site.entries. */
|
|
452
518
|
const renderEntryHtml = (site, entry) => {
|
|
519
|
+
const contents = entry.url && tocReference(entry.url);
|
|
520
|
+
if (entry.library === "toc" || contents) {
|
|
521
|
+
const file = contents
|
|
522
|
+
? contents.file
|
|
523
|
+
: (entry.origin ?? manifestFile(site.root ?? root));
|
|
524
|
+
return {
|
|
525
|
+
html: `<article class="resource-library">${contentsLibrary(site, file, contents ? contents.recursive : true, docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
526
|
+
errors: [...site.errors, ...entry.errors],
|
|
527
|
+
};
|
|
528
|
+
}
|
|
453
529
|
if (entry.format)
|
|
454
530
|
return {
|
|
455
531
|
html: `<article class="res-page resource-library">${renderFormatCollection(site, entry.format, "", docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
@@ -634,9 +710,9 @@ body.edit :is(#sidebar, #panel, .resources-pane, .subformat-toast, .app-dialog,
|
|
|
634
710
|
.preview-pane { background: var(--c-bg0); color: var(--c-fg); }
|
|
635
711
|
.theme-picker { position: fixed; margin: 0; padding: 5px; width: 148px; border: 1px solid var(--c-line);
|
|
636
712
|
border-radius: 6px; background: var(--c-bg1); color: var(--c-fg); box-shadow: 0 8px 24px var(--c-shadow); }
|
|
637
|
-
.theme-picker button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px;
|
|
638
|
-
border: 0; border-radius: 4px; background: transparent; color: inherit; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
|
|
639
|
-
.theme-picker button:hover,
|
|
713
|
+
.theme-picker :is(button, a[download]) { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 8px;
|
|
714
|
+
border: 0; border-radius: 4px; background: transparent; color: inherit; font: inherit; font-size: 12px; text-align: left; text-decoration: none; cursor: pointer; }
|
|
715
|
+
.theme-picker :is(button, a[download]):is(:hover, :focus-visible) { background: var(--c-raised); }
|
|
640
716
|
.theme-picker [aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--c-accent); }
|
|
641
717
|
.font-control:focus:not(:focus-visible), .font-picker button:focus:not(:focus-visible) { outline: none; }
|
|
642
718
|
.font-control:focus-visible, .font-picker button:focus-visible { outline: 1px solid var(--c-accent); outline-offset: 1px; }
|
|
@@ -793,6 +869,12 @@ body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
|
|
|
793
869
|
padding: 10px 0 8px; }
|
|
794
870
|
#nav-groups { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
795
871
|
#nav-groups > .nav-root { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
|
|
872
|
+
#nav-groups:has(> #nav-docs[hidden])::before { content: ""; flex: 1; }
|
|
873
|
+
body.sidebar-closed [data-root-source], body[data-version-read-only=true] [data-root-source] { display: none; }
|
|
874
|
+
.root-source-fields { display: grid; gap: 12px; }
|
|
875
|
+
.root-source-fields label { display: grid; gap: 4px; }
|
|
876
|
+
.root-source-fields .root-source-depth { display: flex; align-items: center; gap: 8px; }
|
|
877
|
+
.root-source-fields [hidden] { display: none; }
|
|
796
878
|
.language-select, .language-picker { font: 13px/18px var(--font-sans); font-weight: var(--fw-body); }
|
|
797
879
|
.language-select { position: relative; }
|
|
798
880
|
.language-select-input { width: 100%; min-width: 0; height: 28px; padding: 4px 26px 4px 8px;
|
|
@@ -837,7 +919,7 @@ body.sidebar-closed #document-versions { padding: 8px 4px 12px; }
|
|
|
837
919
|
body.sidebar-closed #document-versions :is(.subformat-control-label, .version-select > .version-status) { display: none; }
|
|
838
920
|
body.sidebar-closed #document-versions .version-select .language-select-input { display: block; height: 36px; padding: 3px 2px 13px; font-size: 11px; text-align: center; }
|
|
839
921
|
body.sidebar-closed .version-select::after { top: 26px; right: calc(50% - 2px); width: 4px; height: 4px; }
|
|
840
|
-
body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site-icon-slot
|
|
922
|
+
body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site-icon-slot .nav-icon-pick, #save, #validate, .cm-textfile-validate) { display: none; }
|
|
841
923
|
.nav-link { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 16px;
|
|
842
924
|
color: var(--c-fg-muted); text-decoration: none; background: transparent; border: none;
|
|
843
925
|
font: inherit; text-align: left; cursor: pointer; min-width: 0; }
|
|
@@ -879,10 +961,10 @@ body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site
|
|
|
879
961
|
.nav-list > .nav-item.open { grid-template-rows: auto 1fr; }
|
|
880
962
|
.nav-item > .nav-list { min-height: 0; overflow: hidden; visibility: hidden; transition: visibility 0s 260ms; }
|
|
881
963
|
.nav-item.open > .nav-list { visibility: visible; transition-delay: 0s; }
|
|
882
|
-
.nav-tree-toggle { flex: none; display: flex; align-items: center; justify-content: center;
|
|
964
|
+
.nav-tree-toggle, [data-root-source] { flex: none; display: flex; align-items: center; justify-content: center;
|
|
883
965
|
width: 28px; height: 28px; margin-right: 6px; padding: 0; background: transparent; border: none;
|
|
884
966
|
border-radius: 4px; color: var(--c-fg-faint); cursor: pointer; }
|
|
885
|
-
.nav-tree-toggle:hover { color: var(--c-fg); }
|
|
967
|
+
.nav-tree-toggle:hover, [data-root-source]:hover { color: var(--c-fg); }
|
|
886
968
|
.nav-tree-toggle svg { transition: transform var(--nav-motion); }
|
|
887
969
|
.nav-tree-toggle[aria-expanded="true"]:not([data-expansion="all"]) svg { transform: rotate(90deg); }
|
|
888
970
|
.nav-tree-toggle .nav-chevron-double, .nav-tree-toggle[data-expansion="all"] .nav-chevron-single, .nav-tree-toggle[hidden], #nav-docs[hidden] { display: none; }
|
|
@@ -967,8 +1049,8 @@ body.sidebar-closed #nav-groups .nav-doc-icon { z-index: 1; pointer-events: none
|
|
|
967
1049
|
.workspace-location::-webkit-details-marker { display: none; }
|
|
968
1050
|
.workspace-location:hover { color: var(--c-fg); }
|
|
969
1051
|
.workspace-location > .nav-icon { flex: none; width: 14px; height: 14px; background: var(--c-bg1); }
|
|
970
|
-
.workspace-location > .nav-icon:last-child { margin-left: auto; }
|
|
971
|
-
#nav-tools[open] > .workspace-location > .nav-icon:last-child { transform: rotate(90deg); }
|
|
1052
|
+
.workspace-location > .nav-icon:nth-last-child(2) { margin-left: auto; }
|
|
1053
|
+
#nav-tools[open] > .workspace-location > .nav-icon:nth-last-child(2) { transform: rotate(90deg); }
|
|
972
1054
|
.workspace-address { min-width: 0; padding: 0 2px; background: var(--c-bg1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
973
1055
|
body.sidebar-closed #nav-tools { margin-left: 4px; margin-right: 4px; padding-left: 0; padding-right: 0; }
|
|
974
1056
|
body.sidebar-closed .workspace-location { left: 2px; right: 2px; min-height: 16px; }
|
|
@@ -984,16 +1066,21 @@ body.sidebar-closed .workspace-address { display: none; }
|
|
|
984
1066
|
.files-upload-status:empty { display: none; }
|
|
985
1067
|
.files-upload-status[data-state="error"] { color: var(--c-danger); }
|
|
986
1068
|
.files-upload-status[data-state="done"] { color: var(--doc-ok); }
|
|
987
|
-
.files-drop-hint, .extensions-drop-hint {
|
|
988
|
-
|
|
989
|
-
.files-
|
|
990
|
-
.files-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
body.files-
|
|
996
|
-
body.files-
|
|
1069
|
+
.files-drop-hint, .extensions-drop-hint { display: none; }
|
|
1070
|
+
body.files-dragging #nav-tools { min-height: 104px; border: 1px dashed var(--c-accent); border-radius: 8px; background: var(--c-bg1); }
|
|
1071
|
+
body.files-dragging #nav-tools .workspace-location { inset: 0; transform: none; justify-content: center; pointer-events: none; }
|
|
1072
|
+
body.files-dragging #nav-tools .workspace-location > :not(.files-drop-hint) { display: none; }
|
|
1073
|
+
body.files-dragging .nav-tool-cards > * { visibility: hidden; }
|
|
1074
|
+
body.files-dragging .files-drop-hint { display: grid; justify-items: center; gap: 6px; padding: 8px; color: var(--c-fg); font: 12px/1.4 var(--font-sans); text-align: center; }
|
|
1075
|
+
.files-drop-hint svg { width: 27px; height: 27px; color: var(--c-accent); }
|
|
1076
|
+
.files-drop-hint > span { color: var(--c-fg-muted); }
|
|
1077
|
+
body.files-plugin-drag #nav-extensions { z-index: 4; visibility: visible; }
|
|
1078
|
+
body.files-plugin-drag #nav-extensions .nav-item { visibility: hidden; }
|
|
1079
|
+
body.files-plugin-drag #nav-extensions .extensions-drop-hint { display: flex; height: 100%; gap: 6px; align-items: center; justify-content: center; color: var(--c-fg-muted); font-size: 11px; position: absolute; inset: 0; pointer-events: none; }
|
|
1080
|
+
body.files-over #nav-tools, .files-table tr.file-drop-over > td, .nav-doc-row.file-drop-over, #site-icon-slot.file-drop-over { background: color-mix(in srgb, var(--c-accent) 12%, var(--c-bg1)); }
|
|
1081
|
+
:is(.nav-doc-icon, #site-icon-slot, .nav-placeholder, #files-manager).file-drop-over { outline: 2px solid var(--c-accent); outline-offset: -2px; }
|
|
1082
|
+
body.sidebar-closed.files-dragging #nav-groups .files-drop-hint { display: flex; }
|
|
1083
|
+
body.sidebar-closed .files-drop-hint > :not(svg) { display: none; }
|
|
997
1084
|
#nav-status { min-height: 16px; margin: 6px 16px 0; color: var(--c-fg-faint); font-size: 11px;
|
|
998
1085
|
line-height: 1.35; }
|
|
999
1086
|
#nav-status.err { color: var(--c-danger); }
|
|
@@ -1274,6 +1361,7 @@ article blockquote > :first-child { margin-top: 0; }
|
|
|
1274
1361
|
article blockquote > :last-child { margin-bottom: 0; }
|
|
1275
1362
|
ul.idx { list-style: none; padding: 0; }
|
|
1276
1363
|
ul.idx li { margin: 10px 0; }
|
|
1364
|
+
ul.idx ul { list-style: none; padding-inline-start: 16px; margin-inline-start: 20px; border-inline-start: 1px solid var(--doc-border); }
|
|
1277
1365
|
ul.idx a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--doc-border); border-radius: 6px; color: var(--doc-fg); text-decoration: none; }
|
|
1278
1366
|
ul.idx a:hover { background: var(--doc-panel-2); }
|
|
1279
1367
|
ul.idx a > .nav-icon { width: 18px; height: 18px; }
|
|
@@ -1396,6 +1484,13 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1396
1484
|
.manifest-completions button { border: 0; border-radius: 0; background: transparent; }
|
|
1397
1485
|
.resources-pane .manifest-tabs { margin: 0 0 4px; padding: 0; }
|
|
1398
1486
|
.manifest-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 14px; background: transparent; color: var(--c-fg-muted); }
|
|
1487
|
+
.manifest-icon-field, .manifest-color-field { display:flex; align-items:end; gap:6px; }
|
|
1488
|
+
.manifest-icon-field .manifest-field, .manifest-color-field .manifest-field { flex:1; min-width:0; }
|
|
1489
|
+
.manifest-icon-field button, .manifest-color-field input[type="color"] { width:32px; height:32px; flex:none; padding:4px; cursor:pointer; }
|
|
1490
|
+
.cm-accent-picker { width: 24px; height: 20px; padding: 0 2px; margin-inline-start: 4px; border: 0; background: transparent; vertical-align: middle; cursor: pointer; }
|
|
1491
|
+
.manifest-icon-field button { display:grid; place-items:center; }
|
|
1492
|
+
.manifest-icon-field img { width:18px; height:18px; object-fit:contain; }
|
|
1493
|
+
.manifest-icon-field img:not([src]), .manifest-icon-field button:has(img[src]) svg { display:none; }
|
|
1399
1494
|
.manifest-tabs button[aria-selected="true"] { color: var(--c-accent); border-bottom-color: currentColor; }
|
|
1400
1495
|
.manifest-fields { min-width: 0; margin: 0; padding: 12px 0; border: 0; }
|
|
1401
1496
|
.manifest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; min-width: 0; }
|
|
@@ -1609,6 +1704,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1609
1704
|
.format-navigation code { color: var(--doc-fg-3); overflow-wrap: anywhere; }
|
|
1610
1705
|
.format-navigation select, .format-folder select { min-height: 34px; border: 1px solid var(--c-line); border-radius: 4px; padding: 4px 8px; background: var(--doc-bg); color: var(--doc-fg); font: inherit; box-sizing: border-box; }
|
|
1611
1706
|
.format-navigation select { max-width: min(240px, 65vw); }
|
|
1707
|
+
.toc-library-options > code { flex-basis: 100%; user-select: all; }
|
|
1612
1708
|
.format-collection .subformat-embed-toolbar { align-items: center; gap: 8px; }
|
|
1613
1709
|
.format-collection .format-folder { display: block; flex: 1 1 120px; max-width: 240px; margin: 0; order: 1; }
|
|
1614
1710
|
.format-folder select { width: 100%; max-width: none; }
|
|
@@ -1628,7 +1724,8 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1628
1724
|
.format-grid-boxes { display: block; width: 100%; height: 100%; stroke: currentColor; stroke-width: 1; fill: color-mix(in srgb, currentColor 8%, transparent); }
|
|
1629
1725
|
.format-grid-boxes > * { vector-effect: non-scaling-stroke; }
|
|
1630
1726
|
.format-grid-ellipsis { fill: none; stroke-width: 1.5; stroke-linecap: round; }
|
|
1631
|
-
.format-grid-grip {
|
|
1727
|
+
.format-grid-grip { fill: none; stroke: currentColor; stroke-linecap: round; }
|
|
1728
|
+
.format-column-count { display: inline-flex; align-items: center; gap: 6px; }
|
|
1632
1729
|
.format-display-settings { order: 5; font: 12px/1.6 var(--font-sans); }
|
|
1633
1730
|
.format-display-settings > button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; }
|
|
1634
1731
|
.format-display-fields { width: min(300px, calc(100vw - 16px)); padding: 16px 12px; }
|
|
@@ -1649,6 +1746,10 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1649
1746
|
.format-gallery > button:enabled:hover { background: var(--c-raised); }
|
|
1650
1747
|
.format-collection :is(.format-gallery > button, .format-view-switch button, .format-display-settings > button, .format-grid-size > button):focus-visible { outline: 2px solid var(--doc-accent); outline-offset: -2px; }
|
|
1651
1748
|
.format-collection [data-subformat-view="grid"] .subformat-cards { display: grid; grid-template-columns: repeat(var(--format-columns, 3), minmax(min(100%, 240px), 1fr)); gap: 16px; }
|
|
1749
|
+
.format-collection [data-subformat-view="expand"] .subformat-cards { display: grid; grid-template-columns: repeat(var(--format-columns, 3), minmax(0, 1fr)); gap: 16px; align-items: start; }
|
|
1750
|
+
.format-collection [data-subformat-board][data-subformat-view="expand"] { max-height: none; overflow: visible; }
|
|
1751
|
+
.format-collection [data-subformat-view="expand"] .format-card > .format-preview:has(.fig) { container-type: normal; min-height: 0; max-height: none; }
|
|
1752
|
+
.format-collection [data-subformat-view="expand"] .format-preview .fig > img:not(.resource-modal *) { width: 100%; height: auto; max-height: none; }
|
|
1652
1753
|
.format-collection .format-card { display: flex; flex-direction: column; padding: 0; border-radius: 8px; overflow: hidden; }
|
|
1653
1754
|
.format-card-header { display: flex; align-items: center; gap: 8px; padding: 3px 8px; min-height: 32px; border-bottom: 1px solid var(--c-line); }
|
|
1654
1755
|
.format-card-header > h3 { flex: 1; min-width: 0; margin: 0; font: 500 13px/1.4 var(--font-sans); }
|
|
@@ -1776,7 +1877,60 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1776
1877
|
.app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
|
|
1777
1878
|
.app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
|
|
1778
1879
|
.app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
|
|
1880
|
+
.sidebar-removal, .removal-summary { margin-bottom: 18px; min-width: 0; }
|
|
1881
|
+
.sidebar-removal [hidden] { display: none; }
|
|
1882
|
+
.removal-scroll, .removal-summary { max-height: min(58dvh, 440px); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
|
|
1883
|
+
.removal-tree, .removal-tree ul { list-style: none; margin: 0; padding: 0; }
|
|
1884
|
+
.removal-tree .nav-tree { --nav-pad: min(calc(4px + var(--removal-depth) * 23px), 40%); --nav-line: calc(var(--nav-pad) - 16px); }
|
|
1885
|
+
.removal-tree .nav-tree > .nav-item > .nav-row::before { width: 11px; }
|
|
1886
|
+
.removal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 36px; padding: 2px 4px 2px var(--nav-pad, 4px); }
|
|
1887
|
+
.removal-row > label { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; cursor: pointer; }
|
|
1888
|
+
.removal-row label span { overflow-wrap: anywhere; }
|
|
1889
|
+
.removal-row:focus-within, .removal-row:hover { background: var(--c-raised); }
|
|
1890
|
+
.removal-all { position: sticky; inset-block-start: 0; z-index: 4; border-bottom: 1px solid var(--c-line); background: var(--c-bg1); font-weight: 600; }
|
|
1891
|
+
.removal-modes { flex: none; display: inline-flex; overflow: hidden; border: 1px solid var(--c-line); border-radius: 5px; }
|
|
1892
|
+
.removal-modes button { display: grid; place-items: center; min-width: 30px; height: 28px; padding: 0; border: 0; border-radius: 0; background: transparent; color: var(--c-fg-muted); }
|
|
1893
|
+
.removal-modes button + button { border-inline-start: 1px solid var(--c-line); }
|
|
1894
|
+
.removal-modes button[aria-pressed=true] { color: var(--c-fg); background: var(--c-line); }
|
|
1895
|
+
.removal-modes button:disabled { opacity: .4; cursor: default; }
|
|
1896
|
+
.removal-modes button:focus-visible { outline-offset: -3px; }
|
|
1897
|
+
.removal-sources { margin-inline-start: calc(var(--nav-pad, 4px) + 23px); font-size: 12px; }
|
|
1898
|
+
.removal-sources label { display: flex; align-items: center; gap: 8px; min-height: 30px; overflow-wrap: anywhere; }
|
|
1899
|
+
.removal-summary > * + * { border-top: 1px solid var(--c-line); }
|
|
1900
|
+
.removal-stat { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 38px; padding: 4px; }
|
|
1901
|
+
.removal-stat::before { content: ""; }
|
|
1902
|
+
summary.removal-stat { cursor: pointer; list-style: none; }
|
|
1903
|
+
summary.removal-stat::-webkit-details-marker { display: none; }
|
|
1904
|
+
summary.removal-stat::before { width: 5px; height: 5px; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(-45deg); }
|
|
1905
|
+
details[open] > summary.removal-stat::before { transform: rotate(45deg); }
|
|
1906
|
+
.removal-stat strong { font-variant-numeric: tabular-nums; }
|
|
1907
|
+
.removal-subtotal { position: relative; padding-inline-start: 20px; color: var(--c-fg-muted); }
|
|
1908
|
+
.removal-subtotal::before { content: ""; position: absolute; inset-inline-start: 7px; inset-block-start: 0; width: 10px; height: 19px; border-inline-start: 1px solid var(--c-line); border-block-end: 1px solid var(--c-line); pointer-events: none; }
|
|
1909
|
+
.removal-summary ul { margin: 0 0 8px; padding-inline-start: 38px; overflow-wrap: anywhere; }
|
|
1910
|
+
.removal-summary li { padding-block: 2px; }
|
|
1911
|
+
.removal-summary code { color: var(--c-fg-muted); }
|
|
1912
|
+
.app-dialog:has(.removal-summary) .dialog-actions > :first-child { margin-inline-end: auto; }
|
|
1913
|
+
@media (forced-colors: active) { .removal-modes button[aria-pressed=true] { outline: 1px solid Highlight; outline-offset: -2px; } }
|
|
1914
|
+
@media (pointer: coarse) {
|
|
1915
|
+
.removal-row, .removal-row label, .removal-modes button { min-height: 44px; }
|
|
1916
|
+
.removal-modes button { min-width: 44px; }
|
|
1917
|
+
}
|
|
1779
1918
|
.app-dialog button.danger { color: var(--c-danger); }
|
|
1919
|
+
.file-placement, .icon-picker { display: grid; gap: 14px; margin-bottom: 18px; }
|
|
1920
|
+
.file-placement label { display: grid; gap: 5px; font-weight: 600; }
|
|
1921
|
+
.file-placement :is(input, select), .icon-picker input[type=search] { width: 100%; box-sizing: border-box; min-width: 0; min-height: 34px; padding: 5px 8px; border: 1px solid var(--c-line); border-radius: 4px; background: var(--c-bg0); color: var(--c-fg); font: inherit; }
|
|
1922
|
+
.file-placement-list { max-height: min(36dvh, 280px); overflow: auto; padding: 0; margin: 0; list-style: none; }
|
|
1923
|
+
.file-placement-list li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 4px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--c-line); overflow-wrap: anywhere; }
|
|
1924
|
+
.file-placement-list li > :is(small, select, input) { grid-column: 2; }
|
|
1925
|
+
.file-placement-list small, .icon-picker small { color: var(--c-fg-muted); }
|
|
1926
|
+
.file-placement-list svg { display: block; color: var(--c-fg-muted); }
|
|
1927
|
+
.icon-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(110px, 100%), 1fr)); gap: 6px; max-height: min(48dvh, 360px); overflow: auto; }
|
|
1928
|
+
.icon-picker-grid button { display: grid; gap: 3px; align-content: start; justify-items: center; overflow-wrap: anywhere; min-width: 0; }
|
|
1929
|
+
.icon-picker-grid button[hidden] { display: none; }
|
|
1930
|
+
.icon-picker-grid img { width: 36px; height: 36px; object-fit: contain; margin: 3px 0 5px; }
|
|
1931
|
+
.icon-picker > button { justify-self: start; }
|
|
1932
|
+
.app-dialog:has(.file-placement) .dialog-actions button:last-child { color: var(--c-bg0); background: var(--c-fg); }
|
|
1933
|
+
|
|
1780
1934
|
.history-dialog input { box-sizing: border-box; width: 100%; padding: 8px; color: var(--c-fg); background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 4px; font: inherit; }
|
|
1781
1935
|
.history-dialog ul { max-height: 50dvh; margin: 12px 0 20px; padding: 0; overflow-y: auto; list-style: none; color: var(--c-fg-muted); }
|
|
1782
1936
|
.history-dialog li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
|
|
@@ -1884,10 +2038,10 @@ a.file-editor-title:hover { color: var(--c-accent); text-decoration: underline;
|
|
|
1884
2038
|
body.git-diff-hidden .cm-lineNumbers :is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { box-shadow: none; }
|
|
1885
2039
|
body.git-diff-hidden .cm-line:is(.cm-git-added, .cm-git-modified, .cm-git-deleted-start, .cm-git-deleted-end) { background-color: transparent; }
|
|
1886
2040
|
#site-title .nav-rename-form { inset: 0; padding: 0; }
|
|
1887
|
-
#site-icon-slot
|
|
2041
|
+
#site-icon-slot .nav-icon-pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
|
|
1888
2042
|
#site-icon-slot:hover, #site-icon-slot:focus-within, #sidebar-head.over #site-icon-slot { background: var(--c-line); border-radius: 3px; }
|
|
1889
2043
|
#site-icon-slot:focus-within, #sidebar-head.over #site-icon-slot { outline: 1px solid var(--c-fg-muted); outline-offset: 2px; }
|
|
1890
|
-
body.sidebar-closed #site-icon-slot
|
|
2044
|
+
body.sidebar-closed #site-icon-slot .nav-icon-pick { display: none; }
|
|
1891
2045
|
/* Right panel = header / properties / editor stacked on one surface, separated by rules (no
|
|
1892
2046
|
nested frames). */
|
|
1893
2047
|
#panel { width: var(--panel-width, min(760px, 52vw)); flex-shrink: 0; position: sticky; top: 0; height: 100dvh; container: editor-panel / inline-size;
|
|
@@ -1945,10 +2099,11 @@ body.textfile-open:has(#file-editor:is(form), #file-editor .cm-content[contented
|
|
|
1945
2099
|
.schema-builder .schema-type-control > .subformat-control-label { padding: 0 4px; }
|
|
1946
2100
|
.schema-builder :is(input, textarea) { width: 100%; }
|
|
1947
2101
|
.schema-builder textarea { resize: vertical; }
|
|
1948
|
-
.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; }
|
|
1949
|
-
.schema-builder input[type="checkbox"]:checked { border-color: var(--c-fg-muted); }
|
|
1950
|
-
.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; }
|
|
1951
|
-
.schema-builder input[type="checkbox"]:
|
|
2102
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"] { flex: none; width: 14px; height: 14px; margin: 0; padding: 0; border-color: var(--c-fg-muted); border-radius: 3px; background: transparent; }
|
|
2103
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"]:checked { border-color: var(--c-fg-muted); }
|
|
2104
|
+
:is(.schema-builder, .sidebar-removal) 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; }
|
|
2105
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"]:indeterminate::after { left: 50%; top: 50%; width: 7px; height: 0; border: 0; border-top: 1.5px solid var(--c-fg); transform: translate(-50%, -50%); }
|
|
2106
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"]:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 3px; }
|
|
1952
2107
|
.schema-builder button { cursor: pointer; }
|
|
1953
2108
|
.schema-builder button:hover { background: var(--c-raised); }
|
|
1954
2109
|
.schema-builder button:disabled { opacity: .45; cursor: default; }
|
|
@@ -2098,8 +2253,8 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
|
|
|
2098
2253
|
.nav-doc-name { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 17px; }
|
|
2099
2254
|
.nav-doc-icon { position: relative; flex: none; display: flex; align-items: center; justify-content: center;
|
|
2100
2255
|
width: 20px; height: 24px; cursor: pointer; border-radius: 3px; color: var(--c-fg-faint); }
|
|
2101
|
-
.nav-doc-icon:hover, .nav-doc-icon.over, .nav-doc-icon:focus-within { background: var(--c-line); color: var(--c-fg); }
|
|
2102
|
-
.nav-doc-icon
|
|
2256
|
+
.nav-doc-icon:hover, .nav-doc-icon.file-drop-over, .nav-doc-icon:focus-within { background: var(--c-line); color: var(--c-fg); }
|
|
2257
|
+
.nav-doc-icon .nav-icon-pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
|
|
2103
2258
|
.nav-doc-icon > :is(.nav-icon, .doc-icon-frame) { width: 18px; height: 18px; }
|
|
2104
2259
|
.nav-icon-clear { position: absolute; right: -4px; top: -4px; width: 13px; height: 13px; padding: 0;
|
|
2105
2260
|
border: 1px solid var(--c-line); border-radius: 50%; font: 10px/11px sans-serif;
|
|
@@ -2184,7 +2339,8 @@ main.editor-workspace { padding: 0; height: 100dvh; display: flex; flex-directio
|
|
|
2184
2339
|
#preview-panes.split .preview-pane.active { border-top-color: var(--c-accent); }
|
|
2185
2340
|
#preview-panes .preview-pane:has(> .pane-resource .document-web, > .preview-content:not([hidden]) .document-web) { position: relative; padding: 0; border: 0; overflow: hidden; }
|
|
2186
2341
|
.preview-pane:has(> .preview-content:not([hidden]) .document-web) > .pane-actions { display: none; }
|
|
2187
|
-
.preview-pane:focus-visible { outline:
|
|
2342
|
+
#preview-panes:not(.split) > .preview-pane:focus-visible { outline:none; }
|
|
2343
|
+
#preview-panes.split .preview-pane:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
|
|
2188
2344
|
@media (max-width: 820px) {
|
|
2189
2345
|
body.edit:has(#panel) { display: grid; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: 50dvh 50dvh; height: 100dvh; min-height: 0; overflow: hidden; }
|
|
2190
2346
|
body.edit:has(#panel) #sidebar { grid-column: 1; grid-row: 1 / 3; height: 100dvh; z-index: 10; }
|
|
@@ -2337,7 +2493,7 @@ body.corr main article > [data-ln].corr-hi {
|
|
|
2337
2493
|
background: transparent; color: var(--c-fg-muted); cursor: pointer; opacity: 0; }
|
|
2338
2494
|
.nav-row:hover :is(.new, .nav-delete), .nav-row:focus-within :is(.new, .nav-delete),
|
|
2339
2495
|
.nav-row.renaming :is(.nav-rename-save, .nav-rename-cancel) { opacity: 1; }
|
|
2340
|
-
.nav-row.renaming > :is(.new, .nav-delete, .nav-tree-toggle, .nav-tree-spacer
|
|
2496
|
+
.nav-row.renaming > :is(.new, .nav-delete, .nav-tree-toggle, .nav-tree-spacer) { display: none; }
|
|
2341
2497
|
.nav-row :is(.new, .nav-delete, .nav-create, .nav-rename-save, .nav-rename-cancel):is(:hover, :focus-visible) { background: var(--c-line); }
|
|
2342
2498
|
.nav-row :is(.nav-rename-save, .nav-rename-cancel):disabled { opacity: .5; cursor: wait; }
|
|
2343
2499
|
.nav-row :is(.nav-rename-save, .nav-rename-cancel) svg { width: 15px; height: 15px; }
|
|
@@ -2440,16 +2596,21 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2440
2596
|
// shortcut: Edit included tree structure in its manifest until cross-manifest transactions are supported.
|
|
2441
2597
|
if (mode === "edit" && !e.origin) {
|
|
2442
2598
|
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>`;
|
|
2443
|
-
editableIcon = `<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${entryIcon(e, "doc-icon")}<
|
|
2599
|
+
editableIcon = `<span class="nav-doc-icon" title="icon" data-i18n-title="icon">${entryIcon(e, "doc-icon")}<button class="nav-icon-pick" type="button" aria-label="Choose an icon" data-i18n-aria-label="Choose an icon" aria-haspopup="dialog"></button>${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>`;
|
|
2444
2600
|
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>`;
|
|
2445
2601
|
}
|
|
2602
|
+
if (mode === "edit" &&
|
|
2603
|
+
e.included &&
|
|
2604
|
+
!site.entries.find((parent) => parent.id === e.parent)?.origin &&
|
|
2605
|
+
!actions)
|
|
2606
|
+
actions = `<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>`;
|
|
2446
2607
|
const branch = childrenOf(site.entries, e.id).length > 0;
|
|
2447
2608
|
const toggle = branch
|
|
2448
2609
|
? `<button class="nav-tree-toggle" type="button" aria-expanded="${open.has(e.id)}" aria-label="Toggle ${label}">${DISCLOSURE_ICON}</button>`
|
|
2449
2610
|
: mode === "edit"
|
|
2450
2611
|
? '<span class="nav-tree-spacer" aria-hidden="true"></span>'
|
|
2451
2612
|
: "";
|
|
2452
|
-
return `<div class="nav-item${open.has(e.id) ? " open" : ""}" data-doc-id="${escapeHtml(e.id)}"${!isContentPage(e) ? " data-subformat-nav" : ""}><div class="nav-row${mode === "edit" && !e.origin ? " nav-doc-row" : ""}"${mode === "edit" && !e.origin ? ' draggable="true"' : ""}>${editableIcon}${link}${actions}${toggle}</div>${list(e.id, depth + 1)}</div>`;
|
|
2613
|
+
return `<div class="nav-item${open.has(e.id) ? " open" : ""}" data-doc-id="${escapeHtml(e.id)}"${mode === "edit" && isContentPage(e) ? ` data-source-file="${escapeHtml(e.sourceFile ?? CONTENT_PREFIX + e.file)}"` : ""}${!isContentPage(e) ? " data-subformat-nav" : ""}><div class="nav-row${mode === "edit" && !e.origin ? " nav-doc-row" : ""}"${mode === "edit" && !e.origin ? ' draggable="true"' : ""}>${editableIcon}${link}${actions}${toggle}</div>${list(e.id, depth + 1)}</div>`;
|
|
2453
2614
|
})
|
|
2454
2615
|
.join("");
|
|
2455
2616
|
const placeholder = mode === "edit" && depth === 0
|
|
@@ -2504,16 +2665,16 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2504
2665
|
const format = currentRes?.startsWith("_format") ||
|
|
2505
2666
|
["codeblocks", "_library/codeblocks", "dictionary", "code"].includes(currentRes ?? "");
|
|
2506
2667
|
const library = !format && (currentRes?.startsWith("_library") || isReferenceLibrary(currentRes));
|
|
2507
|
-
const hint = `<
|
|
2668
|
+
const hint = `<span class="files-drop-hint" aria-hidden="true">${UPLOAD_ICON}<strong data-i18n="Drop files here">Drop files here</strong><span data-i18n="Choose where to place them">Choose where to place them</span></span>`;
|
|
2508
2669
|
const location = source?.protocol === "git"
|
|
2509
|
-
? `<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>`
|
|
2510
|
-
: `<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>`;
|
|
2670
|
+
? `<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}${hint}</summary>`
|
|
2671
|
+
: `<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}${hint}</summary>`;
|
|
2511
2672
|
const git = source?.protocol === "git" && sharedBranch === undefined
|
|
2512
2673
|
? `<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>`
|
|
2513
2674
|
: "";
|
|
2514
2675
|
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>`;
|
|
2515
|
-
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
|
|
2516
|
-
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" && currentRes !== "_llm" && !library && !format ? " 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
|
|
2676
|
+
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>`;
|
|
2677
|
+
return `<details id="nav-tools" open${site.uploadDirectory ? ` data-upload-directory="${escapeHtml(site.uploadDirectory)}"` : ""}>${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" && currentRes !== "_llm" && !library && !format ? " 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></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><div class="nav-resources" id="nav-format"><div class="nav-item" data-node-id="_format"><div class="nav-row"><a class="nav-link${format ? " cur" : ""}" href="/_format" title="Format" data-i18n-title="Format">${libraryIcon("codeblocks") ?? STATICS_ICON}<span class="nav-label" data-i18n="Format">Format</span></a></div></div></div>${subformats}${git}${extensions}</div></details>`;
|
|
2517
2678
|
};
|
|
2518
2679
|
const formatSize = (bytes) => bytes < 1024
|
|
2519
2680
|
? `${bytes} B`
|
|
@@ -2575,6 +2736,17 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2575
2736
|
if (errors.length)
|
|
2576
2737
|
return { html: "", errors };
|
|
2577
2738
|
try {
|
|
2739
|
+
if (language === "md" || language === "markdown") {
|
|
2740
|
+
const { doc, source: parsed } = compileDraft(draftContext(site), file, source);
|
|
2741
|
+
return {
|
|
2742
|
+
html: blocksHtml(doc.blocks, {
|
|
2743
|
+
...site.ctx,
|
|
2744
|
+
terms: [...site.ctx.terms, ...parsed.terms],
|
|
2745
|
+
pageContents: (file, recursive, title) => contentsLibrary(site, file, recursive, title),
|
|
2746
|
+
}),
|
|
2747
|
+
errors: parsed.errors,
|
|
2748
|
+
};
|
|
2749
|
+
}
|
|
2578
2750
|
return {
|
|
2579
2751
|
html: blocksHtml(parsed?.blocks ?? [
|
|
2580
2752
|
{
|
|
@@ -2605,16 +2777,6 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2605
2777
|
catch (error) {
|
|
2606
2778
|
errors.push(error instanceof Error ? error.message : String(error));
|
|
2607
2779
|
}
|
|
2608
|
-
if (/\.(md|markdown)$/i.test(file)) {
|
|
2609
|
-
const { doc, source: parsed } = compileDraft(draftContext(site), file, source);
|
|
2610
|
-
errors.push(...parsed.errors);
|
|
2611
|
-
try {
|
|
2612
|
-
blocksHtml(doc.blocks, site.ctx);
|
|
2613
|
-
}
|
|
2614
|
-
catch (error) {
|
|
2615
|
-
errors.push(error instanceof Error ? error.message : String(error));
|
|
2616
|
-
}
|
|
2617
|
-
}
|
|
2618
2780
|
return errors;
|
|
2619
2781
|
};
|
|
2620
2782
|
/** Hidden skill entries are readable only through the validated project skill list. */
|
|
@@ -2789,6 +2951,24 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2789
2951
|
}
|
|
2790
2952
|
if (!file && (kind === "dictionary" || kind === "code"))
|
|
2791
2953
|
return resourcesMain(site, "codeblocks");
|
|
2954
|
+
if (!file && kind === "toc") {
|
|
2955
|
+
const owner = site.root ?? root;
|
|
2956
|
+
const manifest = manifestFile(owner);
|
|
2957
|
+
const sources = new Map([[manifest, ""]]);
|
|
2958
|
+
for (const entry of site.entries) {
|
|
2959
|
+
if (entry.included && entry.origin)
|
|
2960
|
+
sources.set(entry.origin, entry.root ? "" : entry.id);
|
|
2961
|
+
if (isContentPage(entry) && entry.sourceFile)
|
|
2962
|
+
sources.set(entry.sourceFile, entry.root ? "" : entry.id);
|
|
2963
|
+
}
|
|
2964
|
+
const choices = [...sources]
|
|
2965
|
+
.map(([path, id]) => `<option value="${escapeHtml(path)}" data-page="${escapeHtml(id)}">${escapeHtml(path)}</option>`)
|
|
2966
|
+
.join("");
|
|
2967
|
+
return {
|
|
2968
|
+
title: "Table of contents",
|
|
2969
|
+
main: `<article class="res-page resource-library" data-toc-library>${resourceTabs("toc", readManifest(owner).libraries)}<div class="format-navigation toc-library-options"><label><span data-i18n="Page or manifest file">Page or manifest file</span><select data-toc-source>${choices}</select></label><label><input type="checkbox" data-toc-recursive checked><span data-i18n="Include all descendants">Include all descendants</span></label><code data-toc-embed aria-live="polite">)})</code></div><div data-toc-results>${contentsLibrary(site, manifest, true)}</div></article>`,
|
|
2970
|
+
};
|
|
2971
|
+
}
|
|
2792
2972
|
if (kind === "schema" && file) {
|
|
2793
2973
|
const config = site.subformats?.find((format) => format.ext === file);
|
|
2794
2974
|
if (!config)
|
|
@@ -2921,6 +3101,14 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2921
3101
|
? title
|
|
2922
3102
|
: `${title} — ${site.title ?? "dooc edit"}`;
|
|
2923
3103
|
// Navigation follows the manifest hierarchy via routing.docPath.
|
|
3104
|
+
const siteIconImages = (site) => {
|
|
3105
|
+
const iconImg = `<img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>`;
|
|
3106
|
+
const iconVariants = Object.entries(site.iconVariants ?? {});
|
|
3107
|
+
// The base image sits in a wrapper so theme switching and edit-client's #site-icon.hidden never fight.
|
|
3108
|
+
return iconVariants.length
|
|
3109
|
+
? `<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>`
|
|
3110
|
+
: iconImg;
|
|
3111
|
+
};
|
|
2924
3112
|
const page = (mode, site, opts) => {
|
|
2925
3113
|
const currentDocument = site.entries.find((entry) => entry.id === opts.currentId);
|
|
2926
3114
|
const rootPage = site.entries.find((entry) => entry.root);
|
|
@@ -2928,8 +3116,9 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2928
3116
|
const rootCurrent = currentDocument?.root && (!opts.currentRes || opts.currentRes === "/");
|
|
2929
3117
|
const nav = navGroupsHtml(historicalReadOnly || opts.loading ? "preview" : mode, site, opts.currentId, opts.currentRes);
|
|
2930
3118
|
const siteTitle = escapeHtml(site.title ?? "dooc");
|
|
2931
|
-
const
|
|
2932
|
-
|
|
3119
|
+
const rootEdit = mode === "edit" && !historicalReadOnly
|
|
3120
|
+
? `<button type="button" data-root-source aria-haspopup="dialog" aria-label="Edit root page" title="Edit root page" data-i18n-aria-label="Edit root page" data-i18n-title="Edit root page">${icon('<path d="m4 12 8.8-8.8a1.6 1.6 0 0 1 2.3 2.3L6.3 14.3l-3.4.9Z"/><path d="m11.4 4.6 2.3 2.3"/>', 16)}</button>`
|
|
3121
|
+
: "";
|
|
2933
3122
|
const tabIcons = { "": site.icon, ...site.iconVariants };
|
|
2934
3123
|
const favicons = mode === "preview"
|
|
2935
3124
|
? Object.entries(tabIcons)
|
|
@@ -2938,11 +3127,7 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2938
3127
|
: [])
|
|
2939
3128
|
.join("\n")
|
|
2940
3129
|
: "";
|
|
2941
|
-
|
|
2942
|
-
const iconHtml = iconVariants.length
|
|
2943
|
-
? `<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>`
|
|
2944
|
-
: iconImg;
|
|
2945
|
-
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>`;
|
|
3130
|
+
const siteIcon = `<span id="site-icon-slot"${mode === "edit" ? ' title="Change site icon" data-i18n-title="Change site icon"' : ""}>${siteIconImages(site)}${DOCS_ICON}${mode === "edit" ? '<button class="nav-icon-pick" type="button" aria-label="Change site icon" data-i18n-aria-label="Change site icon" aria-haspopup="dialog"></button>' : ""}</span>`;
|
|
2946
3131
|
const output = opts.publish?.output;
|
|
2947
3132
|
const script = (js) => output
|
|
2948
3133
|
? `<script src="${escapeHtml(output.asset(js, "js"))}"></script>`
|
|
@@ -2951,7 +3136,6 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2951
3136
|
const stylesheet = output
|
|
2952
3137
|
? `<link rel="stylesheet" href="${escapeHtml(output.asset(css, "css"))}">`
|
|
2953
3138
|
: `<style>${css}</style>`;
|
|
2954
|
-
const self = output ? "'self' " : "";
|
|
2955
3139
|
const bootScripts = opts.boot != null
|
|
2956
3140
|
? `<script id="boot" type="application/json">${JSON.stringify(opts.boot).replace(/</g, "\\u003c")}</script>
|
|
2957
3141
|
<script src="/assets/edit.js"></script>
|
|
@@ -2969,17 +3153,17 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2969
3153
|
|
|
2970
3154
|
|
|
2971
3155
|
<div id="preview-language-menu" role="menu" aria-label="Change language" data-i18n-aria-label="Change language" hidden></div>
|
|
2972
|
-
<div id="preview-panes"${opts.currentRes !== undefined ? " hidden" : ""}><section class="preview-pane active"
|
|
3156
|
+
<div id="preview-panes"${opts.currentRes !== undefined ? " hidden" : ""}><section class="preview-pane active" 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("reader")}<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>`
|
|
2973
3157
|
: mode === "edit" && opts.currentRes !== undefined
|
|
2974
3158
|
? `<main class="resources-pane">${opts.main}</main>`
|
|
2975
|
-
: `<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>`;
|
|
3159
|
+
: `<main tabindex="-1"><div class="page-actions"><button class="pbtn" type="button" data-theme-picker="document" aria-label="Preview theme"></button>${fontButton("reader")}</div>${opts.main}</main>`;
|
|
2976
3160
|
const graphScript = output?.graph
|
|
2977
3161
|
? `<script type="module" src="${escapeHtml(output.graph)}"></script>`
|
|
2978
3162
|
: opts.publish
|
|
2979
3163
|
? script(opts.publish.graphJs)
|
|
2980
3164
|
: `<script>(${loadPreviewScript.toString()})("/assets/graph.js", "svg[data-sg-layout], [data-mermaid]", "module");</script>`;
|
|
2981
|
-
const frame = `<!doctype html><html lang="en"><head><meta charset="utf-8">
|
|
2982
|
-
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" :
|
|
3165
|
+
const frame = `<!doctype html><html lang="en"${site.accentColor ? ` style="--project-accent:${escapeHtml(site.accentColor)}"` : ""}><head><meta charset="utf-8">
|
|
3166
|
+
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : offlinePolicy(Boolean(output))}` : ""}
|
|
2983
3167
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2984
3168
|
<title>${escapeHtml(pageTitle(mode, opts.title, site))}</title>
|
|
2985
3169
|
${favicons}
|
|
@@ -2987,7 +3171,7 @@ ${script(`var __name = (f) => f;
|
|
|
2987
3171
|
(${initializeThemes.toString()})(${JSON.stringify(site.themes)});
|
|
2988
3172
|
(${mountFigureFrames.toString()})(document);`)}
|
|
2989
3173
|
${stylesheet}</head>
|
|
2990
|
-
<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
|
|
3174
|
+
<body${mode === "edit" ? ` data-draft-project="${escapeHtml(root)}"` : ""} 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>${rootEdit}<button class="nav-tree-toggle" type="button" data-nav-root-toggle aria-controls="nav-docs" aria-expanded="true" aria-label="Toggle ${siteTitle}">${DISCLOSURE_ICON}</button><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 ?? ""}
|
|
2991
3175
|
`;
|
|
2992
3176
|
if (opts.loading)
|
|
2993
3177
|
return `${frame}<script>document.body.dataset.clientLoading = "true";
|
|
@@ -3138,6 +3322,13 @@ ${mode === "edit"
|
|
|
3138
3322
|
const res = await localeFetch("/api/nav?current=" + encodeURIComponent(id) + (rp == null ? "" : "&res=" + encodeURIComponent(rp)));
|
|
3139
3323
|
if (res.ok) {
|
|
3140
3324
|
const data = await res.json();
|
|
3325
|
+
document.documentElement.style.setProperty("--project-accent", data.accentColor || "");
|
|
3326
|
+
const slot = document.getElementById("site-icon-slot");
|
|
3327
|
+
if (slot && data.iconImages && slot.dataset.images !== data.iconImages) {
|
|
3328
|
+
slot.querySelector(".site-icon-variants, #site-icon")?.remove();
|
|
3329
|
+
slot.insertAdjacentHTML("afterbegin",data.iconImages);
|
|
3330
|
+
slot.dataset.images = data.iconImages;
|
|
3331
|
+
}
|
|
3141
3332
|
(${updateNav.toString()})(document.getElementById("nav-groups"), data.html);
|
|
3142
3333
|
const currentPage = document.querySelector('[data-subformat-nav][data-doc-id="' + CSS.escape(id) + '"] > .nav-row > a');
|
|
3143
3334
|
if (currentPage && currentPage.pathname !== location.pathname) {
|
|
@@ -3161,17 +3352,16 @@ ${mode === "edit"
|
|
|
3161
3352
|
return data;
|
|
3162
3353
|
};
|
|
3163
3354
|
|
|
3355
|
+
window.__docsRefreshSidebar = refresh;
|
|
3164
3356
|
const docAction = (item, action) => {
|
|
3165
|
-
if (
|
|
3166
|
-
document.dispatchEvent(new CustomEvent("docs:
|
|
3357
|
+
if (action === "delete") {
|
|
3358
|
+
document.dispatchEvent(new CustomEvent("docs:remove-sidebar-entry", {detail: item}));
|
|
3167
3359
|
return;
|
|
3168
3360
|
}
|
|
3169
|
-
if (window.__docsDocAction) {
|
|
3170
|
-
|
|
3361
|
+
if (item.hasAttribute("data-subformat-nav") || !window.__docsDocAction) {
|
|
3362
|
+
document.dispatchEvent(new CustomEvent("docs:rename-sidebar-entry", { detail: item }));
|
|
3171
3363
|
} else {
|
|
3172
|
-
|
|
3173
|
-
url.searchParams.set("doc-action", action);
|
|
3174
|
-
location.href = url.href;
|
|
3364
|
+
void window.__docsDocAction(item.dataset.docId, action);
|
|
3175
3365
|
}
|
|
3176
3366
|
};
|
|
3177
3367
|
document.addEventListener("click", (event) => {
|
|
@@ -3232,17 +3422,18 @@ ${mode === "edit"
|
|
|
3232
3422
|
try {
|
|
3233
3423
|
const result = await post("/api/site-title", { title: input.value, baseTitle, language: target.language }, target);
|
|
3234
3424
|
if (!current(target)) { close(); return; }
|
|
3425
|
+
const restoreFocus = form.contains(document.activeElement);
|
|
3235
3426
|
closed = true;
|
|
3236
3427
|
form.remove();
|
|
3237
3428
|
label.textContent = label.title = result.title;
|
|
3238
3429
|
label.dataset.title = result.title;
|
|
3239
3430
|
label.setAttribute("href", href);
|
|
3431
|
+
if (restoreFocus) label.focus({preventScroll:true});
|
|
3240
3432
|
await refresh();
|
|
3241
|
-
label.focus();
|
|
3242
3433
|
setStatus("", false);
|
|
3243
3434
|
} catch (error) {
|
|
3244
3435
|
setStatus(error.message, true);
|
|
3245
|
-
input.focus();
|
|
3436
|
+
if (form.contains(document.activeElement)) input.focus();
|
|
3246
3437
|
} finally {
|
|
3247
3438
|
busy = false;
|
|
3248
3439
|
input.readOnly = false;
|
|
@@ -3266,60 +3457,6 @@ ${mode === "edit"
|
|
|
3266
3457
|
};
|
|
3267
3458
|
document.addEventListener("dblclick", editLabel);
|
|
3268
3459
|
document.addEventListener("keydown", (event) => { if (event.key === "F2") editLabel(event); });
|
|
3269
|
-
const setIcon = async (slot, file) => {
|
|
3270
|
-
const target = context();
|
|
3271
|
-
if (file && !/\\.svg$/i.test(file.name) && file.type !== "image/svg+xml") {
|
|
3272
|
-
setStatus("Icon must be svg", true);
|
|
3273
|
-
return;
|
|
3274
|
-
}
|
|
3275
|
-
const id = slot.closest(".nav-item")?.dataset.docId;
|
|
3276
|
-
try {
|
|
3277
|
-
const data = file ? btoa(Array.from(new Uint8Array(await file.arrayBuffer()), (byte) => String.fromCharCode(byte)).join("")) : null;
|
|
3278
|
-
const result = await post(id ? "/api/icon" : "/api/site-icon", { file: id ? id + ".md" : undefined, data, theme: getComputedStyle(document.documentElement).colorScheme === "dark" ? "dark" : "light" }, target);
|
|
3279
|
-
if (!current(target)) return;
|
|
3280
|
-
if (!id) {
|
|
3281
|
-
const logo = document.getElementById("site-icon");
|
|
3282
|
-
logo.src = result.icon;
|
|
3283
|
-
logo.hidden = false;
|
|
3284
|
-
}
|
|
3285
|
-
setStatus("", false);
|
|
3286
|
-
await refresh();
|
|
3287
|
-
} catch (error) {
|
|
3288
|
-
setStatus(error.message, true);
|
|
3289
|
-
}
|
|
3290
|
-
};
|
|
3291
|
-
document.addEventListener("change", (event) => {
|
|
3292
|
-
const input = event.target;
|
|
3293
|
-
if (!(input instanceof HTMLInputElement) || !input.closest(".nav-doc-icon, #site-icon-slot")) return;
|
|
3294
|
-
const file = input.files[0];
|
|
3295
|
-
input.value = "";
|
|
3296
|
-
if (file) void setIcon(input.closest(".nav-doc-icon, #site-icon-slot"), file);
|
|
3297
|
-
});
|
|
3298
|
-
document.addEventListener("click", (event) => {
|
|
3299
|
-
const clear = event.target instanceof Element ? event.target.closest(".nav-icon-clear") : null;
|
|
3300
|
-
if (!clear) return;
|
|
3301
|
-
event.preventDefault();
|
|
3302
|
-
void setIcon(clear.closest(".nav-doc-icon"), null);
|
|
3303
|
-
});
|
|
3304
|
-
document.addEventListener("dragover", (event) => {
|
|
3305
|
-
const slot = event.target instanceof Element ? event.target.closest(".nav-doc-icon, #sidebar-head") : null;
|
|
3306
|
-
if (!slot || !event.dataTransfer?.types.includes("Files")) return;
|
|
3307
|
-
event.preventDefault();
|
|
3308
|
-
slot.classList.add("over");
|
|
3309
|
-
});
|
|
3310
|
-
document.addEventListener("dragleave", (event) => {
|
|
3311
|
-
const slot = event.target instanceof Element ? event.target.closest(".nav-doc-icon, #sidebar-head") : null;
|
|
3312
|
-
if (slot && !slot.contains(event.relatedTarget)) slot.classList.remove("over");
|
|
3313
|
-
});
|
|
3314
|
-
document.addEventListener("drop", (event) => {
|
|
3315
|
-
const slot = event.target instanceof Element ? event.target.closest(".nav-doc-icon, #sidebar-head") : null;
|
|
3316
|
-
const file = event.dataTransfer?.files[0];
|
|
3317
|
-
if (!slot || !file) return;
|
|
3318
|
-
event.preventDefault();
|
|
3319
|
-
slot.classList.remove("over");
|
|
3320
|
-
void setIcon(slot, file);
|
|
3321
|
-
});
|
|
3322
|
-
|
|
3323
3460
|
let dragContext;
|
|
3324
3461
|
let dragged = null;
|
|
3325
3462
|
let drop = null;
|
|
@@ -3439,7 +3576,7 @@ ${mode === "edit"
|
|
|
3439
3576
|
form.innerHTML =
|
|
3440
3577
|
'<p class="nav-new-heading" data-i18n="Markdown page">Markdown page</p>' +
|
|
3441
3578
|
'<input name="title" placeholder="title" data-i18n-placeholder="title" aria-label="title" data-i18n-aria-label="title" required autocomplete="off">' +
|
|
3442
|
-
'<div class="nav-new-file"><input name="name" placeholder="File
|
|
3579
|
+
'<div class="nav-new-file"><input name="name" placeholder="File path" data-i18n-placeholder="File path" aria-label="File path" data-i18n-aria-label="File path" required autocomplete="off" spellcheck="false"></div>' +
|
|
3443
3580
|
'<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>' +
|
|
3444
3581
|
'<div class="err" role="alert"></div>';
|
|
3445
3582
|
row.append(form);
|
|
@@ -3458,7 +3595,11 @@ ${mode === "edit"
|
|
|
3458
3595
|
trigger.focus();
|
|
3459
3596
|
};
|
|
3460
3597
|
form.querySelector(".nav-new-cancel").addEventListener("click", cancel);
|
|
3461
|
-
|
|
3598
|
+
const directory = document.getElementById("nav-tools")?.dataset.uploadDirectory;
|
|
3599
|
+
title.addEventListener("input", () => {
|
|
3600
|
+
const name = suggestFileName(title.value);
|
|
3601
|
+
if (!nameTouched) nameInput.value = name && directory && directory !== "." ? directory + "/" + name : name;
|
|
3602
|
+
});
|
|
3462
3603
|
nameInput.addEventListener("input", () => { nameTouched = true; });
|
|
3463
3604
|
form.addEventListener("keydown", (e) => {
|
|
3464
3605
|
if (e.key === "Escape") { e.preventDefault(); cancel(); }
|
|
@@ -3475,7 +3616,7 @@ ${mode === "edit"
|
|
|
3475
3616
|
submit.setAttribute("aria-busy", "true");
|
|
3476
3617
|
err.textContent = "";
|
|
3477
3618
|
try {
|
|
3478
|
-
await post("/api/create", { parent: parent || undefined, title: title.value.trim(),
|
|
3619
|
+
await post("/api/create", { parent: parent || undefined, title: title.value.trim(), path: nameInput.value.trim() }, target);
|
|
3479
3620
|
if (!current(target)) return;
|
|
3480
3621
|
closeForm();
|
|
3481
3622
|
await refresh();
|
|
@@ -3807,17 +3948,15 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3807
3948
|
// Linked files get their previewer page too.
|
|
3808
3949
|
// shortcut: file names containing HTML-escaped characters (& < > " ') get no page, decode entities if needed
|
|
3809
3950
|
const routes = new Set(pages.map((p) => p.route));
|
|
3810
|
-
for (const
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
pages.push({ route: encoded, ...linked });
|
|
3820
|
-
}
|
|
3951
|
+
for (const page of pages)
|
|
3952
|
+
for (const [, encoded] of page.main.matchAll(/href="\/(_files\/file\/[^"#&]+)/g)) {
|
|
3953
|
+
if (!encoded || routes.has(encoded))
|
|
3954
|
+
continue;
|
|
3955
|
+
routes.add(encoded);
|
|
3956
|
+
const linked = linkedFilePage(site, decodeURIComponent(encoded.slice("_files/file/".length)));
|
|
3957
|
+
if (linked)
|
|
3958
|
+
pages.push({ route: encoded, ...linked });
|
|
3959
|
+
}
|
|
3821
3960
|
const templates = pages
|
|
3822
3961
|
.map((p) => {
|
|
3823
3962
|
const content = toHashLinks(p.main, p.route);
|
|
@@ -3840,8 +3979,6 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3840
3979
|
},
|
|
3841
3980
|
}), first);
|
|
3842
3981
|
};
|
|
3843
|
-
// A doc's main content. A doc with an empty body and children (a chapter-heading-only doc) shows
|
|
3844
|
-
// its children list in place of the body.
|
|
3845
3982
|
const entryMain = (site, e) => {
|
|
3846
3983
|
if (e.url && /^https?:\/\//i.test(e.url)) {
|
|
3847
3984
|
const title = docDisplayName(e.frontmatter, e.id);
|
|
@@ -3852,14 +3989,44 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3852
3989
|
`<article><p role="alert">File not found: ${escapeHtml(e.url)}</p></article>`);
|
|
3853
3990
|
const html = renderEntryHtml(site, e).html;
|
|
3854
3991
|
const kids = childrenOf(site.entries, e.id);
|
|
3855
|
-
if (e.subformat ||
|
|
3992
|
+
if (e.subformat ||
|
|
3993
|
+
e.library ||
|
|
3994
|
+
e.format ||
|
|
3995
|
+
(e.url && tocReference(e.url)) ||
|
|
3996
|
+
e.blocks.length ||
|
|
3997
|
+
(e.root && isContentPage(e)) ||
|
|
3998
|
+
(!e.root && !kids.length)) {
|
|
3856
3999
|
return html;
|
|
3857
4000
|
}
|
|
3858
|
-
|
|
3859
|
-
.map((k) => `<li><a href="/${k.id}">${entryIcon(k, "doc-icon")}<span class="document-card-label">${escapeHtml(docDisplayName(k.frontmatter, k.id))}</span></a></li>`)
|
|
3860
|
-
.join("");
|
|
3861
|
-
return docLinks(site, html.replace(/<\/article>\s*$/, `<ul class="idx">${items}</ul></article>`));
|
|
4001
|
+
return html.replace(/<\/article>\s*$/, () => `${contentsTree(site, e, true)}</article>`);
|
|
3862
4002
|
};
|
|
4003
|
+
function contentsTree(site, parent, recursive) {
|
|
4004
|
+
const children = new Map();
|
|
4005
|
+
for (const entry of site.entries) {
|
|
4006
|
+
const group = children.get(entry.parent) ?? [];
|
|
4007
|
+
group.push(entry);
|
|
4008
|
+
children.set(entry.parent, group);
|
|
4009
|
+
}
|
|
4010
|
+
const items = (id) => (children.get(id) ?? [])
|
|
4011
|
+
.map((entry) => {
|
|
4012
|
+
const nested = recursive && children.has(entry.id) ? `<ul>${items(entry.id)}</ul>` : "";
|
|
4013
|
+
return `<li data-toc-page="${escapeHtml(entry.id)}"><a href="/${escapeHtml(entry.id)}">${entryIcon(entry, "doc-icon")}<span class="document-card-label">${escapeHtml(docDisplayName(entry.frontmatter, entry.id))}</span></a>${nested}</li>`;
|
|
4014
|
+
})
|
|
4015
|
+
.join("");
|
|
4016
|
+
return children.has(parent.id)
|
|
4017
|
+
? docLinks(site, `<ul class="idx" data-library="toc">${items(parent.id)}</ul>`)
|
|
4018
|
+
: '<p data-library="toc" data-i18n="No child pages">No child pages</p>';
|
|
4019
|
+
}
|
|
4020
|
+
function contentsLibrary(site, file, recursive, title) {
|
|
4021
|
+
const entry = file === manifestFile(site.root ?? root)
|
|
4022
|
+
? site.entries.find((page) => page.root)
|
|
4023
|
+
: site.entries.find((page) => (page.included && page.origin === file) ||
|
|
4024
|
+
(isContentPage(page) && page.sourceFile === file));
|
|
4025
|
+
const listing = entry
|
|
4026
|
+
? contentsTree(site, entry, recursive)
|
|
4027
|
+
: `<p role="alert">Table of contents source is not in this document: ${escapeHtml(file)}</p>`;
|
|
4028
|
+
return title ? `<section><h2>${escapeHtml(title)}</h2>${listing}</section>` : listing;
|
|
4029
|
+
}
|
|
3863
4030
|
const languageFieldHtml = (defaultLang, language = contentLanguageCode(defaultLang), translatedLanguages = [contentLanguageCode(defaultLang)], declaredLanguages) => {
|
|
3864
4031
|
const existing = new Set(translatedLanguages);
|
|
3865
4032
|
const options = [...contentLanguages]
|
|
@@ -3952,6 +4119,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3952
4119
|
</div><div id="editor-header-workspace"></div><div id="editor-header-actions">
|
|
3953
4120
|
<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>
|
|
3954
4121
|
<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>
|
|
4122
|
+
<button id="editor-llm" class="pbtn" type="button" aria-controls="llm-chat" aria-label="Open chat" data-i18n-aria-label="Open chat" title="Open chat" data-i18n-title="Open chat">${LLM_ICON}</button>
|
|
3955
4123
|
<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>
|
|
3956
4124
|
<div id="gear"><button class="pbtn" type="button" aria-expanded="false" aria-controls="gearmenu" aria-label="View settings" data-i18n-aria-label="View settings" title="View settings" data-i18n-title="View settings">${GEAR_ICON}</button><div id="gearmenu">
|
|
3957
4125
|
<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>
|
|
@@ -4227,13 +4395,14 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4227
4395
|
? ops.addLibrary(body.library, title, parent)
|
|
4228
4396
|
: typeof body?.subformat === "string"
|
|
4229
4397
|
? ops.addSubformat(body.subformat, title, parent)
|
|
4230
|
-
:
|
|
4398
|
+
: typeof body?.path === "string"
|
|
4399
|
+
? ops.addFile(body.path, title, parent, body.reference === true ? "reference" : "path")
|
|
4400
|
+
: ops.addFile(name, title, parent);
|
|
4231
4401
|
sendOp(res, isOpError(result)
|
|
4232
4402
|
? result
|
|
4233
4403
|
: { ...result, path: docPath(loadSite().entries, result.id) });
|
|
4234
4404
|
};
|
|
4235
|
-
//
|
|
4236
|
-
// (the client inserts ).
|
|
4405
|
+
// Compatibility endpoint for clients that upload figure bytes.
|
|
4237
4406
|
const handleFigure = async (req, res) => {
|
|
4238
4407
|
const body = await readJson(req);
|
|
4239
4408
|
if (typeof body?.name !== "string" || typeof body?.data !== "string") {
|
|
@@ -4245,8 +4414,6 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4245
4414
|
? result
|
|
4246
4415
|
: { ...result, path: result.path ?? `figures/${result.file}` });
|
|
4247
4416
|
};
|
|
4248
|
-
// Doc icon (the header's icon slot). data = base64 of an svg (null = remove). Pads it to 1:1 and
|
|
4249
|
-
// writes icons/<id>.svg. Response icon = the new data URI (null if removed).
|
|
4250
4417
|
const handleIcon = async (req, res) => {
|
|
4251
4418
|
const body = await readJson(req);
|
|
4252
4419
|
const manifest = readManifest(root);
|
|
@@ -4267,6 +4434,22 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4267
4434
|
sendJson(res, 403, { error: "Remote document sources are read-only" });
|
|
4268
4435
|
return;
|
|
4269
4436
|
}
|
|
4437
|
+
if (body?.path !== undefined) {
|
|
4438
|
+
try {
|
|
4439
|
+
const svg = projectIcon(root, body.path);
|
|
4440
|
+
manifest.files ??= parseFileLayout({});
|
|
4441
|
+
manifest.files.icons ??= {};
|
|
4442
|
+
manifest.files.icons[id] = body.path;
|
|
4443
|
+
writeManifest(root, manifest.tree, manifest);
|
|
4444
|
+
sendJson(res, 200, { ok: true, icon: svgDataUri(svg) });
|
|
4445
|
+
}
|
|
4446
|
+
catch (error) {
|
|
4447
|
+
sendJson(res, 400, {
|
|
4448
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4449
|
+
});
|
|
4450
|
+
}
|
|
4451
|
+
return;
|
|
4452
|
+
}
|
|
4270
4453
|
let file = manifest.format === undefined &&
|
|
4271
4454
|
manifest.files?.defaultLayout !== false &&
|
|
4272
4455
|
!Object.hasOwn(manifest.files?.icons ?? {}, id) &&
|
|
@@ -4344,37 +4527,82 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4344
4527
|
const file = sourceDocFile(target.id, snapshot.layout);
|
|
4345
4528
|
if (body?.sourceFile !== file)
|
|
4346
4529
|
throw new Error("Files changed. Reload before retrying.");
|
|
4347
|
-
|
|
4530
|
+
updateFiles(root, {
|
|
4348
4531
|
action: "rename",
|
|
4349
4532
|
file,
|
|
4350
4533
|
name: typeof body?.name === "string" ? body.name.trim() : "",
|
|
4351
4534
|
revision: snapshot.revision,
|
|
4352
4535
|
});
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4536
|
+
const next = file.slice(0, file.lastIndexOf("/") + 1) + String(body?.name).trim();
|
|
4537
|
+
const manifest = readManifest(root);
|
|
4538
|
+
const entries = flattenTree(manifest.tree);
|
|
4539
|
+
const renamed = entries.find((entry) => isContentPage(entry) && sourceDocFile(entry.id, manifest.files) === next);
|
|
4540
|
+
if (!renamed)
|
|
4541
|
+
throw new Error("Renamed page not found");
|
|
4542
|
+
sendOp(res, { id: renamed.id, path: docPath(entries, renamed.id), sourceFile: next });
|
|
4357
4543
|
}
|
|
4358
4544
|
catch (error) {
|
|
4359
4545
|
sendJson(res, 409, { error: error instanceof Error ? error.message : String(error) });
|
|
4360
4546
|
}
|
|
4361
4547
|
};
|
|
4362
|
-
// Delete a doc. If it's referenced, refuse without force and return the referrers (the client
|
|
4363
|
-
// confirms and resends with force). Response parent = where to navigate after deletion.
|
|
4364
4548
|
const handleDelete = async (req, res) => {
|
|
4365
4549
|
const body = await readJson(req);
|
|
4550
|
+
if (typeof body?.id === "string") {
|
|
4551
|
+
if (body.preview === true &&
|
|
4552
|
+
body.selected === undefined &&
|
|
4553
|
+
body.children === undefined) {
|
|
4554
|
+
sendOp(res, previewSidebarRemoval(root, body.id));
|
|
4555
|
+
return;
|
|
4556
|
+
}
|
|
4557
|
+
if ((body.selected === undefined
|
|
4558
|
+
? body.children !== "remove" && body.children !== "promote"
|
|
4559
|
+
: !Array.isArray(body.selected) ||
|
|
4560
|
+
!body.selected.every((id) => typeof id === "string")) ||
|
|
4561
|
+
(body.files !== "keep" &&
|
|
4562
|
+
body.files !== "delete" &&
|
|
4563
|
+
(!Array.isArray(body.files) ||
|
|
4564
|
+
!body.files.every((path) => typeof path === "string"))) ||
|
|
4565
|
+
(body.confirmation !== undefined && typeof body.confirmation !== "string") ||
|
|
4566
|
+
(body.preview !== undefined && typeof body.preview !== "boolean") ||
|
|
4567
|
+
typeof body.revision !== "string") {
|
|
4568
|
+
sendJson(res, 400, { error: "Review the sidebar and choose what to remove" });
|
|
4569
|
+
return;
|
|
4570
|
+
}
|
|
4571
|
+
const options = {
|
|
4572
|
+
children: body.children === "remove" || body.children === "promote"
|
|
4573
|
+
? body.children
|
|
4574
|
+
: undefined,
|
|
4575
|
+
selected: body.selected,
|
|
4576
|
+
files: body.files,
|
|
4577
|
+
revision: body.revision,
|
|
4578
|
+
confirmation: body.confirmation,
|
|
4579
|
+
force: body.force === true,
|
|
4580
|
+
};
|
|
4581
|
+
try {
|
|
4582
|
+
const changed = options.files === "delete" ||
|
|
4583
|
+
(Array.isArray(options.files) && options.files.length)
|
|
4584
|
+
? await host.changedTrackedFiles(root)
|
|
4585
|
+
: new Set();
|
|
4586
|
+
const operation = body.preview === true ? reviewSidebarRemoval : removeSidebarEntry;
|
|
4587
|
+
sendOp(res, operation(root, body.id, options, changed));
|
|
4588
|
+
}
|
|
4589
|
+
catch {
|
|
4590
|
+
sendJson(res, 409, {
|
|
4591
|
+
error: "Could not check Git changes. Review the deletion again.",
|
|
4592
|
+
});
|
|
4593
|
+
}
|
|
4594
|
+
return;
|
|
4595
|
+
}
|
|
4596
|
+
if (body?.preview !== undefined || body?.confirmation !== undefined) {
|
|
4597
|
+
sendJson(res, 400, { error: "Use the sidebar entry ID to review or confirm deletion" });
|
|
4598
|
+
return;
|
|
4599
|
+
}
|
|
4366
4600
|
const target = resolveContentFile(body?.file);
|
|
4367
4601
|
if (!target) {
|
|
4368
4602
|
sendJson(res, 404, { error: "target doc not found" });
|
|
4369
4603
|
return;
|
|
4370
4604
|
}
|
|
4371
|
-
|
|
4372
|
-
sendOp(res, isOpError(result)
|
|
4373
|
-
? result
|
|
4374
|
-
: {
|
|
4375
|
-
...result,
|
|
4376
|
-
path: result.parent ? docPath(loadSite().entries, result.parent) : "/",
|
|
4377
|
-
});
|
|
4605
|
+
sendOp(res, removeSidebarEntry(root, target.id, { files: "delete", force: body?.force === true }));
|
|
4378
4606
|
};
|
|
4379
4607
|
const handle = async (mode, req, res) => {
|
|
4380
4608
|
const requestUrl = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -4421,11 +4649,39 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4421
4649
|
}
|
|
4422
4650
|
if (mode === "edit" && req.method === "GET" && path === "/api/download") {
|
|
4423
4651
|
try {
|
|
4424
|
-
const
|
|
4425
|
-
|
|
4652
|
+
const route = requestUrl.searchParams.get("page");
|
|
4653
|
+
let filename;
|
|
4654
|
+
let data;
|
|
4655
|
+
let contentType = "application/octet-stream";
|
|
4656
|
+
if (route !== null) {
|
|
4657
|
+
const format = requestUrl.searchParams.get("format");
|
|
4658
|
+
if (format !== "html" && format !== "md") {
|
|
4659
|
+
sendJson(res, 400, { error: "Expected HTML or Markdown download format" });
|
|
4660
|
+
return;
|
|
4661
|
+
}
|
|
4662
|
+
const site = loadSite(locale, route);
|
|
4663
|
+
const id = resolveDocPath(site.entries, route);
|
|
4664
|
+
const entry = site.entries.find((page) => page.id === id && isContentPage(page));
|
|
4665
|
+
const file = entry && (entry.sourceFile ?? CONTENT_PREFIX + entry.file);
|
|
4666
|
+
if (!entry || !file || !site.ctx.downloads?.has(file)) {
|
|
4667
|
+
notFound(res, route);
|
|
4668
|
+
return;
|
|
4669
|
+
}
|
|
4670
|
+
filename = format === "html" ? pageHtmlFilename(file) : textfileName(file);
|
|
4671
|
+
data = format === "html" ? standalonePageHtml(site, entry) : entry.raw;
|
|
4672
|
+
contentType =
|
|
4673
|
+
format === "html"
|
|
4674
|
+
? "text/html; charset=utf-8"
|
|
4675
|
+
: "text/markdown; charset=utf-8";
|
|
4676
|
+
}
|
|
4677
|
+
else {
|
|
4678
|
+
const file = requestUrl.searchParams.get("file") ?? "";
|
|
4679
|
+
filename = textfileName(file);
|
|
4680
|
+
data = readDownloadFile(root, file);
|
|
4681
|
+
}
|
|
4426
4682
|
res.writeHead(200, {
|
|
4427
|
-
"content-type":
|
|
4428
|
-
"content-disposition": `attachment; filename*=UTF-8''${encodeURIComponent(
|
|
4683
|
+
"content-type": contentType,
|
|
4684
|
+
"content-disposition": `attachment; filename*=UTF-8''${encodeURIComponent(filename)}`,
|
|
4429
4685
|
"cache-control": "no-store",
|
|
4430
4686
|
"x-content-type-options": "nosniff",
|
|
4431
4687
|
});
|
|
@@ -4480,7 +4736,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4480
4736
|
const grammar = siteLanguages.codeGrammars?.find((entry) => entry.name === extension || entry.aliases?.includes(extension));
|
|
4481
4737
|
const language = existsSync(join(root, ".dooc/editor-tools", `${extension}.json`))
|
|
4482
4738
|
? extension
|
|
4483
|
-
: (readManifest(root).
|
|
4739
|
+
: (recordSubformat(root, readManifest(root), input.file, applicationPreviews.domains)?.format ??
|
|
4484
4740
|
grammar?.name ??
|
|
4485
4741
|
extension);
|
|
4486
4742
|
const result = await validateTextfileCode(root, language, input.content);
|
|
@@ -4568,6 +4824,30 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4568
4824
|
await handleCreate(req, res);
|
|
4569
4825
|
return;
|
|
4570
4826
|
}
|
|
4827
|
+
if (path === "/api/root-source") {
|
|
4828
|
+
const body = await readJson(req);
|
|
4829
|
+
if (body?.action !== "read" && body?.action !== "save") {
|
|
4830
|
+
sendJson(res, 400, { error: "Unknown root page action" });
|
|
4831
|
+
return;
|
|
4832
|
+
}
|
|
4833
|
+
sendOp(res, rootPageSource(root, body.action === "save" ? body : undefined));
|
|
4834
|
+
return;
|
|
4835
|
+
}
|
|
4836
|
+
if (path === "/api/sidebar-title") {
|
|
4837
|
+
const body = await readJson(req);
|
|
4838
|
+
const entry = loadNavigation(locale, null).entries.find((entry) => entry.id === body?.id);
|
|
4839
|
+
if (!entry || entry.origin) {
|
|
4840
|
+
sendJson(res, 404, { error: "Sidebar entry not found" });
|
|
4841
|
+
return;
|
|
4842
|
+
}
|
|
4843
|
+
if (typeof body?.title !== "string" ||
|
|
4844
|
+
body.baseTitle !== docDisplayName(entry.frontmatter, entry.id)) {
|
|
4845
|
+
sendJson(res, 409, { error: "The title changed. Review it before renaming." });
|
|
4846
|
+
return;
|
|
4847
|
+
}
|
|
4848
|
+
sendOp(res, ops.setTitle(entry.id, body.title));
|
|
4849
|
+
return;
|
|
4850
|
+
}
|
|
4571
4851
|
if (path === "/api/subformat-page") {
|
|
4572
4852
|
const body = await readJson(req);
|
|
4573
4853
|
const id = typeof body?.id === "string" ? body.id : "";
|
|
@@ -4591,7 +4871,13 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4591
4871
|
const result = path === "/api/site-title"
|
|
4592
4872
|
? siteTitleResponse(root, input)
|
|
4593
4873
|
: siteIconResponse(root, input);
|
|
4594
|
-
|
|
4874
|
+
if (path === "/api/site-icon" && input?.path && result.status === 200)
|
|
4875
|
+
sendJson(res, 200, {
|
|
4876
|
+
...result.body,
|
|
4877
|
+
images: siteIconImages(loadSite(locale)),
|
|
4878
|
+
});
|
|
4879
|
+
else
|
|
4880
|
+
sendJson(res, result.status, result.body);
|
|
4595
4881
|
return;
|
|
4596
4882
|
}
|
|
4597
4883
|
if (path === "/api/figure") {
|
|
@@ -4630,6 +4916,8 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4630
4916
|
const currentId = params.get("current") || resolveDocPath(site.entries, params.get("route") ?? "/");
|
|
4631
4917
|
sendJson(res, 200, {
|
|
4632
4918
|
siteTitle: site.title,
|
|
4919
|
+
accentColor: site.accentColor,
|
|
4920
|
+
iconImages: siteIconImages(site),
|
|
4633
4921
|
siteIcon: site.icon ? svgDataUri(site.icon) : undefined,
|
|
4634
4922
|
themes: site.themes,
|
|
4635
4923
|
rootJump: docHref(site.entries, site.entries.find((entry) => entry.root)?.id ?? ""),
|