vue-intlayer 8.12.2 → 8.12.4-canary.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/dist/cjs/markdown/compiler.cjs +1 -1
- package/dist/cjs/markdown/index.cjs +1 -1
- package/dist/esm/markdown/compiler.mjs +10 -10
- package/dist/esm/markdown/index.mjs +4 -4
- package/dist/types/markdown/MarkdownRenderer.d.ts +102 -0
- package/dist/types/markdown/compiler.d.ts +45 -6
- package/dist/types/markdown/index.d.ts +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./runtime.cjs");let t=require("@intlayer/core/markdown");var n=(n=``,r={})=>{let{components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s,...c}=r;return(0,t.parseMarkdown)(n,{runtime:e.default,components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s},c)},r=(n=``,r={})=>{if(typeof n==`string`)return(0,t.compileWithOptions)(n,e.default,r);let{components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s,...c}=r;return(0,t.renderMarkdownAst)(n,{runtime:e.default,components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s},c)}
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./runtime.cjs");let t=require("@intlayer/core/markdown");var n=(n=``,r={})=>{let{components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s,...c}=r;return(0,t.parseMarkdown)(n,{runtime:e.default,components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s},c)},r=(n=``,r={})=>{if(typeof n==`string`)return(0,t.compileWithOptions)(n,e.default,r);let{components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s,...c}=r;return(0,t.renderMarkdownAst)(n,{runtime:e.default,components:i,namedCodesToUnicode:a,sanitizer:o,slugify:s},c)};exports.compileMarkdown=r,exports.parseMarkdown=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./compiler.cjs"),t=require("./installIntlayerMarkdown.cjs"),n=require("./MarkdownRenderer.cjs");
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./compiler.cjs"),t=require("./installIntlayerMarkdown.cjs"),n=require("./MarkdownRenderer.cjs");exports.MarkdownRenderer=n.MarkdownRenderer,exports.compileMarkdown=e.compileMarkdown,exports.installIntlayerMarkdown=t.installIntlayerMarkdown,exports.intlayerMarkdown=t.intlayerMarkdown,exports.parseMarkdown=e.parseMarkdown,exports.renderMarkdown=n.renderMarkdown,exports.useMarkdown=t.useMarkdown,exports.useMarkdownRenderer=n.useMarkdownRenderer;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import e from "./runtime.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { compileWithOptions as t, parseMarkdown as n, renderMarkdownAst as r } from "@intlayer/core/markdown";
|
|
3
3
|
//#region src/markdown/compiler.ts
|
|
4
|
-
var
|
|
5
|
-
let { components: i, namedCodesToUnicode: a, sanitizer: o, slugify: s, ...c } =
|
|
6
|
-
return
|
|
4
|
+
var i = (t = "", r = {}) => {
|
|
5
|
+
let { components: i, namedCodesToUnicode: a, sanitizer: o, slugify: s, ...c } = r;
|
|
6
|
+
return n(t, {
|
|
7
7
|
runtime: e,
|
|
8
8
|
components: i,
|
|
9
9
|
namedCodesToUnicode: a,
|
|
10
10
|
sanitizer: o,
|
|
11
11
|
slugify: s
|
|
12
12
|
}, c);
|
|
13
|
-
},
|
|
14
|
-
if (typeof
|
|
15
|
-
let { components: a, namedCodesToUnicode: o, sanitizer: s, slugify: c, ...l } =
|
|
16
|
-
return
|
|
13
|
+
}, a = (n = "", i = {}) => {
|
|
14
|
+
if (typeof n == "string") return t(n, e, i);
|
|
15
|
+
let { components: a, namedCodesToUnicode: o, sanitizer: s, slugify: c, ...l } = i;
|
|
16
|
+
return r(n, {
|
|
17
17
|
runtime: e,
|
|
18
18
|
components: a,
|
|
19
19
|
namedCodesToUnicode: o,
|
|
20
20
|
sanitizer: s,
|
|
21
21
|
slugify: c
|
|
22
22
|
}, l);
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
//#endregion
|
|
25
|
-
export {
|
|
25
|
+
export { a as compileMarkdown, i as parseMarkdown };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { installIntlayerMarkdown as
|
|
3
|
-
import { MarkdownRenderer as
|
|
4
|
-
export {
|
|
1
|
+
import { compileMarkdown as e, parseMarkdown as t } from "./compiler.mjs";
|
|
2
|
+
import { installIntlayerMarkdown as n, intlayerMarkdown as r, useMarkdown as i } from "./installIntlayerMarkdown.mjs";
|
|
3
|
+
import { MarkdownRenderer as a, renderMarkdown as o, useMarkdownRenderer as s } from "./MarkdownRenderer.mjs";
|
|
4
|
+
export { a as MarkdownRenderer, e as compileMarkdown, n as installIntlayerMarkdown, r as intlayerMarkdown, t as parseMarkdown, o as renderMarkdown, i as useMarkdown, s as useMarkdownRenderer };
|
|
@@ -4,6 +4,22 @@ import { ParsedMarkdown } from './compiler';
|
|
|
4
4
|
import { MarkdownPluginOptions, RenderMarkdownFunction } from './installIntlayerMarkdown';
|
|
5
5
|
/**
|
|
6
6
|
* Props for rendering markdown content.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* const props: RenderMarkdownProps = {
|
|
11
|
+
* components: {
|
|
12
|
+
* h1: ({ children }) => <h1 className="text-3xl">{children}</h1>,
|
|
13
|
+
* p: ({ children }) => <p className="text-gray-700">{children}</p>,
|
|
14
|
+
* },
|
|
15
|
+
* wrapper: ({ children }) => <article>{children}</article>,
|
|
16
|
+
* options: {
|
|
17
|
+
* forceBlock: true,
|
|
18
|
+
* preserveFrontmatter: false,
|
|
19
|
+
* tagfilter: true,
|
|
20
|
+
* },
|
|
21
|
+
* };
|
|
22
|
+
* ```
|
|
7
23
|
*/
|
|
8
24
|
export type RenderMarkdownProps = MarkdownPluginOptions & {
|
|
9
25
|
/** Component overrides for HTML tags. */
|
|
@@ -16,6 +32,25 @@ export type RenderMarkdownProps = MarkdownPluginOptions & {
|
|
|
16
32
|
*
|
|
17
33
|
* This function does not use context from MarkdownProvider. Use `useMarkdownRenderer`
|
|
18
34
|
* hook if you want to leverage provider context.
|
|
35
|
+
*
|
|
36
|
+
* @param content - The markdown string to render
|
|
37
|
+
* @param props - Configuration options for rendering
|
|
38
|
+
* @param props.components - Component overrides for HTML tags
|
|
39
|
+
* @param props.wrapper - Wrapper component for multiple children
|
|
40
|
+
* @returns Vue VNodes representing the rendered markdown
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { renderMarkdown } from 'vue-intlayer/markdown';
|
|
45
|
+
*
|
|
46
|
+
* const markdown = '# Hello World\n\nThis is **bold** text.';
|
|
47
|
+
* const vnodes = await renderMarkdown(markdown, {
|
|
48
|
+
* components: {
|
|
49
|
+
* h1: ({ children }) => h('h1', { class: 'title' }, children),
|
|
50
|
+
* },
|
|
51
|
+
* forceBlock: true,
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
19
54
|
*/
|
|
20
55
|
export declare const renderMarkdown: (content: string | ParsedMarkdown, { components, wrapper, forceBlock, forceInline, preserveFrontmatter, tagfilter, }?: RenderMarkdownProps) => Promise<VNodeChild>;
|
|
21
56
|
/**
|
|
@@ -23,12 +58,79 @@ export declare const renderMarkdown: (content: string | ParsedMarkdown, { compon
|
|
|
23
58
|
*
|
|
24
59
|
* This hook considers the configuration from the `MarkdownProvider` context if available,
|
|
25
60
|
* falling back to the provided props or default behavior.
|
|
61
|
+
*
|
|
62
|
+
* @param props - Optional configuration that will override context values
|
|
63
|
+
* @param props.components - Component overrides for HTML tags (overrides context)
|
|
64
|
+
* @param props.wrapper - Wrapper component (overrides context)
|
|
65
|
+
* @returns A function that takes markdown content and returns VNodes
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```vue
|
|
69
|
+
* <script setup>
|
|
70
|
+
* import { useMarkdownRenderer } from 'vue-intlayer/markdown';
|
|
71
|
+
*
|
|
72
|
+
* const renderMarkdown = useMarkdownRenderer({
|
|
73
|
+
* components: {
|
|
74
|
+
* h1: (props) => h('h1', { class: 'custom' }, props.children),
|
|
75
|
+
* },
|
|
76
|
+
* });
|
|
77
|
+
* </script>
|
|
78
|
+
*
|
|
79
|
+
* <template>
|
|
80
|
+
* <component :is="renderMarkdown('# Hello\n\nThis is **markdown**')" />
|
|
81
|
+
* </template>
|
|
82
|
+
* ```
|
|
26
83
|
*/
|
|
27
84
|
export declare const useMarkdownRenderer: ({ components, wrapper, forceBlock, forceInline, preserveFrontmatter, tagfilter, }?: RenderMarkdownProps) => (content: string | ParsedMarkdown) => VNodeChild | Promise<VNodeChild>;
|
|
85
|
+
/**
|
|
86
|
+
* Props for the MarkdownRenderer component.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```vue
|
|
90
|
+
* <script setup>
|
|
91
|
+
* const props = {
|
|
92
|
+
* content: '# Hello World\n\nThis is **bold** text.',
|
|
93
|
+
* components: {
|
|
94
|
+
* h1: (props) => h('h1', { class: 'title' }, props.children),
|
|
95
|
+
* },
|
|
96
|
+
* forceBlock: true,
|
|
97
|
+
* };
|
|
98
|
+
* </script>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
28
101
|
export type MarkdownRendererProps = RenderMarkdownProps & {
|
|
102
|
+
/**
|
|
103
|
+
* The markdown content to render as a string.
|
|
104
|
+
*/
|
|
29
105
|
content?: string | ParsedMarkdown;
|
|
106
|
+
/**
|
|
107
|
+
* Custom render function for markdown.
|
|
108
|
+
* If provided, it will overwrite context and default rendering.
|
|
109
|
+
*/
|
|
30
110
|
renderMarkdown?: RenderMarkdownFunction;
|
|
31
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Vue component that renders markdown content to VNodes.
|
|
114
|
+
*
|
|
115
|
+
* This component uses the `renderMarkdown` function from the `intlayerMarkdown` plugin
|
|
116
|
+
* if available. Otherwise, it falls back to the default compiler with provided components
|
|
117
|
+
* and options. You can also provide a custom `renderMarkdown` function prop to override
|
|
118
|
+
* all rendering behavior.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```vue
|
|
122
|
+
* <script setup>
|
|
123
|
+
* import { MarkdownRenderer } from 'vue-intlayer/markdown';
|
|
124
|
+
* </script>
|
|
125
|
+
*
|
|
126
|
+
* <template>
|
|
127
|
+
* <MarkdownRenderer
|
|
128
|
+
* content="# Hello World"
|
|
129
|
+
* :forceBlock="true"
|
|
130
|
+
* />
|
|
131
|
+
* </template>
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
32
134
|
export declare const MarkdownRenderer: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
33
135
|
content: {
|
|
34
136
|
type: PropType<string | ParsedMarkdown>;
|
|
@@ -1,12 +1,51 @@
|
|
|
1
|
-
import { CompileOptions,
|
|
2
|
-
|
|
1
|
+
import { CompileOptions, ParsedMarkdown } from '@intlayer/core/markdown';
|
|
2
|
+
/**
|
|
3
|
+
* Options accepted by `compileMarkdown` and `parseMarkdown` to customise
|
|
4
|
+
* rendering behaviour (custom components, sanitizer, slugify, rule hooks, …).
|
|
5
|
+
*/
|
|
3
6
|
export type MarkdownCompilerOptions = CompileOptions;
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
8
|
+
* Alias for `MarkdownCompilerOptions` to align with other frameworks.
|
|
9
|
+
*/
|
|
10
|
+
export type MarkdownRendererOptions = MarkdownCompilerOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Intermediate AST produced by `parseMarkdown`.
|
|
13
|
+
* Pass this to `compileMarkdown` to skip re-parsing when the same content is
|
|
14
|
+
* rendered multiple times.
|
|
7
15
|
*/
|
|
8
16
|
export type { ParsedMarkdown };
|
|
17
|
+
/**
|
|
18
|
+
* **Step 1 of 2 — parse only.**
|
|
19
|
+
* Converts a raw markdown string into a `ParsedMarkdown` AST without rendering
|
|
20
|
+
* any Vue VNodes. Use this when you need to:
|
|
21
|
+
* - Cache the parsed result and render it several times with different options.
|
|
22
|
+
* - Inspect or transform the AST before rendering.
|
|
23
|
+
* - Defer the render step to a later point.
|
|
24
|
+
*
|
|
25
|
+
* @param markdown - The markdown source string.
|
|
26
|
+
* @param options - Options that affect parsing (sanitizer, slugify, …).
|
|
27
|
+
* @returns A `ParsedMarkdown` AST ready to be passed to `compileMarkdown`.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const ast = parseMarkdown('# Hello **world**');
|
|
32
|
+
* const vnodes = compileMarkdown(ast, { forceBlock: true });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
9
35
|
export declare const parseMarkdown: (markdown?: string, options?: MarkdownCompilerOptions) => ParsedMarkdown;
|
|
36
|
+
/**
|
|
37
|
+
* **Steps 1 + 2 — parse and render in one shot.**
|
|
38
|
+
* Accepts a raw markdown string or a pre-parsed `ParsedMarkdown` AST and
|
|
39
|
+
* returns Vue VNodes. Use `parseMarkdown` first when you need to reuse the
|
|
40
|
+
* same AST with different options.
|
|
41
|
+
*
|
|
42
|
+
* @param input - Markdown string or pre-parsed AST.
|
|
43
|
+
* @param options - Rendering options (custom components, sanitizer, slugify, …).
|
|
44
|
+
* @returns Vue VNodes representing the rendered markdown.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const vnodes = compileMarkdown('# Hello **world**', { forceBlock: true });
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
10
51
|
export declare const compileMarkdown: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => unknown;
|
|
11
|
-
export declare const compiler: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => unknown;
|
|
12
|
-
export declare const compile: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => unknown;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { compileMarkdown, type MarkdownCompilerOptions, type MarkdownRendererOptions, type ParsedMarkdown, parseMarkdown, } from './compiler';
|
|
2
2
|
export { type IntlayerMarkdownPluginOptions, type IntlayerMarkdownProvider, installIntlayerMarkdown, intlayerMarkdown, type MarkdownProviderOptions, type RenderMarkdownFunction, useMarkdown, } from './installIntlayerMarkdown';
|
|
3
3
|
export { MarkdownRenderer, type MarkdownRendererProps, type RenderMarkdownProps, renderMarkdown, useMarkdownRenderer, } from './MarkdownRenderer';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-intlayer",
|
|
3
|
-
"version": "8.12.
|
|
3
|
+
"version": "8.12.4-canary.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vue applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -102,14 +102,14 @@
|
|
|
102
102
|
"typecheck": "vue-tsc --noEmit --project tsconfig.types.json"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"@intlayer/api": "8.12.
|
|
106
|
-
"@intlayer/config": "8.12.
|
|
107
|
-
"@intlayer/core": "8.12.
|
|
108
|
-
"@intlayer/editor": "8.12.
|
|
109
|
-
"@intlayer/types": "8.12.
|
|
105
|
+
"@intlayer/api": "8.12.4-canary.0",
|
|
106
|
+
"@intlayer/config": "8.12.4-canary.0",
|
|
107
|
+
"@intlayer/core": "8.12.4-canary.0",
|
|
108
|
+
"@intlayer/editor": "8.12.4-canary.0",
|
|
109
|
+
"@intlayer/types": "8.12.4-canary.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
|
-
"@types/node": "25.9.
|
|
112
|
+
"@types/node": "25.9.2",
|
|
113
113
|
"@utils/ts-config": "1.0.4",
|
|
114
114
|
"@utils/ts-config-types": "1.0.4",
|
|
115
115
|
"@utils/tsdown-config": "1.0.4",
|
|
@@ -117,15 +117,15 @@
|
|
|
117
117
|
"ajv": "8.18.0",
|
|
118
118
|
"fast-glob": "3.3.3",
|
|
119
119
|
"rimraf": "6.1.3",
|
|
120
|
-
"tsdown": "0.
|
|
120
|
+
"tsdown": "0.21.10",
|
|
121
121
|
"typescript": "6.0.3",
|
|
122
122
|
"vite": "8.0.16",
|
|
123
|
-
"vite-plugin-dts": "5.0.
|
|
123
|
+
"vite-plugin-dts": "5.0.2",
|
|
124
124
|
"vitest": "4.1.8",
|
|
125
125
|
"vue-tsc": "3.1.8"
|
|
126
126
|
},
|
|
127
127
|
"peerDependencies": {
|
|
128
|
-
"intlayer": "8.12.
|
|
128
|
+
"intlayer": "8.12.4-canary.0",
|
|
129
129
|
"vue": ">=3.0.0"
|
|
130
130
|
},
|
|
131
131
|
"peerDependenciesMeta": {
|