Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Editor

This is the class to instantiate for editing.

Hierarchy

  • Editor

Implements

  • EditorAPI

Index

Constructors

Properties

Accessors

Methods

Constructors

constructor

  • new Editor(widget: HTMLElement, options: Options | Runtime): Editor

Properties

$dataRoot

$dataRoot: JQuery

$errorList

$errorList: JQuery

Private $excludedFromBlur

$excludedFromBlur: JQuery

$frame

$frame: JQuery

$guiRoot

$guiRoot: JQuery

Private $inputField

$inputField: JQuery

Private $modificationStatus

$modificationStatus: JQuery

Private $navigationList

$navigationList: JQuery

Private $navigationPanel

$navigationPanel: JQuery

Private $saveStatus

$saveStatus: JQuery

$widget

$widget: JQuery

Private _dataChild

_dataChild: Element | undefined

A temporary initialization value.

Private _firstValidationComplete

_firstValidationComplete: boolean = false

Private _selectionMode

_selectionMode: SelectionMode = SelectionMode.SPAN

Private _selectionModeChanges

_selectionModeChanges: Subject<SelectionModeChange> = new Subject()

Private _transformations

_transformations: TransformationEventSubject = new TransformationEventSubject()

Private _undo

_undo: UndoList

Private appender

appender: AjaxAppender | undefined

Private caretLayer

caretLayer: Layer

caretManager

caretManager: CaretManager

Private caretOwners

caretOwners: NodeListOf<Element>

Private clickedLabels

clickedLabels: NodeListOf<Element>

Private clipboard

clipboard: Clipboard

Private clipboardAdd

clipboardAdd: boolean = false

complexPatternAction

complexPatternAction: Action<__type>

Private composing

composing: boolean = false

Private compositionData

compositionData: object | undefined

Private constrainer

constrainer: HTMLElement

Private currentLabelLevel

currentLabelLevel: number = 0

cutTr

cutUnitTr

cutUnitTr: Transformation<CutUnitTransformationData>

dataDLocRoot

dataDLocRoot: DLocRoot

dataRoot

dataRoot: Document

dataUpdater

dataUpdater: TreeUpdater

decreaseLabelVisibilityLevelAction

decreaseLabelVisibilityLevelAction: Action<__type> = new editorActions.DecreaseLabelVisibilityLevel(this)

Private deleteCharTr

deleteSelectionTr

Private destroyed

destroyed: boolean = false

Private developmentMode

developmentMode: boolean = false

doc

doc: Document

docURL

docURL: string

domlistener

domlistener: domlistener.DOMListener

editingMenuManager

editingMenuManager: EditingMenuManager

Private errorItemHandlerBound

errorItemHandlerBound: ErrorItemHandler

Private errorLayer

errorLayer: ErrorLayer

firstValidationComplete

firstValidationComplete: Promise<Editor>

Private firstValidationCompleteResolve

firstValidationCompleteResolve: function

Type declaration

    • Parameters

      Returns void

Private globalKeydownHandlers

globalKeydownHandlers: KeydownHandler[] = []

guiDLocRoot

guiDLocRoot: DLocRoot

guiRoot

guiRoot: HTMLElement

guiUpdater

guiUpdater: GUIUpdater

increaseLabelVisibilityLevelAction

increaseLabelVisibilityLevelAction: Action<__type> = new editorActions.IncreaseLabelVisibilityLevel(this)

Private initialLabelLevel

initialLabelLevel: number = 0

initialized

initialized: Promise<Editor>

Private initializedResolve

initializedResolve: function

Type declaration

    • Parameters

      Returns void

Private inputField

inputField: HTMLInputElement

Private insertTextTr

maxLabelLevel

maxLabelLevel: number = 0

mergeWithNextHomogeneousSiblingTr

mergeWithNextHomogeneousSiblingTr: Transformation<TransformationData>

mergeWithPreviousHomogeneousSiblingTr

mergeWithPreviousHomogeneousSiblingTr: Transformation<TransformationData>

minibuffer

minibuffer: Minibuffer

modals

modals: StockModals

Private modeData

modeData: any

modeTree

modeTree: ModeTree

name

name: string = ""

Private normalizeEnteredSpaces

normalizeEnteredSpaces: boolean = true

options

options: Options

pasteTr

pasteTr: Transformation<PasteTransformationData>

pasteUnitTr

pasteUnitTr: Transformation<PasteTransformationData>

Private preferences

preferences: preferences.Preferences

redoAction

redoAction: Action<__type> = new editorActions.Redo(this)

removeMarkupTr

replaceRangeTr

replaceRangeTr: Transformation<ReplaceRangeTransformationData>

Private replacedSpaces

