@myrmidon/cadmus-core 0.0.22 → 0.2.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.
Files changed (65) hide show
  1. package/README.md +24 -24
  2. package/esm2020/lib/cadmus-core.module.mjs +20 -0
  3. package/esm2020/lib/datation.mjs +520 -0
  4. package/esm2020/lib/guards/pending-changes.guard.mjs +24 -0
  5. package/esm2020/lib/historical-date.mjs +297 -0
  6. package/esm2020/lib/models.mjs +11 -0
  7. package/esm2020/lib/pipes/sort.pipe.mjs +41 -0
  8. package/esm2020/lib/services/gravatar.service.mjs +30 -0
  9. package/esm2020/lib/services/library-route.service.mjs +210 -0
  10. package/esm2020/lib/services/text-layer.service.mjs +680 -0
  11. package/esm2020/lib/text-range.mjs +58 -0
  12. package/esm2020/lib/token-location.mjs +74 -0
  13. package/esm2020/lib/token-point.mjs +65 -0
  14. package/esm2020/lib/validators/cadmus-validators.mjs +61 -0
  15. package/esm2020/lib/validators/password.validator.mjs +34 -0
  16. package/{esm2015/myrmidon-cadmus-core.js → esm2020/myrmidon-cadmus-core.mjs} +1 -1
  17. package/esm2020/public-api.mjs +19 -0
  18. package/fesm2015/{myrmidon-cadmus-core.js → myrmidon-cadmus-core.mjs} +83 -473
  19. package/fesm2015/myrmidon-cadmus-core.mjs.map +1 -0
  20. package/fesm2020/myrmidon-cadmus-core.mjs +2120 -0
  21. package/fesm2020/myrmidon-cadmus-core.mjs.map +1 -0
  22. package/lib/cadmus-core.module.d.ts +8 -0
  23. package/lib/guards/pending-changes.guard.d.ts +3 -0
  24. package/lib/models.d.ts +2 -19
  25. package/lib/pipes/sort.pipe.d.ts +3 -0
  26. package/lib/services/gravatar.service.d.ts +3 -0
  27. package/lib/services/library-route.service.d.ts +3 -0
  28. package/lib/services/text-layer.service.d.ts +3 -0
  29. package/lib/validators/cadmus-validators.d.ts +11 -0
  30. package/myrmidon-cadmus-core.d.ts +1 -0
  31. package/package.json +22 -10
  32. package/public-api.d.ts +0 -6
  33. package/bundles/myrmidon-cadmus-core.umd.js +0 -2903
  34. package/bundles/myrmidon-cadmus-core.umd.js.map +0 -1
  35. package/bundles/myrmidon-cadmus-core.umd.min.js +0 -2
  36. package/bundles/myrmidon-cadmus-core.umd.min.js.map +0 -1
  37. package/esm2015/lib/cadmus-core.module.js +0 -14
  38. package/esm2015/lib/datation.js +0 -520
  39. package/esm2015/lib/guards/pending-changes.guard.js +0 -22
  40. package/esm2015/lib/historical-date.js +0 -297
  41. package/esm2015/lib/models.js +0 -11
  42. package/esm2015/lib/pipes/sort.pipe.js +0 -37
  43. package/esm2015/lib/roman-number.js +0 -155
  44. package/esm2015/lib/services/env.service.js +0 -76
  45. package/esm2015/lib/services/env.service.provider.js +0 -31
  46. package/esm2015/lib/services/error.service.js +0 -38
  47. package/esm2015/lib/services/gravatar.service.js +0 -28
  48. package/esm2015/lib/services/library-route.service.js +0 -208
  49. package/esm2015/lib/services/local-storage.service.js +0 -99
  50. package/esm2015/lib/services/text-layer.service.js +0 -680
  51. package/esm2015/lib/text-range.js +0 -58
  52. package/esm2015/lib/token-location.js +0 -74
  53. package/esm2015/lib/token-point.js +0 -65
  54. package/esm2015/lib/utils.js +0 -36
  55. package/esm2015/lib/validators/cadmus-validators.js +0 -40
  56. package/esm2015/lib/validators/password.validator.js +0 -34
  57. package/esm2015/public-api.js +0 -25
  58. package/fesm2015/myrmidon-cadmus-core.js.map +0 -1
  59. package/lib/roman-number.d.ts +0 -34
  60. package/lib/services/env.service.d.ts +0 -52
  61. package/lib/services/env.service.provider.d.ts +0 -15
  62. package/lib/services/error.service.d.ts +0 -13
  63. package/lib/services/local-storage.service.d.ts +0 -32
  64. package/lib/utils.d.ts +0 -4
  65. package/myrmidon-cadmus-core.metadata.json +0 -1
