@webiny/react-rich-text-lexical-renderer 5.44.1-beta.1 β†’ 5.45.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,170 +1,11 @@
1
1
  # @webiny/react-rich-text-lexical-renderer
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/react-rich-textlexical-renderer.svg)](https://www.npmjs.com/package/@webiny/react-rich-text-lexical-renderer)
4
- [![](https://img.shields.io/npm/v/@webiny/react-rich-text-lexical-renderer.svg)](https://www.npmjs.com/package/@webiny/react-rich-text-lexical-renderer)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
3
+ > [!NOTE]
4
+ > This package is part of the [Webiny](https://www.webiny.com) monorepo.
5
+ > It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
7
6
 
8
- A React component to render lexical editor data coming from Webiny Headless CMS and Webiny Form Builder.
7
+ πŸ“˜ **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
9
8
 
10
- ## About
11
-
12
- Webiny uses Lexical editor https://lexical.dev/ as a go to Rich Text Editor, with some additional plugins. To speed up
13
- the rendering of data for developers, we created this component.
14
-
15
- ## Install
16
-
17
- ```
18
- npm install --save @webiny/react-rich-text-lexical-renderer
19
- ```
20
-
21
- Or if you prefer yarn:
22
-
23
- ```
24
- yarn add @webiny/react-rich-text-lexical-renderer
25
- ```
26
-
27
- ## Usage
28
-
29
- Fetch your data from Headless CMS, then pass it to the component like this:
30
-
31
- ```tsx
32
- import {RichTextRenderer} from "@webiny/react-rich-text-renderer";
33
-
34
- // Load content from Headless CMS (here we show what your content might look like).
35
- const content = {
36
- root: {
37
- children: [
38
- {
39
- children: [
40
- {
41
- detail: 0,
42
- format: 0,
43
- mode: "normal",
44
- style: "",
45
- text: "A well written paragraph of text can bring so much joy!",
46
- type: "text",
47
- version: 1
48
- }
49
- ],
50
- direction: "ltr",
51
- styles: [],
52
- format: "",
53
- indent: 0,
54
- tag: "p",
55
- type: "paragraph-element",
56
- version: 1
57
- }
58
- ],
59
- direction: "ltr",
60
- format: "",
61
- indent: 0,
62
- type: "root",
63
- version: 1
64
- }
65
- }
66
-
67
- // Mount the component
68
- <RichTextLexicalRenderer value={content}/>;
69
- ```
70
-
71
- ## Adding your custom lexical nodes for rendering
72
-
73
- You can add custom lexical nodes for rendering your content:
74
-
75
- ```tsx
76
-
77
- class MyCustomNode extends LexicalNode {
78
- ...
79
- }
80
-
81
- // Mount the component
82
- <RichTextLexicalRenderer value={content} nodes={[MyCustomNode]}/>;
83
- ```
84
-
85
- ## Adding your custom typography theme.
86
-
87
- You can override Webiny default typography theme that is used by lexical editor by providing your custom typography
88
- object.
89
-
90
- Please [ read our docs ](https://www.webiny.com/docs/page-builder/theming/theme-object) and check
91
- our [theme object on GitHub](hhttps://github.com/webiny/webiny-js/blob/v5.35.0/packages/cwp-template-aws/template/common/apps/theme/theme.ts)
92
- before add you custom theme.
93
-
94
- ```tsx
95
-
96
- const myTheme = {
97
- styles: {
98
- typography: {
99
- headings: [
100
- {
101
- id: "custom_heading1",
102
- name: "Custom Heading 1",
103
- tag: "h1",
104
- styles: {...headings, fontWeight: "bold", fontSize: 48}
105
- }]
106
- }
107
- }
108
- }
109
-
110
- // Mount the component
111
- <RichTextLexicalRenderer value={content} theme={myTheme} nodes={[MyCustomNode]}/>;
112
- ```
113
-
114
- ## Resolve the mismatch of the versions in the React v18 application
115
-
116
- When you try to use `RichTextLexicalRenderer` component in React `v18` application you will see this error on the
117
- screen:
118
-
119
- ![React application error for mismatch of the React versions](./images/react-renderer-versisons-conflict-error.png)
120
-
121
- This is because our `@webiny/react-rich-text-lexical-renderer` package and the React application have
122
- different versions of React. Our rich text renderer component is using `v17.0.2`, and the React application is
123
- using `v18.x.x`.
124
-
125
- > You can check which React versions are requested by various dependencies by running the following command:
126
- > - `yarn why react` for `yarn` users.
127
- > - `npm ls react` for `npm` users.
128
-
129
- To resolve this problem, we need to force all dependencies to use the same version of React.
130
-
131
- ### Instructions for `yarn` users
132
-
133
- To force `yarn` to resolve dependencies across the project to the exact versions we're looking for, use
134
- the `resolutions` field in the root `package.json` file.
135
-
136
- ```json package.json
137
- {
138
- ...
139
- "resolutions": {
140
- "react": "18.x.x"
141
- },
142
- ...
143
- }
144
- ```
145
-
146
- Once the `resolutions` field is defined, run `yarn` to apply the new config.
147
-
148
- To learn more about the `resolutions` field, please check
149
- this [yarn documentation article](https://classic.yarnpkg.com/lang/en/docs/selective-version-resolutions/).
150
-
151
- ### Instructions for `npm` users
152
-
153
- The `npm` supports the same functionality as `yarn` with the `overrides` field name. You need to add `overrides`
154
- field in `package.json` file.
155
-
156
- ```json package.json
157
- {
158
- ...
159
- "overrides": {
160
- "react": "^18.x.x"
161
- },
162
- ...
163
- }
164
- ```
165
-
166
- Once the `overrides` field is defined, run `npm install` to apply the new config.
167
-
168
- To learn more about the `overrides` field, please check
169
- this [npm documentation article](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#overrides).
9
+ ---
170
10
 
11
+ _This README file is automatically generated during the publish process._
package/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
- import type { LexicalNode, LexicalValue, Klass } from "@webiny/lexical-editor/types";
2
+ import type { Klass, LexicalNode, LexicalValue } from "@webiny/lexical-editor/types.js";
3
3
  import type { EditorTheme } from "@webiny/lexical-theme";
4
4
  type RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;
5
5
  interface RichTextLexicalRenderer {
6
6
  value: RendererLexicalValue;
7
- theme?: Partial<EditorTheme>;
7
+ theme: EditorTheme;
8
8
  nodes?: Klass<LexicalNode>[];
9
9
  }
10
10
  export declare const RichTextLexicalRenderer: (props: RichTextLexicalRenderer) => React.JSX.Element;
package/index.js CHANGED
@@ -1,39 +1,20 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.RichTextLexicalRenderer = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _react = _interopRequireWildcard(require("react"));
11
- var _appTheme = require("@webiny/app-theme");
12
- var _lexicalEditor = require("@webiny/lexical-editor");
13
- var defaultTheme = {
14
- styles: {},
15
- emotionMap: {}
16
- };
17
- var LexicalRenderer = function LexicalRenderer(props) {
18
- var _useTheme = (0, _appTheme.useTheme)(),
19
- theme = _useTheme.theme;
20
- var getValue = function getValue(value) {
1
+ import React from "react";
2
+ import { LexicalHtmlRenderer } from "@webiny/lexical-editor";
3
+ const LexicalRenderer = props => {
4
+ const getValue = value => {
21
5
  if (!value) {
22
6
  return null;
23
7
  }
24
8
  return typeof props?.value === "string" ? props.value : JSON.stringify(props.value);
25
9
  };
26
- var rendererTheme = (0, _react.useMemo)(function () {
27
- return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props?.theme), theme);
28
- }, [props?.theme, theme]);
29
- return /*#__PURE__*/_react.default.createElement(_lexicalEditor.LexicalHtmlRenderer, {
10
+ return /*#__PURE__*/React.createElement(LexicalHtmlRenderer, {
30
11
  value: getValue(props?.value),
31
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, defaultTheme), rendererTheme),
12
+ theme: props.theme,
32
13
  nodes: props.nodes
33
14
  });
34
15
  };
35
- var RichTextLexicalRenderer = exports.RichTextLexicalRenderer = function RichTextLexicalRenderer(props) {
36
- return /*#__PURE__*/_react.default.createElement(_appTheme.ThemeProvider, null, /*#__PURE__*/_react.default.createElement(LexicalRenderer, props));
16
+ export const RichTextLexicalRenderer = props => {
17
+ return /*#__PURE__*/React.createElement(LexicalRenderer, props);
37
18
  };
38
19
 
39
20
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_appTheme","_lexicalEditor","defaultTheme","styles","emotionMap","LexicalRenderer","props","_useTheme","useTheme","theme","getValue","value","JSON","stringify","rendererTheme","useMemo","_objectSpread2","default","createElement","LexicalHtmlRenderer","nodes","RichTextLexicalRenderer","exports","ThemeProvider"],"sources":["index.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { ThemeProvider, useTheme } from \"@webiny/app-theme\";\nimport type { LexicalNode, LexicalValue, Klass } from \"@webiny/lexical-editor/types\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { LexicalHtmlRenderer } from \"@webiny/lexical-editor\";\n\ntype RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;\n\ninterface RichTextLexicalRenderer {\n value: RendererLexicalValue;\n theme?: Partial<EditorTheme>;\n nodes?: Klass<LexicalNode>[];\n}\n\nconst defaultTheme: EditorTheme = {\n styles: {},\n emotionMap: {}\n};\n\nconst LexicalRenderer = (props: RichTextLexicalRenderer) => {\n const { theme } = useTheme();\n\n const getValue = (value: RendererLexicalValue): string | null => {\n if (!value) {\n return null;\n }\n return typeof props?.value === \"string\" ? props.value : JSON.stringify(props.value);\n };\n\n const rendererTheme = useMemo(() => {\n return { ...props?.theme, ...theme };\n }, [props?.theme, theme]);\n\n return (\n <LexicalHtmlRenderer\n value={getValue(props?.value)}\n theme={{ ...defaultTheme, ...rendererTheme }}\n nodes={props.nodes}\n />\n );\n};\n\nexport const RichTextLexicalRenderer = (props: RichTextLexicalRenderer) => {\n return (\n <ThemeProvider>\n <LexicalRenderer {...props} />\n </ThemeProvider>\n );\n};\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAGA,IAAAE,cAAA,GAAAF,OAAA;AAUA,IAAMG,YAAyB,GAAG;EAC9BC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B,CAAC;AAExB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","LexicalHtmlRenderer","LexicalRenderer","props","getValue","value","JSON","stringify","createElement","theme","nodes","RichTextLexicalRenderer"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport type { Klass, LexicalNode, LexicalValue } from \"@webiny/lexical-editor/types.js\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport { LexicalHtmlRenderer } from \"@webiny/lexical-editor\";\n\ntype RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;\n\ninterface RichTextLexicalRenderer {\n value: RendererLexicalValue;\n theme: EditorTheme;\n nodes?: Klass<LexicalNode>[];\n}\n\nconst LexicalRenderer = (props: RichTextLexicalRenderer) => {\n const getValue = (value: RendererLexicalValue): string | null => {\n if (!value) {\n return null;\n }\n return typeof props?.value === \"string\" ? props.value : JSON.stringify(props.value);\n };\n\n return (\n <LexicalHtmlRenderer\n value={getValue(props?.value)}\n theme={props.theme}\n nodes={props.nodes}\n />\n );\n};\n\nexport const RichTextLexicalRenderer = (props: RichTextLexicalRenderer) => {\n return <LexicalRenderer {...props} />;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAGzB,SAASC,mBAAmB,QAAQ,wBAAwB;AAU5D,MAAMC,eAAe,GAAIC,KAA8B,IAAK;EACxD,MAAMC,QAAQ,GAAIC,KAA2B,IAAoB;IAC7D,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAO,OAAOF,KAAK,EAAEE,KAAK,KAAK,QAAQ,GAAGF,KAAK,CAACE,KAAK,GAAGC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACE,KAAK,CAAC;EACvF,CAAC;EAED,oBACIL,KAAA,CAAAQ,aAAA,CAACP,mBAAmB;IAChBI,KAAK,EAAED,QAAQ,CAACD,KAAK,EAAEE,KAAK,CAAE;IAC9BI,KAAK,EAAEN,KAAK,CAACM,KAAM;IACnBC,KAAK,EAAEP,KAAK,CAACO;EAAM,CACtB,CAAC;AAEV,CAAC;AAED,OAAO,MAAMC,uBAAuB,GAAIR,KAA8B,IAAK;EACvE,oBAAOH,KAAA,CAAAQ,aAAA,CAACN,eAAe,EAAKC,KAAQ,CAAC;AACzC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@webiny/react-rich-text-lexical-renderer",
3
- "version": "5.44.1-beta.1",
3
+ "version": "5.45.0-beta.0",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -10,27 +11,29 @@
10
11
  "license": "MIT",
11
12
  "dependencies": {
12
13
  "@types/react": "18.2.79",
13
- "@webiny/app-theme": "5.44.1-beta.1",
14
- "@webiny/lexical-editor": "5.44.1-beta.1",
15
- "@webiny/lexical-theme": "5.44.1-beta.1",
14
+ "@webiny/lexical-editor": "5.45.0-beta.0",
15
+ "@webiny/lexical-theme": "5.45.0-beta.0",
16
16
  "react": "18.2.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@emotion/react": "11.10.8",
20
20
  "@testing-library/react": "15.0.7",
21
- "@webiny/app-theme": "0.0.0",
22
- "@webiny/project-utils": "5.44.1-beta.1",
23
- "@webiny/react-composition": "5.44.1-beta.1",
21
+ "@webiny/build-tools": "5.45.0-beta.0",
22
+ "@webiny/react-composition": "5.45.0-beta.0",
24
23
  "identity-obj-proxy": "3.0.0",
25
- "prettier": "2.8.8"
24
+ "prettier": "3.6.2",
25
+ "vitest": "4.0.18"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public",
29
29
  "directory": "dist"
30
30
  },
31
- "scripts": {
32
- "build": "node ../cli/bin.js run build",
33
- "watch": "node ../cli/bin.js run watch"
31
+ "adio": {
32
+ "ignore": {
33
+ "src": [
34
+ "@webiny/app-theme"
35
+ ]
36
+ }
34
37
  },
35
- "gitHead": "ff5f085c417040291d39fdbe5153067f3a23ed86"
38
+ "gitHead": "b85c33cfbe7c02c130445c918d913ef4b2c09cb2"
36
39
  }