package
Text Type for Yjs
npm install y-textGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 2 packages.
51.1 kB
Includes dependencies.
Use the Y.Text type to share text content. The shared content can be bound to Ace, CodeMirror, Monaco, or any HTML input element (e.g. <input>, <textarea>, any element that has the contenteditable property)
// bind text to the first p element that is contenteditable
y.share.text.bind(document.querySelector("p[contenteditable]"))Retrieve this with bower or npm.
bower install y-text --savenpm install y-text y-array --saveThis type depends on y-array. So you have to extend Yjs in the right order:
var Y = require('yjs')
require('y-array')(Y)
require('y-text')(Y)options supports the following properties:
If two users insert something at the same position concurrently, the content that was inserted by the user with the higher user-id will be to the right of the other content. In the OT world we often speak of intention preservation, which is very loosely defined in most cases. This type has the following notion of intention preservation: When a user inserts content c after a set of content C_left, and before a set of content C_right, then C_left will be always to the left of c, and C_right will be always to the right of c. This property will also hold when content is deleted or when a deletion is undone.
We thank @NathanaelA who sponsored the bindings to the Monaco editor!
Yjs is licensed under the MIT License.
aceaceClass.require). Must work similar to ace.require.bind[editor](..).bind*(editor) does not preserve the existing value of the bound editor.