Skip to content

Commit e8dda1c

Browse files
committed
优化FootnoteDefinition组件样式,添加导出图标并调整间距;更新CSS以支持响应式宽度
1 parent cc756c6 commit e8dda1c

File tree

8 files changed

+275
-25
lines changed

8 files changed

+275
-25
lines changed

src/MarkdownEditor/editor/elements/FootnoteDefinition.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useMemo } from 'react';
1+
import { ExportOutlined } from '@ant-design/icons';
2+
import React, { useMemo } from 'react';
23
import { Node } from 'slate';
34
import { ElementProps, FootnoteDefinitionNode } from '../../el';
45
import { useEditorStore } from '../store';
@@ -24,6 +25,7 @@ export const FootnoteDefinition = (
2425
fontSize: '12px',
2526
margin: '5px 0',
2627
display: 'flex',
28+
gap: 4,
2729
}}
2830
contentEditable={false}
2931
data-be={'footnoteDefinition'}
@@ -39,11 +41,17 @@ export const FootnoteDefinition = (
3941
style={{
4042
color: '#1677ff',
4143
textDecoration: 'none',
42-
marginLeft: '5px',
4344
cursor: 'pointer',
45+
display: 'flex',
46+
alignItems: 'center',
47+
gap: 2,
4448
}}
49+
target="_blank"
50+
rel="noopener noreferrer"
4551
>
4652
{props.children}
53+
54+
<ExportOutlined />
4755
</a>
4856
</div>
4957
);

src/MarkdownEditor/index.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
border: 1px solid #0000001a;
121121
margin-bottom: 0.5em;
122122
font-size: 14px;
123-
min-width: 320px;
123+
min-width: min(320px, 100%);
124124
}
125125

