@yoopta/code 6.0.0-beta.9 → 6.0.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
@@ -1,11 +1,53 @@
1
- # `yoopta-code`
1
+ # @yoopta/code
2
2
 
3
- > TODO: description
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
- // TODO: DEMONSTRATE API
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).
@@ -13,7 +13,7 @@ export type BeautifyTabResult = {
13
13
  success: boolean;
14
14
  error?: string;
15
15
  };
16
- export type CodeGroupCommands = {
16
+ export type CodeGroupCommandsType = {
17
17
  buildCodeElements: (editor: YooEditor) => CodeGroupContainerElement;
18
18
  addTabItem: (editor: YooEditor, blockId: string, options?: InsertTabOptions) => void;
19
19
  deleteTabItem: (editor: YooEditor, blockId: string, options: DeleteTabOptions) => void;
@@ -22,5 +22,5 @@ export type CodeGroupCommands = {
22
22
  /** Checks if a language supports formatting */
23
23
  isLanguageSupported: (language: string) => boolean;
24
24
  };
25
- export declare const CodeGroupCommands: CodeGroupCommands;
25
+ export declare const CodeGroupCommands: CodeGroupCommandsType;
26
26
  //# sourceMappingURL=code-group-commands.d.ts.map
@@ -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,E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AS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACrF,aAAa,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACvF,yEAAyE;IACzE,WAAW,EAAE,CACX,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAChC,+CAA+C;IAC/C,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,qBA4R/B,CAAC"}
package/dist/index.d.ts CHANGED
@@ -2,8 +2,8 @@ import { CodeGroup } from './plugin/code-group-plugin';
2
2
  import { Code } from './plugin/code-plugin';
3
3
  import { CodeElement, CodeElementProps, CodeGroupElementMap, CodeGroupPluginBlockOptions } from './types';
4
4
  export { HighlightedCodeOverlay, useHighlighter } from './components/highlighted-code-overlay';
5
- export { CodeCommands, type BeautifyCodeResult } from './commands/code-commands';
6
- export { CodeGroupCommands, type BeautifyTabResult } from './commands/code-group-commands';
5
+ export { CodeCommands, type BeautifyCodeResult, type CodeCommandsType } from './commands/code-commands';
6
+ export { CodeGroupCommands, type BeautifyTabResult, type CodeGroupCommandsType } from './commands/code-group-commands';
7
7
  export { SHIKI_CODE_LANGUAGES, SHIKI_CODE_THEMES } from './utils/shiki';
8
8
  export { isLanguageSupported, type FormatCodeOptions } from './utils/prettier';
9
9
  export { CodeElement, CodeElementProps };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC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