@remirror/extension-collaboration
Version:
Add collaboration to your remirror editor.
131 lines (121 loc) • 4.18 kB
TypeScript
import { CommandFunction } from '@remirror/core';
import { Handler } from '@remirror/core';
import { PlainExtension } from '@remirror/core';
import { ProsemirrorAttributes } from '@remirror/core';
import { ProsemirrorPlugin } from '@remirror/core';
import { Shape } from '@remirror/core';
import { StateUpdateLifecycleProps } from '@remirror/core';
import { Static } from '@remirror/core';
import { Step } from '@remirror/pm/transform';
import { Transaction } from '@remirror/core';
declare type CollaborationAttributes = ProsemirrorAttributes<{
/**
* The steps to confirm, combined with the clientID of the user who created the change
*/
steps: StepWithClientId[];
/**
* The version of the document that these steps were added to.
*/
version: number;
}>;
export { CollaborationAttributes }
export { CollaborationAttributes as CollaborationAttributes_alias_1 }
/**
* The collaboration extension adds collaborative functionality to your editor.
*
* Once a central server is created the collaboration extension is good.
*/
declare class CollaborationExtension extends PlainExtension<CollaborationOptions> {
get name(): "collaboration";
private _debounceGetSendableSteps?;
private get debounceGetSendableSteps();
/**
* Send a collaboration update.
*/
sendCollaborationUpdate(attributes: CollaborationAttributes): CommandFunction;
cancelSendableSteps(): CommandFunction;
flushSendableSteps(): CommandFunction;
createExternalPlugins(): ProsemirrorPlugin[];
onStateUpdate(props: StateUpdateLifecycleProps): void;
onDestroy(): void;
/**
* This passes the sendable steps into the `onSendableReceived` handler defined in the
* options when there is something to send.
*/
private getSendableSteps;
}
export { CollaborationExtension }
export { CollaborationExtension as CollaborationExtension_alias_1 }
declare interface CollaborationOptions {
/**
* The document version.
*
* @defaultValue 0
*/
version?: Static<number>;
/**
* The unique ID of the client connecting to the server.
*/
clientID: Static<number | string>;
/**
* The debounce time in milliseconds
*
* @defaultValue 250
*/
debounceMs?: Static<number>;
/**
* Called when an an editor transaction occurs and there are changes ready to
* be sent to the server.
*
* @remarks
*
* The callback will receive the `jsonSendable` which can be sent to the
* server as it is. If you need more control then the `sendable` property can
* be used to shape the data the way you require.
*
* Since this method is called for everyTransaction that updates the
* jsonSendable value it is automatically debounced for you.
*
* @param props - the sendable and jsonSendable properties which can be sent
* to your backend
*/
onSendableReceived: Handler<(props: OnSendableReceivedProps) => void>;
}
export { CollaborationOptions }
export { CollaborationOptions as CollaborationOptions_alias_1 }
declare interface JSONSendable extends Omit<Sendable, 'steps' | 'origins'> {
steps: Shape[];
}
export { JSONSendable }
export { JSONSendable as JSONSendable_alias_1 }
declare interface OnSendableReceivedProps {
/**
* The raw sendable generated by the prosemirror-collab library.
*/
sendable: Sendable;
/**
* A sendable which can be sent to a server
*/
jsonSendable: JSONSendable;
}
export { OnSendableReceivedProps }
export { OnSendableReceivedProps as OnSendableReceivedProps_alias_1 }
declare interface Sendable {
version: number;
steps: readonly Step[];
clientID: number | string;
origins: readonly Transaction[];
}
export { Sendable }
export { Sendable as Sendable_alias_1 }
export declare interface StepWithClientId extends Step {
clientID: number | string;
}
export { }
declare global {
namespace Remirror {
interface AllExtensions {
collaboration: CollaborationExtension;
}
}
}