0.37.0 • Published 2 days ago

@prezly/content-renderer-react-js v0.37.0

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

Prezly Content Renderer for React.js

Render Prezly Content Format documents used at Prezly.

Version License

Installation

npm

npm install --save @prezly/content-renderer-react-js

peerDependencies

Make sure all peer dependencies are met (react, react-dom).

npm install --save react react-dom
npm install --save-dev @types/react @types/react-dom

object-fit-images polyfill

If you need to support older browsers, you can use this polyfill for object-fit: https://github.com/fregante/object-fit-images. This package already includes necessary syntax to work with the polyfill - all you have to do is include the polyfill.

<script src="//cdnjs.cloudflare.com/ajax/libs/object-fit-images/3.2.4/ofi.min.js"></script>
<script>
    objectFitImages();
</script>

Usage

import { DocumentNode, HeadingNode } from '@prezly/story-content-format';
import { Renderer, Component } from '@prezly/slate-renderer';

const documentNode: DocumentNode = {
    type: DocumentNode.TYPE,
    version: '0.50',
    children: [
        {
            type: HeadingNode.Type.HEADING_ONE,
            children: [{ text: 'Hello world!' }],
        },
    ],
};

export function Content() {
    return <Renderer nodes={documentNode} />;
}

// You can also override default renders by
// declaring custom renderers as children `<Component>` elements
export function ContentWithCustomHeadings() {
    return (
        <Renderer nodes={documentNode}>
            <Component
                match={isHeadingNode}
                component={({ children, node }) => <div style={{ color: 'red' }}>{children}</div>}
            />
        </Renderer>
    );
}

Development

There is a sandbox app in this repository with Hot Module Replacement. It will automatically include updates of any code changes you make locally. To start it, simply run npm run start:

npm install
npm run start

Loki

We use Loki visual testing library for storybook. There are several commands that you can use from package.json:

  1. loki - checks that your current stories are matched with what you already have (Storybook server should run)
  2. loki:update - Regenerate all snapshots despite what you already have (Storybook server should run)
  3. loki:static-build - Performs checks like loki does, but over builded sources from storybook, no need to run Storybook server

If Loki fails on CI you can download generated images like here


Brought to you by Prezly.

0.37.0

2 days ago

0.36.2

25 days ago

0.36.1

1 month ago

0.36.0

1 month ago

0.36.0-0

1 month ago

0.35.0

2 months ago

0.34.4

2 months ago

0.34.3

2 months ago

0.34.2

3 months ago

0.34.1

6 months ago

0.34.0

6 months ago

0.32.1

9 months ago

0.32.0

9 months ago

0.30.1

9 months ago

0.30.0

9 months ago

0.33.0-1

8 months ago

0.33.0-0

8 months ago

0.29.2

10 months ago

0.29.1

10 months ago

0.33.0

8 months ago

0.31.0

9 months ago

0.29.0

11 months ago

0.27.2

12 months ago

0.27.1

12 months ago

0.27.0

12 months ago

0.27.4

12 months ago

0.27.3

12 months ago

0.28.1

11 months ago

0.28.0

11 months ago

0.26.2

1 year ago

0.29.0-0

11 months ago

0.28.3

11 months ago

0.28.2

11 months ago

0.26.1

1 year ago

0.26.0

1 year ago

0.24.4-0

2 years ago

0.25.0

1 year ago

0.24.3-0

2 years ago

0.24.3-1

2 years ago

0.24.5

1 year ago

0.24.4

1 year ago

0.24.3

2 years ago

0.24.2

2 years ago

0.24.1

2 years ago

0.22.6

2 years ago

0.22.5

2 years ago

0.24.0

2 years ago

0.23.0

2 years ago

0.22.4

2 years ago

0.22.3

2 years ago

0.22.2

2 years ago

0.21.3

2 years ago

0.22.1

2 years ago

0.21.2

2 years ago

0.22.0

2 years ago

0.21.0

2 years ago

0.20.0

2 years ago

0.19.0

2 years ago

0.19.1

2 years ago

0.21.1

2 years ago

0.17.2

2 years ago

0.15.0

2 years ago

0.16.0

2 years ago

0.17.0

2 years ago

0.18.0

2 years ago

0.17.1

2 years ago

0.14.0

2 years ago

0.11.0

2 years ago

0.10.1

2 years ago

0.12.0

2 years ago

0.11.1

2 years ago

0.10.2

2 years ago

0.13.0

2 years ago

0.10.3

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.6.3

2 years ago

0.8.0

2 years ago

0.6.2

2 years ago

0.6.4

2 years ago

0.7.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.4

2 years ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago