@lvce-editor/find-widget-worker 1.7.0 → 1.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/findWidgetWorkerMain.js +70 -74
- package/package.json +1 -1
|
@@ -981,36 +981,74 @@ const focusCloseButton = state => {
|
|
|
981
981
|
return setFindWidgetFocus(state, FocusFindWidgetCloseButton);
|
|
982
982
|
};
|
|
983
983
|
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
984
|
+
const rpcs = Object.create(null);
|
|
985
|
+
const set$a = (id, rpc) => {
|
|
986
|
+
rpcs[id] = rpc;
|
|
987
|
+
};
|
|
988
|
+
const get = id => {
|
|
989
|
+
return rpcs[id];
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
993
|
+
|
|
994
|
+
const create = rpcId => {
|
|
995
|
+
return {
|
|
996
|
+
// @ts-ignore
|
|
997
|
+
invoke(method, ...params) {
|
|
998
|
+
const rpc = get(rpcId);
|
|
999
|
+
// @ts-ignore
|
|
1000
|
+
return rpc.invoke(method, ...params);
|
|
1001
|
+
},
|
|
1002
|
+
// @ts-ignore
|
|
1003
|
+
invokeAndTransfer(method, ...params) {
|
|
1004
|
+
const rpc = get(rpcId);
|
|
1005
|
+
// @ts-ignore
|
|
1006
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1007
|
+
},
|
|
1008
|
+
set(rpc) {
|
|
1009
|
+
set$a(rpcId, rpc);
|
|
1010
|
+
}
|
|
1011
|
+
};
|
|
1012
|
+
};
|
|
1013
|
+
const EditorWorker$1 = 99;
|
|
1014
|
+
const {
|
|
1015
|
+
invoke: invoke$9,
|
|
1016
|
+
set: set$9
|
|
1017
|
+
} = create(EditorWorker$1);
|
|
1018
|
+
const EditorWorker = {
|
|
1019
|
+
__proto__: null,
|
|
1020
|
+
invoke: invoke$9,
|
|
1021
|
+
set: set$9
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
const {
|
|
1025
|
+
invoke,
|
|
1026
|
+
set} = EditorWorker;
|
|
1027
|
+
|
|
1028
|
+
const setSelections = async (editorUid, selections) => {
|
|
1029
|
+
// @ts-ignore
|
|
1030
|
+
await invoke('Editor.setSelections2', editorUid, selections);
|
|
1031
|
+
};
|
|
1032
|
+
|
|
1033
|
+
const focusIndex = async (state, index) => {
|
|
987
1034
|
const {
|
|
988
|
-
matchIndex
|
|
1035
|
+
matchIndex,
|
|
1036
|
+
matches,
|
|
1037
|
+
editorUid,
|
|
1038
|
+
value
|
|
989
1039
|
} = state;
|
|
990
1040
|
if (index === matchIndex) {
|
|
991
1041
|
return state;
|
|
992
1042
|
}
|
|
993
|
-
// TODO update editor
|
|
994
|
-
// const { widgets } = editor
|
|
995
|
-
// const childIndex = widgets.findIndex(isFind)
|
|
996
|
-
// const childWidget = widgets[childIndex]
|
|
997
|
-
|
|
998
1043
|
// // TODO find next match and highlight it
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
// ...findState,
|
|
1004
|
-
// matchIndex: index,
|
|
1005
|
-
// }
|
|
1006
|
-
// const newWidget = {
|
|
1007
|
-
// ...childWidget,
|
|
1008
|
-
// newState,
|
|
1009
|
-
// }
|
|
1010
|
-
// const newWidgets = [...widgets.slice(0, childIndex), newWidget, ...widgets.slice(childIndex + 1)]
|
|
1044
|
+
const matchRowIndex = matches[index * 2];
|
|
1045
|
+
const matchColumnIndex = matches[index * 2 + 1];
|
|
1046
|
+
const newSelections = new Uint32Array([matchRowIndex, matchColumnIndex, matchRowIndex, matchColumnIndex + value.length]);
|
|
1047
|
+
await setSelections(editorUid, newSelections);
|
|
1011
1048
|
return {
|
|
1012
1049
|
...state,
|
|
1013
|
-
matchIndex: index
|
|
1050
|
+
matchIndex: index,
|
|
1051
|
+
selections: [...newSelections]
|
|
1014
1052
|
};
|
|
1015
1053
|
};
|
|
1016
1054
|
const focusFirst = state => {
|
|
@@ -1058,50 +1096,6 @@ const handleBlur = async state => {
|
|
|
1058
1096
|
};
|
|
1059
1097
|
};
|
|
1060
1098
|
|
|
1061
|
-
const rpcs = Object.create(null);
|
|
1062
|
-
const set$a = (id, rpc) => {
|
|
1063
|
-
rpcs[id] = rpc;
|
|
1064
|
-
};
|
|
1065
|
-
const get = id => {
|
|
1066
|
-
return rpcs[id];
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1070
|
-
|
|
1071
|
-
const create = rpcId => {
|
|
1072
|
-
return {
|
|
1073
|
-
// @ts-ignore
|
|
1074
|
-
invoke(method, ...params) {
|
|
1075
|
-
const rpc = get(rpcId);
|
|
1076
|
-
// @ts-ignore
|
|
1077
|
-
return rpc.invoke(method, ...params);
|
|
1078
|
-
},
|
|
1079
|
-
// @ts-ignore
|
|
1080
|
-
invokeAndTransfer(method, ...params) {
|
|
1081
|
-
const rpc = get(rpcId);
|
|
1082
|
-
// @ts-ignore
|
|
1083
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
1084
|
-
},
|
|
1085
|
-
set(rpc) {
|
|
1086
|
-
set$a(rpcId, rpc);
|
|
1087
|
-
}
|
|
1088
|
-
};
|
|
1089
|
-
};
|
|
1090
|
-
const EditorWorker$1 = 99;
|
|
1091
|
-
const {
|
|
1092
|
-
invoke: invoke$9,
|
|
1093
|
-
set: set$9
|
|
1094
|
-
} = create(EditorWorker$1);
|
|
1095
|
-
const EditorWorker = {
|
|
1096
|
-
__proto__: null,
|
|
1097
|
-
invoke: invoke$9,
|
|
1098
|
-
set: set$9
|
|
1099
|
-
};
|
|
1100
|
-
|
|
1101
|
-
const {
|
|
1102
|
-
invoke,
|
|
1103
|
-
set} = EditorWorker;
|
|
1104
|
-
|
|
1105
1099
|
const close$1 = async state => {
|
|
1106
1100
|
const {
|
|
1107
1101
|
editorUid
|
|
@@ -1137,11 +1131,9 @@ const findRegexMatches = (lines, regex) => {
|
|
|
1137
1131
|
return new Uint32Array(matches);
|
|
1138
1132
|
};
|
|
1139
1133
|
|
|
1140
|
-
// copied from https://github.com/microsoft/vscode/tree/main/src/vs/base/common/strings.ts by Microsoft (License MIT)
|
|
1141
|
-
|
|
1142
|
-
const RE_ESCAPE = /[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g;
|
|
1143
1134
|
const escapeRegExpCharacters = value => {
|
|
1144
|
-
|
|
1135
|
+
// @ts-ignore
|
|
1136
|
+
return RegExp.escape(value);
|
|
1145
1137
|
};
|
|
1146
1138
|
|
|
1147
1139
|
const regexFlags = 'gi';
|
|
@@ -1289,6 +1281,10 @@ const loadContent = async state => {
|
|
|
1289
1281
|
};
|
|
1290
1282
|
};
|
|
1291
1283
|
|
|
1284
|
+
const preventDefaultBrowserFind = state => {
|
|
1285
|
+
return state;
|
|
1286
|
+
};
|
|
1287
|
+
|
|
1292
1288
|
const SetBounds = 'Viewlet.setBounds';
|
|
1293
1289
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1294
1290
|
const SetUid = 'Viewlet.setUid';
|
|
@@ -1307,7 +1303,6 @@ const renderBounds = (oldState, newState) => {
|
|
|
1307
1303
|
|
|
1308
1304
|
const HandleBlur = 'handleBlur';
|
|
1309
1305
|
const HandleClickClose = 'handleClickClose';
|
|
1310
|
-
const HandleClickFocusPreviousMatch = 'handleClickFocusPreviousMatch';
|
|
1311
1306
|
const HandleClickNextMatch = 'handleClickNextMatch';
|
|
1312
1307
|
const HandleClickPreviousMatch = 'handleClickPreviousMatch';
|
|
1313
1308
|
const HandleClickReplace = 'handleClickReplace';
|
|
@@ -1660,11 +1655,11 @@ const getEventListeners = (uid, widgetId) => {
|
|
|
1660
1655
|
name: HandleClickClose,
|
|
1661
1656
|
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleClickClose', 0, widgetId]
|
|
1662
1657
|
}, {
|
|
1663
|
-
name:
|
|
1664
|
-
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.
|
|
1658
|
+
name: HandleClickPreviousMatch,
|
|
1659
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.focusPrevious', 0, widgetId]
|
|
1665
1660
|
}, {
|
|
1666
1661
|
name: HandleClickNextMatch,
|
|
1667
|
-
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.
|
|
1662
|
+
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.focusNext', 0, widgetId]
|
|
1668
1663
|
}, {
|
|
1669
1664
|
name: HandleClickReplace,
|
|
1670
1665
|
params: ['executeWidgetCommand', 'FindWidget', 'FindWidget.handleClickReplace', 0, widgetId]
|
|
@@ -1795,6 +1790,7 @@ const commandMap = {
|
|
|
1795
1790
|
'FindWidget.handleClickClose': wrapCommand(handleClickClose),
|
|
1796
1791
|
'FindWidget.handleInput': wrapCommand(handleInput),
|
|
1797
1792
|
'FindWidget.loadContent': wrapCommand(loadContent),
|
|
1793
|
+
'FindWidget.preventDefaultBrowserFind': wrapCommand(preventDefaultBrowserFind),
|
|
1798
1794
|
'FindWidget.render2': render2,
|
|
1799
1795
|
'FindWidget.terminate': terminate,
|
|
1800
1796
|
'FindWidget.toggleReplace': wrapCommand(toggleReplace)
|