From 0e26b233904a9a289eb3258b7edb1571fbbf5928 Mon Sep 17 00:00:00 2001 From: indigoxela Date: Thu, 30 May 2024 08:16:27 +0200 Subject: [PATCH] Issue #102: Provide icon vars added via API in editor content style --- js/tinymce-integration.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/js/tinymce-integration.js b/js/tinymce-integration.js index fd07588..eb3bf64 100644 --- a/js/tinymce-integration.js +++ b/js/tinymce-integration.js @@ -46,6 +46,23 @@ } } + // Add icon API vars to editor content styles. They might be in use in + // CSS files attached via content_css option. + if (typeof Backdrop.settings.icons === 'object') { + let contentStyle = ':root{'; + for (const [key, value] of Object.entries(Backdrop.settings.icons)) { + contentStyle += '--icon-' + key + ':url(' + value + ');'; + } + contentStyle += '}'; + // Consider custom profiles already using this option. + if (typeof options.content_style === 'string') { + options.content_style += contentStyle; + } + else { + options.content_style = contentStyle; + } + } + // Content language defaults to interface language. let contentLang = options.language; // If this element's form has a language select list, toggle content lang