@uniweb/semantic-parser 1.1.18 → 1.1.19

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.19",
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 }
@@ -625,8 +625,18 @@ function parseUniwebIcon(itemAttrs) {
625
625
  if (preserveColors) icon.preserveColors = preserveColors;
626
626
  if (href) icon.href = href;
627
627
  if (target) icon.target = target;
628
- if (library) icon.library = library;
629
- if (name) icon.name = name;
628
+ // The editor carries the family inside `name` as `family:id`; the markdown
629
+ // pipeline carries them separately. Normalize to the separate form, which
630
+ // is what `<Icon library name />` consumes.
631
+ let resolvedLibrary = library;
632
+ let resolvedName = name;
633
+ if (!resolvedLibrary && typeof name === "string" && name.includes(":")) {
634
+ const [family, ...rest] = name.split(":");
635
+ resolvedLibrary = family;
636
+ resolvedName = rest.join(":");
637
+ }
638
+ if (resolvedLibrary) icon.library = resolvedLibrary;
639
+ if (resolvedName) icon.name = resolvedName;
630
640
 
631
641
  return icon;
632
642
  }