Class gui.UndoStateRules
Defined in: UndoStateRules.js.
Constructor Attributes | Constructor Name and Description |
---|---|
This class attempts to implement undo/redo behaviour identical
to how LibreOffice behaves.
|
Method Attributes | Method Name and Description |
---|---|
<inner> |
Returns true if the supplied optype is allowed to
aggregate multiple operations in a single undo or redo state
|
<inner> |
continuesMostRecentEditGroup(thisOp, recentOperations)
Returns true if thisOp can be grouped together with the most recent edit operations group.
|
<inner> |
continuesMostRecentEditOperation(thisOp, recentOperations)
Returns true if thisOp can be grouped together with the most recent edit operations.
|
<inner> |
continuesOperations(thisOp, lastEditOp, secondLastEditOp)
|
<inner> |
getOpPosition(op)
|
<inner> |
getOpType(op)
|
<inner> |
isAdjacentOperation(thisOp, lastEditOp)
Returns true if the two operations are considered adjacent.
|
<inner> |
isEditOperation(op)
Returns true if the supplied operation
is considered an editing operation.
|
<inner> |
isPartOfOperationSet(operation, recentOperations)
Returns true if the provided operation is part of the existing
set of operations according to the undo rules
|
<inner> |
isSameDirectionOfTravel(thisOp, lastEditOp, secondLastEditOp)
Returns true if the newly supplied operation is continuing
in the same direction of travel as the recent edit operations
|
Class Detail
gui.UndoStateRules()
This class attempts to implement undo/redo behaviour identical
to how LibreOffice behaves.
State iteration rules are:
- Multiple text inserts in the same direction are treated as one state
- Multiple text removes in the same direction are treated as one state
- An Undo state always consumes all trailing cursor move operations
- An edit operation cannot follow non-edit operations. A state can
start with non-edit operations if it contains no further edit ops.
Method Detail
<inner>
{!boolean}
canAggregateOperation(op)
Returns true if the supplied optype is allowed to
aggregate multiple operations in a single undo or redo state
- Parameters:
- {!ops.Operation} op
- Returns:
- {!boolean}
<inner>
{!boolean}
continuesMostRecentEditGroup(thisOp, recentOperations)
Returns true if thisOp can be grouped together with the most recent edit operations group.
For an operation to be considered continuous it must:
- Be of a type that supports aggregation (e.g., insert text or remove text)
- Be continuous with the most recent edit operation of the same type in the most recent operations group
(see isContinuousWithExistingOperation for the definition of "continuous")
- Parameters:
- {!ops.Operation} thisOp
- {!Array.} recentOperations
- Returns:
- {!boolean}
<inner>
{!boolean}
continuesMostRecentEditOperation(thisOp, recentOperations)
Returns true if thisOp can be grouped together with the most recent edit operations.
For an operation to be considered continuous it must:
- Be of a type that supports aggregation (e.g., insert text or remove text)
- Be of the same type as the most recent edit operation
- Be considered adjacent (and in the same direction as) the most recent edit operation
- Parameters:
- {!ops.Operation} thisOp
- {!Array.} recentOperations
- Returns:
- {!boolean}
<inner>
{!boolean}
continuesOperations(thisOp, lastEditOp, secondLastEditOp)
- Parameters:
- {!ops.Operation} thisOp
- {!ops.Operation} lastEditOp
- {?ops.Operation} secondLastEditOp
- Returns:
- {!boolean}
<inner>
{number|undefined}
getOpPosition(op)
- Parameters:
- {!ops.Operation} op
- Returns:
- {number|undefined}
<inner>
{string}
getOpType(op)
- Parameters:
- {!ops.Operation} op
- Returns:
- {string}
<inner>
{!boolean}
isAdjacentOperation(thisOp, lastEditOp)
Returns true if the two operations are considered adjacent.
- Parameters:
- {!ops.Operation} thisOp
- {!ops.Operation} lastEditOp
- Returns:
- {!boolean}
<inner>
{!boolean}
isEditOperation(op)
Returns true if the supplied operation
is considered an editing operation.
- Parameters:
- {!ops.Operation} op
- Returns:
- {!boolean} Returns true if the supplied op is an edit operation
<inner>
{!boolean}
isPartOfOperationSet(operation, recentOperations)
Returns true if the provided operation is part of the existing
set of operations according to the undo rules
- Parameters:
- {!ops.Operation} operation
- {!Array.} recentOperations
- Returns:
- {!boolean}
<inner>
{!boolean}
isSameDirectionOfTravel(thisOp, lastEditOp, secondLastEditOp)
Returns true if the newly supplied operation is continuing
in the same direction of travel as the recent edit operations
- Parameters:
- {!ops.Operation} thisOp
- {!ops.Operation} lastEditOp
- {!ops.Operation} secondLastEditOp
- Returns:
- {!boolean}