@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,13 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { IMarkdownEditorProps, MarkdownEditor } from '../markdown-editor/editor'
|
|
3
|
-
|
|
4
|
-
interface TextListEditorProps extends IMarkdownEditorProps {}
|
|
5
|
-
|
|
6
|
-
export const TextListEditor = (props: TextListEditorProps) => {
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="border rounded border-dark-subtle">
|
|
10
|
-
<MarkdownEditor {...props} />
|
|
11
|
-
</div>
|
|
12
|
-
)
|
|
13
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import * as globals from '../globals';
|
|
3
|
-
// import { visibleNotifications } from '../notifications';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const TopBar = () => {
|
|
7
|
-
// const [_notifications] = useObservable(visibleNotifications);
|
|
8
|
-
// const unreadNotifications = _notifications.filter(n => !n.status);
|
|
9
|
-
// const unreadNotificationCount = unreadNotifications.length;
|
|
10
|
-
// const [group] = useObservable(globals.activeGroup);
|
|
11
|
-
|
|
12
|
-
let connections = [1,2,3];
|
|
13
|
-
let connectionsSyncing = [1,2];
|
|
14
|
-
let unreadNotificationCount = 0;
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<nav className="navbar navbar-expand-lg navbar-dark bg-body-tertiary fixed-top peers-top-bar"
|
|
18
|
-
// style={{ borderLeft: 'solid', borderColor: '#606365', borderWidth: globals.isDesktop() ? '1px' : 0, }}
|
|
19
|
-
// style={{ borderBottom: 'solid', borderColor: '#606365', borderWidth: '1px', }}
|
|
20
|
-
style={{ height: '50px' }}
|
|
21
|
-
>
|
|
22
|
-
<div className="container-fluid">
|
|
23
|
-
{/* <a className="dropdown-toggle logo" href="#"
|
|
24
|
-
id="brandDD" data-bs-toggle="dropdown" aria-expanded="false"
|
|
25
|
-
>
|
|
26
|
-
<img src="/android/android-launchericon-512-512.png" alt="" width="40" height="40" className="d-inline-block align-top"></img>
|
|
27
|
-
</a> */}
|
|
28
|
-
|
|
29
|
-
<div>
|
|
30
|
-
<button className="navbar-toggler collapsed" type="button"
|
|
31
|
-
data-bs-toggle="offcanvas"
|
|
32
|
-
data-bs-target="#leftBar"
|
|
33
|
-
aria-controls="leftBar"
|
|
34
|
-
aria-expanded="false"
|
|
35
|
-
aria-label="Toggle Left Bar"
|
|
36
|
-
>
|
|
37
|
-
<span className="navbar-toggler-icon"></span>
|
|
38
|
-
</button>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<div>
|
|
42
|
-
<span className="text-white">
|
|
43
|
-
{/* {group?.name} */} open tabs here
|
|
44
|
-
</span>
|
|
45
|
-
</div>
|
|
46
|
-
|
|
47
|
-
<div>
|
|
48
|
-
<span className="navbar-text" style={{ marginRight: 8, fontSize: "12pt" }}>
|
|
49
|
-
<span style={{ display: 'inline-block' }}>
|
|
50
|
-
{Boolean(connectionsSyncing.length) && [
|
|
51
|
-
connectionsSyncing.length + " ",
|
|
52
|
-
<i key="1" className="bi bi-arrow-repeat"></i>,
|
|
53
|
-
<span key="2"> </span>
|
|
54
|
-
]}
|
|
55
|
-
{connections.length} <i className="bi bi-arrow-down-up"></i>
|
|
56
|
-
</span>
|
|
57
|
-
</span>
|
|
58
|
-
|
|
59
|
-
<button type="button" className="btn btn-dark position-relative"
|
|
60
|
-
data-bs-toggle="offcanvas"
|
|
61
|
-
data-bs-target="#rightBar"
|
|
62
|
-
aria-controls="rightBar"
|
|
63
|
-
aria-expanded="false"
|
|
64
|
-
aria-label="Toggle Right Bar"
|
|
65
|
-
// TODO take this out once we are ready to show content in the right bar
|
|
66
|
-
hidden
|
|
67
|
-
>
|
|
68
|
-
<i className={`bi bi-bell${unreadNotificationCount > 0 ? '-fill' : ''}`}></i>
|
|
69
|
-
<span
|
|
70
|
-
className="translate-middle badge rounded-pill bg-danger"
|
|
71
|
-
style={{
|
|
72
|
-
display: unreadNotificationCount < 1 ? 'none' : '',
|
|
73
|
-
position: 'absolute',
|
|
74
|
-
top: unreadNotificationCount > 9 ? 4 : 7,
|
|
75
|
-
right: unreadNotificationCount > 9 ? -27 : -16
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
{unreadNotificationCount > 9 ? "9+" : unreadNotificationCount}
|
|
79
|
-
<span className="visually-hidden">unread notifications</span>
|
|
80
|
-
</span>
|
|
81
|
-
</button>
|
|
82
|
-
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
{/* <div className="d-flex">
|
|
86
|
-
<input className="form-control me-2" type="search" placeholder="Search" aria-label="Search" />
|
|
87
|
-
</div> */}
|
|
88
|
-
|
|
89
|
-
{/*
|
|
90
|
-
<button className="navbar-toggler collapsed" type="button" data-bs-toggle="collapse"
|
|
91
|
-
data-bs-target="#navbarMain" aria-controls="navbarMain" aria-expanded="false"
|
|
92
|
-
aria-label="Toggle navigation"
|
|
93
|
-
>
|
|
94
|
-
<span className="navbar-toggler-icon"></span>
|
|
95
|
-
</button>
|
|
96
|
-
|
|
97
|
-
<div className="navbar-collapse collapse" id="navbarMain" >
|
|
98
|
-
<ul className="navbar-nav me-auto mb-2 mb-md-0">
|
|
99
|
-
{[
|
|
100
|
-
{ path: 'new-order', name: 'New Order' },
|
|
101
|
-
{ path: 'inventory', name: 'Inventory' },
|
|
102
|
-
].map(({ path, name }) => {
|
|
103
|
-
return (
|
|
104
|
-
<li key={path + name} className="nav-item"
|
|
105
|
-
>
|
|
106
|
-
<a className={'nav-link'}
|
|
107
|
-
aria-current="page"
|
|
108
|
-
href={`#/${path}`}>{name}</a>
|
|
109
|
-
</li>
|
|
110
|
-
)
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
</ul>
|
|
115
|
-
</div> */}
|
|
116
|
-
</div>
|
|
117
|
-
</nav>
|
|
118
|
-
);
|
|
119
|
-
}
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
-
import {
|
|
3
|
-
LexicalTypeaheadMenuPlugin,
|
|
4
|
-
MenuOption,
|
|
5
|
-
useBasicTypeaheadTriggerMatch
|
|
6
|
-
} from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
7
|
-
import { IMentionData, observable, Observable } from "@peers-app/peers-sdk";
|
|
8
|
-
import { $getSelection, TextNode } from 'lexical';
|
|
9
|
-
import { sortBy, uniqBy } from 'lodash';
|
|
10
|
-
import * as React from 'react';
|
|
11
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
12
|
-
import * as ReactDOM from 'react-dom';
|
|
13
|
-
import { IMentionConfig } from '../../mention-configs';
|
|
14
|
-
import { $createMentionNode } from '../markdown-editor/mention-node';
|
|
15
|
-
|
|
16
|
-
// At most, 5 suggestions are shown in the popup.
|
|
17
|
-
const SUGGESTION_LIST_LENGTH_LIMIT = 10;
|
|
18
|
-
export const MENTIONS_MAX_RESULTS = 10;
|
|
19
|
-
|
|
20
|
-
function useMentionLookupService(mentionString: string | null, mentionConfigs: IMentionConfig[] = []): IMentionData[] {
|
|
21
|
-
const [results, setResults] = useState<Array<IMentionData>>([]);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (!mentionString) {
|
|
25
|
-
setResults([]);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
(async () => {
|
|
29
|
-
mentionString = mentionString || '';
|
|
30
|
-
const prefix = mentionString[0];
|
|
31
|
-
// TODO simplify how users can include completed tasks in their search
|
|
32
|
-
let searchCompletedTasks = prefix === '$' && mentionString.startsWith('done');
|
|
33
|
-
if (searchCompletedTasks) {
|
|
34
|
-
mentionString = mentionString.slice(4);
|
|
35
|
-
}
|
|
36
|
-
let kind = '';
|
|
37
|
-
if (mentionString.includes(':')) {
|
|
38
|
-
const parts = mentionString.split(':');
|
|
39
|
-
kind = parts[0];
|
|
40
|
-
mentionString = parts[1] || '';
|
|
41
|
-
}
|
|
42
|
-
const config = mentionConfigs?.find(c => c.kind === kind);
|
|
43
|
-
if (config) {
|
|
44
|
-
let results = await config.query(mentionString);
|
|
45
|
-
results = results.map(r => ({ ...r, clickable: false }));
|
|
46
|
-
setResults(results);
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const results = await Promise.all(
|
|
50
|
-
mentionConfigs?.map(c => c.query(mentionString || '')),
|
|
51
|
-
);
|
|
52
|
-
let allResults = results.flat();
|
|
53
|
-
allResults = uniqBy(allResults, 'id');
|
|
54
|
-
let filteredResults = allResults;
|
|
55
|
-
if (prefix === '@') {
|
|
56
|
-
filteredResults = filteredResults.filter((result) => result.kind === 'user' || result.kind === 'assistant');
|
|
57
|
-
} else {
|
|
58
|
-
filteredResults = filteredResults.filter((result) => result.kind !== 'user' && result.kind !== 'assistant');
|
|
59
|
-
}
|
|
60
|
-
if (kind) {
|
|
61
|
-
filteredResults = allResults.filter((result) => result.kind.toLowerCase() === kind.toLowerCase());
|
|
62
|
-
} else if (!filteredResults.length) {
|
|
63
|
-
filteredResults = allResults;
|
|
64
|
-
}
|
|
65
|
-
filteredResults = sortBy(filteredResults, r => {
|
|
66
|
-
return r.name.toLowerCase().indexOf((mentionString!).toLowerCase());
|
|
67
|
-
});
|
|
68
|
-
filteredResults = filteredResults.slice(0, SUGGESTION_LIST_LENGTH_LIMIT);
|
|
69
|
-
filteredResults = filteredResults.map(r => ({ ...r, clickable: false }));
|
|
70
|
-
setResults(filteredResults);
|
|
71
|
-
})();
|
|
72
|
-
}, [mentionString]);
|
|
73
|
-
|
|
74
|
-
return results;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
class MentionTypeaheadOption extends MenuOption {
|
|
78
|
-
name: string;
|
|
79
|
-
picture: JSX.Element;
|
|
80
|
-
id: string;
|
|
81
|
-
userId?: string;
|
|
82
|
-
|
|
83
|
-
constructor(
|
|
84
|
-
public readonly data: IMentionData,
|
|
85
|
-
picture: JSX.Element
|
|
86
|
-
) {
|
|
87
|
-
super(data.name);
|
|
88
|
-
this.name = data.name;
|
|
89
|
-
this.picture = picture;
|
|
90
|
-
this.id = data.id;
|
|
91
|
-
// if (data.kind === 'assistant') {
|
|
92
|
-
// this.userId = data.userId;
|
|
93
|
-
// }
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function MentionsTypeaheadMenuItem({
|
|
98
|
-
index,
|
|
99
|
-
isSelected,
|
|
100
|
-
onClick,
|
|
101
|
-
onMouseEnter,
|
|
102
|
-
option,
|
|
103
|
-
}: {
|
|
104
|
-
index: number;
|
|
105
|
-
isSelected: boolean;
|
|
106
|
-
onClick: () => void;
|
|
107
|
-
onMouseEnter: () => void;
|
|
108
|
-
option: MentionTypeaheadOption;
|
|
109
|
-
}) {
|
|
110
|
-
let className = 'item';
|
|
111
|
-
if (isSelected) {
|
|
112
|
-
className += ' selected';
|
|
113
|
-
}
|
|
114
|
-
return (
|
|
115
|
-
<li
|
|
116
|
-
key={option.key}
|
|
117
|
-
tabIndex={-1}
|
|
118
|
-
className={className}
|
|
119
|
-
ref={option.setRefElement}
|
|
120
|
-
role="option"
|
|
121
|
-
aria-selected={isSelected}
|
|
122
|
-
id={'typeahead-item-' + index}
|
|
123
|
-
onMouseEnter={onMouseEnter}
|
|
124
|
-
onClick={onClick}
|
|
125
|
-
data-kind={option.data.kind}
|
|
126
|
-
data-id={option.id}
|
|
127
|
-
data-user-id={option.userId || undefined}
|
|
128
|
-
>
|
|
129
|
-
{option.picture}
|
|
130
|
-
<span className="text">{option.name}</span>
|
|
131
|
-
</li>
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function MentionsPlugin(
|
|
136
|
-
props: {
|
|
137
|
-
mentionConfigs?: IMentionConfig[]
|
|
138
|
-
mentionsOpen?: Observable<boolean>
|
|
139
|
-
}
|
|
140
|
-
): JSX.Element | null {
|
|
141
|
-
const [editor] = useLexicalComposerContext();
|
|
142
|
-
|
|
143
|
-
const [queryString, setQueryString] = useState<string | null>(null);
|
|
144
|
-
const results = useMentionLookupService(queryString, props.mentionConfigs);
|
|
145
|
-
const [_mentionsOpen] = useState(() => observable(false));
|
|
146
|
-
|
|
147
|
-
if (props.mentionsOpen) {
|
|
148
|
-
const finalMentionsOpen = _mentionsOpen() && results.length > 0;
|
|
149
|
-
if (props.mentionsOpen() !== finalMentionsOpen) {
|
|
150
|
-
props.mentionsOpen(finalMentionsOpen);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const checkForSlashTriggerMatch = useBasicTypeaheadTriggerMatch('/', {
|
|
155
|
-
minLength: 0,
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
const options = useMemo(
|
|
159
|
-
() =>
|
|
160
|
-
results
|
|
161
|
-
.map(
|
|
162
|
-
(result) => {
|
|
163
|
-
let picture = <i className="bi bi-question pe-1" />;
|
|
164
|
-
const config = props.mentionConfigs?.find(c => c.kind === result.kind);
|
|
165
|
-
if (config) {
|
|
166
|
-
if (config.picture) {
|
|
167
|
-
picture = config.picture(result);
|
|
168
|
-
} else {
|
|
169
|
-
picture = <i className={config.iconClass + ' pe-1'} />;
|
|
170
|
-
}
|
|
171
|
-
} else {
|
|
172
|
-
picture = <i className={'bi bi-question pe-1'} />;
|
|
173
|
-
}
|
|
174
|
-
return new MentionTypeaheadOption(result, picture);
|
|
175
|
-
}
|
|
176
|
-
)
|
|
177
|
-
.slice(0, SUGGESTION_LIST_LENGTH_LIMIT),
|
|
178
|
-
[results],
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
const onSelectOption = useCallback(
|
|
182
|
-
(
|
|
183
|
-
selectedOption: MentionTypeaheadOption,
|
|
184
|
-
nodeToReplace: TextNode | null,
|
|
185
|
-
closeMenu: () => void,
|
|
186
|
-
) => {
|
|
187
|
-
editor.update(() => {
|
|
188
|
-
const mentionNode = $createMentionNode(selectedOption.data);
|
|
189
|
-
if (nodeToReplace) {
|
|
190
|
-
nodeToReplace.replace(mentionNode);
|
|
191
|
-
}
|
|
192
|
-
mentionNode.selectNext(); // Move cursor to the position after the mention
|
|
193
|
-
const selection = $getSelection();
|
|
194
|
-
if (selection !== null) {
|
|
195
|
-
selection.insertText(' '); // Insert a space after the mention
|
|
196
|
-
}
|
|
197
|
-
closeMenu();
|
|
198
|
-
});
|
|
199
|
-
},
|
|
200
|
-
[editor],
|
|
201
|
-
);
|
|
202
|
-
|
|
203
|
-
const checkForMentionMatch = useCallback(
|
|
204
|
-
(text: string) => {
|
|
205
|
-
const textTrimmed = text.trimStart();
|
|
206
|
-
return {
|
|
207
|
-
leadOffset: text.length - textTrimmed.length,
|
|
208
|
-
matchingString: text.trim(),
|
|
209
|
-
replaceableString: text.trim(),
|
|
210
|
-
};
|
|
211
|
-
},
|
|
212
|
-
[checkForSlashTriggerMatch, editor],
|
|
213
|
-
);
|
|
214
|
-
|
|
215
|
-
return (
|
|
216
|
-
<LexicalTypeaheadMenuPlugin<MentionTypeaheadOption>
|
|
217
|
-
onQueryChange={setQueryString}
|
|
218
|
-
onSelectOption={onSelectOption}
|
|
219
|
-
triggerFn={checkForMentionMatch}
|
|
220
|
-
options={options}
|
|
221
|
-
onOpen={() => _mentionsOpen(true)}
|
|
222
|
-
onClose={() => _mentionsOpen(false)}
|
|
223
|
-
menuRenderFn={(
|
|
224
|
-
anchorElementRef,
|
|
225
|
-
{ selectedIndex, selectOptionAndCleanUp, setHighlightedIndex },
|
|
226
|
-
) => {
|
|
227
|
-
if (!(anchorElementRef.current && results.length)) {
|
|
228
|
-
return null;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// distance from the top of the viewport to the top of the anchor element
|
|
232
|
-
const anchorTop = anchorElementRef.current.getBoundingClientRect().top;
|
|
233
|
-
const viewportHeight = window.innerHeight;
|
|
234
|
-
|
|
235
|
-
let className = 'typeahead-popover mentions-menu';
|
|
236
|
-
if (anchorTop > (viewportHeight / 2)) {
|
|
237
|
-
className += ' mentions-menu-popup';
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
return ReactDOM.createPortal(
|
|
241
|
-
<div className={className}>
|
|
242
|
-
<ul>
|
|
243
|
-
{options.map((option, i: number) => (
|
|
244
|
-
<MentionsTypeaheadMenuItem
|
|
245
|
-
index={i}
|
|
246
|
-
isSelected={selectedIndex === i}
|
|
247
|
-
onClick={() => {
|
|
248
|
-
setHighlightedIndex(i);
|
|
249
|
-
selectOptionAndCleanUp(option);
|
|
250
|
-
}}
|
|
251
|
-
onMouseEnter={() => {
|
|
252
|
-
setHighlightedIndex(i);
|
|
253
|
-
}}
|
|
254
|
-
key={option.key}
|
|
255
|
-
option={option}
|
|
256
|
-
/>
|
|
257
|
-
))}
|
|
258
|
-
</ul>
|
|
259
|
-
</div>,
|
|
260
|
-
anchorElementRef.current,
|
|
261
|
-
);
|
|
262
|
-
}}
|
|
263
|
-
/>
|
|
264
|
-
);
|
|
265
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { CodeNode } from '@lexical/code';
|
|
2
|
-
import { AutoLinkNode, LinkNode } from '@lexical/link';
|
|
3
|
-
import { ListItemNode, ListNode } from '@lexical/list';
|
|
4
|
-
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
5
|
-
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
6
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
7
|
-
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
8
|
-
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
9
|
-
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
10
|
-
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
11
|
-
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
12
|
-
import { observable, Observable } from "@peers-app/peers-sdk";
|
|
13
|
-
import { COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND } from 'lexical';
|
|
14
|
-
import React, { useEffect, useState } from 'react';
|
|
15
|
-
import { MarkdownPlugin } from '../markdown-editor/markdown-plugin';
|
|
16
|
-
import { MentionNode } from '../markdown-editor/mention-node';
|
|
17
|
-
import theme from '../markdown-editor/theme';
|
|
18
|
-
import { MentionsPlugin } from './mentions-plugin';
|
|
19
|
-
import { IMentionConfig, mentionConfigs } from '../../mention-configs';
|
|
20
|
-
|
|
21
|
-
const editorConfig = {
|
|
22
|
-
namespace: 'PeersEditor',
|
|
23
|
-
nodes: [
|
|
24
|
-
HeadingNode,
|
|
25
|
-
QuoteNode,
|
|
26
|
-
CodeNode,
|
|
27
|
-
ListNode,
|
|
28
|
-
ListItemNode,
|
|
29
|
-
MentionNode,
|
|
30
|
-
AutoLinkNode as any,
|
|
31
|
-
LinkNode,
|
|
32
|
-
],
|
|
33
|
-
// Handling of errors during update
|
|
34
|
-
onError(error: Error) {
|
|
35
|
-
throw error;
|
|
36
|
-
},
|
|
37
|
-
// The editor theme
|
|
38
|
-
theme,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export interface IEditorEffects {
|
|
42
|
-
onKeyDown?: (e: React.KeyboardEvent) => (boolean | void);
|
|
43
|
-
focus?: () => void;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export interface ITypeaheadEditorProps {
|
|
47
|
-
value: Observable<string>;
|
|
48
|
-
effects?: IEditorEffects;
|
|
49
|
-
autoFocus?: boolean;
|
|
50
|
-
maxHeight?: string | number;
|
|
51
|
-
mentionConfigs?: IMentionConfig[];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function TypeaheadEditor(props: ITypeaheadEditorProps) {
|
|
55
|
-
const { effects } = props;
|
|
56
|
-
const editorRef = React.useRef<HTMLDivElement>(null);
|
|
57
|
-
|
|
58
|
-
const [mentionsOpen] = useState(() => {
|
|
59
|
-
const obs = observable(false);
|
|
60
|
-
return obs;
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (effects) {
|
|
64
|
-
effects.focus = () => {
|
|
65
|
-
if (editorRef.current?.children[0]) {
|
|
66
|
-
const div = editorRef.current.children[0] as HTMLDivElement;
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
div.focus();
|
|
69
|
-
// Set the selection to the end of the div content
|
|
70
|
-
const range = document.createRange();
|
|
71
|
-
range.selectNodeContents(div);
|
|
72
|
-
range.collapse(false);
|
|
73
|
-
const selection = window.getSelection();
|
|
74
|
-
if (selection) {
|
|
75
|
-
selection.removeAllRanges();
|
|
76
|
-
selection.addRange(range);
|
|
77
|
-
}
|
|
78
|
-
}, 10);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const _mentionConfigs = props.mentionConfigs ?? mentionConfigs;
|
|
84
|
-
|
|
85
|
-
return (
|
|
86
|
-
<div className="border rounded border-dark-subtle">
|
|
87
|
-
<LexicalComposer initialConfig={{ ...editorConfig }}>
|
|
88
|
-
<div className="editor-container">
|
|
89
|
-
|
|
90
|
-
<div
|
|
91
|
-
className="editor-inner"
|
|
92
|
-
ref={editorRef}
|
|
93
|
-
style={{ maxHeight: props.maxHeight ?? 30, overflowY: 'hidden' }}
|
|
94
|
-
>
|
|
95
|
-
<RichTextPlugin
|
|
96
|
-
contentEditable={
|
|
97
|
-
<ContentEditable
|
|
98
|
-
className="editor-input p-1"
|
|
99
|
-
/>
|
|
100
|
-
}
|
|
101
|
-
// placeholder={(isEditable) => !isEditable ? <div className="text-muted">Type here...</div> : null}
|
|
102
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
103
|
-
/>
|
|
104
|
-
<HistoryPlugin />
|
|
105
|
-
{props.autoFocus && <AutoFocusPlugin defaultSelection='rootEnd' />}
|
|
106
|
-
|
|
107
|
-
{_mentionConfigs.length > 0 && (
|
|
108
|
-
<MentionsPlugin
|
|
109
|
-
mentionConfigs={_mentionConfigs}
|
|
110
|
-
mentionsOpen={mentionsOpen}
|
|
111
|
-
/>
|
|
112
|
-
)}
|
|
113
|
-
|
|
114
|
-
<MarkdownPlugin markdownObs={props.value} />
|
|
115
|
-
{/* <MarkdownShortcutPlugin transformers={customMarkdownTransformers} /> */}
|
|
116
|
-
<OnKeyDownPlugin effects={props.effects} mentionsOpen={mentionsOpen} />
|
|
117
|
-
</div>
|
|
118
|
-
</div>
|
|
119
|
-
</LexicalComposer>
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const OnKeyDownPlugin = (props: { effects?: IEditorEffects, mentionsOpen: Observable<boolean> }) => {
|
|
125
|
-
const [editor] = useLexicalComposerContext();
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
const removeListener = editor.registerCommand(KEY_DOWN_COMMAND, (event: KeyboardEvent) => {
|
|
128
|
-
if (props.mentionsOpen()) {
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
if (props.effects?.onKeyDown) {
|
|
132
|
-
const result = props.effects.onKeyDown(event as any);
|
|
133
|
-
return !!result;
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
136
|
-
}, COMMAND_PRIORITY_LOW);
|
|
137
|
-
return removeListener;
|
|
138
|
-
}, [editor]);
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { formatMention, getAllMentions, observable, Observable } from "@peers-app/peers-sdk";
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import { useObservable, usePromise, useSubscription } from "../../hooks";
|
|
4
|
-
import { IMentionConfig } from '../../mention-configs';
|
|
5
|
-
import { TypeaheadEditor } from './typeahead-editor';
|
|
6
|
-
|
|
7
|
-
interface IProps<T> {
|
|
8
|
-
value: Observable<string> | Observable<string | undefined>
|
|
9
|
-
textValue?: Observable<string>
|
|
10
|
-
mentionConfigs: IMentionConfig[]
|
|
11
|
-
autoFocus?: boolean
|
|
12
|
-
onSubmit?: (value: string, textValue: string) => void
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function Typeahead<T>(props: IProps<T>) {
|
|
16
|
-
const { value: sourceValue } = props;
|
|
17
|
-
|
|
18
|
-
// const typeaheadValue = useObservableState('', true);
|
|
19
|
-
const [typeaheadValue] = useState(() => {
|
|
20
|
-
if (props.textValue) {
|
|
21
|
-
return props.textValue;
|
|
22
|
-
} else {
|
|
23
|
-
return observable('');
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
useObservable(typeaheadValue);
|
|
27
|
-
const existingMention = usePromise(async () => {
|
|
28
|
-
const id = sourceValue();
|
|
29
|
-
if (!id) return true;
|
|
30
|
-
for (const config of props.mentionConfigs) {
|
|
31
|
-
const refValue = await config.getById(id);
|
|
32
|
-
if (refValue) {
|
|
33
|
-
typeaheadValue(formatMention({ kind: config.kind, id, name: refValue.name }) + ' ');
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return true;
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
useSubscription(typeaheadValue, () => {
|
|
41
|
-
const mentions = getAllMentions(typeaheadValue());
|
|
42
|
-
const resolvedMention = mentions.find(m => m.id !== sourceValue()) || mentions[0];
|
|
43
|
-
const resolvedId = resolvedMention?.id;
|
|
44
|
-
if (resolvedId !== sourceValue() || mentions.length > 1) {
|
|
45
|
-
sourceValue(resolvedId);
|
|
46
|
-
if (resolvedId) {
|
|
47
|
-
const newTypeaheadValue = formatMention(resolvedMention) + ' ';
|
|
48
|
-
typeaheadValue(newTypeaheadValue);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}, true);
|
|
52
|
-
|
|
53
|
-
if (!existingMention) {
|
|
54
|
-
return <div>...</div>
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<TypeaheadEditor
|
|
59
|
-
value={typeaheadValue}
|
|
60
|
-
mentionConfigs={props.mentionConfigs}
|
|
61
|
-
autoFocus={props.autoFocus}
|
|
62
|
-
|
|
63
|
-
// these settings configure it for a single line input
|
|
64
|
-
effects={{
|
|
65
|
-
onKeyDown(e) {
|
|
66
|
-
if (e.key === 'Enter') {
|
|
67
|
-
e.preventDefault();
|
|
68
|
-
if (props.onSubmit) {
|
|
69
|
-
props.onSubmit(sourceValue() ?? '', typeaheadValue());
|
|
70
|
-
}
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
}}
|
|
75
|
-
/>
|
|
76
|
-
)
|
|
77
|
-
}
|
package/src/screens/profile.tsx
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { getUserContext, thisDeviceId, Users } from "@peers-app/peers-sdk";
|
|
3
|
-
import React from 'react';
|
|
4
|
-
import { Input } from '../components/input';
|
|
5
|
-
import { SaveButton } from '../components/save-button';
|
|
6
|
-
import { Tooltip } from '../components/tooltip';
|
|
7
|
-
import * as globals from '../globals';
|
|
8
|
-
import { usePromise } from '../hooks';
|
|
9
|
-
|
|
10
|
-
export const Profile = () => {
|
|
11
|
-
|
|
12
|
-
const me = usePromise(async () => {
|
|
13
|
-
const userContext = await getUserContext();
|
|
14
|
-
return Users(userContext.userDataContext).initDoc(globals.me);
|
|
15
|
-
});
|
|
16
|
-
if (!me) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className="container mt-4">
|
|
22
|
-
|
|
23
|
-
<div className="d-flex mb-2">
|
|
24
|
-
<div className="flex-grow-1">
|
|
25
|
-
<h4>Profile</h4>
|
|
26
|
-
</div>
|
|
27
|
-
<div>
|
|
28
|
-
<SaveButton
|
|
29
|
-
doc={me}
|
|
30
|
-
noBuiltInActions
|
|
31
|
-
/>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<small>Name:</small>
|
|
36
|
-
<Input
|
|
37
|
-
value={me.qs.name}
|
|
38
|
-
className="form-control mb-3"
|
|
39
|
-
/>
|
|
40
|
-
|
|
41
|
-
<small>User Id:</small>
|
|
42
|
-
<Tooltip markdownContent="This uniquely identifies you to all other users." />
|
|
43
|
-
<Input
|
|
44
|
-
value={me.userId}
|
|
45
|
-
className="form-control mb-3"
|
|
46
|
-
disabled
|
|
47
|
-
/>
|
|
48
|
-
|
|
49
|
-
<small>Device Id:</small>
|
|
50
|
-
<Tooltip markdownContent="This uniquely identifies this device on Peers networks." />
|
|
51
|
-
<Input
|
|
52
|
-
value={thisDeviceId()}
|
|
53
|
-
className="form-control mb-3"
|
|
54
|
-
disabled
|
|
55
|
-
/>
|
|
56
|
-
|
|
57
|
-
<small>Public Key:</small>
|
|
58
|
-
<Tooltip markdownContent="This is your public key that other users will use to verify your signatures and thereby confirm a message was actually from you." />
|
|
59
|
-
<Input
|
|
60
|
-
value={me.publicKey}
|
|
61
|
-
className="form-control mb-3"
|
|
62
|
-
disabled
|
|
63
|
-
/>
|
|
64
|
-
|
|
65
|
-
<small>Public Box Key:</small>
|
|
66
|
-
<Tooltip markdownContent="This is the public key that other users can use to encrypt data so that only you can open it with your secret key." />
|
|
67
|
-
<Input
|
|
68
|
-
value={me.publicBoxKey}
|
|
69
|
-
className="form-control mb-3"
|
|
70
|
-
disabled
|
|
71
|
-
/>
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|