Skip to content

Instantly share code, notes, and snippets.

@mkhatib
Created January 14, 2016 07:31
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 mkhatib/be16063feeee4e0ebe53 to your computer and use it in GitHub Desktop.
Save mkhatib/be16063feeee4e0ebe53 to your computer and use it in GitHub Desktop.
Carbon Usage
var element = document.getElementById('editor');
var editor = new carbon.Editor(element, {
rtl: true,
modules: [carbon.EmbeddedComponent]
});
editor.install(carbon.EmbeddingExtension, {
embedProviders: {
embedly: new carbon.EmbedlyProvider({
apiKey: EMBEDLY_API_KEY
}),
carbon: new carbon.CarbonEmbedProvider()
},
ComponentClass: carbon.EmbeddedComponent
});
editor.install(carbon.SelfieExtension);
editor.install(carbon.LayoutingExtension);
editor.render();
editor.addEventListener('change', function(event) {
localStorage.setItem('article', JSON.stringify(editor.getJSONModel()));
});
editor.addEventListener('attachment-added', function(event){
var attachment = event.detail.attachment;
var file = attachment.file;
uploadFile(file, function(response) {
attachment.setAttributes({
src: response.mediaLink,
caption: response.caption'
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment