medium-editor
Advanced tools
Comparing version 4.12.6 to 4.12.7
@@ -0,0 +0,0 @@ { |
@@ -0,1 +1,10 @@ | ||
4.12.7 / 2015-08-04 | ||
================== | ||
* Fix issue with finding anchor when clicking anchor button | ||
* Fix issue where block elements outside of range were removed on paste | ||
* Fix issue with creating links and restoring selection after empty paragraphs | ||
* Fix issue with selection spanning empty paragraphs after creating link | ||
* Fix test broken with Chrome for Windows updates | ||
4.12.5 / 2015-06-16 | ||
@@ -2,0 +11,0 @@ ================== |
@@ -0,0 +0,0 @@ # Contributing |
@@ -0,0 +0,0 @@ var TableExtension; |
@@ -0,0 +0,0 @@ /*global module, require, process*/ |
{ | ||
"name": "medium-editor", | ||
"version": "4.12.6", | ||
"version": "4.12.7", | ||
"author": "Davi Ferreira <hi@daviferreira.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -0,0 +0,0 @@ # MediumEditor |
@@ -197,4 +197,17 @@ /*global MediumEditor, describe, it, expect, spyOn, AnchorForm, | ||
}); | ||
it('should NOT be in the DOM when a custom anchorPreview extension is provided', function () { | ||
var editor = this.newMediumEditor('.editor', { | ||
extensions: { | ||
'anchor-preview': {} | ||
} | ||
}); | ||
expect(document.querySelector('.medium-editor-anchor-preview')).toBeNull(); | ||
// destroy | ||
editor.destroy(); | ||
}); | ||
}); | ||
}); |
/*global MediumEditor, describe, it, expect, spyOn, | ||
afterEach, beforeEach, selectElementContents, | ||
jasmine, fireEvent, Util, setupTestHelpers, | ||
selectElementContentsAndFire, AnchorForm */ | ||
selectElementContentsAndFire, Selection */ | ||
@@ -275,2 +275,35 @@ describe('Anchor Button TestCase', function () { | ||
}); | ||
it('should not select empty paragraphs when link is created at beginning of paragraph', function () { | ||
spyOn(MediumEditor.prototype, 'createLink').and.callThrough(); | ||
this.el.innerHTML = '<p>Some text</p><p><br/></p><p><br/></p><p>link text more text</p>'; | ||
var editor = this.newMediumEditor('.editor'), | ||
lastP = this.el.lastChild, | ||
anchorExtension = editor.getExtensionByName('anchor'); | ||
// Select the text 'link text' in the last paragraph | ||
MediumEditor.selection.select(document, lastP.firstChild, 0, lastP.firstChild, 'link text'.length); | ||
fireEvent(editor.elements[0], 'focus'); | ||
jasmine.clock().tick(1); | ||
// Click the 'anchor' button in the toolbar | ||
fireEvent(editor.toolbar.getToolbarElement().querySelector('[data-action="createLink"]'), 'click'); | ||
// Input a url and save | ||
var input = anchorExtension.getInput(); | ||
input.value = 'http://www.example.com'; | ||
fireEvent(input, 'keyup', { | ||
keyCode: Util.keyCode.ENTER | ||
}); | ||
expect(editor.createLink).toHaveBeenCalledWith({ | ||
url: 'http://www.example.com', | ||
target: '_self' | ||
}); | ||
// Make sure selection is only the link | ||
var range = window.getSelection().getRangeAt(0); | ||
expect(MediumEditor.util.isDescendant(lastP, range.startContainer, true)).toBe(true, 'The start of the selection is incorrect'); | ||
expect(MediumEditor.util.isDescendant(lastP, range.endContainer, true)).toBe(true, 'The end of the selection is incorrect'); | ||
}); | ||
}); | ||
@@ -312,3 +345,3 @@ | ||
it('should display the anchor form when toolbar is visible', function () { | ||
spyOn(AnchorForm.prototype, 'showForm').and.callThrough(); | ||
spyOn(MediumEditor.extensions.anchor.prototype, 'showForm').and.callThrough(); | ||
var button, | ||
@@ -339,4 +372,25 @@ editor = this.newMediumEditor('.editor'), | ||
// https://github.com/yabwe/medium-editor/issues/751 | ||
it('should allow more than one link creation within a paragraph', function () { | ||
spyOn(MediumEditor.extensions.anchor.prototype, 'showForm').and.callThrough(); | ||
this.el.innerHTML = '<p><a href="#">beginning</a> some text middle some text end</p>'; | ||
var editor = this.newMediumEditor('.editor'), | ||
anchorExtension = editor.getExtensionByName('anchor'), | ||
para = this.el.firstChild; | ||
// Select the text 'middle' | ||
Selection.select(document, para.childNodes[1], 11, para.childNodes[1], 18); | ||
fireEvent(editor.elements[0], 'focus'); | ||
jasmine.clock().tick(1); | ||
// Click the 'anchor' button in the toolbar | ||
fireEvent(editor.toolbar.getToolbarElement().querySelector('[data-action="createLink"]'), 'click'); | ||
expect(editor.toolbar.getToolbarActionsElement().style.display).toBe('none'); | ||
expect(anchorExtension.isDisplayed()).toBe(true); | ||
expect(anchorExtension.showForm).toHaveBeenCalled(); | ||
expect(anchorExtension.getInput().value).toBe(''); | ||
}); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ /*global describe, it, expect, beforeEach, afterEach, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, AnchorForm, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, beforeEach, afterEach, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, jasmine, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, jasmine, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, afterEach, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, afterEach, beforeEach, |
@@ -0,0 +0,0 @@ /*global describe, it, expect, afterEach, Util, |
@@ -0,0 +0,0 @@ /*global atob, unescape, Uint8Array, Blob*/ |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, |
@@ -114,3 +114,3 @@ /*global describe, it, expect, Util, | ||
} else { | ||
expect(placeholder).toBe('\'' + expectedValue + '\''); | ||
expect(placeholder).toMatch(new RegExp('^[\'"]' + expectedValue + '[\'"]$')); | ||
} | ||
@@ -117,0 +117,0 @@ } |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, |
@@ -66,2 +66,23 @@ /*global MediumEditor, describe, it, expect, spyOn, | ||
// https://github.com/yabwe/medium-editor/issues/738 | ||
it('should import an exported non-collapsed selection after an empty paragraph', function () { | ||
this.el.innerHTML = '<p>This is <a href="#">a link</a></p><p><br/></p><p>not a link</p>'; | ||
var editor = this.newMediumEditor('.editor'), | ||
lastTextNode = this.el.childNodes[2].firstChild; | ||
MediumEditor.selection.select(document, lastTextNode, 0, lastTextNode, 'not a link'.length); | ||
var exportedSelection = editor.exportSelection(); | ||
expect(exportedSelection).toEqual({ start: 14, end: 24, emptyBlocksIndex: 2 }); | ||
editor.importSelection(exportedSelection); | ||
var range = window.getSelection().getRangeAt(0); | ||
expect(range.startContainer === lastTextNode || range.startContainer === lastTextNode.parentNode) | ||
.toBe(true, 'The selection is starting at the wrong element'); | ||
expect(range.startOffset).toBe(0, 'The start of the selection is not at the beginning of the text node'); | ||
expect(range.endContainer === lastTextNode || range.endContainer === lastTextNode.parentNode) | ||
.toBe(true, 'The selection is ending at the wrong element'); | ||
expect(range.endOffset).toBe('not a link'.length, 'The end of the selection is not at the end of the text node'); | ||
}); | ||
it('should have an index in the exported selection when it is in the second contenteditable', function () { | ||
@@ -68,0 +89,0 @@ this.createElement('div', 'editor', 'lorem <i>ipsum</i> dolor'); |
@@ -0,0 +0,0 @@ /*global describe, it, expect, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, jasmine, |
@@ -0,0 +0,0 @@ /*global describe, it, beforeEach, afterEach, expect, |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ /*global MediumEditor, Util, describe, it, expect, spyOn, |
@@ -0,0 +0,0 @@ (function () { |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /*global MediumEditor, describe, it, expect */ |
@@ -1005,3 +1005,3 @@ /*global Util, ButtonsData, Selection, Extension, | ||
if (inSelectionState.emptyBlocksIndex && selectionState.end === nextCharIndex) { | ||
if (inSelectionState.emptyBlocksIndex) { | ||
var targetNode = Util.getBlockContainer(range.startContainer), | ||
@@ -1022,3 +1022,2 @@ index = 0; | ||
range.setStart(Util.getFirstSelectableLeafNode(targetNode), 0); | ||
range.collapse(true); | ||
} | ||
@@ -1025,0 +1024,0 @@ |
@@ -0,0 +0,0 @@ var ButtonsData; |
@@ -0,0 +0,0 @@ /*global Button, FormExtension, |
@@ -0,0 +0,0 @@ var editorDefaults; |
@@ -0,0 +0,0 @@ /*global Util*/ |
@@ -0,0 +0,0 @@ var Extension; |
@@ -0,0 +0,0 @@ var AnchorPreview; |
@@ -58,6 +58,7 @@ var AnchorForm; | ||
var selectedParentElement = Selection.getSelectedParentElement(Selection.getSelectionRange(this.document)), | ||
firstTextNode = Util.getFirstTextNode(selectedParentElement); | ||
var range = Selection.getSelectionRange(this.document); | ||
if (Util.getClosestTag(firstTextNode, 'a')) { | ||
if (range.startContainer.nodeName.toLowerCase() === 'a' || | ||
range.endContainer.nodeName.toLowerCase() === 'a' || | ||
Util.getClosestTag(Selection.getSelectedParentElement(range), 'a')) { | ||
return this.execAction('unlink'); | ||
@@ -64,0 +65,0 @@ } |
@@ -0,0 +0,0 @@ /*global Extension, Util */ |
@@ -0,0 +0,0 @@ var Button; |
@@ -0,0 +0,0 @@ /*global Util*/ |
@@ -0,0 +0,0 @@ /*global Util, Selection, DefaultButton */ |
@@ -0,0 +0,0 @@ /*global Util */ |
@@ -0,0 +0,0 @@ /*global Util, DefaultButton, Selection */ |
@@ -0,0 +0,0 @@ var FontSizeForm; |
@@ -0,0 +0,0 @@ var FormExtension; |
@@ -0,0 +0,0 @@ /*global Util, Extension */ |
@@ -1,2 +0,2 @@ | ||
/*global Util, Selection, Extension */ | ||
/*global Util, Extension */ | ||
var PasteHandler; | ||
@@ -143,4 +143,3 @@ | ||
cleanPaste: function (text) { | ||
var i, elList, workEl, | ||
el = Selection.getSelectionElement(this.window), | ||
var i, elList, | ||
multiline = /<p|<br|<div/.test(text), | ||
@@ -161,27 +160,2 @@ replacements = createReplacements().concat(this.cleanReplacements || []); | ||
this.pasteHTML('<p>' + elList.join('</p><p>') + '</p>'); | ||
try { | ||
this.document.execCommand('insertText', false, '\n'); | ||
} catch (ignore) { } | ||
// block element cleanup | ||
elList = el.querySelectorAll('a,p,div,br'); | ||
for (i = 0; i < elList.length; i += 1) { | ||
workEl = elList[i]; | ||
// Microsoft Word replaces some spaces with newlines. | ||
// While newlines between block elements are meaningless, newlines within | ||
// elements are sometimes actually spaces. | ||
workEl.innerHTML = workEl.innerHTML.replace(/\n/gi, ' '); | ||
switch (workEl.tagName.toLowerCase()) { | ||
case 'p': | ||
case 'div': | ||
this.filterCommonBlocks(workEl); | ||
break; | ||
case 'br': | ||
this.filterLineBreak(workEl); | ||
break; | ||
} | ||
} | ||
}, | ||
@@ -205,3 +179,2 @@ | ||
elList = fragmentBody.querySelectorAll('*'); | ||
for (i = 0; i < elList.length; i += 1) { | ||
@@ -218,2 +191,23 @@ workEl = elList[i]; | ||
// block element cleanup | ||
elList = fragmentBody.querySelectorAll('a,p,div,br'); | ||
for (i = 0; i < elList.length; i += 1) { | ||
workEl = elList[i]; | ||
// Microsoft Word replaces some spaces with newlines. | ||
// While newlines between block elements are meaningless, newlines within | ||
// elements are sometimes actually spaces. | ||
workEl.innerHTML = workEl.innerHTML.replace(/\n/gi, ' '); | ||
switch (workEl.nodeName.toLowerCase()) { | ||
case 'p': | ||
case 'div': | ||
this.filterCommonBlocks(workEl); | ||
break; | ||
case 'br': | ||
this.filterLineBreak(workEl); | ||
break; | ||
} | ||
} | ||
Util.insertHTMLCommand(this.document, fragmentBody.innerHTML.replace(/ /g, ' ')); | ||
@@ -220,0 +214,0 @@ }, |
@@ -0,0 +0,0 @@ var Placeholder; |
@@ -0,0 +0,0 @@ /* |
@@ -236,2 +236,15 @@ /*global Util */ | ||
select: function (doc, startNode, startOffset, endNode, endOffset) { | ||
doc.getSelection().removeAllRanges(); | ||
var range = doc.createRange(); | ||
range.setStart(startNode, startOffset); | ||
if (endNode) { | ||
range.setEnd(endNode, endOffset); | ||
} else { | ||
range.collapse(true); | ||
} | ||
doc.getSelection().addRange(range); | ||
return range; | ||
}, | ||
/** | ||
@@ -238,0 +251,0 @@ * Move cursor to the given node with the given offset. |
@@ -0,0 +0,0 @@ /*global Util, Selection*/ |
@@ -0,0 +0,0 @@ /*global NodeFilter, Selection*/ |
@@ -14,3 +14,3 @@ /*global MediumEditor */ | ||
// grunt-bump looks for this: | ||
'version': '4.12.6' | ||
'version': '4.12.7' | ||
}).version.split('.')); |
return MediumEditor; | ||
}())); |
@@ -0,0 +0,0 @@ (function (root, factory) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18459
1394914
109