import type { EmbedHtmlModel, EmbedHtmlStyles } from '@blocksuite/affine-model';
import { BlockSelection } from '@blocksuite/std';
import { html } from 'lit';
import { query } from 'lit/decorators.js';
import { classMap } from 'lit/directives/class-map.js';
import { type StyleInfo, styleMap } from 'lit/directives/style-map.js';
import { EmbedBlockComponent } from '../common/embed-block-element.js';
import { HtmlIcon, styles } from './styles.js';
export class EmbedHtmlBlockComponent extends EmbedBlockComponent {
static override styles = styles;
override _cardStyle: (typeof EmbedHtmlStyles)[number] = 'html';
close = () => {
document.exitFullscreen().catch(console.error);
};
protected embedHtmlStyle: StyleInfo = {};
open = () => {
this.iframeWrapper?.requestFullscreen().catch(console.error);
};
refreshData = () => {};
private _handleDoubleClick(event: MouseEvent) {
event.stopPropagation();
this.open();
}
private _selectBlock() {
const selectionManager = this.host.selection;
const blockSelection = selectionManager.create(BlockSelection, {
blockId: this.blockId,
});
selectionManager.setGroup('note', [blockSelection]);
}
protected _handleClick(event: MouseEvent) {
event.stopPropagation();
this._selectBlock();
}
override connectedCallback() {
super.connectedCallback();
this._cardStyle = this.model.props.style;
}
override renderBlock(): unknown {
const titleText = 'Basic HTML Page Structure';
const htmlSrc = `
${this.model.props.html}
`;
return this.renderEmbed(() => {
if (!this.model.props.html) {
return html` Empty
`;
}
return html`
`;
});
}
@query('.embed-html-block-iframe-wrapper')
accessor iframeWrapper!: HTMLDivElement;
}