@lvce-editor/editor-worker 3.7.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/editorWorkerMain.js +134 -54
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -134,7 +134,6 @@ const EditorRow = 'EditorRow';
|
|
|
134
134
|
const EditorSelection = 'EditorSelection';
|
|
135
135
|
const FileIcon = 'FileIcon';
|
|
136
136
|
const HoverDisplayString = 'HoverDisplayString';
|
|
137
|
-
const SearchFieldContainer = 'SearchFieldContainer';
|
|
138
137
|
const HoverDocumentation = 'HoverDocumentation';
|
|
139
138
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
140
139
|
const HoverEditorRow = 'HoverEditorRow';
|
|
@@ -2078,7 +2077,7 @@ const applyEdit = async (editor, changes) => {
|
|
|
2078
2077
|
return scheduleDocumentAndCursorsSelections(editor, changes);
|
|
2079
2078
|
};
|
|
2080
2079
|
|
|
2081
|
-
const handleBlur = editor => {
|
|
2080
|
+
const handleBlur$1 = editor => {
|
|
2082
2081
|
// for (const listener of state.blurListeners) {
|
|
2083
2082
|
// listener(editor)
|
|
2084
2083
|
// }
|
|
@@ -3420,9 +3419,6 @@ const noTypeDefinitionFound = () => {
|
|
|
3420
3419
|
const noResults$1 = () => {
|
|
3421
3420
|
return i18nString(UiStrings$1.NoResults);
|
|
3422
3421
|
};
|
|
3423
|
-
const replace = () => {
|
|
3424
|
-
return i18nString(UiStrings$1.Replace);
|
|
3425
|
-
};
|
|
3426
3422
|
|
|
3427
3423
|
// @ts-ignore
|
|
3428
3424
|
const goTo = async ({
|
|
@@ -3627,7 +3623,7 @@ const handleDoubleClick = (editor, modifier, x, y) => {
|
|
|
3627
3623
|
};
|
|
3628
3624
|
|
|
3629
3625
|
const WhenExpressionEditorText = 12;
|
|
3630
|
-
const handleFocus = editor => {
|
|
3626
|
+
const handleFocus$1 = editor => {
|
|
3631
3627
|
// TODO make change events functional,
|
|
3632
3628
|
// when rendering, send focus changes to renderer worker
|
|
3633
3629
|
invoke$3('Focus.setFocus', WhenExpressionEditorText);
|
|
@@ -5219,6 +5215,27 @@ const refresh = (state, value = state.value) => {
|
|
|
5219
5215
|
const handleInput = (state, value) => {
|
|
5220
5216
|
return refresh(state, value);
|
|
5221
5217
|
};
|
|
5218
|
+
const handleFocus = async state => {
|
|
5219
|
+
const FindWidget = 16;
|
|
5220
|
+
await invoke$3('Focus.setFocus', FindWidget);
|
|
5221
|
+
return state;
|
|
5222
|
+
};
|
|
5223
|
+
const handleBlur = async state => {
|
|
5224
|
+
const Empty = 0;
|
|
5225
|
+
await invoke$3('Focus.setFocus', Empty);
|
|
5226
|
+
return state;
|
|
5227
|
+
};
|
|
5228
|
+
const toggleReplace = state => {
|
|
5229
|
+
const newExpanded = !state.replaceExpanded;
|
|
5230
|
+
const collapsedHeight = 30;
|
|
5231
|
+
const expandedHeight = 60;
|
|
5232
|
+
const newHeight = newExpanded ? expandedHeight : collapsedHeight;
|
|
5233
|
+
return {
|
|
5234
|
+
...state,
|
|
5235
|
+
replaceExpanded: !state.replaceExpanded,
|
|
5236
|
+
height: newHeight
|
|
5237
|
+
};
|
|
5238
|
+
};
|
|
5222
5239
|
|
|
5223
5240
|
// TODO this function should be synchronous
|
|
5224
5241
|
const focusIndex$1 = async (state, index) => {
|
|
@@ -5272,6 +5289,14 @@ const focusPrevious$1 = state => {
|
|
|
5272
5289
|
}
|
|
5273
5290
|
return focusIndex$1(state, matchIndex - 1);
|
|
5274
5291
|
};
|
|
5292
|
+
const close$1 = async state => {
|
|
5293
|
+
// TODO
|
|
5294
|
+
// await Viewlet.closeWidget(uid)
|
|
5295
|
+
return {
|
|
5296
|
+
...state,
|
|
5297
|
+
disposed: true
|
|
5298
|
+
};
|
|
5299
|
+
};
|
|
5275
5300
|
|
|
5276
5301
|
const openFind2 = async editor => {
|
|
5277
5302
|
const newStateGenerator = async state => {
|
|
@@ -8594,7 +8619,11 @@ const widgetCommands = {
|
|
|
8594
8619
|
'FindWidget.close': Find,
|
|
8595
8620
|
'FindWidget.focusIndex': Find,
|
|
8596
8621
|
'FindWidget.focusFirst': Find,
|
|
8597
|
-
'FindWidget.focusLast': Find
|
|
8622
|
+
'FindWidget.focusLast': Find,
|
|
8623
|
+
'FindWidget.toggleReplace': Find,
|
|
8624
|
+
'FindWidget.handleFocus': Find,
|
|
8625
|
+
'FindWidget.handleBlur': Find,
|
|
8626
|
+
'FindWidget.handleToggleReplaceFocus': Find
|
|
8598
8627
|
};
|
|
8599
8628
|
|
|
8600
8629
|
// TODO wrap commands globally, not per editor
|
|
@@ -8674,10 +8703,10 @@ const commandMap = {
|
|
|
8674
8703
|
'Editor.goToTypeDefinition': goToTypeDefinition,
|
|
8675
8704
|
'Editor.handleBeforeInput': handleBeforeInput,
|
|
8676
8705
|
'Editor.handleBeforeInputFromContentEditable': handleBeforeInputFromContentEditable,
|
|
8677
|
-
'Editor.handleBlur': handleBlur,
|
|
8706
|
+
'Editor.handleBlur': handleBlur$1,
|
|
8678
8707
|
'Editor.handleContextMenu': handleContextMenu,
|
|
8679
8708
|
'Editor.handleDoubleClick': handleDoubleClick,
|
|
8680
|
-
'Editor.handleFocus': handleFocus,
|
|
8709
|
+
'Editor.handleFocus': handleFocus$1,
|
|
8681
8710
|
'Editor.handleMouseDown': handleMouseDown,
|
|
8682
8711
|
'Editor.handleMouseMove': handleMouseMove,
|
|
8683
8712
|
'Editor.handleMouseMoveWithAltKey': handleMouseMoveWithAltKey,
|
|
@@ -8769,6 +8798,10 @@ const commandMap = {
|
|
|
8769
8798
|
'FindWidget.focusNext': focusNext$1,
|
|
8770
8799
|
'FindWidget.focusPrevious': focusPrevious$1,
|
|
8771
8800
|
'FindWidget.handleInput': handleInput,
|
|
8801
|
+
'FindWidget.handleFocus': handleFocus,
|
|
8802
|
+
'FindWidget.handleBlur': handleBlur,
|
|
8803
|
+
'FindWidget.toggleReplace': toggleReplace,
|
|
8804
|
+
'FindWidget.close': close$1,
|
|
8772
8805
|
'FindWidget.loadContent': loadContent$1,
|
|
8773
8806
|
'Font.ensure': ensure,
|
|
8774
8807
|
'Hover.getHoverInfo': getEditorHoverInfo,
|
|
@@ -9713,9 +9746,14 @@ const add$2 = widget => {
|
|
|
9713
9746
|
return addWidget(widget, 'ColorPicker', render$4);
|
|
9714
9747
|
};
|
|
9715
9748
|
const remove$2 = removeWidget;
|
|
9749
|
+
const Commands$1 = {
|
|
9750
|
+
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
9751
|
+
'ColorPicker.handleSliderPointerMove': handleSliderPointerMove
|
|
9752
|
+
};
|
|
9716
9753
|
|
|
9717
9754
|
const EditorColorPickerWidget = {
|
|
9718
9755
|
__proto__: null,
|
|
9756
|
+
Commands: Commands$1,
|
|
9719
9757
|
add: add$2,
|
|
9720
9758
|
remove: remove$2,
|
|
9721
9759
|
render: render$4
|
|
@@ -9806,7 +9844,9 @@ const UiStrings = {
|
|
|
9806
9844
|
Close: 'Close',
|
|
9807
9845
|
PreviousMatch: 'Previous Match',
|
|
9808
9846
|
NextMatch: 'Next Match',
|
|
9809
|
-
Find: 'Find'
|
|
9847
|
+
Find: 'Find',
|
|
9848
|
+
Replace: 'Replace',
|
|
9849
|
+
ReplaceAll: 'Replace All'
|
|
9810
9850
|
};
|
|
9811
9851
|
const noResults = () => {
|
|
9812
9852
|
return i18nString(UiStrings.NoResults);
|
|
@@ -9826,6 +9866,15 @@ const nextMatch = () => {
|
|
|
9826
9866
|
const close = () => {
|
|
9827
9867
|
return i18nString(UiStrings.Close);
|
|
9828
9868
|
};
|
|
9869
|
+
const find = () => {
|
|
9870
|
+
return i18nString(UiStrings.Find);
|
|
9871
|
+
};
|
|
9872
|
+
const replace = () => {
|
|
9873
|
+
return i18nString(UiStrings.Replace);
|
|
9874
|
+
};
|
|
9875
|
+
const replaceAll = () => {
|
|
9876
|
+
return i18nString(UiStrings.ReplaceAll);
|
|
9877
|
+
};
|
|
9829
9878
|
|
|
9830
9879
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
9831
9880
|
return {
|
|
@@ -9836,6 +9885,26 @@ const getIconVirtualDom = (icon, type = Div) => {
|
|
|
9836
9885
|
};
|
|
9837
9886
|
};
|
|
9838
9887
|
|
|
9888
|
+
const getIconButtonVirtualDom = iconButton => {
|
|
9889
|
+
const {
|
|
9890
|
+
label,
|
|
9891
|
+
icon,
|
|
9892
|
+
disabled
|
|
9893
|
+
} = iconButton;
|
|
9894
|
+
let className = IconButton;
|
|
9895
|
+
if (disabled) {
|
|
9896
|
+
className += ' ' + IconButtonDisabled;
|
|
9897
|
+
}
|
|
9898
|
+
return [{
|
|
9899
|
+
type: Button,
|
|
9900
|
+
className,
|
|
9901
|
+
title: label,
|
|
9902
|
+
ariaLabel: label,
|
|
9903
|
+
childCount: 1,
|
|
9904
|
+
disabled: disabled ? true : undefined
|
|
9905
|
+
}, getIconVirtualDom(icon)];
|
|
9906
|
+
};
|
|
9907
|
+
|
|
9839
9908
|
const getSearchFieldButtonVirtualDom = button => {
|
|
9840
9909
|
const {
|
|
9841
9910
|
icon,
|
|
@@ -9880,13 +9949,35 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
9880
9949
|
childCount: insideButtons.length
|
|
9881
9950
|
}, ...insideButtons.flatMap(getSearchFieldButtonVirtualDom)];
|
|
9882
9951
|
if (outsideButtons.length > 0) {
|
|
9883
|
-
|
|
9952
|
+
throw new Error('outsideButtons are deprecated');
|
|
9953
|
+
}
|
|
9954
|
+
return dom;
|
|
9955
|
+
};
|
|
9956
|
+
|
|
9957
|
+
const getFindWidgetFindVirtualDom = (matchCountText, buttons) => {
|
|
9958
|
+
const dom = [];
|
|
9959
|
+
dom.push({
|
|
9960
|
+
type: Div,
|
|
9961
|
+
className: FindWidgetFind,
|
|
9962
|
+
childCount: 5
|
|
9963
|
+
});
|
|
9964
|
+
dom.push(...getSearchFieldVirtualDom('search-value', find(), 'handleInput', [], [], 'handleFocus'));
|
|
9965
|
+
dom.push({
|
|
9966
|
+
type: Div,
|
|
9967
|
+
className: FindWidgetMatchCount,
|
|
9968
|
+
childCount: 1
|
|
9969
|
+
}, text(matchCountText), ...buttons.flatMap(getIconButtonVirtualDom));
|
|
9970
|
+
return dom;
|
|
9971
|
+
};
|
|
9972
|
+
|
|
9973
|
+
const getFindWidgetReplaceVirtualDom = (replaceExpanded, replaceButtons) => {
|
|
9974
|
+
const dom = [];
|
|
9975
|
+
if (replaceExpanded) {
|
|
9976
|
+
dom.push({
|
|
9884
9977
|
type: Div,
|
|
9885
|
-
className:
|
|
9886
|
-
|
|
9887
|
-
|
|
9888
|
-
});
|
|
9889
|
-
dom.push(...outsideButtons.flatMap(getSearchFieldButtonVirtualDom));
|
|
9978
|
+
className: FindWidgetReplace,
|
|
9979
|
+
childCount: 1 + replaceButtons.length
|
|
9980
|
+
}, ...getSearchFieldVirtualDom('replace-value', replace(), 'handleReplaceInput', [], [], 'handleReplaceFocus'), ...replaceButtons.flatMap(getIconButtonVirtualDom));
|
|
9890
9981
|
}
|
|
9891
9982
|
return dom;
|
|
9892
9983
|
};
|
|
@@ -9908,26 +9999,7 @@ const getSearchToggleButtonVirtualDom = (replaceExpanded, onClick = '') => {
|
|
|
9908
9999
|
}];
|
|
9909
10000
|
};
|
|
9910
10001
|
|
|
9911
|
-
const
|
|
9912
|
-
const {
|
|
9913
|
-
label,
|
|
9914
|
-
icon,
|
|
9915
|
-
disabled
|
|
9916
|
-
} = iconButton;
|
|
9917
|
-
let className = IconButton;
|
|
9918
|
-
if (disabled) {
|
|
9919
|
-
className += ' ' + IconButtonDisabled;
|
|
9920
|
-
}
|
|
9921
|
-
return [{
|
|
9922
|
-
type: Button,
|
|
9923
|
-
className,
|
|
9924
|
-
title: label,
|
|
9925
|
-
ariaLabel: label,
|
|
9926
|
-
childCount: 1,
|
|
9927
|
-
disabled: disabled ? true : undefined
|
|
9928
|
-
}, getIconVirtualDom(icon)];
|
|
9929
|
-
};
|
|
9930
|
-
const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, matchCase, matchWholeWord, useRegularExpression) => {
|
|
10002
|
+
const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, findButtons, replaceButtons, matchCase, matchWholeWord, useRegularExpression) => {
|
|
9931
10003
|
const dom = [];
|
|
9932
10004
|
dom.push({
|
|
9933
10005
|
type: Div,
|
|
@@ -9941,23 +10013,9 @@ const getFindWidgetVirtualDom = (matchCountText, replaceExpanded, buttons, match
|
|
|
9941
10013
|
className: FindWidgetRight,
|
|
9942
10014
|
childCount: replaceExpanded ? 2 : 1
|
|
9943
10015
|
});
|
|
9944
|
-
dom.push(
|
|
9945
|
-
type: Div,
|
|
9946
|
-
className: FindWidgetFind,
|
|
9947
|
-
childCount: 5
|
|
9948
|
-
});
|
|
9949
|
-
dom.push(...getSearchFieldVirtualDom('search-value', 'Find', 'handleInput', [], [], 'handleFocus'));
|
|
9950
|
-
dom.push({
|
|
9951
|
-
type: Div,
|
|
9952
|
-
className: FindWidgetMatchCount,
|
|
9953
|
-
childCount: 1
|
|
9954
|
-
}, text(matchCountText), ...buttons.flatMap(getIconButtonVirtualDom));
|
|
10016
|
+
dom.push(...getFindWidgetFindVirtualDom(matchCountText, findButtons));
|
|
9955
10017
|
if (replaceExpanded) {
|
|
9956
|
-
dom.push(
|
|
9957
|
-
type: Div,
|
|
9958
|
-
className: FindWidgetReplace,
|
|
9959
|
-
childCount: 1
|
|
9960
|
-
}, text(replace()));
|
|
10018
|
+
dom.push(...getFindWidgetReplaceVirtualDom(replaceExpanded, replaceButtons));
|
|
9961
10019
|
}
|
|
9962
10020
|
return dom;
|
|
9963
10021
|
};
|
|
@@ -9972,6 +10030,8 @@ const getMatchCountText = (matchIndex, matchCount) => {
|
|
|
9972
10030
|
const ArrowDown = 'ArrowDown';
|
|
9973
10031
|
const ArrowUp = 'ArrowUp';
|
|
9974
10032
|
const Close = 'Close';
|
|
10033
|
+
const Replace = 'Replace';
|
|
10034
|
+
const ReplaceAll = 'ReplaceAll';
|
|
9975
10035
|
|
|
9976
10036
|
const renderValue = {
|
|
9977
10037
|
isEqual(oldState, newState) {
|
|
@@ -9988,7 +10048,7 @@ const renderDetails = {
|
|
|
9988
10048
|
apply(oldState, newState) {
|
|
9989
10049
|
const matchCountText = getMatchCountText(newState.matchIndex, newState.matchCount);
|
|
9990
10050
|
const buttonsEnabled = newState.matchCount > 0;
|
|
9991
|
-
const
|
|
10051
|
+
const findButtons = [{
|
|
9992
10052
|
label: previousMatch(),
|
|
9993
10053
|
icon: ArrowUp,
|
|
9994
10054
|
disabled: !buttonsEnabled
|
|
@@ -10001,7 +10061,16 @@ const renderDetails = {
|
|
|
10001
10061
|
icon: Close,
|
|
10002
10062
|
disabled: false
|
|
10003
10063
|
}];
|
|
10004
|
-
const
|
|
10064
|
+
const replaceButtons = [{
|
|
10065
|
+
label: replace(),
|
|
10066
|
+
icon: Replace,
|
|
10067
|
+
disabled: !buttonsEnabled
|
|
10068
|
+
}, {
|
|
10069
|
+
label: replaceAll(),
|
|
10070
|
+
icon: ReplaceAll,
|
|
10071
|
+
disabled: !buttonsEnabled
|
|
10072
|
+
}];
|
|
10073
|
+
const dom = getFindWidgetVirtualDom(matchCountText, newState.replaceExpanded, findButtons, replaceButtons);
|
|
10005
10074
|
return ['Viewlet.setDom2', dom];
|
|
10006
10075
|
}
|
|
10007
10076
|
};
|
|
@@ -10069,9 +10138,20 @@ const add = widget => {
|
|
|
10069
10138
|
return addWidget(widget, 'FindWidget', render);
|
|
10070
10139
|
};
|
|
10071
10140
|
const remove = removeWidget;
|
|
10141
|
+
const Commands = {
|
|
10142
|
+
'FindWidget.close': close$1,
|
|
10143
|
+
'FindWidget.focusNext': focusNext$1,
|
|
10144
|
+
'FindWidget.focusPrevious': focusPrevious$1,
|
|
10145
|
+
'FindWidget.focusIndex': focusIndex$1,
|
|
10146
|
+
'FindWidget.focusLast': focusLast,
|
|
10147
|
+
'FindWidget.toggleReplace': toggleReplace,
|
|
10148
|
+
'FindWidget.handleFocus': handleFocus,
|
|
10149
|
+
'FindWidget.handleBlur': handleBlur
|
|
10150
|
+
};
|
|
10072
10151
|
|
|
10073
10152
|
const EditorFindWidget = {
|
|
10074
10153
|
__proto__: null,
|
|
10154
|
+
Commands,
|
|
10075
10155
|
add,
|
|
10076
10156
|
remove,
|
|
10077
10157
|
render
|