dash-core-components 4.4.1 → 4.5.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/dash_core_components/async-datepicker.js +2 -1
- package/dash_core_components/async-datepicker.js.map +1 -1
- package/dash_core_components/async-dropdown.js.map +1 -1
- package/dash_core_components/async-graph.js +1 -1
- package/dash_core_components/async-graph.js.map +1 -1
- package/dash_core_components/async-highlight.js +1 -1
- package/dash_core_components/async-highlight.js.map +1 -1
- package/dash_core_components/async-markdown.js +1 -1
- package/dash_core_components/async-markdown.js.map +1 -1
- package/dash_core_components/async-mathjax.js +1 -1
- package/dash_core_components/async-slider.js +1 -1
- package/dash_core_components/async-slider.js.map +1 -1
- package/dash_core_components/async-upload.js +1 -1
- package/dash_core_components/async-upload.js.map +1 -1
- package/dash_core_components/dash_core_components-shared.js +1 -2
- package/dash_core_components/dash_core_components-shared.js.map +1 -1
- package/dash_core_components/dash_core_components.js +1 -1
- package/dash_core_components/dash_core_components.js.map +1 -1
- package/dash_core_components/proptypes.js +20 -0
- package/lib/components/Graph.react.js +1 -1
- package/lib/components/Input.tsx +3 -3
- package/lib/components/Link.tsx +79 -0
- package/lib/components/Markdown.tsx +35 -0
- package/lib/fragments/DatePickerRange.tsx +2 -0
- package/lib/fragments/DatePickerSingle.tsx +1 -0
- package/lib/fragments/Graph.react.js +6 -7
- package/lib/fragments/Markdown.tsx +101 -0
- package/lib/fragments/Upload.react.js +39 -27
- package/lib/index.ts +2 -2
- package/lib/types.ts +133 -0
- package/lib/utils/LazyLoader/markdown.ts +2 -0
- package/lib/utils/LazyLoader/third-party/highlight.ts +42 -0
- package/lib/utils/LazyLoader/third-party/hljs.ts +18 -0
- package/lib/utils/LazyLoader/third-party/mathjax.ts +23 -0
- package/lib/utils/LazyLoader/third-party/tex-svg.ts +5 -0
- package/lib/utils/markdown/components/Code.tsx +37 -0
- package/lib/utils/markdown/components/DccLink.tsx +25 -0
- package/lib/utils/markdown/components/DccMarkdown.tsx +13 -0
- package/lib/utils/markdown/components/MathJax.tsx +26 -0
- package/lib/utils/markdown/components/index.ts +13 -0
- package/lib/utils/markdown/components/jsx-renderers.d.ts +14 -0
- package/lib/utils/markdown/components/types.ts +15 -0
- package/lib/utils/markdown/context.ts +18 -0
- package/lib/utils/markdown/plugins/index.ts +28 -0
- package/lib/utils/markdown/plugins/rehypeDashMath.ts +69 -0
- package/lib/utils/markdown/plugins/rehypeDccComponents.ts +33 -0
- package/lib/utils/markdown/plugins/rehypeStripTags.ts +23 -0
- package/lib/utils/markdown/text.ts +64 -0
- package/package.json +10 -7
- package/lib/components/Link.react.js +0 -150
- package/lib/components/Markdown.react.js +0 -124
- package/lib/fragments/Markdown.react.js +0 -195
- package/lib/fragments/Math.react.js +0 -72
- package/lib/third-party/highlight.js +0 -46
- package/lib/utils/LazyLoader/hljs.js +0 -11
- package/lib/utils/LazyLoader/markdown.js +0 -9
- package/lib/utils/LazyLoader/mathjax.js +0 -11
- package/lib/utils/MarkdownHighlighter.js +0 -23
- package/lib/utils/mathjax.js +0 -4
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.propTypes = exports.defaultProps = exports.default = void 0;
|
|
8
|
-
var _dashComponentPlugins = require("@plotly/dash-component-plugins");
|
|
9
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _markdown = _interopRequireDefault(require("../utils/LazyLoader/markdown"));
|
|
12
|
-
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
13
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
16
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
17
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
18
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
19
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
20
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
21
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
22
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
23
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
26
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
27
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
28
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
29
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
30
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
31
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
32
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
33
|
-
// eslint-disable-next-line valid-jsdoc
|
|
34
|
-
/**
|
|
35
|
-
* A component that renders Markdown text as specified by the
|
|
36
|
-
* GitHub Markdown spec. These component uses
|
|
37
|
-
* [react-markdown](https://rexxars.github.io/react-markdown/) under the hood.
|
|
38
|
-
*/
|
|
39
|
-
var DashMarkdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
40
|
-
function DashMarkdown(props) {
|
|
41
|
-
var _this;
|
|
42
|
-
_classCallCheck(this, DashMarkdown);
|
|
43
|
-
_this = _callSuper(this, DashMarkdown, [props]);
|
|
44
|
-
if (props.mathjax) {
|
|
45
|
-
DashMarkdown._loadMathjax = true;
|
|
46
|
-
}
|
|
47
|
-
return _this;
|
|
48
|
-
}
|
|
49
|
-
_inherits(DashMarkdown, _Component);
|
|
50
|
-
return _createClass(DashMarkdown, [{
|
|
51
|
-
key: "render",
|
|
52
|
-
value: function render() {
|
|
53
|
-
return /*#__PURE__*/_react.default.createElement(_react.Suspense, {
|
|
54
|
-
fallback: null
|
|
55
|
-
}, /*#__PURE__*/_react.default.createElement(RealDashMarkdown, this.props));
|
|
56
|
-
}
|
|
57
|
-
}]);
|
|
58
|
-
}(_react.Component);
|
|
59
|
-
DashMarkdown.propTypes = {
|
|
60
|
-
/**
|
|
61
|
-
* The ID of this component, used to identify dash components
|
|
62
|
-
* in callbacks. The ID needs to be unique across all of the
|
|
63
|
-
* components in an app.
|
|
64
|
-
*/
|
|
65
|
-
id: _propTypes.default.string,
|
|
66
|
-
/**
|
|
67
|
-
* Class name of the container element
|
|
68
|
-
*/
|
|
69
|
-
className: _propTypes.default.string,
|
|
70
|
-
/**
|
|
71
|
-
* If true, loads mathjax v3 (tex-svg) into the page and use it in the markdown
|
|
72
|
-
*/
|
|
73
|
-
mathjax: _propTypes.default.bool,
|
|
74
|
-
/**
|
|
75
|
-
* A boolean to control raw HTML escaping.
|
|
76
|
-
* Setting HTML from code is risky because it's easy to
|
|
77
|
-
* inadvertently expose your users to a cross-site scripting (XSS)
|
|
78
|
-
* (https://en.wikipedia.org/wiki/Cross-site_scripting) attack.
|
|
79
|
-
*/
|
|
80
|
-
dangerously_allow_html: _propTypes.default.bool,
|
|
81
|
-
/**
|
|
82
|
-
* A string for the target attribute to use on links (such as "_blank")
|
|
83
|
-
*/
|
|
84
|
-
link_target: _propTypes.default.string,
|
|
85
|
-
/**
|
|
86
|
-
* A markdown string (or array of strings) that adheres to the CommonMark spec
|
|
87
|
-
*/
|
|
88
|
-
children: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.arrayOf(_propTypes.default.string)]),
|
|
89
|
-
/**
|
|
90
|
-
* Remove matching leading whitespace from all lines.
|
|
91
|
-
* Lines that are empty, or contain *only* whitespace, are ignored.
|
|
92
|
-
* Both spaces and tab characters are removed, but only if they match;
|
|
93
|
-
* we will not convert tabs to spaces or vice versa.
|
|
94
|
-
*/
|
|
95
|
-
dedent: _propTypes.default.bool,
|
|
96
|
-
/**
|
|
97
|
-
* Config options for syntax highlighting.
|
|
98
|
-
*/
|
|
99
|
-
highlight_config: _propTypes.default.exact({
|
|
100
|
-
/**
|
|
101
|
-
* Color scheme; default 'light'
|
|
102
|
-
*/
|
|
103
|
-
theme: _propTypes.default.oneOf(['dark', 'light'])
|
|
104
|
-
}),
|
|
105
|
-
/**
|
|
106
|
-
* User-defined inline styles for the rendered Markdown
|
|
107
|
-
*/
|
|
108
|
-
style: _propTypes.default.object
|
|
109
|
-
};
|
|
110
|
-
DashMarkdown.defaultProps = {
|
|
111
|
-
mathjax: false,
|
|
112
|
-
dangerously_allow_html: false,
|
|
113
|
-
highlight_config: {},
|
|
114
|
-
dedent: true
|
|
115
|
-
};
|
|
116
|
-
var RealDashMarkdown = (0, _dashComponentPlugins.asyncDecorator)(DashMarkdown, function () {
|
|
117
|
-
return Promise.all([(0, _markdown.default)(), DashMarkdown._loadMathjax ? (0, _mathjax.default)() : undefined]).then(function (_ref) {
|
|
118
|
-
var _ref2 = _slicedToArray(_ref, 1),
|
|
119
|
-
md = _ref2[0];
|
|
120
|
-
return md;
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
var propTypes = exports.propTypes = DashMarkdown.propTypes;
|
|
124
|
-
var defaultProps = exports.defaultProps = DashMarkdown.defaultProps;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _ramda = require("ramda");
|
|
10
|
-
var _reactJsxParser = _interopRequireDefault(require("react-jsx-parser"));
|
|
11
|
-
var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
|
|
12
|
-
var _remarkMath = _interopRequireDefault(require("remark-math"));
|
|
13
|
-
var _Math = _interopRequireDefault(require("./Math.react"));
|
|
14
|
-
var _MarkdownHighlighter = _interopRequireDefault(require("../utils/MarkdownHighlighter"));
|
|
15
|
-
var _Markdown = require("../components/Markdown.react");
|
|
16
|
-
var _Link = _interopRequireDefault(require("./../components/Link.react"));
|
|
17
|
-
var _LoadingElement = _interopRequireDefault(require("../utils/LoadingElement"));
|
|
18
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
20
|
-
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
21
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
22
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
23
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
24
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
25
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
26
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
27
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
29
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
30
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
31
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
32
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
33
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
34
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
35
|
-
var DashMarkdown = exports.default = /*#__PURE__*/function (_Component) {
|
|
36
|
-
function DashMarkdown(props) {
|
|
37
|
-
var _this;
|
|
38
|
-
_classCallCheck(this, DashMarkdown);
|
|
39
|
-
_this = _callSuper(this, DashMarkdown, [props]);
|
|
40
|
-
if (_MarkdownHighlighter.default.isReady !== true) {
|
|
41
|
-
_MarkdownHighlighter.default.isReady.then(function () {
|
|
42
|
-
_this.setState({});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
_this.highlightCode = _this.highlightCode.bind(_this);
|
|
46
|
-
_this.dedent = _this.dedent.bind(_this);
|
|
47
|
-
return _this;
|
|
48
|
-
}
|
|
49
|
-
_inherits(DashMarkdown, _Component);
|
|
50
|
-
return _createClass(DashMarkdown, [{
|
|
51
|
-
key: "componentDidMount",
|
|
52
|
-
value: function componentDidMount() {
|
|
53
|
-
this.highlightCode();
|
|
54
|
-
}
|
|
55
|
-
}, {
|
|
56
|
-
key: "componentDidUpdate",
|
|
57
|
-
value: function componentDidUpdate() {
|
|
58
|
-
this.highlightCode();
|
|
59
|
-
}
|
|
60
|
-
}, {
|
|
61
|
-
key: "highlightCode",
|
|
62
|
-
value: function highlightCode() {
|
|
63
|
-
var isHighlighted = function isHighlighted(node) {
|
|
64
|
-
// a highlighted node will have <span> children which are what color the text
|
|
65
|
-
return node.children.length > 0;
|
|
66
|
-
};
|
|
67
|
-
if (this.mdContainer) {
|
|
68
|
-
var nodes = this.mdContainer.querySelectorAll('pre code');
|
|
69
|
-
if (_MarkdownHighlighter.default.hljs) {
|
|
70
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
71
|
-
if (!isHighlighted(nodes[i])) {
|
|
72
|
-
nodes[i].removeAttribute('data-highlighted');
|
|
73
|
-
_MarkdownHighlighter.default.hljs.highlightElement(nodes[i]);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
_MarkdownHighlighter.default.loadhljs();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "dedent",
|
|
83
|
-
value: function dedent(text) {
|
|
84
|
-
var lines = text.split(/\r\n|\r|\n/);
|
|
85
|
-
var commonPrefix = null;
|
|
86
|
-
var _iterator = _createForOfIteratorHelper(lines),
|
|
87
|
-
_step;
|
|
88
|
-
try {
|
|
89
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
90
|
-
var line = _step.value;
|
|
91
|
-
var preMatch = line && line.match(/^\s*(?=\S)/);
|
|
92
|
-
if (preMatch) {
|
|
93
|
-
var prefix = preMatch[0];
|
|
94
|
-
if (commonPrefix !== null) {
|
|
95
|
-
for (var i = 0; i < commonPrefix.length; i++) {
|
|
96
|
-
// Like Python's textwrap.dedent, we'll remove both
|
|
97
|
-
// space and tab characters, but only if they match
|
|
98
|
-
if (prefix[i] !== commonPrefix[i]) {
|
|
99
|
-
commonPrefix = commonPrefix.substr(0, i);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
} else {
|
|
104
|
-
commonPrefix = prefix;
|
|
105
|
-
}
|
|
106
|
-
if (!commonPrefix) {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
} catch (err) {
|
|
112
|
-
_iterator.e(err);
|
|
113
|
-
} finally {
|
|
114
|
-
_iterator.f();
|
|
115
|
-
}
|
|
116
|
-
var commonLen = commonPrefix ? commonPrefix.length : 0;
|
|
117
|
-
return lines.map(function (line) {
|
|
118
|
-
return line.match(/\S/) ? line.substr(commonLen) : '';
|
|
119
|
-
}).join('\n');
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
key: "render",
|
|
123
|
-
value: function render() {
|
|
124
|
-
var _this2 = this;
|
|
125
|
-
var _this$props = this.props,
|
|
126
|
-
id = _this$props.id,
|
|
127
|
-
style = _this$props.style,
|
|
128
|
-
className = _this$props.className,
|
|
129
|
-
highlight_config = _this$props.highlight_config,
|
|
130
|
-
dangerously_allow_html = _this$props.dangerously_allow_html,
|
|
131
|
-
link_target = _this$props.link_target,
|
|
132
|
-
mathjax = _this$props.mathjax,
|
|
133
|
-
children = _this$props.children,
|
|
134
|
-
dedent = _this$props.dedent;
|
|
135
|
-
var textProp = (0, _ramda.type)(children) === 'Array' ? children.join('\n') : children;
|
|
136
|
-
var displayText = dedent && textProp ? this.dedent(textProp) : textProp;
|
|
137
|
-
var componentTransforms = {
|
|
138
|
-
dccLink: function dccLink(props) {
|
|
139
|
-
return /*#__PURE__*/_react.default.createElement(_Link.default, props);
|
|
140
|
-
},
|
|
141
|
-
dccMarkdown: function dccMarkdown(props) {
|
|
142
|
-
return /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, (0, _ramda.mergeDeepRight)((0, _ramda.pick)(['dangerously_allow_html', 'dedent'], _this2.props), (0, _ramda.pick)(['children'], props)));
|
|
143
|
-
},
|
|
144
|
-
dashMathjax: function dashMathjax(props) {
|
|
145
|
-
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
146
|
-
tex: props.value,
|
|
147
|
-
inline: props.inline
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
var regexMath = function regexMath(value) {
|
|
152
|
-
var newValue = value.replace(/(\${1,2})((?:\\.|[^$])+)\1/g, function (m, tag, src) {
|
|
153
|
-
var inline = tag.length === 1 || src.indexOf('\n') === -1;
|
|
154
|
-
return "<dashMathjax value='".concat(src, "' inline='").concat(inline, "'/>");
|
|
155
|
-
});
|
|
156
|
-
return newValue;
|
|
157
|
-
};
|
|
158
|
-
return /*#__PURE__*/_react.default.createElement(_LoadingElement.default, {
|
|
159
|
-
id: id,
|
|
160
|
-
ref: function ref(node) {
|
|
161
|
-
_this2.mdContainer = node;
|
|
162
|
-
},
|
|
163
|
-
style: style,
|
|
164
|
-
className: (highlight_config && highlight_config.theme || className) && "".concat(className ? className : '', " ").concat(highlight_config && highlight_config.theme && highlight_config.theme === 'dark' ? 'hljs-dark' : '')
|
|
165
|
-
}, /*#__PURE__*/_react.default.createElement(_reactMarkdown.default, {
|
|
166
|
-
source: displayText,
|
|
167
|
-
escapeHtml: !dangerously_allow_html,
|
|
168
|
-
linkTarget: link_target,
|
|
169
|
-
plugins: mathjax ? [_remarkMath.default] : [],
|
|
170
|
-
renderers: {
|
|
171
|
-
math: function math(props) {
|
|
172
|
-
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
173
|
-
tex: props.value,
|
|
174
|
-
inline: false
|
|
175
|
-
});
|
|
176
|
-
},
|
|
177
|
-
inlineMath: function inlineMath(props) {
|
|
178
|
-
return /*#__PURE__*/_react.default.createElement(_Math.default, {
|
|
179
|
-
tex: props.value,
|
|
180
|
-
inline: true
|
|
181
|
-
});
|
|
182
|
-
},
|
|
183
|
-
html: function html(props) {
|
|
184
|
-
return props.escapeHtml ? props.value : /*#__PURE__*/_react.default.createElement(_reactJsxParser.default, {
|
|
185
|
-
jsx: mathjax ? regexMath(props.value) : props.value,
|
|
186
|
-
components: componentTransforms,
|
|
187
|
-
renderInWrapper: false
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}));
|
|
192
|
-
}
|
|
193
|
-
}]);
|
|
194
|
-
}(_react.Component);
|
|
195
|
-
DashMarkdown.propTypes = _Markdown.propTypes;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.propTypes = exports.defaultProps = exports.default = void 0;
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _mathjax = _interopRequireDefault(require("../utils/LazyLoader/mathjax"));
|
|
11
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
14
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
15
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
16
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
19
|
-
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
20
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
-
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
24
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
25
|
-
var DashMath = exports.default = /*#__PURE__*/function (_Component) {
|
|
26
|
-
function DashMath(props) {
|
|
27
|
-
var _this;
|
|
28
|
-
_classCallCheck(this, DashMath);
|
|
29
|
-
_this = _callSuper(this, DashMath, [props]);
|
|
30
|
-
_this.span_element = /*#__PURE__*/_react.default.createRef();
|
|
31
|
-
return _this;
|
|
32
|
-
}
|
|
33
|
-
_inherits(DashMath, _Component);
|
|
34
|
-
return _createClass(DashMath, [{
|
|
35
|
-
key: "componentDidMount",
|
|
36
|
-
value: function componentDidMount() {
|
|
37
|
-
this.renderMath();
|
|
38
|
-
}
|
|
39
|
-
}, {
|
|
40
|
-
key: "componentDidUpdate",
|
|
41
|
-
value: function componentDidUpdate(prevProps) {
|
|
42
|
-
if (prevProps.tex !== this.props.tex || prevProps.inline !== this.props.inline) {
|
|
43
|
-
this.renderMath();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}, {
|
|
47
|
-
key: "renderMath",
|
|
48
|
-
value: function renderMath() {
|
|
49
|
-
var current = this.span_element.current;
|
|
50
|
-
(0, _mathjax.default)().then(function () {
|
|
51
|
-
window.MathJax.typeset([current]);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "render",
|
|
56
|
-
value: function render() {
|
|
57
|
-
return /*#__PURE__*/_react.default.createElement("span", {
|
|
58
|
-
ref: this.span_element
|
|
59
|
-
}, this.props.inline ? '\\(' : '\\[', this.props.tex, this.props.inline ? '\\)' : '\\]');
|
|
60
|
-
}
|
|
61
|
-
}]);
|
|
62
|
-
}(_react.Component);
|
|
63
|
-
DashMath.propTypes = {
|
|
64
|
-
tex: _propTypes.default.string,
|
|
65
|
-
inline: _propTypes.default.bool
|
|
66
|
-
};
|
|
67
|
-
DashMath.defaultProps = {
|
|
68
|
-
tex: '',
|
|
69
|
-
inline: true
|
|
70
|
-
};
|
|
71
|
-
var propTypes = exports.propTypes = DashMath.propTypes;
|
|
72
|
-
var defaultProps = exports.defaultProps = DashMath.defaultProps;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _core = _interopRequireDefault(require("highlight.js/lib/core"));
|
|
8
|
-
require("highlight.js/styles/github.css");
|
|
9
|
-
var _bash = _interopRequireDefault(require("highlight.js/lib/languages/bash"));
|
|
10
|
-
var _csharp = _interopRequireDefault(require("highlight.js/lib/languages/csharp"));
|
|
11
|
-
var _css = _interopRequireDefault(require("highlight.js/lib/languages/css"));
|
|
12
|
-
var _fsharp = _interopRequireDefault(require("highlight.js/lib/languages/fsharp"));
|
|
13
|
-
var _http = _interopRequireDefault(require("highlight.js/lib/languages/http"));
|
|
14
|
-
var _javascript = _interopRequireDefault(require("highlight.js/lib/languages/javascript"));
|
|
15
|
-
var _json = _interopRequireDefault(require("highlight.js/lib/languages/json"));
|
|
16
|
-
var _julia = _interopRequireDefault(require("highlight.js/lib/languages/julia"));
|
|
17
|
-
var _markdown = _interopRequireDefault(require("highlight.js/lib/languages/markdown"));
|
|
18
|
-
var _matlab = _interopRequireDefault(require("highlight.js/lib/languages/matlab"));
|
|
19
|
-
var _plaintext = _interopRequireDefault(require("highlight.js/lib/languages/plaintext"));
|
|
20
|
-
var _python = _interopRequireDefault(require("highlight.js/lib/languages/python"));
|
|
21
|
-
var _r = _interopRequireDefault(require("highlight.js/lib/languages/r"));
|
|
22
|
-
var _ruby = _interopRequireDefault(require("highlight.js/lib/languages/ruby"));
|
|
23
|
-
var _shell = _interopRequireDefault(require("highlight.js/lib/languages/shell"));
|
|
24
|
-
var _sql = _interopRequireDefault(require("highlight.js/lib/languages/sql"));
|
|
25
|
-
var _xml = _interopRequireDefault(require("highlight.js/lib/languages/xml"));
|
|
26
|
-
var _yaml = _interopRequireDefault(require("highlight.js/lib/languages/yaml"));
|
|
27
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
28
|
-
_core.default.registerLanguage('bash', _bash.default);
|
|
29
|
-
_core.default.registerLanguage('csharp', _csharp.default);
|
|
30
|
-
_core.default.registerLanguage('css', _css.default);
|
|
31
|
-
_core.default.registerLanguage('fsharp', _fsharp.default);
|
|
32
|
-
_core.default.registerLanguage('http', _http.default);
|
|
33
|
-
_core.default.registerLanguage('javascript', _javascript.default);
|
|
34
|
-
_core.default.registerLanguage('json', _json.default);
|
|
35
|
-
_core.default.registerLanguage('julia', _julia.default);
|
|
36
|
-
_core.default.registerLanguage('markdown', _markdown.default);
|
|
37
|
-
_core.default.registerLanguage('matlab', _matlab.default);
|
|
38
|
-
_core.default.registerLanguage('plaintext', _plaintext.default);
|
|
39
|
-
_core.default.registerLanguage('python', _python.default);
|
|
40
|
-
_core.default.registerLanguage('r', _r.default);
|
|
41
|
-
_core.default.registerLanguage('ruby', _ruby.default);
|
|
42
|
-
_core.default.registerLanguage('shell', _shell.default);
|
|
43
|
-
_core.default.registerLanguage('sql', _sql.default);
|
|
44
|
-
_core.default.registerLanguage('xml', _xml.default);
|
|
45
|
-
_core.default.registerLanguage('yaml', _yaml.default);
|
|
46
|
-
var _default = exports.default = _core.default;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = function _default() {
|
|
8
|
-
return Promise.resolve(window.hljs || import(/* webpackChunkName: "highlight" */'../../third-party/highlight.js').then(function (result) {
|
|
9
|
-
return result.default;
|
|
10
|
-
}));
|
|
11
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = function _default(mathjax) {
|
|
8
|
-
return Promise.resolve(window.MathJax || (mathjax === false ? undefined : import(/* webpackChunkName: "mathjax" */'../mathjax').then(function () {
|
|
9
|
-
return window.MathJax;
|
|
10
|
-
})));
|
|
11
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _hljs = _interopRequireDefault(require("./LazyLoader/hljs"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
var MarkdownHighlighter = {
|
|
10
|
-
loadhljs: function loadhljs() {
|
|
11
|
-
var _this = this;
|
|
12
|
-
return (0, _hljs.default)().then(function (hljs) {
|
|
13
|
-
_this.hljs = hljs;
|
|
14
|
-
_this.hljsResolve();
|
|
15
|
-
_this.isReady = true;
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
var isReady = new Promise(function (resolve) {
|
|
20
|
-
MarkdownHighlighter.hljsResolve = resolve;
|
|
21
|
-
});
|
|
22
|
-
MarkdownHighlighter.isReady = isReady;
|
|
23
|
-
var _default = exports.default = MarkdownHighlighter;
|
package/lib/utils/mathjax.js
DELETED