content.ts

This file defines section content settings available to users in the Instant Site Editor. If some content settings like texts or images should be modifiable or if you want to provide some choices for users, you must add these settings to the content.ts file.

Ecwid will automatically build UI for the Editor, so you only need to declare the settings and their properties, for example, type and label, in this file. And import user settings to the section-name.vue file.

Each setting is referred to as an element and is defined by the element_id object with its properties inside. You can add multiple elements of the same type to the file if they have unique element_id. If some of the content settings should have related design settings, use the same element_id in both content.ts and design.ts files to link them.

Code example for a simple "Main title" input field (label and placeholder texts are defined in translations.ts file):

export default {
	element_id: {
		type: 'INPUTBOX',
		label: '$label.section_description.label',
		placeholder: '$label.section_description.placeholder',
	},
} as const;

"Main title" input field in the Instant Site Editor:

editor-content-preview

Find the full list of available content settings and their properties below:

INPUTBOX

This element adds a single-line text input field to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has INPUTBOX value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
placeholderstringPlaceholder value displayed in the Editor until a user types something in the field.

Optional
defaultsobjectDefault values for the element.

Optional

defaults

If defaults are presented and there is no showcase overriding its values, these values will be used as default. Users will be able to change them after adding a section in the IS Editor.

NameTypeDescription
textstringDefault value for the input field. Overrides placeholder value.

Optional

Code example:

element_id: {
	type: 'INPUTBOX',
	label: '$label.element_id.label',
	placeholder: '$label.element_id.placeholder',
}

TEXTAREA

This element adds a multi-line text input field to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has TEXTAREA value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
placeholderstringPlaceholder value displayed in the Editor until a user types something in the field.

Optional
defaultsobjectDefault values for the element.

Optional

defaults

If defaults are presented and there is no showcase overriding its values, these values will be used as default. Users will be able to change them after adding a section in the IS Editor.

NameTypeDescription
textstringDefault value for the input field. Overrides placeholder value.

Optional

Code example:

element_id: {
	type: 'TEXTAREA',
	label: '$label.element_id.label',
	placeholder: '$label.element_id.placeholder',
}

BUTTON

This element adds a configurable button to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has BUTTON value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
defaultsobjectDefault values for the element.

Optional

defaults

NameTypeDescription
titlestringTitle that will be rendered on the button itself.

Optional
buttonTypestringType of the button defining its functionality. Available values:

- SCROLL_TO_TILE: Scrolls to a specific Instant Site section.
- HYPER_LINK: Go to link.
- MAIL_LINK: Compose email.
- TEL_LINK: Call phone.
- GO_TO_STORE_LINK: Go to store.
- GO_TO_PAGE: Go to site page. Work in progress Optional
tileIdstringFor SCROLL_TO_TILE button type only. Sets a default website page for the "Go to site page" button. Work in progress
linkstringFor HYPER_LINK button type only. Sets a default URL for the "Go to link" button.
emailstringFor MAIL_LINK button type only. Sets a default email for the "Compose email" button.
phonestringFor TEL_LINK button type only. Sets a default phone number for the "Call phone" button.

Code example:

element_id: {
	type: 'BUTTON',
	label: '$label.element_id.label',
	defaults: {
  	title: 'Contact API Support',
    buttonType: 'MAIL_LINK',
    email: '[email protected]',
  },
}

IMAGE

This element adds an image uploader to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has IMAGE value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
defaultsobjectDefault values for the element.

defaults

NameTypeDescription
imageDataobjectData about the default uploaded image

imageData

NameTypeDescription
setmapMap with the { ImageResolution -> ImageInfo } structure, where:

- ImageResolution must be one of the ORIGINAL, LOW_RES, MID_RES, HI_RES, HI_2X_RES, WEBP_LOW_RES, WEBP_MID_RES, WEBP_HI_RES, WEBP_HI_2X_RES, MOBILE_LOW_RES, MOBILE_MID_RES, MOBILE_HI_RES, MOBILE_WEBP_LOW_RES, MOBILE_WEBP_MID_RES, MOBILE_WEBP_HI_RES.
- ImageInfo is an object with the image details.
borderInfoobjectInformation about image border.

imageInfo

NameTypeDescription
urlstringLink to the image. For images added to the /section-name/assets/ folder, you only need to list the name of the image, for example, image.png.

Optional
widthstringOriginal image width.

Optional
heightstringOriginal image height.

Optional

borderInfo

NameTypeDescription
homogenitybooleanIf true, all the border has the same color.
colorobjectBorder color in RGBA format.

color

NameTypeDescription
rnumberR channel value for the border color.
gnumberG channel value for the border color.
bnumberB channel value for the border color.
anumberAlpha channel value for the border color.

Code example:

element_id: {
  type: 'IMAGE',
  label: '$label.element_id.label',
  defaults: {
    imageData: {
      set: {
        LOW_RES: {
          url: 'new_arrivals_mobile_low.jpeg',
        },
        MOBILE_WEBP_LOW_RES: {
          url: 'new_arrivals_mobile_low.jpeg',
        },
        MOBILE_WEBP_HI_RES: {
          url: 'new_arrivals_mobile_high.jpeg',
        },
        WEBP_LOW_RES: {
          url: 'new_arrivals_pc_low.jpeg',
        },
        WEBP_HI_2X_RES: {
          url: 'new_arrivals_pc_high.jpeg',
        },
      },
      borderInfo: {},
    },
  }
}

TOGGLE

This element adds a toggle to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has TOGGLE value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
descriptionstringDescription displayed under the element in the Editor.

Optional
defaultsobjectDefault values for the element.

Optional

defaults

NameTypeDescription
enabledbooleanDefault toggle state. true if enabled.

Optional

Code example:

element_id: {
	type: 'TOGGLE',
	label: '$label.element_id.label',
	description: '$label.element_id.description',
  defaults: {
  	enabled: true,
  },
}

SELECTBOX

This element adds a dropdown list to user settings available for the section.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has SELECTBOX value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
descriptionstringDescription displayed under the element in the Editor.

Optional
optionsobjectList of available choices in the dropdown list.

Optional
defaultsobjectDefault values for the element.

Optional

options

NameTypeDescription
labelstringDescription displayed under the option value.
valuestringOption value.

defaults

NameTypeDescription
valuestringDefault option value. Must match one of the option values defined in the options.

Code example:

element_id: {
	type: 'SELECTBOX',
	label: '$label.element_id.label',
	description: '$label.element_id.description',
  options: {
  	label: '$label.element_id.option_1.label'
    value: 'Option 1'
  }
  defaults: {
  	value: 'Option 1',
  },
}

INFO

This element adds an unmodifiable information block with text and an optional button. Use it to add some marketing/educational information to the Editor. For example: "Need help? Contact developer: [Email button]" block displayed under the section settings.

List of properties:

NameTypeDescription
typestringType of the setting that defines its functionality. In this case, has INFO value.

Required
labelstringTitle displayed above the element in Instant Site Editor.

Optional
descriptionstringDescription displayed under the element in the Editor.

Optional
buttonobjectPre-configured button for the information block.

Optional
defaultsobjectDefault values for the element.

Optional

button

NameTypeDescription
labelstringText displayed on the button.
linkstringButton link.

defaults

NameTypeDescription
titlestringDefault button text. If exists, overrides the button.label text.
linkstringDefault button link. If exists, overrides the button.link value.

Code example:

element_id: {
	type: 'INFO',
	label: '$label.element_id.label',
	description: '$label.element_id.description',
  button: {
  	label: '$label.element_id.button.label'
    link: 'https://example.com'
  },
}