diff --git a/README.md b/README.md index 3d8ae99..10a8bf7 100644 --- a/README.md +++ b/README.md @@ -35,34 +35,45 @@ This package comes with 2 directives: ## Editor ```html - + ``` Options: -#### content +#### ng-model -1. An expression. +1. An expression. 1. *Expression*: Mandatory -1. Example: `` -1. Example: `` +1. Example: `` +1. Example: `` + +#### ng-change + +1. An expression. +1. *Expression*: Optional +1. Example: `` + +#### $dirty + +- `` + - ``
`` #### show-preview -1. Should a live preview be displayed. +1. Should a live preview be displayed. 1. *Boolean*: Default to true #### help -1. An expression to invoke upon clicking the help (?) button. +1. An expression to invoke upon clicking the help (?) button. 1. *Expression*: Default to open http://daringfireball.net/projects/markdown/syntax in new window -1. Example: `` +1. Example: `` #### insert-image -1. An expression to invoke upon clicking the "Insert Image" button. +1. An expression to invoke upon clicking the "Insert Image" button. 1. *Expression*: Default to `noop` -1. Example: `` +1. Example: `` 1. The parent scope function `promptImageUrl` must return either: - A string of image URL. - A promise resolved with a string of image URL. @@ -71,15 +82,15 @@ Options: 1. An expression. 1. *Expression*: Default to empty string -1. Example: `` +1. Example: `` #### editor-class 1. An expression to use as [ngClass](https://docs.angularjs.org/api/ng/directive/ngClass). 1. *Expression*: Default to `wmd-input` -1. Example: `` -1. Example: `` -1. Example: `` +1. Example: `` +1. Example: `` +1. Example: `` #### editor-rows diff --git a/angular-pagedown.js b/angular-pagedown.js index 9eb962e..6b52ffd 100644 --- a/angular-pagedown.js +++ b/angular-pagedown.js @@ -33,10 +33,7 @@ angular.module("ui.pagedown", []) }, link: function (scope, element, attrs, ngModel) { - scope.changed = function () { - ngModel.$setDirty(); - scope.$parent.$eval(attrs.ngChange); - }; + var editorUniqueId; @@ -84,11 +81,23 @@ angular.module("ui.pagedown", []) editorElement.val(scope.ngModel); + + scope.changed = function () { + var v = editorElement.val(); + ngModel.$setViewValue(v); + }; + converter.hooks.chain("postConversion", function (text) { - ngModel.$setViewValue(editorElement.val()); + + var v = editorElement.val(); + if (scope.ngModel !== v) { + ngModel.$setViewValue(v); + } + // update scope.previewContent = text; + return text; });