fix: have the connection previewer use the registry (#7800)

This commit is contained in:
Beka Westberg
2024-01-26 14:33:27 -08:00
parent bdbfabce6c
commit 1d49ecb1a0
3 changed files with 15 additions and 5 deletions

View File

@@ -31,7 +31,6 @@ import {hasBubble} from './interfaces/i_has_bubble.js';
import * as deprecation from './utils/deprecation.js';
import * as layers from './layers.js';
import {ConnectionType, IConnectionPreviewer} from './blockly.js';
import {InsertionMarkerPreviewer} from './connection_previewers/insertion_marker_previewer.js';
import {RenderedConnection} from './rendered_connection.js';
import {config} from './config.js';
import {ComponentManager} from './component_manager.js';
@@ -86,12 +85,14 @@ export class BlockDragger implements IBlockDragger {
*/
constructor(block: BlockSvg, workspace: WorkspaceSvg) {
this.draggingBlock_ = block;
// TODO: have this access the registry instead.
this.connectionPreviewer = new InsertionMarkerPreviewer(block);
this.workspace_ = workspace;
const previewerConstructor = registry.getClassFromOptions(
registry.Type.CONNECTION_PREVIEWER,
this.workspace_.options,
);
this.connectionPreviewer = new previewerConstructor!(block);
/**
* The location of the top left corner of the dragging block at the
* beginning of the drag in workspace coordinates.

View File

@@ -128,6 +128,7 @@ import {Input} from './inputs/input.js';
import {inputTypes} from './inputs/input_types.js';
import * as inputs from './inputs.js';
import {InsertionMarkerManager} from './insertion_marker_manager.js';
import {InsertionMarkerPreviewer} from './connection_previewers/insertion_marker_previewer.js';
import {IASTNodeLocation} from './interfaces/i_ast_node_location.js';
import {IASTNodeLocationSvg} from './interfaces/i_ast_node_location_svg.js';
import {IASTNodeLocationWithBlock} from './interfaces/i_ast_node_location_with_block.js';
@@ -607,6 +608,7 @@ export {IMovable};
export {Input};
export {inputs};
export {InsertionMarkerManager};
export {InsertionMarkerPreviewer};
export {IObservable, isObservable};
export {IPaster, isPaster};
export {IPositionable};

View File

@@ -11,6 +11,7 @@ import {WorkspaceSvg} from '../workspace_svg.js';
import * as eventUtils from '../events/utils.js';
import * as constants from '../constants.js';
import * as renderManagement from '../render_management.js';
import * as registry from '../registry.js';
/**
* An error message to throw if the block created by createMarkerBlock_ is
@@ -247,3 +248,9 @@ export class InsertionMarkerPreviewer implements IConnectionPreviewer {
this.hidePreview();
}
}
registry.register(
registry.Type.CONNECTION_PREVIEWER,
registry.DEFAULT,
InsertionMarkerPreviewer,
);