Skip to content

Commit

Permalink
cleaner embed url settings
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoitch committed Aug 31, 2014
1 parent df3de85 commit 6f0a1de
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 37 deletions.
31 changes: 12 additions & 19 deletions dist/content-kit-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @version 0.1.0
* @author Garth Poitras <garth22@gmail.com> (http://garthpoitras.com/)
* @license MIT
* Last modified: Aug 30, 2014
* Last modified: Aug 31, 2014
*/

(function(exports, document) {
Expand Down Expand Up @@ -1499,12 +1499,12 @@ define("content-kit-editor/commands/image",
}
}

function ImageCommand() {
function ImageCommand(options) {
Command.call(this, {
name: 'image',
button: '<i class="ck-icon-image"></i>'
});
this.uploader = new FileUploader({ url: '/upload', maxFileSize: 5000000 });
this.uploader = new FileUploader({ url: options.serviceUrl, maxFileSize: 5000000 });
}
inherit(ImageCommand, Command);

Expand Down Expand Up @@ -1669,7 +1669,7 @@ define("content-kit-editor/commands/oembed",
}
}

function OEmbedCommand() {
function OEmbedCommand(options) {
Command.call(this, {
name: 'embed',
button: '<i class="ck-icon-embed"></i>',
Expand All @@ -1679,7 +1679,7 @@ define("content-kit-editor/commands/oembed",
})
});

this.embedService = new OEmbedder({ url: '/embed' });
this.embedService = new OEmbedder({ url: options.serviceUrl });
}
inherit(OEmbedCommand, Command);

Expand Down Expand Up @@ -1959,8 +1959,8 @@ define("content-kit-editor/editor/editor",
new SubheadingCommand()
],
embedCommands: [
new ImageCommand(),
new OEmbedCommand()
new ImageCommand({ serviceUrl: '/images' }),
new OEmbedCommand({ serviceUrl: '/embed' })
],
autoTypingCommands: [
new UnorderedListCommand(),
Expand Down Expand Up @@ -2028,21 +2028,13 @@ define("content-kit-editor/editor/editor",
}

function initEmbedCommands(editor) {
if(editor.embedCommands) {
var embedIntent = new EmbedIntent({
var commands = editor.embedCommands;
if(commands) {
return new EmbedIntent({
editorContext: editor,
commands: editor.embedCommands,
commands: commands,
rootElement: editor.element
});

if (editor.imageServiceUrl) {
// TODO: lookup by name
editor.embedCommands[0].uploader.url = editor.imageServiceUrl;
}
if (editor.embedServiceUrl) {
// TODO: lookup by name
editor.embedCommands[1].embedService.url = editor.embedServiceUrl;
}
}
}

Expand Down Expand Up @@ -2288,6 +2280,7 @@ define("content-kit-editor/utils/event-emitter",
function(__exports__) {
"use strict";
// Based on https://github.com/jeromeetienne/microevent.js/blob/master/microevent.js
// See also: https://github.com/allouis/minivents/blob/master/minivents.js

var EventEmitter = {
on : function(type, handler){
Expand Down
4 changes: 2 additions & 2 deletions src/js/content-kit-editor/commands/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function renderFromFile(file, editor) {
}
}

function ImageCommand() {
function ImageCommand(options) {
Command.call(this, {
name: 'image',
button: '<i class="ck-icon-image"></i>'
});
this.uploader = new FileUploader({ url: '/upload', maxFileSize: 5000000 });
this.uploader = new FileUploader({ url: options.serviceUrl, maxFileSize: 5000000 });
}
inherit(ImageCommand, Command);

Expand Down
4 changes: 2 additions & 2 deletions src/js/content-kit-editor/commands/oembed.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function loadTwitterWidgets(element) {
}
}

function OEmbedCommand() {
function OEmbedCommand(options) {
Command.call(this, {
name: 'embed',
button: '<i class="ck-icon-embed"></i>',
Expand All @@ -26,7 +26,7 @@ function OEmbedCommand() {
})
});

this.embedService = new OEmbedder({ url: '/embed' });
this.embedService = new OEmbedder({ url: options.serviceUrl });
}
inherit(OEmbedCommand, Command);

Expand Down
20 changes: 6 additions & 14 deletions src/js/content-kit-editor/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ var defaults = {
new SubheadingCommand()
],
embedCommands: [
new ImageCommand(),
new OEmbedCommand()
new ImageCommand({ serviceUrl: '/images' }),
new OEmbedCommand({ serviceUrl: '/embed' })
],
autoTypingCommands: [
new UnorderedListCommand(),
Expand Down Expand Up @@ -105,21 +105,13 @@ function bindLiveUpdate(editor) {
}

function initEmbedCommands(editor) {
if(editor.embedCommands) {
var embedIntent = new EmbedIntent({
var commands = editor.embedCommands;
if(commands) {
return new EmbedIntent({
editorContext: editor,
commands: editor.embedCommands,
commands: commands,
rootElement: editor.element
});

if (editor.imageServiceUrl) {
// TODO: lookup by name
editor.embedCommands[0].uploader.url = editor.imageServiceUrl;
}
if (editor.embedServiceUrl) {
// TODO: lookup by name
editor.embedCommands[1].embedService.url = editor.embedServiceUrl;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/js/content-kit-editor/utils/event-emitter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Based on https://github.com/jeromeetienne/microevent.js/blob/master/microevent.js
// See also: https://github.com/allouis/minivents/blob/master/minivents.js

var EventEmitter = {
on : function(type, handler){
Expand Down

0 comments on commit 6f0a1de

Please sign in to comment.