Skip to main content
Alpha: Document API is currently alpha and subject to breaking changes.

Summary

  • Operation ID: query.match
  • API member path: editor.doc.query.match(...)
  • Mutates document: no
  • Idempotency: idempotent
  • Supports tracked mode: no
  • Supports dry run: no
  • Deterministic target resolution: yes

Input fields

FieldTypeRequiredDescription
includeNodesbooleanno
limitintegerno
modeenumno"strict", "candidates"
offsetintegerno
requireenumno"any", "first", "exactlyOne", "all"
selectobject(type=“text”) \object(type=“node”)yesOne of: object(type=“text”), object(type=“node”)
withinNodeAddressnoNodeAddress

Example request

{
  "require": "any",
  "select": {
    "caseSensitive": true,
    "mode": "contains",
    "pattern": "hello world",
    "type": "text"
  },
  "within": {
    "kind": "block",
    "nodeId": "node-def456",
    "nodeType": "paragraph"
  }
}

Output fields

FieldTypeRequiredDescription
evaluatedRevisionstringyes
itemsobject(matchKind=“text”) \object(matchKind=“node”)[]yes
pagePageInfoyesPageInfo
totalintegeryes

Example response

{
  "evaluatedRevision": "rev-001",
  "items": [
    {
      "address": {
        "kind": "block",
        "nodeId": "node-def456",
        "nodeType": "paragraph"
      },
      "blocks": [
        {
          "blockId": "block-abc123",
          "nodeType": "paragraph",
          "paragraphStyle": {
            "isListItem": true,
            "styleId": "style-001"
          },
          "range": {
            "end": 10,
            "start": 0
          },
          "ref": "handle:abc123",
          "runs": [
            {
              "range": {
                "end": 10,
                "start": 0
              },
              "ref": "handle:abc123",
              "styleId": "style-001",
              "styles": {
                "bold": true,
                "color": "example",
                "highlight": "example",
                "italic": true,
                "strike": true,
                "underline": true
              },
              "text": "Hello, world."
            }
          ],
          "text": "Hello, world."
        }
      ],
      "handle": {
        "ref": "handle:abc123",
        "refStability": "stable",
        "targetKind": "text"
      },
      "highlightRange": {
        "end": 10,
        "start": 0
      },
      "id": "id-001",
      "matchKind": "text",
      "snippet": "...the quick brown fox..."
    }
  ],
  "page": {
    "limit": 50,
    "offset": 0,
    "returned": 1
  },
  "total": 1
}

Pre-apply throws

  • MATCH_NOT_FOUND
  • AMBIGUOUS_MATCH
  • INVALID_INPUT
  • INTERNAL_ERROR

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "includeNodes": {
      "type": "boolean"
    },
    "limit": {
      "minimum": 1,
      "type": "integer"
    },
    "mode": {
      "enum": [
        "strict",
        "candidates"
      ]
    },
    "offset": {
      "minimum": 0,
      "type": "integer"
    },
    "require": {
      "enum": [
        "any",
        "first",
        "exactlyOne",
        "all"
      ]
    },
    "select": {
      "oneOf": [
        {
          "additionalProperties": false,
          "properties": {
            "caseSensitive": {
              "type": "boolean"
            },
            "mode": {
              "enum": [
                "contains",
                "regex"
              ]
            },
            "pattern": {
              "type": "string"
            },
            "type": {
              "const": "text"
            }
          },
          "required": [
            "type",
            "pattern"
          ],
          "type": "object"
        },
        {
          "additionalProperties": false,
          "properties": {
            "kind": {
              "enum": [
                "block",
                "inline"
              ]
            },
            "nodeType": {
              "enum": [
                "paragraph",
                "heading",
                "listItem",
                "table",
                "tableRow",
                "tableCell",
                "image",
                "sdt",
                "run",
                "bookmark",
                "comment",
                "hyperlink",
                "footnoteRef",
                "tab",
                "lineBreak"
              ]
            },
            "type": {
              "const": "node"
            }
          },
          "required": [
            "type"
          ],
          "type": "object"
        }
      ]
    },
    "within": {
      "$ref": "#/$defs/NodeAddress"
    }
  },
  "required": [
    "select"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "evaluatedRevision": {
      "type": "string"
    },
    "items": {
      "items": {
        "oneOf": [
          {
            "additionalProperties": false,
            "properties": {
              "address": {
                "$ref": "#/$defs/NodeAddress"
              },
              "blocks": {
                "items": {
                  "$ref": "#/$defs/MatchBlock"
                },
                "minItems": 1,
                "type": "array"
              },
              "handle": {
                "$ref": "#/$defs/ResolvedHandle"
              },
              "highlightRange": {
                "$ref": "#/$defs/Range"
              },
              "id": {
                "type": "string"
              },
              "matchKind": {
                "const": "text"
              },
              "snippet": {
                "type": "string"
              }
            },
            "required": [
              "id",
              "handle",
              "matchKind",
              "address",
              "snippet",
              "highlightRange",
              "blocks"
            ],
            "type": "object"
          },
          {
            "additionalProperties": false,
            "properties": {
              "address": {
                "$ref": "#/$defs/NodeAddress"
              },
              "blocks": {
                "items": {
                  "$ref": "#/$defs/MatchBlock"
                },
                "maxItems": 0,
                "type": "array"
              },
              "handle": {
                "$ref": "#/$defs/ResolvedHandle"
              },
              "id": {
                "type": "string"
              },
              "matchKind": {
                "const": "node"
              }
            },
            "required": [
              "id",
              "handle",
              "matchKind",
              "address",
              "blocks"
            ],
            "type": "object"
          }
        ]
      },
      "type": "array"
    },
    "page": {
      "$ref": "#/$defs/PageInfo"
    },
    "total": {
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "evaluatedRevision",
    "total",
    "items",
    "page"
  ],
  "type": "object"
}