@yuntijs/ui 1.1.0-beta.2 → 1.1.0-beta.4
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/Mentions/index.js
CHANGED
|
@@ -113,10 +113,13 @@ export var Mentions = function Mentions(_ref) {
|
|
|
113
113
|
if (!isBrowser) {
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
+
if (getPopContainer) {
|
|
117
|
+
return getPopContainer();
|
|
118
|
+
}
|
|
116
119
|
if (document.fullscreenElement) {
|
|
117
120
|
return document.fullscreenElement;
|
|
118
121
|
}
|
|
119
|
-
}, []);
|
|
122
|
+
}, [getPopContainer]);
|
|
120
123
|
if (!isBrowser) {
|
|
121
124
|
return /*#__PURE__*/_jsxs("div", {
|
|
122
125
|
className: cx(styles.wrapper, classNames === null || classNames === void 0 ? void 0 : classNames.wrapper),
|
|
@@ -34,7 +34,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
return {
|
|
37
|
-
base: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n box-sizing: content-box;\n min-height: 100px;\n\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n &:hover {\n border-color: ", ";\n ", "\n }\n\n &.ve-focused {\n ", "\n ", "\n }\n\n &.ve-outline {\n border: 1px solid var(--color-field-border, rgba(31, 56, 88, 0.05)) !important;\n }\n\n & > .react-monaco-editor-container {\n width: 100%;\n height: 100%;\n min-height: 100px;\n background: transparent;\n\n ", "\n\n .monaco-editor,\n .monaco-editor-background,\n .monaco-editor .inputarea.ime-input,\n .monaco-editor .margin {\n ", "\n }\n\n & > .monaco-editor {\n border-radius: ", "px;\n outline: none;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n .monaco-scrollable-element {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n .monaco-diff-editor {\n border-radius: ", "px;\n & > .original > .monaco-editor {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n }\n .diffViewport {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n }\n\n .syntaxTips {\n position: absolute;\n bottom: 0;\n left: 0;\n\n box-sizing: border-box;\n width: 100%;\n max-height: 0;\n margin: 0;\n padding: 10px 30px;\n\n color: ", ";\n\n background: ", ";\n\n transition: 0.2s ease max-height;\n }\n\n .syntaxTips:hover {\n overflow: auto;\n max-height: 50%;\n }\n\n .syntaxTips .infoIcon {\n position: absolute;\n top: 2px;\n right: 5px;\n transform: rotateY(180deg);\n\n width: 20px;\n height: 16px;\n }\n "])), getBgColor(), variant === 'outlined' ? token.colorBorder : 'transparent', token.borderRadius, variant === 'outlined' ? token.colorPrimaryHover : 'transparent', variant === 'filled' && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillSecondary), variant === 'filled' && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorBgBase), variant !== 'borderless' && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-color: ", ";\n "])), token.colorPrimaryActive), isFullScreen && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 9998;\n inset: 0;\n\n width: auto !important;\n height: auto !important;\n "]))), !isFullScreen && css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background-color: transparent;\n "]))), token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius - 1, token.borderRadius - 1, token.colorErrorText, token.colorErrorBg),
|
|
37
|
+
base: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n box-sizing: content-box;\n min-height: 100px;\n\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n &:hover {\n border-color: ", ";\n ", "\n }\n\n &.ve-focused {\n ", "\n ", "\n }\n\n &.ve-outline {\n border: 1px solid var(--color-field-border, rgba(31, 56, 88, 0.05)) !important;\n }\n\n & > .react-monaco-editor-container {\n width: 100%;\n height: 100%;\n min-height: 100px;\n background: transparent;\n\n ", "\n\n .monaco-editor,\n .monaco-editor-background,\n .monaco-editor .inputarea.ime-input,\n .monaco-editor .margin {\n ", "\n }\n\n & > .monaco-editor {\n border-radius: ", "px;\n outline: none;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n .monaco-scrollable-element {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n }\n }\n .monaco-diff-editor {\n border-radius: ", "px;\n & > .gutter {\n outline: none;\n }\n & > .original > .monaco-editor {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n outline: none;\n .overflow-guard,\n .margin {\n border-top-left-radius: ", "px;\n border-bottom-left-radius: ", "px;\n }\n }\n & > .modified > .monaco-editor {\n outline: none;\n }\n .diffViewport {\n border-top-right-radius: ", "px;\n border-bottom-right-radius: ", "px;\n outline: none;\n }\n }\n }\n\n .syntaxTips {\n position: absolute;\n bottom: 0;\n left: 0;\n\n box-sizing: border-box;\n width: 100%;\n max-height: 0;\n margin: 0;\n padding: 10px 30px;\n\n color: ", ";\n\n background: ", ";\n\n transition: 0.2s ease max-height;\n }\n\n .syntaxTips:hover {\n overflow: auto;\n max-height: 50%;\n }\n\n .syntaxTips .infoIcon {\n position: absolute;\n top: 2px;\n right: 5px;\n transform: rotateY(180deg);\n\n width: 20px;\n height: 16px;\n }\n "])), getBgColor(), variant === 'outlined' ? token.colorBorder : 'transparent', token.borderRadius, variant === 'outlined' ? token.colorPrimaryHover : 'transparent', variant === 'filled' && css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillSecondary), variant === 'filled' && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorBgBase), variant !== 'borderless' && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n border-color: ", ";\n "])), token.colorPrimaryActive), isFullScreen && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n position: fixed;\n z-index: 9998;\n inset: 0;\n\n width: auto !important;\n height: auto !important;\n "]))), !isFullScreen && css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background-color: transparent;\n "]))), token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius, token.borderRadius - 1, token.borderRadius - 1, token.colorErrorText, token.colorErrorBg),
|
|
38
38
|
fullScreenBtn: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n &.", "-btn {\n position: absolute;\n top: 20px;\n color: ", ";\n transition: none;\n ", "\n }\n "])), prefixCls, token.colorTextSecondary, isFullScreen ? css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n z-index: 9999;\n right: ", "px;\n "])), diff ? 64 : 138) : css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n right: ", "px;\n "])), minimapEnabled || diff ? 64 : 20)),
|
|
39
39
|
loading: css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n position: absolute;\n inset: 0;\n\n display: flex;\n align-items: center;\n justify-content: center;\n\n font-size: ", "px;\n color: ", ";\n\n background-color: transparent;\n\n &::after {\n content: '';\n width: 16px;\n /* display: inline; */\n animation: ", " steps(3) 1s infinite;\n }\n "])), token.fontSizeSM, token.colorTextTertiary, dots)
|
|
40
40
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
export declare const FALLBACK_LANG = "txt";
|
|
2
|
-
export declare const useHighlight: (text: string, lang: string,
|
|
3
|
-
revalidateOnFocus: false;
|
|
4
|
-
}>;
|
|
2
|
+
export declare const useHighlight: (text: string, lang: string, enableTransformer?: boolean) => import("swr/dist/_internal").SWRResponse<string, any, any>;
|
|
5
3
|
export { languageMap } from './languageMap';
|
package/es/hooks/useHighlight.js
CHANGED
|
@@ -1,82 +1,80 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { transformerNotationDiff, transformerNotationErrorLevel, transformerNotationFocus, transformerNotationHighlight, transformerNotationWordHighlight } from '@shikijs/transformers';
|
|
4
|
-
import {
|
|
4
|
+
import { useTheme, useThemeMode } from 'antd-style';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
import { codeToHtml } from 'shiki';
|
|
5
7
|
import useSWR from 'swr';
|
|
6
|
-
import {
|
|
8
|
+
import { Md5 } from 'ts-md5';
|
|
7
9
|
import { languageMap } from "./languageMap";
|
|
8
10
|
export var FALLBACK_LANG = 'txt';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
|
|
11
|
+
|
|
12
|
+
// @Todo: use worker to improve performance
|
|
13
|
+
export var useHighlight = function useHighlight(text, lang, enableTransformer) {
|
|
14
|
+
var _useThemeMode = useThemeMode(),
|
|
15
|
+
isDarkMode = _useThemeMode.isDarkMode;
|
|
16
|
+
var language = lang.toLowerCase();
|
|
17
|
+
var matchedLanguage = useMemo(function () {
|
|
18
|
+
return languageMap.includes(language) ? language : FALLBACK_LANG;
|
|
19
|
+
}, [language]);
|
|
20
|
+
var theme = useTheme();
|
|
21
|
+
var transformers = useMemo(function () {
|
|
22
|
+
if (!enableTransformer) return;
|
|
23
|
+
return [transformerNotationDiff(), transformerNotationHighlight(), transformerNotationWordHighlight(), transformerNotationFocus(), transformerNotationErrorLevel()];
|
|
24
|
+
}, [enableTransformer]);
|
|
25
|
+
var key = useMemo(function () {
|
|
26
|
+
return Md5.hashStr(text);
|
|
27
|
+
}, [text]);
|
|
28
|
+
var shikiTheme = useMemo(function () {
|
|
29
|
+
if (language === 'md') {
|
|
30
|
+
return isDarkMode ? 'catppuccin-mocha' : 'catppuccin-latte';
|
|
31
|
+
}
|
|
32
|
+
return isDarkMode ? 'slack-dark' : 'slack-ochin';
|
|
33
|
+
}, [isDarkMode, language]);
|
|
34
|
+
return useSWR([matchedLanguage, isDarkMode ? 'd' : 'l', key].join('-'), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14
35
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
36
|
while (1) switch (_context.prev = _context.next) {
|
|
16
37
|
case 0:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
38
|
+
_context.prev = 0;
|
|
39
|
+
return _context.abrupt("return", codeToHtml(text, {
|
|
40
|
+
colorReplacements: {
|
|
41
|
+
'slack-dark': {
|
|
42
|
+
'#4ec9b0': theme.yellow,
|
|
43
|
+
'#569cd6': theme.colorError,
|
|
44
|
+
'#6a9955': theme.gray,
|
|
45
|
+
'#9cdcfe': theme.colorText,
|
|
46
|
+
'#b5cea8': theme.purple10,
|
|
47
|
+
'#c586c0': theme.colorInfo,
|
|
48
|
+
'#ce9178': theme.colorSuccess,
|
|
49
|
+
'#dcdcaa': theme.colorWarning,
|
|
50
|
+
'#e6e6e6': theme.colorText
|
|
51
|
+
},
|
|
52
|
+
'slack-ochin': {
|
|
53
|
+
'#002339': theme.colorText,
|
|
54
|
+
'#0991b6': theme.colorError,
|
|
55
|
+
'#174781': theme.purple10,
|
|
56
|
+
'#2f86d2': theme.colorText,
|
|
57
|
+
'#357b42': theme.gray,
|
|
58
|
+
'#7b30d0': theme.colorInfo,
|
|
59
|
+
'#7eb233': theme.colorWarningTextActive,
|
|
60
|
+
'#a44185': theme.colorSuccess,
|
|
61
|
+
'#dc3eb7': theme.yellow11
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
lang: matchedLanguage,
|
|
65
|
+
theme: shikiTheme,
|
|
66
|
+
transformers: transformers
|
|
67
|
+
}));
|
|
24
68
|
case 4:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_context.
|
|
29
|
-
|
|
30
|
-
langs: FALLBACK_LANGS,
|
|
31
|
-
themes: [themeConfig(true), themeConfig(false), 'catppuccin-latte', 'catppuccin-mocha']
|
|
32
|
-
});
|
|
33
|
-
case 7:
|
|
34
|
-
highlighter = _context.sent;
|
|
35
|
-
cacheHighlighter = highlighter;
|
|
36
|
-
return _context.abrupt("return", highlighter);
|
|
37
|
-
case 10:
|
|
69
|
+
_context.prev = 4;
|
|
70
|
+
_context.t0 = _context["catch"](0);
|
|
71
|
+
console.warn('shiki Highlight error:', _context.t0);
|
|
72
|
+
return _context.abrupt("return", text);
|
|
73
|
+
case 8:
|
|
38
74
|
case "end":
|
|
39
75
|
return _context.stop();
|
|
40
76
|
}
|
|
41
|
-
}, _callee);
|
|
42
|
-
}));
|
|
43
|
-
return function initHighlighter(_x) {
|
|
44
|
-
return _ref.apply(this, arguments);
|
|
45
|
-
};
|
|
46
|
-
}();
|
|
47
|
-
export var useHighlight = function useHighlight(text, lang, isDarkMode) {
|
|
48
|
-
return useSWR([lang === null || lang === void 0 ? void 0 : lang.toLowerCase(), isDarkMode ? 'dark' : 'light', text].join('-'), /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
49
|
-
var language, theme, highlighter, html;
|
|
50
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
51
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
52
|
-
case 0:
|
|
53
|
-
_context2.prev = 0;
|
|
54
|
-
language = lang.toLowerCase();
|
|
55
|
-
theme = isDarkMode ? 'dark' : 'light';
|
|
56
|
-
if (language === 'md') {
|
|
57
|
-
theme = isDarkMode ? 'catppuccin-mocha' : 'catppuccin-latte';
|
|
58
|
-
}
|
|
59
|
-
_context2.next = 6;
|
|
60
|
-
return initHighlighter(language);
|
|
61
|
-
case 6:
|
|
62
|
-
highlighter = _context2.sent;
|
|
63
|
-
html = highlighter === null || highlighter === void 0 ? void 0 : highlighter.codeToHtml(text, {
|
|
64
|
-
lang: languageMap.includes(language) ? language : FALLBACK_LANG,
|
|
65
|
-
theme: theme,
|
|
66
|
-
transformers: [transformerNotationDiff(), transformerNotationHighlight(), transformerNotationWordHighlight(), transformerNotationFocus(), transformerNotationErrorLevel()]
|
|
67
|
-
});
|
|
68
|
-
return _context2.abrupt("return", html);
|
|
69
|
-
case 11:
|
|
70
|
-
_context2.prev = 11;
|
|
71
|
-
_context2.t0 = _context2["catch"](0);
|
|
72
|
-
return _context2.abrupt("return", '');
|
|
73
|
-
case 14:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context2.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee2, null, [[0, 11]]);
|
|
78
|
-
})), {
|
|
79
|
-
revalidateOnFocus: false
|
|
80
|
-
});
|
|
77
|
+
}, _callee, null, [[0, 4]]);
|
|
78
|
+
})));
|
|
81
79
|
};
|
|
82
80
|
export { languageMap } from "./languageMap";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuntijs/ui",
|
|
3
|
-
"version": "1.1.0-beta.
|
|
3
|
+
"version": "1.1.0-beta.4",
|
|
4
4
|
"description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yuntijs",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@lobehub/ui": "^1.164.2",
|
|
92
92
|
"@melloware/react-logviewer": "^5.2.0",
|
|
93
93
|
"@monaco-editor/loader": "^1.4.0",
|
|
94
|
-
"@shikijs/transformers": "^
|
|
94
|
+
"@shikijs/transformers": "^3.2.1",
|
|
95
95
|
"leva": "^0",
|
|
96
96
|
"lexical": "^0.23.1",
|
|
97
97
|
"lodash-es": "^4",
|
|
@@ -102,8 +102,9 @@
|
|
|
102
102
|
"react-error-boundary": "^4",
|
|
103
103
|
"react-layout-kit": "^1",
|
|
104
104
|
"react18-json-view": "^0.2.8",
|
|
105
|
-
"shiki": "^
|
|
105
|
+
"shiki": "^3.2.1",
|
|
106
106
|
"swr": "^2.2.5",
|
|
107
|
+
"ts-md5": "^1.3.1",
|
|
107
108
|
"url-join": "^5.0.0",
|
|
108
109
|
"use-merge-value": "^1.2.0"
|
|
109
110
|
},
|