@teipublisher/pb-components 2.26.0-next-3.12 → 2.26.0-next-3.13
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/.github/workflows/main.yml +3 -3
- package/.github/workflows/node.js.yml +3 -3
- package/.github/workflows/release.js.yml +3 -3
- package/CHANGELOG.md +30 -0
- package/Dockerfile +78 -70
- package/css/components.css +5 -5
- package/dist/demo/pb-drawer2.html +1 -1
- package/dist/demo/pb-leaflet-map.html +1 -1
- package/dist/demo/pb-progress.html +2 -2
- package/dist/demo/pb-repeat.html +1 -3
- package/dist/demo/pb-view3.html +1 -1
- package/dist/{paper-icon-button-0fb125c4.js → paper-icon-button-72125e67.js} +1 -1
- package/dist/pb-code-editor.js +25 -20
- package/dist/pb-component-docs.js +58 -54
- package/dist/pb-components-bundle.js +1937 -1782
- package/dist/pb-edit-app.js +167 -107
- package/dist/pb-elements.json +45 -45
- package/dist/{pb-i18n-0611135a.js → pb-i18n-4cc00bfe.js} +1 -1
- package/dist/pb-leaflet-map.js +23 -23
- package/dist/pb-mei.js +56 -41
- package/dist/{pb-mixin-b1caa22e.js → pb-mixin-886ece32.js} +1 -1
- package/dist/pb-odd-editor.js +923 -756
- package/dist/pb-tify.js +2 -2
- package/dist/{vaadin-element-mixin-49ab4037.js → vaadin-element-mixin-84fb7d82.js} +178 -163
- package/gh-pages.js +5 -3
- package/i18n/common/pl.json +2 -2
- package/lib/openseadragon.min.js +1 -1
- package/package.json +2 -2
- package/pb-elements.json +45 -45
- package/src/assets/components.css +5 -5
- package/src/authority/airtable.js +20 -21
- package/src/authority/anton.js +129 -129
- package/src/authority/custom.js +23 -21
- package/src/authority/geonames.js +38 -32
- package/src/authority/gnd.js +47 -42
- package/src/authority/kbga.js +137 -134
- package/src/authority/metagrid.js +44 -46
- package/src/authority/reconciliation.js +66 -67
- package/src/authority/registry.js +4 -4
- package/src/docs/pb-component-docs.js +2 -2
- package/src/docs/pb-component-view.js +5 -5
- package/src/docs/pb-components-list.js +2 -2
- package/src/docs/pb-demo-snippet.js +2 -2
- package/src/dts-client.js +299 -297
- package/src/dts-select-endpoint.js +90 -82
- package/src/parse-date-service.js +184 -135
- package/src/pb-ajax.js +150 -146
- package/src/pb-authority-lookup.js +183 -146
- package/src/pb-autocomplete.js +292 -280
- package/src/pb-blacklab-highlight.js +264 -259
- package/src/pb-blacklab-results.js +236 -221
- package/src/pb-browse-docs.js +540 -475
- package/src/pb-browse.js +68 -65
- package/src/pb-clipboard.js +79 -76
- package/src/pb-code-editor.js +110 -102
- package/src/pb-code-highlight.js +209 -204
- package/src/pb-codepen.js +79 -72
- package/src/pb-collapse.js +212 -207
- package/src/pb-combo-box.js +190 -190
- package/src/pb-components-bundle.js +1 -1
- package/src/pb-custom-form.js +151 -149
- package/src/pb-dialog.js +94 -85
- package/src/pb-document.js +89 -90
- package/src/pb-download.js +210 -198
- package/src/pb-drawer.js +145 -148
- package/src/pb-edit-app.js +301 -229
- package/src/pb-edit-xml.js +98 -96
- package/src/pb-events.js +114 -107
- package/src/pb-facs-link.js +104 -102
- package/src/pb-facsimile.js +411 -413
- package/src/pb-formula.js +151 -153
- package/src/pb-geolocation.js +129 -131
- package/src/pb-grid-action.js +53 -56
- package/src/pb-grid.js +231 -228
- package/src/pb-highlight.js +140 -140
- package/src/pb-hotkeys.js +40 -42
- package/src/pb-i18n.js +101 -104
- package/src/pb-image-strip.js +84 -78
- package/src/pb-lang.js +132 -128
- package/src/pb-leaflet-map.js +488 -485
- package/src/pb-link.js +126 -124
- package/src/pb-load.js +431 -426
- package/src/pb-login.js +291 -248
- package/src/pb-manage-odds.js +364 -318
- package/src/pb-map-icon.js +89 -89
- package/src/pb-map-layer.js +85 -85
- package/src/pb-markdown.js +90 -99
- package/src/pb-media-query.js +74 -72
- package/src/pb-mei.js +306 -295
- package/src/pb-message.js +144 -144
- package/src/pb-mixin.js +269 -264
- package/src/pb-navigation.js +80 -82
- package/src/pb-observable.js +38 -38
- package/src/pb-odd-editor.js +1053 -955
- package/src/pb-odd-elementspec-editor.js +348 -297
- package/src/pb-odd-model-editor.js +1061 -901
- package/src/pb-odd-parameter-editor.js +200 -178
- package/src/pb-odd-rendition-editor.js +136 -124
- package/src/pb-page.js +431 -421
- package/src/pb-paginate.js +202 -190
- package/src/pb-panel.js +191 -179
- package/src/pb-popover-themes.js +7 -5
- package/src/pb-popover.js +296 -287
- package/src/pb-print-preview.js +127 -127
- package/src/pb-progress.js +51 -51
- package/src/pb-repeat.js +105 -104
- package/src/pb-restricted.js +84 -77
- package/src/pb-search.js +252 -241
- package/src/pb-select-feature.js +127 -120
- package/src/pb-select-odd.js +132 -124
- package/src/pb-select-template.js +89 -78
- package/src/pb-select.js +251 -227
- package/src/pb-split-list.js +179 -174
- package/src/pb-svg.js +80 -79
- package/src/pb-table-column.js +54 -54
- package/src/pb-table-grid.js +221 -203
- package/src/pb-tabs.js +61 -63
- package/src/pb-tify.js +154 -154
- package/src/pb-timeline.js +271 -229
- package/src/pb-toggle-feature.js +182 -175
- package/src/pb-upload.js +184 -174
- package/src/pb-version.js +30 -30
- package/src/pb-view-annotate.js +132 -98
- package/src/pb-view.js +1289 -1270
- package/src/pb-zoom.js +75 -59
- package/src/polymer-hack.js +1 -1
- package/src/search-result-service.js +256 -223
- package/src/seed-element.js +13 -20
- package/src/settings.js +4 -4
- package/src/theming.js +96 -96
- package/src/urls.js +289 -289
- package/src/utils.js +53 -51
package/src/pb-code-highlight.js
CHANGED
|
@@ -1,204 +1,209 @@
|
|
|
1
|
-
import { LitElement, html, css } from 'lit-element';
|
|
2
|
-
import
|
|
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
|
|
8
|
-
|
|
9
|
-
const PRISM_THEMES = new Map();
|
|
10
|
-
|
|
11
|
-
function loadTheme(theme) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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(
|
|
26
|
+
html`<style>
|
|
27
|
+
${text}
|
|
28
|
+
</style>`,
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
PRISM_THEMES.set(themeName, promise);
|
|
33
|
+
return promise;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Highlight a code snippet. The snippet may either be passed in a template child
|
|
38
|
+
* element, which could contain HTML or text. If no template child is present, the
|
|
39
|
+
* component will take any text content contained in it and highlight it. One can also
|
|
40
|
+
* pass the code to be highlighted in the `code` property.
|
|
41
|
+
*
|
|
42
|
+
* @cssprop [--pb-code-highlight-white-space=pre] - configures line wrapping
|
|
43
|
+
* @cssprop [--pb-code-highlight-theme=default] - configures the default theme to be used
|
|
44
|
+
*/
|
|
45
|
+
export class PbCodeHighlight extends themableMixin(LitElement) {
|
|
46
|
+
static get properties() {
|
|
47
|
+
return {
|
|
48
|
+
/**
|
|
49
|
+
* The language to be used for syntax highlighting.
|
|
50
|
+
*/
|
|
51
|
+
language: {
|
|
52
|
+
type: String,
|
|
53
|
+
},
|
|
54
|
+
/**
|
|
55
|
+
* The code to be highlighted as a string. If not set,
|
|
56
|
+
* this will be populated from either a template child element
|
|
57
|
+
* or the element's text content.
|
|
58
|
+
* The value of the property can be changed programmatically from JavaScript.
|
|
59
|
+
*/
|
|
60
|
+
code: {
|
|
61
|
+
type: String,
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* Highlighting theme to use: 'coy', 'dark', 'funky', 'okaida', 'solarizedlight',
|
|
65
|
+
* 'tomorrow', 'twilight' or 'default'.
|
|
66
|
+
*/
|
|
67
|
+
theme: {
|
|
68
|
+
type: String,
|
|
69
|
+
},
|
|
70
|
+
lineNumbers: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
attribute: 'line-numbers',
|
|
73
|
+
},
|
|
74
|
+
_themeStyles: {
|
|
75
|
+
type: String,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
constructor() {
|
|
81
|
+
super();
|
|
82
|
+
this.language = 'xml';
|
|
83
|
+
this.theme = 'default';
|
|
84
|
+
this.lineNumbers = false;
|
|
85
|
+
this._themeStyles = null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
connectedCallback() {
|
|
89
|
+
super.connectedCallback();
|
|
90
|
+
let theme = this.getAttribute('theme');
|
|
91
|
+
if (theme === null) {
|
|
92
|
+
theme = getCSSProperty(this, '--pb-code-highlight-theme', 'default');
|
|
93
|
+
this.setAttribute('theme', theme);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
firstUpdated() {
|
|
98
|
+
super.firstUpdated();
|
|
99
|
+
|
|
100
|
+
if (!this.code) {
|
|
101
|
+
const template = this.querySelector('template');
|
|
102
|
+
if (template) {
|
|
103
|
+
this.code = Prism.plugins.NormalizeWhitespace.normalize(template.innerHTML);
|
|
104
|
+
} else {
|
|
105
|
+
this.code = Prism.plugins.NormalizeWhitespace.normalize(this.textContent);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
111
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
112
|
+
switch (name) {
|
|
113
|
+
case 'theme':
|
|
114
|
+
loadTheme(newValue).then(loadedStyles => {
|
|
115
|
+
this._themeStyles = loadedStyles;
|
|
116
|
+
});
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
updated(changedProperties) {
|
|
124
|
+
super.updated(changedProperties);
|
|
125
|
+
if (changedProperties.has('code')) {
|
|
126
|
+
// if the code property is changed, the content of the <code> element is replaced
|
|
127
|
+
const pre = this.shadowRoot.getElementById('pb-code-highlight');
|
|
128
|
+
if (pre != null) {
|
|
129
|
+
const code = document.createElement('code');
|
|
130
|
+
code.textContent = this.code; // textContent property keeps new lines in the code
|
|
131
|
+
pre.replaceChildren(code);
|
|
132
|
+
}
|
|
133
|
+
this.highlight();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
highlight() {
|
|
138
|
+
Prism.highlightAllUnder(this.shadowRoot);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
render() {
|
|
142
|
+
if (this.code) {
|
|
143
|
+
return html`
|
|
144
|
+
${this._themeStyles}
|
|
145
|
+
<pre
|
|
146
|
+
id="pb-code-highlight"
|
|
147
|
+
class="${this.lineNumbers ? 'line-numbers' : ''} language-${this.language}"
|
|
148
|
+
><code>${this.code}</code></pre>
|
|
149
|
+
`;
|
|
150
|
+
}
|
|
151
|
+
return html`<pre class="line-numbers"><code><code></pre>`;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static get styles() {
|
|
155
|
+
return css`
|
|
156
|
+
:host {
|
|
157
|
+
display: block;
|
|
158
|
+
}
|
|
159
|
+
pre[class*='language-'] {
|
|
160
|
+
margin: 0;
|
|
161
|
+
}
|
|
162
|
+
code[class*='language-'] {
|
|
163
|
+
white-space: var(--pb-code-highlight-white-space, pre);
|
|
164
|
+
}
|
|
165
|
+
pre.line-numbers {
|
|
166
|
+
position: relative;
|
|
167
|
+
padding-left: 3.8em;
|
|
168
|
+
counter-reset: linenumber;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
pre.line-numbers > code {
|
|
172
|
+
position: relative;
|
|
173
|
+
white-space: inherit;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.line-numbers .line-numbers-rows {
|
|
177
|
+
position: absolute;
|
|
178
|
+
pointer-events: none;
|
|
179
|
+
top: 0;
|
|
180
|
+
font-size: 100%;
|
|
181
|
+
left: -3.8em;
|
|
182
|
+
width: 3em; /* works for line-numbers below 1000 lines */
|
|
183
|
+
letter-spacing: -1px;
|
|
184
|
+
border-right: 1px solid #999;
|
|
185
|
+
|
|
186
|
+
-webkit-user-select: none;
|
|
187
|
+
-moz-user-select: none;
|
|
188
|
+
-ms-user-select: none;
|
|
189
|
+
user-select: none;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.line-numbers-rows > span {
|
|
193
|
+
pointer-events: none;
|
|
194
|
+
display: block;
|
|
195
|
+
counter-increment: linenumber;
|
|
196
|
+
height: auto !important;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.line-numbers-rows > span:before {
|
|
200
|
+
content: counter(linenumber);
|
|
201
|
+
color: #999;
|
|
202
|
+
display: block;
|
|
203
|
+
padding-right: 0.8em;
|
|
204
|
+
text-align: right;
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
customElements.define('pb-code-highlight', PbCodeHighlight);
|
package/src/pb-codepen.js
CHANGED
|
@@ -1,85 +1,92 @@
|
|
|
1
1
|
import { LitElement, html, css } from 'lit-element';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
/**
|
|
5
4
|
* Embed a codepen project to show live code. Used for some documentation examples.
|
|
6
5
|
*
|
|
7
6
|
*/
|
|
8
7
|
export class PbCodepen extends LitElement {
|
|
8
|
+
static get properties() {
|
|
9
|
+
return {
|
|
10
|
+
...super.properties,
|
|
11
|
+
/**
|
|
12
|
+
* The user which created the codepen
|
|
13
|
+
*/
|
|
14
|
+
user: {
|
|
15
|
+
type: String,
|
|
16
|
+
},
|
|
17
|
+
/**
|
|
18
|
+
* Identifies the pen
|
|
19
|
+
*/
|
|
20
|
+
hash: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
/**
|
|
24
|
+
* Height of the iframe in pixel
|
|
25
|
+
*/
|
|
26
|
+
height: {
|
|
27
|
+
type: Number,
|
|
28
|
+
},
|
|
29
|
+
/**
|
|
30
|
+
* Either 'dark' or 'light'
|
|
31
|
+
*/
|
|
32
|
+
theme: {
|
|
33
|
+
type: String,
|
|
34
|
+
},
|
|
35
|
+
/**
|
|
36
|
+
* If set, the codepen will not load before being
|
|
37
|
+
* clicked by the user
|
|
38
|
+
*/
|
|
39
|
+
preview: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Make the codepen editable (requires paid account)
|
|
44
|
+
*/
|
|
45
|
+
editable: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
9
50
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
*/
|
|
16
|
-
user: {
|
|
17
|
-
type: String
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* Identifies the pen
|
|
21
|
-
*/
|
|
22
|
-
hash: {
|
|
23
|
-
type: String
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* Height of the iframe in pixel
|
|
27
|
-
*/
|
|
28
|
-
height: {
|
|
29
|
-
type: Number
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Either 'dark' or 'light'
|
|
33
|
-
*/
|
|
34
|
-
theme: {
|
|
35
|
-
type: String
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* If set, the codepen will not load before being
|
|
39
|
-
* clicked by the user
|
|
40
|
-
*/
|
|
41
|
-
preview: {
|
|
42
|
-
type: Boolean
|
|
43
|
-
},
|
|
44
|
-
/**
|
|
45
|
-
* Make the codepen editable (requires paid account)
|
|
46
|
-
*/
|
|
47
|
-
editable: {
|
|
48
|
-
type: Boolean
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
}
|
|
51
|
+
constructor() {
|
|
52
|
+
super();
|
|
53
|
+
this.height = 256;
|
|
54
|
+
this.theme = 'light';
|
|
55
|
+
}
|
|
52
56
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
render() {
|
|
58
|
+
let params = `height=${this.height}&theme-id=${this.theme}&default-tab=html,result`;
|
|
59
|
+
if (this.editable) {
|
|
60
|
+
params = `${params}&editable=true`;
|
|
57
61
|
}
|
|
62
|
+
const url = `https://codepen.io/${this.user}/embed/${this.preview ? 'preview/' : ''}${
|
|
63
|
+
this.hash
|
|
64
|
+
}?${params}`;
|
|
65
|
+
return html`
|
|
66
|
+
<iframe
|
|
67
|
+
height="${this.height}"
|
|
68
|
+
scrolling="no"
|
|
69
|
+
title="${this.labe}l"
|
|
70
|
+
src="${url}"
|
|
71
|
+
frameborder="no"
|
|
72
|
+
allowtransparency="true"
|
|
73
|
+
allowfullscreen
|
|
74
|
+
>
|
|
75
|
+
Loading codepen ...
|
|
76
|
+
</iframe>
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
58
79
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const url = `https://codepen.io/${this.user}/embed/${this.preview ? 'preview/' : ''}${this.hash}?${params}`;
|
|
65
|
-
return html`
|
|
66
|
-
<iframe height="${this.height}" scrolling="no" title="${this.labe}l"
|
|
67
|
-
src="${url}" frameborder="no" allowtransparency="true" allowfullscreen>
|
|
68
|
-
Loading codepen ...
|
|
69
|
-
</iframe>
|
|
70
|
-
`;
|
|
71
|
-
}
|
|
80
|
+
static get styles() {
|
|
81
|
+
return css`
|
|
82
|
+
:host {
|
|
83
|
+
display: block;
|
|
84
|
+
}
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
iframe {
|
|
80
|
-
width: 100%;
|
|
81
|
-
}
|
|
82
|
-
`;
|
|
83
|
-
}
|
|
86
|
+
iframe {
|
|
87
|
+
width: 100%;
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
84
91
|
}
|
|
85
|
-
customElements.define('pb-codepen', PbCodepen);
|
|
92
|
+
customElements.define('pb-codepen', PbCodepen);
|