I have added a custom event listener to copy/cut of Rich text (HTML) from an element (say elementId). Now when I copy partial ordered list tags, it converts them to unordered list items. This happens due to partial copying the list. Is there any way to solve this ?
document.getElementById(config.editorEl).addEventListener('copy', function(event) {
const range = window.getSelection().getRangeAt(0);
const content = range.cloneContents();
const div = document.createElement('div');
div.appendChild(content);
$(div)
.find('.remove_this_class')
.contents()
.unwrap();
event.clipboardData.setData('text/html', div.innerHTML);
event.preventDefault();
});
Summary: when I copy partial ordered list tags, custom copy handler converts them to unordered list items. How to retain the same ? I see many RTFs have this working.