UNPKG

@y/y

Version:

Shared Editing Library

99 lines • 3.87 kB
export const attributionJsonSchema: s.Schema<{ insert?: string[] | undefined; insertedAt?: number | undefined; delete?: string[] | undefined; deletedAt?: number | undefined; format?: { [x: string]: string[]; } | undefined; formatAt?: number | undefined; }>; /** * @todo rename this to `insertBy`, `insertAt`, .. * * @typedef {s.Unwrap<typeof attributionJsonSchema>} Attribution */ /** * @template T */ export class AttributedContent<T> { /** * @param {AbstractContent} content * @param {number} clock * @param {boolean} deleted * @param {Array<ContentAttribute<T>> | null} attrs * @param {0|1|2} renderBehavior */ constructor(content: AbstractContent, clock: number, deleted: boolean, attrs: Array<ContentAttribute<T>> | null, renderBehavior: 0 | 1 | 2); content: import("../structs/Item.js").AbstractContent; clock: number; deleted: boolean; attrs: import("./ids.js").ContentAttribute<T>[] | null; render: boolean; } /** * Abstract class for associating Attributions to content / changes * * Should fire an event when the attributions changed _after_ the original change happens. This * Event will be used to update the attribution on the current content. * * @extends {ObservableV2<{change:(idset:IdSet,origin:any,local:boolean)=>void}>} */ export class AbstractAttributionManager extends ObservableV2<{ change: (idset: IdSet, origin: any, local: boolean) => void; }> { constructor(); /** * @param {Array<AttributedContent<any>>} _contents - where to write the result * @param {number} _client * @param {number} _clock * @param {boolean} _deleted * @param {AbstractContent} _content * @param {0|1|2} _shouldRender - 0: if undeleted or attributed, render as a retain operation. 1: render only if undeleted or attributed. 2: render as insert operation (if unattributed and deleted, render as delete). */ readContent(_contents: Array<AttributedContent<any>>, _client: number, _clock: number, _deleted: boolean, _content: AbstractContent, _shouldRender: 0 | 1 | 2): void; /** * Calculate the length of the attributed content. This is used by iterators that walk through the * content. * * If the content is not countable, it should return 0. * * @param {Item} _item * @return {number} */ contentLength(_item: Item): number; $type: s.Schema<AbstractAttributionManager>; } export const $attributionManager: s.Schema<AbstractAttributionManager>; /** * Abstract class for associating Attributions to content / changes * * @implements AbstractAttributionManager * * @extends {ObservableV2<{change:(idset:IdSet,origin:any,local:boolean)=>void}>} */ export class NoAttributionsManager extends ObservableV2<{ change: (idset: IdSet, origin: any, local: boolean) => void; }> implements AbstractAttributionManager { constructor(); get $type(): s.Schema<AbstractAttributionManager>; /** * @param {Array<AttributedContent<any>>} contents - where to write the result * @param {number} _client * @param {number} clock * @param {boolean} deleted * @param {AbstractContent} content * @param {0|1|2} shouldRender - whether this should render or just result in a `retain` operation */ readContent(contents: Array<AttributedContent<any>>, _client: number, clock: number, deleted: boolean, content: AbstractContent, shouldRender: 0 | 1 | 2): void; /** * @param {Item} item * @return {number} */ contentLength(item: Item): number; } export const noAttributionsManager: NoAttributionsManager; export type Attribution = s.Unwrap<typeof attributionJsonSchema>; import * as s from 'lib0/schema'; import { ObservableV2 } from 'lib0/observable'; //# sourceMappingURL=attribution-manager-helpers.d.ts.map