Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-content-editable

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-content-editable - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

dist/content-editable.directive.js

@@ -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(/&nbsp;/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(/&nbsp;/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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc