Free cookie consent management tool by TermsFeed Generator
All Products & Integrations

jalpi page builder docs

Editor Overview

A tour of the Jalpi Page Builder editor: how it mounts, its four layout regions, the inspector tabs, editor state, autosave and the keyboard shortcuts that drive it.

Jalpi CoreDeveloper
16 min read Β· November 2026

The Jalpi editor is a single-page React application that takes over a WordPress admin screen. PHP prints one empty <div>, enqueues the compiled bundle, and hands the app a configuration object; everything after that β€” layout, selection, styling, history, saving β€” happens client-side against a JSON node tree.

This page is the map. It walks through how the app boots, what each region of the screen does, how editor state is organised, and how work reaches the server. Deeper treatments of the canvas, the control primitives and the node format live on their own pages; here the goal is to know where everything is and which file to open next.

How the Editor Mounts#

There is no router and no server-rendered markup. The entire editor is one React root.

Jalpi_Editor::render_editor_page() prints:

<div id="jalpi-editor-root" data-post-id="42"></div>

admin/editor/src/index.tsx then finds that element and mounts <App /> into it with createRoot, importing styles/editor.css as the single stylesheet entry point.

Everything the app needs to reach the server arrives through window.jalpiEditorConfig, localized onto the script by Jalpi_Editor::enqueue_editor(). App reads postId and designSystem from it, useApi reads apiUrl, postId and nonce, and TopBar reads adminUrl and previewUrl.

The design system arrives inline rather than through a request: App seeds useEditorStore(jalpiEditorConfig.postId, jalpiEditorConfig.designSystem), so tokens are available on the first paint. Page data is not β€” it is fetched on mount and loaded into the store when it arrives.

The Four Regions#

App renders a fixed shell: a top bar across the full width, then a body split into three columns.

The Jalpi editor with the top toolbar, the Elements drawer, the canvas and the properties inspector
Figure: Jalpi Editor workspace layout with top toolbar, live canvas viewport, and dual inspector panels.
RegionComponentDefault widthResizable range
Top barTopBarfull widthβ€”
Left: Elements panelElementsPanel200 px160–480 px
Center: CanvasCanvasfills remaining spaceβ€”
Right: InspectorLayersPanel / PropertiesPanel / PagePanel / GlobalStylesPanel / ClassesPanel300 px220–560 px

Both side panels are resized by a PanelResizer β€” a thin drag handle that mutates the panel element's inline width during the drag and commits the final value to React state on mouse-up. Widths live in component state only, so they reset when the editor is reloaded.

The left panel can be toggled off entirely from the top bar; the inspector is always present.

The Top Bar#

components/toolbar/TopBar.tsx holds the global controls, arranged in three groups.

Left β€” Context#

  • Elements panel toggle, reflecting the current visibility state.
  • Logo, linking back to jalpiEditorConfig.adminUrl.
  • Page title, taken from the REST response, with a ● dirty indicator shown whenever state.isDirty is true.

Center β€” Device Switcher#

Three buttons β€” Desktop, Tablet, Mobile β€” call store.setBreakpoint(). The active breakpoint drives both the canvas frame width and which style map the inspector writes to.

Right β€” Actions#

  • Undo / Redo, wired to store.undo and store.redo and disabled at the ends of the history array (historyIndex <= 0 and historyIndex >= history.length - 1).
  • Zoom, stepping store.setZoom(state.zoom Β± 10) with the current percentage displayed between the buttons.
  • Preview, which saves silently and then opens jalpiEditorConfig.previewUrl in a new tab.
  • Save, disabled while saving or when nothing is dirty, showing "Saving…" in flight.
  • Publish, disabled while publishing, showing "Publishing…" in flight.

Undo, redo and save tooltips are labelled from SHORTCUT_LABELS, which renders ⌘/⇧ on macOS and Ctrl+/Shift+ elsewhere.

The Elements Panel#

components/panels/ElementsPanel.tsx is the widget palette. It presents three views β€” ALL, FAVORITES and RECENT β€” over a set of category accordions.

Seven categories are declared explicitly: LAYOUT, BASIC, NAVIGATION, MEDIA, MARKETING, CONTENT and WIDGETS. LAYOUT contains Section, Container and Column; the rest are built from BLOCKS (exported by BlockPicker.tsx) via hardcoded type lists.

Everything else comes from the widget registry automatically. Any WIDGET_REGISTRY entry whose type is not already placed by one of those lists is grouped by its own category:

  • if that category matches a hardcoded group name, the widget joins the existing group (Icon Box, category Basic, joins BASIC);
  • otherwise the category becomes a new accordion of its own.

This is what makes a newly registered widget appear in the palette without editing this file. Empty groups are filtered out.

Favorites and recents are per-browser, stored in localStorage under jalpiElementFavorites and jalpiElementRecent, capped at 24 entries each and wrapped in try/catch so a blocked storage API cannot break the panel.

Selecting an item calls App's handleAddElement, which decides where the node lands based on the current selection β€” see Insertion Rules below.

The Canvas#

components/canvas/Canvas.tsx renders the page itself. Each top-level section is handed to a CanvasNode, which recursively renders the tree.

The frame is sized by breakpoint and scaled by zoom:

const BREAKPOINT_WIDTHS = {
  desktop: '100%',
  tablet:  '768px',
  mobile:  '390px',
};

const frameWidth = BREAKPOINT_WIDTHS[state.breakpoint];
const scale      = state.zoom / 100;   // applied as transform: scale(...)

Surrounding the tree:

  • Empty state β€” when the page has no sections, EmptyCanvas offers a starting point and a route into the template picker.
  • Quick Insert bar β€” one-click insertion of Section, Container, Heading, Text, Image, Button and Icon, each with a seeded default node.
  • Sticky footer β€” an always-visible "+ Add Section" bar with its own context menu, including copy-page and paste-page actions that move the whole pageData through the clipboard as JSON tagged with a __jalpi_page__ marker. Clipboard writes fall back to document.execCommand('copy') on non-secure origins, so it still works over plain HTTP.
  • Context menu β€” right-clicking anything with a data-node-id selects that node and opens ContextMenu at the pointer.
  • Selection scroll β€” whenever selectedId changes, the matching DOM node is scrolled into view.

Nodes are draggable unless locked, and text elements are edited inline directly on the canvas.

The Inspector#

The right column is a five-tab inspector. The active tab is local component state (InspectorTab), not store state.

TabComponentPurpose
OutlineLayersPanelTree navigation over the node hierarchy, with per-node labels derived from content
StylePropertiesPanelAll per-node editing β€” the tab you spend most time in
PagePagePanelRead-only page title and post type
GlobalGlobalStylesPanelSite-wide Design System tokens and presets
ClassesClassesPanelReusable CSS classes

Selecting a node automatically switches the inspector to Style. This is driven by state.selectionSeq, a counter that increments on every selection β€” so re-selecting the node you are already on still brings the Style tab back.

Below the tab body, a Quick Actions strip appears whenever a node is selected, offering Duplicate, Copy and Delete with their shortcut labels.

Inside the Style Tab#

PropertiesPanel has its own four sub-tabs, backed by state.panelTab in the store so the choice survives switching between nodes:

panelTabRendersNotes
propertiesContentTabWidget content fields
styleStyleTabTypography, background, border, colors
animationAnimationTabEntrance animations and interactions
responsiveAdvancedTabSpacing, sizing, advanced options

The responsive tab is relabelled Settings when the selected node is a section, container or column.

Each tab opens on a sensible accordion group for the selected element type, resolved from CONTENT_FIRST_GROUP and STYLE_FIRST_GROUP lookups.

When the breakpoint is not desktop, a DeviceBanner appears above the tab body reading "Editing Tablet β€” overrides only", with a one-click return to desktop. This is the visual reminder that edits are writing to tabletStyles or mobileStyles, not the base styles map.

Overlays, Modals and Palettes#

Several surfaces sit above the main layout and are opened either by UI controls or by custom events:

