0.3.0 • Published 6 years ago

undate v0.3.0

Weekly downloads
5,822
License
MIT
Repository
github
Last release
6 years ago

undate

Undoable update for HTMLTextAreaElement

NPM version Build Status Code Climate

Install

npm install --save undate

Usage

import {update, wrapCursor} from 'undate';

const textareaElement = document.getElementById('textarea');

textareaElement.value; //=> ''

// Update whole value
update(textareaElement, 'string before cursor', 'optional string after cursor');

textareaElement.value; //=> 'string before cursoroptional string after cursor'

// Update around the cursor
wrapCursor(textareaElement, ' _', '_ ');

textareaElement.value; //=> 'string before cursor __ optional string after cursor'

// Press cmd-z

textareaElement.value; //=> 'string before cursoroptional string after cursor'

textareaElement.setSelectionRange(14, 27);

textareaElement.value; //=> 'string before cursoroptional string after cursor'
                       //                  ^^^^^^^^^^^^^^ selected

wrapCursor(textareaElement, '**', '**');

textareaElement.value; //=> 'string before **cursoroptional** string after cursor'
                       //                    ^^^^^^^^^^^^^^ selected

// Press cmd-z

textareaElement.value; //=> 'string before cursoroptional string after cursor'
                       //                  ^^^^^^^^^^^^^^ selected

// Press cmd-z

textareaElement.value; //=> ''

License

The MIT License

0.3.0

6 years ago

0.2.4

6 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago