---
title: Quill - Rich Content Editor
product: Form Library
description: Form builder tool with Quill, a rich text editor that enables users to input and format their content with bold, italics, lists, hyperlinks, and more. View a free demo for JavaScript to learn how to integrate Quill into SurveyJS.
framework: jQuery
source: https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/jquery
index: https://surveyjs.io/form-library/examples/overview.md
---

# Quill - Rich Content Editor (jQuery)

A rich text editor is a tool that allows users to create, edit, and format text using advanced features. For instance, your respondents can apply a bold, italic, or underline font style to text, add bullet points, numbered lists, hyperlinks, adjust text alignment, and more. This demo shows how to integrate the <a href="https://quilljs.com/" target="_blank">Quill</a> text editor into your survey.

For a step-by step Quill integration tutorial, refer to the following documentation articles. Although they describe integration of a color picker, the same instructions apply to any other third-party component, including Quill. 

- [Integrate Third-Party React Components](https://surveyjs.io/form-library/documentation/customize-question-types/third-party-component-integration-react)
- [Integrate Third-Party Angular Components](https://surveyjs.io/form-library/documentation/customize-question-types/third-party-component-integration-angular)
- [Integrate Third-Party Vue 3 Components](/form-library/documentation/customize-question-types/third-party-component-integration-vue)

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/index.css`

```css
.ql-toolbar.ql-snow {
    white-space: normal;
}
```

### `src/quill.js`

```js
import { CustomWidgetCollection, Serializer, ElementFactory } from "survey-core";
import Quill from "quill";
import "quill/dist/quill.snow.css";

const componentName = "quill";

function initQuill() {
    const iconId = "icon-editor";
    var widget = {
        name: componentName,
        title: "Quill",
        iconName: iconId,
        widgetIsLoaded: function () {
            return Quill !== undefined;
        },
        isFit: function (question) {
            return question.getType() === componentName;
        },
        activatedByChanged: function (activatedBy) {
            Serializer.addClass(componentName, [], null, "empty");
            let registerQuestion = ElementFactory.Instance.registerCustomQuestion;
            if (!!registerQuestion) registerQuestion(componentName);
            Serializer.addProperty(componentName, {
                name: "height",
                default: "200px",
                category: "layout"
            });
        },
        htmlTemplate: "<div></div>",
        afterRender: function (question, el) {
            el.style.height = question.height;
            var editor = new Quill(el, {
                theme: "snow"
            });
            editor.enable(!question.isReadOnly);
            var isValueChanging = false;
            editor.on("text-change", function (eventName, ...args) {
                isValueChanging = true;
                question.value = editor.root.innerHTML;
                isValueChanging = false;
            });
            var updateValueHandler = function () {
                if (isValueChanging) return;
                const text = question.value || "";
                editor.root.innerHTML = text;
            };
            question.valueChangedCallback = updateValueHandler;
            question.readOnlyChangedCallback = function () {
                editor.enable(!question.isReadOnly);
            };
            updateValueHandler();
        },
        willUnmount: function (question, el) { }
    };

    CustomWidgetCollection.Instance.addCustomWidget(widget, "customtype");
}

if (!Serializer.findClass(componentName)) {
    initQuill();
}
```

### `src/index.js`

```js
import $ from "jquery";
import { Model } from "survey-core";
import "survey-js-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";
export * from "./quill";

import { registerFunction } from "survey-core";

function encodeHtml([ input ]) {
    return input
        .replace(/&/g, '&amp;')
        .replace(/</g, '&lt;')
        .replace(/>/g, '&gt;');
}
registerFunction({ name: "encodeHtml", func: encodeHtml });

const survey = new Model(json);
survey.onComplete.add((sender, options) => {
    console.log(JSON.stringify(sender.data, null, 3));
});

$("#surveyElement").Survey({ model: survey });
```

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "type": "quill",
      "name": "rich-text-editor",
      "defaultValue": "Hello world!"
    },
    {
      "type": "html",
      "name": "rich-text-editor-html",
      "html": "{encodedHtml}"
    }
  ],
  "calculatedValues": [{
    "name": "encodedHtml",
    "expression": "encodeHtml({rich-text-editor})"
  }],
  "questionTitleLocation": "hidden",
  "showNavigationButtons": false
}
;
```

### `package.json`

```json
{
  "dependencies": {
    "jquery": "latest",
    "quill": "^1.3.7",
    
    "survey-core": "latest",
    "survey-js-ui": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/angular.md)
- [React](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/reactjs.md)
- [Vue 3](https://surveyjs.io/form-library/examples/form-builder-with-rich-content-editor/vue3js.md)
