Skip to content

Commit f88852c

Browse files
committed
Expose addCodeLanguage function
1 parent e39ff4d commit f88852c

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Add `markedit-api` to your (TypeScript) project's devDependencies:
1717
```json
1818
{
1919
"devDependencies": {
20-
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.4.0"
20+
"markedit-api": "https://github.com/MarkEdit-app/MarkEdit-api#v0.5.0"
2121
}
2222
}
2323
```
@@ -46,6 +46,8 @@ interface MarkEdit {
4646
addExtension: (extension: Extension) => void;
4747
// Add a Markdown config to MarkEdit.
4848
addMarkdownConfig: (config: MarkdownConfig) => void;
49+
// Add a language to be highlighted (in code blocks) to MarkEdit.
50+
addCodeLanguage: (language: LanguageDescription) => void;
4951
}
5052
```
5153

@@ -70,6 +72,12 @@ Build [MarkdownConfig](https://github.com/lezer-parser/markdown?tab=readme-ov-fi
7072
MarkEdit.addMarkdownConfig(config);
7173
```
7274

75+
MarkEdit supports syntax highlighting for code blocks, you can also build your own [Language Package](https://codemirror.net/examples/lang-package/), and add it to MarkEdit with:
76+
77+
```ts
78+
MarkEdit.addCodeLanguage(language);
79+
```
80+
7381
> While extensions and configs can theoretically be added at any time, it is recommended that they be added immediately after loading the script.
7482
7583
## Building

markedit.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
/**
2+
* https://github.com/MarkEdit-app/MarkEdit-api
3+
*
4+
* - [MarkEdit Customization Guide](https://github.com/MarkEdit-app/MarkEdit/wiki/Customization)
5+
* - [Example (Markdown Table Editor)](https://github.com/MarkEdit-app/MarkEdit-mte)
6+
* - [Example (Text Highlight)](https://github.com/MarkEdit-app/MarkEdit-highlight)
7+
*/
8+
19
import type { EditorView } from '@codemirror/view';
210
import type { Extension } from '@codemirror/state';
11+
import type { LanguageDescription } from '@codemirror/language';
312
import type { MarkdownConfig } from '@lezer/markdown';
413

514
import type * as cmView from '@codemirror/view';
@@ -98,8 +107,17 @@ export interface MarkEdit {
98107
* @param config Markdown config.
99108
*/
100109
addMarkdownConfig: (config: MarkdownConfig) => void;
110+
111+
/**
112+
* Add a language to be highlighted (in code blocks) to MarkEdit.
113+
* @param language The language description.
114+
*/
115+
addCodeLanguage: (language: LanguageDescription) => void;
101116
}
102117

118+
/**
119+
* Abstract editor to provide convenient text editing interfaces.
120+
*/
103121
export interface TextEditable {
104122
/**
105123
* Get text of the document.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "markedit-api",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Type definitions for the latest MakrEdit API.",
55
"main": "main.ts",
66
"types": "markedit.d.ts",

0 commit comments

Comments
 (0)