@teipublisher/pb-components 2.19.2 → 2.20.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/pb-components-bundle.js +22 -7
- package/dist/pb-elements.json +22 -1
- package/lib/openseadragon.min.js +75 -4
- package/lib/read-me-osd.md +12 -0
- package/package.json +1 -1
- package/pb-elements.json +22 -1
- package/src/pb-facsimile.js +7 -9
- package/src/pb-grid.js +41 -3
- package/src/pb-panel.js +70 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
## Openseadragon
|
|
2
|
+
|
|
3
|
+
We are using our own patched version of OSD from https://github.com/Jinntec/openseadragon
|
|
4
|
+
|
|
5
|
+
Reason:
|
|
6
|
+
OSD removes all body children when going to fullscreen. This creates issues with `<pb-page>` also be gone so display is empty after existing full-screen.
|
|
7
|
+
|
|
8
|
+
Fork is up-to-date with upstream OSD 4.1.1
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
package/package.json
CHANGED
package/pb-elements.json
CHANGED
|
@@ -4415,7 +4415,7 @@
|
|
|
4415
4415
|
},
|
|
4416
4416
|
{
|
|
4417
4417
|
"name": "pb-load-facsimile",
|
|
4418
|
-
"description": "When received, adds an image to the current image sequence. Emitted by
|
|
4418
|
+
"description": "When received, adds an image to the current image sequence. Emitted by\n`pb-facs-link`. The event detail should contain an object with the properties `url`, `order` and `element`,\nwhere `url` is the relative or absolute URL to the image, `order` is an integer specifying the position at which\nthe image should be inserted in the list, and `element` points to the `pb-facs-link` element triggering the event."
|
|
4419
4419
|
},
|
|
4420
4420
|
{
|
|
4421
4421
|
"name": "pb-show-annotation",
|
|
@@ -8791,6 +8791,12 @@
|
|
|
8791
8791
|
"description": "a name for each available panel, to be displayed in the dropdown. If not set,\neach template will be checked for a title attribute, which will be taken as name.",
|
|
8792
8792
|
"type": "array"
|
|
8793
8793
|
},
|
|
8794
|
+
{
|
|
8795
|
+
"name": "draggable",
|
|
8796
|
+
"description": "if set, the panel can be dragged to another position in the grid. A button will\nbe added to the toolbar to allow dragging.",
|
|
8797
|
+
"type": "boolean",
|
|
8798
|
+
"default": "false"
|
|
8799
|
+
},
|
|
8794
8800
|
{
|
|
8795
8801
|
"name": "subscribe",
|
|
8796
8802
|
"description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
|
|
@@ -8844,6 +8850,18 @@
|
|
|
8844
8850
|
"description": "a name for each available panel, to be displayed in the dropdown. If not set,\neach template will be checked for a title attribute, which will be taken as name.",
|
|
8845
8851
|
"type": "array"
|
|
8846
8852
|
},
|
|
8853
|
+
{
|
|
8854
|
+
"name": "position",
|
|
8855
|
+
"type": "number",
|
|
8856
|
+
"default": "-1"
|
|
8857
|
+
},
|
|
8858
|
+
{
|
|
8859
|
+
"name": "draggable",
|
|
8860
|
+
"attribute": "draggable",
|
|
8861
|
+
"description": "if set, the panel can be dragged to another position in the grid. A button will\nbe added to the toolbar to allow dragging.",
|
|
8862
|
+
"type": "boolean",
|
|
8863
|
+
"default": "false"
|
|
8864
|
+
},
|
|
8847
8865
|
{
|
|
8848
8866
|
"name": "subscribe",
|
|
8849
8867
|
"attribute": "subscribe",
|
|
@@ -8890,6 +8908,9 @@
|
|
|
8890
8908
|
{
|
|
8891
8909
|
"name": "pb-refresh",
|
|
8892
8910
|
"description": "Fired after a new content panel is shown to allow connected components to refresh."
|
|
8911
|
+
},
|
|
8912
|
+
{
|
|
8913
|
+
"name": "pb-drop"
|
|
8893
8914
|
}
|
|
8894
8915
|
],
|
|
8895
8916
|
"slots": [
|
package/src/pb-facsimile.js
CHANGED
|
@@ -7,7 +7,7 @@ import { resolveURL } from './utils.js';
|
|
|
7
7
|
* View zoomable images using a IIIF server.
|
|
8
8
|
*
|
|
9
9
|
* @fires pb-start-update - When received, resets the facsimile viewer
|
|
10
|
-
* @fires pb-load-facsimile - When received, adds an image to the current image sequence. Emitted by
|
|
10
|
+
* @fires pb-load-facsimile - When received, adds an image to the current image sequence. Emitted by
|
|
11
11
|
* `pb-facs-link`. The event detail should contain an object with the properties `url`, `order` and `element`,
|
|
12
12
|
* where `url` is the relative or absolute URL to the image, `order` is an integer specifying the position at which
|
|
13
13
|
* the image should be inserted in the list, and `element` points to the `pb-facs-link` element triggering the event.
|
|
@@ -41,7 +41,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
41
41
|
type: Boolean,
|
|
42
42
|
attribute: 'show-navigator'
|
|
43
43
|
},
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
/** If true then the 'previous" and 'next' button is displayed switch between images. */
|
|
46
46
|
showSequenceMode: {
|
|
47
47
|
type: Boolean,
|
|
@@ -173,16 +173,16 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
173
173
|
this.subscribeTo('pb-start-update', this._clearAll.bind(this));
|
|
174
174
|
this.subscribeTo('pb-load-facsimile', (e) => {
|
|
175
175
|
const { element, order } = e.detail
|
|
176
|
-
const itemOrder = this._facsimiles.map(item => item.getOrder ? item.getOrder() : Number.POSITIVE_INFINITY )
|
|
176
|
+
const itemOrder = this._facsimiles.map(item => item.getOrder ? item.getOrder() : Number.POSITIVE_INFINITY )
|
|
177
177
|
const insertAt = itemOrder.reduce((result, next, index) => {
|
|
178
178
|
if (order < next) return result;
|
|
179
179
|
if (order === next) return index;
|
|
180
180
|
return index + 1;
|
|
181
181
|
}, 0)
|
|
182
|
-
|
|
182
|
+
|
|
183
183
|
this._facsimiles.splice(insertAt, 0, element)
|
|
184
184
|
this.loaded = this._facsimiles.length > 0;
|
|
185
|
-
|
|
185
|
+
|
|
186
186
|
this._facsimileObserver()
|
|
187
187
|
});
|
|
188
188
|
this.subscribeTo('pb-show-annotation', this._showAnnotationListener.bind(this));
|
|
@@ -236,7 +236,7 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
236
236
|
const options = {
|
|
237
237
|
element: this.shadowRoot.getElementById('viewer'),
|
|
238
238
|
prefixUrl,
|
|
239
|
-
preserveViewport: true,
|
|
239
|
+
preserveViewport: true,
|
|
240
240
|
showZoomControl: true,
|
|
241
241
|
sequenceMode: this.showSequenceMode,
|
|
242
242
|
showHomeControl: this.showHomeControl,
|
|
@@ -271,10 +271,8 @@ export class PbFacsimile extends pbMixin(LitElement) {
|
|
|
271
271
|
to full-page functionality. Standard OSD completely deletes all body children disconnecting all event-handlers
|
|
272
272
|
that have been there. This solution just uses style.display to hide/show. Former display value of pb-page
|
|
273
273
|
will be preserved.
|
|
274
|
-
|
|
275
|
-
Current limitation: this solution assumes that a pb-page element exists and is an immediate child of body.
|
|
276
274
|
*/
|
|
277
|
-
this.ownerPage =
|
|
275
|
+
this.ownerPage = document.querySelector('pb-page');
|
|
278
276
|
if(this.ownerPage){
|
|
279
277
|
this.pbPageDisplay = window.getComputedStyle(this.ownerPage).getPropertyValue('display');
|
|
280
278
|
this.viewer.addHandler('full-screen', (ev) => {
|
package/src/pb-grid.js
CHANGED
|
@@ -92,10 +92,27 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
firstUpdated() {
|
|
95
|
+
|
|
95
96
|
this.panels.forEach(panelNum => this._insertPanel(panelNum));
|
|
96
97
|
registry.commit(this, this._getState())
|
|
97
98
|
this._animate();
|
|
98
99
|
this._update();
|
|
100
|
+
|
|
101
|
+
this.addEventListener('pb-drop', (ev) => {
|
|
102
|
+
const draggedPanelIdx = parseInt(ev.detail.panel);
|
|
103
|
+
const targetPanelIdx = this._getPanelIndex(ev.detail.target);
|
|
104
|
+
|
|
105
|
+
console.log('<pb-grid> Insert panel %d at %d in %s', draggedPanelIdx, targetPanelIdx, this.panels);
|
|
106
|
+
this.querySelectorAll('._grid_panel').forEach((panel) => {
|
|
107
|
+
panel.classList.remove('dragover');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
this.panels.splice(targetPanelIdx, 0, this.panels.splice(draggedPanelIdx, 1)[0]);
|
|
111
|
+
this.innerHTML=''; // hard reset of child DOM
|
|
112
|
+
this.panels.forEach(panelNum => this._insertPanel(panelNum));
|
|
113
|
+
registry.commit(this, this._getState());
|
|
114
|
+
this._update();
|
|
115
|
+
});
|
|
99
116
|
}
|
|
100
117
|
|
|
101
118
|
/**
|
|
@@ -153,14 +170,28 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
153
170
|
this.emitTo('pb-refresh', null);
|
|
154
171
|
}
|
|
155
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Remove a panel from the grid
|
|
175
|
+
*
|
|
176
|
+
* @param {HTMLElement|number} panel the pb-panel element or the panel number
|
|
177
|
+
*/
|
|
156
178
|
removePanel(panel) {
|
|
157
|
-
|
|
179
|
+
let idx;
|
|
180
|
+
let container;
|
|
181
|
+
if (typeof panel === 'number') {
|
|
182
|
+
idx = this.panels.indexOf(panel);
|
|
183
|
+
container = this.querySelector(`[active="${panel}"]`);
|
|
184
|
+
} else {
|
|
185
|
+
container = panel;
|
|
186
|
+
idx = this._getPanelIndex(panel);
|
|
187
|
+
}
|
|
158
188
|
console.log('<pb-grid> Removing panel %d', idx);
|
|
159
189
|
this.panels.splice(this.direction === 'rtl' ? this.panels.length - idx - 1 : idx, 1);
|
|
160
190
|
|
|
161
|
-
|
|
191
|
+
container.parentNode.removeChild(panel);
|
|
162
192
|
this._columns -= 1;
|
|
163
|
-
registry.commit(this, this._getState()
|
|
193
|
+
registry.commit(this, this._getState());
|
|
194
|
+
this._assignPanelIds();
|
|
164
195
|
this._update();
|
|
165
196
|
}
|
|
166
197
|
|
|
@@ -173,6 +204,7 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
173
204
|
this.insertBefore(clone, this.firstElementChild);
|
|
174
205
|
}
|
|
175
206
|
clone.classList.add('_grid_panel');
|
|
207
|
+
this._assignPanelIds();
|
|
176
208
|
}
|
|
177
209
|
|
|
178
210
|
_update() {
|
|
@@ -194,6 +226,12 @@ export class PbGrid extends pbMixin(LitElement) {
|
|
|
194
226
|
return panels.indexOf(panel);
|
|
195
227
|
}
|
|
196
228
|
|
|
229
|
+
_assignPanelIds() {
|
|
230
|
+
this.querySelectorAll('._grid_panel').forEach((panel, idx) => {
|
|
231
|
+
panel.position = idx;
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
197
235
|
_getState() {
|
|
198
236
|
return { panels: this.panels.join('.') };
|
|
199
237
|
}
|
package/src/pb-panel.js
CHANGED
|
@@ -43,6 +43,13 @@ export class PbPanel extends pbMixin(LitElement) {
|
|
|
43
43
|
panels: {
|
|
44
44
|
type: Array,
|
|
45
45
|
reflect: true
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* if set, the panel can be dragged to another position in the grid. A button will
|
|
49
|
+
* be added to the toolbar to allow dragging.
|
|
50
|
+
*/
|
|
51
|
+
draggable: {
|
|
52
|
+
type: Boolean
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
}
|
|
@@ -52,6 +59,8 @@ export class PbPanel extends pbMixin(LitElement) {
|
|
|
52
59
|
this.active = 0;
|
|
53
60
|
this.label = 'View';
|
|
54
61
|
this.panels = null;
|
|
62
|
+
this.position = -1;
|
|
63
|
+
this.draggable = false;
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
connectedCallback() {
|
|
@@ -65,15 +74,59 @@ export class PbPanel extends pbMixin(LitElement) {
|
|
|
65
74
|
this._show();
|
|
66
75
|
}
|
|
67
76
|
|
|
77
|
+
firstUpdated() {
|
|
78
|
+
const dragHandle = this.shadowRoot.getElementById('drag-handle');
|
|
79
|
+
let initiator = null;
|
|
80
|
+
|
|
81
|
+
if (this.draggable) {
|
|
82
|
+
dragHandle.addEventListener('dragstart', (ev) => {
|
|
83
|
+
ev.dataTransfer.setDragImage(this, 10, 10);
|
|
84
|
+
ev.dataTransfer.setData("text", this.position);
|
|
85
|
+
initiator = this;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.addEventListener('dragover', (ev) => {
|
|
90
|
+
ev.preventDefault();
|
|
91
|
+
});
|
|
92
|
+
document.addEventListener('dragenter', (ev) => {
|
|
93
|
+
ev.stopPropagation();
|
|
94
|
+
ev.preventDefault();
|
|
95
|
+
if (initiator === this) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (this.contains(ev.target)) {
|
|
99
|
+
this.classList.add('dragover');
|
|
100
|
+
} else {
|
|
101
|
+
this.classList.remove('dragover');
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
this.addEventListener('drop', (ev) => {
|
|
105
|
+
ev.stopPropagation();
|
|
106
|
+
ev.preventDefault();
|
|
107
|
+
|
|
108
|
+
initiator = null;
|
|
109
|
+
this.dispatchEvent(new CustomEvent('pb-drop', {
|
|
110
|
+
detail: {
|
|
111
|
+
panel: ev.dataTransfer.getData("text"),
|
|
112
|
+
target: this
|
|
113
|
+
},
|
|
114
|
+
bubbles: true,
|
|
115
|
+
composed: true
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
68
120
|
render() {
|
|
69
121
|
return html`
|
|
70
|
-
<app-toolbar>
|
|
122
|
+
<app-toolbar id="toolbar">
|
|
71
123
|
<paper-dropdown-menu id="menu" label="${this.label}">
|
|
72
124
|
<paper-listbox id="panels" slot="dropdown-content" class="dropdown-content"
|
|
73
|
-
|
|
125
|
+
selected="${this.active}" @selected-item-changed="${this._update}">
|
|
74
126
|
${this.panels.map((item) => html`<paper-item>${item}</paper-item>`)}
|
|
75
|
-
|
|
127
|
+
</paper-listbox>
|
|
76
128
|
</paper-dropdown-menu>
|
|
129
|
+
${this.draggable ? html`<paper-icon-button id="drag-handle" icon="icons:open-with" draggable="true"></paper-icon-button>` : ''}
|
|
77
130
|
<slot name="toolbar"></slot>
|
|
78
131
|
</app-toolbar>
|
|
79
132
|
<slot></slot>
|
|
@@ -99,6 +152,20 @@ export class PbPanel extends pbMixin(LitElement) {
|
|
|
99
152
|
app-toolbar {
|
|
100
153
|
font-size: 75%;
|
|
101
154
|
}
|
|
155
|
+
|
|
156
|
+
:host(.dragover) {
|
|
157
|
+
background-color: var(--pb-grid-highlight-color, var(--pb-highlight-color));
|
|
158
|
+
animation: highlight 1s;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@keyframes highlight {
|
|
162
|
+
from {
|
|
163
|
+
background-color: transparent;
|
|
164
|
+
}
|
|
165
|
+
to {
|
|
166
|
+
background-color: var(--pb-grid-highlight-color, var(--pb-highlight-color));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
102
169
|
`;
|
|
103
170
|
}
|
|
104
171
|
|