From ab228b376bfb045fbd151db30621ae68fb2c68ab Mon Sep 17 00:00:00 2001 From: Victor Ilyushchenko Date: Tue, 15 Apr 2025 14:21:19 +0300 Subject: [PATCH] Enabled the new profile preview in the text editor (#8555) Signed-off-by: Victor Ilyushchenko --- .../src/components/extension/reference.ts | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/plugins/text-editor-resources/src/components/extension/reference.ts b/plugins/text-editor-resources/src/components/extension/reference.ts index 1c3f29a246..185120fb12 100644 --- a/plugins/text-editor-resources/src/components/extension/reference.ts +++ b/plugins/text-editor-resources/src/components/extension/reference.ts @@ -27,7 +27,7 @@ import presentation, { createQuery, getClient } from '@hcengineering/presentatio import view from '@hcengineering/view' import contact from '@hcengineering/contact' -import { parseLocation, type Location } from '@hcengineering/ui' +import { parseLocation, tooltip, type LabelAndProps, type Location } from '@hcengineering/ui' import workbench, { type Application } from '@hcengineering/workbench' export interface ReferenceExtensionOptions extends ReferenceOptions { @@ -139,6 +139,14 @@ export const ReferenceExtension = ReferenceNode.extend { + if (typeof tooltipHandle?.destroy === 'function') { + tooltipHandle.destroy() + } + tooltipHandle = newState + } + const titleSpan = root.appendChild(document.createElement('span')) renderLabel({ id, objectclass, label: node.attrs.label }) @@ -150,6 +158,9 @@ export const ReferenceExtension = ReferenceNode.extend ( + objectclass: Ref>, + id: Ref, + doc?: T +): Promise { + const client = getClient() + const hierarchy = client.getHierarchy() + + const mixin = hierarchy.classHierarchyMixin(objectclass as Ref>, view.mixin.ObjectTooltip) + + if (mixin?.provider !== undefined) { + const providerFn = await getResource(mixin.provider) + return (await providerFn(client, doc)) ?? { label: hierarchy.getClass(objectclass).label } + } + + return { label: hierarchy.getClass(objectclass).label } +} + export async function getReferenceLabel ( objectclass: Ref>, id: Ref,