diff --git a/lib/outputlib.php b/lib/outputlib.php index a2ee601e843..b0079f6f28c 100644 --- a/lib/outputlib.php +++ b/lib/outputlib.php @@ -749,7 +749,7 @@ class theme_config { 'parents', 'sheets', 'parents_exclude_sheets', 'plugins_exclude_sheets', 'usefallback', 'javascripts', 'javascripts_footer', 'parents_exclude_javascripts', 'layouts', 'enable_dock', 'enablecourseajax', 'requiredblocks', - 'rendererfactory', 'csspostprocess', 'editor_sheets', 'rarrow', 'larrow', 'uarrow', 'darrow', + 'rendererfactory', 'csspostprocess', 'editor_sheets', 'editor_scss', 'rarrow', 'larrow', 'uarrow', 'darrow', 'hidefromselector', 'doctype', 'yuicssmodules', 'blockrtlmanipulations', 'lessfile', 'extralesscallback', 'lessvariablescallback', 'blockrendermethod', 'scss', 'extrascsscallback', 'prescsscallback', 'csstreepostprocessor', 'addblockposition', @@ -973,6 +973,31 @@ class theme_config { return $files; } + /** + * Compiles and returns the content of the SCSS to be used in editor content + * + * @return string Compiled CSS from the editor SCSS + */ + public function editor_scss_to_css() { + $css = ''; + + if (!empty($this->editor_scss)) { + $compiler = new core_scss(); + + foreach ($this->editor_scss as $filename) { + $compiler->set_file("{$this->dir}/scss/{$filename}.scss"); + + try { + $css .= $compiler->to_css(); + } catch (\Exception $e) { + debugging('Error while compiling editor SCSS: ' . $e->getMessage(), DEBUG_DEVELOPER); + } + } + } + + return $css; + } + /** * Get the stylesheet URL of this theme. * @@ -1270,13 +1295,22 @@ class theme_config { * @return string CSS markup */ public function get_css_content_editor() { - // Do not bother to optimise anything here, just very basic stuff. - $cssfiles = $this->editor_css_files(); $css = ''; + $cssfiles = $this->editor_css_files(); + + // If editor has static CSS, include it. foreach ($cssfiles as $file) { $css .= file_get_contents($file)."\n"; } - return $this->post_process($css); + + // If editor has SCSS, compile and include it. + if (($convertedscss = $this->editor_scss_to_css())) { + $css .= $convertedscss; + } + + $output = $this->post_process($css); + + return $output; } /** diff --git a/theme/boost/config.php b/theme/boost/config.php index 354af14e4ed..a8a727c4286 100644 --- a/theme/boost/config.php +++ b/theme/boost/config.php @@ -29,6 +29,7 @@ require_once(__DIR__ . '/lib.php'); $THEME->name = 'boost'; $THEME->sheets = []; $THEME->editor_sheets = []; +$THEME->editor_scss = ['editor']; $THEME->usefallback = true; $THEME->scss = function($theme) { return theme_boost_get_main_scss_content($theme); diff --git a/theme/boost/scss/editor.scss b/theme/boost/scss/editor.scss new file mode 100644 index 00000000000..74eb7794000 --- /dev/null +++ b/theme/boost/scss/editor.scss @@ -0,0 +1,2 @@ +/* Give editor access to all of bootstrap. */ +@import "bootstrap/bootstrap";