@mindlogic-ai/logician-ui 3.2.0-alpha.5 → 4.0.0-alpha.6
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/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
- package/src/index.ts +0 -1
- package/dist/components/MDXEditor/MDXEditor.d.ts +0 -6
- package/dist/components/MDXEditor/MDXEditor.d.ts.map +0 -1
- package/dist/components/MDXEditor/MDXEditor.js +0 -237
- package/dist/components/MDXEditor/MDXEditor.js.map +0 -1
- package/dist/components/MDXEditor/MDXEditor.mjs +0 -235
- package/dist/components/MDXEditor/MDXEditor.mjs.map +0 -1
- package/dist/components/MDXEditor/MDXEditor.types.d.ts +0 -7
- package/dist/components/MDXEditor/MDXEditor.types.d.ts.map +0 -1
- package/dist/components/MDXEditor/index.d.ts +0 -3
- package/dist/components/MDXEditor/index.d.ts.map +0 -1
- package/src/components/MDXEditor/MDXEditor.css +0 -40
- package/src/components/MDXEditor/MDXEditor.stories.tsx +0 -56
- package/src/components/MDXEditor/MDXEditor.tsx +0 -337
- package/src/components/MDXEditor/MDXEditor.types.ts +0 -7
- package/src/components/MDXEditor/index.ts +0 -2
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,6 @@ export * from './components/LogicianProvider';
|
|
|
35
35
|
export * from './components/Markdown';
|
|
36
36
|
export * from './components/Masonry';
|
|
37
37
|
export * from './components/MaxLengthIndicator';
|
|
38
|
-
export * from './components/MDXEditor';
|
|
39
38
|
export * from './components/Menu';
|
|
40
39
|
export * from './components/Modal';
|
|
41
40
|
export * from './components/MonthPicker';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,c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AAC3C,cAAc,uBAAuB,CAAC;AAGtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAG5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AAEtC,OAAO,EACL,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACF,EAAE,EACF,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,IAAI,GACL,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EACL,MAAM,EACN,KAAK,kBAAkB,EACvB,cAAc,GACf,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -54,7 +54,6 @@ var LogicianProvider = require('./components/LogicianProvider/LogicianProvider.j
|
|
|
54
54
|
var Markdown = require('./components/Markdown/Markdown.js');
|
|
55
55
|
var Masonry = require('./components/Masonry/Masonry.js');
|
|
56
56
|
var MaxLengthIndicator = require('./components/MaxLengthIndicator/MaxLengthIndicator.js');
|
|
57
|
-
var MDXEditor = require('./components/MDXEditor/MDXEditor.js');
|
|
58
57
|
var Menu = require('./components/Menu/Menu.js');
|
|
59
58
|
var MenuItem = require('./components/Menu/MenuItem.js');
|
|
60
59
|
var MenuList = require('./components/Menu/MenuList.js');
|
|
@@ -232,7 +231,6 @@ exports.Markdown = Markdown.Markdown;
|
|
|
232
231
|
exports.baseMarkdownComponents = Markdown.baseMarkdownComponents;
|
|
233
232
|
exports.Masonry = Masonry.Masonry;
|
|
234
233
|
exports.MaxLengthIndicator = MaxLengthIndicator.MaxLengthIndicator;
|
|
235
|
-
exports.MDXEditor = MDXEditor.MDXEditor;
|
|
236
234
|
exports.Menu = Menu.Menu;
|
|
237
235
|
exports.MenuItem = MenuItem.MenuItem;
|
|
238
236
|
exports.MenuList = MenuList.MenuList;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.mjs
CHANGED
|
@@ -52,7 +52,6 @@ export { LogicianProvider } from './components/LogicianProvider/LogicianProvider
|
|
|
52
52
|
export { Markdown, baseMarkdownComponents } from './components/Markdown/Markdown.mjs';
|
|
53
53
|
export { Masonry } from './components/Masonry/Masonry.mjs';
|
|
54
54
|
export { MaxLengthIndicator } from './components/MaxLengthIndicator/MaxLengthIndicator.mjs';
|
|
55
|
-
export { MDXEditor } from './components/MDXEditor/MDXEditor.mjs';
|
|
56
55
|
export { Menu } from './components/Menu/Menu.mjs';
|
|
57
56
|
export { MenuItem } from './components/Menu/MenuItem.mjs';
|
|
58
57
|
export { MenuList } from './components/Menu/MenuList.mjs';
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mindlogic-ai/logician-ui",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.6",
|
|
4
4
|
"description": "A comprehensive React design system built on Chakra UI",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@dagrejs/dagre": "^3.0.0",
|
|
64
|
-
"@mdxeditor/editor": "^3.45.1",
|
|
65
64
|
"@types/lodash": "^4.17.20",
|
|
66
65
|
"@xyflow/react": "^12.10.2",
|
|
67
66
|
"chakra-dayzed-datepicker": "3.0.0",
|
package/src/index.ts
CHANGED
|
@@ -53,7 +53,6 @@ export * from './components/LogicianProvider';
|
|
|
53
53
|
export * from './components/Markdown';
|
|
54
54
|
export * from './components/Masonry';
|
|
55
55
|
export * from './components/MaxLengthIndicator';
|
|
56
|
-
export * from './components/MDXEditor';
|
|
57
56
|
export * from './components/Menu';
|
|
58
57
|
export * from './components/Modal';
|
|
59
58
|
export * from './components/MonthPicker';
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { MDXEditorMethods, MDXEditorProps as BaseEditorProps } from '@mdxeditor/editor';
|
|
2
|
-
import '@mdxeditor/editor/style.css';
|
|
3
|
-
import './MDXEditor.css';
|
|
4
|
-
import type { MDXEditorProps } from './MDXEditor.types';
|
|
5
|
-
export declare const MDXEditor: import("react").ForwardRefExoticComponent<MDXEditorProps & import("react").RefAttributes<BaseEditorProps & MDXEditorMethods>>;
|
|
6
|
-
//# sourceMappingURL=MDXEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MDXEditor.d.ts","sourceRoot":"","sources":["../../../src/components/MDXEditor/MDXEditor.tsx"],"names":[],"mappings":"AAIA,OAAO,EAeL,gBAAgB,EAChB,cAAc,IAAI,eAAe,EAOlC,MAAM,mBAAmB,CAAC;AAE3B,OAAO,6BAA6B,CAAC;AACrC,OAAO,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD,eAAO,MAAM,SAAS,+HA4SpB,CAAC"}
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var react = require('@chakra-ui/react');
|
|
7
|
-
var editor = require('@mdxeditor/editor');
|
|
8
|
-
require('@mdxeditor/editor/style.css');
|
|
9
|
-
|
|
10
|
-
const MDXEditor = React.forwardRef(({ containerProps, autoFocus = true, onError, ...rest }, ref) => {
|
|
11
|
-
const [error, setError] = React.useState(null);
|
|
12
|
-
// Resolve theme tokens to actual values
|
|
13
|
-
const [space1, space2, space4] = react.useToken('spacing', ['1', '2', '4']);
|
|
14
|
-
const [radiusSm] = react.useToken('radii', ['sm']);
|
|
15
|
-
// 내부적으로 Editor 인스턴스를 참조하기 위한 로컬 ref
|
|
16
|
-
const editorRef = React.useRef(null);
|
|
17
|
-
// 부모 컴포넌트로 전달된 ref가 editorRef를 바라보도록 연결
|
|
18
|
-
React.useImperativeHandle(ref, () => editorRef.current, []);
|
|
19
|
-
const handleContainerClick = (e) => {
|
|
20
|
-
// Only focus if clicking on the container itself, not on toolbar and table elements
|
|
21
|
-
const target = e.target;
|
|
22
|
-
const isToolbarClick = target.closest('.mdxeditor-toolbar');
|
|
23
|
-
const isTableClick = target.closest('table');
|
|
24
|
-
const isPopupClick = target.closest('.mdxeditor-popup-container');
|
|
25
|
-
if (!isToolbarClick && !isTableClick && !isPopupClick) {
|
|
26
|
-
editorRef.current?.focus();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
return (jsxRuntime.jsx(react.Box, { width: "100%", height: "100%", borderWidth: "1px", borderRadius: "lg", overflow: "hidden", onClick: handleContainerClick, cursor: "text", ...containerProps, css: {
|
|
30
|
-
/**
|
|
31
|
-
* Chakra v3 css prop styling notes:
|
|
32
|
-
*
|
|
33
|
-
* 1. All nested selectors require '&' prefix (e.g., '& .class', '& h1')
|
|
34
|
-
* 2. Use full CSS property names (background, padding) instead of Chakra
|
|
35
|
-
* shorthand props (bg, p) in nested selectors
|
|
36
|
-
* 3. Color values must be resolved via useToken(), not token strings
|
|
37
|
-
* 4. Font sizes use responsive objects: { base: '2.4em', md: '3em' }
|
|
38
|
-
* 5. List styles must be explicitly defined (listStyleType, etc.)
|
|
39
|
-
*
|
|
40
|
-
* These requirements differ from v2's sx prop, which was more implicit.
|
|
41
|
-
* v3 prioritizes performance and explicitness over automatic handling.
|
|
42
|
-
*/
|
|
43
|
-
...containerProps?.css,
|
|
44
|
-
'& .mdxeditor': {
|
|
45
|
-
width: '100%',
|
|
46
|
-
minHeight: '300px',
|
|
47
|
-
height: '100%',
|
|
48
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
49
|
-
display: 'flex',
|
|
50
|
-
flexDirection: 'column',
|
|
51
|
-
},
|
|
52
|
-
'& .mdxeditor-toolbar': {
|
|
53
|
-
display: 'flex',
|
|
54
|
-
gap: space2,
|
|
55
|
-
padding: space2,
|
|
56
|
-
borderBottomWidth: '1px',
|
|
57
|
-
background: 'var(--chakra-colors-bg-subtle)',
|
|
58
|
-
flexShrink: 0,
|
|
59
|
-
cursor: 'default',
|
|
60
|
-
},
|
|
61
|
-
// Toolbar icons. mdxeditor colors its toolbar svgs with its own
|
|
62
|
-
// `--baseTextContrast` (its internal slate scale), which doesn't follow
|
|
63
|
-
// our color mode — in dark mode they stay near-black (#1c2024) and all
|
|
64
|
-
// but vanish against the dark toolbar. Flip them onto the semantic
|
|
65
|
-
// foreground token so they track light/dark like the editor body text.
|
|
66
|
-
'& .mdxeditor-toolbar svg': {
|
|
67
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
68
|
-
},
|
|
69
|
-
// Disabled toolbar buttons (e.g. undo/redo with nothing to undo) — keep
|
|
70
|
-
// them dimmed but still mode-aware, instead of mdxeditor's light-only
|
|
71
|
-
// border color.
|
|
72
|
-
'& .mdxeditor-toolbar [data-disabled] svg': {
|
|
73
|
-
color: 'var(--chakra-colors-fg-subtle)',
|
|
74
|
-
},
|
|
75
|
-
// Hover / pressed / toggled-on backgrounds. mdxeditor paints these with
|
|
76
|
-
// `--baseBgActive` (its slate scale), which also doesn't track the color
|
|
77
|
-
// mode — in dark mode it goes light-grey, so the now-light icons sit on a
|
|
78
|
-
// light fill and disappear on hover and when a format is active. Flip the
|
|
79
|
-
// fill onto the semantic hover token so it stays mode-aware.
|
|
80
|
-
'& .mdxeditor-toolbar button:hover, & .mdxeditor-toolbar button[data-state="on"], & .mdxeditor-toolbar button:active': {
|
|
81
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
82
|
-
},
|
|
83
|
-
// Block-type select trigger in the toolbar — mdxeditor themes it with
|
|
84
|
-
// its own vars (left white), so flip it onto the semantic surface.
|
|
85
|
-
'& [class*="_selectTrigger_"]': {
|
|
86
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
87
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
88
|
-
},
|
|
89
|
-
// Target the root contenteditable wrapper
|
|
90
|
-
'& [class*="_rootContentEditableWrapper_"]': {
|
|
91
|
-
flex: 1,
|
|
92
|
-
display: 'flex',
|
|
93
|
-
flexDirection: 'column',
|
|
94
|
-
minHeight: 0,
|
|
95
|
-
height: '100%',
|
|
96
|
-
overflow: 'auto',
|
|
97
|
-
},
|
|
98
|
-
// Target the actual contenteditable element
|
|
99
|
-
'& [contenteditable="true"]': {
|
|
100
|
-
flex: 1,
|
|
101
|
-
minHeight: '100%',
|
|
102
|
-
outline: 'none',
|
|
103
|
-
},
|
|
104
|
-
// Target any intermediate wrapper elements
|
|
105
|
-
'& [class*="_contentEditable_"]': {
|
|
106
|
-
flex: 1,
|
|
107
|
-
display: 'flex',
|
|
108
|
-
flexDirection: 'column',
|
|
109
|
-
},
|
|
110
|
-
'& .content-editable': {
|
|
111
|
-
padding: space4,
|
|
112
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
113
|
-
display: 'flex',
|
|
114
|
-
flexDirection: 'column',
|
|
115
|
-
gap: radiusSm,
|
|
116
|
-
flex: 1,
|
|
117
|
-
height: '100%',
|
|
118
|
-
'& h1, & h2, & h3, & h4, & h5': {
|
|
119
|
-
marginBottom: '2px',
|
|
120
|
-
fontWeight: 'bold',
|
|
121
|
-
},
|
|
122
|
-
'& h1:not(:first-child), & h2:not(:first-child), & h3:not(:first-child), & h4:not(:first-child)': {
|
|
123
|
-
marginTop: space1,
|
|
124
|
-
},
|
|
125
|
-
/**
|
|
126
|
-
* Font sizes - Cannot be tokenized due to responsive objects
|
|
127
|
-
*
|
|
128
|
-
* Unlike spacing/radii/colors, fontSize values here are responsive objects
|
|
129
|
-
* { base: '2.4em', md: '3em' } which cannot be stored as regular tokens
|
|
130
|
-
* in Chakra v3. Only textStyles support responsive values, but we cannot
|
|
131
|
-
* extract just the fontSize from textStyles using useToken().
|
|
132
|
-
*
|
|
133
|
-
* These values match theme/index.ts textStyles exactly and must be
|
|
134
|
-
* manually synchronized when updating the theme:
|
|
135
|
-
* - h1: { base: '2.4em', md: '3em' }
|
|
136
|
-
* - h2: { base: '2em', md: '2.5em' }
|
|
137
|
-
* - h3: { base: '1.5em', md: '1.75em' }
|
|
138
|
-
* - h4: { base: '1.25em', md: '1.44em' }
|
|
139
|
-
* - h5: { base: '1.1em', md: '1.2em' }
|
|
140
|
-
*/
|
|
141
|
-
'& h1': {
|
|
142
|
-
fontSize: { base: '2.4em', md: '3em' },
|
|
143
|
-
},
|
|
144
|
-
'& h2': {
|
|
145
|
-
fontSize: { base: '2em', md: '2.5em' },
|
|
146
|
-
},
|
|
147
|
-
'& h3': {
|
|
148
|
-
fontSize: { base: '1.5em', md: '1.75em' },
|
|
149
|
-
},
|
|
150
|
-
'& h4': {
|
|
151
|
-
fontSize: { base: '1.25em', md: '1.44em' },
|
|
152
|
-
},
|
|
153
|
-
'& h5': {
|
|
154
|
-
fontSize: { base: '1.1em', md: '1.2em' },
|
|
155
|
-
},
|
|
156
|
-
/**
|
|
157
|
-
* List styling - IMPORTANT: v3 requires explicit list-style properties
|
|
158
|
-
*
|
|
159
|
-
* In Chakra v2, the `sx` prop automatically preserved browser default list styles.
|
|
160
|
-
* In Chakra v3, the `css` prop is more explicit and performant, but requires
|
|
161
|
-
* manual specification of list styles to override MDXEditor's CSS resets.
|
|
162
|
-
*
|
|
163
|
-
* Required properties:
|
|
164
|
-
* - listStyleType: 'disc' (ul) or 'decimal' (ol) - Shows bullets/numbers
|
|
165
|
-
* - listStylePosition: 'outside' - Places markers outside content box
|
|
166
|
-
* - display: 'list-item' (on li) - Ensures proper list item rendering
|
|
167
|
-
*
|
|
168
|
-
* Why this changed: v3 optimized for speed by removing automatic style inference,
|
|
169
|
-
* requiring more explicit style declarations.
|
|
170
|
-
*/
|
|
171
|
-
'& ul': {
|
|
172
|
-
marginTop: space2,
|
|
173
|
-
paddingInlineStart: space4,
|
|
174
|
-
listStyleType: 'disc',
|
|
175
|
-
listStylePosition: 'outside',
|
|
176
|
-
},
|
|
177
|
-
'& ol': {
|
|
178
|
-
marginTop: space2,
|
|
179
|
-
paddingInlineStart: space4,
|
|
180
|
-
listStyleType: 'decimal',
|
|
181
|
-
listStylePosition: 'outside',
|
|
182
|
-
},
|
|
183
|
-
'& li': {
|
|
184
|
-
lineHeight: '1.5',
|
|
185
|
-
marginBottom: space2,
|
|
186
|
-
display: 'list-item',
|
|
187
|
-
},
|
|
188
|
-
'& blockquote': {
|
|
189
|
-
borderLeftWidth: '4px',
|
|
190
|
-
borderLeftColor: 'var(--chakra-colors-primary-light)',
|
|
191
|
-
background: 'var(--chakra-colors-primary-lighter)',
|
|
192
|
-
paddingLeft: space4,
|
|
193
|
-
paddingBlock: space2,
|
|
194
|
-
marginBlock: space4,
|
|
195
|
-
color: 'var(--chakra-colors-fg-muted)',
|
|
196
|
-
},
|
|
197
|
-
'& a': {
|
|
198
|
-
color: 'var(--chakra-colors-primary-main)',
|
|
199
|
-
textDecoration: 'underline',
|
|
200
|
-
},
|
|
201
|
-
'& code': {
|
|
202
|
-
fontFamily: 'mono',
|
|
203
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
204
|
-
paddingInline: space1,
|
|
205
|
-
borderRadius: radiusSm,
|
|
206
|
-
'& span': {
|
|
207
|
-
background: 'transparent',
|
|
208
|
-
},
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
'& .mdxeditor-diff-source-wrapper': {
|
|
212
|
-
overflow: 'auto',
|
|
213
|
-
},
|
|
214
|
-
}, children: jsxRuntime.jsx(editor.MDXEditor, { ref: editorRef, contentEditableClassName: "content-editable", overlayContainer: typeof document !== 'undefined' ? document.body : undefined, autoFocus: autoFocus, onError: ({ error }) => {
|
|
215
|
-
setError(error);
|
|
216
|
-
onError?.(error);
|
|
217
|
-
}, plugins: [
|
|
218
|
-
editor.headingsPlugin({
|
|
219
|
-
allowedHeadingLevels: [2, 3, 4, 5],
|
|
220
|
-
}),
|
|
221
|
-
editor.linkPlugin(),
|
|
222
|
-
editor.listsPlugin(),
|
|
223
|
-
editor.imagePlugin(),
|
|
224
|
-
editor.quotePlugin(),
|
|
225
|
-
editor.thematicBreakPlugin(),
|
|
226
|
-
editor.markdownShortcutPlugin(),
|
|
227
|
-
editor.tablePlugin(),
|
|
228
|
-
editor.diffSourcePlugin(),
|
|
229
|
-
editor.toolbarPlugin({
|
|
230
|
-
toolbarContents: () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(editor.UndoRedo, {}), jsxRuntime.jsx(editor.Separator, {}), jsxRuntime.jsx(editor.BoldItalicUnderlineToggles, {}), jsxRuntime.jsx(editor.CodeToggle, {}), jsxRuntime.jsx(editor.Separator, {}), jsxRuntime.jsx(editor.ListsToggle, {}), jsxRuntime.jsx(editor.Separator, {}), jsxRuntime.jsx(editor.BlockTypeSelect, {}), jsxRuntime.jsx(editor.Separator, {}), jsxRuntime.jsx(editor.InsertTable, {}), jsxRuntime.jsx(editor.InsertThematicBreak, {}), error && (jsxRuntime.jsx(editor.DiffSourceToggleWrapper, { options: ['rich-text', 'source'], children: jsxRuntime.jsx(jsxRuntime.Fragment, {}) }))] })),
|
|
231
|
-
}),
|
|
232
|
-
], ...rest }) }));
|
|
233
|
-
});
|
|
234
|
-
MDXEditor.displayName = 'MDXEditor';
|
|
235
|
-
|
|
236
|
-
exports.MDXEditor = MDXEditor;
|
|
237
|
-
//# sourceMappingURL=MDXEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MDXEditor.js","sources":["../../../src/components/MDXEditor/MDXEditor.tsx"],"sourcesContent":[null],"names":["forwardRef","useState","useToken","useRef","useImperativeHandle","_jsx","Box","Editor","headingsPlugin","linkPlugin","listsPlugin","imagePlugin","quotePlugin","thematicBreakPlugin","markdownShortcutPlugin","tablePlugin","diffSourcePlugin","toolbarPlugin","_jsxs","_Fragment","UndoRedo","Separator","BoldItalicUnderlineToggles","CodeToggle","ListsToggle","BlockTypeSelect","InsertTable","InsertThematicBreak","DiffSourceToggleWrapper"],"mappings":";;;;;;;;;MAkCa,SAAS,GAAGA,gBAAU,CAGjC,CAAC,EAAE,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,KAAI;IAChE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGC,cAAQ,CAAgB,IAAI,CAAC;;IAGvD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAGC,cAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACrE,IAAA,MAAM,CAAC,QAAQ,CAAC,GAAGA,cAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;;AAG5C,IAAA,MAAM,SAAS,GAAGC,YAAM,CAAqC,IAAI,CAAC;;AAGlE,IAAAC,yBAAmB,CAAC,GAAG,EAAE,MAAM,SAAS,CAAC,OAAQ,EAAE,EAAE,CAAC;AAEtD,IAAA,MAAM,oBAAoB,GAAG,CAAC,CAAmB,KAAI;;AAEnD,QAAA,MAAM,MAAM,GAAG,CAAC,CAAC,MAAqB;QACtC,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC;QAC3D,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAC5C,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,4BAA4B,CAAC;QAEjE,IAAI,CAAC,cAAc,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE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AAA,CAAG,EAEfnB,cAAA,CAACgB,gBAAS,EAAA,EAAA,CAAG,EAEbhB,cAAA,CAACoB,sBAAe,EAAA,EAAA,CAAG,EAEnBpB,cAAA,CAACgB,gBAAS,KAAG,EAEbhB,cAAA,CAACqB,kBAAW,EAAA,EAAA,CAAG,EAEfrB,cAAA,CAACsB,0BAAmB,EAAA,EAAA,CAAG,EAKtB,KAAK,KACJtB,cAAA,CAACuB,8BAAuB,EAAA,EAAC,OAAO,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAA,QAAA,EACvDvB,cAAA,CAAAc,mBAAA,EAAA,EAAA,CAAK,EAAA,CACmB,CAC3B,IACA,CACJ;iBACF,CAAC;AACH,aAAA,EAAA,GACG,IAAI,EAAA,CACR,EAAA,CACE;AAEV,CAAC;AAED,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import { forwardRef, useState, useRef, useImperativeHandle } from 'react';
|
|
4
|
-
import { useToken, Box } from '@chakra-ui/react';
|
|
5
|
-
import { MDXEditor as MDXEditor$1, headingsPlugin, linkPlugin, listsPlugin, imagePlugin, quotePlugin, thematicBreakPlugin, markdownShortcutPlugin, tablePlugin, diffSourcePlugin, toolbarPlugin, UndoRedo, Separator, BoldItalicUnderlineToggles, CodeToggle, ListsToggle, BlockTypeSelect, InsertTable, InsertThematicBreak, DiffSourceToggleWrapper } from '@mdxeditor/editor';
|
|
6
|
-
import '@mdxeditor/editor/style.css';
|
|
7
|
-
|
|
8
|
-
const MDXEditor = forwardRef(({ containerProps, autoFocus = true, onError, ...rest }, ref) => {
|
|
9
|
-
const [error, setError] = useState(null);
|
|
10
|
-
// Resolve theme tokens to actual values
|
|
11
|
-
const [space1, space2, space4] = useToken('spacing', ['1', '2', '4']);
|
|
12
|
-
const [radiusSm] = useToken('radii', ['sm']);
|
|
13
|
-
// 내부적으로 Editor 인스턴스를 참조하기 위한 로컬 ref
|
|
14
|
-
const editorRef = useRef(null);
|
|
15
|
-
// 부모 컴포넌트로 전달된 ref가 editorRef를 바라보도록 연결
|
|
16
|
-
useImperativeHandle(ref, () => editorRef.current, []);
|
|
17
|
-
const handleContainerClick = (e) => {
|
|
18
|
-
// Only focus if clicking on the container itself, not on toolbar and table elements
|
|
19
|
-
const target = e.target;
|
|
20
|
-
const isToolbarClick = target.closest('.mdxeditor-toolbar');
|
|
21
|
-
const isTableClick = target.closest('table');
|
|
22
|
-
const isPopupClick = target.closest('.mdxeditor-popup-container');
|
|
23
|
-
if (!isToolbarClick && !isTableClick && !isPopupClick) {
|
|
24
|
-
editorRef.current?.focus();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
return (jsx(Box, { width: "100%", height: "100%", borderWidth: "1px", borderRadius: "lg", overflow: "hidden", onClick: handleContainerClick, cursor: "text", ...containerProps, css: {
|
|
28
|
-
/**
|
|
29
|
-
* Chakra v3 css prop styling notes:
|
|
30
|
-
*
|
|
31
|
-
* 1. All nested selectors require '&' prefix (e.g., '& .class', '& h1')
|
|
32
|
-
* 2. Use full CSS property names (background, padding) instead of Chakra
|
|
33
|
-
* shorthand props (bg, p) in nested selectors
|
|
34
|
-
* 3. Color values must be resolved via useToken(), not token strings
|
|
35
|
-
* 4. Font sizes use responsive objects: { base: '2.4em', md: '3em' }
|
|
36
|
-
* 5. List styles must be explicitly defined (listStyleType, etc.)
|
|
37
|
-
*
|
|
38
|
-
* These requirements differ from v2's sx prop, which was more implicit.
|
|
39
|
-
* v3 prioritizes performance and explicitness over automatic handling.
|
|
40
|
-
*/
|
|
41
|
-
...containerProps?.css,
|
|
42
|
-
'& .mdxeditor': {
|
|
43
|
-
width: '100%',
|
|
44
|
-
minHeight: '300px',
|
|
45
|
-
height: '100%',
|
|
46
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
47
|
-
display: 'flex',
|
|
48
|
-
flexDirection: 'column',
|
|
49
|
-
},
|
|
50
|
-
'& .mdxeditor-toolbar': {
|
|
51
|
-
display: 'flex',
|
|
52
|
-
gap: space2,
|
|
53
|
-
padding: space2,
|
|
54
|
-
borderBottomWidth: '1px',
|
|
55
|
-
background: 'var(--chakra-colors-bg-subtle)',
|
|
56
|
-
flexShrink: 0,
|
|
57
|
-
cursor: 'default',
|
|
58
|
-
},
|
|
59
|
-
// Toolbar icons. mdxeditor colors its toolbar svgs with its own
|
|
60
|
-
// `--baseTextContrast` (its internal slate scale), which doesn't follow
|
|
61
|
-
// our color mode — in dark mode they stay near-black (#1c2024) and all
|
|
62
|
-
// but vanish against the dark toolbar. Flip them onto the semantic
|
|
63
|
-
// foreground token so they track light/dark like the editor body text.
|
|
64
|
-
'& .mdxeditor-toolbar svg': {
|
|
65
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
66
|
-
},
|
|
67
|
-
// Disabled toolbar buttons (e.g. undo/redo with nothing to undo) — keep
|
|
68
|
-
// them dimmed but still mode-aware, instead of mdxeditor's light-only
|
|
69
|
-
// border color.
|
|
70
|
-
'& .mdxeditor-toolbar [data-disabled] svg': {
|
|
71
|
-
color: 'var(--chakra-colors-fg-subtle)',
|
|
72
|
-
},
|
|
73
|
-
// Hover / pressed / toggled-on backgrounds. mdxeditor paints these with
|
|
74
|
-
// `--baseBgActive` (its slate scale), which also doesn't track the color
|
|
75
|
-
// mode — in dark mode it goes light-grey, so the now-light icons sit on a
|
|
76
|
-
// light fill and disappear on hover and when a format is active. Flip the
|
|
77
|
-
// fill onto the semantic hover token so it stays mode-aware.
|
|
78
|
-
'& .mdxeditor-toolbar button:hover, & .mdxeditor-toolbar button[data-state="on"], & .mdxeditor-toolbar button:active': {
|
|
79
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
80
|
-
},
|
|
81
|
-
// Block-type select trigger in the toolbar — mdxeditor themes it with
|
|
82
|
-
// its own vars (left white), so flip it onto the semantic surface.
|
|
83
|
-
'& [class*="_selectTrigger_"]': {
|
|
84
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
85
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
86
|
-
},
|
|
87
|
-
// Target the root contenteditable wrapper
|
|
88
|
-
'& [class*="_rootContentEditableWrapper_"]': {
|
|
89
|
-
flex: 1,
|
|
90
|
-
display: 'flex',
|
|
91
|
-
flexDirection: 'column',
|
|
92
|
-
minHeight: 0,
|
|
93
|
-
height: '100%',
|
|
94
|
-
overflow: 'auto',
|
|
95
|
-
},
|
|
96
|
-
// Target the actual contenteditable element
|
|
97
|
-
'& [contenteditable="true"]': {
|
|
98
|
-
flex: 1,
|
|
99
|
-
minHeight: '100%',
|
|
100
|
-
outline: 'none',
|
|
101
|
-
},
|
|
102
|
-
// Target any intermediate wrapper elements
|
|
103
|
-
'& [class*="_contentEditable_"]': {
|
|
104
|
-
flex: 1,
|
|
105
|
-
display: 'flex',
|
|
106
|
-
flexDirection: 'column',
|
|
107
|
-
},
|
|
108
|
-
'& .content-editable': {
|
|
109
|
-
padding: space4,
|
|
110
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
111
|
-
display: 'flex',
|
|
112
|
-
flexDirection: 'column',
|
|
113
|
-
gap: radiusSm,
|
|
114
|
-
flex: 1,
|
|
115
|
-
height: '100%',
|
|
116
|
-
'& h1, & h2, & h3, & h4, & h5': {
|
|
117
|
-
marginBottom: '2px',
|
|
118
|
-
fontWeight: 'bold',
|
|
119
|
-
},
|
|
120
|
-
'& h1:not(:first-child), & h2:not(:first-child), & h3:not(:first-child), & h4:not(:first-child)': {
|
|
121
|
-
marginTop: space1,
|
|
122
|
-
},
|
|
123
|
-
/**
|
|
124
|
-
* Font sizes - Cannot be tokenized due to responsive objects
|
|
125
|
-
*
|
|
126
|
-
* Unlike spacing/radii/colors, fontSize values here are responsive objects
|
|
127
|
-
* { base: '2.4em', md: '3em' } which cannot be stored as regular tokens
|
|
128
|
-
* in Chakra v3. Only textStyles support responsive values, but we cannot
|
|
129
|
-
* extract just the fontSize from textStyles using useToken().
|
|
130
|
-
*
|
|
131
|
-
* These values match theme/index.ts textStyles exactly and must be
|
|
132
|
-
* manually synchronized when updating the theme:
|
|
133
|
-
* - h1: { base: '2.4em', md: '3em' }
|
|
134
|
-
* - h2: { base: '2em', md: '2.5em' }
|
|
135
|
-
* - h3: { base: '1.5em', md: '1.75em' }
|
|
136
|
-
* - h4: { base: '1.25em', md: '1.44em' }
|
|
137
|
-
* - h5: { base: '1.1em', md: '1.2em' }
|
|
138
|
-
*/
|
|
139
|
-
'& h1': {
|
|
140
|
-
fontSize: { base: '2.4em', md: '3em' },
|
|
141
|
-
},
|
|
142
|
-
'& h2': {
|
|
143
|
-
fontSize: { base: '2em', md: '2.5em' },
|
|
144
|
-
},
|
|
145
|
-
'& h3': {
|
|
146
|
-
fontSize: { base: '1.5em', md: '1.75em' },
|
|
147
|
-
},
|
|
148
|
-
'& h4': {
|
|
149
|
-
fontSize: { base: '1.25em', md: '1.44em' },
|
|
150
|
-
},
|
|
151
|
-
'& h5': {
|
|
152
|
-
fontSize: { base: '1.1em', md: '1.2em' },
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* List styling - IMPORTANT: v3 requires explicit list-style properties
|
|
156
|
-
*
|
|
157
|
-
* In Chakra v2, the `sx` prop automatically preserved browser default list styles.
|
|
158
|
-
* In Chakra v3, the `css` prop is more explicit and performant, but requires
|
|
159
|
-
* manual specification of list styles to override MDXEditor's CSS resets.
|
|
160
|
-
*
|
|
161
|
-
* Required properties:
|
|
162
|
-
* - listStyleType: 'disc' (ul) or 'decimal' (ol) - Shows bullets/numbers
|
|
163
|
-
* - listStylePosition: 'outside' - Places markers outside content box
|
|
164
|
-
* - display: 'list-item' (on li) - Ensures proper list item rendering
|
|
165
|
-
*
|
|
166
|
-
* Why this changed: v3 optimized for speed by removing automatic style inference,
|
|
167
|
-
* requiring more explicit style declarations.
|
|
168
|
-
*/
|
|
169
|
-
'& ul': {
|
|
170
|
-
marginTop: space2,
|
|
171
|
-
paddingInlineStart: space4,
|
|
172
|
-
listStyleType: 'disc',
|
|
173
|
-
listStylePosition: 'outside',
|
|
174
|
-
},
|
|
175
|
-
'& ol': {
|
|
176
|
-
marginTop: space2,
|
|
177
|
-
paddingInlineStart: space4,
|
|
178
|
-
listStyleType: 'decimal',
|
|
179
|
-
listStylePosition: 'outside',
|
|
180
|
-
},
|
|
181
|
-
'& li': {
|
|
182
|
-
lineHeight: '1.5',
|
|
183
|
-
marginBottom: space2,
|
|
184
|
-
display: 'list-item',
|
|
185
|
-
},
|
|
186
|
-
'& blockquote': {
|
|
187
|
-
borderLeftWidth: '4px',
|
|
188
|
-
borderLeftColor: 'var(--chakra-colors-primary-light)',
|
|
189
|
-
background: 'var(--chakra-colors-primary-lighter)',
|
|
190
|
-
paddingLeft: space4,
|
|
191
|
-
paddingBlock: space2,
|
|
192
|
-
marginBlock: space4,
|
|
193
|
-
color: 'var(--chakra-colors-fg-muted)',
|
|
194
|
-
},
|
|
195
|
-
'& a': {
|
|
196
|
-
color: 'var(--chakra-colors-primary-main)',
|
|
197
|
-
textDecoration: 'underline',
|
|
198
|
-
},
|
|
199
|
-
'& code': {
|
|
200
|
-
fontFamily: 'mono',
|
|
201
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
202
|
-
paddingInline: space1,
|
|
203
|
-
borderRadius: radiusSm,
|
|
204
|
-
'& span': {
|
|
205
|
-
background: 'transparent',
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
},
|
|
209
|
-
'& .mdxeditor-diff-source-wrapper': {
|
|
210
|
-
overflow: 'auto',
|
|
211
|
-
},
|
|
212
|
-
}, children: jsx(MDXEditor$1, { ref: editorRef, contentEditableClassName: "content-editable", overlayContainer: typeof document !== 'undefined' ? document.body : undefined, autoFocus: autoFocus, onError: ({ error }) => {
|
|
213
|
-
setError(error);
|
|
214
|
-
onError?.(error);
|
|
215
|
-
}, plugins: [
|
|
216
|
-
headingsPlugin({
|
|
217
|
-
allowedHeadingLevels: [2, 3, 4, 5],
|
|
218
|
-
}),
|
|
219
|
-
linkPlugin(),
|
|
220
|
-
listsPlugin(),
|
|
221
|
-
imagePlugin(),
|
|
222
|
-
quotePlugin(),
|
|
223
|
-
thematicBreakPlugin(),
|
|
224
|
-
markdownShortcutPlugin(),
|
|
225
|
-
tablePlugin(),
|
|
226
|
-
diffSourcePlugin(),
|
|
227
|
-
toolbarPlugin({
|
|
228
|
-
toolbarContents: () => (jsxs(Fragment, { children: [jsx(UndoRedo, {}), jsx(Separator, {}), jsx(BoldItalicUnderlineToggles, {}), jsx(CodeToggle, {}), jsx(Separator, {}), jsx(ListsToggle, {}), jsx(Separator, {}), jsx(BlockTypeSelect, {}), jsx(Separator, {}), jsx(InsertTable, {}), jsx(InsertThematicBreak, {}), error && (jsx(DiffSourceToggleWrapper, { options: ['rich-text', 'source'], children: jsx(Fragment, {}) }))] })),
|
|
229
|
-
}),
|
|
230
|
-
], ...rest }) }));
|
|
231
|
-
});
|
|
232
|
-
MDXEditor.displayName = 'MDXEditor';
|
|
233
|
-
|
|
234
|
-
export { MDXEditor };
|
|
235
|
-
//# sourceMappingURL=MDXEditor.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MDXEditor.mjs","sources":["../../../src/components/MDXEditor/MDXEditor.tsx"],"sourcesContent":[null],"names":["_jsx","Editor","_jsxs","_Fragment"],"mappings":";;;;;;;MAkCa,SAAS,GAAG,UAAU,CAGjC,CAAC,EAAE,cAAc,EAAE,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG,KAAI;IAChE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC;;IAGvD,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AACrE,IAAA,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AAA,UAAU,EAAE;AACZ,gBAAA,WAAW,EAAE;AACb,gBAAA,WAAW,EAAE;AACb,gBAAA,WAAW,EAAE;AACb,gBAAA,mBAAmB,EAAE;AACrB,gBAAA,sBAAsB,EAAE;AACxB,gBAAA,WAAW,EAAE;AACb,gBAAA,gBAAgB,EAAE;AAClB,gBAAA,aAAa,CAAC;AACZ,oBAAA,eAAe,EAAE,OACfC,IAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAA,CACEH,GAAA,CAAC,QAAQ,EAAA,EAAA,CAAG,EAEZA,GAAA,CAAC,SAAS,EAAA,EAAA,CAAG,EAEbA,GAAA,CAAC,0BAA0B,EAAA,EAAA,CAAG,EAC9BA,GAAA,CAAC,UAAU,EAAA,EAAA,CAAG,EAEdA,IAAC,SAAS,EAAA,EAAA,CAAG,EAEbA,GAAA,CAAC,WAAW,EAAA,EAAA,CAAG,EAEfA,GAAA,CAAC,SAAS,EAAA,EAAA,CAAG,EAEbA,GAAA,CAAC,eAAe,EAAA,EAAA,CAAG,EAEnBA,GAAA,CAAC,SAAS,KAAG,EAEbA,GAAA,CAAC,WAAW,EAAA,EAAA,CAAG,EAEfA,GAAA,CAAC,mBAAmB,EAAA,EAAA,CAAG,EAKtB,KAAK,KACJA,GAAA,CAAC,uBAAuB,EAAA,EAAC,OAAO,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,EAAA,QAAA,EACvDA,GAAA,CAAAG,QAAA,EAAA,EAAA,CAAK,EAAA,CACmB,CAC3B,IACA,CACJ;iBACF,CAAC;AACH,aAAA,EAAA,GACG,IAAI,EAAA,CACR,EAAA,CACE;AAEV,CAAC;AAED,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { BoxProps } from '@chakra-ui/react';
|
|
2
|
-
import { MDXEditorProps as BaseEditorProps } from '@mdxeditor/editor';
|
|
3
|
-
export interface MDXEditorProps extends Omit<BaseEditorProps, 'onError'> {
|
|
4
|
-
containerProps?: BoxProps;
|
|
5
|
-
onError?: (error: string) => void;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=MDXEditor.types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MDXEditor.types.d.ts","sourceRoot":"","sources":["../../../src/components/MDXEditor/MDXEditor.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,eAAe,EAAE,SAAS,CAAC;IACtE,cAAc,CAAC,EAAE,QAAQ,CAAC;IAC1B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/MDXEditor/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/* MDXEditor popup container overrides */
|
|
2
|
-
[class*='_popupContainer_'] {
|
|
3
|
-
z-index: 9999 !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.mdxeditor-popup-container {
|
|
7
|
-
z-index: 9999 !important;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/* MDXEditor select content overrides */
|
|
11
|
-
[class*='_selectContent_'] {
|
|
12
|
-
z-index: 9999 !important;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.mdxeditor-select-content {
|
|
16
|
-
z-index: 9999 !important;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
[data-radix-select-content] {
|
|
20
|
-
z-index: 9999 !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/*
|
|
24
|
-
* Block-type select dropdown popup. It's portaled outside `.mdxeditor`, so the
|
|
25
|
-
* scoped css prop can't reach it — flip its surface/text/highlight onto the
|
|
26
|
-
* semantic tokens here (they resolve per color mode via the `.dark` class).
|
|
27
|
-
*/
|
|
28
|
-
.mdxeditor-select-content {
|
|
29
|
-
background: var(--chakra-colors-bg-surface) !important;
|
|
30
|
-
color: var(--chakra-colors-fg-default);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.mdxeditor-select-content [class*='_selectItem_'] {
|
|
34
|
-
color: var(--chakra-colors-fg-default);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.mdxeditor-select-content [class*='_selectItem_'][data-highlighted],
|
|
38
|
-
.mdxeditor-select-content [class*='_selectItem_']:hover {
|
|
39
|
-
background: var(--chakra-colors-bg-muted) !important;
|
|
40
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { MDXEditor } from './MDXEditor';
|
|
4
|
-
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Components/MDXEditor',
|
|
7
|
-
component: MDXEditor,
|
|
8
|
-
tags: ['autodocs'],
|
|
9
|
-
} satisfies Meta<typeof MDXEditor>;
|
|
10
|
-
|
|
11
|
-
export default meta;
|
|
12
|
-
|
|
13
|
-
type Story = StoryObj<typeof MDXEditor>;
|
|
14
|
-
|
|
15
|
-
const sampleMarkdown = `# Hello World
|
|
16
|
-
This is a sample markdown text. You can:
|
|
17
|
-
- Make lists
|
|
18
|
-
- **Bold text**
|
|
19
|
-
- *Italic text*
|
|
20
|
-
- Create [links](https://example.com)
|
|
21
|
-
## Second Level Heading
|
|
22
|
-
> This is a blockquote
|
|
23
|
-
1. Numbered lists
|
|
24
|
-
2. Work too!
|
|
25
|
-
---
|
|
26
|
-
### Try the editor out!
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const sampleMarkdownWithError = `
|
|
30
|
-
Sample Link (<https://example.com>)
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
export const Default: Story = {
|
|
34
|
-
args: {
|
|
35
|
-
markdown: sampleMarkdown,
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const Empty: Story = {
|
|
40
|
-
args: {
|
|
41
|
-
markdown: '',
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const WithPlaceholder: Story = {
|
|
46
|
-
args: {
|
|
47
|
-
markdown: '',
|
|
48
|
-
placeholder: '마크다운을 입력해보세요...',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export const Error: Story = {
|
|
53
|
-
args: {
|
|
54
|
-
markdown: sampleMarkdownWithError,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
|
|
4
|
-
import { Box, useToken } from '@chakra-ui/react';
|
|
5
|
-
import {
|
|
6
|
-
BlockTypeSelect,
|
|
7
|
-
BoldItalicUnderlineToggles,
|
|
8
|
-
CodeToggle,
|
|
9
|
-
diffSourcePlugin,
|
|
10
|
-
DiffSourceToggleWrapper,
|
|
11
|
-
headingsPlugin,
|
|
12
|
-
imagePlugin,
|
|
13
|
-
InsertTable,
|
|
14
|
-
InsertThematicBreak,
|
|
15
|
-
linkPlugin,
|
|
16
|
-
listsPlugin,
|
|
17
|
-
ListsToggle,
|
|
18
|
-
markdownShortcutPlugin,
|
|
19
|
-
MDXEditor as Editor,
|
|
20
|
-
MDXEditorMethods,
|
|
21
|
-
MDXEditorProps as BaseEditorProps,
|
|
22
|
-
quotePlugin,
|
|
23
|
-
Separator,
|
|
24
|
-
tablePlugin,
|
|
25
|
-
thematicBreakPlugin,
|
|
26
|
-
toolbarPlugin,
|
|
27
|
-
UndoRedo,
|
|
28
|
-
} from '@mdxeditor/editor';
|
|
29
|
-
|
|
30
|
-
import '@mdxeditor/editor/style.css';
|
|
31
|
-
import './MDXEditor.css';
|
|
32
|
-
|
|
33
|
-
import type { MDXEditorProps } from './MDXEditor.types';
|
|
34
|
-
|
|
35
|
-
export const MDXEditor = forwardRef<
|
|
36
|
-
BaseEditorProps & MDXEditorMethods,
|
|
37
|
-
MDXEditorProps
|
|
38
|
-
>(({ containerProps, autoFocus = true, onError, ...rest }, ref) => {
|
|
39
|
-
const [error, setError] = useState<string | null>(null);
|
|
40
|
-
|
|
41
|
-
// Resolve theme tokens to actual values
|
|
42
|
-
const [space1, space2, space4] = useToken('spacing', ['1', '2', '4']);
|
|
43
|
-
const [radiusSm] = useToken('radii', ['sm']);
|
|
44
|
-
|
|
45
|
-
// 내부적으로 Editor 인스턴스를 참조하기 위한 로컬 ref
|
|
46
|
-
const editorRef = useRef<BaseEditorProps & MDXEditorMethods>(null);
|
|
47
|
-
|
|
48
|
-
// 부모 컴포넌트로 전달된 ref가 editorRef를 바라보도록 연결
|
|
49
|
-
useImperativeHandle(ref, () => editorRef.current!, []);
|
|
50
|
-
|
|
51
|
-
const handleContainerClick = (e: React.MouseEvent) => {
|
|
52
|
-
// Only focus if clicking on the container itself, not on toolbar and table elements
|
|
53
|
-
const target = e.target as HTMLElement;
|
|
54
|
-
const isToolbarClick = target.closest('.mdxeditor-toolbar');
|
|
55
|
-
const isTableClick = target.closest('table');
|
|
56
|
-
const isPopupClick = target.closest('.mdxeditor-popup-container');
|
|
57
|
-
|
|
58
|
-
if (!isToolbarClick && !isTableClick && !isPopupClick) {
|
|
59
|
-
editorRef.current?.focus();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Box
|
|
65
|
-
width="100%"
|
|
66
|
-
height="100%"
|
|
67
|
-
borderWidth="1px"
|
|
68
|
-
borderRadius="lg"
|
|
69
|
-
overflow="hidden"
|
|
70
|
-
onClick={handleContainerClick}
|
|
71
|
-
cursor="text"
|
|
72
|
-
{...containerProps}
|
|
73
|
-
css={{
|
|
74
|
-
/**
|
|
75
|
-
* Chakra v3 css prop styling notes:
|
|
76
|
-
*
|
|
77
|
-
* 1. All nested selectors require '&' prefix (e.g., '& .class', '& h1')
|
|
78
|
-
* 2. Use full CSS property names (background, padding) instead of Chakra
|
|
79
|
-
* shorthand props (bg, p) in nested selectors
|
|
80
|
-
* 3. Color values must be resolved via useToken(), not token strings
|
|
81
|
-
* 4. Font sizes use responsive objects: { base: '2.4em', md: '3em' }
|
|
82
|
-
* 5. List styles must be explicitly defined (listStyleType, etc.)
|
|
83
|
-
*
|
|
84
|
-
* These requirements differ from v2's sx prop, which was more implicit.
|
|
85
|
-
* v3 prioritizes performance and explicitness over automatic handling.
|
|
86
|
-
*/
|
|
87
|
-
...containerProps?.css,
|
|
88
|
-
'& .mdxeditor': {
|
|
89
|
-
width: '100%',
|
|
90
|
-
minHeight: '300px',
|
|
91
|
-
height: '100%',
|
|
92
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
93
|
-
display: 'flex',
|
|
94
|
-
flexDirection: 'column',
|
|
95
|
-
},
|
|
96
|
-
'& .mdxeditor-toolbar': {
|
|
97
|
-
display: 'flex',
|
|
98
|
-
gap: space2,
|
|
99
|
-
padding: space2,
|
|
100
|
-
borderBottomWidth: '1px',
|
|
101
|
-
background: 'var(--chakra-colors-bg-subtle)',
|
|
102
|
-
flexShrink: 0,
|
|
103
|
-
cursor: 'default',
|
|
104
|
-
},
|
|
105
|
-
// Toolbar icons. mdxeditor colors its toolbar svgs with its own
|
|
106
|
-
// `--baseTextContrast` (its internal slate scale), which doesn't follow
|
|
107
|
-
// our color mode — in dark mode they stay near-black (#1c2024) and all
|
|
108
|
-
// but vanish against the dark toolbar. Flip them onto the semantic
|
|
109
|
-
// foreground token so they track light/dark like the editor body text.
|
|
110
|
-
'& .mdxeditor-toolbar svg': {
|
|
111
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
112
|
-
},
|
|
113
|
-
// Disabled toolbar buttons (e.g. undo/redo with nothing to undo) — keep
|
|
114
|
-
// them dimmed but still mode-aware, instead of mdxeditor's light-only
|
|
115
|
-
// border color.
|
|
116
|
-
'& .mdxeditor-toolbar [data-disabled] svg': {
|
|
117
|
-
color: 'var(--chakra-colors-fg-subtle)',
|
|
118
|
-
},
|
|
119
|
-
// Hover / pressed / toggled-on backgrounds. mdxeditor paints these with
|
|
120
|
-
// `--baseBgActive` (its slate scale), which also doesn't track the color
|
|
121
|
-
// mode — in dark mode it goes light-grey, so the now-light icons sit on a
|
|
122
|
-
// light fill and disappear on hover and when a format is active. Flip the
|
|
123
|
-
// fill onto the semantic hover token so it stays mode-aware.
|
|
124
|
-
'& .mdxeditor-toolbar button:hover, & .mdxeditor-toolbar button[data-state="on"], & .mdxeditor-toolbar button:active':
|
|
125
|
-
{
|
|
126
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
127
|
-
},
|
|
128
|
-
// Block-type select trigger in the toolbar — mdxeditor themes it with
|
|
129
|
-
// its own vars (left white), so flip it onto the semantic surface.
|
|
130
|
-
'& [class*="_selectTrigger_"]': {
|
|
131
|
-
background: 'var(--chakra-colors-bg-surface)',
|
|
132
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
133
|
-
},
|
|
134
|
-
// Target the root contenteditable wrapper
|
|
135
|
-
'& [class*="_rootContentEditableWrapper_"]': {
|
|
136
|
-
flex: 1,
|
|
137
|
-
display: 'flex',
|
|
138
|
-
flexDirection: 'column',
|
|
139
|
-
minHeight: 0,
|
|
140
|
-
height: '100%',
|
|
141
|
-
overflow: 'auto',
|
|
142
|
-
},
|
|
143
|
-
// Target the actual contenteditable element
|
|
144
|
-
'& [contenteditable="true"]': {
|
|
145
|
-
flex: 1,
|
|
146
|
-
minHeight: '100%',
|
|
147
|
-
outline: 'none',
|
|
148
|
-
},
|
|
149
|
-
// Target any intermediate wrapper elements
|
|
150
|
-
'& [class*="_contentEditable_"]': {
|
|
151
|
-
flex: 1,
|
|
152
|
-
display: 'flex',
|
|
153
|
-
flexDirection: 'column',
|
|
154
|
-
},
|
|
155
|
-
'& .content-editable': {
|
|
156
|
-
padding: space4,
|
|
157
|
-
color: 'var(--chakra-colors-fg-default)',
|
|
158
|
-
display: 'flex',
|
|
159
|
-
flexDirection: 'column',
|
|
160
|
-
gap: radiusSm,
|
|
161
|
-
flex: 1,
|
|
162
|
-
height: '100%',
|
|
163
|
-
|
|
164
|
-
'& h1, & h2, & h3, & h4, & h5': {
|
|
165
|
-
marginBottom: '2px',
|
|
166
|
-
fontWeight: 'bold',
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
'& h1:not(:first-child), & h2:not(:first-child), & h3:not(:first-child), & h4:not(:first-child)':
|
|
170
|
-
{
|
|
171
|
-
marginTop: space1,
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Font sizes - Cannot be tokenized due to responsive objects
|
|
176
|
-
*
|
|
177
|
-
* Unlike spacing/radii/colors, fontSize values here are responsive objects
|
|
178
|
-
* { base: '2.4em', md: '3em' } which cannot be stored as regular tokens
|
|
179
|
-
* in Chakra v3. Only textStyles support responsive values, but we cannot
|
|
180
|
-
* extract just the fontSize from textStyles using useToken().
|
|
181
|
-
*
|
|
182
|
-
* These values match theme/index.ts textStyles exactly and must be
|
|
183
|
-
* manually synchronized when updating the theme:
|
|
184
|
-
* - h1: { base: '2.4em', md: '3em' }
|
|
185
|
-
* - h2: { base: '2em', md: '2.5em' }
|
|
186
|
-
* - h3: { base: '1.5em', md: '1.75em' }
|
|
187
|
-
* - h4: { base: '1.25em', md: '1.44em' }
|
|
188
|
-
* - h5: { base: '1.1em', md: '1.2em' }
|
|
189
|
-
*/
|
|
190
|
-
'& h1': {
|
|
191
|
-
fontSize: { base: '2.4em', md: '3em' },
|
|
192
|
-
},
|
|
193
|
-
'& h2': {
|
|
194
|
-
fontSize: { base: '2em', md: '2.5em' },
|
|
195
|
-
},
|
|
196
|
-
'& h3': {
|
|
197
|
-
fontSize: { base: '1.5em', md: '1.75em' },
|
|
198
|
-
},
|
|
199
|
-
'& h4': {
|
|
200
|
-
fontSize: { base: '1.25em', md: '1.44em' },
|
|
201
|
-
},
|
|
202
|
-
'& h5': {
|
|
203
|
-
fontSize: { base: '1.1em', md: '1.2em' },
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* List styling - IMPORTANT: v3 requires explicit list-style properties
|
|
208
|
-
*
|
|
209
|
-
* In Chakra v2, the `sx` prop automatically preserved browser default list styles.
|
|
210
|
-
* In Chakra v3, the `css` prop is more explicit and performant, but requires
|
|
211
|
-
* manual specification of list styles to override MDXEditor's CSS resets.
|
|
212
|
-
*
|
|
213
|
-
* Required properties:
|
|
214
|
-
* - listStyleType: 'disc' (ul) or 'decimal' (ol) - Shows bullets/numbers
|
|
215
|
-
* - listStylePosition: 'outside' - Places markers outside content box
|
|
216
|
-
* - display: 'list-item' (on li) - Ensures proper list item rendering
|
|
217
|
-
*
|
|
218
|
-
* Why this changed: v3 optimized for speed by removing automatic style inference,
|
|
219
|
-
* requiring more explicit style declarations.
|
|
220
|
-
*/
|
|
221
|
-
'& ul': {
|
|
222
|
-
marginTop: space2,
|
|
223
|
-
paddingInlineStart: space4,
|
|
224
|
-
listStyleType: 'disc',
|
|
225
|
-
listStylePosition: 'outside',
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
'& ol': {
|
|
229
|
-
marginTop: space2,
|
|
230
|
-
paddingInlineStart: space4,
|
|
231
|
-
listStyleType: 'decimal',
|
|
232
|
-
listStylePosition: 'outside',
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
'& li': {
|
|
236
|
-
lineHeight: '1.5',
|
|
237
|
-
marginBottom: space2,
|
|
238
|
-
display: 'list-item',
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
'& blockquote': {
|
|
242
|
-
borderLeftWidth: '4px',
|
|
243
|
-
borderLeftColor: 'var(--chakra-colors-primary-light)',
|
|
244
|
-
background: 'var(--chakra-colors-primary-lighter)',
|
|
245
|
-
paddingLeft: space4,
|
|
246
|
-
paddingBlock: space2,
|
|
247
|
-
marginBlock: space4,
|
|
248
|
-
color: 'var(--chakra-colors-fg-muted)',
|
|
249
|
-
},
|
|
250
|
-
|
|
251
|
-
'& a': {
|
|
252
|
-
color: 'var(--chakra-colors-primary-main)',
|
|
253
|
-
textDecoration: 'underline',
|
|
254
|
-
},
|
|
255
|
-
|
|
256
|
-
'& code': {
|
|
257
|
-
fontFamily: 'mono',
|
|
258
|
-
background: 'var(--chakra-colors-bg-muted)',
|
|
259
|
-
paddingInline: space1,
|
|
260
|
-
borderRadius: radiusSm,
|
|
261
|
-
|
|
262
|
-
'& span': {
|
|
263
|
-
background: 'transparent',
|
|
264
|
-
},
|
|
265
|
-
},
|
|
266
|
-
},
|
|
267
|
-
'& .mdxeditor-diff-source-wrapper': {
|
|
268
|
-
overflow: 'auto',
|
|
269
|
-
},
|
|
270
|
-
}}
|
|
271
|
-
>
|
|
272
|
-
<Editor
|
|
273
|
-
ref={editorRef}
|
|
274
|
-
contentEditableClassName="content-editable"
|
|
275
|
-
overlayContainer={
|
|
276
|
-
typeof document !== 'undefined' ? document.body : undefined
|
|
277
|
-
}
|
|
278
|
-
autoFocus={autoFocus}
|
|
279
|
-
onError={({ error }) => {
|
|
280
|
-
setError(error);
|
|
281
|
-
onError?.(error);
|
|
282
|
-
}}
|
|
283
|
-
plugins={[
|
|
284
|
-
headingsPlugin({
|
|
285
|
-
allowedHeadingLevels: [2, 3, 4, 5],
|
|
286
|
-
}),
|
|
287
|
-
linkPlugin(),
|
|
288
|
-
listsPlugin(),
|
|
289
|
-
imagePlugin(),
|
|
290
|
-
quotePlugin(),
|
|
291
|
-
thematicBreakPlugin(),
|
|
292
|
-
markdownShortcutPlugin(),
|
|
293
|
-
tablePlugin(),
|
|
294
|
-
diffSourcePlugin(),
|
|
295
|
-
toolbarPlugin({
|
|
296
|
-
toolbarContents: () => (
|
|
297
|
-
<>
|
|
298
|
-
<UndoRedo />
|
|
299
|
-
|
|
300
|
-
<Separator />
|
|
301
|
-
|
|
302
|
-
<BoldItalicUnderlineToggles />
|
|
303
|
-
<CodeToggle />
|
|
304
|
-
|
|
305
|
-
<Separator />
|
|
306
|
-
|
|
307
|
-
<ListsToggle />
|
|
308
|
-
|
|
309
|
-
<Separator />
|
|
310
|
-
|
|
311
|
-
<BlockTypeSelect />
|
|
312
|
-
|
|
313
|
-
<Separator />
|
|
314
|
-
|
|
315
|
-
<InsertTable />
|
|
316
|
-
|
|
317
|
-
<InsertThematicBreak />
|
|
318
|
-
|
|
319
|
-
{/* <CreateLink />
|
|
320
|
-
<InsertImage /> */}
|
|
321
|
-
|
|
322
|
-
{error && (
|
|
323
|
-
<DiffSourceToggleWrapper options={['rich-text', 'source']}>
|
|
324
|
-
<></>
|
|
325
|
-
</DiffSourceToggleWrapper>
|
|
326
|
-
)}
|
|
327
|
-
</>
|
|
328
|
-
),
|
|
329
|
-
}),
|
|
330
|
-
]}
|
|
331
|
-
{...rest}
|
|
332
|
-
/>
|
|
333
|
-
</Box>
|
|
334
|
-
);
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
MDXEditor.displayName = 'MDXEditor';
|