mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-26 02:35:58 +08:00
refactor(editor): unify directories naming (#11516)
**Directory Structure Changes** - Renamed multiple block-related directories by removing the "block-" prefix: - `block-attachment` → `attachment` - `block-bookmark` → `bookmark` - `block-callout` → `callout` - `block-code` → `code` - `block-data-view` → `data-view` - `block-database` → `database` - `block-divider` → `divider` - `block-edgeless-text` → `edgeless-text` - `block-embed` → `embed`
This commit is contained in:
95
blocksuite/affine/blocks/surface-ref/src/configs/toolbar.ts
Normal file
95
blocksuite/affine/blocks/surface-ref/src/configs/toolbar.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
import { toast } from '@blocksuite/affine-components/toast';
|
||||
import {
|
||||
copySelectedModelsCommand,
|
||||
draftSelectedModelsCommand,
|
||||
} from '@blocksuite/affine-shared/commands';
|
||||
import {
|
||||
ActionPlacement,
|
||||
type ToolbarModuleConfig,
|
||||
} from '@blocksuite/affine-shared/services';
|
||||
import { CaptionIcon, CopyIcon, DeleteIcon } from '@blocksuite/icons/lit';
|
||||
import { html } from 'lit';
|
||||
|
||||
import { SurfaceRefBlockComponent } from '../surface-ref-block';
|
||||
|
||||
export const surfaceRefToolbarModuleConfig: ToolbarModuleConfig = {
|
||||
actions: [
|
||||
{
|
||||
id: 'a.surface-ref-title',
|
||||
when: ctx =>
|
||||
!!ctx.getCurrentBlockByType(SurfaceRefBlockComponent)?.referenceModel,
|
||||
content: ctx => {
|
||||
const surfaceRefBlock = ctx.getCurrentBlockByType(
|
||||
SurfaceRefBlockComponent
|
||||
);
|
||||
if (!surfaceRefBlock) return null;
|
||||
|
||||
return html`<surface-ref-toolbar-title
|
||||
.referenceModel=${surfaceRefBlock.referenceModel}
|
||||
></surface-ref-toolbar-title>`;
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'c.copy-surface-ref',
|
||||
label: 'Copy',
|
||||
icon: CopyIcon(),
|
||||
run: ctx => {
|
||||
const surfaceRefBlock = ctx.getCurrentBlockByType(
|
||||
SurfaceRefBlockComponent
|
||||
);
|
||||
if (!surfaceRefBlock) return;
|
||||
|
||||
ctx.chain
|
||||
.pipe(draftSelectedModelsCommand, {
|
||||
selectedModels: [surfaceRefBlock.model],
|
||||
})
|
||||
.pipe(copySelectedModelsCommand)
|
||||
.run();
|
||||
|
||||
toast(surfaceRefBlock.std.host, 'Copied to clipboard');
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'd.surface-ref-caption',
|
||||
icon: CaptionIcon(),
|
||||
run: ctx => {
|
||||
const surfaceRefBlock = ctx.getCurrentBlockByType(
|
||||
SurfaceRefBlockComponent
|
||||
);
|
||||
if (!surfaceRefBlock) return;
|
||||
|
||||
surfaceRefBlock.captionElement.show();
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'a.clipboard',
|
||||
placement: ActionPlacement.More,
|
||||
when: ctx => {
|
||||
const surfaceRefBlock = ctx.getCurrentBlock();
|
||||
if (!(surfaceRefBlock instanceof SurfaceRefBlockComponent))
|
||||
return false;
|
||||
|
||||
return !!surfaceRefBlock.referenceModel;
|
||||
},
|
||||
actions: [
|
||||
// TODO(@L-Sun): add duplicate action after refactoring root-block/edgeless
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'g.surface-ref-deletion',
|
||||
label: 'Delete',
|
||||
icon: DeleteIcon(),
|
||||
placement: ActionPlacement.More,
|
||||
variant: 'destructive',
|
||||
run: ctx => {
|
||||
const surfaceRefBlock = ctx.getCurrentBlockByType(
|
||||
SurfaceRefBlockComponent
|
||||
);
|
||||
if (!surfaceRefBlock) return;
|
||||
|
||||
ctx.store.deleteBlock(surfaceRefBlock.model);
|
||||
},
|
||||
},
|
||||
],
|
||||
placement: 'inner',
|
||||
};
|
||||
Reference in New Issue
Block a user