From 2220d7e19efda011c7dfa2df9b7bf45f7bfe534c Mon Sep 17 00:00:00 2001 From: Alexander Onnikov Date: Mon, 15 Apr 2024 18:11:47 +0700 Subject: [PATCH] UBERF-6068 Show collaborators in collaborative editors (#5335) Signed-off-by: Alexander Onnikov --- common/config/rush/pnpm-lock.yaml | 2 +- packages/panel/package.json | 1 - packages/text-editor/package.json | 1 - .../components/CollaborationUserPopup.svelte | 4 +- .../src/components/CollaborationUsers.svelte | 97 +++++++++++++++++++ .../CollaborativeAttributeBox.svelte | 9 +- .../CollaborativeAttributeSectionBox.svelte | 15 ++- .../components/CollaborativeTextEditor.svelte | 20 +++- .../src/components/CollaboratorEditor.svelte | 9 +- .../src/components/editor/collaboration.ts | 6 +- packages/text-editor/src/provider/tiptap.ts | 2 +- packages/text-editor/src/types.ts | 23 ++++- packages/text-editor/src/utils.ts | 37 ------- packages/ui/src/utils.ts | 16 +++ .../AttachmentStyleBoxCollabEditor.svelte | 15 ++- plugins/contact-resources/package.json | 3 +- .../src/components/AccountArrayEditor.svelte | 1 + .../components/CollaborationUserAvatar.svelte | 43 ++++++++ plugins/contact-resources/src/index.ts | 2 + plugins/contact/src/index.ts | 3 +- .../src/components/DocumentEditor.svelte | 14 ++- .../components/CollaborativeDocEditor.svelte | 13 ++- .../components/CollaborativeHTMLEditor.svelte | 13 ++- plugins/view-resources/src/utils.ts | 16 ++- 24 files changed, 296 insertions(+), 69 deletions(-) create mode 100644 packages/text-editor/src/components/CollaborationUsers.svelte create mode 100644 plugins/contact-resources/src/components/CollaborationUserAvatar.svelte diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 71709607f4..5a5de3ac26 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -20650,7 +20650,7 @@ packages: dev: false file:projects/panel.tgz(@types/node@20.11.19)(esbuild@0.20.1)(postcss-load-config@4.0.2)(postcss@8.4.35)(ts-node@10.9.2): - resolution: {integrity: sha512-P4H97igqWddz9UBNpLY742cNaADue6UfT+1y00SNB/MmJE7qop/lttaCMAvFXgZJ4HvlN7d18II/AHpMZAnABg==, tarball: file:projects/panel.tgz} + resolution: {integrity: sha512-cFoTjnZ6mHJtNSppmfDuDx2wE5B4xGLxee96kAfHWSufWMYuHF69977P0VSlDEen1iXSNu2jQAWUux7wiEaKQQ==, tarball: file:projects/panel.tgz} id: file:projects/panel.tgz name: '@rush-temp/panel' version: 0.0.0 diff --git a/packages/panel/package.json b/packages/panel/package.json index ef81d544e9..18f5ba963f 100644 --- a/packages/panel/package.json +++ b/packages/panel/package.json @@ -39,7 +39,6 @@ }, "dependencies": { "@hcengineering/ui": "^0.6.11", - "@hcengineering/text-editor": "^0.6.0", "svelte": "^4.2.12", "@hcengineering/platform": "^0.6.9", "@hcengineering/core": "^0.6.28", diff --git a/packages/text-editor/package.json b/packages/text-editor/package.json index f5e3beab9b..6adab64652 100644 --- a/packages/text-editor/package.json +++ b/packages/text-editor/package.json @@ -41,7 +41,6 @@ "@hcengineering/presentation": "^0.6.2", "@hcengineering/platform": "^0.6.9", "@hcengineering/core": "^0.6.28", - "@hcengineering/contact": "^0.6.20", "@hcengineering/ui": "^0.6.11", "@hcengineering/view": "^0.6.9", "@hcengineering/text": "^0.6.1", diff --git a/packages/text-editor/src/components/CollaborationUserPopup.svelte b/packages/text-editor/src/components/CollaborationUserPopup.svelte index 87574b8c5b..f1d3c2753b 100644 --- a/packages/text-editor/src/components/CollaborationUserPopup.svelte +++ b/packages/text-editor/src/components/CollaborationUserPopup.svelte @@ -15,7 +15,7 @@ // --> + +{#if states.length > 0} +
+ {#each states as state} + + {/each} +
+{/if} + + diff --git a/packages/text-editor/src/components/CollaborativeAttributeBox.svelte b/packages/text-editor/src/components/CollaborativeAttributeBox.svelte index 4ff86576ab..e184433fdc 100644 --- a/packages/text-editor/src/components/CollaborativeAttributeBox.svelte +++ b/packages/text-editor/src/components/CollaborativeAttributeBox.svelte @@ -16,12 +16,12 @@ import core, { CollaborativeDoc, Doc, getCollaborativeDoc, getCollaborativeDocId } from '@hcengineering/core' import { IntlString } from '@hcengineering/platform' import { KeyedAttribute, getAttribute, getClient } from '@hcengineering/presentation' - import { registerFocus } from '@hcengineering/ui' + import { AnySvelteComponent, registerFocus } from '@hcengineering/ui' import CollaborativeTextEditor from './CollaborativeTextEditor.svelte' import { FocusExtension } from './extension/focus' import { type FileAttachFunction } from './extension/types' import textEditorPlugin from '../plugin' - import { RefAction, TextNodeAction } from '../types' + import { CollaborationUser, RefAction, TextNodeAction } from '../types' export let object: Doc export let key: KeyedAttribute @@ -29,6 +29,9 @@ export let textNodeActions: TextNodeAction[] = [] export let refActions: RefAction[] = [] + export let user: CollaborationUser + export let userComponent: AnySvelteComponent | undefined = undefined + export let placeholder: IntlString = textEditorPlugin.string.EditorPlaceholder export let attachFile: FileAttachFunction | undefined = undefined export let boundary: HTMLElement | undefined = undefined @@ -105,6 +108,8 @@ objectClass={object._class} objectId={object._id} objectAttr={key.key} + {user} + {userComponent} {textNodeActions} {refActions} {extensions} diff --git a/packages/text-editor/src/components/CollaborativeAttributeSectionBox.svelte b/packages/text-editor/src/components/CollaborativeAttributeSectionBox.svelte index be8733485a..835a5c0c01 100644 --- a/packages/text-editor/src/components/CollaborativeAttributeSectionBox.svelte +++ b/packages/text-editor/src/components/CollaborativeAttributeSectionBox.svelte @@ -19,12 +19,16 @@ import { Label, Icon } from '@hcengineering/ui' import type { AnySvelteComponent } from '@hcengineering/ui' import textEditorPlugin from '../plugin' + import { CollaborationUser } from '../types' import CollaborativeAttributeBox from './CollaborativeAttributeBox.svelte' import IconDescription from './icons/Description.svelte' export let object: Doc export let key: KeyedAttribute + export let user: CollaborationUser + export let userComponent: AnySvelteComponent | undefined = undefined + export let label: IntlString = textEditorPlugin.string.FullDescription export let icon: Asset | AnySvelteComponent = IconDescription @@ -40,5 +44,14 @@