Skip to content

Commit

Permalink
fix(app-admin): improve Lexical prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Nov 18, 2024
1 parent cc16ecc commit 8990f00
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/app-admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@webiny/app-wcp": "0.0.0",
"@webiny/form": "0.0.0",
"@webiny/lexical-editor": "0.0.0",
"@webiny/lexical-theme": "0.0.0",
"@webiny/plugins": "0.0.0",
"@webiny/react-composition": "0.0.0",
"@webiny/react-router": "0.0.0",
Expand Down
13 changes: 10 additions & 3 deletions packages/app-admin/src/components/LexicalEditor/LexicalEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,30 @@ import { FileManager } from "~/components";
import { RichTextEditor as BaseEditor } from "@webiny/lexical-editor";
import { RichTextEditorProps } from "@webiny/lexical-editor/types";
import { useTheme } from "@webiny/app-theme";
import { Theme } from "@webiny/app-theme/types";
import { EditorTheme } from "@webiny/lexical-theme";

interface LexicalEditorProps extends Omit<RichTextEditorProps, "theme"> {
theme?: Theme;
theme?: Partial<EditorTheme>;
}

const imagesOnly = ["image/*"];

export const LexicalEditor = (props: LexicalEditorProps) => {
const { theme } = useTheme();

const editorTheme: EditorTheme = {
styles: {},
emotionMap: {},
...theme,
...(props.theme || {})
};

return (
<FileManager accept={imagesOnly}>
{({ showFileManager }) => (
<BaseEditor
{...props}
theme={{ ...theme, ...props?.theme }}
theme={editorTheme}
toolbarActionPlugins={[
...(props.toolbarActionPlugins || []),
{ targetAction: "image-action", plugin: showFileManager }
Expand Down
1 change: 1 addition & 0 deletions packages/app-admin/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ "path": "../app-wcp/tsconfig.build.json" },
{ "path": "../form/tsconfig.build.json" },
{ "path": "../lexical-editor/tsconfig.build.json" },
{ "path": "../lexical-theme/tsconfig.build.json" },
{ "path": "../plugins/tsconfig.build.json" },
{ "path": "../react-composition/tsconfig.build.json" },
{ "path": "../react-router/tsconfig.build.json" },
Expand Down
3 changes: 3 additions & 0 deletions packages/app-admin/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{ "path": "../app-wcp" },
{ "path": "../form" },
{ "path": "../lexical-editor" },
{ "path": "../lexical-theme" },
{ "path": "../plugins" },
{ "path": "../react-composition" },
{ "path": "../react-router" },
Expand Down Expand Up @@ -35,6 +36,8 @@
"@webiny/form": ["../form/src"],
"@webiny/lexical-editor/*": ["../lexical-editor/src/*"],
"@webiny/lexical-editor": ["../lexical-editor/src"],
"@webiny/lexical-theme/*": ["../lexical-theme/src/*"],
"@webiny/lexical-theme": ["../lexical-theme/src"],
"@webiny/plugins/*": ["../plugins/src/*"],
"@webiny/plugins": ["../plugins/src"],
"@webiny/react-composition/*": ["../react-composition/src/*"],
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15540,6 +15540,7 @@ __metadata:
"@webiny/cli": 0.0.0
"@webiny/form": 0.0.0
"@webiny/lexical-editor": 0.0.0
"@webiny/lexical-theme": 0.0.0
"@webiny/plugins": 0.0.0
"@webiny/project-utils": 0.0.0
"@webiny/react-composition": 0.0.0
Expand Down

0 comments on commit 8990f00

Please sign in to comment.