@@ -1,165 +1,11 @@
1
- import { ɵɵdefineInjectable, Injectable, Pipe, ɵɵinject, Inject, NgModule } from '@angular/core';
2
- import { throwError } from 'rxjs';
3
- import { url } from 'gravatar';
4
- import { getSelection } from 'rangy';
1
+ import { RomanNumber, NgToolsModule } from '@myrmidon/ng-tools';
2
+ import * as i0 from '@angular/core';
3
+ import { Injectable, Pipe, Inject, NgModule } from '@angular/core';
4
+ import * as gravatar from 'gravatar';
5
+ import * as rangy from 'rangy';
5
6
  import { CommonModule } from '@angular/common';
6
7
  import { HttpClientModule } from '@angular/common/http';
7
8
 
8
- /**
9
- * Roman number converter.
10
- */
11
- class RomanNumber {
12
- /**
13
- * Convert the specified numeric value to a Roman number.
14
- *
15
- * @param value The value.
16
- * @param allowBar True to allow bar on letters. A bar on a letter
17
- * multiplies its value by 1000.
18
- * @param allowPrefix True to allow prefix notation.
19
- * @param ancient True to use the ancient preferred notation, i.e.
20
- * the preferred epigraphical notation (IIII instead of IV, VIIII instead of IX).
21
- */
22
- static toRoman(value, allowBar = true, allowPrefix = true, ancient = false) {
23
- if (value <= 0) {
24
- return '';
25
- }
26
- let place = allowBar ? 0 : 6;
27
- const sb = [];
28
- while (value > 0) {
29
- while (value >= this._postVal[place]) {
30
- sb.push(this._postAlpha[place]);
31
- value -= this._postVal[place];
32
- }
33
- if (allowPrefix) {
34
- if (value >= this._preVal[place]) {
35
- sb.push(this._preAlpha[place]);
36
- value -= this._preVal[place];
37
- }
38
- }
39
- place++;
40
- }
41
- if (ancient) {
42
- let s = sb.join('');
43
- s = s.replace('IV', 'IIII');
44
- return s.replace('IX', 'VIII');
45
- }
46
- return sb.join('');
47
- }
48
- static isLower(c) {
49
- return c.toLowerCase() === c;
50
- }
51
- static isUpper(c) {
52
- return c.toUpperCase() === c;
53
- }
54
- static isCaseEqual(c1, c2) {
55
- return ((this.isLower(c1) && this.isLower(c2)) ||
56
- (this.isUpper(c1) && this.isUpper(c2)));
57
- }
58
- static getRomanDigitValue(digit) {
59
- const i = this._romanDigits.indexOf(digit.toUpperCase());
60
- if (i === -1) {
61
- return 0;
62
- }
63
- return this.isLower(digit)
64
- ? this._romanValues[i] * 1000
65
- : this._romanValues[i];
66
- }
67
- /**
68
- * Convert the specified Roman number to a numeric value.
69
- *
70
- * @param roman: The Roman number.
71
- * @param allowBar: True to allow bar-on-letter notation.
72
- */
73
- static fromRoman(roman, allowBar = true) {
74
- if (!roman) {
75
- return 0;
76
- }
77
- let result = 0;
78
- if (!allowBar) {
79
- roman = roman.toUpperCase();
80
- }
81
- for (let index = 0; index < roman.length; index++) {
82
- // if the previous value was a sub-digit, it had to be subtracted instead
83
- // of added; thus, subtract it twice (once to compensate for the wrong addition,
84
- // and once to subtract from this value) from the current digit value
85
- result += this.getRomanDigitValue(roman[index]);
86
- if (index > 0) {
87
- const i = this._romanDigits.indexOf(roman[index]);
88
- if (roman[index - 1].toUpperCase() ===
89
- this._romanSubdigits[i].toUpperCase() &&
90
- this.isCaseEqual(roman[index - 1], roman[index])) {
91
- // tslint:disable-next-line:no-bitwise
92
- result -= this.getRomanDigitValue(this._romanSubdigits[i]) << 1;
93
- }
94
- }
95
- }
96
- return result;
97
- }
98
- }
99
- RomanNumber._postVal = [
100
- 1000000,
101
- 500000,
102
- 100000,
103
- 50000,
104
- 10000,
105
- 5000,
106
- 1000,
107
- 500,
108
- 100,
109
- 50,
110
- 10,
111
- 5,
112
- 1,
113
- ];
114
- RomanNumber._postAlpha = [
115
- 'm',
116
- 'd',
117
- 'c',
118
- 'l',
119
- 'x',
120
- 'v',
121
- 'M',
122
- 'D',
123
- 'C',
124
- 'L',
125
- 'X',
126
- 'V',
127
- 'I',
128
- ];
129
- RomanNumber._preVal = [
130
- 900000,
131
- 400000,
132
- 90000,
133
- 40000,
134
- 9000,
135
- 4000,
136
- 900,
137
- 400,
138
- 90,
139
- 40,
140
- 9,
141
- 4,
142
- 1,
143
- ];
144
- RomanNumber._preAlpha = [
145
- 'cm',
146
- 'cd',
147
- 'xc',
148
- 'xl',
149
- 'ix',
150
- 'iv',
151
- 'CM',
152
- 'CD',
153
- 'XC',
154
- 'XL',
155
- 'IX',
156
- 'IV',
157
- 'I',
158
- ];
159
- RomanNumber._romanDigits = 'IVXLCDM';
160
- RomanNumber._romanSubdigits = ' IIXXCC';
161
- RomanNumber._romanValues = [1, 5, 10, 50, 100, 500, 1000];
162
-
163
9
  /**
164
10
  * Default options for formatting a datation.
165
11
  */
