提交 d24ad98e 编写于 作者: M Matt Bierner

Convert to switch/case

This makes the logic more clear
上级 8b72fdc3
...@@ -755,97 +755,144 @@ var requirejs = (function() { ...@@ -755,97 +755,144 @@ var requirejs = (function() {
return; return;
} }
if (data.__vscode_notebook_message) { if (!data.__vscode_notebook_message) {
if (data.type === 'dimension') { this._onMessage.fire({ message: data });
if (data.isOutput) { return;
const height = data.data.height; }
const outputHeight = height;
switch (data.type) {
case 'dimension':
{
if (data.isOutput) {
const height = data.data.height;
const outputHeight = height;
const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) {
const { cellInfo, output } = resolvedResult;
this.notebookEditor.updateOutputHeight(cellInfo, output, outputHeight, !!data.init);
}
} else {
const cellId = data.id.substr(0, data.id.length - '_preview'.length);
this.notebookEditor.updateMarkdownCellHeight(cellId, data.data.height, !!data.init);
}
break;
}
case 'mouseenter':
{
const resolvedResult = this.resolveOutputId(data.id); const resolvedResult = this.resolveOutputId(data.id);
if (resolvedResult) { if (resolvedResult) {
const { cellInfo, output } = resolvedResult; const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
this.notebookEditor.updateOutputHeight(cellInfo, output, outputHeight, !!data.init); if (latestCell) {
latestCell.outputIsHovered = true;
}
} }
} else { break;
const cellId = data.id.substr(0, data.id.length - '_preview'.length);
this.notebookEditor.updateMarkdownCellHeight(cellId, data.data.height, !!data.init);
} }
} else if (data.type === 'mouseenter') { case 'mouseleave':
const resolvedResult = this.resolveOutputId(data.id); {
if (resolvedResult) { const resolvedResult = this.resolveOutputId(data.id);
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo); if (resolvedResult) {
if (latestCell) { const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
latestCell.outputIsHovered = true; if (latestCell) {
latestCell.outputIsHovered = false;
}
} }
break;
}
case 'scroll-ack':
{
// const date = new Date();
// const top = data.data.top;
// console.log('ack top ', top, ' version: ', data.version, ' - ', date.getMinutes() + ':' + date.getSeconds() + ':' + date.getMilliseconds());
break;
}
case 'did-scroll-wheel':
{
this.notebookEditor.triggerScroll({
...data.payload,
preventDefault: () => { },
stopPropagation: () => { }
});
break;
} }
} else if (data.type === 'mouseleave') { case 'focus-editor':
const resolvedResult = this.resolveOutputId(data.id); {
if (resolvedResult) { const resolvedResult = this.resolveOutputId(data.id);
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo); if (resolvedResult) {
if (latestCell) { const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo);
latestCell.outputIsHovered = false; if (!latestCell) {
return;
}
if (data.focusNext) {
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor');
} else {
this.notebookEditor.focusNotebookCell(latestCell, 'editor');
}
} }
break;
} }
} else if (data.type === 'scroll-ack') { case 'clicked-data-url':
// const date = new Date(); {
// const top = data.data.top; this._onDidClickDataLink(data);
// console.log('ack top ', top, ' version: ', data.version, ' - ', date.getMinutes() + ':' + date.getSeconds() + ':' + date.getMilliseconds()); break;
} else if (data.type === 'did-scroll-wheel') { }
this.notebookEditor.triggerScroll({ case 'customRendererMessage':
...data.payload, {
preventDefault: () => { }, this._onMessage.fire({ message: data.message, forRenderer: data.rendererId });
stopPropagation: () => { } break;
}); }
} else if (data.type === 'focus-editor') { case 'focusMarkdownPreview':
const resolvedResult = this.resolveOutputId(data.id); {
if (resolvedResult) { const cell = this.notebookEditor.getCellById(data.cellId);
const latestCell = this.notebookEditor.getCellByInfo(resolvedResult.cellInfo); if (cell) {
if (!latestCell) { this.notebookEditor.focusNotebookCell(cell, 'container');
return;
} }
break;
if (data.focusNext) { }
this.notebookEditor.focusNextNotebookCell(latestCell, 'editor'); case 'toggleMarkdownPreview':
} else { {
this.notebookEditor.focusNotebookCell(latestCell, 'editor'); this.notebookEditor.setMarkdownCellEditState(data.cellId, CellEditState.Editing);
break;
}
case 'mouseEnterMarkdownPreview':
{
const cell = this.notebookEditor.getCellById(data.cellId);
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = true;
} }
break;
} }
} else if (data.type === 'clicked-data-url') { case 'mouseLeaveMarkdownPreview':
this._onDidClickDataLink(data); {
} else if (data.type === 'customRendererMessage') { const cell = this.notebookEditor.getCellById(data.cellId);
this._onMessage.fire({ message: data.message, forRenderer: data.rendererId }); if (cell instanceof MarkdownCellViewModel) {
} else if (data.type === 'focusMarkdownPreview') { cell.cellIsHovered = false;
const cell = this.notebookEditor.getCellById(data.cellId); }
if (cell) { break;
this.notebookEditor.focusNotebookCell(cell, 'container');
} }
} else if (data.type === 'toggleMarkdownPreview') { case 'cell-drag-start':
this.notebookEditor.setMarkdownCellEditState(data.cellId, CellEditState.Editing); {
} else if (data.type === 'mouseEnterMarkdownPreview') { this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
const cell = this.notebookEditor.getCellById(data.cellId); break;
if (cell instanceof MarkdownCellViewModel) {
cell.cellIsHovered = true;
} }
} else if (data.type === 'mouseLeaveMarkdownPreview') { case 'cell-drag':
const cell = this.notebookEditor.getCellById(data.cellId); {
if (cell instanceof MarkdownCellViewModel) { this.notebookEditor.markdownCellDrag(data.cellId, data.position);
cell.cellIsHovered = false; break;
}
case 'cell-drag-end':
{
this.notebookEditor.markdownCellDragEnd(data.cellId, {
clientY: data.position.clientY,
ctrlKey: data.ctrlKey,
altKey: data.altKey,
});
break;
} }
} else if (data.type === 'cell-drag-start') {
this.notebookEditor.markdownCellDragStart(data.cellId, data.position);
} else if (data.type === 'cell-drag') {
this.notebookEditor.markdownCellDrag(data.cellId, data.position);
} else if (data.type === 'cell-drag-end') {
this.notebookEditor.markdownCellDragEnd(data.cellId, {
clientY: data.position.clientY,
ctrlKey: data.ctrlKey,
altKey: data.altKey,
});
}
return;
} }
this._onMessage.fire({ message: data });
})); }));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册