Files
AFFiNE-Mirror/blocksuite/affine/blocks/code/src/styles.ts
Flrande f79dfe837f feat(editor): support preview mode in code block (#11805)
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced a preview mode for code blocks, allowing users to toggle between code and rendered previews (e.g., HTML output) directly within the editor.
  - Added a preview toggle button to the code block toolbar for supported languages.
  - Enabled dynamic rendering of code block previews using a shared WebContainer, allowing live HTML previews in an embedded iframe.
  - Added HTML preview support with loading and error states for enhanced user feedback.
  - Integrated the preview feature as a view extension provider for seamless framework support.

- **Bug Fixes**
  - Improved toolbar layout and button alignment for a cleaner user interface.

- **Tests**
  - Added end-to-end tests to verify the new code block preview functionality and language switching behavior.

- **Chores**
  - Updated development server configuration to include enhanced security headers.
  - Added a new runtime dependency for WebContainer support.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-05-06 09:14:12 +00:00

57 lines
1.4 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: 28px 24px;
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: 4px;
width: 24px;
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 .affine-code-block-preview {
padding: 12px;
}
`;