Skip to content

An open source design system that's fully customizable and agent ready

TypeScript
5.6 KB
Raw Blame

API report: @astryxdesign/richtext

.

Components

component RichTextEditor(props: RichTextEditorProps)
  prop codeLanguages?: ReadonlyArray<CodeLanguage>
  prop defaultValue?: string
  prop description?: string
  prop hasAutoFocus?: boolean = false
  prop hasMarkdownShortcuts?: boolean = true
  prop isDisabled?: boolean = false
  prop isLabelHidden?: boolean = false
  prop isOptional?: boolean = false
  prop isReadOnly?: boolean = false
  prop isRequired?: boolean = false
  prop label: string
  prop labelTooltip?: string
  prop markdownExtensions?: ReadonlyArray<RichTextMarkdownExtension>
  prop maxLength?: number
  prop minHeight?: SizeValue = '4.5rem'
  prop namespace?: string = 'astryx-editor'
  prop nodes?: ReadonlyArray<Klass<LexicalNode>>
  prop onChange?: (editorState: EditorState, editor: LexicalEditor) => void
  prop placeholder?: string
  prop plugins?: ReactNode
  prop ref?: Ref<RichTextEditorRef>
  prop size?: RichTextEditorSize = 'md'
  prop status?: RichTextEditorStatus
  prop statusVariant?: FieldStatusVariant | 'tooltip' = 'attached'
  prop tabEscapeHint?: string = 'Press Escape then Tab to move focus out of the editor.', translated for the active locale
  prop toolbar?: ReactNode
  prop transformers?: ReadonlyArray<Transformer>
  prop width?: SizeValue
  inherits AriaAttributes, BaseProps, DOMAttributes, HTMLAttributes
component RichTextEditorAutoLinkPlugin(props: RichTextEditorAutoLinkPluginProps)
  prop matchers?: LinkMatcher[]
  prop onChange?: (url: string | null, prevUrl: string | null) => void
component RichTextEditorToolbar(props: RichTextEditorToolbarProps)
  prop endContent?: ReactNode
  prop hasLink?: boolean = true
  prop hasNewTabLinks?: boolean = true
  prop headingLevels?: ReadonlyArray<'h1' | 'h2' | 'h3'> = ['h1', 'h2', 'h3']
  prop label?: string = 'Text formatting', translated for the active locale
  prop promptForUrl?: (selectedText: string) => string | null | undefined
  prop ref?: Ref<HTMLDivElement>
  prop size?: 'sm' | 'md' | 'lg' = 'sm'
  inherits AriaAttributes, BaseProps, DOMAttributes, HTMLAttributes
component RichTextView(props: RichTextViewProps)
  prop codeLanguages?: ReadonlyArray<CodeLanguage>
  prop errorFallback?: ReactNode = null
  prop markdownExtensions?: ReadonlyArray<RichTextMarkdownExtension>
  prop namespace?: string = 'astryx-view'
  prop nodes?: ReadonlyArray<Klass<LexicalNode>>
  prop onParseError?: (error: Error) => void
  prop plugins?: ReactNode
  prop value: string
  inherits AriaAttributes, BaseProps, DOMAttributes, HTMLAttributes

Functions

function createRichTextExtension: (plugin: MarkdownPluginEntry) => RichTextMarkdownExtension
function editorStateJSONToMarkdown: (editorStateJSON: string, options?: MarkdownSerializerOptions) => string
function markdownToEditorStateJSON: (markdown: string, options?: MarkdownSerializerOptions) => string
function sanitizeUrl: (url: string) => string
function validateUrl: (url: string) => boolean

Classes

class RichTextExtensionError
  capability: string
  claimant: string | null
  plugin: string
  inherits Error

Values

const DEFAULT_LINK_MATCHERS: LinkMatcher[]
const NEW_TAB_LINK_ATTRIBUTES: { readonly target: "_blank"; readonly rel: "noopener noreferrer" }
const RICHTEXT_ICON_KEYS: object
  bold: 'richtext:bold'
  italic: 'richtext:italic'
  underline: 'richtext:underline'
  strikethrough: 'richtext:strikethrough'
  code: 'richtext:code'
  link: 'richtext:link'
  paragraph: 'richtext:paragraph'
  h1: 'richtext:h1'
  h2: 'richtext:h2'
  h3: 'richtext:h3'
  quote: 'richtext:quote'
  bullet: 'richtext:bullet'
  number: 'richtext:number'
  undo: 'richtext:undo'
  redo: 'richtext:redo'

Types

interface MarkdownSerializerOptions
  extensions?: ReadonlyArray<RichTextMarkdownExtension>
  nodes?: ReadonlyArray<Klass<LexicalNode>>
  transformers?: ReadonlyArray<Transformer>
interface RichTextEditorAutoLinkPluginProps (props of RichTextEditorAutoLinkPlugin)
interface RichTextEditorProps extends Omit<BaseProps, 'onChange' | 'defaultValue'> (props of RichTextEditor)
interface RichTextEditorRef
  clear: () => void
  focus: () => void
  getEditor: () => LexicalEditor
  getEditorState: () => EditorState
  getHTML: () => string
  getMarkdown: () => string
type RichTextEditorSize = 'sm' | 'md' | 'lg'
interface RichTextEditorStatus
  message?: string
  type: RichTextEditorStatusType
type RichTextEditorStatusType = 'warning' | 'error' | 'success'
interface RichTextEditorToolbarProps extends BaseProps<HTMLDivElement> (props of RichTextEditorToolbar)
interface RichTextMarkdownExtension
  [extensionPlugin]: MarkdownPluginEntry
  name: string
interface RichTextViewProps extends BaseProps (props of RichTextView)

./markdown

Also exported from an earlier entry point

MarkdownSerializerOptions (.)
RichTextExtensionError (.)
RichTextMarkdownExtension (.)
createRichTextExtension (.)
editorStateJSONToMarkdown (.)
markdownToEditorStateJSON (.)

./richtext.css

stylesheet ./dist/richtext.css

Stylesheets

var --astryx-section-padding-inline-end (./richtext.css)
var --astryx-section-padding-inline-start (./richtext.css)
var --container-padding-block-end (./richtext.css)
var --container-padding-block-start (./richtext.css)
var --container-padding-inline-end (./richtext.css)
var --container-padding-inline-start (./richtext.css)

Theme targets

target rich-text-editor (RichTextEditor) props [size, status]

Public attributes

attr data-size (theme reflection on 1 target)
attr data-status (theme reflection on 1 target)