This repository was archived by the owner on Sep 8, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,15 @@ angular.module('ui.tinymce', [])
7
7
uiTinymceConfig = uiTinymceConfig || { } ;
8
8
var generatedIds = 0 ;
9
9
return {
10
- require : 'ngModel' ,
11
- link : function ( scope , element , attrs , ngModel ) {
10
+ require : [ 'ngModel' , '^?form' ] ,
11
+ link : function ( scope , element , attrs , ctrls ) {
12
12
if ( ! $window . tinymce ) {
13
13
return ;
14
14
}
15
15
16
+ var ngModel = ctrls [ 0 ] ,
17
+ form = ctrls [ 1 ] || null ;
18
+
16
19
var expression , options , tinyInstance ,
17
20
updateView = function ( editor ) {
18
21
if ( options . raw === true ) {
@@ -43,6 +46,9 @@ angular.module('ui.tinymce', [])
43
46
ed . on ( 'init' , function ( ) {
44
47
ngModel . $render ( ) ;
45
48
ngModel . $setPristine ( ) ;
49
+ if ( form ) {
50
+ form . $setPristine ( ) ;
51
+ }
46
52
} ) ;
47
53
// Update model on button click
48
54
ed . on ( 'ExecCommand' , function ( ) {
Original file line number Diff line number Diff line change @@ -27,6 +27,12 @@ describe('uiTinymce', function () {
27
27
scope . $apply ( ) ;
28
28
}
29
29
30
+ it ( 'should be pristine on load' , function ( ) {
31
+ compile ( ) ;
32
+ expect ( element . find ( 'textarea' ) . controller ( 'form' ) . $pristine ) . toBe ( true ) ;
33
+ expect ( element . find ( 'textarea' ) . controller ( 'ngModel' ) . $pristine ) . toBe ( true ) ;
34
+ } ) ;
35
+
30
36
describe ( 'compiling this directive' , function ( ) {
31
37
32
38
it ( 'should include the passed options' , function ( ) {
You can’t perform that action at this time.
0 commit comments