Skip to content

Instantly share code, notes, and snippets.

@nktvrm79
Forked from mc-doc/custom-Quilljs-block.js
Last active March 2, 2019 14:56
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 nktvrm79/9b2fca80c76ffc0abf3f8b6ca8f34ada to your computer and use it in GitHub Desktop.
Save nktvrm79/9b2fca80c76ffc0abf3f8b6ca8f34ada to your computer and use it in GitHub Desktop.
example custom Quilljs block widget
var BlockSDK = require('blocksdk');
if (window.self === window.top) {
document.body.innerText = 'This application is for use in the Salesforce Marketing Cloud Content Builder Editor only.';
} else {
var sdk = new BlockSDK();
sdk.getContent(function (content) {
var quill = new Quill('#editor-container', {
theme: 'snow'
});
quill.root.innerHTML = content;
function saveText() {
var html = quill.root.innerHTML;
sdk.setContent(html);
sdk.setSuperContent('This is super content: ' + html);
sdk.getData(function (data) {
var numberOfEdits = data.numberOfEdits || 0;
sdk.setData({
numberOfEdits: numberOfEdits + 1
});
});
}
quill.on('text-change', saveText);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment