Foundry Virtual Tabletop - API Documentation - Version 14
    Preparing search index...

    The Application responsible for displaying and editing a single JournalEntry Document.

    HandlebarsApplication

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Accessors

    Methods

    _attachFrameListeners _awaitTransition _canDetach _canRender _configureRenderOptions _configureRenderParts _doEvent _getFrameButtons _getHeaderControls _headerControlButtons _initializeApplicationOptions _onChangeForm _onClose _onFirstRender _onRender _onRevealSecret _prepareContext _preparePartContext _preSyncPartState _renderFrame _renderHTML _replaceHTML _tearDown _updateFrame addEventListener attachWindow bringToFront changeTab close createPageDialog detachWindow dispatchEvent getPageSheet goToPage isPageVisible maximize minimize nextPage previousPage removeEventListener render renderChild setPosition submit toggleSearchMode toggleSidebar viewedPageDocuments _activatePagesInView _canAttach _canDragDrop _canDragStart _createContextMenu _getEntryContextOptions _getTabsConfig _headerControlContextEntries _insertElement _observeHeadings _observePages _onAttach _onClickAction _onClickImage _onClickTab _onContextMenuClose _onContextMenuOpen _onDetach _onDragStart _onDrop _onEditPage _onPageScroll _onPosition _onSearchFilter _onShowPlayers _onSubmitForm _postRender _preClose _preFirstRender _preparePageData _preparePagesContext _prepareSidebarContext _prepareSubmitData _prepareTableOfContents _prepareTabs _prePosition _preRender _processFormData _processSubmitData _refit _removeElement _renderFrameButtons _renderHeaderControl _renderHeadings _renderPageView _renderPageViews _setCurrentPage _synchronizeSidebar _toggleDisabled _updateButtonState _updatePosition _migrateConstructorParams inheritanceChain instances parseCSSDimension waitForImages

    Constructors

    • Parameters

      • options: any
      • ...args: any[]

      Returns JournalEntrySheet

    Properties

    options: DocumentSheetConfiguration

    Application instance configuration options.

    position: ApplicationPosition = ...

    The current position of the application with respect to the window.document.body.

    tabGroups: Record<string, string | null> = ...

    If this Application uses tabbed navigation groups, this mapping is updated whenever the changeTab method is called. Reports the active tab for each group, with a value of null indicating no tab is active. Subclasses may override this property to define default tabs for each group.

    _pages: Record<string, JournalSheetPageContext> = {}

    The cached list of processed page entries.

    _appId: number = 0

    An incrementing integer Application ID.

    _maxZ: number = ...

    The current maximum z-index of any displayed Application.

    BASE_APPLICATION: typeof ApplicationV2 = ApplicationV2

    Designates which upstream Application class in this class' inheritance chain is the base application. Any DEFAULT_OPTIONS of super-classes further upstream of the BASE_APPLICATION are ignored. Hook events for super-classes further upstream of the BASE_APPLICATION are not dispatched.

    DEFAULT_OPTIONS: {
        actions: {
            configCategories: (this: JournalEntrySheet) => void;
            createPage: () => any;
            editPage: (event: PointerEvent, target: HTMLElement) => any;
            goToHeading: (
                this: JournalEntrySheet,
                event: PointerEvent,
                target: HTMLElement,
            ) => void;
            nextPage: () => Promise<JournalEntrySheet> | undefined;
            previousPage: () => Promise<JournalEntrySheet> | undefined;
            showPlayers: () => void;
            toggleLock: (this: JournalEntrySheet) => void;
            toggleMode: (this: JournalEntrySheet) => Promise<JournalEntrySheet>;
            toggleSearch: () => Promise<JournalEntrySheet>;
            toggleSidebar: () => void;
        };
        classes: string[];
        form: { submitOnChange: boolean };
        position: { height: number; width: number };
        viewPermission: 0;
        window: { resizable: boolean };
    } = ...
    emittedEvents: readonly ["prerender", "render", "close", "position"] = ...
    OWNERSHIP_ICONS: { "0": string; "2": string; "3": string } = ...

    Icons for page ownership.

    PARTS: {
        pages: { scrollable: string[]; template: string };
        sidebar: { scrollable: string[]; template: string; templates: string[] };
    } = ...
    RENDER_STATES: Record<string, number> = ...

    The sequence of rendering states that describe the Application life-cycle.

    TABS: Record<string, ApplicationTabsConfiguration> = {}

    Configuration of application tabs, with an entry per tab group.

    VIEW_MODES: { MULTIPLE: number; SINGLE: number } = ...

    The available view modes for journal entries.

    Accessors

    • get classList(): DOMTokenList

      The CSS class list of this Application instance

      Returns DOMTokenList

    • get document(): ClientDocument

      The Document instance associated with the application

      Returns ClientDocument

    • get element(): HTMLElement

      The HTMLElement which renders this Application into the DOM.

      Returns HTMLElement

    entry

    • get form(): HTMLFormElement | null

      Does this Application have a top-level form element?

      Returns HTMLFormElement | null

    • get hasFrame(): boolean

      Does this Application instance render within an outer window frame?

      Returns boolean

    • get id(): string

      The HTML element ID of this Application instance. This provides a readonly view into the internal ID used by this application. This getter should not be overridden by subclasses, which should instead configure the ID in DEFAULT_OPTIONS or by defining a uniqueId during _initializeApplicationOptions.

      Returns string

    • get isEditable(): boolean

      Is this Document sheet editable by the current User? This is governed by the editPermission threshold configured for the class.

      Returns boolean

    • get isMultiple(): boolean

      Whether the sheet is in multi-page mode.

      Returns boolean

    • get isVisible(): boolean

      Is this Document sheet visible to the current User? This is governed by the viewPermission threshold configured for the class.

      Returns boolean

    • get locked(): boolean

      Whether the journal is locked and disallows modifications to the table of contents.

      Returns boolean

    • get minimized(): boolean

      Is this Application instance currently minimized?

      Returns boolean

    • get mode(): { MULTIPLE: number; SINGLE: number }

      Get the JournalEntry's current view mode.

      Returns { MULTIPLE: number; SINGLE: number }

    • get observer(): IntersectionObserver

      The currently active IntersectionObserver.

      Returns IntersectionObserver

    • get pageId(): string

      The ID of the currently-viewed page.

      Returns string

    • get pageIndex(): number

      The index of the currently-viewed page in the list of available pages.

      Returns number

    • get pagesInView(): HTMLElement[]

      The pages that are currently scrolled into view and marked as 'active' in the sidebar.

      Returns HTMLElement[]

    • get rendered(): boolean

      Is this Application instance currently rendered?

      Returns boolean

    • get searchMode(): string

      Get the JournalEntry's current search mode.

      Returns string

    • get sidebarExpanded(): boolean

      The expanded state of the sidebar.

      Returns boolean

    • get state(): number

      The current render state of the Application.

      Returns number

    • get title(): string

      Returns string

    • get window(): {
          close: HTMLButtonElement;
          content: HTMLElement;
          controls: HTMLButtonElement;
          header: HTMLElement;
          icon: HTMLElement;
          onDrag: Function;
          onResize: Function;
          pointerMoveThrottle: boolean;
          pointerStartPosition: ApplicationPosition;
          resize: HTMLElement;
          title: HTMLHeadingElement;
          windowId: string;
      }

      Convenience references to window header elements.

      Returns {
          close: HTMLButtonElement;
          content: HTMLElement;
          controls: HTMLButtonElement;
          header: HTMLElement;
          icon: HTMLElement;
          onDrag: Function;
          onResize: Function;
          pointerMoveThrottle: boolean;
          pointerStartPosition: ApplicationPosition;
          resize: HTMLElement;
          title: HTMLHeadingElement;
          windowId: string;
      }

    Methods

    • Returns void

    • Internal

      Wait for a CSS transition to complete for an element.

      Parameters

      • element: HTMLElement

        The element which is transitioning

      • timeout: number

        A timeout in milliseconds in case the transitionend event does not occur

      Returns Promise<void>

    • Whether this Application is permitted to detach from the main workspace. Managed children (those with an active parent) may detach to break the parent link and claim their own window.

      Returns boolean

    • Parameters

      • _options: any

      Returns void

    • Parameters

      • options: any

      Returns void

    • Parameters

      • options: any

      Returns any

    • Internal

      Perform an event in the application life-cycle. Await an internal life-cycle method defined by the class. Optionally dispatch an event for any registered listeners.

      Parameters

      • handler: Function

        A handler function to call

      • options: {
            async?: boolean;
            debugText?: string;
            eventName?: string;
            handlerArgs?: any[];
            hookArgs?: any[];
            hookName?: string;
            hookResponse?: boolean;
            parentClassHooks?: boolean;
        } = {}

        Options which configure event handling

        • Optionalasync?: boolean

          Await the result of the handler function?

        • OptionaldebugText?: string

          Debugging text to log for the event

        • OptionaleventName?: string

          An event name to dispatch for registered listeners

        • OptionalhandlerArgs?: any[]

          Arguments passed to the handler function

        • OptionalhookArgs?: any[]

          Arguments passed to the requested hook function

        • OptionalhookName?: string

          A hook name to dispatch for this and all parent classes

        • OptionalhookResponse?: boolean

          Add the handler response to hookArgs

        • OptionalparentClassHooks?: boolean

          Call hooks for parent classes in the inheritance chain?

      Returns void | Promise<void>

      A promise which resoles once the handler is complete if async is true

    • Parameters

      • options: any

      Returns any

    • Parameters

      • formConfig: any
      • event: any

      Returns void

    • Parameters

      • options: any

      Returns void

    • Parameters

      • context: any
      • options: any

      Returns Promise<void>

    • Parameters

      • context: any
      • options: any

      Returns Promise<void>

    • Parameters

      • event: any

      Returns void

    • Parameters

      • options: any

      Returns Promise<
          ApplicationRenderContext & {
              document: ClientDocument;
              editable: boolean;
              fields: any;
              model: ClientDocument;
              rootId: string;
              source: any;
              user: documents.User
              | null;
          },
      >

    • Parameters

      • partId: any
      • context: any
      • options: any

      Returns Promise<any>

    • Parameters

      • partId: any
      • newElement: any
      • priorElement: any
      • state: any

      Returns void

    • Parameters

      • options: any

      Returns Promise<HTMLElement>

    • Render an HTMLElement for the Application. An Application subclass must implement this method in order for the Application to be renderable.

      Parameters

      • context: ApplicationRenderContext

        Context data for the render operation

      • options: any

        Options which configure application rendering behavior

      Returns Promise<any>

      The result of HTML rendering may be implementation specific. Whatever value is returned here is passed to _replaceHTML

    • Parameters

      • result: any
      • content: any
      • options: any

      Returns void

    • Parameters

      • options: any

      Returns void

    • Parameters

      • options: any

      Returns void

    • Add a new event listener for a certain type of event.

      Parameters

      • type: string

        The type of event being registered for

      • listener: EmittedEventListener

        The listener function called when the event occurs

      • Optionaloptions: { once?: boolean } = {}

        Options which configure the event listener

        • Optionalonce?: boolean

          Should the event only be responded to once and then removed

      Returns void

    • Bring this Application window to the front of the rendering stack by increasing its z-index. Once ApplicationV1 is deprecated we should switch from _maxZ to ApplicationV2#maxZ We should also eliminate ui.activeWindow in favor of only ApplicationV2#frontApp

      Returns void

    • Change the active tab within a tab group in this Application instance.

      Parameters

      • tab: string

        The name of the tab which should become active

      • group: string

        The name of the tab group which defines the set of tabs

      • Optionaloptions: {
            event?: Event;
            force?: boolean;
            navElement?: HTMLElement;
            updatePosition?: boolean;
        } = {}

        Additional options which affect tab navigation

        • Optionalevent?: Event

          An interaction event which caused the tab change, if any

        • Optionalforce?: boolean

          Force changing the tab even if the new tab is already active

        • OptionalnavElement?: HTMLElement

          An explicit navigation element being modified

        • OptionalupdatePosition?: boolean

          Update application position after changing the tab?

      Returns void

    • Prompt the user with a Dialog for creation of a new JournalEntryPage.

      Returns any

    • Detach an application from the main workspace, and render it in a separate browser window. If this application is a registered child, detaching it breaks the parent link and gives it its own window.

      Parameters

      • Optionaloptions: any = {}

        Render options.

      Returns Promise<JournalEntrySheet>

    • Turn to a specific page.

      Parameters

      • pageId: string

        The ID of the page to turn to.

      • Optionaloptions: { anchor?: string } = {}
        • Optionalanchor?: string

          Optionally an anchor slug to focus within that page.

      Returns Promise<JournalEntrySheet> | undefined

    • Restore the Application to its original dimensions.

      Returns Promise<void>

    • Minimize the Application, collapsing it to a minimal header.

      Returns Promise<void>

    • Render the Application, creating its HTMLElement and replacing its innerHTML. Add it to the DOM if it is not currently rendered and rendering is forced. Otherwise, re-render its contents.

      Parameters

      • Optionaloptions: any = {}

        Options which configure application rendering behavior. A boolean is interpreted as the "force" option.

      • Optional_options: any = {}

        Legacy options for backwards-compatibility with the original ApplicationV1#render signature.

      Returns Promise<JournalEntrySheet>

      A Promise which resolves to the rendered Application instance

    • Update the Application element position using provided data which is merged with the prior position.

      Parameters

      Returns void | ApplicationPosition

      The updated application position

    • Programmatically submit an ApplicationV2 instance which implements a single top-level form.

      Parameters

      • OptionalsubmitOptions: object = {}

        Arbitrary options which are supported by and provided to the configured form submission handler.

      Returns Promise<any>

      A promise that resolves to the returned result of the form submission handler, if any.

    • Toggle the collapsed or expanded state of the sidebar.

      Returns void

    • Iterate over the JournalEntryPage documents which are currently visible in the sheet.

      Returns Generator<any, void, unknown>

    • Protected

      Highlights the currently-viewed page in the sidebar.

      Returns void

    • Protected

      Whether this Application is permitted to re-attach to the main workspace. Managed children (those with an active parent) cannot re-attach independently; their parent controls placement.

      Returns boolean

    • Protected

      Determine if drop operations are permitted.

      Parameters

      • selector: string

        The candidate HTML selector for dragging

      Returns boolean

      Can the current user drag this selector?

    • Protected

      Determine if drag operations are permitted.

      Parameters

      • selector: string

        The candidate HTML selector for dragging

      Returns boolean

      Can the current user drag this selector?

    • Protected

      Create a ContextMenu instance used in this Application.

      Parameters

      • handler: () => ContextMenuEntry[]

        A handler function that provides initial context options

      • selector: string

        A CSS selector to which the ContextMenu will be bound

      • Optionaloptions: { container?: HTMLElement; hookName?: string; parentClassHooks?: boolean } = {}

        Additional options which affect ContextMenu construction

        • Optionalcontainer?: HTMLElement

          A parent HTMLElement which contains the selector target

        • OptionalhookName?: string

          The hook name

        • OptionalparentClassHooks?: boolean

          Whether to call hooks for the parent classes in the inheritance chain.

      Returns ContextMenu | null

      A created ContextMenu or null if no menu items were defined

    • Protected

      Get the set of ContextMenu options which should be used for journal entry pages in the sidebar.

      Returns ContextMenuEntry[]

    • Protected

      Generate context menu entries based on the header control specification.

      Returns Generator<ContextMenuEntry, void, any>

    • Protected

      Insert the application HTML element into the DOM. Subclasses may override this method to customize how the application is inserted.

      Parameters

      • element: HTMLElement

        The element to insert

      • Optionaloptions: any = {}

        Render options.

      Returns Promise<void>

    • Protected

      Create an intersection observer to maintain a list of headings that are in view. This is much more performant than calling getBoundingClientRect on all headings whenever we want to determine this list.

      Returns void

    • Protected

      Create an intersection observer to maintain a list of pages that are in view.

      Returns void

    • Protected

      Actions performed after the Application has been re-attached to the main workspace. Registered child Applications are re-attached automatically after this method returns.

      Parameters

      • from: Document

        The Application's former host document. This document's window may have been closed.

      • to: Document

        The main workspace document.

      Returns void

    • Protected

      A generic event handler for action clicks which can be extended by subclasses. Action handlers defined in DEFAULT_OPTIONS are called first. This method is only called for actions which have no defined handler.

      Parameters

      • event: PointerEvent

        The originating click event

      • target: HTMLElement

        The capturing HTML element which defined a [data-action]

      Returns void

    • Protected

      Handle clicking an image to pop it out for fullscreen view.

      Parameters

      • event: PointerEvent

        The triggering click event.

      Returns void

    • Protected

      Handle click events on a tab within the Application.

      Parameters

      • event: PointerEvent

      Returns void

    • Protected

      Handle closing the context menu.

      Parameters

      • target: HTMLElement

        The element the context menu has been triggered for.

      Returns void

    • Protected

      Handle opening the context menu.

      Parameters

      • target: HTMLElement

        The element the context menu has been triggered for.

      Returns void

    • Protected

      Actions performed after the Application has been detached from the main workspace. Registered child Applications are moved into the same detached window automatically after this method returns.

      Parameters

      • from: Document

        The main workspace document.

      • to: Document

        The Application's new host document.

      Returns void

    • Protected

      Handle drag operations.

      Parameters

      • event: DragEvent

      Returns void

    • Protected

      Handle drop operations.

      Parameters

      • event: DragEvent

      Returns Promise<any>

    • Protected

      Handle editing one of the journal entry's pages.

      Parameters

      • event: PointerEvent

        The triggering event.

      • target: HTMLElement

        The action target.

      Returns any

    • Protected

      Handle new pages scrolling into view.

      Parameters

      • entries: IntersectionObserverEntry[]

        An array of element that have scrolled into or out of view.

      • observer: IntersectionObserver

        The IntersectionObserver that invoked this callback.

      Returns void

    • Protected

      Actions performed after the Application is re-positioned.

      Parameters

      Returns void

    • Protected

      Handle journal entry search and filtering.

      Parameters

      • event: KeyboardEvent

        The keyboard input event.

      • query: string

        The input search string.

      • rgx: RegExp

        The regular expression query that should be matched against.

      • html: HTMLElement

        The container to filter items from.

      Returns void

    • Protected

      Handle a request to show the JournalEntry to other Users.

      Returns void

    • Protected

      Handle submission for an Application which uses the form element.

      Parameters

      • formConfig: ApplicationFormConfiguration

        The form configuration for which this handler is bound

      • event: Event | SubmitEvent

        The form submission event

      Returns Promise<void>

    • Protected

      Perform post-render finalization actions.

      Parameters

      Returns Promise<void>

    • Protected

      Actions performed before closing the Application. Pre-close steps are awaited by the close process.

      Parameters

      • options: any

        Provided render options

      Returns Promise<void>

    • Protected

      Actions performed before a first render of the Application.

      Parameters

      Returns Promise<void>

    • Protected

      Prepare data used to update the Document upon form submission. This data is cleaned and validated before being returned for further processing.

      Parameters

      • event: SubmitEvent

        The originating form submission event

      • form: HTMLFormElement

        The form element that was submitted

      • formData: FormDataExtended

        Processed data for the submitted form

      • OptionalupdateData: object

        Additional data passed in if this form is submitted manually which should be merged with prepared formData.

      Returns object

      Prepared submission data as an object

      Subclasses may throw validation errors here to prevent form submission

    • Protected

      Prepare application tab data for a single tab group.

      Parameters

      • group: string

        The ID of the tab group to prepare

      Returns Record<string, ApplicationTab>

    • Protected

      Actions performed before the Application is re-positioned. Pre-position steps are not awaited because setPosition is synchronous.

      Parameters

      Returns void

    • Protected

      Actions performed before any render of the Application. Pre-render steps are awaited by the render process.

      Parameters

      Returns Promise<void>

    • Protected

      Customize how form data is extracted into an expanded object.

      Parameters

      • event: SubmitEvent | null

        The originating form submission event

      • form: HTMLFormElement

        The form element that was submitted

      • formData: FormDataExtended

        Processed data for the submitted form

      Returns object

      An expanded object of processed form data

      Subclasses may throw validation errors here to prevent form submission

    • Protected

      Submit a document update or creation request based on the processed form data.

      Parameters

      • event: SubmitEvent

        The originating form submission event

      • form: HTMLFormElement

        The form element that was submitted

      • submitData: object

        Processed and validated form data to be used for a document update

      • Optionaloptions: Partial<DatabaseUpdateOperation | DatabaseCreateOperation> = {}

        Additional options altering the request

      Returns Promise<
          {
              created?: Document<object, DocumentConstructionContext>;
              updated?: Document<object, DocumentConstructionContext>;
          },
      >

      The result of the form submission that communicates whether a Document was created or updated. It is possible that neither creation nor update occurred.

      An Error if Document creation or update was prohibited

    • Protected

      Re-fit an application to its content following a change in its natural size.

      Parameters

      • OptionalpositionUpdate: Partial<ApplicationPosition> = {}

        Position data forwarded to setPosition.

      Returns void

    • Protected

      Remove the application HTML element from the DOM. Subclasses may override this method to customize how the application element is removed.

      Parameters

      • element: HTMLElement

        The element to be removed

      Returns void

    • Protected

      Render buttons that are inserted directly into the frame header. Header controls should be preferred over frame buttons, which should be used sparingly.

      Parameters

      • options: any

        Options which configure application rendering behavior.

      Returns Promise<void>

    • Protected

      Add headings to the table of contents for the given node.

      Parameters

      • pageNode: HTMLElement

        The HTML node of the page's rendered contents.

      • toc: Record<string, JournalEntryPageHeading>

        The page's table of contents.

      Returns Promise<void>

    • Protected

      Render the page view for a page sheet.

      Parameters

      • element: HTMLElement

        The existing page element in the journal entry view.

      • sheet: JournalEntryPageSheet

        The page sheet.

      Returns Promise<void>

    • Protected

      Update which page of the journal sheet should be currently rendered. This can be controlled by options passed into the render method, or by subclass override.

      Parameters

      • Optionaloptions: any = {}

      Returns void

    • Protected

      If the set of active pages has changed, various elements in the sidebar will expand and collapse. For particularly long ToCs, this can leave the scroll position of the sidebar in a seemingly random state. We try to do our best to sync the sidebar scroll position with the current journal viewport.

      Returns void

    • Protected

      Disable or reenable all form fields in this application.

      Parameters

      • disabled: boolean

        Should the fields be disabled?

      Returns void

    • Protected

      Update the disabled state of the previous and next page buttons.

      Returns void

    • Protected

      Translate a requested application position updated into a resolved allowed position for the Application. Subclasses may override this method to implement more advanced positioning behavior.

      Parameters

      Returns ApplicationPosition

      Resolved Application positioning data

    • Internal

      Provide a deprecation path for converted V1 document sheets.

      Parameters

      • first: unknown

        The first parameter received by this class's constructor

      • rest: unknown[]

        Any additional parameters received

      Returns Partial<DocumentSheetConfiguration>

    • Iterate over the inheritance chain of this Application. The chain includes this Application itself and all parents until the base application is encountered.

      Returns Generator<typeof ApplicationV2, void, unknown>

    • Iterate over the instances of this Application.

      Returns Generator<typeof ApplicationV2, any, any>

    • Parse a CSS style rule into a number of pixels which apply to that dimension.

      Parameters

      • style: string

        The CSS style rule

      • parentDimension: number

        The relevant dimension of the parent element

      Returns number | void

      The parsed style dimension in pixels

    • Wait for any images in the given element to load.

      Parameters

      • element: HTMLElement

        The element.

      Returns Promise<void>