-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added editHTMLDocumentMode in iframe plugin - it allows edit whole do…
…cument instead BODY in different case Fixed #241
- Loading branch information
Showing
7 changed files
with
329 additions
and
259 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,150 @@ | ||
describe('Drag and drop element inside Editor', function () { | ||
['mousedown|mousemove|mouseup', 'touchstart|touchmove|touchend'].map(function (item) { | ||
return item.split('|'); | ||
}).forEach(function (events) { | ||
describe(events[0] + ' and move image inside the editor', function () { | ||
it('Should ' + events[1] + ' dom element', function () { | ||
const editor = new Jodit(appendTestArea()); | ||
editor.value = '<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt="">' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
simulateEvent(events[0], 0, editor.editor.getElementsByTagName('img')[0]); | ||
|
||
window.scrollTo(0, 100000); | ||
const box = offset(editor.editor.querySelectorAll('p')[1]); | ||
// createPoint(box.left + 15, box.top + 5); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 15; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
|
||
simulateEvent(events[2], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 20; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
|
||
expect(sortAttributes(editor.value)).equals( | ||
'<p>1111</p>' + | ||
'<p>22<img alt="" src="https://xdsoft.net/jodit/build/images/artio.jpg" style="width:100px">22</p>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>' | ||
); | ||
}); | ||
}); | ||
describe(events[1] + ' image inside anchor', function () { | ||
it('Should ' + events[1] + ' anchor with image', function () { | ||
const editor = new Jodit(appendTestArea()); | ||
editor.value = '<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
simulateEvent(events[0], 0, editor.editor.getElementsByTagName('img')[0]); | ||
|
||
const box = Jodit.modules.Helpers.offset(editor.editor.querySelectorAll('p')[1], editor, editor.editorDocument); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 15; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
simulateEvent(events[2], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 20; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
|
||
}); | ||
|
||
expect(editor.value).equals('<p>1111</p><p>22<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>22</p><p>3333</p><p>4444</p>'); | ||
}); | ||
}); | ||
describe('Disable dragging', function () { | ||
it('Should not move image', function () { | ||
const editor = new Jodit(appendTestArea(), { | ||
draggableTags: [], | ||
}); | ||
|
||
const defaultValue = '<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
editor.value = defaultValue; | ||
|
||
simulateEvent(events[0], 0, editor.editor.getElementsByTagName('img')[0]); | ||
|
||
const box = Jodit.modules.Helpers.offset(editor.editor.querySelectorAll('p')[1], editor, editor.editorDocument); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 15; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
simulateEvent(events[2], 0, editor.editor, function (options) { | ||
options.clientX = box.left + 20; | ||
options.clientY = box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
|
||
expect(editor.value).equals(defaultValue); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(removeStuff); | ||
describe('Drag and drop element inside Editor', function() { | ||
['mousedown|mousemove|mouseup', 'touchstart|touchmove|touchend'] | ||
.map(function(item) { | ||
return item.split('|'); | ||
}) | ||
.forEach(function(events) { | ||
describe( | ||
events[0] + ' and move image inside the editor', | ||
function() { | ||
it('Should ' + events[1] + ' dom element', function() { | ||
const editor = new Jodit(appendTestArea()); | ||
editor.value = | ||
'<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt="">' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
simulateEvent( | ||
events[0], | ||
0, | ||
editor.editor.getElementsByTagName('img')[0] | ||
); | ||
|
||
window.scrollTo(0, 100000); | ||
const box = offset( | ||
editor.editor.querySelectorAll('p')[1] | ||
); | ||
// createPoint(box.left + 15, box.top + 5); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 15; | ||
options.clientY = | ||
box.top + | ||
5 - | ||
document.documentElement.scrollTop; | ||
}); | ||
|
||
simulateEvent(events[2], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 20; | ||
options.clientY = | ||
box.top + | ||
5 - | ||
document.documentElement.scrollTop; | ||
}); | ||
|
||
expect(sortAttributes(editor.value)).equals( | ||
'<p>1111</p>' + | ||
'<p>22<img alt="" src="https://xdsoft.net/jodit/build/images/artio.jpg" style="width:100px">22</p>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>' | ||
); | ||
}); | ||
} | ||
); | ||
describe(events[1] + ' image inside anchor', function() { | ||
it('Should ' + events[1] + ' anchor with image', function() { | ||
const editor = new Jodit(appendTestArea()); | ||
editor.value = | ||
'<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
simulateEvent( | ||
events[0], | ||
0, | ||
editor.editor.getElementsByTagName('img')[0] | ||
); | ||
|
||
const box = Jodit.modules.Helpers.offset( | ||
editor.editor.querySelectorAll('p')[1], | ||
editor, | ||
editor.editorDocument | ||
); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 15; | ||
options.clientY = | ||
box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
simulateEvent(events[2], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 20; | ||
options.clientY = | ||
box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
|
||
expect(editor.value).equals( | ||
'<p>1111</p><p>22<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>22</p><p>3333</p><p>4444</p>' | ||
); | ||
}); | ||
}); | ||
describe('Disable dragging', function() { | ||
it('Should not move image', function() { | ||
const editor = new Jodit(appendTestArea(), { | ||
draggableTags: [] | ||
}); | ||
|
||
const defaultValue = | ||
'<p>1111</p>' + | ||
'<p>2222</p>' + | ||
'<a href="#test"><img style="width: 100px" src="https://xdsoft.net/jodit/build/images/artio.jpg" alt=""></a>' + | ||
'<p>3333</p>' + | ||
'<p>4444</p>'; | ||
|
||
editor.value = defaultValue; | ||
|
||
simulateEvent( | ||
events[0], | ||
0, | ||
editor.editor.getElementsByTagName('img')[0] | ||
); | ||
|
||
const box = Jodit.modules.Helpers.offset( | ||
editor.editor.querySelectorAll('p')[1], | ||
editor, | ||
editor.editorDocument | ||
); | ||
|
||
simulateEvent(events[1], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 15; | ||
options.clientY = | ||
box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
simulateEvent(events[2], 0, editor.editor, function( | ||
options | ||
) { | ||
options.clientX = box.left + 20; | ||
options.clientY = | ||
box.top + 5 - document.documentElement.scrollTop; | ||
}); | ||
|
||
expect(editor.value).equals(defaultValue); | ||
}); | ||
}); | ||
}); | ||
|
||
afterEach(removeStuff); | ||
}); |
Oops, something went wrong.