@operato/help 10.29.33 → 10.29.34
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/CHANGELOG.md +9 -0
- package/coverage/lcov-report/index.html +1047 -72
- package/coverage/lcov.info +48067 -5437
- package/dist/src/components/ox-doc.d.ts +2 -0
- package/dist/src/components/ox-doc.js +8 -1
- package/dist/src/components/ox-doc.js.map +1 -1
- package/dist/src/components/ox-help-spot.d.ts +2 -12
- package/dist/src/components/ox-help-spot.js +23 -96
- package/dist/src/components/ox-help-spot.js.map +1 -1
- package/dist/src/controller/help.d.ts +5 -1
- package/dist/src/controller/help.js +7 -2
- package/dist/src/controller/help.js.map +1 -1
- package/dist/src/help-documents.d.ts +6 -0
- package/dist/src/help-documents.js +31 -0
- package/dist/src/help-documents.js.map +1 -0
- package/dist/src/pages/ox-help-home.d.ts +1 -0
- package/dist/src/pages/ox-help-home.js +29 -2
- package/dist/src/pages/ox-help-home.js.map +1 -1
- package/dist/src/viewparts/ox-help-panel.d.ts +1 -0
- package/dist/src/viewparts/ox-help-panel.js +35 -2
- package/dist/src/viewparts/ox-help-panel.js.map +1 -1
- package/dist/test/ox-doc.test.d.ts +1 -0
- package/dist/test/ox-doc.test.js +39 -37
- package/dist/test/ox-doc.test.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/test/ox-doc.test.ts +42 -44
- package/translations/en.json +0 -4
- package/translations/es.json +0 -4
- package/translations/ja.json +0 -4
- package/translations/ko.json +0 -4
- package/translations/ms.json +0 -4
- package/translations/zh.json +0 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-help-home.js","sourceRoot":"","sources":["../../../src/pages/ox-help-home.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"ox-help-home.js","sourceRoot":"","sources":["../../../src/pages/ox-help-home.ts"],"names":[],"mappings":";AAAA,OAAO,4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Aa,CAAC;4CAAyB;AA9D1C,QAAQ;IADb,aAAa,CAAC,cAAc,CAAC;GACxB,QAAQ,CAqIb","sourcesContent":["import '@material/web/icon/icon.js'\nimport '../components/ox-doc.js'\n\nimport { css, html } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport Headroom from '@operato/headroom'\nimport { i18next, localize } from '@operato/i18n'\nimport { navigate, PageView } from '@operato/shell'\nimport { HeadroomStyles, ScrollbarStyles } from '@operato/styles'\nimport { helpFormatOf } from '../help-documents.js'\n\n@customElement('ox-help-home')\nclass HelpHome extends localize(i18next)(PageView) {\n static styles = [\n ScrollbarStyles,\n HeadroomStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n overflow: hidden;\n position: relative;\n\n --md-icon-size: 24px;\n }\n\n #navigation {\n position: absolute;\n display: flex;\n width: 100%;\n padding: var(--help-navigation-padding);\n border-bottom: var(--help-navigation-bottom);\n background-color: var(--md-sys-color-surface);\n }\n\n #navigation md-icon {\n padding: var(--help-navigation-icon-padding, var(--padding-default));\n border-right: var(--help-navigation-icon-border);\n cursor: pointer;\n color: var(--help-icon-color);\n }\n\n #content {\n flex: 1;\n\n overflow: auto;\n padding: var(--help-panel-content-padding);\n margin: var(--help-panel-margin);\n }\n\n #upward {\n --md-icon-size: 26px;\n position: absolute;\n bottom: var(--data-list-fab-position-vertical);\n right: var(--data-list-fab-position-horizontal);\n background-color: rgba(255, 255, 255, 0.7);\n border-radius: 20px;\n color: var(--data-list-fab-color);\n box-shadow: var(--data-list-fab-shadow);\n padding: 7px;\n\n scroll-padding-top: 65px;\n }\n `\n ]\n\n @property({ type: String }) topic!: string\n /** The section to open at - the part a `?` showed in the help overlay. */\n @property({ type: String }) section: string = ''\n @property({ type: Boolean }) showGotoTop: boolean = false\n /** How the topic is written (`helpFormatOf`): an html document or the markdown this page always read. */\n @state() format?: 'html' | 'md'\n\n @query('#content') content!: HTMLElement\n @query('#navigation') navigation!: HTMLElement\n\n get context() {\n return {\n title: i18next.t('text.help')\n }\n }\n\n render() {\n const src = this.topic && `/helps/${this.topic || 'index'}.md`\n\n return html`\n <div id=\"content\">\n ${this.format === 'html'\n ? html`<ox-doc topic=${this.topic} anchor=${this.section}></ox-doc>`\n : this.format === 'md'\n ? html`<ox-markdown .src=${src} toc></ox-markdown>`\n : ''}\n </div>\n\n <div id=\"navigation\">\n <md-icon @click=${() => navigate('help')} ?disabled=${this.topic == 'index'}>home</md-icon>\n <md-icon @click=${() => window.history.back()}>keyboard_arrow_left</md-icon>\n <md-icon @click=${() => window.history.forward()}>keyboard_arrow_right</md-icon>\n </div>\n\n ${this.showGotoTop\n ? html` <md-icon id=\"upward\" @click=${(e: Event) => this.gotoTop(e)}>arrow_upward</md-icon> `\n : html``}\n `\n }\n\n override async firstUpdated() {\n this.content.addEventListener('scroll', (e: Event) => {\n this.showGotoTop = (e.target as HTMLElement)?.scrollTop !== 0\n })\n\n await this.requestUpdate()\n\n var originPaddingTop = parseFloat(getComputedStyle(this.content, null).getPropertyValue('padding-top'))\n this.content.style.paddingTop = this.navigation.clientHeight + originPaddingTop + 'px'\n\n var headroom = new Headroom(this.navigation, {\n scroller: this.content\n })\n\n headroom.init()\n }\n\n override async pageUpdated(changes: any, lifecycle: any) {\n if (this.active) {\n this.topic = lifecycle.params['topic'] || 'index'\n this.section = lifecycle.params['section'] || ''\n this.content.scrollTop = 0\n }\n }\n\n updated(changes: Map<string, unknown>) {\n super.updated?.(changes as any)\n if (changes.has('topic')) {\n const topic = this.topic\n this.format = undefined\n if (topic) helpFormatOf(topic, i18next?.language ?? 'en').then(format => topic === this.topic && (this.format = format))\n }\n }\n\n gotoTop(e: Event) {\n this.content.scrollTop = 0\n\n e.stopPropagation()\n }\n}\n"]}
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import '@material/web/icon/icon.js';
|
|
3
3
|
import '@operato/markdown/ox-markdown.js';
|
|
4
|
+
import '../components/ox-doc.js';
|
|
4
5
|
import { css, html, LitElement } from 'lit';
|
|
5
6
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
6
7
|
import Headroom from '@operato/headroom';
|
|
7
8
|
import { closeOverlay } from '@operato/layout';
|
|
8
9
|
import { navigate } from '@operato/shell';
|
|
10
|
+
import { i18next } from '@operato/i18n';
|
|
9
11
|
import { HeadroomStyles, ScrollbarStyles } from '@operato/styles';
|
|
12
|
+
import { helpFormatOf } from '../help-documents.js';
|
|
10
13
|
let HelpPanel = class HelpPanel extends LitElement {
|
|
11
14
|
constructor() {
|
|
12
15
|
super(...arguments);
|
|
16
|
+
/** The one section a `?` asked about; the overlay shows that part, and 「open in new」 the whole document at it. */
|
|
17
|
+
this.section = '';
|
|
13
18
|
this.showGotoTop = false;
|
|
14
19
|
this.historyIndex = -1;
|
|
15
20
|
this.history = [];
|
|
16
21
|
}
|
|
17
22
|
render() {
|
|
18
23
|
const src = this.topic && `/helps/${this.topic}.md`;
|
|
24
|
+
const full = `help?topic=${encodeURIComponent(this.topic)}${this.section ? `§ion=${encodeURIComponent(this.section)}` : ''}`;
|
|
19
25
|
return html `
|
|
20
26
|
<div id="navigation">
|
|
21
27
|
<md-icon filled @click=${() => this.goHome()} ?disabled=${this.history[0] === this.history[this.historyIndex]}>
|
|
@@ -27,14 +33,20 @@ let HelpPanel = class HelpPanel extends LitElement {
|
|
|
27
33
|
<md-icon filled @click=${() => this.historyForward()} ?disabled=${this.historyIndex >= this.history.length - 1}>
|
|
28
34
|
keyboard_arrow_right
|
|
29
35
|
</md-icon>
|
|
30
|
-
<md-icon filled @click=${() => navigate(
|
|
36
|
+
<md-icon filled @click=${() => navigate(full)}> open_in_new </md-icon>
|
|
31
37
|
<md-icon filled id="close" @click=${() => closeOverlay('help')}> close </md-icon>
|
|
32
38
|
</div>
|
|
33
39
|
|
|
34
40
|
${!this.showGotoTop
|
|
35
41
|
? html ``
|
|
36
42
|
: html ` <md-icon filled id="upward" @click=${(e) => this.gotoTop(e)}>arrow_upward</md-icon> `}
|
|
37
|
-
<
|
|
43
|
+
<div id="content">
|
|
44
|
+
${this.format === 'html'
|
|
45
|
+
? html `<ox-doc compact topic=${this.topic} section=${this.section} @ox-doc-topic=${(e) => this.follow(e.detail.topic)}></ox-doc>`
|
|
46
|
+
: this.format === 'md'
|
|
47
|
+
? html `<ox-markdown .src=${src}></ox-markdown>`
|
|
48
|
+
: ''}
|
|
49
|
+
</div>
|
|
38
50
|
`;
|
|
39
51
|
}
|
|
40
52
|
async firstUpdated() {
|
|
@@ -52,13 +64,21 @@ let HelpPanel = class HelpPanel extends LitElement {
|
|
|
52
64
|
headroom.init();
|
|
53
65
|
}
|
|
54
66
|
async updated(changes) {
|
|
67
|
+
var _a;
|
|
55
68
|
if (changes.has('topic')) {
|
|
69
|
+
const topic = this.topic;
|
|
70
|
+
this.format = undefined;
|
|
71
|
+
if (topic)
|
|
72
|
+
helpFormatOf(topic, (_a = i18next === null || i18next === void 0 ? void 0 : i18next.language) !== null && _a !== void 0 ? _a : 'en').then(format => topic === this.topic && (this.format = format));
|
|
56
73
|
if (this.historyIndex === -1) {
|
|
57
74
|
this.history = [this.topic];
|
|
58
75
|
this.historyIndex = 0;
|
|
59
76
|
}
|
|
60
77
|
}
|
|
61
78
|
if (changes.has('historyIndex')) {
|
|
79
|
+
/* Moving through the history leaves the section the `?` opened at. */
|
|
80
|
+
if (this.history[this.historyIndex] !== this.topic)
|
|
81
|
+
this.section = '';
|
|
62
82
|
this.topic = this.history[this.historyIndex];
|
|
63
83
|
this.content.scrollTop = 0;
|
|
64
84
|
}
|
|
@@ -93,6 +113,13 @@ let HelpPanel = class HelpPanel extends LitElement {
|
|
|
93
113
|
return;
|
|
94
114
|
});
|
|
95
115
|
}
|
|
116
|
+
/** A link inside an html document took it to another topic: the overlay follows, as with a markdown link. */
|
|
117
|
+
follow(topic) {
|
|
118
|
+
if (!topic || topic === this.topic)
|
|
119
|
+
return;
|
|
120
|
+
this.history = [...this.history.slice(0, this.historyIndex + 1), topic];
|
|
121
|
+
this.historyIndex++;
|
|
122
|
+
}
|
|
96
123
|
gotoTop(e) {
|
|
97
124
|
this.content.scrollTop = 0;
|
|
98
125
|
e.stopPropagation();
|
|
@@ -195,9 +222,15 @@ HelpPanel.styles = [
|
|
|
195
222
|
__decorate([
|
|
196
223
|
property({ type: String })
|
|
197
224
|
], HelpPanel.prototype, "topic", void 0);
|
|
225
|
+
__decorate([
|
|
226
|
+
property({ type: String })
|
|
227
|
+
], HelpPanel.prototype, "section", void 0);
|
|
198
228
|
__decorate([
|
|
199
229
|
property({ type: Boolean })
|
|
200
230
|
], HelpPanel.prototype, "showGotoTop", void 0);
|
|
231
|
+
__decorate([
|
|
232
|
+
state()
|
|
233
|
+
], HelpPanel.prototype, "format", void 0);
|
|
201
234
|
__decorate([
|
|
202
235
|
state()
|
|
203
236
|
], HelpPanel.prototype, "historyIndex", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-help-panel.js","sourceRoot":"","sources":["../../../src/viewparts/ox-help-panel.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,kCAAkC,CAAA;AAEzC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAGjE,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,UAAU;IAAlC;;QAmF+B,gBAAW,GAAY,KAAK,CAAA;QAEhD,iBAAY,GAAW,CAAC,CAAC,CAAA;QACzB,YAAO,GAAa,EAA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on.js'\nimport '@operato/markdown/ox-markdown.js'\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport Headroom from '@operato/headroom'\nimport { closeOverlay } from '@operato/layout'\nimport { navigate } from '@operato/shell'\nimport { HeadroomStyles, ScrollbarStyles } from '@operato/styles'\n\n@customElement('ox-help-panel')\nclass HelpPanel extends LitElement {\n static styles = [\n ScrollbarStyles,\n HeadroomStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--help-panel-background-color);\n\n position: relative;\n width: var(--help-panel-width);\n max-height: 90%;\n border-radius: var(--help-panel-border-raidus);\n border: var(--help-panel-border);\n box-shadow: var(--help-panel-box-shadow);\n color: var(--help-panel-color);\n margin: 4px;\n\n overflow: hidden;\n\n --md-icon-size: 24px;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n #navigation {\n display: flex;\n position: absolute;\n width: 100%;\n padding: var(--help-navigation-padding);\n border-bottom: var(--help-navigation-bottom);\n background-color: var(--md-sys-color-surface);\n }\n\n #navigation md-icon {\n padding: var(--help-navigation-icon-padding, var(--padding-default));\n border-right: var(--help-navigation-icon-border);\n cursor: pointer;\n color: var(--help-icon-color);\n }\n\n #close {\n margin-left: auto;\n border-right: 0;\n }\n\n #content {\n flex: 1;\n overflow: auto;\n padding: var(--help-panel-content-padding);\n margin: var(--help-panel-margin);\n }\n\n #upward {\n --md-icon-size: 26px;\n position: absolute;\n bottom: var(--data-list-fab-position-vertical);\n right: var(--data-list-fab-position-horizontal);\n background-color: rgba(255, 255, 255, 0.7);\n border-radius: 20px;\n color: var(--data-list-fab-color);\n box-shadow: var(--data-list-fab-shadow);\n padding: 7px;\n }\n\n md-icon[filled] {\n font-variation-settings: 'FILL' 1;\n }\n\n @media screen and (max-width: 460px) {\n :host {\n height: 100%;\n max-height: 100%;\n margin: 0;\n }\n }\n `\n ]\n\n @property({ type: String }) topic!: string\n @property({ type: Boolean }) showGotoTop: boolean = false\n\n @state() historyIndex: number = -1\n @state() history: string[] = []\n\n @query('#content') content!: HTMLElement\n @query('#navigation') navigation!: HTMLElement\n\n render() {\n const src = this.topic && `/helps/${this.topic}.md`\n\n return html`\n <div id=\"navigation\">\n <md-icon filled @click=${() => this.goHome()} ?disabled=${this.history[0] === this.history[this.historyIndex]}>\n home\n </md-icon>\n <md-icon filled @click=${() => this.historyBack()} ?disabled=${this.historyIndex < 1}>\n keyboard_arrow_left\n </md-icon>\n <md-icon filled @click=${() => this.historyForward()} ?disabled=${this.historyIndex >= this.history.length - 1}>\n keyboard_arrow_right\n </md-icon>\n <md-icon filled @click=${() => navigate(`help?topic=${this.topic}`)}> open_in_new </md-icon>\n <md-icon filled id=\"close\" @click=${() => closeOverlay('help')}> close </md-icon>\n </div>\n\n ${!this.showGotoTop\n ? html``\n : html` <md-icon filled id=\"upward\" @click=${(e: Event) => this.gotoTop(e)}>arrow_upward</md-icon> `}\n <ox-markdown id=\"content\" .src=${src}></ox-markdown>\n `\n }\n\n async firstUpdated() {\n this.setupRouter()\n\n this.content.addEventListener('scroll', (e: Event) => {\n this.showGotoTop = (e.target as HTMLElement)?.scrollTop !== 0\n })\n\n await this.requestUpdate()\n\n var originPaddingTop = parseFloat(getComputedStyle(this.content, null).getPropertyValue('padding-top'))\n this.content.style.paddingTop = this.navigation.clientHeight + originPaddingTop + 'px'\n\n var headroom = new Headroom(this.navigation, {\n scroller: this.content\n })\n headroom.init()\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('topic')) {\n if (this.historyIndex === -1) {\n this.history = [this.topic]\n this.historyIndex = 0\n }\n }\n\n if (changes.has('historyIndex')) {\n this.topic = this.history[this.historyIndex]\n this.content.scrollTop = 0\n }\n }\n\n setupRouter() {\n this.addEventListener('click', e => {\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey) {\n return\n }\n\n const anchor = e.composedPath().filter(n => (n as HTMLElement).tagName === 'A')[0] as HTMLAnchorElement\n if (!anchor || anchor.target || anchor.hasAttribute('download') || anchor.getAttribute('rel') === 'external') {\n return\n }\n\n const href = anchor.href\n const newUrl = new URL(href, document.baseURI)\n if (!href || href.indexOf('mailto:') !== -1 || newUrl.origin !== location.origin) {\n return\n }\n\n e.preventDefault()\n e.stopPropagation()\n\n const pathname = newUrl.pathname\n const topic = newUrl.searchParams?.get('topic')\n if (pathname.endsWith('/help') && topic) {\n this.history = [...this.history.slice(0, this.historyIndex + 1), topic]\n this.historyIndex++\n this.topic = topic\n } else {\n navigate(href)\n }\n\n return\n })\n }\n\n gotoTop(e: Event) {\n this.content.scrollTop = 0\n\n e.stopPropagation()\n }\n\n goHome() {\n if (!this.history?.[0] || this.history[0] == this.topic) {\n return\n }\n this.history.push(this.history[0])\n this.historyIndex = this.history.length - 1\n }\n\n historyBack() {\n this.historyIndex > 0 && this.historyIndex--\n }\n\n historyForward() {\n this.history && this.historyIndex < this.history.length - 1 && this.historyIndex++\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ox-help-panel.js","sourceRoot":"","sources":["../../../src/viewparts/ox-help-panel.ts"],"names":[],"mappings":";AAAA,OAAO,4BAA4B,CAAA;AACnC,OAAO,kCAAkC,CAAA;AACzC,OAAO,yBAAyB,CAAA;AAEhC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAA;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,QAAQ,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;A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,MAAM,EAAE,CAAC;0CAAqB;AACnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAA6B;AAEhD;IAAR,KAAK,EAAE;yCAAuB;AAEtB;IAAR,KAAK,EAAE;+CAA0B;AACzB;IAAR,KAAK,EAAE;0CAAuB;AAEZ;IAAlB,KAAK,CAAC,UAAU,CAAC;0CAAsB;AAClB;IAArB,KAAK,CAAC,aAAa,CAAC;6CAAyB;AA7F1C,SAAS;IADd,aAAa,CAAC,eAAe,CAAC;GACzB,SAAS,CAkOd","sourcesContent":["import '@material/web/icon/icon.js'\nimport '@operato/markdown/ox-markdown.js'\nimport '../components/ox-doc.js'\n\nimport { css, html, LitElement, PropertyValues } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport Headroom from '@operato/headroom'\nimport { closeOverlay } from '@operato/layout'\nimport { navigate } from '@operato/shell'\nimport { i18next } from '@operato/i18n'\nimport { HeadroomStyles, ScrollbarStyles } from '@operato/styles'\nimport { helpFormatOf } from '../help-documents.js'\n\n@customElement('ox-help-panel')\nclass HelpPanel extends LitElement {\n static styles = [\n ScrollbarStyles,\n HeadroomStyles,\n css`\n :host {\n display: flex;\n flex-direction: column;\n background-color: var(--help-panel-background-color);\n\n position: relative;\n width: var(--help-panel-width);\n max-height: 90%;\n border-radius: var(--help-panel-border-raidus);\n border: var(--help-panel-border);\n box-shadow: var(--help-panel-box-shadow);\n color: var(--help-panel-color);\n margin: 4px;\n\n overflow: hidden;\n\n --md-icon-size: 24px;\n }\n\n :host(:focus) {\n outline: none;\n }\n\n #navigation {\n display: flex;\n position: absolute;\n width: 100%;\n padding: var(--help-navigation-padding);\n border-bottom: var(--help-navigation-bottom);\n background-color: var(--md-sys-color-surface);\n }\n\n #navigation md-icon {\n padding: var(--help-navigation-icon-padding, var(--padding-default));\n border-right: var(--help-navigation-icon-border);\n cursor: pointer;\n color: var(--help-icon-color);\n }\n\n #close {\n margin-left: auto;\n border-right: 0;\n }\n\n #content {\n flex: 1;\n overflow: auto;\n padding: var(--help-panel-content-padding);\n margin: var(--help-panel-margin);\n }\n\n #upward {\n --md-icon-size: 26px;\n position: absolute;\n bottom: var(--data-list-fab-position-vertical);\n right: var(--data-list-fab-position-horizontal);\n background-color: rgba(255, 255, 255, 0.7);\n border-radius: 20px;\n color: var(--data-list-fab-color);\n box-shadow: var(--data-list-fab-shadow);\n padding: 7px;\n }\n\n md-icon[filled] {\n font-variation-settings: 'FILL' 1;\n }\n\n @media screen and (max-width: 460px) {\n :host {\n height: 100%;\n max-height: 100%;\n margin: 0;\n }\n }\n `\n ]\n\n @property({ type: String }) topic!: string\n /** The one section a `?` asked about; the overlay shows that part, and 「open in new」 the whole document at it. */\n @property({ type: String }) section: string = ''\n @property({ type: Boolean }) showGotoTop: boolean = false\n /** How the topic is written (`helpFormatOf`) - undefined while it is being asked. */\n @state() format?: 'html' | 'md'\n\n @state() historyIndex: number = -1\n @state() history: string[] = []\n\n @query('#content') content!: HTMLElement\n @query('#navigation') navigation!: HTMLElement\n\n render() {\n const src = this.topic && `/helps/${this.topic}.md`\n const full = `help?topic=${encodeURIComponent(this.topic)}${this.section ? `§ion=${encodeURIComponent(this.section)}` : ''}`\n\n return html`\n <div id=\"navigation\">\n <md-icon filled @click=${() => this.goHome()} ?disabled=${this.history[0] === this.history[this.historyIndex]}>\n home\n </md-icon>\n <md-icon filled @click=${() => this.historyBack()} ?disabled=${this.historyIndex < 1}>\n keyboard_arrow_left\n </md-icon>\n <md-icon filled @click=${() => this.historyForward()} ?disabled=${this.historyIndex >= this.history.length - 1}>\n keyboard_arrow_right\n </md-icon>\n <md-icon filled @click=${() => navigate(full)}> open_in_new </md-icon>\n <md-icon filled id=\"close\" @click=${() => closeOverlay('help')}> close </md-icon>\n </div>\n\n ${!this.showGotoTop\n ? html``\n : html` <md-icon filled id=\"upward\" @click=${(e: Event) => this.gotoTop(e)}>arrow_upward</md-icon> `}\n <div id=\"content\">\n ${this.format === 'html'\n ? html`<ox-doc compact topic=${this.topic} section=${this.section} @ox-doc-topic=${(e: CustomEvent) => this.follow(e.detail.topic)}></ox-doc>`\n : this.format === 'md'\n ? html`<ox-markdown .src=${src}></ox-markdown>`\n : ''}\n </div>\n `\n }\n\n async firstUpdated() {\n this.setupRouter()\n\n this.content.addEventListener('scroll', (e: Event) => {\n this.showGotoTop = (e.target as HTMLElement)?.scrollTop !== 0\n })\n\n await this.requestUpdate()\n\n var originPaddingTop = parseFloat(getComputedStyle(this.content, null).getPropertyValue('padding-top'))\n this.content.style.paddingTop = this.navigation.clientHeight + originPaddingTop + 'px'\n\n var headroom = new Headroom(this.navigation, {\n scroller: this.content\n })\n headroom.init()\n }\n\n async updated(changes: PropertyValues<this>) {\n if (changes.has('topic')) {\n const topic = this.topic\n this.format = undefined\n if (topic) helpFormatOf(topic, i18next?.language ?? 'en').then(format => topic === this.topic && (this.format = format))\n if (this.historyIndex === -1) {\n this.history = [this.topic]\n this.historyIndex = 0\n }\n }\n\n if (changes.has('historyIndex')) {\n /* Moving through the history leaves the section the `?` opened at. */\n if (this.history[this.historyIndex] !== this.topic) this.section = ''\n this.topic = this.history[this.historyIndex]\n this.content.scrollTop = 0\n }\n }\n\n setupRouter() {\n this.addEventListener('click', e => {\n if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey) {\n return\n }\n\n const anchor = e.composedPath().filter(n => (n as HTMLElement).tagName === 'A')[0] as HTMLAnchorElement\n if (!anchor || anchor.target || anchor.hasAttribute('download') || anchor.getAttribute('rel') === 'external') {\n return\n }\n\n const href = anchor.href\n const newUrl = new URL(href, document.baseURI)\n if (!href || href.indexOf('mailto:') !== -1 || newUrl.origin !== location.origin) {\n return\n }\n\n e.preventDefault()\n e.stopPropagation()\n\n const pathname = newUrl.pathname\n const topic = newUrl.searchParams?.get('topic')\n if (pathname.endsWith('/help') && topic) {\n this.history = [...this.history.slice(0, this.historyIndex + 1), topic]\n this.historyIndex++\n this.topic = topic\n } else {\n navigate(href)\n }\n\n return\n })\n }\n\n /** A link inside an html document took it to another topic: the overlay follows, as with a markdown link. */\n follow(topic: string) {\n if (!topic || topic === this.topic) return\n this.history = [...this.history.slice(0, this.historyIndex + 1), topic]\n this.historyIndex++\n }\n\n gotoTop(e: Event) {\n this.content.scrollTop = 0\n\n e.stopPropagation()\n }\n\n goHome() {\n if (!this.history?.[0] || this.history[0] == this.topic) {\n return\n }\n this.history.push(this.history[0])\n this.historyIndex = this.history.length - 1\n }\n\n historyBack() {\n this.historyIndex > 0 && this.historyIndex--\n }\n\n historyForward() {\n this.history && this.historyIndex < this.history.length - 1 && this.historyIndex++\n }\n}\n"]}
|
package/dist/test/ox-doc.test.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { expect, fixture, html, waitUntil } from '@open-wc/testing';
|
|
2
2
|
import '../src/components/ox-doc.js';
|
|
3
3
|
import '../src/components/ox-help-spot.js';
|
|
4
|
+
import '../src/viewparts/ox-help-panel.js';
|
|
5
|
+
import { appendViewpart, VIEWPART_POSITION } from '@operato/layout';
|
|
6
|
+
import { store } from '@operato/shell';
|
|
4
7
|
/**
|
|
5
8
|
* ox-doc reads /helps/{topic}.html and renders it; the products that used to keep their own copy rely on
|
|
6
9
|
* these behaviours.
|
|
@@ -60,45 +63,25 @@ describe('ox-doc', () => {
|
|
|
60
63
|
});
|
|
61
64
|
});
|
|
62
65
|
describe('ox-help-spot', () => {
|
|
63
|
-
/*
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
expect(bar).to.contain('닫기');
|
|
74
|
-
expect(bar).not.to.contain('close');
|
|
75
|
-
});
|
|
76
|
-
it('opens the section in place and closes on Escape', async () => {
|
|
77
|
-
const el = await fixture(html `<ox-help-spot topic="a/one" section="part"></ox-help-spot>`);
|
|
78
|
-
await waitUntil(() => el.shadowRoot.querySelector('button.q'));
|
|
79
|
-
el.shadowRoot.querySelector('button.q').click();
|
|
80
|
-
await waitUntil(() => el.shadowRoot.querySelector('ox-doc'));
|
|
81
|
-
/* The dialog says what opened and can take focus (operato-twin's overlay guard asks both). */
|
|
82
|
-
const panel = el.shadowRoot.querySelector('.panel');
|
|
83
|
-
expect(panel.getAttribute('aria-label')).to.equal('help');
|
|
84
|
-
expect(panel.getAttribute('tabindex')).to.equal('-1');
|
|
85
|
-
const doc = el.shadowRoot.querySelector('ox-doc');
|
|
86
|
-
expect(doc.getAttribute('section')).to.equal('part');
|
|
87
|
-
expect(doc.hasAttribute('compact')).to.equal(true);
|
|
88
|
-
el.shadowRoot.querySelector('.panel').dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, composed: true }));
|
|
89
|
-
await waitUntil(() => !el.shadowRoot.querySelector('.panel'));
|
|
90
|
-
});
|
|
91
|
-
/* A `?` in a grid header sits in nowrap, bold, right-aligned text; its panel is a document and must not take those. */
|
|
92
|
-
it('opens a panel that wraps and reads from the start, whatever the text around the ?', async () => {
|
|
93
|
-
const host = await fixture(html `<div style="white-space: nowrap; text-align: right; font-weight: 700; width: 120px"><ox-help-spot topic="a/one" section="part"></ox-help-spot></div>`);
|
|
66
|
+
/*
|
|
67
|
+
* The `?` opens the app's help overlay at its section and draws no panel of its own: one drawn inside it sat in
|
|
68
|
+
* whatever held the `?` (a card button, a grid header), took that parent's pointer and text settings, and handed
|
|
69
|
+
* its scrolling and presses back to it. The press of the `?` itself is not a press of its parent either.
|
|
70
|
+
*/
|
|
71
|
+
it('opens the help overlay at its section, and its press does not reach what holds it', async () => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
appendViewpart({ name: 'help', viewpart: { show: false, hovering: 'edge', template: html `<ox-help-panel></ox-help-panel>` }, position: VIEWPART_POSITION.ASIDEBAR });
|
|
74
|
+
let parentPresses = 0;
|
|
75
|
+
const host = await fixture(html `<button style="cursor: pointer" @click=${() => parentPresses++} @pointerdown=${() => parentPresses++}><ox-help-spot topic="a/one" section="part"></ox-help-spot></button>`);
|
|
94
76
|
const el = host.querySelector('ox-help-spot');
|
|
95
77
|
await waitUntil(() => el.shadowRoot.querySelector('button.q'));
|
|
96
|
-
el.shadowRoot.querySelector('button.q')
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
expect(
|
|
100
|
-
expect(panel
|
|
101
|
-
expect(
|
|
78
|
+
const q = el.shadowRoot.querySelector('button.q');
|
|
79
|
+
q.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, composed: true }));
|
|
80
|
+
q.click();
|
|
81
|
+
expect(parentPresses).to.equal(0);
|
|
82
|
+
expect(el.shadowRoot.querySelector('.panel, ox-doc')).to.equal(null);
|
|
83
|
+
expect((_b = (_a = history.state) === null || _a === void 0 ? void 0 : _a.overlay) === null || _b === void 0 ? void 0 : _b.name).to.equal('help');
|
|
84
|
+
expect(store.getState().layout.viewparts.help.templateProperties).to.deep.equal({ topic: 'a/one', section: 'part' });
|
|
102
85
|
});
|
|
103
86
|
/* A `?` is placed before its help is written; it must not open 「Content not found」 or the whole document. */
|
|
104
87
|
it('stays out of sight until its topic is written', async () => {
|
|
@@ -118,4 +101,23 @@ describe('ox-help-spot', () => {
|
|
|
118
101
|
expect(missing.hasAttribute('hidden')).to.equal(true);
|
|
119
102
|
});
|
|
120
103
|
});
|
|
104
|
+
describe('ox-help-panel', () => {
|
|
105
|
+
/* The overlay shows what a `?` asked about - an html document's section - and the older markdown topics as before. */
|
|
106
|
+
it('shows an html topic through ox-doc at the section, and a markdown topic as markdown', async () => {
|
|
107
|
+
const html1 = await fixture(html `<ox-help-panel topic="a/one" section="part"></ox-help-panel>`);
|
|
108
|
+
await waitUntil(() => html1.shadowRoot.querySelector('ox-doc'));
|
|
109
|
+
const doc = html1.shadowRoot.querySelector('ox-doc');
|
|
110
|
+
expect([doc.getAttribute('topic'), doc.getAttribute('section'), doc.hasAttribute('compact')]).to.deep.equal(['a/one', 'part', true]);
|
|
111
|
+
const md = await fixture(html `<ox-help-panel topic="b/md"></ox-help-panel>`);
|
|
112
|
+
await waitUntil(() => md.shadowRoot.querySelector('ox-markdown'));
|
|
113
|
+
expect(md.shadowRoot.querySelector('ox-doc')).to.equal(null);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
describe('ox-doc anchor', () => {
|
|
117
|
+
/* The help page opens the whole document at the part the overlay showed. */
|
|
118
|
+
it('scrolls its scrolling parent to the anchor once the document is drawn', async () => {
|
|
119
|
+
const box = await fixture(html `<div style="height: 40px; overflow: auto"><ox-doc topic="a/one" anchor="next"></ox-doc></div>`);
|
|
120
|
+
await waitUntil(() => box.scrollTop > 0, 'the box scrolls to #next');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
121
123
|
//# sourceMappingURL=ox-doc.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ox-doc.test.js","sourceRoot":"","sources":["../../test/ox-doc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,6BAA6B,CAAA;AACpC,OAAO,mCAAmC,CAAA;AAG1C;;;GAGG;AACH,MAAM,IAAI,GAA2B;IACnC,OAAO,EAAE,6KAA6K;IACtL,OAAO,EAAE,mCAAmC;CAC7C,CAAA;AAED,IAAI,QAAQ,GAAa,EAAE,CAAA;AAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAA;AAE9B,UAAU,CAAC,GAAG,EAAE;IACd,QAAQ,GAAG,EAAE,CAAA;IACb,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,KAAwB,EAAE,EAAE;QACjD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QACzB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,C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,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QAClE,MAAM,CAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAChD,MAAM,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2DAA2D,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,KAAK,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,4DAA4D,CAAC,CAAA;QAC1G,MAAM,OAAO,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,6DAA6D,CAAC,CAAA;QAC7G,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,UAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAA;QAClE,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;QAErD,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,UAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;QACvE,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IACvD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, html, waitUntil } from '@open-wc/testing'\n\nimport '../src/components/ox-doc.js'\nimport '../src/components/ox-help-spot.js'\nimport type { OxDoc } from '../src/components/ox-doc.js'\n\n/**\n * ox-doc reads /helps/{topic}.html and renders it; the products that used to keep their own copy rely on\n * these behaviours.\n */\nconst DOCS: Record<string, string> = {\n 'a/one': `<h1 id=\"top\">One</h1><p>lead</p><h2 id=\"part\">Part</h2><p>in part</p><table><tr><td>x</td></tr></table><h2 id=\"next\">Next</h2><p>after</p><a data-topic=\"a/two#end\">two</a>`,\n 'a/two': `<h1>Two</h1><h2 id=\"end\">End</h2>`\n}\n\nlet requests: string[] = []\nconst realFetch = window.fetch\n\nbeforeEach(() => {\n requests = []\n window.fetch = (async (input: RequestInfo | URL) => {\n const url = String(input)\n requests.push(url)\n const topic = url.replace(/^\\/helps\\//, '').replace(/\\.html.*$/, '')\n return DOCS[topic] ? new Response(DOCS[topic]) : new Response('', { status: 404 })\n }) as typeof window.fetch\n})\n\nafterEach(() => {\n window.fetch = realFetch\n})\n\nconst bodyOf = (el: OxDoc) => el.shadowRoot!.querySelector('.body') as HTMLElement\n\ndescribe('ox-doc', () => {\n it('reads /helps/{topic}.html with the language and renders it', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('h1'))\n\n expect(requests[0]).to.match(/^\\/helps\\/a\\/one\\.html\\?lng=/)\n expect(bodyOf(el).querySelector('h1')!.textContent).to.equal('One')\n })\n\n it('wraps tables in a scrolling box so they do not push the page wide', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('table'))\n\n expect(bodyOf(el).querySelector('table')!.parentElement!.classList.contains('tablewrap')).to.equal(true)\n })\n\n it('shows only the named section, up to the next heading of its level', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\" section=\"part\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('h2'))\n\n expect(bodyOf(el).textContent).to.contain('in part')\n expect(bodyOf(el).textContent).to.not.contain('lead')\n expect(bodyOf(el).textContent).to.not.contain('after')\n })\n\n it('follows a topic link in place and tells the host, without keeping the anchor in the file name', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('a[data-topic]'))\n\n let told: any\n el.addEventListener('ox-doc-topic', e => (told = (e as CustomEvent).detail))\n ;(bodyOf(el).querySelector('a[data-topic]') as HTMLElement).click()\n await waitUntil(() => bodyOf(el)?.querySelector('h1')?.textContent === 'Two')\n\n expect(told).to.deep.equal({ topic: 'a/two', hash: 'end' })\n expect(requests[requests.length - 1]).to.match(/^\\/helps\\/a\\/two\\.html\\?/)\n })\n\n it('says the topic is missing instead of showing an empty page', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/none\"></ox-doc>`)\n await waitUntil(() => el.shadowRoot!.querySelector('.status.err'))\n\n expect(el.shadowRoot!.querySelector('.status.err')!.textContent).to.contain('a/none')\n })\n})\n\ndescribe('ox-help-spot', () => {\n /* Its two links are words of the reader's language, not English left in a Korean screen. */\n it('names its links in the reader\\'s language', async () => {\n const { i18next } = await import('@operato/i18n')\n i18next.addResourceBundle(i18next.language || 'en', 'translations', { 'button.close': '닫기', 'text.help-open-full': '전체 보기' }, true, true)\n const el = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot>`)\n await waitUntil(() => el.shadowRoot!.querySelector('button.q'))\n ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()\n await waitUntil(() => el.shadowRoot!.querySelector('.bar'))\n\n const bar = el.shadowRoot!.querySelector('.bar')!.textContent!.replace(/\\s+/g, ' ')\n expect(bar).to.contain('전체 보기')\n expect(bar).to.contain('닫기')\n expect(bar).not.to.contain('close')\n })\n\n it('opens the section in place and closes on Escape', async () => {\n const el = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot>`)\n await waitUntil(() => el.shadowRoot!.querySelector('button.q'))\n ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()\n await waitUntil(() => el.shadowRoot!.querySelector('ox-doc'))\n\n /* The dialog says what opened and can take focus (operato-twin's overlay guard asks both). */\n const panel = el.shadowRoot!.querySelector('.panel')!\n expect(panel.getAttribute('aria-label')).to.equal('help')\n expect(panel.getAttribute('tabindex')).to.equal('-1')\n\n const doc = el.shadowRoot!.querySelector('ox-doc') as OxDoc\n expect(doc.getAttribute('section')).to.equal('part')\n expect(doc.hasAttribute('compact')).to.equal(true)\n\n el.shadowRoot!.querySelector('.panel')!.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, composed: true }))\n await waitUntil(() => !el.shadowRoot!.querySelector('.panel'))\n })\n\n /* A `?` in a grid header sits in nowrap, bold, right-aligned text; its panel is a document and must not take those. */\n it('opens a panel that wraps and reads from the start, whatever the text around the ?', async () => {\n const host = await fixture<HTMLElement>(\n html`<div style=\"white-space: nowrap; text-align: right; font-weight: 700; width: 120px\"><ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot></div>`\n )\n const el = host.querySelector('ox-help-spot') as HTMLElement\n await waitUntil(() => el.shadowRoot!.querySelector('button.q'))\n ;(el.shadowRoot!.querySelector('button.q') as HTMLButtonElement).click()\n await waitUntil(() => el.shadowRoot!.querySelector('.panel'))\n\n const panel = getComputedStyle(el.shadowRoot!.querySelector('.panel')!)\n expect(panel.whiteSpace).to.equal('normal')\n expect(panel.textAlign).to.equal('start')\n expect(panel.fontWeight).to.equal('400')\n })\n\n /* A `?` is placed before its help is written; it must not open 「Content not found」 or the whole document. */\n it('stays out of sight until its topic is written', async () => {\n const el = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/none\" section=\"part\"></ox-help-spot>`)\n await waitUntil(() => requests.some(url => url.startsWith('/helps/a/none.html')))\n await new Promise(resolve => setTimeout(resolve, 20))\n\n expect(!!el.shadowRoot!.querySelector('button.q')).to.equal(false)\n expect(el.hasAttribute('hidden')).to.equal(true)\n expect(getComputedStyle(el).display).to.equal('none')\n })\n\n it('stays out of sight while the named section is not written', async () => {\n const shown = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot>`)\n const missing = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"later\"></ox-help-spot>`)\n await waitUntil(() => shown.shadowRoot!.querySelector('button.q'))\n await new Promise(resolve => setTimeout(resolve, 20))\n\n expect(!!missing.shadowRoot!.querySelector('button.q')).to.equal(false)\n expect(missing.hasAttribute('hidden')).to.equal(true)\n })\n})\n"]}
|
|
1
|
+
{"version":3,"file":"ox-doc.test.js","sourceRoot":"","sources":["../../test/ox-doc.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAEnE,OAAO,6BAA6B,CAAA;AACpC,OAAO,mCAAmC,CAAA;AAC1C,OAAO,mCAAmC,CAAA;AAE1C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC;;;GAGG;AACH,MAAM,IAAI,GAA2B;IACnC,OAAO,EAAE,6KAA6K;IACtL,OAAO,EAAE,mCAAmC;CAC7C,CAAA;AAED,IAAI,QAAQ,GAAa,EAAE,CAAA;AAC3B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAA;AAE9B,UAAU,CAAC,GAAG,EAAE;IACd,QAAQ,GAAG,EAAE,CAAA;IACb,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,KAAwB,EAAE,EAAE;QACjD,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAA;QACzB,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAClB,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;QACpE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAA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AE,CAAC,uEAAuE,EAAE,KAAK,IAAI,EAAE;QACrF,MAAM,GAAG,GAAG,MAAM,OAAO,CAAc,IAAI,CAAA,+FAA+F,CAAC,CAAA;QAC3I,MAAM,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,EAAE,0BAA0B,CAAC,CAAA;IACtE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { expect, fixture, html, waitUntil } from '@open-wc/testing'\n\nimport '../src/components/ox-doc.js'\nimport '../src/components/ox-help-spot.js'\nimport '../src/viewparts/ox-help-panel.js'\nimport type { OxDoc } from '../src/components/ox-doc.js'\nimport { appendViewpart, VIEWPART_POSITION } from '@operato/layout'\nimport { store } from '@operato/shell'\n\n/**\n * ox-doc reads /helps/{topic}.html and renders it; the products that used to keep their own copy rely on\n * these behaviours.\n */\nconst DOCS: Record<string, string> = {\n 'a/one': `<h1 id=\"top\">One</h1><p>lead</p><h2 id=\"part\">Part</h2><p>in part</p><table><tr><td>x</td></tr></table><h2 id=\"next\">Next</h2><p>after</p><a data-topic=\"a/two#end\">two</a>`,\n 'a/two': `<h1>Two</h1><h2 id=\"end\">End</h2>`\n}\n\nlet requests: string[] = []\nconst realFetch = window.fetch\n\nbeforeEach(() => {\n requests = []\n window.fetch = (async (input: RequestInfo | URL) => {\n const url = String(input)\n requests.push(url)\n const topic = url.replace(/^\\/helps\\//, '').replace(/\\.html.*$/, '')\n return DOCS[topic] ? new Response(DOCS[topic]) : new Response('', { status: 404 })\n }) as typeof window.fetch\n})\n\nafterEach(() => {\n window.fetch = realFetch\n})\n\nconst bodyOf = (el: OxDoc) => el.shadowRoot!.querySelector('.body') as HTMLElement\n\ndescribe('ox-doc', () => {\n it('reads /helps/{topic}.html with the language and renders it', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('h1'))\n\n expect(requests[0]).to.match(/^\\/helps\\/a\\/one\\.html\\?lng=/)\n expect(bodyOf(el).querySelector('h1')!.textContent).to.equal('One')\n })\n\n it('wraps tables in a scrolling box so they do not push the page wide', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('table'))\n\n expect(bodyOf(el).querySelector('table')!.parentElement!.classList.contains('tablewrap')).to.equal(true)\n })\n\n it('shows only the named section, up to the next heading of its level', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\" section=\"part\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('h2'))\n\n expect(bodyOf(el).textContent).to.contain('in part')\n expect(bodyOf(el).textContent).to.not.contain('lead')\n expect(bodyOf(el).textContent).to.not.contain('after')\n })\n\n it('follows a topic link in place and tells the host, without keeping the anchor in the file name', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/one\"></ox-doc>`)\n await waitUntil(() => bodyOf(el)?.querySelector('a[data-topic]'))\n\n let told: any\n el.addEventListener('ox-doc-topic', e => (told = (e as CustomEvent).detail))\n ;(bodyOf(el).querySelector('a[data-topic]') as HTMLElement).click()\n await waitUntil(() => bodyOf(el)?.querySelector('h1')?.textContent === 'Two')\n\n expect(told).to.deep.equal({ topic: 'a/two', hash: 'end' })\n expect(requests[requests.length - 1]).to.match(/^\\/helps\\/a\\/two\\.html\\?/)\n })\n\n it('says the topic is missing instead of showing an empty page', async () => {\n const el = await fixture<OxDoc>(html`<ox-doc topic=\"a/none\"></ox-doc>`)\n await waitUntil(() => el.shadowRoot!.querySelector('.status.err'))\n\n expect(el.shadowRoot!.querySelector('.status.err')!.textContent).to.contain('a/none')\n })\n})\n\ndescribe('ox-help-spot', () => {\n /*\n * The `?` opens the app's help overlay at its section and draws no panel of its own: one drawn inside it sat in\n * whatever held the `?` (a card button, a grid header), took that parent's pointer and text settings, and handed\n * its scrolling and presses back to it. The press of the `?` itself is not a press of its parent either.\n */\n it('opens the help overlay at its section, and its press does not reach what holds it', async () => {\n appendViewpart({ name: 'help', viewpart: { show: false, hovering: 'edge', template: html`<ox-help-panel></ox-help-panel>` }, position: VIEWPART_POSITION.ASIDEBAR })\n let parentPresses = 0\n const host = await fixture<HTMLElement>(\n html`<button style=\"cursor: pointer\" @click=${() => parentPresses++} @pointerdown=${() => parentPresses++}><ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot></button>`\n )\n const el = host.querySelector('ox-help-spot') as HTMLElement\n await waitUntil(() => el.shadowRoot!.querySelector('button.q'))\n const q = el.shadowRoot!.querySelector('button.q') as HTMLButtonElement\n q.dispatchEvent(new PointerEvent('pointerdown', { bubbles: true, composed: true }))\n q.click()\n\n expect(parentPresses).to.equal(0)\n expect(el.shadowRoot!.querySelector('.panel, ox-doc')).to.equal(null)\n expect(history.state?.overlay?.name).to.equal('help')\n expect((store.getState() as any).layout.viewparts.help.templateProperties).to.deep.equal({ topic: 'a/one', section: 'part' })\n })\n\n /* A `?` is placed before its help is written; it must not open 「Content not found」 or the whole document. */\n it('stays out of sight until its topic is written', async () => {\n const el = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/none\" section=\"part\"></ox-help-spot>`)\n await waitUntil(() => requests.some(url => url.startsWith('/helps/a/none.html')))\n await new Promise(resolve => setTimeout(resolve, 20))\n\n expect(!!el.shadowRoot!.querySelector('button.q')).to.equal(false)\n expect(el.hasAttribute('hidden')).to.equal(true)\n expect(getComputedStyle(el).display).to.equal('none')\n })\n\n it('stays out of sight while the named section is not written', async () => {\n const shown = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"part\"></ox-help-spot>`)\n const missing = await fixture<HTMLElement>(html`<ox-help-spot topic=\"a/one\" section=\"later\"></ox-help-spot>`)\n await waitUntil(() => shown.shadowRoot!.querySelector('button.q'))\n await new Promise(resolve => setTimeout(resolve, 20))\n\n expect(!!missing.shadowRoot!.querySelector('button.q')).to.equal(false)\n expect(missing.hasAttribute('hidden')).to.equal(true)\n })\n})\n\ndescribe('ox-help-panel', () => {\n /* The overlay shows what a `?` asked about - an html document's section - and the older markdown topics as before. */\n it('shows an html topic through ox-doc at the section, and a markdown topic as markdown', async () => {\n const html1 = await fixture<HTMLElement>(html`<ox-help-panel topic=\"a/one\" section=\"part\"></ox-help-panel>`)\n await waitUntil(() => html1.shadowRoot!.querySelector('ox-doc'))\n const doc = html1.shadowRoot!.querySelector('ox-doc') as OxDoc\n expect([doc.getAttribute('topic'), doc.getAttribute('section'), doc.hasAttribute('compact')]).to.deep.equal(['a/one', 'part', true])\n\n const md = await fixture<HTMLElement>(html`<ox-help-panel topic=\"b/md\"></ox-help-panel>`)\n await waitUntil(() => md.shadowRoot!.querySelector('ox-markdown'))\n expect(md.shadowRoot!.querySelector('ox-doc')).to.equal(null)\n })\n})\n\ndescribe('ox-doc anchor', () => {\n /* The help page opens the whole document at the part the overlay showed. */\n it('scrolls its scrolling parent to the anchor once the document is drawn', async () => {\n const box = await fixture<HTMLElement>(html`<div style=\"height: 40px; overflow: auto\"><ox-doc topic=\"a/one\" anchor=\"next\"></ox-doc></div>`)\n await waitUntil(() => box.scrollTop > 0, 'the box scrolls to #next')\n })\n})\n"]}
|