@lvce-editor/editor-worker 4.1.0 → 4.2.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.
@@ -2258,13 +2258,13 @@ const cancelSelection = editor => {
2258
2258
  };
2259
2259
 
2260
2260
  // TODO use numeric widget id
2261
+ const ColorPicker$2 = 'colorPicker';
2261
2262
  const Completion = 'completion';
2262
2263
  const CompletionDetail$1 = 'completionDetail';
2263
- const ColorPicker$2 = 'colorPicker';
2264
2264
  const Find = 'find';
2265
2265
  const Hover = 'hover';
2266
- const SourceAction = 'sourceAction';
2267
2266
  const Rename$1 = 'rename';
2267
+ const SourceAction = 'sourceAction';
2268
2268
 
2269
2269
  const isCompletionWidget = widget => {
2270
2270
  return widget.id === Completion;
@@ -6697,35 +6697,44 @@ const showHover2 = async editor => {
6697
6697
  return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
6698
6698
  };
6699
6699
 
6700
- const EditorSourceActions = 'EditorSourceActions';
6701
- const showSourceActions$1 = async editor => {
6702
- // TODO
6703
- // 1. hide hover, completions, color picker
6704
- // 2. query source actions from extension host
6705
- // 3. show source actions menu
6706
-
6707
- await invoke$3('Viewlet.openWidget', EditorSourceActions);
6708
- return editor;
6709
- };
6710
-
6711
- // TODO maybe ask extension host worker instead
6700
+ // TODO ask extension host worker instead
6712
6701
  const getEditorSourceActions = async () => {
6713
6702
  const sourceActions = await invoke$3('GetEditorSourceActions.getEditorSourceActions');
6714
6703
  return sourceActions;
6715
6704
  };
6716
6705
 
6717
- const loadSourceActions = async (editorUid, state) => {
6706
+ const getSourceActionWidgetPosition = editor => {
6707
+ const width = 300;
6708
+ const height = 150;
6709
+ const cursor = getPositionAtCursor(editor);
6710
+ const x = cursor.x;
6711
+ const y = cursor.y;
6712
+ return {
6713
+ x,
6714
+ y,
6715
+ width,
6716
+ height
6717
+ };
6718
+ };
6719
+
6720
+ const loadSourceActions = async (editor, state) => {
6718
6721
  // const editor = GetEditor.getEditor(editorUid)
6719
6722
  // TODO request source actions information from extensions
6720
6723
  const sourceActions = await getEditorSourceActions();
6721
6724
  // TODO avoid side effect
6725
+ const {
6726
+ x,
6727
+ y,
6728
+ width,
6729
+ height
6730
+ } = getSourceActionWidgetPosition(editor);
6722
6731
  return {
6723
6732
  ...state,
6724
6733
  sourceActions,
6725
- x: 200,
6726
- y: -200,
6727
- width: 250,
6728
- height: 150,
6734
+ x,
6735
+ y,
6736
+ width,
6737
+ height,
6729
6738
  maxHeight: 150,
6730
6739
  focusedIndex: 0
6731
6740
  };
@@ -6760,9 +6769,8 @@ const create$1 = () => {
6760
6769
  };
6761
6770
 
6762
6771
  const showSourceActions = async editor => {
6763
- const uid = editor.uid;
6764
6772
  const newStateGenerator = state => {
6765
- return loadSourceActions(uid, state);
6773
+ return loadSourceActions(editor, state);
6766
6774
  };
6767
6775
  return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
6768
6776
  };
@@ -9244,7 +9252,7 @@ const commandMap = {
9244
9252
  'Editor.setSelections': setSelections,
9245
9253
  'Editor.showHover': showHover,
9246
9254
  'Editor.showHover2': showHover2,
9247
- 'Editor.showSourceActions': showSourceActions$1,
9255
+ 'Editor.showSourceActions': showSourceActions,
9248
9256
  'Editor.showSourceActions2': showSourceActions,
9249
9257
  'Editor.sortLinesAscending': sortLinesAscending,
9250
9258
  'Editor.tabCompletion': tabCompletion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",