@kardalum/plugin-sdk 0.0.0-stage → 0.16.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/CHANGELOG.md +118 -0
- package/LICENSE +202 -0
- package/README.md +80 -2
- package/dist/admin-section-registry.d.ts +34 -0
- package/dist/admin-section-registry.js +49 -0
- package/dist/built-in-serializers.d.ts +3 -0
- package/dist/built-in-serializers.js +18 -0
- package/dist/built-in-settings-schemas.d.ts +14 -0
- package/dist/built-in-settings-schemas.js +225 -0
- package/dist/built-in-value-schemas.d.ts +4 -0
- package/dist/built-in-value-schemas.js +47 -0
- package/dist/built-ins.d.ts +1 -0
- package/dist/built-ins.js +257 -0
- package/dist/capabilities.d.ts +29 -0
- package/dist/capabilities.js +67 -0
- package/dist/data-type-plugin.d.ts +28 -0
- package/dist/data-type-plugin.js +1 -0
- package/dist/datatype-validation.d.ts +26 -0
- package/dist/datatype-validation.js +110 -0
- package/dist/datatypes-entry.d.ts +4 -0
- package/dist/datatypes-entry.js +18 -0
- package/dist/define-plugin.d.ts +25 -0
- package/dist/define-plugin.js +51 -0
- package/dist/entitlement-entry.d.ts +5 -0
- package/dist/entitlement-entry.js +24 -0
- package/dist/entitlement-gate.d.ts +36 -0
- package/dist/entitlement-gate.js +201 -0
- package/dist/entitlement-types.d.ts +39 -0
- package/dist/entitlement-types.js +1 -0
- package/dist/entitlement.d.ts +57 -0
- package/dist/entitlement.js +170 -0
- package/dist/host-entry.d.ts +1 -0
- package/dist/host-entry.js +11 -0
- package/dist/icon-name.d.ts +1 -0
- package/dist/icon-name.js +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +10 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +94 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +26 -0
- package/dist/local-host.d.ts +3 -0
- package/dist/local-host.js +38 -0
- package/dist/manifest-entry.d.ts +8 -0
- package/dist/manifest-entry.js +13 -0
- package/dist/manifest-schema.d.ts +476 -0
- package/dist/manifest-schema.js +823 -0
- package/dist/manifest.d.ts +611 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +447 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +82 -0
- package/dist/plugin-context.js +77 -0
- package/dist/plugin-screen-context.d.ts +71 -0
- package/dist/plugin-screen-context.js +41 -0
- package/dist/read-all-pages.d.ts +23 -0
- package/dist/read-all-pages.js +30 -0
- package/dist/register-built-ins.d.ts +1 -0
- package/dist/register-built-ins.js +41 -0
- package/dist/registry.d.ts +4 -0
- package/dist/registry.js +17 -0
- package/dist/rendition-eligibility.d.ts +24 -0
- package/dist/rendition-eligibility.js +40 -0
- package/dist/richtext/block-panel.d.ts +27 -0
- package/dist/richtext/block-panel.js +232 -0
- package/dist/richtext/extensions.d.ts +19 -0
- package/dist/richtext/extensions.js +56 -0
- package/dist/richtext/insert-menu.d.ts +24 -0
- package/dist/richtext/insert-menu.js +142 -0
- package/dist/richtext/kardalum-block.d.ts +33 -0
- package/dist/richtext/kardalum-block.js +282 -0
- package/dist/richtext/style-listbox.d.ts +10 -0
- package/dist/richtext/style-listbox.js +69 -0
- package/dist/richtext/text-style-class.d.ts +18 -0
- package/dist/richtext/text-style-class.js +36 -0
- package/dist/simple-storage-value-provider.d.ts +9 -0
- package/dist/simple-storage-value-provider.js +96 -0
- package/dist/structured-storage-types.d.ts +61 -0
- package/dist/structured-storage-types.js +11 -0
- package/dist/tailwind.d.ts +1 -0
- package/dist/tailwind.js +5 -0
- package/dist/tokens/system-dark.css +75 -0
- package/dist/tokens/tokens.css +239 -0
- package/dist/tokens/tokens.json +212 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.js +11 -0
- package/dist/ui-entry.d.ts +5 -0
- package/dist/ui-entry.js +42 -0
- package/dist/views/content-list-preview.d.ts +1 -0
- package/dist/views/content-list-preview.js +14 -0
- package/dist/views/content-list-settings-view.d.ts +1 -0
- package/dist/views/content-list-settings-view.js +97 -0
- package/dist/views/content-list-view.d.ts +19 -0
- package/dist/views/content-list-view.js +248 -0
- package/dist/views/crop-view.d.ts +55 -0
- package/dist/views/crop-view.js +161 -0
- package/dist/views/date-range-view.d.ts +6 -0
- package/dist/views/date-range-view.js +55 -0
- package/dist/views/file-upload-view.d.ts +43 -0
- package/dist/views/file-upload-view.js +104 -0
- package/dist/views/html-code-editor.d.ts +10 -0
- package/dist/views/html-code-editor.js +101 -0
- package/dist/views/html-view.d.ts +3 -0
- package/dist/views/html-view.js +53 -0
- package/dist/views/image-view.d.ts +3 -0
- package/dist/views/image-view.js +372 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +429 -0
- package/node_modules/@kardalum/api-schemas/LICENSE +202 -0
- package/node_modules/@kardalum/api-schemas/README.md +56 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/action.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +93 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +88 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.d.ts +89 -0
- package/node_modules/@kardalum/api-schemas/dist/asset-api.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/asset.schema.js +47 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/auth.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +542 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +357 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +158 -0
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +125 -0
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +260 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash-api.schema.js +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.d.ts +152 -0
- package/node_modules/@kardalum/api-schemas/dist/content-trash.schema.js +82 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.d.ts +18 -0
- package/node_modules/@kardalum/api-schemas/dist/content-version.schema.js +22 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +133 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/culture-direction.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +298 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +121 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +147 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.d.ts +6 -0
- package/node_modules/@kardalum/api-schemas/dist/health.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/html-entities.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +113 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +64 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +73 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +104 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +682 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +269 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +177 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +222 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-use.js +117 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +27 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +279 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.d.ts +74 -0
- package/node_modules/@kardalum/api-schemas/dist/media-rendition.schema.js +157 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +80 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +156 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/nav.schema.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +846 -0
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +356 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +249 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-text.js +889 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +172 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +196 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +59 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +585 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +536 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +391 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +413 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +100 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +162 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-registry-api.schema.js +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +24 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +314 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +338 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +79 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +50 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/render-settings-api.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/reserved-slugs.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +75 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.d.ts +17 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content-outcome.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +79 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +105 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.d.ts +243 -0
- package/node_modules/@kardalum/api-schemas/dist/sites.schema.js +296 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +47 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +30 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +74 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/theme-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +97 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +73 -0
- package/node_modules/@kardalum/api-schemas/package.json +35 -0
- package/node_modules/@kardalum/design-tokens/LICENSE +202 -0
- package/node_modules/@kardalum/design-tokens/README.md +29 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.d.ts +32 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +88 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.d.ts +1 -0
- package/node_modules/@kardalum/design-tokens/dist/generate.js +18 -0
- package/node_modules/@kardalum/design-tokens/dist/index.d.ts +6 -0
- package/node_modules/@kardalum/design-tokens/dist/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +75 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +33 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +54 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.d.ts +12 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-css.js +42 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.d.ts +43 -0
- package/node_modules/@kardalum/design-tokens/dist/theme-types.js +1 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.d.ts +13 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/dark.js +120 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.d.ts +5 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/index.js +4 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.d.ts +9 -0
- package/node_modules/@kardalum/design-tokens/dist/themes/light.js +13 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +239 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +25 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +276 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +212 -0
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +91 -0
- package/node_modules/@kardalum/design-tokens/dist/types.js +5 -0
- package/node_modules/@kardalum/design-tokens/package.json +42 -0
- package/node_modules/@kardalum/plugin-package/LICENSE +202 -0
- package/node_modules/@kardalum/plugin-package/README.md +71 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +111 -0
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +61 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +103 -0
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/docs-contract.js +659 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.d.ts +19 -0
- package/node_modules/@kardalum/plugin-package/dist/envelope.js +104 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.d.ts +37 -0
- package/node_modules/@kardalum/plugin-package/dist/extract.js +199 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/hash.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +13 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +8 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +185 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +236 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.d.ts +50 -0
- package/node_modules/@kardalum/plugin-package/dist/package-contract.js +115 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/reference-entry.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.d.ts +20 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +57 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +43 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +15 -0
- package/node_modules/@kardalum/plugin-package/package.json +54 -0
- package/node_modules/@kardalum/ui/LICENSE +202 -0
- package/node_modules/@kardalum/ui/README.md +35 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.d.ts +14 -0
- package/node_modules/@kardalum/ui/dist/components/alert-dialog.js +38 -0
- package/node_modules/@kardalum/ui/dist/components/badge.d.ts +9 -0
- package/node_modules/@kardalum/ui/dist/components/badge.js +30 -0
- package/node_modules/@kardalum/ui/dist/components/button.d.ts +11 -0
- package/node_modules/@kardalum/ui/dist/components/button.js +37 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/checkbox.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/dialog.js +48 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/dropdown-menu.js +53 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.d.ts +30 -0
- package/node_modules/@kardalum/ui/dist/components/empty-state.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/input.d.ts +4 -0
- package/node_modules/@kardalum/ui/dist/components/input.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/panel.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/panel.js +6 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.d.ts +19 -0
- package/node_modules/@kardalum/ui/dist/components/property-field.js +89 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/sheet.js +55 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.d.ts +3 -0
- package/node_modules/@kardalum/ui/dist/components/skeleton.js +9 -0
- package/node_modules/@kardalum/ui/dist/components/switch.d.ts +5 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.d.ts +34 -0
- package/node_modules/@kardalum/ui/dist/components/tab-strip.js +72 -0
- package/node_modules/@kardalum/ui/dist/components/toast.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/components/toast.js +42 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.d.ts +12 -0
- package/node_modules/@kardalum/ui/dist/components/toaster.js +11 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.d.ts +17 -0
- package/node_modules/@kardalum/ui/dist/components/use-toast.js +62 -0
- package/node_modules/@kardalum/ui/dist/index.d.ts +18 -0
- package/node_modules/@kardalum/ui/dist/index.js +18 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/lib/cn.js +5 -0
- package/node_modules/@kardalum/ui/package.json +63 -0
- package/package.json +146 -4
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { Selection } from "@tiptap/pm/state";
|
|
4
|
+
import { Button, Dialog, DialogCloseButton, DialogContent, DialogFooter, DialogHeader, DialogTitle, Input, PropertyField, Switch, } from "@kardalum/ui";
|
|
5
|
+
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
6
|
+
import { MediaPicker } from "../media/media-picker.js";
|
|
7
|
+
import { useBlockListings } from "./insert-menu.js";
|
|
8
|
+
function useMediaParamPreview(mediaId) {
|
|
9
|
+
const fetchApi = usePluginApi();
|
|
10
|
+
const [preview, setPreview] = useState(null);
|
|
11
|
+
const [loading, setLoading] = useState(false);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!mediaId) {
|
|
14
|
+
setPreview(null);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let cancelled = false;
|
|
18
|
+
setLoading(true);
|
|
19
|
+
fetchApi(`${MANAGE_API}/media/${mediaId}`)
|
|
20
|
+
.then(async (response) => {
|
|
21
|
+
if (!response.ok)
|
|
22
|
+
throw new Error(`Failed to load media (${response.status})`);
|
|
23
|
+
const body = (await response.json());
|
|
24
|
+
if (!cancelled)
|
|
25
|
+
setPreview({ filename: body.filename, downloadUrl: body.downloadUrl });
|
|
26
|
+
})
|
|
27
|
+
.catch(() => {
|
|
28
|
+
if (!cancelled)
|
|
29
|
+
setPreview(null);
|
|
30
|
+
})
|
|
31
|
+
.finally(() => {
|
|
32
|
+
if (!cancelled)
|
|
33
|
+
setLoading(false);
|
|
34
|
+
});
|
|
35
|
+
return () => {
|
|
36
|
+
cancelled = true;
|
|
37
|
+
};
|
|
38
|
+
}, [mediaId, fetchApi]);
|
|
39
|
+
return { preview, loading };
|
|
40
|
+
}
|
|
41
|
+
// One field per declared param, keyed by its type (S197 Task 3 brief:
|
|
42
|
+
// text/textarea/number/boolean(switch)/image(MediaPicker)/choice(select)).
|
|
43
|
+
function BlockParamField({ spec, value, onChange, error }) {
|
|
44
|
+
const fieldId = `block-param-${spec.key}`;
|
|
45
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
46
|
+
const mediaId = spec.type === "image" ? (value ?? null) : null;
|
|
47
|
+
const { preview } = useMediaParamPreview(mediaId);
|
|
48
|
+
switch (spec.type) {
|
|
49
|
+
case "text":
|
|
50
|
+
return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx(Input, { id: fieldId, type: "text", value: value ?? "", onChange: (event) => onChange(event.target.value) }) }));
|
|
51
|
+
case "textarea":
|
|
52
|
+
return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx("textarea", { id: fieldId, rows: 3, value: value ?? "", onChange: (event) => onChange(event.target.value), className: "w-full rounded-md border border-border-strong bg-background-elevated px-3 py-2 text-sm text-text-primary focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50" }) }));
|
|
53
|
+
case "number":
|
|
54
|
+
return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx(Input, { id: fieldId, type: "number", value: value ?? 0, onChange: (event) => {
|
|
55
|
+
// A `type="number"` input still hands back an empty or
|
|
56
|
+
// otherwise unparseable string in plenty of real situations
|
|
57
|
+
// (cleared entirely, "-", "1e", a paste) — Number() turns
|
|
58
|
+
// those into NaN, which must never reach the node's attrs.
|
|
59
|
+
// 0 is the same documented empty-state default this field
|
|
60
|
+
// (and defaultBlockParams) already uses.
|
|
61
|
+
const raw = event.target.value;
|
|
62
|
+
const next = raw === "" ? 0 : Number(raw);
|
|
63
|
+
onChange(Number.isNaN(next) ? 0 : next);
|
|
64
|
+
} }) }));
|
|
65
|
+
case "boolean":
|
|
66
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("label", { htmlFor: fieldId, className: "text-sm font-medium text-text-primary", children: spec.label }), _jsx(Switch, { id: fieldId, checked: Boolean(value), onCheckedChange: (checked) => onChange(checked) })] }), error && (_jsx("p", { role: "alert", className: "text-xs text-danger-600", children: error }))] }));
|
|
67
|
+
case "choice":
|
|
68
|
+
return (_jsx(PropertyField, { label: spec.label, htmlFor: fieldId, error: error, children: _jsx("select", { id: fieldId, value: value ?? "", onChange: (event) => onChange(event.target.value), className: "h-10 w-full rounded-md border border-border-strong bg-background-elevated px-3 text-sm text-text-primary focus-visible:border-primary-600 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-primary-50", children: (spec.options ?? []).map((option) => (_jsx("option", { value: option, children: option }, option))) }) }));
|
|
69
|
+
case "image":
|
|
70
|
+
return (_jsxs(PropertyField, { label: spec.label, error: error, children: [_jsxs("div", { className: "flex items-center gap-3 rounded-md border border-border-default bg-background-subtle p-2", children: [preview ? (_jsx("img", { src: preview.downloadUrl, alt: "", className: "h-10 w-10 shrink-0 rounded-md object-cover" })) : (_jsx("div", { "aria-hidden": "true", className: "h-10 w-10 shrink-0 rounded-md bg-background-hover" })), _jsx("span", { className: "flex-1 truncate text-sm text-text-secondary", children: preview?.filename ?? "No image selected" }), _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: () => setPickerOpen(true), children: "Change" })] }), pickerOpen && (_jsx(MediaPicker
|
|
71
|
+
// A block param stores the media id and nothing else, so
|
|
72
|
+
// there is nowhere for alt text to go: asking for it here
|
|
73
|
+
// would be collecting something this field then discards.
|
|
74
|
+
, {
|
|
75
|
+
// A block param stores the media id and nothing else, so
|
|
76
|
+
// there is nowhere for alt text to go: asking for it here
|
|
77
|
+
// would be collecting something this field then discards.
|
|
78
|
+
collectAlt: false, onPick: (item) => {
|
|
79
|
+
onChange(item.id);
|
|
80
|
+
setPickerOpen(false);
|
|
81
|
+
}, onClose: () => setPickerOpen(false) }))] }));
|
|
82
|
+
default:
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// The typed param field list, extracted out of BlockPanel (S197 Task 12 —
|
|
87
|
+
// same reasoning as StyleListbox's own extraction) so the on-page side
|
|
88
|
+
// panel (apps/admin-ui's block-overlay.tsx) can render the exact same
|
|
89
|
+
// fields inside its OWN chrome (a slide-in side panel, not this Dialog) —
|
|
90
|
+
// the form-view/on-page distinction is only ever about the surrounding
|
|
91
|
+
// panel shell, never about how a param is edited.
|
|
92
|
+
export function BlockParamFields({ listing, listingsError, params, onChange, fieldErrors }) {
|
|
93
|
+
return (_jsxs(_Fragment, { children: [!listing && listingsError && _jsx("p", { className: "text-sm text-danger-600", children: listingsError }), !listing && !listingsError && (_jsx("p", { className: "text-sm text-text-secondary", children: "This block's fields couldn't be loaded. Its template declaration may be missing or the render service is unavailable." })), listing?.params.map((spec) => (_jsx(BlockParamField, { spec: spec, value: params[spec.key], onChange: (next) => onChange(spec.key, next), error: fieldErrors?.[spec.key] }, spec.key)))] }));
|
|
94
|
+
}
|
|
95
|
+
// The mockup's right-hand settings panel (screen 1) for the form view: a
|
|
96
|
+
// modal over the editor (Dialog, per packages/ui — MediaPicker moved to
|
|
97
|
+
// the newer Sheet side-drawer for its own modal in S197 QA-wave C Item 5,
|
|
98
|
+
// but this panel's own content is a centered param form, not a browsing
|
|
99
|
+
// UI, so Dialog is still the right shape here), focus-trapped by Radix.
|
|
100
|
+
// Rendered by rich-text-view.tsx exactly
|
|
101
|
+
// while the current selection is a NodeSelection on this block — see that
|
|
102
|
+
// file for why: the same click that selects the atom node (default
|
|
103
|
+
// ProseMirror behavior for an atom+selectable node, nothing bespoke) is
|
|
104
|
+
// what the mockup calls "click the block to open its settings panel", so
|
|
105
|
+
// panel visibility is just a read of editor state, not separate
|
|
106
|
+
// open/close state duplicated here.
|
|
107
|
+
export function BlockPanel({ editor, pos, partial, params }) {
|
|
108
|
+
const { listings, error: listingsError } = useBlockListings();
|
|
109
|
+
const listing = listings.find((entry) => entry.alias === partial) ?? null;
|
|
110
|
+
// "at the node's position" (S197 Task 3 brief): setNodeSelection(pos)
|
|
111
|
+
// first so updateAttributes — which otherwise acts on whatever the
|
|
112
|
+
// CURRENT selection happens to be — is guaranteed to target this exact
|
|
113
|
+
// node, never whatever the user last clicked elsewhere. No .focus(): a
|
|
114
|
+
// focus() here would yank keyboard focus out of the panel's own input
|
|
115
|
+
// on every keystroke.
|
|
116
|
+
function updateParam(key, next) {
|
|
117
|
+
editor
|
|
118
|
+
.chain()
|
|
119
|
+
.setNodeSelection(pos)
|
|
120
|
+
.updateAttributes("kardalumBlock", { params: { ...params, [key]: next } })
|
|
121
|
+
.run();
|
|
122
|
+
}
|
|
123
|
+
function moveSelectionPastBlock() {
|
|
124
|
+
const size = editor.state.doc.nodeAt(pos)?.nodeSize ?? 1;
|
|
125
|
+
const next = Math.min(pos + size, editor.state.doc.content.size);
|
|
126
|
+
// Selection.near, not setTextSelection(next) directly: when the block
|
|
127
|
+
// is the document's only content, `next` doesn't resolve into any
|
|
128
|
+
// inline content at all, and TipTap's setTextSelection constructs a
|
|
129
|
+
// TextSelection there unconditionally (ProseMirror warns and the
|
|
130
|
+
// resulting selection is unreliable). Selection.near finds the
|
|
131
|
+
// nearest position that's actually valid instead.
|
|
132
|
+
// .focus() here IS wanted — Done/Remove/Escape are all "I'm finished
|
|
133
|
+
// editing this block," and returning keyboard focus to the document is
|
|
134
|
+
// the expected outcome, unlike updateParam's keystroke-time writes.
|
|
135
|
+
editor
|
|
136
|
+
.chain()
|
|
137
|
+
.focus()
|
|
138
|
+
.command(({ tr, dispatch }) => {
|
|
139
|
+
if (dispatch)
|
|
140
|
+
tr.setSelection(Selection.near(tr.doc.resolve(next)));
|
|
141
|
+
return true;
|
|
142
|
+
})
|
|
143
|
+
.run();
|
|
144
|
+
}
|
|
145
|
+
function handleRemove() {
|
|
146
|
+
editor.chain().setNodeSelection(pos).deleteSelection().run();
|
|
147
|
+
editor.commands.focus();
|
|
148
|
+
}
|
|
149
|
+
return (_jsx(Dialog, { open: true, onOpenChange: (next) => {
|
|
150
|
+
if (!next)
|
|
151
|
+
moveSelectionPastBlock();
|
|
152
|
+
}, children: _jsxs(DialogContent, { onCloseAutoFocus: (event) => {
|
|
153
|
+
// Radix's default is to refocus whatever triggered the dialog —
|
|
154
|
+
// there is no trigger button here (the panel opens off a
|
|
155
|
+
// NodeSelection, not a click on some menu item), so without this
|
|
156
|
+
// focus lands on <body> (admin-ui.md's dialog-focus rule).
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
// This callback runs on a rAF after the close, by which point the
|
|
159
|
+
// whole editor can already be gone (e.g. the page navigated away
|
|
160
|
+
// while the panel was open) — commands throws on a destroyed
|
|
161
|
+
// editor, so this is a real guard, not defensive-for-its-own-sake.
|
|
162
|
+
if (!editor.isDestroyed)
|
|
163
|
+
editor.commands.focus();
|
|
164
|
+
}, className: "flex max-h-[80vh] max-w-sm flex-col gap-0 p-0", children: [_jsxs(DialogHeader, { className: "border-b border-border-default px-4 py-3", children: [_jsxs("div", { className: "flex flex-col gap-0.5", children: [_jsx(DialogTitle, { children: listing?.name ?? partial }), _jsxs("span", { className: "font-mono text-xs text-text-tertiary", children: ["partial: ", partial, ".liquid"] })] }), _jsx(DialogCloseButton, { "aria-label": "Close" })] }), _jsxs("div", { className: "flex flex-1 flex-col gap-4 overflow-y-auto p-4", children: [_jsx(BlockParamFields, { listing: listing, listingsError: listingsError, params: params, onChange: updateParam }), _jsxs("p", { className: "rounded-md border border-border-default bg-background-subtle p-2 text-xs text-text-secondary", children: [_jsx("b", { className: "font-semibold text-text-primary", children: "Live preview." }), " This block is rendered by your own template on the server. What you see on the page is exactly what visitors will get."] })] }), _jsxs(DialogFooter, { className: "mt-0 justify-start border-t border-border-default p-4", children: [_jsx(Button, { type: "button", variant: "ghost", className: "text-danger-600 hover:text-danger-700", onClick: handleRemove, children: "Remove block" }), _jsx(Button, { type: "button", className: "ms-auto", onClick: moveSelectionPastBlock, children: "Done" })] })] }) }));
|
|
165
|
+
}
|
|
166
|
+
// The chip's "preview ⤢" affordance (S197 mockup screen 3): fetches
|
|
167
|
+
// POST /api/manage/v1/render/block for the block's CURRENT params and shows the
|
|
168
|
+
// returned HTML in a sandboxed iframe — sandbox="" (no tokens granted) so
|
|
169
|
+
// arbitrary template markup can never run script in the admin UI.
|
|
170
|
+
// Position is computed from a live viewport rect (getBoundingClientRect),
|
|
171
|
+
// which is inherently a physical measurement — plain `top`/`left` here,
|
|
172
|
+
// not logical properties, matches how that rect is expressed.
|
|
173
|
+
export function BlockPreviewPopover({ partial, params, anchorRect, onClose }) {
|
|
174
|
+
const fetchApi = usePluginApi();
|
|
175
|
+
const [html, setHtml] = useState(null);
|
|
176
|
+
const [loading, setLoading] = useState(true);
|
|
177
|
+
const [error, setError] = useState(null);
|
|
178
|
+
const popoverRef = useRef(null);
|
|
179
|
+
useEffect(() => {
|
|
180
|
+
let cancelled = false;
|
|
181
|
+
setLoading(true);
|
|
182
|
+
setError(null);
|
|
183
|
+
fetchApi(`${MANAGE_API}/render/block`, {
|
|
184
|
+
method: "POST",
|
|
185
|
+
headers: { "Content-Type": "application/json" },
|
|
186
|
+
body: JSON.stringify({ partial, params }),
|
|
187
|
+
})
|
|
188
|
+
.then(async (response) => {
|
|
189
|
+
if (!response.ok)
|
|
190
|
+
throw new Error(`Failed to render preview (${response.status})`);
|
|
191
|
+
const body = (await response.json());
|
|
192
|
+
if (!cancelled)
|
|
193
|
+
setHtml(body.html);
|
|
194
|
+
})
|
|
195
|
+
.catch((err) => {
|
|
196
|
+
if (!cancelled)
|
|
197
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
198
|
+
})
|
|
199
|
+
.finally(() => {
|
|
200
|
+
if (!cancelled)
|
|
201
|
+
setLoading(false);
|
|
202
|
+
});
|
|
203
|
+
return () => {
|
|
204
|
+
cancelled = true;
|
|
205
|
+
};
|
|
206
|
+
// params is a fresh object per render (rich-text-view.tsx reads it off
|
|
207
|
+
// node attrs each time) — comparing it by reference would refetch on
|
|
208
|
+
// every unrelated re-render, so key on its serialized form instead.
|
|
209
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
210
|
+
}, [partial, JSON.stringify(params), fetchApi]);
|
|
211
|
+
useEffect(() => {
|
|
212
|
+
function handlePointerDown(event) {
|
|
213
|
+
if (popoverRef.current && !popoverRef.current.contains(event.target))
|
|
214
|
+
onClose();
|
|
215
|
+
}
|
|
216
|
+
function handleKeyDown(event) {
|
|
217
|
+
if (event.key === "Escape")
|
|
218
|
+
onClose();
|
|
219
|
+
}
|
|
220
|
+
document.addEventListener("mousedown", handlePointerDown);
|
|
221
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
222
|
+
return () => {
|
|
223
|
+
document.removeEventListener("mousedown", handlePointerDown);
|
|
224
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
225
|
+
};
|
|
226
|
+
}, [onClose]);
|
|
227
|
+
function handleKeyDownCapture(event) {
|
|
228
|
+
if (event.key === "Escape")
|
|
229
|
+
onClose();
|
|
230
|
+
}
|
|
231
|
+
return (_jsxs("div", { ref: popoverRef, role: "dialog", "aria-label": `Preview: ${partial}`, onKeyDown: handleKeyDownCapture, style: { position: "fixed", top: anchorRect.bottom + 4, left: anchorRect.left }, className: "z-20 w-80 rounded-md border border-border-default bg-background-elevated p-2 shadow-xl", children: [loading && _jsx("p", { className: "text-xs text-text-secondary", children: "Loading preview\u2026" }), error && _jsx("p", { className: "text-xs text-danger-600", children: error }), !loading && !error && (_jsx("iframe", { title: `Preview: ${partial}`, srcDoc: html ?? "", sandbox: "", className: "h-40 w-full rounded-sm border border-border-subtle bg-white" }))] }));
|
|
232
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Extensions } from "@tiptap/core";
|
|
2
|
+
export type { TextStyleClassAttributes } from "./text-style-class.js";
|
|
3
|
+
export type { KardalumBlockAttributes, KardalumBlockLocation, SelectedKardalumBlock } from "./kardalum-block.js";
|
|
4
|
+
export { TextStyleClass } from "./text-style-class.js";
|
|
5
|
+
export { KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./kardalum-block.js";
|
|
6
|
+
export interface RichtextTextStyle {
|
|
7
|
+
key: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
export interface BuildRichtextExtensionsOptions {
|
|
11
|
+
textStyles?: RichtextTextStyle[];
|
|
12
|
+
blockRenderMode?: "chip" | "onPage";
|
|
13
|
+
}
|
|
14
|
+
declare module "@tiptap/extension-image" {
|
|
15
|
+
interface SetImageOptions {
|
|
16
|
+
mediaId?: string | null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export declare function buildRichtextExtensions(options?: BuildRichtextExtensionsOptions): Extensions;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
2
|
+
import Image from "@tiptap/extension-image";
|
|
3
|
+
import Link from "@tiptap/extension-link";
|
|
4
|
+
// tiptap 3.31 ships table's row/header/cell as named exports of this ONE
|
|
5
|
+
// package (not the separate @tiptap/extension-table-row/-cell/-header
|
|
6
|
+
// packages older tiptap majors used) — no extra dependencies needed.
|
|
7
|
+
import { Table, TableRow, TableHeader, TableCell } from "@tiptap/extension-table";
|
|
8
|
+
import { TextStyleClass } from "./text-style-class.js";
|
|
9
|
+
import { KardalumBlock, KardalumBlockOnPage } from "./kardalum-block.js";
|
|
10
|
+
export { TextStyleClass } from "./text-style-class.js";
|
|
11
|
+
export { KardalumBlock, KardalumBlockOnPage, selectedKardalumBlock, findKardalumBlocks, setBlockHtml, unavailableBlockHtml, moveSelectionPastBlock, } from "./kardalum-block.js";
|
|
12
|
+
// The media-library image node (S197 spec §3 "Content shape"): `mediaId`
|
|
13
|
+
// is the reference the server resolves at render/edit time, never a raw
|
|
14
|
+
// pasted URL — `src`/`alt` (the base extension's own attrs) are what the
|
|
15
|
+
// editor shows once resolved, kept in sync by whichever mount inserts the
|
|
16
|
+
// image (this package's toolbar today; the on-page iframe editor later).
|
|
17
|
+
const KardalumImage = Image.extend({
|
|
18
|
+
name: "image",
|
|
19
|
+
addAttributes() {
|
|
20
|
+
return {
|
|
21
|
+
...this.parent?.(),
|
|
22
|
+
mediaId: { default: null },
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
// THE shared TipTap extension set (S197 spec §3: "one TipTap editor
|
|
27
|
+
// definition, mounted two ways"). This package's form-view editor
|
|
28
|
+
// (rich-text-view.tsx) consumes it today; the on-page iframe editor (a
|
|
29
|
+
// later task, spec §6.3 — a vanilla @tiptap/core instance, no React)
|
|
30
|
+
// consumes it unchanged. A mount-specific need (a bubble menu, an insert
|
|
31
|
+
// popover) belongs in that mount's own UI layer, never forked in here.
|
|
32
|
+
export function buildRichtextExtensions(options = {}) {
|
|
33
|
+
const { blockRenderMode = "chip" } = options;
|
|
34
|
+
return [
|
|
35
|
+
// StarterKit bundles its own Link internally (tiptap 3.31) — disabled
|
|
36
|
+
// here so this package's own Link instance (prompt-free popover input,
|
|
37
|
+
// spec-listed as its own extension) is the only one registered; two
|
|
38
|
+
// instances of the same mark name throws.
|
|
39
|
+
StarterKit.configure({ link: false }),
|
|
40
|
+
Link.configure({ openOnClick: false, autolink: true }),
|
|
41
|
+
KardalumImage,
|
|
42
|
+
TextStyleClass,
|
|
43
|
+
blockRenderMode === "onPage" ? KardalumBlockOnPage : KardalumBlock,
|
|
44
|
+
// Registered as its own four-node set (S197 Task 11: the on-page
|
|
45
|
+
// insert menu's "Table" row needs a real `insertTable` command on
|
|
46
|
+
// BOTH mounts — form-view and the vanilla iframe editor — since this
|
|
47
|
+
// is the one shared extension list both consume). `resizable: false`
|
|
48
|
+
// — column dragging needs floating-ui-style pointer tracking this
|
|
49
|
+
// project doesn't wire up anywhere yet; a fixed 3x3 grid (the insert
|
|
50
|
+
// menu's only entry point) needs none of that.
|
|
51
|
+
Table.configure({ resizable: false }),
|
|
52
|
+
TableRow,
|
|
53
|
+
TableHeader,
|
|
54
|
+
TableCell,
|
|
55
|
+
];
|
|
56
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type BlockParamType = "text" | "textarea" | "number" | "boolean" | "image" | "choice";
|
|
2
|
+
export interface BlockParamSpec {
|
|
3
|
+
key: string;
|
|
4
|
+
type: BlockParamType;
|
|
5
|
+
label: string;
|
|
6
|
+
options?: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface BlockListing {
|
|
9
|
+
alias: string;
|
|
10
|
+
name: string;
|
|
11
|
+
params: BlockParamSpec[];
|
|
12
|
+
}
|
|
13
|
+
export declare function defaultBlockParams(params: BlockParamSpec[]): Record<string, unknown>;
|
|
14
|
+
export interface UseBlockListingsResult {
|
|
15
|
+
listings: BlockListing[];
|
|
16
|
+
loading: boolean;
|
|
17
|
+
error: string | null;
|
|
18
|
+
}
|
|
19
|
+
export declare function useBlockListings(): UseBlockListingsResult;
|
|
20
|
+
export interface BlockInsertMenuProps {
|
|
21
|
+
onInsert: (listing: BlockListing) => void;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function BlockInsertMenu({ onInsert, onClose }: BlockInsertMenuProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { cn } from "@kardalum/ui";
|
|
4
|
+
import { MANAGE_API, usePluginApi } from "../plugin-context.js";
|
|
5
|
+
// The value a freshly inserted block's params start with, before the user
|
|
6
|
+
// has touched anything in the param panel (S197 Task 3 brief, "Inserting a
|
|
7
|
+
// block": defaults: text/textarea "", number 0, boolean false, image
|
|
8
|
+
// null, choice first option).
|
|
9
|
+
export function defaultBlockParams(params) {
|
|
10
|
+
const defaults = {};
|
|
11
|
+
for (const param of params) {
|
|
12
|
+
switch (param.type) {
|
|
13
|
+
case "text":
|
|
14
|
+
case "textarea":
|
|
15
|
+
defaults[param.key] = "";
|
|
16
|
+
break;
|
|
17
|
+
case "number":
|
|
18
|
+
defaults[param.key] = 0;
|
|
19
|
+
break;
|
|
20
|
+
case "boolean":
|
|
21
|
+
defaults[param.key] = false;
|
|
22
|
+
break;
|
|
23
|
+
case "image":
|
|
24
|
+
defaults[param.key] = null;
|
|
25
|
+
break;
|
|
26
|
+
case "choice":
|
|
27
|
+
defaults[param.key] = param.options?.[0] ?? "";
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return defaults;
|
|
32
|
+
}
|
|
33
|
+
// GET /api/manage/v1/render/blocks (S197 Task 6 ships this endpoint, until then
|
|
34
|
+
// every call 404s, and this hook surfaces that as `error`, same as
|
|
35
|
+
// MediaPicker's own fetch-failure handling, rather than swallowing it into
|
|
36
|
+
// a silent empty list). Shared between the insert menu (BlockInsertMenu,
|
|
37
|
+
// below) and the param panel (block-panel.tsx needs the same declared
|
|
38
|
+
// param specs + labels to render fields for a block already in the
|
|
39
|
+
// document) — one fetch shape, not forked per consumer.
|
|
40
|
+
export function useBlockListings() {
|
|
41
|
+
const fetchApi = usePluginApi();
|
|
42
|
+
const [listings, setListings] = useState([]);
|
|
43
|
+
const [loading, setLoading] = useState(true);
|
|
44
|
+
const [error, setError] = useState(null);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
let cancelled = false;
|
|
47
|
+
setLoading(true);
|
|
48
|
+
setError(null);
|
|
49
|
+
fetchApi(`${MANAGE_API}/render/blocks`)
|
|
50
|
+
.then(async (response) => {
|
|
51
|
+
if (!response.ok)
|
|
52
|
+
throw new Error(`Failed to load blocks (${response.status})`);
|
|
53
|
+
const body = await response.json();
|
|
54
|
+
if (!cancelled)
|
|
55
|
+
setListings(Array.isArray(body) ? body : []);
|
|
56
|
+
})
|
|
57
|
+
.catch((err) => {
|
|
58
|
+
if (!cancelled)
|
|
59
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
60
|
+
})
|
|
61
|
+
.finally(() => {
|
|
62
|
+
if (!cancelled)
|
|
63
|
+
setLoading(false);
|
|
64
|
+
});
|
|
65
|
+
return () => {
|
|
66
|
+
cancelled = true;
|
|
67
|
+
};
|
|
68
|
+
}, [fetchApi]);
|
|
69
|
+
return { listings, loading, error };
|
|
70
|
+
}
|
|
71
|
+
// The toolbar's "◫ Block ▾" popover body (S197 mockup screen 2, "Blocks —
|
|
72
|
+
// from your templates" section): an ARIA listbox, same single-select
|
|
73
|
+
// pattern as StyleListbox (rich-text-view.tsx): roving tabindex,
|
|
74
|
+
// Arrow/Home/End move focus, Enter/Space commits, Escape closes.
|
|
75
|
+
//
|
|
76
|
+
// Screen 2's mockup also shows Image/Quote/Table rows above the blocks
|
|
77
|
+
// list, but those are already reachable from this editor's own toolbar
|
|
78
|
+
// (the "🖼 Image" button, the "❝" blockquote button) or out of scope (no
|
|
79
|
+
// Table extension exists yet) — this menu covers only what "◫ Block ▾" is
|
|
80
|
+
// for: inserting a template-declared block.
|
|
81
|
+
export function BlockInsertMenu({ onInsert, onClose }) {
|
|
82
|
+
const { listings, loading, error } = useBlockListings();
|
|
83
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
84
|
+
const optionRefs = useRef([]);
|
|
85
|
+
if (loading) {
|
|
86
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Blocks", className: "min-w-64 p-2 text-xs text-text-secondary", children: "Loading\u2026" }));
|
|
87
|
+
}
|
|
88
|
+
if (error) {
|
|
89
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Blocks", className: "min-w-64 p-2 text-xs text-danger-600", children: error }));
|
|
90
|
+
}
|
|
91
|
+
if (listings.length === 0) {
|
|
92
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Blocks", className: "min-w-64 p-2 text-xs text-text-secondary", children: "No blocks declared by your templates yet." }));
|
|
93
|
+
}
|
|
94
|
+
function focusIndex(index) {
|
|
95
|
+
setActiveIndex(index);
|
|
96
|
+
optionRefs.current[index]?.focus();
|
|
97
|
+
}
|
|
98
|
+
function commit(index) {
|
|
99
|
+
const listing = listings[index];
|
|
100
|
+
if (!listing)
|
|
101
|
+
return;
|
|
102
|
+
onInsert(listing);
|
|
103
|
+
onClose();
|
|
104
|
+
}
|
|
105
|
+
function handleKeyDown(event) {
|
|
106
|
+
switch (event.key) {
|
|
107
|
+
case "ArrowDown":
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
focusIndex((activeIndex + 1) % listings.length);
|
|
110
|
+
return;
|
|
111
|
+
case "ArrowUp":
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
focusIndex((activeIndex - 1 + listings.length) % listings.length);
|
|
114
|
+
return;
|
|
115
|
+
case "Home":
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
focusIndex(0);
|
|
118
|
+
return;
|
|
119
|
+
case "End":
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
focusIndex(listings.length - 1);
|
|
122
|
+
return;
|
|
123
|
+
case "Enter":
|
|
124
|
+
case " ":
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
commit(activeIndex);
|
|
127
|
+
return;
|
|
128
|
+
case "Escape":
|
|
129
|
+
event.preventDefault();
|
|
130
|
+
onClose();
|
|
131
|
+
return;
|
|
132
|
+
default:
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return (_jsxs("div", { role: "listbox", "aria-label": "Blocks", onKeyDown: handleKeyDown, className: "min-w-64 p-1", children: [_jsx("div", { className: "px-2 py-1 text-xs font-semibold text-text-tertiary", children: "Blocks: from your templates" }), listings.map((listing, index) => {
|
|
137
|
+
const selected = index === activeIndex;
|
|
138
|
+
return (_jsxs("div", { ref: (el) => {
|
|
139
|
+
optionRefs.current[index] = el;
|
|
140
|
+
}, role: "option", "aria-selected": selected, tabIndex: selected ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("flex cursor-pointer items-start gap-2 rounded-sm px-2 py-1.5 text-sm outline-none", "focus-visible:ring-2 focus-visible:ring-primary-600", selected ? "bg-primary-100" : "text-text-primary hover:bg-background-hover"), children: [_jsx("span", { "aria-hidden": "true", className: "mt-0.5 text-text-secondary", children: "\u25EB" }), _jsxs("span", { className: "flex flex-col", children: [_jsx("span", { className: "font-medium text-text-primary", children: listing.name }), _jsxs("span", { className: "text-xs text-text-secondary", children: [listing.alias, ".liquid", listing.params.length > 0 ? ` · ${listing.params.map((param) => param.key).join(", ")}` : ""] })] })] }, listing.alias));
|
|
141
|
+
})] }));
|
|
142
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Node, type Editor } from "@tiptap/core";
|
|
2
|
+
export interface KardalumBlockOptions {
|
|
3
|
+
HTMLAttributes: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export interface KardalumBlockAttributes {
|
|
6
|
+
partial: string;
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
declare module "@tiptap/core" {
|
|
10
|
+
interface Commands<ReturnType> {
|
|
11
|
+
kardalumBlock: {
|
|
12
|
+
/** Insert a block node referencing a template partial + its params. */
|
|
13
|
+
insertKardalumBlock: (attrs: KardalumBlockAttributes) => ReturnType;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export declare const KardalumBlock: Node<KardalumBlockOptions, any>;
|
|
18
|
+
export interface SelectedKardalumBlock {
|
|
19
|
+
pos: number;
|
|
20
|
+
partial: string;
|
|
21
|
+
params: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
export declare function selectedKardalumBlock(editor: Editor): SelectedKardalumBlock | null;
|
|
24
|
+
export interface KardalumBlockLocation {
|
|
25
|
+
pos: number;
|
|
26
|
+
partial: string;
|
|
27
|
+
params: Record<string, unknown>;
|
|
28
|
+
}
|
|
29
|
+
export declare function findKardalumBlocks(editor: Editor): KardalumBlockLocation[];
|
|
30
|
+
export declare function setBlockHtml(editor: Editor, pos: number, html: string): void;
|
|
31
|
+
export declare function moveSelectionPastBlock(editor: Editor, pos: number): void;
|
|
32
|
+
export declare function unavailableBlockHtml(reason: string): string;
|
|
33
|
+
export declare const KardalumBlockOnPage: Node<KardalumBlockOptions, any>;
|