Skip to content

Commit

Permalink
Merge 0e343e3 into ef6f619
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Jun 2, 2015
2 parents ef6f619 + 0e343e3 commit 5e05b49
Show file tree
Hide file tree
Showing 30 changed files with 881 additions and 574 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = function (grunt) {
'src/js/extensions/fontsize.js',
'src/js/extensions/paste.js',
'src/js/extensions/placeholder.js',
'src/js/toolbar.js',
'src/js/extensions/toolbar.js',
'src/js/defaults/options.js',
'src/js/defaults/extensions.js',
'src/js/core.js',
Expand Down
8 changes: 6 additions & 2 deletions demo/custom-toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ <h2>Custom Labels </h2>
<script src="../dist/js/medium-editor.js"></script>
<script>
var editor = new MediumEditor('.editable', {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'removeFormat', 'outdent', 'indent', 'header1', 'header2'],
toolbar: {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'removeFormat', 'outdent', 'indent', 'header1', 'header2'],
},
buttonLabels: 'fontawesome',
anchor: {
targetCheckbox: true
}
});
var editor2 = new MediumEditor('.secondEditable', {
buttons: ['bold', 'italic', 'underline', 'anchor'],
toolbar: {
buttons: ['bold', 'italic', 'underline', 'anchor']
},
buttonLabels: {
'bold': 'bold',
'italic': '<i>italic</i>',
Expand Down
4 changes: 3 additions & 1 deletion demo/multi-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ <h2>Non editable Div</h2>
<script>
var editor = new MediumEditor('.editable'),
editor2 = new MediumEditor('.secondEditable', {
buttons: ['bold', 'italic', 'quote', 'pre']
toolbar: {
buttons: ['bold', 'italic', 'quote', 'pre']
}
});
</script>

Expand Down
4 changes: 3 additions & 1 deletion demo/multi-paragraph.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ <h1>Medium Editor Demo</h1>
<script>
var editor = new MediumEditor('.editable', {
allowMultiParagraphSelection: false,
diffTop: -12,
firstHeader: 'h1',
secondHeader: 'h2',
delay: 0,
toolbar: {
diffTop: -12
},
anchor: {
placeholderText: 'Type a link'
}
Expand Down
8 changes: 6 additions & 2 deletions demo/pass-instance.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ <h1>Medium Editor</h1>
};

var one = new MediumEditor('.one', {
buttons: ['extension'],
toolbar: {
buttons: ['extension'],
},
extensions: {
extension: new Extension()
}
});

var two = new MediumEditor('.two', {
buttons: ['extension'],
toolbar: {
buttons: ['extension'],
},
extensions: {
extension: new Extension()
}
Expand Down
50 changes: 29 additions & 21 deletions demo/static-toolbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,44 @@ <h3>Right Align</h3>
<script src="../dist/js/medium-editor.js"></script>
<script>
var editor = new MediumEditor('.editable', {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
staticToolbar: true,
stickyToolbar: true
toolbar: {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
static: true,
sticky: true
}
});

var editorColOne = new MediumEditor('#column-one', {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
buttonLabels: 'fontawesome',
stickyToolbar: true,
staticToolbar: true,
toolbarAlign: 'left',
updateOnEmptySelection: true
toolbar: {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
sticky: true,
static: true,
align: 'left',
updateOnEmptySelection: true
},
buttonLabels: 'fontawesome'
});

var editorColTwo = new MediumEditor('#column-two', {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
buttonLabels: 'fontawesome',
stickyToolbar: true,
staticToolbar: true,
toolbarAlign: 'center',
updateOnEmptySelection: true
toolbar: {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
sticky: true,
static: true,
align: 'center',
updateOnEmptySelection: true
},
buttonLabels: 'fontawesome'
});

var editorColThree = new MediumEditor('#column-three', {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
buttonLabels: 'fontawesome',
stickyToolbar: true,
staticToolbar: true,
toolbarAlign: 'right',
updateOnEmptySelection: true
toolbar: {
buttons: ['bold', 'italic', 'underline', 'strikethrough', 'quote', 'anchor', 'image', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'superscript', 'subscript', 'orderedlist', 'unorderedlist', 'pre', 'outdent', 'indent', 'header1', 'header2'],
sticky: true,
static: true,
align: 'right',
updateOnEmptySelection: true
},
buttonLabels: 'fontawesome'
});
</script>
</body>
Expand Down
6 changes: 4 additions & 2 deletions demo/table-extension.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ <h1>Medium Editor Extension Form</h1>
<script src="js/extension-table.js"></script>
<script>
var editor = new MediumEditor('.editable', {
buttons: ['bold', 'italic', 'underline', 'anchor', 'table'],
toolbar: {
buttons: ['bold', 'italic', 'underline', 'anchor', 'table'],
static: true,
},
buttonLabels: 'fontawesome',
staticToolbar: true,
extensions: {
'table': new TableExtension(),
}
Expand Down
19 changes: 11 additions & 8 deletions spec/anchor-preview.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*global describe, it, expect, spyOn, AnchorForm,
afterEach, beforeEach, jasmine, fireEvent, setupTestHelpers,
AnchorPreview, Toolbar */
AnchorPreview, MediumEditor */

describe('Anchor Preview TestCase', function () {
'use strict';
Expand All @@ -26,6 +26,7 @@ describe('Anchor Preview TestCase', function () {
var editor = this.newMediumEditor('.editor', {
delay: 200
}),
toolbar = editor.getExtensionByName('toolbar'),
sel = window.getSelection(),
anchorPreview = editor.getExtensionByName('anchor-preview'),
nextRange;
Expand All @@ -49,14 +50,14 @@ describe('Anchor Preview TestCase', function () {
expect(editor.getExtensionByName('anchor').showForm).toHaveBeenCalled();

// selecting other text should close the toolbar
spyOn(Toolbar.prototype, 'hideToolbar').and.callThrough();
spyOn(MediumEditor.extensions.toolbar.prototype, 'hideToolbar').and.callThrough();
nextRange = document.createRange();
nextRange.selectNodeContents(document.getElementById('another-element'));
sel.removeAllRanges();
sel.addRange(nextRange);
fireEvent(document.getElementById('another-element'), 'click');
jasmine.clock().tick(200);
expect(editor.toolbar.hideToolbar).toHaveBeenCalled();
expect(toolbar.hideToolbar).toHaveBeenCalled();
});

it('should be displayed on hover of a link element with markup inside', function () {
Expand Down Expand Up @@ -116,7 +117,9 @@ describe('Anchor Preview TestCase', function () {

it('should display the anchor form in the toolbar when clicked', function () {
var editor = this.newMediumEditor('.editor'),
anchorPreview = editor.getExtensionByName('anchor-preview');
anchorPreview = editor.getExtensionByName('anchor-preview'),
anchor = editor.getExtensionByName('anchor'),
toolbar = editor.getExtensionByName('toolbar');

// show preview
fireEvent(document.getElementById('test-link'), 'mouseover');
Expand All @@ -126,8 +129,8 @@ describe('Anchor Preview TestCase', function () {
fireEvent(anchorPreview.getPreviewElement(), 'click');
jasmine.clock().tick(200);

expect(editor.toolbar.isDisplayed()).toBe(true);
expect(editor.getExtensionByName('anchor').isDisplayed()).toBe(true);
expect(toolbar.isDisplayed()).toBe(true);
expect(anchor.isDisplayed()).toBe(true);
});

it('should NOT be displayed when the hovered link is empty', function () {
Expand Down Expand Up @@ -173,9 +176,9 @@ describe('Anchor Preview TestCase', function () {
expect(document.querySelector('.medium-editor-anchor-preview')).toBeNull();
});

it('should NOT be present when disableToolbar option is passed', function () {
it('should not be present when toolbar option is disabled', function () {
var editor = this.newMediumEditor('.editor', {
disableToolbar: true
toolbar: false
}),
anchorPreview = editor.getExtensionByName('anchor-preview');

Expand Down

0 comments on commit 5e05b49

Please sign in to comment.