ng2-json-editor
Version:
Angular2 component for editing large json documents
46 lines (45 loc) • 2.01 kB
TypeScript
import { Map } from 'immutable';
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { Subject } from 'rxjs/Subject';
import { PathUtilService } from './path-util.service';
import { KeysStoreService } from './keys-store.service';
import { JsonPatch, JsonPatchesByPath } from '../interfaces';
export declare class JsonStoreService {
private pathUtilService;
private keysStoreService;
readonly patchesByPath$: ReplaySubject<JsonPatchesByPath>;
readonly json$: Subject<Map<string, any>>;
readonly jsonPatches$: Subject<JsonPatch[]>;
private json;
private jsonPatches;
patchesByPath: JsonPatchesByPath;
private history;
constructor(pathUtilService: PathUtilService, keysStoreService: KeysStoreService);
setIn(path: Array<any>, value: any, allowUndo?: boolean): void;
private setEmptyListBeforeEachIndexInPath(path);
getIn(path: Array<any>, notSetValue?: any): any;
removeIn(path: Array<any>): void;
private pushRevertPatchToHistory(path, revertOp);
addIn(path: Array<any>, value: any): void;
private toImmutable(value);
/**
* Moves the element at given index UP or DOWN within the list
* @param listPath path to a list in json
* @param index index of the element that is being moved
* @param direction 1 for DOWN, -1 for UP movement
* @return new path of the moved element
*/
moveIn(listPath: Array<any>, index: number, direction: number): Array<any>;
setJson(json: Map<string, any>): void;
setJsonPatches(patches: Array<JsonPatch>): void;
rollbackLastChange(): string;
applyPatch(patch: JsonPatch, allowUndo?: boolean): void;
rejectPatch(patch: JsonPatch): void;
hasPatch(path: string): boolean;
hasPatchOrChildrenHavePatch(path: string): boolean;
removeJsonPatch(patch: JsonPatch): void;
private getComponentPathForPatch(patch);
private getParentPath(path);
getPatchesIncludingPath(path: string): JsonPatch[];
deletePatchForElement(path: any): void;
}