hooks port to domBinding

This commit is contained in:
Kevin Jahns
2018-04-26 13:26:21 +02:00
parent 94933a704d
commit 1fe37c565e
9 changed files with 68 additions and 51 deletions

View File

@@ -1,7 +1,20 @@
/* global Y, d3 */
const hooks = {
"magic-drawing": {
fillType: function (dom, type) {
initDrawingBindings(type, dom)
},
createDom: function (type) {
const dom = document.createElement('magic-drawing')
initDrawingBindings(type, dom)
return dom
}
}
}
window.onload = function () {
window.yXmlType.bindToDom(document.body)
window.domBinding = new Y.DomBinding(window.yXmlType, document.body, { hooks })
}
window.addMagicDrawing = function addMagicDrawing () {
@@ -96,17 +109,6 @@ function initDrawingBindings (type, dom) {
}
}
Y.XmlHook.addHook('magic-drawing', {
fillType: function (dom, type) {
initDrawingBindings(type, dom)
},
createDom: function (type) {
const dom = document.createElement('magic-drawing')
initDrawingBindings(type, dom)
return dom
}
})
let y = new Y('html-editor-drawing-hook-example', {
connector: {
name: 'websockets-client',