Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@commercetools-uikit/rich-text-input

Package Overview
Dependencies
Maintainers
0
Versions
1034
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@commercetools-uikit/rich-text-input

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

  • 19.16.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.6K
increased by31.63%
Maintainers
0
Weekly downloads
 
Created
Source

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

PropsTypeRequiredDefaultDescription
isAutofocussedbooleanFocus the control when it is mounted
defaultExpandMultilineTextbooleanExpands multiline text input initially
hasErrorbooleanIndicates the input field has an error
hasWarningbooleanIndicates the input field has warning
idstringUsed as the HTML id attribute.
namestringUsed as the HTML name attribute.
placeholderstringPlaceholder value to show in the input field
isDisabledbooleanDisables the rich text input
isReadOnlybooleanIndicates that the rich text input is displaying read-only content
horizontalConstraintunion
Possible values:
, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 'scale', 'auto'
Horizontal size limit of the input fields
onChangeFunction
See signature.
Called with an event containing the new value. Required when input is not read only. Parent should pass it back as value.
onFocusFocusEventHandlerCalled when input is focused
onBlurFocusEventHandlerCalled when input is blurred
valuestringValue of the input component.
showExpandIconbooleanIndicates whether the expand icon should be visible
onClickExpandFunction
See 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.

Keywords

FAQs

Package last updated on 14 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc