@webiny/react-rich-text-lexical-renderer 0.0.0-unstable.c7dec08bb0 β†’ 0.0.0-unstable.df7a8bb475

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,107 +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
9
+ ---
11
10
 
12
- Webiny uses Lexical editor https://lexical.dev/ as a go to Rich Text Editor, with some additional plugins. To speed up the rendering of data for developers, we created this component.
13
-
14
- ## Install
15
-
16
- ```
17
- npm install --save @webiny/react-rich-text-lexical-renderer
18
- ```
19
-
20
- Or if you prefer yarn:
21
-
22
- ```
23
- yarn add @webiny/react-rich-text-lexical-renderer
24
- ```
25
-
26
- ## Usage
27
-
28
- Fetch your data from Headless CMS, then pass it to the component like this:
29
-
30
- ```tsx
31
- import { RichTextRenderer } from "@webiny/react-rich-text-renderer";
32
-
33
- // Load content from Headless CMS (here we show what your content might look like).
34
- const content = {
35
- root: {
36
- children: [
37
- {
38
- children: [
39
- {
40
- detail: 0,
41
- format: 0,
42
- mode: "normal",
43
- style: "",
44
- text: "A well written paragraph of text can bring so much joy!",
45
- type: "text",
46
- version: 1
47
- }
48
- ],
49
- direction: "ltr",
50
- styles: [],
51
- format: "",
52
- indent: 0,
53
- tag: "p",
54
- type: "paragraph-element",
55
- version: 1
56
- }
57
- ],
58
- direction: "ltr",
59
- format: "",
60
- indent: 0,
61
- type: "root",
62
- version: 1
63
- }
64
- }
65
-
66
- // Mount the component
67
- <RichTextLexicalRenderer value={content} />;
68
- ```
69
-
70
- ## Adding your custom lexical nodes for rendering
71
-
72
- You can add custom lexical nodes for rendering your content:
73
-
74
- ```tsx
75
-
76
- class MyCustomNode extends LexicalNode {
77
- ...
78
- }
79
-
80
- // Mount the component
81
- <RichTextLexicalRenderer value={content} nodes={[MyCustomNode]} />;
82
- ```
83
-
84
- ## Adding your custom typography theme.
85
-
86
- You can override Webiny default typography theme that is used by lexical editor by providing your custom typography object.
87
-
88
- Please [ read our docs ](https://www.webiny.com/docs/page-builder/theming/theme-object) and check 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) before add you custom theme.
89
- ```tsx
90
-
91
- const myTheme = {
92
- styles: {
93
- typography: {
94
- headings: [
95
- {
96
- id: "custom_heading1",
97
- name: "Custom Heading 1",
98
- tag: "h1",
99
- styles: { ...headings, fontWeight: "bold", fontSize: 48 }
100
- }]
101
- }
102
- }
103
- }
104
-
105
- // Mount the component
106
- <RichTextLexicalRenderer value={content} theme={myTheme} nodes={[MyCustomNode]} />;
107
- ```
11
+ _This README file is automatically generated during the publish process._
package/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
- import { LexicalNode, LexicalValue, Klass } from "@webiny/lexical-editor/types";
3
- declare type RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;
2
+ import type { Klass, LexicalNode, LexicalValue } from "@webiny/lexical-editor/types.js";
3
+ import type { EditorTheme } from "@webiny/lexical-theme";
4
+ type RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;
4
5
  interface RichTextLexicalRenderer {
5
6
  value: RendererLexicalValue;
6
- theme?: Record<string, any>;
7
+ theme: EditorTheme;
7
8
  nodes?: Klass<LexicalNode>[];
8
9
  }
9
- export declare const RichTextLexicalRenderer: React.FC<RichTextLexicalRenderer>;
10
+ export declare const RichTextLexicalRenderer: (props: RichTextLexicalRenderer) => React.JSX.Element;
10
11
  export {};
package/index.js CHANGED
@@ -1,30 +1,20 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.RichTextLexicalRenderer = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _lexicalEditor = require("@webiny/lexical-editor");
11
- var _appTheme = require("@webiny/app-theme");
12
- var LexicalRenderer = function LexicalRenderer(props) {
13
- var _useTheme = (0, _appTheme.useTheme)(),
14
- theme = _useTheme.theme;
15
- 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 => {
16
5
  if (!value) {
17
6
  return null;
18
7
  }
19
- return typeof (props === null || props === void 0 ? void 0 : props.value) === "string" ? props.value : JSON.stringify(props.value);
8
+ return typeof props?.value === "string" ? props.value : JSON.stringify(props.value);
20
9
  };
21
- return /*#__PURE__*/_react.default.createElement(_lexicalEditor.LexicalHtmlRenderer, {
22
- value: getValue(props === null || props === void 0 ? void 0 : props.value),
23
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, props === null || props === void 0 ? void 0 : props.theme), theme),
10
+ return /*#__PURE__*/React.createElement(LexicalHtmlRenderer, {
11
+ value: getValue(props?.value),
12
+ theme: props.theme,
24
13
  nodes: props.nodes
25
14
  });
26
15
  };
27
- var RichTextLexicalRenderer = function RichTextLexicalRenderer(props) {
28
- 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);
29
18
  };
