@coding-script/script-engine 0.0.5 → 0.0.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.
|
@@ -41,6 +41,9 @@ function ensureScrollbarStyle() {
|
|
|
41
41
|
.${SCROLL_CLASS}::-webkit-scrollbar-track { background: transparent; }
|
|
42
42
|
body.se-panel-resizing { cursor: col-resize !important; user-select: none !important; }
|
|
43
43
|
body.se-panel-resizing * { cursor: col-resize !important; user-select: none !important; }
|
|
44
|
+
.se-desc-tip p { margin: 0 0 4px 0; }
|
|
45
|
+
.se-desc-tip p:last-child { margin-bottom: 0; }
|
|
46
|
+
.se-desc-tip code { font-family: Menlo, Consolas, monospace; font-size: 11px; }
|
|
44
47
|
`;
|
|
45
48
|
document.head.appendChild(style);
|
|
46
49
|
}
|
|
@@ -2,7 +2,7 @@ import react, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
2
2
|
import { ToolbarButton } from "./toolbar-button.js";
|
|
3
3
|
import { FormatIcon } from "./format-icon.js";
|
|
4
4
|
import { MaximizeIcon, MinimizeIcon } from "./fullscreen-icon.js";
|
|
5
|
-
import { themes } from "./theme-colors.js";
|
|
5
|
+
import { ensureScrollbarStyle, themes } from "./theme-colors.js";
|
|
6
6
|
const HammerIcon = ({ color })=>/*#__PURE__*/ react.createElement("svg", {
|
|
7
7
|
width: "14",
|
|
8
8
|
height: "14",
|
|
@@ -51,17 +51,6 @@ function calcTooltipPos(anchorRect, el) {
|
|
|
51
51
|
maxHeight: Math.max(maxHeight, 80)
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
const KV_RE = /^([^:]+):\s*([\s\S]+)$/;
|
|
55
|
-
function renderDescLine(line, accent) {
|
|
56
|
-
const m = line.match(KV_RE);
|
|
57
|
-
if (m) return /*#__PURE__*/ react.createElement("span", null, /*#__PURE__*/ react.createElement("span", {
|
|
58
|
-
style: {
|
|
59
|
-
color: accent,
|
|
60
|
-
fontWeight: 600
|
|
61
|
-
}
|
|
62
|
-
}, m[1]), /*#__PURE__*/ react.createElement("span", null, ": ", m[2]));
|
|
63
|
-
return line;
|
|
64
|
-
}
|
|
65
54
|
const QuestionIcon = ({ color })=>/*#__PURE__*/ react.createElement("svg", {
|
|
66
55
|
width: "13",
|
|
67
56
|
height: "13",
|
|
@@ -104,6 +93,7 @@ const Toolbar = ({ title, theme, onThemeChange, enableThemeToggle, enableFormat,
|
|
|
104
93
|
}, []);
|
|
105
94
|
useEffect(()=>{
|
|
106
95
|
if (!showDesc) return;
|
|
96
|
+
ensureScrollbarStyle();
|
|
107
97
|
updateTipPos();
|
|
108
98
|
window.addEventListener('scroll', updateTipPos, true);
|
|
109
99
|
window.addEventListener('resize', updateTipPos);
|
|
@@ -125,7 +115,7 @@ const Toolbar = ({ title, theme, onThemeChange, enableThemeToggle, enableFormat,
|
|
|
125
115
|
}, [
|
|
126
116
|
description
|
|
127
117
|
]);
|
|
128
|
-
const
|
|
118
|
+
const descHtml = description ? description.replace(/\\n/g, '\n').replace(/\n/g, '<br>') : '';
|
|
129
119
|
const handleThemeToggle = ()=>{
|
|
130
120
|
const next = isDark ? 'light' : 'dark';
|
|
131
121
|
onThemeChange?.(next);
|
|
@@ -155,7 +145,7 @@ const Toolbar = ({ title, theme, onThemeChange, enableThemeToggle, enableFormat,
|
|
|
155
145
|
style: {
|
|
156
146
|
marginRight: 'auto'
|
|
157
147
|
}
|
|
158
|
-
}),
|
|
148
|
+
}), descHtml && /*#__PURE__*/ react.createElement(ToolbarButton, {
|
|
159
149
|
ref: descBtnRef,
|
|
160
150
|
label: /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(QuestionIcon, {
|
|
161
151
|
color: "currentColor"
|
|
@@ -216,8 +206,9 @@ const Toolbar = ({ title, theme, onThemeChange, enableThemeToggle, enableFormat,
|
|
|
216
206
|
textColor: item.textColor,
|
|
217
207
|
borderColor: item.borderColor,
|
|
218
208
|
onClick: item.onClick
|
|
219
|
-
})), toolbarExtra, showDesc && tipPos &&
|
|
209
|
+
})), toolbarExtra, showDesc && tipPos && descHtml && /*#__PURE__*/ react.createElement("div", {
|
|
220
210
|
ref: tipRef,
|
|
211
|
+
className: "se-desc-tip",
|
|
221
212
|
style: {
|
|
222
213
|
position: 'fixed',
|
|
223
214
|
top: tipPos.top,
|
|
@@ -231,17 +222,15 @@ const Toolbar = ({ title, theme, onThemeChange, enableThemeToggle, enableFormat,
|
|
|
231
222
|
borderRadius: 6,
|
|
232
223
|
color: colors.text,
|
|
233
224
|
fontSize: 12,
|
|
234
|
-
lineHeight: 1.
|
|
225
|
+
lineHeight: 1.5,
|
|
235
226
|
wordBreak: 'break-word',
|
|
236
227
|
zIndex: 9999,
|
|
237
228
|
boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
|
|
238
229
|
pointerEvents: 'auto'
|
|
230
|
+
},
|
|
231
|
+
dangerouslySetInnerHTML: {
|
|
232
|
+
__html: descHtml
|
|
239
233
|
}
|
|
240
|
-
}
|
|
241
|
-
key: i,
|
|
242
|
-
style: {
|
|
243
|
-
marginBottom: i < descLines.length - 1 ? 4 : 0
|
|
244
|
-
}
|
|
245
|
-
}, renderDescLine(line, colors.accent)))));
|
|
234
|
+
}));
|
|
246
235
|
};
|
|
247
236
|
export { Toolbar };
|