@myrmidon/cadmus-layer-demo 16.0.1 → 20.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.
@@ -1,157 +1,284 @@
1
- import * as i0 from '@angular/core';
2
- import { signal, ViewChild, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import * as i1 from '@angular/forms';
4
- import { FormsModule, ReactiveFormsModule } from '@angular/forms';
5
- import { MatCard, MatCardHeader, MatCardContent } from '@angular/material/card';
6
- import { MatFormField, MatLabel, MatHint } from '@angular/material/form-field';
7
- import { MatInput } from '@angular/material/input';
8
- import { MatToolbar } from '@angular/material/toolbar';
9
- import { MatIconButton } from '@angular/material/button';
10
- import { MatTooltip } from '@angular/material/tooltip';
11
- import { MatIcon } from '@angular/material/icon';
12
- import { SafeHtmlPipe } from '@myrmidon/ngx-tools';
13
- import * as i2 from '@myrmidon/cadmus-core';
14
- import { TokenLocation } from '@myrmidon/cadmus-core';
15
-
16
- class LayerDemoComponent {
17
- _textLayerService;
18
- _resultElement;
19
- locations = signal([], /* @ts-ignore */
20
- ...(ngDevMode ? [{ debugName: "locations" }] : /* istanbul ignore next */ []));
21
- result = signal('', /* @ts-ignore */
22
- ...(ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []));
23
- userLocation = signal(undefined, /* @ts-ignore */
24
- ...(ngDevMode ? [{ debugName: "userLocation" }] : /* istanbul ignore next */ []));
25
- textSize = signal(14, /* @ts-ignore */
26
- ...(ngDevMode ? [{ debugName: "textSize" }] : /* istanbul ignore next */ []));
27
- // form
28
- rendition;
29
- text;
30
- location;
31
- constructor(formBuilder, _textLayerService) {
32
- this._textLayerService = _textLayerService;
33
- this.text = formBuilder.control('alpha beta\ngamma\ndelta epsilon waw\nzeta');
34
- this.location = formBuilder.control('1.2@2x2');
35
- this.rendition = formBuilder.group({
36
- text: this.text,
37
- location: this.location,
38
- });
39
- }
40
- makeLarger() {
41
- const size = this.textSize() + 2;
42
- if (size > 24) {
43
- return;
44
- }
45
- this.textSize.set(size);
46
- }
47
- makeSmaller() {
48
- const size = this.textSize() - 2;
49
- if (size < 12) {
50
- return;
51
- }
52
- this.textSize.set(size);
53
- }
54
- removeOverlaps(loc) {
55
- const locations = [...this.locations()];
56
- for (let i = locations.length - 1; i > -1; i--) {
57
- if (loc === locations[i]) {
58
- continue;
59
- }
60
- if (loc.overlaps(locations[i])) {
61
- locations.splice(i, 1);
62
- }
63
- }
64
- this.locations.set(locations);
65
- }
66
- addLocation() {
67
- if (!this.location.value) {
68
- return;
69
- }
70
- const loc = TokenLocation.parse(this.location.value);
71
- if (!loc) {
72
- return;
73
- }
74
- const locations = [...this.locations()];
75
- let done = false;
76
- for (let i = 0; i < locations.length && !done; i++) {
77
- const n = loc.compareTo(locations[i]);
78
- // nothing to do if equal
79
- if (n === 0) {
80
- return;
81
- }
82
- // insert before nearest bigger sort value
83
- if (n < 0) {
84
- locations.splice(i, 0, loc);
85
- done = true;
86
- }
87
- }
88
- // append if not yet inserted
89
- if (!done) {
90
- locations.push(loc);
91
- }
92
- this.locations.set(locations);
93
- // remove all the overlapping locations
94
- this.removeOverlaps(loc);
95
- }
96
- removeLocation(loc) {
97
- const i = this.locations().indexOf(loc);
98
- if (i > -1) {
99
- const locations = [...this.locations()];
100
- locations.splice(i, 1);
101
- this.locations.set(locations);
102
- }
103
- }
104
- clearLocations() {
105
- this.locations.set([]);
106
- }
107
- render() {
108
- if (!this.text.value) {
109
- return;
110
- }
111
- this.result.set(this._textLayerService.render(this.text.value, this.locations()));
112
- }
113
- getLocationForNew() {
114
- if (!this.text.value) {
115
- return;
116
- }
117
- this.userLocation.set(this._textLayerService.getSelectedLocationForNew(this._textLayerService.getSelectedRange(), this.text.value) || undefined);
118
- }
119
- getLocationForEdit() {
120
- this.userLocation.set(this._textLayerService.getSelectedLocationForEdit(this._textLayerService.getSelectedRange()) || undefined);
121
- }
122
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LayerDemoComponent, deps: [{ token: i1.FormBuilder }, { token: i2.TextLayerService }], target: i0.ɵɵFactoryTarget.Component });
123
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.1", type: LayerDemoComponent, isStandalone: true, selector: "cadmus-layer-demo", viewQueries: [{ propertyName: "_resultElement", first: true, predicate: ["resultElem"], descendants: true }], ngImport: i0, template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formGroup]=\"rendition\" (ngSubmit)=\"render()\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n maxlength=\"1000\"\r\n spellcheck=\"false\"\r\n formControlName=\"text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n required\r\n spellcheck=\"false\"\r\n formControlName=\"location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: ["textarea#text{min-width:300px;min-height:100px}:host ::ng-deep div#result{counter-reset:text-y-counter}:host ::ng-deep div#result p:before{content:counter(text-y-counter);counter-increment:text-y-counter;margin-right:6px;color:#a0a0a0}:host ::ng-deep span.fr{background-color:#ff0;border:1px solid silver;border-radius:6px}article{column-width:20em}\n"], dependencies: [{ kind: "component", type: MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "component", type: MatCardHeader, selector: "mat-card-header" }, { kind: "directive", type: MatCardContent, selector: "mat-card-content" }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: MatLabel, selector: "mat-label" }, { kind: "directive", type: MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "directive", type: MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "component", type: MatToolbar, selector: "mat-toolbar", inputs: ["color"], exportAs: ["matToolbar"] }, { kind: "component", type: MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "directive", type: MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "pipe", type: SafeHtmlPipe, name: "safeHtml" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
124
- }
125
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.1", ngImport: i0, type: LayerDemoComponent, decorators: [{
126
- type: Component,
127
- args: [{ selector: 'cadmus-layer-demo', changeDetection: ChangeDetectionStrategy.OnPush, imports: [
128
- MatCard,
129
- MatCardHeader,
130
- MatCardContent,
131
- FormsModule,
132
- ReactiveFormsModule,
133
- MatFormField,
134
- MatLabel,
135
- MatInput,
136
- MatHint,
137
- MatToolbar,
138
- MatIconButton,
139
- MatTooltip,
140
- MatIcon,
141
- SafeHtmlPipe,
142
- ], template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formGroup]=\"rendition\" (ngSubmit)=\"render()\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n maxlength=\"1000\"\r\n spellcheck=\"false\"\r\n formControlName=\"text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n required\r\n spellcheck=\"false\"\r\n formControlName=\"location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n", styles: ["textarea#text{min-width:300px;min-height:100px}:host ::ng-deep div#result{counter-reset:text-y-counter}:host ::ng-deep div#result p:before{content:counter(text-y-counter);counter-increment:text-y-counter;margin-right:6px;color:#a0a0a0}:host ::ng-deep span.fr{background-color:#ff0;border:1px solid silver;border-radius:6px}article{column-width:20em}\n"] }]
143
- }], ctorParameters: () => [{ type: i1.FormBuilder }, { type: i2.TextLayerService }], propDecorators: { _resultElement: [{
144
- type: ViewChild,
145
- args: ['resultElem']
146
- }] } });
147
-
148
- /*
149
- * Public API Surface of cadmus-layer-demo
150
- */
151
-
152
- /**
153
- * Generated bundle index. Do not edit.
154
- */
155
-
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectionStrategy, Component, ViewChild, signal } from "@angular/core";
3
+ import { FormField, FormRoot, form, maxLength, required } from "@angular/forms/signals";
4
+ import { MatCard, MatCardContent, MatCardHeader } from "@angular/material/card";
5
+ import { MatFormField, MatHint, MatLabel } from "@angular/material/form-field";
6
+ import { MatInput } from "@angular/material/input";
7
+ import { MatToolbar } from "@angular/material/toolbar";
8
+ import { MatIconButton } from "@angular/material/button";
9
+ import { MatTooltip } from "@angular/material/tooltip";
10
+ import { MatIcon } from "@angular/material/icon";
11
+ import { SafeHtmlPipe } from "@myrmidon/ngx-tools";
12
+ import * as i1 from "@myrmidon/cadmus-core";
13
+ import { TokenLocation } from "@myrmidon/cadmus-core";
14
+ var LayerDemoComponent = class LayerDemoComponent {
15
+ _textLayerService;
16
+ _resultElement;
17
+ locations = signal([], ...ngDevMode ? [{ debugName: "locations" }] : /* istanbul ignore next */ []);
18
+ result = signal("", ...ngDevMode ? [{ debugName: "result" }] : /* istanbul ignore next */ []);
19
+ userLocation = signal(void 0, ...ngDevMode ? [{ debugName: "userLocation" }] : /* istanbul ignore next */ []);
20
+ textSize = signal(14, ...ngDevMode ? [{ debugName: "textSize" }] : /* istanbul ignore next */ []);
21
+ rendition = form(signal({
22
+ text: "alpha beta\ngamma\ndelta epsilon waw\nzeta",
23
+ location: "1.2@2x2"
24
+ }), (path) => {
25
+ maxLength(path.text, 1e3);
26
+ required(path.location);
27
+ }, { submission: {
28
+ action: async () => {
29
+ this.render();
30
+ },
31
+ ignoreValidators: "all"
32
+ } });
33
+ constructor(_textLayerService) {
34
+ this._textLayerService = _textLayerService;
35
+ }
36
+ makeLarger() {
37
+ const size = this.textSize() + 2;
38
+ if (size > 24) return;
39
+ this.textSize.set(size);
40
+ }
41
+ makeSmaller() {
42
+ const size = this.textSize() - 2;
43
+ if (size < 12) return;
44
+ this.textSize.set(size);
45
+ }
46
+ removeOverlaps(loc) {
47
+ const locations = [...this.locations()];
48
+ for (let i = locations.length - 1; i > -1; i--) {
49
+ if (loc === locations[i]) continue;
50
+ if (loc.overlaps(locations[i])) locations.splice(i, 1);
51
+ }
52
+ this.locations.set(locations);
53
+ }
54
+ addLocation() {
55
+ const location = this.rendition.location().value();
56
+ if (!location) return;
57
+ const loc = TokenLocation.parse(location);
58
+ if (!loc) return;
59
+ const locations = [...this.locations()];
60
+ let done = false;
61
+ for (let i = 0; i < locations.length && !done; i++) {
62
+ const n = loc.compareTo(locations[i]);
63
+ if (n === 0) return;
64
+ if (n < 0) {
65
+ locations.splice(i, 0, loc);
66
+ done = true;
67
+ }
68
+ }
69
+ if (!done) locations.push(loc);
70
+ this.locations.set(locations);
71
+ this.removeOverlaps(loc);
72
+ }
73
+ removeLocation(loc) {
74
+ const i = this.locations().indexOf(loc);
75
+ if (i > -1) {
76
+ const locations = [...this.locations()];
77
+ locations.splice(i, 1);
78
+ this.locations.set(locations);
79
+ }
80
+ }
81
+ clearLocations() {
82
+ this.locations.set([]);
83
+ }
84
+ render() {
85
+ const text = this.rendition.text().value();
86
+ if (!text) return;
87
+ this.result.set(this._textLayerService.render(text, this.locations()));
88
+ }
89
+ getLocationForNew() {
90
+ const text = this.rendition.text().value();
91
+ if (!text) return;
92
+ this.userLocation.set(this._textLayerService.getSelectedLocationForNew(this._textLayerService.getSelectedRange(), text) || void 0);
93
+ }
94
+ getLocationForEdit() {
95
+ this.userLocation.set(this._textLayerService.getSelectedLocationForEdit(this._textLayerService.getSelectedRange()) || void 0);
96
+ }
97
+ static ɵfac = i0.ɵɵngDeclareFactory({
98
+ minVersion: "12.0.0",
99
+ version: "22.2.0",
100
+ ngImport: i0,
101
+ type: LayerDemoComponent,
102
+ deps: [{ token: i1.TextLayerService }],
103
+ target: i0.ɵɵFactoryTarget.Component
104
+ });
105
+ static ɵcmp = i0.ɵɵngDeclareComponent({
106
+ minVersion: "17.0.0",
107
+ version: "22.2.0",
108
+ type: LayerDemoComponent,
109
+ isStandalone: true,
110
+ selector: "cadmus-layer-demo",
111
+ viewQueries: [{
112
+ propertyName: "_resultElement",
113
+ first: true,
114
+ predicate: ["resultElem"],
115
+ descendants: true
116
+ }],
117
+ ngImport: i0,
118
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formRoot]=\"rendition\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button type=\"button\" mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
119
+ styles: ["textarea#text{min-width:300px;min-height:100px}:host ::ng-deep div#result{counter-reset:text-y-counter}:host ::ng-deep div#result p:before{content:counter(text-y-counter);counter-increment:text-y-counter;margin-right:6px;color:#a0a0a0}:host ::ng-deep span.fr{background-color:#ff0;border:1px solid silver;border-radius:6px}article{column-width:20em}\n"],
120
+ dependencies: [
121
+ {
122
+ kind: "component",
123
+ type: MatCard,
124
+ selector: "mat-card",
125
+ inputs: ["appearance"],
126
+ exportAs: ["matCard"]
127
+ },
128
+ {
129
+ kind: "component",
130
+ type: MatCardHeader,
131
+ selector: "mat-card-header"
132
+ },
133
+ {
134
+ kind: "directive",
135
+ type: MatCardContent,
136
+ selector: "mat-card-content"
137
+ },
138
+ {
139
+ kind: "directive",
140
+ type: FormField,
141
+ selector: "[formField]",
142
+ inputs: ["formField"],
143
+ exportAs: ["formField"]
144
+ },
145
+ {
146
+ kind: "directive",
147
+ type: FormRoot,
148
+ selector: "form[formRoot]",
149
+ inputs: ["formRoot"]
150
+ },
151
+ {
152
+ kind: "component",
153
+ type: MatFormField,
154
+ selector: "mat-form-field",
155
+ inputs: [
156
+ "hideRequiredMarker",
157
+ "color",
158
+ "floatLabel",
159
+ "appearance",
160
+ "subscriptSizing",
161
+ "hintLabel"
162
+ ],
163
+ exportAs: ["matFormField"]
164
+ },
165
+ {
166
+ kind: "directive",
167
+ type: MatLabel,
168
+ selector: "mat-label"
169
+ },
170
+ {
171
+ kind: "directive",
172
+ type: MatInput,
173
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
174
+ inputs: [
175
+ "disabled",
176
+ "id",
177
+ "placeholder",
178
+ "name",
179
+ "required",
180
+ "type",
181
+ "errorStateMatcher",
182
+ "aria-describedby",
183
+ "value",
184
+ "readonly",
185
+ "disabledInteractive"
186
+ ],
187
+ exportAs: ["matInput"]
188
+ },
189
+ {
190
+ kind: "directive",
191
+ type: MatHint,
192
+ selector: "mat-hint",
193
+ inputs: ["align", "id"]
194
+ },
195
+ {
196
+ kind: "component",
197
+ type: MatToolbar,
198
+ selector: "mat-toolbar",
199
+ inputs: ["color"],
200
+ exportAs: ["matToolbar"]
201
+ },
202
+ {
203
+ kind: "component",
204
+ type: MatIconButton,
205
+ selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
206
+ exportAs: ["matButton", "matAnchor"]
207
+ },
208
+ {
209
+ kind: "directive",
210
+ type: MatTooltip,
211
+ selector: "[matTooltip]",
212
+ inputs: [
213
+ "matTooltipPosition",
214
+ "matTooltipPositionAtOrigin",
215
+ "matTooltipDisabled",
216
+ "matTooltipShowDelay",
217
+ "matTooltipHideDelay",
218
+ "matTooltipTouchGestures",
219
+ "matTooltip",
220
+ "matTooltipClass"
221
+ ],
222
+ exportAs: ["matTooltip"]
223
+ },
224
+ {
225
+ kind: "component",
226
+ type: MatIcon,
227
+ selector: "mat-icon",
228
+ inputs: [
229
+ "color",
230
+ "inline",
231
+ "svgIcon",
232
+ "fontSet",
233
+ "fontIcon"
234
+ ],
235
+ exportAs: ["matIcon"]
236
+ },
237
+ {
238
+ kind: "pipe",
239
+ type: SafeHtmlPipe,
240
+ name: "safeHtml"
241
+ }
242
+ ],
243
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
244
+ });
245
+ };
246
+ i0.ɵɵngDeclareClassMetadata({
247
+ minVersion: "12.0.0",
248
+ version: "22.2.0",
249
+ ngImport: i0,
250
+ type: LayerDemoComponent,
251
+ decorators: [{
252
+ type: Component,
253
+ args: [{
254
+ selector: "cadmus-layer-demo",
255
+ changeDetection: ChangeDetectionStrategy.OnPush,
256
+ imports: [
257
+ MatCard,
258
+ MatCardHeader,
259
+ MatCardContent,
260
+ FormField,
261
+ FormRoot,
262
+ MatFormField,
263
+ MatLabel,
264
+ MatInput,
265
+ MatHint,
266
+ MatToolbar,
267
+ MatIconButton,
268
+ MatTooltip,
269
+ MatIcon,
270
+ SafeHtmlPipe
271
+ ],
272
+ template: "<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formRoot]=\"rendition\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button type=\"button\" mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n",
273
+ styles: ["textarea#text{min-width:300px;min-height:100px}:host ::ng-deep div#result{counter-reset:text-y-counter}:host ::ng-deep div#result p:before{content:counter(text-y-counter);counter-increment:text-y-counter;margin-right:6px;color:#a0a0a0}:host ::ng-deep span.fr{background-color:#ff0;border:1px solid silver;border-radius:6px}article{column-width:20em}\n"]
274
+ }]
275
+ }],
276
+ ctorParameters: () => [{ type: i1.TextLayerService }],
277
+ propDecorators: { _resultElement: [{
278
+ type: ViewChild,
279
+ args: ["resultElem"]
280
+ }] }
281
+ });
156
282
  export { LayerDemoComponent };
