HTML Kit site requirements.

HTML editor / Support Document
HomeHTML-Kit downloadsAdd-ins that update and extend HTML-Kit's capabilitiesSoftware and authoring support channelsRegister -- download add-ons and support HTML-KitOnline tools for HTML-Kit users
 

Support Document

 Home > Support > Support Documents > Plugins > How to: Write preview pl...
 
 
How to: Write preview plugins
The information in this document applies to:
 Summary

This document explains how to write plugins that can update/modify content sent to Preview and Active Preview windows.
 
 Details
  • Paste the following hkScript source code in to a file named demoPreviewPlugin.hks and install it using HTML-Kit's "Tools | Install | Plugins" main menu option.
     
  • After restarting HTML-Kit, go to "Edit | Preferences | Preview | Edit Preview Rules" from the main menu.
     
  • Click "Add" under "File mappings," enter "css" (without quotes) for the extensions and select the "demoPreviewPlugin" plugin.
     
  • Click "OK," "OK" and "OK."
     
  • Open a *.css file and click the "Preview" tab or open the "Active Preview" window.
     
  • Now the content in the editor will go through the demoPreviewPlugin.
     
--- cut here ---
function hkp_Register(pDataIn, pDataOut)
{
  hkp_DataSetGlobalSuffix("_1");

    // name of the plugin (must be unique)
  hkp_DataAdd(pDataOut, "NAME", "demoPreviewPlugin");

    // no need to show a button on the ActionsBar
    // (unless we're going to use it to configure
    // preview options, for example)
  hkp_DataAddInt(pDataOut, "BUTTON_VISIBLE", 0);

    // request the content in the editor
  hkp_DataAddInt(pDataOut, "MODE_IN_TEXT_FULL", 1);

    // request preview events
  hkp_DataAddInt(pDataOut, "PREVIEW_EVENT_ONPREVIEW", 1);

  hkp_DataSetGlobalSuffix("");
}

function hkp_Main(pDataIn, pDataOut)
{
    // is this a preview event?
  if( 1100 == hkp_DataGetInt(pDataIn, "EVENT", 0) )
  {
    var sText = "";

      // get the content in the editor
    if( hkp_DataGet(pDataIn, "INPUT", &sText) )
    {
        // modify the content, for example,
        // convert everything to uppercase
      sText = strupr( sText );

        // send the modified content to the preview window
      hkp_DataAdd(pDataOut, "PREVIEW_OUTPUT_CONTENT", sText);

        // use the following command to send a file/web URL
        // to preview, instead of sending the actual content:
        //  hkp_DataAdd(pDataOut, "PREVIEW_OUTPUT_URL", "url");
    }
  }

    // no other output either way
  hkp_DataAddInt(pDataOut, "MODE_OUTPUT", 1);
}
--- cut here ---
 
 
 
Document ID: H000136
Reviewed On: 09-Jan-2002
THE INFORMATION IN THIS DOCUMENT IS PROVIDED ON AN AS-IS BASIS WITHOUT WARRANTY OF ANY KIND. PROVIDER SPECIFICALLY DISCLAIMS ANY OTHER WARRANTY, EXPRESS OR IMPLIED, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL PROVIDER BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, SPECIAL OR INCIDENTAL DAMAGES, EVEN IF PROVIDER HAS BEEN ADVISED BY "USER" OF THE POSSIBILITY OF SUCH POTENTIAL LOSS OR DAMAGE. "USER" AGREES TO HOLD PROVIDER HARMLESS FROM AND AGAINST ANY AND ALL CLAIMS, LOSSES, LIABILITIES AND EXPENSES.