-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): add toolbar registry extension
- Loading branch information
Showing
35 changed files
with
1,231 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import type { | ||
ToolbarActionGroup, | ||
ToolbarModuleConfig, | ||
} from '@blocksuite/affine-shared/services'; | ||
|
||
export const builtinToolbarConfig = { | ||
actions: [ | ||
{ | ||
id: 'rename', | ||
tooltip: 'Rename', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'conversions', | ||
actions: [ | ||
{ | ||
id: 'card-view', | ||
label: 'Card view', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'embed-view', | ||
label: 'Embed view', | ||
run(_cx) {}, | ||
}, | ||
], | ||
content(_cx) { | ||
this.actions; | ||
return null; | ||
}, | ||
} satisfies ToolbarActionGroup, | ||
{ | ||
id: 'download', | ||
tooltip: 'Download', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'caption', | ||
tooltip: 'Caption', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'clipboard', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'copy', | ||
label: 'Copy', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'duplicate', | ||
label: 'Duplicate', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'refresh', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'reload', | ||
label: 'Reload', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'delete', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'delete', | ||
label: 'Delete', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
], | ||
} as const satisfies ToolbarModuleConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,32 @@ | ||
import { ToolbarModuleExtension } from '@blocksuite/affine-shared/services'; | ||
import { | ||
BlockFlavourIdentifier, | ||
BlockViewExtension, | ||
CommandExtension, | ||
FlavourExtension, | ||
} from '@blocksuite/block-std'; | ||
import type { ExtensionType } from '@blocksuite/store'; | ||
import { literal } from 'lit/static-html.js'; | ||
|
||
import { BookmarkBlockAdapterExtensions } from './adapters/extension.js'; | ||
import { BookmarkBlockService } from './bookmark-service.js'; | ||
import { commands } from './commands/index.js'; | ||
import { BookmarkBlockAdapterExtensions } from './adapters/extension'; | ||
import { BookmarkBlockService } from './bookmark-service'; | ||
import { commands } from './commands/index'; | ||
import { builtinToolbarConfig } from './configs/toolbar'; | ||
|
||
const Flavour = 'affine:bookmark'; | ||
|
||
export const BookmarkBlockSpec: ExtensionType[] = [ | ||
FlavourExtension('affine:bookmark'), | ||
FlavourExtension(Flavour), | ||
BookmarkBlockService, | ||
CommandExtension(commands), | ||
BlockViewExtension('affine:bookmark', model => { | ||
BlockViewExtension(Flavour, model => { | ||
return model.parent?.flavour === 'affine:surface' | ||
? literal`affine-edgeless-bookmark` | ||
: literal`affine-bookmark`; | ||
}), | ||
BookmarkBlockAdapterExtensions, | ||
ToolbarModuleExtension({ | ||
id: BlockFlavourIdentifier(Flavour), | ||
config: builtinToolbarConfig, | ||
}), | ||
].flat(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { | ||
ToolbarActionGroup, | ||
ToolbarModuleConfig, | ||
} from '@blocksuite/affine-shared/services'; | ||
|
||
export const builtinToolbarConfig = { | ||
actions: [ | ||
{ | ||
id: 'conversions', | ||
actions: [ | ||
{ | ||
id: 'inline-view', | ||
label: 'Inline view', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'card-view', | ||
label: 'Card view', | ||
run(_cx) {}, | ||
}, | ||
], | ||
content(_cx) { | ||
this.actions; | ||
return null; | ||
}, | ||
} satisfies ToolbarActionGroup, | ||
{ | ||
id: 'style', | ||
tooltip: 'Card style', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'caption', | ||
tooltip: 'Caption', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'clipboard', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'copy', | ||
label: 'Copy', | ||
run(_cx) {}, | ||
}, | ||
{ | ||
id: 'duplicate', | ||
label: 'Duplicate', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'refresh', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'reload', | ||
label: 'Reload', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
{ | ||
id: 'delete', | ||
placement: 'more', | ||
actions: [ | ||
{ | ||
id: 'delete', | ||
label: 'Delete', | ||
run(_cx) {}, | ||
}, | ||
], | ||
}, | ||
], | ||
} as const satisfies ToolbarModuleConfig; |
Oops, something went wrong.