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.9.0 to 5.10.0

spec/fontname.spec.js

9

CHANGES.md

@@ -0,1 +1,10 @@

5.10.0 / 2015-10-30
==================
* Added disableExtraSpaces option for preventing errant spaces
* Added editalbeKeydownSpace event
* Fix issue with return key at the end of text with bad formatting
* Added new font name extension (beta)
* Documentation updates and cleanup
5.9.0 / 2015-10-19

@@ -2,0 +11,0 @@ ==================

7

CUSTOM-EVENTS.md

@@ -23,3 +23,3 @@ # MediumEditor Custom Events (v5.0.0)

- [`focus`](#focus)
- [Toolbar Custom Evenst](#toolbar-custom-evenst)
- [Toolbar Custom Events](#toolbar-custom-events)
- [`hideToolbar`](#hidetoolbar)

@@ -37,2 +37,3 @@ - [`positionToolbar`](#positiontoolbar)

- [`editableKeydownDelete`](#editablekeydowndelete)
- [`editableKeydownSpace`](#editablekeydownspace)
- [`editableMouseover`](#editablemouseover)

@@ -145,3 +146,3 @@ - [`editableDrag`](#editabledrag)

## Toolbar Custom Evenst
## Toolbar Custom Events

@@ -182,2 +183,4 @@ These events are triggered by the toolbar when the toolbar extension has not been disabled.

native `keydown` event for each element, but only triggered if the key is `DELETE` (keycode 46).
##### `editableKeydownSpace`
native `keydown` event for each element, but only triggered if the key is `SPACE` (keycode 32).
##### `editableMouseover`

@@ -184,0 +187,0 @@ native `mouseover` event for each element.

@@ -29,2 +29,3 @@ /*global module, require, process*/

'src/js/extensions/keyboard-commands.js',
'src/js/extensions/fontname.js',
'src/js/extensions/fontsize.js',

@@ -31,0 +32,0 @@ 'src/js/extensions/paste.js',

@@ -21,2 +21,3 @@ # MediumEditor Options (v5.0.0)

- [`disableDoubleReturn`](#disabledoublereturn)
- [`disableExtraSpaces`](#disableextraspaces)
- [`disableEditing`](#disableediting)

@@ -91,2 +92,3 @@ - [`elementsContainer`](#elementscontainer)

disableDoubleReturn: false,
disableExtraSpaces: false,
disableEditing: false,

@@ -147,2 +149,8 @@ elementsContainer: false,

***
#### `disableExtraSpaces`
**Default:** `false`
When set to true, it disallows spaces at the beginning and end of the element. Also it disallows entering 2 consecutive spaces between 2 words.
***
#### `disableEditing`

@@ -149,0 +157,0 @@ **Default:** `false`

{
"name": "medium-editor",
"version": "5.9.0",
"version": "5.10.0",
"author": "Davi Ferreira <hi@daviferreira.com>",

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

@@ -117,2 +117,3 @@ # MediumEditor

* __disableDoubleReturn__: allows/disallows two (or more) empty new lines. You can also set specific element behavior by using setting a data-disable-double-return attribute. Default: `false`
* __disableExtraSpaces__: when set to true, it disallows spaces at the beginning and end of the element. Also it disallows entering 2 consecutive spaces between 2 words. Default: `false`
* __disableEditing__: enables/disables adding the contenteditable behavior. Useful for using the toolbar with customized buttons/actions. You can also set specific element behavior by using setting a data-disable-editing attribute. Default: `false`

@@ -142,4 +143,3 @@ * __elementsContainer__: specifies a DOM node to contain MediumEditor's toolbar and anchor preview elements. Default: `document.body`

static: false,
relativeContainer: null
relativeContainer: null,
/* options which only apply when static is true */

@@ -146,0 +146,0 @@ align: 'center',

@@ -85,2 +85,42 @@ /*global fireEvent, firePreparedEvent,

describe('when the space key is pressed', function () {
it('should not prevent new spaces from being inserted when disableExtraSpaces options is false', function () {
this.el.innerHTML = '<p>lorem ipsum</p>';
var editor = this.newMediumEditor('.editor', { disableExtraSpaces: false }),
evt;
placeCursorInsideElement(editor.elements[0], 0);
evt = prepareEvent(editor.elements[0], 'keydown', {
keyCode: MediumEditor.util.keyCode.SPACE
});
spyOn(evt, 'preventDefault').and.callThrough();
firePreparedEvent(evt, editor.elements[0], 'keydown');
expect(evt.preventDefault).not.toHaveBeenCalled();
});
it('should prevent new spaces from being inserted when disableExtraSpaces options is true', function () {
this.el.innerHTML = '<p>lorem ipsum</p>';
var editor = this.newMediumEditor('.editor', { disableExtraSpaces: true }),
evt;
placeCursorInsideElement(editor.elements[0], 0);
evt = prepareEvent(editor.elements[0], 'keydown', {
keyCode: MediumEditor.util.keyCode.SPACE
});
spyOn(evt, 'preventDefault').and.callThrough();
firePreparedEvent(evt, editor.elements[0], 'keydown');
expect(evt.preventDefault).toHaveBeenCalled();
});
});
describe('when the enter key is pressed', function () {

@@ -145,2 +185,23 @@ it('should prevent new lines from being inserted when disableReturn options is true', function () {

it('should allow a line to be added when pressed enter at end of the <p> tag when disableDoubleReturn is true and contains <br> as the previous sibling', function () {
this.el.innerHTML = '<p>it is a test</p><br><p>because tests are great..!!</p>';
var editor = this.newMediumEditor('.editor', { disableDoubleReturn: true }),
targetNode = editor.elements[0].querySelector('p:last-child'),
evt;
placeCursorInsideElement(targetNode, 0);
evt = prepareEvent(targetNode, 'keydown', {
keyCode: MediumEditor.util.keyCode.ENTER
});
spyOn(evt, 'preventDefault').and.callThrough();
firePreparedEvent(evt, targetNode, 'keydown');
expect(evt.preventDefault).not.toHaveBeenCalled();
});
it('should prevent consecutive new lines from being inserted when disableDoubleReturn is true', function () {

@@ -147,0 +208,0 @@ this.el.innerHTML = '<p><br></p>';

@@ -103,2 +103,3 @@ /*global _ */

disableDoubleReturn: false,
disableExtraSpaces: false,
disableEditing: false,

@@ -199,2 +200,2 @@ autoLink: false,

});
});
});

@@ -6,2 +6,12 @@ (function () {

function handleDisableExtraSpaces(event) {
var node = MediumEditor.selection.getSelectionStart(this.options.ownerDocument),
textContent = node.textContent,
caretPositions = MediumEditor.selection.getCaretOffsets(node);
if ((textContent[caretPositions.left - 1] === undefined) || (textContent[caretPositions.left - 1] === ' ') || (textContent[caretPositions.left] === undefined)) {
event.preventDefault();
}
}
function handleDisabledEnterKeydown(event, element) {

@@ -15,3 +25,4 @@ if (this.options.disableReturn || element.getAttribute('data-disable-return')) {

if ((node && node.textContent.trim() === '' && node.nodeName.toLowerCase() !== 'li') ||
(node.previousElementSibling && node.previousElementSibling.textContent.trim() === '')) {
(node.previousElementSibling && node.previousElementSibling.nodeName.toLowerCase() !== 'br' &&
node.previousElementSibling.textContent.trim() === '')) {
event.preventDefault();

@@ -356,2 +367,7 @@ }

// Bind double space event
if (this.options.disableExtraSpaces) {
this.subscribe('editableKeydownSpace', handleDisableExtraSpaces.bind(this));
}
// disabling return or double return

@@ -483,2 +499,6 @@ if (this.options.disableReturn || this.options.disableDoubleReturn) {

if (action === 'fontName') {
return this.options.ownerDocument.execCommand('fontName', false, opts.name);
}
if (action === 'createLink') {

@@ -713,2 +733,5 @@ return this.createLink(opts);

break;
case 'fontname':
extension = new MediumEditor.extensions.fontName(this.options.fontName);
break;
case 'fontsize':

@@ -715,0 +738,0 @@ extension = new MediumEditor.extensions.fontSize(opts);

@@ -10,2 +10,3 @@ (function () {

disableDoubleReturn: false,
disableExtraSpaces: false,
disableEditing: false,

@@ -12,0 +13,0 @@ autoLink: false,

@@ -272,2 +272,6 @@ (function () {

break;
case 'editableKeydownSpace':
// Detecting keydown for SPACE on the contenteditables
this.setupListener('editableKeydown');
break;
case 'editableKeydownEnter':

@@ -485,4 +489,9 @@ // Detecting keydown for ENTER on the contenteditables

handleKeydown: function (event) {
this.triggerCustomEvent('editableKeydown', event, event.currentTarget);
if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.SPACE)) {
return this.triggerCustomEvent('editableKeydownSpace', event, event.currentTarget);
}
if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.ENTER) || (event.ctrlKey && MediumEditor.util.isKey(event, MediumEditor.util.keyCode.M))) {

@@ -489,0 +498,0 @@ return this.triggerCustomEvent('editableKeydownEnter', event, event.currentTarget);

@@ -18,3 +18,3 @@ MediumEditor.parseVersionString = function (release) {

// grunt-bump looks for this:
'version': '5.9.0'
'version': '5.10.0'
}).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