v1.0.0
This commit is contained in:
@@ -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