Fixed cut/copy from the editor
This commit is contained in:
parent
1e8fa944a1
commit
c4651fcb3f
@ -295,6 +295,24 @@ function cledit(contentElt, scrollElt, windowParam) {
|
|||||||
}, 0)
|
}, 0)
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
|
contentElt.addEventListener('copy', function (evt) {
|
||||||
|
if (evt.clipboardData) {
|
||||||
|
evt.clipboardData.setData('text/plain', selectionMgr.getSelectedText());
|
||||||
|
evt.preventDefault();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
contentElt.addEventListener('cut', function (evt) {
|
||||||
|
if (evt.clipboardData) {
|
||||||
|
evt.clipboardData.setData('text/plain', selectionMgr.getSelectedText());
|
||||||
|
evt.preventDefault();
|
||||||
|
replace(selectionMgr.selectionStart, selectionMgr.selectionEnd, '')
|
||||||
|
} else {
|
||||||
|
undoMgr.setCurrentMode('single')
|
||||||
|
}
|
||||||
|
adjustCursorPosition()
|
||||||
|
})
|
||||||
|
|
||||||
contentElt.addEventListener('paste', function (evt) {
|
contentElt.addEventListener('paste', function (evt) {
|
||||||
undoMgr.setCurrentMode('single')
|
undoMgr.setCurrentMode('single')
|
||||||
evt.preventDefault()
|
evt.preventDefault()
|
||||||
@ -304,10 +322,10 @@ function cledit(contentElt, scrollElt, windowParam) {
|
|||||||
data = clipboardData.getData('text/plain')
|
data = clipboardData.getData('text/plain')
|
||||||
try {
|
try {
|
||||||
var html = clipboardData.getData('text/html');
|
var html = clipboardData.getData('text/html');
|
||||||
if (html) {
|
if (html && !clipboardData.getData('text/css')) {
|
||||||
var sanitizedHtml = htmlSanitizer.sanitizeHtml(html)
|
var sanitizedHtml = htmlSanitizer.sanitizeHtml(html)
|
||||||
.replace(/ /g, ' '); // Replace non-breaking spaces with classic spaces
|
.replace(/ /g, ' '); // Replace non-breaking spaces with classic spaces
|
||||||
if (sanitizedHtml && sanitizedHtml.indexOf('<span class="token ') === -1) {
|
if (sanitizedHtml) {
|
||||||
data = turndownService.turndown(sanitizedHtml);
|
data = turndownService.turndown(sanitizedHtml);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,11 +343,6 @@ function cledit(contentElt, scrollElt, windowParam) {
|
|||||||
adjustCursorPosition()
|
adjustCursorPosition()
|
||||||
}, false)
|
}, false)
|
||||||
|
|
||||||
contentElt.addEventListener('cut', function () {
|
|
||||||
undoMgr.setCurrentMode('single')
|
|
||||||
adjustCursorPosition()
|
|
||||||
}, false)
|
|
||||||
|
|
||||||
contentElt.addEventListener('focus', function () {
|
contentElt.addEventListener('focus', function () {
|
||||||
editor.$trigger('focus')
|
editor.$trigger('focus')
|
||||||
}, false)
|
}, false)
|
||||||
|
Loading…
Reference in New Issue
Block a user