Created
January 14, 2016 07:31
-
-
Save mkhatib/be16063feeee4e0ebe53 to your computer and use it in GitHub Desktop.
Carbon Usage
This file contains hidden or 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 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