30
- exports.RichTextLexicalRenderer = RichTextLexicalRenderer;
19
+
20
+ //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["LexicalRenderer","props","useTheme","theme","getValue","value","JSON","stringify","nodes","RichTextLexicalRenderer"],"sources":["index.tsx"],"sourcesContent":["import React from \"react\";\nimport { LexicalNode, LexicalValue, Klass } from \"@webiny/lexical-editor/types\";\nimport { LexicalHtmlRenderer } from \"@webiny/lexical-editor\";\nimport { ThemeProvider, useTheme } from \"@webiny/app-theme\";\n\ntype RendererLexicalValue = LexicalValue | Record<string, any> | null | undefined;\n\ninterface RichTextLexicalRenderer {\n value: RendererLexicalValue;\n theme?: Record<string, any>;\n nodes?: Klass<LexicalNode>[];\n}\n\nconst LexicalRenderer: React.FC<RichTextLexicalRenderer> = props => {\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 return (\n <LexicalHtmlRenderer\n value={getValue(props?.value)}\n theme={{ ...props?.theme, ...theme }}\n nodes={props.nodes}\n />\n );\n};\n\nexport const RichTextLexicalRenderer: React.FC<RichTextLexicalRenderer> = props => {\n return (\n <ThemeProvider>\n <LexicalRenderer {...props} />\n </ThemeProvider>\n );\n};\n"],"mappings":";;;;;;;;AAAA;AAEA;AACA;AAUA,IAAMA,eAAkD,GAAG,SAArDA,eAAkD,CAAGC,KAAK,EAAI;EAChE,gBAAkB,IAAAC,kBAAQ,GAAE;IAApBC,KAAK,aAALA,KAAK;EAEb,IAAMC,QAAQ,GAAG,SAAXA,QAAQ,CAAIC,KAA2B,EAAoB;IAC7D,IAAI,CAACA,KAAK,EAAE;MACR,OAAO,IAAI;IACf;IACA,OAAO,QAAOJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEI,KAAK,MAAK,QAAQ,GAAGJ,KAAK,CAACI,KAAK,GAAGC,IAAI,CAACC,SAAS,CAACN,KAAK,CAACI,KAAK,CAAC;EACvF,CAAC;EAED,oBACI,6BAAC,kCAAmB;IAChB,KAAK,EAAED,QAAQ,CAACH,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEI,KAAK,CAAE;IAC9B,KAAK,8DAAOJ,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEE,KAAK,GAAKA,KAAK,CAAG;IACrC,KAAK,EAAEF,KAAK,CAACO;EAAM,EACrB;AAEV,CAAC;AAEM,IAAMC,uBAA0D,GAAG,SAA7DA,uBAA0D,CAAGR,KAAK,EAAI;EAC/E,oBACI,6BAAC,uBAAa,qBACV,6BAAC,eAAe,EAAKA,KAAK,CAAI,CAClB;AAExB,CAAC;AAAC"}
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": "0.0.0-unstable.c7dec08bb0",
3
+ "version": "0.0.0-unstable.df7a8bb475",
4
+ "type": "module",
4
5
  "main": "index.js",
5
6
  "repository": {
6
7
  "type": "git",
@@ -9,28 +10,30 @@
9
10
  "author": "Webiny Ltd",
10
11
  "license": "MIT",
11
12
  "dependencies": {
12
- "@babel/runtime": "7.20.13",
13
- "@types/react": "17.0.39",
14
- "@webiny/app-theme": "0.0.0-unstable.c7dec08bb0",
15
- "@webiny/lexical-editor": "0.0.0-unstable.c7dec08bb0",
16
- "react": "17.0.2"
13
+ "@types/react": "18.2.79",
14
+ "@webiny/lexical-editor": "0.0.0-unstable.df7a8bb475",
15
+ "@webiny/lexical-theme": "0.0.0-unstable.df7a8bb475",
16
+ "react": "18.2.0"
17
17
  },
18
18
  "devDependencies": {
19
- "@testing-library/react": "12.1.5",
20
- "@webiny/cli": "0.0.0-unstable.c7dec08bb0",
21
- "@webiny/project-utils": "0.0.0-unstable.c7dec08bb0",
22
- "@webiny/react-composition": "0.0.0-unstable.c7dec08bb0",
19
+ "@emotion/react": "11.10.8",
20
+ "@testing-library/react": "15.0.7",
21
+ "@webiny/build-tools": "0.0.0-unstable.df7a8bb475",
22
+ "@webiny/react-composition": "0.0.0-unstable.df7a8bb475",
23
23
  "identity-obj-proxy": "3.0.0",
24
- "prettier": "2.8.3",
25
- "theme": "0.0.0"
24
+ "prettier": "3.6.2",
25
+ "vitest": "3.2.4"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public",
29
29
  "directory": "dist"
30
30
  },
31
- "scripts": {
32
- "build": "yarn webiny run build",
33
- "watch": "yarn webiny run watch"
31
+ "adio": {
32
+ "ignore": {
33
+ "src": [
34
+ "@webiny/app-theme"
35
+ ]
36
+ }
34
37
  },
35
- "gitHead": "c7dec08bb095467cca6a61381bd399d66b7bb147"
38
+ "gitHead": "df7a8bb4755a1da047f0af8c56bdb649cc81bf7d"
36
39
  }