Add support for handling editor resize events
This commit is contained in:
parent
a9330e50b9
commit
c14294d80d
@ -8,16 +8,16 @@ window.onload = () => {
|
|||||||
let editor = {
|
let editor = {
|
||||||
timer: null,
|
timer: null,
|
||||||
children: [
|
children: [
|
||||||
{
|
// {
|
||||||
elements: null,
|
// elements: null,
|
||||||
isProofed: false
|
// isProofed: false
|
||||||
// matches: [
|
// matches: [
|
||||||
// {
|
// {
|
||||||
// range: null,
|
// range: null,
|
||||||
// rects: null
|
// rects: null
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
}
|
// }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
besEditors[edit.id] = editor
|
besEditors[edit.id] = editor
|
||||||
@ -28,7 +28,19 @@ window.onload = () => {
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
edit.addEventListener('click', e => besHandleClick(e, edit))
|
edit.addEventListener('click', e => besHandleClick(e, edit))
|
||||||
// TODO: Handle editor resizes.
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
window.onresize = () => {
|
||||||
|
Object.keys(besEditors).forEach(key => {
|
||||||
|
let editor = besEditors[key]
|
||||||
|
editor.children.forEach(child => {
|
||||||
|
besClearAllMistakes(child?.elements)
|
||||||
|
child.matches.forEach(match => {
|
||||||
|
const clientRect = besAddMistake(match.range, match.message)
|
||||||
|
match.rects = clientRect
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,7 +214,7 @@ function besClearProofed(el) {
|
|||||||
|
|
||||||
// Remove all grammar mistakes markup for given block element.
|
// Remove all grammar mistakes markup for given block element.
|
||||||
function besClearAllMistakes(el) {
|
function besClearAllMistakes(el) {
|
||||||
if (el.id.startsWith('ed')) return
|
if (el?.id.startsWith('ed')) return
|
||||||
const editorId = el.parentElement.id
|
const editorId = el.parentElement.id
|
||||||
const editor = besEditors[editorId]
|
const editor = besEditors[editorId]
|
||||||
let filteredChildren = editor?.children.filter(child => child.elements === el)
|
let filteredChildren = editor?.children.filter(child => child.elements === el)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user