y-text
y-text copied to clipboard
yText doesn't work properly with Monaco v0.10.0
There are at couple issues with the current version of Monaco and the current version of Y-JS. I finally had an opportunity to test this out and integrate it; and it doesn't work. ;-(
First The new version of Monaco changed the onDidChangeModelContent
it now sends you an array of changes. So in monacoCallback, made a small change so that it would loop through the changes
function monacoCallback (orgEvent) {
...
for (var j=0;j<orgEvent.changes.length;j++) {
var event = orgEvent.changes[j];
...
No more exceptions Yay. (I think this fixes the obvious compatible issue)
I tested initially on a TextArea which works great with the following design:
- Server creates a new Workspace with Share.files = Map. (i.e. ymap)
- Client gets a message to attach to the Workspace, and connects (and waits for it).
- Client asks to open a file
- Server creates new YText's inside the files Map.
- Client gets a message to attach to a file in the editor and uses:
- Removed any existing binding and creates a new Monaco Model, and attaches it as the current monaco model. The text is transferred in the inital attach message (outside of YJS), because Y can sometimes be slow... Then it proceeds to do:
yWorkspace.connector.whenSynced
which works about 33% of the time to have the file YText is ready, but if it fails here; I waits for they.share.files.observe
add
event and then attempts the same code path above with the whenSynced and catches the rest of the times. At this point I am able to get thefiles YText
properly. And then I bind it to the actual editor. So far everything seems good. If I type I see events occur on the server, clients, etc. BUT the attached editors never change their content. ;-(
If I use a pure TextArea, this seems to work fine. If I create a demo Monaco project using the "Monaco" as the share; it partially works; one browser will update the other browser; but the other browser will NOT updated the other one. So it posts updates through the exact same server process...
So in summary:
- Using YMap -> Multiple YTexts; does NOT update any browsers on changes, but attaching to the events, I see update and sync messages; so it "appears" that it is sending things between the browser, just not updating Monaco.
- Using YText directly, appears to keep one Monaco instance in one browser updated; the other browser does not update.
- Using YText or YMap->YText in textarea seems to work great.
I based this off the default YSocket examples; other than the changes to make it used Map's. All sides are using the YMemory storage. I was really hoping to present this project on the 19th; but at this point I'm not going to be able to use YJS to sync things as much as I would love to.. If you have any thoughts, I'll be watching this issue religiously. :)