SurfaceComponentOpened by
Command paletteCommandPaletteCtrl/⌘ + K
Global finderGlobalFinderCtrl/⌘ + P
Revision panelRevisionPanelTop bar / Elements panel history button
Save template modalSaveTemplateModalcb:openSaveTemplate event
Timeline editorTimelinePanelcb:openTimeline event
Template pickerTemplatePickerEmpty canvas or the sticky footer
Context menuContextMenuRight-click on a canvas node
Toastinline in Appcb:toast event, auto-dismissed after 2.5 s

Command palette builds its action list from BLOCKS β€” one "Add …" entry per widget β€” plus core actions such as Undo, Redo, Duplicate and Copy, each showing its platform-correct shortcut.

Global finder searches four categories at once β€” Pages, Elements, Commands and Settings. Element results are produced by walking the live node tree and extracting a text preview from each node's text or html content; page results come from the WordPress core REST API (/wp/v2/pages), which useApi.searchPages() reaches by stripping the Jalpi namespace off the configured apiUrl.

The Timeline editor deliberately stores only a node id rather than a node snapshot, re-resolving it from the store on every render so edits made inside the panel are never applied to a stale copy.

Editor State#

All editor state lives in one hook, useEditorStore (src/store/editorStore.ts), created once in App and passed down by prop. There is no context provider and no external state library; the exported EditorStore type is simply ReturnType<typeof useEditorStore>.

The EditorState shape:

FieldTypePurpose
postIdnumberPost being edited
pageDataPageDataThe node tree β€” the document itself
selectedId / hoveredIdstring | nullCanvas selection and hover
breakpointBreakpointdesktop / tablet / mobile
isDirty, isSaving, isPublishingbooleanSave lifecycle
history, historyIndexHistoryEntry[], numberUndo stack
panelTab'properties' | 'style' | 'animation' | 'responsive'Inspector sub-tab
showLayersbooleanLayers visibility
zoomnumberCanvas zoom percentage
clipboard, styleClipboardCBNode | null, StyleMap | nullNode and style copy buffers
selectionSeqnumberIncrements on every selection
designSystem, designSystemDirty, designSystemSavingβ€”Site-wide tokens, separate save lifecycle
classes, classesLoaded, editingClassKeyβ€”Reusable class system

editingClassKey is worth singling out: when it is null the Style and Advanced tabs edit the selected node, and when it holds a class key those same tabs edit that class instead.

The store exposes more than eighty actions covering node mutation, layout, clipboard, templates, global styles, design tokens, interactions and classes. Every mutating action follows the same pattern β€” produce a new tree, set isDirty, and append a labelled history entry.

Undo History#

History is an array of HistoryEntry objects, each a deep clone of pageData plus a timestamp and an optional label such as 'Detach Class'. Adding an entry truncates anything after the current index β€” so a new edit discards the redo branch β€” and the result is capped:

const MAX_HISTORY = 30;

const trimmed = prev.history.slice(0, prev.historyIndex + 1);
const next    = [...trimmed, entry].slice(-MAX_HISTORY);

Cloning is JSON.parse(JSON.stringify(...)), which is why the node tree stays strictly JSON-serialisable.

Undo and redo restore a clone of the target entry, mark the page dirty, and clear the current selection.

Those labels are not only cosmetic: the revision autosave reads history[historyIndex].label and sends it as the revision description, so the server-side revision timeline shows what the change actually was.

Insertion Rules#

App.handleAddElement resolves where a new node goes from the current selection:

SelectionResult
Adding a sectionInserted after the section containing the selection, or appended if nothing is selected
A section is selectedaddElementInContainer() β€” placed inside that section
A container or column is selectedaddElement() β€” appended to it
A leaf element is selectedaddElementInNewSection() β€” a new section is created after the containing one
Nothing is selectedaddElementInNewSection() at the end

The command palette applies the same logic independently for its "Add …" actions.

Saving, Autosave and Publishing#

Four independent lifecycles run in the editor.

Page Save#

