@peers-app/peers-ui 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/README.md +52 -0
- package/.github/workflows/publish.yml +45 -0
- package/babel.config.js +7 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +54 -0
- package/dist/command-palette/command-palette-ui.d.ts +2 -0
- package/dist/command-palette/command-palette-ui.js +192 -0
- package/dist/command-palette/command-palette.d.ts +23 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +20 -0
- package/dist/components/group-switcher.d.ts +6 -0
- package/dist/components/group-switcher.js +301 -0
- package/dist/components/input-date.d.ts +7 -0
- package/dist/components/input-date.js +19 -0
- package/dist/components/input-datetime.d.ts +7 -0
- package/dist/components/input-datetime.js +35 -0
- package/dist/components/input-number.d.ts +9 -0
- package/dist/components/input-number.js +87 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +20 -0
- package/dist/components/io-schema-values.d.ts +15 -0
- package/dist/components/io-schema-values.js +105 -0
- package/dist/components/io-schema.d.ts +13 -0
- package/dist/components/io-schema.js +163 -0
- package/dist/components/lazy-list.d.ts +13 -0
- package/dist/components/lazy-list.js +91 -0
- package/dist/components/lazy-sortable-list.d.ts +29 -0
- package/dist/components/lazy-sortable-list.js +12 -0
- package/dist/components/left-bar.d.ts +3 -0
- package/dist/components/left-bar.js +130 -0
- package/dist/components/list-screen.d.ts +16 -0
- package/dist/components/list-screen.js +100 -0
- package/dist/components/loading-indicator.d.ts +2 -0
- package/dist/components/loading-indicator.js +12 -0
- package/dist/components/main-content-container.d.ts +2 -0
- package/dist/components/main-content-container.js +90 -0
- package/dist/components/markdown-editor/autolink-plugin.d.ts +2 -0
- package/dist/components/markdown-editor/autolink-plugin.js +29 -0
- package/dist/components/markdown-editor/editor-inline.d.ts +3 -0
- package/dist/components/markdown-editor/editor-inline.js +13 -0
- package/dist/components/markdown-editor/editor.d.ts +18 -0
- package/dist/components/markdown-editor/editor.js +143 -0
- package/dist/components/markdown-editor/markdown-plugin.d.ts +9 -0
- package/dist/components/markdown-editor/markdown-plugin.js +194 -0
- package/dist/components/markdown-editor/mention-node.d.ts +21 -0
- package/dist/components/markdown-editor/mention-node.js +160 -0
- package/dist/components/markdown-editor/mentions-plugin.d.ts +7 -0
- package/dist/components/markdown-editor/mentions-plugin.js +268 -0
- package/dist/components/markdown-editor/theme.d.ts +46 -0
- package/dist/components/markdown-editor/theme.js +48 -0
- package/dist/components/markdown-editor/toolbar.d.ts +10 -0
- package/dist/components/markdown-editor/toolbar.js +112 -0
- package/dist/components/markdown-with-mentions.d.ts +4 -0
- package/dist/components/markdown-with-mentions.js +140 -0
- package/dist/components/message-logs/message-logs.d.ts +6 -0
- package/dist/components/message-logs/message-logs.js +307 -0
- package/dist/components/messages/avatar.d.ts +10 -0
- package/dist/components/messages/avatar.js +65 -0
- package/dist/components/messages/channel-message-list.d.ts +14 -0
- package/dist/components/messages/channel-message-list.js +158 -0
- package/dist/components/messages/channel-view.d.ts +6 -0
- package/dist/components/messages/channel-view.js +82 -0
- package/dist/components/messages/message-compose.d.ts +11 -0
- package/dist/components/messages/message-compose.js +152 -0
- package/dist/components/messages/message-display.d.ts +10 -0
- package/dist/components/messages/message-display.js +152 -0
- package/dist/components/messages/thread-message-list.d.ts +11 -0
- package/dist/components/messages/thread-message-list.js +122 -0
- package/dist/components/messages/thread-view.d.ts +6 -0
- package/dist/components/messages/thread-view.js +174 -0
- package/dist/components/off-canvas.d.ts +13 -0
- package/dist/components/off-canvas.js +89 -0
- package/dist/components/router.d.ts +6 -0
- package/dist/components/router.js +240 -0
- package/dist/components/save-button.d.ts +13 -0
- package/dist/components/save-button.js +75 -0
- package/dist/components/sortable-list.d.ts +36 -0
- package/dist/components/sortable-list.js +77 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +69 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +6 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.js +13 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +20 -0
- package/dist/components/top-bar.d.ts +2 -0
- package/dist/components/top-bar.js +51 -0
- package/dist/components/typeahead/mentions-plugin.d.ts +7 -0
- package/dist/components/typeahead/mentions-plugin.js +203 -0
- package/dist/components/typeahead/typeahead-editor.d.ts +15 -0
- package/dist/components/typeahead/typeahead-editor.js +134 -0
- package/dist/components/typeahead/typeahead.d.ts +12 -0
- package/dist/components/typeahead/typeahead.js +94 -0
- package/dist/components/typeahead.d.ts +22 -0
- package/dist/components/typeahead.js +270 -0
- package/dist/globals.d.ts +29 -0
- package/dist/globals.js +148 -0
- package/dist/hooks.d.ts +34 -0
- package/dist/hooks.js +137 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/layout-vars.d.ts +6 -0
- package/dist/layout-vars.js +10 -0
- package/dist/mention-configs.d.ts +18 -0
- package/dist/mention-configs.js +149 -0
- package/dist/screens/assistants/assistant-config.d.ts +5 -0
- package/dist/screens/assistants/assistant-config.js +52 -0
- package/dist/screens/assistants/assistant-details.d.ts +4 -0
- package/dist/screens/assistants/assistant-details.js +85 -0
- package/dist/screens/assistants/assistant-info.d.ts +6 -0
- package/dist/screens/assistants/assistant-info.js +28 -0
- package/dist/screens/assistants/assistant-list.d.ts +2 -0
- package/dist/screens/assistants/assistant-list.js +114 -0
- package/dist/screens/assistants/assistant-tools.d.ts +5 -0
- package/dist/screens/assistants/assistant-tools.js +38 -0
- package/dist/screens/contacts/contact-details.d.ts +6 -0
- package/dist/screens/contacts/contact-details.js +100 -0
- package/dist/screens/contacts/contact-list.d.ts +2 -0
- package/dist/screens/contacts/contact-list.js +213 -0
- package/dist/screens/contacts/index.d.ts +4 -0
- package/dist/screens/contacts/index.js +21 -0
- package/dist/screens/events/cron.d.ts +3 -0
- package/dist/screens/events/cron.js +77 -0
- package/dist/screens/events/event-details.d.ts +6 -0
- package/dist/screens/events/event-details.js +112 -0
- package/dist/screens/events/event-handlers.d.ts +7 -0
- package/dist/screens/events/event-handlers.js +84 -0
- package/dist/screens/events/event-info.d.ts +5 -0
- package/dist/screens/events/event-info.js +19 -0
- package/dist/screens/events/event-list.d.ts +2 -0
- package/dist/screens/events/event-list.js +107 -0
- package/dist/screens/events/event-schedule.d.ts +5 -0
- package/dist/screens/events/event-schedule.js +124 -0
- package/dist/screens/groups/group-details.d.ts +6 -0
- package/dist/screens/groups/group-details.js +218 -0
- package/dist/screens/groups/group-list.d.ts +2 -0
- package/dist/screens/groups/group-list.js +275 -0
- package/dist/screens/groups/group-members.d.ts +8 -0
- package/dist/screens/groups/group-members.js +315 -0
- package/dist/screens/groups/index.d.ts +6 -0
- package/dist/screens/groups/index.js +23 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.js +84 -0
- package/dist/screens/knowledge/knowledge-frame-details.d.ts +8 -0
- package/dist/screens/knowledge/knowledge-frame-details.js +143 -0
- package/dist/screens/knowledge/knowledge-frame-list.d.ts +2 -0
- package/dist/screens/knowledge/knowledge-frame-list.js +45 -0
- package/dist/screens/knowledge/knowledge-value-details.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-value-details.js +150 -0
- package/dist/screens/knowledge/knowledge-value-list-item.d.ts +5 -0
- package/dist/screens/knowledge/knowledge-value-list-item.js +39 -0
- package/dist/screens/knowledge/knowledge-value-list.d.ts +3 -0
- package/dist/screens/knowledge/knowledge-value-list.js +123 -0
- package/dist/screens/packages/package-details.d.ts +6 -0
- package/dist/screens/packages/package-details.js +82 -0
- package/dist/screens/packages/package-info.d.ts +5 -0
- package/dist/screens/packages/package-info.js +42 -0
- package/dist/screens/packages/package-list.d.ts +2 -0
- package/dist/screens/packages/package-list.js +182 -0
- package/dist/screens/packages/package-new-local.d.ts +2 -0
- package/dist/screens/packages/package-new-local.js +82 -0
- package/dist/screens/peer-types/peer-type-details.d.ts +10 -0
- package/dist/screens/peer-types/peer-type-details.js +126 -0
- package/dist/screens/peer-types/peer-type-list.d.ts +2 -0
- package/dist/screens/peer-types/peer-type-list.js +57 -0
- package/dist/screens/predicates/predicate-details.d.ts +6 -0
- package/dist/screens/predicates/predicate-details.js +103 -0
- package/dist/screens/predicates/predicate-list.d.ts +2 -0
- package/dist/screens/predicates/predicate-list.js +46 -0
- package/dist/screens/profile.d.ts +2 -0
- package/dist/screens/profile.js +66 -0
- package/dist/screens/search/global-search.d.ts +2 -0
- package/dist/screens/search/global-search.js +186 -0
- package/dist/screens/settings/color-mode-dropdown.d.ts +6 -0
- package/dist/screens/settings/color-mode-dropdown.js +63 -0
- package/dist/screens/settings/settings-page.d.ts +2 -0
- package/dist/screens/settings/settings-page.js +49 -0
- package/dist/screens/setup-user.d.ts +2 -0
- package/dist/screens/setup-user.js +270 -0
- package/dist/screens/tools/tool-code.d.ts +5 -0
- package/dist/screens/tools/tool-code.js +32 -0
- package/dist/screens/tools/tool-details.d.ts +6 -0
- package/dist/screens/tools/tool-details.js +68 -0
- package/dist/screens/tools/tool-info.d.ts +5 -0
- package/dist/screens/tools/tool-info.js +74 -0
- package/dist/screens/tools/tool-list.d.ts +2 -0
- package/dist/screens/tools/tool-list.js +123 -0
- package/dist/screens/tools/tool-schema.d.ts +5 -0
- package/dist/screens/tools/tool-schema.js +30 -0
- package/dist/screens/tools/tool-test-details.d.ts +4 -0
- package/dist/screens/tools/tool-test-details.js +54 -0
- package/dist/screens/tools/tool-test-list.d.ts +4 -0
- package/dist/screens/tools/tool-test-list.js +82 -0
- package/dist/screens/variables/variable-details.d.ts +6 -0
- package/dist/screens/variables/variable-details.js +140 -0
- package/dist/screens/variables/variable-list.d.ts +2 -0
- package/dist/screens/variables/variable-list.js +58 -0
- package/dist/screens/workflows/workflow-details.d.ts +6 -0
- package/dist/screens/workflows/workflow-details.js +122 -0
- package/dist/screens/workflows/workflow-info.d.ts +5 -0
- package/dist/screens/workflows/workflow-info.js +18 -0
- package/dist/screens/workflows/workflow-instructions.d.ts +5 -0
- package/dist/screens/workflows/workflow-instructions.js +118 -0
- package/dist/screens/workflows/workflow-list.d.ts +2 -0
- package/dist/screens/workflows/workflow-list.js +109 -0
- package/dist/screens/workflows/workflow-subscriptions.d.ts +6 -0
- package/dist/screens/workflows/workflow-subscriptions.js +81 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +31 -0
- package/dist/system-apps/assistants.app.d.ts +2 -0
- package/dist/system-apps/assistants.app.js +8 -0
- package/dist/system-apps/contacts.app.d.ts +2 -0
- package/dist/system-apps/contacts.app.js +9 -0
- package/dist/system-apps/events.app.d.ts +2 -0
- package/dist/system-apps/events.app.js +8 -0
- package/dist/system-apps/groups.app.d.ts +2 -0
- package/dist/system-apps/groups.app.js +9 -0
- package/dist/system-apps/index.d.ts +19 -0
- package/dist/system-apps/index.js +90 -0
- package/dist/system-apps/knowledge-frames.app.d.ts +2 -0
- package/dist/system-apps/knowledge-frames.app.js +9 -0
- package/dist/system-apps/knowledge-values.app.d.ts +2 -0
- package/dist/system-apps/knowledge-values.app.js +9 -0
- package/dist/system-apps/packages.app.d.ts +2 -0
- package/dist/system-apps/packages.app.js +8 -0
- package/dist/system-apps/predicates.app.d.ts +2 -0
- package/dist/system-apps/predicates.app.js +8 -0
- package/dist/system-apps/profile.app.d.ts +2 -0
- package/dist/system-apps/profile.app.js +8 -0
- package/dist/system-apps/search.app.d.ts +2 -0
- package/dist/system-apps/search.app.js +9 -0
- package/dist/system-apps/settings.app.d.ts +2 -0
- package/dist/system-apps/settings.app.js +8 -0
- package/dist/system-apps/threads.app.d.ts +2 -0
- package/dist/system-apps/threads.app.js +8 -0
- package/dist/system-apps/tools.app.d.ts +2 -0
- package/dist/system-apps/tools.app.js +8 -0
- package/dist/system-apps/types.app.d.ts +2 -0
- package/dist/system-apps/types.app.js +8 -0
- package/dist/system-apps/variables.app.d.ts +2 -0
- package/dist/system-apps/variables.app.js +8 -0
- package/dist/system-apps/workflows.app.d.ts +2 -0
- package/dist/system-apps/workflows.app.js +8 -0
- package/dist/tabs-layout/tabs-layout.d.ts +5 -0
- package/dist/tabs-layout/tabs-layout.js +374 -0
- package/dist/tabs-layout/tabs-state.d.ts +26 -0
- package/dist/tabs-layout/tabs-state.js +239 -0
- package/dist/three-bar-layout/left-bar-content.d.ts +7 -0
- package/dist/three-bar-layout/left-bar-content.js +151 -0
- package/dist/three-bar-layout/right-bar-content.d.ts +2 -0
- package/dist/three-bar-layout/right-bar-content.js +64 -0
- package/dist/three-bar-layout/three-bar-layout.d.ts +5 -0
- package/dist/three-bar-layout/three-bar-layout.js +218 -0
- package/dist/ui-defaults/index.d.ts +2 -0
- package/dist/ui-defaults/index.js +4 -0
- package/dist/ui-defaults/list-screen.d.ts +6 -0
- package/dist/ui-defaults/list-screen.js +74 -0
- package/dist/ui-defaults/notes-editor.d.ts +7 -0
- package/dist/ui-defaults/notes-editor.js +41 -0
- package/dist/ui-router/routes-loader.d.ts +25 -0
- package/dist/ui-router/routes-loader.js +97 -0
- package/dist/ui-router/ui-loader.d.ts +18 -0
- package/dist/ui-router/ui-loader.js +481 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +250 -0
- package/docs/conversation-tab.md +201 -0
- package/docs/getting-started.md +284 -0
- package/docs/knowledge.md +187 -0
- package/docs/tabs-ui.md +696 -0
- package/docs/user-contacts-ui.md +384 -0
- package/jest.config.js +25 -0
- package/package.json +109 -0
- package/src/app.tsx +59 -0
- package/src/command-palette/command-palette-ui.tsx +264 -0
- package/src/command-palette/command-palette.ts +364 -0
- package/src/components/checkbox.tsx +22 -0
- package/src/components/group-switcher.tsx +469 -0
- package/src/components/input-date.tsx +28 -0
- package/src/components/input-datetime.tsx +41 -0
- package/src/components/input-number.tsx +67 -0
- package/src/components/input.tsx +22 -0
- package/src/components/io-schema-values.tsx +122 -0
- package/src/components/io-schema.tsx +234 -0
- package/src/components/lazy-list.tsx +98 -0
- package/src/components/lazy-sortable-list.tsx +51 -0
- package/src/components/left-bar.tsx +264 -0
- package/src/components/list-screen.tsx +105 -0
- package/src/components/loading-indicator.tsx +9 -0
- package/src/components/main-content-container.tsx +76 -0
- package/src/components/markdown-editor/autolink-plugin.tsx +36 -0
- package/src/components/markdown-editor/editor-inline.tsx +10 -0
- package/src/components/markdown-editor/editor.tsx +152 -0
- package/src/components/markdown-editor/markdown-plugin.tsx +224 -0
- package/src/components/markdown-editor/mention-node.ts +199 -0
- package/src/components/markdown-editor/mentions-plugin.tsx +356 -0
- package/src/components/markdown-editor/theme.ts +47 -0
- package/src/components/markdown-editor/toolbar.tsx +263 -0
- package/src/components/markdown-with-mentions.tsx +183 -0
- package/src/components/message-logs/message-logs.tsx +406 -0
- package/src/components/messages/avatar.tsx +95 -0
- package/src/components/messages/channel-message-list.tsx +177 -0
- package/src/components/messages/channel-view.tsx +74 -0
- package/src/components/messages/message-compose.tsx +162 -0
- package/src/components/messages/message-display.tsx +217 -0
- package/src/components/messages/thread-message-list.tsx +126 -0
- package/src/components/messages/thread-view.tsx +214 -0
- package/src/components/off-canvas.tsx +83 -0
- package/src/components/router.tsx +224 -0
- package/src/components/save-button.tsx +109 -0
- package/src/components/sortable-list.tsx +102 -0
- package/src/components/tabs.tsx +70 -0
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +13 -0
- package/src/components/tooltip.tsx +50 -0
- package/src/components/top-bar.tsx +119 -0
- package/src/components/typeahead/mentions-plugin.tsx +265 -0
- package/src/components/typeahead/typeahead-editor.tsx +140 -0
- package/src/components/typeahead/typeahead.tsx +77 -0
- package/src/components/typeahead.tsx +359 -0
- package/src/globals.tsx +162 -0
- package/src/hooks.ts +144 -0
- package/src/index.tsx +8 -0
- package/src/layout-vars.ts +8 -0
- package/src/mention-configs.ts +166 -0
- package/src/screens/assistants/assistant-config.tsx +80 -0
- package/src/screens/assistants/assistant-details.tsx +77 -0
- package/src/screens/assistants/assistant-info.tsx +45 -0
- package/src/screens/assistants/assistant-list.tsx +115 -0
- package/src/screens/assistants/assistant-tools.tsx +61 -0
- package/src/screens/contacts/contact-details.tsx +175 -0
- package/src/screens/contacts/contact-list.tsx +251 -0
- package/src/screens/contacts/index.ts +6 -0
- package/src/screens/events/cron.ts +74 -0
- package/src/screens/events/event-details.tsx +117 -0
- package/src/screens/events/event-handlers.tsx +61 -0
- package/src/screens/events/event-info.tsx +29 -0
- package/src/screens/events/event-list.tsx +104 -0
- package/src/screens/events/event-schedule.tsx +130 -0
- package/src/screens/groups/group-details.tsx +306 -0
- package/src/screens/groups/group-list.tsx +366 -0
- package/src/screens/groups/group-members.tsx +455 -0
- package/src/screens/groups/index.ts +9 -0
- package/src/screens/knowledge/knowledge-frame-details.bk.tsx +160 -0
- package/src/screens/knowledge/knowledge-frame-details.tsx +176 -0
- package/src/screens/knowledge/knowledge-frame-list.tsx +49 -0
- package/src/screens/knowledge/knowledge-value-details.tsx +181 -0
- package/src/screens/knowledge/knowledge-value-list-item.tsx +48 -0
- package/src/screens/knowledge/knowledge-value-list.tsx +131 -0
- package/src/screens/packages/package-details.tsx +117 -0
- package/src/screens/packages/package-info.tsx +83 -0
- package/src/screens/packages/package-list.tsx +191 -0
- package/src/screens/packages/package-new-local.tsx +93 -0
- package/src/screens/peer-types/peer-type-details.tsx +162 -0
- package/src/screens/peer-types/peer-type-list.tsx +74 -0
- package/src/screens/predicates/predicate-details.tsx +125 -0
- package/src/screens/predicates/predicate-list.tsx +50 -0
- package/src/screens/profile.tsx +68 -0
- package/src/screens/search/global-search.tsx +274 -0
- package/src/screens/settings/color-mode-dropdown.tsx +57 -0
- package/src/screens/settings/settings-page.tsx +76 -0
- package/src/screens/setup-user.tsx +367 -0
- package/src/screens/tools/tool-code.tsx +35 -0
- package/src/screens/tools/tool-details.tsx +101 -0
- package/src/screens/tools/tool-info.tsx +60 -0
- package/src/screens/tools/tool-list.tsx +121 -0
- package/src/screens/tools/tool-schema.tsx +42 -0
- package/src/screens/tools/tool-test-details.tsx +100 -0
- package/src/screens/tools/tool-test-list.tsx +74 -0
- package/src/screens/variables/variable-details.tsx +183 -0
- package/src/screens/variables/variable-list.tsx +74 -0
- package/src/screens/workflows/workflow-details.tsx +130 -0
- package/src/screens/workflows/workflow-info.tsx +29 -0
- package/src/screens/workflows/workflow-instructions.tsx +127 -0
- package/src/screens/workflows/workflow-list.tsx +107 -0
- package/src/screens/workflows/workflow-subscriptions.tsx +58 -0
- package/src/setupTests.ts +32 -0
- package/src/system-apps/assistants.app.ts +7 -0
- package/src/system-apps/contacts.app.ts +8 -0
- package/src/system-apps/events.app.ts +7 -0
- package/src/system-apps/groups.app.ts +8 -0
- package/src/system-apps/index.ts +79 -0
- package/src/system-apps/knowledge-frames.app.ts +8 -0
- package/src/system-apps/knowledge-values.app.ts +8 -0
- package/src/system-apps/packages.app.ts +7 -0
- package/src/system-apps/predicates.app.ts +7 -0
- package/src/system-apps/profile.app.ts +7 -0
- package/src/system-apps/search.app.ts +8 -0
- package/src/system-apps/settings.app.ts +7 -0
- package/src/system-apps/threads.app.ts +7 -0
- package/src/system-apps/tools.app.ts +7 -0
- package/src/system-apps/types.app.ts +7 -0
- package/src/system-apps/variables.app.ts +7 -0
- package/src/system-apps/workflows.app.ts +7 -0
- package/src/tabs-layout/tabs-layout.tsx +672 -0
- package/src/tabs-layout/tabs-state.ts +269 -0
- package/src/three-bar-layout/left-bar-content.tsx +202 -0
- package/src/three-bar-layout/right-bar-content.tsx +67 -0
- package/src/three-bar-layout/three-bar-layout.tsx +297 -0
- package/src/ui-defaults/index.ts +3 -0
- package/src/ui-defaults/list-screen.tsx +92 -0
- package/src/ui-defaults/notes-editor.tsx +51 -0
- package/src/ui-router/routes-loader.ts +98 -0
- package/src/ui-router/ui-loader.tsx +497 -0
- package/src/utils.ts +266 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.MainContentContainer = void 0;
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const react_split_pane_1 = __importDefault(require("react-split-pane"));
|
|
42
|
+
const globals_1 = require("../globals");
|
|
43
|
+
const thread_view_1 = require("./messages/thread-view");
|
|
44
|
+
const router_1 = require("./router");
|
|
45
|
+
const hooks_1 = require("../hooks");
|
|
46
|
+
const MainContentContainer = () => {
|
|
47
|
+
const splitPositionGlobalName = 'mainContentContainerSplitPos';
|
|
48
|
+
let [splitPos, setSplitPos] = (0, react_1.useState)(localStorage.getItem(splitPositionGlobalName) || '800');
|
|
49
|
+
(0, hooks_1.useObservable)(globals_1.threadViewOpen);
|
|
50
|
+
if (!(0, globals_1.threadViewOpen)()) {
|
|
51
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
52
|
+
react_1.default.createElement("button", { className: "btn small m-0 p-0 thread-view-open-button", onClick: () => {
|
|
53
|
+
const lastThread = (0, globals_1.openThreads)()[0];
|
|
54
|
+
if (!lastThread) {
|
|
55
|
+
(0, thread_view_1.startNewThread)();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, globals_1.threadViewOpen)(true);
|
|
59
|
+
}
|
|
60
|
+
}, style: {
|
|
61
|
+
position: 'fixed',
|
|
62
|
+
// top: '3px',
|
|
63
|
+
// right: '16px',
|
|
64
|
+
top: '-5px',
|
|
65
|
+
right: '6px',
|
|
66
|
+
zIndex: 1000,
|
|
67
|
+
// backgroundColor: 'white',
|
|
68
|
+
backgroundColor: 'transparent'
|
|
69
|
+
} }, "+"),
|
|
70
|
+
react_1.default.createElement(router_1.Router, null)));
|
|
71
|
+
}
|
|
72
|
+
return (
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
react_1.default.createElement(react_split_pane_1.default, { split: "vertical", defaultSize: parseInt(splitPos), onChange: (size) => {
|
|
75
|
+
localStorage.setItem(splitPositionGlobalName, String(size));
|
|
76
|
+
setSplitPos(String(size));
|
|
77
|
+
}, style: {
|
|
78
|
+
position: 'unset',
|
|
79
|
+
height: `100vh`,
|
|
80
|
+
} },
|
|
81
|
+
react_1.default.createElement("div", null,
|
|
82
|
+
react_1.default.createElement(router_1.Router, null)),
|
|
83
|
+
react_1.default.createElement("div", { className: 'thread-view', style: {
|
|
84
|
+
height: `100vh`,
|
|
85
|
+
overflowY: 'scroll',
|
|
86
|
+
width: `calc(100vw - ${splitPos}px - 300px)`,
|
|
87
|
+
} },
|
|
88
|
+
react_1.default.createElement(thread_view_1.ThreadContainer, null))));
|
|
89
|
+
};
|
|
90
|
+
exports.MainContentContainer = MainContentContainer;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.LexicalAutoLinkPlugin = LexicalAutoLinkPlugin;
|
|
7
|
+
exports.default = LinkPlugin;
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const LexicalAutoLinkPlugin_1 = require("@lexical/react/LexicalAutoLinkPlugin");
|
|
10
|
+
const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/;
|
|
11
|
+
const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
12
|
+
const MATCHERS = [
|
|
13
|
+
(0, LexicalAutoLinkPlugin_1.createLinkMatcherWithRegExp)(URL_REGEX, (text) => {
|
|
14
|
+
return text.startsWith('http') ? text : `https://${text}`;
|
|
15
|
+
}),
|
|
16
|
+
(0, LexicalAutoLinkPlugin_1.createLinkMatcherWithRegExp)(EMAIL_REGEX, (text) => {
|
|
17
|
+
return `mailto:${text}`;
|
|
18
|
+
}),
|
|
19
|
+
];
|
|
20
|
+
function LexicalAutoLinkPlugin() {
|
|
21
|
+
return react_1.default.createElement(LexicalAutoLinkPlugin_1.AutoLinkPlugin, { matchers: MATCHERS });
|
|
22
|
+
}
|
|
23
|
+
const LexicalLinkPlugin_1 = require("@lexical/react/LexicalLinkPlugin");
|
|
24
|
+
function LinkPlugin() {
|
|
25
|
+
const validateUrl = (url) => {
|
|
26
|
+
return url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:');
|
|
27
|
+
};
|
|
28
|
+
return react_1.default.createElement(LexicalLinkPlugin_1.LinkPlugin, { validateUrl: validateUrl });
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.MarkdownEditorInline = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const editor_1 = require("./editor");
|
|
9
|
+
const MarkdownEditorInline = (props) => {
|
|
10
|
+
return (react_1.default.createElement("div", { className: "border rounded border-dark-subtle" },
|
|
11
|
+
react_1.default.createElement(editor_1.MarkdownEditor, { ...props })));
|
|
12
|
+
};
|
|
13
|
+
exports.MarkdownEditorInline = MarkdownEditorInline;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IToolbarControl } from './toolbar';
|
|
4
|
+
import { IMentionConfig } from '../../mention-configs';
|
|
5
|
+
export interface IEditorEffects {
|
|
6
|
+
onKeyDown?: (e: React.KeyboardEvent) => (boolean | void);
|
|
7
|
+
focus?: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface IMarkdownEditorProps {
|
|
10
|
+
value: Observable<string>;
|
|
11
|
+
effects?: IEditorEffects;
|
|
12
|
+
topRightControls?: IToolbarControl[];
|
|
13
|
+
autoFocus?: boolean;
|
|
14
|
+
hideToolbar?: boolean;
|
|
15
|
+
maxHeight?: string | number;
|
|
16
|
+
mentionConfigs?: IMentionConfig[];
|
|
17
|
+
}
|
|
18
|
+
export declare function MarkdownEditor(props: IMarkdownEditorProps): React.JSX.Element;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.MarkdownEditor = MarkdownEditor;
|
|
40
|
+
const code_1 = require("@lexical/code");
|
|
41
|
+
const link_1 = require("@lexical/link");
|
|
42
|
+
const list_1 = require("@lexical/list");
|
|
43
|
+
const LexicalAutoFocusPlugin_1 = require("@lexical/react/LexicalAutoFocusPlugin");
|
|
44
|
+
const LexicalCheckListPlugin_1 = require("@lexical/react/LexicalCheckListPlugin");
|
|
45
|
+
const LexicalComposer_1 = require("@lexical/react/LexicalComposer");
|
|
46
|
+
const LexicalContentEditable_1 = require("@lexical/react/LexicalContentEditable");
|
|
47
|
+
const LexicalErrorBoundary_1 = require("@lexical/react/LexicalErrorBoundary");
|
|
48
|
+
const LexicalHistoryPlugin_1 = require("@lexical/react/LexicalHistoryPlugin");
|
|
49
|
+
const LexicalListPlugin_1 = require("@lexical/react/LexicalListPlugin");
|
|
50
|
+
const LexicalMarkdownShortcutPlugin_1 = require("@lexical/react/LexicalMarkdownShortcutPlugin");
|
|
51
|
+
const LexicalRichTextPlugin_1 = require("@lexical/react/LexicalRichTextPlugin");
|
|
52
|
+
const LexicalTabIndentationPlugin_1 = require("@lexical/react/LexicalTabIndentationPlugin");
|
|
53
|
+
const rich_text_1 = require("@lexical/rich-text");
|
|
54
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
55
|
+
const react_1 = __importStar(require("react"));
|
|
56
|
+
const autolink_plugin_1 = require("./autolink-plugin");
|
|
57
|
+
const markdown_plugin_1 = require("./markdown-plugin");
|
|
58
|
+
const mention_node_1 = require("./mention-node");
|
|
59
|
+
const mentions_plugin_1 = require("./mentions-plugin");
|
|
60
|
+
const theme_1 = __importDefault(require("./theme"));
|
|
61
|
+
const toolbar_1 = require("./toolbar");
|
|
62
|
+
const lexical_1 = require("lexical");
|
|
63
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
64
|
+
const mention_configs_1 = require("../../mention-configs");
|
|
65
|
+
const editorConfig = {
|
|
66
|
+
namespace: 'PeersEditor',
|
|
67
|
+
nodes: [
|
|
68
|
+
rich_text_1.HeadingNode,
|
|
69
|
+
rich_text_1.QuoteNode,
|
|
70
|
+
code_1.CodeNode,
|
|
71
|
+
list_1.ListNode,
|
|
72
|
+
list_1.ListItemNode,
|
|
73
|
+
mention_node_1.MentionNode,
|
|
74
|
+
link_1.AutoLinkNode,
|
|
75
|
+
link_1.LinkNode,
|
|
76
|
+
],
|
|
77
|
+
// Handling of errors during update
|
|
78
|
+
onError(error) {
|
|
79
|
+
throw error;
|
|
80
|
+
},
|
|
81
|
+
// The editor theme
|
|
82
|
+
theme: theme_1.default,
|
|
83
|
+
};
|
|
84
|
+
function MarkdownEditor(props) {
|
|
85
|
+
const { effects } = props;
|
|
86
|
+
const editorRef = react_1.default.useRef(null);
|
|
87
|
+
const [mentionsOpen] = (0, react_1.useState)(() => {
|
|
88
|
+
const obs = (0, peers_sdk_1.observable)(false);
|
|
89
|
+
return obs;
|
|
90
|
+
});
|
|
91
|
+
if (effects) {
|
|
92
|
+
effects.focus = () => {
|
|
93
|
+
if (editorRef.current?.children[0]) {
|
|
94
|
+
const div = editorRef.current.children[0];
|
|
95
|
+
setTimeout(() => {
|
|
96
|
+
div.focus();
|
|
97
|
+
// Set the selection to the end of the div content
|
|
98
|
+
const range = document.createRange();
|
|
99
|
+
range.selectNodeContents(div);
|
|
100
|
+
range.collapse(false);
|
|
101
|
+
const selection = window.getSelection();
|
|
102
|
+
if (selection) {
|
|
103
|
+
selection.removeAllRanges();
|
|
104
|
+
selection.addRange(range);
|
|
105
|
+
}
|
|
106
|
+
}, 10);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const _mentionConfigs = props.mentionConfigs ?? mention_configs_1.mentionConfigs;
|
|
111
|
+
return (react_1.default.createElement(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig } },
|
|
112
|
+
react_1.default.createElement("div", { className: "editor-container" },
|
|
113
|
+
props.hideToolbar ? null : react_1.default.createElement(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }),
|
|
114
|
+
react_1.default.createElement("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: 'auto' } },
|
|
115
|
+
react_1.default.createElement(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: react_1.default.createElement(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }),
|
|
116
|
+
react_1.default.createElement(LexicalHistoryPlugin_1.HistoryPlugin, null),
|
|
117
|
+
props.autoFocus && react_1.default.createElement(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: 'rootEnd' }),
|
|
118
|
+
react_1.default.createElement(LexicalListPlugin_1.ListPlugin, null),
|
|
119
|
+
_mentionConfigs.length > 0 && (react_1.default.createElement(mentions_plugin_1.MentionsPlugin, { mentionConfigs: _mentionConfigs, mentionsOpen: mentionsOpen })),
|
|
120
|
+
react_1.default.createElement(autolink_plugin_1.LexicalAutoLinkPlugin, null),
|
|
121
|
+
react_1.default.createElement(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value }),
|
|
122
|
+
react_1.default.createElement(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: markdown_plugin_1.customMarkdownTransformers }),
|
|
123
|
+
react_1.default.createElement(LexicalCheckListPlugin_1.CheckListPlugin, null),
|
|
124
|
+
react_1.default.createElement(LexicalTabIndentationPlugin_1.TabIndentationPlugin, null),
|
|
125
|
+
react_1.default.createElement(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen })))));
|
|
126
|
+
}
|
|
127
|
+
const OnKeyDownPlugin = (props) => {
|
|
128
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
129
|
+
(0, react_1.useEffect)(() => {
|
|
130
|
+
const removeListener = editor.registerCommand(lexical_1.KEY_DOWN_COMMAND, (event) => {
|
|
131
|
+
if (props.mentionsOpen()) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
if (props.effects?.onKeyDown) {
|
|
135
|
+
const result = props.effects.onKeyDown(event);
|
|
136
|
+
return !!result;
|
|
137
|
+
}
|
|
138
|
+
return false;
|
|
139
|
+
}, lexical_1.COMMAND_PRIORITY_LOW);
|
|
140
|
+
return removeListener;
|
|
141
|
+
}, [editor]);
|
|
142
|
+
return null;
|
|
143
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ElementTransformer } from "@lexical/markdown";
|
|
2
|
+
import { Observable } from "@peers-app/peers-sdk";
|
|
3
|
+
export declare const PRESERVE_NEWLINES: ElementTransformer;
|
|
4
|
+
export declare const customMarkdownTransformers: import("@lexical/markdown").Transformer[];
|
|
5
|
+
interface IProps {
|
|
6
|
+
markdownObs: Observable<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare function MarkdownPlugin(props: IProps): null;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customMarkdownTransformers = exports.PRESERVE_NEWLINES = void 0;
|
|
4
|
+
exports.MarkdownPlugin = MarkdownPlugin;
|
|
5
|
+
const list_1 = require("@lexical/list");
|
|
6
|
+
const markdown_1 = require("@lexical/markdown");
|
|
7
|
+
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
8
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
9
|
+
const lexical_1 = require("lexical");
|
|
10
|
+
const react_1 = require("react");
|
|
11
|
+
const mention_node_1 = require("./mention-node");
|
|
12
|
+
// Amount of spaces that define indentation level
|
|
13
|
+
const LIST_INDENT_SIZE = 4;
|
|
14
|
+
function getIndent(whitespaces) {
|
|
15
|
+
const tabs = whitespaces.match(/\t/g);
|
|
16
|
+
const spaces = whitespaces.match(/ /g);
|
|
17
|
+
let indent = 0;
|
|
18
|
+
if (tabs) {
|
|
19
|
+
indent += tabs.length;
|
|
20
|
+
}
|
|
21
|
+
if (spaces) {
|
|
22
|
+
indent += Math.floor(spaces.length / LIST_INDENT_SIZE);
|
|
23
|
+
}
|
|
24
|
+
return indent;
|
|
25
|
+
}
|
|
26
|
+
const listReplace = (listType) => {
|
|
27
|
+
return (parentNode, children, match) => {
|
|
28
|
+
const previousNode = parentNode.getPreviousSibling();
|
|
29
|
+
const nextNode = parentNode.getNextSibling();
|
|
30
|
+
const listItem = (0, list_1.$createListItemNode)(listType === 'check' ? match[3] === 'x' : undefined);
|
|
31
|
+
if ((0, list_1.$isListNode)(nextNode) && nextNode.getListType() === listType) {
|
|
32
|
+
const firstChild = nextNode.getFirstChild();
|
|
33
|
+
if (firstChild !== null) {
|
|
34
|
+
firstChild.insertBefore(listItem);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// should never happen, but let's handle gracefully, just in case.
|
|
38
|
+
nextNode.append(listItem);
|
|
39
|
+
}
|
|
40
|
+
parentNode.remove();
|
|
41
|
+
}
|
|
42
|
+
else if ((0, list_1.$isListNode)(previousNode) &&
|
|
43
|
+
previousNode.getListType() === listType) {
|
|
44
|
+
previousNode.append(listItem);
|
|
45
|
+
parentNode.remove();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const list = (0, list_1.$createListNode)(listType, listType === 'number' ? Number(match[2]) : undefined);
|
|
49
|
+
list.append(listItem);
|
|
50
|
+
parentNode.replace(list);
|
|
51
|
+
}
|
|
52
|
+
listItem.append(...children);
|
|
53
|
+
listItem.select(0, 0);
|
|
54
|
+
const indent = getIndent(match[1]);
|
|
55
|
+
if (indent) {
|
|
56
|
+
listItem.setIndent(indent);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const listExport = (listNode, exportChildren, depth) => {
|
|
61
|
+
const output = [];
|
|
62
|
+
const children = listNode.getChildren();
|
|
63
|
+
let index = 0;
|
|
64
|
+
for (const listItemNode of children) {
|
|
65
|
+
if ((0, list_1.$isListItemNode)(listItemNode)) {
|
|
66
|
+
if (listItemNode.getChildrenSize() === 1) {
|
|
67
|
+
const firstChild = listItemNode.getFirstChild();
|
|
68
|
+
if ((0, list_1.$isListNode)(firstChild)) {
|
|
69
|
+
output.push(listExport(firstChild, exportChildren, depth + 1));
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const indent = ' '.repeat(depth * LIST_INDENT_SIZE);
|
|
74
|
+
const listType = listNode.getListType();
|
|
75
|
+
const prefix = listType === 'number'
|
|
76
|
+
? `${listNode.getStart() + index}. `
|
|
77
|
+
: listType === 'check'
|
|
78
|
+
? `- [${listItemNode.getChecked() ? 'x' : ' '}] `
|
|
79
|
+
: '- ';
|
|
80
|
+
output.push(indent + prefix + exportChildren(listItemNode));
|
|
81
|
+
index++;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return output.join('\n');
|
|
85
|
+
};
|
|
86
|
+
const CHECK_LIST_TRANSFORMER = {
|
|
87
|
+
dependencies: [list_1.ListNode, list_1.ListItemNode],
|
|
88
|
+
export: (node, exportChildren) => {
|
|
89
|
+
return (0, list_1.$isListNode)(node) ? listExport(node, exportChildren, 0) : null;
|
|
90
|
+
},
|
|
91
|
+
regExp: /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,
|
|
92
|
+
replace: listReplace('check'),
|
|
93
|
+
type: 'element',
|
|
94
|
+
};
|
|
95
|
+
const MENTION_TRANSFORMER = {
|
|
96
|
+
type: 'text-match',
|
|
97
|
+
trigger: '<',
|
|
98
|
+
dependencies: [mention_node_1.MentionNode],
|
|
99
|
+
importRegExp: (0, peers_sdk_1.mentionRegex)(),
|
|
100
|
+
regExp: (0, peers_sdk_1.mentionRegex)(),
|
|
101
|
+
export: (node) => {
|
|
102
|
+
if ((0, mention_node_1.$isMentionNode)(node)) {
|
|
103
|
+
return (0, peers_sdk_1.formatMention)(node.data);
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
},
|
|
107
|
+
replace: (textNode, match) => {
|
|
108
|
+
const kind = match[2];
|
|
109
|
+
const name = match[3].replace(/_/g, ' ');
|
|
110
|
+
const id = match[4];
|
|
111
|
+
const data = {
|
|
112
|
+
kind: kind,
|
|
113
|
+
name,
|
|
114
|
+
id,
|
|
115
|
+
clickable: false,
|
|
116
|
+
};
|
|
117
|
+
const node = (0, mention_node_1.$createMentionNode)(data);
|
|
118
|
+
textNode.replace(node);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
exports.PRESERVE_NEWLINES = {
|
|
122
|
+
type: 'element',
|
|
123
|
+
dependencies: [lexical_1.ParagraphNode],
|
|
124
|
+
export: (node) => {
|
|
125
|
+
if ((0, lexical_1.$isParagraphNode)(node)) {
|
|
126
|
+
const content = node.getTextContent();
|
|
127
|
+
if (!content.trim()) {
|
|
128
|
+
return '\n \n';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return null;
|
|
132
|
+
},
|
|
133
|
+
regExp: /^ $/, // a line with only a space
|
|
134
|
+
replace: (textNode, nodes, _, isImport) => {
|
|
135
|
+
if (isImport && nodes.length === 1) {
|
|
136
|
+
textNode.append((0, lexical_1.$createTextNode)(''));
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
exports.customMarkdownTransformers = [
|
|
141
|
+
exports.PRESERVE_NEWLINES,
|
|
142
|
+
MENTION_TRANSFORMER,
|
|
143
|
+
CHECK_LIST_TRANSFORMER, // This needs to be first or checklists will be treated as unordered lists
|
|
144
|
+
...markdown_1.TRANSFORMERS.filter(transformer => {
|
|
145
|
+
const t = transformer;
|
|
146
|
+
// disable headings for this markdown since these are inline messages
|
|
147
|
+
if (t.dependencies?.[0]?.name === 'HeadingNode') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
return true;
|
|
151
|
+
}),
|
|
152
|
+
];
|
|
153
|
+
function MarkdownPlugin(props) {
|
|
154
|
+
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
155
|
+
const { markdownObs } = props;
|
|
156
|
+
(0, react_1.useEffect)(() => {
|
|
157
|
+
let markdown = '';
|
|
158
|
+
function setMarkdown() {
|
|
159
|
+
const newMarkdown = markdownObs() || '';
|
|
160
|
+
if (newMarkdown === markdown) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
markdown = newMarkdown;
|
|
164
|
+
editor.update(() => {
|
|
165
|
+
const shouldPreserveNewLines = false;
|
|
166
|
+
const shouldMergeAdjacentLines = false;
|
|
167
|
+
(0, markdown_1.$convertFromMarkdownString)(markdown, exports.customMarkdownTransformers, undefined, shouldPreserveNewLines, shouldMergeAdjacentLines);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
setMarkdown();
|
|
171
|
+
const sub = markdownObs.subscribe(() => {
|
|
172
|
+
setMarkdown();
|
|
173
|
+
});
|
|
174
|
+
const sub2Dispose = editor.registerUpdateListener(({ editorState }) => {
|
|
175
|
+
editor.update(() => {
|
|
176
|
+
const shouldPreserveNewLines = false;
|
|
177
|
+
let newMarkdown = (0, markdown_1.$convertToMarkdownString)(exports.customMarkdownTransformers, undefined, shouldPreserveNewLines);
|
|
178
|
+
newMarkdown = newMarkdown.replace(/\n\n\n \n\n\n/gm, '\n\n \n\n');
|
|
179
|
+
if (newMarkdown === "\n \n") {
|
|
180
|
+
newMarkdown = '';
|
|
181
|
+
}
|
|
182
|
+
if (newMarkdown !== markdown) {
|
|
183
|
+
markdown = newMarkdown;
|
|
184
|
+
markdownObs(markdown);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
return () => {
|
|
189
|
+
sub.dispose();
|
|
190
|
+
sub2Dispose();
|
|
191
|
+
};
|
|
192
|
+
}, [editor]);
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalNode, type NodeKey, type SerializedTextNode, type Spread, TextNode } from 'lexical';
|
|
2
|
+
import { IMentionData } from "@peers-app/peers-sdk";
|
|
3
|
+
export type SerializedMentionNode = Spread<{
|
|
4
|
+
data: IMentionData;
|
|
5
|
+
}, SerializedTextNode>;
|
|
6
|
+
export declare class MentionNode extends TextNode {
|
|
7
|
+
readonly data: IMentionData;
|
|
8
|
+
static getType(): string;
|
|
9
|
+
static clone(node: MentionNode): MentionNode;
|
|
10
|
+
static importJSON(serializedNode: SerializedMentionNode): MentionNode;
|
|
11
|
+
constructor(data: IMentionData, key?: NodeKey);
|
|
12
|
+
exportJSON(): SerializedMentionNode;
|
|
13
|
+
createDOM(config: EditorConfig): HTMLElement;
|
|
14
|
+
exportDOM(): DOMExportOutput;
|
|
15
|
+
static importDOM(): DOMConversionMap | null;
|
|
16
|
+
isTextEntity(): true;
|
|
17
|
+
canInsertTextBefore(): boolean;
|
|
18
|
+
canInsertTextAfter(): boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function $createMentionNode(data: IMentionData): MentionNode;
|
|
21
|
+
export declare function $isMentionNode(node: LexicalNode | null | undefined): node is MentionNode;
|