Support stylesheets in subfolders in the RTE
This commit is contained in:
committed by
Sebastiaan Janssen
parent
73e4c6022d
commit
29a542a0dd
@@ -48,7 +48,14 @@ function tinyMceService($rootScope, $q, imageHelper, $locale, $http, $timeout, s
|
||||
if (configuredStylesheets) {
|
||||
angular.forEach(configuredStylesheets, function (val, key) {
|
||||
|
||||
stylesheets.push(Umbraco.Sys.ServerVariables.umbracoSettings.cssPath + "/" + val + ".css");
|
||||
if (val.indexOf(Umbraco.Sys.ServerVariables.umbracoSettings.cssPath + "/") === 0) {
|
||||
// current format (full path to stylesheet)
|
||||
stylesheets.push(val);
|
||||
}
|
||||
else {
|
||||
// legacy format (stylesheet name only) - must prefix with stylesheet folder and postfix with ".css"
|
||||
stylesheets.push(Umbraco.Sys.ServerVariables.umbracoSettings.cssPath + "/" + val + ".css");
|
||||
}
|
||||
|
||||
promises.push(stylesheetResource.getRulesByName(val).then(function (rules) {
|
||||
angular.forEach(rules, function (rule) {
|
||||
|
||||
@@ -40,14 +40,17 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RteController",
|
||||
$scope.stylesheets = stylesheets;
|
||||
});
|
||||
|
||||
$scope.selected = function(cmd, alias, lookup){
|
||||
if (lookup && angular.isArray(lookup)) {
|
||||
cmd.selected = lookup.indexOf(alias) >= 0;
|
||||
return cmd.selected;
|
||||
}
|
||||
return false;
|
||||
$scope.commandSelected = function(cmd) {
|
||||
cmd.selected = $scope.model.value.toolbar.indexOf(cmd.alias) >= 0;
|
||||
return cmd.selected;
|
||||
};
|
||||
|
||||
$scope.cssSelected = function (css) {
|
||||
// support both current format (full stylesheet path) and legacy format (stylesheet name only)
|
||||
css.selected = $scope.model.value.stylesheets.indexOf(css.path) >= 0 ||$scope.model.value.stylesheets.indexOf(css.name) >= 0;
|
||||
return css.selected;
|
||||
}
|
||||
|
||||
$scope.selectCommand = function(command){
|
||||
var index = $scope.model.value.toolbar.indexOf(command.alias);
|
||||
|
||||
@@ -60,11 +63,16 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RteController",
|
||||
|
||||
$scope.selectStylesheet = function (css) {
|
||||
|
||||
var index = $scope.model.value.stylesheets.indexOf(css.name);
|
||||
// find out if the stylesheet is already selected; first look for the full stylesheet path (current format)
|
||||
var index = $scope.model.value.stylesheets.indexOf(css.path);
|
||||
if (index === -1) {
|
||||
// ... then look for the stylesheet name (legacy format)
|
||||
index = $scope.model.value.stylesheets.indexOf(css.name);
|
||||
}
|
||||
|
||||
if(css.selected && index === -1){
|
||||
$scope.model.value.stylesheets.push(css.name);
|
||||
}else if(index >= 0){
|
||||
if(index === -1){
|
||||
$scope.model.value.stylesheets.push(css.path);
|
||||
}else{
|
||||
$scope.model.value.stylesheets.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div ng-repeat="cmd in tinyMceConfig.commands">
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
ng-checked="selected(cmd, cmd.alias, model.value.toolbar)"
|
||||
ng-checked="commandSelected(cmd)"
|
||||
ng-model="cmd.selected"
|
||||
ng-change="selectCommand(cmd)" />
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<div ng-repeat="css in stylesheets">
|
||||
<label>
|
||||
<input type="checkbox"
|
||||
ng-checked="selected(css, css.name, model.value.stylesheets)"
|
||||
ng-checked="cssSelected(css)"
|
||||
ng-model="css.selected"
|
||||
ng-change="selectStylesheet(css)" />
|
||||
{{css.name}}
|
||||
|
||||
Reference in New Issue
Block a user