diff --git a/packages/collaboration-extension/src/collaboration.ts b/packages/collaboration-extension/src/collaboration.ts index 9ee439e0..ce750985 100644 --- a/packages/collaboration-extension/src/collaboration.ts +++ b/packages/collaboration-extension/src/collaboration.ts @@ -41,17 +41,16 @@ import { ITranslator, nullTranslator, TranslationBundle } from '@jupyterlab/tran import { Menu, MenuBar } from '@lumino/widgets'; -import { IAwareness, ISharedNotebook, ISuggestions, NotebookChange } from '@jupyter/ydoc'; +import { IAwareness, ISharedNotebook, NotebookChange } from '@jupyter/ydoc'; import { CollaboratorsPanel, - SuggestionsPanel, IGlobalAwareness, IUserMenu, remoteUserCursors, RendererUserMenu, UserInfoPanel, - UserMenu, + UserMenu } from '@jupyter/collaboration'; import * as Y from 'yjs'; @@ -148,12 +147,11 @@ export const rtcPanelPlugin: JupyterFrontEndPlugin = { id: '@jupyter/collaboration-extension:rtcPanel', description: 'Add side panel to display all currently connected users.', autoStart: true, - requires: [IGlobalAwareness, ISuggestions], + requires: [IGlobalAwareness], optional: [ITranslator], activate: ( app: JupyterFrontEnd, awareness: Awareness, - suggestions: ISuggestions, translator: ITranslator | null ): void => { const { user } = app.serviceManager; @@ -185,10 +183,6 @@ export const rtcPanelPlugin: JupyterFrontEndPlugin = { ); collaboratorsPanel.title.label = trans.__('Online Collaborators'); userPanel.addWidget(collaboratorsPanel); - - const suggestionsPanel = new SuggestionsPanel(fileopener, suggestions); - suggestionsPanel.title.label = trans.__('Suggestions'); - userPanel.addWidget(suggestionsPanel); } }; @@ -306,8 +300,6 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension { - console.log('currentRoomId', context.model.sharedModel.currentRoomId); - console.log('rootRoomId', context.model.sharedModel.rootRoomId); requestDocMerge(context.model.sharedModel.currentRoomId, context.model.sharedModel.rootRoomId); } }); @@ -396,42 +388,3 @@ export class EditingModeExtension implements DocumentRegistry.IWidgetExtension = { - id: '@jupyter/collaboration-extension:rtcGlobalSuggestions', - description: 'A plugin to provide shared document suggestions.', - autoStart: true, - provides: ISuggestions, - activate: (app: JupyterFrontEnd): ISuggestions => { - console.log('suggestions plugin activated'); - return new Suggestions(); - }, -}; - -export class Suggestions implements ISuggestions { - private _forkIds: string[]; - private _callbacks: any[]; - - constructor() { - this._forkIds = []; - this._callbacks = []; - } - - addFork(forkId: string) { - this._forkIds.push(forkId); - for (const callback of this._callbacks) { - callback(forkId); - } - } - - addCallback(callback: any) { - this._callbacks.push(callback); - } - - get forks(): string[] { - return this._forkIds; - } -} diff --git a/packages/collaboration-extension/src/filebrowser.ts b/packages/collaboration-extension/src/filebrowser.ts index a3ecb15f..75348215 100644 --- a/packages/collaboration-extension/src/filebrowser.ts +++ b/packages/collaboration-extension/src/filebrowser.ts @@ -24,7 +24,7 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation'; import { CommandRegistry } from '@lumino/commands'; -import { ISuggestions, YFile, YNotebook } from '@jupyter/ydoc'; +import { YFile, YNotebook } from '@jupyter/ydoc'; import { ICollaborativeDrive, YDrive } from '@jupyter/docprovider'; @@ -42,15 +42,14 @@ export const drive: JupyterFrontEndPlugin = { id: '@jupyter/collaboration-extension:drive', description: 'The default collaborative drive provider', provides: ICollaborativeDrive, - requires: [ITranslator, ISuggestions], + requires: [ITranslator], optional: [], activate: ( app: JupyterFrontEnd, - translator: ITranslator, - suggestions: ISuggestions + translator: ITranslator ): ICollaborativeDrive => { const trans = translator.load('jupyter_collaboration'); - const drive = new YDrive(app.serviceManager.user, trans, suggestions); + const drive = new YDrive(app.serviceManager.user, trans); app.serviceManager.contents.addDrive(drive); return drive; } diff --git a/packages/collaboration-extension/src/index.ts b/packages/collaboration-extension/src/index.ts index e268aaf9..3e1be19b 100644 --- a/packages/collaboration-extension/src/index.ts +++ b/packages/collaboration-extension/src/index.ts @@ -20,8 +20,7 @@ import { rtcGlobalAwarenessPlugin, rtcPanelPlugin, userEditorCursors, - editingMode, - suggestions + editingMode } from './collaboration'; import { sharedLink } from './sharedlink'; @@ -40,8 +39,7 @@ const plugins: JupyterFrontEndPlugin[] = [ rtcPanelPlugin, sharedLink, userEditorCursors, - editingMode, - suggestions + editingMode ]; export default plugins; diff --git a/packages/collaboration/src/index.ts b/packages/collaboration/src/index.ts index ef38378c..05e4fff7 100644 --- a/packages/collaboration/src/index.ts +++ b/packages/collaboration/src/index.ts @@ -7,8 +7,6 @@ export * from './tokens'; export * from './collaboratorspanel'; -export * from './suggestionspanel'; -//export * from './suggestions'; export * from './cursors'; export * from './menu'; export * from './sharedlink'; diff --git a/packages/collaboration/src/suggestionspanel.tsx b/packages/collaboration/src/suggestionspanel.tsx deleted file mode 100644 index ed12289a..00000000 --- a/packages/collaboration/src/suggestionspanel.tsx +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (c) Jupyter Development Team. -// Distributed under the terms of the Modified BSD License. - -import * as React from 'react'; - -import { Panel } from '@lumino/widgets'; - -import { ReactWidget } from '@jupyterlab/apputils'; - -//import { PathExt } from '@jupyterlab/coreutils'; - -import { ISuggestions } from '@jupyter/ydoc'; - -//import { ICollaboratorAwareness } from './tokens'; - -export class SuggestionsPanel extends Panel { - private _body: SuggestionsBody; - - constructor(fileopener: (path: string) => void, suggestions: ISuggestions) { - super({}); - - this._body = new SuggestionsBody(fileopener, suggestions); - this.addWidget(this._body); - this.update(); - } -} - -/** - * The suggestions list. - */ -export class SuggestionsBody extends ReactWidget { - private _suggestions: ISuggestions; - //private _fileopener: (path: string) => void; - - constructor(fileopener: (path: string) => void, suggestions: ISuggestions) { - super(); - //this._fileopener = fileopener; - suggestions.addCallback((forkId: string) => { this.update(); }); - this._suggestions = suggestions; - } - - render(): React.ReactElement[] { - return this._suggestions.forks.map((value, i) => { - // let canOpenCurrent = false; - // let current = ''; - // let separator = ''; - // let currentFileLocation = ''; - - // if (value.current) { - // canOpenCurrent = true; - // const path = value.current.split(':'); - // currentFileLocation = `${path[1]}:${path[2]}`; - - // current = PathExt.basename(path[2]); - // current = - // current.length > 25 ? current.slice(0, 12).concat('…') : current; - // separator = '•'; - // } - - // const onClick = () => { - // if (canOpenCurrent) { - // this._fileopener(currentFileLocation); - // } - // }; - - // const displayName = `${value.user.display_name} ${separator} ${current}`; - - // return ( - //
- //
- // {value.user.initials} - //
- // {displayName} - //
- // ); - return ( -
-
- {value} -
-
- ); - }); - } -} diff --git a/packages/collaboration/src/tokens.ts b/packages/collaboration/src/tokens.ts index 42cbbec3..5f717390 100644 --- a/packages/collaboration/src/tokens.ts +++ b/packages/collaboration/src/tokens.ts @@ -24,13 +24,6 @@ export const IGlobalAwareness = new Token( '@jupyter/collaboration:IGlobalAwareness' ); -///** -// * The global suggestions token. -// */ -//export const IGlobalSuggestions = new Token( -// '@jupyter/collaboration:IGlobalSuggestions' -//); -// /** * An interface describing the user menu. */ diff --git a/packages/docprovider/src/ydrive.ts b/packages/docprovider/src/ydrive.ts index c31f05d8..aab5b43c 100644 --- a/packages/docprovider/src/ydrive.ts +++ b/packages/docprovider/src/ydrive.ts @@ -5,7 +5,7 @@ import { PageConfig, URLExt } from '@jupyterlab/coreutils'; import { TranslationBundle } from '@jupyterlab/translation'; import { Contents, Drive, User } from '@jupyterlab/services'; -import { DocumentChange, ISharedDocument, YDocument, ISuggestions } from '@jupyter/ydoc'; +import { DocumentChange, ISharedDocument, YDocument } from '@jupyter/ydoc'; import { WebSocketProvider } from './yprovider'; import { @@ -14,8 +14,6 @@ import { SharedDocumentFactory } from './tokens'; -import * as Y from 'yjs'; - const DISABLE_RTC = PageConfig.getOption('disableRTC') === 'true' ? true : false; @@ -34,12 +32,11 @@ export class YDrive extends Drive implements ICollaborativeDrive { * * @param user - The user manager to add the identity to the awareness of documents. */ - constructor(user: User.IManager, translator: TranslationBundle, suggestions: ISuggestions) { + constructor(user: User.IManager, translator: TranslationBundle) { super({ name: 'RTC' }); this._user = user; this._trans = translator; this._providers = new Map(); - this._suggestions = suggestions; this.sharedModelFactory = new SharedModelFactory(this._onCreate); } @@ -129,18 +126,6 @@ export class YDrive extends Drive implements ICollaborativeDrive { return super.save(localPath, options); } - private _handleForks = (event: Y.YMapEvent) => { - const forkPrefix = 'fork_'; - event.changes.keys.forEach((change, key) => { - if (change.action === 'add') { - if (key.startsWith(forkPrefix)) { - const forkId = key.slice(forkPrefix.length); - this._suggestions.addFork(forkId); - } - } - }); - }; - private _onCreate = ( options: Contents.ISharedFactoryOptions, sharedModel: YDocument @@ -162,7 +147,6 @@ export class YDrive extends Drive implements ICollaborativeDrive { const key = `${options.format}:${options.contentType}:${options.path}`; this._providers.set(key, provider); - sharedModel.ystate.observe(this._handleForks); sharedModel.provider = provider; sharedModel.disposed.connect(() => { const provider = this._providers.get(key); @@ -183,7 +167,6 @@ export class YDrive extends Drive implements ICollaborativeDrive { private _user: User.IManager; private _trans: TranslationBundle; private _providers: Map; - private _suggestions: ISuggestions; } /** diff --git a/yarn.lock b/yarn.lock index 68a69e8b..36c6893a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2156,7 +2156,7 @@ __metadata: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc::locator=%40jupyter%2Freal-time-collaboration%40workspace%3A.": version: 2.0.1 - resolution: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc#.yalc/@jupyter/ydoc::hash=7b1261&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A." + resolution: "@jupyter/ydoc@file:.yalc/@jupyter/ydoc#.yalc/@jupyter/ydoc::hash=63b59a&locator=%40jupyter%2Freal-time-collaboration%40workspace%3A." dependencies: "@jupyterlab/application": ^4.0.0 "@jupyterlab/nbformat": ^3.0.0 || ^4.0.0-alpha.21 || ^4.0.0 @@ -2165,7 +2165,7 @@ __metadata: "@lumino/signaling": ^1.10.0 || ^2.0.0 y-protocols: ^1.0.5 yjs: ^13.5.40 - checksum: c1f8d5c6854f5854b2754200be67f117586736c08deb5edc6dc7ce419d734d8797e0d009554479ab340ac02cf94f6bd60cce0186f2d1e2df8097a6b9c607b14c + checksum: 9e034badb962ea9d26e8ed279feb7fb85130d11920841e8cdeb930586c23c1b27071a32bf78211043c6dcc1f303736e3abe11f2bfc33cfbc024a2f2cf8e7bd2f languageName: node linkType: hard