import { ComponentCanDeactivate, EditedObject, FacetDefinition, FlagDefinition, Fragment, FragmentIdentity, LayerHint, LibraryRouteService, Part, PartIdentity, TextLayerPart, ThesauriSet, Thesaurus, TokenLocation } from "@myrmidon/cadmus-core"; import { Observable } from "rxjs"; import { EditorSettingsService, FacetService, FlagService, ItemService, PreviewService, ThesaurusService } from "@myrmidon/cadmus-api"; import * as i0 from "@angular/core"; import { OnDestroy, OnInit } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; import { MatSnackBar } from "@angular/material/snack-bar"; /** * App state repository. */ export declare class AppRepository { private _facetService; private _flagService; private _thesaurusService; private _previewService; private _settingService; private readonly _facets$; private readonly _flags$; private readonly _typeThesaurus$; private readonly _itemBrowserThesaurus$; private readonly _previewJKeys$; private readonly _previewFKeys$; private readonly _previewCKeys$; private readonly _settingsCache; get facets$(): Observable; get flags$(): Observable; get typeThesaurus$(): Observable; get itemBrowserThesaurus$(): Observable; get previewJKeys$(): Observable; get previewFKeys$(): Observable; get previewCKeys$(): Observable; constructor(_facetService: FacetService, _flagService: FlagService, _thesaurusService: ThesaurusService, _previewService: PreviewService, _settingService: EditorSettingsService); /** * Get the loaded model types thesaurus. * @returns Thesaurus or undefined if not loaded. */ getTypeThesaurus(): Thesaurus | undefined; /** * Get the loaded items facets. * @returns The facets. */ getFacets(): FacetDefinition[]; /** * Get the loaded items flags. * @returns The flags. */ getFlags(): FlagDefinition[]; /** * Load app data from the API. If the data is already loaded, this * does nothing unless refresh is true. * * @param refresh True to force a refresh. * @returns Promise. */ load(refresh?: boolean): Promise; /** * Clear the repository. */ clear(): void; /** * Load the model types and item browsers thesauri. */ loadThesauri(): Promise; /** * Get the color defined for the specified part type ID, reading it * from the facets definitions. * @param typeId The part type ID. * @param roleId The optional role type ID. * @returns The color key, or undefined if not found. */ getPartColor(typeId: string, roleId?: string): string | undefined; /** * Load the flags definitions. */ loadFlags(): Promise; /** * Get the editor setting with the specified ID. * @param id The setting ID. * @param reload True to force reloading from server. * @returns Promise with the settings object. */ getSetting(id: string, reload?: boolean): Promise; /** * Set the editor setting with the specified ID. * @param id The setting ID. * @param setting The setting to store. */ setSetting(id: string, setting: T): void; /** * Get the editor setting for the specified part or fragment type ID, * optionally having the specified role ID. * @param typeId The part or fragment type ID. * @param roleId The optional role ID. * @param reload True to force reloading from server. * @returns Promise with settings object. */ getSettingFor(typeId: string, roleId?: string, reload?: boolean): Promise; /** * Set the editor setting for the specified part or fragment type ID, * optionally having the specified role ID. * @param typeId The part or fragment type ID. * @param setting The setting to store. * @param roleId The optional role ID. */ setSettingFor(typeId: string, setting: T, roleId?: string): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Service used by layer part editor wrappers to load part and thesauri * or save parts. */ export declare class FragmentEditorService { private _itemService; private _thesaurusService; private _loading$; private _saving$; loading$: Observable; saving$: Observable; constructor(_itemService: ItemService, _thesaurusService: ThesaurusService); private getFragmentFromPart; private loadWithThesauri; private loadWithoutThesauri; /** * Load into the state the part with the specified ID * and its thesauri. * If the ID is not specified, it's a new part; in this case, * it will get a null ID, but use the specified itemId and roleId. * * @param identity The part identity. * @param thesauriIds The thesauri IDs array. */ load(identity: FragmentIdentity, thesauriIds?: string[]): Promise | null>; /** * Save the fragments in their layer part. * * @param part The part. * @returns Promise which when successful returns the saved part. */ save(part: Part): Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Base class for fragment feature editors. * This is similar to the EditPartFeatureBase class. */ export declare abstract class EditFragmentFeatureBase implements OnInit, OnDestroy, ComponentCanDeactivate { private _router; protected snackbar: MatSnackBar; protected editorService: FragmentEditorService; private _libraryRouteService; private _loadingSub?; private _savingSub?; /** * The fragment being edited. */ readonly data: import("@angular/core").WritableSignal | undefined>; /** * The identity of the fragment being edited. This gets built from the current * route. */ readonly identity: import("@angular/core").WritableSignal; /** * True when the wrapped editor component data is dirty. */ readonly dirty: import("@angular/core").WritableSignal; /** * True when loading data. */ readonly loading: import("@angular/core").WritableSignal; /** * True when saving data. */ readonly saving: import("@angular/core").WritableSignal; /** * The location of the fragment being edited. */ readonly frLoc: import("@angular/core").WritableSignal; constructor(_router: Router, route: ActivatedRoute, snackbar: MatSnackBar, editorService: FragmentEditorService, _libraryRouteService: LibraryRouteService); /** * Override in derived classes to return the IDs of the thesauri requested * for this editor. * * @return Array with thesauri IDs, eventually empty. */ protected getReqThesauriIds(): string[]; /** * Called once data has been loaded. */ protected onDataLoaded(): void; ngOnInit(): void; ngOnDestroy(): void; canDeactivate(): boolean; /** * Called when the wrapped editor dirty state changes. * In the HTML template, you MUST bind this handler to the dirtyChange event * emitted by your wrapped editor (i.e. (dirtyChange)="onDirtyChange($event)"). * * @param value The value of the dirty state. */ onDirtyChange(value: boolean): void; /** * Save the fragment. * * @param fragment The fragment to be saved. */ save(fragment: Fragment): void; close(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } /** * Service used by part editor wrappers to load part and thesauri * or save parts. */ export declare class PartEditorService { private _itemService; private _thesaurusService; private _loading$; private _saving$; loading$: Observable; saving$: Observable; constructor(_itemService: ItemService, _thesaurusService: ThesaurusService); private loadWithThesauri; private loadWithoutThesauri; /** * Load into the state the part with the specified ID * and its thesauri. * If the ID is not specified, it's a new part; in this case, * it will get a null ID, but use the specified itemId and roleId. * * @param identity The part identity. * @param thesauriIds The thesauri IDs array. */ load(identity: PartIdentity, thesauriIds?: string[]): Promise | null>; /** * Save the part. * * @param part The part. * @returns Promise which when successful returns the saved part. */ save(part: Part): Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Base class for part feature editors. * A part feature editor is a wrapper component around a model editor component, * used to separate the editor's logic from its host infrastructure. */ export declare abstract class EditPartFeatureBase implements OnInit, OnDestroy, ComponentCanDeactivate { protected router: Router; protected snackbar: MatSnackBar; protected itemService: ItemService; protected thesaurusService: ThesaurusService; protected editorService: PartEditorService; private _loadingSub?; private _savingSub?; /** * The part being edited. */ readonly data: import("@angular/core").WritableSignal | undefined>; /** * The identity of the part being edited. This gets built from the current * route. */ readonly identity: import("@angular/core").WritableSignal; /** * True when the wrapped editor component data is dirty. */ readonly dirty: import("@angular/core").WritableSignal; /** * True when loading data. */ readonly loading: import("@angular/core").WritableSignal; /** * True when saving data. */ readonly saving: import("@angular/core").WritableSignal; /** * Set to true when you want the role ID (defined by identity) to affect * the ID of the thesauri to load. You should set this in your editor * constructor, or in your getReqThesauriIds override. When true, the role ID * will be suffixed (preceded by an underscore) to the thesaurus ID, * before its language identifier, i.e. for instance "categories@en" * with role "sample" becomes "categories_sample@en". When this option is * enabled, and some of your thesauri do not need to be suffixed, just * provide an alias for the suffixed thesaurus in the backend. */ protected roleIdInThesauri?: boolean; constructor(router: Router, route: ActivatedRoute, snackbar: MatSnackBar, itemService: ItemService, thesaurusService: ThesaurusService, editorService: PartEditorService); /** * Override in derived classes to return the IDs of the thesauri requested * for this editor. * * @return Array with thesauri IDs, eventually empty. */ protected getReqThesauriIds(): string[]; /** * Called once data has been loaded. */ protected onDataLoaded(): void; private suffixThesaurusId; private suffixThesauriIds; ngOnInit(): void; ngOnDestroy(): void; canDeactivate(): boolean; /** * Called when the wrapped editor dirty state changes. * In the HTML template, you MUST bind this handler to the dirtyChange event * emitted by your wrapped editor (i.e. (dirtyChange)="onDirtyChange($event)"). * * @param value The value of the dirty state. */ onDirtyChange(value: boolean): void; /** * Save the part. * * @param part The part to be saved. */ save(part: Part): void; /** * Close the editor by navigating back to the part's item. */ close(): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵcmp: i0.ɵɵComponentDeclaration; } export declare class EditedThesaurusRepository { private _thesaurusService; private _thesaurus$; private _loading$; private _saving$; loading$: Observable; saving$: Observable; get thesaurus$(): Observable; constructor(_thesaurusService: ThesaurusService); getThesaurus(): Thesaurus | undefined; /** * Load the specified thesaurus. * * @param id The thesaurus ID or undefined to load a new thesaurus. */ load(id?: string): void; /** * Save the specified thesaurus. * * @param thesaurus The thesaurus to save. * @returns Promise with saved thesaurus. */ save(thesaurus: Thesaurus): Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Edited layer part repository. */ export declare class EditedLayerRepository { private _itemService; private _facetService; private _thesaurusService; private _part$; private _baseText$; private _baseTextPart$; private _locations$; private _breakChance$; private _layerHints$; private _thesauriSet; private _loading$; private _saving$; get loading$(): Observable; get saving$(): Observable; get part$(): Observable; get baseText$(): Observable; get baseTextPart$(): Observable; get locations$(): Observable; get breakChance$(): Observable; get layerHints$(): Observable; get thesauriSet$(): Observable; constructor(_itemService: ItemService, _facetService: FacetService, _thesaurusService: ThesaurusService); reset(): void; getPart(): TextLayerPart | undefined; getBaseText(): string | undefined; getLocations(): TokenLocation[]; private getPartLocations; private loadWithThesauri; private loadWithoutThesauri; /** * Load the state for editing layer part(s). * * @param itemId The item ID the layer part belongs to. * @param partId The layer part ID. * @param thesauriIds The optional thesauri IDs to load. */ load(itemId: string, partId: string, thesauriIds?: string[]): void; /** * Refresh the layer part break chance. */ refreshBreakChance(): void; applyLayerPatches(partId: string, patches: string[]): void; /** * Delete the fragment at the specified location. * * @param loc The fragment's location. */ deleteFragment(loc: TokenLocation): void; /** * Save the specified fragment. * * @param fragment The fragment. */ saveFragment(fragment: Fragment): void; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }