Closes: BS-3209 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced mind map view and store extensions, enhancing mind map integration and conversion to plain text and markdown formats. - Added priority property to quick tools, allowing for custom ordering in the toolbar. - **Improvements** - Toolbar quick tools are now sorted by priority for a more intuitive user experience. - Updated toolbar and extension configurations to streamline available tools and extensions. - **Bug Fixes** - Conditional registration of certain components ensures correct behavior in edgeless mode. - **Chores** - Updated dependencies and project references to improve module integration and maintainability. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
import type { MenuConfig } from '@blocksuite/affine-components/context-menu';
|
|
import { createIdentifier } from '@blocksuite/global/di';
|
|
import type { BlockComponent } from '@blocksuite/std';
|
|
import type { GfxController, GfxToolsMap } from '@blocksuite/std/gfx';
|
|
import type { ExtensionType } from '@blocksuite/store';
|
|
import { type TemplateResult } from 'lit';
|
|
|
|
export interface QuickTool {
|
|
type?: keyof GfxToolsMap;
|
|
enable?: boolean;
|
|
content: TemplateResult;
|
|
/**
|
|
* if not configured, the tool will not be shown in dense mode
|
|
*/
|
|
menu?: MenuConfig;
|
|
priority?: number;
|
|
}
|
|
|
|
export interface SeniorTool {
|
|
/**
|
|
* Used to show in nav-button's tooltip
|
|
*/
|
|
name: string;
|
|
content: TemplateResult;
|
|
enable?: boolean;
|
|
}
|
|
|
|
export type ToolBuilder<T> = (options: {
|
|
block: BlockComponent;
|
|
gfx: GfxController;
|
|
toolbarContainer: HTMLElement;
|
|
}) => T;
|
|
|
|
export const QuickToolIdentifier = createIdentifier<ToolBuilder<QuickTool>>(
|
|
'edgeless-quick-tool'
|
|
);
|
|
export const SeniorToolIdentifier = createIdentifier<ToolBuilder<SeniorTool>>(
|
|
'edgeless-senior-tool'
|
|
);
|
|
|
|
export const QuickToolExtension = (
|
|
id: string,
|
|
builder: ToolBuilder<QuickTool>
|
|
): ExtensionType => {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(QuickToolIdentifier(id), () => builder);
|
|
},
|
|
};
|
|
};
|
|
|
|
export const SeniorToolExtension = (
|
|
id: string,
|
|
builder: ToolBuilder<SeniorTool>
|
|
): ExtensionType => {
|
|
return {
|
|
setup: di => {
|
|
di.addImpl(SeniorToolIdentifier(id), () => builder);
|
|
},
|
|
};
|
|
};
|