@lobehub/ui 2.0.14 → 2.0.16
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/es/Markdown/Markdown.js +30 -3
- package/package.json +1 -1
package/es/Markdown/Markdown.js
CHANGED
|
@@ -7,10 +7,16 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
8
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
9
|
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); }
|
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
11
|
+
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."); }
|
|
12
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
+
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; } }
|
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
16
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
11
17
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
18
|
import { cva } from 'class-variance-authority';
|
|
13
|
-
import { memo, useMemo } from 'react';
|
|
19
|
+
import { memo, useEffect, useMemo, useState } from 'react';
|
|
14
20
|
import SyntaxMarkdown from "./SyntaxMarkdown";
|
|
15
21
|
import Typography from "./Typography";
|
|
16
22
|
import { useStyles } from "./style";
|
|
@@ -55,6 +61,27 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
55
61
|
var _useStyles = useStyles(),
|
|
56
62
|
cx = _useStyles.cx,
|
|
57
63
|
styles = _useStyles.styles;
|
|
64
|
+
// Add state to track delayed animated value
|
|
65
|
+
var _useState = useState(animated),
|
|
66
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
67
|
+
delayedAnimated = _useState2[0],
|
|
68
|
+
setDelayedAnimated = _useState2[1];
|
|
69
|
+
|
|
70
|
+
// Watch for changes in animated prop
|
|
71
|
+
useEffect(function () {
|
|
72
|
+
// If animated changes from true to false, delay the update by 1 second
|
|
73
|
+
if (animated === false && delayedAnimated === true) {
|
|
74
|
+
var timer = setTimeout(function () {
|
|
75
|
+
setDelayedAnimated(false);
|
|
76
|
+
}, 1000);
|
|
77
|
+
return function () {
|
|
78
|
+
return clearTimeout(timer);
|
|
79
|
+
};
|
|
80
|
+
} else {
|
|
81
|
+
// For any other changes, update immediately
|
|
82
|
+
setDelayedAnimated(animated);
|
|
83
|
+
}
|
|
84
|
+
}, [animated, delayedAnimated]);
|
|
58
85
|
|
|
59
86
|
// Style variant handling
|
|
60
87
|
var variants = useMemo(function () {
|
|
@@ -84,7 +111,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
84
111
|
}, [styles]);
|
|
85
112
|
return /*#__PURE__*/_jsx(Typography, _objectSpread(_objectSpread({
|
|
86
113
|
className: cx(variants({
|
|
87
|
-
animated:
|
|
114
|
+
animated: delayedAnimated,
|
|
88
115
|
enableLatex: enableLatex,
|
|
89
116
|
variant: variant
|
|
90
117
|
}), className),
|
|
@@ -99,7 +126,7 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
99
126
|
}, rest), {}, {
|
|
100
127
|
children: /*#__PURE__*/_jsx(SyntaxMarkdown, {
|
|
101
128
|
allowHtml: allowHtml,
|
|
102
|
-
animated:
|
|
129
|
+
animated: delayedAnimated,
|
|
103
130
|
citations: citations,
|
|
104
131
|
componentProps: componentProps,
|
|
105
132
|
components: components,
|