handleSave(silent) guards on isSaving, POSTs pageData to /page/{postId}, calls store.markSaved() and shows a "Saved" toast unless it was silent. Failures surface the error message as a toast rather than throwing.

Autosave fires 3 seconds after the last change: an effect watching pageData and isDirty sets a timeout that calls the save handler in silent mode, clearing any pending timer first so rapid edits debounce into one request.

The handler is kept in a ref (handleSaveRef) so effects and the cb:save listener can be registered once and still call the latest closure.

Revision Autosave#

A separate 60-second interval posts the current pageData to the revisions endpoint, labelled with the most recent history entry's label (falling back to 'Auto-save'). Errors are swallowed β€” a failed revision must never interrupt editing.

Design System Save#

The site-wide Design System saves on its own track, with its own dirty and saving flags, its own 3-second autosave and a distinct "Design System saved" toast. The reason is a real distinction: linking a widget to a token edits the page, while editing the token's value edits the site. Keeping the toasts different means the two are never ambiguous.

Publish and Preview#

Publish saves silently first, then POSTs to /page/{postId}/publish, and toasts "Published!". Preview also saves silently first, then opens jalpiEditorConfig.previewUrl in a new tab β€” so a preview never shows stale content.

A beforeunload listener warns before leaving while isDirty is true.

Keyboard Shortcuts#

useShortcuts (re-exported as useKeyboard for backwards compatibility) is mounted once in App. It registers a single keydown listener on window and reads the store through a ref, so it never re-registers.

ShortcutAction
Ctrl/⌘ + KToggle the command palette
Ctrl/⌘ + PToggle the global finder
Ctrl/⌘ + ZUndo
Ctrl/⌘ + Y or Ctrl/⌘ + Shift + ZRedo
Ctrl/⌘ + SSave
Ctrl/⌘ + CCopy selected node
Ctrl/⌘ + VPaste into selected node
Ctrl/⌘ + DDuplicate selected node
Delete / BackspaceDelete selected node
EscapeDeselect (the canvas closes its own overlays separately)

The modifier is metaKey on macOS and ctrlKey elsewhere, detected from navigator.platform.

SHORTCUT_LABELS is the display-side counterpart β€” import it anywhere a shortcut string needs rendering rather than hardcoding Ctrl+.

Cross-Component Events#

Components that are not in a parent-child relationship communicate through CustomEvents on window rather than lifted state. All of them use the cb: prefix:

EventDispatched byHandled by
cb:openCmduseShortcuts (Ctrl+K)Canvas β€” toggles the command palette
cb:openFinderuseShortcuts (Ctrl+P)App β€” toggles the global finder
cb:saveuseShortcuts (Ctrl+S)App β€” runs a non-silent save
cb:openElementsCanvas "+" buttons in empty containersApp β€” reveals the Elements panel
cb:openSaveTemplateContext menu and other UIApp β€” opens SaveTemplateModal (no nodeId means the whole page)
cb:openTimelineContext menuApp β€” opens TimelinePanel
cb:toastAnywhere, e.g. canvas copy/pasteApp β€” shows a toast

This keeps deeply nested canvas components from having to thread callbacks up through the tree.

Talking to the Server#

Every request goes through useApi (src/hooks/useApi.ts), a hook returning memoised callbacks over a small apiFetch wrapper. The wrapper sets Content-Type: application/json and the X-WP-Nonce header from jalpiEditorConfig.nonce, and converts a non-OK response into a thrown Error carrying the server's message.

The surface it exposes, grouped:

  • Page β€” loadPage, savePage, publishPage
  • Design System β€” loadDesignSystem, saveDesignSystem
  • Media β€” getMedia, uploadMedia (multipart, so it bypasses the JSON wrapper and sends only the nonce header)
  • Templates β€” getTemplates, getTemplate, getTemplateCategories, createTemplate, deleteTemplate, duplicateTemplate, exportTemplate, importTemplate, seedBundledTemplates, getTemplateUserLists, toggleTemplateFavorite, pushTemplateRecent
  • Revisions β€” listRevisions, getRevision, createRevision, restoreRevision, deleteRevision
  • Classes β€” getClasses, createClass, updateClass, duplicateClass, deleteClass, toggleFavoriteClass, getClassUsage, reorderClasses, exportClasses, importClasses
  • WordPress core β€” searchPages, the one call that leaves the Jalpi namespace

