Created
May 12, 2020 13:11
-
-
Save bjoerntx/880853dc9c084cfc544da378efdb7c0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// connect to signalr hub | |
_connection = new signalR.HubConnectionBuilder().withUrl("/collabHub").build(); | |
_connection.start(); | |
_connection.on("ReceiveRegionSync", async function (syncRegion) { | |
// set flag to avoid infinite loops | |
_updating = true; | |
TXTextControl.editableRegions.forEach(function (er) { | |
// find editable region by id | |
er.getID(function (id) { | |
if (syncRegion.regionId == id) { | |
er.getStart(function (start) { | |
er.getLength(function (length) { | |
TXTextControl.inputPosition.getTextPosition(function (sp) { | |
// select editable region | |
var sel = TXTextControl.selection; | |
var bounds = { "start": start - 1, "length": length }; | |
sel.setBounds(bounds); | |
//sel = TXTextControl.selection; | |
// load synchronized content | |
sel.load(TXTextControl.StreamType.InternalUnicodeFormat, | |
syncRegion.document); | |
// reset input position | |
var bounds = { "start": sp, "length": 0 }; | |
sel.setBounds(bounds); | |
// reset flags | |
setTimeout(function () { | |
_updating = false; | |
_dirtyFlag = false; | |
}, 100); | |
}); | |
}); | |
}); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment