@peers-app/peers-ui 0.0.14
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/.github/README.md +52 -0
- package/.github/workflows/publish.yml +45 -0
- package/babel.config.js +7 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +54 -0
- package/dist/command-palette/command-palette-ui.d.ts +2 -0
- package/dist/command-palette/command-palette-ui.js +192 -0
- package/dist/command-palette/command-palette.d.ts +23 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +20 -0
- package/dist/components/group-switcher.d.ts +6 -0
- package/dist/components/group-switcher.js +301 -0
- package/dist/components/input-date.d.ts +7 -0
- package/dist/components/input-date.js +19 -0
- package/dist/components/input-datetime.d.ts +7 -0
- package/dist/components/input-datetime.js +35 -0
- package/dist/components/input-number.d.ts +9 -0
- package/dist/components/input-number.js +87 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +20 -0
- package/dist/components/io-schema-values.d.ts +15 -0
- package/dist/components/io-schema-values.js +105 -0
- package/dist/components/io-schema.d.ts +13 -0
- package/dist/components/io-schema.js +163 -0
- package/dist/components/lazy-list.d.ts +13 -0
- package/dist/components/lazy-list.js +91 -0
- package/dist/components/lazy-sortable-list.d.ts +29 -0
- package/dist/components/lazy-sortable-list.js +12 -0
- package/dist/components/left-bar.d.ts +3 -0
- package/dist/components/left-bar.js +130 -0
- package/dist/components/list-screen.d.ts +16 -0
- package/dist/components/list-screen.js +100 -0
- package/dist/components/loading-indicator.d.ts +2 -0
- package/dist/components/loading-indicator.js +12 -0
- package/dist/components/main-content-container.d.ts +2 -0
- package/dist/components/main-content-container.js +90 -0
- package/dist/components/markdown-editor/autolink-plugin.d.ts +2 -0
- package/dist/components/markdown-editor/autolink-plugin.js +29 -0
- package/dist/components/markdown-editor/editor-inline.d.ts +3 -0
- package/dist/components/markdown-editor/editor-inline.js +13 -0
- package/dist/components/markdown-editor/editor.d.ts +18 -0
- package/dist/components/markdown-editor/editor.js +143 -0
- package/dist/components/markdown-editor/markdown-plugin.d.ts +9 -0
- package/dist/components/markdown-editor/markdown-plugin.js +194 -0
- package/dist/components/markdown-editor/mention-node.d.ts +21 -0
- package/dist/components/markdown-editor/mention-node.js +160 -0
- package/dist/components/markdown-editor/mentions-plugin.d.ts +7 -0
- package/dist/components/markdown-editor/mentions-plugin.js +268 -0
- package/dist/components/markdown-editor/theme.d.ts +46 -0
- package/dist/components/markdown-editor/theme.js +48 -0
- package/dist/components/markdown-editor/toolbar.d.ts +10 -0
- package/dist/components/markdown-editor/toolbar.js +112 -0
- package/dist/components/markdown-with-mentions.d.ts +4 -0
- package/dist/components/markdown-with-mentions.js +140 -0
- package/dist/components/message-logs/message-logs.d.ts +6 -0
- package/dist/components/message-logs/message-logs.js +307 -0
- package/dist/components/messages/avatar.d.ts +10 -0
- package/dist/components/messages/avatar.js +65 -0
- package/dist/components/messages/channel-message-list.d.ts +14 -0
- package/dist/components/messages/channel-message-list.js +158 -0
- package/dist/components/messages/channel-view.d.ts +6 -0
- package/dist/components/messages/channel-view.js +82 -0
- package/dist/components/messages/message-compose.d.ts +11 -0
- package/dist/components/messages/message-compose.js +152 -0
- package/dist/components/messages/message-display.d.ts +10 -0
- package/dist/components/messages/message-display.js +152 -0
- package/dist/components/messages/thread-message-list.d.ts +11 -0
- package/dist/components/messages/thread-message-list.js +122 -0
- package/dist/components/messages/thread-view.d.ts +6 -0
- package/dist/components/messages/thread-view.js +174 -0
- package/dist/components/off-canvas.d.ts +13 -0
- package/dist/components/off-canvas.js +89 -0
- package/dist/components/router.d.ts +6 -0
- package/dist/components/router.js +240 -0
- package/dist/components/save-button.d.ts +13 -0
- package/dist/components/save-button.js +75 -0
- package/dist/components/sortable-list.d.ts +36 -0
- package/dist/components/sortable-list.js +77 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +69 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +6 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.js +13 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +20 -0
- package/dist/components/top-bar.d.ts +2 -0
- package/dist/components/top-bar.js +51 -0
- package/dist/components/typeahead/mentions-plugin.d.ts +7 -0
- package/dist/components/typeahead/mentions-plugin.js +203 -0
- package/dist/components/typeahead/typeahead-editor.d.ts +15 -0
- package/dist/components/typeahead/typeahead-editor.js +134 -0
- package/dist/components/typeahead/typeahead.d.ts +12 -0
- package/dist/components/typeahead/typeahead.js +94 -0
- package/dist/components/typeahead.d.ts +22 -0
- package/dist/components/typeahead.js +270 -0
- package/dist/globals.d.ts +29 -0
- package/dist/globals.js +148 -0
- package/dist/hooks.d.ts +34 -0
- package/dist/hooks.js +137 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/layout-vars.d.ts +6 -0
- package/dist/layout-vars.js +10 -0
- package/dist/mention-configs.d.ts +18 -0
- package/dist/mention-configs.js +149 -0
- package/dist/screens/assistants/assistant-config.d.ts +5 -0
- package/dist/screens/assistants/assistant-config.js +52 -0
- package/dist/screens/assistants/assistant-details.d.ts +4 -0
- package/dist/screens/assistants/assistant-details.js +85 -0
- package/dist/screens/assistants/assistant-info.d.ts +6 -0
- package/dist/screens/assistants/assistant-info.js +28 -0
- package/dist/screens/assistants/assistant-list.d.ts +2 -0
- package/dist/screens/assistants/assistant-list.js +114 -0
- package/dist/screens/assistants/assistant-tools.d.ts +5 -0
- package/dist/screens/assistants/assistant-tools.js +38 -0
- package/dist/screens/contacts/contact-details.d.ts +6 -0
- package/dist/screens/contacts/contact-details.js +100 -0
- package/dist/screens/contacts/contact-list.d.ts +2 -0
- package/dist/screens/contacts/contact-list.js +213 -0
- package/dist/screens/contacts/index.d.ts +4 -0
- package/dist/screens/contacts/index.js +21 -0
- package/dist/screens/events/cron.d.ts +3 -0
- package/dist/screens/events/cron.js +77 -0
- package/dist/screens/events/event-details.d.ts +6 -0
- package/dist/screens/events/event-details.js +112 -0
- package/dist/screens/events/event-handlers.d.ts +7 -0
- package/dist/screens/events/event-handlers.js +84 -0
- package/dist/screens/events/event-info.d.ts +5 -0
- package/dist/screens/events/event-info.js +19 -0
- package/dist/screens/events/event-list.d.ts +2 -0
- package/dist/screens/events/event-list.js +107 -0
- package/dist/screens/events/event-schedule.d.ts +5 -0
- package/dist/screens/events/event-schedule.js +124 -0
- package/dist/screens/groups/group-details.d.ts +6 -0
- package/dist/screens/groups/group-details.js +218 -0
- package/dist/screens/groups/group-list.d.ts +2 -0
- package/dist/screens/groups/group-list.js +275 -0
- package/dist/screens/groups/group-members.d.ts +8 -0
- package/dist/screens/groups/group-members.js +315 -0
- package/dist/screens/groups/index.d.ts +6 -0
- package/dist/screens/groups/index.js +23 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.js +84 -0
- package/dist/screens/knowledge/knowledge-frame-details.d.ts +8 -0
- package/dist/screens/knowledge/knowledge-frame-details.js +143 -0
- package/dist/screens/knowledge/knowledge-frame-list.d.ts +2 -0
- package/dist/screens/knowledge/knowledge-frame-list.js +45 -0
- package/dist/screens/knowledge/knowledge-value-details.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-value-details.js +150 -0
- package/dist/screens/knowledge/knowledge-value-list-item.d.ts +5 -0
- package/dist/screens/knowledge/knowledge-value-list-item.js +39 -0
- package/dist/screens/knowledge/knowledge-value-list.d.ts +3 -0
- package/dist/screens/knowledge/knowledge-value-list.js +123 -0
- package/dist/screens/packages/package-details.d.ts +6 -0
- package/dist/screens/packages/package-details.js +82 -0
- package/dist/screens/packages/package-info.d.ts +5 -0
- package/dist/screens/packages/package-info.js +42 -0
- package/dist/screens/packages/package-list.d.ts +2 -0
- package/dist/screens/packages/package-list.js +182 -0
- package/dist/screens/packages/package-new-local.d.ts +2 -0
- package/dist/screens/packages/package-new-local.js +82 -0
- package/dist/screens/peer-types/peer-type-details.d.ts +10 -0
- package/dist/screens/peer-types/peer-type-details.js +126 -0
- package/dist/screens/peer-types/peer-type-list.d.ts +2 -0
- package/dist/screens/peer-types/peer-type-list.js +57 -0
- package/dist/screens/predicates/predicate-details.d.ts +6 -0
- package/dist/screens/predicates/predicate-details.js +103 -0
- package/dist/screens/predicates/predicate-list.d.ts +2 -0
- package/dist/screens/predicates/predicate-list.js +46 -0
- package/dist/screens/profile.d.ts +2 -0
- package/dist/screens/profile.js +66 -0
- package/dist/screens/search/global-search.d.ts +2 -0
- package/dist/screens/search/global-search.js +186 -0
- package/dist/screens/settings/color-mode-dropdown.d.ts +6 -0
- package/dist/screens/settings/color-mode-dropdown.js +63 -0
- package/dist/screens/settings/settings-page.d.ts +2 -0
- package/dist/screens/settings/settings-page.js +49 -0
- package/dist/screens/setup-user.d.ts +2 -0
- package/dist/screens/setup-user.js +270 -0
- package/dist/screens/tools/tool-code.d.ts +5 -0
- package/dist/screens/tools/tool-code.js +32 -0
- package/dist/screens/tools/tool-details.d.ts +6 -0
- package/dist/screens/tools/tool-details.js +68 -0
- package/dist/screens/tools/tool-info.d.ts +5 -0
- package/dist/screens/tools/tool-info.js +74 -0
- package/dist/screens/tools/tool-list.d.ts +2 -0
- package/dist/screens/tools/tool-list.js +123 -0
- package/dist/screens/tools/tool-schema.d.ts +5 -0
- package/dist/screens/tools/tool-schema.js +30 -0
- package/dist/screens/tools/tool-test-details.d.ts +4 -0
- package/dist/screens/tools/tool-test-details.js +54 -0
- package/dist/screens/tools/tool-test-list.d.ts +4 -0
- package/dist/screens/tools/tool-test-list.js +82 -0
- package/dist/screens/variables/variable-details.d.ts +6 -0
- package/dist/screens/variables/variable-details.js +140 -0
- package/dist/screens/variables/variable-list.d.ts +2 -0
- package/dist/screens/variables/variable-list.js +58 -0
- package/dist/screens/workflows/workflow-details.d.ts +6 -0
- package/dist/screens/workflows/workflow-details.js +122 -0
- package/dist/screens/workflows/workflow-info.d.ts +5 -0
- package/dist/screens/workflows/workflow-info.js +18 -0
- package/dist/screens/workflows/workflow-instructions.d.ts +5 -0
- package/dist/screens/workflows/workflow-instructions.js +118 -0
- package/dist/screens/workflows/workflow-list.d.ts +2 -0
- package/dist/screens/workflows/workflow-list.js +109 -0
- package/dist/screens/workflows/workflow-subscriptions.d.ts +6 -0
- package/dist/screens/workflows/workflow-subscriptions.js +81 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +31 -0
- package/dist/system-apps/assistants.app.d.ts +2 -0
- package/dist/system-apps/assistants.app.js +8 -0
- package/dist/system-apps/contacts.app.d.ts +2 -0
- package/dist/system-apps/contacts.app.js +9 -0
- package/dist/system-apps/events.app.d.ts +2 -0
- package/dist/system-apps/events.app.js +8 -0
- package/dist/system-apps/groups.app.d.ts +2 -0
- package/dist/system-apps/groups.app.js +9 -0
- package/dist/system-apps/index.d.ts +19 -0
- package/dist/system-apps/index.js +90 -0
- package/dist/system-apps/knowledge-frames.app.d.ts +2 -0
- package/dist/system-apps/knowledge-frames.app.js +9 -0
- package/dist/system-apps/knowledge-values.app.d.ts +2 -0
- package/dist/system-apps/knowledge-values.app.js +9 -0
- package/dist/system-apps/packages.app.d.ts +2 -0
- package/dist/system-apps/packages.app.js +8 -0
- package/dist/system-apps/predicates.app.d.ts +2 -0
- package/dist/system-apps/predicates.app.js +8 -0
- package/dist/system-apps/profile.app.d.ts +2 -0
- package/dist/system-apps/profile.app.js +8 -0
- package/dist/system-apps/search.app.d.ts +2 -0
- package/dist/system-apps/search.app.js +9 -0
- package/dist/system-apps/settings.app.d.ts +2 -0
- package/dist/system-apps/settings.app.js +8 -0
- package/dist/system-apps/threads.app.d.ts +2 -0
- package/dist/system-apps/threads.app.js +8 -0
- package/dist/system-apps/tools.app.d.ts +2 -0
- package/dist/system-apps/tools.app.js +8 -0
- package/dist/system-apps/types.app.d.ts +2 -0
- package/dist/system-apps/types.app.js +8 -0
- package/dist/system-apps/variables.app.d.ts +2 -0
- package/dist/system-apps/variables.app.js +8 -0
- package/dist/system-apps/workflows.app.d.ts +2 -0
- package/dist/system-apps/workflows.app.js +8 -0
- package/dist/tabs-layout/tabs-layout.d.ts +5 -0
- package/dist/tabs-layout/tabs-layout.js +374 -0
- package/dist/tabs-layout/tabs-state.d.ts +26 -0
- package/dist/tabs-layout/tabs-state.js +239 -0
- package/dist/three-bar-layout/left-bar-content.d.ts +7 -0
- package/dist/three-bar-layout/left-bar-content.js +151 -0
- package/dist/three-bar-layout/right-bar-content.d.ts +2 -0
- package/dist/three-bar-layout/right-bar-content.js +64 -0
- package/dist/three-bar-layout/three-bar-layout.d.ts +5 -0
- package/dist/three-bar-layout/three-bar-layout.js +218 -0
- package/dist/ui-defaults/index.d.ts +2 -0
- package/dist/ui-defaults/index.js +4 -0
- package/dist/ui-defaults/list-screen.d.ts +6 -0
- package/dist/ui-defaults/list-screen.js +74 -0
- package/dist/ui-defaults/notes-editor.d.ts +7 -0
- package/dist/ui-defaults/notes-editor.js +41 -0
- package/dist/ui-router/routes-loader.d.ts +25 -0
- package/dist/ui-router/routes-loader.js +97 -0
- package/dist/ui-router/ui-loader.d.ts +18 -0
- package/dist/ui-router/ui-loader.js +481 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +250 -0
- package/docs/conversation-tab.md +201 -0
- package/docs/getting-started.md +284 -0
- package/docs/knowledge.md +187 -0
- package/docs/tabs-ui.md +696 -0
- package/docs/user-contacts-ui.md +384 -0
- package/jest.config.js +25 -0
- package/package.json +109 -0
- package/src/app.tsx +59 -0
- package/src/command-palette/command-palette-ui.tsx +264 -0
- package/src/command-palette/command-palette.ts +364 -0
- package/src/components/checkbox.tsx +22 -0
- package/src/components/group-switcher.tsx +469 -0
- package/src/components/input-date.tsx +28 -0
- package/src/components/input-datetime.tsx +41 -0
- package/src/components/input-number.tsx +67 -0
- package/src/components/input.tsx +22 -0
- package/src/components/io-schema-values.tsx +122 -0
- package/src/components/io-schema.tsx +234 -0
- package/src/components/lazy-list.tsx +98 -0
- package/src/components/lazy-sortable-list.tsx +51 -0
- package/src/components/left-bar.tsx +264 -0
- package/src/components/list-screen.tsx +105 -0
- package/src/components/loading-indicator.tsx +9 -0
- package/src/components/main-content-container.tsx +76 -0
- package/src/components/markdown-editor/autolink-plugin.tsx +36 -0
- package/src/components/markdown-editor/editor-inline.tsx +10 -0
- package/src/components/markdown-editor/editor.tsx +152 -0
- package/src/components/markdown-editor/markdown-plugin.tsx +224 -0
- package/src/components/markdown-editor/mention-node.ts +199 -0
- package/src/components/markdown-editor/mentions-plugin.tsx +356 -0
- package/src/components/markdown-editor/theme.ts +47 -0
- package/src/components/markdown-editor/toolbar.tsx +263 -0
- package/src/components/markdown-with-mentions.tsx +183 -0
- package/src/components/message-logs/message-logs.tsx +406 -0
- package/src/components/messages/avatar.tsx +95 -0
- package/src/components/messages/channel-message-list.tsx +177 -0
- package/src/components/messages/channel-view.tsx +74 -0
- package/src/components/messages/message-compose.tsx +162 -0
- package/src/components/messages/message-display.tsx +217 -0
- package/src/components/messages/thread-message-list.tsx +126 -0
- package/src/components/messages/thread-view.tsx +214 -0
- package/src/components/off-canvas.tsx +83 -0
- package/src/components/router.tsx +224 -0
- package/src/components/save-button.tsx +109 -0
- package/src/components/sortable-list.tsx +102 -0
- package/src/components/tabs.tsx +70 -0
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +13 -0
- package/src/components/tooltip.tsx +50 -0
- package/src/components/top-bar.tsx +119 -0
- package/src/components/typeahead/mentions-plugin.tsx +265 -0
- package/src/components/typeahead/typeahead-editor.tsx +140 -0
- package/src/components/typeahead/typeahead.tsx +77 -0
- package/src/components/typeahead.tsx +359 -0
- package/src/globals.tsx +162 -0
- package/src/hooks.ts +144 -0
- package/src/index.tsx +8 -0
- package/src/layout-vars.ts +8 -0
- package/src/mention-configs.ts +166 -0
- package/src/screens/assistants/assistant-config.tsx +80 -0
- package/src/screens/assistants/assistant-details.tsx +77 -0
- package/src/screens/assistants/assistant-info.tsx +45 -0
- package/src/screens/assistants/assistant-list.tsx +115 -0
- package/src/screens/assistants/assistant-tools.tsx +61 -0
- package/src/screens/contacts/contact-details.tsx +175 -0
- package/src/screens/contacts/contact-list.tsx +251 -0
- package/src/screens/contacts/index.ts +6 -0
- package/src/screens/events/cron.ts +74 -0
- package/src/screens/events/event-details.tsx +117 -0
- package/src/screens/events/event-handlers.tsx +61 -0
- package/src/screens/events/event-info.tsx +29 -0
- package/src/screens/events/event-list.tsx +104 -0
- package/src/screens/events/event-schedule.tsx +130 -0
- package/src/screens/groups/group-details.tsx +306 -0
- package/src/screens/groups/group-list.tsx +366 -0
- package/src/screens/groups/group-members.tsx +455 -0
- package/src/screens/groups/index.ts +9 -0
- package/src/screens/knowledge/knowledge-frame-details.bk.tsx +160 -0
- package/src/screens/knowledge/knowledge-frame-details.tsx +176 -0
- package/src/screens/knowledge/knowledge-frame-list.tsx +49 -0
- package/src/screens/knowledge/knowledge-value-details.tsx +181 -0
- package/src/screens/knowledge/knowledge-value-list-item.tsx +48 -0
- package/src/screens/knowledge/knowledge-value-list.tsx +131 -0
- package/src/screens/packages/package-details.tsx +117 -0
- package/src/screens/packages/package-info.tsx +83 -0
- package/src/screens/packages/package-list.tsx +191 -0
- package/src/screens/packages/package-new-local.tsx +93 -0
- package/src/screens/peer-types/peer-type-details.tsx +162 -0
- package/src/screens/peer-types/peer-type-list.tsx +74 -0
- package/src/screens/predicates/predicate-details.tsx +125 -0
- package/src/screens/predicates/predicate-list.tsx +50 -0
- package/src/screens/profile.tsx +68 -0
- package/src/screens/search/global-search.tsx +274 -0
- package/src/screens/settings/color-mode-dropdown.tsx +57 -0
- package/src/screens/settings/settings-page.tsx +76 -0
- package/src/screens/setup-user.tsx +367 -0
- package/src/screens/tools/tool-code.tsx +35 -0
- package/src/screens/tools/tool-details.tsx +101 -0
- package/src/screens/tools/tool-info.tsx +60 -0
- package/src/screens/tools/tool-list.tsx +121 -0
- package/src/screens/tools/tool-schema.tsx +42 -0
- package/src/screens/tools/tool-test-details.tsx +100 -0
- package/src/screens/tools/tool-test-list.tsx +74 -0
- package/src/screens/variables/variable-details.tsx +183 -0
- package/src/screens/variables/variable-list.tsx +74 -0
- package/src/screens/workflows/workflow-details.tsx +130 -0
- package/src/screens/workflows/workflow-info.tsx +29 -0
- package/src/screens/workflows/workflow-instructions.tsx +127 -0
- package/src/screens/workflows/workflow-list.tsx +107 -0
- package/src/screens/workflows/workflow-subscriptions.tsx +58 -0
- package/src/setupTests.ts +32 -0
- package/src/system-apps/assistants.app.ts +7 -0
- package/src/system-apps/contacts.app.ts +8 -0
- package/src/system-apps/events.app.ts +7 -0
- package/src/system-apps/groups.app.ts +8 -0
- package/src/system-apps/index.ts +79 -0
- package/src/system-apps/knowledge-frames.app.ts +8 -0
- package/src/system-apps/knowledge-values.app.ts +8 -0
- package/src/system-apps/packages.app.ts +7 -0
- package/src/system-apps/predicates.app.ts +7 -0
- package/src/system-apps/profile.app.ts +7 -0
- package/src/system-apps/search.app.ts +8 -0
- package/src/system-apps/settings.app.ts +7 -0
- package/src/system-apps/threads.app.ts +7 -0
- package/src/system-apps/tools.app.ts +7 -0
- package/src/system-apps/types.app.ts +7 -0
- package/src/system-apps/variables.app.ts +7 -0
- package/src/system-apps/workflows.app.ts +7 -0
- package/src/tabs-layout/tabs-layout.tsx +672 -0
- package/src/tabs-layout/tabs-state.ts +269 -0
- package/src/three-bar-layout/left-bar-content.tsx +202 -0
- package/src/three-bar-layout/right-bar-content.tsx +67 -0
- package/src/three-bar-layout/three-bar-layout.tsx +297 -0
- package/src/ui-defaults/index.ts +3 -0
- package/src/ui-defaults/list-screen.tsx +92 -0
- package/src/ui-defaults/notes-editor.tsx +51 -0
- package/src/ui-router/routes-loader.ts +98 -0
- package/src/ui-router/ui-loader.tsx +497 -0
- package/src/utils.ts +266 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import {
|
|
3
|
+
LexicalTypeaheadMenuPlugin,
|
|
4
|
+
MenuOption,
|
|
5
|
+
MenuTextMatch,
|
|
6
|
+
useBasicTypeaheadTriggerMatch,
|
|
7
|
+
} from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
8
|
+
import { IMentionData, observable, Observable } from "@peers-app/peers-sdk";
|
|
9
|
+
import { $getSelection, TextNode } from 'lexical';
|
|
10
|
+
import { sortBy, uniqBy } from 'lodash';
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
|
+
import * as ReactDOM from 'react-dom';
|
|
14
|
+
import { IMentionConfig } from '../../mention-configs';
|
|
15
|
+
import { $createMentionNode } from './mention-node';
|
|
16
|
+
|
|
17
|
+
const PUNCTUATION =
|
|
18
|
+
'\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
19
|
+
const NAME = '\\b[A-Z][^\\s' + PUNCTUATION + ']';
|
|
20
|
+
|
|
21
|
+
const DocumentMentionsRegex = {
|
|
22
|
+
NAME,
|
|
23
|
+
PUNCTUATION,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const PUNC = DocumentMentionsRegex.PUNCTUATION;
|
|
27
|
+
|
|
28
|
+
const TRIGGERS = ['@', '<'].join('');
|
|
29
|
+
|
|
30
|
+
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
31
|
+
const VALID_CHARS = '[^' + TRIGGERS + PUNC + '\\s]';
|
|
32
|
+
|
|
33
|
+
// Non-standard series of chars. Each series must be preceded and followed by
|
|
34
|
+
// a valid char.
|
|
35
|
+
const VALID_JOINS =
|
|
36
|
+
'(?:' +
|
|
37
|
+
'\\.[ |$]|' + // E.g. "r. " in "Mr. Smith"
|
|
38
|
+
' |' + // E.g. " " in "Josh Duck"
|
|
39
|
+
'[' +
|
|
40
|
+
PUNC +
|
|
41
|
+
']|' + // E.g. "-' in "Salier-Hellendag"
|
|
42
|
+
')';
|
|
43
|
+
|
|
44
|
+
const LENGTH_LIMIT = 75;
|
|
45
|
+
|
|
46
|
+
const AtSignMentionsRegex = new RegExp(
|
|
47
|
+
'(^|\\s|\\()(' +
|
|
48
|
+
'[' +
|
|
49
|
+
TRIGGERS +
|
|
50
|
+
']' +
|
|
51
|
+
'((?:' +
|
|
52
|
+
VALID_CHARS +
|
|
53
|
+
VALID_JOINS +
|
|
54
|
+
'){0,' +
|
|
55
|
+
LENGTH_LIMIT +
|
|
56
|
+
'})' +
|
|
57
|
+
')$',
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// 50 is the longest alias length limit.
|
|
61
|
+
const ALIAS_LENGTH_LIMIT = 50;
|
|
62
|
+
|
|
63
|
+
// Regex used to match alias.
|
|
64
|
+
const AtSignMentionsRegexAliasRegex = new RegExp(
|
|
65
|
+
'(^|\\s|\\()(' +
|
|
66
|
+
'[' +
|
|
67
|
+
TRIGGERS +
|
|
68
|
+
']' +
|
|
69
|
+
'((?:' +
|
|
70
|
+
VALID_CHARS +
|
|
71
|
+
'){0,' +
|
|
72
|
+
ALIAS_LENGTH_LIMIT +
|
|
73
|
+
'})' +
|
|
74
|
+
')$',
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// At most, 5 suggestions are shown in the popup.
|
|
78
|
+
const SUGGESTION_LIST_LENGTH_LIMIT = 10;
|
|
79
|
+
export const MENTIONS_MAX_RESULTS = 10;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
function useMentionLookupService(mentionString: string | null, mentionConfigs: IMentionConfig[] = []): IMentionData[] {
|
|
83
|
+
const [results, setResults] = useState<Array<IMentionData>>([]);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!mentionString) {
|
|
87
|
+
setResults([]);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
(async () => {
|
|
91
|
+
const prefix = mentionString[0];
|
|
92
|
+
mentionString = mentionString.slice(1);
|
|
93
|
+
// TODO simplify how users can include completed tasks in their search
|
|
94
|
+
let searchCompletedTasks = prefix === '$' && mentionString.startsWith('done');
|
|
95
|
+
if (searchCompletedTasks) {
|
|
96
|
+
mentionString = mentionString.slice(4);
|
|
97
|
+
}
|
|
98
|
+
let kind = '';
|
|
99
|
+
if (mentionString.includes(':')) {
|
|
100
|
+
const parts = mentionString.split(':');
|
|
101
|
+
kind = parts[0];
|
|
102
|
+
mentionString = parts[1] || '';
|
|
103
|
+
}
|
|
104
|
+
const config = mentionConfigs?.find(c => c.kind === kind);
|
|
105
|
+
if (config) {
|
|
106
|
+
const results = await config.query(mentionString);
|
|
107
|
+
setResults(results);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const results = await Promise.all(
|
|
111
|
+
mentionConfigs?.map(c => c.query(mentionString || '')),
|
|
112
|
+
);
|
|
113
|
+
let allResults = results.flat();
|
|
114
|
+
allResults = uniqBy(allResults, 'id');
|
|
115
|
+
let filteredResults = allResults;
|
|
116
|
+
if (prefix === '@') {
|
|
117
|
+
filteredResults = filteredResults.filter((result) => result.kind === 'user' || result.kind === 'assistant');
|
|
118
|
+
} else {
|
|
119
|
+
filteredResults = filteredResults.filter((result) => result.kind !== 'user' && result.kind !== 'assistant');
|
|
120
|
+
}
|
|
121
|
+
if (kind) {
|
|
122
|
+
filteredResults = allResults.filter((result) => result.kind.toLowerCase() === kind.toLowerCase());
|
|
123
|
+
} else if (!filteredResults.length) {
|
|
124
|
+
filteredResults = allResults;
|
|
125
|
+
}
|
|
126
|
+
filteredResults = sortBy(filteredResults, r => {
|
|
127
|
+
return r.name.toLowerCase().indexOf((mentionString!).toLowerCase());
|
|
128
|
+
});
|
|
129
|
+
filteredResults = filteredResults.slice(0, SUGGESTION_LIST_LENGTH_LIMIT);
|
|
130
|
+
setResults(filteredResults);
|
|
131
|
+
})();
|
|
132
|
+
}, [mentionString]);
|
|
133
|
+
|
|
134
|
+
return results;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function checkForAtSignMentions(
|
|
138
|
+
text: string,
|
|
139
|
+
minMatchLength: number,
|
|
140
|
+
): MenuTextMatch | null {
|
|
141
|
+
let match = AtSignMentionsRegex.exec(text);
|
|
142
|
+
|
|
143
|
+
if (match === null) {
|
|
144
|
+
match = AtSignMentionsRegexAliasRegex.exec(text);
|
|
145
|
+
}
|
|
146
|
+
if (match !== null) {
|
|
147
|
+
// The strategy ignores leading whitespace but we need to know it's
|
|
148
|
+
// length to add it to the leadOffset
|
|
149
|
+
const maybeLeadingWhitespace = match[1];
|
|
150
|
+
|
|
151
|
+
const matchingString = match[3];
|
|
152
|
+
if (matchingString.length >= minMatchLength) {
|
|
153
|
+
return {
|
|
154
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
155
|
+
matchingString: match[2],
|
|
156
|
+
replaceableString: match[2],
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function getPossibleQueryMatch(text: string): MenuTextMatch | null {
|
|
164
|
+
return checkForAtSignMentions(text, 1);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
class MentionTypeaheadOption extends MenuOption {
|
|
168
|
+
name: string;
|
|
169
|
+
picture: JSX.Element;
|
|
170
|
+
id: string;
|
|
171
|
+
userId?: string;
|
|
172
|
+
|
|
173
|
+
constructor(
|
|
174
|
+
public readonly data: IMentionData,
|
|
175
|
+
picture: JSX.Element
|
|
176
|
+
) {
|
|
177
|
+
super(data.name);
|
|
178
|
+
this.name = data.name;
|
|
179
|
+
this.picture = picture;
|
|
180
|
+
this.id = data.id;
|
|
181
|
+
// if (data.kind === 'assistant') {
|
|
182
|
+
// this.userId = data.userId;
|
|
183
|
+
// }
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function MentionsTypeaheadMenuItem({
|
|
188
|
+
index,
|
|
189
|
+
isSelected,
|
|
190
|
+
onClick,
|
|
191
|
+
onMouseEnter,
|
|
192
|
+
option,
|
|
193
|
+
}: {
|
|
194
|
+
index: number;
|
|
195
|
+
isSelected: boolean;
|
|
196
|
+
onClick: () => void;
|
|
197
|
+
onMouseEnter: () => void;
|
|
198
|
+
option: MentionTypeaheadOption;
|
|
199
|
+
}) {
|
|
200
|
+
let className = 'item';
|
|
201
|
+
if (isSelected) {
|
|
202
|
+
className += ' selected';
|
|
203
|
+
}
|
|
204
|
+
return (
|
|
205
|
+
<li
|
|
206
|
+
key={option.key}
|
|
207
|
+
tabIndex={-1}
|
|
208
|
+
className={className}
|
|
209
|
+
ref={option.setRefElement}
|
|
210
|
+
role="option"
|
|
211
|
+
aria-selected={isSelected}
|
|
212
|
+
id={'typeahead-item-' + index}
|
|
213
|
+
onMouseEnter={onMouseEnter}
|
|
214
|
+
onClick={onClick}
|
|
215
|
+
data-kind={option.data.kind}
|
|
216
|
+
data-id={option.id}
|
|
217
|
+
data-user-id={option.userId || undefined}
|
|
218
|
+
>
|
|
219
|
+
{option.picture}
|
|
220
|
+
<span className="text">{option.name}</span>
|
|
221
|
+
</li>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function MentionsPlugin(
|
|
226
|
+
props: {
|
|
227
|
+
mentionConfigs?: IMentionConfig[]
|
|
228
|
+
mentionsOpen?: Observable<boolean>
|
|
229
|
+
}
|
|
230
|
+
): JSX.Element | null {
|
|
231
|
+
const [editor] = useLexicalComposerContext();
|
|
232
|
+
|
|
233
|
+
const [queryString, setQueryString] = useState<string | null>(null);
|
|
234
|
+
const results = useMentionLookupService(queryString, props.mentionConfigs);
|
|
235
|
+
const [_mentionsOpen] = useState(() => observable(false));
|
|
236
|
+
|
|
237
|
+
if (props.mentionsOpen) {
|
|
238
|
+
const finalMentionsOpen = _mentionsOpen() && results.length > 0;
|
|
239
|
+
if (props.mentionsOpen() !== finalMentionsOpen) {
|
|
240
|
+
props.mentionsOpen(finalMentionsOpen);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const checkForSlashTriggerMatch = useBasicTypeaheadTriggerMatch('/', {
|
|
245
|
+
minLength: 0,
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const options = useMemo(
|
|
249
|
+
() =>
|
|
250
|
+
results
|
|
251
|
+
.map(
|
|
252
|
+
(result) => {
|
|
253
|
+
let picture = <i className="bi bi-question pe-1" />;
|
|
254
|
+
const config = props.mentionConfigs?.find(c => c.kind === result.kind);
|
|
255
|
+
if (config) {
|
|
256
|
+
if (config.picture) {
|
|
257
|
+
picture = config.picture(result);
|
|
258
|
+
} else {
|
|
259
|
+
picture = <i className={config.iconClass + ' pe-1'} />;
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
picture = <i className={'bi bi-question pe-1'} />;
|
|
263
|
+
}
|
|
264
|
+
return new MentionTypeaheadOption(result, picture);
|
|
265
|
+
}
|
|
266
|
+
)
|
|
267
|
+
.slice(0, SUGGESTION_LIST_LENGTH_LIMIT),
|
|
268
|
+
[results],
|
|
269
|
+
);
|
|
270
|
+
|
|
271
|
+
const onSelectOption = useCallback(
|
|
272
|
+
(
|
|
273
|
+
selectedOption: MentionTypeaheadOption,
|
|
274
|
+
nodeToReplace: TextNode | null,
|
|
275
|
+
closeMenu: () => void,
|
|
276
|
+
) => {
|
|
277
|
+
editor.update(() => {
|
|
278
|
+
const mentionNode = $createMentionNode(selectedOption.data);
|
|
279
|
+
if (nodeToReplace) {
|
|
280
|
+
nodeToReplace.replace(mentionNode);
|
|
281
|
+
}
|
|
282
|
+
mentionNode.selectNext(); // Move cursor to the position after the mention
|
|
283
|
+
const selection = $getSelection();
|
|
284
|
+
if (selection !== null) {
|
|
285
|
+
selection.insertText(' '); // Insert a space after the mention
|
|
286
|
+
}
|
|
287
|
+
closeMenu();
|
|
288
|
+
});
|
|
289
|
+
},
|
|
290
|
+
[editor],
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
const checkForMentionMatch = useCallback(
|
|
294
|
+
(text: string) => {
|
|
295
|
+
const slashMatch = checkForSlashTriggerMatch(text, editor);
|
|
296
|
+
if (slashMatch !== null) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
return getPossibleQueryMatch(text);
|
|
300
|
+
},
|
|
301
|
+
[checkForSlashTriggerMatch, editor],
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const popoverRef = React.useRef<HTMLDivElement>(null);
|
|
305
|
+
|
|
306
|
+
return (
|
|
307
|
+
<LexicalTypeaheadMenuPlugin<MentionTypeaheadOption>
|
|
308
|
+
onQueryChange={setQueryString}
|
|
309
|
+
onSelectOption={onSelectOption}
|
|
310
|
+
triggerFn={checkForMentionMatch}
|
|
311
|
+
options={options}
|
|
312
|
+
onOpen={() => _mentionsOpen(true)}
|
|
313
|
+
onClose={() => _mentionsOpen(false)}
|
|
314
|
+
menuRenderFn={(
|
|
315
|
+
anchorElementRef,
|
|
316
|
+
{ selectedIndex, selectOptionAndCleanUp, setHighlightedIndex },
|
|
317
|
+
) => {
|
|
318
|
+
if (!(anchorElementRef.current && results.length)) {
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// distance from the top of the viewport to the top of the anchor element
|
|
323
|
+
const anchorTop = anchorElementRef.current.getBoundingClientRect().top;
|
|
324
|
+
const viewportHeight = window.innerHeight;
|
|
325
|
+
|
|
326
|
+
let className = 'typeahead-popover mentions-menu';
|
|
327
|
+
if (anchorTop > (viewportHeight / 2)) {
|
|
328
|
+
className += ' mentions-menu-popup';
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
return ReactDOM.createPortal(
|
|
332
|
+
<div className={className}>
|
|
333
|
+
<ul>
|
|
334
|
+
{options.map((option, i: number) => (
|
|
335
|
+
<MentionsTypeaheadMenuItem
|
|
336
|
+
index={i}
|
|
337
|
+
isSelected={selectedIndex === i}
|
|
338
|
+
onClick={() => {
|
|
339
|
+
setHighlightedIndex(i);
|
|
340
|
+
selectOptionAndCleanUp(option);
|
|
341
|
+
}}
|
|
342
|
+
onMouseEnter={() => {
|
|
343
|
+
setHighlightedIndex(i);
|
|
344
|
+
}}
|
|
345
|
+
key={option.key}
|
|
346
|
+
option={option}
|
|
347
|
+
/>
|
|
348
|
+
))}
|
|
349
|
+
</ul>
|
|
350
|
+
</div>,
|
|
351
|
+
anchorElementRef.current,
|
|
352
|
+
);
|
|
353
|
+
}}
|
|
354
|
+
/>
|
|
355
|
+
);
|
|
356
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default {
|
|
9
|
+
code: 'editor-code',
|
|
10
|
+
heading: {
|
|
11
|
+
h1: 'editor-heading-h1',
|
|
12
|
+
h2: 'editor-heading-h2',
|
|
13
|
+
h3: 'editor-heading-h3',
|
|
14
|
+
h4: 'editor-heading-h4',
|
|
15
|
+
h5: 'editor-heading-h5',
|
|
16
|
+
},
|
|
17
|
+
image: 'editor-image',
|
|
18
|
+
link: 'editor-link',
|
|
19
|
+
list: {
|
|
20
|
+
listitem: 'editor-listitem',
|
|
21
|
+
nested: {
|
|
22
|
+
// listitem: 'editor-nested-listitem',
|
|
23
|
+
listitem: 'PlaygroundEditorTheme__nestedListItem',
|
|
24
|
+
},
|
|
25
|
+
ol: 'editor-list-ol',
|
|
26
|
+
ul: 'editor-list-ul',
|
|
27
|
+
checklist: 'PlaygroundEditorTheme__checklist',
|
|
28
|
+
listitemChecked: 'PlaygroundEditorTheme__listItemChecked',
|
|
29
|
+
listitemUnchecked: 'PlaygroundEditorTheme__listItemUnchecked',
|
|
30
|
+
|
|
31
|
+
},
|
|
32
|
+
ltr: 'ltr',
|
|
33
|
+
paragraph: 'editor-paragraph',
|
|
34
|
+
placeholder: 'editor-placeholder',
|
|
35
|
+
quote: 'editor-quote',
|
|
36
|
+
rtl: 'rtl',
|
|
37
|
+
text: {
|
|
38
|
+
bold: 'editor-text-bold',
|
|
39
|
+
code: 'editor-text-code',
|
|
40
|
+
hashtag: 'editor-text-hashtag',
|
|
41
|
+
italic: 'editor-text-italic',
|
|
42
|
+
overflowed: 'editor-text-overflowed',
|
|
43
|
+
strikethrough: 'editor-text-strikethrough',
|
|
44
|
+
underline: 'editor-text-underline',
|
|
45
|
+
underlineStrikethrough: 'editor-text-underlineStrikethrough',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
+
import { mergeRegister } from '@lexical/utils';
|
|
4
|
+
import {
|
|
5
|
+
$getSelection,
|
|
6
|
+
$isRangeSelection,
|
|
7
|
+
CAN_REDO_COMMAND,
|
|
8
|
+
CAN_UNDO_COMMAND,
|
|
9
|
+
FORMAT_TEXT_COMMAND,
|
|
10
|
+
REDO_COMMAND,
|
|
11
|
+
SELECTION_CHANGE_COMMAND,
|
|
12
|
+
UNDO_COMMAND,
|
|
13
|
+
} from 'lexical';
|
|
14
|
+
import {
|
|
15
|
+
INSERT_UNORDERED_LIST_COMMAND,
|
|
16
|
+
INSERT_ORDERED_LIST_COMMAND,
|
|
17
|
+
REMOVE_LIST_COMMAND,
|
|
18
|
+
INSERT_CHECK_LIST_COMMAND,
|
|
19
|
+
} from '@lexical/list';
|
|
20
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
21
|
+
|
|
22
|
+
const LowPriority = 1;
|
|
23
|
+
|
|
24
|
+
function Divider() {
|
|
25
|
+
return <span className='tool-bar-divider'></span>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface IToolbarControl {
|
|
29
|
+
iconClass: string;
|
|
30
|
+
onClick: () => any;
|
|
31
|
+
title?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IToolbarProps {
|
|
35
|
+
topRightControls?: IToolbarControl[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function ToolbarPlugin(props: IToolbarProps) {
|
|
39
|
+
const [editor] = useLexicalComposerContext();
|
|
40
|
+
const toolbarRef = useRef(null);
|
|
41
|
+
const [canUndo, setCanUndo] = useState(false);
|
|
42
|
+
const [canRedo, setCanRedo] = useState(false);
|
|
43
|
+
const [isBold, setIsBold] = useState(false);
|
|
44
|
+
const [isItalic, setIsItalic] = useState(false);
|
|
45
|
+
const [isUnderline, setIsUnderline] = useState(false);
|
|
46
|
+
const [isStrikethrough, setIsStrikethrough] = useState(false);
|
|
47
|
+
// New state for list types
|
|
48
|
+
const [isUnorderedList, setIsUnorderedList] = useState(false);
|
|
49
|
+
const [isOrderedList, setIsOrderedList] = useState(false);
|
|
50
|
+
const [isCheckList, setIsCheckList] = useState(false);
|
|
51
|
+
|
|
52
|
+
const $updateToolbar = useCallback(() => {
|
|
53
|
+
const selection = $getSelection();
|
|
54
|
+
if ($isRangeSelection(selection)) {
|
|
55
|
+
// Update text format
|
|
56
|
+
setIsBold(selection.hasFormat('bold'));
|
|
57
|
+
setIsItalic(selection.hasFormat('italic'));
|
|
58
|
+
setIsUnderline(selection.hasFormat('underline'));
|
|
59
|
+
setIsStrikethrough(selection.hasFormat('strikethrough'));
|
|
60
|
+
|
|
61
|
+
// Update list format
|
|
62
|
+
const anchorNode = selection.anchor.getNode();
|
|
63
|
+
const element = anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow();
|
|
64
|
+
const elementKey = element.getKey();
|
|
65
|
+
const elementDOM = editor.getElementByKey(elementKey);
|
|
66
|
+
if (elementDOM !== null) {
|
|
67
|
+
setIsUnorderedList(elementDOM.tagName === 'UL');
|
|
68
|
+
setIsOrderedList(elementDOM.tagName === 'OL');
|
|
69
|
+
setIsCheckList(elementDOM.tagName === 'UL' && elementDOM.classList.contains('PlaygroundEditorTheme__checklist'));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, [editor]);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
return mergeRegister(
|
|
76
|
+
editor.registerUpdateListener(({ editorState }) => {
|
|
77
|
+
editorState.read(() => {
|
|
78
|
+
$updateToolbar();
|
|
79
|
+
});
|
|
80
|
+
}),
|
|
81
|
+
editor.registerCommand(
|
|
82
|
+
SELECTION_CHANGE_COMMAND,
|
|
83
|
+
(_payload, _newEditor) => {
|
|
84
|
+
$updateToolbar();
|
|
85
|
+
return false;
|
|
86
|
+
},
|
|
87
|
+
LowPriority,
|
|
88
|
+
),
|
|
89
|
+
editor.registerCommand(
|
|
90
|
+
CAN_UNDO_COMMAND,
|
|
91
|
+
(payload) => {
|
|
92
|
+
setCanUndo(payload);
|
|
93
|
+
return false;
|
|
94
|
+
},
|
|
95
|
+
LowPriority,
|
|
96
|
+
),
|
|
97
|
+
editor.registerCommand(
|
|
98
|
+
CAN_REDO_COMMAND,
|
|
99
|
+
(payload) => {
|
|
100
|
+
setCanRedo(payload);
|
|
101
|
+
return false;
|
|
102
|
+
},
|
|
103
|
+
LowPriority,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
106
|
+
}, [editor, $updateToolbar]);
|
|
107
|
+
|
|
108
|
+
const insertUnorderedList = () => {
|
|
109
|
+
if (isUnorderedList) {
|
|
110
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
111
|
+
} else {
|
|
112
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const insertOrderedList = () => {
|
|
117
|
+
if (isOrderedList) {
|
|
118
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
119
|
+
} else {
|
|
120
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const insertCheckList = () => {
|
|
125
|
+
if (isCheckList) {
|
|
126
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
127
|
+
} else {
|
|
128
|
+
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div className="toolbar" ref={toolbarRef}>
|
|
134
|
+
{/* <button
|
|
135
|
+
disabled={!canUndo}
|
|
136
|
+
onClick={() => {
|
|
137
|
+
editor.dispatchCommand(UNDO_COMMAND, undefined);
|
|
138
|
+
}}
|
|
139
|
+
className="toolbar-item spaced"
|
|
140
|
+
aria-label="Undo">
|
|
141
|
+
<i className="bi bi-arrow-counterclockwise" />
|
|
142
|
+
</button>
|
|
143
|
+
<button
|
|
144
|
+
disabled={!canRedo}
|
|
145
|
+
onClick={() => {
|
|
146
|
+
editor.dispatchCommand(REDO_COMMAND, undefined);
|
|
147
|
+
}}
|
|
148
|
+
className="toolbar-item"
|
|
149
|
+
aria-label="Redo">
|
|
150
|
+
<i className="bi bi-arrow-clockwise" />
|
|
151
|
+
</button>
|
|
152
|
+
<Divider /> */}
|
|
153
|
+
<button
|
|
154
|
+
onClick={() => {
|
|
155
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold');
|
|
156
|
+
}}
|
|
157
|
+
tabIndex={-1}
|
|
158
|
+
className={'toolbar-item spaced ' + (isBold ? 'active' : '')}
|
|
159
|
+
aria-label="Format Bold">
|
|
160
|
+
<i className="bi bi-type-bold" />
|
|
161
|
+
</button>
|
|
162
|
+
<button
|
|
163
|
+
tabIndex={-1}
|
|
164
|
+
onClick={() => {
|
|
165
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic');
|
|
166
|
+
}}
|
|
167
|
+
className={'toolbar-item spaced ' + (isItalic ? 'active' : '')}
|
|
168
|
+
aria-label="Format Italics">
|
|
169
|
+
<i className="bi bi-type-italic" />
|
|
170
|
+
</button>
|
|
171
|
+
{/* <button
|
|
172
|
+
onClick={() => {
|
|
173
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline');
|
|
174
|
+
}}
|
|
175
|
+
className={'toolbar-item spaced ' + (isUnderline ? 'active' : '')}
|
|
176
|
+
aria-label="Format Underline">
|
|
177
|
+
<i className="bi bi-type-underline" />
|
|
178
|
+
</button> */}
|
|
179
|
+
<button
|
|
180
|
+
tabIndex={-1}
|
|
181
|
+
onClick={() => {
|
|
182
|
+
editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough');
|
|
183
|
+
}}
|
|
184
|
+
className={'toolbar-item spaced ' + (isStrikethrough ? 'active' : '')}
|
|
185
|
+
aria-label="Format Strikethrough">
|
|
186
|
+
<i className="bi bi-type-strikethrough" />
|
|
187
|
+
</button>
|
|
188
|
+
<Divider />
|
|
189
|
+
{/* <button
|
|
190
|
+
onClick={() => {
|
|
191
|
+
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left');
|
|
192
|
+
}}
|
|
193
|
+
className="toolbar-item spaced"
|
|
194
|
+
aria-label="Left Align">
|
|
195
|
+
<i className="bi bi-text-left" />
|
|
196
|
+
</button>
|
|
197
|
+
<button
|
|
198
|
+
onClick={() => {
|
|
199
|
+
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center');
|
|
200
|
+
}}
|
|
201
|
+
className="toolbar-item spaced"
|
|
202
|
+
aria-label="Center Align">
|
|
203
|
+
<i className="bi bi-text-center" />
|
|
204
|
+
</button>
|
|
205
|
+
<button
|
|
206
|
+
onClick={() => {
|
|
207
|
+
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right');
|
|
208
|
+
}}
|
|
209
|
+
className="toolbar-item spaced"
|
|
210
|
+
aria-label="Right Align">
|
|
211
|
+
<i className="bi bi-text-right" />
|
|
212
|
+
</button>
|
|
213
|
+
<button
|
|
214
|
+
onClick={() => {
|
|
215
|
+
editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify');
|
|
216
|
+
}}
|
|
217
|
+
className="toolbar-item"
|
|
218
|
+
aria-label="Justify Align">
|
|
219
|
+
<i className="bi bi-justify" />
|
|
220
|
+
</button>{' '} */}
|
|
221
|
+
{/* <Divider /> */}
|
|
222
|
+
<button
|
|
223
|
+
tabIndex={-1}
|
|
224
|
+
onClick={insertUnorderedList}
|
|
225
|
+
className={'toolbar-item spaced ' + (isUnorderedList ? 'active' : '')}
|
|
226
|
+
aria-label="Insert Unordered List">
|
|
227
|
+
<i className="bi bi-list-ul" />
|
|
228
|
+
</button>
|
|
229
|
+
<button
|
|
230
|
+
tabIndex={-1}
|
|
231
|
+
onClick={insertOrderedList}
|
|
232
|
+
className={'toolbar-item spaced ' + (isOrderedList ? 'active' : '')}
|
|
233
|
+
aria-label="Insert Ordered List">
|
|
234
|
+
<i className="bi bi-list-ol" />
|
|
235
|
+
</button>
|
|
236
|
+
<button
|
|
237
|
+
tabIndex={-1}
|
|
238
|
+
onClick={insertCheckList}
|
|
239
|
+
className={'toolbar-item spaced ' + (isCheckList ? 'active' : '')}
|
|
240
|
+
aria-label="Insert Check List">
|
|
241
|
+
<i className="bi bi-list-check" />
|
|
242
|
+
</button>
|
|
243
|
+
|
|
244
|
+
{(props.topRightControls?.length ?? 0) > 0 && (
|
|
245
|
+
<div className='float-end'>
|
|
246
|
+
{props.topRightControls?.map((control, i) => (
|
|
247
|
+
<button
|
|
248
|
+
key={i}
|
|
249
|
+
tabIndex={-1}
|
|
250
|
+
onClick={control.onClick}
|
|
251
|
+
className={'toolbar-item spaced active'}
|
|
252
|
+
aria-label="Insert Check List"
|
|
253
|
+
title={control.title}
|
|
254
|
+
>
|
|
255
|
+
<i className={control.iconClass} />
|
|
256
|
+
</button>
|
|
257
|
+
))}
|
|
258
|
+
</div>
|
|
259
|
+
)}
|
|
260
|
+
|
|
261
|
+
</div>
|
|
262
|
+
);
|
|
263
|
+
}
|