Skip to content

Commit 8ba1ed8

Browse files
author
kim jeong yong
committed
[fix] function_field_label에서 %N 예약어 오입력 방지 처리
- FieldTextInput.applyValue에서 block 타입이 function_field_label일 경우 %N 패턴의 % 기호를 제거하여 플레이스홀더로 오인식되는 문제 수정 - destroyOption 시에도 동일한 정제 로직 적용 - block_view.js 코드 스타일 소폭 정리 (function 공백, 들여쓰기)
1 parent a1cfbbc commit 8ba1ed8

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/playground/block_view.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Entry.BlockView = class BlockView {
8888
}
8989

9090
this.isInBlockMenu = this.getBoard() instanceof Entry.BlockMenu;
91-
this.mouseHandler = function (e) {
91+
this.mouseHandler = function(e) {
9292
(_.result(that.block.events, 'mousedown') || []).forEach((fn) => {
9393
if (Entry.documentMousedown) {
9494
Entry.documentMousedown.notify(e);
@@ -608,7 +608,7 @@ Entry.BlockView = class BlockView {
608608
const mouseDownCoordinate = this.mouseDownCoordinate;
609609
const diff = Math.sqrt(
610610
Math.pow(mouseEvent.pageX - mouseDownCoordinate.x, 2) +
611-
Math.pow(mouseEvent.pageY - mouseDownCoordinate.y, 2)
611+
Math.pow(mouseEvent.pageY - mouseDownCoordinate.y, 2)
612612
);
613613
if (this.dragMode == Entry.DRAG_MODE_DRAG || diff > Entry.BlockView.DRAG_RADIUS) {
614614
const blockView = this;
@@ -1019,9 +1019,8 @@ Entry.BlockView = class BlockView {
10191019
magnet = this.magnet.previous;
10201020
const dragHeight = dragBlock.getBelowHeight();
10211021
const nextX = _get(dragBlock, 'magnet.next.x');
1022-
transform = `translate(${pos.scaleX + magnet.x - nextX},${
1023-
pos.scaleY + magnet.y - dragHeight
1024-
})`;
1022+
transform = `translate(${pos.scaleX + magnet.x - nextX},${pos.scaleY + magnet.y - dragHeight
1023+
})`;
10251024
}
10261025

10271026
const $shadow = $(shadow);
@@ -1642,7 +1641,7 @@ Entry.BlockView = class BlockView {
16421641
halfWidth = 20;
16431642
}
16441643
return {
1645-
getBoundingClientRect: function () {
1644+
getBoundingClientRect: function() {
16461645
const coord = this.getAbsoluteCoordinate();
16471646
const boardOffset = this._board.relativeOffset;
16481647
const magnet = this.magnet[selector];
@@ -1767,7 +1766,7 @@ Entry.BlockView = class BlockView {
17671766
canvas.height = height;
17681767
const ctx = canvas.getContext('2d');
17691768

1770-
img.onload = function () {
1769+
img.onload = function() {
17711770
try {
17721771
ctx.drawImage(img, 0, 0, width, height);
17731772
const data = canvas.toDataURL('image/png');
@@ -1780,7 +1779,7 @@ Entry.BlockView = class BlockView {
17801779
}
17811780
};
17821781

1783-
img.onerror = function () {
1782+
img.onerror = function() {
17841783
return reject('error occured');
17851784
};
17861785
img.src = src;

src/playground/field/textInput.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ Entry.FieldTextInput = class FieldTextInput extends Entry.Field {
270270

271271
applyValue(value, isNotUpdate) {
272272
let result = value;
273+
273274
if (this.optionWidget) {
274275
switch (this.optionWidget.type) {
275276
case 'angleWidget':
@@ -289,6 +290,12 @@ Entry.FieldTextInput = class FieldTextInput extends Entry.Field {
289290
this.optionInput.val(result);
290291
}
291292

293+
if (this._block?.data?.type === 'function_field_label') {
294+
const reg = /(%\d)/im;
295+
if (result && reg.test(result)) {
296+
result = result.replace(/%(\d)/gi, '$1');
297+
}
298+
}
292299
this.setValue(result);
293300
this._setTextValue();
294301
this.resize();
@@ -318,6 +325,11 @@ Entry.FieldTextInput = class FieldTextInput extends Entry.Field {
318325
delete this.optionInput;
319326
}
320327

328+
const reg = /(%\d)/im;
329+
if (this.value && reg.test(this.value)) {
330+
this.applyValue(this.value.replace(/%(\d)/gi, '$1'));
331+
}
332+
321333
super.destroyOption(skipCommand, forceCommand);
322334
}
323335

0 commit comments

Comments
 (0)