Skip to Content
Config SystemEditor Placements

Editor Placements

Placements embed custom UI into the Foir editor. You can add a full-page editor tab or a sidebar panel that loads your own web application inside an iframe.

Placement Interface

interface ApplyConfigPlacementInput { type: string; // 'main-editor' or 'sidebar'. Required: a placement // carrying neither value is shown in neither place url: string; // URL of your custom UI allowedOrigin?: string; // Origin allowed for postMessage communication height?: number; // Height of the iframe in pixels tabName?: string; // Tab label, or sidebar panel heading hideContentTab?: boolean; // Hide the default content editing tab modelKeys?: string[]; // Restrict placement to specific models }

Placement Types

main-editor

Adds a tab to the main editor area. When users open a record of a matching model, they see your custom tab alongside (or instead of) the default content tab.

placements: [ { type: 'main-editor', url: 'https://my-editor.example.com', modelKeys: ['redirect'], tabName: 'Redirect Editor', hideContentTab: true, }, ]

Adds a panel in the editor sidebar. Sidebar placements appear alongside the built-in sidebar sections.

placements: [ { type: 'sidebar', url: 'https://my-editor.example.com/sidebar', modelKeys: ['blog-post'], tabName: 'SEO Tools', height: 400, }, ]

Options

url

The URL loaded in the iframe. Give an absolute https:// URL: it is stored and loaded exactly as written, and nothing resolves a relative path against a base URL. The console fills in ${context.tenantId}, ${context.projectId}, ${record.id}, ${record.naturalKey}, ${entity.modelKey} and ${version.id} when it loads a main-editor placement.

{ type: 'main-editor', url: 'https://my-editor.example.com' } // With the record filled in by the console { type: 'main-editor', url: 'https://my-editor.example.com/records/${record.id}' }

modelKeys

Restricts the placement to specific models. If omitted, the placement appears for all models.

// Only show for redirect and vanity-url models { type: 'main-editor', url: 'https://my-editor.example.com', modelKeys: ['redirect', 'vanity-url'] }

hideContentTab

When true, the default content editing tab is hidden. Use this when your custom editor completely replaces the built-in editor.

// Replace the default editor entirely { type: 'main-editor', url: 'https://my-editor.example.com', modelKeys: ['design-system'], hideContentTab: true, tabName: 'Design Tokens', }

tabName

The name the placement is shown under: the tab label for a main-editor placement, the panel heading for a sidebar one. Defaults to the config’s name when it is not specified, and to the config’s key when the config has no name.

There is no label key. It is tabName for both kinds.

height

Sets the iframe height in pixels. Mainly useful for sidebar placements where you want to control the panel size.

{ type: 'sidebar', url: 'https://my-editor.example.com/preview', height: 300 }

allowedOrigin

The origin allowed for postMessage communication between the editor and your iframe. Set this to enable two-way communication with the Foir editor SDK.

{ type: 'main-editor', url: 'https://my-editor.example.com', allowedOrigin: 'https://my-editor.example.com', }

Examples

Custom Main Editor

Replace the default editor with a custom redirect management UI:

import { defineConfig } from '@foir/cli/configs'; export default defineConfig({ key: 'cloudflare-kv', name: 'Cloudflare KV Redirector', models: [ { key: 'redirect', name: 'Redirect', fields: [...] }, ], placements: [ { type: 'main-editor', url: 'https://my-editor.example.com', modelKeys: ['redirect'], hideContentTab: true, tabName: 'Redirect Editor', }, ], });

Design Token Editor

A custom editor for design system tokens with an external URL and allowed origin:

placements: [ { type: 'main-editor', url: 'https://design-editor.example.com', allowedOrigin: 'https://design-editor.example.com', tabName: 'Design Tokens', hideContentTab: true, modelKeys: ['design-system'], }, ]

Add a sidebar panel that shows a live preview of content:

placements: [ { type: 'sidebar', url: 'https://my-editor.example.com/preview', modelKeys: ['page', 'blog-post'], tabName: 'Live Preview', height: 500, }, ]

Multiple Placements

You can define multiple placements in the same config:

placements: [ { type: 'main-editor', url: 'https://my-editor.example.com', modelKeys: ['product'], tabName: 'Product Editor', }, { type: 'sidebar', url: 'https://my-editor.example.com/analytics', modelKeys: ['product'], tabName: 'Analytics', height: 350, }, ]

Next Steps

Last updated on