@lvce-editor/explorer-view 2.61.0 → 2.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explorerViewWorkerMain.js +101 -42
- package/package.json +1 -1
|
@@ -2021,7 +2021,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
2021
2021
|
scrollBarHeight: 0,
|
|
2022
2022
|
confirmPaste: false,
|
|
2023
2023
|
pasteShouldMove: false,
|
|
2024
|
-
cutItems: []
|
|
2024
|
+
cutItems: [],
|
|
2025
|
+
isPointerDown: false
|
|
2025
2026
|
};
|
|
2026
2027
|
set(uid, state, state);
|
|
2027
2028
|
};
|
|
@@ -2070,7 +2071,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
2070
2071
|
scrollBarHeight: 0,
|
|
2071
2072
|
confirmPaste: false,
|
|
2072
2073
|
pasteShouldMove: false,
|
|
2073
|
-
cutItems: []
|
|
2074
|
+
cutItems: [],
|
|
2075
|
+
isPointerDown: false
|
|
2074
2076
|
};
|
|
2075
2077
|
set(state.uid, state, state);
|
|
2076
2078
|
return state;
|
|
@@ -2081,6 +2083,7 @@ const RenderFocus = 6;
|
|
|
2081
2083
|
const RenderFocusContext = 7;
|
|
2082
2084
|
const RenderValue = 8;
|
|
2083
2085
|
const RenderSelection = 9;
|
|
2086
|
+
const RenderDragData = 10;
|
|
2084
2087
|
|
|
2085
2088
|
const diffType$3 = RenderFocus;
|
|
2086
2089
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -2408,7 +2411,7 @@ const focusPrevious = state => {
|
|
|
2408
2411
|
}
|
|
2409
2412
|
};
|
|
2410
2413
|
|
|
2411
|
-
const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', '
|
|
2414
|
+
const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleCut', 'handleDragLeave', 'handleDragOver', 'handleDragStart', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectIndices', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'toggleIndividualSelection', 'updateEditingValue', 'updateIcons'];
|
|
2412
2415
|
|
|
2413
2416
|
const getCommandIds = () => {
|
|
2414
2417
|
return commandIds;
|
|
@@ -2927,9 +2930,19 @@ const handleArrowRight = async state => {
|
|
|
2927
2930
|
const handleBlur = async state => {
|
|
2928
2931
|
// TODO when blur event occurs because of context menu, focused index should stay the same
|
|
2929
2932
|
// but focus outline should be removed
|
|
2933
|
+
const {
|
|
2934
|
+
items
|
|
2935
|
+
} = state;
|
|
2936
|
+
const newItems = items.map(item => {
|
|
2937
|
+
return {
|
|
2938
|
+
...item,
|
|
2939
|
+
selected: false
|
|
2940
|
+
};
|
|
2941
|
+
});
|
|
2930
2942
|
return {
|
|
2931
2943
|
...state,
|
|
2932
|
-
focused: false
|
|
2944
|
+
focused: false,
|
|
2945
|
+
items: newItems
|
|
2933
2946
|
};
|
|
2934
2947
|
};
|
|
2935
2948
|
|
|
@@ -3260,14 +3273,6 @@ const handleCut = async state => {
|
|
|
3260
3273
|
|
|
3261
3274
|
const handleDragLeave = state => {
|
|
3262
3275
|
return state;
|
|
3263
|
-
// const { dropTargets } = state
|
|
3264
|
-
// if (dropTargets.length === 0) {
|
|
3265
|
-
// return state
|
|
3266
|
-
// }
|
|
3267
|
-
// return {
|
|
3268
|
-
// ...state,
|
|
3269
|
-
// dropTargets: [],
|
|
3270
|
-
// }
|
|
3271
3276
|
};
|
|
3272
3277
|
|
|
3273
3278
|
const canBeDroppedInto = dirent => {
|
|
@@ -3333,6 +3338,10 @@ const handleDragOver = (state, x, y) => {
|
|
|
3333
3338
|
};
|
|
3334
3339
|
};
|
|
3335
3340
|
|
|
3341
|
+
const handleDragStart = state => {
|
|
3342
|
+
return state;
|
|
3343
|
+
};
|
|
3344
|
+
|
|
3336
3345
|
const isExpanded = item => {
|
|
3337
3346
|
return item.type === DirectoryExpanded || item.type === DirectoryExpanding;
|
|
3338
3347
|
};
|
|
@@ -3649,8 +3658,7 @@ const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) =>
|
|
|
3649
3658
|
if (parentIndex === -1) {
|
|
3650
3659
|
return handleDropRoot(state, fileHandles, files, paths);
|
|
3651
3660
|
}
|
|
3652
|
-
|
|
3653
|
-
return handleDropIndex(parentIndex);
|
|
3661
|
+
return handleDropIndex(state, fileHandles, files, paths, parentIndex);
|
|
3654
3662
|
};
|
|
3655
3663
|
const handleDropIndex = async (state, fileHandles, files, paths, index) => {
|
|
3656
3664
|
const {
|
|
@@ -4077,7 +4085,10 @@ const handlePointerDown = (state, button, x, y) => {
|
|
|
4077
4085
|
focus: List
|
|
4078
4086
|
};
|
|
4079
4087
|
}
|
|
4080
|
-
return
|
|
4088
|
+
return {
|
|
4089
|
+
...state,
|
|
4090
|
+
focusedIndex: index
|
|
4091
|
+
};
|
|
4081
4092
|
};
|
|
4082
4093
|
|
|
4083
4094
|
const handleUpload = async (state, dirents) => {
|
|
@@ -4611,6 +4622,38 @@ const renameDirent = state => {
|
|
|
4611
4622
|
};
|
|
4612
4623
|
};
|
|
4613
4624
|
|
|
4625
|
+
const getDragLabel = urls => {
|
|
4626
|
+
if (urls.length === 1) {
|
|
4627
|
+
return urls[0];
|
|
4628
|
+
}
|
|
4629
|
+
return `${urls.length}`;
|
|
4630
|
+
};
|
|
4631
|
+
const getDragData = urls => {
|
|
4632
|
+
const data = urls.join('\n');
|
|
4633
|
+
// TODO send selected urls
|
|
4634
|
+
const dragData = [{
|
|
4635
|
+
type: 'text/plain',
|
|
4636
|
+
data
|
|
4637
|
+
}, {
|
|
4638
|
+
type: 'text/uri-list',
|
|
4639
|
+
data
|
|
4640
|
+
}];
|
|
4641
|
+
// @ts-ignore
|
|
4642
|
+
dragData.label = getDragLabel(urls);
|
|
4643
|
+
return dragData;
|
|
4644
|
+
};
|
|
4645
|
+
|
|
4646
|
+
const renderDragData = (oldState, newState) => {
|
|
4647
|
+
const {
|
|
4648
|
+
items,
|
|
4649
|
+
focusedIndex
|
|
4650
|
+
} = newState;
|
|
4651
|
+
const selected = items.filter((item, index) => item.selected || index === focusedIndex);
|
|
4652
|
+
const urls = selected.map(item => item.path);
|
|
4653
|
+
const dragData = getDragData(urls);
|
|
4654
|
+
return ['Viewlet.setDragData', newState.uid, dragData];
|
|
4655
|
+
};
|
|
4656
|
+
|
|
4614
4657
|
const ExplorerInput = 'ExplorerInput';
|
|
4615
4658
|
|
|
4616
4659
|
const renderEditingSelection = (oldState, newState) => {
|
|
@@ -4734,6 +4777,7 @@ const HandleListBlur = 11;
|
|
|
4734
4777
|
const HandleListFocus = 12;
|
|
4735
4778
|
const HandlePointerDown = 14;
|
|
4736
4779
|
const HandleWheel = 15;
|
|
4780
|
+
const HandleDragStart = 17;
|
|
4737
4781
|
|
|
4738
4782
|
const getExplorerWelcomeVirtualDom = isWide => {
|
|
4739
4783
|
return [{
|
|
@@ -4847,7 +4891,8 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4847
4891
|
path,
|
|
4848
4892
|
setSize,
|
|
4849
4893
|
posInSet,
|
|
4850
|
-
isCut
|
|
4894
|
+
isCut,
|
|
4895
|
+
index
|
|
4851
4896
|
} = item;
|
|
4852
4897
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
4853
4898
|
return [{
|
|
@@ -4864,7 +4909,8 @@ const getExplorerItemVirtualDom = item => {
|
|
|
4864
4909
|
ariaLabel: name,
|
|
4865
4910
|
ariaExpanded,
|
|
4866
4911
|
ariaDescription: '',
|
|
4867
|
-
id
|
|
4912
|
+
id,
|
|
4913
|
+
'data-index': index
|
|
4868
4914
|
}, ...chevronDom, getFileIconVirtualDom(icon), ...getInputOrLabelDom(isEditing, hasEditingError, name, isCut)];
|
|
4869
4915
|
};
|
|
4870
4916
|
|
|
@@ -4999,16 +5045,15 @@ const getExpandedType = type => {
|
|
|
4999
5045
|
}
|
|
5000
5046
|
};
|
|
5001
5047
|
|
|
5002
|
-
const
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
return focused;
|
|
5048
|
+
const getTreeItemClassName = (isSelected, isFocused, isDropping) => {
|
|
5049
|
+
let className = TreeItem;
|
|
5050
|
+
if (isSelected || isFocused) {
|
|
5051
|
+
className = mergeClassNames(className, TreeItemActive);
|
|
5007
5052
|
}
|
|
5008
|
-
if (
|
|
5009
|
-
|
|
5053
|
+
if (isDropping) {
|
|
5054
|
+
className = mergeClassNames(className, 'DropTarget');
|
|
5010
5055
|
}
|
|
5011
|
-
return
|
|
5056
|
+
return className;
|
|
5012
5057
|
};
|
|
5013
5058
|
|
|
5014
5059
|
const defaultIndent$1 = 1;
|
|
@@ -5050,7 +5095,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
5050
5095
|
const id = isFocused ? 'TreeItemActive' : undefined;
|
|
5051
5096
|
const isSelected = item.selected;
|
|
5052
5097
|
const isCut = cutItems.includes(item.path);
|
|
5053
|
-
const
|
|
5098
|
+
const isDropping = dropTargets.includes(i);
|
|
5099
|
+
const className = getTreeItemClassName(isSelected, isFocused, isDropping); // TODO compute classname in dom function
|
|
5054
5100
|
const expanded = getExpandedType(item.type);
|
|
5055
5101
|
const ariaExpanded = ariaExpandedValues[expanded];
|
|
5056
5102
|
const isEditing = i === editingIndex;
|
|
@@ -5072,7 +5118,8 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
5072
5118
|
chevron,
|
|
5073
5119
|
id,
|
|
5074
5120
|
className,
|
|
5075
|
-
isCut
|
|
5121
|
+
isCut,
|
|
5122
|
+
index: i
|
|
5076
5123
|
});
|
|
5077
5124
|
}
|
|
5078
5125
|
return visible;
|
|
@@ -5080,25 +5127,25 @@ const getVisibleExplorerItems = (items, minLineY, maxLineY, focusedIndex, editin
|
|
|
5080
5127
|
|
|
5081
5128
|
const renderItems = (oldState, newState) => {
|
|
5082
5129
|
const {
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5130
|
+
cutItems,
|
|
5131
|
+
deltaY,
|
|
5132
|
+
dropTargets,
|
|
5133
|
+
editingErrorMessage,
|
|
5134
|
+
editingIcon,
|
|
5087
5135
|
editingIndex,
|
|
5088
5136
|
editingType,
|
|
5089
5137
|
editingValue,
|
|
5090
|
-
|
|
5138
|
+
focused,
|
|
5139
|
+
focusedIndex,
|
|
5140
|
+
height,
|
|
5091
5141
|
icons,
|
|
5092
|
-
useChevrons,
|
|
5093
|
-
dropTargets,
|
|
5094
|
-
editingIcon,
|
|
5095
5142
|
itemHeight,
|
|
5096
|
-
|
|
5143
|
+
items,
|
|
5144
|
+
maxLineY,
|
|
5145
|
+
minLineY,
|
|
5097
5146
|
root,
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
height,
|
|
5101
|
-
cutItems
|
|
5147
|
+
useChevrons,
|
|
5148
|
+
width
|
|
5102
5149
|
} = newState;
|
|
5103
5150
|
const visibleDirents = getVisibleExplorerItems(items, minLineY, maxLineY, focusedIndex, editingIndex, editingType, editingValue, editingErrorMessage, icons, useChevrons, dropTargets, editingIcon, cutItems);
|
|
5104
5151
|
const isWide = width > 450;
|
|
@@ -5139,6 +5186,8 @@ const getRenderer = diffType => {
|
|
|
5139
5186
|
return renderValue;
|
|
5140
5187
|
case RenderSelection:
|
|
5141
5188
|
return renderEditingSelection;
|
|
5189
|
+
case RenderDragData:
|
|
5190
|
+
return renderDragData;
|
|
5142
5191
|
default:
|
|
5143
5192
|
throw new Error('unknown renderer');
|
|
5144
5193
|
}
|
|
@@ -5286,8 +5335,8 @@ const renderEventListeners = () => {
|
|
|
5286
5335
|
preventDefault: true
|
|
5287
5336
|
}, {
|
|
5288
5337
|
name: HandlePointerDown,
|
|
5289
|
-
params: ['handlePointerDown', 'event.button', 'event.clientX', 'event.clientY']
|
|
5290
|
-
preventDefault: true
|
|
5338
|
+
params: ['handlePointerDown', 'event.button', 'event.clientX', 'event.clientY']
|
|
5339
|
+
// preventDefault: true,
|
|
5291
5340
|
}, {
|
|
5292
5341
|
name: HandleEditingInput,
|
|
5293
5342
|
params: ['updateEditingValue', 'event.target.value']
|
|
@@ -5310,6 +5359,15 @@ const renderEventListeners = () => {
|
|
|
5310
5359
|
}, {
|
|
5311
5360
|
name: HandleDragLeave,
|
|
5312
5361
|
params: ['handleDragLeave']
|
|
5362
|
+
}, {
|
|
5363
|
+
name: HandleDragStart,
|
|
5364
|
+
params: ['handleDragStart'],
|
|
5365
|
+
// @ts-ignore
|
|
5366
|
+
dragInfo: [{
|
|
5367
|
+
type: 'text/plain',
|
|
5368
|
+
data: 'https://example.com'
|
|
5369
|
+
}],
|
|
5370
|
+
dragEffect: 'copyMove'
|
|
5313
5371
|
}];
|
|
5314
5372
|
};
|
|
5315
5373
|
|
|
@@ -5606,6 +5664,7 @@ const commandMap = {
|
|
|
5606
5664
|
'Explorer.focusFirst': wrapCommand(focusFirst),
|
|
5607
5665
|
'Explorer.focusIndex': wrapCommand(focusIndex),
|
|
5608
5666
|
'Explorer.focusLast': wrapCommand(focusLast),
|
|
5667
|
+
'Explorer.handleDragStart': wrapCommand(handleDragStart),
|
|
5609
5668
|
'Explorer.focusNext': wrapCommand(focusNext),
|
|
5610
5669
|
'Explorer.focusNone': wrapCommand(focusNone),
|
|
5611
5670
|
'Explorer.focusPrevious': wrapCommand(focusPrevious),
|