Skip to content

Instantly share code, notes, and snippets.

@mkhatib
Created January 14, 2016 07:29
Show Gist options
  • Save mkhatib/ec20159754a48d509629 to your computer and use it in GitHub Desktop.
Save mkhatib/ec20159754a48d509629 to your computer and use it in GitHub Desktop.

Revisions

  1. mkhatib created this gist Jan 14, 2016.
    33 changes: 33 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    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'
    });
    });
    });
    10 changes: 10 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    <html>
    <head>
    <link rel="stylesheet" href="dist/carbon.min.css" />
    </head>
    <body>
    <div id="editor"></div>
    <script src="dist/carbon.min.js"></script>
    <script src="app.js"></script>
    </body>
    </html>