diff --git a/apps/core/app/test/page.tsx b/apps/core/app/test/page.tsx index 4f20deba..9587074d 100644 --- a/apps/core/app/test/page.tsx +++ b/apps/core/app/test/page.tsx @@ -1,11 +1,19 @@ "use client"; -import React from "react"; -import { FileFormatField } from "../dashboard/products/create/_components/file-formate-field"; -import { FileFormatSection } from "../dashboard/products/create/_components/file-formate-section"; +import { RichTextEditor } from "@repo/ui/components/editor/editor"; const Page = () => { - return ; + return ( +
+ console.log(html, text)} + defaultValue="hello" + value="salam" + label="badry" + helperText="ali" + /> +
+ ); }; export default Page; diff --git a/apps/storybook/src/stories/editor.stories.tsx b/apps/storybook/src/stories/editor.stories.tsx new file mode 100644 index 00000000..a7d36e42 --- /dev/null +++ b/apps/storybook/src/stories/editor.stories.tsx @@ -0,0 +1,47 @@ +import { RichTextEditor } from "@repo/ui/components/editor/editor"; +import type { Meta, StoryObj } from "@storybook/react"; + +const meta: Meta = { + title: "Components/RichTextEditor", + component: RichTextEditor, + tags: ["autodocs"], + argTypes: { + value: { control: "text" }, + defaultValue: { control: "text" }, + onChange: { action: "onChange" }, + className: { control: "text" }, + label: { control: "text" }, + helperText: { control: "text" }, + error: { control: "text" }, + id: { control: "text" }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = { + args: { + label: "Rich Text Editor", + helperText: "You can enter rich text here.", + defaultValue: "

Initial content

", + }, +}; + +export const WithError: Story = { + args: { + label: "Rich Text Editor", + helperText: "This editor has an error.", + defaultValue: "

Initial content with error

", + error: "This is an error message.", + }, +}; + +export const CustomClass: Story = { + args: { + label: "Rich Text Editor", + helperText: "This editor has a custom class.", + defaultValue: "

Initial content with custom class

", + className: "custom-editor-class", + }, +}; diff --git a/bun.lockb b/bun.lockb index a60456c8..9a631ef4 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 7a8d754e..06a19cde 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,19 @@ { "name": "turborepo-shadcn-ui", "version": "1.3.0", - "private": true, + "devDependencies": { + "@repo/eslint-config": "*", + "@repo/typescript-config": "*", + "husky": "^9.1.7", + "prettier": "^3.3.2", + "turbo": "2.0.6" + }, + "engines": { + "node": ">=18" + }, "license": "MIT", + "packageManager": "bun@1.1.29", + "private": true, "scripts": { "build": "turbo build", "type-checks": "turbo build check-types", @@ -17,17 +28,6 @@ "deploy": "git pull origin main && git push vercel main", "rebase:main": "git fetch origin main && git rebase main" }, - "devDependencies": { - "@repo/eslint-config": "*", - "@repo/typescript-config": "*", - "husky": "^9.1.7", - "prettier": "^3.3.2", - "turbo": "2.0.6" - }, - "packageManager": "bun@1.1.29", - "engines": { - "node": ">=18" - }, "workspaces": [ "apps/*", "packages/*" diff --git a/packages/ui/package.json b/packages/ui/package.json index 91a5171c..8868160a 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -24,8 +24,6 @@ "typescript": "^5.4.5" }, "dependencies": { - "@repo/design-system": "*", - "@repo/icons": "*", "@hookform/resolvers": "^3.9.0", "@radix-ui/react-accordion": "^1.2.0", "@radix-ui/react-alert-dialog": "^1.1.1", @@ -51,8 +49,23 @@ "@radix-ui/react-switch": "^1.1.0", "@radix-ui/react-tabs": "^1.1.0", "@radix-ui/react-tooltip": "^1.1.0", - + "@repo/design-system": "*", + "@repo/icons": "*", "@tabler/icons-react": "^3.12.0", + "@tailwindcss/typography": "^0.5.16", + "@tiptap/extension-code": "^2.11.7", + "@tiptap/extension-code-block": "^2.11.7", + "@tiptap/extension-color": "^2.11.7", + "@tiptap/extension-highlight": "^2.11.5", + "@tiptap/extension-image": "^2.11.5", + "@tiptap/extension-link": "^2.11.5", + "@tiptap/extension-list-item": "^2.11.7", + "@tiptap/extension-ordered-list": "^2.11.7", + "@tiptap/extension-text-align": "^2.11.5", + "@tiptap/extension-text-style": "^2.11.7", + "@tiptap/extension-underline": "^2.11.7", + "@tiptap/react": "^2.11.5", + "@tiptap/starter-kit": "^2.11.5", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "1.0.0", diff --git a/packages/ui/src/components/atoms/command.tsx b/packages/ui/src/components/atoms/command.tsx index fe211d38..061f4ffa 100644 --- a/packages/ui/src/components/atoms/command.tsx +++ b/packages/ui/src/components/atoms/command.tsx @@ -1,12 +1,12 @@ "use client" import * as React from "react" -import { type DialogProps } from "@radix-ui/react-dialog" + import { Command as CommandPrimitive } from "cmdk" import { Search } from "lucide-react" import { cn } from "@repo/ui/lib/utils" -import { Dialog, DialogContent } from "@repo/ui/components/ui/dialog" + const Command = React.forwardRef< React.ElementRef, diff --git a/packages/ui/src/components/atoms/rich-text-style-provider.tsx b/packages/ui/src/components/atoms/rich-text-style-provider.tsx new file mode 100644 index 00000000..8d71640b --- /dev/null +++ b/packages/ui/src/components/atoms/rich-text-style-provider.tsx @@ -0,0 +1,10 @@ +import { PropsWithChildren } from "react"; + +export const RichTextStylesProvider = ({ children }: PropsWithChildren) => { + return ( + // INFO: "prose" class has max-width and we should remove it by max-w-none +
+ {children} +
+ ); +}; diff --git a/packages/ui/src/components/atoms/textarea.tsx b/packages/ui/src/components/atoms/textarea.tsx index 2f33e297..782f2d83 100644 --- a/packages/ui/src/components/atoms/textarea.tsx +++ b/packages/ui/src/components/atoms/textarea.tsx @@ -1,6 +1,6 @@ -import * as React from "react" +import * as React from "react"; -import { cn } from "@repo/ui/lib/utils" +import { cn } from "@repo/ui/lib/utils"; export interface TextareaProps extends React.TextareaHTMLAttributes {} @@ -11,14 +11,14 @@ const Textarea = React.forwardRef(