chore: bump bs (#8189)

This commit is contained in:
Saul-Mirone
2024-09-10 13:48:08 +00:00
parent 95738e796f
commit daa9d9ff5c
20 changed files with 217 additions and 199 deletions

View File

@@ -178,7 +178,7 @@ function addAIChatBlock(
}
export function promptDocTitle(host: EditorHost, autofill?: string) {
const notification = host.std.getService('affine:page').notificationService;
const notification = host.std.getService('affine:page')?.notificationService;
if (!notification) return Promise.resolve(undefined);
return notification.prompt({
@@ -386,6 +386,8 @@ const ADD_TO_EDGELESS_AS_NOTE = {
reportResponse('result:add-note');
const { doc } = host;
const service = host.std.getService<EdgelessRootService>('affine:page');
if (!service) return;
const elements = service.selection.selectedElements;
const props: { displayMode: NoteDisplayMode; xywh?: SerializedXYWH } = {
@@ -426,7 +428,7 @@ const CREATE_AS_DOC = {
newDoc.addBlock('affine:surface', {}, rootId);
const noteId = newDoc.addBlock('affine:note', {}, rootId);
host.std.getService('affine:page').slots.docLinkClicked.emit({
host.std.getService('affine:page')?.slots.docLinkClicked.emit({
pageId: newDoc.id,
});
let complete = false;
@@ -464,6 +466,9 @@ const CREATE_AS_LINKED_DOC = {
}
const service = host.std.getService<EdgelessRootService>('affine:page');
if (!service) {
return false;
}
const docModeService = host.std.get(DocModeProvider);
const mode = docModeService.getEditorMode();
if (mode !== 'edgeless') {

View File

@@ -148,7 +148,7 @@ export class ChatActionList extends LitElement {
messageId
);
if (success) {
this._rootService.notificationService?.notify({
this._rootService?.notificationService?.notify({
title: action.toast,
accent: 'success',
onClose: function (): void {},

View File

@@ -128,6 +128,7 @@ export class ChatCopyMore extends WithDisposable(LitElement) {
}
private readonly _notifySuccess = (title: string) => {
if (!this._rootService) return;
const { notificationService } = this._rootService;
notificationService?.notify({
title: title,

View File

@@ -78,7 +78,7 @@ export async function selectedToPng(editor: EditorHost) {
export async function getSelectedTextContent(editorHost: EditorHost) {
const slice = Slice.fromModels(
editorHost.std.doc,
getRootService(editorHost).selectedModels
getRootService(editorHost)?.selectedModels ?? []
);
return getMarkdownFromSlice(editorHost, slice);
}

View File

@@ -510,6 +510,7 @@ export const responses: {
if (!contents) return;
const images = data.images as { url: string; id: string }[][];
const service = host.std.getService<EdgelessRootService>('affine:page');
if (!service) return;
(async function () {
for (let i = 0; i < contents.length - 1; i++) {

View File

@@ -160,7 +160,7 @@ export class ChatPanel extends WithDisposable(ShadowlessElement) {
private readonly _cleanupHistories = async () => {
const notification =
this.host.std.getService('affine:page').notificationService;
this.host.std.getService('affine:page')?.notificationService;
if (!notification) return;
if (

View File

@@ -1,6 +1,8 @@
import type { MindmapStyle } from '@blocksuite/affine-block-surface';
import type { EditorHost } from '@blocksuite/block-std';
import type { AffineAIPanelWidgetConfig } from '@blocksuite/blocks';
import type {
AffineAIPanelWidgetConfig,
MindmapStyle,
} from '@blocksuite/blocks';
import { markdownToMindmap, MiniMindmapPreview } from '@blocksuite/blocks';
import { noop } from '@blocksuite/global/utils';
import { html, nothing } from 'lit';

View File

@@ -80,7 +80,7 @@ export class AISlidesRenderer extends WithDisposable(LitElement) {
PPTBuilder(this._editorHost)
.process(this.text)
.then(res => {
if (this.ctx) {
if (res && this.ctx) {
this.ctx.set({
contents: res.contents,
images: res.images,

View File

@@ -254,10 +254,9 @@ export class AIChatBlockPeekView extends LitElement {
* Clean current chat messages and delete the newly created AI chat block
*/
cleanCurrentChatHistories = async () => {
if (!this._rootService) return;
const { notificationService } = this._rootService;
if (!notificationService) {
return;
}
if (!notificationService) return;
const { currentChatBlockId, currentSessionId } = this.chatContext;
if (!currentChatBlockId && !currentSessionId) {

View File

@@ -35,7 +35,7 @@ export const PPTBuilder = (host: EditorHost) => {
};
docs.push(doc);
if (doc.isCover) return;
if (doc.isCover || !service) return;
const job = service.createTemplateJob('template');
const { images, content } = await basicTheme(doc);
contents.push(content);
@@ -56,6 +56,7 @@ export const PPTBuilder = (host: EditorHost) => {
return {
process: async (text: string) => {
try {
if (!service) return;
const snapshot = await markdownToSnapshot(text, host);
const block = snapshot.snapshot.content[0];

View File

@@ -18,14 +18,18 @@ import {
EmbedSyncedDocBlockSpec,
EmbedYoutubeBlockSpec,
ImageBlockSpec,
LatexBlockSpec,
ListBlockSpec,
ParagraphBlockSpec,
RichTextExtensions,
} from '@blocksuite/blocks';
import { AIChatBlockSpec } from '@blocksuite/presets';
import { CustomAttachmentBlockSpec } from './custom/attachment-block';
const CommonBlockSpecs: ExtensionType[] = [
RichTextExtensions,
LatexBlockSpec,
ListBlockSpec,
DatabaseBlockSpec,
DataViewBlockSpec,

View File

@@ -30,11 +30,8 @@ import {
import { BlockServiceWatcher } from '@blocksuite/block-std';
import {
type AffineReference,
type DatabaseBlockService,
type DocMode,
EmbedOptionProvider,
type ListBlockService,
type ParagraphBlockService,
type RootService,
} from '@blocksuite/blocks';
import {
@@ -43,6 +40,7 @@ import {
EdgelessRootBlockComponent,
EmbedLinkedDocBlockComponent,
QuickSearchProvider,
ReferenceNodeConfigExtension,
} from '@blocksuite/blocks';
import { LinkIcon } from '@blocksuite/icons/rc';
import { AIChatBlockSchema } from '@blocksuite/presets';
@@ -95,21 +93,14 @@ function patchSpecService<Service extends BlockService = BlockService>(
export function patchReferenceRenderer(
reactToLit: (element: ElementOrFactory) => TemplateResult,
reactRenderer: ReferenceReactRenderer
): ExtensionType[] {
): ExtensionType {
const litRenderer = (reference: AffineReference) => {
const node = reactRenderer(reference);
return reactToLit(node);
};
return ['affine:paragraph', 'affine:list', 'affine:database'].map(flavour => {
return patchSpecService<
ParagraphBlockService | ListBlockService | DatabaseBlockService
>(flavour, service => {
service.referenceNodeConfig.setCustomContent(litRenderer);
return () => {
service.referenceNodeConfig.setCustomContent(null);
};
});
return ReferenceNodeConfigExtension({
customContent: litRenderer,
});
}

View File

@@ -37,6 +37,9 @@ function fitViewport(
const rootService =
editor.host.std.getService<EdgelessRootService>('affine:page');
if (!rootService) {
return;
}
rootService.viewport.onResize();
if (xywh) {
@@ -85,6 +88,9 @@ function DocPeekPreviewEditor({
}
const disposableGroup = new DisposableGroup();
const rootService = editorContainer.host.std.getService('affine:page');
if (!rootService) {
return;
}
// doc change event inside peek view should be handled by peek view
disposableGroup.add(
rootService.slots.docLinkClicked.on(options => {