@dooc-dev/dooc 0.0.7 → 0.0.9
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/LICENSE +21 -0
- package/README.md +16 -18
- package/dist/client.global.js +1 -0
- package/dist/code-worker.global.js +11 -11
- package/dist/code.global.js +75 -75
- package/dist/edit.global.js +234 -231
- package/dist/{compiler → engine/compiler}/bundle-urls.js +1 -4
- package/dist/{compiler → engine/compiler}/check-prose.d.ts +1 -1
- package/dist/{compiler → engine/compiler}/check-prose.js +1 -1
- package/dist/{compiler → engine/compiler}/check.js +15 -27
- package/dist/{compiler → engine/compiler}/code-blocks.js +3 -1
- package/dist/{compiler → engine/compiler}/code-languages.js +1 -2
- package/dist/{compiler → engine/compiler}/compile.d.ts +5 -4
- package/dist/{compiler → engine/compiler}/compile.js +91 -32
- package/dist/{compiler → engine/compiler}/config.js +1 -3
- package/dist/{compiler → engine/compiler}/dialect.d.ts +1 -3
- package/dist/{compiler → engine/compiler}/dialect.js +8 -52
- package/dist/{compiler → engine/compiler}/dxf.js +1 -1
- package/dist/{compiler → engine/compiler}/export.js +15 -8
- package/dist/{compiler → engine/compiler}/figures.js +26 -22
- package/dist/{compiler → engine/compiler}/file-cache.d.ts +1 -2
- package/dist/{compiler → engine/compiler}/file-cache.js +8 -15
- package/dist/{compiler → engine/compiler}/files.js +49 -38
- package/dist/{compiler → engine/compiler}/fonts.js +1 -3
- package/dist/{compiler → engine/compiler}/from-mdast.js +1 -1
- package/dist/engine/compiler/host.d.ts +10 -0
- package/dist/engine/compiler/host.js +16 -0
- package/dist/{compiler → engine/compiler}/icons.d.ts +3 -0
- package/dist/{compiler → engine/compiler}/icons.js +28 -10
- package/dist/{compiler → engine/compiler}/ignored-files.d.ts +2 -0
- package/dist/{compiler → engine/compiler}/ignored-files.js +12 -3
- package/dist/{compiler → engine/compiler}/locales.js +2 -8
- package/dist/{compiler → engine/compiler}/manifest.d.ts +3 -2
- package/dist/engine/compiler/manifest.js +46 -0
- package/dist/{compiler → engine/compiler}/ops.d.ts +4 -1
- package/dist/{compiler → engine/compiler}/ops.js +36 -21
- package/dist/engine/compiler/schema-file-references.d.ts +2 -0
- package/dist/engine/compiler/schema-file-references.js +82 -0
- package/dist/engine/compiler/serialize.d.ts +2 -0
- package/dist/engine/compiler/serialize.js +5 -0
- package/dist/{compiler → engine/compiler}/subformat-schema.js +1 -3
- package/dist/{compiler → engine/compiler}/subformats.d.ts +10 -0
- package/dist/{compiler → engine/compiler}/subformats.js +122 -18
- package/dist/{compiler → engine/compiler}/textfile-remote.js +1 -2
- package/dist/{compiler → engine/compiler}/textfile.js +4 -6
- package/dist/{compiler → engine/compiler}/theme-variants.js +1 -1
- package/dist/{compiler → engine/compiler}/zip.js +1 -1
- package/dist/{core → engine/core}/blocks.d.ts +6 -4
- package/dist/{core → engine/core}/content-metadata.d.ts +6 -1
- package/dist/{core → engine/core}/content-metadata.js +84 -18
- package/dist/{core → engine/core}/content-types.d.ts +4 -2
- package/dist/{core → engine/core}/html.d.ts +7 -0
- package/dist/{core → engine/core}/html.js +44 -3
- package/dist/{core → engine/core}/icons.d.ts +3 -0
- package/dist/engine/core/icons.js +20 -0
- package/dist/{core → engine/core}/routing.d.ts +2 -0
- package/dist/{core → engine/core}/routing.js +9 -0
- package/dist/{core → engine/core}/schema-refs.d.ts +1 -1
- package/dist/{core → engine/core}/schema-refs.js +3 -1
- package/dist/engine/core/subformat-references.d.ts +5 -0
- package/dist/engine/core/subformat-references.js +33 -0
- package/dist/{core → engine/core}/subformats.d.ts +7 -0
- package/dist/{core → engine/core}/subformats.js +5 -1
- package/dist/{core → engine/core}/taxonomy.d.ts +2 -3
- package/dist/{core → engine/core}/taxonomy.js +1 -5
- package/dist/flow.global.js +306 -306
- package/dist/frontend/application-request.d.ts +14 -0
- package/dist/frontend/application-request.js +36 -0
- package/dist/frontend/document-application.d.ts +200 -0
- package/dist/{viewer/serve.js → frontend/document-application.js} +1611 -1670
- package/dist/frontend/figure-preview.d.ts +4 -0
- package/dist/{viewer → frontend}/figure-preview.js +4 -4
- package/dist/{viewer → frontend}/file-references.d.ts +1 -1
- package/dist/{viewer → frontend}/file-references.js +3 -3
- package/dist/{viewer → frontend}/font-picker.d.ts +1 -1
- package/dist/{viewer → frontend}/font-settings.d.ts +1 -1
- package/dist/{viewer → frontend}/language-picker.js +112 -18
- package/dist/{viewer → frontend}/locales/eng.json +16 -2
- package/dist/{viewer → frontend}/locales/jpn.json +16 -2
- package/dist/{viewer → frontend}/locales/zho.json +16 -2
- package/dist/{viewer → frontend}/nav-focus.js +2 -0
- package/dist/{viewer → frontend}/plugin-blocks.js +2 -2
- package/dist/{viewer → frontend}/resize.js +14 -2
- package/dist/frontend/resource-download.d.ts +2 -0
- package/dist/frontend/resource-download.js +43 -0
- package/dist/{viewer → frontend}/resource-library.d.ts +9 -2
- package/dist/{viewer → frontend}/resource-library.js +133 -37
- package/dist/{core → frontend}/schema-graph-flow.d.ts +1 -1
- package/dist/{core → frontend}/schema-graph-flow.js +1 -1
- package/dist/{viewer → frontend}/search.d.ts +2 -2
- package/dist/{viewer → frontend}/search.js +26 -8
- package/dist/graph/schema-graph-global.js +17 -17
- package/dist/install.sh +68 -0
- package/dist/plugins.global.js +62 -62
- package/dist/{viewer → server}/assets.d.ts +2 -0
- package/dist/server/assets.js +7 -0
- package/dist/{viewer → server}/build-plugins.js +4 -4
- package/dist/{viewer → server}/build.d.ts +2 -1
- package/dist/{viewer → server}/build.js +31 -15
- package/dist/{cli.js → server/cli.js} +199 -66
- package/dist/server/editor-tools.d.ts +1 -0
- package/dist/server/editor-tools.js +1 -0
- package/dist/{viewer → server}/extension-pack.js +2 -2
- package/dist/{viewer → server}/extensions.d.ts +1 -1
- package/dist/{viewer → server}/extensions.js +3 -3
- package/dist/server/git-diff.d.ts +10 -0
- package/dist/{viewer → server}/git-diff.js +45 -10
- package/dist/server/git-origin.d.ts +4 -0
- package/dist/server/git-origin.js +103 -0
- package/dist/server/git.d.ts +9 -0
- package/dist/{viewer → server}/git.js +50 -6
- package/dist/server/history.d.ts +14 -0
- package/dist/server/history.js +205 -0
- package/dist/{viewer → server}/hmr.d.ts +0 -22
- package/dist/server/hmr.js +168 -0
- package/dist/server/index.d.ts +17 -0
- package/dist/{index.js → server/index.js} +16 -16
- package/dist/{viewer → server}/ja-lint.d.ts +1 -1
- package/dist/{viewer → server}/languages.d.ts +1 -1
- package/dist/{viewer → server}/languages.js +3 -3
- package/dist/{mcp.d.ts → server/mcp.d.ts} +2 -2
- package/dist/{mcp.js → server/mcp.js} +60 -21
- package/dist/{viewer → server}/plugin-config.d.ts +2 -2
- package/dist/{viewer → server}/plugin-config.js +2 -2
- package/dist/{plugins → server/plugins}/local-storage.d.ts +1 -1
- package/dist/{plugins → server/plugins}/local-storage.js +1 -1
- package/dist/{plugins → server/plugins}/runtime.d.ts +4 -4
- package/dist/{plugins → server/plugins}/runtime.js +4 -4
- package/dist/{viewer → server}/plugins.d.ts +3 -3
- package/dist/{viewer → server}/plugins.js +14 -13
- package/dist/server/resource-library.d.ts +1 -0
- package/dist/server/resource-library.js +1 -0
- package/dist/server/self.d.ts +5 -0
- package/dist/server/self.js +98 -0
- package/dist/server/serve.d.ts +61 -0
- package/dist/server/serve.js +503 -0
- package/dist/server/static-client.d.ts +4 -0
- package/dist/server/static-client.js +117 -0
- package/dist/server/workspace-server.d.ts +16 -0
- package/dist/server/workspace-server.js +266 -0
- package/dist/{viewer → server}/workspace.d.ts +6 -1
- package/dist/{viewer → server}/workspace.js +46 -0
- package/dist/subformats.global.js +92 -6
- package/dist/ui.global.js +85 -72
- package/dist/workspace/client.d.ts +13 -0
- package/dist/workspace/client.js +114 -0
- package/dist/{viewer → workspace}/code-file.d.ts +1 -1
- package/dist/{viewer → workspace}/code-file.js +7 -7
- package/dist/workspace/connection.d.ts +27 -0
- package/dist/workspace/connection.js +38 -0
- package/dist/{viewer → workspace}/editor-tools.d.ts +7 -1
- package/dist/{viewer → workspace}/editor-tools.js +12 -9
- package/dist/{viewer → workspace}/git-types.d.ts +7 -0
- package/dist/workspace/github.d.ts +4 -0
- package/dist/workspace/github.js +99 -0
- package/dist/workspace/history.d.ts +46 -0
- package/dist/workspace/history.js +86 -0
- package/dist/workspace/protocol.d.ts +38 -0
- package/dist/workspace/protocol.js +20 -0
- package/dist/workspace/resource-download.d.ts +1 -0
- package/dist/workspace/resource-download.js +8 -0
- package/dist/workspace/server.d.ts +9 -0
- package/dist/workspace/server.js +48 -0
- package/dist/{viewer → workspace}/site-icon.js +9 -10
- package/dist/{viewer → workspace}/site-title.js +6 -7
- package/dist/{viewer → workspace}/textfile.d.ts +1 -1
- package/dist/{viewer → workspace}/textfile.js +5 -5
- package/dist/workspace-worker.global.js +2859 -0
- package/package.json +35 -20
- package/dist/compiler/manifest.js +0 -37
- package/dist/compiler/serialize.d.ts +0 -3
- package/dist/compiler/serialize.js +0 -16
- package/dist/core/icons.js +0 -5
- package/dist/index.d.ts +0 -17
- package/dist/viewer/assets.js +0 -3
- package/dist/viewer/figure-preview.d.ts +0 -4
- package/dist/viewer/git-diff.d.ts +0 -6
- package/dist/viewer/git.d.ts +0 -5
- package/dist/viewer/hmr.js +0 -341
- package/dist/viewer/serve.d.ts +0 -216
- /package/dist/{compiler → engine/compiler}/asset-references.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/asset-references.js +0 -0
- /package/dist/{compiler → engine/compiler}/bundle-urls.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/check-types.js +0 -0
- /package/dist/{compiler → engine/compiler}/check.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-blocks.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/code-languages.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/config.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/drawio.js +0 -0
- /package/dist/{compiler → engine/compiler}/dxf.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/export.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/figures.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/files.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/fonts.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/format.js +0 -0
- /package/dist/{compiler → engine/compiler}/from-mdast.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/language-codes.js +0 -0
- /package/dist/{compiler → engine/compiler}/locales.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/public-file.js +0 -0
- /package/dist/{compiler → engine/compiler}/subformat-schema.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/terms.js +0 -0
- /package/dist/{compiler → engine/compiler}/textfile-remote.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/textfile.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/theme-variants.d.ts +0 -0
- /package/dist/{compiler → engine/compiler}/zip.d.ts +0 -0
- /package/dist/{core → engine/core}/blocks.js +0 -0
- /package/dist/{core → engine/core}/code-file.d.ts +0 -0
- /package/dist/{core → engine/core}/code-file.js +0 -0
- /package/dist/{core → engine/core}/code-grammars.d.ts +0 -0
- /package/dist/{core → engine/core}/code-grammars.js +0 -0
- /package/dist/{core → engine/core}/content-types.js +0 -0
- /package/dist/{core → engine/core}/escape-html.d.ts +0 -0
- /package/dist/{core → engine/core}/escape-html.js +0 -0
- /package/dist/{core → engine/core}/extension-package.d.ts +0 -0
- /package/dist/{core → engine/core}/extension-package.js +0 -0
- /package/dist/{core → engine/core}/figure-frame.d.ts +0 -0
- /package/dist/{core → engine/core}/figure-frame.js +0 -0
- /package/dist/{core → engine/core}/file-embed.d.ts +0 -0
- /package/dist/{core → engine/core}/file-embed.js +0 -0
- /package/dist/{core → engine/core}/files.d.ts +0 -0
- /package/dist/{core → engine/core}/files.js +0 -0
- /package/dist/{core → engine/core}/graph-common.d.ts +0 -0
- /package/dist/{core → engine/core}/graph-common.js +0 -0
- /package/dist/{core → engine/core}/graph.d.ts +0 -0
- /package/dist/{core → engine/core}/graph.js +0 -0
- /package/dist/{core → engine/core}/inline.d.ts +0 -0
- /package/dist/{core → engine/core}/inline.js +0 -0
- /package/dist/{core → engine/core}/json-tools.d.ts +0 -0
- /package/dist/{core → engine/core}/json-tools.js +0 -0
- /package/dist/{core → engine/core}/language.d.ts +0 -0
- /package/dist/{core → engine/core}/language.js +0 -0
- /package/dist/{core → engine/core}/languages/ja.d.ts +0 -0
- /package/dist/{core → engine/core}/languages/ja.js +0 -0
- /package/dist/{core → engine/core}/markdown.d.ts +0 -0
- /package/dist/{core → engine/core}/markdown.js +0 -0
- /package/dist/{core → engine/core}/previewers.d.ts +0 -0
- /package/dist/{core → engine/core}/previewers.js +0 -0
- /package/dist/{core → engine/core}/schema-comments.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-comments.js +0 -0
- /package/dist/{core → engine/core}/schema-fields.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-fields.js +0 -0
- /package/dist/{core → engine/core}/schema-graph.d.ts +0 -0
- /package/dist/{core → engine/core}/schema-graph.js +0 -0
- /package/dist/{core → engine/core}/subformat-record.d.ts +0 -0
- /package/dist/{core → engine/core}/subformat-record.js +0 -0
- /package/dist/{core → engine/core}/term-reference.d.ts +0 -0
- /package/dist/{core → engine/core}/term-reference.js +0 -0
- /package/dist/{core → engine/core}/textfile.d.ts +0 -0
- /package/dist/{core → engine/core}/textfile.js +0 -0
- /package/dist/{core → engine/core}/theme-variants.d.ts +0 -0
- /package/dist/{core → engine/core}/theme-variants.js +0 -0
- /package/dist/{core → engine/core}/workspace.d.ts +0 -0
- /package/dist/{core → engine/core}/workspace.js +0 -0
- /package/dist/{viewer → frontend}/bundle-network.d.ts +0 -0
- /package/dist/{viewer → frontend}/bundle-network.js +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.d.ts +0 -0
- /package/dist/{core → frontend}/flow-base-css.generated.js +0 -0
- /package/dist/{core → frontend}/flow-css.d.ts +0 -0
- /package/dist/{core → frontend}/flow-css.js +0 -0
- /package/dist/{viewer → frontend}/font-picker.js +0 -0
- /package/dist/{viewer → frontend}/font-settings.js +0 -0
- /package/dist/{viewer → frontend}/i18n.d.ts +0 -0
- /package/dist/{viewer → frontend}/i18n.js +0 -0
- /package/dist/{viewer → frontend}/language-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.d.ts +0 -0
- /package/dist/{viewer → frontend}/lazy-preview.js +0 -0
- /package/dist/{viewer → frontend}/nav-focus.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.d.ts +0 -0
- /package/dist/{viewer → frontend}/nav-update.js +0 -0
- /package/dist/{viewer → frontend}/plugin-blocks.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-style.js +0 -0
- /package/dist/{viewer → frontend}/plugin-view.d.ts +0 -0
- /package/dist/{viewer → frontend}/plugin-view.js +0 -0
- /package/dist/{viewer → frontend}/resize.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.d.ts +0 -0
- /package/dist/{core → frontend}/schema-graph-mount.js +0 -0
- /package/dist/{core → frontend}/table-ui.d.ts +0 -0
- /package/dist/{core → frontend}/table-ui.js +0 -0
- /package/dist/{core → frontend}/terms-ui.d.ts +0 -0
- /package/dist/{core → frontend}/terms-ui.js +0 -0
- /package/dist/{viewer → frontend}/theme-picker.d.ts +0 -0
- /package/dist/{viewer → frontend}/theme-picker.js +0 -0
- /package/dist/{core → frontend}/toc-ui.d.ts +0 -0
- /package/dist/{core → frontend}/toc-ui.js +0 -0
- /package/dist/{core → frontend}/video-ui.d.ts +0 -0
- /package/dist/{core → frontend}/video-ui.js +0 -0
- /package/dist/{viewer → server}/build-plugins.d.ts +0 -0
- /package/dist/{cli.d.ts → server/cli.d.ts} +0 -0
- /package/dist/{viewer → server}/extension-pack.d.ts +0 -0
- /package/dist/{viewer → server}/fonts/LICENSE.txt +0 -0
- /package/dist/{viewer → server}/fonts/udev-gothic-regular.woff2 +0 -0
- /package/dist/{viewer → server}/fonts.d.ts +0 -0
- /package/dist/{viewer → server}/fonts.js +0 -0
- /package/dist/{viewer → server}/ja-lint.js +0 -0
- /package/dist/{viewer → workspace}/git-types.js +0 -0
- /package/dist/{viewer → workspace}/site-icon.d.ts +0 -0
- /package/dist/{viewer → workspace}/site-title.d.ts +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FigureEntry } from "../engine/core/content-types.js";
|
|
2
|
+
export declare const deferredFigureHtml: (fig: FigureEntry, cls?: string, label?: string) => string;
|
|
3
|
+
/** Delegated so previews inserted by navigation or HMR use the same loading state. */
|
|
4
|
+
export declare function mountFigurePreviews(request?: (url: string, init?: RequestInit, workspace?: string) => Promise<Response>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { escapeHtml } from "../core/escape-html.js";
|
|
2
|
-
import { figureFrameHtml } from "../core/figure-frame.js";
|
|
1
|
+
import { escapeHtml } from "../engine/core/escape-html.js";
|
|
2
|
+
import { figureFrameHtml } from "../engine/core/figure-frame.js";
|
|
3
3
|
export const deferredFigureHtml = (fig, cls = "fig-frame", label) => {
|
|
4
4
|
if (fig.markup.length <= 100_000)
|
|
5
5
|
return figureFrameHtml(fig, cls, label);
|
|
@@ -9,7 +9,7 @@ export const deferredFigureHtml = (fig, cls = "fig-frame", label) => {
|
|
|
9
9
|
return `<div class="figure-placeholder" data-figure-preview="${escapeHtml(url)}"><span>${escapeHtml(label || fig.title || fig.file)}</span><button type="button" data-i18n="Load preview">Load preview</button><span role="status"></span></div>`;
|
|
10
10
|
};
|
|
11
11
|
/** Delegated so previews inserted by navigation or HMR use the same loading state. */
|
|
12
|
-
export function mountFigurePreviews() {
|
|
12
|
+
export function mountFigurePreviews(request = fetch) {
|
|
13
13
|
document.addEventListener("click", async (event) => {
|
|
14
14
|
const button = event.target instanceof Element
|
|
15
15
|
? event.target.closest("[data-figure-preview] > button")
|
|
@@ -24,7 +24,7 @@ export function mountFigurePreviews() {
|
|
|
24
24
|
host.setAttribute("aria-busy", "true");
|
|
25
25
|
status.textContent = translate("Loading");
|
|
26
26
|
try {
|
|
27
|
-
const response = await
|
|
27
|
+
const response = await request(url, undefined, host.closest("[data-workspace]")?.dataset.workspace);
|
|
28
28
|
if (!response.ok)
|
|
29
29
|
throw new Error(translate("Preview unavailable"));
|
|
30
30
|
const html = await response.text();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit";
|
|
2
|
-
import { parseFileEmbed } from "../core/file-embed.js";
|
|
3
|
-
import { contentLinks, embeddedImages, parseMdast } from "../core/markdown.js";
|
|
4
|
-
import { parseTermReference } from "../core/term-reference.js";
|
|
2
|
+
import { parseFileEmbed } from "../engine/core/file-embed.js";
|
|
3
|
+
import { contentLinks, embeddedImages, parseMdast } from "../engine/core/markdown.js";
|
|
4
|
+
import { parseTermReference } from "../engine/core/term-reference.js";
|
|
5
5
|
/** Use the compiler's Markdown grammar so examples, escapes and URL encodings agree. */
|
|
6
6
|
export const fileReferences = (body, settings) => {
|
|
7
7
|
const root = parseMdast(body);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectFont } from "../compiler/fonts.js";
|
|
1
|
+
import type { ProjectFont } from "../engine/compiler/fonts.js";
|
|
2
2
|
import type { createFontSettings } from "./font-settings.js";
|
|
3
3
|
/** Self-contained because published viewers embed this function directly. */
|
|
4
4
|
export declare const mountFontPickers: (createSettings: typeof createFontSettings, registered: readonly ProjectFont[]) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ProjectFont } from "../compiler/fonts.js";
|
|
1
|
+
import type { ProjectFont } from "../engine/compiler/fonts.js";
|
|
2
2
|
/** Self-contained because published viewers embed this function directly. */
|
|
3
3
|
export declare const createFontSettings: (registered: readonly ProjectFont[]) => {
|
|
4
4
|
fonts: Map<string, FontFace>;
|
|
@@ -1,24 +1,43 @@
|
|
|
1
|
+
const fitWorkspaceLabel = (input, label) => {
|
|
2
|
+
input.title = label;
|
|
3
|
+
input.value = label;
|
|
4
|
+
const context = document.createElement("canvas").getContext("2d");
|
|
5
|
+
if (!context)
|
|
6
|
+
return;
|
|
7
|
+
const style = getComputedStyle(input);
|
|
8
|
+
context.font = style.font;
|
|
9
|
+
const width = input.clientWidth - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight);
|
|
10
|
+
const characters = [...label];
|
|
11
|
+
if (context.measureText(label).width > width) {
|
|
12
|
+
while (characters.length && context.measureText(`${characters.join("")}...`).width > width)
|
|
13
|
+
characters.pop();
|
|
14
|
+
input.value = `${characters.join("")}...`;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
1
17
|
/** Keep the native select as the value and change-event source. */
|
|
2
18
|
export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-lang, #ui-language")) => {
|
|
3
19
|
const disposers = [];
|
|
4
20
|
for (const select of selects) {
|
|
5
21
|
const translations = select.id === "fm-lang";
|
|
22
|
+
const workspace = select.hasAttribute("data-workspace-pane");
|
|
6
23
|
const trigger = select
|
|
7
24
|
.closest(".fm-language")
|
|
8
25
|
?.querySelector("[data-language-open]");
|
|
9
26
|
const wrapper = document.createElement("div");
|
|
10
|
-
wrapper.className =
|
|
27
|
+
wrapper.className = `language-select${workspace ? " workspace-select" : ""}`;
|
|
11
28
|
const popup = document.createElement("div");
|
|
12
|
-
popup.className =
|
|
29
|
+
popup.className = `language-picker${workspace ? " workspace-picker" : ""}`;
|
|
13
30
|
popup.id = `${select.id}-picker`;
|
|
14
31
|
popup.popover = "manual";
|
|
15
32
|
const input = document.createElement("input");
|
|
16
33
|
input.type = "text";
|
|
17
|
-
input.className =
|
|
34
|
+
input.className = `language-select-input${workspace ? " workspace-picker-input" : ""}`;
|
|
35
|
+
if (workspace)
|
|
36
|
+
input.id = `${select.id}-input`;
|
|
18
37
|
input.autocomplete = "off";
|
|
19
38
|
input.spellcheck = false;
|
|
20
39
|
input.setAttribute("role", "combobox");
|
|
21
|
-
input.setAttribute("aria-autocomplete", "list");
|
|
40
|
+
input.setAttribute("aria-autocomplete", workspace ? "none" : "list");
|
|
22
41
|
input.setAttribute("aria-haspopup", "listbox");
|
|
23
42
|
input.setAttribute("aria-expanded", "false");
|
|
24
43
|
const list = document.createElement("div");
|
|
@@ -44,11 +63,14 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
44
63
|
const selectedText = () => select.selectedOptions[0]?.text ?? "";
|
|
45
64
|
const position = () => {
|
|
46
65
|
const rect = input.getBoundingClientRect();
|
|
66
|
+
const width = workspace
|
|
67
|
+
? Math.min(Math.max(rect.width, 280), innerWidth - 16)
|
|
68
|
+
: rect.width;
|
|
47
69
|
const below = innerHeight - rect.bottom;
|
|
48
70
|
const above = below < 240 && rect.top > below;
|
|
49
71
|
Object.assign(popup.style, {
|
|
50
|
-
width: `${
|
|
51
|
-
left: `${rect.left}px`,
|
|
72
|
+
width: `${width}px`,
|
|
73
|
+
left: `${workspace ? Math.max(8, Math.min(rect.left + (rect.width - width) / 2, innerWidth - width - 8)) : rect.left}px`,
|
|
52
74
|
maxHeight: `${Math.max(80, Math.min(360, (above ? rect.top : below) - 12))}px`,
|
|
53
75
|
top: above ? "auto" : `${rect.bottom + 4}px`,
|
|
54
76
|
bottom: above ? `${innerHeight - rect.top + 4}px` : "auto",
|
|
@@ -70,12 +92,16 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
70
92
|
input.removeAttribute("aria-activedescendant");
|
|
71
93
|
};
|
|
72
94
|
const render = () => {
|
|
95
|
+
const highlighted = workspace && isOpen()
|
|
96
|
+
? list.querySelector('[data-active="true"]')?.dataset.value
|
|
97
|
+
: undefined;
|
|
73
98
|
const words = query.normalize("NFKC").toLowerCase().trim().split(/\s+/).filter(Boolean);
|
|
74
99
|
const fragment = document.createDocumentFragment();
|
|
75
100
|
let selected = 0;
|
|
101
|
+
let preserved;
|
|
76
102
|
let count = 0;
|
|
77
103
|
for (const [i, option] of [...select.options].entries()) {
|
|
78
|
-
if (option.disabled ||
|
|
104
|
+
if ((!workspace && option.disabled) ||
|
|
79
105
|
!words.every((word) => option.text.normalize("NFKC").toLowerCase().includes(word)))
|
|
80
106
|
continue;
|
|
81
107
|
const item = document.createElement("button");
|
|
@@ -84,6 +110,25 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
84
110
|
item.id = `${select.id}-option-${i}`;
|
|
85
111
|
item.dataset.value = option.value;
|
|
86
112
|
item.textContent = item.title = option.text;
|
|
113
|
+
if (workspace) {
|
|
114
|
+
item.dataset.change = option.dataset.change ?? "";
|
|
115
|
+
if (option.dataset.create)
|
|
116
|
+
item.dataset.create = option.dataset.create;
|
|
117
|
+
item.setAttribute("aria-disabled", String(select.disabled || option.disabled));
|
|
118
|
+
if (option.disabled) {
|
|
119
|
+
const reason = option.dataset.unavailable || option.title || option.text;
|
|
120
|
+
item.dataset.unavailable = item.title = reason;
|
|
121
|
+
item.setAttribute("aria-description", reason);
|
|
122
|
+
const label = document.createElement("span");
|
|
123
|
+
label.textContent = option.text;
|
|
124
|
+
const info = document.createElement("span");
|
|
125
|
+
info.className = "workspace-unavailable-icon";
|
|
126
|
+
info.setAttribute("aria-hidden", "true");
|
|
127
|
+
info.innerHTML =
|
|
128
|
+
'<svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" aria-hidden="true"><circle cx="10" cy="10" r="7"/><path d="M10 9v5M10 6.5h.01"/></svg>';
|
|
129
|
+
item.replaceChildren(label, info);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
87
132
|
item.disabled = select.disabled;
|
|
88
133
|
item.setAttribute("role", "option");
|
|
89
134
|
item.setAttribute("aria-selected", translations ? (option.dataset.added ?? "false") : String(option.selected));
|
|
@@ -102,26 +147,44 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
102
147
|
}
|
|
103
148
|
if (option.selected)
|
|
104
149
|
selected = count;
|
|
150
|
+
if (option.value === highlighted)
|
|
151
|
+
preserved = count;
|
|
105
152
|
fragment.append(item);
|
|
106
153
|
count++;
|
|
107
154
|
}
|
|
108
155
|
list.replaceChildren(fragment);
|
|
109
156
|
empty.hidden = count > 0;
|
|
110
157
|
empty.textContent = t("No results");
|
|
111
|
-
highlight(selected);
|
|
158
|
+
highlight(preserved ?? selected);
|
|
112
159
|
};
|
|
113
160
|
const sync = () => {
|
|
114
161
|
input.title = selectedText();
|
|
115
|
-
input.readOnly = select.disabled;
|
|
162
|
+
input.readOnly = workspace || select.disabled;
|
|
163
|
+
if (workspace) {
|
|
164
|
+
wrapper.dataset.workspacePane = input.dataset.workspacePane =
|
|
165
|
+
select.dataset.workspacePane;
|
|
166
|
+
wrapper.dataset.active = input.dataset.active = select.dataset.active;
|
|
167
|
+
input.setAttribute("aria-current", String(select.dataset.active === "true"));
|
|
168
|
+
input.dataset.change = select.selectedOptions[0]?.dataset.change ?? "";
|
|
169
|
+
input.setAttribute("aria-description", selectedText());
|
|
170
|
+
if (select.disabled && isOpen())
|
|
171
|
+
popup.hidePopover();
|
|
172
|
+
}
|
|
116
173
|
if (trigger)
|
|
117
174
|
trigger.disabled = select.disabled;
|
|
118
175
|
input.setAttribute("aria-disabled", String(select.disabled));
|
|
119
|
-
input.placeholder =
|
|
176
|
+
input.placeholder = workspace
|
|
177
|
+
? ""
|
|
178
|
+
: (select.dataset.placeholder ?? t("Search languages"));
|
|
120
179
|
input.setAttribute("aria-label", select.getAttribute("aria-label") ?? t("Language"));
|
|
121
180
|
if (translations)
|
|
122
181
|
input.setAttribute("aria-description", t("Enter to edit; Ctrl+Enter to add or remove translation"));
|
|
123
|
-
if (!isOpen() || !query)
|
|
124
|
-
|
|
182
|
+
if (!isOpen() || !query) {
|
|
183
|
+
if (workspace)
|
|
184
|
+
fitWorkspaceLabel(input, selectedText());
|
|
185
|
+
else
|
|
186
|
+
input.value = selectedText();
|
|
187
|
+
}
|
|
125
188
|
if (isOpen())
|
|
126
189
|
render();
|
|
127
190
|
};
|
|
@@ -135,13 +198,19 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
135
198
|
}
|
|
136
199
|
else {
|
|
137
200
|
query = "";
|
|
138
|
-
|
|
201
|
+
if (workspace)
|
|
202
|
+
fitWorkspaceLabel(input, selectedText());
|
|
203
|
+
else
|
|
204
|
+
input.value = selectedText();
|
|
139
205
|
input.removeAttribute("aria-activedescendant");
|
|
140
206
|
}
|
|
141
207
|
});
|
|
142
208
|
const choose = (item) => {
|
|
143
209
|
if (!item || select.disabled)
|
|
144
210
|
return;
|
|
211
|
+
if (workspace &&
|
|
212
|
+
![...select.options].some((option) => option.value === item.dataset.value && !option.disabled))
|
|
213
|
+
return;
|
|
145
214
|
select.value = item.dataset.value ?? "";
|
|
146
215
|
if (!translations)
|
|
147
216
|
popup.hidePopover();
|
|
@@ -156,15 +225,23 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
156
225
|
const open = () => {
|
|
157
226
|
if (isOpen() || select.disabled)
|
|
158
227
|
return;
|
|
228
|
+
select.dispatchEvent(new Event("docs:picker-open"));
|
|
159
229
|
popup.showPopover();
|
|
160
|
-
|
|
230
|
+
if (!workspace)
|
|
231
|
+
input.select();
|
|
161
232
|
};
|
|
162
|
-
|
|
233
|
+
if (!workspace)
|
|
234
|
+
input.addEventListener("focus", open);
|
|
163
235
|
trigger?.addEventListener("click", () => {
|
|
164
236
|
input.focus();
|
|
165
237
|
open();
|
|
166
238
|
});
|
|
167
|
-
input.addEventListener("click",
|
|
239
|
+
input.addEventListener("click", () => {
|
|
240
|
+
if (workspace && isOpen())
|
|
241
|
+
popup.hidePopover();
|
|
242
|
+
else
|
|
243
|
+
open();
|
|
244
|
+
});
|
|
168
245
|
input.addEventListener("input", () => {
|
|
169
246
|
query = input.value;
|
|
170
247
|
if (isOpen())
|
|
@@ -182,7 +259,11 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
182
259
|
else
|
|
183
260
|
open();
|
|
184
261
|
}
|
|
185
|
-
else if (
|
|
262
|
+
else if (workspace && isOpen() && ["Home", "End"].includes(event.key)) {
|
|
263
|
+
event.preventDefault();
|
|
264
|
+
highlight(event.key === "Home" ? 0 : list.children.length - 1);
|
|
265
|
+
}
|
|
266
|
+
else if ((event.key === "Enter" || (workspace && event.key === " ")) && isOpen()) {
|
|
186
267
|
event.preventDefault();
|
|
187
268
|
const item = list.querySelector('[data-active="true"]');
|
|
188
269
|
if (translations && event.ctrlKey)
|
|
@@ -190,10 +271,15 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
190
271
|
else
|
|
191
272
|
choose(item);
|
|
192
273
|
}
|
|
274
|
+
else if (workspace && (event.key === "Enter" || event.key === " ")) {
|
|
275
|
+
event.preventDefault();
|
|
276
|
+
open();
|
|
277
|
+
}
|
|
193
278
|
else if (event.key === "Escape" && isOpen()) {
|
|
194
279
|
event.preventDefault();
|
|
195
280
|
popup.hidePopover();
|
|
196
|
-
|
|
281
|
+
if (!workspace)
|
|
282
|
+
input.select();
|
|
197
283
|
}
|
|
198
284
|
});
|
|
199
285
|
list.addEventListener("pointerdown", (event) => event.preventDefault());
|
|
@@ -220,10 +306,17 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
220
306
|
};
|
|
221
307
|
document.addEventListener("pointerdown", outside);
|
|
222
308
|
const resize = new ResizeObserver(() => {
|
|
309
|
+
if (workspace)
|
|
310
|
+
fitWorkspaceLabel(input, selectedText());
|
|
223
311
|
if (isOpen())
|
|
224
312
|
position();
|
|
225
313
|
});
|
|
226
314
|
resize.observe(input);
|
|
315
|
+
const reposition = () => {
|
|
316
|
+
if (isOpen())
|
|
317
|
+
position();
|
|
318
|
+
};
|
|
319
|
+
window.addEventListener("resize", reposition);
|
|
227
320
|
select.addEventListener("change", sync);
|
|
228
321
|
const observer = new MutationObserver(sync);
|
|
229
322
|
observer.observe(select, {
|
|
@@ -236,6 +329,7 @@ export const mountSelectPickers = (t, selects = document.querySelectorAll("#fm-l
|
|
|
236
329
|
document.removeEventListener("pointerdown", outside);
|
|
237
330
|
document.removeEventListener("docs:ui-language", sync);
|
|
238
331
|
select.removeEventListener("change", sync);
|
|
332
|
+
window.removeEventListener("resize", reposition);
|
|
239
333
|
resize.disconnect();
|
|
240
334
|
observer.disconnect();
|
|
241
335
|
wrapper.replaceWith(select);
|
|
@@ -269,6 +269,9 @@
|
|
|
269
269
|
"Switch branch": "Switch branch",
|
|
270
270
|
"New branch": "New branch",
|
|
271
271
|
"Create branch": "Create branch",
|
|
272
|
+
"Commit {manifest} before creating a branch.": "Commit {manifest} before creating a branch.",
|
|
273
|
+
"This branch does not contain {manifest} at the same path.": "This branch does not contain {manifest} at the same path.",
|
|
274
|
+
"New branches start from the latest commit. Unsaved changes stay in the current workspace.": "New branches start from the latest commit. Unsaved changes stay in the current workspace.",
|
|
272
275
|
"Changes": "Changes",
|
|
273
276
|
"Git uses saved files.": "Git uses saved files.",
|
|
274
277
|
"Stage": "Stage",
|
|
@@ -291,7 +294,7 @@
|
|
|
291
294
|
"Stash · empty": "Stash · empty",
|
|
292
295
|
"Restore stash": "Restore stash",
|
|
293
296
|
"Stash changes": "Stash changes",
|
|
294
|
-
"
|
|
297
|
+
"Library": "Library",
|
|
295
298
|
"Subformats": "Subformats",
|
|
296
299
|
"Expand card": "Expand card",
|
|
297
300
|
"Collapse card": "Collapse card",
|
|
@@ -336,6 +339,7 @@
|
|
|
336
339
|
"Provided by viewer": "Provided by viewer",
|
|
337
340
|
"Added": "Added",
|
|
338
341
|
"Modified": "Modified",
|
|
342
|
+
"Relations": "Relations",
|
|
339
343
|
"Add subformat…": "Add subformat…",
|
|
340
344
|
"Delete": "Delete",
|
|
341
345
|
"Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "Delete subformat {ext} and its sidebar page? Records and schema files will be kept.",
|
|
@@ -400,5 +404,15 @@
|
|
|
400
404
|
"Clear": "Clear",
|
|
401
405
|
"Enter a valid date (YYYY-MM-DD).": "Enter a valid date (YYYY-MM-DD).",
|
|
402
406
|
"Load preview": "Load preview",
|
|
403
|
-
"Preview unavailable": "Preview unavailable"
|
|
407
|
+
"Preview unavailable": "Preview unavailable",
|
|
408
|
+
"History": "History",
|
|
409
|
+
"Snapshot message": "Snapshot message",
|
|
410
|
+
"Restore": "Restore",
|
|
411
|
+
"No snapshots yet": "No snapshots yet",
|
|
412
|
+
"Save snapshot": "Save snapshot",
|
|
413
|
+
"Restore every file to this snapshot?": "Restore every file to this snapshot?",
|
|
414
|
+
"Your name": "Your name",
|
|
415
|
+
"Email (optional)": "Email (optional)",
|
|
416
|
+
"Shared workspace": "Shared workspace",
|
|
417
|
+
"Join": "Join"
|
|
404
418
|
}
|
|
@@ -269,6 +269,9 @@
|
|
|
269
269
|
"Switch branch": "切り替え",
|
|
270
270
|
"New branch": "新しいブランチ",
|
|
271
271
|
"Create branch": "ブランチを作成",
|
|
272
|
+
"Commit {manifest} before creating a branch.": "ブランチを作成する前に、{manifest} をコミットしてください。",
|
|
273
|
+
"This branch does not contain {manifest} at the same path.": "このブランチには、同じ場所に {manifest} がありません。",
|
|
274
|
+
"New branches start from the latest commit. Unsaved changes stay in the current workspace.": "新しいブランチは最新のコミットから作成します。未保存の変更は現在のワークスペースに保持されます。",
|
|
272
275
|
"Changes": "変更",
|
|
273
276
|
"Git uses saved files.": "保存済みファイルの変更を表示しています。",
|
|
274
277
|
"Stage": "ステージ",
|
|
@@ -291,7 +294,7 @@
|
|
|
291
294
|
"Stash · empty": "Stash · 空",
|
|
292
295
|
"Restore stash": "stashを復元",
|
|
293
296
|
"Stash changes": "変更をstashへ退避",
|
|
294
|
-
"
|
|
297
|
+
"Library": "ライブラリ",
|
|
295
298
|
"Subformats": "Subformats",
|
|
296
299
|
"Expand card": "カードを展開",
|
|
297
300
|
"Collapse card": "カードを折りたたむ",
|
|
@@ -336,6 +339,7 @@
|
|
|
336
339
|
"Provided by viewer": "開発用プラグイン",
|
|
337
340
|
"Added": "新規",
|
|
338
341
|
"Modified": "変更",
|
|
342
|
+
"Relations": "関係図",
|
|
339
343
|
"Add subformat…": "subformatを追加…",
|
|
340
344
|
"Delete": "削除",
|
|
341
345
|
"Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "subformat {ext} とサイドバーのページを削除しますか? レコードとスキーマファイルは保持されます。",
|
|
@@ -400,5 +404,15 @@
|
|
|
400
404
|
"Clear": "クリア",
|
|
401
405
|
"Enter a valid date (YYYY-MM-DD).": "有効な日付を入力してください(YYYY-MM-DD)。",
|
|
402
406
|
"Load preview": "プレビューを読み込む",
|
|
403
|
-
"Preview unavailable": "プレビューを読み込めません"
|
|
407
|
+
"Preview unavailable": "プレビューを読み込めません",
|
|
408
|
+
"History": "履歴",
|
|
409
|
+
"Snapshot message": "スナップショットの説明",
|
|
410
|
+
"Restore": "復元",
|
|
411
|
+
"No snapshots yet": "スナップショットはまだありません",
|
|
412
|
+
"Save snapshot": "スナップショットを保存",
|
|
413
|
+
"Restore every file to this snapshot?": "すべてのファイルをこのスナップショットの状態に戻しますか?",
|
|
414
|
+
"Your name": "名前",
|
|
415
|
+
"Email (optional)": "メールアドレス(任意)",
|
|
416
|
+
"Shared workspace": "共有ワークスペース",
|
|
417
|
+
"Join": "参加"
|
|
404
418
|
}
|
|
@@ -269,6 +269,9 @@
|
|
|
269
269
|
"Switch branch": "切换分支",
|
|
270
270
|
"New branch": "新分支",
|
|
271
271
|
"Create branch": "创建分支",
|
|
272
|
+
"Commit {manifest} before creating a branch.": "创建分支前,请先提交 {manifest}。",
|
|
273
|
+
"This branch does not contain {manifest} at the same path.": "此分支的相同路径下没有 {manifest}。",
|
|
274
|
+
"New branches start from the latest commit. Unsaved changes stay in the current workspace.": "新分支从最新提交创建。未保存的更改会保留在当前工作区。",
|
|
272
275
|
"Changes": "更改",
|
|
273
276
|
"Git uses saved files.": "显示已保存文件的更改。",
|
|
274
277
|
"Stage": "暂存",
|
|
@@ -291,7 +294,7 @@
|
|
|
291
294
|
"Stash · empty": "Stash · 空",
|
|
292
295
|
"Restore stash": "恢复 stash",
|
|
293
296
|
"Stash changes": "暂存更改",
|
|
294
|
-
"
|
|
297
|
+
"Library": "资料库",
|
|
295
298
|
"Subformats": "Subformats",
|
|
296
299
|
"Expand card": "展开卡片",
|
|
297
300
|
"Collapse card": "折叠卡片",
|
|
@@ -336,6 +339,7 @@
|
|
|
336
339
|
"Provided by viewer": "由查看器提供",
|
|
337
340
|
"Added": "新增",
|
|
338
341
|
"Modified": "修改",
|
|
342
|
+
"Relations": "关系图",
|
|
339
343
|
"Add subformat…": "添加子格式…",
|
|
340
344
|
"Delete": "删除",
|
|
341
345
|
"Delete subformat {ext} and its sidebar page? Records and schema files will be kept.": "删除子格式 {ext} 及其侧边栏页面?记录和模式文件将保留。",
|
|
@@ -400,5 +404,15 @@
|
|
|
400
404
|
"Clear": "清除",
|
|
401
405
|
"Enter a valid date (YYYY-MM-DD).": "请输入有效日期(YYYY-MM-DD)。",
|
|
402
406
|
"Load preview": "加载预览",
|
|
403
|
-
"Preview unavailable": "无法加载预览"
|
|
407
|
+
"Preview unavailable": "无法加载预览",
|
|
408
|
+
"History": "历史",
|
|
409
|
+
"Snapshot message": "快照说明",
|
|
410
|
+
"Restore": "恢复",
|
|
411
|
+
"No snapshots yet": "暂无快照",
|
|
412
|
+
"Save snapshot": "保存快照",
|
|
413
|
+
"Restore every file to this snapshot?": "将所有文件恢复到此快照的状态吗?",
|
|
414
|
+
"Your name": "您的姓名",
|
|
415
|
+
"Email (optional)": "电子邮件(可选)",
|
|
416
|
+
"Shared workspace": "共享工作区",
|
|
417
|
+
"Join": "加入"
|
|
404
418
|
}
|
|
@@ -68,4 +68,6 @@ export const focusNavTree = (root) => {
|
|
|
68
68
|
item.classList.add("open");
|
|
69
69
|
current?.querySelector(":scope > .nav-row")?.scrollIntoView({ block: "nearest" });
|
|
70
70
|
}
|
|
71
|
+
for (const item of items)
|
|
72
|
+
item.querySelector(":scope > .nav-row > .nav-tree-toggle")?.setAttribute("aria-expanded", String(item.classList.contains("open")));
|
|
71
73
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { escapeHtml } from "../core/escape-html.js";
|
|
2
|
-
import { parseMdast } from "../core/markdown.js";
|
|
3
1
|
import { pluginLink, } from "../plugins/blocks.js";
|
|
2
|
+
import { escapeHtml } from "../engine/core/escape-html.js";
|
|
3
|
+
import { parseMdast } from "../engine/core/markdown.js";
|
|
4
4
|
const link = (url, html) => pluginLink(url)
|
|
5
5
|
? `<a href="${escapeHtml(url)}" target="_blank" rel="noopener noreferrer">${html}</a>`
|
|
6
6
|
: html;
|
|
@@ -3,7 +3,8 @@ export const mountPanelResize = () => {
|
|
|
3
3
|
const sidebar = document.getElementById("sidebar");
|
|
4
4
|
const editor = document.getElementById("panel");
|
|
5
5
|
const closed = () => document.body.classList.contains("sidebar-closed");
|
|
6
|
-
const
|
|
6
|
+
const split = () => !!document.querySelector("#preview-panes.split");
|
|
7
|
+
const contentWidth = () => Math.min(split() ? 480 : 240, Math.max(0, window.innerWidth - (closed() ? 52 : 200) - (editor ? 320 : 0)));
|
|
7
8
|
const panels = [
|
|
8
9
|
{
|
|
9
10
|
element: sidebar,
|
|
@@ -36,7 +37,10 @@ export const mountPanelResize = () => {
|
|
|
36
37
|
/* Width persistence is optional. */
|
|
37
38
|
}
|
|
38
39
|
const property = options.direction === 1 ? "--sidebar-width" : "--panel-width";
|
|
39
|
-
const requested = () => preferred ??
|
|
40
|
+
const requested = () => preferred ??
|
|
41
|
+
(options.direction === 1
|
|
42
|
+
? 260
|
|
43
|
+
: Math.min(split() ? 480 : 760, window.innerWidth * (split() ? 0.34 : 0.52)));
|
|
40
44
|
if (options.direction === 1 && closed())
|
|
41
45
|
element.style.setProperty(property, `${requested()}px`);
|
|
42
46
|
const apply = (width) => {
|
|
@@ -112,6 +116,11 @@ export const mountPanelResize = () => {
|
|
|
112
116
|
return [{ ...options, element, apply, requested, persist, property }];
|
|
113
117
|
});
|
|
114
118
|
const layout = () => {
|
|
119
|
+
if (editor && window.innerWidth <= 820) {
|
|
120
|
+
const left = panels.find((panel) => panel.direction === 1);
|
|
121
|
+
left?.element.style.setProperty(left.property, `${Math.min(left.requested(), window.innerWidth - 52)}px`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
115
124
|
// On a smaller viewport, make room for the navigation before clamping both panels.
|
|
116
125
|
const right = panels.find((panel) => panel.direction === -1);
|
|
117
126
|
if (right) {
|
|
@@ -125,8 +134,11 @@ export const mountPanelResize = () => {
|
|
|
125
134
|
}
|
|
126
135
|
};
|
|
127
136
|
window.addEventListener("resize", layout);
|
|
137
|
+
document.addEventListener("docs:panes-changed", layout);
|
|
128
138
|
document.getElementById("sidebar-toggle")?.addEventListener("click", layout);
|
|
129
139
|
window.addEventListener("keydown", (event) => {
|
|
140
|
+
if (editor && window.innerWidth <= 820)
|
|
141
|
+
return;
|
|
130
142
|
if (event.defaultPrevented || !(event.ctrlKey || event.metaKey) || !event.altKey)
|
|
131
143
|
return;
|
|
132
144
|
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight")
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Self-contained for standalone HTML; data URLs use the browser's native download behavior. */
|
|
2
|
+
export const mountResourceDownloads = (request = fetch) => {
|
|
3
|
+
document.addEventListener("click", async (event) => {
|
|
4
|
+
const link = event.target instanceof Element
|
|
5
|
+
? event.target.closest("a[data-resource-download]")
|
|
6
|
+
: null;
|
|
7
|
+
if (!link || !/^https?:/.test(link.href))
|
|
8
|
+
return;
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
if (link.getAttribute("aria-busy") === "true")
|
|
11
|
+
return;
|
|
12
|
+
const status = link.parentElement?.querySelector("[role=status]") ?? document.createElement("span");
|
|
13
|
+
status.setAttribute("role", "status");
|
|
14
|
+
status.textContent = "Downloading…";
|
|
15
|
+
link.after(status);
|
|
16
|
+
link.setAttribute("aria-busy", "true");
|
|
17
|
+
try {
|
|
18
|
+
const response = await request(link.href, {
|
|
19
|
+
credentials: "omit",
|
|
20
|
+
referrerPolicy: "no-referrer",
|
|
21
|
+
signal: AbortSignal.timeout(30000),
|
|
22
|
+
}, link.closest("[data-workspace]")?.dataset.workspace);
|
|
23
|
+
if (!response.ok)
|
|
24
|
+
throw new Error();
|
|
25
|
+
const url = URL.createObjectURL(await response.blob());
|
|
26
|
+
const download = document.createElement("a");
|
|
27
|
+
download.href = url;
|
|
28
|
+
download.download = link.download;
|
|
29
|
+
document.body.append(download);
|
|
30
|
+
download.click();
|
|
31
|
+
download.remove();
|
|
32
|
+
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
|
33
|
+
status.textContent = "";
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
status.textContent =
|
|
37
|
+
"Download failed. Check your connection and the source's download permissions, then try again.";
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
link.removeAttribute("aria-busy");
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { SchemaModel } from "../engine/core/schema-graph.js";
|
|
2
|
+
import { type SubformatCollection } from "../engine/core/subformats.js";
|
|
2
3
|
interface SourceLocation {
|
|
3
4
|
file: string;
|
|
4
5
|
line: number;
|
|
@@ -21,11 +22,17 @@ export interface ResourceIndex {
|
|
|
21
22
|
}[];
|
|
22
23
|
urlPreviews: ResourceIndex["urls"];
|
|
23
24
|
subformats: SubformatCollection[];
|
|
25
|
+
/** Schema references between subformats, drawn like a schemath diagram. */
|
|
26
|
+
relations?: SchemaModel;
|
|
24
27
|
errors: string[];
|
|
25
28
|
}
|
|
26
29
|
/** Index authored content, including files not referenced by any document. */
|
|
27
30
|
export declare const resourceIndex: (root: string, files: readonly string[], domains?: readonly string[]) => ResourceIndex;
|
|
28
31
|
export type ResourceView = "files" | "codeblocks" | "urls" | "url-previews";
|
|
29
32
|
export declare const resourceTabs: (view: ResourceView) => string;
|
|
30
|
-
export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<ResourceView, "files"> | "subformats", pageTitle?: string
|
|
33
|
+
export declare const resourceLibraryHtml: (index: ResourceIndex, view: Exclude<ResourceView, "files"> | "subformats", pageTitle?: string,
|
|
34
|
+
/** Library page: use each format's preview without the format picker. */
|
|
35
|
+
page?: boolean) => string;
|
|
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, title: string) => string;
|
|
31
38
|
export {};
|