0.3.9 • Published 2 years ago

verbum-refined v0.3.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Verbum Refined : Stable version - Not maintained 0.3.5

Refer to official repository for latest version

Verbum Refined - Flexible Text Editor for React

Verbum is a fully flexible rich text editor based on lexical-playground and lexical framework.

⚠️ As the Lexical framework is currently in early development, this component library is also likely to change quite often

Installation

npm install verbum-refined --save

Demo

Demo Live demo is coming soon...

Usage

import { FC } from 'react';
import {
  EditorComposer,
  Editor,
  ToolbarPlugin,
  AlignDropdown,
  BackgroundColorPicker,
  BoldButton,
  CodeFormatButton,
  FloatingLinkEditor,
  FontFamilyDropdown,
  FontSizeDropdown,
  InsertDropdown,
  InsertLinkButton,
  ItalicButton,
  TextColorPicker,
  TextFormatDropdown,
  UnderlineButton,
  Divider,
} from 'verbum';

const NoteViewer: FC = () => {
  return (
    <EditorComposer>
      <Editor hashtagsEnabled={true}>
        <ToolbarPlugin defaultFontSize="20px">
          <FontFamilyDropdown />
          <FontSizeDropdown />
          <Divider />
          <BoldButton />
          <ItalicButton />
          <UnderlineButton />
          <CodeFormatButton />
          <InsertLinkButton />
          <TextColorPicker />
          <BackgroundColorPicker />
          <TextFormatDropdown />
          <Divider />
          <InsertDropdown enablePoll={true} />
          <Divider />
          <AlignDropdown />
        </ToolbarPlugin>
      </Editor>
    </EditorComposer>
  );
};

export default NoteViewer;

API

<Editor />

PropertyTypedescription
childrenReactNodeoptionalNested child components, like the ToolbarPlugin
hashtagsEnabledbooleanoptionalEnables the automatic hashtag highlighting, default is false
autoLinkEnabledbooleanoptionalEnables the automatic link highlighting, default is false
emojisEnabledbooleanoptionalReplaces the emoji combiniations with its corresponding symbol, default is false
actionsEnabledbooleanoptionalEnables the actions toolbar, default is false
placeholderstringoptionalThe default content of the editor when it is first loaded
listMaxIndentnumberoptionalThe maximum indent capacity of any listed element, the default is 7
isReadOnlybooleanoptionalEnables read-only mode for the editor, default is false
initialEditorStatestringoptionalJSON string to initialize the initial content of the editor.
onChange(editorState: string, editorInstance?: LexicalEditor) => voidoptionalAccessing the current editor state and the active editor instance
localeen | fr | nulloptionalEnables localization in the language of your choice, default is en. Available languages are en and fr

Automatic browser language detection Support

Verbum supports automatic browser language detection by default if locale not provided. If the browser language is set to fr, the editor will be automatically localized in French. If the browser language is set to en, the editor will be automatically localized in English. If the browser language is set to any other language, the editor will be automatically localized in English.

<ToolbarPlugin />

PropertyTypedescription
childrenReact.ReactElement[]optionalNested child components, like the InsertDropdown
defaultFontSizestringoptionalThe default font size selected when the editor first loaded, default value is 15px
defaultFontColorstringoptionalThe default font color selected when the editor first loaded, default value is #000
defaultBgColorstringoptionalThe default text background color selected when the editor first loaded, default value is #fff
defaultFontFamilystringoptionalThe default font family selected when the editor first loaded, default value is Arial

<InsertDropdown />

PropertyTypedescription
enableTablebooleanoptionalEnables table inserting feature
enableYoutubebooleanoptionalEnables youtube video inserting feature
enableTwitterbooleanoptionalEnables tweet inserting feature
enablePollbooleanoptionalEnables poll inserting feature
enableImagebooleanoptionalEnables image inserting feature
enableEquationsbooleanoptionalEnables equation inserting feature
enableExcalidrawbooleanoptionalEnables diagram inserting feature
enableHorizontalRulebooleanoptionalEnables the horizontal rule inserting for layout
enableStickyNotebooleanoptionalEnables stick note inserting for layout

Development

For development use:

$ npm install (in case of an error, run `npm install --legacy-peer-deps`)
$ npm start
$ npm run storybook

Future plans

  • Test coverage
  • Programmatic access to the editor input as JSON
  • Localization in more languages
  • Ready templates with different options (MUI, Bootstrap, etc...)
  • Dark/Light modes
  • Custom styling flexibility
  • Disassembling all of the toolbar to enable using them as nested components, increasing the flexibility
  • Enabling adjusting editor settings such read-only mode and etc. programmatically

License

Licensed under MIT License.