@dooc-dev/dooc 0.0.17 → 0.0.19
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 +163 -163
- package/dist/engine/core/html.d.ts +2 -2
- package/dist/engine/core/html.js +4 -4
- package/dist/frontend/document-application.js +4 -8
- package/dist/frontend/locales/eng.json +0 -6
- package/dist/frontend/locales/jpn.json +0 -6
- package/dist/frontend/locales/zho.json +0 -6
- package/dist/frontend/resource-library.d.ts +1 -1
- package/dist/frontend/resource-library.js +10 -11
- package/dist/plugins.global.js +4 -4
- package/dist/server/workspace-server.js +2 -6
- package/dist/subformats.global.js +34 -42
- package/dist/ui.global.js +36 -44
- package/dist/workspace-mcp-worker.global.js +7 -11
- package/dist/workspace-reader-mcp-worker.global.js +7 -11
- package/dist/workspace-reader-worker.global.js +7 -11
- package/dist/workspace-worker.global.js +7 -11
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import type { FigureEntry, TermEntry } from "./content-types.js";
|
|
|
3
3
|
import { figureFrameHtml } from "./figure-frame.js";
|
|
4
4
|
import { type LanguageAdapter } from "./language.js";
|
|
5
5
|
import type { SubformatCollection } from "./subformats.js";
|
|
6
|
-
import {
|
|
6
|
+
import type { Frontmatter } from "./taxonomy.js";
|
|
7
7
|
export { escapeHtml } from "./escape-html.js";
|
|
8
8
|
export interface RenderCtx {
|
|
9
9
|
downloads?: ReadonlyMap<string, string>;
|
|
@@ -38,4 +38,4 @@ export declare const termsHtml: (terms: readonly TermEntry[], language?: Languag
|
|
|
38
38
|
export declare const resourceDownloadHtml: (file: string, href: string) => string;
|
|
39
39
|
export declare const subformatTableHtml: (collection: SubformatCollection, label: string) => string;
|
|
40
40
|
export declare const blocksHtml: (blocks: Block[], ctx?: RenderCtx) => string;
|
|
41
|
-
export declare const docHtml: (
|
|
41
|
+
export declare const docHtml: (_fm: Frontmatter, blocks: Block[], errors: string[], ctx?: RenderCtx, toc?: TocEntry[]) => string;
|
package/dist/engine/core/html.js
CHANGED
|
@@ -12,7 +12,6 @@ import { inlineSegmenter, termMap } from "./inline.js";
|
|
|
12
12
|
import { termComparator } from "./language.js";
|
|
13
13
|
import { isReferenceUrl, parseDocLink } from "./routing.js";
|
|
14
14
|
import { layoutSchemaGraph, SCHEMA_LAYOUT_MARGIN, schemaGraphClientData, schemaGraphUid, } from "./schema-graph.js";
|
|
15
|
-
import { docDisplayName } from "./taxonomy.js";
|
|
16
15
|
import { termAnchor } from "./term-reference.js";
|
|
17
16
|
import { parseFileReference, textfileName } from "./textfile.js";
|
|
18
17
|
export { escapeHtml } from "./escape-html.js";
|
|
@@ -474,7 +473,7 @@ export const blocksHtml = (blocks, ctx = emptyCtx) => {
|
|
|
474
473
|
.filter((h) => h !== "")
|
|
475
474
|
.join("\n");
|
|
476
475
|
};
|
|
477
|
-
// Keep the document outline
|
|
476
|
+
// Keep the document outline above its content in every reader.
|
|
478
477
|
const inPageTocHtml = (toc, title = "Contents") => {
|
|
479
478
|
if (toc.length === 0) {
|
|
480
479
|
return "";
|
|
@@ -484,10 +483,11 @@ const inPageTocHtml = (toc, title = "Contents") => {
|
|
|
484
483
|
.join("");
|
|
485
484
|
return `<nav class="in-toc" aria-label="${escapeHtml(title)}"><button class="toc-current" type="button" aria-expanded="false">${escapeHtml(toc[0]?.text ?? "")}</button><ul class="toc-options" popover>${items}</ul></nav>`;
|
|
486
485
|
};
|
|
487
|
-
export const docHtml = (
|
|
486
|
+
export const docHtml = (_fm, blocks, errors, ctx = emptyCtx, toc = []) => {
|
|
488
487
|
const errBox = errors.length > 0
|
|
489
488
|
? `<div class="errors">${errors.map((e) => `<div>${escapeHtml(e)}</div>`).join("")}</div>`
|
|
490
489
|
: "";
|
|
491
490
|
const lang = ctx.lang ? ` lang="${escapeHtml(ctx.lang)}"` : "";
|
|
492
|
-
|
|
491
|
+
const controls = `${ctx.pageDownload ? resourceDownloadHtml(ctx.pageDownload.file, ctx.pageDownload.href) : ""}${inPageTocHtml(toc, ctx.tocTitle)}`;
|
|
492
|
+
return `<article${lang}>${errBox}${controls ? `<header class="doc-title">${controls}</header>` : ""}${blocksHtml(blocks, ctx)}</article>`;
|
|
493
493
|
};
|
|
@@ -263,7 +263,7 @@ export const createDocumentApplication = (root, host) => {
|
|
|
263
263
|
const jump = docHref(site.entries, id);
|
|
264
264
|
return `${isLinkedEntry(entry) ? "data-document-link " : ""}${/^https?:\/\//i.test(jump) ? `data-jump-url="${escapeHtml(jump)}" ` : ""}href="${escapeHtml(docHref(site.entries, id, true))}`;
|
|
265
265
|
});
|
|
266
|
-
/** Easy download offers the page's own Markdown
|
|
266
|
+
/** Easy download offers the page's own Markdown above its content. */
|
|
267
267
|
const pageDownload = (site, entry) => {
|
|
268
268
|
const file = entry.sourceFile ?? CONTENT_PREFIX + entry.file;
|
|
269
269
|
const href = site.ctx.downloads?.get(file);
|
|
@@ -867,7 +867,6 @@ article { max-width: 860px; margin: 0 auto; font-family: var(--reader-font, syst
|
|
|
867
867
|
.codeblk-head .resource-download { width: 16px; height: 16px; border-radius: 6px; color: var(--doc-fg-3); }
|
|
868
868
|
.codeblk-head .resource-download svg { width: 14px; height: 14px; }
|
|
869
869
|
.doc-title > .resource-download { align-self: center; }
|
|
870
|
-
.doc-title:has(.toc-card) > h1 { display: inline-block; vertical-align: middle; }
|
|
871
870
|
.resource-download { display: inline-flex; flex: none; align-items: center; justify-content: center; box-sizing: border-box; width: 24px; height: 24px; border-radius: 4px; color: var(--doc-fg-2); text-decoration: none; }
|
|
872
871
|
.resource-download:hover { background: var(--doc-panel); color: var(--doc-accent); }
|
|
873
872
|
.resource-download:focus-visible { outline: 2px solid var(--doc-accent); outline-offset: 2px; }
|
|
@@ -1094,7 +1093,6 @@ article a { color: var(--doc-accent); }
|
|
|
1094
1093
|
.errors { border: 1px solid var(--doc-danger); border-radius: 8px; padding: 10px 16px;
|
|
1095
1094
|
margin-bottom: 16px; color: var(--doc-danger); font-size: 13px; }
|
|
1096
1095
|
.doc-title { display: flex; align-items: baseline; gap: 12px; max-width: calc(100% - 100px); padding-top: 8px; margin-bottom: 2px; }
|
|
1097
|
-
.doc-title > h1 { min-width: 0; margin: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
1098
1096
|
.in-toc { min-width: 28px; max-width: 100%; }
|
|
1099
1097
|
.toc-current { position: relative; display: block; max-width: min(240px, 100%); padding: 4px 20px 4px 6px;
|
|
1100
1098
|
overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 0; border-radius: 4px;
|
|
@@ -1114,7 +1112,6 @@ article a { color: var(--doc-accent); }
|
|
|
1114
1112
|
.in-toc .lvl6 a { padding-left: 60px; }
|
|
1115
1113
|
.in-toc a:hover, .in-toc a[aria-current] { color: var(--doc-accent); background: color-mix(in srgb, var(--doc-accent) 8%, transparent); }
|
|
1116
1114
|
.doc-title:has(.toc-card) { display: block; max-width: none; }
|
|
1117
|
-
.doc-title:has(.toc-card) > h1 { max-width: calc(100% - 100px); }
|
|
1118
1115
|
.toc-card { margin: 10px 0 14px; padding: 10px; border: 1px solid var(--doc-border); border-radius: 6px; }
|
|
1119
1116
|
.toc-card::before { content: attr(aria-label); display: block; margin: 0 10px 6px; color: var(--doc-fg-3); font: 12px/1.5 var(--font-sans); }
|
|
1120
1117
|
.toc-card .toc-current { display: none; }
|
|
@@ -1490,7 +1487,6 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1490
1487
|
.history-dialog li span { flex: 1; overflow-wrap: anywhere; }
|
|
1491
1488
|
.subformat-page-name { display: block; box-sizing: border-box; width: 100%; margin: 8px 0 20px; padding: 8px; color: var(--c-fg); background: var(--c-bg0); border: 1px solid var(--c-line); border-radius: 4px; font: inherit; }
|
|
1492
1489
|
.subformat-page .resource-query { flex-wrap: wrap; max-width: none; }
|
|
1493
|
-
.subformat-page-title { flex: 1 1 100%; margin: 0 0 12px; color: var(--c-fg); font: 500 24px/1.3 var(--font-sans); overflow-wrap: anywhere; }
|
|
1494
1490
|
.subformat-page .resource-toolbar { align-items: flex-end; }
|
|
1495
1491
|
.subformat-page .subformat-columns { padding-top: 20px; }
|
|
1496
1492
|
body:not(.edit) .subformat-page { padding-top: 64px; }
|
|
@@ -3317,11 +3313,11 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3317
3313
|
const entryMain = (site, e) => {
|
|
3318
3314
|
if (e.url && /^https?:\/\//i.test(e.url)) {
|
|
3319
3315
|
const title = docDisplayName(e.frontmatter, e.id);
|
|
3320
|
-
return `<article><
|
|
3316
|
+
return `<article><section class="document-web" data-web-url="${escapeHtml(e.url)}" data-title="${escapeHtml(title)}"><div class="document-web-tools"><span>${escapeHtml(e.url)}</span><a href="${escapeHtml(e.url)}" data-web-open data-i18n="Open externally">Open externally</a></div><p data-web-status role="status" data-i18n="Loading website…">Loading website…</p></section></article>`;
|
|
3321
3317
|
}
|
|
3322
3318
|
if (e.url && pageUrlKind(e.url) === "file")
|
|
3323
3319
|
return (linkedFilePage(site, e.url)?.main ??
|
|
3324
|
-
`<article><
|
|
3320
|
+
`<article><p role="alert">File not found: ${escapeHtml(e.url)}</p></article>`);
|
|
3325
3321
|
const html = renderEntryHtml(site, e).html;
|
|
3326
3322
|
const kids = childrenOf(site.entries, e.id);
|
|
3327
3323
|
if (e.subformat || e.library || e.blocks.length > 0 || kids.length === 0) {
|
|
@@ -3369,7 +3365,7 @@ ${opts.publish ? `${opts.publish.pages}<script>${publishRouterScript(opts.publis
|
|
|
3369
3365
|
...(site.workspace
|
|
3370
3366
|
? {
|
|
3371
3367
|
workspaceLabel: site.workspace.protocol === "git"
|
|
3372
|
-
?
|
|
3368
|
+
? site.workspace.branch
|
|
3373
3369
|
: site.workspace.folder,
|
|
3374
3370
|
}
|
|
3375
3371
|
: {}),
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "version",
|
|
3
|
-
"Unsaved drafts": "Unsaved drafts",
|
|
4
|
-
"Choose an unsaved draft": "Choose an unsaved draft",
|
|
5
3
|
"Read-only version": "Read-only version",
|
|
6
4
|
"Site title": "Site title",
|
|
7
5
|
"Edit site title": "Edit site title",
|
|
@@ -63,7 +61,6 @@
|
|
|
63
61
|
"Open sidebar": "Open sidebar",
|
|
64
62
|
"Create": "Create",
|
|
65
63
|
"Unsaved changes": "Unsaved changes",
|
|
66
|
-
"Modified (waiting for auto-save)": "Modified (waiting for auto-save)",
|
|
67
64
|
"Enter to rename / Esc to cancel (file links follow)": "Enter to rename / Esc to cancel (file links follow)",
|
|
68
65
|
"Icon must be svg": "Icon must be svg",
|
|
69
66
|
"Change site icon": "Change site icon",
|
|
@@ -78,8 +75,6 @@
|
|
|
78
75
|
"Light": "Light",
|
|
79
76
|
"Dark": "Dark",
|
|
80
77
|
"Theme": "Theme",
|
|
81
|
-
"Saved {time}": "Saved {time}",
|
|
82
|
-
"Saved (validation errors: {count})": "Saved (validation errors: {count})",
|
|
83
78
|
"Failed to save: {error}": "Failed to save: {error}",
|
|
84
79
|
"Delete \"{file}\"? (this cannot be undone)": "Delete \"{file}\" and all its translations? (this cannot be undone)",
|
|
85
80
|
"Failed to delete: {error}": "Failed to delete: {error}",
|
|
@@ -243,7 +238,6 @@
|
|
|
243
238
|
"Organize files": "Organize files",
|
|
244
239
|
"Auto-save paused": "Auto-save paused",
|
|
245
240
|
"Reload failed": "Reload failed",
|
|
246
|
-
"Waiting for auto-save": "Waiting for auto-save",
|
|
247
241
|
"Conflict unresolved. Auto-save is paused; your edits are kept.": "Conflict unresolved. Auto-save is paused; your edits are kept.",
|
|
248
242
|
"File not found — editing will create it automatically.": "File not found — editing will create it automatically.",
|
|
249
243
|
"Play": "Play",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "バージョン",
|
|
3
|
-
"Unsaved drafts": "未保存の下書き",
|
|
4
|
-
"Choose an unsaved draft": "下書きを選択",
|
|
5
3
|
"Read-only version": "閲覧専用のバージョン",
|
|
6
4
|
"Site title": "サイト名",
|
|
7
5
|
"Edit site title": "サイト名を編集",
|
|
@@ -63,7 +61,6 @@
|
|
|
63
61
|
"Open sidebar": "サイドバーを開く",
|
|
64
62
|
"Create": "作成",
|
|
65
63
|
"Unsaved changes": "未保存の変更",
|
|
66
|
-
"Modified (waiting for auto-save)": "変更あり(自動保存待ち)",
|
|
67
64
|
"Enter to rename / Esc to cancel (file links follow)": "Enterで名前を変更 / Escでキャンセル(文書リンクも更新)",
|
|
68
65
|
"Icon must be svg": "アイコンにはSVGを指定してください",
|
|
69
66
|
"Change site icon": "サイトアイコンを変更",
|
|
@@ -78,8 +75,6 @@
|
|
|
78
75
|
"Light": "ライト",
|
|
79
76
|
"Dark": "ダーク",
|
|
80
77
|
"Theme": "テーマ",
|
|
81
|
-
"Saved {time}": "保存しました {time}",
|
|
82
|
-
"Saved (validation errors: {count})": "保存しました(検証エラー: {count}件)",
|
|
83
78
|
"Failed to save: {error}": "保存できませんでした: {error}",
|
|
84
79
|
"Delete \"{file}\"? (this cannot be undone)": "「{file}」とすべての言語版を削除しますか?(元に戻せません)",
|
|
85
80
|
"Failed to delete: {error}": "削除できませんでした: {error}",
|
|
@@ -243,7 +238,6 @@
|
|
|
243
238
|
"Organize files": "ファイルを整理",
|
|
244
239
|
"Auto-save paused": "自動保存を停止中",
|
|
245
240
|
"Reload failed": "再読み込みに失敗",
|
|
246
|
-
"Waiting for auto-save": "自動保存を待機中",
|
|
247
241
|
"Conflict unresolved. Auto-save is paused; your edits are kept.": "競合が未解決のため自動保存を停止しています。編集内容は保持されています。",
|
|
248
242
|
"File not found — editing will create it automatically.": "ファイルがありません。編集すると自動的に作成されます。",
|
|
249
243
|
"Play": "再生",
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "版本",
|
|
3
|
-
"Unsaved drafts": "未保存的草稿",
|
|
4
|
-
"Choose an unsaved draft": "选择未保存的草稿",
|
|
5
3
|
"Read-only version": "只读版本",
|
|
6
4
|
"Site title": "站点名称",
|
|
7
5
|
"Edit site title": "编辑站点名称",
|
|
@@ -63,7 +61,6 @@
|
|
|
63
61
|
"Open sidebar": "展开侧边栏",
|
|
64
62
|
"Create": "创建",
|
|
65
63
|
"Unsaved changes": "未保存的更改",
|
|
66
|
-
"Modified (waiting for auto-save)": "已修改(等待自动保存)",
|
|
67
64
|
"Enter to rename / Esc to cancel (file links follow)": "Enter重命名 / Esc取消(文档链接将同步更新)",
|
|
68
65
|
"Icon must be svg": "图标必须为SVG格式",
|
|
69
66
|
"Change site icon": "更换站点图标",
|
|
@@ -78,8 +75,6 @@
|
|
|
78
75
|
"Light": "浅色",
|
|
79
76
|
"Dark": "深色",
|
|
80
77
|
"Theme": "主题",
|
|
81
|
-
"Saved {time}": "已保存 {time}",
|
|
82
|
-
"Saved (validation errors: {count})": "已保存(验证错误:{count})",
|
|
83
78
|
"Failed to save: {error}": "保存失败:{error}",
|
|
84
79
|
"Delete \"{file}\"? (this cannot be undone)": "删除“{file}”及其所有翻译?(此操作无法撤销)",
|
|
85
80
|
"Failed to delete: {error}": "删除失败:{error}",
|
|
@@ -243,7 +238,6 @@
|
|
|
243
238
|
"Organize files": "整理文件",
|
|
244
239
|
"Auto-save paused": "自动保存已暂停",
|
|
245
240
|
"Reload failed": "重新加载失败",
|
|
246
|
-
"Waiting for auto-save": "等待自动保存",
|
|
247
241
|
"Conflict unresolved. Auto-save is paused; your edits are kept.": "冲突尚未解决,自动保存已暂停;您的编辑已保留。",
|
|
248
242
|
"File not found — editing will create it automatically.": "文件不存在;编辑后会自动创建。",
|
|
249
243
|
"Play": "播放",
|
|
@@ -34,5 +34,5 @@ export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<R
|
|
|
34
34
|
/** Library page: use each format's preview without the format picker. */
|
|
35
35
|
page?: boolean) => string;
|
|
36
36
|
/** A Library view shown as a site page: one block format, `urls` or `url-previews`. */
|
|
37
|
-
export declare const libraryPageHtml: (index: ResourceIndex, view: string,
|
|
37
|
+
export declare const libraryPageHtml: (index: ResourceIndex, view: string, _title: string) => string;
|
|
38
38
|
export {};
|
|
@@ -323,28 +323,27 @@ page = false) => {
|
|
|
323
323
|
: "";
|
|
324
324
|
const selectedChange = index.subformats[0] && subformatChange(index.subformats[0]);
|
|
325
325
|
const filter = pageTitle !== undefined
|
|
326
|
-
?
|
|
326
|
+
? ""
|
|
327
327
|
: subformatsOnly
|
|
328
328
|
? `<div class="subformat-picker">${selector}<button type="button" data-subformat-trigger aria-haspopup="menu" aria-expanded="false"${selectedChange ? ` data-subformat-change="${selectedChange}"` : ""}>${escapeHtml(filterGroups[0] ?? "Subformats")}</button><div class="subformat-picker-menu" data-subformat-options popover="auto" role="menu" aria-label="Subformats" data-i18n-aria-label="Subformats"></div></div>`
|
|
329
329
|
: selector;
|
|
330
330
|
const search = `<label class="resource-search"><svg width="13" height="13" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" aria-hidden="true"><path d="${SEARCH_ICON_PATH}"/></svg><input type="search" data-resource-search placeholder="Search resources" aria-label="Search resources" data-i18n-placeholder="Search resources" data-i18n-aria-label="Search resources"></label>`;
|
|
331
|
+
const toolbar = `<div class="resource-toolbar">${subformatsOnly ? (filter ? `<div class="resource-query">${filter}</div>` : "") : `${page ? "" : '<span data-i18n="Name">Name</span>'}${search}${filter}`}${subformatsOnly ? "" : `<span class="resource-count" data-resource-count role="status" aria-live="polite">${items.length}</span>`}</div>`;
|
|
331
332
|
const subformats = subformatsOnly || (view === "codeblocks" && index.subformats.length)
|
|
332
333
|
? `<template data-subformats>${escapeHtml(JSON.stringify(index.subformats))}</template><div data-subformat-board role="region" hidden></div>${relations ? `<div data-subformat-relations hidden>${blocksHtml([{ type: "schemaGraph", graph: relations }])}</div>` : ""}`
|
|
333
334
|
: "";
|
|
334
335
|
const emptyMessage = subformatsOnly && !index.subformats.length
|
|
335
336
|
? "No subformats configured. Add subformats to dooc.yaml."
|
|
336
337
|
: "No matching resources";
|
|
337
|
-
return `<section class="resource-results" data-resource-results${page ? " data-resource-page" : ""}${pageTitle !== undefined ? ` data-subformat-page="${escapeHtml(index.subformats[0]?.ext ?? "")}"` : ""}
|
|
338
|
+
return `<section class="resource-results" data-resource-results${page ? " data-resource-page" : ""}${pageTitle !== undefined ? ` data-subformat-page="${escapeHtml(index.subformats[0]?.ext ?? "")}"` : ""}>${toolbar}${subformats}${index.errors.length && !page ? `<details class="resource-errors"><summary><span data-i18n="Files with errors">Files with errors</span> (${index.errors.length})</summary><ul>${index.errors.map((error) => `<li>${escapeHtml(error)}</li>`).join("")}</ul></details>` : ""}<div class="resource-items resource-${view}">${items.join("")}</div><p class="resource-empty" data-resource-empty${items.length ? " hidden" : ""} data-i18n="${emptyMessage}">${emptyMessage}</p></section>`;
|
|
338
339
|
};
|
|
339
340
|
/** A Library view shown as a site page: one block format, `urls` or `url-previews`. */
|
|
340
|
-
export const libraryPageHtml = (index, view,
|
|
341
|
-
const heading = `<h1 class="subformat-page-title">${escapeHtml(title)}</h1>`;
|
|
341
|
+
export const libraryPageHtml = (index, view, _title) => {
|
|
342
342
|
if (view === "urls" || view === "url-previews")
|
|
343
|
-
return
|
|
344
|
-
return (
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
}, "codeblocks", undefined, true));
|
|
343
|
+
return resourceLibraryHtml({ ...index, subformats: [] }, view, undefined, true);
|
|
344
|
+
return resourceLibraryHtml({
|
|
345
|
+
...index,
|
|
346
|
+
subformats: [],
|
|
347
|
+
codeblocks: index.codeblocks.filter((item) => item.format === view),
|
|
348
|
+
}, "codeblocks", undefined, true);
|
|
350
349
|
};
|