@kids-reporter/draft-renderer 0.4.8 → 0.4.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/block-render-map.js
CHANGED
|
@@ -14,30 +14,26 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
15
|
// @ts-ignore pkg does not contain ts header file
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const Paragraph = _styledComponents.default.div`
|
|
18
18
|
width: 100%;
|
|
19
19
|
max-width: 700px;
|
|
20
|
-
margin: 0 auto 27px auto;
|
|
21
20
|
font-size: 18px;
|
|
22
21
|
font-weight: 500;
|
|
23
22
|
color: #3a4f66;
|
|
24
23
|
letter-spacing: 0.9px;
|
|
25
24
|
line-height: 2;
|
|
25
|
+
margin: 0 auto;
|
|
26
26
|
|
|
27
27
|
${_mediaQuery.default.mobileOnly`
|
|
28
28
|
padding-left: 15px;
|
|
29
29
|
padding-right: 15px;
|
|
30
30
|
`}
|
|
31
|
+
|
|
32
|
+
> div[data-block="true"] {
|
|
33
|
+
margin-bottom: 27px;
|
|
34
|
+
}
|
|
31
35
|
`;
|
|
32
|
-
|
|
33
|
-
className,
|
|
34
|
-
children
|
|
35
|
-
}) {
|
|
36
|
-
return /*#__PURE__*/_react.default.createElement(ParagraphBlock, {
|
|
37
|
-
className: className
|
|
38
|
-
}, children);
|
|
39
|
-
}
|
|
40
|
-
const HeadingBlock = _styledComponents.default.div`
|
|
36
|
+
const Heading = _styledComponents.default.div`
|
|
41
37
|
font-weight: 700;
|
|
42
38
|
line-height: 1.5;
|
|
43
39
|
color: #232323;
|
|
@@ -73,15 +69,7 @@ const HeadingBlock = _styledComponents.default.div`
|
|
|
73
69
|
padding-right: 15px;
|
|
74
70
|
`}
|
|
75
71
|
`;
|
|
76
|
-
|
|
77
|
-
className,
|
|
78
|
-
children
|
|
79
|
-
}) {
|
|
80
|
-
return /*#__PURE__*/_react.default.createElement(HeadingBlock, {
|
|
81
|
-
className: className
|
|
82
|
-
}, children);
|
|
83
|
-
}
|
|
84
|
-
const ListBlock = _styledComponents.default.ol`
|
|
72
|
+
const List = _styledComponents.default.ol`
|
|
85
73
|
width: 100%;
|
|
86
74
|
max-width: 700px;
|
|
87
75
|
margin: 0 auto 27px auto;
|
|
@@ -94,26 +82,16 @@ const ListBlock = _styledComponents.default.ol`
|
|
|
94
82
|
margin-bottom: 6px;
|
|
95
83
|
}
|
|
96
84
|
`;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}, children);
|
|
104
|
-
}
|
|
105
|
-
function UnorderdedList({
|
|
106
|
-
children,
|
|
107
|
-
className
|
|
108
|
-
}) {
|
|
109
|
-
return /*#__PURE__*/_react.default.createElement(ListBlock, {
|
|
110
|
-
as: "ul",
|
|
111
|
-
className: className
|
|
112
|
-
}, children);
|
|
113
|
-
}
|
|
85
|
+
const Atomic = _styledComponents.default.div`
|
|
86
|
+
/* hide empty block which immediately follows atomic block */
|
|
87
|
+
& + ${Paragraph} {
|
|
88
|
+
display: none;
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
114
91
|
const _blockRenderMap = _immutable.default.Map({
|
|
115
92
|
atomic: {
|
|
116
|
-
element: 'div'
|
|
93
|
+
element: 'div',
|
|
94
|
+
wrapper: /*#__PURE__*/_react.default.createElement(Atomic, null)
|
|
117
95
|
},
|
|
118
96
|
'header-two': {
|
|
119
97
|
element: 'h2',
|
|
@@ -133,11 +111,13 @@ const _blockRenderMap = _immutable.default.Map({
|
|
|
133
111
|
},
|
|
134
112
|
'ordered-list-item': {
|
|
135
113
|
element: 'li',
|
|
136
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
114
|
+
wrapper: /*#__PURE__*/_react.default.createElement(List, null)
|
|
137
115
|
},
|
|
138
116
|
'unordered-list-item': {
|
|
139
117
|
element: 'li',
|
|
140
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
118
|
+
wrapper: /*#__PURE__*/_react.default.createElement(List, {
|
|
119
|
+
as: "ul"
|
|
120
|
+
})
|
|
141
121
|
},
|
|
142
122
|
unstyled: {
|
|
143
123
|
element: 'div',
|
|
@@ -149,20 +129,19 @@ exports.blockRenderMap = blockRenderMap;
|
|
|
149
129
|
const ParagraphForIntroduction = (0, _styledComponents.default)(Paragraph)`
|
|
150
130
|
color: #575757;
|
|
151
131
|
`;
|
|
152
|
-
const
|
|
153
|
-
color: #575757;
|
|
154
|
-
`;
|
|
155
|
-
const UnorderdedListForIntroduction = (0, _styledComponents.default)(UnorderdedList)`
|
|
132
|
+
const ListForIntroduction = (0, _styledComponents.default)(List)`
|
|
156
133
|
color: #575757;
|
|
157
134
|
`;
|
|
158
135
|
const blockRenderMapForIntroduction = _draftJs.DefaultDraftBlockRenderMap.merge(_immutable.default.Map({
|
|
159
136
|
'ordered-list-item': {
|
|
160
137
|
element: 'li',
|
|
161
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
138
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForIntroduction, null)
|
|
162
139
|
},
|
|
163
140
|
'unordered-list-item': {
|
|
164
141
|
element: 'li',
|
|
165
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
142
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForIntroduction, {
|
|
143
|
+
as: "ul"
|
|
144
|
+
})
|
|
166
145
|
},
|
|
167
146
|
unstyled: {
|
|
168
147
|
element: 'div',
|
|
@@ -173,12 +152,7 @@ exports.blockRenderMapForIntroduction = blockRenderMapForIntroduction;
|
|
|
173
152
|
const HeadingForAnnotation = (0, _styledComponents.default)(Heading)`
|
|
174
153
|
margin: 0 auto 27px auto;
|
|
175
154
|
`;
|
|
176
|
-
const
|
|
177
|
-
li {
|
|
178
|
-
font-size: 16px;
|
|
179
|
-
}
|
|
180
|
-
`;
|
|
181
|
-
const UnorderdedListForAnnotation = (0, _styledComponents.default)(UnorderdedList)`
|
|
155
|
+
const ListForAnnotation = (0, _styledComponents.default)(List)`
|
|
182
156
|
li {
|
|
183
157
|
font-size: 16px;
|
|
184
158
|
}
|
|
@@ -203,11 +177,13 @@ const _blockRenderMapForAnnotation = _immutable.default.Map({
|
|
|
203
177
|
},
|
|
204
178
|
'ordered-list-item': {
|
|
205
179
|
element: 'li',
|
|
206
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
180
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForAnnotation, null)
|
|
207
181
|
},
|
|
208
182
|
'unordered-list-item': {
|
|
209
183
|
element: 'li',
|
|
210
|
-
wrapper: /*#__PURE__*/_react.default.createElement(
|
|
184
|
+
wrapper: /*#__PURE__*/_react.default.createElement(ListForAnnotation, {
|
|
185
|
+
as: "ul"
|
|
186
|
+
})
|
|
211
187
|
},
|
|
212
188
|
unstyled: {
|
|
213
189
|
element: 'div',
|
|
@@ -36,7 +36,6 @@ const DropdownOption = _styledComponents.default.li`
|
|
|
36
36
|
const Container = _styledComponents.default.div`
|
|
37
37
|
width: 100%;
|
|
38
38
|
overflow: hidden;
|
|
39
|
-
cursor: pointer;
|
|
40
39
|
|
|
41
40
|
font-size: 18px;
|
|
42
41
|
font-weight: 400;
|
|
@@ -54,13 +53,14 @@ const Input = _styledComponents.default.input`
|
|
|
54
53
|
padding: 12px 0;
|
|
55
54
|
outline: none;
|
|
56
55
|
border: none;
|
|
57
|
-
cursor: pointer;
|
|
58
56
|
`;
|
|
59
|
-
const
|
|
57
|
+
const Label = _styledComponents.default.span`
|
|
60
58
|
margin-left: 10px;
|
|
61
59
|
font-size: 14px;
|
|
60
|
+
cursor: pointer;
|
|
62
61
|
`;
|
|
63
62
|
const Arrow = _styledComponents.default.span`
|
|
63
|
+
cursor: pointer;
|
|
64
64
|
margin-left: auto;
|
|
65
65
|
|
|
66
66
|
width: 20px;
|
|
@@ -93,6 +93,9 @@ const Dropdown = function ({
|
|
|
93
93
|
const [isListOpen, setIsListOpen] = (0, _react.useState)(false);
|
|
94
94
|
const [selectedOption, setSelectedOption] = (0, _react.useState)(options === null || options === void 0 ? void 0 : options[0]);
|
|
95
95
|
const toggleList = () => {
|
|
96
|
+
if (options.length <= 1) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
96
99
|
setIsListOpen(!isListOpen);
|
|
97
100
|
};
|
|
98
101
|
const selectOption = option => {
|
|
@@ -115,6 +118,6 @@ const Dropdown = function ({
|
|
|
115
118
|
value: selectedOption.name
|
|
116
119
|
}), options.length > 1 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(Arrow, {
|
|
117
120
|
$isListOpen: isListOpen
|
|
118
|
-
}), labelForMore && /*#__PURE__*/_react.default.createElement(
|
|
121
|
+
}), labelForMore && /*#__PURE__*/_react.default.createElement(Label, null, labelForMore))), isListOpen && /*#__PURE__*/_react.default.createElement(DropdownOptionList, null, optionItem));
|
|
119
122
|
};
|
|
120
123
|
exports.Dropdown = Dropdown;
|
|
@@ -59,12 +59,6 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
59
59
|
margin: 0;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
&::after {
|
|
63
|
-
content: '';
|
|
64
|
-
display: table;
|
|
65
|
-
clear: both;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
62
|
max-width: 100%;
|
|
69
63
|
margin: 0 auto 27px auto;
|
|
70
64
|
|
|
@@ -81,31 +75,23 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
81
75
|
case 'paragraph-width':
|
|
82
76
|
return `
|
|
83
77
|
${_index.theme.breakpoint.xl} {
|
|
84
|
-
|
|
85
|
-
width: 700px;
|
|
86
|
-
margin-left: auto;
|
|
87
|
-
margin-right: auto;
|
|
88
|
-
}
|
|
78
|
+
max-width: 700px;
|
|
89
79
|
}
|
|
90
80
|
`;
|
|
91
81
|
case 'right':
|
|
92
82
|
return `
|
|
93
83
|
${_index.theme.breakpoint.xl} {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
margin: 5px 0px 5px 27px;
|
|
98
|
-
}
|
|
84
|
+
width: 361px;
|
|
85
|
+
float: right;
|
|
86
|
+
margin: 5px 0px 5px 27px;
|
|
99
87
|
}
|
|
100
88
|
`;
|
|
101
89
|
case 'left':
|
|
102
90
|
return `
|
|
103
91
|
${_index.theme.breakpoint.xl} {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
margin: 5px 27px 5px 0px;
|
|
108
|
-
}
|
|
92
|
+
width: 361px;
|
|
93
|
+
float: left;
|
|
94
|
+
margin: 5px 27px 5px 0px;
|
|
109
95
|
}
|
|
110
96
|
`;
|
|
111
97
|
}
|
|
@@ -130,40 +116,15 @@ const InfoBoxContainer = _styledComponents.default.div`
|
|
|
130
116
|
margin-bottom: 30px;
|
|
131
117
|
width: fit-content;
|
|
132
118
|
|
|
133
|
-
&::after {
|
|
134
|
-
content: '';
|
|
135
|
-
display: table;
|
|
136
|
-
clear: both;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
119
|
${props => {
|
|
140
120
|
switch (props.$alignment) {
|
|
141
|
-
case '
|
|
142
|
-
{
|
|
143
|
-
return `
|
|
144
|
-
figure {
|
|
145
|
-
margin-left: auto;
|
|
146
|
-
margin-right: auto;
|
|
147
|
-
}
|
|
148
|
-
`;
|
|
149
|
-
}
|
|
150
|
-
case 'left':
|
|
121
|
+
case 'center':
|
|
151
122
|
{
|
|
152
|
-
return `
|
|
153
|
-
figure {
|
|
154
|
-
max-width: 50%;
|
|
155
|
-
margin-right: auto;
|
|
156
|
-
}
|
|
157
|
-
`;
|
|
123
|
+
return `margin-left: auto; margin-right: auto;`;
|
|
158
124
|
}
|
|
159
125
|
case 'right':
|
|
160
126
|
{
|
|
161
|
-
return `
|
|
162
|
-
figure {
|
|
163
|
-
max-width: 50%;
|
|
164
|
-
margin-left: auto;
|
|
165
|
-
}
|
|
166
|
-
`;
|
|
127
|
+
return `margin-left: auto`;
|
|
167
128
|
}
|
|
168
129
|
}
|
|
169
130
|
}}
|
|
@@ -40,6 +40,9 @@ const NewsReading = function ({
|
|
|
40
40
|
}), [readings]);
|
|
41
41
|
const [selectedOption, setSelectedOption] = (0, _react.useState)(options[0]);
|
|
42
42
|
const selectedReading = readings.find(r => r.name === selectedOption.value);
|
|
43
|
+
if (readings.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
43
46
|
return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
|
|
44
47
|
className: className
|
|
45
48
|
}, /*#__PURE__*/_react.default.createElement(_dropdown.Dropdown, {
|