prosemirror-highlight 0.0.1 → 0.2.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/README.md +23 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -7
- package/dist/lowlight.js +0 -2
- package/dist/shiki.js +2 -2651
- package/dist/shikiji.d.ts +8 -0
- package/dist/shikiji.js +27 -0
- package/package.json +69 -31
- package/dist/chunk-YSQDPG26.js +0 -30
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/prosemirror-highlight)
|
|
4
4
|
|
|
5
|
-
Highlight your code blocks in ProseMirror, with any syntax highlighter you want.
|
|
5
|
+
Highlight your code blocks in [ProseMirror], with any syntax highlighter you want.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
@@ -24,6 +24,22 @@ const parser = createParser(highlighter)
|
|
|
24
24
|
export const shikiPlugin = createHighlightPlugin({ parser })
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
### With [Shikiji]
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { getHighlighter } from 'shikiji'
|
|
31
|
+
|
|
32
|
+
import { createHighlightPlugin } from 'prosemirror-highlight'
|
|
33
|
+
import { createParser } from 'prosemirror-highlight/shikiji'
|
|
34
|
+
|
|
35
|
+
const highlighter = await getHighlighter({
|
|
36
|
+
themes: ['vitesse-light'],
|
|
37
|
+
langs: ['javascript', 'typescript', 'python'],
|
|
38
|
+
})
|
|
39
|
+
const parser = createParser(highlighter)
|
|
40
|
+
export const shikijiPlugin = createHighlightPlugin({ parser })
|
|
41
|
+
```
|
|
42
|
+
|
|
27
43
|
### With [lowlight] (based on [Highlight.js])
|
|
28
44
|
|
|
29
45
|
```ts
|
|
@@ -39,6 +55,10 @@ const parser = createParser(lowlight)
|
|
|
39
55
|
export const lowlightPlugin = createHighlightPlugin({ parser })
|
|
40
56
|
```
|
|
41
57
|
|
|
58
|
+
## Online demo
|
|
59
|
+
|
|
60
|
+
[](https://stackblitz.com/github/ocavue/prosemirror-highlight?file=playground%2Fmain.ts)
|
|
61
|
+
|
|
42
62
|
## Credits
|
|
43
63
|
|
|
44
64
|
- [prosemirror-highlightjs] - Highlight.js syntax highlighting for ProseMirror
|
|
@@ -47,7 +67,9 @@ export const lowlightPlugin = createHighlightPlugin({ parser })
|
|
|
47
67
|
|
|
48
68
|
MIT
|
|
49
69
|
|
|
70
|
+
[ProseMirror]: https://prosemirror.net
|
|
50
71
|
[prosemirror-highlightjs]: https://github.com/b-kelly/prosemirror-highlightjs
|
|
51
72
|
[lowlight]: https://github.com/wooorm/lowlight
|
|
52
73
|
[Highlight.js]: https://github.com/highlightjs/highlight.js
|
|
53
74
|
[Shiki]: https://github.com/shikijs/shiki
|
|
75
|
+
[Shikiji]: https://github.com/antfu/shikiji
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Node } from 'prosemirror-model';
|
|
1
2
|
import { Transaction, Plugin } from 'prosemirror-state';
|
|
2
3
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
|
-
import { Node } from 'prosemirror-model';
|
|
4
4
|
import { P as Parser, L as LanguageExtractor } from './types-wUmJTPF3.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -82,4 +82,4 @@ declare function createHighlightPlugin({ parser, nodeTypes, languageExtractor, }
|
|
|
82
82
|
languageExtractor?: LanguageExtractor;
|
|
83
83
|
}): Plugin<HighlightPluginState>;
|
|
84
84
|
|
|
85
|
-
export { DecorationCache, type HighlightPluginState, createHighlightPlugin };
|
|
85
|
+
export { DecorationCache, type HighlightPluginState, LanguageExtractor, Parser, createHighlightPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import "./chunk-YSQDPG26.js";
|
|
2
|
-
|
|
3
|
-
// src/plugin.ts
|
|
4
|
-
import "prosemirror-model";
|
|
5
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
6
|
-
import { DecorationSet } from "prosemirror-view";
|
|
7
|
-
|
|
8
1
|
// src/cache.ts
|
|
9
2
|
import "prosemirror-model";
|
|
10
3
|
import "prosemirror-state";
|
|
@@ -82,6 +75,9 @@ var DecorationCache = class _DecorationCache {
|
|
|
82
75
|
};
|
|
83
76
|
|
|
84
77
|
// src/plugin.ts
|
|
78
|
+
import "prosemirror-model";
|
|
79
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
80
|
+
import { DecorationSet } from "prosemirror-view";
|
|
85
81
|
function createHighlightPlugin({
|
|
86
82
|
parser,
|
|
87
83
|
nodeTypes = ["code_block"],
|