@uniweb/semantic-parser 1.1.1 → 1.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/semantic-parser",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Semantic parser for ProseMirror/TipTap content structures",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -16,6 +16,7 @@ function flattenGroup(group) {
16
16
  icons: group.body.icons || [],
17
17
  lists: group.body.lists || [],
18
18
  videos: group.body.videos || [],
19
+ insets: group.body.insets || [],
19
20
  data: group.body.data || {},
20
21
  quotes: group.body.quotes || [],
21
22
  headings: group.body.headings || [],
@@ -42,6 +43,7 @@ function processGroups(sequence, options = {}) {
42
43
  icons: [],
43
44
  lists: [],
44
45
  videos: [],
46
+ insets: [],
45
47
  data: {},
46
48
  quotes: [],
47
49
  headings: [],
@@ -78,6 +80,7 @@ function processGroups(sequence, options = {}) {
78
80
  icons: [],
79
81
  lists: [],
80
82
  videos: [],
83
+ insets: [],
81
84
  data: {},
82
85
  quotes: [],
83
86
  headings: [],
@@ -216,6 +219,7 @@ function processGroupContent(elements) {
216
219
  imgs: [],
217
220
  icons: [],
218
221
  videos: [],
222
+ insets: [],
219
223
  paragraphs: [],
220
224
  links: [],
221
225
  lists: [],
@@ -343,8 +347,8 @@ function processGroupContent(elements) {
343
347
  }
344
348
  break;
345
349
 
346
- case "child_block":
347
- // Inline child block reference — preserved in sequence, not in flat fields
350
+ case "inset":
351
+ body.insets.push({ refId: element.refId });
348
352
  break;
349
353
 
350
354
  case "form":
@@ -401,7 +405,14 @@ function identifyMainContent(groups) {
401
405
  const first = groups[0].metadata.level;
402
406
  const second = groups[1].metadata.level;
403
407
 
404
- return first ? !second || first < second : false;
408
+ // First group has a heading more important than second main
409
+ if (first && (!second || first < second)) return true;
410
+
411
+ // First group has NO heading (just body content before first heading) → promote to main
412
+ // This prevents empty-titled first items when content precedes headings
413
+ if (!first && second) return true;
414
+
415
+ return false;
405
416
  }
406
417
 
407
418
  function processInlineElements(children, body) {
@@ -153,9 +153,9 @@ function createSequenceElement(node, options = {}) {
153
153
  attrs,
154
154
  };
155
155
 
156
- case "inline_child_placeholder":
156
+ case "inset_placeholder":
157
157
  return {
158
- type: "child_block",
158
+ type: "inset",
159
159
  refId: attrs.refId,
160
160
  };
161
161
  case "ImageBlock":