New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.2.1 to 1.2.2

test/angular-content-editable.directive.test.js

42

dist/angular-content-editable.js

@@ -24,4 +24,3 @@ angular.module('angular-content-editable', []);

var noEscape = true;
var originalElement = elem[0];
var noEscape = true, originalElement = elem[0], callback;

@@ -37,3 +36,6 @@ // get default usage options

});
// Get the callback from item scope or global defined
callback = scope.editCallback || options.editCallback;
// add editable class

@@ -76,3 +78,3 @@ attrs.$addClass(options.editableClass);

noEscape = true;
// select all on focus

@@ -86,3 +88,3 @@ if( options.focusSelect ) {

}
// if render-html is enabled convert

@@ -94,3 +96,3 @@ // all text content to plaintext

}
});

@@ -106,11 +108,11 @@

var html;
scope.isEditing = false;
// remove active class when editing is over
attrs.$removeClass('active');
// disable editability
attrs.$set('contenteditable', 'false');
// if text needs to be rendered as html

@@ -123,3 +125,3 @@ if( options.renderHtml && noEscape ) {

elem.html(html);
} else {

@@ -129,6 +131,6 @@ // get element content replacing html tag

}
// if element value is different from model value
if( html != ngModel.$modelValue ) {
/**

@@ -140,17 +142,17 @@ * This method should be called

ngModel.$setViewValue(html);
// if user passed a variable
// and is a function
if( scope.editCallback && angular.isFunction(scope.editCallback) ) {
if( callback && angular.isFunction(callback) ) {
// run the callback with arguments: current text and element
return scope.editCallback({
return callback({
text: html,
elem: elem
});
}
}
});

@@ -157,0 +159,0 @@

@@ -1,1 +0,1 @@

angular.module("angular-content-editable",[]),angular.module("angular-content-editable").directive("contentEditable",["$log","$sce","$parse","$window","contentEditable",function($log,$sce,$parse,$window,contentEditable){function _link(scope,elem,attrs,ngModel){function onClick(e){e.preventDefault(),attrs.$set("contenteditable","true"),attrs.$addClass("active"),originalElement.focus()}function onFocus(e){scope.$evalAsync(function(){if(scope.isEditing=!0,noEscape=!0,options.focusSelect){var range=$window.document.createRange(),selection=$window.getSelection();range.selectNodeContents(originalElement),selection.removeAllRanges(),selection.addRange(range)}options.renderHtml&&(originalElement.textContent=elem.html())})}function onBlur(e){scope.$apply(function(){var html;if(scope.isEditing=!1,attrs.$removeClass("active"),attrs.$set("contenteditable","false"),options.renderHtml&&noEscape?(html=originalElement.textContent.replace(/\u00a0/g," "),elem.html(html)):html=elem.html().replace(/ /g," "),html!=ngModel.$modelValue&&(ngModel.$setViewValue(html),scope.editCallback&&angular.isFunction(scope.editCallback)))return scope.editCallback({text:html,elem:elem})})}function onKeyDown(e){return 9==e.which?void originalElement.blur():27==e.which?(ngModel.$rollbackViewValue(),noEscape=!1,originalElement.blur()):13==e.which&&(options.singleLine||e.ctrlKey)?originalElement.blur():void 0}if(!ngModel)return void $log.warn("Error: ngModel is required in elem: ",elem);var noEscape=!0,originalElement=elem[0],options=angular.copy(contentEditable);angular.forEach(options,function(val,key){key in attrs&&(options[key]=$parse(attrs[key])(scope))}),attrs.$addClass(options.editableClass),scope.$watch("isEditing",function(newValue,oldValue){newValue!==oldValue&&(newValue?originalElement.click():originalElement.blur())}),ngModel.$render=function(){elem.html(ngModel.$modelValue||elem.html())},elem.on("click",onClick),elem.on("focus",onFocus),elem.on("blur",onBlur),elem.on("keydown",onKeyDown),scope.$on("$destroy",function(){elem.off("click",onClick),elem.off("focus",onFocus),elem.off("blur",onBlur),elem.off("keydown",onKeyDown)})}return{restrict:"A",require:"ngModel",scope:{editCallback:"&?",isEditing:"=?"},link:_link}}]),angular.module("angular-content-editable").provider("contentEditable",function(){var defaults={editableClass:"editable",keyBindings:!0,singleLine:!1,focusSelect:!0,renderHtml:!1,editCallback:!1};this.configure=function(options){return angular.extend(defaults,options)},this.$get=function(){return defaults}});
angular.module("angular-content-editable",[]),angular.module("angular-content-editable").directive("contentEditable",["$log","$sce","$parse","$window","contentEditable",function($log,$sce,$parse,$window,contentEditable){function _link(scope,elem,attrs,ngModel){function onClick(e){e.preventDefault(),attrs.$set("contenteditable","true"),attrs.$addClass("active"),originalElement.focus()}function onFocus(e){scope.$evalAsync(function(){if(scope.isEditing=!0,noEscape=!0,options.focusSelect){var range=$window.document.createRange(),selection=$window.getSelection();range.selectNodeContents(originalElement),selection.removeAllRanges(),selection.addRange(range)}options.renderHtml&&(originalElement.textContent=elem.html())})}function onBlur(e){scope.$apply(function(){var html;if(scope.isEditing=!1,attrs.$removeClass("active"),attrs.$set("contenteditable","false"),options.renderHtml&&noEscape?(html=originalElement.textContent.replace(/\u00a0/g," "),elem.html(html)):html=elem.html().replace(/ /g," "),html!=ngModel.$modelValue&&(ngModel.$setViewValue(html),callback&&angular.isFunction(callback)))return callback({text:html,elem:elem})})}function onKeyDown(e){return 9==e.which?void originalElement.blur():27==e.which?(ngModel.$rollbackViewValue(),noEscape=!1,originalElement.blur()):13==e.which&&(options.singleLine||e.ctrlKey)?originalElement.blur():void 0}if(!ngModel)return void $log.warn("Error: ngModel is required in elem: ",elem);var callback,noEscape=!0,originalElement=elem[0],options=angular.copy(contentEditable);angular.forEach(options,function(val,key){key in attrs&&(options[key]=$parse(attrs[key])(scope))}),callback=scope.editCallback||options.editCallback,attrs.$addClass(options.editableClass),scope.$watch("isEditing",function(newValue,oldValue){newValue!==oldValue&&(newValue?originalElement.click():originalElement.blur())}),ngModel.$render=function(){elem.html(ngModel.$modelValue||elem.html())},elem.on("click",onClick),elem.on("focus",onFocus),elem.on("blur",onBlur),elem.on("keydown",onKeyDown),scope.$on("$destroy",function(){elem.off("click",onClick),elem.off("focus",onFocus),elem.off("blur",onBlur),elem.off("keydown",onKeyDown)})}return{restrict:"A",require:"ngModel",scope:{editCallback:"&?",isEditing:"=?"},link:_link}}]),angular.module("angular-content-editable").provider("contentEditable",function(){var defaults={editableClass:"editable",keyBindings:!0,singleLine:!1,focusSelect:!0,renderHtml:!1,editCallback:!1};this.configure=function(options){return angular.extend(defaults,options)},this.$get=function(){return defaults}});
{
"name": "angular-content-editable",
"version": "1.2.1",
"version": "1.2.2",
"description": "modify in real time any html tag you want",

@@ -10,3 +10,6 @@ "main": "dist/angular-content-editable.js",

"scripts": {
"test": "node node_modules/karma/bin/karma start --single-run"
"test": "karma start --single-run",
"start": "grunt",
"prebuild": "npm run test",
"build": "grunt build"
},

@@ -13,0 +16,0 @@ "repository": {

@@ -22,4 +22,3 @@ angular.module('angular-content-editable')

var noEscape = true;
var originalElement = elem[0];
var noEscape = true, originalElement = elem[0], callback;

@@ -35,3 +34,6 @@ // get default usage options

});
// Get the callback from item scope or global defined
callback = scope.editCallback || options.editCallback;
// add editable class

@@ -74,3 +76,3 @@ attrs.$addClass(options.editableClass);

noEscape = true;
// select all on focus

@@ -84,3 +86,3 @@ if( options.focusSelect ) {

}
// if render-html is enabled convert

@@ -92,3 +94,3 @@ // all text content to plaintext

}
});

@@ -104,11 +106,11 @@

var html;
scope.isEditing = false;
// remove active class when editing is over
attrs.$removeClass('active');
// disable editability
attrs.$set('contenteditable', 'false');
// if text needs to be rendered as html

@@ -121,3 +123,3 @@ if( options.renderHtml && noEscape ) {

elem.html(html);
} else {

@@ -127,6 +129,6 @@ // get element content replacing html tag

}
// if element value is different from model value
if( html != ngModel.$modelValue ) {
/**

@@ -138,17 +140,17 @@ * This method should be called

ngModel.$setViewValue(html);
// if user passed a variable
// and is a function
if( scope.editCallback && angular.isFunction(scope.editCallback) ) {
if( callback && angular.isFunction(callback) ) {
// run the callback with arguments: current text and element
return scope.editCallback({
return callback({
text: html,
elem: elem
});
}
}
});

@@ -155,0 +157,0 @@

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