Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ProgramAuthor<SS>

ProgramAuthor is a Redux-connected component responsible for rendering and manipulating the chapter structure in the shape of a tree. It receives all its props via the Redux state tree.

Type parameters

  • SS

Hierarchy

Index

Constructors

constructor

  • Parameters

    Returns ProgramAuthor

Properties

Private boxMargin

boxMargin: Coords = [40, 55]

Private boxSize

boxSize: Coords = this.defaultBoxSize.slice() as Coords

Private canvasWidth

canvasWidth: number = window.innerWidth - 40 - 300

context

context: any

Private defaultBoxSize

defaultBoxSize: Coords = [200, 120]

props

props: Readonly<object> & Readonly<ProgramAuthorProps>

refs

refs: object

Type declaration

  • [key: string]: ReactInstance

state

state: Readonly<__type>

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<ProgramAuthorProps>, nextContext: any): void

Optional UNSAFE_componentWillUpdate

  • UNSAFE_componentWillUpdate(nextProps: Readonly<ProgramAuthorProps>, nextState: Readonly<__type>, nextContext: any): void

Private adjustBoxWidth

  • adjustBoxWidth(): void
  • Adjust the base width of chapter node boxes based on tree size and available canvas width.

    Returns void

Private adjustCanvasHeight

  • adjustCanvasHeight(chapters: List<Chapter>): number
  • Adjust the height of the drawing canvas based on the number of tree levels and available screen real estate.

    Parameters

    • chapters: List<Chapter>

      Chapter tree which will be drawn

    Returns number

    The calculated canvas height

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

Optional componentDidMount

  • componentDidMount(): void
  • Called immediately after a compoment is mounted. Setting state here will trigger re-rendering.

    Returns void

Optional componentDidUpdate

  • componentDidUpdate(prevProps: Readonly<ProgramAuthorProps>, prevState: Readonly<__type>, snapshot?: SS): void
  • Called immediately after updating occurs. Not called for the initial render.

    The snapshot is only present if getSnapshotBeforeUpdate is present and returns non-null.

    Parameters

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

  • componentWillReceiveProps(nextProps: Readonly<ProgramAuthorProps>, nextContext: any): void

Optional componentWillUnmount

  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

Optional componentWillUpdate

  • componentWillUpdate(nextProps: Readonly<ProgramAuthorProps>, nextState: Readonly<__type>, nextContext: any): void

Private drawChapterTree

  • drawChapterTree(chapters: List<Chapter>, startPos: [number, number], accessPath?: Array<number>): Array<any>
  • Draws the chapter tree starting from the level passed in as first argument. Visits all children in the data structure and draws them recursively as well and configures callbacks for interaction with the chapter nodes.

    Parameters

    • chapters: List<Chapter>

      Tree level from which to start drawing

    • startPos: [number, number]

      Position to start drawing at.

    • Default value accessPath: Array<number> = []

      Access path of the current chapter. Optional, only used for recursion.

    Returns Array<any>

    A series of components ready to be rendered inside a Stage component

forceUpdate

  • forceUpdate(callBack?: undefined | function): void
  • Parameters

    • Optional callBack: undefined | function

    Returns void

Optional getSnapshotBeforeUpdate

  • getSnapshotBeforeUpdate(prevProps: Readonly<ProgramAuthorProps>, prevState: Readonly<__type>): SS | null
  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns SS | null

Private getTreeOffset

  • Calculates the offset for the first level of the tree such that the tree can be drawn centred on the canvas.

    Parameters

    • chapters: List<Chapter>

      Chapter tree which will be drawn

    Returns Coords

    Offsets for x and y for the root of the tree such that the tree is centred on the canvas

Private handleAddChapterClick

  • handleAddChapterClick(accessPath: Array<number>, handlePosition: "left" | "right" | "bottom"): Promise<void>
  • Callback invoked when one of the three handles of a chapter node is clicked. These handles are intended to be used to add new chapters either before, after or as children of the clicked chapter.

    Parameters

    • accessPath: Array<number>

      The access path of the chapter node that was clicked

    • handlePosition: "left" | "right" | "bottom"

    Returns Promise<void>

Private handleChapterClick

  • handleChapterClick(accessPath: Array<number>): void
  • Callback invoked when a chapter node is clicked. This is intended to be used to navigate to the timeline editor for the chapter that was clicked.

    Parameters

    • accessPath: Array<number>

      The access path of the chapter node that was clicked

    Returns void

Private handleLabelClick

  • handleLabelClick(accessPath: Array<number>, currentName: string | undefined): Promise<void>
  • Callback invoked when the name label of a chapter node is clicked. This is intended to be used to change the name of a chapter.

    Parameters

    • accessPath: Array<number>

      The access path of the chapter node that was clicked

    • currentName: string | undefined

      The current name of the chapter node

    Returns Promise<void>

Private handleRemoveClick

  • handleRemoveClick(accessPath: Array<number>): Promise<void>
  • Callback invoked when the close icon on a chapter node is clicked.

    Parameters

    • accessPath: Array<number>

      The access path of the chapter node that was clicked

    Returns Promise<void>

render

  • render(): Element
  • Renders the component.

    Returns Element

setState

  • setState<K>(state: function | null | S | object, callback?: undefined | function): void
  • Type parameters

    • K: keyof __type

    Parameters

    • state: function | null | S | object
    • Optional callback: undefined | function

    Returns void

Optional shouldComponentUpdate

  • shouldComponentUpdate(nextProps: Readonly<ProgramAuthorProps>, nextState: Readonly<__type>, nextContext: any): boolean
  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    Returns boolean

Generated using TypeDoc