Created
June 30, 2017 01:09
-
-
Save briandk/88795112c02d1f4718156d413dd17009 to your computer and use it in GitHub Desktop.
Extending classes in Quill to create a Timestamp Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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