Skip to Content
SumX EditorToolbar, variables & media

Toolbar, variables & media

Configuration surface for SumXEditor: toolbar presets, merge fields, images, and SunEditor init overrides.

Toolbar presets

Set toolbarPreset on SumXEditor. The kit maps presets to SunEditor button lists via getSunEditorButtonList.

PresetTypical useHighlights
minimalShort notesUndo/redo, basic inline, link
standardGeneral ERP rich textFonts, colors, lists, table, link, code view
fullLong-form contentFull SunEditor set + preview, fullscreen
emailTransactional email bodiesEmail-oriented blocks, no table

Media buttons are controlled separately:

PropDefaultEffect
showImageButtonfalse unless upload hooks / flagAdds image to toolbar
showVideoButtonfalseAdds video to toolbar
<SumXEditor toolbarPreset="email" showImageButton onImageUploadBefore={cropHandler} onChange={setHtml} value={html} />

Custom button list

Export and extend in advanced cases:

import { getSunEditorButtonList } from '@sumx/sumx-editor'; const buttons = getSunEditorButtonList('standard', { includeImage: true, includeVideo: false, });

Pass merged options through editorOptions.buttonList only if you intentionally override the preset wiring in core (prefer toolbarPreset + media flags first).

Layout & chrome props

PropTypeDescription
heightnumber | stringEditor body height (px or CSS length)
maxHeightnumber | stringMax body height
placeholderstringEmpty-state hint
showToolbarbooleanHide SunEditor toolbar when false
classNamestringRoot wrapper
editorClassNamestringPassed into SunEditor init
toolbarClassNamestringVariable slot / chrome
invalidbooleanRed border on wrapper (border-destructive)
disabledbooleanDisables SunEditor UI
readOnlybooleanRead-only body; toolbar may still show for copy
toolbarAddonReactNodeSlot beside variable picker

Merge fields (variables)

Types:

type SumXEditorVariableOption = { label: string; value: string; // inserted HTML token, e.g. {{employee.name}} description?: string; id?: string; }; type SumXEditorVariableGroup = { groupKey: string; groupLabel: string; options: SumXEditorVariableOption[]; };

Usage:

<SumXEditor variableGroups={[ { groupKey: 'employee', groupLabel: 'Employee', options: [ { label: 'Full name', value: '{{employee.fullName}}' }, { label: 'Email', value: '{{employee.email}}' }, ], }, ]} onChange={setHtml} value={html} />
PropDescription
variableGroupsGroups shown in Variables dropdown
variablesEnabledForce show/hide picker; default true when groups exist

Inserted tokens render as .sumx-editor-variable chips (styled in styles.scss). Sanitizer allows data-sumx-variable attribute.

Imperative insert (ref):

editorRef.current?.insertVariable('{{vendor.name}}');

Standalone picker (custom toolbar):

import { SumXEditorVariablePicker } from '@sumx/sumx-editor'; <SumXEditorVariablePicker groups={groups} onInsert={(opt) => editorRef.current?.insertVariable(opt.value)} toolbarChrome />

Image upload & crop

Handlers

CallbackWhen
onImageUploadBeforeBefore insert — return modified ImageInfo, false to cancel, or async
onImageUploadAfter create/update/delete
onImageUploadErrorSunEditor error string

Legacy signatures are adapted to SunEditor 3 events internally.

Crop hook

import SumXEditor, { useSumxEditorImageCropUploadBefore } from '@sumx/sumx-editor'; function EditorWithCrop() { const onImageUploadBefore = useSumxEditorImageCropUploadBefore(); return ( <SumXEditor showImageButton onImageUploadBefore={onImageUploadBefore} onChange={setHtml} value={html} /> ); }

The hook opens an @sumx/ui Dialog with react-easy-crop, then returns a blob/file SunEditor can insert.

editorOptions (SunEditor init)

Pass partial SunEditor.InitOptions merged after preset defaults:

<SumXEditor editorOptions={{ charCounter: true, charCounterMax: 5000, resizingBar: true, }} onChange={setHtml} value={html} />

Hot reload options on an existing instance:

editorRef.current?.resetEditorOptions({ height: '400px' });

Save shortcut

<SumXEditor onSave={async () => { await saveDraft(); }} ... />

Maps to SunEditor onSave (Ctrl/Cmd+S and save toolbar action when present).

Legacy nested props

Older screens may pass props={{ placeholder, variableGroups, … }}. Root-level props win on conflict. Prefer flat props for new code.