A custom field allows to define a new field type via script.

Hierarchy

Properties

area: {
    flipX: boolean;
    flipY: boolean;
    h: number;
    hidden: boolean;
    page: number;
    rotation: number;
    subPage: number;
    w: number;
    x: number;
    y: number;
    zIndex: number;
}

The area of the field on the canvas as defined by the parameter. If the actual position is required, have a look at FieldBoundingBox and GetBoundingBox.

Type declaration

  • flipX: boolean

    Flag to control if the field is visible or hidden. Flipped fields will be mirrored horizontally.

  • flipY: boolean

    Flag to control if the field is vertically flipped or not. Flipped fields will be mirrored vertically.

  • h: number

    The height of the field on the canvas. Value in points.

  • hidden: boolean

    Flag to control if the field is visible or hidden. Hidden fields will not show in the UI and not on the output.

  • Readonly page: number

    The index of the page this field is on. The index is zero based.

  • rotation: number

    The rotation of the field on the canvas. Value in degrees. The rotation center is the top left coordinate.

  • Readonly subPage: number

    For spread setups only this is the index of the sub page. The index is zero based.

    • 0: left page
    • 1: right page
  • w: number

    The width of the field on the canvas. Value in points.

  • x: number

    The x coordinate of the field on the canvas. Value in points.

  • y: number

    The y coordinate of the field on the canvas. Value in points.

  • Readonly zIndex: number

    The z-index of the field on the page. The z-index defines the order of the fields on the page. The higher the z-index, the more on top the field is.

border: FieldBorder

The border object defines the field border settings - which includes not only the border itself but also the background fill of the field. This is available for all field types except path fields.

custom: {
    canvasBackgroundData: unknown;
    canvasData: unknown;
    canvasOverlayData: unknown;
    data: unknown;
    externalResources: unknown;
    fieldScaleFactor: number;
    type: string;
}

The custom object holds information specific to that field

Type declaration

  • Readonly canvasBackgroundData: unknown

    The canvas background data to render on the output. This data is in an internal format. Use the CustomFieldCanvas to write this data via normal drawing commands.

  • Readonly canvasData: unknown

    The canvas data to render on the output. This data is in an internal format. Use the CustomFieldCanvas to write this data via normal drawing commands.

  • Readonly canvasOverlayData: unknown

    The canvas overlay data to render on the output. This data is in an internal format. Use the CustomFieldCanvas to write this data via normal drawing commands.

  • data: unknown

    The data object is fully controlled by the script. It can be used to store any information needed by the script.

  • Readonly externalResources: unknown

    The external resources used by the field. This is generated automatically during rendering via CustomFieldCanvas.

  • fieldScaleFactor: number

    The scale factor of the field in relation to the document. This is used to scale the field to the correct size when rendering. Useful for higher resolution output. Default value is 2.

  • Readonly type: string

    This defines the specific type of the custom field as defined by a script. This is used to identify the code which will interact with this field.

id: string

The id of the field (GUID) as a unique identifier.

info: {
    customData: string;
    name: string;
    sequence: number;
    tags: string[];
}

The info or meta data details of the field.

Type declaration

  • customData: string

    The custom data is an arbitrary object which can be used to store additional information against the field. This is for scripting usage only. Note that there is only a single custom data object per field. So multiple scripts would have to consider a merge or overwrite strategy.

  • name: string

    The name of the field. By default empty, this can be used to provide semantic information to the field and will be used for logging, errors and debugging, but can also be helpful for field retrieval. The name of a field doesn't have to be unique and duplicates can happen.

  • sequence: number

    The sequence is used for auto mapping values when applying layouts. In order to determine which field of the new layout should be populated with the value of which field in the old layout the sequence is used. This is independent of creation order or z-index and allows to semantically control this. When generating fields the sequence is automatically set as an incrementing number.

  • tags: string[]

    The list of tags. Tags can be also used to retrieve fields and store additional meta data against the field. Note that a tag cannot contain the '|' character.

The issues object holds flags about the current health status of the field. Issues are being shown visually within the editor and a warning/error is triggered before adding the item to the cart.

restrictions: BaseFieldRestrictions

The restrictions object holds flags about the restrictions configured against the field. Restrictions control what manipulations are possible within the editor UI.

shadow: FieldShadow

The shadow object defines the field shadow settings. This is available for all field types except path fields.

type: FieldType

The type of the field

The UI options control the UI aviailable in the editor in relation to this field. Most of it will be used for the field specific dialog options.

Methods

  • Converts a relative field position (a position within the field from the top/left corner of the field without the rotation applied) to a global location on the canvas.

    Parameters

    • point: Point

      The point as the relative position.

    Returns Point

    The converted point as the global location.

  • Little helper to calculate the field bounding box - this includes also information about the location of all 4 corner points of the field on teh canvas.

    Returns FieldBoundingBox

    The bounding box of the field. This is the area the field occupies on the canvas.

  • Rearranges the field on the canvas by adjusting the z-index in relation to the other fields. Updates the field properties.

    Parameters

    Returns void

  • Refreshes the field with the latest parameters as used within the editor. As the script instance is decoupled, changes to the field object are not automatically reflected in the script instance. Use the refresh method to ensure the field object is up to date.

    Returns void

  • Save the changes of the script object back into the editor. This will update the field with the latest changes, but not every change will be reflected directly in the UI. Some changes would require reinitialization.

    Note that not all properties can be saved with this function:

    • page: currently cannot be changed, but fields can be copied to a new location and then the original can be deleted
    • z-index: use the rearrange function to change the z-index

    Returns void

  • Saves the changes of the script back into the editor, while allowing to control certain actions via a save options object. For further information of what can be saved Save

    Parameters

    • options: boolean | SaveOptions

      The save options to use for this operation. If the parameter is a boolean, the value is used for the 'addUndo' flag of SaveOptions.

    Returns void

Generated using TypeDoc