@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,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MentionNode = void 0;
|
|
4
|
+
exports.$createMentionNode = $createMentionNode;
|
|
5
|
+
exports.$isMentionNode = $isMentionNode;
|
|
6
|
+
const lexical_1 = require("lexical");
|
|
7
|
+
const globals_1 = require("../../globals");
|
|
8
|
+
const mention_configs_1 = require("../../mention-configs");
|
|
9
|
+
function $convertMentionElement(domNode) {
|
|
10
|
+
const mentionName = domNode.textContent?.substring(1);
|
|
11
|
+
const dataKind = domNode.getAttribute('data-kind') ?? '';
|
|
12
|
+
const dataId = domNode.getAttribute('data-id') ?? '';
|
|
13
|
+
const clickable = domNode.getAttribute('data-clickable');
|
|
14
|
+
if (mentionName && dataId) {
|
|
15
|
+
const data = {
|
|
16
|
+
kind: dataKind,
|
|
17
|
+
name: mentionName,
|
|
18
|
+
id: dataId,
|
|
19
|
+
clickable: clickable === 'true' ? true : clickable === 'false' ? false : undefined,
|
|
20
|
+
};
|
|
21
|
+
const node = $createMentionNode(data);
|
|
22
|
+
return {
|
|
23
|
+
node,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
class MentionNode extends lexical_1.TextNode {
|
|
29
|
+
data;
|
|
30
|
+
static getType() {
|
|
31
|
+
return 'mention';
|
|
32
|
+
}
|
|
33
|
+
static clone(node) {
|
|
34
|
+
return new MentionNode(node.data, node.__key);
|
|
35
|
+
}
|
|
36
|
+
static importJSON(serializedNode) {
|
|
37
|
+
const node = $createMentionNode(serializedNode.data);
|
|
38
|
+
// node.setTextContent('@' + serializedNode.text);
|
|
39
|
+
node.setTextContent(serializedNode.text);
|
|
40
|
+
node.setFormat(serializedNode.format);
|
|
41
|
+
node.setDetail(serializedNode.detail);
|
|
42
|
+
node.setMode(serializedNode.mode);
|
|
43
|
+
node.setStyle(serializedNode.style);
|
|
44
|
+
return node;
|
|
45
|
+
}
|
|
46
|
+
constructor(data, key) {
|
|
47
|
+
// const prefix = (data.kind === 'assistant' || data.kind === 'user') ? '@' : '$';
|
|
48
|
+
const prefix = data.kind === 'user' ? '@' : '';
|
|
49
|
+
super(prefix + data.name, key);
|
|
50
|
+
this.data = data;
|
|
51
|
+
}
|
|
52
|
+
exportJSON() {
|
|
53
|
+
return {
|
|
54
|
+
...super.exportJSON(),
|
|
55
|
+
type: 'mention',
|
|
56
|
+
version: 1,
|
|
57
|
+
data: this.data,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
createDOM(config) {
|
|
61
|
+
const dom = super.createDOM(config);
|
|
62
|
+
const kind = this.data.kind;
|
|
63
|
+
const mentionConfig = mention_configs_1.mentionConfigs.find(c => c.kind === kind);
|
|
64
|
+
if (mentionConfig) {
|
|
65
|
+
dom.className = mentionConfig.styleClass || 'mention-default-default';
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
dom.className = `mention-${this.data.kind}`;
|
|
69
|
+
}
|
|
70
|
+
dom.textContent = this.__text;
|
|
71
|
+
dom.setAttribute('data-kind', this.data.kind);
|
|
72
|
+
dom.setAttribute('data-id', this.data.id);
|
|
73
|
+
dom.setAttribute('data-clickable', this.data.clickable === undefined ? '' : String(this.data.clickable));
|
|
74
|
+
// currently ignoring `clickable` attribute
|
|
75
|
+
// if (this.data.clickable !== false) {...
|
|
76
|
+
const onClick = mentionConfig?.onClick;
|
|
77
|
+
dom.style.cursor = 'pointer';
|
|
78
|
+
dom.addEventListener('click', () => {
|
|
79
|
+
if (onClick) {
|
|
80
|
+
onClick(this.data);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const id = this.data.id;
|
|
84
|
+
const href = `#${kind}s/${id}`;
|
|
85
|
+
(0, globals_1.mainContentPath)(href);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
if (mentionConfig && kind !== 'user') {
|
|
89
|
+
const iconSpan = document.createElement('i');
|
|
90
|
+
iconSpan.className = 'pe-1 ' + mentionConfig.iconClass;
|
|
91
|
+
dom.prepend(iconSpan);
|
|
92
|
+
return dom;
|
|
93
|
+
}
|
|
94
|
+
// else if (kind === 'task') {
|
|
95
|
+
// const ckbx = document.createElement('input');
|
|
96
|
+
// ckbx.type = 'checkbox';
|
|
97
|
+
// ckbx.className = 'me-1';
|
|
98
|
+
// const taskId = this.data.id;
|
|
99
|
+
// Tasks().get(taskId).then(task => {
|
|
100
|
+
// if (!task) return;
|
|
101
|
+
// ckbx.checked = !!task.completeDT;
|
|
102
|
+
// ckbx.addEventListener('change', () => {
|
|
103
|
+
// task.completeDT = ckbx.checked ? new Date() : undefined;
|
|
104
|
+
// Tasks().update(task);
|
|
105
|
+
// });
|
|
106
|
+
// });
|
|
107
|
+
// const sub = Tasks().dataChanged.subscribe(evt => {
|
|
108
|
+
// const task = evt.dataObject as ITask;
|
|
109
|
+
// if (!task || task.taskId !== taskId) return;
|
|
110
|
+
// if (!document.body.contains(ckbx)) {
|
|
111
|
+
// sub.unsubscribe();
|
|
112
|
+
// } else {
|
|
113
|
+
// ckbx.checked = !!task.completeDT;
|
|
114
|
+
// }
|
|
115
|
+
// });
|
|
116
|
+
// dom.prepend(ckbx);
|
|
117
|
+
// }
|
|
118
|
+
return dom;
|
|
119
|
+
}
|
|
120
|
+
exportDOM() {
|
|
121
|
+
const element = document.createElement('span');
|
|
122
|
+
element.setAttribute('data-lexical-mention', 'true');
|
|
123
|
+
element.textContent = this.__text;
|
|
124
|
+
element.setAttribute('data-kind', this.data.kind);
|
|
125
|
+
element.setAttribute('data-id', this.data.id);
|
|
126
|
+
element.setAttribute('data-clickable', this.data.clickable === undefined ? '' : String(this.data.clickable));
|
|
127
|
+
return { element };
|
|
128
|
+
}
|
|
129
|
+
static importDOM() {
|
|
130
|
+
return {
|
|
131
|
+
span: (domNode) => {
|
|
132
|
+
if (!domNode.hasAttribute('data-lexical-mention')) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
conversion: $convertMentionElement,
|
|
137
|
+
priority: 1,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
isTextEntity() {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
canInsertTextBefore() {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
canInsertTextAfter() {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.MentionNode = MentionNode;
|
|
153
|
+
function $createMentionNode(data) {
|
|
154
|
+
const mentionNode = new MentionNode(data);
|
|
155
|
+
mentionNode.setMode('segmented').toggleDirectionless();
|
|
156
|
+
return (0, lexical_1.$applyNodeReplacement)(mentionNode);
|
|
157
|
+
}
|
|
158
|
+
function $isMentionNode(node) {
|
|
159
|
+
return node instanceof MentionNode;
|
|
160
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import { IMentionConfig } from '../../mention-configs';
|
|
3
|
+
export declare const MENTIONS_MAX_RESULTS = 10;
|
|
4
|
+
export declare function MentionsPlugin(props: {
|
|
5
|
+
mentionConfigs?: IMentionConfig[];
|
|
6
|
+
mentionsOpen?: Observable<boolean>;
|
|
7
|
+
}): JSX.Element | null;
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.MENTIONS_MAX_RESULTS = void 0;
|
|
37
|
+
exports.MentionsPlugin = MentionsPlugin;
|
|
38
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
39
|
+
const LexicalTypeaheadMenuPlugin_1 = require("@lexical/react/LexicalTypeaheadMenuPlugin");
|
|
40
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
41
|
+
const lexical_1 = require("lexical");
|
|
42
|
+
const lodash_1 = require("lodash");
|
|
43
|
+
const React = __importStar(require("react"));
|
|
44
|
+
const react_1 = require("react");
|
|
45
|
+
const ReactDOM = __importStar(require("react-dom"));
|
|
46
|
+
const mention_node_1 = require("./mention-node");
|
|
47
|
+
const PUNCTUATION = '\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%\'"~=<>_:;';
|
|
48
|
+
const NAME = '\\b[A-Z][^\\s' + PUNCTUATION + ']';
|
|
49
|
+
const DocumentMentionsRegex = {
|
|
50
|
+
NAME,
|
|
51
|
+
PUNCTUATION,
|
|
52
|
+
};
|
|
53
|
+
const PUNC = DocumentMentionsRegex.PUNCTUATION;
|
|
54
|
+
const TRIGGERS = ['@', '<'].join('');
|
|
55
|
+
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
56
|
+
const VALID_CHARS = '[^' + TRIGGERS + PUNC + '\\s]';
|
|
57
|
+
// Non-standard series of chars. Each series must be preceded and followed by
|
|
58
|
+
// a valid char.
|
|
59
|
+
const VALID_JOINS = '(?:' +
|
|
60
|
+
'\\.[ |$]|' + // E.g. "r. " in "Mr. Smith"
|
|
61
|
+
' |' + // E.g. " " in "Josh Duck"
|
|
62
|
+
'[' +
|
|
63
|
+
PUNC +
|
|
64
|
+
']|' + // E.g. "-' in "Salier-Hellendag"
|
|
65
|
+
')';
|
|
66
|
+
const LENGTH_LIMIT = 75;
|
|
67
|
+
const AtSignMentionsRegex = new RegExp('(^|\\s|\\()(' +
|
|
68
|
+
'[' +
|
|
69
|
+
TRIGGERS +
|
|
70
|
+
']' +
|
|
71
|
+
'((?:' +
|
|
72
|
+
VALID_CHARS +
|
|
73
|
+
VALID_JOINS +
|
|
74
|
+
'){0,' +
|
|
75
|
+
LENGTH_LIMIT +
|
|
76
|
+
'})' +
|
|
77
|
+
')$');
|
|
78
|
+
// 50 is the longest alias length limit.
|
|
79
|
+
const ALIAS_LENGTH_LIMIT = 50;
|
|
80
|
+
// Regex used to match alias.
|
|
81
|
+
const AtSignMentionsRegexAliasRegex = new RegExp('(^|\\s|\\()(' +
|
|
82
|
+
'[' +
|
|
83
|
+
TRIGGERS +
|
|
84
|
+
']' +
|
|
85
|
+
'((?:' +
|
|
86
|
+
VALID_CHARS +
|
|
87
|
+
'){0,' +
|
|
88
|
+
ALIAS_LENGTH_LIMIT +
|
|
89
|
+
'})' +
|
|
90
|
+
')$');
|
|
91
|
+
// At most, 5 suggestions are shown in the popup.
|
|
92
|
+
const SUGGESTION_LIST_LENGTH_LIMIT = 10;
|
|
93
|
+
exports.MENTIONS_MAX_RESULTS = 10;
|
|
94
|
+
function useMentionLookupService(mentionString, mentionConfigs = []) {
|
|
95
|
+
const [results, setResults] = (0, react_1.useState)([]);
|
|
96
|
+
(0, react_1.useEffect)(() => {
|
|
97
|
+
if (!mentionString) {
|
|
98
|
+
setResults([]);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
(async () => {
|
|
102
|
+
const prefix = mentionString[0];
|
|
103
|
+
mentionString = mentionString.slice(1);
|
|
104
|
+
// TODO simplify how users can include completed tasks in their search
|
|
105
|
+
let searchCompletedTasks = prefix === '$' && mentionString.startsWith('done');
|
|
106
|
+
if (searchCompletedTasks) {
|
|
107
|
+
mentionString = mentionString.slice(4);
|
|
108
|
+
}
|
|
109
|
+
let kind = '';
|
|
110
|
+
if (mentionString.includes(':')) {
|
|
111
|
+
const parts = mentionString.split(':');
|
|
112
|
+
kind = parts[0];
|
|
113
|
+
mentionString = parts[1] || '';
|
|
114
|
+
}
|
|
115
|
+
const config = mentionConfigs?.find(c => c.kind === kind);
|
|
116
|
+
if (config) {
|
|
117
|
+
const results = await config.query(mentionString);
|
|
118
|
+
setResults(results);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const results = await Promise.all(mentionConfigs?.map(c => c.query(mentionString || '')));
|
|
122
|
+
let allResults = results.flat();
|
|
123
|
+
allResults = (0, lodash_1.uniqBy)(allResults, 'id');
|
|
124
|
+
let filteredResults = allResults;
|
|
125
|
+
if (prefix === '@') {
|
|
126
|
+
filteredResults = filteredResults.filter((result) => result.kind === 'user' || result.kind === 'assistant');
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
filteredResults = filteredResults.filter((result) => result.kind !== 'user' && result.kind !== 'assistant');
|
|
130
|
+
}
|
|
131
|
+
if (kind) {
|
|
132
|
+
filteredResults = allResults.filter((result) => result.kind.toLowerCase() === kind.toLowerCase());
|
|
133
|
+
}
|
|
134
|
+
else if (!filteredResults.length) {
|
|
135
|
+
filteredResults = allResults;
|
|
136
|
+
}
|
|
137
|
+
filteredResults = (0, lodash_1.sortBy)(filteredResults, r => {
|
|
138
|
+
return r.name.toLowerCase().indexOf((mentionString).toLowerCase());
|
|
139
|
+
});
|
|
140
|
+
filteredResults = filteredResults.slice(0, SUGGESTION_LIST_LENGTH_LIMIT);
|
|
141
|
+
setResults(filteredResults);
|
|
142
|
+
})();
|
|
143
|
+
}, [mentionString]);
|
|
144
|
+
return results;
|
|
145
|
+
}
|
|
146
|
+
function checkForAtSignMentions(text, minMatchLength) {
|
|
147
|
+
let match = AtSignMentionsRegex.exec(text);
|
|
148
|
+
if (match === null) {
|
|
149
|
+
match = AtSignMentionsRegexAliasRegex.exec(text);
|
|
150
|
+
}
|
|
151
|
+
if (match !== null) {
|
|
152
|
+
// The strategy ignores leading whitespace but we need to know it's
|
|
153
|
+
// length to add it to the leadOffset
|
|
154
|
+
const maybeLeadingWhitespace = match[1];
|
|
155
|
+
const matchingString = match[3];
|
|
156
|
+
if (matchingString.length >= minMatchLength) {
|
|
157
|
+
return {
|
|
158
|
+
leadOffset: match.index + maybeLeadingWhitespace.length,
|
|
159
|
+
matchingString: match[2],
|
|
160
|
+
replaceableString: match[2],
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
function getPossibleQueryMatch(text) {
|
|
167
|
+
return checkForAtSignMentions(text, 1);
|
|
168
|
+
}
|
|
169
|
+
class MentionTypeaheadOption extends LexicalTypeaheadMenuPlugin_1.MenuOption {
|
|
170
|
+
data;
|
|
171
|
+
name;
|
|
172
|
+
picture;
|
|
173
|
+
id;
|
|
174
|
+
userId;
|
|
175
|
+
constructor(data, picture) {
|
|
176
|
+
super(data.name);
|
|
177
|
+
this.data = data;
|
|
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
|
+
function MentionsTypeaheadMenuItem({ index, isSelected, onClick, onMouseEnter, option, }) {
|
|
187
|
+
let className = 'item';
|
|
188
|
+
if (isSelected) {
|
|
189
|
+
className += ' selected';
|
|
190
|
+
}
|
|
191
|
+
return (React.createElement("li", { key: option.key, tabIndex: -1, className: className, ref: option.setRefElement, role: "option", "aria-selected": isSelected, id: 'typeahead-item-' + index, onMouseEnter: onMouseEnter, onClick: onClick, "data-kind": option.data.kind, "data-id": option.id, "data-user-id": option.userId || undefined },
|
|
192
|
+
option.picture,
|
|
193
|
+
React.createElement("span", { className: "text" }, option.name)));
|
|
194
|
+
}
|
|
195
|
+
function MentionsPlugin(props) {
|
|
196
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
197
|
+
const [queryString, setQueryString] = (0, react_1.useState)(null);
|
|
198
|
+
const results = useMentionLookupService(queryString, props.mentionConfigs);
|
|
199
|
+
const [_mentionsOpen] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)(false));
|
|
200
|
+
if (props.mentionsOpen) {
|
|
201
|
+
const finalMentionsOpen = _mentionsOpen() && results.length > 0;
|
|
202
|
+
if (props.mentionsOpen() !== finalMentionsOpen) {
|
|
203
|
+
props.mentionsOpen(finalMentionsOpen);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const checkForSlashTriggerMatch = (0, LexicalTypeaheadMenuPlugin_1.useBasicTypeaheadTriggerMatch)('/', {
|
|
207
|
+
minLength: 0,
|
|
208
|
+
});
|
|
209
|
+
const options = (0, react_1.useMemo)(() => results
|
|
210
|
+
.map((result) => {
|
|
211
|
+
let picture = React.createElement("i", { className: "bi bi-question pe-1" });
|
|
212
|
+
const config = props.mentionConfigs?.find(c => c.kind === result.kind);
|
|
213
|
+
if (config) {
|
|
214
|
+
if (config.picture) {
|
|
215
|
+
picture = config.picture(result);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
picture = React.createElement("i", { className: config.iconClass + ' pe-1' });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
picture = React.createElement("i", { className: 'bi bi-question pe-1' });
|
|
223
|
+
}
|
|
224
|
+
return new MentionTypeaheadOption(result, picture);
|
|
225
|
+
})
|
|
226
|
+
.slice(0, SUGGESTION_LIST_LENGTH_LIMIT), [results]);
|
|
227
|
+
const onSelectOption = (0, react_1.useCallback)((selectedOption, nodeToReplace, closeMenu) => {
|
|
228
|
+
editor.update(() => {
|
|
229
|
+
const mentionNode = (0, mention_node_1.$createMentionNode)(selectedOption.data);
|
|
230
|
+
if (nodeToReplace) {
|
|
231
|
+
nodeToReplace.replace(mentionNode);
|
|
232
|
+
}
|
|
233
|
+
mentionNode.selectNext(); // Move cursor to the position after the mention
|
|
234
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
235
|
+
if (selection !== null) {
|
|
236
|
+
selection.insertText(' '); // Insert a space after the mention
|
|
237
|
+
}
|
|
238
|
+
closeMenu();
|
|
239
|
+
});
|
|
240
|
+
}, [editor]);
|
|
241
|
+
const checkForMentionMatch = (0, react_1.useCallback)((text) => {
|
|
242
|
+
const slashMatch = checkForSlashTriggerMatch(text, editor);
|
|
243
|
+
if (slashMatch !== null) {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
return getPossibleQueryMatch(text);
|
|
247
|
+
}, [checkForSlashTriggerMatch, editor]);
|
|
248
|
+
const popoverRef = React.useRef(null);
|
|
249
|
+
return (React.createElement(LexicalTypeaheadMenuPlugin_1.LexicalTypeaheadMenuPlugin, { onQueryChange: setQueryString, onSelectOption: onSelectOption, triggerFn: checkForMentionMatch, options: options, onOpen: () => _mentionsOpen(true), onClose: () => _mentionsOpen(false), menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
250
|
+
if (!(anchorElementRef.current && results.length)) {
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
// distance from the top of the viewport to the top of the anchor element
|
|
254
|
+
const anchorTop = anchorElementRef.current.getBoundingClientRect().top;
|
|
255
|
+
const viewportHeight = window.innerHeight;
|
|
256
|
+
let className = 'typeahead-popover mentions-menu';
|
|
257
|
+
if (anchorTop > (viewportHeight / 2)) {
|
|
258
|
+
className += ' mentions-menu-popup';
|
|
259
|
+
}
|
|
260
|
+
return ReactDOM.createPortal(React.createElement("div", { className: className },
|
|
261
|
+
React.createElement("ul", null, options.map((option, i) => (React.createElement(MentionsTypeaheadMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
262
|
+
setHighlightedIndex(i);
|
|
263
|
+
selectOptionAndCleanUp(option);
|
|
264
|
+
}, onMouseEnter: () => {
|
|
265
|
+
setHighlightedIndex(i);
|
|
266
|
+
}, key: option.key, option: option }))))), anchorElementRef.current);
|
|
267
|
+
} }));
|
|
268
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
declare const _default: {
|
|
9
|
+
code: string;
|
|
10
|
+
heading: {
|
|
11
|
+
h1: string;
|
|
12
|
+
h2: string;
|
|
13
|
+
h3: string;
|
|
14
|
+
h4: string;
|
|
15
|
+
h5: string;
|
|
16
|
+
};
|
|
17
|
+
image: string;
|
|
18
|
+
link: string;
|
|
19
|
+
list: {
|
|
20
|
+
listitem: string;
|
|
21
|
+
nested: {
|
|
22
|
+
listitem: string;
|
|
23
|
+
};
|
|
24
|
+
ol: string;
|
|
25
|
+
ul: string;
|
|
26
|
+
checklist: string;
|
|
27
|
+
listitemChecked: string;
|
|
28
|
+
listitemUnchecked: string;
|
|
29
|
+
};
|
|
30
|
+
ltr: string;
|
|
31
|
+
paragraph: string;
|
|
32
|
+
placeholder: string;
|
|
33
|
+
quote: string;
|
|
34
|
+
rtl: string;
|
|
35
|
+
text: {
|
|
36
|
+
bold: string;
|
|
37
|
+
code: string;
|
|
38
|
+
hashtag: string;
|
|
39
|
+
italic: string;
|
|
40
|
+
overflowed: string;
|
|
41
|
+
strikethrough: string;
|
|
42
|
+
underline: string;
|
|
43
|
+
underlineStrikethrough: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
exports.default = {
|
|
11
|
+
code: 'editor-code',
|
|
12
|
+
heading: {
|
|
13
|
+
h1: 'editor-heading-h1',
|
|
14
|
+
h2: 'editor-heading-h2',
|
|
15
|
+
h3: 'editor-heading-h3',
|
|
16
|
+
h4: 'editor-heading-h4',
|
|
17
|
+
h5: 'editor-heading-h5',
|
|
18
|
+
},
|
|
19
|
+
image: 'editor-image',
|
|
20
|
+
link: 'editor-link',
|
|
21
|
+
list: {
|
|
22
|
+
listitem: 'editor-listitem',
|
|
23
|
+
nested: {
|
|
24
|
+
// listitem: 'editor-nested-listitem',
|
|
25
|
+
listitem: 'PlaygroundEditorTheme__nestedListItem',
|
|
26
|
+
},
|
|
27
|
+
ol: 'editor-list-ol',
|
|
28
|
+
ul: 'editor-list-ul',
|
|
29
|
+
checklist: 'PlaygroundEditorTheme__checklist',
|
|
30
|
+
listitemChecked: 'PlaygroundEditorTheme__listItemChecked',
|
|
31
|
+
listitemUnchecked: 'PlaygroundEditorTheme__listItemUnchecked',
|
|
32
|
+
},
|
|
33
|
+
ltr: 'ltr',
|
|
34
|
+
paragraph: 'editor-paragraph',
|
|
35
|
+
placeholder: 'editor-placeholder',
|
|
36
|
+
quote: 'editor-quote',
|
|
37
|
+
rtl: 'rtl',
|
|
38
|
+
text: {
|
|
39
|
+
bold: 'editor-text-bold',
|
|
40
|
+
code: 'editor-text-code',
|
|
41
|
+
hashtag: 'editor-text-hashtag',
|
|
42
|
+
italic: 'editor-text-italic',
|
|
43
|
+
overflowed: 'editor-text-overflowed',
|
|
44
|
+
strikethrough: 'editor-text-strikethrough',
|
|
45
|
+
underline: 'editor-text-underline',
|
|
46
|
+
underlineStrikethrough: 'editor-text-underlineStrikethrough',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IToolbarControl {
|
|
3
|
+
iconClass: string;
|
|
4
|
+
onClick: () => any;
|
|
5
|
+
title?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface IToolbarProps {
|
|
8
|
+
topRightControls?: IToolbarControl[];
|
|
9
|
+
}
|
|
10
|
+
export declare function ToolbarPlugin(props: IToolbarProps): React.JSX.Element;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ToolbarPlugin = ToolbarPlugin;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
9
|
+
const utils_1 = require("@lexical/utils");
|
|
10
|
+
const lexical_1 = require("lexical");
|
|
11
|
+
const list_1 = require("@lexical/list");
|
|
12
|
+
const react_2 = require("react");
|
|
13
|
+
const LowPriority = 1;
|
|
14
|
+
function Divider() {
|
|
15
|
+
return react_1.default.createElement("span", { className: 'tool-bar-divider' });
|
|
16
|
+
}
|
|
17
|
+
function ToolbarPlugin(props) {
|
|
18
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
19
|
+
const toolbarRef = (0, react_2.useRef)(null);
|
|
20
|
+
const [canUndo, setCanUndo] = (0, react_2.useState)(false);
|
|
21
|
+
const [canRedo, setCanRedo] = (0, react_2.useState)(false);
|
|
22
|
+
const [isBold, setIsBold] = (0, react_2.useState)(false);
|
|
23
|
+
const [isItalic, setIsItalic] = (0, react_2.useState)(false);
|
|
24
|
+
const [isUnderline, setIsUnderline] = (0, react_2.useState)(false);
|
|
25
|
+
const [isStrikethrough, setIsStrikethrough] = (0, react_2.useState)(false);
|
|
26
|
+
// New state for list types
|
|
27
|
+
const [isUnorderedList, setIsUnorderedList] = (0, react_2.useState)(false);
|
|
28
|
+
const [isOrderedList, setIsOrderedList] = (0, react_2.useState)(false);
|
|
29
|
+
const [isCheckList, setIsCheckList] = (0, react_2.useState)(false);
|
|
30
|
+
const $updateToolbar = (0, react_2.useCallback)(() => {
|
|
31
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
32
|
+
if ((0, lexical_1.$isRangeSelection)(selection)) {
|
|
33
|
+
// Update text format
|
|
34
|
+
setIsBold(selection.hasFormat('bold'));
|
|
35
|
+
setIsItalic(selection.hasFormat('italic'));
|
|
36
|
+
setIsUnderline(selection.hasFormat('underline'));
|
|
37
|
+
setIsStrikethrough(selection.hasFormat('strikethrough'));
|
|
38
|
+
// Update list format
|
|
39
|
+
const anchorNode = selection.anchor.getNode();
|
|
40
|
+
const element = anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow();
|
|
41
|
+
const elementKey = element.getKey();
|
|
42
|
+
const elementDOM = editor.getElementByKey(elementKey);
|
|
43
|
+
if (elementDOM !== null) {
|
|
44
|
+
setIsUnorderedList(elementDOM.tagName === 'UL');
|
|
45
|
+
setIsOrderedList(elementDOM.tagName === 'OL');
|
|
46
|
+
setIsCheckList(elementDOM.tagName === 'UL' && elementDOM.classList.contains('PlaygroundEditorTheme__checklist'));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}, [editor]);
|
|
50
|
+
(0, react_2.useEffect)(() => {
|
|
51
|
+
return (0, utils_1.mergeRegister)(editor.registerUpdateListener(({ editorState }) => {
|
|
52
|
+
editorState.read(() => {
|
|
53
|
+
$updateToolbar();
|
|
54
|
+
});
|
|
55
|
+
}), editor.registerCommand(lexical_1.SELECTION_CHANGE_COMMAND, (_payload, _newEditor) => {
|
|
56
|
+
$updateToolbar();
|
|
57
|
+
return false;
|
|
58
|
+
}, LowPriority), editor.registerCommand(lexical_1.CAN_UNDO_COMMAND, (payload) => {
|
|
59
|
+
setCanUndo(payload);
|
|
60
|
+
return false;
|
|
61
|
+
}, LowPriority), editor.registerCommand(lexical_1.CAN_REDO_COMMAND, (payload) => {
|
|
62
|
+
setCanRedo(payload);
|
|
63
|
+
return false;
|
|
64
|
+
}, LowPriority));
|
|
65
|
+
}, [editor, $updateToolbar]);
|
|
66
|
+
const insertUnorderedList = () => {
|
|
67
|
+
if (isUnorderedList) {
|
|
68
|
+
editor.dispatchCommand(list_1.REMOVE_LIST_COMMAND, undefined);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
editor.dispatchCommand(list_1.INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const insertOrderedList = () => {
|
|
75
|
+
if (isOrderedList) {
|
|
76
|
+
editor.dispatchCommand(list_1.REMOVE_LIST_COMMAND, undefined);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
editor.dispatchCommand(list_1.INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const insertCheckList = () => {
|
|
83
|
+
if (isCheckList) {
|
|
84
|
+
editor.dispatchCommand(list_1.REMOVE_LIST_COMMAND, undefined);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
editor.dispatchCommand(list_1.INSERT_CHECK_LIST_COMMAND, undefined);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
return (react_1.default.createElement("div", { className: "toolbar", ref: toolbarRef },
|
|
91
|
+
react_1.default.createElement("button", { onClick: () => {
|
|
92
|
+
editor.dispatchCommand(lexical_1.FORMAT_TEXT_COMMAND, 'bold');
|
|
93
|
+
}, tabIndex: -1, className: 'toolbar-item spaced ' + (isBold ? 'active' : ''), "aria-label": "Format Bold" },
|
|
94
|
+
react_1.default.createElement("i", { className: "bi bi-type-bold" })),
|
|
95
|
+
react_1.default.createElement("button", { tabIndex: -1, onClick: () => {
|
|
96
|
+
editor.dispatchCommand(lexical_1.FORMAT_TEXT_COMMAND, 'italic');
|
|
97
|
+
}, className: 'toolbar-item spaced ' + (isItalic ? 'active' : ''), "aria-label": "Format Italics" },
|
|
98
|
+
react_1.default.createElement("i", { className: "bi bi-type-italic" })),
|
|
99
|
+
react_1.default.createElement("button", { tabIndex: -1, onClick: () => {
|
|
100
|
+
editor.dispatchCommand(lexical_1.FORMAT_TEXT_COMMAND, 'strikethrough');
|
|
101
|
+
}, className: 'toolbar-item spaced ' + (isStrikethrough ? 'active' : ''), "aria-label": "Format Strikethrough" },
|
|
102
|
+
react_1.default.createElement("i", { className: "bi bi-type-strikethrough" })),
|
|
103
|
+
react_1.default.createElement(Divider, null),
|
|
104
|
+
react_1.default.createElement("button", { tabIndex: -1, onClick: insertUnorderedList, className: 'toolbar-item spaced ' + (isUnorderedList ? 'active' : ''), "aria-label": "Insert Unordered List" },
|
|
105
|
+
react_1.default.createElement("i", { className: "bi bi-list-ul" })),
|
|
106
|
+
react_1.default.createElement("button", { tabIndex: -1, onClick: insertOrderedList, className: 'toolbar-item spaced ' + (isOrderedList ? 'active' : ''), "aria-label": "Insert Ordered List" },
|
|
107
|
+
react_1.default.createElement("i", { className: "bi bi-list-ol" })),
|
|
108
|
+
react_1.default.createElement("button", { tabIndex: -1, onClick: insertCheckList, className: 'toolbar-item spaced ' + (isCheckList ? 'active' : ''), "aria-label": "Insert Check List" },
|
|
109
|
+
react_1.default.createElement("i", { className: "bi bi-list-check" })),
|
|
110
|
+
(props.topRightControls?.length ?? 0) > 0 && (react_1.default.createElement("div", { className: 'float-end' }, props.topRightControls?.map((control, i) => (react_1.default.createElement("button", { key: i, tabIndex: -1, onClick: control.onClick, className: 'toolbar-item spaced active', "aria-label": "Insert Check List", title: control.title },
|
|
111
|
+
react_1.default.createElement("i", { className: control.iconClass }))))))));
|
|
112
|
+
}
|