Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46df174

Browse files
author
minjk-bl
committed
Edit insert cell codes for lab4.x
1 parent3ef773e commit46df174

File tree

1 file changed

+69
-28
lines changed

1 file changed

+69
-28
lines changed

‎visualpython/js/com/com_interface.js‎

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,23 @@ define([
122122
varnotebook=notebookPanel.content;
123123
varnotebookModel=notebook.model;
124124

125-
varcellModel=notebookModel.contentFactory.createCell(type,{});
126-
cellModel.value.text=command;
127-
128-
constnewCellIndex=notebook.activeCellIndex+1;
125+
// LAB 4.x: notebookPanel.content.contentFactory.createCodeCell / createMarkdownCell
126+
// var cellModel = notebookModel.contentFactory.createCell(type, {});
129127
// 셀 추가
130-
notebookModel.cells.insert(newCellIndex,cellModel);
131-
notebook.activeCellIndex=newCellIndex;
128+
// LAB 4.x: insert cell api 변경
129+
// notebookModel.cells.insert(newCellIndex, cellModel);
130+
// notebook.activeCellIndex = newCellIndex;
131+
NotebookActions.insertBelow(notebook);
132+
try{
133+
NotebookActions.changeCellType(notebook,type);
134+
}catch(err){
135+
vpLog.display(VP_LOG_TYPE.ERROR,err);
136+
}
137+
// let activeCellIndex = notebook.activeCellIndex;
138+
// let cell = notebookModel.cells.model.getCell(activeCellIndex);
139+
// cell.setSource(command);
140+
letactiveCell=notebook.activeCell;
141+
activeCell.model.sharedModel.setSource(command);
132142

133143
if(exec==true){
134144
try{
@@ -147,16 +157,17 @@ define([
147157
// add # before the lines
148158
command='#'+command.split('\n').join('\n#');
149159
}
150-
160+
161+
// LAB 4.x: console insert and run
162+
widget.promptCell.model.sharedModel.setSource(command)
151163
// execute or not
152164
if(exec==true){
153165
// console allow only code cell
154-
varcellModel=widget.createCodeCell();
155-
cellModel.model.value.text=command;
156-
widget.addCell(cellModel);
157-
widget._execute(cellModel);
158-
}else{
159-
widget.promptCell.model.value.text=command;
166+
// var cellModel = widget.createCodeCell();
167+
// cellModel.model.value.text = command;
168+
// widget.addCell(cellModel);
169+
// widget._execute(cellModel);
170+
widget.execute()
160171
}
161172
widget.promptCell.inputArea.editor.focus();
162173
}
@@ -263,15 +274,24 @@ define([
263274
varnotebookModel=notebook.model;
264275

265276
varoptions={};
266-
varcellModel=notebookModel.contentFactory.createCell(type,options);
267-
cellModel.value.text=command;
268-
269-
constnewCellIndex=notebook.activeCellIndex+1;
277+
// LAB 4.x: notebookPanel.content.contentFactory.createCodeCell / createMarkdownCell
278+
// var cellModel = notebookModel.contentFactory.createCell(type, options);
270279
// 셀 추가
271-
notebookModel.cells.insert(newCellIndex,cellModel);
272-
notebook.activeCellIndex=newCellIndex;
273-
274-
varcell=notebook.activeCell;
280+
// LAB 4.x: insert cell api 변경
281+
// notebookModel.cells.insert(newCellIndex, cellModel);
282+
// notebook.activeCellIndex = newCellIndex;
283+
NotebookActions.insertBelow(notebook);
284+
try{
285+
NotebookActions.changeCellType(notebook,type);
286+
}catch(err){
287+
vpLog.display(VP_LOG_TYPE.ERROR,err);
288+
}
289+
// let activeCellIndex = notebook.activeCellIndex;
290+
// let cell = notebookModel.cells.model.getCell(activeCellIndex);
291+
// cell.setSource(command);
292+
letactiveCell=notebook.activeCell;
293+
activeCell.model.sharedModel.setSource(command);
294+
275295
if(exec==true){
276296
try{
277297
NotebookActions.run(notebook,sessionContext);
@@ -280,9 +300,27 @@ define([
280300
}
281301
}
282302
}elseif(sessionType==='console'){
283-
varconsole=notebookPanel.content;
284-
varcellModel=console.contentFactory.createCell(type,{});
285-
cellModel.value.text=command;
303+
// LAB 4.x: notebookPanel.console.contentFactory.createCodeCell
304+
// var console = notebookPanel.content;
305+
// var cellModel = console.contentFactory.createCell(type, {});
306+
varlabConsole=notebookPanel.content;
307+
varwidget=labConsole.widgets[0];
308+
if(type==='markdown'){
309+
// add # before the lines
310+
command='#'+command.split('\n').join('\n#');
311+
}
312+
313+
// LAB 4.x: console insert and run
314+
widget.promptCell.model.sharedModel.setSource(command)
315+
// execute or not
316+
if(exec==true){
317+
// console allow only code cell
318+
// var cellModel = widget.createCodeCell();
319+
// cellModel.model.value.text = command;
320+
// widget.addCell(cellModel);
321+
// widget._execute(cellModel);
322+
widget.execute()
323+
}
286324
}
287325
}else{
288326
// No session found
@@ -299,10 +337,13 @@ define([
299337

300338
}elseif(vpConfig.extensionType==='lab'||vpConfig.extensionType==='lite'){
301339
// LAB: TODO:
302-
letactiveCell=notebookPanel.content.activeCell;
303-
letactiveCellTop=$(activeCell.node).position().top;
304-
// scroll to current cell
305-
$(vpKernel.getLabNotebookPanel().content.activeCell.node)[0].scrollIntoView(true);
340+
letsessionType=notebookPanel.sessionContext.type;
341+
if(sessionType==='notebook'){
342+
letactiveCell=notebookPanel.content.activeCell;
343+
letactiveCellTop=$(activeCell.node).position().top;
344+
// scroll to current cell
345+
$(notebookPanel.content.activeCell.node)[0].scrollIntoView(true);
346+
}
306347
}
307348

308349
com_util.renderSuccessMessage('Your code is successfully generated.');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp