Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui) Support rich text for form descriptions #10425

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion datahub-web-react/src/app/entity/shared/entityForm/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import FormRequestedBy from './FormSelectionModal/FormRequestedBy';
import useHasComponentRendered from '../../../shared/useHasComponentRendered';
import Loading from '../../../shared/Loading';
import { DeferredRenderComponent } from '../../../shared/DeferredRenderComponent';
import { Editor } from '../tabs/Documentation/components/editor/Editor';

const TabWrapper = styled.div`
background-color: ${ANTD_GRAY_V2[1]};
Expand Down Expand Up @@ -70,7 +71,9 @@ function Form({ formUrn }: Props) {
</RequestedByWrapper>
)}
{description ? (
<SubTitle>{description}</SubTitle>
<SubTitle>
<Editor content={description} readOnly editorStyle="padding: 0;" />
</SubTitle>
) : (
<SubTitle>
Please fill out the following information for this {entityRegistry.getEntityName(entityType)} so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ type EditorProps = {
doNotFocus?: boolean;
dataTestId?: string;
onKeyDown?: (event: React.KeyboardEvent<HTMLDivElement>) => void;
editorStyle?: string;
};

export const Editor = forwardRef((props: EditorProps, ref) => {
const { content, readOnly, onChange, className, dataTestId, onKeyDown } = props;
const { content, readOnly, onChange, className, dataTestId, onKeyDown, editorStyle } = props;
const { manager, state, getContext } = useRemirror({
extensions: () => [
new BlockquoteExtension(),
Expand Down Expand Up @@ -100,7 +101,7 @@ export const Editor = forwardRef((props: EditorProps, ref) => {
}, [readOnly, content]);

return (
<EditorContainer className={className} onKeyDown={onKeyDown} data-testid={dataTestId}>
<EditorContainer className={className} onKeyDown={onKeyDown} data-testid={dataTestId} editorStyle={editorStyle}>
<ThemeProvider theme={EditorTheme}>
<Remirror classNames={['ant-typography']} editable={!readOnly} manager={manager} initialContent={state}>
{!readOnly && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const EditorTheme: RemirrorThemeType = {
},
};

export const EditorContainer = styled.div`
export const EditorContainer = styled.div<{ editorStyle?: string }>`
${extensionBlockquoteStyledCss}
${extensionCalloutStyledCss}
${extensionCodeBlockStyledCss}
Expand Down Expand Up @@ -81,6 +81,7 @@ export const EditorContainer = styled.div`
line-height: 1.5;
white-space: pre-wrap;
margin: 0;
${props => props.editorStyle}

a {
font-weight: 500;
Expand Down
Loading