{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://shapes.penny.coop/content/1.0.0/schema.json",
  "title": "Content document",
  "description": "The portable JSON structure of a Penny Content document. This checks the document envelope and supported node/mark names; the editor's ProseMirror schema also validates nesting, attributes and safe links. Collaborative Yjs state is stored separately and is never included in the shared shape.",
  "type": "object",
  "properties": {
    "type": { "const": "doc" },
    "content": { "type": "array", "minItems": 1, "items": { "$ref": "#/$defs/node" } }
  },
  "required": ["type", "content"],
  "additionalProperties": false,
  "$defs": {
    "node": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": { "const": "text" },
            "text": { "type": "string", "minLength": 1 },
            "marks": { "type": "array", "items": { "$ref": "#/$defs/mark" } }
          },
          "required": ["type", "text"],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": { "enum": ["paragraph", "heading", "blockquote", "codeBlock", "bulletList", "orderedList", "listItem", "hardBreak", "horizontalRule"] },
            "attrs": { "type": "object" },
            "content": { "type": "array", "items": { "$ref": "#/$defs/node" } },
            "marks": { "type": "array", "items": { "$ref": "#/$defs/mark" } }
          },
          "required": ["type"],
          "additionalProperties": false
        }
      ]
    },
    "mark": {
      "type": "object",
      "properties": {
        "type": { "enum": ["bold", "italic", "strike", "code", "underline", "link"] },
        "attrs": { "type": "object" }
      },
      "required": ["type"],
      "additionalProperties": false
    }
  },
  "x-penny": { "shape": "content", "version": "1.0.0", "field": "content" }
}
