Skip to main content

extension-yjs

package @remirror/extension-yjs

class YjsExtension

The YJS extension is the recommended extension for creating a collaborative editor.

Signature:

export declare class YjsExtension extends PlainExtension<YjsOptions> 

Extends: PlainExtension<YjsOptions>

(Some inherited members may not be shown because they are not represented in the documentation.)

property name

Signature:

get name(): "yjs";

property provider

The provider that is being used for the editor.

Signature:

get provider(): YjsRealtimeProvider;

method createExternalPlugins

Create the yjs plugins.

Signature:

createExternalPlugins(): ProsemirrorPlugin[];

Returns:

ProsemirrorPlugin[]

method getBinding

Signature:

getBinding(): {
mapping: Map<any, any>;
} | undefined;

Returns:

{ mapping: Map<any, any>; } | undefined

method onDestroy

Remove the provider from the manager.

Signature:

onDestroy(): void;

Returns:

void

method onSetOptions

This managers the updates of the collaboration provider.

Signature:

onSetOptions(props: OnSetOptionsProps<YjsOptions>): void;

Parameters:

ParameterTypeDescription
propsOnSetOptionsProps<YjsOptions>

Returns:

void

method redoShortcut

Handle the redo keybinding for the editor.

Signature:

redoShortcut(props: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
propsKeyBindingProps

Returns:

boolean

method undoShortcut

Handle the undo keybinding.

Signature:

undoShortcut(props: KeyBindingProps): boolean;

Parameters:

ParameterTypeDescription
propsKeyBindingProps

Returns:

boolean

method yRedo

Redo the last transaction undone with a previous yUndo command.

This command does **not** support chaining. This command is a no-op and always returns false when the disableUndo option is set.

Signature:

yRedo(): NonChainableCommandFunction;

Returns:

NonChainableCommandFunction

method yUndo

Undo that last Yjs transaction(s)

This command does **not** support chaining. This command is a no-op and always returns false when the disableUndo option is set.

Signature:

yUndo(): NonChainableCommandFunction;

Returns:

NonChainableCommandFunction

function defaultDestroyProvider()

The default destroy provider method.

Signature:

export declare function defaultDestroyProvider(provider: YjsRealtimeProvider): void;

Parameters:

ParameterTypeDescription
providerYjsRealtimeProvider

Returns:

void

interface YjsOptions

Signature:

export interface YjsOptions<Provider extends YjsRealtimeProvider = YjsRealtimeProvider> 

property cursorBuilder

Take the user data and transform it into a html element which is used for the cursor. This is passed into the cursor builder.

See https://github.com/yjs/y-prosemirror\#remote-cursors

Signature:

cursorBuilder?: (user: Shape) => HTMLElement;

property cursorStateField

By default all editor bindings use the awareness 'cursor' field to propagate cursor information.

Signature:

cursorStateField?: string;

property destroyProvider

Remove the active provider. This should only be set at initial construction of the editor.

Signature:

destroyProvider?: (provider: Provider) => void;

property disableUndo

Signature:

disableUndo?: Static<boolean>;

property getProvider

Get the provider for this extension.

Signature:

getProvider: Provider | (() => Provider);

property getSelection

Get the current editor selection.

Signature:

getSelection?: (state: EditorState) => Selection;

property protectedNodes

Names of nodes in the editor which should be protected.

Signature:

protectedNodes?: Static<Set<string>>;

property selectionBuilder

Generator for the selection attributes

Signature:

selectionBuilder?: (user: Shape) => DecorationAttrs;

property syncPluginOptions

The options which are passed through to the Yjs sync plugin.

Signature:

syncPluginOptions?: AcceptUndefined<YSyncOpts>;

property trackedOrigins

Signature:

trackedOrigins?: Static<any[]>;