sej
    Preparing search index...

    Type Alias History

    History: {
        addSerializableCommand: (command: typeof EmptyCommand) => void;
        clear: () => void;
        clearRedos: () => void;
        execute: (command: Command, optionalName?: string) => void;
        redo: () => void;
        redos: Command[];
        undo: () => Command | undefined;
        undos: Command[];
        enableSerialization(id: number): void;
        fromJSON(json: HistoryJSON): void;
        goToState(id: number): void;
        toJSON(): HistoryJSON;
    } & EditorPointer & Test

    Type declaration

    • addSerializableCommand: (command: typeof EmptyCommand) => void

      Add a Command that fromJSON can use.

    • clear: () => void

      Clears the history by resetting the undo and redo stacks and the ID counter. Also dispatches a signal indicating that the history has changed.

    • clearRedos: () => void

      Clears the redo stack and dispatches a history changed signal.

      This method resets the redos array to an empty state and notifies the editor that the history has changed by dispatching the historyChanged signal.

    • execute: (command: Command, optionalName?: string) => void

      Execute a Command.

    • redo: () => void

      Redo the last executed command Will fail if something goes wrong with the command.

    • redos: Command[]

      Array of commands that have been undone.

    • undo: () => Command | undefined

      Undo the last executed command. Will fail if something goes wrong with the command.

    • undos: Command[]

      Array of commands that have been executed.

    • enableSerialization: function
      • Enables serialization of commands in the history stack.

        This method ensures that all commands in the undo and redo stacks are serialized by invoking their toJSON method. It temporarily disables the sceneGraphChanged and historyChanged signals to prevent unnecessary updates during the serialization process.

        Parameters

        • id: number

          The state ID to which the history should be restored after serialization.

        Returns void

    • fromJSON: function
      • Populates the history state from a JSON object.

        Parameters

        • json: HistoryJSON

          The JSON object containing the history data.

          The method processes the undos and redos arrays from the JSON object, creating command instances and populating the respective history stacks. It also updates the idCounter to the highest command ID found in the JSON data.

          If a command cannot be created from the JSON data, an error is logged to the console.

          Finally, it dispatches a historyChanged signal with the last executed undo-command.

        Returns void

    • goToState: function
      • Go to a specific state in the history.

        Parameters

        • id: number

          State id to go to

        Returns void

    • toJSON: function
      • Converts the current history state to a JSON object.

        Returns HistoryJSON

        The JSON representation of the history, including undos and redos. If the 'settings/history' configuration key is not set, returns an empty history.