mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-09 20:50:12 +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>
55 lines
1.4 KiB
TypeScript
55 lines
1.4 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React, {useMemo} from 'react';
|
|
|
|
import {ContainerBlock} from './layout_blocks';
|
|
import {MmBlocksContextProvider} from './mm_blocks_context_provider';
|
|
|
|
import type {MmBlocksInlineMarkdownActions} from './context';
|
|
import type {ActionHandler} from './types';
|
|
import type {AvailableScreens} from '@typings/screens/navigation';
|
|
|
|
export type BlockRendererProps = {
|
|
blocks: MmBlock[];
|
|
channelId: string;
|
|
imagesMetadata?: Record<string, PostImage>;
|
|
inlineMarkdownActions?: MmBlocksInlineMarkdownActions;
|
|
location: AvailableScreens;
|
|
onAction: ActionHandler;
|
|
postId: string;
|
|
theme: Theme;
|
|
};
|
|
|
|
export const BlockRenderer = ({
|
|
blocks,
|
|
channelId,
|
|
imagesMetadata,
|
|
inlineMarkdownActions,
|
|
location,
|
|
onAction,
|
|
postId,
|
|
theme,
|
|
}: BlockRendererProps) => {
|
|
const block = useMemo(() => ({
|
|
type: 'container' as const,
|
|
content: blocks,
|
|
}), [blocks]);
|
|
|
|
return (
|
|
<MmBlocksContextProvider
|
|
channelId={channelId}
|
|
imagesMetadata={imagesMetadata}
|
|
inlineMarkdownActions={inlineMarkdownActions}
|
|
location={location}
|
|
postId={postId}
|
|
>
|
|
<ContainerBlock
|
|
block={block}
|
|
onAction={onAction}
|
|
theme={theme}
|
|
/>
|
|
</MmBlocksContextProvider>
|
|
);
|
|
};
|