SunEditor Type Definitions Guide

July 22, 2026 ยท View on GitHub

This document provides a comprehensive overview of all TypeScript types available in SunEditor.


Table of Contents


Public API Types

SunEditor (Root)

Core types for editor initialization and usage.

TypeDescription
SunEditor.InstanceMain editor instance
SunEditor.KernelCore kernel (DI container); used for constructor params
SunEditor.DepsShared dependency bag (this.$) for cross-module access
SunEditor.StoreCentral runtime state store (kernel.store)
SunEditor.StorePathMapStore state shape (state path โ†’ value map)
SunEditor.InitOptionsFull initialization options (EditorInitOptions)
SunEditor.InitFrameOptionsFrame-specific initialization options
SunEditor.ContextEditor context (Map-based)
SunEditor.OptionsBase options map (runtime)
SunEditor.FrameContextFrame context utility
SunEditor.FrameOptionsFrame options map (runtime)
SunEditor.ComponentInfoComponent metadata (target, container, caption, etc.)
SunEditor.ComponentLauncherLightweight plugin stand-in for non-plugin components (e.g. pageBreak)
SunEditor.ComponentInsertType"auto" | "select" | "line" | "none"
SunEditor.NodeCollectionArray<Node> | HTMLCollection | NodeList

SunEditor.Module

Cross-module public API types.

Controller

TypeDescription
SunEditor.Module.Controller.InfoController information object

Figure

TypeDescription
SunEditor.Module.Figure.InfoFigure information object
SunEditor.Module.Figure.TargetInfoFigure target information
SunEditor.Module.Figure.ControlButtonFigure control button config
SunEditor.Module.Figure.ControlResizeFigure resize control config
SunEditor.Module.Figure.ControlCustomActionCustom action handler
SunEditor.Module.Figure.ControlsFull controls configuration

Browser

TypeDescription
SunEditor.Module.Browser.FileBrowser file object

HueSlider

TypeDescription
SunEditor.Module.HueSlider.ColorColor object from hue slider

SunEditor.Hook

Hook method signatures for plugins and modules.

Event Hooks (Sync)

TypeDescription
SunEditor.Hook.Event.ActiveActive state change
SunEditor.Hook.Event.OnFocusFocus event
SunEditor.Hook.Event.OnBlurBlur event
SunEditor.Hook.Event.OnMouseMoveMouse move event
SunEditor.Hook.Event.OnScrollScroll event

Event Hooks (Sync/Async)

TypeAsync VersionDescription
SunEditor.Hook.Event.OnBeforeInputOnBeforeInputAsyncBefore input event
SunEditor.Hook.Event.OnInputOnInputAsyncInput event
SunEditor.Hook.Event.OnKeyDownOnKeyDownAsyncKey down event
SunEditor.Hook.Event.OnKeyUpOnKeyUpAsyncKey up event
SunEditor.Hook.Event.OnMouseDownOnMouseDownAsyncMouse down event
SunEditor.Hook.Event.OnMouseUpOnMouseUpAsyncMouse up event
SunEditor.Hook.Event.OnClickOnClickAsyncClick event
SunEditor.Hook.Event.OnMouseLeaveOnMouseLeaveAsyncMouse leave event
SunEditor.Hook.Event.OnFilePasteAndDropOnFilePasteAndDropAsyncFile paste/drop event
SunEditor.Hook.Event.OnPasteOnPasteAsyncPaste event

Core Hooks

TypeDescription
SunEditor.Hook.Core.RetainFormatFormat retention hook
SunEditor.Hook.Core.ShortcutKeyboard shortcut handler
SunEditor.Hook.Core.SetDirDirection change handler
SunEditor.Hook.Core.InitInitialization hook

Component Hooks

TypeDescription
SunEditor.Hook.Component.SelectComponent selection
SunEditor.Hook.Component.DeselectComponent deselection
SunEditor.Hook.Component.EditComponent edit trigger
SunEditor.Hook.Component.DestroyComponent destruction
SunEditor.Hook.Component.CopyComponent copy handler
TypeDescription
SunEditor.Hook.Modal.ActionModal action handler
SunEditor.Hook.Modal.OnModal open handler
SunEditor.Hook.Modal.InitModal initialization
SunEditor.Hook.Modal.OffModal close handler
SunEditor.Hook.Modal.ResizeModal resize handler

Controller Hooks

TypeDescription
SunEditor.Hook.Controller.ActionController action handler
SunEditor.Hook.Controller.OnController open handler
SunEditor.Hook.Controller.CloseController close handler

