Skip to content

insert

ts
function Delta.insert(
  ops: Delta,
  content: string | EmbedValue,
  attributes?: OpAttributes | null,
): Delta

Adds an insert operation to the delta.

Example

ts
import { Delta } from "@monstermann/delta";

Delta.insert([], "Hello");
// [{ type: "insert", value: "Hello" }]

Delta.insert([], "Hello", { bold: true });
// [{ type: "insert", value: "Hello", attributes: { bold: true } }]
ts
import { Delta } from "@monstermann/delta";

pipe([], Delta.insert("Hello"));
// [{ type: "insert", value: "Hello" }]

pipe(
    [],
    Delta.insert("Hello", { bold: true }),
    Delta.insert(" world", { italic: true }),
);
// [{ type: "insert", value: "Hello", attributes: { bold: true } },
//  { type: "insert", value: " world", attributes: { italic: true } }]