@examind/block-sdk 0.2.2 → 0.2.4

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
@@ -114,6 +114,56 @@ function isSerializedParagraphNode(node) {
114
114
  return node?.type === "paragraph" && "textFormat" in node && typeof node.textFormat === "number" && "textStyle" in node && typeof node.textStyle === "string";
115
115
  }
116
116
 
117
+ // src/typeGuards/isSerializedFillInTheBlankQuestionNode.ts
118
+ function isSerializedFillInTheBlankQuestionNode(node) {
119
+ return node?.type === "fill-in-the-blank-question" && "id" in node && typeof node.id === "string" && "pointsPerSpace" in node && typeof node.pointsPerSpace === "number" && "content" in node;
120
+ }
121
+
122
+ // src/typeGuards/isSerializedFinancialStatementQuestionNode.ts
123
+ function isSerializedFinancialStatementQuestionNode(node) {
124
+ return node?.type === "financial-statement-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "header" in node && "columnHeaders" in node && Array.isArray(node.columnHeaders) && "rows" in node && Array.isArray(node.rows) && "distractors" in node && Array.isArray(node.distractors);
125
+ }
126
+
127
+ // src/typeGuards/isSerializedImageNode.ts
128
+ var isSerializedImageNode = (node) => {
129
+ return node?.type === "image" && "altText" in node && typeof node.altText === "string" && "caption" in node && "showCaption" in node && typeof node.showCaption === "boolean" && "src" in node && typeof node.src === "string" && "width" in node && typeof node.width === "string" && "align" in node && typeof node.align === "string" && "showBorder" in node && typeof node.showBorder === "boolean";
130
+ };
131
+
132
+ // src/typeGuards/isSerializedJournalEntryQuestionNode.ts
133
+ function isSerializedJournalEntryQuestionNode(node) {
134
+ return node?.type === "journal-entry-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "lineItems" in node && Array.isArray(node.lineItems);
135
+ }
136
+
137
+ // src/typeGuards/isSerializedMatchingQuestionNode.ts
138
+ function isSerializedMatchingQuestionNode(node) {
139
+ return node?.type === "matching-question" && "id" in node && typeof node.id === "string" && "pointsPerMatch" in node && typeof node.pointsPerMatch === "number" && "items" in node && Array.isArray(node.items);
140
+ }
141
+
142
+ // src/typeGuards/isSerializedMultipleOptionQuestionNode.ts
143
+ function isSerializedMultipleOptionQuestionNode(node) {
144
+ return node?.type === "multiple-option-question" && "id" in node && typeof node.id === "string" && "questionType" in node && typeof node.questionType === "string" && "points" in node && typeof node.points === "number" && "options" in node && Array.isArray(node.options);
145
+ }
146
+
147
+ // src/typeGuards/isSerializedShortAnswerQuestionNode.ts
148
+ function isSerializedShortAnswerQuestionNode(node) {
149
+ return node?.type === "short-answer-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "maxWords" in node && typeof node.maxWords === "number" && "notes" in node;
150
+ }
151
+
152
+ // src/typeGuards/isSerializedTableCellNode.ts
153
+ function isSerializedTableCellNode(node) {
154
+ return node?.type === "tablecell" && "headerState" in node && typeof node.headerState === "number";
155
+ }
156
+
157
+ // src/exportToHtml/shouldAvoidWrap.ts
158
+ function shouldAvoidParagraphWrap(parentNode) {
159
+ if (parentNode === void 0) return false;
160
+ return isSerializedFillInTheBlankQuestionNode(parentNode) || isSerializedFinancialStatementQuestionNode(parentNode) || isSerializedJournalEntryQuestionNode(parentNode) || isSerializedMatchingQuestionNode(parentNode) || isSerializedMultipleOptionQuestionNode(parentNode) || isSerializedShortAnswerQuestionNode(parentNode) || isSerializedTableCellNode(parentNode) || isSerializedImageNode(parentNode);
161
+ }
162
+ function shouldAvoidDivWrap(parentNode) {
163
+ if (parentNode === void 0) return false;
164
+ return isSerializedImageNode(parentNode);
165
+ }
166
+
117
167
  // src/exportToHtml/createHtmlFromNestedNodes.ts
