@myrmidon/cadmus-core 1.1.2 → 2.0.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/esm2020/lib/cadmus-core.module.mjs +4 -4
- package/esm2020/lib/guards/pending-changes.guard.mjs +13 -11
- package/esm2020/lib/models.mjs +1 -1
- package/esm2020/lib/pipes/sort.pipe.mjs +3 -3
- package/esm2020/lib/services/library-route.service.mjs +6 -6
- package/esm2020/lib/services/text-layer.service.mjs +15 -19
- package/fesm2015/myrmidon-cadmus-core.mjs +39 -40
- package/fesm2015/myrmidon-cadmus-core.mjs.map +1 -1
- package/fesm2020/myrmidon-cadmus-core.mjs +39 -40
- package/fesm2020/myrmidon-cadmus-core.mjs.map +1 -1
- package/lib/guards/pending-changes.guard.d.ts +3 -0
- package/lib/models.d.ts +0 -4
- package/lib/services/library-route.service.d.ts +2 -2
- package/lib/services/text-layer.service.d.ts +2 -3
- package/package.json +3 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Injectable, Pipe, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import { take, map } from 'rxjs';
|
|
4
|
+
import * as i1 from '@myrmidon/ng-mat-tools';
|
|
3
5
|
import * as rangy from 'rangy';
|
|
4
6
|
import { CommonModule } from '@angular/common';
|
|
5
7
|
import { HttpClientModule } from '@angular/common/http';
|
|
@@ -226,26 +228,26 @@ class TokenLocation {
|
|
|
226
228
|
}
|
|
227
229
|
|
|
228
230
|
class PendingChangesGuard {
|
|
231
|
+
constructor(_dialogService) {
|
|
232
|
+
this._dialogService = _dialogService;
|
|
233
|
+
}
|
|
229
234
|
canDeactivate(component) {
|
|
230
235
|
// if there are no pending changes, just allow deactivation; else confirm first
|
|
231
236
|
return !component || component.canDeactivate()
|
|
232
237
|
? true
|
|
233
|
-
:
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
// see http://stackoverflow.com/a/42207299/7307355
|
|
237
|
-
confirm('Warning: your changes have not been saved. ' +
|
|
238
|
-
'Press Cancel to go back and save, OK to continue.');
|
|
238
|
+
: this._dialogService
|
|
239
|
+
.confirm('Warning', 'There are unsaved changes. Do you want to leave?')
|
|
240
|
+
.pipe(take(1), map((yes) => (yes ? true : false)));
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
|
-
PendingChangesGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
242
|
-
PendingChangesGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
243
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
243
|
+
PendingChangesGuard.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: PendingChangesGuard, deps: [{ token: i1.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
244
|
+
PendingChangesGuard.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: PendingChangesGuard, providedIn: 'root' });
|
|
245
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: PendingChangesGuard, decorators: [{
|
|
244
246
|
type: Injectable,
|
|
245
247
|
args: [{
|
|
246
248
|
providedIn: 'root',
|
|
247
249
|
}]
|
|
248
|
-
}] });
|
|
250
|
+
}], ctorParameters: function () { return [{ type: i1.DialogService }]; } });
|
|
249
251
|
|
|
250
252
|
/**
|
|
251
253
|
* Sort pipe. Use like *ngFor="let i of items | sort:'propname'".
|
|
@@ -278,9 +280,9 @@ class SortPipe {
|
|
|
278
280
|
});
|
|
279
281
|
}
|
|
280
282
|
}
|
|
281
|
-
SortPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
282
|
-
SortPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "
|
|
283
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
283
|
+
SortPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: SortPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
284
|
+
SortPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: SortPipe, name: "sort" });
|
|
285
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: SortPipe, decorators: [{
|
|
284
286
|
type: Pipe,
|
|
285
287
|
args: [{
|
|
286
288
|
name: 'sort',
|
|
@@ -332,7 +334,7 @@ class LibraryRouteService {
|
|
|
332
334
|
* would return "fr.it.vedph.comment". This is required to navigate to
|
|
333
335
|
* the correct fragment editor, which is the same for each fragment type,
|
|
334
336
|
* independently from its role.
|
|
335
|
-
* @param
|
|
337
|
+
* @param roleId The part role ID.
|
|
336
338
|
* @returns An object where frTypeId=fragment type ID and frRoleId=fragment role
|
|
337
339
|
* ID, or null.
|
|
338
340
|
*/
|
|
@@ -439,7 +441,7 @@ class LibraryRouteService {
|
|
|
439
441
|
* as a suffix preceded by a colon.
|
|
440
442
|
*
|
|
441
443
|
* A fragment editing route is like
|
|
442
|
-
* "/items/<id>/<part-group>/fragment/<part-id>/<fr-typeid>/<loc>?
|
|
444
|
+
* "/items/<id>/<part-group>/fragment/<part-id>/<fr-typeid>/<loc>?frrid=<role-id>",
|
|
443
445
|
* where the role ID is as above, and the fragment's type ID is derived
|
|
444
446
|
* from the part's role ID, stripping the eventual fragment's role ID out.
|
|
445
447
|
*
|
|
@@ -484,9 +486,9 @@ class LibraryRouteService {
|
|
|
484
486
|
};
|
|
485
487
|
}
|
|
486
488
|
}
|
|
487
|
-
LibraryRouteService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
488
|
-
LibraryRouteService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
489
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
489
|
+
LibraryRouteService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: LibraryRouteService, deps: [{ token: 'partEditorKeys' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
490
|
+
LibraryRouteService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: LibraryRouteService, providedIn: 'root' });
|
|
491
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: LibraryRouteService, decorators: [{
|
|
490
492
|
type: Injectable,
|
|
491
493
|
args: [{
|
|
492
494
|
providedIn: 'root',
|
|
@@ -621,8 +623,6 @@ class TextLayerService {
|
|
|
621
623
|
* Render the specified token intersecting the specified range start location.
|
|
622
624
|
* The received token starts a multi-tokens range.
|
|
623
625
|
* @param loc location.
|
|
624
|
-
* @param locPortion the index of the token's portion (0-N). This is used
|
|
625
|
-
* to build a unique ID for each HTML span rendering a layer fragment.
|
|
626
626
|
* @param token token.
|
|
627
627
|
* @param sb target strings array.
|
|
628
628
|
* @param isSelected True if the token is selected.
|
|
@@ -1068,27 +1068,25 @@ class TextLayerService {
|
|
|
1068
1068
|
* @param matcher The matcher function, which receives a node
|
|
1069
1069
|
* to match, and returns 1=match, 0=no match, -1=stop the
|
|
1070
1070
|
* find operation with a no match.
|
|
1071
|
+
* @return 1=match, 0=no match, -1=stop the find operation with a no match.
|
|
1071
1072
|
*/
|
|
1072
|
-
|
|
1073
|
+
matchNode(node, matcher) {
|
|
1073
1074
|
// self
|
|
1074
1075
|
const n = matcher(node);
|
|
1075
|
-
if (n
|
|
1076
|
-
return
|
|
1077
|
-
}
|
|
1078
|
-
if (n === -1) {
|
|
1079
|
-
return null;
|
|
1076
|
+
if (n) {
|
|
1077
|
+
return n;
|
|
1080
1078
|
}
|
|
1081
1079
|
// children
|
|
1082
1080
|
if (node.hasChildNodes()) {
|
|
1083
1081
|
for (let i = 0; i < node.childNodes.length; i++) {
|
|
1084
1082
|
const child = node.childNodes[i];
|
|
1085
|
-
const
|
|
1086
|
-
if (
|
|
1087
|
-
return
|
|
1083
|
+
const m = this.matchNode(child, matcher);
|
|
1084
|
+
if (m) {
|
|
1085
|
+
return m;
|
|
1088
1086
|
}
|
|
1089
1087
|
}
|
|
1090
1088
|
}
|
|
1091
|
-
return
|
|
1089
|
+
return 0;
|
|
1092
1090
|
}
|
|
1093
1091
|
selHasAnySpan(range) {
|
|
1094
1092
|
var _a, _b;
|
|
@@ -1096,10 +1094,10 @@ class TextLayerService {
|
|
|
1096
1094
|
if (
|
|
1097
1095
|
// the selected text node must not be child of a span
|
|
1098
1096
|
((_a = range.startContainer.parentElement) === null || _a === void 0 ? void 0 : _a.tagName) === 'SPAN' ||
|
|
1099
|
-
((_b = range.
|
|
1097
|
+
((_b = range.endContainer.parentElement) === null || _b === void 0 ? void 0 : _b.tagName) === 'SPAN' ||
|
|
1100
1098
|
// the nodes tree from the common ancestor, from the start node
|
|
1101
1099
|
// up to the end node, must not include any span
|
|
1102
|
-
this.
|
|
1100
|
+
this.matchNode(range.commonAncestorContainer, (node) => {
|
|
1103
1101
|
// start checking only when start node reached
|
|
1104
1102
|
if (node === range.startContainer) {
|
|
1105
1103
|
inside = true;
|
|
@@ -1117,7 +1115,7 @@ class TextLayerService {
|
|
|
1117
1115
|
return 1;
|
|
1118
1116
|
}
|
|
1119
1117
|
return 0;
|
|
1120
|
-
})) {
|
|
1118
|
+
}) === 1) {
|
|
1121
1119
|
return true;
|
|
1122
1120
|
}
|
|
1123
1121
|
return false;
|
|
@@ -1174,9 +1172,9 @@ class TextLayerService {
|
|
|
1174
1172
|
return sel.getRangeAt(0);
|
|
1175
1173
|
}
|
|
1176
1174
|
}
|
|
1177
|
-
TextLayerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1178
|
-
TextLayerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
1179
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1175
|
+
TextLayerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: TextLayerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1176
|
+
TextLayerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: TextLayerService, providedIn: 'root' });
|
|
1177
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: TextLayerService, decorators: [{
|
|
1180
1178
|
type: Injectable,
|
|
1181
1179
|
args: [{ providedIn: 'root' }]
|
|
1182
1180
|
}], ctorParameters: function () { return []; } });
|
|
@@ -1244,10 +1242,10 @@ class CadmusValidators {
|
|
|
1244
1242
|
|
|
1245
1243
|
class CadmusCoreModule {
|
|
1246
1244
|
}
|
|
1247
|
-
CadmusCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1248
|
-
CadmusCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
1249
|
-
CadmusCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
1250
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1245
|
+
CadmusCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: CadmusCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1246
|
+
CadmusCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.0", ngImport: i0, type: CadmusCoreModule, declarations: [SortPipe], imports: [CommonModule, HttpClientModule, NgToolsModule], exports: [SortPipe] });
|
|
1247
|
+
CadmusCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: CadmusCoreModule, imports: [CommonModule, HttpClientModule, NgToolsModule] });
|
|
1248
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.0", ngImport: i0, type: CadmusCoreModule, decorators: [{
|
|
1251
1249
|
type: NgModule,
|
|
1252
1250
|
args: [{
|
|
1253
1251
|
imports: [CommonModule, HttpClientModule, NgToolsModule],
|
|
@@ -1266,3 +1264,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.3", ngImpor
|
|
|
1266
1264
|
|
|
1267
1265
|
export { CadmusCoreModule, CadmusValidators, DataPinValueType, FlagMatching, LibraryRouteService, PendingChangesGuard, SortPipe, TextLayerService, TextRange, TokenLocation, TokenPoint };
|
|
1268
1266
|
//# sourceMappingURL=myrmidon-cadmus-core.mjs.map
|
|
1267
|
+
//# sourceMappingURL=myrmidon-cadmus-core.mjs.map
|