moderator-toolbox-nxg-for-reddit / dom/uiLocations

dom/uiLocations

Functions

LocationRenderers()

LocationRenderers(__namedParameters): Element

Defined in: extension/data/dom/uiLocations.tsx:167

Renders all registered renderers for location into the current React tree.

Use this when the host is itself a Toolbox-owned React component (e.g. the modbar) and you want to avoid creating a separate React root. The target element is passed unchanged to each renderer as UILocationRenderArgs.target.

Parameters

__namedParameters

LocationRenderersProps

Returns

Element


provideLocation()

provideLocation(location, target, context, options?): () => void

Defined in: extension/data/dom/uiLocations.tsx:236

Declare that a concrete Reddit DOM target provides a named UI location.

Creates a Toolbox host element appended to target and mounts a React root that renders all registered renderers for location. Renderers added or removed later automatically reflect in the mounted React root.

Call the returned cleanup to unmount the React root and remove the host.

Parameters

location

UILocation

target

Element

context

UILocationContext

options?

ProvideLocationOptions = {}

Returns

() => void


refreshProvidedLocation()

refreshProvidedLocation(location, target, context, options?): () => void

Defined in: extension/data/dom/uiLocations.tsx:296

Re-trigger provider logic for a target element.

Providers that are driven by LocationRenderers respond to renderer registry changes automatically, so this is only needed when the context passed to provideLocation has changed and the provider should be re-created with new context data.

Parameters

location

UILocation

target

Element

context

UILocationContext

options?

ProvideLocationOptions

Returns

() => void


removeProvidedLocation()

removeProvidedLocation(target, location?): void

Defined in: extension/data/dom/uiLocations.tsx:275

Remove a provided location (or all locations) from a target element.

If location is omitted, removes all provided locations for the target.

Parameters

target

Element

location?

UILocation

Returns

void


renderAtLocation()

renderAtLocation(location, options, render): () => void

Defined in: extension/data/dom/uiLocations.tsx:205

Register a React renderer for a named UI location.

The renderer is called once per active provider for location. When the renderer returns null, it contributes nothing for that provider instance.

Returns a cleanup function that unregisters the renderer.

Parameters

location

UILocation

options

RegisterLocationRendererOptions

render

(args) => ReactNode

Returns

() => void

Interfaces

LocationRenderersProps

Defined in: extension/data/dom/uiLocations.tsx:154

Props for the LocationRenderers React component.

Properties

context

Defined in: extension/data/dom/uiLocations.tsx:156

location

location: UILocation

Defined in: extension/data/dom/uiLocations.tsx:155

target

target: Element

Defined in: extension/data/dom/uiLocations.tsx:157


ProvideLocationOptions

Defined in: extension/data/dom/uiLocations.tsx:112

Properties

hostTag?

optional hostTag?: string

Defined in: extension/data/dom/uiLocations.tsx:122

HTML tag for the Toolbox host element. Default ‘div’. Use ‘li’ when providing into a Reddit

    flat-list button row so the host element is valid HTML inside a list.

key?

optional key?: string

Defined in: extension/data/dom/uiLocations.tsx:114

Passed to mountToTarget for idempotent re-provision.

shadow?

optional shadow?: boolean

Defined in: extension/data/dom/uiLocations.tsx:116

false = light DOM; use for old Reddit

    lists and form button rows. Default true.


RegisterLocationRendererOptions

Defined in: extension/data/dom/uiLocations.tsx:103

Options for registering a renderer via renderAtLocation.

Properties

id

id: string

Defined in: extension/data/dom/uiLocations.tsx:105

Unique identifier for this renderer; used for deduplication.

lifecycle?

optional lifecycle?: Lifecycle

Defined in: extension/data/dom/uiLocations.tsx:107

When provided, the renderer is automatically unregistered when the lifecycle is cleaned up.

order?

optional order?: number

Defined in: extension/data/dom/uiLocations.tsx:109

Render order relative to other renderers at the same location; lower values render first.


UILocationContext

Defined in: extension/data/dom/uiLocations.tsx:78

Contextual data about the Reddit DOM location provided to each registered renderer.

Properties

author?

optional author?: string

Defined in: extension/data/dom/uiLocations.tsx:81

commentId?

optional commentId?: string

Defined in: extension/data/dom/uiLocations.tsx:85

isRemoved?

optional isRemoved?: boolean

Defined in: extension/data/dom/uiLocations.tsx:88

True when the thing has been removed.

kind

Defined in: extension/data/dom/uiLocations.tsx:80

pageType?

optional pageType?: string

Defined in: extension/data/dom/uiLocations.tsx:90

Page type string from TBPageContext (e.g. 'queueListing').

platform

platform: RedditPlatform

Defined in: extension/data/dom/uiLocations.tsx:79

postId?

optional postId?: string

Defined in: extension/data/dom/uiLocations.tsx:84

rawDetail?

optional rawDetail?: unknown

Defined in: extension/data/dom/uiLocations.tsx:92

Raw platform-specific detail object for advanced use cases.

subreddit?

optional subreddit?: string

Defined in: extension/data/dom/uiLocations.tsx:82

thingId?

optional thingId?: string

Defined in: extension/data/dom/uiLocations.tsx:83


UILocationRenderArgs

Defined in: extension/data/dom/uiLocations.tsx:96

Arguments passed to each renderer function registered via renderAtLocation.

Properties

context

Defined in: extension/data/dom/uiLocations.tsx:97

target

target: Element

Defined in: extension/data/dom/uiLocations.tsx:99

The concrete DOM element that is providing this location.

Type Aliases

UILocation

UILocation = "authorActions" | "thingActions" | "thingDetails" | "thingDomainControls" | "thingFlatListActions" | "thingTaglineStatus" | "commentDistinguishControls" | "thingNativeActionReplacement" | "commentThreadControls" | "commentComposerControls" | "queueToolbar" | "queueThingSelection" | "queueTabControls" | "wikiEditorControls" | "stylesheetEditorControls" | "userTextControls" | "modmailComposerControls" | "contentMenuControls" | "sidebarControls" | "modbar" | "modbarContent" | "modbarCounters" | "modLogControls"

Defined in: extension/data/dom/uiLocations.tsx:21


UILocationKind

UILocationKind = "post" | "comment" | "user" | "queue" | "queueTab" | "commentThread" | "commentComposer" | "wikiEditor" | "stylesheetEditor" | "userText" | "modmailComposer" | "sidebar" | "thingNativeAction" | "modbar" | "overlay" | "page"

Defined in: extension/data/dom/uiLocations.tsx:59