Document and callbacks
new ViText(target, options?) accepts a selector or HTMLElement.
| Option | Type/default | Contract |
|---|---|---|
| content | string/DocumentNode; empty document | Initial HTML/JSON/Markdown |
| contentType | html/markdown/json; html for string | Objects identify structured JSON |
| css | string; empty | Separate initial stylesheet, asynchronous |
| label | string; Document | Accessible document name |
| onChange | ChangeEvent callback | Applied document change |
| markdownPaste | boolean; enabled with Markdown support | Convert pasted plain Markdown text |
| language | ru/en; ru | Editor UI language |
| markdownDraft | string; empty | Initial Markdown draft, checked when opened |
Interface and resources
| Option | Type/default | Contract |
|---|---|---|
| preset | simple/base/pro; pro | Upper limit of available UI features |
| toolbar | readonly ToolbarItem; preset default | Subset with automatic library groups |
| toolbarLayout | readonly ToolbarLayoutItem; absent | Explicit order, separators, spacer and menus |
| features | Partial<EditorFeatures>; preset defaults | html/markdown/css/fullscreen/tables/images/plugins |
| plugins | readonly ViTextPlugin; empty | API 1 extensions, when enabled |
| uploadImage | File + AbortSignal callback; absent | Application-owned upload, otherwise URL insertion |
| onToolbarOverflow | ToolbarItem callback; absent | Tools moved to overflow |
| sourceModuleURL | string; alongside build | Trusted HTML/CSS UI module |
| codecsModuleURL | string; alongside build | Trusted Markdown/CSS engines |
Unsupported features, duplicate tools, nested menus or more than one spacer throw TypeError. CSS requires HTML. Failed plugin installation releases already installed resources. HTML/JSON without CSS apply immediately; await whenReady for initial Markdown/CSS and whenSourceReady for source controls. Presets, methods.