Declare lowlight as a peerDependency (#2625)
Declare lowlight as a peerDependency to delegate the control of which version of lowlight is used to the client application Co-authored-by: Enrique Alcantara <ealcantara@gitlab.com>
This commit is contained in:
committed by
GitHub
parent
fd593bb93e
commit
39f5e4c31e
@@ -65,7 +65,15 @@ function getDecorations({
|
||||
return DecorationSet.create(doc, decorations)
|
||||
}
|
||||
|
||||
function isFunction(param: Function) {
|
||||
return typeof param === 'function'
|
||||
}
|
||||
|
||||
export function LowlightPlugin({ name, lowlight, defaultLanguage }: { name: string, lowlight: any, defaultLanguage: string | null | undefined }) {
|
||||
if (!['highlight', 'highlightAuto', 'listLanguages'].every(api => isFunction(lowlight[api]))) {
|
||||
throw Error('You should provide an instance of lowlight to use the code-block-lowlight extension')
|
||||
}
|
||||
|
||||
return new Plugin({
|
||||
key: new PluginKey('lowlight'),
|
||||
|
||||
|
||||
Reference in New Issue
Block a user