@@ -1182,42 +1028,6 @@ class TokenLocation {
1182
1028
  }
1183
1029
  }
1184
1030
 
1185
- /**
1186
- * Deep-copy an object.
1187
- */
1188
- function deepCopy(obj) {
1189
- let copy;
1190
- // handle the 3 simple types, and null or undefined
1191
- if (null == obj || 'object' !== typeof obj) {
1192
- return obj;
1193
- }
1194
- // handle date
1195
- if (obj instanceof Date) {
1196
- copy = new Date();
1197
- copy.setTime(obj.getTime());
1198
- return copy;
1199
- }
1200
- // handle array
1201
- if (obj instanceof Array) {
1202
- copy = [];
1203
- for (let i = 0, len = obj.length; i < len; i++) {
1204
- copy[i] = deepCopy(obj[i]);
1205
- }
1206
- return copy;
1207
- }
1208
- // handle object
1209
- if (obj instanceof Object) {
1210
- copy = {};
1211
- for (const attr in obj) {
1212
- if (obj.hasOwnProperty(attr)) {
1213
- copy[attr] = deepCopy(obj[attr]);
1214
- }
1215
- }
1216
- return copy;
1217
- }
1218
- throw new Error('Unable to copy object!');
1219
- }
1220
-
1221
1031
  class PendingChangesGuard {
1222
1032
  canDeactivate(component) {
1223
1033
  // if there are no pending changes, just allow deactivation; else confirm first
@@ -1231,12 +1041,14 @@ class PendingChangesGuard {
1231
1041
  'Press Cancel to go back and save, OK to continue.');
1232
1042
  }
1233
1043
  }
1234
- PendingChangesGuard.ɵprov = ɵɵdefineInjectable({ factory: function PendingChangesGuard_Factory() { return new PendingChangesGuard(); }, token: PendingChangesGuard, providedIn: "root" });
1235
- PendingChangesGuard.decorators = [
1236
- { type: Injectable, args: [{
1237
- providedIn: 'root'
1238
- },] }
1239
- ];
1044
+ PendingChangesGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: PendingChangesGuard, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1045
+ PendingChangesGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: PendingChangesGuard, providedIn: 'root' });
1046
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: PendingChangesGuard, decorators: [{
1047
+ type: Injectable,
1048
+ args: [{
1049
+ providedIn: 'root'
1050
+ }]
1051
+ }] });
1240
1052
 
