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

Commit

Permalink
Patchin'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinchok committed Aug 12, 2014
1 parent 1f86d2b commit 002ad17
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
32 changes: 27 additions & 5 deletions build/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3534,7 +3534,7 @@ define('plugins/core/patches/commands/bold',[],function () {

return scribe.api.CommandPatch.prototype.queryEnabled.apply(this, arguments) && ! headingNode;
};

// TODO: We can't use STRONGs because this would mean we have to
// re-implement the `queryState` command, which would be difficult.

Expand Down Expand Up @@ -10741,6 +10741,28 @@ define('onion-editor',[
scribe.use(scribePluginPlaceholder(options.placeholder));
}

// For now, we need to patch some scribe commands, just in case.
scribe.commandPatches.bold.execute = function (value) {
if (this.selection === undefined) {
document.execCommand(this.commandName, false, value || null);
} else {
scribe.transactionManager.run(function () {
document.execCommand(this.commandName, false, value || null);
}.bind(this));
}
};
var italicCommand = new scribe.api.CommandPatch('italic');
italicCommand.execute = function (value) {
if (this.selection === undefined) {
document.execCommand(this.commandName, false, value || null);
} else {
scribe.transactionManager.run(function () {
document.execCommand(this.commandName, false, value || null);
}.bind(this));
}
};
scribe.commandPatches['italic'] = italicCommand;

var keyCommands = {};
var ctrlKey = function (event) { return event.metaKey || event.ctrlKey; };

Expand All @@ -10760,24 +10782,24 @@ 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 = {};
}

//Remove formatting...
// Remove formatting...
keyCommands.removeFormat = function (event) { return event.altKey && event.shiftKey && event.keyCode === 65; }; // a

// Links
Expand Down
Loading

0 comments on commit 002ad17

Please sign in to comment.