mirror of
https://github.com/codex-team/editor.js
synced 2024-06-11 02:12:31 +02:00
Add sanitize for paste into block event. Currently pastes only into the end of a block.
This commit is contained in:
parent
93328b1879
commit
f455e806b3
|
@ -271,6 +271,10 @@ cEditor.ui = {
|
|||
|
||||
}, false);
|
||||
|
||||
block.addEventListener('paste', function (event) {
|
||||
cEditor.callback.blockPaste(event, block);
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -581,6 +585,21 @@ cEditor.callback = {
|
|||
|
||||
event.preventDefault();
|
||||
|
||||
},
|
||||
|
||||
blockPaste: function(event, block) {
|
||||
|
||||
var clipboardData, pastedData;
|
||||
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
clipboardData = event.clipboardData || window.clipboardData;
|
||||
pastedData = clipboardData.getData('Text');
|
||||
|
||||
nodeContent = document.createTextNode(pastedData);
|
||||
block.appendChild(nodeContent);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue