How to access content area width and height in wp editor
In some cases, we need to access the width & height of content area size in pixel.
Here is the solution which I already tested during my working time.
function checkEditorSection() {
// Select the editor content area
const editorSection = document.querySelector('.interface-interface-skeleton__content');
if (editorSection) {
// Get the size of the editor section
const editorSize = editorSection.getBoundingClientRect();
// Output width and height
console.log('Editor Width:', editorSize.width);
console.log('Editor Height:', editorSize.height);
} else {
// Retry after a short delay if the section isn't found yet
console.log("Retrying... Editor section not found!");
setTimeout(checkEditorSection, 3000); // Retry after 500ms
}
}
// Call the function once the DOM content is fully loaded
window.onload = function () {
checkEditorSection();
};
Comments
Post a Comment