replacedSpaces: RegExp = /\s+/g

runtime

runtime: Runtime

saveAction

saveAction: Action<__type> = new editorActions.Save(this)

Private saveStatusInterval

saveStatusInterval: number | undefined

saver

saver: Saver

Private scroller

scroller: Scroller

selectionModeChanges

selectionModeChanges: Observable<SelectionModeChange> = this._selectionModeChanges.asObservable()

setSelectionModeToSpan

setSelectionModeToSpan: Action<__type> = new editorActions.SetSelectionMode(this, "span",icon.makeHTML("spanSelectionMode"),SelectionMode.SPAN)

setSelectionModeToUnit

setSelectionModeToUnit: Action<__type> = new editorActions.SetSelectionMode(this, "unit",icon.makeHTML("unitSelectionMode"),SelectionMode.UNIT)

Private sidebar

sidebar: HTMLElement

splitNodeTr

Private strippedSpaces

strippedSpaces: RegExp = /\u200B/g

Private taskRunners

taskRunners: TaskRunner[] = []

Private taskSuspension

taskSuspension: number = 0

Private textUndoMaxLength

textUndoMaxLength: number = 10

toggleAttributeHidingAction

toggleAttributeHidingAction: Action<__type> = new editorActions.ToggleAttributeHiding(this)

toolbar

toolbar: Toolbar

transformations

transformations: Observable<TransformationEvent> = this._transformations.asObservable()

undoAction

undoAction: Action<__type> = new editorActions.Undo(this)

Private undoRecorder

undoRecorder: UndoRecorder

Private updatingPlaceholder

updatingPlaceholder: number = 0

Private validationController

validationController: ValidationController

Private validationMessage

validationMessage: HTMLElement

Private validationProgress

validationProgress: HTMLElement

validator

validator: Validator

Private wedLocationBar

wedLocationBar: HTMLElement

widget

widget: HTMLElement

window

window: Window

Private withCaret

withCaret: NodeListOf<Element>

Accessors

selectionMode

undoEvents

Methods

Private _deleteChar

Private _deleteSelection

Private _fireTransformation

Private _insertText

addToolbarAction

  • addToolbarAction(actionClass: editorActions.ActionCtor, options: AddOptions): void

Private caretChange

Private clipboardToElement

  • clipboardToElement(data: DataTransfer): Element | null

Private closeAllTooltips

  • closeAllTooltips(): boolean

Private compensateForAdjacentSpaces

  • compensateForAdjacentSpaces(text: string, caret: DLoc): string

Private compositionHandler

  • compositionHandler(ev: JQueryEventObject): void

Private copyHandler

  • copyHandler(e: JQueryEventObject): boolean

Private cut

Private cutHandler

  • cutHandler(e: JQueryEventObject): boolean

Private cutUnit

  • cutUnit(_editor: EditorAPI, data: CutUnitTransformationData): void
  • Parameters

    • _editor: EditorAPI
    • data: CutUnitTransformationData

    Returns void

decreaseLabelVisiblityLevel

  • decreaseLabelVisiblityLevel(): void

Private deleteChar

  • deleteChar(key: Key): void
  • Delete a single character of text at caret.

    Parameters

    • key: Key

      The keyboard key that performs the deletion.

    Returns void

    Whether a character was deleted.

Private deleteSelection

  • deleteSelection(): boolean
  • Delete the current selection from the document. If the selection is not well-formed, this is a no-op.

    We do not call this a "cut" because a real cut operation modifies the clipboard. Whereas this does not.

    Returns boolean

    false if there was no selection to process, or the selection was empty. true otherwise.

destroy

  • destroy(): void

dumpUndo

  • dumpUndo(): void

Private enterTaskSuspension

  • enterTaskSuspension(): void
  • Enter a state in which all tasks are suspended. It is possible to call this method while the state is already in effect. Its sister method exitTaskSuspension should be called the same number of times to resume the tasks.

    Returns void

Private errorItemHandler

  • errorItemHandler(ev: JQueryEventObject): boolean

excludeFromBlur

  • excludeFromBlur(elements: JQuery | Element): void

Private exitTaskSuspension

  • exitTaskSuspension(): void
  • Exit a state in which all tasks are suspended. For the state to be effectively exited, this method needs to be called the same number of times enterTaskSuspension was called.

    Returns void

expandErrorPanelWhenNoNavigation

  • expandErrorPanelWhenNoNavigation(): void
  • Expand the error panel if there is no navigation.

    Returns void

