Skip to content

Commit fa01344

Browse files
CopilotTechQuery
andcommitted
Update editor example to use Shadcn UI Button component and improve README documentation
Co-authored-by: TechQuery <[email protected]>
1 parent 8e327fa commit fa01344

3 files changed

Lines changed: 40 additions & 6 deletions

File tree

README.md

Lines changed: 29 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,34 @@ export const EditorPage = () => (
195196
);
196197
```
197198

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

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

app/page.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { RangeInputExample } from "@/registry/new-york/blocks/range-input/exampl
1515
import { FilePickerExample } from "@/registry/new-york/blocks/file-picker/example";
1616
import { FormFieldExample } from "@/registry/new-york/blocks/form-field/example";
1717
import { RestTableExample } from "@/registry/new-york/blocks/rest-table/example";
18+
import EditorExample from "@/registry/new-york/blocks/editor/example";
1819

1920
export default function Home() {
2021
return (
@@ -139,6 +140,14 @@ export default function Home() {
139140
>
140141
<RestTableExample />
141142
</ComponentCard>
143+
144+
<ComponentCard
145+
name="editor"
146+
description="A lightweight rich text editor based on Edkit and Shadcn UI with various formatting tools."
147+
minHeight="min-h-[400px]"
148+
>
149+
<EditorExample />
150+
</ComponentCard>
142151
</main>
143152
</div>
144153
);

registry/new-york/blocks/editor/example.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { configure } from "mobx";
44
import { formToJSON } from "web-utility";
55
import { Editor, OriginalTools, ExtraTools } from "./index";
6+
import { Button } from "@/components/ui/button";
67

78
configure({ enforceActions: "never" });
89

@@ -31,12 +32,7 @@ export default function EditorExample() {
3132
onChange={console.log}
3233
/>
3334

34-
<button
35-
className="inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-9 px-4 py-2"
36-
type="submit"
37-
>
38-
Submit
39-
</button>
35+
<Button type="submit">Submit</Button>
4036
</div>
4137
</form>
4238
);

0 commit comments

Comments
 (0)