getTemplate routes on the shape of the id: virtual kit templates (kit:, kitsec:, kitchrome:) contain a colon, so they are base64url-encoded and sent to a separate read-only /kit-template/{id} route.

Two requests fire on mount β€” loadPage(), whose result sets the page title and loads the tree into the store, and getClasses(), loaded eagerly so the Style tab's class picker has data regardless of which inspector tab opens first.

Keeping the Canvas Honest#

An effect in App writes the Design System into a <style id="jalpi-global-vars"> element in the document head, regenerated whenever designSystem changes. It emits every token as a CSS custom property, plus one variable per typography and button preset property.

The variable names come from utils/designTokens.ts (cssVarName, typoVarName, btnVarName) β€” the same --jalpi-* naming that Jalpi_Settings::output_design_system_css() emits on the real frontend. That shared naming is what keeps the editor canvas pixel-matched with production rather than approximating it.

Examples#

The entire editor entry point#

src/index.tsx β€” one root, one stylesheet import, no router.

import React from 'react';
import { createRoot } from 'react-dom/client';
import { App } from './App';
import './styles/editor.css';

const root = document.getElementById('jalpi-editor-root');
if (root) {
  createRoot(root).render(<App />);
}

Creating the store and wiring shortcuts#

From App.tsx. The store is created once and passed down by prop; the shortcut hook is mounted at the root.

export function App() {
  const store = useEditorStore(jalpiEditorConfig.postId, jalpiEditorConfig.designSystem);
  const api   = useApi();

  useKeyboard(store);

  // Initial load
  useEffect(() => {
    api.loadPage()
      .then((res) => {
        setPostTitle(res.post_title);
        storeRef.current.loadPageData(res.page_data);
      })
      .catch((err) => setError(err.message));
  }, []);

  // …
}

The 3-second autosave#

Debounced through a cleared timeout, and invoked through a ref so the effect never re-registers with a stale closure.

useEffect(() => {
  if (!store.state.isDirty) return;
  if (autoSaveRef.current) clearTimeout(autoSaveRef.current);
  autoSaveRef.current = setTimeout(() => handleSaveRef.current(true), 3000);
  return () => { if (autoSaveRef.current) clearTimeout(autoSaveRef.current); };
}, [store.state.pageData, store.state.isDirty]);

How a history entry is recorded#

Every mutating store action calls this. Note the truncation of the redo branch and the 30-entry cap.

const MAX_HISTORY = 30;

function mkHistory(
  prev: EditorState,
  newData: PageData,
  label?: string
): Pick<EditorState, 'history' | 'historyIndex'> {
  const entry: HistoryEntry = { pageData: cloneDeep(newData), timestamp: Date.now(), label };
  const trimmed = prev.history.slice(0, prev.historyIndex + 1);
  const next    = [...trimmed, entry].slice(-MAX_HISTORY);
  return { history: next, historyIndex: next.length - 1 };
}

Opening a panel from a nested component#

Canvas components dispatch a window event instead of threading a callback up through the tree; App listens once.

// dispatch, from anywhere in the canvas
window.dispatchEvent(new CustomEvent('cb:openTimeline', { detail: { nodeId } }));

// listen, in App
useEffect(() => {
  const handler = (e: Event) => {
    const nodeId = (e as CustomEvent<{ nodeId?: string }>).detail?.nodeId;
    if (nodeId) setTimelineNodeId(nodeId);
  };
  window.addEventListener('cb:openTimeline', handler as EventListener);
  return () => window.removeEventListener('cb:openTimeline', handler as EventListener);
}, []);

Rendering a shortcut label#

SHORTCUT_LABELS resolves the platform modifier once at module load. Import it rather than hardcoding "Ctrl+".

