UNPKG

@ckeditor/ckeditor5-operations-compressor

Version:

CKEditor 5 operations compressor for real-time collaboration.

62 lines (61 loc) 2.68 kB
/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ import type { CompressedOperationsData, Compressor, CompressionInput, DecompressionInput } from '../compressor.js'; /** * * Compresses and decompresses multiple operations into the one buffer. */ export declare abstract class ActionCompressor { constructor(id: number, context: Compressor); /** * Combines and compress operations from the list. * Operations are consumed as long as match this compressor. * * @param result Object to which compression result should be added. * @param input Input data to compress. The action compressor will try to compress one or multiple operations starting from * `input.index`. After compression, `input.index` will be incremented by the number of operations compressed by the compressor. * @returns `true` when operation is consumed `false` otherwise. */ compress(result: CompressedOperationsData, input: CompressionInput): boolean; /** * Decompress and split compressed operations. Decompressed operations are consumed (removed from the input data). * * @param result Decompressed operations in JSON format. * @param input Input data to be decompressed. */ decompress(result: Array<any>, input: DecompressionInput): void; /** * Compresses single operation using a proper compressor. * * @param operation Operation in JSON format. * @returns Operation JSON compressed to the binary format. */ protected abstract _compressSingleOperation(operation: any): Uint8Array; /** * Decompresses combined operation using a proper compressor. * * @param input Input data to decompress. * @returns Decompressed operation in JSON format. */ protected abstract _decompressSingleOperation(input: DecompressionInput): any; /** * Combine next operation into the combined one. * * @param nextOperation Operation to combine in JSON format. * @param combined Combined operation in JSON format. * @returns Combined operation in JSON format. */ protected abstract _combineNext(nextOperation: any, combined: any): any; /** * Split operation from combined one. * * @param combined Combined operation in JSON format. * @returns Split operation in JSON format. */ protected abstract _splitCurrent(combined: any): any; /** * Checks if two operations can be combined. */ protected abstract _compareOperations(opA: any, opB: any): boolean; }