Skip to content

Commit 755bde1

Browse files
CopilotTechQuery
andauthored
[add] HTML Editor component with Edkit & Shadcn UI (#6)
Co-authored-by: TechQuery <[email protected]>
1 parent 559ed86 commit 755bde1

File tree

27 files changed

+748
-566
lines changed

27 files changed

+748
-566
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A **Pagination Table** & **Scroll List** component suite for [CRUD operation][1]
2424
14. [Scroll Boundary](https://mobx-restful-shadcn.idea2.app/)
2525
15. [Scroll List](https://mobx-restful-shadcn.idea2.app/)
2626
16. [Searchable Input](https://mobx-restful-shadcn.idea2.app/)
27+
17. [Editor](https://mobx-restful-shadcn.idea2.app/)
2728

2829
## Installation
2930

@@ -195,6 +196,37 @@ export const EditorPage = () => (
195196
);
196197
```
197198

199+
### Editor
200+
201+
```tsx
202+
import { configure } from "mobx";
203+
import { formToJSON } from "web-utility";
204+
205+
import { Editor, OriginalTools, ExtraTools } from "@/components/ui/editor";
206+
207+
configure({ enforceActions: "never" });
208+
209+
export const EditorPage = () => (
210+
<form
211+
onSubmit={(event) => {
212+
event.preventDefault();
213+
214+
const { content } = formToJSON(event.currentTarget);
215+
216+
alert(content);
217+
}}
218+
>
219+
<Editor
220+
tools={[...OriginalTools, ...ExtraTools]}
221+
name="content"
222+
defaultValue="Hello <b>Edkit</b>!"
223+
onChange={console.log}
224+
/>
225+
<button type="submit">Submit</button>
226+
</form>
227+
);
228+
```
229+
198230
## Development
199231

200232
This is a custom component registry built with Next.js and compatible with the `shadcn` CLI.

app/page.tsx

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
import { ComponentCard } from "@/components/example/component-card";
2-
import { HelloWorld } from "@/registry/new-york/blocks/hello-world/hello-world";
3-
import { ExampleForm } from "@/registry/new-york/blocks/example-form/example-form";
4-
import PokemonPage from "@/registry/new-york/blocks/complex-component/page";
5-
import { ExampleCard } from "@/registry/new-york/blocks/example-with-css/example-card";
62
import { BadgeBarExample } from "@/registry/new-york/blocks/badge-bar/example";
73
import { PagerExample } from "@/registry/new-york/blocks/pager/example";
84
import { ImagePreviewExample } from "@/registry/new-york/blocks/image-preview/example";
@@ -15,46 +11,20 @@ import { RangeInputExample } from "@/registry/new-york/blocks/range-input/exampl
1511
import { FilePickerExample } from "@/registry/new-york/blocks/file-picker/example";
1612
import { FormFieldExample } from "@/registry/new-york/blocks/form-field/example";
1713
import { RestTableExample } from "@/registry/new-york/blocks/rest-table/example";
14+
import { EditorExample } from "@/registry/new-york/blocks/editor/example";
1815

1916
export default function Home() {
2017
return (
2118
<div className="max-w-3xl mx-auto flex flex-col min-h-svh px-4 py-8 gap-8">
2219
<header className="flex flex-col gap-1">
23-
<h1 className="text-3xl font-bold tracking-tight">Custom Registry</h1>
20+
<h1 className="text-3xl font-bold tracking-tight">
21+
MobX-RESTful-Shadcn Registry
22+
</h1>
2423
<p className="text-muted-foreground">
2524
A custom registry for distributing code using shadcn.
2625
</p>
2726
</header>
2827
<main className="flex flex-col flex-1 gap-8">
29-
<ComponentCard
30-
name="hello-world"
31-
description="A simple hello world component"
32-
>
33-
<HelloWorld />
34-
</ComponentCard>
35-
36-
<ComponentCard
37-
name="example-form"
38-
description="A contact form with Zod validation."
39-
minHeight="min-h-[500px]"
40-
>
41-
<ExampleForm />
42-
</ComponentCard>
43-
44-
<ComponentCard
45-
name="complex-component"
46-
description="A complex component showing hooks, libs and components."
47-
>
48-
<PokemonPage />
49-
</ComponentCard>
50-
51-
<ComponentCard
52-
name="example-with-css"
53-
description="A login form with a CSS file."
54-
>
55-
<ExampleCard />
56-
</ComponentCard>
57-
5828
<ComponentCard
5929
name="badge-bar"
6030
description="A component for displaying a list of badges with optional click and delete handlers."
@@ -139,6 +109,14 @@ export default function Home() {
139109
>
140110
<RestTableExample />
141111
</ComponentCard>
112+
113+
<ComponentCard
114+
name="editor"
115+
description="A lightweight rich text editor based on Edkit and Shadcn UI with various formatting tools."
116+
minHeight="min-h-[400px]"
117+
>
118+
<EditorExample />
119+
</ComponentCard>
142120
</main>
143121
</div>
144122
);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mobx-restful-shadcn",
3-
"version": "1.5.0",
3+
"version": "1.6.0",
44
"private": true,
55
"scripts": {
66
"postinstall": "shadcn-helper install",
@@ -16,6 +16,7 @@
1616
"@radix-ui/react-slot": "^1.2.4",
1717
"class-variance-authority": "^0.7.1",
1818
"clsx": "^2.1.1",
19+
"edkit": "^1.2.7",
1920
"lodash.debounce": "^4.0.8",
2021
"lucide-react": "^0.562.0",
2122
"mobx": "^6.15.0",

pnpm-lock.yaml

Lines changed: 64 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)