@kardalum/plugin-sdk 0.0.0-stage → 0.15.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 +108 -0
- package/LICENSE +202 -0
- package/README.md +70 -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 +99 -0
- package/dist/capabilities.js +363 -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 +93 -0
- package/dist/license-verdict-keys.d.ts +18 -0
- package/dist/license-verdict-keys.js +22 -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 +408 -0
- package/dist/manifest-schema.js +774 -0
- package/dist/manifest.d.ts +546 -0
- package/dist/manifest.js +86 -0
- package/dist/media/media-picker.d.ts +39 -0
- package/dist/media/media-picker.js +438 -0
- package/dist/media/upload-error.d.ts +12 -0
- package/dist/media/upload-error.js +30 -0
- package/dist/plugin-context.d.ts +75 -0
- package/dist/plugin-context.js +70 -0
- package/dist/plugin-screen-context.d.ts +40 -0
- package/dist/plugin-screen-context.js +16 -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 +387 -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 +5 -0
- package/node_modules/@kardalum/api-schemas/dist/api-error.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +36 -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 +537 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +353 -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 +256 -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 +151 -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 +302 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +97 -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 +36 -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 +296 -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 +102 -0
- package/node_modules/@kardalum/api-schemas/dist/index.js +58 -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/marketplace-listing-api.schema.d.ts +381 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +167 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +214 -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 +169 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.js +80 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +134 -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-management-api.schema.d.ts +369 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +393 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +87 -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 +306 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +328 -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 +90 -0
- package/node_modules/@kardalum/api-schemas/dist/role.schema.js +69 -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/setup-api.schema.d.ts +108 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +93 -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 +43 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.js +25 -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 +89 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +68 -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/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 +11 -0
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -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/sample-content.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/sample-content.js +17 -0
- package/node_modules/@kardalum/plugin-package/dist/types.d.ts +45 -0
- package/node_modules/@kardalum/plugin-package/dist/types.js +1 -0
- package/node_modules/@kardalum/plugin-package/package.json +49 -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 +86 -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,104 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from "react";
|
|
3
|
+
import { Button, Input, PropertyField } from "@kardalum/ui";
|
|
4
|
+
import { usePluginSettings, usePluginSettingsValue } from "../plugin-context.js";
|
|
5
|
+
const MediaFileContext = createContext({ file: null, replace: null });
|
|
6
|
+
// The context value is rebuilt on every render rather than memoized: both
|
|
7
|
+
// halves of it are objects the host owns, and a host that passes fresh
|
|
8
|
+
// literals (the media item screen does) would defeat a memo anyway. The
|
|
9
|
+
// only consumers are the two file upload views, which re-render with the
|
|
10
|
+
// host regardless.
|
|
11
|
+
export function MediaFileProvider({ file, replace, children }) {
|
|
12
|
+
return (_jsx(MediaFileContext.Provider, { value: { file, replace: replace ?? null }, children: children }));
|
|
13
|
+
}
|
|
14
|
+
export function useMediaFile() {
|
|
15
|
+
return useContext(MediaFileContext).file;
|
|
16
|
+
}
|
|
17
|
+
export function useMediaFileReplace() {
|
|
18
|
+
return useContext(MediaFileContext).replace;
|
|
19
|
+
}
|
|
20
|
+
// Plain bytes with thousands separators ("812,000 bytes") rather than a
|
|
21
|
+
// KB/MB conversion: exact and unambiguous, and this does not claim any
|
|
22
|
+
// locale-specific unit convention beyond the separators toLocaleString()
|
|
23
|
+
// already applies.
|
|
24
|
+
function formatSize(size) {
|
|
25
|
+
return `${size.toLocaleString()} bytes`;
|
|
26
|
+
}
|
|
27
|
+
function acceptedExtensionsText(extensions) {
|
|
28
|
+
return extensions && extensions.length > 0 ? `Accepts: ${extensions.join(", ")}` : "Accepts any file type.";
|
|
29
|
+
}
|
|
30
|
+
// The picker, and only the picker. Piece A shipped this field with no
|
|
31
|
+
// Replace control on purpose, because versioned replacement did not exist
|
|
32
|
+
// and a disabled button is an empty promise; piece B built it, so the
|
|
33
|
+
// control arrives with it (S234b Task 6, mockup screen 2's file card).
|
|
34
|
+
function ReplaceControl({ replace, extensions, }) {
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
|
+
const buttonRef = useRef(null);
|
|
37
|
+
// The OS dialog offers what this field would accept, rather than
|
|
38
|
+
// everything and a refusal afterwards. Extensions are stored bare
|
|
39
|
+
// ("jpg"), and the accept attribute wants the dot.
|
|
40
|
+
const accept = extensions && extensions.length > 0 ? extensions.map((ext) => `.${ext}`).join(",") : undefined;
|
|
41
|
+
return (_jsxs("div", { className: "mt-2 flex items-center gap-2", children: [_jsx("input", { ref: inputRef, type: "file", className: "hidden", accept: accept, "aria-label": replace.label,
|
|
42
|
+
// Disabled with the button, not just behind it: a replace in
|
|
43
|
+
// flight must not be joined by a second one, and the button is
|
|
44
|
+
// only one of the ways this input can be reached.
|
|
45
|
+
disabled: replace.busy, onChange: (event) => {
|
|
46
|
+
const picked = event.target.files?.[0];
|
|
47
|
+
// Cleared so choosing the SAME file twice still fires a change:
|
|
48
|
+
// a replace that was cancelled at the confirm has to be
|
|
49
|
+
// repeatable without picking something else first.
|
|
50
|
+
event.target.value = "";
|
|
51
|
+
if (!picked)
|
|
52
|
+
return;
|
|
53
|
+
// Focus goes back to the button BEFORE the host is told. The host
|
|
54
|
+
// opens a confirm dialog, and Radix restores focus to whatever
|
|
55
|
+
// was focused when the dialog mounted; a hidden input is not
|
|
56
|
+
// somewhere a person can be left.
|
|
57
|
+
buttonRef.current?.focus();
|
|
58
|
+
replace.onReplace(picked);
|
|
59
|
+
} }), _jsx(Button, { ref: buttonRef, type: "button", variant: "outline", size: "sm", disabled: replace.busy, onClick: () => inputRef.current?.click(), children: replace.label })] }));
|
|
60
|
+
}
|
|
61
|
+
// Shared by the input and read-only views: the current file's name and
|
|
62
|
+
// size, and what this field accepts. The field still stores NO value of
|
|
63
|
+
// its own, so the Replace control below is not an editor for one: it hands
|
|
64
|
+
// the host a file and the host writes a new version of the media row.
|
|
65
|
+
function FileUploadDisplay({ replaceable }) {
|
|
66
|
+
const settings = usePluginSettings();
|
|
67
|
+
const file = useMediaFile();
|
|
68
|
+
const replace = useMediaFileReplace();
|
|
69
|
+
return (_jsxs("div", { className: "flex flex-col gap-1 text-sm text-text-primary", children: [file ? (_jsxs(_Fragment, { children: [_jsx("p", { className: "font-medium", dir: "auto", children: file.filename }), _jsx("p", { className: "text-xs text-text-secondary", children: formatSize(file.size) })] })) : (_jsx("p", { className: "text-text-secondary", children: "No file yet." })), _jsx("p", { className: "text-xs text-text-secondary", children: acceptedExtensionsText(settings.extensions) }), replaceable && replace && (_jsx(ReplaceControl, { replace: replace, extensions: settings.extensions }))] }));
|
|
70
|
+
}
|
|
71
|
+
export function FileUploadInputView() {
|
|
72
|
+
return _jsx(FileUploadDisplay, { replaceable: true });
|
|
73
|
+
}
|
|
74
|
+
// No Replace here: read-only means read-only, whatever the host offers.
|
|
75
|
+
export function FileUploadReadOnlyView() {
|
|
76
|
+
return _jsx(FileUploadDisplay, { replaceable: false });
|
|
77
|
+
}
|
|
78
|
+
// Rendered by the Data Types editor only: a settings-EDITING view, same
|
|
79
|
+
// pattern as ImageSettingsView (image-view.tsx). Extensions are stored
|
|
80
|
+
// bare and lowercase with no dot ("jpg", never ".jpg" or "image/jpeg"),
|
|
81
|
+
// so the comma-separated text is normalized to that shape on every
|
|
82
|
+
// change, the same idiom ImageSettingsView uses for acceptedTypes.
|
|
83
|
+
//
|
|
84
|
+
// THE MAX FILE SIZE CONTROL IS BACK, and it is back because the rule now
|
|
85
|
+
// exists (S234d Task 8). Piece A shipped this control over nothing: an
|
|
86
|
+
// admin could set a 5MB limit, upload a 40MB file and be told nothing, so
|
|
87
|
+
// the final fix wave took the control out rather than leave it standing
|
|
88
|
+
// for a promise the product did not keep, exactly as the same plan refused
|
|
89
|
+
// to ship a disabled Replace button here. MediaService now enforces this
|
|
90
|
+
// value on upload AND on replace, server-side, which is where the bytes
|
|
91
|
+
// arrive, so the control is a setting a person can act on again.
|
|
92
|
+
//
|
|
93
|
+
// Blank is NO limit rather than a limit of zero: the schema's member is
|
|
94
|
+
// optional and the server reads an absent one as "anything fits".
|
|
95
|
+
export function FileUploadSettingsView() {
|
|
96
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
97
|
+
return (_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(PropertyField, { label: "Accepted extensions", htmlFor: "file-upload-settings-extensions", helpText: "Comma-separated extensions, no dot, e.g. jpg,png,pdf. Leave blank to accept any file.", children: _jsx(Input, { id: "file-upload-settings-extensions", value: (settings.extensions ?? []).join(","), onChange: (e) => {
|
|
98
|
+
const extensions = e.target.value
|
|
99
|
+
.split(",")
|
|
100
|
+
.map((ext) => ext.trim().toLowerCase())
|
|
101
|
+
.filter((ext) => ext.length > 0);
|
|
102
|
+
onChange({ ...settings, extensions });
|
|
103
|
+
} }) }), _jsx(PropertyField, { label: "Max file size (bytes)", htmlFor: "file-upload-settings-max-size", helpText: "e.g. 5000000 for ~5MB. Leave blank for no limit. Enforced on upload and on replace.", children: _jsx(Input, { id: "file-upload-settings-max-size", type: "number", min: 1, value: settings.maxSizeBytes ?? "", onChange: (e) => onChange({ ...settings, maxSizeBytes: e.target.value === "" ? undefined : Number(e.target.value) }) }) })] }));
|
|
104
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface HtmlCodeEditorProps {
|
|
2
|
+
value: string;
|
|
3
|
+
onChange: (value: string) => void;
|
|
4
|
+
readOnly?: boolean;
|
|
5
|
+
fieldId?: string;
|
|
6
|
+
ariaLabelledBy?: string;
|
|
7
|
+
ariaDescribedBy?: string;
|
|
8
|
+
ariaInvalid?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function HtmlCodeEditor({ value, onChange, readOnly, fieldId, ariaLabelledBy, ariaDescribedBy, ariaInvalid, }: HtmlCodeEditorProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { Annotation, Compartment, EditorState } from "@codemirror/state";
|
|
4
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
5
|
+
import { html } from "@codemirror/lang-html";
|
|
6
|
+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
7
|
+
import { bracketMatching, defaultHighlightStyle, indentOnInput, syntaxHighlighting } from "@codemirror/language";
|
|
8
|
+
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
|
|
9
|
+
// Tags a dispatch made by the value-sync effect below so the update
|
|
10
|
+
// listener can tell "we just replaced the doc from a new `value` prop"
|
|
11
|
+
// apart from a real user edit and skip the onChange echo — same pattern
|
|
12
|
+
// (and same rationale) as admin-ui's code-editor.tsx.
|
|
13
|
+
const externalSync = Annotation.define();
|
|
14
|
+
export function HtmlCodeEditor({ value, onChange, readOnly = false, fieldId, ariaLabelledBy, ariaDescribedBy, ariaInvalid, }) {
|
|
15
|
+
const containerRef = useRef(null);
|
|
16
|
+
const viewRef = useRef(null);
|
|
17
|
+
const lastKnownValueRef = useRef(value);
|
|
18
|
+
const onChangeRef = useRef(onChange);
|
|
19
|
+
onChangeRef.current = onChange;
|
|
20
|
+
const readOnlyCompartmentRef = useRef(null);
|
|
21
|
+
if (readOnlyCompartmentRef.current === null)
|
|
22
|
+
readOnlyCompartmentRef.current = new Compartment();
|
|
23
|
+
const initialValueRef = useRef(value);
|
|
24
|
+
const initialReadOnlyRef = useRef(readOnly);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
const container = containerRef.current;
|
|
27
|
+
if (!container)
|
|
28
|
+
return;
|
|
29
|
+
const updateListener = EditorView.updateListener.of((update) => {
|
|
30
|
+
if (!update.docChanged)
|
|
31
|
+
return;
|
|
32
|
+
const next = update.state.doc.toString();
|
|
33
|
+
lastKnownValueRef.current = next;
|
|
34
|
+
if (update.transactions.some((tr) => tr.annotation(externalSync)))
|
|
35
|
+
return;
|
|
36
|
+
onChangeRef.current(next);
|
|
37
|
+
});
|
|
38
|
+
const state = EditorState.create({
|
|
39
|
+
doc: initialValueRef.current,
|
|
40
|
+
extensions: [
|
|
41
|
+
html(),
|
|
42
|
+
history(),
|
|
43
|
+
closeBrackets(),
|
|
44
|
+
bracketMatching(),
|
|
45
|
+
indentOnInput(),
|
|
46
|
+
autocompletion(),
|
|
47
|
+
syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
|
|
48
|
+
keymap.of([...closeBracketsKeymap, ...defaultKeymap, ...historyKeymap, ...completionKeymap]),
|
|
49
|
+
readOnlyCompartmentRef.current.of(EditorView.editable.of(!initialReadOnlyRef.current)),
|
|
50
|
+
EditorView.lineWrapping,
|
|
51
|
+
// ProseMirror-style aria wiring (see rich-text-view.tsx's own
|
|
52
|
+
// comment on the same idiom): CodeMirror's editable surface is
|
|
53
|
+
// also a bare contenteditable div with no role of its own.
|
|
54
|
+
EditorView.contentAttributes.of({
|
|
55
|
+
role: "textbox",
|
|
56
|
+
"aria-multiline": "true",
|
|
57
|
+
...(fieldId ? { id: fieldId } : {}),
|
|
58
|
+
...(ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {}),
|
|
59
|
+
...(ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {}),
|
|
60
|
+
...(ariaInvalid ? { "aria-invalid": "true" } : {}),
|
|
61
|
+
}),
|
|
62
|
+
updateListener,
|
|
63
|
+
],
|
|
64
|
+
});
|
|
65
|
+
const view = new EditorView({ state, parent: container });
|
|
66
|
+
viewRef.current = view;
|
|
67
|
+
return () => {
|
|
68
|
+
view.destroy();
|
|
69
|
+
viewRef.current = null;
|
|
70
|
+
};
|
|
71
|
+
// Mount-only by design — see admin-ui's code-editor.tsx for the same
|
|
72
|
+
// convention and rationale.
|
|
73
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
74
|
+
}, []);
|
|
75
|
+
// Sync an externally-changed `value` into the view, guarded against
|
|
76
|
+
// feedback from our own updateListener echoing the same string back.
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
const view = viewRef.current;
|
|
79
|
+
if (!view)
|
|
80
|
+
return;
|
|
81
|
+
if (value === lastKnownValueRef.current)
|
|
82
|
+
return;
|
|
83
|
+
const currentDoc = view.state.doc.toString();
|
|
84
|
+
lastKnownValueRef.current = value;
|
|
85
|
+
if (value === currentDoc)
|
|
86
|
+
return;
|
|
87
|
+
view.dispatch({
|
|
88
|
+
changes: { from: 0, to: currentDoc.length, insert: value },
|
|
89
|
+
annotations: externalSync.of(true),
|
|
90
|
+
});
|
|
91
|
+
}, [value]);
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
const view = viewRef.current;
|
|
94
|
+
if (!view)
|
|
95
|
+
return;
|
|
96
|
+
view.dispatch({
|
|
97
|
+
effects: readOnlyCompartmentRef.current.reconfigure(EditorView.editable.of(!readOnly)),
|
|
98
|
+
});
|
|
99
|
+
}, [readOnly]);
|
|
100
|
+
return _jsx("div", { ref: containerRef, className: "cm-kardalum-editor rounded-md border border-border-default" });
|
|
101
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { lazy, Suspense } from "react";
|
|
3
|
+
import { PropertyField, Switch, usePropertyFieldControl } from "@kardalum/ui";
|
|
4
|
+
import { usePluginSettingsValue, usePluginValue } from "../plugin-context.js";
|
|
5
|
+
// The only React.lazy() boundary in this package's views so far — mirrors
|
|
6
|
+
// apps/admin-ui/src/editor/lazy-code-editor.tsx's split (html-code-editor.js
|
|
7
|
+
// pulls in the whole @codemirror/* graph, ~six packages' worth, which must
|
|
8
|
+
// stay out of whatever chunk loads this file / built-ins.tsx's static
|
|
9
|
+
// registration). Importing straight from './html-code-editor.js' anywhere
|
|
10
|
+
// else would defeat the split, so this file is the only allowed entry
|
|
11
|
+
// point for the com.kardalum.html editor.
|
|
12
|
+
const HtmlCodeEditorLazy = lazy(() => import("./html-code-editor.js").then((module) => ({ default: module.HtmlCodeEditor })));
|
|
13
|
+
// Same role="status" + aria-hidden placeholder pattern as
|
|
14
|
+
// lazy-code-editor.tsx's CodeEditorFallback — no react-i18next here (this
|
|
15
|
+
// package's views deliberately hardcode English strings today, see
|
|
16
|
+
// built-ins.tsx's TextReadOnlyView/ImageInputView precedent).
|
|
17
|
+
function HtmlEditorFallback() {
|
|
18
|
+
return (_jsx("div", { role: "status", "aria-label": "Loading code editor\u2026", children: _jsx("div", { "aria-hidden": "true", className: "h-40 w-full animate-pulse rounded-md border border-border-default bg-background-subtle" }) }));
|
|
19
|
+
}
|
|
20
|
+
// The Trusted setting has no bearing on how this field is EDITED (both
|
|
21
|
+
// modes get the same CodeMirror surface) — only on how it's RENDERED
|
|
22
|
+
// (render-context.ts's html branch, S197 Task 8) — so neither the input
|
|
23
|
+
// nor the readOnly view reads settings at all, matching the datatype's
|
|
24
|
+
// posture that `trusted` is purely a render-pipeline decision.
|
|
25
|
+
function HtmlEditor({ editable }) {
|
|
26
|
+
const { value, onChange } = usePluginValue();
|
|
27
|
+
const field = usePropertyFieldControl();
|
|
28
|
+
const editorProps = {
|
|
29
|
+
value: value ?? "",
|
|
30
|
+
onChange,
|
|
31
|
+
readOnly: !editable,
|
|
32
|
+
fieldId: field.id,
|
|
33
|
+
ariaLabelledBy: field["aria-labelledby"],
|
|
34
|
+
ariaDescribedBy: field["aria-describedby"],
|
|
35
|
+
ariaInvalid: Boolean(field["aria-invalid"]),
|
|
36
|
+
};
|
|
37
|
+
return (_jsx(Suspense, { fallback: _jsx(HtmlEditorFallback, {}), children: _jsx(HtmlCodeEditorLazy, { ...editorProps }) }));
|
|
38
|
+
}
|
|
39
|
+
export function HtmlInputView() {
|
|
40
|
+
return _jsx(HtmlEditor, { editable: true });
|
|
41
|
+
}
|
|
42
|
+
export function HtmlReadOnlyView() {
|
|
43
|
+
return _jsx(HtmlEditor, { editable: false });
|
|
44
|
+
}
|
|
45
|
+
// Rendered by the Data Types editor only (data-type-editor.tsx) — a
|
|
46
|
+
// settings-EDITING view, same usePluginSettingsValue() convention as
|
|
47
|
+
// TextSettingsView/ImageSettingsView in built-ins.tsx. The help copy is
|
|
48
|
+
// spec-binding verbatim text (S197 spec §7 / task brief), not a paraphrase
|
|
49
|
+
// — do not reword it.
|
|
50
|
+
export function HtmlSettingsView() {
|
|
51
|
+
const { value: settings, onChange } = usePluginSettingsValue();
|
|
52
|
+
return (_jsx("div", { className: "flex flex-col gap-4", children: _jsx(PropertyField, { label: "Trusted", htmlFor: "html-settings-trusted", helpText: "Trusted HTML renders exactly as written: including scripts. Only enable for fields edited by people you'd let deploy code.", children: _jsx(Switch, { id: "html-settings-trusted", checked: settings.trusted === true, onCheckedChange: (checked) => onChange({ ...settings, trusted: checked === true }) }) }) }));
|
|
53
|
+
}
|