@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
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { Extension, Mark, Node } from "@tiptap/core";
|
|
2
|
+
import { NodeSelection, Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
import { Fragment, Slice } from "@tiptap/pm/model";
|
|
4
|
+
import { RICH_TEXT_ITEM_DATA_BYTES_MAX, RICH_TEXT_MAX_DEPTH, utf8Length } from "@kardalum/api-schemas";
|
|
5
|
+
const ITEM_ATTR = "data-kardalum-item";
|
|
6
|
+
const WRAPPER_ATTR = "data-kardalum-wrapper";
|
|
7
|
+
const MARK_ATTR = "data-kardalum-mark";
|
|
8
|
+
const DATA_ATTR = "data-item";
|
|
9
|
+
const ID_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
10
|
+
/** A 12-character id of letters and digits, set by the editor when it inserts an item; the server never sets one. */
|
|
11
|
+
export function newItemId() {
|
|
12
|
+
const bytes = new Uint8Array(12);
|
|
13
|
+
crypto.getRandomValues(bytes);
|
|
14
|
+
let out = "";
|
|
15
|
+
for (const byte of bytes)
|
|
16
|
+
out += ID_ALPHABET[byte % ID_ALPHABET.length];
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
/** "<plugin>/<name>" read back: a plugin id and a name hold no "/". */
|
|
20
|
+
function readRef(raw) {
|
|
21
|
+
if (raw === null || raw.length > 200)
|
|
22
|
+
return { plugin: "", name: "" };
|
|
23
|
+
const slash = raw.indexOf("/");
|
|
24
|
+
return slash < 0 ? { plugin: "", name: "" } : { plugin: raw.slice(0, slash), name: raw.slice(slash + 1) };
|
|
25
|
+
}
|
|
26
|
+
/** Design D12: a `data-item` over 64 KiB or not JSON gives empty values, which the save check then judges. */
|
|
27
|
+
function readItemJson(raw) {
|
|
28
|
+
const empty = { v: 1, id: null, data: {}, text: "", editorial: false };
|
|
29
|
+
if (raw === null || utf8Length(raw) > RICH_TEXT_ITEM_DATA_BYTES_MAX)
|
|
30
|
+
return empty;
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(raw);
|
|
33
|
+
if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed))
|
|
34
|
+
return empty;
|
|
35
|
+
const record = parsed;
|
|
36
|
+
const data = record.data;
|
|
37
|
+
return {
|
|
38
|
+
v: typeof record.v === "number" ? record.v : 1,
|
|
39
|
+
id: typeof record.id === "string" ? record.id : null,
|
|
40
|
+
data: data !== null && typeof data === "object" && !Array.isArray(data) ? data : {},
|
|
41
|
+
text: typeof record.text === "string" ? record.text : "",
|
|
42
|
+
editorial: record.editorial === true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return empty;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Each element's `data-item` is read once for its five JSON attributes: one item of up to 64 KiB is measured and
|
|
50
|
+
// parsed once, not once an attribute. Keyed by the element and checked against the raw text, so a changed attribute
|
|
51
|
+
// is read anew and no two elements share a parsed object.
|
|
52
|
+
const parsedItemJson = new WeakMap();
|
|
53
|
+
function itemJsonOf(element) {
|
|
54
|
+
const raw = element.getAttribute(DATA_ATTR);
|
|
55
|
+
const known = parsedItemJson.get(element);
|
|
56
|
+
if (known && known.raw === raw)
|
|
57
|
+
return known.json;
|
|
58
|
+
const json = readItemJson(raw);
|
|
59
|
+
parsedItemJson.set(element, { raw, json });
|
|
60
|
+
return json;
|
|
61
|
+
}
|
|
62
|
+
/** The first character of a label, a whole code point (never half a surrogate pair), upper-cased. */
|
|
63
|
+
export function firstLetterOf(label) {
|
|
64
|
+
const first = label.codePointAt(0);
|
|
65
|
+
return first === undefined ? "" : String.fromCodePoint(first).toUpperCase();
|
|
66
|
+
}
|
|
67
|
+
function attributesOf(refAttr, withText) {
|
|
68
|
+
const fromJson = (key) => (element) => itemJsonOf(element)[key];
|
|
69
|
+
return {
|
|
70
|
+
plugin: { default: "", parseHTML: (element) => readRef(element.getAttribute(refAttr)).plugin, renderHTML: () => ({}) },
|
|
71
|
+
name: { default: "", parseHTML: (element) => readRef(element.getAttribute(refAttr)).name, renderHTML: () => ({}) },
|
|
72
|
+
v: { default: 1, parseHTML: fromJson("v"), renderHTML: () => ({}) },
|
|
73
|
+
id: { default: null, parseHTML: fromJson("id"), renderHTML: () => ({}) },
|
|
74
|
+
data: { default: {}, parseHTML: fromJson("data"), renderHTML: () => ({}) },
|
|
75
|
+
...(withText ? { text: { default: "", parseHTML: fromJson("text"), renderHTML: () => ({}) } } : {}),
|
|
76
|
+
editorial: { default: false, parseHTML: fromJson("editorial"), renderHTML: () => ({}) },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function htmlAttributesOf(attrs, refAttr, withText) {
|
|
80
|
+
const json = { v: attrs.v, id: attrs.id, data: attrs.data };
|
|
81
|
+
if (withText)
|
|
82
|
+
json.text = attrs.text;
|
|
83
|
+
json.editorial = attrs.editorial;
|
|
84
|
+
return { [refAttr]: `${String(attrs.plugin)}/${String(attrs.name)}`, [DATA_ATTR]: JSON.stringify(json) };
|
|
85
|
+
}
|
|
86
|
+
/** A chip, or on page the server render once setItemHtml has it: plain DOM, an atom the editor never edits. */
|
|
87
|
+
function itemView(options, type) {
|
|
88
|
+
return ({ node, view, getPos }) => {
|
|
89
|
+
let current = node;
|
|
90
|
+
const inline = type === "pluginInline";
|
|
91
|
+
const dom = document.createElement(inline ? "span" : "div");
|
|
92
|
+
dom.contentEditable = "false";
|
|
93
|
+
dom.className = inline
|
|
94
|
+
? "inline-flex items-center gap-1 rounded-sm border border-border-default bg-background-subtle px-1 text-xs text-text-secondary"
|
|
95
|
+
: "my-3 flex items-center gap-2 rounded-md border border-dashed border-border-default bg-background-subtle px-3 py-2 text-xs text-text-secondary";
|
|
96
|
+
const icon = document.createElement("span");
|
|
97
|
+
icon.setAttribute("aria-hidden", "true");
|
|
98
|
+
const label = document.createElement("b");
|
|
99
|
+
label.className = "font-semibold text-text-primary";
|
|
100
|
+
const short = document.createElement("bdi");
|
|
101
|
+
const state = document.createElement("span");
|
|
102
|
+
state.className = inline ? "sr-only" : "ms-auto text-text-tertiary";
|
|
103
|
+
const rendered = document.createElement(inline ? "span" : "div");
|
|
104
|
+
rendered.hidden = true;
|
|
105
|
+
dom.append(icon, label, short, state, rendered);
|
|
106
|
+
let clearIcon = null;
|
|
107
|
+
const paint = () => {
|
|
108
|
+
const plugin = String(current.attrs.plugin);
|
|
109
|
+
const name = String(current.attrs.name);
|
|
110
|
+
dom.setAttribute(ITEM_ATTR, `${plugin}/${name}`);
|
|
111
|
+
const described = options.items?.describe(type, plugin, name) ?? { label: `${plugin}/${name}`, icon: null, state: null, on: false };
|
|
112
|
+
label.textContent = described.label;
|
|
113
|
+
short.textContent = typeof current.attrs.text === "string" ? current.attrs.text : "";
|
|
114
|
+
state.textContent = described.state ?? "";
|
|
115
|
+
clearIcon?.();
|
|
116
|
+
if (options.items?.renderIcon)
|
|
117
|
+
clearIcon = options.items.renderIcon(icon, described.icon, described.label);
|
|
118
|
+
else
|
|
119
|
+
icon.textContent = firstLetterOf(described.label);
|
|
120
|
+
};
|
|
121
|
+
if (options.mode === "onPage") {
|
|
122
|
+
dom.__kardalumSetItemHtml = (html) => {
|
|
123
|
+
rendered.innerHTML = html;
|
|
124
|
+
rendered.hidden = false;
|
|
125
|
+
// The edit-mode stylesheet draws the chip only until its preview is in (edit-mode.css).
|
|
126
|
+
dom.setAttribute("data-kardalum-item-preview", "");
|
|
127
|
+
icon.hidden = label.hidden = short.hidden = state.hidden = true;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
dom.addEventListener("mousedown", () => {
|
|
131
|
+
const pos = typeof getPos === "function" ? getPos() : undefined;
|
|
132
|
+
if (typeof pos === "number")
|
|
133
|
+
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)));
|
|
134
|
+
});
|
|
135
|
+
if (options.mode === "onPage") {
|
|
136
|
+
dom.addEventListener("click", (event) => {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
paint();
|
|
142
|
+
const unsubscribe = options.items?.subscribe(paint);
|
|
143
|
+
return {
|
|
144
|
+
dom,
|
|
145
|
+
update: (updated) => {
|
|
146
|
+
if (updated.type !== current.type)
|
|
147
|
+
return false;
|
|
148
|
+
current = updated;
|
|
149
|
+
paint();
|
|
150
|
+
return true;
|
|
151
|
+
},
|
|
152
|
+
selectNode: () => dom.classList.add("ring-2", "ring-primary-600"),
|
|
153
|
+
deselectNode: () => dom.classList.remove("ring-2", "ring-primary-600"),
|
|
154
|
+
destroy: () => {
|
|
155
|
+
unsubscribe?.();
|
|
156
|
+
clearIcon?.();
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export const PluginBlock = Node.create({
|
|
162
|
+
name: "pluginBlock",
|
|
163
|
+
group: "block",
|
|
164
|
+
atom: true,
|
|
165
|
+
selectable: true,
|
|
166
|
+
draggable: false,
|
|
167
|
+
addOptions: () => ({ items: undefined, mode: "chip" }),
|
|
168
|
+
addAttributes: () => attributesOf(ITEM_ATTR, true),
|
|
169
|
+
parseHTML: () => [{ tag: `div[${ITEM_ATTR}]` }],
|
|
170
|
+
renderHTML: ({ node }) => ["div", htmlAttributesOf(node.attrs, ITEM_ATTR, true)],
|
|
171
|
+
renderText: ({ node }) => (typeof node.attrs.text === "string" ? node.attrs.text : ""),
|
|
172
|
+
addNodeView() {
|
|
173
|
+
return itemView(this.options, "pluginBlock");
|
|
174
|
+
},
|
|
175
|
+
addCommands() {
|
|
176
|
+
return {
|
|
177
|
+
insertPluginItem: (type, attrs) => ({ commands }) => commands.insertContent({ type, attrs: { ...attrs, id: attrs.id ?? newItemId() }, ...(type === "pluginWrapper" ? { content: [{ type: "paragraph" }] } : {}) }),
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
export const PluginInline = Node.create({
|
|
182
|
+
name: "pluginInline",
|
|
183
|
+
group: "inline",
|
|
184
|
+
inline: true,
|
|
185
|
+
atom: true,
|
|
186
|
+
selectable: true,
|
|
187
|
+
draggable: false,
|
|
188
|
+
addOptions: () => ({ items: undefined, mode: "chip" }),
|
|
189
|
+
addAttributes: () => attributesOf(ITEM_ATTR, true),
|
|
190
|
+
parseHTML: () => [{ tag: `span[${ITEM_ATTR}]` }],
|
|
191
|
+
renderHTML: ({ node }) => ["span", htmlAttributesOf(node.attrs, ITEM_ATTR, true)],
|
|
192
|
+
renderText: ({ node }) => (typeof node.attrs.text === "string" ? node.attrs.text : ""),
|
|
193
|
+
addNodeView() {
|
|
194
|
+
return itemView(this.options, "pluginInline");
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
export const PluginWrapper = Node.create({
|
|
198
|
+
name: "pluginWrapper",
|
|
199
|
+
group: "block",
|
|
200
|
+
content: "block+",
|
|
201
|
+
defining: true,
|
|
202
|
+
isolating: true,
|
|
203
|
+
addOptions: () => ({ items: undefined, mode: "chip" }),
|
|
204
|
+
addAttributes: () => attributesOf(WRAPPER_ATTR, true),
|
|
205
|
+
parseHTML: () => [{ tag: `div[${WRAPPER_ATTR}]` }],
|
|
206
|
+
renderHTML: ({ node }) => ["div", htmlAttributesOf(node.attrs, WRAPPER_ATTR, true), 0],
|
|
207
|
+
addNodeView() {
|
|
208
|
+
const options = this.options;
|
|
209
|
+
return ({ node, view, getPos }) => {
|
|
210
|
+
let current = node;
|
|
211
|
+
const dom = document.createElement("div");
|
|
212
|
+
dom.className = "my-3 rounded-md border border-border-default bg-background-subtle";
|
|
213
|
+
const header = document.createElement("div");
|
|
214
|
+
header.contentEditable = "false";
|
|
215
|
+
header.className = "border-b border-border-default px-3 py-1 text-xs font-semibold text-text-secondary";
|
|
216
|
+
// The header is the wrapper's chip: pressing it selects the whole wrapper, so its item panel opens from its label.
|
|
217
|
+
header.addEventListener("mousedown", (event) => {
|
|
218
|
+
const pos = typeof getPos === "function" ? getPos() : undefined;
|
|
219
|
+
if (typeof pos !== "number")
|
|
220
|
+
return;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, pos)));
|
|
223
|
+
});
|
|
224
|
+
const contentDOM = document.createElement("div");
|
|
225
|
+
contentDOM.className = "px-3 py-2";
|
|
226
|
+
dom.append(header, contentDOM);
|
|
227
|
+
// The label is the plugin's words in the content's language (S366f D10), so it sits in a bdi of its own, as the
|
|
228
|
+
// block chip's short text does, and the state follows it in the admin's language.
|
|
229
|
+
const labelIsolate = document.createElement("bdi");
|
|
230
|
+
const label = document.createElement("b");
|
|
231
|
+
label.className = "font-semibold";
|
|
232
|
+
labelIsolate.append(label);
|
|
233
|
+
const state = document.createElement("span");
|
|
234
|
+
state.className = "ms-2 font-normal text-text-tertiary";
|
|
235
|
+
header.append(labelIsolate, state);
|
|
236
|
+
const paint = () => {
|
|
237
|
+
const plugin = String(current.attrs.plugin);
|
|
238
|
+
const name = String(current.attrs.name);
|
|
239
|
+
dom.setAttribute(WRAPPER_ATTR, `${plugin}/${name}`);
|
|
240
|
+
const described = options.items?.describe("pluginWrapper", plugin, name) ?? { label: `${plugin}/${name}`, state: null };
|
|
241
|
+
label.textContent = described.label;
|
|
242
|
+
state.textContent = described.state ?? "";
|
|
243
|
+
state.hidden = !described.state;
|
|
244
|
+
};
|
|
245
|
+
paint();
|
|
246
|
+
const unsubscribe = options.items?.subscribe(paint);
|
|
247
|
+
return {
|
|
248
|
+
dom,
|
|
249
|
+
contentDOM,
|
|
250
|
+
update: (updated) => {
|
|
251
|
+
if (updated.type !== current.type)
|
|
252
|
+
return false;
|
|
253
|
+
current = updated;
|
|
254
|
+
paint();
|
|
255
|
+
return true;
|
|
256
|
+
},
|
|
257
|
+
destroy: () => unsubscribe?.(),
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
},
|
|
261
|
+
});
|
|
262
|
+
function removeOwnMarks(tr, doc, from, to, type, ref) {
|
|
263
|
+
const found = [];
|
|
264
|
+
doc.nodesBetween(from, to, (node, pos) => {
|
|
265
|
+
for (const mark of node.marks) {
|
|
266
|
+
if (mark.type === type && mark.attrs.plugin === ref.plugin && mark.attrs.name === ref.name)
|
|
267
|
+
found.push({ from: Math.max(pos, from), to: Math.min(pos + node.nodeSize, to), mark });
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
for (const each of found)
|
|
271
|
+
tr.removeMark(each.from, each.to, each.mark);
|
|
272
|
+
}
|
|
273
|
+
/** M35 C4b: design D2's mark write in a transaction the caller owns (the commands below and the editor handle): this
|
|
274
|
+
* plugin's mark of this name set over [from, to], its earlier instances there removed first. */
|
|
275
|
+
export function applyPluginMark(tr, doc, from, to, type, attrs) {
|
|
276
|
+
removeOwnMarks(tr, doc, from, to, type, attrs);
|
|
277
|
+
tr.addMark(from, to, type.create({ ...attrs, id: attrs.id ?? newItemId() }));
|
|
278
|
+
}
|
|
279
|
+
/** M35 C4b: this plugin's mark of this name removed over [from, to]; another plugin's marks stay. */
|
|
280
|
+
export function removePluginMark(tr, doc, from, to, type, ref) {
|
|
281
|
+
removeOwnMarks(tr, doc, from, to, type, ref);
|
|
282
|
+
}
|
|
283
|
+
/** The data of this plugin's mark of this name where the selection starts (a stored mark on an empty selection), or
|
|
284
|
+
* null when none is there: what the mark form opens with when the mark is already set. */
|
|
285
|
+
export function pluginMarkDataAt(editor, ref) {
|
|
286
|
+
const { from, to, empty } = editor.state.selection;
|
|
287
|
+
const own = (mark) => mark.type.name === "pluginMark" && mark.attrs.plugin === ref.plugin && mark.attrs.name === ref.name;
|
|
288
|
+
const dataOf = (mark) => {
|
|
289
|
+
const data = mark?.attrs.data;
|
|
290
|
+
return data !== null && typeof data === "object" && !Array.isArray(data) ? data : mark ? {} : null;
|
|
291
|
+
};
|
|
292
|
+
if (empty)
|
|
293
|
+
return dataOf((editor.state.storedMarks ?? editor.state.selection.$from.marks()).find(own));
|
|
294
|
+
let found;
|
|
295
|
+
editor.state.doc.nodesBetween(from, to, (node) => {
|
|
296
|
+
if (found || !node.isText)
|
|
297
|
+
return !found;
|
|
298
|
+
found = node.marks.find(own);
|
|
299
|
+
return !found;
|
|
300
|
+
});
|
|
301
|
+
return dataOf(found);
|
|
302
|
+
}
|
|
303
|
+
/** Whether every text in the selection carries this plugin's mark of this name. */
|
|
304
|
+
export function isPluginMarkActive(editor, ref) {
|
|
305
|
+
const { from, to, empty } = editor.state.selection;
|
|
306
|
+
if (empty)
|
|
307
|
+
return editor.state.storedMarks?.some((mark) => mark.type.name === "pluginMark" && mark.attrs.plugin === ref.plugin && mark.attrs.name === ref.name) ?? false;
|
|
308
|
+
let texts = 0;
|
|
309
|
+
let marked = 0;
|
|
310
|
+
editor.state.doc.nodesBetween(from, to, (node) => {
|
|
311
|
+
if (!node.isText)
|
|
312
|
+
return;
|
|
313
|
+
texts += 1;
|
|
314
|
+
if (node.marks.some((mark) => mark.type.name === "pluginMark" && mark.attrs.plugin === ref.plugin && mark.attrs.name === ref.name))
|
|
315
|
+
marked += 1;
|
|
316
|
+
});
|
|
317
|
+
return texts > 0 && texts === marked;
|
|
318
|
+
}
|
|
319
|
+
export const PluginMark = Mark.create({
|
|
320
|
+
name: "pluginMark",
|
|
321
|
+
excludes: "",
|
|
322
|
+
inclusive: false,
|
|
323
|
+
addOptions: () => ({ items: undefined, mode: "chip" }),
|
|
324
|
+
addAttributes: () => attributesOf(MARK_ATTR, false),
|
|
325
|
+
parseHTML: () => [{ tag: `span[${MARK_ATTR}]` }],
|
|
326
|
+
renderHTML: ({ mark }) => ["span", { ...htmlAttributesOf(mark.attrs, MARK_ATTR, false), class: "underline decoration-dotted decoration-primary-600" }, 0],
|
|
327
|
+
addCommands() {
|
|
328
|
+
return {
|
|
329
|
+
setPluginMark: (attrs) => ({ tr, state, dispatch }) => {
|
|
330
|
+
const type = state.schema.marks.pluginMark;
|
|
331
|
+
const { from, to, empty } = state.selection;
|
|
332
|
+
if (empty)
|
|
333
|
+
return false;
|
|
334
|
+
if (dispatch)
|
|
335
|
+
applyPluginMark(tr, state.doc, from, to, type, attrs);
|
|
336
|
+
return true;
|
|
337
|
+
},
|
|
338
|
+
unsetPluginMark: (ref) => ({ tr, state, dispatch }) => {
|
|
339
|
+
const { from, to } = state.selection;
|
|
340
|
+
if (dispatch)
|
|
341
|
+
removePluginMark(tr, state.doc, from, to, state.schema.marks.pluginMark, ref);
|
|
342
|
+
return true;
|
|
343
|
+
},
|
|
344
|
+
togglePluginMark: (attrs) => ({ editor, commands }) => isPluginMarkActive(editor, attrs) ? commands.unsetPluginMark(attrs) : commands.setPluginMark(attrs),
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
/** ProseMirror's own textBetween carries a leaf item's short text (design D2). */
|
|
349
|
+
export const PluginItemText = Extension.create({
|
|
350
|
+
name: "pluginItemText",
|
|
351
|
+
extendNodeSchema(extension) {
|
|
352
|
+
return extension.name === "pluginBlock" || extension.name === "pluginInline"
|
|
353
|
+
? { leafText: (node) => (typeof node.attrs.text === "string" ? node.attrs.text : "") }
|
|
354
|
+
: {};
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
/** Design D12: pasted HTML keeps items only when it came from an editor (`data-pm-slice`); otherwise each item becomes
|
|
358
|
+
* its short text, each wrapper its content and each plugin mark its text. C4a-D9 names the residual risk. */
|
|
359
|
+
export function keepItemsOnlyFromEditor(html) {
|
|
360
|
+
const parsed = new DOMParser().parseFromString(html, "text/html");
|
|
361
|
+
// C4a-D9: only the outermost element counts, where ProseMirror's serializeForClipboard writes it (a `<meta>` a
|
|
362
|
+
// browser puts first is moved into the head by the parser, and comments are not elements).
|
|
363
|
+
if (parsed.body.firstElementChild?.hasAttribute("data-pm-slice") === true)
|
|
364
|
+
return html;
|
|
365
|
+
const items = [...parsed.body.querySelectorAll(`[${ITEM_ATTR}],[${WRAPPER_ATTR}],[${MARK_ATTR}]`)];
|
|
366
|
+
if (items.length === 0)
|
|
367
|
+
return html;
|
|
368
|
+
for (const element of items.reverse()) {
|
|
369
|
+
if (element.hasAttribute(ITEM_ATTR)) {
|
|
370
|
+
const text = readItemJson(element.getAttribute(DATA_ATTR)).text;
|
|
371
|
+
if (element.tagName === "DIV") {
|
|
372
|
+
if (text === "")
|
|
373
|
+
element.remove();
|
|
374
|
+
else {
|
|
375
|
+
const paragraph = parsed.createElement("p");
|
|
376
|
+
paragraph.textContent = text;
|
|
377
|
+
element.replaceWith(paragraph);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
else
|
|
381
|
+
element.replaceWith(parsed.createTextNode(text));
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
element.replaceWith(...element.childNodes);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return parsed.body.innerHTML;
|
|
388
|
+
}
|
|
389
|
+
/** Design D2: an id is kept when an item moves within the editor and made anew when a paste would repeat one. A node
|
|
390
|
+
* is one item, so each repeat of its id is another item and gets its own id. One plugin mark spans every text node
|
|
391
|
+
* it covers (a bold word inside a highlight is three text nodes), so `markIds` maps a repeated mark id to one new id
|
|
392
|
+
* for the whole paste, and the runs of the pasted mark stay one item. */
|
|
393
|
+
function freshIds(fragment, taken, markIds, depth, fillMissing = false) {
|
|
394
|
+
if (depth > RICH_TEXT_MAX_DEPTH)
|
|
395
|
+
return fragment;
|
|
396
|
+
const children = [];
|
|
397
|
+
fragment.forEach((child) => {
|
|
398
|
+
let node = child;
|
|
399
|
+
const isItem = node.type.name === "pluginBlock" || node.type.name === "pluginInline" || node.type.name === "pluginWrapper";
|
|
400
|
+
// M35 C4b (C4b-D8): the handle's insertContent also gives an item with no id a new one.
|
|
401
|
+
if (isItem && fillMissing && typeof node.attrs.id !== "string")
|
|
402
|
+
node = node.type.create({ ...node.attrs, id: newItemId() }, node.content, node.marks);
|
|
403
|
+
if (isItem && typeof node.attrs.id === "string") {
|
|
404
|
+
if (taken.has(node.attrs.id))
|
|
405
|
+
node = node.type.create({ ...node.attrs, id: newItemId() }, node.content, node.marks);
|
|
406
|
+
taken.add(node.attrs.id);
|
|
407
|
+
}
|
|
408
|
+
const marks = node.marks.map((mark) => {
|
|
409
|
+
if (mark.type.name !== "pluginMark" || typeof mark.attrs.id !== "string" || !taken.has(mark.attrs.id))
|
|
410
|
+
return mark;
|
|
411
|
+
let renewed = markIds.get(mark.attrs.id);
|
|
412
|
+
if (renewed === undefined) {
|
|
413
|
+
renewed = newItemId();
|
|
414
|
+
markIds.set(mark.attrs.id, renewed);
|
|
415
|
+
}
|
|
416
|
+
return mark.type.create({ ...mark.attrs, id: renewed });
|
|
417
|
+
});
|
|
418
|
+
if (marks.some((mark, index) => mark !== node.marks[index]))
|
|
419
|
+
node = node.mark(marks);
|
|
420
|
+
if (node.content.size > 0)
|
|
421
|
+
node = node.copy(freshIds(node.content, taken, markIds, depth + 1, fillMissing));
|
|
422
|
+
children.push(node);
|
|
423
|
+
});
|
|
424
|
+
return Fragment.fromArray(children);
|
|
425
|
+
}
|
|
426
|
+
/** M35 C4b: the fresh id rule of a paste (design D2), for the paste and the handle's insertContent alike: an id the
|
|
427
|
+
* document already holds is made anew, and with `fillMissing` an item with no id gets one. */
|
|
428
|
+
export function withFreshItemIds(fragment, doc, fillMissing = false) {
|
|
429
|
+
const taken = new Set();
|
|
430
|
+
doc.descendants((node) => {
|
|
431
|
+
if (typeof node.attrs.id === "string" && (node.type.name === "pluginBlock" || node.type.name === "pluginInline" || node.type.name === "pluginWrapper"))
|
|
432
|
+
taken.add(node.attrs.id);
|
|
433
|
+
for (const mark of node.marks)
|
|
434
|
+
if (mark.type.name === "pluginMark" && typeof mark.attrs.id === "string")
|
|
435
|
+
taken.add(mark.attrs.id);
|
|
436
|
+
});
|
|
437
|
+
return freshIds(fragment, taken, new Map(), 0, fillMissing);
|
|
438
|
+
}
|
|
439
|
+
// M35 C4b (design D12, C4b-D11): the last copy's editorial items for this tab, by id: a copy never puts their data on the
|
|
440
|
+
// system clipboard, and a paste in this tab restores it. Cleared at each copy, so it holds one copy's items at most.
|
|
441
|
+
const editorialMemory = new Map();
|
|
442
|
+
function isItemNode(node) {
|
|
443
|
+
return node.type.name === "pluginBlock" || node.type.name === "pluginInline" || node.type.name === "pluginWrapper";
|
|
444
|
+
}
|
|
445
|
+
function hideEditorial(fragment, depth) {
|
|
446
|
+
if (depth > RICH_TEXT_MAX_DEPTH)
|
|
447
|
+
return Fragment.empty;
|
|
448
|
+
const children = [];
|
|
449
|
+
fragment.forEach((child) => {
|
|
450
|
+
let node = child;
|
|
451
|
+
if (isItemNode(node) && node.attrs.editorial === true) {
|
|
452
|
+
if (typeof node.attrs.id === "string")
|
|
453
|
+
editorialMemory.set(node.attrs.id, { data: node.attrs.data, text: String(node.attrs.text ?? "") });
|
|
454
|
+
node = node.type.create({ ...node.attrs, data: {}, text: "" }, node.content, node.marks);
|
|
455
|
+
}
|
|
456
|
+
const marks = node.marks.map((mark) => {
|
|
457
|
+
if (mark.type.name !== "pluginMark" || mark.attrs.editorial !== true)
|
|
458
|
+
return mark;
|
|
459
|
+
if (typeof mark.attrs.id === "string")
|
|
460
|
+
editorialMemory.set(mark.attrs.id, { data: mark.attrs.data, text: "" });
|
|
461
|
+
return mark.type.create({ ...mark.attrs, data: {} });
|
|
462
|
+
});
|
|
463
|
+
if (marks.some((mark, index) => mark !== node.marks[index]))
|
|
464
|
+
node = node.mark(marks);
|
|
465
|
+
if (node.content.size > 0)
|
|
466
|
+
node = node.copy(hideEditorial(node.content, depth + 1));
|
|
467
|
+
children.push(node);
|
|
468
|
+
});
|
|
469
|
+
return Fragment.fromArray(children);
|
|
470
|
+
}
|
|
471
|
+
function restoreEditorial(fragment, depth) {
|
|
472
|
+
if (depth > RICH_TEXT_MAX_DEPTH)
|
|
473
|
+
return Fragment.empty;
|
|
474
|
+
const children = [];
|
|
475
|
+
fragment.forEach((child) => {
|
|
476
|
+
let node = child;
|
|
477
|
+
if (isItemNode(node) && node.attrs.editorial === true) {
|
|
478
|
+
const kept = typeof node.attrs.id === "string" ? editorialMemory.get(node.attrs.id) : undefined;
|
|
479
|
+
if (!kept) {
|
|
480
|
+
// Not this tab's copy: a block or inline item goes, a wrapper leaves its content.
|
|
481
|
+
if (node.type.name === "pluginWrapper")
|
|
482
|
+
restoreEditorial(node.content, depth + 1).forEach((inner) => children.push(inner));
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
node = node.type.create({ ...node.attrs, data: kept.data, text: kept.text }, node.content, node.marks);
|
|
486
|
+
}
|
|
487
|
+
const marks = node.marks.flatMap((mark) => {
|
|
488
|
+
if (mark.type.name !== "pluginMark" || mark.attrs.editorial !== true)
|
|
489
|
+
return [mark];
|
|
490
|
+
const kept = typeof mark.attrs.id === "string" ? editorialMemory.get(mark.attrs.id) : undefined;
|
|
491
|
+
return kept ? [mark.type.create({ ...mark.attrs, data: kept.data })] : [];
|
|
492
|
+
});
|
|
493
|
+
if (marks.length !== node.marks.length || marks.some((mark, index) => mark !== node.marks[index]))
|
|
494
|
+
node = node.mark(marks);
|
|
495
|
+
if (node.content.size > 0)
|
|
496
|
+
node = node.copy(restoreEditorial(node.content, depth + 1));
|
|
497
|
+
children.push(node);
|
|
498
|
+
});
|
|
499
|
+
return Fragment.fromArray(children);
|
|
500
|
+
}
|
|
501
|
+
export const PluginItemPaste = Extension.create({
|
|
502
|
+
name: "pluginItemPaste",
|
|
503
|
+
addProseMirrorPlugins() {
|
|
504
|
+
return [
|
|
505
|
+
new Plugin({
|
|
506
|
+
key: new PluginKey("kardalumPluginItemPaste"),
|
|
507
|
+
props: {
|
|
508
|
+
transformPastedHTML: (html) => keepItemsOnlyFromEditor(html),
|
|
509
|
+
// M35 C4b (design D12, C4b-D11): a copy (and a drag, which prosemirror-view serializes the same way) never puts
|
|
510
|
+
// an editorial item's data on the system clipboard; this tab keeps it until the next copy.
|
|
511
|
+
transformCopied: (slice) => {
|
|
512
|
+
editorialMemory.clear();
|
|
513
|
+
return new Slice(hideEditorial(slice.content, 0), slice.openStart, slice.openEnd);
|
|
514
|
+
},
|
|
515
|
+
transformPasted: (incoming, view) => {
|
|
516
|
+
// The identity test needs the untouched slice: prosemirror-view keeps the transformed copy as
|
|
517
|
+
// view.dragging.slice, so a drag-move is recognised before the restore below makes a new one.
|
|
518
|
+
const moving = view.dragging !== null && view.dragging.slice === incoming && view.dragging.move;
|
|
519
|
+
// The editorial restore runs first, the drag-move included, so a moved editorial item keeps its data.
|
|
520
|
+
const slice = new Slice(restoreEditorial(incoming.content, 0), incoming.openStart, incoming.openEnd);
|
|
521
|
+
// A drag that moves its own slice (prosemirror-view runs transformPasted on a drop while the source is
|
|
522
|
+
// still in the document, `input.ts:790`): the item moves, so it keeps its id.
|
|
523
|
+
if (moving)
|
|
524
|
+
return slice;
|
|
525
|
+
return new Slice(withFreshItemIds(slice.content, view.state.doc), slice.openStart, slice.openEnd);
|
|
526
|
+
},
|
|
527
|
+
},
|
|
528
|
+
}),
|
|
529
|
+
];
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
const ITEM_TYPES = new Set(["pluginBlock", "pluginInline", "pluginWrapper"]);
|
|
533
|
+
export function selectedPluginItem(editor) {
|
|
534
|
+
const { selection } = editor.state;
|
|
535
|
+
if (!(selection instanceof NodeSelection) || !ITEM_TYPES.has(selection.node.type.name))
|
|
536
|
+
return null;
|
|
537
|
+
return { pos: selection.from, type: selection.node.type.name, attrs: selection.node.attrs };
|
|
538
|
+
}
|
|
539
|
+
export function findPluginItems(editor) {
|
|
540
|
+
const found = [];
|
|
541
|
+
editor.state.doc.descendants((node, pos) => {
|
|
542
|
+
if (ITEM_TYPES.has(node.type.name))
|
|
543
|
+
found.push({ pos, type: node.type.name, attrs: node.attrs });
|
|
544
|
+
return true;
|
|
545
|
+
});
|
|
546
|
+
return found;
|
|
547
|
+
}
|
|
548
|
+
/** The on-page view's server render, set without touching the node's attrs (the HTML is never stored). */
|
|
549
|
+
export function setItemHtml(editor, pos, html) {
|
|
550
|
+
if (editor.isDestroyed)
|
|
551
|
+
return;
|
|
552
|
+
let dom;
|
|
553
|
+
try {
|
|
554
|
+
dom = editor.view.nodeDOM(pos);
|
|
555
|
+
}
|
|
556
|
+
catch {
|
|
557
|
+
return;
|
|
558
|
+
}
|
|
559
|
+
const handle = dom?.__kardalumSetItemHtml;
|
|
560
|
+
if (typeof handle === "function")
|
|
561
|
+
handle(html);
|
|
562
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
import { Decoration, DecorationSet } from "@tiptap/pm/view";
|
|
4
|
+
// M35 C4b (design D8, C4a review note 17): a plugin mark is drawn with its label as a tooltip, as a decoration redrawn
|
|
5
|
+
// when the item directory changes. The mark's renderHTML also writes the stored HTML form and runs before the listing
|
|
6
|
+
// arrives, so the title cannot live there. A redraw is a transaction with no step: no onUpdate, no undo entry.
|
|
7
|
+
const key = new PluginKey("kardalumPluginMarkTooltips");
|
|
8
|
+
function tooltips(doc, items) {
|
|
9
|
+
const decorations = [];
|
|
10
|
+
doc.descendants((node, pos) => {
|
|
11
|
+
if (!node.isText)
|
|
12
|
+
return;
|
|
13
|
+
const labels = node.marks.filter((mark) => mark.type.name === "pluginMark").map((mark) => items.describe("pluginMark", String(mark.attrs.plugin), String(mark.attrs.name)).label);
|
|
14
|
+
if (labels.length > 0)
|
|
15
|
+
decorations.push(Decoration.inline(pos, pos + node.nodeSize, { title: labels.join(", ") }));
|
|
16
|
+
});
|
|
17
|
+
return DecorationSet.create(doc, decorations);
|
|
18
|
+
}
|
|
19
|
+
export const PluginMarkTooltips = Extension.create({
|
|
20
|
+
name: "pluginMarkTooltips",
|
|
21
|
+
addOptions: () => ({ items: undefined }),
|
|
22
|
+
addProseMirrorPlugins() {
|
|
23
|
+
const items = this.options.items;
|
|
24
|
+
if (!items)
|
|
25
|
+
return [];
|
|
26
|
+
return [
|
|
27
|
+
new Plugin({
|
|
28
|
+
key,
|
|
29
|
+
state: {
|
|
30
|
+
init: (_, state) => tooltips(state.doc, items),
|
|
31
|
+
apply: (tr, old, _before, state) => (tr.docChanged || tr.getMeta(key) === true ? tooltips(state.doc, items) : old),
|
|
32
|
+
},
|
|
33
|
+
props: { decorations: (state) => key.getState(state) },
|
|
34
|
+
view: (view) => {
|
|
35
|
+
const unsubscribe = items.subscribe(() => {
|
|
36
|
+
if (!view.isDestroyed)
|
|
37
|
+
view.dispatch(view.state.tr.setMeta(key, true).setMeta("addToHistory", false));
|
|
38
|
+
});
|
|
39
|
+
return { destroy: unsubscribe };
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
];
|
|
43
|
+
},
|
|
44
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type KeyboardEvent } from "react";
|
|
2
|
+
import type { Editor } from "@tiptap/core";
|
|
3
|
+
import { type RichItemMarkListing, type RichItemNodeListing } from "@kardalum/api-schemas";
|
|
4
|
+
import type { RichItemDirectory } from "./rich-items.js";
|
|
5
|
+
export interface ToolbarEntry {
|
|
6
|
+
key: string;
|
|
7
|
+
plugin: string;
|
|
8
|
+
label: string;
|
|
9
|
+
icon: string | null;
|
|
10
|
+
does: {
|
|
11
|
+
insert: RichItemNodeListing;
|
|
12
|
+
} | {
|
|
13
|
+
toggle: RichItemMarkListing;
|
|
14
|
+
} | {
|
|
15
|
+
view: {
|
|
16
|
+
buttonId: string;
|
|
17
|
+
action: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Design D5: the plugin buttons in plugin id order, the first RICH_TEXT_TOOLBAR_PLUGIN_BUTTONS_MAX on the toolbar, the
|
|
22
|
+
* rest and every declared mark under More. Re-read when the listing arrives. */
|
|
23
|
+
export declare function usePluginToolbarEntries(items: RichItemDirectory, language: string): {
|
|
24
|
+
shown: ToolbarEntry[];
|
|
25
|
+
more: ToolbarEntry[];
|
|
26
|
+
};
|
|
27
|
+
/** What an entry does: insert its node, or toggle its mark. A mark with attributes always goes through its form,
|
|
28
|
+
* opened with the set mark's data when it is already there, so its data can be changed (Apply) or the mark removed
|
|
29
|
+
* (Remove). */
|
|
30
|
+
export declare function runToolbarEntry(editor: Editor, entry: ToolbarEntry, openMarkForm: (entry: ToolbarEntry, initial: Record<string, unknown>) => void, openButtonView?: (entry: ToolbarEntry) => void): void;
|
|
31
|
+
/** The one keyboard rule of the plugin menus (More, and the pasted address choice, M35 C4b): an ARIA menu with the arrow
|
|
32
|
+
* keys, Home, End, Enter, Space and Escape, as StyleListbox handles its listbox. Its keys stop at the menu, so the
|
|
33
|
+
* toolbar's own roving keys do not move focus out of it. The first item takes focus when the menu opens. */
|
|
34
|
+
export declare function useMenuKeys(count: number, onChoose: (index: number) => void, onClose: () => void): {
|
|
35
|
+
activeIndex: number;
|
|
36
|
+
setActiveIndex: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
37
|
+
itemRefs: import("react").RefObject<(HTMLDivElement | null)[]>;
|
|
38
|
+
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
39
|
+
};
|
|
40
|
+
export interface PluginToolbarGroupProps {
|
|
41
|
+
editor: Editor;
|
|
42
|
+
/** M35 C4b (design D16): the directory a button view's editor handle reads, and the field's culture. */
|
|
43
|
+
items: RichItemDirectory;
|
|
44
|
+
culture: string | null;
|
|
45
|
+
entries: {
|
|
46
|
+
shown: ToolbarEntry[];
|
|
47
|
+
more: ToolbarEntry[];
|
|
48
|
+
};
|
|
49
|
+
sourceMode: boolean;
|
|
50
|
+
activeKey: string | null;
|
|
51
|
+
setActiveKey: (key: string) => void;
|
|
52
|
+
registerRef: (key: string) => (el: HTMLButtonElement | null) => void;
|
|
53
|
+
/** The language the entries were worded in (the directory's), used when no host gives an admin language. */
|
|
54
|
+
language?: string;
|
|
55
|
+
}
|
|
56
|
+
/** The toolbar's "Plugin tools" group: one button a shown entry, then More with the rest and every mark. */
|
|
57
|
+
export declare function PluginToolbarGroup({ editor, entries, items, culture, sourceMode, activeKey, setActiveKey, registerRef, language: entriesLanguage }: PluginToolbarGroupProps): import("react").JSX.Element;
|