Skip to content

Instantly share code, notes, and snippets.

@briandk
Created June 30, 2017 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandk/88795112c02d1f4718156d413dd17009 to your computer and use it in GitHub Desktop.
Save briandk/88795112c02d1f4718156d413dd17009 to your computer and use it in GitHub Desktop.
Extending classes in Quill to create a Timestamp Class
const Quill = require('quill');
// https://github.com/quilljs/quill/blob/develop/formats/link.js
const Link = Quill.import('formats/link');
class Timestamp extends Link {
static create(value) {
let node = super.create(value);
value = this.sanitize(value);
node.setAttribute('href', value);
node.setAttribute('target', '_blank');
node.setAttribute('class', 'timestamp'); // This is the only modification
return node;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment