Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DocumentModel

The default implementation of a document model.

Hierarchy

  • Model
    • DocumentModel

Implements

Index

Constructors

constructor

  • Construct a new document model.

    Parameters

    • Optional languagePreference: string
    • Optional modelDB: IModelDB

    Returns DocumentModel

Properties

Private _contentChanged

_contentChanged: any

Private _defaultLang

_defaultLang: any

Private _onStateChanged

_onStateChanged: any

Private _readOnly

_readOnly: any

Private _stateChanged

_stateChanged: any

Readonly modelDB

modelDB: IModelDB

The underlying IModelDB instance in which model data is stored.

Readonly sharedModel

sharedModel: ISharedFile

The shared notebook model.

Accessors

contentChanged

  • get contentChanged(): ISignal<this, void>
  • A signal emitted when the document content changes.

    Returns ISignal<this, void>

defaultKernelLanguage

  • get defaultKernelLanguage(): string
  • The default kernel language of the document.

    Notes

    This is a read-only property.

    Returns string

defaultKernelName

  • get defaultKernelName(): string
  • The default kernel name of the document.

    Notes

    This is a read-only property.

    Returns string

dirty

  • get dirty(): boolean
  • set dirty(newValue: boolean): void
  • The dirty state of the document.

    Returns boolean

  • The dirty state of the document.

    Parameters

    • newValue: boolean

    Returns void

isDisposed

  • get isDisposed(): boolean
  • Whether the model is disposed.

    Returns boolean

mimeType

  • get mimeType(): string
  • set mimeType(newValue: string): void
  • A mime type of the model.

    Returns string

  • A mime type of the model.

    Parameters

    • newValue: string

    Returns void

mimeTypeChanged

  • get mimeTypeChanged(): ISignal<this, IChangedArgs<string, string, string>>
  • A signal emitted when a mimetype changes.

    Returns ISignal<this, IChangedArgs<string, string, string>>

readOnly

  • get readOnly(): boolean
  • set readOnly(newValue: boolean): void
  • The read only state of the document.

    Returns boolean

  • The read only state of the document.

    Parameters

    • newValue: boolean

    Returns void

selections

sharedModelSwitched

  • get sharedModelSwitched(): ISignal<this, boolean>
  • A signal emitted when the shared model was switched.

    Returns ISignal<this, boolean>

stateChanged

  • get stateChanged(): ISignal<this, IChangedArgs<any, any, string>>
  • A signal emitted when the document state changes.

    Returns ISignal<this, IChangedArgs<any, any, string>>

type

  • Returns CellType

value

Methods

Protected _onSharedModelChanged

  • _onSharedModelChanged(sender: ISharedBaseCell<any>, change: CellChange<IBaseCellMetadata>): void
  • We update the modeldb store when the shared model changes. To ensure that we don't run into infinite loops, we wrap this call in a "mutex". The "mutex" ensures that the wrapped code can only be executed by either the sharedModelChanged handler or the modelDB change handler.

    Parameters

    Returns void

dispose

  • dispose(): void
  • Dispose of the resources used by the model.

    Returns void

fromJSON

  • fromJSON(value: PartialJSONValue): void
  • Deserialize the model from JSON.

    Notes

    Should emit a [contentChanged] signal.

    Parameters

    • value: PartialJSONValue

    Returns void

fromString

  • fromString(value: string): void
  • Deserialize the model from a string.

    Notes

    Should emit a [contentChanged] signal.

    Parameters

    • value: string

    Returns void

initialize

  • initialize(): void
  • Initialize the model with its current state.

    Returns void

switchSharedModel

  • switchSharedModel(sharedModel: ISharedText, reinitialize?: boolean): void
  • When we initialize a cell model, we create a standalone model that cannot be shared in a YNotebook. Call this function to re-initialize the local representation based on a fresh shared model (e.g. models.YFile or models.YCodeCell).

    Parameters

    • sharedModel: ISharedText
    • Optional reinitialize: boolean

      Whether to reinitialize the shared model.

    Returns void

toJSON

  • toJSON(): PartialJSONValue
  • Serialize the model to JSON.

    Returns PartialJSONValue

toString

  • toString(): string
  • Serialize the model to a string.

    Returns string

Protected triggerContentChange

  • triggerContentChange(): void
  • Trigger a content changed signal.

    Returns void

Protected triggerStateChange

  • triggerStateChange(args: IChangedArgs<any, any, string>): void
  • Trigger a state change signal.

    Parameters

    Returns void

Generated using TypeDoc