Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Hopefully fixing some of these command issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Aug 12, 2014
1 parent 9c72e69 commit 1f86d2b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
36 changes: 18 additions & 18 deletions build/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10721,15 +10721,15 @@ define('onion-editor',[
domain: 'avclub.com'
},
video: {
videoEmbedUrl: "http://example.com?videoid=",
videoEmbedUrl: 'http://example.com?videoid=',
insertDialog: function() { },
editDialog: function() { }
},
image: {
insertDialog: function() { },
editDialog: function() { }
}
}
};

function OnionEditor(element, options) {

Expand All @@ -10748,7 +10748,7 @@ define('onion-editor',[
var tags = {},
/* if a node running throught the sanitizer passes this test, it won't get santized true */
skipSanitization = function(node) {
return ($(node).is("div.inline"));
return ($(node).is('div.inline'));
};

// Multiline
Expand All @@ -10760,20 +10760,20 @@ define('onion-editor',[

// Bold
if (options.formatting.indexOf('bold') !== -1) {
keyCommands.bold = function (event) { return event.metaKey && event.keyCode === 66; }; // b
// keyCommands.bold = function (event) { return event.metaKey && event.keyCode === 66; }; // b
tags.b = {};
}

// Italics
if (options.formatting.indexOf('italic') !== -1) {
keyCommands.italic = function (event) { return event.metaKey && event.keyCode === 73; }; // i
// keyCommands.italic = function (event) { return event.metaKey && event.keyCode === 73; }; // i
tags.i = {};
tags.em = {};
}

// Strike
if (options.formatting.indexOf('strike') !== -1) {
keyCommands.strikeThrough = function (event) { return event.altKey && event.shiftKey && event.keyCode === 83; }; // s
// keyCommands.strikeThrough = function (event) { return event.altKey && event.shiftKey && event.keyCode === 83; }; // s
tags.s = {};
}

Expand All @@ -10787,7 +10787,7 @@ define('onion-editor',[
scribe.use(scribePluginIntelligentUnlinkCommand());
scribe.use(scribePluginLinkUI(options.link));
scribe.use(linkFormatter(options.link));
tags.a = { href:true, target:true }
tags.a = { href:true, target:true };
}

// Lists
Expand Down Expand Up @@ -10861,22 +10861,22 @@ define('onion-editor',[
// Default is to skipFormatters. Only place this needs to be set to false is when updating links.
// We want formatters to run on links. Embeds & other shit seem to get sanitized
// despite there being safegaurds for that.
if (typeof skipFormatters == "undefined") {
if (typeof skipFormatters === 'undefined') {
skipFormatters = true;
}
scribe._skipFormatters = skipFormatters;
var scrollY = window.scrollY;
setTimeout(function() {
scribe.el.focus();
setTimeout(function() {
scribe.transactionManager.run(fn)
scribe.transactionManager.run(fn);
window.scrollTo(0, scrollY);

// This should notify any changes that happen outside of typing
scribe.trigger('content-changed');
}, 20);
}, 20);
}
};

scribe.use(scribePluginCurlyQuotes());
scribe.use(scribePluginKeyboardShortcuts(Object.freeze(keyCommands)));
Expand All @@ -10890,31 +10890,31 @@ define('onion-editor',[
}

// a little hacky to prevent deletion of images and other inline elements via the backspace key.
scribe.el.addEventListener("keydown", function(event) {
scribe.el.addEventListener('keydown', function(event) {
if (event.keyCode === 8) {
// is the previous immediate child of editor an inline item?
var sel = new scribe.api.Selection();
var prev = $(sel.selection.anchorNode).closest(".editor>*").prev();
if (prev.hasClass("inline")
var prev = $(sel.selection.anchorNode).closest('.editor>*').prev();
if (prev.hasClass('inline')
&& sel.selection.anchorOffset === 0
&& sel.selection.isCollapsed) {
event.preventDefault();
}
}
})
});

scribe.use(scribePluginFormatterPlainTextConvertNewLinesToHtml());

this.setChangeHandler = function(func) {
scribe.on('content-changed', func);
}
};

this.setContent = function(content) {
if (!content) {
content = "<p><br></p>";
content = '<p><br></p>';
}
scribe.setContent(content);
}
};

this.getContent = function() {
//todo: if multiline is false, only return contents of the paragraph
Expand All @@ -10923,7 +10923,7 @@ define('onion-editor',[

// Allow any plugins to clean up markup. Main use case is for embed plugin, atm.
return contents;
}
};

this.scribe = scribe;
return this;
Expand Down
4 changes: 2 additions & 2 deletions build/onion-editor.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ module.exports = function(config) {
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
reporters: ['progress'],


// web server port
Expand Down Expand Up @@ -115,7 +115,6 @@ module.exports = function(config) {
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER
};

config.customLaunchers = customLaunchers;
config.browsers = Object.keys(customLaunchers);
config.singleRun = true;
config.reporters.push('saucelabs');
Expand Down
36 changes: 18 additions & 18 deletions src/js/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ define('onion-editor',[
domain: 'avclub.com'
},
video: {
videoEmbedUrl: "http://example.com?videoid=",
videoEmbedUrl: 'http://example.com?videoid=',
insertDialog: function() { },
editDialog: function() { }
},
image: {
insertDialog: function() { },
editDialog: function() { }
}
}
};

function OnionEditor(element, options) {

Expand All @@ -76,7 +76,7 @@ define('onion-editor',[
var tags = {},
/* if a node running throught the sanitizer passes this test, it won't get santized true */
skipSanitization = function(node) {
return ($(node).is("div.inline"));
return ($(node).is('div.inline'));
};

// Multiline
Expand All @@ -88,20 +88,20 @@ define('onion-editor',[

// Bold
if (options.formatting.indexOf('bold') !== -1) {
keyCommands.bold = function (event) { return event.metaKey && event.keyCode === 66; }; // b
// keyCommands.bold = function (event) { return event.metaKey && event.keyCode === 66; }; // b
tags.b = {};
}

// Italics
if (options.formatting.indexOf('italic') !== -1) {
keyCommands.italic = function (event) { return event.metaKey && event.keyCode === 73; }; // i
// keyCommands.italic = function (event) { return event.metaKey && event.keyCode === 73; }; // i
tags.i = {};
tags.em = {};
}

// Strike
if (options.formatting.indexOf('strike') !== -1) {
keyCommands.strikeThrough = function (event) { return event.altKey && event.shiftKey && event.keyCode === 83; }; // s
// keyCommands.strikeThrough = function (event) { return event.altKey && event.shiftKey && event.keyCode === 83; }; // s
tags.s = {};
}

Expand All @@ -115,7 +115,7 @@ define('onion-editor',[
scribe.use(scribePluginIntelligentUnlinkCommand());
scribe.use(scribePluginLinkUI(options.link));
scribe.use(linkFormatter(options.link));
tags.a = { href:true, target:true }
tags.a = { href:true, target:true };
}

// Lists
Expand Down Expand Up @@ -189,22 +189,22 @@ define('onion-editor',[
// Default is to skipFormatters. Only place this needs to be set to false is when updating links.
// We want formatters to run on links. Embeds & other shit seem to get sanitized
// despite there being safegaurds for that.
if (typeof skipFormatters == "undefined") {
if (typeof skipFormatters === 'undefined') {
skipFormatters = true;
}
scribe._skipFormatters = skipFormatters;
var scrollY = window.scrollY;
setTimeout(function() {
scribe.el.focus();
setTimeout(function() {
scribe.transactionManager.run(fn)
scribe.transactionManager.run(fn);
window.scrollTo(0, scrollY);

// This should notify any changes that happen outside of typing
scribe.trigger('content-changed');
}, 20);
}, 20);
}
};

scribe.use(scribePluginCurlyQuotes());
scribe.use(scribePluginKeyboardShortcuts(Object.freeze(keyCommands)));
Expand All @@ -218,31 +218,31 @@ define('onion-editor',[
}

// a little hacky to prevent deletion of images and other inline elements via the backspace key.
scribe.el.addEventListener("keydown", function(event) {
scribe.el.addEventListener('keydown', function(event) {
if (event.keyCode === 8) {
// is the previous immediate child of editor an inline item?
var sel = new scribe.api.Selection();
var prev = $(sel.selection.anchorNode).closest(".editor>*").prev();
if (prev.hasClass("inline")
var prev = $(sel.selection.anchorNode).closest('.editor>*').prev();
if (prev.hasClass('inline')
&& sel.selection.anchorOffset === 0
&& sel.selection.isCollapsed) {
event.preventDefault();
}
}
})
});

scribe.use(scribePluginFormatterPlainTextConvertNewLinesToHtml());

this.setChangeHandler = function(func) {
scribe.on('content-changed', func);
}
};

this.setContent = function(content) {
if (!content) {
content = "<p><br></p>";
content = '<p><br></p>';
}
scribe.setContent(content);
}
};

this.getContent = function() {
//todo: if multiline is false, only return contents of the paragraph
Expand All @@ -251,7 +251,7 @@ define('onion-editor',[

// Allow any plugins to clean up markup. Main use case is for embed plugin, atm.
return contents;
}
};

this.scribe = scribe;
return this;
Expand Down

0 comments on commit 1f86d2b

Please sign in to comment.