@myrmidon/cadmus-layer-demo 16.0.1 → 20.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
|
-
# CadmusLayerDemo
|
|
2
|
-
|
|
3
|
-
- 📦 `@myrmidon/cadmus-layer-demo`
|
|
4
|
-
|
|
5
|
-
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0.
|
|
6
|
-
|
|
7
|
-
This library contains the Cadmus layers demo page. It is mostly used for developing or demonstrative purposes.
|
|
1
|
+
# CadmusLayerDemo
|
|
2
|
+
|
|
3
|
+
- 📦 `@myrmidon/cadmus-layer-demo`
|
|
4
|
+
|
|
5
|
+
This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 19.0.0.
|
|
6
|
+
|
|
7
|
+
This library contains the Cadmus text layers demo page. It is mostly used for developing or demonstrative purposes, as a playground for the token-based coordinates system used by text layers.
|
|
8
|
+
|
|
9
|
+
The page uses the same component used by the text layer part editor, i.e. `DecoratedTokenTextComponent` from `@myrmidon/cadmus-ui` (see its documentation for the details of the coordinates system). Users can:
|
|
10
|
+
|
|
11
|
+
- enter any base text, which is displayed live. Each line is a block.
|
|
12
|
+
- add fragments, either by typing their location (e.g. `1.2@2x2`), or by selecting any portion of the text, which shows the selection's location and text. Like the backend does when adding a fragment to a layer part, adding a fragment removes any existing fragment overlapping it.
|
|
13
|
+
- see that the characters of fragments are highlighted and blocked, so that a new selection can never overlap them.
|
|
14
|
+
- click a fragment (or its chip in the fragments list) to pick it, viewing its location and text, or removing it.
|
|
15
|
+
- zoom the text, find text in it, or select a portion of it by typing its coordinates in the box below the text.
|
|
16
|
+
|
|
17
|
+
## History
|
|
18
|
+
|
|
19
|
+
- 2026-11-19: refactored the page for the new `DecoratedTokenTextComponent`, based on `@myrmidon/cadmus-text-segment`. The text is now rendered live (no more render button), and the DOM-based selection of the legacy `TextLayerService` is replaced by the segmented text selection.
|
|
@@ -1,157 +1,393 @@
|
|
|
1
|
-
import * as i0 from
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { FormField, FormRoot, form, maxLength } from "@angular/forms/signals";
|
|
4
|
+
import { MatCard, MatCardAvatar, MatCardContent, MatCardHeader, MatCardSubtitle, MatCardTitle } from "@angular/material/card";
|
|
5
|
+
import { MatButton, MatIconButton } from "@angular/material/button";
|
|
6
|
+
import { MatChip, MatChipRemove, MatChipSet } from "@angular/material/chips";
|
|
7
|
+
import { MatError, MatFormField, MatHint, MatLabel } from "@angular/material/form-field";
|
|
8
|
+
import { MatIcon } from "@angular/material/icon";
|
|
9
|
+
import { MatInput } from "@angular/material/input";
|
|
10
|
+
import { MatExpansionPanel, MatExpansionPanelHeader, MatExpansionPanelTitle } from "@angular/material/expansion";
|
|
11
|
+
import { MatTooltip } from "@angular/material/tooltip";
|
|
12
|
+
import { TokenLocation } from "@myrmidon/cadmus-core";
|
|
13
|
+
import { DecoratedTokenTextComponent, TokenTextSegmenter } from "@myrmidon/cadmus-ui";
|
|
14
|
+
const LAYER_DEMO_TEXT = "alpha beta\ngamma\ndelta epsilon waw\nzeta";
|
|
15
|
+
var LayerDemoComponent = class LayerDemoComponent {
|
|
16
|
+
_segmenter = new TokenTextSegmenter();
|
|
17
|
+
_textView = viewChild(DecoratedTokenTextComponent, ...ngDevMode ? [{ debugName: "_textView" }] : /* istanbul ignore next */ []);
|
|
18
|
+
locations = signal([], ...ngDevMode ? [{ debugName: "locations" }] : /* istanbul ignore next */ []);
|
|
19
|
+
selectedLocation = signal(void 0, ...ngDevMode ? [{ debugName: "selectedLocation" }] : /* istanbul ignore next */ []);
|
|
20
|
+
selection = signal(null, ...ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []);
|
|
21
|
+
textSize = signal(16, ...ngDevMode ? [{ debugName: "textSize" }] : /* istanbul ignore next */ []);
|
|
22
|
+
locationError = signal(null, ...ngDevMode ? [{ debugName: "locationError" }] : /* istanbul ignore next */ []);
|
|
23
|
+
demoForm = form(signal({
|
|
24
|
+
text: LAYER_DEMO_TEXT,
|
|
25
|
+
location: "1.2@2x2"
|
|
26
|
+
}), (path) => {
|
|
27
|
+
maxLength(path.text, 5e3);
|
|
28
|
+
}, { submission: {
|
|
29
|
+
action: async () => {
|
|
30
|
+
this.addTypedLocation();
|
|
31
|
+
},
|
|
32
|
+
ignoreValidators: "all"
|
|
33
|
+
} });
|
|
34
|
+
text = computed(() => this.demoForm.text().value() || "", ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
|
|
35
|
+
_blocks = computed(() => this._segmenter.getBlocks(this.text()), ...ngDevMode ? [{ debugName: "_blocks" }] : /* istanbul ignore next */ []);
|
|
36
|
+
selectedText = computed(() => {
|
|
37
|
+
const loc = this.selectedLocation();
|
|
38
|
+
if (!loc) return "";
|
|
39
|
+
const segments = this._segmenter.getLocationSegments(this._blocks(), loc);
|
|
40
|
+
return segments ? this._segmenter.getSegmentsText(this._blocks(), segments) : "";
|
|
41
|
+
}, ...ngDevMode ? [{ debugName: "selectedText" }] : /* istanbul ignore next */ []);
|
|
42
|
+
makeLarger() {
|
|
43
|
+
this.textSize.update((size) => Math.min(24, size + 2));
|
|
44
|
+
}
|
|
45
|
+
makeSmaller() {
|
|
46
|
+
this.textSize.update((size) => Math.max(12, size - 2));
|
|
47
|
+
}
|
|
48
|
+
removeOverlaps(loc, locations) {
|
|
49
|
+
for (let i = locations.length - 1; i > -1; i--) if (loc !== locations[i] && loc.overlaps(locations[i])) locations.splice(i, 1);
|
|
50
|
+
}
|
|
51
|
+
addLocation(loc) {
|
|
52
|
+
const locations = [...this.locations()];
|
|
53
|
+
let done = false;
|
|
54
|
+
for (let i = 0; i < locations.length && !done; i++) {
|
|
55
|
+
const n = loc.compareTo(locations[i]);
|
|
56
|
+
if (n === 0) return false;
|
|
57
|
+
if (n < 0) {
|
|
58
|
+
locations.splice(i, 0, loc);
|
|
59
|
+
done = true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!done) locations.push(loc);
|
|
63
|
+
this.removeOverlaps(loc, locations);
|
|
64
|
+
this.locations.set(locations);
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
addTypedLocation() {
|
|
68
|
+
const value = this.demoForm.location().value()?.trim();
|
|
69
|
+
if (!value) {
|
|
70
|
+
this.locationError.set(null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const loc = TokenLocation.parse(value);
|
|
74
|
+
if (!loc || !this._segmenter.getCoordsSegments(this._blocks(), loc.toString())) {
|
|
75
|
+
this.locationError.set(loc ? "location not found in text" : "invalid location");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.locationError.set(null);
|
|
79
|
+
this.addLocation(loc);
|
|
80
|
+
}
|
|
81
|
+
addSelection() {
|
|
82
|
+
const loc = this.selection()?.location;
|
|
83
|
+
if (loc && this.addLocation(loc)) this.selection.set(null);
|
|
84
|
+
}
|
|
85
|
+
onSelectionChange(selection) {
|
|
86
|
+
this.selection.set(selection.coords ? selection : null);
|
|
87
|
+
}
|
|
88
|
+
pickLocation(loc) {
|
|
89
|
+
this.selectedLocation.set(loc);
|
|
90
|
+
}
|
|
91
|
+
removeLocation(loc) {
|
|
92
|
+
const i = this.locations().indexOf(loc);
|
|
93
|
+
if (i > -1) {
|
|
94
|
+
const locations = [...this.locations()];
|
|
95
|
+
locations.splice(i, 1);
|
|
96
|
+
this.locations.set(locations);
|
|
97
|
+
if (this.selectedLocation() === loc) this.selectedLocation.set(void 0);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
clearLocations() {
|
|
101
|
+
this.locations.set([]);
|
|
102
|
+
this.selectedLocation.set(void 0);
|
|
103
|
+
}
|
|
104
|
+
clearSelection() {
|
|
105
|
+
this._textView()?.clearSelection();
|
|
106
|
+
this.selection.set(null);
|
|
107
|
+
}
|
|
108
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
109
|
+
minVersion: "12.0.0",
|
|
110
|
+
version: "22.3.0",
|
|
111
|
+
ngImport: i0,
|
|
112
|
+
type: LayerDemoComponent,
|
|
113
|
+
deps: [],
|
|
114
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
115
|
+
});
|
|
116
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
117
|
+
minVersion: "17.0.0",
|
|
118
|
+
version: "22.3.0",
|
|
119
|
+
type: LayerDemoComponent,
|
|
120
|
+
isStandalone: true,
|
|
121
|
+
selector: "cadmus-layer-demo",
|
|
122
|
+
viewQueries: [{
|
|
123
|
+
propertyName: "_textView",
|
|
124
|
+
first: true,
|
|
125
|
+
predicate: DecoratedTokenTextComponent,
|
|
126
|
+
descendants: true,
|
|
127
|
+
isSignal: true
|
|
128
|
+
}],
|
|
129
|
+
ngImport: i0,
|
|
130
|
+
template: "<mat-card appearance=\"outlined\">\n <mat-card-header>\n <mat-icon mat-card-avatar>layers</mat-icon>\n <mat-card-title>Text Layers Demo</mat-card-title>\n <mat-card-subtitle>token-based coordinates</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <mat-expansion-panel>\n <mat-expansion-panel-header>\n <mat-panel-title>How it works</mat-panel-title>\n </mat-expansion-panel-header>\n <article>\n <p>\n A text layer annotates portions of a base text with fragments. Each\n fragment has a <strong>location</strong> with token-based\n coordinates, where a token is any sequence of non-whitespace\n characters. A point is <code>Y.X@AxR</code>:\n </p>\n <ul>\n <li><code>Y</code>: the line number (1-N).</li>\n <li><code>X</code>: the token number in the line (1-N).</li>\n <li>\n optionally, when not selecting whole tokens: <code>A</code> is\n the first character in the token (1-N), and <code>R</code> the\n count of characters (omitted when 1).\n </li>\n </ul>\n <p>\n A selection spanning several tokens has a start and an end point\n separated by <code>-</code>: the start point picks from its\n <code>A</code> to the end of its token, the end point picks the\n first <code>R</code> characters of its token. Whitespace at the\n edges of a selection is ignored. For instance, with the default\n text: <code>2.1</code> is <em>gamma</em>, <code>1.2@2x2</code>\n is <em>et</em>, <code>3.1@4x2-3.2@1</code> is\n <em>ta e</em>.\n </p>\n <p>\n Fragments in the same layer never overlap: so their characters are\n highlighted and <strong>blocked</strong>, and a selection always\n stops before them. Click a fragment to pick it; select any other\n portion of text (by dragging, SHIFT+clicking, or with SHIFT+arrows)\n to get its location, and add it as a new fragment. You can also\n type coordinates in the box below the text to select them.\n </p>\n </article>\n </mat-expansion-panel>\n\n <div class=\"layout\">\n <!-- input -->\n <form class=\"input\" [formRoot]=\"demoForm\">\n <mat-form-field class=\"text-field\">\n <mat-label>base text</mat-label>\n <textarea\n matInput\n id=\"text\"\n rows=\"6\"\n spellcheck=\"false\"\n [formField]=\"demoForm.text\"\n ></textarea>\n <mat-hint>each line is a block</mat-hint>\n </mat-form-field>\n\n <div class=\"location-row\">\n <mat-form-field>\n <mat-label>location</mat-label>\n <input\n matInput\n id=\"location\"\n spellcheck=\"false\"\n autocomplete=\"off\"\n [formField]=\"demoForm.location\"\n />\n @if (locationError(); as error) {\n <mat-error>{{ error }}</mat-error>\n } @else {\n <mat-hint>Y.X@AxR or Y.X@AxR-Y.X@AxR</mat-hint>\n }\n </mat-form-field>\n <button\n mat-icon-button\n type=\"submit\"\n matTooltip=\"Add a fragment at the typed location\"\n >\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\n </button>\n </div>\n\n <!-- fragments -->\n <div class=\"fragments\">\n <div class=\"fragments-header\">\n <span>fragments: {{ locations().length }}</span>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Remove all the fragments\"\n [disabled]=\"!locations().length\"\n (click)=\"clearLocations()\"\n >\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\n </button>\n </div>\n <mat-chip-set aria-label=\"fragments\">\n @for (loc of locations(); track loc) {\n <mat-chip\n [highlighted]=\"selectedLocation() === loc\"\n (click)=\"pickLocation(loc)\"\n (removed)=\"removeLocation(loc)\"\n >\n {{ loc.toString() }}\n <button\n matChipRemove\n type=\"button\"\n [attr.aria-label]=\"'remove ' + loc.toString()\"\n >\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n }\n </mat-chip-set>\n </div>\n </form>\n\n <!-- text -->\n <div class=\"output\">\n <div class=\"size-bar\">\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Larger text\"\n (click)=\"makeLarger()\"\n [disabled]=\"textSize() >= 24\"\n >\n <mat-icon>format_size</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Smaller text\"\n (click)=\"makeSmaller()\"\n [disabled]=\"textSize() <= 12\"\n >\n <mat-icon>text_fields</mat-icon>\n </button>\n </div>\n <cadmus-decorated-token-text\n [baseText]=\"text()\"\n [locations]=\"locations()\"\n [fontSize]=\"textSize()\"\n [showToolbar]=\"true\"\n [(selectedLocation)]=\"selectedLocation\"\n (selectionChange)=\"onSelectionChange($event)\"\n />\n\n <!-- details -->\n <div class=\"details\">\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>highlight_alt</mat-icon> selection\n </div>\n @if (selection(); as sel) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ sel.coords }}</code>\n <span class=\"text\">{{ sel.text }}</span>\n @if (sel.overlapping) {\n <span class=\"warn\">overlaps a fragment</span>\n }\n </div>\n <div class=\"detail-actions\">\n <button\n mat-flat-button\n type=\"button\"\n [disabled]=\"!sel.location\"\n (click)=\"addSelection()\"\n >\n <mat-icon>add_circle</mat-icon>\n add fragment\n </button>\n <button mat-button type=\"button\" (click)=\"clearSelection()\">\n clear\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">\n select any portion of the text\n </div>\n }\n </div>\n\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>bookmark</mat-icon> picked fragment\n </div>\n @if (selectedLocation(); as loc) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ loc.toString() }}</code>\n <span class=\"text\">{{ selectedText() }}</span>\n </div>\n <div class=\"detail-actions\">\n <button\n mat-button\n type=\"button\"\n class=\"mat-warn\"\n (click)=\"removeLocation(loc)\"\n >\n <mat-icon>remove_circle</mat-icon>\n remove\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">click a fragment to pick it</div>\n }\n </div>\n </div>\n </div>\n </div>\n </mat-card-content>\n</mat-card>\n",
|
|
131
|
+
styles: ["article{column-width:24em;font:var(--mat-sys-body-medium)}article code,code.loc{font-family:Roboto Mono,Consolas,monospace}.layout{display:grid;grid-template-columns:minmax(260px,1fr) minmax(0,2fr);gap:16px;margin-top:16px}@media(max-width:800px){.layout{grid-template-columns:minmax(0,1fr)}}.input{display:flex;flex-direction:column;gap:8px;min-width:0}.text-field{width:100%}textarea#text{font-family:Roboto Mono,Consolas,monospace}.location-row{display:flex;align-items:flex-start;gap:4px}.location-row mat-form-field{flex:1 1 auto}.location-row input{font-family:Roboto Mono,Consolas,monospace}.location-row button{margin-top:8px}.fragments-header{display:flex;align-items:center;justify-content:space-between;font:var(--mat-sys-title-small)}.fragments mat-chip{font-family:Roboto Mono,Consolas,monospace;cursor:pointer}.output{display:flex;flex-direction:column;gap:8px;min-width:0}.size-bar{display:flex;justify-content:flex-end}cadmus-decorated-token-text{--cadmus-decorated-token-text-max-height: 60vh}.details{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}.detail{display:flex;flex-direction:column;gap:6px;padding:8px 12px;border:1px solid var(--mat-sys-outline-variant);border-radius:var(--mat-sys-corner-small, 4px);background-color:var(--mat-sys-surface-container-low)}.detail-title{display:flex;align-items:center;gap:6px;font:var(--mat-sys-title-small);color:var(--mat-sys-on-surface-variant)}.detail-title mat-icon{font-size:18px;width:18px;height:18px}.detail-body{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;min-height:24px}.detail-body .text{font-style:italic;overflow-wrap:anywhere}.detail-body .warn{color:var(--mat-sys-error);font:var(--mat-sys-label-medium)}.detail-actions{display:flex;gap:8px}.muted{color:var(--mat-sys-on-surface-variant);font:var(--mat-sys-body-small)}\n"],
|
|
132
|
+
dependencies: [
|
|
133
|
+
{
|
|
134
|
+
kind: "component",
|
|
135
|
+
type: MatCard,
|
|
136
|
+
selector: "mat-card",
|
|
137
|
+
inputs: ["appearance"],
|
|
138
|
+
exportAs: ["matCard"]
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
kind: "component",
|
|
142
|
+
type: MatCardHeader,
|
|
143
|
+
selector: "mat-card-header"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
kind: "directive",
|
|
147
|
+
type: MatCardAvatar,
|
|
148
|
+
selector: "[mat-card-avatar], [matCardAvatar]"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
kind: "directive",
|
|
152
|
+
type: MatCardTitle,
|
|
153
|
+
selector: "mat-card-title, [mat-card-title], [matCardTitle]"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
kind: "directive",
|
|
157
|
+
type: MatCardSubtitle,
|
|
158
|
+
selector: "mat-card-subtitle, [mat-card-subtitle], [matCardSubtitle]"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
kind: "directive",
|
|
162
|
+
type: MatCardContent,
|
|
163
|
+
selector: "mat-card-content"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
kind: "component",
|
|
167
|
+
type: MatButton,
|
|
168
|
+
selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
|
|
169
|
+
inputs: ["matButton"],
|
|
170
|
+
exportAs: ["matButton", "matAnchor"]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
kind: "component",
|
|
174
|
+
type: MatIconButton,
|
|
175
|
+
selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]",
|
|
176
|
+
exportAs: ["matButton", "matAnchor"]
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
kind: "component",
|
|
180
|
+
type: MatChipSet,
|
|
181
|
+
selector: "mat-chip-set",
|
|
182
|
+
inputs: [
|
|
183
|
+
"disabled",
|
|
184
|
+
"role",
|
|
185
|
+
"tabIndex"
|
|
186
|
+
]
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
kind: "component",
|
|
190
|
+
type: MatChip,
|
|
191
|
+
selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]",
|
|
192
|
+
inputs: [
|
|
193
|
+
"role",
|
|
194
|
+
"id",
|
|
195
|
+
"aria-label",
|
|
196
|
+
"aria-description",
|
|
197
|
+
"value",
|
|
198
|
+
"color",
|
|
199
|
+
"removable",
|
|
200
|
+
"highlighted",
|
|
201
|
+
"disableRipple",
|
|
202
|
+
"disabled"
|
|
203
|
+
],
|
|
204
|
+
outputs: ["removed", "destroyed"],
|
|
205
|
+
exportAs: ["matChip"]
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
kind: "directive",
|
|
209
|
+
type: MatChipRemove,
|
|
210
|
+
selector: "[matChipRemove]"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
kind: "component",
|
|
214
|
+
type: MatFormField,
|
|
215
|
+
selector: "mat-form-field",
|
|
216
|
+
inputs: [
|
|
217
|
+
"hideRequiredMarker",
|
|
218
|
+
"color",
|
|
219
|
+
"floatLabel",
|
|
220
|
+
"appearance",
|
|
221
|
+
"subscriptSizing",
|
|
222
|
+
"hintLabel"
|
|
223
|
+
],
|
|
224
|
+
exportAs: ["matFormField"]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
kind: "directive",
|
|
228
|
+
type: MatLabel,
|
|
229
|
+
selector: "mat-label"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
kind: "directive",
|
|
233
|
+
type: MatHint,
|
|
234
|
+
selector: "mat-hint",
|
|
235
|
+
inputs: ["align", "id"]
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
kind: "directive",
|
|
239
|
+
type: MatError,
|
|
240
|
+
selector: "mat-error, [matError]",
|
|
241
|
+
inputs: ["id"]
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
kind: "directive",
|
|
245
|
+
type: MatInput,
|
|
246
|
+
selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
|
|
247
|
+
inputs: [
|
|
248
|
+
"disabled",
|
|
249
|
+
"id",
|
|
250
|
+
"placeholder",
|
|
251
|
+
"name",
|
|
252
|
+
"required",
|
|
253
|
+
"type",
|
|
254
|
+
"errorStateMatcher",
|
|
255
|
+
"aria-describedby",
|
|
256
|
+
"value",
|
|
257
|
+
"readonly",
|
|
258
|
+
"disabledInteractive"
|
|
259
|
+
],
|
|
260
|
+
exportAs: ["matInput"]
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
kind: "component",
|
|
264
|
+
type: MatIcon,
|
|
265
|
+
selector: "mat-icon",
|
|
266
|
+
inputs: [
|
|
267
|
+
"color",
|
|
268
|
+
"inline",
|
|
269
|
+
"svgIcon",
|
|
270
|
+
"fontSet",
|
|
271
|
+
"fontIcon"
|
|
272
|
+
],
|
|
273
|
+
exportAs: ["matIcon"]
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
kind: "directive",
|
|
277
|
+
type: MatTooltip,
|
|
278
|
+
selector: "[matTooltip]",
|
|
279
|
+
inputs: [
|
|
280
|
+
"matTooltipPosition",
|
|
281
|
+
"matTooltipPositionAtOrigin",
|
|
282
|
+
"matTooltipDisabled",
|
|
283
|
+
"matTooltipShowDelay",
|
|
284
|
+
"matTooltipHideDelay",
|
|
285
|
+
"matTooltipTouchGestures",
|
|
286
|
+
"matTooltip",
|
|
287
|
+
"matTooltipClass"
|
|
288
|
+
],
|
|
289
|
+
exportAs: ["matTooltip"]
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
kind: "component",
|
|
293
|
+
type: MatExpansionPanel,
|
|
294
|
+
selector: "mat-expansion-panel",
|
|
295
|
+
inputs: ["hideToggle", "togglePosition"],
|
|
296
|
+
outputs: ["afterExpand", "afterCollapse"],
|
|
297
|
+
exportAs: ["matExpansionPanel"]
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
kind: "component",
|
|
301
|
+
type: MatExpansionPanelHeader,
|
|
302
|
+
selector: "mat-expansion-panel-header",
|
|
303
|
+
inputs: [
|
|
304
|
+
"expandedHeight",
|
|
305
|
+
"collapsedHeight",
|
|
306
|
+
"tabIndex"
|
|
307
|
+
]
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
kind: "directive",
|
|
311
|
+
type: MatExpansionPanelTitle,
|
|
312
|
+
selector: "mat-panel-title"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
kind: "directive",
|
|
316
|
+
type: FormField,
|
|
317
|
+
selector: "[formField]",
|
|
318
|
+
inputs: ["formField"],
|
|
319
|
+
exportAs: ["formField"]
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
kind: "directive",
|
|
323
|
+
type: FormRoot,
|
|
324
|
+
selector: "form[formRoot]",
|
|
325
|
+
inputs: ["formRoot"]
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
kind: "component",
|
|
329
|
+
type: DecoratedTokenTextComponent,
|
|
330
|
+
selector: "cadmus-decorated-token-text",
|
|
331
|
+
inputs: [
|
|
332
|
+
"baseText",
|
|
333
|
+
"locations",
|
|
334
|
+
"selectedLocation",
|
|
335
|
+
"fontSize",
|
|
336
|
+
"showToolbar",
|
|
337
|
+
"settings",
|
|
338
|
+
"colors"
|
|
339
|
+
],
|
|
340
|
+
outputs: ["selectedLocationChange", "selectionChange"]
|
|
341
|
+
}
|
|
342
|
+
],
|
|
343
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
347
|
+
minVersion: "12.0.0",
|
|
348
|
+
version: "22.3.0",
|
|
349
|
+
ngImport: i0,
|
|
350
|
+
type: LayerDemoComponent,
|
|
351
|
+
decorators: [{
|
|
352
|
+
type: Component,
|
|
353
|
+
args: [{
|
|
354
|
+
selector: "cadmus-layer-demo",
|
|
355
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
356
|
+
imports: [
|
|
357
|
+
MatCard,
|
|
358
|
+
MatCardHeader,
|
|
359
|
+
MatCardAvatar,
|
|
360
|
+
MatCardTitle,
|
|
361
|
+
MatCardSubtitle,
|
|
362
|
+
MatCardContent,
|
|
363
|
+
MatButton,
|
|
364
|
+
MatIconButton,
|
|
365
|
+
MatChipSet,
|
|
366
|
+
MatChip,
|
|
367
|
+
MatChipRemove,
|
|
368
|
+
MatFormField,
|
|
369
|
+
MatLabel,
|
|
370
|
+
MatHint,
|
|
371
|
+
MatError,
|
|
372
|
+
MatInput,
|
|
373
|
+
MatIcon,
|
|
374
|
+
MatTooltip,
|
|
375
|
+
MatExpansionPanel,
|
|
376
|
+
MatExpansionPanelHeader,
|
|
377
|
+
MatExpansionPanelTitle,
|
|
378
|
+
FormField,
|
|
379
|
+
FormRoot,
|
|
380
|
+
DecoratedTokenTextComponent
|
|
381
|
+
],
|
|
382
|
+
template: "<mat-card appearance=\"outlined\">\n <mat-card-header>\n <mat-icon mat-card-avatar>layers</mat-icon>\n <mat-card-title>Text Layers Demo</mat-card-title>\n <mat-card-subtitle>token-based coordinates</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <mat-expansion-panel>\n <mat-expansion-panel-header>\n <mat-panel-title>How it works</mat-panel-title>\n </mat-expansion-panel-header>\n <article>\n <p>\n A text layer annotates portions of a base text with fragments. Each\n fragment has a <strong>location</strong> with token-based\n coordinates, where a token is any sequence of non-whitespace\n characters. A point is <code>Y.X@AxR</code>:\n </p>\n <ul>\n <li><code>Y</code>: the line number (1-N).</li>\n <li><code>X</code>: the token number in the line (1-N).</li>\n <li>\n optionally, when not selecting whole tokens: <code>A</code> is\n the first character in the token (1-N), and <code>R</code> the\n count of characters (omitted when 1).\n </li>\n </ul>\n <p>\n A selection spanning several tokens has a start and an end point\n separated by <code>-</code>: the start point picks from its\n <code>A</code> to the end of its token, the end point picks the\n first <code>R</code> characters of its token. Whitespace at the\n edges of a selection is ignored. For instance, with the default\n text: <code>2.1</code> is <em>gamma</em>, <code>1.2@2x2</code>\n is <em>et</em>, <code>3.1@4x2-3.2@1</code> is\n <em>ta e</em>.\n </p>\n <p>\n Fragments in the same layer never overlap: so their characters are\n highlighted and <strong>blocked</strong>, and a selection always\n stops before them. Click a fragment to pick it; select any other\n portion of text (by dragging, SHIFT+clicking, or with SHIFT+arrows)\n to get its location, and add it as a new fragment. You can also\n type coordinates in the box below the text to select them.\n </p>\n </article>\n </mat-expansion-panel>\n\n <div class=\"layout\">\n <!-- input -->\n <form class=\"input\" [formRoot]=\"demoForm\">\n <mat-form-field class=\"text-field\">\n <mat-label>base text</mat-label>\n <textarea\n matInput\n id=\"text\"\n rows=\"6\"\n spellcheck=\"false\"\n [formField]=\"demoForm.text\"\n ></textarea>\n <mat-hint>each line is a block</mat-hint>\n </mat-form-field>\n\n <div class=\"location-row\">\n <mat-form-field>\n <mat-label>location</mat-label>\n <input\n matInput\n id=\"location\"\n spellcheck=\"false\"\n autocomplete=\"off\"\n [formField]=\"demoForm.location\"\n />\n @if (locationError(); as error) {\n <mat-error>{{ error }}</mat-error>\n } @else {\n <mat-hint>Y.X@AxR or Y.X@AxR-Y.X@AxR</mat-hint>\n }\n </mat-form-field>\n <button\n mat-icon-button\n type=\"submit\"\n matTooltip=\"Add a fragment at the typed location\"\n >\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\n </button>\n </div>\n\n <!-- fragments -->\n <div class=\"fragments\">\n <div class=\"fragments-header\">\n <span>fragments: {{ locations().length }}</span>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Remove all the fragments\"\n [disabled]=\"!locations().length\"\n (click)=\"clearLocations()\"\n >\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\n </button>\n </div>\n <mat-chip-set aria-label=\"fragments\">\n @for (loc of locations(); track loc) {\n <mat-chip\n [highlighted]=\"selectedLocation() === loc\"\n (click)=\"pickLocation(loc)\"\n (removed)=\"removeLocation(loc)\"\n >\n {{ loc.toString() }}\n <button\n matChipRemove\n type=\"button\"\n [attr.aria-label]=\"'remove ' + loc.toString()\"\n >\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n }\n </mat-chip-set>\n </div>\n </form>\n\n <!-- text -->\n <div class=\"output\">\n <div class=\"size-bar\">\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Larger text\"\n (click)=\"makeLarger()\"\n [disabled]=\"textSize() >= 24\"\n >\n <mat-icon>format_size</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Smaller text\"\n (click)=\"makeSmaller()\"\n [disabled]=\"textSize() <= 12\"\n >\n <mat-icon>text_fields</mat-icon>\n </button>\n </div>\n <cadmus-decorated-token-text\n [baseText]=\"text()\"\n [locations]=\"locations()\"\n [fontSize]=\"textSize()\"\n [showToolbar]=\"true\"\n [(selectedLocation)]=\"selectedLocation\"\n (selectionChange)=\"onSelectionChange($event)\"\n />\n\n <!-- details -->\n <div class=\"details\">\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>highlight_alt</mat-icon> selection\n </div>\n @if (selection(); as sel) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ sel.coords }}</code>\n <span class=\"text\">{{ sel.text }}</span>\n @if (sel.overlapping) {\n <span class=\"warn\">overlaps a fragment</span>\n }\n </div>\n <div class=\"detail-actions\">\n <button\n mat-flat-button\n type=\"button\"\n [disabled]=\"!sel.location\"\n (click)=\"addSelection()\"\n >\n <mat-icon>add_circle</mat-icon>\n add fragment\n </button>\n <button mat-button type=\"button\" (click)=\"clearSelection()\">\n clear\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">\n select any portion of the text\n </div>\n }\n </div>\n\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>bookmark</mat-icon> picked fragment\n </div>\n @if (selectedLocation(); as loc) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ loc.toString() }}</code>\n <span class=\"text\">{{ selectedText() }}</span>\n </div>\n <div class=\"detail-actions\">\n <button\n mat-button\n type=\"button\"\n class=\"mat-warn\"\n (click)=\"removeLocation(loc)\"\n >\n <mat-icon>remove_circle</mat-icon>\n remove\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">click a fragment to pick it</div>\n }\n </div>\n </div>\n </div>\n </div>\n </mat-card-content>\n</mat-card>\n",
|
|
383
|
+
styles: ["article{column-width:24em;font:var(--mat-sys-body-medium)}article code,code.loc{font-family:Roboto Mono,Consolas,monospace}.layout{display:grid;grid-template-columns:minmax(260px,1fr) minmax(0,2fr);gap:16px;margin-top:16px}@media(max-width:800px){.layout{grid-template-columns:minmax(0,1fr)}}.input{display:flex;flex-direction:column;gap:8px;min-width:0}.text-field{width:100%}textarea#text{font-family:Roboto Mono,Consolas,monospace}.location-row{display:flex;align-items:flex-start;gap:4px}.location-row mat-form-field{flex:1 1 auto}.location-row input{font-family:Roboto Mono,Consolas,monospace}.location-row button{margin-top:8px}.fragments-header{display:flex;align-items:center;justify-content:space-between;font:var(--mat-sys-title-small)}.fragments mat-chip{font-family:Roboto Mono,Consolas,monospace;cursor:pointer}.output{display:flex;flex-direction:column;gap:8px;min-width:0}.size-bar{display:flex;justify-content:flex-end}cadmus-decorated-token-text{--cadmus-decorated-token-text-max-height: 60vh}.details{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px}.detail{display:flex;flex-direction:column;gap:6px;padding:8px 12px;border:1px solid var(--mat-sys-outline-variant);border-radius:var(--mat-sys-corner-small, 4px);background-color:var(--mat-sys-surface-container-low)}.detail-title{display:flex;align-items:center;gap:6px;font:var(--mat-sys-title-small);color:var(--mat-sys-on-surface-variant)}.detail-title mat-icon{font-size:18px;width:18px;height:18px}.detail-body{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;min-height:24px}.detail-body .text{font-style:italic;overflow-wrap:anywhere}.detail-body .warn{color:var(--mat-sys-error);font:var(--mat-sys-label-medium)}.detail-actions{display:flex;gap:8px}.muted{color:var(--mat-sys-on-surface-variant);font:var(--mat-sys-body-small)}\n"]
|
|
384
|
+
}]
|
|
385
|
+
}],
|
|
386
|
+
propDecorators: { _textView: [{
|
|
387
|
+
type: i0.ViewChild,
|
|
388
|
+
args: [i0.forwardRef(() => DecoratedTokenTextComponent), { isSignal: true }]
|
|
389
|
+
}] }
|
|
390
|
+
});
|
|
391
|
+
export { LAYER_DEMO_TEXT, LayerDemoComponent };
|
|
15
392
|
|
|
16
|
-
|
|
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@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@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
|
-
|
|
156
|
-
export { LayerDemoComponent };
|
|
157
|
-
//# sourceMappingURL=myrmidon-cadmus-layer-demo.mjs.map
|
|
393
|
+
//# 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@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;;AAGtC,IAAA,SAAS;AACT,IAAA,IAAI;AACJ,IAAA,QAAQ;IAEf,WAAA,CACE,WAAwB,EAChB,iBAAmC,EAAA;QAAnC,IAAA,CAAA,iBAAiB,GAAjB,iBAAiB;QAEzB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,OAAO,CAC7B,4CAA4C,CAC7C;QACD,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC;AAC9C,QAAA,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,KAAK,CAAC;YACjC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACxB,SAAA,CAAC;IACJ;IAEO,UAAU,GAAA;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;AAChC,QAAA,IAAI,IAAI,GAAG,EAAE,EAAE;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AAA,EAAA,YAAA,EAAA,iBAAA,CAAA,EAAA,QAAA,EAAA,CAAA,YAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EACV,OAAO,sIACP,YAAY,EAAA,IAAA,EAAA,UAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAGH,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAtB9B,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,mBAAmB,EAAA,eAAA,EAGZ,uBAAuB,CAAC,MAAM,EAAA,OAAA,EACtC;wBACP,OAAO;wBACP,aAAa;wBACb,cAAc;wBACd,WAAW;wBACX,mBAAmB;wBACnB,YAAY;wBACZ,QAAQ;wBACR,QAAQ;wBACR,OAAO;wBACP,UAAU;wBACV,aAAa;wBACb,UAAU;wBACV,OAAO;wBACP,YAAY;AACb,qBAAA,EAAA,QAAA,EAAA,64KAAA,EAAA,MAAA,EAAA,CAAA,iWAAA,CAAA,EAAA;;sBAGA,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 {\n ChangeDetectionStrategy,\n Component,\n computed,\n signal,\n viewChild,\n} from '@angular/core';\nimport { FormField, FormRoot, form, maxLength } from '@angular/forms/signals';\n\nimport {\n MatCard,\n MatCardContent,\n MatCardHeader,\n MatCardTitle,\n MatCardSubtitle,\n MatCardAvatar,\n} from '@angular/material/card';\nimport { MatButton, MatIconButton } from '@angular/material/button';\nimport { MatChip, MatChipRemove, MatChipSet } from '@angular/material/chips';\nimport {\n MatError,\n MatFormField,\n MatHint,\n MatLabel,\n} from '@angular/material/form-field';\nimport { MatIcon } from '@angular/material/icon';\nimport { MatInput } from '@angular/material/input';\nimport {\n MatExpansionPanel,\n MatExpansionPanelHeader,\n MatExpansionPanelTitle,\n} from '@angular/material/expansion';\nimport { MatTooltip } from '@angular/material/tooltip';\n\nimport { TokenLocation } from '@myrmidon/cadmus-core';\nimport {\n DecoratedTokenTextComponent,\n DecoratedTokenTextSelection,\n TokenTextSegmenter,\n} from '@myrmidon/cadmus-ui';\n\n/**\n * The default demo text.\n */\nexport const LAYER_DEMO_TEXT = 'alpha beta\\ngamma\\ndelta epsilon waw\\nzeta';\n\n/**\n * Text layers demo page. This lets users play with the token-based\n * coordinates system used by Cadmus text layers, as implemented by\n * `DecoratedTokenTextComponent` and its `TokenTextSegmenter`:\n * - enter a base text, which is displayed live.\n * - add fragments (i.e. their locations) either by typing their\n * coordinates, or by selecting a portion of the text. Fragment characters\n * are highlighted and blocked, so that a new selection can never overlap\n * them.\n * - click a fragment to pick it, viewing its location and text, or\n * removing it.\n */\n@Component({\n selector: 'cadmus-layer-demo',\n templateUrl: './layer-demo.component.html',\n styleUrls: ['./layer-demo.component.css'],\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n MatCard,\n MatCardHeader,\n MatCardAvatar,\n MatCardTitle,\n MatCardSubtitle,\n MatCardContent,\n MatButton,\n MatIconButton,\n MatChipSet,\n MatChip,\n MatChipRemove,\n MatFormField,\n MatLabel,\n MatHint,\n MatError,\n MatInput,\n MatIcon,\n MatTooltip,\n MatExpansionPanel,\n MatExpansionPanelHeader,\n MatExpansionPanelTitle,\n FormField,\n FormRoot,\n DecoratedTokenTextComponent,\n ],\n})\nexport class LayerDemoComponent {\n private readonly _segmenter = new TokenTextSegmenter();\n private readonly _textView = viewChild(DecoratedTokenTextComponent);\n\n /**\n * The fragments locations, in their order.\n */\n public readonly locations = signal<TokenLocation[]>([]);\n\n /**\n * The location of the picked fragment, if any.\n */\n public readonly selectedLocation = signal<TokenLocation | undefined>(\n undefined,\n );\n\n /**\n * The current text selection.\n */\n public readonly selection = signal<DecoratedTokenTextSelection | null>(\n null,\n );\n\n /**\n * The text size in pixels.\n */\n public readonly textSize = signal<number>(16);\n\n /**\n * The error for the typed location, if any.\n */\n public readonly locationError = signal<string | null>(null);\n\n /**\n * The demo form. This is a submission root: submitting it (e.g. with\n * Enter in the location input) adds the typed location.\n */\n public readonly demoForm = form(\n signal({\n text: LAYER_DEMO_TEXT,\n location: '1.2@2x2',\n }),\n (path) => {\n maxLength(path.text, 5000);\n },\n {\n submission: {\n action: async () => {\n this.addTypedLocation();\n return undefined;\n },\n ignoreValidators: 'all',\n },\n },\n );\n\n /**\n * The base text.\n */\n public readonly text = computed(() => this.demoForm.text().value() || '');\n\n private readonly _blocks = computed(() =>\n this._segmenter.getBlocks(this.text()),\n );\n\n /**\n * The text of the picked fragment.\n */\n public readonly selectedText = computed(() => {\n const loc = this.selectedLocation();\n if (!loc) {\n return '';\n }\n const segments = this._segmenter.getLocationSegments(this._blocks(), loc);\n return segments\n ? this._segmenter.getSegmentsText(this._blocks(), segments)\n : '';\n });\n\n public makeLarger(): void {\n this.textSize.update((size) => Math.min(24, size + 2));\n }\n\n public makeSmaller(): void {\n this.textSize.update((size) => Math.max(12, size - 2));\n }\n\n private removeOverlaps(loc: TokenLocation, locations: TokenLocation[]): void {\n for (let i = locations.length - 1; i > -1; i--) {\n if (loc !== locations[i] && loc.overlaps(locations[i])) {\n locations.splice(i, 1);\n }\n }\n }\n\n /**\n * Add the specified location to the fragments, keeping them sorted.\n * Like the backend does when adding a fragment to a layer part, any\n * existing fragment overlapping the new one is removed.\n * @returns True if added.\n */\n public addLocation(loc: TokenLocation): boolean {\n const locations = [...this.locations()];\n let done = false;\n for (let i = 0; i < locations.length && !done; i++) {\n const n = loc.compareTo(locations[i]);\n // nothing to do if equal\n if (n === 0) {\n return false;\n }\n // insert before nearest bigger sort value\n if (n < 0) {\n locations.splice(i, 0, loc);\n done = true;\n }\n }\n // append if not yet inserted\n if (!done) {\n locations.push(loc);\n }\n this.removeOverlaps(loc, locations);\n this.locations.set(locations);\n return true;\n }\n\n /**\n * Add the location typed in the form.\n */\n public addTypedLocation(): void {\n const value = this.demoForm.location().value()?.trim();\n if (!value) {\n this.locationError.set(null);\n return;\n }\n const loc = TokenLocation.parse(value);\n if (\n !loc ||\n !this._segmenter.getCoordsSegments(this._blocks(), loc.toString())\n ) {\n this.locationError.set(\n loc ? 'location not found in text' : 'invalid location',\n );\n return;\n }\n this.locationError.set(null);\n this.addLocation(loc);\n }\n\n /**\n * Add the location of the current selection.\n */\n public addSelection(): void {\n const loc = this.selection()?.location;\n if (loc && this.addLocation(loc)) {\n this.selection.set(null);\n }\n }\n\n /**\n * Handle a new selection in the text.\n */\n public onSelectionChange(selection: DecoratedTokenTextSelection): void {\n this.selection.set(selection.coords ? selection : null);\n }\n\n /**\n * Pick the specified fragment.\n */\n public pickLocation(loc: TokenLocation): void {\n this.selectedLocation.set(loc);\n }\n\n public removeLocation(loc: TokenLocation): void {\n const i = this.locations().indexOf(loc);\n if (i > -1) {\n const locations = [...this.locations()];\n locations.splice(i, 1);\n this.locations.set(locations);\n if (this.selectedLocation() === loc) {\n this.selectedLocation.set(undefined);\n }\n }\n }\n\n public clearLocations(): void {\n this.locations.set([]);\n this.selectedLocation.set(undefined);\n }\n\n /**\n * Clear the text selection.\n */\n public clearSelection(): void {\n this._textView()?.clearSelection();\n this.selection.set(null);\n }\n}\n","<mat-card appearance=\"outlined\">\n <mat-card-header>\n <mat-icon mat-card-avatar>layers</mat-icon>\n <mat-card-title>Text Layers Demo</mat-card-title>\n <mat-card-subtitle>token-based coordinates</mat-card-subtitle>\n </mat-card-header>\n <mat-card-content>\n <mat-expansion-panel>\n <mat-expansion-panel-header>\n <mat-panel-title>How it works</mat-panel-title>\n </mat-expansion-panel-header>\n <article>\n <p>\n A text layer annotates portions of a base text with fragments. Each\n fragment has a <strong>location</strong> with token-based\n coordinates, where a token is any sequence of non-whitespace\n characters. A point is <code>Y.X@AxR</code>:\n </p>\n <ul>\n <li><code>Y</code>: the line number (1-N).</li>\n <li><code>X</code>: the token number in the line (1-N).</li>\n <li>\n optionally, when not selecting whole tokens: <code>A</code> is\n the first character in the token (1-N), and <code>R</code> the\n count of characters (omitted when 1).\n </li>\n </ul>\n <p>\n A selection spanning several tokens has a start and an end point\n separated by <code>-</code>: the start point picks from its\n <code>A</code> to the end of its token, the end point picks the\n first <code>R</code> characters of its token. Whitespace at the\n edges of a selection is ignored. For instance, with the default\n text: <code>2.1</code> is <em>gamma</em>, <code>1.2@2x2</code>\n is <em>et</em>, <code>3.1@4x2-3.2@1</code> is\n <em>ta e</em>.\n </p>\n <p>\n Fragments in the same layer never overlap: so their characters are\n highlighted and <strong>blocked</strong>, and a selection always\n stops before them. Click a fragment to pick it; select any other\n portion of text (by dragging, SHIFT+clicking, or with SHIFT+arrows)\n to get its location, and add it as a new fragment. You can also\n type coordinates in the box below the text to select them.\n </p>\n </article>\n </mat-expansion-panel>\n\n <div class=\"layout\">\n <!-- input -->\n <form class=\"input\" [formRoot]=\"demoForm\">\n <mat-form-field class=\"text-field\">\n <mat-label>base text</mat-label>\n <textarea\n matInput\n id=\"text\"\n rows=\"6\"\n spellcheck=\"false\"\n [formField]=\"demoForm.text\"\n ></textarea>\n <mat-hint>each line is a block</mat-hint>\n </mat-form-field>\n\n <div class=\"location-row\">\n <mat-form-field>\n <mat-label>location</mat-label>\n <input\n matInput\n id=\"location\"\n spellcheck=\"false\"\n autocomplete=\"off\"\n [formField]=\"demoForm.location\"\n />\n @if (locationError(); as error) {\n <mat-error>{{ error }}</mat-error>\n } @else {\n <mat-hint>Y.X@AxR or Y.X@AxR-Y.X@AxR</mat-hint>\n }\n </mat-form-field>\n <button\n mat-icon-button\n type=\"submit\"\n matTooltip=\"Add a fragment at the typed location\"\n >\n <mat-icon class=\"mat-primary\">add_circle</mat-icon>\n </button>\n </div>\n\n <!-- fragments -->\n <div class=\"fragments\">\n <div class=\"fragments-header\">\n <span>fragments: {{ locations().length }}</span>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Remove all the fragments\"\n [disabled]=\"!locations().length\"\n (click)=\"clearLocations()\"\n >\n <mat-icon class=\"mat-warn\">delete_sweep</mat-icon>\n </button>\n </div>\n <mat-chip-set aria-label=\"fragments\">\n @for (loc of locations(); track loc) {\n <mat-chip\n [highlighted]=\"selectedLocation() === loc\"\n (click)=\"pickLocation(loc)\"\n (removed)=\"removeLocation(loc)\"\n >\n {{ loc.toString() }}\n <button\n matChipRemove\n type=\"button\"\n [attr.aria-label]=\"'remove ' + loc.toString()\"\n >\n <mat-icon>cancel</mat-icon>\n </button>\n </mat-chip>\n }\n </mat-chip-set>\n </div>\n </form>\n\n <!-- text -->\n <div class=\"output\">\n <div class=\"size-bar\">\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Larger text\"\n (click)=\"makeLarger()\"\n [disabled]=\"textSize() >= 24\"\n >\n <mat-icon>format_size</mat-icon>\n </button>\n <button\n mat-icon-button\n type=\"button\"\n matTooltip=\"Smaller text\"\n (click)=\"makeSmaller()\"\n [disabled]=\"textSize() <= 12\"\n >\n <mat-icon>text_fields</mat-icon>\n </button>\n </div>\n <cadmus-decorated-token-text\n [baseText]=\"text()\"\n [locations]=\"locations()\"\n [fontSize]=\"textSize()\"\n [showToolbar]=\"true\"\n [(selectedLocation)]=\"selectedLocation\"\n (selectionChange)=\"onSelectionChange($event)\"\n />\n\n <!-- details -->\n <div class=\"details\">\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>highlight_alt</mat-icon> selection\n </div>\n @if (selection(); as sel) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ sel.coords }}</code>\n <span class=\"text\">{{ sel.text }}</span>\n @if (sel.overlapping) {\n <span class=\"warn\">overlaps a fragment</span>\n }\n </div>\n <div class=\"detail-actions\">\n <button\n mat-flat-button\n type=\"button\"\n [disabled]=\"!sel.location\"\n (click)=\"addSelection()\"\n >\n <mat-icon>add_circle</mat-icon>\n add fragment\n </button>\n <button mat-button type=\"button\" (click)=\"clearSelection()\">\n clear\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">\n select any portion of the text\n </div>\n }\n </div>\n\n <div class=\"detail\">\n <div class=\"detail-title\">\n <mat-icon>bookmark</mat-icon> picked fragment\n </div>\n @if (selectedLocation(); as loc) {\n <div class=\"detail-body\">\n <code class=\"loc\">{{ loc.toString() }}</code>\n <span class=\"text\">{{ selectedText() }}</span>\n </div>\n <div class=\"detail-actions\">\n <button\n mat-button\n type=\"button\"\n class=\"mat-warn\"\n (click)=\"removeLocation(loc)\"\n >\n <mat-icon>remove_circle</mat-icon>\n remove\n </button>\n </div>\n } @else {\n <div class=\"detail-body muted\">click a fragment to pick it</div>\n }\n </div>\n </div>\n </div>\n </div>\n </mat-card-content>\n</mat-card>\n"],"mappings":";;;;;;;;;;;;;AA4CA,MAAa,kBAAkB;AA8C/B,IAAa,qBAAb,MAAa,mBAAkB;CACZ,aAAa,IAAI,mBAAkB;CACnC,YAAY,UAAU,6BAA4B,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAKnD,YAAY,OAAwB,CAAA,GAAG,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAKvC,mBAAmB,OACjC,QACD,GAAA,YAAA,CAAA,EAAA,WAAA,mBAAA,CAAA,+BAAA,CAAA,CAAA;CAKe,YAAY,OAC1B,MACD,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CAKe,WAAW,OAAe,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CAK7B,gBAAgB,OAAsB,MAAK,GAAA,YAAA,CAAA,EAAA,WAAA,gBAAA,CAAA,+BAAA,CAAA,CAAA;CAM3C,WAAW,KACzB,OAAO;EACL,MAAM;EACN,UAAU;CACX,CAAA,IACA,SAAQ;E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AAA;GAAA;IAAA,MAAA;IAAA,MACR;IAA2B,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,0BAAA,iBAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAGlB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAkB,YAAA,CAAA;EAhC9B,MAAA;EACW,MAAA,CAAA;GAAA,UAAA;GAAmB,iBAGZ,wBAAwB;GAAM,SACtC;IACP;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD;GAAA,UAAA;GAAA,QAAA,CAAA,2zDAAA;EAAA,CAAA;CAIsC,CAAA;CAAA,gBAAA,EAAA,WAAA,CAAA;EAAA,MAAA,GAAA;EAAA,MAAA,CAAA,GAAA,iBAAA,2BAA2B,GAAA,EAAA,UAAA,KAAA,CAAA;CAAA,CAAA,EAAA;AAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@myrmidon/cadmus-layer-demo",
|
|
3
|
-
"version": "16.0.1",
|
|
4
2
|
"description": "Cadmus - text layer demo page.",
|
|
5
3
|
"keywords": [
|
|
6
4
|
"Cadmus"
|
|
@@ -14,27 +12,28 @@
|
|
|
14
12
|
"name": "Daniele Fusi"
|
|
15
13
|
},
|
|
16
14
|
"peerDependencies": {
|
|
17
|
-
"@angular/common": "^22.
|
|
18
|
-
"@angular/core": "^22.
|
|
19
|
-
"@angular/material": "^22.
|
|
20
|
-
"@myrmidon/ngx-tools": "^3.0.
|
|
21
|
-
"@myrmidon/cadmus-core": "^
|
|
22
|
-
"@myrmidon/cadmus-ui": "^
|
|
23
|
-
},
|
|
24
|
-
"dependencies": {
|
|
25
|
-
"tslib": "^2.3.0"
|
|
15
|
+
"@angular/common": "^22.2.1",
|
|
16
|
+
"@angular/core": "^22.2.1",
|
|
17
|
+
"@angular/material": "^22.2.1",
|
|
18
|
+
"@myrmidon/ngx-tools": "^3.0.2",
|
|
19
|
+
"@myrmidon/cadmus-core": "^20.0.0",
|
|
20
|
+
"@myrmidon/cadmus-ui": "^20.0.0"
|
|
26
21
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
22
|
+
"name": "@myrmidon/cadmus-layer-demo",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"main": "./fesm2022/myrmidon-cadmus-layer-demo.mjs",
|
|
26
|
+
"module": "./fesm2022/myrmidon-cadmus-layer-demo.mjs",
|
|
27
|
+
"typings": "./types/myrmidon-cadmus-layer-demo.d.ts",
|
|
28
|
+
"types": "./types/myrmidon-cadmus-layer-demo.d.ts",
|
|
29
29
|
"exports": {
|
|
30
|
-
"./package.json": {
|
|
31
|
-
"default": "./package.json"
|
|
32
|
-
},
|
|
33
30
|
".": {
|
|
34
31
|
"types": "./types/myrmidon-cadmus-layer-demo.d.ts",
|
|
35
32
|
"default": "./fesm2022/myrmidon-cadmus-layer-demo.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": {
|
|
35
|
+
"default": "./package.json"
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
}
|
|
38
|
+
"version": "20.0.2"
|
|
39
|
+
}
|
|
@@ -1,30 +1,94 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { TokenLocation } from "@myrmidon/cadmus-core";
|
|
2
|
+
import { DecoratedTokenTextSelection } from "@myrmidon/cadmus-ui";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* The default demo text.
|
|
6
|
+
*/
|
|
7
|
+
export declare const LAYER_DEMO_TEXT = "alpha beta\ngamma\ndelta epsilon waw\nzeta";
|
|
8
|
+
/**
|
|
9
|
+
* Text layers demo page. This lets users play with the token-based
|
|
10
|
+
* coordinates system used by Cadmus text layers, as implemented by
|
|
11
|
+
* `DecoratedTokenTextComponent` and its `TokenTextSegmenter`:
|
|
12
|
+
* - enter a base text, which is displayed live.
|
|
13
|
+
* - add fragments (i.e. their locations) either by typing their
|
|
14
|
+
* coordinates, or by selecting a portion of the text. Fragment characters
|
|
15
|
+
* are highlighted and blocked, so that a new selection can never overlap
|
|
16
|
+
* them.
|
|
17
|
+
* - click a fragment to pick it, viewing its location and text, or
|
|
18
|
+
* removing it.
|
|
19
|
+
*/
|
|
20
|
+
export declare class LayerDemoComponent {
|
|
21
|
+
private readonly _segmenter;
|
|
22
|
+
private readonly _textView;
|
|
23
|
+
/**
|
|
24
|
+
* The fragments locations, in their order.
|
|
25
|
+
*/
|
|
26
|
+
readonly locations: import("@angular/core").WritableSignal<TokenLocation[]>;
|
|
27
|
+
/**
|
|
28
|
+
* The location of the picked fragment, if any.
|
|
29
|
+
*/
|
|
30
|
+
readonly selectedLocation: import("@angular/core").WritableSignal<TokenLocation | undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* The current text selection.
|
|
33
|
+
*/
|
|
34
|
+
readonly selection: import("@angular/core").WritableSignal<DecoratedTokenTextSelection | null>;
|
|
35
|
+
/**
|
|
36
|
+
* The text size in pixels.
|
|
37
|
+
*/
|
|
38
|
+
readonly textSize: import("@angular/core").WritableSignal<number>;
|
|
39
|
+
/**
|
|
40
|
+
* The error for the typed location, if any.
|
|
41
|
+
*/
|
|
42
|
+
readonly locationError: import("@angular/core").WritableSignal<string | null>;
|
|
43
|
+
/**
|
|
44
|
+
* The demo form. This is a submission root: submitting it (e.g. with
|
|
45
|
+
* Enter in the location input) adds the typed location.
|
|
46
|
+
*/
|
|
47
|
+
readonly demoForm: import("@angular/forms/signals").FieldTree<{
|
|
48
|
+
text: string;
|
|
49
|
+
location: string;
|
|
50
|
+
}, string | number, "writable">;
|
|
51
|
+
/**
|
|
52
|
+
* The base text.
|
|
53
|
+
*/
|
|
54
|
+
readonly text: import("@angular/core").Signal<string>;
|
|
55
|
+
private readonly _blocks;
|
|
56
|
+
/**
|
|
57
|
+
* The text of the picked fragment.
|
|
58
|
+
*/
|
|
59
|
+
readonly selectedText: import("@angular/core").Signal<string>;
|
|
60
|
+
makeLarger(): void;
|
|
61
|
+
makeSmaller(): void;
|
|
62
|
+
private removeOverlaps;
|
|
63
|
+
/**
|
|
64
|
+
* Add the specified location to the fragments, keeping them sorted.
|
|
65
|
+
* Like the backend does when adding a fragment to a layer part, any
|
|
66
|
+
* existing fragment overlapping the new one is removed.
|
|
67
|
+
* @returns True if added.
|
|
68
|
+
*/
|
|
69
|
+
addLocation(loc: TokenLocation): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Add the location typed in the form.
|
|
72
|
+
*/
|
|
73
|
+
addTypedLocation(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Add the location of the current selection.
|
|
76
|
+
*/
|
|
77
|
+
addSelection(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Handle a new selection in the text.
|
|
80
|
+
*/
|
|
81
|
+
onSelectionChange(selection: DecoratedTokenTextSelection): void;
|
|
82
|
+
/**
|
|
83
|
+
* Pick the specified fragment.
|
|
84
|
+
*/
|
|
85
|
+
pickLocation(loc: TokenLocation): void;
|
|
86
|
+
removeLocation(loc: TokenLocation): void;
|
|
87
|
+
clearLocations(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Clear the text selection.
|
|
90
|
+
*/
|
|
91
|
+
clearSelection(): void;
|
|
92
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<LayerDemoComponent, never>;
|
|
93
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<LayerDemoComponent, "cadmus-layer-demo", never, {}, {}, never, never, true, never>;
|
|
94
|
+
}
|