@tiptap/extension-code-block-lowlight
Advanced tools
Comparing version 2.0.0-beta.3 to 2.0.0-beta.6
@@ -6,2 +6,21 @@ # Change Log | ||
# [2.0.0-beta.6](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.4...@tiptap/extension-code-block-lowlight@2.0.0-beta.6) (2021-04-14) | ||
**Note:** Version bump only for package @tiptap/extension-code-block-lowlight | ||
# [2.0.0-beta.4](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.3...@tiptap/extension-code-block-lowlight@2.0.0-beta.4) (2021-04-14) | ||
### Bug Fixes | ||
* fix lowlight decorations for vue 3 ([daa5dc0](https://github.com/ueberdosis/tiptap-next/commit/daa5dc0fb1ec2db6889565fc9c091f3dbdbbda6d)) | ||
# [2.0.0-beta.3](https://github.com/ueberdosis/tiptap-next/compare/@tiptap/extension-code-block-lowlight@2.0.0-beta.2...@tiptap/extension-code-block-lowlight@2.0.0-beta.3) (2021-04-12) | ||
@@ -8,0 +27,0 @@ |
@@ -1,1 +0,5 @@ | ||
export declare const CodeBlockLowlight: import("@tiptap/core").Node<import("@tiptap/extension-code-block").CodeBlockOptions>; | ||
import { CodeBlockOptions } from '@tiptap/extension-code-block'; | ||
export interface CodeBlockLowlightOptions extends CodeBlockOptions { | ||
lowlight: any; | ||
} | ||
export declare const CodeBlockLowlight: import("@tiptap/core").Node<CodeBlockLowlightOptions>; |
import { Plugin } from 'prosemirror-state'; | ||
export declare function LowlightPlugin({ name }: { | ||
export declare function LowlightPlugin({ name, lowlight }: { | ||
name: string; | ||
lowlight: any; | ||
}): Plugin<any, any>; |
{ | ||
"name": "@tiptap/extension-code-block-lowlight", | ||
"description": "code block extension for tiptap", | ||
"version": "2.0.0-beta.3", | ||
"version": "2.0.0-beta.6", | ||
"homepage": "https://tiptap.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "28d30a10341cb5cd10626b1b8c884c20787b5d72" | ||
"gitHead": "6e8970566b356a5cfaa225fea621d50c419d73f7" | ||
} |
@@ -1,11 +0,25 @@ | ||
import CodeBlock from '@tiptap/extension-code-block' | ||
import lowlight from 'lowlight/lib/core' | ||
import CodeBlock, { CodeBlockOptions } from '@tiptap/extension-code-block' | ||
import { LowlightPlugin } from './lowlight-plugin' | ||
export const CodeBlockLowlight = CodeBlock.extend({ | ||
export interface CodeBlockLowlightOptions extends CodeBlockOptions { | ||
lowlight: any, | ||
} | ||
export const CodeBlockLowlight = CodeBlock.extend<CodeBlockLowlightOptions>({ | ||
defaultOptions: { | ||
...CodeBlock.config.defaultOptions, | ||
lowlight, | ||
}, | ||
addProseMirrorPlugins() { | ||
return [ | ||
...this.parentConfig.addProseMirrorPlugins?.() || [], | ||
LowlightPlugin({ name: 'codeBlock' }), | ||
// disable for now, see: https://github.com/ueberdosis/tiptap-next/issues/259#issuecomment-817954835 | ||
// ...this.parentConfig.addProseMirrorPlugins?.() || [], | ||
LowlightPlugin({ | ||
name: 'codeBlock', | ||
lowlight: this.options.lowlight, | ||
}), | ||
] | ||
}, | ||
}) |
@@ -5,3 +5,2 @@ import { Plugin, PluginKey } from 'prosemirror-state' | ||
import { findChildren } from '@tiptap/core' | ||
import lowlight from 'lowlight/lib/core' | ||
@@ -30,3 +29,3 @@ function parseNodes(nodes: any[], className: string[] = []): { text: string, classes: string[] }[] { | ||
function getDecorations({ doc, name }: { doc: ProsemirrorNode, name: string}) { | ||
function getDecorations({ doc, name, lowlight }: { doc: ProsemirrorNode, name: string, lowlight: any }) { | ||
const decorations: Decoration[] = [] | ||
@@ -63,3 +62,3 @@ | ||
export function LowlightPlugin({ name }: { name: string }) { | ||
export function LowlightPlugin({ name, lowlight }: { name: string, lowlight: any }) { | ||
return new Plugin({ | ||
@@ -69,3 +68,3 @@ key: new PluginKey('lowlight'), | ||
state: { | ||
init: (_, { doc }) => getDecorations({ doc, name }), | ||
init: (_, { doc }) => getDecorations({ doc, name, lowlight }), | ||
apply: (transaction, decorationSet, oldState, newState) => { | ||
@@ -102,3 +101,3 @@ const oldNodeName = oldState.selection.$head.parent.type.name | ||
) { | ||
return getDecorations({ doc: transaction.doc, name }) | ||
return getDecorations({ doc: transaction.doc, name, lowlight }) | ||
} | ||
@@ -105,0 +104,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
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1773108
8741