@pinnacle0/web-ui 0.3.73 → 0.3.75
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/core/Markdown/index.d.ts +3 -3
- package/core/Markdown/index.js +28 -18
- package/core/Markdown/index.js.map +1 -1
- package/package.json +1 -1
package/core/Markdown/index.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ export interface Props {
|
|
|
16
16
|
}
|
|
17
17
|
export declare class Markdown extends React.PureComponent<Props> {
|
|
18
18
|
static displayName: string;
|
|
19
|
-
renderBold: (content: string, index: number) => JSX.Element;
|
|
20
|
-
renderLine: (content: string, index: number) => JSX.Element;
|
|
21
19
|
render(): JSX.Element;
|
|
22
|
-
private
|
|
20
|
+
private processLine;
|
|
21
|
+
private renderBold;
|
|
22
|
+
private renderEmphasis;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
package/core/Markdown/index.js
CHANGED
|
@@ -19,29 +19,39 @@ var Markdown = /** @class */ (function (_super) {
|
|
|
19
19
|
__extends(Markdown, _super);
|
|
20
20
|
function Markdown() {
|
|
21
21
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
22
|
-
_this.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (React.createElement("div", { className: "line", key: index }, splitContents.map(function (_, segmentIndex) { return (segmentIndex % 2 === 1 ? React.createElement("em", { key: segmentIndex }, _) : _this.renderBold(_, segmentIndex)); })));
|
|
33
|
-
};
|
|
34
|
-
_this.whiteListRegexPart = function (symbol) {
|
|
35
|
-
if (symbol === "**") {
|
|
36
|
-
return "\\*\\*";
|
|
22
|
+
_this.processLine = function (content, index, symbols) {
|
|
23
|
+
switch (symbols[0]) {
|
|
24
|
+
case "**":
|
|
25
|
+
return _this.renderBold(content.split(/\*\*/g), symbols);
|
|
26
|
+
case "__":
|
|
27
|
+
return _this.renderBold(content.split(/__/g), symbols);
|
|
28
|
+
case "`":
|
|
29
|
+
return _this.renderEmphasis(content.split(/`/g), symbols);
|
|
30
|
+
default:
|
|
31
|
+
return [React.createElement(React.Fragment, { key: index }, content)];
|
|
37
32
|
}
|
|
38
|
-
return symbol;
|
|
39
33
|
};
|
|
40
34
|
return _this;
|
|
41
35
|
}
|
|
42
36
|
Markdown.prototype.render = function () {
|
|
43
|
-
var
|
|
44
|
-
|
|
37
|
+
var _this = this;
|
|
38
|
+
var _a = this.props, children = _a.children, style = _a.style, whitelist = _a.whitelist;
|
|
39
|
+
var symbols = whitelist || ["**", "__", "`"];
|
|
40
|
+
return (React.createElement("div", { className: "g-markdown", style: style }, children.split("\n").map(function (line, index) { return (React.createElement("div", { className: "line", key: index }, _this.processLine(line, index, symbols))); })));
|
|
41
|
+
};
|
|
42
|
+
Markdown.prototype.renderBold = function (splitContents, symbols) {
|
|
43
|
+
var _this = this;
|
|
44
|
+
return splitContents.map(function (_, segmentIndex) {
|
|
45
|
+
var text = _this.processLine(_, segmentIndex, symbols.slice(1));
|
|
46
|
+
return segmentIndex % 2 === 1 ? React.createElement("b", { key: "bold".concat(segmentIndex) }, text) : text;
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
Markdown.prototype.renderEmphasis = function (splitContents, symbols) {
|
|
50
|
+
var _this = this;
|
|
51
|
+
return splitContents.map(function (_, segmentIndex) {
|
|
52
|
+
var text = _this.processLine(_, segmentIndex, symbols.slice(1));
|
|
53
|
+
return segmentIndex % 2 === 1 ? React.createElement("em", { key: "emphasis".concat(segmentIndex) }, text) : text;
|
|
54
|
+
});
|
|
45
55
|
};
|
|
46
56
|
Markdown.displayName = "Markdown";
|
|
47
57
|
return Markdown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/Markdown/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CA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