tetrons 2.3.78 → 2.3.79
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/index.cjs +61 -3
- package/dist/index.mjs +61 -3
- package/dist/styles/tetrons.css +21 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -102,7 +102,12 @@ var init_CodeEditorModal = __esm({
|
|
|
102
102
|
"use client";
|
|
103
103
|
import_react20 = __toESM(require("react"));
|
|
104
104
|
import_react21 = __toESM(require("@monaco-editor/react"));
|
|
105
|
-
CodeEditorModal = ({
|
|
105
|
+
CodeEditorModal = ({
|
|
106
|
+
isOpen,
|
|
107
|
+
onClose,
|
|
108
|
+
onSubmitCode,
|
|
109
|
+
onSubmitCodeWithOutput
|
|
110
|
+
}) => {
|
|
106
111
|
const [language, setLanguage] = (0, import_react20.useState)("javascript");
|
|
107
112
|
const [code, setCode] = (0, import_react20.useState)("// Write your code here");
|
|
108
113
|
const [output, setOutput] = (0, import_react20.useState)("");
|
|
@@ -129,6 +134,18 @@ ${data.stderr}
|
|
|
129
134
|
}
|
|
130
135
|
setLoading(false);
|
|
131
136
|
};
|
|
137
|
+
const handleSubmitCode = () => {
|
|
138
|
+
if (onSubmitCode) {
|
|
139
|
+
onSubmitCode(code);
|
|
140
|
+
}
|
|
141
|
+
onClose();
|
|
142
|
+
};
|
|
143
|
+
const handleSubmitCodeWithOutput = () => {
|
|
144
|
+
if (onSubmitCodeWithOutput) {
|
|
145
|
+
onSubmitCodeWithOutput({ code, output });
|
|
146
|
+
}
|
|
147
|
+
onClose();
|
|
148
|
+
};
|
|
132
149
|
if (!isOpen) return null;
|
|
133
150
|
return /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-modal-overlay" }, /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-modal-content" }, /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-modal-header" }, /* @__PURE__ */ import_react20.default.createElement("h2", null, "Run Code"), /* @__PURE__ */ import_react20.default.createElement("button", { onClick: onClose, className: "code-close-btn" }, "\xD7")), /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-modal-controls" }, /* @__PURE__ */ import_react20.default.createElement("label", { htmlFor: "language" }, "Language:"), /* @__PURE__ */ import_react20.default.createElement(
|
|
134
151
|
"select",
|
|
@@ -151,7 +168,23 @@ ${data.stderr}
|
|
|
151
168
|
value: code,
|
|
152
169
|
onChange: (v) => setCode(v ?? "")
|
|
153
170
|
}
|
|
154
|
-
), /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-output" }, /* @__PURE__ */ import_react20.default.createElement("strong", null, "Output:"), /* @__PURE__ */ import_react20.default.createElement("pre", null, output.trim() === "" ? "\u2190 Click Run to see output here" : output))
|
|
171
|
+
), /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-output" }, /* @__PURE__ */ import_react20.default.createElement("strong", null, "Output:"), /* @__PURE__ */ import_react20.default.createElement("pre", null, output.trim() === "" ? "\u2190 Click Run to see output here" : output)), /* @__PURE__ */ import_react20.default.createElement("div", { className: "code-submit-buttons-container" }, /* @__PURE__ */ import_react20.default.createElement(
|
|
172
|
+
"button",
|
|
173
|
+
{
|
|
174
|
+
className: "code-submit-buttons",
|
|
175
|
+
onClick: handleSubmitCode,
|
|
176
|
+
disabled: loading || !code
|
|
177
|
+
},
|
|
178
|
+
"Submit Code Snippet Only"
|
|
179
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
className: "code-submit-buttons",
|
|
183
|
+
onClick: handleSubmitCodeWithOutput,
|
|
184
|
+
disabled: loading || !code
|
|
185
|
+
},
|
|
186
|
+
"Submit Code Snippet With Output"
|
|
187
|
+
))));
|
|
155
188
|
};
|
|
156
189
|
CodeEditorModal_default = CodeEditorModal;
|
|
157
190
|
}
|
|
@@ -16988,6 +17021,29 @@ var AddOnGroup = ({ editor }) => {
|
|
|
16988
17021
|
setModalOpen(false);
|
|
16989
17022
|
setLatexValue("");
|
|
16990
17023
|
};
|
|
17024
|
+
const handleSubmitCode = (code) => {
|
|
17025
|
+
editor.chain().focus().insertContent({
|
|
17026
|
+
type: "codeBlock",
|
|
17027
|
+
content: [{ type: "text", text: code }]
|
|
17028
|
+
}).run();
|
|
17029
|
+
setCodeModalOpen(false);
|
|
17030
|
+
};
|
|
17031
|
+
const handleSubmitCodeWithOutput = ({
|
|
17032
|
+
code,
|
|
17033
|
+
output
|
|
17034
|
+
}) => {
|
|
17035
|
+
editor.chain().focus().insertContent({
|
|
17036
|
+
type: "codeBlock",
|
|
17037
|
+
content: [{ type: "text", text: code }]
|
|
17038
|
+
}).insertContent({
|
|
17039
|
+
type: "paragraph",
|
|
17040
|
+
content: [{ type: "text", text: "Output:" }]
|
|
17041
|
+
}).insertContent({
|
|
17042
|
+
type: "codeBlock",
|
|
17043
|
+
content: [{ type: "text", text: output }]
|
|
17044
|
+
}).run();
|
|
17045
|
+
setCodeModalOpen(false);
|
|
17046
|
+
};
|
|
16991
17047
|
return /* @__PURE__ */ import_react22.default.createElement(import_react22.default.Fragment, null, /* @__PURE__ */ import_react22.default.createElement("div", { className: "group flex gap-2 items-center" }, /* @__PURE__ */ import_react22.default.createElement(
|
|
16992
17048
|
"button",
|
|
16993
17049
|
{
|
|
@@ -17019,7 +17075,9 @@ var AddOnGroup = ({ editor }) => {
|
|
|
17019
17075
|
CodeEditorModal2,
|
|
17020
17076
|
{
|
|
17021
17077
|
isOpen: isCodeModalOpen,
|
|
17022
|
-
onClose: () => setCodeModalOpen(false)
|
|
17078
|
+
onClose: () => setCodeModalOpen(false),
|
|
17079
|
+
onSubmitCode: handleSubmitCode,
|
|
17080
|
+
onSubmitCodeWithOutput: handleSubmitCodeWithOutput
|
|
17023
17081
|
}
|
|
17024
17082
|
));
|
|
17025
17083
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -79,7 +79,12 @@ var init_CodeEditorModal = __esm({
|
|
|
79
79
|
"src/components/tetrons/toolbar/CodeEditorModal.js"() {
|
|
80
80
|
"use strict";
|
|
81
81
|
"use client";
|
|
82
|
-
CodeEditorModal = ({
|
|
82
|
+
CodeEditorModal = ({
|
|
83
|
+
isOpen,
|
|
84
|
+
onClose,
|
|
85
|
+
onSubmitCode,
|
|
86
|
+
onSubmitCodeWithOutput
|
|
87
|
+
}) => {
|
|
83
88
|
const [language, setLanguage] = useState8("javascript");
|
|
84
89
|
const [code, setCode] = useState8("// Write your code here");
|
|
85
90
|
const [output, setOutput] = useState8("");
|
|
@@ -106,6 +111,18 @@ ${data.stderr}
|
|
|
106
111
|
}
|
|
107
112
|
setLoading(false);
|
|
108
113
|
};
|
|
114
|
+
const handleSubmitCode = () => {
|
|
115
|
+
if (onSubmitCode) {
|
|
116
|
+
onSubmitCode(code);
|
|
117
|
+
}
|
|
118
|
+
onClose();
|
|
119
|
+
};
|
|
120
|
+
const handleSubmitCodeWithOutput = () => {
|
|
121
|
+
if (onSubmitCodeWithOutput) {
|
|
122
|
+
onSubmitCodeWithOutput({ code, output });
|
|
123
|
+
}
|
|
124
|
+
onClose();
|
|
125
|
+
};
|
|
109
126
|
if (!isOpen) return null;
|
|
110
127
|
return /* @__PURE__ */ React14.createElement("div", { className: "code-modal-overlay" }, /* @__PURE__ */ React14.createElement("div", { className: "code-modal-content" }, /* @__PURE__ */ React14.createElement("div", { className: "code-modal-header" }, /* @__PURE__ */ React14.createElement("h2", null, "Run Code"), /* @__PURE__ */ React14.createElement("button", { onClick: onClose, className: "code-close-btn" }, "\xD7")), /* @__PURE__ */ React14.createElement("div", { className: "code-modal-controls" }, /* @__PURE__ */ React14.createElement("label", { htmlFor: "language" }, "Language:"), /* @__PURE__ */ React14.createElement(
|
|
111
128
|
"select",
|
|
@@ -128,7 +145,23 @@ ${data.stderr}
|
|
|
128
145
|
value: code,
|
|
129
146
|
onChange: (v) => setCode(v ?? "")
|
|
130
147
|
}
|
|
131
|
-
), /* @__PURE__ */ React14.createElement("div", { className: "code-output" }, /* @__PURE__ */ React14.createElement("strong", null, "Output:"), /* @__PURE__ */ React14.createElement("pre", null, output.trim() === "" ? "\u2190 Click Run to see output here" : output))
|
|
148
|
+
), /* @__PURE__ */ React14.createElement("div", { className: "code-output" }, /* @__PURE__ */ React14.createElement("strong", null, "Output:"), /* @__PURE__ */ React14.createElement("pre", null, output.trim() === "" ? "\u2190 Click Run to see output here" : output)), /* @__PURE__ */ React14.createElement("div", { className: "code-submit-buttons-container" }, /* @__PURE__ */ React14.createElement(
|
|
149
|
+
"button",
|
|
150
|
+
{
|
|
151
|
+
className: "code-submit-buttons",
|
|
152
|
+
onClick: handleSubmitCode,
|
|
153
|
+
disabled: loading || !code
|
|
154
|
+
},
|
|
155
|
+
"Submit Code Snippet Only"
|
|
156
|
+
), /* @__PURE__ */ React14.createElement(
|
|
157
|
+
"button",
|
|
158
|
+
{
|
|
159
|
+
className: "code-submit-buttons",
|
|
160
|
+
onClick: handleSubmitCodeWithOutput,
|
|
161
|
+
disabled: loading || !code
|
|
162
|
+
},
|
|
163
|
+
"Submit Code Snippet With Output"
|
|
164
|
+
))));
|
|
132
165
|
};
|
|
133
166
|
CodeEditorModal_default = CodeEditorModal;
|
|
134
167
|
}
|
|
@@ -16998,6 +17031,29 @@ var AddOnGroup = ({ editor }) => {
|
|
|
16998
17031
|
setModalOpen(false);
|
|
16999
17032
|
setLatexValue("");
|
|
17000
17033
|
};
|
|
17034
|
+
const handleSubmitCode = (code) => {
|
|
17035
|
+
editor.chain().focus().insertContent({
|
|
17036
|
+
type: "codeBlock",
|
|
17037
|
+
content: [{ type: "text", text: code }]
|
|
17038
|
+
}).run();
|
|
17039
|
+
setCodeModalOpen(false);
|
|
17040
|
+
};
|
|
17041
|
+
const handleSubmitCodeWithOutput = ({
|
|
17042
|
+
code,
|
|
17043
|
+
output
|
|
17044
|
+
}) => {
|
|
17045
|
+
editor.chain().focus().insertContent({
|
|
17046
|
+
type: "codeBlock",
|
|
17047
|
+
content: [{ type: "text", text: code }]
|
|
17048
|
+
}).insertContent({
|
|
17049
|
+
type: "paragraph",
|
|
17050
|
+
content: [{ type: "text", text: "Output:" }]
|
|
17051
|
+
}).insertContent({
|
|
17052
|
+
type: "codeBlock",
|
|
17053
|
+
content: [{ type: "text", text: output }]
|
|
17054
|
+
}).run();
|
|
17055
|
+
setCodeModalOpen(false);
|
|
17056
|
+
};
|
|
17001
17057
|
return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement("div", { className: "group flex gap-2 items-center" }, /* @__PURE__ */ React15.createElement(
|
|
17002
17058
|
"button",
|
|
17003
17059
|
{
|
|
@@ -17029,7 +17085,9 @@ var AddOnGroup = ({ editor }) => {
|
|
|
17029
17085
|
CodeEditorModal2,
|
|
17030
17086
|
{
|
|
17031
17087
|
isOpen: isCodeModalOpen,
|
|
17032
|
-
onClose: () => setCodeModalOpen(false)
|
|
17088
|
+
onClose: () => setCodeModalOpen(false),
|
|
17089
|
+
onSubmitCode: handleSubmitCode,
|
|
17090
|
+
onSubmitCodeWithOutput: handleSubmitCodeWithOutput
|
|
17033
17091
|
}
|
|
17034
17092
|
));
|
|
17035
17093
|
};
|
package/dist/styles/tetrons.css
CHANGED
|
@@ -668,3 +668,24 @@
|
|
|
668
668
|
opacity: 0.6;
|
|
669
669
|
cursor: not-allowed;
|
|
670
670
|
}
|
|
671
|
+
|
|
672
|
+
.code-submit-buttons-container{
|
|
673
|
+
display: flex;
|
|
674
|
+
justify-content: space-between;
|
|
675
|
+
gap: 10px;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
.code-submit-buttons{
|
|
679
|
+
background-color: black;
|
|
680
|
+
color: white;
|
|
681
|
+
padding: 16px;
|
|
682
|
+
border: none;
|
|
683
|
+
border-radius: 4px;
|
|
684
|
+
cursor: pointer;
|
|
685
|
+
font-size: 14px;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
.code-submit-buttons:disabled {
|
|
689
|
+
opacity: 0.6;
|
|
690
|
+
cursor: not-allowed;
|
|
691
|
+
}
|