Timeline

Timeline

DALS.Timeline: Represents a singular timeline in an undo/redo tree within the Delta Action Logging System (DALS). .value is structured as an Array<Object>, with [0] representing the head state, and subsequent elements state mutations.

Note that actions should generally be pushed to a timeline using the corresponding addAction(arg0_json:Object|string) function. DALS.undo()/DALS.redo() should generally be called instead of specific jumpTo() instructions within a timeline.

Constructor:
  • arg0_options: Object
    • .name: string
    • .parent_timeline: Array<string, number> - [0] represents the DALS.Timeline .id belonging to the parent timeline, and [1] the index of the parent branch node.
Instance:
  • .id=Class.generateRandomID(DALS.Timeline): string
  • .initial_timeline: boolean
  • .name="Timeline " + this.id: string
  • .parent_timeline: Array<string, number>
  • .value: Array<string> - Array of JSON strings. [0] represents the state head, [n] represents state mutations.
Methods:
  • addAction(arg0_json:Object|string, arg1_options:{ do_not_parse_action:boolean }) | DALS.Action - Pushes an action to the timeline, and attempts to parse it automatically.

  • branch(arg0_options:Object) | DALS.Timeline - arg0_options is the same as the options asked for DALS.Timeline.

  • delete() - Deletes and removes the present timeline.

  • jumpToAction(arg0_action_id:number|string)

  • jumpToEnd()

  • jumpToStart()

  • removeAction(arg0_action_id:number|string) - arg0_action_id is either the index of the action, or its .id.

  • fromJSON(arg0_json:Object|string) | DALS.Timeline

  • toJSON() | Object

Static Fields:
  • .current_index: number - The index of the current timeline the state is at.
  • .current_timeline: string - The ID of the current timeline being displayed.
  • .instances: Array<DALS.Timeline>
Static Methods:

Constructor

new Timeline()

Source:

Members

current_index :number

Source:
Type:
  • number

current_timeline :string

Source:
Type:
  • string

Methods

(async) addAction(arg0_json, arg1_optionsopt) → {DALS.Action}

Adds a given action to the current timeline and immediately parses it by default.

Source:
Parameters:
Name Type Attributes Description
arg0_json Object | string
arg1_options Object <optional>
Name Type Attributes Default Description
do_not_parse_action boolean <optional>
false
Returns:
Type:
DALS.Action

assignChildTimelines()

Assigns the .child_timelines field for the present timeline by looking for any attached DALS.Timeline instances.

Source:

branch(arg0_optionsopt) → {DALS.Timeline}

Branches off a new timeline from the current timeline. If the current timeline is not selected, the branch node is automatically placed at the end of the timeline.

Source:
Parameters:
Name Type Attributes Default Description
arg0_options Object <optional>
{}

Refer to DALS.Timeline.options for information on what options are acceptable.

Returns:
Type:
DALS.Timeline

(async) delete()

Deletes the present timeline and removes its references.

Source:

fromJSON(arg0_json) → {DALS.Timeline}

Overwrites the current timeline instance with data from a JSON object.

Source:
Parameters:
Name Type Description
arg0_json Object | string
Returns:
Type:
DALS.Timeline

generateFlippedGraph() → {Object}

Flips a generated graph from generateGraph() by switching the .x/.y coordinates of each node.

Source:
Returns:
Type:
Object

generateGraph(arg0_options) → {Object}

Generates a timeline graph starting from the current DALS.Timeline instance with plotted .x/.y fields for node positions. Used in ve.Component.UndoRedo for rendering canvas displays.

Source:
Parameters:
Name Type Description
arg0_options Object
Returns:
Type:
Object

getGroups() → {Array.<Array.<DALS.Action>>}

Groups together actions with the same .key field to avoid their duplication and returns the grouped .value of the present timeline accordingly.

Source:
Returns:
Type:
Array.<Array.<DALS.Action>>

getTimelineWidth() → {number}

Returns the width of the present timeline, accounting for any .child_timelines that may exist.

Source:
Returns:
Type:
number

(async) jumpToAction(arg0_action_id)

Jumps to a specific action ID in the timeline, starting from its head, utilising .parseAction()

Source:
Parameters:
Name Type Description
arg0_action_id number | string

(async) jumpToEnd()

Jumps to the end of this timeline.

Source:

jumpToStart()

Jumps to the start of this timeline.

Source:

removeAction(arg0_action_id)

Removes an action from the timeline based upon its ID.

Source:
Parameters:
Name Type Description
arg0_action_id string

toJSON() → {Object}

Returns a JSON representation of the current timeline.

Source:
Returns:
Type:
Object

(async, static) fromJSON(arg0_json, arg1_optionsopt)

Reconstructs all timelines from a JSON object or string.

Source:
Parameters:
Name Type Attributes Description
arg0_json Object | string
arg1_options Object <optional>
Name Type Attributes Default Description
do_not_overwrite boolean <optional>
false

If true, existing timelines and actions are preserved.

(static) generateGraph() → {Object}

Generates a global timeline graph from the root DALS.Timeline.initial_timeline.

Source:
Returns:
Type:
Object

(static) getGraphMaxX(arg0_graph) → {number}

Returns the max .x value from a given graph from DALS.Timeline.generateGraph() to assess its dimensions.

Source:
Parameters:
Name Type Description
arg0_graph Object
Returns:
Type:
number

(static) getGraphMaxY(arg0_graph) → {number}

Returns the max .y value from a given graph from DALS.Timeline.generateGraph() to assess its dimensions.

Source:
Parameters:
Name Type Description
arg0_graph Object
Returns:
Type:
number

(static) getTimeline(arg0_timeline_id) → {DALS.Timeline}

Returns a DALS.Timeline object based upon a timeline ID string.

Source:
Parameters:
Name Type Description
arg0_timeline_id Object | string
Returns:
Type:
DALS.Timeline

(static) jumpToTimeline(arg0_timeline_id)

Jumps to the start of a timeline based off its ID.

Source:
Parameters:
Name Type Description
arg0_timeline_id DALS.Timeline | string

(static) load(arg0_file_path, arg1_optionsopt)

Loads DALS from a given filepath.

Source:
Parameters:
Name Type Attributes Description
arg0_file_path string
arg1_options Object <optional>

The same options passed for DALS.Timeline.fromJSON.

(static) parseAction(arg0_jsonopt)

Parses an action for DALS/ve.UndoRedo. Contract function.

Source:
Parameters:
Name Type Attributes Description
arg0_json Object | string <optional>
Name Type Attributes Description
options Object <optional>
Name Type Attributes Default Description
name string <optional>
"New Action"
key string <optional>
value Array.<Object> <optional>

[n]: { type: string, <action_key>: any }

(async, static) redo() → {number}

Redoes an action group in the current timeline. Returns the jumped to index.

Source:
Returns:
Type:
number

(static) save(arg0_file_path)

Saves DALS to an existing file if possible.

Source:
Parameters:
Name Type Description
arg0_file_path string

(static) toJSON() → {Object}

Serialises all DALS.Timeline instances and global registry state into a single JSON-compatible object.

Source:
Returns:
Type:
Object

(async, static) undo() → {number}

Undoes an action group in the current timeline. Returns the jumped to index.

Source:
Returns:
Type:
number