mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
Bug fix check in.
This commit is contained in:
committed by
Junyoung Choi
parent
895aee3e6c
commit
aecf2eb08d
@@ -882,8 +882,25 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
|
|
||||||
const markdownPreviewIframe = document.querySelector('.MarkdownPreview')
|
const markdownPreviewIframe = document.querySelector('.MarkdownPreview')
|
||||||
const rect = markdownPreviewIframe.getBoundingClientRect()
|
const rect = markdownPreviewIframe.getBoundingClientRect()
|
||||||
|
const config = { attributes: true, subtree: true }
|
||||||
|
const imgObserver = new MutationObserver((mutationList) => {
|
||||||
|
for (const mu of mutationList) {
|
||||||
|
if (mu.target.className === 'carouselContent-enter-done') {
|
||||||
|
this.setImgOnClickEventHelper(mu.target, rect)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const imgList = markdownPreviewIframe.contentWindow.document.body.querySelectorAll('img')
|
const imgList = markdownPreviewIframe.contentWindow.document.body.querySelectorAll('img')
|
||||||
for (const img of imgList) {
|
for (const img of imgList) {
|
||||||
|
const parentEl = img.parentElement
|
||||||
|
this.setImgOnClickEventHelper(img, rect)
|
||||||
|
imgObserver.observe(parentEl, config)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setImgOnClickEventHelper (img, rect) {
|
||||||
img.onclick = () => {
|
img.onclick = () => {
|
||||||
const widthMagnification = document.body.clientWidth / img.width
|
const widthMagnification = document.body.clientWidth / img.width
|
||||||
const heightMagnification = document.body.clientHeight / img.height
|
const heightMagnification = document.body.clientHeight / img.height
|
||||||
@@ -953,7 +970,6 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
overlay.appendChild(zoomImg)
|
overlay.appendChild(zoomImg)
|
||||||
document.body.appendChild(overlay)
|
document.body.appendChild(overlay)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.getWindow().scrollTo(0, 0)
|
this.getWindow().scrollTo(0, 0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user