@difizen/libro-core 0.0.2-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/es/add-cell/index.d.ts +4 -0
- package/es/add-cell/index.d.ts.map +1 -0
- package/es/add-cell/index.js +3 -0
- package/es/add-cell/index.less +38 -0
- package/es/add-cell/libro-add-cell-module.d.ts +3 -0
- package/es/add-cell/libro-add-cell-module.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-module.js +4 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts +12 -0
- package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-slot-contribution.js +53 -0
- package/es/add-cell/libro-add-cell-view.d.ts +21 -0
- package/es/add-cell/libro-add-cell-view.d.ts.map +1 -0
- package/es/add-cell/libro-add-cell-view.js +129 -0
- package/es/cell/index.d.ts +10 -0
- package/es/cell/index.d.ts.map +1 -0
- package/es/cell/index.js +9 -0
- package/es/cell/libro-cell-contribution.d.ts +13 -0
- package/es/cell/libro-cell-contribution.d.ts.map +1 -0
- package/es/cell/libro-cell-contribution.js +41 -0
- package/es/cell/libro-cell-model.d.ts +19 -0
- package/es/cell/libro-cell-model.d.ts.map +1 -0
- package/es/cell/libro-cell-model.js +103 -0
- package/es/cell/libro-cell-module.d.ts +10 -0
- package/es/cell/libro-cell-module.d.ts.map +1 -0
- package/es/cell/libro-cell-module.js +30 -0
- package/es/cell/libro-cell-protocol.d.ts +42 -0
- package/es/cell/libro-cell-protocol.d.ts.map +1 -0
- package/es/cell/libro-cell-protocol.js +11 -0
- package/es/cell/libro-cell-service.d.ts +28 -0
- package/es/cell/libro-cell-service.d.ts.map +1 -0
- package/es/cell/libro-cell-service.js +242 -0
- package/es/cell/libro-cell-view.d.ts +65 -0
- package/es/cell/libro-cell-view.d.ts.map +1 -0
- package/es/cell/libro-cell-view.js +191 -0
- package/es/cell/libro-edit-cell-view.d.ts +32 -0
- package/es/cell/libro-edit-cell-view.d.ts.map +1 -0
- package/es/cell/libro-edit-cell-view.js +72 -0
- package/es/cell/libro-executable-cell-model.d.ts +14 -0
- package/es/cell/libro-executable-cell-model.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-model.js +7 -0
- package/es/cell/libro-executable-cell-view.d.ts +27 -0
- package/es/cell/libro-executable-cell-view.d.ts.map +1 -0
- package/es/cell/libro-executable-cell-view.js +66 -0
- package/es/cell/libro-markdown-cell-model.d.ts +9 -0
- package/es/cell/libro-markdown-cell-model.d.ts.map +1 -0
- package/es/cell/libro-markdown-cell-model.js +7 -0
- package/es/collapse-service.d.ts +36 -0
- package/es/collapse-service.d.ts.map +1 -0
- package/es/collapse-service.js +55 -0
- package/es/command/document-commands.d.ts +6 -0
- package/es/command/document-commands.d.ts.map +1 -0
- package/es/command/document-commands.js +13 -0
- package/es/command/index.d.ts +7 -0
- package/es/command/index.d.ts.map +1 -0
- package/es/command/index.js +6 -0
- package/es/command/kernel-command.d.ts +5 -0
- package/es/command/kernel-command.d.ts.map +1 -0
- package/es/command/kernel-command.js +39 -0
- package/es/command/libro-command-contribution.d.ts +14 -0
- package/es/command/libro-command-contribution.d.ts.map +1 -0
- package/es/command/libro-command-contribution.js +1751 -0
- package/es/command/libro-command-register.d.ts +22 -0
- package/es/command/libro-command-register.d.ts.map +1 -0
- package/es/command/libro-command-register.js +105 -0
- package/es/command/module.d.ts +3 -0
- package/es/command/module.d.ts.map +1 -0
- package/es/command/module.js +4 -0
- package/es/command/notebook-commands.d.ts +6 -0
- package/es/command/notebook-commands.d.ts.map +1 -0
- package/es/command/notebook-commands.js +468 -0
- package/es/components/cell-protocol.d.ts +20 -0
- package/es/components/cell-protocol.d.ts.map +1 -0
- package/es/components/cell-protocol.js +4 -0
- package/es/components/dnd-cell-item-render.d.ts +12 -0
- package/es/components/dnd-cell-item-render.d.ts.map +1 -0
- package/es/components/dnd-cell-item-render.js +253 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts +9 -0
- package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -0
- package/es/components/dnd-component/custom-drag-layer.js +141 -0
- package/es/components/dnd-component/default-dnd-content.d.ts +10 -0
- package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -0
- package/es/components/dnd-component/default-dnd-content.js +257 -0
- package/es/components/dnd-component/dnd-context.d.ts +3 -0
- package/es/components/dnd-component/dnd-context.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-context.js +20 -0
- package/es/components/dnd-component/dnd-list.d.ts +10 -0
- package/es/components/dnd-component/dnd-list.d.ts.map +1 -0
- package/es/components/dnd-component/dnd-list.js +115 -0
- package/es/components/dnd-component/index.d.ts +5 -0
- package/es/components/dnd-component/index.d.ts.map +1 -0
- package/es/components/dnd-component/index.js +4 -0
- package/es/components/index.d.ts +6 -0
- package/es/components/index.d.ts.map +1 -0
- package/es/components/index.js +5 -0
- package/es/components/libro-component.d.ts +5 -0
- package/es/components/libro-component.d.ts.map +1 -0
- package/es/components/libro-component.js +35 -0
- package/es/components/libro-side-toolbar-menu.d.ts +21 -0
- package/es/components/libro-side-toolbar-menu.d.ts.map +1 -0
- package/es/components/libro-side-toolbar-menu.js +58 -0
- package/es/components/libro-view-header.d.ts +3 -0
- package/es/components/libro-view-header.d.ts.map +1 -0
- package/es/components/libro-view-header.js +37 -0
- package/es/configuration/libro-configuration-contribution.d.ts +5 -0
- package/es/configuration/libro-configuration-contribution.d.ts.map +1 -0
- package/es/configuration/libro-configuration-contribution.js +24 -0
- package/es/configuration/libro-configuration.d.ts +10 -0
- package/es/configuration/libro-configuration.d.ts.map +1 -0
- package/es/configuration/libro-configuration.js +81 -0
- package/es/content/index.d.ts +5 -0
- package/es/content/index.d.ts.map +1 -0
- package/es/content/index.js +4 -0
- package/es/content/libro-content-contribution.d.ts +11 -0
- package/es/content/libro-content-contribution.d.ts.map +1 -0
- package/es/content/libro-content-contribution.js +32 -0
- package/es/content/libro-content-module.d.ts +3 -0
- package/es/content/libro-content-module.d.ts.map +1 -0
- package/es/content/libro-content-module.js +5 -0
- package/es/content/libro-content-protocol.d.ts +8 -0
- package/es/content/libro-content-protocol.d.ts.map +1 -0
- package/es/content/libro-content-protocol.js +2 -0
- package/es/content/libro-content-service.d.ts +9 -0
- package/es/content/libro-content-service.d.ts.map +1 -0
- package/es/content/libro-content-service.js +35 -0
- package/es/index.d.ts +20 -0
- package/es/index.d.ts.map +1 -0
- package/es/index.js +19 -0
- package/es/index.less +682 -0
- package/es/libro-context-key.d.ts +22 -0
- package/es/libro-context-key.d.ts.map +1 -0
- package/es/libro-context-key.js +80 -0
- package/es/libro-keybind-registry.d.ts +5 -0
- package/es/libro-keybind-registry.d.ts.map +1 -0
- package/es/libro-keybind-registry.js +68 -0
- package/es/libro-model.d.ts +129 -0
- package/es/libro-model.d.ts.map +1 -0
- package/es/libro-model.js +803 -0
- package/es/libro-protocol.d.ts +241 -0
- package/es/libro-protocol.d.ts.map +1 -0
- package/es/libro-protocol.js +34 -0
- package/es/libro-service.d.ts +34 -0
- package/es/libro-service.d.ts.map +1 -0
- package/es/libro-service.js +180 -0
- package/es/libro-view-tracker.d.ts +6 -0
- package/es/libro-view-tracker.d.ts.map +1 -0
- package/es/libro-view-tracker.js +13 -0
- package/es/libro-view.d.ts +151 -0
- package/es/libro-view.d.ts.map +1 -0
- package/es/libro-view.js +1963 -0
- package/es/material-from-designer.d.ts +27 -0
- package/es/material-from-designer.d.ts.map +1 -0
- package/es/material-from-designer.js +550 -0
- package/es/module.d.ts +3 -0
- package/es/module.d.ts.map +1 -0
- package/es/module.js +55 -0
- package/es/output/index.d.ts +6 -0
- package/es/output/index.d.ts.map +1 -0
- package/es/output/index.js +5 -0
- package/es/output/output-area.d.ts +51 -0
- package/es/output/output-area.d.ts.map +1 -0
- package/es/output/output-area.js +346 -0
- package/es/output/output-contribution.d.ts +11 -0
- package/es/output/output-contribution.d.ts.map +1 -0
- package/es/output/output-contribution.js +31 -0
- package/es/output/output-model.d.ts +27 -0
- package/es/output/output-model.d.ts.map +1 -0
- package/es/output/output-model.js +95 -0
- package/es/output/output-module.d.ts +3 -0
- package/es/output/output-module.d.ts.map +1 -0
- package/es/output/output-module.js +6 -0
- package/es/output/output-protocol.d.ts +130 -0
- package/es/output/output-protocol.d.ts.map +1 -0
- package/es/output/output-protocol.js +18 -0
- package/es/slot/index.d.ts +5 -0
- package/es/slot/index.d.ts.map +1 -0
- package/es/slot/index.js +4 -0
- package/es/slot/libro-slot-manager.d.ts +13 -0
- package/es/slot/libro-slot-manager.d.ts.map +1 -0
- package/es/slot/libro-slot-manager.js +57 -0
- package/es/slot/libro-slot-protocol.d.ts +19 -0
- package/es/slot/libro-slot-protocol.d.ts.map +1 -0
- package/es/slot/libro-slot-protocol.js +5 -0
- package/es/slot/libro-slot-view.d.ts +9 -0
- package/es/slot/libro-slot-view.d.ts.map +1 -0
- package/es/slot/libro-slot-view.js +81 -0
- package/es/slot/module.d.ts +3 -0
- package/es/slot/module.d.ts.map +1 -0
- package/es/slot/module.js +5 -0
- package/es/theme/libro-color-registry.d.ts +6 -0
- package/es/theme/libro-color-registry.d.ts.map +1 -0
- package/es/theme/libro-color-registry.js +494 -0
- package/es/toolbar/change-cell-to-selector.d.ts +5 -0
- package/es/toolbar/change-cell-to-selector.d.ts.map +1 -0
- package/es/toolbar/change-cell-to-selector.js +48 -0
- package/es/toolbar/hide-all-selector.d.ts +5 -0
- package/es/toolbar/hide-all-selector.d.ts.map +1 -0
- package/es/toolbar/hide-all-selector.js +99 -0
- package/es/toolbar/index.d.ts +4 -0
- package/es/toolbar/index.d.ts.map +1 -0
- package/es/toolbar/index.js +3 -0
- package/es/toolbar/index.less +59 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts +4 -0
- package/es/toolbar/libro-toolbar-protocol.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar-protocol.js +1 -0
- package/es/toolbar/libro-toolbar.d.ts +8 -0
- package/es/toolbar/libro-toolbar.d.ts.map +1 -0
- package/es/toolbar/libro-toolbar.js +223 -0
- package/es/toolbar/module.d.ts +3 -0
- package/es/toolbar/module.d.ts.map +1 -0
- package/es/toolbar/module.js +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts +5 -0
- package/es/toolbar/restart-clear-outputs-contribution.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-contribution.js +23 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts +6 -0
- package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -0
- package/es/toolbar/restart-clear-outputs-modal.js +30 -0
- package/es/toolbar/save-icon.d.ts +3 -0
- package/es/toolbar/save-icon.d.ts.map +1 -0
- package/es/toolbar/save-icon.js +54 -0
- package/es/toolbar/shutdown-contribution.d.ts +5 -0
- package/es/toolbar/shutdown-contribution.d.ts.map +1 -0
- package/es/toolbar/shutdown-contribution.js +23 -0
- package/es/toolbar/shutdown-modal.d.ts +6 -0
- package/es/toolbar/shutdown-modal.d.ts.map +1 -0
- package/es/toolbar/shutdown-modal.js +30 -0
- package/es/toolbar/side-toolar-more-select.d.ts +4 -0
- package/es/toolbar/side-toolar-more-select.d.ts.map +1 -0
- package/es/toolbar/side-toolar-more-select.js +161 -0
- package/es/typings/index.d.ts +1 -0
- package/package.json +70 -0
- package/src/add-cell/index.less +38 -0
- package/src/add-cell/index.ts +3 -0
- package/src/add-cell/libro-add-cell-module.ts +9 -0
- package/src/add-cell/libro-add-cell-slot-contribution.ts +31 -0
- package/src/add-cell/libro-add-cell-view.tsx +101 -0
- package/src/cell/README.md +14 -0
- package/src/cell/index.ts +9 -0
- package/src/cell/libro-cell-contribution.ts +38 -0
- package/src/cell/libro-cell-model.ts +61 -0
- package/src/cell/libro-cell-module.ts +40 -0
- package/src/cell/libro-cell-protocol.ts +53 -0
- package/src/cell/libro-cell-service.ts +157 -0
- package/src/cell/libro-cell-view.tsx +128 -0
- package/src/cell/libro-edit-cell-view.tsx +60 -0
- package/src/cell/libro-executable-cell-model.ts +32 -0
- package/src/cell/libro-executable-cell-view.ts +74 -0
- package/src/cell/libro-markdown-cell-model.ts +20 -0
- package/src/collapse-service.ts +69 -0
- package/src/command/document-commands.ts +18 -0
- package/src/command/index.ts +6 -0
- package/src/command/kernel-command.ts +41 -0
- package/src/command/libro-command-contribution.ts +1339 -0
- package/src/command/libro-command-register.ts +171 -0
- package/src/command/module.ts +9 -0
- package/src/command/notebook-commands.ts +498 -0
- package/src/components/cell-protocol.ts +22 -0
- package/src/components/dnd-cell-item-render.tsx +308 -0
- package/src/components/dnd-component/custom-drag-layer.tsx +145 -0
- package/src/components/dnd-component/default-dnd-content.tsx +275 -0
- package/src/components/dnd-component/dnd-context.tsx +28 -0
- package/src/components/dnd-component/dnd-list.tsx +116 -0
- package/src/components/dnd-component/index.tsx +4 -0
- package/src/components/index.ts +5 -0
- package/src/components/libro-component.tsx +30 -0
- package/src/components/libro-side-toolbar-menu.tsx +82 -0
- package/src/components/libro-view-header.tsx +33 -0
- package/src/configuration/libro-configuration-contribution.ts +29 -0
- package/src/configuration/libro-configuration.ts +88 -0
- package/src/content/index.ts +4 -0
- package/src/content/libro-content-contribution.ts +17 -0
- package/src/content/libro-content-module.ts +9 -0
- package/src/content/libro-content-protocol.ts +8 -0
- package/src/content/libro-content-service.ts +30 -0
- package/src/index.less +682 -0
- package/src/index.tsx +19 -0
- package/src/libro-context-key.ts +80 -0
- package/src/libro-keybind-registry.ts +43 -0
- package/src/libro-model.ts +614 -0
- package/src/libro-protocol.ts +322 -0
- package/src/libro-service.ts +121 -0
- package/src/libro-view-tracker.ts +9 -0
- package/src/libro-view.tsx +1399 -0
- package/src/material-from-designer.tsx +457 -0
- package/src/module.ts +90 -0
- package/src/output/index.ts +5 -0
- package/src/output/output-area.tsx +255 -0
- package/src/output/output-contribution.ts +18 -0
- package/src/output/output-model.tsx +66 -0
- package/src/output/output-module.ts +10 -0
- package/src/output/output-protocol.ts +164 -0
- package/src/slot/index.ts +4 -0
- package/src/slot/libro-slot-manager.ts +37 -0
- package/src/slot/libro-slot-protocol.ts +28 -0
- package/src/slot/libro-slot-view.tsx +51 -0
- package/src/slot/module.ts +9 -0
- package/src/theme/libro-color-registry.ts +371 -0
- package/src/toolbar/change-cell-to-selector.tsx +58 -0
- package/src/toolbar/hide-all-selector.tsx +126 -0
- package/src/toolbar/index.less +59 -0
- package/src/toolbar/index.ts +3 -0
- package/src/toolbar/libro-toolbar-protocol.ts +4 -0
- package/src/toolbar/libro-toolbar.tsx +192 -0
- package/src/toolbar/module.ts +11 -0
- package/src/toolbar/restart-clear-outputs-contribution.tsx +10 -0
- package/src/toolbar/restart-clear-outputs-modal.tsx +37 -0
- package/src/toolbar/save-icon.tsx +47 -0
- package/src/toolbar/shutdown-contribution.tsx +10 -0
- package/src/toolbar/shutdown-modal.tsx +37 -0
- package/src/toolbar/side-toolar-more-select.tsx +172 -0
- package/src/typings/index.d.ts +1 -0
package/es/libro-view.js
ADDED
|
@@ -0,0 +1,1963 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8;
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
+
function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
|
|
8
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
+
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
21
|
+
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
22
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
23
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
25
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
26
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
27
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
28
|
+
import { ToTopOutlined } from '@ant-design/icons';
|
|
29
|
+
import { concatMultilineString } from '@difizen/libro-common';
|
|
30
|
+
import { ConfigurationService, useConfigurationValue } from '@difizen/mana-app';
|
|
31
|
+
import { getOrigin, prop, watch } from '@difizen/mana-app';
|
|
32
|
+
import { Deferred, Disposable, DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
33
|
+
import { Slot, ViewManager, BaseView, view, ViewInstance, ViewOption } from '@difizen/mana-app';
|
|
34
|
+
import { inject, transient, useInject, equals } from '@difizen/mana-app';
|
|
35
|
+
import { Spin, Button, FloatButton } from 'antd';
|
|
36
|
+
import { useEffect, useRef, useCallback, memo, forwardRef } from 'react';
|
|
37
|
+
import { v4 } from 'uuid';
|
|
38
|
+
import { CellService, ExecutableCellModel, ExecutableCellView, EditorCellView } from "./cell/index.js";
|
|
39
|
+
import { CollapseServiceFactory } from "./collapse-service.js";
|
|
40
|
+
import { CustomDragLayer, DefaultDndContent, DndCellItemRender, DndContext, DndList } from "./components/index.js";
|
|
41
|
+
import { LibroViewHeader } from "./components/libro-view-header.js";
|
|
42
|
+
import { AutoInsertWhenNoCell, EnterEditModeWhenAddCell, HeaderToolbarVisible, RightContentFixed } from "./configuration/libro-configuration.js";
|
|
43
|
+
import { LirboContextKey } from "./libro-context-key.js";
|
|
44
|
+
import { LibroModel } from "./libro-model.js";
|
|
45
|
+
import { NotebookService, notebookViewFactoryId } from "./libro-protocol.js";
|
|
46
|
+
import { LibroService } from "./libro-service.js";
|
|
47
|
+
import { LibroSlotManager, LibroSlotView } from "./slot/index.js";
|
|
48
|
+
import "./index.less";
|
|
49
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
50
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
51
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
52
|
+
export var LibroContentComponent = /*#__PURE__*/memo(function LibroContentComponent() {
|
|
53
|
+
var libroSlotManager = useInject(LibroSlotManager);
|
|
54
|
+
var ref = useRef(null);
|
|
55
|
+
var libroViewTopRef = useRef(null);
|
|
56
|
+
var libroViewRightContentRef = useRef(null);
|
|
57
|
+
var libroViewLeftContentRef = useRef(null);
|
|
58
|
+
var libroViewContentRef = useRef(null);
|
|
59
|
+
var instance = useInject(ViewInstance);
|
|
60
|
+
var HeaderRender = getOrigin(instance.headerRender);
|
|
61
|
+
var _useConfigurationValu = useConfigurationValue(HeaderToolbarVisible),
|
|
62
|
+
_useConfigurationValu2 = _slicedToArray(_useConfigurationValu, 1),
|
|
63
|
+
headerVisible = _useConfigurationValu2[0];
|
|
64
|
+
var _useConfigurationValu3 = useConfigurationValue(RightContentFixed),
|
|
65
|
+
_useConfigurationValu4 = _slicedToArray(_useConfigurationValu3, 1),
|
|
66
|
+
rightContentFixed = _useConfigurationValu4[0];
|
|
67
|
+
var handleScroll = useCallback(function () {
|
|
68
|
+
var _instance$container, _instance$container$c, _instance$activeCell, _instance$activeCell$, _instance$activeCell$2, _instance$activeCell2, _instance$activeCell3, _instance$activeCell4, _instance$activeCell5, _activeOutput$outputs, _activeOutput$outputs2, _instance$activeCell6, _instance$activeCell7, _instance$activeCell8, _libroViewTopRef$curr;
|
|
69
|
+
var cellRightToolbar = (_instance$container = instance.container) === null || _instance$container === void 0 ? void 0 : (_instance$container$c = _instance$container.current) === null || _instance$container$c === void 0 ? void 0 : _instance$container$c.getElementsByClassName('libro-cell-right-toolbar')[instance.model.activeIndex];
|
|
70
|
+
var activeCellOffsetY = (_instance$activeCell = instance.activeCell) === null || _instance$activeCell === void 0 ? void 0 : (_instance$activeCell$ = _instance$activeCell.container) === null || _instance$activeCell$ === void 0 ? void 0 : (_instance$activeCell$2 = _instance$activeCell$.current) === null || _instance$activeCell$2 === void 0 ? void 0 : _instance$activeCell$2.getBoundingClientRect().y;
|
|
71
|
+
var activeCellOffsetRight = (_instance$activeCell2 = instance.activeCell) === null || _instance$activeCell2 === void 0 ? void 0 : (_instance$activeCell3 = _instance$activeCell2.container) === null || _instance$activeCell3 === void 0 ? void 0 : (_instance$activeCell4 = _instance$activeCell3.current) === null || _instance$activeCell4 === void 0 ? void 0 : _instance$activeCell4.getBoundingClientRect().right;
|
|
72
|
+
var activeOutput = ExecutableCellView.is(instance.activeCell) && ((_instance$activeCell5 = instance.activeCell) === null || _instance$activeCell5 === void 0 ? void 0 : _instance$activeCell5.outputArea);
|
|
73
|
+
var activeOutputOffsetBottom = activeOutput && activeOutput.length > 0 ? activeOutput === null || activeOutput === void 0 ? void 0 : (_activeOutput$outputs = activeOutput.outputs[activeOutput.length - 1].container) === null || _activeOutput$outputs === void 0 ? void 0 : (_activeOutput$outputs2 = _activeOutput$outputs.current) === null || _activeOutput$outputs2 === void 0 ? void 0 : _activeOutput$outputs2.getBoundingClientRect().bottom : (_instance$activeCell6 = instance.activeCell) === null || _instance$activeCell6 === void 0 ? void 0 : (_instance$activeCell7 = _instance$activeCell6.container) === null || _instance$activeCell7 === void 0 ? void 0 : (_instance$activeCell8 = _instance$activeCell7.current) === null || _instance$activeCell8 === void 0 ? void 0 : _instance$activeCell8.getBoundingClientRect().bottom;
|
|
74
|
+
var libroViewTopOffsetBottom = (_libroViewTopRef$curr = libroViewTopRef.current) === null || _libroViewTopRef$curr === void 0 ? void 0 : _libroViewTopRef$curr.getBoundingClientRect().bottom;
|
|
75
|
+
if (!cellRightToolbar) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (activeCellOffsetY !== undefined && libroViewTopOffsetBottom !== undefined && activeOutputOffsetBottom !== undefined && activeCellOffsetY <= libroViewTopOffsetBottom + 12 && activeOutputOffsetBottom >= libroViewTopOffsetBottom && activeCellOffsetRight !== undefined) {
|
|
79
|
+
cellRightToolbar.style.cssText = "position:fixed;top:".concat(libroViewTopOffsetBottom + 12, "px;left:").concat(activeCellOffsetRight + 44 - 34, "px;right:unset;");
|
|
80
|
+
} else {
|
|
81
|
+
cellRightToolbar.style.cssText = ' position: absolute;top: 0px;right: -44px;';
|
|
82
|
+
}
|
|
83
|
+
}, [instance]);
|
|
84
|
+
useEffect(function () {
|
|
85
|
+
if (rightContentFixed && libroViewRightContentRef.current && libroViewContentRef.current && libroViewLeftContentRef.current) {
|
|
86
|
+
libroViewContentRef.current.style.cssText = 'display: block;';
|
|
87
|
+
libroViewRightContentRef.current.style.cssText = 'position: absolute;top:44px;right:20px';
|
|
88
|
+
libroViewLeftContentRef.current.style.cssText = 'padding-right: 80px;';
|
|
89
|
+
}
|
|
90
|
+
}, [rightContentFixed]);
|
|
91
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
92
|
+
children: [headerVisible && /*#__PURE__*/_jsx("div", {
|
|
93
|
+
className: "libro-view-top",
|
|
94
|
+
ref: libroViewTopRef,
|
|
95
|
+
children: /*#__PURE__*/_jsx(HeaderRender, {})
|
|
96
|
+
}), /*#__PURE__*/_jsxs("div", {
|
|
97
|
+
className: "libro-view-content",
|
|
98
|
+
onScroll: handleScroll,
|
|
99
|
+
ref: libroViewContentRef,
|
|
100
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
101
|
+
className: "libro-view-content-left",
|
|
102
|
+
ref: libroViewLeftContentRef,
|
|
103
|
+
children: /*#__PURE__*/_jsxs(DndContext, {
|
|
104
|
+
children: [/*#__PURE__*/_jsx(CustomDragLayer, {}), /*#__PURE__*/_jsx(DndList, {
|
|
105
|
+
libroView: instance,
|
|
106
|
+
ref: ref,
|
|
107
|
+
children: /*#__PURE__*/_jsx(Slot, {
|
|
108
|
+
name: libroSlotManager.getSlotName(instance, 'list'),
|
|
109
|
+
slotView: LibroSlotView
|
|
110
|
+
})
|
|
111
|
+
})]
|
|
112
|
+
})
|
|
113
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
114
|
+
className: "libro-view-content-right",
|
|
115
|
+
ref: libroViewRightContentRef,
|
|
116
|
+
children: /*#__PURE__*/_jsx(Slot, {
|
|
117
|
+
name: libroSlotManager.getSlotName(instance, 'right'),
|
|
118
|
+
slotView: LibroSlotView
|
|
119
|
+
})
|
|
120
|
+
}), /*#__PURE__*/_jsx(FloatButton.BackTop, {
|
|
121
|
+
target: function target() {
|
|
122
|
+
return libroViewContentRef.current || document;
|
|
123
|
+
},
|
|
124
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
125
|
+
className: "libro-totop-button",
|
|
126
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
127
|
+
shape: "circle",
|
|
128
|
+
icon: /*#__PURE__*/_jsx(ToTopOutlined, {})
|
|
129
|
+
})
|
|
130
|
+
})
|
|
131
|
+
}), /*#__PURE__*/_jsx(Slot, {
|
|
132
|
+
name: libroSlotManager.getSlotName(instance, 'content'),
|
|
133
|
+
slotView: LibroSlotView
|
|
134
|
+
})]
|
|
135
|
+
}), /*#__PURE__*/_jsx(Slot, {
|
|
136
|
+
name: libroSlotManager.getSlotName(instance, 'container'),
|
|
137
|
+
slotView: LibroSlotView
|
|
138
|
+
})]
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
export var LibroRender = /*#__PURE__*/forwardRef(function LibroRender(_props, ref) {
|
|
142
|
+
var instance = useInject(ViewInstance);
|
|
143
|
+
var libroService = useInject(LibroService);
|
|
144
|
+
var handleMouseDown = useCallback(function (e) {
|
|
145
|
+
if (e.defaultPrevented) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (!instance.model.commandMode) {
|
|
149
|
+
instance.enterCommandMode(true);
|
|
150
|
+
}
|
|
151
|
+
}, [instance]);
|
|
152
|
+
var handFocus = useCallback(
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
154
|
+
function (_e) {
|
|
155
|
+
if (!equals(libroService.active, instance)) {
|
|
156
|
+
libroService.active = instance;
|
|
157
|
+
}
|
|
158
|
+
if (!equals(libroService.focus, instance)) {
|
|
159
|
+
libroService.focus = instance;
|
|
160
|
+
}
|
|
161
|
+
}, [instance, libroService]);
|
|
162
|
+
var handBlur = useCallback(function (e) {
|
|
163
|
+
var _ref$current;
|
|
164
|
+
if (typeof ref !== 'function' && !(ref !== null && ref !== void 0 && (_ref$current = ref.current) !== null && _ref$current !== void 0 && _ref$current.contains(e.relatedTarget))) {
|
|
165
|
+
instance.enterCommandMode(false);
|
|
166
|
+
libroService.focus = undefined;
|
|
167
|
+
instance.onBlurEmitter.fire('');
|
|
168
|
+
}
|
|
169
|
+
}, [instance, libroService, ref]);
|
|
170
|
+
return /*#__PURE__*/_jsx("div", {
|
|
171
|
+
className: "".concat(instance.model.libroViewClass, " libro-view"),
|
|
172
|
+
onMouseDown: handleMouseDown,
|
|
173
|
+
ref: ref,
|
|
174
|
+
tabIndex: 0,
|
|
175
|
+
onFocus: handFocus,
|
|
176
|
+
onBlur: handBlur,
|
|
177
|
+
children: /*#__PURE__*/_jsx(LibroContentComponent, {})
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
export var LibroView = (_dec = transient(), _dec2 = view(notebookViewFactoryId), _dec3 = inject(CellService), _dec4 = inject(LibroService), _dec5 = inject(LibroSlotManager), _dec6 = inject(LirboContextKey), _dec7 = inject(ViewManager), _dec8 = inject(ConfigurationService), _dec9 = prop(), _dec10 = prop(), _dec(_class = _dec2(_class = (_class2 = /*#__PURE__*/function (_BaseView) {
|
|
181
|
+
_inherits(LibroView, _BaseView);
|
|
182
|
+
var _super = _createSuper(LibroView);
|
|
183
|
+
function LibroView(_options, collapseServiceFactory, notebookService) {
|
|
184
|
+
var _this;
|
|
185
|
+
_classCallCheck(this, LibroView);
|
|
186
|
+
_this = _super.call(this);
|
|
187
|
+
_this.toDispose = new DisposableCollection();
|
|
188
|
+
_this.model = void 0;
|
|
189
|
+
_this.headerRender = LibroViewHeader;
|
|
190
|
+
_this.loadingRender = function () {
|
|
191
|
+
return /*#__PURE__*/_jsx("div", {
|
|
192
|
+
className: "libro-loading",
|
|
193
|
+
children: /*#__PURE__*/_jsx(Spin, {})
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
_this.dndContentRender = DefaultDndContent;
|
|
197
|
+
_this.dndItemRender = DndCellItemRender;
|
|
198
|
+
_this.onCellCreateEmitter = new Emitter();
|
|
199
|
+
_this.onBlurEmitter = new Emitter();
|
|
200
|
+
_initializerDefineProperty(_this, "cellService", _descriptor, _assertThisInitialized(_this));
|
|
201
|
+
_initializerDefineProperty(_this, "libroService", _descriptor2, _assertThisInitialized(_this));
|
|
202
|
+
_initializerDefineProperty(_this, "libroSlotManager", _descriptor3, _assertThisInitialized(_this));
|
|
203
|
+
_initializerDefineProperty(_this, "contextKey", _descriptor4, _assertThisInitialized(_this));
|
|
204
|
+
_initializerDefineProperty(_this, "viewManager", _descriptor5, _assertThisInitialized(_this));
|
|
205
|
+
_initializerDefineProperty(_this, "configurationService", _descriptor6, _assertThisInitialized(_this));
|
|
206
|
+
_this.notebookService = void 0;
|
|
207
|
+
_this.collapseService = void 0;
|
|
208
|
+
_this.isDragging = false;
|
|
209
|
+
_initializerDefineProperty(_this, "collapserVisible", _descriptor7, _assertThisInitialized(_this));
|
|
210
|
+
_initializerDefineProperty(_this, "saving", _descriptor8, _assertThisInitialized(_this));
|
|
211
|
+
_this.onSaveEmitter = new Emitter();
|
|
212
|
+
_this.runCellEmitter = new Emitter();
|
|
213
|
+
_this.initializedDefer = new Deferred();
|
|
214
|
+
_this.view = LibroRender;
|
|
215
|
+
_this.onViewMount = function () {
|
|
216
|
+
_this.libroService.active = _assertThisInitialized(_this);
|
|
217
|
+
_this.libroSlotManager.setup(_assertThisInitialized(_this));
|
|
218
|
+
};
|
|
219
|
+
_this.onViewUnmount = function () {
|
|
220
|
+
if (equals(_this.libroService.active, _assertThisInitialized(_this))) {
|
|
221
|
+
_this.libroService.active = undefined;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
_this.focus = function () {
|
|
225
|
+
var _this$container, _this$container$curre, _this$container2, _this$container2$curr;
|
|
226
|
+
if ((_this$container = _this.container) !== null && _this$container !== void 0 && (_this$container$curre = _this$container.current) !== null && _this$container$curre !== void 0 && _this$container$curre.contains(document.activeElement)) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
(_this$container2 = _this.container) === null || _this$container2 === void 0 ? void 0 : (_this$container2$curr = _this$container2.current) === null || _this$container2$curr === void 0 ? void 0 : _this$container2$curr.focus();
|
|
230
|
+
};
|
|
231
|
+
_this.insertCells = /*#__PURE__*/function () {
|
|
232
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options, position) {
|
|
233
|
+
var cellView;
|
|
234
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
235
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
236
|
+
case 0:
|
|
237
|
+
_context2.next = 2;
|
|
238
|
+
return Promise.all(options.map( /*#__PURE__*/function () {
|
|
239
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(option) {
|
|
240
|
+
var newView;
|
|
241
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
242
|
+
while (1) switch (_context.prev = _context.next) {
|
|
243
|
+
case 0:
|
|
244
|
+
_context.next = 2;
|
|
245
|
+
return _this.getCellViewByOption(option);
|
|
246
|
+
case 2:
|
|
247
|
+
newView = _context.sent;
|
|
248
|
+
return _context.abrupt("return", newView);
|
|
249
|
+
case 4:
|
|
250
|
+
case "end":
|
|
251
|
+
return _context.stop();
|
|
252
|
+
}
|
|
253
|
+
}, _callee);
|
|
254
|
+
}));
|
|
255
|
+
return function (_x4) {
|
|
256
|
+
return _ref2.apply(this, arguments);
|
|
257
|
+
};
|
|
258
|
+
}()));
|
|
259
|
+
case 2:
|
|
260
|
+
cellView = _context2.sent;
|
|
261
|
+
_this.model.insertCells(cellView, position);
|
|
262
|
+
case 4:
|
|
263
|
+
case "end":
|
|
264
|
+
return _context2.stop();
|
|
265
|
+
}
|
|
266
|
+
}, _callee2);
|
|
267
|
+
}));
|
|
268
|
+
return function (_x2, _x3) {
|
|
269
|
+
return _ref.apply(this, arguments);
|
|
270
|
+
};
|
|
271
|
+
}();
|
|
272
|
+
_this.selectCell = function (cell) {
|
|
273
|
+
_this.model.active = cell;
|
|
274
|
+
_this.model.selectCell(cell);
|
|
275
|
+
};
|
|
276
|
+
_this.addCell = /*#__PURE__*/function () {
|
|
277
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(option, position) {
|
|
278
|
+
var cellView;
|
|
279
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
280
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
281
|
+
case 0:
|
|
282
|
+
_context3.next = 2;
|
|
283
|
+
return _this.getCellViewByOption(option);
|
|
284
|
+
case 2:
|
|
285
|
+
cellView = _context3.sent;
|
|
286
|
+
_this.model.addCell(cellView, position);
|
|
287
|
+
case 4:
|
|
288
|
+
case "end":
|
|
289
|
+
return _context3.stop();
|
|
290
|
+
}
|
|
291
|
+
}, _callee3);
|
|
292
|
+
}));
|
|
293
|
+
return function (_x5, _x6) {
|
|
294
|
+
return _ref3.apply(this, arguments);
|
|
295
|
+
};
|
|
296
|
+
}();
|
|
297
|
+
_this.addCellAbove = /*#__PURE__*/function () {
|
|
298
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(option, position) {
|
|
299
|
+
var cellView;
|
|
300
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
301
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
302
|
+
case 0:
|
|
303
|
+
_context4.next = 2;
|
|
304
|
+
return _this.getCellViewByOption(option);
|
|
305
|
+
case 2:
|
|
306
|
+
cellView = _context4.sent;
|
|
307
|
+
_this.model.addCell(cellView, position, 'above');
|
|
308
|
+
case 4:
|
|
309
|
+
case "end":
|
|
310
|
+
return _context4.stop();
|
|
311
|
+
}
|
|
312
|
+
}, _callee4);
|
|
313
|
+
}));
|
|
314
|
+
return function (_x7, _x8) {
|
|
315
|
+
return _ref4.apply(this, arguments);
|
|
316
|
+
};
|
|
317
|
+
}();
|
|
318
|
+
_this.findCellIndex = function (cell) {
|
|
319
|
+
var cellList = _this.model.getCells();
|
|
320
|
+
if (cell) {
|
|
321
|
+
var cellIndex = cellList.findIndex(function (item) {
|
|
322
|
+
return item.id === cell.id;
|
|
323
|
+
});
|
|
324
|
+
return cellIndex;
|
|
325
|
+
}
|
|
326
|
+
return -1;
|
|
327
|
+
};
|
|
328
|
+
_this.deleteCell = function (cell) {
|
|
329
|
+
var deleteIndex = _this.model.getCells().findIndex(function (item) {
|
|
330
|
+
return equals(item, cell);
|
|
331
|
+
});
|
|
332
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
333
|
+
var startIndex = _this.model.getCells().findIndex(function (item) {
|
|
334
|
+
return equals(item, _this.model.selections[0]);
|
|
335
|
+
});
|
|
336
|
+
var endIndex = startIndex + _this.model.selections.length;
|
|
337
|
+
getOrigin(_this.model.sharedModel).transact(function () {
|
|
338
|
+
getOrigin(_this.model.sharedModel).deleteCellRange(startIndex, endIndex);
|
|
339
|
+
});
|
|
340
|
+
_this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
|
|
341
|
+
var isAutoInsertWhenNoCell = value;
|
|
342
|
+
if (isAutoInsertWhenNoCell && _this.model.cells.length === 0) {
|
|
343
|
+
_this.addCell({
|
|
344
|
+
id: v4(),
|
|
345
|
+
cell: {
|
|
346
|
+
cell_type: 'code',
|
|
347
|
+
source: '',
|
|
348
|
+
metadata: {}
|
|
349
|
+
}
|
|
350
|
+
}, 0);
|
|
351
|
+
}
|
|
352
|
+
return;
|
|
353
|
+
}).catch(function () {
|
|
354
|
+
//
|
|
355
|
+
});
|
|
356
|
+
} else {
|
|
357
|
+
if (deleteIndex > -1) {
|
|
358
|
+
_this.model.deletedCells.push(cell);
|
|
359
|
+
_this.model.deleteCell(cell.id);
|
|
360
|
+
cell.isAttached = false;
|
|
361
|
+
}
|
|
362
|
+
_this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
|
|
363
|
+
var isAutoInsertWhenNoCell = value;
|
|
364
|
+
if (isAutoInsertWhenNoCell && _this.model.cells.length === 0) {
|
|
365
|
+
_this.addCell({
|
|
366
|
+
id: v4(),
|
|
367
|
+
cell: {
|
|
368
|
+
cell_type: 'code',
|
|
369
|
+
source: '',
|
|
370
|
+
metadata: {}
|
|
371
|
+
}
|
|
372
|
+
}, 0);
|
|
373
|
+
}
|
|
374
|
+
return;
|
|
375
|
+
}).catch(function () {
|
|
376
|
+
//
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
_this.runCells = /*#__PURE__*/function () {
|
|
381
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(cells) {
|
|
382
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
383
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
384
|
+
case 0:
|
|
385
|
+
if (!(_this.model.canRun && !_this.model.canRun())) {
|
|
386
|
+
_context5.next = 2;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
return _context5.abrupt("return", false);
|
|
390
|
+
case 2:
|
|
391
|
+
return _context5.abrupt("return", Promise.all(cells.map(function (cell) {
|
|
392
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
393
|
+
return _this.executeCellRun(cell);
|
|
394
|
+
}
|
|
395
|
+
return undefined;
|
|
396
|
+
})).then(function (resultList) {
|
|
397
|
+
return resultList.every(function (item) {
|
|
398
|
+
return !!item;
|
|
399
|
+
});
|
|
400
|
+
}).catch(function (reason) {
|
|
401
|
+
if (reason.message.startsWith('KernelReplyNotOK')) {
|
|
402
|
+
return undefined;
|
|
403
|
+
} else {
|
|
404
|
+
throw reason;
|
|
405
|
+
}
|
|
406
|
+
}));
|
|
407
|
+
case 3:
|
|
408
|
+
case "end":
|
|
409
|
+
return _context5.stop();
|
|
410
|
+
}
|
|
411
|
+
}, _callee5);
|
|
412
|
+
}));
|
|
413
|
+
return function (_x9) {
|
|
414
|
+
return _ref5.apply(this, arguments);
|
|
415
|
+
};
|
|
416
|
+
}();
|
|
417
|
+
_this.runAllCell = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
418
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
419
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
420
|
+
case 0:
|
|
421
|
+
_this.runCells(_this.model.cells);
|
|
422
|
+
case 1:
|
|
423
|
+
case "end":
|
|
424
|
+
return _context6.stop();
|
|
425
|
+
}
|
|
426
|
+
}, _callee6);
|
|
427
|
+
}));
|
|
428
|
+
_this.runAllAbove = /*#__PURE__*/function () {
|
|
429
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(cell) {
|
|
430
|
+
var index;
|
|
431
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
432
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
433
|
+
case 0:
|
|
434
|
+
index = _this.findCellIndex(cell);
|
|
435
|
+
_this.runCells(_this.model.cells.slice(0, index));
|
|
436
|
+
case 2:
|
|
437
|
+
case "end":
|
|
438
|
+
return _context7.stop();
|
|
439
|
+
}
|
|
440
|
+
}, _callee7);
|
|
441
|
+
}));
|
|
442
|
+
return function (_x10) {
|
|
443
|
+
return _ref7.apply(this, arguments);
|
|
444
|
+
};
|
|
445
|
+
}();
|
|
446
|
+
_this.runAllBelow = /*#__PURE__*/function () {
|
|
447
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(cell) {
|
|
448
|
+
var index;
|
|
449
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
450
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
451
|
+
case 0:
|
|
452
|
+
index = _this.findCellIndex(cell);
|
|
453
|
+
_this.runCells(_this.model.cells.slice(index));
|
|
454
|
+
case 2:
|
|
455
|
+
case "end":
|
|
456
|
+
return _context8.stop();
|
|
457
|
+
}
|
|
458
|
+
}, _callee8);
|
|
459
|
+
}));
|
|
460
|
+
return function (_x11) {
|
|
461
|
+
return _ref8.apply(this, arguments);
|
|
462
|
+
};
|
|
463
|
+
}();
|
|
464
|
+
_this.runCell = /*#__PURE__*/function () {
|
|
465
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(cell) {
|
|
466
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
467
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
468
|
+
case 0:
|
|
469
|
+
_this.enterCommandMode(true);
|
|
470
|
+
if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
|
|
471
|
+
_context9.next = 6;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
_context9.next = 4;
|
|
475
|
+
return _this.runCells(_this.model.selections);
|
|
476
|
+
case 4:
|
|
477
|
+
_context9.next = 8;
|
|
478
|
+
break;
|
|
479
|
+
case 6:
|
|
480
|
+
_context9.next = 8;
|
|
481
|
+
return _this.runCells([cell]);
|
|
482
|
+
case 8:
|
|
483
|
+
case "end":
|
|
484
|
+
return _context9.stop();
|
|
485
|
+
}
|
|
486
|
+
}, _callee9);
|
|
487
|
+
}));
|
|
488
|
+
return function (_x12) {
|
|
489
|
+
return _ref9.apply(this, arguments);
|
|
490
|
+
};
|
|
491
|
+
}();
|
|
492
|
+
_this.runCellandSelectNext = /*#__PURE__*/function () {
|
|
493
|
+
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(cell) {
|
|
494
|
+
var toRunCells, selectIndex, _selectIndex;
|
|
495
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
496
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
497
|
+
case 0:
|
|
498
|
+
_this.enterCommandMode(true);
|
|
499
|
+
_this.collapseCell(cell, false);
|
|
500
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
501
|
+
toRunCells = _this.model.selections;
|
|
502
|
+
selectIndex = _this.findCellIndex(_this.model.selections[_this.model.selections.length - 1]);
|
|
503
|
+
if (selectIndex >= 0 && selectIndex < _this.model.cells.length - 1) {
|
|
504
|
+
_this.model.selectCell(_this.model.cells[selectIndex + 1]);
|
|
505
|
+
}
|
|
506
|
+
if (selectIndex === _this.model.cells.length - 1) {
|
|
507
|
+
_this.addCell({
|
|
508
|
+
id: v4(),
|
|
509
|
+
cell: {
|
|
510
|
+
cell_type: cell.model.type,
|
|
511
|
+
source: '',
|
|
512
|
+
metadata: {}
|
|
513
|
+
}
|
|
514
|
+
}, selectIndex + 1).then(function () {
|
|
515
|
+
_this.enterEditMode();
|
|
516
|
+
return;
|
|
517
|
+
}).catch(function () {
|
|
518
|
+
//
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
_this.runCells(toRunCells);
|
|
522
|
+
if (_this.activeCell) {
|
|
523
|
+
_this.model.scrollToView(_this.activeCell);
|
|
524
|
+
}
|
|
525
|
+
} else {
|
|
526
|
+
_selectIndex = _this.findCellIndex(cell);
|
|
527
|
+
if (_selectIndex >= 0 && _selectIndex < _this.model.cells.length - 1) {
|
|
528
|
+
_this.model.selectCell(_this.model.cells[_selectIndex + 1]);
|
|
529
|
+
}
|
|
530
|
+
if (_selectIndex === _this.model.cells.length - 1) {
|
|
531
|
+
_this.addCell({
|
|
532
|
+
id: v4(),
|
|
533
|
+
cell: {
|
|
534
|
+
cell_type: cell.model.type,
|
|
535
|
+
source: '',
|
|
536
|
+
metadata: {}
|
|
537
|
+
}
|
|
538
|
+
}, _selectIndex + 1).then(function () {
|
|
539
|
+
_this.enterEditMode();
|
|
540
|
+
return;
|
|
541
|
+
}).catch(function () {
|
|
542
|
+
//
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
_this.runCells([cell]);
|
|
546
|
+
if (_this.activeCell) {
|
|
547
|
+
_this.model.scrollToView(_this.activeCell);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
case 3:
|
|
551
|
+
case "end":
|
|
552
|
+
return _context10.stop();
|
|
553
|
+
}
|
|
554
|
+
}, _callee10);
|
|
555
|
+
}));
|
|
556
|
+
return function (_x13) {
|
|
557
|
+
return _ref10.apply(this, arguments);
|
|
558
|
+
};
|
|
559
|
+
}();
|
|
560
|
+
_this.runCellandInsertBelow = /*#__PURE__*/function () {
|
|
561
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(cell) {
|
|
562
|
+
var insertIndex, _insertIndex;
|
|
563
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
564
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
565
|
+
case 0:
|
|
566
|
+
_this.enterCommandMode(true);
|
|
567
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
568
|
+
insertIndex = _this.findCellIndex(_this.model.selections[_this.model.selections.length - 1]);
|
|
569
|
+
_this.addCell({
|
|
570
|
+
id: v4(),
|
|
571
|
+
cell: {
|
|
572
|
+
cell_type: cell.model.type,
|
|
573
|
+
source: '',
|
|
574
|
+
metadata: {}
|
|
575
|
+
}
|
|
576
|
+
}, insertIndex + 1);
|
|
577
|
+
_this.runCells(_this.model.selections);
|
|
578
|
+
} else {
|
|
579
|
+
_insertIndex = _this.findCellIndex(cell);
|
|
580
|
+
_this.addCell({
|
|
581
|
+
id: v4(),
|
|
582
|
+
cell: {
|
|
583
|
+
cell_type: cell.model.type,
|
|
584
|
+
source: '',
|
|
585
|
+
metadata: {}
|
|
586
|
+
}
|
|
587
|
+
}, _insertIndex + 1);
|
|
588
|
+
_this.runCells([cell]);
|
|
589
|
+
}
|
|
590
|
+
case 2:
|
|
591
|
+
case "end":
|
|
592
|
+
return _context11.stop();
|
|
593
|
+
}
|
|
594
|
+
}, _callee11);
|
|
595
|
+
}));
|
|
596
|
+
return function (_x14) {
|
|
597
|
+
return _ref11.apply(this, arguments);
|
|
598
|
+
};
|
|
599
|
+
}();
|
|
600
|
+
_this.moveUpCell = function (cell) {
|
|
601
|
+
_this.collapseCell(cell, false);
|
|
602
|
+
var previousCell = _this.getPreviousVisibleCell(cell);
|
|
603
|
+
if (previousCell) {
|
|
604
|
+
_this.collapseCell(previousCell, false);
|
|
605
|
+
}
|
|
606
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
607
|
+
var _iterator = _createForOfIteratorHelper(_this.model.selections),
|
|
608
|
+
_step;
|
|
609
|
+
try {
|
|
610
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
611
|
+
var selectedCell = _step.value;
|
|
612
|
+
var selectIndex = _this.findCellIndex(selectedCell);
|
|
613
|
+
if (selectIndex === 0) {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
_this.model.exchangeCells(_this.model.selections, selectIndex - 1);
|
|
617
|
+
}
|
|
618
|
+
} catch (err) {
|
|
619
|
+
_iterator.e(err);
|
|
620
|
+
} finally {
|
|
621
|
+
_iterator.f();
|
|
622
|
+
}
|
|
623
|
+
} else {
|
|
624
|
+
var sourceIndex = _this.findCellIndex(cell);
|
|
625
|
+
if (sourceIndex > -1) {
|
|
626
|
+
_this.model.exchangeCell(sourceIndex, sourceIndex - 1);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
_this.moveDownCell = function (cell) {
|
|
631
|
+
_this.collapseCell(cell, false);
|
|
632
|
+
var nextCell = _this.getNextVisibleCell(cell);
|
|
633
|
+
if (nextCell) {
|
|
634
|
+
_this.collapseCell(nextCell, false);
|
|
635
|
+
}
|
|
636
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
637
|
+
for (var i = _this.model.selections.length - 1; i > -1; i--) {
|
|
638
|
+
var selectIndex = _this.findCellIndex(_this.model.selections[i]);
|
|
639
|
+
if (selectIndex === _this.model.cells.length - 1) {
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
_this.model.exchangeCells(_this.model.selections, selectIndex + 1);
|
|
643
|
+
}
|
|
644
|
+
} else {
|
|
645
|
+
var sourceIndex = _this.findCellIndex(cell);
|
|
646
|
+
if (sourceIndex > -1) {
|
|
647
|
+
_this.model.exchangeCell(sourceIndex, sourceIndex + 1);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
};
|
|
651
|
+
_this.copyCell = function (cell) {
|
|
652
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
653
|
+
_this.model.clipboard = _this.model.selections;
|
|
654
|
+
_this.model.selections = [];
|
|
655
|
+
} else {
|
|
656
|
+
_this.model.clipboard = cell;
|
|
657
|
+
}
|
|
658
|
+
_this.model.lastClipboardInteraction = 'copy';
|
|
659
|
+
};
|
|
660
|
+
_this.cutCell = function (cell) {
|
|
661
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
662
|
+
_this.model.clipboard = _this.model.selections;
|
|
663
|
+
_this.model.selections = [];
|
|
664
|
+
var _iterator2 = _createForOfIteratorHelper(_this.model.clipboard),
|
|
665
|
+
_step2;
|
|
666
|
+
try {
|
|
667
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
668
|
+
var cutCell = _step2.value;
|
|
669
|
+
_this.deleteCell(cutCell);
|
|
670
|
+
}
|
|
671
|
+
} catch (err) {
|
|
672
|
+
_iterator2.e(err);
|
|
673
|
+
} finally {
|
|
674
|
+
_iterator2.f();
|
|
675
|
+
}
|
|
676
|
+
} else {
|
|
677
|
+
_this.model.clipboard = cell;
|
|
678
|
+
_this.deleteCell(cell);
|
|
679
|
+
}
|
|
680
|
+
_this.model.lastClipboardInteraction = 'cut';
|
|
681
|
+
};
|
|
682
|
+
_this.pasteCell = function (cell) {
|
|
683
|
+
var pasteIndex = _this.model.getCells().findIndex(function (item) {
|
|
684
|
+
return equals(item, cell);
|
|
685
|
+
});
|
|
686
|
+
var pasteCells = getOrigin(_this.model.clipboard);
|
|
687
|
+
if (!_this.model.lastClipboardInteraction) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
if (!pasteCells) {
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
if (_this.model.lastClipboardInteraction === 'copy') {
|
|
694
|
+
if (Array.isArray(pasteCells)) {
|
|
695
|
+
var _iterator3 = _createForOfIteratorHelper(pasteCells),
|
|
696
|
+
_step3;
|
|
697
|
+
try {
|
|
698
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
699
|
+
var pasteCell = _step3.value;
|
|
700
|
+
var cellOptions = pasteCell.toJSONWithoutId();
|
|
701
|
+
_this.addCell({
|
|
702
|
+
id: v4(),
|
|
703
|
+
cell: cellOptions
|
|
704
|
+
}, pasteIndex + 1);
|
|
705
|
+
pasteIndex++;
|
|
706
|
+
}
|
|
707
|
+
} catch (err) {
|
|
708
|
+
_iterator3.e(err);
|
|
709
|
+
} finally {
|
|
710
|
+
_iterator3.f();
|
|
711
|
+
}
|
|
712
|
+
} else {
|
|
713
|
+
var _cellOptions = pasteCells.toJSONWithoutId();
|
|
714
|
+
_this.addCell({
|
|
715
|
+
id: v4(),
|
|
716
|
+
cell: _cellOptions
|
|
717
|
+
}, pasteIndex + 1);
|
|
718
|
+
}
|
|
719
|
+
} else {
|
|
720
|
+
if (Array.isArray(pasteCells)) {
|
|
721
|
+
var _iterator4 = _createForOfIteratorHelper(pasteCells),
|
|
722
|
+
_step4;
|
|
723
|
+
try {
|
|
724
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
725
|
+
var _pasteCell = _step4.value;
|
|
726
|
+
_this.model.addCell(_pasteCell, pasteIndex + 1);
|
|
727
|
+
_this.model.deletedCells.splice(_this.model.deletedCells.indexOf(_pasteCell), 1);
|
|
728
|
+
pasteIndex++;
|
|
729
|
+
}
|
|
730
|
+
} catch (err) {
|
|
731
|
+
_iterator4.e(err);
|
|
732
|
+
} finally {
|
|
733
|
+
_iterator4.f();
|
|
734
|
+
}
|
|
735
|
+
} else {
|
|
736
|
+
_this.model.addCell(pasteCells, pasteIndex + 1);
|
|
737
|
+
_this.model.deletedCells.splice(_this.model.deletedCells.indexOf(pasteCells), 1);
|
|
738
|
+
}
|
|
739
|
+
_this.model.lastClipboardInteraction = '';
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
_this.pasteCellAbove = function (cell) {
|
|
743
|
+
var pasteIndex = _this.model.getCells().findIndex(function (item) {
|
|
744
|
+
return equals(item, cell);
|
|
745
|
+
});
|
|
746
|
+
var pasteCells = getOrigin(_this.model.clipboard);
|
|
747
|
+
if (!_this.model.lastClipboardInteraction) {
|
|
748
|
+
return;
|
|
749
|
+
}
|
|
750
|
+
if (!pasteCells) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (_this.model.lastClipboardInteraction === 'copy') {
|
|
754
|
+
if (Array.isArray(pasteCells)) {
|
|
755
|
+
var _iterator5 = _createForOfIteratorHelper(pasteCells),
|
|
756
|
+
_step5;
|
|
757
|
+
try {
|
|
758
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
759
|
+
var pasteCell = _step5.value;
|
|
760
|
+
var cellOptions = pasteCell.toJSONWithoutId();
|
|
761
|
+
_this.addCell({
|
|
762
|
+
id: v4(),
|
|
763
|
+
cell: cellOptions
|
|
764
|
+
}, pasteIndex);
|
|
765
|
+
pasteIndex++;
|
|
766
|
+
}
|
|
767
|
+
} catch (err) {
|
|
768
|
+
_iterator5.e(err);
|
|
769
|
+
} finally {
|
|
770
|
+
_iterator5.f();
|
|
771
|
+
}
|
|
772
|
+
} else {
|
|
773
|
+
var _cellOptions2 = pasteCells.toJSONWithoutId();
|
|
774
|
+
_this.addCell({
|
|
775
|
+
id: v4(),
|
|
776
|
+
cell: _cellOptions2
|
|
777
|
+
}, pasteIndex);
|
|
778
|
+
}
|
|
779
|
+
} else {
|
|
780
|
+
if (Array.isArray(pasteCells)) {
|
|
781
|
+
var _iterator6 = _createForOfIteratorHelper(pasteCells),
|
|
782
|
+
_step6;
|
|
783
|
+
try {
|
|
784
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
785
|
+
var _pasteCell2 = _step6.value;
|
|
786
|
+
_this.model.addCell(_pasteCell2, pasteIndex);
|
|
787
|
+
_this.model.deletedCells.splice(_this.model.deletedCells.indexOf(_pasteCell2), 1);
|
|
788
|
+
pasteIndex++;
|
|
789
|
+
}
|
|
790
|
+
} catch (err) {
|
|
791
|
+
_iterator6.e(err);
|
|
792
|
+
} finally {
|
|
793
|
+
_iterator6.f();
|
|
794
|
+
}
|
|
795
|
+
} else {
|
|
796
|
+
_this.model.addCell(pasteCells, pasteIndex);
|
|
797
|
+
_this.model.deletedCells.splice(_this.model.deletedCells.indexOf(pasteCells), 1);
|
|
798
|
+
}
|
|
799
|
+
_this.model.lastClipboardInteraction = '';
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
_this.invertCell = /*#__PURE__*/function () {
|
|
803
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(cell, type) {
|
|
804
|
+
var cellIndex, _iterator7, _step7, selectedCell, cellOptions, cellView, _cellOptions3, _cellView;
|
|
805
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
806
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
807
|
+
case 0:
|
|
808
|
+
cellIndex = _this.model.getCells().findIndex(function (item) {
|
|
809
|
+
return equals(item, cell);
|
|
810
|
+
});
|
|
811
|
+
if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
|
|
812
|
+
_context12.next = 24;
|
|
813
|
+
break;
|
|
814
|
+
}
|
|
815
|
+
_iterator7 = _createForOfIteratorHelper(_this.model.selections);
|
|
816
|
+
_context12.prev = 3;
|
|
817
|
+
_iterator7.s();
|
|
818
|
+
case 5:
|
|
819
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
820
|
+
_context12.next = 14;
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
selectedCell = _step7.value;
|
|
824
|
+
cellOptions = {
|
|
825
|
+
cell: {
|
|
826
|
+
cell_type: type,
|
|
827
|
+
source: selectedCell.toJSON().source,
|
|
828
|
+
metadata: {}
|
|
829
|
+
}
|
|
830
|
+
};
|
|
831
|
+
_context12.next = 10;
|
|
832
|
+
return _this.getCellViewByOption(cellOptions);
|
|
833
|
+
case 10:
|
|
834
|
+
cellView = _context12.sent;
|
|
835
|
+
_this.model.invertCell(cellView, cellIndex);
|
|
836
|
+
case 12:
|
|
837
|
+
_context12.next = 5;
|
|
838
|
+
break;
|
|
839
|
+
case 14:
|
|
840
|
+
_context12.next = 19;
|
|
841
|
+
break;
|
|
842
|
+
case 16:
|
|
843
|
+
_context12.prev = 16;
|
|
844
|
+
_context12.t0 = _context12["catch"](3);
|
|
845
|
+
_iterator7.e(_context12.t0);
|
|
846
|
+
case 19:
|
|
847
|
+
_context12.prev = 19;
|
|
848
|
+
_iterator7.f();
|
|
849
|
+
return _context12.finish(19);
|
|
850
|
+
case 22:
|
|
851
|
+
_context12.next = 29;
|
|
852
|
+
break;
|
|
853
|
+
case 24:
|
|
854
|
+
_cellOptions3 = {
|
|
855
|
+
cell: {
|
|
856
|
+
cell_type: type,
|
|
857
|
+
source: cell.toJSON().source,
|
|
858
|
+
metadata: {}
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
_context12.next = 27;
|
|
862
|
+
return _this.getCellViewByOption(_cellOptions3);
|
|
863
|
+
case 27:
|
|
864
|
+
_cellView = _context12.sent;
|
|
865
|
+
_this.model.invertCell(_cellView, cellIndex);
|
|
866
|
+
case 29:
|
|
867
|
+
case "end":
|
|
868
|
+
return _context12.stop();
|
|
869
|
+
}
|
|
870
|
+
}, _callee12, null, [[3, 16, 19, 22]]);
|
|
871
|
+
}));
|
|
872
|
+
return function (_x15, _x16) {
|
|
873
|
+
return _ref12.apply(this, arguments);
|
|
874
|
+
};
|
|
875
|
+
}();
|
|
876
|
+
_this.clearOutputs = function (cell) {
|
|
877
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
878
|
+
var _iterator8 = _createForOfIteratorHelper(_this.model.selections),
|
|
879
|
+
_step8;
|
|
880
|
+
try {
|
|
881
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
882
|
+
var selectedCell = _step8.value;
|
|
883
|
+
if (ExecutableCellView.is(selectedCell) && ExecutableCellModel.is(selectedCell.model)) {
|
|
884
|
+
selectedCell.clearExecution();
|
|
885
|
+
selectedCell.model.hasOutputHidden = false;
|
|
886
|
+
}
|
|
887
|
+
}
|
|
888
|
+
} catch (err) {
|
|
889
|
+
_iterator8.e(err);
|
|
890
|
+
} finally {
|
|
891
|
+
_iterator8.f();
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
|
|
895
|
+
cell.clearExecution();
|
|
896
|
+
cell.model.hasOutputHidden = false;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
};
|
|
900
|
+
_this.clearAllOutputs = function () {
|
|
901
|
+
var _iterator9 = _createForOfIteratorHelper(_this.model.cells),
|
|
902
|
+
_step9;
|
|
903
|
+
try {
|
|
904
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
905
|
+
var cell = _step9.value;
|
|
906
|
+
if (ExecutableCellView.is(cell) && ExecutableCellModel.is(cell.model)) {
|
|
907
|
+
cell.clearExecution();
|
|
908
|
+
cell.model.hasOutputHidden = false;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
} catch (err) {
|
|
912
|
+
_iterator9.e(err);
|
|
913
|
+
} finally {
|
|
914
|
+
_iterator9.f();
|
|
915
|
+
}
|
|
916
|
+
};
|
|
917
|
+
_this.hideCellCode = function (cell) {
|
|
918
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
919
|
+
var _iterator10 = _createForOfIteratorHelper(_this.model.selections),
|
|
920
|
+
_step10;
|
|
921
|
+
try {
|
|
922
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
923
|
+
var selectedCell = _step10.value;
|
|
924
|
+
selectedCell.hasInputHidden = true;
|
|
925
|
+
}
|
|
926
|
+
} catch (err) {
|
|
927
|
+
_iterator10.e(err);
|
|
928
|
+
} finally {
|
|
929
|
+
_iterator10.f();
|
|
930
|
+
}
|
|
931
|
+
} else {
|
|
932
|
+
cell.hasInputHidden = true;
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
_this.hideOrShowCellCode = function (cell) {
|
|
936
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
937
|
+
var _iterator11 = _createForOfIteratorHelper(_this.model.selections),
|
|
938
|
+
_step11;
|
|
939
|
+
try {
|
|
940
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
941
|
+
var selectedCell = _step11.value;
|
|
942
|
+
selectedCell.hasInputHidden = !selectedCell.hasInputHidden;
|
|
943
|
+
}
|
|
944
|
+
} catch (err) {
|
|
945
|
+
_iterator11.e(err);
|
|
946
|
+
} finally {
|
|
947
|
+
_iterator11.f();
|
|
948
|
+
}
|
|
949
|
+
} else {
|
|
950
|
+
cell.hasInputHidden = !cell.hasInputHidden;
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
_this.hideOutputs = function (cell) {
|
|
954
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
955
|
+
var _iterator12 = _createForOfIteratorHelper(_this.model.selections),
|
|
956
|
+
_step12;
|
|
957
|
+
try {
|
|
958
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
959
|
+
var selectedCell = _step12.value;
|
|
960
|
+
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
961
|
+
selectedCell.model.hasOutputHidden = true;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
} catch (err) {
|
|
965
|
+
_iterator12.e(err);
|
|
966
|
+
} finally {
|
|
967
|
+
_iterator12.f();
|
|
968
|
+
}
|
|
969
|
+
} else {
|
|
970
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
971
|
+
cell.model.hasOutputHidden = true;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
_this.hideOrShowOutputs = function (cell) {
|
|
976
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
977
|
+
var _iterator13 = _createForOfIteratorHelper(_this.model.selections),
|
|
978
|
+
_step13;
|
|
979
|
+
try {
|
|
980
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
981
|
+
var selectedCell = _step13.value;
|
|
982
|
+
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
983
|
+
selectedCell.model.hasOutputHidden = !selectedCell.model.hasOutputHidden;
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
} catch (err) {
|
|
987
|
+
_iterator13.e(err);
|
|
988
|
+
} finally {
|
|
989
|
+
_iterator13.f();
|
|
990
|
+
}
|
|
991
|
+
} else {
|
|
992
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
993
|
+
cell.model.hasOutputHidden = !cell.model.hasOutputHidden;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
_this.hideAllOutputs = function () {
|
|
998
|
+
var _iterator14 = _createForOfIteratorHelper(_this.model.cells),
|
|
999
|
+
_step14;
|
|
1000
|
+
try {
|
|
1001
|
+
for (_iterator14.s(); !(_step14 = _iterator14.n()).done;) {
|
|
1002
|
+
var cell = _step14.value;
|
|
1003
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1004
|
+
cell.model.hasOutputHidden = true;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
} catch (err) {
|
|
1008
|
+
_iterator14.e(err);
|
|
1009
|
+
} finally {
|
|
1010
|
+
_iterator14.f();
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
_this.hideAllCellCode = function () {
|
|
1014
|
+
var _iterator15 = _createForOfIteratorHelper(_this.model.cells),
|
|
1015
|
+
_step15;
|
|
1016
|
+
try {
|
|
1017
|
+
for (_iterator15.s(); !(_step15 = _iterator15.n()).done;) {
|
|
1018
|
+
var cell = _step15.value;
|
|
1019
|
+
cell.hasInputHidden = true;
|
|
1020
|
+
}
|
|
1021
|
+
} catch (err) {
|
|
1022
|
+
_iterator15.e(err);
|
|
1023
|
+
} finally {
|
|
1024
|
+
_iterator15.f();
|
|
1025
|
+
}
|
|
1026
|
+
};
|
|
1027
|
+
_this.showCellCode = function (cell) {
|
|
1028
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
1029
|
+
var _iterator16 = _createForOfIteratorHelper(_this.model.selections),
|
|
1030
|
+
_step16;
|
|
1031
|
+
try {
|
|
1032
|
+
for (_iterator16.s(); !(_step16 = _iterator16.n()).done;) {
|
|
1033
|
+
var selectedCell = _step16.value;
|
|
1034
|
+
selectedCell.hasInputHidden = false;
|
|
1035
|
+
}
|
|
1036
|
+
} catch (err) {
|
|
1037
|
+
_iterator16.e(err);
|
|
1038
|
+
} finally {
|
|
1039
|
+
_iterator16.f();
|
|
1040
|
+
}
|
|
1041
|
+
} else {
|
|
1042
|
+
cell.hasInputHidden = false;
|
|
1043
|
+
}
|
|
1044
|
+
};
|
|
1045
|
+
_this.showAllCellCode = function () {
|
|
1046
|
+
var _iterator17 = _createForOfIteratorHelper(_this.model.cells),
|
|
1047
|
+
_step17;
|
|
1048
|
+
try {
|
|
1049
|
+
for (_iterator17.s(); !(_step17 = _iterator17.n()).done;) {
|
|
1050
|
+
var cell = _step17.value;
|
|
1051
|
+
cell.hasInputHidden = false;
|
|
1052
|
+
}
|
|
1053
|
+
} catch (err) {
|
|
1054
|
+
_iterator17.e(err);
|
|
1055
|
+
} finally {
|
|
1056
|
+
_iterator17.f();
|
|
1057
|
+
}
|
|
1058
|
+
};
|
|
1059
|
+
_this.showCellOutputs = function (cell) {
|
|
1060
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
1061
|
+
var _iterator18 = _createForOfIteratorHelper(_this.model.selections),
|
|
1062
|
+
_step18;
|
|
1063
|
+
try {
|
|
1064
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
1065
|
+
var selectedCell = _step18.value;
|
|
1066
|
+
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
1067
|
+
selectedCell.model.hasOutputHidden = false;
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
} catch (err) {
|
|
1071
|
+
_iterator18.e(err);
|
|
1072
|
+
} finally {
|
|
1073
|
+
_iterator18.f();
|
|
1074
|
+
}
|
|
1075
|
+
} else {
|
|
1076
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1077
|
+
cell.model.hasOutputHidden = false;
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1081
|
+
_this.showAllCellOutputs = function () {
|
|
1082
|
+
var _iterator19 = _createForOfIteratorHelper(_this.model.cells),
|
|
1083
|
+
_step19;
|
|
1084
|
+
try {
|
|
1085
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
1086
|
+
var cell = _step19.value;
|
|
1087
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1088
|
+
cell.model.hasOutputHidden = false;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
} catch (err) {
|
|
1092
|
+
_iterator19.e(err);
|
|
1093
|
+
} finally {
|
|
1094
|
+
_iterator19.f();
|
|
1095
|
+
}
|
|
1096
|
+
};
|
|
1097
|
+
_this.extendSelectionAbove = function () {
|
|
1098
|
+
if (_this.activeCell) {
|
|
1099
|
+
var previousCell = _this.getPreviousVisibleCell(_this.activeCell);
|
|
1100
|
+
if (previousCell) {
|
|
1101
|
+
_this.collapseCell(previousCell, false);
|
|
1102
|
+
}
|
|
1103
|
+
var activeIndex = _this.findCellIndex(_this.activeCell);
|
|
1104
|
+
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1105
|
+
_this.extendContiguousSelectionTo(activeIndex - 1);
|
|
1106
|
+
}
|
|
1107
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
_this.extendSelectionToTop = function () {
|
|
1111
|
+
if (_this.activeCell) {
|
|
1112
|
+
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1113
|
+
_this.extendContiguousSelectionTo(0);
|
|
1114
|
+
}
|
|
1115
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
_this.extendSelectionBelow = function () {
|
|
1119
|
+
if (_this.activeCell) {
|
|
1120
|
+
var nextCell = _this.getNextVisibleCell(_this.activeCell);
|
|
1121
|
+
if (nextCell) {
|
|
1122
|
+
_this.collapseCell(nextCell, false);
|
|
1123
|
+
}
|
|
1124
|
+
var activeIndex = _this.findCellIndex(_this.activeCell);
|
|
1125
|
+
if (_this.findCellIndex(_this.activeCell) >= 0) {
|
|
1126
|
+
_this.extendContiguousSelectionTo(activeIndex + 1);
|
|
1127
|
+
}
|
|
1128
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1129
|
+
}
|
|
1130
|
+
};
|
|
1131
|
+
_this.extendSelectionToBottom = function () {
|
|
1132
|
+
if (_this.activeCell) {
|
|
1133
|
+
if (_this.findCellIndex(_this.activeCell) > 0) {
|
|
1134
|
+
_this.extendContiguousSelectionTo(_this.model.cells.length - 1);
|
|
1135
|
+
}
|
|
1136
|
+
_this.model.scrollToView(_this.activeCell);
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
_this.enableOutputScrolling = function (cell) {
|
|
1140
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
1141
|
+
var _iterator20 = _createForOfIteratorHelper(_this.model.selections),
|
|
1142
|
+
_step20;
|
|
1143
|
+
try {
|
|
1144
|
+
for (_iterator20.s(); !(_step20 = _iterator20.n()).done;) {
|
|
1145
|
+
var selectedCell = _step20.value;
|
|
1146
|
+
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
1147
|
+
selectedCell.model.hasOutputsScrolled = true;
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
} catch (err) {
|
|
1151
|
+
_iterator20.e(err);
|
|
1152
|
+
} finally {
|
|
1153
|
+
_iterator20.f();
|
|
1154
|
+
}
|
|
1155
|
+
} else {
|
|
1156
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1157
|
+
cell.model.hasOutputsScrolled = true;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
_this.disableOutputScrolling = function (cell) {
|
|
1162
|
+
if (_this.model.selections.length !== 0 && _this.isSelected(cell)) {
|
|
1163
|
+
var _iterator21 = _createForOfIteratorHelper(_this.model.selections),
|
|
1164
|
+
_step21;
|
|
1165
|
+
try {
|
|
1166
|
+
for (_iterator21.s(); !(_step21 = _iterator21.n()).done;) {
|
|
1167
|
+
var selectedCell = _step21.value;
|
|
1168
|
+
if (ExecutableCellModel.is(selectedCell.model)) {
|
|
1169
|
+
selectedCell.model.hasOutputsScrolled = false;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
} catch (err) {
|
|
1173
|
+
_iterator21.e(err);
|
|
1174
|
+
} finally {
|
|
1175
|
+
_iterator21.f();
|
|
1176
|
+
}
|
|
1177
|
+
} else {
|
|
1178
|
+
if (ExecutableCellModel.is(cell.model)) {
|
|
1179
|
+
cell.model.hasOutputsScrolled = false;
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
};
|
|
1183
|
+
_this.disposed = false;
|
|
1184
|
+
_this.enterCommandMode = function (isInLibro) {
|
|
1185
|
+
if (_this.hasModal) {
|
|
1186
|
+
return;
|
|
1187
|
+
}
|
|
1188
|
+
if (_this.model.enterCommandMode) {
|
|
1189
|
+
_this.model.enterCommandMode();
|
|
1190
|
+
}
|
|
1191
|
+
if (isInLibro) {
|
|
1192
|
+
var _this$container3, _this$container3$curr;
|
|
1193
|
+
(_this$container3 = _this.container) === null || _this$container3 === void 0 ? void 0 : (_this$container3$curr = _this$container3.current) === null || _this$container3$curr === void 0 ? void 0 : _this$container3$curr.focus();
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
_this.enterEditMode = function () {
|
|
1197
|
+
if (_this.model.enterEditMode) {
|
|
1198
|
+
_this.model.enterEditMode();
|
|
1199
|
+
}
|
|
1200
|
+
};
|
|
1201
|
+
_this.moveCursorDown = function (cell) {
|
|
1202
|
+
var newSelectedCell = _this.getNextVisibleCell(cell);
|
|
1203
|
+
if (newSelectedCell) {
|
|
1204
|
+
_this.model.selectCell(newSelectedCell);
|
|
1205
|
+
_this.model.selections = [];
|
|
1206
|
+
_this.model.scrollToView(newSelectedCell);
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
_this.moveCursorUp = function (cell) {
|
|
1210
|
+
var newSelectedCell = _this.getPreviousVisibleCell(cell);
|
|
1211
|
+
if (newSelectedCell) {
|
|
1212
|
+
_this.model.selectCell(newSelectedCell);
|
|
1213
|
+
_this.model.selections = [];
|
|
1214
|
+
_this.model.scrollToView(newSelectedCell);
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
_this.mergeCellBelow = /*#__PURE__*/function () {
|
|
1218
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(cell) {
|
|
1219
|
+
var _this$model, cells, selections, selectedIndex, nextCell, source, cellView, cellData;
|
|
1220
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1221
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1222
|
+
case 0:
|
|
1223
|
+
_this$model = _this.model, cells = _this$model.cells, selections = _this$model.selections;
|
|
1224
|
+
if (!(selections.length > 1)) {
|
|
1225
|
+
_context13.next = 4;
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
_this.mergeCells(cell);
|
|
1229
|
+
return _context13.abrupt("return");
|
|
1230
|
+
case 4:
|
|
1231
|
+
selectedIndex = _this.findCellIndex(cell);
|
|
1232
|
+
if (!(selectedIndex >= cells.length - 1)) {
|
|
1233
|
+
_context13.next = 7;
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
return _context13.abrupt("return");
|
|
1237
|
+
case 7:
|
|
1238
|
+
nextCell = cells[selectedIndex + 1];
|
|
1239
|
+
source = concatMultilineString([cell.model.value + '\n', nextCell.model.value]);
|
|
1240
|
+
_context13.next = 11;
|
|
1241
|
+
return _this.getCellViewByOption({
|
|
1242
|
+
id: v4(),
|
|
1243
|
+
cell: {
|
|
1244
|
+
cell_type: cell.model.type,
|
|
1245
|
+
source: source,
|
|
1246
|
+
metadata: {}
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
case 11:
|
|
1250
|
+
cellView = _context13.sent;
|
|
1251
|
+
if (_this.model instanceof LibroModel) {
|
|
1252
|
+
_this.model.activeIndex = selectedIndex;
|
|
1253
|
+
cellData = [cellView].map(function (_cell) {
|
|
1254
|
+
_this.model.cellViewCache.set(_cell.model.id, _cell);
|
|
1255
|
+
return _cell.toJSON();
|
|
1256
|
+
});
|
|
1257
|
+
_this.model.sharedModel.transact(function () {
|
|
1258
|
+
_this.model.sharedModel.deleteCell(selectedIndex);
|
|
1259
|
+
_this.model.sharedModel.insertCells(selectedIndex, cellData);
|
|
1260
|
+
_this.model.sharedModel.deleteCell(selectedIndex + 1);
|
|
1261
|
+
});
|
|
1262
|
+
}
|
|
1263
|
+
case 13:
|
|
1264
|
+
case "end":
|
|
1265
|
+
return _context13.stop();
|
|
1266
|
+
}
|
|
1267
|
+
}, _callee13);
|
|
1268
|
+
}));
|
|
1269
|
+
return function (_x17) {
|
|
1270
|
+
return _ref13.apply(this, arguments);
|
|
1271
|
+
};
|
|
1272
|
+
}();
|
|
1273
|
+
_this.mergeCellAbove = /*#__PURE__*/function () {
|
|
1274
|
+
var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(cell) {
|
|
1275
|
+
var _this$model2, cells, selections, selectedIndex, prevCell, source, cellView, cellData;
|
|
1276
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1277
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1278
|
+
case 0:
|
|
1279
|
+
_this$model2 = _this.model, cells = _this$model2.cells, selections = _this$model2.selections;
|
|
1280
|
+
if (!(selections.length > 1)) {
|
|
1281
|
+
_context14.next = 4;
|
|
1282
|
+
break;
|
|
1283
|
+
}
|
|
1284
|
+
_this.mergeCells(cell);
|
|
1285
|
+
return _context14.abrupt("return");
|
|
1286
|
+
case 4:
|
|
1287
|
+
selectedIndex = _this.findCellIndex(cell);
|
|
1288
|
+
if (!(selectedIndex <= 0)) {
|
|
1289
|
+
_context14.next = 7;
|
|
1290
|
+
break;
|
|
1291
|
+
}
|
|
1292
|
+
return _context14.abrupt("return");
|
|
1293
|
+
case 7:
|
|
1294
|
+
prevCell = cells[selectedIndex - 1];
|
|
1295
|
+
source = concatMultilineString([prevCell.model.value + '\n' + cell.model.value]);
|
|
1296
|
+
_context14.next = 11;
|
|
1297
|
+
return _this.getCellViewByOption({
|
|
1298
|
+
id: v4(),
|
|
1299
|
+
cell: {
|
|
1300
|
+
cell_type: cell.model.type,
|
|
1301
|
+
source: source,
|
|
1302
|
+
metadata: {}
|
|
1303
|
+
}
|
|
1304
|
+
});
|
|
1305
|
+
case 11:
|
|
1306
|
+
cellView = _context14.sent;
|
|
1307
|
+
if (_this.model instanceof LibroModel) {
|
|
1308
|
+
_this.model.activeIndex = selectedIndex - 1;
|
|
1309
|
+
cellData = [cellView].map(function (_cell) {
|
|
1310
|
+
_this.model.cellViewCache.set(_cell.model.id, _cell);
|
|
1311
|
+
return _cell.toJSON();
|
|
1312
|
+
});
|
|
1313
|
+
_this.model.sharedModel.transact(function () {
|
|
1314
|
+
_this.model.sharedModel.deleteCell(selectedIndex - 1);
|
|
1315
|
+
_this.model.sharedModel.insertCells(selectedIndex - 1, cellData);
|
|
1316
|
+
_this.model.sharedModel.deleteCell(selectedIndex);
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
case 13:
|
|
1320
|
+
case "end":
|
|
1321
|
+
return _context14.stop();
|
|
1322
|
+
}
|
|
1323
|
+
}, _callee14);
|
|
1324
|
+
}));
|
|
1325
|
+
return function (_x18) {
|
|
1326
|
+
return _ref14.apply(this, arguments);
|
|
1327
|
+
};
|
|
1328
|
+
}();
|
|
1329
|
+
_this.mergeCells = /*#__PURE__*/function () {
|
|
1330
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(cell) {
|
|
1331
|
+
var selections, selectionsValue, selectionsIndex, source, cellView, cellData, startIndex, endIndex;
|
|
1332
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1333
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1334
|
+
case 0:
|
|
1335
|
+
selections = _this.model.selections;
|
|
1336
|
+
if (!(selections.length <= 1)) {
|
|
1337
|
+
_context15.next = 3;
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
return _context15.abrupt("return");
|
|
1341
|
+
case 3:
|
|
1342
|
+
selectionsValue = [];
|
|
1343
|
+
selectionsIndex = [];
|
|
1344
|
+
selections.map(function (item) {
|
|
1345
|
+
selectionsValue.push(item.model.value);
|
|
1346
|
+
selectionsValue.push('\n');
|
|
1347
|
+
var index = _this.findCellIndex(item);
|
|
1348
|
+
selectionsIndex.push(index);
|
|
1349
|
+
});
|
|
1350
|
+
source = concatMultilineString(selectionsValue);
|
|
1351
|
+
_context15.next = 9;
|
|
1352
|
+
return _this.getCellViewByOption({
|
|
1353
|
+
id: v4(),
|
|
1354
|
+
cell: {
|
|
1355
|
+
cell_type: cell.model.type,
|
|
1356
|
+
source: source,
|
|
1357
|
+
metadata: {}
|
|
1358
|
+
}
|
|
1359
|
+
});
|
|
1360
|
+
case 9:
|
|
1361
|
+
cellView = _context15.sent;
|
|
1362
|
+
if (_this.model instanceof LibroModel) {
|
|
1363
|
+
_this.model.activeIndex = Math.min.apply(Math, selectionsIndex);
|
|
1364
|
+
cellData = [cellView].map(function (_cell) {
|
|
1365
|
+
_this.model.cellViewCache.set(_cell.model.id, _cell);
|
|
1366
|
+
return _cell.toJSON();
|
|
1367
|
+
});
|
|
1368
|
+
startIndex = Math.min.apply(Math, selectionsIndex);
|
|
1369
|
+
endIndex = Math.max.apply(Math, selectionsIndex);
|
|
1370
|
+
_this.model.sharedModel.transact(function () {
|
|
1371
|
+
_this.model.sharedModel.deleteCellRange(startIndex, endIndex + 1);
|
|
1372
|
+
_this.model.sharedModel.insertCells(Math.min.apply(Math, selectionsIndex), cellData);
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1375
|
+
case 11:
|
|
1376
|
+
case "end":
|
|
1377
|
+
return _context15.stop();
|
|
1378
|
+
}
|
|
1379
|
+
}, _callee15);
|
|
1380
|
+
}));
|
|
1381
|
+
return function (_x19) {
|
|
1382
|
+
return _ref15.apply(this, arguments);
|
|
1383
|
+
};
|
|
1384
|
+
}();
|
|
1385
|
+
_this.selectAllCell = function () {
|
|
1386
|
+
_this.model.selections = _this.model.cells;
|
|
1387
|
+
};
|
|
1388
|
+
_this.splitCell = /*#__PURE__*/function () {
|
|
1389
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(cell) {
|
|
1390
|
+
var index, selections, offsets, i, _cell$getSelectionsOf, start, end, splitCells;
|
|
1391
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
1392
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1393
|
+
case 0:
|
|
1394
|
+
index = _this.findCellIndex(cell);
|
|
1395
|
+
if (!EditorCellView.is(cell)) {
|
|
1396
|
+
_context17.next = 10;
|
|
1397
|
+
break;
|
|
1398
|
+
}
|
|
1399
|
+
selections = cell.getSelections();
|
|
1400
|
+
offsets = [0];
|
|
1401
|
+
for (i = 0; i < selections.length; i++) {
|
|
1402
|
+
// append start and end to handle selections
|
|
1403
|
+
// cursors will have same start and end
|
|
1404
|
+
_cell$getSelectionsOf = cell.getSelectionsOffsetAt(selections[i]), start = _cell$getSelectionsOf.start, end = _cell$getSelectionsOf.end;
|
|
1405
|
+
if (start < end) {
|
|
1406
|
+
offsets.push(start);
|
|
1407
|
+
offsets.push(end);
|
|
1408
|
+
} else if (end < start) {
|
|
1409
|
+
offsets.push(end);
|
|
1410
|
+
offsets.push(start);
|
|
1411
|
+
} else {
|
|
1412
|
+
offsets.push(start);
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
offsets.push(cell.model.value.length);
|
|
1416
|
+
_context17.next = 8;
|
|
1417
|
+
return Promise.all(offsets.slice(0, -1).map( /*#__PURE__*/function () {
|
|
1418
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(offset, offsetIdx) {
|
|
1419
|
+
var cellView;
|
|
1420
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
1421
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1422
|
+
case 0:
|
|
1423
|
+
_context16.next = 2;
|
|
1424
|
+
return _this.getCellViewByOption({
|
|
1425
|
+
id: v4(),
|
|
1426
|
+
cell: {
|
|
1427
|
+
cell_type: cell.model.type,
|
|
1428
|
+
source: cell.model.value.slice(offset, offsets[offsetIdx + 1]).replace(/^\n+/, '').replace(/\n+$/, ''),
|
|
1429
|
+
metadata: {}
|
|
1430
|
+
}
|
|
1431
|
+
});
|
|
1432
|
+
case 2:
|
|
1433
|
+
cellView = _context16.sent;
|
|
1434
|
+
return _context16.abrupt("return", cellView);
|
|
1435
|
+
case 4:
|
|
1436
|
+
case "end":
|
|
1437
|
+
return _context16.stop();
|
|
1438
|
+
}
|
|
1439
|
+
}, _callee16);
|
|
1440
|
+
}));
|
|
1441
|
+
return function (_x21, _x22) {
|
|
1442
|
+
return _ref17.apply(this, arguments);
|
|
1443
|
+
};
|
|
1444
|
+
}()));
|
|
1445
|
+
case 8:
|
|
1446
|
+
splitCells = _context17.sent;
|
|
1447
|
+
_this.model.splitCell(splitCells, index);
|
|
1448
|
+
case 10:
|
|
1449
|
+
case "end":
|
|
1450
|
+
return _context17.stop();
|
|
1451
|
+
}
|
|
1452
|
+
}, _callee17);
|
|
1453
|
+
}));
|
|
1454
|
+
return function (_x20) {
|
|
1455
|
+
return _ref16.apply(this, arguments);
|
|
1456
|
+
};
|
|
1457
|
+
}();
|
|
1458
|
+
_this.restartClearOutput = function () {
|
|
1459
|
+
if (_this.model.restart) {
|
|
1460
|
+
_this.model.restart();
|
|
1461
|
+
}
|
|
1462
|
+
_this.clearAllOutputs();
|
|
1463
|
+
};
|
|
1464
|
+
_this.closeAndShutdown = function () {
|
|
1465
|
+
if (_this.model.shutdown) {
|
|
1466
|
+
_this.model.shutdown();
|
|
1467
|
+
}
|
|
1468
|
+
};
|
|
1469
|
+
/**
|
|
1470
|
+
* Set the markdown header level of a cell.
|
|
1471
|
+
*/
|
|
1472
|
+
_this.setMarkdownHeader = /*#__PURE__*/function () {
|
|
1473
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(cell, level) {
|
|
1474
|
+
var selections, selectionsValue, selectionsIndex, cellViews, cellData, startIndex, endIndex, index, source, regex, newHeader, matches, cellView, _cellData;
|
|
1475
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
1476
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1477
|
+
case 0:
|
|
1478
|
+
if (!(_this.model.selections.length !== 0 && _this.isSelected(cell))) {
|
|
1479
|
+
_context19.next = 10;
|
|
1480
|
+
break;
|
|
1481
|
+
}
|
|
1482
|
+
selections = _this.model.selections;
|
|
1483
|
+
selectionsValue = [];
|
|
1484
|
+
selectionsIndex = [];
|
|
1485
|
+
_context19.next = 6;
|
|
1486
|
+
return Promise.all(selections.map( /*#__PURE__*/function () {
|
|
1487
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(item) {
|
|
1488
|
+
var source, regex, newHeader, matches, index, cellView;
|
|
1489
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
1490
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1491
|
+
case 0:
|
|
1492
|
+
source = item.model.value;
|
|
1493
|
+
regex = /^(#+\s*)|^(\s*)/;
|
|
1494
|
+
newHeader = Array(level + 1).join('#') + ' ';
|
|
1495
|
+
matches = regex.exec(source);
|
|
1496
|
+
if (matches) {
|
|
1497
|
+
source = source.slice(matches[0].length);
|
|
1498
|
+
}
|
|
1499
|
+
source = newHeader + source;
|
|
1500
|
+
selectionsValue.push(source);
|
|
1501
|
+
index = _this.findCellIndex(item);
|
|
1502
|
+
selectionsIndex.push(index);
|
|
1503
|
+
_context18.next = 11;
|
|
1504
|
+
return _this.getCellViewByOption({
|
|
1505
|
+
id: v4(),
|
|
1506
|
+
cell: {
|
|
1507
|
+
cell_type: 'markdown',
|
|
1508
|
+
source: source,
|
|
1509
|
+
metadata: {}
|
|
1510
|
+
}
|
|
1511
|
+
});
|
|
1512
|
+
case 11:
|
|
1513
|
+
cellView = _context18.sent;
|
|
1514
|
+
return _context18.abrupt("return", cellView);
|
|
1515
|
+
case 13:
|
|
1516
|
+
case "end":
|
|
1517
|
+
return _context18.stop();
|
|
1518
|
+
}
|
|
1519
|
+
}, _callee18);
|
|
1520
|
+
}));
|
|
1521
|
+
return function (_x25) {
|
|
1522
|
+
return _ref19.apply(this, arguments);
|
|
1523
|
+
};
|
|
1524
|
+
}()));
|
|
1525
|
+
case 6:
|
|
1526
|
+
cellViews = _context19.sent;
|
|
1527
|
+
// TODO: why is this needed?
|
|
1528
|
+
// const source = concatMultilineString(selectionsValue);
|
|
1529
|
+
|
|
1530
|
+
if (_this.model instanceof LibroModel) {
|
|
1531
|
+
_this.model.activeIndex = Math.min.apply(Math, selectionsIndex);
|
|
1532
|
+
cellData = cellViews.map(function (_cell) {
|
|
1533
|
+
_this.model.cellViewCache.set(_cell.model.id, _cell);
|
|
1534
|
+
return _cell.toJSON();
|
|
1535
|
+
});
|
|
1536
|
+
startIndex = Math.min.apply(Math, selectionsIndex);
|
|
1537
|
+
endIndex = Math.max.apply(Math, selectionsIndex);
|
|
1538
|
+
_this.model.sharedModel.transact(function () {
|
|
1539
|
+
_this.model.sharedModel.deleteCellRange(startIndex, endIndex + 1);
|
|
1540
|
+
_this.model.sharedModel.insertCells(startIndex, cellData);
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
_context19.next = 21;
|
|
1544
|
+
break;
|
|
1545
|
+
case 10:
|
|
1546
|
+
index = _this.findCellIndex(cell);
|
|
1547
|
+
source = cell.model.value;
|
|
1548
|
+
regex = /^(#+\s*)|^(\s*)/;
|
|
1549
|
+
newHeader = Array(level + 1).join('#') + ' ';
|
|
1550
|
+
matches = regex.exec(source);
|
|
1551
|
+
if (matches) {
|
|
1552
|
+
source = source.slice(matches[0].length);
|
|
1553
|
+
}
|
|
1554
|
+
source = newHeader + source;
|
|
1555
|
+
_context19.next = 19;
|
|
1556
|
+
return _this.getCellViewByOption({
|
|
1557
|
+
id: v4(),
|
|
1558
|
+
cell: {
|
|
1559
|
+
cell_type: 'markdown',
|
|
1560
|
+
source: source,
|
|
1561
|
+
metadata: {}
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
case 19:
|
|
1565
|
+
cellView = _context19.sent;
|
|
1566
|
+
if (_this.model instanceof LibroModel) {
|
|
1567
|
+
_this.model.activeIndex = index;
|
|
1568
|
+
_cellData = [cellView].map(function (_cell) {
|
|
1569
|
+
_this.model.cellViewCache.set(_cell.model.id, _cell);
|
|
1570
|
+
return _cell.toJSON();
|
|
1571
|
+
});
|
|
1572
|
+
_this.model.sharedModel.transact(function () {
|
|
1573
|
+
_this.model.sharedModel.deleteCell(index);
|
|
1574
|
+
_this.model.sharedModel.insertCells(index, _cellData);
|
|
1575
|
+
});
|
|
1576
|
+
}
|
|
1577
|
+
case 21:
|
|
1578
|
+
_this.enterCommandMode(true);
|
|
1579
|
+
case 22:
|
|
1580
|
+
case "end":
|
|
1581
|
+
return _context19.stop();
|
|
1582
|
+
}
|
|
1583
|
+
}, _callee19);
|
|
1584
|
+
}));
|
|
1585
|
+
return function (_x23, _x24) {
|
|
1586
|
+
return _ref18.apply(this, arguments);
|
|
1587
|
+
};
|
|
1588
|
+
}();
|
|
1589
|
+
if (_options.id) {
|
|
1590
|
+
_this.id = _options.id;
|
|
1591
|
+
}
|
|
1592
|
+
_this.notebookService = notebookService;
|
|
1593
|
+
_this.model = _this.notebookService.getOrCreateModel(_options);
|
|
1594
|
+
_this.collapseService = collapseServiceFactory({
|
|
1595
|
+
view: _assertThisInitialized(_this)
|
|
1596
|
+
});
|
|
1597
|
+
_this.collapserVisible = _this.collapseService.collapserVisible;
|
|
1598
|
+
_this.initialize();
|
|
1599
|
+
_this.initView();
|
|
1600
|
+
return _this;
|
|
1601
|
+
}
|
|
1602
|
+
LibroView = inject(NotebookService)(LibroView, undefined, 2) || LibroView;
|
|
1603
|
+
LibroView = inject(CollapseServiceFactory)(LibroView, undefined, 1) || LibroView;
|
|
1604
|
+
LibroView = inject(ViewOption)(LibroView, undefined, 0) || LibroView;
|
|
1605
|
+
_createClass(LibroView, [{
|
|
1606
|
+
key: "onCellCreate",
|
|
1607
|
+
get: function get() {
|
|
1608
|
+
return this.onCellCreateEmitter.event;
|
|
1609
|
+
}
|
|
1610
|
+
}, {
|
|
1611
|
+
key: "onBlur",
|
|
1612
|
+
get: function get() {
|
|
1613
|
+
return this.onBlurEmitter.event;
|
|
1614
|
+
}
|
|
1615
|
+
}, {
|
|
1616
|
+
key: "hasModal",
|
|
1617
|
+
get: function get() {
|
|
1618
|
+
return this.model.cells.some(function (item) {
|
|
1619
|
+
return item.hasModal;
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
}, {
|
|
1623
|
+
key: "onSave",
|
|
1624
|
+
get: function get() {
|
|
1625
|
+
return this.onSaveEmitter.event;
|
|
1626
|
+
}
|
|
1627
|
+
}, {
|
|
1628
|
+
key: "onRunCell",
|
|
1629
|
+
get: function get() {
|
|
1630
|
+
return this.runCellEmitter.event;
|
|
1631
|
+
}
|
|
1632
|
+
}, {
|
|
1633
|
+
key: "initialized",
|
|
1634
|
+
get: function get() {
|
|
1635
|
+
return this.initializedDefer.promise;
|
|
1636
|
+
}
|
|
1637
|
+
}, {
|
|
1638
|
+
key: "initView",
|
|
1639
|
+
value: function initView() {
|
|
1640
|
+
// this.configurationService.get(TOCVisible).then(() => {
|
|
1641
|
+
// this.viewManager.getOrCreateView(MarkdownCellTocView, { id: this.id }).then(toc => {
|
|
1642
|
+
// this.toc = toc;
|
|
1643
|
+
// toc.parent = this;
|
|
1644
|
+
// });
|
|
1645
|
+
// });
|
|
1646
|
+
// this.viewManager
|
|
1647
|
+
// .getOrCreateView(LibroKeybindInstrutionsView, { id: 'libro-keybind-instructions' })
|
|
1648
|
+
// .then(keybindInstrutions => {
|
|
1649
|
+
// this.keybindInstrutionsView = keybindInstrutions;
|
|
1650
|
+
// });
|
|
1651
|
+
}
|
|
1652
|
+
}, {
|
|
1653
|
+
key: "initialize",
|
|
1654
|
+
value: function () {
|
|
1655
|
+
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20() {
|
|
1656
|
+
var _this2 = this;
|
|
1657
|
+
var options;
|
|
1658
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
1659
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1660
|
+
case 0:
|
|
1661
|
+
this.model.isInitialized = false;
|
|
1662
|
+
_context20.next = 3;
|
|
1663
|
+
return this.model.initialize();
|
|
1664
|
+
case 3:
|
|
1665
|
+
options = _context20.sent;
|
|
1666
|
+
this.configurationService.get(AutoInsertWhenNoCell).then(function (value) {
|
|
1667
|
+
var isAutoInsertWhenNoCell = value;
|
|
1668
|
+
if (isAutoInsertWhenNoCell && options.length === 0) {
|
|
1669
|
+
_this2.addCell({
|
|
1670
|
+
id: v4(),
|
|
1671
|
+
cell: {
|
|
1672
|
+
cell_type: 'code',
|
|
1673
|
+
source: '',
|
|
1674
|
+
metadata: {}
|
|
1675
|
+
}
|
|
1676
|
+
}, 0);
|
|
1677
|
+
}
|
|
1678
|
+
return;
|
|
1679
|
+
}).catch(function () {
|
|
1680
|
+
//
|
|
1681
|
+
});
|
|
1682
|
+
_context20.next = 7;
|
|
1683
|
+
return this.insertCells(options);
|
|
1684
|
+
case 7:
|
|
1685
|
+
// 第一次insert不需要历史
|
|
1686
|
+
setTimeout(function () {
|
|
1687
|
+
_this2.model.sharedModel.clearUndoHistory();
|
|
1688
|
+
// 未初始化完成不做渲染,防止重复渲染多次
|
|
1689
|
+
_this2.model.isInitialized = true;
|
|
1690
|
+
_this2.configurationService.get(EnterEditModeWhenAddCell).then(function (value) {
|
|
1691
|
+
if (value) {
|
|
1692
|
+
_this2.enterEditMode();
|
|
1693
|
+
} else {
|
|
1694
|
+
_this2.enterCommandMode(true);
|
|
1695
|
+
}
|
|
1696
|
+
return;
|
|
1697
|
+
}).catch(function () {
|
|
1698
|
+
//
|
|
1699
|
+
});
|
|
1700
|
+
_this2.toDispose.push(watch(_this2.model, 'cells', function () {
|
|
1701
|
+
var _this2$model$onChange, _this2$model;
|
|
1702
|
+
(_this2$model$onChange = (_this2$model = _this2.model).onChange) === null || _this2$model$onChange === void 0 ? void 0 : _this2$model$onChange.call(_this2$model);
|
|
1703
|
+
}));
|
|
1704
|
+
_this2.initializedDefer.resolve();
|
|
1705
|
+
}, 0);
|
|
1706
|
+
case 8:
|
|
1707
|
+
case "end":
|
|
1708
|
+
return _context20.stop();
|
|
1709
|
+
}
|
|
1710
|
+
}, _callee20, this);
|
|
1711
|
+
}));
|
|
1712
|
+
function initialize() {
|
|
1713
|
+
return _initialize.apply(this, arguments);
|
|
1714
|
+
}
|
|
1715
|
+
return initialize;
|
|
1716
|
+
}()
|
|
1717
|
+
}, {
|
|
1718
|
+
key: "getCellViewByOption",
|
|
1719
|
+
value: function () {
|
|
1720
|
+
var _getCellViewByOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(option) {
|
|
1721
|
+
var _this3 = this;
|
|
1722
|
+
var toDispose, cellView, disposable;
|
|
1723
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
1724
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1725
|
+
case 0:
|
|
1726
|
+
toDispose = new DisposableCollection();
|
|
1727
|
+
option.cell.metadata.trusted = this.model.trusted;
|
|
1728
|
+
_context21.next = 4;
|
|
1729
|
+
return this.cellService.getOrCreateView(option, this.id);
|
|
1730
|
+
case 4:
|
|
1731
|
+
cellView = _context21.sent;
|
|
1732
|
+
cellView.parent = this;
|
|
1733
|
+
this.onCellCreateEmitter.fire(cellView);
|
|
1734
|
+
toDispose.push(Disposable.create(function () {
|
|
1735
|
+
_this3.deleteCell(cellView);
|
|
1736
|
+
}));
|
|
1737
|
+
disposable = cellView.onDisposed(function () {
|
|
1738
|
+
toDispose.dispose();
|
|
1739
|
+
});
|
|
1740
|
+
toDispose.push(disposable);
|
|
1741
|
+
return _context21.abrupt("return", cellView);
|
|
1742
|
+
case 11:
|
|
1743
|
+
case "end":
|
|
1744
|
+
return _context21.stop();
|
|
1745
|
+
}
|
|
1746
|
+
}, _callee21, this);
|
|
1747
|
+
}));
|
|
1748
|
+
function getCellViewByOption(_x26) {
|
|
1749
|
+
return _getCellViewByOption.apply(this, arguments);
|
|
1750
|
+
}
|
|
1751
|
+
return getCellViewByOption;
|
|
1752
|
+
}()
|
|
1753
|
+
}, {
|
|
1754
|
+
key: "activeCell",
|
|
1755
|
+
get: function get() {
|
|
1756
|
+
return this.model.active;
|
|
1757
|
+
}
|
|
1758
|
+
}, {
|
|
1759
|
+
key: "executeCellRun",
|
|
1760
|
+
value: function executeCellRun(cell) {
|
|
1761
|
+
this.runCellEmitter.fire(cell);
|
|
1762
|
+
return cell.run();
|
|
1763
|
+
}
|
|
1764
|
+
}, {
|
|
1765
|
+
key: "getPreviousVisibleCell",
|
|
1766
|
+
value: function getPreviousVisibleCell(cell) {
|
|
1767
|
+
var _this4 = this;
|
|
1768
|
+
var currentIndex = this.findCellIndex(cell);
|
|
1769
|
+
return this.model.cells.slice().reverse().find(function (item, index) {
|
|
1770
|
+
return index > _this4.model.cells.length - currentIndex - 1 && item.collapsedHidden === false;
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}, {
|
|
1774
|
+
key: "getNextVisibleCell",
|
|
1775
|
+
value: function getNextVisibleCell(cell) {
|
|
1776
|
+
var currentIndex = this.findCellIndex(cell);
|
|
1777
|
+
return this.model.cells.find(function (item, index) {
|
|
1778
|
+
return index > currentIndex && item.collapsedHidden === false;
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
}, {
|
|
1782
|
+
key: "isSelected",
|
|
1783
|
+
value:
|
|
1784
|
+
/**
|
|
1785
|
+
* Whether a cell is selected.
|
|
1786
|
+
*/
|
|
1787
|
+
function isSelected(cell) {
|
|
1788
|
+
if (this.activeCell === cell) {
|
|
1789
|
+
return true;
|
|
1790
|
+
}
|
|
1791
|
+
if (this.model.selections.length !== 0) {
|
|
1792
|
+
return this.model.selections.findIndex(function (item) {
|
|
1793
|
+
return item.id === cell.id;
|
|
1794
|
+
}) >= 0 ? true : false;
|
|
1795
|
+
}
|
|
1796
|
+
return false;
|
|
1797
|
+
}
|
|
1798
|
+
}, {
|
|
1799
|
+
key: "extendContiguousSelectionTo",
|
|
1800
|
+
value:
|
|
1801
|
+
/**
|
|
1802
|
+
* Move the head of an existing contiguous selection to extend the selection.
|
|
1803
|
+
*
|
|
1804
|
+
* @param index - The new head of the existing selection.
|
|
1805
|
+
*
|
|
1806
|
+
* #### Notes
|
|
1807
|
+
* If there is no existing selection, the active cell is considered an
|
|
1808
|
+
* existing one-cell selection.
|
|
1809
|
+
*
|
|
1810
|
+
* If the new selection is a single cell, that cell becomes the active cell
|
|
1811
|
+
* and all cells are deselected.
|
|
1812
|
+
*
|
|
1813
|
+
* There is no change if there are no cells (i.e., activeCellIndex is -1).
|
|
1814
|
+
*/
|
|
1815
|
+
function extendContiguousSelectionTo(index) {
|
|
1816
|
+
var selectIndex = index;
|
|
1817
|
+
var _this$getContiguousSe = this.getContiguousSelection(),
|
|
1818
|
+
head = _this$getContiguousSe.head,
|
|
1819
|
+
anchor = _this$getContiguousSe.anchor;
|
|
1820
|
+
if (this.activeCell) {
|
|
1821
|
+
// Handle the case of no current selection.
|
|
1822
|
+
if (anchor === null || head === null) {
|
|
1823
|
+
if (selectIndex === this.model.activeIndex) {
|
|
1824
|
+
// Already collapsed selection, nothing more to do.
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
// We will start a new selection below.
|
|
1829
|
+
head = this.model.activeIndex;
|
|
1830
|
+
anchor = this.model.activeIndex;
|
|
1831
|
+
}
|
|
1832
|
+
// Move the active cell. We do this before the collapsing shortcut below.
|
|
1833
|
+
if (this.model.cells[selectIndex]) {
|
|
1834
|
+
this.model.active = this.model.cells[selectIndex];
|
|
1835
|
+
this.model.activeIndex = selectIndex;
|
|
1836
|
+
}
|
|
1837
|
+
// Make sure the index is valid, according to the rules for setting and clipping the
|
|
1838
|
+
// active cell index. This may change the index.
|
|
1839
|
+
selectIndex = this.model.activeIndex;
|
|
1840
|
+
|
|
1841
|
+
// Collapse the selection if it is only the active cell.
|
|
1842
|
+
if (selectIndex === anchor) {
|
|
1843
|
+
// this.deselectAll();
|
|
1844
|
+
this.model.selections = [];
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
this.model.selections = this.model.cells.slice(Math.min(anchor, selectIndex), Math.max(anchor, selectIndex) + 1);
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
|
|
1851
|
+
/**
|
|
1852
|
+
* Get the head and anchor of a contiguous cell selection.
|
|
1853
|
+
*
|
|
1854
|
+
* The head of a contiguous selection is always the active cell.
|
|
1855
|
+
*
|
|
1856
|
+
* If there are no cells selected, `{head: null, anchor: null}` is returned.
|
|
1857
|
+
*
|
|
1858
|
+
* Throws an error if the currently selected cells do not form a contiguous
|
|
1859
|
+
* selection.
|
|
1860
|
+
*/
|
|
1861
|
+
}, {
|
|
1862
|
+
key: "getContiguousSelection",
|
|
1863
|
+
value: function getContiguousSelection() {
|
|
1864
|
+
if (this.model.selections.length !== 0 && this.activeCell) {
|
|
1865
|
+
var first = this.findCellIndex(this.model.selections[0]);
|
|
1866
|
+
var last = this.findCellIndex(this.model.selections[this.model.selections.length - 1]);
|
|
1867
|
+
// Check that the active cell is one of the endpoints of the selection.
|
|
1868
|
+
var activeIndex = this.findCellIndex(this.activeCell);
|
|
1869
|
+
if (first !== activeIndex && last !== activeIndex) {
|
|
1870
|
+
throw new Error('Active cell not at endpoint of selection');
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
// Determine the head and anchor of the selection.
|
|
1874
|
+
if (first === activeIndex) {
|
|
1875
|
+
return {
|
|
1876
|
+
head: first,
|
|
1877
|
+
anchor: last
|
|
1878
|
+
};
|
|
1879
|
+
} else {
|
|
1880
|
+
return {
|
|
1881
|
+
head: last,
|
|
1882
|
+
anchor: first
|
|
1883
|
+
};
|
|
1884
|
+
}
|
|
1885
|
+
}
|
|
1886
|
+
return {
|
|
1887
|
+
head: null,
|
|
1888
|
+
anchor: null
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
}, {
|
|
1892
|
+
key: "dispose",
|
|
1893
|
+
value: function dispose() {
|
|
1894
|
+
if (!this.disposed) {
|
|
1895
|
+
this.libroService.deleteLibroViewFromCache(this);
|
|
1896
|
+
this.toDispose.dispose();
|
|
1897
|
+
}
|
|
1898
|
+
this.disposed = true;
|
|
1899
|
+
}
|
|
1900
|
+
}, {
|
|
1901
|
+
key: "collapseCell",
|
|
1902
|
+
value: function collapseCell(cell, collspse) {
|
|
1903
|
+
this.collapseService.setHeadingCollapse(cell, collspse);
|
|
1904
|
+
}
|
|
1905
|
+
}, {
|
|
1906
|
+
key: "save",
|
|
1907
|
+
value: function save() {
|
|
1908
|
+
this.saving = true;
|
|
1909
|
+
try {
|
|
1910
|
+
this.model.saveNotebookContent();
|
|
1911
|
+
this.onSaveEmitter.fire(true);
|
|
1912
|
+
this.model.dirty = false;
|
|
1913
|
+
} catch (ex) {
|
|
1914
|
+
this.onSaveEmitter.fire(false);
|
|
1915
|
+
} finally {
|
|
1916
|
+
this.saving = false;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
}]);
|
|
1920
|
+
return LibroView;
|
|
1921
|
+
}(BaseView), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "cellService", [_dec3], {
|
|
1922
|
+
configurable: true,
|
|
1923
|
+
enumerable: true,
|
|
1924
|
+
writable: true,
|
|
1925
|
+
initializer: null
|
|
1926
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "libroService", [_dec4], {
|
|
1927
|
+
configurable: true,
|
|
1928
|
+
enumerable: true,
|
|
1929
|
+
writable: true,
|
|
1930
|
+
initializer: null
|
|
1931
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class2.prototype, "libroSlotManager", [_dec5], {
|
|
1932
|
+
configurable: true,
|
|
1933
|
+
enumerable: true,
|
|
1934
|
+
writable: true,
|
|
1935
|
+
initializer: null
|
|
1936
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class2.prototype, "contextKey", [_dec6], {
|
|
1937
|
+
configurable: true,
|
|
1938
|
+
enumerable: true,
|
|
1939
|
+
writable: true,
|
|
1940
|
+
initializer: null
|
|
1941
|
+
}), _descriptor5 = _applyDecoratedDescriptor(_class2.prototype, "viewManager", [_dec7], {
|
|
1942
|
+
configurable: true,
|
|
1943
|
+
enumerable: true,
|
|
1944
|
+
writable: true,
|
|
1945
|
+
initializer: null
|
|
1946
|
+
}), _descriptor6 = _applyDecoratedDescriptor(_class2.prototype, "configurationService", [_dec8], {
|
|
1947
|
+
configurable: true,
|
|
1948
|
+
enumerable: true,
|
|
1949
|
+
writable: true,
|
|
1950
|
+
initializer: null
|
|
1951
|
+
}), _descriptor7 = _applyDecoratedDescriptor(_class2.prototype, "collapserVisible", [_dec9], {
|
|
1952
|
+
configurable: true,
|
|
1953
|
+
enumerable: true,
|
|
1954
|
+
writable: true,
|
|
1955
|
+
initializer: function initializer() {
|
|
1956
|
+
return false;
|
|
1957
|
+
}
|
|
1958
|
+
}), _descriptor8 = _applyDecoratedDescriptor(_class2.prototype, "saving", [_dec10], {
|
|
1959
|
+
configurable: true,
|
|
1960
|
+
enumerable: true,
|
|
1961
|
+
writable: true,
|
|
1962
|
+
initializer: null
|
|
1963
|
+
})), _class2)) || _class) || _class);
|