Note kit command

text.insert

Insert text

Inserts `text` at a text position (from 0) and answers the note's new length. Get positions from `text.find`; inserting at 0 puts text above the front matter.

Kit
Note 0.3.0 (Markdown (.md))
Changes the document
yes

Parameters

Parameters of text.insert
NameTypeRequiredDescription
atintegeryesWhere to insert.
expectedstringnoWhat the empty range at `at` holds: ""; any other text fails the insert.
textstringyesThe Markdown to insert.
unit"scalar" | "utf16"noHow positions are counted: Unicode characters (scalar, the default), or UTF-16 code units as the editor counts them.

Call through note_run

text
note_run {
  "path": "<file>.md",
  "steps": [{ "command": "text.insert", "params": { "at": <integer>, "text": <string> } }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: expected, unit. note_run answers the step’s result in completed[i].result.

Result

Result of text.insert
NameTypeRequiredDescription
lengthintegeryesThe note's length after the edit, in the request's unit.
Result JSON Schema
json
{
  "additionalProperties": false,
  "properties": {
    "length": {
      "description": "The note's length after the edit, in the request's unit.",
      "type": "integer"
    }
  },
  "required": [
    "length"
  ],
  "type": "object"
}

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "at": {
      "description": "Where to insert.",
      "type": "integer"
    },
    "expected": {
      "description": "What the empty range at `at` holds: \"\"; any other text fails the insert.",
      "type": "string"
    },
    "text": {
      "description": "The Markdown to insert.",
      "type": "string"
    },
    "unit": {
      "default": "scalar",
      "description": "How positions are counted: Unicode characters (scalar, the default), or UTF-16 code units as the editor counts them.",
      "enum": [
        "scalar",
        "utf16"
      ],
      "type": "string"
    }
  },
  "required": [
    "at",
    "text"
  ],
  "type": "object"
}

Generated from kition-sdk packages/script/kits/note.ts and the kit itself (kition-note@69e14d9). As data: commands.jsonl.