feat(editor): brush and note gfx extension (#11927)

Closes: BS-3206
Closes: BS-3210

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Introduced new brush and note view extensions, enhancing integration and extensibility for brush and note tools.
  - Added store extension for brush tools, allowing for improved adapter integration.

- **Improvements**
  - Expanded module exports for brush and note graphics, making store and view functionalities more accessible.
  - Added new dependencies to support extension loading and improved project structure.

- **Refactor**
  - Updated extension arrays and toolbars to use the new view and store extensions for brush and note tools.
  - Removed legacy brush and note tools, effects, and toolbar extensions in favor of the new extension-based approach.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Saul-Mirone
2025-04-23 15:46:22 +00:00
parent c831a2ab2f
commit 61121ab727
23 changed files with 115 additions and 37 deletions

View File

@@ -12,6 +12,7 @@
"dependencies": {
"@blocksuite/affine-block-surface": "workspace:*",
"@blocksuite/affine-components": "workspace:*",
"@blocksuite/affine-ext-loader": "workspace:*",
"@blocksuite/affine-model": "workspace:*",
"@blocksuite/affine-rich-text": "workspace:*",
"@blocksuite/affine-shared": "workspace:*",
@@ -33,7 +34,9 @@
},
"exports": {
".": "./src/index.ts",
"./effects": "./src/effects.ts"
"./effects": "./src/effects.ts",
"./store": "./src/store.ts",
"./view": "./src/view.ts"
},
"files": [
"src",

View File

@@ -0,0 +1,19 @@
import {
type StoreExtensionContext,
StoreExtensionProvider,
} from '@blocksuite/affine-ext-loader';
import {
brushToMarkdownAdapterMatcher,
brushToPlainTextAdapterMatcher,
} from './adapter';
export class BrushStoreExtension extends StoreExtensionProvider {
override name = 'affine-brush-gfx';
override setup(context: StoreExtensionContext) {
super.setup(context);
context.register(brushToMarkdownAdapterMatcher);
context.register(brushToPlainTextAdapterMatcher);
}
}

View File

@@ -0,0 +1,39 @@
import {
type ViewExtensionContext,
ViewExtensionProvider,
} from '@blocksuite/affine-ext-loader';
import { BrushTool } from './brush-tool';
import { effects } from './effects';
import { BrushElementRendererExtension } from './element-renderer';
import { EraserTool } from './eraser-tool';
import { HighlighterTool } from './highlighter-tool';
import {
brushToolbarExtension,
highlighterToolbarExtension,
} from './toolbar/configs';
import { penSeniorTool } from './toolbar/senior-tool';
export class BrushViewExtension extends ViewExtensionProvider {
override name = 'affine-brush-gfx';
override effect(): void {
super.effect();
effects();
}
override setup(context: ViewExtensionContext) {
super.setup(context);
context.register(BrushTool);
context.register(EraserTool);
context.register(HighlighterTool);
context.register(BrushElementRendererExtension);
context.register(brushToolbarExtension);
context.register(highlighterToolbarExtension);
context.register(penSeniorTool);
}
}

View File

@@ -9,6 +9,7 @@
"references": [
{ "path": "../../blocks/surface" },
{ "path": "../../components" },
{ "path": "../../ext-loader" },
{ "path": "../../model" },
{ "path": "../../rich-text" },
{ "path": "../../shared" },