@yoopta/code 4.9.9 → 6.0.0-beta.10
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/dist/commands/code-commands.d.ts +35 -0
- package/dist/commands/code-commands.d.ts.map +1 -0
- package/dist/commands/code-group-commands.d.ts +26 -0
- package/dist/commands/code-group-commands.d.ts.map +1 -0
- package/dist/components/highlighted-code-overlay.d.ts +13 -0
- package/dist/components/highlighted-code-overlay.d.ts.map +1 -0
- package/dist/index.d.ts +15 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/plugin/code-group-plugin.d.ts +5 -0
- package/dist/plugin/code-group-plugin.d.ts.map +1 -0
- package/dist/plugin/{index.d.ts → code-plugin.d.ts} +2 -2
- package/dist/plugin/code-plugin.d.ts.map +1 -0
- package/dist/types.d.ts +23 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/element.d.ts +2 -1
- package/dist/utils/element.d.ts.map +1 -1
- package/dist/utils/prettier.d.ts +24 -0
- package/dist/utils/prettier.d.ts.map +1 -0
- package/dist/utils/shiki.d.ts +16 -0
- package/dist/utils/shiki.d.ts.map +1 -0
- package/package.json +14 -42
- package/dist/commands/index.d.ts +0 -20
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/ui/Code.d.ts +0 -4
- package/dist/ui/Code.d.ts.map +0 -1
- package/dist/ui/CodeBlockOptions.d.ts +0 -10
- package/dist/ui/CodeBlockOptions.d.ts.map +0 -1
- package/dist/ui/Select.d.ts +0 -29
- package/dist/ui/Select.d.ts.map +0 -1
- package/dist/utils/languages.d.ts +0 -90
- package/dist/utils/languages.d.ts.map +0 -1
- package/dist/utils/themes.d.ts +0 -15
- package/dist/utils/themes.d.ts.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { YooEditor, YooptaPathIndex } from '@yoopta/editor';
|
|
2
|
+
import type { CodeElement, CodeElementProps } from '../types';
|
|
3
|
+
import { type FormatCodeOptions } from '../utils/prettier';
|
|
4
|
+
type CodeElementOptions = {
|
|
5
|
+
text?: string;
|
|
6
|
+
props?: CodeElementProps;
|
|
7
|
+
};
|
|
8
|
+
type InsertCodeOptions = CodeElementOptions & {
|
|
9
|
+
at?: YooptaPathIndex;
|
|
10
|
+
focus?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type BeautifyCodeResult = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
16
|
+
export type CodeCommandsType = {
|
|
17
|
+
buildCodeElements: (editor: YooEditor, options?: Partial<CodeElementOptions>) => CodeElement;
|
|
18
|
+
insertCode: (editor: YooEditor, options?: Partial<InsertCodeOptions>) => void;
|
|
19
|
+
deleteCode: (editor: YooEditor, blockId: string) => void;
|
|
20
|
+
updateCodeTheme: (editor: YooEditor, blockId: string, theme: CodeElementProps['theme']) => void;
|
|
21
|
+
updateCodeLanguage: (editor: YooEditor, blockId: string, language: CodeElementProps['language']) => void;
|
|
22
|
+
/** Formats the code string and returns the result (does not modify editor) */
|
|
23
|
+
prettifyCode: (editor: YooEditor, code: string, language: string, options?: FormatCodeOptions) => Promise<{
|
|
24
|
+
formatted: string;
|
|
25
|
+
success: boolean;
|
|
26
|
+
error?: string;
|
|
27
|
+
}>;
|
|
28
|
+
/** Beautifies the code in the specified block (modifies editor content) */
|
|
29
|
+
beautifyCode: (editor: YooEditor, blockId: string, options?: FormatCodeOptions) => Promise<BeautifyCodeResult>;
|
|
30
|
+
/** Checks if a language supports formatting */
|
|
31
|
+
isLanguageSupported: (language: string) => boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare const CodeCommands: CodeCommandsType;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=code-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-commands.d.ts","sourceRoot":"","sources":["../../src/commands/code-commands.ts"],"names":[],"mappings":"AAAA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EACZ,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,2EAA2E;IAC3E,YAAY,EAAE,CACZ,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,iBAAiB,KACxB,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACjC,+CAA+C;IAC/C,mBAAmB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;CACpD,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,gBA4E1B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { YooEditor } from '@yoopta/editor';
|
|
2
|
+
import type { Location } from 'slate';
|
|
3
|
+
import type { CodeGroupContainerElement } from '../types';
|
|
4
|
+
import { type FormatCodeOptions } from '../utils/prettier';
|
|
5
|
+
export type InsertTabOptions = {
|
|
6
|
+
afterTabId?: string;
|
|
7
|
+
at?: Location;
|
|
8
|
+
};
|
|
9
|
+
export type DeleteTabOptions = {
|
|
10
|
+
tabId: string;
|
|
11
|
+
};
|
|
12
|
+
export type BeautifyTabResult = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
16
|
+
export type CodeGroupCommands = {
|
|
17
|
+
buildCodeElements: (editor: YooEditor) => CodeGroupContainerElement;
|
|
18
|
+
addTabItem: (editor: YooEditor, blockId: string, options?: InsertTabOptions) => void;
|
|
19
|
+
deleteTabItem: (editor: YooEditor, blockId: string, options: DeleteTabOptions) => void;
|
|
20
|
+
/** Beautifies the code in the specified tab (modifies editor content) */
|
|
21
|
+
beautifyTab: (editor: YooEditor, blockId: string, tabId: string, options?: FormatCodeOptions) => Promise<BeautifyTabResult>;
|
|
22
|
+
/** Checks if a language supports formatting */
|
|
23
|
+
isLanguageSupported: (language: string) => boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const CodeGroupCommands: CodeGroupCommands;
|
|
26
|
+
//# sourceMappingURL=code-group-commands.d.ts.map
|
|
@@ -0,0 +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,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,iBA0Q/B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SlateElement } from '@yoopta/editor';
|
|
2
|
+
import type { BundledLanguage, BundledTheme, HighlighterGeneric, SpecialLanguage } from 'shiki';
|
|
3
|
+
export declare const useHighlighter: () => {
|
|
4
|
+
highlighter: HighlighterGeneric<BundledLanguage, BundledTheme> | null;
|
|
5
|
+
};
|
|
6
|
+
type HighlightedOverlayProps = {
|
|
7
|
+
element: SlateElement;
|
|
8
|
+
language: SpecialLanguage;
|
|
9
|
+
theme: BundledTheme;
|
|
10
|
+
};
|
|
11
|
+
export declare const HighlightedCodeOverlay: ({ element, language, theme }: HighlightedOverlayProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=highlighted-code-overlay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"highlighted-code-overlay.d.ts","sourceRoot":"","sources":["../../src/components/highlighted-code-overlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,eAAe,EAEhB,MAAM,OAAO,CAAC;AAOf,eAAO,MAAM,cAAc;;CAmB1B,CAAC;AASF,KAAK,uBAAuB,GAAG;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,eAAe,CAAC;IAC1B,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,sBAAsB,iCAAkC,uBAAuB,4CA6C3F,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import './
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export { CodeCommands } from './commands';
|
|
10
|
-
export default Code;
|
|
1
|
+
import { CodeGroup } from './plugin/code-group-plugin';
|
|
2
|
+
import { Code } from './plugin/code-plugin';
|
|
3
|
+
import { CodeElement, CodeElementProps, CodeGroupElementMap, CodeGroupPluginBlockOptions } from './types';
|
|
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';
|
|
7
|
+
export { SHIKI_CODE_LANGUAGES, SHIKI_CODE_THEMES } from './utils/shiki';
|
|
8
|
+
export { isLanguageSupported, type FormatCodeOptions } from './utils/prettier';
|
|
11
9
|
export { CodeElement, CodeElementProps };
|
|
10
|
+
export { CodeGroupElementMap, CodeGroupPluginBlockOptions };
|
|
11
|
+
export { CodeGroup, Code };
|
|
12
|
+
declare const CodePlugins: {
|
|
13
|
+
Code: import("@yoopta/editor").YooptaPlugin<import("./types").CodeElementMap, import("./types").CodePluginBlockOptions>;
|
|
14
|
+
CodeGroup: import("@yoopta/editor").YooptaPlugin<CodeGroupElementMap, CodeGroupPluginBlockOptions>;
|
|
15
|
+
};
|
|
16
|
+
export default CodePlugins;
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
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;AAC5C,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,2BAA2B,EAC5B,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC3F,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAE3B,QAAA,MAAM,WAAW;;;CAGhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|