(basePlugin: T, ...sourcePlugins: any[])
| 3 | import type { SlatePlugin } from '../../lib'; |
| 4 | |
| 5 | export function mergePlugins<T>(basePlugin: T, ...sourcePlugins: any[]): T { |
| 6 | return mergeWith( |
| 7 | {}, |
| 8 | basePlugin, |
| 9 | ...sourcePlugins, |
| 10 | (objValue: unknown, srcValue: unknown, key: keyof SlatePlugin) => { |
| 11 | // Overwrite array (including plugins) without cloning |
| 12 | if (Array.isArray(srcValue)) { |
| 13 | return srcValue; |
| 14 | } |
| 15 | // Shallow merge options |
| 16 | if (key === 'options') { |
| 17 | return { ...(objValue as any), ...(srcValue as any) }; |
| 18 | } |
| 19 | } |
| 20 | ); |
| 21 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…