@swisper.ai/web-chat-ui 0.0.2
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 +202 -0
- package/README.md +251 -0
- package/dist/components/canvas-shell/canvas-shell.d.ts +64 -0
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -0
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +26 -0
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -0
- package/dist/components/canvas-shell/index.d.ts +2 -0
- package/dist/components/canvas-shell/index.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +21 -0
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +24 -0
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +28 -0
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +12 -0
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +19 -0
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +1 -0
- package/dist/components/card-item-picker/index.d.ts +9 -0
- package/dist/components/card-item-picker/index.d.ts.map +1 -0
- package/dist/components/chat-card/chat-card.d.ts +4 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -0
- package/dist/components/chat-card/chat-card.stories.d.ts +11 -0
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts +22 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts +20 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-form.d.ts +28 -0
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-header.d.ts +36 -0
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -0
- package/dist/components/chat-card/components/index.d.ts +5 -0
- package/dist/components/chat-card/components/index.d.ts.map +1 -0
- package/dist/components/chat-card/context.d.ts +13 -0
- package/dist/components/chat-card/context.d.ts.map +1 -0
- package/dist/components/chat-card/contexts.d.ts +16 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -0
- package/dist/components/chat-card/hooks.d.ts +13 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -0
- package/dist/components/chat-card/index.d.ts +6 -0
- package/dist/components/chat-card/index.d.ts.map +1 -0
- package/dist/components/chat-card/types.d.ts +21 -0
- package/dist/components/chat-card/types.d.ts.map +1 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts +43 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -0
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +17 -0
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -0
- package/dist/components/chat-card-container/index.d.ts +3 -0
- package/dist/components/chat-card-container/index.d.ts.map +1 -0
- package/dist/components/chat-container/chat-container.d.ts +51 -0
- package/dist/components/chat-container/chat-container.d.ts.map +1 -0
- package/dist/components/chat-container/chat-container.stories.d.ts +21 -0
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -0
- package/dist/components/chat-container/index.d.ts +3 -0
- package/dist/components/chat-container/index.d.ts.map +1 -0
- package/dist/components/chat-input/chat-input.d.ts +35 -0
- package/dist/components/chat-input/chat-input.d.ts.map +1 -0
- package/dist/components/chat-input/chat-input.stories.d.ts +14 -0
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -0
- package/dist/components/chat-input/index.d.ts +3 -0
- package/dist/components/chat-input/index.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts +8 -0
- package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/disabled-plugin.d.ts +7 -0
- package/dist/components/chat-input/plugins/disabled-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/focus-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/has-value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/has-value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/hooks.d.ts +2 -0
- package/dist/components/chat-input/plugins/hooks.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/index.d.ts +8 -0
- package/dist/components/chat-input/plugins/index.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts +2 -0
- package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/utils.d.ts +4 -0
- package/dist/components/chat-input/plugins/utils.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/transformers.d.ts +3 -0
- package/dist/components/chat-input/transformers.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list-item.d.ts +8 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list-items.d.ts +11 -0
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list.d.ts +63 -0
- package/dist/components/chat-list/chat-list.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list.stories.d.ts +13 -0
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -0
- package/dist/components/chat-list/index.d.ts +4 -0
- package/dist/components/chat-list/index.d.ts.map +1 -0
- package/dist/components/chat-message/chat-message.d.ts +17 -0
- package/dist/components/chat-message/chat-message.d.ts.map +1 -0
- package/dist/components/chat-message/chat-message.stories.d.ts +11 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -0
- package/dist/components/chat-message/index.d.ts +2 -0
- package/dist/components/chat-message/index.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +9 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +30 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +11 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/index.d.ts +4 -0
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts +5 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -0
- package/dist/components/chat-message-history/chat-message-history.d.ts +48 -0
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +1 -0
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +7 -0
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +1 -0
- package/dist/components/chat-message-history/index.d.ts +2 -0
- package/dist/components/chat-message-history/index.d.ts.map +1 -0
- package/dist/components/chat-message-response/chat-message-response.d.ts +7 -0
- package/dist/components/chat-message-response/chat-message-response.d.ts.map +1 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +7 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -0
- package/dist/components/chat-message-response/index.d.ts +2 -0
- package/dist/components/chat-message-response/index.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +25 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +7 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/index.d.ts +2 -0
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -0
- package/dist/components/chat-messages/chat-messages.d.ts +24 -0
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -0
- package/dist/components/chat-messages/chat-messages.stories.d.ts +8 -0
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -0
- package/dist/components/chat-messages/index.d.ts +2 -0
- package/dist/components/chat-messages/index.d.ts.map +1 -0
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +114 -0
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -0
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +10 -0
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -0
- package/dist/components/chat-notification-card/index.d.ts +4 -0
- package/dist/components/chat-notification-card/index.d.ts.map +1 -0
- package/dist/components/chat-notification-card/types.d.ts +2 -0
- package/dist/components/chat-notification-card/types.d.ts.map +1 -0
- package/dist/components/chat-notification-card/utils.d.ts +3 -0
- package/dist/components/chat-notification-card/utils.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +12 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +8 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/index.d.ts +2 -0
- package/dist/components/chat-notification-popup/index.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts +17 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts +2 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +27 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +9 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/index.d.ts +3 -0
- package/dist/components/chat-prompt-box/index.d.ts.map +1 -0
- package/dist/components/chat-reply/chat-reply.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts +7 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -0
- package/dist/components/chat-reply/index.d.ts +2 -0
- package/dist/components/chat-reply/index.d.ts.map +1 -0
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +37 -0
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -0
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +9 -0
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -0
- package/dist/components/chat-suggestion/index.d.ts +2 -0
- package/dist/components/chat-suggestion/index.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +47 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +10 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/index.d.ts +2 -0
- package/dist/components/chat-thinking-process/index.d.ts.map +1 -0
- package/dist/components/chat-thread/chat-thread.d.ts +78 -0
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -0
- package/dist/components/chat-thread/chat-thread.stories.d.ts +14 -0
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -0
- package/dist/components/chat-thread/index.d.ts +2 -0
- package/dist/components/chat-thread/index.d.ts.map +1 -0
- package/dist/components/deprecated-empty-state.d.ts +22 -0
- package/dist/components/deprecated-empty-state.d.ts.map +1 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/markdown-viewer/hooks.d.ts +9 -0
- package/dist/components/markdown-viewer/hooks.d.ts.map +1 -0
- package/dist/components/markdown-viewer/index.d.ts +3 -0
- package/dist/components/markdown-viewer/index.d.ts.map +1 -0
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +10 -0
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -0
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +9 -0
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -0
- package/dist/components/markdown-viewer/types.d.ts +9 -0
- package/dist/components/markdown-viewer/types.d.ts.map +1 -0
- package/dist/components/markdown-viewer/utils.d.ts +3 -0
- package/dist/components/markdown-viewer/utils.d.ts.map +1 -0
- package/dist/components/new-chat-trigger/index.d.ts +2 -0
- package/dist/components/new-chat-trigger/index.d.ts.map +1 -0
- package/dist/components/new-chat-trigger/new-chat-trigger.d.ts +8 -0
- package/dist/components/new-chat-trigger/new-chat-trigger.d.ts.map +1 -0
- package/dist/components/rich-text-area/constants/index.d.ts +3 -0
- package/dist/components/rich-text-area/constants/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/hooks.d.ts +3 -0
- package/dist/components/rich-text-area/hooks.d.ts.map +1 -0
- package/dist/components/rich-text-area/html-config.d.ts +4 -0
- package/dist/components/rich-text-area/html-config.d.ts.map +1 -0
- package/dist/components/rich-text-area/index.d.ts +7 -0
- package/dist/components/rich-text-area/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/nodes/div-block-node.d.ts +18 -0
- package/dist/components/rich-text-area/nodes/div-block-node.d.ts.map +1 -0
- package/dist/components/rich-text-area/nodes/image-node.d.ts +24 -0
- package/dist/components/rich-text-area/nodes/image-node.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/blur-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/blur-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts +10 -0
- package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/focus-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/focus-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts +19 -0
- package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts +12 -0
- package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/index.d.ts +11 -0
- package/dist/components/rich-text-area/plugins/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts +2 -0
- package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts +20 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +7 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -0
- package/dist/components/rich-text-area/styled.d.ts +3 -0
- package/dist/components/rich-text-area/styled.d.ts.map +1 -0
- package/dist/components/rich-text-area/transformers.d.ts +16 -0
- package/dist/components/rich-text-area/transformers.d.ts.map +1 -0
- package/dist/components/rich-text-area/types.d.ts +8 -0
- package/dist/components/rich-text-area/types.d.ts.map +1 -0
- package/dist/components/rich-text-area/utils/index.d.ts +6 -0
- package/dist/components/rich-text-area/utils/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/alignment-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/alignment-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/attachment-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/attachment-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/bold-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/bold-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/clean-format-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/clean-format-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +11 -0
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/image-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/image-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/index.d.ts +14 -0
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/italic-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/italic-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/link-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/link-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/size-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/size-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/text-color-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/toolbar-button.d.ts +6 -0
- package/dist/components/rich-text-field/components/toolbar-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/toolbar-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/toolbar-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/typography-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/typography-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/underline-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/underline-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/constants.d.ts +57 -0
- package/dist/components/rich-text-field/constants.d.ts.map +1 -0
- package/dist/components/rich-text-field/context.d.ts +26 -0
- package/dist/components/rich-text-field/context.d.ts.map +1 -0
- package/dist/components/rich-text-field/index.d.ts +3 -0
- package/dist/components/rich-text-field/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts +17 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -0
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +10 -0
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -0
- package/dist/components/rich-text-field/utils.d.ts +1759 -0
- package/dist/components/rich-text-field/utils.d.ts.map +1 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.d.ts.map +1 -0
- package/dist/components/spinner/spinner.d.ts +9 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.stories.d.ts +8 -0
- package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
- package/dist/contexts/chat-context/chat-context.d.ts +20 -0
- package/dist/contexts/chat-context/chat-context.d.ts.map +1 -0
- package/dist/contexts/chat-context/index.d.ts +2 -0
- package/dist/contexts/chat-context/index.d.ts.map +1 -0
- package/dist/contexts/chat-context/utils.d.ts +3 -0
- package/dist/contexts/chat-context/utils.d.ts.map +1 -0
- package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts +20 -0
- package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts.map +1 -0
- package/dist/contexts/chat-conversation-context/index.d.ts +2 -0
- package/dist/contexts/chat-conversation-context/index.d.ts.map +1 -0
- package/dist/contexts/index.d.ts +3 -0
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts +41 -0
- package/dist/docs/agent.stories.d.ts.map +1 -0
- package/dist/docs/chat-panel.d.ts +33 -0
- package/dist/docs/chat-panel.d.ts.map +1 -0
- package/dist/docs/chatbot-panel.d.ts +20 -0
- package/dist/docs/chatbot-panel.d.ts.map +1 -0
- package/dist/docs/chatbot.stories.d.ts +11 -0
- package/dist/docs/chatbot.stories.d.ts.map +1 -0
- package/dist/domain/actions/constants.d.ts +2 -0
- package/dist/domain/actions/constants.d.ts.map +1 -0
- package/dist/domain/actions/hooks/index.d.ts +3 -0
- package/dist/domain/actions/hooks/index.d.ts.map +1 -0
- package/dist/domain/actions/index.d.ts +5 -0
- package/dist/domain/actions/index.d.ts.map +1 -0
- package/dist/domain/actions/types.d.ts +7 -0
- package/dist/domain/actions/types.d.ts.map +1 -0
- package/dist/domain/actions/utils/index.d.ts +11 -0
- package/dist/domain/actions/utils/index.d.ts.map +1 -0
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-chat-prompt-placeholder.d.ts +6 -0
- package/dist/hooks/use-chat-prompt-placeholder.d.ts.map +1 -0
- package/dist/hooks/use-chat-stream-message.d.ts +42 -0
- package/dist/hooks/use-chat-stream-message.d.ts.map +1 -0
- package/dist/hooks/use-current-chat-id.d.ts +2 -0
- package/dist/hooks/use-current-chat-id.d.ts.map +1 -0
- package/dist/hooks/use-is-current-chat-new.d.ts +2 -0
- package/dist/hooks/use-is-current-chat-new.d.ts.map +1 -0
- package/dist/hooks/use-loaded-chat-ids.d.ts +9 -0
- package/dist/hooks/use-loaded-chat-ids.d.ts.map +1 -0
- package/dist/hooks/use-on-chat-changed.d.ts +9 -0
- package/dist/hooks/use-on-chat-changed.d.ts.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +4404 -0
- package/dist/index.es.js.map +1 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +95 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +24 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-list-layout/index.d.ts +3 -0
- package/dist/layouts/chat-card-list-layout/index.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +84 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +45 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +37 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +81 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/index.d.ts +5 -0
- package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +31 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +12 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +19 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +35 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/index.d.ts +4 -0
- package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +1 -0
- package/dist/layouts/index.d.ts +4 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/use-streaming-markdown.d.ts +18 -0
- package/dist/utils/use-streaming-markdown.d.ts.map +1 -0
- package/package.json +155 -0
- package/src/__tests__/setup.ts +5 -0
- package/src/components/canvas-shell/canvas-shell.json +126 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +194 -0
- package/src/components/canvas-shell/canvas-shell.test.tsx +205 -0
- package/src/components/canvas-shell/canvas-shell.tsx +250 -0
- package/src/components/canvas-shell/index.ts +19 -0
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +279 -0
- package/src/components/card-item-picker/card-item-picker-context.tsx +44 -0
- package/src/components/card-item-picker/card-item-picker-list.tsx +95 -0
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +96 -0
- package/src/components/card-item-picker/card-item-picker-row.tsx +109 -0
- package/src/components/card-item-picker/card-item-picker.json +147 -0
- package/src/components/card-item-picker/card-item-picker.stories.tsx +158 -0
- package/src/components/card-item-picker/index.ts +24 -0
- package/src/components/chat-card/__tests__/chat-card.spec.tsx +118 -0
- package/src/components/chat-card/chat-card.json +162 -0
- package/src/components/chat-card/chat-card.stories.tsx +349 -0
- package/src/components/chat-card/chat-card.tsx +106 -0
- package/src/components/chat-card/components/chat-card-body.tsx +115 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +95 -0
- package/src/components/chat-card/components/chat-card-form.tsx +120 -0
- package/src/components/chat-card/components/chat-card-header.tsx +240 -0
- package/src/components/chat-card/components/index.ts +4 -0
- package/src/components/chat-card/context.tsx +34 -0
- package/src/components/chat-card/contexts.tsx +42 -0
- package/src/components/chat-card/hooks.ts +51 -0
- package/src/components/chat-card/index.ts +5 -0
- package/src/components/chat-card/types.ts +23 -0
- package/src/components/chat-card-container/chat-card-container.json +84 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +149 -0
- package/src/components/chat-card-container/chat-card-container.tsx +75 -0
- package/src/components/chat-card-container/index.ts +2 -0
- package/src/components/chat-container/chat-container.json +93 -0
- package/src/components/chat-container/chat-container.stories.tsx +179 -0
- package/src/components/chat-container/chat-container.tsx +231 -0
- package/src/components/chat-container/index.ts +2 -0
- package/src/components/chat-input/chat-input.json +106 -0
- package/src/components/chat-input/chat-input.stories.tsx +291 -0
- package/src/components/chat-input/chat-input.tsx +220 -0
- package/src/components/chat-input/index.ts +2 -0
- package/src/components/chat-input/plugins/auto-focus-plugin.tsx +43 -0
- package/src/components/chat-input/plugins/controlled-value-plugin.tsx +47 -0
- package/src/components/chat-input/plugins/disabled-plugin.tsx +18 -0
- package/src/components/chat-input/plugins/focus-plugin.tsx +44 -0
- package/src/components/chat-input/plugins/has-value-plugin.tsx +51 -0
- package/src/components/chat-input/plugins/hooks.ts +7 -0
- package/src/components/chat-input/plugins/index.ts +7 -0
- package/src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx +63 -0
- package/src/components/chat-input/plugins/utils.ts +48 -0
- package/src/components/chat-input/plugins/value-plugin.tsx +35 -0
- package/src/components/chat-input/transformers.ts +4 -0
- package/src/components/chat-list/chat-list-item.tsx +33 -0
- package/src/components/chat-list/chat-list-items.tsx +144 -0
- package/src/components/chat-list/chat-list.json +117 -0
- package/src/components/chat-list/chat-list.stories.tsx +332 -0
- package/src/components/chat-list/chat-list.tsx +278 -0
- package/src/components/chat-list/index.ts +18 -0
- package/src/components/chat-message/chat-message.json +105 -0
- package/src/components/chat-message/chat-message.stories.tsx +95 -0
- package/src/components/chat-message/chat-message.tsx +66 -0
- package/src/components/chat-message/index.ts +1 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +74 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +110 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +131 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +142 -0
- package/src/components/chat-message-attachment-card/index.ts +12 -0
- package/src/components/chat-message-attachment-card/utils.ts +41 -0
- package/src/components/chat-message-history/chat-message-history.json +99 -0
- package/src/components/chat-message-history/chat-message-history.stories.tsx +136 -0
- package/src/components/chat-message-history/chat-message-history.tsx +277 -0
- package/src/components/chat-message-history/index.ts +13 -0
- package/src/components/chat-message-response/chat-message-response.json +68 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +63 -0
- package/src/components/chat-message-response/chat-message-response.tsx +24 -0
- package/src/components/chat-message-response/index.ts +1 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +100 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +62 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +97 -0
- package/src/components/chat-message-toolbar/index.ts +6 -0
- package/src/components/chat-messages/chat-messages.json +95 -0
- package/src/components/chat-messages/chat-messages.stories.tsx +284 -0
- package/src/components/chat-messages/chat-messages.tsx +264 -0
- package/src/components/chat-messages/index.ts +10 -0
- package/src/components/chat-notification-card/chat-notification-card.json +135 -0
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +290 -0
- package/src/components/chat-notification-card/chat-notification-card.tsx +684 -0
- package/src/components/chat-notification-card/index.ts +3 -0
- package/src/components/chat-notification-card/types.ts +1 -0
- package/src/components/chat-notification-card/utils.ts +34 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +97 -0
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +80 -0
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +36 -0
- package/src/components/chat-notification-popup/index.ts +1 -0
- package/src/components/chat-prompt-box/chat-prompt-box-context.tsx +62 -0
- package/src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx +22 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +106 -0
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +117 -0
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +296 -0
- package/src/components/chat-prompt-box/index.ts +16 -0
- package/src/components/chat-reply/chat-reply.json +79 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +72 -0
- package/src/components/chat-reply/chat-reply.tsx +103 -0
- package/src/components/chat-reply/index.ts +1 -0
- package/src/components/chat-suggestion/chat-suggestion.json +108 -0
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +147 -0
- package/src/components/chat-suggestion/chat-suggestion.tsx +184 -0
- package/src/components/chat-suggestion/index.ts +8 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +110 -0
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +202 -0
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +268 -0
- package/src/components/chat-thinking-process/index.ts +9 -0
- package/src/components/chat-thread/__tests__/chat-thread.spec.tsx +385 -0
- package/src/components/chat-thread/chat-thread.json +120 -0
- package/src/components/chat-thread/chat-thread.stories.tsx +218 -0
- package/src/components/chat-thread/chat-thread.tsx +549 -0
- package/src/components/chat-thread/index.ts +18 -0
- package/src/components/deprecated-empty-state.ts +39 -0
- package/src/components/index.ts +26 -0
- package/src/components/markdown-viewer/hooks.ts +59 -0
- package/src/components/markdown-viewer/index.ts +2 -0
- package/src/components/markdown-viewer/markdown-viewer.json +84 -0
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +110 -0
- package/src/components/markdown-viewer/markdown-viewer.tsx +95 -0
- package/src/components/markdown-viewer/types.ts +10 -0
- package/src/components/markdown-viewer/utils.ts +5 -0
- package/src/components/new-chat-trigger/index.ts +1 -0
- package/src/components/new-chat-trigger/new-chat-trigger.tsx +29 -0
- package/src/components/rich-text-area/constants/index.ts +10 -0
- package/src/components/rich-text-area/hooks.ts +24 -0
- package/src/components/rich-text-area/html-config.ts +195 -0
- package/src/components/rich-text-area/index.ts +6 -0
- package/src/components/rich-text-area/nodes/div-block-node.tsx +145 -0
- package/src/components/rich-text-area/nodes/image-node.tsx +100 -0
- package/src/components/rich-text-area/plugins/blur-plugin.tsx +36 -0
- package/src/components/rich-text-area/plugins/controlled-plugin.tsx +23 -0
- package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +101 -0
- package/src/components/rich-text-area/plugins/disabled-plugin.tsx +17 -0
- package/src/components/rich-text-area/plugins/file-attachment-plugin.tsx +57 -0
- package/src/components/rich-text-area/plugins/focus-plugin.tsx +44 -0
- package/src/components/rich-text-area/plugins/html-paste-plugin.tsx +104 -0
- package/src/components/rich-text-area/plugins/image-drop-plugin.tsx +56 -0
- package/src/components/rich-text-area/plugins/index.ts +10 -0
- package/src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx +63 -0
- package/src/components/rich-text-area/plugins/value-plugin.tsx +46 -0
- package/src/components/rich-text-area/rich-text-area.json +102 -0
- package/src/components/rich-text-area/rich-text-area.stories.tsx +140 -0
- package/src/components/rich-text-area/rich-text-area.tsx +156 -0
- package/src/components/rich-text-area/styled.tsx +20 -0
- package/src/components/rich-text-area/transformers.ts +175 -0
- package/src/components/rich-text-area/types.ts +8 -0
- package/src/components/rich-text-area/utils/index.ts +77 -0
- package/src/components/rich-text-field/components/alignment-select.tsx +103 -0
- package/src/components/rich-text-field/components/attachment-button.tsx +25 -0
- package/src/components/rich-text-field/components/bold-button.tsx +21 -0
- package/src/components/rich-text-field/components/clean-format-button.tsx +44 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +69 -0
- package/src/components/rich-text-field/components/image-button.tsx +11 -0
- package/src/components/rich-text-field/components/index.ts +14 -0
- package/src/components/rich-text-field/components/italic-button.tsx +21 -0
- package/src/components/rich-text-field/components/link-button.tsx +11 -0
- package/src/components/rich-text-field/components/size-select.tsx +27 -0
- package/src/components/rich-text-field/components/text-color-button.tsx +41 -0
- package/src/components/rich-text-field/components/toolbar-button.tsx +27 -0
- package/src/components/rich-text-field/components/toolbar-select.tsx +19 -0
- package/src/components/rich-text-field/components/typography-select.tsx +27 -0
- package/src/components/rich-text-field/components/underline-button.tsx +21 -0
- package/src/components/rich-text-field/constants.ts +33 -0
- package/src/components/rich-text-field/context.tsx +251 -0
- package/src/components/rich-text-field/index.tsx +6 -0
- package/src/components/rich-text-field/rich-text-field.json +118 -0
- package/src/components/rich-text-field/rich-text-field.stories.tsx +218 -0
- package/src/components/rich-text-field/rich-text-field.tsx +93 -0
- package/src/components/rich-text-field/utils.ts +532 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner/spinner.json +73 -0
- package/src/components/spinner/spinner.stories.tsx +41 -0
- package/src/components/spinner/spinner.tsx +32 -0
- package/src/contexts/chat-context/chat-context.tsx +97 -0
- package/src/contexts/chat-context/index.ts +1 -0
- package/src/contexts/chat-context/utils.ts +7 -0
- package/src/contexts/chat-conversation-context/chat-conversation-context.tsx +608 -0
- package/src/contexts/chat-conversation-context/index.ts +1 -0
- package/src/contexts/index.ts +2 -0
- package/src/docs/agent.stories.tsx +567 -0
- package/src/docs/chat-panel.tsx +174 -0
- package/src/docs/chatbot-panel.tsx +381 -0
- package/src/docs/chatbot.mdx +144 -0
- package/src/docs/chatbot.stories.tsx +63 -0
- package/src/domain/actions/constants.ts +1 -0
- package/src/domain/actions/hooks/index.ts +22 -0
- package/src/domain/actions/index.ts +4 -0
- package/src/domain/actions/types.ts +6 -0
- package/src/domain/actions/utils/index.ts +112 -0
- package/src/domain/index.ts +1 -0
- package/src/hooks/index.tsx +10 -0
- package/src/hooks/use-chat-prompt-placeholder.ts +7 -0
- package/src/hooks/use-chat-stream-message.ts +189 -0
- package/src/hooks/use-current-chat-id.ts +6 -0
- package/src/hooks/use-is-current-chat-new.ts +6 -0
- package/src/hooks/use-loaded-chat-ids.ts +32 -0
- package/src/hooks/use-on-chat-changed.ts +33 -0
- package/src/index.css +1 -0
- package/src/index.ts +6 -0
- package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +204 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +116 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +190 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +250 -0
- package/src/layouts/chat-card-list-layout/index.ts +11 -0
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +73 -0
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +282 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +131 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +78 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +273 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +291 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +135 -0
- package/src/layouts/chat-card-three-column-layout/index.ts +24 -0
- package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +109 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +97 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +21 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +138 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +132 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +65 -0
- package/src/layouts/chat-card-two-column-layout/index.ts +17 -0
- package/src/layouts/index.ts +3 -0
- package/src/types.ts +29 -0
- package/src/utils/use-streaming-markdown.ts +113 -0
- package/tailwind.css +7 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "markdown-viewer",
|
|
4
|
+
"purpose": "Renders an assistant's markdown (GitHub-flavoured, with sanitised inline HTML) through Streamdown, repairs half-received syntax while it streams, and renders <swi-*> tags with caller-supplied React components.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Rendering an assistant answer or any model-generated markdown in the chat",
|
|
7
|
+
"The text is still streaming in and must render cleanly at every partial step",
|
|
8
|
+
"The response embeds <swi-*> tags that should become interactive components (replies, cards)"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"A whole assistant answer in a message — use web-chat-ui/chat-message-response, which wraps this",
|
|
12
|
+
"Previewing a markdown file — use web-file-preview/file-preview",
|
|
13
|
+
"Plain, non-markdown text — use ui/typography"
|
|
14
|
+
],
|
|
15
|
+
"uxPrinciples": [
|
|
16
|
+
"Render as it arrives: partial text should never flash raw markdown or half tags.",
|
|
17
|
+
"The caret signals that the answer is still being written; it disappears when streaming ends."
|
|
18
|
+
],
|
|
19
|
+
"accessibility": {
|
|
20
|
+
"required": [
|
|
21
|
+
"Markdown headings render as real h1–h6: have the model start below the page's own heading level",
|
|
22
|
+
"Images in markdown need alt text in the markdown itself ()",
|
|
23
|
+
"Components passed in customComponents own their own accessibility"
|
|
24
|
+
],
|
|
25
|
+
"keyboard": [
|
|
26
|
+
"Not interactive itself; links and the controls in rendered blocks follow standard keyboard behaviour"
|
|
27
|
+
],
|
|
28
|
+
"aria": [
|
|
29
|
+
"Semantic HTML from the markdown (headings, lists, tables, links); no role or live region is added, so streamed text is not announced as it arrives"
|
|
30
|
+
],
|
|
31
|
+
"focus": [
|
|
32
|
+
"No focus management; focusable elements are those the markdown or the custom components render"
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"behaviour": {
|
|
36
|
+
"states": ["static", "streaming", "streaming with caret"],
|
|
37
|
+
"rules": [
|
|
38
|
+
"markdown is the full text received so far, not the newest chunk: pass the accumulated string on every update",
|
|
39
|
+
"Incomplete markdown and half-received <swi-*> tags are repaired on every render: a cut-off opening tag is completed and an unclosed <swi-*> tag gets its closing tag, so its renderer always receives a well-formed element",
|
|
40
|
+
"isStreaming tells Streamdown the last block is still arriving (isAnimating); hasCaret shows a block caret after the last character only while isStreaming is true",
|
|
41
|
+
"customComponents maps tag names to React components: <swi-*> keys render those tags, and standard element keys (p, a, code) override Streamdown's renderers but log a console warning",
|
|
42
|
+
"A <swi-*> tag with no entry in customComponents is stripped by the sanitiser and only its text is kept",
|
|
43
|
+
"Inline HTML is parsed and sanitised with rehype-sanitize, whose allow-list is extended with the mapped <swi-*> tags; links may use the swisper: protocol, and they render without Streamdown's link-safety confirmation"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"composition": {
|
|
47
|
+
"allowedParents": ["web-chat-ui/ChatMessageContent"],
|
|
48
|
+
"allowedChildren": ["markdown string", "<swi-*> tag renderers (customComponents)"],
|
|
49
|
+
"avoidCombinations": [
|
|
50
|
+
"One viewer per streamed chunk — render a single viewer with the accumulated text, so syntax that spans chunks parses",
|
|
51
|
+
"Rendering an assistant answer directly when web-chat-ui/chat-message-response fits — it already configures the viewer for a message"
|
|
52
|
+
],
|
|
53
|
+
"contexts": ["assistant message in a chat thread"]
|
|
54
|
+
},
|
|
55
|
+
"content": {
|
|
56
|
+
"labelRules": [],
|
|
57
|
+
"helperTextRules": [],
|
|
58
|
+
"errorRules": []
|
|
59
|
+
},
|
|
60
|
+
"aiDecisionRules": [
|
|
61
|
+
{
|
|
62
|
+
"condition": "Passing customComponents",
|
|
63
|
+
"decision": "Create the object once (module scope or useMemo), keyed by the exact tag name ('swi-reply')",
|
|
64
|
+
"reason": "Its identity is a memo dependency: a new object each render rebuilds the sanitiser plugins"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"condition": "The model can emit a <swi-*> tag the app does not render",
|
|
68
|
+
"decision": "Leave it out of customComponents",
|
|
69
|
+
"reason": "Unmapped <swi-*> tags are stripped and their text is shown, so nothing breaks"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"condition": "Showing a caret while the answer streams",
|
|
73
|
+
"decision": "Set both hasCaret and isStreaming, and turn both off when the stream ends",
|
|
74
|
+
"reason": "The caret only renders while isStreaming is true"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"relatedComponents": [
|
|
78
|
+
"web-chat-ui/chat-message-response",
|
|
79
|
+
"web-chat-ui/chat-message",
|
|
80
|
+
"web-chat-ui/chat-reply",
|
|
81
|
+
"web-file-preview/file-preview",
|
|
82
|
+
"ui/typography"
|
|
83
|
+
]
|
|
84
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { expect, within } from 'storybook/test';
|
|
3
|
+
|
|
4
|
+
import { useStreamingMarkdown } from '../../utils/use-streaming-markdown';
|
|
5
|
+
|
|
6
|
+
import { MarkdownViewer } from './markdown-viewer';
|
|
7
|
+
|
|
8
|
+
const meta: Meta<typeof MarkdownViewer> = {
|
|
9
|
+
title: 'Chatbot/MarkdownViewer',
|
|
10
|
+
component: MarkdownViewer,
|
|
11
|
+
parameters: {
|
|
12
|
+
layout: 'padded',
|
|
13
|
+
},
|
|
14
|
+
tags: ['autodocs'],
|
|
15
|
+
argTypes: {
|
|
16
|
+
markdown: {
|
|
17
|
+
control: 'text',
|
|
18
|
+
description:
|
|
19
|
+
'Markdown to render: GFM, math and `<swi-*>` tags. Pass the accumulated text so far while streaming.',
|
|
20
|
+
},
|
|
21
|
+
isStreaming: {
|
|
22
|
+
control: 'boolean',
|
|
23
|
+
description:
|
|
24
|
+
'Set while the response is still arriving: animates new text and closes half-received `<swi-*>` tags.',
|
|
25
|
+
table: { defaultValue: { summary: 'false' } },
|
|
26
|
+
},
|
|
27
|
+
hasCaret: {
|
|
28
|
+
control: 'boolean',
|
|
29
|
+
description: 'Shows a block caret after the last character, typically while streaming.',
|
|
30
|
+
table: { defaultValue: { summary: 'false' } },
|
|
31
|
+
},
|
|
32
|
+
customComponents: {
|
|
33
|
+
control: false,
|
|
34
|
+
description:
|
|
35
|
+
'Overrides for markdown elements or renderers for `<swi-*>` tags, keyed by tag name. Unmapped `<swi-*>` tags are stripped and only their text is kept.',
|
|
36
|
+
table: { defaultValue: { summary: '{}' } },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
args: {
|
|
40
|
+
markdown:
|
|
41
|
+
"Here's your day at a glance:\n\n- **09:30** Stand-up with the product team\n- **12:00** Lunch with Anna at Hiltl\n- **15:00** Quarterly review, *slides still in draft*",
|
|
42
|
+
isStreaming: false,
|
|
43
|
+
hasCaret: false,
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default meta;
|
|
48
|
+
type Story = StoryObj<typeof MarkdownViewer>;
|
|
49
|
+
|
|
50
|
+
const sampleMarkdown = `Welcome to MarkdownViewer!`;
|
|
51
|
+
|
|
52
|
+
const GREETING_EXAMPLE = `Good evening! Great to see you! I'm ready to help with whatever's on your mind - whether it's research, planning, writing, or just thinking something through.
|
|
53
|
+
|
|
54
|
+
<swi-reply style="display:none" version="0.0.1">
|
|
55
|
+
What can you help me with?|Check my calendar for today|Search for something
|
|
56
|
+
</swi-reply>`;
|
|
57
|
+
|
|
58
|
+
export const Default: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
markdown: sampleMarkdown,
|
|
61
|
+
isStreaming: false,
|
|
62
|
+
},
|
|
63
|
+
argTypes: {
|
|
64
|
+
markdown: {
|
|
65
|
+
control: 'text',
|
|
66
|
+
description: 'Markdown content to render',
|
|
67
|
+
},
|
|
68
|
+
isStreaming: {
|
|
69
|
+
control: 'boolean',
|
|
70
|
+
description: 'Whether the content is currently streaming',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const CustomComponents: Story = {
|
|
76
|
+
args: {
|
|
77
|
+
markdown: `<swi-reply style="display:none" version="0.0.1">
|
|
78
|
+
What can you help me with?|Check my calendar for today|Search for something
|
|
79
|
+
</swi-reply>
|
|
80
|
+
<swi-unsupported>Not supported(just text)</swi-unsupported>
|
|
81
|
+
`,
|
|
82
|
+
customComponents: {
|
|
83
|
+
'swi-reply': () => <div data-testid="swi-reply">[custom component: swi-reply!]</div>,
|
|
84
|
+
},
|
|
85
|
+
isStreaming: false,
|
|
86
|
+
},
|
|
87
|
+
play: async ({ canvasElement }) => {
|
|
88
|
+
const canvas = within(canvasElement);
|
|
89
|
+
|
|
90
|
+
// Verify swi-reply custom component renders correctly
|
|
91
|
+
const customComponent = canvas.getByText('[custom component: swi-reply!]');
|
|
92
|
+
expect(canvas.getByTestId('swi-reply')).toBeInTheDocument();
|
|
93
|
+
expect(customComponent).toBeInTheDocument();
|
|
94
|
+
expect(customComponent.tagName).toBe('DIV');
|
|
95
|
+
|
|
96
|
+
// Verify swi-unsupported is completely removed
|
|
97
|
+
const htmlContent = canvasElement.innerHTML;
|
|
98
|
+
expect(htmlContent).not.toContain('swi-unsupported');
|
|
99
|
+
expect(canvas.queryByText('swi-unsupported')).not.toBeInTheDocument();
|
|
100
|
+
expect(canvas.queryByText('Not supported(just text)')).toBeInTheDocument();
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const Streaming: Story = {
|
|
105
|
+
render: () => {
|
|
106
|
+
const { markdown, isStreaming } = useStreamingMarkdown(GREETING_EXAMPLE, 30);
|
|
107
|
+
|
|
108
|
+
return <MarkdownViewer markdown={markdown} isStreaming={isStreaming} />;
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { Streamdown } from 'streamdown';
|
|
2
|
+
|
|
3
|
+
import type { Markdown } from '../../types';
|
|
4
|
+
|
|
5
|
+
import { useMarkdownViewer } from './hooks';
|
|
6
|
+
import type { CustomMarkdownViewerComponents } from './types';
|
|
7
|
+
|
|
8
|
+
import 'katex/dist/katex.min.css';
|
|
9
|
+
|
|
10
|
+
export interface MarkdownViewerProps {
|
|
11
|
+
markdown: Markdown;
|
|
12
|
+
isStreaming?: boolean;
|
|
13
|
+
hasCaret?: boolean;
|
|
14
|
+
customComponents?: CustomMarkdownViewerComponents;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function MarkdownViewer({
|
|
18
|
+
markdown,
|
|
19
|
+
isStreaming = false,
|
|
20
|
+
hasCaret = false,
|
|
21
|
+
customComponents = {},
|
|
22
|
+
}: MarkdownViewerProps) {
|
|
23
|
+
const { components, remarkPlugins, rehypePlugins } = useMarkdownViewer({ customComponents });
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Streamdown
|
|
27
|
+
caret={hasCaret ? 'block' : undefined}
|
|
28
|
+
isAnimating={isStreaming}
|
|
29
|
+
components={components}
|
|
30
|
+
remarkPlugins={remarkPlugins}
|
|
31
|
+
rehypePlugins={rehypePlugins}
|
|
32
|
+
linkSafety={{ enabled: false }}
|
|
33
|
+
remend={{
|
|
34
|
+
handlers: [
|
|
35
|
+
{
|
|
36
|
+
name: 'swi-tag-filter',
|
|
37
|
+
handle: swiTagHandler,
|
|
38
|
+
priority: 0,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
{markdown}
|
|
44
|
+
</Streamdown>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function swiTagHandler(text: string, separator = '|') {
|
|
49
|
+
const incompleteRegex = /<swi-(\w+)([^>]*)$/gm;
|
|
50
|
+
const [incompleteMatch, tagName] = incompleteRegex.exec(text) ?? [];
|
|
51
|
+
|
|
52
|
+
if (text.endsWith('<swi-')) {
|
|
53
|
+
return text + '>';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (incompleteMatch) {
|
|
57
|
+
return text.replace(incompleteMatch, `<swi-${tagName}>`);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (text.endsWith(separator)) {
|
|
61
|
+
return text.slice(0, -1) + `</swi-${tagName}>`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const openingTagRegex = /<swi-(\w+)([^>]*)>/g;
|
|
65
|
+
const openingTags: { name: string; index: number }[] = [];
|
|
66
|
+
let match;
|
|
67
|
+
|
|
68
|
+
openingTagRegex.lastIndex = 0;
|
|
69
|
+
while ((match = openingTagRegex.exec(text)) !== null) {
|
|
70
|
+
const tagName = match[1];
|
|
71
|
+
const attributes = match[2];
|
|
72
|
+
|
|
73
|
+
if (attributes.trim().endsWith('/')) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
openingTags.push({
|
|
78
|
+
name: tagName,
|
|
79
|
+
index: match.index,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (openingTags.length > 0) {
|
|
84
|
+
const lastTag = openingTags[openingTags.length - 1];
|
|
85
|
+
const tagName = lastTag.name;
|
|
86
|
+
const closingTag = `</swi-${tagName}>`;
|
|
87
|
+
|
|
88
|
+
const textAfterOpening = text.substring(lastTag.index);
|
|
89
|
+
if (!textAfterOpening.includes(closingTag)) {
|
|
90
|
+
return text + closingTag;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return text;
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Element } from 'hast';
|
|
2
|
+
import type { ComponentType } from 'react';
|
|
3
|
+
import type { StreamdownProps } from 'streamdown';
|
|
4
|
+
|
|
5
|
+
import type { SwiTagName } from '../../types';
|
|
6
|
+
|
|
7
|
+
export type MarkdownViewerComponents = StreamdownProps['components'];
|
|
8
|
+
|
|
9
|
+
export type CustomMarkdownViewerComponents = MarkdownViewerComponents &
|
|
10
|
+
Partial<Record<SwiTagName, ComponentType<{ node?: Element }>>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './new-chat-trigger';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
+
import { forwardRef, type ComponentProps, type ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useChatContext } from '@/contexts';
|
|
5
|
+
|
|
6
|
+
interface NewChatTriggerProps extends ComponentProps<'button'> {
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const NewChatTrigger = forwardRef<HTMLButtonElement, NewChatTriggerProps>(
|
|
12
|
+
({ asChild = false, children, onClick, ...rest }, ref) => {
|
|
13
|
+
const { goToNewChat } = useChatContext();
|
|
14
|
+
const Component = asChild ? Slot : 'button';
|
|
15
|
+
|
|
16
|
+
function handleClick(event: React.MouseEvent<HTMLButtonElement>) {
|
|
17
|
+
onClick?.(event);
|
|
18
|
+
goToNewChat();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Component ref={ref} data-testid="new-chat-trigger" onClick={handleClick} {...rest}>
|
|
23
|
+
{children}
|
|
24
|
+
</Component>
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
NewChatTrigger.displayName = 'NewChatTrigger';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EditorThemeClasses } from 'lexical';
|
|
2
|
+
|
|
3
|
+
export const defaultEditorTheme: EditorThemeClasses = {
|
|
4
|
+
paragraph: 'editor-paragraph',
|
|
5
|
+
text: {
|
|
6
|
+
bold: 'editor-text-bold',
|
|
7
|
+
italic: 'editor-text-italic',
|
|
8
|
+
underline: 'editor-text-underline',
|
|
9
|
+
},
|
|
10
|
+
} as const;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { $getSelection } from 'lexical';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
|
|
5
|
+
export function useRichTextAreaEditor() {
|
|
6
|
+
const [editor] = useLexicalComposerContext();
|
|
7
|
+
|
|
8
|
+
return editor;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useRichTextAreaSelectedText() {
|
|
12
|
+
const [editor] = useLexicalComposerContext();
|
|
13
|
+
|
|
14
|
+
return useCallback(() => {
|
|
15
|
+
let selectedText = '';
|
|
16
|
+
|
|
17
|
+
editor.getEditorState().read(() => {
|
|
18
|
+
const selection = $getSelection();
|
|
19
|
+
selectedText = selection?.getTextContent() ?? '';
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return selectedText;
|
|
23
|
+
}, [editor]);
|
|
24
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { $createListNode, $createListItemNode, ListNode, ListItemNode } from '@lexical/list';
|
|
2
|
+
import { $createHeadingNode, HeadingNode } from '@lexical/rich-text';
|
|
3
|
+
import { setNodeIndentFromDOM, isHTMLElement, $isTextNode } from 'lexical';
|
|
4
|
+
import type {
|
|
5
|
+
DOMConversionMap,
|
|
6
|
+
DOMConversionOutput,
|
|
7
|
+
DOMExportOutput,
|
|
8
|
+
DOMExportOutputMap,
|
|
9
|
+
LexicalEditor,
|
|
10
|
+
LexicalNode,
|
|
11
|
+
ElementNode,
|
|
12
|
+
} from 'lexical';
|
|
13
|
+
|
|
14
|
+
import { extractFontStyles } from './transformers';
|
|
15
|
+
|
|
16
|
+
function convertHeadingElement(element: HTMLElement): DOMConversionOutput | null {
|
|
17
|
+
const nodeName = element.nodeName.toLowerCase();
|
|
18
|
+
if (
|
|
19
|
+
nodeName !== 'h1' &&
|
|
20
|
+
nodeName !== 'h2' &&
|
|
21
|
+
nodeName !== 'h3' &&
|
|
22
|
+
nodeName !== 'h4' &&
|
|
23
|
+
nodeName !== 'h5' &&
|
|
24
|
+
nodeName !== 'h6'
|
|
25
|
+
) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const node = $createHeadingNode(nodeName);
|
|
29
|
+
const style = element.getAttribute('style') ?? '';
|
|
30
|
+
node.setStyle(style);
|
|
31
|
+
if (element.style) {
|
|
32
|
+
const align = element.style.textAlign;
|
|
33
|
+
if (
|
|
34
|
+
align === 'left' ||
|
|
35
|
+
align === 'right' ||
|
|
36
|
+
align === 'center' ||
|
|
37
|
+
align === 'justify' ||
|
|
38
|
+
align === 'start' ||
|
|
39
|
+
align === 'end'
|
|
40
|
+
) {
|
|
41
|
+
node.setFormat(align);
|
|
42
|
+
}
|
|
43
|
+
setNodeIndentFromDOM(element, node);
|
|
44
|
+
}
|
|
45
|
+
return { node };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isDomChecklist(domNode: HTMLElement): boolean {
|
|
49
|
+
if (
|
|
50
|
+
domNode.getAttribute('__lexicallisttype') === 'check' ||
|
|
51
|
+
domNode.classList.contains('contains-task-list')
|
|
52
|
+
) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
for (const child of domNode.childNodes) {
|
|
56
|
+
if (isHTMLElement(child) && child.hasAttribute('aria-checked')) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function convertListElement(domNode: HTMLElement): DOMConversionOutput | null {
|
|
64
|
+
const nodeName = domNode.nodeName.toLowerCase();
|
|
65
|
+
let node = null;
|
|
66
|
+
if (nodeName === 'ol') {
|
|
67
|
+
const start = (domNode as HTMLOListElement).start;
|
|
68
|
+
node = $createListNode('number', start);
|
|
69
|
+
} else if (nodeName === 'ul') {
|
|
70
|
+
if (isDomChecklist(domNode)) {
|
|
71
|
+
node = $createListNode('check');
|
|
72
|
+
} else {
|
|
73
|
+
node = $createListNode('bullet');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!node) return null;
|
|
77
|
+
const style = domNode.getAttribute('style') ?? '';
|
|
78
|
+
node.setStyle(style);
|
|
79
|
+
return { node };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function convertListItemElement(domNode: HTMLElement): DOMConversionOutput | null {
|
|
83
|
+
const isGitHubCheckList = domNode.classList.contains('task-list-item');
|
|
84
|
+
if (isGitHubCheckList) {
|
|
85
|
+
for (const child of domNode.children) {
|
|
86
|
+
if (child.tagName === 'INPUT') {
|
|
87
|
+
const input = child as HTMLInputElement;
|
|
88
|
+
const isCheckbox = input.getAttribute('type') === 'checkbox';
|
|
89
|
+
if (isCheckbox) {
|
|
90
|
+
const checked = input.hasAttribute('checked');
|
|
91
|
+
const node = $createListItemNode(checked);
|
|
92
|
+
const style = domNode.getAttribute('style') ?? '';
|
|
93
|
+
node.setStyle(style);
|
|
94
|
+
return { node };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const ariaCheckedAttr = domNode.getAttribute('aria-checked');
|
|
100
|
+
const checked =
|
|
101
|
+
ariaCheckedAttr === 'true' ? true : ariaCheckedAttr === 'false' ? false : undefined;
|
|
102
|
+
const node = $createListItemNode(checked);
|
|
103
|
+
const style = domNode.getAttribute('style') ?? '';
|
|
104
|
+
node.setStyle(style);
|
|
105
|
+
return { node };
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const IMPORT_PRIORITY = 4;
|
|
109
|
+
|
|
110
|
+
function convertSpanElementWithStyles(domNode: HTMLElement): DOMConversionOutput | null {
|
|
111
|
+
const styleAttr = domNode.getAttribute('style') ?? '';
|
|
112
|
+
const { color, fontSize, fontFamily } = extractFontStyles(styleAttr);
|
|
113
|
+
|
|
114
|
+
if (!color && !fontSize && !fontFamily) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const domStyle = domNode.style;
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
forChild: (lexicalNode) => {
|
|
122
|
+
if (!$isTextNode(lexicalNode)) return lexicalNode;
|
|
123
|
+
|
|
124
|
+
// Replicate Lexical's default text-format handling from applyTextFormatFromStyle
|
|
125
|
+
const fontWeight = domStyle.fontWeight;
|
|
126
|
+
const textDecoration = (domStyle.textDecoration || '').split(' ');
|
|
127
|
+
if ((fontWeight === '700' || fontWeight === 'bold') && !lexicalNode.hasFormat('bold')) {
|
|
128
|
+
lexicalNode.toggleFormat('bold');
|
|
129
|
+
}
|
|
130
|
+
if (textDecoration.includes('line-through') && !lexicalNode.hasFormat('strikethrough')) {
|
|
131
|
+
lexicalNode.toggleFormat('strikethrough');
|
|
132
|
+
}
|
|
133
|
+
if (domStyle.fontStyle === 'italic' && !lexicalNode.hasFormat('italic')) {
|
|
134
|
+
lexicalNode.toggleFormat('italic');
|
|
135
|
+
}
|
|
136
|
+
if (textDecoration.includes('underline') && !lexicalNode.hasFormat('underline')) {
|
|
137
|
+
lexicalNode.toggleFormat('underline');
|
|
138
|
+
}
|
|
139
|
+
if (domStyle.verticalAlign === 'sub' && !lexicalNode.hasFormat('subscript')) {
|
|
140
|
+
lexicalNode.toggleFormat('subscript');
|
|
141
|
+
}
|
|
142
|
+
if (domStyle.verticalAlign === 'super' && !lexicalNode.hasFormat('superscript')) {
|
|
143
|
+
lexicalNode.toggleFormat('superscript');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Apply inline CSS styles (color, font-size, font-family)
|
|
147
|
+
let styleStr = '';
|
|
148
|
+
if (fontSize) styleStr += `font-size: ${fontSize};`;
|
|
149
|
+
if (fontFamily) styleStr += `font-family: ${fontFamily};`;
|
|
150
|
+
if (color) styleStr += `color: ${color};`;
|
|
151
|
+
lexicalNode.setStyle(styleStr);
|
|
152
|
+
|
|
153
|
+
return lexicalNode;
|
|
154
|
+
},
|
|
155
|
+
node: null,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export const HTML_IMPORT_CONFIG: DOMConversionMap = {
|
|
160
|
+
h1: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
161
|
+
h2: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
162
|
+
h3: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
163
|
+
h4: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
164
|
+
h5: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
165
|
+
h6: () => ({ conversion: convertHeadingElement, priority: IMPORT_PRIORITY }),
|
|
166
|
+
ul: () => ({ conversion: convertListElement, priority: IMPORT_PRIORITY }),
|
|
167
|
+
ol: () => ({ conversion: convertListElement, priority: IMPORT_PRIORITY }),
|
|
168
|
+
li: () => ({ conversion: convertListItemElement, priority: IMPORT_PRIORITY }),
|
|
169
|
+
span: () => ({ conversion: convertSpanElementWithStyles, priority: IMPORT_PRIORITY }),
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
type NodeExportDOMFn = (editor: LexicalEditor) => DOMExportOutput;
|
|
173
|
+
|
|
174
|
+
function wrapExportWithStyle(OriginalClass: {
|
|
175
|
+
prototype: { exportDOM: NodeExportDOMFn };
|
|
176
|
+
}): (editor: LexicalEditor, target: LexicalNode) => DOMExportOutput {
|
|
177
|
+
return (editor: LexicalEditor, target: LexicalNode) => {
|
|
178
|
+
const result = OriginalClass.prototype.exportDOM.call(target, editor);
|
|
179
|
+
const elementNode = target as ElementNode;
|
|
180
|
+
const style = elementNode.getStyle();
|
|
181
|
+
if (result.element && style) {
|
|
182
|
+
(result.element as HTMLElement).setAttribute('style', style);
|
|
183
|
+
}
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export const HTML_EXPORT_CONFIG: DOMExportOutputMap = new Map<
|
|
189
|
+
unknown,
|
|
190
|
+
(editor: LexicalEditor, target: LexicalNode) => DOMExportOutput
|
|
191
|
+
>([
|
|
192
|
+
[HeadingNode, wrapExportWithStyle(HeadingNode)],
|
|
193
|
+
[ListNode, wrapExportWithStyle(ListNode)],
|
|
194
|
+
[ListItemNode, wrapExportWithStyle(ListItemNode)],
|
|
195
|
+
]) as DOMExportOutputMap;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RichTextArea } from './rich-text-area';
|
|
2
|
+
export type { RichTextAreaProps } from './rich-text-area';
|
|
3
|
+
export * from './plugins/image-drop-plugin';
|
|
4
|
+
export * from './plugins/html-paste-plugin';
|
|
5
|
+
export { useRichTextAreaEditor, useRichTextAreaSelectedText } from './hooks';
|
|
6
|
+
export * from './utils';
|