@ant-design/x-markdown-mini 0.1.0-beta.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/LICENSE +21 -0
- package/README.md +216 -0
- package/dist/components/Markdown/index.acss +103 -0
- package/dist/components/Markdown/index.axml +12 -0
- package/dist/components/Markdown/index.js +93 -0
- package/dist/components/Markdown/index.json +7 -0
- package/dist/components/MiniNodeRenderer/index.acss +11 -0
- package/dist/components/MiniNodeRenderer/index.axml +113 -0
- package/dist/components/MiniNodeRenderer/index.js +37 -0
- package/dist/components/MiniNodeRenderer/index.json +7 -0
- package/dist/components/MiniNodeRenderer/index.sjs +63 -0
- package/dist/es/Markdown/index.acss +103 -0
- package/dist/es/Markdown/index.axml +12 -0
- package/dist/es/Markdown/index.js +93 -0
- package/dist/es/Markdown/index.json +7 -0
- package/dist/es/MiniNodeRenderer/index.acss +11 -0
- package/dist/es/MiniNodeRenderer/index.axml +113 -0
- package/dist/es/MiniNodeRenderer/index.js +37 -0
- package/dist/es/MiniNodeRenderer/index.json +7 -0
- package/dist/es/MiniNodeRenderer/index.sjs +63 -0
- package/dist/index.d.mts +508 -0
- package/dist/index.d.ts +508 -0
- package/dist/index.js +3151 -0
- package/dist/index.mjs +3111 -0
- package/dist/miniprogram_dist/components/Markdown/index.js +85 -0
- package/dist/miniprogram_dist/components/Markdown/index.json +10 -0
- package/dist/miniprogram_dist/components/Markdown/index.wxml +11 -0
- package/dist/miniprogram_dist/components/Markdown/index.wxss +103 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.js +39 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.json +10 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxml +112 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxs +40 -0
- package/dist/miniprogram_dist/components/MiniNodeRenderer/index.wxss +11 -0
- package/dist/miniprogram_dist/es/Markdown/index.js +85 -0
- package/dist/miniprogram_dist/es/Markdown/index.json +10 -0
- package/dist/miniprogram_dist/es/Markdown/index.wxml +11 -0
- package/dist/miniprogram_dist/es/Markdown/index.wxss +103 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.js +39 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.json +10 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxml +112 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxs +40 -0
- package/dist/miniprogram_dist/es/MiniNodeRenderer/index.wxss +11 -0
- package/dist/miniprogram_dist/index.js +3151 -0
- package/dist/miniprogram_dist/plugins/CodeHighlight/index.js +8038 -0
- package/dist/miniprogram_dist/plugins/CodeHighlight/style.wxss +105 -0
- package/dist/miniprogram_dist/plugins/Latex/index.js +14728 -0
- package/dist/miniprogram_dist/plugins/Latex/style.wxss +648 -0
- package/dist/miniprogram_dist/shared/flattenInline.js +100 -0
- package/dist/plugins/CodeHighlight/index.d.mts +27 -0
- package/dist/plugins/CodeHighlight/index.d.ts +27 -0
- package/dist/plugins/CodeHighlight/index.js +8038 -0
- package/dist/plugins/CodeHighlight/index.mjs +8028 -0
- package/dist/plugins/CodeHighlight/style.acss +105 -0
- package/dist/plugins/Latex/index.d.mts +12 -0
- package/dist/plugins/Latex/index.d.ts +12 -0
- package/dist/plugins/Latex/index.js +14728 -0
- package/dist/plugins/Latex/index.mjs +14705 -0
- package/dist/plugins/Latex/style.acss +648 -0
- package/dist/shared/flattenInline.js +100 -0
- package/dist/types-CegkonfJ.d.mts +83 -0
- package/dist/types-CegkonfJ.d.ts +83 -0
- package/package.json +93 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var flattenInline_exports = {};
|
|
20
|
+
__export(flattenInline_exports, {
|
|
21
|
+
flattenInlineNodes: () => flattenInlineNodes
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(flattenInline_exports);
|
|
24
|
+
function flattenInlineNodes(nodes) {
|
|
25
|
+
return nodes.map(walk);
|
|
26
|
+
}
|
|
27
|
+
const INLINE_TAGS = {
|
|
28
|
+
strong: true,
|
|
29
|
+
em: true,
|
|
30
|
+
del: true,
|
|
31
|
+
code: true,
|
|
32
|
+
span: true
|
|
33
|
+
};
|
|
34
|
+
const TAG_CLASS = {
|
|
35
|
+
strong: "md-strong",
|
|
36
|
+
em: "md-em",
|
|
37
|
+
del: "md-del",
|
|
38
|
+
code: "md-inline-code"
|
|
39
|
+
// 'span' 不附加额外 class
|
|
40
|
+
};
|
|
41
|
+
function walk(node) {
|
|
42
|
+
if (!node.children || node.children.length === 0) return node;
|
|
43
|
+
if (node.name === "a") {
|
|
44
|
+
return { ...node, children: flattenChildren(node.children) };
|
|
45
|
+
}
|
|
46
|
+
return { ...node, children: flattenChildren(node.children) };
|
|
47
|
+
}
|
|
48
|
+
function flattenChildren(children) {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const c of children) {
|
|
51
|
+
flattenOne(c, "", out);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
function flattenOne(n, classChain, out) {
|
|
56
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
57
|
+
if (n.name === "text") {
|
|
58
|
+
const value = (_b = (_a = n.attrs) == null ? void 0 : _a.value) != null ? _b : "";
|
|
59
|
+
if (!value) return;
|
|
60
|
+
const merged = mergeClass(classChain, (_c = n.attrs) == null ? void 0 : _c.class);
|
|
61
|
+
out.push({ name: "text", attrs: merged ? { value, class: merged } : { value } });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (n.name === "br") {
|
|
65
|
+
out.push({ name: "br", attrs: {} });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (n.name === "a") {
|
|
69
|
+
out.push({ ...n, children: flattenChildren((_d = n.children) != null ? _d : []) });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (n.name === "img") {
|
|
73
|
+
out.push(n);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (INLINE_TAGS[n.name]) {
|
|
77
|
+
const next = mergeClass(
|
|
78
|
+
classChain,
|
|
79
|
+
(_e = n.attrs) == null ? void 0 : _e.class,
|
|
80
|
+
(_f = TAG_CLASS[n.name]) != null ? _f : ""
|
|
81
|
+
);
|
|
82
|
+
for (const c of (_g = n.children) != null ? _g : []) flattenOne(c, next, out);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
out.push(walk(n));
|
|
86
|
+
}
|
|
87
|
+
function mergeClass(...parts) {
|
|
88
|
+
const seen = /* @__PURE__ */ new Set();
|
|
89
|
+
for (const p of parts) {
|
|
90
|
+
if (!p) continue;
|
|
91
|
+
for (const tok of p.split(/\s+/)) {
|
|
92
|
+
if (tok) seen.add(tok);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return Array.from(seen).join(" ");
|
|
96
|
+
}
|
|
97
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
+
0 && (module.exports = {
|
|
99
|
+
flattenInlineNodes
|
|
100
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LanguageFn } from 'highlight.js';
|
|
2
|
+
import { X as XMarkdownExtension } from '../../types-CegkonfJ.mjs';
|
|
3
|
+
import 'marked';
|
|
4
|
+
|
|
5
|
+
interface CodeHighlightOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Map of language registrations. Keys are language names (or aliases),
|
|
8
|
+
* values are the language definition modules from highlight.js.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import javascript from 'highlight.js/lib/languages/javascript';
|
|
13
|
+
* import python from 'highlight.js/lib/languages/python';
|
|
14
|
+
* CodeHighlight({ languages: { javascript, python } })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* When omitted, all commonly-used languages are registered automatically.
|
|
18
|
+
*/
|
|
19
|
+
languages?: Record<string, LanguageFn>;
|
|
20
|
+
/** Options forwarded to hljs.highlight(). */
|
|
21
|
+
hljsOptions?: {
|
|
22
|
+
ignoreIllegals?: boolean;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
declare function CodeHighlight(options?: CodeHighlightOptions): XMarkdownExtension;
|
|
26
|
+
|
|
27
|
+
export { type CodeHighlightOptions, CodeHighlight as default };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LanguageFn } from 'highlight.js';
|
|
2
|
+
import { X as XMarkdownExtension } from '../../types-CegkonfJ.js';
|
|
3
|
+
import 'marked';
|
|
4
|
+
|
|
5
|
+
interface CodeHighlightOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Map of language registrations. Keys are language names (or aliases),
|
|
8
|
+
* values are the language definition modules from highlight.js.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import javascript from 'highlight.js/lib/languages/javascript';
|
|
13
|
+
* import python from 'highlight.js/lib/languages/python';
|
|
14
|
+
* CodeHighlight({ languages: { javascript, python } })
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* When omitted, all commonly-used languages are registered automatically.
|
|
18
|
+
*/
|
|
19
|
+
languages?: Record<string, LanguageFn>;
|
|
20
|
+
/** Options forwarded to hljs.highlight(). */
|
|
21
|
+
hljsOptions?: {
|
|
22
|
+
ignoreIllegals?: boolean;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
declare function CodeHighlight(options?: CodeHighlightOptions): XMarkdownExtension;
|
|
26
|
+
|
|
27
|
+
export { type CodeHighlightOptions, CodeHighlight as default };
|