Skip to content

Commit

Permalink
Merge pull request #4 from briangershon/clear-formatting
Browse files Browse the repository at this point in the history
Add a new feature (with toolbar button) for removing all formatting from a selected range.
  • Loading branch information
joshontheweb committed Jun 14, 2012
2 parents fa48fe2 + 4d1275c commit 51b2a70
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions scripts/etch.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// in the markup as "data-button-class"
etch.buttonClasses = {
'default': ['save'],
'all': ['bold', 'italic', 'underline', 'unordered-list', 'ordered-list', 'link', 'save'],
'all': ['bold', 'italic', 'underline', 'unordered-list', 'ordered-list', 'link', 'save', 'clear-formatting'],
'title': ['bold', 'italic', 'underline', 'save']
}

Expand Down Expand Up @@ -43,7 +43,8 @@
'click .etch-ordered-list': 'toggleOrderedList',
'click .etch-link': 'toggleLink',
'click .etch-image': 'getImage',
'click .etch-save': 'save'
'click .etch-save': 'save',
'click .etch-clear-formatting': 'clearFormatting'
},

changeEditable: function() {
Expand Down Expand Up @@ -88,6 +89,11 @@
range.surroundContents(el);
},

clearFormatting: function(e) {
e.preventDefault();
document.execCommand('removeFormat', false, null);
},

toggleBold: function(e) {
e.preventDefault();
document.execCommand('bold', false, null);
Expand Down
2 changes: 1 addition & 1 deletion styles/etch.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
.etch-editor-panel .etch-justify-right span { background-position: -300px 0; }
.etch-editor-panel .etch-cite span { background-position: -330px 0; }
.etch-editor-panel .etch-heading span { background-position: -360px 0; }

.etch-editor-panel .etch-clear-formatting span { background-position: -390px 0; }

Binary file modified styles/images/editor_icons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 51b2a70

Please sign in to comment.