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

text-field-edit

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

text-field-edit - npm Package Compare versions

Comparing version 3.1.9001 to 3.2.0

4

index.d.ts

@@ -9,5 +9,5 @@ /** Inserts `text` at the cursor’s position, replacing any selection, with **undo** support and by firing the `input` event. */

export declare function wrapSelection(field: HTMLTextAreaElement | HTMLInputElement, wrap: string, wrapEnd?: string): void;
declare type ReplacerCallback = (substring: string, ...args: any[]) => string;
type ReplacerCallback = (substring: string, ...args: any[]) => string;
/** Finds and replaces strings and regex in the field’s value, like `field.value = field.value.replace()` but better */
export declare function replace(field: HTMLTextAreaElement | HTMLInputElement, searchValue: string | RegExp, replacer: string | ReplacerCallback): void;
export declare function replace(field: HTMLTextAreaElement | HTMLInputElement, searchValue: string | RegExp, replacer: string | ReplacerCallback, cursor?: 'select' | 'after-replacement'): void;
export {};

@@ -52,3 +52,4 @@ // https://github.com/fregante/text-field-edit/issues/16

/** Finds and replaces strings and regex in the field’s value, like `field.value = field.value.replace()` but better */
export function replace(field, searchValue, replacer) {
export function replace(field, searchValue, replacer, cursor) {
if (cursor === void 0) { cursor = 'select'; }
/** Remembers how much each match offset should be adjusted */

@@ -68,4 +69,6 @@ var drift = 0;

insert(field, replacement);
// Select replacement. Without this, the cursor would be after the replacement
field.selectionStart = matchStart;
if (cursor === 'select') {
// Select replacement. Without this, the cursor would be after the replacement
field.selectionStart = matchStart;
}
drift += replacement.length - matchLength;

@@ -72,0 +75,0 @@ return replacement;

{
"name": "text-field-edit",
"version": "3.1.9001",
"version": "3.2.0",
"description": "Insert text in a `<textarea>` and `<input>` (including Undo in most browsers)",

@@ -54,11 +54,11 @@ "keywords": [

"devDependencies": {
"@sindresorhus/tsconfig": "^2.0.0",
"@sindresorhus/tsconfig": "^3.0.1",
"browserify": "^17.0.0",
"esmify": "^2.1.1",
"npm-run-all": "^4.1.5",
"tape": "^5.4.0",
"tape-run": "^9.0.0",
"typescript": "^4.5.4",
"xo": "^0.47.0"
"tape": "^5.6.1",
"tape-run": "^10.0.0",
"typescript": "^4.9.3",
"xo": "^0.53.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