Library tested in
textarea
)
Gets selected text.
Returns String
.
textarea
)Gets selected lines. Returns array of strings.
textarea
)
Gets length of selected text.
Returns int
.
textarea
, prefix
, suffix
, selectAll = FALSE
)
Wraps selected text.
Returns void
.
textarea
, prefix
, suffix
)
Unwraps selected text.
Returns void
.
textarea
, prefix
, suffix
, ignoreSpaces = FALSE
)
Wraps selected lines.
Returns void
.
textarea
, prefix
, suffix
, ignoreSpaces = FALSE
)
Unwraps selected lines.
Returns void
.
textarea
, text
, replaceAlways = FALSE
, selectReplacedText = TRUE
)
Replace selected text.
Returns void
.
textarea
, text
, position = undefined
, selectInsertedText = FALSE
)
Insert text at the position
(or cursor positon/end current selection for undefined
value).
Returns void
.
var myTextArea = document.getElementById('my-textarea');
var selection = new Cz.TextAreaSelection(myTextArea);
selection.getText();
selection.getLines();
selection.getLength();
selection.wrap(prefix, suffix, selectAll);
selection.unwrap(prefix, suffix);
selection.wrapLines(prefix, suffix, ignoreSpaces);
selection.unwrapLines(prefix, suffix, ignoreSpaces);
selection.replace(text, replaceAlways, selectReplacedText);
selection.insert(text, position, selectInsertedText);
selection.focus();
Require CzTextAreaSelection.js
file.
See repository czproject/selection-js on server GitHub.com.
Copyright © 2013 Jan Pecha (http://janpecha.iunas.cz/) All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.