@valkyrianlabs/payload-markdown 1.3.1
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 +222 -0
- package/dist/blocks/MarkdownBlock/Component.d.ts +2 -0
- package/dist/blocks/MarkdownBlock/Component.js +13 -0
- package/dist/blocks/MarkdownBlock/Component.js.map +1 -0
- package/dist/blocks/MarkdownBlock/config.d.ts +2 -0
- package/dist/blocks/MarkdownBlock/config.js +20 -0
- package/dist/blocks/MarkdownBlock/config.js.map +1 -0
- package/dist/blocks/MarkdownBlock/types.d.js +3 -0
- package/dist/blocks/MarkdownBlock/types.d.js.map +1 -0
- package/dist/components/MarkdownRenderer/Component.client.d.ts +5 -0
- package/dist/components/MarkdownRenderer/Component.client.js +163 -0
- package/dist/components/MarkdownRenderer/Component.client.js.map +1 -0
- package/dist/components/MarkdownRenderer/Component.d.ts +3 -0
- package/dist/components/MarkdownRenderer/Component.js +87 -0
- package/dist/components/MarkdownRenderer/Component.js.map +1 -0
- package/dist/components/MarkdownRenderer/index.css +69 -0
- package/dist/components/MarkdownRenderer/index.module.css +45 -0
- package/dist/components/MarkdownRenderer/index.module.scss +43 -0
- package/dist/components/MarkdownRenderer/index.scss +83 -0
- package/dist/components/MarkdownRenderer/types.d.js +5 -0
- package/dist/components/MarkdownRenderer/types.d.js.map +1 -0
- package/dist/core/codeConfig.d.ts +6 -0
- package/dist/core/codeConfig.js +45 -0
- package/dist/core/codeConfig.js.map +1 -0
- package/dist/core/codeToHtml.d.ts +5 -0
- package/dist/core/codeToHtml.js +180 -0
- package/dist/core/codeToHtml.js.map +1 -0
- package/dist/core/plugins/rehypeApplyLayoutClasses.d.ts +4 -0
- package/dist/core/plugins/rehypeApplyLayoutClasses.js +72 -0
- package/dist/core/plugins/rehypeApplyLayoutClasses.js.map +1 -0
- package/dist/core/plugins/rehypeStripAuthoredInlineStyles.d.ts +3 -0
- package/dist/core/plugins/rehypeStripAuthoredInlineStyles.js +17 -0
- package/dist/core/plugins/rehypeStripAuthoredInlineStyles.js.map +1 -0
- package/dist/core/plugins/remarkCompileLayouts.d.ts +3 -0
- package/dist/core/plugins/remarkCompileLayouts.js +169 -0
- package/dist/core/plugins/remarkCompileLayouts.js.map +1 -0
- package/dist/core/plugins/remarkHeadingAnchorsAndToc.d.ts +3 -0
- package/dist/core/plugins/remarkHeadingAnchorsAndToc.js +68 -0
- package/dist/core/plugins/remarkHeadingAnchorsAndToc.js.map +1 -0
- package/dist/core/plugins/remarkLayoutDirectives.d.ts +3 -0
- package/dist/core/plugins/remarkLayoutDirectives.js +26 -0
- package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -0
- package/dist/core/plugins/remarkLayoutSentinels.d.ts +3 -0
- package/dist/core/plugins/remarkLayoutSentinels.js +184 -0
- package/dist/core/plugins/remarkLayoutSentinels.js.map +1 -0
- package/dist/core/plugins/remarkLiftLayoutDirectives.d.ts +3 -0
- package/dist/core/plugins/remarkLiftLayoutDirectives.js +93 -0
- package/dist/core/plugins/remarkLiftLayoutDirectives.js.map +1 -0
- package/dist/core/plugins/remarkNormalizeLayoutSyntax.d.ts +3 -0
- package/dist/core/plugins/remarkValidateDirectiveThemes.d.ts +4 -0
- package/dist/core/plugins/remarkValidateDirectiveThemes.js +28 -0
- package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -0
- package/dist/core/renderMarkdown.d.ts +2 -0
- package/dist/core/renderMarkdown.js +270 -0
- package/dist/core/renderMarkdown.js.map +1 -0
- package/dist/core/types.d.js +7 -0
- package/dist/core/types.d.js.map +1 -0
- package/dist/core/types.d.ts +238 -0
- package/dist/core/types.js +5 -0
- package/dist/core/types.js.map +1 -0
- package/dist/directives/attributes.d.ts +14 -0
- package/dist/directives/attributes.js +121 -0
- package/dist/directives/attributes.js.map +1 -0
- package/dist/directives/definitions/callout.d.ts +6 -0
- package/dist/directives/definitions/callout.js +107 -0
- package/dist/directives/definitions/callout.js.map +1 -0
- package/dist/directives/definitions/card.d.ts +4 -0
- package/dist/directives/definitions/card.js +120 -0
- package/dist/directives/definitions/card.js.map +1 -0
- package/dist/directives/definitions/cards.d.ts +7 -0
- package/dist/directives/definitions/cards.js +72 -0
- package/dist/directives/definitions/cards.js.map +1 -0
- package/dist/directives/definitions/cell.d.ts +4 -0
- package/dist/directives/definitions/cell.js +44 -0
- package/dist/directives/definitions/cell.js.map +1 -0
- package/dist/directives/definitions/columns.d.ts +4 -0
- package/dist/directives/definitions/columns.js +89 -0
- package/dist/directives/definitions/columns.js.map +1 -0
- package/dist/directives/definitions/details.d.ts +2 -0
- package/dist/directives/definitions/details.js +76 -0
- package/dist/directives/definitions/details.js.map +1 -0
- package/dist/directives/definitions/section.d.ts +2 -0
- package/dist/directives/definitions/section.js +32 -0
- package/dist/directives/definitions/section.js.map +1 -0
- package/dist/directives/definitions/steps.d.ts +2 -0
- package/dist/directives/definitions/steps.js +242 -0
- package/dist/directives/definitions/steps.js.map +1 -0
- package/dist/directives/definitions/tab.d.ts +8 -0
- package/dist/directives/definitions/tab.js +59 -0
- package/dist/directives/definitions/tab.js.map +1 -0
- package/dist/directives/definitions/tabs.d.ts +2 -0
- package/dist/directives/definitions/tabs.js +197 -0
- package/dist/directives/definitions/tabs.js.map +1 -0
- package/dist/directives/definitions/toc.d.ts +7 -0
- package/dist/directives/definitions/toc.js +59 -0
- package/dist/directives/definitions/toc.js.map +1 -0
- package/dist/directives/diagnostics.d.ts +8 -0
- package/dist/directives/diagnostics.js +167 -0
- package/dist/directives/diagnostics.js.map +1 -0
- package/dist/directives/headingAnchors.d.ts +9 -0
- package/dist/directives/headingAnchors.js +54 -0
- package/dist/directives/headingAnchors.js.map +1 -0
- package/dist/directives/index.d.ts +5 -0
- package/dist/directives/index.js +6 -0
- package/dist/directives/index.js.map +1 -0
- package/dist/directives/registry.d.ts +20 -0
- package/dist/directives/registry.js +152 -0
- package/dist/directives/registry.js.map +1 -0
- package/dist/directives/renderData.d.ts +3 -0
- package/dist/directives/renderData.js +11 -0
- package/dist/directives/renderData.js.map +1 -0
- package/dist/directives/themes.d.ts +25 -0
- package/dist/directives/themes.js +274 -0
- package/dist/directives/themes.js.map +1 -0
- package/dist/directives/types.d.ts +72 -0
- package/dist/directives/types.js +3 -0
- package/dist/directives/types.js.map +1 -0
- package/dist/editor/MarkdownCodeMirror/Component.client.d.ts +8 -0
- package/dist/editor/MarkdownCodeMirror/Component.client.js +78 -0
- package/dist/editor/MarkdownCodeMirror/Component.client.js.map +1 -0
- package/dist/editor/MarkdownCodeMirror/Component.d.ts +9 -0
- package/dist/editor/MarkdownCodeMirror/Component.js +10 -0
- package/dist/editor/MarkdownCodeMirror/Component.js.map +1 -0
- package/dist/editor/MarkdownCodeMirror.d.ts +8 -0
- package/dist/editor/MarkdownCodeMirror.js +74 -0
- package/dist/editor/MarkdownCodeMirror.js.map +1 -0
- package/dist/editor/MarkdownEditor.d.ts +10 -0
- package/dist/editor/MarkdownEditor.js +22 -0
- package/dist/editor/MarkdownEditor.js.map +1 -0
- package/dist/editor/directives/completions.d.ts +5 -0
- package/dist/editor/directives/completions.js +93 -0
- package/dist/editor/directives/completions.js.map +1 -0
- package/dist/editor/directives/diagnostics.d.ts +1 -0
- package/dist/editor/directives/diagnostics.js +12 -0
- package/dist/editor/directives/diagnostics.js.map +1 -0
- package/dist/editor/themes/payload.d.ts +27 -0
- package/dist/editor/themes/payload.js +269 -0
- package/dist/editor/themes/payload.js.map +1 -0
- package/dist/editor/themes/support/highlighters.d.ts +20 -0
- package/dist/editor/themes/support/highlighters.js +1141 -0
- package/dist/editor/themes/support/highlighters.js.map +1 -0
- package/dist/editor/themes/support/lang.d.ts +40 -0
- package/dist/editor/themes/support/lang.js +201 -0
- package/dist/editor/themes/support/lang.js.map +1 -0
- package/dist/exports/advanced.d.ts +3 -0
- package/dist/exports/advanced.js +5 -0
- package/dist/exports/advanced.js.map +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +2 -0
- package/dist/exports/client.js.map +1 -0
- package/dist/exports/server.d.ts +3 -0
- package/dist/exports/server.js +5 -0
- package/dist/exports/server.js.map +1 -0
- package/dist/field/BlocksParams/config.d.ts +7 -0
- package/dist/field/BlocksParams/config.js +149 -0
- package/dist/field/BlocksParams/config.js.map +1 -0
- package/dist/field/CodeBlock/config.d.ts +7 -0
- package/dist/field/CodeBlock/config.js +321 -0
- package/dist/field/CodeBlock/config.js.map +1 -0
- package/dist/field/CodeBlockConfig/config.d.ts +7 -0
- package/dist/field/CodeBlockConfig/config.js +306 -0
- package/dist/field/CodeBlockConfig/config.js.map +1 -0
- package/dist/field/CodeBlockParams/config.d.ts +7 -0
- package/dist/field/CodeBlockParams/config.js +321 -0
- package/dist/field/CodeBlockParams/config.js.map +1 -0
- package/dist/field/Config/config.d.ts +7 -0
- package/dist/field/Config/config.js +149 -0
- package/dist/field/Config/config.js.map +1 -0
- package/dist/field/MarkdownField/Component.d.ts +2 -0
- package/dist/field/MarkdownField/Component.js +42 -0
- package/dist/field/MarkdownField/Component.js.map +1 -0
- package/dist/field/MarkdownField/config.d.ts +3 -0
- package/dist/field/MarkdownField/config.js +20 -0
- package/dist/field/MarkdownField/config.js.map +1 -0
- package/dist/field/Tailwind/config.d.ts +9 -0
- package/dist/field/Tailwind/config.js +13 -0
- package/dist/field/Tailwind/config.js.map +1 -0
- package/dist/field/TailwindField/config.d.ts +9 -0
- package/dist/field/TailwindField/config.js +13 -0
- package/dist/field/TailwindField/config.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/runtime/index.d.ts +36 -0
- package/dist/runtime/index.js +124 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/styles/directiveSurface.d.ts +11 -0
- package/dist/styles/directiveSurface.js +38 -0
- package/dist/styles/directiveSurface.js.map +1 -0
- package/dist/types/core.d.ts +285 -0
- package/dist/types/core.js +5 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/layoutToken.d.ts +1 -0
- package/dist/types/layoutToken.js +3 -0
- package/dist/types/layoutToken.js.map +1 -0
- package/dist/types/mdast.d.js +5 -0
- package/dist/types/mdast.d.js.map +1 -0
- package/dist/types.d.js +3 -0
- package/dist/types.d.js.map +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +181 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function stripEnclosingBraces(value) {
|
|
2
|
+
const trimmed = value.trim();
|
|
3
|
+
if (!trimmed) return {
|
|
4
|
+
value: '',
|
|
5
|
+
warnings: []
|
|
6
|
+
};
|
|
7
|
+
if (trimmed.startsWith('{') && trimmed.endsWith('}')) return {
|
|
8
|
+
value: trimmed.slice(1, -1).trim(),
|
|
9
|
+
warnings: []
|
|
10
|
+
};
|
|
11
|
+
if (trimmed.startsWith('{') || trimmed.endsWith('}')) return {
|
|
12
|
+
value: trimmed.replace(/^\{/, '').replace(/\}$/, '').trim(),
|
|
13
|
+
warnings: [
|
|
14
|
+
'Malformed directive attributes: braces must be balanced.'
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
value: trimmed,
|
|
19
|
+
warnings: []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function stripQuotes(value) {
|
|
23
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
function tokenizeAttributes(value) {
|
|
27
|
+
const tokens = [];
|
|
28
|
+
const warnings = [];
|
|
29
|
+
let current = '';
|
|
30
|
+
let quote = null;
|
|
31
|
+
for (const char of value){
|
|
32
|
+
if ((char === '"' || char === "'") && quote === null) {
|
|
33
|
+
quote = char;
|
|
34
|
+
current += char;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (char === quote) {
|
|
38
|
+
quote = null;
|
|
39
|
+
current += char;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (/\s/.test(char) && quote === null) {
|
|
43
|
+
if (current) tokens.push(current);
|
|
44
|
+
current = '';
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
current += char;
|
|
48
|
+
}
|
|
49
|
+
if (current) tokens.push(current);
|
|
50
|
+
if (quote) warnings.push('Malformed directive attributes: quoted value is not closed.');
|
|
51
|
+
return {
|
|
52
|
+
tokens,
|
|
53
|
+
warnings
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function appendClassName(attributes, className) {
|
|
57
|
+
const existing = typeof attributes.class === 'string' ? attributes.class : '';
|
|
58
|
+
attributes.class = [
|
|
59
|
+
existing,
|
|
60
|
+
className
|
|
61
|
+
].filter(Boolean).join(' ');
|
|
62
|
+
}
|
|
63
|
+
export function parseDirectiveAttributesDetailed(value = '') {
|
|
64
|
+
const stripped = stripEnclosingBraces(value);
|
|
65
|
+
const warnings = [
|
|
66
|
+
...stripped.warnings
|
|
67
|
+
];
|
|
68
|
+
if (!stripped.value) return {
|
|
69
|
+
attributes: {},
|
|
70
|
+
warnings
|
|
71
|
+
};
|
|
72
|
+
const attributes = {};
|
|
73
|
+
const tokenized = tokenizeAttributes(stripped.value);
|
|
74
|
+
warnings.push(...tokenized.warnings);
|
|
75
|
+
for (const token of tokenized.tokens){
|
|
76
|
+
if (token.startsWith('#') && token.length > 1) {
|
|
77
|
+
attributes.id = token.slice(1);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (token.startsWith('.') && token.length > 1) {
|
|
81
|
+
appendClassName(attributes, token.slice(1));
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const equalIndex = token.indexOf('=');
|
|
85
|
+
if (equalIndex < 0) {
|
|
86
|
+
attributes[token] = true;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const key = token.slice(0, equalIndex);
|
|
90
|
+
const rawValue = token.slice(equalIndex + 1);
|
|
91
|
+
if (!key) continue;
|
|
92
|
+
if (key === 'class') appendClassName(attributes, stripQuotes(rawValue));
|
|
93
|
+
else attributes[key] = stripQuotes(rawValue);
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
attributes,
|
|
97
|
+
warnings
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export function parseDirectiveAttributes(value = '') {
|
|
101
|
+
return parseDirectiveAttributesDetailed(value).attributes;
|
|
102
|
+
}
|
|
103
|
+
export function parseDirectiveLine(text) {
|
|
104
|
+
const trimmed = text.trim();
|
|
105
|
+
if (!trimmed.startsWith(':::')) return null;
|
|
106
|
+
const body = trimmed.slice(3);
|
|
107
|
+
if (!body) return null;
|
|
108
|
+
const firstWhitespaceIndex = body.search(/\s/);
|
|
109
|
+
const name = firstWhitespaceIndex < 0 ? body : body.slice(0, firstWhitespaceIndex);
|
|
110
|
+
if (!/^[\w-]+$/.test(name)) return null;
|
|
111
|
+
const rawAttributes = firstWhitespaceIndex < 0 ? undefined : body.slice(firstWhitespaceIndex).trim();
|
|
112
|
+
const attributes = parseDirectiveAttributesDetailed(rawAttributes);
|
|
113
|
+
return {
|
|
114
|
+
name,
|
|
115
|
+
attributes: attributes.attributes,
|
|
116
|
+
rawAttributes,
|
|
117
|
+
warnings: attributes.warnings
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/directives/attributes.ts"],"sourcesContent":["export type DirectiveAttributeValue = boolean | string\n\nexport type DirectiveAttributes = Record<string, DirectiveAttributeValue>\n\nexport type ParsedDirectiveLine = {\n attributes: DirectiveAttributes\n name: string\n rawAttributes?: string\n warnings: string[]\n}\n\ntype TokenizeAttributesResult = {\n tokens: string[]\n warnings: string[]\n}\n\nfunction stripEnclosingBraces(value: string): { value: string; warnings: string[] } {\n const trimmed = value.trim()\n\n if (!trimmed) return { value: '', warnings: [] }\n\n if (trimmed.startsWith('{') && trimmed.endsWith('}'))\n return { value: trimmed.slice(1, -1).trim(), warnings: [] }\n\n if (trimmed.startsWith('{') || trimmed.endsWith('}'))\n return {\n value: trimmed.replace(/^\\{/, '').replace(/\\}$/, '').trim(),\n warnings: ['Malformed directive attributes: braces must be balanced.'],\n }\n\n return { value: trimmed, warnings: [] }\n}\n\nfunction stripQuotes(value: string): string {\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n )\n return value.slice(1, -1)\n\n return value\n}\n\nfunction tokenizeAttributes(value: string): TokenizeAttributesResult {\n const tokens: string[] = []\n const warnings: string[] = []\n let current = ''\n let quote: \"'\" | '\"' | null = null\n\n for (const char of value) {\n if ((char === '\"' || char === \"'\") && quote === null) {\n quote = char\n current += char\n continue\n }\n\n if (char === quote) {\n quote = null\n current += char\n continue\n }\n\n if (/\\s/.test(char) && quote === null) {\n if (current) tokens.push(current)\n current = ''\n continue\n }\n\n current += char\n }\n\n if (current) tokens.push(current)\n if (quote) warnings.push('Malformed directive attributes: quoted value is not closed.')\n\n return { tokens, warnings }\n}\n\nfunction appendClassName(attributes: DirectiveAttributes, className: string) {\n const existing = typeof attributes.class === 'string' ? attributes.class : ''\n attributes.class = [existing, className].filter(Boolean).join(' ')\n}\n\nexport function parseDirectiveAttributesDetailed(value = ''): {\n attributes: DirectiveAttributes\n warnings: string[]\n} {\n const stripped = stripEnclosingBraces(value)\n const warnings = [...stripped.warnings]\n\n if (!stripped.value)\n return {\n attributes: {},\n warnings,\n }\n\n const attributes: DirectiveAttributes = {}\n const tokenized = tokenizeAttributes(stripped.value)\n warnings.push(...tokenized.warnings)\n\n for (const token of tokenized.tokens) {\n if (token.startsWith('#') && token.length > 1) {\n attributes.id = token.slice(1)\n continue\n }\n\n if (token.startsWith('.') && token.length > 1) {\n appendClassName(attributes, token.slice(1))\n continue\n }\n\n const equalIndex = token.indexOf('=')\n\n if (equalIndex < 0) {\n attributes[token] = true\n continue\n }\n\n const key = token.slice(0, equalIndex)\n const rawValue = token.slice(equalIndex + 1)\n\n if (!key) continue\n\n if (key === 'class') appendClassName(attributes, stripQuotes(rawValue))\n else attributes[key] = stripQuotes(rawValue)\n }\n\n return {\n attributes,\n warnings,\n }\n}\n\nexport function parseDirectiveAttributes(value = ''): DirectiveAttributes {\n return parseDirectiveAttributesDetailed(value).attributes\n}\n\nexport function parseDirectiveLine(text: string): null | ParsedDirectiveLine {\n const trimmed = text.trim()\n\n if (!trimmed.startsWith(':::')) return null\n\n const body = trimmed.slice(3)\n if (!body) return null\n\n const firstWhitespaceIndex = body.search(/\\s/)\n const name = firstWhitespaceIndex < 0 ? body : body.slice(0, firstWhitespaceIndex)\n\n if (!/^[\\w-]+$/.test(name)) return null\n\n const rawAttributes =\n firstWhitespaceIndex < 0 ? undefined : body.slice(firstWhitespaceIndex).trim()\n\n const attributes = parseDirectiveAttributesDetailed(rawAttributes)\n\n return {\n name,\n attributes: attributes.attributes,\n rawAttributes,\n warnings: attributes.warnings,\n }\n}\n"],"names":["stripEnclosingBraces","value","trimmed","trim","warnings","startsWith","endsWith","slice","replace","stripQuotes","tokenizeAttributes","tokens","current","quote","char","test","push","appendClassName","attributes","className","existing","class","filter","Boolean","join","parseDirectiveAttributesDetailed","stripped","tokenized","token","length","id","equalIndex","indexOf","key","rawValue","parseDirectiveAttributes","parseDirectiveLine","text","body","firstWhitespaceIndex","search","name","rawAttributes","undefined"],"mappings":"AAgBA,SAASA,qBAAqBC,KAAa;IACzC,MAAMC,UAAUD,MAAME,IAAI;IAE1B,IAAI,CAACD,SAAS,OAAO;QAAED,OAAO;QAAIG,UAAU,EAAE;IAAC;IAE/C,IAAIF,QAAQG,UAAU,CAAC,QAAQH,QAAQI,QAAQ,CAAC,MAC9C,OAAO;QAAEL,OAAOC,QAAQK,KAAK,CAAC,GAAG,CAAC,GAAGJ,IAAI;QAAIC,UAAU,EAAE;IAAC;IAE5D,IAAIF,QAAQG,UAAU,CAAC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,MAAM,OAAO;IAElB,MAAMC,uBAAuBD,KAAKE,MAAM,CAAC;IACzC,MAAMC,OAAOF,uBAAuB,IAAID,OAAOA,KAAK/B,KAAK,CAAC,GAAGgC;IAE7D,IAAI,CAAC,WAAWxB,IAAI,CAAC0B,OAAO,OAAO;IAEnC,MAAMC,gBACJH,uBAAuB,IAAII,YAAYL,KAAK/B,KAAK,CAACgC,sBAAsBpC,IAAI;IAE9E,MAAMe,aAAaO,iCAAiCiB;IAEpD,OAAO;QACLD;QACAvB,YAAYA,WAAWA,UAAU;QACjCwB;QACAtC,UAAUc,WAAWd,QAAQ;IAC/B;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ContainerDirective } from 'mdast-util-directive';
|
|
2
|
+
import type { LayoutDirectiveDefinition } from '../types.js';
|
|
3
|
+
export declare const CALLOUT_VARIANTS: readonly ["note", "info", "tip", "warning", "danger", "success"];
|
|
4
|
+
export type CalloutVariant = (typeof CALLOUT_VARIANTS)[number];
|
|
5
|
+
export declare function resolveCalloutVariant(node: ContainerDirective): CalloutVariant;
|
|
6
|
+
export declare const calloutDirective: LayoutDirectiveDefinition;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { resolveDirectiveTheme } from '../themes.js';
|
|
2
|
+
export const CALLOUT_VARIANTS = [
|
|
3
|
+
'note',
|
|
4
|
+
'info',
|
|
5
|
+
'tip',
|
|
6
|
+
'warning',
|
|
7
|
+
'danger',
|
|
8
|
+
'success'
|
|
9
|
+
];
|
|
10
|
+
const calloutVariantClasses = {
|
|
11
|
+
danger: 'bg-red-500/10 text-red-50',
|
|
12
|
+
info: 'bg-sky-500/10 text-sky-50',
|
|
13
|
+
note: 'bg-slate-500/10 text-slate-50',
|
|
14
|
+
success: 'bg-emerald-500/10 text-emerald-50',
|
|
15
|
+
tip: 'bg-cyan-500/10 text-cyan-50',
|
|
16
|
+
warning: 'bg-amber-500/10 text-amber-50'
|
|
17
|
+
};
|
|
18
|
+
function isCalloutVariant(value) {
|
|
19
|
+
return typeof value === 'string' && CALLOUT_VARIANTS.includes(value);
|
|
20
|
+
}
|
|
21
|
+
export function resolveCalloutVariant(node) {
|
|
22
|
+
const variant = node.attributes?.variant;
|
|
23
|
+
return isCalloutVariant(variant) ? variant : 'note';
|
|
24
|
+
}
|
|
25
|
+
function getTitle(node) {
|
|
26
|
+
const title = node.attributes?.title;
|
|
27
|
+
return typeof title === 'string' && title.trim() ? title.trim() : undefined;
|
|
28
|
+
}
|
|
29
|
+
export const calloutDirective = {
|
|
30
|
+
name: 'callout',
|
|
31
|
+
allowedAttributes: [
|
|
32
|
+
'theme',
|
|
33
|
+
'title',
|
|
34
|
+
'variant'
|
|
35
|
+
],
|
|
36
|
+
applyHast (node, config, { mergeClassNames }) {
|
|
37
|
+
const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note';
|
|
38
|
+
const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined;
|
|
39
|
+
const theme = resolveDirectiveTheme('callout', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft', config.themes);
|
|
40
|
+
const children = node.children;
|
|
41
|
+
node.properties.dataTheme = theme.name;
|
|
42
|
+
node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes, calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note']);
|
|
43
|
+
node.children = [
|
|
44
|
+
...title ? [
|
|
45
|
+
{
|
|
46
|
+
type: 'element',
|
|
47
|
+
children: [
|
|
48
|
+
{
|
|
49
|
+
type: 'text',
|
|
50
|
+
value: title
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
properties: {
|
|
54
|
+
className: [
|
|
55
|
+
'mb-2 text-sm font-semibold tracking-wide'
|
|
56
|
+
],
|
|
57
|
+
dataDirectiveTitle: 'callout'
|
|
58
|
+
},
|
|
59
|
+
tagName: 'div'
|
|
60
|
+
}
|
|
61
|
+
] : [],
|
|
62
|
+
{
|
|
63
|
+
type: 'element',
|
|
64
|
+
children,
|
|
65
|
+
properties: {
|
|
66
|
+
className: [
|
|
67
|
+
'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'
|
|
68
|
+
],
|
|
69
|
+
dataDirectiveBody: 'callout'
|
|
70
|
+
},
|
|
71
|
+
tagName: 'div'
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
},
|
|
75
|
+
defaultAttributes: {
|
|
76
|
+
variant: 'note'
|
|
77
|
+
},
|
|
78
|
+
description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',
|
|
79
|
+
editor: {
|
|
80
|
+
detail: 'Static directive',
|
|
81
|
+
label: 'Callout',
|
|
82
|
+
snippet: ':::callout {variant="${variant}" title="${Title}"}\n${Content}\n:::\n${}'
|
|
83
|
+
},
|
|
84
|
+
getMdastRenderProperties (node) {
|
|
85
|
+
return {
|
|
86
|
+
dataDirective: 'callout',
|
|
87
|
+
dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',
|
|
88
|
+
dataTitle: getTitle(node),
|
|
89
|
+
dataVariant: resolveCalloutVariant(node)
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
kind: 'callout',
|
|
93
|
+
openMarker: ':::callout',
|
|
94
|
+
public: true,
|
|
95
|
+
supportsAttributes: true,
|
|
96
|
+
tagName: 'div',
|
|
97
|
+
themeAttributes: {
|
|
98
|
+
theme: 'callout'
|
|
99
|
+
},
|
|
100
|
+
validateAttributes ({ attributes }) {
|
|
101
|
+
const warnings = [];
|
|
102
|
+
if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant)) warnings.push(`Unsupported callout variant "${attributes.variant}". Falling back to "note".`);
|
|
103
|
+
return warnings;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=callout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/callout.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CALLOUT_VARIANTS = [\n 'note',\n 'info',\n 'tip',\n 'warning',\n 'danger',\n 'success',\n] as const\n\nexport type CalloutVariant = (typeof CALLOUT_VARIANTS)[number]\n\nconst calloutVariantClasses: Record<CalloutVariant, string> = {\n danger: 'bg-red-500/10 text-red-50',\n info: 'bg-sky-500/10 text-sky-50',\n note: 'bg-slate-500/10 text-slate-50',\n success: 'bg-emerald-500/10 text-emerald-50',\n tip: 'bg-cyan-500/10 text-cyan-50',\n warning: 'bg-amber-500/10 text-amber-50',\n}\n\nfunction isCalloutVariant(value: unknown): value is CalloutVariant {\n return typeof value === 'string' && CALLOUT_VARIANTS.includes(value as CalloutVariant)\n}\n\nexport function resolveCalloutVariant(node: ContainerDirective): CalloutVariant {\n const variant = node.attributes?.variant\n\n return isCalloutVariant(variant) ? variant : 'note'\n}\n\nfunction getTitle(node: ContainerDirective): string | undefined {\n const title = node.attributes?.title\n\n return typeof title === 'string' && title.trim() ? title.trim() : undefined\n}\n\nexport const calloutDirective: LayoutDirectiveDefinition = {\n name: 'callout',\n allowedAttributes: ['theme', 'title', 'variant'],\n applyHast(node, config, { mergeClassNames }) {\n const variant = typeof node.properties.dataVariant === 'string' ? node.properties.dataVariant : 'note'\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n const theme = resolveDirectiveTheme(\n 'callout',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : 'soft',\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n calloutVariantClasses[isCalloutVariant(variant) ? variant : 'note'],\n )\n\n node.children = [\n ...(title\n ? [\n {\n type: 'element' as const,\n children: [{ type: 'text' as const, value: title }],\n properties: {\n className: ['mb-2 text-sm font-semibold tracking-wide'],\n dataDirectiveTitle: 'callout',\n },\n tagName: 'div',\n },\n ]\n : []),\n {\n type: 'element',\n children,\n properties: {\n className: ['space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'],\n dataDirectiveBody: 'callout',\n },\n tagName: 'div',\n },\n ]\n },\n defaultAttributes: {\n variant: 'note',\n },\n description: 'Emphasized content block with note, info, tip, warning, danger, or success variants.',\n editor: {\n detail: 'Static directive',\n label: 'Callout',\n snippet: ':::callout {variant=\"${variant}\" title=\"${Title}\"}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'callout',\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'soft',\n dataTitle: getTitle(node),\n dataVariant: resolveCalloutVariant(node),\n }\n },\n kind: 'callout',\n openMarker: ':::callout',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'callout',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.variant === 'string' && !isCalloutVariant(attributes.variant))\n warnings.push(\n `Unsupported callout variant \"${attributes.variant}\". Falling back to \"note\".`,\n )\n\n return warnings\n },\n}\n"],"names":["resolveDirectiveTheme","CALLOUT_VARIANTS","calloutVariantClasses","danger","info","note","success","tip","warning","isCalloutVariant","value","includes","resolveCalloutVariant","node","variant","attributes","getTitle","title","trim","undefined","calloutDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataVariant","dataTitle","theme","dataTheme","themes","children","className","hookClassName","modifierClassName","classes","type","dataDirectiveTitle","tagName","dataDirectiveBody","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,mBAAmB;IAC9B;IACA;IACA;IACA;IACA;IACA;CACD,CAAS;AAIV,MAAMC,wBAAwD;IAC5DC,QAAQ;I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,MAAM;4BAAiB3B,OAAOO;wBAAM;qBAAE;oBACnDS,YAAY;wBACVO,WAAW;4BAAC;yBAA2C;wBACvDK,oBAAoB;oBACtB;oBACAC,SAAS;gBACX;aACD,GACD,EAAE;YACN;gBACEF,MAAM;gBACNL;gBACAN,YAAY;oBACVO,WAAW;wBAAC;qBAAuD;oBACnEO,mBAAmB;gBACrB;gBACAD,SAAS;YACX;SACD;IACH;IACAE,mBAAmB;QACjB3B,SAAS;IACX;IACA4B,aAAa;IACbC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBlC,IAAI;QAC3B,OAAO;YACLmC,eAAe;YACflB,WAAW,OAAOjB,KAAKE,UAAU,EAAEc,UAAU,WAAWhB,KAAKE,UAAU,CAACc,KAAK,GAAG;YAChFD,WAAWZ,SAASH;YACpBc,aAAaf,sBAAsBC;QACrC;IACF;IACAoC,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBb,SAAS;IACTc,iBAAiB;QACfxB,OAAO;IACT;IACAyB,oBAAmB,EAAEvC,UAAU,EAAE;QAC/B,MAAMwC,WAAqB,EAAE;QAE7B,IAAI,OAAOxC,WAAWD,OAAO,KAAK,YAAY,CAACL,iBAAiBM,WAAWD,OAAO,GAChFyC,SAASC,IAAI,CACX,CAAC,6BAA6B,EAAEzC,WAAWD,OAAO,CAAC,0BAA0B,CAAC;QAGlF,OAAOyC;IACT;AACF,EAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LayoutDirectiveDefinition } from '../types.js';
|
|
2
|
+
export declare const CARD_BODY_CLASS_NAMES = "space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0";
|
|
3
|
+
export declare const CARD_TITLE_CLASS_NAMES = "mb-3 text-lg font-semibold tracking-tight";
|
|
4
|
+
export declare const cardDirective: LayoutDirectiveDefinition;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { resolveDirectiveTheme } from '../themes.js';
|
|
2
|
+
export const CARD_BODY_CLASS_NAMES = 'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0';
|
|
3
|
+
export const CARD_TITLE_CLASS_NAMES = 'mb-3 text-lg font-semibold tracking-tight';
|
|
4
|
+
function getAttribute(node, name) {
|
|
5
|
+
const value = node.attributes?.[name];
|
|
6
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
7
|
+
}
|
|
8
|
+
function makeTitle(title, href) {
|
|
9
|
+
const children = href ? [
|
|
10
|
+
{
|
|
11
|
+
type: 'element',
|
|
12
|
+
children: [
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
value: title
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
properties: {
|
|
19
|
+
href
|
|
20
|
+
},
|
|
21
|
+
tagName: 'a'
|
|
22
|
+
}
|
|
23
|
+
] : [
|
|
24
|
+
{
|
|
25
|
+
type: 'text',
|
|
26
|
+
value: title
|
|
27
|
+
}
|
|
28
|
+
];
|
|
29
|
+
return {
|
|
30
|
+
type: 'element',
|
|
31
|
+
children,
|
|
32
|
+
properties: {
|
|
33
|
+
className: [
|
|
34
|
+
CARD_TITLE_CLASS_NAMES
|
|
35
|
+
],
|
|
36
|
+
dataDirectiveTitle: 'card'
|
|
37
|
+
},
|
|
38
|
+
tagName: 'h3'
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function makeEyebrow(eyebrow) {
|
|
42
|
+
return {
|
|
43
|
+
type: 'element',
|
|
44
|
+
children: [
|
|
45
|
+
{
|
|
46
|
+
type: 'text',
|
|
47
|
+
value: eyebrow
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
properties: {
|
|
51
|
+
className: [
|
|
52
|
+
'mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground'
|
|
53
|
+
],
|
|
54
|
+
dataDirectiveEyebrow: 'card'
|
|
55
|
+
},
|
|
56
|
+
tagName: 'p'
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export const cardDirective = {
|
|
60
|
+
name: 'card',
|
|
61
|
+
allowedAttributes: [
|
|
62
|
+
'eyebrow',
|
|
63
|
+
'href',
|
|
64
|
+
'theme',
|
|
65
|
+
'title'
|
|
66
|
+
],
|
|
67
|
+
applyHast (node, config, { mergeClassNames }) {
|
|
68
|
+
const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined;
|
|
69
|
+
const href = typeof node.properties.dataHref === 'string' ? node.properties.dataHref : undefined;
|
|
70
|
+
const eyebrow = typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined;
|
|
71
|
+
const theme = resolveDirectiveTheme('card', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
|
|
72
|
+
const children = node.children;
|
|
73
|
+
node.properties.dataTheme = theme.name;
|
|
74
|
+
node.properties.className = mergeClassNames('not-prose', theme.hookClassName, theme.modifierClassName, theme.classes);
|
|
75
|
+
node.children = [
|
|
76
|
+
...eyebrow ? [
|
|
77
|
+
makeEyebrow(eyebrow)
|
|
78
|
+
] : [],
|
|
79
|
+
...title ? [
|
|
80
|
+
makeTitle(title, href)
|
|
81
|
+
] : [],
|
|
82
|
+
{
|
|
83
|
+
type: 'element',
|
|
84
|
+
children,
|
|
85
|
+
properties: {
|
|
86
|
+
className: [
|
|
87
|
+
CARD_BODY_CLASS_NAMES
|
|
88
|
+
],
|
|
89
|
+
dataDirectiveBody: 'card'
|
|
90
|
+
},
|
|
91
|
+
tagName: 'div'
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
},
|
|
95
|
+
description: 'Card content block with optional title, eyebrow, and title link.',
|
|
96
|
+
editor: {
|
|
97
|
+
detail: 'Layout directive',
|
|
98
|
+
label: 'Card',
|
|
99
|
+
snippet: ':::card {title="${Title}"}\n${Content}\n:::\n${}'
|
|
100
|
+
},
|
|
101
|
+
getMdastRenderProperties (node) {
|
|
102
|
+
return {
|
|
103
|
+
dataDirective: 'card',
|
|
104
|
+
dataEyebrow: getAttribute(node, 'eyebrow'),
|
|
105
|
+
dataHref: getAttribute(node, 'href'),
|
|
106
|
+
dataTheme: getAttribute(node, 'theme'),
|
|
107
|
+
dataTitle: getAttribute(node, 'title')
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
kind: 'card',
|
|
111
|
+
openMarker: ':::card',
|
|
112
|
+
public: true,
|
|
113
|
+
supportsAttributes: true,
|
|
114
|
+
tagName: 'article',
|
|
115
|
+
themeAttributes: {
|
|
116
|
+
theme: 'card'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=card.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/card.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CARD_BODY_CLASS_NAMES = 'space-y-3 [&>:first-child]:mt-0 [&>:last-child]:mb-0'\nexport const CARD_TITLE_CLASS_NAMES = 'mb-3 text-lg font-semibold tracking-tight'\n\nfunction getAttribute(node: ContainerDirective, name: string): string | undefined {\n const value = node.attributes?.[name]\n\n return typeof value === 'string' && value.trim() ? value.trim() : undefined\n}\n\nfunction makeTitle(title: string, href?: string): Element {\n const children: ElementContent[] = href\n ? [\n {\n type: 'element',\n children: [{ type: 'text', value: title }],\n properties: {\n href,\n },\n tagName: 'a',\n },\n ]\n : [{ type: 'text', value: title }]\n\n return {\n type: 'element',\n children,\n properties: {\n className: [CARD_TITLE_CLASS_NAMES],\n dataDirectiveTitle: 'card',\n },\n tagName: 'h3',\n }\n}\n\nfunction makeEyebrow(eyebrow: string): Element {\n return {\n type: 'element',\n children: [{ type: 'text', value: eyebrow }],\n properties: {\n className: ['mb-2 text-xs font-semibold uppercase tracking-[0.18em] text-muted-foreground'],\n dataDirectiveEyebrow: 'card',\n },\n tagName: 'p',\n }\n}\n\nexport const cardDirective: LayoutDirectiveDefinition = {\n name: 'card',\n allowedAttributes: ['eyebrow', 'href', 'theme', 'title'],\n applyHast(node, config, { mergeClassNames }) {\n const title = typeof node.properties.dataTitle === 'string' ? node.properties.dataTitle : undefined\n const href = typeof node.properties.dataHref === 'string' ? node.properties.dataHref : undefined\n const eyebrow =\n typeof node.properties.dataEyebrow === 'string' ? node.properties.dataEyebrow : undefined\n const theme = resolveDirectiveTheme(\n 'card',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const children = node.children\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n )\n node.children = [\n ...(eyebrow ? [makeEyebrow(eyebrow)] : []),\n ...(title ? [makeTitle(title, href)] : []),\n {\n type: 'element',\n children,\n properties: {\n className: [CARD_BODY_CLASS_NAMES],\n dataDirectiveBody: 'card',\n },\n tagName: 'div',\n },\n ]\n },\n description: 'Card content block with optional title, eyebrow, and title link.',\n editor: {\n detail: 'Layout directive',\n label: 'Card',\n snippet: ':::card {title=\"${Title}\"}\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataDirective: 'card',\n dataEyebrow: getAttribute(node, 'eyebrow'),\n dataHref: getAttribute(node, 'href'),\n dataTheme: getAttribute(node, 'theme'),\n dataTitle: getAttribute(node, 'title'),\n }\n },\n kind: 'card',\n openMarker: ':::card',\n public: true,\n supportsAttributes: true,\n tagName: 'article',\n themeAttributes: {\n theme: 'card',\n },\n}\n"],"names":["resolveDirectiveTheme","CARD_BODY_CLASS_NAMES","CARD_TITLE_CLASS_NAMES","getAttribute","node","name","value","attributes","trim","undefined","makeTitle","title","href","children","type","properties","tagName","className","dataDirectiveTitle","makeEyebrow","eyebrow","dataDirectiveEyebrow","cardDirective","allowedAttributes","applyHast","config","mergeClassNames","dataTitle","dataHref","dataEyebrow","theme","dataTheme","themes","hookClassName","modifierClassName","classes","dataDirectiveBody","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","themeAttributes"],"mappings":"AAKA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,wBAAwB,uDAAsD;AAC3F,OAAO,MAAMC,yBAAyB,4CAA2C;AAEjF,SAASC,aAAaC,IAAwB,EAAEC,IAAY;IAC1D,MAAMC,QAAQF,KAAKG,UAAU,EAAE,CAACF,KAAK;IAErC,OAAO,OAAOC,UAAU,YAAYA,MAAME,IAAI,KAAKF,MAAME,IAAI,KAAKC;AACpE;AAEA,SAASC,UAAUC,KAAa,EAAEC,IAAa;IAC7C,MAAMC,WAA6BD,OAC/B;QACE;YACEE,MAAM;YACND,UAAU;gBAAC;oBAAEC,MAAM;oBAAQR,OAAOK;gBAAM;aAAE;YAC1CI,YAAY;gBACVH;YACF;YACAI,SAAS;QACX;KACD,GACD;QAAC;YAAEF,MAAM;YAAQR,OAAOK;QAAM;KAAE;IAEpC,OAAO;QACLG,MAAM;QACND;QACAE,YAAY;YACVE,WAAW;gBAACf;aAAuB;YACnCgB,oBAAoB;QACtB;QACAF,SAAS;IACX;AACF;AAEA,SAASG,YAAYC,OAAe;IAClC,OAAO;QACLN,MAAM;QACND,UAAU;YAAC;gBAAEC,MAAM;gBAAQR,OAAOc;YAAQ;SAAE;QAC5CL,YAAY;YACVE,WAAW;gBAAC;aAA+E;YAC3FI,sBAAsB;QACxB;QACAL,SAAS;IACX;AACF;AAEA,OAAO,MAAMM,gBAA2C;IACtDjB,MAAM;IACNkB,mBAAmB;QAAC;QAAW;QAAQ;QAAS;KAAQ;IACxDC,WAAUpB,IAAI,EAAEqB,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMf,QAAQ,OAAOP,KAAKW,UAAU,CAACY,SAAS,KAAK,WAAWvB,KAAKW,UAAU,CAACY,SAAS,GAAGlB;QAC1F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
+
import type { LayoutDirectiveDefinition } from '../types.js';
|
|
3
|
+
export declare const CARD_GRID_COLUMNS: readonly ["1", "2", "3", "4", "auto"];
|
|
4
|
+
export declare const DEFAULT_CARD_GRID_COLUMNS = "3";
|
|
5
|
+
export type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number];
|
|
6
|
+
export declare function resolveCardGridColumns(node: ContainerDirective): CardGridColumns;
|
|
7
|
+
export declare const cardsDirective: LayoutDirectiveDefinition;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { resolveDirectiveTheme } from '../themes.js';
|
|
2
|
+
export const CARD_GRID_COLUMNS = [
|
|
3
|
+
'1',
|
|
4
|
+
'2',
|
|
5
|
+
'3',
|
|
6
|
+
'4',
|
|
7
|
+
'auto'
|
|
8
|
+
];
|
|
9
|
+
export const DEFAULT_CARD_GRID_COLUMNS = '3';
|
|
10
|
+
const cardGridColumnClasses = {
|
|
11
|
+
'1': 'grid-cols-1',
|
|
12
|
+
'2': 'grid-cols-1 md:grid-cols-2',
|
|
13
|
+
'3': 'grid-cols-1 md:grid-cols-3',
|
|
14
|
+
'4': 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4',
|
|
15
|
+
auto: 'grid-cols-1 md:grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]'
|
|
16
|
+
};
|
|
17
|
+
function isCardGridColumns(value) {
|
|
18
|
+
return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value);
|
|
19
|
+
}
|
|
20
|
+
export function resolveCardGridColumns(node) {
|
|
21
|
+
const columns = node.attributes?.columns;
|
|
22
|
+
return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS;
|
|
23
|
+
}
|
|
24
|
+
export const cardsDirective = {
|
|
25
|
+
name: 'cards',
|
|
26
|
+
allowedAttributes: [
|
|
27
|
+
'cardTheme',
|
|
28
|
+
'columns',
|
|
29
|
+
'theme'
|
|
30
|
+
],
|
|
31
|
+
applyHast (node, config, { mergeClassNames }) {
|
|
32
|
+
const columns = typeof node.properties.dataColumns === 'string' ? node.properties.dataColumns : DEFAULT_CARD_GRID_COLUMNS;
|
|
33
|
+
const theme = resolveDirectiveTheme('cards', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
|
|
34
|
+
const cardTheme = typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined;
|
|
35
|
+
for (const child of node.children)if (child.type === 'element' && child.properties?.dataVlLayout === 'card' && typeof child.properties.dataTheme !== 'string' && cardTheme) child.properties.dataTheme = cardTheme;
|
|
36
|
+
node.properties.dataTheme = theme.name;
|
|
37
|
+
node.properties.className = mergeClassNames('not-prose my-8 grid gap-4', theme.hookClassName, theme.modifierClassName, theme.classes, cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS]);
|
|
38
|
+
},
|
|
39
|
+
defaultAttributes: {
|
|
40
|
+
columns: DEFAULT_CARD_GRID_COLUMNS
|
|
41
|
+
},
|
|
42
|
+
description: 'Responsive card grid for docs and landing-page content.',
|
|
43
|
+
editor: {
|
|
44
|
+
detail: 'Layout directive',
|
|
45
|
+
label: 'Cards',
|
|
46
|
+
snippet: ':::cards {columns="${3}"}\n\n:::card {title="${Title}"}\n${Content}\n:::\n\n:::card {title="${Title}"}\n${Content}\n:::\n\n:::\n${}'
|
|
47
|
+
},
|
|
48
|
+
getMdastRenderProperties (node) {
|
|
49
|
+
return {
|
|
50
|
+
dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,
|
|
51
|
+
dataColumns: resolveCardGridColumns(node),
|
|
52
|
+
dataDirective: 'cards',
|
|
53
|
+
dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default'
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
kind: 'cards',
|
|
57
|
+
openMarker: ':::cards',
|
|
58
|
+
public: true,
|
|
59
|
+
supportsAttributes: true,
|
|
60
|
+
tagName: 'section',
|
|
61
|
+
themeAttributes: {
|
|
62
|
+
cardTheme: 'card',
|
|
63
|
+
theme: 'cards'
|
|
64
|
+
},
|
|
65
|
+
validateAttributes ({ attributes }) {
|
|
66
|
+
const warnings = [];
|
|
67
|
+
if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns)) warnings.push(`Invalid cards columns "${attributes.columns}". Falling back to "${DEFAULT_CARD_GRID_COLUMNS}".`);
|
|
68
|
+
return warnings;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=cards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/cards.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { LayoutDirectiveDefinition } from '../types.js'\n\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const CARD_GRID_COLUMNS = ['1', '2', '3', '4', 'auto'] as const\nexport const DEFAULT_CARD_GRID_COLUMNS = '3'\n\nexport type CardGridColumns = (typeof CARD_GRID_COLUMNS)[number]\n\nconst cardGridColumnClasses: Record<CardGridColumns, string> = {\n '1': 'grid-cols-1',\n '2': 'grid-cols-1 md:grid-cols-2',\n '3': 'grid-cols-1 md:grid-cols-3',\n '4': 'grid-cols-1 sm:grid-cols-2 xl:grid-cols-4',\n auto: 'grid-cols-1 md:grid-cols-[repeat(auto-fit,minmax(16rem,1fr))]',\n}\n\nfunction isCardGridColumns(value: unknown): value is CardGridColumns {\n return typeof value === 'string' && CARD_GRID_COLUMNS.includes(value as CardGridColumns)\n}\n\nexport function resolveCardGridColumns(node: ContainerDirective): CardGridColumns {\n const columns = node.attributes?.columns\n\n return isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS\n}\n\nexport const cardsDirective: LayoutDirectiveDefinition = {\n name: 'cards',\n allowedAttributes: ['cardTheme', 'columns', 'theme'],\n applyHast(node, config, { mergeClassNames }) {\n const columns =\n typeof node.properties.dataColumns === 'string'\n ? node.properties.dataColumns\n : DEFAULT_CARD_GRID_COLUMNS\n const theme = resolveDirectiveTheme(\n 'cards',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n const cardTheme =\n typeof node.properties.dataCardTheme === 'string' ? node.properties.dataCardTheme : undefined\n\n for (const child of node.children)\n if (\n child.type === 'element' &&\n child.properties?.dataVlLayout === 'card' &&\n typeof child.properties.dataTheme !== 'string' &&\n cardTheme\n )\n child.properties.dataTheme = cardTheme\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n 'not-prose my-8 grid gap-4',\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n cardGridColumnClasses[isCardGridColumns(columns) ? columns : DEFAULT_CARD_GRID_COLUMNS],\n )\n },\n defaultAttributes: {\n columns: DEFAULT_CARD_GRID_COLUMNS,\n },\n description: 'Responsive card grid for docs and landing-page content.',\n editor: {\n detail: 'Layout directive',\n label: 'Cards',\n snippet:\n ':::cards {columns=\"${3}\"}\\n\\n:::card {title=\"${Title}\"}\\n${Content}\\n:::\\n\\n:::card {title=\"${Title}\"}\\n${Content}\\n:::\\n\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataCardTheme: typeof node.attributes?.cardTheme === 'string' ? node.attributes.cardTheme : undefined,\n dataColumns: resolveCardGridColumns(node),\n dataDirective: 'cards',\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cards',\n openMarker: ':::cards',\n public: true,\n supportsAttributes: true,\n tagName: 'section',\n themeAttributes: {\n cardTheme: 'card',\n theme: 'cards',\n },\n validateAttributes({ attributes }) {\n const warnings: string[] = []\n\n if (typeof attributes.columns === 'string' && !isCardGridColumns(attributes.columns))\n warnings.push(\n `Invalid cards columns \"${attributes.columns}\". Falling back to \"${DEFAULT_CARD_GRID_COLUMNS}\".`,\n )\n\n return warnings\n },\n}\n"],"names":["resolveDirectiveTheme","CARD_GRID_COLUMNS","DEFAULT_CARD_GRID_COLUMNS","cardGridColumnClasses","auto","isCardGridColumns","value","includes","resolveCardGridColumns","node","columns","attributes","cardsDirective","name","allowedAttributes","applyHast","config","mergeClassNames","properties","dataColumns","theme","dataTheme","undefined","themes","cardTheme","dataCardTheme","child","children","type","dataVlLayout","className","hookClassName","modifierClassName","classes","defaultAttributes","description","editor","detail","label","snippet","getMdastRenderProperties","dataDirective","kind","openMarker","public","supportsAttributes","tagName","themeAttributes","validateAttributes","warnings","push"],"mappings":"AAIA,SAASA,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,oBAAoB;IAAC;IAAK;IAAK;IAAK;IAAK;CAAO,CAAS;AACtE,OAAO,MAAMC,4BAA4B,IAAG;AAI5C,MAAMC,wBAAyD;IAC7D,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACLC,MAAM;AACR;AAEA,SAASC,kBAAkBC,KAAc;IACvC,OAAO,OAAOA,UAAU,YAAYL,kBAAkBM,QAAQ,CAACD;AACjE;AAEA,OAAO,SAASE,uBAAuBC,IAAwB;IAC7D,MAAMC,UAAUD,KAAKE,UAAU,EAAED;IAEjC,OAAOL,kBAAkBK,WAAWA,UAAUR;AAChD;AAEA,OAAO,MAAMU,iBAA4C;IACvDC,MAAM;IACNC,mBAAmB;QAAC;QAAa;QAAW;KAAQ;IACpDC,WAAUN,IAAI,EAAEO,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMP,UACJ,OAAOD,KAAKS,UAAU,CAACC,WAAW,KAAK,WACnCV,KAAKS,UAAU,CAACC,WAAW,GAC3BjB;QACN,MAAMkB,QAAQpB,sBACZ,SACA,OAAOS,KAAKS,UAAU,CAACG,SAAS,KAAK,WAAWZ,KAAKS,UAAU,CAACG,SAAS,GAAGC,WAC5EN,OAAOO,MAAM;QAEf,MAAMC,YACJ,OAAOf,KAAKS,UAAU,CAACO,aAAa,KAAK,WAAWhB,KAAKS,UAAU,CAACO,aAAa,GAAGH;QAEtF,KAAK,MAA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
|
2
|
+
import type { DirectiveChild, LayoutDirectiveDefinition } from '../types.js';
|
|
3
|
+
export declare const cellDirective: LayoutDirectiveDefinition;
|
|
4
|
+
export declare function makeCellDirective(children: DirectiveChild[]): ContainerDirective;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { setDirectiveRenderData } from '../renderData.js';
|
|
2
|
+
import { resolveDirectiveTheme } from '../themes.js';
|
|
3
|
+
export const cellDirective = {
|
|
4
|
+
name: 'cell',
|
|
5
|
+
allowedAttributes: [
|
|
6
|
+
'theme'
|
|
7
|
+
],
|
|
8
|
+
applyHast (node, config, { mergeClassNames }) {
|
|
9
|
+
const theme = resolveDirectiveTheme('cell', typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined, config.themes);
|
|
10
|
+
node.properties.dataTheme = theme.name;
|
|
11
|
+
node.properties.className = mergeClassNames(theme.hookClassName, theme.modifierClassName, theme.classes, config.columnClassName);
|
|
12
|
+
},
|
|
13
|
+
editor: {
|
|
14
|
+
detail: 'Layout directive',
|
|
15
|
+
label: 'Layout cell',
|
|
16
|
+
snippet: ':::cell\n${Content}\n:::\n${}'
|
|
17
|
+
},
|
|
18
|
+
getMdastRenderProperties (node) {
|
|
19
|
+
return {
|
|
20
|
+
dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default'
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
kind: 'cell',
|
|
24
|
+
openMarker: ':::cell',
|
|
25
|
+
public: true,
|
|
26
|
+
supportsAttributes: true,
|
|
27
|
+
tagName: 'div',
|
|
28
|
+
themeAttributes: {
|
|
29
|
+
theme: 'cell'
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export function makeCellDirective(children) {
|
|
33
|
+
const node = {
|
|
34
|
+
name: 'cell',
|
|
35
|
+
type: 'containerDirective',
|
|
36
|
+
attributes: {},
|
|
37
|
+
children,
|
|
38
|
+
data: {}
|
|
39
|
+
};
|
|
40
|
+
setDirectiveRenderData(node, cellDirective);
|
|
41
|
+
return node;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=cell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/directives/definitions/cell.ts"],"sourcesContent":["import type { ContainerDirective } from 'mdast-util-directive'\n\nimport type { DirectiveChild, LayoutDirectiveDefinition } from '../types.js'\n\nimport { setDirectiveRenderData } from '../renderData.js'\nimport { resolveDirectiveTheme } from '../themes.js'\n\nexport const cellDirective: LayoutDirectiveDefinition = {\n name: 'cell',\n allowedAttributes: ['theme'],\n applyHast(node, config, { mergeClassNames }) {\n const theme = resolveDirectiveTheme(\n 'cell',\n typeof node.properties.dataTheme === 'string' ? node.properties.dataTheme : undefined,\n config.themes,\n )\n\n node.properties.dataTheme = theme.name\n node.properties.className = mergeClassNames(\n theme.hookClassName,\n theme.modifierClassName,\n theme.classes,\n config.columnClassName,\n )\n },\n editor: {\n detail: 'Layout directive',\n label: 'Layout cell',\n snippet: ':::cell\\n${Content}\\n:::\\n${}',\n },\n getMdastRenderProperties(node) {\n return {\n dataTheme: typeof node.attributes?.theme === 'string' ? node.attributes.theme : 'default',\n }\n },\n kind: 'cell',\n openMarker: ':::cell',\n public: true,\n supportsAttributes: true,\n tagName: 'div',\n themeAttributes: {\n theme: 'cell',\n },\n}\n\nexport function makeCellDirective(children: DirectiveChild[]): ContainerDirective {\n const node: ContainerDirective = {\n name: 'cell',\n type: 'containerDirective',\n attributes: {},\n children,\n data: {},\n }\n\n setDirectiveRenderData(node, cellDirective)\n\n return node\n}\n"],"names":["setDirectiveRenderData","resolveDirectiveTheme","cellDirective","name","allowedAttributes","applyHast","node","config","mergeClassNames","theme","properties","dataTheme","undefined","themes","className","hookClassName","modifierClassName","classes","columnClassName","editor","detail","label","snippet","getMdastRenderProperties","attributes","kind","openMarker","public","supportsAttributes","tagName","themeAttributes","makeCellDirective","children","type","data"],"mappings":"AAIA,SAASA,sBAAsB,QAAQ,mBAAkB;AACzD,SAASC,qBAAqB,QAAQ,eAAc;AAEpD,OAAO,MAAMC,gBAA2C;IACtDC,MAAM;IACNC,mBAAmB;QAAC;KAAQ;IAC5BC,WAAUC,IAAI,EAAEC,MAAM,EAAE,EAAEC,eAAe,EAAE;QACzC,MAAMC,QAAQR,sBACZ,QACA,OAAOK,KAAKI,UAAU,CAACC,SAAS,KAAK,WAAWL,KAAKI,UAAU,CAACC,SAAS,GAAGC,WAC5EL,OAAOM,MAAM;QAGfP,KAAKI,UAAU,CAACC,SAAS,GAAGF,MAAMN,IAAI;QACtCG,KAAKI,UAAU,CAACI,SAAS,GAAGN,gBAC1BC,MAAMM,aAAa,EACnBN,MAAMO,iBAAiB,EACvBP,MAAMQ,OAAO,EACbV,OAAOW,eAAe;IAE1B;IACAC,QAAQ;QACNC,QAAQ;QACRC,OAAO;QACPC,SAAS;IACX;IACAC,0BAAyBjB,IAAI;QAC3B,OAAO;YACLK,WAAW,OAAOL,KAAKkB,UAAU,EAAEf,UAAU,WAAWH,KAAKkB,UAAU,CAACf,KAAK,GAAG;QAClF;IACF;IACAgB,MAAM;IACNC,YAAY;IACZC,QAAQ;IACRC,oBAAoB;IACpBC,SAAS;IACTC,iBAAiB;QACfrB,OAAO;IACT;AACF,EAAC;AAED,OAAO,SAASsB,kBAAkBC,QAA0B;IAC1D,MAAM1B,OAA2B;QAC/BH,MAAM;QACN8B,MAAM;QACNT,YAAY,CAAC;QACbQ;QACAE,MAAM,CAAC;IACT;IAEAlC,uBAAuBM,MAAMJ;IAE7B,OAAOI;AACT"}
|