mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-14 21:27:20 +00:00
Close [BS-2310](https://linear.app/affine-design/issue/BS-2310/note-display-in-page-%E7%9A%84%E8%A1%8C%E4%B8%BA), [BS-2312](https://linear.app/affine-design/issue/BS-2312/edgeless-note-%E7%9A%84-element-toolbar-%E6%B7%BB%E5%8A%A0display-in-page%E6%8C%89%E9%92%AE) and [BS-2313](https://linear.app/affine-design/issue/BS-2313/添加display-in-page的toast提示,以及打开toc的按钮)
57 lines
1.5 KiB
TypeScript
57 lines
1.5 KiB
TypeScript
import { createIdentifier } from '@blocksuite/global/di';
|
|
import type { ExtensionType } from '@blocksuite/store';
|
|
import type { TemplateResult } from 'lit';
|
|
|
|
export interface NotificationService {
|
|
toast(
|
|
message: string,
|
|
options?: {
|
|
duration?: number;
|
|
portal?: HTMLElement;
|
|
}
|
|
): void;
|
|
confirm(options: {
|
|
title: string | TemplateResult;
|
|
message: string | TemplateResult;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
abort?: AbortSignal;
|
|
}): Promise<boolean>;
|
|
prompt(options: {
|
|
title: string | TemplateResult;
|
|
message: string | TemplateResult;
|
|
autofill?: string;
|
|
placeholder?: string;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
abort?: AbortSignal;
|
|
}): Promise<string | null>; // when cancel, return null
|
|
notify(options: {
|
|
title: string | TemplateResult;
|
|
message?: string | TemplateResult;
|
|
footer?: string | TemplateResult;
|
|
accent?: 'info' | 'success' | 'warning' | 'error';
|
|
duration?: number; // unit ms, give 0 to disable auto dismiss
|
|
abort?: AbortSignal;
|
|
action?: {
|
|
label: string | TemplateResult;
|
|
onClick: () => void;
|
|
};
|
|
onClose: () => void;
|
|
}): void;
|
|
}
|
|
|
|
export const NotificationProvider = createIdentifier<NotificationService>(
|
|
'AffineNotificationService'
|
|
);
|
|
|
|
export function NotificationExtension(
|
|
notificationService: NotificationService
|
|
): ExtensionType {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(NotificationProvider, notificationService);
|
|
},
|
|
};
|
|
}
|