Expand all

abstract ve.ui.AnnotationInspector

Extends

Constructor

new ve.ui.AnnotationInspector([config])abstract #

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Source:
Inspector for working with content annotations.

Properties

getAnnotationabstract #

Get the annotation object to apply.

This method is called when the inspector is closing, and should return the annotation to apply to the text. If this method returns a falsey value like null, no annotation will be applied, but existing annotations won't be removed either.

Source:
Get the annotation object to apply.

getAnnotationFromFragmentabstract #

Get an annotation object from a fragment.

Source:
Get an annotation object from a fragment.

modelClassesstatic #

Annotation models this inspector can edit.

Properties:

Type Description
Array.<function()>
Source:
Annotation models this inspector can edit.

Methods

getInsertionData() → {Array.<string>} #

Get data to insert if nothing was selected when the inspector opened.

Defaults to using #getInsertionText.

Source:

Returns:

Linear model content to insert

Type
Array.<string>
Get data to insert if nothing was selected when the inspector opened.

getInsertionText() → {string} #

Get text to insert if nothing was selected when the inspector opened.

Source:

Returns:

Text to insert

Type
string
Get text to insert if nothing was selected when the inspector opened.

getMatchingAnnotations(fragment, [all]) → {ve.dm.AnnotationSet} #

Get matching annotations within a fragment.

Parameters:

Name Type Attributes Description
fragment ve.dm.SurfaceFragment

Fragment to get matching annotations within

all boolean optional

Get annotations which only cover some of the fragment

Source:

Returns:

Matching annotations

Type
ve.dm.AnnotationSet
Get matching annotations within a fragment.

getSetupProcess([data]) → {OO.ui.Process} #

Handle the inspector being setup.

There are 4 scenarios:

  • Zero-length selection not near a word -> no change, text will be inserted on close
  • Zero-length selection inside or adjacent to a word -> expand selection to cover word
  • Selection covering non-annotated text -> trim selection to remove leading/trailing whitespace
  • Selection covering annotated text -> expand selection to cover annotation

Parameters:

Name Type Attributes Description
data Object optional

Inspector opening data

Properties:
Name Type Attributes Description
noExpand boolean optional

Don't expand the selection when opening

Overrides:
Source:

Returns:

Type
OO.ui.Process
Handle the inspector being setup.

onFormSubmit() #

Handle form submit events.

Executes the 'done' action when the user presses enter in the form.

Inherited from:
Source:
Handle form submit events.

shouldInsertText() → {boolean} #

Work out whether the teardown process should replace the current text of the fragment.

Default behavior is to only do so if nothing was selected initially, in which case we need something to apply the annotation to. If this returns true, getInsertionData had better produce something.

Source:

Returns:

Whether to insert text on teardown

Type
boolean
Work out whether the teardown process should replace the current text of the fragment.

shouldRemoveAnnotation() → {boolean} #

Check if form is empty, which if saved should result in removing the annotation.

Only override this if the form provides the user a way to blank out primary information, allowing them to remove the annotation by clearing the form.

Source:

Returns:

Form is empty

Type
boolean
Check if form is empty, which if saved should result in removing the annotation.