@teipublisher/pb-components 1.41.1 → 1.42.0
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/dist/demo/demos.json +3 -0
- package/dist/demo/pb-print-preview.html +32 -0
- package/dist/pb-components-bundle.js +3 -3
- package/dist/pb-elements.json +109 -2
- package/dist/pb-odd-editor.js +1 -1
- package/dist/pb-print-preview.js +6 -0
- package/package.json +2 -1
- package/pb-elements.json +109 -2
- package/src/pb-document.js +4 -0
- package/src/pb-link.js +8 -0
- package/src/pb-odd-model-editor.js +1 -0
- package/src/pb-print-preview.js +111 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teipublisher/pb-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"description": "Collection of webcomponents underlying TEI Publisher",
|
|
5
5
|
"repository": "https://github.com/eeditiones/tei-publisher-components.git",
|
|
6
6
|
"main": "index.html",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"lit-html": "^1.3.0",
|
|
81
81
|
"marked": "^1.2.0",
|
|
82
82
|
"openseadragon": "^2.4.2",
|
|
83
|
+
"pagedjs": "^0.4.0",
|
|
83
84
|
"prismjs": "^1.21.0",
|
|
84
85
|
"tippy.js": "^6.2.7",
|
|
85
86
|
"tom-select": "^2.0.2",
|
package/pb-elements.json
CHANGED
|
@@ -5145,6 +5145,11 @@
|
|
|
5145
5145
|
"description": "Switch the ODD to use for display",
|
|
5146
5146
|
"type": "string"
|
|
5147
5147
|
},
|
|
5148
|
+
{
|
|
5149
|
+
"name": "view",
|
|
5150
|
+
"description": "Control the view mode, i.e. 'page', 'div', 'single'",
|
|
5151
|
+
"type": "string"
|
|
5152
|
+
},
|
|
5148
5153
|
{
|
|
5149
5154
|
"name": "history",
|
|
5150
5155
|
"description": "Modify browser history: if set, clicking this\nelement will generate a new history entry in the browser's history.\nOnly use this on one element on the page.",
|
|
@@ -5213,6 +5218,12 @@
|
|
|
5213
5218
|
"description": "Switch the ODD to use for display",
|
|
5214
5219
|
"type": "string"
|
|
5215
5220
|
},
|
|
5221
|
+
{
|
|
5222
|
+
"name": "view",
|
|
5223
|
+
"attribute": "view",
|
|
5224
|
+
"description": "Control the view mode, i.e. 'page', 'div', 'single'",
|
|
5225
|
+
"type": "string"
|
|
5226
|
+
},
|
|
5216
5227
|
{
|
|
5217
5228
|
"name": "history",
|
|
5218
5229
|
"attribute": "history",
|
|
@@ -7256,7 +7267,7 @@
|
|
|
7256
7267
|
{
|
|
7257
7268
|
"name": "outputs",
|
|
7258
7269
|
"type": "array",
|
|
7259
|
-
"default": "[\"\",\"web\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7270
|
+
"default": "[\"\",\"web\",\"printcss\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7260
7271
|
},
|
|
7261
7272
|
{
|
|
7262
7273
|
"name": "behaviours",
|
|
@@ -7379,7 +7390,7 @@
|
|
|
7379
7390
|
"name": "outputs",
|
|
7380
7391
|
"attribute": "outputs",
|
|
7381
7392
|
"type": "array",
|
|
7382
|
-
"default": "[\"\",\"web\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7393
|
+
"default": "[\"\",\"web\",\"printcss\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7383
7394
|
},
|
|
7384
7395
|
{
|
|
7385
7396
|
"name": "parentModel",
|
|
@@ -8379,6 +8390,102 @@
|
|
|
8379
8390
|
}
|
|
8380
8391
|
]
|
|
8381
8392
|
},
|
|
8393
|
+
{
|
|
8394
|
+
"name": "pb-print-preview",
|
|
8395
|
+
"path": "./src/pb-print-preview.js",
|
|
8396
|
+
"attributes": [
|
|
8397
|
+
{
|
|
8398
|
+
"name": "src",
|
|
8399
|
+
"description": "ID of the pb-document this element is connected to. The document path to\nload will be taken from the pb-document.",
|
|
8400
|
+
"type": "string"
|
|
8401
|
+
},
|
|
8402
|
+
{
|
|
8403
|
+
"name": "styles",
|
|
8404
|
+
"type": "string"
|
|
8405
|
+
},
|
|
8406
|
+
{
|
|
8407
|
+
"name": "subscribe",
|
|
8408
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
8409
|
+
"type": "string"
|
|
8410
|
+
},
|
|
8411
|
+
{
|
|
8412
|
+
"name": "subscribe-config",
|
|
8413
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
8414
|
+
"type": "object"
|
|
8415
|
+
},
|
|
8416
|
+
{
|
|
8417
|
+
"name": "emit",
|
|
8418
|
+
"description": "The name of the channel to send events to.",
|
|
8419
|
+
"type": "string"
|
|
8420
|
+
},
|
|
8421
|
+
{
|
|
8422
|
+
"name": "emit-config",
|
|
8423
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
8424
|
+
"type": "object"
|
|
8425
|
+
},
|
|
8426
|
+
{
|
|
8427
|
+
"name": "wait-for",
|
|
8428
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
8429
|
+
"type": "string"
|
|
8430
|
+
},
|
|
8431
|
+
{
|
|
8432
|
+
"name": "disabled",
|
|
8433
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
8434
|
+
"type": "boolean",
|
|
8435
|
+
"default": "false"
|
|
8436
|
+
}
|
|
8437
|
+
],
|
|
8438
|
+
"properties": [
|
|
8439
|
+
{
|
|
8440
|
+
"name": "src",
|
|
8441
|
+
"attribute": "src",
|
|
8442
|
+
"description": "ID of the pb-document this element is connected to. The document path to\nload will be taken from the pb-document.",
|
|
8443
|
+
"type": "string"
|
|
8444
|
+
},
|
|
8445
|
+
{
|
|
8446
|
+
"name": "styles",
|
|
8447
|
+
"attribute": "styles",
|
|
8448
|
+
"type": "string"
|
|
8449
|
+
},
|
|
8450
|
+
{
|
|
8451
|
+
"name": "subscribe",
|
|
8452
|
+
"attribute": "subscribe",
|
|
8453
|
+
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
8454
|
+
"type": "string"
|
|
8455
|
+
},
|
|
8456
|
+
{
|
|
8457
|
+
"name": "subscribeConfig",
|
|
8458
|
+
"attribute": "subscribe-config",
|
|
8459
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to listen to.",
|
|
8460
|
+
"type": "object"
|
|
8461
|
+
},
|
|
8462
|
+
{
|
|
8463
|
+
"name": "emit",
|
|
8464
|
+
"attribute": "emit",
|
|
8465
|
+
"description": "The name of the channel to send events to.",
|
|
8466
|
+
"type": "string"
|
|
8467
|
+
},
|
|
8468
|
+
{
|
|
8469
|
+
"name": "emitConfig",
|
|
8470
|
+
"attribute": "emit-config",
|
|
8471
|
+
"description": "Configuration object to define a channel/event mapping. Every property\nin the object is interpreted as the name of a channel and its value should\nbe an array of event names to be dispatched.",
|
|
8472
|
+
"type": "object"
|
|
8473
|
+
},
|
|
8474
|
+
{
|
|
8475
|
+
"name": "waitFor",
|
|
8476
|
+
"attribute": "wait-for",
|
|
8477
|
+
"description": "A selector pointing to other components this component depends on.\nWhen method `wait` is called, it will wait until all referenced\ncomponents signal with a `pb-ready` event that they are ready and listening\nto events.",
|
|
8478
|
+
"type": "string"
|
|
8479
|
+
},
|
|
8480
|
+
{
|
|
8481
|
+
"name": "disabled",
|
|
8482
|
+
"attribute": "disabled",
|
|
8483
|
+
"description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
|
|
8484
|
+
"type": "boolean",
|
|
8485
|
+
"default": "false"
|
|
8486
|
+
}
|
|
8487
|
+
]
|
|
8488
|
+
},
|
|
8382
8489
|
{
|
|
8383
8490
|
"name": "pb-progress",
|
|
8384
8491
|
"path": "./src/pb-progress.js",
|
package/src/pb-document.js
CHANGED
package/src/pb-link.js
CHANGED
|
@@ -36,6 +36,10 @@ export class PbLink extends pbMixin(LitElement) {
|
|
|
36
36
|
odd: {
|
|
37
37
|
type: String
|
|
38
38
|
},
|
|
39
|
+
/** Control the view mode, i.e. 'page', 'div', 'single' */
|
|
40
|
+
view: {
|
|
41
|
+
type: String
|
|
42
|
+
},
|
|
39
43
|
/**
|
|
40
44
|
* Modify browser history: if set, clicking this
|
|
41
45
|
* element will generate a new history entry in the browser's history.
|
|
@@ -102,6 +106,10 @@ export class PbLink extends pbMixin(LitElement) {
|
|
|
102
106
|
params.odd = this.odd;
|
|
103
107
|
this.history && this.setParameter('odd', this.odd);
|
|
104
108
|
}
|
|
109
|
+
if (this.view) {
|
|
110
|
+
params.view = this.view;
|
|
111
|
+
this.history && this.setParameter('view', this.view);
|
|
112
|
+
}
|
|
105
113
|
if (this.hash){
|
|
106
114
|
params.hash = this.hash;
|
|
107
115
|
if (this.history) {
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { LitElement, html } from 'lit-element';
|
|
2
|
+
import { Previewer } from "pagedjs/dist/paged.esm";
|
|
3
|
+
import { pbMixin } from './pb-mixin.js';
|
|
4
|
+
import { resolveURL } from './utils.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* @customElement pb-print-preview
|
|
10
|
+
* @polymer
|
|
11
|
+
* @demo demo/pb-print-preview.html
|
|
12
|
+
* @appliesMixin pbMixin
|
|
13
|
+
*/
|
|
14
|
+
export class PbPrintPreview extends pbMixin(LitElement) {
|
|
15
|
+
|
|
16
|
+
static get properties() {
|
|
17
|
+
return {
|
|
18
|
+
/** ID of the pb-document this element is connected to. The document path to
|
|
19
|
+
* load will be taken from the pb-document.
|
|
20
|
+
*/
|
|
21
|
+
src: {
|
|
22
|
+
type: String
|
|
23
|
+
},
|
|
24
|
+
styles: {
|
|
25
|
+
type: String
|
|
26
|
+
},
|
|
27
|
+
...super.properties
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
constructor() {
|
|
32
|
+
super();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
connectedCallback() {
|
|
36
|
+
super.connectedCallback();
|
|
37
|
+
|
|
38
|
+
if (!document.head.querySelector('#pb-print-preview-interface')) {
|
|
39
|
+
const style = document.createElement('link');
|
|
40
|
+
style.id = 'pb-print-preview-interface';
|
|
41
|
+
style.rel = 'Stylesheet';
|
|
42
|
+
style.type = 'text/css';
|
|
43
|
+
style.href = resolveURL('../css/pagedjs/interface.css');
|
|
44
|
+
document.head.appendChild(style);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
firstUpdated() {
|
|
49
|
+
super.firstUpdated();
|
|
50
|
+
|
|
51
|
+
this._container = this.querySelector('.content');
|
|
52
|
+
|
|
53
|
+
PbPrintPreview.waitOnce('pb-page-ready', () => {
|
|
54
|
+
this.refresh();
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
refresh() {
|
|
59
|
+
this.emitTo('pb-start-update');
|
|
60
|
+
|
|
61
|
+
const doc = this.getDocument();
|
|
62
|
+
const params = new URLSearchParams();
|
|
63
|
+
params.set('wc', false);
|
|
64
|
+
if (doc.odd) {
|
|
65
|
+
params.set('odd', `${doc.odd}.odd`);
|
|
66
|
+
}
|
|
67
|
+
params.set('base', `${this.getEndpoint()}/${doc.getCollection()}`);
|
|
68
|
+
|
|
69
|
+
const url = `${this.getEndpoint()}/api/document/${encodeURIComponent(doc.path)}/print?${params.toString()}`;
|
|
70
|
+
fetch(url, {
|
|
71
|
+
method: 'GET',
|
|
72
|
+
mode: 'cors',
|
|
73
|
+
credentials: 'same-origin'
|
|
74
|
+
})
|
|
75
|
+
.then((response) => response.text())
|
|
76
|
+
.then((data) => {
|
|
77
|
+
const previewer = new Previewer();
|
|
78
|
+
// previewer.registerHandlers(previewHandler(this._container));
|
|
79
|
+
previewer.preview(data, this._getCustomStyles(), this._container);
|
|
80
|
+
this.emitTo('pb-end-update');
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
render() {
|
|
85
|
+
return html`
|
|
86
|
+
<div class="content"></div>
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
createRenderRoot() {
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_getCustomStyles() {
|
|
95
|
+
let customStyles = [];
|
|
96
|
+
if (this.getEndpoint()) {
|
|
97
|
+
const doc = this.getDocument();
|
|
98
|
+
if (this.styles) {
|
|
99
|
+
customStyles = this.styles.split(/\s*,\s*/).map((href) =>
|
|
100
|
+
this.toAbsoluteURL(href, this.getEndpoint())
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
if (doc.odd) {
|
|
104
|
+
customStyles.push(`${this.getEndpoint()}/transform/${doc.odd}.css`);
|
|
105
|
+
}
|
|
106
|
+
return customStyles;
|
|
107
|
+
}
|
|
108
|
+
return customStyles;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
customElements.define('pb-print-preview', PbPrintPreview);
|