mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-07 19:30:14 +00:00
* Mattermost Blocks * Move block renderer to its own components folder * Sync translation layer * UX fixes * Refactor button to use the button component * Code review * Fix CI * Add animations to collapse blocks * Add unit tests * Add e2e tests and related fixes * Address coderabbit comments * Address UX comments * Address feedback * Address coderabbit comments * Fix snapshots * Sync with webapp translation * Add node limit to button markdown node * Address feedback * i18n-extract * Fix test * Move image utils to the utils folder * Remove unneeded style * Revert build script change --------- Co-authored-by: Mattermost Build <build@mattermost.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useContext, useMemo} from 'react';
|
|
|
|
import Markdown from '@components/markdown';
|
|
|
|
import {MmBlocksRenderContext} from './context';
|
|
import {getStyleSheet} from './styles';
|
|
|
|
type TextBlockProps = {
|
|
block: MmTextBlock;
|
|
theme: Theme;
|
|
};
|
|
|
|
export const TextBlock = ({block, theme}: TextBlockProps) => {
|
|
const style = getStyleSheet(theme);
|
|
const renderContext = useContext(MmBlocksRenderContext);
|
|
|
|
const textStyle = useMemo(() => [
|
|
style.message,
|
|
block.is_subtle && style.textSubtle,
|
|
block.size === 'small' && style.textSmall,
|
|
], [block.is_subtle, block.size, style]);
|
|
|
|
if (!block.text || !renderContext) {
|
|
return null;
|
|
}
|
|
|
|
const {channelId, inlineMarkdownActions, location, postId} = renderContext;
|
|
const {mmBlocksActionCookie, integrationFormat} = inlineMarkdownActions;
|
|
|
|
return (
|
|
<Markdown
|
|
allowInlineActions={true}
|
|
baseTextStyle={textStyle}
|
|
channelId={channelId}
|
|
integrationFormat={integrationFormat}
|
|
location={location}
|
|
mmBlocksActionCookie={mmBlocksActionCookie}
|
|
postId={postId}
|
|
theme={theme}
|
|
value={block.text}
|
|
/>
|
|
);
|
|
};
|