@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,224 @@
|
|
|
1
|
+
import { $createListItemNode, $createListNode, $isListItemNode, $isListNode, ListItemNode, ListNode, ListType } from '@lexical/list';
|
|
2
|
+
import { $convertFromMarkdownString, $convertToMarkdownString, ElementTransformer, TextMatchTransformer, TRANSFORMERS } from "@lexical/markdown";
|
|
3
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
+
import { formatMention, IMentionData, mentionRegex, Observable } from "@peers-app/peers-sdk";
|
|
5
|
+
import { $createTextNode, $isParagraphNode, ParagraphNode } from 'lexical';
|
|
6
|
+
import { useEffect } from 'react';
|
|
7
|
+
import { $createMentionNode, $isMentionNode, MentionNode } from './mention-node';
|
|
8
|
+
|
|
9
|
+
// Amount of spaces that define indentation level
|
|
10
|
+
const LIST_INDENT_SIZE = 4;
|
|
11
|
+
|
|
12
|
+
function getIndent(whitespaces: string): number {
|
|
13
|
+
const tabs = whitespaces.match(/\t/g);
|
|
14
|
+
const spaces = whitespaces.match(/ /g);
|
|
15
|
+
let indent = 0;
|
|
16
|
+
if (tabs) {
|
|
17
|
+
indent += tabs.length;
|
|
18
|
+
}
|
|
19
|
+
if (spaces) {
|
|
20
|
+
indent += Math.floor(spaces.length / LIST_INDENT_SIZE);
|
|
21
|
+
}
|
|
22
|
+
return indent;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const listReplace = (listType: ListType): ElementTransformer['replace'] => {
|
|
26
|
+
return (parentNode, children, match) => {
|
|
27
|
+
const previousNode = parentNode.getPreviousSibling();
|
|
28
|
+
const nextNode = parentNode.getNextSibling();
|
|
29
|
+
const listItem = $createListItemNode(
|
|
30
|
+
listType === 'check' ? match[3] === 'x' : undefined,
|
|
31
|
+
);
|
|
32
|
+
if ($isListNode(nextNode) && nextNode.getListType() === listType) {
|
|
33
|
+
const firstChild = nextNode.getFirstChild();
|
|
34
|
+
if (firstChild !== null) {
|
|
35
|
+
firstChild.insertBefore(listItem);
|
|
36
|
+
} else {
|
|
37
|
+
// should never happen, but let's handle gracefully, just in case.
|
|
38
|
+
nextNode.append(listItem);
|
|
39
|
+
}
|
|
40
|
+
parentNode.remove();
|
|
41
|
+
} else if (
|
|
42
|
+
$isListNode(previousNode) &&
|
|
43
|
+
previousNode.getListType() === listType
|
|
44
|
+
) {
|
|
45
|
+
previousNode.append(listItem);
|
|
46
|
+
parentNode.remove();
|
|
47
|
+
} else {
|
|
48
|
+
const list = $createListNode(
|
|
49
|
+
listType,
|
|
50
|
+
listType === 'number' ? Number(match[2]) : undefined,
|
|
51
|
+
);
|
|
52
|
+
list.append(listItem);
|
|
53
|
+
parentNode.replace(list);
|
|
54
|
+
}
|
|
55
|
+
listItem.append(...children);
|
|
56
|
+
listItem.select(0, 0);
|
|
57
|
+
const indent = getIndent(match[1]);
|
|
58
|
+
if (indent) {
|
|
59
|
+
listItem.setIndent(indent);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const listExport = (
|
|
65
|
+
listNode: ListNode,
|
|
66
|
+
exportChildren: (node: ListItemNode) => string,
|
|
67
|
+
depth: number,
|
|
68
|
+
): string => {
|
|
69
|
+
const output = [];
|
|
70
|
+
const children = listNode.getChildren();
|
|
71
|
+
let index = 0;
|
|
72
|
+
for (const listItemNode of children) {
|
|
73
|
+
if ($isListItemNode(listItemNode)) {
|
|
74
|
+
if (listItemNode.getChildrenSize() === 1) {
|
|
75
|
+
const firstChild = listItemNode.getFirstChild();
|
|
76
|
+
if ($isListNode(firstChild)) {
|
|
77
|
+
output.push(listExport(firstChild, exportChildren, depth + 1));
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const indent = ' '.repeat(depth * LIST_INDENT_SIZE);
|
|
82
|
+
const listType = listNode.getListType();
|
|
83
|
+
const prefix =
|
|
84
|
+
listType === 'number'
|
|
85
|
+
? `${listNode.getStart() + index}. `
|
|
86
|
+
: listType === 'check'
|
|
87
|
+
? `- [${listItemNode.getChecked() ? 'x' : ' '}] `
|
|
88
|
+
: '- ';
|
|
89
|
+
output.push(indent + prefix + exportChildren(listItemNode));
|
|
90
|
+
index++;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return output.join('\n');
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const CHECK_LIST_TRANSFORMER: ElementTransformer = {
|
|
98
|
+
dependencies: [ListNode, ListItemNode],
|
|
99
|
+
export: (node, exportChildren) => {
|
|
100
|
+
return $isListNode(node) ? listExport(node, exportChildren, 0) : null;
|
|
101
|
+
},
|
|
102
|
+
regExp: /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,
|
|
103
|
+
replace: listReplace('check'),
|
|
104
|
+
type: 'element',
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const MENTION_TRANSFORMER: TextMatchTransformer = {
|
|
108
|
+
type: 'text-match',
|
|
109
|
+
trigger: '<',
|
|
110
|
+
dependencies: [MentionNode],
|
|
111
|
+
importRegExp: mentionRegex(),
|
|
112
|
+
regExp: mentionRegex(),
|
|
113
|
+
export: (node) => {
|
|
114
|
+
if ($isMentionNode(node)) {
|
|
115
|
+
return formatMention(node.data);
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
},
|
|
119
|
+
replace: (textNode, match) => {
|
|
120
|
+
const kind = match[2];
|
|
121
|
+
const name = match[3].replace(/_/g, ' ');
|
|
122
|
+
const id = match[4];
|
|
123
|
+
const data: IMentionData = {
|
|
124
|
+
kind: kind as any,
|
|
125
|
+
name,
|
|
126
|
+
id,
|
|
127
|
+
clickable: false,
|
|
128
|
+
};
|
|
129
|
+
const node = $createMentionNode(data);
|
|
130
|
+
textNode.replace(node);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const PRESERVE_NEWLINES: ElementTransformer = {
|
|
135
|
+
type: 'element',
|
|
136
|
+
dependencies: [ParagraphNode],
|
|
137
|
+
export: (node) => {
|
|
138
|
+
if ($isParagraphNode(node)) {
|
|
139
|
+
const content = node.getTextContent();
|
|
140
|
+
if (!content.trim()) {
|
|
141
|
+
return '\n \n';
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return null;
|
|
145
|
+
},
|
|
146
|
+
regExp: /^ $/, // a line with only a space
|
|
147
|
+
replace: (textNode, nodes, _, isImport) => {
|
|
148
|
+
if (isImport && nodes.length === 1) {
|
|
149
|
+
textNode.append($createTextNode(''));
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const customMarkdownTransformers = [
|
|
155
|
+
PRESERVE_NEWLINES,
|
|
156
|
+
MENTION_TRANSFORMER,
|
|
157
|
+
CHECK_LIST_TRANSFORMER, // This needs to be first or checklists will be treated as unordered lists
|
|
158
|
+
...TRANSFORMERS.filter(transformer => {
|
|
159
|
+
const t = transformer as any;
|
|
160
|
+
// disable headings for this markdown since these are inline messages
|
|
161
|
+
if (t.dependencies?.[0]?.name === 'HeadingNode') {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
return true;
|
|
165
|
+
}),
|
|
166
|
+
];
|
|
167
|
+
|
|
168
|
+
interface IProps {
|
|
169
|
+
markdownObs: Observable<string>;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function MarkdownPlugin(props: IProps) {
|
|
173
|
+
const [editor] = useLexicalComposerContext();
|
|
174
|
+
const { markdownObs } = props;
|
|
175
|
+
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
|
|
178
|
+
let markdown = '';
|
|
179
|
+
|
|
180
|
+
function setMarkdown() {
|
|
181
|
+
const newMarkdown = markdownObs() || '';
|
|
182
|
+
if (newMarkdown === markdown) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
markdown = newMarkdown;
|
|
186
|
+
editor.update(() => {
|
|
187
|
+
const shouldPreserveNewLines = false;
|
|
188
|
+
const shouldMergeAdjacentLines = false;
|
|
189
|
+
$convertFromMarkdownString(markdown, customMarkdownTransformers, undefined, shouldPreserveNewLines, shouldMergeAdjacentLines);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
setMarkdown();
|
|
194
|
+
|
|
195
|
+
const sub = markdownObs.subscribe(() => {
|
|
196
|
+
setMarkdown();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const sub2Dispose = editor.registerUpdateListener(({ editorState }) => {
|
|
200
|
+
editor.update(() => {
|
|
201
|
+
const shouldPreserveNewLines = false;
|
|
202
|
+
let newMarkdown = $convertToMarkdownString(customMarkdownTransformers, undefined, shouldPreserveNewLines);
|
|
203
|
+
newMarkdown = newMarkdown.replace(/\n\n\n \n\n\n/gm, '\n\n \n\n');
|
|
204
|
+
if (newMarkdown === "\n \n") {
|
|
205
|
+
newMarkdown = '';
|
|
206
|
+
}
|
|
207
|
+
if (newMarkdown !== markdown) {
|
|
208
|
+
markdown = newMarkdown;
|
|
209
|
+
markdownObs(markdown);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
return () => {
|
|
216
|
+
sub.dispose();
|
|
217
|
+
sub2Dispose();
|
|
218
|
+
}
|
|
219
|
+
}, [editor]);
|
|
220
|
+
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$applyNodeReplacement,
|
|
3
|
+
type DOMConversionMap,
|
|
4
|
+
type DOMConversionOutput,
|
|
5
|
+
type DOMExportOutput,
|
|
6
|
+
type EditorConfig,
|
|
7
|
+
type LexicalNode,
|
|
8
|
+
type NodeKey,
|
|
9
|
+
type SerializedTextNode,
|
|
10
|
+
type Spread,
|
|
11
|
+
TextNode,
|
|
12
|
+
} from 'lexical';
|
|
13
|
+
import { IMentionData } from "@peers-app/peers-sdk";
|
|
14
|
+
import { mainContentPath } from '../../globals';
|
|
15
|
+
import { mentionConfigs } from '../../mention-configs';
|
|
16
|
+
|
|
17
|
+
export type SerializedMentionNode = Spread<
|
|
18
|
+
{
|
|
19
|
+
data: IMentionData;
|
|
20
|
+
},
|
|
21
|
+
SerializedTextNode
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
function $convertMentionElement(
|
|
25
|
+
domNode: HTMLElement,
|
|
26
|
+
): DOMConversionOutput | null {
|
|
27
|
+
const mentionName = domNode.textContent?.substring(1);
|
|
28
|
+
const dataKind = domNode.getAttribute('data-kind') ?? '';
|
|
29
|
+
const dataId = domNode.getAttribute('data-id') ?? '';
|
|
30
|
+
const clickable = domNode.getAttribute('data-clickable');
|
|
31
|
+
|
|
32
|
+
if (mentionName && dataId) {
|
|
33
|
+
const data: IMentionData = {
|
|
34
|
+
kind: dataKind as any,
|
|
35
|
+
name: mentionName,
|
|
36
|
+
id: dataId,
|
|
37
|
+
clickable: clickable === 'true' ? true : clickable === 'false' ? false : undefined,
|
|
38
|
+
};
|
|
39
|
+
const node = $createMentionNode(data);
|
|
40
|
+
return {
|
|
41
|
+
node,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class MentionNode extends TextNode {
|
|
49
|
+
|
|
50
|
+
static getType(): string {
|
|
51
|
+
return 'mention';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
static clone(node: MentionNode): MentionNode {
|
|
55
|
+
return new MentionNode(node.data, node.__key);
|
|
56
|
+
}
|
|
57
|
+
static importJSON(serializedNode: SerializedMentionNode): MentionNode {
|
|
58
|
+
const node = $createMentionNode(serializedNode.data);
|
|
59
|
+
// node.setTextContent('@' + serializedNode.text);
|
|
60
|
+
node.setTextContent(serializedNode.text);
|
|
61
|
+
node.setFormat(serializedNode.format);
|
|
62
|
+
node.setDetail(serializedNode.detail);
|
|
63
|
+
node.setMode(serializedNode.mode);
|
|
64
|
+
node.setStyle(serializedNode.style);
|
|
65
|
+
return node;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor(
|
|
69
|
+
public readonly data: IMentionData,
|
|
70
|
+
key?: NodeKey
|
|
71
|
+
) {
|
|
72
|
+
// const prefix = (data.kind === 'assistant' || data.kind === 'user') ? '@' : '$';
|
|
73
|
+
const prefix = data.kind === 'user' ? '@' : '';
|
|
74
|
+
super(prefix + data.name, key);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
exportJSON(): SerializedMentionNode {
|
|
78
|
+
return {
|
|
79
|
+
...super.exportJSON(),
|
|
80
|
+
type: 'mention',
|
|
81
|
+
version: 1,
|
|
82
|
+
data: this.data,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
createDOM(config: EditorConfig): HTMLElement {
|
|
87
|
+
const dom = super.createDOM(config);
|
|
88
|
+
|
|
89
|
+
const kind = this.data.kind;
|
|
90
|
+
const mentionConfig = mentionConfigs.find(c => c.kind === kind);
|
|
91
|
+
|
|
92
|
+
if (mentionConfig) {
|
|
93
|
+
dom.className = mentionConfig.styleClass || 'mention-default-default';
|
|
94
|
+
} else {
|
|
95
|
+
dom.className = `mention-${this.data.kind}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
dom.textContent = this.__text;
|
|
99
|
+
dom.setAttribute('data-kind', this.data.kind);
|
|
100
|
+
dom.setAttribute('data-id', this.data.id);
|
|
101
|
+
dom.setAttribute('data-clickable', this.data.clickable === undefined ? '' : String(this.data.clickable));
|
|
102
|
+
|
|
103
|
+
// currently ignoring `clickable` attribute
|
|
104
|
+
// if (this.data.clickable !== false) {...
|
|
105
|
+
const onClick = mentionConfig?.onClick;
|
|
106
|
+
dom.style.cursor = 'pointer';
|
|
107
|
+
dom.addEventListener('click', () => {
|
|
108
|
+
if (onClick) {
|
|
109
|
+
onClick(this.data);
|
|
110
|
+
} else {
|
|
111
|
+
const id = this.data.id;
|
|
112
|
+
const href = `#${kind}s/${id}`;
|
|
113
|
+
mainContentPath(href);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (mentionConfig && kind !== 'user') {
|
|
118
|
+
const iconSpan = document.createElement('i');
|
|
119
|
+
iconSpan.className = 'pe-1 ' + mentionConfig.iconClass;
|
|
120
|
+
dom.prepend(iconSpan);
|
|
121
|
+
return dom;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// else if (kind === 'task') {
|
|
125
|
+
// const ckbx = document.createElement('input');
|
|
126
|
+
// ckbx.type = 'checkbox';
|
|
127
|
+
// ckbx.className = 'me-1';
|
|
128
|
+
// const taskId = this.data.id;
|
|
129
|
+
// Tasks().get(taskId).then(task => {
|
|
130
|
+
// if (!task) return;
|
|
131
|
+
// ckbx.checked = !!task.completeDT;
|
|
132
|
+
// ckbx.addEventListener('change', () => {
|
|
133
|
+
// task.completeDT = ckbx.checked ? new Date() : undefined;
|
|
134
|
+
// Tasks().update(task);
|
|
135
|
+
// });
|
|
136
|
+
// });
|
|
137
|
+
// const sub = Tasks().dataChanged.subscribe(evt => {
|
|
138
|
+
// const task = evt.dataObject as ITask;
|
|
139
|
+
// if (!task || task.taskId !== taskId) return;
|
|
140
|
+
// if (!document.body.contains(ckbx)) {
|
|
141
|
+
// sub.unsubscribe();
|
|
142
|
+
// } else {
|
|
143
|
+
// ckbx.checked = !!task.completeDT;
|
|
144
|
+
// }
|
|
145
|
+
// });
|
|
146
|
+
// dom.prepend(ckbx);
|
|
147
|
+
// }
|
|
148
|
+
|
|
149
|
+
return dom;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
exportDOM(): DOMExportOutput {
|
|
153
|
+
const element = document.createElement('span');
|
|
154
|
+
element.setAttribute('data-lexical-mention', 'true');
|
|
155
|
+
element.textContent = this.__text;
|
|
156
|
+
element.setAttribute('data-kind', this.data.kind);
|
|
157
|
+
element.setAttribute('data-id', this.data.id);
|
|
158
|
+
element.setAttribute('data-clickable', this.data.clickable === undefined ? '' : String(this.data.clickable));
|
|
159
|
+
return { element };
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static importDOM(): DOMConversionMap | null {
|
|
163
|
+
return {
|
|
164
|
+
span: (domNode: HTMLElement) => {
|
|
165
|
+
if (!domNode.hasAttribute('data-lexical-mention')) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
conversion: $convertMentionElement,
|
|
170
|
+
priority: 1,
|
|
171
|
+
};
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
isTextEntity(): true {
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
canInsertTextBefore(): boolean {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
canInsertTextAfter(): boolean {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function $createMentionNode(data: IMentionData): MentionNode {
|
|
190
|
+
const mentionNode = new MentionNode(data);
|
|
191
|
+
mentionNode.setMode('segmented').toggleDirectionless();
|
|
192
|
+
return $applyNodeReplacement(mentionNode);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function $isMentionNode(
|
|
196
|
+
node: LexicalNode | null | undefined,
|
|
197
|
+
): node is MentionNode {
|
|
198
|
+
return node instanceof MentionNode;
|
|
199
|
+
}
|