Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prosemirror-highlight

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prosemirror-highlight - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

dist/types-D9kxOI8-.d.ts

2

dist/index.d.ts
import { Node } from 'prosemirror-model';
import { Transaction, Plugin } from 'prosemirror-state';
import { Decoration, DecorationSet } from 'prosemirror-view';
import { P as Parser, L as LanguageExtractor } from './types-hA0ujWQ1.js';
import { P as Parser, L as LanguageExtractor } from './types-D9kxOI8-.js';

@@ -6,0 +6,0 @@ /**

import { Root } from 'hast';
import { P as Parser } from './types-hA0ujWQ1.js';
import { P as Parser } from './types-D9kxOI8-.js';
import 'prosemirror-model';

@@ -4,0 +4,0 @@ import 'prosemirror-view';

import { Refractor } from 'refractor/lib/core';
import { P as Parser } from './types-hA0ujWQ1.js';
import { P as Parser } from './types-D9kxOI8-.js';
import 'prosemirror-model';

@@ -4,0 +4,0 @@ import 'prosemirror-view';

import { Highlighter } from 'shiki';
import { P as Parser } from './types-hA0ujWQ1.js';
import { P as Parser } from './types-D9kxOI8-.js';
import 'prosemirror-model';

@@ -4,0 +4,0 @@ import 'prosemirror-view';

@@ -1,2 +0,2 @@

import { P as Parser } from './types-hA0ujWQ1.js';
import { P as Parser } from './types-D9kxOI8-.js';
import 'prosemirror-model';

@@ -3,0 +3,0 @@ import 'prosemirror-view';

{
"name": "prosemirror-highlight",
"type": "module",
"version": "0.6.0",
"packageManager": "pnpm@8.13.1",
"version": "0.7.0",
"description": "A ProseMirror plugin to highlight code blocks",

@@ -21,3 +20,2 @@ "author": "ocavue <ocavue@gmail.com>",

"shiki",
"shikiji",
"refractor",

@@ -48,6 +46,2 @@ "lowlight",

},
"./shikiji": {
"types": "./dist/shikiji.d.ts",
"default": "./dist/shikiji.js"
},
"./sugar-high": {

@@ -70,4 +64,3 @@ "types": "./dist/sugar-high.d.ts",

"refractor": "^4.8.1",
"shiki": "^1.0.0",
"shikiji": "^0.8.0 || ^0.9.0 || ^0.10.0",
"shiki": "^1.9.0",
"sugar-high": "^0.6.1"

@@ -103,5 +96,2 @@ },

},
"shikiji": {
"optional": true
},
"sugar-high": {

@@ -113,24 +103,23 @@ "optional": true

"@antfu/ni": "^0.21.12",
"@ocavue/eslint-config": "^1.4.0",
"@types/hast": "^3.0.3",
"@types/node": "^20.10.6",
"eslint": "^8.56.0",
"@ocavue/eslint-config": "^1.6.0",
"@types/hast": "^3.0.4",
"@types/node": "^20.14.7",
"eslint": "^8.57.0",
"highlight.js": "^11.9.0",
"jsdom": "^24.0.0",
"jsdom": "^24.1.0",
"lowlight": "^3.1.0",
"prettier": "^3.1.1",
"prettier": "^3.3.2",
"prosemirror-example-setup": "^1.2.2",
"prosemirror-model": "^1.19.4",
"prosemirror-model": "^1.21.1",
"prosemirror-schema-basic": "^1.2.2",
"prosemirror-state": "^1.4.3",
"prosemirror-transform": "^1.8.0",
"prosemirror-view": "^1.32.7",
"prosemirror-transform": "^1.9.0",
"prosemirror-view": "^1.33.8",
"refractor": "^4.8.1",
"shiki": "^1.0.0",
"shikiji": "^0.10.2",
"sugar-high": "^0.6.1",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vitest": "^1.1.1"
"shiki": "^1.9.0",
"sugar-high": "^0.7.0",
"tsup": "^8.1.0",
"typescript": "^5.5.2",
"vite": "^5.3.1",
"vitest": "^1.6.0"
},

@@ -146,2 +135,3 @@ "renovate": {

"build": "tsup",
"build:playground": "vite build",
"lint": "eslint .",

@@ -148,0 +138,0 @@ "fix": "eslint --fix . && prettier --write .",

@@ -5,3 +5,3 @@ # prosemirror-highlight

Highlight your code blocks in [ProseMirror], with any syntax highlighter you like!
Highlight your [ProseMirror] code blocks with any syntax highlighter you like!

@@ -16,3 +16,3 @@ ## Usage

```ts
import { getHighlighter } from 'shiki'
import { getSingletonHighlighter } from 'shiki'

@@ -22,3 +22,3 @@ import { createHighlightPlugin } from 'prosemirror-highlight'

const highlighter = await getHighlighter({
const highlighter = await getSingletonHighlighter({
themes: ['github-light'],

@@ -37,3 +37,7 @@ langs: ['javascript', 'typescript', 'python'],

```ts
import { getHighlighter, type Highlighter, type BuiltinLanguage } from 'shiki'
import {
getSingletonHighlighter,
type BuiltinLanguage,
type Highlighter,
} from 'shiki'

@@ -43,6 +47,4 @@ import { createHighlightPlugin } from 'prosemirror-highlight'

let highlighterPromise: Promise<void> | undefined
let highlighter: Highlighter | undefined
let parser: Parser | undefined
const loadedLanguages = new Set<string>()

@@ -57,4 +59,4 @@ /**

const lazyParser: Parser = (options) => {
if (!highlighterPromise) {
highlighterPromise = getHighlighter({
if (!highlighter) {
return getSingletonHighlighter({
themes: ['github-light'],

@@ -65,16 +67,9 @@ langs: [],

})
return highlighterPromise
}
if (!highlighter) {
return highlighterPromise
const language = options.language as BuiltinLanguage
if (language && !highlighter.getLoadedLanguages().includes(language)) {
return highlighter.loadLanguage(language)
}
const language = options.language
if (language && !loadedLanguages.has(language)) {
return highlighter.loadLanguage(language as BuiltinLanguage).then(() => {
loadedLanguages.add(language)
})
}
if (!parser) {

@@ -92,78 +87,2 @@ parser = createParser(highlighter)

### With [Shikiji]
<details>
<summary>Static loading of a fixed set of languages</summary>
```ts
import { getHighlighter } from 'shikiji'
import { createHighlightPlugin } from 'prosemirror-highlight'
import { createParser } from 'prosemirror-highlight/shikiji'
const highlighter = await getHighlighter({
themes: ['vitesse-light'],
langs: ['javascript', 'typescript', 'python'],
})
const parser = createParser(highlighter)
export const shikijiPlugin = createHighlightPlugin({ parser })
```
</details>
<details>
<summary>Dynamic loading of arbitrary languages</summary>
```ts
import { getHighlighter, type Highlighter, type BuiltinLanguage } from 'shikiji'
import { createHighlightPlugin, type Parser } from 'prosemirror-highlight'
import { createParser } from 'prosemirror-highlight/shikiji'
let highlighterPromise: Promise<void> | undefined
let highlighter: Highlighter | undefined
let parser: Parser | undefined
const loadedLanguages = new Set<string>()
/**
* Lazy load highlighter and highlighter languages.
*
* When the highlighter or the required language is not loaded, it returns a
* promise that resolves when the highlighter or the language is loaded.
* Otherwise, it returns an array of decorations.
*/
const lazyParser: Parser = (options) => {
if (!highlighterPromise) {
highlighterPromise = getHighlighter({
themes: ['vitesse-light'],
langs: [],
}).then((h) => {
highlighter = h
})
return highlighterPromise
}
if (!highlighter) {
return highlighterPromise
}
const language = options.language
if (language && !loadedLanguages.has(language)) {
return highlighter.loadLanguage(language as BuiltinLanguage).then(() => {
loadedLanguages.add(language)
})
}
if (!parser) {
parser = createParser(highlighter)
}
return parser(options)
}
export const shikijiLazyPlugin = createHighlightPlugin({ parser: lazyParser })
```
</details>
### With [lowlight] (based on [Highlight.js])

@@ -252,5 +171,4 @@

[Shiki]: https://github.com/shikijs/shiki
[Shikiji]: https://github.com/antfu/shikiji
[refractor]: https://github.com/wooorm/refractor
[Prism]: https://github.com/PrismJS/prism
[Sugar high]: https://github.com/huozhi/sugar-high
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc