Fix card loading on open card (#800)

* Fix card loading on open card

* Fix MDE problem

* Fix eslint
This commit is contained in:
Jesús Espino 2021-07-29 13:43:34 +02:00 committed by GitHub
parent cfac3fe81b
commit 8823991eb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 18 deletions

View File

@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useState} from 'react'
import React, {useState, useEffect} from 'react'
import {FormattedMessage, useIntl} from 'react-intl'
import mutator from '../mutator'
@ -27,6 +27,13 @@ const CardDialog = (props: Props) => {
const [syncComplete, setSyncComplete] = useState(false)
const [cardTree, setCardTree] = useState<CardTree>()
const intl = useIntl()
useEffect(() => {
MutableCardTree.sync(props.cardId).then((ct) => {
setCardTree(ct)
setSyncComplete(true)
})
}, [props.boardTree])
useCardListener(
async (blocks) => {
Utils.log(`cardListener.onChanged: ${blocks.length}`)

View File

@ -1,6 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useState, useRef} from 'react'
import React, {useState, useRef, useMemo} from 'react'
import EasyMDE from 'easymde'
import SimpleMDE from 'react-simplemde-editor'
@ -52,6 +52,23 @@ const MarkdownEditor = (props: Props): JSX. Element => {
const stateAndPropsRef = useRef(stateAndPropsValue)
stateAndPropsRef.current = stateAndPropsValue
const mdeOptions = useMemo(() => ({
autoDownloadFontAwesome: true,
toolbar: false,
status: false,
spellChecker: true,
nativeSpellcheck: true,
minHeight: '10px',
shortcuts: {
toggleStrikethrough: 'Cmd-.',
togglePreview: null,
drawImage: null,
drawLink: null,
toggleSideBySide: null,
toggleFullScreen: null,
},
}), [])
const html: string = Utils.htmlFromMarkdown(text || placeholderText || '')
const previewElement = (
@ -132,22 +149,7 @@ const MarkdownEditor = (props: Props): JSX. Element => {
}
},
}}
options={{
autoDownloadFontAwesome: true,
toolbar: false,
status: false,
spellChecker: true,
nativeSpellcheck: true,
minHeight: '10px',
shortcuts: {
toggleStrikethrough: 'Cmd-.',
togglePreview: null,
drawImage: null,
drawLink: null,
toggleSideBySide: null,
toggleFullScreen: null,
},
}}
options={mdeOptions}
/>
</div>)