editor-react-parser
Version:
A renderer for editorjs block data for react
39 lines (38 loc) • 1.48 kB
JavaScript
import React from "react";
export var QuoteAlignment;
(function (QuoteAlignment) {
QuoteAlignment["left"] = "left";
QuoteAlignment["center"] = "center";
QuoteAlignment["right"] = "right";
QuoteAlignment["justify"] = "justify";
})(QuoteAlignment || (QuoteAlignment = {}));
var defaultQuoteConfig = {
classNames: {
alignCenter: "text-center",
alignRight: "text-right",
alignLeft: "text-left",
alignJustify: "text-justify",
quote: "italic text-lg",
caption: "opacity-85 text-sm",
},
};
var QuoteBlock = function (_a) {
var _b;
var item = _a.item, config = _a.config;
var currentConfig = Object.assign({}, defaultQuoteConfig, config);
return (React.createElement("p", { className: (_b = {},
_b[QuoteAlignment.left] = currentConfig.classNames.alignLeft,
_b[QuoteAlignment.center] = currentConfig.classNames.alignCenter,
_b[QuoteAlignment.right] = currentConfig.classNames.alignRight,
_b[QuoteAlignment.justify] = currentConfig.classNames.alignJustify,
_b)[item.data.alignment] },
React.createElement("span", { className: currentConfig.classNames.quote },
"\"",
item.data.text,
"\""),
React.createElement("br", null),
React.createElement("span", { className: currentConfig.classNames.caption },
"- ",
item.data.caption)));
};
export default QuoteBlock;