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.8.3 to 5.9.0

.node-version

9

CHANGES.md

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

5.9.0 / 2015-10-19
==================
* Add showWhenToolbarIsVisible option for displaying anchor-preview when toolbar is visible
* Remove trailing whitespace when creating links via anchor extension
* Fix issue with escaping list items via pressing enter
* Fix font-awesome links in demo pages
* Updates to documentation around creating links
5.8.3 / 2015-10-08

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

10

OPTIONS.md

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

Custom content for the toolbar buttons.
Custom content for the toolbar buttons.

@@ -323,2 +323,8 @@ **Valid Values:**

***
#### `showWhenToolbarIsVisible`
**Default:** `false`
Determines whether the anchor tag preview shows up when the toolbar is visible. You should set this value to true if the static option for the toolbar is true and you want the preview to show at the same time.
### Disabling Anchor Preview

@@ -607,2 +613,2 @@

});
```
```

2

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

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

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

* __previewValueSelector__: the default selector to locate where to put the activeAnchor value in the preview. You should only need to override this if you've modified the way in which the anchor-preview extension renders. Default: `'a'`
* __showWhenToolbarIsVisible__: determines whether the anchor tag preview shows up when the toolbar is visible. You should set this value to true if the static option for the toolbar is true and you want the preview to show at the same time. Default: `false`

@@ -255,0 +256,0 @@ To disable the anchor preview, set the value of the `anchorPreview` option to `false`:

@@ -1,2 +0,2 @@

/*global fireEvent */
/*global fireEvent, selectElementContentsAndFire */

