Merge branch 'MDL-62968-master' of git://github.com/mickhawkins/moodle

This commit is contained in:
Sara Arjona 2019-01-18 12:38:14 +01:00
commit b577f30b8e
3 changed files with 41 additions and 4 deletions

View File

@ -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;
}
/**

View File

@ -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);

View File

@ -0,0 +1,2 @@
/* Give editor access to all of bootstrap. */
@import "bootstrap/bootstrap";