Skip to content

feat: Form element custom rendering in Content Fragment Editor #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ module.exports = {
path: "/services/aem-cf-editor/api/modal/"
},
{
title: "Custom form element rendering",
title: "Form elements custom rendering",
path: "/services/aem-cf-editor/api/custom-fields/"
}
]
Expand Down
37 changes: 27 additions & 10 deletions src/pages/services/aem-cf-editor/api/custom-fields/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
---
title: Custom form element rendering - AEM Content Fragments Editor Extensibility
title: Form elements custom rendering - AEM Content Fragments Editor Extensibility
description: Learn how to customize a form field rendering in AEM Content Fragments Editor
contributors:
- https://github.com/AdobeDocs/uix
---

# Custom form element rendering
# Form elements custom rendering

This feature allows third-party developer to build custom input UI for specific fields or types of fields.

Expand Down Expand Up @@ -67,14 +67,31 @@ function CustomField() {
}
```

## API Reference
## API reference

| Field | Type | Required | Description |
|--------------|-----------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| url | `string` | ✔️ | URL of the page to load in the iframe that will replace the original field. The URL must have the same origin as the extension declaring the rules for field replacement. |
| pathExp | `string` | | RegExp for "fragment content" path |
| modelPathExp | `string` | | RegExp for "fragment content model" path |
| fieldTypeExp | `string` | | RegExp for field type |
| fieldNameExp | `string` | | RegExp for field name |
### Override rules definition API

Allowed values in `getDefinitions` when registering override rules.

| Field | Type | Required | Description |
|----------------|-----------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `url` | `string` | ✔️ | URL of the page to load in the iframe that will replace the original field. The URL must have the same origin as the extension declaring the rules for field replacement. |
| `pathExp` | `string` | | RegExp for "content fragment" path. |
| `modelPathExp` | `string` | | RegExp for "content fragment model" path. |
| `fieldTypeExp` | `string` | | RegExp for field type. |
| `fieldNameExp` | `string` | | RegExp for field name. |

At least one valid expression must be specified: `pathExp`, `modelPathExp`, `fieldTypeExp`, or `fieldNameExp`.

### Host API

Methods that can be called on the `conn.host.field` object during rendering logic implementation.

| Method | Description |
|-----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| `getModel(): Object` | Return Content Fragment Model for the currently edited Content Fragment. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we describe at least major fields of the object?

| `getDefaultValue(): mixed` | Returns the initial value for the input we are replacing. |
| `getValidationState(): invalid|valid` | Returns the validation state value for the input we are replacing. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it string with two possible values or a boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| `onValidationStateChange(Function callback): void` | Accepts a callback that will be called when the validation state changes for the input we are replacing. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a callback signature? Does it accept any arguments?

| `onChange(Function callback): void` | Accepts a callback that will be called when the value of the input we are replacing changes. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a callback signature? Does it accept any arguments?

| `setHeight(number|"auto" height): void): void` | Sets the height value of the frame in which custom UI for the input we are replacing is rendered. A number of pixels, a CSS value, or the string auto. |
2 changes: 1 addition & 1 deletion src/pages/services/aem-cf-editor/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ Learn how to use basic methods for navigating within an extension

Learn about modal host API methods that can be used in any extension

[Custom form element rendering](custom-fields)
[Form elements custom rendering](custom-fields)

Learn how to customize a form field rendering