2017-12-24 03:18:00 +01:00
|
|
|
/* global Y */
|
2017-11-12 13:34:23 -08:00
|
|
|
|
2017-11-29 15:08:49 -08:00
|
|
|
window.onload = function () {
|
2018-05-05 14:47:59 +02:00
|
|
|
window.domBinding = new Y.DomBinding(window.yXmlType, document.body, { scrollingElement: document.scrollingElement })
|
2017-11-29 15:08:49 -08:00
|
|
|
}
|
|
|
|
|
|
2018-01-16 16:13:47 +01:00
|
|
|
let y = new Y('htmleditor', {
|
2017-08-25 20:35:06 +02:00
|
|
|
connector: {
|
|
|
|
|
name: 'websockets-client',
|
2018-01-25 17:28:33 -07:00
|
|
|
url: 'http://127.0.0.1:1234'
|
2017-08-25 20:35:06 +02:00
|
|
|
}
|
2018-01-25 17:28:33 -07:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
window.y = y
|
2017-11-08 13:40:36 -08:00
|
|
|
window.yXmlType = y.define('xml', Y.XmlFragment)
|
2017-11-08 17:31:12 -08:00
|
|
|
window.undoManager = new Y.utils.UndoManager(window.yXmlType, {
|
2017-11-12 13:34:23 -08:00
|
|
|
captureTimeout: 500
|
2017-11-08 17:31:12 -08:00
|
|
|
})
|
2017-10-30 11:33:00 +01:00
|
|
|
|
|
|
|
|
document.onkeydown = function interceptUndoRedo (e) {
|
2018-02-15 17:58:14 +01:00
|
|
|
if (e.keyCode === 90 && (e.metaKey || e.ctrlKey)) {
|
2017-10-30 11:33:00 +01:00
|
|
|
if (!e.shiftKey) {
|
|
|
|
|
window.undoManager.undo()
|
|
|
|
|
} else {
|
|
|
|
|
window.undoManager.redo()
|
|
|
|
|
}
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
}
|
2017-10-19 17:36:28 +02:00
|
|
|
}
|