@lvce-editor/editor-worker 19.30.7 → 19.30.9

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.
@@ -7708,8 +7708,7 @@ const getHover = async (editor, offset) => {
7708
7708
 
7709
7709
  const measureTextBlockHeight = async (text, fontFamily, fontSize, lineHeight, width) => {
7710
7710
  // @ts-ignore
7711
- // return RendererProcess.invoke('MeasureTextBlockHeight.measureTextBlockHeight', text, fontSize, fontFamily, lineHeight, width)
7712
- return 100;
7711
+ return invoke$a('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, lineHeight, width);
7713
7712
  };
7714
7713
 
7715
7714
  const getLineInfo = (line, tokens, TokenMap) => {
@@ -7790,7 +7789,12 @@ const getMatchingDiagnostics = (diagnostics, rowIndex, columnIndex) => {
7790
7789
  return matching;
7791
7790
  };
7792
7791
  const fallbackDisplayStringLanguageId = 'typescript'; // TODO remove this
7792
+
7793
+ const hoverDocumentationFontSize = 15;
7794
+ const hoverDocumentationFontFamily = 'Fira Code';
7795
+ const hoverDocumentationLineHeight = '1.33333';
7793
7796
  const hoverWidth = 600;
7797
+ const hoverDocumentationWidth = hoverWidth - 18;
7794
7798
  const getEditorHoverInfo = async (editorUid, position) => {
7795
7799
  number(editorUid);
7796
7800
  const instance = get$8(editorUid);
@@ -7824,8 +7828,13 @@ const getEditorHoverInfo = async (editorUid, position) => {
7824
7828
  const lineInfos = displayString ? await tokenizeCodeBlock(displayString, displayStringLanguageId || fallbackDisplayStringLanguageId, tokenizerPath) : [];
7825
7829
  const wordPart = getWordBefore(editor, rowIndex, columnIndex);
7826
7830
  const wordStart = columnIndex - wordPart.length;
7827
- const documentationHeight = await measureTextBlockHeight();
7828
- const height = Math.min((matchingDiagnostics.length > 0 ? 30 : 0) + (lineInfos.length > 0 ? lineInfos.length * editor.rowHeight + 12 : 0) + (documentation ? documentationHeight + 11 : 0) || 20, editor.height);
7831
+ const documentationHeight = documentation ? await measureTextBlockHeight(documentation, hoverDocumentationFontFamily, hoverDocumentationFontSize, hoverDocumentationLineHeight, hoverDocumentationWidth) : 0;
7832
+ let diagnosticText = '';
7833
+ for (const diagnostic of matchingDiagnostics) {
7834
+ diagnosticText += `${diagnosticText ? '\n' : ''}${diagnostic.message} ${diagnostic.source} (${diagnostic.code})`;
7835
+ }
7836
+ const diagnosticsHeight = diagnosticText ? (await measureTextBlockHeight(diagnosticText, editor.fontFamily, editor.fontSize, `${editor.rowHeight}px`, hoverDocumentationWidth)) + 10 : 0;
7837
+ const height = Math.min(diagnosticsHeight + (lineInfos.length > 0 ? lineInfos.length * editor.rowHeight + 12 : 0) + (documentation ? documentationHeight + 11 : 0) || 20, editor.height);
7829
7838
  const x$1 = Math.max(editor.x, Math.min(x(editor, rowIndex, wordStart), editor.x + editor.width - hoverWidth));
7830
7839
  const rowBottom = y(editor, rowIndex);
7831
7840
  const y$1 = rowBottom + height <= editor.y + editor.height ? rowBottom : Math.max(editor.y, rowBottom - editor.rowHeight - height);
@@ -10101,6 +10110,13 @@ const getSignatureHelp = async (editor, offset) => {
10101
10110
  return executeSignatureHelpProvider(editor, offset);
10102
10111
  };
10103
10112
 
10113
+ const documentationFontSize = 15;
10114
+ const documentationFontFamily = 'Fira Code';
10115
+ const documentationLineHeight = '1.33333';
10116
+ const borderLeft = 1;
10117
+ const borderRight = 1;
10118
+ const paddingLeft = 8;
10119
+ const paddingRight = 8;
10104
10120
  const getSignatureHelpInfo = async editorUid => {
10105
10121
  number(editorUid);
10106
10122
  const instance = get$8(editorUid);
@@ -10124,7 +10140,9 @@ const getSignatureHelpInfo = async editorUid => {
10124
10140
  documentation
10125
10141
  } = content;
10126
10142
  const lineInfos = await tokenizeCodeBlock(displayString, editor.languageId || 'typescript', '');
10127
- const documentationHeight = await measureTextBlockHeight();
10143
+ const fullWidth = Math.min(600, editor.width);
10144
+ const documentationWidth = fullWidth - paddingLeft - paddingRight - borderLeft - borderRight;
10145
+ const documentationHeight = await measureTextBlockHeight(documentation, documentationFontFamily, documentationFontSize, documentationLineHeight, documentationWidth);
10128
10146
  const bounds = getSignatureHelpWidgetBounds(editor, rowIndex, columnIndex, lineInfos.length, documentationHeight, Boolean(documentation));
10129
10147
  return {
10130
10148
  ...bounds,
@@ -11154,6 +11172,7 @@ const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
11154
11172
  const CompletionDetailContent = 'CompletionDetailContent';
11155
11173
  const Diagnostic = 'Diagnostic';
11156
11174
  const EditorCursor = 'EditorCursor';
11175
+ const EditorHoverDiagnosticOnly = 'EditorHoverDiagnosticOnly';
11157
11176
  const EditorRow = 'EditorRow';
11158
11177
  const EditorRowHighlighted = 'EditorRowHighlighted';
11159
11178
  const EditorSelection = 'EditorSelection';
@@ -11272,11 +11291,15 @@ const getChildCount = (lineInfos, documentation, diagnostics) => {
11272
11291
  const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
11273
11292
  return lineInfos.length + documentationCount + diagnosticsCount;
11274
11293
  };
11294
+ const getEditorHoverClassName = (lineInfos, documentation, diagnostics) => {
11295
+ const isDiagnosticOnly = diagnostics?.length === 1 && lineInfos.length === 0 && !documentation;
11296
+ return mergeClassNames('Viewlet', 'EditorHover', isDiagnosticOnly ? EditorHoverDiagnosticOnly : '');
11297
+ };
11275
11298
  const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
11276
11299
  const dom = [];
11277
11300
  dom.push({
11278
11301
  childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
11279
- className: mergeClassNames('Viewlet', 'EditorHover'),
11302
+ className: getEditorHoverClassName(lineInfos, documentation, diagnostics),
11280
11303
  type: Div
11281
11304
  });
11282
11305
  if (diagnostics && diagnostics.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.30.7",
3
+ "version": "19.30.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"