The main editor class that provides a live-rendering editor for various content types.
newSquibView(element, options)
| Parameter | Type | Description |
|---|---|---|
element | HTMLElement | string | The DOM element or CSS selector where the editor will be mounted |
options | Object | Configuration options for the editor (see Options) |
// Create editor with default optionsconst editor = newSquibView('#editor');
// Create editor with custom optionsconst editor = newSquibView('#editor', {
initialContent: '# Hello World',
inputContentType: 'md',
initialView: 'split',
showControls: true,
showLineNumbers: true
});
SquibView.versionReturns version information for the library.
console.log(SquibView.version);
// { version: '1.0.18', url: 'https://github.com/...' }SquibView.defaultOptionsDefault configuration options for new instances.
{
initialContent: '',
inputContentType: 'md',
showControls: true,
titleShow: false,
titleContent: '',
initialView: 'split',
baseClass: 'squibview',
preserveImageTags: true,
showLineNumbers: false,
lineNumberStart: 1,
lineNumberMinDigits: 2,
autoload_deps: null
}
SquibView.DEFAULT_CDN_URLSDefault CDN URLs for autoloading external dependencies.
| Property | Type | Description |
|---|---|---|
container | HTMLElement | The container element |
input | HTMLTextAreaElement | The source input textarea |
output | HTMLElement | The rendered output element |
currentView | string | Current view mode (‘src’, ‘html’, ‘split’) |
inputContentType | string | Current content type (‘md’, ‘html’, ‘reveal’, ‘csv’, ‘tsv’) |
revisionManager | RevisionHistory | Revision history manager |
events | TinyEmitter | Event emitter for plugin communication |
setContent(content, contentType, saveRevision) - Set editor contentgetContent() - Get current source contentgetRenderedHTML() - Get rendered HTML outputclearContent() - Clear all contentsetView(view) - Change view modetoggleView() - Cycle through view modesshowSource() - Show source view onlyshowHTML() - Show rendered view onlyshowSplit() - Show split viewsetContentType(type) - Change content typegetContentType() - Get current content typeundo() - Undo last changeredo() - Redo previously undone changecanUndo() - Check if undo is availablecanRedo() - Check if redo is availablegetRevisionCount() - Get number of saved revisionscopyToClipboard(copyMode) - Copy content to clipboardgetSelectedText() - Get currently selected textgetSelectionData() - Get detailed selection informationsetOnReplaceSelectedText(handler) - Set text replacement handlerregisterRenderer(type, config) - Register custom rendererrender() - Manually trigger renderingon(event, handler) - Subscribe to eventoff(event, handler) - Unsubscribe from eventemit(event, data) - Emit custom eventSee Events Documentation for complete event reference.
content-change - Content has changedview-change - View mode has changedtype-change - Content type has changedrender - Content has been renderedselection-change - Text selection has changedrevision-added - New revision savedundo - Undo performedredo - Redo performed