angular-content-editable
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
angular.module('app') | ||
angular.module('content-editable', []) | ||
@@ -3,0 +3,0 @@ .directive('contentEditable', contentEditable) |
@@ -1,1 +0,1 @@ | ||
function contentEditable($log,$sce,$compile,$window){function _link(scope,elem,attrs,ngModel){if(!ngModel)return void $log.warn("Error: ngModel is required in elem: ",elem);var noEscape=!0;elem.addClass("content-editable"),scope.ngModel||ngModel.$setViewValue(elem.html()),ngModel.$render=function(){elem.html(ngModel.$modelValue)},elem.bind("click",function(e){return e.preventDefault(),elem.attr("contenteditable","true"),elem[0].focus()}),elem.bind("focus",function(e){if(noEscape=!0,attrs.focusSelect){var range=$window.document.createRange();range.selectNodeContents(elem[0]),$window.getSelection().addRange(range)}attrs.renderHtml&&(elem[0].textContent=elem.html())}),elem.bind("blur",function(){var html;return elem.attr("contenteditable","false"),attrs.renderHtml&&noEscape?(console.log(noEscape),html=elem[0].textContent.replace(/\u00a0/g," "),elem.html(html)):html=elem.html().replace(/<div>/g,"").replace(/ /g," ").replace(/<\/div>/g,""),html!=ngModel.$modelValue&&(ngModel.$setViewValue(html),scope.editCallback&&angular.isFunction(scope.editCallback))?scope.$apply(scope.editCallback(html,elem)):void 0}),elem.bind("keydown",function(e){return 9==e.which?elem[0].blur():27==e.which?(ngModel.$rollbackViewValue(),noEscape=!1,elem[0].blur()):13==e.which&&attrs.singleLine?elem[0].blur():void 0})}var directive={restrict:"A",require:"?ngModel",scope:{editCallback:"=",ngModel:"="},link:_link};return directive}angular.module("app").directive("contentEditable",contentEditable),contentEditable.$inject=["$log","$sce","$compile","$window"]; | ||
function contentEditable($log,$sce,$compile,$window){function _link(scope,elem,attrs,ngModel){if(!ngModel)return void $log.warn("Error: ngModel is required in elem: ",elem);var noEscape=!0;elem.addClass("content-editable"),scope.ngModel||ngModel.$setViewValue(elem.html()),ngModel.$render=function(){elem.html(ngModel.$modelValue)},elem.bind("click",function(e){return e.preventDefault(),elem.attr("contenteditable","true"),elem[0].focus()}),elem.bind("focus",function(e){if(noEscape=!0,attrs.focusSelect){var range=$window.document.createRange();range.selectNodeContents(elem[0]),$window.getSelection().addRange(range)}attrs.renderHtml&&(elem[0].textContent=elem.html())}),elem.bind("blur",function(){var html;return elem.attr("contenteditable","false"),attrs.renderHtml&&noEscape?(console.log(noEscape),html=elem[0].textContent.replace(/\u00a0/g," "),elem.html(html)):html=elem.html().replace(/<div>/g,"").replace(/ /g," ").replace(/<\/div>/g,""),html!=ngModel.$modelValue&&(ngModel.$setViewValue(html),scope.editCallback&&angular.isFunction(scope.editCallback))?scope.$apply(scope.editCallback(html,elem)):void 0}),elem.bind("keydown",function(e){return 9==e.which?elem[0].blur():27==e.which?(ngModel.$rollbackViewValue(),noEscape=!1,elem[0].blur()):13==e.which&&attrs.singleLine?elem[0].blur():void 0})}var directive={restrict:"A",require:"?ngModel",scope:{editCallback:"=",ngModel:"="},link:_link};return directive}angular.module("content-editable",[]).directive("contentEditable",contentEditable),contentEditable.$inject=["$log","$sce","$compile","$window"]; |
{ | ||
"name": "angular-content-editable", | ||
"version": "1.0.2", | ||
"description": "a tiny angularjs directive that allow to edit any html tag", | ||
"version": "1.0.3", | ||
"description": "modify in real time any html tag you want", | ||
"main": "Gruntfile.js", | ||
@@ -13,2 +13,6 @@ "directories": { | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/codekraft-studio/angular-content-editable.git" | ||
}, | ||
"keywords": [ | ||
@@ -19,2 +23,6 @@ "angular", | ||
"author": "codekraft-studio", | ||
"bugs": { | ||
"url": "https://github.com/codekraft-studio/angular-content-editable/issues" | ||
}, | ||
"homepage": "https://github.com/codekraft-studio/angular-content-editable#readme", | ||
"license": "ISC", | ||
@@ -21,0 +29,0 @@ "devDependencies": { |
# angular-content-editable | ||
angular directive for modify in real time any html tag you want | ||
##### Directive attributes: | ||
## Getting started: | ||
Download the package using npm: | ||
```bash | ||
npm install angular-content-editable | ||
``` | ||
or directly from github. | ||
Add the script to your page dependencies: | ||
```html | ||
<script type="text/javascript" src="content-editable.min.js"></script> | ||
``` | ||
And finally add __content-editable__ to your module dependencies: | ||
```javascript | ||
angular.module('app', ['content-editable']) | ||
``` | ||
and you are ready to go, add the directive to any element you want: | ||
```html | ||
<a href="!#" content-editable>edit my text</a> | ||
``` | ||
--- | ||
### Directive attributes: | ||
* __single-line__: if set to true makes the enter key save and blur | ||
@@ -11,5 +31,5 @@ * __focus-select__: if set to true when element goes to focus, all the text inside will be selected | ||
Note that, __edit-callback__ has two arguments: | ||
* text: the new text inside the element | ||
* elem: the element that has been modified | ||
* __text__: the new text inside the element | ||
* __elem__: the element that has been modified | ||
--- | ||
## Example basic: | ||
@@ -16,0 +36,0 @@ Simply adding the directive makes the element fully editable. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
666572
1
2
62
1