@dooc-dev/dooc 0.0.27 → 0.0.28
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/edit.global.js +68 -68
- package/dist/engine/compiler/format-collections.js +8 -2
- package/dist/engine/core/html.js +1 -1
- package/dist/frontend/document-application.js +25 -17
- package/dist/manifest.global.js +51 -51
- package/dist/server/build.js +11 -8
- package/dist/server/cli.js +6 -1
- package/dist/subformats.global.js +19 -19
- package/dist/ui.global.js +15 -15
- package/dist/workspace-worker.global.js +6 -4
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FORMAT_META_FIELDS, formatMetadataSchema, formatTraits, inFormatFolder, matchesFormat, } from "../core/format-collections.js";
|
|
2
|
-
import { fileFormat } from "../core/formats.js";
|
|
2
|
+
import { fenceFormat, fileFormat } from "../core/formats.js";
|
|
3
3
|
import { matchesSubformatRecord, sortSubformatRecords, validateSubformatOptions, } from "../core/subformats.js";
|
|
4
4
|
import { parseContentSource } from "./code-blocks.js";
|
|
5
5
|
import { figureName } from "./figures.js";
|
|
@@ -11,12 +11,18 @@ export const readFormatCollection = (root, selector, options = {}, textfiles) =>
|
|
|
11
11
|
validateSubformatOptions(options, FORMAT_META_FIELDS);
|
|
12
12
|
const paths = projectFiles(root).map((file) => file.path);
|
|
13
13
|
const index = resourceIndex(root, paths);
|
|
14
|
+
const alias = selector && fenceFormat(selector);
|
|
15
|
+
const match = alias !== selector &&
|
|
16
|
+
!index.formats?.includes(selector) &&
|
|
17
|
+
!paths.some((file) => fileFormat(file) === selector)
|
|
18
|
+
? alias
|
|
19
|
+
: selector;
|
|
14
20
|
const records = [];
|
|
15
21
|
const add = (file, format, line, inline, source) => {
|
|
16
22
|
const traits = formatTraits(format);
|
|
17
23
|
if (inline && !traits.includes("codes"))
|
|
18
24
|
traits.push("codes");
|
|
19
|
-
if (!matchesFormat(format,
|
|
25
|
+
if (!matchesFormat(format, match, traits) ||
|
|
20
26
|
(options.folder && !inFormatFolder(file, options.folder)))
|
|
21
27
|
return;
|
|
22
28
|
const folder = file.slice(0, file.lastIndexOf("/")) || ".";
|
package/dist/engine/core/html.js
CHANGED
|
@@ -400,7 +400,7 @@ const blockContentHtml = (b, ctx, seg) => {
|
|
|
400
400
|
const label = b.embed?.title ?? b.alt ?? b.subformat.ext;
|
|
401
401
|
const fields = b.embed?.fields?.flatMap((name) => b.subformat?.fields.filter((field) => field.name === name) ?? []) ?? b.subformat.fields;
|
|
402
402
|
const previews = b.subformat.resource
|
|
403
|
-
? `<template data-format-previews>${b.subformat.records.map((record) => `<div data-format-preview="${escapeHtml(JSON.stringify(record.data))}">${blocksHtml(record.preview ?? [], ctx)}</div>`).join("")}</template>`
|
|
403
|
+
? `<template data-format-previews>${b.subformat.records.map((record) => `<div data-format-preview="${escapeHtml(JSON.stringify(record.data))}">${blocksHtml(record.preview ?? [], ctx)}<a class="resource-source" href="/_files/file/${encodeURIComponent(record.file)}">${escapeHtml(record.file)}</a></div>`).join("")}</template>`
|
|
404
404
|
: "";
|
|
405
405
|
const collection = b.subformat.resource
|
|
406
406
|
? {
|
|
@@ -21,7 +21,7 @@ import { docIdOfFile, flattenTree, isContentPage, pageUrlKind, } from "../engine
|
|
|
21
21
|
import { figureFrameHtml, mountFigureFrames } from "../engine/core/figure-frame.js";
|
|
22
22
|
import { defaultFilePath, docIconFile, isSkillFile, manifestDirectory, parseFileLayout, docFile as sourceDocFile, suggestDocFileName, } from "../engine/core/files.js";
|
|
23
23
|
import { FORMAT_TRAITS, formatSelector, matchesFormat, parseFormatQuery, } from "../engine/core/format-collections.js";
|
|
24
|
-
import { fileFormat, isReferenceLibrary, REFERENCE_LIBRARIES, } from "../engine/core/formats.js";
|
|
24
|
+
import { fenceFormat, fileFormat, isReferenceLibrary, REFERENCE_LIBRARIES, } from "../engine/core/formats.js";
|
|
25
25
|
import { blocksHtml, docHtml, escapeHtml, resourceDownloadHtml, termsHtml, } from "../engine/core/html.js";
|
|
26
26
|
import { FOLDER_ICON_PATH, LIBRARY_ICONS, LLM_ICON, libraryIcon, PLUGINS_ICON, SUBFORMATS_ICON, } from "../engine/core/icons.js";
|
|
27
27
|
import { DEFAULT_LANG, isLangTag, resolveLanguage, } from "../engine/core/language.js";
|
|
@@ -450,16 +450,15 @@ export const createDocumentApplication = (root, host) => {
|
|
|
450
450
|
const entryHtmlCache = new Map();
|
|
451
451
|
/** Renders only the requested doc, not every doc in site.entries. */
|
|
452
452
|
const renderEntryHtml = (site, entry) => {
|
|
453
|
-
if (entry.
|
|
454
|
-
|
|
455
|
-
(entry.format
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
};
|
|
453
|
+
if (entry.format)
|
|
454
|
+
return {
|
|
455
|
+
html: `<article class="res-page resource-library">${renderFormatCollection(site, entry.format, "", docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
456
|
+
errors: [...site.errors, ...entry.errors],
|
|
457
|
+
};
|
|
458
|
+
if (entry.library) {
|
|
460
459
|
const index = resourceIndex(site.root ?? root, site.filePaths ?? filesSnapshot(site.root ?? root).files.map((item) => item.path), site.previews?.domains);
|
|
461
460
|
return {
|
|
462
|
-
html: `<article class="res-page resource-library subformat-page">${
|
|
461
|
+
html: `<article class="res-page resource-library subformat-page">${libraryPageHtml(index, entry.library, docDisplayName(entry.frontmatter, entry.id))}</article>`,
|
|
463
462
|
errors: [...site.errors, ...entry.errors],
|
|
464
463
|
};
|
|
465
464
|
}
|
|
@@ -1663,6 +1662,8 @@ body.extensions-over #nav-extensions, body.extensions-over .extensions-dropzone
|
|
|
1663
1662
|
.format-preview :is(img, video, iframe):not(.resource-modal *) { max-width: 100%; max-height: 220px; object-fit: contain; }
|
|
1664
1663
|
.format-card > .format-preview { display: grid; flex: 1; align-items: center; min-height: 180px; padding: 12px; box-sizing: border-box; background: var(--doc-bg-2); }
|
|
1665
1664
|
.format-card > .format-preview .fig > :is(img, iframe) { margin-inline: auto; }
|
|
1665
|
+
.format-card > .format-preview:has(.fig > :is(img, iframe[data-doc-figure-frame="svg"])) { container-type: size; grid-template-columns: minmax(0, 1fr); }
|
|
1666
|
+
.format-card > .format-preview .fig > :is(img, iframe[data-doc-figure-frame="svg"]):not(.resource-modal *) { max-height: 100cqh; }
|
|
1666
1667
|
.format-card > .format-preview:has(video) { display: block; min-height: 0; max-height: none; padding: 0; overflow: visible; }
|
|
1667
1668
|
.format-card > .format-preview .video-player > video:not(.resource-modal *) { height: 180px; border-radius: 0; }
|
|
1668
1669
|
.format-card .video-controls:not(.resource-modal *) { flex-wrap: wrap; padding: 6px 10px; gap: 4px; border-top: 1px solid var(--c-line); }
|
|
@@ -2691,16 +2692,26 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2691
2692
|
}
|
|
2692
2693
|
};
|
|
2693
2694
|
};
|
|
2694
|
-
const renderFormatCollection = (site, selector, query = "") => {
|
|
2695
|
-
const
|
|
2695
|
+
const renderFormatCollection = (site, selector, query = "", title = selector) => {
|
|
2696
|
+
const project = site.root ?? root;
|
|
2697
|
+
const alias = selector && fenceFormat(selector);
|
|
2698
|
+
if (!query && site.subformats?.some(({ ext }) => ext === selector || ext === alias)) {
|
|
2699
|
+
const files = site.filePaths ?? filesSnapshot(project).files.map((item) => item.path);
|
|
2700
|
+
const index = resourceIndex(project, files, site.previews?.domains);
|
|
2701
|
+
const format = index.formats?.includes(selector) ? selector : alias;
|
|
2702
|
+
if (index.subformats.some(({ ext }) => ext === format))
|
|
2703
|
+
return `<div class="subformat-page">${formatPageHtml(index, format, title)}</div>`;
|
|
2704
|
+
}
|
|
2705
|
+
const options = parseFormatQuery(query);
|
|
2706
|
+
const collection = readFormatCollection(project, selector, options);
|
|
2696
2707
|
const missing = collection.records
|
|
2697
2708
|
.filter((record) => record.preview?.some((block) => block.type === "figureRef" && !site.ctx.figures.has(block.name)))
|
|
2698
2709
|
.map((record) => record.file);
|
|
2699
2710
|
const figures = new Map(site.ctx.figures);
|
|
2700
2711
|
if (missing.length)
|
|
2701
|
-
for (const figure of loadFigures(join(
|
|
2712
|
+
for (const figure of loadFigures(join(project, "figures"), missing).figures)
|
|
2702
2713
|
figures.set(figure.name, figure);
|
|
2703
|
-
return blocksHtml([formatCollectionBlock(collection,
|
|
2714
|
+
return blocksHtml([formatCollectionBlock(collection, options)], {
|
|
2704
2715
|
...site.ctx,
|
|
2705
2716
|
figures,
|
|
2706
2717
|
figurePreview: figureFrameHtml,
|
|
@@ -2754,10 +2765,7 @@ body.edit .nav-row { cursor: grab; }
|
|
|
2754
2765
|
}
|
|
2755
2766
|
choices.add(selector);
|
|
2756
2767
|
const navigation = `<nav class="format-navigation" aria-label="Format collections" data-i18n-aria-label="Format collections"><label><span data-i18n="Collection">Collection</span><select data-format-path>${[...choices].map((value) => `<option value="${escapeHtml(value)}"${value === selector ? " selected" : ""}${value ? "" : ' data-i18n="All formats"'}>${escapeHtml(value || "All formats")}</option>`).join("")}</select></label><code>format/${escapeHtml(selector || "all")}</code></nav>`;
|
|
2757
|
-
const
|
|
2758
|
-
const content = registered
|
|
2759
|
-
? formatPageHtml(resourceIndex(site.root ?? root, files, site.previews?.domains), selector, selector)
|
|
2760
|
-
: renderFormatCollection(site, selector, query);
|
|
2768
|
+
const content = renderFormatCollection(site, selector, query);
|
|
2761
2769
|
return {
|
|
2762
2770
|
title: "Format",
|
|
2763
2771
|
main: `<article class="res-page resource-library resource-results">${navigation}${content}</article>`,
|