Provides several methods to create documents, folders, and modify them through use of TJSDialog and a modal and non-draggable by default user experience.

Index
  • Change ownership of a document by rendering a dialog to alter the default and all user / player ownership.

    Type Parameters

    • D extends Any

    Parameters

    • document: D

      Document instance to modify.

    • Optionaloptions: OptionsCore

      Rest of options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<D>

    The modified document or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Create a new Document of the type specified by documentCls by rendering a dialog window to provide basic creation details.

    Type Parameters

    • D extends AnyConstructor

    Parameters

    • documentCls: D

      Document class to create.

    • Optionaldata: object

      Document data.

    • Optionalcontext: { pack?: string; parent?: Any; renderSheet?: boolean } & Partial<OptionsCore>

      Additional context options or dialog positioning options.

      • Optionalpack?: string

        A Compendium pack identifier within which the Documents should be modified.

      • Optionalparent?: Any

        A parent Document within which these Documents should be embedded.

      • OptionalrenderSheet?: boolean

        Render the sheet for the new document.

      • parent

        A parent Document within which these Documents should be embedded.

      • pack

        A Compendium pack identifier within which the Documents should be modified.

      • renderSheet

        Render the sheet for the new document.

      • options

        Rest of options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<false | InstanceType<D>>

    The newly created document or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Shows a modal / non-draggable dialog to delete a document.

    Type Parameters

    • D extends Any

    Parameters

    • document: D

      Document to delete.

    • Optionaloptions: OptionsCore

      TJSDialog / SvelteApp options.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<false | D>

    The document if deleted or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Create a new Folder by rendering a dialog to provide basic creation details.

    Parameters

    • folderData: { folder?: string; type: string }

      Initial data with which to populate the creation form.

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<
        Folder<
            | "Actor"
            | "Adventure"
            | "Cards"
            | "Item"
            | "JournalEntry"
            | "Macro"
            | "Playlist"
            | "RollTable"
            | "Scene"
            | "Compendium",
        >,
    >

    The newly created Folder or null if the dialog is closed.

  • Deletes a folder and does delete subfolders / documents.

    Parameters

    • document: Folder

      Folder to delete.

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<
        Folder<
            | "Actor"
            | "Adventure"
            | "Cards"
            | "Item"
            | "JournalEntry"
            | "Macro"
            | "Playlist"
            | "RollTable"
            | "Scene"
            | "Compendium",
        >,
    >

    The deleted Folder or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Shows a modal / non-draggable dialog to export a folder to an eligible compendium pack.

    Parameters

    • document: Folder

      Folder to export.

    • Optionalopts: { keepId?: boolean; merge?: boolean; pack?: string } & Partial<OptionsCore>

      Additional options.

      • OptionalkeepId?: boolean

        Keep document IDs.

      • Optionalmerge?: boolean

        Update existing entries in the Compendium pack, matching by name

      • Optionalpack?: string

        The name of the compendium pack to provide an initial selection value in the dialog.

      • pack

        The name of the compendium pack to provide an initial selection value in the dialog.

      • merge

        Update existing entries in the Compendium pack, matching by name

      • keepId

        Keep document IDs.

      • options

        Rest of options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<any>

    The compendium collection the folder is exported to or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Removes a folder, but does not delete / remove sub-folders / documents.

    Parameters

    • document: Folder

      The folder to remove.

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<
        | false
        | Folder<
            | "Actor"
            | "Adventure"
            | "Cards"
            | "Item"
            | "JournalEntry"
            | "Macro"
            | "Playlist"
            | "RollTable"
            | "Scene"
            | "Compendium",
        >,
    >

    The removed Folder or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Create a RollTable from the contents of the Folder.

    Parameters

    • document: Folder

      Folder to create roll table from...

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<false | RollTable>

    The newly created RollTable or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.

  • Updates an existing Folder by rendering a dialog window with basic details.

    Parameters

    • document: Folder

      The folder to edit.

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<
        Folder<
            | "Actor"
            | "Adventure"
            | "Cards"
            | "Item"
            | "JournalEntry"
            | "Macro"
            | "Playlist"
            | "RollTable"
            | "Scene"
            | "Compendium",
        >,
    >

    The modified Folder or null if the dialog is closed.

  • Render an import dialog for updating the data related to this Document through an exported JSON file

    Type Parameters

    • D extends Any

    Parameters

    • document: D

      The document to import JSON to...

    • Optionaloptions: OptionsCore

      Options to pass to TJSDialog / SvelteApp.

    • OptionaldialogData: OptionsData

      Optional data to modify dialog.

    Returns Promise<false | D>

    The document after import completes or a falsy value; either 'false' for cancelling or 'null' if the user closed the dialog via <Esc> or the close header button.