@teipublisher/pb-components 1.42.7 → 1.43.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/CHANGELOG.md +14 -0
- package/css/components.css +5 -0
- package/dist/demo/components.css +26 -0
- package/dist/demo/pb-code-highlight.html +63 -63
- package/dist/demo/pb-table-grid.html +16 -16
- package/dist/demo/pb-view2.html +135 -136
- package/dist/pb-code-editor.js +1 -1
- package/dist/pb-component-docs.js +40 -40
- package/dist/pb-components-bundle.js +261 -262
- package/dist/pb-edit-app.js +1 -1
- package/dist/pb-elements.json +703 -690
- package/dist/{pb-i18n-6ad23bcf.js → pb-i18n-dc551878.js} +1 -1
- package/dist/pb-leaflet-map.js +1 -1
- package/dist/{pb-message-0fb0b538.js → pb-message-fbc1b645.js} +25 -26
- package/dist/{pb-mixin-15ff531f.js → pb-mixin-f8b22e51.js} +1 -1
- package/dist/pb-odd-editor.js +1 -1
- package/package.json +1 -1
- package/pb-elements.json +703 -690
- package/src/assets/components.css +5 -0
- package/src/pb-browse-docs.js +520 -519
- package/src/pb-clipboard.js +75 -74
- package/src/pb-code-highlight.js +194 -193
- package/src/pb-collapse.js +183 -182
- package/src/pb-mixin.js +542 -529
- package/src/pb-page.js +399 -384
- package/src/pb-split-list.js +2 -1
- package/src/pb-table-grid.js +218 -211
- package/src/pb-view.js +1366 -1368
- package/src/theming.js +150 -0
- package/src/utils.js +50 -51
package/src/pb-clipboard.js
CHANGED
|
@@ -1,75 +1,76 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import { pbMixin } from './pb-mixin.js';
|
|
3
|
-
import { translate } from "./pb-i18n.js";
|
|
4
|
-
import
|
|
5
|
-
import '@polymer/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
<
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
font-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
1
|
+
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import { pbMixin } from './pb-mixin.js';
|
|
3
|
+
import { translate } from "./pb-i18n.js";
|
|
4
|
+
import { themableMixin } from "./theming.js";
|
|
5
|
+
import '@polymer/paper-icon-button';
|
|
6
|
+
import '@polymer/iron-icons';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* A component with a button which copies the contained content to the clipboard.
|
|
10
|
+
* Use for the typical 'quote this content as' hints on a webpage.
|
|
11
|
+
*
|
|
12
|
+
* @slot content - contains the actual content to copy to the clipboard
|
|
13
|
+
*/
|
|
14
|
+
export class PbClipboard extends themableMixin(pbMixin(LitElement)) {
|
|
15
|
+
static get properties() {
|
|
16
|
+
return {
|
|
17
|
+
/**
|
|
18
|
+
* Label to display above the text to be copied
|
|
19
|
+
*/
|
|
20
|
+
label: {
|
|
21
|
+
type: String
|
|
22
|
+
},
|
|
23
|
+
...super.properties
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.label = 'clipboard.label';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
render() {
|
|
33
|
+
return html`
|
|
34
|
+
<h3>${translate(this.label)}</h3>
|
|
35
|
+
<div>
|
|
36
|
+
<slot></slot>
|
|
37
|
+
<paper-icon-button icon="icons:content-copy" @click="${this._copy}"
|
|
38
|
+
title="${translate('clipboard.copy')}"></paper-icon-button>
|
|
39
|
+
</div>
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Copy text content from the <slot> to the clipboard
|
|
45
|
+
*/
|
|
46
|
+
_copy() {
|
|
47
|
+
const slot = this.shadowRoot.querySelector('slot');
|
|
48
|
+
// first import nodes from the slot into a temporary div
|
|
49
|
+
const content = document.createElement('div');
|
|
50
|
+
slot.assignedNodes().forEach((node) => {
|
|
51
|
+
content.appendChild(document.importNode(node, true));
|
|
52
|
+
});
|
|
53
|
+
// copy the innerText of the temp div into the clipboard
|
|
54
|
+
navigator.clipboard.writeText(content.innerText);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static get styles() {
|
|
58
|
+
return css`
|
|
59
|
+
:host {
|
|
60
|
+
display: block;
|
|
61
|
+
}
|
|
62
|
+
h3 {
|
|
63
|
+
margin: 0;
|
|
64
|
+
font-size: .85em;
|
|
65
|
+
font-weight: normal;
|
|
66
|
+
color: #3a3a3a;
|
|
67
|
+
}
|
|
68
|
+
div {
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
padding: 0 16px;
|
|
72
|
+
}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
75
76
|
customElements.define('pb-clipboard', PbClipboard);
|
package/src/pb-code-highlight.js
CHANGED
|
@@ -1,194 +1,195 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import "prismjs/prism";
|
|
3
|
-
import 'prismjs/components/prism-xquery';
|
|
4
|
-
import 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace';
|
|
5
|
-
import 'prismjs/plugins/line-numbers/prism-line-numbers';
|
|
6
|
-
import { resolveURL, getCSSProperty } from './utils.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @cssprop [--pb-code-highlight-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
* '
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
-
|
|
172
|
-
-
|
|
173
|
-
user-select: none;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
1
|
+
import { LitElement, html, css } from 'lit-element';
|
|
2
|
+
import "prismjs/prism";
|
|
3
|
+
import 'prismjs/components/prism-xquery';
|
|
4
|
+
import 'prismjs/plugins/normalize-whitespace/prism-normalize-whitespace';
|
|
5
|
+
import 'prismjs/plugins/line-numbers/prism-line-numbers';
|
|
6
|
+
import { resolveURL, getCSSProperty } from './utils.js';
|
|
7
|
+
import { themableMixin } from "./theming.js";
|
|
8
|
+
|
|
9
|
+
const PRISM_THEMES = new Map();
|
|
10
|
+
|
|
11
|
+
function loadTheme(theme) {
|
|
12
|
+
const themeName = theme === 'default' ? 'prism.css' : `prism-${theme}.css`;
|
|
13
|
+
if (PRISM_THEMES.has(themeName)) {
|
|
14
|
+
console.log('Using cached theme: %s', themeName);
|
|
15
|
+
return PRISM_THEMES.get(themeName);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const promise = new Promise((resolve) => {
|
|
19
|
+
const resource = resolveURL('../css/prismjs/') + themeName;
|
|
20
|
+
console.log('<pb-code-highlight> loading theme %s from %s', theme, resource);
|
|
21
|
+
fetch(resource)
|
|
22
|
+
.then(response => response.text())
|
|
23
|
+
.catch(() => resolve(''))
|
|
24
|
+
.then(text => {
|
|
25
|
+
resolve(html`<style>${text}</style>`);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
PRISM_THEMES.set(themeName, promise);
|
|
29
|
+
return promise;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Highlight a code snippet. The snippet may either be passed in a template child
|
|
34
|
+
* element, which could contain HTML or text. If no template child is present, the
|
|
35
|
+
* component will take any text content contained in it and highlight it. One can also
|
|
36
|
+
* pass the code to be highlighted in the `code` property.
|
|
37
|
+
*
|
|
38
|
+
* @cssprop [--pb-code-highlight-white-space=pre] - configures line wrapping
|
|
39
|
+
* @cssprop [--pb-code-highlight-theme=default] - configures the default theme to be used
|
|
40
|
+
*/
|
|
41
|
+
export class PbCodeHighlight extends themableMixin(LitElement) {
|
|
42
|
+
static get properties() {
|
|
43
|
+
return {
|
|
44
|
+
/**
|
|
45
|
+
* The language to be used for syntax highlighting.
|
|
46
|
+
*/
|
|
47
|
+
language: {
|
|
48
|
+
type: String
|
|
49
|
+
},
|
|
50
|
+
/**
|
|
51
|
+
* The code to be highlighted as a string. If not set,
|
|
52
|
+
* this will be populated from either a template child element
|
|
53
|
+
* or the element's text content.
|
|
54
|
+
*/
|
|
55
|
+
code: {
|
|
56
|
+
type: String
|
|
57
|
+
},
|
|
58
|
+
/**
|
|
59
|
+
* Highlighting theme to use: 'coy', 'dark', 'funky', 'okaida', 'solarizedlight',
|
|
60
|
+
* 'tomorrow', 'twilight' or 'default'.
|
|
61
|
+
*/
|
|
62
|
+
theme: {
|
|
63
|
+
type: String
|
|
64
|
+
},
|
|
65
|
+
lineNumbers: {
|
|
66
|
+
type: Boolean,
|
|
67
|
+
attribute: 'line-numbers'
|
|
68
|
+
},
|
|
69
|
+
_themeStyles: {
|
|
70
|
+
type: String
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
constructor() {
|
|
76
|
+
super();
|
|
77
|
+
this.language = 'xml';
|
|
78
|
+
this.theme = 'default';
|
|
79
|
+
this.lineNumbers = false;
|
|
80
|
+
this._themeStyles = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
connectedCallback() {
|
|
84
|
+
super.connectedCallback();
|
|
85
|
+
let theme = this.getAttribute('theme');
|
|
86
|
+
if (theme === null) {
|
|
87
|
+
theme = getCSSProperty(this, '--pb-code-highlight-theme', 'default');
|
|
88
|
+
this.setAttribute('theme', theme);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
firstUpdated() {
|
|
93
|
+
super.firstUpdated();
|
|
94
|
+
|
|
95
|
+
if (!this.code) {
|
|
96
|
+
const template = this.querySelector('template');
|
|
97
|
+
if (template) {
|
|
98
|
+
this.code = Prism.plugins.NormalizeWhitespace.normalize(template.innerHTML);
|
|
99
|
+
} else {
|
|
100
|
+
this.code = Prism.plugins.NormalizeWhitespace.normalize(this.textContent);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
106
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
107
|
+
switch (name) {
|
|
108
|
+
case 'theme':
|
|
109
|
+
loadTheme(newValue).then(loadedStyles => {
|
|
110
|
+
this._themeStyles = loadedStyles;
|
|
111
|
+
});
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
updated(changedProperties) {
|
|
119
|
+
super.updated(changedProperties);
|
|
120
|
+
if (changedProperties.has('code')) {
|
|
121
|
+
this.highlight();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
highlight() {
|
|
126
|
+
Prism.highlightAllUnder(this.shadowRoot);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
render() {
|
|
130
|
+
if (this.code) {
|
|
131
|
+
return html`
|
|
132
|
+
${this._themeStyles}
|
|
133
|
+
<pre class="${this.lineNumbers ? 'line-numbers' : ''} language-${this.language}"><code>${this.code}</code></pre>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
return html`<pre class="line-numbers"><code><code></pre>`;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
static get styles() {
|
|
140
|
+
return css`
|
|
141
|
+
:host {
|
|
142
|
+
display: block;
|
|
143
|
+
}
|
|
144
|
+
pre[class*='language-'] {
|
|
145
|
+
margin: 0;
|
|
146
|
+
}
|
|
147
|
+
code[class*='language-'] {
|
|
148
|
+
white-space: var(--pb-code-highlight-white-space, pre);
|
|
149
|
+
}
|
|
150
|
+
pre.line-numbers {
|
|
151
|
+
position: relative;
|
|
152
|
+
padding-left: 3.8em;
|
|
153
|
+
counter-reset: linenumber;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
pre.line-numbers > code {
|
|
157
|
+
position: relative;
|
|
158
|
+
white-space: inherit;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.line-numbers .line-numbers-rows {
|
|
162
|
+
position: absolute;
|
|
163
|
+
pointer-events: none;
|
|
164
|
+
top: 0;
|
|
165
|
+
font-size: 100%;
|
|
166
|
+
left: -3.8em;
|
|
167
|
+
width: 3em; /* works for line-numbers below 1000 lines */
|
|
168
|
+
letter-spacing: -1px;
|
|
169
|
+
border-right: 1px solid #999;
|
|
170
|
+
|
|
171
|
+
-webkit-user-select: none;
|
|
172
|
+
-moz-user-select: none;
|
|
173
|
+
-ms-user-select: none;
|
|
174
|
+
user-select: none;
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.line-numbers-rows > span {
|
|
179
|
+
pointer-events: none;
|
|
180
|
+
display: block;
|
|
181
|
+
counter-increment: linenumber;
|
|
182
|
+
height: auto !important;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.line-numbers-rows > span:before {
|
|
186
|
+
content: counter(linenumber);
|
|
187
|
+
color: #999;
|
|
188
|
+
display: block;
|
|
189
|
+
padding-right: 0.8em;
|
|
190
|
+
text-align: right;
|
|
191
|
+
}
|
|
192
|
+
`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
194
195
|
customElements.define('pb-code-highlight', PbCodeHighlight);
|