@uniweb/semantic-parser 1.1.18 → 1.1.20

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.18",
3
+ "version": "1.1.20",
4
4
  "description": "Semantic parser for ProseMirror/TipTap content structures",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -57,11 +57,16 @@ function imageBlock({ src, alt = '', caption = '', direction, role, width, heigh
57
57
  }
58
58
 
59
59
  function iconNode({ src, svg, library, name, size, color }) {
60
- // UniwebIcon supports multiple source types
60
+ // UniwebIcon supports multiple source types.
61
+ //
62
+ // The family rides INSIDE `name` as `family:id`. The editor's node declares
63
+ // `{ name, svg, url, size, color, preserveColors, info }` and no `library`,
64
+ // and ProseMirror silently drops undeclared attrs on `fromJSON` — so emitting
65
+ // a separate `library` lost the family without a trace, on the path that
66
+ // builds starter content for every new section.
61
67
  const attrs = {}
62
68
  if (svg || src) attrs.svg = svg || src
63
- if (library) attrs.library = library
64
- if (name) attrs.name = name
69
+ if (name) attrs.name = library ? `${library}:${name}` : name
65
70
  if (size) attrs.size = size
66
71
  if (color) attrs.color = color
67
72
  return { type: 'UniwebIcon', attrs }
@@ -154,6 +154,20 @@ function createSequenceElement(node, options = {}) {
154
154
  attrs,
155
155
  };
156
156
 
157
+ case "inset_block": {
158
+ // The block form of an inset: a component reference that carries
159
+ // real block content. Its children are processed like a
160
+ // blockquote's — the default branch would flatten them to a text
161
+ // string, which loses the author's prose entirely.
162
+ const { component, ...params } = attrs || {};
163
+ return {
164
+ type: "inset_block",
165
+ component,
166
+ params,
167
+ children: processSequence({ content }),
168
+ };
169
+ }
170
+
157
171
  case "dataBlock":
158
172
  // Pre-parsed structured data from content-reader
159
173
  return {
@@ -625,8 +639,18 @@ function parseUniwebIcon(itemAttrs) {
625
639
  if (preserveColors) icon.preserveColors = preserveColors;
626
640
  if (href) icon.href = href;
627
641
  if (target) icon.target = target;
628
- if (library) icon.library = library;
629
- if (name) icon.name = name;
642
+ // The editor carries the family inside `name` as `family:id`; the markdown
643
+ // pipeline carries them separately. Normalize to the separate form, which
644
+ // is what `<Icon library name />` consumes.
645
+ let resolvedLibrary = library;
646
+ let resolvedName = name;
647
+ if (!resolvedLibrary && typeof name === "string" && name.includes(":")) {
648
+ const [family, ...rest] = name.split(":");
649
+ resolvedLibrary = family;
650
+ resolvedName = rest.join(":");
651
+ }
652
+ if (resolvedLibrary) icon.library = resolvedLibrary;
653
+ if (resolvedName) icon.name = resolvedName;
630
654
 
631
655
  return icon;
632
656
  }