@mantine-vue/code-highlight 3.2.0 → 3.4.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/cjs/index.cjs +144 -39
- package/cjs/index.cjs.map +1 -1
- package/esm/index.mjs +143 -41
- package/esm/index.mjs.map +1 -1
- package/lib/CodeHighlight/CodeHighlight.types.d.ts +2 -0
- package/lib/CodeHighlight/InlineCodeHighlight.types.d.ts +2 -0
- package/lib/CodeHighlightProvider/CodeHighlightProvider.d.ts +7 -1
- package/lib/CodeHighlightProvider/CodeHighlightProvider.types.d.ts +4 -0
- package/lib/CodeHighlightProvider/adapters/shiki-adapter.d.ts +2 -1
- package/lib/index.d.mts +3 -1
- package/lib/index.d.ts +3 -1
- package/lib/normalize-code.d.ts +6 -0
- package/package.json +3 -3
|
@@ -37,6 +37,8 @@ export interface CodeHighlightSettings {
|
|
|
37
37
|
controls?: VNodeChild[] | (() => VNodeChild);
|
|
38
38
|
/** Set to use dark or light color scheme. When using shiki adapter, you can use loaded themes here. */
|
|
39
39
|
codeColorScheme?: 'dark' | 'light' | (string & {});
|
|
40
|
+
/** If set, indentation of the first line is preserved. @default false */
|
|
41
|
+
withFirstLineIndentation?: boolean;
|
|
40
42
|
}
|
|
41
43
|
export interface CodeHighlightProps extends CodeHighlightSettings {
|
|
42
44
|
__withOffset?: boolean;
|
|
@@ -13,6 +13,8 @@ export interface InlineCodeHighlightProps {
|
|
|
13
13
|
radius?: string | number;
|
|
14
14
|
/** Adds border to the root element. @default false */
|
|
15
15
|
withBorder?: boolean;
|
|
16
|
+
/** If set, indentation of the first line is preserved. @default false */
|
|
17
|
+
withFirstLineIndentation?: boolean;
|
|
16
18
|
/** CSS classes applied to component elements. */
|
|
17
19
|
classNames?: any;
|
|
18
20
|
/** Inline styles applied to component elements. */
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { CodeHighlightProviderContext } from './CodeHighlightProvider.types';
|
|
2
2
|
export declare function provideCodeHighlightAdapterContext(value: CodeHighlightProviderContext): void;
|
|
3
|
-
export declare function useHighlight():
|
|
3
|
+
export declare function useHighlight(): (input: Parameters<CodeHighlightProviderContext["highlight"]>[0]) => {
|
|
4
|
+
highlightedCode: string;
|
|
5
|
+
isHighlighted: boolean;
|
|
6
|
+
codeElementProps?: Record<string, any>;
|
|
7
|
+
};
|
|
8
|
+
export declare function useLoadLanguage(): (language: string | undefined) => void;
|
|
9
|
+
export declare function useIsLanguageLoaded(): (language: string | undefined) => boolean;
|
|
4
10
|
export declare const CodeHighlightAdapterProvider: {
|
|
5
11
|
new (...args: any[]): import("vue").CreateComponentPublicInstanceWithMixins<Readonly<import("./CodeHighlightProvider.types").CodeHighlightAdapterProviderProps> & Readonly<{}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, import("vue").PublicProps, {}, false, {}, {}, import("vue").GlobalComponents, import("vue").GlobalDirectives, string, {}, any, import("vue").ComponentProvideOptions, {
|
|
6
12
|
P: {};
|
|
@@ -14,10 +14,14 @@ export type Highlighter = (input: HighlighterInput) => {
|
|
|
14
14
|
export interface CodeHighlightAdapter {
|
|
15
15
|
loadContext?: () => Promise<any>;
|
|
16
16
|
getHighlighter: (ctx: any) => Highlighter;
|
|
17
|
+
/** Lazily loads grammar data for a language. */
|
|
18
|
+
loadLanguage?: (ctx: any, language: string) => Promise<any> | undefined;
|
|
17
19
|
}
|
|
18
20
|
export interface CodeHighlightProviderContext {
|
|
19
21
|
adapter: CodeHighlightAdapter;
|
|
20
22
|
highlight: Highlighter;
|
|
23
|
+
loadLanguage: (language: string | undefined) => void;
|
|
24
|
+
isLanguageLoaded: (language: string | undefined) => boolean;
|
|
21
25
|
}
|
|
22
26
|
export interface CodeHighlightAdapterProviderProps {
|
|
23
27
|
/** Highlighting adapter used by descendant components. */
|
|
@@ -2,6 +2,7 @@ import type { CodeHighlightAdapter } from '../CodeHighlightProvider';
|
|
|
2
2
|
export declare function stripShikiCodeBlocks(data: string): string;
|
|
3
3
|
interface CreateShikiAdapterOptions {
|
|
4
4
|
forceColorScheme?: 'dark' | 'light' | (string & {});
|
|
5
|
+
resolveLanguage?: (language: string) => any;
|
|
5
6
|
}
|
|
6
|
-
export declare const createShikiAdapter: (loadShiki: () => Promise<any>, { forceColorScheme }?: CreateShikiAdapterOptions) => CodeHighlightAdapter;
|
|
7
|
+
export declare const createShikiAdapter: (loadShiki: () => Promise<any>, { forceColorScheme, resolveLanguage }?: CreateShikiAdapterOptions) => CodeHighlightAdapter;
|
|
7
8
|
export {};
|
package/lib/index.d.mts
CHANGED
|
@@ -3,7 +3,9 @@ export { InlineCodeHighlight } from './CodeHighlight/InlineCodeHighlight';
|
|
|
3
3
|
export { CodeHighlightTabs } from './CodeHighlightTabs/CodeHighlightTabs';
|
|
4
4
|
export { CodeHighlightControl } from './CodeHighlight/CodeHighlightControl/CodeHighlightControl';
|
|
5
5
|
export { useCodeHighlightContext } from './CodeHighlight/CodeHighlight.context';
|
|
6
|
-
export { CodeHighlightAdapterProvider, useHighlight, } from './CodeHighlightProvider/CodeHighlightProvider';
|
|
6
|
+
export { CodeHighlightAdapterProvider, useHighlight, useIsLanguageLoaded, useLoadLanguage, } from './CodeHighlightProvider/CodeHighlightProvider';
|
|
7
|
+
export { normalizeCode } from './normalize-code';
|
|
8
|
+
export type { NormalizeCodeOptions } from './normalize-code';
|
|
7
9
|
export { createHighlightJsAdapter } from './CodeHighlightProvider/adapters/highlight-js-adapter';
|
|
8
10
|
export { createShikiAdapter, stripShikiCodeBlocks, } from './CodeHighlightProvider/adapters/shiki-adapter';
|
|
9
11
|
export { plainTextAdapter } from './CodeHighlightProvider/adapters/plain-text-adapter';
|
package/lib/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export { InlineCodeHighlight } from './CodeHighlight/InlineCodeHighlight';
|
|
|
3
3
|
export { CodeHighlightTabs } from './CodeHighlightTabs/CodeHighlightTabs';
|
|
4
4
|
export { CodeHighlightControl } from './CodeHighlight/CodeHighlightControl/CodeHighlightControl';
|
|
5
5
|
export { useCodeHighlightContext } from './CodeHighlight/CodeHighlight.context';
|
|
6
|
-
export { CodeHighlightAdapterProvider, useHighlight, } from './CodeHighlightProvider/CodeHighlightProvider';
|
|
6
|
+
export { CodeHighlightAdapterProvider, useHighlight, useIsLanguageLoaded, useLoadLanguage, } from './CodeHighlightProvider/CodeHighlightProvider';
|
|
7
|
+
export { normalizeCode } from './normalize-code';
|
|
8
|
+
export type { NormalizeCodeOptions } from './normalize-code';
|
|
7
9
|
export { createHighlightJsAdapter } from './CodeHighlightProvider/adapters/highlight-js-adapter';
|
|
8
10
|
export { createShikiAdapter, stripShikiCodeBlocks, } from './CodeHighlightProvider/adapters/shiki-adapter';
|
|
9
11
|
export { plainTextAdapter } from './CodeHighlightProvider/adapters/plain-text-adapter';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface NormalizeCodeOptions {
|
|
2
|
+
/** If set, indentation of the first line is preserved. @default false */
|
|
3
|
+
withFirstLineIndentation?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/** Removes blank leading lines and trailing whitespace before highlighting or copying code. */
|
|
6
|
+
export declare function normalizeCode(code: string, { withFirstLineIndentation }?: NormalizeCodeOptions): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mantine-vue/code-highlight",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "Vue code highlight components equivalent to @mantine/code-highlight",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"vue": "^3.5.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@mantine-vue/core": "3.
|
|
43
|
-
"@mantine-vue/hooks": "3.
|
|
42
|
+
"@mantine-vue/core": "3.4.0",
|
|
43
|
+
"@mantine-vue/hooks": "3.4.0",
|
|
44
44
|
"vue": "^3.5.0"
|
|
45
45
|
}
|
|
46
46
|
}
|