vzcode 1.18.0 → 1.20.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/dist/assets/{index-CSSpCKM0.js → index-DxgQGuCb.js} +101 -101
- package/dist/assets/index-w9VAfRwW.js +192 -0
- package/dist/assets/{worker-8af7bTHW.js → worker-B9Dbsldy.js} +179 -179
- package/dist/index.html +1 -1
- package/package.json +38 -38
- package/src/client/App/useShareDB.ts +0 -2
- package/src/client/CodeEditor/InteractiveWidgets/colorPicker.ts +57 -176
- package/src/client/CodeEditor/InteractiveWidgets/colorsInTextPlugin.ts +14 -14
- package/src/client/CodeEditor/getOrCreateEditor.ts +22 -10
- package/src/client/CodeEditor/style.scss +26 -26
- package/src/client/RunCodeWidget/index.tsx +11 -3
- package/src/client/VZKeyboardShortcutsDoc.tsx +34 -8
- package/src/client/VZSettings.tsx +109 -118
- package/src/server/handleAICopilot.js +2 -2
- package/dist/assets/index-eifYAxsF.js +0 -181
package/dist/index.html
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
|
21
21
|
rel="stylesheet"
|
|
22
22
|
/>
|
|
23
|
-
<script type="module" crossorigin src="/assets/index-
|
|
23
|
+
<script type="module" crossorigin src="/assets/index-w9VAfRwW.js"></script>
|
|
24
24
|
<link rel="stylesheet" crossorigin href="/assets/index-zzK6rRiK.css">
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vzcode",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "Multiplayer code editor system",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -103,17 +103,17 @@
|
|
|
103
103
|
},
|
|
104
104
|
"homepage": "https://github.com/vizhub-core/vzcode#readme",
|
|
105
105
|
"dependencies": {
|
|
106
|
-
"@codemirror/autocomplete": "^6.18.
|
|
106
|
+
"@codemirror/autocomplete": "^6.18.4",
|
|
107
107
|
"@codemirror/lang-css": "^6.3.1",
|
|
108
108
|
"@codemirror/lang-html": "^6.4.9",
|
|
109
109
|
"@codemirror/lang-javascript": "^6.2.2",
|
|
110
110
|
"@codemirror/lang-json": "^6.0.1",
|
|
111
|
-
"@codemirror/lang-markdown": "^6.3.
|
|
112
|
-
"@codemirror/state": "^6.
|
|
111
|
+
"@codemirror/lang-markdown": "^6.3.2",
|
|
112
|
+
"@codemirror/state": "^6.5.1",
|
|
113
113
|
"@codemirror/theme-one-dark": "^6.1.2",
|
|
114
|
-
"@codemirror/view": "^6.
|
|
114
|
+
"@codemirror/view": "^6.36.2",
|
|
115
115
|
"@lezer/highlight": "^1.2.1",
|
|
116
|
-
"@livekit/components-react": "^2.
|
|
116
|
+
"@livekit/components-react": "^2.7.0",
|
|
117
117
|
"@livekit/components-styles": "^1.1.4",
|
|
118
118
|
"@replit/codemirror-indentation-markers": "^6.5.3",
|
|
119
119
|
"@replit/codemirror-interact": "^6.3.1",
|
|
@@ -121,15 +121,15 @@
|
|
|
121
121
|
"@replit/codemirror-vscode-keymap": "^6.0.2",
|
|
122
122
|
"@teamwork/websocket-json-stream": "^2.0.0",
|
|
123
123
|
"@typescript/vfs": "^1.6.0",
|
|
124
|
-
"@uiw/codemirror-theme-abcdef": "^4.23.
|
|
125
|
-
"@uiw/codemirror-theme-dracula": "^4.23.
|
|
126
|
-
"@uiw/codemirror-theme-eclipse": "^4.23.
|
|
127
|
-
"@uiw/codemirror-theme-github": "^4.23.
|
|
128
|
-
"@uiw/codemirror-theme-material": "^4.23.
|
|
129
|
-
"@uiw/codemirror-theme-nord": "^4.23.
|
|
130
|
-
"@uiw/codemirror-theme-okaidia": "^4.23.
|
|
131
|
-
"@uiw/codemirror-theme-xcode": "^4.23.
|
|
132
|
-
"@uiw/codemirror-themes": "^4.23.
|
|
124
|
+
"@uiw/codemirror-theme-abcdef": "^4.23.7",
|
|
125
|
+
"@uiw/codemirror-theme-dracula": "^4.23.7",
|
|
126
|
+
"@uiw/codemirror-theme-eclipse": "^4.23.7",
|
|
127
|
+
"@uiw/codemirror-theme-github": "^4.23.7",
|
|
128
|
+
"@uiw/codemirror-theme-material": "^4.23.7",
|
|
129
|
+
"@uiw/codemirror-theme-nord": "^4.23.7",
|
|
130
|
+
"@uiw/codemirror-theme-okaidia": "^4.23.7",
|
|
131
|
+
"@uiw/codemirror-theme-xcode": "^4.23.7",
|
|
132
|
+
"@uiw/codemirror-themes": "^4.23.7",
|
|
133
133
|
"body-parser": "^1.20.3",
|
|
134
134
|
"codemirror": "^6.0.1",
|
|
135
135
|
"codemirror-copilot": "^0.0.7",
|
|
@@ -137,40 +137,40 @@
|
|
|
137
137
|
"color-hash": "^2.0.2",
|
|
138
138
|
"d3-array": "^3.2.4",
|
|
139
139
|
"diff-match-patch": "^1.0.5",
|
|
140
|
-
"dotenv": "^16.4.
|
|
141
|
-
"express": "^4.21.
|
|
142
|
-
"ignore": "^
|
|
140
|
+
"dotenv": "^16.4.7",
|
|
141
|
+
"express": "^4.21.2",
|
|
142
|
+
"ignore": "^7.0.3",
|
|
143
143
|
"json0-ot-diff": "^1.1.2",
|
|
144
|
-
"livekit-client": "^2.
|
|
145
|
-
"livekit-server-sdk": "^2.9.
|
|
144
|
+
"livekit-client": "^2.8.0",
|
|
145
|
+
"livekit-server-sdk": "^2.9.7",
|
|
146
146
|
"ngrok": "^4.3.3",
|
|
147
147
|
"open": "^10.1.0",
|
|
148
|
-
"openai": "^4.
|
|
149
|
-
"prettier-plugin-svelte": "^3.3.
|
|
150
|
-
"react": "^
|
|
151
|
-
"react-bootstrap": "^2.10.
|
|
152
|
-
"react-dom": "^
|
|
153
|
-
"react-router-dom": "^7.
|
|
148
|
+
"openai": "^4.78.1",
|
|
149
|
+
"prettier-plugin-svelte": "^3.3.3",
|
|
150
|
+
"react": "^19.0.0",
|
|
151
|
+
"react-bootstrap": "^2.10.7",
|
|
152
|
+
"react-dom": "^19.0.0",
|
|
153
|
+
"react-router-dom": "^7.1.2",
|
|
154
154
|
"sharedb": "^5.1.1",
|
|
155
|
-
"sharedb-client-browser": "^5.
|
|
156
|
-
"uuid": "^11.0.
|
|
155
|
+
"sharedb-client-browser": "^5.1.1",
|
|
156
|
+
"uuid": "^11.0.5",
|
|
157
157
|
"vizhub-ui": "^3.23.0",
|
|
158
158
|
"ws": "^8.18.0"
|
|
159
159
|
},
|
|
160
160
|
"devDependencies": {
|
|
161
|
-
"@types/react": "^
|
|
162
|
-
"@types/react-dom": "^
|
|
161
|
+
"@types/react": "^19.0.7",
|
|
162
|
+
"@types/react-dom": "^19.0.3",
|
|
163
163
|
"@vitejs/plugin-react": "^4.3.4",
|
|
164
|
-
"concurrently": "^9.1.
|
|
164
|
+
"concurrently": "^9.1.2",
|
|
165
165
|
"cross-env": "^7.0.3",
|
|
166
|
-
"prettier": "^3.4.
|
|
167
|
-
"sass": "^1.
|
|
168
|
-
"typescript": "^5.7.
|
|
169
|
-
"vite": "^6.0.
|
|
170
|
-
"vitest": "^
|
|
166
|
+
"prettier": "^3.4.2",
|
|
167
|
+
"sass": "^1.83.4",
|
|
168
|
+
"typescript": "^5.7.3",
|
|
169
|
+
"vite": "^6.0.7",
|
|
170
|
+
"vitest": "^3.0.1"
|
|
171
171
|
},
|
|
172
172
|
"optionalDependencies": {
|
|
173
|
-
"@rollup/rollup-darwin-arm64": "^4.
|
|
174
|
-
"@rollup/rollup-win32-x64-msvc": "^4.
|
|
173
|
+
"@rollup/rollup-darwin-arm64": "^4.30.1",
|
|
174
|
+
"@rollup/rollup-win32-x64-msvc": "^4.30.1"
|
|
175
175
|
}
|
|
176
176
|
}
|
|
@@ -142,8 +142,6 @@ export const useShareDB = ({
|
|
|
142
142
|
// False for "Saved"
|
|
143
143
|
const pending = usePending(shareDBDoc);
|
|
144
144
|
|
|
145
|
-
console.log('pending ', pending);
|
|
146
|
-
|
|
147
145
|
// A convenience function for mutating the ShareDB document
|
|
148
146
|
// based submitting OT ops generated by diffing the JSON.
|
|
149
147
|
const submitOperation =
|
|
@@ -8,180 +8,61 @@ export const colorPickerRegex = /#[0-9A-Fa-f]{6}/g;
|
|
|
8
8
|
// Works without quotes to support CSS.
|
|
9
9
|
export const colorPicker = (
|
|
10
10
|
onInteract?: () => void,
|
|
11
|
-
):
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// Assuming you're applying the color to a circle element with id 'colorCircle'
|
|
62
|
-
const colorCircle = document.getElementById('colorCircle');
|
|
63
|
-
if (colorCircle) {
|
|
64
|
-
colorCircle.style.backgroundColor = newText;
|
|
65
|
-
console.log(`Color applied to colorCircle: ${newText}`);
|
|
66
|
-
} else {
|
|
67
|
-
console.log('colorCircle element not found');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// If there is any other text element (like an input or div for displaying hex color), update it too.
|
|
71
|
-
const hexDisplay = document.getElementById('hexDisplay');
|
|
72
|
-
if (hexDisplay) {
|
|
73
|
-
hexDisplay.textContent = newText;
|
|
74
|
-
console.log(`Hex value applied to hexDisplay: ${newText}`);
|
|
75
|
-
} else {
|
|
76
|
-
console.log('hexDisplay element not found');
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
regexp: colorPickerRegex,
|
|
82
|
-
cursor: 'pointer',
|
|
83
|
-
|
|
84
|
-
onClick(
|
|
85
|
-
text: string,
|
|
86
|
-
setText: (newText: string) => void,
|
|
87
|
-
event: MouseEvent
|
|
88
|
-
) {
|
|
89
|
-
const startingColor: string = text;
|
|
90
|
-
|
|
91
|
-
// Set the initial value of the color picker
|
|
92
|
-
console.log('Initial color:', startingColor);
|
|
93
|
-
sel.value = startingColor.toLowerCase();
|
|
94
|
-
console.log('Color picker initial value set to:', sel.value);
|
|
95
|
-
|
|
96
|
-
// Position the color picker near the cursor
|
|
97
|
-
const cursorX = event.clientX;
|
|
98
|
-
const cursorY = event.clientY;
|
|
99
|
-
sel.style.left = cursorX + 'px';
|
|
100
|
-
sel.style.top = cursorY + 'px';
|
|
101
|
-
|
|
102
|
-
// Show and position the close button
|
|
103
|
-
closeButton.style.display = 'block';
|
|
104
|
-
closeButton.style.left = `${cursorX + sel.offsetWidth - 15}px`; // Adjust to place in corner
|
|
105
|
-
closeButton.style.top = `${cursorY - 15}px`;
|
|
106
|
-
|
|
107
|
-
// Update the color selection and setText on change
|
|
108
|
-
const updateHex = (e: Event) => {
|
|
109
|
-
const el: HTMLInputElement = e.target as HTMLInputElement;
|
|
110
|
-
console.log('Hex color value selected:', el.value);
|
|
111
|
-
|
|
112
|
-
if (el.value) {
|
|
113
|
-
setText(el.value.toUpperCase()); // Use uppercase for consistency
|
|
114
|
-
}
|
|
115
|
-
if (onInteract) {
|
|
116
|
-
console.log('onInteract called');
|
|
117
|
-
onInteract();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Update color display directly (for example, changing the background color of an element)
|
|
121
|
-
const colorDisplay = document.getElementById('colorDisplay');
|
|
122
|
-
if (colorDisplay) {
|
|
123
|
-
colorDisplay.style.backgroundColor = el.value;
|
|
124
|
-
console.log(`colorDisplay updated to: ${el.value}`);
|
|
125
|
-
} else {
|
|
126
|
-
console.log('colorDisplay element not found');
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
// Add input event listener to handle color selection
|
|
131
|
-
sel.addEventListener('input', updateHex);
|
|
132
|
-
|
|
133
|
-
// Trigger click event on the color picker to display it
|
|
11
|
+
): InteractRule => ({
|
|
12
|
+
regexp: colorPickerRegex,
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
onClick(
|
|
15
|
+
text: string,
|
|
16
|
+
setText: (newText: string) => void,
|
|
17
|
+
event: MouseEvent,
|
|
18
|
+
) {
|
|
19
|
+
const startingColor: string = text;
|
|
20
|
+
|
|
21
|
+
const sel: HTMLInputElement =
|
|
22
|
+
document.createElement('input');
|
|
23
|
+
sel.type = 'color';
|
|
24
|
+
sel.value = startingColor.toLowerCase();
|
|
25
|
+
|
|
26
|
+
// `valueIsUpper` maintains the style of the user's code.
|
|
27
|
+
// It keeps the case of a-f the same case as the original.
|
|
28
|
+
const valueIsUpper: boolean =
|
|
29
|
+
startingColor.toUpperCase() === startingColor;
|
|
30
|
+
|
|
31
|
+
const updateHex = (e: Event) => {
|
|
32
|
+
const el: HTMLInputElement =
|
|
33
|
+
e.target as HTMLInputElement;
|
|
34
|
+
if (el.value) {
|
|
35
|
+
setText(
|
|
36
|
+
valueIsUpper ? el.value.toUpperCase() : el.value,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
if (onInteract) onInteract();
|
|
40
|
+
};
|
|
41
|
+
sel.addEventListener('input', updateHex);
|
|
42
|
+
|
|
43
|
+
// Position the color input at the mouse cursor
|
|
44
|
+
sel.style.position = 'absolute';
|
|
45
|
+
sel.style.left = `${event.clientX}px`;
|
|
46
|
+
sel.style.top = `${event.clientY}px`;
|
|
47
|
+
|
|
48
|
+
// Make it invisible
|
|
49
|
+
sel.style.opacity = '0';
|
|
50
|
+
sel.style.height = '0';
|
|
51
|
+
sel.style.width = '0';
|
|
52
|
+
sel.style.border = 'none';
|
|
53
|
+
sel.style.padding = '0';
|
|
54
|
+
sel.style.margin = '0';
|
|
55
|
+
document.body.appendChild(sel);
|
|
56
|
+
|
|
57
|
+
// Click the input after a delay, so that
|
|
58
|
+
// it gets the correct position
|
|
59
|
+
setTimeout(() => {
|
|
134
60
|
sel.click();
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
// Inspired by https://github.com/replit/codemirror-interact/blob/master/dev/index.ts#L71
|
|
144
|
-
//TODO: create color picker for hsl colors
|
|
145
|
-
// {
|
|
146
|
-
// regexp: /rgb\(.*\)/g,
|
|
147
|
-
// cursor: 'pointer',
|
|
148
|
-
// onClick: (text, setText, e) => {
|
|
149
|
-
// const res =
|
|
150
|
-
// /rgb\((?<r>\d+)\s*,\s*(?<g>\d+)\s*,\s*(?<b>\d+)\)/.exec(
|
|
151
|
-
// text,
|
|
152
|
-
// );
|
|
153
|
-
// const r = Number(res?.groups?.r);
|
|
154
|
-
// const g = Number(res?.groups?.g);
|
|
155
|
-
// const b = Number(res?.groups?.b);
|
|
156
|
-
|
|
157
|
-
// //sel will open the color picker when sel.click is called.
|
|
158
|
-
// const sel = document.createElement('input');
|
|
159
|
-
// sel.type = 'color';
|
|
160
|
-
|
|
161
|
-
// if (!isNaN(r + g + b)) sel.value = rgb2Hex(r, g, b);
|
|
162
|
-
|
|
163
|
-
// const updateRGB = (e: Event) => {
|
|
164
|
-
// const el = e.target as HTMLInputElement;
|
|
165
|
-
// if (onInteract) onInteract();
|
|
166
|
-
|
|
167
|
-
// if (el.value) {
|
|
168
|
-
// const [r, g, b] = hex2RGB(el.value);
|
|
169
|
-
// setText(`rgb(${r}, ${g}, ${b})`);
|
|
170
|
-
// }
|
|
171
|
-
// sel.removeEventListener('change', updateRGB);
|
|
172
|
-
// };
|
|
173
|
-
|
|
174
|
-
// sel.addEventListener('change', updateRGB);
|
|
175
|
-
// sel.click();
|
|
176
|
-
// },
|
|
177
|
-
// },
|
|
178
|
-
|
|
179
|
-
// // Inspired by https://github.com/replit/codemirror-interact/blob/master/dev/index.ts#L108
|
|
180
|
-
// const hex2RGB = (hex: string): [number, number, number] => {
|
|
181
|
-
// const v = parseInt(hex.substring(1), 16);
|
|
182
|
-
// return [(v >> 16) & 255, (v >> 8) & 255, v & 255];
|
|
183
|
-
// };
|
|
184
|
-
|
|
185
|
-
// // Inspired by https://github.com/replit/codemirror-interact/blob/master/dev/index.ts#L117
|
|
186
|
-
// const rgb2Hex = (r: number, g: number, b: number): string =>
|
|
187
|
-
// '#' + r.toString(16) + g.toString(16) + b.toString(16);
|
|
61
|
+
}, 10);
|
|
62
|
+
|
|
63
|
+
// Remove the input after interaction
|
|
64
|
+
sel.addEventListener('blur', () => {
|
|
65
|
+
document.body.removeChild(sel);
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -32,8 +32,8 @@ class ColorWidget extends WidgetType {
|
|
|
32
32
|
|
|
33
33
|
parent.setAttribute(
|
|
34
34
|
'style',
|
|
35
|
-
`width:${size}px;height:${size}px;position:relative;`,
|
|
36
|
-
// Position relative for the hovering tool tip to work
|
|
35
|
+
`width:${size}px;height:${size}px;position:relative;`,
|
|
36
|
+
// Position relative for the hovering tool tip to work
|
|
37
37
|
);
|
|
38
38
|
parent.className = 'color-circle-parent';
|
|
39
39
|
const svg = document.createElementNS(
|
|
@@ -80,12 +80,9 @@ class ColorWidget extends WidgetType {
|
|
|
80
80
|
// Set class for tooltip to use CSS styles
|
|
81
81
|
hoveringTooltip.className = 'tooltip_hover_circle';
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
hoveringTooltip.innerHTML =
|
|
85
|
-
`<strong>Alt + Click on a hex color</strong><br />
|
|
83
|
+
hoveringTooltip.innerHTML = `<strong>Alt + Click on a hex color</strong><br />
|
|
86
84
|
<div>Open a color picker to modify the color</div>`;
|
|
87
85
|
|
|
88
|
-
|
|
89
86
|
parent.appendChild(hoveringTooltip);
|
|
90
87
|
|
|
91
88
|
// Timer to prevent constant pop-ups when scrolling through code
|
|
@@ -93,13 +90,16 @@ class ColorWidget extends WidgetType {
|
|
|
93
90
|
|
|
94
91
|
// Fade in and fade out effect for when user hovers over the circle
|
|
95
92
|
// Mouse Event to set y and x of the tool tip pop up to prevent overlap onto circle
|
|
96
|
-
parent.addEventListener(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
parent.addEventListener(
|
|
94
|
+
'mouseenter',
|
|
95
|
+
(event: MouseEvent) => {
|
|
96
|
+
hoverTimeout = window.setTimeout(() => {
|
|
97
|
+
hoveringTooltip.style.top = `${event.clientY - 60}px`;
|
|
98
|
+
hoveringTooltip.style.left = `${event.clientX}px`;
|
|
99
|
+
hoveringTooltip.style.opacity = '1';
|
|
100
|
+
}, 700);
|
|
101
|
+
},
|
|
102
|
+
);
|
|
103
103
|
|
|
104
104
|
parent.addEventListener('mouseleave', () => {
|
|
105
105
|
clearTimeout(hoverTimeout);
|
|
@@ -108,7 +108,7 @@ class ColorWidget extends WidgetType {
|
|
|
108
108
|
|
|
109
109
|
return parent;
|
|
110
110
|
}
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
ignoreEvent() {
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
@@ -108,7 +108,8 @@ const getAtPath = (obj, path) => {
|
|
|
108
108
|
};
|
|
109
109
|
|
|
110
110
|
// Extend the EditorCacheValue type to include the compartments and the updateRainbowBrackets method
|
|
111
|
-
interface ExtendedEditorCacheValue
|
|
111
|
+
interface ExtendedEditorCacheValue
|
|
112
|
+
extends EditorCacheValue {
|
|
112
113
|
themeCompartment: Compartment;
|
|
113
114
|
rainbowBracketsCompartment: Compartment;
|
|
114
115
|
updateRainbowBrackets: (enabled: boolean) => void;
|
|
@@ -179,7 +180,9 @@ export const getOrCreateEditor = ({
|
|
|
179
180
|
const cacheKey = editorCacheKey(fileId, paneId);
|
|
180
181
|
|
|
181
182
|
if (editorCache.has(cacheKey)) {
|
|
182
|
-
return editorCache.get(
|
|
183
|
+
return editorCache.get(
|
|
184
|
+
cacheKey,
|
|
185
|
+
) as ExtendedEditorCacheValue;
|
|
183
186
|
}
|
|
184
187
|
|
|
185
188
|
// Cache miss
|
|
@@ -194,7 +197,7 @@ export const getOrCreateEditor = ({
|
|
|
194
197
|
// Create a compartment for the theme so that it can be changed dynamically.
|
|
195
198
|
// Inspired by: https://github.com/craftzdog/cm6-themes/blob/main/example/index.ts
|
|
196
199
|
let themeCompartment = new Compartment();
|
|
197
|
-
|
|
200
|
+
|
|
198
201
|
// Create a compartment for rainbow brackets so that it can be enabled/disabled dynamically.
|
|
199
202
|
let rainbowBracketsCompartment = new Compartment();
|
|
200
203
|
|
|
@@ -260,7 +263,7 @@ export const getOrCreateEditor = ({
|
|
|
260
263
|
// Adds compartment for rainbow brackets with initial toggle state.
|
|
261
264
|
extensions.push(
|
|
262
265
|
rainbowBracketsCompartment.of(
|
|
263
|
-
rainbowBracketsEnabled ? rainbowBrackets() : []
|
|
266
|
+
rainbowBracketsEnabled ? rainbowBrackets() : [],
|
|
264
267
|
),
|
|
265
268
|
);
|
|
266
269
|
|
|
@@ -420,17 +423,26 @@ export const getOrCreateEditor = ({
|
|
|
420
423
|
}),
|
|
421
424
|
});
|
|
422
425
|
|
|
423
|
-
const editorCacheValue: ExtendedEditorCacheValue = {
|
|
424
|
-
editor
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
426
|
+
const editorCacheValue: ExtendedEditorCacheValue = {
|
|
427
|
+
editor,
|
|
428
|
+
themeCompartment,
|
|
429
|
+
rainbowBracketsCompartment,
|
|
430
|
+
updateRainbowBrackets: (enabled) => {
|
|
431
|
+
editor.dispatch({
|
|
432
|
+
effects: rainbowBracketsCompartment.reconfigure(
|
|
433
|
+
enabled ? rainbowBrackets() : [],
|
|
434
|
+
),
|
|
435
|
+
});
|
|
436
|
+
},
|
|
437
|
+
};
|
|
428
438
|
|
|
429
439
|
// Populate the cache.
|
|
430
440
|
editorCache.set(cacheKey, editorCacheValue);
|
|
431
441
|
|
|
432
442
|
// Initialize rainbow brackets based on the toggle state
|
|
433
|
-
editorCacheValue.updateRainbowBrackets(
|
|
443
|
+
editorCacheValue.updateRainbowBrackets(
|
|
444
|
+
rainbowBracketsEnabled,
|
|
445
|
+
);
|
|
434
446
|
|
|
435
447
|
return editorCacheValue;
|
|
436
448
|
};
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
.tooltip_hover_circle div {
|
|
71
71
|
font-size: 12px;
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
.cm-panel.cm-search {
|
|
75
75
|
padding: 5px;
|
|
76
76
|
position: relative;
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
color: var(--vh-color-neutral-04);
|
|
80
80
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
.cm-panels {
|
|
84
84
|
background-color: #333338;
|
|
85
85
|
color: var(--vh-color-neutral-04);
|
|
86
86
|
border: 2px solid var(--vh-color-neutral-02);
|
|
87
87
|
border-radius: 6px;
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
.cm-textfield {
|
|
91
91
|
background-color: var(--vh-color-neutral-01);
|
|
92
92
|
color: #efe7dc;
|
|
@@ -95,10 +95,10 @@
|
|
|
95
95
|
border-radius: 6px;
|
|
96
96
|
font-size: 14px;
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
.cm-button {
|
|
100
100
|
background-color: var(--vh-color-neutral-01);
|
|
101
|
-
|
|
101
|
+
border: 1px solid #193350;
|
|
102
102
|
color: var(--vh-color-neutral-04);
|
|
103
103
|
border: 1px solid var(--vh-color-neutral-04);
|
|
104
104
|
border-radius: 5px;
|
|
@@ -107,50 +107,50 @@
|
|
|
107
107
|
cursor: pointer;
|
|
108
108
|
transition: all 0.3s ease-in-out;
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
.cm-button:hover {
|
|
112
112
|
background-color: #50c878;
|
|
113
113
|
color: #ffffff;
|
|
114
114
|
transform: scale(1.1);
|
|
115
115
|
}
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
.cm-button:active {
|
|
118
118
|
background-color: #202e46;
|
|
119
119
|
transform: scale(0.95);
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
.cm-searchMatch {
|
|
123
123
|
background-color: rgba(255, 255, 0, 0.5);
|
|
124
124
|
border-radius: 2px;
|
|
125
125
|
}
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
.cm-searchMatch-selected {
|
|
128
128
|
background-color: rgba(255, 140, 0, 0.5);
|
|
129
129
|
border: 2px solid #ff8800;
|
|
130
130
|
border-radius: 2px;
|
|
131
131
|
}
|
|
132
|
-
.cm-panel.cm-search [name=
|
|
132
|
+
.cm-panel.cm-search [name='close'] {
|
|
133
133
|
position: absolute;
|
|
134
134
|
top: 0;
|
|
135
135
|
right: 4px;
|
|
136
|
-
background-color: var(--vh-color-neutral-01);
|
|
136
|
+
background-color: var(--vh-color-neutral-01);
|
|
137
137
|
color: var(--vh-color-neutral-04);
|
|
138
|
-
border: none;
|
|
139
|
-
font: inherit;
|
|
140
|
-
padding: 4px 8px;
|
|
138
|
+
border: none;
|
|
139
|
+
font: inherit;
|
|
140
|
+
padding: 4px 8px;
|
|
141
141
|
margin: 4px;
|
|
142
|
-
border-radius: 4px;
|
|
143
|
-
cursor: pointer;
|
|
144
|
-
transition: all 0.3s ease-in-out;
|
|
142
|
+
border-radius: 4px;
|
|
143
|
+
cursor: pointer;
|
|
144
|
+
transition: all 0.3s ease-in-out;
|
|
145
145
|
}
|
|
146
|
-
|
|
147
|
-
.cm-panel.cm-search [name=
|
|
148
|
-
background-color: var(--vh-color-caution-01);
|
|
149
|
-
color: #ffffff;
|
|
146
|
+
|
|
147
|
+
.cm-panel.cm-search [name='close']:hover {
|
|
148
|
+
background-color: var(--vh-color-caution-01);
|
|
149
|
+
color: #ffffff;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
.cm-panel.cm-search [name=
|
|
153
|
-
background-color: var(--vh-color-caution-02);
|
|
154
|
-
transform: scale(0.95);
|
|
151
|
+
|
|
152
|
+
.cm-panel.cm-search [name='close']:active {
|
|
153
|
+
background-color: var(--vh-color-caution-02);
|
|
154
|
+
transform: scale(0.95);
|
|
155
155
|
}
|
|
156
|
-
}
|
|
156
|
+
}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useCallback,
|
|
3
|
+
useContext,
|
|
4
|
+
useEffect,
|
|
5
|
+
useState,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import { PlaySVG } from '../Icons';
|
|
3
8
|
import { SplitEditorSVG } from '../Icons/SplitEditorSVG';
|
|
4
9
|
import { VZCodeContext } from '../VZCodeContext';
|
|
@@ -17,7 +22,7 @@ export const RunCodeWidget = ({
|
|
|
17
22
|
</>
|
|
18
23
|
),
|
|
19
24
|
}: {
|
|
20
|
-
|
|
25
|
+
runCodeWidgetTooltipText?: JSX.Element;
|
|
21
26
|
}) => {
|
|
22
27
|
const { runCodeRef, runPrettierRef, splitCurrentPane } =
|
|
23
28
|
useContext(VZCodeContext);
|
|
@@ -51,7 +56,10 @@ export const RunCodeWidget = ({
|
|
|
51
56
|
// Add the keyboard event listener for Ctrl+S and Shift+Enter
|
|
52
57
|
useEffect(() => {
|
|
53
58
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
54
|
-
if (
|
|
59
|
+
if (
|
|
60
|
+
(event.ctrlKey && event.key === 's') ||
|
|
61
|
+
(event.shiftKey && event.key === 'Enter')
|
|
62
|
+
) {
|
|
55
63
|
event.preventDefault();
|
|
56
64
|
handleClick();
|
|
57
65
|
}
|