Hi,
To get or set the Editor’s value dynamically, you can use its value property.
Here is a basic sample which i hope will help you:
` // Initialize Firebase
const firebaseConfig = {
apiKey: “AIzaSy…yourKey…”,
authDomain: “yourapp.firebaseapp.com”,
projectId: “yourapp”,
storageBucket: “yourapp.appspot.com”,
messagingSenderId: “1234567890”,
appId: “1:1234567890:web:abcdef”
};
const app = firebase.initializeApp(firebaseConfig);
const db = firebase.firestore();
const editor = document.getElementById(‘editor’);
// Save content to Firestore
document.getElementById(‘saveBtn’).addEventListener(‘click’, async () => {
const htmlContent = editor.value;
await db.collection(‘documents’).doc(‘exampleDoc’).set({ content: htmlContent });
alert(‘Saved to Firebase!’);
});
// Load content from Firestore
document.getElementById(‘loadBtn’).addEventListener(‘click’, async () => {
const doc = await db.collection(‘documents’).doc(‘exampleDoc’).get();
if (doc.exists) {
editor.value = doc.data().content;
} else {
alert(‘No content found!’);
}`
Best regards,
Markov
Smart UI Team
https://www.htmlelements.com/