You can add an Ace Editor custom field extension, an embeddable code editor that includes features of native code editors, such as Sublime and Vim, to your stack. The content managers can then select one or more resources from the list while creating an entry.
This step-by-step guide explains how to create an Ace Editor custom field extension for your content types:
- Add the ‘Ace Editor’ custom field extension to your stack
- Use your custom field
Step 1 - Add the ‘Ace Editor’ custom field extension to your stack
- Go to Settings > Extensions. Click on the ‘+ Add Extension’ button on the top-right corner and select ‘Use prebuilt’.
- This opens the 'Prebuilt Extensions' window.
- Click on the filter at the top and select 'Custom Field'. Select ‘Ace Editor’ from the given set of Prebuilt custom fields.
- Click ‘Add’. You will be led to the ‘Create New Extension’ details page where the following details are displayed:
- Title - You will see a predefined title, ‘Ace Editor’. The same title can be used when adding the custom field in your content type.
- Field data type - Select the field data type for your input data as ‘Text’.
- Hosting method - The hosting method will be set to ‘Hosted By Contentstack’. This option allows the source code for the custom field to be displayed in the ‘Extension source code’ field.
- Extension source code - You will find that the source code for your custom field is already available in this field. You can make the required changes to it to suit your needs.
- Config Parameter - Provide values for the config parameters if you have used any in your source code.
Note: You can provide different configuration settings for specific instances of your Custom Field Extension when setting up your content type. The configuration that you provide for an instance will only be applicable for that instance and will not affect any other instances of the same custom field extension or any other fields within the same content type. Learn more.
- Click on ‘Save’. This creates your custom field.
Now, let’s understand how you can start using this custom field in your content type.
Step 2 - Use your custom field
To use your custom field, you need to follow the steps given below:
- Create a content type by clicking on the ‘+ New Content Type’. Enter the relevant details for the content type and click on ‘Create and Add fields’.
This leads you to the ‘Content Type Builder’ page where you can add the relevant fields.
- Add the ‘Custom’ field in your content type.
- Select 'Ace Editor' from the dropdown and set the other properties of your custom field.
Note: You can provide specific instance-level configuration settings for your Custom Field extension. Learn more.
- After adding other relevant fields in your Content Type, click on Save and Close.
This will create your Content Type. Now you can use the custom field while creating an entry for this Content Type as shown below: