@prosekit/extensions
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -11,2 +11,3 @@ import { CommandArgs } from '@prosekit/core'; | ||
import { Options } from 'tsup'; | ||
import { Parser } from 'prosemirror-highlight'; | ||
import { Plugin as Plugin_2 } from '@prosekit/pm/state'; | ||
@@ -17,3 +18,2 @@ import { PluginKey } from '@prosekit/pm/state'; | ||
import { UnwrapListOptions } from 'prosemirror-flat-list'; | ||
import { UserProjectConfigExport } from 'vitest/dist/config.js'; | ||
@@ -53,3 +53,7 @@ declare class AutocompleteRule { | ||
export declare const default_alias_1: UserProjectConfigExport; | ||
export declare const default_alias_1: { | ||
test: { | ||
environment: "jsdom"; | ||
}; | ||
}; | ||
@@ -113,3 +117,10 @@ export declare function defaultCanMatch({ state }: { | ||
export declare function defineCodeBlock(options?: { | ||
/** | ||
* @deprecated Use `highlight` instead. | ||
*/ | ||
hljs?: HLJSApi; | ||
/** | ||
* A parser for the `prosemirror-highlight` package to use for syntax highlighting. | ||
*/ | ||
parser?: HighlightParser; | ||
}): Extension< { | ||
@@ -128,3 +139,10 @@ NODES: "codeBlock"; | ||
export declare function defineCodeBlockHighlight(options: { | ||
export declare function defineCodeBlockHighlight({ parser }: { | ||
parser: Parser; | ||
}): Extension<ExtensionTyping<string, string, CommandArgs>>; | ||
/** | ||
* @deprecated | ||
*/ | ||
export declare function defineCodeBlockHighlightDeprecated(options: { | ||
hljs?: HLJSApi; | ||
@@ -384,2 +402,9 @@ }): Extension<ExtensionTyping<string, string, CommandArgs>>; | ||
/** | ||
* @public | ||
* | ||
* An alias for the `Parser` type from the `prosemirror-highlight` package. | ||
*/ | ||
export declare type HighlightParser = Parser; | ||
export declare interface ImageAttrs { | ||
@@ -386,0 +411,0 @@ src?: string | null; |
@@ -6,1 +6,2 @@ export { defineCodeBlockSpec } from './_tsup-dts-rollup'; | ||
export { CodeBlockAttrs_alias_1 as CodeBlockAttrs } from './_tsup-dts-rollup'; | ||
export { HighlightParser } from './_tsup-dts-rollup'; |
@@ -6,4 +6,4 @@ // src/code-block/index.ts | ||
defineNodeSpec, | ||
union, | ||
getNodeType | ||
getNodeType, | ||
union | ||
} from "@prosekit/core"; | ||
@@ -14,6 +14,15 @@ import { textblockTypeInputRule } from "@prosekit/pm/inputrules"; | ||
import { definePlugin } from "@prosekit/core"; | ||
import { createHighlightPlugin } from "prosemirror-highlight"; | ||
function defineCodeBlockHighlight({ parser }) { | ||
return definePlugin( | ||
createHighlightPlugin({ parser, nodeTypes: ["codeBlock"] }) | ||
); | ||
} | ||
// src/code-block/code-block-highlight-deprecated.ts | ||
import { definePlugin as definePlugin2 } from "@prosekit/core"; | ||
import { PluginKey, ProseMirrorPlugin } from "@prosekit/pm/state"; | ||
import { DecorationSet } from "@prosekit/pm/view"; | ||
import { getHighlightDecorations } from "prosemirror-highlightjs"; | ||
function defineCodeBlockHighlight(options) { | ||
function defineCodeBlockHighlightDeprecated(options) { | ||
const hljs = options.hljs; | ||
@@ -46,3 +55,3 @@ const plugin = new ProseMirrorPlugin({ | ||
}); | ||
return definePlugin(plugin); | ||
return definePlugin2(plugin); | ||
} | ||
@@ -78,2 +87,3 @@ var key = new PluginKey("prosekit-code-block-highlight"); | ||
"pre", | ||
// TODO: remove class 'hljs' | ||
{ "data-language": attrs.language, class: "hljs" }, | ||
@@ -110,8 +120,16 @@ ["code", 0] | ||
function defineCodeBlock(options) { | ||
return union([ | ||
const extensions = [ | ||
defineCodeBlockSpec(), | ||
defineCodeBlockInputRule(), | ||
defineCodeBlockHighlight({ hljs: options == null ? void 0 : options.hljs }), | ||
defineCodeBlockCommands() | ||
]); | ||
]; | ||
const parser = options == null ? void 0 : options.parser; | ||
if (parser) { | ||
extensions.push(defineCodeBlockHighlight({ parser })); | ||
} | ||
const hljs = options == null ? void 0 : options.hljs; | ||
if (hljs) { | ||
extensions.push(defineCodeBlockHighlightDeprecated({ hljs })); | ||
} | ||
return union(extensions); | ||
} | ||
@@ -118,0 +136,0 @@ export { |
{ | ||
"name": "@prosekit/extensions", | ||
"type": "module", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"private": false, | ||
@@ -128,2 +128,3 @@ "author": { | ||
"prosemirror-flat-list": "^0.4.5", | ||
"prosemirror-highlight": "^0.3.1", | ||
"prosemirror-highlightjs": "^0.9.1" | ||
@@ -134,4 +135,4 @@ }, | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.3.2", | ||
"vitest": "^0.34.6" | ||
"typescript": "^5.3.3", | ||
"vitest": "^1.0.2" | ||
}, | ||
@@ -138,0 +139,0 @@ "scripts": { |
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
55191
1673
6
+ Addedprosemirror-highlight@^0.3.1
+ Addedprosemirror-highlight@0.3.3(transitive)