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

medium-editor

Package Overview
Dependencies
Maintainers
5
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.13.0 to 5.14.0

8

CHANGES.md

@@ -0,1 +1,8 @@

5.14.0 / 2016-01-31
==================
* Added pre clean replacements
* Fixed an infinite loop
* Handled enter event for empty h2/h3 tag
5.13.0 / 2016-01-18

@@ -8,2 +15,3 @@ ==================

5.12.0 / 2015-12-15

@@ -10,0 +18,0 @@ ==================

2

OPTIONS.md

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

The image dragging handler is a built-in extenson for handling dragging & dropping images into the contenteditable. This feature is ON by default.
The image dragging handler is a built-in extension for handling dragging & dropping images into the contenteditable. This feature is ON by default.

@@ -589,0 +589,0 @@ ### Disabling Image Dragging

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

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

@@ -176,5 +176,5 @@ # MediumEditor

Button behavior can be modified by passing an object into the buttons array instead of a string. This allow for overriding some of the default behavior of buttons. The following options are some of the basic parts of buttons that you may override, but any part of the `MediumEditor.Extension.prototype` can be overriden via these button options. (Check out the [source code for buttons](src/js/extensions/button.js) to see what all can be overriden).
Button behavior can be modified by passing an object into the buttons array instead of a string. This allow for overriding some of the default behavior of buttons. The following options are some of the basic parts of buttons that you may override, but any part of the `MediumEditor.Extension.prototype` can be overridden via these button options. (Check out the [source code for buttons](src/js/extensions/button.js) to see what all can be overridden).
* __name__: name of the button being overriden
* __name__: name of the button being overridden
* __action__: argument to pass to `MediumEditor.execAction()` when the button is clicked.

@@ -342,3 +342,4 @@ * __aria__: value to add as the aria-label attribute of the button element displayed in the toolbar. This is also used as the tooltip for the button.

* __cleanPastedHTML__: cleans pasted content from different sources, like google docs etc. Default: `false`
* __cleanReplacements__: custom pairs (2 element arrays) of RegExp and replacement text to use during paste when __forcePlainText__ or __cleanPastedHTML__ are `true` OR when calling `cleanPaste(text)` helper method. Default: `[]`
* __preCleanReplacements__: custom pairs (2 element arrays) of RegExp and replacement text to use during paste when __forcePlainText__ or __cleanPastedHTML__ are `true` OR when calling `cleanPaste(text)` helper method. These replacements are executed _before_ builtin replacements. Default: `[]`
* __cleanReplacements__: custom pairs (2 element arrays) of RegExp and replacement text to use during paste when __forcePlainText__ or __cleanPastedHTML__ are `true` OR when calling `cleanPaste(text)` helper method. These replacements are executed _after_ builtin replacements. Default: `[]`
* __cleanAttrs__: list of element attributes to remove during paste when __cleanPastedHTML__ is `true` or when calling `cleanPaste(text)` or `pasteHTML(html,options)` helper methods. Default: `['class', 'style', 'dir']`

@@ -413,3 +414,3 @@ * __cleanTags__: list of element tag names to remove during paste when __cleanPastedHTML__ is `true` or when calling `cleanPaste(text)` or `pasteHTML(html,options)` helper methods. Default: `['meta']`

The image dragging handler is a built-in extenson for handling dragging & dropping images into the contenteditable. This feature is ON by default.
The image dragging handler is a built-in extension for handling dragging & dropping images into the contenteditable. This feature is ON by default.

@@ -416,0 +417,0 @@ To disable built-in image dragging, set the value of the `imageDragging` option to `false`:

