Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default toolbar items #5398

Merged
merged 10 commits into from Sep 29, 2018
Merged

Conversation

@blink1073
Copy link
Member

@blink1073 blink1073 commented Sep 28, 2018

Supersedes #5395.

@jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Sep 28, 2018

What about calling the toolbar-item function "toolbarItemFactory", to be consistent with the other "Factory" uses in the code? Or even just "toolbarFactory"?

@jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Sep 28, 2018

Looking at this now...

@jasongrout
Copy link
Contributor

@jasongrout jasongrout commented Sep 28, 2018

I went a bit further after conversations about some ideas @blink1073 had about extending toolbars to rendermime extensions. You can test adding something to a toolbar with, for example:

diff --git a/packages/json-extension/src/index.tsx b/packages/json-extension/src/index.tsx
index d1b4c2f0d..096e1dcc2 100644
--- a/packages/json-extension/src/index.tsx
+++ b/packages/json-extension/src/index.tsx
@@ -75,7 +75,12 @@ const extensions: IRenderMime.IExtension | IRenderMime.IExtension[] = [
       name: 'JSON',
       primaryFileType: 'json',
       fileTypes: ['json', 'notebook'],
-      defaultFor: ['json']
+      defaultFor: ['json'],
+      toolbarFactory: () => {
+        let button = new Widget();
+        button.node.textContent = 'Hi!';
+        return [{ name: 'Button 1', widget: button }];
+      }
     }
   }
 ];

@blink1073
Copy link
Member Author

@blink1073 blink1073 commented Sep 28, 2018

LGTM!

@blink1073 blink1073 merged commit 3502102 into jupyterlab:master Sep 29, 2018
2 checks passed
@blink1073 blink1073 deleted the default-toolbar-items branch Oct 2, 2018
jasongrout added a commit to jasongrout/jupyterlab that referenced this issue Oct 10, 2018
@lock lock bot locked as resolved and limited conversation to collaborators Aug 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants