From 3145ef1bbc09f36374020c59bc9d8ebba5d6211c Mon Sep 17 00:00:00 2001 From: usbsync Date: Thu, 21 Nov 2024 16:59:08 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=8A=88=208891=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extern/lang/en.js | 7 ++--- extern/lang/ko.js | 7 ++--- src/command/commands/block.js | 51 +++++++++++++++++++++++++---------- src/playground/block_view.js | 14 ++++++++-- src/playground/workspace.js | 2 +- 5 files changed, 58 insertions(+), 23 deletions(-) diff --git a/extern/lang/en.js b/extern/lang/en.js index 5921e8141f..a66d6d6d1c 100644 --- a/extern/lang/en.js +++ b/extern/lang/en.js @@ -1436,9 +1436,10 @@ Lang.Blocks = { START_message_cast_wait: 'message and wait', START_message_send_wait_1: 'Send', START_message_send_wait_2: ' message and wait', - Duplication_option: 'copy & paste', - CONTEXT_COPY_option: 'copy code(s)', - Delete_Blocks: 'delete code(s)', + Duplication_option: 'Duplicate', + cut_blocks: 'Cut', + CONTEXT_COPY_option: 'Copy', + Delete_Blocks: 'Remove', add_my_storage: 'add to my storage', export_object: 'Export Object', this_project: 'this project', diff --git a/extern/lang/ko.js b/extern/lang/ko.js index 1267d4e3e9..d395e3b399 100644 --- a/extern/lang/ko.js +++ b/extern/lang/ko.js @@ -1284,9 +1284,10 @@ Lang.Blocks = { TUT_repeat_until_gold: '부품에 도달할 때 까지 반복', TUT_declare_function: '함수 선언', TUT_call_function: '함수 호출', - CONTEXT_COPY_option: '코드 복사', - Delete_Blocks: '코드 삭제', - Duplication_option: '코드 복사 & 붙여넣기', + CONTEXT_COPY_option: '코드 복사하기', + Delete_Blocks: '코드 삭제하기', + Duplication_option: '코드 복제하기', + cut_blocks: '코드 잘라내기', Paste_blocks: '붙여넣기', add_my_storage: '나의 보관함에 추가하기', export_object: '오브젝트 파일로 내보내기', diff --git a/src/command/commands/block.js b/src/command/commands/block.js index 340c9d7dd8..12d6111d73 100644 --- a/src/command/commands/block.js +++ b/src/command/commands/block.js @@ -4,7 +4,7 @@ 'use strict'; import isFunction from 'lodash/isFunction'; -(function(c) { +(function (c) { const COMMAND_TYPES = Entry.STATIC.COMMAND_TYPES; let obj; @@ -22,7 +22,10 @@ import isFunction from 'lodash/isFunction'; if (blocks instanceof Entry.Thread) { blocks = blocks.toJSON(); } - return [['blocks', blocks], ['index', index]]; + return [ + ['blocks', blocks], + ['index', index], + ]; }, undo: 'destroyThread', recordable: Entry.STATIC.RECORDABLE.SUPPORT, @@ -31,7 +34,7 @@ import isFunction from 'lodash/isFunction'; }; obj = _.clone(c[COMMAND_TYPES.addThread]); - obj.showMe = function(restrictor) { + obj.showMe = function (restrictor) { if (restrictor.isTooltipFaded()) { return; } @@ -54,7 +57,7 @@ import isFunction from 'lodash/isFunction'; }); }; obj.followCmd = true; - obj.restrict = function(data, domQuery, callback, restrictor) { + obj.restrict = function (data, domQuery, callback, restrictor) { const nextCmd = restrictor.requestNextData().content; if (nextCmd[0] === Entry.STATIC.COMMAND_TYPES.insertBlockFromBlockMenu) { Entry.Command.editor.board.scrollToPointer(nextCmd[2][1]); @@ -161,7 +164,10 @@ import isFunction from 'lodash/isFunction'; }, log(block, pointer) { block = this.editor.board.findBlock(block.id); - return [['block', block], ['pointer', pointer]]; + return [ + ['block', block], + ['pointer', pointer], + ]; }, undo: 'destroyBlock', }; @@ -319,7 +325,7 @@ import isFunction from 'lodash/isFunction'; c[COMMAND_TYPES.insertBlockFollowSeparate] = obj; obj = _.clone(c[COMMAND_TYPES.insertBlock]); - obj.restrict = function(data, domQuery, callback, restrictor) { + obj.restrict = function (data, domQuery, callback, restrictor) { if (restrictor.toolTipRender) { if (restrictor.toolTipRender) { const target = Entry.Command.editor.board.code.getByPointer(data.content[2][1]); @@ -408,7 +414,11 @@ import isFunction from 'lodash/isFunction'; block = block.view; } - return [['block', blockPointer], ['x', block.x], ['y', block.y]]; + return [ + ['block', blockPointer], + ['x', block.x], + ['y', block.y], + ]; }, restrict(data, domQuery, callback, restrictor) { Entry.Command.editor.board.scrollToPointer(data.content[1][1]); @@ -469,7 +479,7 @@ import isFunction from 'lodash/isFunction'; }; obj = _.clone(c[COMMAND_TYPES.separateBlock]); - obj.restrict = function(data, domQuery, callback, restrictor) { + obj.restrict = function (data, domQuery, callback, restrictor) { Entry.Command.editor.board.scrollToPointer(data.content[1][1]); let isDone = false; if (restrictor.toolTipRender) { @@ -517,7 +527,7 @@ import isFunction from 'lodash/isFunction'; ); return tooltip; }; - obj.showMe = function(restrictor) { + obj.showMe = function (restrictor) { if (restrictor.isTooltipFaded()) { return; } @@ -598,7 +608,11 @@ import isFunction from 'lodash/isFunction'; console.error('moveBlock: target not exist ', block); return []; } - return [['block', block.pointer()], ['x', block.view.x], ['y', block.view.y]]; + return [ + ['block', block.pointer()], + ['x', block.view.x], + ['y', block.view.y], + ]; }, undo: 'moveBlock', dom: ['playground', 'board', '&0'], @@ -606,7 +620,7 @@ import isFunction from 'lodash/isFunction'; obj = _.clone(c[COMMAND_TYPES.moveBlock]); obj.followCmd = true; - obj.restrict = function(data, domQuery, callback, restrictor) { + obj.restrict = function (data, domQuery, callback, restrictor) { Entry.Command.editor.board.scrollToPointer(data.content[1][1]); let isDone = false; if (restrictor.toolTipRender) { @@ -657,7 +671,7 @@ import isFunction from 'lodash/isFunction'; c[COMMAND_TYPES.moveBlockForDestroy] = obj; obj = _.clone(c[COMMAND_TYPES.moveBlock]); - obj.restrict = function(data, domQuery, callback) { + obj.restrict = function (data, domQuery, callback) { callback(); return new Entry.Tooltip( [ @@ -693,7 +707,10 @@ import isFunction from 'lodash/isFunction'; return [-dx, -dy]; }, log(dx, dy) { - return [['dx', dx], ['dy', dy]]; + return [ + ['dx', dx], + ['dy', dy], + ]; }, recordable: Entry.STATIC.RECORDABLE.SKIP, undo: 'scrollBoard', @@ -722,7 +739,10 @@ import isFunction from 'lodash/isFunction'; return [pointer, field._startValue || field.getValue()]; }, log(pointer, value) { - return [['pointer', pointer], ['value', value]]; + return [ + ['pointer', pointer], + ['value', value], + ]; }, restrict(data, domQuery, callback, restrictor) { let isDone = false; @@ -899,6 +919,9 @@ import isFunction from 'lodash/isFunction'; do(block) { block = this.editor.board.findBlock(block); block.doDestroyBelow(true); + if (block.isParamBlockType()) { + block.thread.updateValueBlock(); + } }, state(block) { block = this.editor.board.findBlock(block); diff --git a/src/playground/block_view.js b/src/playground/block_view.js index 0cc4402e56..34dedd0677 100644 --- a/src/playground/block_view.js +++ b/src/playground/block_view.js @@ -1421,7 +1421,7 @@ Entry.BlockView = class BlockView { const { block, isInBlockMenu, copyable } = blockView; const { options: EntryOptions = {} } = Entry; const { - Blocks: { Duplication_option, CONTEXT_COPY_option, Delete_Blocks }, + Blocks: { Duplication_option, CONTEXT_COPY_option, cut_blocks, Delete_Blocks }, Menus: { save_as_image }, } = Lang; @@ -1441,6 +1441,16 @@ Entry.BlockView = class BlockView { }, }; + const cut = { + text: cut_blocks, + enable: copyable && block.isDeletable() && !isBoardReadOnly, + callback() { + block.copyToClipboard(); + Entry.do('destroyBlockBelow', block); + blockView.getBoard().setSelectedBlock(null); + }, + }; + const remove = { text: Delete_Blocks, enable: block.isDeletable() && !isBoardReadOnly, @@ -1484,7 +1494,7 @@ Entry.BlockView = class BlockView { } if (!isInBlockMenu) { - options = [copyAndPaste, copy, remove, addStorage, ...options, comment].filter( + options = [copyAndPaste, copy, cut, remove, addStorage, ...options, comment].filter( (x) => x ); } diff --git a/src/playground/workspace.js b/src/playground/workspace.js index 5b862bbe97..246727cfb9 100644 --- a/src/playground/workspace.js +++ b/src/playground/workspace.js @@ -514,7 +514,7 @@ Entry.Workspace = class Workspace { !blockView.isInBlockMenu && blockView.block.isDeletable() ) { - (function(block) { + (function (block) { block.copyToClipboard(); Entry.do('destroyBlockBelow', block); blockView.getBoard().setSelectedBlock(null);