@lvce-editor/editor-worker 3.10.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 +107 -20
- 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;
|
|
@@ -5217,20 +5230,28 @@ const handleInput = (state, value) => {
|
|
|
5217
5230
|
return refresh(state, value);
|
|
5218
5231
|
};
|
|
5219
5232
|
const handleFocus = async state => {
|
|
5220
|
-
|
|
5221
|
-
|
|
5222
|
-
|
|
5233
|
+
if (state.focus === 'find') {
|
|
5234
|
+
return state;
|
|
5235
|
+
}
|
|
5236
|
+
await setFocus(FindWidget);
|
|
5237
|
+
return {
|
|
5238
|
+
...state,
|
|
5239
|
+
focus: 'find'
|
|
5240
|
+
};
|
|
5223
5241
|
};
|
|
5224
5242
|
const handleBlur = async state => {
|
|
5225
|
-
|
|
5226
|
-
await invoke$3('Focus.setFocus', Empty);
|
|
5243
|
+
await setFocus(Empty);
|
|
5227
5244
|
return state;
|
|
5228
5245
|
};
|
|
5229
|
-
const
|
|
5230
|
-
const newExpanded = !state.replaceExpanded;
|
|
5246
|
+
const getHeight = replaceExpanded => {
|
|
5231
5247
|
const collapsedHeight = 30;
|
|
5232
5248
|
const expandedHeight = 60;
|
|
5233
|
-
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);
|
|
5234
5255
|
return {
|
|
5235
5256
|
...state,
|
|
5236
5257
|
replaceExpanded: !state.replaceExpanded,
|
|
@@ -5298,6 +5319,45 @@ const close$1 = async state => {
|
|
|
5298
5319
|
disposed: true
|
|
5299
5320
|
};
|
|
5300
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
|
+
};
|
|
5301
5361
|
|
|
5302
5362
|
const openFind2 = async editor => {
|
|
5303
5363
|
const newStateGenerator = async state => {
|
|
@@ -5323,7 +5383,9 @@ const openFind2 = async editor => {
|
|
|
5323
5383
|
y,
|
|
5324
5384
|
width,
|
|
5325
5385
|
height,
|
|
5326
|
-
editorUid: editor.uid || editor.id
|
|
5386
|
+
editorUid: editor.uid || editor.id,
|
|
5387
|
+
focusSource: Script,
|
|
5388
|
+
focus: 'find'
|
|
5327
5389
|
};
|
|
5328
5390
|
return latestState;
|
|
5329
5391
|
};
|
|
@@ -8628,7 +8690,10 @@ const widgetCommands = {
|
|
|
8628
8690
|
'FindWidget.handleToggleReplaceFocus': Find,
|
|
8629
8691
|
'FindWidget.handleInput': Find,
|
|
8630
8692
|
'FindWidget.handleReplaceInput': Find,
|
|
8631
|
-
'FindWidget.handleReplaceFocus': Find
|
|
8693
|
+
'FindWidget.handleReplaceFocus': Find,
|
|
8694
|
+
'FindWidget.focusFind': Find,
|
|
8695
|
+
'FindWidget.focusToggleReplace': Find,
|
|
8696
|
+
'FindWidget.focusReplace': Find
|
|
8632
8697
|
};
|
|
8633
8698
|
|
|
8634
8699
|
// TODO wrap commands globally, not per editor
|
|
@@ -8797,17 +8862,22 @@ const commandMap = {
|
|
|
8797
8862
|
'EditorCompletion.selectCurrent': selectCurrent,
|
|
8798
8863
|
'EditorCompletion.selectIndex': selectIndex,
|
|
8799
8864
|
'EditorCompletion.toggleDetails': toggleDetails,
|
|
8865
|
+
'FindWidget.close': close$1,
|
|
8800
8866
|
'FindWidget.focusFirst': focusFirst$1,
|
|
8801
8867
|
'FindWidget.focusIndex': focusIndex$1,
|
|
8802
8868
|
'FindWidget.focusLast': focusLast,
|
|
8803
8869
|
'FindWidget.focusNext': focusNext$1,
|
|
8804
8870
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
8805
|
-
'FindWidget.handleInput': handleInput,
|
|
8806
|
-
'FindWidget.handleFocus': handleFocus,
|
|
8807
8871
|
'FindWidget.handleBlur': handleBlur,
|
|
8808
|
-
'FindWidget.
|
|
8809
|
-
'FindWidget.
|
|
8872
|
+
'FindWidget.handleFocus': handleFocus,
|
|
8873
|
+
'FindWidget.handleInput': handleInput,
|
|
8874
|
+
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
8810
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,
|
|
8811
8881
|
'Font.ensure': ensure,
|
|
8812
8882
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
8813
8883
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
@@ -9981,7 +10051,7 @@ const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
|
|
|
9981
10051
|
if (replaceExpanded) {
|
|
9982
10052
|
dom.push({
|
|
9983
10053
|
type: Div,
|
|
9984
|
-
className: FindWidgetReplace,
|
|
10054
|
+
className: FindWidgetReplace$1,
|
|
9985
10055
|
childCount: 1 + replaceButtons.length
|
|
9986
10056
|
}, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
|
|
9987
10057
|
}
|
|
@@ -9995,6 +10065,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
|
9995
10065
|
title: 'Toggle Replace',
|
|
9996
10066
|
ariaLabel: 'Toggle Replace',
|
|
9997
10067
|
ariaExpanded: replaceExpanded,
|
|
10068
|
+
name: 'ToggleReplace',
|
|
9998
10069
|
childCount: 1,
|
|
9999
10070
|
'data-command': 'toggleReplace',
|
|
10000
10071
|
onClick
|
|
@@ -10099,12 +10170,28 @@ const renderBounds = {
|
|
|
10099
10170
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10100
10171
|
}
|
|
10101
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
|
+
};
|
|
10102
10188
|
const renderFocus = {
|
|
10103
10189
|
isEqual(oldState, newState) {
|
|
10104
|
-
return oldState.focused === newState.focused;
|
|
10190
|
+
return oldState.focused === newState.focused && oldState.focus === newState.focus && oldState.focusSource === newState.focusSource;
|
|
10105
10191
|
},
|
|
10106
10192
|
apply(oldState, newState) {
|
|
10107
|
-
|
|
10193
|
+
const key = getKey(newState.focus || '');
|
|
10194
|
+
return ['focus', key, newState.focusSource];
|
|
10108
10195
|
}
|
|
10109
10196
|
};
|
|
10110
10197
|
// const getAriaLabel = (state: FindWidgetState) => {
|