Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Console error Uncaught InternalError: too much recursion after adding getSemanticHTML(); #4388

Open
radhakrishnan005 opened this issue Aug 24, 2024 · 0 comments

Comments

@radhakrishnan005
Copy link

I added a bullet list, applied indentation, and tried to submit the form, but I'm getting a Console error: Uncaught InternalError: too much recursion. I customized the indentation to use inline styles instead of classes.
photo_jpg

Below is my script function.
function TextAreaToEditor()
{

//Define a custom attributor for text-indent
class IndentAttributor extends Parchment.StyleAttributor {
    add(node, value) {
        console.log(value);
        const normalizedValue = typeof value === 'string'
            ? parseFloat(value) : value;
        if (normalizedValue === 0) {
            this.remove(node);
            return true;
        } else {
            return super.add(node, `${normalizedValue}em`);
        }
    }

}

// Registering the IndentAttributor
const IndentStyle = new IndentAttributor('indent', 'padding-left', {
    scope: Parchment.Scope.BLOCK,
    whitelist: ['1em', '2em', '3em', '4em', '5em', '6em', '7em', '8em', '9em']
});


Quill.register(IndentStyle, true);

// Default toolbar options for the Quill editor
const toolbarOptions = [
    [
        { 'font': [] },
        { 'size': ['10px', false, '18px', '32px'] }
    ],
    [{ 'color': [] }, { 'background': [] }],
    [
        'bold', 'italic', 'underline', 'strike',
        { 'script': 'sub' }, { 'script': 'super' }
    ],
    [{ 'list': 'ordered' }, { 'list': 'bullet' }, { 'align': [] }],
    [{ 'indent': '-1' }, { 'indent': '+1' }],
    ['link', 'blockquote', 'clean']
];

var defaultOptions = {
    theme: 'snow',
    modules: {
        toolbar: toolbarOptions,
    }
};

// Merge user options with default options
var quillOptions = Object.assign({}, defaultOptions);

// Initialize Quill on all elements with the specified class
document.querySelectorAll('.txt-area-editor').forEach(function(textarea) {
    // Create a new div to replace the textarea
    var quillDiv = document.createElement('div');
    quillDiv.style.height = '200px';
    quillDiv.innerHTML = textarea.value;
    textarea.parentNode.insertBefore(quillDiv, textarea);
    textarea.style.display = 'none';

    // Initialize Quill on the new div
    var quill = new Quill(quillDiv, quillOptions);

    // Store the Quill instance in a data attribute on the textarea
    $(textarea).data('quillInstance', quill);

});

}

I used getSemanticHTML() to get the html data from editor and store it in database.

function GetDatafromTextEditortoTextArea() {
$('.txt-area-editor').each(function() {
const quillEditor = $(this).data('quillInstance');
if (quillEditor) {
$(this).val(quillEditor.getSemanticHTML());
}
});
}

NOTE: Console error occur after using getSemanticHTML(), before that I used innerHTML .How to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant