@teipublisher/pb-components 2.3.0 → 2.3.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/demo/bundle-test.html +1 -1
  3. package/dist/demo/dts-client.html +1 -1
  4. package/dist/demo/pb-autocomplete.html +1 -1
  5. package/dist/demo/pb-autocomplete2.html +1 -1
  6. package/dist/demo/pb-blacklab-highlight.html +1 -1
  7. package/dist/demo/pb-blacklab-results.html +1 -1
  8. package/dist/demo/pb-browse-docs.html +1 -1
  9. package/dist/demo/pb-browse-docs2.html +1 -1
  10. package/dist/demo/pb-clipboard.html +1 -1
  11. package/dist/demo/pb-code-editor.html +2 -4
  12. package/dist/demo/pb-collapse.html +1 -1
  13. package/dist/demo/pb-collapse2.html +1 -1
  14. package/dist/demo/pb-combo-box.html +1 -1
  15. package/dist/demo/pb-custom-form.html +1 -1
  16. package/dist/demo/pb-document.html +1 -1
  17. package/dist/demo/pb-download.html +1 -1
  18. package/dist/demo/pb-drawer.html +1 -1
  19. package/dist/demo/pb-drawer2.html +1 -1
  20. package/dist/demo/pb-edit-app.html +1 -1
  21. package/dist/demo/pb-edit-xml.html +1 -1
  22. package/dist/demo/pb-facsimile-2.html +1 -1
  23. package/dist/demo/pb-facsimile.html +1 -1
  24. package/dist/demo/pb-formula.html +1 -1
  25. package/dist/demo/pb-grid.html +1 -1
  26. package/dist/demo/pb-image-strip-standalone.html +1 -1
  27. package/dist/demo/pb-image-strip-view.html +1 -1
  28. package/dist/demo/pb-leaflet-map.html +1 -1
  29. package/dist/demo/pb-leaflet-map2.html +1 -1
  30. package/dist/demo/pb-leaflet-map3.html +1 -1
  31. package/dist/demo/pb-link.html +1 -1
  32. package/dist/demo/pb-load.html +1 -1
  33. package/dist/demo/pb-login.html +1 -1
  34. package/dist/demo/pb-manage-odds.html +1 -1
  35. package/dist/demo/pb-markdown.html +1 -1
  36. package/dist/demo/pb-media-query.html +1 -1
  37. package/dist/demo/pb-mei.html +1 -1
  38. package/dist/demo/pb-mei2.html +1 -1
  39. package/dist/demo/pb-odd-editor.html +1 -1
  40. package/dist/demo/pb-popover.html +1 -1
  41. package/dist/demo/pb-print-preview.html +1 -1
  42. package/dist/demo/pb-search.html +1 -1
  43. package/dist/demo/pb-search2.html +1 -1
  44. package/dist/demo/pb-search3.html +1 -1
  45. package/dist/demo/pb-search4.html +1 -1
  46. package/dist/demo/pb-select-feature.html +1 -1
  47. package/dist/demo/pb-select-feature2.html +1 -1
  48. package/dist/demo/pb-select-feature3.html +1 -1
  49. package/dist/demo/pb-select-odd.html +1 -1
  50. package/dist/demo/pb-select.html +1 -1
  51. package/dist/demo/pb-select2.html +1 -1
  52. package/dist/demo/pb-select3.html +1 -1
  53. package/dist/demo/pb-svg.html +1 -1
  54. package/dist/demo/pb-table-grid.html +2 -2
  55. package/dist/demo/pb-tabs.html +1 -1
  56. package/dist/demo/pb-timeline2.html +1 -1
  57. package/dist/demo/pb-toggle-feature.html +1 -1
  58. package/dist/demo/pb-toggle-feature2.html +1 -1
  59. package/dist/demo/pb-toggle-feature3.html +1 -1
  60. package/dist/demo/pb-view.html +1 -1
  61. package/dist/demo/pb-view2.html +1 -1
  62. package/dist/demo/pb-view3.html +1 -1
  63. package/dist/demo/pb-view4.html +1 -1
  64. package/dist/demo/pb-zoom.html +1 -1
  65. package/dist/pb-components-bundle.js +4 -4
  66. package/dist/pb-elements.json +15 -0
  67. package/package.json +1 -1
  68. package/pb-elements.json +15 -0
  69. package/src/pb-page.js +16 -1
  70. package/src/pb-view.js +3 -3
  71. package/src/urls.js +23 -4
