@lvce-editor/editor-worker 19.34.0 → 19.35.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.
@@ -4545,6 +4545,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
4545
4545
  diagnosticsEnabled: false,
4546
4546
  differences: [],
4547
4547
  embeds: [],
4548
+ endOfLineDecorations: [],
4548
4549
  finalDeltaY: 0,
4549
4550
  finalY: 0,
4550
4551
  focus: 0,
@@ -4628,6 +4629,7 @@ const emptyEditor = {
4628
4629
  diagnostics: [],
4629
4630
  differences: [],
4630
4631
  embeds: [],
4632
+ endOfLineDecorations: [],
4631
4633
  focused: false,
4632
4634
  foldingRanges: [],
4633
4635
  hasListener: false,
@@ -4792,6 +4794,7 @@ const createEditor = async ({
4792
4794
  diagnostics: [],
4793
4795
  diagnosticsEnabled,
4794
4796
  differences: [],
4797
+ endOfLineDecorations: [],
4795
4798
  finalDeltaY: 0,
4796
4799
  finalY: 0,
4797
4800
  focused: false,
@@ -7890,6 +7893,43 @@ const getClickHandler = modifier => {
7890
7893
  }
7891
7894
  };
7892
7895
 
7896
+ const isProviderDecoration = value => {
7897
+ return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
7898
+ };
7899
+ const getProviderDecorations = (results, rowIndex) => {
7900
+ if (!Array.isArray(results)) {
7901
+ return [];
7902
+ }
7903
+ const decorations = [];
7904
+ for (const result of results) {
7905
+ if (!Array.isArray(result)) {
7906
+ continue;
7907
+ }
7908
+ for (const decoration of result) {
7909
+ if (isProviderDecoration(decoration) && typeof decoration.text === 'string') {
7910
+ decorations.push({
7911
+ rowIndex,
7912
+ text: decoration.text
7913
+ });
7914
+ }
7915
+ }
7916
+ }
7917
+ return decorations;
7918
+ };
7919
+ const getEditorLineDecorations = async (editor, rowIndex) => {
7920
+ const textDocument = {
7921
+ languageId: editor.languageId,
7922
+ text: getText$1(editor),
7923
+ uri: editor.uri
7924
+ };
7925
+ try {
7926
+ const results = await invoke$d('Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
7927
+ return getProviderDecorations(results, rowIndex);
7928
+ } catch {
7929
+ return [];
7930
+ }
7931
+ };
7932
+
7893
7933
  const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) => {
7894
7934
  object(editor);
7895
7935
  number(modifier);
@@ -7900,7 +7940,11 @@ const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) =>
7900
7940
  columnIndex,
7901
7941
  rowIndex
7902
7942
  });
7903
- return newEditor;
7943
+ const endOfLineDecorations = await getEditorLineDecorations(newEditor, rowIndex);
7944
+ return {
7945
+ ...newEditor,
7946
+ endOfLineDecorations
7947
+ };
7904
7948
  };
7905
7949
 
7906
7950
  const Editor = 3;
@@ -11617,6 +11661,7 @@ const CompletionDetailContent = 'CompletionDetailContent';
11617
11661
  const Diagnostic = 'Diagnostic';
11618
11662
  const EditorCursor = 'EditorCursor';
11619
11663
  const EditorHoverDiagnosticOnly = 'EditorHoverDiagnosticOnly';
11664
+ const EditorLineDecoration = 'EditorLineDecoration';
11620
11665
  const EditorRow = 'EditorRow';
11621
11666
  const EditorRowHighlighted = 'EditorRowHighlighted';
11622
11667
  const EditorSelection = 'EditorSelection';
@@ -13305,6 +13350,12 @@ ${editorSelector} .EditorRow {
13305
13350
  height: var(--EditorRowHeight);
13306
13351
  line-height: var(--EditorRowHeight);
13307
13352
  }
13353
+ ${editorSelector} .EditorLineDecoration {
13354
+ color: var(--EditorInlineBlameForeground, rgba(255, 255, 255, 0.5));
13355
+ font-style: italic;
13356
+ margin-left: 2em;
13357
+ user-select: none;
13358
+ }
13308
13359
  ${editorSelector} .R{background-color:#add6ff40}
13309
13360
  ${editorSelector} .ScrollBarThumbVertical {
13310
13361
  height: var(--ScrollBarHeight);
@@ -13723,17 +13774,24 @@ const getEditorDiagnosticsVirtualDom = diagnostics => {
13723
13774
  }, ...diagnosticsDom];
13724
13775
  };
13725
13776
 
13726
- const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
13777
+ const editorLineDecorationNode = {
13778
+ childCount: 1,
13779
+ className: EditorLineDecoration,
13780
+ type: Span
13781
+ };
13782
+ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
13727
13783
  const dom = [];
13728
13784
  for (let i = 0; i < textInfos.length; i++) {
13729
13785
  const textInfo = textInfos[i];
13730
13786
  const difference = differences[i];
13787
+ const rowIndex = visibleLineIndices[i] ?? i;
13788
+ const rowDecorations = endOfLineDecorations.filter(decoration => decoration.rowIndex === rowIndex);
13731
13789
  let className = EditorRow;
13732
13790
  if (i === highlightedLine) {
13733
13791
  className = mergeClassNames(className, EditorRowHighlighted);
13734
13792
  }
13735
13793
  dom.push({
13736
- childCount: textInfo.length / 2,
13794
+ childCount: textInfo.length / 2 + rowDecorations.length,
13737
13795
  className,
13738
13796
  translate: px(difference),
13739
13797
  type: Div
@@ -13747,12 +13805,15 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
13747
13805
  type: Span
13748
13806
  }, text(tokenText));
13749
13807
  }
13808
+ for (const decoration of rowDecorations) {
13809
+ dom.push(editorLineDecorationNode, text(decoration.text));
13810
+ }
13750
13811
  }
13751
13812
  return dom;
13752
13813
  };
13753
13814
 
13754
- const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
13755
- const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine);
13815
+ const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
13816
+ const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations);
13756
13817
  return [{
13757
13818
  childCount: textInfos.length,
13758
13819
  className: 'EditorRows',
@@ -14046,6 +14107,7 @@ const renderLines = {
14046
14107
  }
14047
14108
  const {
14048
14109
  differences,
14110
+ endOfLineDecorations,
14049
14111
  textInfos
14050
14112
  } = newState;
14051
14113
  newState.differences = differences;
@@ -14054,10 +14116,10 @@ const renderLines = {
14054
14116
  visibleLineIndices
14055
14117
  } = newState;
14056
14118
  const relativeLine = visibleLineIndices.indexOf(highlightedLine);
14057
- const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
14119
+ const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine, visibleLineIndices, endOfLineDecorations);
14058
14120
  return [/* method */'setText', dom];
14059
14121
  },
14060
- isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
14122
+ isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
14061
14123
  };
14062
14124
  const renderSelections = {
14063
14125
  apply: (oldState, newState) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.34.0",
3
+ "version": "19.35.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"