mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
feat: bump blocksuite (#7603)
## Features - https://github.com/toeverything/BlockSuite/pull/7717 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7691 @L-Sun ## Bugfix - https://github.com/toeverything/BlockSuite/pull/7720 @akumatus - https://github.com/toeverything/BlockSuite/pull/7719 @doouding ## Refactor - https://github.com/toeverything/BlockSuite/pull/7703 @donteatfriedrice - https://github.com/toeverything/BlockSuite/pull/7694 @doouding - https://github.com/toeverything/BlockSuite/pull/7700 @L-Sun - https://github.com/toeverything/BlockSuite/pull/7716 @doodlewind ## Misc
This commit is contained in:
@@ -63,7 +63,7 @@ function actionToRenderer<T extends keyof BlockSuitePresets.AIActions>(
|
||||
if (id === 'brainstormMindmap') {
|
||||
const selectedElements = ctx.get()[
|
||||
'selectedElements'
|
||||
] as BlockSuite.EdgelessModelType[];
|
||||
] as BlockSuite.EdgelessModel[];
|
||||
|
||||
if (
|
||||
isMindMapRoot(selectedElements[0] || isMindmapChild(selectedElements[0]))
|
||||
@@ -123,7 +123,7 @@ async function getContentFromHubBlockModel(
|
||||
|
||||
export async function getContentFromSelected(
|
||||
host: EditorHost,
|
||||
selected: BlockSuite.EdgelessModelType[]
|
||||
selected: BlockSuite.EdgelessModel[]
|
||||
) {
|
||||
type RemoveUndefinedKey<T, K extends keyof T> = T & {
|
||||
[P in K]-?: Exclude<T[P], undefined>;
|
||||
|
||||
@@ -317,7 +317,7 @@ export const responses: {
|
||||
|
||||
const elements = ctx.get()[
|
||||
'selectedElements'
|
||||
] as BlockSuite.EdgelessModelType[];
|
||||
] as BlockSuite.EdgelessModel[];
|
||||
const data = ctx.get() as {
|
||||
node: MindMapNode;
|
||||
};
|
||||
@@ -371,7 +371,7 @@ export const responses: {
|
||||
) as SurfaceBlockModel[];
|
||||
const elements = ctx.get()[
|
||||
'selectedElements'
|
||||
] as BlockSuite.EdgelessModelType[];
|
||||
] as BlockSuite.EdgelessModel[];
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const data = ctx.get() as any;
|
||||
let newGenerated = true;
|
||||
|
||||
@@ -70,7 +70,7 @@ declare global {
|
||||
|
||||
// internal context
|
||||
host: EditorHost;
|
||||
models?: (BlockModel | BlockSuite.SurfaceElementModelType)[];
|
||||
models?: (BlockModel | BlockSuite.SurfaceElementModel)[];
|
||||
control: TrackerControl;
|
||||
where: TrackerWhere;
|
||||
}
|
||||
|
||||
+13
-13
@@ -30,27 +30,27 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
|
||||
|
||||
const showWhenWrapper =
|
||||
(item?: AIItemConfig) =>
|
||||
({ rootElement }: AffineSlashMenuContext) => {
|
||||
const affineAIPanelWidget = rootElement.host.view.getWidget(
|
||||
({ rootComponent }: AffineSlashMenuContext) => {
|
||||
const affineAIPanelWidget = rootComponent.host.view.getWidget(
|
||||
AFFINE_AI_PANEL_WIDGET,
|
||||
rootElement.model.id
|
||||
rootComponent.model.id
|
||||
);
|
||||
if (affineAIPanelWidget === null) return false;
|
||||
|
||||
const chain = rootElement.host.command.chain();
|
||||
const editorMode = rootElement.service.docModeService.getMode(
|
||||
rootElement.doc.id
|
||||
const chain = rootComponent.host.command.chain();
|
||||
const editorMode = rootComponent.service.docModeService.getMode(
|
||||
rootComponent.doc.id
|
||||
);
|
||||
|
||||
return item?.showWhen?.(chain, editorMode, rootElement.host) ?? true;
|
||||
return item?.showWhen?.(chain, editorMode, rootComponent.host) ?? true;
|
||||
};
|
||||
|
||||
const actionItemWrapper = (
|
||||
item: AIItemConfig
|
||||
): AffineSlashMenuActionItem => ({
|
||||
...basicItemConfig(item),
|
||||
action: ({ rootElement }: AffineSlashMenuContext) => {
|
||||
item?.handler?.(rootElement.host);
|
||||
action: ({ rootComponent }: AffineSlashMenuContext) => {
|
||||
item?.handler?.(rootComponent.host);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
|
||||
subMenu: item.subItem.map<AffineSlashMenuActionItem>(
|
||||
({ type, handler }) => ({
|
||||
name: type,
|
||||
action: ({ rootElement }) => handler?.(rootElement.host),
|
||||
action: ({ rootComponent }) => handler?.(rootComponent.host),
|
||||
})
|
||||
),
|
||||
};
|
||||
@@ -81,11 +81,11 @@ export function setupSlashMenuEntry(slashMenu: AffineSlashMenuWidget) {
|
||||
name: 'Ask AI',
|
||||
icon: AIStarIcon,
|
||||
showWhen: showWhenWrapper(),
|
||||
action: ({ rootElement }) => {
|
||||
const view = rootElement.host.view;
|
||||
action: ({ rootComponent }) => {
|
||||
const view = rootComponent.host.view;
|
||||
const affineAIPanelWidget = view.getWidget(
|
||||
AFFINE_AI_PANEL_WIDGET,
|
||||
rootElement.model.id
|
||||
rootComponent.model.id
|
||||
) as AffineAIPanelWidget;
|
||||
assertExists(affineAIPanelWidget);
|
||||
assertExists(AIProvider.actions.chat);
|
||||
|
||||
@@ -29,13 +29,13 @@ export function mindMapToMarkdown(mindmap: MindmapElementModel) {
|
||||
return markdownStr;
|
||||
}
|
||||
|
||||
export function isMindMapRoot(ele: BlockSuite.EdgelessModelType) {
|
||||
export function isMindMapRoot(ele: BlockSuite.EdgelessModel) {
|
||||
const group = ele?.group;
|
||||
|
||||
return group instanceof MindmapElementModel && group.tree.element === ele;
|
||||
}
|
||||
|
||||
export function isMindmapChild(ele: BlockSuite.EdgelessModelType) {
|
||||
export function isMindmapChild(ele: BlockSuite.EdgelessModel) {
|
||||
return ele?.group instanceof MindmapElementModel && !isMindMapRoot(ele);
|
||||
}
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ export const getSelectedNoteAnchor = (host: EditorHost, id: string) => {
|
||||
|
||||
export function getCopilotSelectedElems(
|
||||
host: EditorHost
|
||||
): BlockSuite.EdgelessModelType[] {
|
||||
): BlockSuite.EdgelessModel[] {
|
||||
const service = getService(host);
|
||||
const copilotWidget = getEdgelessCopilotWidget(host);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user