Skip to content

Commit 69c1328

Browse files
misc ref
1 parent 23fe0db commit 69c1328

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

src/js/term.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {getEventTarget, isCustom} from './utils';
22

33
const Selector = {
4-
CUT: '.yfm .yfm-term',
54
TITLE: '.yfm .yfm-term_title',
65
CONTENT: '.yfm .yfm-term_dfn',
76
};

src/scss/_term.scss

+11-7
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414

1515
&_dfn {
1616
position: absolute;
17-
top: 25px;
18-
left: 0;
1917
z-index: 1000;
2018

2119
max-width: 450px;
2220
width: max-content;
2321

22+
visibility: hidden;
23+
opacity: 0;
24+
2425
padding: 10px;
2526

26-
border-radius: 4px;
2727
background-color: rgb(255, 255, 255);
28-
visibility: hidden;
29-
opacity: 0;
30-
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
31-
outline: none;
3228

29+
color: rgba(0, 0, 0, 0.85);
30+
font-size: 14px;
31+
line-height: 20px;
3332
font-style: normal;
3433

34+
border-radius: 4px;
35+
36+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
37+
outline: none;
38+
3539
&::before {
3640
content: '';
3741
position: absolute;

src/transform/plugins/code.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,15 @@ function termReplace(str: string, env: EnvTerm): string {
6262
`<i class="yfm yfm-term_title" term-key=":${p3}" id="${generateID()}">${p1}</i>`,
6363
);
6464

65-
return termCode;
65+
return termCode || str;
6666
}
6767

6868
const code: MarkdownItPluginCb = (md) => {
6969
const superCodeRenderer = md.renderer.rules.fence;
7070
md.renderer.rules.fence = function (tokens, idx, options, env, self) {
7171
const superCode = superCodeRenderer?.(tokens, idx, options, env, self);
72-
const superCodeWithTerms = superCode && termReplace(superCode, env);
72+
const superCodeWithTerms =
73+
superCode && env?.terms?.length ? termReplace(superCode, env) : superCode;
7374

7475
return wrapInClipboard(superCodeWithTerms, idx);
7576
};

test/term.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ const transformYfm = (text: string, path?: string) => {
1919
return html;
2020
};
2121

22-
function clearRandomId(str: string) {
22+
const clearRandomId = (str: string) => {
2323
const clearRandomId = new RegExp(/<([i\s]+).*?id="([^"]*?)".*?>(.+?)/, 'g');
2424
const randomId = clearRandomId.exec(str);
2525

2626
return randomId ? str.replace(randomId[2], '') : str;
27-
}
27+
};
2828

2929
describe('Terms', () => {
3030
test('Should create term in text with definition template', () => {

0 commit comments

Comments
 (0)