@lvce-editor/hover-worker 2.18.0 → 2.18.2

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.
@@ -1470,11 +1470,12 @@ const Text = 12;
1470
1470
  const EditorWorker = 99;
1471
1471
  const ExtensionHostWorker = 44;
1472
1472
  const ExtensionManagementWorker = 9006;
1473
+ const RendererWorker = 1;
1473
1474
 
1474
1475
  const SetFocusContext = 'Viewlet.setFocusContext';
1475
1476
 
1476
1477
  const {
1477
- invoke: invoke$2,
1478
+ invoke: invoke$4,
1478
1479
  invokeAndTransfer,
1479
1480
  set: set$5
1480
1481
  } = create$1(EditorWorker);
@@ -1482,18 +1483,18 @@ const sendMessagePortToExtensionManagementWorker$1 = async port => {
1482
1483
  await invokeAndTransfer('SendMessagePortToExtensionManagementWorker.sendMessagePortToExtensionManagementWorker', port, 0);
1483
1484
  };
1484
1485
  const getLines$1 = async editorUid => {
1485
- const lines = await invoke$2('Editor.getLines2', editorUid);
1486
+ const lines = await invoke$4('Editor.getLines2', editorUid);
1486
1487
  return lines;
1487
1488
  };
1488
1489
  const getWordAtOffset2$1 = async editorUid => {
1489
- return invoke$2('Editor.getWordAtOffset2', editorUid);
1490
+ return invoke$4('Editor.getWordAtOffset2', editorUid);
1490
1491
  };
