Theme options, RichTextarea and extended toolbar

Description of issue or problem I’m having:
I am developing a new theme and as part of the theme options I have created a text field into which the users can paste some additional content to show in the home page. The field is working and the content is being shown on the home page, however it includes all HTML formatting because it doesn’t appear to be possible to switch the editor into “code” mode (the </> icon).

Steps I took leading up to the issue:
Added the field to the theme options:

$this->addOption('clinicalQueries', 'FieldRichTextarea', [
 'label' => __('plugins.themes.default.option.clinicalQueries.label'),
 'default' => '',
]);

Included the content in the indexJournal.tpl file:

<section aria-labelledBy="clinical-queries">
 {$activeTheme->getOption('clinicalQueries')}
</section>

What I tried to resolve the issue:
I have looked on the forums and there are some solutions that require editing of the core TinyMCE setup. (Is this recommended??)

I was hoping there would be some additional configuration parameters I could pass to the addOption command to activate the extended editor toolbar. Do any exist?

Application Version - e.g., OJS 3.1.2:
OJS 3.3.0.10

Additional information, such as screenshots and error log messages if applicable:
clinicalQueries

Actually - after some more digging, I think I’ve found a way to change the toolbars for any RichTextarea option field:-

$this->addOption('clinicalQueries', 'FieldRichTextarea', [
 'tooltip' => __('plugins.themes.rcvsk.option.clinicalQueries.description'),
 'isMultilingual' => false,
 'value' => $context->getData('clinicalQueries'),
 'toolbar' => 'bold italic superscript subscript | link | blockquote bullist numlist | image | code',
			'plugins' => 'paste,link,lists,image,code',
			'uploadUrl' => $themeApiUrl,
			'label' => __('plugins.themes.rcvsk.option.clinicalQueries.label'),
			'default' => '',
]);

the editor now shows with the correct toolbar.

Hmm, it almost works!

The problem now is that the $themeApiUrl value isn’t correct and I’m unsure exactly how to set that. The editor rejects any attempts to upload an image due to this.

The code I’m using the set up the $themeApiUrl value is:-

$request = Application::get()->getRequest();
$context = Application::get()->getRequest()->getContext();
$dispatcher = $request->getDispatcher();
$router = $request->getRouter();
$contextApiUrl = $dispatcher->url($request, ROUTE_API, $context->getPath(), 'contexts/' . $context->getId());
$themeApiUrl = $dispatcher->url($request, ROUTE_API, $context->getPath(), 'contexts/' . $context->getId() . '/theme');

Has anyone else managed to get this working correctly?