Skip to content

Commit

Permalink
1.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Davi Ferreira committed Oct 23, 2013
1 parent 4030f3d commit a48b205
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
1.1.5 / 2013-10-13
==================

* Changes buttons blacklist to whitelist


1.1.4 / 2013-10-13
==================

* Exports MediumEditor as module
* Changes "Underline" button to display "U" instead of "S"


1.1.3 / 2013-10-08
==================

* Pasted text is now wrapped into P elements


1.1.2 / 2013-10-06
==================

Expand Down Expand Up @@ -36,19 +44,22 @@

* Fixes toolbar positioning on screen top


1.0.2 / 2013-09-24
==================

* Adds the possibility to pass an element list directly into initialization
* Fixes issue with initial positioning when some actions are disabled
* Don't rely on :last-child to style first/last element, as they may be hidden


1.0.1 / 2013-09-20
==================

* Changes demo texto to something more friendly
* Fixes shift+enter behavior


1.0.0 / 2013-08-26
==================

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var elements = document.querySelectorAll('.editable'),
## Initialization options

* __anchorInputPlaceholder__: text to be shown as placeholder of the anchor input. Default: _Paste or type a link_
* __buttons__: the set of buttons to display on the toolbar. Default: [ 'bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote' ]
* __buttons__: the set of buttons to display on the toolbar. Default: ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote']
* __delay__: time in milliseconds to show the toolbar. Default: 0
* __diffLeft__: value in pixels to be added to the X axis positioning of the toolbar. Default: 0
* __diffTop__: value in pixels to be added to the Y axis positioning of the toolbar. Default: -5
Expand All @@ -57,7 +57,7 @@ Example:
```javascript
var editor = new MediumEditor('.editable', {
anchorInputPlaceholder: 'Type a link',
buttons: [ 'bold', 'italic', 'quote' ]
buttons: ['bold', 'italic', 'quote']
diffLeft: 25,
diffTop: 10,
firstHeader: 'h1',
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
"version": "1.1.4",
"version": "1.1.5",
"homepage": "http://daviferreira.github.io/medium-editor/",
"authors": [
"Davi Ferreira <hi@daviferreira.com>"
Expand Down
49 changes: 29 additions & 20 deletions dist/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ if (window.module !== undefined) {
diffTop: -10,
disableReturn: false,
disableToolbar: false,
excludedActions: [],
firstHeader: 'h3',
forcePlainText: true,
placeholder: 'Type your text',
secondHeader: 'h4'
secondHeader: 'h4',
buttons: ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote']
},

init: function (elements, options) {
Expand Down Expand Up @@ -140,20 +140,38 @@ if (window.module !== undefined) {
});
},

buttonTemplate: function(btnType) {
var buttonTemplates = {
'bold': '<li><button class="medium-editor-action medium-editor-action-bold" data-action="bold" data-element="b">B</button></li>',
'italic': '<li><button class="medium-editor-action medium-editor-action-italic" data-action="italic" data-element="i">I</button></li>',
'underline': '<li><button class="medium-editor-action medium-editor-action-underline" data-action="underline" data-element="u">U</button></li>',
'anchor': '<li><button class="medium-editor-action medium-editor-action-anchor" data-action="anchor" data-element="a">#</button></li>',
'header1': '<li><button class="medium-editor-action medium-editor-action-header1" data-action="append-' + this.options.firstHeader + '" data-element="' + this.options.firstHeader + '">h1</button></li>',
'header2': '<li><button class="medium-editor-action medium-editor-action-header2" data-action="append-' + this.options.secondHeader + '" data-element="' + this.options.secondHeader + '">h2</button></li>',
'quote': '<li><button class="medium-editor-action medium-editor-action-quote" data-action="append-blockquote" data-element="blockquote">&ldquo;</button></li>'
};
return buttonTemplates[btnType];
},

//TODO: actionTemplate
toolbarTemplate: function () {
return '<ul id="medium-editor-toolbar-actions" class="medium-editor-toolbar-actions clearfix">' +
' <li><button class="medium-editor-action medium-editor-action-bold" data-action="bold" data-element="b">B</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-italic" data-action="italic" data-element="i">I</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-underline" data-action="underline" data-element="u">U</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-anchor" data-action="anchor" data-element="a">#</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-header1" data-action="append-' + this.options.firstHeader + '" data-element="' + this.options.firstHeader + '">h1</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-header2" data-action="append-' + this.options.secondHeader + '" data-element="' + this.options.secondHeader + '">h2</button></li>' +
' <li><button class="medium-editor-action medium-editor-action-quote" data-action="append-blockquote" data-element="blockquote">&ldquo;</button></li>' +
'</ul>' +
var btns = this.options.buttons,
html = '<ul id="medium-editor-toolbar-actions" class="medium-editor-toolbar-actions clearfix">',
i,
iBtn;

for (i = 0; i < btns.length; i += 1) {
iBtn = btns[i];

if (this.defaults.buttons.indexOf(iBtn) > -1) {
html += this.buttonTemplate(iBtn);
}
}
html += '</ul>' +
'<div class="medium-editor-toolbar-form-anchor" id="medium-editor-toolbar-form-anchor">' +
' <input type="text" value="" placeholder="' + this.options.anchorInputPlaceholder + '"><a href="#">&times;</a>' +
'</div>';
return html;
},

initToolbar: function () {
Expand Down Expand Up @@ -256,20 +274,11 @@ if (window.module !== undefined) {
i;
for (i = 0; i < buttons.length; i += 1) {
buttons[i].classList.remove('medium-editor-button-active');
this.showHideButton(buttons[i]);
}
this.checkActiveButtons();
return this;
},

showHideButton: function (button) {
if (this.options.excludedActions.indexOf(button.getAttribute('data-element')) > -1) {
button.style.display = 'none';
} else {
button.style.display = 'block';
}
},

checkActiveButtons: function () {
var parentNode = this.selection.anchorNode;
if (!parentNode.tagName) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/medium-editor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "medium-editor",
"version": "1.1.4",
"version": "1.1.5",
"description": "Medium.com WYSIWYG editor clone.",
"main": "src/js/medium-editor.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/js/medium-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if (window.module !== undefined) {
forcePlainText: true,
placeholder: 'Type your text',
secondHeader: 'h4',
buttons: [ 'bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote' ]
buttons: ['bold', 'italic', 'underline', 'anchor', 'header1', 'header2', 'quote']
},

init: function (elements, options) {
Expand Down

0 comments on commit a48b205

Please sign in to comment.