1491
1492
  const getWordBefore$1 = async (editorUid, rowIndex, columnIndex) => {
1492
- return invoke$2('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
1493
+ return invoke$4('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
1493
1494
  };
1494
1495
  const getUri$1 = async editorUid => {
1495
1496
  // @ts-ignore
1496
- return invoke$2('Editor.getUri', editorUid);
1497
+ return invoke$4('Editor.getUri', editorUid);
1497
1498
  };
1498
1499
 
1499
1500
  const {
@@ -1501,15 +1502,18 @@ const {
1501
1502
  } = create$1(ExtensionHostWorker);
1502
1503
 
1503
1504
  const {
1504
- invoke: invoke$1,
1505
+ invoke: invoke$3,
1505
1506
  set: set$3
1506
1507
  } = create$1(ExtensionManagementWorker);
1507
1508
 
1509
+ const {
1510
+ invoke: invoke$2} = create$1(RendererWorker);
1511
+
1508
1512
  const getLines = (...args) => getLines$1(...args);
1509
1513
  const getUri = (...args) => getUri$1(...args);
1510
1514
  const getWordAtOffset2 = (...args) => getWordAtOffset2$1(...args);
1511
1515
  const getWordBefore = (...args) => getWordBefore$1(...args);
1512
- const invoke = (...args) => invoke$2(...args);
1516
+ const invoke$1 = (...args) => invoke$4(...args);
1513
1517
  const sendMessagePortToExtensionManagementWorker = (...args) => sendMessagePortToExtensionManagementWorker$1(...args);
1514
1518
  const set$2 = (...args) => set$5(...args);
1515
1519
 
@@ -1523,7 +1527,7 @@ const close = async state => {
1523
1527
  editorUid
1524
1528
  } = state;
1525
1529
  // @ts-ignore
1526
- await invoke('Editor.closeWidget2', editorUid, Hover, 'Hovers', FocusEditorHovers);
1530
+ await invoke$1('Editor.closeWidget2', editorUid, Hover, 'Hovers', FocusEditorHovers);
1527
1531
  return state;
1528
1532
  };
1529
1533
 
@@ -1537,6 +1541,7 @@ const {
1537
1541
  const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
1538
1542
  const state = {
1539
1543
  documentation: '',
1544
+ documentationVirtualDom: [],
1540
1545
  editorLanguageId,
1541
1546
  editorUid,
1542
1547
  fallbackDisplayStringLanguageId: 'typescript',
@@ -1577,7 +1582,7 @@ const isEqual$2 = (oldState, newState) => {
1577
1582
  };
1578
1583
 
1579
1584
  const isEqual$1 = (oldState, newState) => {
1580
- return oldState.leadingWord === newState.leadingWord && oldState.x === newState.x && oldState.y === newState.y;
1585
+ return oldState.documentation === newState.documentation && oldState.leadingWord === newState.leadingWord && oldState.x === newState.x && oldState.y === newState.y;
1581
1586
  };
1582
1587
 
1583
1588
  const isEqual = (oldState, newState) => {
@@ -1777,7 +1782,7 @@ const getOffsetAtCursor = editorUid => {
1777
1782
  };
1778
1783
 
1779
1784
  const getPositionAtCursor = async editorUid => {
1780
- const position = await invoke('Editor.getPositionAtCursor', editorUid);
1785
+ const position = await invoke$1('Editor.getPositionAtCursor', editorUid);
1781
1786
  return position;
1782
1787
  };
1783
1788
 
@@ -1792,7 +1797,7 @@ const getTextDocument = async (editorUid, languageId) => {
1792
1797
  };
1793
1798
  const executeHoverProvider = async (editorUid, editorLanguageId, offset) => {
1794
1799
  const textDocument = await getTextDocument(editorUid, editorLanguageId);
1795
- return invoke$1('Extensions.executeHoverProvider', textDocument, offset);
1800
+ return invoke$3('Extensions.executeHoverProvider', textDocument, offset);
1796
1801
  };
1797
1802
 
1798
1803
  const getHover = async (editorUid, editorLanguageId, offset) => {
@@ -1830,7 +1835,7 @@ const getEditorHoverInfo = async (editorUid, editorLanguageId, hoverFullWidth, h
1830
1835
  const offset = getOffsetAtCursor();
1831
1836
 
1832
1837
  // @ts-ignore
1833
- const diagnostics = await invoke('Editor.getDiagnostics', editorUid);
1838
+ const diagnostics = await invoke$1('Editor.getDiagnostics', editorUid);
1834
1839
  const wordPart = await getWordBefore(editorUid, rowIndex, columnIndex);
1835
1840
  const wordStart = columnIndex - wordPart.length;
1836
1841
 
@@ -1876,6 +1881,8 @@ const getEditorHoverInfo = async (editorUid, editorLanguageId, hoverFullWidth, h
1876
1881
 
1877
1882
  const getWordAtOffset = getWordAtOffset2;
1878
1883
 
1884
+ const invoke = (...args) => invoke$2(...args);
1885
+
1879
1886
  const loadContent = async state => {
1880
1887
  const {
1881
1888
  editorLanguageId,
@@ -1897,9 +1904,11 @@ const loadContent = async state => {
1897
1904
  if (!documentation && lineInfos.length === 0 && matchingDiagnostics.length === 0) {
1898
1905
  return close(state);
1899
1906
  }
1907
+ const documentationVirtualDom = documentation ? await invoke('Markdown.getVirtualDomFromMarkdown', documentation) : [];
1900
1908
  return {
1901
1909
  ...state,
1902
1910
  documentation,
1911
+ documentationVirtualDom,
1903
1912
  leadingWord: wordAtOffset,
1904
1913
  lineInfos,
1905
1914
  matchingDiagnostics,
@@ -2007,6 +2016,7 @@ const getLineInfosVirtualDom = lineInfos => {
2007
2016
 
2008
2017
  const hoverClassName = mergeClassNames(Viewlet, EditorHover);
2009
2018
  const problemClassName = mergeClassNames(HoverDisplayString, HoverProblem);
2019
+ const hoverDocumentationClassName = mergeClassNames(HoverDocumentation, 'Markdown');
2010
2020
  const hoverProblemMessage = {
2011
2021
  childCount: 1,
2012
2022
  className: HoverProblemMessage,
@@ -2017,30 +2027,36 @@ const hoverProblemDetail = {
2017
2027
  className: HoverProblemDetail,
2018
2028
  type: Span
2019
2029
  };
2020
- const hoverDocumentation = {
2021
- childCount: 1,
2022
- className: HoverDocumentation,
2023
- type: Div
2024
- };
2025
2030
  const sash = {
2026
2031
  childCount: 0,
2027
2032
  className: mergeClassNames('Sash', 'SashVertical', 'SashResize'),
2028
2033
  onPointerDown: HandleSashPointerDown,
2029
2034
  type: Div
2030
2035
  };
2031
- const getChildCount = (lineInfos, documentation, diagnostics) => {
2036
+ const getChildCount = (lineInfos, documentationVirtualDom, diagnostics) => {
2032
2037
  const diagnosticsCount = diagnostics && diagnostics.length > 0 ? 1 : 0;
2033
2038
  const lineInfosCount = lineInfos.length > 0 ? 1 : 0;
2034
- const documentationCount = documentation ? 1 : 0;
2039
+ const documentationCount = documentationVirtualDom.length > 0 ? 1 : 0;
2035
2040
  return lineInfosCount + documentationCount + diagnosticsCount;
2036
2041
  };
2037
- const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
2038
- if (lineInfos.length === 0 && !documentation && diagnostics.length === 0) {
2042
+ const getDocumentationChildCount = documentationVirtualDom => {
2043
+ let stack = [];
2044
+ for (let i = documentationVirtualDom.length - 1; i >= 0; i--) {
2045
+ const node = documentationVirtualDom[i];
2046
+ if (node.childCount > 0) {
2047
+ stack = stack.slice(node.childCount);
2048
+ }
2049
+ stack.unshift(node);
2050
+ }
2051
+ return stack.length;
2052
+ };
2053
+ const getHoverVirtualDom = (lineInfos, documentationVirtualDom, diagnostics) => {
2054
+ if (lineInfos.length === 0 && documentationVirtualDom.length === 0 && diagnostics.length === 0) {
2039
2055
  return [];
2040
2056
  }
2041
2057
  const dom = [];
2042
2058
  dom.push({
2043
- childCount: getChildCount(lineInfos, documentation, diagnostics) + 1,
2059
+ childCount: getChildCount(lineInfos, documentationVirtualDom, diagnostics) + 1,
2044
2060
  className: hoverClassName,
2045
2061
  type: Div
2046
2062
  });
@@ -2062,8 +2078,12 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
2062
2078
  type: Div
2063
2079
  }, ...lineInfosDom);
2064
2080
  }
2065
- if (documentation) {
2066
- dom.push(hoverDocumentation, text(documentation));
2081
+ if (documentationVirtualDom.length > 0) {
2082
+ dom.push({
2083
+ childCount: getDocumentationChildCount(documentationVirtualDom),
2084
+ className: hoverDocumentationClassName,
2085
+ type: Div
2086
+ }, ...documentationVirtualDom);
2067
2087
  }
2068
2088
  dom.push(sash);
2069
2089
  return dom;
@@ -2071,12 +2091,12 @@ const getHoverVirtualDom = (lineInfos, documentation, diagnostics) => {
2071
2091
 
2072
2092
  const renderItems = (oldState, newState) => {
2073
2093
  const {
2074
- documentation,
2094
+ documentationVirtualDom,
2075
2095
  lineInfos,
2076
2096
  matchingDiagnostics,
2077
2097
  uid
2078
2098
  } = newState;
2079
- const dom = getHoverVirtualDom(lineInfos, documentation, matchingDiagnostics);
2099
+ const dom = getHoverVirtualDom(lineInfos, documentationVirtualDom, matchingDiagnostics);
2080
2100
  return [/* method */'Viewlet.setDom2', uid, dom];
2081
2101
  };
2082
2102
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/hover-worker",
3
- "version": "2.18.0",
3
+ "version": "2.18.2",
4
4
  "description": "Web Worker for the find widget in Lvce Editor",
5
5
  "repository": {
6
6
  "type": "git",