126126
.ace-container.frontmatter:before {

tests/demo/__snapshots__/src/MarkdownEditor/demos/FncTooltip.snap

+24-2
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,14 @@
455455
contenteditable="false"
456456
data-be="footnoteDefinition"
457457
data-slate-node="element"
458-
style="font-size: 12px; margin: 5px 0px; display: flex;"
458+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
459459
>
460460
1.
461461
<a
462462
href="#md-editor-ref1"
463-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
463+
rel="noopener noreferrer"
464+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
465+
target="_blank"
464466
>
465467
<span
466468
data-slate-node="text"
@@ -495,6 +497,26 @@
495497
</span>
496498
</span>
497499
</span>
500+
<span
501+
aria-label="export"
502+
class="anticon anticon-export"
503+
role="img"
504+
>
505+
<svg
506+
aria-hidden="true"
507+
data-icon="export"
508+
fill="currentColor"
509+
fill-rule="evenodd"
510+
focusable="false"
511+
height="1em"
512+
viewBox="64 64 896 896"
513+
width="1em"
514+
>
515+
<path
516+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
517+
/>
518+
</svg>
519+
</span>
498520
</a>
499521
</div>
500522
<div

tests/demo/__snapshots__/src/MarkdownEditor/demos/footnoteReference.snap

+48-4
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,14 @@
200200
contenteditable="false"
201201
data-be="footnoteDefinition"
202202
data-slate-node="element"
203-
style="font-size: 12px; margin: 5px 0px; display: flex;"
203+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
204204
>
205205
doc_0.
206206
<a
207207
href="#md-editor-refdoc_0"
208-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
208+
rel="noopener noreferrer"
209+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
210+
target="_blank"
209211
>
210212
<span
211213
data-slate-node="text"
@@ -225,19 +227,41 @@
225227
</span>
226228
</span>
227229
</span>
230+
<span
231+
aria-label="export"
232+
class="anticon anticon-export"
233+
role="img"
234+
>
235+
<svg
236+
aria-hidden="true"
237+
data-icon="export"
238+
fill="currentColor"
239+
fill-rule="evenodd"
240+
focusable="false"
241+
height="1em"
242+
viewBox="64 64 896 896"
243+
width="1em"
244+
>
245+
<path
246+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
247+
/>
248+
</svg>
249+
</span>
228250
</a>
229251
</div>
230252
<div
231253
class="ant-md-editor-drag-el empty"
232254
contenteditable="false"
233255
data-be="footnoteDefinition"
234256
data-slate-node="element"
235-
style="font-size: 12px; margin: 5px 0px; display: flex;"
257+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
236258
>
237259
doc_1.
238260
<a
239261
href="#md-editor-refdoc_1"
240-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
262+
rel="noopener noreferrer"
263+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
264+
target="_blank"
241265
>
242266
<span
243267
data-slate-node="text"
@@ -257,6 +281,26 @@
257281
</span>
258282
</span>
259283
</span>
284+
<span
285+
aria-label="export"
286+
class="anticon anticon-export"
287+
role="img"
288+
>
289+
<svg
290+
aria-hidden="true"
291+
data-icon="export"
292+
fill="currentColor"
293+
fill-rule="evenodd"
294+
focusable="false"
295+
height="1em"
296+
viewBox="64 64 896 896"
297+
width="1em"
298+
>
299+
<path
300+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
301+
/>
302+
</svg>
303+
</span>
260304
</a>
261305
</div>
262306
<div

tests/demo/__snapshots__/src/MarkdownEditor/demos/min-render.snap

+48-4
Original file line numberDiff line numberDiff line change
@@ -9695,12 +9695,14 @@
96959695
contenteditable="false"
96969696
data-be="footnoteDefinition"
96979697
data-slate-node="element"
9698-
style="font-size: 12px; margin: 5px 0px; display: flex;"
9698+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
96999699
>
97009700
1.
97019701
<a
97029702
href="#md-editor-ref1"
9703-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
9703+
rel="noopener noreferrer"
9704+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
9705+
target="_blank"
97049706
>
97059707
<span
97069708
data-slate-node="text"
@@ -9718,19 +9720,41 @@
97189720
</span>
97199721
</span>
97209722
</span>
9723+
<span
9724+
aria-label="export"
9725+
class="anticon anticon-export"
9726+
role="img"
9727+
>
9728+
<svg
9729+
aria-hidden="true"
9730+
data-icon="export"
9731+
fill="currentColor"
9732+
fill-rule="evenodd"
9733+
focusable="false"
9734+
height="1em"
9735+
viewBox="64 64 896 896"
9736+
width="1em"
9737+
>
9738+
<path
9739+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
9740+
/>
9741+
</svg>
9742+
</span>
97219743
</a>
97229744
</div>
97239745
<div
97249746
class="ant-md-editor-drag-el"
97259747
contenteditable="false"
97269748
data-be="footnoteDefinition"
97279749
data-slate-node="element"
9728-
style="font-size: 12px; margin: 5px 0px; display: flex;"
9750+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
97299751
>
97309752
2.
97319753
<a
97329754
href="#md-editor-ref2"
9733-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
9755+
rel="noopener noreferrer"
9756+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
9757+
target="_blank"
97349758
>
97359759
<span
97369760
data-slate-node="text"
@@ -9748,6 +9772,26 @@
97489772
</span>
97499773
</span>
97509774
</span>
9775+
<span
9776+
aria-label="export"
9777+
class="anticon anticon-export"
9778+
role="img"
9779+
>
9780+
<svg
9781+
aria-hidden="true"
9782+
data-icon="export"
9783+
fill="currentColor"
9784+
fill-rule="evenodd"
9785+
focusable="false"
9786+
height="1em"
9787+
viewBox="64 64 896 896"
9788+
width="1em"
9789+
>
9790+
<path
9791+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
9792+
/>
9793+
</svg>
9794+
</span>
97519795
</a>
97529796
</div>
97539797
</div>

tests/demo/__snapshots__/src/MarkdownEditor/demos/min.snap

+48-4
Original file line numberDiff line numberDiff line change
@@ -6855,12 +6855,14 @@
68556855
contenteditable="false"
68566856
data-be="footnoteDefinition"
68576857
data-slate-node="element"
6858-
style="font-size: 12px; margin: 5px 0px; display: flex;"
6858+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
68596859
>
68606860
1.
68616861
<a
68626862
href="#md-editor-ref1"
6863-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
6863+
rel="noopener noreferrer"
6864+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
6865+
target="_blank"
68646866
>
68656867
<span
68666868
data-slate-node="text"
@@ -6878,19 +6880,41 @@
68786880
</span>
68796881
</span>
68806882
</span>
6883+
<span
6884+
aria-label="export"
6885+
class="anticon anticon-export"
6886+
role="img"
6887+
>
6888+
<svg
6889+
aria-hidden="true"
6890+
data-icon="export"
6891+
fill="currentColor"
6892+
fill-rule="evenodd"
6893+
focusable="false"
6894+
height="1em"
6895+
viewBox="64 64 896 896"
6896+
width="1em"
6897+
>
6898+
<path
6899+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
6900+
/>
6901+
</svg>
6902+
</span>
68816903
</a>
68826904
</div>
68836905
<div
68846906
class="ant-md-editor-drag-el"
68856907
contenteditable="false"
68866908
data-be="footnoteDefinition"
68876909
data-slate-node="element"
6888-
style="font-size: 12px; margin: 5px 0px; display: flex;"
6910+
style="font-size: 12px; margin: 5px 0px; display: flex; gap: 4px;"
68896911
>
68906912
2.
68916913
<a
68926914
href="#md-editor-ref2"
6893-
style="color: rgb(22, 119, 255); text-decoration: none; margin-left: 5px; cursor: pointer;"
6915+
rel="noopener noreferrer"
6916+
style="color: rgb(22, 119, 255); text-decoration: none; cursor: pointer; display: flex; align-items: center; gap: 2px;"
6917+
target="_blank"
68946918
>
68956919
<span
68966920
data-slate-node="text"
@@ -6908,6 +6932,26 @@
69086932
</span>
69096933
</span>
69106934
</span>
6935+
<span
6936+
aria-label="export"
6937+
class="anticon anticon-export"
6938+
role="img"
6939+
>
6940+
<svg
6941+
aria-hidden="true"
6942+
data-icon="export"
6943+
fill="currentColor"
6944+
fill-rule="evenodd"
6945+
focusable="false"
6946+
height="1em"
6947+
viewBox="64 64 896 896"
6948+
width="1em"
6949+
>
6950+
<path
6951+
d="M880 912H144c-17.7 0-32-14.3-32-32V144c0-17.7 14.3-32 32-32h360c4.4 0 8 3.6 8 8v56c0 4.4-3.6 8-8 8H184v656h656V520c0-4.4 3.6-8 8-8h56c4.4 0 8 3.6 8 8v360c0 17.7-14.3 32-32 32zM770.87 199.13l-52.2-52.2a8.01 8.01 0 014.7-13.6l179.4-21c5.1-.6 9.5 3.7 8.9 8.9l-21 179.4c-.8 6.6-8.9 9.4-13.6 4.7l-52.4-52.4-256.2 256.2a8.03 8.03 0 01-11.3 0l-42.4-42.4a8.03 8.03 0 010-11.3l256.1-256.3z"
6952+
/>
6953+
</svg>
6954+
</span>
69116955
</a>
69126956
</div>
69136957
</div>

0 commit comments

Comments
 (0)