npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@commercetools-uikit/rich-text-input

v19.15.0

Published

A controlled rich text input component for rich text with validation states.

Downloads

14,436

Readme

RichTextInput

Description

A controlled rich text input component for rich text with validation states.

Installation

yarn add @commercetools-uikit/rich-text-input
npm --save install @commercetools-uikit/rich-text-input

Additionally install the peer dependencies (if not present)

yarn add react react-dom react-intl
npm --save install react react-dom react-intl

Usage

import React from 'react';
import RichTextInput from '@commercetools-uikit/rich-text-input';

const html = '<p>hello world</p>';

const Example = (props) => {
  const [value, setValue] = React.useState(html);
  const handleChange = React.useCallback((event) => {
    setValue(event.target.value);
  }, []);
  const ref = React.useRef(null);
  const handleReset = React.useCallback(() => {
    ref.current?.resetValue('<p>after reset</p>');
  }, []);

  return (
    <>
      <button onClick={handleReset}>Reset</button>
      <RichTextInput value={value} onChange={handleChange} ref={ref} />
    </>
  );
};

export default Example;

Properties

| Props | Type | Required | Default | Description | | ---------------------------- | ----------------------------------------------------------------------------------------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------------------- | | isAutofocussed | boolean | | | Focus the control when it is mounted | | defaultExpandMultilineText | boolean | | | Expands multiline text input initially | | hasError | boolean | | | Indicates the input field has an error | | hasWarning | boolean | | | Indicates the input field has warning | | id | string | | | Used as the HTML id attribute. | | name | string | | | Used as the HTML name attribute. | | placeholder | string | ✅ | | Placeholder value to show in the input field | | isDisabled | boolean | | | Disables the rich text input | | isReadOnly | boolean | | | Indicates that the rich text input is displaying read-only content | | horizontalConstraint | unionPossible values:, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto' | | | Horizontal size limit of the input fields | | onChange | FunctionSee signature. | | | Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value. | | onFocus | FocusEventHandler | | | Called when input is focused | | onBlur | FocusEventHandler | | | Called when input is blurred | | value | string | | | Value of the input component. | | showExpandIcon | boolean | ✅ | | Indicates whether the expand icon should be visible | | onClickExpand | FunctionSee signature. | | | Called when the expand button is clicked |

Signatures

Signature onChange

(event: TChangeEvent) => void

Signature onClickExpand

() => boolean;

Static methods

RichTextInput.isEmpty

Returns true when the value is considered empty, which is when the value is empty.

RichTextInput.isEmpty(''); // -> true
RichTextInput.isEmpty('<p></p>'); // -> true
RichTextInput.isEmpty('tree'); // -> false

isTouched(touched)

Expects to be called with an array or boolean. Returns true when truthy.