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

prosemirror-highlight

Package Overview
Dependencies
Maintainers
1
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.2.0 to 0.3.0

dist/chunk-ZZGBRRBM.js

46

dist/lowlight.js

@@ -0,3 +1,7 @@

import {
fillFromRoot
} from "./chunk-ZZGBRRBM.js";
// src/lowlight.ts
import { Decoration } from "prosemirror-view";
import "prosemirror-view";
function createParser(lowlight) {

@@ -12,44 +16,4 @@ return function highlighter({ content, language, pos }) {

}
function fillFromRoot(decorations, node, from) {
for (const child of node.children) {
from = fillFromRootContent(decorations, child, from);
}
}
function fillFromRootContent(decorations, node, from) {
if (node.type === "element") {
const to = from + getElementSize(node);
const { className, ...rest } = node.properties;
decorations.push(
Decoration.inline(from, to, {
class: className ? Array.isArray(className) ? className.join(" ") : String(className) : void 0,
...rest,
nodeName: node.tagName
})
);
return to;
} else if (node.type === "text") {
return from + node.value.length;
} else {
return from;
}
}
function getElementSize(node) {
let size = 0;
for (const child of node.children) {
size += getElementContentSize(child);
}
return size;
}
function getElementContentSize(node) {
switch (node.type) {
case "element":
return getElementSize(node);
case "text":
return node.value.length;
default:
return 0;
}
}
export {
createParser
};
{
"name": "prosemirror-highlight",
"type": "module",
"version": "0.2.0",
"version": "0.3.0",
"packageManager": "pnpm@8.10.0",

@@ -16,3 +16,12 @@ "description": "A ProseMirror plugin to highlight code blocks",

"bugs": "https://github.com/ocavue/prosemirror-highlight/issues",
"keywords": [],
"keywords": [
"prosemirror",
"editor",
"highlight.js",
"shiki",
"shikiji",
"refractor",
"lowlight",
"prism"
],
"sideEffects": false,

@@ -29,2 +38,5 @@ "main": "./src/index.ts",

},
"./refractor": {
"default": "./src/refractor.ts"
},
"./shiki": {

@@ -58,2 +70,3 @@ "default": "./src/shiki.ts"

"prosemirror-view": "^1.32.4",
"refractor": "^4.8.1",
"shiki": "^0.14.6",

@@ -84,2 +97,5 @@ "shikiji": "^0.8.0"

},
"refractor": {
"optional": true
},
"shiki": {

@@ -108,2 +124,3 @@ "optional": true

"prosemirror-view": "^1.32.4",
"refractor": "^4.8.1",
"shiki": "^0.14.6",

@@ -129,2 +146,6 @@ "shikiji": "^0.8.0",

},
"./refractor": {
"types": "./dist/refractor.d.ts",
"default": "./dist/refractor.js"
},
"./shiki": {

@@ -131,0 +152,0 @@ "types": "./dist/shiki.d.ts",

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

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

@@ -59,2 +59,14 @@ ## Usage

### With [refractor] (based on [Prism])
```ts
import { refractor } from 'refractor'
import { createHighlightPlugin } from 'prosemirror-highlight'
import { createParser } from 'prosemirror-highlight/refractor'
const parser = createParser(refractor)
export const refractorPlugin = createHighlightPlugin({ parser })
```
## Online demo

@@ -78,1 +90,3 @@

[Shikiji]: https://github.com/antfu/shikiji
[refractor]: https://github.com/wooorm/refractor
[Prism]: https://github.com/PrismJS/prism
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