Skip to content

Commit c026f93

Browse files
committed
Merge remote-tracking branch 'angular-ui/master'
Conflicts: src/tinymce.js
2 parents 1b3369a + c46b976 commit c026f93

File tree

10 files changed

+156
-91
lines changed

10 files changed

+156
-91
lines changed

.bowerrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "bower_components"
3+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- "0.8"
3+
- "0.10"
44

55
before_install:
66
- export DISPLAY=:99.0

README.md

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,70 @@ This directive allows you to add a TinyMCE editor to your form elements.
1010
# Testing
1111

1212
We use karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt:
13-
14-
npm install -g grunt-cli
15-
npm install
16-
bower install
17-
grunt
13+
```
14+
npm install -g grunt-cli
15+
npm install
16+
bower install
17+
grunt
18+
```
1819

1920
The karma task will try to open Chrome as a browser in which to run the tests. Make sure this is available or change the configuration in `test\test.config.js`
2021

2122
# Usage
2223

2324
We use [bower](http://twitter.github.com/bower/) for dependency management. Add
2425

25-
dependencies: {
26-
"angular-ui-tinymce": "latest"
27-
}
26+
```
27+
dependencies: {
28+
"angular-ui-tinymce": "latest"
29+
}
30+
```
2831

2932
To your `bower.json` file. Then run
3033

31-
bower install
34+
```
35+
bower install
36+
```
3237

3338
This will copy the ui-tinymce files into your `components` folder, along with its dependencies. Load the script files in your application:
3439

35-
<script type="text/javascript" src="components/tinymce/tinymce.js"></script>
36-
<script type="text/javascript" src="components/angular/angular.js"></script>
37-
<script type="text/javascript" src="components/angular-ui-tinymce/tinymce.js"></script>
40+
```html
41+
<script type="text/javascript" src="app/bower_components/tinymce/tinymce.js"></script>
42+
<script type="text/javascript" src="app/bower_components/angular/angular.js"></script>
43+
<script type="text/javascript" src="app/bower_components/angular-ui-tinymce/tinymce.js"></script>
44+
```
3845

3946
Add the tinymce module as a dependency to your application module:
4047

41-
var myAppModule = angular.module('MyApp', ['ui.tinymce'])
48+
```javascript
49+
var myAppModule = angular.module('MyApp', ['ui.tinymce'])
50+
```
4251

4352
Apply the directive to your form elements:
4453

45-
<form method="post">
46-
<textarea ui-tinymce ng-model="tinymceModel"></textarea>
47-
</form>
48-
54+
```html
55+
<form method="post">
56+
<textarea ui-tinymce ng-model="tinymceModel"></textarea>
57+
</form>
58+
```
4959
## Options
5060

5161
All the TinyMCE options can be passed through the directive.
5262

53-
myAppModule.controller('MyController', function($scope) {
54-
$scope.tinymceOptions = {
55-
handle_event_callback: function (e) {
56-
// put logic here for keypress
57-
}
58-
};
59-
});
60-
61-
<form method="post">
62-
<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>
63-
</form>
63+
```javascript
64+
myAppModule.controller('MyController', function($scope) {
65+
$scope.tinymceOptions = {
66+
handle_event_callback: function (e) {
67+
// put logic here for keypress
68+
}
69+
};
70+
});
71+
```
72+
```html
73+
<form method="post">
74+
<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>
75+
</form>
76+
```
6477

6578
## Working with ng-model
6679

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
],
1818
"dependencies": {
1919
"angular": "~1.x",
20-
"tinymce": "git://github.com/jozzhart/tinymce.git#4.0.0"
20+
"tinymce": "git@github.com:jozzhart/tinymce.git#4.0.22"
2121
},
2222
"devDependencies": {
2323
"angular-mocks": "~1.x"

gruntFile.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
module.exports = function (grunt) {
22

3-
grunt.loadNpmTasks('grunt-karma');
4-
grunt.loadNpmTasks('grunt-contrib-jshint');
3+
require('load-grunt-tasks')(grunt);
54

65
// Default task.
76
grunt.registerTask('default', ['jshint', 'karma']);
87

98
var karmaConfig = function(configFile, customOptions) {
10-
var options = { configFile: configFile, keepalive: true };
9+
var options = { configFile: configFile, singleRun: true };
1110
var travisOptions = process.env.TRAVIS && { browsers: ['Firefox'], reporters: 'dots' };
1211
return grunt.util._.extend(options, customOptions, travisOptions);
1312
};
1413

1514
// Project configuration.
1615
grunt.initConfig({
1716
karma: {
18-
unit: {
19-
options: karmaConfig('test/test.conf.js')
20-
}
17+
unit: karmaConfig('test/karma.conf.js')
2118
},
2219
jshint:{
2320
files:['src/**/*.js', 'test/**/*.js', 'demo/**/*.js'],
@@ -33,7 +30,12 @@ module.exports = function (grunt) {
3330
eqnull:true,
3431
globals:{}
3532
}
33+
},
34+
changelog: {
35+
options: {
36+
dest: 'CHANGELOG.md'
37+
}
3638
}
3739
});
3840

39-
};
41+
};

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
22
"name": "angular-ui-tinymce",
3-
"version": "0.0.3",
3+
"version": "0.0.5",
44
"description": "This directive allows you to add a tinymce to your form elements.",
55
"author": "https://github.com/angular-ui/ui-tinymce/graphs/contributors",
66
"license": "MIT",
77
"homepage": "http://angular-ui.github.com",
88
"main": "src/tinymce.js",
99
"dependencies": {},
1010
"devDependencies": {
11-
"grunt": "~0.4.1",
12-
"grunt-karma": "~0.4.4",
13-
"grunt-contrib-jshint": "~0.2.0"
11+
"grunt": "~0.4.4",
12+
"grunt-karma": "~0.8.2",
13+
"grunt-contrib-jshint": "~0.10.0",
14+
"grunt-conventional-changelog": "~1.0.0",
15+
"karma-jasmine": "~0.2.2",
16+
"karma-chrome-launcher": "~0.1.3",
17+
"karma-firefox-launcher": "~0.1.3",
18+
"load-grunt-tasks": "~0.2.0"
1419
},
1520
"scripts": {},
1621
"repository": {

src/tinymce.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,19 @@ angular.module('ui.tinymce', [])
2929
expression = {};
3030
}
3131

