// Get Selected Element
const selectedElement = await webflow.getSelectedElement();
if (selectedElement?.textContent && selectedElement?.children) {
// Get Child Elements
const children = await selectedElement.getChildren();
// Filter string elements from children
const strings = children.filter(child => child.type === "String");
// Initialize an array to hold text content
let textContent = [];
// Loop over string elements to get text
for (const myString of strings) {
if (myString.type === "String") {
const text = await myString.getText();
textContent.push(text);
}
}
// Print text
console.log(textContent);
}