Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit f9d2eb3

Browse files
d-e-v-eshDianaLease
authored andcommitted
fix(ui-markdown-editor): Overriding CSS - #327
Signed-off-by: d-e-v-esh <[email protected]>
1 parent 763874e commit f9d2eb3

File tree

4 files changed

+70
-41
lines changed

4 files changed

+70
-41
lines changed

packages/ui-markdown-editor/src/FormattingToolbar/StyleFormat/index.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import { Dropdown } from 'semantic-ui-react';
55
import StyleDropdownItem from './Item';
66
import {
77
DROPDOWN_STYLE,
8-
DROPDOWN_STYLE_H1,
9-
DROPDOWN_STYLE_H2,
10-
DROPDOWN_STYLE_H3,
11-
DROPDOWN_STYLE_H4,
12-
DROPDOWN_STYLE_H5,
8+
TOOLBAR_DROPDOWN_STYLE_H1,
9+
TOOLBAR_DROPDOWN_STYLE_H2,
10+
TOOLBAR_DROPDOWN_STYLE_H3,
11+
TOOLBAR_DROPDOWN_STYLE_H4,
12+
TOOLBAR_DROPDOWN_STYLE_H5,
1313
TOOLBAR_DROPDOWN_STYLE_H6,
1414
} from '../../utilities/constants';
1515
import {
@@ -42,31 +42,31 @@ const StyleDropdown = ({ canBeFormatted, currentStyle }) => {
4242
<StyleDropdownItem
4343
editor={editor}
4444
type={H1}
45-
style={DROPDOWN_STYLE_H1}
45+
style={TOOLBAR_DROPDOWN_STYLE_H1}
4646
canBeFormatted={canBeFormatted}
4747
/>
4848
<StyleDropdownItem
4949
editor={editor}
5050
type={H2}
51-
style={DROPDOWN_STYLE_H2}
51+
style={TOOLBAR_DROPDOWN_STYLE_H2}
5252
canBeFormatted={canBeFormatted}
5353
/>
5454
<StyleDropdownItem
5555
editor={editor}
5656
type={H3}
57-
style={DROPDOWN_STYLE_H3}
57+
style={TOOLBAR_DROPDOWN_STYLE_H3}
5858
canBeFormatted={canBeFormatted}
5959
/>
6060
<StyleDropdownItem
6161
editor={editor}
6262
type={H4}
63-
style={DROPDOWN_STYLE_H4}
63+
style={TOOLBAR_DROPDOWN_STYLE_H4}
6464
canBeFormatted={canBeFormatted}
6565
/>
6666
<StyleDropdownItem
6767
editor={editor}
6868
type={H5}
69-
style={DROPDOWN_STYLE_H5}
69+
style={TOOLBAR_DROPDOWN_STYLE_H5}
7070
canBeFormatted={canBeFormatted}
7171
/>
7272
<StyleDropdownItem

packages/ui-markdown-editor/src/components/index.js

+14-13
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import {
1010
HTML_INLINE, SOFTBREAK, LINEBREAK, HEADINGS
1111
} from '../utilities/schema';
1212
import {
13-
DROPDOWN_STYLE_H1,
14-
DROPDOWN_STYLE_H2,
15-
DROPDOWN_STYLE_H3,
16-
DROPDOWN_STYLE_H4,
17-
DROPDOWN_STYLE_H5,
18-
DROPDOWN_STYLE_H6
13+
H1_STYLING,
14+
H2_STYLING,
15+
H3_STYLING,
16+
H4_STYLING,
17+
H5_STYLING,
18+
H6_STYLING,
19+
PARAGRAPH_STYLING
1920
} from '../utilities/constants';
2021
import generateId from '../utilities/generateId';
2122

@@ -26,13 +27,13 @@ const Element = (props) => {
2627
const { type, data } = element;
2728
const headingId = HEADINGS.includes(type) ? generateId(element) : null;
2829
const baseElementRenderer = {
29-
[PARAGRAPH]: () => (<p {...attributes}>{children}</p>),
30-
[H1]: () => (<Heading id={headingId} as="h1" style={DROPDOWN_STYLE_H1} {...attributes}>{children}</Heading>),
31-
[H2]: () => (<Heading id={headingId} as="h2" style={DROPDOWN_STYLE_H2} {...attributes}>{children}</Heading>),
32-
[H3]: () => (<Heading id={headingId} as="h3" style={DROPDOWN_STYLE_H3} {...attributes}>{children}</Heading>),
33-
[H4]: () => (<Heading id={headingId} as="h4" style={DROPDOWN_STYLE_H4} {...attributes}>{children}</Heading>),
34-
[H5]: () => (<Heading id={headingId} as="h5" style={DROPDOWN_STYLE_H5} {...attributes}>{children}</Heading>),
35-
[H6]: () => (<Heading id={headingId} as="h6" style={DROPDOWN_STYLE_H6} {...attributes}>{children}</Heading>),
30+
[PARAGRAPH]: () => (<p style={PARAGRAPH_STYLING} {...attributes}>{children}</p>),
31+
[H1]: () => (<Heading id={headingId} as="h1" style={H1_STYLING} {...attributes}>{children}</Heading>),
32+
[H2]: () => (<Heading id={headingId} as="h2" style={H2_STYLING} {...attributes}>{children}</Heading>),
33+
[H3]: () => (<Heading id={headingId} as="h3" style={H3_STYLING} {...attributes}>{children}</Heading>),
34+
[H4]: () => (<Heading id={headingId} as="h4" style={H4_STYLING} {...attributes}>{children}</Heading>),
35+
[H5]: () => (<Heading id={headingId} as="h5" style={H5_STYLING} {...attributes}>{children}</Heading>),
36+
[H6]: () => (<Heading id={headingId} as="h6" style={H6_STYLING} {...attributes}>{children}</Heading>),
3637
[SOFTBREAK]: () => (<span className={SOFTBREAK} {...attributes}> {children}</span>),
3738
[LINEBREAK]: () => (<span {...attributes}>
3839
<span contentEditable={false} style={{ userSelect: 'none' }}>

packages/ui-markdown-editor/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export const MarkdownEditor = (props) => {
214214
<Editable
215215
id="ap-rich-text-editor"
216216
style={{
217-
padding: '20px',
217+
padding: '0px 20px 10px 20px',
218218
border: '1px solid grey',
219219
borderRadius: '4px',
220220
minWidth: '600px'

packages/ui-markdown-editor/src/utilities/constants.js

+45-17
Original file line numberDiff line numberDiff line change
@@ -37,61 +37,89 @@ export const DROPDOWN_STYLE = {
3737
width: '100px',
3838
};
3939

40-
export const DROPDOWN_STYLE_H1 = {
40+
export const PARAGRAPH_STYLING = {
41+
margin: '1rem 0rem 0rem 0rem'
42+
}
43+
44+
export const H1_STYLING = {
4145
fontSize: '25px',
4246
lineHeight: '23px',
47+
margin: '2rem 0rem 1rem 0rem',
4348
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
4449
color: MISC_CONSTANTS.DROPDOWN_COLOR,
4550
textAlign: 'center',
4651
};
4752

48-
export const DROPDOWN_STYLE_H2 = {
53+
export const H2_STYLING = {
4954
fontSize: '25px',
5055
lineHeight: '23px',
56+
margin: '1.8rem 0rem 0.9rem 0rem',
5157
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
5258
color: MISC_CONSTANTS.DROPDOWN_COLOR,
5359
};
5460

55-
export const DROPDOWN_STYLE_H3 = {
61+
export const H3_STYLING = {
5662
fontSize: '20px',
5763
lineHeight: '20px',
64+
margin: '1.6rem 0rem 0.8rem 0rem',
5865
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
5966
color: MISC_CONSTANTS.DROPDOWN_COLOR,
6067
};
6168

62-
export const DROPDOWN_STYLE_H4 = {
69+
export const H4_STYLING = {
6370
fontSize: '18px',
6471
lineHeight: '18px',
72+
margin: '1.4rem 0rem 0.7rem 0rem',
6573
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
6674
color: MISC_CONSTANTS.DROPDOWN_COLOR,
6775
};
6876

69-
export const DROPDOWN_STYLE_H5 = {
70-
fontSize: '16x',
77+
export const H5_STYLING = {
78+
fontSize: '16px',
7179
lineHeight: '16px',
80+
margin: '1.2rem 0rem 0.6rem 0rem',
7281
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
7382
color: MISC_CONSTANTS.DROPDOWN_COLOR,
7483
};
7584

76-
export const DROPDOWN_STYLE_H6 = {
85+
export const H6_STYLING = {
7786
fontSize: '14px',
7887
lineHeight: '14px',
79-
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
8088
color: '#949CA2',
8189
letterSpacing: '0.3px',
82-
// This margin is to override default styling in chrome
83-
margin: '0.7rem 0rem 1rem 0rem',
8490
textTransform: 'uppercase',
91+
margin: '1.2rem 0rem 0.5rem 0rem',
92+
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
93+
};
94+
95+
export const TOOLBAR_DROPDOWN_STYLE_H1 = {
96+
...H1_STYLING,
97+
margin: 0
98+
};
99+
100+
export const TOOLBAR_DROPDOWN_STYLE_H2 = {
101+
...H2_STYLING,
102+
margin: 0
103+
};
104+
105+
export const TOOLBAR_DROPDOWN_STYLE_H3 = {
106+
...H3_STYLING,
107+
margin: 0
108+
};
109+
110+
export const TOOLBAR_DROPDOWN_STYLE_H4 = {
111+
...H4_STYLING,
112+
margin: 0
113+
};
114+
115+
export const TOOLBAR_DROPDOWN_STYLE_H5 = {
116+
...H5_STYLING,
117+
margin: 0
85118
};
86119

87-
// Separate styling for the toolbar without margin to make it look normal
88120
export const TOOLBAR_DROPDOWN_STYLE_H6 = {
89-
fontSize: '14px',
90-
lineHeight: '14px',
91-
fontWeight: MISC_CONSTANTS.DROPDOWN_WEIGHT,
92-
color: '#949CA2',
93-
letterSpacing: '0.3px',
94-
textTransform: 'uppercase',
121+
...H6_STYLING,
122+
margin: 0
95123
};
96124

97125
export const POPUP_STYLE = {

0 commit comments

Comments
 (0)