How to submit rich text editor content to Airtable database

I’m working on a web application that uses a rich text editor and I need to save the content to my Airtable database when users click a submit button. My plan is to get the text from the editor, grab some user info, and then add a new record to the table.

I’m having issues with my current code though. Can someone help me figure out what’s wrong?

HTML Setup:

<div id="editor-container">Write your content here!</div>
<button onclick="submitContent()" class="submit-btn">Save Content</button>

JavaScript Code:

// Initialize the editor
Quill.init({
  selector: '#editor-container',
  theme: 'snow'
});

// Function to handle submission
function submitContent(){
    var content = quill.root.innerHTML;
    uploadToDatabase(content);

    function uploadToDatabase(content){
        var userID = window['currentUser']['recordId'];
        var database = new Airtable({apiKey: 'your-key-here'}).base('base-id');
    }

    database('Posts').create([
        {
           "fields": {
              "Text": content,
              "Author": [
                 userID
              ]
           }
        }
    ], function(error, results) {
        if (error) {
             console.log(error);
             return;
            }
     });
}

The function doesn’t seem to work properly. What am I missing here?

your database var is declared inside uploadToDatabase, but ur calling it outside. either move the Airtable init outside or put the create call inside the function. also, make sure you’ve initialized quill as a variable first.