Migrate add content into new menus

This commit is contained in:
Jesús Espino 2020-10-25 14:40:47 +01:00
parent 1c2cf03645
commit 342e8fb26c

View file

@ -40,6 +40,10 @@ class CardDetail extends React.Component<Props, State> {
private titleRef = React.createRef<Editable>() private titleRef = React.createRef<Editable>()
private cardListener?: OctoListener private cardListener?: OctoListener
shouldComponentUpdate() {
return true
}
constructor(props: Props) { constructor(props: Props) {
super(props) super(props)
this.state = {} this.state = {}
@ -330,33 +334,35 @@ class CardDetail extends React.Component<Props, State> {
<div className='CardDetail content'> <div className='CardDetail content'>
<div className='octo-hoverpanel octo-hover-container'> <div className='octo-hoverpanel octo-hover-container'>
<div <MenuWrapper>
className='octo-button octo-hovercontrol octo-hover-item' <div className='octo-button octo-hovercontrol octo-hover-item'>
onClick={(e) => { <FormattedMessage
OldMenu.shared.options = [ id='CardDetail.add-content'
{id: 'text', name: 'Text'}, defaultMessage='Add content'
{id: 'image', name: 'Image'}, />
] </div>
OldMenu.shared.onMenuClicked = async (optionId: string, type?: string) => { <Menu>
switch (optionId) { <Menu.Text
case 'text': id='text'
name={intl.formatMessage({id: 'CardDetail.text', defaultMessage: 'Text'})}
onClick={() => {
const block = new MutableTextBlock() const block = new MutableTextBlock()
block.parentId = card.id block.parentId = card.id
block.order = cardTree.contents.length * 1000 block.order = cardTree.contents.length * 1000
await mutator.insertBlock(block, 'add text') mutator.insertBlock(block, 'add text')
break }}
case 'image': />
Utils.selectLocalFile( <Menu.Text
(file) => { id='image'
mutator.createImageBlock(card.id, file, cardTree.contents.length * 1000) name={intl.formatMessage({id: 'CardDetail.image', defaultMessage: 'Image'})}
}, onClick={() => Utils.selectLocalFile(
'.jpg,.jpeg,.png') (file) => mutator.createImageBlock(card.id, file, cardTree.contents.length * 1000),
break '.jpg,.jpeg,.png',
} )}
} />
OldMenu.shared.showAtElement(e.target as HTMLElement)
}} </Menu>
>Add content</div> </MenuWrapper>
</div> </div>
</div> </div>
</> </>