@jant/core 0.6.14 → 0.6.15
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/import-site.js +81 -13
- package/bin/commands/migrate.js +55 -0
- package/bin/commands/posts/rebuild-html.js +184 -0
- package/bin/commands/site/snapshot/import.js +14 -10
- package/bin/lib/d1-query.js +23 -5
- package/bin/lib/migration-runner.js +29 -7
- package/bin/lib/node-database.js +32 -0
- package/bin/lib/site-snapshot.js +347 -46
- package/bin/lib/sql-export.js +1 -1
- package/bin/lib/thread-collection-migration.js +326 -0
- package/dist/app-BxCOR3Uc.js +6 -0
- package/dist/{app-2i7-WQHg.js → app-C-oi_t8W.js} +7408 -6343
- package/dist/client/.vite/manifest.json +3 -3
- package/dist/client/_assets/client-B_eGKN5p.css +2 -0
- package/dist/client/_assets/{client-BvID5ucz.js → client-DxY5BFe8.js} +58 -37
- package/dist/client/_assets/client-auth-CakPESv9.js +5533 -0
- package/dist/{export-DWn149b7.js → export-CsFx6F_M.js} +1259 -125
- package/dist/{github-sync-Ckk0sJxK.js → github-sync-Cq1pzzOI.js} +1 -1
- package/dist/{github-sync-C0zyF6XS.js → github-sync-ppWXN3jb.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/node.js +5 -5
- package/package.json +11 -10
- package/src/__tests__/bin/posts-rebuild-html.test.ts +137 -0
- package/src/__tests__/dev-navigation-defaults.test.ts +22 -0
- package/src/__tests__/export-hugo-build.test.ts +63 -4
- package/src/__tests__/export-import-roundtrip.test.ts +6 -4
- package/src/__tests__/export-service.test.ts +142 -9
- package/src/__tests__/helpers/app.ts +3 -0
- package/src/__tests__/helpers/export-fixtures.ts +2 -0
- package/src/__tests__/import-site-command.test.ts +65 -0
- package/src/__tests__/vite-config.test.ts +45 -0
- package/src/app.tsx +16 -3
- package/src/client/__tests__/collection-created-notice.test.ts +36 -0
- package/src/client/__tests__/collection-form-bridge.test.ts +10 -1
- package/src/client/__tests__/collection-page-actions.test.ts +71 -2
- package/src/client/__tests__/compose-bridge.test.ts +64 -0
- package/src/client/__tests__/feed-video-player.test.ts +16 -1
- package/src/client/__tests__/footnote-rail.test.ts +472 -0
- package/src/client/__tests__/hydrate-partial.test.ts +3 -0
- package/src/client/__tests__/toast.test.ts +18 -1
- package/src/client/collection-created-notice.ts +66 -0
- package/src/client/collection-form-bridge.ts +17 -0
- package/src/client/collection-navigation.ts +44 -0
- package/src/client/collection-page-actions.ts +57 -1
- package/src/client/components/__tests__/jant-collection-directory.test.ts +155 -6
- package/src/client/components/__tests__/jant-compose-dialog.test.ts +370 -5
- package/src/client/components/__tests__/jant-compose-editor.test.ts +97 -0
- package/src/client/components/__tests__/jant-compose-fullscreen.test.ts +104 -0
- package/src/client/components/__tests__/jant-config-editor.test.ts +405 -0
- package/src/client/components/__tests__/jant-media-lightbox.test.ts +121 -0
- package/src/client/components/__tests__/jant-nav-manager.test.ts +538 -2
- package/src/client/components/__tests__/jant-post-form.test.ts +2 -2
- package/src/client/components/__tests__/jant-post-menu.test.ts +47 -5
- package/src/client/components/__tests__/jant-settings-avatar.test.ts +2 -2
- package/src/client/components/__tests__/jant-settings-general.test.ts +3 -3
- package/src/client/components/collection-manager-types.ts +9 -3
- package/src/client/components/compose-types.ts +8 -0
- package/src/client/components/jant-collection-directory.ts +165 -30
- package/src/client/components/jant-command-palette.ts +2 -1
- package/src/client/components/jant-compose-dialog.ts +85 -21
- package/src/client/components/jant-compose-editor.ts +13 -7
- package/src/client/components/jant-compose-fullscreen.ts +24 -4
- package/src/client/components/jant-config-editor.ts +722 -0
- package/src/client/components/jant-media-lightbox.ts +100 -18
- package/src/client/components/jant-nav-manager.ts +1283 -54
- package/src/client/components/jant-post-form.ts +3 -3
- package/src/client/components/jant-post-menu.ts +86 -74
- package/src/client/components/nav-manager-types.ts +51 -2
- package/src/client/components/post-form-types.ts +1 -1
- package/src/client/compose-bridge.ts +4 -1
- package/src/client/feed-video-player.ts +62 -2
- package/src/client/footnote-rail.ts +478 -0
- package/src/client/hydrate-partial.ts +2 -0
- package/src/client/media-lightbox-events.ts +63 -0
- package/src/client/site-header-fragment.ts +38 -0
- package/src/client/tiptap/__tests__/blockquote-editing.test.ts +201 -0
- package/src/client/tiptap/__tests__/clear-formatting.test.ts +168 -0
- package/src/client/tiptap/__tests__/list-editing.test.ts +447 -0
- package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +727 -4
- package/src/client/tiptap/__tests__/table-controls.test.ts +263 -0
- package/src/client/tiptap/__tests__/table-size-picker.test.ts +179 -0
- package/src/client/tiptap/bubble-menu.ts +88 -10
- package/src/client/tiptap/continuous-lists.ts +102 -0
- package/src/client/tiptap/create-editor.ts +3 -0
- package/src/client/tiptap/extensions.ts +14 -5
- package/src/client/tiptap/markdown-clipboard.ts +608 -11
- package/src/client/tiptap/slash-commands.ts +8 -1
- package/src/client/tiptap/structural-keymap.ts +211 -0
- package/src/client/tiptap/tab-indent.ts +8 -22
- package/src/client/tiptap/table-control-labels.ts +30 -0
- package/src/client/tiptap/table-controls.ts +537 -0
- package/src/client/tiptap/table-size-picker.ts +254 -0
- package/src/client/toast.ts +8 -6
- package/src/client-auth.ts +1 -0
- package/src/client.ts +1 -0
- package/src/db/__tests__/d1-query.test.ts +43 -1
- package/src/db/__tests__/migration-runner.test.ts +63 -0
- package/src/db/__tests__/migrations.test.ts +469 -0
- package/src/db/__tests__/thread-collection-migration.test.ts +364 -0
- package/src/db/migrations/0027_old_blue_blade.sql +39 -0
- package/src/db/migrations/0028_superb_post.sql +2 -0
- package/src/db/migrations/0029_boring_magma.sql +1 -0
- package/src/db/migrations/0030_typical_vivisector.sql +50 -0
- package/src/db/migrations/meta/0027_snapshot.json +2511 -0
- package/src/db/migrations/meta/0028_snapshot.json +2511 -0
- package/src/db/migrations/meta/0029_snapshot.json +2519 -0
- package/src/db/migrations/meta/0030_snapshot.json +2541 -0
- package/src/db/migrations/meta/_journal.json +28 -0
- package/src/db/migrations/pg/0025_moaning_epoch.sql +39 -0
- package/src/db/migrations/pg/0026_talented_killer_shrike.sql +2 -0
- package/src/db/migrations/pg/0027_short_cannonball.sql +1 -0
- package/src/db/migrations/pg/0028_perfect_sharon_carter.sql +27 -0
- package/src/db/migrations/pg/meta/0025_snapshot.json +3204 -0
- package/src/db/migrations/pg/meta/0026_snapshot.json +3204 -0
- package/src/db/migrations/pg/meta/0027_snapshot.json +3211 -0
- package/src/db/migrations/pg/meta/0028_snapshot.json +3248 -0
- package/src/db/migrations/pg/meta/_journal.json +28 -0
- package/src/db/pg/schema.ts +28 -20
- package/src/db/rehearsal-fixtures/demo-current.json +39 -4
- package/src/db/rehearsal-fixtures/demo-current.sql +121 -6
- package/src/db/schema.ts +28 -20
- package/src/i18n/__tests__/detect.test.ts +8 -2
- package/src/i18n/detect.ts +14 -5
- package/src/i18n/locales/public/en.po +133 -30
- package/src/i18n/locales/public/en.ts +1 -1
- package/src/i18n/locales/public/zh-Hans.po +128 -25
- package/src/i18n/locales/public/zh-Hans.ts +1 -1
- package/src/i18n/locales/public/zh-Hant.po +128 -25
- package/src/i18n/locales/public/zh-Hant.ts +1 -1
- package/src/i18n/locales/settings/en.po +513 -10
- package/src/i18n/locales/settings/en.ts +1 -1
- package/src/i18n/locales/settings/zh-Hans.po +515 -12
- package/src/i18n/locales/settings/zh-Hans.ts +1 -1
- package/src/i18n/locales/settings/zh-Hant.po +515 -12
- package/src/i18n/locales/settings/zh-Hant.ts +1 -1
- package/src/lib/__tests__/api-settings.test.ts +299 -0
- package/src/lib/__tests__/constants.test.ts +5 -0
- package/src/lib/__tests__/feed-policy.test.ts +25 -0
- package/src/lib/__tests__/footnotes-upgrade.test.ts +181 -0
- package/src/lib/__tests__/markdown-roundtrip-embed.test.ts +61 -0
- package/src/lib/__tests__/markdown-to-tiptap.test.ts +32 -4
- package/src/lib/__tests__/markdown.test.ts +8 -6
- package/src/lib/__tests__/navigation.test.ts +59 -2
- package/src/lib/__tests__/post-body-html.test.ts +176 -0
- package/src/lib/__tests__/post-display.test.ts +64 -0
- package/src/lib/__tests__/resolve-config.test.ts +113 -1
- package/src/lib/__tests__/summary.test.ts +82 -0
- package/src/lib/__tests__/timeline.test.ts +109 -70
- package/src/lib/__tests__/timezones.test.ts +31 -3
- package/src/lib/__tests__/tiptap-render.test.ts +268 -9
- package/src/lib/__tests__/tiptap-to-markdown.test.ts +6 -0
- package/src/lib/__tests__/view.test.ts +53 -0
- package/src/lib/__tests__/worker-response-cache.test.ts +18 -1
- package/src/lib/api-settings.ts +239 -12
- package/src/lib/collection-sort.ts +7 -5
- package/src/lib/constants.ts +2 -0
- package/src/lib/feed-path.ts +25 -0
- package/src/lib/feed-policy.ts +64 -0
- package/src/lib/footnotes.ts +264 -0
- package/src/lib/github-sync-site-config.ts +2 -0
- package/src/lib/hugo-markdown.ts +10 -3
- package/src/lib/jant-branding.ts +1 -0
- package/src/lib/markdown-manager.ts +188 -5
- package/src/lib/markdown.ts +10 -3
- package/src/lib/navigation.ts +16 -3
- package/src/lib/post-body-html.ts +131 -0
- package/src/lib/post-display.ts +7 -1
- package/src/lib/render.tsx +9 -2
- package/src/lib/resolve-config.ts +100 -16
- package/src/lib/schemas.ts +133 -1
- package/src/lib/settings-paths.ts +5 -0
- package/src/lib/site-skill.ts +78 -0
- package/src/lib/summary.ts +16 -5
- package/src/lib/timeline.ts +98 -122
- package/src/lib/timezones.ts +54 -14
- package/src/lib/tiptap-render.ts +355 -81
- package/src/lib/view.ts +30 -20
- package/src/lib/worker-response-cache.ts +11 -18
- package/src/middleware/__tests__/public-content-access.test.ts +91 -0
- package/src/middleware/config.ts +2 -2
- package/src/middleware/public-content-access.ts +87 -0
- package/src/node/__tests__/cli-export.test.ts +14 -0
- package/src/node/__tests__/cli-migrate.test.ts +6 -0
- package/src/node/__tests__/cli-site-snapshot.test.ts +205 -2
- package/src/node/__tests__/cli-snapshot-meta.test.ts +100 -0
- package/src/node/index.ts +2 -1
- package/src/preset.css +16 -2
- package/src/routes/__tests__/compose.test.ts +51 -0
- package/src/routes/__tests__/site-skill.test.ts +112 -0
- package/src/routes/api/__tests__/collections.test.ts +91 -19
- package/src/routes/api/__tests__/mcp.test.ts +65 -1
- package/src/routes/api/__tests__/nav-items.test.ts +91 -0
- package/src/routes/api/__tests__/public-access.test.ts +81 -0
- package/src/routes/api/__tests__/settings.test.ts +217 -0
- package/src/routes/api/collections.ts +22 -26
- package/src/routes/api/export.ts +2 -0
- package/src/routes/api/internal/__tests__/post-body-html.test.ts +163 -0
- package/src/routes/api/internal/__tests__/sites.test.ts +35 -2
- package/src/routes/api/internal/post-body-html.ts +43 -0
- package/src/routes/api/internal/sites.ts +24 -0
- package/src/routes/api/nav-items.ts +24 -1
- package/src/routes/api/posts.ts +2 -2
- package/src/routes/api/public/__tests__/archive.test.ts +35 -0
- package/src/routes/api/public/__tests__/posts.test.ts +208 -0
- package/src/routes/api/public/archive.ts +4 -0
- package/src/routes/api/public/posts.ts +41 -24
- package/src/routes/api/search.ts +3 -0
- package/src/routes/api/settings.ts +33 -0
- package/src/routes/auth/__tests__/setup.test.ts +7 -4
- package/src/routes/compose.tsx +2 -1
- package/src/routes/dash/settings.tsx +45 -2
- package/src/routes/feed/__tests__/feed.test.ts +210 -6
- package/src/routes/feed/feed.ts +23 -14
- package/src/routes/pages/__tests__/archive-params.test.ts +92 -3
- package/src/routes/pages/__tests__/collection-routing.test.ts +63 -5
- package/src/routes/pages/__tests__/collections.test.ts +9 -9
- package/src/routes/pages/__tests__/preview.test.ts +174 -0
- package/src/routes/pages/__tests__/search.test.ts +69 -0
- package/src/routes/pages/archive.tsx +27 -7
- package/src/routes/pages/collection.tsx +32 -19
- package/src/routes/pages/collections.tsx +6 -1
- package/src/routes/pages/page.tsx +83 -11
- package/src/routes/site-skill.ts +18 -0
- package/src/services/__tests__/auth.test.ts +7 -5
- package/src/services/__tests__/collection.test.ts +159 -44
- package/src/services/__tests__/navigation.test.ts +229 -21
- package/src/services/__tests__/post-timeline.test.ts +109 -30
- package/src/services/__tests__/post.test.ts +567 -5
- package/src/services/__tests__/search.test.ts +48 -1
- package/src/services/__tests__/settings.test.ts +8 -0
- package/src/services/__tests__/site-admin.test.ts +121 -1
- package/src/services/auth.ts +2 -2
- package/src/services/bootstrap.ts +3 -2
- package/src/services/collection.ts +226 -167
- package/src/services/export-theme/assets/client-site.css +1 -1
- package/src/services/export-theme/assets/client-site.js +46 -25
- package/src/services/export-theme/layouts/_default/list.html +18 -4
- package/src/services/export-theme/layouts/_default/rss.xml +8 -12
- package/src/services/export-theme/layouts/featured/list.html +5 -4
- package/src/services/export-theme/layouts/partials/featured-thread.html +56 -0
- package/src/services/export-theme/layouts/partials/footer.html +1 -1
- package/src/services/export-theme/layouts/partials/media-gallery.html +1 -0
- package/src/services/export-theme/styles/main.css +30 -2
- package/src/services/export.ts +91 -80
- package/src/services/mcp.ts +37 -27
- package/src/services/media.ts +1 -1
- package/src/services/navigation.ts +185 -46
- package/src/services/post.ts +874 -271
- package/src/services/search.ts +8 -2
- package/src/services/settings.ts +2 -10
- package/src/services/site-admin.ts +63 -43
- package/src/style-cjk-jp.css +1 -1
- package/src/style-cjk-kr.css +1 -1
- package/src/style-cjk-tc.css +1 -1
- package/src/style-cjk.css +1 -1
- package/src/styles/components.css +540 -0
- package/src/styles/site-media.css +111 -19
- package/src/styles/tokens.css +14 -9
- package/src/styles/ui.css +829 -29
- package/src/types/bindings.ts +3 -0
- package/src/types/config.ts +243 -12
- package/src/types/constants.ts +22 -1
- package/src/types/entities.ts +9 -8
- package/src/types/operations.ts +18 -10
- package/src/types/props.ts +8 -2
- package/src/types/raw-assets.d.ts +5 -0
- package/src/types/views.ts +16 -4
- package/src/ui/__tests__/font-themes.test.ts +42 -30
- package/src/ui/compose/ComposeDialog.tsx +92 -2
- package/src/ui/dash/appearance/NavigationContent.tsx +332 -4
- package/src/ui/dash/appearance/__tests__/NavigationContent.test.tsx +23 -0
- package/src/ui/dash/settings/ConfigEditorContent.tsx +578 -0
- package/src/ui/dash/settings/GeneralContent.tsx +15 -5
- package/src/ui/dash/settings/SettingsRootContent.tsx +21 -1
- package/src/ui/dash/settings/__tests__/ConfigEditorContent.test.tsx +98 -0
- package/src/ui/dash/settings/__tests__/SettingsRootContent.test.tsx +15 -0
- package/src/ui/feed/CuratedThreadPreview.tsx +16 -4
- package/src/ui/feed/LinkCard.tsx +2 -12
- package/src/ui/feed/NoteCard.tsx +10 -20
- package/src/ui/feed/QuoteCard.tsx +2 -12
- package/src/ui/feed/ThreadPreview.tsx +26 -34
- package/src/ui/feed/TimelineFeed.tsx +2 -2
- package/src/ui/feed/__tests__/thread-preview.test.ts +197 -56
- package/src/ui/feed/__tests__/timeline-cards.test.ts +178 -3
- package/src/ui/feed/thread-preview-state.ts +5 -7
- package/src/ui/font-themes.ts +74 -26
- package/src/ui/layouts/BaseLayout.tsx +22 -8
- package/src/ui/layouts/__tests__/BaseLayout.test.tsx +64 -1
- package/src/ui/pages/CollectionPage.tsx +101 -22
- package/src/ui/pages/CollectionsPage.tsx +3 -1
- package/src/ui/pages/PostPage.tsx +39 -12
- package/src/ui/pages/SearchPage.tsx +6 -14
- package/src/ui/pages/__tests__/ArchivePage.test.tsx +7 -0
- package/src/ui/pages/__tests__/PostPage.test.tsx +88 -0
- package/src/ui/shared/CollectionDirectory.tsx +13 -9
- package/src/ui/shared/CollectionsManager.tsx +17 -7
- package/src/ui/shared/DraftPreviewBar.tsx +33 -0
- package/src/ui/shared/HomePageBranding.tsx +2 -2
- package/src/ui/shared/MediaGallery.tsx +1 -0
- package/src/ui/shared/PostFooter.tsx +3 -1
- package/src/ui/shared/__tests__/home-page-branding.test.tsx +1 -1
- package/src/ui/shared/__tests__/media-gallery.test.ts +1 -0
- package/src/ui/shared/__tests__/navigation-labels.test.ts +2 -2
- package/src/ui/shared/__tests__/post-footer.test.ts +15 -0
- package/src/ui/shared/collection-management-labels.ts +33 -2
- package/src/ui/shared/navigation-labels.ts +2 -4
- package/src/ui/shared/post-article-attributes.ts +46 -0
- package/dist/app-DZDlmh7C.js +0 -6
- package/dist/client/_assets/client-Cevfpm8H.css +0 -2
- package/dist/client/_assets/client-auth-v3yvhbgZ.js +0 -4736
- package/src/client/tiptap/wrapping-input-rules.ts +0 -102
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
renderTiptapDocument,
|
|
4
|
+
renderTiptapDocumentAroundBoundary,
|
|
4
5
|
renderTiptapJson,
|
|
6
|
+
tryRenderTiptapJson,
|
|
5
7
|
trimTiptapBody,
|
|
6
8
|
} from "../tiptap-render.js";
|
|
7
9
|
|
|
@@ -68,7 +70,7 @@ describe("renderTiptapDocument", () => {
|
|
|
68
70
|
);
|
|
69
71
|
});
|
|
70
72
|
|
|
71
|
-
it("renders
|
|
73
|
+
it("renders canonical semantic endnotes without layout wrappers", () => {
|
|
72
74
|
const html = renderTiptapDocument(
|
|
73
75
|
doc(
|
|
74
76
|
p(text("Body copy"), {
|
|
@@ -81,16 +83,21 @@ describe("renderTiptapDocument", () => {
|
|
|
81
83
|
content: [p(text("Footnote body"))],
|
|
82
84
|
},
|
|
83
85
|
),
|
|
86
|
+
{ namespace: "pst_test" },
|
|
84
87
|
);
|
|
85
88
|
|
|
86
89
|
expect(html).toBe(
|
|
87
|
-
'<p>Body copy<
|
|
88
|
-
'<
|
|
89
|
-
'<
|
|
90
|
+
'<p>Body copy<sup class="footnote-ref">' +
|
|
91
|
+
'<a id="fnref-0sk9zhgh1dhm5-1-1" href="#fn-0sk9zhgh1dhm5-1" role="doc-noteref">1</a></sup></p>' +
|
|
92
|
+
'<section class="footnote-endnotes" role="doc-endnotes"><ol class="footnote-list">' +
|
|
93
|
+
'<li id="fn-0sk9zhgh1dhm5-1" class="footnote"><p>Footnote body <span class="footnote-backlinks">' +
|
|
94
|
+
'<a href="#fnref-0sk9zhgh1dhm5-1-1" class="footnote-backref" role="doc-backlink">↩︎</a>' +
|
|
95
|
+
"</span></p></li></ol></section>",
|
|
90
96
|
);
|
|
97
|
+
expect(html).not.toMatch(/<div|\sstyle=|\sdata-footnote-/);
|
|
91
98
|
});
|
|
92
99
|
|
|
93
|
-
it("renders footnote
|
|
100
|
+
it("renders a missing footnote definition without a dead link", () => {
|
|
94
101
|
const html = renderTiptapDocument(
|
|
95
102
|
doc(
|
|
96
103
|
p(text("Body copy"), {
|
|
@@ -100,11 +107,255 @@ describe("renderTiptapDocument", () => {
|
|
|
100
107
|
),
|
|
101
108
|
);
|
|
102
109
|
|
|
103
|
-
expect(html).toBe(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
110
|
+
expect(html).toBe('<p>Body copy<sup class="footnote-ref">1</sup></p>');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("uses a native list start when a missing definition creates a leading numbering gap", () => {
|
|
114
|
+
const html = renderTiptapDocument(
|
|
115
|
+
doc(
|
|
116
|
+
p(text("Missing"), {
|
|
117
|
+
type: "footnoteReference",
|
|
118
|
+
attrs: { label: "missing" },
|
|
119
|
+
}),
|
|
120
|
+
p(text("Defined"), {
|
|
121
|
+
type: "footnoteReference",
|
|
122
|
+
attrs: { label: "defined" },
|
|
123
|
+
}),
|
|
124
|
+
{
|
|
125
|
+
type: "footnoteDefinition",
|
|
126
|
+
attrs: { label: "defined" },
|
|
127
|
+
content: [p(text("Second definition"))],
|
|
128
|
+
},
|
|
129
|
+
),
|
|
107
130
|
);
|
|
131
|
+
|
|
132
|
+
expect(html).toContain('<sup class="footnote-ref">1</sup>');
|
|
133
|
+
expect(html).toContain('href="#fn-2" role="doc-noteref">2</a>');
|
|
134
|
+
expect(html).toContain('<ol class="footnote-list" start="2">');
|
|
135
|
+
expect(html).toContain('<li id="fn-2" class="footnote">');
|
|
136
|
+
expect(html).not.toContain('value="2"');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it("uses a native list-item value only for an internal numbering gap", () => {
|
|
140
|
+
const html = renderTiptapDocument(
|
|
141
|
+
doc(
|
|
142
|
+
p({ type: "footnoteReference", attrs: { label: "one" } }),
|
|
143
|
+
p({ type: "footnoteReference", attrs: { label: "missing" } }),
|
|
144
|
+
p({ type: "footnoteReference", attrs: { label: "three" } }),
|
|
145
|
+
{
|
|
146
|
+
type: "footnoteDefinition",
|
|
147
|
+
attrs: { label: "one" },
|
|
148
|
+
content: [p(text("First definition"))],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
type: "footnoteDefinition",
|
|
152
|
+
attrs: { label: "three" },
|
|
153
|
+
content: [p(text("Third definition"))],
|
|
154
|
+
},
|
|
155
|
+
),
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
expect(html).toContain('<ol class="footnote-list">');
|
|
159
|
+
expect(html).toContain('<li id="fn-1" class="footnote">');
|
|
160
|
+
expect(html).toContain('<li id="fn-3" class="footnote" value="3">');
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("renders repeated references once with unique reciprocal backlinks", () => {
|
|
164
|
+
const html = renderTiptapDocument(
|
|
165
|
+
doc(
|
|
166
|
+
p(text("First"), {
|
|
167
|
+
type: "footnoteReference",
|
|
168
|
+
attrs: { label: "Note" },
|
|
169
|
+
}),
|
|
170
|
+
p(text("Second"), {
|
|
171
|
+
type: "footnoteReference",
|
|
172
|
+
attrs: { label: "note" },
|
|
173
|
+
}),
|
|
174
|
+
{
|
|
175
|
+
type: "footnoteDefinition",
|
|
176
|
+
attrs: { label: "NOTE" },
|
|
177
|
+
content: [p(text("Shared definition"))],
|
|
178
|
+
},
|
|
179
|
+
),
|
|
180
|
+
{ namespace: "pst_repeat" },
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
expect(html.match(/role="doc-endnotes"/g)).toHaveLength(1);
|
|
184
|
+
expect(html.match(/<ol class="footnote-list">/g)).toHaveLength(1);
|
|
185
|
+
expect(html.match(/<li id="fn-/g)).toHaveLength(1);
|
|
186
|
+
expect(html).toContain('id="fnref-0r3u815ai35bm-1-1"');
|
|
187
|
+
expect(html).toContain('id="fnref-0r3u815ai35bm-1-2"');
|
|
188
|
+
expect(html.match(/href="#fn-0r3u815ai35bm-1"/g)).toHaveLength(2);
|
|
189
|
+
expect(html).toContain(
|
|
190
|
+
'href="#fnref-0r3u815ai35bm-1-1" class="footnote-backref" role="doc-backlink">↩︎1</a>',
|
|
191
|
+
);
|
|
192
|
+
expect(html).toContain(
|
|
193
|
+
'href="#fnref-0r3u815ai35bm-1-2" class="footnote-backref" role="doc-backlink">↩︎2</a>',
|
|
194
|
+
);
|
|
195
|
+
expect(html.indexOf("Shared definition")).toBeGreaterThan(
|
|
196
|
+
html.indexOf("Second"),
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
it("keeps all definitions in one native ordered list", () => {
|
|
201
|
+
const html = renderTiptapDocument(
|
|
202
|
+
doc(
|
|
203
|
+
p(text("First"), {
|
|
204
|
+
type: "footnoteReference",
|
|
205
|
+
attrs: { label: "first" },
|
|
206
|
+
}),
|
|
207
|
+
p(text("Second"), {
|
|
208
|
+
type: "footnoteReference",
|
|
209
|
+
attrs: { label: "second" },
|
|
210
|
+
}),
|
|
211
|
+
{
|
|
212
|
+
type: "footnoteDefinition",
|
|
213
|
+
attrs: { label: "first" },
|
|
214
|
+
content: [p(text("First definition"))],
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
type: "footnoteDefinition",
|
|
218
|
+
attrs: { label: "second" },
|
|
219
|
+
content: [p(text("Second definition"))],
|
|
220
|
+
},
|
|
221
|
+
),
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
expect(html.match(/<ol class="footnote-list">/g)).toHaveLength(1);
|
|
225
|
+
expect(html).toContain('<li id="fn-1" class="footnote">');
|
|
226
|
+
expect(html).toContain('<li id="fn-2" class="footnote">');
|
|
227
|
+
expect(html).not.toMatch(/\s(?:start|value|style)=/);
|
|
228
|
+
expect(html.indexOf("First definition")).toBeGreaterThan(
|
|
229
|
+
html.indexOf("Second"),
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("keeps rich footnote blocks inside a native endnote list item", () => {
|
|
234
|
+
const html = renderTiptapDocument(
|
|
235
|
+
doc(
|
|
236
|
+
p(text("Body"), {
|
|
237
|
+
type: "footnoteReference",
|
|
238
|
+
attrs: { label: "rich" },
|
|
239
|
+
}),
|
|
240
|
+
{
|
|
241
|
+
type: "footnoteDefinition",
|
|
242
|
+
attrs: { label: "rich" },
|
|
243
|
+
content: [
|
|
244
|
+
p(text("First paragraph")),
|
|
245
|
+
{
|
|
246
|
+
type: "bulletList",
|
|
247
|
+
content: [
|
|
248
|
+
{
|
|
249
|
+
type: "listItem",
|
|
250
|
+
content: [p(text("List item"))],
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
},
|
|
256
|
+
),
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
expect(html).toContain(
|
|
260
|
+
'<section class="footnote-endnotes" role="doc-endnotes"><ol class="footnote-list"',
|
|
261
|
+
);
|
|
262
|
+
expect(html).toContain('<li id="fn-1" class="footnote">');
|
|
263
|
+
expect(html).toContain(
|
|
264
|
+
'<p>First paragraph</p><ul><li><p>List item</p></li></ul><p class="footnote-backlinks"><a href="#fnref-1-1" class="footnote-backref" role="doc-backlink">↩︎</a></p>',
|
|
265
|
+
);
|
|
266
|
+
expect(html).not.toContain('<div class="footnote-body"');
|
|
267
|
+
expect(html).not.toContain('role="doc-footnote"');
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it("appends backlinks to the authored final paragraph of rich definitions", () => {
|
|
271
|
+
const html = renderTiptapDocument(
|
|
272
|
+
doc(p({ type: "footnoteReference", attrs: { label: "rich" } }), {
|
|
273
|
+
type: "footnoteDefinition",
|
|
274
|
+
attrs: { label: "rich" },
|
|
275
|
+
content: [
|
|
276
|
+
{
|
|
277
|
+
type: "bulletList",
|
|
278
|
+
content: [
|
|
279
|
+
{
|
|
280
|
+
type: "listItem",
|
|
281
|
+
content: [p(text("List item"))],
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
p(text("Final paragraph")),
|
|
286
|
+
],
|
|
287
|
+
}),
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
expect(html).toContain(
|
|
291
|
+
'<ul><li><p>List item</p></li></ul><p>Final paragraph <span class="footnote-backlinks">',
|
|
292
|
+
);
|
|
293
|
+
expect(html).not.toContain('<p class="footnote-backlinks">');
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
it("uses the render namespace to isolate documents sharing a page", () => {
|
|
297
|
+
const input = doc(p({ type: "footnoteReference", attrs: { label: "1" } }), {
|
|
298
|
+
type: "footnoteDefinition",
|
|
299
|
+
attrs: { label: "1" },
|
|
300
|
+
content: [p(text("Definition"))],
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const first = renderTiptapDocument(input, { namespace: "pst_first" });
|
|
304
|
+
const second = renderTiptapDocument(input, { namespace: "pst_second" });
|
|
305
|
+
|
|
306
|
+
expect(first).toContain('id="fn-3t66v0e9xc2qx-1"');
|
|
307
|
+
expect(second).toContain('id="fn-2b338ib1g2med-1"');
|
|
308
|
+
expect(first).not.toContain("2b338ib1g2med");
|
|
309
|
+
expect(second).not.toContain("3t66v0e9xc2qx");
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("keeps immutable entity namespaces compact in public fragment IDs", () => {
|
|
313
|
+
const input = doc(p({ type: "footnoteReference", attrs: { label: "1" } }), {
|
|
314
|
+
type: "footnoteDefinition",
|
|
315
|
+
attrs: { label: "1" },
|
|
316
|
+
content: [p(text("Definition"))],
|
|
317
|
+
});
|
|
318
|
+
const namespace = "pst_01kxwe4tkwfqfsrwcgqgeg1b7k";
|
|
319
|
+
const html = renderTiptapDocument(input, { namespace });
|
|
320
|
+
const referenceId = html.match(/<a id="([^"]+)"/)?.[1];
|
|
321
|
+
const definitionId = html.match(/<li id="([^"]+)"/)?.[1];
|
|
322
|
+
|
|
323
|
+
expect(referenceId).toBe("fnref-0nj7nw33xdf9h-1-1");
|
|
324
|
+
expect(definitionId).toBe("fn-0nj7nw33xdf9h-1");
|
|
325
|
+
expect(referenceId?.length).toBeLessThan(30);
|
|
326
|
+
expect(html).not.toContain(namespace);
|
|
327
|
+
expect(html).toContain(`href="#${definitionId}"`);
|
|
328
|
+
expect(html).toContain(`href="#${referenceId}"`);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it("splits at a source boundary using the full repeated-footnote plan", () => {
|
|
332
|
+
const input = doc(
|
|
333
|
+
p(text("First"), {
|
|
334
|
+
type: "footnoteReference",
|
|
335
|
+
attrs: { label: "shared" },
|
|
336
|
+
}),
|
|
337
|
+
p(text("Second"), {
|
|
338
|
+
type: "footnoteReference",
|
|
339
|
+
attrs: { label: "shared" },
|
|
340
|
+
}),
|
|
341
|
+
{
|
|
342
|
+
type: "footnoteDefinition",
|
|
343
|
+
attrs: { label: "shared" },
|
|
344
|
+
content: [p(text("Definition"))],
|
|
345
|
+
},
|
|
346
|
+
);
|
|
347
|
+
const options = { namespace: "pst_split" };
|
|
348
|
+
const full = renderTiptapDocument(input, options);
|
|
349
|
+
const split = renderTiptapDocumentAroundBoundary(input, 1, options);
|
|
350
|
+
|
|
351
|
+
expect(split).not.toBeNull();
|
|
352
|
+
expect(split!.beforeHtml + split!.afterHtml).toBe(full);
|
|
353
|
+
expect(split!.beforeHtml).toContain("fnref-2q7yplng9am9n-1-1");
|
|
354
|
+
expect(split!.beforeHtml).not.toContain("footnote-document");
|
|
355
|
+
expect(split!.beforeHtml).not.toContain('role="doc-endnotes"');
|
|
356
|
+
expect(split!.afterHtml).toContain('id="fnref-2q7yplng9am9n-1-2"');
|
|
357
|
+
expect(split!.afterHtml).toContain('role="doc-endnotes"');
|
|
358
|
+
expect(split!.afterHtml.endsWith("</section>")).toBe(true);
|
|
108
359
|
});
|
|
109
360
|
|
|
110
361
|
it("renders code blocks as escaped text, not nested inline markup", () => {
|
|
@@ -141,6 +392,14 @@ describe("renderTiptapJson", () => {
|
|
|
141
392
|
it("returns an empty string for non-doc JSON", () => {
|
|
142
393
|
expect(renderTiptapDocument({ type: "paragraph" })).toBe("");
|
|
143
394
|
});
|
|
395
|
+
|
|
396
|
+
it("distinguishes invalid JSON from a valid empty document", () => {
|
|
397
|
+
expect(tryRenderTiptapJson("not json")).toMatchObject({ ok: false });
|
|
398
|
+
expect(tryRenderTiptapJson(JSON.stringify(doc()))).toEqual({
|
|
399
|
+
ok: true,
|
|
400
|
+
html: "",
|
|
401
|
+
});
|
|
402
|
+
});
|
|
144
403
|
});
|
|
145
404
|
|
|
146
405
|
describe("trimTiptapBody", () => {
|
|
@@ -402,6 +402,12 @@ describe("tiptapJsonToMarkdown", () => {
|
|
|
402
402
|
const md = "Body copy[^1]\n\n[^1]: Footnote body";
|
|
403
403
|
expect(roundtrip(md)).toBe(md);
|
|
404
404
|
});
|
|
405
|
+
|
|
406
|
+
it("canonicalizes inline footnotes as references plus definitions", () => {
|
|
407
|
+
expect(roundtrip("Body^[Inline **bold** note.]")).toBe(
|
|
408
|
+
"Body[^1]\n\n[^1]: Inline **bold** note.",
|
|
409
|
+
);
|
|
410
|
+
});
|
|
405
411
|
});
|
|
406
412
|
|
|
407
413
|
describe("edge cases", () => {
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
SearchResult,
|
|
21
21
|
Post,
|
|
22
22
|
} from "../../types.js";
|
|
23
|
+
import { renderTiptapJson } from "../tiptap-render.js";
|
|
23
24
|
const EMPTY_CTX: MediaContext = {};
|
|
24
25
|
const CTX_WITH_URLS: MediaContext = {
|
|
25
26
|
r2PublicUrl: "https://cdn.example.com",
|
|
@@ -271,6 +272,58 @@ describe("toPostView", () => {
|
|
|
271
272
|
);
|
|
272
273
|
});
|
|
273
274
|
|
|
275
|
+
it("places the summary boundary after a footnote repeated in the hidden tail", () => {
|
|
276
|
+
const firstText = "A".repeat(300);
|
|
277
|
+
const secondText = "B".repeat(300);
|
|
278
|
+
const body = JSON.stringify({
|
|
279
|
+
type: "doc",
|
|
280
|
+
content: [
|
|
281
|
+
{
|
|
282
|
+
type: "paragraph",
|
|
283
|
+
content: [
|
|
284
|
+
{ type: "text", text: firstText },
|
|
285
|
+
{ type: "footnoteReference", attrs: { label: "shared" } },
|
|
286
|
+
],
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
type: "paragraph",
|
|
290
|
+
content: [
|
|
291
|
+
{ type: "text", text: secondText },
|
|
292
|
+
{ type: "footnoteReference", attrs: { label: "shared" } },
|
|
293
|
+
],
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: "footnoteDefinition",
|
|
297
|
+
attrs: { label: "shared" },
|
|
298
|
+
content: [
|
|
299
|
+
{
|
|
300
|
+
type: "paragraph",
|
|
301
|
+
content: [{ type: "text", text: "Shared definition" }],
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
},
|
|
305
|
+
],
|
|
306
|
+
});
|
|
307
|
+
const bodyHtml = renderTiptapJson(body, { namespace: UUID_1 });
|
|
308
|
+
const view = toPostView(
|
|
309
|
+
makePostWithMedia({ title: "Article", body, bodyHtml }),
|
|
310
|
+
EMPTY_CTX,
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
expect(view.summaryHasMore).toBe(true);
|
|
314
|
+
const markerIndex = view.bodyHtml?.indexOf('<span id="continue"></span>');
|
|
315
|
+
expect(markerIndex).toBeGreaterThan(
|
|
316
|
+
view.bodyHtml?.indexOf(firstText) ?? -1,
|
|
317
|
+
);
|
|
318
|
+
expect(markerIndex).toBeLessThan(view.bodyHtml?.indexOf(secondText) ?? -1);
|
|
319
|
+
expect(view.bodyHtml).toContain('href="#fnref-1jp3895hp1ag7-1-2"');
|
|
320
|
+
expect(view.bodyHtml).not.toContain("footnote-document");
|
|
321
|
+
expect(view.bodyHtml?.match(/<ol class="footnote-list">/g)).toHaveLength(1);
|
|
322
|
+
expect(view.bodyHtml?.indexOf("Shared definition")).toBeGreaterThan(
|
|
323
|
+
view.bodyHtml?.indexOf(secondText) ?? -1,
|
|
324
|
+
);
|
|
325
|
+
});
|
|
326
|
+
|
|
274
327
|
it("does not attach summaryHtml for short untitled notes", () => {
|
|
275
328
|
const body = JSON.stringify({
|
|
276
329
|
type: "doc",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import type { Bindings } from "../../types.js";
|
|
3
|
-
import {
|
|
3
|
+
import { POST_BODY_HTML_VERSION } from "../post-body-html.js";
|
|
4
|
+
import {
|
|
5
|
+
normalizeWorkerCacheKeyUrl,
|
|
6
|
+
withWorkerResponseCache,
|
|
7
|
+
} from "../worker-response-cache.js";
|
|
4
8
|
|
|
5
9
|
interface StoredResponse {
|
|
6
10
|
body: Uint8Array;
|
|
@@ -59,6 +63,19 @@ function createCloudflareBindings(overrides: Partial<Bindings> = {}): Bindings {
|
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
describe("withWorkerResponseCache", () => {
|
|
66
|
+
it("versions cache keys with the current body HTML contract", () => {
|
|
67
|
+
const url = new URL(
|
|
68
|
+
normalizeWorkerCacheKeyUrl(
|
|
69
|
+
"https://example.com/feed?__jant_body_html=old&utm_source=test",
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
expect(url.searchParams.get("__jant_body_html")).toBe(
|
|
74
|
+
String(POST_BODY_HTML_VERSION),
|
|
75
|
+
);
|
|
76
|
+
expect(url.searchParams.has("utm_source")).toBe(false);
|
|
77
|
+
});
|
|
78
|
+
|
|
62
79
|
it("caches anonymous phase-one feed responses and normalizes tracking params", async () => {
|
|
63
80
|
const cache = createMemoryCache();
|
|
64
81
|
const bindings = createCloudflareBindings();
|