revert: "refactor: Remove block and workspace drag surfaces (#6758)" (#6888)

This reverts commit 332c0fd2f2.
This commit is contained in:
Maribeth Bottorff
2023-03-09 13:43:12 -08:00
committed by GitHub
parent c0934216f8
commit cdb1215d95
15 changed files with 791 additions and 30 deletions

View File

@@ -12,6 +12,7 @@
import * as goog from '../closure/goog/goog.js';
goog.declareModuleId('Blockly.inject');
import {BlockDragSurfaceSvg} from './block_drag_surface.js';
import type {BlocklyOptions} from './blockly_options.js';
import * as browserEvents from './browser_events.js';
import * as bumpObjects from './bump_objects.js';
@@ -30,6 +31,7 @@ import * as dom from './utils/dom.js';
import {Svg} from './utils/svg.js';
import * as userAgent from './utils/useragent.js';
import * as WidgetDiv from './widgetdiv.js';
import {WorkspaceDragSurfaceSvg} from './workspace_drag_surface_svg.js';
import {WorkspaceSvg} from './workspace_svg.js';
@@ -66,7 +68,14 @@ export function inject(
(container as AnyDuringMigration).appendChild(subContainer);
const svg = createDom(subContainer, options);
const workspace = createMainWorkspace(svg, options);
// Create surfaces for dragging things. These are optimizations
// so that the browser does not repaint during the drag.
const blockDragSurface = new BlockDragSurfaceSvg(subContainer);
const workspaceDragSurface = new WorkspaceDragSurfaceSvg(subContainer);
const workspace =
createMainWorkspace(svg, options, blockDragSurface, workspaceDragSurface);
init(workspace);
@@ -144,11 +153,16 @@ function createDom(container: Element, options: Options): SVGElement {
*
* @param svg SVG element with pattern defined.
* @param options Dictionary of options.
* @param blockDragSurface Drag surface SVG for the blocks.
* @param workspaceDragSurface Drag surface SVG for the workspace.
* @returns Newly created main workspace.
*/
function createMainWorkspace(svg: SVGElement, options: Options): WorkspaceSvg {
function createMainWorkspace(
svg: SVGElement, options: Options, blockDragSurface: BlockDragSurfaceSvg,
workspaceDragSurface: WorkspaceDragSurfaceSvg): WorkspaceSvg {
options.parentWorkspace = null;
const mainWorkspace = new WorkspaceSvg(options);
const mainWorkspace =
new WorkspaceSvg(options, blockDragSurface, workspaceDragSurface);
const wsOptions = mainWorkspace.options;
mainWorkspace.scale = wsOptions.zoomOptions.startScale;
svg.appendChild(mainWorkspace.createDom('blocklyMainBackground'));