v1.0.0
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
# TODO
|
||||
|
||||
- [ ] Support multiple input type in a question
|
||||
- [ ] Support special text input
|
||||
- [ ] Support drag and drop quiz
|
||||
- [ ] Support media for gpt-4
|
||||
|
||||
+26
-2
@@ -124,7 +124,8 @@
|
||||
const lineSeparationSize = maxColumnsLength.reduce((a, b) => a + b) + tab[0].length + 1;
|
||||
const lineSeparation = "\n" + Array(lineSeparationSize).fill("-").join("") + "\n";
|
||||
const mappedTab = tab.map((line) => {
|
||||
const mappedLine = line.map((content, index) => content.padEnd(maxColumnsLength[index], "\u00A0"));
|
||||
const mappedLine = line.map((content, index) => content.padEnd(maxColumnsLength[index], "\u00A0") //for no matching with \s
|
||||
);
|
||||
return "|" + mappedLine.join("|") + "|";
|
||||
});
|
||||
return lineSeparation + mappedTab.join(lineSeparation) + lineSeparation;
|
||||
@@ -323,6 +324,28 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
function handleContentEditable(config, inputList, response) {
|
||||
const input = inputList[0];
|
||||
if (inputList.length !== 1 ||
|
||||
input.getAttribute("contenteditable") !== "true")
|
||||
return false;
|
||||
if (config.typing) {
|
||||
let index = 0;
|
||||
input.addEventListener("keydown", function (event) {
|
||||
if (event.key === "Backspace")
|
||||
index = response.length + 1;
|
||||
if (index > response.length)
|
||||
return;
|
||||
event.preventDefault();
|
||||
input.textContent = response.slice(0, ++index);
|
||||
});
|
||||
}
|
||||
else {
|
||||
input.textContent = response;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to the question
|
||||
* @param config
|
||||
@@ -353,6 +376,7 @@
|
||||
Logs.response(response);
|
||||
}
|
||||
const handlers = [
|
||||
handleContentEditable,
|
||||
handleTextbox,
|
||||
handleNumber,
|
||||
handleSelect,
|
||||
@@ -405,7 +429,7 @@
|
||||
const inputQuery = ["checkbox", "radio", "text", "number"]
|
||||
.map((e) => `input[type="${e}"]`)
|
||||
.join(",");
|
||||
const query = inputQuery + ", textarea, select";
|
||||
const query = inputQuery + ", textarea, select, [contenteditable]";
|
||||
const forms = Array.from(document.querySelectorAll(".formulation"));
|
||||
for (const form of forms) {
|
||||
const hiddenButton = form.querySelector(".qtext");
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -44,7 +44,7 @@ function setUpMoodleGpt(config: Config) {
|
||||
const inputQuery = ["checkbox", "radio", "text", "number"]
|
||||
.map((e) => `input[type="${e}"]`)
|
||||
.join(",");
|
||||
const query = inputQuery + ", textarea, select";
|
||||
const query = inputQuery + ", textarea, select, [contenteditable]";
|
||||
const forms = Array.from(document.querySelectorAll(".formulation"));
|
||||
|
||||
for (const form of forms) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import Config from "../../types/config";
|
||||
|
||||
function handleContentEditable(
|
||||
config: Config,
|
||||
inputList: NodeListOf<HTMLElement>,
|
||||
response: string
|
||||
): boolean {
|
||||
const input = inputList[0];
|
||||
|
||||
if (
|
||||
inputList.length !== 1 ||
|
||||
input.getAttribute("contenteditable") !== "true"
|
||||
)
|
||||
return false;
|
||||
|
||||
if (config.typing) {
|
||||
let index = 0;
|
||||
input.addEventListener("keydown", function (event: KeyboardEvent) {
|
||||
if (event.key === "Backspace") index = response.length + 1;
|
||||
if (index > response.length) return;
|
||||
event.preventDefault();
|
||||
input.textContent = response.slice(0, ++index);
|
||||
});
|
||||
} else {
|
||||
input.textContent = response;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export default handleContentEditable;
|
||||
@@ -7,6 +7,7 @@ import handleSelect from "./questions/select";
|
||||
import handleTextbox from "./questions/textbox";
|
||||
import handleClipboard from "./questions/clipboard";
|
||||
import handleNumber from "./questions/number";
|
||||
import handleContentEditable from "./questions/contenteditable";
|
||||
|
||||
/**
|
||||
* Reply to the question
|
||||
@@ -49,6 +50,7 @@ async function reply(
|
||||
}
|
||||
|
||||
const handlers = [
|
||||
handleContentEditable,
|
||||
handleTextbox,
|
||||
handleNumber,
|
||||
handleSelect,
|
||||
|
||||
Reference in New Issue
Block a user