{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://sciflow.org/schemas/manuscript-snapshot.schema.json",
  "title": "SciFlow Manuscript Snapshot",
  "description": "JSON Schema describing a complete SciFlow document snapshot, including the ProseMirror document, files, references, and selection state.",
  "type": "object",
  "required": [
    "doc"
  ],
  "additionalProperties": false,
  "properties": {
    "doc": {
      "$ref": "#/$defs/doc",
      "description": "The ProseMirror document in toJSON() format."
    },
    "version": {
      "type": "number",
      "description": "Document version number, incremented on each change."
    },
    "selection": {
      "$ref": "#/$defs/_selection",
      "description": "Cursor/selection state."
    },
    "files": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/_snapshotFile"
      },
      "description": "Files and assets referenced by the document."
    },
    "references": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/_snapshotReference"
      },
      "description": "Bibliography and citation references."
    }
  },
  "$defs": {
    "mark_tags": {
      "type": "object",
      "description": "Semantic tags applied to a text range. Used for classification and filtering.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "tags"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "tags": {
              "description": "Array of tag objects, each with a \"key\" string.",
              "type": "array",
              "default": []
            }
          },
          "additionalProperties": false
        }
      }
    },
    "mark_anchor": {
      "type": "object",
      "description": "Hyperlink mark wrapping text with an external or internal URL.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "anchor"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "href": {
              "description": "Link target URL.",
              "type": [
                "string",
                "null"
              ]
            },
            "title": {
              "description": "Link title shown on hover.",
              "type": [
                "string",
                "null"
              ]
            },
            "id": {
              "description": "Unique identifier for the link instance.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        }
      }
    },
    "mark_em": {
      "type": "object",
      "description": "em mark.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "em"
        }
      }
    },
    "mark_strong": {
      "type": "object",
      "description": "strong mark.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "strong"
        }
      }
    },
    "mark_sup": {
      "type": "object",
      "description": "Superscript formatting.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "sup"
        }
      }
    },
    "mark_sub": {
      "type": "object",
      "description": "Subscript formatting.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "sub"
        }
      }
    },
    "mark_bdi": {
      "type": "object",
      "description": "Bidirectional isolate — prevents surrounding text direction from affecting the marked range.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "bdi"
        }
      }
    },
    "mark_indexEntry": {
      "type": "object",
      "description": "Back-of-book index entry anchored to a text range. Carries one or more index terms and optional typesetting attributes.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "indexEntry"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "description": "Unique identifier for this index entry.",
              "type": [
                "string",
                "null"
              ]
            },
            "entries": {
              "description": "Array of index term objects, each with an optional \"raw\" string for the sort key or display form.",
              "type": "array",
              "default": []
            },
            "attributes": {
              "description": "Additional typesetting or classification attributes for the index entry.",
              "type": "object",
              "default": {}
            }
          },
          "additionalProperties": false
        }
      }
    },
    "_mark": {
      "description": "An inline mark (formatting, link, tag, or index entry).",
      "oneOf": [
        {
          "$ref": "#/$defs/mark_tags"
        },
        {
          "$ref": "#/$defs/mark_anchor"
        },
        {
          "$ref": "#/$defs/mark_em"
        },
        {
          "$ref": "#/$defs/mark_strong"
        },
        {
          "$ref": "#/$defs/mark_sup"
        },
        {
          "$ref": "#/$defs/mark_sub"
        },
        {
          "$ref": "#/$defs/mark_bdi"
        },
        {
          "$ref": "#/$defs/mark_indexEntry"
        }
      ]
    },
    "paragraph": {
      "type": "object",
      "description": "Standard block of inline content (text, citations, math, etc.).",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "paragraph"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "text-align": {
              "description": "Text alignment: \"left\", \"right\", \"center\", or \"justify\".",
              "type": [
                "string",
                "null"
              ]
            },
            "text-direction": {
              "description": "Text direction: \"ltr\", \"rtl\", or \"auto\".",
              "type": [
                "string",
                "null"
              ]
            },
            "class": {
              "description": "Custom CSS class.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `inline*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/image"
              },
              {
                "$ref": "#/$defs/math"
              },
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/hard_break"
              },
              {
                "$ref": "#/$defs/citation"
              },
              {
                "$ref": "#/$defs/link"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "reference": {
      "type": "object",
      "description": "Bibliography entry rendered as a paragraph-like block. Carries a refId linking to a SnapshotReference.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "reference"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "refId": {
              "description": "Identifier linking to a SnapshotReference entry.",
              "type": [
                "string",
                "null"
              ]
            },
            "text-align": {
              "description": "Text alignment.",
              "type": [
                "string",
                "null"
              ]
            },
            "text-direction": {
              "description": "Text direction: \"ltr\", \"rtl\", or \"auto\".",
              "type": [
                "string",
                "null"
              ]
            },
            "class": {
              "description": "Custom CSS class.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `inline*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/image"
              },
              {
                "$ref": "#/$defs/math"
              },
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/hard_break"
              },
              {
                "$ref": "#/$defs/citation"
              },
              {
                "$ref": "#/$defs/link"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "part": {
      "type": "object",
      "description": "Section wrapper representing a chapter, abstract, appendix, bibliography, or other structural division.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "part"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "type": {
              "description": "Part type: \"chapter\", \"abstract\", \"bibliography\", \"appendix\", \"part\", or \"free\".",
              "type": "string",
              "default": "chapter"
            },
            "locale": {
              "description": "BCP 47 locale override for this section (e.g. \"de-DE\").",
              "type": [
                "string",
                "null"
              ]
            },
            "numbering": {
              "description": "Numbering style for this section.",
              "type": [
                "string",
                "null"
              ]
            },
            "placement": {
              "description": "Placement in the document (\"cover\", \"front\", \"body\", \"back\").",
              "type": [
                "string",
                "null"
              ]
            },
            "role": {
              "description": "Semantic role of this section.",
              "type": [
                "string",
                "null"
              ]
            },
            "text-direction": {
              "description": "Text direction: \"ltr\", \"rtl\", or \"auto\".",
              "type": [
                "string",
                "null"
              ]
            },
            "class": {
              "description": "Custom CSS class applied to this section.",
              "type": [
                "string",
                "null"
              ]
            },
            "skipToc": {
              "description": "When true, exclude this section from the table of contents.",
              "type": "boolean",
              "default": false
            },
            "data": {
              "description": "Extended settings object, e.g. alternative titles for running headers.",
              "type": [
                "string",
                "null"
              ]
            },
            "pageBreak": {
              "description": "Page-break behaviour: \"after\", \"before\", \"right\", or \"before-and-after\".",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `heading? block*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/reference"
              },
              {
                "$ref": "#/$defs/horizontal_rule"
              },
              {
                "$ref": "#/$defs/blockquote"
              },
              {
                "$ref": "#/$defs/pageBreak"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/placeHolder"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "subtitle": {
      "type": "object",
      "description": "Subtitle node that sits below the main heading inside a header block.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "subtitle"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `inline*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/image"
              },
              {
                "$ref": "#/$defs/math"
              },
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/hard_break"
              },
              {
                "$ref": "#/$defs/citation"
              },
              {
                "$ref": "#/$defs/link"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "header": {
      "type": "object",
      "description": "Container that groups the main heading with an optional subtitle. Appears at most once at the top of the document.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "header"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `heading subtitle?`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/subtitle"
              }
            ]
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "heading": {
      "type": "object",
      "description": "Section or chapter title supporting levels 1–6.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "heading"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "level": {
              "description": "Heading level from 1 (highest) to 6 (lowest).",
              "type": "number",
              "default": 1
            },
            "role": {
              "description": "Semantic role such as \"title\" or \"subtitle\".",
              "type": [
                "string",
                "null"
              ]
            },
            "type": {
              "description": "Heading type, e.g. \"chapter\".",
              "type": "string",
              "default": "chapter"
            },
            "numbering": {
              "description": "Numbering style override (\"decimal\", \"alpha\", \"roman\", \"none\").",
              "type": [
                "string",
                "null"
              ]
            },
            "placement": {
              "description": "Placement hint (\"cover\", \"front\", \"body\", \"back\").",
              "type": [
                "string",
                "null"
              ]
            },
            "data": {
              "description": "Extended settings object, e.g. { literalNumbering: \"A.1\" }.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `(text | footnote)*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "doc": {
      "type": "object",
      "description": "Root document node that wraps an optional header and structural or block-level content.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "doc"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "type": {
              "description": "Document type, typically \"article\".",
              "type": "string",
              "default": "article"
            },
            "lang": {
              "description": "BCP 47 language tag (e.g. \"en-US\", \"de-DE\").",
              "type": [
                "string",
                "null"
              ]
            },
            "role": {
              "description": "Semantic role of the document.",
              "type": [
                "string",
                "null"
              ]
            },
            "schema": {
              "description": "Schema version identifier.",
              "type": [
                "string",
                "null"
              ]
            },
            "pageBreak": {
              "description": "Page-break behaviour (\"after\", \"before\", \"right\", \"before-and-after\").",
              "type": [
                "string",
                "null"
              ]
            },
            "placement": {
              "description": "Placement hint (\"cover\", \"front\", \"body\", \"back\").",
              "type": [
                "string",
                "null"
              ]
            },
            "numbering": {
              "description": "Numbering style (\"decimal\", \"alpha\", \"roman\", \"none\").",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `header? (structural | block)*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/header"
              },
              {
                "$ref": "#/$defs/part"
              },
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/reference"
              },
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/horizontal_rule"
              },
              {
                "$ref": "#/$defs/blockquote"
              },
              {
                "$ref": "#/$defs/pageBreak"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/placeHolder"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "image": {
      "type": "object",
      "description": "Inline image node for images that flow with text rather than standing alone as figures.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "image"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "src": {
              "description": "Image source URL.",
              "type": [
                "string",
                "null"
              ]
            },
            "alt": {
              "description": "Alternative text for accessibility.",
              "type": [
                "string",
                "null"
              ]
            },
            "title": {
              "description": "Image title shown on hover.",
              "type": [
                "string",
                "null"
              ]
            },
            "width": {
              "description": "Rendered width in pixels.",
              "type": [
                "string",
                "null"
              ]
            },
            "height": {
              "description": "Rendered height in pixels.",
              "type": [
                "string",
                "null"
              ]
            },
            "metaData": {
              "description": "Opaque metadata string for downstream processing.",
              "type": [
                "string",
                "null"
              ]
            },
            "decorative": {
              "description": "When true, the image is decorative (role=\"presentation\") and alt text is cleared.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        }
      }
    },
    "horizontal_rule": {
      "type": "object",
      "description": "Horizontal rule separator between blocks.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "horizontal_rule"
        }
      }
    },
    "blockquote": {
      "type": "object",
      "description": "Block quotation containing one or more child blocks.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "blockquote"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "lang": {
              "description": "BCP 47 language tag if the quote is in a different language.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `block+`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/reference"
              },
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/horizontal_rule"
              },
              {
                "$ref": "#/$defs/blockquote"
              },
              {
                "$ref": "#/$defs/pageBreak"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/placeHolder"
              }
            ]
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "pageBreak": {
      "type": "object",
      "description": "Explicit page-break marker inserted between blocks.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "pageBreak"
        }
      }
    },
    "label": {
      "type": "object",
      "description": "Caption label element displaying the figure/table number (e.g. \"Figure 1\", \"Table 2\").",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "label"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `text*`.",
          "items": {
            "$ref": "#/$defs/text"
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "caption": {
      "type": "object",
      "description": "Container for caption content beneath a figure. Holds an optional label followed by descriptive blocks.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "caption"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `label? block*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/label"
              },
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/reference"
              },
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/horizontal_rule"
              },
              {
                "$ref": "#/$defs/blockquote"
              },
              {
                "$ref": "#/$defs/pageBreak"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/placeHolder"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "code_block": {
      "type": "object",
      "description": "Block-level code snippet that preserves whitespace and disables marks.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "code_block"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "text": {
              "description": "Raw code text content.",
              "type": "string",
              "default": ""
            },
            "type": {
              "description": "Block type, defaults to \"code\".",
              "type": "string",
              "default": "code"
            },
            "language": {
              "description": "Language identifier or MIME type (e.g. \"text/javascript\", \"python\").",
              "type": "string",
              "default": "text/plain"
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `text*`.",
          "items": {
            "$ref": "#/$defs/text"
          }
        }
      }
    },
    "math": {
      "type": "object",
      "description": "Inline or display math expression rendered from TeX source.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "math"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "tex": {
              "description": "TeX source code for the expression.",
              "type": "string",
              "default": ""
            },
            "style": {
              "description": "Rendering style: \"inline\" for within text, \"display\" for a centred block equation.",
              "type": "string",
              "default": "inline"
            },
            "label": {
              "description": "Optional equation label for cross-referencing (e.g. \"eq:euler\").",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `text*`.",
          "items": {
            "$ref": "#/$defs/text"
          }
        }
      }
    },
    "text": {
      "type": "object",
      "description": "text node (group: inline).",
      "required": [
        "type",
        "text"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "text"
        },
        "text": {
          "type": "string",
          "description": "The text content of this node."
        },
        "marks": {
          "type": "array",
          "description": "Inline marks applied to this text (bold, italic, links, etc.).",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "hard_break": {
      "type": "object",
      "description": "hard_break node (group: inline).",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "hard_break"
        }
      }
    },
    "citation": {
      "type": "object",
      "description": "Inline citation placeholder linking to one or more bibliography references. Rendered according to a citation style.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "citation"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "source": {
              "description": "URI-encoded JSON array of CSL citation items. Each item has an \"id\" referencing a SnapshotReference and optional fields (prefix, suffix, locator, label). Null when unresolved.",
              "type": [
                "string",
                "null"
              ]
            },
            "style": {
              "description": "Citation style key, e.g. \"apa\", \"chicago-author-date\", \"ieee\".",
              "type": "string",
              "default": "apa"
            },
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `inline*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/image"
              },
              {
                "$ref": "#/$defs/math"
              },
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/hard_break"
              },
              {
                "$ref": "#/$defs/citation"
              },
              {
                "$ref": "#/$defs/link"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "link": {
      "type": "object",
      "description": "Cross-reference node rendered as a hyperlink. Links to headings, figures, or other labelled targets within the document.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "link"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "type": {
              "description": "Link type, typically \"xref\" for cross-references.",
              "type": [
                "string",
                "null"
              ]
            },
            "href": {
              "description": "Target anchor (e.g. \"#heading-id\" or \"#figure-id\").",
              "type": [
                "string",
                "null"
              ]
            },
            "reference-format": {
              "description": "How the cross-reference text should be generated (e.g. \"number\", \"title\").",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `text*`.",
          "items": {
            "$ref": "#/$defs/text"
          }
        }
      }
    },
    "footnote": {
      "type": "object",
      "description": "Inline atom that stores footnote content. Rendered as a superscript marker in the editor.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "footnote"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "type": {
              "description": "Footnote type, defaults to \"footnote\".",
              "type": "string",
              "default": "footnote"
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `inline*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/image"
              },
              {
                "$ref": "#/$defs/math"
              },
              {
                "$ref": "#/$defs/text"
              },
              {
                "$ref": "#/$defs/hard_break"
              },
              {
                "$ref": "#/$defs/citation"
              },
              {
                "$ref": "#/$defs/link"
              },
              {
                "$ref": "#/$defs/footnote"
              }
            ]
          }
        }
      }
    },
    "list_item": {
      "type": "object",
      "description": "list_item node.",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "list_item"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `block*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/reference"
              },
              {
                "$ref": "#/$defs/heading"
              },
              {
                "$ref": "#/$defs/horizontal_rule"
              },
              {
                "$ref": "#/$defs/blockquote"
              },
              {
                "$ref": "#/$defs/pageBreak"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/placeHolder"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "bullet_list": {
      "type": "object",
      "description": "bullet_list node (group: block).",
      "required": [
        "type"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "bullet_list"
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `list_item+`.",
          "items": {
            "$ref": "#/$defs/list_item"
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "ordered_list": {
      "type": "object",
      "description": "ordered_list node (group: block).",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "ordered_list"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "order": {
              "type": "number",
              "default": 1
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `list_item+`.",
          "items": {
            "$ref": "#/$defs/list_item"
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "table": {
      "type": "object",
      "description": "table node (group: block).",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "table"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `table_row+`.",
          "items": {
            "$ref": "#/$defs/table_row"
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "table_row": {
      "type": "object",
      "description": "table_row node.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "table_row"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `(table_cell | table_header)*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/table_cell"
              },
              {
                "$ref": "#/$defs/table_header"
              }
            ]
          }
        }
      }
    },
    "table_cell": {
      "type": "object",
      "description": "table_cell node.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "table_cell"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "colspan": {
              "type": "number",
              "default": 1
            },
            "rowspan": {
              "type": "number",
              "default": 1
            },
            "colwidth": {
              "type": [
                "string",
                "null"
              ]
            },
            "background": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `(paragraph | ordered_list | bullet_list | figure | blockquote)*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/blockquote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "table_header": {
      "type": "object",
      "description": "table_header node.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "table_header"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "colspan": {
              "type": "number",
              "default": 1
            },
            "rowspan": {
              "type": "number",
              "default": 1
            },
            "colwidth": {
              "type": [
                "string",
                "null"
              ]
            },
            "background": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `(paragraph | ordered_list | bullet_list | figure | blockquote)*`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/paragraph"
              },
              {
                "$ref": "#/$defs/ordered_list"
              },
              {
                "$ref": "#/$defs/bullet_list"
              },
              {
                "$ref": "#/$defs/figure"
              },
              {
                "$ref": "#/$defs/blockquote"
              }
            ]
          }
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "figure": {
      "type": "object",
      "description": "Figure wrapper that can host an image, a table, or a code block together with a caption. Supports float placement for typesetting.",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "figure"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "src": {
              "description": "Image source URL (empty string if the figure wraps a table or code block).",
              "type": "string",
              "default": ""
            },
            "alt": {
              "description": "Alternative text describing the image for accessibility.",
              "type": "string",
              "default": ""
            },
            "width": {
              "description": "Intrinsic image width in pixels.",
              "type": [
                "string",
                "null"
              ]
            },
            "height": {
              "description": "Intrinsic image height in pixels.",
              "type": [
                "string",
                "null"
              ]
            },
            "title": {
              "description": "Figure title (used as tooltip and in some export formats).",
              "type": [
                "string",
                "null"
              ]
            },
            "type": {
              "description": "Figure variant: \"figure\" for image figures, \"native-table\" for table figures.",
              "type": "string",
              "default": "figure"
            },
            "environment": {
              "description": "LaTeX environment name for typesetting (e.g. \"figure*\" for two-column spanning).",
              "type": [
                "string",
                "null"
              ]
            },
            "orientation": {
              "description": "Image orientation: \"portrait\" or \"landscape\".",
              "type": "string",
              "default": "portrait"
            },
            "decorative": {
              "description": "When true, the image is decorative and should be skipped by screen readers.",
              "type": [
                "string",
                "null"
              ]
            },
            "scale-width": {
              "description": "Scale factor from 0 to 1 controlling how much of the text width the figure occupies.",
              "type": "number",
              "default": 1
            },
            "float-placement": {
              "description": "Float placement hint for typesetting (e.g. \"top\", \"bottom\", \"here\").",
              "type": [
                "string",
                "null"
              ]
            },
            "float-reference": {
              "description": "Float reference frame (e.g. \"column\", \"page\").",
              "type": [
                "string",
                "null"
              ]
            },
            "float-defer-page": {
              "description": "Number of pages to defer the float placement.",
              "type": [
                "string",
                "null"
              ]
            },
            "float-modifier": {
              "description": "Additional float modifier for the typesetting engine.",
              "type": [
                "string",
                "null"
              ]
            }
          },
          "additionalProperties": false
        },
        "content": {
          "type": "array",
          "description": "Child nodes. Content expression: `(table|code_block)? caption`.",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/table"
              },
              {
                "$ref": "#/$defs/code_block"
              },
              {
                "$ref": "#/$defs/caption"
              }
            ]
          },
          "minItems": 1
        },
        "marks": {
          "type": "array",
          "description": "Inline marks that may appear on child text nodes.",
          "items": {
            "$ref": "#/$defs/_mark"
          }
        }
      }
    },
    "placeHolder": {
      "type": "object",
      "description": "Placeholder atom for assets injected later (e.g. publisher logos in templates).",
      "required": [
        "type",
        "attrs"
      ],
      "additionalProperties": false,
      "properties": {
        "type": {
          "const": "placeHolder"
        },
        "attrs": {
          "type": "object",
          "properties": {
            "id": {
              "type": [
                "string",
                "null"
              ],
              "description": "Unique node identifier."
            },
            "type": {
              "description": "Placeholder type, e.g. \"logo\".",
              "type": "string",
              "default": "logo"
            },
            "label": {
              "description": "Human-readable label shown in the editor.",
              "type": "string",
              "default": "Logo"
            }
          },
          "additionalProperties": false
        }
      }
    },
    "_snapshotFile": {
      "type": "object",
      "description": "Descriptor for a file/asset referenced by the document (images, attachments, etc.).",
      "required": [
        "id"
      ],
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the asset."
        },
        "type": {
          "type": "string",
          "description": "Resource type, e.g. 'image'."
        },
        "url": {
          "type": "string",
          "description": "Full-resolution URL for fetching the asset."
        },
        "previewSrc": {
          "type": "string",
          "description": "Preview-sized URL or data URI used for in-document rendering."
        },
        "mimeType": {
          "type": "string",
          "description": "MIME type of the resource."
        },
        "name": {
          "type": "string",
          "description": "Human-readable name."
        },
        "dimensions": {
          "type": "object",
          "description": "Asset dimensions if known.",
          "properties": {
            "width": {
              "type": [
                "string",
                "number"
              ]
            },
            "height": {
              "type": [
                "string",
                "number"
              ]
            }
          },
          "required": [
            "width",
            "height"
          ],
          "additionalProperties": false
        }
      }
    },
    "_snapshotReference": {
      "type": "object",
      "description": "Bibliography/citation reference included alongside the snapshot.",
      "required": [
        "id",
        "rawReference"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique reference identifier."
        },
        "rawReference": {
          "type": "string",
          "description": "Plain-text bibliography string for this reference. Used as initial content when creating a reference node, and updated from node content on export. May be empty if the bibliography is generated from structured CSL data instead."
        },
        "mimeType": {
          "type": "string",
          "description": "Citation format MIME type, e.g. 'application/vnd.citationstyles.csl+json'.",
          "enum": [
            "application/vnd.openalex+json",
            "application/vnd.citationstyles.csl+json"
          ]
        }
      },
      "additionalProperties": true
    },
    "_selection": {
      "type": "object",
      "description": "ProseMirror selection state with anchor and head positions.",
      "required": [
        "anchor",
        "head"
      ],
      "properties": {
        "anchor": {
          "type": "number",
          "description": "Anchor position in the document."
        },
        "head": {
          "type": "number",
          "description": "Head position in the document."
        }
      },
      "additionalProperties": true
    }
  }
}
