New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vanilla-caret-js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-caret-js - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

4

dist/VanillaCaret.js

@@ -54,3 +54,3 @@ (function (global, factory) {

}
if (this.isContentEditable) {
if (this.isContentEditable === 'true') {
this.target.focus();

@@ -69,3 +69,3 @@ var _range = document.getSelection().getRangeAt(0);

value: function setPos(position) {
if (this.isContentEditable) {
if (this.isContentEditable === 'true') {
if (position >= 0) {

@@ -72,0 +72,0 @@ var selection = window.getSelection();

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

!function(e,t){if("function"==typeof define&&define.amd)define("VanillaCaret",["module"],t);else if("undefined"!=typeof exports)t(module);else{var n={exports:{}};t(n),e.VanillaCaret=n.exports}}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),o=function(){function e(n){t(this,e),this.target=n,this.isContentEditable=n&&n.contentEditable}return n(e,[{key:"getPos",value:function(){if(document.activeElement!==this.target)return-1;if(this.isContentEditable){this.target.focus();var e=document.getSelection().getRangeAt(0),t=e.cloneRange();return t.selectNodeContents(this.target),t.setEnd(e.endContainer,e.endOffset),t.toString().length}return this.target.selectionStart}},{key:"setPos",value:function(e){if(this.isContentEditable){if(e>=0){var t=window.getSelection(),n=this.createRange(this.target,{count:e});n&&(n.collapse(!1),t.removeAllRanges(),t.addRange(n))}}else this.target.setSelectionRange(e,e)}},{key:"createRange",value:function(e,t,n){if(n||((n=document.createRange()).selectNode(e),n.setStart(e,0)),0===t.count)n.setEnd(e,t.count);else if(e&&t.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length<t.count?t.count-=e.textContent.length:(n.setEnd(e,t.count),t.count=0);else for(var o=0;o<e.childNodes.length&&(n=this.createRange(e.childNodes[o],t,n),0!==t.count);o++);return n}}]),e}();e.exports=o});
!function(e,t){if("function"==typeof define&&define.amd)define("VanillaCaret",["module"],t);else if("undefined"!=typeof exports)t(module);else{var n={exports:{}};t(n),e.VanillaCaret=n.exports}}(this,function(e){"use strict";function t(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),o=function(){function e(n){t(this,e),this.target=n,this.isContentEditable=n&&n.contentEditable}return n(e,[{key:"getPos",value:function(){if(document.activeElement!==this.target)return-1;if("true"===this.isContentEditable){this.target.focus();var e=document.getSelection().getRangeAt(0),t=e.cloneRange();return t.selectNodeContents(this.target),t.setEnd(e.endContainer,e.endOffset),t.toString().length}return this.target.selectionStart}},{key:"setPos",value:function(e){if("true"===this.isContentEditable){if(e>=0){var t=window.getSelection(),n=this.createRange(this.target,{count:e});n&&(n.collapse(!1),t.removeAllRanges(),t.addRange(n))}}else this.target.setSelectionRange(e,e)}},{key:"createRange",value:function(e,t,n){if(n||((n=document.createRange()).selectNode(e),n.setStart(e,0)),0===t.count)n.setEnd(e,t.count);else if(e&&t.count>0)if(e.nodeType===Node.TEXT_NODE)e.textContent.length<t.count?t.count-=e.textContent.length:(n.setEnd(e,t.count),t.count=0);else for(var o=0;o<e.childNodes.length&&(n=this.createRange(e.childNodes[o],t,n),0!==t.count);o++);return n}}]),e}();e.exports=o});
{
"name": "vanilla-caret-js",
"version": "1.0.1",
"version": "1.1.0",
"description": "Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript",

@@ -40,3 +40,3 @@ "main": "index.js",

"gh-pages-deploy": "^0.5.1",
"karma": "^1.7.1",
"karma": "^6.3.14",
"karma-babel-preprocessor": "^7.0.0",

@@ -50,3 +50,3 @@ "karma-chrome-launcher": "^2.2.0",

"rollup": "^0.50.0",
"serve": "^7.1.3",
"serve": "^10.1.2",
"sinon": "^4.0.1",

@@ -53,0 +53,0 @@ "sinon-chai": "^2.14.0",

Set and get Caret position (contenteditable or TextArea) using Vanilla JavaScript
====================
[![NPM version][npm-version-image]][npm-url]
[![NPM size][npm-size-image]][npm-url]
[![Build Status][travis-image]][travis-url]
[![Donate][donate-image]][paypal-link]
[![MIT License][license-image]][license-url]
# Demo
[![Demo](https://media.giphy.com/media/fndxOJjHJMvZqWEJBT/giphy.gif)](http://abhas9.github.io/vanilla-caret-js)
# Setup

@@ -55,1 +62,10 @@ ```shell

[npm-url]: https://www.npmjs.com/package/vanilla-caret-js
[npm-version-image]: http://img.shields.io/npm/v/vanilla-caret-js.svg?style=flat-square
[npm-size-image]: https://img.shields.io/bundlephobia/min/vanilla-caret-js.svg?style=flat-square
[travis-url]:https://travis-ci.org/abhas9/vanilla-caret-js
[travis-image]: https://api.travis-ci.org/abhas9/vanilla-caret-js.svg?branch=master&style=flat-square
export default class VanillaCaret {
/**
* get/set caret position
* @param {HTMLColletion} target
* @param {HTMLColletion} target
*/

@@ -20,3 +20,3 @@ constructor(target) {

}
if (this.isContentEditable) {
if (this.isContentEditable === 'true') {
this.target.focus()

@@ -38,3 +38,3 @@ let _range = document.getSelection().getRangeAt(0)

setPos(position) {
if (this.isContentEditable) {
if (this.isContentEditable === 'true') {
if (position >= 0) {

@@ -83,2 +83,2 @@ var selection = window.getSelection()

}
}
}

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