2.3.1 • Published 6 months ago

@webkom/lego-editor v2.3.1

Weekly downloads
23
License
MIT
Repository
github
Last release
6 months ago

lego-editor

Build Status npm (scoped) Dependabot Dependencies

Editor made for lego-webapp written with Slate.js

Installation

  • Add the package
    $ yarn add @webkom/lego-editor
  • Import the component in your project

    import Editor from '@webkom/lego-editor'
    // Add the stylesheet
    import '@webkom/lego-editor/dist/style.css'
    // Also add the stylesheet from react-image-crop
    import 'react-image-crop/dist/ReactCrop.css'
    
    const YourComponent = () => (
      <div>
        <Editor placeholder="Let the words flow!"/>
      </div>
    )

Extending the editor

Lego-editor uses Slate.js version 0.81. You can therefore add any plugins as described in this version of Slate. The <Editor /> component accepts the prop plugins, which takes an array of plugins (plugins: (Editor => Editor)[]).

Props

nameTypeDefaultDescription
valuestringThe editors value/default value
disabledBooleanFalseDisables the ability to edit the content
simpleBooleanFalseRemoves the toolbar.
onChangestring => voidHandler called when the editor value changes. Takes the serialized value
onBlurevent => voidHandler called on blur
onFocusevent => voidHandler called on focus
autoFocusBooleanFalseEnables autoFocus
placeholderstringA placeholder shown when the editor is empty
imageUploadBlob => Promise<Record<string,any>>A function for uploading images. Should contain src in the promise object.
plugins(Editor => Editor)[]An array of plugins to load. The first plugin will be applied first (the last one will override any other plugins)
domParserstring => HTMLDocumentCustom function that the deserializer will use to parse the input value to a HTML document. Can be useful for environments where the browser API is not available, like Node.js

See type definitions for more detailed types

Example app

To test out the editor using the development application:

$ yarn dev

Development

Installing dependencies

$ yarn

Building the module

$ yarn build

Linting & formatting

To run the linter & check formatting

$ yarn lint

Formatting with prettier

$ yarn prettier
2.3.0

6 months ago

2.3.1

6 months ago

2.0.3

2 years ago

2.2.0

1 year ago

2.0.2

2 years ago

2.1.0

1 year ago

2.0.1

2 years ago

2.0.0

2 years ago

1.3.4

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.1

5 years ago