mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-28 19:08:01 +00:00
fix(github): broken images in issue description (#7534)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Dakshesh Jain <dakshesh.jain14@gmail.com>
This commit is contained in:
parent
5becc4137f
commit
aaf2c14e7a
@ -140,7 +140,22 @@ export const storeNodes: Record<string, NodeProcessor> = {
|
||||
|
||||
image: (state, node) => {
|
||||
const attrs = nodeAttrs(node)
|
||||
if (attrs['file-id'] != null) {
|
||||
if (attrs.token != null && attrs['file-id'] != null) {
|
||||
// Convert image to token format
|
||||
state.write(
|
||||
' : '') +
|
||||
(attrs.height != null ? '&height=' + state.esc(`${attrs.height}`) : '') +
|
||||
(attrs.token != null ? '&token=' + state.esc(`${attrs.token}`) : '')) +
|
||||
(attrs.title != null ? ' ' + state.quote(`${attrs.title}`) : '') +
|
||||
')'
|
||||
)
|
||||
} else if (attrs['file-id'] != null) {
|
||||
// Convert image to fileid format
|
||||
state.write(
|
||||
'![' +
|
||||
|
@ -2,10 +2,11 @@
|
||||
// Copyright © 2023 Hardcore Engineering Inc.
|
||||
//
|
||||
|
||||
import { Branding, TxOperations, WorkspaceIdWithUrl } from '@hcengineering/core'
|
||||
import { Branding, generateId, TxOperations, WorkspaceIdWithUrl } from '@hcengineering/core'
|
||||
import { MarkupMarkType, MarkupNode, MarkupNodeType, traverseMarkupNode } from '@hcengineering/text'
|
||||
import { getPublicLink } from '@hcengineering/server-guest-resources'
|
||||
import { Task } from '@hcengineering/task'
|
||||
import { generateToken } from '@hcengineering/server-token'
|
||||
|
||||
const githubLinkText = process.env.LINK_TEXT ?? 'Huly®:'
|
||||
|
||||
@ -54,6 +55,7 @@ export async function appendGuestLink (
|
||||
const publicLink = await getPublicLink(doc, client, workspace, false, branding)
|
||||
await stripGuestLink(markdown)
|
||||
appendGuestLinkToModel(markdown, publicLink, doc.identifier)
|
||||
appendGuestLinkToImage(markdown, workspace)
|
||||
}
|
||||
|
||||
export function appendGuestLinkToModel (markdown: MarkupNode, publicLink: string, identifier: string): void {
|
||||
@ -76,3 +78,31 @@ export function appendGuestLinkToModel (markdown: MarkupNode, publicLink: string
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
function findImageTags (node: MarkupNode): MarkupNode[] {
|
||||
if (node.type === MarkupNodeType.paragraph) {
|
||||
return node.content?.flatMap(findImageTags) ?? []
|
||||
}
|
||||
if (node.type === MarkupNodeType.image) {
|
||||
return [node]
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
export function appendGuestLinkToImage (markdown: MarkupNode, workspace: WorkspaceIdWithUrl): void {
|
||||
const imageTags: MarkupNode[] = markdown.content?.flatMap(findImageTags) ?? []
|
||||
|
||||
if (imageTags.length === 0) {
|
||||
return
|
||||
}
|
||||
|
||||
const id = generateId()
|
||||
const token = generateToken(id, workspace, { linkId: id, guest: 'true' })
|
||||
|
||||
for (const imageTag of imageTags) {
|
||||
const src = imageTag.attrs?.src
|
||||
if (src !== undefined && imageTag.attrs !== undefined) {
|
||||
imageTag.attrs.token = token
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ export class GithubWorker implements IntegrationManager {
|
||||
text ?? '',
|
||||
concatLink(this.getBranding()?.front ?? config.FrontURL, `/browse/?workspace=${this.workspace.name}`),
|
||||
// TODO storage URL
|
||||
concatLink(this.getBranding()?.front ?? config.FrontURL, `/files?workspace=${this.workspace.name}&file=`),
|
||||
concatLink(this.getBranding()?.front ?? config.FrontURL, `/files/${this.workspace.name}/`),
|
||||
preprocessor
|
||||
)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user