chore(editor): revert padding and layout of code block toolbar (#9562)
Close [BS-1767](https://linear.app/affine-design/issue/BS-1767/code-block调整边距) This PR reverts padding and layout of code block toolbar. 
This commit is contained in:
@@ -16,7 +16,7 @@ import {
|
|||||||
getInlineRangeProvider,
|
getInlineRangeProvider,
|
||||||
TextSelection,
|
TextSelection,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
import { IS_MAC } from '@blocksuite/global/env';
|
import { IS_MAC, IS_MOBILE } from '@blocksuite/global/env';
|
||||||
import { noop } from '@blocksuite/global/utils';
|
import { noop } from '@blocksuite/global/utils';
|
||||||
import {
|
import {
|
||||||
INLINE_ROOT_ATTR,
|
INLINE_ROOT_ATTR,
|
||||||
@@ -389,6 +389,7 @@ export class CodeBlockComponent extends CaptionedBlockComponent<
|
|||||||
<div
|
<div
|
||||||
class=${classMap({
|
class=${classMap({
|
||||||
'affine-code-block-container': true,
|
'affine-code-block-container': true,
|
||||||
|
mobile: IS_MOBILE,
|
||||||
wrap: this.model.wrap,
|
wrap: this.model.wrap,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -17,15 +17,19 @@ export class AffineCodeToolbar extends WithDisposable(LitElement) {
|
|||||||
static override styles = css`
|
static override styles = css`
|
||||||
:host {
|
:host {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-toolbar-container {
|
.code-toolbar-container {
|
||||||
|
width: auto;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-toolbar-button {
|
.code-toolbar-button {
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ export class LanguageListButton extends WithDisposable(
|
|||||||
SignalWatcher(LitElement)
|
SignalWatcher(LitElement)
|
||||||
) {
|
) {
|
||||||
static override styles = css`
|
static override styles = css`
|
||||||
|
:host {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.lang-button {
|
.lang-button {
|
||||||
background-color: var(--affine-background-primary-color);
|
background-color: var(--affine-background-primary-color);
|
||||||
box-shadow: var(--affine-shadow-1);
|
box-shadow: var(--affine-shadow-1);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
TextSelection,
|
TextSelection,
|
||||||
WidgetComponent,
|
WidgetComponent,
|
||||||
} from '@blocksuite/block-std';
|
} from '@blocksuite/block-std';
|
||||||
import { limitShift, shift } from '@floating-ui/dom';
|
import { limitShift, shift, size } from '@floating-ui/dom';
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
import type { CodeBlockComponent } from '../code-block.js';
|
import type { CodeBlockComponent } from '../code-block.js';
|
||||||
@@ -82,8 +82,13 @@ export class AffineCodeToolbarWidget extends WidgetComponent<
|
|||||||
},
|
},
|
||||||
computePosition: {
|
computePosition: {
|
||||||
referenceElement: codeBlock,
|
referenceElement: codeBlock,
|
||||||
placement: 'right-start',
|
placement: 'top',
|
||||||
middleware: [
|
middleware: [
|
||||||
|
size({
|
||||||
|
apply({ rects, elements }) {
|
||||||
|
elements.floating.style.width = `${rects.reference.width}px`;
|
||||||
|
},
|
||||||
|
}),
|
||||||
shift({
|
shift({
|
||||||
crossAxis: true,
|
crossAxis: true,
|
||||||
padding: {
|
padding: {
|
||||||
|
|||||||
@@ -9,12 +9,16 @@ export const codeBlockStyles = css`
|
|||||||
font-size: var(--affine-font-xs);
|
font-size: var(--affine-font-xs);
|
||||||
line-height: var(--affine-line-height);
|
line-height: var(--affine-line-height);
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 12px;
|
padding: 28px 24px;
|
||||||
background: var(--affine-background-code-block);
|
background: var(--affine-background-code-block);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.affine-code-block-container.mobile {
|
||||||
|
padding: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.affine-code-block-container .inline-editor {
|
.affine-code-block-container .inline-editor {
|
||||||
font-family: var(--affine-font-code-family);
|
font-family: var(--affine-font-code-family);
|
||||||
font-variant-ligatures: none;
|
font-variant-ligatures: none;
|
||||||
|
|||||||
Reference in New Issue
Block a user