157
- //# sourceMappingURL=myrmidon-cadmus-layer-demo.mjs.map
283
+
284
+ //# sourceMappingURL=myrmidon-cadmus-layer-demo.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"myrmidon-cadmus-layer-demo.mjs","sources":["../../../../projects/myrmidon/cadmus-layer-demo/src/lib/layer-demo/layer-demo.component.ts","../../../../projects/myrmidon/cadmus-layer-demo/src/lib/layer-demo/layer-demo.component.html","../../../../projects/myrmidon/cadmus-layer-demo/src/public-api.ts","../../../../projects/myrmidon/cadmus-layer-demo/src/myrmidon-cadmus-layer-demo.ts"],"sourcesContent":["import {\r\n Component,\r\n ViewChild,\r\n ElementRef,\r\n signal,\r\n ChangeDetectionStrategy,\r\n} from '@angular/core';\r\nimport {\r\n FormGroup,\r\n FormControl,\r\n FormBuilder,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n} from '@angular/forms';\r\n\r\nimport { MatCard, MatCardHeader, MatCardContent } from '@angular/material/card';\r\nimport { MatFormField, MatLabel, MatHint } from '@angular/material/form-field';\r\nimport { MatInput } from '@angular/material/input';\r\nimport { MatToolbar } from '@angular/material/toolbar';\r\nimport { MatIconButton } from '@angular/material/button';\r\nimport { MatTooltip } from '@angular/material/tooltip';\r\nimport { MatIcon } from '@angular/material/icon';\r\n\r\nimport { SafeHtmlPipe } from '@myrmidon/ngx-tools';\r\n\r\nimport { TextLayerService, TokenLocation } from '@myrmidon/cadmus-core';\r\n\r\n@Component({\r\n selector: 'cadmus-layer-demo',\r\n templateUrl: './layer-demo.component.html',\r\n styleUrls: ['./layer-demo.component.css'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [\r\n MatCard,\r\n MatCardHeader,\r\n MatCardContent,\r\n FormsModule,\r\n ReactiveFormsModule,\r\n MatFormField,\r\n MatLabel,\r\n MatInput,\r\n MatHint,\r\n MatToolbar,\r\n MatIconButton,\r\n MatTooltip,\r\n MatIcon,\r\n SafeHtmlPipe,\r\n ],\r\n})\r\nexport class LayerDemoComponent {\r\n @ViewChild('resultElem') _resultElement?: ElementRef;\r\n\r\n public readonly locations = signal<TokenLocation[]>([]);\r\n public readonly result = signal<string>('');\r\n public readonly userLocation = signal<TokenLocation | undefined>(undefined);\r\n public readonly textSize = signal<number>(14);\r\n\r\n // form\r\n public rendition: FormGroup;\r\n public text: FormControl<string | null>;\r\n public location: FormControl<string | null>;\r\n\r\n constructor(\r\n formBuilder: FormBuilder,\r\n private _textLayerService: TextLayerService,\r\n ) {\r\n this.text = formBuilder.control(\r\n 'alpha beta\\ngamma\\ndelta epsilon waw\\nzeta',\r\n );\r\n this.location = formBuilder.control('1.2@2x2');\r\n this.rendition = formBuilder.group({\r\n text: this.text,\r\n location: this.location,\r\n });\r\n }\r\n\r\n public makeLarger(): void {\r\n const size = this.textSize() + 2;\r\n if (size > 24) {\r\n return;\r\n }\r\n this.textSize.set(size);\r\n }\r\n\r\n public makeSmaller(): void {\r\n const size = this.textSize() - 2;\r\n if (size < 12) {\r\n return;\r\n }\r\n this.textSize.set(size);\r\n }\r\n\r\n private removeOverlaps(loc: TokenLocation): void {\r\n const locations = [...this.locations()];\r\n\r\n for (let i = locations.length - 1; i > -1; i--) {\r\n if (loc === locations[i]) {\r\n continue;\r\n }\r\n if (loc.overlaps(locations[i])) {\r\n locations.splice(i, 1);\r\n }\r\n }\r\n\r\n this.locations.set(locations);\r\n }\r\n\r\n public addLocation(): void {\r\n if (!this.location.value) {\r\n return;\r\n }\r\n const loc = TokenLocation.parse(this.location.value);\r\n if (!loc) {\r\n return;\r\n }\r\n\r\n const locations = [...this.locations()];\r\n let done = false;\r\n for (let i = 0; i < locations.length && !done; i++) {\r\n const n = loc.compareTo(locations[i]);\r\n // nothing to do if equal\r\n if (n === 0) {\r\n return;\r\n }\r\n // insert before nearest bigger sort value\r\n if (n < 0) {\r\n locations.splice(i, 0, loc);\r\n done = true;\r\n }\r\n }\r\n // append if not yet inserted\r\n if (!done) {\r\n locations.push(loc);\r\n }\r\n this.locations.set(locations);\r\n\r\n // remove all the overlapping locations\r\n this.removeOverlaps(loc);\r\n }\r\n\r\n public removeLocation(loc: TokenLocation): void {\r\n const i = this.locations().indexOf(loc);\r\n if (i > -1) {\r\n const locations = [...this.locations()];\r\n locations.splice(i, 1);\r\n this.locations.set(locations);\r\n }\r\n }\r\n\r\n public clearLocations(): void {\r\n this.locations.set([]);\r\n }\r\n\r\n public render(): void {\r\n if (!this.text.value) {\r\n return;\r\n }\r\n this.result.set(\r\n this._textLayerService.render(this.text.value, this.locations()),\r\n );\r\n }\r\n\r\n public getLocationForNew(): void {\r\n if (!this.text.value) {\r\n return;\r\n }\r\n this.userLocation.set(\r\n this._textLayerService.getSelectedLocationForNew(\r\n this._textLayerService.getSelectedRange()!,\r\n this.text.value,\r\n ) || undefined,\r\n );\r\n }\r\n\r\n public getLocationForEdit(): void {\r\n this.userLocation.set(\r\n this._textLayerService.getSelectedLocationForEdit(\r\n this._textLayerService.getSelectedRange()!,\r\n ) || undefined,\r\n );\r\n }\r\n}\r\n","<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formGroup]=\"rendition\" (ngSubmit)=\"render()\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n maxlength=\"1000\"\r\n spellcheck=\"false\"\r\n formControlName=\"text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n required\r\n spellcheck=\"false\"\r\n formControlName=\"location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n","/*\r\n * Public API Surface of cadmus-layer-demo\r\n */\r\n\r\nexport * from './lib/layer-demo/layer-demo.component';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;MAiDa,kBAAkB,CAAA;AAenB,IAAA,iBAAA;AAde,IAAA,cAAc;IAEvB,SAAS,GAAG,MAAM,CAAkB,EAAE;kFAAC;IACvC,MAAM,GAAG,MAAM,CAAS,EAAE;+EAAC;IAC3B,YAAY,GAAG,MAAM,CAA4B,SAAS;qFAAC;IAC3D,QAAQ,GAAG,MAAM,CAAS,EAAE;iFAAC;;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GA,SAAS;uBAAC,YAAY;;;AElDzB;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"myrmidon-cadmus-layer-demo.mjs","names":[],"sources":["../../../../projects/myrmidon/cadmus-layer-demo/src/lib/layer-demo/layer-demo.component.ts","../../../../projects/myrmidon/cadmus-layer-demo/src/lib/layer-demo/layer-demo.component.html"],"sourcesContent":["import {\r\n Component,\r\n ViewChild,\r\n ElementRef,\r\n signal,\r\n ChangeDetectionStrategy,\r\n} from '@angular/core';\r\nimport {\r\n FormField,\r\n FormRoot,\r\n form,\r\n maxLength,\r\n required,\r\n} from '@angular/forms/signals';\r\n\r\nimport { MatCard, MatCardHeader, MatCardContent } from '@angular/material/card';\r\nimport { MatFormField, MatLabel, MatHint } from '@angular/material/form-field';\r\nimport { MatInput } from '@angular/material/input';\r\nimport { MatToolbar } from '@angular/material/toolbar';\r\nimport { MatIconButton } from '@angular/material/button';\r\nimport { MatTooltip } from '@angular/material/tooltip';\r\nimport { MatIcon } from '@angular/material/icon';\r\n\r\nimport { SafeHtmlPipe } from '@myrmidon/ngx-tools';\r\n\r\nimport { TextLayerService, TokenLocation } from '@myrmidon/cadmus-core';\r\n\r\n@Component({\r\n selector: 'cadmus-layer-demo',\r\n templateUrl: './layer-demo.component.html',\r\n styleUrls: ['./layer-demo.component.css'],\r\n changeDetection: ChangeDetectionStrategy.OnPush,\r\n imports: [\r\n MatCard,\r\n MatCardHeader,\r\n MatCardContent,\r\n FormField,\r\n FormRoot,\r\n MatFormField,\r\n MatLabel,\r\n MatInput,\r\n MatHint,\r\n MatToolbar,\r\n MatIconButton,\r\n MatTooltip,\r\n MatIcon,\r\n SafeHtmlPipe,\r\n ],\r\n})\r\nexport class LayerDemoComponent {\r\n @ViewChild('resultElem') _resultElement?: ElementRef;\r\n\r\n public readonly locations = signal<TokenLocation[]>([]);\r\n public readonly result = signal<string>('');\r\n public readonly userLocation = signal<TokenLocation | undefined>(undefined);\r\n public readonly textSize = signal<number>(14);\r\n\r\n /**\r\n * The rendition form. This page is a submission root: submitting it\r\n * (the render button, or Enter in the location input) renders the text.\r\n * As with the old ngSubmit, rendering does not depend on validity: the\r\n * location is required only to add it.\r\n */\r\n public readonly rendition = form(\r\n signal({\r\n text: 'alpha beta\\ngamma\\ndelta epsilon waw\\nzeta',\r\n location: '1.2@2x2',\r\n }),\r\n (path) => {\r\n maxLength(path.text, 1000);\r\n required(path.location);\r\n },\r\n {\r\n submission: {\r\n action: async () => {\r\n this.render();\r\n return undefined;\r\n },\r\n ignoreValidators: 'all',\r\n },\r\n },\r\n );\r\n\r\n constructor(private _textLayerService: TextLayerService) {}\r\n\r\n public makeLarger(): void {\r\n const size = this.textSize() + 2;\r\n if (size > 24) {\r\n return;\r\n }\r\n this.textSize.set(size);\r\n }\r\n\r\n public makeSmaller(): void {\r\n const size = this.textSize() - 2;\r\n if (size < 12) {\r\n return;\r\n }\r\n this.textSize.set(size);\r\n }\r\n\r\n private removeOverlaps(loc: TokenLocation): void {\r\n const locations = [...this.locations()];\r\n\r\n for (let i = locations.length - 1; i > -1; i--) {\r\n if (loc === locations[i]) {\r\n continue;\r\n }\r\n if (loc.overlaps(locations[i])) {\r\n locations.splice(i, 1);\r\n }\r\n }\r\n\r\n this.locations.set(locations);\r\n }\r\n\r\n public addLocation(): void {\r\n const location = this.rendition.location().value();\r\n if (!location) {\r\n return;\r\n }\r\n const loc = TokenLocation.parse(location);\r\n if (!loc) {\r\n return;\r\n }\r\n\r\n const locations = [...this.locations()];\r\n let done = false;\r\n for (let i = 0; i < locations.length && !done; i++) {\r\n const n = loc.compareTo(locations[i]);\r\n // nothing to do if equal\r\n if (n === 0) {\r\n return;\r\n }\r\n // insert before nearest bigger sort value\r\n if (n < 0) {\r\n locations.splice(i, 0, loc);\r\n done = true;\r\n }\r\n }\r\n // append if not yet inserted\r\n if (!done) {\r\n locations.push(loc);\r\n }\r\n this.locations.set(locations);\r\n\r\n // remove all the overlapping locations\r\n this.removeOverlaps(loc);\r\n }\r\n\r\n public removeLocation(loc: TokenLocation): void {\r\n const i = this.locations().indexOf(loc);\r\n if (i > -1) {\r\n const locations = [...this.locations()];\r\n locations.splice(i, 1);\r\n this.locations.set(locations);\r\n }\r\n }\r\n\r\n public clearLocations(): void {\r\n this.locations.set([]);\r\n }\r\n\r\n public render(): void {\r\n const text = this.rendition.text().value();\r\n if (!text) {\r\n return;\r\n }\r\n this.result.set(this._textLayerService.render(text, this.locations()));\r\n }\r\n\r\n public getLocationForNew(): void {\r\n const text = this.rendition.text().value();\r\n if (!text) {\r\n return;\r\n }\r\n this.userLocation.set(\r\n this._textLayerService.getSelectedLocationForNew(\r\n this._textLayerService.getSelectedRange()!,\r\n text,\r\n ) || undefined,\r\n );\r\n }\r\n\r\n public getLocationForEdit(): void {\r\n this.userLocation.set(\r\n this._textLayerService.getSelectedLocationForEdit(\r\n this._textLayerService.getSelectedRange()!,\r\n ) || undefined,\r\n );\r\n }\r\n}\r\n","<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Layered Text Demo</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <article>\r\n <p>\r\n Enter some base text and zero or more layer fragments locations, then\r\n click the render button. This renders the base text with all its ranges.\r\n </p>\r\n <p>\r\n Once the text has been decorated, select any portion of it, either\r\n including a decorated part, or not. Then, if you selected a part\r\n including decorations, click the location button with the checkmark\r\n (=get the location of the fragment to edit); else, click the location\r\n button with the plus (=get the location of a new fragment).\r\n </p>\r\n <p>\r\n This will show you the token-based coordinates corresponding to your\r\n selection, provided that if you include any portion of a decorated text\r\n you will get the full coordinates of the decoration; otherwise, you will\r\n just get the coordinates of the selected character(s).\r\n </p>\r\n <p>\r\n This behavior is used to allow users edit existing part fragments by\r\n just selecting any part of it, even partially; while they must be\r\n precise when they are creating a new fragment.\r\n </p>\r\n </article>\r\n <hr />\r\n\r\n <form [formRoot]=\"rendition\">\r\n <div>\r\n <mat-form-field>\r\n <mat-label>base text</mat-label>\r\n <textarea\r\n matInput\r\n type=\"text\"\r\n id=\"text\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.text\"\r\n ></textarea>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-form-field>\r\n <mat-label>location</mat-label>\r\n <input\r\n matInput\r\n type=\"text\"\r\n id=\"location\"\r\n spellcheck=\"false\"\r\n [formField]=\"rendition.location\"\r\n />\r\n <mat-hint>Y.X&#64;AxR</mat-hint>\r\n </mat-form-field>\r\n </div>\r\n\r\n <div>\r\n <mat-toolbar>\r\n <span>\r\n <button\r\n mat-icon-button\r\n (click)=\"addLocation()\"\r\n type=\"button\"\r\n matTooltip=\"Add the specified location\"\r\n >\r\n <mat-icon style=\"color: #66cc75\">add_circle</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"clearLocations()\"\r\n type=\"button\"\r\n matTooltip=\"Remove all the locations\"\r\n >\r\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"submit\"\r\n matTooltip=\"Render the decorated base text\"\r\n >\r\n <mat-icon class=\"mat-primary\">play_circle_outline</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForNew()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for new item\"\r\n >\r\n <mat-icon>playlist_add</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n (click)=\"getLocationForEdit()\"\r\n type=\"button\"\r\n matTooltip=\"Get location for selected item\"\r\n >\r\n <mat-icon>playlist_add_check</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Larger text\"\r\n (click)=\"makeLarger()\"\r\n [disabled]=\"textSize() >= 24\"\r\n >\r\n <mat-icon>format_size</mat-icon>\r\n </button>\r\n <button\r\n mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"Smaller text\"\r\n (click)=\"makeSmaller()\"\r\n [disabled]=\"textSize() <= 12\"\r\n >\r\n <mat-icon>text_fields</mat-icon>\r\n </button>\r\n </span>\r\n <span class=\"tb-fill-remaining-space\"></span>\r\n <span>{{ userLocation() }}</span>\r\n </mat-toolbar>\r\n </div>\r\n\r\n <table>\r\n <tbody>\r\n @for (loc of locations(); track loc) {\r\n <tr>\r\n <td>\r\n <button type=\"button\" mat-icon-button (click)=\"removeLocation(loc)\">\r\n <mat-icon class=\"mat-warn\">remove_circle</mat-icon>\r\n </button>\r\n </td>\r\n <td>{{ loc.toString() }}</td>\r\n </tr>\r\n }\r\n </tbody>\r\n </table>\r\n </form>\r\n </mat-card-content>\r\n</mat-card>\r\n\r\n<mat-card appearance=\"outlined\">\r\n <mat-card-header>\r\n <h3>Rendition</h3>\r\n </mat-card-header>\r\n <mat-card-content>\r\n <div\r\n [style.font-size]=\"textSize() + 'px'\"\r\n [innerHtml]=\"result() | safeHtml: 'html'\"\r\n id=\"result()\"\r\n #resultElem\r\n ></div>\r\n <hr />\r\n <div>\r\n <code>{{ result() }}</code>\r\n </div>\r\n </mat-card-content>\r\n</mat-card>\r\n"],"mappings":";;;;;;;;;;;;;AAiDA,IAAa,qBAAb,MAAa,mBAAkB;CAkCT;CAjCK;CAET,YAAY,OAAwB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CACvC,SAAS,OAAe,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,SAAA,CAAA,+BAAA,CAAA,CAAA;CAC3B,eAAe,OAAkC,QAAU,GAAA,YAAA,CAAA,EAAA,WAAA,eAAA,CAAA,+BAAA,CAAA,CAAA;CAC3D,WAAW,OAAe,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAQ7B,YAAY,KAC1B,OAAO;EACL,MAAM;EACN,UAAU;CACX,CAAA,IACA,SAAQ;EACP,UAAU,KAAK,MAAM,GAAI;EACzB,SAAS,KAAK,QAAQ;CACxB,GACA,EACE,YAAY;EACV,QAAQ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;GAAA,UAAA;GAAmB,iBAGZ,wBAAwB;GAAM,SACtC;IACP;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD;GAAA,UAAA;GAAA,QAAA,CAAA,iWAAA;EAAA,CAAA;;;;EAGA,MAAA;EAAU,MAAA,CAAA,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrmidon/cadmus-layer-demo",
3
- "version": "16.0.1",
3
+ "version": "20.0.0",
4
4
  "description": "Cadmus - text layer demo page.",
