@teipublisher/pb-components 2.8.0 → 2.10.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.
@@ -111,7 +111,10 @@
111
111
  "reset": "Obnovit",
112
112
  "placeholder": "Zadejte dotaz",
113
113
  "sections": "Hledat v oddílech",
114
- "headings": "Hledat v nadpisech"
114
+ "headings": "Hledat v nadpisech",
115
+ "title": "Titul",
116
+ "content": "Text",
117
+ "scope": "Omezit hledání na"
115
118
  },
116
119
  "dts": {
117
120
  "endpoint": "Vybrat koncový bod",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "2.8.0",
3
+ "version": "2.10.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",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@babel/runtime": "7.11.2",
40
40
  "@cwmr/paper-autocomplete": "^4.0.0",
41
- "@jinntec/jinn-codemirror": "^1.11.6",
41
+ "@jinntec/jinn-codemirror": "^1.13.4",
42
42
  "@lrnwebcomponents/es-global-bridge": "^2.7.10",
43
43
  "@polymer/app-layout": "^3.1.0",
44
44
  "@polymer/iron-ajax": "^3.0.1",
@@ -85,6 +85,7 @@
85
85
  "pagedjs": "^0.4.0",
86
86
  "path-to-regexp": "^6.2.1",
87
87
  "prismjs": "^1.21.0",
88
+ "tify": "^0.28.1",
88
89
  "tippy.js": "^6.2.7",
89
90
  "tom-select": "^2.0.2",
90
91
  "uniqolor": "^1.0.1",
package/pb-elements.json CHANGED
@@ -3944,7 +3944,7 @@
3944
3944
  "name": "wait-for",
3945
3945
  "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.",
3946
3946
  "type": "string",
3947
- "default": "\"pb-facsimile,pb-image-strip\""
3947
+ "default": "\"pb-facsimile,pb-image-strip,pb-tify\""
3948
3948
  },
3949
3949
  {
3950
3950
  "name": "disabled",
@@ -4025,7 +4025,7 @@
4025
4025
  "attribute": "wait-for",
4026
4026
  "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.",
4027
4027
  "type": "string",
4028
- "default": "\"pb-facsimile,pb-image-strip\""
4028
+ "default": "\"pb-facsimile,pb-image-strip,pb-tify\""
4029
4029
  },
4030
4030
  {
4031
4031
  "name": "disabled",
@@ -10771,6 +10771,109 @@
10771
10771
  }
10772
10772
  ]
10773
10773
  },