32+
// make config'ed setup method available
33+
if (expression.setup) {
34+
var configSetup = expression.setup;
35+
delete expression.setup;
36+
}
37+
3238
options = {
3339
// Update model when calling setContent (such as from the source editor popup)
3440
setup: function (ed) {
3541
var args;
3642
ed.on('init', function(args) {
3743
ngModel.$render();
44+
ngModel.$setPristine();
3845
});
3946
// Update model on button click
4047
ed.on('ExecCommand', function (e) {
@@ -48,14 +55,21 @@ angular.module('ui.tinymce', [])
4855
});
4956
// Update model on change, i.e. copy/pasted text, plugins altering content
5057
ed.on('SetContent', function (e) {
51-
if(!e.initial){
58+
if (!e.initial && ngModel.$viewValue !== e.content) {
5259
ed.save();
5360
updateView();
5461
}
5562
});
56-
if (expression.setup) {
57-
scope.$eval(expression.setup);
58-
delete expression.setup;
63+
ed.on('blur', function(e) {
64+
elm.blur();
65+
});
66+
// Update model when an object has been resized (table, image)
67+
ed.on('ObjectResized', function (e) {
68+
ed.save();
69+
updateView();
70+
});
71+
if (configSetup) {
72+
configSetup(ed);
5973
}
6074
},
6175
mode: 'exact',

test/karma.conf.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = function (config) {
2+
config.set({
3+
basePath: '..',
4+
frameworks: ['jasmine'],
5+
files: [
6+
'bower_components/angular/angular.js',
7+
'bower_components/angular-mocks/angular-mocks.js',
8+
'bower_components/tinymce/tinymce.min.js',
9+
'src/tinymce.js',
10+
'test/*.spec.js',
11+
{pattern: 'bower_components/tinymce/themes/modern/theme.min.js', served: true},
12+
{pattern: 'bower_components/tinymce/skins/lightgray/*', served: true}
13+
],
14+
singleRun: false,
15+
autoWatch: true,
16+
browsers: [ 'Chrome' ],
17+
});
18+
};

test/test.conf.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)