@examind/block-sdk 0.1.37 → 0.1.39

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 CHANGED
@@ -80,7 +80,7 @@ var NodeHandler = class {
80
80
  var CustomQuestionNodeHandler = class extends NodeHandler {
81
81
  processNode(node) {
82
82
  if (!isSerializedCustomQuestionNode(node)) return null;
83
- return `<x-custom id="${node.id}" data-x-prompt data-x-points="${node.points}" data-x-name="${node.name}"></x-custom>`;
83
+ return `<x-custom id="${node.id}" data-x-prompt data-x-points="${node.points}" data-x-name="${node.name}"><x-data>${node.data ? node.data : "{}"}</x-data></x-custom>`;
84
84
  }
85
85
  };
86
86
 
@@ -218,13 +218,33 @@ var FinancialStatementQuestionNodeHandler = class extends NodeHandler {
218
218
  return `<x-financial-statement id="${node.id}" data-x-prompt data-x-points="${node.points}">${children.join("")}</x-financial-statement>`;
219
219
  }
220
220
  processHeaderSection(node) {
221
+ return node.columnHeaders.length < 2 ? this.processSimpleHeaderSection(node) : this.processColumnHeaderSection(node);
222
+ }
223
+ processSimpleHeaderSection(node) {
221
224
  return `<x-header>${createHtmlFromNestedEditor(node.header, {
222
225
  parentNode: node
223
- })}${this.processColumnHeadersSection(node)}</x-header>`;
224
- }
225
- processColumnHeadersSection(node) {
226
- if (node.columnHeaders.length < 2) return "";
227
- return `<div style="display:flex; width:100%; margin-top: 16px;"><div style="flex:1; font-weight:bold; text-align:left;">${node.columnHeaders[0]}</div><div style="flex:1; font-weight:bold; text-align:right;">${node.columnHeaders[1]}</div></div>`;
226
+ })}</x-header>`;
227
+ }
228
+ processColumnHeaderSection(node) {
229
+ return [
230
+ "<x-header>",
231
+ '<div style="text-align: left; font-weight: normal;">',
232
+ "<div>",
233
+ createHtmlFromNestedEditor(node.header, {
234
+ parentNode: node
235
+ }),
236
+ "</div>",
237
+ '<div style="display:flex; width:100%; margin-top: 16px;">',
238
+ '<div style="flex:1; font-weight:bold;">',
239
+ node.columnHeaders[0],
240
+ "</div>",
241
+ '<div style="flex:1; font-weight:bold; text-align:right;">',
242
+ node.columnHeaders[1],
243
+ "</div>",
244
+ "</div>",
245
+ "</div>",
246
+ "</x-header>"
247
+ ].join("");
228
248
  }
229
249
  processRowsSection(node) {
230
250
  const rowElements = [];
@@ -1030,7 +1050,7 @@ var CustomQuestionNodeHandler2 = class extends NodeHandler2 {
1030
1050
  id: node.getAttribute("id") || "",
1031
1051
  points: Number(node.getAttribute("data-x-points") || 1),
1032
1052
  name: node.getAttribute("data-x-name") || "",
1033
- data: "",
1053
+ data: node.querySelector("x-data")?.innerHTML || "{}",
1034
1054
  type: "custom-question",
1035
1055
  version: 1
1036
1056
  };
@@ -1414,11 +1434,8 @@ var FinancialStatementQuestionNodeHandler2 = class extends NodeHandler2 {
1414
1434
  const contentDiv = headerElement.querySelector(
1415
1435
  'div > div:not([style*="display:flex"])'
1416
1436
  );
1417
- if (contentDiv && contentDiv instanceof import_node_html_parser7.HTMLElement) {
1418
- const contentDivClone = contentDiv.clone();
1419
- contentDivClone.setAttribute("style", "text-align: left;");
1420
- return createNestedEditorFromHtml(contentDivClone);
1421
- }
1437
+ if (contentDiv && contentDiv instanceof import_node_html_parser7.HTMLElement)
1438
+ return createNestedEditorFromHtml(contentDiv);
1422
1439
  }
1423
1440
  return createNestedEditorFromHtml(headerElement);
1424
1441
  }
package/dist/index.mjs CHANGED
@@ -53,7 +53,7 @@ var NodeHandler = class {
53
53
  var CustomQuestionNodeHandler = class extends NodeHandler {
54
54
  processNode(node) {
55
55
  if (!isSerializedCustomQuestionNode(node)) return null;
56
- return `<x-custom id="${node.id}" data-x-prompt data-x-points="${node.points}" data-x-name="${node.name}"></x-custom>`;
56
+ return `<x-custom id="${node.id}" data-x-prompt data-x-points="${node.points}" data-x-name="${node.name}"><x-data>${node.data ? node.data : "{}"}</x-data></x-custom>`;
57
57
  }
58
58
  };
59
59
 
@@ -191,13 +191,33 @@ var FinancialStatementQuestionNodeHandler = class extends NodeHandler {
191
191
  return `<x-financial-statement id="${node.id}" data-x-prompt data-x-points="${node.points}">${children.join("")}</x-financial-statement>`;
192
192
  }
193
193
  processHeaderSection(node) {
194
+ return node.columnHeaders.length < 2 ? this.processSimpleHeaderSection(node) : this.processColumnHeaderSection(node);
195
+ }
196
+ processSimpleHeaderSection(node) {
194
197
  return `<x-header>${createHtmlFromNestedEditor(node.header, {
195
198
  parentNode: node
196
- })}${this.processColumnHeadersSection(node)}</x-header>`;
197
- }
198
- processColumnHeadersSection(node) {
199
- if (node.columnHeaders.length < 2) return "";
200
- return `<div style="display:flex; width:100%; margin-top: 16px;"><div style="flex:1; font-weight:bold; text-align:left;">${node.columnHeaders[0]}</div><div style="flex:1; font-weight:bold; text-align:right;">${node.columnHeaders[1]}</div></div>`;
199
+ })}</x-header>`;
200
+ }
201
+ processColumnHeaderSection(node) {
202
+ return [
203
+ "<x-header>",
204
+ '<div style="text-align: left; font-weight: normal;">',
205
+ "<div>",
206
+ createHtmlFromNestedEditor(node.header, {
207
+ parentNode: node
208
+ }),
209
+ "</div>",
210
+ '<div style="display:flex; width:100%; margin-top: 16px;">',
211
+ '<div style="flex:1; font-weight:bold;">',
212
+ node.columnHeaders[0],
213
+ "</div>",
214
+ '<div style="flex:1; font-weight:bold; text-align:right;">',
215
+ node.columnHeaders[1],
216
+ "</div>",
217
+ "</div>",
218
+ "</div>",
219
+ "</x-header>"
220
+ ].join("");
201
221
  }
