prosemirror-highlight
Advanced tools
Comparing version 0.8.0 to 0.9.0
// src/cache.ts | ||
import "prosemirror-model"; | ||
import "prosemirror-state"; | ||
import "prosemirror-view"; | ||
var DecorationCache = class _DecorationCache { | ||
@@ -78,3 +75,2 @@ constructor(cache) { | ||
// src/plugin.ts | ||
import "prosemirror-model"; | ||
import { Plugin, PluginKey } from "prosemirror-state"; | ||
@@ -81,0 +77,0 @@ import { DecorationSet } from "prosemirror-view"; |
@@ -6,3 +6,2 @@ import { | ||
// src/lowlight.ts | ||
import "prosemirror-view"; | ||
function createParser(lowlight) { | ||
@@ -9,0 +8,0 @@ return function highlighter({ content, language, pos }) { |
@@ -6,3 +6,2 @@ import { | ||
// src/refractor.ts | ||
import "prosemirror-view"; | ||
function createParser(refractor) { | ||
@@ -9,0 +8,0 @@ return function highlighter({ content, language, pos }) { |
@@ -1,2 +0,2 @@ | ||
import { Highlighter, BundledTheme } from 'shiki'; | ||
import { Highlighter, CodeToTokensOptions, BundledLanguage, BundledTheme } from 'shiki'; | ||
import { P as Parser } from './types-D9kxOI8-.js'; | ||
@@ -6,6 +6,4 @@ import 'prosemirror-model'; | ||
declare function createParser(highlighter: Highlighter, options?: { | ||
theme?: BundledTheme; | ||
}): Parser; | ||
declare function createParser(highlighter: Highlighter, options?: CodeToTokensOptions<BundledLanguage, BundledTheme>): Parser; | ||
export { Parser, createParser }; |
// src/shiki.ts | ||
import { Decoration } from "prosemirror-view"; | ||
import "shiki"; | ||
function createParser(highlighter, options) { | ||
return function parser({ content, language, pos }) { | ||
var _a; | ||
const decorations = []; | ||
const tokens = highlighter.codeToTokensBase(content, { | ||
const { tokens } = highlighter.codeToTokens(content, { | ||
lang: language, | ||
theme: options == null ? void 0 : options.theme | ||
// Use provided options for themes or just use first loaded theme | ||
...options != null ? options : { | ||
theme: highlighter.getLoadedThemes()[0] | ||
} | ||
}); | ||
@@ -15,3 +20,5 @@ let from = pos + 1; | ||
const decoration = Decoration.inline(from, to, { | ||
style: `color: ${token.color}` | ||
// When using `options.themes` the `htmlStyle` field will be set, otherwise `color` will be set | ||
style: (_a = token.htmlStyle) != null ? _a : `color: ${token.color}`, | ||
class: "shiki" | ||
}); | ||
@@ -18,0 +25,0 @@ decorations.push(decoration); |
{ | ||
"name": "prosemirror-highlight", | ||
"type": "module", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"description": "A ProseMirror plugin to highlight code blocks", | ||
@@ -98,24 +98,24 @@ "author": "ocavue <ocavue@gmail.com>", | ||
"devDependencies": { | ||
"@antfu/ni": "^0.21.12", | ||
"@ocavue/eslint-config": "^1.6.0", | ||
"@antfu/ni": "^0.23.0", | ||
"@ocavue/eslint-config": "^2.6.0", | ||
"@types/hast": "^3.0.4", | ||
"@types/node": "^20.14.7", | ||
"eslint": "^8.57.0", | ||
"highlight.js": "^11.9.0", | ||
"jsdom": "^24.1.0", | ||
"@types/node": "^20.16.2", | ||
"eslint": "^9.9.1", | ||
"highlight.js": "^11.10.0", | ||
"jsdom": "^24.1.3", | ||
"lowlight": "^3.1.0", | ||
"prettier": "^3.3.2", | ||
"prosemirror-example-setup": "^1.2.2", | ||
"prosemirror-model": "^1.21.1", | ||
"prosemirror-schema-basic": "^1.2.2", | ||
"prettier": "^3.3.3", | ||
"prosemirror-example-setup": "^1.2.3", | ||
"prosemirror-model": "^1.22.3", | ||
"prosemirror-schema-basic": "^1.2.3", | ||
"prosemirror-state": "^1.4.3", | ||
"prosemirror-transform": "^1.9.0", | ||
"prosemirror-view": "^1.33.8", | ||
"prosemirror-transform": "^1.10.0", | ||
"prosemirror-view": "^1.34.1", | ||
"refractor": "^4.8.1", | ||
"shiki": "^1.9.0", | ||
"shiki": "^1.15.2", | ||
"sugar-high": "^0.7.0", | ||
"tsup": "^8.1.0", | ||
"typescript": "^5.5.2", | ||
"vite": "^5.3.1", | ||
"vitest": "^1.6.0" | ||
"tsup": "^8.2.4", | ||
"typescript": "^5.5.4", | ||
"vite": "^5.4.2", | ||
"vitest": "^2.0.5" | ||
}, | ||
@@ -122,0 +122,0 @@ "renovate": { |
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
23104
464