@lobehub/ui 2.9.5 → 2.10.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/Highlighter/SyntaxHighlighter/Line.js +2 -0
- package/es/Highlighter/SyntaxHighlighter/Span.js +2 -0
- package/es/Highlighter/SyntaxHighlighter/index.js +2 -0
- package/es/Markdown/Markdown.js +3 -2
- package/es/Markdown/SyntaxMarkdown/MarkdownRender.d.ts +3 -0
- package/es/Markdown/SyntaxMarkdown/MarkdownRender.js +32 -0
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.d.ts +3 -0
- package/es/Markdown/SyntaxMarkdown/StreamdownRender.js +64 -0
- package/es/Markdown/SyntaxMarkdown/index.d.ts +2 -3
- package/es/Markdown/SyntaxMarkdown/index.js +2 -40
- package/es/Markdown/SyntaxMarkdown/parseIncompleteMarkdown.d.ts +1 -0
- package/es/Markdown/SyntaxMarkdown/parseIncompleteMarkdown.js +293 -0
- package/es/Markdown/Typography.js +17 -11
- package/es/Markdown/components/CodeBlock.d.ts +2 -2
- package/es/Markdown/components/CodeBlock.js +5 -2
- package/es/Markdown/markdown.style.d.ts +1 -6
- package/es/Markdown/markdown.style.js +19 -27
- package/es/Mermaid/SyntaxMermaid/index.js +2 -0
- package/es/hooks/useMarkdown/fixMarkdownEmphasisSpacing.js +0 -60
- package/es/hooks/useMarkdown/useMarkdownComponents.js +36 -35
- package/es/hooks/useMarkdown/utils.d.ts +0 -10
- package/es/hooks/useMarkdown/utils.js +0 -10
- package/package.json +2 -1
|
@@ -181,6 +181,8 @@ var SyntaxHighlighter = /*#__PURE__*/memo(function (_ref) {
|
|
|
181
181
|
})
|
|
182
182
|
})
|
|
183
183
|
});
|
|
184
|
+
}, function (prevProps, nextProps) {
|
|
185
|
+
return prevProps.children === nextProps.children && prevProps.language === nextProps.language;
|
|
184
186
|
});
|
|
185
187
|
SyntaxHighlighter.displayName = 'SyntaxHighlighter';
|
|
186
188
|
export default SyntaxHighlighter;
|
package/es/Markdown/Markdown.js
CHANGED
|
@@ -19,7 +19,7 @@ import { cva } from 'class-variance-authority';
|
|
|
19
19
|
import { memo, useEffect, useMemo, useState } from 'react';
|
|
20
20
|
import { PreviewGroup } from "../Image";
|
|
21
21
|
import { MarkdownProvider } from "./components/MarkdownProvider";
|
|
22
|
-
import
|
|
22
|
+
import { MarkdownRender, StreamdownRender } from "./SyntaxMarkdown";
|
|
23
23
|
import Typography from "./Typography";
|
|
24
24
|
import { useStyles } from "./style";
|
|
25
25
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -109,7 +109,8 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
109
109
|
/* eslint-enable sort-keys-fix/sort-keys-fix */
|
|
110
110
|
});
|
|
111
111
|
}, [styles]);
|
|
112
|
-
var
|
|
112
|
+
var DefaultRender = animated ? StreamdownRender : MarkdownRender;
|
|
113
|
+
var defaultDOM = /*#__PURE__*/_jsx(DefaultRender, _objectSpread(_objectSpread({}, reactMarkdownProps), {}, {
|
|
113
114
|
children: children
|
|
114
115
|
}));
|
|
115
116
|
return /*#__PURE__*/_jsx(PreviewGroup, {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
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
|
+
var _excluded = ["children"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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 _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
|
+
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
|
+
import { memo } from 'react';
|
|
13
|
+
import { MarkdownHooks } from 'react-markdown';
|
|
14
|
+
import { useMarkdownComponents, useMarkdownContent, useMarkdownRehypePlugins, useMarkdownRemarkPlugins } from "../../hooks/useMarkdown";
|
|
15
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
+
var MarkdownRenderer = /*#__PURE__*/memo(function (_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
19
|
+
var escapedContent = useMarkdownContent(children || '');
|
|
20
|
+
var components = useMarkdownComponents();
|
|
21
|
+
var rehypePluginsList = useMarkdownRehypePlugins();
|
|
22
|
+
var remarkPluginsList = useMarkdownRemarkPlugins();
|
|
23
|
+
return /*#__PURE__*/_jsx(MarkdownHooks, _objectSpread(_objectSpread({}, rest), {}, {
|
|
24
|
+
components: components,
|
|
25
|
+
rehypePlugins: rehypePluginsList,
|
|
26
|
+
remarkPlugins: remarkPluginsList,
|
|
27
|
+
children: escapedContent
|
|
28
|
+
}));
|
|
29
|
+
}, function (prevProps, nextProps) {
|
|
30
|
+
return prevProps.children === nextProps.children;
|
|
31
|
+
});
|
|
32
|
+
export default MarkdownRenderer;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client';
|
|
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
|
+
var _excluded = ["children"],
|
|
5
|
+
_excluded2 = ["children"];
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
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; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
import { marked } from 'marked';
|
|
14
|
+
import { memo, useId, useMemo } from 'react';
|
|
15
|
+
import { MarkdownHooks } from 'react-markdown';
|
|
16
|
+
import { useMarkdownComponents, useMarkdownContent, useMarkdownRehypePlugins, useMarkdownRemarkPlugins } from "../../hooks/useMarkdown";
|
|
17
|
+
import { parseIncompleteMarkdown } from "./parseIncompleteMarkdown";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
var parseMarkdownIntoBlocks = function parseMarkdownIntoBlocks(markdown) {
|
|
20
|
+
var tokens = marked.lexer(markdown);
|
|
21
|
+
return tokens.map(function (token) {
|
|
22
|
+
return token.raw;
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var StreamdownBlock = /*#__PURE__*/memo(function (_ref) {
|
|
26
|
+
var children = _ref.children,
|
|
27
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
var parsedContent = useMemo(function () {
|
|
29
|
+
return typeof children === 'string' ? parseIncompleteMarkdown(children.trim()) : children;
|
|
30
|
+
}, [children]);
|
|
31
|
+
return /*#__PURE__*/_jsx(MarkdownHooks, _objectSpread(_objectSpread({}, rest), {}, {
|
|
32
|
+
children: parsedContent
|
|
33
|
+
}));
|
|
34
|
+
}, function (prevProps, nextProps) {
|
|
35
|
+
return prevProps.children === nextProps.children;
|
|
36
|
+
});
|
|
37
|
+
StreamdownBlock.displayName = 'StreamdownBlock';
|
|
38
|
+
export var StreamdownRender = /*#__PURE__*/memo(function (_ref2) {
|
|
39
|
+
var children = _ref2.children,
|
|
40
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
41
|
+
var escapedContent = useMarkdownContent(children || '');
|
|
42
|
+
var components = useMarkdownComponents();
|
|
43
|
+
var rehypePluginsList = useMarkdownRehypePlugins();
|
|
44
|
+
var remarkPluginsList = useMarkdownRemarkPlugins();
|
|
45
|
+
var generatedId = useId();
|
|
46
|
+
var blocks = useMemo(function () {
|
|
47
|
+
return parseMarkdownIntoBlocks(typeof escapedContent === 'string' ? escapedContent : '');
|
|
48
|
+
}, [escapedContent]);
|
|
49
|
+
return /*#__PURE__*/_jsx("div", {
|
|
50
|
+
children: blocks.map(function (block, index) {
|
|
51
|
+
return /*#__PURE__*/_jsx(StreamdownBlock, _objectSpread(_objectSpread({
|
|
52
|
+
components: components,
|
|
53
|
+
rehypePlugins: rehypePluginsList,
|
|
54
|
+
remarkPlugins: remarkPluginsList
|
|
55
|
+
}, rest), {}, {
|
|
56
|
+
children: block
|
|
57
|
+
}), "".concat(generatedId, "-block_").concat(index));
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
}, function (prevProps, nextProps) {
|
|
61
|
+
return prevProps.children === nextProps.children;
|
|
62
|
+
});
|
|
63
|
+
StreamdownRender.displayName = 'StreamdownRender';
|
|
64
|
+
export default StreamdownRender;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export default SyntaxMarkdown;
|
|
1
|
+
export { default as MarkdownRender } from './MarkdownRender';
|
|
2
|
+
export { default as StreamdownRender } from './StreamdownRender';
|
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
var _excluded = ["children"],
|
|
5
|
-
_excluded2 = ["children"];
|
|
6
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
-
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; }
|
|
9
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
import { memo } from 'react';
|
|
14
|
-
import Markdown from 'react-markdown';
|
|
15
|
-
import { useMarkdownComponents, useMarkdownContent, useMarkdownRehypePlugins, useMarkdownRemarkPlugins } from "../../hooks/useMarkdown";
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
var MarkdownRenderer = /*#__PURE__*/memo(function (_ref) {
|
|
18
|
-
var children = _ref.children,
|
|
19
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
20
|
-
var components = useMarkdownComponents();
|
|
21
|
-
var rehypePluginsList = useMarkdownRehypePlugins();
|
|
22
|
-
var remarkPluginsList = useMarkdownRemarkPlugins();
|
|
23
|
-
return /*#__PURE__*/_jsx(Markdown, _objectSpread(_objectSpread({}, rest), {}, {
|
|
24
|
-
components: components,
|
|
25
|
-
rehypePlugins: rehypePluginsList,
|
|
26
|
-
remarkPlugins: remarkPluginsList,
|
|
27
|
-
children: children
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
30
|
-
MarkdownRenderer.displayName = 'MarkdownRenderer';
|
|
31
|
-
var SyntaxMarkdown = /*#__PURE__*/memo(function (_ref2) {
|
|
32
|
-
var children = _ref2.children,
|
|
33
|
-
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
34
|
-
var escapedContent = useMarkdownContent(children || '');
|
|
35
|
-
return /*#__PURE__*/_jsx(MarkdownRenderer, _objectSpread(_objectSpread({}, rest), {}, {
|
|
36
|
-
children: escapedContent
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
SyntaxMarkdown.displayName = 'SyntaxMarkdown';
|
|
40
|
-
export default SyntaxMarkdown;
|
|
1
|
+
export { default as MarkdownRender } from "./MarkdownRender";
|
|
2
|
+
export { default as StreamdownRender } from "./StreamdownRender";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const parseIncompleteMarkdown: (text: string) => string;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
var linkImagePattern = /(!?\[)([^\]]*?)$/;
|
|
5
|
+
var boldPattern = /(\*\*)([^*]*?)$/;
|
|
6
|
+
var italicPattern = /(__)([^_]*?)$/;
|
|
7
|
+
var boldItalicPattern = /(\*{3})([^*]*?)$/;
|
|
8
|
+
var singleAsteriskPattern = /(\*)([^*]*?)$/;
|
|
9
|
+
var singleUnderscorePattern = /(_)([^_]*?)$/;
|
|
10
|
+
var inlineCodePattern = /(`)([^`]*?)$/;
|
|
11
|
+
var strikethroughPattern = /(~~)([^~]*?)$/;
|
|
12
|
+
var inlineKatexPattern = /(\$)([^$]*?)$/;
|
|
13
|
+
var blockKatexPattern = /(\$\$)([^$]*?)$/;
|
|
14
|
+
|
|
15
|
+
// Handles incomplete links and images by removing them if not closed
|
|
16
|
+
var handleIncompleteLinksAndImages = function handleIncompleteLinksAndImages(text) {
|
|
17
|
+
var linkMatch = text.match(linkImagePattern);
|
|
18
|
+
if (linkMatch) {
|
|
19
|
+
var startIndex = text.lastIndexOf(linkMatch[1]);
|
|
20
|
+
return text.slice(0, Math.max(0, startIndex));
|
|
21
|
+
}
|
|
22
|
+
return text;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Completes incomplete bold formatting (**)
|
|
26
|
+
var handleIncompleteBold = function handleIncompleteBold(text) {
|
|
27
|
+
var boldMatch = text.match(boldPattern);
|
|
28
|
+
if (boldMatch) {
|
|
29
|
+
var asteriskPairs = (text.match(/\*\*/g) || []).length;
|
|
30
|
+
if (asteriskPairs % 2 === 1) {
|
|
31
|
+
return "".concat(text, "**");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return text;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// Completes incomplete italic formatting with double underscores (__)
|
|
38
|
+
var handleIncompleteDoubleUnderscoreItalic = function handleIncompleteDoubleUnderscoreItalic(text) {
|
|
39
|
+
var italicMatch = text.match(italicPattern);
|
|
40
|
+
if (italicMatch) {
|
|
41
|
+
var underscorePairs = (text.match(/__/g) || []).length;
|
|
42
|
+
if (underscorePairs % 2 === 1) {
|
|
43
|
+
return "".concat(text, "__");
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return text;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Counts single asterisks that are not part of double asterisks and not escaped
|
|
50
|
+
var countSingleAsterisks = function countSingleAsterisks(text) {
|
|
51
|
+
return text.split('').reduce(function (acc, char, index) {
|
|
52
|
+
if (char === '*') {
|
|
53
|
+
var prevChar = text[index - 1];
|
|
54
|
+
var nextChar = text[index + 1];
|
|
55
|
+
// Skip if escaped with backslash
|
|
56
|
+
if (prevChar === '\\') {
|
|
57
|
+
return acc;
|
|
58
|
+
}
|
|
59
|
+
if (prevChar !== '*' && nextChar !== '*') {
|
|
60
|
+
return acc + 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
}, 0);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Completes incomplete italic formatting with single asterisks (*)
|
|
68
|
+
var handleIncompleteSingleAsteriskItalic = function handleIncompleteSingleAsteriskItalic(text) {
|
|
69
|
+
var singleAsteriskMatch = text.match(singleAsteriskPattern);
|
|
70
|
+
if (singleAsteriskMatch) {
|
|
71
|
+
var singleAsterisks = countSingleAsterisks(text);
|
|
72
|
+
if (singleAsterisks % 2 === 1) {
|
|
73
|
+
return "".concat(text, "*");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return text;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Counts single underscores that are not part of double underscores and not escaped
|
|
80
|
+
var countSingleUnderscores = function countSingleUnderscores(text) {
|
|
81
|
+
return text.split('').reduce(function (acc, char, index) {
|
|
82
|
+
if (char === '_') {
|
|
83
|
+
var prevChar = text[index - 1];
|
|
84
|
+
var nextChar = text[index + 1];
|
|
85
|
+
// Skip if escaped with backslash
|
|
86
|
+
if (prevChar === '\\') {
|
|
87
|
+
return acc;
|
|
88
|
+
}
|
|
89
|
+
if (prevChar !== '_' && nextChar !== '_') {
|
|
90
|
+
return acc + 1;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return acc;
|
|
94
|
+
}, 0);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// Completes incomplete italic formatting with single underscores (_)
|
|
98
|
+
var handleIncompleteSingleUnderscoreItalic = function handleIncompleteSingleUnderscoreItalic(text) {
|
|
99
|
+
var singleUnderscoreMatch = text.match(singleUnderscorePattern);
|
|
100
|
+
if (singleUnderscoreMatch) {
|
|
101
|
+
var singleUnderscores = countSingleUnderscores(text);
|
|
102
|
+
if (singleUnderscores % 2 === 1) {
|
|
103
|
+
return "".concat(text, "_");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return text;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// Checks if a backtick at position i is part of a triple backtick sequence
|
|
110
|
+
var isPartOfTripleBacktick = function isPartOfTripleBacktick(text, i) {
|
|
111
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
112
|
+
var isTripleStart = text.substring(i, i + 3) === '```';
|
|
113
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
114
|
+
var isTripleMiddle = i > 0 && text.substring(i - 1, i + 2) === '```';
|
|
115
|
+
// eslint-disable-next-line unicorn/prefer-string-slice
|
|
116
|
+
var isTripleEnd = i > 1 && text.substring(i - 2, i + 1) === '```';
|
|
117
|
+
return isTripleStart || isTripleMiddle || isTripleEnd;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// Counts single backticks that are not part of triple backticks
|
|
121
|
+
var countSingleBackticks = function countSingleBackticks(text) {
|
|
122
|
+
var count = 0;
|
|
123
|
+
for (var i = 0; i < text.length; i++) {
|
|
124
|
+
if (text[i] === '`' && !isPartOfTripleBacktick(text, i)) {
|
|
125
|
+
count++;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return count;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// Completes incomplete inline code formatting (`)
|
|
132
|
+
// Avoids completing if inside an incomplete code block
|
|
133
|
+
var handleIncompleteInlineCode = function handleIncompleteInlineCode(text) {
|
|
134
|
+
// Check if we have inline triple backticks (starts with ``` and should end with ```)
|
|
135
|
+
// This pattern should ONLY match truly inline code (no newlines)
|
|
136
|
+
// Examples: ```code``` or ```python code```
|
|
137
|
+
var inlineTripleBacktickMatch = text.match(/^```[^\n`]*```?$/);
|
|
138
|
+
if (inlineTripleBacktickMatch && !text.includes('\n')) {
|
|
139
|
+
// Check if it ends with exactly 2 backticks (incomplete)
|
|
140
|
+
if (text.endsWith('``') && !text.endsWith('```')) {
|
|
141
|
+
return "".concat(text) + '`';
|
|
142
|
+
}
|
|
143
|
+
// Already complete inline triple backticks
|
|
144
|
+
return text;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Check if we're inside a multi-line code block (complete or incomplete)
|
|
148
|
+
var allTripleBackticks = (text.match(/```/g) || []).length;
|
|
149
|
+
var insideIncompleteCodeBlock = allTripleBackticks % 2 === 1;
|
|
150
|
+
|
|
151
|
+
// Special case: if text ends with ```\n (triple backticks followed by newline)
|
|
152
|
+
// This is actually a complete code block, not incomplete
|
|
153
|
+
if ((text.endsWith('```\n') || text.endsWith('```')) &&
|
|
154
|
+
// Count all triple backticks - if even, it's complete
|
|
155
|
+
allTripleBackticks % 2 === 0) {
|
|
156
|
+
return text;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Don't modify text if we have complete multi-line code blocks (even pairs of ```)
|
|
160
|
+
if (allTripleBackticks > 0 && allTripleBackticks % 2 === 0 && text.includes('\n')) {
|
|
161
|
+
// We have complete multi-line code blocks, don't add any backticks
|
|
162
|
+
return text;
|
|
163
|
+
}
|
|
164
|
+
var inlineCodeMatch = text.match(inlineCodePattern);
|
|
165
|
+
if (inlineCodeMatch && !insideIncompleteCodeBlock) {
|
|
166
|
+
var singleBacktickCount = countSingleBackticks(text);
|
|
167
|
+
if (singleBacktickCount % 2 === 1) {
|
|
168
|
+
return "".concat(text) + '`';
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return text;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// Completes incomplete strikethrough formatting (~~)
|
|
175
|
+
var handleIncompleteStrikethrough = function handleIncompleteStrikethrough(text) {
|
|
176
|
+
var strikethroughMatch = text.match(strikethroughPattern);
|
|
177
|
+
if (strikethroughMatch) {
|
|
178
|
+
var tildePairs = (text.match(/~~/g) || []).length;
|
|
179
|
+
if (tildePairs % 2 === 1) {
|
|
180
|
+
return "".concat(text, "~~");
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return text;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
// Counts single dollar signs that are not part of double dollar signs and not escaped
|
|
187
|
+
var countSingleDollarSigns = function countSingleDollarSigns(text) {
|
|
188
|
+
return text.split('').reduce(function (acc, char, index) {
|
|
189
|
+
if (char === '$') {
|
|
190
|
+
var prevChar = text[index - 1];
|
|
191
|
+
var nextChar = text[index + 1];
|
|
192
|
+
// Skip if escaped with backslash
|
|
193
|
+
if (prevChar === '\\') {
|
|
194
|
+
return acc;
|
|
195
|
+
}
|
|
196
|
+
if (prevChar !== '$' && nextChar !== '$') {
|
|
197
|
+
return acc + 1;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return acc;
|
|
201
|
+
}, 0);
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
// Completes incomplete block KaTeX formatting ($$)
|
|
205
|
+
var handleIncompleteBlockKatex = function handleIncompleteBlockKatex(text) {
|
|
206
|
+
var blockKatexMatch = text.match(blockKatexPattern);
|
|
207
|
+
if (blockKatexMatch) {
|
|
208
|
+
var dollarPairs = (text.match(/\$\$/g) || []).length;
|
|
209
|
+
if (dollarPairs % 2 === 1) {
|
|
210
|
+
return "".concat(text, "$$");
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return text;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// Completes incomplete inline KaTeX formatting ($)
|
|
217
|
+
var handleIncompleteInlineKatex = function handleIncompleteInlineKatex(text) {
|
|
218
|
+
var inlineKatexMatch = text.match(inlineKatexPattern);
|
|
219
|
+
if (inlineKatexMatch) {
|
|
220
|
+
var singleDollars = countSingleDollarSigns(text);
|
|
221
|
+
if (singleDollars % 2 === 1) {
|
|
222
|
+
return "".concat(text, "$");
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return text;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// Counts triple asterisks that are not part of quadruple or more asterisks
|
|
229
|
+
var countTripleAsterisks = function countTripleAsterisks(text) {
|
|
230
|
+
var count = 0;
|
|
231
|
+
var matches = text.match(/\*+/g) || [];
|
|
232
|
+
var _iterator = _createForOfIteratorHelper(matches),
|
|
233
|
+
_step;
|
|
234
|
+
try {
|
|
235
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
236
|
+
var match = _step.value;
|
|
237
|
+
// Count how many complete triple asterisks are in this sequence
|
|
238
|
+
var asteriskCount = match.length;
|
|
239
|
+
if (asteriskCount >= 3) {
|
|
240
|
+
// Each group of exactly 3 asterisks counts as one triple asterisk marker
|
|
241
|
+
count += Math.floor(asteriskCount / 3);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
} catch (err) {
|
|
245
|
+
_iterator.e(err);
|
|
246
|
+
} finally {
|
|
247
|
+
_iterator.f();
|
|
248
|
+
}
|
|
249
|
+
return count;
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
// Completes incomplete bold-italic formatting (***)
|
|
253
|
+
var handleIncompleteBoldItalic = function handleIncompleteBoldItalic(text) {
|
|
254
|
+
// Don't process if text is only asterisks and has 4 or more consecutive asterisks
|
|
255
|
+
// This prevents cases like **** from being treated as incomplete ***
|
|
256
|
+
if (/^\*{4,}$/.test(text)) {
|
|
257
|
+
return text;
|
|
258
|
+
}
|
|
259
|
+
var boldItalicMatch = text.match(boldItalicPattern);
|
|
260
|
+
if (boldItalicMatch) {
|
|
261
|
+
var tripleAsteriskCount = countTripleAsterisks(text);
|
|
262
|
+
if (tripleAsteriskCount % 2 === 1) {
|
|
263
|
+
return "".concat(text, "***");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return text;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
// Parses markdown text and removes incomplete tokens to prevent partial rendering
|
|
270
|
+
export var parseIncompleteMarkdown = function parseIncompleteMarkdown(text) {
|
|
271
|
+
if (!text || typeof text !== 'string') {
|
|
272
|
+
return text;
|
|
273
|
+
}
|
|
274
|
+
var result = text;
|
|
275
|
+
|
|
276
|
+
// Handle incomplete links and images first (removes content)
|
|
277
|
+
result = handleIncompleteLinksAndImages(result);
|
|
278
|
+
|
|
279
|
+
// Handle various formatting completions
|
|
280
|
+
// Handle triple asterisks first (most specific)
|
|
281
|
+
result = handleIncompleteBoldItalic(result);
|
|
282
|
+
result = handleIncompleteBold(result);
|
|
283
|
+
result = handleIncompleteDoubleUnderscoreItalic(result);
|
|
284
|
+
result = handleIncompleteSingleAsteriskItalic(result);
|
|
285
|
+
result = handleIncompleteSingleUnderscoreItalic(result);
|
|
286
|
+
result = handleIncompleteInlineCode(result);
|
|
287
|
+
result = handleIncompleteStrikethrough(result);
|
|
288
|
+
|
|
289
|
+
// Handle KaTeX formatting (block first, then inline)
|
|
290
|
+
result = handleIncompleteBlockKatex(result);
|
|
291
|
+
result = handleIncompleteInlineKatex(result);
|
|
292
|
+
return result;
|
|
293
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
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
|
-
var _excluded = ["ref", "children", "className", "fontSize", "headerMultiple", "marginMultiple", "lineHeight"];
|
|
4
|
+
var _excluded = ["ref", "children", "className", "fontSize", "headerMultiple", "marginMultiple", "lineHeight", "style"];
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
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; }
|
|
@@ -16,23 +16,29 @@ var Typography = /*#__PURE__*/memo(function (_ref) {
|
|
|
16
16
|
var ref = _ref.ref,
|
|
17
17
|
children = _ref.children,
|
|
18
18
|
className = _ref.className,
|
|
19
|
-
fontSize = _ref.fontSize,
|
|
20
|
-
|
|
19
|
+
_ref$fontSize = _ref.fontSize,
|
|
20
|
+
fontSize = _ref$fontSize === void 0 ? 16 : _ref$fontSize,
|
|
21
|
+
_ref$headerMultiple = _ref.headerMultiple,
|
|
22
|
+
headerMultiple = _ref$headerMultiple === void 0 ? 1 : _ref$headerMultiple,
|
|
21
23
|
_ref$marginMultiple = _ref.marginMultiple,
|
|
22
24
|
marginMultiple = _ref$marginMultiple === void 0 ? 2 : _ref$marginMultiple,
|
|
23
|
-
lineHeight = _ref.lineHeight,
|
|
25
|
+
_ref$lineHeight = _ref.lineHeight,
|
|
26
|
+
lineHeight = _ref$lineHeight === void 0 ? 1.8 : _ref$lineHeight,
|
|
27
|
+
style = _ref.style,
|
|
24
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
25
|
-
var _useStyles = useStyles(
|
|
26
|
-
fontSize: fontSize,
|
|
27
|
-
headerMultiple: headerMultiple,
|
|
28
|
-
lineHeight: lineHeight,
|
|
29
|
-
marginMultiple: marginMultiple
|
|
30
|
-
}),
|
|
29
|
+
var _useStyles = useStyles(),
|
|
31
30
|
cx = _useStyles.cx,
|
|
32
31
|
styles = _useStyles.styles;
|
|
33
32
|
return /*#__PURE__*/_jsx("article", _objectSpread(_objectSpread({
|
|
34
33
|
className: cx(styles.root, styles.variant, className),
|
|
35
|
-
ref: ref
|
|
34
|
+
ref: ref,
|
|
35
|
+
style: _objectSpread({
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
'--lobe-markdown-font-size': "".concat(fontSize, "px"),
|
|
38
|
+
'--lobe-markdown-header-multiple': headerMultiple,
|
|
39
|
+
'--lobe-markdown-line-height': lineHeight,
|
|
40
|
+
'--lobe-markdown-margin-multiple': marginMultiple
|
|
41
|
+
}, style)
|
|
36
42
|
}, rest), {}, {
|
|
37
43
|
children: children
|
|
38
44
|
}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { type HighlighterProps } from "../../Highlighter";
|
|
3
3
|
import { type MermaidProps } from "../../Mermaid";
|
|
4
4
|
export declare const useCode: (raw: any) => {
|
|
@@ -14,5 +14,5 @@ interface CodeBlockProps {
|
|
|
14
14
|
highlight?: HighlighterProps;
|
|
15
15
|
mermaid?: MermaidProps;
|
|
16
16
|
}
|
|
17
|
-
export declare const CodeBlock:
|
|
17
|
+
export declare const CodeBlock: import("react").NamedExoticComponent<CodeBlockProps>;
|
|
18
18
|
export {};
|
|
@@ -7,6 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
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); }
|
|
8
8
|
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; }
|
|
9
9
|
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; }
|
|
10
|
+
import { memo } from 'react';
|
|
10
11
|
import { FALLBACK_LANG } from "../../Highlighter/const";
|
|
11
12
|
import Pre, { PreMermaid, PreSingleLine } from "../../mdx/mdxComponents/Pre";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -30,7 +31,7 @@ export var useCode = function useCode(raw) {
|
|
|
30
31
|
lang: lang
|
|
31
32
|
};
|
|
32
33
|
};
|
|
33
|
-
export var CodeBlock = function
|
|
34
|
+
export var CodeBlock = /*#__PURE__*/memo(function (_ref) {
|
|
34
35
|
var fullFeatured = _ref.fullFeatured,
|
|
35
36
|
enableMermaid = _ref.enableMermaid,
|
|
36
37
|
highlight = _ref.highlight,
|
|
@@ -56,4 +57,6 @@ export var CodeBlock = function CodeBlock(_ref) {
|
|
|
56
57
|
}, highlight), rest), {}, {
|
|
57
58
|
children: code.content
|
|
58
59
|
}));
|
|
59
|
-
}
|
|
60
|
+
}, function (prevProps, nextProps) {
|
|
61
|
+
return prevProps.children === nextProps.children;
|
|
62
|
+
});
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
export declare const useStyles: (props?: {
|
|
2
|
-
fontSize?: number | undefined;
|
|
3
|
-
headerMultiple?: number | undefined;
|
|
4
|
-
lineHeight?: number | undefined;
|
|
5
|
-
marginMultiple?: number | undefined;
|
|
6
|
-
} | undefined) => import("antd-style").ReturnStyles<{
|
|
1
|
+
export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
|
|
7
2
|
root: import("antd-style").SerializedStyles;
|
|
8
3
|
variant: string;
|
|
9
4
|
}>;
|
|
@@ -2,36 +2,28 @@ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _temp
|
|
|
2
2
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
var IGNORE_CLASSNAME = '.ignore-markdown-style';
|
|
5
|
-
export var useStyles = createStyles(function (_ref
|
|
5
|
+
export var useStyles = createStyles(function (_ref) {
|
|
6
6
|
var cx = _ref.cx,
|
|
7
7
|
token = _ref.token,
|
|
8
8
|
css = _ref.css;
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var list = css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n li:not(", " li) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.33em);\n\n p {\n display: inline;\n }\n }\n\n ul:not(", " ul),\n ol:not(", " ol) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n margin-inline-start: 1em;\n padding-inline-start: 0;\n list-style-position: outside;\n\n > ul,\n > ol {\n margin-block: 0;\n }\n\n > li {\n margin-inline-start: 1em;\n }\n }\n\n ol:not(", " ol) {\n list-style: auto;\n }\n\n ul:not(", " ul) {\n list-style-type: none;\n\n > li {\n &::before {\n content: '-';\n display: inline-block;\n margin-inline: -1em 0.5em;\n opacity: 0.5;\n }\n }\n }\n "])), IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME);
|
|
28
|
-
var p = css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n p:not(", " kbd) {\n margin-block: 4px;\n line-height: var(--lobe-markdown-line-height);\n letter-spacing: 0.02em;\n\n &:not(:first-child) {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n\n &:not(:last-child) {\n margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n }\n "])), IGNORE_CLASSNAME);
|
|
29
|
-
var pre = css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n pre {\n font-size: calc(var(--lobe-markdown-font-size) * 0.85);\n }\n "])));
|
|
30
|
-
var strong = css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n strong:not(", " strong) {\n font-weight: 600;\n }\n "])), IGNORE_CLASSNAME);
|
|
31
|
-
var svg = css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n svg:not(", " svg) {\n line-height: 1;\n }\n "])), IGNORE_CLASSNAME);
|
|
32
|
-
var table = css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n table:not(", " table) {\n unicode-bidi: isolate;\n overflow: auto hidden;\n display: block;\n border-spacing: 0;\n border-collapse: collapse;\n\n box-sizing: border-box;\n width: max-content;\n max-width: 100%;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n\n text-align: start;\n text-indent: initial;\n text-wrap: pretty;\n word-break: auto-phrase;\n overflow-wrap: break-word;\n\n background: ", ";\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n\n code {\n word-break: break-word;\n }\n\n thead {\n background: ", ";\n }\n\n tr {\n box-shadow: 0 1px 0 var(--lobe-markdown-border-color);\n }\n\n th,\n td {\n min-width: 120px;\n padding-block: 0.75em;\n padding-inline: 1em;\n text-align: start;\n }\n }\n "])), IGNORE_CLASSNAME, token.colorFillQuaternary, token.colorFillQuaternary);
|
|
33
|
-
var video = css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n > video:not(", " video),\n > p:not(", " p) > video {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n }\n\n video:not(", " video) {\n max-width: 100%;\n }\n "])), IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME);
|
|
34
|
-
var gfm = css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n .markdown-alert {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-start: 1em;\n border-inline-start: solid 4px ", ";\n\n > p {\n margin-block-start: 0 !important;\n }\n }\n\n .markdown-alert > :first-child {\n margin-block-start: 0;\n }\n\n .markdown-alert > :last-child {\n margin-block-end: 0;\n }\n\n .markdown-alert-note {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-tip {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-important {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-warning {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-caution {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-title {\n display: flex;\n align-items: center;\n margin-block-end: 0.5em !important;\n font-weight: 500;\n }\n\n .markdown-alert-note .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-tip .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-important .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-warning .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-caution .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .octicon {\n overflow: visible !important;\n display: inline-block;\n margin-inline-end: 0.5em;\n vertical-align: text-bottom;\n }\n\n .task-list-item {\n &::before {\n display: none !important;\n }\n\n input[type='checkbox'] {\n margin-block: 0 0.25em;\n margin-inline: -1.6em 0.2em;\n vertical-align: middle;\n }\n\n input[type='checkbox']:dir(rtl) {\n margin: 0 -1.6em 0.25em 0.2em;\n }\n }\n\n /* Style the footnotes section. */\n\n .footnotes {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 1em);\n font-size: smaller;\n color: #8b949e;\n\n #footnote-label {\n display: none;\n }\n\n > ol {\n margin: 0 !important;\n }\n }\n\n .sr-only {\n position: absolute;\n\n overflow: hidden;\n\n width: 1px;\n height: 1px;\n padding: 0;\n border: 0;\n\n word-wrap: normal;\n\n clip: rect(0, 0, 0, 0);\n }\n\n sup:has(a[aria-describedby='footnote-label']) {\n margin-inline: 2px;\n vertical-align: super !important;\n\n [data-footnote-ref] {\n display: inline-block;\n\n width: 16px;\n height: 16px;\n border-radius: 4px;\n\n font-family: ", ";\n font-size: 10px;\n color: ", " !important;\n text-align: center;\n\n background: ", ";\n }\n }\n "])), token.colorBorder, token.colorInfo, token.colorSuccess, token.purple, token.colorWarning, token.colorError, token.colorInfo, token.colorInfo, token.colorSuccess, token.colorSuccess, token.purple, token.purple, token.colorWarning, token.colorWarning, token.colorError, token.colorError, token.fontFamilyCode, token.colorTextSecondary, token.colorFillSecondary);
|
|
9
|
+
var __root = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n width: 100%;\n max-width: 100%;\n padding-inline: 1px;\n\n font-size: var(--lobe-markdown-font-size);\n line-height: var(--lobe-markdown-line-height);\n word-break: break-word;\n\n :root {\n --lobe-markdown-font-size: 16px;\n --lobe-markdown-header-multiple: 1;\n --lobe-markdown-margin-multiple: 2;\n --lobe-markdown-line-height: 1.8;\n --lobe-markdown-border-radius: ", ";\n --lobe-markdown-border-color: ", ";\n }\n\n ", " {\n font-size: 14px;\n line-height: 1.5;\n }\n "])), token.borderRadiusLG, token.colorFillQuaternary, IGNORE_CLASSNAME);
|
|
10
|
+
var a = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n a:not(", " a) {\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n }\n "])), IGNORE_CLASSNAME, token.colorInfoText, token.colorInfoHover);
|
|
11
|
+
var blockquote = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n blockquote:not(", " blockquote) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n margin-inline: 0;\n padding-block: 0;\n padding-inline: 1em;\n border-inline-start: solid 4px ", ";\n\n color: ", ";\n }\n "])), IGNORE_CLASSNAME, token.colorBorder, token.colorTextSecondary);
|
|
12
|
+
var code = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n code:not(", " code) {\n &:not(:has(span)) {\n display: inline;\n\n margin-inline: 0.25em;\n padding-block: 0.2em;\n padding-inline: 0.4em;\n border: 1px solid var(--lobe-markdown-border-color);\n border-radius: 0.25em;\n\n font-family: ", ";\n font-size: 0.875em;\n line-height: 1;\n word-break: break-word;\n white-space: break-spaces;\n\n background: ", ";\n }\n }\n "])), IGNORE_CLASSNAME, token.fontFamilyCode, token.colorFillSecondary);
|
|
13
|
+
var del = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n del:not(", " del) {\n color: ", ";\n text-decoration: line-through;\n }\n "])), IGNORE_CLASSNAME, token.colorTextDescription);
|
|
14
|
+
var details = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n details:not(", " details) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-block: 0.75em;\n padding-inline: 1em;\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n\n background: ", ";\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n\n summary {\n cursor: pointer;\n display: flex;\n align-items: center;\n list-style: none;\n\n &::before {\n content: '';\n\n position: absolute;\n inset-inline-end: 1.25em;\n transform: rotateZ(-45deg);\n\n display: block;\n\n width: 0.4em;\n height: 0.4em;\n border-block-end: 1.5px solid ", ";\n border-inline-end: 1.5px solid ", ";\n\n font-family: ", ";\n\n transition: transform 200ms ", ";\n }\n }\n\n &[open] {\n summary {\n padding-block-end: 0.75em;\n border-block-end: 1px dashed ", ";\n\n &::before {\n transform: rotateZ(45deg);\n }\n }\n }\n }\n "])), IGNORE_CLASSNAME, token.colorFillTertiary, token.colorTextSecondary, token.colorTextSecondary, token.fontFamily, token.motionEaseOut, token.colorBorder);
|
|
15
|
+
var header = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n h1:not(", " h1),\n h2:not(", " h2),\n h3:not(", " h3),\n h4:not(", " h4),\n h5:not(", " h5),\n h6:not(", " h6) {\n margin-block: max(\n calc(var(--lobe-markdown-header-multiple) * var(--lobe-markdown-margin-multiple) * 0.4em),\n var(--lobe-markdown-font-size)\n );\n font-weight: bold;\n line-height: 1.25;\n }\n\n h1:not(", " h1) {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 1.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h2:not(", " h2) {\n font-size: calc(var(--lobe-markdown-font-size) * (1 + var(--lobe-markdown-header-multiple)));\n }\n\n h3:not(", " h3) {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.5 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h4:not(", " h4) {\n font-size: calc(\n var(--lobe-markdown-font-size) * (1 + 0.25 * var(--lobe-markdown-header-multiple))\n );\n }\n\n h5:not(", " h5),\n h6:not(", " h6) {\n font-size: calc(var(--lobe-markdown-font-size) * 1);\n }\n "])), IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME);
|
|
16
|
+
var hr = css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n hr:not(", " hr) {\n width: 100%;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 1.5em);\n border-color: ", ";\n border-style: dashed;\n border-width: 1px;\n border-block-start: none;\n border-inline-start: none;\n border-inline-end: none;\n }\n "])), IGNORE_CLASSNAME, token.colorBorder);
|
|
17
|
+
var img = css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n img:not(", " img) {\n max-width: 100%;\n }\n\n > img,\n > p > img {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n }\n "])), IGNORE_CLASSNAME);
|
|
18
|
+
var kbd = css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n kbd:not(", " kbd) {\n cursor: default;\n\n display: inline-block;\n\n min-width: 1em;\n margin-inline: 0.25em;\n padding-block: 0.2em;\n padding-inline: 0.4em;\n border: 1px solid ", ";\n border-radius: 0.25em;\n\n font-family: ", ";\n font-size: 0.875em;\n font-weight: 500;\n line-height: 1;\n text-align: center;\n\n background: ", ";\n }\n "])), IGNORE_CLASSNAME, token.colorBorderSecondary, token.fontFamily, token.colorBgLayout);
|
|
19
|
+
var list = css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n li:not(", " li) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.33em);\n\n p:first-child {\n display: inline;\n }\n }\n\n ul:not(", " ul),\n ol:not(", " ol) {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n margin-inline-start: 1em;\n padding-inline-start: 0;\n list-style-position: outside;\n\n > ul,\n > ol {\n margin-block: 0;\n }\n\n > li {\n margin-inline-start: 1em;\n }\n }\n\n ol:not(", " ol) {\n list-style: auto;\n }\n\n ul:not(", " ul) {\n list-style-type: none;\n\n > li {\n &::before {\n content: '-';\n\n position: absolute;\n\n display: inline-block;\n\n margin-inline: -1em 0.5em;\n\n opacity: 0.5;\n }\n }\n }\n "])), IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME);
|
|
20
|
+
var p = css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n p:not(", " kbd) {\n margin-block: 4px;\n line-height: var(--lobe-markdown-line-height);\n letter-spacing: 0.02em;\n\n &:not(:first-child) {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n\n &:not(:last-child) {\n margin-block-end: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n }\n }\n "])), IGNORE_CLASSNAME);
|
|
21
|
+
var pre = css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n pre {\n font-size: calc(var(--lobe-markdown-font-size) * 0.85);\n }\n "])));
|
|
22
|
+
var strong = css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n strong:not(", " strong) {\n font-weight: 600;\n }\n "])), IGNORE_CLASSNAME);
|
|
23
|
+
var svg = css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n svg:not(", " svg) {\n line-height: 1;\n }\n "])), IGNORE_CLASSNAME);
|
|
24
|
+
var table = css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n table:not(", " table) {\n unicode-bidi: isolate;\n overflow: auto hidden;\n display: block;\n border-spacing: 0;\n border-collapse: collapse;\n\n box-sizing: border-box;\n width: max-content;\n max-width: 100%;\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n\n text-align: start;\n text-indent: initial;\n text-wrap: pretty;\n word-break: auto-phrase;\n overflow-wrap: break-word;\n\n background: ", ";\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n\n code {\n word-break: break-word;\n }\n\n thead {\n background: ", ";\n }\n\n tr {\n box-shadow: 0 1px 0 var(--lobe-markdown-border-color);\n }\n\n th,\n td {\n min-width: 120px;\n padding-block: 0.75em;\n padding-inline: 1em;\n text-align: start;\n }\n }\n "])), IGNORE_CLASSNAME, token.colorFillQuaternary, token.colorFillQuaternary);
|
|
25
|
+
var video = css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n > video:not(", " video),\n > p:not(", " p) > video {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n border-radius: calc(var(--lobe-markdown-border-radius) * 1px);\n box-shadow: 0 0 0 1px var(--lobe-markdown-border-color);\n }\n\n video:not(", " video) {\n max-width: 100%;\n }\n "])), IGNORE_CLASSNAME, IGNORE_CLASSNAME, IGNORE_CLASSNAME);
|
|
26
|
+
var gfm = css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n .markdown-alert {\n margin-block: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-start: 1em;\n border-inline-start: solid 4px ", ";\n\n > p {\n margin-block-start: 0 !important;\n }\n }\n\n .markdown-alert > :first-child {\n margin-block-start: 0;\n }\n\n .markdown-alert > :last-child {\n margin-block-end: 0;\n }\n\n .markdown-alert-note {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-tip {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-important {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-warning {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-caution {\n border-inline-start-color: ", ";\n }\n\n .markdown-alert-title {\n display: flex;\n align-items: center;\n margin-block-end: 0.5em !important;\n font-weight: 500;\n }\n\n .markdown-alert-note .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-tip .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-important .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-warning .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .markdown-alert-caution .markdown-alert-title {\n color: ", ";\n fill: ", ";\n }\n\n .octicon {\n overflow: visible !important;\n display: inline-block;\n margin-inline-end: 0.5em;\n vertical-align: text-bottom;\n }\n\n .task-list-item {\n &::before {\n display: none !important;\n }\n\n input[type='checkbox'] {\n margin-block: 0 0.25em;\n margin-inline: -1.6em 0.2em;\n vertical-align: middle;\n }\n\n input[type='checkbox']:dir(rtl) {\n margin: 0 -1.6em 0.25em 0.2em;\n }\n }\n\n /* Style the footnotes section. */\n\n .footnotes {\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 1em);\n font-size: smaller;\n color: #8b949e;\n\n #footnote-label {\n display: none;\n }\n\n > ol {\n margin: 0 !important;\n }\n }\n\n .sr-only {\n position: absolute;\n\n overflow: hidden;\n\n width: 1px;\n height: 1px;\n padding: 0;\n border: 0;\n\n word-wrap: normal;\n\n clip: rect(0, 0, 0, 0);\n }\n\n sup {\n line-height: var(--lobe-markdown-line-height);\n }\n\n sup:has(a[aria-describedby='footnote-label']) {\n margin-inline: 2px;\n vertical-align: super !important;\n\n [data-footnote-ref] {\n display: inline-block;\n\n width: 16px;\n height: 16px;\n border-radius: 4px;\n\n font-family: ", ";\n font-size: 10px;\n color: ", " !important;\n text-align: center;\n\n background: ", ";\n }\n }\n "])), token.colorBorder, token.colorInfo, token.colorSuccess, token.purple, token.colorWarning, token.colorError, token.colorInfo, token.colorInfo, token.colorSuccess, token.colorSuccess, token.purple, token.purple, token.colorWarning, token.colorWarning, token.colorError, token.colorError, token.fontFamilyCode, token.colorTextSecondary, token.colorFillSecondary);
|
|
35
27
|
return {
|
|
36
28
|
root: __root,
|
|
37
29
|
variant: cx(a, blockquote, code, del, details, header, hr, img, kbd, list, p, pre, strong, svg, table, video, gfm)
|
|
@@ -99,6 +99,8 @@ var SyntaxMermaid = /*#__PURE__*/memo(function (_ref) {
|
|
|
99
99
|
},
|
|
100
100
|
variant: 'borderless'
|
|
101
101
|
});
|
|
102
|
+
}, function (prevProps, nextProps) {
|
|
103
|
+
return prevProps.children === nextProps.children;
|
|
102
104
|
});
|
|
103
105
|
SyntaxMermaid.displayName = 'SyntaxMermaid';
|
|
104
106
|
export default SyntaxMermaid;
|
|
@@ -111,66 +111,6 @@ function applyEmphasisFixes(text) {
|
|
|
111
111
|
return match;
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
// Step 3: Add space before opening emphasis markers when preceded by non-whitespace and first char is symbol/punctuation
|
|
116
|
-
var beforeEmphasisPatterns = [
|
|
117
|
-
// ** (bold)
|
|
118
|
-
{
|
|
119
|
-
markerChar: '*',
|
|
120
|
-
pattern: /(\S)(\*\*)([^\n*]*?)(\*\*)/g
|
|
121
|
-
},
|
|
122
|
-
// __ (bold)
|
|
123
|
-
{
|
|
124
|
-
markerChar: '_',
|
|
125
|
-
pattern: /(\S)(__)([^\n_]*?)(__)/g
|
|
126
|
-
},
|
|
127
|
-
// * (italic) - need to avoid matching **
|
|
128
|
-
{
|
|
129
|
-
markerChar: '*',
|
|
130
|
-
pattern: /(\S)(\*(?!\*))([^\n*]*?)(\*(?!\*))/g
|
|
131
|
-
},
|
|
132
|
-
// _ (italic) - need to avoid matching __
|
|
133
|
-
{
|
|
134
|
-
markerChar: '_',
|
|
135
|
-
pattern: /(\S)(_(?!_))([^\n_]*?)(_(?!_))/g
|
|
136
|
-
},
|
|
137
|
-
// ~~ (strikethrough)
|
|
138
|
-
{
|
|
139
|
-
markerChar: '~',
|
|
140
|
-
pattern: /(\S)(~~)([^\n~]*?)(~~)/g
|
|
141
|
-
}];
|
|
142
|
-
|
|
143
|
-
// Apply space before opening markers for each emphasis type
|
|
144
|
-
for (var _i2 = 0, _beforeEmphasisPatter = beforeEmphasisPatterns; _i2 < _beforeEmphasisPatter.length; _i2++) {
|
|
145
|
-
var _pattern = _beforeEmphasisPatter[_i2].pattern;
|
|
146
|
-
result = result.replaceAll(_pattern, function (match, prevChar, start, content, end) {
|
|
147
|
-
// Check if the content starts with a symbol/punctuation (like :, :, ", (, etc.)
|
|
148
|
-
var firstChar = content.charAt(0);
|
|
149
|
-
var isSymbolOrPunctuation = /[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~、。《》【】!(),:;?{|}-]/.test(firstChar);
|
|
150
|
-
|
|
151
|
-
// If previous character is not whitespace and content starts with symbol/punctuation, add space before
|
|
152
|
-
if (prevChar && !/\s/.test(prevChar) && isSymbolOrPunctuation) {
|
|
153
|
-
return prevChar + ' ' + start + content + end;
|
|
154
|
-
}
|
|
155
|
-
return match;
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Step 4: Re-run step 2 after step 3 to handle cases where both before and after spaces are needed
|
|
160
|
-
for (var _i3 = 0, _emphasisPatterns2 = emphasisPatterns; _i3 < _emphasisPatterns2.length; _i3++) {
|
|
161
|
-
var _pattern2 = _emphasisPatterns2[_i3].pattern;
|
|
162
|
-
result = result.replaceAll(_pattern2, function (match, start, content, end, nextChar) {
|
|
163
|
-
// Check if the content ends with a symbol/punctuation (like :, :, etc.)
|
|
164
|
-
var lastChar = content.slice(-1);
|
|
165
|
-
var isSymbolOrPunctuation = /[!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~、。《》【】!(),:;?{|}-]/.test(lastChar);
|
|
166
|
-
|
|
167
|
-
// If content ends with symbol/punctuation and next character is not whitespace, add space
|
|
168
|
-
if (isSymbolOrPunctuation && nextChar && !/\s/.test(nextChar)) {
|
|
169
|
-
return start + content + end + ' ' + nextChar;
|
|
170
|
-
}
|
|
171
|
-
return match;
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
114
|
return result;
|
|
175
115
|
}
|
|
176
116
|
function splitMarkdownWithAllCodeTypes(text) {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
var _excluded = ["children"];
|
|
3
4
|
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
4
7
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
8
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
9
|
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; }
|
|
7
10
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
11
|
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); }
|
|
9
|
-
import { useMemo } from 'react';
|
|
12
|
+
import { useCallback, useMemo } from 'react';
|
|
10
13
|
import { CodeBlock } from "../../Markdown/components/CodeBlock";
|
|
11
14
|
import { useMarkdownContext } from "../../Markdown/components/MarkdownProvider";
|
|
12
15
|
import Image from "../../mdx/mdxComponents/Image";
|
|
@@ -24,30 +27,34 @@ export var useMarkdownComponents = function useMarkdownComponents() {
|
|
|
24
27
|
showFootnotes = _useMarkdownContext.showFootnotes,
|
|
25
28
|
enableMermaid = _useMarkdownContext.enableMermaid,
|
|
26
29
|
fullFeaturedCodeBlock = _useMarkdownContext.fullFeaturedCodeBlock;
|
|
27
|
-
var memoA =
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.a));
|
|
32
|
-
};
|
|
30
|
+
var memoA = useCallback(function (props) {
|
|
31
|
+
return /*#__PURE__*/_jsx(Link, _objectSpread(_objectSpread({
|
|
32
|
+
citations: citations
|
|
33
|
+
}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.a));
|
|
33
34
|
}, [citations, componentProps === null || componentProps === void 0 ? void 0 : componentProps.a]);
|
|
34
|
-
var memoImg =
|
|
35
|
-
return
|
|
36
|
-
return /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.img));
|
|
37
|
-
};
|
|
35
|
+
var memoImg = useCallback(function (props) {
|
|
36
|
+
return /*#__PURE__*/_jsx(Image, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.img));
|
|
38
37
|
}, [componentProps === null || componentProps === void 0 ? void 0 : componentProps.img]);
|
|
39
|
-
var memoVideo =
|
|
40
|
-
return
|
|
41
|
-
return /*#__PURE__*/_jsx(Video, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.video));
|
|
42
|
-
};
|
|
38
|
+
var memoVideo = useCallback(function (props) {
|
|
39
|
+
return /*#__PURE__*/_jsx(Video, _objectSpread(_objectSpread({}, props), componentProps === null || componentProps === void 0 ? void 0 : componentProps.video));
|
|
43
40
|
}, [componentProps === null || componentProps === void 0 ? void 0 : componentProps.video]);
|
|
44
|
-
var memoSection =
|
|
45
|
-
return
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}, props));
|
|
49
|
-
};
|
|
41
|
+
var memoSection = useCallback(function (props) {
|
|
42
|
+
return /*#__PURE__*/_jsx(Section, _objectSpread({
|
|
43
|
+
showFootnotes: showFootnotes
|
|
44
|
+
}, props));
|
|
50
45
|
}, [showFootnotes]);
|
|
46
|
+
var memoBr = useCallback(function () {
|
|
47
|
+
return /*#__PURE__*/_jsx("br", {});
|
|
48
|
+
}, []);
|
|
49
|
+
var memeP = useCallback(function (_ref) {
|
|
50
|
+
var _children$props;
|
|
51
|
+
var children = _ref.children,
|
|
52
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
53
|
+
var hasImage = _typeof(children) === 'object' && (children === null || children === void 0 || (_children$props = children.props) === null || _children$props === void 0 || (_children$props = _children$props.node) === null || _children$props === void 0 ? void 0 : _children$props.tagName) === 'img';
|
|
54
|
+
return hasImage ? children : /*#__PURE__*/_jsx("p", _objectSpread(_objectSpread({}, rest), {}, {
|
|
55
|
+
children: children
|
|
56
|
+
}));
|
|
57
|
+
}, []);
|
|
51
58
|
|
|
52
59
|
// Stable references for theme objects to prevent unnecessary re-renders
|
|
53
60
|
var highlightTheme = useMemo(function () {
|
|
@@ -71,30 +78,24 @@ export var useMarkdownComponents = function useMarkdownComponents() {
|
|
|
71
78
|
}) : undefined
|
|
72
79
|
};
|
|
73
80
|
}, [highlightTheme, mermaidTheme]);
|
|
74
|
-
var memoPre =
|
|
75
|
-
return
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, stableComponentProps), componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre), props));
|
|
81
|
-
};
|
|
81
|
+
var memoPre = useCallback(function (props) {
|
|
82
|
+
return /*#__PURE__*/_jsx(CodeBlock, _objectSpread(_objectSpread(_objectSpread({
|
|
83
|
+
animated: animated,
|
|
84
|
+
enableMermaid: enableMermaid,
|
|
85
|
+
fullFeatured: fullFeaturedCodeBlock
|
|
86
|
+
}, stableComponentProps), componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre), props));
|
|
82
87
|
}, [animated, enableMermaid, fullFeaturedCodeBlock, stableComponentProps, componentProps === null || componentProps === void 0 ? void 0 : componentProps.pre]);
|
|
83
|
-
var memoBr = useMemo(function () {
|
|
84
|
-
return function () {
|
|
85
|
-
return /*#__PURE__*/_jsx("br", {});
|
|
86
|
-
};
|
|
87
|
-
}, []);
|
|
88
88
|
var memoComponents = useMemo(function () {
|
|
89
89
|
return {
|
|
90
90
|
a: memoA,
|
|
91
91
|
br: memoBr,
|
|
92
92
|
img: memoImg,
|
|
93
|
+
p: memeP,
|
|
93
94
|
pre: memoPre,
|
|
94
95
|
section: memoSection,
|
|
95
96
|
video: memoVideo
|
|
96
97
|
};
|
|
97
|
-
}, [memoA, memoBr, memoImg, memoVideo, memoPre, memoSection]);
|
|
98
|
+
}, [memoA, memoBr, memoImg, memoVideo, memoPre, memoSection, memeP]);
|
|
98
99
|
return useMemo(function () {
|
|
99
100
|
return _objectSpread(_objectSpread({}, memoComponents), components);
|
|
100
101
|
}, [memoComponents, components]);
|
|
@@ -26,15 +26,5 @@ interface PreprocessOptions {
|
|
|
26
26
|
enableCustomFootnotes?: boolean;
|
|
27
27
|
enableLatex?: boolean;
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Preprocesses markdown content by applying various transformations:
|
|
31
|
-
* - LaTeX preprocessing
|
|
32
|
-
* - Citation transformations
|
|
33
|
-
* - Bold syntax fixing
|
|
34
|
-
*
|
|
35
|
-
* @param str The raw markdown content
|
|
36
|
-
* @param options Preprocessing options
|
|
37
|
-
* @returns The processed markdown content
|
|
38
|
-
*/
|
|
39
29
|
export declare const preprocessContent: (str: string, { enableCustomFootnotes, enableLatex, citationsLength }?: PreprocessOptions) => string;
|
|
40
30
|
export {};
|
|
@@ -118,16 +118,6 @@ export var transformCitations = function transformCitations(rawContent) {
|
|
|
118
118
|
* Preprocessing options for markdown content
|
|
119
119
|
*/
|
|
120
120
|
|
|
121
|
-
/**
|
|
122
|
-
* Preprocesses markdown content by applying various transformations:
|
|
123
|
-
* - LaTeX preprocessing
|
|
124
|
-
* - Citation transformations
|
|
125
|
-
* - Bold syntax fixing
|
|
126
|
-
*
|
|
127
|
-
* @param str The raw markdown content
|
|
128
|
-
* @param options Preprocessing options
|
|
129
|
-
* @returns The processed markdown content
|
|
130
|
-
*/
|
|
131
121
|
export var preprocessContent = function preprocessContent(str) {
|
|
132
122
|
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
133
123
|
enableCustomFootnotes = _ref.enableCustomFootnotes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -74,6 +74,7 @@
|
|
|
74
74
|
"leva": "^0.10.0",
|
|
75
75
|
"lodash-es": "^4.17.21",
|
|
76
76
|
"lucide-react": "^0.525.0",
|
|
77
|
+
"marked": "^16.2.0",
|
|
77
78
|
"mermaid": "^11.9.0",
|
|
78
79
|
"numeral": "^2.0.6",
|
|
79
80
|
"polished": "^4.3.1",
|