0.0.75 • Published 8 years ago

sh-quill v0.0.75

Weekly downloads
9
License
MIT
Repository
github
Last release
8 years ago

Sh-Quill npm.io

A Quill component for React.

See the live demo.

  1. Quick start
  2. Styles and themes
  3. Bundling with Webpack
  4. API reference
  5. Building and testing

Quick start

  1. Use straight away:

    See the github page's live demo for quick start code examples

Using with Quill 1.0

If using Quill >1.0.0 as a dependency, the toolbar should be configured directly through the Quill module API rather than through the React-Quill wrapper.

  1. Mixing in:

    Use mix-ins to extend the functionality of Sh-Quill from the pre-built Quill mix-ins

    See component.js for a fully fleshed-out example.

Styles and themes

As a default setting Sh-Quill comes with the Quill theme snow set as default.

The Quill editor supports themes.

It includes a full-fledged theme, called snow, that is Quill's standard appearance, and a base theme containing only the bare essentials to allow modules like toolbars or tooltips to work.

These stylesheets can be found in the Quill distribution, but for convenience they are also linked among React Quill's dists. In a common case you would activate a theme like this:

<ShQuill theme='snow' />

And then link the appropriate stylesheet:

<link rel="stylesheet" href="../node_modules/react-quill/dist/quill.snow.css">

This may vary depending how application is structured, directories or otherwise. For example, if you use a CSS pre-processor like SASS, you may want to import that stylesheet inside your own.

Quill will include a set of basic styles upon instantiation, so that including quill.core.css is not needed. If you would instead like to avoid this style injection, so to include quill.core.css manually or use your own styles, pass false (not just a falsy value) as styles:

<ShQuill styles={false}>

Otherwise, you can set this to an object containing selectors and rules, that will be injected inside the document by Quill.

API reference

Exports

ShQuill.Mixin : Provides the bridge between React and Quill. ShQuill implements this mixin; in the same way you can use it to build your own component, or replace it to implement a new core for the default component.

ShQuill.Toolbar : The component that renders the basic ShQuill toolbar. The default collection of items and color swatches is available as ShQuill.Toolbar.defaultItems and ShQuill.Toolbar.defaultColors respectively.

ShQuill.Quill : The Quill namespace on which you can call registerModule and such.

Props

id : ID to be applied to the DOM element.

className : Classes to be applied to the DOM element.

value : Value for the editor as a controlled component. Note that due to limitations in Quill, this is actually a semi-controlled mode, meaning that the edit is not prevented, but changing value will still replace the contents.

defaultValue : Initial value for the editor as an uncontrolled component.

readOnly : If true, the editor won't allow changing its contents.

modules : An object specifying what modules are enabled, and their configuration. See the modules section over the Quill documentation for more information on what modules are available.

toolbar : A list of toolbar items to use as custom configuration for the toolbar. Pass false to disable the toolbar completely. Defaults items are available for reference in ShQuill.Toolbar.defaultItems and ShQuill.Toolbar.defaultColors. See also the Toolbar module over the Quill documentation for more information on the inner workings.

formats : An array of formats to be enabled during editing. All implemented formats are enabled by default. See Formats for a list. Also accepts definitions of custom formats:

[
  "list",
  "bullet",
  "bold",
  "italic",
  { name: "h1", tag: "H1", prepare: "heading", type: "line" },
  { name: "h2", tag: "H2", prepare: "heading", type: "line" },
  { name: "h3", tag: "H3", prepare: "heading", type: "line" }
];

style : An object with custom CSS rules to apply on the editor's container. Rules should be in React's "camelCased" naming style.

styles : An object with custom CSS selectors and rules to add to the editor. Neither should be in "camelCased" style. Pass false to prevent Quill from injecting any style at all (except for text formats). See configuration for details.

theme : The name of the theme to apply to the editor. Defaults to base.

bounds : Selector used by Quill to constrain position of popups. Defaults to document.body.

pollInterval : Interval in ms between checks for local changes in editor contents.

onChange(content, delta, source, editor) : Called back with the new contents of the editor after change. It will be passed the HTML contents of the editor, a delta object expressing the change-set itself, the source of the change, and finally a read-only proxy to editor accessors such as getText().

onChangeSelection(range, source, editor) : Called back with the new selected range, or null when unfocused. It will be passed the selection range, the source of the change, and finally a read-only proxy to editor accessors such as getBounds().

onKeyPress(event) : Called after a key has been pressed and released. : Note that, like its native counterpart, this won't be called for special keys such as shift or enter. If you need those, hook onto onKeyDown or onKeyUp.

onKeyDown(event) : Called after a key has been pressed, but before it is released. : Note that, due to how Quill works, it's possible that you won't receive events for keys such as enter, backspace or delete. If that's the case, try hooking onto onKeyUp instead.

onKeyUp(event) : Called after a key has been released.

Methods

If you have a ref to a ShQuill node, you will be able to invoke the following methods:

focus() : Focuses the editor.

blur() : Removes focus from the editor.

getEditor() : Returns the Quill instance that backs the editor. While you can freely use this to access methods such as getText(), please avoid from imperatively manipulating the instance.

Building and testing

You can run the automated test suite:

$ npm run test

And build a version of the source:

$ npm run build
0.0.75

8 years ago

0.0.74

8 years ago

0.0.73

8 years ago

0.0.72

8 years ago

0.0.71

8 years ago

0.0.70

8 years ago

0.0.67

8 years ago

0.0.66

8 years ago

0.0.65

8 years ago

0.0.64

8 years ago

0.0.63

9 years ago

0.0.61

9 years ago

0.0.60

9 years ago

0.0.59

9 years ago

0.0.58

9 years ago

0.0.57

9 years ago

0.0.56

9 years ago

0.0.55

9 years ago

0.0.54

9 years ago

0.0.53

9 years ago

0.0.52

9 years ago

0.0.51

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago