Make sure to set the 'emitUpdate' parameter to 'true' when setting the content. This will signal the extension to update the table of content.
editor.commands.setContent(content, true)