diff --git a/plugins/contact/src/utils.ts b/plugins/contact/src/utils.ts index 08b159c0cf..eceb5ae392 100644 --- a/plugins/contact/src/utils.ts +++ b/plugins/contact/src/utils.ts @@ -88,6 +88,18 @@ export function setCurrentEmployeeSpace (space: Ref): void { currentEmployeeSpace = space } +/** + * True when {@link Doc.createdBy} is one of the given account's social identities. + * + * @public + */ +export function isDocCreatedByAccount (doc: Doc, account: Account): boolean { + const creator = doc.createdBy + if (creator === undefined) return false + if (creator === account.primarySocialId) return true + return account.socialIds.includes(creator) +} + /** * @public */ diff --git a/plugins/text-editor-resources/src/components/CollaborativeTextEditor.svelte b/plugins/text-editor-resources/src/components/CollaborativeTextEditor.svelte index 2b4620ad77..50fabb5118 100644 --- a/plugins/text-editor-resources/src/components/CollaborativeTextEditor.svelte +++ b/plugins/text-editor-resources/src/components/CollaborativeTextEditor.svelte @@ -38,6 +38,7 @@ imageSizeToRatio, KeyedAttribute } from '@hcengineering/presentation' + import { isDocCreatedByAccount } from '@hcengineering/contact' import { markupToJSON } from '@hcengineering/text' import { AnySvelteComponent, @@ -131,7 +132,13 @@ let editorReady = false $: loading = !synced - $: editable = !readonly && !contentError && synced && editorReady && hasAccountRole(account, AccountRole.User) + $: canEditAsGuestCreator = account.role === AccountRole.Guest && isDocCreatedByAccount(object, account) + $: editable = + !readonly && + !contentError && + synced && + editorReady && + (hasAccountRole(account, AccountRole.User) || canEditAsGuestCreator) void provider.loaded.then(() => (synced = true)) void provider.loaded.then(() => dispatch('loaded'))