0

I'm writing some customization for the WordPress editor, and running in to an odd issue.

If I console.log(tinyMCE.editors), I get an array output:

console.log(tinyMCE.editors)

Clearly I can see there's are four keys in the array, but when I run console.log(Object.keys(tinyMCE.editors), I get:

console.log(Object.keys(tinyMCE.editors)

And when I try to reference the editor I want to modify with console.log(tinyMCE.editors.content), I get:

console.log(tinyMCE.editors.content)

I don't understand what's happening here, as far as I can tell the keys should exist, but I can't seem to reference them. What am I doing wrong?

JacobTheDev
  • 17,318
  • 25
  • 95
  • 158
  • 1
    `tinyMCE.editors` is an empty array, it logs `[]`. What you see below is "live", so it doesn't show how the array looked like when the code ran. You probably got an issue with asynchronity, but thats hard to tell without code (have a look at the dupes) – Jonas Wilms Feb 15 '19 at 15:32
  • 2
    As a future reference, don't use images to show code. Just copy the console.log output. – kemicofa ghost Feb 15 '19 at 15:33
  • @JonasWilms Oh! That makes so much more sense, thanks! – JacobTheDev Feb 15 '19 at 15:35
  • 1
    @kemicofa will keep it in mind, thanks. I thought for this instance I should show exactly what the console output, which I do think helped because I likely would've excluded the `[]` otherwise. In the future, if I feel the need to post screenshots, I'll be sure to also post code – JacobTheDev Feb 15 '19 at 15:36

0 Answers0