Skip to content

Commit dbbdd15

Browse files
committed
feat: add option to hide embed block border
1 parent 6179c14 commit dbbdd15

File tree

3 files changed

+40
-63
lines changed

3 files changed

+40
-63
lines changed

src/editor/embed.scss

Lines changed: 35 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,54 @@
11
@use '../utils.scss';
22

3-
@include utils.use-no-plugin('.embed-enable') {
4-
.cm-embed-block {
3+
body {
4+
--embed-background: var(--bg-editor);
5+
--embed-padding: var(--size-4-5) var(--size-4-4);
6+
--embed-block-shadow-hover: 0 0 0 1px var(--accent-inactive),
7+
inset 0 0 0 1px var(--accent-inactive);
8+
--embed-border-start: var(--size-2-1) solid var(--accent-inactive);
9+
--embed-border-end: var(--embed-border-start);
10+
--embed-border-top: var(--embed-border-start);
11+
--embed-border-bottom: var(--embed-border-start);
12+
13+
// latex block
14+
.markdown-source-view.mod-cm6 .cm-embed-block {
15+
margin-block: var(--size-4-1) !important;
516
border-radius: var(--radius-m) !important;
6-
transition: var(--animation);
17+
transition: box-shadow var(--animation);
718

819
.edit-block-button {
9-
border-radius: var(--radius-m) !important;
20+
border-radius: var(--radius-s) !important;
1021
transition: var(--animation);
11-
inset-block: 0.2rem;
22+
transition-property: background-color, opacity;
1223
height: fit-content;
1324
}
1425
}
26+
1527
.internal-embed.is-loaded:not(.image-embed) {
16-
--embed-background: var(--background-primary);
17-
--embed-max-height: initial;
1828
transition: var(--animation);
19-
padding: var(--size-4-1) var(--size-2-1) !important;
20-
21-
:is(.markdown-embed-link, .file-embed-link) {
22-
padding: var(--size-2-3);
23-
border-radius: var(--radius-m);
24-
transition: var(--animation);
25-
color: var(--accent-active);
26-
top: 0.2rem;
27-
right: 0.2rem;
29+
transition-property: border-color, background-color;
30+
border-radius: var(--radius-m);
31+
margin-block: var(--size-4-1) !important;
2832

29-
&:hover {
30-
background-color: var(--nav-item-background-hover);
31-
}
33+
&:hover {
34+
border-color: var(--accent-active);
3235
}
3336

34-
.markdown-embed-title {
35-
text-align: center;
36-
line-height: 2.8;
37+
&:is(.mod-empty, .mod-empty-attachment) {
38+
border: var(--size-2-1) dotted var(--text-faint);
3739
}
3840

39-
&:is(.markdown-embed, .file-embed) {
40-
border-radius: var(--radius-m);
41+
:is(.markdown-embed-link, .file-embed-link) {
42+
border-radius: var(--radius-s);
4143
transition: var(--animation);
42-
margin-block: var(--size-4-1) !important;
43-
padding: 0;
44-
border: var(--block-outline-width) solid var(--background-modifier-border);
45-
46-
&:is(.mod-empty, .mod-empty-attachment) {
47-
border-style: dotted;
48-
}
49-
50-
.markdown-preview-view {
51-
padding: calc(var(--font-text-size) * 1.2)
52-
calc(var(--font-text-size) * 1.5);
53-
position: initial;
54-
55-
.markdown-preview-section {
56-
min-height: fit-content !important;
57-
}
58-
}
44+
transition-property: color, background-color;
5945

6046
&:hover {
61-
border-color: var(--background-modifier-border-hover);
62-
}
63-
64-
&:active {
65-
border-color: var(--background-modifier-border-focus);
66-
}
67-
68-
.frontmatter + div {
69-
display: none;
47+
background-color: var(--nav-item-background-hover);
7048
}
7149
}
72-
73-
svg.link {
74-
transform: rotate(90deg);
50+
.markdown-embed-title {
51+
display: none;
7552
}
7653
}
7754

@@ -81,6 +58,11 @@
8158
}
8259
}
8360

61+
&.embed-border-hidden {
62+
--embed-border-start: none;
63+
--embed-background: var(--background-primary-alt);
64+
}
65+
8466
&.scrollbar-gutter-reserve.embed-title-right-top
8567
.internal-embed.is-loaded:not([alt='#'])
8668
.markdown-embed-heading

src/style-settings/_index.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,6 @@ body:not(.heading-h5-full-line)
273273
body:not(.heading-h6-full-line)
274274
.setting-item[data-id='heading-h6-full-line-direction'],
275275
body:not(.table-colorful) .setting-item[data-id^='setting-table'],
276-
body:not(.embed-enable) .setting-item[data-id^='embed-title'],
277276
body:not(.hr-enable) .setting-item[data-id^='setting-hr-icon'],
278277
body:not(.tag-outline)
279278
.setting-item:is(

src/style-settings/editor.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -554,19 +554,15 @@ export default Settings.create('maple-editor', 'Maple Editor').children([
554554
},
555555
'hex',
556556
),
557-
Settings.ofLevel(1, { title: { en: 'Embed File', zh: '内嵌文件' } })
558-
.addClassToggle(
559-
'embed-enable',
560-
{
561-
title: { en: 'Block Style Embed File', zh: '块状内嵌文件' },
562-
},
563-
{ enable: true },
564-
)
557+
Settings.ofLevel(1, { title: { en: 'Embed Block', zh: '内嵌块' } })
558+
.addClassToggle('embed-border-hidden', {
559+
title: { en: "Hide Embed Block's Border", zh: '隐藏内嵌块的边框' },
560+
})
565561
.addClassToggle(
566562
'embed-title-right-top',
567563
{
568564
title: {
569-
en: 'Move Embed Title to Top Right',
565+
en: 'Move Embed File Title to Top Right',
570566
zh: '内嵌文件标题移至右上角',
571567
},
572568
desc: {

0 commit comments

Comments
 (0)