@dooc-dev/dooc 0.0.28 → 0.0.29
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 +1 -0
- package/dist/engine/core/html.js +8 -4
- 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 +378 -172
- 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 +62 -1
- package/dist/frontend/locales/jpn.json +62 -1
- package/dist/frontend/locales/zho.json +62 -1
- package/dist/frontend/page-jump.js +17 -10
- package/dist/frontend/resize.js +38 -12
- 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/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 +238 -196
- 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";
|
|
@@ -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,
|
|
@@ -374,6 +379,7 @@ export const createDocumentApplication = (root, host) => {
|
|
|
374
379
|
};
|
|
375
380
|
const renderEntry = (site, entry, fallbackTitle) => docLinks(site, docHtml(entry.frontmatter ?? { title: fallbackTitle }, entry.blocks, [...site.errors, ...entry.errors], {
|
|
376
381
|
...site.ctx,
|
|
382
|
+
pageContents: (file, recursive, title) => contentsLibrary(site, file, recursive, title),
|
|
377
383
|
...pageDownload(site, entry),
|
|
378
384
|
terms: entry.terms ?? site.ctx.terms,
|
|
379
385
|
lang: webLanguage(entry.lang),
|
|
@@ -444,12 +450,27 @@ export const createDocumentApplication = (root, host) => {
|
|
|
444
450
|
// changed. Rebuild if any of them did.
|
|
445
451
|
const renderSignature = (site, entry) => JSON.stringify([site.ctx.terms, site.errors, entry.errors, entry.frontmatter, entry.lang]) +
|
|
446
452
|
site.entries
|
|
447
|
-
.map((e) => [
|
|
448
|
-
.
|
|
453
|
+
.map((e) => [
|
|
454
|
+
e.sourceFile ?? CONTENT_PREFIX + e.file,
|
|
455
|
+
docPath(site.entries, e.id),
|
|
456
|
+
e.frontmatter?.title,
|
|
457
|
+
e.url,
|
|
458
|
+
e.icon,
|
|
459
|
+
])
|
|
449
460
|
.join("\n");
|
|
450
461
|
const entryHtmlCache = new Map();
|
|
451
462
|
/** Renders only the requested doc, not every doc in site.entries. */
|
|
452
463
|
const renderEntryHtml = (site, entry) => {
|
|
464
|
+
const contents = entry.url && tocReference(entry.url);
|
|
465
|
+
if (entry.library === "toc" || contents) {
|
|
466
|
+
const file = contents
|
|
467
|
+
? contents.file
|
|
468
|
+
: (entry.origin ?? manifestFile(site.root ?? root));
|
|
469
|
+
return {
|
|
470
|
+
html: `<article class="resource-library">${contentsLibrary(site, file, contents ? contents.recursive : true, docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
471
|
+
errors: [...site.errors, ...entry.errors],
|
|
472
|
+
};
|
|
473
|
+
}
|
|
453
474
|
if (entry.format)
|
|
454
475
|
return {
|
|
455
476
|
html: `<article class="res-page resource-library">${renderFormatCollection(site, entry.format, "", docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
@@ -793,6 +814,12 @@ body.sidebar-closed #sidebar-toggle svg { visibility: hidden; }
|
|
|
793
814
|
padding: 10px 0 8px; }
|
|
794
815
|
#nav-groups { flex: 1; min-height: 0; display: flex; flex-direction: column; }
|
|
795
816
|
#nav-groups > .nav-root { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
|
|
817
|
+
#nav-groups:has(> #nav-docs[hidden])::before { content: ""; flex: 1; }
|
|
818
|
+
body.sidebar-closed [data-root-source], body[data-version-read-only=true] [data-root-source] { display: none; }
|
|
819
|
+
.root-source-fields { display: grid; gap: 12px; }
|
|
820
|
+
.root-source-fields label { display: grid; gap: 4px; }
|
|
821
|
+
.root-source-fields .root-source-depth { display: flex; align-items: center; gap: 8px; }
|
|
822
|
+
.root-source-fields [hidden] { display: none; }
|
|
796
823
|
.language-select, .language-picker { font: 13px/18px var(--font-sans); font-weight: var(--fw-body); }
|
|
797
824
|
.language-select { position: relative; }
|
|
798
825
|
.language-select-input { width: 100%; min-width: 0; height: 28px; padding: 4px 26px 4px 8px;
|
|
@@ -837,7 +864,7 @@ body.sidebar-closed #document-versions { padding: 8px 4px 12px; }
|
|
|
837
864
|
body.sidebar-closed #document-versions :is(.subformat-control-label, .version-select > .version-status) { display: none; }
|
|
838
865
|
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
866
|
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
|
|
867
|
+
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
868
|
.nav-link { position: relative; display: flex; align-items: center; gap: 14px; padding: 10px 16px;
|
|
842
869
|
color: var(--c-fg-muted); text-decoration: none; background: transparent; border: none;
|
|
843
870
|
font: inherit; text-align: left; cursor: pointer; min-width: 0; }
|
|
@@ -879,10 +906,10 @@ body[data-version-read-only="true"] :is(.nav-doc-actions, .nav-icon-clear, #site
|
|
|
879
906
|
.nav-list > .nav-item.open { grid-template-rows: auto 1fr; }
|
|
880
907
|
.nav-item > .nav-list { min-height: 0; overflow: hidden; visibility: hidden; transition: visibility 0s 260ms; }
|
|
881
908
|
.nav-item.open > .nav-list { visibility: visible; transition-delay: 0s; }
|
|
882
|
-
.nav-tree-toggle { flex: none; display: flex; align-items: center; justify-content: center;
|
|
909
|
+
.nav-tree-toggle, [data-root-source] { flex: none; display: flex; align-items: center; justify-content: center;
|
|
883
910
|
width: 28px; height: 28px; margin-right: 6px; padding: 0; background: transparent; border: none;
|
|
884
911
|
border-radius: 4px; color: var(--c-fg-faint); cursor: pointer; }
|
|
885
|
-
.nav-tree-toggle:hover { color: var(--c-fg); }
|
|
912
|
+
.nav-tree-toggle:hover, [data-root-source]:hover { color: var(--c-fg); }
|
|
886
913
|
.nav-tree-toggle svg { transition: transform var(--nav-motion); }
|
|
887
914
|
.nav-tree-toggle[aria-expanded="true"]:not([data-expansion="all"]) svg { transform: rotate(90deg); }
|
|
888
915
|
.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 +994,8 @@ body.sidebar-closed #nav-groups .nav-doc-icon { z-index: 1; pointer-events: none
|
|
|
967
994
|
.workspace-location::-webkit-details-marker { display: none; }
|
|
968
995
|
.workspace-location:hover { color: var(--c-fg); }
|
|
969
996
|
.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); }
|
|
997
|
+
.workspace-location > .nav-icon:nth-last-child(2) { margin-left: auto; }
|
|
998
|
+
#nav-tools[open] > .workspace-location > .nav-icon:nth-last-child(2) { transform: rotate(90deg); }
|
|
972
999
|
.workspace-address { min-width: 0; padding: 0 2px; background: var(--c-bg1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
973
1000
|
body.sidebar-closed #nav-tools { margin-left: 4px; margin-right: 4px; padding-left: 0; padding-right: 0; }
|
|
974
1001
|
body.sidebar-closed .workspace-location { left: 2px; right: 2px; min-height: 16px; }
|
|
@@ -984,16 +1011,21 @@ body.sidebar-closed .workspace-address { display: none; }
|
|
|
984
1011
|
.files-upload-status:empty { display: none; }
|
|
985
1012
|
.files-upload-status[data-state="error"] { color: var(--c-danger); }
|
|
986
1013
|
.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-
|
|
1014
|
+
.files-drop-hint, .extensions-drop-hint { display: none; }
|
|
1015
|
+
body.files-dragging #nav-tools { min-height: 104px; border: 1px dashed var(--c-accent); border-radius: 8px; background: var(--c-bg1); }
|
|
1016
|
+
body.files-dragging #nav-tools .workspace-location { inset: 0; transform: none; justify-content: center; pointer-events: none; }
|
|
1017
|
+
body.files-dragging #nav-tools .workspace-location > :not(.files-drop-hint) { display: none; }
|
|
1018
|
+
body.files-dragging .nav-tool-cards > * { visibility: hidden; }
|
|
1019
|
+
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; }
|
|
1020
|
+
.files-drop-hint svg { width: 27px; height: 27px; color: var(--c-accent); }
|
|
1021
|
+
.files-drop-hint > span { color: var(--c-fg-muted); }
|
|
1022
|
+
body.files-plugin-drag #nav-extensions { z-index: 4; visibility: visible; }
|
|
1023
|
+
body.files-plugin-drag #nav-extensions .nav-item { visibility: hidden; }
|
|
1024
|
+
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; }
|
|
1025
|
+
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)); }
|
|
1026
|
+
:is(.nav-doc-icon, #site-icon-slot, .nav-placeholder, #files-manager).file-drop-over { outline: 2px solid var(--c-accent); outline-offset: -2px; }
|
|
1027
|
+
body.sidebar-closed.files-dragging #nav-groups .files-drop-hint { display: flex; }
|
|
1028
|
+
body.sidebar-closed .files-drop-hint > :not(svg) { display: none; }
|
|
997
1029
|
#nav-status { min-height: 16px; margin: 6px 16px 0; color: var(--c-fg-faint); font-size: 11px;
|
|
998
1030
|
line-height: 1.35; }
|
|
999
1031
|
#nav-status.err { color: var(--c-danger); }
|
|
@@ -1274,6 +1306,7 @@ article blockquote > :first-child { margin-top: 0; }
|
|
|
1274
1306
|
article blockquote > :last-child { margin-bottom: 0; }
|
|
1275
1307
|
ul.idx { list-style: none; padding: 0; }
|
|
1276
1308
|
ul.idx li { margin: 10px 0; }
|
|
1309
|
+
ul.idx ul { list-style: none; padding-inline-start: 16px; margin-inline-start: 20px; border-inline-start: 1px solid var(--doc-border); }
|
|
1277
1310
|
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
1311
|
ul.idx a:hover { background: var(--doc-panel-2); }
|
|
1279
1312
|
ul.idx a > .nav-icon { width: 18px; height: 18px; }
|
|
@@ -1396,6 +1429,13 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1396
1429
|
.manifest-completions button { border: 0; border-radius: 0; background: transparent; }
|
|
1397
1430
|
.resources-pane .manifest-tabs { margin: 0 0 4px; padding: 0; }
|
|
1398
1431
|
.manifest-tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 8px 14px; background: transparent; color: var(--c-fg-muted); }
|
|
1432
|
+
.manifest-icon-field, .manifest-color-field { display:flex; align-items:end; gap:6px; }
|
|
1433
|
+
.manifest-icon-field .manifest-field, .manifest-color-field .manifest-field { flex:1; min-width:0; }
|
|
1434
|
+
.manifest-icon-field button, .manifest-color-field input[type="color"] { width:32px; height:32px; flex:none; padding:4px; cursor:pointer; }
|
|
1435
|
+
.cm-accent-picker { width: 24px; height: 20px; padding: 0 2px; margin-inline-start: 4px; border: 0; background: transparent; vertical-align: middle; cursor: pointer; }
|
|
1436
|
+
.manifest-icon-field button { display:grid; place-items:center; }
|
|
1437
|
+
.manifest-icon-field img { width:18px; height:18px; object-fit:contain; }
|
|
1438
|
+
.manifest-icon-field img:not([src]), .manifest-icon-field button:has(img[src]) svg { display:none; }
|
|
1399
1439
|
.manifest-tabs button[aria-selected="true"] { color: var(--c-accent); border-bottom-color: currentColor; }
|
|
1400
1440
|
.manifest-fields { min-width: 0; margin: 0; padding: 12px 0; border: 0; }
|
|
1401
1441
|
.manifest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; min-width: 0; }
|
|
@@ -1609,6 +1649,7 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1609
1649
|
.format-navigation code { color: var(--doc-fg-3); overflow-wrap: anywhere; }
|
|
1610
1650
|
.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
1651
|
.format-navigation select { max-width: min(240px, 65vw); }
|
|
1652
|
+
.toc-library-options > code { flex-basis: 100%; user-select: all; }
|
|
1612
1653
|
.format-collection .subformat-embed-toolbar { align-items: center; gap: 8px; }
|
|
1613
1654
|
.format-collection .format-folder { display: block; flex: 1 1 120px; max-width: 240px; margin: 0; order: 1; }
|
|
1614
1655
|
.format-folder select { width: 100%; max-width: none; }
|
|
@@ -1628,7 +1669,8 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1628
1669
|
.format-grid-boxes { display: block; width: 100%; height: 100%; stroke: currentColor; stroke-width: 1; fill: color-mix(in srgb, currentColor 8%, transparent); }
|
|
1629
1670
|
.format-grid-boxes > * { vector-effect: non-scaling-stroke; }
|
|
1630
1671
|
.format-grid-ellipsis { fill: none; stroke-width: 1.5; stroke-linecap: round; }
|
|
1631
|
-
.format-grid-grip {
|
|
1672
|
+
.format-grid-grip { fill: none; stroke: currentColor; stroke-linecap: round; }
|
|
1673
|
+
.format-column-count { display: inline-flex; align-items: center; gap: 6px; }
|
|
1632
1674
|
.format-display-settings { order: 5; font: 12px/1.6 var(--font-sans); }
|
|
1633
1675
|
.format-display-settings > button { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; }
|
|
1634
1676
|
.format-display-fields { width: min(300px, calc(100vw - 16px)); padding: 16px 12px; }
|
|
@@ -1649,6 +1691,10 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1649
1691
|
.format-gallery > button:enabled:hover { background: var(--c-raised); }
|
|
1650
1692
|
.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
1693
|
.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; }
|
|
1694
|
+
.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; }
|
|
1695
|
+
.format-collection [data-subformat-board][data-subformat-view="expand"] { max-height: none; overflow: visible; }
|
|
1696
|
+
.format-collection [data-subformat-view="expand"] .format-card > .format-preview:has(.fig) { container-type: normal; min-height: 0; max-height: none; }
|
|
1697
|
+
.format-collection [data-subformat-view="expand"] .format-preview .fig > img:not(.resource-modal *) { width: 100%; height: auto; max-height: none; }
|
|
1652
1698
|
.format-collection .format-card { display: flex; flex-direction: column; padding: 0; border-radius: 8px; overflow: hidden; }
|
|
1653
1699
|
.format-card-header { display: flex; align-items: center; gap: 8px; padding: 3px 8px; min-height: 32px; border-bottom: 1px solid var(--c-line); }
|
|
1654
1700
|
.format-card-header > h3 { flex: 1; min-width: 0; margin: 0; font: 500 13px/1.4 var(--font-sans); }
|
|
@@ -1776,7 +1822,60 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1776
1822
|
.app-dialog button { padding: 7px 14px; color: inherit; background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 5px; cursor: pointer; }
|
|
1777
1823
|
.app-dialog button:hover { background: var(--c-raised); border-color: var(--c-fg-muted); }
|
|
1778
1824
|
.app-dialog button:focus-visible { outline-color: var(--c-fg-muted); }
|
|
1825
|
+
.sidebar-removal, .removal-summary { margin-bottom: 18px; min-width: 0; }
|
|
1826
|
+
.sidebar-removal [hidden] { display: none; }
|
|
1827
|
+
.removal-scroll, .removal-summary { max-height: min(58dvh, 440px); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
|
|
1828
|
+
.removal-tree, .removal-tree ul { list-style: none; margin: 0; padding: 0; }
|
|
1829
|
+
.removal-tree .nav-tree { --nav-pad: min(calc(4px + var(--removal-depth) * 23px), 40%); --nav-line: calc(var(--nav-pad) - 16px); }
|
|
1830
|
+
.removal-tree .nav-tree > .nav-item > .nav-row::before { width: 11px; }
|
|
1831
|
+
.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); }
|
|
1832
|
+
.removal-row > label { display: flex; align-items: center; gap: 8px; min-height: 30px; min-width: 0; cursor: pointer; }
|
|
1833
|
+
.removal-row label span { overflow-wrap: anywhere; }
|
|
1834
|
+
.removal-row:focus-within, .removal-row:hover { background: var(--c-raised); }
|
|
1835
|
+
.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; }
|
|
1836
|
+
.removal-modes { flex: none; display: inline-flex; overflow: hidden; border: 1px solid var(--c-line); border-radius: 5px; }
|
|
1837
|
+
.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); }
|
|
1838
|
+
.removal-modes button + button { border-inline-start: 1px solid var(--c-line); }
|
|
1839
|
+
.removal-modes button[aria-pressed=true] { color: var(--c-fg); background: var(--c-line); }
|
|
1840
|
+
.removal-modes button:disabled { opacity: .4; cursor: default; }
|
|
1841
|
+
.removal-modes button:focus-visible { outline-offset: -3px; }
|
|
1842
|
+
.removal-sources { margin-inline-start: calc(var(--nav-pad, 4px) + 23px); font-size: 12px; }
|
|
1843
|
+
.removal-sources label { display: flex; align-items: center; gap: 8px; min-height: 30px; overflow-wrap: anywhere; }
|
|
1844
|
+
.removal-summary > * + * { border-top: 1px solid var(--c-line); }
|
|
1845
|
+
.removal-stat { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 38px; padding: 4px; }
|
|
1846
|
+
.removal-stat::before { content: ""; }
|
|
1847
|
+
summary.removal-stat { cursor: pointer; list-style: none; }
|
|
1848
|
+
summary.removal-stat::-webkit-details-marker { display: none; }
|
|
1849
|
+
summary.removal-stat::before { width: 5px; height: 5px; border: solid currentColor; border-width: 0 1px 1px 0; transform: rotate(-45deg); }
|
|
1850
|
+
details[open] > summary.removal-stat::before { transform: rotate(45deg); }
|
|
1851
|
+
.removal-stat strong { font-variant-numeric: tabular-nums; }
|
|
1852
|
+
.removal-subtotal { position: relative; padding-inline-start: 20px; color: var(--c-fg-muted); }
|
|
1853
|
+
.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; }
|
|
1854
|
+
.removal-summary ul { margin: 0 0 8px; padding-inline-start: 38px; overflow-wrap: anywhere; }
|
|
1855
|
+
.removal-summary li { padding-block: 2px; }
|
|
1856
|
+
.removal-summary code { color: var(--c-fg-muted); }
|
|
1857
|
+
.app-dialog:has(.removal-summary) .dialog-actions > :first-child { margin-inline-end: auto; }
|
|
1858
|
+
@media (forced-colors: active) { .removal-modes button[aria-pressed=true] { outline: 1px solid Highlight; outline-offset: -2px; } }
|
|
1859
|
+
@media (pointer: coarse) {
|
|
1860
|
+
.removal-row, .removal-row label, .removal-modes button { min-height: 44px; }
|
|
1861
|
+
.removal-modes button { min-width: 44px; }
|
|
1862
|
+
}
|
|
1779
1863
|
.app-dialog button.danger { color: var(--c-danger); }
|
|
1864
|
+
.file-placement, .icon-picker { display: grid; gap: 14px; margin-bottom: 18px; }
|
|
1865
|
+
.file-placement label { display: grid; gap: 5px; font-weight: 600; }
|
|
1866
|
+
.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; }
|
|
1867
|
+
.file-placement-list { max-height: min(36dvh, 280px); overflow: auto; padding: 0; margin: 0; list-style: none; }
|
|
1868
|
+
.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; }
|
|
1869
|
+
.file-placement-list li > :is(small, select, input) { grid-column: 2; }
|
|
1870
|
+
.file-placement-list small, .icon-picker small { color: var(--c-fg-muted); }
|
|
1871
|
+
.file-placement-list svg { display: block; color: var(--c-fg-muted); }
|
|
1872
|
+
.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; }
|
|
1873
|
+
.icon-picker-grid button { display: grid; gap: 3px; align-content: start; justify-items: center; overflow-wrap: anywhere; min-width: 0; }
|
|
1874
|
+
.icon-picker-grid button[hidden] { display: none; }
|
|
1875
|
+
.icon-picker-grid img { width: 36px; height: 36px; object-fit: contain; margin: 3px 0 5px; }
|
|
1876
|
+
.icon-picker > button { justify-self: start; }
|
|
1877
|
+
.app-dialog:has(.file-placement) .dialog-actions button:last-child { color: var(--c-bg0); background: var(--c-fg); }
|
|
1878
|
+
|
|
1780
1879
|
.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
1880
|
.history-dialog ul { max-height: 50dvh; margin: 12px 0 20px; padding: 0; overflow-y: auto; list-style: none; color: var(--c-fg-muted); }
|
|
1782
1881
|
.history-dialog li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
|
|
@@ -1884,10 +1983,10 @@ a.file-editor-title:hover { color: var(--c-accent); text-decoration: underline;
|
|
|
1884
1983
|
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
1984
|
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
1985
|
#site-title .nav-rename-form { inset: 0; padding: 0; }
|
|
1887
|
-
#site-icon-slot
|
|
1986
|
+
#site-icon-slot .nav-icon-pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
|
|
1888
1987
|
#site-icon-slot:hover, #site-icon-slot:focus-within, #sidebar-head.over #site-icon-slot { background: var(--c-line); border-radius: 3px; }
|
|
1889
1988
|
#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
|
|
1989
|
+
body.sidebar-closed #site-icon-slot .nav-icon-pick { display: none; }
|
|
1891
1990
|
/* Right panel = header / properties / editor stacked on one surface, separated by rules (no
|
|
1892
1991
|
nested frames). */
|
|
1893
1992
|
#panel { width: var(--panel-width, min(760px, 52vw)); flex-shrink: 0; position: sticky; top: 0; height: 100dvh; container: editor-panel / inline-size;
|
|
@@ -1945,10 +2044,11 @@ body.textfile-open:has(#file-editor:is(form), #file-editor .cm-content[contented
|
|
|
1945
2044
|
.schema-builder .schema-type-control > .subformat-control-label { padding: 0 4px; }
|
|
1946
2045
|
.schema-builder :is(input, textarea) { width: 100%; }
|
|
1947
2046
|
.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"]:
|
|
2047
|
+
: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; }
|
|
2048
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"]:checked { border-color: var(--c-fg-muted); }
|
|
2049
|
+
: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; }
|
|
2050
|
+
: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%); }
|
|
2051
|
+
:is(.schema-builder, .sidebar-removal) input[type="checkbox"]:focus-visible { outline: 1px solid var(--c-fg-muted); outline-offset: 3px; }
|
|
1952
2052
|
.schema-builder button { cursor: pointer; }
|
|
1953
2053
|
.schema-builder button:hover { background: var(--c-raised); }
|
|
1954
2054
|
.schema-builder button:disabled { opacity: .45; cursor: default; }
|
|
@@ -2098,8 +2198,8 @@ body.edit #nav-groups { --nav-rail: 22px; --nav-icon-half: 9px; }
|
|
|
2098
2198
|
.nav-doc-name { display: flex; flex: 1; flex-direction: column; min-width: 0; line-height: 17px; }
|
|
2099
2199
|
.nav-doc-icon { position: relative; flex: none; display: flex; align-items: center; justify-content: center;
|
|
2100
2200
|
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
|
|
2201
|
+
.nav-doc-icon:hover, .nav-doc-icon.file-drop-over, .nav-doc-icon:focus-within { background: var(--c-line); color: var(--c-fg); }
|
|
2202
|
+
.nav-doc-icon .nav-icon-pick { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
|
|
2103
2203
|
.nav-doc-icon > :is(.nav-icon, .doc-icon-frame) { width: 18px; height: 18px; }
|
|
2104
2204
|
.nav-icon-clear { position: absolute; right: -4px; top: -4px; width: 13px; height: 13px; padding: 0;
|
|
2105
2205
|
border: 1px solid var(--c-line); border-radius: 50%; font: 10px/11px sans-serif;
|
|
@@ -2184,7 +2284,8 @@ main.editor-workspace { padding: 0; height: 100dvh; display: flex; flex-directio
|
|
|
2184
2284
|
#preview-panes.split .preview-pane.active { border-top-color: var(--c-accent); }
|
|
2185
2285
|
#preview-panes .preview-pane:has(> .pane-resource .document-web, > .preview-content:not([hidden]) .document-web) { position: relative; padding: 0; border: 0; overflow: hidden; }
|
|
2186
2286
|
.preview-pane:has(> .preview-content:not([hidden]) .document-web) > .pane-actions { display: none; }
|
|
2187
|
-
.preview-pane:focus-visible { outline:
|
|
2287
|
+
#preview-panes:not(.split) > .preview-pane:focus-visible { outline:none; }
|
|
2288
|
+
#preview-panes.split .preview-pane:focus-visible { outline: 2px solid var(--c-accent); outline-offset: -2px; }
|
|
2188
2289
|
@media (max-width: 820px) {
|
|
2189
2290
|
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
2291
|
body.edit:has(#panel) #sidebar { grid-column: 1; grid-row: 1 / 3; height: 100dvh; z-index: 10; }
|
|
@@ -2337,7 +2438,7 @@ body.corr main article > [data-ln].corr-hi {
|
|
|
2337
2438
|
background: transparent; color: var(--c-fg-muted); cursor: pointer; opacity: 0; }
|
|
2338
2439
|
.nav-row:hover :is(.new, .nav-delete), .nav-row:focus-within :is(.new, .nav-delete),
|
|
2339
2440
|
.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
|
|
2441
|
+
.nav-row.renaming > :is(.new, .nav-delete, .nav-tree-toggle, .nav-tree-spacer) { display: none; }
|
|
2341
2442
|
.nav-row :is(.new, .nav-delete, .nav-create, .nav-rename-save, .nav-rename-cancel):is(:hover, :focus-visible) { background: var(--c-line); }
|
|
2342
2443
|
.nav-row :is(.nav-rename-save, .nav-rename-cancel):disabled { opacity: .5; cursor: wait; }
|
|
2343
2444
|
.nav-row :is(.nav-rename-save, .nav-rename-cancel) svg { width: 15px; height: 15px; }
|
|
@@ -2440,16 +2541,21 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2440
2541
|
// shortcut: Edit included tree structure in its manifest until cross-manifest transactions are supported.
|
|
2441
2542
|
if (mode === "edit" && !e.origin) {
|
|
2442
2543
|
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")}<
|
|
2544
|
+
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
2545
|
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
2546
|
}
|
|
2547
|
+
if (mode === "edit" &&
|
|
2548
|
+
e.included &&
|
|
2549
|
+
!site.entries.find((parent) => parent.id === e.parent)?.origin &&
|
|
2550
|
+
!actions)
|
|
2551
|
+
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
2552
|
const branch = childrenOf(site.entries, e.id).length > 0;
|
|
2447
2553
|
const toggle = branch
|
|
2448
2554
|
? `<button class="nav-tree-toggle" type="button" aria-expanded="${open.has(e.id)}" aria-label="Toggle ${label}">${DISCLOSURE_ICON}</button>`
|
|
2449
2555
|
: mode === "edit"
|
|
2450
2556
|
? '<span class="nav-tree-spacer" aria-hidden="true"></span>'
|
|
2451
2557
|
: "";
|
|
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>`;
|
|
2558
|
+
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
2559
|
})
|
|
2454
2560
|
.join("");
|
|
2455
2561
|
const placeholder = mode === "edit" && depth === 0
|
|
@@ -2504,16 +2610,16 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2504
2610
|
const format = currentRes?.startsWith("_format") ||
|
|
2505
2611
|
["codeblocks", "_library/codeblocks", "dictionary", "code"].includes(currentRes ?? "");
|
|
2506
2612
|
const library = !format && (currentRes?.startsWith("_library") || isReferenceLibrary(currentRes));
|
|
2507
|
-
const hint = `<
|
|
2613
|
+
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
2614
|
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>`;
|
|
2615
|
+
? `<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>`
|
|
2616
|
+
: `<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
2617
|
const git = source?.protocol === "git" && sharedBranch === undefined
|
|
2512
2618
|
? `<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
2619
|
: "";
|
|
2514
2620
|
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
|
|
2621
|
+
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>`;
|
|
2622
|
+
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
2623
|
};
|
|
2518
2624
|
const formatSize = (bytes) => bytes < 1024
|
|
2519
2625
|
? `${bytes} B`
|
|
@@ -2575,6 +2681,17 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2575
2681
|
if (errors.length)
|
|
2576
2682
|
return { html: "", errors };
|
|
2577
2683
|
try {
|
|
2684
|
+
if (language === "md" || language === "markdown") {
|
|
2685
|
+
const { doc, source: parsed } = compileDraft(draftContext(site), file, source);
|
|
2686
|
+
return {
|
|
2687
|
+
html: blocksHtml(doc.blocks, {
|
|
2688
|
+
...site.ctx,
|
|
2689
|
+
terms: [...site.ctx.terms, ...parsed.terms],
|
|
2690
|
+
pageContents: (file, recursive, title) => contentsLibrary(site, file, recursive, title),
|
|
2691
|
+
}),
|
|
2692
|
+
errors: parsed.errors,
|
|
2693
|
+
};
|
|
2694
|
+
}
|
|
2578
2695
|
return {
|
|
2579
2696
|
html: blocksHtml(parsed?.blocks ?? [
|
|
2580
2697
|
{
|
|
@@ -2605,16 +2722,6 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2605
2722
|
catch (error) {
|
|
2606
2723
|
errors.push(error instanceof Error ? error.message : String(error));
|
|
2607
2724
|
}
|
|
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
2725
|
return errors;
|
|
2619
2726
|
};
|
|
2620
2727
|
/** Hidden skill entries are readable only through the validated project skill list. */
|
|
@@ -2789,6 +2896,24 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2789
2896
|
}
|
|
2790
2897
|
if (!file && (kind === "dictionary" || kind === "code"))
|
|
2791
2898
|
return resourcesMain(site, "codeblocks");
|
|
2899
|
+
if (!file && kind === "toc") {
|
|
2900
|
+
const owner = site.root ?? root;
|
|
2901
|
+
const manifest = manifestFile(owner);
|
|
2902
|
+
const sources = new Map([[manifest, ""]]);
|
|
2903
|
+
for (const entry of site.entries) {
|
|
2904
|
+
if (entry.included && entry.origin)
|
|
2905
|
+
sources.set(entry.origin, entry.root ? "" : entry.id);
|
|
2906
|
+
if (isContentPage(entry) && entry.sourceFile)
|
|
2907
|
+
sources.set(entry.sourceFile, entry.root ? "" : entry.id);
|
|
2908
|
+
}
|
|
2909
|
+
const choices = [...sources]
|
|
2910
|
+
.map(([path, id]) => `<option value="${escapeHtml(path)}" data-page="${escapeHtml(id)}">${escapeHtml(path)}</option>`)
|
|
2911
|
+
.join("");
|
|
2912
|
+
return {
|
|
2913
|
+
title: "Table of contents",
|
|
2914
|
+
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>`,
|
|
2915
|
+
};
|
|
2916
|
+
}
|
|
2792
2917
|
if (kind === "schema" && file) {
|
|
2793
2918
|
const config = site.subformats?.find((format) => format.ext === file);
|
|
2794
2919
|
if (!config)
|
|
@@ -2921,6 +3046,14 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2921
3046
|
? title
|
|
2922
3047
|
: `${title} — ${site.title ?? "dooc edit"}`;
|
|
2923
3048
|
// Navigation follows the manifest hierarchy via routing.docPath.
|
|
3049
|
+
const siteIconImages = (site) => {
|
|
3050
|
+
const iconImg = `<img id="site-icon" alt=""${site.icon ? ` src="${svgDataUri(site.icon)}"` : " hidden"}>`;
|
|
3051
|
+
const iconVariants = Object.entries(site.iconVariants ?? {});
|
|
3052
|
+
// The base image sits in a wrapper so theme switching and edit-client's #site-icon.hidden never fight.
|
|
3053
|
+
return iconVariants.length
|
|
3054
|
+
? `<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>`
|
|
3055
|
+
: iconImg;
|
|
3056
|
+
};
|
|
2924
3057
|
const page = (mode, site, opts) => {
|
|
2925
3058
|
const currentDocument = site.entries.find((entry) => entry.id === opts.currentId);
|
|
2926
3059
|
const rootPage = site.entries.find((entry) => entry.root);
|
|
@@ -2928,8 +3061,9 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2928
3061
|
const rootCurrent = currentDocument?.root && (!opts.currentRes || opts.currentRes === "/");
|
|
2929
3062
|
const nav = navGroupsHtml(historicalReadOnly || opts.loading ? "preview" : mode, site, opts.currentId, opts.currentRes);
|
|
2930
3063
|
const siteTitle = escapeHtml(site.title ?? "dooc");
|
|
2931
|
-
const
|
|
2932
|
-
|
|
3064
|
+
const rootEdit = mode === "edit" && !historicalReadOnly
|
|
3065
|
+
? `<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>`
|
|
3066
|
+
: "";
|
|
2933
3067
|
const tabIcons = { "": site.icon, ...site.iconVariants };
|
|
2934
3068
|
const favicons = mode === "preview"
|
|
2935
3069
|
? Object.entries(tabIcons)
|
|
@@ -2938,11 +3072,7 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2938
3072
|
: [])
|
|
2939
3073
|
.join("\n")
|
|
2940
3074
|
: "";
|
|
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>`;
|
|
3075
|
+
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
3076
|
const output = opts.publish?.output;
|
|
2947
3077
|
const script = (js) => output
|
|
2948
3078
|
? `<script src="${escapeHtml(output.asset(js, "js"))}"></script>`
|
|
@@ -2969,16 +3099,16 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2969
3099
|
|
|
2970
3100
|
|
|
2971
3101
|
<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"
|
|
3102
|
+
<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
3103
|
: mode === "edit" && opts.currentRes !== undefined
|
|
2974
3104
|
? `<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>`;
|
|
3105
|
+
: `<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
3106
|
const graphScript = output?.graph
|
|
2977
3107
|
? `<script type="module" src="${escapeHtml(output.graph)}"></script>`
|
|
2978
3108
|
: opts.publish
|
|
2979
3109
|
? script(opts.publish.graphJs)
|
|
2980
3110
|
: `<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">
|
|
3111
|
+
const frame = `<!doctype html><html lang="en"${site.accentColor ? ` style="--project-accent:${escapeHtml(site.accentColor)}"` : ""}><head><meta charset="utf-8">
|
|
2982
3112
|
${opts.publish ? `<meta name="referrer" content="no-referrer"><meta http-equiv="x-dns-prefetch-control" content="off">${opts.publish.network ? "" : `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src ${self}'unsafe-inline'; style-src ${self}'unsafe-inline' data:; img-src ${self}data: blob:; media-src ${self}data: blob:; object-src ${self}data:; font-src ${self}data: blob:; frame-src ${self}data: blob:; connect-src ${output ? "'self'" : "'none'"}; base-uri 'none'; form-action 'none'">`}` : ""}
|
|
2983
3113
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2984
3114
|
<title>${escapeHtml(pageTitle(mode, opts.title, site))}</title>
|
|
@@ -2987,7 +3117,7 @@ ${script(`var __name = (f) => f;
|
|
|
2987
3117
|
(${initializeThemes.toString()})(${JSON.stringify(site.themes)});
|
|
2988
3118
|
(${mountFigureFrames.toString()})(document);`)}
|
|
2989
3119
|
${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
|
|
3120
|
+
<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
3121
|
`;
|
|
2992
3122
|
if (opts.loading)
|
|
2993
3123
|
return `${frame}<script>document.body.dataset.clientLoading = "true";
|
|
@@ -3138,6 +3268,13 @@ ${mode === "edit"
|
|
|
3138
3268
|
const res = await localeFetch("/api/nav?current=" + encodeURIComponent(id) + (rp == null ? "" : "&res=" + encodeURIComponent(rp)));
|
|
3139
3269
|
if (res.ok) {
|
|
3140
3270
|
const data = await res.json();
|
|
3271
|
+
document.documentElement.style.setProperty("--project-accent", data.accentColor || "");
|
|
3272
|
+
const slot = document.getElementById("site-icon-slot");
|
|
3273
|
+
if (slot && data.iconImages && slot.dataset.images !== data.iconImages) {
|
|
3274
|
+
slot.querySelector(".site-icon-variants, #site-icon")?.remove();
|
|
3275
|
+
slot.insertAdjacentHTML("afterbegin",data.iconImages);
|
|
3276
|
+
slot.dataset.images = data.iconImages;
|
|
3277
|
+
}
|
|
3141
3278
|
(${updateNav.toString()})(document.getElementById("nav-groups"), data.html);
|
|
3142
3279
|
const currentPage = document.querySelector('[data-subformat-nav][data-doc-id="' + CSS.escape(id) + '"] > .nav-row > a');
|
|
3143
3280
|
if (currentPage && currentPage.pathname !== location.pathname) {
|
|
@@ -3161,17 +3298,16 @@ ${mode === "edit"
|
|
|
3161
3298
|
return data;
|
|
3162
3299
|
};
|
|
3163
3300
|
|
|
3301
|
+
window.__docsRefreshSidebar = refresh;
|
|
3164
3302
|
const docAction = (item, action) => {
|
|
3165
|
-
if (
|
|
3166
|
-
document.dispatchEvent(new CustomEvent("docs:
|
|
3303
|
+
if (action === "delete") {
|
|
3304
|
+
document.dispatchEvent(new CustomEvent("docs:remove-sidebar-entry", {detail: item}));
|
|
3167
3305
|
return;
|
|
3168
3306
|
}
|
|
3169
|
-
if (window.__docsDocAction) {
|
|
3170
|
-
|
|
3307
|
+
if (item.hasAttribute("data-subformat-nav") || !window.__docsDocAction) {
|
|
3308
|
+
document.dispatchEvent(new CustomEvent("docs:rename-sidebar-entry", { detail: item }));
|
|
3171
3309
|
} else {
|
|
3172
|
-
|
|
3173
|
-
url.searchParams.set("doc-action", action);
|
|
3174
|
-
location.href = url.href;
|
|
3310
|
+
void window.__docsDocAction(item.dataset.docId, action);
|
|
3175
3311
|
}
|
|
3176
3312
|
};
|
|
3177
3313
|
document.addEventListener("click", (event) => {
|
|
@@ -3232,17 +3368,18 @@ ${mode === "edit"
|
|
|
3232
3368
|
try {
|
|
3233
3369
|
const result = await post("/api/site-title", { title: input.value, baseTitle, language: target.language }, target);
|
|
3234
3370
|
if (!current(target)) { close(); return; }
|
|
3371
|
+
const restoreFocus = form.contains(document.activeElement);
|
|
3235
3372
|
closed = true;
|
|
3236
3373
|
form.remove();
|
|
3237
3374
|
label.textContent = label.title = result.title;
|
|
3238
3375
|
label.dataset.title = result.title;
|
|
3239
3376
|
label.setAttribute("href", href);
|
|
3377
|
+
if (restoreFocus) label.focus({preventScroll:true});
|
|
3240
3378
|
await refresh();
|
|
3241
|
-
label.focus();
|
|
3242
3379
|
setStatus("", false);
|
|
3243
3380
|
} catch (error) {
|
|
3244
3381
|
setStatus(error.message, true);
|
|
3245
|
-
input.focus();
|
|
3382
|
+
if (form.contains(document.activeElement)) input.focus();
|
|
3246
3383
|
} finally {
|
|
3247
3384
|
busy = false;
|
|
3248
3385
|
input.readOnly = false;
|
|
@@ -3266,60 +3403,6 @@ ${mode === "edit"
|
|
|
3266
3403
|
};
|
|
3267
3404
|
document.addEventListener("dblclick", editLabel);
|
|
3268
3405
|
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
3406
|
let dragContext;
|
|
3324
3407
|
let dragged = null;
|
|
3325
3408
|
let drop = null;
|
|
@@ -3439,7 +3522,7 @@ ${mode === "edit"
|
|
|
3439
3522
|
form.innerHTML =
|
|
3440
3523
|
'<p class="nav-new-heading" data-i18n="Markdown page">Markdown page</p>' +
|
|
3441
3524
|
'<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
|
|
3525
|
+
'<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
3526
|
'<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
3527
|
'<div class="err" role="alert"></div>';
|
|
3445
3528
|
row.append(form);
|
|
@@ -3458,7 +3541,11 @@ ${mode === "edit"
|
|
|
3458
3541
|
trigger.focus();
|
|
3459
3542
|
};
|
|
3460
3543
|
form.querySelector(".nav-new-cancel").addEventListener("click", cancel);
|
|
3461
|
-
|
|
3544
|
+
const directory = document.getElementById("nav-tools")?.dataset.uploadDirectory;
|
|
3545
|
+
title.addEventListener("input", () => {
|
|
3546
|
+
const name = suggestFileName(title.value);
|
|
3547
|
+
if (!nameTouched) nameInput.value = name && directory && directory !== "." ? directory + "/" + name : name;
|
|
3548
|
+
});
|
|
3462
3549
|
nameInput.addEventListener("input", () => { nameTouched = true; });
|
|
3463
3550
|
form.addEventListener("keydown", (e) => {
|
|
3464
3551
|
if (e.key === "Escape") { e.preventDefault(); cancel(); }
|
|
@@ -3475,7 +3562,7 @@ ${mode === "edit"
|
|
|
3475
3562
|
submit.setAttribute("aria-busy", "true");
|
|
3476
3563
|
err.textContent = "";
|
|
3477
3564
|
try {
|
|
3478
|
-
await post("/api/create", { parent: parent || undefined, title: title.value.trim(),
|
|
3565
|
+
await post("/api/create", { parent: parent || undefined, title: title.value.trim(), path: nameInput.value.trim() }, target);
|
|
3479
3566
|
if (!current(target)) return;
|
|
3480
3567
|
closeForm();
|
|
3481
3568
|
await refresh();
|
|
@@ -3807,17 +3894,15 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3807
3894
|
// Linked files get their previewer page too.
|
|
3808
3895
|
// shortcut: file names containing HTML-escaped characters (& < > " ') get no page, decode entities if needed
|
|
3809
3896
|
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
|
-
}
|
|
3897
|
+
for (const page of pages)
|
|
3898
|
+
for (const [, encoded] of page.main.matchAll(/href="\/(_files\/file\/[^"#&]+)/g)) {
|
|
3899
|
+
if (!encoded || routes.has(encoded))
|
|
3900
|
+
continue;
|
|
3901
|
+
routes.add(encoded);
|
|
3902
|
+
const linked = linkedFilePage(site, decodeURIComponent(encoded.slice("_files/file/".length)));
|
|
3903
|
+
if (linked)
|
|
3904
|
+
pages.push({ route: encoded, ...linked });
|
|
3905
|
+
}
|
|
3821
3906
|
const templates = pages
|
|
3822
3907
|
.map((p) => {
|
|
3823
3908
|
const content = toHashLinks(p.main, p.route);
|
|
@@ -3840,8 +3925,6 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3840
3925
|
},
|
|
3841
3926
|
}), first);
|
|
3842
3927
|
};
|
|
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
3928
|
const entryMain = (site, e) => {
|
|
3846
3929
|
if (e.url && /^https?:\/\//i.test(e.url)) {
|
|
3847
3930
|
const title = docDisplayName(e.frontmatter, e.id);
|
|
@@ -3852,14 +3935,44 @@ ${opts.publish ? `${opts.publish.pages}${script(`${publishRouterScript(opts.publ
|
|
|
3852
3935
|
`<article><p role="alert">File not found: ${escapeHtml(e.url)}</p></article>`);
|
|
3853
3936
|
const html = renderEntryHtml(site, e).html;
|
|
3854
3937
|
const kids = childrenOf(site.entries, e.id);
|
|
3855
|
-
if (e.subformat ||
|
|
3938
|
+
if (e.subformat ||
|
|
3939
|
+
e.library ||
|
|
3940
|
+
e.format ||
|
|
3941
|
+
(e.url && tocReference(e.url)) ||
|
|
3942
|
+
e.blocks.length ||
|
|
3943
|
+
(e.root && isContentPage(e)) ||
|
|
3944
|
+
(!e.root && !kids.length)) {
|
|
3856
3945
|
return html;
|
|
3857
3946
|
}
|
|
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>`));
|
|
3947
|
+
return html.replace(/<\/article>\s*$/, () => `${contentsTree(site, e, true)}</article>`);
|
|
3862
3948
|
};
|
|
3949
|
+
function contentsTree(site, parent, recursive) {
|
|
3950
|
+
const children = new Map();
|
|
3951
|
+
for (const entry of site.entries) {
|
|
3952
|
+
const group = children.get(entry.parent) ?? [];
|
|
3953
|
+
group.push(entry);
|
|
3954
|
+
children.set(entry.parent, group);
|
|
3955
|
+
}
|
|
3956
|
+
const items = (id) => (children.get(id) ?? [])
|
|
3957
|
+
.map((entry) => {
|
|
3958
|
+
const nested = recursive && children.has(entry.id) ? `<ul>${items(entry.id)}</ul>` : "";
|
|
3959
|
+
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>`;
|
|
3960
|
+
})
|
|
3961
|
+
.join("");
|
|
3962
|
+
return children.has(parent.id)
|
|
3963
|
+
? docLinks(site, `<ul class="idx" data-library="toc">${items(parent.id)}</ul>`)
|
|
3964
|
+
: '<p data-library="toc" data-i18n="No child pages">No child pages</p>';
|
|
3965
|
+
}
|
|
3966
|
+
function contentsLibrary(site, file, recursive, title) {
|
|
3967
|
+
const entry = file === manifestFile(site.root ?? root)
|
|
3968
|
+
? site.entries.find((page) => page.root)
|
|
3969
|
+
: site.entries.find((page) => (page.included && page.origin === file) ||
|
|
3970
|
+
(isContentPage(page) && page.sourceFile === file));
|
|
3971
|
+
const listing = entry
|
|
3972
|
+
? contentsTree(site, entry, recursive)
|
|
3973
|
+
: `<p role="alert">Table of contents source is not in this document: ${escapeHtml(file)}</p>`;
|
|
3974
|
+
return title ? `<section><h2>${escapeHtml(title)}</h2>${listing}</section>` : listing;
|
|
3975
|
+
}
|
|
3863
3976
|
const languageFieldHtml = (defaultLang, language = contentLanguageCode(defaultLang), translatedLanguages = [contentLanguageCode(defaultLang)], declaredLanguages) => {
|
|
3864
3977
|
const existing = new Set(translatedLanguages);
|
|
3865
3978
|
const options = [...contentLanguages]
|
|
@@ -3952,6 +4065,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
3952
4065
|
</div><div id="editor-header-workspace"></div><div id="editor-header-actions">
|
|
3953
4066
|
<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
4067
|
<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>
|
|
4068
|
+
<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
4069
|
<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
4070
|
<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
4071
|
<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 +4341,14 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4227
4341
|
? ops.addLibrary(body.library, title, parent)
|
|
4228
4342
|
: typeof body?.subformat === "string"
|
|
4229
4343
|
? ops.addSubformat(body.subformat, title, parent)
|
|
4230
|
-
:
|
|
4344
|
+
: typeof body?.path === "string"
|
|
4345
|
+
? ops.addFile(body.path, title, parent, body.reference === true ? "reference" : "path")
|
|
4346
|
+
: ops.addFile(name, title, parent);
|
|
4231
4347
|
sendOp(res, isOpError(result)
|
|
4232
4348
|
? result
|
|
4233
4349
|
: { ...result, path: docPath(loadSite().entries, result.id) });
|
|
4234
4350
|
};
|
|
4235
|
-
//
|
|
4236
|
-
// (the client inserts ).
|
|
4351
|
+
// Compatibility endpoint for clients that upload figure bytes.
|
|
4237
4352
|
const handleFigure = async (req, res) => {
|
|
4238
4353
|
const body = await readJson(req);
|
|
4239
4354
|
if (typeof body?.name !== "string" || typeof body?.data !== "string") {
|
|
@@ -4245,8 +4360,6 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4245
4360
|
? result
|
|
4246
4361
|
: { ...result, path: result.path ?? `figures/${result.file}` });
|
|
4247
4362
|
};
|
|
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
4363
|
const handleIcon = async (req, res) => {
|
|
4251
4364
|
const body = await readJson(req);
|
|
4252
4365
|
const manifest = readManifest(root);
|
|
@@ -4267,6 +4380,22 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4267
4380
|
sendJson(res, 403, { error: "Remote document sources are read-only" });
|
|
4268
4381
|
return;
|
|
4269
4382
|
}
|
|
4383
|
+
if (body?.path !== undefined) {
|
|
4384
|
+
try {
|
|
4385
|
+
const svg = projectIcon(root, body.path);
|
|
4386
|
+
manifest.files ??= parseFileLayout({});
|
|
4387
|
+
manifest.files.icons ??= {};
|
|
4388
|
+
manifest.files.icons[id] = body.path;
|
|
4389
|
+
writeManifest(root, manifest.tree, manifest);
|
|
4390
|
+
sendJson(res, 200, { ok: true, icon: svgDataUri(svg) });
|
|
4391
|
+
}
|
|
4392
|
+
catch (error) {
|
|
4393
|
+
sendJson(res, 400, {
|
|
4394
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4395
|
+
});
|
|
4396
|
+
}
|
|
4397
|
+
return;
|
|
4398
|
+
}
|
|
4270
4399
|
let file = manifest.format === undefined &&
|
|
4271
4400
|
manifest.files?.defaultLayout !== false &&
|
|
4272
4401
|
!Object.hasOwn(manifest.files?.icons ?? {}, id) &&
|
|
@@ -4344,37 +4473,82 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4344
4473
|
const file = sourceDocFile(target.id, snapshot.layout);
|
|
4345
4474
|
if (body?.sourceFile !== file)
|
|
4346
4475
|
throw new Error("Files changed. Reload before retrying.");
|
|
4347
|
-
|
|
4476
|
+
updateFiles(root, {
|
|
4348
4477
|
action: "rename",
|
|
4349
4478
|
file,
|
|
4350
4479
|
name: typeof body?.name === "string" ? body.name.trim() : "",
|
|
4351
4480
|
revision: snapshot.revision,
|
|
4352
4481
|
});
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4482
|
+
const next = file.slice(0, file.lastIndexOf("/") + 1) + String(body?.name).trim();
|
|
4483
|
+
const manifest = readManifest(root);
|
|
4484
|
+
const entries = flattenTree(manifest.tree);
|
|
4485
|
+
const renamed = entries.find((entry) => isContentPage(entry) && sourceDocFile(entry.id, manifest.files) === next);
|
|
4486
|
+
if (!renamed)
|
|
4487
|
+
throw new Error("Renamed page not found");
|
|
4488
|
+
sendOp(res, { id: renamed.id, path: docPath(entries, renamed.id), sourceFile: next });
|
|
4357
4489
|
}
|
|
4358
4490
|
catch (error) {
|
|
4359
4491
|
sendJson(res, 409, { error: error instanceof Error ? error.message : String(error) });
|
|
4360
4492
|
}
|
|
4361
4493
|
};
|
|
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
4494
|
const handleDelete = async (req, res) => {
|
|
4365
4495
|
const body = await readJson(req);
|
|
4496
|
+
if (typeof body?.id === "string") {
|
|
4497
|
+
if (body.preview === true &&
|
|
4498
|
+
body.selected === undefined &&
|
|
4499
|
+
body.children === undefined) {
|
|
4500
|
+
sendOp(res, previewSidebarRemoval(root, body.id));
|
|
4501
|
+
return;
|
|
4502
|
+
}
|
|
4503
|
+
if ((body.selected === undefined
|
|
4504
|
+
? body.children !== "remove" && body.children !== "promote"
|
|
4505
|
+
: !Array.isArray(body.selected) ||
|
|
4506
|
+
!body.selected.every((id) => typeof id === "string")) ||
|
|
4507
|
+
(body.files !== "keep" &&
|
|
4508
|
+
body.files !== "delete" &&
|
|
4509
|
+
(!Array.isArray(body.files) ||
|
|
4510
|
+
!body.files.every((path) => typeof path === "string"))) ||
|
|
4511
|
+
(body.confirmation !== undefined && typeof body.confirmation !== "string") ||
|
|
4512
|
+
(body.preview !== undefined && typeof body.preview !== "boolean") ||
|
|
4513
|
+
typeof body.revision !== "string") {
|
|
4514
|
+
sendJson(res, 400, { error: "Review the sidebar and choose what to remove" });
|
|
4515
|
+
return;
|
|
4516
|
+
}
|
|
4517
|
+
const options = {
|
|
4518
|
+
children: body.children === "remove" || body.children === "promote"
|
|
4519
|
+
? body.children
|
|
4520
|
+
: undefined,
|
|
4521
|
+
selected: body.selected,
|
|
4522
|
+
files: body.files,
|
|
4523
|
+
revision: body.revision,
|
|
4524
|
+
confirmation: body.confirmation,
|
|
4525
|
+
force: body.force === true,
|
|
4526
|
+
};
|
|
4527
|
+
try {
|
|
4528
|
+
const changed = options.files === "delete" ||
|
|
4529
|
+
(Array.isArray(options.files) && options.files.length)
|
|
4530
|
+
? await host.changedTrackedFiles(root)
|
|
4531
|
+
: new Set();
|
|
4532
|
+
const operation = body.preview === true ? reviewSidebarRemoval : removeSidebarEntry;
|
|
4533
|
+
sendOp(res, operation(root, body.id, options, changed));
|
|
4534
|
+
}
|
|
4535
|
+
catch {
|
|
4536
|
+
sendJson(res, 409, {
|
|
4537
|
+
error: "Could not check Git changes. Review the deletion again.",
|
|
4538
|
+
});
|
|
4539
|
+
}
|
|
4540
|
+
return;
|
|
4541
|
+
}
|
|
4542
|
+
if (body?.preview !== undefined || body?.confirmation !== undefined) {
|
|
4543
|
+
sendJson(res, 400, { error: "Use the sidebar entry ID to review or confirm deletion" });
|
|
4544
|
+
return;
|
|
4545
|
+
}
|
|
4366
4546
|
const target = resolveContentFile(body?.file);
|
|
4367
4547
|
if (!target) {
|
|
4368
4548
|
sendJson(res, 404, { error: "target doc not found" });
|
|
4369
4549
|
return;
|
|
4370
4550
|
}
|
|
4371
|
-
|
|
4372
|
-
sendOp(res, isOpError(result)
|
|
4373
|
-
? result
|
|
4374
|
-
: {
|
|
4375
|
-
...result,
|
|
4376
|
-
path: result.parent ? docPath(loadSite().entries, result.parent) : "/",
|
|
4377
|
-
});
|
|
4551
|
+
sendOp(res, removeSidebarEntry(root, target.id, { files: "delete", force: body?.force === true }));
|
|
4378
4552
|
};
|
|
4379
4553
|
const handle = async (mode, req, res) => {
|
|
4380
4554
|
const requestUrl = new URL(req.url ?? "/", "http://localhost");
|
|
@@ -4480,7 +4654,7 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4480
4654
|
const grammar = siteLanguages.codeGrammars?.find((entry) => entry.name === extension || entry.aliases?.includes(extension));
|
|
4481
4655
|
const language = existsSync(join(root, ".dooc/editor-tools", `${extension}.json`))
|
|
4482
4656
|
? extension
|
|
4483
|
-
: (readManifest(root).
|
|
4657
|
+
: (recordSubformat(root, readManifest(root), input.file, applicationPreviews.domains)?.format ??
|
|
4484
4658
|
grammar?.name ??
|
|
4485
4659
|
extension);
|
|
4486
4660
|
const result = await validateTextfileCode(root, language, input.content);
|
|
@@ -4568,6 +4742,30 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4568
4742
|
await handleCreate(req, res);
|
|
4569
4743
|
return;
|
|
4570
4744
|
}
|
|
4745
|
+
if (path === "/api/root-source") {
|
|
4746
|
+
const body = await readJson(req);
|
|
4747
|
+
if (body?.action !== "read" && body?.action !== "save") {
|
|
4748
|
+
sendJson(res, 400, { error: "Unknown root page action" });
|
|
4749
|
+
return;
|
|
4750
|
+
}
|
|
4751
|
+
sendOp(res, rootPageSource(root, body.action === "save" ? body : undefined));
|
|
4752
|
+
return;
|
|
4753
|
+
}
|
|
4754
|
+
if (path === "/api/sidebar-title") {
|
|
4755
|
+
const body = await readJson(req);
|
|
4756
|
+
const entry = loadNavigation(locale, null).entries.find((entry) => entry.id === body?.id);
|
|
4757
|
+
if (!entry || entry.origin) {
|
|
4758
|
+
sendJson(res, 404, { error: "Sidebar entry not found" });
|
|
4759
|
+
return;
|
|
4760
|
+
}
|
|
4761
|
+
if (typeof body?.title !== "string" ||
|
|
4762
|
+
body.baseTitle !== docDisplayName(entry.frontmatter, entry.id)) {
|
|
4763
|
+
sendJson(res, 409, { error: "The title changed. Review it before renaming." });
|
|
4764
|
+
return;
|
|
4765
|
+
}
|
|
4766
|
+
sendOp(res, ops.setTitle(entry.id, body.title));
|
|
4767
|
+
return;
|
|
4768
|
+
}
|
|
4571
4769
|
if (path === "/api/subformat-page") {
|
|
4572
4770
|
const body = await readJson(req);
|
|
4573
4771
|
const id = typeof body?.id === "string" ? body.id : "";
|
|
@@ -4591,7 +4789,13 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4591
4789
|
const result = path === "/api/site-title"
|
|
4592
4790
|
? siteTitleResponse(root, input)
|
|
4593
4791
|
: siteIconResponse(root, input);
|
|
4594
|
-
|
|
4792
|
+
if (path === "/api/site-icon" && input?.path && result.status === 200)
|
|
4793
|
+
sendJson(res, 200, {
|
|
4794
|
+
...result.body,
|
|
4795
|
+
images: siteIconImages(loadSite(locale)),
|
|
4796
|
+
});
|
|
4797
|
+
else
|
|
4798
|
+
sendJson(res, result.status, result.body);
|
|
4595
4799
|
return;
|
|
4596
4800
|
}
|
|
4597
4801
|
if (path === "/api/figure") {
|
|
@@ -4630,6 +4834,8 @@ ${languageFieldHtml(site.defaultLang, site.contentLanguage, entry.translatedLang
|
|
|
4630
4834
|
const currentId = params.get("current") || resolveDocPath(site.entries, params.get("route") ?? "/");
|
|
4631
4835
|
sendJson(res, 200, {
|
|
4632
4836
|
siteTitle: site.title,
|
|
4837
|
+
accentColor: site.accentColor,
|
|
4838
|
+
iconImages: siteIconImages(site),
|
|
4633
4839
|
siteIcon: site.icon ? svgDataUri(site.icon) : undefined,
|
|
4634
4840
|
themes: site.themes,
|
|
4635
4841
|
rootJump: docHref(site.entries, site.entries.find((entry) => entry.root)?.id ?? ""),
|