37 lines
1.6 KiB
JavaScript
37 lines
1.6 KiB
JavaScript
"use strict";
|
|
/**
|
|
* Created by viktor.shevchenko on 3/19/2015.
|
|
*/
|
|
(function () {
|
|
'use strict';
|
|
angular.module('knowledgeArticleModule')
|
|
.directive('editKnowledgeArticleSection', ['localStorageService', function (localStorageService) {
|
|
return {
|
|
restrict: 'E',
|
|
template: '<div ux-id="edit-ka-section-snippet" ckeditor="editorOptions" ng-model="section.snippet" class="ka-ckeditor__section-content clearfix" ng-if="state.ready"></div>',
|
|
scope: {
|
|
options: '=',
|
|
section: '=',
|
|
articleUuid: '@'
|
|
},
|
|
link: function (scope, element, attrs) {
|
|
scope.state = {
|
|
ready: false
|
|
};
|
|
if (attrs.ignoreSectionOptions && scope.$eval(attrs.ignoreSectionOptions)) {
|
|
scope.editorOptions = scope.options;
|
|
}
|
|
else {
|
|
var sectionOptions = {
|
|
title: scope.section.label,
|
|
embeddedImageLimit: scope.section.embeddedImageLimit,
|
|
filebrowserImageUploadUrl: '/smartit/rest/attachment/user/' + encodeURIComponent(localStorageService.get('user.userId')) + '/' + scope.articleUuid + '?section=' + encodeURIComponent(scope.section.name)
|
|
};
|
|
scope.editorOptions = angular.extend({}, scope.options, sectionOptions);
|
|
}
|
|
scope.state.ready = true;
|
|
}
|
|
};
|
|
}]);
|
|
}());
|