|
@@ -865,6 +865,9 @@ namespace Private {
|
|
|
if (reply && reply.content.status === 'ok') {
|
|
|
let content = reply.content as KernelMessage.IExecuteOkReply;
|
|
|
parent.inspectionHandler.handleExecuteReply(content);
|
|
|
+ if (content.payload && content.payload.length) {
|
|
|
+ handlePayload(content, parent, child);
|
|
|
+ }
|
|
|
} else {
|
|
|
parent.inspectionHandler.handleExecuteReply(null);
|
|
|
}
|
|
@@ -879,6 +882,38 @@ namespace Private {
|
|
|
return Promise.resolve(true);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Handle payloads from an execute reply.
|
|
|
+ *
|
|
|
+ * #### Notes
|
|
|
+ * Payloads are deprecated and there are no official interfaces for them in
|
|
|
+ * the kernel type definitions.
|
|
|
+ * See [Payloads (DEPRECATED)](http://jupyter-client.readthedocs.io/en/latest/messaging.html#payloads-deprecated).
|
|
|
+ */
|
|
|
+ function handlePayload(content: KernelMessage.IExecuteOkReply, parent: Notebook, child: BaseCellWidget) {
|
|
|
+ let setNextInput = content.payload.filter(i => {
|
|
|
+ return (i as any).source === 'set_next_input';
|
|
|
+ })[0];
|
|
|
+ if (setNextInput) {
|
|
|
+ let text = (setNextInput as any).text;
|
|
|
+ let replace = (setNextInput as any).replace;
|
|
|
+ if (replace) {
|
|
|
+ child.model.source = text;
|
|
|
+ } else {
|
|
|
+ // Create a new code cell and add as the next cell.
|
|
|
+ let cell = parent.model.factory.createCodeCell();
|
|
|
+ cell.source = text;
|
|
|
+ let cells = parent.model.cells;
|
|
|
+ let i = cells.indexOf(child.model);
|
|
|
+ if (i === -1) {
|
|
|
+ cells.add(cell);
|
|
|
+ } else {
|
|
|
+ cells.insert(i + 1, cell);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Set the markdown header level of a cell.
|
|
|
*/
|