@yoopta/code 6.0.0-beta.17 → 6.0.0-beta.19
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 +46 -4
- package/dist/commands/code-group-commands.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,11 +1,53 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yoopta/code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Code block plugin for Yoopta Editor. Renders code blocks with optional language and theme (e.g. for syntax highlighting). Use headless or with theme UI from `@yoopta/themes-shadcn`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add @yoopta/code
|
|
9
|
+
```
|
|
4
10
|
|
|
5
11
|
## Usage
|
|
6
12
|
|
|
13
|
+
Pass the plugin to `createYooptaEditor`. Do not pass `plugins` to `<YooptaEditor>`.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { useMemo } from 'react';
|
|
17
|
+
import YooptaEditor, { createYooptaEditor } from '@yoopta/editor';
|
|
18
|
+
import Code from '@yoopta/code';
|
|
19
|
+
|
|
20
|
+
const plugins = [Code];
|
|
21
|
+
|
|
22
|
+
export default function Editor() {
|
|
23
|
+
const editor = useMemo(() => createYooptaEditor({ plugins, marks: [] }), []);
|
|
24
|
+
return <YooptaEditor editor={editor} onChange={() => {}} />;
|
|
25
|
+
}
|
|
7
26
|
```
|
|
8
|
-
const code = require('yoopta-code');
|
|
9
27
|
|
|
10
|
-
|
|
28
|
+
## Themed UI
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { applyTheme } from '@yoopta/themes-shadcn';
|
|
32
|
+
const plugins = applyTheme([Paragraph, Code, /* ... */]);
|
|
11
33
|
```
|
|
34
|
+
|
|
35
|
+
Or: `Code.extend({ elements: CodeUI })` with `CodeUI` from `@yoopta/themes-shadcn/code`.
|
|
36
|
+
|
|
37
|
+
## Extend
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
Code.extend({
|
|
41
|
+
elements: {
|
|
42
|
+
code: { render: (props) => <YourCodeBlock {...props} /> },
|
|
43
|
+
},
|
|
44
|
+
options: {
|
|
45
|
+
display: { title: 'Code', description: 'Code block' },
|
|
46
|
+
shortcuts: ['code', '```'],
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Docs
|
|
52
|
+
|
|
53
|
+
See [Code plugin docs](https://docs.yoopta.dev/plugins/code) and [Code group](https://docs.yoopta.dev/plugins/code-group).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-group-commands.d.ts","sourceRoot":"","sources":["../../src/commands/code-group-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGtC,OAAO,KAAK,EAAE,yBAAyB,EAA2B,MAAM,UAAU,CAAC;AACnF,OAAO,EAAE,KAAK,iBAAiB,EAAmC,MAAM,mBAAmB,CAAC;AAE5F,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,EAAE,CAAC,EAAE,QAAQ,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,iBAAiB,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,yBAAyB,CAAC;IACpE,UAAU,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAA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