refactor: remove dark mode functionality from text editor components
This commit is contained in:
parent
5cf6eb191d
commit
32b435d762
@ -21,7 +21,7 @@ export const EditorButton = (properties: TProperties) => {
|
|||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'flex h-6 w-8 items-center justify-center rounded-md p-2 hover:bg-[#2E2F7C] hover:text-white disabled:cursor-not-allowed disabled:bg-[#2E2F7C]/50 disabled:text-white disabled:hover:bg-[#2E2F7C]/50',
|
'flex h-6 w-8 cursor-pointer items-center justify-center rounded-md p-2 hover:bg-[#2E2F7C] hover:text-white disabled:cursor-not-allowed disabled:bg-[#2E2F7C]/50 disabled:text-white disabled:hover:bg-[#2E2F7C]/50',
|
||||||
isActive ? 'bg-[#2E2F7C]/10' : '',
|
isActive ? 'bg-[#2E2F7C]/10' : '',
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
|
|||||||
@ -15,11 +15,9 @@ import {
|
|||||||
LinkIcon,
|
LinkIcon,
|
||||||
LinkSlashIcon,
|
LinkSlashIcon,
|
||||||
ListBulletIcon,
|
ListBulletIcon,
|
||||||
MoonIcon,
|
|
||||||
NumberedListIcon,
|
NumberedListIcon,
|
||||||
PhotoIcon,
|
PhotoIcon,
|
||||||
StrikethroughIcon,
|
StrikethroughIcon,
|
||||||
SunIcon,
|
|
||||||
SwatchIcon,
|
SwatchIcon,
|
||||||
} from '@heroicons/react/20/solid'
|
} from '@heroicons/react/20/solid'
|
||||||
import type { Editor } from '@tiptap/react'
|
import type { Editor } from '@tiptap/react'
|
||||||
@ -41,8 +39,6 @@ type TProperties = {
|
|||||||
editor: Editor | null
|
editor: Editor | null
|
||||||
setIsPlainHTML: Dispatch<SetStateAction<boolean>>
|
setIsPlainHTML: Dispatch<SetStateAction<boolean>>
|
||||||
category: string
|
category: string
|
||||||
darkMode: boolean
|
|
||||||
setDarkMode: Dispatch<SetStateAction<boolean>>
|
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,8 +47,6 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
editor,
|
editor,
|
||||||
setIsPlainHTML,
|
setIsPlainHTML,
|
||||||
// category,
|
// category,
|
||||||
darkMode,
|
|
||||||
setDarkMode,
|
|
||||||
disabled = false,
|
disabled = false,
|
||||||
} = properties
|
} = properties
|
||||||
// const [isOpenImage, setIsOpenImage] = useState(false)
|
// const [isOpenImage, setIsOpenImage] = useState(false)
|
||||||
@ -114,11 +108,6 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleDark = () => {
|
|
||||||
setDarkMode(!darkMode)
|
|
||||||
// localStorage.setItem(editorKey, JSON.stringify(!darkMode))
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="flex items-start justify-between gap-4 rounded-[5px_5px_0_0] px-4 py-3">
|
<div className="flex items-start justify-between gap-4 rounded-[5px_5px_0_0] px-4 py-3">
|
||||||
@ -384,13 +373,6 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
>
|
>
|
||||||
<ArrowUturnRightIcon />
|
<ArrowUturnRightIcon />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
<EditorButton
|
|
||||||
onClick={() => toggleDark()}
|
|
||||||
title={darkMode ? 'Switch to Light Mode' : 'Switch to Dark Mode'}
|
|
||||||
isActive={true}
|
|
||||||
>
|
|
||||||
{darkMode ? <MoonIcon /> : <SunIcon />}
|
|
||||||
</EditorButton>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -398,7 +380,6 @@ export const EditorMenuBar = (properties: TProperties) => {
|
|||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => setIsPlainHTML(true)}
|
onClick={() => setIsPlainHTML(true)}
|
||||||
title="Switch to Plain Text"
|
title="Switch to Plain Text"
|
||||||
isActive={true}
|
|
||||||
>
|
>
|
||||||
<DocumentTextIcon />
|
<DocumentTextIcon />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
|
|||||||
@ -27,7 +27,6 @@ export const EditorTextArea = (properties: TProperties) => {
|
|||||||
<EditorButton
|
<EditorButton
|
||||||
onClick={() => setIsPlainHTML(false)}
|
onClick={() => setIsPlainHTML(false)}
|
||||||
title="Switch to Rich Text"
|
title="Switch to Rich Text"
|
||||||
isActive={true}
|
|
||||||
>
|
>
|
||||||
<CodeBracketSquareIcon />
|
<CodeBracketSquareIcon />
|
||||||
</EditorButton>
|
</EditorButton>
|
||||||
|
|||||||
@ -53,7 +53,6 @@ export const TextEditor = <TFormValues extends Record<string, unknown>>(
|
|||||||
|
|
||||||
const [isPlainHTML, setIsPlainHTML] = useState(false)
|
const [isPlainHTML, setIsPlainHTML] = useState(false)
|
||||||
const [init, setInit] = useState(true)
|
const [init, setInit] = useState(true)
|
||||||
const [darkMode, setDarkMode] = useState(false)
|
|
||||||
const generatedId = useId()
|
const generatedId = useId()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
@ -129,16 +128,13 @@ export const TextEditor = <TFormValues extends Record<string, unknown>>(
|
|||||||
category={category}
|
category={category}
|
||||||
editor={editor}
|
editor={editor}
|
||||||
setIsPlainHTML={setIsPlainHTML}
|
setIsPlainHTML={setIsPlainHTML}
|
||||||
darkMode={darkMode}
|
|
||||||
setDarkMode={setDarkMode}
|
|
||||||
/>
|
/>
|
||||||
<EditorContent
|
<EditorContent
|
||||||
readOnly={disabled}
|
readOnly={disabled}
|
||||||
editor={editor}
|
editor={editor}
|
||||||
id={id ?? generatedId}
|
id={id ?? generatedId}
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
'prose-invert max-h-96 max-w-none cursor-text overflow-y-auto rounded-[0_0_5px_5px] border border-[#D2D2D2] p-2',
|
'prose prose-headings:my-0 prose-p:my-0 max-h-96 max-w-none cursor-text overflow-y-auto rounded-[0_0_5px_5px] border border-[#D2D2D2] p-2',
|
||||||
darkMode ? 'bg-[#00000055]' : '',
|
|
||||||
inputClassName,
|
inputClassName,
|
||||||
)}
|
)}
|
||||||
onClick={() => editor?.commands.focus()}
|
onClick={() => editor?.commands.focus()}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user