When I copy pasted the below lines from notepad to ckeditor5 in Angular 10. I am getting the output with
tag for the second line.
Ex:
This is the first line.
This is the second line.
Output:
<p>This is the first line.<br>This is the second line.</p>
I tried clipboardInput, conversion and transformation etc but all are failed. Approach 1:
editingView.document.on('clipboardInput', (evt, data) => {
const dataTransfer = data.dataTransfer;
console.log('data..', dataTransfer.getData('text/plain'));
let content = plainTextToHtml(dataTransfer.getData('text/plain'));
content = content.replace('\n', '<br />');
content = content.replace('<br>', '<br />');
data.content = editor.data.htmlProcessor.toView(content);
});
Approach 2:
editingView.document.on('clipboardInput', (evt, data) => {
editor.conversion
.for('downcast')
.elementToElement({ model: '<br>', view: '<br />' });
});
is there any way we can configure
as
when copy-paste for new line. Are any plugins available?
There is one hack. Once I get the output I will replace
with
in the data but I want to achieve in plugins level.