Files
AFFiNE-Mirror/blocksuite/affine/blocks/divider/src/divider-block.ts
Saul-Mirone 1f45cc5dec refactor(editor): unify directories naming (#11516)
**Directory Structure Changes**

- Renamed multiple block-related directories by removing the "block-" prefix:
  - `block-attachment` → `attachment`
  - `block-bookmark` → `bookmark`
  - `block-callout` → `callout`
  - `block-code` → `code`
  - `block-data-view` → `data-view`
  - `block-database` → `database`
  - `block-divider` → `divider`
  - `block-edgeless-text` → `edgeless-text`
  - `block-embed` → `embed`
2025-04-07 12:34:40 +00:00

51 lines
1.3 KiB
TypeScript

import { CaptionedBlockComponent } from '@blocksuite/affine-components/caption';
import type { DividerBlockModel } from '@blocksuite/affine-model';
import { BLOCK_CHILDREN_CONTAINER_PADDING_LEFT } from '@blocksuite/affine-shared/consts';
import { BlockSelection } from '@blocksuite/std';
import { html } from 'lit';
import { dividerBlockStyles } from './styles.js';
export class DividerBlockComponent extends CaptionedBlockComponent<DividerBlockModel> {
static override styles = dividerBlockStyles;
override connectedCallback() {
super.connectedCallback();
this.contentEditable = 'false';
this.handleEvent('click', () => {
this.host.selection.setGroup('note', [
this.host.selection.create(BlockSelection, {
blockId: this.blockId,
}),
]);
});
}
override renderBlock() {
const children = html`<div
class="affine-block-children-container"
style="padding-left: ${BLOCK_CHILDREN_CONTAINER_PADDING_LEFT}px"
>
${this.renderChildren(this.model)}
</div>`;
return html`
<div class="affine-divider-block-container">
<hr />
${children}
</div>
`;
}
override accessor useZeroWidth = true;
}
declare global {
interface HTMLElementTagNameMap {
'affine-divider': DividerBlockComponent;
}
}