@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,282 @@
|
|
|
1
|
+
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
import { NodeSelection, Selection } from "@tiptap/pm/state";
|
|
3
|
+
export const KardalumBlock = Node.create({
|
|
4
|
+
name: "kardalumBlock",
|
|
5
|
+
group: "block",
|
|
6
|
+
atom: true,
|
|
7
|
+
selectable: true,
|
|
8
|
+
draggable: false,
|
|
9
|
+
addOptions() {
|
|
10
|
+
return { HTMLAttributes: {} };
|
|
11
|
+
},
|
|
12
|
+
addAttributes() {
|
|
13
|
+
return {
|
|
14
|
+
partial: {
|
|
15
|
+
default: "",
|
|
16
|
+
// The shell attribute is `data-kardalum-block`, not a bare `partial`
|
|
17
|
+
// — parse/render both go through that one attribute so the two
|
|
18
|
+
// never drift apart.
|
|
19
|
+
parseHTML: (element) => element.getAttribute("data-kardalum-block") ?? "",
|
|
20
|
+
renderHTML: () => ({}),
|
|
21
|
+
},
|
|
22
|
+
params: {
|
|
23
|
+
default: {},
|
|
24
|
+
parseHTML: (element) => {
|
|
25
|
+
const raw = element.getAttribute("data-params");
|
|
26
|
+
if (!raw)
|
|
27
|
+
return {};
|
|
28
|
+
try {
|
|
29
|
+
return JSON.parse(raw);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
renderHTML: (attributes) => ({ "data-params": JSON.stringify(attributes.params ?? {}) }),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
parseHTML() {
|
|
40
|
+
return [{ tag: "div[data-kardalum-block]" }];
|
|
41
|
+
},
|
|
42
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
43
|
+
// No content hole: this is an atom/leaf node (no `content` expression),
|
|
44
|
+
// and ProseMirror's DOMSerializer rejects a `0` hole on a leaf spec.
|
|
45
|
+
return [
|
|
46
|
+
"div",
|
|
47
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
48
|
+
"data-kardalum-block": node.attrs.partial,
|
|
49
|
+
}),
|
|
50
|
+
];
|
|
51
|
+
},
|
|
52
|
+
addCommands() {
|
|
53
|
+
return {
|
|
54
|
+
insertKardalumBlock: (attrs) => ({ commands }) => commands.insertContent({ type: this.name, attrs }),
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
addNodeView() {
|
|
58
|
+
return ({ node, view, getPos }) => {
|
|
59
|
+
// Reassigned in `update` below so the preview button always reads
|
|
60
|
+
// the block's CURRENT params (the param panel writes them back via
|
|
61
|
+
// updateAttributes — this closure must not keep serving the params
|
|
62
|
+
// it was constructed with).
|
|
63
|
+
let currentNode = node;
|
|
64
|
+
const dom = document.createElement("div");
|
|
65
|
+
dom.setAttribute("data-kardalum-block", node.attrs.partial);
|
|
66
|
+
// No contentDOM: this is a leaf/atom view. contentEditable=false stops
|
|
67
|
+
// the browser from placing a caret or accepting stray keystrokes
|
|
68
|
+
// inside the chip's own markup.
|
|
69
|
+
dom.contentEditable = "false";
|
|
70
|
+
dom.className =
|
|
71
|
+
"flex items-center gap-2 rounded-md border border-dashed border-border-default bg-background-subtle " +
|
|
72
|
+
"px-3 py-2 my-3 text-xs text-text-secondary";
|
|
73
|
+
// A click anywhere on the chip (other than "preview", which stops
|
|
74
|
+
// its own mousedown below) drops a NodeSelection here explicitly —
|
|
75
|
+
// dispatched straight from the position this view already knows via
|
|
76
|
+
// getPos(), rather than counting on ProseMirror's own coordinate-based
|
|
77
|
+
// click-to-select for a leaf. The form-view mount (rich-text-view.tsx)
|
|
78
|
+
// renders its param panel directly off that selection.
|
|
79
|
+
dom.addEventListener("mousedown", () => {
|
|
80
|
+
const pos = typeof getPos === "function" ? getPos() : undefined;
|
|
81
|
+
if (typeof pos !== "number")
|
|
82
|
+
return;
|
|
83
|
+
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)));
|
|
84
|
+
});
|
|
85
|
+
const icon = document.createElement("span");
|
|
86
|
+
icon.textContent = "◫";
|
|
87
|
+
icon.setAttribute("aria-hidden", "true");
|
|
88
|
+
const label = document.createElement("b");
|
|
89
|
+
label.className = "font-semibold text-text-primary";
|
|
90
|
+
label.textContent = node.attrs.partial || "Block";
|
|
91
|
+
const preview = document.createElement("button");
|
|
92
|
+
preview.type = "button";
|
|
93
|
+
preview.className = "ms-auto text-primary-700 hover:underline";
|
|
94
|
+
preview.textContent = "preview ⤢";
|
|
95
|
+
// mousedown (not just click) must stop here, BEFORE ProseMirror's own
|
|
96
|
+
// mousedown listener on the editable root sees it (bubble phase,
|
|
97
|
+
// target-first) — otherwise clicking "preview" would also drop a
|
|
98
|
+
// NodeSelection on this block and pop the param panel at the same
|
|
99
|
+
// time, when the mockup treats preview and "open settings" as two
|
|
100
|
+
// separate affordances.
|
|
101
|
+
preview.addEventListener("mousedown", (event) => event.stopPropagation());
|
|
102
|
+
preview.addEventListener("click", (event) => {
|
|
103
|
+
event.stopPropagation();
|
|
104
|
+
// Plain DOM APIs only (this view has no React tree of its own —
|
|
105
|
+
// see the file-level doc comment) — a bubbling CustomEvent is how
|
|
106
|
+
// the mount that DOES have React (rich-text-view.tsx's fetchApi,
|
|
107
|
+
// its popover state) hears about the request. Any mount can listen
|
|
108
|
+
// for "kardalum:preview-block" the same way, vanilla or not.
|
|
109
|
+
dom.dispatchEvent(new CustomEvent("kardalum:preview-block", {
|
|
110
|
+
bubbles: true,
|
|
111
|
+
detail: {
|
|
112
|
+
partial: currentNode.attrs.partial,
|
|
113
|
+
params: currentNode.attrs.params ?? {},
|
|
114
|
+
anchor: preview,
|
|
115
|
+
},
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
dom.append(icon, label, preview);
|
|
119
|
+
return {
|
|
120
|
+
dom,
|
|
121
|
+
update: (updatedNode) => {
|
|
122
|
+
if (updatedNode.type.name !== node.type.name)
|
|
123
|
+
return false;
|
|
124
|
+
currentNode = updatedNode;
|
|
125
|
+
dom.setAttribute("data-kardalum-block", updatedNode.attrs.partial);
|
|
126
|
+
label.textContent = updatedNode.attrs.partial || "Block";
|
|
127
|
+
return true;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
export function selectedKardalumBlock(editor) {
|
|
134
|
+
const { selection } = editor.state;
|
|
135
|
+
if (!(selection instanceof NodeSelection) || selection.node.type.name !== "kardalumBlock")
|
|
136
|
+
return null;
|
|
137
|
+
return {
|
|
138
|
+
pos: selection.from,
|
|
139
|
+
partial: selection.node.attrs.partial ?? "",
|
|
140
|
+
params: selection.node.attrs.params ?? {},
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function findKardalumBlocks(editor) {
|
|
144
|
+
const found = [];
|
|
145
|
+
editor.state.doc.descendants((node, pos) => {
|
|
146
|
+
if (node.type.name === "kardalumBlock") {
|
|
147
|
+
found.push({
|
|
148
|
+
pos,
|
|
149
|
+
partial: node.attrs.partial ?? "",
|
|
150
|
+
params: node.attrs.params ?? {},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return true;
|
|
154
|
+
});
|
|
155
|
+
return found;
|
|
156
|
+
}
|
|
157
|
+
// Patches a single on-page block's rendered content WITHOUT touching node
|
|
158
|
+
// attrs — html is never stored in content (S197 spec §8), this only updates
|
|
159
|
+
// the NodeView's own DOM. A no-op if `pos` doesn't currently resolve to a
|
|
160
|
+
// mounted on-page NodeView (the block may have been removed or the editor
|
|
161
|
+
// destroyed between when the caller read `pos`/started its fetch and this
|
|
162
|
+
// call landing — a real race an async fetch can hit, not defensive-for-its-
|
|
163
|
+
// own-sake).
|
|
164
|
+
export function setBlockHtml(editor, pos, html) {
|
|
165
|
+
if (editor.isDestroyed)
|
|
166
|
+
return;
|
|
167
|
+
let dom;
|
|
168
|
+
try {
|
|
169
|
+
dom = editor.view.nodeDOM(pos);
|
|
170
|
+
}
|
|
171
|
+
catch {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const handle = dom?.__kardalumSetBlockHtml;
|
|
175
|
+
if (typeof handle === "function")
|
|
176
|
+
handle(html);
|
|
177
|
+
}
|
|
178
|
+
function escapeHtml(value) {
|
|
179
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
180
|
+
}
|
|
181
|
+
// Moves the selection to just past a block at `pos` (Task 12's on-page
|
|
182
|
+
// panel Done/Remove/Escape actions — mirrors block-panel.tsx's own
|
|
183
|
+
// moveSelectionPastBlock exactly, centralized here so BOTH mounts share one
|
|
184
|
+
// implementation). Selection.near, not a direct setTextSelection: when the
|
|
185
|
+
// block is the document's only content, the position just past it doesn't
|
|
186
|
+
// resolve into any inline content at all, and TipTap's setTextSelection
|
|
187
|
+
// constructs an unreliable TextSelection there regardless (ProseMirror
|
|
188
|
+
// warns) — Selection.near finds the nearest position that's actually valid.
|
|
189
|
+
export function moveSelectionPastBlock(editor, pos) {
|
|
190
|
+
if (editor.isDestroyed)
|
|
191
|
+
return;
|
|
192
|
+
const size = editor.state.doc.nodeAt(pos)?.nodeSize ?? 1;
|
|
193
|
+
const next = Math.min(pos + size, editor.state.doc.content.size);
|
|
194
|
+
editor
|
|
195
|
+
.chain()
|
|
196
|
+
.focus()
|
|
197
|
+
.command(({ tr, dispatch }) => {
|
|
198
|
+
if (dispatch)
|
|
199
|
+
tr.setSelection(Selection.near(tr.doc.resolve(next)));
|
|
200
|
+
return true;
|
|
201
|
+
})
|
|
202
|
+
.run();
|
|
203
|
+
}
|
|
204
|
+
// The on-page warning state (spec: a block whose params/partial fail server-
|
|
205
|
+
// side validation renders as an HTML comment on the public page and "the
|
|
206
|
+
// admin editor shows the same state as a warning chip") — fed into
|
|
207
|
+
// setBlockHtml the same way a successful render's HTML is, so the NodeView
|
|
208
|
+
// itself needs no separate notion of "unavailable," only "here is the
|
|
209
|
+
// content to show."
|
|
210
|
+
export function unavailableBlockHtml(reason) {
|
|
211
|
+
return `<div class="kardalum-block-unavailable" role="alert">Block unavailable: ${escapeHtml(reason)}</div>`;
|
|
212
|
+
}
|
|
213
|
+
// The on-page render mode (S197 Task 12): extends the form-view chip's node
|
|
214
|
+
// definition unchanged (same name/attrs/parseHTML/renderHTML — a document
|
|
215
|
+
// authored in one mount round-trips through the other with no data loss,
|
|
216
|
+
// per the brief's "ONE source of truth for the node schema"), overriding
|
|
217
|
+
// only addNodeView. Where the chip shows an icon + partial name + a preview
|
|
218
|
+
// affordance (there is no page here to render INTO), this NodeView shows the
|
|
219
|
+
// block's actual fetched HTML directly in the page — initially empty until
|
|
220
|
+
// the caller (apps/admin-ui's BlockOverlay) fetches it and calls
|
|
221
|
+
// setBlockHtml. Selecting it (click-to-open-panel, same mousedown-dispatched
|
|
222
|
+
// NodeSelection idiom as the chip) is surfaced visually via the NodeView
|
|
223
|
+
// lifecycle's own selectNode/deselectNode hooks (ProseMirror calls these
|
|
224
|
+
// automatically for a selectable atom — the chip doesn't need them since it
|
|
225
|
+
// has no visual "selected" state of its own beyond the panel opening).
|
|
226
|
+
export const KardalumBlockOnPage = KardalumBlock.extend({
|
|
227
|
+
name: "kardalumBlock",
|
|
228
|
+
addNodeView() {
|
|
229
|
+
return ({ node, view, getPos }) => {
|
|
230
|
+
const dom = document.createElement("div");
|
|
231
|
+
dom.setAttribute("data-kardalum-block", node.attrs.partial);
|
|
232
|
+
dom.className = "kardalum-block-onpage";
|
|
233
|
+
// No contentDOM: this is a leaf/atom view, same as the chip.
|
|
234
|
+
// contentEditable=false stops the browser from placing a caret or
|
|
235
|
+
// accepting stray keystrokes inside the block's own rendered markup.
|
|
236
|
+
dom.contentEditable = "false";
|
|
237
|
+
const content = document.createElement("div");
|
|
238
|
+
content.className = "kardalum-block-onpage-content";
|
|
239
|
+
dom.appendChild(content);
|
|
240
|
+
dom.__kardalumSetBlockHtml = (html) => {
|
|
241
|
+
content.innerHTML = html;
|
|
242
|
+
};
|
|
243
|
+
// Blocks are atomic in edit mode (this file's own top comment: "a
|
|
244
|
+
// block's internals are the template's, not the editor's, to edit") —
|
|
245
|
+
// a click anywhere on the rendered HTML (including a real <a>/<button>
|
|
246
|
+
// the template itself emits) opens the settings panel instead of
|
|
247
|
+
// acting like a normal page. `click` is captured (not just mousedown)
|
|
248
|
+
// specifically to preventDefault a real link's navigation, which
|
|
249
|
+
// mousedown alone can't stop.
|
|
250
|
+
dom.addEventListener("click", (event) => {
|
|
251
|
+
event.preventDefault();
|
|
252
|
+
event.stopPropagation();
|
|
253
|
+
});
|
|
254
|
+
dom.addEventListener("mousedown", () => {
|
|
255
|
+
const pos = typeof getPos === "function" ? getPos() : undefined;
|
|
256
|
+
if (typeof pos !== "number")
|
|
257
|
+
return;
|
|
258
|
+
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)));
|
|
259
|
+
});
|
|
260
|
+
return {
|
|
261
|
+
dom,
|
|
262
|
+
// ProseMirror calls these automatically for a selectable atom node
|
|
263
|
+
// whenever its own NodeSelection is set/cleared — the mockup's
|
|
264
|
+
// dashed (hover) vs solid (active/selected) outline is driven by
|
|
265
|
+
// this class from CSS (edit-mode.css), not by re-deriving selection
|
|
266
|
+
// state by hand on every transaction.
|
|
267
|
+
selectNode() {
|
|
268
|
+
dom.classList.add("kardalum-block-onpage-active");
|
|
269
|
+
},
|
|
270
|
+
deselectNode() {
|
|
271
|
+
dom.classList.remove("kardalum-block-onpage-active");
|
|
272
|
+
},
|
|
273
|
+
update: (updatedNode) => {
|
|
274
|
+
if (updatedNode.type.name !== node.type.name)
|
|
275
|
+
return false;
|
|
276
|
+
dom.setAttribute("data-kardalum-block", updatedNode.attrs.partial);
|
|
277
|
+
return true;
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
},
|
|
282
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RichtextTextStyle } from "./extensions.js";
|
|
2
|
+
export interface StyleListboxProps {
|
|
3
|
+
styles: RichtextTextStyle[];
|
|
4
|
+
loading: boolean;
|
|
5
|
+
activeStyleKey: string | null;
|
|
6
|
+
onSelect: (styleKey: string) => void;
|
|
7
|
+
onClear: () => void;
|
|
8
|
+
onClose: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function StyleListbox({ styles, loading, activeStyleKey, onSelect, onClear, onClose }: StyleListboxProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo, useRef, useState } from "react";
|
|
3
|
+
import { cn } from "@kardalum/ui";
|
|
4
|
+
// The Aa Style dropdown's popover body: a proper ARIA listbox (role
|
|
5
|
+
// listbox/option), not a menu — it's a single-select "pick one" widget,
|
|
6
|
+
// same pattern as IconPickerDialog's grid (roving tabindex, Arrow/Home/End,
|
|
7
|
+
// Enter/Space commits).
|
|
8
|
+
export function StyleListbox({ styles, loading, activeStyleKey, onSelect, onClear, onClose }) {
|
|
9
|
+
const options = useMemo(() => [...styles.map((style) => ({ kind: "style", style })), { kind: "clear" }], [styles]);
|
|
10
|
+
const [activeIndex, setActiveIndex] = useState(0);
|
|
11
|
+
const optionRefs = useRef([]);
|
|
12
|
+
if (loading) {
|
|
13
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-40 p-2 text-xs text-text-secondary", children: "Loading\u2026" }));
|
|
14
|
+
}
|
|
15
|
+
if (styles.length === 0) {
|
|
16
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", className: "min-w-40 p-2 text-xs text-text-secondary", children: "No theme styles declared" }));
|
|
17
|
+
}
|
|
18
|
+
function focusIndex(index) {
|
|
19
|
+
setActiveIndex(index);
|
|
20
|
+
optionRefs.current[index]?.focus();
|
|
21
|
+
}
|
|
22
|
+
function commit(index) {
|
|
23
|
+
const option = options[index];
|
|
24
|
+
if (!option)
|
|
25
|
+
return;
|
|
26
|
+
if (option.kind === "clear")
|
|
27
|
+
onClear();
|
|
28
|
+
else
|
|
29
|
+
onSelect(option.style.key);
|
|
30
|
+
onClose();
|
|
31
|
+
}
|
|
32
|
+
function handleKeyDown(event) {
|
|
33
|
+
switch (event.key) {
|
|
34
|
+
case "ArrowDown":
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
focusIndex((activeIndex + 1) % options.length);
|
|
37
|
+
return;
|
|
38
|
+
case "ArrowUp":
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
focusIndex((activeIndex - 1 + options.length) % options.length);
|
|
41
|
+
return;
|
|
42
|
+
case "Home":
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
focusIndex(0);
|
|
45
|
+
return;
|
|
46
|
+
case "End":
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
focusIndex(options.length - 1);
|
|
49
|
+
return;
|
|
50
|
+
case "Enter":
|
|
51
|
+
case " ":
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
commit(activeIndex);
|
|
54
|
+
return;
|
|
55
|
+
case "Escape":
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
onClose();
|
|
58
|
+
return;
|
|
59
|
+
default:
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return (_jsx("div", { role: "listbox", "aria-label": "Text styles", onKeyDown: handleKeyDown, className: "min-w-40 p-1", children: options.map((option, index) => {
|
|
64
|
+
const selected = option.kind === "style" && option.style.key === activeStyleKey;
|
|
65
|
+
return (_jsx("div", { ref: (el) => {
|
|
66
|
+
optionRefs.current[index] = el;
|
|
67
|
+
}, role: "option", "aria-selected": selected, tabIndex: index === activeIndex ? 0 : -1, onFocus: () => setActiveIndex(index), onClick: () => commit(index), className: cn("cursor-pointer 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-primary-800" : "text-text-primary hover:bg-background-hover", option.kind === "clear" && "mt-1 border-t border-border-default pt-1.5 text-text-secondary"), children: option.kind === "style" ? option.style.label : "Clear style" }, option.kind === "style" ? option.style.key : "__clear__"));
|
|
68
|
+
}) }));
|
|
69
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Mark } from "@tiptap/core";
|
|
2
|
+
export interface TextStyleClassOptions {
|
|
3
|
+
HTMLAttributes: Record<string, unknown>;
|
|
4
|
+
}
|
|
5
|
+
export interface TextStyleClassAttributes {
|
|
6
|
+
styleKey: string;
|
|
7
|
+
}
|
|
8
|
+
declare module "@tiptap/core" {
|
|
9
|
+
interface Commands<ReturnType> {
|
|
10
|
+
textStyleClass: {
|
|
11
|
+
/** Apply the named style `rt-<styleKey>` to the current selection. */
|
|
12
|
+
setTextStyle: (styleKey: string) => ReturnType;
|
|
13
|
+
/** Remove any named style from the current selection. */
|
|
14
|
+
unsetTextStyle: () => ReturnType;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export declare const TextStyleClass: Mark<TextStyleClassOptions, any>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Mark, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
const STYLE_KEY_PATTERN = /(?:^|\s)rt-(\S+)/;
|
|
3
|
+
export const TextStyleClass = Mark.create({
|
|
4
|
+
name: "textStyleClass",
|
|
5
|
+
addOptions() {
|
|
6
|
+
return { HTMLAttributes: {} };
|
|
7
|
+
},
|
|
8
|
+
addAttributes() {
|
|
9
|
+
return {
|
|
10
|
+
styleKey: {
|
|
11
|
+
default: null,
|
|
12
|
+
// The class carries the value — nothing to read from a bare
|
|
13
|
+
// attribute, and nothing to render as one (see renderHTML below,
|
|
14
|
+
// which builds the class directly from mark.attrs.styleKey).
|
|
15
|
+
parseHTML: (element) => STYLE_KEY_PATTERN.exec(element.getAttribute("class") ?? "")?.[1] ?? null,
|
|
16
|
+
renderHTML: () => ({}),
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
parseHTML() {
|
|
21
|
+
return [{ tag: 'span[class^="rt-"]' }];
|
|
22
|
+
},
|
|
23
|
+
renderHTML({ mark, HTMLAttributes }) {
|
|
24
|
+
return [
|
|
25
|
+
"span",
|
|
26
|
+
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, { class: `rt-${mark.attrs.styleKey}` }),
|
|
27
|
+
0,
|
|
28
|
+
];
|
|
29
|
+
},
|
|
30
|
+
addCommands() {
|
|
31
|
+
return {
|
|
32
|
+
setTextStyle: (styleKey) => ({ commands }) => commands.setMark(this.name, { styleKey }),
|
|
33
|
+
unsetTextStyle: () => ({ commands }) => commands.unsetMark(this.name),
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
interface SimpleStorageValueProviderProps {
|
|
3
|
+
contentId: string;
|
|
4
|
+
fieldId: string;
|
|
5
|
+
pluginId: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function SimpleStorageValueProvider({ contentId, fieldId, pluginId, children, }: SimpleStorageValueProviderProps): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { PluginValueProvider, usePluginApi } from "./plugin-context.js";
|
|
4
|
+
// S278b (D5): the node refusal a refused write answers (403): the refused
|
|
5
|
+
// action, and the entry that decided, labelled. Its page is named only when
|
|
6
|
+
// the server sent its name, which is only when the person may view it.
|
|
7
|
+
const ACTION_NOUNS = {
|
|
8
|
+
"content.read": "Viewing",
|
|
9
|
+
"content.create": "Creating pages",
|
|
10
|
+
"content.update": "Editing",
|
|
11
|
+
"content.publish": "Publishing",
|
|
12
|
+
"content.delete": "Deleting",
|
|
13
|
+
};
|
|
14
|
+
const ACTION_VERBS = {
|
|
15
|
+
"content.read": "view",
|
|
16
|
+
"content.create": "create",
|
|
17
|
+
"content.update": "edit",
|
|
18
|
+
"content.publish": "publish",
|
|
19
|
+
"content.delete": "delete",
|
|
20
|
+
};
|
|
21
|
+
function refusalSentence(body) {
|
|
22
|
+
if (!body || typeof body !== "object")
|
|
23
|
+
return null;
|
|
24
|
+
const { action, access } = body;
|
|
25
|
+
if (typeof action !== "string" || !(action in ACTION_NOUNS) || !access || typeof access !== "object")
|
|
26
|
+
return null;
|
|
27
|
+
const entry = access.decidedAt ?? null;
|
|
28
|
+
if (access.reason === "role-lacks-action" || entry === null) {
|
|
29
|
+
return `Could not save this field. Your role cannot ${ACTION_VERBS[action]} pages.`;
|
|
30
|
+
}
|
|
31
|
+
const place = entry.name ?? entry.path?.split("/").filter(Boolean).pop() ?? "a page you cannot view";
|
|
32
|
+
// A user the server does not name (no display name; the email is never
|
|
33
|
+
// sent) is "a user"; a role keeps its id when its label is missing.
|
|
34
|
+
const labels = (entry.grants ?? [])
|
|
35
|
+
.map((grant) => grant.label || (grant.subjectKind === "user" ? "a user" : grant.subjectId))
|
|
36
|
+
.filter(Boolean);
|
|
37
|
+
return `Could not save this field. ${ACTION_NOUNS[action]} is restricted at ${place} to: ${labels.length > 0 ? labels.join(", ") : "admins only"}.`;
|
|
38
|
+
}
|
|
39
|
+
// The only SDK code path that ever hits /api/plugins/:pluginId/storage/...
|
|
40
|
+
// (SimpleStorageAPI, Session 68) — a plugin's view code (and usePluginValue()
|
|
41
|
+
// itself) never touches the storage API directly, matching plugin-sdk.md's
|
|
42
|
+
// "SDK handles all host communication" rule. Fetches the current value on
|
|
43
|
+
// mount and feeds it into the SAME PluginValueContext usePluginValue()
|
|
44
|
+
// already reads, so a view wrapped in this provider is indistinguishable
|
|
45
|
+
// from one wrapped in a plain PluginValueProvider — swap this in wherever a
|
|
46
|
+
// field's value should live in content_field_values instead of the local
|
|
47
|
+
// content blob (see document-type-form.tsx for the blob-backed default).
|
|
48
|
+
//
|
|
49
|
+
// Shape mirrors views/image-view.tsx's useMediaPreview(): usePluginApi(),
|
|
50
|
+
// a cancelled-guarded effect, local value/error state. A GET returning
|
|
51
|
+
// {value: null} is the normal "never set" state, not an error.
|
|
52
|
+
export function SimpleStorageValueProvider({ contentId, fieldId, pluginId, children, }) {
|
|
53
|
+
const fetchApi = usePluginApi();
|
|
54
|
+
const [value, setValue] = useState(null);
|
|
55
|
+
const [error, setError] = useState(null);
|
|
56
|
+
const path = `/api/plugins/${pluginId}/storage/${contentId}/${fieldId}`;
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
let cancelled = false;
|
|
59
|
+
setError(null);
|
|
60
|
+
fetchApi(path)
|
|
61
|
+
.then(async (response) => {
|
|
62
|
+
if (!response.ok)
|
|
63
|
+
throw new Error(`Failed to load plugin value (${response.status})`);
|
|
64
|
+
const body = (await response.json());
|
|
65
|
+
if (!cancelled)
|
|
66
|
+
setValue(body.value);
|
|
67
|
+
})
|
|
68
|
+
.catch((err) => {
|
|
69
|
+
if (!cancelled)
|
|
70
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
71
|
+
});
|
|
72
|
+
return () => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
};
|
|
75
|
+
}, [fetchApi, path]);
|
|
76
|
+
function onChange(next) {
|
|
77
|
+
setValue(next); // optimistic — the view should feel instant
|
|
78
|
+
fetchApi(path, {
|
|
79
|
+
method: "PUT",
|
|
80
|
+
headers: { "Content-Type": "application/json" },
|
|
81
|
+
body: JSON.stringify({ value: next }),
|
|
82
|
+
})
|
|
83
|
+
.then(async (response) => {
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
// S278b (D5): a restriction's refusal says why, from its body.
|
|
86
|
+
const refusal = response.status === 403 ? refusalSentence(await response.json().catch(() => null)) : null;
|
|
87
|
+
throw new Error(refusal ?? `Failed to save plugin value (${response.status})`);
|
|
88
|
+
}
|
|
89
|
+
setError(null);
|
|
90
|
+
})
|
|
91
|
+
.catch((err) => {
|
|
92
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return (_jsxs(_Fragment, { children: [error && (_jsx("p", { role: "alert", className: "text-xs text-danger-600", children: error })), _jsx(PluginValueProvider, { value: value, onChange: onChange, children: children })] }));
|
|
96
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export type PluginColumnType = "text" | "integer" | "boolean" | "json" | "timestamp";
|
|
2
|
+
export interface PluginColumnSchema {
|
|
3
|
+
name: string;
|
|
4
|
+
type: PluginColumnType;
|
|
5
|
+
primaryKey?: boolean;
|
|
6
|
+
notNull?: boolean;
|
|
7
|
+
unique?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface PluginIndexSchema {
|
|
10
|
+
columns: string[];
|
|
11
|
+
unique?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface PluginTableSchema {
|
|
14
|
+
tableName: string;
|
|
15
|
+
columns: PluginColumnSchema[];
|
|
16
|
+
indexes?: PluginIndexSchema[];
|
|
17
|
+
}
|
|
18
|
+
export interface StructuredQueryBuilder<T = Record<string, unknown>> extends PromiseLike<T[]> {
|
|
19
|
+
where(conditions: Record<string, unknown>): this;
|
|
20
|
+
orderBy(column: string, direction?: "asc" | "desc"): this;
|
|
21
|
+
limit(n: number): this;
|
|
22
|
+
paginate(options: {
|
|
23
|
+
cursor?: string;
|
|
24
|
+
limit: number;
|
|
25
|
+
}): this;
|
|
26
|
+
}
|
|
27
|
+
export interface StructuredStorageTransaction {
|
|
28
|
+
insert(tableName: string, data: Record<string, unknown>): Promise<void>;
|
|
29
|
+
update(tableName: string, where: Record<string, unknown>, data: Record<string, unknown>): Promise<number>;
|
|
30
|
+
delete(tableName: string, where: Record<string, unknown>): Promise<number>;
|
|
31
|
+
query<T = Record<string, unknown>>(tableName: string): StructuredQueryBuilder<T>;
|
|
32
|
+
}
|
|
33
|
+
export interface ScopedStructuredStorage {
|
|
34
|
+
defineTable(schema: PluginTableSchema): Promise<void>;
|
|
35
|
+
insert(tableName: string, data: Record<string, unknown>): Promise<void>;
|
|
36
|
+
update(tableName: string, where: Record<string, unknown>, data: Record<string, unknown>): Promise<number>;
|
|
37
|
+
delete(tableName: string, where: Record<string, unknown>): Promise<number>;
|
|
38
|
+
query<T = Record<string, unknown>>(tableName: string): StructuredQueryBuilder<T>;
|
|
39
|
+
transaction(fn: (tx: StructuredStorageTransaction) => Promise<void>): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
import type { Entitlement } from "./entitlement-types.js";
|
|
42
|
+
export interface PublishedContent {
|
|
43
|
+
id: string;
|
|
44
|
+
documentTypeId: string;
|
|
45
|
+
data: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
export interface PluginApiRouteContext {
|
|
48
|
+
structuredStorage: ScopedStructuredStorage;
|
|
49
|
+
/** Null if the content id doesn't exist OR isn't published (a
|
|
50
|
+
* draft-only save never satisfies this) — deliberately conflates
|
|
51
|
+
* "missing" and "not yet purchasable," since callers treat both the
|
|
52
|
+
* same way. */
|
|
53
|
+
getPublishedContent(contentId: string): Promise<PublishedContent | null>;
|
|
54
|
+
/** S284b: the host's latest licence verdict for this plugin, exactly as
|
|
55
|
+
* the marketplace signed it (`kind: "verdict"`), `kind: "exempt"` on a
|
|
56
|
+
* non-production install, `kind: "none"` when the host holds no verdict.
|
|
57
|
+
* Check it with `requireEntitlement` from
|
|
58
|
+
* `@kardalum/plugin-sdk/entitlement`; a thrown EntitlementError
|
|
59
|
+
* answers 403 `{ code: "entitlement", reason }`. */
|
|
60
|
+
entitlement: Entitlement;
|
|
61
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Local, SDK-owned duplicates of packages/db-adapter's structured-storage
|
|
2
|
+
// shapes and apps/server's StructuredStorageAPI/StructuredQueryBuilder/
|
|
3
|
+
// StructuredStorageTransaction classes — never imported directly, since
|
|
4
|
+
// @kardalum/plugin-sdk is a published package that must not depend on
|
|
5
|
+
// unpublished adapter/server internals (same reasoning manifest.ts's
|
|
6
|
+
// DatabaseDialect duplication already uses). TypeScript's structural
|
|
7
|
+
// typing means the real apps/server classes satisfy these interfaces
|
|
8
|
+
// without any cast, as long as their member shapes match (they do —
|
|
9
|
+
// this is exactly the public contract apps/docs/src/content/docs/v1/reference/storage.md
|
|
10
|
+
// already documents).
|
|
11
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tailwindTheme } from "@kardalum/design-tokens";
|
package/dist/tailwind.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// The `@kardalum/plugin-sdk/tailwind` subpath: the Tailwind theme preset
|
|
2
|
+
// generated from the design tokens, for a plugin whose UI is styled with
|
|
3
|
+
// Tailwind. Use it as `theme` in the plugin's tailwind.config, the way the
|
|
4
|
+
// admin does, so the plugin's classes map to the same CSS variables.
|
|
5
|
+
export { tailwindTheme } from "@kardalum/design-tokens";
|