@tiptap/extension-code-block-lowlight
Advanced tools
Comparing version 2.0.0-beta.50 to 2.0.0-beta.51
import { CodeBlockOptions } from '@tiptap/extension-code-block'; | ||
export interface CodeBlockLowlightOptions extends CodeBlockOptions { | ||
lowlight: any; | ||
defaultLanguage: string | null | undefined; | ||
} | ||
export declare const CodeBlockLowlight: import("@tiptap/core").Node<CodeBlockLowlightOptions, any>; |
import { Plugin } from 'prosemirror-state'; | ||
export declare function LowlightPlugin({ name, lowlight }: { | ||
export declare function LowlightPlugin({ name, lowlight, defaultLanguage }: { | ||
name: string; | ||
lowlight: any; | ||
defaultLanguage: string | null | undefined; | ||
}): Plugin<any, any>; |
{ | ||
"name": "@tiptap/extension-code-block-lowlight", | ||
"description": "code block extension for tiptap", | ||
"version": "2.0.0-beta.50", | ||
"version": "2.0.0-beta.51", | ||
"homepage": "https://tiptap.dev", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"prosemirror-state": "^1.3.4", | ||
"prosemirror-view": "^1.20.3" | ||
"prosemirror-view": "^1.21.0" | ||
}, | ||
@@ -40,3 +40,3 @@ "repository": { | ||
}, | ||
"gitHead": "31c23336d0e5d2be8b250530353531b8a241253c" | ||
"gitHead": "3c32e66c02efb30d7e083e06cdf81bceb3582a33" | ||
} |
@@ -7,2 +7,3 @@ import lowlight from 'lowlight/lib/core' | ||
lowlight: any, | ||
defaultLanguage: string | null | undefined, | ||
} | ||
@@ -15,2 +16,3 @@ | ||
lowlight, | ||
defaultLanguage: null, | ||
} | ||
@@ -25,2 +27,3 @@ }, | ||
lowlight: this.options.lowlight, | ||
defaultLanguage: this.options.defaultLanguage, | ||
}), | ||
@@ -27,0 +30,0 @@ ] |
@@ -33,3 +33,8 @@ import { Plugin, PluginKey } from 'prosemirror-state' | ||
function getDecorations({ doc, name, lowlight }: { doc: ProsemirrorNode, name: string, lowlight: any }) { | ||
function getDecorations({ | ||
doc, | ||
name, | ||
lowlight, | ||
defaultLanguage, | ||
}: { doc: ProsemirrorNode, name: string, lowlight: any, defaultLanguage: string | null | undefined }) { | ||
const decorations: Decoration[] = [] | ||
@@ -40,3 +45,4 @@ | ||
let from = block.pos + 1 | ||
const { language } = block.node.attrs | ||
const language = block.node.attrs.language || defaultLanguage | ||
console.log({ language, defaultLanguage }) | ||
const languages = lowlight.listLanguages() | ||
@@ -65,3 +71,3 @@ const nodes = language && languages.includes(language) | ||
export function LowlightPlugin({ name, lowlight }: { name: string, lowlight: any }) { | ||
export function LowlightPlugin({ name, lowlight, defaultLanguage }: { name: string, lowlight: any, defaultLanguage: string | null | undefined }) { | ||
return new Plugin({ | ||
@@ -71,3 +77,8 @@ key: new PluginKey('lowlight'), | ||
state: { | ||
init: (_, { doc }) => getDecorations({ doc, name, lowlight }), | ||
init: (_, { doc }) => getDecorations({ | ||
doc, | ||
name, | ||
lowlight, | ||
defaultLanguage, | ||
}), | ||
apply: (transaction, decorationSet, oldState, newState) => { | ||
@@ -104,3 +115,8 @@ const oldNodeName = oldState.selection.$head.parent.type.name | ||
) { | ||
return getDecorations({ doc: transaction.doc, name, lowlight }) | ||
return getDecorations({ | ||
doc: transaction.doc, | ||
name, | ||
lowlight, | ||
defaultLanguage, | ||
}) | ||
} | ||
@@ -107,0 +123,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
761118
8061
Updatedprosemirror-view@^1.21.0