@teipublisher/pb-components 2.12.0 → 2.12.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teipublisher/pb-components",
3
- "version": "2.12.0",
3
+ "version": "2.12.2",
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",
@@ -28,7 +28,7 @@
28
28
  "lint": "npm run lint:eslint && npm run lint:prettier",
29
29
  "format": "npm run format:eslint && npm run format:prettier",
30
30
  "clean": "npm run clean-lib && rimraf dist css images/leaflet demo/build docs",
31
- "clean-lib": "rimraf -g lib/leaflet* lib/paged* lib/web-midi-player.js lib/openseadragon*",
31
+ "clean-lib": "rimraf -g lib/leaflet* lib/paged* lib/web-midi-player.js lib/openseadragon* lib/airtable.browser.js",
32
32
  "prepare": "npm run docs && npm run build:production",
33
33
  "semantic-release": "semantic-release",
34
34
  "gh-pages": "node gh-pages.js"
@@ -68,6 +68,7 @@
68
68
  "@vaadin/vaadin-tabs": "^3.2.0",
69
69
  "@vaadin/vaadin-upload": "^4.4.0",
70
70
  "@webcomponents/webcomponentsjs": "latest",
71
+ "airtable": "^0.12.2",
71
72
  "animejs": "^3.2.0",
72
73
  "browser-fs-access": "^0.34.1",
73
74
  "construct-style-sheets-polyfill": "^3.1.0",
@@ -55,7 +55,7 @@ export class Airtable extends Registry {
55
55
 
56
56
  _init() {
57
57
  window.ESGlobalBridge.requestAvailability();
58
- const path = resolveURL('https://cdn.jsdelivr.net/npm/airtable@0.11.1/build/airtable.browser.js');
58
+ const path = resolveURL('../lib/airtable.browser.js');
59
59
  window.ESGlobalBridge.instance.load('airtable', path);
60
60
  window.addEventListener(
61
61
  'es-bridge-airtable-loaded',
@@ -149,11 +149,12 @@ export class Airtable extends Registry {
149
149
  });
150
150
  const regex = new RegExp(this.tokenizeChars);
151
151
  this.tokenize.forEach((key) => {
152
- strings = strings.concat(data[key].split(regex));
152
+ if (data[key]) {
153
+ strings = strings.concat(data[key].split(regex));
154
+ }
153
155
  });
154
156
  strings = strings.filter(tok => !/^\d+$/.test(tok));
155
157
  strings.sort((s1, s2) => s2.length - s1.length);
156
- console.log(strings);
157
158
  container.innerHTML = expandTemplate(this.infoExpr, data);
158
159
 
159
160
  resolve({
@@ -313,9 +313,9 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
313
313
 
314
314
  <span class="icons">
315
315
  <pb-edit-xml id="editSource"><paper-icon-button icon="code" title="${translate('odd.editor.odd-source')}"></paper-icon-button></pb-edit-xml>
316
- <paper-icon-button @click="${this._download}" icon="icons:cloud-download" title="${fsSupported ? translate('odd.editor.save-as'): translate('odd.editor.download')}"></paper-icon-button>
316
+ <paper-icon-button @click="${() => this.save(true)}" icon="icons:cloud-download" title="${fsSupported ? translate('odd.editor.save-as'): translate('odd.editor.download')}"></paper-icon-button>
317
317
  <paper-icon-button @click="${this._reload}" icon="refresh" title="${translate('odd.editor.reload')}"></paper-icon-button>
318
- <paper-icon-button @click="${this.save}" icon="save" title="${translate('odd.editor.save')} ${this.display('save')}"
318
+ <paper-icon-button @click="${() => this.save(false)}" icon="save" title="${translate('odd.editor.save')} ${this.display('save')}"
319
319
  ?disabled="${!this.loggedIn}"></paper-icon-button>
320
320
  </span>
321
321
  </h3>
@@ -441,7 +441,7 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
441
441
  this.inited = true;
442
442
  });
443
443
 
444
- this.registerHotkey('save', this.save.bind(this));
444
+ this.registerHotkey('save', () => this.save(false));
445
445
  }
446
446
 
447
447
  setUseNamespace() {
@@ -892,32 +892,7 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
892
892
  return code;
893
893
  }
894
894
 
895
- _download() {
896
- if (this._hasChanges) {
897
- const dialog = this.shadowRoot.getElementById('dialog');
898
- dialog.confirm(i18n("odd.editor.save"), i18n('odd.editor.unsaved'))
899
- .then(
900
- () => this._downloadOdd(),
901
- () => console.log('<pb-odd-editor> Download aborted'));
902
- return;
903
- }
904
- this._downloadOdd();
905
- }
906
-
907
- _downloadOdd() {
908
- const data = this.serializeOdd();
909
- const blob = new Blob([data], { type: 'application/xml'});
910
- fileSave(blob, {
911
- fileName: this.odd,
912
- extensions: ['.odd'],
913
- })
914
- .then(
915
- () => console.log(`<pb-odd-editor> ${this.odd} exported`),
916
- () => console.log('<pb-odd-editor> export aborted')
917
- );
918
- }
919
-
920
- save() {
895
+ save(download=false) {
921
896
  document.dispatchEvent(new CustomEvent('pb-start-update'));
922
897
  const data = this.serializeOdd();
923
898
 
@@ -949,7 +924,9 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
949
924
 
950
925
  const request = saveOdd.generateRequest();
951
926
  request.completes
952
- .then(this.handleSaveComplete.bind(this))
927
+ .then((req) => {
928
+ this.handleSaveComplete(req, download);
929
+ })
953
930
  .catch(this.handleSaveError.bind(this));
954
931
  }
955
932
 
@@ -972,16 +949,16 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
972
949
  `;
973
950
  }
974
951
 
975
- handleSaveComplete(req) {
952
+ handleSaveComplete(req, download=false) {
976
953
  const data = req.response;
977
954
  if (data.status === 'denied') {
978
955
  this.shadowRoot.getElementById('dialog').set(i18n("odd.editor.denied"), i18n("odd.editor.denied-message", { odd: this.odd }));
979
956
  document.dispatchEvent(new CustomEvent('pb-end-update'));
980
957
  return;
981
958
  }
982
-
959
+
983
960
  let msg;
984
-
961
+
985
962
  if (this.lessThanApiVersion('1.0.0')) {
986
963
  const report = data.report.map(PbOddEditor._renderReport);
987
964
  msg = `<div class="list-group">${report.join('')}</div>`;
@@ -991,9 +968,21 @@ export class PbOddEditor extends pbHotkeys(pbMixin(LitElement)) {
991
968
  }
992
969
 
993
970
  this.shadowRoot.getElementById('dialog').set(i18n("odd.editor.saved"), msg);
994
-
971
+
995
972
  this._hasChanges = false;
996
973
  document.dispatchEvent(new CustomEvent('pb-end-update'));
974
+
975
+ if (download) {
976
+ const blob = new Blob([data.source], { type: 'application/xml'});
977
+ fileSave(blob, {
978
+ fileName: this.odd,
979
+ extensions: ['.odd'],
980
+ })
981
+ .then(
982
+ () => console.log(`<pb-odd-editor> ${this.odd} exported`),
983
+ () => console.log('<pb-odd-editor> export aborted')
984
+ );
985
+ }
997
986
  }
998
987
 
999
988
  handleSaveError(rejected) {