mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
feat: feedback (#156)
* minimal tiptap * wip * img edit block * wip * fix
This commit is contained in:
15
web/components/minimal-tiptap/hooks/use-image-load.ts
Normal file
15
web/components/minimal-tiptap/hooks/use-image-load.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import * as React from 'react'
|
||||
|
||||
export const useImageLoad = (src: string) => {
|
||||
const [imgSize, setImgSize] = React.useState({ width: 0, height: 0 })
|
||||
|
||||
React.useEffect(() => {
|
||||
const img = new Image()
|
||||
img.src = src
|
||||
img.onload = () => {
|
||||
setImgSize({ width: img.width, height: img.height })
|
||||
}
|
||||
}, [src])
|
||||
|
||||
return imgSize
|
||||
}
|
||||
Reference in New Issue
Block a user