@kardalum/plugin-sdk 0.19.0 → 0.21.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 +281 -0
- package/README.md +19 -0
- package/dist/admin-section-registry.d.ts +48 -1
- package/dist/admin-section-registry.js +90 -0
- package/dist/built-in-editor-ids.d.ts +1 -1
- package/dist/built-in-editor-ids.js +2 -20
- package/dist/built-in-settings-schemas.d.ts +10 -0
- package/dist/built-in-settings-schemas.js +86 -0
- package/dist/built-in-value-schemas.js +35 -0
- package/dist/built-ins.js +38 -7
- package/dist/capabilities.d.ts +11 -1
- package/dist/capabilities.js +101 -4
- package/dist/cli.d.ts +66 -0
- package/dist/cli.js +22 -0
- package/dist/consent-entry.d.ts +11 -0
- package/dist/consent-entry.js +18 -0
- package/dist/content-library.d.ts +102 -0
- package/dist/content-library.js +15 -0
- package/dist/content-list-extensions.d.ts +50 -0
- package/dist/content-list-extensions.js +11 -0
- package/dist/content-picker/page-picker-sheet.d.ts +15 -0
- package/dist/content-picker/page-picker-sheet.js +105 -0
- package/dist/content-picker/page-picker.d.ts +18 -0
- package/dist/content-picker/page-picker.js +20 -0
- package/dist/content-picker/page-tree.d.ts +25 -0
- package/dist/content-picker/page-tree.js +132 -0
- package/dist/data-type-plugin.d.ts +7 -1
- package/dist/datatype-validation.d.ts +4 -9
- package/dist/datatype-validation.js +147 -1
- package/dist/datatypes-entry.d.ts +1 -0
- package/dist/datatypes-entry.js +2 -0
- package/dist/entitlement-entry.d.ts +1 -1
- package/dist/entitlement-entry.js +1 -1
- package/dist/entitlement-gate.d.ts +14 -0
- package/dist/entitlement-gate.js +64 -7
- package/dist/entitlement-plan.d.ts +6 -0
- package/dist/entitlement-plan.js +10 -0
- package/dist/entitlement-types.d.ts +53 -12
- package/dist/entitlement.d.ts +31 -4
- package/dist/entitlement.js +58 -17
- package/dist/hook-entry.d.ts +5 -0
- package/dist/hook-entry.js +30 -0
- package/dist/host-entry.d.ts +7 -1
- package/dist/host-entry.js +14 -1
- package/dist/index.d.ts +67 -7
- package/dist/index.js +94 -6
- package/dist/mail.d.ts +34 -0
- package/dist/mail.js +1 -0
- package/dist/manifest-entry.d.ts +47 -4
- package/dist/manifest-entry.js +63 -2
- package/dist/manifest-schema.d.ts +993 -40
- package/dist/manifest-schema.js +516 -26
- package/dist/manifest.d.ts +1186 -62
- package/dist/manifest.js +8 -4
- package/dist/media/media-picker.js +31 -18
- package/dist/media/upload-error.d.ts +5 -1
- package/dist/media/upload-error.js +14 -2
- package/dist/media-library.d.ts +32 -0
- package/dist/media-library.js +15 -0
- package/dist/nested-field-host.d.ts +76 -0
- package/dist/nested-field-host.js +90 -0
- package/dist/notify.d.ts +12 -4
- package/dist/notify.js +1 -1
- package/dist/outbound.d.ts +47 -0
- package/dist/outbound.js +1 -0
- package/dist/plugin-context.d.ts +52 -0
- package/dist/plugin-context.js +27 -0
- package/dist/plugin-permissions.d.ts +18 -0
- package/dist/plugin-permissions.js +25 -0
- package/dist/plugin-screen-context.d.ts +262 -9
- package/dist/plugin-screen-context.js +56 -0
- package/dist/providers.d.ts +313 -0
- package/dist/providers.js +74 -0
- package/dist/read-all-pages.d.ts +5 -0
- package/dist/read-all-pages.js +3 -2
- package/dist/render-page.d.ts +15 -0
- package/dist/render-page.js +20 -0
- package/dist/richtext/block-panel.d.ts +12 -1
- package/dist/richtext/block-panel.js +36 -25
- package/dist/richtext/button-view.d.ts +11 -0
- package/dist/richtext/button-view.js +45 -0
- package/dist/richtext/content-guard.d.ts +4 -0
- package/dist/richtext/content-guard.js +27 -0
- package/dist/richtext/editor-handle.d.ts +34 -0
- package/dist/richtext/editor-handle.js +225 -0
- package/dist/richtext/extensions.d.ts +6 -0
- package/dist/richtext/extensions.js +16 -0
- package/dist/richtext/insert-menu.d.ts +6 -1
- package/dist/richtext/insert-menu.js +45 -22
- package/dist/richtext/item-attributes.d.ts +6 -0
- package/dist/richtext/item-attributes.js +19 -0
- package/dist/richtext/item-panel.d.ts +25 -0
- package/dist/richtext/item-panel.js +118 -0
- package/dist/richtext/item-view.d.ts +58 -0
- package/dist/richtext/item-view.js +172 -0
- package/dist/richtext/mark-form.d.ts +10 -0
- package/dist/richtext/mark-form.js +38 -0
- package/dist/richtext/paste-choice.d.ts +9 -0
- package/dist/richtext/paste-choice.js +13 -0
- package/dist/richtext/plugin-items.d.ts +72 -0
- package/dist/richtext/plugin-items.js +562 -0
- package/dist/richtext/plugin-mark-tooltips.d.ts +5 -0
- package/dist/richtext/plugin-mark-tooltips.js +44 -0
- package/dist/richtext/plugin-toolbar.d.ts +57 -0
- package/dist/richtext/plugin-toolbar.js +186 -0
- package/dist/richtext/rich-item-icons.d.ts +5 -0
- package/dist/richtext/rich-item-icons.js +42 -0
- package/dist/richtext/rich-items.d.ts +42 -0
- package/dist/richtext/rich-items.js +68 -0
- package/dist/richtext/rich-text-view-host.d.ts +24 -0
- package/dist/richtext/rich-text-view-host.js +11 -0
- package/dist/richtext/style-listbox.js +6 -4
- package/dist/richtext/toolbar-button.d.ts +16 -0
- package/dist/richtext/toolbar-button.js +9 -0
- package/dist/richtext/url-paste.d.ts +20 -0
- package/dist/richtext/url-paste.js +82 -0
- package/dist/richtext-html-entry.d.ts +5 -0
- package/dist/richtext-html-entry.js +11 -0
- package/dist/sdk-strings.d.ts +344 -0
- package/dist/sdk-strings.js +411 -0
- package/dist/sealing.d.ts +14 -0
- package/dist/sealing.js +1 -0
- package/dist/service-contract.d.ts +17 -0
- package/dist/service-contract.js +39 -0
- package/dist/services.d.ts +114 -0
- package/dist/services.js +1 -0
- package/dist/simple-storage-value-provider.js +24 -24
- package/dist/structured-storage-types.d.ts +429 -9
- package/dist/tailwind.js +10 -5
- package/dist/template-reads.d.ts +16 -0
- package/dist/template-reads.js +21 -0
- package/dist/testing-entry.d.ts +38 -0
- package/dist/testing-entry.js +173 -0
- package/dist/text-entry.d.ts +1 -0
- package/dist/text-entry.js +7 -0
- package/dist/tokens/system-dark.css +1 -0
- package/dist/tokens/tailwind-theme.css +7 -0
- package/dist/tokens/tokens.css +19 -3
- package/dist/tokens/tokens.json +13 -4
- package/dist/uploads.d.ts +43 -0
- package/dist/uploads.js +1 -0
- package/dist/user-library.d.ts +51 -0
- package/dist/user-library.js +15 -0
- package/dist/view-helpers.d.ts +18 -0
- package/dist/view-helpers.js +64 -0
- package/dist/views/asset-view.js +4 -1
- package/dist/views/content-list-preview.js +3 -1
- package/dist/views/content-list-settings-view.js +11 -7
- package/dist/views/content-list-view.d.ts +5 -3
- package/dist/views/content-list-view.js +243 -40
- package/dist/views/content-picker-view.d.ts +3 -0
- package/dist/views/content-picker-view.js +143 -0
- package/dist/views/crop-view.d.ts +4 -6
- package/dist/views/crop-view.js +22 -13
- package/dist/views/date-range-view.js +4 -1
- package/dist/views/file-upload-view.d.ts +5 -7
- package/dist/views/file-upload-view.js +16 -7
- package/dist/views/group-view.d.ts +8 -0
- package/dist/views/group-view.js +123 -0
- package/dist/views/html-view.js +7 -6
- package/dist/views/image-view.js +37 -19
- package/dist/views/link-view.d.ts +3 -0
- package/dist/views/link-view.js +150 -0
- package/dist/views/options-list-view.d.ts +3 -0
- package/dist/views/options-list-view.js +104 -0
- package/dist/views/repeatable-list-view.d.ts +3 -0
- package/dist/views/repeatable-list-view.js +113 -0
- package/dist/views/rich-text-view.d.ts +2 -0
- package/dist/views/rich-text-view.js +208 -35
- package/dist/views/suggest-key.d.ts +17 -0
- package/dist/views/suggest-key.js +55 -0
- package/dist/views/unreadable-rich-text.d.ts +17 -0
- package/dist/views/unreadable-rich-text.js +40 -0
- package/dist/visitors.d.ts +81 -0
- package/dist/visitors.js +1 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.d.ts +21 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-hosts.js +39 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-app-redirects.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.d.ts +334 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-connections.schema.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/ai-context.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/api-key-api.schema.js +5 -0
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.d.ts +11 -1
- package/node_modules/@kardalum/api-schemas/dist/audit-api.schema.js +4 -2
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/built-in-editor-ids.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.d.ts +65 -0
- package/node_modules/@kardalum/api-schemas/dist/capability-detail.js +144 -0
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.d.ts +115 -3
- package/node_modules/@kardalum/api-schemas/dist/content-api.schema.js +58 -11
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.d.ts +137 -2
- package/node_modules/@kardalum/api-schemas/dist/content-list.schema.js +178 -2
- package/node_modules/@kardalum/api-schemas/dist/content-path.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-path.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/content-reads.schema.js +234 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.d.ts +50 -0
- package/node_modules/@kardalum/api-schemas/dist/content-search.schema.js +42 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/content-summary.schema.js +19 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/content-unpublish.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/content.schema.js +10 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/contract-cancel.schema.js +86 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/contribution-issues.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/core-actions.d.ts +55 -13
- package/node_modules/@kardalum/api-schemas/dist/core-actions.js +22 -10
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-api.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-config.schema.js +1 -1
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.d.ts +35 -0
- package/node_modules/@kardalum/api-schemas/dist/data-type-issue.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.d.ts +257 -15
- package/node_modules/@kardalum/api-schemas/dist/document-type-api.schema.js +78 -5
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.d.ts +24 -6
- package/node_modules/@kardalum/api-schemas/dist/document-type.schema.js +90 -5
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.d.ts +19 -0
- package/node_modules/@kardalum/api-schemas/dist/experimental-points.js +250 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.d.ts +29 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection-callers.js +31 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/form-protection.js +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/graphql-limits.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/held-embed-words.js +70 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/html-scan.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.d.ts +48 -0
- package/node_modules/@kardalum/api-schemas/dist/html-start-tags.js +381 -0
- package/node_modules/@kardalum/api-schemas/dist/index.d.ts +162 -48
- package/node_modules/@kardalum/api-schemas/dist/index.js +137 -30
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/install-sign-in-switched-off.schema.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/json-depth.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/json-depth.js +20 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/legal-anchors.js +9 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.d.ts +63 -0
- package/node_modules/@kardalum/api-schemas/dist/licensing.schema.js +54 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.d.ts +226 -0
- package/node_modules/@kardalum/api-schemas/dist/mail-rules.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.d.ts +8 -0
- package/node_modules/@kardalum/api-schemas/dist/management-multipart.schema.js +4 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-leaks.schema.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.d.ts +490 -10
- package/node_modules/@kardalum/api-schemas/dist/marketplace-listing-api.schema.js +53 -3
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.d.ts +15 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-package-api.schema.js +14 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.d.ts +131 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-payouts.schema.js +272 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.d.ts +84 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-profile.schema.js +138 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.d.ts +20 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-revocation.schema.js +49 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.d.ts +211 -0
- package/node_modules/@kardalum/api-schemas/dist/marketplace-sites.schema.js +424 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.d.ts +78 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-plugins.schema.js +27 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/mcp-tool-inputs.schema.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.d.ts +38 -0
- package/node_modules/@kardalum/api-schemas/dist/media-api.schema.js +13 -1
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.d.ts +75 -0
- package/node_modules/@kardalum/api-schemas/dist/media-move.schema.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference-api.schema.d.ts +2 -2
- package/node_modules/@kardalum/api-schemas/dist/media-reference.d.ts +2 -0
- package/node_modules/@kardalum/api-schemas/dist/media-reference.js +55 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/media.schema.js +8 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.d.ts +204 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-fields.schema.js +370 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.d.ts +60 -0
- package/node_modules/@kardalum/api-schemas/dist/nested-validation.js +333 -0
- package/node_modules/@kardalum/api-schemas/dist/news.schema.d.ts +5 -5
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.d.ts +1 -2
- package/node_modules/@kardalum/api-schemas/dist/node-access.schema.js +1 -2
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.d.ts +145 -0
- package/node_modules/@kardalum/api-schemas/dist/notification-kinds.js +177 -0
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.d.ts +258 -7
- package/node_modules/@kardalum/api-schemas/dist/notification.schema.js +96 -5
- package/node_modules/@kardalum/api-schemas/dist/page-address.d.ts +10 -0
- package/node_modules/@kardalum/api-schemas/dist/page-address.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.d.ts +87 -0
- package/node_modules/@kardalum/api-schemas/dist/page-audience.schema.js +44 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/password-reset.schema.js +60 -0
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.d.ts +28 -3
- package/node_modules/@kardalum/api-schemas/dist/plan-editor.schema.js +55 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.d.ts +12 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-actions.schema.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.d.ts +11 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-admin-slots.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.d.ts +23 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-caller.js +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.d.ts +76 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-cli-commands.js +316 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.d.ts +44 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-access.js +84 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-content-slots.js +254 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.d.ts +22 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-checks.js +66 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.d.ts +130 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-document.js +173 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.d.ts +16 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-fetch.js +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-schema.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.d.ts +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-contract-types.js +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.d.ts +31 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-data-type-configs.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs-api.schema.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.d.ts +44 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-docs.js +16 -5
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.d.ts +228 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-document-types.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.d.ts +34 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-durable-hooks.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.d.ts +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-editor-extensions.js +126 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.d.ts +24 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-events.js +53 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-field-info.js +51 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.d.ts +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-graphql-fields.js +102 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.d.ts +112 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-guards.js +118 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.d.ts +119 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-held-embeds.js +216 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-https-origin.js +21 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-id-rules.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.d.ts +46 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-install-record.schema.js +41 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.d.ts +304 -2
- package/node_modules/@kardalum/api-schemas/dist/plugin-install.js +220 -6
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.d.ts +138 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-kept-parts.js +110 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.d.ts +26 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-labels.js +29 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.d.ts +32 -8
- package/node_modules/@kardalum/api-schemas/dist/plugin-locales.js +120 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.d.ts +408 -14
- package/node_modules/@kardalum/api-schemas/dist/plugin-management-api.schema.js +307 -23
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-actions.js +61 -3
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.d.ts +40 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-ai.js +139 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.d.ts +23 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-manifest-api-routes.js +37 -1
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.d.ts +25 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-media-access.js +43 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.d.ts +107 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-outbound.js +150 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-package-build.schema.js +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.d.ts +346 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-providers.js +461 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.d.ts +4 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-read-only.schema.js +2 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.d.ts +638 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-rich-text.js +533 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-sealed-values.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.d.ts +68 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-secrets.js +114 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.d.ts +36 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-call.js +32 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.d.ts +193 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-connections.js +123 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.d.ts +209 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-service-declarations.js +372 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.d.ts +90 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-services.js +204 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.d.ts +352 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-settings.js +409 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.d.ts +347 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-extensions.js +976 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.d.ts +69 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-site-requests.js +149 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.d.ts +7 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-storage-api.schema.js +47 -4
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.d.ts +5 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-styles.js +13 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.d.ts +45 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-tasks.js +197 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.d.ts +96 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-uploads.js +185 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.d.ts +213 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-user-accounts.js +131 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.d.ts +54 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-view-kit.js +154 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.d.ts +37 -0
- package/node_modules/@kardalum/api-schemas/dist/plugin-visitor-points.js +124 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.d.ts +9 -0
- package/node_modules/@kardalum/api-schemas/dist/plural-rules.js +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.d.ts +41 -0
- package/node_modules/@kardalum/api-schemas/dist/public-api.schema.js +100 -12
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.d.ts +189 -0
- package/node_modules/@kardalum/api-schemas/dist/refund-request.schema.js +164 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.d.ts +126 -0
- package/node_modules/@kardalum/api-schemas/dist/render-cache.js +263 -0
- package/node_modules/@kardalum/api-schemas/dist/render-editing.d.ts +307 -4
- package/node_modules/@kardalum/api-schemas/dist/render-editing.js +61 -0
- package/node_modules/@kardalum/api-schemas/dist/revenue-view.schema.js +7 -3
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.d.ts +14 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-paste-hosts.js +108 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.d.ts +71 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-shape.js +540 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.d.ts +66 -0
- package/node_modules/@kardalum/api-schemas/dist/rich-text-text.js +394 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.d.ts +82 -0
- package/node_modules/@kardalum/api-schemas/dist/sale-conditions.schema.js +99 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/sample-content.schema.js +28 -0
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.d.ts +201 -1
- package/node_modules/@kardalum/api-schemas/dist/sandbox-attach.schema.js +36 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.d.ts +64 -0
- package/node_modules/@kardalum/api-schemas/dist/security-overview.schema.js +38 -0
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.d.ts +97 -8
- package/node_modules/@kardalum/api-schemas/dist/server-settings-api.schema.js +64 -1
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.d.ts +136 -0
- package/node_modules/@kardalum/api-schemas/dist/setup-api.schema.js +53 -2
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.d.ts +724 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in-steps.js +408 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.d.ts +386 -0
- package/node_modules/@kardalum/api-schemas/dist/sign-in.schema.js +618 -0
- package/node_modules/@kardalum/api-schemas/dist/site-consent.d.ts +77 -0
- package/node_modules/@kardalum/api-schemas/dist/site-consent.js +122 -0
- package/node_modules/@kardalum/api-schemas/dist/snapshot-api.schema.d.ts +3 -3
- package/node_modules/@kardalum/api-schemas/dist/snapshot.schema.d.ts +1 -1
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-duplicate-key.js +26 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.d.ts +70 -0
- package/node_modules/@kardalum/api-schemas/dist/structured-fields.schema.js +188 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.d.ts +33 -0
- package/node_modules/@kardalum/api-schemas/dist/template-api.schema.js +26 -1
- package/node_modules/@kardalum/api-schemas/dist/template.schema.d.ts +1 -0
- package/node_modules/@kardalum/api-schemas/dist/template.schema.js +3 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/transaction-rolled-back.js +29 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.d.ts +13 -0
- package/node_modules/@kardalum/api-schemas/dist/trash-purge.schema.js +6 -0
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.d.ts +72 -1
- package/node_modules/@kardalum/api-schemas/dist/user-api.schema.js +36 -3
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.d.ts +5 -1
- package/node_modules/@kardalum/api-schemas/dist/vendor-service.schema.js +4 -3
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.d.ts +482 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-accounts.js +380 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.d.ts +109 -0
- package/node_modules/@kardalum/api-schemas/dist/visitor-groups.js +62 -0
- package/node_modules/@kardalum/api-schemas/package.json +2 -0
- package/node_modules/@kardalum/design-tokens/dist/build-css.js +15 -1
- package/node_modules/@kardalum/design-tokens/dist/system-dark.css +1 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.css +7 -0
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.d.ts +2 -1
- package/node_modules/@kardalum/design-tokens/dist/tailwind-theme.js +2 -0
- package/node_modules/@kardalum/design-tokens/dist/tokens.css +19 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.d.ts +1 -1
- package/node_modules/@kardalum/design-tokens/dist/tokens.js +18 -3
- package/node_modules/@kardalum/design-tokens/dist/tokens.json +13 -4
- package/node_modules/@kardalum/design-tokens/dist/types.d.ts +5 -1
- package/node_modules/@kardalum/plugin-package/dist/build-reference.d.ts +38 -2
- package/node_modules/@kardalum/plugin-package/dist/build-reference.js +17 -2
- package/node_modules/@kardalum/plugin-package/dist/capabilities.d.ts +17 -10
- package/node_modules/@kardalum/plugin-package/dist/capabilities.js +625 -35
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/client-bundle.js +25 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/cms-range.js +353 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/contract-fingerprint.js +39 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.d.ts +23 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/admin-styles.js +351 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/ai-declarations.js +26 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.d.ts +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/archive-names.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/bundle.js +1 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/content-access.js +47 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/contributions.js +2 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/editor-extensions.js +40 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/graphql-fields.js +22 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/icons.js +3 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/index.js +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/label-languages.js +76 -6
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.d.ts +27 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/licence-check.js +99 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/limits.js +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/locales.js +9 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/plugin-settings.js +68 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.d.ts +5 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/providers.js +316 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/registry.js +40 -4
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/rich-text.js +173 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sample-content.js +91 -2
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.d.ts +6 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/server-powers.js +150 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/services-events.js +35 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/sign-in-steps.js +71 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/site-extensions.js +69 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/templates.js +21 -1
- package/node_modules/@kardalum/plugin-package/dist/delivery/types.d.ts +17 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/user-accounts.js +36 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.d.ts +3 -0
- package/node_modules/@kardalum/plugin-package/dist/delivery/visitor-points.js +33 -0
- package/node_modules/@kardalum/plugin-package/dist/index.d.ts +8 -2
- package/node_modules/@kardalum/plugin-package/dist/index.js +7 -1
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.d.ts +75 -0
- package/node_modules/@kardalum/plugin-package/dist/license-verdict.js +123 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.d.ts +7 -0
- package/node_modules/@kardalum/plugin-package/dist/public-suffix.js +23 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.d.ts +1 -0
- package/node_modules/@kardalum/plugin-package/dist/rich-text-summary.js +27 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.d.ts +2 -0
- package/node_modules/@kardalum/plugin-package/dist/stylesheet-load-hook.js +28 -0
- package/node_modules/@kardalum/plugin-package/package.json +4 -0
- package/node_modules/@kardalum/ui/dist/components/select.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/select.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/switch.js +1 -1
- package/node_modules/@kardalum/ui/dist/components/textarea.d.ts +6 -0
- package/node_modules/@kardalum/ui/dist/components/textarea.js +7 -0
- package/node_modules/@kardalum/ui/dist/components/tooltip.js +1 -2
- package/node_modules/@kardalum/ui/dist/components/truncated-text.d.ts +6 -1
- package/node_modules/@kardalum/ui/dist/components/truncated-text.js +5 -4
- package/node_modules/@kardalum/ui/dist/index.d.ts +2 -0
- package/node_modules/@kardalum/ui/dist/index.js +2 -0
- package/package.json +25 -3
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { EditorContent, useEditor } from "@tiptap/react";
|
|
4
4
|
import { NodeSelection } from "@tiptap/pm/state";
|
|
5
|
+
import { canonicalRichTextJson, itemNodeTypeOf } from "@kardalum/api-schemas";
|
|
5
6
|
import { Code2, Image as ImageIcon, Link as LinkIcon, List as ListIcon, Quote as QuoteIcon } from "lucide-react";
|
|
6
|
-
import { cn,
|
|
7
|
-
import {
|
|
7
|
+
import { cn, usePropertyFieldControl } from "@kardalum/ui";
|
|
8
|
+
import { ToolbarButton, ToolbarSeparator } from "../richtext/toolbar-button.js";
|
|
9
|
+
import { PluginToolbarGroup, usePluginToolbarEntries } from "../richtext/plugin-toolbar.js";
|
|
10
|
+
import { ItemPanel, newItemAttributes } from "../richtext/item-panel.js";
|
|
11
|
+
import { selectedPluginItem } from "../richtext/plugin-items.js";
|
|
12
|
+
import { MANAGE_API, usePluginApi, usePluginFieldContext, usePluginValue } from "../plugin-context.js";
|
|
8
13
|
import { buildRichtextExtensions } from "../richtext/extensions.js";
|
|
14
|
+
import { convertPastedAddress } from "../richtext/url-paste.js";
|
|
15
|
+
import { PasteChoiceMenu } from "../richtext/paste-choice.js";
|
|
9
16
|
import { MediaPicker } from "../media/media-picker.js";
|
|
10
17
|
import { BlockInsertMenu, defaultBlockParams } from "../richtext/insert-menu.js";
|
|
11
18
|
import { BlockPanel, BlockPreviewPopover } from "../richtext/block-panel.js";
|
|
12
19
|
import { StyleListbox } from "../richtext/style-listbox.js";
|
|
20
|
+
import { useInsideNestedField } from "../nested-field-host.js";
|
|
21
|
+
import { useAdminDirection, useAdminLanguage, useSdkString } from "../sdk-strings.js";
|
|
22
|
+
import { richTextOpens, richTextSchemaOf } from "../richtext/content-guard.js";
|
|
23
|
+
import { createRichItemDirectory, useRichItems } from "../richtext/rich-items.js";
|
|
24
|
+
import { renderRichItemIcon } from "../richtext/rich-item-icons.js";
|
|
25
|
+
import { UnreadableRichText } from "./unreadable-rich-text.js";
|
|
13
26
|
// The rich content editor (S197 spec §3): one TipTap editor definition
|
|
14
27
|
// (buildRichtextExtensions), mounted here with a fixed compact toolbar per
|
|
15
28
|
// the mockup's screen 3: the same commands the on-page bubble toolbar
|
|
@@ -77,8 +90,10 @@ function useTextStyles() {
|
|
|
77
90
|
// pattern): one stop in the page Tab order, arrow keys move focus among
|
|
78
91
|
// buttons, Home/End jump to the ends. Disabled buttons (Block, Edit on
|
|
79
92
|
// page, both placeholders this task) are skipped entirely, matching
|
|
80
|
-
// native disabled-control behavior, so they can never hold focus.
|
|
81
|
-
|
|
93
|
+
// native disabled-control behavior, so they can never hold focus. The
|
|
94
|
+
// toolbar reads in the admin's direction (S366f D10), so Right moves on in a
|
|
95
|
+
// left-to-right admin and back in a right-to-left one.
|
|
96
|
+
function useToolbarRovingTabIndex(focusableKeys, dir) {
|
|
82
97
|
const [activeKey, setActiveKey] = useState(focusableKeys[0] ?? null);
|
|
83
98
|
const refs = useRef(new Map());
|
|
84
99
|
useEffect(() => {
|
|
@@ -106,11 +121,13 @@ function useToolbarRovingTabIndex(focusableKeys) {
|
|
|
106
121
|
return;
|
|
107
122
|
const currentIndex = activeKey !== null ? focusableKeys.indexOf(activeKey) : 0;
|
|
108
123
|
let nextIndex = currentIndex;
|
|
124
|
+
const forward = dir === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
125
|
+
const back = dir === "rtl" ? "ArrowRight" : "ArrowLeft";
|
|
109
126
|
switch (event.key) {
|
|
110
|
-
case
|
|
127
|
+
case forward:
|
|
111
128
|
nextIndex = (currentIndex + 1) % focusableKeys.length;
|
|
112
129
|
break;
|
|
113
|
-
case
|
|
130
|
+
case back:
|
|
114
131
|
nextIndex = (currentIndex - 1 + focusableKeys.length) % focusableKeys.length;
|
|
115
132
|
break;
|
|
116
133
|
case "Home":
|
|
@@ -127,19 +144,13 @@ function useToolbarRovingTabIndex(focusableKeys) {
|
|
|
127
144
|
}
|
|
128
145
|
return { activeKey, setActiveKey, registerRef, handleKeyDown };
|
|
129
146
|
}
|
|
130
|
-
function ToolbarButton({ itemKey, label, ariaLabel, active, disabled, expanded, hasPopup, isRovingActive, registerRef, onFocus, onClick, }) {
|
|
131
|
-
const button = (_jsx("button", { ref: registerRef, type: "button", "data-testid": `rt-toolbar-${itemKey}`, "aria-label": ariaLabel, "aria-pressed": active, "aria-haspopup": hasPopup, "aria-expanded": hasPopup ? expanded : undefined, disabled: disabled, tabIndex: disabled ? -1 : isRovingActive ? 0 : -1, onFocus: onFocus, onClick: onClick, className: cn("inline-flex h-8 items-center gap-1 rounded-md px-2 text-xs font-medium text-text-secondary hover:bg-background-hover disabled:pointer-events-none disabled:opacity-50", "focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600", active && "bg-primary-100 text-primary-800"), children: label }));
|
|
132
|
-
return ariaLabel ? _jsx(IconTooltip, { children: button }) : button;
|
|
133
|
-
}
|
|
134
|
-
function ToolbarSeparator() {
|
|
135
|
-
return _jsx("span", { "aria-hidden": "true", className: "mx-1 inline-block h-4 w-px bg-border-default" });
|
|
136
|
-
}
|
|
137
147
|
// Prompt-free link input (spec-listed toolbar command): a small popover
|
|
138
148
|
// form instead of window.prompt(), so the flow stays keyboard/a11y
|
|
139
149
|
// reachable and themeable, unlike a native prompt dialog.
|
|
140
150
|
function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
|
|
141
151
|
const [href, setHref] = useState(initialHref);
|
|
142
152
|
const inputRef = useRef(null);
|
|
153
|
+
const s = useSdkString();
|
|
143
154
|
useEffect(() => {
|
|
144
155
|
inputRef.current?.focus();
|
|
145
156
|
inputRef.current?.select();
|
|
@@ -149,13 +160,13 @@ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
|
|
|
149
160
|
event.preventDefault();
|
|
150
161
|
onClose();
|
|
151
162
|
}
|
|
152
|
-
}, children: [_jsx("label", { htmlFor: "rt-link-href", className: "mb-1 block text-xs font-medium text-text-secondary", children: "
|
|
163
|
+
}, children: [_jsx("label", { htmlFor: "rt-link-href", className: "mb-1 block text-xs font-medium text-text-secondary", children: s("richText.linkUrl") }), _jsx("input", { ref: inputRef, id: "rt-link-href", type: "url", value: href, placeholder: "https://", onChange: (event) => setHref(event.target.value), onKeyDown: (event) => {
|
|
153
164
|
if (event.key === "Enter") {
|
|
154
165
|
event.preventDefault();
|
|
155
166
|
if (href.trim())
|
|
156
167
|
onApply(href.trim());
|
|
157
168
|
}
|
|
158
|
-
}, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: "
|
|
169
|
+
}, className: "mb-2 w-full rounded-md border border-border-default bg-background-elevated px-2 py-1 text-sm text-text-primary focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-primary-600" }), _jsxs("div", { className: "flex justify-end gap-2", children: [hasLink && (_jsx("button", { type: "button", onClick: onRemove, className: "rounded-md px-2 py-1 text-xs text-danger-600 hover:bg-background-hover", children: s("richText.removeLink") })), _jsx("button", { type: "button", disabled: !href.trim(), onClick: () => onApply(href.trim()), className: "rounded-md bg-primary-600 px-2 py-1 text-xs font-medium text-text-inverse hover:bg-primary-700 disabled:opacity-50", children: s("richText.apply") })] })] }));
|
|
159
170
|
}
|
|
160
171
|
// S197 Task 12: bubbles up so a mount that HAS routing (content-editor.tsx,
|
|
161
172
|
// admin-ui) can navigate to /content/:id/edit-on-page, the same "plain DOM
|
|
@@ -166,10 +177,21 @@ function LinkPopover({ initialHref, hasLink, onApply, onRemove, onClose }) {
|
|
|
166
177
|
// ambient route context, and even ContentEditor itself renders this view
|
|
167
178
|
// with a fixed, prop-less signature).
|
|
168
179
|
const EDIT_ON_PAGE_EVENT = "kardalum:edit-on-page";
|
|
169
|
-
function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
180
|
+
function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource, items }) {
|
|
170
181
|
const { styles: textStyles, loading: textStylesLoading } = useTextStyles();
|
|
171
182
|
const [openPopover, setOpenPopover] = useState(null);
|
|
172
183
|
const [pickerOpen, setPickerOpen] = useState(false);
|
|
184
|
+
const s = useSdkString();
|
|
185
|
+
// M32 I2 (A4): inside a Group there is no page to edit on.
|
|
186
|
+
const nested = useInsideNestedField();
|
|
187
|
+
// The toolbar is the admin's chrome, so it takes the admin's direction;
|
|
188
|
+
// the editable surface below keeps the content's (S366f D10).
|
|
189
|
+
const dir = useAdminDirection();
|
|
190
|
+
const lang = useAdminLanguage();
|
|
191
|
+
// M35 C4a (design D5): the switched-on plugins' buttons, the first few on the toolbar and the rest under More.
|
|
192
|
+
const { shown: pluginShown, more: pluginMore } = usePluginToolbarEntries(items, lang ?? items.language);
|
|
193
|
+
// M35 C4b (design D16): the field's culture, which a button view's editor handle reads.
|
|
194
|
+
const fieldContext = usePluginFieldContext();
|
|
173
195
|
const activeStyleKey = editor.getAttributes("textStyleClass").styleKey ?? null;
|
|
174
196
|
const allItemKeys = [
|
|
175
197
|
"bold",
|
|
@@ -182,15 +204,17 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
182
204
|
"style",
|
|
183
205
|
"image",
|
|
184
206
|
"block",
|
|
207
|
+
...pluginShown.map((entry) => entry.key),
|
|
208
|
+
...(pluginMore.length > 0 ? ["more"] : []),
|
|
185
209
|
"source",
|
|
186
|
-
"editOnPage",
|
|
210
|
+
...(nested ? [] : ["editOnPage"]),
|
|
187
211
|
];
|
|
188
212
|
// Every other command is disabled in source mode (editing raw HTML has no
|
|
189
213
|
// "toggle bold" equivalent); Source itself is the only tab stop then, so
|
|
190
214
|
// the roving tabindex's own focusable set shrinks to match, same as the
|
|
191
215
|
// doc comment above useToolbarRovingTabIndex describes for disabled items.
|
|
192
216
|
const focusableKeys = sourceMode ? ["source"] : allItemKeys;
|
|
193
|
-
const { activeKey, setActiveKey, registerRef, handleKeyDown } = useToolbarRovingTabIndex(focusableKeys);
|
|
217
|
+
const { activeKey, setActiveKey, registerRef, handleKeyDown } = useToolbarRovingTabIndex(focusableKeys, dir);
|
|
194
218
|
function closePopover() {
|
|
195
219
|
setOpenPopover(null);
|
|
196
220
|
}
|
|
@@ -211,17 +235,17 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
211
235
|
setPickerOpen(false);
|
|
212
236
|
}
|
|
213
237
|
const linkAttrs = editor.getAttributes("link");
|
|
214
|
-
return (_jsxs("div", { role: "toolbar", "aria-label": "
|
|
238
|
+
return (_jsxs("div", { role: "toolbar", dir: dir, lang: lang, "aria-label": s("richText.toolbar"), "aria-orientation": "horizontal", onKeyDown: handleKeyDown,
|
|
215
239
|
// gap-1/p-2 (not the mockup's literal .15rem/.4rem: the token scale's
|
|
216
240
|
// nearest whole steps; gap-0.5/p-1.5 generate no CSS at all under this
|
|
217
241
|
// project's replaced spacing scale, see the admin UI conventions).
|
|
218
|
-
className: "relative flex flex-wrap items-center gap-1 border-b border-border-default bg-background-subtle p-2", children: [_jsx(ToolbarButton, { itemKey: "bold", label: _jsx("span", { className: "font-bold", children: "
|
|
242
|
+
className: "relative flex flex-wrap items-center gap-1 border-b border-border-default bg-background-subtle p-2", children: [_jsx(ToolbarButton, { itemKey: "bold", label: _jsx("span", { className: "font-bold", children: s("richText.boldMark") }), ariaLabel: s("richText.bold"), active: editor.isActive("bold"), disabled: sourceMode, isRovingActive: activeKey === "bold", registerRef: registerRef("bold"), onFocus: () => setActiveKey("bold"), onClick: () => editor.chain().focus().toggleBold().run() }), _jsx(ToolbarButton, { itemKey: "italic", label: _jsx("span", { className: "italic", children: s("richText.italicMark") }), ariaLabel: s("richText.italic"), active: editor.isActive("italic"), disabled: sourceMode, isRovingActive: activeKey === "italic", registerRef: registerRef("italic"), onFocus: () => setActiveKey("italic"), onClick: () => editor.chain().focus().toggleItalic().run() }), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "link", label: _jsxs(_Fragment, { children: [_jsx(LinkIcon, { "aria-hidden": "true", className: "size-4" }), s("richText.link")] }), active: editor.isActive("link"), disabled: sourceMode, hasPopup: "dialog", expanded: openPopover === "link", isRovingActive: activeKey === "link", registerRef: registerRef("link"), onFocus: () => setActiveKey("link"), onClick: () => setOpenPopover((current) => (current === "link" ? null : "link")) }), openPopover === "link" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(LinkPopover, { initialHref: linkAttrs.href ?? "", hasLink: editor.isActive("link"), onApply: (href) => {
|
|
219
243
|
editor.chain().focus().extendMarkRange("link").setLink({ href }).run();
|
|
220
244
|
closePopover();
|
|
221
245
|
}, onRemove: () => {
|
|
222
246
|
editor.chain().focus().unsetLink().run();
|
|
223
247
|
closePopover();
|
|
224
|
-
}, onClose: closePopover }) }))] }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "h2", label: "
|
|
248
|
+
}, onClose: closePopover }) }))] }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "h2", label: s("richText.h2Mark"), ariaLabel: s("richText.heading2"), active: editor.isActive("heading", { level: 2 }), disabled: sourceMode, isRovingActive: activeKey === "h2", registerRef: registerRef("h2"), onFocus: () => setActiveKey("h2"), onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run() }), _jsx(ToolbarButton, { itemKey: "h3", label: s("richText.h3Mark"), ariaLabel: s("richText.heading3"), active: editor.isActive("heading", { level: 3 }), disabled: sourceMode, isRovingActive: activeKey === "h3", registerRef: registerRef("h3"), onFocus: () => setActiveKey("h3"), onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run() }), _jsx(ToolbarButton, { itemKey: "blockquote", label: _jsx(QuoteIcon, { "aria-hidden": "true", className: "size-4" }), ariaLabel: s("richText.quote"), active: editor.isActive("blockquote"), disabled: sourceMode, isRovingActive: activeKey === "blockquote", registerRef: registerRef("blockquote"), onFocus: () => setActiveKey("blockquote"), onClick: () => editor.chain().focus().toggleBlockquote().run() }), _jsx(ToolbarButton, { itemKey: "bulletList", label: _jsxs(_Fragment, { children: [_jsx(ListIcon, { "aria-hidden": "true", className: "size-4" }), s("richText.list")] }), ariaLabel: s("richText.bulletedList"), active: editor.isActive("bulletList"), disabled: sourceMode, isRovingActive: activeKey === "bulletList", registerRef: registerRef("bulletList"), onFocus: () => setActiveKey("bulletList"), onClick: () => editor.chain().focus().toggleBulletList().run() }), _jsx(ToolbarSeparator, {}), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "style", label: `Aa ${s("richText.style")} ▾`, disabled: sourceMode, hasPopup: "listbox", expanded: openPopover === "style", isRovingActive: activeKey === "style", registerRef: registerRef("style"), onFocus: () => setActiveKey("style"), onClick: () => setOpenPopover((current) => (current === "style" ? null : "style")) }), openPopover === "style" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(StyleListbox, { styles: textStyles, loading: textStylesLoading, activeStyleKey: activeStyleKey, onSelect: (styleKey) => editor.chain().focus().setTextStyle(styleKey).run(), onClear: () => editor.chain().focus().unsetTextStyle().run(), onClose: closePopover }) }))] }), _jsx(ToolbarButton, { itemKey: "image", label: _jsxs(_Fragment, { children: [_jsx(ImageIcon, { "aria-hidden": "true", className: "size-4" }), s("richText.image")] }), disabled: sourceMode, hasPopup: "dialog", expanded: pickerOpen, isRovingActive: activeKey === "image", registerRef: registerRef("image"), onFocus: () => setActiveKey("image"), onClick: () => setPickerOpen(true) }), pickerOpen && _jsx(MediaPicker, { collectAlt: true, onPick: handleMediaPick, onClose: () => setPickerOpen(false) }), _jsxs("div", { className: "relative", children: [_jsx(ToolbarButton, { itemKey: "block", label: `◫ ${s("richText.block")} ▾`, disabled: sourceMode, hasPopup: "listbox", expanded: openPopover === "block", isRovingActive: activeKey === "block", registerRef: registerRef("block"), onFocus: () => setActiveKey("block"), onClick: () => setOpenPopover((current) => (current === "block" ? null : "block")) }), openPopover === "block" && (_jsx("div", { className: "absolute start-0 top-full z-10 mt-1 rounded-md border border-border-default bg-background-elevated shadow-lg", children: _jsx(BlockInsertMenu, { onInsert: (listing) => {
|
|
225
249
|
editor
|
|
226
250
|
.chain()
|
|
227
251
|
.focus()
|
|
@@ -230,9 +254,83 @@ function RichTextToolbar({ editor, containerRef, sourceMode, onToggleSource }) {
|
|
|
230
254
|
attrs: { partial: listing.alias, params: defaultBlockParams(listing.params) },
|
|
231
255
|
})
|
|
232
256
|
.run();
|
|
233
|
-
}, onClose: closePopover }) }))] }), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "source", label: _jsxs(_Fragment, { children: [_jsx(Code2, { "aria-hidden": "true", className: "size-4" }), "
|
|
257
|
+
}, onClose: closePopover, items: items, onInsertItem: (plugin, node) => editor.chain().focus().insertPluginItem(itemNodeTypeOf(node.shape), newItemAttributes(plugin, node)).run() }) }))] }), pluginShown.length + pluginMore.length > 0 && (_jsxs(_Fragment, { children: [_jsx(ToolbarSeparator, {}), _jsx(PluginToolbarGroup, { editor: editor, entries: { shown: pluginShown, more: pluginMore }, items: items, culture: fieldContext?.culture ?? null, sourceMode: sourceMode, activeKey: activeKey, setActiveKey: setActiveKey, registerRef: registerRef, language: lang ?? items.language })] })), _jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "source", label: _jsxs(_Fragment, { children: [_jsx(Code2, { "aria-hidden": "true", className: "size-4" }), s("richText.source")] }), ariaLabel: s("richText.toggleSource"), active: sourceMode, isRovingActive: activeKey === "source", registerRef: registerRef("source"), onFocus: () => setActiveKey("source"), onClick: onToggleSource }), !nested && (_jsxs(_Fragment, { children: [_jsx(ToolbarSeparator, {}), _jsx(ToolbarButton, { itemKey: "editOnPage", label: _jsx("span", { className: "text-primary-700", children: `⤢ ${s("richText.editOnPage")}` }), disabled: sourceMode, isRovingActive: activeKey === "editOnPage", registerRef: registerRef("editOnPage"), onFocus: () => setActiveKey("editOnPage"), onClick: () => containerRef.current?.dispatchEvent(new CustomEvent(EDIT_ON_PAGE_EVENT, { bubbles: true })) })] }))] }));
|
|
258
|
+
}
|
|
259
|
+
/** M35 C4b (35-C4a review (b)): `value` as `editor`'s schema reads it (attribute defaults filled in), ending in the empty
|
|
260
|
+
* paragraph StarterKit's TrailingNode appends after a last node that is not a paragraph. Null when the schema cannot
|
|
261
|
+
* read it. One read per value: the last answer is kept. */
|
|
262
|
+
const schemaReads = new WeakMap();
|
|
263
|
+
function schemaReadOf(editor, value) {
|
|
264
|
+
if (value === null || typeof value !== "object")
|
|
265
|
+
return null;
|
|
266
|
+
const kept = schemaReads.get(value);
|
|
267
|
+
if (kept && kept.editor === editor)
|
|
268
|
+
return kept.read;
|
|
269
|
+
let read = null;
|
|
270
|
+
try {
|
|
271
|
+
const doc = editor.schema.nodeFromJSON(value).toJSON();
|
|
272
|
+
const content = Array.isArray(doc.content) ? doc.content : [];
|
|
273
|
+
const last = content[content.length - 1];
|
|
274
|
+
read = last !== undefined && last.type !== "paragraph" ? { ...doc, content: [...content, { type: "paragraph" }] } : doc;
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
read = null;
|
|
278
|
+
}
|
|
279
|
+
schemaReads.set(value, { editor, read });
|
|
280
|
+
return read;
|
|
281
|
+
}
|
|
282
|
+
/** M35 C4a (design section 5): two values equal by value, whatever order a database kept their keys in. */
|
|
283
|
+
export function richTextValuesEqual(a, b) {
|
|
284
|
+
const left = canonicalRichTextJson(a ?? {});
|
|
285
|
+
const right = canonicalRichTextJson(b ?? {});
|
|
286
|
+
return left !== null && right !== null ? left === right : JSON.stringify(a ?? {}) === JSON.stringify(b ?? {});
|
|
287
|
+
}
|
|
288
|
+
/** One item directory a mount, fed by the listing and worded in the admin's language. */
|
|
289
|
+
function useItemDirectory() {
|
|
290
|
+
const s = useSdkString();
|
|
291
|
+
const language = useAdminLanguage();
|
|
292
|
+
// The sentences read the latest translator, so a language switch of the host is picked up at the next repaint.
|
|
293
|
+
const translate = useRef(s);
|
|
294
|
+
translate.current = s;
|
|
295
|
+
const directory = useRef(null);
|
|
296
|
+
directory.current ??= createRichItemDirectory({
|
|
297
|
+
language: language ?? "en",
|
|
298
|
+
// Each sentence is interpolated by the host's own translator (the admin's i18next, or the SDK's English table).
|
|
299
|
+
words: {
|
|
300
|
+
off: (plugin) => translate.current("richText.itemOff", { plugin }),
|
|
301
|
+
notInstalled: (id) => translate.current("richText.itemNotInstalled", { id }),
|
|
302
|
+
dropped: (plugin) => translate.current("richText.itemDropped", { plugin }),
|
|
303
|
+
get failed() {
|
|
304
|
+
return translate.current("richText.itemDetailsFailed");
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
renderIcon: renderRichItemIcon,
|
|
308
|
+
});
|
|
309
|
+
const listing = useRichItems();
|
|
310
|
+
useEffect(() => directory.current.set(listing), [listing]);
|
|
311
|
+
return directory.current;
|
|
234
312
|
}
|
|
235
313
|
function RichTextEditor({ editable }) {
|
|
314
|
+
const { value, onChange } = usePluginValue();
|
|
315
|
+
const items = useItemDirectory();
|
|
316
|
+
// M35 C4b (design D17): a pasted address two plugins' items list asks which; through a ref, so the extensions are
|
|
317
|
+
// made once a directory.
|
|
318
|
+
const [pasteChoice, setPasteChoice] = useState(null);
|
|
319
|
+
const onPasteChoiceRef = useRef(setPasteChoice);
|
|
320
|
+
onPasteChoiceRef.current = setPasteChoice;
|
|
321
|
+
const extensions = useMemo(() => buildRichtextExtensions({ items, onPasteChoice: (choice) => onPasteChoiceRef.current(choice) }), [items]);
|
|
322
|
+
const schema = useMemo(() => richTextSchemaOf(extensions), [extensions]);
|
|
323
|
+
// The value the mounted editor last emitted: the schema made it, so it opens, and checking it again (a whole
|
|
324
|
+
// nodeFromJSON and check) on every keystroke's re-render would make typing in a long document lag. Only a value
|
|
325
|
+
// that arrives from outside is checked.
|
|
326
|
+
const ownValue = useRef(undefined);
|
|
327
|
+
if (!(value !== null && value === ownValue.current) && !richTextOpens(schema, value)) {
|
|
328
|
+
// Design D7: TipTap would show an empty document and the next edit would store it, so the editor is not mounted.
|
|
329
|
+
return _jsx(UnreadableRichText, { value: value, editable: editable, onKeepText: (doc) => onChange(doc) });
|
|
330
|
+
}
|
|
331
|
+
return _jsx(MountedRichTextEditor, { editable: editable, extensions: extensions, schema: schema, items: items, ownValue: ownValue, pasteChoice: pasteChoice, setPasteChoice: setPasteChoice });
|
|
332
|
+
}
|
|
333
|
+
function MountedRichTextEditor({ editable, extensions, schema, items, ownValue, pasteChoice, setPasteChoice, }) {
|
|
236
334
|
const { value, onChange } = usePluginValue();
|
|
237
335
|
// Guards the sync effect below against reacting to the update it just
|
|
238
336
|
// caused itself. Without this, every keystroke would round-trip
|
|
@@ -245,8 +343,9 @@ function RichTextEditor({ editable }) {
|
|
|
245
343
|
// field's identity is stamped there instead (WCAG 4.1.2; axe reports
|
|
246
344
|
// the gap as `aria-input-field-name`).
|
|
247
345
|
const field = usePropertyFieldControl();
|
|
346
|
+
const s = useSdkString();
|
|
248
347
|
const editor = useEditor({
|
|
249
|
-
extensions
|
|
348
|
+
extensions,
|
|
250
349
|
content: value ?? "",
|
|
251
350
|
editable,
|
|
252
351
|
// @tiptap/react 3.31 no longer re-renders the owning component on every
|
|
@@ -278,12 +377,70 @@ function RichTextEditor({ editable }) {
|
|
|
278
377
|
// source (emitUpdate: false, see the effect below), so any doc that
|
|
279
378
|
// still equals the external value is TipTap's own construction-time
|
|
280
379
|
// normalization pass, not an edit.
|
|
281
|
-
if (
|
|
380
|
+
if (richTextValuesEqual(json, value))
|
|
381
|
+
return;
|
|
382
|
+
// M35 C4b (35-C4a review (b)): opening the panel writes nothing. Selecting a chip is the first transaction of a
|
|
383
|
+
// value that ends with an item, and StarterKit's TrailingNode answers it by appending an empty paragraph; an item
|
|
384
|
+
// a script wrote without id or text reads with the schema's defaults. Neither is an edit, so the value is compared
|
|
385
|
+
// as the editor's schema reads it, with the paragraph TrailingNode would add.
|
|
386
|
+
if (richTextValuesEqual(json, schemaReadOf(updated, value)))
|
|
282
387
|
return;
|
|
283
388
|
isInternalUpdate.current = true;
|
|
389
|
+
ownValue.current = json;
|
|
284
390
|
onChange(json);
|
|
285
391
|
},
|
|
286
392
|
});
|
|
393
|
+
// The selection no person chose (see `panelsOpen` below): the editor's first one, then whatever each setContent
|
|
394
|
+
// here leaves. Any transaction that sets the selection clears it.
|
|
395
|
+
const unchosenSelection = useRef(null);
|
|
396
|
+
const seenEditor = useRef(null);
|
|
397
|
+
if (editor && seenEditor.current !== editor) {
|
|
398
|
+
seenEditor.current = editor;
|
|
399
|
+
unchosenSelection.current = editor.state.selection;
|
|
400
|
+
}
|
|
401
|
+
useEffect(() => {
|
|
402
|
+
if (!editor)
|
|
403
|
+
return;
|
|
404
|
+
const onTransaction = ({ transaction }) => {
|
|
405
|
+
if (transaction.selectionSet)
|
|
406
|
+
unchosenSelection.current = null;
|
|
407
|
+
};
|
|
408
|
+
editor.on("transaction", onTransaction);
|
|
409
|
+
return () => {
|
|
410
|
+
editor.off("transaction", onTransaction);
|
|
411
|
+
};
|
|
412
|
+
}, [editor]);
|
|
413
|
+
// `keepChosen` (an outside value): when a person had chosen a node (an open item or block panel) and the new
|
|
414
|
+
// document still holds it (an item by its id, any other node by its type at the same place), it is selected again,
|
|
415
|
+
// so the panel does not close under them; otherwise the new selection is recorded as unchosen.
|
|
416
|
+
function setContentUnchosen(content, keepChosen = false) {
|
|
417
|
+
if (!editor)
|
|
418
|
+
return;
|
|
419
|
+
const before = editor.state.selection;
|
|
420
|
+
const chosen = keepChosen && unchosenSelection.current === null && before instanceof NodeSelection ? before : null;
|
|
421
|
+
editor.commands.setContent(content);
|
|
422
|
+
if (chosen) {
|
|
423
|
+
const id = chosen.node.attrs.id;
|
|
424
|
+
let found = -1;
|
|
425
|
+
if (typeof id === "string" && id.length > 0) {
|
|
426
|
+
editor.state.doc.descendants((node, pos) => {
|
|
427
|
+
if (found >= 0)
|
|
428
|
+
return false;
|
|
429
|
+
if (node.type.name === chosen.node.type.name && node.attrs.id === id)
|
|
430
|
+
found = pos;
|
|
431
|
+
return true;
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
else if (chosen.from < editor.state.doc.content.size && editor.state.doc.nodeAt(chosen.from)?.type.name === chosen.node.type.name) {
|
|
435
|
+
found = chosen.from;
|
|
436
|
+
}
|
|
437
|
+
if (found >= 0) {
|
|
438
|
+
editor.commands.setNodeSelection(found);
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
unchosenSelection.current = editor.state.selection;
|
|
443
|
+
}
|
|
287
444
|
// Item 3 (S197 QA-wave B): the HTML source view. `null` means "not in
|
|
288
445
|
// source mode"; the textarea's own in-progress edits live here, entirely
|
|
289
446
|
// separate from `value`/onChange, until the toggle-back below commits
|
|
@@ -336,7 +493,7 @@ function RichTextEditor({ editable }) {
|
|
|
336
493
|
// this buffer was dirty (sourceStale), this is the "informed overwrite"
|
|
337
494
|
// the notice warned about: the user's buffer wins, same as any other
|
|
338
495
|
// edit made after seeing the notice.
|
|
339
|
-
|
|
496
|
+
setContentUnchosen(sourceHtml);
|
|
340
497
|
sourceSeedRef.current = null;
|
|
341
498
|
setSourceHtml(null);
|
|
342
499
|
setSourceStale(false);
|
|
@@ -348,9 +505,7 @@ function RichTextEditor({ editable }) {
|
|
|
348
505
|
isInternalUpdate.current = false;
|
|
349
506
|
return;
|
|
350
507
|
}
|
|
351
|
-
|
|
352
|
-
const next = JSON.stringify(value ?? {});
|
|
353
|
-
if (current === next)
|
|
508
|
+
if (richTextValuesEqual(editor.getJSON(), value))
|
|
354
509
|
return;
|
|
355
510
|
// An external value change while the source textarea is open (review
|
|
356
511
|
// fix, S197 QA-wave B): without this branch, the live editor doc would
|
|
@@ -372,15 +527,20 @@ function RichTextEditor({ editable }) {
|
|
|
372
527
|
// No local edits yet: safe to re-seed from the fresh external doc,
|
|
373
528
|
// same as the non-source branch below but keeping the textarea's
|
|
374
529
|
// displayed HTML in sync too.
|
|
375
|
-
|
|
530
|
+
// M35 C4a (design D7): the parent re-renders into the read-only state with this value, so it is never set here.
|
|
531
|
+
if (!richTextOpens(schema, value))
|
|
532
|
+
return;
|
|
533
|
+
setContentUnchosen(value ?? "", true);
|
|
376
534
|
const reseeded = prettifyHtml(editor.getHTML());
|
|
377
535
|
sourceSeedRef.current = reseeded;
|
|
378
536
|
setSourceHtml(reseeded);
|
|
379
537
|
setSourceStale(false);
|
|
380
538
|
return;
|
|
381
539
|
}
|
|
382
|
-
|
|
383
|
-
|
|
540
|
+
if (!richTextOpens(schema, value))
|
|
541
|
+
return;
|
|
542
|
+
setContentUnchosen(value ?? "", true);
|
|
543
|
+
}, [value, editor, schema]);
|
|
384
544
|
useEffect(() => {
|
|
385
545
|
// emitUpdate: false, since setEditable's unconditional 'update' event is
|
|
386
546
|
// not an edit; silencing it at the source keeps onUpdate's arming
|
|
@@ -413,14 +573,27 @@ function RichTextEditor({ editable }) {
|
|
|
413
573
|
// kardalumBlock, see block-panel.tsx's doc comment for why that's the
|
|
414
574
|
// right signal rather than separate open/close state.
|
|
415
575
|
const selection = editor?.state.selection;
|
|
416
|
-
|
|
417
|
-
|
|
576
|
+
// M35 C4a: the selection TipTap starts with, or a setContent leaves, is nobody's choice. A value that begins with an
|
|
577
|
+
// item or a block starts with that node selected, which would open its panel the moment the page opens; so a panel
|
|
578
|
+
// opens only once a transaction has set the selection (a click on a chip, an arrow key), never for this one.
|
|
579
|
+
const panelsOpen = !(unchosenSelection.current !== null && selection !== undefined && selection.eq(unchosenSelection.current));
|
|
580
|
+
const blockSelection = panelsOpen && editor && selection instanceof NodeSelection && selection.node.type.name === "kardalumBlock" ? selection : null;
|
|
581
|
+
// M35 C4a (design D8): a selected plugin item opens the core's item panel the same way.
|
|
582
|
+
const itemSelection = panelsOpen && editor ? selectedPluginItem(editor) : null;
|
|
583
|
+
return (_jsxs("div", { ref: wrapperRef, className: cn(editable && "overflow-hidden rounded-md border border-border-default bg-background-elevated"), children: [_jsxs("div", { inert: editable && (Boolean(blockSelection) || Boolean(itemSelection)) ? true : undefined, children: [editable && editor && (_jsx(RichTextToolbar, { editor: editor, containerRef: wrapperRef, sourceMode: sourceMode, onToggleSource: handleToggleSource, items: items })), sourceMode ? (_jsxs(_Fragment, { children: [sourceStale && (_jsx("div", { role: "alert", "data-testid": "rt-source-stale-notice", className: "border-b border-warning-100 bg-warning-100 px-5 py-2 text-xs text-warning-800", children: s("richText.sourceStale") })), _jsx("textarea", { "data-testid": "rt-source-textarea", "aria-label": s("richText.sourceLabel"), value: sourceHtml, onChange: (event) => setSourceHtml(event.target.value), spellCheck: false, className: "block min-h-72 w-full resize-y border-0 bg-background-elevated px-5 py-4 font-mono text-xs text-text-primary focus-visible:outline-hidden" })] })) : (_jsx(EditorContent, { editor: editor, className: cn(CONTENT_CLASSES, editable &&
|
|
418
584
|
// min-h-72 (18rem) matches the mockup's .rtbody proportions (S197
|
|
419
585
|
// screen 3): the editor grows with content past that floor, it
|
|
420
586
|
// never shrinks below a real working height. px-5/py-4 are the
|
|
421
587
|
// token scale's closest steps to the mockup's literal 1.3rem/
|
|
422
588
|
// 1.1rem .rtbody padding (design-tokens has no 1.1/1.3rem step).
|
|
423
|
-
"min-h-72 px-5 py-4 focus-within:outline-hidden focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })),
|
|
589
|
+
"min-h-72 px-5 py-4 focus-within:outline-hidden focus-within:ring-2 focus-within:ring-primary-600 focus-within:ring-offset-2 focus-within:ring-offset-background-base") }))] }), editable && editor && blockSelection && (_jsx(BlockPanel, { editor: editor, pos: blockSelection.from, partial: blockSelection.node.attrs.partial, params: blockSelection.node.attrs.params ?? {} })), editable && editor && pasteChoice && (_jsx("div", { className: "relative", children: _jsx("div", { className: "absolute start-0 top-0 z-10", children: _jsx(PasteChoiceMenu, { choice: pasteChoice, pluginNames: Object.fromEntries(items.plugins().map((entry) => [entry.plugin, entry.name])), onPick: (match) => {
|
|
590
|
+
convertPastedAddress(editor, pasteChoice, match);
|
|
591
|
+
setPasteChoice(null);
|
|
592
|
+
editor.commands.focus();
|
|
593
|
+
}, onClose: () => {
|
|
594
|
+
setPasteChoice(null);
|
|
595
|
+
editor.commands.focus();
|
|
596
|
+
} }) }) })), editable && editor && itemSelection && (_jsx(ItemPanel, { editor: editor, pos: itemSelection.pos, type: itemSelection.type, attrs: itemSelection.attrs, items: items }, itemSelection.pos)), previewRequest && (_jsx(BlockPreviewPopover, { partial: previewRequest.partial, params: previewRequest.params, anchorRect: previewRequest.anchorRect, onClose: () => setPreviewRequest(null) }))] }));
|
|
424
597
|
}
|
|
425
598
|
export function RichTextInputView() {
|
|
426
599
|
return _jsx(RichTextEditor, { editable: true });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A key suggested from a name: lower-case, spaces and dashes to `_`, other characters dropped.
|
|
3
|
+
* A linear loop over the characters, never a pattern. With `leadingLetter` a result that would
|
|
4
|
+
* start with a digit or `_` (or is empty) gives no suggestion.
|
|
5
|
+
*/
|
|
6
|
+
export declare function suggestKey(name: string, max: number, leadingLetter: boolean): string;
|
|
7
|
+
/**
|
|
8
|
+
* Remembers per row whether its key was set by hand. A row loaded with a key counts as by hand, so
|
|
9
|
+
* a stored key is never overwritten; a row added here follows its name until the key is edited.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useHandEditedKeys(keys: string[]): {
|
|
12
|
+
follows: (index: number) => boolean;
|
|
13
|
+
markByHand: (index: number) => void;
|
|
14
|
+
added: () => void;
|
|
15
|
+
moved: (index: number, by: number) => void;
|
|
16
|
+
removed: (index: number) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { useRef } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A key suggested from a name: lower-case, spaces and dashes to `_`, other characters dropped.
|
|
4
|
+
* A linear loop over the characters, never a pattern. With `leadingLetter` a result that would
|
|
5
|
+
* start with a digit or `_` (or is empty) gives no suggestion.
|
|
6
|
+
*/
|
|
7
|
+
export function suggestKey(name, max, leadingLetter) {
|
|
8
|
+
let out = "";
|
|
9
|
+
for (const ch of name.trim()) {
|
|
10
|
+
const c = ch.toLowerCase();
|
|
11
|
+
const letter = c >= "a" && c <= "z";
|
|
12
|
+
const digit = c >= "0" && c <= "9";
|
|
13
|
+
if (letter || digit)
|
|
14
|
+
out += c;
|
|
15
|
+
else if ((c === " " || c === "-" || c === "_") && out !== "" && !out.endsWith("_"))
|
|
16
|
+
out += "_";
|
|
17
|
+
if (out.length >= max)
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
while (out.endsWith("_"))
|
|
21
|
+
out = out.slice(0, -1);
|
|
22
|
+
if (out === "")
|
|
23
|
+
return "";
|
|
24
|
+
if (leadingLetter && !(out[0] >= "a" && out[0] <= "z"))
|
|
25
|
+
return "";
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Remembers per row whether its key was set by hand. A row loaded with a key counts as by hand, so
|
|
30
|
+
* a stored key is never overwritten; a row added here follows its name until the key is edited.
|
|
31
|
+
*/
|
|
32
|
+
export function useHandEditedKeys(keys) {
|
|
33
|
+
const flags = useRef([]);
|
|
34
|
+
const read = () => keys.map((key, i) => flags.current[i] ?? key !== "");
|
|
35
|
+
return {
|
|
36
|
+
follows: (index) => !read()[index],
|
|
37
|
+
markByHand: (index) => {
|
|
38
|
+
const all = read();
|
|
39
|
+
all[index] = true;
|
|
40
|
+
flags.current = all;
|
|
41
|
+
},
|
|
42
|
+
added: () => {
|
|
43
|
+
flags.current = [...read(), false];
|
|
44
|
+
},
|
|
45
|
+
moved: (index, by) => {
|
|
46
|
+
const all = read();
|
|
47
|
+
const [flag] = all.splice(index, 1);
|
|
48
|
+
all.splice(index + by, 0, flag);
|
|
49
|
+
flags.current = all;
|
|
50
|
+
},
|
|
51
|
+
removed: (index) => {
|
|
52
|
+
flags.current = read().filter((_, i) => i !== index);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { JSONContent } from "@tiptap/react";
|
|
3
|
+
/** M35 C4a (design D7): the page's history opens on this event; ContentEditor listens for it on `document`. */
|
|
4
|
+
export declare const OPEN_HISTORY_EVENT = "kardalum:open-history";
|
|
5
|
+
/** The most plain text the read-only state shows, here and in the on-page editor's notice. */
|
|
6
|
+
export declare const UNREADABLE_TEXT_MAX = 100000;
|
|
7
|
+
/** Host-only (`@kardalum/plugin-sdk/host`): wraps the fields of a host that listens for OPEN_HISTORY_EVENT. */
|
|
8
|
+
export declare function RichTextHistoryProvider({ children }: {
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
/** The plain text as paragraphs: one a line, an empty line an empty paragraph, never an empty text node. */
|
|
12
|
+
export declare function paragraphsFromText(text: string): JSONContent;
|
|
13
|
+
export declare function UnreadableRichText({ value, editable, onKeepText }: {
|
|
14
|
+
value: unknown;
|
|
15
|
+
editable: boolean;
|
|
16
|
+
onKeepText(doc: JSONContent): void;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useRef } from "react";
|
|
3
|
+
import { Button } from "@kardalum/ui";
|
|
4
|
+
import { richTextToText } from "@kardalum/api-schemas";
|
|
5
|
+
import { useAdminDirection, useSdkString } from "../sdk-strings.js";
|
|
6
|
+
import { useAdminFormat } from "../view-helpers.js";
|
|
7
|
+
/** M35 C4a (design D7): the page's history opens on this event; ContentEditor listens for it on `document`. */
|
|
8
|
+
export const OPEN_HISTORY_EVENT = "kardalum:open-history";
|
|
9
|
+
/** The most plain text the read-only state shows, here and in the on-page editor's notice. */
|
|
10
|
+
export const UNREADABLE_TEXT_MAX = 100_000;
|
|
11
|
+
/** Whether the host around the field opens a page's history on OPEN_HISTORY_EVENT. Only ContentEditor does, so
|
|
12
|
+
* "Open an earlier version" is offered there and nowhere else (a media item, a plugin settings screen). */
|
|
13
|
+
const RichTextHistoryContext = createContext(false);
|
|
14
|
+
/** Host-only (`@kardalum/plugin-sdk/host`): wraps the fields of a host that listens for OPEN_HISTORY_EVENT. */
|
|
15
|
+
export function RichTextHistoryProvider({ children }) {
|
|
16
|
+
return _jsx(RichTextHistoryContext.Provider, { value: true, children: children });
|
|
17
|
+
}
|
|
18
|
+
/** The plain text as paragraphs: one a line, an empty line an empty paragraph, never an empty text node. */
|
|
19
|
+
export function paragraphsFromText(text) {
|
|
20
|
+
const lines = text.split("\n");
|
|
21
|
+
const content = lines.map((line) => (line.length > 0 ? { type: "paragraph", content: [{ type: "text", text: line }] } : { type: "paragraph" }));
|
|
22
|
+
return { type: "doc", content: content.length > 0 ? content : [{ type: "paragraph" }] };
|
|
23
|
+
}
|
|
24
|
+
export function UnreadableRichText({ value, editable, onKeepText }) {
|
|
25
|
+
const s = useSdkString();
|
|
26
|
+
const dir = useAdminDirection();
|
|
27
|
+
// M35 wave 4 merge (C4a minor 8): the length in the notice is the constant, written for the admin's language.
|
|
28
|
+
const format = useAdminFormat();
|
|
29
|
+
const hasHistory = useContext(RichTextHistoryContext);
|
|
30
|
+
const here = useRef(null);
|
|
31
|
+
// Past UNREADABLE_TEXT_MAX the text is cut, and so is what Keep the text only puts in: the person is told.
|
|
32
|
+
let shortened = false;
|
|
33
|
+
const text = richTextToText(value, {
|
|
34
|
+
maxLength: UNREADABLE_TEXT_MAX,
|
|
35
|
+
onCut: () => {
|
|
36
|
+
shortened = true;
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
return (_jsxs("div", { ref: here, className: "flex flex-col gap-3 rounded-md border border-warning-100 bg-background-elevated p-4", children: [_jsx("p", { role: "status", dir: dir, className: "text-sm text-warning-800", children: s("richText.unreadable") }), _jsx("div", { dir: "auto", "data-testid": "rt-unreadable-text", className: "whitespace-pre-wrap text-sm text-text-primary", children: text }), shortened && (_jsx("p", { dir: dir, className: "text-xs text-text-secondary", children: s("richText.unreadableShortened", { max: format.number(UNREADABLE_TEXT_MAX) }) })), editable && (_jsxs("div", { dir: dir, className: "flex flex-col gap-2", children: [_jsxs("div", { className: "flex flex-wrap gap-2", children: [hasHistory && (_jsx(Button, { type: "button", variant: "secondary", onClick: () => here.current?.dispatchEvent(new CustomEvent(OPEN_HISTORY_EVENT, { bubbles: true })), children: s("richText.unreadableEarlierVersion") })), _jsx(Button, { type: "button", variant: "secondary", onClick: () => onKeepText(paragraphsFromText(text)), children: s("richText.unreadableKeepText") })] }), _jsx("p", { className: "text-xs text-text-secondary", children: s("richText.unreadableKeepTextHint") })] }))] }));
|
|
40
|
+
}
|