@heycys/gallery 0.1.0 → 0.1.2
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 +45 -32
- 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/embed/index.mjs +2 -2
- 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 +7 -6
- package/browser/editor/components/flowchart/page.mjs +1 -1
- 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 +13 -2
- package/browser/editor/components/image/crop.mjs +6 -9
- package/browser/editor/components/image/page.mjs +2 -2
- package/browser/editor/components/installed/index.mjs +82 -29
- package/browser/editor/components/installed/page.mjs +146 -34
- package/browser/editor/components/installed/served.mjs +6 -5
- package/browser/editor/components/instances.mjs +18 -0
- package/browser/editor/components/kit.mjs +3 -0
- package/browser/editor/components/list/page.mjs +3 -6
- package/browser/editor/components/media/page.mjs +44 -14
- package/browser/editor/components/pages.mjs +2 -2
- package/browser/editor/components/registry.mjs +68 -33
- 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 +64 -5
- package/browser/editor/components/table/page.mjs +30 -19
- package/browser/editor/page/annotate/anchors.mjs +4 -3
- package/browser/editor/page/annotate/card.mjs +3 -6
- package/browser/editor/page/annotate/index.mjs +61 -34
- package/browser/editor/page/autosave.mjs +357 -38
- 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/board/client.mjs +57 -0
- package/browser/editor/page/board/hint.mjs +145 -0
- package/browser/editor/page/board/history.mjs +119 -0
- package/browser/editor/page/board/index.mjs +970 -0
- package/browser/editor/page/board/settings.mjs +209 -0
- package/browser/editor/page/caret.mjs +5 -2
- package/browser/editor/page/changes/bar.mjs +94 -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/import/html.mjs +29 -6
- package/browser/editor/page/clipboard/import/inline.mjs +32 -0
- package/browser/editor/page/clipboard/import/markdown.mjs +58 -13
- package/browser/editor/page/clipboard/import/read.mjs +6 -1
- package/browser/editor/page/clipboard/import/to-blocks.mjs +44 -12
- package/browser/editor/page/clipboard/import/yuque.mjs +622 -0
- package/browser/editor/page/clipboard/index.mjs +156 -26
- package/browser/editor/page/clipboard/own/blocks.mjs +25 -16
- package/browser/editor/page/clipboard/own/chart-keys.mjs +41 -28
- 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 +3 -3
- package/browser/editor/page/clipboard/own/writers.mjs +0 -11
- package/browser/editor/page/columns/index.mjs +48 -46
- package/browser/editor/page/commit.mjs +98 -25
- package/browser/editor/page/conflicts.mjs +13 -33
- package/browser/editor/page/convert.mjs +8 -7
- package/browser/editor/page/core.mjs +81 -27
- package/browser/editor/page/custom-page.mjs +106 -0
- package/browser/editor/page/drag/index.mjs +40 -24
- package/browser/editor/page/drag/preview.mjs +9 -4
- package/browser/editor/page/editor.mjs +120 -28
- 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 +156 -2
- package/browser/editor/page/emoji-picker/support.mjs +6 -4
- package/browser/editor/page/emoji-picker/upload.mjs +14 -13
- 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 +22 -14
- package/browser/editor/page/hints/index.mjs +1 -1
- package/browser/editor/page/history.mjs +24 -4
- package/browser/editor/page/insert/index.mjs +30 -17
- package/browser/editor/page/links/index.mjs +5 -3
- package/browser/editor/page/links/pages.mjs +27 -9
- package/browser/editor/page/long-runs.mjs +75 -0
- package/browser/editor/page/look.mjs +69 -6
- package/browser/editor/page/margin.mjs +63 -27
- package/browser/editor/page/media-menu/index.mjs +6 -7
- package/browser/editor/page/menu.mjs +86 -31
- package/browser/editor/page/merge.mjs +24 -0
- package/browser/editor/page/notices.mjs +3 -3
- 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/page-objects.mjs +13 -2
- package/browser/editor/page/panel.mjs +9 -13
- package/browser/editor/page/present-links.mjs +11 -2
- package/browser/editor/page/resize/index.mjs +42 -29
- package/browser/editor/page/selection/delete.mjs +8 -6
- package/browser/editor/page/selection/index.mjs +10 -3
- package/browser/editor/page/served.mjs +14 -0
- package/browser/editor/page/session.mjs +101 -6
- package/browser/editor/page/slash-menu/index.mjs +3 -3
- package/browser/editor/page/table/cell-bar.mjs +4 -1
- package/browser/editor/page/table/cells.mjs +103 -47
- package/browser/editor/page/table/icons.mjs +3 -1
- package/browser/editor/page/table/index.mjs +40 -16
- package/browser/editor/page/table/pictures.mjs +299 -0
- package/browser/editor/page/table/views.mjs +150 -0
- package/browser/editor/page/table/widths.mjs +9 -4
- package/browser/editor/page/text-select/index.mjs +43 -14
- package/browser/editor/page/todo-writes.mjs +75 -0
- 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 +65 -9
- package/browser/editor/page/typing/leave.mjs +1 -1
- package/browser/editor/page/ui.mjs +13 -0
- package/browser/shared/annotations.mjs +8 -10
- package/browser/shared/block-packs.mjs +404 -0
- package/browser/shared/board-places.mjs +224 -0
- package/browser/shared/card-size.mjs +59 -0
- package/browser/shared/code-folds.mjs +5 -1
- package/browser/shared/colors.mjs +17 -14
- package/browser/shared/component-catalog.mjs +345 -54
- package/browser/shared/component-source.mjs +37 -0
- package/browser/shared/components/callout.mjs +4 -2
- package/browser/shared/components/index.mjs +72 -9
- package/browser/shared/components/installed.mjs +110 -8
- package/browser/shared/components/page.mjs +22 -3
- package/browser/shared/components/state.mjs +5 -1
- package/browser/shared/components/table.mjs +1 -1
- package/browser/shared/components/text.mjs +2 -2
- package/browser/shared/document-look.mjs +183 -0
- package/browser/shared/drafts.mjs +432 -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/extension-sidebar.mjs +126 -0
- package/browser/shared/extensions.mjs +79 -0
- package/browser/shared/file-table.mjs +101 -0
- package/browser/shared/html-tree.mjs +11 -5
- package/browser/shared/i18n/en.mjs +374 -35
- package/browser/shared/json-layout.mjs +47 -0
- package/browser/shared/long-runs.mjs +39 -0
- package/browser/shared/net-cache.mjs +133 -0
- package/browser/shared/net-keys.mjs +32 -0
- package/browser/shared/net-policy.mjs +177 -0
- package/browser/shared/new-names.mjs +5 -2
- package/browser/shared/outline-shape.mjs +128 -0
- package/browser/shared/outline.mjs +458 -0
- package/browser/shared/pack-manifest.mjs +77 -0
- package/browser/shared/page-address.mjs +6 -3
- package/browser/shared/page-cards.mjs +308 -0
- package/browser/shared/page-links.mjs +69 -6
- package/browser/shared/pages.mjs +388 -0
- package/browser/shared/paths.mjs +6 -0
- package/browser/shared/preferences.mjs +10 -4
- package/browser/shared/preview-server.mjs +3 -7
- package/browser/shared/session.mjs +13 -5
- package/browser/shared/shipped-blocks.mjs +299 -0
- package/browser/shared/table-chart.mjs +33 -1
- package/browser/shared/todos.mjs +83 -0
- package/browser/shared/user-directory.mjs +24 -0
- package/browser/shared/versions.mjs +14 -0
- package/browser/shared/web-links.mjs +134 -0
- package/browser/shared/workspace-columns.mjs +120 -0
- package/browser/shared/workspace-look.mjs +91 -0
- package/browser/shared/workspace-name.mjs +154 -0
- package/browser/shared/workspace-query.mjs +125 -0
- package/browser/shared/workspace-registry.mjs +272 -0
- package/browser/shared/workspace.mjs +171 -20
- package/browser/shared/zoom.mjs +5 -5
- package/dist/chunk-2NRBY6AJ.mjs +2 -0
- package/dist/chunk-32ZUEFZ7.mjs +2 -0
- package/dist/chunk-35NQ4PLQ.mjs +2 -0
- package/dist/chunk-3KJHLHUO.mjs +2 -0
- package/dist/chunk-3NJACR4W.mjs +2 -0
- package/dist/chunk-4AV456RQ.mjs +2 -0
- package/dist/chunk-4OZWXZE5.mjs +5 -0
- package/dist/chunk-5XYHDBJ5.mjs +2 -0
- package/dist/chunk-5ZJA7CXT.mjs +2 -0
- package/dist/chunk-6A53MZYZ.mjs +2 -0
- package/dist/chunk-6EXH3ORZ.mjs +166 -0
- package/dist/chunk-6EZ7FNIK.mjs +3 -0
- package/dist/{chunk-UXUK4PMC.mjs → chunk-6QBHU4DF.mjs} +1 -1
- package/dist/{chunk-6U2SLSDN.mjs → chunk-6VTU6KEO.mjs} +1 -1
- package/dist/chunk-B4P2CM2J.mjs +3 -0
- package/dist/chunk-BPL64HGA.mjs +4 -0
- package/dist/chunk-BVEFGE4B.mjs +2 -0
- package/dist/chunk-BZ5RAF7L.mjs +2 -0
- package/dist/chunk-CRJEG7MT.mjs +2 -0
- package/dist/{chunk-B3VTYBYR.mjs → chunk-D4CKRD3V.mjs} +91 -91
- package/dist/chunk-D4EURAX4.mjs +4 -0
- package/dist/chunk-DQCE7TJY.mjs +5 -0
- package/dist/chunk-DR73Y2UJ.mjs +3 -0
- package/dist/{chunk-TMYZB6AV.mjs → chunk-EKNHM3P4.mjs} +1 -1
- package/dist/{chunk-DB4WKGYF.mjs → chunk-ERLAIBOA.mjs} +2 -2
- package/dist/chunk-EURLTOTZ.mjs +4 -0
- package/dist/chunk-FJYN7RTH.mjs +4 -0
- package/dist/chunk-FWNRPMCJ.mjs +12 -0
- package/dist/chunk-FWW4CSAZ.mjs +2 -0
- package/dist/{chunk-2B5E4CDJ.mjs → chunk-GPIWQ4X4.mjs} +1 -1
- package/dist/chunk-GY3FAUVM.mjs +2 -0
- package/dist/chunk-HLYV7RIH.mjs +2 -0
- package/dist/chunk-HMYTM3GT.mjs +15 -0
- package/dist/chunk-IA4PSIMD.mjs +2 -0
- package/dist/chunk-JEUK3ZO7.mjs +2 -0
- package/dist/chunk-JVHHHGEA.mjs +3 -0
- package/dist/chunk-KTKHRC6H.mjs +2 -0
- package/dist/chunk-L7UP52JO.mjs +2 -0
- package/dist/chunk-MHW7ZKOU.mjs +2 -0
- package/dist/chunk-N76HWBA3.mjs +10 -0
- package/dist/chunk-N7AZZLGT.mjs +548 -0
- package/dist/chunk-NAMN3RAF.mjs +2 -0
- package/dist/{chunk-YXAUQPVK.mjs → chunk-NFMCP2HI.mjs} +3 -3
- package/dist/chunk-NG375ILQ.mjs +2 -0
- package/dist/chunk-NVRNLK25.mjs +6 -0
- package/dist/chunk-NWFBE2YA.mjs +2 -0
- package/dist/chunk-NWR2LT5B.mjs +2 -0
- package/dist/chunk-OJKMINIU.mjs +20 -0
- package/dist/chunk-OUUP3WKT.mjs +2 -0
- package/dist/chunk-OW5NWPOJ.mjs +10 -0
- package/dist/chunk-PAREWQGB.mjs +4 -0
- package/dist/chunk-POQSE4C2.mjs +2 -0
- package/dist/chunk-PUOQ65NC.mjs +2 -0
- package/dist/{chunk-Z52HTUW7.mjs → chunk-PVER7LSC.mjs} +2 -2
- package/dist/chunk-PZDLJJTJ.mjs +3 -0
- package/dist/chunk-Q47PLKIJ.mjs +15 -0
- package/dist/chunk-Q4UEPUWF.mjs +2 -0
- package/dist/chunk-QKXMPUXC.mjs +2 -0
- package/dist/chunk-QOUEFUCH.mjs +16 -0
- package/dist/chunk-RFDZXFJF.mjs +13 -0
- package/dist/chunk-RKPWLGZ3.mjs +4 -0
- package/dist/chunk-RMECZA2K.mjs +2 -0
- package/dist/{chunk-EUX7IC5J.mjs → chunk-SQ6Y2ZMA.mjs} +2 -2
- package/dist/chunk-SX4LJYT6.mjs +8 -0
- package/dist/chunk-SXHBYZST.mjs +16 -0
- package/dist/chunk-TANZRINB.mjs +2 -0
- package/dist/chunk-TEZAWDSQ.mjs +2 -0
- package/dist/chunk-UBBRTJ2R.mjs +24 -0
- package/dist/chunk-UFNYFFKO.mjs +20 -0
- package/dist/chunk-UGWYKHBL.mjs +170 -0
- package/dist/chunk-UKSHDZZ6.mjs +2 -0
- package/dist/chunk-UMHUSOPJ.mjs +2 -0
- package/dist/chunk-UNOYVIYR.mjs +2 -0
- package/dist/chunk-V6RIYQZZ.mjs +4 -0
- package/dist/chunk-VJPFVNNW.mjs +15 -0
- package/dist/chunk-VS3ZMVGX.mjs +5 -0
- package/dist/chunk-VTKNEYT3.mjs +6 -0
- package/dist/chunk-VXACTLO3.mjs +3 -0
- package/dist/chunk-W3BGBJQW.mjs +2 -0
- package/dist/chunk-YI43RG4P.mjs +2 -0
- package/dist/chunk-YQGT4AB2.mjs +6 -0
- package/dist/chunk-ZB4H7ZN4.mjs +2 -0
- package/dist/{chunk-ACOPDCNB.mjs → chunk-ZHEHPMBK.mjs} +1 -1
- package/dist/chunk-ZTHICSSF.mjs +2 -0
- package/dist/chunk-ZUNVAXLH.mjs +2 -0
- package/dist/chunk-ZWPMCK7P.mjs +2 -0
- package/dist/cli.mjs +1 -1
- package/dist/server.mjs +1 -1
- package/dist/{chunk-EVJ3BX3M.mjs → update-fetch.mjs} +1 -1
- package/dist/worker.mjs +1 -1
- package/kit/board.css +95 -0
- package/kit/board.js +250 -0
- package/kit/charts.js +5 -71
- package/kit/code.js +14 -14
- package/kit/math.js +18 -2
- package/kit/report.css +500 -151
- package/kit/runtime.js +1720 -170
- package/kit/state.js +10 -1
- package/kit/tables.js +172 -37
- package/kit/ui.js +166 -27
- package/package.json +2 -1
- package/packs/gallery/card/component.json +14 -0
- package/packs/gallery/card/example.html +10 -0
- package/packs/gallery/card/preview.svg +1 -0
- package/packs/gallery/card/style.css +6 -0
- package/packs/gallery/card/template.html +6 -0
- package/packs/gallery/card/writing.md +14 -0
- package/packs/gallery/chart-card/component.json +15 -0
- package/packs/gallery/chart-card/example.html +14 -0
- package/packs/gallery/chart-card/kit.js +130 -0
- package/packs/gallery/chart-card/preview.svg +1 -0
- package/packs/gallery/chart-card/style.css +42 -0
- package/packs/gallery/chart-card/template.html +13 -0
- package/packs/gallery/chart-card/writing.md +20 -0
- package/packs/gallery/chart-view/component.json +20 -0
- package/packs/gallery/chart-view/example.html +13 -0
- package/packs/gallery/chart-view/kit.js +355 -0
- package/packs/gallery/chart-view/preview.svg +1 -0
- package/packs/gallery/chart-view/style.css +94 -0
- package/packs/gallery/chart-view/template.html +3 -0
- package/packs/gallery/chart-view/writing.md +22 -0
- package/packs/gallery/countdown/component.json +18 -0
- package/packs/gallery/countdown/example.html +3 -0
- package/packs/gallery/countdown/kit.js +156 -0
- package/packs/gallery/countdown/preview.svg +1 -0
- package/packs/gallery/countdown/style.css +130 -0
- package/packs/gallery/countdown/template.html +3 -0
- package/packs/gallery/countdown/writing.md +22 -0
- package/packs/gallery/habit/component.json +14 -0
- package/packs/gallery/habit/example.html +3 -0
- package/packs/gallery/habit/kit.js +295 -0
- package/packs/gallery/habit/preview.svg +1 -0
- package/packs/gallery/habit/style.css +246 -0
- package/packs/gallery/habit/template.html +3 -0
- package/packs/gallery/habit/writing.md +21 -0
- package/packs/gallery/heatmap/component.json +18 -0
- package/packs/gallery/heatmap/example.html +3 -0
- package/packs/gallery/heatmap/kit.js +351 -0
- package/packs/gallery/heatmap/preview.svg +1 -0
- package/packs/gallery/heatmap/style.css +201 -0
- package/packs/gallery/heatmap/template.html +3 -0
- package/packs/gallery/heatmap/writing.md +21 -0
- package/packs/gallery/kanban/component.json +18 -0
- package/packs/gallery/kanban/example.html +12 -0
- package/packs/gallery/kanban/kit.js +540 -0
- package/packs/gallery/kanban/preview.svg +1 -0
- package/packs/gallery/kanban/style.css +212 -0
- package/packs/gallery/kanban/template.html +3 -0
- package/packs/gallery/kanban/writing.md +20 -0
- package/packs/gallery/metric/component.json +22 -0
- package/packs/gallery/metric/example.html +15 -0
- package/packs/gallery/metric/kit.js +248 -0
- package/packs/gallery/metric/preview.svg +1 -0
- package/packs/gallery/metric/style.css +92 -0
- package/packs/gallery/metric/template.html +3 -0
- package/packs/gallery/metric/writing.md +23 -0
- package/packs/gallery/note/component.json +14 -0
- package/packs/gallery/note/example.html +3 -0
- package/packs/gallery/note/kit.js +102 -0
- package/packs/gallery/note/preview.svg +1 -0
- package/packs/gallery/note/style.css +76 -0
- package/packs/gallery/note/template.html +3 -0
- package/packs/gallery/note/writing.md +18 -0
- package/packs/gallery/pack.json +8 -0
- package/packs/gallery/recent/component.json +13 -0
- package/packs/gallery/recent/example.html +1 -0
- package/packs/gallery/recent/kit.js +238 -0
- package/packs/gallery/recent/preview.svg +1 -0
- package/packs/gallery/recent/style.css +158 -0
- package/packs/gallery/recent/template.html +1 -0
- package/packs/gallery/recent/writing.md +15 -0
- package/packs/gallery/static/component.json +13 -0
- package/packs/gallery/static/example.html +11 -0
- package/packs/gallery/static/preview.svg +1 -0
- package/packs/gallery/static/style.css +138 -0
- package/packs/gallery/static/template.html +1 -0
- package/packs/gallery/static/writing.md +18 -0
- package/packs/gallery/stats/component.json +13 -0
- package/packs/gallery/stats/example.html +1 -0
- package/packs/gallery/stats/kit.js +166 -0
- package/packs/gallery/stats/preview.svg +1 -0
- package/packs/gallery/stats/style.css +151 -0
- package/packs/gallery/stats/template.html +1 -0
- package/packs/gallery/stats/writing.md +11 -0
- package/packs/gallery/today/component.json +12 -0
- package/packs/gallery/today/example.html +1 -0
- package/packs/gallery/today/kit.js +185 -0
- package/packs/gallery/today/preview.svg +1 -0
- package/packs/gallery/today/style.css +120 -0
- package/packs/gallery/today/template.html +1 -0
- package/packs/gallery/today/writing.md +14 -0
- package/packs/gallery/todos/component.json +19 -0
- package/packs/gallery/todos/example.html +3 -0
- package/packs/gallery/todos/kit.js +342 -0
- package/packs/gallery/todos/preview.svg +1 -0
- package/packs/gallery/todos/style.css +267 -0
- package/packs/gallery/todos/template.html +3 -0
- package/packs/gallery/todos/writing.md +30 -0
- package/packs/gallery/weather/component.json +19 -0
- package/packs/gallery/weather/example.html +3 -0
- package/packs/gallery/weather/kit.js +312 -0
- package/packs/gallery/weather/preview.svg +1 -0
- package/packs/gallery/weather/style.css +258 -0
- package/packs/gallery/weather/template.html +3 -0
- package/packs/gallery/weather/writing.md +26 -0
- package/packs/gallery-soft/pack.json +8 -0
- package/release.json +13 -11
- package/sdk/doc-kit.d.ts +404 -7
- package/sdk/doc-state.d.ts +2 -0
- package/skill/SKILL.md +71 -26
- package/skill/references/block-script.md +140 -0
- package/skill/references/building-blocks.md +257 -0
- package/skill/references/example-report.html +1 -1
- package/skill/references/extensions.md +59 -0
- package/skill/references/pages-and-data.md +221 -0
- package/skill/references/writing-html.md +9 -7
- package/skill/sdk/doc-kit.d.ts +404 -7
- package/skill/sdk/doc-state.d.ts +2 -0
- package/web/assets/index-BK2e_07w.js +13 -0
- package/web/assets/index-CWFI83mF.css +1 -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-6CYG3Z4V.mjs +0 -2
- package/dist/chunk-7GHT2UCA.mjs +0 -15
- package/dist/chunk-7QQBR7PB.mjs +0 -2
- package/dist/chunk-ATCJYAR4.mjs +0 -2
- package/dist/chunk-C7HWOBIF.mjs +0 -2
- package/dist/chunk-E7VYDG2X.mjs +0 -2
- package/dist/chunk-EZY3WC6Z.mjs +0 -15
- package/dist/chunk-FQGQH4KM.mjs +0 -2
- package/dist/chunk-G7TOXONE.mjs +0 -6
- package/dist/chunk-GPF4YWWB.mjs +0 -9
- package/dist/chunk-GYQV7Y4J.mjs +0 -120
- package/dist/chunk-HMHK3EQ6.mjs +0 -2
- package/dist/chunk-HQQMJCQJ.mjs +0 -10
- package/dist/chunk-IERUOGC3.mjs +0 -6
- package/dist/chunk-ITNLYXXV.mjs +0 -3
- package/dist/chunk-L4DVONOG.mjs +0 -2
- package/dist/chunk-LAE5NQ4B.mjs +0 -2
- package/dist/chunk-LC7YNQFG.mjs +0 -2
- package/dist/chunk-LHTFLRB6.mjs +0 -4
- package/dist/chunk-NFIBI4IP.mjs +0 -26
- package/dist/chunk-NSKUTQ5J.mjs +0 -5
- package/dist/chunk-O52JMOCZ.mjs +0 -2
- package/dist/chunk-P2CAZPDP.mjs +0 -3
- package/dist/chunk-QMQUXTU4.mjs +0 -12
- package/dist/chunk-QVWVFC5K.mjs +0 -6
- package/dist/chunk-QYKCJ7FG.mjs +0 -8
- package/dist/chunk-QZY6Q64C.mjs +0 -2
- package/dist/chunk-TDQP3DKQ.mjs +0 -10
- package/dist/chunk-TX6JH7TR.mjs +0 -2
- package/dist/chunk-UNUEWH4S.mjs +0 -2
- 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/dist/chunk-YZ5Z6H4W.mjs +0 -4
- package/dist/chunk-ZBIM6ARY.mjs +0 -216
- package/skill/references/building-components.md +0 -327
- package/web/assets/index-B6Ai3wsa.js +0 -13
- package/web/assets/index-SYPC3EZy.css +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createBlockInfo } from "./block-info.mjs";
|
|
2
2
|
import { createBlockMenu } from "./block-menu/index.mjs";
|
|
3
3
|
import { createDrag } from "./drag/index.mjs";
|
|
4
|
+
import { createFolds } from "./fold/index.mjs";
|
|
4
5
|
import { createHandle } from "./handle/index.mjs";
|
|
5
6
|
import { createMenu } from "./menu.mjs";
|
|
6
7
|
import { createDelete } from "./selection/delete.mjs";
|
|
@@ -19,6 +20,7 @@ import { pageObjects } from "./page-objects.mjs";
|
|
|
19
20
|
// block-menu/ the menu a handle opens: turning a block into another type, layout, a new block below, columns, sections, deleting
|
|
20
21
|
// selection/ the selected blocks and their fills; box selection (marquee.mjs); deleting (delete.mjs)
|
|
21
22
|
// drag/ moving blocks: dragging a handle, where they would go (drop.mjs), Ctrl+Shift+arrows
|
|
23
|
+
// fold/ a heading's section folded: the triangle right of its words, what is hidden, the section going with its heading
|
|
22
24
|
//
|
|
23
25
|
// What they share: what the page knows of a block (block-info.mjs), the menu card (menu.mjs), one
|
|
24
26
|
// task of the editor's frames (frames.mjs) that keeps the handle, the bar and the fills where their
|
|
@@ -49,8 +51,9 @@ import { pageObjects } from "./page-objects.mjs";
|
|
|
49
51
|
* notes.write(units) the annotation begun.
|
|
50
52
|
* copyLink(unit): 复制块链接, the block menu's (the editor's copyBlockLink), or null for no such row.
|
|
51
53
|
* linkAhead(): a block's menu opens with that row in it: what the click will want is read now.
|
|
54
|
+
* slug: the report's (what is folded is kept by report: fold/).
|
|
52
55
|
*/
|
|
53
|
-
export function createBlocks({ units, boxes, active, struct, look, say, edit, turnInto, convert, turnIntoAll = () => null, convertAll = () => null, below, belowTypes = () => [], add, after = () => false, blank, nest, keepsHandle = () => false, addNear = () => {}, copyLink = () => {}, linkAhead = () => {}, notes }) {
|
|
56
|
+
export function createBlocks({ slug = "", units, boxes, active, struct, look, say, edit, turnInto, convert, turnIntoAll = () => null, convertAll = () => null, below, belowTypes = () => [], add, after = () => false, blank, nest, keepsHandle = () => false, addNear = () => {}, copyLink = () => {}, linkAhead = () => {}, notes }) {
|
|
54
57
|
const info = createBlockInfo({ units, boxes });
|
|
55
58
|
const menu = createMenu();
|
|
56
59
|
const closeMenu = () => menu.close();
|
|
@@ -59,10 +62,11 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
59
62
|
const schedule = () => frames.wake();
|
|
60
63
|
|
|
61
64
|
const selection = createSelection({ info, active, say, closeMenu, schedule });
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
65
|
+
const folds = createFolds({ slug, selection, active, schedule });
|
|
66
|
+
const drag = createDrag({ info, selection, struct, say, closeMenu, schedule, folds });
|
|
67
|
+
const blockMenu = createBlockMenu({ info, menu, selection, remove: (targets) => remove(targets), takenWith: folds.takenWith, turnInto, convert, turnIntoAll, convertAll, below, belowTypes, add, look, copyLink, linkAhead });
|
|
68
|
+
const handle = createHandle({ info, active, selection, drag, menu, openMenu: blockMenu.open, drawing: () => marquee.drawing, schedule, keeps: (node) => keepsHandle(node) || folds.holds(node), aside: folds.holds, add: (target, where) => { selection.clear(); addNear(target, where); }, notes });
|
|
69
|
+
const remove = createDelete({ info, selection, struct, say, closeMenu, forget: () => handle.forget(), folds });
|
|
66
70
|
// What a component makes with these tools (`blockTools`): a Sheet's tabs as Notion's pills, a click, a drag, their menu, + (components/sheets/pills.mjs).
|
|
67
71
|
const parts = pageObjects().flatMap((page) => page.blockTools?.({ active, drag, menu, openMenu: blockMenu.open, struct, say }) ?? []);
|
|
68
72
|
// A press on empty space: a box selection, or a click there (marquee.mjs clears the selection).
|
|
@@ -86,8 +90,9 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
86
90
|
step("drag", () => drag.step(), () => drag.end(false));
|
|
87
91
|
step("selection", () => selection.paint(drag.active), () => selection.unpaint());
|
|
88
92
|
step("handle", () => handle.place(), () => handle.hide());
|
|
93
|
+
step("fold", () => folds.place(handle.pointed), () => folds.hide());
|
|
89
94
|
if (drag.active) return true;
|
|
90
|
-
return handle.showing || selection.picked.length > 0 ? FOLLOW : false;
|
|
95
|
+
return handle.showing || folds.showing || selection.picked.length > 0 ? FOLLOW : false;
|
|
91
96
|
}
|
|
92
97
|
|
|
93
98
|
// One tool's part of a frame; when it throws, what that tool draws goes, and it is said.
|
|
@@ -105,7 +110,7 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
105
110
|
// A press anywhere but on the block tools closes the menu; on a divider line it selects the line,
|
|
106
111
|
// on empty space it may start a box selection, elsewhere it clears the selection.
|
|
107
112
|
document.addEventListener("pointerdown", (event) => {
|
|
108
|
-
if (handle.holds(event.target) || menu.contains(event.target) || parts.some((part) => part.holds(event.target))) return;
|
|
113
|
+
if (handle.holds(event.target) || folds.holds(event.target) || menu.contains(event.target) || parts.some((part) => part.holds(event.target))) return;
|
|
109
114
|
closeMenu();
|
|
110
115
|
const line = event.button === 0 && active() ? handle.lineAt(event.target, event.clientX, event.clientY) : null;
|
|
111
116
|
if (line) {
|
|
@@ -199,6 +204,7 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
199
204
|
drag.end(false);
|
|
200
205
|
marquee.cancel();
|
|
201
206
|
handle.hide();
|
|
207
|
+
folds.hide();
|
|
202
208
|
selection.unpaint();
|
|
203
209
|
}
|
|
204
210
|
|
|
@@ -206,6 +212,7 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
206
212
|
if (drag.active) drag.end(false);
|
|
207
213
|
marquee.cancel();
|
|
208
214
|
handle.hide();
|
|
215
|
+
folds.hide();
|
|
209
216
|
parts.forEach((part) => part.hide());
|
|
210
217
|
selection.hide();
|
|
211
218
|
closeMenu();
|
|
@@ -225,6 +232,8 @@ export function createBlocks({ units, boxes, active, struct, look, say, edit, tu
|
|
|
225
232
|
mark: selection.mark,
|
|
226
233
|
keepText: info.keepText,
|
|
227
234
|
moveBy: drag.moveBy,
|
|
235
|
+
/** Headings' sections folded (fold/). */
|
|
236
|
+
folds,
|
|
228
237
|
remove,
|
|
229
238
|
closeMenu,
|
|
230
239
|
/** A block selected and its menu open by `rect` (a component's own button: an image's 更多). */
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { postAnswer } from "../post.mjs";
|
|
2
|
+
|
|
3
|
+
// What a custom page's board editing sends the page service (POST /__gallery/pages/<slug>/cards:
|
|
4
|
+
// src/editor/page-service.mjs), one task at a time, in the order asked. A task is the whole of what the
|
|
5
|
+
// page does for one gesture or one step of undo: what it sends, built only once its turn comes, and what
|
|
6
|
+
// it does with the answer (each card's cells and base taken in, the undo step pushed or moved), all done
|
|
7
|
+
// before the next task starts. So a write sent while one before it waits for its answer goes with the
|
|
8
|
+
// bases that answer gave (a block's two context.edit calls in a row, two quick Ctrl+Z on one card, a
|
|
9
|
+
// Ctrl+Z pressed before a drop is answered, which undoes the drop), never with those it had when it was
|
|
10
|
+
// asked, which the service would refuse as changed. It knows which versions of the page are its own (the
|
|
11
|
+
// one it was served at, and each its ops wrote), so that the live script's "page <version>" of its own
|
|
12
|
+
// write changes nothing, and it says when an answer was applied to a version that is none of them:
|
|
13
|
+
// someone else wrote the page meanwhile (`others`), which the page then shows again.
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* slug, token, version: the page map's. others(): someone else wrote the page (an op's answer was
|
|
17
|
+
* applied to another version than the page's). Returns { run(task) (task(send) run once every task asked
|
|
18
|
+
* before it is done, `send(body)` giving the service's answer: { ok, … }, its refusal, or { ok: false,
|
|
19
|
+
* reason: "offline" } where it cannot be reached; resolves with what the task gives), ours(version), busy,
|
|
20
|
+
* idle() (a promise of the tasks asked so far being done) }.
|
|
21
|
+
*/
|
|
22
|
+
export function createClient({ slug, token, version, others = () => {} }) {
|
|
23
|
+
const route = `/__gallery/pages/${slug}/cards`;
|
|
24
|
+
const ours = new Set([version]);
|
|
25
|
+
let current = version;
|
|
26
|
+
let waiting = 0;
|
|
27
|
+
let chain = Promise.resolve();
|
|
28
|
+
const send = async (body) => {
|
|
29
|
+
const answer = await postAnswer(route, token, body);
|
|
30
|
+
if (answer?.ok) {
|
|
31
|
+
const before = answer.before;
|
|
32
|
+
ours.add(answer.version);
|
|
33
|
+
if (before !== current && !ours.has(before)) others();
|
|
34
|
+
current = answer.version;
|
|
35
|
+
}
|
|
36
|
+
return answer;
|
|
37
|
+
};
|
|
38
|
+
const run = (task) => {
|
|
39
|
+
waiting++;
|
|
40
|
+
const done = chain.then(() => task(send)).finally(() => {
|
|
41
|
+
waiting--;
|
|
42
|
+
});
|
|
43
|
+
chain = done.catch(() => {}); // a task that threw is its asker's to hear of; the next goes on
|
|
44
|
+
return done;
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
run,
|
|
48
|
+
/** Whether `version` is the page's own: served at it, or written to it by an op. */
|
|
49
|
+
ours: (version) => ours.has(version),
|
|
50
|
+
/** Whether a task is asked and not yet done (sent, answered and taken in). */
|
|
51
|
+
get busy() {
|
|
52
|
+
return waiting > 0;
|
|
53
|
+
},
|
|
54
|
+
/** Once every task asked so far is done. */
|
|
55
|
+
idle: () => chain,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { language, t } from "../../../shared/i18n/index.mjs";
|
|
2
|
+
import { postAnswer } from "../post.mjs";
|
|
3
|
+
import { say } from "../notices.mjs";
|
|
4
|
+
import { addStyle, element } from "../ui.mjs";
|
|
5
|
+
|
|
6
|
+
// The home page's first-open note (notes/plans/component-pages-plan-2026-11-07.md §5.2; docs/render.md
|
|
7
|
+
// "A custom page", **The default home page**): at the top of the home page, while the page map says
|
|
8
|
+
// `hint` (src/server/routes.mjs: the home page, its note not yet closed in this workspace), a short
|
|
9
|
+
// note on its cards: how to move one (the grip at its top-right: drag it), open its menu (a click on
|
|
10
|
+
// the same grip: 大小, 设置, 删除), add one (添加自定义块: the first item of the ··· menu at the top right of the workbench's bar; a page open
|
|
11
|
+
// alone in a tab has it at the top right of its board) and take one out (the menu's 删除), and that a new
|
|
12
|
+
// card or a new page is the Agent's to make, with a sentence the reader can copy and say to one (its 复制
|
|
13
|
+
// button). Its × closes it for good, for the workspace (POST
|
|
14
|
+
// /__gallery/pages/home/hint: .gallery/hints.json), whichever browser shows the page next. In the
|
|
15
|
+
// editor's look: grays alone, a quiet fill, no colour; the kit's own light and dark through the
|
|
16
|
+
// editor's tokens (look.mjs).
|
|
17
|
+
//
|
|
18
|
+
// And its note of new default cards (showNews: the plan's 3.4), on a home page made before them (a phase 2
|
|
19
|
+
// home: 问候与日期 and 便签 alone), while the page map says `news`: which default cards it does not hold
|
|
20
|
+
// that came since (我的待办, 最近编辑, 工作区统计, 编辑热力图), and that 加到首页 puts them in the empty spots
|
|
21
|
+
// as 恢复默认卡片 in the home page's menu in the sidebar does (the board's restoreDefaults: what is missing
|
|
22
|
+
// alone, the cards there untouched, one step of the page's undo). A home already made is never changed by
|
|
23
|
+
// itself: the reader is told once, at the top of the page, where the first-open note stands, and nothing
|
|
24
|
+
// moves on the board until they ask. Its × (or 加到首页) says it for the workspace (POST
|
|
25
|
+
// /__gallery/pages/home/hint with { cards: true }), which 恢复默认卡片 from the sidebar does too.
|
|
26
|
+
|
|
27
|
+
const STYLE = `
|
|
28
|
+
.ge-home-hint { box-sizing: border-box; max-width: var(--gallery-board-width, 944px); margin: 0 auto 12px; }
|
|
29
|
+
.ge-home-hint-box { position: relative; box-sizing: border-box; max-width: 720px; padding: 14px 44px 14px 16px; border-radius: 10px;
|
|
30
|
+
background: light-dark(rgb(55 53 47 / 4%), rgb(255 255 255 / 4.5%)); color: var(--ge-tx);
|
|
31
|
+
font: 14px/1.6 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Helvetica, "PingFang SC", "Microsoft YaHei", Arial, sans-serif; }
|
|
32
|
+
.ge-home-hint-box p { margin: 0; }
|
|
33
|
+
.ge-home-hint-box p + p { margin-top: 4px; }
|
|
34
|
+
.ge-home-hint-title { font-weight: 600; }
|
|
35
|
+
.ge-home-hint-box .ge-home-hint-ask { margin-top: 10px; color: var(--ge-tx2); }
|
|
36
|
+
.ge-home-hint-icon { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin: 0 2px; vertical-align: -3px; border-radius: 4px; background: var(--ge-hover); color: var(--ge-ico2); }
|
|
37
|
+
.ge-home-hint-icon svg { display: block; width: 10px; height: 12px; fill: currentColor; }
|
|
38
|
+
.ge-home-hint-say { display: flex; align-items: center; gap: 8px; margin-top: 6px; padding: 6px 6px 6px 12px; border-radius: 6px; background: var(--ge-bg); }
|
|
39
|
+
.ge-home-hint-say span { flex: 1; min-width: 0; color: var(--ge-tx); user-select: text; }
|
|
40
|
+
.ge-home-hint-copy, .ge-home-hint-close { flex: none; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; border: 0; border-radius: 6px; background: transparent; color: var(--ge-tx2); font: inherit; cursor: pointer; user-select: none; }
|
|
41
|
+
.ge-home-hint-copy { height: 28px; padding: 0 10px; font-size: 13px; }
|
|
42
|
+
.ge-home-hint-copy:hover, .ge-home-hint-close:hover { background: var(--ge-hover); color: var(--ge-tx); }
|
|
43
|
+
.ge-home-hint-copy:active, .ge-home-hint-close:active { background: var(--ge-press); }
|
|
44
|
+
.ge-home-hint-close { position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; color: var(--ge-ico3); }
|
|
45
|
+
.ge-home-hint-close svg { display: block; width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
|
|
46
|
+
.ge-home-hint-act { margin-top: 8px; }
|
|
47
|
+
.ge-home-hint-box .ge-home-hint-add { margin-left: -2px; background: var(--ge-btn-primary); color: var(--ge-btn-primary-text); }
|
|
48
|
+
.ge-home-hint-box .ge-home-hint-add:hover:not(:disabled) { background: var(--ge-btn-primary-hover); color: var(--ge-btn-primary-text); }
|
|
49
|
+
.ge-home-hint-box .ge-home-hint-add:disabled { opacity: .5; cursor: default; }
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
const DOTS = '<svg viewBox="0 0 10 16" aria-hidden="true"><circle cx="2.5" cy="2" r="1.25"/><circle cx="7.5" cy="2" r="1.25"/><circle cx="2.5" cy="8" r="1.25"/><circle cx="7.5" cy="8" r="1.25"/><circle cx="2.5" cy="14" r="1.25"/><circle cx="7.5" cy="14" r="1.25"/></svg>';
|
|
53
|
+
const CLOSE = '<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 4l8 8M12 4l-8 8"/></svg>';
|
|
54
|
+
|
|
55
|
+
// `template` (t's words, {0}, {1}… where `nodes` go) as the nodes of a line.
|
|
56
|
+
function filled(template, nodes) {
|
|
57
|
+
return template.split(/\{(\d+)\}/).map((piece, index) => (index % 2 ? nodes[Number(piece)] ?? "" : piece)).filter((piece) => piece !== "");
|
|
58
|
+
}
|
|
59
|
+
const icon = (html) => element("span", { class: "ge-home-hint-icon", html });
|
|
60
|
+
// A note at the top of the home page, of the editor's UI (never the file's): `kind` its class beside ge-home-hint, `label` what it is called.
|
|
61
|
+
const noteOf = (kind, label, box) => element("div", { class: `ge-home-hint${kind ? ` ${kind}` : ""}`, role: "note", "aria-label": label, "data-doc-dev": "" }, box);
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The note of new default cards, on the home page whose map says `news` ([{ block, name }]), at the top of
|
|
65
|
+
* the page, after the first-open note where that is shown; `restore`, the board's restoreDefaults. Returns
|
|
66
|
+
* the note, or null where none is shown.
|
|
67
|
+
*/
|
|
68
|
+
export function showNews(map, { restore }) {
|
|
69
|
+
const main = document.querySelector("main.gallery-page");
|
|
70
|
+
if (!map?.news?.length || !main) return null;
|
|
71
|
+
addStyle(STYLE);
|
|
72
|
+
const named = ({ block, name }) => name?.[language === "en" ? "en" : "zh"] ?? name?.zh ?? block;
|
|
73
|
+
const add = element("button", { type: "button", class: "ge-home-hint-copy ge-home-hint-add", text: t("加到首页") });
|
|
74
|
+
const close = element("button", { type: "button", class: "ge-home-hint-close", "aria-label": t("关闭这条说明"), title: t("关闭"), html: CLOSE });
|
|
75
|
+
const box = element("div", { class: "ge-home-hint-box" },
|
|
76
|
+
element("p", { class: "ge-home-hint-title", text: t("首页有了新的卡片") }),
|
|
77
|
+
element("p", { text: map.news.map(named).join(t("、")) }),
|
|
78
|
+
element("p", { class: "ge-home-hint-ask", text: t("点「加到首页」放进空位,已有的卡片不动。以后也可以在侧栏里首页的菜单中点「恢复默认卡片」。") }),
|
|
79
|
+
element("div", { class: "ge-home-hint-act" }, add),
|
|
80
|
+
close);
|
|
81
|
+
const note = noteOf("ge-home-news", t("首页的新卡片"), box);
|
|
82
|
+
for (const button of [add, close]) button.addEventListener("mousedown", (event) => event.preventDefault());
|
|
83
|
+
const told = () => postAnswer(`/__gallery/pages/${map.slug}/hint`, map.token, { cards: true });
|
|
84
|
+
add.addEventListener("click", async () => {
|
|
85
|
+
add.disabled = true;
|
|
86
|
+
const answer = await restore();
|
|
87
|
+
if (!answer?.ok) {
|
|
88
|
+
add.disabled = false;
|
|
89
|
+
return say(t("没能把卡片放到首页"), "error");
|
|
90
|
+
}
|
|
91
|
+
note.remove();
|
|
92
|
+
const added = answer.added ?? [];
|
|
93
|
+
say(added.length ? t("已放回默认卡片:{0}", added.map(named).join(t("、"))) : t("默认卡片都在,没有要放回的"));
|
|
94
|
+
});
|
|
95
|
+
close.addEventListener("click", async () => {
|
|
96
|
+
note.remove();
|
|
97
|
+
const answer = await told();
|
|
98
|
+
if (!answer?.ok) say(t("没能记下这条说明已关闭"), "error");
|
|
99
|
+
});
|
|
100
|
+
const first = main.querySelector(":scope > .ge-home-hint");
|
|
101
|
+
if (first) first.after(note);
|
|
102
|
+
else main.prepend(note);
|
|
103
|
+
return note;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The note shown, on the home page whose map (`map`: slug, token) says `hint`, at the top of the page
|
|
108
|
+
* (`main.gallery-page`, before what the page holds). `hosted`: the page stands in a workbench, whose top
|
|
109
|
+
* bar's ··· menu has 添加自定义块 (the words say so), else the page's own at the top right of its board. Returns the
|
|
110
|
+
* note, or null where none is shown.
|
|
111
|
+
*/
|
|
112
|
+
export function showHint(map, { hosted = false } = {}) {
|
|
113
|
+
const main = document.querySelector("main.gallery-page");
|
|
114
|
+
if (!map?.hint || !main) return null;
|
|
115
|
+
addStyle(STYLE);
|
|
116
|
+
// The sentence offered: one that names Gallery, so that the Agent takes up its skill.
|
|
117
|
+
const ask = t("用 Gallery 在首页加一张卡片,记我每天喝了几杯水。别动我摆好的卡片。");
|
|
118
|
+
const copy = element("button", { type: "button", class: "ge-home-hint-copy", text: t("复制") });
|
|
119
|
+
const close = element("button", { type: "button", class: "ge-home-hint-close", "aria-label": t("关闭这条说明"), title: t("关闭"), html: CLOSE });
|
|
120
|
+
const box = element("div", { class: "ge-home-hint-box" },
|
|
121
|
+
element("p", { class: "ge-home-hint-title", text: t("这是你的首页") }),
|
|
122
|
+
element("p", {}, ...filled(hosted ? t("拖卡片右上角的 {0} 移动它,点一下它打开菜单(大小、设置、删除),点页面右上角的 ··· 里的「添加自定义块」加一张。") : t("拖卡片右上角的 {0} 移动它,点一下它打开菜单(大小、设置、删除),点页面右上方的「添加自定义块」加一张。"), [icon(DOTS)])),
|
|
123
|
+
element("p", { class: "ge-home-hint-ask", text: t("想要新卡片或新页面,跟 Agent 说,比如:") }),
|
|
124
|
+
element("div", { class: "ge-home-hint-say" }, element("span", { text: ask }), copy),
|
|
125
|
+
close);
|
|
126
|
+
const note = noteOf("", t("首页的说明"), box);
|
|
127
|
+
for (const button of [copy, close]) button.addEventListener("mousedown", (event) => event.preventDefault());
|
|
128
|
+
copy.addEventListener("click", () => {
|
|
129
|
+
// The frame given the focus first: in a workbench a press its mousedown keeps from moving the focus
|
|
130
|
+
// leaves it in the workbench, and Chrome refuses a clipboard write to a document without it
|
|
131
|
+
// ("Document is not focused"), as the board's grip takes it for the page's keys.
|
|
132
|
+
window.focus();
|
|
133
|
+
navigator.clipboard?.writeText(ask).then(() => {
|
|
134
|
+
copy.textContent = t("已复制");
|
|
135
|
+
say(t("已复制这句话,发给 Agent 就行"));
|
|
136
|
+
}, () => say(t("没能复制:浏览器不允许写剪贴板。"), "error"));
|
|
137
|
+
});
|
|
138
|
+
close.addEventListener("click", async () => {
|
|
139
|
+
note.remove();
|
|
140
|
+
const answer = await postAnswer(`/__gallery/pages/${map.slug}/hint`, map.token, {});
|
|
141
|
+
if (!answer?.ok) say(t("没能记下这条说明已关闭"), "error");
|
|
142
|
+
});
|
|
143
|
+
main.prepend(note);
|
|
144
|
+
return note;
|
|
145
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// A custom page's own undo and redo (docs/render.md "A custom page", the board's editing): what the
|
|
2
|
+
// page did, each step a list of what to send the page service to take it back or do it again, never
|
|
3
|
+
// a copy of the file. Kept in the tab's sessionStorage by the page's slug, so that a page shown again
|
|
4
|
+
// (the hidden frame's swap after a card is added from the library, or after someone else wrote
|
|
5
|
+
// page.html) undoes what this one did: the next page takes the steps up, and forgets those of a card
|
|
6
|
+
// someone else changed meanwhile (`forgetChanged`: its base, as the page knew it last, is not the one
|
|
7
|
+
// it is served with), whose undo would write over what they did. Each step names its cards by id; what
|
|
8
|
+
// it sends is held to each card's base as the page knows it then, so a card someone else changed is
|
|
9
|
+
// refused by the service whenever the page has not yet heard of it.
|
|
10
|
+
//
|
|
11
|
+
// A step is one of:
|
|
12
|
+
// { kind: "cells", cards: [{ id, before: { x, y, w, h }, after: { x, y, w, h } }] } moved, resized, pushed
|
|
13
|
+
// { kind: "edit", id, parts: { <name>: { was, now } } } a block's data or its settings
|
|
14
|
+
// { kind: "remove", id, board, html } a card taken out
|
|
15
|
+
// { kind: "add", id, board, html } a card put in
|
|
16
|
+
// { kind: "group", steps: [step, …] } several at once (恢复默认卡片's cards)
|
|
17
|
+
// { kind: "checked", slug, ref, done } a to-do of document `slug` checked (done) or not by a block
|
|
18
|
+
|
|
19
|
+
const MOST = 100; // steps kept each way
|
|
20
|
+
|
|
21
|
+
const read = (key) => {
|
|
22
|
+
try {
|
|
23
|
+
const value = JSON.parse(sessionStorage.getItem(key) ?? "null");
|
|
24
|
+
return value && Array.isArray(value.undo) && Array.isArray(value.redo) && value.bases && typeof value.bases === "object" ? value : null;
|
|
25
|
+
} catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** The page `slug`'s steps. */
|
|
31
|
+
export function createHistory(slug) {
|
|
32
|
+
const key = `gallery-edit:${slug}:page-history`; // an editor key as the others (gallery-edit:<slug>:<kind>, shared/renamed-storage.mjs): made after the rename, so no old name
|
|
33
|
+
const kept = read(key);
|
|
34
|
+
let undo = kept?.undo ?? [];
|
|
35
|
+
let redo = kept?.redo ?? [];
|
|
36
|
+
let bases = kept?.bases ?? {}; // a card's id -> its base as this page knew it last
|
|
37
|
+
let measure = kept?.measure ?? null; // a card just added whose height its content gives, to measure once shown
|
|
38
|
+
const save = () => {
|
|
39
|
+
try {
|
|
40
|
+
sessionStorage.setItem(key, JSON.stringify({ undo, redo, bases, measure }));
|
|
41
|
+
} catch {} // no storage: the steps last as long as the page
|
|
42
|
+
};
|
|
43
|
+
const touches = (step, id) => (step.kind === "group" ? step.steps.some((one) => touches(one, id)) : step.kind === "cells" ? step.cards.some((card) => card.id === id) : step.id === id);
|
|
44
|
+
const rename = (step, from, to) => {
|
|
45
|
+
if (step.kind === "group") for (const one of step.steps) rename(one, from, to);
|
|
46
|
+
else if (step.kind === "cells") for (const card of step.cards) card.id = card.id === from ? to : card.id;
|
|
47
|
+
else if (step.id === from) step.id = to;
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
/** A step done: undo takes it back first; what was undone cannot be done again any more. */
|
|
51
|
+
push(step) {
|
|
52
|
+
undo.push(step);
|
|
53
|
+
if (undo.length > MOST) undo.shift();
|
|
54
|
+
redo = [];
|
|
55
|
+
save();
|
|
56
|
+
},
|
|
57
|
+
/** The step undo takes back now, left where it is (null: none). */
|
|
58
|
+
nextUndo: () => undo.at(-1) ?? null,
|
|
59
|
+
/** The step undo takes back now, taken off (null: none). */
|
|
60
|
+
takeUndo: () => {
|
|
61
|
+
const step = undo.pop() ?? null;
|
|
62
|
+
save();
|
|
63
|
+
return step;
|
|
64
|
+
},
|
|
65
|
+
takeRedo: () => {
|
|
66
|
+
const step = redo.pop() ?? null;
|
|
67
|
+
save();
|
|
68
|
+
return step;
|
|
69
|
+
},
|
|
70
|
+
/** A step undone (it can be done again) or done again (it can be undone again). */
|
|
71
|
+
undone(step) {
|
|
72
|
+
redo.push(step);
|
|
73
|
+
save();
|
|
74
|
+
},
|
|
75
|
+
redone(step) {
|
|
76
|
+
undo.push(step);
|
|
77
|
+
save();
|
|
78
|
+
},
|
|
79
|
+
/** Card `from` goes by `to` now (put back under another id): the steps say so. */
|
|
80
|
+
renamed(from, to) {
|
|
81
|
+
for (const step of [...undo, ...redo]) rename(step, from, to);
|
|
82
|
+
save();
|
|
83
|
+
},
|
|
84
|
+
/** The cards' bases as this page knows them now ({ id: base }), for the next page to hold its own against. */
|
|
85
|
+
know(now) {
|
|
86
|
+
bases = { ...now };
|
|
87
|
+
save();
|
|
88
|
+
},
|
|
89
|
+
/**
|
|
90
|
+
* The page shown again: the steps of each card whose base (`served`, { id: base }) is not the one the
|
|
91
|
+
* page before knew are forgotten, someone else's change of it standing; so is a card gone or come.
|
|
92
|
+
*/
|
|
93
|
+
forgetChanged(served) {
|
|
94
|
+
const changed = Object.keys(bases).filter((id) => served[id] !== bases[id]);
|
|
95
|
+
const gone = (step) => changed.some((id) => touches(step, id));
|
|
96
|
+
undo = undo.filter((step) => !gone(step));
|
|
97
|
+
redo = redo.filter((step) => !gone(step));
|
|
98
|
+
bases = { ...served };
|
|
99
|
+
save();
|
|
100
|
+
},
|
|
101
|
+
/** A card added whose height is its content's: measured once the next page shows it (`take`: and forgotten). */
|
|
102
|
+
toMeasure(id) {
|
|
103
|
+
measure = id;
|
|
104
|
+
save();
|
|
105
|
+
},
|
|
106
|
+
takeMeasure() {
|
|
107
|
+
const id = measure;
|
|
108
|
+
measure = null;
|
|
109
|
+
save();
|
|
110
|
+
return id;
|
|
111
|
+
},
|
|
112
|
+
get canUndo() {
|
|
113
|
+
return undo.length > 0;
|
|
114
|
+
},
|
|
115
|
+
get canRedo() {
|
|
116
|
+
return redo.length > 0;
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|