@@ -8164,9 +8164,16 @@
8164
8164
  },
8165
8165
  {
8166
8166
  "name": "url-path",
8167
+ "description": "Is the resource path part of the URL or should it be\nencoded as a parameter? TEI Publisher uses the\nURL path, but the webcomponent demos need to encode the resource path\nin a query parameter.",
8167
8168
  "type": "string",
8168
8169
  "default": "\"path\""
8169
8170
  },
8171
+ {
8172
+ "name": "id-hash",
8173
+ "description": "If enabled, a hash in the URL (e.g. documentation.xml#introduction) will\nbe interpreted as an xml:id to navigate to when talking to the server.",
8174
+ "type": "boolean",
8175
+ "default": "false"
8176
+ },
8170
8177
  {
8171
8178
  "name": "api-version",
8172
8179
  "type": "string",
@@ -8266,9 +8273,17 @@
8266
8273
  {
8267
8274
  "name": "urlPath",
8268
8275
  "attribute": "url-path",
8276
+ "description": "Is the resource path part of the URL or should it be\nencoded as a parameter? TEI Publisher uses the\nURL path, but the webcomponent demos need to encode the resource path\nin a query parameter.",
8269
8277
  "type": "string",
8270
8278
  "default": "\"path\""
8271
8279
  },
8280
+ {
8281
+ "name": "idHash",
8282
+ "attribute": "id-hash",
8283
+ "description": "If enabled, a hash in the URL (e.g. documentation.xml#introduction) will\nbe interpreted as an xml:id to navigate to when talking to the server.",
8284
+ "type": "boolean",
8285
+ "default": "false"
8286
+ },
8272
8287
  {
8273
8288
  "name": "apiVersion",
8274
8289
  "attribute": "api-version",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "2.3.0",
3
+ "version": "2.3.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",
package/pb-elements.json CHANGED
@@ -8164,9 +8164,16 @@
8164
8164
  },
8165
8165
  {
8166
8166
  "name": "url-path",
8167
+ "description": "Is the resource path part of the URL or should it be\nencoded as a parameter? TEI Publisher uses the\nURL path, but the webcomponent demos need to encode the resource path\nin a query parameter.",
8167
8168
  "type": "string",
8168
8169
  "default": "\"path\""
8169
8170
  },
8171
+ {
8172
+ "name": "id-hash",
8173
+ "description": "If enabled, a hash in the URL (e.g. documentation.xml#introduction) will\nbe interpreted as an xml:id to navigate to when talking to the server.",
8174
+ "type": "boolean",
8175
+ "default": "false"
8176
+ },
8170
8177
  {
8171
8178
  "name": "api-version",
8172
8179
  "type": "string",
@@ -8266,9 +8273,17 @@
8266
8273
  {
8267
8274
  "name": "urlPath",
8268
8275
  "attribute": "url-path",
8276
+ "description": "Is the resource path part of the URL or should it be\nencoded as a parameter? TEI Publisher uses the\nURL path, but the webcomponent demos need to encode the resource path\nin a query parameter.",
8269
8277
  "type": "string",
8270
8278
  "default": "\"path\""
8271
8279
  },
8280
+ {
8281
+ "name": "idHash",
8282
+ "attribute": "id-hash",
8283
+ "description": "If enabled, a hash in the URL (e.g. documentation.xml#introduction) will\nbe interpreted as an xml:id to navigate to when talking to the server.",
8284
+ "type": "boolean",
8285
+ "default": "false"
8286
+ },
8272
8287
  {
8273
8288
  "name": "apiVersion",
8274
8289
  "attribute": "api-version",
package/src/pb-page.js CHANGED
@@ -39,10 +39,24 @@ export class PbPage extends pbMixin(LitElement) {
39
39
  type: String,
40
40
  attribute: 'app-root'
41
41
  },
42
+ /**
43
+ * Is the resource path part of the URL or should it be
44
+ * encoded as a parameter? TEI Publisher uses the
45
+ * URL path, but the webcomponent demos need to encode the resource path
46
+ * in a query parameter.
47
+ */
42
48
  urlPath: {
43
49
  type: String,
44
50
  attribute: 'url-path'
45
51
  },
52
+ /**
53
+ * If enabled, a hash in the URL (e.g. documentation.xml#introduction) will
54
+ * be interpreted as an xml:id to navigate to when talking to the server.
55
+ */
56
+ idHash: {
57
+ type: Boolean,
58
+ attribute: 'id-hash'
59
+ },
46
60
  /**
47
61
  * TEI Publisher internal: set to the current page template.
48
62
  */
@@ -148,6 +162,7 @@ export class PbPage extends pbMixin(LitElement) {
148
162
  this.unresolved = true;
149
163
  this.endpoint = ".";
150
164
  this.urlPath = 'path';
165
+ this.idHash = false;
151
166
  this.apiVersion = undefined;
152
167
  this.requireLanguage = false;
153
168
  this.theme = null;
@@ -189,7 +204,7 @@ export class PbPage extends pbMixin(LitElement) {
189
204
  this.appRoot = window.location.pathname;
190
205
  }
191
206
 
192
- registry.configure(this.urlPath === 'path', this.appRoot);
207
+ registry.configure(this.urlPath === 'path', this.idHash, this.appRoot);
193
208
 
194
209
  this.endpoint = this.endpoint.replace(/\/+$/, '');
195
210
 
package/src/pb-view.js CHANGED
@@ -907,13 +907,13 @@ export class PbView extends themableMixin(pbMixin(LitElement)) {
907
907
  if (this.noScroll) {
908
908
  return;
909
909
  }
910
- if (registry.state.id) {
911
- const target = this.shadowRoot.getElementById(registry.state.id);
910
+ if (registry.hash) {
911
+ const target = this.shadowRoot.getElementById(registry.hash.substring(1));
912
912
  console.log('hash target: %o', target);
913
913
  if (target) {
914
914
  window.requestAnimationFrame(() =>
915
915
  setTimeout(() => {
916
- target.scrollIntoView({block: 'nearest'});
916
+ target.scrollIntoView({ block: "center", inline: "nearest" });
917
917
  }, 400)
918
918
  );
919
919
  }
package/src/urls.js CHANGED
@@ -36,6 +36,11 @@ class Registry {
36
36
 
37
37
  constructor() {
38
38
  this.rootPath = '';
39
+ /**
40
+ * Is the resource path part of the URL path or is it
41
+ * passed in a query parameter?
42
+ */
43
+ this.usePath = false;
39
44
  /**
40
45
  * Records current state as determined from parsing the URL.
41
46
  * This should be used to initialize components.
@@ -46,12 +51,21 @@ class Registry {
46
51
  * if a component calls commit or replace.
47
52
  */
48
53
  this.channelStates = {};
54
+ /**
55
+ * Records the hash part of the URL, if any
56
+ */
57
+ this.hash = null;
58
+ /**
59
+ * Should a hash in the URL be interpreted as an xml:id for loading the content?
60
+ */
61
+ this.idHash = true;
49
62
  this._listeners = [];
50
63
  }
51
64
 
52
- configure(usePath = true, rootPath = '') {
65
+ configure(usePath = true, idHash = false, rootPath = '') {
53
66
  this.rootPath = rootPath;
54
67
  this.usePath = usePath;
68
+ this.idHash = idHash;
55
69
 
56
70
  // determine initial state of the registry by parsing current URL
57
71
  const initialState = this._stateFromURL();
@@ -92,8 +106,11 @@ class Registry {
92
106
 
93
107
  _stateFromURL() {
94
108
  const params = {};
95
- if (window.location.hash.length > 0) {
96
- params.id = window.location.hash.substring(1);
109
+ this.hash = window.location.hash;
110
+ // use the hash as an xml:id?
111
+ // hashs of the form #1.2.3.4 are internal eXist ids though and thus excluded
112
+ if (this.idHash && this.hash.length > 0 && (!/^#\d+\./.test(this.hash))) {
113
+ params.id = this.hash.substring(1);
97
114
  }
98
115
  if (this.usePath) {
99
116
  params.path = window.location.pathname.replace(new RegExp(`^${this.rootPath}/?`), '');
@@ -216,7 +233,9 @@ class Registry {
216
233
  newUrl.pathname = `${this.rootPath}/${this.state.path}`;
217
234
  }
218
235
 
219
- newUrl.hash = this.state.id ? `#${this.state.id}` : '';
236
+ if (this.state.id) {
237
+ newUrl.hash = `#${this.state.id}`;
238
+ }
220
239
 
221
240
  console.log('urlFromState', newUrl.searchParams.toString())
222
241
  return newUrl;