refactor: remove list and divider buttons from RichTextEditor toolbar
This commit is contained in:
@@ -35,7 +35,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
|
||||
const execCommand = (command: string) => {
|
||||
editorRef.current?.focus();
|
||||
|
||||
|
||||
if (command === 'bold') {
|
||||
document.execCommand('bold', false);
|
||||
} else if (command === 'italic') {
|
||||
@@ -57,7 +57,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
} else if (command === 'redo') {
|
||||
document.execCommand('redo', false);
|
||||
}
|
||||
|
||||
|
||||
updateValue();
|
||||
};
|
||||
|
||||
@@ -80,7 +80,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
tableHTML += '</tr>';
|
||||
}
|
||||
tableHTML += '</table><p><br></p>';
|
||||
|
||||
|
||||
if (editorRef.current) {
|
||||
editorRef.current.focus();
|
||||
document.execCommand('insertHTML', false, tableHTML);
|
||||
@@ -93,7 +93,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
if (!editorRef.current) return;
|
||||
const selection = window.getSelection();
|
||||
if (!selection || selection.rangeCount === 0) return;
|
||||
|
||||
|
||||
const range = selection.getRangeAt(0);
|
||||
let cell = range.commonAncestorContainer;
|
||||
while (cell && cell !== editorRef.current) {
|
||||
@@ -114,7 +114,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
if (!editorRef.current) return;
|
||||
const selection = window.getSelection();
|
||||
if (!selection || selection.rangeCount === 0) return;
|
||||
|
||||
|
||||
const range = selection.getRangeAt(0);
|
||||
let cell = range.commonAncestorContainer;
|
||||
while (cell && cell !== editorRef.current) {
|
||||
@@ -143,7 +143,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
if (!editorRef.current) return;
|
||||
const selection = window.getSelection();
|
||||
if (!selection || selection.rangeCount === 0) return;
|
||||
|
||||
|
||||
const range = selection.getRangeAt(0);
|
||||
let cell = range.commonAncestorContainer;
|
||||
while (cell && cell !== editorRef.current) {
|
||||
@@ -182,13 +182,13 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
<Underline className="w-4 h-4" />
|
||||
</ToolbarButton>
|
||||
<ToolbarDivider />
|
||||
<ToolbarButton onClick={() => execCommand('insertUnorderedList')} title="Bullet List">
|
||||
{/* <ToolbarButton onClick={() => execCommand('insertUnorderedList')} title="Bullet List">
|
||||
<List className="w-4 h-4" />
|
||||
</ToolbarButton>
|
||||
<ToolbarButton onClick={() => execCommand('insertOrderedList')} title="Numbered List">
|
||||
<ListOrdered className="w-4 h-4" />
|
||||
</ToolbarButton>
|
||||
<ToolbarDivider />
|
||||
<ToolbarDivider /> */}
|
||||
<ToolbarButton onClick={() => execCommand('justifyLeft')} title="Align Left">
|
||||
<AlignLeft className="w-4 h-4" />
|
||||
</ToolbarButton>
|
||||
@@ -207,7 +207,7 @@ export default function RichTextEditor({ value, onChange, placeholder = 'Enter d
|
||||
<div className="absolute top-full left-0 mt-1 bg-white border border-slate-200 rounded-lg shadow-lg p-2 z-50 min-w-[160px]">
|
||||
<div className="text-xs text-slate-500 mb-2 px-1">Insert Table</div>
|
||||
<div className="grid grid-cols-4 gap-1 mb-2">
|
||||
{[2, 3, 4, 5].map(rows =>
|
||||
{[2, 3, 4, 5].map(rows =>
|
||||
<Fragment key={rows}>
|
||||
{[2, 3, 4, 5].map(cols => (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user