@uniweb/core 0.5.1 → 0.5.2
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 +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
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.1"
|
|
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,23 @@ export default class Block {
|
|
|
77
77
|
? blockData.subsections.map((block, i) => new Block(block, `${id}_${i}`, this.page))
|
|
78
78
|
: []
|
|
79
79
|
|
|
80
|
+
// Inline child blocks (from @ component references in markdown)
|
|
81
|
+
if (blockData.inlineChildren?.length > 0) {
|
|
82
|
+
const start = this.childBlocks.length
|
|
83
|
+
for (let i = 0; i < blockData.inlineChildren.length; i++) {
|
|
84
|
+
const ref = blockData.inlineChildren[i]
|
|
85
|
+
const child = new Block(
|
|
86
|
+
{ type: ref.type, params: ref.params || {}, content: {}, stableId: ref.refId },
|
|
87
|
+
`${id}_${start + i}`,
|
|
88
|
+
this.page
|
|
89
|
+
)
|
|
90
|
+
child.inline = true
|
|
91
|
+
child.refId = ref.refId
|
|
92
|
+
child.alt = ref.alt || ''
|
|
93
|
+
this.childBlocks.push(child)
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
// Fetch configuration (from section frontmatter)
|
|
81
98
|
// Supports local files (path) or remote URLs (url)
|
|
82
99
|
this.fetch = blockData.fetch || null
|
|
@@ -265,6 +282,15 @@ export default class Block {
|
|
|
265
282
|
return this.properties
|
|
266
283
|
}
|
|
267
284
|
|
|
285
|
+
/**
|
|
286
|
+
* Get an inline child block by its refId
|
|
287
|
+
* @param {string} refId - The reference ID (e.g., 'inline_0')
|
|
288
|
+
* @returns {Block|null}
|
|
289
|
+
*/
|
|
290
|
+
getInlineChild(refId) {
|
|
291
|
+
return this.childBlocks.find(c => c.refId === refId) || null
|
|
292
|
+
}
|
|
293
|
+
|
|
268
294
|
/**
|
|
269
295
|
* Get child block renderer from runtime
|
|
270
296
|
*/
|