@@ -437,2 +437,41 @@ /*global fireEvent, firePreparedEvent,

});
it('should add a new line when selected node is an h2/h3 tag with text in it and when disableDoubleReturn is true', function () {
this.el.innerHTML = '<p>lorem</p><h2>ipsum<br></h2>';
var editor = this.newMediumEditor('.editor', { disableDoubleReturn: true }),
p = editor.elements[0].getElementsByTagName('h2')[0],
evt;
placeCursorInsideElement(p, 0);
evt = prepareEvent(p, 'keydown', {
keyCode: MediumEditor.util.keyCode.ENTER
});
spyOn(evt, 'preventDefault').and.callThrough();
firePreparedEvent(evt, p, 'keydown');
expect(evt.preventDefault).not.toHaveBeenCalled();
});
it('should prevent new line being added when selected node is an empty h2/h3 tag and when disableDoubleReturn is true', function () {
this.el.innerHTML = '<p>lorem</p><h2><br></h2>';
var editor = this.newMediumEditor('.editor', { disableDoubleReturn: true }),
p = editor.elements[0].getElementsByTagName('h2')[0],
evt;
placeCursorInsideElement(p, 1);
evt = prepareEvent(p, 'keydown', {
keyCode: MediumEditor.util.keyCode.ENTER
});
spyOn(evt, 'preventDefault').and.callThrough();
firePreparedEvent(evt, p, 'keydown');
expect(evt.preventDefault).toHaveBeenCalled();
expect(this.el.innerHTML).toBe('<p>lorem</p><h2><br></h2>');
});
});

@@ -439,0 +478,0 @@

@@ -288,2 +288,22 @@ /*global selectElementContents,

it('should respect custom replacements before builtin replacements.', function () {
var editor = this.newMediumEditor('.editor', {
paste: {
forcePlainText: false,
cleanPastedHTML: true,
preCleanReplacements: [[new RegExp(/<\/?o:[a-z]*>/gi), 'foo']]
}
});
this.el.innerHTML = 'Before&nbsp;<span id="editor-inner">&nbsp;</span>&nbsp;after.';
selectElementContents(document.getElementById('editor-inner'));
// Normally, the paste extension's regular expressions would clear the `<o:p></o:p>` tags,
// but our `preCleanReplacements` should transform them each to "foo" before the default
// cleanReplacement has a chance to see it.
editor.cleanPaste('<div><o:p></o:p></div>');
expect(this.el.innerHTML).toMatch(new RegExp('foofoo'));
});
it('should cleanup only pasted element on multi-line when nothing is selected', function () {

@@ -290,0 +310,0 @@ var editor = this.newMediumEditor('.editor', {

@@ -141,2 +141,16 @@ /*global selectElementContents, placeCursorInsideElement */

it('should be able to import an exported selection that contain nodeTypes > 3', function (done) {
this.el.innerHTML = '<div><p>stuff here <!-- comment nodeType is 8 --> additional stuff here </p></div>';
selectElementContents(this.el.querySelector('p'));
var exportedSelection = MediumEditor.selection.exportSelection(this.el, document);
expect(Object.keys(exportedSelection).sort()).toEqual(['end', 'start']);
selectElementContents(this.el);
expect(exportedSelection).toEqual(MediumEditor.selection.exportSelection(this.el, document));
MediumEditor.selection.importSelection(exportedSelection, this.el, document);
expect(exportedSelection).toEqual(MediumEditor.selection.exportSelection(this.el, document));
done();
});
it('should import an exported selection outside any anchor tag', function () {

@@ -143,0 +157,0 @@ this.el.innerHTML = '<p id=1>Hello world: <a href="#">http://www.example.com</a></p><p id=2><br></p>';

@@ -73,3 +73,3 @@ (function () {

event.preventDefault();
} else if (MediumEditor.util.isKey(event, MediumEditor.util.keyCode.ENTER)) {
} else if (!this.options.disableDoubleReturn && MediumEditor.util.isKey(event, MediumEditor.util.keyCode.ENTER)) {
// hitting return in the begining of a header will create empty header elements before the current one

@@ -76,0 +76,0 @@ // instead, make "<p><br></p>" element, which are what happens if you hit return in an empty paragraph

@@ -63,5 +63,13 @@ (function () {

/* preCleanReplacements: [Array]
* custom pairs (2 element arrays) of RegExp and replacement text to use during past when
* __forcePlainText__ or __cleanPastedHTML__ are `true` OR when calling `cleanPaste(text)` helper method.
* These replacements are executed before any medium editor defined replacements.
*/
preCleanReplacements: [],
/* cleanReplacements: [Array]
* custom pairs (2 element arrays) of RegExp and replacement text to use during paste when
* __forcePlainText__ or __cleanPastedHTML__ are `true` OR when calling `cleanPaste(text)` helper method.
* These replacements are executed after any medium editor defined replacements.
*/

@@ -144,3 +152,6 @@ cleanReplacements: [],

multiline = /<p|<br|<div/.test(text),
replacements = createReplacements().concat(this.cleanReplacements || []);
replacements = [].concat(
this.preCleanReplacements || [],
createReplacements(),
this.cleanReplacements || []);

@@ -147,0 +158,0 @@ for (i = 0; i < replacements.length; i += 1) {

@@ -89,2 +89,4 @@ # Extensions

* Enables users to add multiple placeholders with specific HTML tags.
* [MediumEditor TCMention Plugin](https://github.com/tomchentw/medium-editor-tc-mention)
* A Medium Editor extension for adding custom 'mention' support, circa Medium 2.0.

@@ -91,0 +93,0 @@

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

if (node.nodeType > 3) {
node = nodeStack.pop();
continue;

@@ -315,2 +316,3 @@ }

if (node.nodeType > 3) {
node = nodeStack.pop();
continue;

@@ -317,0 +319,0 @@ }

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

// grunt-bump looks for this:
'version': '5.13.0'
'version': '5.14.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