mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 11:42:30 +03:00
UBERF-7829 Fix embedded image preview (#6279)
This commit is contained in:
parent
36cbccfeb2
commit
3c424b8c31
@ -21,7 +21,7 @@
|
||||
import presentation from '../plugin'
|
||||
|
||||
import { BlobMetadata } from '../types'
|
||||
import { getClient, getFileUrl } from '../utils'
|
||||
import { getFileUrl } from '../utils'
|
||||
|
||||
import ActionContext from './ActionContext.svelte'
|
||||
import FilePreview from './FilePreview.svelte'
|
||||
@ -36,7 +36,6 @@
|
||||
export let fullSize = false
|
||||
export let showIcon = true
|
||||
|
||||
const client = getClient()
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let download: HTMLAnchorElement
|
||||
|
@ -71,18 +71,6 @@ export const FileNode = Node.create<FileOptions>({
|
||||
return [
|
||||
{
|
||||
tag: `div[data-type="${this.name}"]`
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-name]'
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-size]'
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-type]'
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-href]'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -73,7 +73,10 @@ export const ImageNode = Node.create<ImageOptions>({
|
||||
title: {
|
||||
default: null
|
||||
},
|
||||
align: getDataAttribute('align')
|
||||
align: getDataAttribute('align'),
|
||||
'data-file-type': {
|
||||
default: null
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -120,8 +123,10 @@ export const ImageNode = Node.create<ImageOptions>({
|
||||
}
|
||||
|
||||
for (const [k, v] of Object.entries(divAttributes)) {
|
||||
if (v !== null) {
|
||||
container.setAttribute(k, v)
|
||||
}
|
||||
}
|
||||
|
||||
const imgAttributes = mergeAttributes(
|
||||
{
|
||||
|
@ -28,9 +28,8 @@ export function getDataAttribute (
|
||||
default: null,
|
||||
parseHTML: (element) => element.getAttribute(dataName),
|
||||
renderHTML: (attributes) => {
|
||||
// eslint-disable-next-line
|
||||
if (!attributes[name]) {
|
||||
return {}
|
||||
if (attributes[name] == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -53,15 +53,6 @@ export const FileExtension = FileNode.extend<FileOptions>({
|
||||
return [
|
||||
{
|
||||
tag: `div[data-type="${this.name}"]`
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-name]'
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-size]'
|
||||
},
|
||||
{
|
||||
tag: 'div[data-file-type]'
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -151,7 +151,7 @@ export const ImageExtension = ImageNode.extend<ImageOptions>({
|
||||
|
||||
const fileId = node.attrs['file-id'] ?? node.attrs.src
|
||||
const fileName = node.attrs.alt ?? ''
|
||||
const fileType = node.attrs['data-file-type'] ?? ''
|
||||
const fileType = node.attrs['data-file-type'] ?? 'image/*'
|
||||
|
||||
showPopup(
|
||||
FilePreviewPopup,
|
||||
@ -211,7 +211,7 @@ export async function openImage (editor: Editor): Promise<void> {
|
||||
const attributes = editor.getAttributes('image')
|
||||
const fileId = attributes['file-id'] ?? attributes.src
|
||||
const fileName = attributes.alt ?? ''
|
||||
const fileType = attributes['data-file-type'] ?? ''
|
||||
const fileType = attributes['data-file-type'] ?? 'image/*'
|
||||
await new Promise<void>((resolve) => {
|
||||
showPopup(
|
||||
FilePreviewPopup,
|
||||
|
@ -153,7 +153,10 @@ async function handleImageUpload (
|
||||
const size = await getImageSize(file)
|
||||
const node = view.state.schema.nodes.image.create({
|
||||
'file-id': attached.file,
|
||||
'data-file-type': file.type,
|
||||
src: url,
|
||||
alt: file.name,
|
||||
title: file.name,
|
||||
width: Math.round(size.width / size.pixelRatio)
|
||||
})
|
||||
|
||||
|
@ -755,7 +755,8 @@ A list of closed updated issues`
|
||||
align: null,
|
||||
height: null,
|
||||
title: null,
|
||||
'file-id': null
|
||||
'file-id': null,
|
||||
'data-file-type': null
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user