@xleddyl/nuxt-cms 0.9.3 → 0.10.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/README.md +1 -1
- package/dist/module.d.mts +20 -1
- package/dist/module.json +1 -1
- package/dist/module.mjs +1037 -148
- package/dist/runtime/app/blocks/CmsBlocks.d.vue.ts +1 -1
- package/dist/runtime/app/blocks/CmsBlocks.vue +57 -9
- package/dist/runtime/app/blocks/CmsBlocks.vue.d.ts +1 -1
- package/dist/runtime/app/blocks/CmsField.d.ts +24 -0
- package/dist/runtime/app/blocks/CmsField.js +16 -0
- package/dist/runtime/app/blocks/node.d.ts +37 -0
- package/dist/runtime/app/blocks/node.js +17 -0
- package/dist/runtime/app/blocks/resolve.d.ts +18 -0
- package/dist/runtime/app/blocks/resolve.js +34 -0
- package/dist/runtime/app/components/cms/BlockPicker.d.vue.ts +22 -0
- package/dist/runtime/app/components/cms/BlockPicker.vue +87 -0
- package/dist/runtime/app/components/cms/BlockPicker.vue.d.ts +22 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.d.vue.ts +38 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.vue +44 -0
- package/dist/runtime/app/components/cms/BlockPickerPopover.vue.d.ts +38 -0
- package/dist/runtime/app/components/cms/BlockTree.d.vue.ts +29 -0
- package/dist/runtime/app/components/cms/BlockTree.vue +322 -0
- package/dist/runtime/app/components/cms/BlockTree.vue.d.ts +29 -0
- package/dist/runtime/app/components/cms/BlocksField.vue +569 -218
- package/dist/runtime/app/components/cms/BrandMark.vue +7 -13
- package/dist/runtime/app/components/cms/ConfirmGroups.vue +15 -13
- package/dist/runtime/app/components/cms/{BlockPalette.vue.d.ts → EditorHistory.d.vue.ts} +6 -5
- package/dist/runtime/app/components/cms/EditorHistory.vue +34 -0
- package/dist/runtime/app/components/cms/{BlockPalette.d.vue.ts → EditorHistory.vue.d.ts} +6 -5
- package/dist/runtime/app/components/cms/EntryDrawer.d.vue.ts +11 -5
- package/dist/runtime/app/components/cms/EntryDrawer.vue +183 -152
- package/dist/runtime/app/components/cms/EntryDrawer.vue.d.ts +11 -5
- package/dist/runtime/app/components/cms/EntryForm.d.vue.ts +16 -4
- package/dist/runtime/app/components/cms/EntryForm.vue +106 -146
- package/dist/runtime/app/components/cms/EntryForm.vue.d.ts +16 -4
- package/dist/runtime/app/components/cms/FieldInput.vue +10 -2
- package/dist/runtime/app/components/cms/FormSections.d.vue.ts +22 -0
- package/dist/runtime/app/components/cms/FormSections.vue +71 -0
- package/dist/runtime/app/components/cms/FormSections.vue.d.ts +22 -0
- package/dist/runtime/app/components/cms/ImportModal.vue +46 -58
- package/dist/runtime/app/components/cms/LinkField.d.vue.ts +16 -0
- package/dist/runtime/app/components/cms/LinkField.vue +250 -0
- package/dist/runtime/app/components/cms/LinkField.vue.d.ts +16 -0
- package/dist/runtime/app/components/cms/ListFilters.vue +10 -12
- package/dist/runtime/app/components/cms/LocaleSwitch.d.vue.ts +2 -1
- package/dist/runtime/app/components/cms/LocaleSwitch.vue +29 -5
- package/dist/runtime/app/components/cms/LocaleSwitch.vue.d.ts +2 -1
- package/dist/runtime/app/components/cms/MediaDetail.d.vue.ts +2 -0
- package/dist/runtime/app/components/cms/MediaDetail.vue +112 -83
- package/dist/runtime/app/components/cms/MediaDetail.vue.d.ts +2 -0
- package/dist/runtime/app/components/cms/MediaField.vue +35 -25
- package/dist/runtime/app/components/cms/MediaFolderPicker.vue +26 -71
- package/dist/runtime/app/components/cms/MediaGallery.d.vue.ts +1 -0
- package/dist/runtime/app/components/cms/MediaGallery.vue +442 -419
- package/dist/runtime/app/components/cms/MediaGallery.vue.d.ts +1 -0
- package/dist/runtime/app/components/cms/MediaThumb.vue +9 -25
- package/dist/runtime/app/components/cms/MediaUpload.vue +1 -1
- package/dist/runtime/app/components/cms/{BlockOutline.d.vue.ts → NestedBlockList.d.vue.ts} +5 -5
- package/dist/runtime/app/components/cms/NestedBlockList.vue +87 -0
- package/dist/runtime/app/components/cms/{BlockOutline.vue.d.ts → NestedBlockList.vue.d.ts} +5 -5
- package/dist/runtime/app/components/cms/PoweredBy.vue +12 -5
- package/dist/runtime/app/components/cms/PresetModal.d.vue.ts +18 -0
- package/dist/runtime/app/components/cms/PresetModal.vue +70 -0
- package/dist/runtime/app/components/cms/PresetModal.vue.d.ts +18 -0
- package/dist/runtime/app/components/cms/RelationField.vue +2 -8
- package/dist/runtime/app/components/cms/SettingsAccount.vue +60 -71
- package/dist/runtime/app/components/cms/SettingsColumns.vue +47 -69
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue +21 -0
- package/dist/runtime/app/components/cms/SettingsEmptyAdd.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntries.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntries.vue +50 -0
- package/dist/runtime/app/components/cms/SettingsEntries.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsEntry.d.vue.ts +1 -10
- package/dist/runtime/app/components/cms/SettingsEntry.vue +11 -95
- package/dist/runtime/app/components/cms/SettingsEntry.vue.d.ts +1 -10
- package/dist/runtime/app/components/cms/SettingsEntryActions.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryActions.vue +42 -0
- package/dist/runtime/app/components/cms/SettingsEntryActions.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.vue +21 -0
- package/dist/runtime/app/components/cms/SettingsEntryTabs.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.vue +17 -0
- package/dist/runtime/app/components/cms/SettingsFormAction.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsLayout.vue +18 -14
- package/dist/runtime/app/components/cms/SettingsPresetForm.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsPresetForm.vue +60 -0
- package/dist/runtime/app/components/cms/SettingsPresetForm.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsPresets.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsPresets.vue +65 -0
- package/dist/runtime/app/components/cms/SettingsPresets.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.d.vue.ts +32 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.vue +45 -0
- package/dist/runtime/app/components/cms/SettingsRecordActions.vue.d.ts +32 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.vue +59 -0
- package/dist/runtime/app/components/cms/SettingsRedirectActions.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.vue +77 -0
- package/dist/runtime/app/components/cms/SettingsRedirectForm.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.d.vue.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.vue +117 -0
- package/dist/runtime/app/components/cms/SettingsRedirects.vue.d.ts +13 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.d.vue.ts +17 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.vue +43 -0
- package/dist/runtime/app/components/cms/SettingsSecretCard.vue.d.ts +17 -0
- package/dist/runtime/app/components/cms/SettingsSite.d.vue.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsSite.vue +140 -0
- package/dist/runtime/app/components/cms/SettingsSite.vue.d.ts +3 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.d.vue.ts +8 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.vue +82 -0
- package/dist/runtime/app/components/cms/SettingsUserCreate.vue.d.ts +8 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.d.vue.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.vue +179 -0
- package/dist/runtime/app/components/cms/SettingsUserDetail.vue.d.ts +11 -0
- package/dist/runtime/app/components/cms/SettingsUsers.d.vue.ts +9 -6
- package/dist/runtime/app/components/cms/SettingsUsers.vue +88 -234
- package/dist/runtime/app/components/cms/SettingsUsers.vue.d.ts +9 -6
- package/dist/runtime/app/components/cms/SharePreview.d.vue.ts +18 -0
- package/dist/runtime/app/components/cms/SharePreview.vue +219 -0
- package/dist/runtime/app/components/cms/SharePreview.vue.d.ts +18 -0
- package/dist/runtime/app/components/cms/SlugField.vue +5 -3
- package/dist/runtime/app/components/cms/StatusBadge.vue +9 -8
- package/dist/runtime/app/components/cms/TranslationBadges.d.vue.ts +7 -0
- package/dist/runtime/app/components/cms/TranslationBadges.vue +45 -0
- package/dist/runtime/app/components/cms/TranslationBadges.vue.d.ts +7 -0
- package/dist/runtime/app/components/cms/TranslationMenu.d.vue.ts +17 -0
- package/dist/runtime/app/components/cms/TranslationMenu.vue +28 -0
- package/dist/runtime/app/components/cms/TranslationMenu.vue.d.ts +17 -0
- package/dist/runtime/app/components/cms/VisualEditor.d.vue.ts +22 -4
- package/dist/runtime/app/components/cms/VisualEditor.vue +1152 -335
- package/dist/runtime/app/components/cms/VisualEditor.vue.d.ts +22 -4
- package/dist/runtime/app/components/cms/WelcomeModal.vue +32 -50
- package/dist/runtime/app/composables/cms-clipboard.d.ts +8 -0
- package/dist/runtime/app/composables/cms-clipboard.js +38 -0
- package/dist/runtime/app/composables/cms-confirm.d.ts +6 -8
- package/dist/runtime/app/composables/cms-confirm.js +5 -7
- package/dist/runtime/app/composables/cms-entry-disabled.d.ts +5 -1
- package/dist/runtime/app/composables/cms-entry-disabled.js +7 -0
- package/dist/runtime/app/composables/cms-entry-form.d.ts +15 -0
- package/dist/runtime/app/composables/cms-entry-form.js +40 -0
- package/dist/runtime/app/composables/cms-entry-settings.d.ts +30 -0
- package/dist/runtime/app/composables/cms-entry-settings.js +122 -0
- package/dist/runtime/app/composables/cms-entry.d.ts +5 -1
- package/dist/runtime/app/composables/cms-entry.js +36 -11
- package/dist/runtime/app/composables/cms-history.d.ts +10 -0
- package/dist/runtime/app/composables/cms-history.js +24 -0
- package/dist/runtime/app/composables/cms-link-targets.d.ts +10 -0
- package/dist/runtime/app/composables/cms-link-targets.js +40 -0
- package/dist/runtime/app/composables/cms-link-usage.d.ts +1 -0
- package/dist/runtime/app/composables/cms-link-usage.js +45 -0
- package/dist/runtime/app/composables/cms-media-library.d.ts +19 -9
- package/dist/runtime/app/composables/cms-media-library.js +31 -13
- package/dist/runtime/app/composables/cms-media-uploader.js +6 -20
- package/dist/runtime/app/composables/cms-permissions.d.ts +18 -0
- package/dist/runtime/app/composables/cms-permissions.js +54 -0
- package/dist/runtime/app/composables/cms-presets.d.ts +11 -0
- package/dist/runtime/app/composables/cms-presets.js +40 -0
- package/dist/runtime/app/composables/cms-preview-mode.d.ts +4 -0
- package/dist/runtime/app/composables/cms-preview-mode.js +8 -0
- package/dist/runtime/app/composables/cms-query.d.ts +3 -0
- package/dist/runtime/app/composables/cms-query.js +45 -20
- package/dist/runtime/app/composables/cms-record-list.d.ts +31 -0
- package/dist/runtime/app/composables/cms-record-list.js +75 -0
- package/dist/runtime/app/composables/cms-route.d.ts +6 -0
- package/dist/runtime/app/composables/cms-route.js +36 -0
- package/dist/runtime/app/composables/cms-runtime.d.ts +1 -0
- package/dist/runtime/app/composables/cms-save-handoff.d.ts +4 -0
- package/dist/runtime/app/composables/cms-save-handoff.js +19 -0
- package/dist/runtime/app/composables/cms-seo.d.ts +12 -0
- package/dist/runtime/app/composables/cms-seo.js +69 -0
- package/dist/runtime/app/composables/cms-settings-form.d.ts +13 -0
- package/dist/runtime/app/composables/cms-settings-form.js +29 -0
- package/dist/runtime/app/composables/cms-settings-sections.d.ts +26 -0
- package/dist/runtime/app/composables/cms-settings-sections.js +181 -0
- package/dist/runtime/app/composables/cms-settings-stores.d.ts +52 -0
- package/dist/runtime/app/composables/cms-settings-stores.js +156 -0
- package/dist/runtime/app/composables/cms-settings.d.ts +3 -3
- package/dist/runtime/app/composables/cms-settings.js +14 -8
- package/dist/runtime/app/composables/cms-site-disabled.d.ts +7 -0
- package/dist/runtime/app/composables/cms-site-disabled.js +8 -0
- package/dist/runtime/app/composables/cms-site.d.ts +7 -0
- package/dist/runtime/app/composables/cms-site.js +22 -0
- package/dist/runtime/app/composables/cms-toast.d.ts +2 -8
- package/dist/runtime/app/composables/cms-toast.js +3 -9
- package/dist/runtime/app/composables/cms-translation-actions.d.ts +15 -0
- package/dist/runtime/app/composables/cms-translation-actions.js +108 -0
- package/dist/runtime/app/css-url.d.ts +4 -0
- package/dist/runtime/app/image/CmsImage.d.vue.ts +89 -0
- package/dist/runtime/app/image/CmsImage.vue +91 -0
- package/dist/runtime/app/image/CmsImage.vue.d.ts +89 -0
- package/dist/runtime/app/layouts/cms-admin.d.vue.ts +2 -2
- package/dist/runtime/app/layouts/cms-admin.vue +98 -76
- package/dist/runtime/app/layouts/cms-admin.vue.d.ts +2 -2
- package/dist/runtime/app/layouts/cms-editor.vue +7 -2
- package/dist/runtime/app/links/CmsLink.d.vue.ts +18 -0
- package/dist/runtime/app/links/CmsLink.vue +18 -0
- package/dist/runtime/app/links/CmsLink.vue.d.ts +18 -0
- package/dist/runtime/app/middleware/cms-auth.js +13 -1
- package/dist/runtime/app/pages/admin-collection.vue +473 -297
- package/dist/runtime/app/pages/admin-content.vue +190 -53
- package/dist/runtime/app/pages/admin-entry.vue +79 -75
- package/dist/runtime/app/pages/admin-index.vue +18 -5
- package/dist/runtime/app/pages/admin-login.vue +1 -1
- package/dist/runtime/app/pages/admin-logout.vue +1 -1
- package/dist/runtime/app/pages/admin-media.vue +3 -3
- package/dist/runtime/app/pages/admin-preview.vue +112 -24
- package/dist/runtime/app/plugins/cms-field.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-field.js +8 -0
- package/dist/runtime/app/plugins/cms-preview-banner.client.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-preview-banner.client.js +19 -0
- package/dist/runtime/app/plugins/cms-preview.d.ts +2 -0
- package/dist/runtime/app/plugins/cms-preview.js +27 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.d.vue.ts +7 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.vue +63 -0
- package/dist/runtime/app/preview/CmsPreviewBanner.vue.d.ts +7 -0
- package/dist/runtime/app/preview/PreviewOverlay.d.vue.ts +17 -3
- package/dist/runtime/app/preview/PreviewOverlay.vue +629 -166
- package/dist/runtime/app/preview/PreviewOverlay.vue.d.ts +17 -3
- package/dist/runtime/app/preview/field-marker.d.ts +12 -0
- package/dist/runtime/app/preview/field-marker.js +20 -0
- package/dist/runtime/app/preview/inline-text.d.ts +15 -0
- package/dist/runtime/app/preview/inline-text.js +158 -0
- package/dist/runtime/app/utils/block-editor.d.ts +22 -0
- package/dist/runtime/app/utils/block-editor.js +12 -0
- package/dist/runtime/app/utils/keyboard.d.ts +6 -0
- package/dist/runtime/app/utils/keyboard.js +52 -0
- package/dist/runtime/app/utils/redirects.d.ts +6 -0
- package/dist/runtime/app/utils/redirects.js +7 -0
- package/dist/runtime/app/utils/ui.d.ts +8 -0
- package/dist/runtime/app/utils/ui.js +15 -1
- package/dist/runtime/app/utils/users.d.ts +15 -0
- package/dist/runtime/app/utils/users.js +14 -0
- package/dist/runtime/assets/cms.css +1 -1
- package/dist/runtime/generate.js +16 -2
- package/dist/runtime/server/api/collection-export.get.js +3 -2
- package/dist/runtime/server/api/collection-import.post.js +39 -11
- package/dist/runtime/server/api/collection.get.js +29 -10
- package/dist/runtime/server/api/collection.post.js +28 -11
- package/dist/runtime/server/api/collection.put.js +35 -13
- package/dist/runtime/server/api/item.delete.js +19 -7
- package/dist/runtime/server/api/item.get.js +3 -2
- package/dist/runtime/server/api/item.put.js +52 -18
- package/dist/runtime/server/api/link-usage.post.d.ts +5 -0
- package/dist/runtime/server/api/link-usage.post.js +21 -0
- package/dist/runtime/server/api/media-delete.post.js +4 -2
- package/dist/runtime/server/api/media-download.get.js +2 -2
- package/dist/runtime/server/api/media-folder.delete.js +8 -2
- package/dist/runtime/server/api/media-folder.patch.js +10 -2
- package/dist/runtime/server/api/media-folder.post.js +4 -2
- package/dist/runtime/server/api/media-move.post.js +7 -4
- package/dist/runtime/server/api/media-presign.post.js +2 -2
- package/dist/runtime/server/api/media-upload.put.js +2 -2
- package/dist/runtime/server/api/media-usage.post.d.ts +2 -4
- package/dist/runtime/server/api/media-usage.post.js +13 -9
- package/dist/runtime/server/api/media.delete.js +4 -2
- package/dist/runtime/server/api/media.get.js +22 -7
- package/dist/runtime/server/api/media.post.js +4 -2
- package/dist/runtime/server/api/media.put.js +33 -16
- package/dist/runtime/server/api/preset.delete.d.ts +4 -0
- package/dist/runtime/server/api/preset.delete.js +9 -0
- package/dist/runtime/server/api/preset.put.d.ts +3 -0
- package/dist/runtime/server/api/preset.put.js +23 -0
- package/dist/runtime/server/api/presets-field.get.d.ts +3 -0
- package/dist/runtime/server/api/presets-field.get.js +13 -0
- package/dist/runtime/server/api/presets-field.post.d.ts +3 -0
- package/dist/runtime/server/api/presets-field.post.js +36 -0
- package/dist/runtime/server/api/presets.get.d.ts +3 -0
- package/dist/runtime/server/api/presets.get.js +7 -0
- package/dist/runtime/server/api/preview-link.delete.d.ts +4 -0
- package/dist/runtime/server/api/preview-link.delete.js +15 -0
- package/dist/runtime/server/api/preview-links.get.d.ts +3 -0
- package/dist/runtime/server/api/preview-links.get.js +10 -0
- package/dist/runtime/server/api/preview-links.post.d.ts +3 -0
- package/dist/runtime/server/api/preview-links.post.js +17 -0
- package/dist/runtime/server/api/preview.get.d.ts +3 -0
- package/dist/runtime/server/api/preview.get.js +7 -0
- package/dist/runtime/server/api/redirect.delete.d.ts +4 -0
- package/dist/runtime/server/api/redirect.delete.js +10 -0
- package/dist/runtime/server/api/redirect.put.d.ts +3 -0
- package/dist/runtime/server/api/redirect.put.js +8 -0
- package/dist/runtime/server/api/redirects-import.post.d.ts +3 -0
- package/dist/runtime/server/api/redirects-import.post.js +13 -0
- package/dist/runtime/server/api/redirects.get.d.ts +3 -0
- package/dist/runtime/server/api/redirects.get.js +7 -0
- package/dist/runtime/server/api/redirects.post.d.ts +3 -0
- package/dist/runtime/server/api/redirects.post.js +7 -0
- package/dist/runtime/server/api/search.get.js +8 -3
- package/dist/runtime/server/api/settings.delete.js +2 -2
- package/dist/runtime/server/api/settings.get.js +4 -2
- package/dist/runtime/server/api/settings.put.js +2 -2
- package/dist/runtime/server/api/site.get.d.ts +3 -0
- package/dist/runtime/server/api/site.get.js +7 -0
- package/dist/runtime/server/api/site.put.d.ts +3 -0
- package/dist/runtime/server/api/site.put.js +16 -0
- package/dist/runtime/server/api/tags.get.js +3 -2
- package/dist/runtime/server/api/user.delete.js +8 -2
- package/dist/runtime/server/api/user.put.js +14 -4
- package/dist/runtime/server/api/users.get.js +2 -2
- package/dist/runtime/server/api/users.post.js +8 -4
- package/dist/runtime/server/middleware/hidden-site.d.ts +2 -0
- package/dist/runtime/server/middleware/hidden-site.js +8 -0
- package/dist/runtime/server/middleware/preview-links.d.ts +2 -0
- package/dist/runtime/server/middleware/preview-links.js +6 -0
- package/dist/runtime/server/middleware/redirects.d.ts +2 -0
- package/dist/runtime/server/middleware/redirects.js +18 -0
- package/dist/runtime/server/plugins/session-validate.js +4 -1
- package/dist/runtime/server/plugins/webhooks.d.ts +3 -0
- package/dist/runtime/server/plugins/webhooks.js +27 -0
- package/dist/runtime/server/routes/graphql.js +5 -3
- package/dist/runtime/server/routes/robots.d.ts +2 -0
- package/dist/runtime/server/routes/robots.js +16 -0
- package/dist/runtime/server/routes/sitemap.d.ts +2 -0
- package/dist/runtime/server/routes/sitemap.js +67 -0
- package/dist/runtime/server/utils/cached-value.d.ts +5 -0
- package/dist/runtime/server/utils/cached-value.js +24 -0
- package/dist/runtime/server/utils/content-routes.d.ts +5 -0
- package/dist/runtime/server/utils/content-routes.js +29 -0
- package/dist/runtime/server/utils/field-rules.d.ts +19 -0
- package/dist/runtime/server/utils/field-rules.js +72 -0
- package/dist/runtime/server/utils/graphql.d.ts +3 -1
- package/dist/runtime/server/utils/graphql.js +145 -29
- package/dist/runtime/server/utils/hooks.d.ts +14 -0
- package/dist/runtime/server/utils/hooks.js +71 -0
- package/dist/runtime/server/utils/import.d.ts +7 -2
- package/dist/runtime/server/utils/import.js +108 -14
- package/dist/runtime/server/utils/link-usage.d.ts +4 -0
- package/dist/runtime/server/utils/link-usage.js +28 -0
- package/dist/runtime/server/utils/media-references.d.ts +6 -1
- package/dist/runtime/server/utils/media-references.js +49 -20
- package/dist/runtime/server/utils/media-usage.d.ts +2 -0
- package/dist/runtime/server/utils/media-usage.js +5 -3
- package/dist/runtime/server/utils/page-rows.d.ts +2 -0
- package/dist/runtime/server/utils/page-rows.js +42 -29
- package/dist/runtime/server/utils/permissions.d.ts +14 -0
- package/dist/runtime/server/utils/permissions.js +43 -0
- package/dist/runtime/server/utils/presets.d.ts +18 -0
- package/dist/runtime/server/utils/presets.js +68 -0
- package/dist/runtime/server/utils/preview-links.d.ts +207 -0
- package/dist/runtime/server/utils/preview-links.js +161 -0
- package/dist/runtime/server/utils/redirects.d.ts +31 -0
- package/dist/runtime/server/utils/redirects.js +240 -0
- package/dist/runtime/server/utils/registry.js +4 -1
- package/dist/runtime/server/utils/relations.d.ts +8 -0
- package/dist/runtime/server/utils/relations.js +25 -6
- package/dist/runtime/server/utils/require-admin.d.ts +0 -1
- package/dist/runtime/server/utils/require-admin.js +4 -8
- package/dist/runtime/server/utils/search.d.ts +1 -0
- package/dist/runtime/server/utils/search.js +44 -19
- package/dist/runtime/server/utils/single-row.d.ts +3 -0
- package/dist/runtime/server/utils/single-row.js +4 -0
- package/dist/runtime/server/utils/site.d.ts +23 -0
- package/dist/runtime/server/utils/site.js +79 -0
- package/dist/runtime/server/utils/sitemap.d.ts +12 -0
- package/dist/runtime/server/utils/sitemap.js +109 -0
- package/dist/runtime/server/utils/user-management.d.ts +4 -0
- package/dist/runtime/server/utils/user-management.js +20 -0
- package/dist/runtime/server/utils/users.d.ts +1 -1
- package/dist/runtime/server/utils/users.js +1 -1
- package/dist/runtime/server/utils/visibility.d.ts +1 -0
- package/dist/runtime/server/utils/visibility.js +6 -1
- package/dist/runtime/server/utils/webhooks.d.ts +24 -0
- package/dist/runtime/server/utils/webhooks.js +90 -0
- package/dist/runtime/shared/block-paths.d.ts +66 -0
- package/dist/runtime/shared/block-paths.js +310 -0
- package/dist/runtime/shared/block-picker.d.ts +18 -0
- package/dist/runtime/shared/block-picker.js +31 -0
- package/dist/runtime/shared/block-signature.d.ts +4 -0
- package/dist/runtime/shared/block-signature.js +46 -0
- package/dist/runtime/shared/clipboard.d.ts +31 -0
- package/dist/runtime/shared/clipboard.js +206 -0
- package/dist/runtime/shared/conditions.d.ts +36 -0
- package/dist/runtime/shared/conditions.js +100 -0
- package/dist/runtime/shared/content-routes.d.ts +42 -0
- package/dist/runtime/shared/content-routes.js +237 -0
- package/dist/runtime/shared/duplicate.js +2 -1
- package/dist/runtime/shared/editor-layout.d.ts +18 -0
- package/dist/runtime/shared/editor-layout.js +9 -0
- package/dist/runtime/shared/field-options.d.ts +21 -0
- package/dist/runtime/shared/field-options.js +90 -0
- package/dist/runtime/shared/graphql-sdl.d.ts +1 -0
- package/dist/runtime/shared/graphql-sdl.js +50 -26
- package/dist/runtime/shared/history.d.ts +27 -0
- package/dist/runtime/shared/history.js +123 -0
- package/dist/runtime/shared/hooks.d.ts +45 -0
- package/dist/runtime/shared/hooks.js +28 -0
- package/dist/runtime/shared/index.d.ts +90 -21
- package/dist/runtime/shared/index.js +121 -37
- package/dist/runtime/shared/inline-text.d.ts +38 -0
- package/dist/runtime/shared/inline-text.js +85 -0
- package/dist/runtime/shared/layout.d.ts +2 -1
- package/dist/runtime/shared/layout.js +3 -0
- package/dist/runtime/shared/links.d.ts +48 -0
- package/dist/runtime/shared/links.js +155 -0
- package/dist/runtime/shared/list-filters.d.ts +2 -0
- package/dist/runtime/shared/list-filters.js +2 -0
- package/dist/runtime/shared/media-focal.d.ts +30 -0
- package/dist/runtime/shared/media-focal.js +52 -0
- package/dist/runtime/shared/migrations-dir.d.ts +14 -0
- package/dist/runtime/shared/migrations-dir.js +48 -2
- package/dist/runtime/shared/presets.d.ts +67 -0
- package/dist/runtime/shared/presets.js +127 -0
- package/dist/runtime/shared/preview-links.d.ts +64 -0
- package/dist/runtime/shared/preview-links.js +54 -0
- package/dist/runtime/shared/preview.d.ts +124 -21
- package/dist/runtime/shared/preview.js +419 -81
- package/dist/runtime/shared/redirects.d.ts +75 -0
- package/dist/runtime/shared/redirects.js +230 -0
- package/dist/runtime/shared/roles.d.ts +57 -0
- package/dist/runtime/shared/roles.js +293 -0
- package/dist/runtime/shared/save-state.d.ts +8 -0
- package/dist/runtime/shared/save-state.js +15 -0
- package/dist/runtime/shared/search.d.ts +16 -1
- package/dist/runtime/shared/search.js +41 -7
- package/dist/runtime/shared/seo.d.ts +167 -0
- package/dist/runtime/shared/seo.js +335 -0
- package/dist/runtime/shared/transfer.js +2 -1
- package/dist/runtime/shared/translations.d.ts +29 -0
- package/dist/runtime/shared/translations.js +123 -0
- package/dist/runtime/shared/users.d.ts +1 -1
- package/dist/runtime/shared/validation.d.ts +23 -1
- package/dist/runtime/shared/validation.js +214 -64
- package/dist/runtime/webhooks.d.ts +33 -0
- package/dist/runtime/webhooks.js +57 -0
- package/dist/types.d.mts +5 -1
- package/package.json +6 -2
- package/dist/runtime/app/components/cms/BlockOutline.vue +0 -88
- package/dist/runtime/app/components/cms/BlockPalette.vue +0 -31
- package/dist/runtime/app/components/cms/SettingsModal.d.vue.ts +0 -12
- package/dist/runtime/app/components/cms/SettingsModal.vue +0 -126
- package/dist/runtime/app/components/cms/SettingsModal.vue.d.ts +0 -12
- package/dist/runtime/app/composables/cms-field-focus.d.ts +0 -4
- package/dist/runtime/app/composables/cms-field-focus.js +0 -20
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { BlockConfig, FieldConfig } from './index.js';
|
|
2
|
+
export declare const MAX_BLOCKS_DEPTH = 3;
|
|
3
|
+
export type CmsBlockPathSegment = string | number;
|
|
4
|
+
export type CmsBlockPath = readonly CmsBlockPathSegment[];
|
|
5
|
+
type Values = Record<string, unknown>;
|
|
6
|
+
type Item = Record<string, unknown>;
|
|
7
|
+
export declare function isBlockItemPath(path: CmsBlockPath): boolean;
|
|
8
|
+
export declare function isBlockListPath(path: CmsBlockPath): boolean;
|
|
9
|
+
export declare function formatBlockPath(path: CmsBlockPath): string;
|
|
10
|
+
export declare function blockReferenceLabel(path: CmsBlockPath, fieldKey?: string): string;
|
|
11
|
+
export declare function parseBlockPath(text: unknown): CmsBlockPath | null;
|
|
12
|
+
export declare function blockPathDepth(path: CmsBlockPath): number;
|
|
13
|
+
export declare function blockListPath(itemPath: CmsBlockPath): CmsBlockPath;
|
|
14
|
+
export declare function blockPathIndex(itemPath: CmsBlockPath): number;
|
|
15
|
+
export declare function parentBlockPath(path: CmsBlockPath): CmsBlockPath | null;
|
|
16
|
+
export declare function childBlockPath(itemPath: CmsBlockPath, fieldKey: string, index?: number): CmsBlockPath;
|
|
17
|
+
export declare function blockPathStartsWith(path: CmsBlockPath, prefix: CmsBlockPath): boolean;
|
|
18
|
+
export declare function sameBlockPath(a: CmsBlockPath | null, b: CmsBlockPath | null): boolean;
|
|
19
|
+
export declare function blocksFieldAt(fields: Record<string, FieldConfig>, values: Values | null | undefined, listPath: CmsBlockPath): FieldConfig | null;
|
|
20
|
+
export declare function blockSchemaPath(fields: Record<string, FieldConfig>, values: Values | null | undefined, path: CmsBlockPath): string[] | null;
|
|
21
|
+
export declare function blockListAt(values: Values | null | undefined, listPath: CmsBlockPath): Item[] | null;
|
|
22
|
+
export declare function blockAt(values: Values | null | undefined, itemPath: CmsBlockPath): Item | null;
|
|
23
|
+
export interface CmsBlockLocation {
|
|
24
|
+
path: CmsBlockPath;
|
|
25
|
+
index: number;
|
|
26
|
+
depth: number;
|
|
27
|
+
item: Item;
|
|
28
|
+
field: FieldConfig;
|
|
29
|
+
block: BlockConfig | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare function resolveBlockPath(fields: Record<string, FieldConfig>, values: Values | null | undefined, itemPath: CmsBlockPath): CmsBlockLocation | null;
|
|
32
|
+
export declare function updateBlockList(values: Values, listPath: CmsBlockPath, update: (list: Item[]) => Item[] | null): Values;
|
|
33
|
+
export declare function updateBlockAt(values: Values, itemPath: CmsBlockPath, update: (item: Item) => Item): Values;
|
|
34
|
+
export declare function insertBlocks(values: Values, listPath: CmsBlockPath, index: number, items: readonly Item[]): Values;
|
|
35
|
+
export declare function removeBlock(values: Values, itemPath: CmsBlockPath): Values;
|
|
36
|
+
export declare function pathAfterRemove(path: CmsBlockPath, removed: CmsBlockPath): CmsBlockPath | null;
|
|
37
|
+
export declare function pathAfterInsert(path: CmsBlockPath, listPath: CmsBlockPath, index: number, count?: number): CmsBlockPath;
|
|
38
|
+
export declare function movedBlockPath(from: CmsBlockPath, toList: CmsBlockPath, toIndex: number): CmsBlockPath | null;
|
|
39
|
+
export declare function pathAfterMove(path: CmsBlockPath, from: CmsBlockPath, toList: CmsBlockPath, toIndex: number): CmsBlockPath;
|
|
40
|
+
export interface CmsInsertionPoint {
|
|
41
|
+
list: CmsBlockPath;
|
|
42
|
+
index: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function remapInsertionPoint(point: CmsInsertionPoint, remap: (path: CmsBlockPath) => CmsBlockPath | null): CmsInsertionPoint | null;
|
|
45
|
+
export declare function moveBlock(values: Values, from: CmsBlockPath, toList: CmsBlockPath, toIndex: number): Values;
|
|
46
|
+
export interface CmsBlockVisit {
|
|
47
|
+
item: Item;
|
|
48
|
+
block: BlockConfig;
|
|
49
|
+
field: FieldConfig;
|
|
50
|
+
path: CmsBlockPath;
|
|
51
|
+
schemaPath: readonly string[];
|
|
52
|
+
index: number;
|
|
53
|
+
depth: number;
|
|
54
|
+
}
|
|
55
|
+
export declare function walkBlocks(fields: Record<string, FieldConfig>, values: Values | null | undefined, visit: (visit: CmsBlockVisit) => boolean | void, prefix?: CmsBlockPath, schemaPrefix?: readonly string[]): void;
|
|
56
|
+
export declare function blocksFieldAtSchemaPath(fields: Record<string, FieldConfig>, schemaPath: string | readonly string[]): FieldConfig | null;
|
|
57
|
+
export interface CmsBlocksFieldVisit {
|
|
58
|
+
field: FieldConfig;
|
|
59
|
+
schemaPath: readonly string[];
|
|
60
|
+
depth: number;
|
|
61
|
+
}
|
|
62
|
+
export declare function blocksFieldPaths(fields: Record<string, FieldConfig>, prefix?: readonly string[]): CmsBlocksFieldVisit[];
|
|
63
|
+
export declare function mapBlocks(field: FieldConfig, value: unknown, map: (item: Item, block: BlockConfig | undefined, field: FieldConfig) => Item | null): unknown;
|
|
64
|
+
export declare function hasNestedBlocks(field: FieldConfig): boolean;
|
|
65
|
+
export declare function blockFieldsDeep(field: FieldConfig): FieldConfig[];
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
export const MAX_BLOCKS_DEPTH = 3;
|
|
2
|
+
const FIELD_SEGMENT = /^[a-z_]\w*$/i;
|
|
3
|
+
const INDEX_SEGMENT = /^\d+$/;
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
|
+
}
|
|
7
|
+
function isFieldSegment(segment) {
|
|
8
|
+
return typeof segment === "string" && FIELD_SEGMENT.test(segment);
|
|
9
|
+
}
|
|
10
|
+
function isIndexSegment(segment) {
|
|
11
|
+
return typeof segment === "number" && Number.isInteger(segment) && segment >= 0;
|
|
12
|
+
}
|
|
13
|
+
function isAlternating(path) {
|
|
14
|
+
return path.every(
|
|
15
|
+
(segment, position) => position % 2 === 0 ? isFieldSegment(segment) : isIndexSegment(segment)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
export function isBlockItemPath(path) {
|
|
19
|
+
return path.length >= 2 && path.length % 2 === 0 && isAlternating(path);
|
|
20
|
+
}
|
|
21
|
+
export function isBlockListPath(path) {
|
|
22
|
+
return path.length >= 1 && path.length % 2 === 1 && isAlternating(path);
|
|
23
|
+
}
|
|
24
|
+
export function formatBlockPath(path) {
|
|
25
|
+
return path.join(".");
|
|
26
|
+
}
|
|
27
|
+
export function blockReferenceLabel(path, fieldKey) {
|
|
28
|
+
const base = path.map((segment) => typeof segment === "number" ? `[${segment}]` : `.${segment}`).join("").replace(/^\./, "");
|
|
29
|
+
return fieldKey ? `${base}.${fieldKey}` : base;
|
|
30
|
+
}
|
|
31
|
+
export function parseBlockPath(text) {
|
|
32
|
+
if (typeof text !== "string" || !text) return null;
|
|
33
|
+
const path = text.split(".").map((segment) => INDEX_SEGMENT.test(segment) ? Number(segment) : segment);
|
|
34
|
+
return isAlternating(path) ? path : null;
|
|
35
|
+
}
|
|
36
|
+
export function blockPathDepth(path) {
|
|
37
|
+
return Math.ceil(path.length / 2);
|
|
38
|
+
}
|
|
39
|
+
export function blockListPath(itemPath) {
|
|
40
|
+
return itemPath.slice(0, -1);
|
|
41
|
+
}
|
|
42
|
+
export function blockPathIndex(itemPath) {
|
|
43
|
+
const last = itemPath.at(-1);
|
|
44
|
+
return isIndexSegment(last) ? last : -1;
|
|
45
|
+
}
|
|
46
|
+
export function parentBlockPath(path) {
|
|
47
|
+
const list = path.length % 2 === 0 ? path.slice(0, -1) : path;
|
|
48
|
+
return list.length >= 3 ? list.slice(0, -1) : null;
|
|
49
|
+
}
|
|
50
|
+
export function childBlockPath(itemPath, fieldKey, index) {
|
|
51
|
+
return index === void 0 ? [...itemPath, fieldKey] : [...itemPath, fieldKey, index];
|
|
52
|
+
}
|
|
53
|
+
export function blockPathStartsWith(path, prefix) {
|
|
54
|
+
return prefix.length <= path.length && prefix.every((segment, i) => path[i] === segment);
|
|
55
|
+
}
|
|
56
|
+
export function sameBlockPath(a, b) {
|
|
57
|
+
if (!a || !b) return a === b;
|
|
58
|
+
return a.length === b.length && blockPathStartsWith(a, b);
|
|
59
|
+
}
|
|
60
|
+
function locateList(fields, values, listPath) {
|
|
61
|
+
if (!isBlockListPath(listPath)) return null;
|
|
62
|
+
const schemaPath = [];
|
|
63
|
+
let scope = fields;
|
|
64
|
+
let current = values;
|
|
65
|
+
for (let position = 0; position < listPath.length; position += 2) {
|
|
66
|
+
const key = listPath[position];
|
|
67
|
+
const field = Object.hasOwn(scope, key) ? scope[key] : void 0;
|
|
68
|
+
if (field?.type !== "blocks") return null;
|
|
69
|
+
schemaPath.push(key);
|
|
70
|
+
if (position === listPath.length - 1) return { field, schemaPath };
|
|
71
|
+
const list = isRecord(current) ? current[key] : void 0;
|
|
72
|
+
const item = Array.isArray(list) ? list[listPath[position + 1]] : void 0;
|
|
73
|
+
const block = isRecord(item) ? field.blocks?.[String(item.type)] : void 0;
|
|
74
|
+
if (!block || !isRecord(item)) return null;
|
|
75
|
+
schemaPath.push(String(item.type));
|
|
76
|
+
scope = block.fields;
|
|
77
|
+
current = item;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
export function blocksFieldAt(fields, values, listPath) {
|
|
82
|
+
return locateList(fields, values, listPath)?.field ?? null;
|
|
83
|
+
}
|
|
84
|
+
export function blockSchemaPath(fields, values, path) {
|
|
85
|
+
return locateList(fields, values, path.length % 2 === 0 ? path.slice(0, -1) : path)?.schemaPath ?? null;
|
|
86
|
+
}
|
|
87
|
+
export function blockListAt(values, listPath) {
|
|
88
|
+
if (!isBlockListPath(listPath)) return null;
|
|
89
|
+
let current = values;
|
|
90
|
+
for (let position = 0; position < listPath.length; position++) {
|
|
91
|
+
const segment = listPath[position];
|
|
92
|
+
if (position % 2 === 0) {
|
|
93
|
+
if (!isRecord(current)) return null;
|
|
94
|
+
current = current[segment];
|
|
95
|
+
} else {
|
|
96
|
+
current = Array.isArray(current) ? current[segment] : void 0;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return Array.isArray(current) ? current : null;
|
|
100
|
+
}
|
|
101
|
+
export function blockAt(values, itemPath) {
|
|
102
|
+
if (!isBlockItemPath(itemPath)) return null;
|
|
103
|
+
const item = blockListAt(values, blockListPath(itemPath))?.[blockPathIndex(itemPath)];
|
|
104
|
+
return isRecord(item) ? item : null;
|
|
105
|
+
}
|
|
106
|
+
export function resolveBlockPath(fields, values, itemPath) {
|
|
107
|
+
const item = blockAt(values, itemPath);
|
|
108
|
+
const field = item ? blocksFieldAt(fields, values, blockListPath(itemPath)) : null;
|
|
109
|
+
if (!item || !field) return null;
|
|
110
|
+
return {
|
|
111
|
+
path: itemPath,
|
|
112
|
+
index: blockPathIndex(itemPath),
|
|
113
|
+
depth: blockPathDepth(itemPath),
|
|
114
|
+
item,
|
|
115
|
+
field,
|
|
116
|
+
block: field.blocks?.[String(item.type)]
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function updateIn(current, path, update) {
|
|
120
|
+
if (!path.length) {
|
|
121
|
+
const next2 = update(Array.isArray(current) ? current : []);
|
|
122
|
+
return next2 && next2.length ? next2 : null;
|
|
123
|
+
}
|
|
124
|
+
const [segment, ...rest] = path;
|
|
125
|
+
if (typeof segment === "string") {
|
|
126
|
+
if (!isRecord(current)) return current;
|
|
127
|
+
const next2 = updateIn(current[segment], rest, update);
|
|
128
|
+
return next2 === current[segment] ? current : { ...current, [segment]: next2 };
|
|
129
|
+
}
|
|
130
|
+
if (!Array.isArray(current) || !isRecord(current[segment])) return current;
|
|
131
|
+
const next = updateIn(current[segment], rest, update);
|
|
132
|
+
if (next === current[segment]) return current;
|
|
133
|
+
const copy = [...current];
|
|
134
|
+
copy[segment] = next;
|
|
135
|
+
return copy;
|
|
136
|
+
}
|
|
137
|
+
export function updateBlockList(values, listPath, update) {
|
|
138
|
+
if (!isBlockListPath(listPath)) return values;
|
|
139
|
+
return updateIn(values, listPath, update);
|
|
140
|
+
}
|
|
141
|
+
export function updateBlockAt(values, itemPath, update) {
|
|
142
|
+
if (!blockAt(values, itemPath)) return values;
|
|
143
|
+
const index = blockPathIndex(itemPath);
|
|
144
|
+
return updateBlockList(values, blockListPath(itemPath), (list) => {
|
|
145
|
+
const next = [...list];
|
|
146
|
+
next[index] = update(list[index]);
|
|
147
|
+
return next;
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
export function insertBlocks(values, listPath, index, items) {
|
|
151
|
+
if (!items.length) return values;
|
|
152
|
+
if (listPath.length > 1 && !blockAt(values, listPath.slice(0, -1))) return values;
|
|
153
|
+
return updateBlockList(values, listPath, (list) => {
|
|
154
|
+
const next = [...list];
|
|
155
|
+
next.splice(Math.min(Math.max(index, 0), list.length), 0, ...items);
|
|
156
|
+
return next;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
export function removeBlock(values, itemPath) {
|
|
160
|
+
if (!blockAt(values, itemPath)) return values;
|
|
161
|
+
const index = blockPathIndex(itemPath);
|
|
162
|
+
return updateBlockList(
|
|
163
|
+
values,
|
|
164
|
+
blockListPath(itemPath),
|
|
165
|
+
(list) => list.filter((_, position) => position !== index)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
export function pathAfterRemove(path, removed) {
|
|
169
|
+
const list = blockListPath(removed);
|
|
170
|
+
const index = blockPathIndex(removed);
|
|
171
|
+
if (path.length <= list.length || !blockPathStartsWith(path, list)) return path;
|
|
172
|
+
const position = path[list.length];
|
|
173
|
+
if (position === index) return null;
|
|
174
|
+
if (position < index) return path;
|
|
175
|
+
const next = [...path];
|
|
176
|
+
next[list.length] = position - 1;
|
|
177
|
+
return next;
|
|
178
|
+
}
|
|
179
|
+
export function pathAfterInsert(path, listPath, index, count = 1) {
|
|
180
|
+
if (path.length <= listPath.length || !blockPathStartsWith(path, listPath)) return path;
|
|
181
|
+
const position = path[listPath.length];
|
|
182
|
+
if (position < index) return path;
|
|
183
|
+
const next = [...path];
|
|
184
|
+
next[listPath.length] = position + count;
|
|
185
|
+
return next;
|
|
186
|
+
}
|
|
187
|
+
export function movedBlockPath(from, toList, toIndex) {
|
|
188
|
+
if (!isBlockItemPath(from) || !isBlockListPath(toList)) return null;
|
|
189
|
+
if (blockPathStartsWith(toList, from)) return null;
|
|
190
|
+
const fromList = blockListPath(from);
|
|
191
|
+
const fromIndex = blockPathIndex(from);
|
|
192
|
+
const target = pathAfterRemove(toList, from);
|
|
193
|
+
if (!target) return null;
|
|
194
|
+
const sameList = sameBlockPath(fromList, toList);
|
|
195
|
+
const index = Math.max(sameList && toIndex > fromIndex ? toIndex - 1 : toIndex, 0);
|
|
196
|
+
if (sameList && index === fromIndex) return null;
|
|
197
|
+
return [...target, index];
|
|
198
|
+
}
|
|
199
|
+
export function pathAfterMove(path, from, toList, toIndex) {
|
|
200
|
+
const moved = movedBlockPath(from, toList, toIndex);
|
|
201
|
+
if (!moved) return path;
|
|
202
|
+
if (blockPathStartsWith(path, from)) return [...moved, ...path.slice(from.length)];
|
|
203
|
+
const removed = pathAfterRemove(path, from) ?? path;
|
|
204
|
+
return pathAfterInsert(removed, blockListPath(moved), blockPathIndex(moved));
|
|
205
|
+
}
|
|
206
|
+
export function remapInsertionPoint(point, remap) {
|
|
207
|
+
const slot = remap([...point.list, point.index]);
|
|
208
|
+
if (slot) return { list: blockListPath(slot), index: blockPathIndex(slot) };
|
|
209
|
+
if (point.list.length <= 1) return point;
|
|
210
|
+
const owner = remap(point.list.slice(0, -1));
|
|
211
|
+
return owner ? { list: [...owner, point.list.at(-1)], index: point.index } : null;
|
|
212
|
+
}
|
|
213
|
+
export function moveBlock(values, from, toList, toIndex) {
|
|
214
|
+
const item = blockAt(values, from);
|
|
215
|
+
const moved = item ? movedBlockPath(from, toList, toIndex) : null;
|
|
216
|
+
if (!item || !moved) return values;
|
|
217
|
+
const target = blockListPath(moved);
|
|
218
|
+
const removed = removeBlock(values, from);
|
|
219
|
+
if (target.length > 1 && !blockAt(removed, target.slice(0, -1))) return values;
|
|
220
|
+
return insertBlocks(removed, target, blockPathIndex(moved), [item]);
|
|
221
|
+
}
|
|
222
|
+
export function walkBlocks(fields, values, visit, prefix = [], schemaPrefix = []) {
|
|
223
|
+
if (!isRecord(values)) return;
|
|
224
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
225
|
+
if (field?.type !== "blocks") continue;
|
|
226
|
+
const list = values[key];
|
|
227
|
+
if (!Array.isArray(list)) continue;
|
|
228
|
+
const schemaPath = [...schemaPrefix, key];
|
|
229
|
+
list.forEach((item, index) => {
|
|
230
|
+
if (!isRecord(item)) return;
|
|
231
|
+
const block = field.blocks?.[String(item.type)];
|
|
232
|
+
if (!block) return;
|
|
233
|
+
const path = [...prefix, key, index];
|
|
234
|
+
const descend = visit({
|
|
235
|
+
item,
|
|
236
|
+
block,
|
|
237
|
+
field,
|
|
238
|
+
path,
|
|
239
|
+
schemaPath,
|
|
240
|
+
index,
|
|
241
|
+
depth: blockPathDepth(path)
|
|
242
|
+
});
|
|
243
|
+
if (descend === false) return;
|
|
244
|
+
walkBlocks(block.fields, item, visit, path, [...schemaPath, String(item.type)]);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
export function blocksFieldAtSchemaPath(fields, schemaPath) {
|
|
249
|
+
const segments = typeof schemaPath === "string" ? schemaPath.split(".") : schemaPath;
|
|
250
|
+
if (!segments.length || segments.length % 2 === 0) return null;
|
|
251
|
+
let scope = fields;
|
|
252
|
+
for (let position = 0; position < segments.length; position += 2) {
|
|
253
|
+
const key = segments[position];
|
|
254
|
+
const field = Object.hasOwn(scope, key) ? scope[key] : void 0;
|
|
255
|
+
if (field?.type !== "blocks") return null;
|
|
256
|
+
if (position === segments.length - 1) return field;
|
|
257
|
+
const type = segments[position + 1];
|
|
258
|
+
const block = field.blocks && Object.hasOwn(field.blocks, type) ? field.blocks[type] : void 0;
|
|
259
|
+
if (!block) return null;
|
|
260
|
+
scope = block.fields;
|
|
261
|
+
}
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
export function blocksFieldPaths(fields, prefix = []) {
|
|
265
|
+
const found = [];
|
|
266
|
+
for (const [key, field] of Object.entries(fields)) {
|
|
267
|
+
if (field?.type !== "blocks" || field.private) continue;
|
|
268
|
+
const schemaPath = [...prefix, key];
|
|
269
|
+
found.push({ field, schemaPath, depth: Math.ceil(schemaPath.length / 2) });
|
|
270
|
+
for (const [blockName, block] of Object.entries(field.blocks ?? {})) {
|
|
271
|
+
found.push(...blocksFieldPaths(block?.fields ?? {}, [...schemaPath, blockName]));
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return found;
|
|
275
|
+
}
|
|
276
|
+
export function mapBlocks(field, value, map) {
|
|
277
|
+
if (!Array.isArray(value)) return value;
|
|
278
|
+
const result = [];
|
|
279
|
+
for (const item of value) {
|
|
280
|
+
if (!isRecord(item)) {
|
|
281
|
+
result.push(item);
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
const block = field.blocks?.[String(item.type)];
|
|
285
|
+
const mapped = map(item, block, field);
|
|
286
|
+
if (!mapped) continue;
|
|
287
|
+
let next = mapped;
|
|
288
|
+
for (const [key, subfield] of Object.entries(block?.fields ?? {})) {
|
|
289
|
+
if (subfield.type !== "blocks" || !Array.isArray(next[key])) continue;
|
|
290
|
+
const nested = mapBlocks(subfield, next[key], map);
|
|
291
|
+
if (nested === next[key]) continue;
|
|
292
|
+
if (next === item) next = { ...item };
|
|
293
|
+
next[key] = nested;
|
|
294
|
+
}
|
|
295
|
+
result.push(next);
|
|
296
|
+
}
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
export function hasNestedBlocks(field) {
|
|
300
|
+
return Object.values(field.blocks ?? {}).some(
|
|
301
|
+
(block) => Object.values(block?.fields ?? {}).some((subfield) => subfield?.type === "blocks")
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
export function blockFieldsDeep(field) {
|
|
305
|
+
return Object.values(field.blocks ?? {}).flatMap(
|
|
306
|
+
(block) => Object.values(block?.fields ?? {}).flatMap(
|
|
307
|
+
(subfield) => subfield?.type === "blocks" ? [subfield, ...blockFieldsDeep(subfield)] : [subfield]
|
|
308
|
+
)
|
|
309
|
+
);
|
|
310
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { BlockConfig } from './index.js';
|
|
2
|
+
export declare const CMS_BLOCK_PICKER_OTHER_GROUP = "Other";
|
|
3
|
+
export declare const CMS_BLOCK_ICON = "rectangle-stack";
|
|
4
|
+
export interface CmsBlockPickerItem {
|
|
5
|
+
type: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
icon: string;
|
|
9
|
+
keywords: string[];
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
disabledReason?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface CmsBlockPickerGroup {
|
|
14
|
+
id: string;
|
|
15
|
+
label: string | null;
|
|
16
|
+
items: CmsBlockPickerItem[];
|
|
17
|
+
}
|
|
18
|
+
export declare function blockPickerGroups(blocks: Record<string, BlockConfig>, disabledReason?: (type: string) => string | undefined): CmsBlockPickerGroup[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const CMS_BLOCK_PICKER_OTHER_GROUP = "Other";
|
|
2
|
+
export const CMS_BLOCK_ICON = "rectangle-stack";
|
|
3
|
+
export function blockPickerGroups(blocks, disabledReason = () => void 0) {
|
|
4
|
+
const entries = Object.entries(blocks);
|
|
5
|
+
const grouped = entries.some(([, block]) => !!block.group?.trim());
|
|
6
|
+
const groups = /* @__PURE__ */ new Map();
|
|
7
|
+
const other = {
|
|
8
|
+
id: "",
|
|
9
|
+
label: grouped ? CMS_BLOCK_PICKER_OTHER_GROUP : null,
|
|
10
|
+
items: []
|
|
11
|
+
};
|
|
12
|
+
for (const [type, block] of entries) {
|
|
13
|
+
const name = block.group?.trim();
|
|
14
|
+
let group = other;
|
|
15
|
+
if (name) {
|
|
16
|
+
group = groups.get(name) ?? { id: name, label: name, items: [] };
|
|
17
|
+
groups.set(name, group);
|
|
18
|
+
}
|
|
19
|
+
const reason = disabledReason(type) || void 0;
|
|
20
|
+
group.items.push({
|
|
21
|
+
type,
|
|
22
|
+
label: block.label,
|
|
23
|
+
description: block.description || void 0,
|
|
24
|
+
icon: block.icon ?? CMS_BLOCK_ICON,
|
|
25
|
+
keywords: [type, ...name ? [name] : [], ...block.tags ?? []],
|
|
26
|
+
disabled: !!reason,
|
|
27
|
+
...reason ? { disabledReason: reason } : {}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return [...groups.values(), other].filter((group) => group.items.length);
|
|
31
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BlockConfig } from './index.js';
|
|
2
|
+
export declare function blockShape(block: Pick<BlockConfig, 'fields'>): string;
|
|
3
|
+
export declare function blockSignature(block: Pick<BlockConfig, 'fields'>): string;
|
|
4
|
+
export declare function blockSignatures(blocks: Record<string, Pick<BlockConfig, 'fields'>> | undefined, types: readonly string[]): Record<string, string>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isTranslatableField, mediaTypeFilter, selectOptionValues } from "./index.js";
|
|
2
|
+
function fieldShape(key, field) {
|
|
3
|
+
const shape = [key, field.type];
|
|
4
|
+
if (isTranslatableField(field)) shape.push("translatable");
|
|
5
|
+
if (field.type === "number" && field.integer) shape.push("integer");
|
|
6
|
+
if (field.type === "select") {
|
|
7
|
+
if (field.multiple) shape.push("multiple");
|
|
8
|
+
shape.push({ options: [...new Set(selectOptionValues(field))].sort() });
|
|
9
|
+
}
|
|
10
|
+
if (field.type === "media")
|
|
11
|
+
shape.push({ mediaType: mediaTypeFilter(field.mediaType)?.sort() ?? null });
|
|
12
|
+
if (field.type === "blocks") {
|
|
13
|
+
const blocks = field.blocks ?? {};
|
|
14
|
+
shape.push({
|
|
15
|
+
blocks: Object.keys(blocks).sort().map((name) => [name, blockFieldShapes(blocks[name])])
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return shape;
|
|
19
|
+
}
|
|
20
|
+
function blockFieldShapes(block) {
|
|
21
|
+
return Object.keys(block.fields).sort().map((key) => fieldShape(key, block.fields[key]));
|
|
22
|
+
}
|
|
23
|
+
export function blockShape(block) {
|
|
24
|
+
return JSON.stringify(blockFieldShapes(block));
|
|
25
|
+
}
|
|
26
|
+
function hashText(text) {
|
|
27
|
+
let first = 2166136261;
|
|
28
|
+
let second = 2538058380;
|
|
29
|
+
for (let index = 0; index < text.length; index++) {
|
|
30
|
+
const code = text.charCodeAt(index);
|
|
31
|
+
first = Math.imul(first ^ code, 16777619);
|
|
32
|
+
second = Math.imul(second ^ code, 1540483477);
|
|
33
|
+
second ^= second >>> 15;
|
|
34
|
+
}
|
|
35
|
+
const hex = (value) => (value >>> 0).toString(16).padStart(8, "0");
|
|
36
|
+
return `${hex(first)}${hex(second)}`;
|
|
37
|
+
}
|
|
38
|
+
export function blockSignature(block) {
|
|
39
|
+
return hashText(blockShape(block));
|
|
40
|
+
}
|
|
41
|
+
export function blockSignatures(blocks, types) {
|
|
42
|
+
const available = blocks ?? {};
|
|
43
|
+
return Object.fromEntries(
|
|
44
|
+
types.filter((type) => Object.hasOwn(available, type)).map((type) => [type, blockSignature(available[type])])
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BlockConfig, CmsI18n, FieldConfig } from './index.js';
|
|
2
|
+
import type { CmsBlockValue } from './preview.js';
|
|
3
|
+
export declare const CMS_CLIPBOARD_KIND = "blocks";
|
|
4
|
+
export declare const CMS_CLIPBOARD_VERSION = 1;
|
|
5
|
+
export declare const CMS_CLIPBOARD_MAX_ITEMS = 200;
|
|
6
|
+
export interface CmsClipboardPayload {
|
|
7
|
+
nuxtCms: typeof CMS_CLIPBOARD_KIND;
|
|
8
|
+
version: typeof CMS_CLIPBOARD_VERSION;
|
|
9
|
+
items: CmsBlockValue[];
|
|
10
|
+
}
|
|
11
|
+
export interface CmsPasteResult {
|
|
12
|
+
list: CmsBlockValue[];
|
|
13
|
+
at: number;
|
|
14
|
+
pasted: number;
|
|
15
|
+
unknown: string[];
|
|
16
|
+
overflow: number;
|
|
17
|
+
}
|
|
18
|
+
export interface CmsClipboardNotice {
|
|
19
|
+
title: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
color?: 'success' | 'error';
|
|
22
|
+
}
|
|
23
|
+
export declare function clipboardText(items: readonly CmsBlockValue[]): string;
|
|
24
|
+
export declare function parseClipboardText(text: unknown): CmsBlockValue[] | null;
|
|
25
|
+
export declare function pastedFieldValue(field: FieldConfig, raw: unknown, i18n: CmsI18n): unknown;
|
|
26
|
+
export declare function pastedBlock(type: string, block: BlockConfig, item: Record<string, unknown>, i18n: CmsI18n): CmsBlockValue;
|
|
27
|
+
export declare function pasteBlocks(list: readonly CmsBlockValue[], at: number, items: readonly CmsBlockValue[], field: Pick<FieldConfig, 'blocks' | 'max'>, i18n: CmsI18n): CmsPasteResult;
|
|
28
|
+
export declare function pasteableCount(items: readonly CmsBlockValue[] | null | undefined, field: Pick<FieldConfig, 'blocks'>): number;
|
|
29
|
+
export declare function skippedText(result: CmsPasteResult, field: Pick<FieldConfig, 'max'>): string | undefined;
|
|
30
|
+
export declare function copyNotice(count: number, cut?: boolean): CmsClipboardNotice;
|
|
31
|
+
export declare function pasteNotice(result: CmsPasteResult | null, field: Pick<FieldConfig, 'max'>): CmsClipboardNotice;
|