Compare commits
2 Commits
d08466ec70
...
5170d3adf4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5170d3adf4 | ||
|
|
d5e9d7ecd3 |
9
AGENTS.md
Normal file
9
AGENTS.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Core SDK
|
||||
|
||||
Go module `git.dev.alexdunmow.com/block/core`. Defines plugin interfaces, template engine, block registry, and shared types for the BlockNinja CMS.
|
||||
|
||||
## Critical Rules
|
||||
|
||||
- **NEVER use `replace` directives in go.mod** — not in this repo, not in any consumer. All module resolution goes through the Gitea module proxy. If you need to test local changes, tag and push a version.
|
||||
- Plugins import from core only — never from the CMS (`blockninja/backend`) or orchestrator.
|
||||
- All consumers are in-house — no backwards compatibility shims needed. Just change the API and update consumers.
|
||||
@ -1,9 +0,0 @@
|
||||
# Core SDK
|
||||
|
||||
Go module `git.dev.alexdunmow.com/block/core`. Defines plugin interfaces, template engine, block registry, and shared types for the BlockNinja CMS.
|
||||
|
||||
## Critical Rules
|
||||
|
||||
- **NEVER use `replace` directives in go.mod** — not in this repo, not in any consumer. All module resolution goes through the Gitea module proxy. If you need to test local changes, tag and push a version.
|
||||
- Plugins import from core only — never from the CMS (`blockninja/backend`) or orchestrator.
|
||||
- All consumers are in-house — no backwards compatibility shims needed. Just change the API and update consumers.
|
||||
@ -374,8 +374,17 @@ func renderBlock(ctx context.Context, block map[string]any) string {
|
||||
cellTag = "th"
|
||||
cellClass = "px-4 py-3 text-left text-sm font-semibold"
|
||||
}
|
||||
// BlockNote >=0.15 wraps each cell as a tableCell object
|
||||
// {type:"tableCell", content:[...]}; older docs store the
|
||||
// cell's inline content (string or array) directly.
|
||||
cellContent := cell
|
||||
if cellMap, ok := cell.(map[string]any); ok {
|
||||
if t, _ := cellMap["type"].(string); t == "tableCell" {
|
||||
cellContent = cellMap["content"]
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(&sb, "<%s class=\"%s\">", cellTag, cellClass)
|
||||
sb.WriteString(renderInlineContent(inlineContentFromRaw(cell), false))
|
||||
sb.WriteString(renderInlineContent(inlineContentFromRaw(cellContent), false))
|
||||
fmt.Fprintf(&sb, "</%s>", cellTag)
|
||||
}
|
||||
}
|
||||
|
||||
@ -520,6 +520,40 @@ func TestTableCellStringContent(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// BlockNote >=0.15 (the editor ships 0.47) stores each table cell as a
|
||||
// tableCell object: {type:"tableCell", props:{...}, content:[...inline]}.
|
||||
// The renderer must unwrap content[] from these objects, not just bare
|
||||
// inline arrays/strings.
|
||||
func TestTableCellObjectContent(t *testing.T) {
|
||||
cell := func(text string) map[string]any {
|
||||
return map[string]any{
|
||||
"type": "tableCell",
|
||||
"props": map[string]any{},
|
||||
"content": []any{map[string]any{"type": "text", "text": text}},
|
||||
}
|
||||
}
|
||||
doc := map[string]any{
|
||||
"blocks": []any{
|
||||
map[string]any{
|
||||
"type": "table",
|
||||
"content": map[string]any{
|
||||
"type": "tableContent",
|
||||
"rows": []any{
|
||||
map[string]any{"cells": []any{cell("Header A"), cell("Header B")}},
|
||||
map[string]any{"cells": []any{cell("Cell A"), cell("Cell B")}},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
html := BlockNoteToHTML(context.Background(), doc)
|
||||
for _, want := range []string{"Header A", "Header B", "Cell A", "Cell B"} {
|
||||
if !strings.Contains(html, want) {
|
||||
t.Errorf("expected table cell content %q in output: %s", want, html)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNestedListRendering(t *testing.T) {
|
||||
doc := map[string]any{
|
||||
"blocks": []any{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user