dumi 2.3.0-beta.5 → 2.3.0-beta.7
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/package.json +1 -1
- package/theme-default/builtins/SourceCode/index.d.ts +1 -0
- package/theme-default/builtins/SourceCode/index.js +22 -17
- package/theme-default/builtins/SourceCode/index.less +25 -0
- package/theme-default/slots/SourceCodeEditor/index.js +3 -2
- package/theme-default/slots/SourceCodeEditor/index.less +23 -4
package/package.json
CHANGED
|
@@ -46,22 +46,7 @@ var SourceCode = function SourceCode(props) {
|
|
|
46
46
|
setText(_text);
|
|
47
47
|
}
|
|
48
48
|
}, [lang, children]);
|
|
49
|
-
|
|
50
|
-
className: "dumi-default-source-code"
|
|
51
|
-
}, /*#__PURE__*/React.createElement(CopyToClipboard, {
|
|
52
|
-
text: text,
|
|
53
|
-
onCopy: function onCopy() {
|
|
54
|
-
setIsCopied(true);
|
|
55
|
-
clearTimeout(timer.current);
|
|
56
|
-
timer.current = window.setTimeout(function () {
|
|
57
|
-
return setIsCopied(false);
|
|
58
|
-
}, 2000);
|
|
59
|
-
}
|
|
60
|
-
}, /*#__PURE__*/React.createElement("button", {
|
|
61
|
-
type: "button",
|
|
62
|
-
className: "dumi-default-source-code-copy",
|
|
63
|
-
"data-copied": isCopied || undefined
|
|
64
|
-
}, isCopied ? /*#__PURE__*/React.createElement(IconCheck, null) : /*#__PURE__*/React.createElement(IconCopy, null))), /*#__PURE__*/React.createElement(Highlight, _extends({}, defaultProps, {
|
|
49
|
+
var code = /*#__PURE__*/React.createElement(Highlight, _extends({}, defaultProps, {
|
|
65
50
|
code: children,
|
|
66
51
|
language: SIMILAR_DSL[lang] || lang,
|
|
67
52
|
theme: undefined
|
|
@@ -102,6 +87,26 @@ var SourceCode = function SourceCode(props) {
|
|
|
102
87
|
);
|
|
103
88
|
})));
|
|
104
89
|
}));
|
|
105
|
-
})
|
|
90
|
+
});
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: "dumi-default-source-code"
|
|
93
|
+
}, /*#__PURE__*/React.createElement(CopyToClipboard, {
|
|
94
|
+
text: text,
|
|
95
|
+
onCopy: function onCopy() {
|
|
96
|
+
setIsCopied(true);
|
|
97
|
+
clearTimeout(timer.current);
|
|
98
|
+
timer.current = window.setTimeout(function () {
|
|
99
|
+
return setIsCopied(false);
|
|
100
|
+
}, 2000);
|
|
101
|
+
}
|
|
102
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
103
|
+
type: "button",
|
|
104
|
+
className: "dumi-default-source-code-copy",
|
|
105
|
+
"data-copied": isCopied || undefined
|
|
106
|
+
}, isCopied ? /*#__PURE__*/React.createElement(IconCheck, null) : /*#__PURE__*/React.createElement(IconCopy, null))), props.textarea ? /*#__PURE__*/React.createElement("div", {
|
|
107
|
+
className: "dumi-default-source-code-scroll-container"
|
|
108
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
109
|
+
className: "dumi-default-source-code-scroll-content"
|
|
110
|
+
}, code, props.textarea)) : code, props.extra);
|
|
106
111
|
};
|
|
107
112
|
export default SourceCode;
|
|
@@ -25,7 +25,32 @@
|
|
|
25
25
|
border-bottom-left-radius: 4px;
|
|
26
26
|
border-bottom-right-radius: 4px;
|
|
27
27
|
|
|
28
|
+
&-scroll-container {
|
|
29
|
+
overflow: auto;
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&-scroll-content {
|
|
35
|
+
position: relative;
|
|
36
|
+
width: max-content;
|
|
37
|
+
height: max-content;
|
|
38
|
+
min-width: 100%;
|
|
39
|
+
min-height: 100%;
|
|
40
|
+
|
|
41
|
+
> pre.prism-code {
|
|
42
|
+
width: max-content;
|
|
43
|
+
position: relative;
|
|
44
|
+
overflow: visible;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
28
48
|
> pre.prism-code {
|
|
49
|
+
overflow: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
> pre.prism-code,
|
|
53
|
+
&-scroll-content > pre.prism-code {
|
|
29
54
|
margin: 0;
|
|
30
55
|
padding: 18px 24px;
|
|
31
56
|
font-size: 14px;
|
|
@@ -43,7 +43,7 @@ var SourceCodeEditor = function SourceCodeEditor(props) {
|
|
|
43
43
|
className: "dumi-default-source-code-editor",
|
|
44
44
|
ref: elm
|
|
45
45
|
}, /*#__PURE__*/React.createElement(SourceCode, _extends({}, props, {
|
|
46
|
-
|
|
46
|
+
textarea: style && /*#__PURE__*/React.createElement("textarea", {
|
|
47
47
|
className: "dumi-default-source-code-editor-textarea",
|
|
48
48
|
style: style,
|
|
49
49
|
value: code,
|
|
@@ -77,7 +77,8 @@ var SourceCodeEditor = function SourceCodeEditor(props) {
|
|
|
77
77
|
autoComplete: "off",
|
|
78
78
|
autoCorrect: "off",
|
|
79
79
|
autoSave: "off"
|
|
80
|
-
}),
|
|
80
|
+
}),
|
|
81
|
+
extra: style && props.extra
|
|
81
82
|
}), code));
|
|
82
83
|
};
|
|
83
84
|
export default SourceCodeEditor;
|
|
@@ -30,11 +30,7 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
&:focus {
|
|
33
|
-
box-shadow: 0 0 0 1px lighten(@c-primary, 20%) inset;
|
|
34
|
-
|
|
35
33
|
@{dark-selector} & {
|
|
36
|
-
box-shadow: 0 0 0 1px darken(@c-primary-dark, 20%) inset;
|
|
37
|
-
|
|
38
34
|
// for firefox because its selection color is not translucent when color-scheme is dark
|
|
39
35
|
&::selection {
|
|
40
36
|
background-color: fade(@c-primary-dark, 30%);
|
|
@@ -42,4 +38,27 @@
|
|
|
42
38
|
}
|
|
43
39
|
}
|
|
44
40
|
}
|
|
41
|
+
|
|
42
|
+
&::after {
|
|
43
|
+
content: '';
|
|
44
|
+
position: absolute;
|
|
45
|
+
z-index: 0;
|
|
46
|
+
top: 0;
|
|
47
|
+
left: 0;
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
border-bottom-left-radius: 3px;
|
|
51
|
+
border-bottom-right-radius: 3px;
|
|
52
|
+
pointer-events: none;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:focus-within {
|
|
56
|
+
&::after {
|
|
57
|
+
box-shadow: 0 0 0 1px @c-primary inset;
|
|
58
|
+
|
|
59
|
+
@{dark-selector} & {
|
|
60
|
+
box-shadow: 0 0 0 1px @c-primary-dark inset;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
45
64
|
}
|