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

30 lines
589 B
JavaScript
Raw Normal View History

2017-12-24 03:18:00 +01:00
/* global Y */
window.onload = function () {
window.yXmlType.bindToDom(document.body)
}
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) {
2017-11-09 17:31:58 -08:00
if (e.keyCode === 90 && e.metaKey) {
2017-10-30 11:33:00 +01:00
if (!e.shiftKey) {
window.undoManager.undo()
} else {
window.undoManager.redo()
}
e.preventDefault()
}
}