@covalent/markdown-navigator 4.0.0-alpha.0 → 4.0.0-beta.1
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.
- package/covalent-markdown-navigator.d.ts +1 -1
- package/esm2020/covalent-markdown-navigator.mjs +5 -0
- package/esm2020/index.mjs +2 -0
- package/esm2020/markdown-navigator-window/markdown-navigator-window.component.mjs +91 -0
- package/esm2020/markdown-navigator-window-directive/markdown-navigator-window.directive.mjs +34 -0
- package/esm2020/markdown-navigator-window-service/markdown-navigator-window.service.mjs +129 -0
- package/esm2020/markdown-navigator.component.mjs +587 -0
- package/esm2020/markdown-navigator.module.mjs +62 -0
- package/esm2020/public-api.mjs +6 -0
- package/fesm2015/covalent-markdown-navigator.mjs +968 -0
- package/fesm2015/covalent-markdown-navigator.mjs.map +1 -0
- package/fesm2020/covalent-markdown-navigator.mjs +889 -0
- package/fesm2020/covalent-markdown-navigator.mjs.map +1 -0
- package/markdown-navigator-window/markdown-navigator-window.component.d.ts +3 -0
- package/markdown-navigator-window/markdown-navigator-window.component.scss +1 -0
- package/markdown-navigator-window-directive/markdown-navigator-window.directive.d.ts +3 -0
- package/markdown-navigator-window-service/markdown-navigator-window.service.d.ts +3 -0
- package/markdown-navigator.component.d.ts +3 -0
- package/markdown-navigator.component.scss +5 -0
- package/markdown-navigator.module.d.ts +16 -0
- package/package.json +30 -15
- package/public-api.d.ts +1 -0
- package/bundles/covalent-markdown-navigator.umd.js +0 -1650
- package/bundles/covalent-markdown-navigator.umd.js.map +0 -1
- package/bundles/covalent-markdown-navigator.umd.min.js +0 -16
- package/bundles/covalent-markdown-navigator.umd.min.js.map +0 -1
- package/covalent-markdown-navigator.metadata.json +0 -1
- package/esm2015/covalent-markdown-navigator.js +0 -11
- package/esm2015/index.js +0 -7
- package/esm2015/markdown-navigator-window/markdown-navigator-window.component.js +0 -129
- package/esm2015/markdown-navigator-window-directive/markdown-navigator-window.directive.js +0 -50
- package/esm2015/markdown-navigator-window-service/markdown-navigator-window.service.js +0 -254
- package/esm2015/markdown-navigator.component.js +0 -698
- package/esm2015/markdown-navigator.module.js +0 -41
- package/esm2015/public-api.js +0 -10
- package/fesm2015/covalent-markdown-navigator.js +0 -1181
- package/fesm2015/covalent-markdown-navigator.js.map +0 -1
|
@@ -1,1181 +0,0 @@
|
|
|
1
|
-
import { EventEmitter, SecurityContext, Component, ChangeDetectionStrategy, ChangeDetectorRef, Input, Output, ViewChild, HostListener, Injectable, Inject, RendererFactory2, Directive, NgModule } from '@angular/core';
|
|
2
|
-
import { DOCUMENT, CommonModule } from '@angular/common';
|
|
3
|
-
import { __awaiter } from 'tslib';
|
|
4
|
-
import { removeLeadingHash, isAnchorLink, TdMarkdownLoaderService } from '@covalent/markdown';
|
|
5
|
-
import { DomSanitizer } from '@angular/platform-browser';
|
|
6
|
-
import { HttpClient } from '@angular/common/http';
|
|
7
|
-
import { MatButtonModule } from '@angular/material/button';
|
|
8
|
-
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
9
|
-
import { MatListModule } from '@angular/material/list';
|
|
10
|
-
import { MatIconModule } from '@angular/material/icon';
|
|
11
|
-
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
|
12
|
-
import { CovalentFlavoredMarkdownModule } from '@covalent/flavored-markdown';
|
|
13
|
-
import { ResizableDraggableDialog, TdDialogService, CovalentDialogsModule } from '@covalent/core/dialogs';
|
|
14
|
-
import { CovalentMessageModule } from '@covalent/core/message';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @fileoverview added by tsickle
|
|
18
|
-
* Generated from: markdown-navigator.component.ts
|
|
19
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* @record
|
|
23
|
-
*/
|
|
24
|
-
function IMarkdownNavigatorItem() { }
|
|
25
|
-
if (false) {
|
|
26
|
-
/** @type {?|undefined} */
|
|
27
|
-
IMarkdownNavigatorItem.prototype.id;
|
|
28
|
-
/** @type {?|undefined} */
|
|
29
|
-
IMarkdownNavigatorItem.prototype.title;
|
|
30
|
-
/** @type {?|undefined} */
|
|
31
|
-
IMarkdownNavigatorItem.prototype.url;
|
|
32
|
-
/** @type {?|undefined} */
|
|
33
|
-
IMarkdownNavigatorItem.prototype.httpOptions;
|
|
34
|
-
/** @type {?|undefined} */
|
|
35
|
-
IMarkdownNavigatorItem.prototype.markdownString;
|
|
36
|
-
/** @type {?|undefined} */
|
|
37
|
-
IMarkdownNavigatorItem.prototype.anchor;
|
|
38
|
-
/** @type {?|undefined} */
|
|
39
|
-
IMarkdownNavigatorItem.prototype.children;
|
|
40
|
-
/** @type {?|undefined} */
|
|
41
|
-
IMarkdownNavigatorItem.prototype.childrenUrl;
|
|
42
|
-
/** @type {?|undefined} */
|
|
43
|
-
IMarkdownNavigatorItem.prototype.description;
|
|
44
|
-
/** @type {?|undefined} */
|
|
45
|
-
IMarkdownNavigatorItem.prototype.icon;
|
|
46
|
-
/** @type {?|undefined} */
|
|
47
|
-
IMarkdownNavigatorItem.prototype.footer;
|
|
48
|
-
/** @type {?|undefined} */
|
|
49
|
-
IMarkdownNavigatorItem.prototype.startAtLink;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @record
|
|
53
|
-
*/
|
|
54
|
-
function IMarkdownNavigatorLabels() { }
|
|
55
|
-
if (false) {
|
|
56
|
-
/** @type {?|undefined} */
|
|
57
|
-
IMarkdownNavigatorLabels.prototype.goHome;
|
|
58
|
-
/** @type {?|undefined} */
|
|
59
|
-
IMarkdownNavigatorLabels.prototype.goBack;
|
|
60
|
-
/** @type {?|undefined} */
|
|
61
|
-
IMarkdownNavigatorLabels.prototype.emptyState;
|
|
62
|
-
}
|
|
63
|
-
/** @type {?} */
|
|
64
|
-
const DEFAULT_MARKDOWN_NAVIGATOR_LABELS = {
|
|
65
|
-
goHome: 'Go home',
|
|
66
|
-
goBack: 'Go back',
|
|
67
|
-
emptyState: 'No item(s) to display',
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* @param {?} url
|
|
71
|
-
* @return {?}
|
|
72
|
-
*/
|
|
73
|
-
function getTitleFromUrl(url) {
|
|
74
|
-
if (url) {
|
|
75
|
-
/** @type {?} */
|
|
76
|
-
const temp = new URL(url);
|
|
77
|
-
if (temp.hash) {
|
|
78
|
-
return removeLeadingHash(temp.hash);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
/** @type {?} */
|
|
82
|
-
const path = temp.pathname.split('/');
|
|
83
|
-
/** @type {?} */
|
|
84
|
-
const fileName = path[path.length - 1];
|
|
85
|
-
return fileName.replace(/\.[^/.]+$/, ''); // remove .md
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return undefined;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* @param {?} markdownString
|
|
92
|
-
* @return {?}
|
|
93
|
-
*/
|
|
94
|
-
function getTitleFromMarkdownString(markdownString) {
|
|
95
|
-
if (markdownString) {
|
|
96
|
-
/** @type {?} */
|
|
97
|
-
const firstLine = markdownString.split(/[\r\n]+/).find((/**
|
|
98
|
-
* @param {?} line
|
|
99
|
-
* @return {?}
|
|
100
|
-
*/
|
|
101
|
-
(line) => !!line));
|
|
102
|
-
return removeLeadingHash(firstLine).trim();
|
|
103
|
-
}
|
|
104
|
-
return undefined;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* @param {?} anchor
|
|
108
|
-
* @return {?}
|
|
109
|
-
*/
|
|
110
|
-
function isMarkdownHref(anchor) {
|
|
111
|
-
return !isAnchorLink(anchor) && anchor.pathname.endsWith('.md');
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* @param {?} o1
|
|
115
|
-
* @param {?} o2
|
|
116
|
-
* @return {?}
|
|
117
|
-
*/
|
|
118
|
-
function defaultCompareWith(o1, o2) {
|
|
119
|
-
if (o1.id && o2.id) {
|
|
120
|
-
return o1.id === o2.id;
|
|
121
|
-
}
|
|
122
|
-
return o1 === o2;
|
|
123
|
-
}
|
|
124
|
-
class TdMarkdownNavigatorComponent {
|
|
125
|
-
/**
|
|
126
|
-
* @param {?} _markdownUrlLoaderService
|
|
127
|
-
* @param {?} _changeDetectorRef
|
|
128
|
-
* @param {?} _sanitizer
|
|
129
|
-
* @param {?} _http
|
|
130
|
-
*/
|
|
131
|
-
constructor(_markdownUrlLoaderService, _changeDetectorRef, _sanitizer, _http) {
|
|
132
|
-
this._markdownUrlLoaderService = _markdownUrlLoaderService;
|
|
133
|
-
this._changeDetectorRef = _changeDetectorRef;
|
|
134
|
-
this._sanitizer = _sanitizer;
|
|
135
|
-
this._http = _http;
|
|
136
|
-
/**
|
|
137
|
-
* copyCodeToClipboard?: boolean
|
|
138
|
-
*
|
|
139
|
-
* Display copy button on code snippets to copy code to clipboard.
|
|
140
|
-
*
|
|
141
|
-
*/
|
|
142
|
-
this.copyCodeToClipboard = false;
|
|
143
|
-
/**
|
|
144
|
-
* copyCodeTooltips?: ICopyCodeTooltips
|
|
145
|
-
*
|
|
146
|
-
* Tooltips for copy button to copy and upon copying.
|
|
147
|
-
*/
|
|
148
|
-
this.copyCodeTooltips = {};
|
|
149
|
-
this.buttonClicked = new EventEmitter();
|
|
150
|
-
this.historyStack = []; // history
|
|
151
|
-
// currently rendered
|
|
152
|
-
this.currentMenuItems = []; // current menu items
|
|
153
|
-
// current menu items
|
|
154
|
-
this.loading = false;
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* @param {?} event
|
|
158
|
-
* @return {?}
|
|
159
|
-
*/
|
|
160
|
-
clickListener(event) {
|
|
161
|
-
/** @type {?} */
|
|
162
|
-
const element = (/** @type {?} */ (event.srcElement));
|
|
163
|
-
if (element.matches('a[href]') && isMarkdownHref((/** @type {?} */ (element)))) {
|
|
164
|
-
this.handleLinkClick(event);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* @return {?}
|
|
169
|
-
*/
|
|
170
|
-
get showGoBackButton() {
|
|
171
|
-
return this.historyStack.length > 0;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* @return {?}
|
|
175
|
-
*/
|
|
176
|
-
get showHomeButton() {
|
|
177
|
-
return this.historyStack.length > 1;
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* @return {?}
|
|
181
|
-
*/
|
|
182
|
-
get showHeader() {
|
|
183
|
-
return this.showHomeButton || this.showGoBackButton || !!this.currentItemTitle;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* @return {?}
|
|
187
|
-
*/
|
|
188
|
-
get showMenu() {
|
|
189
|
-
return this.currentMenuItems && this.currentMenuItems.length > 0;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* @return {?}
|
|
193
|
-
*/
|
|
194
|
-
get showTdMarkdownLoader() {
|
|
195
|
-
return !!this.currentMarkdownItem && !!this.currentMarkdownItem.url && !this.showTdMarkdown;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* @return {?}
|
|
199
|
-
*/
|
|
200
|
-
get showTdMarkdown() {
|
|
201
|
-
return !!this.currentMarkdownItem && !!this.currentMarkdownItem.markdownString;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* @return {?}
|
|
205
|
-
*/
|
|
206
|
-
get url() {
|
|
207
|
-
if (this.currentMarkdownItem) {
|
|
208
|
-
return this.currentMarkdownItem.url;
|
|
209
|
-
}
|
|
210
|
-
return undefined;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* @return {?}
|
|
214
|
-
*/
|
|
215
|
-
get footerComponent() {
|
|
216
|
-
if (this.currentMarkdownItem && this.currentMarkdownItem.footer) {
|
|
217
|
-
return this.currentMarkdownItem.footer;
|
|
218
|
-
}
|
|
219
|
-
return this.footer;
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* @return {?}
|
|
223
|
-
*/
|
|
224
|
-
get httpOptions() {
|
|
225
|
-
if (this.currentMarkdownItem) {
|
|
226
|
-
return this.currentMarkdownItem.httpOptions;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* @return {?}
|
|
231
|
-
*/
|
|
232
|
-
get markdownString() {
|
|
233
|
-
if (this.currentMarkdownItem) {
|
|
234
|
-
return this.currentMarkdownItem.markdownString;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* @return {?}
|
|
239
|
-
*/
|
|
240
|
-
get anchor() {
|
|
241
|
-
if (this.currentMarkdownItem) {
|
|
242
|
-
return this.currentMarkdownItem.anchor;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* @return {?}
|
|
247
|
-
*/
|
|
248
|
-
get showEmptyState() {
|
|
249
|
-
return !this.items || this.items.length < 1;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* @return {?}
|
|
253
|
-
*/
|
|
254
|
-
get goHomeLabel() {
|
|
255
|
-
return (this.labels && this.labels.goHome) || DEFAULT_MARKDOWN_NAVIGATOR_LABELS.goHome;
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* @return {?}
|
|
259
|
-
*/
|
|
260
|
-
get goBackLabel() {
|
|
261
|
-
return (this.labels && this.labels.goBack) || DEFAULT_MARKDOWN_NAVIGATOR_LABELS.goBack;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* @return {?}
|
|
265
|
-
*/
|
|
266
|
-
get emptyStateLabel() {
|
|
267
|
-
return (this.labels && this.labels.emptyState) || DEFAULT_MARKDOWN_NAVIGATOR_LABELS.emptyState;
|
|
268
|
-
}
|
|
269
|
-
/**
|
|
270
|
-
* @return {?}
|
|
271
|
-
*/
|
|
272
|
-
get currentItemTitle() {
|
|
273
|
-
if (this.historyStack.length < 1) {
|
|
274
|
-
return '';
|
|
275
|
-
}
|
|
276
|
-
else if (this.currentMarkdownItem) {
|
|
277
|
-
return this.getTitle(this.currentMarkdownItem);
|
|
278
|
-
}
|
|
279
|
-
else if (this.historyStack.length > 0) {
|
|
280
|
-
return this.getTitle(this.historyStack[this.historyStack.length - 1]);
|
|
281
|
-
}
|
|
282
|
-
return '';
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @param {?} changes
|
|
286
|
-
* @return {?}
|
|
287
|
-
*/
|
|
288
|
-
ngOnChanges(changes) {
|
|
289
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
290
|
-
if (changes.items) {
|
|
291
|
-
this.reset();
|
|
292
|
-
}
|
|
293
|
-
if (changes.startAt && this.items && this.startAt) {
|
|
294
|
-
this._jumpTo(this.startAt, undefined);
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* @param {?} item
|
|
300
|
-
* @return {?}
|
|
301
|
-
*/
|
|
302
|
-
hasChildrenOrChildrenUrl(item) {
|
|
303
|
-
return (item.children && item.children.length > 0) || !!item.childrenUrl;
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* @return {?}
|
|
307
|
-
*/
|
|
308
|
-
clearErrors() {
|
|
309
|
-
this.markdownLoaderError = undefined;
|
|
310
|
-
this.childrenUrlError = undefined;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* @return {?}
|
|
314
|
-
*/
|
|
315
|
-
reset() {
|
|
316
|
-
this.loading = false;
|
|
317
|
-
this.clearErrors();
|
|
318
|
-
// if single item and no children
|
|
319
|
-
if (this.items && this.items.length === 1 && !this.hasChildrenOrChildrenUrl(this.items[0])) {
|
|
320
|
-
this.currentMenuItems = [];
|
|
321
|
-
this.currentMarkdownItem = this.items[0];
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
this.currentMenuItems = this.items;
|
|
325
|
-
this.currentMarkdownItem = undefined;
|
|
326
|
-
}
|
|
327
|
-
this.historyStack = [];
|
|
328
|
-
this._changeDetectorRef.markForCheck();
|
|
329
|
-
}
|
|
330
|
-
/**
|
|
331
|
-
* @return {?}
|
|
332
|
-
*/
|
|
333
|
-
goBack() {
|
|
334
|
-
this.loading = false;
|
|
335
|
-
this.clearErrors();
|
|
336
|
-
if (this.historyStack.length > 1) {
|
|
337
|
-
/** @type {?} */
|
|
338
|
-
let parent = this.historyStack[this.historyStack.length - 2];
|
|
339
|
-
if (parent.startAtLink) {
|
|
340
|
-
parent = this.historyStack[this.historyStack.length - 3]
|
|
341
|
-
? this.historyStack[this.historyStack.length - 3]
|
|
342
|
-
: undefined;
|
|
343
|
-
this.historyStack = this.historyStack.slice(0, -1);
|
|
344
|
-
}
|
|
345
|
-
if (parent) {
|
|
346
|
-
this.currentMarkdownItem = parent;
|
|
347
|
-
this.historyStack = this.historyStack.slice(0, -1);
|
|
348
|
-
this.setChildrenAsCurrentMenuItems(parent);
|
|
349
|
-
}
|
|
350
|
-
else {
|
|
351
|
-
this.reset();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
else {
|
|
355
|
-
// one level down just go to root
|
|
356
|
-
this.reset();
|
|
357
|
-
}
|
|
358
|
-
this._changeDetectorRef.markForCheck();
|
|
359
|
-
}
|
|
360
|
-
/**
|
|
361
|
-
* @param {?} item
|
|
362
|
-
* @return {?}
|
|
363
|
-
*/
|
|
364
|
-
handleItemSelected(item) {
|
|
365
|
-
this.clearErrors();
|
|
366
|
-
this.currentMarkdownItem = item;
|
|
367
|
-
this.historyStack = [...this.historyStack, item];
|
|
368
|
-
this.setChildrenAsCurrentMenuItems(item);
|
|
369
|
-
this._changeDetectorRef.markForCheck();
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* @param {?} item
|
|
373
|
-
* @return {?}
|
|
374
|
-
*/
|
|
375
|
-
setChildrenAsCurrentMenuItems(item) {
|
|
376
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
377
|
-
this.currentMenuItems = [];
|
|
378
|
-
this.loading = true;
|
|
379
|
-
this._changeDetectorRef.markForCheck();
|
|
380
|
-
/** @type {?} */
|
|
381
|
-
const stackSnapshot = this.historyStack;
|
|
382
|
-
/** @type {?} */
|
|
383
|
-
let children = [];
|
|
384
|
-
if (item.children) {
|
|
385
|
-
children = item.children;
|
|
386
|
-
}
|
|
387
|
-
else if (item.childrenUrl) {
|
|
388
|
-
children = yield this.loadChildrenUrl(item);
|
|
389
|
-
}
|
|
390
|
-
if (children && children.length && item.startAtLink) {
|
|
391
|
-
this._jumpTo(item.startAtLink, children);
|
|
392
|
-
}
|
|
393
|
-
/** @type {?} */
|
|
394
|
-
const newStackSnapshot = this.historyStack;
|
|
395
|
-
if (stackSnapshot.length === newStackSnapshot.length &&
|
|
396
|
-
stackSnapshot.every((/**
|
|
397
|
-
* @param {?} stackItem
|
|
398
|
-
* @param {?} index
|
|
399
|
-
* @return {?}
|
|
400
|
-
*/
|
|
401
|
-
(stackItem, index) => stackItem === newStackSnapshot[index]))) {
|
|
402
|
-
this.currentMenuItems = children;
|
|
403
|
-
}
|
|
404
|
-
this.loading = false;
|
|
405
|
-
this._changeDetectorRef.markForCheck();
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* @param {?} item
|
|
410
|
-
* @return {?}
|
|
411
|
-
*/
|
|
412
|
-
loadChildrenUrl(item) {
|
|
413
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
414
|
-
/** @type {?} */
|
|
415
|
-
const sanitizedUrl = this._sanitizer.sanitize(SecurityContext.URL, item.childrenUrl);
|
|
416
|
-
try {
|
|
417
|
-
return yield this._http.get(sanitizedUrl, Object.assign({}, item.httpOptions)).toPromise();
|
|
418
|
-
}
|
|
419
|
-
catch (error) {
|
|
420
|
-
this.handleChildrenUrlError(error);
|
|
421
|
-
return [];
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
|
-
/**
|
|
426
|
-
* @param {?} item
|
|
427
|
-
* @return {?}
|
|
428
|
-
*/
|
|
429
|
-
getTitle(item) {
|
|
430
|
-
if (item) {
|
|
431
|
-
return (removeLeadingHash(item.anchor) ||
|
|
432
|
-
item.title ||
|
|
433
|
-
getTitleFromUrl(item.url) ||
|
|
434
|
-
getTitleFromMarkdownString(item.markdownString) ||
|
|
435
|
-
'').trim();
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* @param {?} item
|
|
440
|
-
* @return {?}
|
|
441
|
-
*/
|
|
442
|
-
getIcon(item) {
|
|
443
|
-
if (item) {
|
|
444
|
-
return item.icon || 'subject';
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* @param {?} error
|
|
449
|
-
* @return {?}
|
|
450
|
-
*/
|
|
451
|
-
handleChildrenUrlError(error) {
|
|
452
|
-
this.childrenUrlError = error.message;
|
|
453
|
-
this._changeDetectorRef.markForCheck();
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* @param {?} error
|
|
457
|
-
* @return {?}
|
|
458
|
-
*/
|
|
459
|
-
handleMarkdownLoaderError(error) {
|
|
460
|
-
this.markdownLoaderError = error.message;
|
|
461
|
-
this._changeDetectorRef.markForCheck();
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* @private
|
|
465
|
-
* @param {?} itemOrPath
|
|
466
|
-
* @param {?} children
|
|
467
|
-
* @return {?}
|
|
468
|
-
*/
|
|
469
|
-
_jumpTo(itemOrPath, children) {
|
|
470
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
471
|
-
/** @type {?} */
|
|
472
|
-
const historyStack = this.historyStack;
|
|
473
|
-
this.reset();
|
|
474
|
-
if (this.items && this.items.length > 0) {
|
|
475
|
-
/** @type {?} */
|
|
476
|
-
let path = [];
|
|
477
|
-
if (Array.isArray(itemOrPath)) {
|
|
478
|
-
path = yield this.followPath(this.items, itemOrPath);
|
|
479
|
-
}
|
|
480
|
-
else if (children && children.length > 0) {
|
|
481
|
-
this.historyStack = historyStack;
|
|
482
|
-
path = this.findPath(children, itemOrPath);
|
|
483
|
-
}
|
|
484
|
-
else {
|
|
485
|
-
path = this.findPath(this.items, itemOrPath);
|
|
486
|
-
}
|
|
487
|
-
(path || []).forEach((/**
|
|
488
|
-
* @param {?} pathItem
|
|
489
|
-
* @return {?}
|
|
490
|
-
*/
|
|
491
|
-
(pathItem) => this.handleItemSelected(pathItem)));
|
|
492
|
-
}
|
|
493
|
-
this._changeDetectorRef.markForCheck();
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* @private
|
|
498
|
-
* @param {?} items
|
|
499
|
-
* @param {?} path
|
|
500
|
-
* @return {?}
|
|
501
|
-
*/
|
|
502
|
-
followPath(items, path) {
|
|
503
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
504
|
-
/** @type {?} */
|
|
505
|
-
let pathItems = [];
|
|
506
|
-
/** @type {?} */
|
|
507
|
-
let currentLevel = items;
|
|
508
|
-
/** @type {?} */
|
|
509
|
-
const compareWith = this.compareWith || defaultCompareWith;
|
|
510
|
-
for (const pathItem of path) {
|
|
511
|
-
/** @type {?} */
|
|
512
|
-
const foundItem = currentLevel.find((/**
|
|
513
|
-
* @param {?} item
|
|
514
|
-
* @return {?}
|
|
515
|
-
*/
|
|
516
|
-
(item) => compareWith(pathItem, item)));
|
|
517
|
-
if (foundItem) {
|
|
518
|
-
pathItems = [...pathItems, foundItem];
|
|
519
|
-
if (foundItem.children) {
|
|
520
|
-
currentLevel = foundItem.children;
|
|
521
|
-
}
|
|
522
|
-
else if (foundItem.childrenUrl) {
|
|
523
|
-
currentLevel = yield this.loadChildrenUrl(foundItem);
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
else {
|
|
527
|
-
break;
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
if (pathItems.length !== path.length) {
|
|
531
|
-
pathItems = [];
|
|
532
|
-
}
|
|
533
|
-
return pathItems;
|
|
534
|
-
});
|
|
535
|
-
}
|
|
536
|
-
/**
|
|
537
|
-
* @private
|
|
538
|
-
* @param {?} items
|
|
539
|
-
* @param {?} item
|
|
540
|
-
* @return {?}
|
|
541
|
-
*/
|
|
542
|
-
findPath(items, item) {
|
|
543
|
-
/** @type {?} */
|
|
544
|
-
const compareWith = this.compareWith || defaultCompareWith;
|
|
545
|
-
if (items) {
|
|
546
|
-
for (const child of items) {
|
|
547
|
-
if (compareWith(child, item)) {
|
|
548
|
-
return [child];
|
|
549
|
-
}
|
|
550
|
-
/** @type {?} */
|
|
551
|
-
const ancestors = this.findPath(child.children, item);
|
|
552
|
-
if (ancestors) {
|
|
553
|
-
return [child, ...ancestors];
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
return undefined;
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* @private
|
|
561
|
-
* @param {?} event
|
|
562
|
-
* @return {?}
|
|
563
|
-
*/
|
|
564
|
-
handleLinkClick(event) {
|
|
565
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
566
|
-
event.preventDefault();
|
|
567
|
-
/** @type {?} */
|
|
568
|
-
const link = (/** @type {?} */ (event.target));
|
|
569
|
-
/** @type {?} */
|
|
570
|
-
const url = new URL(link.href);
|
|
571
|
-
this.loading = true;
|
|
572
|
-
this._changeDetectorRef.markForCheck();
|
|
573
|
-
try {
|
|
574
|
-
/** @type {?} */
|
|
575
|
-
const markdownString = yield this._markdownUrlLoaderService.load(url.href);
|
|
576
|
-
// pass in url to be able to use currentMarkdownItem.url later on
|
|
577
|
-
this.handleItemSelected({ markdownString, url: url.href });
|
|
578
|
-
this.markdownWrapper.nativeElement.scrollTop = 0;
|
|
579
|
-
}
|
|
580
|
-
catch (error) {
|
|
581
|
-
/** @type {?} */
|
|
582
|
-
const win = window.open(url.href, '_blank');
|
|
583
|
-
win.focus();
|
|
584
|
-
}
|
|
585
|
-
finally {
|
|
586
|
-
this.loading = false;
|
|
587
|
-
}
|
|
588
|
-
this._changeDetectorRef.markForCheck();
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
TdMarkdownNavigatorComponent.decorators = [
|
|
593
|
-
{ type: Component, args: [{
|
|
594
|
-
selector: 'td-markdown-navigator',
|
|
595
|
-
template: "<ng-container *ngIf=\"!showEmptyState\">\n <mat-progress-bar *ngIf=\"loading\" mode=\"indeterminate\" color=\"accent\"></mat-progress-bar>\n\n <ng-container *ngIf=\"showHeader\">\n <div [style.display]=\"'flex'\">\n <button\n id=\"td-markdown-navigator-home-button\"\n *ngIf=\"showHomeButton\"\n mat-icon-button\n [matTooltip]=\"goHomeLabel\"\n (click)=\"reset()\"\n [attr.data-test]=\"'home-button'\"\n >\n <mat-icon [attr.aria-label]=\"goHomeLabel\">home</mat-icon>\n </button>\n\n <button\n id=\"td-markdown-navigator-back-button\"\n *ngIf=\"showGoBackButton\"\n mat-icon-button\n [matTooltip]=\"goBackLabel\"\n (click)=\"goBack()\"\n [attr.data-test]=\"'back-button'\"\n >\n <mat-icon [attr.aria-label]=\"goBackLabel\">arrow_back</mat-icon>\n </button>\n <span flex *ngIf=\"currentItemTitle\" class=\"mat-body-2 title truncate\" [attr.data-test]=\"'title'\">\n {{ currentItemTitle }}\n </span>\n </div>\n\n <mat-divider [style.position]=\"'relative'\"></mat-divider>\n </ng-container>\n\n <div class=\"scroll-area\" id=\"td-markdown-navigator-content\">\n <div *ngIf=\"showTdMarkdownLoader || showTdMarkdown\" class=\"markdown-wrapper\" #markdownWrapper>\n <td-message\n *ngIf=\"markdownLoaderError\"\n [sublabel]=\"markdownLoaderError\"\n color=\"warn\"\n icon=\"error\"\n [attr.data-test]=\"'markdown-loader-error'\"\n ></td-message>\n <td-flavored-markdown-loader\n *ngIf=\"showTdMarkdownLoader\"\n [url]=\"url\"\n [httpOptions]=\"httpOptions\"\n [anchor]=\"anchor\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n (loadFailed)=\"handleMarkdownLoaderError($event)\"\n ></td-flavored-markdown-loader>\n <td-flavored-markdown\n *ngIf=\"showTdMarkdown\"\n [content]=\"markdownString\"\n [hostedUrl]=\"url\"\n [anchor]=\"anchor\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n (buttonClicked)=\"buttonClicked.emit($event)\"\n ></td-flavored-markdown>\n </div>\n\n <td-message\n *ngIf=\"childrenUrlError\"\n [sublabel]=\"childrenUrlError\"\n color=\"warn\"\n icon=\"error\"\n [attr.data-test]=\"'children-url-error'\"\n ></td-message>\n <div *ngIf=\"showMenu\" class=\"td-markdown-list\">\n <mat-action-list>\n <button\n *ngFor=\"let item of currentMenuItems; index as index\"\n [id]=\"'td-markdown-navigator-list-item-' + (item.id ? item.id : index)\"\n (click)=\"handleItemSelected(item)\"\n mat-list-item\n [matTooltip]=\"getTitle(item)\"\n matTooltipPosition=\"before\"\n matTooltipShowDelay=\"500\"\n >\n <mat-icon matListIcon>\n {{ getIcon(item) }}\n </mat-icon>\n <span matLine class=\"truncate\">\n {{ getTitle(item) }}\n </span>\n <span matLine class=\"truncate\">{{ item.description }}</span>\n <mat-divider></mat-divider>\n </button>\n </mat-action-list>\n </div>\n\n <ng-container *ngComponentOutlet=\"footerComponent\"></ng-container>\n </div>\n</ng-container>\n\n<div *ngIf=\"showEmptyState\" layout=\"column\" layout-align=\"center center\" class=\"empty-state\">\n <mat-icon matListAvatar>subject</mat-icon>\n <h2>{{ emptyStateLabel }}</h2>\n</div>\n",
|
|
596
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
597
|
-
styles: [":host{-ms-flex-direction:column;box-sizing:border-box;display:-ms-flexbox;display:flex;flex-direction:column;height:inherit;height:100%;position:relative}:host .scroll-area{-ms-flex:1;box-sizing:border-box;flex:1;min-height:1px;overflow-y:auto}:host .markdown-wrapper{padding:16px 16px 0}:host .td-markdown-list>.mat-list{padding-top:0}:host td-flavored-markdown-loader ::ng-deep .mat-progress-bar{left:0;position:absolute;right:0;top:0}:host .title{display:inline-block;margin:8px 0;padding-left:16px;vertical-align:middle}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.empty-state{padding:32px}.empty-state mat-icon{font-size:4em}"]
|
|
598
|
-
}] }
|
|
599
|
-
];
|
|
600
|
-
/** @nocollapse */
|
|
601
|
-
TdMarkdownNavigatorComponent.ctorParameters = () => [
|
|
602
|
-
{ type: TdMarkdownLoaderService },
|
|
603
|
-
{ type: ChangeDetectorRef },
|
|
604
|
-
{ type: DomSanitizer },
|
|
605
|
-
{ type: HttpClient }
|
|
606
|
-
];
|
|
607
|
-
TdMarkdownNavigatorComponent.propDecorators = {
|
|
608
|
-
items: [{ type: Input }],
|
|
609
|
-
labels: [{ type: Input }],
|
|
610
|
-
startAt: [{ type: Input }],
|
|
611
|
-
copyCodeToClipboard: [{ type: Input }],
|
|
612
|
-
copyCodeTooltips: [{ type: Input }],
|
|
613
|
-
footer: [{ type: Input }],
|
|
614
|
-
compareWith: [{ type: Input }],
|
|
615
|
-
buttonClicked: [{ type: Output }],
|
|
616
|
-
markdownWrapper: [{ type: ViewChild, args: ['markdownWrapper',] }],
|
|
617
|
-
clickListener: [{ type: HostListener, args: ['click', ['$event'],] }]
|
|
618
|
-
};
|
|
619
|
-
if (false) {
|
|
620
|
-
/**
|
|
621
|
-
* items: IMarkdownNavigatorItem[]
|
|
622
|
-
*
|
|
623
|
-
* List of IMarkdownNavigatorItems to be rendered
|
|
624
|
-
* @type {?}
|
|
625
|
-
*/
|
|
626
|
-
TdMarkdownNavigatorComponent.prototype.items;
|
|
627
|
-
/**
|
|
628
|
-
* labels?: IMarkdownNavigatorLabels
|
|
629
|
-
*
|
|
630
|
-
* Translated labels
|
|
631
|
-
* @type {?}
|
|
632
|
-
*/
|
|
633
|
-
TdMarkdownNavigatorComponent.prototype.labels;
|
|
634
|
-
/**
|
|
635
|
-
* startAt?: IMarkdownNavigatorItem | IMarkdownNavigatorItem[];
|
|
636
|
-
*
|
|
637
|
-
* Item or path to start at
|
|
638
|
-
* @type {?}
|
|
639
|
-
*/
|
|
640
|
-
TdMarkdownNavigatorComponent.prototype.startAt;
|
|
641
|
-
/**
|
|
642
|
-
* copyCodeToClipboard?: boolean
|
|
643
|
-
*
|
|
644
|
-
* Display copy button on code snippets to copy code to clipboard.
|
|
645
|
-
*
|
|
646
|
-
* @type {?}
|
|
647
|
-
*/
|
|
648
|
-
TdMarkdownNavigatorComponent.prototype.copyCodeToClipboard;
|
|
649
|
-
/**
|
|
650
|
-
* copyCodeTooltips?: ICopyCodeTooltips
|
|
651
|
-
*
|
|
652
|
-
* Tooltips for copy button to copy and upon copying.
|
|
653
|
-
* @type {?}
|
|
654
|
-
*/
|
|
655
|
-
TdMarkdownNavigatorComponent.prototype.copyCodeTooltips;
|
|
656
|
-
/**
|
|
657
|
-
* footer?: Type<any>
|
|
658
|
-
*
|
|
659
|
-
* Component to be displayed in footer
|
|
660
|
-
* @type {?}
|
|
661
|
-
*/
|
|
662
|
-
TdMarkdownNavigatorComponent.prototype.footer;
|
|
663
|
-
/**
|
|
664
|
-
* compareWith?: IMarkdownNavigatorCompareWith
|
|
665
|
-
*
|
|
666
|
-
* Function used to find startAt item
|
|
667
|
-
* Defaults to comparison by strict equality (===)
|
|
668
|
-
* @type {?}
|
|
669
|
-
*/
|
|
670
|
-
TdMarkdownNavigatorComponent.prototype.compareWith;
|
|
671
|
-
/** @type {?} */
|
|
672
|
-
TdMarkdownNavigatorComponent.prototype.buttonClicked;
|
|
673
|
-
/** @type {?} */
|
|
674
|
-
TdMarkdownNavigatorComponent.prototype.markdownWrapper;
|
|
675
|
-
/** @type {?} */
|
|
676
|
-
TdMarkdownNavigatorComponent.prototype.historyStack;
|
|
677
|
-
/** @type {?} */
|
|
678
|
-
TdMarkdownNavigatorComponent.prototype.currentMarkdownItem;
|
|
679
|
-
/** @type {?} */
|
|
680
|
-
TdMarkdownNavigatorComponent.prototype.currentMenuItems;
|
|
681
|
-
/** @type {?} */
|
|
682
|
-
TdMarkdownNavigatorComponent.prototype.loading;
|
|
683
|
-
/** @type {?} */
|
|
684
|
-
TdMarkdownNavigatorComponent.prototype.markdownLoaderError;
|
|
685
|
-
/** @type {?} */
|
|
686
|
-
TdMarkdownNavigatorComponent.prototype.childrenUrlError;
|
|
687
|
-
/**
|
|
688
|
-
* @type {?}
|
|
689
|
-
* @private
|
|
690
|
-
*/
|
|
691
|
-
TdMarkdownNavigatorComponent.prototype._markdownUrlLoaderService;
|
|
692
|
-
/**
|
|
693
|
-
* @type {?}
|
|
694
|
-
* @private
|
|
695
|
-
*/
|
|
696
|
-
TdMarkdownNavigatorComponent.prototype._changeDetectorRef;
|
|
697
|
-
/**
|
|
698
|
-
* @type {?}
|
|
699
|
-
* @private
|
|
700
|
-
*/
|
|
701
|
-
TdMarkdownNavigatorComponent.prototype._sanitizer;
|
|
702
|
-
/**
|
|
703
|
-
* @type {?}
|
|
704
|
-
* @private
|
|
705
|
-
*/
|
|
706
|
-
TdMarkdownNavigatorComponent.prototype._http;
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* @fileoverview added by tsickle
|
|
711
|
-
* Generated from: markdown-navigator-window/markdown-navigator-window.component.ts
|
|
712
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
713
|
-
*/
|
|
714
|
-
/**
|
|
715
|
-
* @record
|
|
716
|
-
*/
|
|
717
|
-
function IMarkdownNavigatorWindowLabels() { }
|
|
718
|
-
if (false) {
|
|
719
|
-
/** @type {?|undefined} */
|
|
720
|
-
IMarkdownNavigatorWindowLabels.prototype.title;
|
|
721
|
-
/** @type {?|undefined} */
|
|
722
|
-
IMarkdownNavigatorWindowLabels.prototype.close;
|
|
723
|
-
/** @type {?|undefined} */
|
|
724
|
-
IMarkdownNavigatorWindowLabels.prototype.dock;
|
|
725
|
-
/** @type {?|undefined} */
|
|
726
|
-
IMarkdownNavigatorWindowLabels.prototype.unDock;
|
|
727
|
-
}
|
|
728
|
-
/** @type {?} */
|
|
729
|
-
const DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS = {
|
|
730
|
-
title: 'Help',
|
|
731
|
-
close: 'Close',
|
|
732
|
-
dock: 'Dock',
|
|
733
|
-
unDock: 'Undock',
|
|
734
|
-
};
|
|
735
|
-
class TdMarkdownNavigatorWindowComponent {
|
|
736
|
-
constructor() {
|
|
737
|
-
this.toolbarColor = 'primary';
|
|
738
|
-
this.docked = false;
|
|
739
|
-
this.copyCodeToClipboard = false;
|
|
740
|
-
this.copyCodeTooltips = {};
|
|
741
|
-
this.closed = new EventEmitter();
|
|
742
|
-
this.dockToggled = new EventEmitter();
|
|
743
|
-
this.buttonClicked = new EventEmitter();
|
|
744
|
-
}
|
|
745
|
-
/**
|
|
746
|
-
* @return {?}
|
|
747
|
-
*/
|
|
748
|
-
get markdownNavigatorLabels() {
|
|
749
|
-
if (this.labels) {
|
|
750
|
-
const { goHome, goBack, emptyState } = this.labels;
|
|
751
|
-
return {
|
|
752
|
-
goHome,
|
|
753
|
-
goBack,
|
|
754
|
-
emptyState,
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* @return {?}
|
|
760
|
-
*/
|
|
761
|
-
get titleLabel() {
|
|
762
|
-
return (this.labels && this.labels.title) || DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS.title;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* @return {?}
|
|
766
|
-
*/
|
|
767
|
-
get closeLabel() {
|
|
768
|
-
return (this.labels && this.labels.close) || DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS.close;
|
|
769
|
-
}
|
|
770
|
-
/**
|
|
771
|
-
* @return {?}
|
|
772
|
-
*/
|
|
773
|
-
get toggleDockedStateLabel() {
|
|
774
|
-
if (this.docked) {
|
|
775
|
-
return (this.labels && this.labels.unDock) || DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS.unDock;
|
|
776
|
-
}
|
|
777
|
-
else {
|
|
778
|
-
return (this.labels && this.labels.dock) || DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS.dock;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* @return {?}
|
|
783
|
-
*/
|
|
784
|
-
toggleDockedState() {
|
|
785
|
-
this.dockToggled.emit(this.docked);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
TdMarkdownNavigatorWindowComponent.decorators = [
|
|
789
|
-
{ type: Component, args: [{
|
|
790
|
-
selector: 'td-markdown-navigator-window',
|
|
791
|
-
template: "<td-window-dialog\n [toolbarColor]=\"toolbarColor\"\n [docked]=\"docked\"\n [title]=\"titleLabel\"\n [toggleDockedStateLabel]=\"toggleDockedStateLabel\"\n [closeLabel]=\"closeLabel\"\n (dockToggled)=\"toggleDockedState()\"\n (closed)=\"closed.emit()\"\n>\n <td-markdown-navigator\n [items]=\"items\"\n [labels]=\"markdownNavigatorLabels\"\n [style.display]=\"docked ? 'none' : 'inherit'\"\n [startAt]=\"startAt\"\n [compareWith]=\"compareWith\"\n [footer]=\"footer\"\n [copyCodeToClipboard]=\"copyCodeToClipboard\"\n [copyCodeTooltips]=\"copyCodeTooltips\"\n (buttonClicked)=\"buttonClicked.emit($event)\"\n ></td-markdown-navigator>\n</td-window-dialog>\n",
|
|
792
|
-
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
793
|
-
styles: [":host{-ms-flex-direction:column;display:-ms-flexbox;display:flex;flex-direction:column;height:100%}td-markdown-navigator{height:calc(100% - 56px)}"]
|
|
794
|
-
}] }
|
|
795
|
-
];
|
|
796
|
-
TdMarkdownNavigatorWindowComponent.propDecorators = {
|
|
797
|
-
items: [{ type: Input }],
|
|
798
|
-
labels: [{ type: Input }],
|
|
799
|
-
toolbarColor: [{ type: Input }],
|
|
800
|
-
startAt: [{ type: Input }],
|
|
801
|
-
compareWith: [{ type: Input }],
|
|
802
|
-
docked: [{ type: Input }],
|
|
803
|
-
copyCodeToClipboard: [{ type: Input }],
|
|
804
|
-
copyCodeTooltips: [{ type: Input }],
|
|
805
|
-
footer: [{ type: Input }],
|
|
806
|
-
closed: [{ type: Output }],
|
|
807
|
-
dockToggled: [{ type: Output }],
|
|
808
|
-
buttonClicked: [{ type: Output }]
|
|
809
|
-
};
|
|
810
|
-
if (false) {
|
|
811
|
-
/** @type {?} */
|
|
812
|
-
TdMarkdownNavigatorWindowComponent.prototype.items;
|
|
813
|
-
/** @type {?} */
|
|
814
|
-
TdMarkdownNavigatorWindowComponent.prototype.labels;
|
|
815
|
-
/** @type {?} */
|
|
816
|
-
TdMarkdownNavigatorWindowComponent.prototype.toolbarColor;
|
|
817
|
-
/** @type {?} */
|
|
818
|
-
TdMarkdownNavigatorWindowComponent.prototype.startAt;
|
|
819
|
-
/** @type {?} */
|
|
820
|
-
TdMarkdownNavigatorWindowComponent.prototype.compareWith;
|
|
821
|
-
/** @type {?} */
|
|
822
|
-
TdMarkdownNavigatorWindowComponent.prototype.docked;
|
|
823
|
-
/** @type {?} */
|
|
824
|
-
TdMarkdownNavigatorWindowComponent.prototype.copyCodeToClipboard;
|
|
825
|
-
/** @type {?} */
|
|
826
|
-
TdMarkdownNavigatorWindowComponent.prototype.copyCodeTooltips;
|
|
827
|
-
/** @type {?} */
|
|
828
|
-
TdMarkdownNavigatorWindowComponent.prototype.footer;
|
|
829
|
-
/** @type {?} */
|
|
830
|
-
TdMarkdownNavigatorWindowComponent.prototype.closed;
|
|
831
|
-
/** @type {?} */
|
|
832
|
-
TdMarkdownNavigatorWindowComponent.prototype.dockToggled;
|
|
833
|
-
/** @type {?} */
|
|
834
|
-
TdMarkdownNavigatorWindowComponent.prototype.buttonClicked;
|
|
835
|
-
}
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* @fileoverview added by tsickle
|
|
839
|
-
* Generated from: markdown-navigator-window-service/markdown-navigator-window.service.ts
|
|
840
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
841
|
-
*/
|
|
842
|
-
/**
|
|
843
|
-
* @record
|
|
844
|
-
*/
|
|
845
|
-
function IMarkdownNavigatorWindowConfig() { }
|
|
846
|
-
if (false) {
|
|
847
|
-
/** @type {?} */
|
|
848
|
-
IMarkdownNavigatorWindowConfig.prototype.items;
|
|
849
|
-
/** @type {?|undefined} */
|
|
850
|
-
IMarkdownNavigatorWindowConfig.prototype.dialogConfig;
|
|
851
|
-
/** @type {?|undefined} */
|
|
852
|
-
IMarkdownNavigatorWindowConfig.prototype.labels;
|
|
853
|
-
/** @type {?|undefined} */
|
|
854
|
-
IMarkdownNavigatorWindowConfig.prototype.toolbarColor;
|
|
855
|
-
/** @type {?|undefined} */
|
|
856
|
-
IMarkdownNavigatorWindowConfig.prototype.startAt;
|
|
857
|
-
/** @type {?|undefined} */
|
|
858
|
-
IMarkdownNavigatorWindowConfig.prototype.compareWith;
|
|
859
|
-
/** @type {?|undefined} */
|
|
860
|
-
IMarkdownNavigatorWindowConfig.prototype.copyCodeToClipboard;
|
|
861
|
-
/** @type {?|undefined} */
|
|
862
|
-
IMarkdownNavigatorWindowConfig.prototype.copyCodeTooltips;
|
|
863
|
-
/** @type {?|undefined} */
|
|
864
|
-
IMarkdownNavigatorWindowConfig.prototype.footer;
|
|
865
|
-
}
|
|
866
|
-
/** @type {?} */
|
|
867
|
-
const CDK_OVERLAY_CUSTOM_CLASS = 'td-window-dialog';
|
|
868
|
-
/** @type {?} */
|
|
869
|
-
const DEFAULT_POSITION = { bottom: '0px', right: '0px' };
|
|
870
|
-
/** @type {?} */
|
|
871
|
-
const DEFAULT_WIDTH = '360px';
|
|
872
|
-
/** @type {?} */
|
|
873
|
-
const DEFAULT_HEIGHT = '75vh';
|
|
874
|
-
/** @type {?} */
|
|
875
|
-
const MIN_HEIGHT = '56px';
|
|
876
|
-
/** @type {?} */
|
|
877
|
-
const MAX_WIDTH = '100vw';
|
|
878
|
-
/** @type {?} */
|
|
879
|
-
const DEFAULT_DRAGGABLE_DIALOG_CONFIG = {
|
|
880
|
-
hasBackdrop: false,
|
|
881
|
-
closeOnNavigation: true,
|
|
882
|
-
panelClass: [CDK_OVERLAY_CUSTOM_CLASS],
|
|
883
|
-
position: DEFAULT_POSITION,
|
|
884
|
-
height: DEFAULT_HEIGHT,
|
|
885
|
-
width: DEFAULT_WIDTH,
|
|
886
|
-
maxWidth: MAX_WIDTH,
|
|
887
|
-
};
|
|
888
|
-
/**
|
|
889
|
-
* @record
|
|
890
|
-
*/
|
|
891
|
-
function IDialogDimensions() { }
|
|
892
|
-
if (false) {
|
|
893
|
-
/** @type {?} */
|
|
894
|
-
IDialogDimensions.prototype.width;
|
|
895
|
-
/** @type {?} */
|
|
896
|
-
IDialogDimensions.prototype.height;
|
|
897
|
-
}
|
|
898
|
-
class TdMarkdownNavigatorWindowService {
|
|
899
|
-
/**
|
|
900
|
-
* @param {?} _tdDialogService
|
|
901
|
-
* @param {?} _document
|
|
902
|
-
* @param {?} rendererFactory
|
|
903
|
-
*/
|
|
904
|
-
constructor(_tdDialogService, _document, rendererFactory) {
|
|
905
|
-
this._tdDialogService = _tdDialogService;
|
|
906
|
-
this._document = _document;
|
|
907
|
-
this.rendererFactory = rendererFactory;
|
|
908
|
-
this.markdownNavigatorWindowDialog = undefined;
|
|
909
|
-
this.markdownNavigatorWindowDialogsOpen = 0;
|
|
910
|
-
this._renderer2 = rendererFactory.createRenderer(undefined, undefined);
|
|
911
|
-
}
|
|
912
|
-
/**
|
|
913
|
-
* @param {?} config
|
|
914
|
-
* @return {?}
|
|
915
|
-
*/
|
|
916
|
-
open(config) {
|
|
917
|
-
this.close();
|
|
918
|
-
/** @type {?} */
|
|
919
|
-
let panelClass = [...DEFAULT_DRAGGABLE_DIALOG_CONFIG.panelClass];
|
|
920
|
-
if (config.dialogConfig && config.dialogConfig.panelClass) {
|
|
921
|
-
if (Array.isArray(config.dialogConfig.panelClass)) {
|
|
922
|
-
panelClass = [...config.dialogConfig.panelClass];
|
|
923
|
-
}
|
|
924
|
-
else {
|
|
925
|
-
panelClass = [config.dialogConfig.panelClass];
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
/** @type {?} */
|
|
929
|
-
const draggableConfig = Object.assign(Object.assign(Object.assign({}, DEFAULT_DRAGGABLE_DIALOG_CONFIG), config.dialogConfig), { panelClass });
|
|
930
|
-
const { matDialogRef, dragRefSubject } = this._tdDialogService.openDraggable({
|
|
931
|
-
component: TdMarkdownNavigatorWindowComponent,
|
|
932
|
-
config: draggableConfig,
|
|
933
|
-
dragHandleSelectors: ['.td-window-dialog-toolbar'],
|
|
934
|
-
draggableClass: 'td-draggable-markdown-navigator-window',
|
|
935
|
-
});
|
|
936
|
-
this.markdownNavigatorWindowDialog = matDialogRef;
|
|
937
|
-
this.markdownNavigatorWindowDialog.componentInstance.items = config.items;
|
|
938
|
-
this.markdownNavigatorWindowDialog.componentInstance.labels = config.labels;
|
|
939
|
-
this.markdownNavigatorWindowDialog.componentInstance.startAt = config.startAt;
|
|
940
|
-
this.markdownNavigatorWindowDialog.componentInstance.copyCodeToClipboard = config.copyCodeToClipboard;
|
|
941
|
-
this.markdownNavigatorWindowDialog.componentInstance.copyCodeTooltips = config.copyCodeTooltips;
|
|
942
|
-
this.markdownNavigatorWindowDialog.componentInstance.compareWith = config.compareWith;
|
|
943
|
-
this.markdownNavigatorWindowDialog.componentInstance.toolbarColor =
|
|
944
|
-
'toolbarColor' in config ? config.toolbarColor : 'primary';
|
|
945
|
-
this.markdownNavigatorWindowDialogsOpen++;
|
|
946
|
-
this.markdownNavigatorWindowDialog.componentInstance.footer = config.footer;
|
|
947
|
-
dragRefSubject.subscribe((/**
|
|
948
|
-
* @param {?} dragRf
|
|
949
|
-
* @return {?}
|
|
950
|
-
*/
|
|
951
|
-
(dragRf) => {
|
|
952
|
-
this.dragRef = dragRf;
|
|
953
|
-
this.resizableDraggableDialog = new ResizableDraggableDialog(this._document, this._renderer2, this.markdownNavigatorWindowDialog, this.dragRef);
|
|
954
|
-
}));
|
|
955
|
-
this._handleEvents();
|
|
956
|
-
return this.markdownNavigatorWindowDialog;
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* @return {?}
|
|
960
|
-
*/
|
|
961
|
-
close() {
|
|
962
|
-
if (this.markdownNavigatorWindowDialog) {
|
|
963
|
-
if (this.resizableDraggableDialog) {
|
|
964
|
-
this.resizableDraggableDialog.detach();
|
|
965
|
-
}
|
|
966
|
-
this.markdownNavigatorWindowDialog.close();
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
/**
|
|
970
|
-
* @return {?}
|
|
971
|
-
*/
|
|
972
|
-
get isOpen() {
|
|
973
|
-
return this.markdownNavigatorWindowDialogsOpen > 0;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* @private
|
|
977
|
-
* @return {?}
|
|
978
|
-
*/
|
|
979
|
-
_handleEvents() {
|
|
980
|
-
/** @type {?} */
|
|
981
|
-
let position;
|
|
982
|
-
/** @type {?} */
|
|
983
|
-
let dimensions;
|
|
984
|
-
this.markdownNavigatorWindowDialog.componentInstance.closed.subscribe((/**
|
|
985
|
-
* @return {?}
|
|
986
|
-
*/
|
|
987
|
-
() => this.close()));
|
|
988
|
-
this.markdownNavigatorWindowDialog.componentInstance.dockToggled.subscribe((/**
|
|
989
|
-
* @param {?} docked
|
|
990
|
-
* @return {?}
|
|
991
|
-
*/
|
|
992
|
-
(docked) => {
|
|
993
|
-
if (docked) {
|
|
994
|
-
this.markdownNavigatorWindowDialog.componentInstance.docked = false;
|
|
995
|
-
this.markdownNavigatorWindowDialog.updateSize(dimensions.width, dimensions.height);
|
|
996
|
-
this.markdownNavigatorWindowDialog.updatePosition({ top: '0px', right: '0px', bottom: '0px', left: '0px' });
|
|
997
|
-
this.dragRef.setFreeDragPosition(position);
|
|
998
|
-
this.dragRef.disabled = false;
|
|
999
|
-
this.resizableDraggableDialog.attach();
|
|
1000
|
-
}
|
|
1001
|
-
else {
|
|
1002
|
-
dimensions = this._getDialogSize(this.markdownNavigatorWindowDialog);
|
|
1003
|
-
position = this.dragRef.getFreeDragPosition();
|
|
1004
|
-
this.markdownNavigatorWindowDialog.componentInstance.docked = true;
|
|
1005
|
-
this.markdownNavigatorWindowDialog.updateSize(DEFAULT_WIDTH, MIN_HEIGHT);
|
|
1006
|
-
this.markdownNavigatorWindowDialog.updatePosition(DEFAULT_POSITION);
|
|
1007
|
-
this.dragRef.reset();
|
|
1008
|
-
this.dragRef.disabled = true;
|
|
1009
|
-
this.resizableDraggableDialog.detach();
|
|
1010
|
-
}
|
|
1011
|
-
}));
|
|
1012
|
-
this.markdownNavigatorWindowDialog
|
|
1013
|
-
.afterClosed()
|
|
1014
|
-
.toPromise()
|
|
1015
|
-
.then((/**
|
|
1016
|
-
* @return {?}
|
|
1017
|
-
*/
|
|
1018
|
-
() => {
|
|
1019
|
-
this.markdownNavigatorWindowDialogsOpen--;
|
|
1020
|
-
}));
|
|
1021
|
-
}
|
|
1022
|
-
/**
|
|
1023
|
-
* @private
|
|
1024
|
-
* @param {?} dialogRef
|
|
1025
|
-
* @return {?}
|
|
1026
|
-
*/
|
|
1027
|
-
_getDialogSize(dialogRef) {
|
|
1028
|
-
const { width, height } = getComputedStyle(((/** @type {?} */ (this._document.getElementById(dialogRef.id)))).parentElement);
|
|
1029
|
-
return {
|
|
1030
|
-
width,
|
|
1031
|
-
height,
|
|
1032
|
-
};
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
TdMarkdownNavigatorWindowService.decorators = [
|
|
1036
|
-
{ type: Injectable }
|
|
1037
|
-
];
|
|
1038
|
-
/** @nocollapse */
|
|
1039
|
-
TdMarkdownNavigatorWindowService.ctorParameters = () => [
|
|
1040
|
-
{ type: TdDialogService },
|
|
1041
|
-
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
1042
|
-
{ type: RendererFactory2 }
|
|
1043
|
-
];
|
|
1044
|
-
if (false) {
|
|
1045
|
-
/**
|
|
1046
|
-
* @type {?}
|
|
1047
|
-
* @private
|
|
1048
|
-
*/
|
|
1049
|
-
TdMarkdownNavigatorWindowService.prototype._renderer2;
|
|
1050
|
-
/**
|
|
1051
|
-
* @type {?}
|
|
1052
|
-
* @private
|
|
1053
|
-
*/
|
|
1054
|
-
TdMarkdownNavigatorWindowService.prototype.dragRef;
|
|
1055
|
-
/**
|
|
1056
|
-
* @type {?}
|
|
1057
|
-
* @private
|
|
1058
|
-
*/
|
|
1059
|
-
TdMarkdownNavigatorWindowService.prototype.resizableDraggableDialog;
|
|
1060
|
-
/**
|
|
1061
|
-
* @type {?}
|
|
1062
|
-
* @private
|
|
1063
|
-
*/
|
|
1064
|
-
TdMarkdownNavigatorWindowService.prototype.markdownNavigatorWindowDialog;
|
|
1065
|
-
/**
|
|
1066
|
-
* @type {?}
|
|
1067
|
-
* @private
|
|
1068
|
-
*/
|
|
1069
|
-
TdMarkdownNavigatorWindowService.prototype.markdownNavigatorWindowDialogsOpen;
|
|
1070
|
-
/**
|
|
1071
|
-
* @type {?}
|
|
1072
|
-
* @private
|
|
1073
|
-
*/
|
|
1074
|
-
TdMarkdownNavigatorWindowService.prototype._tdDialogService;
|
|
1075
|
-
/**
|
|
1076
|
-
* @type {?}
|
|
1077
|
-
* @private
|
|
1078
|
-
*/
|
|
1079
|
-
TdMarkdownNavigatorWindowService.prototype._document;
|
|
1080
|
-
/**
|
|
1081
|
-
* @type {?}
|
|
1082
|
-
* @private
|
|
1083
|
-
*/
|
|
1084
|
-
TdMarkdownNavigatorWindowService.prototype.rendererFactory;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
/**
|
|
1088
|
-
* @fileoverview added by tsickle
|
|
1089
|
-
* Generated from: markdown-navigator-window-directive/markdown-navigator-window.directive.ts
|
|
1090
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1091
|
-
*/
|
|
1092
|
-
class TdMarkdownNavigatorWindowDirective {
|
|
1093
|
-
/**
|
|
1094
|
-
* @param {?} _markdownNavigatorWindowService
|
|
1095
|
-
*/
|
|
1096
|
-
constructor(_markdownNavigatorWindowService) {
|
|
1097
|
-
this._markdownNavigatorWindowService = _markdownNavigatorWindowService;
|
|
1098
|
-
this.disabled = false;
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* @return {?}
|
|
1102
|
-
*/
|
|
1103
|
-
click() {
|
|
1104
|
-
if (!this.disabled) {
|
|
1105
|
-
this._markdownNavigatorWindowService.open(this.config);
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
TdMarkdownNavigatorWindowDirective.decorators = [
|
|
1110
|
-
{ type: Directive, args: [{
|
|
1111
|
-
selector: '[tdMarkdownNavigatorWindow]',
|
|
1112
|
-
},] }
|
|
1113
|
-
];
|
|
1114
|
-
/** @nocollapse */
|
|
1115
|
-
TdMarkdownNavigatorWindowDirective.ctorParameters = () => [
|
|
1116
|
-
{ type: TdMarkdownNavigatorWindowService }
|
|
1117
|
-
];
|
|
1118
|
-
TdMarkdownNavigatorWindowDirective.propDecorators = {
|
|
1119
|
-
config: [{ type: Input, args: ['tdMarkdownNavigatorWindow',] }],
|
|
1120
|
-
disabled: [{ type: Input }],
|
|
1121
|
-
click: [{ type: HostListener, args: ['click',] }]
|
|
1122
|
-
};
|
|
1123
|
-
if (false) {
|
|
1124
|
-
/** @type {?} */
|
|
1125
|
-
TdMarkdownNavigatorWindowDirective.prototype.config;
|
|
1126
|
-
/** @type {?} */
|
|
1127
|
-
TdMarkdownNavigatorWindowDirective.prototype.disabled;
|
|
1128
|
-
/**
|
|
1129
|
-
* @type {?}
|
|
1130
|
-
* @private
|
|
1131
|
-
*/
|
|
1132
|
-
TdMarkdownNavigatorWindowDirective.prototype._markdownNavigatorWindowService;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
/**
|
|
1136
|
-
* @fileoverview added by tsickle
|
|
1137
|
-
* Generated from: markdown-navigator.module.ts
|
|
1138
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1139
|
-
*/
|
|
1140
|
-
class CovalentMarkdownNavigatorModule {
|
|
1141
|
-
}
|
|
1142
|
-
CovalentMarkdownNavigatorModule.decorators = [
|
|
1143
|
-
{ type: NgModule, args: [{
|
|
1144
|
-
imports: [
|
|
1145
|
-
CommonModule,
|
|
1146
|
-
// material
|
|
1147
|
-
MatButtonModule,
|
|
1148
|
-
MatTooltipModule,
|
|
1149
|
-
MatListModule,
|
|
1150
|
-
MatIconModule,
|
|
1151
|
-
MatProgressBarModule,
|
|
1152
|
-
CovalentMessageModule,
|
|
1153
|
-
CovalentFlavoredMarkdownModule,
|
|
1154
|
-
CovalentDialogsModule,
|
|
1155
|
-
],
|
|
1156
|
-
declarations: [TdMarkdownNavigatorComponent, TdMarkdownNavigatorWindowComponent, TdMarkdownNavigatorWindowDirective],
|
|
1157
|
-
exports: [TdMarkdownNavigatorComponent, TdMarkdownNavigatorWindowComponent, TdMarkdownNavigatorWindowDirective],
|
|
1158
|
-
providers: [TdMarkdownNavigatorWindowService],
|
|
1159
|
-
},] }
|
|
1160
|
-
];
|
|
1161
|
-
|
|
1162
|
-
/**
|
|
1163
|
-
* @fileoverview added by tsickle
|
|
1164
|
-
* Generated from: public-api.ts
|
|
1165
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1166
|
-
*/
|
|
1167
|
-
|
|
1168
|
-
/**
|
|
1169
|
-
* @fileoverview added by tsickle
|
|
1170
|
-
* Generated from: index.ts
|
|
1171
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1172
|
-
*/
|
|
1173
|
-
|
|
1174
|
-
/**
|
|
1175
|
-
* @fileoverview added by tsickle
|
|
1176
|
-
* Generated from: covalent-markdown-navigator.ts
|
|
1177
|
-
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1178
|
-
*/
|
|
1179
|
-
|
|
1180
|
-
export { CovalentMarkdownNavigatorModule, DEFAULT_MARKDOWN_NAVIGATOR_LABELS, DEFAULT_MARKDOWN_NAVIGATOR_WINDOW_LABELS, TdMarkdownNavigatorComponent, TdMarkdownNavigatorWindowComponent, TdMarkdownNavigatorWindowService, TdMarkdownNavigatorWindowDirective as ɵa };
|
|
1181
|
-
//# sourceMappingURL=covalent-markdown-navigator.js.map
|