
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
easyui-richtextarea
Advanced tools
A textarea element that handles and hands off events well.
This element enshrines the concept of being active, that is being both visible and hogging the user input. Hogging the user input means that several event handlers are registered to handle user input events when the element is activated. These handlers are then unregistered when the element is deactivated. Using it will take some of the headache out of having multiple textareas in one application because only the active rich textarea will invoke its handlers. It also provides better event handling. For example, the change handler will be invoked whenever the content or selection changes, no matter how often, rather then just, say, when the focus is lost.
Actually they are, here:
You can install EasyUI-RichTextarea with npm:
npm install easyui-richtextarea
You can also clone the repository with Git...
git clone https://github.com/djalbat/EasyUI-RichTextarea.git
...and then install the necessary modules with npm from within the project's root directory:
npm install
If you're building with Node.js the usage is as follows:
var easyuirichtextarea = require('easyui-richtextarea'),
Selection = easyuirichtextarea.Selection,
RichTextArea = easyuirichtextarea.RichTextArea; ///
To use EasyUI-RichTextarea in the browser, take the easyui-richtextarea.js file from the project's dist/ directory and put it somewhere such as a public/scripts/lib directory. Referencing this distribution file from a script element...
<script src="scripts/lib/easyui-richtextarea.js"> </script>
...will give you a global easyuirichtextarea variable which can be used directly:
var RichTextArea = easyuirichtextarea;
Alternatively, if you're using an AMD style require the usage is similar to the Node.js case, only make sure that the path to the distribution file is correct. The following script should work, assuming it lives in the the public/scripts/ directory:
var easyuirichtextarea = require('easyui-richtextarea'),
Selection = easyuirichtextarea.Selection,
RichTextArea = easyuirichtextarea.RichTextArea; ///
Automation is done with npm scripts, have a look at the package.json file. The pertinent commands are:
npm run build-debug
npm run watch-debug
Aside from the usual selector, the constructor takes four additional and optional arguments for the handlers:
var richTextarea = new RichTextarea('#richTextarea', changeHandler, scrollHandler, focusHandler, blurHandler);
function changeHandler(content, selection, contentChanged, selectionChanged) {
if (contentChanged) {
console.log('content changed')
}
if (selectionChanged) {
console.log('selection changed')
}
}
function scrollHandler(scrollTop, scrollLeft) {
console.log('scrolled')
}
function focusHandler(content, selection) {
console.log('focused')
}
function blurHandler() {
console.log('blurred')
}
Note the arguments passed to the handlers. It also has the usual clone() methods.
Activating and deactivating the element couldn't be simpler:
richTextarea.activate();
richTextarea.deactivate();
It is important to note that being active and having the focus are not the same thing for a rich textarea element. The former is a concept defined here, the latter is a native property of the underlying DOM element. This is worth mentioning because the concepts of being active and being focused are often used interchangeably elsewhere.
Also, note that the getSelection() method will always return a selection even when the underlying DOM element has none. This is because the native startPosition and endPosition properties of the DOM element, on which the getSelection() method ultimately relies, always return values regardless of the presence or otherwise of a selection. If there is no selection, they will both return zero. A textarea element does not always have a selection, however. This can occur before it receives the focus, or if the selection is cleared programmatically by way of the native removeAllRanges() method. Despite this, there currently appears to be no reliable way to discern when the underlying selection is present, and so the getSelection() method will always return a selection object.
Some good news is that the selection is unaffected by focus. Bear in mind, however, that a selection is not updated until the tick after a DOM element in question receives the focus. For this reason, the rich textarea element will defer the handing off of a 'focus' event for a tick so as to be able to provide the updated selection as one of the arguments to its focus handler.
All the activate() and deactivate() methods do is add and remove an active class from the element. If you want that element to be hidden or shown depending on whether or not it is active, which is part of the idea, you need to define this class accordingly. Look at the easyui-richtextarea.css file in the dist directory to see how this is easily done.
FAQs
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
The npm package easyui-richtextarea receives a total of 2 weekly downloads. As such, easyui-richtextarea popularity was classified as not popular.
We found that easyui-richtextarea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.