• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Quill.js Module which allows you to quickly view/edit the HTML in the editor

quill-html-edit-button

NPM Version License Downloads/week Github Issues

Quill.js Module which allows you to quickly view/edit the HTML in the editor

Demo

Install

yarn add quill-html-edit-button

Quickstart (Javascript)

import Quill from 'quill/core';
import Toolbar from 'quill/modules/toolbar';
import Snow from 'quill/themes/snow';

import htmlEditButton from "quill-html-edit-button";

Quill.register({
  'modules/toolbar': Toolbar,
  'themes/snow': Snow,
  "modules/htmlEditButton": htmlEditButton
})

const quill = new Quill(editor, {
  // ...
  modules: {
    // ...
    htmlEditButton: {}
  }
});

Quickstart (typescript)

Due to Quill's implementation, typescript integration is not trivial:

  • Follow the demo example here demos/typescript/src/index.ts
  • The file setup.js is to use the library without types (as they aren't implemented with quill modules).
  • Your tsconfig.json needs the following properties, to prevent errors:
  "compilerOptions": {
    "allowJs": true,
    "checkJs": false
  }

Quickstart (script tag)

<script src="https://unpkg.com/[email protected]/dist/quill.js"></script>
<script src="https://unpkg.com/[email protected]/dist/quill.htmlEditButton.min.js"></script>
<script>
  Quill.register("modules/htmlEditButton", htmlEditButton);
  const quill = new Quill(editor, {
    // ...
    modules: {
      // ...
      htmlEditButton: {}
    }
  });
</script>

Options

modules: {
  // ...
  htmlEditButton: {
    debug: true, // logging, default:false
    msg: "Edit the content in HTML format", //Custom message to display in the editor, default: Edit HTML here, when you click "OK" the quill editor's contents will be replaced
    okText: "Ok", // Text to display in the OK button, default: Ok,
    cancelText: "Cancel", // Text to display in the cancel button, default: Cancel
    buttonHTML: "&lt;&gt;", // Text to display in the toolbar button, default: <>
    buttonTitle: "Show HTML source", // Text to display as the tooltip for the toolbar button, default: Show HTML source
    syntax: false, // Show the HTML with syntax highlighting. Requires highlightjs on window.hljs (similar to Quill itself), default: false
    prependSelector: 'div#myelement', // a string used to select where you want to insert the overlayContainer, default: null (appends to body),
    editorModules: {} // The default mod
  }
}

Syntax Highlighting

By default syntax highlighting is off, if you want to enable it use syntax: true in the options (as shown above) and make sure you add the following script tags:

<link
  rel="stylesheet"
  href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/styles/github.min.css"
/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/highlight.min.js"></script>
<script
  charset="UTF-8"
  src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.2/languages/xml.min.js"
></script>

Alternatively, include these scripts in your package bundler, as long as highlightjs is available in the global space at window.hljs.

Customising The HTML Editor

The editor itself is actually a Quill Editor instance too! So you can pass in custom modules like this:

  // options
  htmlEditButton: {
    // Flags
    debug?: boolean;              // default:  false 
    syntax?: boolean;             // default:  false  
    // Overlay
    closeOnClickOverlay: boolean; // default:  true                       
    prependSelector: string;      // default:  null                       
    // Labels
    buttonHTML?: string;          // default:  "&lt;&gt;"
    buttonTitle?: string;         // default:  "Show HTML source"
    msg: string;                  // default:  'Edit HTML here, when you click "OK" the quill editor\'s contents will be replaced'     
    okText: string;               // default:  "Ok"
    cancelText: string;           // default:  "Cancel"            
    // Quill Modules (for the HTML editor)
    editorModules?: {             // default:  null
      // Any modules here will be declared in HTML quill editor instance
      keyboard: {
        bindings: {
          custom: {
            key: 'a',
            handler: function(range, context) {
              console.log('A KEY PRESSED!');
            }
          },
        },
      },
    },
  },

Thanks

This project is based on quill-image-uploader, thanks mate!

More Repositories

1

react-admin-firebase

A firebase data provider for the react-admin framework
TypeScript
429
star
2

react-admin-import-csv

A csv file import button for react-admin
TypeScript
119
star
3

quill-image-compress

A Quill rich text editor Module which compresses images uploaded to the editor
TypeScript
100
star
4

ngext

Better routing for Angular
TypeScript
82
star
5

react-admin-firebase-demo

Demo project for the react-admin-firebase npm package
JavaScript
46
star
6

command-pal

The hackable command palette for the web, inspired by Visual Studio Code.
HTML
41
star
7

newsit

Chrome Extension for Hacker News and Reddit Links
TypeScript
21
star
8

example-jest-firestore-triggers

An example of using jest to test firestore triggers
JavaScript
19
star
9

pdfstamp

A cli tool to stamp PDF's, using (ImageMagick and pdftk)
JavaScript
19
star
10

vuex-trace

Log actions & mutations in vuex! πŸš€
JavaScript
12
star
11

wealth-visualizer

Wealth Visualizer
Vue
11
star
12

vuetify-datatable-extended

An extension of vuetify-datatable to make filters a bit easier
Vue
10
star
13

ngx-filemanager

File manager for Angular
TypeScript
8
star
14

dokku-pages

Simple static sites on Dokku!
JavaScript
8
star
15

react-admin-firebase-demo-typescript

Demo project for the react-admin-firebase npm package
TypeScript
8
star
16

scrape-reduce

A simple way to scrape websites
TypeScript
7
star
17

localnotes.page

A simple website to write notes, stored in browser
HTML
3
star
18

frank-the-collie

Frank the Collie
Svelte
3
star
19

Meme-Bot-Messenger-Client

A meme responding bot for facebook messenger
JavaScript
3
star
20

quill-image-rotate-module

A module for Quill rich text editor to allow images to be rotated.
JavaScript
3
star
21

ngx-auto-table

A simple to use data table for Angular
TypeScript
3
star
22

twingex

A simple export format for Twine text adventure games
HTML
2
star
23

jira-to-github

Migrate JIRA issues to Github
TypeScript
2
star
24

zoomore

Zoom pictures and turn them into gifs!!
Dart
2
star
25

benw-blog

Stylus
1
star
26

benw-portal

My website portal!
HTML
1
star
27

mat-reduce

Angular Material is verbose, here's a wrapper library to reduce that!
TypeScript
1
star
28

pat.dog

JavaScript
1
star
29

gatsby-starter-netlify-cms

JavaScript
1
star
30

doughculator

A calculator for Dough!
TypeScript
1
star
31

cloud-html2pdf

A small node server to convert HTML documents to PDF
HTML
1
star
32

benwinding

1
star
33

ycomments-landingpage

CSS
1
star
34

lenny.homes

A website for my homie Lenny!
TypeScript
1
star
35

newsit-landingpage

HTML
1
star
36

myuni-dl

Command-line tool to download all files from a MyUni course
Python
1
star
37

mat-firebase-upload

An easy to use upload dropzone for Angular/Firebase.
TypeScript
1
star
38

firecache

Client-side state-management using Firebase
TypeScript
1
star
39

LEDMatrix64-Arduino

Based on "tomaskovacik/arduino" but altered for a 64x32 pixel LED display
Objective-C
1
star