@lvce-editor/editor-worker 4.6.0 → 4.7.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.
@@ -3357,7 +3357,8 @@ const UiStrings$1 = {
3357
3357
  Replace: 'Replace',
3358
3358
  SourceAction: 'Source Action',
3359
3359
  OrganizeImports: 'Organize Imports',
3360
- SortImports: 'Sort Imports'
3360
+ SortImports: 'Sort Imports',
3361
+ NoCodeActionsAvailable: 'No code actions available'
3361
3362
  };
3362
3363
  const noDefinitionFound = () => {
3363
3364
  return i18nString(UiStrings$1.NoDefinitionFound);
@@ -3381,6 +3382,9 @@ const noResults$1 = () => {
3381
3382
  const sourceAction = () => {
3382
3383
  return i18nString(UiStrings$1.SourceAction);
3383
3384
  };
3385
+ const noCodeActionsAvailable = () => {
3386
+ return i18nString(UiStrings$1.NoCodeActionsAvailable);
3387
+ };
3384
3388
 
3385
3389
  // @ts-ignore
3386
3390
  const goTo = async ({
@@ -6721,12 +6725,19 @@ const getEditorSourceActions = async () => {
6721
6725
  return sourceActions;
6722
6726
  };
6723
6727
 
6724
- const getSourceActionWidgetPosition = editor => {
6728
+ const getHeight = sourceActionCount => {
6729
+ if (sourceActionCount === 0) {
6730
+ return 45;
6731
+ }
6732
+ return 150;
6733
+ };
6734
+ const getSourceActionWidgetPosition = (editor, sourceActionCount) => {
6725
6735
  const width = 300;
6726
- const height = 150;
6736
+ const height = getHeight(sourceActionCount);
6727
6737
  const cursor = getPositionAtCursor(editor);
6728
6738
  const x = cursor.x;
6729
6739
  const y = cursor.y;
6740
+ // TODO support virtual list
6730
6741
  return {
6731
6742
  x,
6732
6743
  y,
@@ -6745,7 +6756,7 @@ const loadSourceActions = async (editor, state) => {
6745
6756
  y,
6746
6757
  width,
6747
6758
  height
6748
- } = getSourceActionWidgetPosition(editor);
6759
+ } = getSourceActionWidgetPosition(editor, sourceActions.length);
6749
6760
  return {
6750
6761
  ...state,
6751
6762
  sourceActions,
@@ -7861,6 +7872,7 @@ const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
7861
7872
  const SourceActionItem = 'SourceActionItem';
7862
7873
  const SourceActionItemFocused = 'SourceActionItemFocused';
7863
7874
  const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
7875
+ const EditorSourceActionsList = 'EditorSourceActionsList';
7864
7876
  const IconButtonDisabled = 'IconButtonDisabled';
7865
7877
  const IconButton = 'IconButton';
7866
7878
  const SourceActionHeading = 'SourceActionHeading';
@@ -11000,7 +11012,32 @@ const getSourceActionListItemVirtualDom = sourceAction => {
11000
11012
  }, text(name)];
11001
11013
  };
11002
11014
 
11015
+ const getEditorMessageVirtualDom = message => {
11016
+ const dom = [{
11017
+ type: Div,
11018
+ className: 'Viewlet EditorMessage',
11019
+ tabIndex: -1,
11020
+ childCount: 2
11021
+ }, {
11022
+ type: Div,
11023
+ className: 'EditorMessageText',
11024
+ childCount: 1
11025
+ }, text(message), {
11026
+ type: Div,
11027
+ className: 'EditorMessageTriangle',
11028
+ childCount: 0
11029
+ }];
11030
+ return dom;
11031
+ };
11032
+
11033
+ const getEmptySourceActionsVirtualDom = () => {
11034
+ return getEditorMessageVirtualDom(noCodeActionsAvailable());
11035
+ };
11036
+
11003
11037
  const getSourceActionsVirtualDom = sourceActions => {
11038
+ if (sourceActions.length === 0) {
11039
+ return getEmptySourceActionsVirtualDom();
11040
+ }
11004
11041
  const dom = [{
11005
11042
  type: Div,
11006
11043
  className: 'Viewlet EditorSourceActions',
@@ -11013,7 +11050,7 @@ const getSourceActionsVirtualDom = sourceActions => {
11013
11050
  childCount: 1
11014
11051
  }, text(sourceAction()), {
11015
11052
  type: Div,
11016
- className: 'EditorSourceActionsList',
11053
+ className: EditorSourceActionsList,
11017
11054
  childCount: sourceActions.length,
11018
11055
  onClick: HandleClick
11019
11056
  }, ...sourceActions.flatMap(getSourceActionListItemVirtualDom)];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "",
5
5
  "main": "dist/editorWorkerMain.js",
6
6
  "type": "module",