Skip to content
This repository was archived by the owner on Jan 26, 2022. It is now read-only.

catch up #1

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[![Stories in Ready](https://badge.waffle.io/TylerGarlick/angular-redactor.png?label=ready&title=Ready)](https://waffle.io/TylerGarlick/angular-redactor)
angular-redactor
================

Expand All @@ -7,6 +8,7 @@ Angular Redactor is an angular directive for the Redactor editor. http://impera
Important Changes
--------------

There is an additional file (angular-redactor-2) for Redactor II.
As of version 1.1.0, there is an additional file (angular-redactor-9.x) has been added to accommodate the the 9.x version of redactor, the angular-redactor.js will support the latest version of redactor.


Expand Down Expand Up @@ -36,13 +38,18 @@ With Options
<textarea ng-model="content" redactor="{buttons: ['formatting', '|', 'bold', 'italic']}" cols="30" rows="10"></textarea>
```

With Plugins
```html
<textarea ng-model="content" redactor="{plugins: ['source']}" cols="30" rows="10"></textarea>
```

You can pass options directly to Redactor by specifying them as the value of the `redactor` attribute.

Global Options
```js
angular.module('app', ['angular-redactor'])
.config(function(redactorOptions) {
redactorOptions.buttons = ['formatting', '|', 'bold', 'italic'];
redactorOptions.buttons = ['formatting', '|', 'bold', 'italic'];
});
```

Expand All @@ -56,3 +63,9 @@ Bower Installation
```js
bower install angular-redactor
```

NPM Installation
--------------
```js
npm install angular-redactor
```
62 changes: 62 additions & 0 deletions angular-redactor-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
(function() {
'use strict';

/**
* usage: <textarea ng-model="content" redactor></textarea>
*
* additional options:
* redactor: hash (pass in a redactor options hash)
*
*/

var redactorOptions = {};

angular.module('angular-redactor', [])
.constant('redactorOptions', redactorOptions)
.directive('redactor', ['$timeout', function($timeout) {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attrs, ngModel) {

// Expose scope var with loaded state of Redactor
scope.redactorLoaded = false;

var updateModel = function updateModel(value) {
// $timeout to avoid $digest collision
$timeout(function() {
scope.$apply(function() {
ngModel.$setViewValue(value);
});
});
},
options = {
callbacks: {
change: updateModel
}
},
additionalOptions = attrs.redactor ?
scope.$eval(attrs.redactor) : {},
editor;

angular.extend(options, redactorOptions, additionalOptions);

// put in timeout to avoid $digest collision. call render()
// to set the initial value.
$timeout(function() {
editor = element.redactor(options);
ngModel.$render();
});

ngModel.$render = function() {
if(angular.isDefined(editor)) {
$timeout(function() {
element.redactor('code.set', ngModel.$viewValue || '');
scope.redactorLoaded = true;
});
}
};
}
};
}]);
})();
7 changes: 3 additions & 4 deletions angular-redactor-9.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
},
additionalOptions = attrs.redactor ?
scope.$eval(attrs.redactor) : {},
editor,
$_element = angular.element(element);
editor;

angular.extend(options, redactorOptions, additionalOptions);

Expand All @@ -51,14 +50,14 @@
// put in timeout to avoid $digest collision. call render() to
// set the initial value.
$timeout(function() {
editor = $_element.redactor(options);
editor = element.redactor(options);
ngModel.$render();
});

ngModel.$render = function() {
if(angular.isDefined(editor)) {
$timeout(function() {
$_element.redactor('set', ngModel.$viewValue || '');
element.redactor('set', ngModel.$viewValue || '');
scope.redactorLoaded = true;
});
}
Expand Down
13 changes: 8 additions & 5 deletions angular-redactor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
},
additionalOptions = attrs.redactor ?
scope.$eval(attrs.redactor) : {},
editor,
$_element = angular.element(element);
editor;

angular.extend(options, redactorOptions, additionalOptions);

Expand All @@ -52,15 +51,19 @@
// put in timeout to avoid $digest collision. call render() to
// set the initial value.
$timeout(function() {
editor = $_element.redactor(options);
editor = element.redactor(options);
ngModel.$render();
element.on('remove',function(){
element.off('remove');
element.redactor('core.destroy');
});
});

ngModel.$render = function() {
if(angular.isDefined(editor)) {
$timeout(function() {
$_element.redactor('code.set', ngModel.$viewValue || '');
$_element.redactor('placeholder.toggle');
element.redactor('code.set', ngModel.$viewValue || '');
element.redactor('placeholder.toggle');
scope.redactorLoaded = true;
});
}
Expand Down
4 changes: 2 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "angular-redactor",
"main": "angular-redactor.js",
"version": "1.1.4",
"version": "1.1.5",
"homepage": "https://github.com/TylerGarlick/angular-redactor",
"authors": [
"Tyler Garlick <[email protected]>"
Expand All @@ -24,7 +24,7 @@
"tests"
],
"dependencies": {
"jquery": ">=2.0.0",
"jquery": "^2.0.0 || ^1.9.0",
"angular": ">=1.2.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion demo/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ angular.module('app')
$scope.changeContent = function () {
$scope.content = "<h1>Some bogus content</h1>"
}
$scope.content = "<p>This is my fawesome content</p>";
$scope.content = "<p>This is my awesome content</p>";
}]);
7 changes: 4 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular-route.js"></script>
<link rel="stylesheet" href="redactor/redactor.css"/>
<script src="redactor/redactor.js"></script>
<script src="redactor/source.js"></script>
</head>
<body>
<div class="container">
<div ng-view></div>
</div>
<script src="../bower_components/angular/angular.js"></script>
<script src="../bower_components/angular-route/angular-route.js"></script>
<script src="../angular-redactor.js"></script>
<script src="../angular-redactor-2.js"></script>
<script src="app.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions demo/views/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ <h1>Demo</h1>
<div class="panel-heading">Air Option</div>
<div class="panel-body">
<div class="form-group">
<textarea ng-model="content" redactor="{air: true}" cols="30" rows="10"></textarea>
<textarea ng-model="content" redactor="{air: true, plugins: ['source']}" cols="30" rows="10"></textarea>
</div>
<strong>Markup</strong>
<pre>
&lt;textarea ng-model="content" redactor="{air: true}" cols="30" rows="10"&gt;&lt;/textarea&gt;
&lt;textarea ng-model="content" redactor="{air: true, plugins: ['source']}" cols="30" rows="10"&gt;&lt;/textarea&gt;
</pre>
</div>
</div>
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "angular-redactor",
"version": "1.1.7",
"description": "Directive for redactor WYSIWYG editor",
"main": "angular-redactor.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/TylerGarlick/angular-redactor.git"
},
"keywords": [
"Redactor",
"WYSIWYG",
"Angular",
"Directives",
"Html5",
"Editor"
],
"author": [
"Tyler Garlick <[email protected]>"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/TylerGarlick/angular-redactor/issues"
},
"homepage": "https://github.com/TylerGarlick/angular-redactor#readme"
}