1241
1053
  /**
1242
1054
  * Sort pipe. Use like *ngFor="let i of items | sort:'propname'".
@@ -1268,150 +1080,14 @@ class SortPipe {
1268
1080
  });
1269
1081
  }
1270
1082
  }
1271
- SortPipe.decorators = [
1272
- { type: Pipe, args: [{
1273
- name: 'sort',
1274
- },] }
1275
- ];
1276
-
1277
- /**
1278
- * Environment variables service. This requires EnvServiceProvider.
1279
- * See https://www.jvandemo.com/how-to-use-environment-variables-to-configure-your-angular-application-without-a-rebuild/.
1280
- *
1281
- * To use this service:
1282
- * 1. ensure to add env.js from your app's src folder to the app's assets
1283
- * ("src/env.js" under architect/build/options/assets);
1284
- * 2. add the EnvServiceProvider to your app's providers array;
1285
- * 3. ensure to include env.js in the head of your index.html:
1286
- * <script src="env.js"></script>.
1287
- *
1288
- * The env.js file should include all your environment-dependent settings,
1289
- * e.g.:
1290
- *
1291
- * (function (window) {
1292
- * window.__env = window.__env || {};
1293
- * window.__env.apiUrl = 'http://localhost:60200/api/';
1294
- * }(this));
1295
- */
1296
- class EnvService {
1297
- constructor() {
1298
- this._map = new Map();
1299
- }
1300
- /**
1301
- * Get the value for the specified key. If the key is not found,
1302
- * defValue will be returned.
1303
- *
1304
- * @param key The key.
1305
- * @param defValue The default value to return if key is not found.
1306
- */
1307
- get(key, defValue) {
1308
- if (this._map.has(key)) {
1309
- return this._map.get(key);
1310
- }
1311
- return defValue;
1312
- }
1313
- /**
1314
- * Enumerate all the keys in this store.
1315
- */
1316
- getKeys() {
1317
- return this._map.keys();
1318
- }
1319
- /**
1320
- * Set a value with the specified key.
1321
- *
1322
- * @param key The key.
1323
- * @param value The value.
1324
- */
1325
- set(key, value) {
1326
- this._map.set(key, value);
1327
- }
1328
- /**
1329
- * Delete the value with the specified key, if any.
1330
- *
1331
- * @param key The key.
1332
- */
1333
- delete(key) {
1334
- this._map.delete(key);
1335
- }
1336
- /**
1337
- * Clear this store.
1338
- */
1339
- clear() {
1340
- this._map.clear();
1341
- }
1342
- }
1343
- EnvService.ɵprov = ɵɵdefineInjectable({ factory: function EnvService_Factory() { return new EnvService(); }, token: EnvService, providedIn: "root" });
1344
- EnvService.decorators = [
1345
- { type: Injectable, args: [{
1346
- providedIn: 'root',
1347
- },] }
1348
- ];
1349
- EnvService.ctorParameters = () => [];
1350
-
1351
- // https://www.jvandemo.com/how-to-use-environment-variables-to-configure-your-angular-application-without-a-rebuild/
1352
- /**
1353
- * This function creates an instance of EnvService, and copies
1354
- * all the properties from window.__env object into it.
1355
- */
1356
- const EnvServiceFactory = () => {
1357
- const env = new EnvService();
1358
- // read environment variables from browser window
1359
- const browserWindow = window || {};
1360
- const browserWindowEnv = browserWindow['__env'] || {};
1361
- // assign environment variables from browser window to env;
1362
- // in the current implementation, properties from env.js
1363
- // overwrite defaults (if any) from the EnvService.
1364
- for (const key in browserWindowEnv) {
1365
- if (browserWindowEnv.hasOwnProperty(key)) {
1366
- env.set(key, browserWindowEnv[key]);
1367
- }
1368
- }
1369
- return env;
1370
- };
1371
- /**
1372
- * A provider recipe for the EnvService.
1373
- * This must be registered in the applications providers array.
1374
- */
1375
- const EnvServiceProvider = {
1376
- provide: EnvService,
1377
- useFactory: EnvServiceFactory,
1378
- deps: [],
1379
- };
1380
-
1381
- // https://angular.io/guide/http
1382
- /**
1383
- * Error handler for services. To use this in your service, pipe a catchError
1384
- * operator with its argument equal to the handleError method of this service.
1385
- * Note: pipe this method after retry, if using it.
1386
- */
1387
- class ErrorService {
1388
- /**
1389
- * Handle the specified error response.
1390
- * @param error The error response.
1391
- */
1392
- handleError(error) {
1393
- if (error.error instanceof ErrorEvent) {
1394
- // A client-side or network error occurred. Handle it accordingly.
1395
- console.error('A client-side or network error occurred: ', error.error.message);
1396
- }
1397
- else {
1398
- // The backend returned an unsuccessful response code.
1399
- // The response body may contain clues as to what went wrong,
1400
- console.error(`Backend returned code ${error.status}, ` + `body was: ${error.error}`);
1401
- if (typeof error === 'object') {
1402
- console.log(JSON.stringify(error));
1403
- }
1404
- }
1405
- // return an observable with a user-facing error message
1406
- return throwError('Something bad happened; please try again later.');
1407
- }
1408
- }
1409
- ErrorService.ɵprov = ɵɵdefineInjectable({ factory: function ErrorService_Factory() { return new ErrorService(); }, token: ErrorService, providedIn: "root" });
1410
- ErrorService.decorators = [
1411
- { type: Injectable, args: [{
1412
- providedIn: 'root',
1413
- },] }
1414
- ];
1083
+ SortPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: SortPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1084
+ SortPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: SortPipe, name: "sort" });
1085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: SortPipe, decorators: [{
1086
+ type: Pipe,
1087
+ args: [{
1088
+ name: 'sort',
1089
+ }]
1090
+ }] });
1415
1091
 
1416
1092
  // npm i gravatar --save
1417
1093
  // npm i @types/gravatar --save
@@ -1426,17 +1102,19 @@ class GravatarService {
1426
1102
  if (!email) {
1427
1103
  return null;
1428
1104
  }
1429
- return url(email, { s: size.toString() });
1105
+ return gravatar.url(email, { s: size.toString() });
1430
1106
  // const hash = this._hash.getMd5(email.trim().toLowerCase());
1431
1107
  // return this.buildGravatarUrlFromHash(hash, size);
1432
1108
  }
1433
1109
  }
1434
- GravatarService.ɵprov = ɵɵdefineInjectable({ factory: function GravatarService_Factory() { return new GravatarService(); }, token: GravatarService, providedIn: "root" });
1435
- GravatarService.decorators = [
1436
- { type: Injectable, args: [{
1437
- providedIn: 'root'
1438
- },] }
1439
- ];
1110
+ GravatarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GravatarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1111
+ GravatarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GravatarService, providedIn: 'root' });
1112
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: GravatarService, decorators: [{
1113
+ type: Injectable,
1114
+ args: [{
1115
+ providedIn: 'root'
1116
+ }]
1117
+ }] });
1440
1118
 
1441
1119
  /**
1442
1120
  * Library route service.
@@ -1634,112 +1312,19 @@ class LibraryRouteService {
1634
1312
  };
1635
1313
  }
1636
1314
  }
1637
- LibraryRouteService.ɵprov = ɵɵdefineInjectable({ factory: function LibraryRouteService_Factory() { return new LibraryRouteService(ɵɵinject("partEditorKeys")); }, token: LibraryRouteService, providedIn: "root" });
1638
- LibraryRouteService.decorators = [
1639
- { type: Injectable, args: [{
1640
- providedIn: 'root'
1641
- },] }
1642
- ];
1643
- LibraryRouteService.ctorParameters = () => [
1644
- { type: undefined, decorators: [{ type: Inject, args: ['partEditorKeys',] }] }
1645
- ];
1646
-
1647
- class LocalStorageService {
1648
- /**
1649
- * Retrieve the object with the specified key from the specified storage.
1650
- * @param key key.
1651
- * @param session true to use session instead of local storage.
1652
- */
1653
- retrieve(key, session = false) {
1654
- const json = session
1655
- ? sessionStorage.getItem(key)
1656
- : localStorage.getItem(key);
1657
- if (!json) {
1658
- return null;
1659
- }
1660
- return JSON.parse(json);
1661
- }
1662
- /**
1663
- * Store the specified object with the specified key in the specified storage.
1664
- * @param key key.
1665
- * @param value object.
1666
- * @param session true to use session instead of local storage.
1667
- */
1668
- store(key, value, session = false) {
1669
- if (session) {
1670
- sessionStorage.setItem(key, JSON.stringify(value));
1671
- }
1672
- else {
1673
- localStorage.setItem(key, JSON.stringify(value));
1674
- }
1675
- }
1676
- /**
1677
- * Remove the object with the specified key from the specified storage.
1678
- * @param key key.
1679
- * @param session true to use session instead of local storage.
1680
- */
1681
- remove(key, session = false) {
1682
- if (session) {
1683
- sessionStorage.removeItem(key);
1684
- }
1685
- else {
1686
- localStorage.removeItem(key);
1687
- }
1688
- }
1689
- /**
1690
- * Get all the stored entities keys starting with the specified prefix.
1691
- * @param prefix key prefix.
1692
- * @param session true to use session instead of local storage.
1693
- */
1694
- getKeys(prefix, session = false) {
1695
- const keys = [];
1696
- if (session) {
1697
- for (let i = 0, len = sessionStorage.length; i < len; i++) {
1698
- const key = sessionStorage.key(i);
1699
- if (key.startsWith(prefix)) {
1700
- keys.push(key);
1701
- }
1702
- }
1703
- }
1704
- else {
1705
- for (let i = 0, len = localStorage.length; i < len; i++) {
1706
- const key = localStorage.key(i);
1707
- if (key.startsWith(prefix)) {
1708
- keys.push(key);
1709
- }
1710
- }
1711
- }
1712
- return keys;
1713
- }
1714
- /**
1715
- * Remove all the entries whose key starts with the specified prefix.
1716
- * @param prefix key prefix.
1717
- */
1718
- clear(prefix, session = false) {
1719
- if (session) {
1720
- for (let i = 0, len = sessionStorage.length; i < len; i++) {
1721
- const key = sessionStorage.key(i);
1722
- if (key.startsWith(prefix)) {
1723
- sessionStorage.removeItem(key);
1724
- }
1725
- }
1726
- }
1727
- else {
1728
- for (let i = 0, len = localStorage.length; i < len; i++) {
1729
- const key = localStorage.key(i);
1730
- if (key.startsWith(prefix)) {
1731
- localStorage.removeItem(key);
1732
- }
1733
- }
1734
- }
1735
- }
1736
- }
1737
- LocalStorageService.ɵprov = ɵɵdefineInjectable({ factory: function LocalStorageService_Factory() { return new LocalStorageService(); }, token: LocalStorageService, providedIn: "root" });
1738
- LocalStorageService.decorators = [
1739
- { type: Injectable, args: [{
1740
- providedIn: 'root',
1741
- },] }
1742
- ];
1315
+ LibraryRouteService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LibraryRouteService, deps: [{ token: 'partEditorKeys' }], target: i0.ɵɵFactoryTarget.Injectable });
1316
+ LibraryRouteService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LibraryRouteService, providedIn: 'root' });
1317
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: LibraryRouteService, decorators: [{
1318
+ type: Injectable,
1319
+ args: [{
1320
+ providedIn: 'root'
1321
+ }]
1322
+ }], ctorParameters: function () {
1323
+ return [{ type: undefined, decorators: [{
1324
+ type: Inject,
1325
+ args: ['partEditorKeys']
1326
+ }] }];
1327
+ } });
1743
1328
 
