mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
chore: bump blocksuite (#7152)
## Features - https://github.com/toeverything/BlockSuite/pull/7208 @pengx17 - https://github.com/toeverything/BlockSuite/pull/7207 @pengx17 - https://github.com/toeverything/BlockSuite/pull/7206 @regischen - https://github.com/toeverything/BlockSuite/pull/7194 @akumatus - https://github.com/toeverything/BlockSuite/pull/7209 @Saul-Mirone ## Bugfix - https://github.com/toeverything/BlockSuite/pull/7205 @fundon - https://github.com/toeverything/BlockSuite/pull/7211 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7210 @fundon ## Refactor ## Misc - https://github.com/toeverything/BlockSuite/pull/7203 @fundon Also added prompt implementation to fix type change issue 
This commit is contained in:
@@ -2,6 +2,7 @@ import {
|
||||
createReactComponentFromLit,
|
||||
useConfirmModal,
|
||||
useLitPortalFactory,
|
||||
usePromptModal,
|
||||
} from '@affine/component';
|
||||
import { useJournalInfoHelper } from '@affine/core/hooks/use-journal';
|
||||
import { PeekViewService } from '@affine/core/modules/peek-view';
|
||||
@@ -80,11 +81,12 @@ const usePatchSpecs = (page: Doc, specs: BlockSpec[]) => {
|
||||
}, [page.collection]);
|
||||
|
||||
const confirmModal = useConfirmModal();
|
||||
const openPromptModal = usePromptModal();
|
||||
const patchedSpecs = useMemo(() => {
|
||||
let patched = patchReferenceRenderer(specs, reactToLit, referenceRenderer);
|
||||
patched = patchNotificationService(
|
||||
patchReferenceRenderer(patched, reactToLit, referenceRenderer),
|
||||
confirmModal
|
||||
{ ...confirmModal, prompt: openPromptModal }
|
||||
);
|
||||
if (!page.readonly && runtimeConfig.enablePeekView) {
|
||||
patched = patchPeekViewService(patched, peekViewService);
|
||||
@@ -92,6 +94,7 @@ const usePatchSpecs = (page: Doc, specs: BlockSpec[]) => {
|
||||
return patched;
|
||||
}, [
|
||||
confirmModal,
|
||||
openPromptModal,
|
||||
page.readonly,
|
||||
peekViewService,
|
||||
reactToLit,
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
toast,
|
||||
type ToastOptions,
|
||||
type useConfirmModal,
|
||||
type usePromptModal,
|
||||
} from '@affine/component';
|
||||
import type { PeekViewService } from '@affine/core/modules/peek-view';
|
||||
import type { ActivePeekView } from '@affine/core/modules/peek-view/entities/peek-view';
|
||||
@@ -114,7 +115,13 @@ export function patchReferenceRenderer(
|
||||
|
||||
export function patchNotificationService(
|
||||
specs: BlockSpec[],
|
||||
{ closeConfirmModal, openConfirmModal }: ReturnType<typeof useConfirmModal>
|
||||
{
|
||||
closeConfirmModal,
|
||||
openConfirmModal,
|
||||
prompt,
|
||||
}: ReturnType<typeof useConfirmModal> & {
|
||||
prompt: ReturnType<typeof usePromptModal>;
|
||||
}
|
||||
) {
|
||||
const rootSpec = specs.find(
|
||||
spec => spec.schema.model.flavour === 'affine:page'
|
||||
@@ -126,22 +133,10 @@ export function patchNotificationService(
|
||||
|
||||
patchSpecService(rootSpec, service => {
|
||||
service.notificationService = {
|
||||
confirm: async ({
|
||||
title,
|
||||
message,
|
||||
confirmText,
|
||||
cancelText,
|
||||
abort,
|
||||
}: {
|
||||
title: string;
|
||||
message: string | TemplateResult;
|
||||
confirmText: string;
|
||||
cancelText: string;
|
||||
abort?: AbortSignal;
|
||||
}) => {
|
||||
confirm: async ({ title, message, confirmText, cancelText, abort }) => {
|
||||
return new Promise<boolean>(resolve => {
|
||||
openConfirmModal({
|
||||
title,
|
||||
title: toReactNode(title),
|
||||
description: toReactNode(message),
|
||||
confirmButtonOptions: {
|
||||
children: confirmText,
|
||||
@@ -161,6 +156,23 @@ export function patchNotificationService(
|
||||
});
|
||||
});
|
||||
},
|
||||
prompt: async ({
|
||||
title,
|
||||
message,
|
||||
confirmText,
|
||||
placeholder,
|
||||
cancelText,
|
||||
abort,
|
||||
}) => {
|
||||
return prompt({
|
||||
message: toReactNode(message),
|
||||
title: toReactNode(title),
|
||||
confirmText,
|
||||
cancelText,
|
||||
placeholder,
|
||||
abort,
|
||||
});
|
||||
},
|
||||
toast: (message: string, options: ToastOptions) => {
|
||||
return toast(message, options);
|
||||
},
|
||||
@@ -181,6 +193,12 @@ export function patchNotificationService(
|
||||
{
|
||||
title: toReactNode(notification.title),
|
||||
message: toReactNode(notification.message),
|
||||
action: notification.action?.onClick
|
||||
? {
|
||||
label: toReactNode(notification.action?.label),
|
||||
onClick: notification.action.onClick,
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
{
|
||||
duration: notification.duration || 0,
|
||||
|
||||
Reference in New Issue
Block a user