Skip to content

Instantly share code, notes, and snippets.

@mc-doc
Last active March 9, 2019 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mc-doc/63e9db1867cf3785cd565534f7137848 to your computer and use it in GitHub Desktop.
Save mc-doc/63e9db1867cf3785cd565534f7137848 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