Doc kit command

caret.set

Set Caret

Puts the caret at a position (a document position, as file.selection answers) or at a point on a page, optionally extending the selection. With `unit` it selects the word, line, paragraph (with its mark) or paragraph's text (without it) at `pos`; with `extend` too, the selection grows by that unit from the range `start`..`end` (else the anchor), which stays selected.

Kit
Doc 0.1.0 (.docx)
Changes the document
no

Parameters

Parameters of caret.set
NameTypeRequiredDescription
endobjectnowhere the range the selection grows from ends (with `unit` and `extend`)
extendbooleannoin one of several forms of the parameters
pageintegernoin one of several forms of the parameters
posobjectnoa position as file.selection answers
startobjectnowhere the range the selection grows from starts (with `unit` and `extend`)
storystring | objectnoread by the command beside its listed parameters
unit"word" | "line" | "paragraph" | "paragraphText"noin one of several forms of the parameters
xnumbernopoints; in one of several forms of the parameters
ynumbernopoints; in one of several forms of the parameters

Call through doc_run

text
doc_run {
  "path": "<file>.docx",
  "steps": [{ "command": "caret.set" }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: end, extend, page, pos, start, story, unit, x, y. doc_run answers the step’s result in completed[i].result.

Result

Result of caret.set
NameTypeRequiredDescription
anchorobjectno
focusobjectno
Result JSON Schema
json
{
  "additionalProperties": true,
  "properties": {
    "anchor": {
      "additionalProperties": true,
      "properties": {
        "off": {
          "type": "number"
        },
        "path": {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        "story": {
          "type": "string"
        }
      },
      "type": "object"
    },
    "focus": {
      "additionalProperties": true,
      "properties": {
        "off": {
          "type": "number"
        },
        "path": {
          "items": {
            "type": "number"
          },
          "type": "array"
        },
        "story": {
          "type": "string"
        }
      },
      "type": "object"
    }
  },
  "type": "object"
}

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "end": {
      "additionalProperties": true,
      "description": "where the range the selection grows from ends (with `unit` and `extend`)",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "extend": {
      "description": "in one of several forms of the parameters",
      "type": "boolean"
    },
    "page": {
      "description": "in one of several forms of the parameters",
      "type": "integer"
    },
    "pos": {
      "additionalProperties": true,
      "description": "a position as file.selection answers",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "start": {
      "additionalProperties": true,
      "description": "where the range the selection grows from starts (with `unit` and `extend`)",
      "properties": {
        "off": {
          "description": "character offset in the paragraph",
          "type": "integer"
        },
        "path": {
          "description": "paragraph path counted from 0",
          "items": {
            "type": "integer"
          },
          "type": "array"
        },
        "story": {
          "description": "\"body\", or {\"part\": n} for a header, footer, note, comment or text box story",
          "oneOf": [
            {
              "enum": [
                "body"
              ],
              "type": "string"
            },
            {
              "additionalProperties": false,
              "properties": {
                "part": {
                  "description": "header, footer, footnote, endnote, comment or text box story number",
                  "type": "integer"
                }
              },
              "type": "object"
            }
          ]
        }
      },
      "type": "object"
    },
    "story": {
      "description": "read by the command beside its listed parameters",
      "oneOf": [
        {
          "type": "string"
        },
        {
          "additionalProperties": true,
          "type": "object"
        }
      ]
    },
    "unit": {
      "description": "in one of several forms of the parameters",
      "enum": [
        "word",
        "line",
        "paragraph",
        "paragraphText"
      ],
      "type": "string"
    },
    "x": {
      "description": "points; in one of several forms of the parameters",
      "type": "number"
    },
    "y": {
      "description": "points; in one of several forms of the parameters",
      "type": "number"
    }
  },
  "type": "object"
}

Generated from the command list of @kition/[email protected] and the kit itself (doc_commands through @kition/[email protected], built from KitionAI/kition-doc@41e14a8). As data: commands.jsonl.