Constructor
new HistoryRecordingService(undoManager)
Parameters:
Name | Type | Description |
---|---|---|
undoManager |
history.UndoManager | null | The undo manager.
A value of |
- Source:
Examples
hrService = new HistoryRecordingService(this.undoMgr);
hrService.insertElement(elem, text); // add simple command to history.
hrService.startBatchCommand('create two elements');
hrService.changeElement(elem, attrs, text); // add to batchCommand
hrService.changeElement(elem, attrs2, text); // add to batchCommand
hrService.endBatchCommand(); // add batch command with two change commands to history.
hrService.insertElement(elem, text); // add simple command to history.
// Note that all functions return this, so commands can be chained, like so:
hrService
.startBatchCommand('create two elements')
.insertElement(elem, text)
.changeElement(elem, attrs, text)
.endBatchCommand();
Members
(static) HistoryRecordingService.NO_HISTORY
Properties:
Name | Type | Description |
---|---|---|
NO_HISTORY |
module:history.HistoryRecordingService | Singleton that can be passed to functions that record history, but the caller requires that no history be recorded. |
- Source:
Methods
changeElement(elem, attrs, textopt) → {module:history.HistoryRecordingService}
Add a ChangeElementCommand
to the history or current batch command.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem |
Element | The DOM element that was changed |
|
attrs |
module:history.CommandAttributes | An object with the attributes to be changed and the values they had before the change |
|
text |
string |
<optional> |
An optional string visible to user related to this change |
- Source:
Returns:
endBatchCommand() → {module:history.HistoryRecordingService}
End a batch command and add it to the history or a parent batch command.
- Source:
Returns:
insertElement(elem, textopt) → {module:history.HistoryRecordingService}
Add an InsertElementCommand
to the history or current batch command.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem |
Element | The DOM element that was added |
|
text |
string |
<optional> |
An optional string visible to user related to this change |
- Source:
Returns:
moveElement(elem, oldNextSibling, oldParent, textopt) → {module:history.HistoryRecordingService}
Add a MoveElementCommand
to the history or current batch command.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem |
Element | The DOM element that was moved |
|
oldNextSibling |
Element | The element's next sibling before it was moved |
|
oldParent |
Element | The element's parent before it was moved |
|
text |
string |
<optional> |
An optional string visible to user related to this change |
- Source:
Returns:
removeElement(elem, oldNextSibling, oldParent, textopt) → {module:history.HistoryRecordingService}
Add a RemoveElementCommand
to the history or current batch command.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
elem |
Element | The DOM element that was removed |
|
oldNextSibling |
Element | The element's next sibling before it was removed |
|
oldParent |
Element | The element's parent before it was removed |
|
text |
string |
<optional> |
An optional string visible to user related to this change |
- Source:
Returns:
startBatchCommand(text) → {module:history.HistoryRecordingService}
Start a batch command so multiple commands can recorded as a single history command. Requires a corresponding call to endBatchCommand. Start and end commands can be nested.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | Optional string describing the batch command. |
- Source: