Skip to content

Commit

Permalink
feat: create webrepub component
Browse files Browse the repository at this point in the history
  • Loading branch information
omnajjar committed Apr 8, 2023
1 parent 4e51785 commit dcb79b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/desginer/typings/webrepub.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { UserComponent } from '@craftjs/core';
import { ReactNode } from 'react';

export type WebrepubComponent<T = unknown> = UserComponent<T> & {
icon?: ReactNode;
};
11 changes: 6 additions & 5 deletions src/presets/react-email/Components/Html/HtmlComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useEditor, useNode, UserComponent } from '@craftjs/core';
import { useNode } from '@craftjs/core';
import { Html, HtmlProps } from '@react-email/html';
import { CSSProperties } from 'react';
import { BsFiletypeHtml } from 'react-icons/bs';

import { useGlobalSettings } from '@/desginer/Providers/GlobalSettings';
import { WebrepubComponent } from '@/desginer/typings/webrepub';
import { HtmlComponentSettings } from '@/presets/react-email/Components/Html/HtmlComponentSettings';

const defaultConfiguredStyles: CSSProperties = {
Expand All @@ -13,17 +15,14 @@ export interface HtmlComponentProps extends HtmlProps {
previwe: boolean;
}

export const HTMLComponent: UserComponent<HtmlComponentProps> = ({
export const HTMLComponent: WebrepubComponent<HtmlComponentProps> = ({
children,
style,
...props
}: HtmlComponentProps) => {
const {
connectors: { connect },
} = useNode();
const { enabled: _enabled } = useEditor((state) => ({
enabled: state.options.enabled,
}));

const {
settings: { isInDesignMode: _isInDesignMode },
Expand Down Expand Up @@ -62,3 +61,5 @@ HTMLComponent.craft = {
settings: HtmlComponentSettings,
},
};

HTMLComponent.icon = <BsFiletypeHtml />;

0 comments on commit dcb79b2

Please sign in to comment.