-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from osscar-org/develop
New extension for the JLab2.1
- Loading branch information
Showing
11 changed files
with
146 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
dist | ||
coverage | ||
**/*.d.ts | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module.exports = { | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/eslint-recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended' | ||
], | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
project: 'tsconfig.json', | ||
sourceType: 'module' | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/interface-name-prefix': [ | ||
'error', | ||
{ prefixWithI: 'always' } | ||
], | ||
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }], | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-namespace': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/quotes': [ | ||
'error', | ||
'single', | ||
{ avoidEscape: true, allowTemplateLiterals: false } | ||
], | ||
curly: ['error', 'all'], | ||
eqeqeq: 'error', | ||
'prefer-arrow-callback': 'error' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
**/node_modules | ||
**/lib | ||
**/package.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2020, Dou Du All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,88 @@ | ||
import { | ||
IDisposable, DisposableDelegate | ||
} from '@phosphor/disposable'; | ||
import { IDisposable, DisposableDelegate } from '@lumino/disposable'; | ||
|
||
import { | ||
PanelLayout | ||
} from '@phosphor/widgets'; | ||
import { PanelLayout } from '@lumino/widgets'; | ||
|
||
import { | ||
JupyterFrontEnd, JupyterFrontEndPlugin | ||
JupyterFrontEnd, | ||
JupyterFrontEndPlugin | ||
} from '@jupyterlab/application'; | ||
|
||
import { | ||
ToolbarButton | ||
} from '@jupyterlab/apputils'; | ||
import { ToolbarButton } from '@jupyterlab/apputils'; | ||
|
||
import { | ||
DocumentRegistry | ||
} from '@jupyterlab/docregistry'; | ||
import { DocumentRegistry } from '@jupyterlab/docregistry'; | ||
|
||
import { | ||
NotebookActions, NotebookPanel, INotebookModel | ||
NotebookActions, | ||
NotebookPanel, | ||
INotebookModel | ||
} from '@jupyterlab/notebook'; | ||
|
||
import '../style/index.css'; | ||
|
||
const plugin: JupyterFrontEndPlugin<void> = { | ||
id: 'jlab-hide-code:buttonPlugin', | ||
autoStart: true, | ||
activate | ||
activate | ||
}; | ||
|
||
|
||
export | ||
class ButtonExtension implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> { | ||
|
||
createNew(panel: NotebookPanel, context: DocumentRegistry.IContext<INotebookModel>): IDisposable { | ||
|
||
let hideInputCode = () => { | ||
NotebookActions.runAll(panel.content, context.session); | ||
export class ButtonExtension | ||
implements DocumentRegistry.IWidgetExtension<NotebookPanel, INotebookModel> { | ||
createNew( | ||
panel: NotebookPanel, | ||
context: DocumentRegistry.IContext<INotebookModel> | ||
): IDisposable { | ||
const hideInputCode = () => { | ||
NotebookActions.runAll(panel.content, context.sessionContext); | ||
|
||
panel.content.widgets.forEach(cell => { | ||
if (cell.model.type === 'code'){ | ||
let layout = cell.layout as PanelLayout; | ||
layout.widgets[1].hide(); | ||
} | ||
}); | ||
if (cell.model.type === 'code') { | ||
const layout = cell.layout as PanelLayout; | ||
layout.widgets[1].hide(); | ||
} | ||
}); | ||
buttonHideInput.hide(); | ||
buttonShowInput.show(); | ||
buttonShowInput.show(); | ||
}; | ||
let showInputCode = () => { | ||
|
||
const showInputCode = () => { | ||
panel.content.widgets.forEach(cell => { | ||
if (cell.model.type === 'code'){ | ||
let layout = cell.layout as PanelLayout; | ||
layout.widgets[1].show(); | ||
} | ||
}); | ||
if (cell.model.type === 'code') { | ||
const layout = cell.layout as PanelLayout; | ||
layout.widgets[1].show(); | ||
} | ||
}); | ||
|
||
buttonHideInput.show(); | ||
buttonShowInput.hide(); | ||
}; | ||
let buttonHideInput = new ToolbarButton({ | ||
buttonShowInput.hide(); | ||
}; | ||
|
||
const buttonHideInput = new ToolbarButton({ | ||
className: 'myButton', | ||
iconClassName: 'fa fa-eye-slash', | ||
iconClass: 'fa fa-sm fa-eye-slash fontawesome-colors', | ||
onClick: hideInputCode, | ||
tooltip: 'Hide Input' | ||
}); | ||
let buttonShowInput = new ToolbarButton({ | ||
|
||
const buttonShowInput = new ToolbarButton({ | ||
className: 'myButton', | ||
iconClassName: 'fa fa-eye', | ||
iconClass: 'fa fa-sm fa-eye fontawesome-colors', | ||
onClick: showInputCode, | ||
tooltip: 'Show Input' | ||
tooltip: 'Show Input' | ||
}); | ||
|
||
buttonShowInput.hide(); | ||
buttonShowInput.hide(); | ||
|
||
panel.toolbar.insertItem(9, 'hideInput', buttonHideInput); | ||
panel.toolbar.insertItem(9, 'showInput', buttonShowInput); | ||
panel.toolbar.insertItem(11, 'hideInput', buttonHideInput); | ||
panel.toolbar.insertItem(11, 'showInput', buttonShowInput); | ||
|
||
return new DisposableDelegate(() => { | ||
buttonHideInput.dispose(); | ||
buttonShowInput.dispose(); | ||
buttonShowInput.dispose(); | ||
}); | ||
} | ||
|
||
} | ||
|
||
function activate(app: JupyterFrontEnd) { | ||
app.docRegistry.addWidgetExtension('Notebook', new ButtonExtension()); | ||
}; | ||
} | ||
|
||
export default plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.fontawesome-colors { | ||
color: gray; | ||
} |