@myrmidon/gve-core 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
- import { DialogService } from '@myrmidon/ng-mat-tools';
3
+ import { DialogService } from '@myrmidon/ngx-mat-tools';
4
4
  import { GveAnimationTimeline } from '@myrmidon/gve-snapshot-view';
5
5
  import * as i0 from "@angular/core";
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter } from '@angular/core';
2
2
  import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
3
  import { CharNode, Feature } from '@myrmidon/gve-snapshot-view';
4
- import { DialogService } from '@myrmidon/ng-mat-tools';
4
+ import { DialogService } from '@myrmidon/ngx-mat-tools';
5
5
  import { BaseTextCharEvent } from '../base-text-char/base-text-char.component';
6
6
  import { VarBaseTextRange } from '../base-text-view/base-text-view.component';
7
7
  import * as i0 from "@angular/core";
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from '@angular/core';
2
- import { BaseTextChar, BaseTextCharEvent } from '../base-text-char/base-text-char.component';
3
2
  import { CharNode } from '@myrmidon/gve-snapshot-view';
3
+ import { BaseTextChar, BaseTextCharEvent } from '../base-text-char/base-text-char.component';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
6
6
  * A range in the base text.
@@ -24,8 +24,9 @@ export interface VarBaseTextRange {
24
24
  * - 🔥 `rangePick` (`VarBaseTextRange`): emitted when a range is picked.
25
25
  */
26
26
  export declare class BaseTextViewComponent {
27
- private _text?;
27
+ private _text;
28
28
  private _lastSelectedChar?;
29
+ private _borderColorCallback?;
29
30
  /**
30
31
  * The default color for the text.
31
32
  */
@@ -45,8 +46,14 @@ export declare class BaseTextViewComponent {
45
46
  /**
46
47
  * The text to display.
47
48
  */
48
- get text(): string | CharNode[] | undefined;
49
- set text(value: string | CharNode[] | undefined | null);
49
+ get text(): CharNode[] | undefined;
50
+ set text(value: CharNode[] | undefined | null);
51
+ /**
52
+ * An optional callback to get the color of a character node.
53
+ * Return null to use the default color.
54
+ */
55
+ get borderColorCallback(): ((node: CharNode) => string | null) | undefined;
56
+ set borderColorCallback(value: ((node: CharNode) => string | null) | undefined);
50
57
  /**
51
58
  * Emitted when a character is picked.
52
59
  */
@@ -62,5 +69,5 @@ export declare class BaseTextViewComponent {
62
69
  private resetColors;
63
70
  onCharPick(event: BaseTextCharEvent): void;
64
71
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseTextViewComponent, never>;
65
- static ɵcmp: i0.ɵɵComponentDeclaration<BaseTextViewComponent, "gve-base-text-view", never, { "defaultColor": { "alias": "defaultColor"; "required": false; }; "defaultBorderColor": { "alias": "defaultBorderColor"; "required": false; }; "selectionColor": { "alias": "selectionColor"; "required": false; }; "hasLineNumber": { "alias": "hasLineNumber"; "required": false; }; "text": { "alias": "text"; "required": false; }; }, { "charPick": "charPick"; "rangePick": "rangePick"; }, never, never, true, never>;
72
+ static ɵcmp: i0.ɵɵComponentDeclaration<BaseTextViewComponent, "gve-base-text-view", never, { "defaultColor": { "alias": "defaultColor"; "required": false; }; "defaultBorderColor": { "alias": "defaultBorderColor"; "required": false; }; "selectionColor": { "alias": "selectionColor"; "required": false; }; "hasLineNumber": { "alias": "hasLineNumber"; "required": false; }; "text": { "alias": "text"; "required": false; }; "borderColorCallback": { "alias": "borderColorCallback"; "required": false; }; }, { "charPick": "charPick"; "rangePick": "rangePick"; }, never, never, true, never>;
66
73
  }
@@ -1,7 +1,7 @@
1
1
  import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
2
  import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
3
  import { Clipboard } from '@angular/cdk/clipboard';
4
- import { DialogService } from '@myrmidon/ng-mat-tools';
4
+ import { DialogService } from '@myrmidon/ngx-mat-tools';
5
5
  import { CharChainOperation, Feature, OperationFeature, OperationType, OperationSource, SnapshotBase } from '@myrmidon/gve-snapshot-view';
6
6
  import { SettingsService } from '../../services/settings.service';
7
7
  import * as i0 from "@angular/core";
@@ -114,6 +114,7 @@ export declare class ChainOperationEditorComponent implements OnInit, OnDestroy
114
114
  value: FormControl<string | null>;
115
115
  svg: FormControl<string>;
116
116
  elementFeatures: FormControl<Record<string, Feature[]>>;
117
+ newTextHidden: FormControl<boolean>;
117
118
  dpFeatures: FormControl<Feature[]>;
118
119
  form: FormGroup;
119
120
  elements: SVGElement[];
@@ -135,6 +136,8 @@ export declare class ChainOperationEditorComponent implements OnInit, OnDestroy
135
136
  loadSvg(): void;
136
137
  setSvgFromClipboard(): void;
137
138
  private parseSvg;
139
+ removeDecimals(): void;
140
+ wrapInGroup(): void;
138
141
  onTabIndexChange(index: number): void;
139
142
  editElementFeatures(element: SVGElement): void;
140
143
  deleteElementFeatures(element: SVGElement): void;
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
2
  import { FormBuilder, FormControl } from '@angular/forms';
3
- import { OperationFeature } from '@myrmidon/gve-snapshot-view';
3
+ import { CharNode, OperationFeature } from '@myrmidon/gve-snapshot-view';
4
4
  import { VarBaseTextRange } from '../base-text-view/base-text-view.component';
5
5
  import { ChainOperationContextStep, CharChainResult } from '../../services/gve-api.service';
6
6
  import { BaseTextCharEvent } from '../base-text-char/base-text-char.component';
@@ -46,6 +46,7 @@ export declare class ChainResultViewComponent implements OnInit, OnDestroy {
46
46
  selectionFeatures: OperationFeature[];
47
47
  constructor(formBuilder: FormBuilder);
48
48
  ngOnInit(): void;
49
+ getCharBorderColor(node: CharNode): string | null;
49
50
  private selectInitialStep;
50
51
  ngOnDestroy(): void;
51
52
  private updateVersionTags;
@@ -65,7 +65,7 @@ export declare class FeatureEditorComponent implements OnInit, OnDestroy {
65
65
  /**
66
66
  * Event emitted when the user saves the edited feature.
67
67
  */
68
- featureChange: EventEmitter<Feature | OperationFeature>;
68
+ featureChange: EventEmitter<OperationFeature | Feature>;
69
69
  name: FormControl<string>;
70
70
  value: FormControl<string>;
71
71
  setPolicy: FormControl<FeatureSetPolicy>;
@@ -2,7 +2,7 @@ import { ElementRef, EventEmitter } from '@angular/core';
2
2
  import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
3
  import { MatSnackBar } from '@angular/material/snack-bar';
4
4
  import { MatDialog } from '@angular/material/dialog';
5
- import { DialogService } from '@myrmidon/ng-mat-tools';
5
+ import { DialogService } from '@myrmidon/ngx-mat-tools';
6
6
  import { CharChainOperation, CharNode, GveAnimationTimeline, GveVisualEvent, Snapshot, SnapshotViewComponent, SnapshotViewData, SnapshotViewRenderEvent } from '@myrmidon/gve-snapshot-view';
7
7
  import { VarBaseTextRange } from '../base-text-view/base-text-view.component';
8
8
  import { ChainOperationContextStep, CharChainResult, GveApiService } from '../../services/gve-api.service';
@@ -59,7 +59,7 @@ export declare class SnapshotEditorComponent {
59
59
  width: FormControl<number>;
60
60
  height: FormControl<number>;
61
61
  style: FormControl<string | null>;
62
- baseText: FormControl<CharNode[] | string>;
62
+ baseText: FormControl<CharNode[]>;
63
63
  offsetX: FormControl<number>;
64
64
  offsetY: FormControl<number>;
65
65
  lineHeightOffset: FormControl<number>;
@@ -113,6 +113,7 @@ export declare class SnapshotEditorComponent {
113
113
  */
114
114
  private setViewData;
115
115
  private updateForm;
116
+ inputBaseText(): void;
116
117
  /**
117
118
  * Update the line count based on the received text.
118
119
  * @param text The text to use for counting lines.
@@ -123,11 +124,6 @@ export declare class SnapshotEditorComponent {
123
124
  * @param range The picked range.
124
125
  */
125
126
  onRangePick(range: VarBaseTextRange): void;
126
- /**
127
- * Handle the event fired by the base text editor to change the base text.
128
- * @param text The text to set.
129
- */
130
- onTextChange(text: CharNode[]): void;
131
127
  /**
132
128
  * Update the lists of operation output tags and element IDs by collecting
133
129
  * all the operation tags and the IDs of the elements in their diplomatic.g
@@ -158,7 +154,7 @@ export declare class SnapshotEditorComponent {
158
154
  * was a new operation.
159
155
  * @param op The changed operation.
160
156
  */
161
- onOperationChange(op: CharChainOperation): Promise<void>;
157
+ onOperationChange(op: CharChainOperation): void;
162
158
  /**
163
159
  * Delete the operation at the specified index.
164
160
  * @param index The index of the operation to delete.
@@ -169,6 +165,9 @@ export declare class SnapshotEditorComponent {
169
165
  * snapshot operations.
170
166
  */
171
167
  parseOperations(): void;
168
+ /**
169
+ * Remove all the operations, close the edited operation and update the view data.
170
+ */
172
171
  private removeAllOperations;
173
172
  /**
174
173
  * Remove all the operations.
@@ -183,6 +182,24 @@ export declare class SnapshotEditorComponent {
183
182
  */
184
183
  private parseSvgIds;
185
184
  private getTransparentIds;
185
+ /**
186
+ * Supply operation nodes to the snapshot text nodes. An execution result is
187
+ * a compact object, so that to build a snapshot accumulating all the nodes
188
+ * and their features up to the last executed operation, we need to start
189
+ * with the base text nodes, and then examine each execution step in the
190
+ * result. Each step contains only those nodes used by the version of the
191
+ * text corresponding to its stage. Among them, some are new nodes, and some
192
+ * are base text nodes. Also, the step contains the full set of features
193
+ * current at its time, both for the text as a whole and for each node.
194
+ * This method accumulates the nodes and their features up to the specified
195
+ * step, updating the features of the nodes already present in the snapshot
196
+ * text nodes, and adding the new nodes.
197
+ *
198
+ * @param snapshot The snapshot to supply the nodes to.
199
+ * @param result The operations execution result.
200
+ * @param tag The output tag of the operation to supply the nodes from.
201
+ */
202
+ private supplyOpNodes;
186
203
  /**
187
204
  * Run the operations up to the specified index (included).
188
205
  * This is called when:
@@ -198,14 +215,15 @@ export declare class SnapshotEditorComponent {
198
215
  * @param lastOperation The operation to use in place of the existing
199
216
  * operation in the snapshot at index. This is used when previewing
200
217
  * the edited operation from within the operation editor.
218
+ * @returns A promise that resolves to the execution result.
201
219
  */
202
- runTo(index: number, lastOperation?: CharChainOperation): Promise<CharChainResult>;
220
+ runTo(index: number, lastOperation?: CharChainOperation): void;
203
221
  /**
204
222
  * Run the operations up to the last operation if any, updating the
205
223
  * execution result. The execution result is always the result from
206
224
  * all the operations, as users must be able to browse across its steps.
207
225
  */
208
- runToLast(): Promise<void>;
226
+ runToLast(): void;
209
227
  /**
210
228
  * Update the snapshot view by running the operations up to the
211
229
  * currently edited operation if any.
@@ -230,7 +248,7 @@ export declare class SnapshotEditorComponent {
230
248
  *
231
249
  * @param step The step to pick.
232
250
  */
233
- onStepPick(step: ChainOperationContextStep): Promise<void>;
251
+ onStepPick(step: ChainOperationContextStep): void;
234
252
  /**
235
253
  * Handle the event fired by a visual in the snapshot view.
236
254
  *
@@ -260,6 +278,9 @@ export declare class SnapshotEditorComponent {
260
278
  * @param event The rendition event.
261
279
  */
262
280
  onSnapshotRender(event: CustomEvent<SnapshotViewRenderEvent>): void;
281
+ onImageLoad(imageElement: HTMLImageElement): void;
282
+ onImageOpacityChange(value: number): void;
283
+ resetImgMetadata(): void;
263
284
  /**
264
285
  * Toggle rulers in the snapshot view.
265
286
  */
@@ -0,0 +1,39 @@
1
+ import { EventEmitter, OnInit } from '@angular/core';
2
+ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
3
+ import { MatDialogRef } from '@angular/material/dialog';
4
+ import { CharNode } from '@myrmidon/gve-snapshot-view';
5
+ import { PayloadMatDialogConfig } from '../../models';
6
+ import * as i0 from "@angular/core";
7
+ /**
8
+ * 🔑 `gve-snapshot-text-editor`
9
+ *
10
+ * A component to edit a snapshot text. This component can be used both in a dialog
11
+ * and as a standalone component.
12
+ *
13
+ * - ▶️ `text` (`CharNode[]`): the text to edit.
14
+ * - 🔥 `textChange` (`CharNode[]`): event emitted when text changes.
15
+ */
16
+ export declare class SnapshotTextEditorComponent implements OnInit {
17
+ dialogRef?: MatDialogRef<SnapshotTextEditorComponent> | undefined;
18
+ data?: PayloadMatDialogConfig<{
19
+ text?: CharNode[];
20
+ }> | undefined;
21
+ private _nodes;
22
+ userText: FormControl<string>;
23
+ form: FormGroup;
24
+ get text(): CharNode[];
25
+ set text(value: CharNode[] | undefined | null);
26
+ /**
27
+ * Emitted when text changes.
28
+ */
29
+ readonly textChange: EventEmitter<CharNode[]>;
30
+ constructor(formBuilder: FormBuilder, dialogRef?: MatDialogRef<SnapshotTextEditorComponent> | undefined, data?: PayloadMatDialogConfig<{
31
+ text?: CharNode[];
32
+ }> | undefined);
33
+ private updateUserText;
34
+ ngOnInit(): void;
35
+ close(): void;
36
+ save(): void;
37
+ static ɵfac: i0.ɵɵFactoryDeclaration<SnapshotTextEditorComponent, [null, { optional: true; }, { optional: true; }]>;
38
+ static ɵcmp: i0.ɵɵComponentDeclaration<SnapshotTextEditorComponent, "gve-snapshot-text-editor", never, { "text": { "alias": "text"; "required": false; }; }, { "textChange": "textChange"; }, never, never, true, never>;
39
+ }
@@ -22,7 +22,10 @@ import * as i0 from "@angular/core";
22
22
  */
23
23
  export declare class StepsMapComponent {
24
24
  private _steps?;
25
- lines: string[];
25
+ private _selectedStep?;
26
+ lines: {
27
+ [key: string]: string[];
28
+ };
26
29
  /**
27
30
  * The steps to display.
28
31
  */
@@ -31,7 +34,8 @@ export declare class StepsMapComponent {
31
34
  /**
32
35
  * The step that is currently selected.
33
36
  */
34
- selectedStep: ChainOperationContextStep | undefined;
37
+ get selectedStep(): ChainOperationContextStep | undefined;
38
+ set selectedStep(value: ChainOperationContextStep | undefined);
35
39
  /**
36
40
  * The font size of the steps text.
37
41
  */
@@ -1,6 +1,6 @@
1
1
  import { HttpClient } from '@angular/common/http';
2
2
  import { Observable } from 'rxjs';
3
- import { ErrorService, EnvService } from '@myrmidon/ng-tools';
3
+ import { ErrorService, EnvService } from '@myrmidon/ngx-tools';
4
4
  import { CharChainOperation, CharNode, OperationFeature } from '@myrmidon/gve-snapshot-view';
5
5
  import { ResultWrapper } from '../models';
6
6
  import * as i0 from "@angular/core";
@@ -21,13 +21,16 @@ export interface ChainOperationContextStep {
21
21
  */
22
22
  outputTag: string;
23
23
  /**
24
- * The string synthetically representing the result.
24
+ * The string synthetically representing the resulting text
25
+ * version.
25
26
  */
26
27
  result?: string;
27
28
  /**
28
29
  * The features emitted up to the executed operation.
29
30
  * These are the features of the text as a whole, and
30
- * those belonging to specific nodes.
31
+ * those belonging to specific nodes, each keyed under
32
+ * a string built with `v` + output version tag + `_`
33
+ * + node ID (e.g. `v1_2` for node with ID 2 at version 1).
31
34
  */
32
35
  featureSet: {
33
36
  features: OperationFeature[];
@@ -52,11 +55,15 @@ export interface CharChainResult {
52
55
  */
53
56
  chainDump: string;
54
57
  /**
55
- * The list of unique tags in the chain.
58
+ * The list of all unique tags in the chain.
56
59
  */
57
60
  chainTags: string[];
58
61
  /**
59
62
  * The sets of nodes in their order, for each version tag.
63
+ * These nodes are collected by following the path defined
64
+ * by the set of links of each version tag; so each of the
65
+ * sets contains only the nodes used at that step to build
66
+ * the text version, with their features up to that stage.
60
67
  */
61
68
  taggedNodes: {
62
69
  [key: string]: CharNode[];
@@ -1,10 +1,15 @@
1
+ import { Observable } from 'rxjs';
1
2
  import * as i0 from "@angular/core";
2
3
  /**
3
- * Service to store and retrieve dynamic settings. On demand, settings can
4
- * be persisted in the local storage.
4
+ * Service to store and retrieve dynamic settings.
5
5
  */
6
6
  export declare class SettingsService {
7
7
  private readonly _cache;
8
+ private readonly _subject;
9
+ /**
10
+ * Observable emitting the key of the setting that has changed.
11
+ */
12
+ get settingChange$(): Observable<string | null>;
8
13
  /**
9
14
  * Prefix to scope the keys. This prefix is used internally to scope the keys
10
15
  * so that they cannot conflict with other keys in the local storage.
@@ -12,6 +17,10 @@ export declare class SettingsService {
12
17
  * use the keys without the prefix.
13
18
  */
14
19
  keyPrefix?: string;
20
+ /**
21
+ * True to persist the settings in the local storage by default.
22
+ */
23
+ persistDefault: boolean;
15
24
  /**
16
25
  * Scopes the key by prefixing it with the keyPrefix if any.
17
26
  *
@@ -19,6 +28,7 @@ export declare class SettingsService {
19
28
  * @returns The scoped key.
20
29
  */
21
30
  private getScopedKey;
31
+ private isPersist;
22
32
  /**
23
33
  * Sets a setting's value.
24
34
  *
@@ -27,6 +37,15 @@ export declare class SettingsService {
27
37
  * @param persist True to persist this setting in local storage.
28
38
  */
29
39
  set(key: string, value: any, persist?: boolean): void;
40
+ /**
41
+ * Set multiple settings at once from the specified settings object.
42
+ *
43
+ * @param settings The settings to set.
44
+ * @param persist True to persist these settings in local storage.
45
+ */
46
+ setFrom(settings: {
47
+ [key: string]: any;
48
+ } | undefined | null, persist?: boolean): void;
30
49
  /**
31
50
  * Get a setting's value of type T.
32
51
  *
@@ -35,20 +54,36 @@ export declare class SettingsService {
35
54
  * is not found in the store.
36
55
  * @returns The value.
37
56
  */
38
- get<T>(key: string, defaultValue?: any): T;
57
+ get<T>(key: string, defaultValue?: any, persist?: boolean): T;
39
58
  /**
40
59
  * Check if a key exists in the store.
41
60
  *
42
61
  * @param key The key.
62
+ * @param persist True to check if the key exists in local storage.
43
63
  * @returns True if the key exists in the store.
44
64
  */
45
- contains(key: string): boolean;
65
+ contains(key: string, persist?: boolean): boolean;
66
+ /**
67
+ * Get all the keys of the settings in the store.
68
+ *
69
+ * @param persist True to include keys from local storage.
70
+ * @returns The keys of the settings in the store.
71
+ */
72
+ getKeys(persist?: boolean): string[];
46
73
  /**
47
74
  * Remove a setting if present.
48
75
  *
49
76
  * @param key The key.
77
+ * @param persist True to remove the setting from local storage.
78
+ */
79
+ remove(key: string, persist?: boolean): void;
80
+ /**
81
+ * Clear all settings. Warning: this will remove all settings from the
82
+ * local storage if no key prefix is set.
83
+ *
84
+ * @param persist True to remove all settings from local storage.
50
85
  */
51
- remove(key: string): void;
86
+ clear(persist?: boolean): void;
52
87
  static ɵfac: i0.ɵɵFactoryDeclaration<SettingsService, never>;
53
88
  static ɵprov: i0.ɵɵInjectableDeclaration<SettingsService>;
54
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrmidon/gve-core",
3
- "version": "1.0.0",
3
+ "version": "2.0.0",
4
4
  "description": "Cadmus - GVE Angular frontend core components.",
5
5
  "keywords": [
6
6
  "GVE"
@@ -17,13 +17,13 @@
17
17
  "@angular/common": "^19.0.0",
18
18
  "@angular/core": "^19.0.0",
19
19
  "@cisstech/nge": "^18.0.4",
20
- "@myrmidon/ng-mat-tools": "^4.0.0",
21
- "@myrmidon/ng-tools": "^4.0.0",
22
- "@myrmidon/gve-snapshot-view": "^1.1.2",
20
+ "@myrmidon/ngx-mat-tools": "^0.0.1",
21
+ "@myrmidon/ngx-tools": "^0.0.1",
22
+ "@myrmidon/gve-snapshot-view": "^1.1.6",
23
23
  "@svgdotjs/svg.js": "^3.2.4",
24
24
  "gsap": "^3.12.5",
25
25
  "monaco-editor": "^0.52.0",
26
- "nanoid": "^5.0.8"
26
+ "nanoid": "^5.0.9"
27
27
  },
28
28
  "dependencies": {
29
29
  "tslib": "^2.3.0"
package/public-api.d.ts CHANGED
@@ -14,6 +14,7 @@ export * from './lib/components/ln-heights-editor/ln-heights-editor.component';
14
14
  export * from './lib/components/operation-source-editor/operation-source-editor.component';
15
15
  export * from './lib/components/simple-tree/simple-tree.component';
16
16
  export * from './lib/components/snapshot-editor/snapshot-editor.component';
17
+ export * from './lib/components/snapshot-text-editor/snapshot-text-editor.component';
17
18
  export * from './lib/components/steps-map/steps-map.component';
18
19
  export * from './lib/services/gve-api.service';
19
20
  export * from './lib/services/settings.service';