mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-08-10 21:48:48 +08:00
chore: merge blocksuite source code (#9213)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import type { BlockComponent, EditorHost } from '@blocksuite/block-std';
|
||||
import { html } from 'lit';
|
||||
|
||||
import { htmlToElement } from './html-to-element.js';
|
||||
|
||||
export const createToastContainer = (editorHost: EditorHost) => {
|
||||
const styles = `
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
top: 16px;
|
||||
left: 16px;
|
||||
right: 16px;
|
||||
bottom: 78px;
|
||||
pointer-events: none;
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
align-items: center;
|
||||
`;
|
||||
const template = html`<div class="toast-container" style="${styles}"></div>`;
|
||||
const element = htmlToElement<HTMLDivElement>(template);
|
||||
const { std, doc } = editorHost;
|
||||
|
||||
let container = document.body;
|
||||
if (doc.root) {
|
||||
const rootComponent = std.view.getBlock(doc.root.id) as BlockComponent & {
|
||||
viewportElement: HTMLElement;
|
||||
};
|
||||
if (rootComponent) {
|
||||
const viewportElement = rootComponent.viewportElement;
|
||||
const editorContainer = viewportElement.parentElement;
|
||||
if (editorContainer) {
|
||||
container = editorContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
container.append(element);
|
||||
|
||||
return element;
|
||||
};
|
||||
Reference in New Issue
Block a user