本文整理匯總了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);
}