@lvce-editor/editor-worker 3.9.0 → 3.11.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/editorWorkerMain.js +126 -28
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -121,7 +121,7 @@ const IconButtonDisabled = 'IconButtonDisabled';
|
|
|
121
121
|
const IconButton = 'IconButton';
|
|
122
122
|
const CompletionDetailContent = 'CompletionDetailContent';
|
|
123
123
|
const Diagnostic = 'Diagnostic';
|
|
124
|
-
const FindWidgetReplace = 'FindWidgetReplace';
|
|
124
|
+
const FindWidgetReplace$1 = 'FindWidgetReplace';
|
|
125
125
|
const FindWidgetFind = 'FindWidgetFind';
|
|
126
126
|
const FindWidgetMatchCount = 'FindWidgetMatchCount';
|
|
127
127
|
const FindWidgetRight = 'FindWidgetRight';
|
|
@@ -2503,6 +2503,9 @@ const ColorPicker = 41;
|
|
|
2503
2503
|
const FindWidget = 16;
|
|
2504
2504
|
const EditorCompletion = 9;
|
|
2505
2505
|
const CompletionDetail = 999;
|
|
2506
|
+
const Empty = 0;
|
|
2507
|
+
const FindWidgetToggleReplace = 42;
|
|
2508
|
+
const FindWidgetReplace = 43;
|
|
2506
2509
|
|
|
2507
2510
|
const newStateGenerator = state => {
|
|
2508
2511
|
return loadContent$3(state);
|
|
@@ -5068,6 +5071,10 @@ const openCompletion = async editor => {
|
|
|
5068
5071
|
};
|
|
5069
5072
|
};
|
|
5070
5073
|
|
|
5074
|
+
const User = 1;
|
|
5075
|
+
const Script = 2;
|
|
5076
|
+
const Unknown$1 = 0;
|
|
5077
|
+
|
|
5071
5078
|
const create$1 = () => {
|
|
5072
5079
|
const uid = create$4();
|
|
5073
5080
|
const widget = {
|
|
@@ -5089,7 +5096,8 @@ const create$1 = () => {
|
|
|
5089
5096
|
y: 0,
|
|
5090
5097
|
width: 0,
|
|
5091
5098
|
height: 0,
|
|
5092
|
-
focused: false
|
|
5099
|
+
focused: false,
|
|
5100
|
+
focusSource: Unknown$1
|
|
5093
5101
|
},
|
|
5094
5102
|
newState: {
|
|
5095
5103
|
value: '',
|
|
@@ -5108,7 +5116,8 @@ const create$1 = () => {
|
|
|
5108
5116
|
y: 0,
|
|
5109
5117
|
width: 0,
|
|
5110
5118
|
height: 0,
|
|
5111
|
-
focused: true
|
|
5119
|
+
focused: true,
|
|
5120
|
+
focusSource: Unknown$1
|
|
5112
5121
|
}
|
|
5113
5122
|
};
|
|
5114
5123
|
return widget;
|
|
@@ -5158,6 +5167,10 @@ const getMatchCount = matches => {
|
|
|
5158
5167
|
return matches.length / 2;
|
|
5159
5168
|
};
|
|
5160
5169
|
|
|
5170
|
+
const setFocus = async focusKey => {
|
|
5171
|
+
await invoke$3('Focus.setFocus', focusKey);
|
|
5172
|
+
};
|
|
5173
|
+
|
|
5161
5174
|
const getPosition = editor => {
|
|
5162
5175
|
const width = 300;
|
|
5163
5176
|
const height = 30;
|
|
@@ -5189,7 +5202,8 @@ const loadContent$1 = editorId => {
|
|
|
5189
5202
|
value,
|
|
5190
5203
|
matches,
|
|
5191
5204
|
matchIndex: 0,
|
|
5192
|
-
matchCount
|
|
5205
|
+
matchCount,
|
|
5206
|
+
editorUid: editor.uid
|
|
5193
5207
|
};
|
|
5194
5208
|
};
|
|
5195
5209
|
const refresh = (state, value = state.value) => {
|
|
@@ -5216,20 +5230,28 @@ const handleInput = (state, value) => {
|
|
|
5216
5230
|
return refresh(state, value);
|
|
5217
5231
|
};
|
|
5218
5232
|
const handleFocus = async state => {
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
|
|
5233
|
+
if (state.focus === 'find') {
|
|
5234
|
+
return state;
|
|
5235
|
+
}
|
|
5236
|
+
await setFocus(FindWidget);
|
|
5237
|
+
return {
|
|
5238
|
+
...state,
|
|
5239
|
+
focus: 'find'
|
|
5240
|
+
};
|
|
5222
5241
|
};
|
|
5223
5242
|
const handleBlur = async state => {
|
|
5224
|
-
|
|
5225
|
-
await invoke$3('Focus.setFocus', Empty);
|
|
5243
|
+
await setFocus(Empty);
|
|
5226
5244
|
return state;
|
|
5227
5245
|
};
|
|
5228
|
-
const
|
|
5229
|
-
const newExpanded = !state.replaceExpanded;
|
|
5246
|
+
const getHeight = replaceExpanded => {
|
|
5230
5247
|
const collapsedHeight = 30;
|
|
5231
5248
|
const expandedHeight = 60;
|
|
5232
|
-
const newHeight =
|
|
5249
|
+
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
5250
|
+
return newHeight;
|
|
5251
|
+
};
|
|
5252
|
+
const toggleReplace = state => {
|
|
5253
|
+
const newExpanded = !state.replaceExpanded;
|
|
5254
|
+
const newHeight = getHeight(newExpanded);
|
|
5233
5255
|
return {
|
|
5234
5256
|
...state,
|
|
5235
5257
|
replaceExpanded: !state.replaceExpanded,
|
|
@@ -5297,6 +5319,45 @@ const close$1 = async state => {
|
|
|
5297
5319
|
disposed: true
|
|
5298
5320
|
};
|
|
5299
5321
|
};
|
|
5322
|
+
const handleReplaceFocus = async state => {
|
|
5323
|
+
if (state.focus === 'replaceInput') {
|
|
5324
|
+
return state;
|
|
5325
|
+
}
|
|
5326
|
+
await setFocus(FindWidgetReplace);
|
|
5327
|
+
return {
|
|
5328
|
+
...state,
|
|
5329
|
+
focus: 'replaceInput',
|
|
5330
|
+
focusSource: User
|
|
5331
|
+
};
|
|
5332
|
+
};
|
|
5333
|
+
const focusReplace = state => {
|
|
5334
|
+
// TODO
|
|
5335
|
+
return {
|
|
5336
|
+
...state,
|
|
5337
|
+
focus: 'replace',
|
|
5338
|
+
focusSource: Script
|
|
5339
|
+
};
|
|
5340
|
+
};
|
|
5341
|
+
const focusFind = state => {
|
|
5342
|
+
// TODO
|
|
5343
|
+
return {
|
|
5344
|
+
...state,
|
|
5345
|
+
focus: 'find',
|
|
5346
|
+
focusSource: Script
|
|
5347
|
+
};
|
|
5348
|
+
};
|
|
5349
|
+
const handleReplaceInput = state => {
|
|
5350
|
+
// TODO
|
|
5351
|
+
return state;
|
|
5352
|
+
};
|
|
5353
|
+
const focusToggleReplace = async state => {
|
|
5354
|
+
await setFocus(FindWidgetToggleReplace);
|
|
5355
|
+
return {
|
|
5356
|
+
...state,
|
|
5357
|
+
focus: 'toggleReplace',
|
|
5358
|
+
focusSource: Script
|
|
5359
|
+
};
|
|
5360
|
+
};
|
|
5300
5361
|
|
|
5301
5362
|
const openFind2 = async editor => {
|
|
5302
5363
|
const newStateGenerator = async state => {
|
|
@@ -5321,7 +5382,10 @@ const openFind2 = async editor => {
|
|
|
5321
5382
|
x,
|
|
5322
5383
|
y,
|
|
5323
5384
|
width,
|
|
5324
|
-
height
|
|
5385
|
+
height,
|
|
5386
|
+
editorUid: editor.uid || editor.id,
|
|
5387
|
+
focusSource: Script,
|
|
5388
|
+
focus: 'find'
|
|
5325
5389
|
};
|
|
5326
5390
|
return latestState;
|
|
5327
5391
|
};
|
|
@@ -8623,7 +8687,13 @@ const widgetCommands = {
|
|
|
8623
8687
|
'FindWidget.toggleReplace': Find,
|
|
8624
8688
|
'FindWidget.handleFocus': Find,
|
|
8625
8689
|
'FindWidget.handleBlur': Find,
|
|
8626
|
-
'FindWidget.handleToggleReplaceFocus': Find
|
|
8690
|
+
'FindWidget.handleToggleReplaceFocus': Find,
|
|
8691
|
+
'FindWidget.handleInput': Find,
|
|
8692
|
+
'FindWidget.handleReplaceInput': Find,
|
|
8693
|
+
'FindWidget.handleReplaceFocus': Find,
|
|
8694
|
+
'FindWidget.focusFind': Find,
|
|
8695
|
+
'FindWidget.focusToggleReplace': Find,
|
|
8696
|
+
'FindWidget.focusReplace': Find
|
|
8627
8697
|
};
|
|
8628
8698
|
|
|
8629
8699
|
// TODO wrap commands globally, not per editor
|
|
@@ -8792,17 +8862,22 @@ const commandMap = {
|
|
|
8792
8862
|
'EditorCompletion.selectCurrent': selectCurrent,
|
|
8793
8863
|
'EditorCompletion.selectIndex': selectIndex,
|
|
8794
8864
|
'EditorCompletion.toggleDetails': toggleDetails,
|
|
8865
|
+
'FindWidget.close': close$1,
|
|
8795
8866
|
'FindWidget.focusFirst': focusFirst$1,
|
|
8796
8867
|
'FindWidget.focusIndex': focusIndex$1,
|
|
8797
8868
|
'FindWidget.focusLast': focusLast,
|
|
8798
8869
|
'FindWidget.focusNext': focusNext$1,
|
|
8799
8870
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
8800
|
-
'FindWidget.handleInput': handleInput,
|
|
8801
|
-
'FindWidget.handleFocus': handleFocus,
|
|
8802
8871
|
'FindWidget.handleBlur': handleBlur,
|
|
8803
|
-
'FindWidget.
|
|
8804
|
-
'FindWidget.
|
|
8872
|
+
'FindWidget.handleFocus': handleFocus,
|
|
8873
|
+
'FindWidget.handleInput': handleInput,
|
|
8874
|
+
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
8805
8875
|
'FindWidget.loadContent': loadContent$1,
|
|
8876
|
+
'FindWidget.toggleReplace': toggleReplace,
|
|
8877
|
+
'FindWidget.focusReplace': focusReplace,
|
|
8878
|
+
'FindWidget.focusFind': focusFind,
|
|
8879
|
+
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
8880
|
+
'FindWidget.focusToggleReplace': focusToggleReplace,
|
|
8806
8881
|
'Font.ensure': ensure,
|
|
8807
8882
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
8808
8883
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
@@ -9901,7 +9976,8 @@ const getIconButtonVirtualDom = iconButton => {
|
|
|
9901
9976
|
title: label,
|
|
9902
9977
|
ariaLabel: label,
|
|
9903
9978
|
childCount: 1,
|
|
9904
|
-
disabled: disabled ? true : undefined
|
|
9979
|
+
disabled: disabled ? true : undefined,
|
|
9980
|
+
onClick: iconButton.onClick
|
|
9905
9981
|
}, getIconVirtualDom(icon)];
|
|
9906
9982
|
};
|
|
9907
9983
|
|
|
@@ -9975,7 +10051,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
|
|
|
9975
10051
|
if (replaceExpanded) {
|
|
9976
10052
|
dom.push({
|
|
9977
10053
|
type: Div,
|
|
9978
|
-
className: FindWidgetReplace,
|
|
10054
|
+
className: FindWidgetReplace$1,
|
|
9979
10055
|
childCount: 1 + replaceButtons.length
|
|
9980
10056
|
}, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
|
|
9981
10057
|
}
|
|
@@ -9989,6 +10065,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
|
9989
10065
|
title: 'Toggle Replace',
|
|
9990
10066
|
ariaLabel: 'Toggle Replace',
|
|
9991
10067
|
ariaExpanded: replaceExpanded,
|
|
10068
|
+
name: 'ToggleReplace',
|
|
9992
10069
|
childCount: 1,
|
|
9993
10070
|
'data-command': 'toggleReplace',
|
|
9994
10071
|
onClick
|
|
@@ -10007,7 +10084,7 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, r
|
|
|
10007
10084
|
childCount: 2,
|
|
10008
10085
|
role: Group
|
|
10009
10086
|
});
|
|
10010
|
-
dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, '
|
|
10087
|
+
dom.push(...getSearchToggleButtonVirtualDom(replaceExpanded, 'handleClickToggleReplace'));
|
|
10011
10088
|
dom.push({
|
|
10012
10089
|
type: Div,
|
|
10013
10090
|
className: FindWidgetRight,
|
|
@@ -10051,24 +10128,29 @@ const renderDetails = {
|
|
|
10051
10128
|
const findButtons = [{
|
|
10052
10129
|
label: previousMatch(),
|
|
10053
10130
|
icon: ArrowUp,
|
|
10054
|
-
disabled: !buttonsEnabled
|
|
10131
|
+
disabled: !buttonsEnabled,
|
|
10132
|
+
onClick: 'handleClickPreviousMatch'
|
|
10055
10133
|
}, {
|
|
10056
10134
|
label: nextMatch(),
|
|
10057
10135
|
icon: ArrowDown,
|
|
10058
|
-
disabled: !buttonsEnabled
|
|
10136
|
+
disabled: !buttonsEnabled,
|
|
10137
|
+
onClick: 'handleClickNextMatch'
|
|
10059
10138
|
}, {
|
|
10060
10139
|
label: close(),
|
|
10061
10140
|
icon: Close,
|
|
10062
|
-
disabled: false
|
|
10141
|
+
disabled: false,
|
|
10142
|
+
onClick: 'handleClickClose'
|
|
10063
10143
|
}];
|
|
10064
10144
|
const replaceButtons = [{
|
|
10065
10145
|
label: replace(),
|
|
10066
10146
|
icon: Replace,
|
|
10067
|
-
disabled: !buttonsEnabled
|
|
10147
|
+
disabled: !buttonsEnabled,
|
|
10148
|
+
onClick: 'handleClickReplace'
|
|
10068
10149
|
}, {
|
|
10069
10150
|
label: replaceAll(),
|
|
10070
10151
|
icon: ReplaceAll,
|
|
10071
|
-
disabled: !buttonsEnabled
|
|
10152
|
+
disabled: !buttonsEnabled,
|
|
10153
|
+
onClick: 'handleClickReplaceAll'
|
|
10072
10154
|
}];
|
|
10073
10155
|
const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons);
|
|
10074
10156
|
return ['Viewlet.setDom2', dom];
|
|
@@ -10088,12 +10170,28 @@ const renderBounds = {
|
|
|
10088
10170
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10089
10171
|
}
|
|
10090
10172
|
};
|
|
10173
|
+
|
|
10174
|
+
// TODO always focus element by name
|
|
10175
|
+
// TODO use numeric key
|
|
10176
|
+
const getKey = focus => {
|
|
10177
|
+
switch (focus) {
|
|
10178
|
+
case 'find':
|
|
10179
|
+
return `[name="search-value"]`;
|
|
10180
|
+
case 'replace':
|
|
10181
|
+
return '[name="replace-value"]';
|
|
10182
|
+
case 'toggleReplace':
|
|
10183
|
+
return `[name="toggleReplace"]`;
|
|
10184
|
+
default:
|
|
10185
|
+
return '';
|
|
10186
|
+
}
|
|
10187
|
+
};
|
|
10091
10188
|
const renderFocus = {
|
|
10092
10189
|
isEqual(oldState, newState) {
|
|
10093
|
-
return oldState.focused === newState.focused;
|
|
10190
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus && oldState.focusSource === newState.focusSource;
|
|
10094
10191
|
},
|
|
10095
10192
|
apply(oldState, newState) {
|
|
10096
|
-
|
|
10193
|
+
const key = getKey(newState.focus || '');
|
|
10194
|
+
return ['focus', key, newState.focusSource];
|
|
10097
10195
|
}
|
|
10098
10196
|
};
|
|
10099
10197
|
// const getAriaLabel = (state: FindWidgetState) => {
|