mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-15 09:14:11 +02:00
cleanup handler interface
This commit is contained in:
parent
13d63f9cd1
commit
42d7bc9a88
@ -13,7 +13,6 @@ type ContentHandler = {
|
|||||||
getDisplayText: (intl: IntlShape) => string,
|
getDisplayText: (intl: IntlShape) => string,
|
||||||
getIcon: () => JSX.Element,
|
getIcon: () => JSX.Element,
|
||||||
createBlock: () => Promise<MutableContentBlock>,
|
createBlock: () => Promise<MutableContentBlock>,
|
||||||
addBlock(card: Card, contents: readonly IContentBlock[], index: number, intl: IntlShape): void,
|
|
||||||
createComponent: (block: IContentBlock, intl: IntlShape, readonly: boolean) => JSX.Element,
|
createComponent: (block: IContentBlock, intl: IntlShape, readonly: boolean) => JSX.Element,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {MutableDividerBlock} from '../../blocks/dividerBlock'
|
import {MutableDividerBlock} from '../../blocks/dividerBlock'
|
||||||
import mutator from '../../mutator'
|
|
||||||
import DividerIcon from '../../widgets/icons/divider'
|
import DividerIcon from '../../widgets/icons/divider'
|
||||||
|
|
||||||
import {contentRegistry} from './contentRegistry'
|
import {contentRegistry} from './contentRegistry'
|
||||||
@ -22,20 +21,6 @@ contentRegistry.registerContentType({
|
|||||||
createBlock: async () => {
|
createBlock: async () => {
|
||||||
return new MutableDividerBlock()
|
return new MutableDividerBlock()
|
||||||
},
|
},
|
||||||
addBlock: (card, contents, index, intl) => {
|
|
||||||
const newBlock = new MutableDividerBlock()
|
|
||||||
newBlock.parentId = card.id
|
|
||||||
newBlock.rootId = card.rootId
|
|
||||||
|
|
||||||
const contentOrder = contents.map((o) => o.id)
|
|
||||||
contentOrder.splice(index, 0, newBlock.id)
|
|
||||||
const typeName = intl.formatMessage({id: 'ContentBlock.divider', defaultMessage: 'divider'})
|
|
||||||
mutator.performAsUndoGroup(async () => {
|
|
||||||
const description = intl.formatMessage({id: 'ContentBlock.addElement', defaultMessage: 'add {type}'}, {type: typeName})
|
|
||||||
await mutator.insertBlock(newBlock, description)
|
|
||||||
await mutator.changeCardContentOrder(card, contentOrder, description)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
createComponent: () => <DividerElement/>,
|
createComponent: () => <DividerElement/>,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {injectIntl, IntlShape} from 'react-intl'
|
import {injectIntl, IntlShape} from 'react-intl'
|
||||||
|
|
||||||
import {IContentBlock, MutableContentBlock} from '../../blocks/contentBlock'
|
import {IContentBlock} from '../../blocks/contentBlock'
|
||||||
import {MutableImageBlock} from '../../blocks/imageBlock'
|
import {MutableImageBlock} from '../../blocks/imageBlock'
|
||||||
import mutator from '../../mutator'
|
|
||||||
import octoClient from '../../octoClient'
|
import octoClient from '../../octoClient'
|
||||||
import {Utils} from '../../utils'
|
import {Utils} from '../../utils'
|
||||||
import ImageIcon from '../../widgets/icons/image'
|
import ImageIcon from '../../widgets/icons/image'
|
||||||
@ -72,21 +71,6 @@ contentRegistry.registerContentType({
|
|||||||
|
|
||||||
// return new MutableImageBlock()
|
// return new MutableImageBlock()
|
||||||
},
|
},
|
||||||
addBlock: (card, contents, index, intl) => {
|
|
||||||
Utils.selectLocalFile((file) => {
|
|
||||||
mutator.performAsUndoGroup(async () => {
|
|
||||||
const typeName = intl.formatMessage({id: 'ContentBlock.image', defaultMessage: 'image'})
|
|
||||||
const description = intl.formatMessage({id: 'ContentBlock.addElement', defaultMessage: 'add {type}'}, {type: typeName})
|
|
||||||
const newBlock = await mutator.createImageBlock(card, file, description)
|
|
||||||
if (newBlock) {
|
|
||||||
const contentOrder = contents.map((o) => o.id)
|
|
||||||
contentOrder.splice(index, 0, newBlock.id)
|
|
||||||
await mutator.changeCardContentOrder(card, contentOrder, description)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
'.jpg,.jpeg,.png')
|
|
||||||
},
|
|
||||||
createComponent: (block, intl) => {
|
createComponent: (block, intl) => {
|
||||||
return (
|
return (
|
||||||
<ImageElement
|
<ImageElement
|
||||||
|
@ -18,20 +18,6 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class TextElement extends React.PureComponent<Props> {
|
class TextElement extends React.PureComponent<Props> {
|
||||||
readonly type = 'text'
|
|
||||||
|
|
||||||
createBlock(): MutableContentBlock {
|
|
||||||
return new MutableTextBlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
getDisplayText(intl: IntlShape): string {
|
|
||||||
return intl.formatMessage({id: 'ContentBlock.text', defaultMessage: 'text'})
|
|
||||||
}
|
|
||||||
|
|
||||||
getIcon(): JSX.Element {
|
|
||||||
return <TextIcon/>
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): JSX.Element {
|
render(): JSX.Element {
|
||||||
const {intl, block, readonly} = this.props
|
const {intl, block, readonly} = this.props
|
||||||
|
|
||||||
@ -55,20 +41,6 @@ contentRegistry.registerContentType({
|
|||||||
createBlock: async () => {
|
createBlock: async () => {
|
||||||
return new MutableTextBlock()
|
return new MutableTextBlock()
|
||||||
},
|
},
|
||||||
addBlock: (card, contents, index, intl) => {
|
|
||||||
const newBlock = new MutableTextBlock()
|
|
||||||
newBlock.parentId = card.id
|
|
||||||
newBlock.rootId = card.rootId
|
|
||||||
|
|
||||||
const contentOrder = contents.map((o) => o.id)
|
|
||||||
contentOrder.splice(index, 0, newBlock.id)
|
|
||||||
const typeName = intl.formatMessage({id: 'ContentBlock.text', defaultMessage: 'text'})
|
|
||||||
mutator.performAsUndoGroup(async () => {
|
|
||||||
const description = intl.formatMessage({id: 'ContentBlock.addElement', defaultMessage: 'add {type}'}, {type: typeName})
|
|
||||||
await mutator.insertBlock(newBlock, description)
|
|
||||||
await mutator.changeCardContentOrder(card, contentOrder, description)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
createComponent: (block, intl, readonly) => {
|
createComponent: (block, intl, readonly) => {
|
||||||
return (
|
return (
|
||||||
<TextElement
|
<TextElement
|
||||||
|
Loading…
Reference in New Issue
Block a user