Socket
Socket
Sign inDemoInstall

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 4.12.3 to 4.12.4

5

CHANGES.md

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

4.12.4 / 2015-06-15
==================
* Ensure auto-link will never select an empty element (br, hr, input, etc.)
4.12.3 / 2015-06-12

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

2

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

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

@@ -112,2 +112,3 @@ /*global MediumEditor, describe, it, expect, spyOn,

});
it('should not export a position indicating the cursor is after an empty paragraph ' +

@@ -232,3 +233,43 @@ '(in a complicated markup with selection on the element)', function () {

it('should import not import a selection beyond any block elements that have text, even when emptyBlocksIndex indicates it should ', function () {
['br', 'img'].forEach(function (tagName) {
it('should not import a selection into focusing on the element \'' + tagName + '\' that cannot have children', function () {
this.el.innerHTML = '<p>Hello</p><p><' + tagName + ' /></p><p>World<p>';
var editor = this.newMediumEditor('.editor', {
buttons: ['italic', 'underline', 'strikethrough']
});
editor.importSelection({
'start': 5,
'end': 5,
'emptyBlocksIndex': 1
});
var innerElement = window.getSelection().getRangeAt(0).startContainer;
expect(innerElement.nodeName.toLowerCase()).toBe('p', 'focused element nodeName');
expect(innerElement).toBe(window.getSelection().getRangeAt(0).endContainer);
expect(innerElement.previousSibling.nodeName.toLowerCase()).toBe('p', 'previous sibling name');
expect(innerElement.nextSibling.nodeName.toLowerCase()).toBe('p', 'next sibling name');
});
});
it('should not import a selection into focusing on an empty element in a table', function () {
this.el.innerHTML = '<p>Hello</p><table><colgroup><col /></colgroup>' +
'<thead><tr><th>Head</th></tr></thead>' +
'<tbody><tr><td>Body</td></tr></tbody></table><p>World<p>';
var editor = this.newMediumEditor('.editor', {
buttons: ['italic', 'underline', 'strikethrough']
});
editor.importSelection({
'start': 5,
'end': 5,
'emptyBlocksIndex': 1
});
var innerElement = window.getSelection().getRangeAt(0).startContainer;
// The behavior varies from browser to browser for this case, some select TH, some #textNode
expect(Util.isDescendant(editor.elements[0].querySelector('th'), innerElement, true))
.toBe(true, 'expect selection to be of TH or a descendant');
expect(innerElement).toBe(window.getSelection().getRangeAt(0).endContainer);
});
it('should not import a selection beyond any block elements that have text, even when emptyBlocksIndex indicates it should ', function () {
this.el.innerHTML = '<p><span>www.google.com</span></p><h1><br /></h1><h2>Not Empty</h2><p><b><i>Whatever</i></b></p>';

@@ -235,0 +276,0 @@ var editor = this.newMediumEditor('.editor', {

@@ -1017,3 +1017,3 @@ /*global Util, ButtonsData, Selection, Extension,

// element at the beginning of the block
range.setStart(Util.getFirstLeafNode(targetNode), 0);
range.setStart(Util.getFirstSelectableLeafNode(targetNode), 0);
range.collapse(true);

@@ -1020,0 +1020,0 @@ }

@@ -675,6 +675,18 @@ /*global NodeFilter, Selection*/

getFirstLeafNode: function (element) {
getFirstSelectableLeafNode: function (element) {
while (element && element.firstChild) {
element = element.firstChild;
}
var emptyElements = ['br', 'col', 'colgroup', 'hr', 'img', 'input', 'source', 'wbr'];
while (emptyElements.indexOf(element.nodeName.toLowerCase()) !== -1) {
// We don't want to set the selection to an element that can't have children, this messes up Gecko.
element = element.parentNode;
}
// Selecting at the beginning of a table doesn't work in PhantomJS.
if (element.nodeName.toLowerCase() === 'table') {
var firstCell = element.querySelector('th, td');
if (firstCell) {
element = firstCell;
}
}
return element;

@@ -681,0 +693,0 @@ },

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

// grunt-bump looks for this:
'version': '4.12.3'
'version': '4.12.4'
}).version.split('.'));

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