Skip to content

Instantly share code, notes, and snippets.

@jamiepollock
Created January 11, 2016 10:22
Show Gist options
  • Select an option

  • Save jamiepollock/3702572a46aaa0210210 to your computer and use it in GitHub Desktop.

Select an option

Save jamiepollock/3702572a46aaa0210210 to your computer and use it in GitHub Desktop.
Simple reusable rte editor - wrapping umb-editor rte with a reusable config for use in a custom Umbraco backoffice ui
angular.module("umbraco.directives").directive('simplerichtexteditor', function (assetsService) {
return {
restrict: 'E',
scope: {
field: '='
},
controller: function ($scope, $element) {
$scope.model = {
alias: 'simpleRichtextEditor',
view: 'rte',
config: {
editor: {
toolbar: [ 'preview', '|', 'undo', 'redo', '|', 'copy', 'cut', 'paste', '|', 'bold', 'italic', '|', 'link', 'unlink'],
stylesheets: [],
dimensions: { height: 400, width: '100%' }
}
},
value: $scope.field
};
$scope.$watch('model', function () {
if ($scope.model != undefined) {
$scope.field = $scope.model.value;
}
}, true);
},
templateUrl: '/App_Plugins/SimpleDirectives/views/simplerichtexteditor.html'
};
});
<div class="richtexteditor--simple">
<umb-editor model="model"></umb-editor>
</div>
<simplerichtexteditor field="model.myRteValue" ng-if="model" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment