當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript apputils.Clipboard類代碼示例

本文整理匯總了TypeScript中@jupyterlab/apputils.Clipboard的典型用法代碼示例。如果您正苦於以下問題:TypeScript Clipboard類的具體用法?TypeScript Clipboard怎麽用?TypeScript Clipboard使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Clipboard類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: encodeURI

    execute: () => {
      const widget = tracker.currentWidget;
      if (!widget) {
        return;
      }
      const path = encodeURI(widget.selectedItems().next().path);
      const tree = PageConfig.getTreeUrl({ workspace: true });

      Clipboard.copyToSystem(URLExt.join(tree, path));
    },
開發者ID:blink1073,項目名稱:jupyterlab,代碼行數:10,代碼來源:index.ts

示例2:

    execute: () => {
      const widget = tracker.currentWidget;
      if (!widget) {
        return;
      }
      const item = widget.selectedItems().next();
      if (!item) {
        return;
      }

      Clipboard.copyToSystem(item.path);
    },
開發者ID:ellisonbg,項目名稱:jupyterlab,代碼行數:12,代碼來源:index.ts

示例3: paste

  function paste(widget: Notebook): void {
    if (!widget.model || !widget.activeCell) {
      return;
    }
    let clipboard = Clipboard.getInstance();
    if (!clipboard.hasData(JUPYTER_CELL_MIME)) {
      return;
    }
    let state = Private.getState(widget);
    let values = clipboard.getData(JUPYTER_CELL_MIME) as nbformat.IBaseCell[];
    let model = widget.model;
    let newCells: ICellModel[] = [];
    widget.mode = 'command';

    each(values, cell => {
      switch (cell.cell_type) {
      case 'code':
        newCells.push(model.contentFactory.createCodeCell({ cell }));
        break;
      case 'markdown':
        newCells.push(model.contentFactory.createMarkdownCell({ cell }));
        break;
      default:
        newCells.push(model.contentFactory.createRawCell({ cell }));
        break;
      }
    });
    let index = widget.activeCellIndex;

    let cells = widget.model.cells;
    cells.beginCompoundOperation();
    each(newCells, cell => {
      cells.insert(++index, cell);
    });
    cells.endCompoundOperation();

    widget.activeCellIndex += newCells.length;
    widget.deselectAll();
    Private.handleState(widget, state);
  }
開發者ID:eskirk,項目名稱:jupyterlab,代碼行數:40,代碼來源:actions.ts

示例4: copyOrCut

 function copyOrCut(widget: Notebook, cut: boolean): void {
   if (!widget.model || !widget.activeCell) {
     return;
   }
   let state = getState(widget);
   widget.mode = 'command';
   let clipboard = Clipboard.getInstance();
   clipboard.clear();
   let data: nbformat.IBaseCell[] = [];
   each(widget.widgets, child => {
     if (widget.isSelectedOrActive(child)) {
       data.push(child.model.toJSON());
     }
   });
   clipboard.setData(JUPYTER_CELL_MIME, data);
   if (cut) {
     deleteCells(widget);
   } else {
     widget.deselectAll();
   }
   handleState(widget, state);
 }
開發者ID:7125messi,項目名稱:jupyterlab,代碼行數:22,代碼來源:actions.ts

示例5: defaultRenderMime

  export const defaultEditorConfig = { ...StaticNotebook.defaultEditorConfig };

  export const editorFactory = editorServices.factoryService.newInlineEditor.bind(
    editorServices.factoryService
  );

  export const mimeTypeService = editorServices.mimeTypeService;

  /**
   * Get a copy of the default rendermime instance.
   */
  export function defaultRenderMime(): RenderMimeRegistry {
    return localRendermime();
  }

  export const clipboard = Clipboard.getInstance();

  /**
   * Create a base cell content factory.
   */
  export function createBaseCellFactory(): Cell.IContentFactory {
    return new Cell.ContentFactory({ editorFactory });
  }

  /**
   * Create a new code cell content factory.
   */
  export function createCodeCellFactory(): Cell.IContentFactory {
    return new Cell.ContentFactory({ editorFactory });
  }
開發者ID:AlbertHilb,項目名稱:jupyterlab,代碼行數:30,代碼來源:notebook-utils.ts

示例6: encodeURIComponent

    execute: () => {
      const path = encodeURIComponent(browser.selectedItems().next().path);
      const tree = PageConfig.getTreeUrl();

      Clipboard.copyToSystem(URLExt.join(tree, path));
    },
開發者ID:cfsmile,項目名稱:jupyterlab,代碼行數:6,代碼來源:index.ts

示例7: paste

  function paste(widget: Notebook, mode: 'below' | 'above' | 'replace' = 'below'): void {
    if (!widget.model || !widget.activeCell) {
      return;
    }
    let clipboard = Clipboard.getInstance();
    if (!clipboard.hasData(JUPYTER_CELL_MIME)) {
      return;
    }
    let state = Private.getState(widget);
    let values = clipboard.getData(JUPYTER_CELL_MIME) as nbformat.IBaseCell[];
    let model = widget.model;
    let newCells: ICellModel[] = [];
    widget.mode = 'command';

    each(values, cell => {
      switch (cell.cell_type) {
      case 'code':
        newCells.push(model.contentFactory.createCodeCell({ cell }));
        break;
      case 'markdown':
        newCells.push(model.contentFactory.createMarkdownCell({ cell }));
        break;
      default:
        newCells.push(model.contentFactory.createRawCell({ cell }));
        break;
      }
    });

    let cells = widget.model.cells;
    let index: number;
    cells.beginCompoundOperation();

    // Set the starting index of the paste
    // operation depending upon the mode.
    switch (mode) {
      case 'below':
        index = widget.activeCellIndex;
        break;
      case 'above':
        index = widget.activeCellIndex - 1;
        break;
      case 'replace':
        // Find the cells to delete.
        const toDelete: number[] = [];
        each(widget.widgets, (child, i) => {
          let deletable = child.model.metadata.get('deletable');
          if (widget.isSelectedOrActive(child) && deletable !== false) {
            toDelete.push(i);
          }
        });
        // If cells are not deletable, we may not have anything to delete.
        if (toDelete.length > 0) {
          // Delete the cells as one undo event.
          each(toDelete.reverse(), i => {
            cells.remove(i);
          });
        }
        index = toDelete[0];
        break;
      default:
        break;
    }

    each(newCells, cell => {
      cells.insert(++index, cell);
    });
    cells.endCompoundOperation();

    widget.activeCellIndex += newCells.length;
    widget.deselectAll();
    Private.handleState(widget, state);
  }
開發者ID:7125messi,項目名稱:jupyterlab,代碼行數:72,代碼來源:actions.ts


注:本文中的@jupyterlab/apputils.Clipboard類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。