y-js / y-text Goto Github PK
View Code? Open in Web Editor NEWText Type for Yjs
License: MIT License
Text Type for Yjs
License: MIT License
Hi Kevin,
Currently its not possible to find out which user deletes characters .
It would be nice to have the user id as property in the event object of the callback of the observe function.
It would be a nice feature for the activity list of SyncMeta.
Best
Mario
Hi
I was trying to run multiple instances of editors for Codemirror/Ace.
The program doesn't seem to work as intended.
Here is what I observed.
Using Ace
Including multiple Ace editors in the same window makes them relay events amongst themselves.
As a result, a change in any window is reflected in the other. They are all initialized to the same value as well.
I have defined different editors and called the bind function separately on the two.
Using Codemirror
Something worse happens in this case. The control seems to be stuck among the functions
codeMirrorCallback
and
yCallback
They keep on calling each other and eventually the window crashes.
I am not sure if the code of y-text was written to handle multiple instances of Codemirror/Ace.
It seems though it should since the code consists of arrays
codeMirrorInstances
and
aceMirrorInstances
which suggests multiple instances should be handled
If not then this issue can be converted into a discussion on how to do that.
Hi,
I'm running into some issues with Monaco:
errors.ts:84 Uncaught Error: TypeError: Cannot read property 'startLineNumber' of undefined
Error: TypeError: Cannot read property 'startLineNumber' of undefined
at mutualExcluse (/Users/user/editor/node_modules/y-text/src/Text.js:101)
at monacoCallback (/Users/user/editor/node_modules/y-text/src/Text.js:109)
at CallbackList.invoke (callbackList.ts:63)
at Emitter.fire (event.ts:123)
at commonCodeEditor.ts:883
at safeInvoke1Arg (eventEmitter.ts:295)
at OrderGuaranteeEventEmitter._emitEvents (eventEmitter.ts:279)
at OrderGuaranteeEventEmitter.EventEmitter._emitCollected (eventEmitter.ts:232)
at OrderGuaranteeEventEmitter.EventEmitter.endDeferredEmit (eventEmitter.ts:211)
at Model.EditableTextModel.pushEditOperations (editableTextModel.ts:98)
at mutualExcluse (/Users/user/editor/node_modules/y-text/src/Text.js:101)
at monacoCallback (/Users/user/editor/node_modules/y-text/src/Text.js:109)
at CallbackList.invoke (callbackList.ts:63)
at Emitter.fire (event.ts:123)
at commonCodeEditor.ts:883
at safeInvoke1Arg (eventEmitter.ts:295)
at OrderGuaranteeEventEmitter._emitEvents (eventEmitter.ts:279)
at OrderGuaranteeEventEmitter.EventEmitter._emitCollected (eventEmitter.ts:232)
at OrderGuaranteeEventEmitter.EventEmitter.endDeferredEmit (eventEmitter.ts:211)
at Model.EditableTextModel.pushEditOperations (editableTextModel.ts:98)
at errors.ts:84
This occurs if I type anything into Monaco. I encounter errors with Monaco versions 0.13.1 to 0.9.0. Monaco version 0.8.3 works fine, however.
Sorry, I can not figure that out from the code.
What algorithm y-text is using?
I see offsets, but I see no transforms. Is it OT, CRDT or something else?
Hi Kevin,
if i type enter (\n) in a html-input field binded to a ytext and retrieve the value usingytext.toString()
the String consits of "\n".
It's not a big problem i can filter it out with ytext.toString().replace(/\n/g,'')
, but for a single line input field I think "\n" shouldn't occur there.
I tested in older SyncMeta version which uses y-text 9.0.1 and yjs 11.2.6 and the newest which uses the latest versions(yjs 12.0.4 and y-text 9.0.2).
Best,
Mario
Currently not working for input elements..
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];
...
I tested initially on a TextArea which works great with the following design:
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 the y.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 the files 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:
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. :)
In Chrome 51 if i bind a html-input field to y-text and insert text. If i reach the right border of the input field the cursor is not following the inserted text like it should. Basically i write out of the visible region and the cursor is not following.
I just binded a input-html field to y.text as is the examples of Yjs:
y.share.text.bind(document.getElementById('test'));
In Firefox its is working.
When I use
EditSession = ace.require("ace/edit_session").EditSession;
And then setup the sessions I can't get the code sharing between browsers to work. I get this error:
Text.js:277 Uncaught Error: Error: This position exceeds the range of the array!
at n (Text.js:277)
at Array.r (Text.js:285)
at b.r._signal (ace.js:1)
at b.onDocumentChange (ace.js:1)
at p.r._signal (ace.js:1)
at p.onChange (ace.js:1)
at a.r._signal (ace.js:1)
at applyDelta (ace.js:1)
at a.insertMergedLines (ace.js:1)
at a.insert (ace.js:1)
Should yjs work with multiple ace edit sessions?
I'm setting it up as follows:
Y({
db: {
name: 'memory'
},
connector: {
name: 'websockets-client',
room: 'ace-example',
url: 'http://localhost:1234'
},
sourceDir: '/bower_components',
share: {
ace: 'Text' // y.share.textarea is of type Y.Text
}
}).then(function (y) {
editor = ace.edit("editor");
editor.setTheme("ace/theme/chrome");
y.share.ace.bindAce(editor);
EditSession = ace.require("ace/edit_session").EditSession;
/* And then code that sets up all the sessions and calls SetValue to set the initial code */
can not work with y.js of version 13.x.x
@dmonad
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.