-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rename paste-utils to parse-utils
- Loading branch information
Showing
8 changed files
with
286 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Helpers from '../test-helpers'; | ||
|
||
const { module, test } = Helpers; | ||
|
||
let editor, editorElement; | ||
|
||
function findCenterPointOfTextNode(node) { | ||
let range = document.createRange(); | ||
range.setStart(node, 0); | ||
range.setEnd(node, node.textContent.length); | ||
|
||
let {left, top, width, height} = range.getBoundingClientRect(); | ||
|
||
let clientX = left + width/2; | ||
let clientY = top + height/2; | ||
|
||
return {clientX, clientY}; | ||
} | ||
|
||
module('Acceptance: editor: drag-drop', { | ||
beforeEach() { | ||
editorElement = $('#editor')[0]; | ||
}, | ||
afterEach() { | ||
if (editor) { | ||
editor.destroy(); | ||
editor = null; | ||
} | ||
} | ||
}); | ||
|
||
test('inserts dropped HTML content at the drop position', (assert) => { | ||
let expected; | ||
editor = Helpers.mobiledoc.renderInto(editorElement, ({post, markupSection, marker}) => { | ||
expected = post([markupSection('h2', [marker('--->some text<---')])]); | ||
return post([markupSection('h2', [marker('---><---')])]); | ||
}); | ||
|
||
let html = '<p>some text</p>'; | ||
let node = Helpers.dom.findTextNode(editorElement, '---><---'); | ||
let {clientX, clientY} = findCenterPointOfTextNode(node); | ||
Helpers.dom.triggerDropEvent(editor, {html, clientX, clientY}); | ||
|
||
assert.postIsSimilar(editor.post, expected); | ||
}); | ||
|
||
test('inserts dropped text content at the drop position if no html data', (assert) => { | ||
let expected; | ||
editor = Helpers.mobiledoc.renderInto(editorElement, ({post, markupSection, marker}) => { | ||
expected = post([markupSection('h2', [marker('--->some text<---')])]); | ||
return post([markupSection('h2', [marker('---><---')])]); | ||
}); | ||
|
||
let text = 'some text'; | ||
let node = Helpers.dom.findTextNode(editorElement, '---><---'); | ||
let {clientX, clientY} = findCenterPointOfTextNode(node); | ||
Helpers.dom.triggerDropEvent(editor, {text, clientX, clientY}); | ||
|
||
assert.postIsSimilar(editor.post, expected); | ||
}); |
Oops, something went wrong.