Represents a piece of the editor.
Handles the actual editing behaviour.
Props
| Name | Type | Default value | Required? | Description |
|---|---|---|---|---|
pieces |
Array.<Piece> |
- | Yes | The piece table |
index |
Number |
- | Yes | The index of the current piece. |
dragStart |
Object |
- | Yes | The start position of dragging. |
dragStop |
Object |
- | Yes | The stop position of dragging. |
theme |
Boolean |
- | Yes | If true, the theme should be a light theme, otherwise a dark theme. |
Data
| Name | Type | Default value | Description |
|---|---|---|---|
lang |
String |
- | The language of the code. |
Computed
| Name | Type | Description |
|---|---|---|
codeArray |
Array.<String> |
The code of this piece with lines separated in items in the array. |
code |
String |
The code of this piece as one continuous string. |
piece |
Piece |
The piece of the piece table that this editor represents. |
username |
String |
The owner of the piece. An empty string if there is no owner. |
editable |
Boolean |
If the piece should be editable or that it should be read only. |
pieceTable |
PieceTable |
The full piece table. |
pieceDragStart |
Number|null |
The line where the user started dragging in the lock-gutter. |
pieceDragLength |
Number |
The length of the lock the user is currently dragging. |
Members
(static) startState :Object|null
Type:
-
Object|null
Methods
gutterSelectMarker() → {HTMLElement}
Makes an marker element for highlighting the dragged lock region.
Returns:
- Type:
-
HTMLElement
- The element with a class lock-gutter-marker.
initializeEditor() → {Promise.<CodeMirror>}
Initializes a codemirror editor.
Also initiates the ghostcursors for this piece after
codemirror has been initiated.
Promise is made only once.
Returns:
- Type:
-
Promise.<CodeMirror>
The promise resolved with the made CodeMirror instance.
initializeEvents()
Initializes all events.
lineToRelativeLine(line) → {number}
- Deprecated:
- Because changes will return line again.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
line |
Returns:
- Type:
-
number
relativeLineToLine(line) → {number}
- Deprecated:
- Because changes will return line again.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
line |
Returns:
- Type:
-
number
setText()
Updates current code to be the same as this.code
unlock()
Does an request to unlock the current piece.
updateDragLength(newDragLength, oldDragLength)
Changes the drag length position in the lock gutter.
Parameters:
| Name | Type | Description |
|---|---|---|
newDragLength |
The current length of the lock the user is dragging. | |
oldDragLength |
The previous length of the lock the user is dragging. |
updateDragStart(newDragStart, oldDragStart)
Changes the drag start position in the lock gutter.
Parameters:
| Name | Type | Description |
|---|---|---|
newDragStart |
The current position where the user is dragging. | |
oldDragStart |
The previous position where the user is dragging. |
updateLineNumbers()
Changes the first line to this.$options.firstLineNumber
updateTheme()
Changes the theme between a light and dark theme as set by this.theme.