Closed TobiasKrais closed 2 months ago
If I add a custom configuration for tag filtering, will it be more flexible? Will it meet this requirement?
Other editors offer several paste function. E.g. TinyMCE or CKE offers:
I think we should use pasteAsText as what it is and what is common use: paste as plain text. That is also my requirement. If you want, you can additionally offer other functionality to discern from other editors, e.g. pasteAsSimpleHtml. But that is not my requirement.
The only "formatting" pasteAsText commonly supports are line breaks that are interpreted as <br>
or <p>
.
Thank you for the fix last week. Please not that pasteAsText still has not the common use. Line breaks are not preserved.
hi @TobiasKrais , the Line breaks are be preserved if config the pastedAsText ? if yes, i will continue to optimize this issue.
TinyMCE and other editors convert line breaks to <br>
. Thus paragraphs are kept for users.
This is my workaround in editor config:
htmlPasteConfig: {
pasteProcessor: (html) => {
// Create a temporary DOM element
let tempDiv = document.createElement('div');
tempDiv.innerHTML = html;
// Extract text content and replace newlines with <br> tags
let formattedContent = tempDiv.innerText.replace('/\\n/g', '<br>');
return formattedContent;
}
},
When
pasteAsText: true
is activated in configuration, text is pasted without formatting. When copied text includes a heading like h1, the editor shows it as h1 heading. Other editors like TinyMCE paste headings also as plain text.