All Projects → y-js → y-richtext

y-js / y-richtext

Licence: other
Rich Text type for Yjs

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to y-richtext

y-leveldb
LevelDB database adapter for Yjs
Stars: ✭ 67 (+131.03%)
Mutual labels:  yjs
y-crdt
Rust port of Yjs
Stars: ✭ 854 (+2844.83%)
Mutual labels:  yjs
caucus
Realtime Collaborate Editor with Embedded Compiler
Stars: ✭ 278 (+858.62%)
Mutual labels:  yjs
Yjs
Shared data types for building collaborative software
Stars: ✭ 5,894 (+20224.14%)
Mutual labels:  yjs
slate-yjs-example
Minimal example project for slate-yjs
Stars: ✭ 43 (+48.28%)
Mutual labels:  yjs
app
Web metaverse client
Stars: ✭ 115 (+296.55%)
Mutual labels:  yjs
y-indexeddb
IndexedDB database adapter for Yjs
Stars: ✭ 57 (+96.55%)
Mutual labels:  yjs
y-websocket
Websocket Connector for Yjs
Stars: ✭ 195 (+572.41%)
Mutual labels:  yjs
SyncedStore
SyncedStore CRDT is an easy-to-use library for building live, collaborative applications that sync automatically.
Stars: ✭ 1,053 (+3531.03%)
Mutual labels:  yjs

Rich Text type for Yjs

The fabulous feature of y-richtext is that you can bind it to a Quill instance (> v1.0.0) in order to enable collaborative richtext editing.

Use it!

Bower

Retrieve y-richtext and Quill Editor with bower.

bower install y-richtext quill --save

NPM

npm install y-richtext y-array quill --save

This 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-richtext')(Y)

Example

Y({
  db: {
    name: 'memory'
  },
  connector: {
    name: 'websockets-client',
    room: 'richtext-example'
  },
  share: {
    richtext: 'Richtext' // y.share.richtext is of type Y.Richtext
  }
}).then(function (y) {
  window.yquill = y

  // create quill element
  window.quill = new Quill('#editor', {
    modules: {
      'toolbar': { container: '#toolbar' },
      'link-tooltip': true
    },
    theme: 'snow'
  })
  // bind quill to richtext type
  y.share.richtext.bindQuill(window.quill)
})

RichText Object

Reference
  • .bind(editor)
    • Bind this type to an rich text editor. (Currently, only QuillJs is supported)
    • .bind(editor) does not preserve the existing value of the bound editor
  • .bindQuill(quill)
    • Explicitely bind a Quill editor
  • unbindQuill(quill)
    • Remove binding
  • unbindQuillAll()
    • Remove all quill bindings
  • .insert(position, string)
    • Insert text at a position
  • .delete(position, length)
    • Delete text
  • select(from, to, attrName, attrValue)
    • Assign meaning to a selection of text (application depending to what you bind, this can assign text to be bold, italic, ..). Set null to remove selection.
  • toString()
    • Get the string representation of this type (without selections)
  • toDelta()
  • applyDelta()

Contribution

We thank Linagora who sponsored this work, and agreed to publish it as Open Source.

Changelog

8.2.1

  • support for Quill@^1.0.0-rc.2
  • relies on Yjs@^12.0.0

License

Yjs and the RichText type are licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].