@pactor-app/markdown 0.1.0 → 1.0.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/index.cjs +8 -3
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +8 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -167,6 +167,7 @@ var highlightingComponents = {
|
|
|
167
167
|
function MarkdownRenderer({
|
|
168
168
|
content = "",
|
|
169
169
|
className,
|
|
170
|
+
style,
|
|
170
171
|
math = true,
|
|
171
172
|
codeHighlight = true
|
|
172
173
|
}) {
|
|
@@ -174,7 +175,7 @@ function MarkdownRenderer({
|
|
|
174
175
|
registerCodeLanguages();
|
|
175
176
|
}
|
|
176
177
|
const containerClass = className ? `pactor-markdown ${className}` : "pactor-markdown";
|
|
177
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: containerClass, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: containerClass, style, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
178
179
|
import_react_markdown.default,
|
|
179
180
|
{
|
|
180
181
|
remarkPlugins: math ? [import_remark_gfm.default, import_remark_math.default] : [import_remark_gfm.default],
|
|
@@ -187,8 +188,12 @@ function MarkdownRenderer({
|
|
|
187
188
|
|
|
188
189
|
// src/dsl-component.tsx
|
|
189
190
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
190
|
-
function MarkdownDslComponent({
|
|
191
|
-
|
|
191
|
+
function MarkdownDslComponent({
|
|
192
|
+
content,
|
|
193
|
+
className,
|
|
194
|
+
style
|
|
195
|
+
}) {
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(MarkdownRenderer, { content: content ?? "", className, style });
|
|
192
197
|
}
|
|
193
198
|
|
|
194
199
|
// src/register.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
2
3
|
import { Registry } from '@pactor-app/core';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -13,6 +14,8 @@ interface MarkdownRendererProps {
|
|
|
13
14
|
content?: string;
|
|
14
15
|
/** 附加 className,与基础 class `@pactor-app/markdown` 并存 */
|
|
15
16
|
className?: string;
|
|
17
|
+
/** 通用:根节点内联样式 */
|
|
18
|
+
style?: CSSProperties;
|
|
16
19
|
/** 数学公式(remark-math + rehype-katex),默认 true;需自行引入 katex css */
|
|
17
20
|
math?: boolean;
|
|
18
21
|
/** fenced 代码块语法高亮,默认 true */
|
|
@@ -26,7 +29,7 @@ interface MarkdownRendererProps {
|
|
|
26
29
|
*
|
|
27
30
|
* 注意:启用 math 时需在使用方引入 `katex/dist/katex.min.css`。
|
|
28
31
|
*/
|
|
29
|
-
declare function MarkdownRenderer({ content, className, math, codeHighlight, }: MarkdownRendererProps): react.JSX.Element;
|
|
32
|
+
declare function MarkdownRenderer({ content, className, style, math, codeHighlight, }: MarkdownRendererProps): react.JSX.Element;
|
|
30
33
|
|
|
31
34
|
interface MarkdownDslComponentProps {
|
|
32
35
|
/**
|
|
@@ -34,12 +37,16 @@ interface MarkdownDslComponentProps {
|
|
|
34
37
|
* `${data.xxx}` 等表达式已由 Renderer 在 props 下发前解析(设计决策 D3)。
|
|
35
38
|
*/
|
|
36
39
|
content?: string;
|
|
40
|
+
/** 通用:根节点 class(与基础 class 并存) */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** 通用:根节点内联样式 */
|
|
43
|
+
style?: CSSProperties;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* DSL 组件适配:`{ type: 'Markdown', props: { content } }`。
|
|
40
47
|
* 仅做 props 透传,渲染与安全边界全部委托给 MarkdownRenderer。
|
|
41
48
|
*/
|
|
42
|
-
declare function MarkdownDslComponent({ content }: MarkdownDslComponentProps): react.JSX.Element;
|
|
49
|
+
declare function MarkdownDslComponent({ content, className, style, }: MarkdownDslComponentProps): react.JSX.Element;
|
|
43
50
|
|
|
44
51
|
/** Markdown 组件的 DSL 类型名 */
|
|
45
52
|
declare const MARKDOWN_DSL_TYPE = "Markdown";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
2
3
|
import { Registry } from '@pactor-app/core';
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -13,6 +14,8 @@ interface MarkdownRendererProps {
|
|
|
13
14
|
content?: string;
|
|
14
15
|
/** 附加 className,与基础 class `@pactor-app/markdown` 并存 */
|
|
15
16
|
className?: string;
|
|
17
|
+
/** 通用:根节点内联样式 */
|
|
18
|
+
style?: CSSProperties;
|
|
16
19
|
/** 数学公式(remark-math + rehype-katex),默认 true;需自行引入 katex css */
|
|
17
20
|
math?: boolean;
|
|
18
21
|
/** fenced 代码块语法高亮,默认 true */
|
|
@@ -26,7 +29,7 @@ interface MarkdownRendererProps {
|
|
|
26
29
|
*
|
|
27
30
|
* 注意:启用 math 时需在使用方引入 `katex/dist/katex.min.css`。
|
|
28
31
|
*/
|
|
29
|
-
declare function MarkdownRenderer({ content, className, math, codeHighlight, }: MarkdownRendererProps): react.JSX.Element;
|
|
32
|
+
declare function MarkdownRenderer({ content, className, style, math, codeHighlight, }: MarkdownRendererProps): react.JSX.Element;
|
|
30
33
|
|
|
31
34
|
interface MarkdownDslComponentProps {
|
|
32
35
|
/**
|
|
@@ -34,12 +37,16 @@ interface MarkdownDslComponentProps {
|
|
|
34
37
|
* `${data.xxx}` 等表达式已由 Renderer 在 props 下发前解析(设计决策 D3)。
|
|
35
38
|
*/
|
|
36
39
|
content?: string;
|
|
40
|
+
/** 通用:根节点 class(与基础 class 并存) */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** 通用:根节点内联样式 */
|
|
43
|
+
style?: CSSProperties;
|
|
37
44
|
}
|
|
38
45
|
/**
|
|
39
46
|
* DSL 组件适配:`{ type: 'Markdown', props: { content } }`。
|
|
40
47
|
* 仅做 props 透传,渲染与安全边界全部委托给 MarkdownRenderer。
|
|
41
48
|
*/
|
|
42
|
-
declare function MarkdownDslComponent({ content }: MarkdownDslComponentProps): react.JSX.Element;
|
|
49
|
+
declare function MarkdownDslComponent({ content, className, style, }: MarkdownDslComponentProps): react.JSX.Element;
|
|
43
50
|
|
|
44
51
|
/** Markdown 组件的 DSL 类型名 */
|
|
45
52
|
declare const MARKDOWN_DSL_TYPE = "Markdown";
|
package/dist/index.js
CHANGED
|
@@ -125,6 +125,7 @@ var highlightingComponents = {
|
|
|
125
125
|
function MarkdownRenderer({
|
|
126
126
|
content = "",
|
|
127
127
|
className,
|
|
128
|
+
style,
|
|
128
129
|
math = true,
|
|
129
130
|
codeHighlight = true
|
|
130
131
|
}) {
|
|
@@ -132,7 +133,7 @@ function MarkdownRenderer({
|
|
|
132
133
|
registerCodeLanguages();
|
|
133
134
|
}
|
|
134
135
|
const containerClass = className ? `pactor-markdown ${className}` : "pactor-markdown";
|
|
135
|
-
return /* @__PURE__ */ jsx3("div", { className: containerClass, children: /* @__PURE__ */ jsx3(
|
|
136
|
+
return /* @__PURE__ */ jsx3("div", { className: containerClass, style, children: /* @__PURE__ */ jsx3(
|
|
136
137
|
Markdown,
|
|
137
138
|
{
|
|
138
139
|
remarkPlugins: math ? [remarkGfm, remarkMath] : [remarkGfm],
|
|
@@ -145,8 +146,12 @@ function MarkdownRenderer({
|
|
|
145
146
|
|
|
146
147
|
// src/dsl-component.tsx
|
|
147
148
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
148
|
-
function MarkdownDslComponent({
|
|
149
|
-
|
|
149
|
+
function MarkdownDslComponent({
|
|
150
|
+
content,
|
|
151
|
+
className,
|
|
152
|
+
style
|
|
153
|
+
}) {
|
|
154
|
+
return /* @__PURE__ */ jsx4(MarkdownRenderer, { content: content ?? "", className, style });
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
// src/register.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pactor-app/markdown",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Pactor Markdown module: safe Markdown renderer (react-markdown AST, no raw HTML) and DSL Markdown component adapter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pactor",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"rehype-katex": "^7.0.1",
|
|
51
51
|
"remark-gfm": "^4.0.1",
|
|
52
52
|
"remark-math": "^6.0.0",
|
|
53
|
-
"@pactor-app/core": "
|
|
53
|
+
"@pactor-app/core": "1.0.0"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": ">=18"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"jsdom": "^30.0.1",
|
|
65
65
|
"react": "^19.2.8",
|
|
66
66
|
"react-dom": "^19.2.8",
|
|
67
|
-
"@pactor-app/runtime": "
|
|
67
|
+
"@pactor-app/runtime": "1.0.0"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "tsup",
|