mirror of
https://github.com/codex-team/editor.js
synced 2024-06-28 02:10:31 +02:00
Better browser behaviour emulation
This commit is contained in:
parent
1286311d38
commit
f0e92915ad
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -275,6 +275,12 @@ module.exports = (function (caret) {
|
||||||
*/
|
*/
|
||||||
caret.insertNode = function (node) {
|
caret.insertNode = function (node) {
|
||||||
|
|
||||||
|
if (node instanceof window.DocumentFragment) {
|
||||||
|
|
||||||
|
var lastNode = node.lastChild;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
var selection, range;
|
var selection, range;
|
||||||
|
|
||||||
selection = window.getSelection();
|
selection = window.getSelection();
|
||||||
|
@ -284,7 +290,7 @@ module.exports = (function (caret) {
|
||||||
|
|
||||||
range.insertNode(node);
|
range.insertNode(node);
|
||||||
|
|
||||||
range.setStartAfter(node);
|
range.setStartAfter(lastNode || node);
|
||||||
range.collapse(true);
|
range.collapse(true);
|
||||||
|
|
||||||
selection.removeAllRanges();
|
selection.removeAllRanges();
|
||||||
|
|
|
@ -243,7 +243,21 @@ module.exports = function (paste) {
|
||||||
|
|
||||||
if (node.childElementCount) {
|
if (node.childElementCount) {
|
||||||
|
|
||||||
newNode = editor.draw.node('SPAN', '', {innerHTML: node.innerHTML.trim()});
|
newNode = document.createDocumentFragment();
|
||||||
|
|
||||||
|
console.log(node.childNodes);
|
||||||
|
|
||||||
|
node.childNodes.forEach(function (current) {
|
||||||
|
|
||||||
|
if (current instanceof window.Text && current.data.trim() === '') {
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
newNode.appendChild(current.cloneNode(true));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue