Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/docs/content/docs/ui/auto-form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ description: Component creates form based on Zod schemas & react-hook-form with
```tsx
import { AutoForm } from "@vitnode/core/components/form/auto-form";
import { AutoFormCheckbox } from "@vitnode/core/components/form/fields/checkbox";
import { AutoFormEditor } from "@vitnode/core/components/form/fields/editor";
import { AutoFormInput } from "@vitnode/core/components/form/fields/input";
import { AutoFormSelect } from "@vitnode/core/components/form/fields/select";
import { AutoFormTextarea } from "@vitnode/core/components/form/fields/textarea";
Expand Down Expand Up @@ -40,6 +41,10 @@ const formSchema = z.object({
message: "You must accept the terms and conditions",
}),
description: z.string().min(10, "Description must be at least 10 characters"),
content: z
.string()
.min(1, "Content is required")
.default("<p>Write your content here...</p>"),
search: z.string().optional(),
});
```
Expand Down Expand Up @@ -119,6 +124,16 @@ const formSchema = z.object({
/>
),
},
{
id: "content",
component: props => (
<AutoFormEditor
{...props}
description="Rich text content powered by the Editor."
label="Content"
/>
),
},
{
id: "search",
component: props => (
Expand Down
112 changes: 112 additions & 0 deletions apps/docs/content/docs/ui/editor.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
title: Editor
description: Rich text editor built on TipTap for editing and rendering HTML content.
---

## Preview

<Preview name="editor" />

## Usage

import { Tab, Tabs } from "fumadocs-ui/components/tabs";

<Tabs items={['Auto Form', 'Manual']}>
<Tab value="Auto Form">

```ts
import { z } from "zod";
import { AutoForm } from "@vitnode/core/components/form/auto-form";
import { AutoFormEditor } from "@vitnode/core/components/form/fields/editor";
```

```ts
const formSchema = z.object({
content: z
.string()
.min(1, "Content is required")
.default("<p>Write your content here...</p>"),
});
```

```tsx
<AutoForm
formSchema={formSchema}
fields={[
{
id: "content",
component: props => (
<AutoFormEditor
{...props}
description="Rich text content powered by the Editor."
label="Content"
/>
),
},
]}
/>
```

</Tab>

<Tab value="Manual">

```ts
import { Editor } from "@vitnode/core/components/ui/editor";
```

The `Editor` is uncontrolled by default — pass `value` as the initial HTML and
listen for changes with `onChange`, which receives the current HTML string:

```tsx
const [content, setContent] = useState("<p>Hello World! 🌎️</p>");

<Editor value={content} onChange={setContent} />;
```

</Tab>
</Tabs>

## Rendering Content

Use `EditorContent` to render the stored HTML as read-only content outside of
the editor (e.g. on a public page):

```ts
import { EditorContent } from "@vitnode/core/components/ui/editor-content";
```

```tsx
<EditorContent content="<h2>Title</h2><p>Hello World! 🌎️</p>" />
```

## Props

import { TypeTable } from "fumadocs-ui/components/type-table";

<TypeTable
type={{
value: {
description: "Initial HTML content rendered inside the editor.",
type: "string",
default: '""',
},
onChange: {
description:
"Called on every change with the current content as an HTML string.",
type: "(value: string) => void",
default: "",
},
disableScroll: {
description:
"Disables the internal max-height scroll area so the editor grows with its content.",
type: "boolean",
default: "false",
},
className: {
description: "Additional classes applied to the editor wrapper.",
type: "string",
default: "",
},
}}
/>
1 change: 1 addition & 0 deletions apps/docs/content/docs/ui/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"auto-form",
"checkbox",
"combobox",
"editor",
"input",
"input-group",
"radio-group",
Expand Down
15 changes: 15 additions & 0 deletions apps/docs/src/examples/auto-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { AutoForm } from "@vitnode/core/components/form/auto-form";
import { AutoFormCheckbox } from "@vitnode/core/components/form/fields/checkbox";
import { AutoFormEditor } from "@vitnode/core/components/form/fields/editor";
import { AutoFormInput } from "@vitnode/core/components/form/fields/input";
import { AutoFormSelect } from "@vitnode/core/components/form/fields/select";
import { AutoFormTextarea } from "@vitnode/core/components/form/fields/textarea";
Expand All @@ -22,6 +23,10 @@ export default function AutoFormExample() {
description: z
.string()
.min(10, "Description must be at least 10 characters"),
content: z
.string()
.min(1, "Content is required")
.default("<p>Write your content here...</p>"),
search: z.string().optional(),
});

Expand Down Expand Up @@ -79,6 +84,16 @@ export default function AutoFormExample() {
/>
),
},
{
id: "content",
component: props => (
<AutoFormEditor
description="Rich text content powered by the Editor."
label="Content"
{...props}
/>
),
},
{
id: "search",
component: props => (
Expand Down
32 changes: 32 additions & 0 deletions apps/docs/src/examples/editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";

import { AutoForm } from "@vitnode/core/components/form/auto-form";
import { AutoFormEditor } from "@vitnode/core/components/form/fields/editor";
import { z } from "zod";

export default function EditorExample() {
const formSchema = z.object({
content: z
.string()
.min(1, "Content is required")
.default("<p>Write your content here...</p>"),
});

return (
<AutoForm
fields={[
{
id: "content",
component: props => (
<AutoFormEditor
description="Rich text content powered by the Editor."
label="Content"
{...props}
/>
),
},
]}
formSchema={formSchema}
/>
);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
2 changes: 1 addition & 1 deletion packages/create-vitnode-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"eslint-react"
],
"scripts": {
"build:scripts": "tsc && node dist/src/prepare/prepare.js",
"build:scripts": "tsc -p tsconfig.build.json && node dist/src/prepare/prepare.js",
"start:scripts": "node dist/src/index.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const createPluginPackageJSON = async ({
type: "module",
scripts: {
"build:plugins":
"tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
dev: 'concurrently "tsc -w --preserveWatchOutput" "swc src -d dist --config-file .swcrc -w" "tsc-alias -w" "vitnode plugin --w"',
"tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
dev: 'concurrently "tsc -w -p tsconfig.build.json --preserveWatchOutput" "swc src -d dist --config-file .swcrc -w" "tsc-alias -w -p tsconfig.build.json" "vitnode plugin --w"',
"dev:email": "email dev --dir src/emails",
...withIf(eslint, {
lint: "turbo lint",
Expand Down
5 changes: 5 additions & 0 deletions packages/create-vitnode-app/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "dist", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/node-cron/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
4 changes: 2 additions & 2 deletions packages/node-cron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
},
"scripts": {
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
"dev:plugins": "concurrently \"tsc -w --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w\"",
"build:plugins": "tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
"dev:plugins": "concurrently \"tsc -w -p tsconfig.build.json --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w -p tsconfig.build.json\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/node-cron/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/nodemailer/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
4 changes: 2 additions & 2 deletions packages/nodemailer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
}
},
"scripts": {
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
"dev:plugins": "concurrently \"tsc -w --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w\"",
"build:plugins": "tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
"dev:plugins": "concurrently \"tsc -w -p tsconfig.build.json --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w -p tsconfig.build.json\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/nodemailer/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/resend/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
4 changes: 2 additions & 2 deletions packages/resend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
}
},
"scripts": {
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
"dev:plugins": "concurrently \"tsc -w --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w\"",
"build:plugins": "tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
"dev:plugins": "concurrently \"tsc -w -p tsconfig.build.json --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w -p tsconfig.build.json\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/resend/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/s3/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
4 changes: 2 additions & 2 deletions packages/s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
},
"scripts": {
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
"dev:plugins": "concurrently \"tsc -w --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w\"",
"build:plugins": "tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
"dev:plugins": "concurrently \"tsc -w -p tsconfig.build.json --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w -p tsconfig.build.json\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/s3/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/supabase-storage/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
4 changes: 2 additions & 2 deletions packages/supabase-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
}
},
"scripts": {
"build:plugins": "tsc && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.json",
"dev:plugins": "concurrently \"tsc -w --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w\"",
"build:plugins": "tsc -p tsconfig.build.json && swc src -d dist --config-file .swcrc && tsc-alias -p tsconfig.build.json",
"dev:plugins": "concurrently \"tsc -w -p tsconfig.build.json --preserveWatchOutput\" \"swc src -d dist --config-file .swcrc -w\" \"tsc-alias -w -p tsconfig.build.json\"",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/supabase-storage/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "./tsconfig.json",
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
1 change: 1 addition & 0 deletions packages/vitnode/.swcrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"$schema": "https://swc.rs/schema.json",
"exclude": ["\\.test\\.tsx?$"],
"minify": true,
"jsc": {
"baseUrl": "./",
Expand Down
Loading
Loading