Perseus
    Preparing search index...

    Hierarchy

    Implements

    Index

    Constructors

    Properties

    _currentFocus: FocusPath
    _foundTextNodes: boolean
    _getDefaultWidgetInfo: (widgetId: string) => any = ...
    _getInitialWidgetState: (
        props: Props,
    ) => { widgetInfo: Readonly<MakeWidgetMap<PerseusWidgetTypes>> } = ...
    _getWidgetInfo: (widgetId: string) => PerseusWidget = ...
    _interactionTrackers: { [id: string]: InteractionTracker<any> }
    _isMounted: boolean
    _isTwoColumn: boolean
    _onWidgetBlur: (id: string, blurPath: FocusPath) => void = ...
    _onWidgetFocus: (id: string, focusPath?: readonly string[]) => void = ...
    _setCurrentFocus: (path: FocusPath) => void = ...
    _translationLinter: default
    _widgetContainers: Map<string, WidgetContainer> = ...
    blur: () => void = ...
    blurPath: (path: FocusPath) => void = ...

    If using the new style context, re-declare this in your class to be the React.ContextType of your static contextType. Should be used with type annotation or static contextType.

    static contextType = MyContext
    // For TS pre-3.7:
    context!: React.ContextType<typeof MyContext>
    // For TS 3.7 and above:
    declare context: React.ContextType<typeof MyContext>
    findInternalWidgets: (
        filterCriterion: FilterCriterion,
    ) => readonly (Widget | null | undefined)[] = ...

    Allows inter-widget communication.

    This function yields this Renderer's own internal widgets, and it's used in two places.

    First, we expose our own internal widgets to each other by giving them a findWidgets function that, in turn, calls this function.

    Second, we expose our own internal widgets to this Renderer's parent, by allowing it to call this function directly. That way, it can hook us up to other Renderers on the page, by writing a findExternalWidgets prop that calls each other Renderer's findInternalWidgets function.

    Takes a filterCriterion on which widgets to return. filterCriterion can be one of:

    • A string widget id
    • A string widget type
    • a function from (id, widgetInfo, widgetComponent) to true or false

    Returns an array of the matching widget components.

    If you need to do logic with more than the components, it is possible to do such logic inside the filter, rather than on the result array.

    "Remember: abilities are not inherently good or evil, it's how you use them." ~ Kyle Katarn Please use this one with caution.

    findWidgets: (filterCriterion: FilterCriterion) => any = ...

    Allows inter-widget communication.

    Includes both widgets internal to this Renderer, and external widgets exposed by the findExternalWidgets prop.

    See findInteralWidgets for more information.

    focus: () => boolean | null | undefined = ...
    focusPath: (path: FocusPath) => void = ...
    getApiOptions: () => APIOptionsWithDefaults = ...
    getContent: (props: Props, state: State) => any = ...
    getDOMNodeForPath: (path: FocusPath) => Element | Text | null | undefined = ...
    getInputPaths: () => readonly FocusPath[] = ...
    getWidgetIds: () => readonly string[] = ...

    Returns an array of all widget IDs in the order they occur in the content.

    getWidgetInstance: (id: string) => Widget | null | undefined = ...
    handleRender: (prevProps: Props) => void = ...
    handletranslationLintErrors: (lintErrors: readonly string[]) => void = ...
    outputMarkdown: (ast: any, state: WidgetState) => ReactElement = ...
    outputNested: (ast: any, state: WidgetState) => ReactElement = ...
    outputNode: (node: any, nestedOutput: any, state: WidgetState) => any = ...
    renderWidget: (impliedType: string, id: string, state: WidgetState) => ReactNode = ...
    replaceJiptContent: (content: string, paragraphIndex: number) => void = ...
    serialize: () => Record<any, any> = ...

    Serializes widget state. Seems to be used only by editors though.

    and likely a very broken API [LEMS-3185] do not trust serializedState

    shouldRenderJiptPlaceholder: (props: Props, state: State) => boolean = ...
    translationIndex: number
    widgetIds: string[]
    contextType: Context<I18nContextType> = PerseusI18nContext

    If set, this.context will be set at runtime to the current value of the given Context.

    type MyContext = number
    const Ctx = React.createContext<MyContext>(0)

    class Foo extends React.Component {
    static contextType = Ctx
    context!: React.ContextType<typeof Ctx>
    render () {
    return <>My context's value: {this.context}</>;
    }
    }
    defaultProps: DefaultProps = ...

    Methods

    • Called immediately after a component is mounted. Setting state here will trigger re-rendering.

      Returns 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

    • 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

    • Returns an array of widget ids that are empty (meaning widgets where the learner has not interacted with the widget yet or has not filled in all fields). For example, the interactive-graph widget is considered empty if the graph is in the starting state.

      Returns readonly string[]

    • 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 any