Skip to content

Commit 72ca86c

Browse files
committed
feat(editor): add affine toolbar widget
1 parent 7f27500 commit 72ca86c

File tree

13 files changed

+103
-0
lines changed

13 files changed

+103
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "@blocksuite/affine-widget-toolbar",
3+
"description": "Affine toolbar widget.",
4+
"type": "module",
5+
"scripts": {
6+
"build": "tsc",
7+
"test:unit": "nx vite:test --run --passWithNoTests",
8+
"test:unit:coverage": "nx vite:test --run --coverage",
9+
"test:e2e": "playwright test"
10+
},
11+
"sideEffects": false,
12+
"keywords": [],
13+
"author": "toeverything",
14+
"license": "MIT",
15+
"dependencies": {
16+
"@blocksuite/affine-model": "workspace:*",
17+
"@blocksuite/affine-shared": "workspace:*",
18+
"@blocksuite/block-std": "workspace:*",
19+
"@blocksuite/global": "workspace:*",
20+
"@preact/signals-core": "^1.8.0",
21+
"@toeverything/theme": "^1.1.3",
22+
"lit": "^3.2.0"
23+
},
24+
"exports": {
25+
".": "./src/index.ts",
26+
"./effects": "./src/effects.ts"
27+
},
28+
"files": [
29+
"src",
30+
"dist",
31+
"!src/__tests__",
32+
"!dist/__tests__"
33+
],
34+
"version": "0.19.0"
35+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { AFFINE_TOOLBAR_WIDGET, AffineToolbarWidget } from './toolbar';
2+
3+
export function effects() {
4+
customElements.define(AFFINE_TOOLBAR_WIDGET, AffineToolbarWidget);
5+
}
6+
7+
declare global {
8+
interface HTMLElementTagNameMap {
9+
[AFFINE_TOOLBAR_WIDGET]: AffineToolbarWidget;
10+
}
11+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './toolbar';
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { WidgetComponent } from '@blocksuite/block-std';
2+
3+
export const AFFINE_TOOLBAR_WIDGET = 'affine-toolbar-widget';
4+
5+
export class AffineToolbarWidget extends WidgetComponent {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "./src/",
5+
"outDir": "./dist/",
6+
"noEmit": false
7+
},
8+
"include": ["./src"],
9+
"references": [
10+
{ "path": "../model" },
11+
{ "path": "../shared" },
12+
{ "path": "../../framework/block-std" },
13+
{ "path": "../../framework/global" }
14+
]
15+
}

blocksuite/blocks/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@blocksuite/affine-widget-frame-title": "workspace:*",
3838
"@blocksuite/affine-widget-remote-selection": "workspace:*",
3939
"@blocksuite/affine-widget-scroll-anchoring": "workspace:*",
40+
"@blocksuite/affine-widget-toolbar": "workspace:*",
4041
"@blocksuite/block-std": "workspace:*",
4142
"@blocksuite/data-view": "workspace:*",
4243
"@blocksuite/global": "workspace:*",

blocksuite/blocks/src/effects.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { effects as widgetDragHandleEffects } from '@blocksuite/affine-widget-dr
3434
import { effects as widgetFrameTitleEffects } from '@blocksuite/affine-widget-frame-title/effects';
3535
import { effects as widgetRemoteSelectionEffects } from '@blocksuite/affine-widget-remote-selection/effects';
3636
import { effects as widgetScrollAnchoringEffects } from '@blocksuite/affine-widget-scroll-anchoring/effects';
37+
import { effects as widgetToolbarEffects } from '@blocksuite/affine-widget-toolbar/effects';
3738
import type { BlockComponent } from '@blocksuite/block-std';
3839
import { effects as stdEffects } from '@blocksuite/block-std/effects';
3940
import { effects as dataViewEffects } from '@blocksuite/data-view/effects';
@@ -223,6 +224,7 @@ export function effects() {
223224
widgetEdgelessElementToolbarEffects();
224225
widgetRemoteSelectionEffects();
225226
widgetDragHandleEffects();
227+
widgetToolbarEffects();
226228
dataViewEffects();
227229

228230
customElements.define('affine-page-root', PageRootBlockComponent);

blocksuite/blocks/src/root-block/edgeless/edgeless-root-spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
AFFINE_EDGELESS_REMOTE_SELECTION_WIDGET,
1414
} from '@blocksuite/affine-widget-remote-selection';
1515
import { AFFINE_SCROLL_ANCHORING_WIDGET } from '@blocksuite/affine-widget-scroll-anchoring';
16+
import { AFFINE_TOOLBAR_WIDGET } from '@blocksuite/affine-widget-toolbar';
1617
import {
1718
BlockServiceWatcher,
1819
BlockViewExtension,
@@ -80,6 +81,7 @@ export const edgelessRootWidgetViewMap = {
8081
AFFINE_EDGELESS_AUTO_CONNECT_WIDGET
8182
)}`,
8283
[AFFINE_SCROLL_ANCHORING_WIDGET]: literal`${unsafeStatic(AFFINE_SCROLL_ANCHORING_WIDGET)}`,
84+
[AFFINE_TOOLBAR_WIDGET]: literal`${unsafeStatic(AFFINE_TOOLBAR_WIDGET)}`,
8385
[EDGELESS_DRAGGING_AREA_WIDGET]: literal`${unsafeStatic(EDGELESS_DRAGGING_AREA_WIDGET)}`,
8486
[NOTE_SLICER_WIDGET]: literal`${unsafeStatic(NOTE_SLICER_WIDGET)}`,
8587
[EDGELESS_NAVIGATOR_BLACK_BACKGROUND_WIDGET]: literal`${unsafeStatic(EDGELESS_NAVIGATOR_BLACK_BACKGROUND_WIDGET)}`,

blocksuite/blocks/src/root-block/page/page-root-spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { AFFINE_DRAG_HANDLE_WIDGET } from '@blocksuite/affine-widget-drag-handle';
1010
import { AFFINE_DOC_REMOTE_SELECTION_WIDGET } from '@blocksuite/affine-widget-remote-selection';
1111
import { AFFINE_SCROLL_ANCHORING_WIDGET } from '@blocksuite/affine-widget-scroll-anchoring';
12+
import { AFFINE_TOOLBAR_WIDGET } from '@blocksuite/affine-widget-toolbar';
1213
import {
1314
BlockViewExtension,
1415
CommandExtension,
@@ -61,6 +62,7 @@ export const pageRootWidgetViewMap = {
6162
AFFINE_VIEWPORT_OVERLAY_WIDGET
6263
)}`,
6364
[AFFINE_SCROLL_ANCHORING_WIDGET]: literal`${unsafeStatic(AFFINE_SCROLL_ANCHORING_WIDGET)}`,
65+
[AFFINE_TOOLBAR_WIDGET]: literal`${unsafeStatic(AFFINE_TOOLBAR_WIDGET)}`,
6466
};
6567

6668
const PageCommonExtension: ExtensionType[] = [

blocksuite/blocks/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
{ "path": "../affine/widget-frame-title" },
3131
{ "path": "../affine/widget-remote-selection" },
3232
{ "path": "../affine/widget-scroll-anchoring" },
33+
{ "path": "../affine/widget-toolbar" },
3334
{ "path": "../framework/block-std" },
3435
{ "path": "../affine/data-view" },
3536
{ "path": "../framework/global" },

0 commit comments

Comments
 (0)