Paste format text style in Bubble rich text editor

Hello everyone,

I wonder if there is a way when someone paste a text into Bubble rich text editor that it would remove any style attached to it.

Meaning, is there a way, to go from this:

To this when you paste (so format all the style as if it was a ctrl+shift+v):

For those looking for a solution, you have to add an id to the Rich Text Editor, add an html element and paste this code replacing YOUREDITORID by the id you used:

const editorEle = document.getElementById('YOUREDITORID ');

// Handle the `paste` event
editorEle.addEventListener('paste', function (e) {
    // Prevent the default action

    // Get the copied text from the clipboard
    const text = e.clipboardData
        ? (e.originalEvent || e).clipboardData.getData('text/plain')
        : // For IE
        ? window.clipboardData.getData('Text')
        : '';

    if (document.queryCommandSupported('insertText')) {
        document.execCommand('insertText', false, text);
    } else {
        // Insert text at the current position of caret
        const range = document.getSelection().getRangeAt(0);

        const textNode = document.createTextNode(text);

        const selection = window.getSelection();
1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.