118
168
  function createHtmlFromNestedNodes(nodes, metadata) {
119
169
  const children = [];
@@ -122,8 +172,8 @@ function createHtmlFromNestedNodes(nodes, metadata) {
122
172
  const isParagraph = isSerializedParagraphNode(child);
123
173
  const element = traverse(child, metadata);
124
174
  if (element) {
125
- if (prevWasParagraph && isParagraph) {
126
- children.push("<br>");
175
+ if (shouldAvoidParagraphWrap(metadata?.parentNode)) {
176
+ if (prevWasParagraph && isParagraph) children.push("<br>");
127
177
  }
128
178
  children.push(element);
129
179
  prevWasParagraph = isParagraph;
@@ -140,6 +190,12 @@ function createHtmlFromNestedEditor(editor, metadata) {
140
190
  }
141
191
 
142
192
  // src/exportToHtml/ExcelQuestionNodeHandler.ts
193
+ var htmlOrNullIfEmpty = (editor, node) => {
194
+ const html = createHtmlFromNestedEditor(editor, {
195
+ parentNode: node
196
+ });
197
+ return !html || html === "<p></p>" ? null : html;
198
+ };
143
199
  var ExcelQuestionNodeHandler = class extends NodeHandler {
144
200
  processNode(node) {
145
201
  if (!isSerializedExcelQuestionNode(node)) return null;
@@ -147,14 +203,14 @@ var ExcelQuestionNodeHandler = class extends NodeHandler {
147
203
  ...node.data,
148
204
  parts: node.data.parts.map((p) => ({
149
205
  ...p,
150
- objective: createHtmlFromNestedEditor(p.objective),
151
- instructions: createHtmlFromNestedEditor(p.instructions),
206
+ objective: htmlOrNullIfEmpty(p.objective, node),
207
+ instructions: htmlOrNullIfEmpty(p.instructions, node),
152
208
  tasks: p.tasks.map((t) => ({
153
209
  ...t,
154
- instructions: createHtmlFromNestedEditor(t.instructions),
210
+ instructions: htmlOrNullIfEmpty(t.instructions, node),
155
211
  steps: t.steps.map((s) => ({
156
212
  ...s,
157
- description: createHtmlFromNestedEditor(s.description)
213
+ description: htmlOrNullIfEmpty(s.description, node)
158
214
  }))
159
215
  }))
160
216
  }))
@@ -176,11 +232,6 @@ var ExcelWorksheetLinkNodeHandler = class extends NodeHandler {
176
232
  }
177
233
  };
178
234
 
179
- // src/typeGuards/isSerializedFillInTheBlankQuestionNode.ts
180
- function isSerializedFillInTheBlankQuestionNode(node) {
181
- return node?.type === "fill-in-the-blank-question" && "id" in node && typeof node.id === "string" && "pointsPerSpace" in node && typeof node.pointsPerSpace === "number" && "content" in node;
182
- }
183
-
184
235
  // src/exportToHtml/FillInTheBlankQuestionNodeHandler.ts
185
236
  var FillInTheBlankQuestionNodeHandler = class extends NodeHandler {
186
237
  processNode(node) {
@@ -236,11 +287,6 @@ var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
236
287
  }
237
288
  };
238
289
 
239
- // src/typeGuards/isSerializedFinancialStatementQuestionNode.ts
240
- function isSerializedFinancialStatementQuestionNode(node) {
241
- return node?.type === "financial-statement-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "header" in node && "columnHeaders" in node && Array.isArray(node.columnHeaders) && "rows" in node && Array.isArray(node.rows) && "distractors" in node && Array.isArray(node.distractors);
242
- }
243
-
244
290
  // src/exportToHtml/FinancialStatementQuestionNodeHandler.ts
245
291
  var isHeading = (row) => {
246
292
  return row.type === "Heading";
@@ -370,11 +416,6 @@ var HorizontalRuleNodeHandler = class extends NodeHandler {
370
416
  var IMAGE_CONTAINER_ATTRIBUTE = "data-block-image-container";
371
417
  var IMAGE_CONTAINER_CLASS = "block-image-container";
372
418
 
373
- // src/typeGuards/isSerializedImageNode.ts
374
- var isSerializedImageNode = (node) => {
375
- return node?.type === "image" && "altText" in node && typeof node.altText === "string" && "caption" in node && "showCaption" in node && typeof node.showCaption === "boolean" && "src" in node && typeof node.src === "string" && "width" in node && typeof node.width === "string" && "align" in node && typeof node.align === "string" && "showBorder" in node && typeof node.showBorder === "boolean";
376
- };
377
-
378
419
  // src/exportToHtml/ImageNodeHandler.ts
379
420
  var ImageNodeHandler = class extends NodeHandler {
380
421
  alignItemsAttribute(node) {
@@ -445,11 +486,6 @@ var ImageNodeHandler = class extends NodeHandler {
445
486
  }
446
487
  };
447
488
 
448
- // src/typeGuards/isSerializedJournalEntryQuestionNode.ts
449
- function isSerializedJournalEntryQuestionNode(node) {
450
- return node?.type === "journal-entry-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "lineItems" in node && Array.isArray(node.lineItems);
451
- }
452
-
453
489
  // src/exportToHtml/createHtmlFromOnePerLineDistractorNodes.ts
454
490
  function createHtmlFromOnePerLineDistractorNodes(distractorNodes, parentNode) {
455
491
  const distractors = distractorNodes.map((node) => {
@@ -590,11 +626,6 @@ var ListNodeHandler = class extends NodeHandler {
590
626
  }
591
627
  };
592
628
 
593
- // src/typeGuards/isSerializedMatchingQuestionNode.ts
594
- function isSerializedMatchingQuestionNode(node) {
595
- return node?.type === "matching-question" && "id" in node && typeof node.id === "string" && "pointsPerMatch" in node && typeof node.pointsPerMatch === "number" && "items" in node && Array.isArray(node.items);
596
- }
597
-
598
629
  // src/exportToHtml/MatchingQuestionNodeHandler.ts
599
630
  var MatchingQuestionNodeHandler = class extends NodeHandler {
600
631
  processNode(node) {
@@ -631,11 +662,6 @@ var MatchingQuestionNodeHandler = class extends NodeHandler {
631
662
  }
632
663
  };
633
664
 
634
- // src/typeGuards/isSerializedMultipleOptionQuestionNode.ts
635
- function isSerializedMultipleOptionQuestionNode(node) {
636
- return node?.type === "multiple-option-question" && "id" in node && typeof node.id === "string" && "questionType" in node && typeof node.questionType === "string" && "points" in node && typeof node.points === "number" && "options" in node && Array.isArray(node.options);
637
- }
638
-
639
665
  // src/exportToHtml/MultipleOptionQuestionNodeHandler.ts
640
666
  var MultipleOptionQuestionNodeHandler = class extends NodeHandler {
641
667
  processNode(node) {
@@ -695,26 +721,8 @@ var MultipleOptionQuestionNodeHandler = class extends NodeHandler {
695
721
  }
696
722
  };
697
723
 
698
- // src/typeGuards/isSerializedShortAnswerQuestionNode.ts
699
- function isSerializedShortAnswerQuestionNode(node) {
700
- return node?.type === "short-answer-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "maxWords" in node && typeof node.maxWords === "number" && "notes" in node;
701
- }
702
-
703
- // src/typeGuards/isSerializedTableCellNode.ts
704
- function isSerializedTableCellNode(node) {
705
- return node?.type === "tablecell" && "headerState" in node && typeof node.headerState === "number";
706
- }
707
-
708
724
  // src/exportToHtml/ParagraphNodeHandler.ts
709
725
  var ParagraphNodeHandler = class extends NodeHandler {
710
- shouldAvoidParagraphWrap(node) {
711
- if (node === void 0) return false;
712
- return isSerializedFillInTheBlankQuestionNode(node) || isSerializedFinancialStatementQuestionNode(node) || isSerializedJournalEntryQuestionNode(node) || isSerializedMatchingQuestionNode(node) || isSerializedMultipleOptionQuestionNode(node) || isSerializedShortAnswerQuestionNode(node) || isSerializedTableCellNode(node) || isSerializedImageNode(node);
713
- }
714
- shouldAvoidDivWrap(node) {
715
- if (node === void 0) return false;
716
- return isSerializedImageNode(node);
717
- }
718
726
  processNode(node, metadata) {
719
727
  if (!isSerializedParagraphNode(node)) return null;
720
728
  const children = [];
@@ -728,8 +736,8 @@ var ParagraphNodeHandler = class extends NodeHandler {
728
736
  }
729
737
  });
730
738
  const attribute = node.format ? ` style="text-align: ${ELEMENT_TYPE_TO_FORMAT[node.format]};"` : "";
731
- if (this.shouldAvoidParagraphWrap(metadata?.parentNode))
732
- if (attribute && !this.shouldAvoidDivWrap(metadata?.parentNode))
739
+ if (shouldAvoidParagraphWrap(metadata?.parentNode))
740
+ if (attribute && !shouldAvoidDivWrap(metadata?.parentNode))
733
741
  return `<div${attribute}>${children.join("")}</div>`;
734
742
  else return children.join("");
735
743
  return `<p${attribute}>${children.join("")}</p>`;
package/dist/index.mjs CHANGED
@@ -87,6 +87,56 @@ function isSerializedParagraphNode(node) {
87
87
  return node?.type === "paragraph" && "textFormat" in node && typeof node.textFormat === "number" && "textStyle" in node && typeof node.textStyle === "string";
88
88
  }
89
89
 
90
+ // src/typeGuards/isSerializedFillInTheBlankQuestionNode.ts
91
+ function isSerializedFillInTheBlankQuestionNode(node) {
92
+ return node?.type === "fill-in-the-blank-question" && "id" in node && typeof node.id === "string" && "pointsPerSpace" in node && typeof node.pointsPerSpace === "number" && "content" in node;
93
+ }
94
+
95
+ // src/typeGuards/isSerializedFinancialStatementQuestionNode.ts
96
+ function isSerializedFinancialStatementQuestionNode(node) {
97
+ return node?.type === "financial-statement-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "header" in node && "columnHeaders" in node && Array.isArray(node.columnHeaders) && "rows" in node && Array.isArray(node.rows) && "distractors" in node && Array.isArray(node.distractors);
98
+ }
99
+
100
+ // src/typeGuards/isSerializedImageNode.ts
101
+ var isSerializedImageNode = (node) => {
102
+ return node?.type === "image" && "altText" in node && typeof node.altText === "string" && "caption" in node && "showCaption" in node && typeof node.showCaption === "boolean" && "src" in node && typeof node.src === "string" && "width" in node && typeof node.width === "string" && "align" in node && typeof node.align === "string" && "showBorder" in node && typeof node.showBorder === "boolean";
103
+ };
104
+
105
+ // src/typeGuards/isSerializedJournalEntryQuestionNode.ts
106
+ function isSerializedJournalEntryQuestionNode(node) {
107
+ return node?.type === "journal-entry-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "lineItems" in node && Array.isArray(node.lineItems);
108
+ }
109
+
110
+ // src/typeGuards/isSerializedMatchingQuestionNode.ts
111
+ function isSerializedMatchingQuestionNode(node) {
112
+ return node?.type === "matching-question" && "id" in node && typeof node.id === "string" && "pointsPerMatch" in node && typeof node.pointsPerMatch === "number" && "items" in node && Array.isArray(node.items);
113
+ }
114
+
115
+ // src/typeGuards/isSerializedMultipleOptionQuestionNode.ts
116
+ function isSerializedMultipleOptionQuestionNode(node) {
117
+ return node?.type === "multiple-option-question" && "id" in node && typeof node.id === "string" && "questionType" in node && typeof node.questionType === "string" && "points" in node && typeof node.points === "number" && "options" in node && Array.isArray(node.options);
118
+ }
119
+
120
+ // src/typeGuards/isSerializedShortAnswerQuestionNode.ts
121
+ function isSerializedShortAnswerQuestionNode(node) {
122
+ return node?.type === "short-answer-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "maxWords" in node && typeof node.maxWords === "number" && "notes" in node;
123
+ }
124
+
125
+ // src/typeGuards/isSerializedTableCellNode.ts
126
+ function isSerializedTableCellNode(node) {
127
+ return node?.type === "tablecell" && "headerState" in node && typeof node.headerState === "number";
128
+ }
129
+
130
+ // src/exportToHtml/shouldAvoidWrap.ts
131
+ function shouldAvoidParagraphWrap(parentNode) {
132
+ if (parentNode === void 0) return false;
133
+ return isSerializedFillInTheBlankQuestionNode(parentNode) || isSerializedFinancialStatementQuestionNode(parentNode) || isSerializedJournalEntryQuestionNode(parentNode) || isSerializedMatchingQuestionNode(parentNode) || isSerializedMultipleOptionQuestionNode(parentNode) || isSerializedShortAnswerQuestionNode(parentNode) || isSerializedTableCellNode(parentNode) || isSerializedImageNode(parentNode);
134
+ }
135
+ function shouldAvoidDivWrap(parentNode) {
136
+ if (parentNode === void 0) return false;
137
+ return isSerializedImageNode(parentNode);
138
+ }
139
+
90
140
  // src/exportToHtml/createHtmlFromNestedNodes.ts
91
141
  function createHtmlFromNestedNodes(nodes, metadata) {
92
142
  const children = [];
@@ -95,8 +145,8 @@ function createHtmlFromNestedNodes(nodes, metadata) {
95
145
  const isParagraph = isSerializedParagraphNode(child);
96
146
  const element = traverse(child, metadata);
97
147
  if (element) {
98
- if (prevWasParagraph && isParagraph) {
99
- children.push("<br>");
148
+ if (shouldAvoidParagraphWrap(metadata?.parentNode)) {
149
+ if (prevWasParagraph && isParagraph) children.push("<br>");
100
150
  }
101
151
  children.push(element);
102
152
  prevWasParagraph = isParagraph;
@@ -113,6 +163,12 @@ function createHtmlFromNestedEditor(editor, metadata) {
113
163
  }
114
164
 
115
165
  // src/exportToHtml/ExcelQuestionNodeHandler.ts
166
+ var htmlOrNullIfEmpty = (editor, node) => {
167
+ const html = createHtmlFromNestedEditor(editor, {
168
+ parentNode: node
169
+ });
170
+ return !html || html === "<p></p>" ? null : html;
171
+ };
116
172
  var ExcelQuestionNodeHandler = class extends NodeHandler {
117
173
  processNode(node) {
118
174
  if (!isSerializedExcelQuestionNode(node)) return null;
@@ -120,14 +176,14 @@ var ExcelQuestionNodeHandler = class extends NodeHandler {
120
176
  ...node.data,
121
177
  parts: node.data.parts.map((p) => ({
122
178
  ...p,
123
- objective: createHtmlFromNestedEditor(p.objective),
124
- instructions: createHtmlFromNestedEditor(p.instructions),
179
+ objective: htmlOrNullIfEmpty(p.objective, node),
180
+ instructions: htmlOrNullIfEmpty(p.instructions, node),
125
181
  tasks: p.tasks.map((t) => ({
126
182
  ...t,
127
- instructions: createHtmlFromNestedEditor(t.instructions),
183
+ instructions: htmlOrNullIfEmpty(t.instructions, node),
128
184
  steps: t.steps.map((s) => ({
129
185
  ...s,
130
- description: createHtmlFromNestedEditor(s.description)
186
+ description: htmlOrNullIfEmpty(s.description, node)
131
187
  }))
132
188
  }))
133
189
  }))
@@ -149,11 +205,6 @@ var ExcelWorksheetLinkNodeHandler = class extends NodeHandler {
149
205
  }
150
206
  };
151
207
 
152
- // src/typeGuards/isSerializedFillInTheBlankQuestionNode.ts
153
- function isSerializedFillInTheBlankQuestionNode(node) {
154
- return node?.type === "fill-in-the-blank-question" && "id" in node && typeof node.id === "string" && "pointsPerSpace" in node && typeof node.pointsPerSpace === "number" && "content" in node;
155
- }
156
-
157
208
  // src/exportToHtml/FillInTheBlankQuestionNodeHandler.ts
158
209
  var FillInTheBlankQuestionNodeHandler = class extends NodeHandler {
159
210
  processNode(node) {
@@ -209,11 +260,6 @@ var FillInTheBlankSpaceNodeHandler = class extends NodeHandler {
209
260
  }
210
261
  };
211
262
 
212
- // src/typeGuards/isSerializedFinancialStatementQuestionNode.ts
213
- function isSerializedFinancialStatementQuestionNode(node) {
214
- return node?.type === "financial-statement-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "header" in node && "columnHeaders" in node && Array.isArray(node.columnHeaders) && "rows" in node && Array.isArray(node.rows) && "distractors" in node && Array.isArray(node.distractors);
215
- }
216
-
217
263
  // src/exportToHtml/FinancialStatementQuestionNodeHandler.ts
218
264
  var isHeading = (row) => {
219
265
  return row.type === "Heading";
@@ -343,11 +389,6 @@ var HorizontalRuleNodeHandler = class extends NodeHandler {
343
389
  var IMAGE_CONTAINER_ATTRIBUTE = "data-block-image-container";
344
390
  var IMAGE_CONTAINER_CLASS = "block-image-container";
345
391
 
346
- // src/typeGuards/isSerializedImageNode.ts
347
- var isSerializedImageNode = (node) => {
348
- return node?.type === "image" && "altText" in node && typeof node.altText === "string" && "caption" in node && "showCaption" in node && typeof node.showCaption === "boolean" && "src" in node && typeof node.src === "string" && "width" in node && typeof node.width === "string" && "align" in node && typeof node.align === "string" && "showBorder" in node && typeof node.showBorder === "boolean";
349
- };
350
-
351
392
  // src/exportToHtml/ImageNodeHandler.ts
352
393
  var ImageNodeHandler = class extends NodeHandler {
353
394
  alignItemsAttribute(node) {
@@ -418,11 +459,6 @@ var ImageNodeHandler = class extends NodeHandler {
418
459
  }
419
460
  };
420
461
 
421
- // src/typeGuards/isSerializedJournalEntryQuestionNode.ts
422
- function isSerializedJournalEntryQuestionNode(node) {
423
- return node?.type === "journal-entry-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "lineItems" in node && Array.isArray(node.lineItems);
424
- }
425
-
426
462
  // src/exportToHtml/createHtmlFromOnePerLineDistractorNodes.ts
427
463
  function createHtmlFromOnePerLineDistractorNodes(distractorNodes, parentNode) {
428
464
  const distractors = distractorNodes.map((node) => {
@@ -563,11 +599,6 @@ var ListNodeHandler = class extends NodeHandler {
563
599
  }
564
600
  };
565
601
 
566
- // src/typeGuards/isSerializedMatchingQuestionNode.ts
567
- function isSerializedMatchingQuestionNode(node) {
568
- return node?.type === "matching-question" && "id" in node && typeof node.id === "string" && "pointsPerMatch" in node && typeof node.pointsPerMatch === "number" && "items" in node && Array.isArray(node.items);
569
- }
570
-
571
602
  // src/exportToHtml/MatchingQuestionNodeHandler.ts
572
603
  var MatchingQuestionNodeHandler = class extends NodeHandler {
573
604
  processNode(node) {
@@ -604,11 +635,6 @@ var MatchingQuestionNodeHandler = class extends NodeHandler {
604
635
  }
605
636
  };
606
637
 
607
- // src/typeGuards/isSerializedMultipleOptionQuestionNode.ts
608
- function isSerializedMultipleOptionQuestionNode(node) {
609
- return node?.type === "multiple-option-question" && "id" in node && typeof node.id === "string" && "questionType" in node && typeof node.questionType === "string" && "points" in node && typeof node.points === "number" && "options" in node && Array.isArray(node.options);
610
- }
611
-
612
638
  // src/exportToHtml/MultipleOptionQuestionNodeHandler.ts
613
639
  var MultipleOptionQuestionNodeHandler = class extends NodeHandler {
614
640
  processNode(node) {
@@ -668,26 +694,8 @@ var MultipleOptionQuestionNodeHandler = class extends NodeHandler {
668
694
  }
669
695
  };
670
696
 
671
- // src/typeGuards/isSerializedShortAnswerQuestionNode.ts
672
- function isSerializedShortAnswerQuestionNode(node) {
673
- return node?.type === "short-answer-question" && "id" in node && typeof node.id === "string" && "points" in node && typeof node.points === "number" && "maxWords" in node && typeof node.maxWords === "number" && "notes" in node;
674
- }
675
-
676
- // src/typeGuards/isSerializedTableCellNode.ts
677
- function isSerializedTableCellNode(node) {
678
- return node?.type === "tablecell" && "headerState" in node && typeof node.headerState === "number";
679
- }
680
-
681
697
  // src/exportToHtml/ParagraphNodeHandler.ts
682
698
  var ParagraphNodeHandler = class extends NodeHandler {
683
- shouldAvoidParagraphWrap(node) {
684
- if (node === void 0) return false;
685
- return isSerializedFillInTheBlankQuestionNode(node) || isSerializedFinancialStatementQuestionNode(node) || isSerializedJournalEntryQuestionNode(node) || isSerializedMatchingQuestionNode(node) || isSerializedMultipleOptionQuestionNode(node) || isSerializedShortAnswerQuestionNode(node) || isSerializedTableCellNode(node) || isSerializedImageNode(node);
686
- }
687
- shouldAvoidDivWrap(node) {
688
- if (node === void 0) return false;
689
- return isSerializedImageNode(node);
690
- }
691
699
  processNode(node, metadata) {
692
700
  if (!isSerializedParagraphNode(node)) return null;
693
701
  const children = [];
@@ -701,8 +709,8 @@ var ParagraphNodeHandler = class extends NodeHandler {
701
709
  }
702
710
  });
703
711
  const attribute = node.format ? ` style="text-align: ${ELEMENT_TYPE_TO_FORMAT[node.format]};"` : "";
704
- if (this.shouldAvoidParagraphWrap(metadata?.parentNode))
705
- if (attribute && !this.shouldAvoidDivWrap(metadata?.parentNode))
712
+ if (shouldAvoidParagraphWrap(metadata?.parentNode))
713
+ if (attribute && !shouldAvoidDivWrap(metadata?.parentNode))
706
714
  return `<div${attribute}>${children.join("")}</div>`;
707
715
  else return children.join("");
708
716
  return `<p${attribute}>${children.join("")}</p>`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@examind/block-sdk",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
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.2.2"
24
+ "@examind/block-types": "^0.2.4"
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.2.2"
39
+ "@examind/block-types": "0.2.4"
40
40
  },
41
41
  "dependencies": {
42
42
  "lodash-es": "4.17.21"