Last active
March 9, 2019 21:10
-
-
Save mc-doc/63e9db1867cf3785cd565534f7137848 to your computer and use it in GitHub Desktop.
example custom Quilljs block widget
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
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