mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
refactor(editor): cleanup dead code (#9300)
This commit is contained in:
@@ -12,7 +12,6 @@ import type {
|
||||
import type { listToParagraphCommand } from './commands/list-to-paragraph.js';
|
||||
import type { splitListCommand } from './commands/split-list.js';
|
||||
import { ListBlockComponent } from './list-block.js';
|
||||
import type { ListBlockService } from './list-service.js';
|
||||
|
||||
export function effects() {
|
||||
customElements.define('affine-list', ListBlockComponent);
|
||||
@@ -20,10 +19,6 @@ export function effects() {
|
||||
|
||||
declare global {
|
||||
namespace BlockSuite {
|
||||
interface BlockServices {
|
||||
'affine:list': ListBlockService;
|
||||
}
|
||||
|
||||
interface CommandContext {
|
||||
listConvertedId?: string;
|
||||
indentContext?: IndentContext;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export * from './adapters/index.js';
|
||||
export { correctNumberedListsOrderToPrev } from './commands/utils';
|
||||
export * from './list-block.js';
|
||||
export * from './list-service.js';
|
||||
export * from './list-spec.js';
|
||||
|
||||
@@ -24,14 +24,10 @@ import { classMap } from 'lit/directives/class-map.js';
|
||||
import { styleMap } from 'lit/directives/style-map.js';
|
||||
|
||||
import { correctNumberedListsOrderToPrev } from './commands/utils.js';
|
||||
import type { ListBlockService } from './list-service.js';
|
||||
import { listBlockStyles } from './styles.js';
|
||||
import { getListIcon } from './utils/get-list-icon.js';
|
||||
|
||||
export class ListBlockComponent extends CaptionedBlockComponent<
|
||||
ListBlockModel,
|
||||
ListBlockService
|
||||
> {
|
||||
export class ListBlockComponent extends CaptionedBlockComponent<ListBlockModel> {
|
||||
static override styles = listBlockStyles;
|
||||
|
||||
private _inlineRangeProvider: InlineRangeProvider | null = null;
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { ListBlockSchema } from '@blocksuite/affine-model';
|
||||
import { BlockService } from '@blocksuite/block-std';
|
||||
|
||||
export class ListBlockService extends BlockService {
|
||||
static override readonly flavour = ListBlockSchema.model.flavour;
|
||||
}
|
||||
@@ -9,11 +9,9 @@ import { literal } from 'lit/static-html.js';
|
||||
import { ListBlockAdapterExtensions } from './adapters/extension.js';
|
||||
import { commands } from './commands/index.js';
|
||||
import { ListKeymapExtension, ListTextKeymapExtension } from './list-keymap.js';
|
||||
import { ListBlockService } from './list-service.js';
|
||||
|
||||
export const ListBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:list'),
|
||||
ListBlockService,
|
||||
CommandExtension(commands),
|
||||
BlockViewExtension('affine:list', literal`affine-list`),
|
||||
ListKeymapExtension,
|
||||
|
||||
@@ -5,10 +5,7 @@ import {
|
||||
} from '@blocksuite/block-std';
|
||||
import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { DataViewBlockService } from './database-service.js';
|
||||
|
||||
export const DataViewBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:data-view'),
|
||||
DataViewBlockService,
|
||||
BlockViewExtension('affine:data-view', literal`affine-data-view`),
|
||||
];
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
import { BlockService } from '@blocksuite/block-std';
|
||||
import { DatabaseSelection } from '@blocksuite/data-view';
|
||||
|
||||
import { DataViewBlockSchema } from './data-view-model.js';
|
||||
|
||||
export class DataViewBlockService extends BlockService {
|
||||
static override readonly flavour = DataViewBlockSchema.model.flavour;
|
||||
|
||||
override mounted(): void {
|
||||
super.mounted();
|
||||
this.selectionManager.register(DatabaseSelection);
|
||||
}
|
||||
}
|
||||
@@ -271,7 +271,6 @@ import { effects as blockSurfaceRefEffects } from './surface-ref-block/effects.j
|
||||
import {
|
||||
EdgelessSurfaceRefBlockComponent,
|
||||
SurfaceRefBlockComponent,
|
||||
type SurfaceRefBlockService,
|
||||
} from './surface-ref-block/index.js';
|
||||
import { SurfaceRefGenericBlockPortal } from './surface-ref-block/portal/generic-block.js';
|
||||
import { SurfaceRefNotePortal } from './surface-ref-block/portal/note.js';
|
||||
@@ -611,7 +610,6 @@ declare global {
|
||||
'affine:bookmark': BookmarkBlockService;
|
||||
'affine:database': DatabaseBlockService;
|
||||
'affine:image': ImageBlockService;
|
||||
'affine:surface-ref': SurfaceRefBlockService;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
export * from './surface-ref-block.js';
|
||||
export * from './surface-ref-block-edgeless.js';
|
||||
export * from './surface-ref-service.js';
|
||||
export {
|
||||
EdgelessSurfaceRefBlockSpec,
|
||||
PageSurfaceRefBlockSpec,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
||||
import {
|
||||
type SurfaceBlockModel,
|
||||
SurfaceElementModel,
|
||||
@@ -46,7 +45,6 @@ import { styleMap } from 'lit/directives/style-map.js';
|
||||
import { SpecProvider } from '../_specs/index.js';
|
||||
import type { EdgelessRootPreviewBlockComponent } from '../root-block/edgeless/edgeless-root-preview-block.js';
|
||||
import { EdgelessRootService } from '../root-block/index.js';
|
||||
import type { SurfaceRefBlockService } from './surface-ref-service.js';
|
||||
import { noContentPlaceholder } from './utils.js';
|
||||
|
||||
const REF_LABEL_ICON = {
|
||||
@@ -66,10 +64,7 @@ const NO_CONTENT_REASON = {
|
||||
} as Record<string, string>;
|
||||
|
||||
@Peekable()
|
||||
export class SurfaceRefBlockComponent extends BlockComponent<
|
||||
SurfaceRefBlockModel,
|
||||
SurfaceRefBlockService
|
||||
> {
|
||||
export class SurfaceRefBlockComponent extends BlockComponent<SurfaceRefBlockModel> {
|
||||
static override styles = css`
|
||||
.affine-surface-ref {
|
||||
position: relative;
|
||||
@@ -599,8 +594,6 @@ export class SurfaceRefBlockComponent extends BlockComponent<
|
||||
|
||||
if (!this._shouldRender) return;
|
||||
|
||||
const service = this.service;
|
||||
assertExists(service, `Surface ref block must run with its service.`);
|
||||
this._initHotkey();
|
||||
this._initSpec();
|
||||
this._initReferencedModel();
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
import { SurfaceRefBlockSchema } from '@blocksuite/affine-model';
|
||||
import { BlockService } from '@blocksuite/block-std';
|
||||
|
||||
export class SurfaceRefBlockService extends BlockService {
|
||||
static override readonly flavour = SurfaceRefBlockSchema.model.flavour;
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import {
|
||||
import { literal } from 'lit/static-html.js';
|
||||
|
||||
import { commands } from './commands.js';
|
||||
import { SurfaceRefBlockService } from './surface-ref-service.js';
|
||||
|
||||
export const PageSurfaceRefBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:surface-ref'),
|
||||
SurfaceRefBlockService,
|
||||
CommandExtension(commands),
|
||||
BlockViewExtension('affine:surface-ref', literal`affine-surface-ref`),
|
||||
WidgetViewMapExtension('affine:surface-ref', {
|
||||
@@ -22,7 +20,6 @@ export const PageSurfaceRefBlockSpec: ExtensionType[] = [
|
||||
|
||||
export const EdgelessSurfaceRefBlockSpec: ExtensionType[] = [
|
||||
FlavourExtension('affine:surface-ref'),
|
||||
SurfaceRefBlockService,
|
||||
BlockViewExtension(
|
||||
'affine:surface-ref',
|
||||
literal`affine-edgeless-surface-ref`
|
||||
|
||||
@@ -74,7 +74,7 @@ export class WidgetComponent<
|
||||
super.connectedCallback();
|
||||
this.std.view.setWidget(this);
|
||||
|
||||
this.service.specSlots.widgetConnected.emit({
|
||||
this.service?.specSlots.widgetConnected.emit({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
@@ -83,7 +83,7 @@ export class WidgetComponent<
|
||||
override disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this.std?.view.deleteWidget(this);
|
||||
this.service.specSlots.widgetDisconnected.emit({
|
||||
this.service?.specSlots.widgetDisconnected.emit({
|
||||
service: this.service,
|
||||
component: this,
|
||||
});
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import {
|
||||
BlockFlavourIdentifier,
|
||||
BlockServiceIdentifier,
|
||||
type ExtensionType,
|
||||
StdIdentifier,
|
||||
} from '@blocksuite/block-std';
|
||||
import {
|
||||
AttachmentBlockService,
|
||||
EdgelessEditorBlockSpecs,
|
||||
PageEditorBlockSpecs,
|
||||
} from '@blocksuite/blocks';
|
||||
|
||||
class CustomAttachmentBlockService extends AttachmentBlockService {
|
||||
override mounted(): void {
|
||||
super.mounted();
|
||||
this.maxFileSize = 100 * 1000 * 1000; // 100MB
|
||||
}
|
||||
}
|
||||
|
||||
export function getCustomAttachmentSpecs() {
|
||||
const pageModeSpecs: ExtensionType[] = [
|
||||
...PageEditorBlockSpecs,
|
||||
{
|
||||
setup: di => {
|
||||
di.override(
|
||||
BlockServiceIdentifier('affine:attachment'),
|
||||
CustomAttachmentBlockService,
|
||||
[StdIdentifier, BlockFlavourIdentifier('affine:attachment')]
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
const edgelessModeSpecs: ExtensionType[] = [
|
||||
...EdgelessEditorBlockSpecs,
|
||||
{
|
||||
setup: di => {
|
||||
di.override(
|
||||
BlockServiceIdentifier('affine:attachment'),
|
||||
CustomAttachmentBlockService,
|
||||
[StdIdentifier, BlockFlavourIdentifier('affine:attachment')]
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
return {
|
||||
pageModeSpecs,
|
||||
edgelessModeSpecs,
|
||||
};
|
||||
}
|
||||
@@ -3,21 +3,9 @@ import {
|
||||
PageEditorBlockSpecs,
|
||||
} from '@blocksuite/blocks';
|
||||
|
||||
import { getCustomAttachmentSpecs } from './custom-attachment/custom-attachment.js';
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
|
||||
export function getExampleSpecs() {
|
||||
const type = params.get('exampleSpec');
|
||||
|
||||
let pageModeSpecs = PageEditorBlockSpecs;
|
||||
let edgelessModeSpecs = EdgelessEditorBlockSpecs;
|
||||
|
||||
if (type === 'attachment') {
|
||||
const specs = getCustomAttachmentSpecs();
|
||||
pageModeSpecs = specs.pageModeSpecs;
|
||||
edgelessModeSpecs = specs.edgelessModeSpecs;
|
||||
}
|
||||
const pageModeSpecs = PageEditorBlockSpecs;
|
||||
const edgelessModeSpecs = EdgelessEditorBlockSpecs;
|
||||
|
||||
return {
|
||||
pageModeSpecs,
|
||||
|
||||
Reference in New Issue
Block a user