File size: 1,316 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable no-restricted-imports */
import { EmbedContainer } from '@automattic/components';
import { useState, useCallback } from '@wordpress/element';
import { useContentFilter } from '../hooks';
import { ArticleContentProps } from '../types';
import HelpCenterFeedbackForm from './help-center-feedback-form';
import { SupportArticleHeader } from './help-center-support-article-header';
import Placeholders from './placeholder-lines';

const ArticleContent = ( { isLoading = false, post }: ArticleContentProps ) => {
	const [ theRef, setTheRef ] = useState< HTMLDivElement | null >( null );
	const articleContentRef = useCallback( ( node: HTMLDivElement | null ) => setTheRef( node ), [] );

	useContentFilter( theRef );

	return (
		<article className="help-center-article-content">
			{ isLoading || ! post ? (
				<Placeholders lines={ 8 } />
			) : (
				<>
					<SupportArticleHeader post={ post } isLoading={ false } />
					<EmbedContainer>
						<div
							className="help-center-article-content__main"
							// eslint-disable-next-line react/no-danger
							dangerouslySetInnerHTML={ { __html: post.content } }
							ref={ articleContentRef }
						/>
						<HelpCenterFeedbackForm postId={ post.ID } />
					</EmbedContainer>
				</>
			) }
		</article>
	);
};

export default ArticleContent;