1744
1329
  class TextLayerService {
1745
1330
  constructor() {
@@ -2404,18 +1989,19 @@ class TextLayerService {
2404
1989
  * This uses the rangy library.
2405
1990
  */
2406
1991
  getSelectedRange() {
2407
- const sel = getSelection();
1992
+ const sel = rangy.getSelection();
2408
1993
  if (sel.isCollapsed) {
2409
1994
  return null;
2410
1995
  }
2411
1996
  return sel.getRangeAt(0);
2412
1997
  }
2413
1998
  }
2414
- TextLayerService.ɵprov = ɵɵdefineInjectable({ factory: function TextLayerService_Factory() { return new TextLayerService(); }, token: TextLayerService, providedIn: "root" });
2415
- TextLayerService.decorators = [
2416
- { type: Injectable, args: [{ providedIn: 'root' },] }
2417
- ];
2418
- TextLayerService.ctorParameters = () => [];
1999
+ TextLayerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TextLayerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2000
+ TextLayerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TextLayerService, providedIn: 'root' });
2001
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: TextLayerService, decorators: [{
2002
+ type: Injectable,
2003
+ args: [{ providedIn: 'root' }]
2004
+ }], ctorParameters: function () { return []; } });
2419
2005
 
2420
2006
  // https://github.com/angular/angular/blob/3b7d4ebbd6445364889d61b7b1b1c65206534d34/packages/forms/src/validators.ts
