@examind/block-sdk 0.1.33 → 0.1.35
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.js +11 -14
- package/dist/index.mjs +11 -14
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -686,8 +686,9 @@ var SimulationQuestionNodeHandler = class extends NodeHandler {
|
|
|
686
686
|
if (!isSerializedSimulationQuestionNode(node)) return null;
|
|
687
687
|
const aiChatModelAttr = node.aiChatModel ? ` data-x-ai-chat-model="${node.aiChatModel}"` : "";
|
|
688
688
|
const aiSystemMessage = node.aiSystemMessage ? `<x-ai-system-message>${node.aiSystemMessage}</x-ai-system-message>` : "";
|
|
689
|
-
const
|
|
690
|
-
|
|
689
|
+
const disableChatAttr = node.disableChat ? ` data-x-disable-chat="true"` : "";
|
|
690
|
+
const commentInstructions = node.commentInstructions ? `<x-comment-instructions>${node.commentInstructions}</x-comment-instructions>` : "";
|
|
691
|
+
return `<x-simulation id="${node.id}" data-x-prompt data-x-points="${node.points}"${aiChatModelAttr}${disableChatAttr}>${aiSystemMessage}${commentInstructions}</x-simulation>`;
|
|
691
692
|
}
|
|
692
693
|
};
|
|
693
694
|
|
|
@@ -1919,7 +1920,9 @@ var ShortAnswerQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
|
1919
1920
|
var import_node_html_parser21 = require("node-html-parser");
|
|
1920
1921
|
var TAG_X_SIMULATION = "x-simulation";
|
|
1921
1922
|
var TAG_X_SYSTEM_MESSAGE2 = "x-ai-system-message";
|
|
1923
|
+
var TAG_X_COMMENT_INSTRUCTIONS = "x-comment-instructions";
|
|
1922
1924
|
var TAG_X_STEP2_INSTRUCTIONS = "x-step2-instructions";
|
|
1925
|
+
var findFirstNonEmptyInnerHtml = (root, elementNames) => elementNames.map((name) => root.querySelector(name)).find((el) => el?.innerHTML.trim().length)?.innerHTML.trim() ?? null;
|
|
1923
1926
|
var SimulationQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
1924
1927
|
processNode(node) {
|
|
1925
1928
|
if (!(node instanceof import_node_html_parser21.HTMLElement) || node.tagName !== TAG_X_SIMULATION.toUpperCase()) {
|
|
@@ -1929,21 +1932,15 @@ var SimulationQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
|
1929
1932
|
id: node.getAttribute("id") || "",
|
|
1930
1933
|
points: Number(node.getAttribute("data-x-points") || 0),
|
|
1931
1934
|
aiChatModel: node.getAttribute("data-x-ai-chat-model") || null,
|
|
1932
|
-
|
|
1933
|
-
|
|
1935
|
+
aiSystemMessage: findFirstNonEmptyInnerHtml(node, [TAG_X_SYSTEM_MESSAGE2]) ?? "",
|
|
1936
|
+
disableChat: node.getAttribute("data-x-disable-chat") === "true",
|
|
1937
|
+
commentInstructions: findFirstNonEmptyInnerHtml(node, [
|
|
1938
|
+
TAG_X_COMMENT_INSTRUCTIONS,
|
|
1939
|
+
TAG_X_STEP2_INSTRUCTIONS
|
|
1940
|
+
]) ?? "",
|
|
1934
1941
|
type: "simulation-question",
|
|
1935
1942
|
version: 1
|
|
1936
1943
|
};
|
|
1937
|
-
const systemMessageElement = node.querySelector(
|
|
1938
|
-
TAG_X_SYSTEM_MESSAGE2
|
|
1939
|
-
);
|
|
1940
|
-
if (systemMessageElement)
|
|
1941
|
-
jsonNode.aiSystemMessage = systemMessageElement.innerHTML;
|
|
1942
|
-
const step2InstructionsElement = node.querySelector(
|
|
1943
|
-
TAG_X_STEP2_INSTRUCTIONS
|
|
1944
|
-
);
|
|
1945
|
-
if (step2InstructionsElement)
|
|
1946
|
-
jsonNode.step2Instructions = step2InstructionsElement.innerHTML;
|
|
1947
1944
|
return jsonNode;
|
|
1948
1945
|
}
|
|
1949
1946
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -659,8 +659,9 @@ var SimulationQuestionNodeHandler = class extends NodeHandler {
|
|
|
659
659
|
if (!isSerializedSimulationQuestionNode(node)) return null;
|
|
660
660
|
const aiChatModelAttr = node.aiChatModel ? ` data-x-ai-chat-model="${node.aiChatModel}"` : "";
|
|
661
661
|
const aiSystemMessage = node.aiSystemMessage ? `<x-ai-system-message>${node.aiSystemMessage}</x-ai-system-message>` : "";
|
|
662
|
-
const
|
|
663
|
-
|
|
662
|
+
const disableChatAttr = node.disableChat ? ` data-x-disable-chat="true"` : "";
|
|
663
|
+
const commentInstructions = node.commentInstructions ? `<x-comment-instructions>${node.commentInstructions}</x-comment-instructions>` : "";
|
|
664
|
+
return `<x-simulation id="${node.id}" data-x-prompt data-x-points="${node.points}"${aiChatModelAttr}${disableChatAttr}>${aiSystemMessage}${commentInstructions}</x-simulation>`;
|
|
664
665
|
}
|
|
665
666
|
};
|
|
666
667
|
|
|
@@ -1892,7 +1893,9 @@ var ShortAnswerQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
|
1892
1893
|
import { HTMLElement as HTMLElement21 } from "node-html-parser";
|
|
1893
1894
|
var TAG_X_SIMULATION = "x-simulation";
|
|
1894
1895
|
var TAG_X_SYSTEM_MESSAGE2 = "x-ai-system-message";
|
|
1896
|
+
var TAG_X_COMMENT_INSTRUCTIONS = "x-comment-instructions";
|
|
1895
1897
|
var TAG_X_STEP2_INSTRUCTIONS = "x-step2-instructions";
|
|
1898
|
+
var findFirstNonEmptyInnerHtml = (root, elementNames) => elementNames.map((name) => root.querySelector(name)).find((el) => el?.innerHTML.trim().length)?.innerHTML.trim() ?? null;
|
|
1896
1899
|
var SimulationQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
1897
1900
|
processNode(node) {
|
|
1898
1901
|
if (!(node instanceof HTMLElement21) || node.tagName !== TAG_X_SIMULATION.toUpperCase()) {
|
|
@@ -1902,21 +1905,15 @@ var SimulationQuestionNodeHandler2 = class extends NodeHandler2 {
|
|
|
1902
1905
|
id: node.getAttribute("id") || "",
|
|
1903
1906
|
points: Number(node.getAttribute("data-x-points") || 0),
|
|
1904
1907
|
aiChatModel: node.getAttribute("data-x-ai-chat-model") || null,
|
|
1905
|
-
|
|
1906
|
-
|
|
1908
|
+
aiSystemMessage: findFirstNonEmptyInnerHtml(node, [TAG_X_SYSTEM_MESSAGE2]) ?? "",
|
|
1909
|
+
disableChat: node.getAttribute("data-x-disable-chat") === "true",
|
|
1910
|
+
commentInstructions: findFirstNonEmptyInnerHtml(node, [
|
|
1911
|
+
TAG_X_COMMENT_INSTRUCTIONS,
|
|
1912
|
+
TAG_X_STEP2_INSTRUCTIONS
|
|
1913
|
+
]) ?? "",
|
|
1907
1914
|
type: "simulation-question",
|
|
1908
1915
|
version: 1
|
|
1909
1916
|
};
|
|
1910
|
-
const systemMessageElement = node.querySelector(
|
|
1911
|
-
TAG_X_SYSTEM_MESSAGE2
|
|
1912
|
-
);
|
|
1913
|
-
if (systemMessageElement)
|
|
1914
|
-
jsonNode.aiSystemMessage = systemMessageElement.innerHTML;
|
|
1915
|
-
const step2InstructionsElement = node.querySelector(
|
|
1916
|
-
TAG_X_STEP2_INSTRUCTIONS
|
|
1917
|
-
);
|
|
1918
|
-
if (step2InstructionsElement)
|
|
1919
|
-
jsonNode.step2Instructions = step2InstructionsElement.innerHTML;
|
|
1920
1917
|
return jsonNode;
|
|
1921
1918
|
}
|
|
1922
1919
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@examind/block-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"@comment version": [
|
|
5
5
|
"Don't specify package version here. It will be injected by publish workflow."
|
|
6
6
|
],
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"nanoid": ">=3.0.0",
|
|
23
23
|
"node-html-parser": ">=6.0.0",
|
|
24
|
-
"@examind/block-types": "^0.1.
|
|
24
|
+
"@examind/block-types": "^0.1.35"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@eslint/js": "^9.17.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"tsup": "^8.3.5",
|
|
37
37
|
"typescript": "^5.7.2",
|
|
38
38
|
"typescript-eslint": "^8.18.2",
|
|
39
|
-
"@examind/block-types": "0.1.
|
|
39
|
+
"@examind/block-types": "0.1.35"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"lodash-es": "4.17.21"
|