Skip to content

Commit d21f95c

Browse files
committed
Add withClass annotation
1 parent 0b106c2 commit d21f95c

File tree

3 files changed

+40
-109
lines changed

3 files changed

+40
-109
lines changed

packages/mdx/dev/content/comment-annotations.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,21 @@ function lorem(ipsum, dolor = 1) {
9393
return $sit and consectetur(ipsum) or []
9494
}
9595
```
96+
97+
With class
98+
99+
```js
100+
function lorem(ipsum, dolor = 1) {
101+
// withClass[15:19] annotation-class
102+
const sit = ipsum == null && 0
103+
// withClass(1:2) annotation-class
104+
dolor = sit - amet(dolor)
105+
return sit ? consectetur(ipsum) : []
106+
}
107+
108+
function adipiscing(...elit) {
109+
console.log("hover me")
110+
// withClass annotation-class
111+
return elit.map(ipsum => ipsum.sit)
112+
}
113+
```

packages/mdx/pages/styles.css

Lines changed: 2 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -33,113 +33,6 @@ div#__next > div {
3333
color: black;
3434
}
3535

36-
/*
37-
nav {
38-
height: 40px;
39-
overflow: hidden;
36+
.annotation-class span {
37+
text-decoration: line-through;
4038
}
41-
42-
main {
43-
flex: 1;
44-
overflow: auto;
45-
} */
46-
47-
/* main */
48-
/*
49-
.columns {
50-
display: flex;
51-
min-height: 100%;
52-
}
53-
54-
.column {
55-
margin-left: auto;
56-
margin-right: auto;
57-
flex: 1;
58-
box-sizing: border-box;
59-
padding: 0 6px 6px;
60-
min-width: 400px;
61-
max-width: 800px;
62-
}
63-
64-
.column > h2 {
65-
padding: 6px;
66-
margin: 0;
67-
text-align: center;
68-
font-size: 20px;
69-
color: #ccc;
70-
}
71-
72-
.column > .content {
73-
padding: 10px 18px;
74-
background-color: #fff;
75-
border-radius: 6px;
76-
}
77-
78-
79-
nav {
80-
display: flex;
81-
align-items: center;
82-
background-color: #222;
83-
color: #ccc;
84-
}
85-
86-
nav h1 {
87-
margin: 0 16px 0 24px;
88-
}
89-
nav h1 a {
90-
color: unset;
91-
text-decoration: none;
92-
}
93-
94-
nav .version {
95-
color: #aaa;
96-
font-size: 14px;
97-
}
98-
99-
.radio {
100-
text-align: center;
101-
border: 1px solid #222;
102-
border-radius: 4px;
103-
overflow: hidden;
104-
display: inline-block;
105-
vertical-align: middle;
106-
margin-left: 6px;
107-
}
108-
.radio button {
109-
border: none;
110-
background-color: #444;
111-
color: #ccc;
112-
height: 24px;
113-
}
114-
.radio button.selected {
115-
background-color: #fafafa;
116-
color: #222;
117-
}
118-
119-
nav label {
120-
margin-right: 24px;
121-
} */
122-
123-
/* nav select {
124-
margin-left: 6px;
125-
border-radius: 4px;
126-
background-color: #fafafa;
127-
height: 24px;
128-
} */
129-
130-
/* result */
131-
/*
132-
.result {
133-
min-width: 900px;
134-
width: 900px;
135-
max-width: 900px;
136-
}
137-
138-
pre.shiki {
139-
white-space: pre-wrap;
140-
}
141-
142-
.tailwind-font code {
143-
font-family: ui-monospace, SFMono-Regular, Consolas,
144-
"Liberation Mono", Menlo, monospace;
145-
} */

packages/mdx/src/mdx-client/annotations.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const annotationsMap: Record<
1515
label: Label,
1616
link: CodeLink,
1717
mark: Mark,
18+
withClass: WithClass,
1819
}
1920

2021
function Mark({
@@ -97,6 +98,25 @@ function Box({
9798
)
9899
}
99100

101+
function WithClass({
102+
children,
103+
data,
104+
style,
105+
theme,
106+
}: {
107+
data: any
108+
children: React.ReactNode
109+
style?: React.CSSProperties
110+
theme: any
111+
}) {
112+
const className = data as string
113+
return (
114+
<span style={style} className={className}>
115+
{children}
116+
</span>
117+
)
118+
}
119+
100120
function Background({
101121
children,
102122
data,

0 commit comments

Comments
 (0)