@lumir-company/editor 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +925 -0
- package/dist/index.d.mts +144 -0
- package/dist/index.d.ts +144 -0
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +427 -0
- package/dist/index.mjs.map +1 -0
- package/dist/style.css +13 -0
- package/package.json +71 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PartialBlock, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, BlockNoteEditor } from '@blocknote/core';
|
|
3
|
+
export { BlockNoteEditor, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from '@blocknote/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LumirEditor에서 사용하는 BlockNote 에디터 타입
|
|
7
|
+
*/
|
|
8
|
+
type EditorType = BlockNoteEditor<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* LumirEditor에서 사용하는 기본 블록 타입
|
|
11
|
+
*/
|
|
12
|
+
type DefaultPartialBlock = PartialBlock<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* LumirEditor 컴포넌트의 Props 인터페이스
|
|
15
|
+
*/
|
|
16
|
+
interface LumirEditorProps {
|
|
17
|
+
initialContent?: DefaultPartialBlock[] | string;
|
|
18
|
+
initialEmptyBlocks?: number;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
uploadFile?: (file: File) => Promise<string>;
|
|
21
|
+
storeImagesAsBase64?: boolean;
|
|
22
|
+
allowVideoUpload?: boolean;
|
|
23
|
+
allowAudioUpload?: boolean;
|
|
24
|
+
allowFileUpload?: boolean;
|
|
25
|
+
pasteHandler?: (ctx: {
|
|
26
|
+
event: ClipboardEvent;
|
|
27
|
+
editor: EditorType;
|
|
28
|
+
defaultPasteHandler: (context?: {
|
|
29
|
+
pasteBehavior?: "prefer-markdown" | "prefer-html";
|
|
30
|
+
}) => boolean | undefined;
|
|
31
|
+
}) => boolean | undefined;
|
|
32
|
+
tables?: {
|
|
33
|
+
splitCells?: boolean;
|
|
34
|
+
cellBackgroundColor?: boolean;
|
|
35
|
+
cellTextColor?: boolean;
|
|
36
|
+
headers?: boolean;
|
|
37
|
+
};
|
|
38
|
+
heading?: {
|
|
39
|
+
levels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
40
|
+
};
|
|
41
|
+
animations?: boolean;
|
|
42
|
+
defaultStyles?: boolean;
|
|
43
|
+
disableExtensions?: string[];
|
|
44
|
+
domAttributes?: Record<string, string>;
|
|
45
|
+
tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
|
|
46
|
+
trailingBlock?: boolean;
|
|
47
|
+
resolveFileUrl?: (url: string) => Promise<string>;
|
|
48
|
+
editable?: boolean;
|
|
49
|
+
theme?: "light" | "dark" | Partial<Record<string, unknown>> | {
|
|
50
|
+
light: Partial<Record<string, unknown>>;
|
|
51
|
+
dark: Partial<Record<string, unknown>>;
|
|
52
|
+
};
|
|
53
|
+
formattingToolbar?: boolean;
|
|
54
|
+
linkToolbar?: boolean;
|
|
55
|
+
sideMenu?: boolean;
|
|
56
|
+
slashMenu?: boolean;
|
|
57
|
+
emojiPicker?: boolean;
|
|
58
|
+
filePanel?: boolean;
|
|
59
|
+
tableHandles?: boolean;
|
|
60
|
+
comments?: boolean;
|
|
61
|
+
onSelectionChange?: () => void;
|
|
62
|
+
className?: string;
|
|
63
|
+
includeDefaultStyles?: boolean;
|
|
64
|
+
sideMenuAddButton?: boolean;
|
|
65
|
+
onContentChange?: (content: DefaultPartialBlock[]) => void;
|
|
66
|
+
editorRef?: React.MutableRefObject<EditorType | null>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 콘텐츠 관리 유틸리티
|
|
71
|
+
* 기본 블록 생성 및 콘텐츠 검증 로직을 담당
|
|
72
|
+
*/
|
|
73
|
+
declare class ContentUtils {
|
|
74
|
+
/**
|
|
75
|
+
* JSON 문자열의 유효성을 검증합니다
|
|
76
|
+
* @param jsonString 검증할 JSON 문자열
|
|
77
|
+
* @returns 유효한 JSON 문자열인지 여부
|
|
78
|
+
*/
|
|
79
|
+
static isValidJSONString(jsonString: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* JSON 문자열을 DefaultPartialBlock 배열로 파싱합니다
|
|
82
|
+
* @param jsonString JSON 문자열
|
|
83
|
+
* @returns 파싱된 블록 배열 또는 null (파싱 실패 시)
|
|
84
|
+
*/
|
|
85
|
+
static parseJSONContent(jsonString: string): DefaultPartialBlock[] | null;
|
|
86
|
+
/**
|
|
87
|
+
* 기본 paragraph 블록 생성
|
|
88
|
+
* @returns 기본 설정이 적용된 DefaultPartialBlock
|
|
89
|
+
*/
|
|
90
|
+
static createDefaultBlock(): DefaultPartialBlock;
|
|
91
|
+
/**
|
|
92
|
+
* 콘텐츠 유효성 검증 및 기본값 설정
|
|
93
|
+
* @param content 사용자 제공 콘텐츠 (객체 배열 또는 JSON 문자열)
|
|
94
|
+
* @param emptyBlockCount 빈 블록 개수 (기본값: 3)
|
|
95
|
+
* @param placeholder 첫 번째 블록의 placeholder 텍스트
|
|
96
|
+
* @returns 검증된 콘텐츠 배열
|
|
97
|
+
*/
|
|
98
|
+
static validateContent(content?: DefaultPartialBlock[] | string, emptyBlockCount?: number, placeholder?: string): DefaultPartialBlock[];
|
|
99
|
+
/**
|
|
100
|
+
* 빈 블록들을 생성합니다
|
|
101
|
+
* @param emptyBlockCount 생성할 블록 개수
|
|
102
|
+
* @param placeholder 첫 번째 블록의 placeholder 텍스트
|
|
103
|
+
* @returns 생성된 빈 블록 배열
|
|
104
|
+
*/
|
|
105
|
+
private static createEmptyBlocks;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 에디터 설정 관리 유틸리티
|
|
109
|
+
* 각종 설정의 기본값과 검증 로직을 담당
|
|
110
|
+
*/
|
|
111
|
+
declare class EditorConfig {
|
|
112
|
+
/**
|
|
113
|
+
* 테이블 설정 기본값 적용
|
|
114
|
+
* @param userTables 사용자 테이블 설정
|
|
115
|
+
* @returns 기본값이 적용된 테이블 설정
|
|
116
|
+
*/
|
|
117
|
+
static getDefaultTableConfig(userTables?: LumirEditorProps["tables"]): {
|
|
118
|
+
splitCells: boolean;
|
|
119
|
+
cellBackgroundColor: boolean;
|
|
120
|
+
cellTextColor: boolean;
|
|
121
|
+
headers: boolean;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 헤딩 설정 기본값 적용
|
|
125
|
+
* @param userHeading 사용자 헤딩 설정
|
|
126
|
+
* @returns 기본값이 적용된 헤딩 설정
|
|
127
|
+
*/
|
|
128
|
+
static getDefaultHeadingConfig(userHeading?: LumirEditorProps["heading"]): {
|
|
129
|
+
levels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 비활성화할 확장 기능 목록 생성
|
|
133
|
+
* @param userExtensions 사용자 정의 비활성 확장
|
|
134
|
+
* @param allowVideo 비디오 업로드 허용 여부
|
|
135
|
+
* @param allowAudio 오디오 업로드 허용 여부
|
|
136
|
+
* @returns 비활성화할 확장 기능 목록
|
|
137
|
+
*/
|
|
138
|
+
static getDisabledExtensions(userExtensions?: string[], allowVideo?: boolean, allowAudio?: boolean): string[];
|
|
139
|
+
}
|
|
140
|
+
declare function LumirEditor({ initialContent, initialEmptyBlocks, placeholder, uploadFile, pasteHandler, tables, heading, animations, defaultStyles, disableExtensions, domAttributes, tabBehavior, trailingBlock, resolveFileUrl, storeImagesAsBase64, allowVideoUpload, allowAudioUpload, allowFileUpload, editable, theme, formattingToolbar, linkToolbar, sideMenu, slashMenu, emojiPicker, filePanel, tableHandles, comments, onSelectionChange, className, includeDefaultStyles, sideMenuAddButton, onContentChange, editorRef, }: LumirEditorProps): react_jsx_runtime.JSX.Element;
|
|
141
|
+
|
|
142
|
+
declare function cn(...inputs: (string | undefined | null | false)[]): string;
|
|
143
|
+
|
|
144
|
+
export { ContentUtils, type DefaultPartialBlock, EditorConfig, type EditorType, LumirEditor, type LumirEditorProps, cn };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PartialBlock, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, BlockNoteEditor } from '@blocknote/core';
|
|
3
|
+
export { BlockNoteEditor, DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema, PartialBlock } from '@blocknote/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* LumirEditor에서 사용하는 BlockNote 에디터 타입
|
|
7
|
+
*/
|
|
8
|
+
type EditorType = BlockNoteEditor<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* LumirEditor에서 사용하는 기본 블록 타입
|
|
11
|
+
*/
|
|
12
|
+
type DefaultPartialBlock = PartialBlock<DefaultBlockSchema, DefaultInlineContentSchema, DefaultStyleSchema>;
|
|
13
|
+
/**
|
|
14
|
+
* LumirEditor 컴포넌트의 Props 인터페이스
|
|
15
|
+
*/
|
|
16
|
+
interface LumirEditorProps {
|
|
17
|
+
initialContent?: DefaultPartialBlock[] | string;
|
|
18
|
+
initialEmptyBlocks?: number;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
uploadFile?: (file: File) => Promise<string>;
|
|
21
|
+
storeImagesAsBase64?: boolean;
|
|
22
|
+
allowVideoUpload?: boolean;
|
|
23
|
+
allowAudioUpload?: boolean;
|
|
24
|
+
allowFileUpload?: boolean;
|
|
25
|
+
pasteHandler?: (ctx: {
|
|
26
|
+
event: ClipboardEvent;
|
|
27
|
+
editor: EditorType;
|
|
28
|
+
defaultPasteHandler: (context?: {
|
|
29
|
+
pasteBehavior?: "prefer-markdown" | "prefer-html";
|
|
30
|
+
}) => boolean | undefined;
|
|
31
|
+
}) => boolean | undefined;
|
|
32
|
+
tables?: {
|
|
33
|
+
splitCells?: boolean;
|
|
34
|
+
cellBackgroundColor?: boolean;
|
|
35
|
+
cellTextColor?: boolean;
|
|
36
|
+
headers?: boolean;
|
|
37
|
+
};
|
|
38
|
+
heading?: {
|
|
39
|
+
levels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
40
|
+
};
|
|
41
|
+
animations?: boolean;
|
|
42
|
+
defaultStyles?: boolean;
|
|
43
|
+
disableExtensions?: string[];
|
|
44
|
+
domAttributes?: Record<string, string>;
|
|
45
|
+
tabBehavior?: "prefer-navigate-ui" | "prefer-indent";
|
|
46
|
+
trailingBlock?: boolean;
|
|
47
|
+
resolveFileUrl?: (url: string) => Promise<string>;
|
|
48
|
+
editable?: boolean;
|
|
49
|
+
theme?: "light" | "dark" | Partial<Record<string, unknown>> | {
|
|
50
|
+
light: Partial<Record<string, unknown>>;
|
|
51
|
+
dark: Partial<Record<string, unknown>>;
|
|
52
|
+
};
|
|
53
|
+
formattingToolbar?: boolean;
|
|
54
|
+
linkToolbar?: boolean;
|
|
55
|
+
sideMenu?: boolean;
|
|
56
|
+
slashMenu?: boolean;
|
|
57
|
+
emojiPicker?: boolean;
|
|
58
|
+
filePanel?: boolean;
|
|
59
|
+
tableHandles?: boolean;
|
|
60
|
+
comments?: boolean;
|
|
61
|
+
onSelectionChange?: () => void;
|
|
62
|
+
className?: string;
|
|
63
|
+
includeDefaultStyles?: boolean;
|
|
64
|
+
sideMenuAddButton?: boolean;
|
|
65
|
+
onContentChange?: (content: DefaultPartialBlock[]) => void;
|
|
66
|
+
editorRef?: React.MutableRefObject<EditorType | null>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 콘텐츠 관리 유틸리티
|
|
71
|
+
* 기본 블록 생성 및 콘텐츠 검증 로직을 담당
|
|
72
|
+
*/
|
|
73
|
+
declare class ContentUtils {
|
|
74
|
+
/**
|
|
75
|
+
* JSON 문자열의 유효성을 검증합니다
|
|
76
|
+
* @param jsonString 검증할 JSON 문자열
|
|
77
|
+
* @returns 유효한 JSON 문자열인지 여부
|
|
78
|
+
*/
|
|
79
|
+
static isValidJSONString(jsonString: string): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* JSON 문자열을 DefaultPartialBlock 배열로 파싱합니다
|
|
82
|
+
* @param jsonString JSON 문자열
|
|
83
|
+
* @returns 파싱된 블록 배열 또는 null (파싱 실패 시)
|
|
84
|
+
*/
|
|
85
|
+
static parseJSONContent(jsonString: string): DefaultPartialBlock[] | null;
|
|
86
|
+
/**
|
|
87
|
+
* 기본 paragraph 블록 생성
|
|
88
|
+
* @returns 기본 설정이 적용된 DefaultPartialBlock
|
|
89
|
+
*/
|
|
90
|
+
static createDefaultBlock(): DefaultPartialBlock;
|
|
91
|
+
/**
|
|
92
|
+
* 콘텐츠 유효성 검증 및 기본값 설정
|
|
93
|
+
* @param content 사용자 제공 콘텐츠 (객체 배열 또는 JSON 문자열)
|
|
94
|
+
* @param emptyBlockCount 빈 블록 개수 (기본값: 3)
|
|
95
|
+
* @param placeholder 첫 번째 블록의 placeholder 텍스트
|
|
96
|
+
* @returns 검증된 콘텐츠 배열
|
|
97
|
+
*/
|
|
98
|
+
static validateContent(content?: DefaultPartialBlock[] | string, emptyBlockCount?: number, placeholder?: string): DefaultPartialBlock[];
|
|
99
|
+
/**
|
|
100
|
+
* 빈 블록들을 생성합니다
|
|
101
|
+
* @param emptyBlockCount 생성할 블록 개수
|
|
102
|
+
* @param placeholder 첫 번째 블록의 placeholder 텍스트
|
|
103
|
+
* @returns 생성된 빈 블록 배열
|
|
104
|
+
*/
|
|
105
|
+
private static createEmptyBlocks;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* 에디터 설정 관리 유틸리티
|
|
109
|
+
* 각종 설정의 기본값과 검증 로직을 담당
|
|
110
|
+
*/
|
|
111
|
+
declare class EditorConfig {
|
|
112
|
+
/**
|
|
113
|
+
* 테이블 설정 기본값 적용
|
|
114
|
+
* @param userTables 사용자 테이블 설정
|
|
115
|
+
* @returns 기본값이 적용된 테이블 설정
|
|
116
|
+
*/
|
|
117
|
+
static getDefaultTableConfig(userTables?: LumirEditorProps["tables"]): {
|
|
118
|
+
splitCells: boolean;
|
|
119
|
+
cellBackgroundColor: boolean;
|
|
120
|
+
cellTextColor: boolean;
|
|
121
|
+
headers: boolean;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 헤딩 설정 기본값 적용
|
|
125
|
+
* @param userHeading 사용자 헤딩 설정
|
|
126
|
+
* @returns 기본값이 적용된 헤딩 설정
|
|
127
|
+
*/
|
|
128
|
+
static getDefaultHeadingConfig(userHeading?: LumirEditorProps["heading"]): {
|
|
129
|
+
levels?: (1 | 2 | 3 | 4 | 5 | 6)[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 비활성화할 확장 기능 목록 생성
|
|
133
|
+
* @param userExtensions 사용자 정의 비활성 확장
|
|
134
|
+
* @param allowVideo 비디오 업로드 허용 여부
|
|
135
|
+
* @param allowAudio 오디오 업로드 허용 여부
|
|
136
|
+
* @returns 비활성화할 확장 기능 목록
|
|
137
|
+
*/
|
|
138
|
+
static getDisabledExtensions(userExtensions?: string[], allowVideo?: boolean, allowAudio?: boolean): string[];
|
|
139
|
+
}
|
|
140
|
+
declare function LumirEditor({ initialContent, initialEmptyBlocks, placeholder, uploadFile, pasteHandler, tables, heading, animations, defaultStyles, disableExtensions, domAttributes, tabBehavior, trailingBlock, resolveFileUrl, storeImagesAsBase64, allowVideoUpload, allowAudioUpload, allowFileUpload, editable, theme, formattingToolbar, linkToolbar, sideMenu, slashMenu, emojiPicker, filePanel, tableHandles, comments, onSelectionChange, className, includeDefaultStyles, sideMenuAddButton, onContentChange, editorRef, }: LumirEditorProps): react_jsx_runtime.JSX.Element;
|
|
141
|
+
|
|
142
|
+
declare function cn(...inputs: (string | undefined | null | false)[]): string;
|
|
143
|
+
|
|
144
|
+
export { ContentUtils, type DefaultPartialBlock, EditorConfig, type EditorType, LumirEditor, type LumirEditorProps, cn };
|