mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-19 02:56:23 +08:00
refactor(editor): cleanup duplicated code (#11548)
This commit is contained in:
@@ -258,7 +258,7 @@ export const moreActions = [
|
||||
other: 'new doc',
|
||||
});
|
||||
|
||||
moveConnectors(model.id, cardId, edgeless.service);
|
||||
moveConnectors(model.id, cardId, ctx.std);
|
||||
|
||||
// Deletes selected note
|
||||
ctx.store.transact(() => {
|
||||
|
||||
@@ -19,6 +19,7 @@ import {
|
||||
} from '@blocksuite/affine-gfx-mindmap';
|
||||
import { NoteTool } from '@blocksuite/affine-gfx-note';
|
||||
import { ShapeTool } from '@blocksuite/affine-gfx-shape';
|
||||
import { TemplateTool } from '@blocksuite/affine-gfx-template';
|
||||
import { TextTool } from '@blocksuite/affine-gfx-text';
|
||||
import { ElementTransformManager } from '@blocksuite/std/gfx';
|
||||
import type { ExtensionType } from '@blocksuite/store';
|
||||
@@ -30,7 +31,6 @@ import { SnapExtension } from './element-transform/snap-manager.js';
|
||||
import { DefaultTool } from './gfx-tool/default-tool.js';
|
||||
import { EmptyTool } from './gfx-tool/empty-tool.js';
|
||||
import { PanTool } from './gfx-tool/pan-tool.js';
|
||||
import { TemplateTool } from './gfx-tool/template-tool.js';
|
||||
import { EditPropsMiddlewareBuilder } from './middlewares/base.js';
|
||||
import { SnapOverlay } from './utils/snap-manager.js';
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
export { DefaultTool } from './default-tool.js';
|
||||
export { EmptyTool } from './empty-tool.js';
|
||||
export { PanTool, type PanToolOption } from './pan-tool.js';
|
||||
export { TemplateTool } from './template-tool.js';
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import { BaseTool } from '@blocksuite/std/gfx';
|
||||
|
||||
export class TemplateTool extends BaseTool {
|
||||
static override toolName: string = 'template';
|
||||
}
|
||||
|
||||
declare module '@blocksuite/std/gfx' {
|
||||
interface GfxToolsMap {
|
||||
template: TemplateTool;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
||||
|
||||
import type { EdgelessRootService } from '../edgeless-root-service.js';
|
||||
import {
|
||||
EdgelessCRUDIdentifier,
|
||||
getSurfaceBlock,
|
||||
} from '@blocksuite/affine-block-surface';
|
||||
import type { BlockStdScope } from '@blocksuite/std';
|
||||
|
||||
/**
|
||||
* move connectors from origin to target
|
||||
@@ -11,10 +13,12 @@ import type { EdgelessRootService } from '../edgeless-root-service.js';
|
||||
export function moveConnectors(
|
||||
originId: string,
|
||||
targetId: string,
|
||||
service: EdgelessRootService
|
||||
std: BlockStdScope
|
||||
) {
|
||||
const connectors = service.surface.getConnectors(originId);
|
||||
const crud = service.std.get(EdgelessCRUDIdentifier);
|
||||
const model = getSurfaceBlock(std.store);
|
||||
if (!model) return;
|
||||
const connectors = model.getConnectors(originId);
|
||||
const crud = std.get(EdgelessCRUDIdentifier);
|
||||
connectors.forEach(connector => {
|
||||
if (connector.source.id === originId) {
|
||||
crud.updateElement(connector.id, {
|
||||
|
||||
@@ -10,7 +10,6 @@ import { WidgetComponent } from '@blocksuite/std';
|
||||
import { effect, signal } from '@preact/signals-core';
|
||||
import { html, nothing } from 'lit';
|
||||
|
||||
import type { PageRootBlockComponent } from '../../page/page-root-block.js';
|
||||
import { RootBlockConfigExtension } from '../../root-config.js';
|
||||
import { defaultKeyboardToolbarConfig } from './config.js';
|
||||
|
||||
@@ -18,10 +17,7 @@ export * from './config.js';
|
||||
|
||||
export const AFFINE_KEYBOARD_TOOLBAR_WIDGET = 'affine-keyboard-toolbar-widget';
|
||||
|
||||
export class AffineKeyboardToolbarWidget extends WidgetComponent<
|
||||
RootBlockModel,
|
||||
PageRootBlockComponent
|
||||
> {
|
||||
export class AffineKeyboardToolbarWidget extends WidgetComponent<RootBlockModel> {
|
||||
private readonly _close = (blur: boolean) => {
|
||||
if (blur) {
|
||||
if (document.activeElement === this._docTitle?.inlineEditorContainer) {
|
||||
|
||||
Reference in New Issue
Block a user