Skip to content

Commit 498c142

Browse files
author
robin
committed
feat(editor): rename WYSIWYG editor to Rich editor and implement new RichEditor component
- Updated the editor mode from WYSIWYG to Rich in the MDEditor component. - Introduced a new RichEditor component utilizing TipTap for enhanced editing capabilities. - Adjusted styles and references in the editor components to reflect the new naming convention.
1 parent 3d43700 commit 498c142

4 files changed

Lines changed: 14 additions & 15 deletions

File tree

ui/src/components/Editor/WysiwygEditor.tsx renamed to ui/src/components/Editor/RichEditor.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { TableKit } from '@tiptap/extension-table';
3333
import { Editor } from './types';
3434
import { createTipTapAdapter } from './utils/tiptap/adapter';
3535

36-
interface WysiwygEditorProps {
36+
interface RichEditorProps {
3737
value: string;
3838
onChange?: (value: string) => void;
3939
onFocus?: () => void;
@@ -43,7 +43,7 @@ interface WysiwygEditorProps {
4343
onEditorReady?: (editor: Editor) => void;
4444
}
4545

46-
const WysiwygEditor: React.FC<WysiwygEditorProps> = ({
46+
const RichEditor: React.FC<RichEditorProps> = ({
4747
value,
4848
onChange,
4949
onFocus,
@@ -153,10 +153,10 @@ const WysiwygEditor: React.FC<WysiwygEditorProps> = ({
153153
}
154154

155155
return (
156-
<div className="wysiwyg-editor-wrap">
156+
<div className="rich-editor-wrap">
157157
<EditorContent editor={editor} />
158158
</div>
159159
);
160160
};
161161

162-
export default WysiwygEditor;
162+
export default RichEditor;

ui/src/components/Editor/index.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@
114114
height: 264px;
115115
}
116116

117-
// WYSIWYG 编辑器样式
118-
.wysiwyg-editor-wrap {
117+
.rich-editor-wrap {
119118
height: 264px;
120119
overflow-y: auto;
121120
padding: 0.375rem 0.75rem;

ui/src/components/Editor/index.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ import {
5151
import { htmlRender } from './utils';
5252
import Viewer from './Viewer';
5353
import { EditorContext } from './EditorContext';
54-
import WysiwygEditor from './WysiwygEditor';
54+
import RichEditor from './RichEditor';
5555
import MarkdownEditor from './MarkdownEditor';
5656
import { Editor } from './types';
5757

@@ -86,14 +86,14 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
8686
},
8787
ref,
8888
) => {
89-
const [mode, setMode] = useState<'markdown' | 'wysiwyg'>('markdown');
89+
const [mode, setMode] = useState<'markdown' | 'rich'>('markdown');
9090
const [currentEditor, setCurrentEditor] = useState<Editor | null>(null);
9191
const previewRef = useRef<{ getHtml; element } | null>(null);
9292

9393
useRenderPlugin(previewRef.current?.element);
9494

9595
const handleModeChange = useCallback(
96-
(newMode: 'markdown' | 'wysiwyg') => {
96+
(newMode: 'markdown' | 'rich') => {
9797
if (newMode === mode) {
9898
return;
9999
}
@@ -116,7 +116,7 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
116116
[getHtml],
117117
);
118118

119-
const EditorComponent = mode === 'markdown' ? MarkdownEditor : WysiwygEditor;
119+
const EditorComponent = mode === 'markdown' ? MarkdownEditor : RichEditor;
120120

121121
return (
122122
<>
@@ -155,17 +155,17 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
155155
className={`btn btn-sm ${
156156
mode === 'markdown' ? 'btn-primary' : 'btn-outline-secondary'
157157
}`}
158-
title="Markdown 模式"
158+
title="Markdown Mode"
159159
onClick={() => handleModeChange('markdown')}>
160160
<i className="bi bi-filetype-md" />
161161
</button>
162162
<button
163163
type="button"
164164
className={`btn btn-sm ${
165-
mode === 'wysiwyg' ? 'btn-primary' : 'btn-outline-secondary'
165+
mode === 'rich' ? 'btn-primary' : 'btn-outline-secondary'
166166
}`}
167-
title="WYSIWYG 模式"
168-
onClick={() => handleModeChange('wysiwyg')}>
167+
title="Rich Mode"
168+
onClick={() => handleModeChange('rich')}>
169169
<i className="bi bi-type" />
170170
</button>
171171
</div>

ui/src/components/Editor/utils/tiptap/adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { createCommandMethods } from './commands';
2929
* Adapts TipTap editor to CodeMirror editor interface
3030
*
3131
* This adapter function converts TipTap editor's API to a CodeMirror-compatible interface,
32-
* enabling toolbar components to work properly in WYSIWYG mode. The adapter implements
32+
* enabling toolbar components to work properly in Rich mode. The adapter implements
3333
* the complete `ExtendEditor` interface, including base methods, event handling, and command methods.
3434
*
3535
* @param editor - TipTap editor instance

0 commit comments

Comments
 (0)