@commonpub/layer 0.1.4 → 0.2.0

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.
@@ -18,16 +18,23 @@ export function useMirrorContent(fedContent: Ref<Record<string, unknown> | null>
18
18
 
19
19
  const title = (fc.title as string) || 'Untitled';
20
20
 
21
- // Parse block content: may be BlockTuple JSON or raw HTML from federation
22
- let content: unknown = fc.content;
23
- if (typeof content === 'string') {
24
- const trimmed = content.trim();
25
- if (trimmed.startsWith('[[') || trimmed.startsWith('[["')) {
26
- try { content = JSON.parse(trimmed); } catch { /* keep as string */ }
27
- }
28
- // If still a string (HTML from federation), wrap as BlockTuple array
29
- if (typeof content === 'string' && content.trim()) {
30
- content = [['paragraph', { html: content }]];
21
+ // Parse block content: prefer cpub:blocks (full fidelity from CommonPub instances),
22
+ // fall back to HTML content (from non-CommonPub instances or legacy federation)
23
+ let content: unknown;
24
+ if (Array.isArray(fc.cpubBlocks) && fc.cpubBlocks.length > 0) {
25
+ // CommonPub→CommonPub: original block structure preserved
26
+ content = fc.cpubBlocks;
27
+ } else {
28
+ content = fc.content;
29
+ if (typeof content === 'string') {
30
+ const trimmed = content.trim();
31
+ if (trimmed.startsWith('[[') || trimmed.startsWith('[["')) {
32
+ try { content = JSON.parse(trimmed); } catch { /* keep as string */ }
33
+ }
34
+ // If still a string (HTML from federation), wrap as BlockTuple array
35
+ if (typeof content === 'string' && content.trim()) {
36
+ content = [['paragraph', { html: content }]];
37
+ }
31
38
  }
32
39
  }
33
40
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commonpub/layer",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "./nuxt.config.ts",
6
6
  "files": [
@@ -45,15 +45,15 @@
45
45
  "vue": "^3.4.0",
46
46
  "vue-router": "^4.3.0",
47
47
  "zod": "^4.3.6",
48
+ "@commonpub/auth": "0.5.0",
48
49
  "@commonpub/config": "0.7.0",
49
50
  "@commonpub/docs": "0.5.0",
50
- "@commonpub/auth": "0.5.0",
51
51
  "@commonpub/editor": "0.5.0",
52
- "@commonpub/protocol": "0.9.3",
53
- "@commonpub/server": "2.6.0",
54
- "@commonpub/schema": "0.8.7",
55
- "@commonpub/ui": "0.7.1",
56
- "@commonpub/learning": "0.5.0"
52
+ "@commonpub/learning": "0.5.0",
53
+ "@commonpub/protocol": "0.9.4",
54
+ "@commonpub/schema": "0.8.8",
55
+ "@commonpub/server": "2.7.0",
56
+ "@commonpub/ui": "0.7.1"
57
57
  },
58
58
  "scripts": {}
59
59
  }