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 5.4.1 to 5.5.0

30

API.md

@@ -6,2 +6,3 @@ # MediumEditor Object API (v5.0.0)

- [Initialization Functions](#initialization-functions)

@@ -39,2 +40,3 @@ - [`MediumEditor(elements, options)`](#mediumeditorelements-options)

- [`serialize()`](#serialize)
- [`setContent(html, index)`](#setcontenthtml-index)

@@ -64,3 +66,3 @@ <!-- END doctoc generated TOC please keep comment here to allow auto update -->

_**options** (`Object`)_:
_**options** (`Object`)_:

@@ -97,3 +99,3 @@ Set of [custom options](OPTIONS.md) used to initialize `MediumEditor`.

2. _**event** (`String`)_:
2. _**event** (`String`)_:

@@ -121,3 +123,3 @@ * type argument for `addEventListener(type, listener, useCapture)`

2. _**event** (`String`)_:
2. _**event** (`String`)_:

@@ -145,3 +147,3 @@ * type argument for `removeEventListener(type, listener, useCapture)`

2. _**listener(data, editable)** (`function`)_:
2. _**listener(data, editable)** (`function`)_:

@@ -170,3 +172,3 @@ * Listener method that will be called whenever the custom event is triggered.

2. _**listener** (`function`)_:
2. _**listener** (`function`)_:

@@ -221,3 +223,3 @@ * A reference to the listener to detach. This must be a match by-reference and not a copy.

2. _**favorLaterSelectionAnchor** (`boolen`)_:
2. _**favorLaterSelectionAnchor** (`boolean`)_:

@@ -297,3 +299,3 @@ * If `true`, import the cursor immediately subsequent to an anchor tag if it would otherwise be placed right at the trailing edge inside the anchor. THis cursor positioning, even though visually equivalent to the user, can affect behavior in Internet Explorer.

### `delay(fn)`
### `delay(fn)`

@@ -324,2 +326,14 @@ Delay any function from being executed by the amount of time passed as the **delay** option.

***
***
### `setContent(html, index)`
Sets the innerHTML content for the element at `index`.
Trigger the `editableInput` event.
**Arguments**
1. _**html** (`string`)_:
* The content to set the element to
2. _**index** (`integer`)_:
* Index of the element to set the content on. Defaults to 0 when not provided.

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

5.5.0 / 2015-07-21
==================
* Add setContent method into core API, which triggers editableInput
5.4.1 / 2015-07-20

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

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

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

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

* __.serialize()__: returns a JSON object with elements contents
* __.setContent(html, element)__: sets the `innerHTML` to `html` of the element at `index`

@@ -540,0 +541,0 @@ ## Capturing DOM changes

@@ -40,2 +40,19 @@ /*global describe, it, expect, beforeEach, afterEach,

});
});
describe('setContent', function () {
it('should set the content of the editor\'s element', function () {
var newHTML = 'Lorem ipsum dolor',
otherHTML = 'something different',
elementOne = this.createElement('div', 'editor', 'lorem ipsum'),
editor = this.newMediumEditor('.editor');
editor.setContent(newHTML);
expect(this.el.innerHTML).toEqual(newHTML);
expect(elementOne.innerHTML).not.toEqual(newHTML);
editor.setContent(otherHTML, 1);
expect(elementOne.innerHTML).toEqual(otherHTML);
expect(this.el.innerHTML).not.toEqual(otherHTML);
});
});
});

@@ -305,2 +305,35 @@ /*global describe, it, expect, jasmine,

});
it(namePrefix + ',setContent should fire editableInput when content changes', function () {
var newHTML = 'Lorem ipsum dolor',
editor = this.newMediumEditor('.editor'),
spy = jasmine.createSpy('handler'),
originalInputSupport = Events.prototype.InputEventOnContenteditableSupported;
Events.prototype.InputEventOnContenteditableSupported = inputSupported;
editor.subscribe('editableInput', spy);
expect(spy).not.toHaveBeenCalled();
editor.setContent(newHTML, 0);
var obj = { target: this.el, currentTarget: this.el };
expect(spy).toHaveBeenCalledWith(obj, this.el);
Events.prototype.InputEventOnContenteditableSupported = originalInputSupport;
});
it(namePrefix + ', setContent should not fire editableInput when content doesn\'t change', function () {
var sameHTML = 'lore ipsum',
editor = this.newMediumEditor('.editor'),
spy = jasmine.createSpy('handler'),
originalInputSupport = Events.prototype.InputEventOnContenteditableSupported;
Events.prototype.InputEventOnContenteditableSupported = inputSupported;
editor.subscribe('editableInput', spy);
expect(spy).not.toHaveBeenCalled();
editor.setContent(sameHTML, 0);
expect(spy).not.toHaveBeenCalled();
Events.prototype.InputEventOnContenteditableSupported = originalInputSupport;
});
}

@@ -307,0 +340,0 @@

@@ -995,4 +995,14 @@ /*global Util, Selection, Extension,

this.getExtensionByName('paste').pasteHTML(html, options);
},
setContent: function (html, index) {
index = index || 0;
if (this.elements[index]) {
var target = this.elements[index];
target.innerHTML = html;
this.events.updateInput(target, { target: target, currentTarget: target });
}
}
};
}());

@@ -368,2 +368,5 @@ /*global Util*/

updateInput: function (target, eventObj) {
if (!this.contentCache) {
return;
}
// An event triggered which signifies that the user may have changed someting

@@ -370,0 +373,0 @@ // Look in our cache of input for the contenteditables to see if something changed

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

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc