Tinymce 에디터 폐쇄망 적용
This commit is contained in:
@@ -10,6 +10,9 @@ const App = async ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||
|
||||
return (
|
||||
<html lang="ko" data-theme={theme?.value}>
|
||||
<head>
|
||||
<script src="/tinymce/tinymce.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<AppProvider>{children}</AppProvider>
|
||||
</body>
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { SERVER_API_URL } from "@/shared/config";
|
||||
|
||||
export const editorBaseConfig = {
|
||||
apiKey: process.env.NEXT_PUBLIC_TINY_API_KEY,
|
||||
// 폐쇄망 환경에서는 API 키 없이 자체 호스팅 모드 사용
|
||||
// apiKey: process.env.NEXT_PUBLIC_TINY_API_KEY,
|
||||
// 자체 호스팅 모드 설정 - GPL 라이선스
|
||||
licenseKey: "gpl",
|
||||
init: {
|
||||
language: "ko_KR",
|
||||
language: "ko-KR",
|
||||
height: 500,
|
||||
// 폐쇄망 환경을 위한 설정
|
||||
base_url: "/tinymce",
|
||||
suffix: ".min",
|
||||
plugins: [
|
||||
"advlist",
|
||||
"autolink",
|
||||
@@ -33,5 +39,9 @@ export const editorBaseConfig = {
|
||||
],
|
||||
images_upload_base_path: SERVER_API_URL,
|
||||
file_picker_types: "image",
|
||||
// 폐쇄망 환경을 위한 추가 설정
|
||||
content_css: "/tinymce/skins/content/default/content.min.css",
|
||||
skin: "oxide",
|
||||
theme: "silver",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { useRef } from "react";
|
||||
import {
|
||||
Editor as TinyEditor,
|
||||
type Editor as TinyEditorInstance,
|
||||
type IAllProps,
|
||||
} from "@tinymce/tinymce-react";
|
||||
import { editorBaseConfig as baseConfig } from "../model/editor-base-config";
|
||||
@@ -9,12 +8,12 @@ import { generateFileInfo } from "../lib/generate-file-info";
|
||||
import { EditorApi } from "../api/editor-service";
|
||||
|
||||
const Editor = ({ ...props }: IAllProps) => {
|
||||
const editorRef = useRef<TinyEditorInstance | null>(null);
|
||||
const editorRef = useRef<unknown>(null);
|
||||
|
||||
const imagesUploadHandler = (blobInfo: {
|
||||
blob: () => Blob;
|
||||
filename: () => string;
|
||||
}) => {
|
||||
}): Promise<string> => {
|
||||
return new Promise(async (resolve) => {
|
||||
const fileInfo = await generateFileInfo(blobInfo);
|
||||
const data = await EditorApi.uploadImage(fileInfo);
|
||||
@@ -44,7 +43,7 @@ const Editor = ({ ...props }: IAllProps) => {
|
||||
return (
|
||||
<TinyEditor
|
||||
{...baseConfig}
|
||||
onInit={(_: unknown, editor: TinyEditorInstance) => {
|
||||
onInit={(_, editor) => {
|
||||
editorRef.current = editor;
|
||||
}}
|
||||
init={{
|
||||
@@ -53,6 +52,8 @@ const Editor = ({ ...props }: IAllProps) => {
|
||||
images_upload_handler: imagesUploadHandler,
|
||||
file_picker_callback: filePickerCallback,
|
||||
}}
|
||||
// 폐쇄망 환경에서는 scriptSrc 제거하여 자체 호스팅 모드 사용
|
||||
// scriptSrc="/tinymce/tinymce.min.js"
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user