本文整理汇总了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));
},
示例2:
execute: () => {
const widget = tracker.currentWidget;
if (!widget) {
return;
}
const item = widget.selectedItems().next();
if (!item) {
return;
}
Clipboard.copyToSystem(item.path);
},
示例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);
}
示例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);
}
示例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 });
}
示例6: encodeURIComponent
execute: () => {
const path = encodeURIComponent(browser.selectedItems().next().path);
const tree = PageConfig.getTreeUrl();
Clipboard.copyToSystem(URLExt.join(tree, path));
},
示例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);
}