You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
635 B
30 lines
635 B
import { ReactNode } from 'react'
|
|
|
|
import onChange from './onChange'
|
|
import renderEditor from './renderEditor'
|
|
|
|
import Connection from './Connection'
|
|
|
|
export interface PluginOptions {
|
|
url?: string
|
|
connectOpts?: SocketIOClient.ConnectOpts
|
|
preloader?: () => ReactNode
|
|
onConnect?: (connection: Connection) => void
|
|
onDisconnect?: (connection: Connection) => void
|
|
}
|
|
|
|
const defaultOpts = {
|
|
url: 'http://localhost:9000'
|
|
}
|
|
|
|
const plugin = (opts: PluginOptions = {}) => {
|
|
const options = { ...defaultOpts, ...opts }
|
|
|
|
return {
|
|
onChange: onChange(options),
|
|
renderEditor: renderEditor(options)
|
|
}
|
|
}
|
|
|
|
export default plugin
|