You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I find a bug , that paste will replace next line when user use Mac OS and press mouse right to paste.
that reson is in Mac. after user press mouser right, the getSelection() will be change. not in last position.
so we need to save last position in keyup and mouseup event.
this is what we do :
editor.onPaste = (event, cleanData, maxCharCount, core) => {
//only for mac because if you set in windows. your mouser right will not update position
if (navigator.userAgent.includes('Mac') || /iPhone|iPad|iPod/.test(navigator.userAgent)) {
if (lastRange) {
core.setRange(
lastRange.startContainer,
lastRange.startOffset,
lastRange.endContainer,
lastRange.endOffset,
);
}
}
return removeFormat(cleanData);
};
const wysiwyg = editor.core.context.element.wysiwyg;
wysiwyg.addEventListener('mouseup', function (e) {
if (e.button === 0) {
setLastRange();
}
});
wysiwyg.addEventListener('keyup', function (e) {
setLastRange();
});
let lastRange = null;
const setLastRange = () => {
//you need setTimeout beacuse sometimes getSelection will delay
setTimeout(() => {
const range = editor.core.getRange();
lastRange = {
startContainer: range.startContainer,
startOffset: range.startOffset,
endContainer: range.endContainer,
endOffset: range.endOffset,
};
}, 50);
};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I find a bug , that paste will replace next line when user use Mac OS and press mouse right to paste.
that reson is in Mac. after user press mouser right, the getSelection() will be change. not in last position.
so we need to save last position in keyup and mouseup event.
this is what we do :
Beta Was this translation helpful? Give feedback.
All reactions