nebula-cms 0.1.3 → 0.1.5
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/README.md +3 -1
- package/dist/astro/index.d.ts +43 -0
- package/dist/astro/index.d.ts.map +1 -0
- package/dist/astro/index.js +223 -0
- package/{src → dist}/client/Admin.svelte +20 -11
- package/dist/client/Admin.svelte.d.ts +11 -0
- package/dist/client/Admin.svelte.d.ts.map +1 -0
- package/dist/client/components/BackendPicker.svelte.d.ts +4 -0
- package/dist/client/components/BackendPicker.svelte.d.ts.map +1 -0
- package/dist/client/components/DraftChip.svelte.d.ts +10 -0
- package/dist/client/components/DraftChip.svelte.d.ts.map +1 -0
- package/dist/client/components/MetadataForm.svelte.d.ts +12 -0
- package/dist/client/components/MetadataForm.svelte.d.ts.map +1 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts +19 -0
- package/dist/client/components/ThemeToggle.svelte.d.ts.map +1 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts +11 -0
- package/dist/client/components/dialogs/DeleteDraftDialog.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/dialogs/FilenameDialog.svelte +1 -2
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts +13 -0
- package/dist/client/components/dialogs/FilenameDialog.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorPane.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts +8 -0
- package/dist/client/components/editor/EditorTabs.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts +4 -0
- package/dist/client/components/editor/EditorToolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts +4 -0
- package/dist/client/components/editor/FormatSelector.svelte.d.ts.map +1 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts +19 -0
- package/dist/client/components/editor/Toolbar.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts +15 -0
- package/dist/client/components/fields/ArrayField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts +28 -0
- package/dist/client/components/fields/ArrayItem.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts +16 -0
- package/dist/client/components/fields/BooleanField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/DateField.svelte.d.ts +16 -0
- package/dist/client/components/fields/DateField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts +17 -0
- package/dist/client/components/fields/EnumField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts +18 -0
- package/dist/client/components/fields/FieldWrapper.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts +16 -0
- package/dist/client/components/fields/NumberField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts +16 -0
- package/dist/client/components/fields/ObjectField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts +16 -0
- package/dist/client/components/fields/SchemaField.svelte.d.ts.map +1 -0
- package/dist/client/components/fields/StringField.svelte.d.ts +16 -0
- package/dist/client/components/fields/StringField.svelte.d.ts.map +1 -0
- package/{src → dist}/client/components/sidebar/AdminSidebar.svelte +2 -4
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts +19 -0
- package/dist/client/components/sidebar/AdminSidebar.svelte.d.ts.map +1 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts +12 -0
- package/dist/client/components/sidebar/AdminSidebarSort.svelte.d.ts.map +1 -0
- package/dist/client/css/icons.css +29 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.d.ts +24 -0
- package/dist/client/js/drafts/merge.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/merge.svelte.js +106 -0
- package/dist/client/js/drafts/ops.svelte.d.ts +31 -0
- package/dist/client/js/drafts/ops.svelte.d.ts.map +1 -0
- package/dist/client/js/drafts/ops.svelte.js +182 -0
- package/dist/client/js/drafts/storage.d.ts +45 -0
- package/dist/client/js/drafts/storage.d.ts.map +1 -0
- package/dist/client/js/drafts/storage.js +76 -0
- package/dist/client/js/drafts/workers/diff.d.ts +2 -0
- package/dist/client/js/drafts/workers/diff.d.ts.map +1 -0
- package/dist/client/js/drafts/workers/diff.js +20 -0
- package/dist/client/js/editor/editor.svelte.d.ts +124 -0
- package/dist/client/js/editor/editor.svelte.d.ts.map +1 -0
- package/dist/client/js/editor/editor.svelte.js +294 -0
- package/dist/client/js/editor/languages.d.ts +11 -0
- package/dist/client/js/editor/languages.d.ts.map +1 -0
- package/dist/client/js/editor/languages.js +93 -0
- package/dist/client/js/editor/link-wrap.d.ts +6 -0
- package/dist/client/js/editor/link-wrap.d.ts.map +1 -0
- package/{src/client/js/editor/link-wrap.ts → dist/client/js/editor/link-wrap.js} +17 -24
- package/dist/client/js/editor/markdown-shortcuts.d.ts +4 -0
- package/dist/client/js/editor/markdown-shortcuts.d.ts.map +1 -0
- package/dist/client/js/editor/markdown-shortcuts.js +219 -0
- package/dist/client/js/handlers/admin.d.ts +64 -0
- package/dist/client/js/handlers/admin.d.ts.map +1 -0
- package/dist/client/js/handlers/admin.js +186 -0
- package/dist/client/js/state/dialogs.svelte.d.ts +16 -0
- package/dist/client/js/state/dialogs.svelte.d.ts.map +1 -0
- package/dist/client/js/state/dialogs.svelte.js +28 -0
- package/dist/client/js/state/router.svelte.d.ts +44 -0
- package/dist/client/js/state/router.svelte.d.ts.map +1 -0
- package/dist/client/js/state/router.svelte.js +141 -0
- package/dist/client/js/state/schema.svelte.d.ts +51 -0
- package/dist/client/js/state/schema.svelte.d.ts.map +1 -0
- package/{src/client/js/state/schema.svelte.ts → dist/client/js/state/schema.svelte.js} +55 -70
- package/dist/client/js/state/state.svelte.d.ts +68 -0
- package/dist/client/js/state/state.svelte.d.ts.map +1 -0
- package/dist/client/js/state/state.svelte.js +300 -0
- package/dist/client/js/state/theme.svelte.d.ts +24 -0
- package/dist/client/js/state/theme.svelte.d.ts.map +1 -0
- package/{src/client/js/state/theme.svelte.ts → dist/client/js/state/theme.svelte.js} +54 -91
- package/dist/client/js/storage/adapter.d.ts +130 -0
- package/dist/client/js/storage/adapter.d.ts.map +1 -0
- package/dist/client/js/storage/adapter.js +5 -0
- package/dist/client/js/storage/client.d.ts +72 -0
- package/dist/client/js/storage/client.d.ts.map +1 -0
- package/dist/client/js/storage/client.js +121 -0
- package/dist/client/js/storage/db.d.ts +8 -0
- package/dist/client/js/storage/db.d.ts.map +1 -0
- package/dist/client/js/storage/db.js +35 -0
- package/dist/client/js/storage/fsa.d.ts +51 -0
- package/dist/client/js/storage/fsa.d.ts.map +1 -0
- package/dist/client/js/storage/fsa.js +91 -0
- package/dist/client/js/storage/github.d.ts +62 -0
- package/dist/client/js/storage/github.d.ts.map +1 -0
- package/dist/client/js/storage/github.js +216 -0
- package/dist/client/js/storage/storage.d.ts +32 -0
- package/dist/client/js/storage/storage.d.ts.map +1 -0
- package/dist/client/js/storage/storage.js +68 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts +2 -0
- package/dist/client/js/storage/workers/frontmatter.d.ts.map +1 -0
- package/dist/client/js/storage/workers/frontmatter.js +253 -0
- package/dist/client/js/storage/workers/storage.d.ts +2 -0
- package/dist/client/js/storage/workers/storage.d.ts.map +1 -0
- package/dist/client/js/storage/workers/storage.js +167 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/toml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/toml-parser.js +75 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts +2 -0
- package/dist/client/js/storage/workers/yaml-parser.d.ts.map +1 -0
- package/dist/client/js/storage/workers/yaml-parser.js +100 -0
- package/dist/client/js/utils/file-types.d.ts +58 -0
- package/dist/client/js/utils/file-types.d.ts.map +1 -0
- package/{src/client/js/utils/file-types.ts → dist/client/js/utils/file-types.js} +75 -107
- package/dist/client/js/utils/format.d.ts +8 -0
- package/dist/client/js/utils/format.d.ts.map +1 -0
- package/{src/client/js/utils/format.ts → dist/client/js/utils/format.js} +5 -6
- package/dist/client/js/utils/frontmatter.d.ts +12 -0
- package/dist/client/js/utils/frontmatter.d.ts.map +1 -0
- package/dist/client/js/utils/frontmatter.js +29 -0
- package/dist/client/js/utils/schema-utils.d.ts +110 -0
- package/dist/client/js/utils/schema-utils.d.ts.map +1 -0
- package/dist/client/js/utils/schema-utils.js +242 -0
- package/dist/client/js/utils/slug.d.ts +8 -0
- package/dist/client/js/utils/slug.d.ts.map +1 -0
- package/{src/client/js/utils/slug.ts → dist/client/js/utils/slug.js} +6 -7
- package/dist/client/js/utils/sort.d.ts +41 -0
- package/dist/client/js/utils/sort.d.ts.map +1 -0
- package/dist/client/js/utils/sort.js +65 -0
- package/dist/client/js/utils/stable-stringify.d.ts +8 -0
- package/dist/client/js/utils/stable-stringify.d.ts.map +1 -0
- package/dist/client/js/utils/stable-stringify.js +23 -0
- package/dist/client/js/utils/url-utils.d.ts +11 -0
- package/dist/client/js/utils/url-utils.d.ts.map +1 -0
- package/{src/client/js/utils/url-utils.ts → dist/client/js/utils/url-utils.js} +22 -23
- package/dist/client/types/browser-apis.d.ts +39 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +13 -3
- package/.github/workflows/ci.yml +0 -27
- package/.github/workflows/publish.yml +0 -34
- package/.mcp.json +0 -12
- package/.prettierignore +0 -5
- package/.prettierrc.cjs +0 -22
- package/AGENTS.md +0 -183
- package/playground/astro.config.mjs +0 -7
- package/playground/node_modules/.bin/astro +0 -21
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js +0 -85
- package/playground/node_modules/.vite/deps/@astrojs_svelte_client__js.js.map +0 -7
- package/playground/node_modules/.vite/deps/_metadata.json +0 -184
- package/playground/node_modules/.vite/deps/astro___aria-query.js +0 -6776
- package/playground/node_modules/.vite/deps/astro___aria-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___axobject-query.js +0 -3754
- package/playground/node_modules/.vite/deps/astro___axobject-query.js.map +0 -7
- package/playground/node_modules/.vite/deps/astro___html-escaper.js +0 -34
- package/playground/node_modules/.vite/deps/astro___html-escaper.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js +0 -0
- package/playground/node_modules/.vite/deps/chunk-AJXJMYAF.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js +0 -8
- package/playground/node_modules/.vite/deps/chunk-BUSYA2B4.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js +0 -21
- package/playground/node_modules/.vite/deps/chunk-CNYJBM5F.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js +0 -223
- package/playground/node_modules/.vite/deps/chunk-DBPNBGEI.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js +0 -27
- package/playground/node_modules/.vite/deps/chunk-FPEUJ7DG.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js +0 -1005
- package/playground/node_modules/.vite/deps/chunk-MHDZ3SK7.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js +0 -204
- package/playground/node_modules/.vite/deps/chunk-RBDTDTPY.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js +0 -688
- package/playground/node_modules/.vite/deps/chunk-RJGEXL5C.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js +0 -5099
- package/playground/node_modules/.vite/deps/chunk-YL4MIWGJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js +0 -4376
- package/playground/node_modules/.vite/deps/chunk-ZOV3DWEJ.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js +0 -23
- package/playground/node_modules/.vite/deps/chunk-ZP4UNCSN.js.map +0 -7
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js +0 -148
- package/playground/node_modules/.vite/deps/chunk-ZREFNRZZ.js.map +0 -7
- package/playground/node_modules/.vite/deps/package.json +0 -3
- package/playground/node_modules/.vite/deps/smol-toml.js +0 -843
- package/playground/node_modules/.vite/deps/smol-toml.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte.js +0 -55
- package/playground/node_modules/.vite/deps/svelte.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte___clsx.js +0 -9
- package/playground/node_modules/.vite/deps/svelte___clsx.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_animate.js +0 -57
- package/playground/node_modules/.vite/deps/svelte_animate.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_attachments.js +0 -15
- package/playground/node_modules/.vite/deps/svelte_attachments.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_easing.js +0 -67
- package/playground/node_modules/.vite/deps/svelte_easing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_events.js +0 -11
- package/playground/node_modules/.vite/deps/svelte_events.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal.js +0 -5
- package/playground/node_modules/.vite/deps/svelte_internal.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_client.js +0 -402
- package/playground/node_modules/.vite/deps/svelte_internal_client.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js +0 -10
- package/playground/node_modules/.vite/deps/svelte_internal_disclose-version.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_async.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js +0 -8
- package/playground/node_modules/.vite/deps/svelte_internal_flags_tracing.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_legacy.js +0 -35
- package/playground/node_modules/.vite/deps/svelte_legacy.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_motion.js +0 -545
- package/playground/node_modules/.vite/deps/svelte_motion.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity.js +0 -29
- package/playground/node_modules/.vite/deps/svelte_reactivity.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js +0 -127
- package/playground/node_modules/.vite/deps/svelte_reactivity_window.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_store.js +0 -103
- package/playground/node_modules/.vite/deps/svelte_store.js.map +0 -7
- package/playground/node_modules/.vite/deps/svelte_transition.js +0 -208
- package/playground/node_modules/.vite/deps/svelte_transition.js.map +0 -7
- package/playground/package.json +0 -16
- package/playground/pnpm-lock.yaml +0 -3167
- package/playground/src/content/authors/jane-doe.json +0 -8
- package/playground/src/content/config/build.toml +0 -2
- package/playground/src/content/courses/web-fundamentals.json +0 -29
- package/playground/src/content/docs/advanced.mdx +0 -6
- package/playground/src/content/docs/intro.md +0 -6
- package/playground/src/content/guides/getting-started.mdx +0 -6
- package/playground/src/content/posts/hello-world.md +0 -7
- package/playground/src/content/products/t-shirt.json +0 -16
- package/playground/src/content/recipes/pancakes.mdoc +0 -8
- package/playground/src/content/settings/site.yml +0 -2
- package/playground/src/content.config.ts +0 -198
- package/playground/src/env.d.ts +0 -1
- package/playground/src/pages/index.astro +0 -11
- package/playground/src/pages/nebula.astro +0 -14
- package/pnpm-workspace.yaml +0 -2
- package/scripts/subset-icons.mjs +0 -178
- package/src/astro/index.ts +0 -295
- package/src/client/js/drafts/merge.svelte.ts +0 -121
- package/src/client/js/drafts/ops.svelte.ts +0 -227
- package/src/client/js/drafts/storage.ts +0 -108
- package/src/client/js/drafts/workers/diff.ts +0 -40
- package/src/client/js/editor/editor.svelte.ts +0 -343
- package/src/client/js/editor/languages.ts +0 -98
- package/src/client/js/editor/markdown-shortcuts.ts +0 -261
- package/src/client/js/handlers/admin.ts +0 -246
- package/src/client/js/state/dialogs.svelte.ts +0 -35
- package/src/client/js/state/router.svelte.ts +0 -156
- package/src/client/js/state/state.svelte.ts +0 -334
- package/src/client/js/storage/adapter.ts +0 -102
- package/src/client/js/storage/client.ts +0 -150
- package/src/client/js/storage/db.ts +0 -36
- package/src/client/js/storage/fsa.ts +0 -110
- package/src/client/js/storage/github.ts +0 -297
- package/src/client/js/storage/storage.ts +0 -83
- package/src/client/js/storage/workers/frontmatter.ts +0 -320
- package/src/client/js/storage/workers/storage.ts +0 -177
- package/src/client/js/storage/workers/toml-parser.ts +0 -106
- package/src/client/js/storage/workers/yaml-parser.ts +0 -132
- package/src/client/js/utils/frontmatter.ts +0 -38
- package/src/client/js/utils/schema-utils.ts +0 -295
- package/src/client/js/utils/sort.ts +0 -84
- package/src/client/js/utils/stable-stringify.ts +0 -27
- package/src/types.ts +0 -25
- package/svelte.config.js +0 -4
- package/tests/astro/build.test.ts +0 -63
- package/tests/astro/index.test.ts +0 -689
- package/tests/client/components/Admin.test.ts +0 -446
- package/tests/client/components/BackendPicker.test.ts +0 -239
- package/tests/client/components/DraftChip.test.ts +0 -53
- package/tests/client/components/MetadataForm.test.ts +0 -164
- package/tests/client/components/dialogs/DeleteDraftDialog.test.ts +0 -91
- package/tests/client/components/dialogs/FilenameDialog.test.ts +0 -209
- package/tests/client/components/dialogs/dialog-stubs.ts +0 -19
- package/tests/client/components/editor/EditorPane.test.ts +0 -100
- package/tests/client/components/editor/EditorTabs.test.ts +0 -253
- package/tests/client/components/editor/EditorToolbar.test.ts +0 -252
- package/tests/client/components/editor/fixtures.ts +0 -31
- package/tests/client/components/fields/ArrayField.test.ts +0 -197
- package/tests/client/components/fields/BooleanField.test.ts +0 -206
- package/tests/client/components/fields/DateField.test.ts +0 -210
- package/tests/client/components/fields/EnumField.test.ts +0 -246
- package/tests/client/components/fields/NumberField.test.ts +0 -240
- package/tests/client/components/fields/ObjectField.test.ts +0 -157
- package/tests/client/components/fields/SchemaField.test.ts +0 -190
- package/tests/client/components/fields/StringField.test.ts +0 -223
- package/tests/client/components/sidebar/AdminSidebar.test.ts +0 -285
- package/tests/client/components/sidebar/AdminSidebarSort.test.ts +0 -135
- package/tests/client/components/sidebar/sort-mock.ts +0 -23
- package/tests/client/js/drafts/fixtures.ts +0 -22
- package/tests/client/js/drafts/merge.test.ts +0 -282
- package/tests/client/js/drafts/ops.test.ts +0 -658
- package/tests/client/js/drafts/storage.test.ts +0 -200
- package/tests/client/js/drafts/workers/diff.test.ts +0 -165
- package/tests/client/js/editor/editor.test.ts +0 -616
- package/tests/client/js/editor/link-wrap.test.ts +0 -225
- package/tests/client/js/editor/markdown-shortcuts.test.ts +0 -370
- package/tests/client/js/handlers/admin.test.ts +0 -467
- package/tests/client/js/state/router.test.ts +0 -619
- package/tests/client/js/state/schema.test.ts +0 -266
- package/tests/client/js/state/state.test.ts +0 -328
- package/tests/client/js/storage/adapter.test.ts +0 -115
- package/tests/client/js/storage/client.test.ts +0 -250
- package/tests/client/js/storage/db.test.ts +0 -59
- package/tests/client/js/storage/fsa.test.ts +0 -284
- package/tests/client/js/storage/github.test.ts +0 -349
- package/tests/client/js/storage/mock-port.ts +0 -95
- package/tests/client/js/storage/storage.test.ts +0 -77
- package/tests/client/js/storage/workers/frontmatter.test.ts +0 -479
- package/tests/client/js/storage/workers/storage.test.ts +0 -299
- package/tests/client/js/storage/workers/toml-parser.test.ts +0 -169
- package/tests/client/js/storage/workers/yaml-parser.test.ts +0 -168
- package/tests/client/js/utils/file-types.test.ts +0 -268
- package/tests/client/js/utils/frontmatter.test.ts +0 -87
- package/tests/client/js/utils/schema-utils.test.ts +0 -318
- package/tests/client/js/utils/slug.test.ts +0 -58
- package/tests/client/js/utils/sort.test.ts +0 -276
- package/tests/client/js/utils/stable-stringify.test.ts +0 -68
- package/tests/client/js/utils/url-utils.test.ts +0 -70
- package/tests/e2e/backend-connection.test.ts +0 -301
- package/tests/e2e/draft-lifecycle.test.ts +0 -388
- package/tests/e2e/editing.test.ts +0 -355
- package/tests/e2e/github-adapter.test.ts +0 -330
- package/tests/e2e/helpers/mock-adapter.ts +0 -166
- package/tests/e2e/helpers/test-app.ts +0 -155
- package/tests/e2e/navigation.test.ts +0 -358
- package/tests/e2e/publishing.test.ts +0 -345
- package/tests/e2e/unsaved-changes.test.ts +0 -317
- package/tests/setup.ts +0 -2
- package/tests/stubs/codemirror.ts +0 -197
- package/tsconfig.json +0 -19
- package/vitest.config.ts +0 -178
- /package/{src → dist}/client/components/BackendPicker.svelte +0 -0
- /package/{src → dist}/client/components/DraftChip.svelte +0 -0
- /package/{src → dist}/client/components/MetadataForm.svelte +0 -0
- /package/{src → dist}/client/components/ThemeToggle.svelte +0 -0
- /package/{src → dist}/client/components/dialogs/DeleteDraftDialog.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorPane.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorTabs.svelte +0 -0
- /package/{src → dist}/client/components/editor/EditorToolbar.svelte +0 -0
- /package/{src → dist}/client/components/editor/FormatSelector.svelte +0 -0
- /package/{src → dist}/client/components/editor/Toolbar.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ArrayItem.svelte +0 -0
- /package/{src → dist}/client/components/fields/BooleanField.svelte +0 -0
- /package/{src → dist}/client/components/fields/DateField.svelte +0 -0
- /package/{src → dist}/client/components/fields/EnumField.svelte +0 -0
- /package/{src → dist}/client/components/fields/FieldWrapper.svelte +0 -0
- /package/{src → dist}/client/components/fields/NumberField.svelte +0 -0
- /package/{src → dist}/client/components/fields/ObjectField.svelte +0 -0
- /package/{src → dist}/client/components/fields/SchemaField.svelte +0 -0
- /package/{src → dist}/client/components/fields/StringField.svelte +0 -0
- /package/{src → dist}/client/components/sidebar/AdminSidebarSort.svelte +0 -0
- /package/{src → dist}/client/css/a11y.css +0 -0
- /package/{src → dist}/client/css/btn.css +0 -0
- /package/{src → dist}/client/css/dialog.css +0 -0
- /package/{src → dist}/client/css/field-input.css +0 -0
- /package/{src → dist}/client/css/reset.css +0 -0
- /package/{src → dist}/client/css/theme.css +0 -0
- /package/{src/client/index.ts → dist/client/index.js} +0 -0
- /package/{src → dist}/virtual.d.ts +0 -0
|
@@ -2,44 +2,37 @@
|
|
|
2
2
|
* CodeMirror extension that decorates markdown link nodes with a CSS class.
|
|
3
3
|
* Enables visual styling of link syntax in the editor.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
import { ViewPlugin, Decoration, type DecorationSet } from '@codemirror/view';
|
|
5
|
+
import { ViewPlugin, Decoration } from '@codemirror/view';
|
|
7
6
|
import { syntaxTree } from '@codemirror/language';
|
|
8
|
-
import { RangeSetBuilder
|
|
9
|
-
|
|
7
|
+
import { RangeSetBuilder } from '@codemirror/state';
|
|
10
8
|
// Mark decoration that adds the cm-link-wrap class to link nodes
|
|
11
9
|
const linkMark = Decoration.mark({ class: 'cm-link-wrap' });
|
|
12
|
-
|
|
13
10
|
/**
|
|
14
11
|
* Builds a DecorationSet marking all Link nodes in the syntax tree with the cm-link-wrap class.
|
|
15
12
|
* @param {EditorState} state - The current editor state
|
|
16
13
|
* @return {DecorationSet} The decoration set with all link ranges marked
|
|
17
14
|
*/
|
|
18
|
-
function buildDecorations(state
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
function buildDecorations(state) {
|
|
16
|
+
const builder = new RangeSetBuilder();
|
|
17
|
+
syntaxTree(state).iterate({
|
|
18
|
+
enter(node) {
|
|
19
|
+
if (node.name === 'Link') {
|
|
20
|
+
builder.add(node.from, node.to, linkMark);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
return builder.finish();
|
|
28
25
|
}
|
|
29
|
-
|
|
30
26
|
/*
|
|
31
27
|
* ViewPlugin that adds a word-break: break-all wrapper around markdown links.
|
|
32
28
|
* This prevents the Unicode Line Break Algorithm from breaking between ] and (
|
|
33
29
|
* in [text](url) syntax, which causes URLs to jump to the next line.
|
|
34
30
|
*/
|
|
35
|
-
export const linkWrapPlugin = ViewPlugin.define(
|
|
36
|
-
(view) => ({
|
|
31
|
+
export const linkWrapPlugin = ViewPlugin.define((view) => ({
|
|
37
32
|
decorations: buildDecorations(view.state),
|
|
38
33
|
update(update) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
if (update.docChanged || update.viewportChanged) {
|
|
35
|
+
this.decorations = buildDecorations(update.state);
|
|
36
|
+
}
|
|
42
37
|
},
|
|
43
|
-
|
|
44
|
-
{ decorations: (v) => v.decorations },
|
|
45
|
-
);
|
|
38
|
+
}), { decorations: (v) => v.decorations });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-shortcuts.d.ts","sourceRoot":"","sources":["../../../../src/client/js/editor/markdown-shortcuts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA8K/D,eAAO,MAAM,uBAAuB,EAAE,UAAU,EAI/C,CAAC;AA6EF,eAAO,MAAM,2BAA2B,yCAGvC,CAAC"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { syntaxTree } from '@codemirror/language';
|
|
2
|
+
import { EditorSelection } from '@codemirror/state';
|
|
3
|
+
import { EditorView } from '@codemirror/view';
|
|
4
|
+
import { isURL } from '../utils/url-utils';
|
|
5
|
+
/*
|
|
6
|
+
//////////////////////////////
|
|
7
|
+
// Bracket/Quote Pair Map
|
|
8
|
+
//////////////////////////////
|
|
9
|
+
*/
|
|
10
|
+
// Maps opening characters to their closing counterparts for selection wrapping
|
|
11
|
+
const wrapPairs = {
|
|
12
|
+
'[': ']',
|
|
13
|
+
'{': '}',
|
|
14
|
+
'(': ')',
|
|
15
|
+
"'": "'",
|
|
16
|
+
'"': '"',
|
|
17
|
+
};
|
|
18
|
+
/*
|
|
19
|
+
//////////////////////////////
|
|
20
|
+
// Formatting Toggle Helpers
|
|
21
|
+
//////////////////////////////
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Finds the innermost syntax tree node of the given type that contains the
|
|
25
|
+
* given position. Returns the node's from/to range, or null if not found.
|
|
26
|
+
* @param {EditorState} state - The current editor state
|
|
27
|
+
* @param {number} pos - The document position to check
|
|
28
|
+
* @param {string} nodeType - The syntax tree node name to search for
|
|
29
|
+
* @return {{ from: number, to: number } | null} The node range, or null
|
|
30
|
+
*/
|
|
31
|
+
function findWrappingNode(state, pos, nodeType) {
|
|
32
|
+
let result = null;
|
|
33
|
+
syntaxTree(state).iterate({
|
|
34
|
+
from: pos,
|
|
35
|
+
to: pos,
|
|
36
|
+
enter(node) {
|
|
37
|
+
if (node.name === nodeType) {
|
|
38
|
+
result = { from: node.from, to: node.to };
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a CodeMirror command that toggles a markdown formatting marker
|
|
46
|
+
* (e.g., ** for bold, _ for italic) using syntax tree detection.
|
|
47
|
+
* When inside the target node type, it unwraps. Otherwise, it wraps
|
|
48
|
+
* the selection or inserts empty markers with the cursor between them.
|
|
49
|
+
* @param {string} marker - The markdown marker string (e.g., "**" or "_")
|
|
50
|
+
* @param {string} nodeType - The syntax tree node name (e.g., "StrongEmphasis" or "Emphasis")
|
|
51
|
+
* @return {(view: EditorView) => boolean} A CodeMirror command function
|
|
52
|
+
*/
|
|
53
|
+
function toggleMarker(marker, nodeType) {
|
|
54
|
+
return (view) => {
|
|
55
|
+
const { state } = view;
|
|
56
|
+
const changes = state.changeByRange((range) => {
|
|
57
|
+
// Check if cursor/selection is inside the target node
|
|
58
|
+
const node = findWrappingNode(state, range.from, nodeType);
|
|
59
|
+
if (node) {
|
|
60
|
+
/*
|
|
61
|
+
* Unwrap — remove markers from both ends of the node.
|
|
62
|
+
* Post-change coordinates: removing the opening marker shifts everything
|
|
63
|
+
* left by len, and removing the closing marker doesn't affect earlier positions.
|
|
64
|
+
* So the inner text spans from node.from to node.to - len * 2.
|
|
65
|
+
*/
|
|
66
|
+
const len = marker.length;
|
|
67
|
+
/*
|
|
68
|
+
* Preserve cursor vs selection: if the user had a cursor (no selection),
|
|
69
|
+
* keep it as a cursor inside the unwrapped text rather than selecting all of it.
|
|
70
|
+
* Clamp the post-change cursor: if the cursor was at or before the opening marker,
|
|
71
|
+
* it lands at the start of the unwrapped text (node.from).
|
|
72
|
+
*/
|
|
73
|
+
const innerEnd = node.to - len * 2;
|
|
74
|
+
const postRange = range.empty
|
|
75
|
+
? EditorSelection.cursor(Math.max(node.from, Math.min(range.from - len, innerEnd)))
|
|
76
|
+
: EditorSelection.range(node.from, innerEnd);
|
|
77
|
+
return {
|
|
78
|
+
range: postRange,
|
|
79
|
+
changes: [
|
|
80
|
+
{ from: node.from, to: node.from + len, insert: '' },
|
|
81
|
+
{ from: node.to - len, to: node.to, insert: '' },
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
if (range.empty) {
|
|
86
|
+
// No selection — insert empty markers and place cursor between them
|
|
87
|
+
const insert = marker + marker;
|
|
88
|
+
return {
|
|
89
|
+
range: EditorSelection.cursor(range.from + marker.length),
|
|
90
|
+
changes: { from: range.from, insert },
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// Wrap selection in markers, keep text selected
|
|
94
|
+
return {
|
|
95
|
+
range: EditorSelection.range(range.from + marker.length, range.to + marker.length),
|
|
96
|
+
changes: [
|
|
97
|
+
{ from: range.from, insert: marker },
|
|
98
|
+
{ from: range.to, insert: marker },
|
|
99
|
+
],
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
view.dispatch(changes);
|
|
103
|
+
return true;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/*
|
|
107
|
+
//////////////////////////////
|
|
108
|
+
// Link Insertion Command
|
|
109
|
+
//////////////////////////////
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* Inserts a markdown link. With a selection, wraps as [text]() and places the
|
|
113
|
+
* cursor in the URL parentheses. Without a selection, inserts []() and places
|
|
114
|
+
* the cursor in the link text brackets. Does nothing inside existing Link nodes.
|
|
115
|
+
* @param {EditorView} view - The CodeMirror editor view
|
|
116
|
+
* @return {boolean} True if the command was handled
|
|
117
|
+
*/
|
|
118
|
+
function insertLink(view) {
|
|
119
|
+
const { state } = view;
|
|
120
|
+
// Don't re-wrap existing links — check the primary selection
|
|
121
|
+
if (findWrappingNode(state, state.selection.main.from, 'Link'))
|
|
122
|
+
return false;
|
|
123
|
+
const changes = state.changeByRange((range) => {
|
|
124
|
+
if (range.empty) {
|
|
125
|
+
// No selection — insert []() with cursor inside []
|
|
126
|
+
return {
|
|
127
|
+
range: EditorSelection.cursor(range.from + 1),
|
|
128
|
+
changes: { from: range.from, insert: '[]()' },
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Wrap selection as [text]() with cursor inside ()
|
|
132
|
+
const selectedText = state.sliceDoc(range.from, range.to);
|
|
133
|
+
const replacement = `[${selectedText}]()`;
|
|
134
|
+
return {
|
|
135
|
+
// Cursor between the parentheses: [text](|)
|
|
136
|
+
range: EditorSelection.cursor(range.from + selectedText.length + 3),
|
|
137
|
+
changes: { from: range.from, to: range.to, insert: replacement },
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
view.dispatch(changes);
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
/*
|
|
144
|
+
//////////////////////////////
|
|
145
|
+
// Keymap Export
|
|
146
|
+
//////////////////////////////
|
|
147
|
+
*/
|
|
148
|
+
// Keymap bindings for markdown formatting shortcuts (bold, italic, link)
|
|
149
|
+
export const markdownShortcutsKeymap = [
|
|
150
|
+
{ key: 'Mod-b', run: toggleMarker('**', 'StrongEmphasis') },
|
|
151
|
+
{ key: 'Mod-i', run: toggleMarker('_', 'Emphasis') },
|
|
152
|
+
{ key: 'Mod-k', run: insertLink },
|
|
153
|
+
];
|
|
154
|
+
/*
|
|
155
|
+
//////////////////////////////
|
|
156
|
+
// Smart Paste Handler
|
|
157
|
+
//////////////////////////////
|
|
158
|
+
*/
|
|
159
|
+
/*
|
|
160
|
+
* Intercepts paste events to wrap selected text as a markdown link when
|
|
161
|
+
* the clipboard contains a URL. Only activates when text is selected.
|
|
162
|
+
*/
|
|
163
|
+
const smartPasteHandler = EditorView.domEventHandlers({
|
|
164
|
+
paste(event, view) {
|
|
165
|
+
const { from, to, empty } = view.state.selection.main;
|
|
166
|
+
if (empty)
|
|
167
|
+
return false;
|
|
168
|
+
const clipboardText = event.clipboardData?.getData('text/plain') ?? '';
|
|
169
|
+
if (!isURL(clipboardText))
|
|
170
|
+
return false;
|
|
171
|
+
const url = clipboardText.trim();
|
|
172
|
+
const selectedText = view.state.sliceDoc(from, to);
|
|
173
|
+
const replacement = `[${selectedText}](${url})`;
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
view.dispatch({
|
|
176
|
+
changes: { from, to, insert: replacement },
|
|
177
|
+
selection: EditorSelection.cursor(from + replacement.length),
|
|
178
|
+
});
|
|
179
|
+
return true;
|
|
180
|
+
},
|
|
181
|
+
});
|
|
182
|
+
/*
|
|
183
|
+
//////////////////////////////
|
|
184
|
+
// Bracket/Quote Wrap Handler
|
|
185
|
+
//////////////////////////////
|
|
186
|
+
*/
|
|
187
|
+
/*
|
|
188
|
+
* Intercepts single-character input to wrap selected text in matching
|
|
189
|
+
* bracket or quote pairs. Only activates when text is selected and
|
|
190
|
+
* the typed character is a recognized opening bracket or quote.
|
|
191
|
+
*/
|
|
192
|
+
const bracketWrapHandler = EditorView.inputHandler.of((view, from, to, text) => {
|
|
193
|
+
const closing = wrapPairs[text];
|
|
194
|
+
if (!closing)
|
|
195
|
+
return false;
|
|
196
|
+
const { main } = view.state.selection;
|
|
197
|
+
if (main.empty)
|
|
198
|
+
return false;
|
|
199
|
+
const selectedText = view.state.sliceDoc(main.from, main.to);
|
|
200
|
+
view.dispatch({
|
|
201
|
+
changes: {
|
|
202
|
+
from: main.from,
|
|
203
|
+
to: main.to,
|
|
204
|
+
insert: text + selectedText + closing,
|
|
205
|
+
},
|
|
206
|
+
selection: EditorSelection.range(main.from + 1, main.from + 1 + selectedText.length),
|
|
207
|
+
});
|
|
208
|
+
return true;
|
|
209
|
+
});
|
|
210
|
+
/*
|
|
211
|
+
//////////////////////////////
|
|
212
|
+
// Extensions Export
|
|
213
|
+
//////////////////////////////
|
|
214
|
+
*/
|
|
215
|
+
// Non-keymap extensions: smart paste URL handler and bracket/quote wrapping
|
|
216
|
+
export const markdownShortcutsExtensions = [
|
|
217
|
+
smartPasteHandler,
|
|
218
|
+
bracketWrapHandler,
|
|
219
|
+
];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ContentItem } from '../state/state.svelte';
|
|
2
|
+
import { type AdminRoute } from '../state/router.svelte';
|
|
3
|
+
import type { Draft } from '../drafts/storage';
|
|
4
|
+
import type { SidebarItem } from '../utils/sort';
|
|
5
|
+
/**
|
|
6
|
+
* Builds the content sidebar item list by merging live content with draft data.
|
|
7
|
+
* @param {ContentItem[]} contentList - Live content items from the storage worker
|
|
8
|
+
* @param {Draft[]} drafts - All drafts for the active collection
|
|
9
|
+
* @param {Record<string, boolean>} outdatedMap - Map of draft ID to outdated status
|
|
10
|
+
* @param {string | null} activeCollection - The currently active collection name
|
|
11
|
+
* @return {SidebarItem[]} Merged list of live and draft sidebar items
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildContentItems(contentList: ContentItem[], drafts: Draft[], outdatedMap: Record<string, boolean>, activeCollection: string | null): SidebarItem[];
|
|
14
|
+
/**
|
|
15
|
+
* Builds the collection sidebar items from collection names, using schema title/description when available.
|
|
16
|
+
* @return {SidebarItem[]} Collection sidebar items with hrefs under the configured basePath
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildCollectionItems(): SidebarItem[];
|
|
19
|
+
/**
|
|
20
|
+
* Derives the active file/draft href for sidebar highlighting from the current route.
|
|
21
|
+
* @param {AdminRoute} route - The current admin route
|
|
22
|
+
* @return {string | undefined} The href of the active file or draft, or undefined if not in a file/draft view
|
|
23
|
+
*/
|
|
24
|
+
export declare function buildActiveFileHref(route: AdminRoute): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Saves the current editor content as a draft to IndexedDB and refreshes the sidebar's draft list so changes appear immediately.
|
|
27
|
+
* @param {string | null} activeCollection - The active collection for refreshing the draft list
|
|
28
|
+
* @return {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
export declare function handleSave(activeCollection: string | null): Promise<void>;
|
|
31
|
+
export type PublishResult = {
|
|
32
|
+
status: 'ok';
|
|
33
|
+
} | {
|
|
34
|
+
status: 'no-file';
|
|
35
|
+
} | {
|
|
36
|
+
status: 'needs-filename';
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Publishes the current editor content via StorageClient. If the file has no filename, returns a status indicating the filename dialog should be shown.
|
|
40
|
+
* @param {string | null} activeCollection - The currently active collection name
|
|
41
|
+
* @return {Promise<PublishResult>} The result of the publish attempt
|
|
42
|
+
*/
|
|
43
|
+
export declare function handlePublish(activeCollection: string | null): Promise<PublishResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Deletes the current draft. For drafts of live content, navigates to the live file's URL so the live version reloads in-place. For new drafts, navigates back to the collection list.
|
|
46
|
+
* @param {string | null} activeCollection - The collection to navigate within
|
|
47
|
+
* @return {Promise<void>}
|
|
48
|
+
*/
|
|
49
|
+
export declare function handleDeleteDraft(activeCollection: string | null): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* Handles the filename dialog confirmation: sets the filename on the editor and triggers publish.
|
|
52
|
+
* @param {string} filename - The chosen filename (with extension)
|
|
53
|
+
* @param {string | null} activeCollection - The active collection name
|
|
54
|
+
* @return {Promise<void>}
|
|
55
|
+
*/
|
|
56
|
+
export declare function handleFilenameConfirm(filename: string, activeCollection: string | null): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Checks whether the publish button should be disabled by verifying required schema fields are populated.
|
|
59
|
+
* @param {Record<string, unknown> | null} schema - The active JSON schema
|
|
60
|
+
* @param {Record<string, unknown>} formData - The current form data
|
|
61
|
+
* @return {boolean} True if publish should be disabled
|
|
62
|
+
*/
|
|
63
|
+
export declare function computePublishDisabled(schema: Record<string, unknown> | null, formData: Record<string, unknown>): boolean;
|
|
64
|
+
//# sourceMappingURL=admin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../../src/client/js/handlers/admin.ts"],"names":[],"mappings":"AAcA,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAuB,KAAK,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAK9E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,EAAE,EAC1B,MAAM,EAAE,KAAK,EAAE,EACf,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,WAAW,EAAE,CA0Cf;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,EAAE,CAOpD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAQzE;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,OAAO,CAAC,IAAI,CAAC,CAKf;AAGD,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,IAAI,CAAA;CAAE,GAChB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAEjC;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,OAAO,CAAC,aAAa,CAAC,CA6BxB;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,OAAO,CAAC,IAAI,CAAC,CAGf;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,EACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,OAAO,CAQT"}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Admin action handlers for save, publish, delete, and sidebar data construction.
|
|
3
|
+
*/
|
|
4
|
+
import { clearEditor, getEditorFile, setFilename, editor, } from '../editor/editor.svelte';
|
|
5
|
+
import { saveDraftToIDB, publishFile, deleteCurrentDraft, } from '../drafts/ops.svelte';
|
|
6
|
+
import { collections, reloadCollection, refreshDrafts, updateContentItem, } from '../state/state.svelte';
|
|
7
|
+
import { navigate, adminPath } from '../state/router.svelte';
|
|
8
|
+
import { getCollectionTitle, getCollectionDescription, } from '../state/schema.svelte';
|
|
9
|
+
import { toSortDate } from '../utils/sort';
|
|
10
|
+
import { stripExtension } from '../utils/file-types';
|
|
11
|
+
/**
|
|
12
|
+
* Builds the content sidebar item list by merging live content with draft data.
|
|
13
|
+
* @param {ContentItem[]} contentList - Live content items from the storage worker
|
|
14
|
+
* @param {Draft[]} drafts - All drafts for the active collection
|
|
15
|
+
* @param {Record<string, boolean>} outdatedMap - Map of draft ID to outdated status
|
|
16
|
+
* @param {string | null} activeCollection - The currently active collection name
|
|
17
|
+
* @return {SidebarItem[]} Merged list of live and draft sidebar items
|
|
18
|
+
*/
|
|
19
|
+
export function buildContentItems(contentList, drafts, outdatedMap, activeCollection) {
|
|
20
|
+
// Build a filename → draft lookup map for O(1) access per content item
|
|
21
|
+
const draftByFile = new Map(drafts.filter((d) => !d.isNew && d.filename).map((d) => [d.filename, d]));
|
|
22
|
+
const liveItems = contentList.map((item) => {
|
|
23
|
+
const title = typeof item.data.title === 'string' ? item.data.title : item.filename;
|
|
24
|
+
const slug = stripExtension(item.filename);
|
|
25
|
+
const draft = draftByFile.get(item.filename);
|
|
26
|
+
const date = toSortDate(item.data.published);
|
|
27
|
+
return {
|
|
28
|
+
label: title,
|
|
29
|
+
href: adminPath(activeCollection, slug),
|
|
30
|
+
subtitle: item.filename,
|
|
31
|
+
...(date ? { date } : {}),
|
|
32
|
+
...(draft
|
|
33
|
+
? {
|
|
34
|
+
draftId: draft.id,
|
|
35
|
+
isDraft: true,
|
|
36
|
+
isOutdated: outdatedMap[draft.id] ?? false,
|
|
37
|
+
}
|
|
38
|
+
: {}),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
const newDraftItems = drafts
|
|
42
|
+
.filter((d) => d.isNew)
|
|
43
|
+
.map((d) => {
|
|
44
|
+
const date = toSortDate(d.formData.published);
|
|
45
|
+
return {
|
|
46
|
+
label: typeof d.formData.title === 'string'
|
|
47
|
+
? d.formData.title
|
|
48
|
+
: 'Untitled Draft',
|
|
49
|
+
href: adminPath(activeCollection, `draft-${d.id}`),
|
|
50
|
+
draftId: d.id,
|
|
51
|
+
isDraft: true,
|
|
52
|
+
isOutdated: false,
|
|
53
|
+
...(date ? { date } : {}),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
return [...liveItems, ...newDraftItems];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Builds the collection sidebar items from collection names, using schema title/description when available.
|
|
60
|
+
* @return {SidebarItem[]} Collection sidebar items with hrefs under the configured basePath
|
|
61
|
+
*/
|
|
62
|
+
export function buildCollectionItems() {
|
|
63
|
+
return collections.map((name) => ({
|
|
64
|
+
label: getCollectionTitle(name) ?? name.charAt(0).toUpperCase() + name.slice(1),
|
|
65
|
+
href: adminPath(name),
|
|
66
|
+
subtitle: getCollectionDescription(name) ?? undefined,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Derives the active file/draft href for sidebar highlighting from the current route.
|
|
71
|
+
* @param {AdminRoute} route - The current admin route
|
|
72
|
+
* @return {string | undefined} The href of the active file or draft, or undefined if not in a file/draft view
|
|
73
|
+
*/
|
|
74
|
+
export function buildActiveFileHref(route) {
|
|
75
|
+
if (route.view === 'file') {
|
|
76
|
+
return adminPath(route.collection, route.slug);
|
|
77
|
+
}
|
|
78
|
+
if (route.view === 'draft') {
|
|
79
|
+
return adminPath(route.collection, `draft-${route.draftId}`);
|
|
80
|
+
}
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Saves the current editor content as a draft to IndexedDB and refreshes the sidebar's draft list so changes appear immediately.
|
|
85
|
+
* @param {string | null} activeCollection - The active collection for refreshing the draft list
|
|
86
|
+
* @return {Promise<void>}
|
|
87
|
+
*/
|
|
88
|
+
export async function handleSave(activeCollection) {
|
|
89
|
+
await saveDraftToIDB();
|
|
90
|
+
if (activeCollection) {
|
|
91
|
+
await refreshDrafts(activeCollection);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Publishes the current editor content via StorageClient. If the file has no filename, returns a status indicating the filename dialog should be shown.
|
|
96
|
+
* @param {string | null} activeCollection - The currently active collection name
|
|
97
|
+
* @return {Promise<PublishResult>} The result of the publish attempt
|
|
98
|
+
*/
|
|
99
|
+
export async function handlePublish(activeCollection) {
|
|
100
|
+
const file = getEditorFile();
|
|
101
|
+
if (!file)
|
|
102
|
+
return { status: 'no-file' };
|
|
103
|
+
if (!file.filename)
|
|
104
|
+
return { status: 'needs-filename' };
|
|
105
|
+
if (!activeCollection)
|
|
106
|
+
return { status: 'no-file' };
|
|
107
|
+
// Pass originalFilename so publishFile can delete the old file when format changes
|
|
108
|
+
const originalFn = editor.originalFilename;
|
|
109
|
+
await publishFile(activeCollection, file.filename, originalFn !== file.filename ? originalFn : undefined);
|
|
110
|
+
// Determine if the filename changed (format conversion or new file)
|
|
111
|
+
const filenameChanged = originalFn && originalFn !== file.filename;
|
|
112
|
+
if (file.isNewDraft || filenameChanged) {
|
|
113
|
+
// New file or renamed file — not in contentList under this name, need a full refresh
|
|
114
|
+
reloadCollection(activeCollection);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
/*
|
|
118
|
+
* Existing file, same name — optimistically update sidebar with current formData
|
|
119
|
+
* so the title reflects edits instantly without re-fetching all files.
|
|
120
|
+
*/
|
|
121
|
+
updateContentItem(file.filename, file.formData);
|
|
122
|
+
}
|
|
123
|
+
await refreshDrafts(activeCollection);
|
|
124
|
+
return { status: 'ok' };
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Deletes the current draft. For drafts of live content, navigates to the live file's URL so the live version reloads in-place. For new drafts, navigates back to the collection list.
|
|
128
|
+
* @param {string | null} activeCollection - The collection to navigate within
|
|
129
|
+
* @return {Promise<void>}
|
|
130
|
+
*/
|
|
131
|
+
export async function handleDeleteDraft(activeCollection) {
|
|
132
|
+
const file = getEditorFile();
|
|
133
|
+
const wasNewDraft = file?.isNewDraft ?? true;
|
|
134
|
+
const liveFilename = file?.filename;
|
|
135
|
+
await deleteCurrentDraft();
|
|
136
|
+
if (!activeCollection)
|
|
137
|
+
return;
|
|
138
|
+
// Capture narrowed value before awaits (TS can't narrow across async boundaries)
|
|
139
|
+
const collection = activeCollection;
|
|
140
|
+
/*
|
|
141
|
+
* Refresh drafts list only — live content hasn't changed, so no need to
|
|
142
|
+
* reload the full collection (which re-reads all files and causes a flash).
|
|
143
|
+
*/
|
|
144
|
+
await refreshDrafts(collection);
|
|
145
|
+
/*
|
|
146
|
+
* Clear editor so the route change triggers a fresh load (preloadFile has
|
|
147
|
+
* an early return if the same filename is already open).
|
|
148
|
+
*/
|
|
149
|
+
clearEditor();
|
|
150
|
+
if (!wasNewDraft && liveFilename) {
|
|
151
|
+
// Draft of live content — navigate to the live file so it reloads from disk
|
|
152
|
+
const slug = stripExtension(liveFilename);
|
|
153
|
+
navigate(adminPath(collection, slug));
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// New draft — no live file to return to, go to collection list
|
|
157
|
+
navigate(adminPath(collection));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Handles the filename dialog confirmation: sets the filename on the editor and triggers publish.
|
|
162
|
+
* @param {string} filename - The chosen filename (with extension)
|
|
163
|
+
* @param {string | null} activeCollection - The active collection name
|
|
164
|
+
* @return {Promise<void>}
|
|
165
|
+
*/
|
|
166
|
+
export async function handleFilenameConfirm(filename, activeCollection) {
|
|
167
|
+
setFilename(filename);
|
|
168
|
+
await handlePublish(activeCollection);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Checks whether the publish button should be disabled by verifying required schema fields are populated.
|
|
172
|
+
* @param {Record<string, unknown> | null} schema - The active JSON schema
|
|
173
|
+
* @param {Record<string, unknown>} formData - The current form data
|
|
174
|
+
* @return {boolean} True if publish should be disabled
|
|
175
|
+
*/
|
|
176
|
+
export function computePublishDisabled(schema, formData) {
|
|
177
|
+
if (!schema)
|
|
178
|
+
return true;
|
|
179
|
+
const required = schema['required'];
|
|
180
|
+
if (!required)
|
|
181
|
+
return false;
|
|
182
|
+
return required.some((key) => {
|
|
183
|
+
const val = formData[key];
|
|
184
|
+
return val === undefined || val === null || val === '';
|
|
185
|
+
});
|
|
186
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type DialogType = 'filename' | 'delete';
|
|
2
|
+
export declare const dialog: {
|
|
3
|
+
readonly active: DialogType | null;
|
|
4
|
+
/**
|
|
5
|
+
* Opens a dialog by type. Only one dialog can be open at a time.
|
|
6
|
+
* @param {DialogType} type - The dialog to open
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
open(type: DialogType): void;
|
|
10
|
+
/**
|
|
11
|
+
* Closes whichever dialog is currently open.
|
|
12
|
+
* @return {void}
|
|
13
|
+
*/
|
|
14
|
+
close(): void;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=dialogs.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialogs.svelte.d.ts","sourceRoot":"","sources":["../../../../src/client/js/state/dialogs.svelte.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE/C,eAAO,MAAM,MAAM;qBAEH,UAAU,GAAG,IAAI;IAI/B;;;;OAIG;eACQ,UAAU,GAAG,IAAI;IAI5B;;;OAGG;aACM,IAAI;CAGd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Reactive state for dialog visibility. Lives here rather than in Admin.svelte
|
|
3
|
+
* so that EditorToolbar (and other components) can trigger dialogs without
|
|
4
|
+
* callback drilling through intermediate components.
|
|
5
|
+
*/
|
|
6
|
+
// Which dialog is currently open, or null if none
|
|
7
|
+
let active = $state(null);
|
|
8
|
+
export const dialog = {
|
|
9
|
+
// The currently open dialog, or null if none.
|
|
10
|
+
get active() {
|
|
11
|
+
return active;
|
|
12
|
+
},
|
|
13
|
+
/**
|
|
14
|
+
* Opens a dialog by type. Only one dialog can be open at a time.
|
|
15
|
+
* @param {DialogType} type - The dialog to open
|
|
16
|
+
* @return {void}
|
|
17
|
+
*/
|
|
18
|
+
open(type) {
|
|
19
|
+
active = type;
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* Closes whichever dialog is currently open.
|
|
23
|
+
* @return {void}
|
|
24
|
+
*/
|
|
25
|
+
close() {
|
|
26
|
+
active = null;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export type AdminRoute = {
|
|
2
|
+
view: 'home';
|
|
3
|
+
} | {
|
|
4
|
+
view: 'collection';
|
|
5
|
+
collection: string;
|
|
6
|
+
} | {
|
|
7
|
+
view: 'file';
|
|
8
|
+
collection: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
} | {
|
|
11
|
+
view: 'draft';
|
|
12
|
+
collection: string;
|
|
13
|
+
draftId: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const nav: {
|
|
16
|
+
readonly route: AdminRoute;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Builds an absolute path under the configured basePath by joining segments.
|
|
20
|
+
* Handles the root basePath case ('/') without producing double slashes.
|
|
21
|
+
* @param {...string} segments - Path segments to append (e.g. 'authors', 'my-post')
|
|
22
|
+
* @return {string} The joined path (e.g. '/admin/authors/my-post' or '/authors/my-post')
|
|
23
|
+
*/
|
|
24
|
+
export declare function adminPath(...segments: string[]): string;
|
|
25
|
+
/**
|
|
26
|
+
* Navigates to a path within the admin SPA using the Navigation API.
|
|
27
|
+
* @param {string} path - The path to navigate to (e.g., '/admin/posts')
|
|
28
|
+
* @return {void}
|
|
29
|
+
*/
|
|
30
|
+
export declare function navigate(path: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a function that returns whether the editor has unsaved changes.
|
|
33
|
+
* @param {() => boolean} checker - Function returning true if there are unsaved changes
|
|
34
|
+
* @return {void}
|
|
35
|
+
*/
|
|
36
|
+
export declare function registerDirtyChecker(checker: () => boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Initializes the Navigation API listener, intercepting navigations under the
|
|
39
|
+
* configured basePath and updating reactive route state.
|
|
40
|
+
* Safe to call multiple times — registers the listener only once.
|
|
41
|
+
* @return {void}
|
|
42
|
+
*/
|
|
43
|
+
export declare function initRouter(): void;
|
|
44
|
+
//# sourceMappingURL=router.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.svelte.d.ts","sourceRoot":"","sources":["../../../../src/client/js/state/router.svelte.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAgB3D,eAAO,MAAM,GAAG;oBAED,UAAU;CAGxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,CAIvD;AAgDD;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE3C;AAKD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,OAAO,GAAG,IAAI,CAEjE;AAKD;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAwCjC"}
|