@@ -238,2 +238,54 @@ describe('Anchor Preview TestCase', function () {

it('should be displayed when the option showWhenToolbarIsVisible is set to true and toolbar is visible', function () {
var editor = this.newMediumEditor('.editor', {
delay: 200,
anchorPreview: {
showWhenToolbarIsVisible: true
},
toolbar: {
static: true
}
}),
anchorPreview = editor.getExtensionByName('anchor-preview'),
toolbar = editor.getExtensionByName('toolbar');
selectElementContentsAndFire(editor.elements[0].firstChild);
// show preview
spyOn(MediumEditor.extensions.anchorPreview.prototype, 'showPreview').and.callThrough();
fireEvent(document.getElementById('test-link'), 'mouseover');
// preview shows only after delay
jasmine.clock().tick(250);
expect(anchorPreview.showPreview).toHaveBeenCalled();
expect(toolbar.isDisplayed()).toBe(true);
expect(anchorPreview.getPreviewElement().classList.contains('medium-toolbar-arrow-over')).toBe(true);
});
it('should be displayed when the option showWhenToolbarIsVisible is set to true and toolbar is visible', function () {
var editor = this.newMediumEditor('.editor', {
delay: 200,
anchorPreview: {
showWhenToolbarIsVisible: false
},
toolbar: {
static: true
}
}),
anchorPreview = editor.getExtensionByName('anchor-preview'),
toolbar = editor.getExtensionByName('toolbar');
selectElementContentsAndFire(editor.elements[0].firstChild);
// show preview
spyOn(MediumEditor.extensions.anchorPreview.prototype, 'showPreview').and.callThrough();
fireEvent(document.getElementById('test-link'), 'mouseover');
// preview shows only after delay
jasmine.clock().tick(250);
expect(anchorPreview.showPreview).not.toHaveBeenCalled();
expect(toolbar.isDisplayed()).toBe(true);
expect(anchorPreview.getPreviewElement().classList.contains('medium-toolbar-arrow-over')).toBe(false);
});
it('should NOT be present when anchorPreview option is set to false', function () {

@@ -240,0 +292,0 @@ var editor = this.newMediumEditor('.editor', {

@@ -75,2 +75,39 @@ /*global fireEvent, selectElementContents,

it('should remove the extra white spaces in the link when user presses enter', function () {
spyOn(MediumEditor.prototype, 'createLink').and.callThrough();
var editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar'),
button, input;
selectElementContents(editor.elements[0]);
button = toolbar.getToolbarElement().querySelector('[data-action="createLink"]');
fireEvent(button, 'click');
input = editor.getExtensionByName('anchor').getInput();
input.value = ' test ';
fireEvent(input, 'keyup', {
keyCode: MediumEditor.util.keyCode.ENTER
});
expect(editor.createLink).toHaveBeenCalled();
// A trailing <br> may be added when insertHTML is used to add the link internally.
expect(this.el.innerHTML.indexOf('<a href="test">lorem ipsum</a>')).toBe(0);
});
it('should not set any href if all user passes is spaces in the link when user presses enter', function () {
spyOn(MediumEditor.prototype, 'createLink').and.callThrough();
var editor = this.newMediumEditor('.editor'),
toolbar = editor.getExtensionByName('toolbar'),
button, input;
selectElementContents(editor.elements[0]);
button = toolbar.getToolbarElement().querySelector('[data-action="createLink"]');
fireEvent(button, 'click');
input = editor.getExtensionByName('anchor').getInput();
input.value = ' ';
fireEvent(input, 'keyup', {
keyCode: MediumEditor.util.keyCode.ENTER
});
//Since user only passes empty string in the url, there should be no <a> tag created for the element.
expect(this.el.innerHTML.indexOf('<a href="">lorem ipsum</a>')).toBe(-1);
});
it('should create only one anchor tag when the user selects across a boundary', function () {

@@ -77,0 +114,0 @@ this.el.innerHTML = 'Hello world, this <strong>will become a link, but this part won\'t.</strong>';

@@ -125,2 +125,21 @@ /*global fireEvent, firePreparedEvent,

it('should allow to get out of list when enter is pressed twice', function () {
this.el.innerHTML = '<li><br></li>';
var editor = this.newMediumEditor('.editor', { disableDoubleReturn: true }),
p = editor.elements[0].querySelector('li'),
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 consecutive new lines from being inserted when disableDoubleReturn is true', function () {

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

@@ -12,4 +12,4 @@ (function () {

// if current text selection is empty OR previous sibling text is empty
if ((node && node.textContent.trim() === '') ||
// if current text selection is empty OR previous sibling text is empty OR it is not a list
if ((node && node.textContent.trim() === '' && node.nodeName.toLowerCase() !== 'li') ||
(node.previousElementSibling && node.previousElementSibling.textContent.trim() === '')) {

@@ -16,0 +16,0 @@ event.preventDefault();

@@ -19,2 +19,7 @@ (function () {

/* showWhenToolbarIsVisible: [boolean]
* determines whether the anchor tag preview shows up when the toolbar is visible
*/
showWhenToolbarIsVisible: false,
init: function () {

@@ -171,3 +176,3 @@ this.anchorPreview = this.createPreview();

var toolbar = this.base.getExtensionByName('toolbar');
if (toolbar && toolbar.isDisplayed && toolbar.isDisplayed()) {
if (!this.showWhenToolbarIsVisible && toolbar && toolbar.isDisplayed && toolbar.isDisplayed()) {
return true;

@@ -174,0 +179,0 @@ }

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

opts = {
url: this.getInput().value
url: this.getInput().value.trim()
};

@@ -324,2 +324,2 @@

MediumEditor.extensions.anchor = AnchorForm;
}());
}());

@@ -82,7 +82,22 @@ (function () {

performLinking: function (contenteditable) {
// Perform linking on a paragraph level basis as otherwise the detection can wrongly find the end
// of one paragraph and the beginning of another paragraph to constitute a link, such as a paragraph ending
// "link." and the next paragraph beginning with "my" is interpreted into "link.my" and the code tries to create
// a link across blockElements - which doesn't work and is terrible.
// (Medium deletes the spaces/returns between P tags so the textContent ends up without paragraph spacing)
/*
Perform linking on blockElement basis, blockElements are HTML elements with text content and without
child element.
Example:
- HTML content
<blockquote>
<p>link.</p>
<p>my</p>
</blockquote>
- blockElements
[<p>link.</p>, <p>my</p>]
otherwise the detection can wrongly find the end of one paragraph and the beginning of another paragraph
to constitute a link, such as a paragraph ending "link." and the next paragraph beginning with "my" is
interpreted into "link.my" and the code tries to create a link across blockElements - which doesn't work
and is terrible.
(Medium deletes the spaces/returns between P tags so the textContent ends up without paragraph spacing)
*/
var blockElements = MediumEditor.util.splitByBlockElements(contenteditable),

@@ -225,2 +240,2 @@ documentModified = false;

MediumEditor.extensions.autoLink = AutoLink;
}());
}());

@@ -223,3 +223,3 @@ /*global NodeFilter*/

* 1) All text content of the elements are in separate blocks. No piece of text content should span
* span multiple blocks. This means no element return by this function should have
* across multiple blocks. This means no element return by this function should have
* any blocks as children.

@@ -226,0 +226,0 @@ * 2) The union of the textcontent of all of the elements returned here covers all

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

// grunt-bump looks for this:
'version': '5.8.3'
'version': '5.9.0'
}).version);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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