prosemirror-highlight 0.9.0 → 0.11.1

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/README.md CHANGED
@@ -103,7 +103,7 @@ export const lowlightPlugin = createHighlightPlugin({ parser })
103
103
  <summary>Static loading of all languages</summary>
104
104
 
105
105
  ```ts
106
- import { refractor } from 'refractor'
106
+ import { refractor } from 'refractor/lib/all'
107
107
 
108
108
  import { createHighlightPlugin } from 'prosemirror-highlight'
109
109
  import { createParser } from 'prosemirror-highlight/refractor'
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Node } from 'prosemirror-model';
2
2
  import { Transaction, Plugin } from 'prosemirror-state';
3
3
  import { Decoration, DecorationSet } from 'prosemirror-view';
4
- import { P as Parser, L as LanguageExtractor } from './types-D9kxOI8-.js';
4
+ import { P as Parser, L as LanguageExtractor } from './types-CwiCqY6X.js';
5
5
 
6
6
  /**
7
7
  * Represents a cache of doc positions to the node and decorations at that position
@@ -67,7 +67,7 @@ declare function createHighlightPlugin({ parser, nodeTypes, languageExtractor, }
67
67
  /**
68
68
  * An array containing all the node type name to target for highlighting.
69
69
  *
70
- * @default ['code_block']
70
+ * @default ['code_block', 'codeBlock']
71
71
  */
72
72
  nodeTypes?: string[];
73
73
  /**
package/dist/index.js CHANGED
@@ -76,7 +76,7 @@ import { Plugin, PluginKey } from "prosemirror-state";
76
76
  import { DecorationSet } from "prosemirror-view";
77
77
  function createHighlightPlugin({
78
78
  parser,
79
- nodeTypes = ["code_block"],
79
+ nodeTypes = ["code_block", "codeBlock"],
80
80
  languageExtractor = (node) => node.attrs.language
81
81
  }) {
82
82
  const key = new PluginKey();
@@ -1,5 +1,5 @@
1
1
  import { Root } from 'hast';
2
- import { P as Parser } from './types-D9kxOI8-.js';
2
+ import { P as Parser } from './types-CwiCqY6X.js';
3
3
  import 'prosemirror-model';
4
4
  import 'prosemirror-view';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { Refractor } from 'refractor/lib/core';
2
- import { P as Parser } from './types-D9kxOI8-.js';
2
+ import { P as Parser } from './types-CwiCqY6X.js';
3
3
  import 'prosemirror-model';
4
4
  import 'prosemirror-view';
5
5
 
package/dist/shiki.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Highlighter, CodeToTokensOptions, BundledLanguage, BundledTheme } from 'shiki';
2
- import { P as Parser } from './types-D9kxOI8-.js';
2
+ import { P as Parser } from './types-CwiCqY6X.js';
3
3
  import 'prosemirror-model';
4
4
  import 'prosemirror-view';
5
5
 
package/dist/shiki.js CHANGED
@@ -18,7 +18,9 @@ function createParser(highlighter, options) {
18
18
  const to = from + token.content.length;
19
19
  const decoration = Decoration.inline(from, to, {
20
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}`,
21
+ style: stringifyTokenStyle(
22
+ (_a = token.htmlStyle) != null ? _a : `color: ${token.color}`
23
+ ),
22
24
  class: "shiki"
23
25
  });
24
26
  decorations.push(decoration);
@@ -29,6 +31,10 @@ function createParser(highlighter, options) {
29
31
  return decorations;
30
32
  };
31
33
  }
34
+ function stringifyTokenStyle(token) {
35
+ if (typeof token === "string") return token;
36
+ return Object.entries(token).map(([key, value]) => `${key}:${value}`).join(";");
37
+ }
32
38
  export {
33
39
  createParser
34
40
  };
@@ -1,4 +1,4 @@
1
- import { P as Parser } from './types-D9kxOI8-.js';
1
+ import { P as Parser } from './types-CwiCqY6X.js';
2
2
  import 'prosemirror-model';
3
3
  import 'prosemirror-view';
4
4
 
@@ -3,8 +3,9 @@ import { Decoration } from 'prosemirror-view';
3
3
 
4
4
  /**
5
5
  * A function that parses the text content of a code block node and returns an
6
- * array of decorations. If the underlying syntax highlighter is still loading,
7
- * you can return a promise that will be resolved when the highlighter is ready.
6
+ * array of ProseMirror decorations. If the underlying syntax highlighter is
7
+ * still loading, you can return a promise that will be resolved when the
8
+ * highlighter is ready.
8
9
  */
9
10
  type Parser = (options: {
10
11
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prosemirror-highlight",
3
3
  "type": "module",
4
- "version": "0.9.0",
4
+ "version": "0.11.1",
5
5
  "description": "A ProseMirror plugin to highlight code blocks",
6
6
  "author": "ocavue <ocavue@gmail.com>",
7
7
  "license": "MIT",
@@ -59,8 +59,8 @@
59
59
  "prosemirror-transform": "^1.8.0",
60
60
  "prosemirror-view": "^1.32.4",
61
61
  "refractor": "^4.8.1",
62
- "shiki": "^1.9.0",
63
- "sugar-high": "^0.6.1"
62
+ "shiki": "^1.9.0 || ^2.0.0",
63
+ "sugar-high": "^0.6.1 || ^0.7.0 || ^0.8.0"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "@types/hast": {
@@ -95,28 +95,28 @@
95
95
  }
96
96
  },
97
97
  "devDependencies": {
98
- "@antfu/ni": "^0.23.0",
99
- "@ocavue/eslint-config": "^2.6.0",
98
+ "@antfu/ni": "^0.23.1",
99
+ "@ocavue/eslint-config": "^2.11.1",
100
100
  "@types/hast": "^3.0.4",
101
- "@types/node": "^20.16.2",
102
- "eslint": "^9.9.1",
101
+ "@types/node": "^20.17.5",
102
+ "eslint": "^9.14.0",
103
103
  "highlight.js": "^11.10.0",
104
- "jsdom": "^24.1.3",
105
- "lowlight": "^3.1.0",
106
- "prettier": "^3.3.3",
104
+ "jsdom": "^25.0.1",
105
+ "lowlight": "^3.2.0",
106
+ "prettier": "^3.4.1",
107
107
  "prosemirror-example-setup": "^1.2.3",
108
- "prosemirror-model": "^1.22.3",
108
+ "prosemirror-model": "^1.24.0",
109
109
  "prosemirror-schema-basic": "^1.2.3",
110
110
  "prosemirror-state": "^1.4.3",
111
- "prosemirror-transform": "^1.10.0",
112
- "prosemirror-view": "^1.34.1",
111
+ "prosemirror-transform": "^1.10.2",
112
+ "prosemirror-view": "^1.37.0",
113
113
  "refractor": "^4.8.1",
114
- "shiki": "^1.15.2",
115
- "sugar-high": "^0.7.0",
116
- "tsup": "^8.2.4",
117
- "typescript": "^5.5.4",
118
- "vite": "^5.4.2",
119
- "vitest": "^2.0.5"
114
+ "shiki": "^2.0.0",
115
+ "sugar-high": "^0.8.2",
116
+ "tsup": "^8.3.5",
117
+ "typescript": "^5.6.3",
118
+ "vite": "^6.0.5",
119
+ "vitest": "^2.1.8"
120
120
  },
121
121
  "renovate": {
122
122
  "dependencyDashboard": true,