Skip to content

Commit

Permalink
feat: decouple copy-paste and create
Browse files Browse the repository at this point in the history
  • Loading branch information
nikku committed Aug 11, 2023
1 parent 5db35ec commit 44b67ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions lib/features/copy-paste/CopyPaste.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import {
* Copy and paste elements.
*
* @param {Canvas} canvas
* @param {Create} create
* @param {Clipboard} clipboard
* @param {ElementFactory} elementFactory
* @param {EventBus} eventBus
Expand All @@ -77,7 +76,6 @@ import {
*/
export default function CopyPaste(
canvas,
create,
clipboard,
elementFactory,
eventBus,
Expand All @@ -87,7 +85,11 @@ export default function CopyPaste(
) {

this._canvas = canvas;
this._create = create;

/**
* @type {Create} create
*/
this._create = injector.get('create', false);
this._clipboard = clipboard;
this._elementFactory = elementFactory;
this._eventBus = eventBus;
Expand Down Expand Up @@ -164,7 +166,6 @@ export default function CopyPaste(

CopyPaste.$inject = [
'canvas',
'create',
'clipboard',
'elementFactory',
'eventBus',
Expand Down Expand Up @@ -241,7 +242,7 @@ CopyPaste.prototype.paste = function(context) {

var mouseEvent = this._mouse && this._mouse.getLastMoveEvent();

this._create.start(mouseEvent, elements, {
this._create && this._create.start(mouseEvent, elements, {
hints: hints || {}
});
};
Expand Down
2 changes: 0 additions & 2 deletions lib/features/copy-paste/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ClipboardModule from '../clipboard';
import CreateModule from '../create';
import RulesModule from '../rules';

import CopyPaste from './CopyPaste';
Expand All @@ -11,7 +10,6 @@ import CopyPaste from './CopyPaste';
export default {
__depends__: [
ClipboardModule,
CreateModule,
RulesModule
],
__init__: [ 'copyPaste' ],
Expand Down
2 changes: 2 additions & 0 deletions test/spec/features/copy-paste/CopyPasteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {

import attachSupportModule from 'lib/features/attach-support';
import copyPasteModule from 'lib/features/copy-paste';
import createModule from 'lib/features/create';
import modelingModule from 'lib/features/modeling';
import rulesModule from './rules';
import selectionModule from 'lib/features/selection';
Expand All @@ -36,6 +37,7 @@ describe('features/copy-paste', function() {
modules: [
attachSupportModule,
copyPasteModule,
createModule,
modelingModule,
rulesModule,
selectionModule
Expand Down

0 comments on commit 44b67ce

Please sign in to comment.