All Projects → reedsy → Quill Cursors

reedsy / Quill Cursors

Licence: mit
A multi cursor module for Quill text editor.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Quill Cursors

collaborative-editor
A collaborative editor that supports authorship display, image uploading placeholder and CJK characters composition based on Quill and ShareDB.
Stars: ✭ 78 (-43.88%)
Mutual labels:  quill, collaborative-editing
Quill Sharedb Cursors
Collaborative editing with multi cursors sync using Quill and ShareDB.
Stars: ✭ 121 (-12.95%)
Mutual labels:  collaborative-editing, quill
quill-placeholder-module
A quill module for adding placeholders
Stars: ✭ 27 (-80.58%)
Mutual labels:  module, quill
Dante
Just another Medium wysiwyg editor clone
Stars: ✭ 1,647 (+1084.89%)
Mutual labels:  collaborative-editing
Pluginguimagic
Examples for foleys_gui_magic - the styleable plugin gui
Stars: ✭ 120 (-13.67%)
Mutual labels:  module
Etherpad Lite
Etherpad: A modern really-real-time collaborative document editor.
Stars: ✭ 11,937 (+8487.77%)
Mutual labels:  collaborative-editing
Terraform Aws Airship Ecs Service
Terraform module which creates an ECS Service, IAM roles, Scaling, ALB listener rules.. Fargate & AWSVPC compatible
Stars: ✭ 139 (+0%)
Mutual labels:  module
Node Hot Loader
Hot module replacement (hot reload) for Node.js applications. Develop without server restarting.
Stars: ✭ 111 (-20.14%)
Mutual labels:  module
Godotads
Godot all in one ads module for Android. (Customizable)
Stars: ✭ 137 (-1.44%)
Mutual labels:  module
Nestjs Amqp
Amqp connections for nestjs 💌
Stars: ✭ 123 (-11.51%)
Mutual labels:  module
Sgf
This is a Smart Game Foundation (Not Framework)
Stars: ✭ 122 (-12.23%)
Mutual labels:  module
Tinypart
TinyPart is an iOS modularization framework implemented by Ojective-C. It also supports URL-routing and inter-module communication. TinyPart是一个由Objective-C编写的面向协议的iOS模块化框架,同时它还支持URL路由和模块间通信机制。
Stars: ✭ 120 (-13.67%)
Mutual labels:  module
Androidmodulesamples
🎨基于 MVP + RxJava + Retrofit + EventBus + Arouter 的 Android 组件化开发框架实践
Stars: ✭ 129 (-7.19%)
Mutual labels:  module
Flok
Web-based P2P collaborative editor for live coding sounds and images
Stars: ✭ 119 (-14.39%)
Mutual labels:  collaborative-editing
Ngx Quill Example
demo app for the advanced usage of ngx-quill module
Stars: ✭ 137 (-1.44%)
Mutual labels:  quill
Ipfs Mini
A super tiny module for querying IPFS that works in the browser and node.
Stars: ✭ 115 (-17.27%)
Mutual labels:  module
Nuxt Image Loader Module
An image loader module for nuxt.js that allows you to configure image style derivatives.
Stars: ✭ 135 (-2.88%)
Mutual labels:  module
Nest Raven
Sentry Raven Module for Nest.js Framework
Stars: ✭ 123 (-11.51%)
Mutual labels:  module
Mis
模块接口服务,如何在一个模块内维护其对外暴露的接口(包括打包发布),而不是把接口和接口实现分离到两个不同的模块?
Stars: ✭ 124 (-10.79%)
Mutual labels:  module
Pytorchchamferdistance
Implementation of the Chamfer Distance as a module for pyTorch
Stars: ✭ 139 (+0%)
Mutual labels:  module

NPM Version Build Status

quill-cursors

A collaborative editing module for the Quill text editor used by the Reedsy team.

Quill cursors

Install

npm install quill-cursors --save

Usage

quill-cursors is a Quill module that exposes a number of methods to help display other users' cursors for collaborative editing.

First, set up a Quill editor.

Next, load quill-cursors through any of the options presented by UMD.

Load script in HTML:

<script src="quill-cursors.js"></script>

Using ES6-style import:

import QuillCursors from 'quill-cursors';

Using CommonJS-style require:

const QuillCursors = require('quill-cursors');

Then, register the quill-cursors module:

Quill.register('modules/cursors', QuillCursors);

const quill = new Quill('#editor', {
  modules: {
    cursors: true,
  }
});

Finally, use the exposed quill-cursors methods to update the cursors (see below). For an example setup, see the example code, which can be run with:

npm start

API

Configuration

The quill-cursors module has the following optional configuration:

  • template string: override the default HTML template used for a cursor
  • containerClass string (default: ql-cursors): the CSS class to add to the cursors container
  • hideDelayMs number (default: 3000): number of milliseconds to show the username flag before hiding it
  • hideSpeedMs number (default: 400): the duration of the flag hiding animation in milliseconds
  • selectionChangeSource string | null (default: api): the event source to use when emitting selection-change
  • transformOnTextChange boolean (default: false): attempt to locally infer cursor positions whenever the editor contents change, without receiving an update from the other client. This can be useful for smoother performance on high-latency connections.
  • boundsContainer HTMLElement (default: Quill's bounds container): the element container used to determine flag positioning
  • positionFlag (flag: HTMLElement, caretRectangle: ClientRect, container: ClientRect) => void (default: flip horizontally): an optional function for positioning the caret flag according to its position relative to the bounds container. By default, the flag will flip horizontally when it reaches the right-hand edge of the bounds

Provide these options when setting up the Quill editor:

const editor = new Quill('#editor', {
  modules: {
    cursors: {
      template: '<div class="custom-cursor">...</div>',
      hideDelayMs: 5000,
      hideSpeedMs: 0,
      selectionChangeSource: null,
      transformOnTextChange: true,
    },
  },
});

template

For the custom template to work correctly with the module, it should closely follow the classes in the original template.

selectionChangeSource

By default, QuillJS will suppress selection-change events when typing to avoid noise.

However, you will probably want to update the quill-cursors selection on both selection-change and text-change. In order to aid this, quill-cursors will automatically emit a selection-change event on text-change.

You can differentiate between user input and the quill-cursors module by checking the source argument for the selection-change event. By default, quill-cursors will have source = 'api', but if you need to differentiate between calls from quill-cursors and other events, then you can change this source using the selectionChangeSource option.

If emitting an event is undesirable (eg you want selection-change to act like the Quill default), then the selectionChangeSource can be set to null, and an event will not be emitted. Note that in this case, you will need to separately handle the text-change event and update the cursor position.

Methods

The module instance can be retrieved through Quill's getModule:

const cursors = editor.getModule('cursors');

createCursor

createCursor(id: string, name: string, color: string): Cursor;

Creates a Cursor instance with the given id. If a cursor with this id already exists, a new one is not created.

  • id string: the unique ID for the cursor
  • name string: the name to display on the cursor
  • color string: the CSS color to use for the cursor

Returns a Cursor object:

{
  id: string;
  name: string;
  color: string;
  range: Range; // See https://quilljs.com/docs/api/#selection-change
}

moveCursor

moveCursor(id: string, range: QuillRange): void;

Sets the selection range of the cursor with the given id.

  • id string: the ID of the cursor to move
  • range Range: the selection range

removeCursor

removeCursor(id: string): void;

Removes the cursor with the given id from the DOM.

  • id string: the ID of the cursor to remove

update

update(): void;

Redraws all of the cursors in the DOM.

clearCursors

clearCursors(): void;

Removes all the cursors from the DOM.

toggleFlag

toggleFlag(id: string, shouldShow?: boolean): void;

Toggles display of the flag for the cursor with the given id.

  • id string: the ID of the cursor whose flag should be toggled
  • shouldShow boolean (optional): if set to true, will display the flag. If set to false, will hide it. If omitted, the flag's display state will be toggled.

cursors

cursors(): Cursor[];

Returns an array of all the Cursor objects in the DOM in no particular order.

License

This code is available 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].