Compare commits

..

No commits in common. "master" and "0.3.0" have entirely different histories.

5 changed files with 1642 additions and 2191 deletions

View File

@ -1,11 +1,7 @@
# Change Log
## [v0.3.1](https://github.com/convergencelabs/monaco-collab-ext/tree/0.3.1) (2020-11-08)
- Add support for Monaco >= 0.21
## [v0.3.0](https://github.com/convergencelabs/monaco-collab-ext/tree/0.3.0) (2020-03-06)
- Add support for Monaco >= 0.19.0. [#3](https://github.com/convergencelabs/monaco-collab-ext/issues/3)
- Add support for Monaco >= 19.0. [#3](https://github.com/convergencelabs/monaco-collab-ext/issues/3)
## [v0.2.0](https://github.com/convergencelabs/monaco-collab-ext/tree/0.2.0) (2020-01-08)

3742
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@convergencelabs/monaco-collab-ext",
"version": "0.3.2",
"version": "0.3.0",
"title": "Monaco Editor Collaborative Extensions",
"description": "Collaborative Extensions for the Monaco Editor",
"keywords": [
@ -30,23 +30,23 @@
"access": "public"
},
"dependencies": {
"monaco-editor": ">=0.15.6"
"monaco-editor": ">=0.15.6 <=0.20.x"
},
"devDependencies": {
"@babel/cli": "7.13.14",
"@babel/core": "7.13.15",
"@babel/node": "7.13.13",
"@babel/preset-env": "7.13.15",
"@babel/preset-stage-3": "7.8.3",
"@babel/preset-typescript": "7.13.0",
"@babel/register": "7.13.14",
"babel-plugin-module-resolver": "4.1.0",
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/node": "7.2.2",
"@babel/preset-env": "7.2.3",
"@babel/preset-stage-3": "7.0.0",
"@babel/preset-typescript": "7.1.0",
"@babel/register": "7.0.0",
"babel-plugin-module-resolver": "3.1.1",
"babel-plugin-transform-class-properties": "6.24.1",
"del": "6.0.0",
"gulp": "4.0.2",
"del": "3.0.0",
"gulp": "4.0.0",
"gulp-babel": "8.0.0",
"gulp-bump": "3.2.0",
"gulp-clean-css": "4.3.0",
"gulp-bump": "3.1.1",
"gulp-clean-css": "4.0.0",
"gulp-filter-each": "1.0.1",
"gulp-header": "2.0.7",
"gulp-insert": "0.5.0",

View File

@ -23,11 +23,6 @@ export interface IRemoteCursorManagerOptions {
*/
editor: monaco.editor.ICodeEditor;
/**
* An additional class name for the cursor element, to tweak the default style
*/
className?: string;
/**
* Determines if tooltips will be shown when the cursor is moved.
*/
@ -38,16 +33,6 @@ export interface IRemoteCursorManagerOptions {
* it was last moved.
*/
tooltipDuration?: number;
/**
* Show the tooltip when the cursor is hovered
*/
showTooltipOnHover?: boolean;
/**
* An additional class name for the tooltip element, to tweak the default style
*/
tooltipClassName?: string;
}
/**
@ -62,7 +47,7 @@ export class RemoteCursorManager {
* The default values for optional parameters.
* @internal
*/
private static readonly DEFAULT_OPTIONS: Partial<IRemoteCursorManagerOptions> = {tooltips: true, tooltipDuration: 1, showTooltipOnHover: false};
private static readonly DEFAULT_OPTIONS = {tooltips: true, tooltipDuration: 1};
/**
* A counter that generates unique ids for the cursor widgets.
@ -131,13 +116,10 @@ export class RemoteCursorManager {
const cursorWidget = new RemoteCursorWidget(
this._options.editor,
widgetId,
this._options.className,
color,
label,
this._options.tooltips,
tooltipDurationMs,
this._options.showTooltipOnHover,
this._options.tooltipClassName,
() => this.removeCursor(id));
this._cursorWidgets.set(id, cursorWidget);

View File

@ -51,13 +51,10 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
constructor(codeEditor: editor.ICodeEditor,
widgetId: string,
className: string | undefined,
color: string,
label: string,
tooltipEnabled: boolean,
tooltipDuration: number,
showTooltipOnHover: boolean,
tooltipClassName: string | undefined,
onDisposed: OnDisposed) {
this._editor = codeEditor;
this._tooltipDuration = tooltipDuration;
@ -67,16 +64,16 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
// Create the main node for the cursor element.
const {lineHeight} = getConfiguration(this._editor);
this._domNode = document.createElement("div");
this._domNode.className = classNames('monaco-remote-cursor', className)
this._domNode.className = "monaco-remote-cursor";
this._domNode.style.background = color;
this._domNode.style.height = `${lineHeight}px`;
// Create the tooltip element if the tooltip is enabled.
if (tooltipEnabled) {
this._tooltipNode = document.createElement("div");
this._tooltipNode.className = classNames('monaco-remote-cursor-tooltip', tooltipClassName)
this._tooltipNode.className = "monaco-remote-cursor-tooltip";
this._tooltipNode.style.background = color;
this._tooltipNode.innerText = label;
this._tooltipNode.innerHTML = label;
this._domNode.appendChild(this._tooltipNode);
// we only need to listen to scroll positions to update the
@ -84,16 +81,6 @@ 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;
@ -184,10 +171,17 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
}
private _showTooltip(): void {
this._setTooltipVisible(true);
this._updateTooltipPosition();
if (this._hideTimer !== null) {
clearTimeout(this._hideTimer);
} else {
this._setTooltipVisible(true);
}
this._hideTimer = setTimeout(() => {
this._setTooltipVisible(false);
this._hideTimer = null;
}, this._tooltipDuration);
}
@ -203,12 +197,7 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
}
private _setTooltipVisible(visible: boolean): void {
if (this._hideTimer !== null) {
clearTimeout(this._hideTimer);
this._hideTimer = null;
}
if (visible) {
this._updateTooltipPosition();
this._tooltipNode.style.opacity = "1.0";
} else {
this._tooltipNode.style.opacity = "0";
@ -254,7 +243,3 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable {
}
}
}
function classNames(...names: (string|undefined|null)[]) {
return names.filter(className => className != null && className.length > 0).join(' ')
}