Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update api-key for TinyMCE Editor #39

Merged
merged 4 commits into from
Aug 27, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ POSTGRES_DB=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}?schema=public"

NEXT_PUBLIC_API_KEY_TINYMCE=""
# GOOGLE_CLIENT_ID=
# GOOGLE_CLIENT_SECRET=

Expand Down
10 changes: 7 additions & 3 deletions src/components/SSEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { useRef, type FC } from 'react';
'use client';
import { useRef, type FC, useEffect } from 'react';
import { Editor } from '@tinymce/tinymce-react';
import { Editor as TinyMCEEditor } from 'tinymce';
type PropTypes = {
value?: string;
onSave?: (value: string) => void;
};
const SSEditor: FC<PropTypes> = ({ value, onSave }) => {

const TextEditor: FC<PropTypes> = ({ value, onSave }) => {
const editorRef = useRef<TinyMCEEditor | null>(null);

return (
<Editor
onInit={(evt, editor) => (editorRef.current = editor)}
apiKey={process.env.NEXT_PUBLIC_API_KEY_TINYMCE}
initialValue={value}
init={{
height: 500,
Expand All @@ -36,4 +40,4 @@ const SSEditor: FC<PropTypes> = ({ value, onSave }) => {
/>
);
};
export default SSEditor;
export default TextEditor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

components thì nên export const, chỉ riêng page là export default thôi

4 changes: 2 additions & 2 deletions src/pages/post/pageposteditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useToast,
} from '@chakra-ui/react';
import { PostList } from '@/components/Post';
import SSEditor from '@/components/SSEditor';
import TextEditor from '@/components/SSEditor';

export default function PagePostEditor() {
const toast = useToast();
Expand Down Expand Up @@ -65,7 +65,7 @@ export default function PagePostEditor() {
>
{published ? 'Công khai' : 'Riêng tư'}
</Checkbox>
<SSEditor onSave={handleSave} />
<TextEditor onSave={handleSave} />
<br />
<Divider />
<PostList />
Expand Down