@teipublisher/pb-components 1.41.2 → 1.42.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/pagedjs/interface.css +180 -0
- package/dist/demo/demos.json +3 -0
- package/dist/demo/pb-print-preview.html +32 -0
- package/dist/pb-components-bundle.js +2 -2
- package/dist/pb-elements.json +98 -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 +98 -2
- package/src/assets/pagedjs/interface.css +180 -0
- package/src/pb-document.js +4 -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.1",
|
|
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
|
@@ -7267,7 +7267,7 @@
|
|
|
7267
7267
|
{
|
|
7268
7268
|
"name": "outputs",
|
|
7269
7269
|
"type": "array",
|
|
7270
|
-
"default": "[\"\",\"web\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7270
|
+
"default": "[\"\",\"web\",\"printcss\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7271
7271
|
},
|
|
7272
7272
|
{
|
|
7273
7273
|
"name": "behaviours",
|
|
@@ -7390,7 +7390,7 @@
|
|
|
7390
7390
|
"name": "outputs",
|
|
7391
7391
|
"attribute": "outputs",
|
|
7392
7392
|
"type": "array",
|
|
7393
|
-
"default": "[\"\",\"web\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7393
|
+
"default": "[\"\",\"web\",\"printcss\",\"print\",\"epub\",\"fo\",\"latex\",\"plain\"]"
|
|
7394
7394
|
},
|
|
7395
7395
|
{
|
|
7396
7396
|
"name": "parentModel",
|
|
@@ -8390,6 +8390,102 @@
|
|
|
8390
8390
|
}
|
|
8391
8391
|
]
|
|
8392
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
|
+
},
|
|
8393
8489
|
{
|
|
8394
8490
|
"name": "pb-progress",
|
|
8395
8491
|
"path": "./src/pb-progress.js",
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/* CSS for Paged.js interface – v0.4 */
|
|
2
|
+
|
|
3
|
+
/* Change the look */
|
|
4
|
+
:root {
|
|
5
|
+
--color-background: whitesmoke;
|
|
6
|
+
--color-pageSheet: #cfcfcf;
|
|
7
|
+
--color-pageBox: violet;
|
|
8
|
+
--color-paper: white;
|
|
9
|
+
--color-marginBox: transparent;
|
|
10
|
+
--pagedjs-crop-color: black;
|
|
11
|
+
--pagedjs-crop-shadow: white;
|
|
12
|
+
--pagedjs-crop-stroke: 1px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* To define how the book look on the screen: */
|
|
16
|
+
@media screen, pagedjs-ignore {
|
|
17
|
+
#preview {
|
|
18
|
+
background-color: var(--color-background);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.pagedjs_pages {
|
|
22
|
+
display: flex;
|
|
23
|
+
width: calc(var(--pagedjs-width) * 2);
|
|
24
|
+
flex: 0;
|
|
25
|
+
flex-wrap: wrap;
|
|
26
|
+
margin: 0 auto;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.pagedjs_page {
|
|
30
|
+
background-color: var(--color-paper);
|
|
31
|
+
box-shadow: 0 0 0 1px var(--color-pageSheet);
|
|
32
|
+
margin: 0;
|
|
33
|
+
flex-shrink: 0;
|
|
34
|
+
flex-grow: 0;
|
|
35
|
+
margin-top: 10mm;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.pagedjs_first_page {
|
|
39
|
+
margin-left: var(--pagedjs-width);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.pagedjs_page:last-of-type {
|
|
43
|
+
margin-bottom: 10mm;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.pagedjs_pagebox{
|
|
47
|
+
box-shadow: 0 0 0 1px var(--color-pageBox);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.pagedjs_left_page{
|
|
51
|
+
z-index: 20;
|
|
52
|
+
width: calc(var(--pagedjs-bleed-left) + var(--pagedjs-pagebox-width))!important;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-crop {
|
|
56
|
+
border-color: transparent;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-middle{
|
|
60
|
+
width: 0;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.pagedjs_right_page{
|
|
64
|
+
z-index: 10;
|
|
65
|
+
position: relative;
|
|
66
|
+
left: calc(var(--pagedjs-bleed-left)*-1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* show the margin-box */
|
|
70
|
+
|
|
71
|
+
.pagedjs_margin-top-left-corner-holder,
|
|
72
|
+
.pagedjs_margin-top,
|
|
73
|
+
.pagedjs_margin-top-left,
|
|
74
|
+
.pagedjs_margin-top-center,
|
|
75
|
+
.pagedjs_margin-top-right,
|
|
76
|
+
.pagedjs_margin-top-right-corner-holder,
|
|
77
|
+
.pagedjs_margin-bottom-left-corner-holder,
|
|
78
|
+
.pagedjs_margin-bottom,
|
|
79
|
+
.pagedjs_margin-bottom-left,
|
|
80
|
+
.pagedjs_margin-bottom-center,
|
|
81
|
+
.pagedjs_margin-bottom-right,
|
|
82
|
+
.pagedjs_margin-bottom-right-corner-holder,
|
|
83
|
+
.pagedjs_margin-right,
|
|
84
|
+
.pagedjs_margin-right-top,
|
|
85
|
+
.pagedjs_margin-right-middle,
|
|
86
|
+
.pagedjs_margin-right-bottom,
|
|
87
|
+
.pagedjs_margin-left,
|
|
88
|
+
.pagedjs_margin-left-top,
|
|
89
|
+
.pagedjs_margin-left-middle,
|
|
90
|
+
.pagedjs_margin-left-bottom {
|
|
91
|
+
box-shadow: 0 0 0 1px inset var(--color-marginBox);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* uncomment this part for recto/verso book : ------------------------------------ */
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
.pagedjs_pages {
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
width: 100%;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.pagedjs_first_page {
|
|
103
|
+
margin-left: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.pagedjs_page {
|
|
107
|
+
margin: 0 auto;
|
|
108
|
+
margin-top: 10mm;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.pagedjs_left_page{
|
|
112
|
+
width: calc(var(--pagedjs-bleed-left) + var(--pagedjs-pagebox-width) + var(--pagedjs-bleed-left))!important;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-crop{
|
|
116
|
+
border-color: var(--pagedjs-crop-color);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.pagedjs_left_page .pagedjs_bleed-right .pagedjs_marks-middle{
|
|
120
|
+
width: var(--pagedjs-cross-size)!important;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.pagedjs_right_page{
|
|
124
|
+
left: 0;
|
|
125
|
+
}
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
/*--------------------------------------------------------------------------------------*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/* uncomment this par to see the baseline : -------------------------------------------*/
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
/* .pagedjs_pagebox {
|
|
138
|
+
--pagedjs-baseline: 22px;
|
|
139
|
+
--pagedjs-baseline-position: 5px;
|
|
140
|
+
--pagedjs-baseline-color: cyan;
|
|
141
|
+
background: linear-gradient(transparent 0%, transparent calc(var(--pagedjs-baseline) - 1px), var(--pagedjs-baseline-color) calc(var(--pagedjs-baseline) - 1px), var(--pagedjs-baseline-color) var(--pagedjs-baseline)), transparent;
|
|
142
|
+
background-size: 100% var(--pagedjs-baseline);
|
|
143
|
+
background-repeat: repeat-y;
|
|
144
|
+
background-position-y: var(--pagedjs-baseline-position);
|
|
145
|
+
} */
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
/*--------------------------------------------------------------------------------------*/
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
/* Marks (to delete when merge in paged.js) */
|
|
156
|
+
|
|
157
|
+
.pagedjs_marks-crop{
|
|
158
|
+
z-index: 999999999999;
|
|
159
|
+
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.pagedjs_bleed-top .pagedjs_marks-crop,
|
|
163
|
+
.pagedjs_bleed-bottom .pagedjs_marks-crop{
|
|
164
|
+
box-shadow: 1px 0px 0px 0px var(--pagedjs-crop-shadow);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.pagedjs_bleed-top .pagedjs_marks-crop:last-child,
|
|
168
|
+
.pagedjs_bleed-bottom .pagedjs_marks-crop:last-child{
|
|
169
|
+
box-shadow: -1px 0px 0px 0px var(--pagedjs-crop-shadow);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.pagedjs_bleed-left .pagedjs_marks-crop,
|
|
173
|
+
.pagedjs_bleed-right .pagedjs_marks-crop{
|
|
174
|
+
box-shadow: 0px 1px 0px 0px var(--pagedjs-crop-shadow);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.pagedjs_bleed-left .pagedjs_marks-crop:last-child,
|
|
178
|
+
.pagedjs_bleed-right .pagedjs_marks-crop:last-child{
|
|
179
|
+
box-shadow: 0px -1px 0px 0px var(--pagedjs-crop-shadow);
|
|
180
|
+
}
|
package/src/pb-document.js
CHANGED
|
@@ -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);
|