import { SHORTCUT_LABELS } from '../../hooks/useShortcuts';

<button
  onClick={store.undo}
  disabled={state.historyIndex <= 0}
  title={`Undo (${SHORTCUT_LABELS.undo})`}
>
  <UndoIcon />
</button>

Notes#

  • Ctrl/⌘ + K and Ctrl/⌘ + P are handled before the typing guard, so they work even while focus is in an input. Every other shortcut is suppressed when focus is inside an INPUT, TEXTAREA, SELECT or any contentEditable element.
  • Undo and redo clear the current selection. This is intentional β€” the restored tree may not contain the node that was selected.
  • The undo history is client-side and capped at 30 entries; it is discarded when the editor is reloaded. Longer-term recovery is the job of the server-side revision system, which autosaves every 60 seconds.
  • The inspector's outer tab (Outline / Style / Page / Global / Classes) is component state, while the Style tab's inner tab (panelTab) lives in the store β€” so the inner choice persists as you move between nodes, and the outer one snaps back to Style on each new selection.
  • Panel widths are session-only React state. Element favorites and recents, by contrast, persist per browser in localStorage.
  • Canvas zoom is clamped to 50–150 % in setZoom, so repeatedly clicking the zoom buttons stops at those bounds.
  • The editor stylesheet is imported from index.tsx and extracted by the build into build/index.css, with an RTL variant generated alongside it.

Warnings#

  • The Page tab is informational only. It renders the post title from the REST response and the literal string "Page" as the post type β€” it does not read the real post type, so a post being edited still shows "Page". Actual page settings are edited in the WordPress editor, as the panel's own hint says.
  • History clones are made with JSON.parse(JSON.stringify(...)). Anything you add to a node that is not JSON-serialisable β€” a function, a Date, a Map, undefined inside an array β€” will not survive undo/redo.
  • Adding a new history entry truncates everything after the current index. An edit made after undoing discards the redo branch permanently.
  • Page saves and Design System saves are separate lifecycles with separate dirty flags. A page save does not persist token edits, and vice versa β€” check which toast you received before assuming work is stored.
  • The store is passed by prop from App; there is no context provider. A component rendered outside that prop chain has no access to editor state, which is exactly why the cb: window events exist.
  • Save, publish and Design System save all guard on their in-flight flag and return early if one is already running. A save triggered while another is in flight is dropped rather than queued β€” the 3-second autosave will pick the change up afterwards.

Source Files#

  • admin/editor/src/index.tsx
  • admin/editor/src/App.tsx
  • admin/editor/src/store/editorStore.ts
  • admin/editor/src/types/index.ts
  • admin/editor/src/hooks/useApi.ts
  • admin/editor/src/hooks/useKeyboard.ts
  • admin/editor/src/hooks/useShortcuts.ts
  • admin/editor/src/components/toolbar/TopBar.tsx
  • admin/editor/src/components/canvas/Canvas.tsx
  • admin/editor/src/components/canvas/CanvasNode.tsx
  • admin/editor/src/components/canvas/CommandPalette.tsx
  • admin/editor/src/components/canvas/ContextMenu.tsx
  • admin/editor/src/components/canvas/TemplatePicker.tsx
  • admin/editor/src/components/panels/ElementsPanel.tsx
  • admin/editor/src/components/panels/PropertiesPanel.tsx
  • admin/editor/src/components/panels/TimelinePanel.tsx
  • admin/editor/src/components/layers/LayersPanel.tsx
  • admin/editor/src/components/globalStyles/GlobalStylesPanel.tsx
  • admin/editor/src/components/classes/ClassesPanel.tsx
  • admin/editor/src/components/GlobalFinder.tsx
  • admin/editor/src/components/RevisionPanel.tsx
  • admin/editor/src/components/SaveTemplateModal.tsx
  • admin/editor/src/utils/designTokens.ts
  • admin/editor/src/widgets/registry.ts
  • includes/class-jalpi-editor.php

Last updated: November 2026