@lvce-editor/editor-worker 3.11.0 → 3.12.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 +72 -38
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -2506,6 +2506,8 @@ const CompletionDetail = 999;
|
|
|
2506
2506
|
const Empty = 0;
|
|
2507
2507
|
const FindWidgetToggleReplace = 42;
|
|
2508
2508
|
const FindWidgetReplace = 43;
|
|
2509
|
+
const FindWidgetReplaceAll = 46;
|
|
2510
|
+
const FindWidgetClose = 47;
|
|
2509
2511
|
|
|
2510
2512
|
const newStateGenerator = state => {
|
|
2511
2513
|
return loadContent$3(state);
|
|
@@ -5097,7 +5099,8 @@ const create$1 = () => {
|
|
|
5097
5099
|
width: 0,
|
|
5098
5100
|
height: 0,
|
|
5099
5101
|
focused: false,
|
|
5100
|
-
focusSource: Unknown$1
|
|
5102
|
+
focusSource: Unknown$1,
|
|
5103
|
+
focus: 0
|
|
5101
5104
|
},
|
|
5102
5105
|
newState: {
|
|
5103
5106
|
value: '',
|
|
@@ -5117,7 +5120,8 @@ const create$1 = () => {
|
|
|
5117
5120
|
width: 0,
|
|
5118
5121
|
height: 0,
|
|
5119
5122
|
focused: true,
|
|
5120
|
-
focusSource: Unknown$1
|
|
5123
|
+
focusSource: Unknown$1,
|
|
5124
|
+
focus: 0
|
|
5121
5125
|
}
|
|
5122
5126
|
};
|
|
5123
5127
|
return widget;
|
|
@@ -5137,6 +5141,9 @@ const getSearchRegex = searchString => {
|
|
|
5137
5141
|
};
|
|
5138
5142
|
|
|
5139
5143
|
const findRegexMatches = (lines, regex) => {
|
|
5144
|
+
if (!regex.global) {
|
|
5145
|
+
throw new Error(`regex must be global`);
|
|
5146
|
+
}
|
|
5140
5147
|
const {
|
|
5141
5148
|
length
|
|
5142
5149
|
} = lines;
|
|
@@ -5163,6 +5170,13 @@ const findMatchesCaseInsensitive = (lines, searchString) => {
|
|
|
5163
5170
|
return findRegexMatches(lines, regex);
|
|
5164
5171
|
};
|
|
5165
5172
|
|
|
5173
|
+
const getFindWidgetHeight = replaceExpanded => {
|
|
5174
|
+
const collapsedHeight = 30;
|
|
5175
|
+
const expandedHeight = 60;
|
|
5176
|
+
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
5177
|
+
return newHeight;
|
|
5178
|
+
};
|
|
5179
|
+
|
|
5166
5180
|
const getMatchCount = matches => {
|
|
5167
5181
|
return matches.length / 2;
|
|
5168
5182
|
};
|
|
@@ -5230,28 +5244,22 @@ const handleInput = (state, value) => {
|
|
|
5230
5244
|
return refresh(state, value);
|
|
5231
5245
|
};
|
|
5232
5246
|
const handleFocus = async state => {
|
|
5233
|
-
if (state.focus ===
|
|
5247
|
+
if (state.focus === FindWidget) {
|
|
5234
5248
|
return state;
|
|
5235
5249
|
}
|
|
5236
5250
|
await setFocus(FindWidget);
|
|
5237
5251
|
return {
|
|
5238
5252
|
...state,
|
|
5239
|
-
focus:
|
|
5253
|
+
focus: FindWidget
|
|
5240
5254
|
};
|
|
5241
5255
|
};
|
|
5242
5256
|
const handleBlur = async state => {
|
|
5243
5257
|
await setFocus(Empty);
|
|
5244
5258
|
return state;
|
|
5245
5259
|
};
|
|
5246
|
-
const getHeight = replaceExpanded => {
|
|
5247
|
-
const collapsedHeight = 30;
|
|
5248
|
-
const expandedHeight = 60;
|
|
5249
|
-
const newHeight = replaceExpanded ? expandedHeight : collapsedHeight;
|
|
5250
|
-
return newHeight;
|
|
5251
|
-
};
|
|
5252
5260
|
const toggleReplace = state => {
|
|
5253
5261
|
const newExpanded = !state.replaceExpanded;
|
|
5254
|
-
const newHeight =
|
|
5262
|
+
const newHeight = getFindWidgetHeight(newExpanded);
|
|
5255
5263
|
return {
|
|
5256
5264
|
...state,
|
|
5257
5265
|
replaceExpanded: !state.replaceExpanded,
|
|
@@ -5319,14 +5327,24 @@ const close$1 = async state => {
|
|
|
5319
5327
|
disposed: true
|
|
5320
5328
|
};
|
|
5321
5329
|
};
|
|
5330
|
+
const handleToggleReplaceFocus = async state => {
|
|
5331
|
+
if (state.focus === FindWidgetToggleReplace) {
|
|
5332
|
+
return state;
|
|
5333
|
+
}
|
|
5334
|
+
await setFocus(FindWidgetToggleReplace);
|
|
5335
|
+
return {
|
|
5336
|
+
...state,
|
|
5337
|
+
focus: FindWidgetToggleReplace
|
|
5338
|
+
};
|
|
5339
|
+
};
|
|
5322
5340
|
const handleReplaceFocus = async state => {
|
|
5323
|
-
if (state.focus ===
|
|
5341
|
+
if (state.focus === FindWidgetReplace) {
|
|
5324
5342
|
return state;
|
|
5325
5343
|
}
|
|
5326
5344
|
await setFocus(FindWidgetReplace);
|
|
5327
5345
|
return {
|
|
5328
5346
|
...state,
|
|
5329
|
-
focus:
|
|
5347
|
+
focus: FindWidgetReplace,
|
|
5330
5348
|
focusSource: User
|
|
5331
5349
|
};
|
|
5332
5350
|
};
|
|
@@ -5334,7 +5352,7 @@ const focusReplace = state => {
|
|
|
5334
5352
|
// TODO
|
|
5335
5353
|
return {
|
|
5336
5354
|
...state,
|
|
5337
|
-
focus:
|
|
5355
|
+
focus: FindWidgetReplace,
|
|
5338
5356
|
focusSource: Script
|
|
5339
5357
|
};
|
|
5340
5358
|
};
|
|
@@ -5342,7 +5360,7 @@ const focusFind = state => {
|
|
|
5342
5360
|
// TODO
|
|
5343
5361
|
return {
|
|
5344
5362
|
...state,
|
|
5345
|
-
focus:
|
|
5363
|
+
focus: FindWidget,
|
|
5346
5364
|
focusSource: Script
|
|
5347
5365
|
};
|
|
5348
5366
|
};
|
|
@@ -5354,10 +5372,20 @@ const focusToggleReplace = async state => {
|
|
|
5354
5372
|
await setFocus(FindWidgetToggleReplace);
|
|
5355
5373
|
return {
|
|
5356
5374
|
...state,
|
|
5357
|
-
focus:
|
|
5375
|
+
focus: FindWidgetToggleReplace,
|
|
5358
5376
|
focusSource: Script
|
|
5359
5377
|
};
|
|
5360
5378
|
};
|
|
5379
|
+
const handleReplaceAllFocus = async state => {
|
|
5380
|
+
if (state.focus === FindWidgetReplaceAll) {
|
|
5381
|
+
return state;
|
|
5382
|
+
}
|
|
5383
|
+
await setFocus(FindWidgetReplaceAll);
|
|
5384
|
+
return {
|
|
5385
|
+
...state,
|
|
5386
|
+
focus: FindWidgetReplaceAll
|
|
5387
|
+
};
|
|
5388
|
+
};
|
|
5361
5389
|
|
|
5362
5390
|
const openFind2 = async editor => {
|
|
5363
5391
|
const newStateGenerator = async state => {
|
|
@@ -5385,7 +5413,7 @@ const openFind2 = async editor => {
|
|
|
5385
5413
|
height,
|
|
5386
5414
|
editorUid: editor.uid || editor.id,
|
|
5387
5415
|
focusSource: Script,
|
|
5388
|
-
focus:
|
|
5416
|
+
focus: FindWidget
|
|
5389
5417
|
};
|
|
5390
5418
|
return latestState;
|
|
5391
5419
|
};
|
|
@@ -8863,21 +8891,23 @@ const commandMap = {
|
|
|
8863
8891
|
'EditorCompletion.selectIndex': selectIndex,
|
|
8864
8892
|
'EditorCompletion.toggleDetails': toggleDetails,
|
|
8865
8893
|
'FindWidget.close': close$1,
|
|
8894
|
+
'FindWidget.focusFind': focusFind,
|
|
8866
8895
|
'FindWidget.focusFirst': focusFirst$1,
|
|
8867
8896
|
'FindWidget.focusIndex': focusIndex$1,
|
|
8868
8897
|
'FindWidget.focusLast': focusLast,
|
|
8869
8898
|
'FindWidget.focusNext': focusNext$1,
|
|
8870
8899
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
8900
|
+
'FindWidget.focusReplace': focusReplace,
|
|
8901
|
+
'FindWidget.focusToggleReplace': focusToggleReplace,
|
|
8871
8902
|
'FindWidget.handleBlur': handleBlur,
|
|
8872
8903
|
'FindWidget.handleFocus': handleFocus,
|
|
8873
8904
|
'FindWidget.handleInput': handleInput,
|
|
8874
8905
|
'FindWidget.handleReplaceFocus': handleReplaceFocus,
|
|
8906
|
+
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
8875
8907
|
'FindWidget.loadContent': loadContent$1,
|
|
8876
8908
|
'FindWidget.toggleReplace': toggleReplace,
|
|
8877
|
-
'FindWidget.
|
|
8878
|
-
'FindWidget.
|
|
8879
|
-
'FindWidget.handleReplaceInput': handleReplaceInput,
|
|
8880
|
-
'FindWidget.focusToggleReplace': focusToggleReplace,
|
|
8909
|
+
'FindWidget.handleToggleReplaceFocus': handleToggleReplaceFocus,
|
|
8910
|
+
'FindWidget.handleReplaceAllFocus': handleReplaceAllFocus,
|
|
8881
8911
|
'Font.ensure': ensure,
|
|
8882
8912
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
8883
8913
|
'Hover.handleSashPointerDown': handleSashPointerDown,
|
|
@@ -9951,6 +9981,24 @@ const replaceAll = () => {
|
|
|
9951
9981
|
return i18nString(UiStrings.ReplaceAll);
|
|
9952
9982
|
};
|
|
9953
9983
|
|
|
9984
|
+
// TODO always focus element by name
|
|
9985
|
+
const getFindWidgetFocusSelector = focus => {
|
|
9986
|
+
switch (focus) {
|
|
9987
|
+
case FindWidget:
|
|
9988
|
+
return `[name="search-value"]`;
|
|
9989
|
+
case FindWidgetReplace:
|
|
9990
|
+
return '[name="replace-value"]';
|
|
9991
|
+
case FindWidgetReplaceAll:
|
|
9992
|
+
return `[name="replaceAll"]`;
|
|
9993
|
+
case FindWidgetClose:
|
|
9994
|
+
return `[name="close"]`;
|
|
9995
|
+
case FindWidgetToggleReplace:
|
|
9996
|
+
return `[name="ToggleReplace"]`;
|
|
9997
|
+
default:
|
|
9998
|
+
return '';
|
|
9999
|
+
}
|
|
10000
|
+
};
|
|
10001
|
+
|
|
9954
10002
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
9955
10003
|
return {
|
|
9956
10004
|
type,
|
|
@@ -10068,7 +10116,8 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
|
10068
10116
|
name: 'ToggleReplace',
|
|
10069
10117
|
childCount: 1,
|
|
10070
10118
|
'data-command': 'toggleReplace',
|
|
10071
|
-
onClick
|
|
10119
|
+
onClick,
|
|
10120
|
+
onFocus: 'handleToggleReplaceFocus'
|
|
10072
10121
|
}, {
|
|
10073
10122
|
type: Div,
|
|
10074
10123
|
className: `MaskIcon ${replaceExpanded ? 'MaskIconChevronDown' : 'MaskIconChevronRight'}`,
|
|
@@ -10170,27 +10219,12 @@ const renderBounds = {
|
|
|
10170
10219
|
return [/* method */SetBounds, /* x */x, /* y */y, /* width */width, /* height */height];
|
|
10171
10220
|
}
|
|
10172
10221
|
};
|
|
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
|
-
};
|
|
10188
10222
|
const renderFocus = {
|
|
10189
10223
|
isEqual(oldState, newState) {
|
|
10190
10224
|
return oldState.focused === newState.focused && oldState.focus === newState.focus && oldState.focusSource === newState.focusSource;
|
|
10191
10225
|
},
|
|
10192
10226
|
apply(oldState, newState) {
|
|
10193
|
-
const key =
|
|
10227
|
+
const key = getFindWidgetFocusSelector(newState.focus);
|
|
10194
10228
|
return ['focus', key, newState.focusSource];
|
|
10195
10229
|
}
|
|
10196
10230
|
};
|