@@ -23,6 +23,7 @@ const icons = {
23
23
warning : 'warning' ,
24
24
error : 'report' ,
25
25
action : 'history' ,
26
+ reset : 'none' ,
26
27
} ;
27
28
28
29
/**
@@ -33,8 +34,6 @@ const icons = {
33
34
* the committed action, allowing the user to go to `previousAction` with
34
35
* `undo()` if `canUndo` and to go to `nextAction` with `redo()` if `canRedo`.
35
36
*
36
- * Also provides a `reset()` method resetting the history and `currentAction`.
37
- *
38
37
* Renders the `history` to `logUI` and the latest `'error'` [[`LogEntry`]] to
39
38
* `messageUI`.
40
39
*/
@@ -95,19 +94,19 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
95
94
return true ;
96
95
}
97
96
98
- /** Resets the history to an empty state. */
99
- reset ( ) : void {
100
- this . history = [ ] ;
101
- this . currentAction = - 1 ;
102
- }
103
-
104
97
private onLog ( le : LogEvent ) : void {
98
+ if ( le . detail . kind === 'reset' ) {
99
+ this . history = [ ] ;
100
+ this . currentAction = - 1 ;
101
+ return ;
102
+ }
103
+
105
104
const entry : LogEntry = {
106
105
time : new Date ( ) ,
107
106
...le . detail ,
108
107
} ;
109
108
110
- if ( entry . kind == 'action' ) {
109
+ if ( entry . kind === 'action' ) {
111
110
if ( entry . action . derived ) return ;
112
111
entry . action . derived = true ;
113
112
if ( this . nextAction !== - 1 ) this . history . splice ( this . nextAction ) ;
@@ -145,11 +144,9 @@ export function Logging<TBase extends LitElementConstructor>(Base: TBase) {
145
144
146
145
this . undo = this . undo . bind ( this ) ;
147
146
this . redo = this . redo . bind ( this ) ;
148
- this . reset = this . reset . bind ( this ) ;
149
147
150
148
this . onLog = this . onLog . bind ( this ) ;
151
149
this . addEventListener ( 'log' , this . onLog ) ;
152
- this . addEventListener ( 'open-doc' , this . reset ) ;
153
150
}
154
151
155
152
renderLogEntry (
0 commit comments