2421
2007
  // https://indepth.dev/posts/1319/the-best-way-to-implement-custom-validators
@@ -2455,6 +2041,27 @@ class CadmusValidators {
2455
2041
  : null;
2456
2042
  };
2457
2043
  }
2044
+ /**
2045
+ * Conditionally validate using the specified validator
2046
+ * when predicate is true.
2047
+ * See https://medium.com/ngx/3-ways-to-implement-conditional-validation-of-reactive-forms-c59ed6fc3325.
2048
+ *
2049
+ * @param predicate The predicate function to use when determining
2050
+ * if the validator should be used.
2051
+ * @param validator The conditional validator to use.
2052
+ * @returns Validation results.
2053
+ */
2054
+ static conditionalValidator(predicate, validator) {
2055
+ return (control) => {
2056
+ if (!control.parent) {
2057
+ return null;
2058
+ }
2059
+ if (predicate()) {
2060
+ return validator(control);
2061
+ }
2062
+ return null;
2063
+ };
2064
+ }
2458
2065
  }
2459
2066
 
2460
2067
  class PasswordValidator {
@@ -2493,13 +2100,17 @@ class PasswordValidator {
2493
2100
 
2494
2101
  class CadmusCoreModule {
2495
2102
  }
2496
- CadmusCoreModule.decorators = [
2497
- { type: NgModule, args: [{
2498
- imports: [CommonModule, HttpClientModule],
2499
- declarations: [SortPipe],
2500
- exports: [SortPipe]
2501
- },] }
2502
- ];
2103
+ CadmusCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2104
+ CadmusCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusCoreModule, declarations: [SortPipe], imports: [CommonModule, HttpClientModule, NgToolsModule], exports: [SortPipe] });
2105
+ CadmusCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusCoreModule, imports: [[CommonModule, HttpClientModule, NgToolsModule]] });
2106
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.2", ngImport: i0, type: CadmusCoreModule, decorators: [{
2107
+ type: NgModule,
2108
+ args: [{
2109
+ imports: [CommonModule, HttpClientModule, NgToolsModule],
2110
+ declarations: [SortPipe],
2111
+ exports: [SortPipe],
2112
+ }]
2113
+ }] });
2503
2114
 
2504
2115
  /*
2505
2116
  * Public API Surface of cadmus-core
@@ -2509,5 +2120,4 @@ CadmusCoreModule.decorators = [
2509
2120
  * Generated bundle index. Do not edit.
2510
2121
  */
2511
2122
 
2512
- export { CadmusCoreModule, CadmusValidators, DATATION_FORMAT_OPTIONS, DataPinValueType, Datation, EnvService, EnvServiceFactory, EnvServiceProvider, ErrorService, GravatarService, HistoricalDate, HistoricalDateType, LibraryRouteService, LocalStorageService, PasswordValidator, PendingChangesGuard, RomanNumber, SortPipe, TextLayerService, TextRange, TokenLocation, TokenPoint, deepCopy };
2513
- //# sourceMappingURL=myrmidon-cadmus-core.js.map
2123
+ export { CadmusCoreModule, CadmusValidators, DATATION_FORMAT_OPTIONS, DataPinValueType, Datation, GravatarService, HistoricalDate, HistoricalDateType, LibraryRouteService, PasswordValidator, PendingChangesGuard, SortPipe, TextLayerService, TextRange, TokenLocation, TokenPoint };