-
Notifications
You must be signed in to change notification settings - Fork 3
/
TransitionalView.ts
122 lines (96 loc) · 3.14 KB
/
TransitionalView.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import { Messenger } from "../Messenger";
import { WebviewToCoreMessageType } from "../../shared/messenger/messages";
import { TransitionalMetadata, TransitionalModelUID } from "../../shared/transitionals/types";
import { RawSourceFileRange } from "../../shared/source-files/types";
import { TransitionalViewContext } from "./TransitionalViewContext";
export abstract class TransitionalView {
abstract readonly transitionalName: string;
readonly context: TransitionalViewContext;
protected messenger: Messenger;
protected metadata: TransitionalMetadata;
protected contentNode: HTMLElement;
constructor(
contentNode: HTMLElement,
metadata: TransitionalMetadata,
context: TransitionalViewContext
) {
this.context = context;
this.messenger = context.messenger;
this.contentNode = contentNode;
this.metadata = metadata;
}
get name(): string {
return this.metadata.name;
}
get title(): string {
return this.metadata.name;
}
get modelUid(): TransitionalModelUID {
return this.metadata.uid;
}
get codeMappingId(): number {
return this.metadata.codeMappingId;
}
get sourceFileName(): string {
return this.metadata.fileName;
}
get sourceFileCodeRange(): RawSourceFileRange {
return this.metadata.codeRange;
}
get isAvailable(): boolean {
return this.metadata.available;
}
revealInSourceDocument(): void {
this.messenger.sendMessage({
type: WebviewToCoreMessageType.NotifyTransitionalModel,
transitionalUid: this.metadata.uid,
title: "reveal-code-in-editor",
notification: {}
});
}
onBeforeTransitionalDisplay(): void {
// Do nothing by default
}
onAfterTransitionalDisplay(): void {
this.messenger.sendMessage({
type: WebviewToCoreMessageType.NotifyTransitionalModel,
transitionalUid: this.metadata.uid,
title: "view-popup-did-open",
notification: {}
});
}
onBeforeTransitionalErrorDisplay(): void {
// Do nothing by default
};
onAfterTransitionalErrorDisplay(): void {
// Do nothing by default
};
onBeforeTransitionalErrorRemoval(): void {
// Do nothing by default
};
onAfterTransitionalErrorRemoval(): void {
// Do nothing by default
};
onBeforeTransitionalRemoval(): void {
// Do nothing by default
}
onAfterTransitionalRemoval(): void {
this.messenger.sendMessage({
type: WebviewToCoreMessageType.NotifyTransitionalModel,
transitionalUid: this.metadata.uid,
title: "view-popup-did-close",
notification: {}
});
}
onBeforePdfResize(): void {
// Do nothing by default
}
onAfterPdfResize(): void {
// Do nothing by default
};
abstract render(): HTMLElement;
abstract updateContentWith(newContentNode: HTMLElement): void;
updateMetadataWith(newMetadata: TransitionalMetadata): void {
this.metadata = newMetadata;
};
}