@kids-reporter/draft-renderer 0.4.0 → 0.4.1
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 +14 -21
- package/lib/block-renderer-fn.js +0 -11
- package/lib/block-renderers/blockquote.js +3 -14
- package/lib/block-renderers/embedded-code-block.js +3 -14
- package/lib/block-renderers/image-block.js +0 -16
- package/lib/block-renderers/index.js +0 -6
- package/lib/block-renderers/info-box-block.js +5 -32
- package/lib/block-renderers/multimedia.js +7 -10
- package/lib/block-renderers/slideshow-block.js +31 -58
- package/lib/draft-renderer.js +2 -21
- package/lib/entity-decorators/annotation-decorator.js +2 -15
- package/lib/entity-decorators/index.js +0 -4
- package/lib/entity-decorators/link-decorator.js +0 -7
- package/lib/index.js +0 -6
- package/package.json +1 -1
package/lib/block-render-map.js
CHANGED
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.blockRenderMapForInfoBoxWithHeaderBorder = exports.blockRenderMapForInfoBox = exports.blockRenderMapForAnnotation = exports.blockRenderMap = void 0;
|
|
7
|
-
|
|
8
7
|
var _immutable = _interopRequireDefault(require("immutable"));
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _draftJs = require("draft-js");
|
|
15
|
-
|
|
16
11
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
-
|
|
18
12
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
14
|
const ParagraphBlock = _styledComponents.default.div`
|
|
23
15
|
width: 100%;
|
|
24
16
|
max-width: 700px;
|
|
@@ -29,7 +21,6 @@ const ParagraphBlock = _styledComponents.default.div`
|
|
|
29
21
|
letter-spacing: 0.9px;
|
|
30
22
|
line-height: 2;
|
|
31
23
|
`;
|
|
32
|
-
|
|
33
24
|
function Paragraph({
|
|
34
25
|
className,
|
|
35
26
|
children
|
|
@@ -38,7 +29,6 @@ function Paragraph({
|
|
|
38
29
|
className: className
|
|
39
30
|
}, children);
|
|
40
31
|
}
|
|
41
|
-
|
|
42
32
|
const HeadingBlock = _styledComponents.default.div`
|
|
43
33
|
font-weight: 700;
|
|
44
34
|
line-height: 1.5;
|
|
@@ -49,7 +39,8 @@ const HeadingBlock = _styledComponents.default.div`
|
|
|
49
39
|
|
|
50
40
|
h2,
|
|
51
41
|
h3,
|
|
52
|
-
h4
|
|
42
|
+
h4,
|
|
43
|
+
h5 {
|
|
53
44
|
margin: 0;
|
|
54
45
|
}
|
|
55
46
|
|
|
@@ -64,8 +55,11 @@ const HeadingBlock = _styledComponents.default.div`
|
|
|
64
55
|
h4 {
|
|
65
56
|
font-size: 25px;
|
|
66
57
|
}
|
|
67
|
-
`;
|
|
68
58
|
|
|
59
|
+
h5 {
|
|
60
|
+
font-size: 20px;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
69
63
|
function Heading({
|
|
70
64
|
className,
|
|
71
65
|
children
|
|
@@ -74,7 +68,6 @@ function Heading({
|
|
|
74
68
|
className: className
|
|
75
69
|
}, children);
|
|
76
70
|
}
|
|
77
|
-
|
|
78
71
|
const ListBlock = _styledComponents.default.ol`
|
|
79
72
|
width: 100%;
|
|
80
73
|
max-width: 700px;
|
|
@@ -88,7 +81,6 @@ const ListBlock = _styledComponents.default.ol`
|
|
|
88
81
|
margin-bottom: 6px;
|
|
89
82
|
}
|
|
90
83
|
`;
|
|
91
|
-
|
|
92
84
|
function OrderdedList({
|
|
93
85
|
children,
|
|
94
86
|
className
|
|
@@ -97,7 +89,6 @@ function OrderdedList({
|
|
|
97
89
|
className: className
|
|
98
90
|
}, children);
|
|
99
91
|
}
|
|
100
|
-
|
|
101
92
|
function UnorderdedList({
|
|
102
93
|
children,
|
|
103
94
|
className
|
|
@@ -107,7 +98,6 @@ function UnorderdedList({
|
|
|
107
98
|
className: className
|
|
108
99
|
}, children);
|
|
109
100
|
}
|
|
110
|
-
|
|
111
101
|
const _blockRenderMap = _immutable.default.Map({
|
|
112
102
|
atomic: {
|
|
113
103
|
element: 'div'
|
|
@@ -124,6 +114,10 @@ const _blockRenderMap = _immutable.default.Map({
|
|
|
124
114
|
element: 'h4',
|
|
125
115
|
wrapper: /*#__PURE__*/_react.default.createElement(Heading, null)
|
|
126
116
|
},
|
|
117
|
+
'header-five': {
|
|
118
|
+
element: 'h5',
|
|
119
|
+
wrapper: /*#__PURE__*/_react.default.createElement(Heading, null)
|
|
120
|
+
},
|
|
127
121
|
'ordered-list-item': {
|
|
128
122
|
element: 'li',
|
|
129
123
|
wrapper: /*#__PURE__*/_react.default.createElement(OrderdedList, null)
|
|
@@ -137,9 +131,7 @@ const _blockRenderMap = _immutable.default.Map({
|
|
|
137
131
|
wrapper: /*#__PURE__*/_react.default.createElement(Paragraph, null)
|
|
138
132
|
}
|
|
139
133
|
});
|
|
140
|
-
|
|
141
134
|
const blockRenderMap = _draftJs.DefaultDraftBlockRenderMap.merge(_blockRenderMap);
|
|
142
|
-
|
|
143
135
|
exports.blockRenderMap = blockRenderMap;
|
|
144
136
|
const HeadingForAnnotation = (0, _styledComponents.default)(Heading)`
|
|
145
137
|
margin: 0 auto 27px auto;
|
|
@@ -160,12 +152,15 @@ const ParagraphForAnnotation = (0, _styledComponents.default)(Paragraph)`
|
|
|
160
152
|
font-weight: 400;
|
|
161
153
|
margin-bottom: 20px;
|
|
162
154
|
`;
|
|
163
|
-
|
|
164
155
|
const _blockRenderMapForAnnotation = _immutable.default.Map({
|
|
165
156
|
'header-four': {
|
|
166
157
|
element: 'h4',
|
|
167
158
|
wrapper: /*#__PURE__*/_react.default.createElement(HeadingForAnnotation, null)
|
|
168
159
|
},
|
|
160
|
+
'header-five': {
|
|
161
|
+
element: 'h5',
|
|
162
|
+
wrapper: /*#__PURE__*/_react.default.createElement(HeadingForAnnotation, null)
|
|
163
|
+
},
|
|
169
164
|
'ordered-list-item': {
|
|
170
165
|
element: 'li',
|
|
171
166
|
wrapper: /*#__PURE__*/_react.default.createElement(OrderdedListForAnnotation, null)
|
|
@@ -179,9 +174,7 @@ const _blockRenderMapForAnnotation = _immutable.default.Map({
|
|
|
179
174
|
wrapper: /*#__PURE__*/_react.default.createElement(ParagraphForAnnotation, null)
|
|
180
175
|
}
|
|
181
176
|
});
|
|
182
|
-
|
|
183
177
|
const blockRenderMapForAnnotation = _draftJs.DefaultDraftBlockRenderMap.merge(_blockRenderMapForAnnotation);
|
|
184
|
-
|
|
185
178
|
exports.blockRenderMapForAnnotation = blockRenderMapForAnnotation;
|
|
186
179
|
const HeadingForInfoBox = (0, _styledComponents.default)(Heading)`
|
|
187
180
|
margin-top: 30px;
|
package/lib/block-renderer-fn.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.atomicBlockRenderer = atomicBlockRenderer;
|
|
7
|
-
|
|
8
7
|
var _blockRenderers = require("./block-renderers");
|
|
9
|
-
|
|
10
8
|
const {
|
|
11
9
|
BlockquoteInArticleBody,
|
|
12
10
|
EmbeddedCodeInArticleBody,
|
|
@@ -14,12 +12,10 @@ const {
|
|
|
14
12
|
InfoBoxInArticleBody,
|
|
15
13
|
SlideshowInArticleBody
|
|
16
14
|
} = _blockRenderers.blockRenderers;
|
|
17
|
-
|
|
18
15
|
const AtomicBlock = props => {
|
|
19
16
|
const entity = props.contentState.getEntity(props.block.getEntityAt(0));
|
|
20
17
|
const entityType = entity.getType();
|
|
21
18
|
const entityData = entity.getData();
|
|
22
|
-
|
|
23
19
|
switch (entityType) {
|
|
24
20
|
case 'BLOCKQUOTE':
|
|
25
21
|
{
|
|
@@ -27,28 +23,24 @@ const AtomicBlock = props => {
|
|
|
27
23
|
data: entityData
|
|
28
24
|
});
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
case 'IMAGE':
|
|
32
27
|
{
|
|
33
28
|
return ImageInArticleBody({
|
|
34
29
|
data: entityData
|
|
35
30
|
});
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
case 'SLIDESHOW':
|
|
39
33
|
{
|
|
40
34
|
return SlideshowInArticleBody({
|
|
41
35
|
data: entityData
|
|
42
36
|
});
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
case 'EMBEDDEDCODE':
|
|
46
39
|
{
|
|
47
40
|
return EmbeddedCodeInArticleBody({
|
|
48
41
|
data: entityData
|
|
49
42
|
});
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
case 'INFOBOX':
|
|
53
45
|
{
|
|
54
46
|
return InfoBoxInArticleBody({
|
|
@@ -56,10 +48,8 @@ const AtomicBlock = props => {
|
|
|
56
48
|
});
|
|
57
49
|
}
|
|
58
50
|
}
|
|
59
|
-
|
|
60
51
|
return null;
|
|
61
52
|
};
|
|
62
|
-
|
|
63
53
|
function atomicBlockRenderer(block) {
|
|
64
54
|
if (block.getType() === 'atomic') {
|
|
65
55
|
return {
|
|
@@ -67,6 +57,5 @@ function atomicBlockRenderer(block) {
|
|
|
67
57
|
editable: false
|
|
68
58
|
};
|
|
69
59
|
}
|
|
70
|
-
|
|
71
60
|
return null;
|
|
72
61
|
}
|
|
@@ -6,25 +6,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BlockquoteInArticleBody = BlockquoteInArticleBody;
|
|
7
7
|
exports.BorderLeftBlockquote = BorderLeftBlockquote;
|
|
8
8
|
exports.QuoteLeftBlockquote = QuoteLeftBlockquote;
|
|
9
|
-
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
12
|
const BorderLeftContainer = _styledComponents.default.blockquote`
|
|
17
13
|
margin: 0;
|
|
18
14
|
padding-left: 30px;
|
|
19
15
|
border-left: 4px solid #27b5f7;
|
|
20
16
|
`;
|
|
21
|
-
|
|
22
17
|
function BorderLeftBlockquote({
|
|
23
18
|
text
|
|
24
19
|
}) {
|
|
25
20
|
return /*#__PURE__*/_react.default.createElement(BorderLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
const QuoteLeftContainer = _styledComponents.default.blockquote`
|
|
29
23
|
margin: 0;
|
|
30
24
|
padding: 40px;
|
|
@@ -48,7 +42,6 @@ const SvgBlock = _styledComponents.default.div`
|
|
|
48
42
|
width: 36px;
|
|
49
43
|
}
|
|
50
44
|
`;
|
|
51
|
-
|
|
52
45
|
function QuoteSvg() {
|
|
53
46
|
return /*#__PURE__*/_react.default.createElement(SvgBlock, null, /*#__PURE__*/_react.default.createElement("svg", {
|
|
54
47
|
fill: "#27B5F7",
|
|
@@ -59,24 +52,20 @@ function QuoteSvg() {
|
|
|
59
52
|
d: "M9.4 14.6c-2.4 2.9-3.6 5.9-3.6 8.9 0 1.3.2 2.4.5 3.3 1.8-1.4 3.8-2.1 6-2.1 2.9 0 5.3.9 7.3 2.7 2 1.8 3 4.2 3 7.3 0 1.9-.5 3.6-1.4 5.1-.9 1.5-2.2 2.7-3.8 3.6s-3.3 1.3-5.1 1.3c-4.1 0-7.3-1.6-9.5-4.9C.9 36.9 0 33.5 0 29.4c0-5.2 1.4-9.9 4.1-14 2.8-4.1 6.9-7.5 12.5-10l1.5 2.8c-3.3 1.3-6.2 3.5-8.7 6.4zm27.5 0c-2.4 2.9-3.6 5.9-3.6 8.9 0 1.3.2 2.4.5 3.3 1.8-1.4 3.8-2.1 6-2.1 2.9 0 5.4.9 7.4 2.7 2 1.8 3 4.2 3 7.3 0 2.8-1 5.2-3 7.1-2 1.9-4.4 2.9-7.3 2.9-4.1 0-7.3-1.6-9.5-4.9-1.8-2.7-2.8-6.2-2.8-10.3 0-5.2 1.4-9.9 4.1-14 2.8-4.1 6.9-7.5 12.5-10l1.5 2.8c-3.5 1.2-6.4 3.4-8.8 6.3z"
|
|
60
53
|
})));
|
|
61
54
|
}
|
|
62
|
-
|
|
63
55
|
function QuoteLeftBlockquote({
|
|
64
56
|
text
|
|
65
57
|
}) {
|
|
66
58
|
return /*#__PURE__*/_react.default.createElement(QuoteLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteSvg, null), /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
|
|
67
59
|
}
|
|
68
|
-
|
|
69
60
|
const ArticleBodyContainer = _styledComponents.default.div`
|
|
70
61
|
max-width: 700px;
|
|
71
62
|
margin: 0 auto 27px auto;
|
|
72
63
|
`;
|
|
73
|
-
var BlockquoteType
|
|
74
|
-
|
|
75
|
-
(function (BlockquoteType) {
|
|
64
|
+
var BlockquoteType = /*#__PURE__*/function (BlockquoteType) {
|
|
76
65
|
BlockquoteType["borderLeft"] = "border_left";
|
|
77
66
|
BlockquoteType["quoteLeft"] = "quote_left";
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
return BlockquoteType;
|
|
68
|
+
}(BlockquoteType || {});
|
|
80
69
|
function BlockquoteInArticleBody({
|
|
81
70
|
className = '',
|
|
82
71
|
data = {
|
|
@@ -5,19 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EmbeddedCodeBlock = exports.Caption = exports.Block = void 0;
|
|
7
7
|
exports.EmbeddedCodeInArticleBody = EmbeddedCodeInArticleBody;
|
|
8
|
-
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
|
|
11
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
12
|
-
|
|
13
10
|
var _nodeHtmlParser = require("node-html-parser");
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
-
|
|
19
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
-
|
|
21
14
|
const Block = _styledComponents.default.div`
|
|
22
15
|
position: relative;
|
|
23
16
|
white-space: normal;
|
|
@@ -40,7 +33,6 @@ const Caption = _styledComponents.default.div`
|
|
|
40
33
|
padding: 15px 15px 0 15px;
|
|
41
34
|
`;
|
|
42
35
|
exports.Caption = Caption;
|
|
43
|
-
|
|
44
36
|
const EmbeddedCodeBlock = ({
|
|
45
37
|
className,
|
|
46
38
|
data
|
|
@@ -49,7 +41,9 @@ const EmbeddedCodeBlock = ({
|
|
|
49
41
|
caption,
|
|
50
42
|
embeddedCode
|
|
51
43
|
} = data;
|
|
52
|
-
const embedded = (0, _react.useRef)(null);
|
|
44
|
+
const embedded = (0, _react.useRef)(null);
|
|
45
|
+
|
|
46
|
+
// `embeddedCode` is a string, which may includes
|
|
53
47
|
// multiple script tags and other html tags.
|
|
54
48
|
// Here we separate script tags and other html tags
|
|
55
49
|
// by using the isomorphic html parser 'node-html-parser'
|
|
@@ -65,7 +59,6 @@ const EmbeddedCodeBlock = ({
|
|
|
65
59
|
// 2. Although the setInnerhtml way won't trigger script tags, those script tags
|
|
66
60
|
// will still show on the HTML provided from SSR. When the browser parse the
|
|
67
61
|
// html it will run those script and produce unexpected behavior.
|
|
68
|
-
|
|
69
62
|
const nodes = (0, _react.useMemo)(() => {
|
|
70
63
|
const ele = (0, _nodeHtmlParser.parse)(`<div id="draft-embed">${embeddedCode}</div>`);
|
|
71
64
|
const scripts = ele.querySelectorAll('script');
|
|
@@ -91,11 +84,9 @@ const EmbeddedCodeBlock = ({
|
|
|
91
84
|
scripts.forEach(s => {
|
|
92
85
|
const scriptEle = document.createElement('script');
|
|
93
86
|
const attrs = s.attributes;
|
|
94
|
-
|
|
95
87
|
for (const key in attrs) {
|
|
96
88
|
scriptEle.setAttribute(key, attrs[key]);
|
|
97
89
|
}
|
|
98
|
-
|
|
99
90
|
scriptEle.text = s.text || '';
|
|
100
91
|
fragment.appendChild(scriptEle);
|
|
101
92
|
});
|
|
@@ -114,13 +105,11 @@ const EmbeddedCodeBlock = ({
|
|
|
114
105
|
}
|
|
115
106
|
}), caption && /*#__PURE__*/_react.default.createElement(Caption, null, caption));
|
|
116
107
|
};
|
|
117
|
-
|
|
118
108
|
exports.EmbeddedCodeBlock = EmbeddedCodeBlock;
|
|
119
109
|
const ArticleBodyContainer = _styledComponents.default.div`
|
|
120
110
|
max-width: 700px;
|
|
121
111
|
margin: 0 auto 27px auto;
|
|
122
112
|
`;
|
|
123
|
-
|
|
124
113
|
function EmbeddedCodeInArticleBody({
|
|
125
114
|
className = '',
|
|
126
115
|
data
|
|
@@ -6,15 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ImageBlock = ImageBlock;
|
|
7
7
|
exports.ImageInArticleBody = ImageInArticleBody;
|
|
8
8
|
exports.ImageInInfoBox = ImageInInfoBox;
|
|
9
|
-
|
|
10
9
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
10
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
11
|
var _index = require("../theme/index");
|
|
15
|
-
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
13
|
const Figure = _styledComponents.default.figure`
|
|
19
14
|
width: 100%;
|
|
20
15
|
`;
|
|
@@ -32,7 +27,6 @@ const FigureCaption = _styledComponents.default.figcaption`
|
|
|
32
27
|
const Img = _styledComponents.default.img`
|
|
33
28
|
width: 100%;
|
|
34
29
|
`;
|
|
35
|
-
|
|
36
30
|
function ImageBlock({
|
|
37
31
|
className = '',
|
|
38
32
|
data
|
|
@@ -43,15 +37,12 @@ function ImageBlock({
|
|
|
43
37
|
resized
|
|
44
38
|
} = data || {};
|
|
45
39
|
const imgSrcSetArr = [];
|
|
46
|
-
|
|
47
40
|
if (resized !== null && resized !== void 0 && resized.medium) {
|
|
48
41
|
imgSrcSetArr.push(`${resized.medium} 500w`);
|
|
49
42
|
}
|
|
50
|
-
|
|
51
43
|
if (resized !== null && resized !== void 0 && resized.large) {
|
|
52
44
|
imgSrcSetArr.push(`${resized.large} 1000w`);
|
|
53
45
|
}
|
|
54
|
-
|
|
55
46
|
const imgBlock = /*#__PURE__*/_react.default.createElement(Figure, {
|
|
56
47
|
className: className
|
|
57
48
|
}, /*#__PURE__*/_react.default.createElement(Img, {
|
|
@@ -60,10 +51,8 @@ function ImageBlock({
|
|
|
60
51
|
srcSet: imgSrcSetArr.join(','),
|
|
61
52
|
sizes: "(min-width: 1200px) 1000px, 100vw"
|
|
62
53
|
}), /*#__PURE__*/_react.default.createElement(FigureCaption, null, desc));
|
|
63
|
-
|
|
64
54
|
return imgBlock;
|
|
65
55
|
}
|
|
66
|
-
|
|
67
56
|
const ArticleBodyContainer = _styledComponents.default.div`
|
|
68
57
|
/* reset browser default styles */
|
|
69
58
|
figure {
|
|
@@ -91,7 +80,6 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
91
80
|
margin: 5px 0px 5px 27px;
|
|
92
81
|
}
|
|
93
82
|
`;
|
|
94
|
-
|
|
95
83
|
case 'left':
|
|
96
84
|
return `
|
|
97
85
|
${_index.theme.breakpoint.xl} {
|
|
@@ -103,7 +91,6 @@ const ArticleBodyContainer = _styledComponents.default.div`
|
|
|
103
91
|
}
|
|
104
92
|
}}
|
|
105
93
|
`;
|
|
106
|
-
|
|
107
94
|
function ImageInArticleBody({
|
|
108
95
|
className = '',
|
|
109
96
|
data
|
|
@@ -115,7 +102,6 @@ function ImageInArticleBody({
|
|
|
115
102
|
data: data
|
|
116
103
|
}));
|
|
117
104
|
}
|
|
118
|
-
|
|
119
105
|
const InfoBoxContainer = _styledComponents.default.div`
|
|
120
106
|
/* reset browser default styles */
|
|
121
107
|
figure {
|
|
@@ -130,7 +116,6 @@ const InfoBoxContainer = _styledComponents.default.div`
|
|
|
130
116
|
{
|
|
131
117
|
return `margin-left: auto; margin-right: auto;`;
|
|
132
118
|
}
|
|
133
|
-
|
|
134
119
|
case 'right':
|
|
135
120
|
{
|
|
136
121
|
return `margin-left: auto`;
|
|
@@ -138,7 +123,6 @@ const InfoBoxContainer = _styledComponents.default.div`
|
|
|
138
123
|
}
|
|
139
124
|
}}
|
|
140
125
|
`;
|
|
141
|
-
|
|
142
126
|
function ImageInInfoBox({
|
|
143
127
|
className = '',
|
|
144
128
|
data
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.blockRenderers = void 0;
|
|
7
|
-
|
|
8
7
|
var _blockquote = require("./blockquote");
|
|
9
|
-
|
|
10
8
|
var _embeddedCodeBlock = require("./embedded-code-block");
|
|
11
|
-
|
|
12
9
|
var _imageBlock = require("./image-block");
|
|
13
|
-
|
|
14
10
|
var _infoBoxBlock = require("./info-box-block");
|
|
15
|
-
|
|
16
11
|
var _slideshowBlock = require("./slideshow-block");
|
|
17
|
-
|
|
18
12
|
const blockRenderers = {
|
|
19
13
|
BlockquoteInArticleBody: _blockquote.BlockquoteInArticleBody,
|
|
20
14
|
EmbeddedCodeBlock: _embeddedCodeBlock.EmbeddedCodeBlock,
|
|
@@ -4,29 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.InfoBoxInArticleBody = InfoBoxInArticleBody;
|
|
7
|
-
|
|
8
7
|
var _draftJs = require("draft-js");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
10
|
var _blockRenderMap = require("../block-render-map");
|
|
15
|
-
|
|
16
11
|
var _imageBlock = require("../block-renderers/image-block");
|
|
17
|
-
|
|
18
12
|
var _index = require("../entity-decorators/index");
|
|
19
|
-
|
|
20
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
var InfoBoxType;
|
|
23
|
-
|
|
24
|
-
(function (InfoBoxType) {
|
|
14
|
+
var InfoBoxType = /*#__PURE__*/function (InfoBoxType) {
|
|
25
15
|
InfoBoxType["newsChargeStation"] = "news-charge-station";
|
|
26
16
|
InfoBoxType["headerBorder"] = "header-border";
|
|
27
17
|
InfoBoxType["boxBorder"] = "box-border";
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
return InfoBoxType;
|
|
19
|
+
}(InfoBoxType || {});
|
|
30
20
|
const NewsChargeStationContainer = _styledComponents.default.div`
|
|
31
21
|
padding: 40px;
|
|
32
22
|
background-color: #fffcf4;
|
|
@@ -45,13 +35,11 @@ const NewsChargeStationContainer = _styledComponents.default.div`
|
|
|
45
35
|
transform: translateX(-50%);
|
|
46
36
|
}
|
|
47
37
|
`;
|
|
48
|
-
|
|
49
38
|
function NewsChargeStation({
|
|
50
39
|
children
|
|
51
40
|
}) {
|
|
52
41
|
return /*#__PURE__*/_react.default.createElement(NewsChargeStationContainer, null, children);
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
const HeaderBorderContainer = _styledComponents.default.div`
|
|
56
44
|
padding: 40px;
|
|
57
45
|
background-color: #d2f5ff;
|
|
@@ -70,13 +58,11 @@ const HeaderBorderContainer = _styledComponents.default.div`
|
|
|
70
58
|
right: 10px;
|
|
71
59
|
}
|
|
72
60
|
`;
|
|
73
|
-
|
|
74
61
|
function HeaderBorder({
|
|
75
62
|
children
|
|
76
63
|
}) {
|
|
77
64
|
return /*#__PURE__*/_react.default.createElement(HeaderBorderContainer, null, children);
|
|
78
65
|
}
|
|
79
|
-
|
|
80
66
|
const BoxBorderContainer = _styledComponents.default.div`
|
|
81
67
|
padding: 40px;
|
|
82
68
|
background-color: #ebebeb;
|
|
@@ -97,18 +83,15 @@ const BoxBorderContainer = _styledComponents.default.div`
|
|
|
97
83
|
right: 0;
|
|
98
84
|
}
|
|
99
85
|
`;
|
|
100
|
-
|
|
101
86
|
function BoxBorder({
|
|
102
87
|
children
|
|
103
88
|
}) {
|
|
104
89
|
return /*#__PURE__*/_react.default.createElement(BoxBorderContainer, null, children);
|
|
105
90
|
}
|
|
106
|
-
|
|
107
91
|
const ArticleBodyContainer = _styledComponents.default.div`
|
|
108
92
|
max-width: 700px;
|
|
109
93
|
margin: 60px auto;
|
|
110
94
|
`;
|
|
111
|
-
|
|
112
95
|
function InfoBoxInArticleBody({
|
|
113
96
|
className,
|
|
114
97
|
data
|
|
@@ -118,12 +101,9 @@ function InfoBoxInArticleBody({
|
|
|
118
101
|
rawContentState
|
|
119
102
|
} = data;
|
|
120
103
|
const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
|
|
121
|
-
|
|
122
104
|
const editorState = _draftJs.EditorState.createWithContent(contentState, _index.decorator);
|
|
123
|
-
|
|
124
105
|
let Component;
|
|
125
106
|
let blockRenderMap = _blockRenderMap.blockRenderMapForInfoBox;
|
|
126
|
-
|
|
127
107
|
switch (type) {
|
|
128
108
|
case InfoBoxType.headerBorder:
|
|
129
109
|
{
|
|
@@ -131,13 +111,11 @@ function InfoBoxInArticleBody({
|
|
|
131
111
|
blockRenderMap = _blockRenderMap.blockRenderMapForInfoBoxWithHeaderBorder;
|
|
132
112
|
break;
|
|
133
113
|
}
|
|
134
|
-
|
|
135
114
|
case InfoBoxType.boxBorder:
|
|
136
115
|
{
|
|
137
116
|
Component = BoxBorder;
|
|
138
117
|
break;
|
|
139
118
|
}
|
|
140
|
-
|
|
141
119
|
case InfoBoxType.newsChargeStation:
|
|
142
120
|
default:
|
|
143
121
|
{
|
|
@@ -145,24 +123,22 @@ function InfoBoxInArticleBody({
|
|
|
145
123
|
break;
|
|
146
124
|
}
|
|
147
125
|
}
|
|
148
|
-
|
|
149
126
|
return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
|
|
150
127
|
className: className
|
|
151
128
|
}, /*#__PURE__*/_react.default.createElement(Component, null, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
|
|
152
129
|
blockRenderMap: blockRenderMap,
|
|
153
130
|
blockRendererFn: blockRendererFn,
|
|
154
131
|
editorState: editorState,
|
|
155
|
-
readOnly: true
|
|
132
|
+
readOnly: true
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
156
134
|
,
|
|
157
135
|
onChange: () => {}
|
|
158
136
|
})));
|
|
159
137
|
}
|
|
160
|
-
|
|
161
138
|
function AtomicBlock(props) {
|
|
162
139
|
const entity = props.contentState.getEntity(props.block.getEntityAt(0));
|
|
163
140
|
const entityType = entity.getType();
|
|
164
141
|
const entityData = entity.getData();
|
|
165
|
-
|
|
166
142
|
switch (entityType) {
|
|
167
143
|
case 'IMAGE':
|
|
168
144
|
{
|
|
@@ -171,10 +147,8 @@ function AtomicBlock(props) {
|
|
|
171
147
|
});
|
|
172
148
|
}
|
|
173
149
|
}
|
|
174
|
-
|
|
175
150
|
return null;
|
|
176
151
|
}
|
|
177
|
-
|
|
178
152
|
function blockRendererFn(block) {
|
|
179
153
|
if (block.getType() === 'atomic') {
|
|
180
154
|
return {
|
|
@@ -182,6 +156,5 @@ function blockRendererFn(block) {
|
|
|
182
156
|
editable: false
|
|
183
157
|
};
|
|
184
158
|
}
|
|
185
|
-
|
|
186
159
|
return null;
|
|
187
160
|
}
|
|
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
// @ts-ignore @twreporter/core does not provide ts header file
|
|
11
|
+
|
|
15
12
|
const mockup = {
|
|
16
13
|
mobile: {
|
|
17
14
|
figure: {
|
|
@@ -19,47 +16,47 @@ const mockup = {
|
|
|
19
16
|
},
|
|
20
17
|
caption: {
|
|
21
18
|
width: 250 // px
|
|
22
|
-
|
|
23
19
|
}
|
|
24
20
|
},
|
|
21
|
+
|
|
25
22
|
tablet: {
|
|
26
23
|
figure: {
|
|
27
24
|
width: '100%'
|
|
28
25
|
},
|
|
29
26
|
caption: {
|
|
30
27
|
width: 512 // px
|
|
31
|
-
|
|
32
28
|
}
|
|
33
29
|
},
|
|
30
|
+
|
|
34
31
|
desktop: {
|
|
35
32
|
figure: {
|
|
36
33
|
width: {
|
|
37
34
|
normal: 100,
|
|
38
35
|
// %
|
|
39
36
|
small: 403 // px
|
|
40
|
-
|
|
41
37
|
}
|
|
42
38
|
},
|
|
39
|
+
|
|
43
40
|
caption: {
|
|
44
41
|
width: 180 // px
|
|
45
|
-
|
|
46
42
|
}
|
|
47
43
|
},
|
|
44
|
+
|
|
48
45
|
hd: {
|
|
49
46
|
figure: {
|
|
50
47
|
width: {
|
|
51
48
|
normal: 100,
|
|
52
49
|
// %
|
|
53
50
|
small: 532 // px
|
|
54
|
-
|
|
55
51
|
}
|
|
56
52
|
},
|
|
53
|
+
|
|
57
54
|
caption: {
|
|
58
55
|
width: 265 // px
|
|
59
|
-
|
|
60
56
|
}
|
|
61
57
|
}
|
|
62
58
|
};
|
|
59
|
+
|
|
63
60
|
const Caption = _styledComponents.default.figcaption`
|
|
64
61
|
color: #494949;
|
|
65
62
|
&::after {
|
|
@@ -5,96 +5,90 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SlideshowBlock = SlideshowBlock;
|
|
7
7
|
exports.SlideshowInArticleBody = SlideshowInArticleBody;
|
|
8
|
-
|
|
9
8
|
var _multimedia = _interopRequireDefault(require("./multimedia"));
|
|
10
|
-
|
|
11
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
|
|
13
10
|
var _mediaQuery = _interopRequireDefault(require("@twreporter/core/lib/utils/media-query"));
|
|
14
|
-
|
|
15
11
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
16
|
-
|
|
17
12
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
-
|
|
19
13
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
20
|
-
|
|
21
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
-
|
|
23
15
|
// @ts-ignore pkg does not contain ts header file
|
|
16
|
+
|
|
24
17
|
const mockup = {
|
|
25
18
|
mobile: {
|
|
26
19
|
container: {
|
|
27
20
|
width: 375 // px
|
|
28
|
-
|
|
29
21
|
},
|
|
22
|
+
|
|
30
23
|
slide: {
|
|
31
24
|
width: 339,
|
|
32
25
|
// px
|
|
33
26
|
height: 189,
|
|
34
27
|
// px
|
|
35
28
|
paddingRight: 2 // px
|
|
36
|
-
|
|
37
29
|
},
|
|
30
|
+
|
|
38
31
|
offset: {
|
|
39
32
|
left: 18 // px
|
|
40
|
-
|
|
41
33
|
}
|
|
42
34
|
},
|
|
35
|
+
|
|
43
36
|
tablet: {
|
|
44
37
|
container: {
|
|
45
38
|
width: 768 // px
|
|
46
|
-
|
|
47
39
|
},
|
|
40
|
+
|
|
48
41
|
slide: {
|
|
49
42
|
width: 687,
|
|
50
43
|
// px
|
|
51
44
|
height: 387,
|
|
52
45
|
// px
|
|
53
46
|
paddingRight: 4 // px
|
|
54
|
-
|
|
55
47
|
},
|
|
48
|
+
|
|
56
49
|
offset: {
|
|
57
50
|
left: 41 // px
|
|
58
|
-
|
|
59
51
|
}
|
|
60
52
|
},
|
|
53
|
+
|
|
61
54
|
desktop: {
|
|
62
55
|
container: {
|
|
63
56
|
width: 752 // px
|
|
64
|
-
|
|
65
57
|
},
|
|
58
|
+
|
|
66
59
|
slide: {
|
|
67
60
|
width: 688,
|
|
68
61
|
// px
|
|
69
62
|
height: 387,
|
|
70
63
|
// px
|
|
71
64
|
paddingRight: 4 // px
|
|
72
|
-
|
|
73
65
|
},
|
|
66
|
+
|
|
74
67
|
offset: {
|
|
75
68
|
left: 32 // px
|
|
76
|
-
|
|
77
69
|
}
|
|
78
70
|
},
|
|
71
|
+
|
|
79
72
|
hd: {
|
|
80
73
|
container: {
|
|
81
74
|
width: 1034 // px
|
|
82
|
-
|
|
83
75
|
},
|
|
76
|
+
|
|
84
77
|
slide: {
|
|
85
78
|
width: 944,
|
|
86
79
|
// px
|
|
87
80
|
height: 531,
|
|
88
81
|
// px
|
|
89
82
|
paddingRight: 4 // px
|
|
90
|
-
|
|
91
83
|
},
|
|
84
|
+
|
|
92
85
|
offset: {
|
|
93
86
|
left: 45 // px
|
|
94
|
-
|
|
95
87
|
}
|
|
96
88
|
}
|
|
97
|
-
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// Assuming there are three images [ A, B, C ] for slideshow.
|
|
98
92
|
// If image B is rendered in the center,
|
|
99
93
|
// users can see part of image A(left side) and image C(right side) with masks.
|
|
100
94
|
// When users click right button to see image C, which means, C is in the center,
|
|
@@ -105,11 +99,12 @@ const mockup = {
|
|
|
105
99
|
//
|
|
106
100
|
// `slidesOffset` indicates how many slides rendered before/after image B, which is, 2 (A and C).
|
|
107
101
|
//
|
|
102
|
+
const slidesOffset = 2;
|
|
108
103
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const duration = 300; // current index to indicate which image should be rendered in the center
|
|
104
|
+
// duration of transition of transform(translateX(?px))
|
|
105
|
+
const duration = 300;
|
|
112
106
|
|
|
107
|
+
// current index to indicate which image should be rendered in the center
|
|
113
108
|
const defaultCurIndex = 0;
|
|
114
109
|
const SlidesSection = _styledComponents.default.div`
|
|
115
110
|
flex-shrink: 0;
|
|
@@ -420,48 +415,45 @@ const SlideshowFlexBox = _styledComponents.default.div`
|
|
|
420
415
|
width: ${mockup.hd.container.width}px;
|
|
421
416
|
`}
|
|
422
417
|
`;
|
|
423
|
-
|
|
424
418
|
function getTranslateX(deviceMockup, unit) {
|
|
425
|
-
const slideWidth = getSlideWidth(deviceMockup);
|
|
419
|
+
const slideWidth = getSlideWidth(deviceMockup);
|
|
426
420
|
|
|
427
|
-
|
|
421
|
+
// total slides width including padding
|
|
422
|
+
let translateX = unit * slideWidth;
|
|
428
423
|
|
|
424
|
+
// add left mask width and padding
|
|
429
425
|
translateX = translateX + deviceMockup.offset.left;
|
|
430
426
|
return translateX; // px
|
|
431
427
|
}
|
|
428
|
+
|
|
432
429
|
/**
|
|
433
430
|
* @param {DeviceMockup} deviceMockup
|
|
434
431
|
* @return {number}
|
|
435
432
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
438
433
|
function getContainerWidth(deviceMockup) {
|
|
439
434
|
return deviceMockup.container.width;
|
|
440
435
|
}
|
|
436
|
+
|
|
441
437
|
/**
|
|
442
438
|
* @param {DeviceMockup} deviceMockup
|
|
443
439
|
* @return {number}
|
|
444
440
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
447
441
|
function getSlideWidth(deviceMockup) {
|
|
448
442
|
return deviceMockup.slide.width + deviceMockup.slide.paddingRight;
|
|
449
443
|
}
|
|
444
|
+
|
|
450
445
|
/**
|
|
451
446
|
* @param {DeviceMockup} deviceMockup
|
|
452
447
|
* @return {number}
|
|
453
448
|
*/
|
|
454
|
-
|
|
455
|
-
|
|
456
449
|
function getLeftMaskWidth(deviceMockup) {
|
|
457
450
|
return deviceMockup.offset.left - deviceMockup.slide.paddingRight; // px
|
|
458
451
|
}
|
|
452
|
+
|
|
459
453
|
/**
|
|
460
454
|
* @param {DeviceMockup} deviceMockup
|
|
461
455
|
* @return {number}
|
|
462
456
|
*/
|
|
463
|
-
|
|
464
|
-
|
|
465
457
|
function getRightMaskWidth(deviceMockup) {
|
|
466
458
|
return deviceMockup.container.width - deviceMockup.offset.left - getSlideWidth(deviceMockup); // px
|
|
467
459
|
}
|
|
@@ -471,21 +463,19 @@ function SlideshowBlock({
|
|
|
471
463
|
data
|
|
472
464
|
}) {
|
|
473
465
|
var _images$curSlideIndex;
|
|
466
|
+
const defaultTranslateXUnit = -slidesOffset;
|
|
474
467
|
|
|
475
|
-
|
|
468
|
+
// value of curSlideIndex would be in [ 0 ~ props.data.content.length ] range,
|
|
476
469
|
// it indicates which image should be placed in the center
|
|
477
|
-
|
|
478
470
|
const [curSlideIndex, setCurSlideIndex] = (0, _react.useState)(defaultCurIndex);
|
|
479
471
|
const [slideTo, setSlideTo] = (0, _react.useState)(''); // '', 'previous' or 'next'. '' means no sliding.
|
|
480
|
-
|
|
481
472
|
const [translateXUnit, setTranslateXUnit] = (0, _react.useState)(defaultTranslateXUnit);
|
|
482
473
|
const images = ((data === null || data === void 0 ? void 0 : data.images) || []).filter(img => {
|
|
483
474
|
var _img$imageFile;
|
|
484
|
-
|
|
485
|
-
return img === null || img === void 0 ? void 0 : (_img$imageFile = img.imageFile) === null || _img$imageFile === void 0 ? void 0 : _img$imageFile.url;
|
|
475
|
+
return img === null || img === void 0 || (_img$imageFile = img.imageFile) === null || _img$imageFile === void 0 ? void 0 : _img$imageFile.url;
|
|
486
476
|
});
|
|
487
477
|
const total = images === null || images === void 0 ? void 0 : images.length;
|
|
488
|
-
const desc = images === null || images === void 0
|
|
478
|
+
const desc = images === null || images === void 0 || (_images$curSlideIndex = images[curSlideIndex]) === null || _images$curSlideIndex === void 0 ? void 0 : _images$curSlideIndex.desc;
|
|
489
479
|
const appendedClassName = className + ' avoid-break';
|
|
490
480
|
const slides = (0, _react.useMemo)(() => {
|
|
491
481
|
// add last `slidesOffset` elements into top of images array.
|
|
@@ -497,24 +487,19 @@ function SlideshowBlock({
|
|
|
497
487
|
const _images = [...images.slice(-slidesOffset), ...images, ...images.slice(defaultCurIndex, slidesOffset)];
|
|
498
488
|
return _images === null || _images === void 0 ? void 0 : _images.map((img, index) => {
|
|
499
489
|
var _img$resized, _img$resized2, _img$resized3, _img$resized4;
|
|
500
|
-
|
|
501
490
|
const width = img.imageFile.width ?? 0;
|
|
502
491
|
const height = img.imageFile.height ?? 0;
|
|
503
492
|
const imgSrc = ((_img$resized = img.resized) === null || _img$resized === void 0 ? void 0 : _img$resized.medium) ?? img.imageFile.url;
|
|
504
493
|
const imgSrcSetArr = [];
|
|
505
|
-
|
|
506
494
|
if ((_img$resized2 = img.resized) !== null && _img$resized2 !== void 0 && _img$resized2.small) {
|
|
507
495
|
imgSrcSetArr.push(`${img.resized.medium} 600w`);
|
|
508
496
|
}
|
|
509
|
-
|
|
510
497
|
if ((_img$resized3 = img.resized) !== null && _img$resized3 !== void 0 && _img$resized3.medium) {
|
|
511
498
|
imgSrcSetArr.push(`${img.resized.medium} 1200w`);
|
|
512
499
|
}
|
|
513
|
-
|
|
514
500
|
if ((_img$resized4 = img.resized) !== null && _img$resized4 !== void 0 && _img$resized4.large) {
|
|
515
501
|
imgSrcSetArr.push(`${img.resized.large} 2000w`);
|
|
516
502
|
}
|
|
517
|
-
|
|
518
503
|
const objectFit = width > height ? 'cover' : 'contain';
|
|
519
504
|
return (
|
|
520
505
|
/*#__PURE__*/
|
|
@@ -534,38 +519,30 @@ function SlideshowBlock({
|
|
|
534
519
|
);
|
|
535
520
|
});
|
|
536
521
|
}, [images]);
|
|
537
|
-
|
|
538
522
|
const slideToPrev = () => {
|
|
539
523
|
setSlideTo('previous');
|
|
540
524
|
setTranslateXUnit(translateXUnit + 1);
|
|
541
525
|
};
|
|
542
|
-
|
|
543
526
|
const slideToNext = () => {
|
|
544
527
|
setSlideTo('next');
|
|
545
528
|
setTranslateXUnit(translateXUnit - 1);
|
|
546
529
|
};
|
|
547
|
-
|
|
548
530
|
(0, _react.useEffect)(() => {
|
|
549
531
|
if (slideTo === '') {
|
|
550
532
|
return;
|
|
551
533
|
}
|
|
552
|
-
|
|
553
534
|
let _curSlideIndex;
|
|
554
|
-
|
|
555
535
|
if (slideTo === 'previous') {
|
|
556
536
|
_curSlideIndex = curSlideIndex - 1;
|
|
557
|
-
|
|
558
537
|
if (_curSlideIndex < defaultCurIndex) {
|
|
559
538
|
_curSlideIndex = total + _curSlideIndex;
|
|
560
539
|
}
|
|
561
540
|
} else if (slideTo === 'next') {
|
|
562
541
|
_curSlideIndex = curSlideIndex + 1;
|
|
563
|
-
|
|
564
542
|
if (_curSlideIndex >= total) {
|
|
565
543
|
_curSlideIndex = _curSlideIndex % total;
|
|
566
544
|
}
|
|
567
545
|
}
|
|
568
|
-
|
|
569
546
|
setTimeout(() => {
|
|
570
547
|
setSlideTo('');
|
|
571
548
|
setCurSlideIndex(_curSlideIndex);
|
|
@@ -585,7 +562,6 @@ function SlideshowBlock({
|
|
|
585
562
|
onClick: isSliding ? undefined : slideToNext
|
|
586
563
|
}, /*#__PURE__*/_react.default.createElement(NextArrowSvg, null))), /*#__PURE__*/_react.default.createElement(ImageNumberCircle, null, /*#__PURE__*/_react.default.createElement(ImageNumber, null, curSlideIndex + 1), /*#__PURE__*/_react.default.createElement(ImageTotal, null, total)), desc ? /*#__PURE__*/_react.default.createElement(Desc, null, desc) : /*#__PURE__*/_react.default.createElement(EmptyDesc, null));
|
|
587
564
|
}
|
|
588
|
-
|
|
589
565
|
function NextArrowSvg() {
|
|
590
566
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
591
567
|
viewBox: "0 0 31 17",
|
|
@@ -598,7 +574,6 @@ function NextArrowSvg() {
|
|
|
598
574
|
fillRule: "nonzero"
|
|
599
575
|
}));
|
|
600
576
|
}
|
|
601
|
-
|
|
602
577
|
function PreArrowSvg() {
|
|
603
578
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
604
579
|
viewBox: "0 0 31 17",
|
|
@@ -610,12 +585,10 @@ function PreArrowSvg() {
|
|
|
610
585
|
fill: "gray"
|
|
611
586
|
}));
|
|
612
587
|
}
|
|
613
|
-
|
|
614
588
|
const ArticleBodyContainer = _styledComponents.default.div`
|
|
615
589
|
width: fit-content;
|
|
616
590
|
margin: 0 auto 27px auto;
|
|
617
591
|
`;
|
|
618
|
-
|
|
619
592
|
function SlideshowInArticleBody({
|
|
620
593
|
className = '',
|
|
621
594
|
data
|
package/lib/draft-renderer.js
CHANGED
|
@@ -4,46 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.DraftRenderer = DraftRenderer;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _draftJs = require("draft-js");
|
|
11
|
-
|
|
12
9
|
var _blockRendererFn = require("./block-renderer-fn");
|
|
13
|
-
|
|
14
10
|
var _blockRenderMap = require("./block-render-map");
|
|
15
|
-
|
|
16
11
|
var _index = require("./entity-decorators/index");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
|
-
const customStyleMap = {
|
|
21
|
-
CODE: {
|
|
22
|
-
backgroundColor: 'rgba(0, 0, 0, 0.05)',
|
|
23
|
-
fontFamily: '"Inconsolata", "Menlo", "Consolas", monospace',
|
|
24
|
-
fontSize: 16,
|
|
25
|
-
padding: 2
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
13
|
const blockRendererFn = block => {
|
|
30
14
|
const atomicBlockObj = (0, _blockRendererFn.atomicBlockRenderer)(block);
|
|
31
15
|
return atomicBlockObj;
|
|
32
16
|
};
|
|
33
|
-
|
|
34
17
|
function DraftRenderer({
|
|
35
18
|
rawContentState
|
|
36
19
|
}) {
|
|
37
20
|
const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
|
|
38
|
-
|
|
39
21
|
const editorState = _draftJs.EditorState.createWithContent(contentState, _index.decorator);
|
|
40
|
-
|
|
41
22
|
return /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
|
|
42
23
|
editorState: editorState,
|
|
43
|
-
customStyleMap: customStyleMap,
|
|
44
24
|
blockRenderMap: _blockRenderMap.blockRenderMap,
|
|
45
25
|
blockRendererFn: blockRendererFn,
|
|
46
|
-
readOnly: true
|
|
26
|
+
readOnly: true
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
47
28
|
,
|
|
48
29
|
onChange: () => {}
|
|
49
30
|
});
|
|
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.annotationDecorator = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
var _draftJs = require("draft-js");
|
|
13
|
-
|
|
14
10
|
var _blockRenderMap = require("../block-render-map");
|
|
15
|
-
|
|
16
11
|
var _index = require("../entity-decorators/index");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
14
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
15
|
const AnnotationWrapper = _styledComponents.default.span`
|
|
25
16
|
display: inline-block;
|
|
26
17
|
cursor: pointer;
|
|
@@ -70,7 +61,6 @@ const ArrowIcon = _styledComponents.default.span`
|
|
|
70
61
|
transition: transform 200ms ease 0s;
|
|
71
62
|
}
|
|
72
63
|
`;
|
|
73
|
-
|
|
74
64
|
function AnnotationBlock(props) {
|
|
75
65
|
const {
|
|
76
66
|
children: annotated
|
|
@@ -80,9 +70,7 @@ function AnnotationBlock(props) {
|
|
|
80
70
|
rawContentState
|
|
81
71
|
} = props.contentState.getEntity(props.entityKey).getData();
|
|
82
72
|
const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
|
|
83
|
-
|
|
84
73
|
const editorState = _draftJs.EditorState.createWithContent(contentState, _index.decorator);
|
|
85
|
-
|
|
86
74
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(AnnotationWrapper, {
|
|
87
75
|
onClick: e => {
|
|
88
76
|
e.preventDefault();
|
|
@@ -93,19 +81,18 @@ function AnnotationBlock(props) {
|
|
|
93
81
|
})), showContent ? /*#__PURE__*/_react.default.createElement(AnnotationBody, null, /*#__PURE__*/_react.default.createElement(_draftJs.Editor, {
|
|
94
82
|
editorState: editorState,
|
|
95
83
|
blockRenderMap: _blockRenderMap.blockRenderMapForAnnotation,
|
|
96
|
-
readOnly: true
|
|
84
|
+
readOnly: true
|
|
85
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
97
86
|
,
|
|
98
87
|
onChange: () => {}
|
|
99
88
|
})) : null);
|
|
100
89
|
}
|
|
101
|
-
|
|
102
90
|
function findAnnotationEntities(contentBlock, callback, contentState) {
|
|
103
91
|
contentBlock.findEntityRanges(character => {
|
|
104
92
|
const entityKey = character.getEntity();
|
|
105
93
|
return entityKey !== null && contentState.getEntity(entityKey).getType() === 'ANNOTATION';
|
|
106
94
|
}, callback);
|
|
107
95
|
}
|
|
108
|
-
|
|
109
96
|
const annotationDecorator = {
|
|
110
97
|
strategy: findAnnotationEntities,
|
|
111
98
|
component: AnnotationBlock
|
|
@@ -16,12 +16,8 @@ Object.defineProperty(exports, "linkDecorator", {
|
|
|
16
16
|
return _linkDecorator.linkDecorator;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
-
|
|
20
19
|
var _draftJs = require("draft-js");
|
|
21
|
-
|
|
22
20
|
var _annotationDecorator = require("./annotation-decorator");
|
|
23
|
-
|
|
24
21
|
var _linkDecorator = require("./link-decorator");
|
|
25
|
-
|
|
26
22
|
const decorator = new _draftJs.CompositeDecorator([_annotationDecorator.annotationDecorator, _linkDecorator.linkDecorator]);
|
|
27
23
|
exports.decorator = decorator;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.linkDecorator = void 0;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
const LinkWrapper = _styledComponents.default.a`
|
|
15
11
|
text-decoration: underline;
|
|
16
12
|
color: #27b5f7;
|
|
@@ -20,20 +16,17 @@ const LinkWrapper = _styledComponents.default.a`
|
|
|
20
16
|
color: #232323;
|
|
21
17
|
}
|
|
22
18
|
`;
|
|
23
|
-
|
|
24
19
|
function findLinkEntities(contentBlock, callback, contentState) {
|
|
25
20
|
contentBlock.findEntityRanges(character => {
|
|
26
21
|
const entityKey = character.getEntity();
|
|
27
22
|
return entityKey !== null && contentState.getEntity(entityKey).getType() === 'LINK';
|
|
28
23
|
}, callback);
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
const linkDecorator = {
|
|
32
26
|
strategy: findLinkEntities,
|
|
33
27
|
component: Link
|
|
34
28
|
};
|
|
35
29
|
exports.linkDecorator = linkDecorator;
|
|
36
|
-
|
|
37
30
|
function Link(props) {
|
|
38
31
|
const {
|
|
39
32
|
url
|
package/lib/index.js
CHANGED
|
@@ -34,17 +34,11 @@ Object.defineProperty(exports, "decorator", {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
exports.default = void 0;
|
|
37
|
-
|
|
38
37
|
var _draftRenderer = require("./draft-renderer");
|
|
39
|
-
|
|
40
38
|
var _blockRendererFn = require("./block-renderer-fn");
|
|
41
|
-
|
|
42
39
|
var _blockRenderMap = require("./block-render-map");
|
|
43
|
-
|
|
44
40
|
var _blockRenderers = require("./block-renderers");
|
|
45
|
-
|
|
46
41
|
var _index = require("./entity-decorators/index");
|
|
47
|
-
|
|
48
42
|
var _default = {
|
|
49
43
|
DraftRenderer: _draftRenderer.DraftRenderer,
|
|
50
44
|
atomicBlockRenderer: _blockRendererFn.atomicBlockRenderer,
|