Ok, i will think about it when the pack will be clean enough.
I try the first approach without success.
I will retry about it later :
const NodeReferenceSchema = coda.makeObjectSchema({
codaType: coda.ValueHintType.Reference,
properties: {
tag: { type: coda.ValueType.String, required: true, },
attrs: {
type: coda.ValueType.Object,
properties: {
src: { type: coda.ValueType.String },
id: { type: coda.ValueType.String },
href: { type: coda.ValueType.String, codaType: coda.ValueHintType.Url },
target: { type: coda.ValueType.String },
},
},
},
displayProperty: "tag",
idProperty: "tag",
identity: {
name: "Node",
},
});
let NodeSchema = coda.makeObjectSchema({
properties: {
tag: { type: coda.ValueType.String, required: true, },
attrs: {
type: coda.ValueType.Object,
properties: {
src: { type: coda.ValueType.String },
id: { type: coda.ValueType.String },
href: { type: coda.ValueType.String, codaType: coda.ValueHintType.Url },
target: { type: coda.ValueType.String },
},
},
//children: { type: coda.ValueType.Array, items: NodeSchema }
displayProperty: "tag",
parentNode: NodeReferenceSchema,
idProperty: "tag",
}
});
One thing make me worry is that there is no “Id” for the node, i guess i have to invent it. For exemple, an excerpt of API answer actually :
{
"tag": "figure",
"children": [
{
"tag": "img",
"attrs": {
"src": "/file/f701e9b51469a318f166b.jpg"
}
},
{
"tag": "figcaption",
"children": [
""
]
}
]
},
{
"tag": "h3",
"attrs": {
"id": ""
},
"children": [
{
"tag": "br"
}
]
},