mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
Feature/y sync options: allow passing ySyncOptions to extension-collaboration (#4976)
* extension-collaboration: allow passing ySyncOptions * fixes import
This commit is contained in:
parent
a06ec40138
commit
e73073c020
@ -9,6 +9,8 @@ import {
|
||||
} from 'y-prosemirror'
|
||||
import { UndoManager } from 'yjs'
|
||||
|
||||
type YSyncOpts = Parameters<typeof ySyncPlugin>[1]
|
||||
|
||||
declare module '@tiptap/core' {
|
||||
interface Commands<ReturnType> {
|
||||
collaboration: {
|
||||
@ -41,6 +43,8 @@ export interface CollaborationOptions {
|
||||
* Fired when the content from Yjs is initially rendered to Tiptap.
|
||||
*/
|
||||
onFirstRender?: () => void,
|
||||
|
||||
ySyncOptions?: YSyncOpts
|
||||
}
|
||||
|
||||
export const Collaboration = Extension.create<CollaborationOptions>({
|
||||
@ -149,8 +153,11 @@ export const Collaboration = Extension.create<CollaborationOptions>({
|
||||
}
|
||||
}
|
||||
|
||||
const onFirstRender = this.options.onFirstRender
|
||||
const ySyncPluginOptions = onFirstRender ? { onFirstRender } : {}
|
||||
const ySyncPluginOptions: YSyncOpts = {
|
||||
...(this.options.ySyncOptions ? { ...this.options.ySyncOptions } : {}),
|
||||
...(this.options.onFirstRender ? { ...this.options.onFirstRender } : {}),
|
||||
}
|
||||
|
||||
const ySyncPluginInstance = ySyncPlugin(fragment, ySyncPluginOptions)
|
||||
|
||||
return [ySyncPluginInstance, yUndoPluginInstance]
|
||||
|
Loading…
Reference in New Issue
Block a user