medium-editor
Advanced tools
Comparing version 5.18.0 to 5.19.0
@@ -0,1 +1,8 @@ | ||
5.19.0 / 2016-05-28 | ||
================== | ||
* Add feature for toggling anchor preview for empty or # links | ||
* Fix keyboard paste to properly fire editablePaste | ||
* Standardize editablePaste to always fire with mock event object | ||
5.18.0 / 2016-05-21 | ||
@@ -2,0 +9,0 @@ ================== |
{ | ||
"name": "medium-editor", | ||
"version": "5.18.0", | ||
"version": "5.19.0", | ||
"author": "Davi Ferreira <hi@daviferreira.com>", | ||
@@ -5,0 +5,0 @@ "contributors": [ |
@@ -205,3 +205,3 @@ /*global fireEvent, selectElementContentsAndFire */ | ||
it('should NOT be displayed when the hovered link is empty', function () { | ||
it('should be displayed by default when the hovered link is empty', function () { | ||
var editor = this.newMediumEditor('.editor', { | ||
@@ -218,2 +218,20 @@ delay: 200 | ||
jasmine.clock().tick(250); | ||
expect(anchorPreview.showPreview).toHaveBeenCalled(); | ||
}); | ||
it('should NOT be displayed when the hovered link is empty and the option showOnEmptyLinks is set to false', function () { | ||
var editor = this.newMediumEditor('.editor', { | ||
delay: 200, | ||
anchorPreview: { | ||
showOnEmptyLinks: false | ||
} | ||
}), | ||
anchorPreview = editor.getExtensionByName('anchor-preview'); | ||
// show preview | ||
spyOn(MediumEditor.extensions.anchorPreview.prototype, 'showPreview').and.callThrough(); | ||
fireEvent(document.getElementById('test-empty-link'), 'mouseover'); | ||
// preview shows only after delay | ||
jasmine.clock().tick(250); | ||
expect(anchorPreview.showPreview).not.toHaveBeenCalled(); | ||
@@ -220,0 +238,0 @@ }); |
@@ -187,2 +187,26 @@ /*global selectElementContents, | ||
it('should trigger editablePaste', function () { | ||
var editorEl = this.el, | ||
editor = this.newMediumEditor('.editor', { | ||
paste: { | ||
forcePlainText: false, | ||
cleanPastedHTML: true | ||
} | ||
}), | ||
spy = jasmine.createSpy('handler'); | ||
editor.subscribe('editablePaste', spy); | ||
// move caret to editor | ||
editorEl.innerHTML = '<span id="editor-inner"> </span>'; | ||
selectElementContentsAndFire(editorEl); | ||
expect(spy).not.toHaveBeenCalled(); | ||
var evt = prepareEvent(editorEl, 'paste'); | ||
firePreparedEvent(evt, editorEl, 'paste'); | ||
jasmine.clock().tick(1); | ||
expect(spy).toHaveBeenCalledWith({ currentTarget: this.el, target: this.el }, this.el); | ||
}); | ||
it('should filter multi-line rich-text pastes when "insertHTML" command is not supported', function () { | ||
@@ -291,2 +315,44 @@ var editor = this.newMediumEditor('.editor', { | ||
it('should fire editablePaste event when pasting', function () { | ||
var editor = this.newMediumEditor('.editor', { | ||
paste: { | ||
forcePlainText: false, | ||
cleanPastedHTML: true | ||
} | ||
}), | ||
spy = jasmine.createSpy('handler'); | ||
editor.subscribe('editablePaste', spy); | ||
selectElementContentsAndFire(editor.elements[0].firstChild); | ||
expect(spy).not.toHaveBeenCalled(); | ||
fireEvent(this.el, 'keydown', { | ||
keyCode: MediumEditor.util.keyCode.V, | ||
ctrlKey: true, | ||
metaKey: true | ||
}); | ||
var contentEditables = document.body.querySelectorAll('[contentEditable=true]'); | ||
expect(contentEditables.length).toBe(2); | ||
var evt = { | ||
type: 'paste', | ||
defaultPrevented: false, | ||
preventDefault: function () {}, | ||
clipboardData: { | ||
types: ['text/plain', 'text/html'], | ||
getData: function () { | ||
// do we need to return different results for the different types? text/plain, text/html | ||
return 'pasted content'; | ||
} | ||
} | ||
}, | ||
pasteExtension = editor.getExtensionByName('paste'); | ||
pasteExtension.handlePasteBinPaste(evt); | ||
jasmine.clock().tick(1); | ||
expect(spy).toHaveBeenCalledWith({ currentTarget: editor.elements[0], target: editor.elements[0] }, editor.elements[0]); | ||
}); | ||
it('should do nothing if default was prevented on paste event of the paste-bin', function () { | ||
@@ -293,0 +359,0 @@ var editor = this.newMediumEditor('.editor', { |
@@ -545,3 +545,3 @@ (function () { | ||
handlePaste: function (event) { | ||
this.triggerCustomEvent('editablePaste', event, event.currentTarget); | ||
this.triggerCustomEvent('editablePaste', { currentTarget: event.currentTarget, target: event.target }, event.currentTarget); | ||
}, | ||
@@ -548,0 +548,0 @@ |
@@ -24,2 +24,7 @@ (function () { | ||
/* showOnEmptyLinks: [boolean] | ||
* determines whether the anchor tag preview shows up on links with href="" or href="#something" | ||
*/ | ||
showOnEmptyLinks: true, | ||
init: function () { | ||
@@ -183,3 +188,4 @@ this.anchorPreview = this.createPreview(); | ||
// into absolute urls when accessed as event.target.href, so check the html | ||
if (!/href=["']\S+["']/.test(target.outerHTML) || /href=["']#\S+["']/.test(target.outerHTML)) { | ||
if (!this.showOnEmptyLinks && | ||
(!/href=["']\S+["']/.test(target.outerHTML) || /href=["']#\S+["']/.test(target.outerHTML))) { | ||
return true; | ||
@@ -186,0 +192,0 @@ } |
@@ -227,2 +227,8 @@ (function () { | ||
this.doPaste(pastedHTML, pastedPlain, editable); | ||
// The event handling code listens for paste on the editable element | ||
// in order to trigger the editablePaste event. Since this paste event | ||
// is happening on the pastebin, the event handling code never knows about it | ||
// So, we have to trigger editablePaste manually | ||
this.trigger('editablePaste', { currentTarget: editable, target: editable }, editable); | ||
return; | ||
@@ -245,2 +251,8 @@ } | ||
this.doPaste(pastedHTML, pastedPlain, editable); | ||
// The event handling code listens for paste on the editable element | ||
// in order to trigger the editablePaste event. Since this paste event | ||
// is happening on the pastebin, the event handling code never knows about it | ||
// So, we have to trigger editablePaste manually | ||
this.trigger('editablePaste', { currentTarget: editable, target: editable }, editable); | ||
}.bind(this), 0); | ||
@@ -247,0 +259,0 @@ }, |
@@ -18,3 +18,3 @@ MediumEditor.parseVersionString = function (release) { | ||
// grunt-bump looks for this: | ||
'version': '5.18.0' | ||
'version': '5.19.0' | ||
}).version); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1873915
24197