platform/server-plugins/document-resources/src/index.ts
Alexander Onnikov 58d39f0cd6
UBERF-5642 Opensource wiki (#4818)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
2024-02-29 15:32:39 +07:00

38 lines
1.1 KiB
TypeScript

//
// Copyright © 2024 Hardcore Engineering Inc.
//
//
import { Doc, concatLink } from '@hcengineering/core'
import { Document, documentId } from '@hcengineering/document'
import { getMetadata } from '@hcengineering/platform'
import { workbenchId } from '@hcengineering/workbench'
import serverCore, { TriggerControl } from '@hcengineering/server-core'
/**
* @public
*/
export async function documentHTMLPresenter (doc: Doc, control: TriggerControl): Promise<string> {
const document = doc as Document
const front = getMetadata(serverCore.metadata.FrontUrl) ?? ''
const path = `${workbenchId}/${control.workspace.workspaceUrl}/${documentId}/${doc._id}`
const link = concatLink(front, path)
return `<a href="${link}">${document.name}</a>`
}
/**
* @public
*/
export async function documentTextPresenter (doc: Doc): Promise<string> {
const document = doc as Document
return document.name
}
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
export default async () => ({
function: {
DocumentHTMLPresenter: documentHTMLPresenter,
DocumentTextPresenter: documentTextPresenter
}
})