{"_id":"selection-update","_rev":"9-bb69bf2fe2f97fc5927ff5b0505ea591","name":"selection-update","dist-tags":{"latest":"1.1.1"},"versions":{"0.1.0":{"name":"selection-update","version":"0.1.0","keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","_id":"selection-update@0.1.0","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"homepage":"https://github.com/nikku/selection-update","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"dist":{"shasum":"5a1dd841ffb04cf1b3f7a77ffe701121e7fbf199","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-0.1.0.tgz","integrity":"sha512-KsOvLoYzqW3/P71/FBc//2nTIiHZD4NbpCEqkeheuyzG8KziUGmSJhgFsMIpgIPmihp8dNFkHd6tNUQ5GiBXhw==","signatures":[{"sig":"MEUCIA9yYDI8Tm2IOV1k+so/xkd53ojaJUEROi5t9+Xy29XiAiEAqdGMjrioFLhELvZGD2lmi/b/shFWX6bhsV75qB7+vGs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"5a1dd841ffb04cf1b3f7a77ffe701121e7fbf199","gitHead":"da274f9db81a9325711d7044d5382290b4251c71","scripts":{"test":"mocha test.js"},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"repository":{"url":"git+ssh://git@github.com/nikku/selection-update.git","type":"git"},"_npmVersion":"2.11.3","description":"Computing selection updates on external INPUT value changes, browser style","_nodeVersion":"0.12.7","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"directories":{}},"0.1.1":{"name":"selection-update","version":"0.1.1","keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","_id":"selection-update@0.1.1","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"homepage":"https://github.com/nikku/selection-update","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"dist":{"shasum":"377dd37d2b5035bfa8eeab7e1d9290adcf6dd237","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-0.1.1.tgz","integrity":"sha512-UTytnZhakucEAFMwfEJ3vToxPan1Q/CwbMtcQMcVwM6QU5eHMDBmJucl1CFM54Uox35SewJzIif5C1n0NNtmHg==","signatures":[{"sig":"MEUCICIRAZJrVMlU4ItxkihvZPvI+fH7rwnUv2jdyoS7+1QiAiEA3FAWsfPxcUpBhMZiBuekZKBZvkwap4PY+nXBUJYGIq4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"377dd37d2b5035bfa8eeab7e1d9290adcf6dd237","gitHead":"d98182d0bb8603a7c47513c9d41c2045c5a7292b","scripts":{"test":"mocha test.js"},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"repository":{"url":"git+ssh://git@github.com/nikku/selection-update.git","type":"git"},"_npmVersion":"2.11.3","description":"Computing selection updates on external INPUT value changes, browser style","_nodeVersion":"0.12.7","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"directories":{}},"0.1.2":{"name":"selection-update","version":"0.1.2","keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","_id":"selection-update@0.1.2","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"homepage":"https://github.com/nikku/selection-update","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"dist":{"shasum":"803a044dcc6edab5a3ae648f5f0357e89ad66b96","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-0.1.2.tgz","integrity":"sha512-4jzoJNh7VT2s2tvm/kUSskSw7pD0BVcrrGccbfOMK+3AXLBPz6nIy1yo+pbXgvNoTNII96Pq92+sAY+rF0LUAA==","signatures":[{"sig":"MEUCIQDvf/qoFGGJZBg1DR1qn6nefmTmCT0klcfxndgGVeh7iAIgft9octVdXiNBXyC/9wfVT0fab8cWFlck0rJLec4EufQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"index.js","_from":".","_shasum":"803a044dcc6edab5a3ae648f5f0357e89ad66b96","gitHead":"d755daa4128ef5eae78a791312adfec5c4a2069d","scripts":{"test":"mocha test.js"},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"repository":{"url":"git+ssh://git@github.com/nikku/selection-update.git","type":"git"},"_npmVersion":"2.11.3","description":"Computing selection updates on external INPUT value changes, browser style","_nodeVersion":"0.12.7","devDependencies":{"chai":"^3.4.1","mocha":"^2.3.4"},"directories":{}},"1.0.0":{"name":"selection-update","version":"1.0.0","keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","_id":"selection-update@1.0.0","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"homepage":"https://github.com/nikku/selection-update","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"dist":{"shasum":"d918ff1a185208cd340783c211fe9c8fd1c1eb21","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-1.0.0.tgz","fileCount":4,"integrity":"sha512-RqktzXhtCgFW1FnT7M0kHJrcvF7zy4xGpPAOcUyoJrp14aT4wGrCoDW+HCGUFb+9oRyFCRyLY3OPZk7jR6Y7+Q==","signatures":[{"sig":"MEUCIQDFg8zdhYgFxUOUOiONMCLSgrWSxYFHDcXUGUVpmtWK1AIgQl4qKw8+V6PdoBFH60C4lc6RShgmhOovaHiw+aTaL+4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":6484},"main":"index.js","type":"module","exports":{".":{"import":"./index.js"},"./package.json":"./package.json"},"gitHead":"866a8b030f1e456f67f604730edd3faf19b15538","scripts":{"all":"npm run lint && npm test","lint":"eslint .","test":"mocha test.js"},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"repository":{"url":"git+ssh://git@github.com/nikku/selection-update.git","type":"git"},"_npmVersion":"11.0.0","description":"Computing selection updates on external INPUT value changes, browser style","directories":{},"_nodeVersion":"20.18.1","_hasShrinkwrap":false,"devDependencies":{"chai":"^5.1.2","mocha":"^11.0.1","eslint":"^9.18.0","eslint-plugin-bpmn-io":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/selection-update_1.0.0_1737220552871_0.8435647844011054","host":"s3://npm-registry-packages-npm-production"}},"1.1.0":{"name":"selection-update","version":"1.1.0","keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","_id":"selection-update@1.1.0","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"homepage":"https://github.com/nikku/selection-update","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"dist":{"shasum":"327f1de8008d692d5060d1b0c2a645ea26142dab","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-1.1.0.tgz","fileCount":5,"integrity":"sha512-X0Gi4/3Z4CxyJUky63iT7BhkVMwH2bCfyhwDYMKoLeio49Hw6bYfbXsXVjRr+VIX+OCHnRGLhBc3VUBphhfAVw==","signatures":[{"sig":"MEUCIDz0Q5Lm+tO8aOQZCAZgG3BiDX3EdGheGHO+LiAwdPnqAiEA21GsqLbj1iZZ6Y292VOLtC2zwC6nk+f94Shwch6wexY=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":7336},"main":"index.js","type":"module","types":"./index.d.ts","exports":{".":{"import":"./index.js"},"./package.json":"./package.json"},"gitHead":"5a076ee671c5b9f2dbcd487023dbcc0566dec222","scripts":{"all":"npm run lint && npm test","lint":"eslint .","test":"mocha test.js"},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"repository":{"url":"git+ssh://git@github.com/nikku/selection-update.git","type":"git"},"_npmVersion":"11.6.1","description":"Computing selection updates on external INPUT value changes, browser style","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.1","mocha":"^11.7.5","eslint":"^9.18.0","eslint-plugin-bpmn-io":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/selection-update_1.1.0_1765140907446_0.7333603840863994","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"selection-update","version":"1.1.1","description":"Computing selection updates on external INPUT value changes, browser style","main":"./index.js","scripts":{"all":"npm run lint && npm test","lint":"eslint .","test":"mocha test.js"},"type":"module","types":"./index.d.ts","exports":{".":"./index.js","./package.json":"./package.json"},"repository":{"type":"git","url":"git+ssh://git@github.com/nikku/selection-update.git"},"keywords":["selection","update","input","textarea","value","html","browserify"],"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","bugs":{"url":"https://github.com/nikku/selection-update/issues"},"homepage":"https://github.com/nikku/selection-update","devDependencies":{"chai":"^6.2.1","eslint":"^9.39.1","eslint-plugin-bpmn-io":"^2.2.0","mocha":"^11.7.5"},"gitHead":"cdf0b4815742eeeb6dd56d6a58d8d1e57f323993","_id":"selection-update@1.1.1","_nodeVersion":"24.11.1","_npmVersion":"11.6.2","dist":{"integrity":"sha512-sdkTSquPXiPTUUJh5KcnNoLauJqy68ctusGj7JfMo+t629f8Tv3EMx0hzTjFe8fYy7dZUzXRDAS42K/YS6Pi6Q==","shasum":"6f1245e75b455966e8e94c3faba2ee602d36c58f","tarball":"https://registry.npmjs.org/selection-update/-/selection-update-1.1.1.tgz","fileCount":5,"unpackedSize":7314,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIE1my4ZCk86rPuZYXJerf8rkC3owJrx+8vJNCOnjQvUMAiEA1/HuoTUDa57j6qvQ/Ow763/XZ7s/JAN/qatREyZvX1Y="}]},"_npmUser":{"name":"nikku","email":"git_nikku@nixis.de"},"directories":{},"maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/selection-update_1.1.1_1769021962962_0.43148098622607267"},"_hasShrinkwrap":false}},"time":{"created":"2015-12-11T08:16:56.943Z","modified":"2026-01-21T18:59:23.220Z","0.1.0":"2015-12-11T08:16:56.943Z","0.1.1":"2015-12-11T08:17:42.536Z","0.1.2":"2015-12-15T14:06:36.272Z","1.0.0":"2025-01-18T17:15:53.091Z","1.1.0":"2025-12-07T20:55:07.584Z","1.1.1":"2026-01-21T18:59:23.127Z"},"bugs":{"url":"https://github.com/nikku/selection-update/issues"},"author":{"name":"Nico Rehwaldt","email":"git_nikku@nixis.de"},"license":"MIT","homepage":"https://github.com/nikku/selection-update","keywords":["selection","update","input","textarea","value","html","browserify"],"repository":{"type":"git","url":"git+ssh://git@github.com/nikku/selection-update.git"},"description":"Computing selection updates on external INPUT value changes, browser style","maintainers":[{"name":"nikku","email":"git_nikku@nixis.de"}],"readme":"# selection-update\n\n[![CI](https://github.com/nikku/selection-update/actions/workflows/CI.yml/badge.svg)](https://github.com/nikku/selection-update/actions/workflows/CI.yml)\n\nComputing input selection updates on external content changes, as if we used browser managed _undo_ and _redo_.\n\n\n## API\n\n```javascript\n/**\n * Calculate the selection update for the given\n * current and new input values.\n *\n * @param {Object} currentSelection as {start, end}\n * @param {String} currentValue\n * @param {String} newValue\n *\n * @return {Object} newSelection as {start, end}\n */\ncalculateUpdate(currentSelection, currentValue, newValue);\n```\n\n\n## Usage\n\n```javascript\nimport { calculateUpdate } from 'selection-update';\n\n/**\n * Update input with new value.\n\n * @param {Node} $input\n * @param {String} newValue\n */\nfunction updateInput($input, newValue) {\n\n  var newSelection;\n\n  // only retrieve and restore input, if the element\n  // is currently active\n  if (document.activeElement === $input) {\n\n    // get the current selection and pass it in as {start, end}\n    newSelection = selectionUpdate(getSelection($input), $input.value, newValue);\n  }\n\n  // apply new value, will naturally send selection to input end\n  $input.value = value;\n\n  if (newSelection) {\n    // set new {start, end} selection on input\n    setSelection($input, selection);\n  }\n}\n```\n\n\n## Related\n\n* [selection-ranges](https://github.com/nikku/selection-ranges) - manipulate selection ranges on contenteditable elements\n\n\n## License\n\nMIT\n","readmeFilename":"README.md"}