tuil
ReferencePackages

@mwillbanks/tuil-editor

Renderer-neutral editor contracts and tree-shakeable terminal editor implementations for tuil.

View rawEdit

Overview

Renderer-neutral editor contracts and tree-shakeable terminal editor implementations for tuil.

@mwillbanks/tuil-editor is independently installable and also participates in the umbrella @mwillbanks/tuil runtime where applicable.

Installation

npm install @mwillbanks/tuil-editor

How it operates

Editor providers own documents, selections, history, composition, clipboard, commands, static output, and buffer, Vim, or rich editing behavior behind one contract.

Documentation flow diagram. register provider; create editor; edit/command; undo; dispose; S0 leads to S1; S1 leads to S2; S2 leads to S3
Documentation flow diagram. register provider; create editor; edit/command; undo; dispose; S0 leads to S1; S1 leads to S2; S2 leads to S3

API

APISignatureDescription
applyEditorTransactionsfunction applyEditorTransactionsPublic function applyEditorTransactions.
assertEditorInvariantfunction assertEditorInvariantPublic function assertEditorInvariant.
BuiltInRichNodeTypetype BuiltInRichNodeTypePublic type BuiltInRichNodeType.
EditorBackendinterface EditorBackendPublic interface EditorBackend.
EditorCapabilitytype EditorCapabilityPublic type EditorCapability.
EditorChangeinterface EditorChangePublic interface EditorChange.
EditorCommandinterface EditorCommandPublic interface EditorCommand.
EditorDecorationinterface EditorDecorationPublic interface EditorDecoration.
EditorDiagnosticinterface EditorDiagnosticPublic interface EditorDiagnostic.
EditorDocumentinterface EditorDocumentPublic interface EditorDocument.
EditorModetype EditorModePublic type EditorMode.
EditorPositioninterface EditorPositionPublic interface EditorPosition.
EditorProviderinterface EditorProviderPublic interface EditorProvider.
EditorProviderFactorytype EditorProviderFactoryPublic type EditorProviderFactory.
EditorProviderOptionsinterface EditorProviderOptionsPublic interface EditorProviderOptions.
EditorRangeinterface EditorRangePublic interface EditorRange.
EditorSelectioninterface EditorSelectionPublic interface EditorSelection.
EditorSessioninterface EditorSessionPublic interface EditorSession.
EditorSnapshotinterface EditorSnapshotPublic interface EditorSnapshot.
EditorTransactioninterface EditorTransactionPublic interface EditorTransaction.
insertTextfunction insertTextPublic function insertText.
RichDocumentinterface RichDocumentPublic interface RichDocument.
RichDocumentSessionclass RichDocumentSessionPublic class RichDocumentSession.
RichEditorDocumentinterface RichEditorDocumentPublic interface RichEditorDocument.
RichEditorProviderOptionsinterface RichEditorProviderOptionsPublic interface RichEditorProviderOptions.
RichMarkinterface RichMarkPublic interface RichMark.
RichNodeinterface RichNodePublic interface RichNode.
RichNodeProviderinterface RichNodeProviderPublic interface RichNodeProvider.
RichNodeTypetype RichNodeTypePublic type RichNodeType.
RichTransactioninterface RichTransactionPublic interface RichTransaction.
runEditorProviderConformancefunction runEditorProviderConformancePublic function runEditorProviderConformance.
textBufferProviderconstant textBufferProviderPublic constant textBufferProvider.
TextBufferSessionclass TextBufferSessionPublic class TextBufferSession.
vimEditorProviderconstant vimEditorProviderPublic constant vimEditorProvider.
VimEditorSessionclass VimEditorSessionPublic class VimEditorSession.
VimKeymapinterface VimKeymapPublic interface VimKeymap.
VimModetype VimModePublic type VimMode.
VimStateinterface VimStatePublic interface VimState.

Events and lifecycle

Editors publish typed snapshots and command outcomes through provider-owned subscriptions.

All subscriptions and registrations return a disposer or belong to an owning runtime that disposes them in reverse order.

Example

import { TextBufferSession } from "@mwillbanks/tuil-editor";

import { TextBufferSession } from "@mwillbanks/tuil-editor/buffer";

const editor = new TextBufferSession({ value: "hello" });

On this page