prosemirror-highlight 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,7 +1,4 @@
1
1
  // src/cache.ts
2
- import "prosemirror-model";
3
- import "prosemirror-state";
4
- import "prosemirror-view";
5
2
  var DecorationCache = class _DecorationCache {
6
3
  constructor(cache) {
7
4
  this.cache = new Map(cache);
@@ -75,7 +72,6 @@ var DecorationCache = class _DecorationCache {
75
72
  };
76
73
 
77
74
  // src/plugin.ts
78
- import "prosemirror-model";
79
75
  import { Plugin, PluginKey } from "prosemirror-state";
80
76
  import { DecorationSet } from "prosemirror-view";
81
77
  function createHighlightPlugin({
package/dist/lowlight.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  } from "./chunk-ZZGBRRBM.js";
4
4
 
5
5
  // src/lowlight.ts
6
- import "prosemirror-view";
7
6
  function createParser(lowlight) {
8
7
  return function highlighter({ content, language, pos }) {
9
8
  const root = language ? lowlight.highlight(language, content) : lowlight.highlightAuto(content);
package/dist/refractor.js CHANGED
@@ -3,7 +3,6 @@ import {
3
3
  } from "./chunk-ZZGBRRBM.js";
4
4
 
5
5
  // src/refractor.ts
6
- import "prosemirror-view";
7
6
  function createParser(refractor) {
8
7
  return function highlighter({ content, language, pos }) {
9
8
  const root = refractor.highlight(content, language || "");
package/dist/shiki.d.ts CHANGED
@@ -1,10 +1,8 @@
1
- import { Highlighter, BundledTheme } from 'shiki';
1
+ import { Highlighter, CodeToTokensOptions, BundledLanguage, BundledTheme } from 'shiki';
2
2
  import { P as Parser } from './types-D9kxOI8-.js';
3
3
  import 'prosemirror-model';
4
4
  import 'prosemirror-view';
5
5
 
6
- declare function createParser(highlighter: Highlighter, options?: {
7
- theme?: BundledTheme;
8
- }): Parser;
6
+ declare function createParser(highlighter: Highlighter, options?: CodeToTokensOptions<BundledLanguage, BundledTheme>): Parser;
9
7
 
10
8
  export { Parser, createParser };
package/dist/shiki.js CHANGED
@@ -1,18 +1,25 @@
1
1
  // src/shiki.ts
2
2
  import { Decoration } from "prosemirror-view";
3
+ import "shiki";
3
4
  function createParser(highlighter, options) {
4
5
  return function parser({ content, language, pos }) {
6
+ var _a;
5
7
  const decorations = [];
6
- const tokens = highlighter.codeToTokensBase(content, {
8
+ const { tokens } = highlighter.codeToTokens(content, {
7
9
  lang: language,
8
- theme: options == null ? void 0 : options.theme
10
+ // Use provided options for themes or just use first loaded theme
11
+ ...options != null ? options : {
12
+ theme: highlighter.getLoadedThemes()[0]
13
+ }
9
14
  });
10
15
  let from = pos + 1;
11
16
  for (const line of tokens) {
12
17
  for (const token of line) {
13
18
  const to = from + token.content.length;
14
19
  const decoration = Decoration.inline(from, to, {
15
- style: `color: ${token.color}`
20
+ // When using `options.themes` the `htmlStyle` field will be set, otherwise `color` will be set
21
+ style: (_a = token.htmlStyle) != null ? _a : `color: ${token.color}`,
22
+ class: "shiki"
16
23
  });
17
24
  decorations.push(decoration);
18
25
  from = to;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prosemirror-highlight",
3
3
  "type": "module",
4
- "version": "0.8.0",
4
+ "version": "0.9.0",
5
5
  "description": "A ProseMirror plugin to highlight code blocks",
6
6
  "author": "ocavue <ocavue@gmail.com>",
7
7
  "license": "MIT",
@@ -95,28 +95,28 @@
95
95
  }
96
96
  },
97
97
  "devDependencies": {
98
- "@antfu/ni": "^0.21.12",
99
- "@ocavue/eslint-config": "^1.6.0",
98
+ "@antfu/ni": "^0.23.0",
99
+ "@ocavue/eslint-config": "^2.6.0",
100
100
  "@types/hast": "^3.0.4",
101
- "@types/node": "^20.14.7",
102
- "eslint": "^8.57.0",
103
- "highlight.js": "^11.9.0",
104
- "jsdom": "^24.1.0",
101
+ "@types/node": "^20.16.2",
102
+ "eslint": "^9.9.1",
103
+ "highlight.js": "^11.10.0",
104
+ "jsdom": "^24.1.3",
105
105
  "lowlight": "^3.1.0",
106
- "prettier": "^3.3.2",
107
- "prosemirror-example-setup": "^1.2.2",
108
- "prosemirror-model": "^1.21.1",
109
- "prosemirror-schema-basic": "^1.2.2",
106
+ "prettier": "^3.3.3",
107
+ "prosemirror-example-setup": "^1.2.3",
108
+ "prosemirror-model": "^1.22.3",
109
+ "prosemirror-schema-basic": "^1.2.3",
110
110
  "prosemirror-state": "^1.4.3",
111
- "prosemirror-transform": "^1.9.0",
112
- "prosemirror-view": "^1.33.8",
111
+ "prosemirror-transform": "^1.10.0",
112
+ "prosemirror-view": "^1.34.1",
113
113
  "refractor": "^4.8.1",
114
- "shiki": "^1.9.0",
114
+ "shiki": "^1.15.2",
115
115
  "sugar-high": "^0.7.0",
116
- "tsup": "^8.1.0",
117
- "typescript": "^5.5.2",
118
- "vite": "^5.3.1",
119
- "vitest": "^1.6.0"
116
+ "tsup": "^8.2.4",
117
+ "typescript": "^5.5.4",
118
+ "vite": "^5.4.2",
119
+ "vitest": "^2.0.5"
120
120
  },
121
121
  "renovate": {
122
122
  "dependencyDashboard": true,