Skip to content

Commit

Permalink
SOROKA-139: fix richtext bug (#37)
Browse files Browse the repository at this point in the history
SOROKA: fix richtext bug
  • Loading branch information
AlexRbkv authored Oct 6, 2022
1 parent 08b460d commit e7ed28e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/components/properties/RichTextProperty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { prosemirrorNodeToHtml } from 'remirror'
import { RemirrorEventListenerProps } from '@remirror/core'
import { FloatingLinkToolbar } from '../common/FloatingLinkToolbar'
import { useIntl } from 'react-intl'
import { IntlError } from '@formatjs/intl'
import { TextPropertyProps } from '../../stores/propertiesStore'
import { RichTextPropertyProps } from '../../stores/propertiesStore'

// TODO: Add button in toolbar
const toolbarItems: ToolbarGroupItem[] = [
Expand Down Expand Up @@ -75,7 +74,7 @@ const toolbarItems: ToolbarGroupItem[] = [
}
]

export const RichTextProperty = ({ value, showHelp = false, onChange }: TextPropertyProps) => {
export const RichTextProperty = ({ value, showHelp = false, onChange }: RichTextPropertyProps) => {
const intl = useIntl()
const linkExtension = useMemo(() => {
const extension = new LinkExtension()
Expand Down
2 changes: 1 addition & 1 deletion src/components/properties/TextProperty.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const TextProperty = ({ value, onChange }: TextPropertyProps) => {
style={{ height: '84px' }}
type="text"
placeholder=""
defaultValue={value}
defaultValue={value.value}
onChange={(event) => {
onChange({ value: event.target.value })
}}
Expand Down
13 changes: 10 additions & 3 deletions src/stores/propertiesStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TemplatesAPI } from '../api/templates'
import { RichTextProperty } from '../components/properties/RichTextProperty'
import { FormattedMessage } from 'react-intl'
import { DatePropertyProps } from '../components/properties/DateProperty/DateProperty'
import { RemirrorContentType } from 'remirror'

export type Property = {
propertyId: number
Expand Down Expand Up @@ -63,6 +64,12 @@ export type GeoPropertyProps = {
}

export type TextPropertyProps = {
value: { value: string }
showHelp: boolean
onChange: ({ value }: { value: string }) => void
}

export type RichTextPropertyProps = {
value: string
showHelp: boolean
onChange: ({ value }: { value: string }) => void
Expand All @@ -77,13 +84,13 @@ export type MediaPropertyProps = {
const TYPES: { [key: string]: any } = {
TEXT: {
renderForm: (props: TextPropertyProps) => <TextProperty {...props} />,
formatToApi: (value: string) => value,
formatToApi: ({ value }: { value: string }) => value,
defaultData: '',
hasHelp: false
},
RICH_TEXT: {
renderForm: (props: TextPropertyProps) => <RichTextProperty {...props} />,
formatToApi: (value: string) => value,
renderForm: (props: RichTextPropertyProps) => <RichTextProperty {...props} />,
formatToApi: ({ value }: { value: RichTextPropertyProps['value'] }) => value,
defaultData: '',
hasHelp: false
},
Expand Down

0 comments on commit e7ed28e

Please sign in to comment.