mirror of
https://github.com/convergencelabs/monaco-collab-ext.git
synced 2024-10-27 20:34:17 +00:00
Add showTooltipOnHover option
This commit is contained in:
parent
a3b0b8a57c
commit
38713d59b9
@ -24,7 +24,7 @@ export interface IRemoteCursorManagerOptions {
|
||||
editor: monaco.editor.ICodeEditor;
|
||||
|
||||
/**
|
||||
* Determines if tooltips will be shown when the cursor is moved.
|
||||
* Determines if tooltips will be shown when the cursor is moved or hovered.
|
||||
*/
|
||||
tooltips?: boolean;
|
||||
|
||||
@ -33,6 +33,11 @@ export interface IRemoteCursorManagerOptions {
|
||||
* it was last moved.
|
||||
*/
|
||||
tooltipDuration?: number;
|
||||
|
||||
/**
|
||||
* Show the tooltip when the cursor is hovered
|
||||
*/
|
||||
showTooltipOnHover?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,6 +125,7 @@ export class RemoteCursorManager {
|
||||
label,
|
||||
this._options.tooltips,
|
||||
tooltipDurationMs,
|
||||
this._options.showTooltipOnHover,
|
||||
() => this.removeCursor(id));
|
||||
this._cursorWidgets.set(id, cursorWidget);
|
||||
|
||||
|
@ -55,6 +55,7 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
|
||||
label: string,
|
||||
tooltipEnabled: boolean,
|
||||
tooltipDuration: number,
|
||||
showTooltipOnHover: boolean,
|
||||
onDisposed: OnDisposed) {
|
||||
this._editor = codeEditor;
|
||||
this._tooltipDuration = tooltipDuration;
|
||||
@ -81,6 +82,16 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
|
||||
this._scrollListener = this._editor.onDidScrollChange(() => {
|
||||
this._updateTooltipPosition();
|
||||
});
|
||||
|
||||
if (showTooltipOnHover) {
|
||||
this._domNode.style.pointerEvents = 'auto';
|
||||
this._domNode.addEventListener('mouseover', () => {
|
||||
this._setTooltipVisible(true);
|
||||
})
|
||||
this._domNode.addEventListener('mouseout', () => {
|
||||
this._setTooltipVisible(false);
|
||||
})
|
||||
}
|
||||
} else {
|
||||
this._tooltipNode = null;
|
||||
this._scrollListener = null;
|
||||
|
Loading…
Reference in New Issue
Block a user