Skip to content

Commit aa7e19b

Browse files
author
robin
committed
Remove TipTap editor utility files including commands, constants, error handling, events, position conversion, and table extension to streamline the editor's functionality and reduce code complexity.
1 parent 0bad2c7 commit aa7e19b

12 files changed

Lines changed: 5 additions & 2593 deletions

File tree

ui/package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@
2121
"@codemirror/language-data": "^6.5.0",
2222
"@codemirror/state": "^6.5.0",
2323
"@codemirror/view": "^6.26.1",
24-
"@tiptap/core": "^3.13.0",
25-
"@tiptap/extension-image": "^3.13.0",
26-
"@tiptap/extension-placeholder": "^3.13.0",
27-
"@tiptap/extension-table": "^3.13.0",
28-
"@tiptap/markdown": "^3.13.0",
29-
"@tiptap/react": "^3.13.0",
30-
"@tiptap/starter-kit": "^3.13.0",
3124
"axios": "^1.7.7",
3225
"bootstrap": "^5.3.2",
3326
"bootstrap-icons": "^1.10.5",
@@ -107,4 +100,4 @@
107100
"pnpm": ">=9"
108101
},
109102
"license": "MIT"
110-
}
103+
}

ui/pnpm-lock.yaml

Lines changed: 1 addition & 670 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/src/components/Editor/RichEditor.tsx

Lines changed: 0 additions & 206 deletions
This file was deleted.

ui/src/components/Editor/index.tsx

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ import {
5151
import { htmlRender } from './utils';
5252
import Viewer from './Viewer';
5353
import { EditorContext } from './EditorContext';
54-
import RichEditor from './RichEditor';
5554
import MarkdownEditor from './MarkdownEditor';
5655
import { Editor } from './types';
5756

@@ -86,24 +85,11 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
8685
},
8786
ref,
8887
) => {
89-
const [mode, setMode] = useState<'markdown' | 'rich'>('markdown');
9088
const [currentEditor, setCurrentEditor] = useState<Editor | null>(null);
9189
const previewRef = useRef<{ getHtml; element } | null>(null);
9290

9391
useRenderPlugin(previewRef.current?.element);
9492

95-
const handleModeChange = useCallback(
96-
(newMode: 'markdown' | 'rich') => {
97-
if (newMode === mode) {
98-
return;
99-
}
100-
101-
setCurrentEditor(null);
102-
setMode(newMode);
103-
},
104-
[mode],
105-
);
106-
10793
const getHtml = useCallback(() => {
10894
return previewRef.current?.getHtml();
10995
}, []);
@@ -116,7 +102,7 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
116102
[getHtml],
117103
);
118104

119-
const EditorComponent = mode === 'markdown' ? MarkdownEditor : RichEditor;
105+
const EditorComponent = MarkdownEditor;
120106

121107
return (
122108
<>
@@ -149,30 +135,10 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
149135
<Help />
150136
</PluginRender>
151137
</EditorContext.Provider>
152-
<div className="btn-group ms-auto" role="group">
153-
<button
154-
type="button"
155-
className={`btn btn-sm ${
156-
mode === 'markdown' ? 'btn-primary' : 'btn-outline-secondary'
157-
}`}
158-
title="Markdown Mode"
159-
onClick={() => handleModeChange('markdown')}>
160-
<i className="bi bi-filetype-md" />
161-
</button>
162-
<button
163-
type="button"
164-
className={`btn btn-sm ${
165-
mode === 'rich' ? 'btn-primary' : 'btn-outline-secondary'
166-
}`}
167-
title="Rich Mode"
168-
onClick={() => handleModeChange('rich')}>
169-
<i className="bi bi-type" />
170-
</button>
171-
</div>
172138
</div>
173139

174140
<EditorComponent
175-
key={mode}
141+
key="markdown-editor"
176142
value={value}
177143
onChange={(markdown) => {
178144
onChange?.(markdown);
@@ -186,7 +152,7 @@ const MDEditor: ForwardRefRenderFunction<EditorRef, Props> = (
186152
}}
187153
/>
188154
</div>
189-
{mode === 'markdown' && <Viewer ref={previewRef} value={value} />}
155+
<Viewer ref={previewRef} value={value} />
190156
</>
191157
);
192158
};

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

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)