L-Sun
2025-04-23 05:41:14 +00:00
parent 9b2cf5cafa
commit 27ff9ab9f4
21 changed files with 304 additions and 339 deletions
@@ -364,13 +364,16 @@ export function notifyDocCreated(std: BlockStdScope, doc: Store) {
message: 'You can click undo to recovery block content',
accent: 'info',
duration: 10 * 1000,
action: {
label: 'Undo',
onClick: () => {
doc.undo();
clear();
actions: [
{
key: 'undo',
label: 'Undo',
onClick: () => {
doc.undo();
clear();
},
},
},
],
abort: abortController.signal,
onClose: clear,
});
@@ -1,24 +0,0 @@
import { cssVar } from '@toeverything/theme';
import { cssVarV2 } from '@toeverything/theme/v2';
import { style } from '@vanilla-extract/css';
export const viewInPageNotifyFooter = style({
display: 'flex',
justifyContent: 'flex-end',
gap: '12px',
});
export const viewInPageNotifyFooterButton = style({
padding: '0px 6px',
borderRadius: '4px',
color: cssVarV2('text/primary'),
fontSize: cssVar('fontSm'),
lineHeight: '22px',
fontWeight: '500',
textAlign: 'center',
':hover': {
background: cssVarV2('layer/background/hoverOverlay'),
},
});
@@ -41,7 +41,6 @@ import { html } from 'lit';
import { keyed } from 'lit/directives/keyed.js';
import { changeNoteDisplayMode } from '../commands';
import * as styles from '../components/view-in-page-notify.css';
import { NoteConfigExtension } from '../config';
const trackBaseProps = {
@@ -550,22 +549,18 @@ function setDisplayMode(
message: `${data.message} Find it in the TOC for quick navigation.`,
accent: 'success',
duration: 5 * 1000,
footer: html`<div class=${styles.viewInPageNotifyFooter}>
<button
class=${styles.viewInPageNotifyFooterButton}
@click=${undo}
data-testid="undo-display-in-page"
>
Undo
</button>
<button
class=${styles.viewInPageNotifyFooterButton}
@click=${viewInToc}
data-testid="view-in-toc"
>
View in Toc
</button>
</div>`,
actions: [
{
key: 'undo-display-in-page',
label: 'Undo',
onClick: () => undo(),
},
{
key: 'view-in-toc',
label: 'View in Toc',
onClick: () => viewInToc(),
},
],
abort: abortController.signal,
onClose: () => {
clear();
@@ -35,13 +35,16 @@ function notify(std: BlockStdScope, title: string, message: string) {
message,
accent: 'info',
duration: 10 * 1000,
action: {
label: 'Undo',
onClick: () => {
doc.undo();
clear();
actions: [
{
key: 'undo',
label: 'Undo',
onClick: () => {
doc.undo();
clear();
},
},
},
],
abort: abortController.signal,
onClose: clear,
});
@@ -29,14 +29,14 @@ export interface NotificationService {
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?: {
actions?: {
key: string;
label: string | TemplateResult;
onClick: () => void;
};
}[];
onClose: () => void;
}): void;
}