5
5
  "keywords": [
6
6
  "Cadmus"
@@ -14,12 +14,12 @@
14
14
  "name": "Daniele Fusi"
15
15
  },
16
16
  "peerDependencies": {
17
- "@angular/common": "^22.0.0",
18
- "@angular/core": "^22.0.0",
19
- "@angular/material": "^22.0.0",
20
- "@myrmidon/ngx-tools": "^3.0.1",
21
- "@myrmidon/cadmus-core": "^13.0.0",
22
- "@myrmidon/cadmus-ui": "^17.0.1"
17
+ "@angular/common": "^22.2.1",
18
+ "@angular/core": "^22.2.1",
19
+ "@angular/material": "^22.2.1",
20
+ "@myrmidon/ngx-tools": "^3.0.2",
21
+ "@myrmidon/cadmus-core": "^20.0.0",
22
+ "@myrmidon/cadmus-ui": "^20.0.0"
23
23
  },
24
24
  "dependencies": {
25
25
  "tslib": "^2.3.0"
@@ -1,30 +1,33 @@
1
- import * as _angular_core from '@angular/core';
2
- import { ElementRef } from '@angular/core';
3
- import { FormGroup, FormControl, FormBuilder } from '@angular/forms';
4
- import { TokenLocation, TextLayerService } from '@myrmidon/cadmus-core';
5
-
6
- declare class LayerDemoComponent {
7
- private _textLayerService;
8
- _resultElement?: ElementRef;
9
- readonly locations: _angular_core.WritableSignal<TokenLocation[]>;
10
- readonly result: _angular_core.WritableSignal<string>;
11
- readonly userLocation: _angular_core.WritableSignal<TokenLocation | undefined>;
12
- readonly textSize: _angular_core.WritableSignal<number>;
13
- rendition: FormGroup;
14
- text: FormControl<string | null>;
15
- location: FormControl<string | null>;
16
- constructor(formBuilder: FormBuilder, _textLayerService: TextLayerService);
17
- makeLarger(): void;
18
- makeSmaller(): void;
19
- private removeOverlaps;
20
- addLocation(): void;
21
- removeLocation(loc: TokenLocation): void;
22
- clearLocations(): void;
23
- render(): void;
24
- getLocationForNew(): void;
25
- getLocationForEdit(): void;
26
- static ɵfac: _angular_core.ɵɵFactoryDeclaration<LayerDemoComponent, never>;
27
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<LayerDemoComponent, "cadmus-layer-demo", never, {}, {}, never, never, true, never>;
28
- }
29
-
30
- export { LayerDemoComponent };
1
+ import * as i0 from "@angular/core";
2
+ import { ElementRef } from "@angular/core";
3
+ import { TextLayerService, TokenLocation } from "@myrmidon/cadmus-core";
4
+ export declare class LayerDemoComponent {
5
+ private _textLayerService;
6
+ _resultElement?: ElementRef;
7
+ readonly locations: import("@angular/core").WritableSignal<TokenLocation[]>;
8
+ readonly result: import("@angular/core").WritableSignal<string>;
9
+ readonly userLocation: import("@angular/core").WritableSignal<TokenLocation | undefined>;
10
+ readonly textSize: import("@angular/core").WritableSignal<number>;
11
+ /**
12
+ * The rendition form. This page is a submission root: submitting it
13
+ * (the render button, or Enter in the location input) renders the text.
14
+ * As with the old ngSubmit, rendering does not depend on validity: the
15
+ * location is required only to add it.
16
+ */
17
+ readonly rendition: import("@angular/forms/signals").FieldTree<{
18
+ text: string;
19
+ location: string;
20
+ }, string | number, "writable">;
21
+ constructor(_textLayerService: TextLayerService);
22
+ makeLarger(): void;
23
+ makeSmaller(): void;
24
+ private removeOverlaps;
25
+ addLocation(): void;
26
+ removeLocation(loc: TokenLocation): void;
27
+ clearLocations(): void;
28
+ render(): void;
29
+ getLocationForNew(): void;
30
+ getLocationForEdit(): void;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<LayerDemoComponent, never>;
32
+ static ɵcmp: i0.ɵɵComponentDeclaration<LayerDemoComponent, "cadmus-layer-demo", never, {}, {}, never, never, true, never>;
33
+ }