braid-text 0.3.15 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/cursor-highlights.js +16 -3
- package/package.json +1 -1
|
@@ -302,6 +302,8 @@ function cursor_highlights(textarea, url) {
|
|
|
302
302
|
var hl = textarea_highlights(textarea)
|
|
303
303
|
var applying_remote = false
|
|
304
304
|
var client = null
|
|
305
|
+
var online = false
|
|
306
|
+
var destroyed = false
|
|
305
307
|
|
|
306
308
|
cursor_client(url, {
|
|
307
309
|
peer,
|
|
@@ -316,7 +318,11 @@ function cursor_highlights(textarea, url) {
|
|
|
316
318
|
}
|
|
317
319
|
hl.render()
|
|
318
320
|
}
|
|
319
|
-
}).then(function(c) {
|
|
321
|
+
}).then(function(c) {
|
|
322
|
+
client = c
|
|
323
|
+
if (online) client.online()
|
|
324
|
+
if (destroyed) client.destroy()
|
|
325
|
+
})
|
|
320
326
|
|
|
321
327
|
document.addEventListener('selectionchange', function() {
|
|
322
328
|
if (applying_remote) return
|
|
@@ -325,8 +331,14 @@ function cursor_highlights(textarea, url) {
|
|
|
325
331
|
})
|
|
326
332
|
|
|
327
333
|
return {
|
|
328
|
-
online: function() {
|
|
329
|
-
|
|
334
|
+
online: function() {
|
|
335
|
+
online = true
|
|
336
|
+
if (client) client.online()
|
|
337
|
+
},
|
|
338
|
+
offline: function() {
|
|
339
|
+
online = false
|
|
340
|
+
if (client) client.offline()
|
|
341
|
+
},
|
|
330
342
|
|
|
331
343
|
on_patches: function(patches) {
|
|
332
344
|
applying_remote = true
|
|
@@ -343,6 +355,7 @@ function cursor_highlights(textarea, url) {
|
|
|
343
355
|
},
|
|
344
356
|
|
|
345
357
|
destroy: function() {
|
|
358
|
+
destroyed = true
|
|
346
359
|
if (client) client.destroy()
|
|
347
360
|
hl.destroy()
|
|
348
361
|
}
|