@compas-oscd/open-scd 0.34.21 → 0.34.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/history.ts"],"names":[],"mappings":"AA6CA,MAAM,UAAU,WAAW,CACzB,MAAiB,EACjB,aAA0C;IAE1C,OAAO,IAAI,WAAW,CAAY,KAAK,EAAE;QACvC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAAmB,EACnB,aAA4C;IAE5C,OAAO,IAAI,WAAW,CAAc,OAAO,EAAE;QAC3C,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { EditV2 } from '../edit.js';\n\ntype InfoEntryKind = 'info' | 'warning' | 'error';\n\nexport type LogEntryType = 'info' | 'warning' | 'error' | 'action' | 'reset';\n\n/** The basic information contained in each [[`LogEntry`]]. */\nexport interface LogDetailBase {\n title: string;\n message?: string;\n}\n/** The [[`LogEntry`]] for a committed [[`EditorAction`]]. */\nexport interface CommitDetail extends LogDetailBase {\n kind: 'action';\n}\n/** A [[`LogEntry`]] for notifying the user. */\nexport interface InfoDetail extends LogDetailBase {\n kind: InfoEntryKind;\n cause?: LogEntry;\n}\n\nexport interface ResetDetail {\n kind: 'reset';\n}\n\nexport type LogDetail = InfoDetail | CommitDetail | ResetDetail;\nexport type LogEvent = CustomEvent<LogDetail>;\n\nexport interface IssueDetail extends LogDetailBase {\n validatorId: string;\n element?: Element;\n}\nexport type IssueEvent = CustomEvent<IssueDetail>;\n\n/** [[`LogEntry`]]s are timestamped upon being committed to the `history`. */\ninterface Timestamped {\n time: Date | null;\n}\n\nexport type CommitEntry = Timestamped & CommitDetail;\nexport type InfoEntry = Timestamped & InfoDetail;\n\nexport type LogEntry = InfoEntry | CommitEntry;\n\n\nexport function newLogEvent(\n detail: LogDetail,\n eventInitDict?: CustomEventInit<LogDetail>\n): LogEvent {\n return new CustomEvent<LogDetail>('log', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\nexport function newIssueEvent(\n detail: IssueDetail,\n eventInitDict?: CustomEventInit<IssueDetail>\n): IssueEvent {\n return new CustomEvent<IssueDetail>('issue', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['log']: LogEvent;\n ['issue']: IssueEvent;\n }\n }\n "]}
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../../../core/foundation/deprecated/history.ts"],"names":[],"mappings":"AAgDA,MAAM,UAAU,WAAW,CACzB,MAAiB,EACjB,aAA0C;IAE1C,OAAO,IAAI,WAAW,CAAY,KAAK,EAAE;QACvC,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,MAAmB,EACnB,aAA4C;IAE5C,OAAO,IAAI,WAAW,CAAc,OAAO,EAAE;QAC3C,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,IAAI;QACd,GAAG,aAAa;QAChB,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,GAAG,aAAa,EAAE,MAAM,EAAE;KAChD,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { EditV2 } from '../edit.js';\n\ntype InfoEntryKind = 'info' | 'warning' | 'error';\n\nexport type LogEntryType = 'info' | 'warning' | 'error' | 'action' | 'reset';\n\n/** The basic information contained in each [[`LogEntry`]]. */\nexport interface LogDetailBase {\n title: string;\n message?: string;\n}\n/** The [[`LogEntry`]] for a committed [[`EditorAction`]]. */\nexport interface CommitDetail extends LogDetailBase {\n kind: 'action';\n redo: EditV2;\n undo: EditV2;\n squash?: boolean;\n}\n/** A [[`LogEntry`]] for notifying the user. */\nexport interface InfoDetail extends LogDetailBase {\n kind: InfoEntryKind;\n cause?: LogEntry;\n}\n\nexport interface ResetDetail {\n kind: 'reset';\n}\n\nexport type LogDetail = InfoDetail | CommitDetail | ResetDetail;\nexport type LogEvent = CustomEvent<LogDetail>;\n\nexport interface IssueDetail extends LogDetailBase {\n validatorId: string;\n element?: Element;\n}\nexport type IssueEvent = CustomEvent<IssueDetail>;\n\n/** [[`LogEntry`]]s are timestamped upon being committed to the `history`. */\ninterface Timestamped {\n time: Date | null;\n}\n\nexport type CommitEntry = Timestamped & CommitDetail;\nexport type InfoEntry = Timestamped & InfoDetail;\n\nexport type LogEntry = InfoEntry | CommitEntry;\n\n\nexport function newLogEvent(\n detail: LogDetail,\n eventInitDict?: CustomEventInit<LogDetail>\n): LogEvent {\n return new CustomEvent<LogDetail>('log', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\nexport function newIssueEvent(\n detail: IssueDetail,\n eventInitDict?: CustomEventInit<IssueDetail>\n): IssueEvent {\n return new CustomEvent<IssueDetail>('issue', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { ...detail, ...eventInitDict?.detail },\n });\n}\n\ndeclare global {\n interface ElementEventMap {\n ['log']: LogEvent;\n ['issue']: IssueEvent;\n }\n }\n "]}
@@ -11,7 +11,11 @@ import '@material/mwc-list/mwc-list-item';
11
11
  import '@material/mwc-snackbar';
12
12
  import '../filtered-list.js';
13
13
  import { getFilterIcon, iconColors } from '../icons/icons.js';
14
- import { getLogText } from './history/get-log-text.js';
14
+ import { isComplexV2, newEditEventV2 } from '@openscd/core';
15
+ export const historyStateEvent = 'history-state';
16
+ function newHistoryStateEvent(state) {
17
+ return new CustomEvent(historyStateEvent, { detail: state });
18
+ }
15
19
  const icons = {
16
20
  info: 'info',
17
21
  warning: 'warning',
@@ -59,7 +63,35 @@ export function newEmptyIssuesEvent(pluginSrc, eventInitDict) {
59
63
  detail: { pluginSrc, ...eventInitDict?.detail },
60
64
  });
61
65
  }
66
+ export function newUndoEvent() {
67
+ return new CustomEvent('undo', { bubbles: true, composed: true });
68
+ }
69
+ export function newRedoEvent() {
70
+ return new CustomEvent('redo', { bubbles: true, composed: true });
71
+ }
62
72
  let OscdHistory = class OscdHistory extends LitElement {
73
+ get canUndo() {
74
+ return this.editCount >= 0;
75
+ }
76
+ get canRedo() {
77
+ return this.nextAction >= 0;
78
+ }
79
+ get previousAction() {
80
+ if (!this.canUndo)
81
+ return -1;
82
+ return this.history
83
+ .slice(0, this.editCount)
84
+ .map(entry => (entry.kind == 'action' ? true : false))
85
+ .lastIndexOf(true);
86
+ }
87
+ get nextAction() {
88
+ let index = this.history
89
+ .slice(this.editCount + 1)
90
+ .findIndex(entry => entry.kind == 'action');
91
+ if (index >= 0)
92
+ index += this.editCount + 1;
93
+ return index;
94
+ }
63
95
  onIssue(de) {
64
96
  const issues = this.diagnoses.get(de.detail.validatorId);
65
97
  if (!issues)
@@ -71,15 +103,82 @@ let OscdHistory = class OscdHistory extends LitElement {
71
103
  this.issueUI.show();
72
104
  }
73
105
  undo() {
74
- this.editor.undo();
106
+ if (!this.canUndo)
107
+ return false;
108
+ const undoEdit = this.history[this.editCount].undo;
109
+ this.host.dispatchEvent(newEditEventV2(undoEdit, { createHistoryEntry: false }));
110
+ this.setEditCount(this.previousAction);
111
+ return true;
75
112
  }
76
113
  redo() {
77
- this.editor.redo();
114
+ if (!this.canRedo)
115
+ return false;
116
+ const redoEdit = this.history[this.nextAction].redo;
117
+ this.host.dispatchEvent(newEditEventV2(redoEdit, { createHistoryEntry: false }));
118
+ this.setEditCount(this.nextAction);
119
+ return true;
120
+ }
121
+ onHistory(detail) {
122
+ const entry = {
123
+ time: new Date(),
124
+ ...detail,
125
+ };
126
+ if (this.nextAction !== -1) {
127
+ this.history.splice(this.nextAction);
128
+ }
129
+ this.addHistoryEntry(entry);
130
+ this.setEditCount(this.history.length - 1);
131
+ this.requestUpdate('history', []);
132
+ }
133
+ addHistoryEntry(entry) {
134
+ const shouldSquash = Boolean(entry.squash) && this.history.length > 0;
135
+ if (shouldSquash) {
136
+ const previousEntry = this.history.pop();
137
+ const squashedEntry = this.squashHistoryEntries(entry, previousEntry);
138
+ this.history.push(squashedEntry);
139
+ }
140
+ else {
141
+ this.history.push(entry);
142
+ }
143
+ }
144
+ squashHistoryEntries(current, previous) {
145
+ const undo = this.squashUndo(current.undo, previous.undo);
146
+ const redo = this.squashRedo(current.redo, previous.redo);
147
+ return {
148
+ ...current,
149
+ undo,
150
+ redo,
151
+ };
152
+ }
153
+ squashUndo(current, previous) {
154
+ const isCurrentComplex = isComplexV2(current);
155
+ const isPreviousComplex = isComplexV2(previous);
156
+ const previousUndos = (isPreviousComplex ? previous : [previous]);
157
+ const currentUndos = (isCurrentComplex ? current : [current]);
158
+ return [...currentUndos, ...previousUndos];
159
+ }
160
+ squashRedo(current, previous) {
161
+ const isCurrentComplex = isComplexV2(current);
162
+ const isPreviousComplex = isComplexV2(previous);
163
+ const previousRedos = (isPreviousComplex ? previous : [previous]);
164
+ const currentRedos = (isCurrentComplex ? current : [current]);
165
+ return [...previousRedos, ...currentRedos];
78
166
  }
79
167
  onReset() {
80
168
  this.log = [];
81
- this.editor.reset();
82
- this.updateHistory();
169
+ this.history = [];
170
+ this.setEditCount(-1);
171
+ }
172
+ setEditCount(count) {
173
+ this.editCount = count;
174
+ this.dispatchHistoryStateEvent();
175
+ }
176
+ dispatchHistoryStateEvent() {
177
+ this.host.dispatchEvent(newHistoryStateEvent({
178
+ editCount: this.editCount,
179
+ canUndo: this.canUndo,
180
+ canRedo: this.canRedo,
181
+ }));
83
182
  }
84
183
  onInfo(detail) {
85
184
  const entry = {
@@ -108,7 +207,7 @@ let OscdHistory = class OscdHistory extends LitElement {
108
207
  this.onReset();
109
208
  break;
110
209
  case 'action':
111
- // No longer needed
210
+ this.onHistory(le.detail);
112
211
  break;
113
212
  default:
114
213
  this.onInfo(le.detail);
@@ -143,27 +242,15 @@ let OscdHistory = class OscdHistory extends LitElement {
143
242
  ? this.diagnosticUI.close()
144
243
  : this.diagnosticUI.show();
145
244
  }
146
- updateHistory() {
147
- const { past, future } = this.editor;
148
- const activeIndex = past.length - 1;
149
- const allEntries = [...past, ...future];
150
- this.history = allEntries.map((e, index) => {
151
- const { title, message } = getLogText(e.redo);
152
- return {
153
- isActive: index === activeIndex,
154
- time: e.time,
155
- title: e.title ?? title,
156
- message
157
- };
158
- });
159
- }
160
245
  constructor() {
161
246
  super();
162
247
  /** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */
163
248
  this.log = [];
164
- this.diagnoses = new Map();
249
+ /** All [[`CommitEntry`]]s received so far through [[`LogEvent`]]s */
165
250
  this.history = [];
166
- this.unsubscribers = [];
251
+ /** Index of the last [[`EditorAction`]] applied. */
252
+ this.editCount = -1;
253
+ this.diagnoses = new Map();
167
254
  this.undo = this.undo.bind(this);
168
255
  this.redo = this.redo.bind(this);
169
256
  this.onLog = this.onLog.bind(this);
@@ -171,26 +258,26 @@ let OscdHistory = class OscdHistory extends LitElement {
171
258
  this.historyUIHandler = this.historyUIHandler.bind(this);
172
259
  this.emptyIssuesHandler = this.emptyIssuesHandler.bind(this);
173
260
  this.handleKeyPress = this.handleKeyPress.bind(this);
261
+ this.dispatchHistoryStateEvent = this.dispatchHistoryStateEvent.bind(this);
174
262
  document.onkeydown = this.handleKeyPress;
175
263
  }
176
264
  connectedCallback() {
177
265
  super.connectedCallback();
178
- this.unsubscribers.push(this.editor.subscribe(e => this.updateHistory()), this.editor.subscribeUndoRedo(e => this.updateHistory()));
179
266
  this.host.addEventListener('log', this.onLog);
180
267
  this.host.addEventListener('issue', this.onIssue);
181
268
  this.host.addEventListener('history-dialog-ui', this.historyUIHandler);
182
269
  this.host.addEventListener('empty-issues', this.emptyIssuesHandler);
270
+ this.host.addEventListener('undo', this.undo);
271
+ this.host.addEventListener('redo', this.redo);
183
272
  this.diagnoses.clear();
184
273
  }
185
- disconnectedCallback() {
186
- this.unsubscribers.forEach(u => u());
187
- }
188
274
  renderLogEntry(entry, index, log) {
189
275
  return html ` <abbr title="${entry.title}">
190
276
  <mwc-list-item
191
277
  class="${entry.kind}"
192
278
  graphic="icon"
193
279
  ?twoline=${!!entry.message}
280
+ ?activated=${this.editCount == log.length - index - 1}
194
281
  >
195
282
  <span>
196
283
  <!-- FIXME: replace tt with mwc-chip asap -->
@@ -206,25 +293,27 @@ let OscdHistory = class OscdHistory extends LitElement {
206
293
  </mwc-list-item></abbr
207
294
  >`;
208
295
  }
209
- renderHistoryEntry(entry) {
296
+ renderHistoryEntry(entry, index, history) {
210
297
  return html ` <abbr title="${entry.title}">
211
298
  <mwc-list-item
299
+ class="${entry.kind}"
300
+ graphic="icon"
212
301
  ?twoline=${!!entry.message}
213
- ?activated=${entry.isActive}
302
+ ?activated=${this.editCount == history.length - index - 1}
214
303
  >
215
304
  <span>
216
- <tt>${this.formatTime(entry.time)}</tt>
217
- ${entry.title}
218
- </span>
305
+ <!-- FIXME: replace tt with mwc-chip asap -->
306
+ <tt>${entry.time?.toLocaleString()}</tt>
307
+ ${entry.title}</span
308
+ >
219
309
  <span slot="secondary">${entry.message}</span>
220
- </mwc-list-item>
221
- </abbr>`;
222
- }
223
- formatTime(time) {
224
- const date = new Date(time);
225
- const hours = date.getHours();
226
- const minutes = date.getMinutes();
227
- return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
310
+ <mwc-icon
311
+ slot="graphic"
312
+ style="--mdc-theme-text-icon-on-background:var(${iconColors[entry.kind]})"
313
+ >history</mwc-icon
314
+ >
315
+ </mwc-list-item></abbr
316
+ >`;
228
317
  }
229
318
  renderLog() {
230
319
  if (this.log.length > 0)
@@ -237,7 +326,7 @@ let OscdHistory = class OscdHistory extends LitElement {
237
326
  }
238
327
  renderHistory() {
239
328
  if (this.history.length > 0)
240
- return this.history.slice().reverse().map(e => this.renderHistoryEntry(e));
329
+ return this.history.slice().reverse().map(this.renderHistoryEntry, this);
241
330
  else
242
331
  return html `<mwc-list-item disabled graphic="icon">
243
332
  <span>${get('history.placeholder')}</span>
@@ -298,14 +387,14 @@ let OscdHistory = class OscdHistory extends LitElement {
298
387
  <mwc-button
299
388
  icon="undo"
300
389
  label="${get('undo')}"
301
- ?disabled=${!this.editor.canUndo}
390
+ ?disabled=${!this.canUndo}
302
391
  @click=${this.undo}
303
392
  slot="secondaryAction"
304
393
  ></mwc-button>
305
394
  <mwc-button
306
395
  icon="redo"
307
396
  label="${get('redo')}"
308
- ?disabled=${!this.editor.canRedo}
397
+ ?disabled=${!this.canRedo}
309
398
  @click=${this.redo}
310
399
  slot="secondaryAction"
311
400
  ></mwc-button>
@@ -448,20 +537,22 @@ __decorate([
448
537
  property({ type: Array })
449
538
  ], OscdHistory.prototype, "log", void 0);
450
539
  __decorate([
451
- property({ type: Object })
452
- ], OscdHistory.prototype, "editor", void 0);
540
+ property({ type: Array })
541
+ ], OscdHistory.prototype, "history", void 0);
542
+ __decorate([
543
+ property({ type: Number })
544
+ ], OscdHistory.prototype, "editCount", void 0);
453
545
  __decorate([
454
546
  property()
455
547
  ], OscdHistory.prototype, "diagnoses", void 0);
456
548
  __decorate([
457
- property({ type: Object })
549
+ property({
550
+ type: Object,
551
+ })
458
552
  ], OscdHistory.prototype, "host", void 0);
459
553
  __decorate([
460
554
  state()
461
555
  ], OscdHistory.prototype, "latestIssue", void 0);
462
- __decorate([
463
- state()
464
- ], OscdHistory.prototype, "history", void 0);
465
556
  __decorate([
466
557
  query('#log')
467
558
  ], OscdHistory.prototype, "logUI", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"History.js","sourceRoot":"","sources":["../../../../src/addons/History.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EAEL,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,2BAA2B,CAAC;AACnC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,wBAAwB,CAAC;AAIhC,OAAO,qBAAqB,CAAC;AAY7B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAK9D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AASvD,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,SAAS,aAAa,CAAC,GAAW;IAEhC,IAAI,mBAAmB,GAAG,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAG,CAAC,mBAAmB,EAAE;QACvB,mBAAmB,GAAG,IAAI,CAAC;KAC5B;IAED,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAa,CAAC;IAClE,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC;IAEtE,IAAG,CAAC,YAAY,EAAE;QAChB,OAAO,mBAAmB,GAAG,OAAO,mBAAmB,EAAE,CAAC;KAC3D;IAED,MAAM,IAAI,GAAG,YAA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EAAE,MAAM,EAAE,CAAC;yCACR;AAGnB;IADC,KAAK,EAAE;gDACkB;AAG1B;IADC,KAAK,EAAE;4CACoB;AAEb;IAAd,KAAK,CAAC,MAAM,CAAC;0CAAgB;AACX;IAAlB,KAAK,CAAC,UAAU,CAAC;8CAAoB;AAChB;IAArB,KAAK,CAAC,aAAa,CAAC;iDAAuB;AAC3B;IAAhB,KAAK,CAAC,QAAQ,CAAC;4CAAoB;AACjB;IAAlB,KAAK,CAAC,UAAU,CAAC;8CAAsB;AACxB;IAAf,KAAK,CAAC,OAAO,CAAC;2CAAmB;AACjB;IAAhB,KAAK,CAAC,QAAQ,CAAC;4CAAoB;AA1BzB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAmcvB;SAncY,WAAW","sourcesContent":["import {\n html,\n state,\n property,\n query,\n TemplateResult,\n customElement,\n LitElement,\n} from 'lit-element';\n\nimport { get } from 'lit-translate';\n\nimport '@material/mwc-button';\nimport '@material/mwc-dialog';\nimport '@material/mwc-icon';\nimport '@material/mwc-icon-button';\nimport '@material/mwc-icon-button-toggle';\nimport '@material/mwc-list';\nimport '@material/mwc-list/mwc-list-item';\nimport '@material/mwc-snackbar';\nimport { Dialog } from '@material/mwc-dialog';\nimport { Snackbar } from '@material/mwc-snackbar';\n\nimport '../filtered-list.js';\n\nimport {\n InfoDetail,\n InfoEntry,\n IssueDetail,\n IssueEvent,\n LogEntry,\n LogEntryType,\n LogEvent,\n} from '@openscd/core/foundation/deprecated/history.js';\n\nimport { getFilterIcon, iconColors } from '../icons/icons.js';\n\nimport { Plugin } from '../plugin.js';\nimport { XMLEditor } from '@openscd/core';\n\nimport { getLogText } from './history/get-log-text.js';\n\ninterface HistoryItem {\n title: string;\n message?: string;\n time: number;\n isActive: boolean;\n}\n\nconst icons = {\n info: 'info',\n warning: 'warning',\n error: 'report',\n};\n\nfunction getPluginName(src: string): string {\n\n let storedPluginsString = localStorage.getItem('plugins');\n if(!storedPluginsString) {\n storedPluginsString = '[]';\n }\n\n const storedPlugins = JSON.parse(storedPluginsString) as Plugin[];\n const wantedPlugin = storedPlugins.find((p: Plugin) => p.src === src);\n\n if(!wantedPlugin) {\n return `pluginnotfound: ${src} in ${storedPluginsString}`;\n }\n\n const name = wantedPlugin.name;\n\n if(!name){\n return `pluginhasnoname:${src}`;\n }\n\n return name;\n\n}\n\nexport enum HistoryUIKind {\n log = 'log',\n history = 'history',\n diagnostic = 'diagnostic',\n}\nexport interface HistoryUIDetail {\n show: boolean;\n kind: HistoryUIKind;\n}\n\nexport type HistoryUIEvent = CustomEvent<HistoryUIDetail>;\n\nexport function newHistoryUIEvent(\n show: boolean,\n kind: HistoryUIKind,\n eventInitDict?: CustomEventInit<Partial<HistoryUIDetail>>\n): HistoryUIEvent {\n return new CustomEvent<HistoryUIDetail>('history-dialog-ui', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: {\n show,\n kind,\n ...eventInitDict?.detail,\n },\n });\n}\n\nexport interface EmptyIssuesDetail {\n pluginSrc: string;\n}\n\nexport type EmptyIssuesEvent = CustomEvent<EmptyIssuesDetail>;\n\nexport function newEmptyIssuesEvent(\n pluginSrc: string,\n eventInitDict?: CustomEventInit<Partial<EmptyIssuesDetail>>\n): EmptyIssuesEvent {\n return new CustomEvent<EmptyIssuesDetail>('empty-issues', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { pluginSrc, ...eventInitDict?.detail },\n });\n}\n\n@customElement('oscd-history')\nexport class OscdHistory extends LitElement {\n /** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */\n @property({ type: Array })\n log: InfoEntry[] = [];\n\n /** XML Editor to apply changes to the scd */\n @property({ type: Object }) editor!: XMLEditor;\n\n @property()\n diagnoses = new Map<string, IssueDetail[]>();\n\n @property({ type: Object })\n host!: HTMLElement;\n\n @state()\n latestIssue!: IssueDetail;\n\n @state()\n history: HistoryItem[] = [];\n\n @query('#log') logUI!: Dialog;\n @query('#history') historyUI!: Dialog;\n @query('#diagnostic') diagnosticUI!: Dialog;\n @query('#error') errorUI!: Snackbar;\n @query('#warning') warningUI!: Snackbar;\n @query('#info') infoUI!: Snackbar;\n @query('#issue') issueUI!: Snackbar;\n\n private unsubscribers: (() => any)[] = [];\n\n private onIssue(de: IssueEvent): void {\n const issues = this.diagnoses.get(de.detail.validatorId);\n\n if (!issues) this.diagnoses.set(de.detail.validatorId, [de.detail]);\n else issues?.push(de.detail);\n\n this.latestIssue = de.detail;\n this.issueUI.close();\n this.issueUI.show();\n }\n\n undo(): void {\n this.editor.undo();\n }\n redo(): void {\n this.editor.redo();\n }\n\n private onReset() {\n this.log = [];\n this.editor.reset();\n this.updateHistory();\n }\n\n private onInfo(detail: InfoDetail) {\n const entry: InfoEntry = {\n time: new Date(),\n ...detail,\n };\n\n this.log.push(entry);\n if (!this.logUI.open) {\n const ui = {\n error: this.errorUI,\n warning: this.warningUI,\n info: this.infoUI,\n }[detail.kind];\n\n ui.close();\n ui.show();\n }\n if (detail.kind == 'error') {\n this.errorUI.close(); // hack to reset timeout\n this.errorUI.show();\n }\n this.requestUpdate('log', []);\n }\n\n private onLog(le: LogEvent): void {\n switch (le.detail.kind) {\n case 'reset':\n this.onReset();\n break;\n case 'action':\n // No longer needed\n break;\n default:\n this.onInfo(le.detail);\n break;\n }\n }\n\n private historyUIHandler(e: HistoryUIEvent): void {\n const ui = {\n log: this.logUI,\n history: this.historyUI,\n diagnostic: this.diagnosticUI,\n }[e.detail.kind];\n\n if (e.detail.show) ui.show();\n else ui.close();\n }\n\n private emptyIssuesHandler(e: EmptyIssuesEvent): void {\n if (this.diagnoses.get(e.detail.pluginSrc))\n this.diagnoses.get(e.detail.pluginSrc)!.length = 0;\n }\n\n private handleKeyPress(e: KeyboardEvent): void {\n const ctrlAnd = (key: string) => e.key === key && e.ctrlKey;\n\n if (ctrlAnd('y')) this.redo();\n if (ctrlAnd('z')) this.undo();\n if (ctrlAnd('l')) this.logUI.open ? this.logUI.close() : this.logUI.show();\n if (ctrlAnd('d'))\n this.diagnosticUI.open\n ? this.diagnosticUI.close()\n : this.diagnosticUI.show();\n }\n\n private updateHistory(): void {\n const { past, future } = this.editor;\n\n const activeIndex = past.length - 1;\n const allEntries = [ ...past, ...future ];\n\n this.history = allEntries.map((e, index) => {\n const { title, message } = getLogText(e.redo as any);\n\n return {\n isActive: index === activeIndex,\n time: e.time,\n title: e.title ?? title,\n message\n };\n });\n }\n\n constructor() {\n super();\n this.undo = this.undo.bind(this);\n this.redo = this.redo.bind(this);\n this.onLog = this.onLog.bind(this);\n this.onIssue = this.onIssue.bind(this);\n this.historyUIHandler = this.historyUIHandler.bind(this);\n this.emptyIssuesHandler = this.emptyIssuesHandler.bind(this);\n this.handleKeyPress = this.handleKeyPress.bind(this);\n document.onkeydown = this.handleKeyPress;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n this.unsubscribers.push(\n this.editor.subscribe(e => this.updateHistory()),\n this.editor.subscribeUndoRedo(e => this.updateHistory())\n );\n\n this.host.addEventListener('log', this.onLog);\n this.host.addEventListener('issue', this.onIssue);\n this.host.addEventListener('history-dialog-ui', this.historyUIHandler);\n this.host.addEventListener('empty-issues', this.emptyIssuesHandler);\n this.diagnoses.clear();\n }\n\n disconnectedCallback(): void {\n this.unsubscribers.forEach(u => u());\n }\n\n renderLogEntry(\n entry: InfoEntry,\n index: number,\n log: LogEntry[]\n ): TemplateResult {\n return html` <abbr title=\"${entry.title}\">\n <mwc-list-item\n class=\"${entry.kind}\"\n graphic=\"icon\"\n ?twoline=${!!entry.message}\n >\n <span>\n <!-- FIXME: replace tt with mwc-chip asap -->\n <tt>${entry.time?.toLocaleString()}</tt>\n ${entry.title}</span\n >\n <span slot=\"secondary\">${entry.message}</span>\n <mwc-icon\n slot=\"graphic\"\n style=\"--mdc-theme-text-icon-on-background:var(${iconColors[\n entry.kind\n ]})\"\n >${icons[entry.kind]}</mwc-icon\n >\n </mwc-list-item></abbr\n >`;\n }\n\n renderHistoryEntry(\n entry: HistoryItem\n ): TemplateResult {\n return html` <abbr title=\"${entry.title}\">\n <mwc-list-item\n ?twoline=${!!entry.message}\n ?activated=${entry.isActive}\n >\n <span>\n <tt>${this.formatTime(entry.time)}</tt>\n ${entry.title}\n </span>\n <span slot=\"secondary\">${entry.message}</span>\n </mwc-list-item>\n </abbr>`;\n }\n\n private formatTime(time: number): string {\n const date = new Date(time);\n const hours = date.getHours();\n const minutes = date.getMinutes();\n return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`\n }\n\n private renderLog(): TemplateResult[] | TemplateResult {\n if (this.log.length > 0)\n return this.log.slice().reverse().map(this.renderLogEntry, this);\n else\n return html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('log.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n private renderHistory(): TemplateResult[] | TemplateResult {\n if (this.history.length > 0)\n return this.history.slice().reverse().map(e => this.renderHistoryEntry(e));\n else\n return html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('history.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n private renderIssueEntry(issue: IssueDetail): TemplateResult {\n return html` <abbr title=\"${issue.title + '\\n' + issue.message}\"\n ><mwc-list-item ?twoline=${!!issue.message}>\n <span> ${issue.title}</span>\n <span slot=\"secondary\">${issue.message}</span>\n </mwc-list-item></abbr\n >`;\n }\n\n renderValidatorsIssues(issues: IssueDetail[]): TemplateResult[] {\n if (issues.length === 0) return [html``];\n return [\n html`\n <mwc-list-item noninteractive>\n ${getPluginName(issues[0].validatorId)}\n </mwc-list-item>\n `,\n html`<li divider padded role=\"separator\"></li>`,\n ...issues.map(issue => this.renderIssueEntry(issue)),\n ];\n }\n\n private renderIssues(): TemplateResult[] | TemplateResult {\n const issueItems: TemplateResult[] = [];\n\n this.diagnoses.forEach(issues => {\n this.renderValidatorsIssues(issues).forEach(issueItem =>\n issueItems.push(issueItem)\n );\n });\n\n return issueItems.length\n ? issueItems\n : html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('diag.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n private renderFilterButtons() {\n return (<LogEntryType[]>Object.keys(icons)).map(\n kind => html`<mwc-icon-button-toggle id=\"${kind}filter\" on\n >${getFilterIcon(kind, false)}\n ${getFilterIcon(kind, true)}</mwc-icon-button-toggle\n >`\n );\n }\n\n private renderLogDialog(): TemplateResult {\n return html` <mwc-dialog id=\"log\" heading=\"${get('log.name')}\">\n ${this.renderFilterButtons()}\n <mwc-list id=\"content\" wrapFocus>${this.renderLog()}</mwc-list>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\"\n >${get('close')}</mwc-button\n >\n </mwc-dialog>`;\n }\n\n private renderHistoryUI(): TemplateResult {\n return html` <mwc-dialog id=\"history\" heading=\"${get('history.name')}\">\n <mwc-list id=\"content\" wrapFocus>${this.renderHistory()}</mwc-list>\n <mwc-button\n icon=\"undo\"\n label=\"${get('undo')}\"\n ?disabled=${!this.editor.canUndo}\n @click=${this.undo}\n slot=\"secondaryAction\"\n ></mwc-button>\n <mwc-button\n icon=\"redo\"\n label=\"${get('redo')}\"\n ?disabled=${!this.editor.canRedo}\n @click=${this.redo}\n slot=\"secondaryAction\"\n ></mwc-button>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\"\n >${get('close')}</mwc-button\n >\n </mwc-dialog>`;\n }\n\n render(): TemplateResult {\n return html`<slot></slot>\n <style>\n #log > mwc-icon-button-toggle {\n position: absolute;\n top: 8px;\n right: 14px;\n }\n #log > mwc-icon-button-toggle:nth-child(2) {\n right: 62px;\n }\n #log > mwc-icon-button-toggle:nth-child(3) {\n right: 110px;\n }\n #log > mwc-icon-button-toggle:nth-child(4) {\n right: 158px;\n }\n #content mwc-list-item.info,\n #content mwc-list-item.warning,\n #content mwc-list-item.error {\n display: none;\n }\n #infofilter[on] ~ #content mwc-list-item.info {\n display: flex;\n }\n #warningfilter[on] ~ #content mwc-list-item.warning {\n display: flex;\n }\n #errorfilter[on] ~ #content mwc-list-item.error {\n display: flex;\n }\n\n #infofilter[on] {\n color: var(--cyan);\n }\n\n #warningfilter[on] {\n color: var(--yellow);\n }\n\n #errorfilter[on] {\n color: var(--red);\n }\n\n #actionfilter[on] {\n color: var(--blue);\n }\n\n #log,\n #history {\n --mdc-dialog-min-width: 92vw;\n }\n\n #log > #filterContainer {\n position: absolute;\n top: 14px;\n right: 14px;\n }\n </style>\n ${this.renderLogDialog()} ${this.renderHistoryUI()}\n <mwc-dialog id=\"diagnostic\" heading=\"${get('diag.name')}\">\n <filtered-list id=\"content\" wrapFocus>\n ${this.renderIssues()}\n </filtered-list>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\">\n ${get('close')}\n </mwc-button>\n </mwc-dialog>\n\n <mwc-snackbar\n id=\"info\"\n timeoutMs=\"4000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'info')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"warning\"\n timeoutMs=\"6000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'warning')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"history\"\n @click=${() => this.logUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"error\"\n timeoutMs=\"10000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'error')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"history\"\n @click=${() => this.logUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"issue\"\n timeoutMs=\"10000\"\n labelText=\"${this.latestIssue?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"rule\"\n @click=${() => this.diagnosticUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>`;\n }\n}\n\ndeclare global {\n interface ElementEventMap {\n 'history-dialog-ui': CustomEvent<HistoryUIDetail>;\n 'empty-issues': CustomEvent<EmptyIssuesDetail>;\n }\n}\n"]}
1
+ {"version":3,"file":"History.js","sourceRoot":"","sources":["../../../../src/addons/History.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EAEL,aAAa,EACb,UAAU,GACX,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,2BAA2B,CAAC;AACnC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,wBAAwB,CAAC;AAIhC,OAAO,qBAAqB,CAAC;AAc7B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG9D,OAAO,EAAU,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpE,MAAM,CAAC,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAQjD,SAAS,oBAAoB,CAAC,KAAmB;IAC/C,OAAO,IAAI,WAAW,CAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AAC/D,CAAC;AAQD,MAAM,KAAK,GAAG;IACZ,IAAI,EAAE,MAAM;IAC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IACrB,CAAC;CACF,CAAA;AA1iBC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;wCACJ;AAItB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;4CACE;AAI5B;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CACZ;AAGf;IADC,QAAQ,EAAE;8CACkC;AAK7C;IAHC,QAAQ,CAAC;QACR,IAAI,EAAE,MAAM;KACb,CAAC;yCACiB;AAGnB;IADC,KAAK,EAAE;gDACkB;AAEX;IAAd,KAAK,CAAC,MAAM,CAAC;0CAAgB;AACX;IAAlB,KAAK,CAAC,UAAU,CAAC;8CAAoB;AAChB;IAArB,KAAK,CAAC,aAAa,CAAC;iDAAuB;AAC3B;IAAhB,KAAK,CAAC,QAAQ,CAAC;4CAAoB;AACjB;IAAlB,KAAK,CAAC,UAAU,CAAC;8CAAsB;AACxB;IAAf,KAAK,CAAC,OAAO,CAAC;2CAAmB;AACjB;IAAhB,KAAK,CAAC,QAAQ,CAAC;4CAAoB;AA9BzB,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA6iBvB;SA7iBY,WAAW","sourcesContent":["import {\n html,\n state,\n property,\n query,\n TemplateResult,\n customElement,\n LitElement,\n} from 'lit-element';\n\nimport { get } from 'lit-translate';\n\nimport '@material/mwc-button';\nimport '@material/mwc-dialog';\nimport '@material/mwc-icon';\nimport '@material/mwc-icon-button';\nimport '@material/mwc-icon-button-toggle';\nimport '@material/mwc-list';\nimport '@material/mwc-list/mwc-list-item';\nimport '@material/mwc-snackbar';\nimport { Dialog } from '@material/mwc-dialog';\nimport { Snackbar } from '@material/mwc-snackbar';\n\nimport '../filtered-list.js';\n\nimport {\n CommitDetail,\n CommitEntry,\n InfoDetail,\n InfoEntry,\n IssueDetail,\n IssueEvent,\n LogEntry,\n LogEntryType,\n LogEvent,\n} from '@openscd/core/foundation/deprecated/history.js';\n\nimport { getFilterIcon, iconColors } from '../icons/icons.js';\n\nimport { Plugin } from '../plugin.js';\nimport { EditV2, isComplexV2, newEditEventV2 } from '@openscd/core';\n\nexport const historyStateEvent = 'history-state';\nexport interface HistoryState {\n editCount: number;\n canUndo: boolean;\n canRedo: boolean;\n}\nexport type HistoryStateEvent = CustomEvent<HistoryState>;\n\nfunction newHistoryStateEvent(state: HistoryState): HistoryStateEvent {\n return new CustomEvent(historyStateEvent, { detail: state });\n}\n\ndeclare global {\n interface ElementEventMap {\n [historyStateEvent]: HistoryStateEvent;\n }\n}\n\nconst icons = {\n info: 'info',\n warning: 'warning',\n error: 'report',\n};\n\nfunction getPluginName(src: string): string {\n let storedPluginsString = localStorage.getItem('plugins');\n if (!storedPluginsString) {\n storedPluginsString = '[]';\n }\n\n const storedPlugins = JSON.parse(storedPluginsString) as Plugin[];\n const wantedPlugin = storedPlugins.find((p: Plugin) => p.src === src);\n\n if (!wantedPlugin) {\n return `pluginnotfound: ${src} in ${storedPluginsString}`;\n }\n\n const name = wantedPlugin.name;\n\n if (!name) {\n return `pluginhasnoname:${src}`;\n }\n\n return name;\n}\n\nexport enum HistoryUIKind {\n log = 'log',\n history = 'history',\n diagnostic = 'diagnostic',\n}\nexport interface HistoryUIDetail {\n show: boolean;\n kind: HistoryUIKind;\n}\n\nexport type HistoryUIEvent = CustomEvent<HistoryUIDetail>;\n\nexport function newHistoryUIEvent(\n show: boolean,\n kind: HistoryUIKind,\n eventInitDict?: CustomEventInit<Partial<HistoryUIDetail>>\n): HistoryUIEvent {\n return new CustomEvent<HistoryUIDetail>('history-dialog-ui', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: {\n show,\n kind,\n ...eventInitDict?.detail,\n },\n });\n}\n\nexport interface EmptyIssuesDetail {\n pluginSrc: string;\n}\n\nexport type EmptyIssuesEvent = CustomEvent<EmptyIssuesDetail>;\n\nexport function newEmptyIssuesEvent(\n pluginSrc: string,\n eventInitDict?: CustomEventInit<Partial<EmptyIssuesDetail>>\n): EmptyIssuesEvent {\n return new CustomEvent<EmptyIssuesDetail>('empty-issues', {\n bubbles: true,\n composed: true,\n ...eventInitDict,\n detail: { pluginSrc, ...eventInitDict?.detail },\n });\n}\n\nexport function newUndoEvent(): CustomEvent {\n return new CustomEvent('undo', { bubbles: true, composed: true });\n}\n\nexport function newRedoEvent(): CustomEvent {\n return new CustomEvent('redo', { bubbles: true, composed: true });\n}\n\n@customElement('oscd-history')\nexport class OscdHistory extends LitElement {\n /** All [[`LogEntry`]]s received so far through [[`LogEvent`]]s. */\n @property({ type: Array })\n log: InfoEntry[] = [];\n\n /** All [[`CommitEntry`]]s received so far through [[`LogEvent`]]s */\n @property({ type: Array })\n history: CommitEntry[] = [];\n\n /** Index of the last [[`EditorAction`]] applied. */\n @property({ type: Number })\n editCount = -1;\n\n @property()\n diagnoses = new Map<string, IssueDetail[]>();\n\n @property({\n type: Object,\n })\n host!: HTMLElement;\n\n @state()\n latestIssue!: IssueDetail;\n\n @query('#log') logUI!: Dialog;\n @query('#history') historyUI!: Dialog;\n @query('#diagnostic') diagnosticUI!: Dialog;\n @query('#error') errorUI!: Snackbar;\n @query('#warning') warningUI!: Snackbar;\n @query('#info') infoUI!: Snackbar;\n @query('#issue') issueUI!: Snackbar;\n\n get canUndo(): boolean {\n return this.editCount >= 0;\n }\n get canRedo(): boolean {\n return this.nextAction >= 0;\n }\n\n get previousAction(): number {\n if (!this.canUndo) return -1;\n return this.history\n .slice(0, this.editCount)\n .map(entry => (entry.kind == 'action' ? true : false))\n .lastIndexOf(true);\n }\n get nextAction(): number {\n let index = this.history\n .slice(this.editCount + 1)\n .findIndex(entry => entry.kind == 'action');\n if (index >= 0) index += this.editCount + 1;\n return index;\n }\n\n private onIssue(de: IssueEvent): void {\n const issues = this.diagnoses.get(de.detail.validatorId);\n\n if (!issues) this.diagnoses.set(de.detail.validatorId, [de.detail]);\n else issues?.push(de.detail);\n\n this.latestIssue = de.detail;\n this.issueUI.close();\n this.issueUI.show();\n }\n\n undo(): boolean {\n if (!this.canUndo) return false;\n\n const undoEdit = (<CommitEntry>this.history[this.editCount]).undo;\n this.host.dispatchEvent(\n newEditEventV2(undoEdit, { createHistoryEntry: false })\n );\n this.setEditCount(this.previousAction);\n\n return true;\n }\n redo(): boolean {\n if (!this.canRedo) return false;\n\n const redoEdit = (<CommitEntry>this.history[this.nextAction]).redo;\n this.host.dispatchEvent(\n newEditEventV2(redoEdit, { createHistoryEntry: false })\n );\n this.setEditCount(this.nextAction);\n\n return true;\n }\n\n private onHistory(detail: CommitDetail) {\n const entry: CommitEntry = {\n time: new Date(),\n ...detail,\n };\n\n if (this.nextAction !== -1) {\n this.history.splice(this.nextAction);\n }\n\n this.addHistoryEntry(entry);\n this.setEditCount(this.history.length - 1);\n this.requestUpdate('history', []);\n }\n\n private addHistoryEntry(entry: CommitEntry) {\n const shouldSquash = Boolean(entry.squash) && this.history.length > 0;\n\n if (shouldSquash) {\n const previousEntry = this.history.pop() as CommitEntry;\n const squashedEntry = this.squashHistoryEntries(entry, previousEntry);\n this.history.push(squashedEntry);\n } else {\n this.history.push(entry);\n }\n }\n\n private squashHistoryEntries(\n current: CommitEntry,\n previous: CommitEntry\n ): CommitEntry {\n const undo = this.squashUndo(current.undo, previous.undo);\n const redo = this.squashRedo(current.redo, previous.redo);\n\n return {\n ...current,\n undo,\n redo,\n };\n }\n\n private squashUndo(current: EditV2, previous: EditV2): EditV2 {\n const isCurrentComplex = isComplexV2(current);\n const isPreviousComplex = isComplexV2(previous);\n\n const previousUndos: EditV2[] = (\n isPreviousComplex ? previous : [previous]\n ) as EditV2[];\n const currentUndos: EditV2[] = (\n isCurrentComplex ? current : [current]\n ) as EditV2[];\n\n return [...currentUndos, ...previousUndos];\n }\n\n private squashRedo(current: EditV2, previous: EditV2): EditV2 {\n const isCurrentComplex = isComplexV2(current);\n const isPreviousComplex = isComplexV2(previous);\n\n const previousRedos: EditV2[] = (\n isPreviousComplex ? previous : [previous]\n ) as EditV2[];\n const currentRedos: EditV2[] = (\n isCurrentComplex ? current : [current]\n ) as EditV2[];\n\n return [...previousRedos, ...currentRedos];\n }\n\n private onReset() {\n this.log = [];\n this.history = [];\n this.setEditCount(-1);\n }\n\n private setEditCount(count: number): void {\n this.editCount = count;\n this.dispatchHistoryStateEvent();\n }\n\n private dispatchHistoryStateEvent(): void {\n this.host.dispatchEvent(\n newHistoryStateEvent({\n editCount: this.editCount,\n canUndo: this.canUndo,\n canRedo: this.canRedo,\n })\n );\n }\n\n private onInfo(detail: InfoDetail) {\n const entry: InfoEntry = {\n time: new Date(),\n ...detail,\n };\n\n this.log.push(entry);\n if (!this.logUI.open) {\n const ui = {\n error: this.errorUI,\n warning: this.warningUI,\n info: this.infoUI,\n }[detail.kind];\n\n ui.close();\n ui.show();\n }\n if (detail.kind == 'error') {\n this.errorUI.close(); // hack to reset timeout\n this.errorUI.show();\n }\n this.requestUpdate('log', []);\n }\n\n private onLog(le: LogEvent): void {\n switch (le.detail.kind) {\n case 'reset':\n this.onReset();\n break;\n case 'action':\n this.onHistory(le.detail);\n break;\n default:\n this.onInfo(le.detail);\n break;\n }\n }\n\n private historyUIHandler(e: HistoryUIEvent): void {\n const ui = {\n log: this.logUI,\n history: this.historyUI,\n diagnostic: this.diagnosticUI,\n }[e.detail.kind];\n\n if (e.detail.show) ui.show();\n else ui.close();\n }\n\n private emptyIssuesHandler(e: EmptyIssuesEvent): void {\n if (this.diagnoses.get(e.detail.pluginSrc))\n this.diagnoses.get(e.detail.pluginSrc)!.length = 0;\n }\n\n private handleKeyPress(e: KeyboardEvent): void {\n const ctrlAnd = (key: string) => e.key === key && e.ctrlKey;\n\n if (ctrlAnd('y')) this.redo();\n if (ctrlAnd('z')) this.undo();\n if (ctrlAnd('l')) this.logUI.open ? this.logUI.close() : this.logUI.show();\n if (ctrlAnd('d'))\n this.diagnosticUI.open\n ? this.diagnosticUI.close()\n : this.diagnosticUI.show();\n }\n\n constructor() {\n super();\n this.undo = this.undo.bind(this);\n this.redo = this.redo.bind(this);\n this.onLog = this.onLog.bind(this);\n this.onIssue = this.onIssue.bind(this);\n this.historyUIHandler = this.historyUIHandler.bind(this);\n this.emptyIssuesHandler = this.emptyIssuesHandler.bind(this);\n this.handleKeyPress = this.handleKeyPress.bind(this);\n this.dispatchHistoryStateEvent = this.dispatchHistoryStateEvent.bind(this);\n document.onkeydown = this.handleKeyPress;\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n\n this.host.addEventListener('log', this.onLog);\n this.host.addEventListener('issue', this.onIssue);\n this.host.addEventListener('history-dialog-ui', this.historyUIHandler);\n this.host.addEventListener('empty-issues', this.emptyIssuesHandler);\n this.host.addEventListener('undo', this.undo);\n this.host.addEventListener('redo', this.redo);\n this.diagnoses.clear();\n }\n\n renderLogEntry(\n entry: InfoEntry,\n index: number,\n log: LogEntry[]\n ): TemplateResult {\n return html` <abbr title=\"${entry.title}\">\n <mwc-list-item\n class=\"${entry.kind}\"\n graphic=\"icon\"\n ?twoline=${!!entry.message}\n ?activated=${this.editCount == log.length - index - 1}\n >\n <span>\n <!-- FIXME: replace tt with mwc-chip asap -->\n <tt>${entry.time?.toLocaleString()}</tt>\n ${entry.title}</span\n >\n <span slot=\"secondary\">${entry.message}</span>\n <mwc-icon\n slot=\"graphic\"\n style=\"--mdc-theme-text-icon-on-background:var(${iconColors[\n entry.kind\n ]})\"\n >${icons[entry.kind]}</mwc-icon\n >\n </mwc-list-item></abbr\n >`;\n }\n\n renderHistoryEntry(\n entry: CommitEntry,\n index: number,\n history: LogEntry[]\n ): TemplateResult {\n return html` <abbr title=\"${entry.title}\">\n <mwc-list-item\n class=\"${entry.kind}\"\n graphic=\"icon\"\n ?twoline=${!!entry.message}\n ?activated=${this.editCount == history.length - index - 1}\n >\n <span>\n <!-- FIXME: replace tt with mwc-chip asap -->\n <tt>${entry.time?.toLocaleString()}</tt>\n ${entry.title}</span\n >\n <span slot=\"secondary\">${entry.message}</span>\n <mwc-icon\n slot=\"graphic\"\n style=\"--mdc-theme-text-icon-on-background:var(${iconColors[\n entry.kind\n ]})\"\n >history</mwc-icon\n >\n </mwc-list-item></abbr\n >`;\n }\n\n private renderLog(): TemplateResult[] | TemplateResult {\n if (this.log.length > 0)\n return this.log.slice().reverse().map(this.renderLogEntry, this);\n else\n return html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('log.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n private renderHistory(): TemplateResult[] | TemplateResult {\n if (this.history.length > 0)\n return this.history.slice().reverse().map(this.renderHistoryEntry, this);\n else\n return html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('history.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n protected renderIssueEntry(issue: IssueDetail): TemplateResult {\n return html` <abbr title=\"${issue.title + '\\n' + issue.message}\"\n ><mwc-list-item ?twoline=${!!issue.message}>\n <span> ${issue.title}</span>\n <span slot=\"secondary\">${issue.message}</span>\n </mwc-list-item></abbr\n >`;\n }\n\n renderValidatorsIssues(issues: IssueDetail[]): TemplateResult[] {\n if (issues.length === 0) return [html``];\n return [\n html`\n <mwc-list-item noninteractive>\n ${getPluginName(issues[0].validatorId)}\n </mwc-list-item>\n `,\n html`<li divider padded role=\"separator\"></li>`,\n ...issues.map(issue => this.renderIssueEntry(issue)),\n ];\n }\n\n private renderIssues(): TemplateResult[] | TemplateResult {\n const issueItems: TemplateResult[] = [];\n\n this.diagnoses.forEach(issues => {\n this.renderValidatorsIssues(issues).forEach(issueItem =>\n issueItems.push(issueItem)\n );\n });\n\n return issueItems.length\n ? issueItems\n : html`<mwc-list-item disabled graphic=\"icon\">\n <span>${get('diag.placeholder')}</span>\n <mwc-icon slot=\"graphic\">info</mwc-icon>\n </mwc-list-item>`;\n }\n\n private renderFilterButtons() {\n return (<LogEntryType[]>Object.keys(icons)).map(\n kind => html`<mwc-icon-button-toggle id=\"${kind}filter\" on\n >${getFilterIcon(kind, false)}\n ${getFilterIcon(kind, true)}</mwc-icon-button-toggle\n >`\n );\n }\n\n private renderLogDialog(): TemplateResult {\n return html` <mwc-dialog id=\"log\" heading=\"${get('log.name')}\">\n ${this.renderFilterButtons()}\n <mwc-list id=\"content\" wrapFocus>${this.renderLog()}</mwc-list>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\"\n >${get('close')}</mwc-button\n >\n </mwc-dialog>`;\n }\n\n private renderHistoryUI(): TemplateResult {\n return html` <mwc-dialog id=\"history\" heading=\"${get('history.name')}\">\n <mwc-list id=\"content\" wrapFocus>${this.renderHistory()}</mwc-list>\n <mwc-button\n icon=\"undo\"\n label=\"${get('undo')}\"\n ?disabled=${!this.canUndo}\n @click=${this.undo}\n slot=\"secondaryAction\"\n ></mwc-button>\n <mwc-button\n icon=\"redo\"\n label=\"${get('redo')}\"\n ?disabled=${!this.canRedo}\n @click=${this.redo}\n slot=\"secondaryAction\"\n ></mwc-button>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\"\n >${get('close')}</mwc-button\n >\n </mwc-dialog>`;\n }\n\n render(): TemplateResult {\n return html`<slot></slot>\n <style>\n #log > mwc-icon-button-toggle {\n position: absolute;\n top: 8px;\n right: 14px;\n }\n #log > mwc-icon-button-toggle:nth-child(2) {\n right: 62px;\n }\n #log > mwc-icon-button-toggle:nth-child(3) {\n right: 110px;\n }\n #log > mwc-icon-button-toggle:nth-child(4) {\n right: 158px;\n }\n #content mwc-list-item.info,\n #content mwc-list-item.warning,\n #content mwc-list-item.error {\n display: none;\n }\n #infofilter[on] ~ #content mwc-list-item.info {\n display: flex;\n }\n #warningfilter[on] ~ #content mwc-list-item.warning {\n display: flex;\n }\n #errorfilter[on] ~ #content mwc-list-item.error {\n display: flex;\n }\n\n #infofilter[on] {\n color: var(--cyan);\n }\n\n #warningfilter[on] {\n color: var(--yellow);\n }\n\n #errorfilter[on] {\n color: var(--red);\n }\n\n #actionfilter[on] {\n color: var(--blue);\n }\n\n #log,\n #history {\n --mdc-dialog-min-width: 92vw;\n }\n\n #log > #filterContainer {\n position: absolute;\n top: 14px;\n right: 14px;\n }\n </style>\n ${this.renderLogDialog()} ${this.renderHistoryUI()}\n <mwc-dialog id=\"diagnostic\" heading=\"${get('diag.name')}\">\n <filtered-list id=\"content\" wrapFocus>\n ${this.renderIssues()}\n </filtered-list>\n <mwc-button slot=\"primaryAction\" dialogaction=\"close\">\n ${get('close')}\n </mwc-button>\n </mwc-dialog>\n\n <mwc-snackbar\n id=\"info\"\n timeoutMs=\"4000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'info')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"warning\"\n timeoutMs=\"6000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'warning')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"history\"\n @click=${() => this.logUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"error\"\n timeoutMs=\"10000\"\n labelText=\"${this.log\n .slice()\n .reverse()\n .find(le => le.kind === 'error')?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"history\"\n @click=${() => this.logUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>\n <mwc-snackbar\n id=\"issue\"\n timeoutMs=\"10000\"\n labelText=\"${this.latestIssue?.title ??\n get('log.snackbar.placeholder')}\"\n >\n <mwc-button\n slot=\"action\"\n icon=\"rule\"\n @click=${() => this.diagnosticUI.show()}\n >${get('log.snackbar.show')}</mwc-button\n >\n <mwc-icon-button icon=\"close\" slot=\"dismiss\"></mwc-icon-button>\n </mwc-snackbar>`;\n }\n}\n\ndeclare global {\n interface ElementEventMap {\n 'history-dialog-ui': CustomEvent<HistoryUIDetail>;\n 'empty-issues': CustomEvent<EmptyIssuesDetail>;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@compas-oscd/open-scd",
3
- "version": "0.34.21",
3
+ "version": "0.34.22",
4
4
  "repository": "https://github.com/openscd/open-scd.git",
5
5
  "directory": "packages/openscd",
6
6
  "description": "A bottom-up substation configuration designer for projects described using SCL `IEC 61850-6` Edition 2 or greater.",