10774
+ {
10775
+ "name": "pb-tify",
10776
+ "path": "./src/pb-tify.js",
10777
+ "description": "Viewer for IIIF presentation manifests based on https://tify.rocks/.\nRequires a proper manifest listing the resources to show. `pb-facs-link`\ncan be used to navigate to a page.",
10778
+ "attributes": [
10779
+ {
10780
+ "name": "manifest",
10781
+ "description": "URL pointing to a IIIF presentation manifest. Relative paths\nare interpreted relative to the API endpoint.",
10782
+ "type": "string"
10783
+ },
10784
+ {
10785
+ "name": "subscribe",
10786
+ "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
10787
+ "type": "string"
10788
+ },
10789
+ {
10790
+ "name": "subscribe-config",
10791
+ "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.",
10792
+ "type": "object"
10793
+ },
10794
+ {
10795
+ "name": "emit",
10796
+ "description": "The name of the channel to send events to.",
10797
+ "type": "string"
10798
+ },
10799
+ {
10800
+ "name": "emit-config",
10801
+ "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.",
10802
+ "type": "object"
10803
+ },
10804
+ {
10805
+ "name": "wait-for",
10806
+ "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.",
10807
+ "type": "string"
10808
+ },
10809
+ {
10810
+ "name": "disabled",
10811
+ "description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
10812
+ "type": "boolean",
10813
+ "default": "false"
10814
+ }
10815
+ ],
10816
+ "properties": [
10817
+ {
10818
+ "name": "manifest",
10819
+ "attribute": "manifest",
10820
+ "description": "URL pointing to a IIIF presentation manifest. Relative paths\nare interpreted relative to the API endpoint.",
10821
+ "type": "string"
10822
+ },
10823
+ {
10824
+ "name": "cssPath",
10825
+ "type": "string",
10826
+ "default": "\"../css/tify\""
10827
+ },
10828
+ {
10829
+ "name": "subscribe",
10830
+ "attribute": "subscribe",
10831
+ "description": "The name of the channel to subscribe to. Only events on a channel corresponding\nto this property are listened to.",
10832
+ "type": "string"
10833
+ },
10834
+ {
10835
+ "name": "subscribeConfig",
10836
+ "attribute": "subscribe-config",
10837
+ "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.",
10838
+ "type": "object"
10839
+ },
10840
+ {
10841
+ "name": "emit",
10842
+ "attribute": "emit",
10843
+ "description": "The name of the channel to send events to.",
10844
+ "type": "string"
10845
+ },
10846
+ {
10847
+ "name": "emitConfig",
10848
+ "attribute": "emit-config",
10849
+ "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.",
10850
+ "type": "object"
10851
+ },
10852
+ {
10853
+ "name": "waitFor",
10854
+ "attribute": "wait-for",
10855
+ "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.",
10856
+ "type": "string"
10857
+ },
10858
+ {
10859
+ "name": "disabled",
10860
+ "attribute": "disabled",
10861
+ "description": "Common property to disable the functionality associated with a component.\n`pb-highlight` and `pb-popover` react to this.",
10862
+ "type": "boolean",
10863
+ "default": "false"
10864
+ }
10865
+ ],
10866
+ "events": [
10867
+ {
10868
+ "name": "pb-refresh",
10869
+ "description": "if user opens another page and the corresponding canvas\nhas an extension property \"https://teipublisher.com/page\", listing the parameters\nto be passed to the event."
10870
+ },
10871
+ {
10872
+ "name": "pb-load-facsimile",
10873
+ "description": "when received, opens the page denoted by the\n`order` property in the event (see `pb-facs-link`). Page counts start at 1."
10874
+ }
10875
+ ]
10876
+ },
10774
10877
  {
10775
10878
  "name": "pb-timeline",
10776
10879
  "path": "./src/pb-timeline.js",
@@ -138,6 +138,7 @@ export class Anton extends Registry {
138
138
  case 'organization':
139
139
  register = 'actors';
140
140
  break;
141
+ case 'origPlace':
141
142
  case 'place':
142
143
  register = 'places';
143
144
  break;
@@ -152,4 +153,4 @@ export class Anton extends Registry {
152
153
  }
153
154
  return register;
154
155
  }
155
- }
156
+ }
@@ -47,7 +47,7 @@ export class PbFacsLink extends pbMixin(LitElement) {
47
47
  this.trigger = 'mouseover';
48
48
  this.label = '';
49
49
  this.order = Number.POSITIVE_INFINITY;
50
- this.waitFor = 'pb-facsimile,pb-image-strip';
50
+ this.waitFor = 'pb-facsimile,pb-image-strip,pb-tify';
51
51
  this.default = '';
52
52
  }
53
53
 
@@ -109,6 +109,7 @@ export class PbFacsLink extends pbMixin(LitElement) {
109
109
  this.emitTo('pb-show-annotation', {
110
110
  element: this,
111
111
  file: this.facs,
112
+ order: this.getOrder(),
112
113
  coordinates: this.coordinates
113
114
  });
114
115
  }
