// Copyright (c) IPython-Contrib Team. // Distributed under the terms of the Modified BSD License. define([ 'base/js/namespace', 'jquery', 'require', 'notebook/js/outputarea', ], function ( Jupyter, $, requirejs, outputarea ) { "use strict"; var mod_name = 'skip-traceback'; var log_prefix = '[' + mod_name + ']'; var cfg = { enable: true, use_toolbar_button: false, button_icon: 'fa-warning', animation_duration: 100, show_copy_buttons: true, }; // this will be filled as they're registered var actions = {}; var apply_patches = function () { outputarea.OutputArea.prototype.append_error = function (json) { // firts part is just a copy of the original, but keeping a reference to inserted_text var inserted_text; var tb = json.traceback; if (tb !== undefined && tb.length > 0) { var s = ''; var len = tb.length; for (var i = 0; i < len; i++) { s = s + tb[i] + '\n'; } s = s + '\n'; var toinsert = this.create_output_area(); var append_text = outputarea.OutputArea.append_map['text/plain']; if (append_text) { inserted_text = append_text.apply(this, [s, {}, toinsert]).addClass('output_error'); } this._safe_append(toinsert); // now we add our header at the top of the inserted_text if (!inserted_text) { return; } var copy_btn = $('') .on('click', function (evt) { // prevent event bubbling up to collapse/uncollapse traceback evt.stopPropagation(); var $copy_btn = $(this) .tooltip({track: false, trigger: 'manual', placement: 'bottom'}); // create temporary off-screen textarea for copying text var $copy_txt_area = $('