Custom elements
Is this page helpful?
<iframe>
in Kontent.ai and interact with Kontent.ai through the Custom Elements API. They enable you to extend the default content type elements to include the functionality you need.
Have a look at a few examples of extending Kontent.ai capabilities using custom elements:
<iframe>
. They need to be hosted so the browser can fetch the file.
You need to host your custom element yourself or use a service like Netlify.
X-frame-options
(or Content-Security-Policy
) header to specify an allowed origin, in this case, https://app.kontent.ai
. For more details, see the MDN Web Docs.sandbox
attribute on the <iframe>
. The following sandbox flags are enabled:
allow-forms
– allows form submissionallow-scripts
– allows JavaScript to run inside the <iframe>
allow-popups
– allows popupsallow-same-origin
– allows the document to maintain its originallow-modals
– allows modal dialogsallow-storage-access-by-user-activation
– allows storage access (e.g. cookies or local storage)
SameSite=None; Secure
to use cookies.null
is considered valid and won't prevent an item from getting published.
{"default_value": "Enter your text here"}
to the JSON parameters. When you initialize your element, check whether there's already some value in the element. If there isn't, use the value from the JSON parameters.
value
.
"markdown_editor": {
"type": "custom",
"name": "Markdown editor",
"value": "## Hello world\nThis is a sentence with **bold** and *italics* in it.\n> And blockquotes!"
}