@jant/core 0.10.0 → 0.11.0
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/bin/commands/db/execute-file.js +1 -1
- package/bin/commands/db/export.js +1 -1
- package/bin/commands/migrate.js +4 -4
- package/bin/commands/posts/rebuild-html.js +1 -1
- package/bin/commands/reset-password.js +1 -1
- package/bin/commands/search/reindex.js +1 -1
- package/bin/commands/setup.js +4 -2
- package/bin/commands/site/export.js +3 -0
- package/bin/commands/site/import.js +178 -91
- package/bin/commands/site/pull-media.js +3 -2
- package/bin/commands/site/snapshot/export.js +3 -1
- package/bin/commands/site/snapshot/import.js +3 -2
- package/bin/commands/start.js +44 -0
- package/bin/commands/telegram/register-webhooks.js +1 -1
- package/bin/commands/uploads/cleanup.js +48 -9
- package/bin/jant.js +39 -4
- package/bin/lib/import-sources.js +151 -0
- package/bin/lib/node-env.js +14 -9
- package/bin/lib/runtime-target.js +1 -1
- package/bin/lib/site-pull-media.js +56 -4
- package/bin/lib/site-snapshot.js +39 -2
- package/bin/lib/sql-export.js +66 -10
- package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
- package/dist/client/.vite/manifest.json +38 -38
- package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
- package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
- package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
- package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
- package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
- package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
- package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
- package/dist/client/_assets/client-52vQhZAv.js +296 -0
- package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
- package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
- package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
- package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
- package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
- package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
- package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +33 -1
- package/dist/node.js +57 -13
- package/package.json +13 -18
- package/src/__tests__/api-docs.test.ts +168 -1
- package/src/__tests__/bin/import-sources.test.ts +85 -0
- package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
- package/src/__tests__/cli-commands.test.ts +40 -0
- package/src/__tests__/config-docs.test.ts +119 -16
- package/src/__tests__/custom-url-redirects.test.ts +108 -0
- package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
- package/src/__tests__/export-docs.test.ts +113 -41
- package/src/__tests__/export-feed-ids.test.ts +1 -0
- package/src/__tests__/export-format-version.test.ts +88 -0
- package/src/__tests__/export-hugo-build.test.ts +139 -4
- package/src/__tests__/export-import-roundtrip.test.ts +2 -1
- package/src/__tests__/export-service.test.ts +42 -13
- package/src/__tests__/export-smart-collection.test.ts +1 -1
- package/src/__tests__/feed-docs.test.ts +287 -21
- package/src/__tests__/feed-reply-addresses.test.ts +100 -0
- package/src/__tests__/feeds-disabled.test.ts +98 -0
- package/src/__tests__/fixtures/export-format/1.json +76 -0
- package/src/__tests__/fixtures/export-format/2.json +80 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
- package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
- package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
- package/src/__tests__/helpers/app.ts +6 -1
- package/src/__tests__/helpers/export-fixtures.ts +1 -0
- package/src/__tests__/import-refused-aliases.test.ts +98 -0
- package/src/__tests__/import-site-command.test.ts +73 -8
- package/src/__tests__/public-types.test.ts +64 -0
- package/src/__tests__/release-fixtures.test.ts +79 -24
- package/src/__tests__/release-version.test.ts +84 -0
- package/src/__tests__/site-pull-media.test.ts +48 -0
- package/src/__tests__/snapshot-tables.test.ts +37 -0
- package/src/__tests__/sql-export.test.ts +21 -1
- package/src/__tests__/stored-file-headers.test.ts +94 -0
- package/src/__tests__/template-deploy-workflow.test.ts +101 -0
- package/src/__tests__/theme-docs.test.ts +113 -24
- package/src/__tests__/toolchain-versions.test.ts +54 -0
- package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
- package/src/__tests__/vite-config-graph.test.ts +98 -0
- package/src/app.tsx +89 -66
- package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
- package/src/client/__tests__/compose-bridge.test.ts +87 -0
- package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
- package/src/client/__tests__/footnote-rail.test.ts +1 -1
- package/src/client/__tests__/lazy-entries.test.ts +1 -1
- package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
- package/src/client/avatar-upload.ts +10 -10
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
- package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
- package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
- package/src/client/components/compose-types.ts +14 -0
- package/src/client/components/jant-compose-dialog.ts +96 -41
- package/src/client/components/jant-compose-editor.ts +21 -4
- package/src/client/components/jant-config-editor.ts +4 -6
- package/src/client/components/jant-media-lightbox.ts +4 -4
- package/src/client/components/jant-settings-general.ts +0 -4
- package/src/client/components/nav-manager-types.ts +6 -5
- package/src/client/compose-bridge.ts +15 -4
- package/src/client/compose-launch.ts +4 -6
- package/src/client/compose-shortcuts.ts +1 -1
- package/src/client/footnote-rail.ts +1 -1
- package/src/client/lazy-entries.ts +1 -1
- package/src/client/media-scroll-hint.ts +2 -2
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
- package/src/client/tiptap/markdown-clipboard.ts +50 -2
- package/src/client/upload-session.ts +7 -6
- package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
- package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
- package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
- package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
- package/src/i18n/locales/public/en.po +46 -48
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +45 -46
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +45 -46
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +15 -29
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +15 -29
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +15 -29
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/index.ts +43 -2
- package/src/lib/__tests__/api-settings.test.ts +3 -3
- package/src/lib/__tests__/constants.test.ts +10 -0
- package/src/lib/__tests__/discover.test.ts +8 -9
- package/src/lib/__tests__/env-values.test.ts +125 -0
- package/src/lib/__tests__/feed-path.test.ts +29 -0
- package/src/lib/__tests__/feed.test.ts +50 -22
- package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
- package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
- package/src/lib/__tests__/rate-limit.test.ts +22 -7
- package/src/lib/__tests__/resolve-config.test.ts +5 -3
- package/src/lib/__tests__/schemas.test.ts +72 -23
- package/src/lib/__tests__/slugify.test.ts +9 -0
- package/src/lib/__tests__/startup-config.test.ts +12 -0
- package/src/lib/__tests__/storage-s3.test.ts +214 -0
- package/src/lib/__tests__/theme.test.ts +20 -1
- package/src/lib/__tests__/time.test.ts +56 -0
- package/src/lib/__tests__/timeline.test.ts +46 -0
- package/src/lib/__tests__/url-fetch.test.ts +65 -1
- package/src/lib/__tests__/url.test.ts +60 -1
- package/src/lib/api-nav-items.ts +16 -20
- package/src/lib/api-post-input.ts +34 -1
- package/src/lib/api-posts.ts +125 -23
- package/src/lib/api-public-posts.ts +28 -37
- package/src/lib/api-search.ts +49 -2
- package/src/lib/api-settings.ts +159 -54
- package/src/lib/api-threads.ts +34 -11
- package/src/lib/constants.ts +6 -0
- package/src/lib/discover.ts +7 -23
- package/src/lib/env-values.ts +140 -0
- package/src/lib/env.ts +203 -12
- package/src/lib/feed-path.ts +8 -2
- package/src/lib/feed-policy.ts +110 -7
- package/src/lib/feed.ts +69 -25
- package/src/lib/filter-dimensions.ts +17 -10
- package/src/lib/github-sync-site-config.ts +1 -0
- package/src/lib/hugo-markdown.ts +5 -6
- package/src/lib/navigation.ts +4 -1
- package/src/lib/post-list-cursor.ts +33 -29
- package/src/lib/public-storage.ts +43 -0
- package/src/lib/rate-limit.ts +31 -16
- package/src/lib/render.tsx +5 -0
- package/src/lib/resolve-config.ts +16 -19
- package/src/lib/schemas.ts +248 -180
- package/src/lib/slugify.ts +6 -1
- package/src/lib/sse.ts +1 -1
- package/src/lib/startup-config.ts +20 -1
- package/src/lib/theme.ts +8 -5
- package/src/lib/thread-fold.ts +6 -0
- package/src/lib/thread-query.ts +19 -24
- package/src/lib/time.ts +137 -17
- package/src/lib/timeline.ts +56 -13
- package/src/lib/url-fetch.ts +141 -40
- package/src/lib/url.ts +86 -1
- package/src/middleware/__tests__/auth.test.ts +27 -0
- package/src/middleware/__tests__/cors.test.ts +54 -0
- package/src/middleware/__tests__/cross-origin.test.ts +149 -0
- package/src/middleware/__tests__/public-content-access.test.ts +2 -42
- package/src/middleware/auth.ts +34 -3
- package/src/middleware/cors.ts +4 -4
- package/src/middleware/cross-origin.ts +124 -0
- package/src/middleware/error-handler.ts +7 -0
- package/src/middleware/public-content-access.ts +3 -26
- package/src/middleware/secure-headers.ts +8 -2
- package/src/node/__tests__/cli-migrate.test.ts +2 -2
- package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
- package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
- package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
- package/src/node/__tests__/cli-sql-export.test.ts +25 -1
- package/src/node/__tests__/cli-start.test.ts +66 -0
- package/src/node/__tests__/request-handler.test.ts +37 -0
- package/src/node/__tests__/runtime.test.ts +56 -1
- package/src/node/request-handler.ts +58 -5
- package/src/node/runtime.ts +37 -11
- package/src/preset.css +3 -3
- package/src/routes/__tests__/compose.test.ts +84 -0
- package/src/routes/api/__tests__/collections.test.ts +68 -0
- package/src/routes/api/__tests__/mcp.test.ts +164 -9
- package/src/routes/api/__tests__/media.test.ts +9 -1
- package/src/routes/api/__tests__/nav-items.test.ts +27 -1
- package/src/routes/api/__tests__/posts.test.ts +269 -78
- package/src/routes/api/__tests__/search.test.ts +17 -4
- package/src/routes/api/__tests__/settings.test.ts +119 -85
- package/src/routes/api/__tests__/telegram.test.ts +11 -6
- package/src/routes/api/__tests__/threads.test.ts +11 -0
- package/src/routes/api/__tests__/upload-response.test.ts +48 -0
- package/src/routes/api/__tests__/uploads.test.ts +35 -2
- package/src/routes/api/collections.ts +3 -3
- package/src/routes/api/custom-urls.ts +2 -1
- package/src/routes/api/export.ts +1 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
- package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
- package/src/routes/api/internal/sites.ts +16 -4
- package/src/routes/api/mcp.ts +1 -0
- package/src/routes/api/media.ts +7 -8
- package/src/routes/api/nav-items.ts +2 -1
- package/src/routes/api/posts.ts +18 -24
- package/src/routes/api/public/__tests__/posts.test.ts +15 -0
- package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
- package/src/routes/api/public/__tests__/threads.test.ts +41 -9
- package/src/routes/api/public/posts.ts +2 -2
- package/src/routes/api/public/threads.ts +16 -26
- package/src/routes/api/search.ts +7 -41
- package/src/routes/api/settings.ts +32 -28
- package/src/routes/api/smart-collections.ts +6 -1
- package/src/routes/api/threads.ts +25 -26
- package/src/routes/api/upload.ts +6 -21
- package/src/routes/api/uploads.ts +14 -20
- package/src/routes/auth/__tests__/dev.test.ts +16 -13
- package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
- package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
- package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
- package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
- package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
- package/src/routes/auth/__tests__/signin.test.ts +167 -2
- package/src/routes/auth/dev.ts +4 -6
- package/src/routes/auth/hosted-sso.ts +9 -6
- package/src/routes/auth/setup.tsx +35 -5
- package/src/routes/auth/signin.tsx +96 -1
- package/src/routes/compose.tsx +47 -47
- package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
- package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
- package/src/routes/dash/custom-urls.tsx +2 -0
- package/src/routes/dash/settings.tsx +79 -32
- package/src/routes/feed/__tests__/feed.test.ts +93 -3
- package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
- package/src/routes/feed/feed.ts +128 -175
- package/src/routes/feed/sitemap.ts +9 -7
- package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
- package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
- package/src/routes/pages/__tests__/collections.test.ts +3 -0
- package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
- package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
- package/src/routes/pages/__tests__/search.test.ts +5 -2
- package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
- package/src/routes/pages/archive.tsx +33 -94
- package/src/routes/pages/brand.tsx +1 -0
- package/src/routes/pages/collection.tsx +13 -84
- package/src/routes/pages/collections.tsx +2 -0
- package/src/routes/pages/featured.tsx +7 -2
- package/src/routes/pages/home.tsx +1 -0
- package/src/routes/pages/latest.tsx +6 -2
- package/src/routes/pages/new.tsx +1 -0
- package/src/routes/pages/page.tsx +73 -47
- package/src/routes/pages/search.tsx +5 -3
- package/src/routes/pages/smart-collection.tsx +11 -70
- package/src/routes/pages/subscribe.tsx +1 -0
- package/src/routes/pages/theme-sample.tsx +1 -0
- package/src/runtime/__tests__/readiness.test.ts +16 -0
- package/src/runtime/cloudflare.ts +2 -3
- package/src/runtime/index.ts +3 -1
- package/src/runtime/node.ts +3 -5
- package/src/runtime/readiness.ts +5 -0
- package/src/services/__tests__/auth.test.ts +115 -0
- package/src/services/__tests__/collection.test.ts +9 -0
- package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
- package/src/services/__tests__/hosted-handoff.test.ts +208 -1
- package/src/services/__tests__/media.test.ts +47 -27
- package/src/services/__tests__/navigation.test.ts +67 -15
- package/src/services/__tests__/post.test.ts +103 -56
- package/src/services/__tests__/search.test.ts +38 -0
- package/src/services/__tests__/settings.test.ts +2 -14
- package/src/services/__tests__/smart-collection.test.ts +2 -2
- package/src/services/__tests__/telegram-ingest.test.ts +113 -0
- package/src/services/__tests__/thread.test.ts +26 -11
- package/src/services/auth.ts +36 -4
- package/src/services/collection.ts +46 -5
- package/src/services/custom-url.ts +11 -4
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +2 -2
- package/src/services/export-theme/layouts/_default/baseof.html +1 -1
- package/src/services/export-theme/layouts/collection/single.html +1 -1
- package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
- package/src/services/export-theme/layouts/partials/head.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
- package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
- package/src/services/export-theme/styles/main.css +3 -3
- package/src/services/export.ts +68 -19
- package/src/services/github-sync.ts +10 -10
- package/src/services/hosted-handoff.ts +106 -6
- package/src/services/index.ts +3 -1
- package/src/services/language.ts +33 -0
- package/src/services/mcp.ts +176 -438
- package/src/services/media.ts +69 -21
- package/src/services/navigation.ts +19 -4
- package/src/services/path.ts +45 -3
- package/src/services/post.ts +329 -214
- package/src/services/search.ts +22 -3
- package/src/services/settings.ts +36 -3
- package/src/services/site-admin.ts +1 -0
- package/src/services/smart-collection.ts +10 -3
- package/src/services/telegram.ts +23 -6
- package/src/services/thread.ts +11 -3
- package/src/services/upload-session.ts +14 -15
- package/src/styles/components.css +2 -2
- package/src/styles/site-media.css +2 -2
- package/src/styles/tokens.css +19 -22
- package/src/styles/ui-author.css +73 -94
- package/src/styles/ui.css +62 -62
- package/src/types/app-context.ts +5 -1
- package/src/types/bindings.ts +11 -0
- package/src/types/config.ts +4 -4
- package/src/types/constants.ts +20 -0
- package/src/types/props.ts +34 -8
- package/src/types/views.ts +28 -13
- package/src/ui/color-themes.ts +6 -5
- package/src/ui/dash/settings/GeneralContent.tsx +0 -22
- package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
- package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
- package/src/ui/feed/LinkCard.tsx +1 -2
- package/src/ui/feed/NoteCard.tsx +1 -2
- package/src/ui/feed/QuoteCard.tsx +2 -2
- package/src/ui/feed/ThreadPreview.tsx +6 -6
- package/src/ui/feed/TimelineFeed.tsx +1 -7
- package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
- package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
- package/src/ui/layouts/BaseLayout.tsx +5 -0
- package/src/ui/pages/ArchivePage.tsx +1 -1
- package/src/ui/pages/BrandPage.tsx +1 -1
- package/src/ui/pages/CollectionPage.tsx +0 -1
- package/src/ui/pages/CollectionsPage.tsx +2 -2
- package/src/ui/pages/ComposePage.tsx +1 -1
- package/src/ui/pages/FeaturedPage.tsx +1 -1
- package/src/ui/pages/HomePage.tsx +1 -1
- package/src/ui/pages/PostPage.tsx +1 -1
- package/src/ui/pages/SearchPage.tsx +1 -1
- package/src/ui/pages/SmartCollectionPage.tsx +2 -3
- package/src/ui/pages/SubscribePage.tsx +1 -1
- package/src/ui/pages/ThemeSamplePage.tsx +1 -1
- package/src/ui/shared/MediaGallery.tsx +1 -1
- package/src/vendor/datastar.js +9 -1956
- package/src/vendor/datastar.js.map +4 -4
- package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
- package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
- package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
- package/dist/client/_assets/client-DRuw7XCt.css +0 -2
- package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
|
@@ -160,15 +160,8 @@ interface ComposeReplyOpenOptions {
|
|
|
160
160
|
restoreMedia?: LocalDraftMedia[];
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
collectionIds: string[];
|
|
166
|
-
slug: string;
|
|
167
|
-
publishedAtInput: string;
|
|
168
|
-
publishedAtTimeMinutes: number | null;
|
|
169
|
-
visibility: ComposeVisibility;
|
|
170
|
-
/** The author's explicit language choice, not what detection reads. */
|
|
171
|
-
language: string | null;
|
|
163
|
+
/** What one editor holds, compared to tell whether the author changed it. */
|
|
164
|
+
interface ComposeEditorSnapshot {
|
|
172
165
|
title: string;
|
|
173
166
|
bodyJson: JSONContent | null;
|
|
174
167
|
url: string;
|
|
@@ -196,6 +189,30 @@ interface ComposeStateSnapshot {
|
|
|
196
189
|
attachmentOrder: string[];
|
|
197
190
|
}
|
|
198
191
|
|
|
192
|
+
interface ComposeStateSnapshot extends ComposeEditorSnapshot {
|
|
193
|
+
format: ComposeFormat;
|
|
194
|
+
collectionIds: string[];
|
|
195
|
+
slug: string;
|
|
196
|
+
publishedAtInput: string;
|
|
197
|
+
publishedAtTimeMinutes: number | null;
|
|
198
|
+
visibility: ComposeVisibility;
|
|
199
|
+
/** The author's explicit language choice, not what detection reads. */
|
|
200
|
+
language: string | null;
|
|
201
|
+
/**
|
|
202
|
+
* Each post of a Thread, in order, and empty outside one. The fields above
|
|
203
|
+
* come from the first editor only, so without these an edit to a later post,
|
|
204
|
+
* or a post added or removed, would not count as a change.
|
|
205
|
+
*/
|
|
206
|
+
threadPosts: Array<
|
|
207
|
+
ComposeEditorSnapshot & {
|
|
208
|
+
format: ComposeFormat;
|
|
209
|
+
slug: string;
|
|
210
|
+
publishedAtInput: string;
|
|
211
|
+
publishedAtTimeMinutes: number | null;
|
|
212
|
+
}
|
|
213
|
+
>;
|
|
214
|
+
}
|
|
215
|
+
|
|
199
216
|
const EDITOR_FLOATING_UI_SELECTOR = "[data-editor-floating-ui]";
|
|
200
217
|
|
|
201
218
|
/**
|
|
@@ -526,6 +543,7 @@ async function resolveApiAttachments(allAttachments: ApiAttachment[]) {
|
|
|
526
543
|
originalName: m.originalName,
|
|
527
544
|
summary: m.summary,
|
|
528
545
|
chars: m.chars,
|
|
546
|
+
persisted: true,
|
|
529
547
|
}));
|
|
530
548
|
|
|
531
549
|
const textAttachments = await Promise.all(
|
|
@@ -1474,15 +1492,29 @@ export class JantComposeDialog extends LitElement {
|
|
|
1474
1492
|
return this._seededFromSource ? this._hasUnsavedChanges() : true;
|
|
1475
1493
|
}
|
|
1476
1494
|
|
|
1495
|
+
/**
|
|
1496
|
+
* Whether leaving the composer, by closing it or going to Drafts, needs the
|
|
1497
|
+
* "Save to drafts?" prompt. A post being edited, or a draft opened from
|
|
1498
|
+
* Drafts, is already saved, so only what changed since it opened is at
|
|
1499
|
+
* stake: opening one to read it and closing it again asks nothing.
|
|
1500
|
+
*/
|
|
1501
|
+
private _hasWorkToLoseOnLeave(): boolean {
|
|
1502
|
+
if (this._editPostId || this._draftSourceId) {
|
|
1503
|
+
return this._hasUnsavedChanges();
|
|
1504
|
+
}
|
|
1505
|
+
return this._hasWorkToLose();
|
|
1506
|
+
}
|
|
1507
|
+
|
|
1477
1508
|
private _buildSnapshot(): ComposeStateSnapshot | null {
|
|
1478
1509
|
const editor = this._editor;
|
|
1479
1510
|
if (!editor) return null;
|
|
1480
1511
|
|
|
1481
|
-
const
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1512
|
+
const editors =
|
|
1513
|
+
this._threadItems.length > 0
|
|
1514
|
+
? Array.from(
|
|
1515
|
+
this.querySelectorAll<JantComposeEditor>("jant-compose-editor"),
|
|
1516
|
+
)
|
|
1517
|
+
: [];
|
|
1486
1518
|
|
|
1487
1519
|
return {
|
|
1488
1520
|
format: this._format,
|
|
@@ -1492,6 +1524,33 @@ export class JantComposeDialog extends LitElement {
|
|
|
1492
1524
|
publishedAtTimeMinutes: this._publishedAtTimeMinutes,
|
|
1493
1525
|
visibility: this._visibility,
|
|
1494
1526
|
language: this._language,
|
|
1527
|
+
...JantComposeDialog._snapshotEditor(editor),
|
|
1528
|
+
threadPosts: this._threadItems.flatMap((item, index) => {
|
|
1529
|
+
const itemEditor = editors[index];
|
|
1530
|
+
if (!itemEditor) return [];
|
|
1531
|
+
return [
|
|
1532
|
+
{
|
|
1533
|
+
format: item.format,
|
|
1534
|
+
slug: item.slug ?? "",
|
|
1535
|
+
publishedAtInput: item.publishedAtInput ?? "",
|
|
1536
|
+
publishedAtTimeMinutes: item.publishedAtTimeMinutes ?? null,
|
|
1537
|
+
...JantComposeDialog._snapshotEditor(itemEditor),
|
|
1538
|
+
},
|
|
1539
|
+
];
|
|
1540
|
+
}),
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
private static _snapshotEditor(
|
|
1545
|
+
editor: JantComposeEditor,
|
|
1546
|
+
): ComposeEditorSnapshot {
|
|
1547
|
+
const editorData = editor.getData();
|
|
1548
|
+
const attachedTexts = editor.getEffectiveAttachedTexts();
|
|
1549
|
+
// No `showTitle` here: a hidden title reads back as an empty one, so the
|
|
1550
|
+
// toggle is already visible in `title`.
|
|
1551
|
+
const showRating = editorData.rating > 0 ? editor._showRating : false;
|
|
1552
|
+
|
|
1553
|
+
return {
|
|
1495
1554
|
title: editorData.title,
|
|
1496
1555
|
bodyJson: editor.getNormalizedBodyJson(),
|
|
1497
1556
|
url: editorData.url,
|
|
@@ -1569,20 +1628,7 @@ export class JantComposeDialog extends LitElement {
|
|
|
1569
1628
|
return;
|
|
1570
1629
|
}
|
|
1571
1630
|
|
|
1572
|
-
|
|
1573
|
-
if (this._editPostId) {
|
|
1574
|
-
if (this._hasUnsavedChanges()) {
|
|
1575
|
-
this._confirmForDrafts = false;
|
|
1576
|
-
this._confirmForAttachedText = false;
|
|
1577
|
-
this._confirmPanelOpen = true;
|
|
1578
|
-
} else {
|
|
1579
|
-
this._closeDialog();
|
|
1580
|
-
this.reset();
|
|
1581
|
-
}
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
if (this._hasWorkToLose()) {
|
|
1631
|
+
if (this._hasWorkToLoseOnLeave()) {
|
|
1586
1632
|
this._confirmForDrafts = false;
|
|
1587
1633
|
this._confirmForAttachedText = false;
|
|
1588
1634
|
this._confirmPanelOpen = true;
|
|
@@ -1592,12 +1638,9 @@ export class JantComposeDialog extends LitElement {
|
|
|
1592
1638
|
}
|
|
1593
1639
|
}
|
|
1594
1640
|
|
|
1641
|
+
// "Don't save" drops this session's changes and nothing more. A draft opened
|
|
1642
|
+
// from Drafts stays as it was saved; deleting one is the Drafts list's job.
|
|
1595
1643
|
private _discardAndClose() {
|
|
1596
|
-
if (this._draftSourceId) {
|
|
1597
|
-
const id = this._draftSourceId;
|
|
1598
|
-
fetch(`/api/posts/${id}`, { method: "DELETE" }).catch(() => {});
|
|
1599
|
-
showToast(this.labels.draftDeleted);
|
|
1600
|
-
}
|
|
1601
1644
|
this._clearDraftFromStorage();
|
|
1602
1645
|
this._confirmPanelOpen = false;
|
|
1603
1646
|
this._confirmForAttachedText = false;
|
|
@@ -1639,11 +1682,6 @@ export class JantComposeDialog extends LitElement {
|
|
|
1639
1682
|
this._confirmPanelOpen = false;
|
|
1640
1683
|
this._discardAttachedPanel();
|
|
1641
1684
|
} else if (this._confirmForDrafts) {
|
|
1642
|
-
if (this._draftSourceId) {
|
|
1643
|
-
const id = this._draftSourceId;
|
|
1644
|
-
fetch(`/api/posts/${id}`, { method: "DELETE" }).catch(() => {});
|
|
1645
|
-
showToast(this.labels.draftDeleted);
|
|
1646
|
-
}
|
|
1647
1685
|
this._confirmPanelOpen = false;
|
|
1648
1686
|
this.reset();
|
|
1649
1687
|
this._openDraftsPanel();
|
|
@@ -1680,7 +1718,9 @@ export class JantComposeDialog extends LitElement {
|
|
|
1680
1718
|
type: "media",
|
|
1681
1719
|
clientId,
|
|
1682
1720
|
mediaId: media.mediaId,
|
|
1683
|
-
|
|
1721
|
+
// Sent even when empty: an omitted alt leaves the stored one as it
|
|
1722
|
+
// is, so dropping "" would keep alt text the author cleared.
|
|
1723
|
+
alt: media.alt,
|
|
1684
1724
|
});
|
|
1685
1725
|
continue;
|
|
1686
1726
|
}
|
|
@@ -2993,7 +3033,7 @@ export class JantComposeDialog extends LitElement {
|
|
|
2993
3033
|
|
|
2994
3034
|
private _handleDraftButtonClick() {
|
|
2995
3035
|
if (this._loading) return;
|
|
2996
|
-
if (this.
|
|
3036
|
+
if (this._hasWorkToLoseOnLeave()) {
|
|
2997
3037
|
this._confirmForDrafts = true;
|
|
2998
3038
|
this._confirmPanelOpen = true;
|
|
2999
3039
|
} else {
|
|
@@ -3513,6 +3553,8 @@ export class JantComposeDialog extends LitElement {
|
|
|
3513
3553
|
bodyJson: t.bodyJson,
|
|
3514
3554
|
bodyHtml: t.bodyHtml,
|
|
3515
3555
|
summary: t.summary,
|
|
3556
|
+
mediaId: t.mediaId,
|
|
3557
|
+
originalBodyJson: t.mediaId ? (t.originalBodyJson ?? null) : undefined,
|
|
3516
3558
|
})),
|
|
3517
3559
|
attachmentOrder: [...data.attachmentOrder],
|
|
3518
3560
|
mediaAttachments: JantComposeDialog._mediaSnapshotFromAttachments(
|
|
@@ -3596,6 +3638,7 @@ export class JantComposeDialog extends LitElement {
|
|
|
3596
3638
|
alt: a.alt || undefined,
|
|
3597
3639
|
summary: a.summary,
|
|
3598
3640
|
chars: a.chars,
|
|
3641
|
+
persisted: a.persisted || undefined,
|
|
3599
3642
|
},
|
|
3600
3643
|
]
|
|
3601
3644
|
: [],
|
|
@@ -3613,6 +3656,7 @@ export class JantComposeDialog extends LitElement {
|
|
|
3613
3656
|
alt: m.alt,
|
|
3614
3657
|
summary: m.summary ?? undefined,
|
|
3615
3658
|
chars: m.chars ?? undefined,
|
|
3659
|
+
persisted: m.persisted ?? false,
|
|
3616
3660
|
}));
|
|
3617
3661
|
}
|
|
3618
3662
|
|
|
@@ -3921,7 +3965,10 @@ export class JantComposeDialog extends LitElement {
|
|
|
3921
3965
|
// from the post rather than filling in for a missing one.
|
|
3922
3966
|
this._language = draft.language ?? null;
|
|
3923
3967
|
|
|
3924
|
-
// Restore editor content
|
|
3968
|
+
// Restore editor content. The draft's attachments replace the post's: an
|
|
3969
|
+
// edit sends the whole list, so what is restored here is what the post
|
|
3970
|
+
// keeps, and one the author removed before the edit was interrupted stays
|
|
3971
|
+
// removed.
|
|
3925
3972
|
const textAttachments = draft.attachedTexts?.flatMap((t) => {
|
|
3926
3973
|
const bodyJson = normalizeComposeDoc(t.bodyJson);
|
|
3927
3974
|
if (!bodyJson) return [];
|
|
@@ -3931,9 +3978,14 @@ export class JantComposeDialog extends LitElement {
|
|
|
3931
3978
|
bodyJson: JSON.stringify(bodyJson),
|
|
3932
3979
|
bodyHtml: t.bodyHtml,
|
|
3933
3980
|
summary: t.summary,
|
|
3981
|
+
mediaId: t.mediaId,
|
|
3982
|
+
originalBodyJson: t.mediaId
|
|
3983
|
+
? JSON.stringify(t.originalBodyJson ?? null)
|
|
3984
|
+
: undefined,
|
|
3934
3985
|
},
|
|
3935
3986
|
];
|
|
3936
3987
|
});
|
|
3988
|
+
const media = draft.mediaAttachments ?? [];
|
|
3937
3989
|
|
|
3938
3990
|
this._editor?.populate({
|
|
3939
3991
|
format: draft.format,
|
|
@@ -3945,6 +3997,9 @@ export class JantComposeDialog extends LitElement {
|
|
|
3945
3997
|
rating: draft.rating || undefined,
|
|
3946
3998
|
showTitle: draft.showTitle,
|
|
3947
3999
|
showRating: draft.showRating,
|
|
4000
|
+
media: media.length
|
|
4001
|
+
? JantComposeDialog._restoredMediaToPopulate(media)
|
|
4002
|
+
: undefined,
|
|
3948
4003
|
textAttachments: textAttachments?.length ? textAttachments : undefined,
|
|
3949
4004
|
attachmentOrder: draft.attachmentOrder,
|
|
3950
4005
|
});
|
|
@@ -1353,6 +1353,8 @@ export class JantComposeEditor extends LitElement {
|
|
|
1353
1353
|
originalName?: string;
|
|
1354
1354
|
summary?: string;
|
|
1355
1355
|
chars?: number;
|
|
1356
|
+
/** Already attached to the post being edited */
|
|
1357
|
+
persisted?: boolean;
|
|
1356
1358
|
}>;
|
|
1357
1359
|
textAttachments?: Array<{
|
|
1358
1360
|
clientId?: string;
|
|
@@ -1360,6 +1362,12 @@ export class JantComposeEditor extends LitElement {
|
|
|
1360
1362
|
bodyHtml?: string;
|
|
1361
1363
|
summary: string;
|
|
1362
1364
|
mediaId?: string;
|
|
1365
|
+
/**
|
|
1366
|
+
* The stored version of an existing text attachment, as JSON. Defaults
|
|
1367
|
+
* to `bodyJson`; a restored edit passes the version it started from, so
|
|
1368
|
+
* text changed before the interruption still counts as changed.
|
|
1369
|
+
*/
|
|
1370
|
+
originalBodyJson?: string;
|
|
1363
1371
|
}>;
|
|
1364
1372
|
attachmentOrder?: string[];
|
|
1365
1373
|
}) {
|
|
@@ -1401,6 +1409,7 @@ export class JantComposeEditor extends LitElement {
|
|
|
1401
1409
|
status: "done" as const,
|
|
1402
1410
|
progress: null,
|
|
1403
1411
|
mediaId: m.id,
|
|
1412
|
+
persisted: m.persisted ?? false,
|
|
1404
1413
|
remoteUrl: m.previewUrl,
|
|
1405
1414
|
alt: m.alt ?? "",
|
|
1406
1415
|
error: null,
|
|
@@ -1413,20 +1422,26 @@ export class JantComposeEditor extends LitElement {
|
|
|
1413
1422
|
|
|
1414
1423
|
// Restore attached texts from server data
|
|
1415
1424
|
if (data.textAttachments?.length) {
|
|
1416
|
-
const
|
|
1417
|
-
let parsed: JSONContent | null = null;
|
|
1425
|
+
const parseDoc = (json: string): JSONContent | null => {
|
|
1418
1426
|
try {
|
|
1419
|
-
|
|
1427
|
+
return JSON.parse(json) as JSONContent | null;
|
|
1420
1428
|
} catch {
|
|
1421
1429
|
// Invalid JSON — leave as null
|
|
1430
|
+
return null;
|
|
1422
1431
|
}
|
|
1432
|
+
};
|
|
1433
|
+
const texts: AttachedTextItem[] = data.textAttachments.map((t) => {
|
|
1434
|
+
const parsed = parseDoc(t.bodyJson);
|
|
1423
1435
|
return {
|
|
1424
1436
|
clientId: t.clientId ?? randomUUID(),
|
|
1425
1437
|
bodyJson: parsed,
|
|
1426
1438
|
bodyHtml: t.bodyHtml ?? "",
|
|
1427
1439
|
summary: t.summary,
|
|
1428
1440
|
mediaId: t.mediaId,
|
|
1429
|
-
originalBodyJson:
|
|
1441
|
+
originalBodyJson:
|
|
1442
|
+
t.originalBodyJson === undefined
|
|
1443
|
+
? parsed
|
|
1444
|
+
: parseDoc(t.originalBodyJson),
|
|
1430
1445
|
};
|
|
1431
1446
|
});
|
|
1432
1447
|
this._attachedTexts = texts;
|
|
@@ -1915,6 +1930,7 @@ export class JantComposeEditor extends LitElement {
|
|
|
1915
1930
|
status: "pending",
|
|
1916
1931
|
progress: null,
|
|
1917
1932
|
mediaId: null,
|
|
1933
|
+
persisted: false,
|
|
1918
1934
|
remoteUrl: null,
|
|
1919
1935
|
alt: "",
|
|
1920
1936
|
error: null,
|
|
@@ -1971,6 +1987,7 @@ export class JantComposeEditor extends LitElement {
|
|
|
1971
1987
|
detail: {
|
|
1972
1988
|
clientId: attachment.clientId,
|
|
1973
1989
|
mediaId: attachment.mediaId,
|
|
1990
|
+
persisted: attachment.persisted,
|
|
1974
1991
|
},
|
|
1975
1992
|
}),
|
|
1976
1993
|
);
|
|
@@ -397,14 +397,12 @@ export class JantConfigEditor extends LitElement {
|
|
|
397
397
|
);
|
|
398
398
|
}
|
|
399
399
|
|
|
400
|
+
// An editable setting comes back with its fallback in `settings`; a
|
|
401
|
+
// linked one (a theme, say) isn't listed there, and resets to the
|
|
402
|
+
// fallback this row already shows.
|
|
400
403
|
const body = await readJsonObject(response);
|
|
401
|
-
const resetSetting = isJsonObject(body.setting)
|
|
402
|
-
? body.setting
|
|
403
|
-
: undefined;
|
|
404
404
|
const resetValue =
|
|
405
|
-
getJsonString(
|
|
406
|
-
getJsonString(body.settings, item.key) ??
|
|
407
|
-
item.fallbackValue;
|
|
405
|
+
getJsonString(body.settings, item.key) ?? item.fallbackValue;
|
|
408
406
|
this._commitValue(item.key, resetValue, false);
|
|
409
407
|
this._setStatus(item.key, { state: "saved" });
|
|
410
408
|
} catch (error) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Media Lightbox
|
|
3
3
|
*
|
|
4
4
|
* Fullscreen overlay carousel for post media galleries.
|
|
5
|
-
* Intercepts clicks on [data-
|
|
5
|
+
* Intercepts clicks on [data-lightbox-group] a[data-lightbox-index] via
|
|
6
6
|
* delegated listener, reads image data from [data-lightbox-group],
|
|
7
7
|
* and displays images in a native <dialog>.
|
|
8
8
|
*
|
|
@@ -227,10 +227,10 @@ export class JantMediaLightbox extends LitElement {
|
|
|
227
227
|
#handleDocumentClick = (e: Event) => {
|
|
228
228
|
const target = e.target as HTMLElement;
|
|
229
229
|
|
|
230
|
-
//
|
|
231
|
-
//
|
|
230
|
+
// A gallery item: an anchor with data-lightbox-index inside the group
|
|
231
|
+
// that lists the images to page through.
|
|
232
232
|
const anchor = target.closest<HTMLAnchorElement>(
|
|
233
|
-
"[data-
|
|
233
|
+
"[data-lightbox-group] a[data-lightbox-index]",
|
|
234
234
|
);
|
|
235
235
|
if (anchor) {
|
|
236
236
|
const group = anchor.closest<HTMLElement>("[data-lightbox-group]");
|
|
@@ -532,10 +532,6 @@ export class JantSettingsGeneral extends LitElement {
|
|
|
532
532
|
* On writes `latest`: the directory may read any public post, and decides
|
|
533
533
|
* itself which list each one reaches — featured posts on its home, links
|
|
534
534
|
* and quotes on their own lists.
|
|
535
|
-
*
|
|
536
|
-
* A site that stored `featured` under an older release still reads as
|
|
537
|
-
* ticked, and stays `featured` until its owner touches the box: widening
|
|
538
|
-
* what the directory may show is the owner's to do, not an upgrade's.
|
|
539
535
|
*/
|
|
540
536
|
private _onDiscoverToggle(enabled: boolean) {
|
|
541
537
|
this._saveDiscover(enabled ? "latest" : "off");
|
|
@@ -8,16 +8,17 @@ import type { CollectionFormLabels } from "./collection-types.js";
|
|
|
8
8
|
export interface NavManagerItem {
|
|
9
9
|
id: string;
|
|
10
10
|
type: "link" | "system" | "collection" | "smart_collection" | "page";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/** API responses carry `null` where a field doesn't apply to the type. */
|
|
12
|
+
systemKey?: SystemNavKey | null;
|
|
13
|
+
collectionId?: string | null;
|
|
14
|
+
smartCollectionId?: string | null;
|
|
15
|
+
postId?: string | null;
|
|
15
16
|
/** Author's override, or `""` when the item follows its target's title */
|
|
16
17
|
label: string;
|
|
17
18
|
/** Resolved label from the server-rendered list */
|
|
18
19
|
displayLabel?: string;
|
|
19
20
|
/** Target's current title, present on mutation responses */
|
|
20
|
-
targetTitle?: string;
|
|
21
|
+
targetTitle?: string | null;
|
|
21
22
|
url: string;
|
|
22
23
|
placement?: "header" | "more";
|
|
23
24
|
}
|
|
@@ -531,12 +531,20 @@ async function uploadFile(
|
|
|
531
531
|
// ── Attachment removal handler ───────────────────────────────────────
|
|
532
532
|
|
|
533
533
|
document.addEventListener("jant:attachment-removed", (e: Event) => {
|
|
534
|
-
const { clientId, mediaId } = (
|
|
535
|
-
e as CustomEvent<{
|
|
534
|
+
const { clientId, mediaId, persisted } = (
|
|
535
|
+
e as CustomEvent<{
|
|
536
|
+
clientId: string;
|
|
537
|
+
mediaId: string | null;
|
|
538
|
+
persisted: boolean;
|
|
539
|
+
}>
|
|
536
540
|
).detail;
|
|
537
541
|
|
|
538
542
|
completedUploads.delete(clientId);
|
|
539
543
|
|
|
544
|
+
// Part of the post being edited: saving the edit deletes it, and
|
|
545
|
+
// discarding the edit has to keep it.
|
|
546
|
+
if (persisted) return;
|
|
547
|
+
|
|
540
548
|
if (mediaId) {
|
|
541
549
|
// Upload already finished — fire-and-forget delete
|
|
542
550
|
fetch(publicPath(`/api/media/${mediaId}`), { method: "DELETE" }).catch(
|
|
@@ -635,7 +643,10 @@ function buildPostBody(
|
|
|
635
643
|
// Thread as a side effect. Collection management stays on Thread-level
|
|
636
644
|
// organization surfaces; JSON.stringify omits this undefined field.
|
|
637
645
|
collectionIds: detail.replyToId ? undefined : detail.collectionIds,
|
|
638
|
-
|
|
646
|
+
// An edit sends the whole list, empty included: the server removes what
|
|
647
|
+
// the list leaves out, which is how an attachment the post already had
|
|
648
|
+
// comes off it. Omitted, it would leave them all as they were.
|
|
649
|
+
attachments: isEdit || attachments.length > 0 ? attachments : undefined,
|
|
639
650
|
replyToId: detail.replyToId || undefined,
|
|
640
651
|
quietReply: detail.quietReply || undefined,
|
|
641
652
|
// Absent means the author left the language to detection; the server runs
|
|
@@ -807,7 +818,7 @@ document.addEventListener("jant:compose-submit-deferred", async (e: Event) => {
|
|
|
807
818
|
mediaId: upload.id,
|
|
808
819
|
url: upload.url,
|
|
809
820
|
mimeType: upload.mimeType,
|
|
810
|
-
name: upload.
|
|
821
|
+
name: upload.originalName || undefined,
|
|
811
822
|
alt: attachment.alt || undefined,
|
|
812
823
|
});
|
|
813
824
|
}
|
|
@@ -79,7 +79,7 @@ export function readComposeDialogLabels(): JantComposeDialog["labels"] | null {
|
|
|
79
79
|
export function getActiveCollectionId(): string | undefined {
|
|
80
80
|
return (
|
|
81
81
|
document.querySelector<HTMLElement>(
|
|
82
|
-
"[data-
|
|
82
|
+
"[data-collection-mode][data-collection-id]",
|
|
83
83
|
)?.dataset.collectionId || undefined
|
|
84
84
|
);
|
|
85
85
|
}
|
|
@@ -89,7 +89,7 @@ export function getCurrentDetailPostArticle(
|
|
|
89
89
|
): HTMLElement | null {
|
|
90
90
|
if (root === document) {
|
|
91
91
|
const hoveredPost = document.querySelector<HTMLElement>(
|
|
92
|
-
"
|
|
92
|
+
".thread-group-detail article[data-post]:hover",
|
|
93
93
|
);
|
|
94
94
|
if (hoveredPost) return hoveredPost;
|
|
95
95
|
}
|
|
@@ -114,9 +114,7 @@ export function getCurrentDetailPostArticle(
|
|
|
114
114
|
function getLastThreadDetailArticle(
|
|
115
115
|
root: globalThis.Document | globalThis.Element,
|
|
116
116
|
): HTMLElement | null {
|
|
117
|
-
const threadGroup = root.querySelector<HTMLElement>(
|
|
118
|
-
".thread-group-detail[data-page='post']",
|
|
119
|
-
);
|
|
117
|
+
const threadGroup = root.querySelector<HTMLElement>(".thread-group-detail");
|
|
120
118
|
if (!threadGroup) return null;
|
|
121
119
|
|
|
122
120
|
const articles = threadGroup.querySelectorAll<HTMLElement>(
|
|
@@ -133,7 +131,7 @@ export function getReplyTargetArticle(
|
|
|
133
131
|
|
|
134
132
|
if (root === document) {
|
|
135
133
|
const hoveredPost = document.querySelector<HTMLElement>(
|
|
136
|
-
"
|
|
134
|
+
".thread-group-detail article[data-post]:hover",
|
|
137
135
|
);
|
|
138
136
|
if (hoveredPost) return hoveredPost;
|
|
139
137
|
}
|
|
@@ -35,7 +35,7 @@ function shouldIgnoreShortcut(event: globalThis.KeyboardEvent): boolean {
|
|
|
35
35
|
if (event.defaultPrevented || event.isComposing || event.repeat) return true;
|
|
36
36
|
if (event.metaKey || event.ctrlKey || event.altKey) return true;
|
|
37
37
|
if (!getComposeDialog()) return true;
|
|
38
|
-
if (document.querySelector(
|
|
38
|
+
if (document.querySelector(".compose-page")) return true;
|
|
39
39
|
if (document.querySelector("dialog[open]")) return true;
|
|
40
40
|
|
|
41
41
|
const activeTarget = document.activeElement;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
const FOOTNOTE_BODY_SELECTOR = [
|
|
12
|
-
|
|
12
|
+
"[data-post-view] .post-detail [data-post-body].post-detail-body",
|
|
13
13
|
"[data-timeline-item] article[data-post] > [data-post-body].prose",
|
|
14
14
|
].join(", ");
|
|
15
15
|
const FOOTNOTE_CONTAINER_SELECTOR = "[data-post-view], [data-timeline-item]";
|
|
@@ -43,7 +43,7 @@ const PAGE_ENTRIES: ReadonlyArray<{
|
|
|
43
43
|
selector: string;
|
|
44
44
|
load: () => Promise<void>;
|
|
45
45
|
}> = [
|
|
46
|
-
{ selector:
|
|
46
|
+
{ selector: ".compose-page", load: ensureCompose },
|
|
47
47
|
{
|
|
48
48
|
selector: [
|
|
49
49
|
"jant-settings-general",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Media gallery horizontal scroll affordances.
|
|
3
3
|
*
|
|
4
|
-
* The gallery strip (`[data-
|
|
4
|
+
* The gallery strip (`[data-media-gallery]` inside `.media-gallery-scroll-wrap`)
|
|
5
5
|
* is trackpad- and touch-friendly, but its scrollbar is hidden, so a plain
|
|
6
6
|
* mouse or the keyboard has no obvious way to scroll it. This module:
|
|
7
7
|
*
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
const THRESHOLD = 4; // px tolerance for "at edge"
|
|
16
16
|
|
|
17
17
|
function getScroller(wrap: HTMLElement): HTMLElement | null {
|
|
18
|
-
return wrap.querySelector("[data-
|
|
18
|
+
return wrap.querySelector("[data-media-gallery]");
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
function updateHints(wrap: HTMLElement): void {
|
|
@@ -150,6 +150,61 @@ describe("isCodeEditorHtml", () => {
|
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
describe("MarkdownClipboard", () => {
|
|
153
|
+
it("pastes a planted HTML block as an html code block", () => {
|
|
154
|
+
const element = document.createElement("div");
|
|
155
|
+
document.body.appendChild(element);
|
|
156
|
+
const editor = createTiptapEditor({ element });
|
|
157
|
+
editors.push(editor);
|
|
158
|
+
|
|
159
|
+
dispatchMarkdownPaste(
|
|
160
|
+
editor,
|
|
161
|
+
"Article text",
|
|
162
|
+
'<p>Article text</p><div data-jant-node="html-block"><script src="https://evil.example/x.js"></script></div>',
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const types = editor.getJSON().content?.map((node) => node.type);
|
|
166
|
+
expect(types).not.toContain("htmlBlock");
|
|
167
|
+
expect(types).toContain("codeBlock");
|
|
168
|
+
expect(JSON.stringify(editor.getJSON())).toContain("evil.example/x.js");
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("pastes a jant-html fence from a Markdown flavor as code, not an HTML block", () => {
|
|
172
|
+
const element = document.createElement("div");
|
|
173
|
+
document.body.appendChild(element);
|
|
174
|
+
const editor = createTiptapEditor({ element });
|
|
175
|
+
editors.push(editor);
|
|
176
|
+
|
|
177
|
+
dispatchMarkdownPaste(
|
|
178
|
+
editor,
|
|
179
|
+
"Plain fallback",
|
|
180
|
+
"",
|
|
181
|
+
'Intro\n\n```jant-html\n<script src="https://evil.example/x.js"></script>\n```\n',
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
const types = editor.getJSON().content?.map((node) => node.type);
|
|
185
|
+
expect(types).not.toContain("htmlBlock");
|
|
186
|
+
expect(types).toContain("codeBlock");
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
it("keeps only a pasted embed's URL", () => {
|
|
190
|
+
const element = document.createElement("div");
|
|
191
|
+
document.body.appendChild(element);
|
|
192
|
+
const editor = createTiptapEditor({ element });
|
|
193
|
+
editors.push(editor);
|
|
194
|
+
|
|
195
|
+
dispatchMarkdownPaste(
|
|
196
|
+
editor,
|
|
197
|
+
"",
|
|
198
|
+
'<figure data-jant-node="embed" data-url="https://www.youtube.com/watch?v=abc" data-provider="youtube" data-src="https://evil.example/frame"></figure>',
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const embed = editor
|
|
202
|
+
.getJSON()
|
|
203
|
+
.content?.find((node) => node.type === "embed");
|
|
204
|
+
expect(embed?.attrs?.url).toBe("https://www.youtube.com/watch?v=abc");
|
|
205
|
+
expect(embed?.attrs?.src).toBe("");
|
|
206
|
+
});
|
|
207
|
+
|
|
153
208
|
it("keeps pasted plain text that opens with a word and a period", () => {
|
|
154
209
|
const element = document.createElement("div");
|
|
155
210
|
document.body.appendChild(element);
|
|
@@ -629,6 +629,52 @@ function normalizePastedSlice(slice: Slice, plain: boolean): Slice {
|
|
|
629
629
|
: slice;
|
|
630
630
|
}
|
|
631
631
|
|
|
632
|
+
/**
|
|
633
|
+
* Pasted or dropped content must not bring in anything that publishes raw.
|
|
634
|
+
*
|
|
635
|
+
* An HTML block renders its HTML as it is, and an embed's stored `src` frames
|
|
636
|
+
* any page. A page the author copies from can plant either: a
|
|
637
|
+
* `data-jant-node` element in its HTML, or raw HTML in a Markdown flavor its
|
|
638
|
+
* copy handler sets. So a pasted HTML block arrives as an `html` code block,
|
|
639
|
+
* its source intact, and a pasted embed keeps only its URL, which the
|
|
640
|
+
* renderer resolves against the providers it knows. Adding an HTML block on
|
|
641
|
+
* purpose goes through the editor's own command.
|
|
642
|
+
*/
|
|
643
|
+
function neutralizePastedNode(node: ProseMirrorNode): ProseMirrorNode {
|
|
644
|
+
const { schema } = node.type;
|
|
645
|
+
|
|
646
|
+
if (node.type.name === "htmlBlock") {
|
|
647
|
+
const html = String(node.attrs.html ?? "");
|
|
648
|
+
const text = html ? [schema.text(html)] : [];
|
|
649
|
+
const codeBlock = schema.nodes.codeBlock;
|
|
650
|
+
return codeBlock
|
|
651
|
+
? codeBlock.create({ language: "html" }, text)
|
|
652
|
+
: schema.node("paragraph", null, text);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
if (node.type.name === "embed") {
|
|
656
|
+
return node.type.create({
|
|
657
|
+
url: node.attrs.url,
|
|
658
|
+
provider: node.attrs.provider,
|
|
659
|
+
providerName: node.attrs.providerName,
|
|
660
|
+
orientation: node.attrs.orientation,
|
|
661
|
+
caption: node.attrs.caption,
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
if (node.isLeaf || node.childCount === 0) return node;
|
|
666
|
+
|
|
667
|
+
const children: ProseMirrorNode[] = [];
|
|
668
|
+
node.forEach((child) => children.push(neutralizePastedNode(child)));
|
|
669
|
+
return node.copy(Fragment.fromArray(children));
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function neutralizePastedSlice(slice: Slice): Slice {
|
|
673
|
+
const nodes: ProseMirrorNode[] = [];
|
|
674
|
+
slice.content.forEach((node) => nodes.push(neutralizePastedNode(node)));
|
|
675
|
+
return new Slice(Fragment.fromArray(nodes), slice.openStart, slice.openEnd);
|
|
676
|
+
}
|
|
677
|
+
|
|
632
678
|
export const MarkdownClipboard = Extension.create({
|
|
633
679
|
name: "markdownClipboard",
|
|
634
680
|
|
|
@@ -644,7 +690,7 @@ export const MarkdownClipboard = Extension.create({
|
|
|
644
690
|
|
|
645
691
|
transformPastedHTML: normalizePastedHtml,
|
|
646
692
|
transformPasted: (slice, _view, plain) =>
|
|
647
|
-
normalizePastedSlice(slice, plain),
|
|
693
|
+
neutralizePastedSlice(normalizePastedSlice(slice, plain)),
|
|
648
694
|
|
|
649
695
|
/**
|
|
650
696
|
* Prefer an explicit Markdown flavor. Marked Obsidian and detected
|
|
@@ -668,7 +714,9 @@ export const MarkdownClipboard = Extension.create({
|
|
|
668
714
|
const content = createNodeFromContent(parsed, view.state.schema, {
|
|
669
715
|
slice: false,
|
|
670
716
|
});
|
|
671
|
-
const slice =
|
|
717
|
+
const slice = neutralizePastedSlice(
|
|
718
|
+
Slice.maxOpen(toFragment(content)),
|
|
719
|
+
);
|
|
672
720
|
|
|
673
721
|
event.preventDefault();
|
|
674
722
|
view.dispatch(
|