@peers-app/peers-ui 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +8 -5
- package/babel.config.js +4 -4
- package/biome.json +191 -0
- package/dist/command-palette/command-palette-ui.d.ts +1 -2
- package/dist/command-palette/command-palette-ui.js +175 -244
- package/dist/command-palette/command-palette.js +65 -64
- package/dist/components/chat-overlay.d.ts +2 -2
- package/dist/components/chat-overlay.js +160 -217
- package/dist/components/checkbox.d.ts +5 -4
- package/dist/components/checkbox.js +4 -7
- package/dist/components/group-switcher.d.ts +1 -2
- package/dist/components/group-switcher.js +119 -159
- package/dist/components/input-date.d.ts +3 -3
- package/dist/components/input-date.js +6 -6
- package/dist/components/input-number.d.ts +7 -6
- package/dist/components/input-number.js +25 -20
- package/dist/components/input.d.ts +5 -4
- package/dist/components/input.js +4 -7
- package/dist/components/inverse-lazy-list.d.ts +3 -3
- package/dist/components/inverse-lazy-list.js +13 -47
- package/dist/components/io-schema-values.d.ts +5 -6
- package/dist/components/io-schema-values.js +28 -65
- package/dist/components/io-schema.d.ts +4 -5
- package/dist/components/io-schema.js +42 -79
- package/dist/components/lazy-list.d.ts +3 -3
- package/dist/components/lazy-list.js +38 -58
- package/dist/components/list-screen.d.ts +3 -8
- package/dist/components/list-screen.js +28 -23
- package/dist/components/loading-indicator.d.ts +1 -2
- package/dist/components/loading-indicator.js +2 -6
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/editor-inline.d.ts +2 -3
- package/dist/components/markdown-editor/editor-inline.js +2 -6
- package/dist/components/markdown-editor/editor.d.ts +6 -6
- package/dist/components/markdown-editor/editor.js +9 -19
- package/dist/components/markdown-editor/markdown-plugin.d.ts +1 -1
- package/dist/components/markdown-editor/markdown-plugin.js +20 -21
- package/dist/components/markdown-editor/mention-node.d.ts +2 -2
- package/dist/components/markdown-editor/mention-node.js +24 -24
- package/dist/components/markdown-editor/mentions-plugin.d.ts +2 -2
- package/dist/components/markdown-editor/mentions-plugin.js +61 -62
- package/dist/components/markdown-editor/theme.js +28 -28
- package/dist/components/markdown-editor/toolbar.d.ts +2 -3
- package/dist/components/markdown-editor/toolbar.js +32 -49
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +43 -43
- package/dist/components/message-logs/message-logs.d.ts +1 -2
- package/dist/components/message-logs/message-logs.js +91 -116
- package/dist/components/messages/avatar.d.ts +3 -4
- package/dist/components/messages/avatar.js +37 -46
- package/dist/components/messages/channel-message-list.d.ts +5 -6
- package/dist/components/messages/channel-message-list.js +34 -34
- package/dist/components/messages/channel-view.d.ts +1 -2
- package/dist/components/messages/channel-view.js +23 -57
- package/dist/components/messages/message-compose.d.ts +3 -4
- package/dist/components/messages/message-compose.js +27 -38
- package/dist/components/messages/message-display.d.ts +2 -3
- package/dist/components/messages/message-display.js +42 -95
- package/dist/components/messages/thread-message-list.d.ts +4 -5
- package/dist/components/messages/thread-message-list.js +29 -29
- package/dist/components/router.d.ts +1 -2
- package/dist/components/router.js +58 -66
- package/dist/components/save-button.d.ts +3 -3
- package/dist/components/save-button.js +23 -33
- package/dist/components/sortable-list.d.ts +11 -12
- package/dist/components/sortable-list.js +42 -22
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +16 -47
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/tooltip.js +4 -9
- package/dist/components/trust-level-badge.d.ts +2 -3
- package/dist/components/trust-level-badge.js +16 -16
- package/dist/components/trust-level-dropdown.d.ts +3 -4
- package/dist/components/trust-level-dropdown.js +32 -55
- package/dist/components/typeahead.d.ts +3 -3
- package/dist/components/typeahead.js +48 -89
- package/dist/components/voice-indicator.d.ts +2 -2
- package/dist/components/voice-indicator.js +93 -106
- package/dist/components/voice-subscribe-events.d.ts +32 -0
- package/dist/components/voice-subscribe-events.js +2 -0
- package/dist/globals.d.ts +3 -5
- package/dist/globals.js +22 -33
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +22 -12
- package/dist/hooks.test.js +129 -145
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/mention-configs.d.ts +2 -2
- package/dist/mention-configs.js +55 -42
- package/dist/screens/assistants/assistant-config.d.ts +2 -3
- package/dist/screens/assistants/assistant-config.js +9 -22
- package/dist/screens/assistants/assistant-details.d.ts +1 -2
- package/dist/screens/assistants/assistant-details.js +13 -28
- package/dist/screens/assistants/assistant-info.d.ts +2 -3
- package/dist/screens/assistants/assistant-info.js +3 -17
- package/dist/screens/assistants/assistant-list.d.ts +1 -2
- package/dist/screens/assistants/assistant-list.js +15 -56
- package/dist/screens/assistants/assistant-tools.d.ts +2 -3
- package/dist/screens/assistants/assistant-tools.js +10 -24
- package/dist/screens/console-logs/console-logs-list.d.ts +1 -2
- package/dist/screens/console-logs/console-logs-list.js +130 -134
- package/dist/screens/console-logs/log-display.d.ts +2 -3
- package/dist/screens/console-logs/log-display.js +40 -42
- package/dist/screens/console-logs/log-filters.d.ts +1 -2
- package/dist/screens/console-logs/log-filters.js +2 -24
- package/dist/screens/console-logs/mobile-log-card.d.ts +2 -3
- package/dist/screens/console-logs/mobile-log-card.js +64 -67
- package/dist/screens/console-logs/resizable-table-header.d.ts +1 -2
- package/dist/screens/console-logs/resizable-table-header.js +31 -67
- package/dist/screens/contacts/contact-details.d.ts +1 -2
- package/dist/screens/contacts/contact-details.js +16 -46
- package/dist/screens/contacts/contact-list.d.ts +1 -2
- package/dist/screens/contacts/contact-list.js +44 -103
- package/dist/screens/contacts/index.d.ts +4 -4
- package/dist/screens/contacts/index.js +1 -1
- package/dist/screens/contacts/user-connect.d.ts +1 -2
- package/dist/screens/contacts/user-connect.js +85 -186
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -2
- package/dist/screens/data-explorer/data-explorer.js +61 -181
- package/dist/screens/data-explorer/index.d.ts +2 -2
- package/dist/screens/data-explorer/query-executor.d.ts +1 -2
- package/dist/screens/data-explorer/query-executor.js +56 -166
- package/dist/screens/groups/group-details.d.ts +1 -2
- package/dist/screens/groups/group-details.js +27 -122
- package/dist/screens/groups/group-invite-listener.d.ts +2 -3
- package/dist/screens/groups/group-invite-listener.js +8 -104
- package/dist/screens/groups/group-list.d.ts +1 -2
- package/dist/screens/groups/group-list.js +56 -133
- package/dist/screens/groups/group-members.d.ts +2 -3
- package/dist/screens/groups/group-members.js +62 -132
- package/dist/screens/groups/index.d.ts +4 -4
- package/dist/screens/groups/index.js +1 -1
- package/dist/screens/join-group/index.d.ts +2 -2
- package/dist/screens/join-group/join-group.d.ts +1 -2
- package/dist/screens/join-group/join-group.js +9 -109
- package/dist/screens/network-viewer/connection-troubleshooter.d.ts +2 -3
- package/dist/screens/network-viewer/connection-troubleshooter.js +89 -193
- package/dist/screens/network-viewer/cpu-usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/cpu-usage-graph.js +60 -99
- package/dist/screens/network-viewer/device-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/device-details-modal.js +25 -177
- package/dist/screens/network-viewer/group-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/group-details-modal.js +31 -142
- package/dist/screens/network-viewer/index.d.ts +4 -4
- package/dist/screens/network-viewer/index.js +3 -3
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +22 -0
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +1 -2
- package/dist/screens/network-viewer/network-viewer.js +91 -296
- package/dist/screens/network-viewer/usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/usage-graph.js +78 -110
- package/dist/screens/packages/package-details.d.ts +1 -2
- package/dist/screens/packages/package-details.js +35 -41
- package/dist/screens/packages/package-info.d.ts +2 -2
- package/dist/screens/packages/package-info.js +33 -86
- package/dist/screens/packages/package-list.d.ts +1 -2
- package/dist/screens/packages/package-list.js +42 -106
- package/dist/screens/packages/package-new-local.d.ts +1 -2
- package/dist/screens/packages/package-new-local.js +13 -19
- package/dist/screens/packages/package-versions.d.ts +2 -3
- package/dist/screens/packages/package-versions.js +29 -96
- package/dist/screens/peer-types/peer-type-details.d.ts +3 -4
- package/dist/screens/peer-types/peer-type-details.js +26 -78
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -2
- package/dist/screens/peer-types/peer-type-list.js +13 -24
- package/dist/screens/search/global-search.d.ts +1 -2
- package/dist/screens/search/global-search.js +104 -182
- package/dist/screens/settings/color-mode-dropdown.d.ts +3 -4
- package/dist/screens/settings/color-mode-dropdown.js +18 -37
- package/dist/screens/settings/settings-page.d.ts +1 -1
- package/dist/screens/settings/settings-page.js +86 -213
- package/dist/screens/settings/voice-settings-agent.d.ts +1 -1
- package/dist/screens/settings/voice-settings-agent.js +7 -44
- package/dist/screens/settings/voice-settings-api-keys.d.ts +2 -2
- package/dist/screens/settings/voice-settings-api-keys.js +2 -29
- package/dist/screens/settings/voice-settings-output.d.ts +2 -2
- package/dist/screens/settings/voice-settings-output.js +2 -40
- package/dist/screens/settings/voice-settings-providers.d.ts +2 -2
- package/dist/screens/settings/voice-settings-providers.js +2 -19
- package/dist/screens/settings/voice-settings-types.d.ts +4 -4
- package/dist/screens/settings/voice-settings-types.js +31 -31
- package/dist/screens/settings/voice-settings-wake-word.d.ts +2 -2
- package/dist/screens/settings/voice-settings-wake-word.js +2 -33
- package/dist/screens/settings/voice-settings.d.ts +1 -1
- package/dist/screens/settings/voice-settings.js +35 -112
- package/dist/screens/setup-user.d.ts +1 -2
- package/dist/screens/setup-user.js +38 -116
- package/dist/screens/tools/tool-code.d.ts +2 -3
- package/dist/screens/tools/tool-code.js +9 -13
- package/dist/screens/tools/tool-details.d.ts +1 -2
- package/dist/screens/tools/tool-details.js +26 -39
- package/dist/screens/tools/tool-info.d.ts +2 -3
- package/dist/screens/tools/tool-info.js +9 -48
- package/dist/screens/tools/tool-list.d.ts +1 -2
- package/dist/screens/tools/tool-list.js +33 -65
- package/dist/screens/tools/tool-schema.d.ts +2 -3
- package/dist/screens/tools/tool-schema.js +2 -13
- package/dist/screens/tools/tool-test-details.d.ts +1 -2
- package/dist/screens/tools/tool-test-details.js +12 -28
- package/dist/screens/tools/tool-test-list.d.ts +1 -2
- package/dist/screens/tools/tool-test-list.js +17 -56
- package/dist/screens/variables/variable-details.d.ts +1 -2
- package/dist/screens/variables/variable-details.js +19 -86
- package/dist/screens/variables/variable-list.d.ts +1 -2
- package/dist/screens/variables/variable-list.js +16 -27
- package/dist/screens/welcome-modal.d.ts +1 -2
- package/dist/screens/welcome-modal.js +44 -111
- package/dist/screens/workflows/workflow-details.d.ts +1 -2
- package/dist/screens/workflows/workflow-details.js +17 -31
- package/dist/screens/workflows/workflow-info.d.ts +2 -3
- package/dist/screens/workflows/workflow-info.js +2 -9
- package/dist/screens/workflows/workflow-instructions.d.ts +2 -3
- package/dist/screens/workflows/workflow-instructions.js +23 -55
- package/dist/screens/workflows/workflow-list.d.ts +1 -2
- package/dist/screens/workflows/workflow-list.js +23 -62
- package/dist/setupTests.d.ts +1 -1
- package/dist/setupTests.js +10 -11
- package/dist/system-apps/assistants.app.d.ts +1 -1
- package/dist/system-apps/assistants.app.js +3 -3
- package/dist/system-apps/console-logs.app.d.ts +1 -1
- package/dist/system-apps/console-logs.app.js +3 -3
- package/dist/system-apps/contacts.app.d.ts +1 -1
- package/dist/system-apps/contacts.app.js +4 -4
- package/dist/system-apps/data-explorer.app.d.ts +1 -1
- package/dist/system-apps/data-explorer.app.js +4 -4
- package/dist/system-apps/groups.app.d.ts +1 -1
- package/dist/system-apps/groups.app.js +4 -4
- package/dist/system-apps/index.d.ts +17 -17
- package/dist/system-apps/index.js +52 -52
- package/dist/system-apps/join-group.app.d.ts +1 -1
- package/dist/system-apps/join-group.app.js +4 -4
- package/dist/system-apps/mobile-settings.app.d.ts +1 -1
- package/dist/system-apps/mobile-settings.app.js +3 -3
- package/dist/system-apps/network-viewer.app.d.ts +1 -1
- package/dist/system-apps/network-viewer.app.js +4 -4
- package/dist/system-apps/packages.app.d.ts +1 -1
- package/dist/system-apps/packages.app.js +3 -3
- package/dist/system-apps/search.app.d.ts +1 -1
- package/dist/system-apps/search.app.js +4 -4
- package/dist/system-apps/settings.app.d.ts +1 -1
- package/dist/system-apps/settings.app.js +3 -3
- package/dist/system-apps/threads.app.d.ts +1 -1
- package/dist/system-apps/threads.app.js +3 -3
- package/dist/system-apps/tools.app.d.ts +1 -1
- package/dist/system-apps/tools.app.js +3 -3
- package/dist/system-apps/types.app.d.ts +1 -1
- package/dist/system-apps/types.app.js +3 -3
- package/dist/system-apps/variables.app.d.ts +1 -1
- package/dist/system-apps/variables.app.js +3 -3
- package/dist/system-apps/workflows.app.d.ts +1 -1
- package/dist/system-apps/workflows.app.js +3 -3
- package/dist/tabs-layout/tabs-layout.d.ts +2 -3
- package/dist/tabs-layout/tabs-layout.js +215 -246
- package/dist/tabs-layout/tabs-state.d.ts +2 -2
- package/dist/tabs-layout/tabs-state.js +73 -61
- package/dist/ui-defaults/index.d.ts +2 -2
- package/dist/ui-defaults/list-screen.d.ts +2 -3
- package/dist/ui-defaults/list-screen.js +33 -37
- package/dist/ui-defaults/markdown-field.js +24 -56
- package/dist/ui-router/routes-loader.d.ts +1 -1
- package/dist/ui-router/routes-loader.js +17 -13
- package/dist/ui-router/ui-loader.d.ts +6 -6
- package/dist/ui-router/ui-loader.js +172 -268
- package/dist/utils.js +49 -39
- package/jest.config.js +16 -16
- package/package.json +16 -14
- package/src/command-palette/command-palette-ui.tsx +261 -237
- package/src/command-palette/command-palette.ts +81 -78
- package/src/components/chat-overlay.tsx +366 -261
- package/src/components/checkbox.tsx +15 -12
- package/src/components/group-switcher.tsx +150 -105
- package/src/components/input-date.tsx +17 -16
- package/src/components/input-number.tsx +47 -31
- package/src/components/input.tsx +15 -12
- package/src/components/inverse-lazy-list.tsx +14 -13
- package/src/components/io-schema-values.tsx +51 -69
- package/src/components/io-schema.tsx +94 -69
- package/src/components/lazy-list.tsx +51 -34
- package/src/components/list-screen.tsx +51 -35
- package/src/components/loading-indicator.tsx +2 -4
- package/src/components/markdown-editor/autolink-plugin.tsx +4 -11
- package/src/components/markdown-editor/editor-inline.tsx +3 -4
- package/src/components/markdown-editor/editor.tsx +53 -51
- package/src/components/markdown-editor/markdown-plugin.tsx +48 -40
- package/src/components/markdown-editor/mention-node.ts +39 -38
- package/src/components/markdown-editor/mentions-plugin.tsx +99 -101
- package/src/components/markdown-editor/theme.ts +28 -29
- package/src/components/markdown-editor/toolbar.tsx +53 -47
- package/src/components/markdown-with-mentions.tsx +56 -46
- package/src/components/message-logs/message-logs.tsx +225 -165
- package/src/components/messages/avatar.tsx +70 -52
- package/src/components/messages/channel-message-list.tsx +80 -68
- package/src/components/messages/channel-view.tsx +34 -33
- package/src/components/messages/message-compose.tsx +84 -67
- package/src/components/messages/message-display.tsx +103 -89
- package/src/components/messages/thread-message-list.tsx +53 -44
- package/src/components/router.tsx +42 -43
- package/src/components/save-button.tsx +43 -39
- package/src/components/sortable-list.tsx +77 -49
- package/src/components/tabs.tsx +31 -31
- package/src/components/tooltip.tsx +21 -28
- package/src/components/trust-level-badge.tsx +15 -11
- package/src/components/trust-level-dropdown.tsx +49 -19
- package/src/components/typeahead.tsx +57 -59
- package/src/components/voice-indicator.tsx +158 -141
- package/src/components/voice-subscribe-events.ts +20 -0
- package/src/globals.tsx +42 -40
- package/src/hooks.test.tsx +141 -134
- package/src/hooks.ts +80 -48
- package/src/index.tsx +17 -10
- package/src/mention-configs.ts +122 -68
- package/src/screens/assistants/assistant-config.tsx +28 -18
- package/src/screens/assistants/assistant-details.tsx +35 -36
- package/src/screens/assistants/assistant-info.tsx +16 -11
- package/src/screens/assistants/assistant-list.tsx +37 -34
- package/src/screens/assistants/assistant-tools.tsx +41 -20
- package/src/screens/console-logs/console-logs-list.tsx +173 -140
- package/src/screens/console-logs/log-display.tsx +65 -38
- package/src/screens/console-logs/log-filters.tsx +4 -3
- package/src/screens/console-logs/mobile-log-card.tsx +78 -71
- package/src/screens/console-logs/resizable-table-header.tsx +29 -21
- package/src/screens/contacts/contact-details.tsx +29 -30
- package/src/screens/contacts/contact-list.tsx +71 -60
- package/src/screens/contacts/index.ts +5 -5
- package/src/screens/contacts/user-connect.tsx +177 -171
- package/src/screens/data-explorer/data-explorer.tsx +134 -98
- package/src/screens/data-explorer/index.ts +2 -3
- package/src/screens/data-explorer/query-executor.tsx +90 -80
- package/src/screens/groups/group-details.tsx +120 -101
- package/src/screens/groups/group-invite-listener.tsx +34 -37
- package/src/screens/groups/group-list.tsx +119 -103
- package/src/screens/groups/group-members.tsx +225 -164
- package/src/screens/groups/index.ts +5 -6
- package/src/screens/join-group/index.ts +2 -2
- package/src/screens/join-group/join-group.tsx +41 -39
- package/src/screens/network-viewer/connection-troubleshooter.tsx +145 -104
- package/src/screens/network-viewer/cpu-usage-graph.tsx +39 -43
- package/src/screens/network-viewer/device-details-modal.tsx +46 -59
- package/src/screens/network-viewer/group-details-modal.tsx +68 -49
- package/src/screens/network-viewer/index.ts +4 -5
- package/src/screens/network-viewer/network-viewer-ipc.ts +23 -0
- package/src/screens/network-viewer/network-viewer.tsx +261 -236
- package/src/screens/network-viewer/usage-graph.tsx +57 -49
- package/src/screens/packages/package-details.tsx +43 -35
- package/src/screens/packages/package-info.tsx +107 -66
- package/src/screens/packages/package-list.tsx +175 -98
- package/src/screens/packages/package-new-local.tsx +28 -26
- package/src/screens/packages/package-versions.tsx +102 -77
- package/src/screens/peer-types/peer-type-details.tsx +60 -50
- package/src/screens/peer-types/peer-type-list.tsx +20 -30
- package/src/screens/search/global-search.tsx +153 -137
- package/src/screens/settings/color-mode-dropdown.tsx +52 -35
- package/src/screens/settings/settings-page.tsx +215 -141
- package/src/screens/settings/voice-settings-agent.tsx +13 -12
- package/src/screens/settings/voice-settings-api-keys.tsx +14 -12
- package/src/screens/settings/voice-settings-output.tsx +12 -11
- package/src/screens/settings/voice-settings-providers.tsx +7 -3
- package/src/screens/settings/voice-settings-types.ts +52 -49
- package/src/screens/settings/voice-settings-wake-word.tsx +25 -9
- package/src/screens/settings/voice-settings.tsx +66 -43
- package/src/screens/setup-user.tsx +88 -41
- package/src/screens/tools/tool-code.tsx +12 -17
- package/src/screens/tools/tool-details.tsx +28 -28
- package/src/screens/tools/tool-info.tsx +14 -19
- package/src/screens/tools/tool-list.tsx +58 -40
- package/src/screens/tools/tool-schema.tsx +16 -9
- package/src/screens/tools/tool-test-details.tsx +11 -22
- package/src/screens/tools/tool-test-list.tsx +29 -30
- package/src/screens/variables/variable-details.tsx +63 -51
- package/src/screens/variables/variable-list.tsx +29 -30
- package/src/screens/welcome-modal.tsx +68 -48
- package/src/screens/workflows/workflow-details.tsx +40 -30
- package/src/screens/workflows/workflow-info.tsx +4 -11
- package/src/screens/workflows/workflow-instructions.tsx +35 -28
- package/src/screens/workflows/workflow-list.tsx +50 -40
- package/src/setupTests.ts +14 -13
- package/src/system-apps/assistants.app.ts +5 -5
- package/src/system-apps/console-logs.app.ts +4 -4
- package/src/system-apps/contacts.app.ts +6 -6
- package/src/system-apps/data-explorer.app.ts +5 -5
- package/src/system-apps/groups.app.ts +6 -6
- package/src/system-apps/index.ts +49 -49
- package/src/system-apps/join-group.app.ts +5 -5
- package/src/system-apps/mobile-settings.app.ts +4 -5
- package/src/system-apps/network-viewer.app.ts +5 -5
- package/src/system-apps/packages.app.ts +5 -5
- package/src/system-apps/search.app.ts +6 -6
- package/src/system-apps/settings.app.ts +5 -5
- package/src/system-apps/threads.app.ts +5 -5
- package/src/system-apps/tools.app.ts +5 -5
- package/src/system-apps/types.app.ts +5 -5
- package/src/system-apps/variables.app.ts +5 -5
- package/src/system-apps/workflows.app.ts +5 -5
- package/src/tabs-layout/tabs-layout.tsx +345 -254
- package/src/tabs-layout/tabs-state.ts +100 -81
- package/src/ui-defaults/index.ts +2 -3
- package/src/ui-defaults/list-screen.tsx +45 -40
- package/src/ui-defaults/markdown-field.tsx +22 -26
- package/src/ui-router/routes-loader.ts +40 -24
- package/src/ui-router/ui-loader.tsx +312 -214
- package/src/utils.ts +68 -81
- package/tsconfig.json +5 -10
- package/dist/components/input-datetime.d.ts +0 -7
- package/dist/components/input-datetime.js +0 -35
- package/dist/components/lazy-sortable-list.d.ts +0 -29
- package/dist/components/lazy-sortable-list.js +0 -12
- package/dist/components/left-bar.d.ts +0 -5
- package/dist/components/left-bar.js +0 -207
- package/dist/components/main-content-container.d.ts +0 -2
- package/dist/components/main-content-container.js +0 -92
- package/dist/components/messages/thread-view.d.ts +0 -6
- package/dist/components/messages/thread-view.js +0 -174
- package/dist/components/off-canvas.d.ts +0 -13
- package/dist/components/off-canvas.js +0 -89
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +0 -6
- package/dist/components/text-list-editor.tsx/text-list-editor.js +0 -13
- package/dist/components/top-bar.d.ts +0 -2
- package/dist/components/top-bar.js +0 -51
- package/dist/components/typeahead/mentions-plugin.d.ts +0 -7
- package/dist/components/typeahead/mentions-plugin.js +0 -203
- package/dist/components/typeahead/typeahead-editor.d.ts +0 -15
- package/dist/components/typeahead/typeahead-editor.js +0 -134
- package/dist/components/typeahead/typeahead.d.ts +0 -12
- package/dist/components/typeahead/typeahead.js +0 -94
- package/dist/screens/profile.d.ts +0 -2
- package/dist/screens/profile.js +0 -76
- package/src/components/input-datetime.tsx +0 -41
- package/src/components/lazy-sortable-list.tsx +0 -51
- package/src/components/left-bar.tsx +0 -322
- package/src/components/main-content-container.tsx +0 -79
- package/src/components/messages/thread-view.tsx +0 -214
- package/src/components/off-canvas.tsx +0 -83
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +0 -13
- package/src/components/top-bar.tsx +0 -119
- package/src/components/typeahead/mentions-plugin.tsx +0 -265
- package/src/components/typeahead/typeahead-editor.tsx +0 -140
- package/src/components/typeahead/typeahead.tsx +0 -77
- package/src/screens/profile.tsx +0 -75
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IMentionData } from "@peers-app/peers-sdk";
|
|
1
2
|
import {
|
|
2
3
|
$applyNodeReplacement,
|
|
3
4
|
type DOMConversionMap,
|
|
@@ -9,10 +10,9 @@ import {
|
|
|
9
10
|
type SerializedTextNode,
|
|
10
11
|
type Spread,
|
|
11
12
|
TextNode,
|
|
12
|
-
} from
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { mentionConfigs } from '../../mention-configs';
|
|
13
|
+
} from "lexical";
|
|
14
|
+
import { mainContentPath } from "../../globals";
|
|
15
|
+
import { mentionConfigs } from "../../mention-configs";
|
|
16
16
|
|
|
17
17
|
export type SerializedMentionNode = Spread<
|
|
18
18
|
{
|
|
@@ -21,20 +21,18 @@ export type SerializedMentionNode = Spread<
|
|
|
21
21
|
SerializedTextNode
|
|
22
22
|
>;
|
|
23
23
|
|
|
24
|
-
function $convertMentionElement(
|
|
25
|
-
domNode: HTMLElement,
|
|
26
|
-
): DOMConversionOutput | null {
|
|
24
|
+
function $convertMentionElement(domNode: HTMLElement): DOMConversionOutput | null {
|
|
27
25
|
const mentionName = domNode.textContent?.substring(1);
|
|
28
|
-
const dataKind = domNode.getAttribute(
|
|
29
|
-
const dataId = domNode.getAttribute(
|
|
30
|
-
const clickable = domNode.getAttribute(
|
|
31
|
-
|
|
26
|
+
const dataKind = domNode.getAttribute("data-kind") ?? "";
|
|
27
|
+
const dataId = domNode.getAttribute("data-id") ?? "";
|
|
28
|
+
const clickable = domNode.getAttribute("data-clickable");
|
|
29
|
+
|
|
32
30
|
if (mentionName && dataId) {
|
|
33
31
|
const data: IMentionData = {
|
|
34
|
-
kind: dataKind
|
|
32
|
+
kind: dataKind,
|
|
35
33
|
name: mentionName,
|
|
36
34
|
id: dataId,
|
|
37
|
-
clickable: clickable ===
|
|
35
|
+
clickable: clickable === "true" ? true : clickable === "false" ? false : undefined,
|
|
38
36
|
};
|
|
39
37
|
const node = $createMentionNode(data);
|
|
40
38
|
return {
|
|
@@ -46,9 +44,8 @@ function $convertMentionElement(
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
export class MentionNode extends TextNode {
|
|
49
|
-
|
|
50
47
|
static getType(): string {
|
|
51
|
-
return
|
|
48
|
+
return "mention";
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
static clone(node: MentionNode): MentionNode {
|
|
@@ -67,17 +64,17 @@ export class MentionNode extends TextNode {
|
|
|
67
64
|
|
|
68
65
|
constructor(
|
|
69
66
|
public readonly data: IMentionData,
|
|
70
|
-
key?: NodeKey
|
|
67
|
+
key?: NodeKey,
|
|
71
68
|
) {
|
|
72
69
|
// const prefix = (data.kind === 'assistant' || data.kind === 'user') ? '@' : '$';
|
|
73
|
-
const prefix = data.kind ===
|
|
70
|
+
const prefix = data.kind === "user" ? "@" : "";
|
|
74
71
|
super(prefix + data.name, key);
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
exportJSON(): SerializedMentionNode {
|
|
78
75
|
return {
|
|
79
76
|
...super.exportJSON(),
|
|
80
|
-
type:
|
|
77
|
+
type: "mention",
|
|
81
78
|
version: 1,
|
|
82
79
|
data: this.data,
|
|
83
80
|
};
|
|
@@ -87,24 +84,27 @@ export class MentionNode extends TextNode {
|
|
|
87
84
|
const dom = super.createDOM(config);
|
|
88
85
|
|
|
89
86
|
const kind = this.data.kind;
|
|
90
|
-
const mentionConfig = mentionConfigs.find(c => c.kind === kind);
|
|
87
|
+
const mentionConfig = mentionConfigs.find((c) => c.kind === kind);
|
|
91
88
|
|
|
92
89
|
if (mentionConfig) {
|
|
93
|
-
dom.className = mentionConfig.styleClass ||
|
|
90
|
+
dom.className = mentionConfig.styleClass || "mention-default-default";
|
|
94
91
|
} else {
|
|
95
92
|
dom.className = `mention-${this.data.kind}`;
|
|
96
93
|
}
|
|
97
94
|
|
|
98
95
|
dom.textContent = this.__text;
|
|
99
|
-
dom.setAttribute(
|
|
100
|
-
dom.setAttribute(
|
|
101
|
-
dom.setAttribute(
|
|
96
|
+
dom.setAttribute("data-kind", this.data.kind);
|
|
97
|
+
dom.setAttribute("data-id", this.data.id);
|
|
98
|
+
dom.setAttribute(
|
|
99
|
+
"data-clickable",
|
|
100
|
+
this.data.clickable === undefined ? "" : String(this.data.clickable),
|
|
101
|
+
);
|
|
102
102
|
|
|
103
103
|
// currently ignoring `clickable` attribute
|
|
104
104
|
// if (this.data.clickable !== false) {...
|
|
105
105
|
const onClick = mentionConfig?.onClick;
|
|
106
|
-
dom.style.cursor =
|
|
107
|
-
dom.addEventListener(
|
|
106
|
+
dom.style.cursor = "pointer";
|
|
107
|
+
dom.addEventListener("click", () => {
|
|
108
108
|
if (onClick) {
|
|
109
109
|
onClick(this.data);
|
|
110
110
|
} else {
|
|
@@ -114,9 +114,9 @@ export class MentionNode extends TextNode {
|
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
116
|
|
|
117
|
-
if (mentionConfig && kind !==
|
|
118
|
-
const iconSpan = document.createElement(
|
|
119
|
-
iconSpan.className =
|
|
117
|
+
if (mentionConfig && kind !== "user") {
|
|
118
|
+
const iconSpan = document.createElement("i");
|
|
119
|
+
iconSpan.className = `pe-1 ${mentionConfig.iconClass}`;
|
|
120
120
|
dom.prepend(iconSpan);
|
|
121
121
|
return dom;
|
|
122
122
|
}
|
|
@@ -150,19 +150,22 @@ export class MentionNode extends TextNode {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
exportDOM(): DOMExportOutput {
|
|
153
|
-
const element = document.createElement(
|
|
154
|
-
element.setAttribute(
|
|
153
|
+
const element = document.createElement("span");
|
|
154
|
+
element.setAttribute("data-lexical-mention", "true");
|
|
155
155
|
element.textContent = this.__text;
|
|
156
|
-
element.setAttribute(
|
|
157
|
-
element.setAttribute(
|
|
158
|
-
element.setAttribute(
|
|
156
|
+
element.setAttribute("data-kind", this.data.kind);
|
|
157
|
+
element.setAttribute("data-id", this.data.id);
|
|
158
|
+
element.setAttribute(
|
|
159
|
+
"data-clickable",
|
|
160
|
+
this.data.clickable === undefined ? "" : String(this.data.clickable),
|
|
161
|
+
);
|
|
159
162
|
return { element };
|
|
160
163
|
}
|
|
161
164
|
|
|
162
165
|
static importDOM(): DOMConversionMap | null {
|
|
163
166
|
return {
|
|
164
167
|
span: (domNode: HTMLElement) => {
|
|
165
|
-
if (!domNode.hasAttribute(
|
|
168
|
+
if (!domNode.hasAttribute("data-lexical-mention")) {
|
|
166
169
|
return null;
|
|
167
170
|
}
|
|
168
171
|
return {
|
|
@@ -188,12 +191,10 @@ export class MentionNode extends TextNode {
|
|
|
188
191
|
|
|
189
192
|
export function $createMentionNode(data: IMentionData): MentionNode {
|
|
190
193
|
const mentionNode = new MentionNode(data);
|
|
191
|
-
mentionNode.setMode(
|
|
194
|
+
mentionNode.setMode("segmented").toggleDirectionless();
|
|
192
195
|
return $applyNodeReplacement(mentionNode);
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
export function $isMentionNode(
|
|
196
|
-
node: LexicalNode | null | undefined,
|
|
197
|
-
): node is MentionNode {
|
|
198
|
+
export function $isMentionNode(node: LexicalNode | null | undefined): node is MentionNode {
|
|
198
199
|
return node instanceof MentionNode;
|
|
199
200
|
}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { useLexicalComposerContext } from
|
|
1
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
2
2
|
import {
|
|
3
3
|
LexicalTypeaheadMenuPlugin,
|
|
4
4
|
MenuOption,
|
|
5
|
-
MenuTextMatch,
|
|
5
|
+
type MenuTextMatch,
|
|
6
6
|
useBasicTypeaheadTriggerMatch,
|
|
7
|
-
} from
|
|
8
|
-
import { IMentionData,
|
|
9
|
-
import { $getSelection, TextNode } from
|
|
10
|
-
import { sortBy, uniqBy } from
|
|
11
|
-
import * as React from
|
|
12
|
-
import { useCallback, useEffect, useMemo, useState } from
|
|
13
|
-
import * as ReactDOM from
|
|
14
|
-
import { IMentionConfig } from
|
|
15
|
-
import { $createMentionNode } from
|
|
16
|
-
|
|
17
|
-
const PUNCTUATION =
|
|
18
|
-
|
|
19
|
-
const NAME = '\\b[A-Z][^\\s' + PUNCTUATION + ']';
|
|
7
|
+
} from "@lexical/react/LexicalTypeaheadMenuPlugin";
|
|
8
|
+
import { type IMentionData, type Observable, observable } from "@peers-app/peers-sdk";
|
|
9
|
+
import { $getSelection, type 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 type { IMentionConfig } from "../../mention-configs";
|
|
15
|
+
import { $createMentionNode } from "./mention-node";
|
|
16
|
+
|
|
17
|
+
const PUNCTUATION = "\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'\"~=<>_:;";
|
|
18
|
+
const NAME = `\\b[A-Z][^\\s${PUNCTUATION}]`;
|
|
20
19
|
|
|
21
20
|
const DocumentMentionsRegex = {
|
|
22
21
|
NAME,
|
|
@@ -25,36 +24,36 @@ const DocumentMentionsRegex = {
|
|
|
25
24
|
|
|
26
25
|
const PUNC = DocumentMentionsRegex.PUNCTUATION;
|
|
27
26
|
|
|
28
|
-
const TRIGGERS = [
|
|
27
|
+
const TRIGGERS = ["@", "<"].join("");
|
|
29
28
|
|
|
30
29
|
// Chars we expect to see in a mention (non-space, non-punctuation).
|
|
31
|
-
const VALID_CHARS =
|
|
30
|
+
const VALID_CHARS = `[^${TRIGGERS}${PUNC}\\s]`;
|
|
32
31
|
|
|
33
32
|
// Non-standard series of chars. Each series must be preceded and followed by
|
|
34
33
|
// a valid char.
|
|
35
34
|
const VALID_JOINS =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
"(?:" +
|
|
36
|
+
"\\.[ |$]|" + // E.g. "r. " in "Mr. Smith"
|
|
37
|
+
" |" + // E.g. " " in "Josh Duck"
|
|
38
|
+
"[" +
|
|
40
39
|
PUNC +
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
"]|" + // E.g. "-' in "Salier-Hellendag"
|
|
41
|
+
")";
|
|
43
42
|
|
|
44
43
|
const LENGTH_LIMIT = 75;
|
|
45
44
|
|
|
46
45
|
const AtSignMentionsRegex = new RegExp(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
46
|
+
"(^|\\s|\\()(" +
|
|
47
|
+
"[" +
|
|
48
|
+
TRIGGERS +
|
|
49
|
+
"]" +
|
|
50
|
+
"((?:" +
|
|
51
|
+
VALID_CHARS +
|
|
52
|
+
VALID_JOINS +
|
|
53
|
+
"){0," +
|
|
54
|
+
LENGTH_LIMIT +
|
|
55
|
+
"})" +
|
|
56
|
+
")$",
|
|
58
57
|
);
|
|
59
58
|
|
|
60
59
|
// 50 is the longest alias length limit.
|
|
@@ -62,82 +61,85 @@ const ALIAS_LENGTH_LIMIT = 50;
|
|
|
62
61
|
|
|
63
62
|
// Regex used to match alias.
|
|
64
63
|
const AtSignMentionsRegexAliasRegex = new RegExp(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
"(^|\\s|\\()(" +
|
|
65
|
+
"[" +
|
|
66
|
+
TRIGGERS +
|
|
67
|
+
"]" +
|
|
68
|
+
"((?:" +
|
|
69
|
+
VALID_CHARS +
|
|
70
|
+
"){0," +
|
|
71
|
+
ALIAS_LENGTH_LIMIT +
|
|
72
|
+
"})" +
|
|
73
|
+
")$",
|
|
75
74
|
);
|
|
76
75
|
|
|
77
76
|
// At most, 5 suggestions are shown in the popup.
|
|
78
77
|
const SUGGESTION_LIST_LENGTH_LIMIT = 10;
|
|
79
78
|
export const MENTIONS_MAX_RESULTS = 10;
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
function useMentionLookupService(
|
|
81
|
+
mentionString: string | null,
|
|
82
|
+
mentionConfigs: IMentionConfig[] = [],
|
|
83
|
+
): IMentionData[] {
|
|
83
84
|
const [results, setResults] = useState<Array<IMentionData>>([]);
|
|
84
85
|
|
|
85
86
|
useEffect(() => {
|
|
86
87
|
if (!mentionString) {
|
|
87
88
|
setResults([]);
|
|
88
|
-
return;
|
|
89
|
+
return;
|
|
89
90
|
}
|
|
90
91
|
(async () => {
|
|
91
92
|
const prefix = mentionString[0];
|
|
92
93
|
mentionString = mentionString.slice(1);
|
|
93
94
|
// TODO simplify how users can include completed tasks in their search
|
|
94
|
-
|
|
95
|
+
const searchCompletedTasks = prefix === "$" && mentionString.startsWith("done");
|
|
95
96
|
if (searchCompletedTasks) {
|
|
96
97
|
mentionString = mentionString.slice(4);
|
|
97
98
|
}
|
|
98
|
-
let kind =
|
|
99
|
-
if (mentionString.includes(
|
|
100
|
-
const parts = mentionString.split(
|
|
99
|
+
let kind = "";
|
|
100
|
+
if (mentionString.includes(":")) {
|
|
101
|
+
const parts = mentionString.split(":");
|
|
101
102
|
kind = parts[0];
|
|
102
|
-
mentionString = parts[1] ||
|
|
103
|
+
mentionString = parts[1] || "";
|
|
103
104
|
}
|
|
104
|
-
const config = mentionConfigs?.find(c => c.kind === kind);
|
|
105
|
+
const config = mentionConfigs?.find((c) => c.kind === kind);
|
|
105
106
|
if (config) {
|
|
106
107
|
const results = await config.query(mentionString);
|
|
107
108
|
setResults(results);
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
const results = await Promise.all(
|
|
111
|
-
mentionConfigs?.map(c => c.query(mentionString || '')),
|
|
112
|
-
);
|
|
111
|
+
const results = await Promise.all(mentionConfigs?.map((c) => c.query(mentionString || "")));
|
|
113
112
|
let allResults = results.flat();
|
|
114
|
-
allResults = uniqBy(allResults,
|
|
113
|
+
allResults = uniqBy(allResults, "id");
|
|
115
114
|
let filteredResults = allResults;
|
|
116
|
-
if (prefix ===
|
|
117
|
-
filteredResults = filteredResults.filter(
|
|
115
|
+
if (prefix === "@") {
|
|
116
|
+
filteredResults = filteredResults.filter(
|
|
117
|
+
(result) => result.kind === "user" || result.kind === "assistant",
|
|
118
|
+
);
|
|
118
119
|
} else {
|
|
119
|
-
filteredResults = filteredResults.filter(
|
|
120
|
+
filteredResults = filteredResults.filter(
|
|
121
|
+
(result) => result.kind !== "user" && result.kind !== "assistant",
|
|
122
|
+
);
|
|
120
123
|
}
|
|
121
124
|
if (kind) {
|
|
122
|
-
filteredResults = allResults.filter(
|
|
125
|
+
filteredResults = allResults.filter(
|
|
126
|
+
(result) => result.kind.toLowerCase() === kind.toLowerCase(),
|
|
127
|
+
);
|
|
123
128
|
} else if (!filteredResults.length) {
|
|
124
129
|
filteredResults = allResults;
|
|
125
130
|
}
|
|
126
|
-
filteredResults = sortBy(filteredResults, r => {
|
|
127
|
-
return r.name.toLowerCase().indexOf((mentionString
|
|
131
|
+
filteredResults = sortBy(filteredResults, (r) => {
|
|
132
|
+
return r.name.toLowerCase().indexOf((mentionString ?? "").toLowerCase());
|
|
128
133
|
});
|
|
129
134
|
filteredResults = filteredResults.slice(0, SUGGESTION_LIST_LENGTH_LIMIT);
|
|
130
135
|
setResults(filteredResults);
|
|
131
136
|
})();
|
|
132
|
-
}, [mentionString]);
|
|
137
|
+
}, [mentionString, mentionConfigs?.find, mentionConfigs?.map]);
|
|
133
138
|
|
|
134
139
|
return results;
|
|
135
140
|
}
|
|
136
141
|
|
|
137
|
-
function checkForAtSignMentions(
|
|
138
|
-
text: string,
|
|
139
|
-
minMatchLength: number,
|
|
140
|
-
): MenuTextMatch | null {
|
|
142
|
+
function checkForAtSignMentions(text: string, minMatchLength: number): MenuTextMatch | null {
|
|
141
143
|
let match = AtSignMentionsRegex.exec(text);
|
|
142
144
|
|
|
143
145
|
if (match === null) {
|
|
@@ -172,7 +174,7 @@ class MentionTypeaheadOption extends MenuOption {
|
|
|
172
174
|
|
|
173
175
|
constructor(
|
|
174
176
|
public readonly data: IMentionData,
|
|
175
|
-
picture: JSX.Element
|
|
177
|
+
picture: JSX.Element,
|
|
176
178
|
) {
|
|
177
179
|
super(data.name);
|
|
178
180
|
this.name = data.name;
|
|
@@ -197,9 +199,9 @@ function MentionsTypeaheadMenuItem({
|
|
|
197
199
|
onMouseEnter: () => void;
|
|
198
200
|
option: MentionTypeaheadOption;
|
|
199
201
|
}) {
|
|
200
|
-
let className =
|
|
202
|
+
let className = "item";
|
|
201
203
|
if (isSelected) {
|
|
202
|
-
className +=
|
|
204
|
+
className += " selected";
|
|
203
205
|
}
|
|
204
206
|
return (
|
|
205
207
|
<li
|
|
@@ -207,9 +209,8 @@ function MentionsTypeaheadMenuItem({
|
|
|
207
209
|
tabIndex={-1}
|
|
208
210
|
className={className}
|
|
209
211
|
ref={option.setRefElement}
|
|
210
|
-
role="option"
|
|
211
212
|
aria-selected={isSelected}
|
|
212
|
-
id={
|
|
213
|
+
id={`typeahead-item-${index}`}
|
|
213
214
|
onMouseEnter={onMouseEnter}
|
|
214
215
|
onClick={onClick}
|
|
215
216
|
data-kind={option.data.kind}
|
|
@@ -222,17 +223,15 @@ function MentionsTypeaheadMenuItem({
|
|
|
222
223
|
);
|
|
223
224
|
}
|
|
224
225
|
|
|
225
|
-
export function MentionsPlugin(
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
): JSX.Element | null {
|
|
226
|
+
export function MentionsPlugin(props: {
|
|
227
|
+
mentionConfigs?: IMentionConfig[];
|
|
228
|
+
mentionsOpen?: Observable<boolean>;
|
|
229
|
+
}): JSX.Element | null {
|
|
231
230
|
const [editor] = useLexicalComposerContext();
|
|
232
231
|
|
|
233
232
|
const [queryString, setQueryString] = useState<string | null>(null);
|
|
234
233
|
const results = useMentionLookupService(queryString, props.mentionConfigs);
|
|
235
|
-
const [_mentionsOpen] = useState(() => observable(false));
|
|
234
|
+
const [_mentionsOpen] = useState(() => observable(false));
|
|
236
235
|
|
|
237
236
|
if (props.mentionsOpen) {
|
|
238
237
|
const finalMentionsOpen = _mentionsOpen() && results.length > 0;
|
|
@@ -241,31 +240,30 @@ export function MentionsPlugin(
|
|
|
241
240
|
}
|
|
242
241
|
}
|
|
243
242
|
|
|
244
|
-
const checkForSlashTriggerMatch = useBasicTypeaheadTriggerMatch(
|
|
243
|
+
const checkForSlashTriggerMatch = useBasicTypeaheadTriggerMatch("/", {
|
|
245
244
|
minLength: 0,
|
|
246
245
|
});
|
|
247
246
|
|
|
248
247
|
const options = useMemo(
|
|
249
248
|
() =>
|
|
250
249
|
results
|
|
251
|
-
.map(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
} else {
|
|
259
|
-
picture = <i className={config.iconClass + ' pe-1'} />;
|
|
260
|
-
}
|
|
250
|
+
.map((result) => {
|
|
251
|
+
const picKey = `mention-pic-${result.kind}-${result.id}`;
|
|
252
|
+
let picture = <i key={picKey} className="bi bi-question pe-1" />;
|
|
253
|
+
const config = props.mentionConfigs?.find((c) => c.kind === result.kind);
|
|
254
|
+
if (config) {
|
|
255
|
+
if (config.picture) {
|
|
256
|
+
picture = config.picture(result);
|
|
261
257
|
} else {
|
|
262
|
-
picture = <i className={
|
|
258
|
+
picture = <i key={picKey} className={`${config.iconClass} pe-1`} />;
|
|
263
259
|
}
|
|
264
|
-
|
|
260
|
+
} else {
|
|
261
|
+
picture = <i key={picKey} className={"bi bi-question pe-1"} />;
|
|
265
262
|
}
|
|
266
|
-
|
|
263
|
+
return new MentionTypeaheadOption(result, picture);
|
|
264
|
+
})
|
|
267
265
|
.slice(0, SUGGESTION_LIST_LENGTH_LIMIT),
|
|
268
|
-
[results],
|
|
266
|
+
[results, props.mentionConfigs?.find],
|
|
269
267
|
);
|
|
270
268
|
|
|
271
269
|
const onSelectOption = useCallback(
|
|
@@ -282,7 +280,7 @@ export function MentionsPlugin(
|
|
|
282
280
|
mentionNode.selectNext(); // Move cursor to the position after the mention
|
|
283
281
|
const selection = $getSelection();
|
|
284
282
|
if (selection !== null) {
|
|
285
|
-
selection.insertText(
|
|
283
|
+
selection.insertText(" "); // Insert a space after the mention
|
|
286
284
|
}
|
|
287
285
|
closeMenu();
|
|
288
286
|
});
|
|
@@ -301,7 +299,7 @@ export function MentionsPlugin(
|
|
|
301
299
|
[checkForSlashTriggerMatch, editor],
|
|
302
300
|
);
|
|
303
301
|
|
|
304
|
-
const
|
|
302
|
+
const _popoverRef = React.useRef<HTMLDivElement>(null);
|
|
305
303
|
|
|
306
304
|
return (
|
|
307
305
|
<LexicalTypeaheadMenuPlugin<MentionTypeaheadOption>
|
|
@@ -318,14 +316,14 @@ export function MentionsPlugin(
|
|
|
318
316
|
if (!(anchorElementRef.current && results.length)) {
|
|
319
317
|
return null;
|
|
320
318
|
}
|
|
321
|
-
|
|
319
|
+
|
|
322
320
|
// distance from the top of the viewport to the top of the anchor element
|
|
323
321
|
const anchorTop = anchorElementRef.current.getBoundingClientRect().top;
|
|
324
322
|
const viewportHeight = window.innerHeight;
|
|
325
323
|
|
|
326
|
-
let className =
|
|
327
|
-
if (anchorTop >
|
|
328
|
-
className +=
|
|
324
|
+
let className = "typeahead-popover mentions-menu";
|
|
325
|
+
if (anchorTop > viewportHeight / 2) {
|
|
326
|
+
className += " mentions-menu-popup";
|
|
329
327
|
}
|
|
330
328
|
|
|
331
329
|
return ReactDOM.createPortal(
|
|
@@ -6,42 +6,41 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
export default {
|
|
9
|
-
code:
|
|
9
|
+
code: "editor-code",
|
|
10
10
|
heading: {
|
|
11
|
-
h1:
|
|
12
|
-
h2:
|
|
13
|
-
h3:
|
|
14
|
-
h4:
|
|
15
|
-
h5:
|
|
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
16
|
},
|
|
17
|
-
image:
|
|
18
|
-
link:
|
|
17
|
+
image: "editor-image",
|
|
18
|
+
link: "editor-link",
|
|
19
19
|
list: {
|
|
20
|
-
listitem:
|
|
20
|
+
listitem: "editor-listitem",
|
|
21
21
|
nested: {
|
|
22
22
|
// listitem: 'editor-nested-listitem',
|
|
23
|
-
listitem:
|
|
23
|
+
listitem: "PlaygroundEditorTheme__nestedListItem",
|
|
24
24
|
},
|
|
25
|
-
ol:
|
|
26
|
-
ul:
|
|
27
|
-
checklist:
|
|
28
|
-
listitemChecked:
|
|
29
|
-
listitemUnchecked:
|
|
30
|
-
|
|
25
|
+
ol: "editor-list-ol",
|
|
26
|
+
ul: "editor-list-ul",
|
|
27
|
+
checklist: "PlaygroundEditorTheme__checklist",
|
|
28
|
+
listitemChecked: "PlaygroundEditorTheme__listItemChecked",
|
|
29
|
+
listitemUnchecked: "PlaygroundEditorTheme__listItemUnchecked",
|
|
31
30
|
},
|
|
32
|
-
ltr:
|
|
33
|
-
paragraph:
|
|
34
|
-
placeholder:
|
|
35
|
-
quote:
|
|
36
|
-
rtl:
|
|
31
|
+
ltr: "ltr",
|
|
32
|
+
paragraph: "editor-paragraph",
|
|
33
|
+
placeholder: "editor-placeholder",
|
|
34
|
+
quote: "editor-quote",
|
|
35
|
+
rtl: "rtl",
|
|
37
36
|
text: {
|
|
38
|
-
bold:
|
|
39
|
-
code:
|
|
40
|
-
hashtag:
|
|
41
|
-
italic:
|
|
42
|
-
overflowed:
|
|
43
|
-
strikethrough:
|
|
44
|
-
underline:
|
|
45
|
-
underlineStrikethrough:
|
|
37
|
+
bold: "editor-text-bold",
|
|
38
|
+
code: "editor-text-code",
|
|
39
|
+
hashtag: "editor-text-hashtag",
|
|
40
|
+
italic: "editor-text-italic",
|
|
41
|
+
overflowed: "editor-text-overflowed",
|
|
42
|
+
strikethrough: "editor-text-strikethrough",
|
|
43
|
+
underline: "editor-text-underline",
|
|
44
|
+
underlineStrikethrough: "editor-text-underlineStrikethrough",
|
|
46
45
|
},
|
|
47
46
|
};
|