Private findLocationAt

  • findLocationAt(x: number, y: number): DLoc | undefined
  • Finds the location of the character closest to the x, y coordinates. Very often this will be the character whose bounding client rect encloses the coordinates. However, if no such character exists the algorithm will return the closest character. If multiple characters are at the same distance, then the first one found will be returned.

    Parameters

    • x: number

      The x coordinate in client coordinates.

    • y: number

      The y coordinate in client coordinates.

    Returns DLoc | undefined

    The location of the boundary character. The value return is undefined if the coordinates are outside the client or if the element in which the click occurred is not inside the editor pane (a descendant of this.guiRoot).

Private findLocationInElementAt

  • findLocationInElementAt(node: Node, x: number, y: number, textOk?: boolean): DLoc | undefined
  • Parameters

    • node: Node
    • x: number
    • y: number
    • Default value textOk: boolean = true

    Returns DLoc | undefined

fireTransformation

fromDataNode

  • fromDataNode(node: Node): Node | null

getElementTransformationsAt

  • getElementTransformationsAt(treeCaret: DLoc, types: string | string[]): object[]
  • Returns the list of element transformations for the location pointed to by the caret.

    Parameters

    • treeCaret: DLoc

      The location in the document. This must be a data location, not a GUI location.

    • types: string | string[]

      The types of transformations to get.

    Returns object[]

    An array of objects having the fields tr which contain the actual transformation and name which is the unresolved element name for this transformation. It is exceptionally possible to have an item of the list contain undefined for name.

getModeData

  • getModeData(key: string): any

Private globalKeydownHandler

  • globalKeydownHandler(wedEvent: JQueryEventObject, e: JQueryEventObject): boolean
  • Parameters

    • wedEvent: JQueryEventObject
    • e: JQueryEventObject

    Returns boolean

Private globalKeypressHandler

  • globalKeypressHandler(_wedEvent: JQueryEventObject, e: JQueryKeyEventObject): boolean
  • Parameters

    • _wedEvent: JQueryEventObject
    • e: JQueryKeyEventObject

    Returns boolean

Private handleKeyInsertingText

  • handleKeyInsertingText(e: JQueryKeyEventObject): boolean | undefined
  • Parameters

    • e: JQueryKeyEventObject

    Returns boolean | undefined

increaseLabelVisibilityLevel

  • increaseLabelVisibilityLevel(): void

init

  • init(xmlData?: undefined | string): Promise<Editor>

Private initializeNamespaces

  • initializeNamespaces(): string | undefined

Private initiateTextUndo

  • initiateTextUndo(): wundo.UndoGroup

Private inputHandler

  • inputHandler(): void

insertText

  • insertText(text: string): void

insertTransientPlaceholderAt

  • insertTransientPlaceholderAt(loc: DLoc): Element

isAttrProtected

  • isAttrProtected(attr: string, parent: Element): boolean
  • isAttrProtected(attr: Attr | Element): boolean

Private keydownHandler

  • keydownHandler(e: JQueryKeyEventObject): void

Private keypressHandler

  • keypressHandler(e: JQueryEventObject): boolean | undefined
  • Parameters

    • e: JQueryEventObject

    Returns boolean | undefined

makeGUITreeTooltip

  • makeGUITreeTooltip($for: JQuery, options: TooltipOptions): void
  • Parameters

    • $for: JQuery
    • options: TooltipOptions

    Returns void

makeModal

  • makeModal(options?: ModalOptions): Modal

Private mousedownHandler

  • mousedownHandler(ev: JQueryMouseEventObject): boolean

Private mousemoveHandler

  • mousemoveHandler(e: JQueryMouseEventObject): void

Private mouseoutHandler

  • mouseoutHandler(ev: JQueryMouseEventObject): boolean | undefined
  • Parameters

    • ev: JQueryMouseEventObject

    Returns boolean | undefined

Private mouseoverHandler

  • mouseoverHandler(ev: JQueryMouseEventObject): void

Private mouseupHandler

  • mouseupHandler(ev: JQueryEventObject): boolean

Private newContentHandler

  • Handler preparing nodes included into the tree. This handler preforms an initial generic setup that does not need mode-specific information.

    Parameters

    Returns void

newTaskRunner

  • Creates a new task runner and registers it with the editor so that it is started and stopped by the methods that stop/start all tasks.

    Parameters

    • task: Task

      The task that the runner must run.

    Returns TaskRunner

    The new runner.

nodeToPath

  • nodeToPath(node: Node | Attr): string

Private normalizeEnteredText

  • normalizeEnteredText(text: string): string

Private notifyHeterogenousData

  • notifyHeterogenousData(): void

Private onModeChange

Private onPossibleDueToWildcardChange

  • onPossibleDueToWildcardChange(node: Node): void

Private onSaverAutosaved

  • onSaverAutosaved(): void

Private onSaverChanged

  • onSaverChanged(): void

