Skip to content
Open
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
6 changes: 5 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Metadata } from 'next';
import './globals.css';
import { Toaster } from 'sonner';

export const metadata: Metadata = {
title: 'Blolet',
Expand All @@ -13,7 +14,10 @@ export default function RootLayout({
}>) {
return (
<html lang='ko'>
<body className='antialiased'>{children}</body>
<body className='antialiased'>
{children}
<Toaster />
</body>
</html>
);
}
22 changes: 21 additions & 1 deletion src/lib/editor/components/plate-editor.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,37 @@
'use client';

import { Plate, usePlateEditor } from 'platejs/react';
import { toast } from 'sonner';

import * as React from 'react';

import { EditorKit } from './editor-kit';
import { PlateEditorAdapter } from '../editor-event-adapter';
import { Editor, EditorContainer } from './ui/editor';

export function PlateEditor() {
const editor = usePlateEditor({
plugins: EditorKit,
});
const editorAdapter = React.useMemo(() => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const adapter = new PlateEditorAdapter(editor as any, 'draftId');

// 임시 change handler 설정 (추후 mutate API 연결)
adapter.onContentChange((request) => {
toast(`📡 [${request.type}]`);
});

return adapter;
}, [editor]);

return (
<Plate editor={editor}>
<Plate
editor={editor}
onChange={({ editor: { operations } }) => {
editorAdapter.processOperations(operations);
}}
>
<EditorContainer>
<Editor
placeholder={`텍스트를 입력해 주세요.\n“/” 입력하여 명령어를 사용할 수 있습니다.`}
Expand Down
Loading