@dxos/app-framework - v0.16.0
    Preparing search index...

    Interface UndoMapping<Op, Inv>

    Undo mapping that links a forward operation to its inverse. Type parameters ensure deriveContext has correctly typed arguments.

    interface UndoMapping<
        Op extends
            Operation.Definition<any, any> = Operation.Definition<any, any>,
        Inv extends Operation.Definition<any, any> = Operation.Definition<any, any>,
    > {
        context?: (input: InputOf<Op>, output: OutputOf<Op>) => unknown;
        deriveContext: (
            input: InputOf<Op>,
            output: OutputOf<Op>,
        ) => undefined | InputOf<Inv>;
        inverse: Inv;
        merge?: (earlier: Invocation<Op>, later: Invocation<Op>) => Invocation<Op>;
        mergeKey?: (input: InputOf<Op>, output: OutputOf<Op>) => undefined | string;
        message?: MessageProvider<Op>;
        operation: Op;
        scope?: (input: InputOf<Op>, output: OutputOf<Op>) => undefined | string;
        toast?: boolean;
    }

    Type Parameters

    • Op extends Operation.Definition<any, any> = Operation.Definition<any, any>

      The forward operation definition type.

    • Inv extends Operation.Definition<any, any> = Operation.Definition<any, any>

      The inverse operation definition type.

    Index

    Properties

    context?: (input: InputOf<Op>, output: OutputOf<Op>) => unknown

    Optional opaque context (e.g. view path and selection) returned on undo and redo so the UI can return to where the change happened.

    deriveContext: (
        input: InputOf<Op>,
        output: OutputOf<Op>,
    ) => undefined | InputOf<Inv>

    Derives the input for the inverse operation from the forward operation's input and output.

    Type declaration

      • (input: InputOf<Op>, output: OutputOf<Op>): undefined | InputOf<Inv>
      • Parameters

        • input: InputOf<Op>

          The input that was passed to the forward operation.

        • output: OutputOf<Op>

          The output that was returned by the forward operation.

        Returns undefined | InputOf<Inv>

        The input to pass to the inverse operation, or undefined to indicate the operation is not undoable.

    inverse: Inv

    The inverse operation to invoke for undo.

    merge?: (earlier: Invocation<Op>, later: Invocation<Op>) => Invocation<Op>

    Optional fold of two merged invocations into one forward, from which the inverse is derived again; without it the entry keeps the earliest inverse and the latest forward, which suits absolute writes but not relative ones (a delta, or a patch between versions).

    mergeKey?: (input: InputOf<Op>, output: OutputOf<Op>) => undefined | string

    Optional merge key; consecutive entries in one scope with equal keys inside the tracker's merge window fold into one undo step (e.g. typing into one field).

    message?: MessageProvider<Op>

    Optional message to show in the undo toast. Can be a static Label or a function that derives the message from input/output.

    operation: Op

    The forward operation.

    scope?: (input: InputOf<Op>, output: OutputOf<Op>) => undefined | string

    Optional scope (document or subject id) so scoped undo/redo can act on this entry alone. Return undefined to leave the entry reachable only by unscoped undo/redo.

    toast?: boolean

    Whether recording an entry offers the undo toast; true when absent. An editor with undo keys of its own (a canvas) turns it off, since every gesture would raise one.