@uniweb/core 0.6.0 → 0.6.1

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 +1 -1
  2. package/src/block.js +11 -24
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Core classes for the Uniweb platform - Uniweb, Website, Page, Block",
5
5
  "type": "module",
6
6
  "exports": {
package/src/block.js CHANGED
@@ -197,17 +197,19 @@ export default class Block {
197
197
  }
198
198
 
199
199
  /**
200
- * Parse content into structured format using semantic-parser
201
- * Supports multiple content formats:
202
- * 1. Pre-parsed groups structure (from editor)
200
+ * Parse content into a flat semantic structure using @uniweb/semantic-parser.
201
+ *
202
+ * Supports multiple input shapes:
203
+ * 1. Pre-parsed groups structure (from the editor)
203
204
  * 2. ProseMirror document (from markdown collection)
204
- * 3. Plain object (passed through directly)
205
+ * 3. Wrapped ProseMirror document (content-API format)
206
+ * 4. Plain object (passed through directly)
205
207
  *
206
- * Uses @uniweb/semantic-parser for rich content extraction including:
207
- * - Pretitle detection (H3 before H1)
208
- * - Banner/background image detection
209
- * - Semantic grouping (main + items)
210
- * - Lists, links, buttons, etc.
208
+ * Pure and idempotent safe to call more than once on the same block.
209
+ * The constructor calls it once to populate `this.parsedContent`; the
210
+ * runtime's `prepareProps` may call it again after a foundation content
211
+ * handler transforms `rawContent`, to produce fresh semantic content
212
+ * from the instantiated tree.
211
213
  */
212
214
  parseContent(content) {
213
215
  // If content is already parsed with groups structure
@@ -215,21 +217,6 @@ export default class Block {
215
217
  return content.groups
216
218
  }
217
219
 
218
- // Foundation content handler hook
219
- // Runs BEFORE semantic parsing. Foundations can declare a handler
220
- // in foundation.js `handlers.content` to transform raw ProseMirror
221
- // content — typically for template engine instantiation of
222
- // {placeholder} expressions against profile/report data.
223
- const contentHandler = globalThis.uniweb?.foundationConfig?.handlers?.content
224
- if (contentHandler && typeof contentHandler === 'function') {
225
- try {
226
- const transformed = contentHandler(content, this)
227
- if (transformed !== undefined) content = transformed
228
- } catch (err) {
229
- console.error('Foundation content handler failed:', err)
230
- }
231
- }
232
-
233
220
  // ProseMirror document - use semantic-parser
234
221
  if (content?.type === 'doc') {
235
222
  return this.extractFromProseMirror(content)