@lvce-editor/text-search-worker 3.8.0 → 3.9.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/textSearchWorkerMain.js +105 -38
- package/package.json +1 -1
|
@@ -882,6 +882,7 @@ const FocusSearchRegex = 33;
|
|
|
882
882
|
const FocusSearchWholeWord = 34;
|
|
883
883
|
const FocusSearchReplaceAll = 35;
|
|
884
884
|
const FocusSearchPreserveCase = 36;
|
|
885
|
+
const FocusSearchIncludeInput = 1007;
|
|
885
886
|
|
|
886
887
|
const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
|
|
887
888
|
const state = {
|
|
@@ -1061,7 +1062,10 @@ const UiStrings = {
|
|
|
1061
1062
|
UseRegularExpression: 'Use Regular Expression',
|
|
1062
1063
|
ViewAsTree: 'View as Tree',
|
|
1063
1064
|
FilesToInclude: 'Files to Include',
|
|
1064
|
-
FilesToExclude: 'Files to Exclude'
|
|
1065
|
+
FilesToExclude: 'Files to Exclude',
|
|
1066
|
+
ToggleSearchDetails: 'Toggle Search Details',
|
|
1067
|
+
SearchOnlyOpenEditors: 'Search Only Open Editors',
|
|
1068
|
+
UseExcludeSettings: 'Use Exclude Settings'
|
|
1065
1069
|
};
|
|
1066
1070
|
const noResults = () => {
|
|
1067
1071
|
return i18nString(UiStrings.NoResults);
|
|
@@ -1081,6 +1085,9 @@ const preserveCase = () => {
|
|
|
1081
1085
|
const matchWholeWord = () => {
|
|
1082
1086
|
return i18nString(UiStrings.MatchWholeWord);
|
|
1083
1087
|
};
|
|
1088
|
+
const toggleSearchDetails = () => {
|
|
1089
|
+
return i18nString(UiStrings.ToggleSearchDetails);
|
|
1090
|
+
};
|
|
1084
1091
|
const useRegularExpression = () => {
|
|
1085
1092
|
return i18nString(UiStrings.UseRegularExpression);
|
|
1086
1093
|
};
|
|
@@ -1159,6 +1166,12 @@ const filesToInclude = () => {
|
|
|
1159
1166
|
const filesToExclude = () => {
|
|
1160
1167
|
return i18nString(UiStrings.FilesToExclude);
|
|
1161
1168
|
};
|
|
1169
|
+
const searchOnlyOpenEditors = () => {
|
|
1170
|
+
return i18nString(UiStrings.SearchOnlyOpenEditors);
|
|
1171
|
+
};
|
|
1172
|
+
const useExcludeSettings = () => {
|
|
1173
|
+
return i18nString(UiStrings.UseExcludeSettings);
|
|
1174
|
+
};
|
|
1162
1175
|
|
|
1163
1176
|
const getStatusMessage = (resultCount, fileResultCount) => {
|
|
1164
1177
|
number(resultCount);
|
|
@@ -1332,6 +1345,8 @@ const ReplaceExpanded = 1 << 2; // 4
|
|
|
1332
1345
|
const MatchWholeWord = 1 << 3; // 8
|
|
1333
1346
|
const MatchCase = 1 << 4; // 16
|
|
1334
1347
|
const DetailsExpanded = 1 << 5; // 32
|
|
1348
|
+
const OpenEditors = 1 << 6; // 64
|
|
1349
|
+
const UseIgnoreFiles = 1 << 7; // 128
|
|
1335
1350
|
|
|
1336
1351
|
const hasPreserveCase = flags => {
|
|
1337
1352
|
return (flags & PreserveCase) === PreserveCase;
|
|
@@ -1348,6 +1363,9 @@ const hasMatchWholeWord = flags => {
|
|
|
1348
1363
|
const hasMatchCase = flags => {
|
|
1349
1364
|
return (flags & MatchCase) === MatchCase;
|
|
1350
1365
|
};
|
|
1366
|
+
const hasDetailsExpanded = flags => {
|
|
1367
|
+
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
1368
|
+
};
|
|
1351
1369
|
|
|
1352
1370
|
const focusSearchValueNext = state => {
|
|
1353
1371
|
if (hasReplaceExpanded(state.flags)) {
|
|
@@ -1375,11 +1393,11 @@ const Grow = 'Grow';
|
|
|
1375
1393
|
const Highlight = 'Highlight';
|
|
1376
1394
|
const HighlightDeleted = 'HighlightDeleted';
|
|
1377
1395
|
const HighlightInserted = 'HighlightInserted';
|
|
1378
|
-
const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
|
|
1379
1396
|
const IconButton = 'IconButton';
|
|
1380
1397
|
const Label = 'Label';
|
|
1381
1398
|
const List = 'List';
|
|
1382
1399
|
const MaskIcon = 'MaskIcon';
|
|
1400
|
+
const MaskIconBook = 'MaskIconBook';
|
|
1383
1401
|
const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
|
|
1384
1402
|
const MaskIconChevronDown = 'MaskIconChevronDown';
|
|
1385
1403
|
const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
@@ -1387,6 +1405,7 @@ const MaskIconEllipsis = 'MaskIconEllipsis';
|
|
|
1387
1405
|
const MaskIconPreserveCase = 'MaskIconPreserveCase';
|
|
1388
1406
|
const MaskIconRegex = 'MaskIconRegex';
|
|
1389
1407
|
const MaskIconReplaceAll = 'MaskIconReplaceAll';
|
|
1408
|
+
const MaskIconSettings = 'MaskIconSettings';
|
|
1390
1409
|
const MaskIconWholeWord = 'MaskIconWholeWord';
|
|
1391
1410
|
const MultilineInputBox = 'MultilineInputBox';
|
|
1392
1411
|
const Search$1 = 'Search';
|
|
@@ -1397,6 +1416,9 @@ const SearchFieldButtons = 'SearchFieldButtons';
|
|
|
1397
1416
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
1398
1417
|
const SearchHeader = 'SearchHeader';
|
|
1399
1418
|
const SearchHeaderDetails = 'SearchHeaderDetails';
|
|
1419
|
+
const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
|
|
1420
|
+
const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
|
|
1421
|
+
const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
|
|
1400
1422
|
const SearchHeaderTop = 'SearchHeaderTop';
|
|
1401
1423
|
const SearchHeaderTopRight = 'SearchHeaderTopRight';
|
|
1402
1424
|
const SearchRemove = 'SearchRemove';
|
|
@@ -1412,12 +1434,13 @@ const ViewletSearchMessage = 'ViewletSearchMessage';
|
|
|
1412
1434
|
const Button$1 = 1;
|
|
1413
1435
|
|
|
1414
1436
|
const Button = 1;
|
|
1437
|
+
const Del = 21;
|
|
1415
1438
|
const Div = 4;
|
|
1416
|
-
const
|
|
1417
|
-
const Text = 12;
|
|
1439
|
+
const H4 = 24;
|
|
1418
1440
|
const Img = 17;
|
|
1419
1441
|
const Ins = 20;
|
|
1420
|
-
const
|
|
1442
|
+
const Span = 8;
|
|
1443
|
+
const Text = 12;
|
|
1421
1444
|
const TextArea = 62;
|
|
1422
1445
|
|
|
1423
1446
|
const mergeClassNames = (...classNames) => {
|
|
@@ -1616,8 +1639,8 @@ const getSearchDetailsToggleVirtualDom = () => {
|
|
|
1616
1639
|
className: ToggleDetails,
|
|
1617
1640
|
role: Button$2,
|
|
1618
1641
|
tabIndex: 0,
|
|
1619
|
-
ariaLabel:
|
|
1620
|
-
title:
|
|
1642
|
+
ariaLabel: toggleSearchDetails(),
|
|
1643
|
+
title: toggleSearchDetails(),
|
|
1621
1644
|
childCount: 1
|
|
1622
1645
|
}, {
|
|
1623
1646
|
type: Div,
|
|
@@ -1720,11 +1743,35 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
1720
1743
|
};
|
|
1721
1744
|
|
|
1722
1745
|
const getSearchHeaderDetailsExpandedVirtualDom = message => {
|
|
1746
|
+
const includeButtons = [{
|
|
1747
|
+
icon: MaskIconBook,
|
|
1748
|
+
title: searchOnlyOpenEditors(),
|
|
1749
|
+
command: 'searchOnlyOpenEditors',
|
|
1750
|
+
checked: false
|
|
1751
|
+
}];
|
|
1752
|
+
const excludeButtons = [{
|
|
1753
|
+
icon: MaskIconSettings,
|
|
1754
|
+
title: useExcludeSettings(),
|
|
1755
|
+
command: 'toggleUseExcludeSettings',
|
|
1756
|
+
checked: false
|
|
1757
|
+
}];
|
|
1723
1758
|
return [{
|
|
1724
1759
|
type: Div,
|
|
1725
1760
|
className: SearchHeaderDetailsExpanded,
|
|
1726
|
-
childCount:
|
|
1727
|
-
},
|
|
1761
|
+
childCount: 5
|
|
1762
|
+
}, {
|
|
1763
|
+
type: Div,
|
|
1764
|
+
className: SearchHeaderDetailsExpandedTop,
|
|
1765
|
+
childCount: 2
|
|
1766
|
+
}, ...getSearchDetailsToggleVirtualDom(), {
|
|
1767
|
+
type: H4,
|
|
1768
|
+
className: SearchHeaderDetailsHeading,
|
|
1769
|
+
childCount: 1
|
|
1770
|
+
}, text(filesToInclude()), ...getSearchFieldVirtualDom('files-to-include-value', 'Include', 'handleIncludeInput', includeButtons, []), {
|
|
1771
|
+
type: H4,
|
|
1772
|
+
className: SearchHeaderDetailsHeading,
|
|
1773
|
+
childCount: 1
|
|
1774
|
+
}, text(filesToExclude()), ...getSearchFieldVirtualDom('files-to-exclude-value', 'Exclude', 'handleExcludeInput', excludeButtons, []), ...getSearchMessageVirtualDom(message)];
|
|
1728
1775
|
};
|
|
1729
1776
|
|
|
1730
1777
|
const getSearchHeaderDetailsVirtualDom = (flags, message) => {
|
|
@@ -3175,18 +3222,8 @@ const refresh = state => {
|
|
|
3175
3222
|
return handleUpdate(state, {});
|
|
3176
3223
|
};
|
|
3177
3224
|
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
|
|
3181
|
-
},
|
|
3182
|
-
apply(oldState, newState) {
|
|
3183
|
-
const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
|
|
3184
|
-
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3185
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3186
|
-
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3187
|
-
}
|
|
3188
|
-
};
|
|
3189
|
-
const getSelector = focusKey => {
|
|
3225
|
+
// TODO just return name
|
|
3226
|
+
const getFocusSelector = focusKey => {
|
|
3190
3227
|
switch (focusKey) {
|
|
3191
3228
|
case FocusSearchInput:
|
|
3192
3229
|
return '[name="search-value"]';
|
|
@@ -3198,16 +3235,30 @@ const getSelector = focusKey => {
|
|
|
3198
3235
|
return '[title="Preserve Case"]';
|
|
3199
3236
|
case FocusSearchRegex:
|
|
3200
3237
|
return '[title="Use Regular Expression"]';
|
|
3238
|
+
case FocusSearchIncludeInput:
|
|
3239
|
+
return '[name="files-to-include-value"]';
|
|
3201
3240
|
default:
|
|
3202
3241
|
return '';
|
|
3203
3242
|
}
|
|
3204
3243
|
};
|
|
3244
|
+
|
|
3245
|
+
const renderItems = {
|
|
3246
|
+
isEqual(oldState, newState) {
|
|
3247
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons;
|
|
3248
|
+
},
|
|
3249
|
+
apply(oldState, newState) {
|
|
3250
|
+
const displayResults = getDisplayResults(newState.items, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.collapsedPaths, newState.icons, newState.focusedIndex);
|
|
3251
|
+
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3252
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3253
|
+
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3254
|
+
}
|
|
3255
|
+
};
|
|
3205
3256
|
const renderFocus = {
|
|
3206
3257
|
isEqual(oldState, newState) {
|
|
3207
3258
|
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3208
3259
|
},
|
|
3209
|
-
apply(newState) {
|
|
3210
|
-
const selector =
|
|
3260
|
+
apply(oldState, newState) {
|
|
3261
|
+
const selector = getFocusSelector(newState.focus);
|
|
3211
3262
|
return ['Viewlet.send', newState.uid, 'setFocus', selector, newState.focusSource];
|
|
3212
3263
|
}
|
|
3213
3264
|
};
|
|
@@ -3227,7 +3278,7 @@ const renderReplacement = {
|
|
|
3227
3278
|
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, '[name="search-replace-value"]'];
|
|
3228
3279
|
}
|
|
3229
3280
|
};
|
|
3230
|
-
const render = [renderItems,
|
|
3281
|
+
const render = [renderItems, renderValue, renderReplacement, renderFocus];
|
|
3231
3282
|
const doRender = uid => {
|
|
3232
3283
|
const {
|
|
3233
3284
|
oldState,
|
|
@@ -3328,19 +3379,13 @@ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount
|
|
|
3328
3379
|
return true;
|
|
3329
3380
|
};
|
|
3330
3381
|
|
|
3331
|
-
const saveState =
|
|
3332
|
-
const {
|
|
3333
|
-
newState
|
|
3334
|
-
} = get(uid);
|
|
3335
|
-
const {
|
|
3336
|
-
value,
|
|
3337
|
-
replacement,
|
|
3338
|
-
flags
|
|
3339
|
-
} = newState;
|
|
3382
|
+
const saveState = state => {
|
|
3340
3383
|
return {
|
|
3341
|
-
value,
|
|
3342
|
-
replacement,
|
|
3343
|
-
flags
|
|
3384
|
+
value: state.value,
|
|
3385
|
+
replacement: state.replacement,
|
|
3386
|
+
flags: state.flags,
|
|
3387
|
+
includeValue: state.includeValue,
|
|
3388
|
+
excludeValue: state.excludeValue
|
|
3344
3389
|
};
|
|
3345
3390
|
};
|
|
3346
3391
|
|
|
@@ -3438,7 +3483,19 @@ const toggleSearchFlag = (state, flag) => {
|
|
|
3438
3483
|
};
|
|
3439
3484
|
|
|
3440
3485
|
const toggleDetailsExpanded = state => {
|
|
3441
|
-
|
|
3486
|
+
const newState = toggleSearchFlag(state, DetailsExpanded);
|
|
3487
|
+
if (hasDetailsExpanded(newState.flags)) {
|
|
3488
|
+
return {
|
|
3489
|
+
...newState,
|
|
3490
|
+
focus: FocusSearchIncludeInput,
|
|
3491
|
+
focusSource: Script
|
|
3492
|
+
};
|
|
3493
|
+
}
|
|
3494
|
+
return {
|
|
3495
|
+
...newState,
|
|
3496
|
+
focus: FocusSearchInput,
|
|
3497
|
+
focusSource: Script
|
|
3498
|
+
};
|
|
3442
3499
|
};
|
|
3443
3500
|
|
|
3444
3501
|
const toggleMatchCase = state => {
|
|
@@ -3449,6 +3506,10 @@ const toggleMatchWholeWord = state => {
|
|
|
3449
3506
|
return toggleSearchFlag(state, MatchWholeWord);
|
|
3450
3507
|
};
|
|
3451
3508
|
|
|
3509
|
+
const toggleOpenEditors = state => {
|
|
3510
|
+
return toggleSearchFlag(state, OpenEditors);
|
|
3511
|
+
};
|
|
3512
|
+
|
|
3452
3513
|
const togglePreserveCase = state => {
|
|
3453
3514
|
return toggleSearchFlag(state, PreserveCase);
|
|
3454
3515
|
};
|
|
@@ -3457,6 +3518,10 @@ const toggleReplace = state => {
|
|
|
3457
3518
|
return toggleSearchFlag(state, ReplaceExpanded);
|
|
3458
3519
|
};
|
|
3459
3520
|
|
|
3521
|
+
const toggleUseIgnoreFiles = state => {
|
|
3522
|
+
return toggleSearchFlag(state, UseIgnoreFiles);
|
|
3523
|
+
};
|
|
3524
|
+
|
|
3460
3525
|
const toggleUseRegularExpression = state => {
|
|
3461
3526
|
return toggleSearchFlag(state, UseRegularExpression);
|
|
3462
3527
|
};
|
|
@@ -3550,10 +3615,12 @@ const commandMap = {
|
|
|
3550
3615
|
'TextSearch.submit': wrapCommand(submit),
|
|
3551
3616
|
'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
3552
3617
|
'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
|
|
3618
|
+
'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
|
|
3553
3619
|
'TextSearch.togglePreserveCase': wrapCommand(togglePreserveCase),
|
|
3554
3620
|
'TextSearch.toggleReplace': wrapCommand(toggleReplace),
|
|
3555
|
-
'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
3556
3621
|
'TextSearch.toggleSearchDetails': wrapCommand(toggleDetailsExpanded),
|
|
3622
|
+
'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
|
|
3623
|
+
'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
3557
3624
|
// not wrapped
|
|
3558
3625
|
'TextSearch.create': create,
|
|
3559
3626
|
'TextSearch.render': doRender,
|