Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"jquery": true,
},
"parserOptions": {
"requireConfigFile": false,
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"trailingComma": "es5",
"bracketSpacing": true,
"semi": true,
"arrowParens": "always"
"arrowParens": "always",
"endOfLine": "auto"
}
5 changes: 5 additions & 0 deletions extern/lang/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -5635,6 +5635,11 @@ Lang.Workspace = {
variable_name_auto_edited_content: 'variable name cannot exceed 10 characters',
list_name_auto_edited_title: 'list name auto-edited',
list_name_auto_edited_content: 'list name cannot exceed 10 characters',
list_cant_add_item: 'Warning',
list_max_length_exceeded: 'You can add up to 5,000 items to a list.',
list_truncated_on_load:
'The number of list items in this project exceeds 5,000, so some may not be displayed.\n\nFor stable use,\nplease reduce the list to 5,000 or fewer.',
list_truncated_on_load_title: 'Notice',
cloned_scene: 'Cloned_',
default_mode: 'Standard',
practical_course_mode: 'Textbook',
Expand Down
5 changes: 5 additions & 0 deletions extern/lang/ko.js
Original file line number Diff line number Diff line change
Expand Up @@ -6014,6 +6014,11 @@ Lang.Workspace = {
variable_name_auto_edited_content: '변수의 이름은 10글자를 넘을 수 없습니다.',
list_name_auto_edited_title: '리스트 이름 자동 변경',
list_name_auto_edited_content: '리스트의 이름은 10글자를 넘을 수 없습니다.',
list_cant_add_item: '경고',
list_max_length_exceeded: '리스트 항목은 최대 5,000개까지 추가할 수 있어요.',
list_truncated_on_load:
'이 작품의 리스트 항목 수가 5,000개를 초과하여 일부가 표시되지 않을 수 있습니다.\n\n안정적인 이용을 위해\n리스트를 5,000개 이하로 줄여주세요.',
list_truncated_on_load_title: '알림',
cloned_scene: '복제본_',
default_mode: '기본형',
practical_course_mode: '교과형',
Expand Down
49 changes: 39 additions & 10 deletions src/class/variable/listVariable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,37 @@ class ListVariable extends Variable {
return 5000;
}

_trimToMaxLength() {
if (this.array_ && this.array_.length > this.LIST_MAX_LENGTH) {
this.array_ = this.array_.slice(-this.LIST_MAX_LENGTH);
this._showListFullWarning();
}
}

_showListFullWarning() {
Entry.toast?.alert(
Lang?.Workspace?.list_cant_add_item || 'Warning',
Lang?.Workspace?.list_max_length_exceeded ||
`You can add up to ${this.LIST_MAX_LENGTH} items to a list.`
);
}

constructor(variable) {
Entry.assert(variable.variableType === 'list', 'Invalid variable type given');
super(variable);
this.array_ = variable.array ? variable.array : [];

let array = variable.array ? variable.array : [];
if (array.length > this.LIST_MAX_LENGTH) {
array = array.slice(-this.LIST_MAX_LENGTH);
setTimeout(() => {
Entry.modal?.alert(
Lang?.Workspace?.list_truncated_on_load ||
`The list exceeded ${this.LIST_MAX_LENGTH} items.`,
Lang?.Workspace?.list_truncated_on_load_title || 'Notice'
);
}, 100);
}
this.array_ = array;

if (!variable.isClone) {
this.width_ = variable.width ? variable.width : 100;
Expand Down Expand Up @@ -62,11 +89,11 @@ class ListVariable extends Variable {
this.resizeHandle_.list = this;

GEDragHelper.handleDrag(this.resizeHandle_);
this.resizeHandle_.on(GEDragHelper.types.OVER, function() {
this.resizeHandle_.on(GEDragHelper.types.OVER, function () {
this.cursor = 'nwse-resize';
});

this.resizeHandle_.on(GEDragHelper.types.DOWN, function(evt) {
this.resizeHandle_.on(GEDragHelper.types.DOWN, function (evt) {
// if(Entry.type != 'workspace') return;
this.list.isResizing = true;
this.offset = {
Expand All @@ -75,18 +102,18 @@ class ListVariable extends Variable {
};
this.parent.cursor = 'nwse-resize';
});
this.resizeHandle_.on(GEDragHelper.types.MOVE, function(evt) {
this.resizeHandle_.on(GEDragHelper.types.MOVE, function (evt) {
// if(Entry.type != 'workspace') return;
this.list.setWidth(evt.stageX * 0.75 - this.offset.x);
this.list.setHeight(evt.stageY * 0.75 - this.offset.y);
this.list.updateView();
});

this.view_.on(GEDragHelper.types.OVER, function() {
this.view_.on(GEDragHelper.types.OVER, function () {
this.cursor = 'move';
});

this.view_.on(GEDragHelper.types.DOWN, function(evt) {
this.view_.on(GEDragHelper.types.DOWN, function (evt) {
if (Entry.type !== 'workspace' || this.variable.isResizing) {
return;
}
Expand All @@ -97,12 +124,12 @@ class ListVariable extends Variable {
this.cursor = 'move';
});

this.view_.on(GEDragHelper.types.UP, function() {
this.view_.on(GEDragHelper.types.UP, function () {
this.cursor = 'initial';
this.variable.isResizing = false;
});

this.view_.on(GEDragHelper.types.MOVE, function(evt) {
this.view_.on(GEDragHelper.types.MOVE, function (evt) {
if (Entry.type !== 'workspace' || this.variable.isResizing) {
return;
}
Expand All @@ -122,12 +149,12 @@ class ListVariable extends Variable {
this.scrollButton_.y = 25;

this.scrollButton_.list = this;
this.scrollButton_.on(GEDragHelper.types.DOWN, function(evt) {
this.scrollButton_.on(GEDragHelper.types.DOWN, function (evt) {
// if(Entry.type != 'workspace') return;
this.list.isResizing = true;
this.offsetY = evt.stageY - this.y / 0.75;
});
this.scrollButton_.on(GEDragHelper.types.MOVE, function(evt) {
this.scrollButton_.on(GEDragHelper.types.MOVE, function (evt) {
// if(Entry.type != 'workspace') return;

const stageY = evt.stageY;
Expand Down Expand Up @@ -200,6 +227,7 @@ class ListVariable extends Variable {
this.array_.push({
data: value,
});
this._trimToMaxLength();
this.updateView();
} else {
return new Promise(async (resolve, reject) => {
Expand Down Expand Up @@ -256,6 +284,7 @@ class ListVariable extends Variable {
insertValue(index, data) {
if (!this.isRealTime_) {
this.array_.splice(index - 1, 0, { data });
this._trimToMaxLength();
this.updateView();
} else {
return new Promise(async (resolve, reject) => {
Expand Down
10 changes: 10 additions & 0 deletions src/class/variable_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -3053,6 +3053,11 @@ Entry.VariableContainer = class VariableContainer {

if (value >= limitValue) {
value = limitValue;
Entry.toast?.alert(
Lang?.Workspace?.list_cant_add_item || 'Warning',
Lang?.Workspace?.list_max_length_exceeded ||
'You can add up to 5,000 items to a list.'
);
}

Entry.do('listChangeLength', v.id_, Number(value));
Expand All @@ -3079,6 +3084,11 @@ Entry.VariableContainer = class VariableContainer {
const selectedLength = array_.length;

if (selectedLength >= limitValue) {
Entry.toast?.alert(
Lang?.Workspace?.list_cant_add_item || 'Warning',
Lang?.Workspace?.list_max_length_exceeded ||
'You can add up to 5,000 items to a list.'
);
Entry.do('listChangeLength', id_, '');
} else {
Entry.do('listChangeLength', id_, 'plus');
Expand Down
Loading