当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript docmanager.IDocumentManager类代码示例

本文整理汇总了TypeScript中@jupyterlab/docmanager.IDocumentManager的典型用法代码示例。如果您正苦于以下问题:TypeScript IDocumentManager类的具体用法?TypeScript IDocumentManager怎么用?TypeScript IDocumentManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IDocumentManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1:

 .then(() => {
   // Open the link with the default rendered widget factory,
   // if applicable.
   const factory = docManager.registry.defaultRenderedWidgetFactory(
     path
   );
   const widget = docManager.openOrReveal(path, factory.name);
   if (!widget) {
     return;
   }
   return widget.revealed.then(() => {
     // Once the widget is ready, attempt to scroll the hash into view
     // if one has been provided.
     if (!id) {
       return;
     }
     // Look for the an element with the hash id in the document.
     // This id is set automatically for headers tags when
     // we render markdown.
     const element = widget.node.querySelector(id);
     if (element) {
       element.scrollIntoView();
     }
     return;
   });
 });
开发者ID:SylvainCorlay,项目名称:jupyterlab,代码行数:26,代码来源:index.ts

示例2: showDialog

 execute: () => {
   if (!isEnabled()) {
     return;
   }
   const context = docManager.contextForWidget(shell.currentWidget);
   return context.listCheckpoints().then(checkpoints => {
     if (checkpoints.length < 1) {
       return;
     }
     const lastCheckpoint = checkpoints[checkpoints.length - 1];
     if (!lastCheckpoint) {
       return;
     }
     return showDialog({
       title: 'Revert notebook to checkpoint',
       body: new RevertConfirmWidget(lastCheckpoint),
       buttons: [
         Dialog.cancelButton(),
         Dialog.warnButton({ label: 'Revert' })
       ]
     }).then(result => {
       if (context.isDisposed) {
         return;
       }
       if (result.button.accept) {
         if (context.model.readOnly) {
           return context.revert();
         }
         return context.restoreCheckpoint().then(() => context.revert());
       }
     });
   });
 }
开发者ID:SylvainCorlay,项目名称:jupyterlab,代码行数:33,代码来源:index.ts

示例3: each

 each(shell.widgets('main'), widget => {
   const context = docManager.contextForWidget(widget);
   if (context && !context.model.readOnly && !paths.has(context.path)) {
     paths.add(context.path);
     promises.push(context.save());
   }
 });
开发者ID:afshin,项目名称:jupyterlab,代码行数:7,代码来源:index.ts

示例4:

 execute: () => {
   if (isEnabled()) {
     let context = docManager.contextForWidget(app.shell.currentWidget);
     return context.saveAs().then(() => {
       return context.createCheckpoint();
     });
   }
 }
开发者ID:samvasko,项目名称:jupyterlab,代码行数:8,代码来源:index.ts

示例5: beforeEach

 beforeEach(() => {
   state.clear();
   model = new FileBrowserModel({ manager, state });
   return manager.newUntitled({ type: 'file' }).then(contents => {
     name = contents.name;
     return model.cd();
   });
 });
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:8,代码来源:model.spec.ts

示例6:

 execute: () => {
   if (isEnabled()) {
     let context = docManager.contextForWidget(app.shell.currentWidget);
     if (context.model.readOnly) {
       return context.revert();
     }
     return context.restoreCheckpoint().then(() => context.revert());
   }
 }
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:9,代码来源:index.ts

示例7:

 isVisible: () => {
   const widget = app.shell.currentWidget;
   if (!widget) {
     return;
   }
   // Find the context for the widget.
   let context = docManager.contextForWidget(widget);
   return context !== null;
 },
开发者ID:cameronoelsen,项目名称:jupyterlab,代码行数:9,代码来源:index.ts

示例8:

    execute: () => {
      let context = docManager.contextForWidget(app.shell.currentWidget);
      if (!context) {
        return;
      }

      // 'activate-main' is needed if this command is selected in the "open tabs" sidebar
      commands.execute('filebrowser:activate-main');
      commands.execute('filebrowser:navigate-main', {path: context.path});
    }
开发者ID:groutr,项目名称:jupyterlab,代码行数:10,代码来源:index.ts

示例9: Error

    execute: args => {
      const path = typeof args['path'] === 'undefined' ? ''
        : args['path'] as string;

      if (!path) {
        const command = CommandIDs.deleteFile;
        throw new Error(`A non-empty path is required for ${command}.`);
      }
      return docManager.deleteFile(path);
    }
开发者ID:SimonBiggs,项目名称:jupyterlab,代码行数:10,代码来源:index.ts

示例10: it

 it('should be emitted when a file is created', (done) => {
   model.fileChanged.connect((sender, args) => {
     expect(sender).to.be(model);
     expect(args.type).to.be('new');
     expect(args.oldValue).to.be(null);
     expect(args.newValue.type).to.be('file');
     done();
   });
   manager.newUntitled({ type: 'file' }).catch(done);
 });
开发者ID:charnpreetsingh185,项目名称:jupyterlab,代码行数:10,代码来源:model.spec.ts


注:本文中的@jupyterlab/docmanager.IDocumentManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。