1.1.3 โ€ข Published 5 months ago

@maestrooo/rich-text-field v1.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Polaris Rich Text Field

The RichTextField component provides a streamlined way to edit Shopify rich text metafields within your embedded app.

โš ๏ธ This is not a general-purpose rich text editor. It is specifically designed for editing Shopify metafields of type rich_text_field, not for generating arbitrary HTML.

๐Ÿšซ This component relies on the Shopify App Bridge modal and can only be used inside an embedded Shopify app that uses App Bridge v4.


๐Ÿ“ฆ Installation

npm i @maestrooo/rich-text-field

This library uses Slate under the hood (which is the same library that Shopify uses for their own rich text field editor, ensuring we get a consistent experience).


๐Ÿ› ๏ธ Usage

Import the component and use it in your app:

import { RichTextField } from "@maestrooo/rich-text-field";

export default function MyComponent() {
  return (
    <RichTextField 
      value={metafield.jsonValue} 
      onChange={(newValue) => doSomething(newValue)} 
    />
  );
}

๐Ÿงพ Props

PropTypeRequiredDescription
valueobject \| string \| nullโœ…The current metafield value. Use metafield.jsonValue, not a stringified value.
onChange(value: object \| string) => voidโœ…Callback triggered whenever the content changes. Returns a JSON object or an empty string.
toolbarOptionsArray<'formatting' \| 'bold' \| 'italic' \| 'link' \| 'ordered-list' \| 'unordered-list'>โŒControls which tools are available in the toolbar.
labelstringโŒOptional label for the field.
helpTextstringโŒOptional help text displayed below the field.
placeholderstringโŒPlaceholder text shown when the field is empty.
errorstringโŒOptional error message displayed below the field.

โš ๏ธ Notes

  • Ensure you pass the parsed JSON object (or ""/null), not the raw string value of the metafield.
  • We recommend using metafield.jsonValue as the input.
  • The onChange callback returns either the updated JSON structure or an empty string when the content is cleared.
1.1.3

5 months ago

1.1.2

5 months ago

1.1.1

5 months ago

1.1.0

5 months ago

1.0.8

5 months ago

1.0.7

5 months ago

1.0.6

5 months ago

1.0.5

5 months ago

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago