Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

medium-editor

Package Overview
Dependencies
Maintainers
4
Versions
125
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

medium-editor - npm Package Compare versions

Comparing version 5.5.3 to 5.5.4

5

CHANGES.md

@@ -0,1 +1,6 @@

5.5.4 / 2015-08-04
==================
* Fix issue with anchor and selection inconsitencies in IE
5.5.3 / 2015-08-03

@@ -2,0 +7,0 @@ ==================

2

package.json
{
"name": "medium-editor",
"version": "5.5.3",
"version": "5.5.4",
"author": "Davi Ferreira <hi@daviferreira.com>",

@@ -5,0 +5,0 @@ "contributors": [

@@ -294,7 +294,55 @@ /*global MediumEditor, describe, it, expect, spyOn,

// Make sure the <p> wasn't removed, and the <a> was added to the end
expect(this.el.lastChild).toBe(lastP);
expect(lastP.firstChild.nodeName.toLowerCase()).toBe('a');
// 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');
expect(range.startOffset).toBe(0);
expect(MediumEditor.util.isDescendant(lastP.firstChild, range.endContainer, true)).toBe(true, 'The end of the selection is not contained within the link');
});
it('should not remove the <p> container when adding a link inside a top-level <p> with a single text-node child', function () {
spyOn(MediumEditor.prototype, 'createLink').and.callThrough();
this.el.innerHTML = '<p>Some text</p><p><br/></p><p><br/></p><p>some text link text</p>';
var editor = this.newMediumEditor('.editor'),
lastP = this.el.lastChild,
anchorExtension = editor.getExtensionByName('anchor'),
toolbar = editor.getExtensionByName('toolbar');
// Select the text 'link text' in the last paragraph
MediumEditor.selection.select(document, lastP.firstChild, 'some text '.length, lastP.firstChild, 'some text link text'.length);
fireEvent(editor.elements[0], 'focus');
jasmine.clock().tick(1);
// Click the 'anchor' button in the toolbar
fireEvent(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 the <p> wasn't removed, and the <a> was added to the end
expect(this.el.lastChild).toBe(lastP);
expect(lastP.lastChild.nodeName.toLowerCase()).toBe('a');
// Make sure selection is only the link
var range = window.getSelection().getRangeAt(0);
if (range.startContainer === lastP.lastChild.firstChild) {
expect(range.startOffset).toBe(0, 'The start of the selection is not at the front of the link');
} else {
expect(range.startContainer).toBe(lastP.firstChild);
expect(range.startOffset).toBe('some text '.length, 'The start of the selection is not at the front of the link');
}
expect(MediumEditor.util.isDescendant(lastP.lastChild, range.endContainer, true)).toBe(true, 'The end of the selection is incorrect');
});
});

@@ -301,0 +349,0 @@

@@ -114,3 +114,3 @@ /*global describe, it, expect, Util,

} else {
expect(placeholder).toBe('\'' + expectedValue + '\'');
expect(placeholder).toMatch(new RegExp('^[\'"]' + expectedValue + '[\'"]$'));
}

@@ -117,0 +117,0 @@ }

@@ -905,3 +905,5 @@ /*global Util, Selection, Extension,

if (currentSelection) {
var exportedSelection,
var currRange = currentSelection.getRangeAt(0),
commonAncestorContainer = currRange.commonAncestorContainer,
exportedSelection,
startContainerParentElement,

@@ -911,6 +913,24 @@ endContainerParentElement,

startContainerParentElement = Util.getClosestBlockContainer(currentSelection.getRangeAt(0).startContainer);
endContainerParentElement = Util.getClosestBlockContainer(currentSelection.getRangeAt(0).endContainer);
// If the selection is contained within a single text node
// and the selection starts at the beginning of the text node,
// MSIE still says the startContainer is the parent of the text node.
// If the selection is contained within a single text node, we
// want to just use the default browser 'createLink', so we need
// to account for this case and adjust the commonAncestorContainer accordingly
if (currRange.endContainer.nodeType === 3 &&
currRange.startContainer.nodeType !== 3 &&
currRange.startOffset === 0 &&
currRange.startContainer.firstChild === currRange.endContainer) {
commonAncestorContainer = currRange.endContainer;
}
if (startContainerParentElement === endContainerParentElement) {
startContainerParentElement = Util.getClosestBlockContainer(currRange.startContainer);
endContainerParentElement = Util.getClosestBlockContainer(currRange.endContainer);
// If the selection is not contained within a single text node
// but the selection is contained within the same block element
// we want to make sure we create a single link, and not multiple links
// which can happen with the built in browser functionality
if (commonAncestorContainer.nodeType !== 3 && startContainerParentElement === endContainerParentElement) {
var currentEditor = Selection.getSelectionElement(this.options.contentWindow),

@@ -939,3 +959,2 @@ parentElement = (startContainerParentElement || currentEditor),

// an invented <br /> tag at the end in the same situation
Selection.select(

@@ -973,4 +992,6 @@ this.options.ownerDocument,

Util.createLink(this.options.ownerDocument, textNodes, opts.url.trim());
// Chrome trims the leading whitespaces when inserting HTML, which messes up restoring the selection.
var leadingWhitespacesCount = (fragment.firstChild.innerHTML.match(/^\s+/) || [''])[0].length;
// Now move the created link back into the original document in a way to preserve undo/redo history

@@ -977,0 +998,0 @@ Util.insertHTMLCommand(this.options.ownerDocument, fragment.firstChild.innerHTML.replace(/^\s+/, ''));

@@ -333,4 +333,4 @@ /*global NodeFilter, Selection*/

selection = doc.defaultView.getSelection();
if (selection.getRangeAt && selection.rangeCount) {
selection = doc.getSelection();
if (selection.rangeCount) {
range = selection.getRangeAt(0);

@@ -340,3 +340,3 @@ toReplace = range.commonAncestorContainer;

// By moving up the DOM and selecting ancestors whose only child is the range
if ((toReplace.nodeType === 3 && toReplace.nodeValue === range.toString()) ||
if ((toReplace.nodeType === 3 && range.startOffset === 0 && range.endOffset === toReplace.nodeValue.length) ||
(toReplace.nodeType !== 3 && toReplace.innerHTML === range.toString())) {

@@ -343,0 +343,0 @@ while (toReplace.parentNode &&

@@ -20,3 +20,3 @@ /*global MediumEditor */

// grunt-bump looks for this:
'version': '5.5.3'
'version': '5.5.4'
}).version);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc