Files

50 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2016-11-14 16:29:04 +01:00
/* global Y, Quill */
2017-04-11 16:20:13 +02:00
// register yjs service worker
if('serviceWorker' in navigator){
// Register service worker
// it is important to copy yjs-sw-template to the root directory!
navigator.serviceWorker.register('./yjs-sw-template.js').then(function(reg){
console.log("Yjs service worker registration succeeded. Scope is " + reg.scope);
}).catch(function(err){
console.error("Yjs service worker registration failed with error " + err);
})
}
2016-11-16 18:08:01 +01:00
// initialize a shared object. This function call returns a promise!
2016-11-14 16:29:04 +01:00
Y({
db: {
name: 'memory'
},
connector: {
2017-04-11 16:20:13 +02:00
name: 'serviceworker',
room: 'ServiceWorkerExample2'
2016-11-14 16:29:04 +01:00
},
sourceDir: '/bower_components',
share: {
richtext: 'Richtext' // y.share.richtext is of type Y.Richtext
}
}).then(function (y) {
2017-04-11 16:20:13 +02:00
window.yServiceWorker = y
2016-11-14 16:29:04 +01:00
// create quill element
window.quill = new Quill('#quill', {
modules: {
formula: true,
syntax: true,
toolbar: [
[{ size: ['small', false, 'large', 'huge'] }],
['bold', 'italic', 'underline'],
[{ color: [] }, { background: [] }], // Snow theme fills in values
[{ script: 'sub' }, { script: 'super' }],
['link', 'image'],
['link', 'code-block'],
[{list: 'ordered' }]
]
},
theme: 'snow'
2016-11-16 18:08:01 +01:00
})
2016-11-14 16:29:04 +01:00
// bind quill to richtext type
y.share.richtext.bind(window.quill)
2016-11-21 16:28:20 +01:00
})