Skip to content

Commit

Permalink
Add editor and components page
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Oct 24, 2024
1 parent 3cc0e64 commit 67c5e67
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 6 deletions.
33 changes: 29 additions & 4 deletions apps/website/src/app/components/editor/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,48 @@ const defaultContent = `
<br />
<strong>Integration with shadcn/cli</strong>
<strong>Easy Integration</strong>
<p>To ensure seamless integration and consistency within our codebase, we utilize the <code>shadcn/cli</code> tool. This CLI allows us to install all necessary dependencies and components directly into our project repository, maintaining a cohesive structure and simplifying management of the editor and its associated elements.</p>
<p>To ensure seamless integration and consistency within your codebase, we've made it easy to add the Midday Editor to your project. You can simply copy and paste the necessary code from our dedicated documentation. This method allows you to quickly incorporate all required dependencies and components directly into your project repository.</p>
<br />
<p>If you already have shadcn/cli installed, you can run this command:</p>
<p>We're actively working on adding the Midday Editor to the shadcn/cli, which will soon allow you to install it with just one command. Stay tuned for this upcoming feature!</p>
<br />
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum convallis congue tellus a lobortis. Curabitur sed velit at sem sagittis accumsan. Quisque non tortor eu orci rutrum iaculis. Nullam tincidunt bibendum lacus, eu dignissim nunc congue at.
<strong>Ongoing Development</strong>
<p>As we continue to develop and expand Midday's features, we're constantly adding new functionality to the editor. Our team is committed to enhancing its capabilities, improving performance, and introducing innovative AI-powered tools to make your editing experience even more powerful and efficient.</p>
<br />
`;

export default function Page() {
return (
<div className="container mt-24 max-w-[540px]">
<Editor content={defaultContent} />

<div className="mt-8">
<div className="border bg-card text-card-foreground shadow-sm">
<div className="flex flex-col space-y-1.5 p-6">
<h3 className="text-xl font-medium">Install Midday Editor</h3>
<p className="text-sm text-[#878787]">
Get started with our powerful AI-enhanced text editor
</p>
</div>
<div className="p-6 pt-0">
<a
href="https://go.midday.ai/editor"
target="_blank"
rel="noopener noreferrer"
className="inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 bg-primary text-primary-foreground hover:bg-primary/90 h-10 px-4 py-2"
>
View implementation
</a>
</div>
</div>
</div>
</div>
);
}
Binary file modified bun.lockb
Binary file not shown.
5 changes: 5 additions & 0 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,12 @@
"@storybook/addon-themes": "^8.3.5",
"@storybook/manager-api": "^8.3.5",
"@tiptap/extension-bold": "^2.9.1",
"@tiptap/extension-document": "^2.9.1",
"@tiptap/extension-link": "^2.9.1",
"@tiptap/extension-paragraph": "^2.9.1",
"@tiptap/extension-placeholder": "^2.9.1",
"@tiptap/extension-text": "^2.9.1",
"@tiptap/extension-underline": "^2.9.1",
"@tiptap/pm": "^2.9.1",
"@tiptap/react": "^2.9.1",
"@tiptap/starter-kit": "^2.9.1",
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/src/components/editor/extentions/register.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
// You can find the list of extensions here: https://tiptap.dev/docs/editor/extensions/functionality

import Link from "@tiptap/extension-link";
import Placeholder from "@tiptap/extension-placeholder";
import StarterKit from "@tiptap/starter-kit";

// Add your extensions here
export const extensions = [
StarterKit,
Placeholder.configure({ placeholder: "Write something..." }),
Link.configure({
openOnClick: false,
defaultProtocol: "https",
}),
];
8 changes: 6 additions & 2 deletions packages/ui/src/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

import "./styles.css";

import { EditorContent, useEditor } from "@tiptap/react";
import { EditorContent, type JSONContent, useEditor } from "@tiptap/react";
import { BubbleMenu } from "./extentions/bubble-menu";
import { extensions } from "./extentions/register";

type EditorProps = {
content?: string;
onChange?: (content: JSONContent) => void;
};

export function Editor({ content }: EditorProps) {
export function Editor({ content, onChange }: EditorProps) {
const editor = useEditor({
extensions,
content,
onUpdate: ({ editor }) => {
onChange?.(editor.getJSON());
},
});

return (
Expand Down

0 comments on commit 67c5e67

Please sign in to comment.