@gsa-tts/graymatter-ui 1.3.0 → 2.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.
@@ -1,55 +0,0 @@
1
- import { visit } from 'unist-util-visit';
2
- import type { Root } from 'mdast';
3
- import type { Code } from 'mdast';
4
- import type { Parent } from 'unist';
5
-
6
- /**
7
- * MDX-specific node type for JSX flow elements
8
- */
9
- interface MdxJsxFlowElement extends Parent {
10
- type: 'mdxJsxFlowElement';
11
- name: string;
12
- attributes?: Array<{
13
- type: 'mdxJsxAttribute';
14
- name: string;
15
- value: string;
16
- }>;
17
- }
18
-
19
- /**
20
- * Remark plugin to wrap code blocks in a div with className 'ai-code-block-wrapper'
21
- *
22
- * This enables the copy button functionality for code blocks in documentation.
23
- *
24
- * @returns A remark plugin function
25
- */
26
- export function remarkWrapPre() {
27
- return (tree: Root) => {
28
- visit(
29
- tree,
30
- 'code',
31
- (node: Code, index: number | undefined, parent: Parent | undefined) => {
32
- if (
33
- node.type === 'code' &&
34
- typeof index === 'number' &&
35
- parent &&
36
- 'children' in parent
37
- ) {
38
- const wrapper: MdxJsxFlowElement = {
39
- type: 'mdxJsxFlowElement',
40
- name: 'div',
41
- attributes: [
42
- {
43
- type: 'mdxJsxAttribute',
44
- name: 'className',
45
- value: 'ai-code-block-wrapper',
46
- },
47
- ],
48
- children: [node],
49
- };
50
- parent.children.splice(index, 1, wrapper);
51
- }
52
- }
53
- );
54
- };
55
- }