202
222
  processRowsSection(node) {
203
223
  const rowElements = [];
@@ -1003,7 +1023,7 @@ var CustomQuestionNodeHandler2 = class extends NodeHandler2 {
1003
1023
  id: node.getAttribute("id") || "",
1004
1024
  points: Number(node.getAttribute("data-x-points") || 1),
1005
1025
  name: node.getAttribute("data-x-name") || "",
1006
- data: "",
1026
+ data: node.querySelector("x-data")?.innerHTML || "{}",
1007
1027
  type: "custom-question",
1008
1028
  version: 1
1009
1029
  };
@@ -1387,11 +1407,8 @@ var FinancialStatementQuestionNodeHandler2 = class extends NodeHandler2 {
1387
1407
  const contentDiv = headerElement.querySelector(
1388
1408
  'div > div:not([style*="display:flex"])'
1389
1409
  );
1390
- if (contentDiv && contentDiv instanceof HTMLElement7) {
1391
- const contentDivClone = contentDiv.clone();
1392
- contentDivClone.setAttribute("style", "text-align: left;");
1393
- return createNestedEditorFromHtml(contentDivClone);
1394
- }
1410
+ if (contentDiv && contentDiv instanceof HTMLElement7)
1411
+ return createNestedEditorFromHtml(contentDiv);
1395
1412
  }
1396
1413
  return createNestedEditorFromHtml(headerElement);
1397
1414
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@examind/block-sdk",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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.37"
24
+ "@examind/block-types": "^0.1.39"
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.37"
39
+ "@examind/block-types": "0.1.39"
40
40
  },
41
41
  "dependencies": {
42
42
  "lodash-es": "4.17.21"