highlight-within-textarea

WebJar for highlight-within-textarea

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

highlight-within-textarea
Last Version

Last Version

2.0.4
Release Date

Release Date

Type

Type

jar
Description

Description

highlight-within-textarea
WebJar for highlight-within-textarea
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/lonekorean/highlight-within-textarea

Download highlight-within-textarea

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/highlight-within-textarea/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>highlight-within-textarea</artifactId>
    <version>2.0.4</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/highlight-within-textarea/
implementation 'org.webjars.npm:highlight-within-textarea:2.0.4'
// https://jarcasting.com/artifacts/org.webjars.npm/highlight-within-textarea/
implementation ("org.webjars.npm:highlight-within-textarea:2.0.4")
'org.webjars.npm:highlight-within-textarea:jar:2.0.4'
<dependency org="org.webjars.npm" name="highlight-within-textarea" rev="2.0.4">
  <artifact name="highlight-within-textarea" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='highlight-within-textarea', version='2.0.4')
)
libraryDependencies += "org.webjars.npm" % "highlight-within-textarea" % "2.0.4"
[org.webjars.npm/highlight-within-textarea "2.0.4"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

highlight-within-textarea

jQuery plugin for highlighting bits of text within a textarea.

Introduction

It's not actually possible to style text in a textarea, because any markup within a textarea is treated as literal text. This plugin aims to fake it, allowing you to highlight pieces of text inside a textarea.

A native textarea element is used and familiar behavior (auto-correct, scrolling, resizing, etc.) works as expected.

Usage

To start, call highlightWithinTextarea() on a textarea, passing in a config object.

$('.my-textarea').highlightWithinTextarea({
    highlight: whatever // string, regexp, array, function, or custom object
});

The highlight property accepts several different types of values to describe what will be highlighted. You can see the various ways to highlight things, along with example code, on the demo page.

Styling

For reference, the demo page has some sample styling (view source to see the CSS).

There are some guidelines for getting your styles in the right places. Here are the classes you'll want to use.

.hwt-container

Use for visibility, positioning, and background.

  • display
  • position
  • top
  • left
  • margin
  • background

.hwt-content

Use for sizing and text formatting.

  • width
  • height
  • padding
  • border
  • color
  • font

.hwt-content mark

Use for highlighted text. Generally, stuff that doesn't change size is fine.

  • background-color
  • border-radius
  • box-shadow

Changes to color won't be visible, since text in the textarea covers colored text in the highlights.

Updating

Highlighting will automatically be updated as the user edits the contents of the textarea. But sometimes other scripts may directly change the contents of the textarea. In these cases, you can manually trigger a highlighting update.

$('.my-textarea').highlightWithinTextarea('update');

Destroying

You can remove the plugin from a textarea with this.

$('.my-textarea').highlightWithinTextarea('destroy');

Versions

Version
2.0.4