Applying custom actions to selected preview text

you can create a custom JavaScript action that your users can perform on selected text in a generated preview. For example, you can specify the script to send the highlighted text to a database.

To create a custom action for your generated previews, use the following steps:

  1. In the Smart Previews installation folder, navigate to the ../SmartPreviews/SmartPreviewsFrontEnd/SmartPreview/HTMLViewer/src/js folder.

  2. Open the userCustomActionOnSelection.js file in a text editor.

  3. Set the value of the isEnableCustomActionDefinition variable to True. If you do not change this value to true, users will not see the Custom Action button on a generated preview.

  4. In the userCustomActionDefinition(value) function, enter your custom JavaScript for your action. By default, the alert(value) script is available. this script will return the highlighted text in an alert prompt.

  5. Optionally, you can update the name of your custom action button. This will change the name of the button for your users:

    1. In the userCustomActionOnSelection.js file, locate the captionOfCustomActionButton variable.

    2. Edit the Value to your desired custom action button name.

  6. When you are finished, save your updates to the file.

How users can interact with your custom action

After you have configured your custom action functionality, your users can interact with the action by doing the following:

  1. Open a document preview.

  2. Highlight a specific section of text on the preview.

  3. Right click and select User Custom Action (This will be a different name if you changed the name of your custom action button in step 5 above). After clicking this button, your configured custom action will apply to the selected text.