more vm to textmodel
This commit is contained in:
parent
938afec432
commit
a198d712f1
5 changed files with 15 additions and 15 deletions
|
@ -1635,8 +1635,8 @@ registerAction2(class ChangeCellLanguageAction extends NotebookCellAction<ICellR
|
|||
} else if (languageId !== 'markdown' && context.cell?.cellKind === CellKind.Markup) {
|
||||
await changeCellToKind(CellKind.Code, { cell: context.cell, notebookEditor: context.notebookEditor }, languageId);
|
||||
} else {
|
||||
const index = context.notebookEditor.viewModel.notebookDocument.cells.indexOf(context.cell.model);
|
||||
context.notebookEditor.viewModel.notebookDocument.applyEdits(
|
||||
const index = context.notebookEditor.textModel.cells.indexOf(context.cell.model);
|
||||
context.notebookEditor.textModel.applyEdits(
|
||||
[{ editType: CellEditType.CellLanguage, index, language: languageId }],
|
||||
true, undefined, () => undefined, undefined
|
||||
);
|
||||
|
|
|
@ -79,7 +79,7 @@ registerAction2(class extends Action2 {
|
|||
});
|
||||
}
|
||||
|
||||
async run(accessor: ServicesAccessor, context?: { id: string, extension: string }): Promise<boolean> {
|
||||
async run(accessor: ServicesAccessor, context?: { id: string, extension: string; }): Promise<boolean> {
|
||||
const notebookKernelService = accessor.get(INotebookKernelService);
|
||||
const editorService = accessor.get(IEditorService);
|
||||
const quickInputService = accessor.get(IQuickInputService);
|
||||
|
@ -96,7 +96,7 @@ registerAction2(class extends Action2 {
|
|||
context = undefined;
|
||||
}
|
||||
|
||||
const notebook = editor.viewModel.notebookDocument;
|
||||
const notebook = editor.textModel;
|
||||
const { selected, all } = notebookKernelService.getMatchingKernel(notebook);
|
||||
|
||||
if (selected && context && selected.id === context.id && ExtensionIdentifier.equals(selected.extension, context.extension)) {
|
||||
|
@ -120,10 +120,10 @@ registerAction2(class extends Action2 {
|
|||
}
|
||||
|
||||
if (!newKernel) {
|
||||
type KernelPick = IQuickPickItem & { kernel: INotebookKernel };
|
||||
type KernelPick = IQuickPickItem & { kernel: INotebookKernel; };
|
||||
const configButton: IQuickInputButton = {
|
||||
iconClass: ThemeIcon.asClassName(configureKernelIcon),
|
||||
tooltip: nls.localize('notebook.promptKernel.setDefaultTooltip', "Set as default for '{0}' notebooks", editor.viewModel.viewType)
|
||||
tooltip: nls.localize('notebook.promptKernel.setDefaultTooltip', "Set as default for '{0}' notebooks", editor.textModel.viewType)
|
||||
};
|
||||
const picks = all.map(kernel => {
|
||||
const res = <KernelPick>{
|
||||
|
@ -246,7 +246,7 @@ export class KernelStatus extends Disposable implements IWorkbenchContribution {
|
|||
return;
|
||||
}
|
||||
|
||||
const notebook = activeEditor.viewModel?.notebookDocument;
|
||||
const notebook = activeEditor.textModel;
|
||||
if (notebook) {
|
||||
this._showKernelStatus(notebook);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ export class ToggleCellToolbarPositionAction extends Action2 {
|
|||
const editor = context && context.ui ? (context as INotebookActionContext).notebookEditor : undefined;
|
||||
if (editor && editor.hasModel()) {
|
||||
// from toolbar
|
||||
const viewType = editor.viewModel.viewType;
|
||||
const viewType = editor.textModel.viewType;
|
||||
const configurationService = accessor.get(IConfigurationService);
|
||||
const toolbarPosition = configurationService.getValue<string | { [key: string]: string }>(CellToolbarLocation);
|
||||
const newConfig = this.togglePosition(viewType, toolbarPosition);
|
||||
|
|
|
@ -154,7 +154,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
}
|
||||
|
||||
private updateInsertIndicator(dropDirection: string, insertionIndicatorAbsolutePos: number) {
|
||||
const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType);
|
||||
const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType);
|
||||
const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + bottomToolbarGap / 2;
|
||||
if (insertionIndicatorTop >= 0) {
|
||||
this.listInsertionIndicator.style.top = `${insertionIndicatorTop}px`;
|
||||
|
@ -193,11 +193,11 @@ export class CellDragAndDropController extends Disposable {
|
|||
}
|
||||
}
|
||||
|
||||
private _dropImpl(draggedCell: ICellViewModel, dropDirection: 'above' | 'below', ctx: { ctrlKey: boolean, altKey: boolean }, draggedOverCell: ICellViewModel) {
|
||||
private _dropImpl(draggedCell: ICellViewModel, dropDirection: 'above' | 'below', ctx: { ctrlKey: boolean, altKey: boolean; }, draggedOverCell: ICellViewModel) {
|
||||
const cellTop = this.list.getAbsoluteTopOfElement(draggedOverCell);
|
||||
const cellHeight = this.list.elementHeight(draggedOverCell);
|
||||
const insertionIndicatorAbsolutePos = dropDirection === 'above' ? cellTop : cellTop + cellHeight;
|
||||
const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType);
|
||||
const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType);
|
||||
const insertionIndicatorTop = insertionIndicatorAbsolutePos - this.list.scrollTop + bottomToolbarGap / 2;
|
||||
const editorHeight = this.notebookEditor.getDomNode().getBoundingClientRect().height;
|
||||
if (insertionIndicatorTop < 0 || insertionIndicatorTop > editorHeight) {
|
||||
|
@ -378,7 +378,7 @@ export class CellDragAndDropController extends Disposable {
|
|||
this.setInsertIndicatorVisibility(false);
|
||||
}
|
||||
|
||||
public explicitDrop(cell: ICellViewModel, ctx: { dragOffsetY: number, ctrlKey: boolean, altKey: boolean }) {
|
||||
public explicitDrop(cell: ICellViewModel, ctx: { dragOffsetY: number, ctrlKey: boolean, altKey: boolean; }) {
|
||||
this.currentDraggedCell = undefined;
|
||||
this.setInsertIndicatorVisibility(false);
|
||||
|
||||
|
|
|
@ -266,7 +266,7 @@ abstract class AbstractCellRenderer {
|
|||
return;
|
||||
}
|
||||
|
||||
const textModel = this.notebookEditor.viewModel!.notebookDocument;
|
||||
const textModel = this.notebookEditor.textModel!;
|
||||
const index = textModel.cells.indexOf(templateData.currentRenderedCell.model);
|
||||
|
||||
if (index < 0) {
|
||||
|
@ -518,7 +518,7 @@ export class MarkupCellRenderer extends AbstractCellRenderer implements IListRen
|
|||
}
|
||||
|
||||
private updateForLayout(element: MarkupCellViewModel, templateData: MarkdownCellRenderTemplate): void {
|
||||
const indicatorPostion = this.notebookEditor.notebookOptions.computeIndicatorPosition(element.layoutInfo.totalHeight, this.notebookEditor.viewModel?.viewType);
|
||||
const indicatorPostion = this.notebookEditor.notebookOptions.computeIndicatorPosition(element.layoutInfo.totalHeight, this.notebookEditor.textModel?.viewType);
|
||||
templateData.focusIndicatorBottom.style.top = `${indicatorPostion.bottomIndicatorTop}px`;
|
||||
templateData.focusIndicatorLeft.style.height = `${indicatorPostion.verticalIndicatorHeight}px`;
|
||||
templateData.focusIndicatorRight.style.height = `${indicatorPostion.verticalIndicatorHeight}px`;
|
||||
|
@ -933,7 +933,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
|
|||
|
||||
private updateForLayout(element: CodeCellViewModel, templateData: CodeCellRenderTemplate): void {
|
||||
const layoutInfo = this.notebookEditor.notebookOptions.getLayoutConfiguration();
|
||||
const bottomToolbarDimensions = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.viewModel?.viewType);
|
||||
const bottomToolbarDimensions = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType);
|
||||
|
||||
templateData.focusIndicatorLeft.style.height = `${element.layoutInfo.indicatorHeight}px`;
|
||||
templateData.focusIndicatorRight.style.height = `${element.layoutInfo.indicatorHeight}px`;
|
||||
|
|
Loading…
Reference in a new issue