@fastsprout/reacd-shadcn 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +28 -2
- package/THIRD_PARTY_NOTICES.md +21 -0
- package/dist/accordion/accordion.adapter.d.ts +2 -0
- package/dist/accordion/accordion.adapter.js +10 -0
- package/dist/action-menu/menu-content.d.ts +5 -0
- package/dist/action-menu/menu-content.js +15 -0
- package/dist/action-menu/menu-items.d.ts +5 -0
- package/dist/action-menu/menu-items.js +46 -0
- package/dist/action-menu/menu-surface.d.ts +7 -0
- package/dist/action-menu/menu-surface.js +15 -0
- package/dist/action-menu/use-menu-frame.d.ts +8 -0
- package/dist/action-menu/use-menu-frame.js +24 -0
- package/dist/alert/alert.adapter.d.ts +2 -0
- package/dist/alert/alert.adapter.js +13 -0
- package/dist/app/app.adapter.d.ts +2 -0
- package/dist/app/app.adapter.js +7 -0
- package/dist/auth-form/auth-form.adapter.d.ts +2 -0
- package/dist/auth-form/auth-form.adapter.js +21 -0
- package/dist/avatar/avatar.adapter.d.ts +2 -0
- package/dist/avatar/avatar.adapter.js +8 -0
- package/dist/avatar-group/avatar-group.adapter.d.ts +2 -0
- package/dist/avatar-group/avatar-group.adapter.js +9 -0
- package/dist/avatar-group/overflow.adapter.d.ts +5 -0
- package/dist/avatar-group/overflow.adapter.js +5 -0
- package/dist/badge/badge.adapter.d.ts +2 -0
- package/dist/badge/badge.adapter.js +9 -0
- package/dist/banner/banner.adapter.d.ts +2 -0
- package/dist/banner/banner.adapter.js +12 -0
- package/dist/blog-post/blog-post.adapter.d.ts +3 -0
- package/dist/blog-post/blog-post.adapter.js +5 -0
- package/dist/blog-posts/blog-posts.adapter.d.ts +3 -0
- package/dist/blog-posts/blog-posts.adapter.js +7 -0
- package/dist/breadcrumb/breadcrumb.adapter.d.ts +2 -0
- package/dist/breadcrumb/breadcrumb.adapter.js +13 -0
- package/dist/button/button.adapter.d.ts +2 -0
- package/dist/button/button.adapter.js +8 -0
- package/dist/calendar/calendar-date.d.ts +7 -0
- package/dist/calendar/calendar-date.js +24 -0
- package/dist/calendar/calendar-day-button.d.ts +2 -0
- package/dist/calendar/calendar-day-button.js +9 -0
- package/dist/calendar/calendar-form-bridge.d.ts +6 -0
- package/dist/calendar/calendar-form-bridge.js +11 -0
- package/dist/calendar/calendar-localization.d.ts +15 -0
- package/dist/calendar/calendar-localization.js +28 -0
- package/dist/calendar/calendar.adapter.d.ts +2 -0
- package/dist/calendar/calendar.adapter.js +47 -0
- package/dist/card/card.adapter.d.ts +2 -0
- package/dist/card/card.adapter.js +13 -0
- package/dist/carousel/carousel-panel.d.ts +7 -0
- package/dist/carousel/carousel-panel.js +8 -0
- package/dist/carousel/carousel.adapter.d.ts +2 -0
- package/dist/carousel/carousel.adapter.js +43 -0
- package/dist/carousel/focus-boundary.d.ts +16 -0
- package/dist/carousel/focus-boundary.js +19 -0
- package/dist/changelog-version/changelog-version.adapter.d.ts +3 -0
- package/dist/changelog-version/changelog-version.adapter.js +5 -0
- package/dist/changelog-versions/changelog-versions.adapter.d.ts +3 -0
- package/dist/changelog-versions/changelog-versions.adapter.js +8 -0
- package/dist/chart/cartesian.d.ts +5 -0
- package/dist/chart/cartesian.js +15 -0
- package/dist/chart/chart-graphic.d.ts +2 -0
- package/dist/chart/chart-graphic.js +14 -0
- package/dist/chart/chart-table.d.ts +2 -0
- package/dist/chart/chart-table.js +6 -0
- package/dist/chart/chart.adapter.d.ts +2 -0
- package/dist/chart/chart.adapter.js +17 -0
- package/dist/chart/legend.d.ts +3 -0
- package/dist/chart/legend.js +14 -0
- package/dist/chart/patterns.d.ts +9 -0
- package/dist/chart/patterns.js +8 -0
- package/dist/chat-attachment/chat-attachment.adapter.d.ts +2 -0
- package/dist/chat-attachment/chat-attachment.adapter.js +12 -0
- package/dist/chat-disclosure/chat-disclosure.d.ts +9 -0
- package/dist/chat-disclosure/chat-disclosure.js +10 -0
- package/dist/chat-message/chat-message.adapter.d.ts +2 -0
- package/dist/chat-message/chat-message.adapter.js +12 -0
- package/dist/chat-messages/chat-messages.adapter.d.ts +2 -0
- package/dist/chat-messages/chat-messages.adapter.js +13 -0
- package/dist/chat-messages/use-follow-latest.d.ts +6 -0
- package/dist/chat-messages/use-follow-latest.js +33 -0
- package/dist/chat-palette/chat-palette.adapter.d.ts +2 -0
- package/dist/chat-palette/chat-palette.adapter.js +4 -0
- package/dist/chat-prompt/chat-prompt.adapter.d.ts +2 -0
- package/dist/chat-prompt/chat-prompt.adapter.js +30 -0
- package/dist/chat-prompt/use-prompt-controls.d.ts +22 -0
- package/dist/chat-prompt/use-prompt-controls.js +69 -0
- package/dist/chat-prompt/use-prompt-escape.d.ts +5 -0
- package/dist/chat-prompt/use-prompt-escape.js +39 -0
- package/dist/chat-prompt-submit/chat-prompt-submit.adapter.d.ts +2 -0
- package/dist/chat-prompt-submit/chat-prompt-submit.adapter.js +14 -0
- package/dist/chat-prompt-submit/prompt-action.d.ts +12 -0
- package/dist/chat-prompt-submit/prompt-action.js +45 -0
- package/dist/chat-reasoning/chat-reasoning.adapter.d.ts +2 -0
- package/dist/chat-reasoning/chat-reasoning.adapter.js +15 -0
- package/dist/chat-reasoning/use-reasoning-disclosure.d.ts +10 -0
- package/dist/chat-reasoning/use-reasoning-disclosure.js +23 -0
- package/dist/chat-shimmer/chat-shimmer.adapter.d.ts +2 -0
- package/dist/chat-shimmer/chat-shimmer.adapter.js +5 -0
- package/dist/chat-tool/chat-tool.adapter.d.ts +2 -0
- package/dist/chat-tool/chat-tool.adapter.js +7 -0
- package/dist/checkbox/checkbox.adapter.d.ts +2 -0
- package/dist/checkbox/checkbox.adapter.js +27 -0
- package/dist/checkbox-group/checkbox-group.adapter.d.ts +2 -0
- package/dist/checkbox-group/checkbox-group.adapter.js +18 -0
- package/dist/chip/chip.adapter.d.ts +2 -0
- package/dist/chip/chip.adapter.js +12 -0
- package/dist/code-editor/code-editor.adapter.d.ts +2 -0
- package/dist/code-editor/code-editor.adapter.js +9 -0
- package/dist/collapsible/collapsible.adapter.d.ts +2 -0
- package/dist/collapsible/collapsible.adapter.js +11 -0
- package/dist/color-mode-avatar/color-mode-avatar.adapter.d.ts +2 -0
- package/dist/color-mode-avatar/color-mode-avatar.adapter.js +6 -0
- package/dist/color-mode-button/color-mode-button.adapter.d.ts +2 -0
- package/dist/color-mode-button/color-mode-button.adapter.js +11 -0
- package/dist/color-mode-image/color-mode-image.adapter.d.ts +2 -0
- package/dist/color-mode-image/color-mode-image.adapter.js +6 -0
- package/dist/color-mode-image/mode-image.d.ts +4 -0
- package/dist/color-mode-image/mode-image.js +8 -0
- package/dist/color-mode-select/color-mode-select.adapter.d.ts +2 -0
- package/dist/color-mode-select/color-mode-select.adapter.js +16 -0
- package/dist/color-mode-switch/color-mode-switch.adapter.d.ts +2 -0
- package/dist/color-mode-switch/color-mode-switch.adapter.js +5 -0
- package/dist/color-picker/color-hex.d.ts +11 -0
- package/dist/color-picker/color-hex.js +57 -0
- package/dist/color-picker/color-picker.adapter.d.ts +2 -0
- package/dist/color-picker/color-picker.adapter.js +20 -0
- package/dist/color-picker/use-color-model.d.ts +6 -0
- package/dist/color-picker/use-color-model.js +18 -0
- package/dist/command-palette/command-palette.adapter.d.ts +2 -0
- package/dist/command-palette/command-palette.adapter.js +44 -0
- package/dist/container/container.adapter.d.ts +2 -0
- package/dist/container/container.adapter.js +4 -0
- package/dist/content-navigation/content-navigation.adapter.d.ts +2 -0
- package/dist/content-navigation/content-navigation.adapter.js +10 -0
- package/dist/content-search/content-search.adapter.d.ts +2 -0
- package/dist/content-search/content-search.adapter.js +27 -0
- package/dist/content-search-button/content-search-button.adapter.d.ts +2 -0
- package/dist/content-search-button/content-search-button.adapter.js +6 -0
- package/dist/content-surround/content-surround.adapter.d.ts +2 -0
- package/dist/content-surround/content-surround.adapter.js +14 -0
- package/dist/content-toc/content-toc.adapter.d.ts +2 -0
- package/dist/content-toc/content-toc.adapter.js +10 -0
- package/dist/context-menu/context-menu.adapter.d.ts +2 -0
- package/dist/context-menu/context-menu.adapter.js +13 -0
- package/dist/context-menu/keyboard-trigger.d.ts +2 -0
- package/dist/context-menu/keyboard-trigger.js +13 -0
- package/dist/dashboard-group/dashboard-group.adapter.d.ts +3 -0
- package/dist/dashboard-group/dashboard-group.adapter.js +54 -0
- package/dist/dashboard-navbar/dashboard-navbar.adapter.d.ts +2 -0
- package/dist/dashboard-navbar/dashboard-navbar.adapter.js +12 -0
- package/dist/dashboard-panel/dashboard-panel.adapter.d.ts +2 -0
- package/dist/dashboard-panel/dashboard-panel.adapter.js +18 -0
- package/dist/dashboard-resize-handle/dashboard-resize-handle.adapter.d.ts +2 -0
- package/dist/dashboard-resize-handle/dashboard-resize-handle.adapter.js +46 -0
- package/dist/dashboard-search/dashboard-search.adapter.d.ts +2 -0
- package/dist/dashboard-search/dashboard-search.adapter.js +24 -0
- package/dist/dashboard-search-button/dashboard-search-button.adapter.d.ts +2 -0
- package/dist/dashboard-search-button/dashboard-search-button.adapter.js +6 -0
- package/dist/dashboard-sidebar/dashboard-sidebar.adapter.d.ts +2 -0
- package/dist/dashboard-sidebar/dashboard-sidebar.adapter.js +19 -0
- package/dist/dashboard-sidebar-collapse/dashboard-sidebar-collapse.adapter.d.ts +2 -0
- package/dist/dashboard-sidebar-collapse/dashboard-sidebar-collapse.adapter.js +22 -0
- package/dist/dashboard-sidebar-toggle/dashboard-sidebar-toggle.adapter.d.ts +2 -0
- package/dist/dashboard-sidebar-toggle/dashboard-sidebar-toggle.adapter.js +22 -0
- package/dist/dashboard-toolbar/dashboard-toolbar.adapter.d.ts +2 -0
- package/dist/dashboard-toolbar/dashboard-toolbar.adapter.js +4 -0
- package/dist/data-table/data-table.adapter.d.ts +2 -0
- package/dist/data-table/data-table.adapter.js +28 -0
- package/dist/data-table/filters.adapter.d.ts +8 -0
- package/dist/data-table/filters.adapter.js +40 -0
- package/dist/data-table/pagination.adapter.d.ts +2 -0
- package/dist/data-table/pagination.adapter.js +21 -0
- package/dist/divider/divider.adapter.d.ts +1 -0
- package/dist/divider/divider.adapter.js +5 -0
- package/dist/drawer/drawer.adapter.d.ts +2 -0
- package/dist/drawer/drawer.adapter.js +14 -0
- package/dist/dropdown-menu/dropdown-menu.adapter.d.ts +2 -0
- package/dist/dropdown-menu/dropdown-menu.adapter.js +14 -0
- package/dist/editor/drag-session.d.ts +7 -0
- package/dist/editor/drag-session.js +41 -0
- package/dist/editor/editor.adapter.d.ts +2 -0
- package/dist/editor/editor.adapter.js +21 -0
- package/dist/editor/publish-edit.d.ts +3 -0
- package/dist/editor/publish-edit.js +12 -0
- package/dist/editor/use-editor-port.d.ts +5 -0
- package/dist/editor/use-editor-port.js +40 -0
- package/dist/editor/use-editor-session.d.ts +14 -0
- package/dist/editor/use-editor-session.js +198 -0
- package/dist/editor-conversion/attribute.d.ts +3 -0
- package/dist/editor-conversion/attribute.js +3 -0
- package/dist/editor-conversion/budget.d.ts +2 -0
- package/dist/editor-conversion/budget.js +61 -0
- package/dist/editor-conversion/from-sdk-block.d.ts +5 -0
- package/dist/editor-conversion/from-sdk-block.js +73 -0
- package/dist/editor-conversion/from-sdk-inline.d.ts +3 -0
- package/dist/editor-conversion/from-sdk-inline.js +57 -0
- package/dist/editor-conversion/from-sdk.d.ts +4 -0
- package/dist/editor-conversion/from-sdk.js +35 -0
- package/dist/editor-conversion/id-allocator.d.ts +2 -0
- package/dist/editor-conversion/id-allocator.js +29 -0
- package/dist/editor-conversion/projection-weight.d.ts +8 -0
- package/dist/editor-conversion/projection-weight.js +124 -0
- package/dist/editor-conversion/text-chunks.d.ts +6 -0
- package/dist/editor-conversion/text-chunks.js +18 -0
- package/dist/editor-conversion/to-sdk.d.ts +3 -0
- package/dist/editor-conversion/to-sdk.js +58 -0
- package/dist/editor-drag-handle/editor-drag-handle.adapter.d.ts +2 -0
- package/dist/editor-drag-handle/editor-drag-handle.adapter.js +54 -0
- package/dist/editor-drag-handle/use-drag-session.d.ts +9 -0
- package/dist/editor-drag-handle/use-drag-session.js +22 -0
- package/dist/editor-emoji-menu/editor-emoji-menu.adapter.d.ts +2 -0
- package/dist/editor-emoji-menu/editor-emoji-menu.adapter.js +9 -0
- package/dist/editor-mention-menu/editor-mention-menu.adapter.d.ts +2 -0
- package/dist/editor-mention-menu/editor-mention-menu.adapter.js +17 -0
- package/dist/editor-menu/lookup-controller.d.ts +24 -0
- package/dist/editor-menu/lookup-controller.js +83 -0
- package/dist/editor-menu/menu-panel.d.ts +10 -0
- package/dist/editor-menu/menu-panel.js +17 -0
- package/dist/editor-menu/menu-plugin.d.ts +3 -0
- package/dist/editor-menu/menu-plugin.js +190 -0
- package/dist/editor-menu/menu-port.d.ts +3 -0
- package/dist/editor-menu/menu-port.js +27 -0
- package/dist/editor-menu/menu-store.d.ts +20 -0
- package/dist/editor-menu/menu-store.js +92 -0
- package/dist/editor-menu/use-editor-menu.d.ts +9 -0
- package/dist/editor-menu/use-editor-menu.js +21 -0
- package/dist/editor-sdk/apply-paste.d.ts +3 -0
- package/dist/editor-sdk/apply-paste.js +12 -0
- package/dist/editor-sdk/atom-data.d.ts +7 -0
- package/dist/editor-sdk/atom-data.js +41 -0
- package/dist/editor-sdk/atoms.d.ts +3 -0
- package/dist/editor-sdk/atoms.js +25 -0
- package/dist/editor-sdk/block-types.d.ts +1 -0
- package/dist/editor-sdk/block-types.js +10 -0
- package/dist/editor-sdk/command-chain.d.ts +3 -0
- package/dist/editor-sdk/command-chain.js +25 -0
- package/dist/editor-sdk/commands.d.ts +5 -0
- package/dist/editor-sdk/commands.js +38 -0
- package/dist/editor-sdk/controlled-selection.d.ts +2 -0
- package/dist/editor-sdk/controlled-selection.js +8 -0
- package/dist/editor-sdk/extensions.d.ts +2 -0
- package/dist/editor-sdk/extensions.js +21 -0
- package/dist/editor-sdk/identity-plugin.d.ts +18 -0
- package/dist/editor-sdk/identity-plugin.js +107 -0
- package/dist/editor-sdk/identity.d.ts +3 -0
- package/dist/editor-sdk/identity.js +28 -0
- package/dist/editor-sdk/plain-paste.d.ts +3 -0
- package/dist/editor-sdk/plain-paste.js +66 -0
- package/dist/editor-sdk/resources.d.ts +5 -0
- package/dist/editor-sdk/resources.js +14 -0
- package/dist/editor-sdk/select-block.d.ts +2 -0
- package/dist/editor-sdk/select-block.js +31 -0
- package/dist/editor-sdk/selection-mapping.d.ts +9 -0
- package/dist/editor-sdk/selection-mapping.js +92 -0
- package/dist/editor-sdk/structural-selection.d.ts +4 -0
- package/dist/editor-sdk/structural-selection.js +21 -0
- package/dist/editor-suggestion-menu/editor-suggestion-menu.adapter.d.ts +2 -0
- package/dist/editor-suggestion-menu/editor-suggestion-menu.adapter.js +13 -0
- package/dist/editor-toolbar/editor-toolbar.adapter.d.ts +2 -0
- package/dist/editor-toolbar/editor-toolbar.adapter.js +38 -0
- package/dist/element/variants.d.ts +5 -0
- package/dist/element/variants.js +5 -0
- package/dist/empty/empty.adapter.d.ts +2 -0
- package/dist/empty/empty.adapter.js +10 -0
- package/dist/error/error.adapter.d.ts +2 -0
- package/dist/error/error.adapter.js +9 -0
- package/dist/field-group/field-group.adapter.d.ts +2 -0
- package/dist/field-group/field-group.adapter.js +5 -0
- package/dist/file-upload/file-upload.adapter.d.ts +2 -0
- package/dist/file-upload/file-upload.adapter.js +60 -0
- package/dist/file-upload/intake-validation.d.ts +8 -0
- package/dist/file-upload/intake-validation.js +48 -0
- package/dist/file-upload/intake.d.ts +36 -0
- package/dist/file-upload/intake.js +112 -0
- package/dist/file-upload/read-file.d.ts +5 -0
- package/dist/file-upload/read-file.js +32 -0
- package/dist/footer/footer.adapter.d.ts +2 -0
- package/dist/footer/footer.adapter.js +4 -0
- package/dist/footer-columns/footer-columns.adapter.d.ts +2 -0
- package/dist/footer-columns/footer-columns.adapter.js +8 -0
- package/dist/form-field/focus-control.d.ts +1 -0
- package/dist/form-field/focus-control.js +21 -0
- package/dist/form-field/form-field.adapter.d.ts +2 -0
- package/dist/form-field/form-field.adapter.js +22 -0
- package/dist/form-menu-shared/request.d.ts +4 -0
- package/dist/form-menu-shared/request.js +14 -0
- package/dist/grid/grid.adapter.d.ts +2 -0
- package/dist/grid/grid.adapter.js +5 -0
- package/dist/h-stack/h-stack.adapter.d.ts +2 -0
- package/dist/h-stack/h-stack.adapter.js +5 -0
- package/dist/header/header-menu.d.ts +7 -0
- package/dist/header/header-menu.js +25 -0
- package/dist/header/header.adapter.d.ts +2 -0
- package/dist/header/header.adapter.js +5 -0
- package/dist/icon/icon-map.d.ts +16 -0
- package/dist/icon/icon-map.js +17 -0
- package/dist/icon/icon.adapter.d.ts +2 -0
- package/dist/icon/icon.adapter.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/input/input.adapter.d.ts +2 -0
- package/dist/input/input.adapter.js +34 -0
- package/dist/input/validation-message.d.ts +1 -0
- package/dist/input/validation-message.js +13 -0
- package/dist/input-date/date-control.d.ts +16 -0
- package/dist/input-date/date-control.js +35 -0
- package/dist/input-date/input-date.adapter.d.ts +2 -0
- package/dist/input-date/input-date.adapter.js +36 -0
- package/dist/input-menu/input-menu-form.d.ts +7 -0
- package/dist/input-menu/input-menu-form.js +8 -0
- package/dist/input-menu/input-menu-popup.d.ts +8 -0
- package/dist/input-menu/input-menu-popup.js +13 -0
- package/dist/input-menu/input-menu.adapter.d.ts +2 -0
- package/dist/input-menu/input-menu.adapter.js +74 -0
- package/dist/input-menu/use-input-menu.d.ts +26 -0
- package/dist/input-menu/use-input-menu.js +92 -0
- package/dist/input-number/input-number.adapter.d.ts +2 -0
- package/dist/input-number/input-number.adapter.js +13 -0
- package/dist/input-rating/input-rating.adapter.d.ts +2 -0
- package/dist/input-rating/input-rating.adapter.js +33 -0
- package/dist/input-rating/rating-stars.d.ts +4 -0
- package/dist/input-rating/rating-stars.js +9 -0
- package/dist/input-tags/input-tags.adapter.d.ts +2 -0
- package/dist/input-tags/input-tags.adapter.js +47 -0
- package/dist/input-tags/use-tag-draft.d.ts +9 -0
- package/dist/input-tags/use-tag-draft.js +43 -0
- package/dist/input-time/anchored-time.d.ts +1 -0
- package/dist/input-time/anchored-time.js +5 -0
- package/dist/input-time/draft-validation.d.ts +1 -0
- package/dist/input-time/draft-validation.js +1 -0
- package/dist/input-time/focus-draft.d.ts +1 -0
- package/dist/input-time/focus-draft.js +1 -0
- package/dist/input-time/input-time.adapter.d.ts +2 -0
- package/dist/input-time/input-time.adapter.js +32 -0
- package/dist/input-time/time-control.d.ts +15 -0
- package/dist/input-time/time-control.js +37 -0
- package/dist/input-time/use-time-change.d.ts +10 -0
- package/dist/input-time/use-time-change.js +4 -0
- package/dist/kbd/kbd-key.adapter.d.ts +5 -0
- package/dist/kbd/kbd-key.adapter.js +5 -0
- package/dist/kbd/kbd.adapter.d.ts +2 -0
- package/dist/kbd/kbd.adapter.js +8 -0
- package/dist/listbox/clear-focus.d.ts +1 -0
- package/dist/listbox/clear-focus.js +8 -0
- package/dist/listbox/form-bridge.d.ts +14 -0
- package/dist/listbox/form-bridge.js +34 -0
- package/dist/listbox/listbox.adapter.d.ts +2 -0
- package/dist/listbox/listbox.adapter.js +79 -0
- package/dist/listbox/native-semantics.d.ts +9 -0
- package/dist/listbox/native-semantics.js +33 -0
- package/dist/listbox/selection.d.ts +4 -0
- package/dist/listbox/selection.js +31 -0
- package/dist/listbox/use-listbox-request.d.ts +10 -0
- package/dist/listbox/use-listbox-request.js +73 -0
- package/dist/locale-select/locale-select.adapter.d.ts +2 -0
- package/dist/locale-select/locale-select.adapter.js +15 -0
- package/dist/main/main.adapter.d.ts +2 -0
- package/dist/main/main.adapter.js +7 -0
- package/dist/marquee/marquee.adapter.d.ts +2 -0
- package/dist/marquee/marquee.adapter.js +23 -0
- package/dist/modal/modal.adapter.d.ts +2 -0
- package/dist/modal/modal.adapter.js +30 -0
- package/dist/navigation/navigation.adapter.d.ts +2 -0
- package/dist/navigation/navigation.adapter.js +5 -0
- package/dist/navigation-menu/menu-target.d.ts +4 -0
- package/dist/navigation-menu/menu-target.js +13 -0
- package/dist/navigation-menu/navigation-menu.adapter.d.ts +2 -0
- package/dist/navigation-menu/navigation-menu.adapter.js +16 -0
- package/dist/page-anchors/page-anchors.adapter.d.ts +3 -0
- package/dist/page-anchors/page-anchors.adapter.js +5 -0
- package/dist/page-aside/page-aside.adapter.d.ts +2 -0
- package/dist/page-aside/page-aside.adapter.js +6 -0
- package/dist/page-body/page-body.adapter.d.ts +2 -0
- package/dist/page-body/page-body.adapter.js +4 -0
- package/dist/page-card/page-card.adapter.d.ts +3 -0
- package/dist/page-card/page-card.adapter.js +5 -0
- package/dist/page-columns/page-columns.adapter.d.ts +2 -0
- package/dist/page-columns/page-columns.adapter.js +5 -0
- package/dist/page-cta/page-cta.adapter.d.ts +3 -0
- package/dist/page-cta/page-cta.adapter.js +5 -0
- package/dist/page-feature/page-feature.adapter.d.ts +3 -0
- package/dist/page-feature/page-feature.adapter.js +6 -0
- package/dist/page-grid/page-grid.adapter.d.ts +2 -0
- package/dist/page-grid/page-grid.adapter.js +4 -0
- package/dist/page-header/page-header.adapter.d.ts +3 -0
- package/dist/page-header/page-header.adapter.js +5 -0
- package/dist/page-hero/page-hero.adapter.d.ts +3 -0
- package/dist/page-hero/page-hero.adapter.js +5 -0
- package/dist/page-links/page-links.adapter.d.ts +3 -0
- package/dist/page-links/page-links.adapter.js +5 -0
- package/dist/page-list/page-list.adapter.d.ts +2 -0
- package/dist/page-list/page-list.adapter.js +6 -0
- package/dist/page-logos/page-logos.adapter.d.ts +2 -0
- package/dist/page-logos/page-logos.adapter.js +11 -0
- package/dist/page-section/page-section.adapter.d.ts +3 -0
- package/dist/page-section/page-section.adapter.js +5 -0
- package/dist/pagination/pagination-control.d.ts +13 -0
- package/dist/pagination/pagination-control.js +31 -0
- package/dist/pagination/pagination.adapter.d.ts +2 -0
- package/dist/pagination/pagination.adapter.js +23 -0
- package/dist/panel/use-panel-frame.d.ts +15 -0
- package/dist/panel/use-panel-frame.js +36 -0
- package/dist/pin-input/pin-input.adapter.d.ts +2 -0
- package/dist/pin-input/pin-input.adapter.js +18 -0
- package/dist/pin-input/pin-slots.d.ts +6 -0
- package/dist/pin-input/pin-slots.js +9 -0
- package/dist/popover/popover.adapter.d.ts +2 -0
- package/dist/popover/popover.adapter.js +55 -0
- package/dist/pricing-plan/pricing-plan.adapter.d.ts +3 -0
- package/dist/pricing-plan/pricing-plan.adapter.js +15 -0
- package/dist/pricing-plans/pricing-plans.adapter.d.ts +3 -0
- package/dist/pricing-plans/pricing-plans.adapter.js +8 -0
- package/dist/pricing-table/pricing-table.adapter.d.ts +3 -0
- package/dist/pricing-table/pricing-table.adapter.js +9 -0
- package/dist/progress/progress.adapter.d.ts +2 -0
- package/dist/progress/progress.adapter.js +10 -0
- package/dist/progress-group/progress-group.adapter.d.ts +2 -0
- package/dist/progress-group/progress-group.adapter.js +9 -0
- package/dist/radio-group/radio-group.adapter.d.ts +2 -0
- package/dist/radio-group/radio-group.adapter.js +14 -0
- package/dist/registry/action-menus.d.ts +4 -0
- package/dist/registry/action-menus.js +9 -0
- package/dist/registry/auth-form.d.ts +3 -0
- package/dist/registry/auth-form.js +6 -0
- package/dist/registry/calendar.d.ts +3 -0
- package/dist/registry/calendar.js +6 -0
- package/dist/registry/carousel.d.ts +3 -0
- package/dist/registry/carousel.js +6 -0
- package/dist/registry/chart.d.ts +3 -0
- package/dist/registry/chart.js +4 -0
- package/dist/registry/chat-composer.d.ts +5 -0
- package/dist/registry/chat-composer.js +12 -0
- package/dist/registry/chat-feedback.d.ts +5 -0
- package/dist/registry/chat-feedback.js +12 -0
- package/dist/registry/chat.d.ts +5 -0
- package/dist/registry/chat.js +12 -0
- package/dist/registry/color-mode.d.ts +7 -0
- package/dist/registry/color-mode.js +18 -0
- package/dist/registry/color-picker.d.ts +3 -0
- package/dist/registry/color-picker.js +6 -0
- package/dist/registry/command-palette.d.ts +3 -0
- package/dist/registry/command-palette.js +6 -0
- package/dist/registry/content-outline.d.ts +4 -0
- package/dist/registry/content-outline.js +9 -0
- package/dist/registry/content-search.d.ts +4 -0
- package/dist/registry/content-search.js +9 -0
- package/dist/registry/content.d.ts +26 -0
- package/dist/registry/content.js +75 -0
- package/dist/registry/dashboard.d.ts +12 -0
- package/dist/registry/dashboard.js +33 -0
- package/dist/registry/edge-panels.d.ts +4 -0
- package/dist/registry/edge-panels.js +9 -0
- package/dist/registry/editor-drag-handle.d.ts +3 -0
- package/dist/registry/editor-drag-handle.js +6 -0
- package/dist/registry/editor-menus.d.ts +5 -0
- package/dist/registry/editor-menus.js +12 -0
- package/dist/registry/editor.d.ts +4 -0
- package/dist/registry/editor.js +9 -0
- package/dist/registry/editorial.d.ts +6 -0
- package/dist/registry/editorial.js +15 -0
- package/dist/registry/element.d.ts +3 -0
- package/dist/registry/element.js +4 -0
- package/dist/registry/feedback.d.ts +8 -0
- package/dist/registry/feedback.js +21 -0
- package/dist/registry/fields.d.ts +24 -0
- package/dist/registry/fields.js +69 -0
- package/dist/registry/file-upload.d.ts +3 -0
- package/dist/registry/file-upload.js +6 -0
- package/dist/registry/listbox.d.ts +3 -0
- package/dist/registry/listbox.js +6 -0
- package/dist/registry/marquee.d.ts +3 -0
- package/dist/registry/marquee.js +6 -0
- package/dist/registry/navigation-composition.d.ts +5 -0
- package/dist/registry/navigation-composition.js +12 -0
- package/dist/registry/page-composition.d.ts +7 -0
- package/dist/registry/page-composition.js +18 -0
- package/dist/registry/page-logos.d.ts +3 -0
- package/dist/registry/page-logos.js +6 -0
- package/dist/registry/page-navigation.d.ts +5 -0
- package/dist/registry/page-navigation.js +12 -0
- package/dist/registry/page-presentation.d.ts +7 -0
- package/dist/registry/page-presentation.js +18 -0
- package/dist/registry/pricing.d.ts +5 -0
- package/dist/registry/pricing.js +12 -0
- package/dist/registry/shells.d.ts +10 -0
- package/dist/registry/shells.js +27 -0
- package/dist/registry/sidebar-splitter.d.ts +4 -0
- package/dist/registry/sidebar-splitter.js +9 -0
- package/dist/registry/structure.d.ts +10 -0
- package/dist/registry/structure.js +27 -0
- package/dist/registry/toast.d.ts +3 -0
- package/dist/registry/toast.js +4 -0
- package/dist/scroll-area/scroll-area.adapter.d.ts +2 -0
- package/dist/scroll-area/scroll-area.adapter.js +6 -0
- package/dist/select/display-text.d.ts +2 -0
- package/dist/select/display-text.js +18 -0
- package/dist/select/select-base-content.adapter.d.ts +6 -0
- package/dist/select/select-base-content.adapter.js +16 -0
- package/dist/select/select-content.adapter.d.ts +4 -0
- package/dist/select/select-content.adapter.js +11 -0
- package/dist/select/select-option.d.ts +5 -0
- package/dist/select/select-option.js +6 -0
- package/dist/select/select.adapter.d.ts +2 -0
- package/dist/select/select.adapter.js +47 -0
- package/dist/select/use-select-change.d.ts +2 -0
- package/dist/select/use-select-change.js +29 -0
- package/dist/select-menu/select-menu-form.d.ts +7 -0
- package/dist/select-menu/select-menu-form.js +14 -0
- package/dist/select-menu/select-menu-popup.d.ts +8 -0
- package/dist/select-menu/select-menu-popup.js +39 -0
- package/dist/select-menu/select-menu-root.d.ts +8 -0
- package/dist/select-menu/select-menu-root.js +34 -0
- package/dist/select-menu/select-menu.adapter.d.ts +2 -0
- package/dist/select-menu/select-menu.adapter.js +63 -0
- package/dist/select-menu/use-select-menu.d.ts +22 -0
- package/dist/select-menu/use-select-menu.js +111 -0
- package/dist/separator/separator.adapter.d.ts +2 -0
- package/dist/separator/separator.adapter.js +6 -0
- package/dist/shadcn.adapter.d.ts +2 -0
- package/dist/shadcn.adapter.js +102 -0
- package/dist/sidebar/sidebar.adapter.d.ts +2 -0
- package/dist/sidebar/sidebar.adapter.js +63 -0
- package/dist/skeleton/skeleton.adapter.d.ts +2 -0
- package/dist/skeleton/skeleton.adapter.js +8 -0
- package/dist/slideover/slideover.adapter.d.ts +2 -0
- package/dist/slideover/slideover.adapter.js +14 -0
- package/dist/slider/request-change.d.ts +2 -0
- package/dist/slider/request-change.js +34 -0
- package/dist/slider/slider-thumb.d.ts +7 -0
- package/dist/slider/slider-thumb.js +18 -0
- package/dist/slider/slider.adapter.d.ts +2 -0
- package/dist/slider/slider.adapter.js +36 -0
- package/dist/splitter/splitter.adapter.d.ts +3 -0
- package/dist/splitter/splitter.adapter.js +50 -0
- package/dist/stepper/stepper.adapter.d.ts +2 -0
- package/dist/stepper/stepper.adapter.js +30 -0
- package/dist/styles-contract.d.ts +1 -0
- package/dist/styles-contract.js +1 -0
- package/dist/styles.css +2 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.js +1 -0
- package/dist/submit-button/submit-button.adapter.d.ts +2 -0
- package/dist/submit-button/submit-button.adapter.js +11 -0
- package/dist/surface/surface.adapter.d.ts +2 -0
- package/dist/surface/surface.adapter.js +8 -0
- package/dist/switch/switch.adapter.d.ts +2 -0
- package/dist/switch/switch.adapter.js +26 -0
- package/dist/table/interactive-table.d.ts +2 -0
- package/dist/table/interactive-table.js +24 -0
- package/dist/table/table.adapter.d.ts +2 -0
- package/dist/table/table.adapter.js +14 -0
- package/dist/tabs/tabs.adapter.d.ts +2 -0
- package/dist/tabs/tabs.adapter.js +17 -0
- package/dist/temporal/draft-validity.d.ts +13 -0
- package/dist/temporal/draft-validity.js +18 -0
- package/dist/temporal/focus-incomplete-segment.d.ts +1 -0
- package/dist/temporal/focus-incomplete-segment.js +7 -0
- package/dist/temporal/range-reset-focus.d.ts +1 -0
- package/dist/temporal/range-reset-focus.js +16 -0
- package/dist/temporal/temporal-recovery.d.ts +6 -0
- package/dist/temporal/temporal-recovery.js +4 -0
- package/dist/temporal/use-range-reset.d.ts +6 -0
- package/dist/temporal/use-range-reset.js +55 -0
- package/dist/temporal/use-temporal-change.d.ts +10 -0
- package/dist/temporal/use-temporal-change.js +21 -0
- package/dist/text/text.adapter.d.ts +1 -0
- package/dist/text/text.adapter.js +1 -0
- package/dist/text-area/text-area.adapter.d.ts +2 -0
- package/dist/text-area/text-area.adapter.js +9 -0
- package/dist/textarea/textarea.adapter.d.ts +2 -0
- package/dist/textarea/textarea.adapter.js +40 -0
- package/dist/textarea/use-auto-rows.d.ts +2 -0
- package/dist/textarea/use-auto-rows.js +33 -0
- package/dist/theme/theme.adapter.d.ts +2 -0
- package/dist/theme/theme.adapter.js +23 -0
- package/dist/timeline/timeline.adapter.d.ts +2 -0
- package/dist/timeline/timeline.adapter.js +13 -0
- package/dist/toast/toast-data.d.ts +17 -0
- package/dist/toast/toast-data.js +1 -0
- package/dist/toast/toast-focus.d.ts +12 -0
- package/dist/toast/toast-focus.js +38 -0
- package/dist/toast/toast-provider.d.ts +4 -0
- package/dist/toast/toast-provider.js +11 -0
- package/dist/toast/toast-queue-context.d.ts +24 -0
- package/dist/toast/toast-queue-context.js +8 -0
- package/dist/toast/toast-queue.d.ts +12 -0
- package/dist/toast/toast-queue.js +29 -0
- package/dist/toast/toast-registration.d.ts +9 -0
- package/dist/toast/toast-registration.js +149 -0
- package/dist/toast/toast-viewport.d.ts +1 -0
- package/dist/toast/toast-viewport.js +36 -0
- package/dist/toast/toast.adapter.d.ts +2 -0
- package/dist/toast/toast.adapter.js +14 -0
- package/dist/toggle/toggle.adapter.d.ts +2 -0
- package/dist/toggle/toggle.adapter.js +8 -0
- package/dist/tooltip/tooltip.adapter.d.ts +2 -0
- package/dist/tooltip/tooltip.adapter.js +29 -0
- package/dist/tooltip/use-tooltip-anchor.d.ts +5 -0
- package/dist/tooltip/use-tooltip-anchor.js +36 -0
- package/dist/tree/focus-element.d.ts +1 -0
- package/dist/tree/focus-element.js +4 -0
- package/dist/tree/tree.adapter.d.ts +2 -0
- package/dist/tree/tree.adapter.js +27 -0
- package/dist/tree/use-tree.d.ts +13 -0
- package/dist/tree/use-tree.js +73 -0
- package/dist/user/user.adapter.d.ts +2 -0
- package/dist/user/user.adapter.js +24 -0
- package/dist/v-stack/v-stack.adapter.d.ts +2 -0
- package/dist/v-stack/v-stack.adapter.js +5 -0
- package/dist/vendor/lib/utils.d.ts +2 -0
- package/dist/vendor/lib/utils.js +5 -0
- package/dist/vendor/ui/accordion.d.ts +7 -0
- package/dist/vendor/ui/accordion.js +14 -0
- package/dist/vendor/ui/alert.d.ts +8 -0
- package/dist/vendor/ui/alert.js +22 -0
- package/dist/vendor/ui/badge.d.ts +9 -0
- package/dist/vendor/ui/badge.js +21 -0
- package/dist/vendor/ui/button.d.ts +11 -0
- package/dist/vendor/ui/button.js +33 -0
- package/dist/vendor/ui/card.d.ts +8 -0
- package/dist/vendor/ui/card.js +16 -0
- package/dist/vendor/ui/checkbox.d.ts +4 -0
- package/dist/vendor/ui/checkbox.js +9 -0
- package/dist/vendor/ui/input.d.ts +3 -0
- package/dist/vendor/ui/input.js +8 -0
- package/dist/vendor/ui/label.d.ts +5 -0
- package/dist/vendor/ui/label.js +10 -0
- package/dist/vendor/ui/progress.d.ts +4 -0
- package/dist/vendor/ui/progress.js +8 -0
- package/dist/vendor/ui/select.d.ts +13 -0
- package/dist/vendor/ui/select.js +27 -0
- package/dist/vendor/ui/separator.d.ts +4 -0
- package/dist/vendor/ui/separator.js +8 -0
- package/dist/vendor/ui/slider.d.ts +4 -0
- package/dist/vendor/ui/slider.js +8 -0
- package/dist/vendor/ui/switch.d.ts +4 -0
- package/dist/vendor/ui/switch.js +8 -0
- package/dist/vendor/ui/tabs.d.ts +7 -0
- package/dist/vendor/ui/tabs.js +13 -0
- package/dist/vendor/ui/textarea.d.ts +3 -0
- package/dist/vendor/ui/textarea.js +8 -0
- package/package.json +71 -3
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { EDITOR_LOOKUP_POLICY } from '@fastsprout/reacd/adapter-runtime/core/editor-lookup-policy.js';
|
|
2
|
+
import { editorMentionLookupScopeSchema, editorMentionLookupQuerySchema, editorMentionLookupRequestSchema, } from '@fastsprout/reacd/adapter-runtime/schema/editor-mention-menu/lookup.schema.js';
|
|
3
|
+
const EMPTY_ITEMS = Object.freeze([]);
|
|
4
|
+
function closeState(state, ordinal) {
|
|
5
|
+
return Object.freeze({
|
|
6
|
+
scope: state.scope,
|
|
7
|
+
ordinal,
|
|
8
|
+
current: undefined,
|
|
9
|
+
accepted: undefined,
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
function errorTransition(state, ordinal, error) {
|
|
13
|
+
return Object.freeze({
|
|
14
|
+
state: closeState(state, ordinal),
|
|
15
|
+
view: Object.freeze({
|
|
16
|
+
request: undefined,
|
|
17
|
+
status: 'error',
|
|
18
|
+
items: EMPTY_ITEMS,
|
|
19
|
+
error,
|
|
20
|
+
}),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function resultView(request, result) {
|
|
24
|
+
return Object.freeze({
|
|
25
|
+
request,
|
|
26
|
+
status: result?.status ?? 'loading',
|
|
27
|
+
items: result?.status === 'ready' ? result.items : EMPTY_ITEMS,
|
|
28
|
+
error: result?.status === 'error' ? result.error : undefined,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export function advanceMentionLookup(state, query, result) {
|
|
32
|
+
const parsedScope = editorMentionLookupScopeSchema.safeParse(state.scope);
|
|
33
|
+
if (!parsedScope.success)
|
|
34
|
+
return errorTransition(state, state.ordinal, EDITOR_LOOKUP_POLICY.invalidScopeMessage);
|
|
35
|
+
const parsedQuery = editorMentionLookupQuerySchema.safeParse(query);
|
|
36
|
+
if (!parsedQuery.success)
|
|
37
|
+
return errorTransition(state, state.ordinal, EDITOR_LOOKUP_POLICY.invalidQueryMessage);
|
|
38
|
+
let ordinal = state.ordinal;
|
|
39
|
+
let current = state.current;
|
|
40
|
+
let accepted = state.accepted;
|
|
41
|
+
let request;
|
|
42
|
+
if (current === undefined || current.query !== parsedQuery.data) {
|
|
43
|
+
ordinal += 1n;
|
|
44
|
+
const generated = editorMentionLookupRequestSchema.safeParse({
|
|
45
|
+
key: `${parsedScope.data}${EDITOR_LOOKUP_POLICY.keySeparator}${ordinal}`,
|
|
46
|
+
query: parsedQuery.data,
|
|
47
|
+
});
|
|
48
|
+
if (!generated.success)
|
|
49
|
+
return errorTransition(state, ordinal, EDITOR_LOOKUP_POLICY.invalidRequestMessage);
|
|
50
|
+
current = generated.data;
|
|
51
|
+
accepted = undefined;
|
|
52
|
+
request = current;
|
|
53
|
+
}
|
|
54
|
+
if (result !== null &&
|
|
55
|
+
result.key === current.key &&
|
|
56
|
+
result.query === current.query &&
|
|
57
|
+
(result.status !== 'loading' ||
|
|
58
|
+
accepted === undefined ||
|
|
59
|
+
accepted.status === 'loading'))
|
|
60
|
+
accepted = result;
|
|
61
|
+
return Object.freeze({
|
|
62
|
+
state: Object.freeze({ scope: state.scope, ordinal, current, accepted }),
|
|
63
|
+
view: resultView(request, accepted),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export function createMentionLookupController(scope) {
|
|
67
|
+
let state = Object.freeze({
|
|
68
|
+
scope,
|
|
69
|
+
ordinal: BigInt(EDITOR_LOOKUP_POLICY.initialOrdinal),
|
|
70
|
+
current: undefined,
|
|
71
|
+
accepted: undefined,
|
|
72
|
+
});
|
|
73
|
+
return {
|
|
74
|
+
close() {
|
|
75
|
+
state = closeState(state, state.ordinal);
|
|
76
|
+
},
|
|
77
|
+
update(query, result) {
|
|
78
|
+
const next = advanceMentionLookup(state, query, result);
|
|
79
|
+
state = next.state;
|
|
80
|
+
return next.view;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorMenuSnapshot } from './menu-store.js';
|
|
2
|
+
interface MenuPanelProps {
|
|
3
|
+
readonly label: string;
|
|
4
|
+
readonly listId: string;
|
|
5
|
+
readonly orphan: boolean;
|
|
6
|
+
readonly snapshot: EditorMenuSnapshot;
|
|
7
|
+
readonly choose: (index: number) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function EditorMenuPanel({ label, listId, orphan, snapshot, choose, }: MenuPanelProps): import("react").JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { EDITOR_MENU_POLICY } from '@fastsprout/reacd/adapter-runtime/core/editor-menu-policy.js';
|
|
3
|
+
import { Issues } from '@fastsprout/reacd/adapter-runtime/renderer/issues/issues.renderer.js';
|
|
4
|
+
export function EditorMenuPanel({ label, listId, orphan, snapshot, choose, }) {
|
|
5
|
+
if (orphan)
|
|
6
|
+
return (_jsx(Issues, { issues: [{ path: 'EditorMenu', message: EDITOR_MENU_POLICY.scopeError }] }));
|
|
7
|
+
if (snapshot === undefined)
|
|
8
|
+
return null;
|
|
9
|
+
if ('issues' in snapshot)
|
|
10
|
+
return _jsx(Issues, { issues: snapshot.issues });
|
|
11
|
+
const { items, selected, status, error } = snapshot.view;
|
|
12
|
+
return (_jsxs("div", { className: "reacd-node reacd-editor-menu", children: [_jsx("p", { id: `${listId}-label`, children: label }), _jsx("div", { role: "listbox", id: listId, "aria-labelledby": `${listId}-label`, "aria-busy": status === 'loading', children: items.map((item, index) => (_jsx("button", { type: "button", role: "option", id: `${listId}-${index}`, tabIndex: -1, "aria-selected": index === selected, disabled: item.disabled === true, onMouseDown: (event) => event.preventDefault(), onClick: () => choose(index), children: item.label }, item.kind === 'suggestion'
|
|
13
|
+
? item.value.command
|
|
14
|
+
: item.kind === 'mention'
|
|
15
|
+
? item.id
|
|
16
|
+
: item.name))) }), status === 'loading' && _jsx("p", { role: "status", children: EDITOR_MENU_POLICY.loading }), status === 'error' && _jsx("p", { role: "alert", children: error }), status === 'ready' && items.length === 0 && (_jsx("p", { role: "status", children: EDITOR_MENU_POLICY.empty }))] }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { EditorMenuLease, EditorMenuRequest } from '@fastsprout/reacd/adapter-runtime/renderer/editor/menu-context.js';
|
|
3
|
+
export declare function mountEditorMenu(editor: Editor, request: EditorMenuRequest, released: () => void): EditorMenuLease;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { Suggestion, exitSuggestion } from '@tiptap/suggestion';
|
|
4
|
+
import { EDITOR_MENU_POLICY as P } from '@fastsprout/reacd/adapter-runtime/core/editor-menu-policy.js';
|
|
5
|
+
import { editorCommandChain } from '../editor-sdk/command-chain.js';
|
|
6
|
+
import { canRunSdkCommand } from '../editor-sdk/commands.js';
|
|
7
|
+
const activeSuggestionSchema = z.object({ active: z.literal(true) });
|
|
8
|
+
function insert(editor, range, item) {
|
|
9
|
+
const chain = editor.chain().focus().deleteRange(range);
|
|
10
|
+
if (item.kind === 'suggestion')
|
|
11
|
+
return editorCommandChain(chain, item.value).run();
|
|
12
|
+
const atom = item.kind === 'mention'
|
|
13
|
+
? { type: 'reacdMention', attrs: { id: item.id, label: item.label } }
|
|
14
|
+
: { type: 'reacdEmoji', attrs: { name: item.name, value: item.value } };
|
|
15
|
+
return chain.insertContent([atom, { type: 'text', text: P.suffix }]).run();
|
|
16
|
+
}
|
|
17
|
+
export function mountEditorMenu(editor, request, released) {
|
|
18
|
+
const key = new PluginKey(`reacd-${request.kind}`);
|
|
19
|
+
let current;
|
|
20
|
+
let selected = P.initialIndex;
|
|
21
|
+
let destroyed = false;
|
|
22
|
+
let revision = 0;
|
|
23
|
+
function resolved(query) {
|
|
24
|
+
const remote = request.lookup?.(query);
|
|
25
|
+
const items = remote?.items ??
|
|
26
|
+
request
|
|
27
|
+
.items()
|
|
28
|
+
.filter((item) => item.label.toLowerCase().includes(query.toLowerCase()))
|
|
29
|
+
.slice(0, P.maxResults);
|
|
30
|
+
return {
|
|
31
|
+
status: remote?.status ?? 'ready',
|
|
32
|
+
error: remote?.error,
|
|
33
|
+
items: items
|
|
34
|
+
.slice(0, P.maxResults)
|
|
35
|
+
.map((item) => item.kind === 'suggestion' && !canRunSdkCommand(editor, item.value)
|
|
36
|
+
? { ...item, disabled: true }
|
|
37
|
+
: item),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function clear() {
|
|
41
|
+
revision += 1;
|
|
42
|
+
current = undefined;
|
|
43
|
+
if (!editor.isDestroyed &&
|
|
44
|
+
editor.view.dom.getAttribute('aria-controls') === request.listId) {
|
|
45
|
+
for (const name of [
|
|
46
|
+
'aria-controls',
|
|
47
|
+
'aria-expanded',
|
|
48
|
+
'aria-activedescendant',
|
|
49
|
+
'aria-autocomplete',
|
|
50
|
+
'aria-busy',
|
|
51
|
+
])
|
|
52
|
+
editor.view.dom.removeAttribute(name);
|
|
53
|
+
}
|
|
54
|
+
request.change(undefined);
|
|
55
|
+
}
|
|
56
|
+
function publish(next) {
|
|
57
|
+
if (destroyed || editor.isDestroyed)
|
|
58
|
+
return;
|
|
59
|
+
const ticket = ++revision;
|
|
60
|
+
current = next;
|
|
61
|
+
const data = resolved(next.query);
|
|
62
|
+
if (ticket !== revision || destroyed || editor.isDestroyed)
|
|
63
|
+
return;
|
|
64
|
+
current = { ...next, items: [...data.items] };
|
|
65
|
+
if (data.items[selected] === undefined || data.items[selected]?.disabled === true)
|
|
66
|
+
selected = data.items.findIndex((item) => item.disabled !== true);
|
|
67
|
+
const input = editor.view.dom;
|
|
68
|
+
input.setAttribute('aria-controls', request.listId);
|
|
69
|
+
input.setAttribute('aria-expanded', 'true');
|
|
70
|
+
input.setAttribute('aria-autocomplete', 'list');
|
|
71
|
+
input.setAttribute('aria-busy', String(data.status === 'loading'));
|
|
72
|
+
if (data.items[selected] === undefined)
|
|
73
|
+
input.removeAttribute('aria-activedescendant');
|
|
74
|
+
else
|
|
75
|
+
input.setAttribute('aria-activedescendant', `${request.listId}-${selected}`);
|
|
76
|
+
request.change(Object.freeze({
|
|
77
|
+
query: next.query,
|
|
78
|
+
status: data.status,
|
|
79
|
+
error: data.error,
|
|
80
|
+
items: Object.freeze([...data.items]),
|
|
81
|
+
selected,
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
function close() {
|
|
85
|
+
if (!destroyed && !editor.isDestroyed)
|
|
86
|
+
exitSuggestion(editor.view, key);
|
|
87
|
+
}
|
|
88
|
+
function choose(index) {
|
|
89
|
+
const suggestion = current;
|
|
90
|
+
if (destroyed ||
|
|
91
|
+
editor.isDestroyed ||
|
|
92
|
+
!editor.isEditable ||
|
|
93
|
+
suggestion === undefined)
|
|
94
|
+
return;
|
|
95
|
+
const item = suggestion.items[index];
|
|
96
|
+
if (item === undefined || item.disabled === true)
|
|
97
|
+
return;
|
|
98
|
+
suggestion.command(item);
|
|
99
|
+
close();
|
|
100
|
+
}
|
|
101
|
+
function step(suggestion, direction) {
|
|
102
|
+
const enabled = suggestion.items.flatMap((item, index) => item.disabled === true ? [] : [index]);
|
|
103
|
+
if (enabled.length > 0) {
|
|
104
|
+
const next = (enabled.indexOf(selected) + direction + enabled.length) % enabled.length;
|
|
105
|
+
for (const [position, value] of enabled.entries()) {
|
|
106
|
+
if (position === next)
|
|
107
|
+
selected = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
publish(suggestion);
|
|
111
|
+
}
|
|
112
|
+
const plugin = Suggestion({
|
|
113
|
+
editor,
|
|
114
|
+
pluginKey: key,
|
|
115
|
+
char: P.triggers[request.kind],
|
|
116
|
+
allow: ({ state, range }) => editor.isEditable &&
|
|
117
|
+
range.to - range.from <= P.maxQuery + P.triggers[request.kind].length &&
|
|
118
|
+
state.selection.$from.parent.type.name !== 'codeBlock',
|
|
119
|
+
shouldResetDismissed: ({ transaction, match, range }) => {
|
|
120
|
+
const reverse = transaction.mapping.invert();
|
|
121
|
+
if (reverse.mapResult(match.range.from).deleted)
|
|
122
|
+
return true;
|
|
123
|
+
// DOM diffing can keep the colon while replacing the entire escaped query.
|
|
124
|
+
const from = reverse.map(range.from, -1) + P.triggers[request.kind].length;
|
|
125
|
+
const to = reverse.map(range.to);
|
|
126
|
+
return (to > from &&
|
|
127
|
+
transaction.mapping.mapResult(from).deleted &&
|
|
128
|
+
transaction.mapping.mapResult(to, -1).deleted);
|
|
129
|
+
},
|
|
130
|
+
items: ({ query }) => [...resolved(query).items],
|
|
131
|
+
command: ({ editor: active, range, props }) => {
|
|
132
|
+
insert(active, range, props);
|
|
133
|
+
},
|
|
134
|
+
render: () => ({
|
|
135
|
+
onStart: (next) => {
|
|
136
|
+
selected = P.initialIndex;
|
|
137
|
+
publish(next);
|
|
138
|
+
},
|
|
139
|
+
onUpdate: (next) => {
|
|
140
|
+
if (current?.query !== next.query)
|
|
141
|
+
selected = P.initialIndex;
|
|
142
|
+
publish(next);
|
|
143
|
+
},
|
|
144
|
+
onExit: () => {
|
|
145
|
+
if (destroyed)
|
|
146
|
+
return;
|
|
147
|
+
if (editor.isDestroyed ||
|
|
148
|
+
!activeSuggestionSchema.safeParse(key.getState(editor.state)).success)
|
|
149
|
+
clear();
|
|
150
|
+
},
|
|
151
|
+
onKeyDown: ({ event }) => {
|
|
152
|
+
const suggestion = current;
|
|
153
|
+
if (editor.isDestroyed || suggestion === undefined || event.isComposing)
|
|
154
|
+
return false;
|
|
155
|
+
if (event.key === 'ArrowDown') {
|
|
156
|
+
step(suggestion, 1);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if (event.key === 'ArrowUp') {
|
|
160
|
+
step(suggestion, -1);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
if (event.key === 'Enter') {
|
|
164
|
+
choose(selected);
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
editor.registerPlugin(plugin, (registered, plugins) => [registered, ...plugins]);
|
|
172
|
+
return {
|
|
173
|
+
choose,
|
|
174
|
+
close,
|
|
175
|
+
refresh() {
|
|
176
|
+
if (current !== undefined && !destroyed && !editor.isDestroyed)
|
|
177
|
+
publish(current);
|
|
178
|
+
},
|
|
179
|
+
destroy() {
|
|
180
|
+
if (destroyed)
|
|
181
|
+
return;
|
|
182
|
+
destroyed = true;
|
|
183
|
+
clear();
|
|
184
|
+
if (!editor.isDestroyed) {
|
|
185
|
+
editor.unregisterPlugin(key);
|
|
186
|
+
}
|
|
187
|
+
released();
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EDITOR_MENU_POLICY } from '@fastsprout/reacd/adapter-runtime/core/editor-menu-policy.js';
|
|
2
|
+
import { mountEditorMenu } from './menu-plugin.js';
|
|
3
|
+
export function createEditorMenuPort(editor, disabled) {
|
|
4
|
+
const registrations = new Set();
|
|
5
|
+
return {
|
|
6
|
+
disabled: disabled || editor === null,
|
|
7
|
+
mount(request) {
|
|
8
|
+
if (editor === null || editor.isDestroyed || disabled)
|
|
9
|
+
return {
|
|
10
|
+
success: false,
|
|
11
|
+
issues: [{ path: 'EditorMenu', message: EDITOR_MENU_POLICY.scopeError }],
|
|
12
|
+
};
|
|
13
|
+
if (registrations.has(request.kind))
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
issues: [{ path: 'EditorMenu', message: EDITOR_MENU_POLICY.duplicateError }],
|
|
17
|
+
};
|
|
18
|
+
registrations.add(request.kind);
|
|
19
|
+
return {
|
|
20
|
+
success: true,
|
|
21
|
+
data: mountEditorMenu(editor, request, () => {
|
|
22
|
+
registrations.delete(request.kind);
|
|
23
|
+
}),
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorMenuItem, EditorMenuPort, EditorMenuRequest, EditorMenuView } from '@fastsprout/reacd/adapter-runtime/renderer/editor/menu-context.js';
|
|
2
|
+
import type { ValidationIssue } from '@fastsprout/reacd/adapter-runtime/core/render-port.js';
|
|
3
|
+
import type { EditorMentionLookupRequest, EditorMentionLookupResult } from '@fastsprout/reacd/adapter-runtime/schema/editor-mention-menu/lookup.schema.js';
|
|
4
|
+
export interface MentionLookupSource {
|
|
5
|
+
readonly results: EditorMentionLookupResult | null;
|
|
6
|
+
readonly onQueryChange: (request: EditorMentionLookupRequest) => void;
|
|
7
|
+
}
|
|
8
|
+
export type EditorMenuSnapshot = {
|
|
9
|
+
readonly view: EditorMenuView;
|
|
10
|
+
} | {
|
|
11
|
+
readonly issues: readonly ValidationIssue[];
|
|
12
|
+
} | undefined;
|
|
13
|
+
export declare function createEditorMenuStore(initial: readonly EditorMenuItem[], scope: string): {
|
|
14
|
+
snapshot: () => EditorMenuSnapshot;
|
|
15
|
+
serverSnapshot: () => undefined;
|
|
16
|
+
subscribe(this: void, listener: () => void): () => void;
|
|
17
|
+
catalog(items: readonly EditorMenuItem[], source: MentionLookupSource | undefined): void;
|
|
18
|
+
attach(port: EditorMenuPort, options: Pick<EditorMenuRequest, 'kind' | 'listId'>): () => void;
|
|
19
|
+
choose(index: number): void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createMentionLookupController } from './lookup-controller.js';
|
|
2
|
+
export function createEditorMenuStore(initial, scope) {
|
|
3
|
+
let catalog = initial;
|
|
4
|
+
let remote;
|
|
5
|
+
let snapshot;
|
|
6
|
+
let lease;
|
|
7
|
+
let attachment;
|
|
8
|
+
const lookup = createMentionLookupController(scope);
|
|
9
|
+
const listeners = new Set();
|
|
10
|
+
function publish(next) {
|
|
11
|
+
if (snapshot === next)
|
|
12
|
+
return;
|
|
13
|
+
snapshot = next;
|
|
14
|
+
for (const listener of listeners)
|
|
15
|
+
listener();
|
|
16
|
+
}
|
|
17
|
+
function resolve(query) {
|
|
18
|
+
if (remote === undefined)
|
|
19
|
+
return undefined;
|
|
20
|
+
const next = lookup.update(query, remote.results);
|
|
21
|
+
if (next.request !== undefined)
|
|
22
|
+
remote.onQueryChange(next.request);
|
|
23
|
+
return {
|
|
24
|
+
status: next.status,
|
|
25
|
+
error: next.error,
|
|
26
|
+
items: next.items.map((item) => ({ ...item, kind: 'mention' })),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
snapshot: () => snapshot,
|
|
31
|
+
serverSnapshot: () => undefined,
|
|
32
|
+
subscribe(listener) {
|
|
33
|
+
listeners.add(listener);
|
|
34
|
+
return () => {
|
|
35
|
+
listeners.delete(listener);
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
catalog(items, source) {
|
|
39
|
+
catalog = items;
|
|
40
|
+
remote = source;
|
|
41
|
+
if (source === undefined)
|
|
42
|
+
lookup.close();
|
|
43
|
+
lease?.refresh();
|
|
44
|
+
},
|
|
45
|
+
attach(port, options) {
|
|
46
|
+
const owner = Object.freeze({});
|
|
47
|
+
attachment = owner;
|
|
48
|
+
lease = undefined;
|
|
49
|
+
let released = false;
|
|
50
|
+
const current = () => !released && attachment === owner;
|
|
51
|
+
const mounted = port.mount({
|
|
52
|
+
...options,
|
|
53
|
+
items: () => (current() ? catalog : []),
|
|
54
|
+
lookup: (query) => (current() ? resolve(query) : undefined),
|
|
55
|
+
change: (view) => {
|
|
56
|
+
if (!current())
|
|
57
|
+
return;
|
|
58
|
+
if (view === undefined)
|
|
59
|
+
lookup.close();
|
|
60
|
+
publish(view === undefined ? undefined : { view });
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
if (!mounted.success) {
|
|
64
|
+
publish({ issues: mounted.issues });
|
|
65
|
+
return () => {
|
|
66
|
+
if (!current())
|
|
67
|
+
return;
|
|
68
|
+
released = true;
|
|
69
|
+
attachment = undefined;
|
|
70
|
+
lookup.close();
|
|
71
|
+
publish(undefined);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
lease = mounted.data;
|
|
75
|
+
return () => {
|
|
76
|
+
if (released)
|
|
77
|
+
return;
|
|
78
|
+
released = true;
|
|
79
|
+
mounted.data.destroy();
|
|
80
|
+
if (attachment === owner) {
|
|
81
|
+
attachment = undefined;
|
|
82
|
+
lease = undefined;
|
|
83
|
+
lookup.close();
|
|
84
|
+
publish(undefined);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
choose(index) {
|
|
89
|
+
lease?.choose(index);
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EditorMenuKind } from '@fastsprout/reacd/adapter-runtime/core/editor-menu-policy.js';
|
|
2
|
+
import type { EditorMenuItem } from '@fastsprout/reacd/adapter-runtime/renderer/editor/menu-context.js';
|
|
3
|
+
import type { EditorMenuSnapshot, MentionLookupSource } from './menu-store.js';
|
|
4
|
+
export declare function useEditorMenu(kind: EditorMenuKind, items: readonly EditorMenuItem[], disabled: boolean | undefined, lookup?: MentionLookupSource): {
|
|
5
|
+
listId: string;
|
|
6
|
+
orphan: boolean;
|
|
7
|
+
snapshot: EditorMenuSnapshot;
|
|
8
|
+
choose: (index: number) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, useEffect, useId, useLayoutEffect, useState, useSyncExternalStore, } from 'react';
|
|
2
|
+
import { EditorMenuScopeContext } from '@fastsprout/reacd/adapter-runtime/renderer/editor/menu-context.js';
|
|
3
|
+
import { createEditorMenuStore } from './menu-store.js';
|
|
4
|
+
export function useEditorMenu(kind, items, disabled, lookup) {
|
|
5
|
+
const listId = useId();
|
|
6
|
+
const port = useContext(EditorMenuScopeContext);
|
|
7
|
+
const [store] = useState(() => createEditorMenuStore(items, listId));
|
|
8
|
+
const snapshot = useSyncExternalStore(store.subscribe, store.snapshot, store.serverSnapshot);
|
|
9
|
+
useLayoutEffect(() => store.catalog(items, lookup), [store, items, lookup]);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (port === null || port.disabled || disabled === true)
|
|
12
|
+
return undefined;
|
|
13
|
+
return store.attach(port, { kind, listId });
|
|
14
|
+
}, [port, kind, listId, disabled, store]);
|
|
15
|
+
return {
|
|
16
|
+
listId,
|
|
17
|
+
orphan: port === null,
|
|
18
|
+
snapshot,
|
|
19
|
+
choose: (index) => store.choose(index),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Fragment, Slice } from '@tiptap/pm/model';
|
|
2
|
+
export function applyEditorPlainPaste(view, content) {
|
|
3
|
+
const marks = view.state.storedMarks ?? view.state.selection.$from.marks();
|
|
4
|
+
const nodes = content.map((value) => {
|
|
5
|
+
const node = view.state.schema.nodeFromJSON(value);
|
|
6
|
+
return node.isText ? node.mark(marks) : node;
|
|
7
|
+
});
|
|
8
|
+
view.dispatch(view.state.tr
|
|
9
|
+
.replaceSelection(new Slice(Fragment.from(nodes), 0, 0))
|
|
10
|
+
.ensureMarks(marks)
|
|
11
|
+
.scrollIntoView());
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { EDITOR_DEFAULTS, EDITOR_POLICY, } from '@fastsprout/reacd/adapter-runtime/core/editor-policy.js';
|
|
3
|
+
import { stateKeySchema } from '@fastsprout/reacd/adapter-runtime/schema/state/shared/definition.js';
|
|
4
|
+
import { labelSchema } from '@fastsprout/reacd/adapter-runtime/schema/shared/values.js';
|
|
5
|
+
const mentionSchema = z.strictObject({ id: stateKeySchema, label: labelSchema });
|
|
6
|
+
const emojiSchema = z.strictObject({
|
|
7
|
+
name: stateKeySchema,
|
|
8
|
+
value: z.string().min(1).max(EDITOR_POLICY.maxEmojiLength),
|
|
9
|
+
});
|
|
10
|
+
export function editorAtomData(kind, attributes) {
|
|
11
|
+
if (kind === 'mention') {
|
|
12
|
+
const parsed = mentionSchema.safeParse(attributes);
|
|
13
|
+
if (parsed.success)
|
|
14
|
+
return {
|
|
15
|
+
text: `${EDITOR_DEFAULTS.mentionPrefix}${parsed.data.label}`,
|
|
16
|
+
attributes: {
|
|
17
|
+
class: 'reacd-editor-mention',
|
|
18
|
+
contenteditable: 'false',
|
|
19
|
+
'data-reacd-mention': parsed.data.id,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const parsed = emojiSchema.safeParse(attributes);
|
|
25
|
+
if (parsed.success)
|
|
26
|
+
return {
|
|
27
|
+
text: parsed.data.value,
|
|
28
|
+
attributes: {
|
|
29
|
+
class: 'reacd-editor-emoji',
|
|
30
|
+
contenteditable: 'false',
|
|
31
|
+
role: 'img',
|
|
32
|
+
'aria-label': parsed.data.name,
|
|
33
|
+
'data-reacd-emoji': parsed.data.name,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
text: EDITOR_DEFAULTS.unavailableInline,
|
|
39
|
+
attributes: { contenteditable: 'false' },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
import { editorAtomData } from './atom-data.js';
|
|
3
|
+
export function createEditorAtom(kind) {
|
|
4
|
+
return Node.create({
|
|
5
|
+
name: kind === 'mention' ? 'reacdMention' : 'reacdEmoji',
|
|
6
|
+
group: 'inline',
|
|
7
|
+
inline: true,
|
|
8
|
+
atom: true,
|
|
9
|
+
addAttributes() {
|
|
10
|
+
return kind === 'mention'
|
|
11
|
+
? { id: { default: null }, label: { default: null } }
|
|
12
|
+
: { name: { default: null }, value: { default: null } };
|
|
13
|
+
},
|
|
14
|
+
parseHTML() {
|
|
15
|
+
return [];
|
|
16
|
+
},
|
|
17
|
+
renderHTML({ node }) {
|
|
18
|
+
const data = editorAtomData(kind, node.attrs);
|
|
19
|
+
return ['span', data.attributes, data.text];
|
|
20
|
+
},
|
|
21
|
+
renderText({ node }) {
|
|
22
|
+
return editorAtomData(kind, node.attrs).text;
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EDITOR_SDK_BLOCK_TYPES: readonly ['paragraph', 'heading', 'codeBlock', 'blockquote', 'bulletList', 'orderedList', 'listItem', 'horizontalRule'];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { EDITOR_HEADING_LEVELS } from '@fastsprout/reacd/adapter-runtime/core/editor-policy.js';
|
|
2
|
+
const operations = {
|
|
3
|
+
bold: (chain) => chain.toggleBold(),
|
|
4
|
+
italic: (chain) => chain.toggleItalic(),
|
|
5
|
+
strike: (chain) => chain.toggleStrike(),
|
|
6
|
+
underline: (chain) => chain.toggleUnderline(),
|
|
7
|
+
code: (chain) => chain.toggleCode(),
|
|
8
|
+
heading1: (chain) => chain.toggleHeading({ level: EDITOR_HEADING_LEVELS[0] }),
|
|
9
|
+
heading2: (chain) => chain.toggleHeading({ level: EDITOR_HEADING_LEVELS[1] }),
|
|
10
|
+
heading3: (chain) => chain.toggleHeading({ level: EDITOR_HEADING_LEVELS[2] }),
|
|
11
|
+
paragraph: (chain) => chain.setParagraph(),
|
|
12
|
+
bulletList: (chain) => chain.toggleBulletList(),
|
|
13
|
+
orderedList: (chain) => chain.toggleOrderedList(),
|
|
14
|
+
quote: (chain) => chain.toggleBlockquote(),
|
|
15
|
+
codeBlock: (chain) => chain.toggleCodeBlock(),
|
|
16
|
+
separator: (chain) => chain.setHorizontalRule(),
|
|
17
|
+
removeLink: (chain) => chain.unsetLink(),
|
|
18
|
+
undo: (chain) => chain.undo(),
|
|
19
|
+
redo: (chain) => chain.redo(),
|
|
20
|
+
};
|
|
21
|
+
export function editorCommandChain(chain, command) {
|
|
22
|
+
return command.command === 'link'
|
|
23
|
+
? chain.setLink({ href: command.href })
|
|
24
|
+
: operations[command.command](chain);
|
|
25
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Editor } from '@tiptap/core';
|
|
2
|
+
import type { EditorCommand } from '@fastsprout/reacd/adapter-runtime/core/editor-commands.js';
|
|
3
|
+
export declare function canRunSdkCommand(editor: Editor, command: EditorCommand): boolean;
|
|
4
|
+
export declare function runSdkCommand(editor: Editor, command: EditorCommand): boolean;
|
|
5
|
+
export declare function sdkCommandActive(editor: Editor, command: EditorCommand): boolean;
|