Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Info required on Paragraph Component (Not a Bug) #8

Open
imransilvake opened this issue Jul 25, 2023 · 1 comment
Open

Info required on Paragraph Component (Not a Bug) #8

imransilvake opened this issue Jul 25, 2023 · 1 comment

Comments

@imransilvake
Copy link

imransilvake commented Jul 25, 2023

I am using a Paragraph component to render the text with styles. i.e

const EditorJsParagraph = (props: IParagraphProps) => {
	const { text } = props.data;

	return <VHtmlText text={text} textClass="text-base text-52 dark:text-52" />;
};
export default EditorJsParagraph;

I need to change the text color based on Light and dark mode. How can I pass the information to EditorJsParagraph component so that I can change the text color?

Desired Behaviour:

if (darkMode) {
return <VHtmlText text={text} textClass="text-base text-52 dark:text-52" />;
}
return <VHtmlText text={text} textClass="text-base text-50 dark:text-50" />;

Setup

const EditorJsViewerNative = createEditorJsViewer({
	tools: {
		header: { Component: EditorJsHeader },
		paragraph: { Component: EditorJsParagraph },
		list: { Component: EditorJsList },
		image: { Component: EditorJsImage }
	},
	showBlockFallback: true
});
@imransilvake imransilvake changed the title Info required on Paragraph Component Info required on Paragraph Component (Not a Bug) Jul 25, 2023
@alexdieudonne
Copy link

You can achieve what you want by the following this, but if you want to render a specific Component you have to duplicate the corresponding tool and accept the text={text}, textClass arguments

const EditorJsViewerNative = createEditorJsViewer({
    list: {
      Component: (d) =>
        List({
          ...d,
          containerStyle: { paddingHorizontal: 15 },
        }),
    },
  },
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants