Add custom class for Editors (#143)
This commit is contained in:
parent
1ca80cede9
commit
f276e2182b
|
@ -45,7 +45,7 @@ import { TrailingNode } from './extensions/TrailingNode'
|
||||||
import Article from './extensions/Article'
|
import Article from './extensions/Article'
|
||||||
import styles from './SimplifiedEditor.module.scss'
|
import styles from './SimplifiedEditor.module.scss'
|
||||||
|
|
||||||
type EditorProps = {
|
type Props = {
|
||||||
shoutId: number
|
shoutId: number
|
||||||
initialContent?: string
|
initialContent?: string
|
||||||
onChange: (text: string) => void
|
onChange: (text: string) => void
|
||||||
|
@ -55,7 +55,7 @@ const yDocs: Record<string, Doc> = {}
|
||||||
const persisters: Record<string, IndexeddbPersistence> = {}
|
const persisters: Record<string, IndexeddbPersistence> = {}
|
||||||
const providers: Record<string, HocuspocusProvider> = {}
|
const providers: Record<string, HocuspocusProvider> = {}
|
||||||
|
|
||||||
export const Editor = (props: EditorProps) => {
|
export const Editor = (props: Props) => {
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize()
|
||||||
const { user } = useSession()
|
const { user } = useSession()
|
||||||
const [isCommonMarkup, setIsCommonMarkup] = createSignal(false)
|
const [isCommonMarkup, setIsCommonMarkup] = createSignal(false)
|
||||||
|
@ -114,6 +114,11 @@ export const Editor = (props: EditorProps) => {
|
||||||
|
|
||||||
const editor = createTiptapEditor(() => ({
|
const editor = createTiptapEditor(() => ({
|
||||||
element: editorElRef.current,
|
element: editorElRef.current,
|
||||||
|
editorProps: {
|
||||||
|
attributes: {
|
||||||
|
class: 'articleEditor'
|
||||||
|
}
|
||||||
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
Document,
|
Document,
|
||||||
Text,
|
Text,
|
||||||
|
@ -220,10 +225,6 @@ export const Editor = (props: EditorProps) => {
|
||||||
content: props.initialContent ?? null
|
content: props.initialContent ?? null
|
||||||
}))
|
}))
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
editor().view.dom.classList.add('articleEditor')
|
|
||||||
})
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
actions: { countWords, setEditor }
|
actions: { countWords, setEditor }
|
||||||
} = useEditorContext()
|
} = useEditorContext()
|
||||||
|
|
|
@ -54,6 +54,11 @@ const SimplifiedEditor = (props: Props) => {
|
||||||
|
|
||||||
const editor = createTiptapEditor(() => ({
|
const editor = createTiptapEditor(() => ({
|
||||||
element: editorElRef.current,
|
element: editorElRef.current,
|
||||||
|
editorProps: {
|
||||||
|
attributes: {
|
||||||
|
class: styles.simplifiedEditorField
|
||||||
|
}
|
||||||
|
},
|
||||||
extensions: [
|
extensions: [
|
||||||
Document,
|
Document,
|
||||||
Text,
|
Text,
|
||||||
|
@ -132,7 +137,6 @@ const SimplifiedEditor = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
editor().view.dom.classList.add(styles.simplifiedEditorField)
|
|
||||||
if (props.submitByShiftEnter || props.submitByEnter) {
|
if (props.submitByShiftEnter || props.submitByEnter) {
|
||||||
window.addEventListener('keydown', handleKeyDown)
|
window.addEventListener('keydown', handleKeyDown)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user