本文整理匯總了TypeScript中@jupyterlab/rendermime.IRenderMimeRegistry.createRenderer方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IRenderMimeRegistry.createRenderer方法的具體用法?TypeScript IRenderMimeRegistry.createRenderer怎麽用?TypeScript IRenderMimeRegistry.createRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@jupyterlab/rendermime.IRenderMimeRegistry
的用法示例。
在下文中一共展示了IRenderMimeRegistry.createRenderer方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: FAQWidget
let createWidget = () => {
let content = rendermime.createRenderer('text/markdown');
const model = rendermime.createModel({
data: { 'text/markdown': SOURCE }
});
content.renderModel(model);
content.addClass('jp-FAQ-content');
return new FAQWidget(content);
};
示例2: MainAreaWidget
let createWidget = () => {
let content = rendermime.createRenderer('text/markdown');
const model = rendermime.createModel({
data: { 'text/markdown': SOURCE }
});
void content.renderModel(model);
content.addClass('jp-FAQ-content');
let widget = new MainAreaWidget({ content });
widget.addClass('jp-FAQ');
widget.title.label = 'FAQ';
return widget;
};
示例3: createView
/**
* Create a new sub-view.
*/
static
createView(model: IDiffModel, parent: CellDiffModel,
editorClasses: string[], rendermime: IRenderMimeRegistry): Panel {
let view: Panel;
if (model instanceof StringDiffModel) {
let inner: Widget | null = null;
if (model.unchanged && parent.cellType === 'markdown') {
let mimeModel = new MimeModel({ data: {'text/markdown': model.base!} });
let mimeType = rendermime.preferredMimeType(mimeModel.data, 'ensure');
if (!mimeType) {
throw new Error('No renderer for output');
}
let renderer = rendermime.createRenderer(mimeType);
renderer.renderModel(mimeModel);
inner = renderer;
} else {
inner = createNbdimeMergeView(model);
}
if (model.collapsible) {
view = new CollapsiblePanel(
inner, model.collapsibleHeader, model.startCollapsed);
} else {
view = new Panel();
view.addWidget(inner);
}
} else if (model instanceof OutputDiffModel) {
view = new OutputPanel(model, parent, editorClasses, rendermime);
if (model.added) {
view.addClass(ADDED_DIFF_CLASS);
} else if (model.deleted) {
view.addClass(DELETED_DIFF_CLASS);
} else if (model.unchanged) {
view.addClass(UNCHANGED_DIFF_CLASS);
} else {
view.addClass(TWOWAY_DIFF_CLASS);
}
} else {
throw new Error('Unrecognized model type.');
}
return view;
}