@lobehub/ui 2.15.4 → 2.16.0
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/CopyButton/CopyButton.js +6 -4
- package/es/CopyButton/type.d.ts +2 -2
- package/es/Highlighter/FullFeatured.js +96 -51
- package/es/Highlighter/Highlighter.js +44 -25
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.d.ts +17 -0
- package/es/Highlighter/SyntaxHighlighter/StaticRenderer.js +36 -0
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.d.ts +13 -0
- package/es/Highlighter/SyntaxHighlighter/StreamRenderer.js +147 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +36 -139
- package/es/Highlighter/type.d.ts +1 -0
- package/es/Mermaid/FullFeatured.js +77 -45
- package/es/Mermaid/Mermaid.js +39 -20
- package/es/Mermaid/type.d.ts +1 -0
- package/es/hooks/useHighlight.d.ts +19 -3
- package/es/hooks/useHighlight.js +303 -35
- package/es/icons/lucideExtra/DiscordIcon.js +4 -11
- package/es/icons/lucideExtra/GlobeOffIcon.js +3 -18
- package/es/icons/lucideExtra/LeftClickIcon.js +3 -4
- package/es/icons/lucideExtra/LeftDoubleClickIcon.js +2 -3
- package/es/icons/lucideExtra/RightClickIcon.js +3 -4
- package/es/icons/lucideExtra/RightDoubleClickIcon.js +3 -4
- package/package.json +3 -1
- package/es/Highlighter/SyntaxHighlighter/Line.d.ts +0 -5
- package/es/Highlighter/SyntaxHighlighter/Line.js +0 -80
- package/es/Highlighter/SyntaxHighlighter/Span.d.ts +0 -5
- package/es/Highlighter/SyntaxHighlighter/Span.js +0 -16
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
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."); }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
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; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
import { memo, useEffect, useState } from 'react';
|
|
15
|
-
import Span from "./Span";
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
var Line = /*#__PURE__*/memo(function (_ref) {
|
|
18
|
-
var children = _ref.children;
|
|
19
|
-
var _useState = useState([]),
|
|
20
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
-
contents = _useState2[0],
|
|
22
|
-
setContents = _useState2[1];
|
|
23
|
-
useEffect(function () {
|
|
24
|
-
if (children && typeof children === 'string') {
|
|
25
|
-
// Extract all lines from the HTML content
|
|
26
|
-
// We need to handle the structure from shiki which gives us HTML with a <pre><code> structure
|
|
27
|
-
var parser = new DOMParser();
|
|
28
|
-
var doc = parser.parseFromString(children, 'text/html');
|
|
29
|
-
var codeElement = doc.querySelector('span.line');
|
|
30
|
-
if (codeElement) {
|
|
31
|
-
var spanLines = codeElement.querySelectorAll('span');
|
|
32
|
-
var newLines = _toConsumableArray(spanLines).map(function (line) {
|
|
33
|
-
return line.outerHTML;
|
|
34
|
-
});
|
|
35
|
-
setContents(function (prevLines) {
|
|
36
|
-
if (prevLines.length !== newLines.length) return newLines;
|
|
37
|
-
var hasChanged = false;
|
|
38
|
-
var _iterator = _createForOfIteratorHelper(newLines.entries()),
|
|
39
|
-
_step;
|
|
40
|
-
try {
|
|
41
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
42
|
-
var _step$value = _slicedToArray(_step.value, 2),
|
|
43
|
-
i = _step$value[0],
|
|
44
|
-
newLine = _step$value[1];
|
|
45
|
-
if (prevLines[i] !== newLine) {
|
|
46
|
-
hasChanged = true;
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
_iterator.e(err);
|
|
52
|
-
} finally {
|
|
53
|
-
_iterator.f();
|
|
54
|
-
}
|
|
55
|
-
return hasChanged ? newLines : prevLines;
|
|
56
|
-
});
|
|
57
|
-
} else {
|
|
58
|
-
// Fallback if the structure is different
|
|
59
|
-
var htmlLines = children.split('\n').map(function (line) {
|
|
60
|
-
return "<span>".concat(line, "</span>");
|
|
61
|
-
});
|
|
62
|
-
setContents(htmlLines);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}, [children]);
|
|
66
|
-
return /*#__PURE__*/_jsx("span", {
|
|
67
|
-
className: 'line',
|
|
68
|
-
children: contents && contents.length > 0 ? contents.map(function (span, index) {
|
|
69
|
-
return /*#__PURE__*/_jsx(Span, {
|
|
70
|
-
children: span
|
|
71
|
-
}, index);
|
|
72
|
-
}) : /*#__PURE__*/_jsx("span", {
|
|
73
|
-
children: " "
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
}, function (prevProps, nextProps) {
|
|
77
|
-
return prevProps.children === nextProps.children;
|
|
78
|
-
});
|
|
79
|
-
Line.displayName = 'HighlighterLine';
|
|
80
|
-
export default Line;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { memo } from 'react';
|
|
4
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
var Span = /*#__PURE__*/memo(function (_ref) {
|
|
6
|
-
var children = _ref.children;
|
|
7
|
-
return /*#__PURE__*/_jsx("span", {
|
|
8
|
-
dangerouslySetInnerHTML: {
|
|
9
|
-
__html: children || ''
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
}, function (prevProps, nextProps) {
|
|
13
|
-
return prevProps.children === nextProps.children;
|
|
14
|
-
});
|
|
15
|
-
Span.displayName = 'HighlighterSpan';
|
|
16
|
-
export default Span;
|