@uniweb/core 0.5.2 → 0.5.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/package.json +2 -2
- package/src/block.js +23 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
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.
|
|
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,20 +77,26 @@ export default class Block {
|
|
|
77
77
|
? blockData.subsections.map((block, i) => new Block(block, `${id}_${i}`, this.page))
|
|
78
78
|
: []
|
|
79
79
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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 || ''
|
|
85
87
|
const child = new Block(
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
+
{
|
|
89
|
+
type: ref.type,
|
|
90
|
+
params: ref.params || {},
|
|
91
|
+
content: { title: description },
|
|
92
|
+
stableId: ref.refId,
|
|
93
|
+
},
|
|
94
|
+
`${id}_inset_${i}`,
|
|
88
95
|
this.page
|
|
89
96
|
)
|
|
90
97
|
child.inline = true
|
|
91
98
|
child.refId = ref.refId
|
|
92
|
-
|
|
93
|
-
this.childBlocks.push(child)
|
|
99
|
+
this.insets.push(child)
|
|
94
100
|
}
|
|
95
101
|
}
|
|
96
102
|
|
|
@@ -283,19 +289,21 @@ export default class Block {
|
|
|
283
289
|
}
|
|
284
290
|
|
|
285
291
|
/**
|
|
286
|
-
* Get an
|
|
287
|
-
* @param {string} refId - The reference ID (e.g., '
|
|
292
|
+
* Get an inset block by its refId
|
|
293
|
+
* @param {string} refId - The reference ID (e.g., 'inset_0')
|
|
288
294
|
* @returns {Block|null}
|
|
289
295
|
*/
|
|
290
|
-
|
|
291
|
-
return this.
|
|
296
|
+
getInset(refId) {
|
|
297
|
+
return this.insets.find(c => c.refId === refId) || null
|
|
292
298
|
}
|
|
293
299
|
|
|
300
|
+
|
|
294
301
|
/**
|
|
295
|
-
* Get child block renderer from runtime
|
|
302
|
+
* Get child block renderer from runtime.
|
|
303
|
+
* @deprecated Use `ChildBlocks` from `@uniweb/kit` instead.
|
|
296
304
|
*/
|
|
297
305
|
getChildBlockRenderer() {
|
|
298
|
-
return globalThis.uniweb
|
|
306
|
+
return globalThis.uniweb.childBlockRenderer
|
|
299
307
|
}
|
|
300
308
|
|
|
301
309
|
/**
|