package/src/pb-tify.js ADDED
@@ -0,0 +1,113 @@
1
+ import { LitElement } from 'lit-element';
2
+ import "tify";
3
+ import { pbMixin, waitOnce } from './pb-mixin.js';
4
+ import { resolveURL } from './utils.js';
5
+
6
+ function _injectStylesheet(path) {
7
+ const style = document.querySelector(`link#pb-tify`);
8
+ if (!style) {
9
+ const elem = document.createElement('link');
10
+ elem.type = 'text/css';
11
+ elem.rel = 'stylesheet';
12
+ elem.id = `pb-tify`;
13
+ elem.href = `${resolveURL(path)}/tify.css`;
14
+ document.head.appendChild(elem);
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Viewer for IIIF presentation manifests based on https://tify.rocks/.
20
+ * Requires a proper manifest listing the resources to show. `pb-facs-link`
21
+ * can be used to navigate to a page.
22
+ *
23
+ * @fires pb-refresh - if user opens another page and the corresponding canvas
24
+ * has an extension property "https://teipublisher.com/page", listing the parameters
25
+ * to be passed to the event.
26
+ * @fires pb-load-facsimile - when received, opens the page denoted by the
27
+ * `order` property in the event (see `pb-facs-link`). Page counts start at 1.
28
+ */
29
+ export class PbTify extends pbMixin(LitElement) {
30
+ static get properties() {
31
+ return {
32
+ /**
33
+ * URL pointing to a IIIF presentation manifest. Relative paths
34
+ * are interpreted relative to the API endpoint.
35
+ */
36
+ manifest: {
37
+ type: String
38
+ },
39
+ ...super.properties
40
+ };
41
+ }
42
+
43
+ constructor() {
44
+ super();
45
+ this.cssPath = '../css/tify';
46
+ this._initialPages = null;
47
+ }
48
+
49
+ async connectedCallback() {
50
+ super.connectedCallback();
51
+
52
+ _injectStylesheet(this.cssPath);
53
+
54
+ this.subscribeTo('pb-load-facsimile', (ev) => {
55
+ if (ev.detail && ev.detail.order && this._tify) {
56
+ // check if tify is already initialized
57
+ if (this._setPage) {
58
+ this._setPage(parseInt(ev.detail.order, 10));
59
+ } else {
60
+ // remember page and wait for tify
61
+ this._initialPages = parseInt(ev.detail.order, 10);
62
+ }
63
+ }
64
+ });
65
+ }
66
+
67
+ firstUpdated() {
68
+ super.firstUpdated();
69
+
70
+ waitOnce('pb-page-ready', () => {
71
+ this._tify = new Tify({
72
+ manifestUrl: this.toAbsoluteURL(this.manifest, this.getEndpoint())
73
+ });
74
+ this._tify.ready.then(() => {
75
+ this.signalReady();
76
+ // open initial page if set earlier via pb-load-facsimile event
77
+ this._tify.setPage(this._initialPages);
78
+
79
+ // extend tify's setPage function to allow emitting an event
80
+ const {app} = this._tify;
81
+ this._setPage = app.setPage;
82
+
83
+ app.setPage = (pages) => {
84
+ const page = Array.isArray(pages) ? pages[0] : pages;
85
+ const canvas = app.$root.canvases[page - 1];
86
+
87
+ this._switchPage(canvas);
88
+ this._setPage(pages);
89
+ };
90
+ });
91
+
92
+ const container = document.createElement('div');
93
+ container.style.height = '100%';
94
+ container.style.width = '100%';
95
+ this.appendChild(container);
96
+
97
+ this._tify.mount(container);
98
+ });
99
+ }
100
+
101
+ _switchPage(canvas) {
102
+ const renderLink = canvas['https://teipublisher.com/page'];
103
+ if (renderLink) {
104
+ console.log('<pb-tify> page changed, emitting refresh with params %o', renderLink);
105
+ this.emitTo('pb-refresh', renderLink);
106
+ }
107
+ }
108
+
109
+ createRenderRoot() {
110
+ return this;
111
+ }
112
+ }
113
+ customElements.define('pb-tify', PbTify);