From 44b67ce20f904b79d43a87746913e9075ee9fc6f Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Fri, 11 Aug 2023 00:02:14 +0200 Subject: [PATCH] feat: decouple copy-paste and create --- lib/features/copy-paste/CopyPaste.js | 11 ++++++----- lib/features/copy-paste/index.js | 2 -- test/spec/features/copy-paste/CopyPasteSpec.js | 2 ++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/features/copy-paste/CopyPaste.js b/lib/features/copy-paste/CopyPaste.js index 814e57c0b..633c44451 100644 --- a/lib/features/copy-paste/CopyPaste.js +++ b/lib/features/copy-paste/CopyPaste.js @@ -67,7 +67,6 @@ import { * Copy and paste elements. * * @param {Canvas} canvas - * @param {Create} create * @param {Clipboard} clipboard * @param {ElementFactory} elementFactory * @param {EventBus} eventBus @@ -77,7 +76,6 @@ import { */ export default function CopyPaste( canvas, - create, clipboard, elementFactory, eventBus, @@ -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; @@ -164,7 +166,6 @@ export default function CopyPaste( CopyPaste.$inject = [ 'canvas', - 'create', 'clipboard', 'elementFactory', 'eventBus', @@ -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 || {} }); }; diff --git a/lib/features/copy-paste/index.js b/lib/features/copy-paste/index.js index 59b61fd2c..ad51eea42 100644 --- a/lib/features/copy-paste/index.js +++ b/lib/features/copy-paste/index.js @@ -1,5 +1,4 @@ import ClipboardModule from '../clipboard'; -import CreateModule from '../create'; import RulesModule from '../rules'; import CopyPaste from './CopyPaste'; @@ -11,7 +10,6 @@ import CopyPaste from './CopyPaste'; export default { __depends__: [ ClipboardModule, - CreateModule, RulesModule ], __init__: [ 'copyPaste' ], diff --git a/test/spec/features/copy-paste/CopyPasteSpec.js b/test/spec/features/copy-paste/CopyPasteSpec.js index 5aa4eede7..484b05811 100644 --- a/test/spec/features/copy-paste/CopyPasteSpec.js +++ b/test/spec/features/copy-paste/CopyPasteSpec.js @@ -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'; @@ -36,6 +37,7 @@ describe('features/copy-paste', function() { modules: [ attachSupportModule, copyPasteModule, + createModule, modelingModule, rulesModule, selectionModule