Skip to content

Type Editor


Type Editor / @type-editor/editor-types

@type-editor/editor-types

Common TypeScript type definitions for the Type Editor.

This module provides shared interfaces, types, and enums used across the Type Editor packages. It defines the core contracts that other modules implement, enabling better separation of concerns and avoiding circular dependencies between packages.

Installation

bash
npm install @type-editor/editor-types

Overview

This package exports type definitions organized into three main categories:

State Types

Type definitions related to editor state management:

  • Editor State: PmEditorState, EditorStateConfig, EditorStateDto, StateJSON
  • Transactions: PmTransaction
  • Plugins: PmPlugin, PmPluginKey, PluginSpec, PluginView, StateField
  • Selection: PmSelection, PmSelectionRange, SelectionBookmark, SelectionJSON

Transform Types

Type definitions for document transformations:

  • Mapping: Mappable, MapResult, PmMapping
  • Steps: PmStep, PmStepMap, PmStepResult, StepJSON
  • Document: TransformDocument
  • Attributes: AttrValue

View Types

Type definitions for the editor view layer:

  • Editor View: PmEditorView, DirectEditorProps, EditorProps, NodeViewSet
  • DOM: DOMSelectionRange, DOMEventMap, PmDOMObserver
  • Decorations: PmDecoration, DecorationSource, DecorationSpec, DecorationType, DecorationWidgetOptions, InlineDecorationOptions, NodeDecorationOptions
  • Node Views: NodeView, NodeViewConstructor, MarkView, MarkViewConstructor, PmViewDesc, PmNodeViewDesc, ViewMutationRecord
  • Input Handling: PmInputState, PmDragging, PmMouseDown
  • Selection State: PmSelectionState

Enums

  • ViewDescType: Enum for view descriptor types (VIEW, NODE, MARK, COMPOSITION, TEXT, WIDGET, CUSTOM, TRAILING_HACK)
  • ViewDirtyState: Enum for tracking view dirty states (NOT_DIRTY, CHILD_DIRTY, CONTENT_DIRTY, NODE_DIRTY)

Usage

typescript
import type {
  PmEditorState,
  PmEditorView,
  PmTransaction,
  PmPlugin,
  NodeView,
} from "@type-editor/editor-types";

import { ViewDescType, ViewDirtyState } from "@type-editor/editor-types";

// Use types for function signatures
function handleTransaction(
  view: PmEditorView,
  tr: PmTransaction,
): PmEditorState {
  return view.state.apply(tr);
}

// Use enums for comparisons
if (dirtyState === ViewDirtyState.NODE_DIRTY) {
  // Recreate the entire node
}

License

MIT

Modules

ModuleDescription

@types

types/state/command/Command

types/state/command/DispatchFunction

types/state/editor-state/EditorStateConfig

types/state/editor-state/EditorStateDto

types/state/editor-state/PmEditorState

types/state/editor-state/StateJSON

types/state/plugin/PluginSpec

types/state/plugin/PluginView

types/state/plugin/PmPlugin

types/state/plugin/PmPluginKey

types/state/plugin/StateField

types/state/PmTransaction

types/state/selection/PmSelection

types/state/selection/PmSelectionRange

types/state/selection/SelectionBookmark

types/state/selection/SelectionJSON

types/transform/AttrValue

types/transform/Mappable

types/transform/MapResult

types/transform/PmMapping

types/transform/PmStep

types/transform/PmStepMap

types/transform/PmStepResult

types/transform/StepJSON

types/transform/TransformDocument

types/view/decoration/DecorationSource

types/view/decoration/DecorationSpec

types/view/decoration/DecorationType

types/view/decoration/DecorationWidgetOptions

types/view/decoration/InlineDecorationOptions

types/view/decoration/NodeDecorationOptions

types/view/decoration/PmDecoration

types/view/dom/DOMSelectionRange

types/view/editor-view/DirectEditorProps

types/view/editor-view/DOMEventMap

types/view/editor-view/EditorProps

types/view/editor-view/NodeViewSet

types/view/input-handler/PmDragging

types/view/input-handler/PmInputState

types/view/input-handler/PmMouseDown

types/view/PmDOMObserver

types/view/PmEditorView

types/view/PmSelectionState

types/view/view-desc/MarkView

types/view/view-desc/MarkViewConstructor

types/view/view-desc/NodeView

types/view/view-desc/NodeViewConstructor

types/view/view-desc/PmNodeViewDesc

types/view/view-desc/PmViewDesc

types/view/view-desc/ViewMutationRecord

view/ViewDescType

view/ViewDirtyState