synapse-react-client
Version:
[](https://travis-ci.com/Sage-Bionetworks/Synapse-React-Client) [](https://badge.fury.io/js/synaps
48 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = (0, tslib_1.__importStar)(require("react"));
var Bookmarks = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Bookmarks, _super);
function Bookmarks(props) {
var _this = _super.call(this, props) || this;
_this.renderBookmarks = _this.renderBookmarks.bind(_this);
return _this;
}
/**
* Returns bookmarks
*
* @returns JSX for the embedded bookmarks in the markdown passed in as a prop
* @memberof Bookmarks
*/
Bookmarks.prototype.renderBookmarks = function () {
var copyFootnotes = String(this.props.footnotes);
// find all the links embedded in the markdown below
var regex = /Synapse widget><\/span>(.*)</g;
var matchedGroup;
var output = [];
// below we use regex.exec to find the find matched group containing the citation source
while ((matchedGroup = regex.exec(copyFootnotes))) {
output.push(matchedGroup[1]);
}
// return all the links formatted accordingly
return output.map(function (el, index) {
var isBeforeLastElement = index < output.length - 1;
return (React.createElement(React.Fragment, { key: index },
React.createElement("button", { className: "SRC-markdown-bookmark", id: "bookmark" + index },
"[",
index + 1,
"]"),
React.createElement("span", { dangerouslySetInnerHTML: { __html: el } }),
isBeforeLastElement && React.createElement("br", null)));
});
};
Bookmarks.prototype.render = function () {
return (React.createElement(React.Fragment, null,
React.createElement("hr", null),
this.renderBookmarks()));
};
return Bookmarks;
}(React.Component));
exports.default = Bookmarks;
//# sourceMappingURL=Bookmarks.js.map