@kids-reporter/draft-renderer 0.2.0 → 0.3.0
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-renderer-fn.js
CHANGED
|
@@ -8,7 +8,8 @@ exports.atomicBlockRenderer = atomicBlockRenderer;
|
|
|
8
8
|
var _blockRenderers = require("./block-renderers");
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
|
-
|
|
11
|
+
BlockquoteInArticleBody,
|
|
12
|
+
EmbeddedCodeInArticleBody,
|
|
12
13
|
ImageInArticleBody,
|
|
13
14
|
InfoBoxBlock,
|
|
14
15
|
SlideshowInArticleBody
|
|
@@ -20,14 +21,21 @@ const AtomicBlock = props => {
|
|
|
20
21
|
const entityData = entity.getData();
|
|
21
22
|
|
|
22
23
|
switch (entityType) {
|
|
23
|
-
case '
|
|
24
|
+
case 'BLOCKQUOTE':
|
|
25
|
+
{
|
|
26
|
+
return BlockquoteInArticleBody({
|
|
27
|
+
data: entityData
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
case 'IMAGE':
|
|
24
32
|
{
|
|
25
33
|
return ImageInArticleBody({
|
|
26
34
|
data: entityData
|
|
27
35
|
});
|
|
28
36
|
}
|
|
29
37
|
|
|
30
|
-
case '
|
|
38
|
+
case 'SLIDESHOW':
|
|
31
39
|
{
|
|
32
40
|
return SlideshowInArticleBody({
|
|
33
41
|
data: entityData
|
|
@@ -36,7 +44,7 @@ const AtomicBlock = props => {
|
|
|
36
44
|
|
|
37
45
|
case 'EMBEDDEDCODE':
|
|
38
46
|
{
|
|
39
|
-
return
|
|
47
|
+
return EmbeddedCodeInArticleBody({
|
|
40
48
|
data: entityData
|
|
41
49
|
});
|
|
42
50
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BlockquoteInArticleBody = BlockquoteInArticleBody;
|
|
7
|
+
exports.BorderLeftBlockquote = BorderLeftBlockquote;
|
|
8
|
+
exports.QuoteLeftBlockquote = QuoteLeftBlockquote;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const BorderLeftContainer = _styledComponents.default.blockquote`
|
|
17
|
+
margin: 0;
|
|
18
|
+
padding-left: 30px;
|
|
19
|
+
border-left: 4px solid #27b5f7;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
function BorderLeftBlockquote({
|
|
23
|
+
text
|
|
24
|
+
}) {
|
|
25
|
+
return /*#__PURE__*/_react.default.createElement(BorderLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const QuoteLeftContainer = _styledComponents.default.blockquote`
|
|
29
|
+
margin: 0;
|
|
30
|
+
padding: 40px;
|
|
31
|
+
background-color: #f4f4f4;
|
|
32
|
+
display: flex;
|
|
33
|
+
border-radius: 20px;
|
|
34
|
+
`;
|
|
35
|
+
const QuoteText = _styledComponents.default.p`
|
|
36
|
+
margin: 0;
|
|
37
|
+
word-break: break-word;
|
|
38
|
+
font-size: 18px;
|
|
39
|
+
font-weight: 500;
|
|
40
|
+
letter-spacing: 0.9px;
|
|
41
|
+
line-height: 2;
|
|
42
|
+
color: #3a4f66;
|
|
43
|
+
`;
|
|
44
|
+
const SvgBlock = _styledComponents.default.div`
|
|
45
|
+
margin-right: 16px;
|
|
46
|
+
|
|
47
|
+
svg {
|
|
48
|
+
width: 36px;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
function QuoteSvg() {
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(SvgBlock, null, /*#__PURE__*/_react.default.createElement("svg", {
|
|
54
|
+
fill: "#27B5F7",
|
|
55
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
56
|
+
viewBox: "0 0 50 50",
|
|
57
|
+
"aria-hidden": "true"
|
|
58
|
+
}, /*#__PURE__*/_react.default.createElement("path", {
|
|
59
|
+
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
|
+
})));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function QuoteLeftBlockquote({
|
|
64
|
+
text
|
|
65
|
+
}) {
|
|
66
|
+
return /*#__PURE__*/_react.default.createElement(QuoteLeftContainer, null, /*#__PURE__*/_react.default.createElement(QuoteSvg, null), /*#__PURE__*/_react.default.createElement(QuoteText, null, text));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ArticleBodyContainer = _styledComponents.default.div`
|
|
70
|
+
max-width: 700px;
|
|
71
|
+
margin: 0 auto 27px auto;
|
|
72
|
+
`;
|
|
73
|
+
var BlockquoteType;
|
|
74
|
+
|
|
75
|
+
(function (BlockquoteType) {
|
|
76
|
+
BlockquoteType["borderLeft"] = "border_left";
|
|
77
|
+
BlockquoteType["quoteLeft"] = "quote_left";
|
|
78
|
+
})(BlockquoteType || (BlockquoteType = {}));
|
|
79
|
+
|
|
80
|
+
function BlockquoteInArticleBody({
|
|
81
|
+
className = '',
|
|
82
|
+
data = {
|
|
83
|
+
type: BlockquoteType.borderLeft,
|
|
84
|
+
text: ''
|
|
85
|
+
}
|
|
86
|
+
}) {
|
|
87
|
+
const {
|
|
88
|
+
type,
|
|
89
|
+
text
|
|
90
|
+
} = data;
|
|
91
|
+
const BlockQuote = type === BlockquoteType.quoteLeft ? QuoteLeftBlockquote : BorderLeftBlockquote;
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
|
|
93
|
+
className: className
|
|
94
|
+
}, /*#__PURE__*/_react.default.createElement(BlockQuote, {
|
|
95
|
+
text: text
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EmbeddedCodeBlock = exports.Caption = exports.Block = void 0;
|
|
7
|
+
exports.EmbeddedCodeInArticleBody = EmbeddedCodeInArticleBody;
|
|
7
8
|
|
|
8
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
10
|
|
|
@@ -114,4 +115,19 @@ const EmbeddedCodeBlock = ({
|
|
|
114
115
|
}), caption && /*#__PURE__*/_react.default.createElement(Caption, null, caption));
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
exports.EmbeddedCodeBlock = EmbeddedCodeBlock;
|
|
118
|
+
exports.EmbeddedCodeBlock = EmbeddedCodeBlock;
|
|
119
|
+
const ArticleBodyContainer = _styledComponents.default.div`
|
|
120
|
+
max-width: 700px;
|
|
121
|
+
margin: 0 auto 27px auto;
|
|
122
|
+
`;
|
|
123
|
+
|
|
124
|
+
function EmbeddedCodeInArticleBody({
|
|
125
|
+
className = '',
|
|
126
|
+
data
|
|
127
|
+
}) {
|
|
128
|
+
return /*#__PURE__*/_react.default.createElement(ArticleBodyContainer, {
|
|
129
|
+
className: className
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(EmbeddedCodeBlock, {
|
|
131
|
+
data: data
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.blockRenderers = void 0;
|
|
7
7
|
|
|
8
|
+
var _blockquote = require("./blockquote");
|
|
9
|
+
|
|
8
10
|
var _embeddedCodeBlock = require("./embedded-code-block");
|
|
9
11
|
|
|
10
12
|
var _imageBlock = require("./image-block");
|
|
@@ -14,10 +16,12 @@ var _infoBoxBlock = require("./info-box-block");
|
|
|
14
16
|
var _slideshowBlock = require("./slideshow-block");
|
|
15
17
|
|
|
16
18
|
const blockRenderers = {
|
|
19
|
+
BlockquoteInArticleBody: _blockquote.BlockquoteInArticleBody,
|
|
17
20
|
EmbeddedCodeBlock: _embeddedCodeBlock.EmbeddedCodeBlock,
|
|
21
|
+
EmbeddedCodeInArticleBody: _embeddedCodeBlock.EmbeddedCodeInArticleBody,
|
|
18
22
|
ImageBlock: _imageBlock.ImageBlock,
|
|
19
23
|
ImageInArticleBody: _imageBlock.ImageInArticleBody,
|
|
20
|
-
|
|
24
|
+
InfoBoxInArticleBody: _infoBoxBlock.InfoBoxInArticleBody,
|
|
21
25
|
SlideshowBlock: _slideshowBlock.SlideshowBlock,
|
|
22
26
|
SlideshowInArticleBody: _slideshowBlock.SlideshowInArticleBody
|
|
23
27
|
};
|
|
@@ -3,9 +3,105 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.InfoBoxInArticleBody = InfoBoxInArticleBody;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
var _draftJs = require("draft-js");
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
|
|
14
|
+
var _index = require("../entity-decorators/index");
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
18
|
+
var InfoBoxType;
|
|
19
|
+
|
|
20
|
+
(function (InfoBoxType) {
|
|
21
|
+
InfoBoxType["newsChargeStation"] = "news-charge-station";
|
|
22
|
+
InfoBoxType["headerBorder"] = "with-header-border";
|
|
23
|
+
InfoBoxType["boxBorder"] = "with-box-border";
|
|
24
|
+
})(InfoBoxType || (InfoBoxType = {}));
|
|
25
|
+
|
|
26
|
+
var InfoBoxLabel;
|
|
27
|
+
|
|
28
|
+
(function (InfoBoxLabel) {
|
|
29
|
+
InfoBoxLabel["newsChargeStation"] = "\u65B0\u805E\u5145\u96FB\u5668";
|
|
30
|
+
InfoBoxLabel["headerBorder"] = "\u7121\u908A\u6846\u677F";
|
|
31
|
+
InfoBoxLabel["boxBorder"] = "\u6709\u908A\u6846\u677F";
|
|
32
|
+
})(InfoBoxLabel || (InfoBoxLabel = {}));
|
|
33
|
+
|
|
34
|
+
const NewsChargeStationContainer = _styledComponents.default.div`
|
|
35
|
+
padding: 40px;
|
|
36
|
+
background-color: #fffcf4;
|
|
37
|
+
position: relative;
|
|
38
|
+
border-radius: 30px;
|
|
39
|
+
|
|
40
|
+
&::before {
|
|
41
|
+
content: '';
|
|
42
|
+
width: 300px;
|
|
43
|
+
height: 80px;
|
|
44
|
+
background-image: url(https://kids.twreporter.org/wp-content/themes/blocksy-child/assets/js/components/rpjr-box/newsChargeStation.svg);
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: -40px;
|
|
47
|
+
left: 50%;
|
|
48
|
+
transform: translateX(-50%);
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
function NewsChargeStation({
|
|
53
|
+
children
|
|
54
|
+
}) {
|
|
55
|
+
return /*#__PURE__*/_react.default.createElement(NewsChargeStationContainer, null, children);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function HeaderBorder() {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function BoxBorder() {
|
|
10
63
|
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const ArticleBodyContainer = _styledComponents.default.div`
|
|
67
|
+
max-width: 700px;
|
|
68
|
+
padding: 40px;
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
function InfoBoxInArticleBody({
|
|
72
|
+
className,
|
|
73
|
+
data
|
|
74
|
+
}) {
|
|
75
|
+
const {
|
|
76
|
+
type,
|
|
77
|
+
rawContentState
|
|
78
|
+
} = data;
|
|
79
|
+
const contentState = (0, _draftJs.convertFromRaw)(rawContentState);
|
|
80
|
+
|
|
81
|
+
const editorState = _draftJs.EditorState.createWithContent(contentState, _index.decorators);
|
|
82
|
+
|
|
83
|
+
let Component;
|
|
84
|
+
|
|
85
|
+
switch (type) {
|
|
86
|
+
case InfoBoxType.boxBorder:
|
|
87
|
+
{
|
|
88
|
+
Component = BoxBorder;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
case InfoBoxType.headerBorder:
|
|
93
|
+
{
|
|
94
|
+
Component = HeaderBorder;
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
case InfoBoxType.newsChargeStation:
|
|
99
|
+
default:
|
|
100
|
+
{
|
|
101
|
+
Component = NewsChargeStation;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return /*#__PURE__*/_react.default.createElement(Component, null, "test");
|
|
11
107
|
}
|