Private onSaverFailed

Private onSaverSaved

  • onSaverSaved(): void

Private onValidatorStateChange

  • onValidatorStateChange(workingState: WorkingStateData): void

openDocumentationLink

  • openDocumentationLink(url: string): void
  • Opens a documentation link.

    Parameters

    • url: string

      The URL to open.

    Returns void

Private paste

  • paste(_editor: EditorAPI, data: PasteTransformationData): void
  • Parameters

    • _editor: EditorAPI
    • data: PasteTransformationData

    Returns void

Private pasteHandler

  • pasteHandler(e: JQueryEventObject): boolean

Private pasteIntoElement

  • pasteIntoElement(caret: DLoc, toPaste: Element): DLoc

Private pasteUnit

  • pasteUnit(_editor: EditorAPI, data: PasteTransformationData): void
  • Parameters

    • _editor: EditorAPI
    • data: PasteTransformationData

    Returns void

pathToNode

  • pathToNode(path: string): Node | Attr | null

Private pointToCharBoundary

  • pointToCharBoundary(x: number, y: number): DLoc | undefined

popGlobalKeydownHandler

Private postInitialize

  • postInitialize(): Promise<Editor>

pushGlobalKeydownHandler

recordUndo

  • recordUndo(undo: Undo): void
  • Record an undo object in the list of undoable operations.

    Note that this method also provides the implementation for the restricted method of the same name that allows only "wed/undo".UndoMarker objects.

    Parameters

    • undo: Undo

      The object to record.

    Returns void

redo

  • redo(): void

Private refreshSaveStatus

  • refreshSaveStatus(): void

replaceRange

  • replaceRange(editor: EditorAPI, data: ReplaceRangeTransformationData): void
  • Parameters

    • editor: EditorAPI
    • data: ReplaceRangeTransformationData

    Returns void

resetLabelVisibilityLevel

  • resetLabelVisibilityLevel(): void
  • Reset the label visibility level to what it was when the editor was first initialized.

    Returns void

resize

  • resize(): void

Private resizeHandler

  • resizeHandler(): void

Private resumeAllTasks

  • resumeAllTasks(): void

resumeTaskWhenPossible

  • If we are not in the task suspended state that is entered upon calling enterTaskSuspension, resume the task right away. Otherwise, this is a no-op.

    Parameters

    Returns void

save

  • save(): Promise<void>

setLabelVisibilityLevel

  • setLabelVisibilityLevel(level: number): void
  • Set the visibility level to a specific value. It is a no-op if it is called with a value that is less than 0 or greater than the maximum level supported, or if the new level is the same as the current level.

    Parameters

    • level: number

      The new level.

    Returns void

Private setLocationTo

  • setLocationTo(el: Element): void
  • Set the location bar to a new location.

    Parameters

    • el: Element

      The element at which the location should point.

    Returns void

setModeData

  • setModeData(key: string, value: any): void

setNavigationList

  • setNavigationList(items: Node | JQuery | Node[]): void

Private shouldAddToClipboard

  • shouldAddToClipboard(): boolean

Private spanCopyHandler

Private spanCutHandler

Private spanPasteHandler

  • spanPasteHandler(e: JQueryEventObject): void

Private spliceAttribute

  • spliceAttribute(attrVal: HTMLElement, offset: number, count: number, add: string): void
  • Parameters

    • attrVal: HTMLElement
    • offset: number
    • count: number
    • add: string

    Returns void

Private stopAllTasks

  • stopAllTasks(): void

Private terminateTextUndo

  • terminateTextUndo(): void

toDataNode

  • toDataNode(node: Node): Node | Attr | null

toggleAttributeHiding

  • toggleAttributeHiding(): void

type

  • Simulates typing text in the editor.

    NOTE: this function is limited in what it can simulate. The main editing pane is where you get the most support. Other locations offer less support. One good example is the minibuffer. Typing a string into it works fine. Trying to use directional arrows and backspace/delete currently does not work. We'd have to write custom code to handle these cases because it is not possible, as we speak, to write JavaScript code that entirely simulates pressing keyboard keys. (JavaScript easily supports sending the events generated by hitting the keyboard, but this is not enough.)

    Parameters

    • text: string | Key | Key[]

      The text to type in. An array of keys, a string or a single key.

    • Default value where: WedEventTarget = WedEventTarget.DEFAULT

    Returns void

undo

  • undo(): void

undoAll

  • undoAll(): void

undoingOrRedoing

  • undoingOrRedoing(): boolean

Private unitCopyHandler

Private unitCutHandler

Private unitPasteHandler

  • unitPasteHandler(e: JQueryEventObject): void

Generated using TypeDoc