@heycys/gallery 0.1.0 → 0.1.1
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/THIRD-PARTY-NOTICES.md +51 -1
- package/browser/editor/components/callout/index.mjs +40 -15
- package/browser/editor/components/columns/page.mjs +41 -28
- package/browser/editor/components/details/index.mjs +2 -1
- package/browser/editor/components/dialog/index.mjs +2 -1
- package/browser/editor/components/dialog/page.mjs +0 -18
- package/browser/editor/components/divider/index.mjs +1 -1
- package/browser/editor/components/figure/page.mjs +10 -1
- package/browser/editor/components/file/page.mjs +2 -2
- package/browser/editor/components/flowchart/add.mjs +2 -2
- package/browser/editor/components/heading/index.mjs +2 -0
- package/browser/editor/components/heading/page.mjs +6 -0
- package/browser/editor/components/highlight/index.mjs +4 -20
- package/browser/editor/components/icons.mjs +5 -2
- package/browser/editor/components/image/page.mjs +2 -2
- package/browser/editor/components/installed/index.mjs +71 -25
- package/browser/editor/components/installed/page.mjs +122 -21
- package/browser/editor/components/kit.mjs +3 -0
- package/browser/editor/components/media/page.mjs +44 -14
- package/browser/editor/components/pages.mjs +2 -2
- package/browser/editor/components/registry.mjs +56 -30
- package/browser/editor/components/section/index.mjs +2 -1
- package/browser/editor/components/set-apart.mjs +24 -0
- package/browser/editor/components/table/index.mjs +5 -3
- package/browser/editor/components/table/page.mjs +29 -18
- package/browser/editor/page/annotate/anchors.mjs +4 -3
- package/browser/editor/page/annotate/index.mjs +61 -34
- package/browser/editor/page/autosave.mjs +50 -4
- package/browser/editor/page/beside.mjs +5 -5
- package/browser/editor/page/block-menu/colors.mjs +3 -1
- package/browser/editor/page/block-menu/index.mjs +8 -6
- package/browser/editor/page/blocks.mjs +16 -7
- package/browser/editor/page/caret.mjs +4 -1
- package/browser/editor/page/changes/bar.mjs +102 -0
- package/browser/editor/page/changes/ghost.mjs +206 -0
- package/browser/editor/page/changes/gone-words.mjs +94 -0
- package/browser/editor/page/changes/index.mjs +447 -0
- package/browser/editor/page/changes/words.mjs +27 -0
- package/browser/editor/page/clipboard/import/colors.mjs +3 -3
- package/browser/editor/page/clipboard/index.mjs +32 -13
- package/browser/editor/page/clipboard/own/blocks.mjs +14 -5
- package/browser/editor/page/clipboard/own/describe.mjs +16 -7
- package/browser/editor/page/clipboard/own/export.mjs +6 -6
- package/browser/editor/page/clipboard/own/selection.mjs +2 -2
- package/browser/editor/page/clipboard/own/writers.mjs +0 -11
- package/browser/editor/page/columns/index.mjs +1 -1
- package/browser/editor/page/commit.mjs +19 -4
- package/browser/editor/page/conflicts.mjs +6 -26
- package/browser/editor/page/convert.mjs +8 -7
- package/browser/editor/page/core.mjs +55 -17
- package/browser/editor/page/drag/index.mjs +40 -24
- package/browser/editor/page/drag/preview.mjs +9 -4
- package/browser/editor/page/editor.mjs +70 -15
- package/browser/editor/page/emoji-picker/emoji-tab.mjs +22 -13
- package/browser/editor/page/emoji-picker/grid.mjs +7 -5
- package/browser/editor/page/emoji-picker/icon-tab.mjs +4 -4
- package/browser/editor/page/emoji-picker/icons.mjs +0 -1
- package/browser/editor/page/emoji-picker/index.mjs +11 -9
- package/browser/editor/page/emoji-picker/styles.mjs +161 -2
- package/browser/editor/page/emoji-picker/support.mjs +6 -4
- package/browser/editor/page/emoji-picker/upload.mjs +12 -11
- package/browser/editor/page/fills.mjs +5 -3
- package/browser/editor/page/fold/index.mjs +348 -0
- package/browser/editor/page/fold/rule.mjs +125 -0
- package/browser/editor/page/folded.mjs +23 -0
- package/browser/editor/page/format-bar/bar.mjs +2 -1
- package/browser/editor/page/format-bar/index.mjs +1 -1
- package/browser/editor/page/geometry.mjs +8 -6
- package/browser/editor/page/handle/index.mjs +17 -6
- package/browser/editor/page/hints/index.mjs +1 -1
- package/browser/editor/page/insert/index.mjs +30 -17
- package/browser/editor/page/long-runs.mjs +75 -0
- package/browser/editor/page/look.mjs +15 -3
- package/browser/editor/page/margin.mjs +45 -24
- package/browser/editor/page/menu.mjs +69 -25
- package/browser/editor/page/merge.mjs +24 -0
- package/browser/editor/page/notices.mjs +1 -1
- package/browser/editor/page/offered.mjs +1 -1
- package/browser/editor/page/outline/folds.mjs +11 -10
- package/browser/editor/page/outline/index.mjs +131 -45
- package/browser/editor/page/outline/list.mjs +23 -11
- package/browser/editor/page/outline/read.mjs +1 -1
- package/browser/editor/page/outline/strip.mjs +7 -1
- package/browser/editor/page/panel.mjs +5 -4
- package/browser/editor/page/resize/index.mjs +1 -1
- package/browser/editor/page/selection/delete.mjs +8 -6
- package/browser/editor/page/selection/index.mjs +10 -3
- package/browser/editor/page/session.mjs +54 -3
- package/browser/editor/page/table/cell-bar.mjs +4 -1
- package/browser/editor/page/table/cells.mjs +1 -1
- package/browser/editor/page/table/icons.mjs +1 -1
- package/browser/editor/page/table/index.mjs +13 -8
- package/browser/editor/page/table/widths.mjs +9 -4
- package/browser/editor/page/text-select/index.mjs +18 -3
- package/browser/editor/page/tooltip.mjs +1 -1
- package/browser/editor/page/type-grid.mjs +4 -3
- package/browser/editor/page/typing/code-edges.mjs +63 -17
- package/browser/editor/page/typing/index.mjs +12 -6
- package/browser/editor/page/typing/leave.mjs +1 -1
- package/browser/shared/annotations.mjs +8 -10
- package/browser/shared/code-folds.mjs +5 -1
- package/browser/shared/colors.mjs +15 -13
- package/browser/shared/component-catalog.mjs +24 -10
- package/browser/shared/components/callout.mjs +4 -2
- package/browser/shared/components/index.mjs +61 -7
- package/browser/shared/components/installed.mjs +75 -5
- package/browser/shared/components/page.mjs +10 -1
- package/browser/shared/components/table.mjs +1 -1
- package/browser/shared/components/text.mjs +2 -2
- package/browser/shared/document-look.mjs +178 -0
- package/browser/shared/emoji/data/LICENSE-lucide.txt +43 -0
- package/browser/shared/emoji/data/README.md +4 -2
- package/browser/shared/emoji/data/categories.json +1 -1
- package/browser/shared/emoji/data/keywords-en.json +1 -1
- package/browser/shared/emoji/data/keywords-zh.json +1 -1
- package/browser/shared/emoji/data/names.json +1 -1
- package/browser/shared/emoji/data/positions.json +1 -1
- package/browser/shared/emoji/data/twemoji-index.json +1 -1
- package/browser/shared/emoji/data/twemoji-svg.bin +0 -0
- package/browser/shared/emoji/data.mjs +10 -12
- package/browser/shared/emoji/emoji.mjs +8 -7
- package/browser/shared/emoji/icon-value.mjs +4 -3
- package/browser/shared/html-tree.mjs +11 -5
- package/browser/shared/i18n/en.mjs +67 -8
- package/browser/shared/long-runs.mjs +39 -0
- package/browser/shared/new-names.mjs +5 -2
- package/browser/shared/outline.mjs +194 -0
- package/browser/shared/preferences.mjs +10 -4
- package/browser/shared/session.mjs +5 -4
- package/browser/shared/workspace-look.mjs +91 -0
- package/browser/shared/zoom.mjs +5 -5
- package/dist/chunk-3HIRPVLU.mjs +2 -0
- package/dist/chunk-4FS7Z7WR.mjs +2 -0
- package/dist/{chunk-LHTFLRB6.mjs → chunk-5MHMDLZD.mjs} +2 -2
- package/dist/{chunk-YXAUQPVK.mjs → chunk-5ZKJ3H4P.mjs} +3 -3
- package/dist/{chunk-ZBIM6ARY.mjs → chunk-64K7IPLO.mjs} +55 -16
- package/dist/{chunk-QYKCJ7FG.mjs → chunk-6QXGZM36.mjs} +1 -1
- package/dist/chunk-6RGJOMJP.mjs +16 -0
- package/dist/{chunk-EUX7IC5J.mjs → chunk-7DTINW6U.mjs} +2 -2
- package/dist/{chunk-6CYG3Z4V.mjs → chunk-AJ73XJF3.mjs} +1 -1
- package/dist/chunk-AUZGSZJH.mjs +13 -0
- package/dist/{chunk-7QQBR7PB.mjs → chunk-BFE45AKL.mjs} +1 -1
- package/dist/chunk-BGGDRNYQ.mjs +10 -0
- package/dist/{chunk-L4DVONOG.mjs → chunk-BXO2ZY5P.mjs} +1 -1
- package/dist/chunk-CEH4MRCC.mjs +2 -0
- package/dist/chunk-CY2FNNAB.mjs +16 -0
- package/dist/{chunk-LC7YNQFG.mjs → chunk-DFUDV4LX.mjs} +1 -1
- package/dist/chunk-DKXG4XDG.mjs +2 -0
- package/dist/chunk-E7LWZRXY.mjs +4 -0
- package/dist/chunk-EZQ34M3F.mjs +124 -0
- package/dist/chunk-FDLXYYG4.mjs +4 -0
- package/dist/chunk-FUKQNOQS.mjs +9 -0
- package/dist/{chunk-DB4WKGYF.mjs → chunk-GB5SOYQJ.mjs} +2 -2
- package/dist/{chunk-ACOPDCNB.mjs → chunk-IVDLMMBD.mjs} +1 -1
- package/dist/chunk-JPOSLGOC.mjs +6 -0
- package/dist/chunk-JVHHHGEA.mjs +3 -0
- package/dist/chunk-L3QKH4OK.mjs +26 -0
- package/dist/{chunk-B3VTYBYR.mjs → chunk-LCTHTZIL.mjs} +2 -2
- package/dist/chunk-LEF6DRCK.mjs +59 -0
- package/dist/chunk-LS4F7JUM.mjs +2 -0
- package/dist/chunk-NO5NJCHO.mjs +2 -0
- package/dist/{chunk-UNUEWH4S.mjs → chunk-NQPVAU63.mjs} +1 -1
- package/dist/chunk-O35FIXRB.mjs +2 -0
- package/dist/chunk-PL6GHLGD.mjs +15 -0
- package/dist/{chunk-G7TOXONE.mjs → chunk-QJIR2BLP.mjs} +1 -1
- package/dist/chunk-QUPLVPB2.mjs +7 -0
- package/dist/chunk-R7BNENLY.mjs +4 -0
- package/dist/chunk-S6O4UHLC.mjs +2 -0
- package/dist/{chunk-HMHK3EQ6.mjs → chunk-SGJWQKEI.mjs} +1 -1
- package/dist/chunk-SYGN7GLU.mjs +2 -0
- package/dist/chunk-TYK6VNAB.mjs +10 -0
- package/dist/{chunk-EVJ3BX3M.mjs → chunk-U6KNPJPR.mjs} +1 -1
- package/dist/{chunk-YZ5Z6H4W.mjs → chunk-UALRNVSE.mjs} +1 -1
- package/dist/chunk-UMHUSOPJ.mjs +2 -0
- package/dist/chunk-V3HXVQEM.mjs +2 -0
- package/dist/{chunk-UXUK4PMC.mjs → chunk-V5JTW2LH.mjs} +1 -1
- package/dist/chunk-V5VXUJKG.mjs +2 -0
- package/dist/chunk-VBXMADMP.mjs +2 -0
- package/dist/chunk-VNV55RUA.mjs +2 -0
- package/dist/chunk-VPD2PS35.mjs +2 -0
- package/dist/chunk-W3BGBJQW.mjs +2 -0
- package/dist/chunk-W4VKN3GF.mjs +7 -0
- package/dist/chunk-W5BXXPDJ.mjs +3 -0
- package/dist/{chunk-Z52HTUW7.mjs → chunk-XNROSH2T.mjs} +2 -2
- package/dist/chunk-XUNHRCOG.mjs +6 -0
- package/dist/{chunk-6U2SLSDN.mjs → chunk-Y6RLRPG3.mjs} +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/math.js +18 -2
- package/kit/report.css +248 -137
- package/kit/runtime.js +126 -51
- package/kit/tables.js +51 -1
- package/kit/ui.js +97 -0
- package/package.json +1 -1
- package/release.json +8 -8
- package/sdk/doc-kit.d.ts +9 -3
- package/skill/SKILL.md +22 -10
- package/skill/references/building-components.md +46 -6
- package/skill/references/example-report.html +1 -1
- package/skill/references/writing-html.md +4 -4
- package/skill/sdk/doc-kit.d.ts +9 -3
- package/web/assets/index-Bh74DfsV.css +1 -0
- package/web/assets/index-UW0RyFFt.js +13 -0
- package/web/index.html +2 -2
- package/browser/editor/components/callout/page.mjs +0 -13
- package/dist/chunk-2PBALTR3.mjs +0 -57
- package/dist/chunk-3LA3EMDE.mjs +0 -15
- package/dist/chunk-5FRMCDPY.mjs +0 -16
- package/dist/chunk-5LEK2CBS.mjs +0 -2
- package/dist/chunk-5OFN5AHC.mjs +0 -2
- package/dist/chunk-5SIYS5HN.mjs +0 -2
- package/dist/chunk-5TEK3RAD.mjs +0 -2
- package/dist/chunk-7GHT2UCA.mjs +0 -15
- package/dist/chunk-ATCJYAR4.mjs +0 -2
- package/dist/chunk-C7HWOBIF.mjs +0 -2
- package/dist/chunk-E7VYDG2X.mjs +0 -2
- package/dist/chunk-FQGQH4KM.mjs +0 -2
- package/dist/chunk-GPF4YWWB.mjs +0 -9
- package/dist/chunk-GYQV7Y4J.mjs +0 -120
- package/dist/chunk-HQQMJCQJ.mjs +0 -10
- package/dist/chunk-IERUOGC3.mjs +0 -6
- package/dist/chunk-ITNLYXXV.mjs +0 -3
- package/dist/chunk-NFIBI4IP.mjs +0 -26
- package/dist/chunk-O52JMOCZ.mjs +0 -2
- package/dist/chunk-QMQUXTU4.mjs +0 -12
- package/dist/chunk-QVWVFC5K.mjs +0 -6
- package/dist/chunk-QZY6Q64C.mjs +0 -2
- package/dist/chunk-TDQP3DKQ.mjs +0 -10
- package/dist/chunk-V4CPWKMZ.mjs +0 -2
- package/dist/chunk-VACRB2NE.mjs +0 -3
- package/dist/chunk-W63L7367.mjs +0 -7
- package/dist/chunk-W7CXPCRV.mjs +0 -6
- package/dist/chunk-XINNG4F2.mjs +0 -4
- package/dist/chunk-YL2DPWVS.mjs +0 -4
- package/web/assets/index-B6Ai3wsa.js +0 -13
- package/web/assets/index-SYPC3EZy.css +0 -1
package/kit/runtime.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
// <define:__COMPONENT_FLOWS__>
|
|
4
|
-
var define_COMPONENT_FLOWS_default = [".doc-page", ".doc-section", ".doc-summary", ".doc-panel", ".doc-details-content", ".doc-dialog-content", "[data-doc-sheet]", ".doc-column"];
|
|
4
|
+
var define_COMPONENT_FLOWS_default = [".doc-page", ".doc-section", ".doc-summary", ".doc-panel", ".doc-callout", ".doc-details-content", ".doc-dialog-content", "[data-doc-sheet]", ".doc-column", "[data-doc-slot]"];
|
|
5
5
|
|
|
6
6
|
// <define:__COMPONENT_RUNTIME__>
|
|
7
|
-
var define_COMPONENT_RUNTIME_default = [{ id: "page", match: "main.doc-page", runtime: { generated: [".doc-display", "script[data-doc-state]"], root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls"] }, state: { html: ["data-doc-theme", "data-doc-width"] }, internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error"] } }, { id: "text", runtime: { classes: { ".doc-range": ["doc-range"] } } }, { id: "mention", runtime: { attrs: { "a.doc-link-mention": ["data-doc-gone"] } } }, { id: "paragraph", match: "p" }, { id: "heading", match: "h1, h2, h3, h4" }, { id: "list", match: "ul, ol", runtime: { attrs: { "ol.doc-flow": ["data-doc-flow-key", "data-doc-flow-recount"] }, generated: ["br.doc-item-line"] } }, { id: "quote", match: "blockquote" }, { id: "
|
|
7
|
+
var define_COMPONENT_RUNTIME_default = [{ id: "page", match: "main.doc-page", runtime: { generated: [".doc-display", "script[data-doc-state]"], root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls"] }, state: { html: ["data-doc-theme", "data-doc-width", "data-doc-font", "data-doc-size", "data-doc-spacing", "data-doc-measure"] }, internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error"] } }, { id: "text", runtime: { classes: { ".doc-range": ["doc-range"], ".doc-long-run": ["doc-long-run"] } } }, { id: "mention", runtime: { attrs: { "a.doc-link-mention": ["data-doc-gone"] } } }, { id: "paragraph", match: "p" }, { id: "heading", match: "h1, h2, h3, h4" }, { id: "list", match: "ul, ol", runtime: { attrs: { "ol.doc-flow": ["data-doc-flow-key", "data-doc-flow-recount"] }, generated: ["br.doc-item-line"] } }, { id: "quote", match: "blockquote" }, { id: "code", match: ".doc-code", runtime: { generated: [".doc-code-fold", ".doc-code-range", ".doc-code-tools"], internal: ["doc-code-lines", "doc-code-line*", "doc-code-content", "doc-code-toolbar", "doc-code-language", "doc-code-separator", "doc-code-copy*", "doc-code-wrap*", "data-line-number"] } }, { id: "divider", match: "hr" }, { id: "math", match: ".doc-math-inline, .doc-math-block", runtime: { generated: [".doc-math-break", ".doc-math-joiner"], classes: { ".doc-math-tie": ["doc-math-tie"], ".doc-math-skip": ["doc-math-skip"] } } }, { id: "section", match: "section.doc-section" }, { id: "highlight", match: ".doc-panel, .doc-summary" }, { id: "callout", match: ".doc-callout" }, { id: "details", match: "details.doc-details" }, { id: "dialog", match: "dialog.doc-dialog", runtime: { attrs: { "dialog.doc-dialog": ["data-doc-dialog-ready", "open", "aria-label"], ".doc-dialog-content": ["tabindex"] }, root: { classes: ["doc-dialog-open", "doc-dialog-gutter"] }, internal: ["doc-dialog-in", "doc-dialog-fade"] } }, { id: "sheets", match: "[data-doc-sheets]", runtime: { state: { "[data-doc-sheets]": ["data-active-sheet"], "[data-sheet-tab]": ["aria-selected", "tabindex", "is-active"], "[data-doc-sheet]": ["hidden", "aria-hidden"] }, internal: ["doc-sheets"] } }, { id: "table", match: "table.doc-table", runtime: { generated: ["colgroup[data-doc-columns]", ".doc-scrollbars"], attrs: { "table.doc-table": ["data-doc-sortable-ready", "data-doc-filled"], ".doc-table-wrap": ["data-doc-min-width", "data-doc-layout", "data-doc-whole"], "th, td": ["data-column-kind", "data-column-wrap", "data-run-wrap", "data-doc-edge"] }, classes: { "table.doc-table": ["doc-table--auto"] }, internal: ["doc-code-run", "doc-table-sort-button", "doc-scrollbar*", "data-doc-sort-arrow", "data-active", "data-drag", "data-x", "data-y", "data-more"] } }, { id: "columns", match: ".doc-columns" }, { id: "figure", match: "figure" }, { id: "chart", match: "[data-doc-chart]", runtime: { attrs: { "[data-doc-chart]": ["data-doc-layout"] }, classes: { "[data-doc-chart]": ["doc-chart"] }, internal: ["doc-chart-message", "data-missing"] } }, { id: "image", match: "figure.doc-image", runtime: { generated: ["dialog.doc-zoom"], attrs: { "img[data-doc-zoom]": ["data-doc-zoom", "tabindex", "role", "aria-haspopup", "aria-label"] }, root: { classes: ["doc-zoom-open", "doc-zoom-gutter", "doc-zoom-hover"] }, internal: ["doc-zoom-*"] } }, { id: "file", match: "figure.doc-file" }, { id: "bookmark", match: "figure.doc-bookmark" }, { id: "embed", match: "figure.doc-embed", runtime: { attrs: { "iframe.doc-embed-frame": ["data-doc-blob"] } } }, { id: "diff", match: ".doc-diff", runtime: { generated: [".doc-diff-body", ".doc-diff-stats"], internal: ["doc-diff-added", "doc-diff-removed"] } }, { id: "icon", match: ".doc-icon", runtime: { internal: ["data-doc-tab-icon"] } }, { id: "installed", match: "div[data-doc-component], section[data-doc-component]", runtime: { generated: [".doc-component-note", ".doc-component-data"], attrs: { "[data-doc-fallback]": ["data-doc-fallback"], "[data-doc-fallback-control]": ["data-doc-fallback-control", "inert"] }, internal: ["data-doc-package", "doc-component-more", "doc-component-one", "doc-component-line", "doc-component-short"] } }, { id: "state", match: "[data-doc-bind], [data-doc-show]", runtime: { attrs: { "[data-doc-show]": ["hidden"] }, state: { "button[data-doc-bind]": ["aria-pressed"] } } }];
|
|
8
8
|
|
|
9
9
|
// src/render/kit/runtime/bindings.js
|
|
10
10
|
var global = globalThis;
|
|
@@ -196,6 +196,23 @@
|
|
|
196
196
|
return each.map((weight) => weight / all);
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
+
// src/shared/long-runs.mjs
|
|
200
|
+
var LONG_RUN = 20;
|
|
201
|
+
var RUNS = /[^\s\u2000-\u206f\u2e80-\u9fff\uac00-\ud7af\uf900-\ufaff\ufe30-\ufe4f\uff00-\uffef]+/gu;
|
|
202
|
+
var PIECES = /(?<=[-?])/u;
|
|
203
|
+
var long = (run) => run.length > LONG_RUN && run.split(PIECES).some((piece) => [...piece].length > LONG_RUN);
|
|
204
|
+
function longRuns(text) {
|
|
205
|
+
const found = [];
|
|
206
|
+
if (text.length <= LONG_RUN) return found;
|
|
207
|
+
for (const match of text.matchAll(RUNS)) if (long(match[0])) found.push({ index: match.index, length: match[0].length });
|
|
208
|
+
return found;
|
|
209
|
+
}
|
|
210
|
+
function holdsLongRun(text) {
|
|
211
|
+
if (text.length <= LONG_RUN) return false;
|
|
212
|
+
for (const match of text.matchAll(RUNS)) if (long(match[0])) return true;
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
|
|
199
216
|
// src/render/kit/words.js
|
|
200
217
|
var RUNTIME = {
|
|
201
218
|
"component-missing": { zh: "\u7EC4\u4EF6 {0} \u7684\u7EC4\u4EF6\u5305\u4E0D\u5728\u8FD9\u4E2A\u5DE5\u4F5C\u533A\u91CC\uFF0C\u8FD9\u91CC\u53EA\u663E\u793A\u5B83\u7684\u5185\u5BB9\u3002", en: "The package of component {0} is not in this workspace: only what it holds is shown." },
|
|
@@ -234,7 +251,7 @@
|
|
|
234
251
|
// src/render/kit/runtime/flowchart.js
|
|
235
252
|
var CJK = "\\u2e80-\\u9fff\\uac00-\\ud7af\\uf900-\\ufaff\\uff00-\\uffef";
|
|
236
253
|
var WORDS = new RegExp(`[${CJK}]|[^\\s${CJK}]+`, "g");
|
|
237
|
-
var
|
|
254
|
+
var PIECES2 = new RegExp(`[${CJK}]|[^\\s${CJK}]+|\\s+`, "g");
|
|
238
255
|
var WIDE = new RegExp(`[${CJK}]`);
|
|
239
256
|
function linesOf(pieces, width) {
|
|
240
257
|
let lines = 0;
|
|
@@ -372,11 +389,23 @@
|
|
|
372
389
|
return context.measureText(text).width;
|
|
373
390
|
};
|
|
374
391
|
}
|
|
375
|
-
function piecesOf(text, style) {
|
|
392
|
+
function piecesOf(text, style, split = true) {
|
|
376
393
|
const measure = measurer(style);
|
|
377
394
|
const space = measure(" ");
|
|
378
|
-
const
|
|
379
|
-
|
|
395
|
+
const anywhere = split && style.wordBreak === "break-all";
|
|
396
|
+
const pieces = [];
|
|
397
|
+
let widest = 0;
|
|
398
|
+
for (const piece of String(text).match(PIECES2) ?? []) {
|
|
399
|
+
if (/^\s/.test(piece)) {
|
|
400
|
+
pieces.push({ width: space, space: true });
|
|
401
|
+
continue;
|
|
402
|
+
}
|
|
403
|
+
const width = measure(piece);
|
|
404
|
+
widest = Math.max(widest, width);
|
|
405
|
+
if (split && !WIDE.test(piece) && (anywhere || holdsLongRun(piece))) for (const character of piece) pieces.push({ width: measure(character) });
|
|
406
|
+
else pieces.push({ width });
|
|
407
|
+
}
|
|
408
|
+
return { pieces, widest };
|
|
380
409
|
}
|
|
381
410
|
function inlinePieces(nodes, style) {
|
|
382
411
|
const holds = (node) => node.nodeType === 1 && (node.tagName === "CODE" || node.querySelector("code"));
|
|
@@ -390,23 +419,27 @@
|
|
|
390
419
|
} else if (node.nodeType === 1) node.childNodes.forEach((child) => walk(child, code ?? (node.tagName === "CODE" ? node : null)));
|
|
391
420
|
};
|
|
392
421
|
nodes.forEach((node) => walk(node, null));
|
|
393
|
-
const
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
422
|
+
const collect = (split) => {
|
|
423
|
+
const pieces = [];
|
|
424
|
+
let joins = false;
|
|
425
|
+
for (const { text, code } of segments) {
|
|
426
|
+
if (!text) continue;
|
|
427
|
+
const look = code ? getComputedStyle(code) : style;
|
|
428
|
+
const own = piecesOf(text, look, split).pieces;
|
|
429
|
+
if (code && own.length) {
|
|
430
|
+
own[0].width += pixels(look.paddingLeft) + pixels(look.borderLeftWidth);
|
|
431
|
+
own.at(-1).width += pixels(look.paddingRight) + pixels(look.borderRightWidth);
|
|
432
|
+
}
|
|
433
|
+
own.forEach((piece, at) => {
|
|
434
|
+
if (at === 0 && joins && !piece.space && !WIDE.test(text[0])) pieces.at(-1).width += piece.width;
|
|
435
|
+
else pieces.push(piece);
|
|
436
|
+
});
|
|
437
|
+
joins = !/\s$/.test(text) && !WIDE.test(text.at(-1));
|
|
402
438
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
joins = !/\s$/.test(text) && !WIDE.test(text.at(-1));
|
|
408
|
-
}
|
|
409
|
-
return { pieces, widest: Math.max(0, ...pieces.filter((piece) => !piece.space).map((piece) => piece.width)) };
|
|
439
|
+
return { pieces, widest: Math.max(0, ...pieces.filter((piece) => !piece.space).map((piece) => piece.width)) };
|
|
440
|
+
};
|
|
441
|
+
const whole = collect(false);
|
|
442
|
+
return { pieces: collect(true).pieces, widest: whole.widest };
|
|
410
443
|
}
|
|
411
444
|
function contentOf(elements) {
|
|
412
445
|
const blocks = [];
|
|
@@ -563,6 +596,19 @@
|
|
|
563
596
|
var ATTRIBUTE = "data-doc-component";
|
|
564
597
|
var PACKAGE_ID = /^[a-z0-9][a-z0-9-]*\/[a-z0-9][a-z0-9-]*$/;
|
|
565
598
|
var INSTANCE = `div[${ATTRIBUTE}], section[${ATTRIBUTE}]`;
|
|
599
|
+
var SLOT = "data-doc-slot";
|
|
600
|
+
var SLOT_PART = `div[${SLOT}], section[${SLOT}]`;
|
|
601
|
+
var REGION = `${INSTANCE}, ${SLOT_PART}`;
|
|
602
|
+
var edgeAround = (node) => node?.parentElement?.closest(REGION) ?? null;
|
|
603
|
+
function heldBy(node) {
|
|
604
|
+
const edge = edgeAround(node);
|
|
605
|
+
if (!edge) return null;
|
|
606
|
+
const owner = heldBy(edge);
|
|
607
|
+
if (edge.matches(INSTANCE)) return owner ?? edge;
|
|
608
|
+
return owner !== null && edgeAround(edge) === owner ? null : owner;
|
|
609
|
+
}
|
|
610
|
+
var opensDocument = (node) => node.matches(SLOT_PART) && heldBy(node) !== null && edgeAround(node) === heldBy(node);
|
|
611
|
+
var componentAt = (node) => node?.nodeType === 1 && heldBy(node) !== null && !opensDocument(node);
|
|
566
612
|
var FALLBACK = "data-doc-fallback";
|
|
567
613
|
var CONTROLS2 = "input, select, textarea, button";
|
|
568
614
|
var CONTROL_MARK = "data-doc-fallback-control";
|
|
@@ -795,7 +841,8 @@
|
|
|
795
841
|
global2.addEventListener("resize", () => tellAll("viewport"));
|
|
796
842
|
document.fonts?.ready.then(() => tellAll("fonts"));
|
|
797
843
|
document.fonts?.addEventListener?.("loadingdone", (event) => tellAll("fonts", [...event.fontfaces ?? []]));
|
|
798
|
-
const
|
|
844
|
+
const ownedBy = (node, host) => node.parentElement.closest(INSTANCE) === host && heldBy(node) === host;
|
|
845
|
+
const partsIn = (host, at, edit = null) => [...host.querySelectorAll(at)].filter((node) => !node.matches(INSTANCE) && ownedBy(node, host) && edit === "flow" === node.matches(SLOT_PART));
|
|
799
846
|
const instanceName = (def, host) => host.getAttribute("data-block-id") ?? String(hostsIn(document, selectorOf(def)).indexOf(host));
|
|
800
847
|
const canEdit = (def, host) => editable && instances.get(host)?.failed === false && !schemaAhead(host.getAttribute(SCHEMA), descriptions.get(def.id)?.schema);
|
|
801
848
|
const partNamed = (def, name) => {
|
|
@@ -804,7 +851,7 @@
|
|
|
804
851
|
return part;
|
|
805
852
|
};
|
|
806
853
|
const packageContext = (def, host) => ({
|
|
807
|
-
part: (name) => partsIn(host, partNamed(def, name).at)[0] ?? null,
|
|
854
|
+
part: (name) => partsIn(host, partNamed(def, name).at, partNamed(def, name).edit)[0] ?? null,
|
|
808
855
|
state: ({ version, defaults, transientKeys }) => global2.DocState.getOrCreate({ id: `${def.id}:${instanceName(def, host)}`, version, defaults, transientKeys }),
|
|
809
856
|
canEdit: () => canEdit(def, host),
|
|
810
857
|
edit(names, change) {
|
|
@@ -813,7 +860,7 @@
|
|
|
813
860
|
const parts = (several ? names : [names]).map((name) => {
|
|
814
861
|
const { at, edit } = partNamed(def, name);
|
|
815
862
|
if (edit !== "data") throw new Error(`the part "${name}" of ${def.id} is not edited as data`);
|
|
816
|
-
return { name, part: partsIn(host, at)[0] };
|
|
863
|
+
return { name, part: partsIn(host, at, edit)[0] };
|
|
817
864
|
});
|
|
818
865
|
const apart = parts.find(({ part }, index) => parts.some((other, at) => at !== index && part && other.part && (part === other.part || other.part.contains(part))));
|
|
819
866
|
if (apart) throw new Error(`the part "${apart.name}" of ${def.id} is in another this edit names, or is it: name the one around it`);
|
|
@@ -832,8 +879,9 @@
|
|
|
832
879
|
});
|
|
833
880
|
function takeRuntime(description, root) {
|
|
834
881
|
const { generated = [], attrs = {} } = description?.runtime ?? {};
|
|
835
|
-
|
|
836
|
-
for (const
|
|
882
|
+
const own = (selector) => hostsIn(root, selector).filter((node) => node === root || heldBy(node) === root);
|
|
883
|
+
for (const selector of generated) own(selector).forEach((node) => node.remove());
|
|
884
|
+
for (const [selector, names] of Object.entries(attrs)) own(selector).forEach((node) => names.forEach((name) => node.removeAttribute(name)));
|
|
837
885
|
}
|
|
838
886
|
function clear(def, host) {
|
|
839
887
|
try {
|
|
@@ -947,10 +995,7 @@
|
|
|
947
995
|
}
|
|
948
996
|
const hostsIn = (root, selector) => [...root.matches?.(selector) ? [root] : [], ...root.querySelectorAll?.(selector) ?? []];
|
|
949
997
|
const outsidePage = (node) => Boolean(node.closest?.("[data-doc-dev]"));
|
|
950
|
-
const inOther = (def, host) =>
|
|
951
|
-
for (let around = host.closest(INSTANCE); around; around = around.parentElement?.closest(INSTANCE)) if (around.getAttribute(ATTRIBUTE) !== def.id) return true;
|
|
952
|
-
return false;
|
|
953
|
-
};
|
|
998
|
+
const inOther = (def, host) => host.matches(INSTANCE) && host.getAttribute(ATTRIBUTE) !== def.id || (heldBy(host)?.getAttribute(ATTRIBUTE) ?? def.id) !== def.id;
|
|
954
999
|
function scan(root, only, { later = false } = {}) {
|
|
955
1000
|
for (const def of only ? [only] : defs.values()) {
|
|
956
1001
|
if (!def.started || later && def.added === false) continue;
|
|
@@ -976,18 +1021,18 @@
|
|
|
976
1021
|
function showAsItStands(host) {
|
|
977
1022
|
host.setAttribute(FALLBACK, "");
|
|
978
1023
|
for (const control of host.querySelectorAll(CONTROLS2)) {
|
|
979
|
-
if (control.hasAttribute("inert")) continue;
|
|
1024
|
+
if (control.hasAttribute("inert") || heldBy(control) !== host) continue;
|
|
980
1025
|
control.setAttribute("inert", "");
|
|
981
1026
|
control.setAttribute(CONTROL_MARK, "");
|
|
982
1027
|
}
|
|
983
1028
|
showData(host);
|
|
984
1029
|
}
|
|
985
1030
|
const drawnFrom = /* @__PURE__ */ new WeakMap();
|
|
986
|
-
const dataShownIn = (host) => [...host.querySelectorAll(`.${DATA_SHOWN}`)].filter((node) => node
|
|
1031
|
+
const dataShownIn = (host) => [...host.querySelectorAll(`.${DATA_SHOWN}`)].filter((node) => ownedBy(node, host));
|
|
987
1032
|
function showData(host) {
|
|
988
1033
|
const kept = /* @__PURE__ */ new Set();
|
|
989
1034
|
for (const script of host.querySelectorAll("script")) {
|
|
990
|
-
if (script
|
|
1035
|
+
if (!ownedBy(script, host) || !isDataScript(script.localName, [...script.attributes])) continue;
|
|
991
1036
|
const next = script.nextElementSibling;
|
|
992
1037
|
if (next && drawnFrom.get(next) === script.textContent) {
|
|
993
1038
|
kept.add(next);
|
|
@@ -1006,7 +1051,7 @@
|
|
|
1006
1051
|
for (const host of hostsIn(root, INSTANCE)) {
|
|
1007
1052
|
const id = host.getAttribute(ATTRIBUTE);
|
|
1008
1053
|
const told = descriptions.get(id);
|
|
1009
|
-
if (outsidePage(host) || host
|
|
1054
|
+
if (outsidePage(host) || heldBy(host) || defs.has(id) || [...document.querySelectorAll(`script[${ARRIVING}]`)].some((script) => script.getAttribute(ARRIVING) === id)) continue;
|
|
1010
1055
|
if (told?.match && !(told.script && loaded2)) {
|
|
1011
1056
|
if (host.hasAttribute(FALLBACK)) takeFallback(host);
|
|
1012
1057
|
continue;
|
|
@@ -1027,7 +1072,13 @@
|
|
|
1027
1072
|
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", () => fallback(document), { once: true });
|
|
1028
1073
|
else fallback(document);
|
|
1029
1074
|
if (document.readyState !== "complete") global2.addEventListener("load", () => fallback(document), { once: true });
|
|
1030
|
-
const sourceParts = (host, id) => Object.values(descriptions.get(id)?.parts ?? {}).filter(({ edit }) => edit === "text" || edit === "data").flatMap(({ at }) => partsIn(host, at));
|
|
1075
|
+
const sourceParts = (host, id) => Object.values(descriptions.get(id)?.parts ?? {}).filter(({ edit }) => edit === "text" || edit === "data" || edit === "flow").flatMap(({ at, edit }) => partsIn(host, at, edit));
|
|
1076
|
+
const ownedHere = (target) => {
|
|
1077
|
+
const host = target.closest(owned);
|
|
1078
|
+
if (!host) return false;
|
|
1079
|
+
if (!host.matches(INSTANCE)) return true;
|
|
1080
|
+
return target === host || componentAt(target) && heldBy(target) === host;
|
|
1081
|
+
};
|
|
1031
1082
|
function changes(records, options) {
|
|
1032
1083
|
if (!global2.document?.defaultView) return;
|
|
1033
1084
|
const changed = [];
|
|
@@ -1040,7 +1091,7 @@
|
|
|
1040
1091
|
const target = record.target.nodeType === 1 ? record.target : record.target.parentElement;
|
|
1041
1092
|
if (!target || outsidePage(target)) continue;
|
|
1042
1093
|
if (sourced.length > 0 && record.type !== "attributes") written.push([target, record]);
|
|
1043
|
-
if (owned && target
|
|
1094
|
+
if (owned && ownedHere(target)) continue;
|
|
1044
1095
|
if (record.type === "attributes") {
|
|
1045
1096
|
revealed.add(target);
|
|
1046
1097
|
continue;
|
|
@@ -1096,10 +1147,11 @@
|
|
|
1096
1147
|
}
|
|
1097
1148
|
}
|
|
1098
1149
|
}
|
|
1099
|
-
for (const description of descriptions
|
|
1150
|
+
for (const [id, description] of descriptions) {
|
|
1100
1151
|
const marks = description.runtime ?? {};
|
|
1101
|
-
|
|
1102
|
-
for (const
|
|
1152
|
+
const of = (selector) => PACKAGE_ID.test(id) ? all(selector).filter((node) => (node.matches(INSTANCE) ? node : heldBy(node))?.getAttribute(ATTRIBUTE) === id) : all(selector);
|
|
1153
|
+
for (const selector of marks.generated ?? []) of(selector).forEach((node) => node.remove());
|
|
1154
|
+
for (const [selector, names] of Object.entries(marks.attrs ?? {})) of(selector).forEach((node) => names.forEach((name) => node.removeAttribute(name)));
|
|
1103
1155
|
for (const [selector, names] of Object.entries(marks.classes ?? {})) {
|
|
1104
1156
|
all(selector).forEach((node) => {
|
|
1105
1157
|
node.classList.remove(...names);
|
|
@@ -1402,12 +1454,12 @@
|
|
|
1402
1454
|
}
|
|
1403
1455
|
|
|
1404
1456
|
// src/render/kit/runtime/spacing.js
|
|
1405
|
-
var inert = (element) => element.closest(
|
|
1457
|
+
var inert = (element) => element.closest("pre, svg, [contenteditable], [data-doc-dev], script, style, textarea") || element.matches(INSTANCE) || componentAt(element);
|
|
1406
1458
|
var NUMBER = String.raw`\d(?:[\d.,]*\d)?(?:%|[A-Za-z]{1,3})?`;
|
|
1407
1459
|
var DASH = "[\u2013\u2014~\uFF5E]";
|
|
1408
1460
|
var CLOSING = new RegExp(String.raw`^(?:${DASH}${NUMBER})?[,。、;:!?)」』》】〉〕”’,.;:!?)\]]*`);
|
|
1409
1461
|
var RANGE = new RegExp(`${NUMBER} ?${DASH} ?${NUMBER}`);
|
|
1410
|
-
var OWN_TEXT = "code, kbd, samp, .katex, .doc-range, option";
|
|
1462
|
+
var OWN_TEXT = "code, kbd, samp, .katex, .doc-range, .doc-long-run, option";
|
|
1411
1463
|
var TEX = /\\[()[\]]|\$\$/;
|
|
1412
1464
|
var WRAPPER = /^(STRONG|B|EM|I|U|S|MARK|SPAN|A|SUB|SUP|SMALL)$/;
|
|
1413
1465
|
function tieClosing(formula) {
|
|
@@ -1458,13 +1510,36 @@
|
|
|
1458
1510
|
}
|
|
1459
1511
|
return held;
|
|
1460
1512
|
}
|
|
1461
|
-
function
|
|
1513
|
+
function holdRuns(text) {
|
|
1514
|
+
const held = [];
|
|
1515
|
+
for (const { index, length } of longRuns(text.data).reverse()) {
|
|
1516
|
+
if (index + length < text.data.length) text.splitText(index + length);
|
|
1517
|
+
held.unshift(breaking(index > 0 ? text.splitText(index) : text));
|
|
1518
|
+
}
|
|
1519
|
+
return held;
|
|
1520
|
+
}
|
|
1521
|
+
function breaking(node) {
|
|
1522
|
+
const span = node.ownerDocument.createElement("span");
|
|
1523
|
+
span.className = "doc-long-run";
|
|
1524
|
+
node.before(span);
|
|
1525
|
+
span.append(node);
|
|
1526
|
+
return span;
|
|
1527
|
+
}
|
|
1528
|
+
function textsIn(root) {
|
|
1462
1529
|
const texts = [];
|
|
1463
1530
|
const walker = root.ownerDocument.createTreeWalker(root, 4);
|
|
1464
1531
|
for (let node = walker.nextNode(); node; node = walker.nextNode()) texts.push(node);
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1532
|
+
return texts;
|
|
1533
|
+
}
|
|
1534
|
+
function looked(text) {
|
|
1535
|
+
const parent = text.parentElement;
|
|
1536
|
+
return Boolean(parent?.closest("main")) && !TEX.test(text.data) && !inert(parent) && !parent.closest(OWN_TEXT) && !(text.data.includes("$") && parent.closest("[data-doc-math-dollar]"));
|
|
1537
|
+
}
|
|
1538
|
+
function holdIn(root) {
|
|
1539
|
+
for (const text of textsIn(root)) if (RANGE.test(text.data) && looked(text)) holdRanges(text);
|
|
1540
|
+
for (const text of textsIn(root)) if (holdsLongRun(text.data) && looked(text)) holdRuns(text);
|
|
1541
|
+
for (const code of [...root.matches("code") ? [root] : [], ...root.querySelectorAll("code")]) {
|
|
1542
|
+
if (code.closest("main") && !inert(code) && !code.parentElement?.closest(`${OWN_TEXT}, td, th`) && holdsLongRun(code.textContent)) breaking(code);
|
|
1468
1543
|
}
|
|
1469
1544
|
}
|
|
1470
1545
|
function keepLines(root, flows) {
|
|
@@ -1506,8 +1581,7 @@
|
|
|
1506
1581
|
".doc-bookmark",
|
|
1507
1582
|
".doc-file",
|
|
1508
1583
|
".doc-zoom",
|
|
1509
|
-
"[data-doc-dev]"
|
|
1510
|
-
INSTANCE
|
|
1584
|
+
"[data-doc-dev]"
|
|
1511
1585
|
].join(", ");
|
|
1512
1586
|
var ZOOM_PICTURES = ".doc-page img";
|
|
1513
1587
|
var ZOOM_MARK = "data-doc-zoom";
|
|
@@ -1515,7 +1589,7 @@
|
|
|
1515
1589
|
var loaded = (img) => img.complete && (img.naturalWidth > 0 || /^data:image\/svg|\.svg(?:[?#]|$)/i.test(img.currentSrc || img.src));
|
|
1516
1590
|
function zoomable(img) {
|
|
1517
1591
|
const holder = img?.hasAttribute?.(ZOOM_MARK) ? img.parentElement : img;
|
|
1518
|
-
if (img?.localName !== "img" || !img.closest(".doc-page") || holder?.closest(ZOOM_SKIP) || !loaded(img)) return false;
|
|
1592
|
+
if (img?.localName !== "img" || !img.closest(".doc-page") || holder?.closest(ZOOM_SKIP) || holder.matches(INSTANCE) || componentAt(holder) || !loaded(img)) return false;
|
|
1519
1593
|
const box = img.getBoundingClientRect();
|
|
1520
1594
|
return box.width >= ZOOM_LEAST || box.height >= ZOOM_LEAST;
|
|
1521
1595
|
}
|
|
@@ -1695,11 +1769,12 @@
|
|
|
1695
1769
|
kit.component({ id: "bind", selector: CONTROLS3, mount: (element, context2) => bindControl(element, context2) });
|
|
1696
1770
|
kit.component({ id: "show", selector: "[data-doc-show]", mount: (element) => bindShow(element) });
|
|
1697
1771
|
kit.component({ id: "embed", mount: (figure) => showEmbed(figure), dehydrate: (figure) => dehydrateEmbed(figure) });
|
|
1698
|
-
kit.component({ id: "flowchart", selector: FLOWCHART, on: ["resize", "fonts", "content"], mount: (list2, context2) => startFlowchart(list2, context2), dehydrate: (list2) => dehydrateFlowchart(list2) });
|
|
1772
|
+
kit.component({ id: "flowchart", selector: FLOWCHART, on: ["resize", "fonts", "content", "layout"], mount: (list2, context2) => startFlowchart(list2, context2), dehydrate: (list2) => dehydrateFlowchart(list2) });
|
|
1699
1773
|
globalThis.DocKit = Object.freeze({ ...kit, bindings: store, flows: define_COMPONENT_FLOWS_default, reveal });
|
|
1700
1774
|
globalThis.ReportKit = globalThis.DocKit;
|
|
1701
1775
|
globalThis.DocKit.component({ id: "range", selector: ".doc-range", added: false, mount: () => null, dehydrate: untie });
|
|
1702
|
-
|
|
1776
|
+
globalThis.DocKit.component({ id: "long-run", selector: ".doc-long-run", added: false, mount: () => null, dehydrate: untie });
|
|
1777
|
+
startSpacing(document, ".doc-page, .doc-section, .doc-summary, .doc-panel, .doc-callout, .doc-details-content, .doc-dialog-content, [data-doc-sheet], .doc-column, [data-doc-slot], :is(.doc-section, .doc-summary, .doc-panel, .doc-callout, .doc-details-content, .doc-dialog-content, .doc-column, [data-doc-slot]) > div:not([class])");
|
|
1703
1778
|
startZoom(document);
|
|
1704
1779
|
globalThis.DocKit.component({ id: "zoom", selector: ZOOM_PICTURES, on: ["resize", "reveal"], mount: (img, context2) => watchZoom(img, context2) });
|
|
1705
1780
|
startBlockLinks(document);
|
package/kit/tables.js
CHANGED
|
@@ -384,6 +384,55 @@
|
|
|
384
384
|
for (const [cell, sides] of edges) if (cell.getAttribute(EDGE) !== sides) cell.setAttribute(EDGE, sides);
|
|
385
385
|
}
|
|
386
386
|
|
|
387
|
+
// src/shared/components/page.mjs
|
|
388
|
+
var LOOK_ATTRIBUTES = Object.freeze({ font: "data-doc-font", size: "data-doc-size", spacing: "data-doc-spacing", width: "data-doc-measure" });
|
|
389
|
+
var page_default = {
|
|
390
|
+
id: "page",
|
|
391
|
+
match: "main.doc-page",
|
|
392
|
+
flow: ".doc-page",
|
|
393
|
+
groups: false,
|
|
394
|
+
header: "header.doc-header",
|
|
395
|
+
// the title and the lines under it
|
|
396
|
+
title: ".doc-title",
|
|
397
|
+
// the document's title, the h1 of the header: its text, mirrored in <title> and report.json
|
|
398
|
+
attrs: {
|
|
399
|
+
"data-doc-id": "the document's slug: its reading state is kept under it",
|
|
400
|
+
"data-doc-kit": "a kit asset's tag (the render puts in those a report needs; an older source writes them)",
|
|
401
|
+
"data-doc-vendor": "a vendor library's tag",
|
|
402
|
+
"data-doc-placeholder": "the starter's content, which the checks want replaced",
|
|
403
|
+
"data-doc-transient-view": "its hidden or open shows transient reading state, reset in an export of the view"
|
|
404
|
+
},
|
|
405
|
+
classes: ["doc-page", "doc-header", "doc-kicker", "doc-title", "doc-button"],
|
|
406
|
+
runtime: {
|
|
407
|
+
generated: [".doc-display", "script[data-doc-state]"],
|
|
408
|
+
root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls"] },
|
|
409
|
+
// The reader's theme and width (ui.js), and the document's look (字体与布局: its doc.json's, put on by
|
|
410
|
+
// the render, src/shared/document-look.mjs), which a copy of the view keeps; never written in doc.html.
|
|
411
|
+
state: { html: ["data-doc-theme", "data-doc-width", ...Object.values(LOOK_ATTRIBUTES)] },
|
|
412
|
+
internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error"]
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
// src/shared/document-look.mjs
|
|
417
|
+
var LOOK = Object.freeze({
|
|
418
|
+
font: Object.freeze(["sans", "serif", "mixed"]),
|
|
419
|
+
// 等线体, 衬线体, 混合体 (the title and headings serif)
|
|
420
|
+
size: Object.freeze(["default", "small", "large"]),
|
|
421
|
+
// 字体大小: 小号, 默认, 大号
|
|
422
|
+
spacing: Object.freeze(["default", "compact", "loose"]),
|
|
423
|
+
// 正文间距: 紧凑, 默认, 宽松
|
|
424
|
+
width: Object.freeze(["default", "narrow", "wide"])
|
|
425
|
+
// 正文宽度: 偏窄, 默认, 偏宽
|
|
426
|
+
});
|
|
427
|
+
var SIZE_FACTOR = Object.freeze({ default: 1, small: 15 / 16, large: 18 / 16 });
|
|
428
|
+
var SPACING = Object.freeze({
|
|
429
|
+
default: Object.freeze({ leading: 1, gaps: 1 }),
|
|
430
|
+
compact: Object.freeze({ leading: 0.8, gaps: 0.75 }),
|
|
431
|
+
loose: Object.freeze({ leading: 1.2, gaps: 1.25 })
|
|
432
|
+
});
|
|
433
|
+
var WIDTH = Object.freeze({ default: 712, narrow: 648, wide: 776 });
|
|
434
|
+
var ATTRIBUTE_VALUE = String.raw`(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?`;
|
|
435
|
+
|
|
387
436
|
// src/shared/table-hides.mjs
|
|
388
437
|
function cellColumns(table) {
|
|
389
438
|
const taken = [];
|
|
@@ -683,7 +732,8 @@
|
|
|
683
732
|
function contextOf(table) {
|
|
684
733
|
const root = document.documentElement;
|
|
685
734
|
const classes = [...table.classList].filter((name) => name !== "doc-table--auto").join(" ");
|
|
686
|
-
|
|
735
|
+
const look = Object.values(LOOK_ATTRIBUTES).map((name) => root.getAttribute(name) ?? "").join("|");
|
|
736
|
+
return `${classes}${wrapperOf(table)?.className ?? ""}${root.getAttribute("data-doc-theme") ?? ""}|${root.getAttribute("data-doc-width") ?? ""}|${look}`;
|
|
687
737
|
}
|
|
688
738
|
function createCellMeasurer(table) {
|
|
689
739
|
sameZoom();
|
package/kit/ui.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
// src/shared/components/installed.mjs
|
|
4
4
|
var ATTRIBUTE = "data-doc-component";
|
|
5
5
|
var INSTANCE = `div[${ATTRIBUTE}], section[${ATTRIBUTE}]`;
|
|
6
|
+
var SLOT = "data-doc-slot";
|
|
7
|
+
var SLOT_PART = `div[${SLOT}], section[${SLOT}]`;
|
|
8
|
+
var REGION = `${INSTANCE}, ${SLOT_PART}`;
|
|
6
9
|
var PACKAGE_MARK = "data-doc-package";
|
|
7
10
|
var DATA_MOST = 1024 * 1024;
|
|
8
11
|
|
|
@@ -204,6 +207,77 @@ ${source}
|
|
|
204
207
|
}
|
|
205
208
|
}
|
|
206
209
|
|
|
210
|
+
// src/shared/components/page.mjs
|
|
211
|
+
var LOOK_ATTRIBUTES = Object.freeze({ font: "data-doc-font", size: "data-doc-size", spacing: "data-doc-spacing", width: "data-doc-measure" });
|
|
212
|
+
var page_default = {
|
|
213
|
+
id: "page",
|
|
214
|
+
match: "main.doc-page",
|
|
215
|
+
flow: ".doc-page",
|
|
216
|
+
groups: false,
|
|
217
|
+
header: "header.doc-header",
|
|
218
|
+
// the title and the lines under it
|
|
219
|
+
title: ".doc-title",
|
|
220
|
+
// the document's title, the h1 of the header: its text, mirrored in <title> and report.json
|
|
221
|
+
attrs: {
|
|
222
|
+
"data-doc-id": "the document's slug: its reading state is kept under it",
|
|
223
|
+
"data-doc-kit": "a kit asset's tag (the render puts in those a report needs; an older source writes them)",
|
|
224
|
+
"data-doc-vendor": "a vendor library's tag",
|
|
225
|
+
"data-doc-placeholder": "the starter's content, which the checks want replaced",
|
|
226
|
+
"data-doc-transient-view": "its hidden or open shows transient reading state, reset in an export of the view"
|
|
227
|
+
},
|
|
228
|
+
classes: ["doc-page", "doc-header", "doc-kicker", "doc-title", "doc-button"],
|
|
229
|
+
runtime: {
|
|
230
|
+
generated: [".doc-display", "script[data-doc-state]"],
|
|
231
|
+
root: { attrs: ["data-doc-ready", "data-doc-drawn", "data-doc-controls"] },
|
|
232
|
+
// The reader's theme and width (ui.js), and the document's look (字体与布局: its doc.json's, put on by
|
|
233
|
+
// the render, src/shared/document-look.mjs), which a copy of the view keeps; never written in doc.html.
|
|
234
|
+
state: { html: ["data-doc-theme", "data-doc-width", ...Object.values(LOOK_ATTRIBUTES)] },
|
|
235
|
+
internal: ["doc-display*", "data-doc-export-copy", "data-theme", "doc-export-id", "doc-reveal", "doc-kit-error"]
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
// src/shared/document-look.mjs
|
|
240
|
+
var LOOK = Object.freeze({
|
|
241
|
+
font: Object.freeze(["sans", "serif", "mixed"]),
|
|
242
|
+
// 等线体, 衬线体, 混合体 (the title and headings serif)
|
|
243
|
+
size: Object.freeze(["default", "small", "large"]),
|
|
244
|
+
// 字体大小: 小号, 默认, 大号
|
|
245
|
+
spacing: Object.freeze(["default", "compact", "loose"]),
|
|
246
|
+
// 正文间距: 紧凑, 默认, 宽松
|
|
247
|
+
width: Object.freeze(["default", "narrow", "wide"])
|
|
248
|
+
// 正文宽度: 偏窄, 默认, 偏宽
|
|
249
|
+
});
|
|
250
|
+
var SIZE_FACTOR = Object.freeze({ default: 1, small: 15 / 16, large: 18 / 16 });
|
|
251
|
+
var SPACING = Object.freeze({
|
|
252
|
+
default: Object.freeze({ leading: 1, gaps: 1 }),
|
|
253
|
+
compact: Object.freeze({ leading: 0.8, gaps: 0.75 }),
|
|
254
|
+
loose: Object.freeze({ leading: 1.2, gaps: 1.25 })
|
|
255
|
+
});
|
|
256
|
+
var WIDTH = Object.freeze({ default: 712, narrow: 648, wide: 776 });
|
|
257
|
+
var isPlain = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
258
|
+
function lookOf(value) {
|
|
259
|
+
const look = {};
|
|
260
|
+
if (!isPlain(value)) return look;
|
|
261
|
+
for (const [key, choices] of Object.entries(LOOK)) {
|
|
262
|
+
const chosen = value[key];
|
|
263
|
+
if (typeof chosen === "string" && choices.includes(chosen) && chosen !== choices[0]) look[key] = chosen;
|
|
264
|
+
}
|
|
265
|
+
return look;
|
|
266
|
+
}
|
|
267
|
+
var ATTRIBUTE_VALUE = String.raw`(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s"'>]+))?`;
|
|
268
|
+
function setLookOn(element, look) {
|
|
269
|
+
const next = lookOf(look);
|
|
270
|
+
let changed = false;
|
|
271
|
+
for (const [key, name] of Object.entries(LOOK_ATTRIBUTES)) {
|
|
272
|
+
const value = next[key] ?? null;
|
|
273
|
+
if (element.getAttribute(name) === value) continue;
|
|
274
|
+
if (value === null) element.removeAttribute(name);
|
|
275
|
+
else element.setAttribute(name, value);
|
|
276
|
+
changed = true;
|
|
277
|
+
}
|
|
278
|
+
return changed;
|
|
279
|
+
}
|
|
280
|
+
|
|
207
281
|
// src/render/kit/words.js
|
|
208
282
|
var DISPLAY = {
|
|
209
283
|
"display": { zh: "\u663E\u793A\u8BBE\u7F6E", en: "Display settings" },
|
|
@@ -529,6 +603,29 @@ ${clone.outerHTML}`;
|
|
|
529
603
|
updateThemeItems();
|
|
530
604
|
themeChanged();
|
|
531
605
|
});
|
|
606
|
+
const LOOK_HELD = 2e3;
|
|
607
|
+
let held = null;
|
|
608
|
+
const showLook = (look) => {
|
|
609
|
+
if (!setLookOn(root, look)) return;
|
|
610
|
+
dispatchEvent(new Event("doc-layout-change"));
|
|
611
|
+
dispatchEvent(new Event("resize"));
|
|
612
|
+
dispatchEvent(new CustomEvent("doc-look-change", { detail: { look: lookOf(look) } }));
|
|
613
|
+
};
|
|
614
|
+
addEventListener("doc-look-request", (event) => {
|
|
615
|
+
const look = event.detail?.look;
|
|
616
|
+
if (event.detail?.from === "file") {
|
|
617
|
+
if (held) held.said = look;
|
|
618
|
+
else showLook(look);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
clearTimeout(held?.timer);
|
|
622
|
+
held = { said: null, timer: setTimeout(() => {
|
|
623
|
+
const said = held?.said;
|
|
624
|
+
held = null;
|
|
625
|
+
if (said) showLook(said);
|
|
626
|
+
}, LOOK_HELD) };
|
|
627
|
+
showLook(look);
|
|
628
|
+
});
|
|
532
629
|
widthItem.addEventListener("click", () => {
|
|
533
630
|
const next = root.dataset.docWidth === "full" ? "reading" : "full";
|
|
534
631
|
if (next === "full") root.dataset.docWidth = "full";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycys/gallery",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Gallery: documents written as HTML by an AI agent, shown and edited in the browser, delivered as one offline file. The gallery command and its local server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"gallery",
|
package/release.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycys/gallery",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"built": "2026-11-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"built": "2026-11-07T19:54:21.173Z",
|
|
5
5
|
"stamps": {
|
|
6
|
-
"editor": "
|
|
6
|
+
"editor": "7973798600a49543",
|
|
7
7
|
"kit": {
|
|
8
|
-
"styles": "
|
|
8
|
+
"styles": "352e294997d57222",
|
|
9
9
|
"katex-styles": "81d0a0b4dcb41846",
|
|
10
|
-
"runtime": "
|
|
10
|
+
"runtime": "5f0ec1aab5218879",
|
|
11
11
|
"code": "0a5cdb6e4d87b122",
|
|
12
12
|
"state": "48e779637984ca20",
|
|
13
13
|
"sheets": "fda7b7b754e01019",
|
|
14
14
|
"tokens": "a218d5d5f9008530",
|
|
15
|
-
"ui": "
|
|
15
|
+
"ui": "c2df5a6e42253acc",
|
|
16
16
|
"dialogs": "42866e832540bf9f",
|
|
17
17
|
"katex": "1b0a973a02ab84f0",
|
|
18
18
|
"katex-auto-render": "63e7162ddec186d6",
|
|
19
|
-
"math": "
|
|
19
|
+
"math": "af1582414dca108c",
|
|
20
20
|
"d3": "9f5a21b6070f8353",
|
|
21
21
|
"charts": "ae38e5e52ab30cef",
|
|
22
|
-
"tables": "
|
|
22
|
+
"tables": "5138346c9a693efb"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
package/sdk/doc-kit.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ import type { DocState } from "./doc-state.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* What an instance can hear (`on`). `editable`: `context.canEdit()` has just become true, for one mounted before the page came to edit.
|
|
5
5
|
* `content`: a change inside the instance, heard only with `owns: false`, as what a component owns the
|
|
6
|
-
* kit does not watch; a change of what the file says of it is `source`, whatever it owns
|
|
6
|
+
* kit does not watch; a change of what the file says of it is `source`, whatever it owns: of a part edited
|
|
7
|
+
* as text or data, or of the blocks a slot holds (a part edited as flow), typed, moved in or out, undone.
|
|
7
8
|
*/
|
|
8
9
|
export type DocComponentSignal = "source" | "resize" | "theme" | "layout" | "viewport" | "fonts" | "content" | "reveal" | "editable";
|
|
9
10
|
|
|
@@ -41,7 +42,12 @@ export interface DocComponentContext {
|
|
|
41
42
|
frame(draw: () => void): void;
|
|
42
43
|
/** Say this instance failed: it ends there, even as `mount` runs, and shows what it holds, read-only. */
|
|
43
44
|
fail(error: unknown): void;
|
|
44
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The first element of a part of the manifest in this instance's own markup, or null. A part edited as
|
|
47
|
+
* flow gives its slot (data-doc-slot), whose blocks are the document's, the reader's: read it (its
|
|
48
|
+
* height, its words, its headings), and never write in it, move it or take it off. A name the manifest
|
|
49
|
+
* does not have throws.
|
|
50
|
+
*/
|
|
45
51
|
part(name: string): HTMLElement | null;
|
|
46
52
|
/** This instance's reading state, of no other instance of the package: the same object at every mount. */
|
|
47
53
|
state<T extends Record<string, unknown>>(options: DocComponentStateOptions<T>): DocState<T>;
|
|
@@ -59,7 +65,7 @@ export interface DocComponentContext {
|
|
|
59
65
|
* draft, or leaves what a file cannot hold (a script, a handler, an element that does not read back as
|
|
60
66
|
* itself, its own tag changed): nothing has happened then, and the console says why. Undo puts the
|
|
61
67
|
* part back and `source` tells you, like any change of it. A name the manifest does not have, or a
|
|
62
|
-
* part not edited as data, throws. A list of names changes those parts in one write, one undo step (a
|
|
68
|
+
* part not edited as data (a text part, a slot), throws. A list of names changes those parts in one write, one undo step (a
|
|
63
69
|
* gesture that moves a card and counts the move): `change` is handed a draft of each, by its name, and
|
|
64
70
|
* two that are one element, or one in the other, throw.
|
|
65
71
|
*/
|