mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00:00
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a toggle in the code block toolbar to show or hide line numbers for individual code blocks. - The display of line numbers now respects both global and per-block settings, allowing more flexible control. - **Style** - Updated styles to hide line numbers when disabled via the new toggle option. - **Tests** - Added end-to-end tests to verify toggling line numbers visibility and undo/redo behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { scrollbarStyle } from '@blocksuite/affine-shared/styles';
|
|
import { css } from 'lit';
|
|
|
|
export const codeBlockStyles = css`
|
|
.affine-code-block-container {
|
|
font-size: var(--affine-font-xs);
|
|
line-height: var(--affine-line-height);
|
|
position: relative;
|
|
padding: 32px 20px;
|
|
background: var(--affine-background-code-block);
|
|
border-radius: 10px;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.affine-code-block-container.mobile {
|
|
padding: 12px;
|
|
}
|
|
|
|
${scrollbarStyle('.affine-code-block-container rich-text')}
|
|
|
|
.affine-code-block-container .inline-editor {
|
|
font-family: var(--affine-font-code-family);
|
|
font-variant-ligatures: none;
|
|
}
|
|
|
|
.affine-code-block-container v-line {
|
|
position: relative;
|
|
display: inline-grid !important;
|
|
grid-template-columns: auto minmax(0, 1fr);
|
|
}
|
|
|
|
.affine-code-block-container div:has(> v-line) {
|
|
display: grid;
|
|
}
|
|
|
|
.affine-code-block-container .line-number {
|
|
position: sticky;
|
|
text-align: left;
|
|
padding-right: 12px;
|
|
width: 32px;
|
|
word-break: break-word;
|
|
white-space: nowrap;
|
|
left: -0.5px;
|
|
z-index: 1;
|
|
background: var(--affine-background-code-block);
|
|
font-size: var(--affine-font-xs);
|
|
line-height: var(--affine-line-height);
|
|
color: var(--affine-text-secondary);
|
|
box-sizing: border-box;
|
|
user-select: none;
|
|
}
|
|
|
|
.affine-code-block-container.disable-line-numbers .line-number {
|
|
display: none;
|
|
}
|
|
|
|
affine-code .affine-code-block-preview {
|
|
padding: 12px;
|
|
}
|
|
`;
|