Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TadCommand

TadCommand (Library)

This is a class that is used for running Drafts commands. These commands are based on the slash command approach of other systems.

Hierarchy

  • TadCommand

Index

Constructors

constructor

  • Creates new instance of TadCommand class.

    Returns TadCommand

Methods

TA_cmdDraft

  • TA_cmdDraft(): void
  • Runs a slash command from the end of the current line in the editor. This is really just a convenience function for the TA_command function.

    // Example
    tadCmd.TA_cmdDraft();
    

    Returns void

TA_cmdPrompt

  • TA_cmdPrompt(): void
  • Runs a slash command from a prompt given to the user. This is really just a convenience function for the TA_command function.

    // Example
    tadCmd.TA_cmdPrompt();
    

    Returns void

TA_command

  • TA_command(p_strMode?: string): void
  • Runs a slash command. The function accepts a single parameter that specifies a mode, Draft or Prompt (default).

    • In Draft mode, the function will scan the current line for the last forward slash and then attempt to read everything from, and including, the slash, as a command.
    • In Prompt mode, the user is presented with a pop-up into which to enter the command. The command is then interprested based on the commands settings in the library settings. The commands settings are a set of JSON that defines a command as the key value, and the operation as the value, along with any parameter use. There are three operations:
    1. OPEN_URL - which opens a URL.
    2. RUN_ACTION - which runs an action by name.
    3. RUN_FUNCTION - which runs a JavaScript function by name.

    Any parameters are either specified in the JSON, or a placeholder of <1> is used to indicate that the parameters are entered after the command.

    Example commands can be found in the TadLibrary initialisation function (constructor()).

    Parameters

    • Optional p_strMode: string

      the command entry mode the function will use. Defaults to Prompt.

      // Example
      tadCmd.TA_command("Draft");
      

    Returns void

TA_slashSplit

  • TA_slashSplit(): string
  • Picks out the slash command from the end of the current line in the editor. The function tracks back from the current line (based on the end of and selection), splits the line by forward slashes, then grabs the last part of the array it produces. This is removed form the text and then returned. If no slash is found, nothing is returned.

    // Example
    tadCmd.TA_slashSplit("This is some text/run Prepare Draft");
    

    Returns string