@uniweb/core 0.5.1 → 0.5.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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/src/block.js +33 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,7 +30,7 @@
30
30
  "jest": "^29.7.0"
31
31
  },
32
32
  "dependencies": {
33
- "@uniweb/semantic-parser": "1.1.0"
33
+ "@uniweb/semantic-parser": "1.1.2"
34
34
  },
35
35
  "scripts": {
36
36
  "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
package/src/block.js CHANGED
@@ -77,6 +77,29 @@ export default class Block {
77
77
  ? blockData.subsections.map((block, i) => new Block(block, `${id}_${i}`, this.page))
78
78
  : []
79
79
 
80
+ // Insets — inline @-referenced components positioned in content flow
81
+ this.insets = []
82
+ const insetData = blockData.insets
83
+ if (insetData?.length > 0) {
84
+ for (let i = 0; i < insetData.length; i++) {
85
+ const ref = insetData[i]
86
+ const description = ref.description || ''
87
+ const child = new Block(
88
+ {
89
+ type: ref.type,
90
+ params: ref.params || {},
91
+ content: { title: description },
92
+ stableId: ref.refId,
93
+ },
94
+ `${id}_inset_${i}`,
95
+ this.page
96
+ )
97
+ child.inline = true
98
+ child.refId = ref.refId
99
+ this.insets.push(child)
100
+ }
101
+ }
102
+
80
103
  // Fetch configuration (from section frontmatter)
81
104
  // Supports local files (path) or remote URLs (url)
82
105
  this.fetch = blockData.fetch || null
@@ -265,6 +288,16 @@ export default class Block {
265
288
  return this.properties
266
289
  }
267
290
 
291
+ /**
292
+ * Get an inset block by its refId
293
+ * @param {string} refId - The reference ID (e.g., 'inset_0')
294
+ * @returns {Block|null}
295
+ */
296
+ getInset(refId) {
297
+ return this.insets.find(c => c.refId === refId) || null
298
+ }
299
+
300
+
268
301
  /**
269
302
  * Get child block renderer from runtime
270
303
  */