Files
yjs/examples/html-editor/index.js

30 lines
681 B
JavaScript
Raw Normal View History

2017-12-24 03:18:00 +01:00
/* global Y */
window.onload = function () {
2018-05-05 14:47:59 +02:00
window.domBinding = new Y.DomBinding(window.yXmlType, document.body, { scrollingElement: document.scrollingElement })
}
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)
window.undoManager = new Y.utils.UndoManager(window.yXmlType, {
captureTimeout: 500
})
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()
}
}