Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const htmlToVNode = html => { // helper function for convert html to vnode
const wrapper = document.createElement('div')
wrapper.innerHTML = html
return toVNode(wrapper).children
}
while (nextSibling && nextSibling.id !== endKey) {
needToRemoved.push(nextSibling)
nextSibling = nextSibling.nextElementSibling
}
nextSibling && needToRemoved.push(nextSibling)
firstOldDom.insertAdjacentHTML('beforebegin', html)
Array.from(needToRemoved).forEach(dom => dom.remove())
// Render cursor block independently
if (needRenderCursorBlock) {
const { key } = cursorOutMostBlock
const cursorDom = document.querySelector(`#${key}`)
if (cursorDom) {
const oldCursorVnode = toVNode(cursorDom)
const newCursorVnode = this.renderBlock(cursorOutMostBlock, cursor, activeBlocks, matches)
patch(oldCursorVnode, newCursorVnode)
}
}
}
export const htmlToVNode = html => { // helper function for convert html to vnode
const wrapper = document.createElement('div')
wrapper.innerHTML = html
return toVNode(wrapper).children
}
function init() {
newRoot();
vnode = render();
vnode = patch(toVNode(target), vnode);
requested = false;
return vnode;
}
function refresh(callback) {
render (blocks, cursor, activeBlocks, matches) {
const selector = `div#${CLASS_OR_ID['AG_EDITOR_ID']}`
const children = blocks.map(block => {
return this.renderBlock(block, cursor, activeBlocks, matches)
})
const newVdom = h(selector, children)
const rootDom = document.querySelector(selector) || this.container
const oldVdom = toVNode(rootDom)
patch(oldVdom, newVdom)
}