Browser Hooks

TypeDescription
SunEditor.Hook.Browser.InitBrowser initialization

ColorPicker Hooks

TypeDescription
SunEditor.Hook.ColorPicker.ActionColor selection action
SunEditor.Hook.ColorPicker.HueSliderOpenHue slider open
SunEditor.Hook.ColorPicker.HueSliderCloseHue slider close

HueSlider Hooks

TypeDescription
SunEditor.Hook.HueSlider.ActionHue slider action
SunEditor.Hook.HueSlider.CancelActionHue slider cancel

SunEditor.HookParams

Parameter types for hook methods.

TypeDescription
SunEditor.HookParams.MouseEventMouse event info (frameContext, event, target)
SunEditor.HookParams.KeyEventKeyboard event info
SunEditor.HookParams.ShortcutShortcut info (command, key, event)
SunEditor.HookParams.FilePasteDropFile paste/drop info
SunEditor.HookParams.FocusBlurFocus/blur event info
SunEditor.HookParams.ScrollScroll event info
SunEditor.HookParams.InputWithDataInput event with data
SunEditor.HookParams.PastePaste event info
SunEditor.HookParams.MouseSimple mouse event
SunEditor.HookParams.KeyboardSimple keyboard event
SunEditor.HookParams.ToolbarInputKeyDownToolbar input keydown event
SunEditor.HookParams.ToolbarInputChangeToolbar input change event
SunEditor.HookParams.CopyComponentComponent copy info

Internal/Advanced Types

SunEditor.Event

Event system types for EventManager.

TypeDescription
SunEditor.Event.InfoEvent registration info (target, type, listener)
SunEditor.Event.GlobalInfoGlobal event info
SunEditor.Event.HandlersAll event callback functions

SunEditor.EventParams

Event callback parameter types.

TypeDescription
SunEditor.EventParams.BaseEventBase event parameters
SunEditor.EventParams.PluginEventPlugin event parameters (frameContext, event, data, line, range, file, doc)
SunEditor.EventParams.ClipboardEventClipboard event parameters
SunEditor.EventParams.FileManagementInfoFile management info
SunEditor.EventParams.ProcessInfoProcess info
SunEditor.EventParams.ImageInfoImage-specific info
SunEditor.EventParams.VideoInfoVideo-specific info
SunEditor.EventParams.AudioInfoAudio-specific info
SunEditor.EventParams.FileInfoFile-specific info
SunEditor.EventParams.EmbedInfoEmbed-specific info

SunEditor.UI

UI and toolbar configuration types.

TypeDescription
SunEditor.UI.ButtonCommandBuilt-in command button names
SunEditor.UI.ButtonPluginPlugin button names
SunEditor.UI.ButtonSpecialSpecial controls ("|", "/", "-left", etc.)
SunEditor.UI.ButtonItemSingle button item
SunEditor.UI.ButtonListFull button list configuration

ButtonSpecial Values

ValueDescription
"|"Vertical separator
"/"Line break (new row)
"-left" | "-right" | "-center"Float alignment
"#fix"RTL direction fix
":Title-icon"More button with dropdown
"%50" | "%100"Responsive breakpoint

DOM & Window Aliases

DOM/window intersection types used across the editor and iframe-safe code.

TypeDescription
SunEditor.EventWysiwygWYSIWYG element intersected with Window (HTMLElement & Window)
SunEditor.WysiwygFrameWYSIWYG iframe element (HTMLElement & HTMLIFrameElement)
SunEditor.GlobalWindowGlobal window (Window & typeof globalThis)

Usage Examples

TypeScript

import type { SunEditor } from 'suneditor';

// Editor instance
const editor: SunEditor.Instance = suneditor.init({ ... });

// Options
const options: SunEditor.InitOptions = {
  width: '100%',
  height: '400px',
  buttonList: [['bold', 'italic', '|', 'underline']]
};

// Hook parameters
function onKeyDown(params: SunEditor.HookParams.KeyEvent): void {
  const { event, frameContext } = params;
  // ...
}

// Component info
function handleComponent(info: SunEditor.ComponentInfo): void {
  console.log(info.pluginName, info.target);
}

JSDoc

/**
 * @param {SunEditor.HookParams.MouseEvent} params
 */
function onMouseDown(params) {
	const { event, frameContext, target } = params;
	// ...
}

/**
 * @type {SunEditor.InitOptions}
 */
const options = {
	plugins: [image, video],
	buttonList: [['image', 'video']],
};