@worktile/theia 3.0.0-next.4 → 3.0.0-next.5

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('slate-angular'), require('ngx-tethys/core'), require('is-hotkey'), require('slate'), require('slate-history'), require('rxjs'), require('ngx-tethys/popover'), require('ngx-tethys/icon'), require('ngx-tethys/input'), require('@atinc/selene'), require('lodash'), require('@angular/cdk/overlay'), require('marked'), require('ngx-tethys/alert'), require('rxjs/operators'), require('ngx-tethys/uploader'), require('@angular/platform-browser'), require('ngx-tethys/progress'), require('ngx-tethys/nav'), require('ngx-tethys/tooltip'), require('ng-codemirror'), require('ngx-tethys/notify'), require('ngx-tethys/action-menu'), require('ngx-tethys/switch'), require('ngx-tethys/resizable'), require('is-url'), require('ngx-tethys/button'), require('ngx-tethys/form'), require('ngx-tethys/shared'), require('ngx-tethys'), require('@angular/cdk/coercion'), require('@angular/cdk/portal'), require('ngx-tethys/list'), require('ngx-tethys/autocomplete'), require('ngx-tethys/avatar'), require('ngx-tethys/select')) :
3
- typeof define === 'function' && define.amd ? define('@worktile/theia', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'slate-angular', 'ngx-tethys/core', 'is-hotkey', 'slate', 'slate-history', 'rxjs', 'ngx-tethys/popover', 'ngx-tethys/icon', 'ngx-tethys/input', '@atinc/selene', 'lodash', '@angular/cdk/overlay', 'marked', 'ngx-tethys/alert', 'rxjs/operators', 'ngx-tethys/uploader', '@angular/platform-browser', 'ngx-tethys/progress', 'ngx-tethys/nav', 'ngx-tethys/tooltip', 'ng-codemirror', 'ngx-tethys/notify', 'ngx-tethys/action-menu', 'ngx-tethys/switch', 'ngx-tethys/resizable', 'is-url', 'ngx-tethys/button', 'ngx-tethys/form', 'ngx-tethys/shared', 'ngx-tethys', '@angular/cdk/coercion', '@angular/cdk/portal', 'ngx-tethys/list', 'ngx-tethys/autocomplete', 'ngx-tethys/avatar', 'ngx-tethys/select'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.worktile = global.worktile || {}, global.worktile.theia = {}), global.ng.core, global.ng.common, global.ng.forms, global.i1, global.core, global.isHotkey, global.slate, global.slateHistory, global.rxjs, global.i1$1, global.i4, global.i5, global.selene, global._lodash, global.ng.cdk.overlay, global.marked, global.i1$2, global.rxjs.operators, global.uploader, global.ng.platformBrowser, global.i6, global.i3, global.i5$1, global.i8, global.i1$4, global.i2$1, global.i5$2, global.i9, global.isUrl, global.i1$5, global.i2$2, global.i5$3, global.i1$6, global.ng.cdk.coercion, global.ng.cdk.portal, global.i1$7, global.autocomplete, global.avatar, global.select));
5
- })(this, (function (exports, i0, i10, i4$1, i1, core, isHotkey, slate, slateHistory, rxjs, i1$1, i4, i5, selene, _lodash, i2, marked, i1$2, operators, uploader, i1$3, i6, i3, i5$1, i8, i1$4, i2$1, i5$2, i9, isUrl, i1$5, i2$2, i5$3, i1$6, coercion, portal, i1$7, autocomplete, avatar, select) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/forms'), require('slate-angular'), require('ngx-tethys/core'), require('is-hotkey'), require('slate'), require('slate-history'), require('rxjs'), require('ngx-tethys/popover'), require('ngx-tethys/icon'), require('ngx-tethys/input'), require('@atinc/selene'), require('lodash'), require('ngx-tethys/util'), require('@angular/cdk/overlay'), require('marked'), require('ngx-tethys/alert'), require('rxjs/operators'), require('ngx-tethys/uploader'), require('@angular/platform-browser'), require('ngx-tethys/progress'), require('ngx-tethys/nav'), require('ngx-tethys/tooltip'), require('ng-codemirror'), require('ngx-tethys/notify'), require('ngx-tethys/action-menu'), require('ngx-tethys/switch'), require('ngx-tethys/resizable'), require('is-url'), require('ngx-tethys/button'), require('ngx-tethys/form'), require('ngx-tethys/shared'), require('ngx-tethys'), require('@angular/cdk/coercion'), require('@angular/cdk/portal'), require('ngx-tethys/list'), require('ngx-tethys/autocomplete'), require('ngx-tethys/avatar'), require('ngx-tethys/select')) :
3
+ typeof define === 'function' && define.amd ? define('@worktile/theia', ['exports', '@angular/core', '@angular/common', '@angular/forms', 'slate-angular', 'ngx-tethys/core', 'is-hotkey', 'slate', 'slate-history', 'rxjs', 'ngx-tethys/popover', 'ngx-tethys/icon', 'ngx-tethys/input', '@atinc/selene', 'lodash', 'ngx-tethys/util', '@angular/cdk/overlay', 'marked', 'ngx-tethys/alert', 'rxjs/operators', 'ngx-tethys/uploader', '@angular/platform-browser', 'ngx-tethys/progress', 'ngx-tethys/nav', 'ngx-tethys/tooltip', 'ng-codemirror', 'ngx-tethys/notify', 'ngx-tethys/action-menu', 'ngx-tethys/switch', 'ngx-tethys/resizable', 'is-url', 'ngx-tethys/button', 'ngx-tethys/form', 'ngx-tethys/shared', 'ngx-tethys', '@angular/cdk/coercion', '@angular/cdk/portal', 'ngx-tethys/list', 'ngx-tethys/autocomplete', 'ngx-tethys/avatar', 'ngx-tethys/select'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.worktile = global.worktile || {}, global.worktile.theia = {}), global.ng.core, global.ng.common, global.ng.forms, global.i1, global.core, global.isHotkey, global.slate, global.slateHistory, global.rxjs, global.i1$1, global.i4, global.i5, global.selene, global._lodash, global.util, global.ng.cdk.overlay, global.marked, global.i1$2, global.rxjs.operators, global.uploader, global.ng.platformBrowser, global.i6, global.i3, global.i5$1, global.i8, global.i1$4, global.i2$1, global.i5$2, global.i9, global.isUrl, global.i1$5, global.i2$2, global.i5$3, global.i1$6, global.ng.cdk.coercion, global.ng.cdk.portal, global.i1$7, global.autocomplete, global.avatar, global.select));
5
+ })(this, (function (exports, i0, i10, i4$1, i1, core, isHotkey, slate, slateHistory, rxjs, i1$1, i4, i5, selene, _lodash, util, i2, marked, i1$2, operators, uploader, i1$3, i6, i3, i5$1, i8, i1$4, i2$1, i5$2, i9, isUrl, i1$5, i2$2, i5$3, i1$6, coercion, portal, i1$7, autocomplete, avatar, select) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
@@ -1445,7 +1445,10 @@
1445
1445
  newOptions[option] = _.union(options[option], override.options[option]);
1446
1446
  continue;
1447
1447
  }
1448
- newOptions[option] = options[option];
1448
+ if (util.isObject(options[option])) {
1449
+ newOptions[option] = _.assign(options[option], override.options[option]);
1450
+ }
1451
+ newOptions[option] = override.options[option];
1449
1452
  }
1450
1453
  plugin.options = newOptions;
1451
1454
  return plugin;
@@ -2363,18 +2366,78 @@
2363
2366
  return parentEntry;
2364
2367
  };
2365
2368
 
2366
- var isTypesInParent = function (editor, types) {
2367
- if (!Array.isArray(types)) {
2368
- types = [types];
2369
- }
2369
+ var getInsertElementsPath = function (editor, allowParentTypes) {
2370
2370
  var _a = __read(getBlockAbove(editor), 2), anchorPath = _a[1];
2371
2371
  if (!anchorPath)
2372
2372
  return false;
2373
- var parentEntry = slate.Editor.above(editor, { match: function (n) { return types.includes(n.type); } });
2373
+ var parentEntry = slate.Editor.above(editor, { match: function (n) { return slate.Editor.isBlock(editor, n) && allowParentTypes.includes(n.type); } });
2374
2374
  if (!parentEntry)
2375
2375
  return false;
2376
- var _b = __read(parentEntry, 1), parentNode = _b[0];
2377
- return types.includes(parentNode.type);
2376
+ var _b = __read(anchorBlockEntry(editor), 2), anchorBlockPath = _b[1];
2377
+ var currentNodePath = anchorBlockPath.slice(0, parentEntry[1].length + 1);
2378
+ var illegalParentEntry = null;
2379
+ var _loop_1 = function () {
2380
+ var _illegalParentEntry = parentEntry &&
2381
+ slate.Editor.above(editor, {
2382
+ mode: 'lowest',
2383
+ at: parentEntry[1],
2384
+ match: function (n) { return n.type && !allowParentTypes.includes(n.type); }
2385
+ });
2386
+ if (_illegalParentEntry) {
2387
+ var childType = editor.nestedStructureByKey[_illegalParentEntry[0].type];
2388
+ if (!childType) {
2389
+ illegalParentEntry = _illegalParentEntry;
2390
+ }
2391
+ if (allowParentTypes.includes(childType)) {
2392
+ var rootKey_1 = findNestedStructureRootType(editor, _illegalParentEntry[0].type, '');
2393
+ parentEntry =
2394
+ parentEntry &&
2395
+ slate.Editor.above(editor, {
2396
+ mode: 'lowest',
2397
+ at: parentEntry[1],
2398
+ match: function (n) { return n.type && n.type === rootKey_1; }
2399
+ });
2400
+ }
2401
+ else {
2402
+ parentEntry = _illegalParentEntry;
2403
+ }
2404
+ }
2405
+ else {
2406
+ return "break";
2407
+ }
2408
+ };
2409
+ // 循环获取最外层的不可插入节点
2410
+ while (true) {
2411
+ var state_1 = _loop_1();
2412
+ if (state_1 === "break")
2413
+ break;
2414
+ }
2415
+ // 获取不可插入节点的根层节点
2416
+ if (illegalParentEntry) {
2417
+ var rootKey_2 = findNestedStructureRootType(editor, illegalParentEntry[0].type, '');
2418
+ if (rootKey_2 && illegalParentEntry[0].type !== rootKey_2) {
2419
+ illegalParentEntry = slate.Editor.above(editor, {
2420
+ mode: 'lowest',
2421
+ at: parentEntry[1],
2422
+ match: function (n) { return n.type && n.type === rootKey_2; }
2423
+ });
2424
+ }
2425
+ currentNodePath = illegalParentEntry && illegalParentEntry[1];
2426
+ }
2427
+ return currentNodePath && slate.Path.next(currentNodePath);
2428
+ };
2429
+ // 获取具有嵌套关系的根类型
2430
+ var findNestedStructureRootType = function (editor, type, rootKey) {
2431
+ var parentKey = _lodash__namespace.findKey(editor.nestedStructureByKey, function (value) {
2432
+ return value === type;
2433
+ });
2434
+ if (parentKey) {
2435
+ rootKey = parentKey;
2436
+ return findNestedStructureRootType(editor, parentKey, rootKey);
2437
+ }
2438
+ else {
2439
+ return rootKey || type;
2440
+ }
2378
2441
  };
2379
2442
 
2380
2443
  var isContainNestedType = function (editor, types) {
@@ -2452,7 +2515,7 @@
2452
2515
  isBlockCardCursor: isBlockCardCursor,
2453
2516
  isEmptyParagraphByPath: isEmptyParagraphByPath,
2454
2517
  isContainer: isContainer,
2455
- isTypesInParent: isTypesInParent,
2518
+ getInsertElementsPath: getInsertElementsPath,
2456
2519
  isContainNestedType: isContainNestedType,
2457
2520
  anchorBlock: anchorBlock,
2458
2521
  anchorBlockEntry: anchorBlockEntry,
@@ -2470,19 +2533,13 @@
2470
2533
  }
2471
2534
  var type = element.type;
2472
2535
  var allowParentTypes = ((_a = getPluginOptions(editor, type)) === null || _a === void 0 ? void 0 : _a.allowParentTypes) || [];
2473
- var isAllowInsert = isTypesInParent(editor, allowParentTypes);
2536
+ var insertNodePath = getInsertElementsPath(editor, allowParentTypes);
2474
2537
  var _b = __read(anchorBlockEntry(editor), 2), anchorBlock = _b[0], anchorBlockPath = _b[1];
2475
2538
  var isEmpty = slate.Editor.isEmpty(editor, anchorBlock);
2476
- var isContainNested = isContainNestedType(editor, allowParentTypes);
2477
- if (isAllowInsert && isContainNested) {
2478
- var _c = __read(slate.Editor.above(editor, {
2479
- match: function (n) { return slate.Editor.isBlock(editor, n) && allowParentTypes.includes(n.type); },
2480
- at: editor.selection
2481
- }), 2), containerPath_1 = _c[1];
2539
+ if (insertNodePath) {
2482
2540
  slate.Editor.withoutNormalizing(editor, function () {
2483
- var containerPathFirstPath = anchorBlockPath.slice(0, containerPath_1.length + 1);
2484
- slate.Transforms.insertNodes(editor, element, { at: slate.Path.next(containerPathFirstPath) });
2485
- slate.Transforms.select(editor, slate.Editor.start(editor, slate.Path.next(containerPathFirstPath)));
2541
+ slate.Transforms.insertNodes(editor, element, { at: insertNodePath });
2542
+ slate.Transforms.select(editor, slate.Editor.start(editor, insertNodePath));
2486
2543
  if (isEmpty) {
2487
2544
  slate.Transforms.removeNodes(editor, { at: anchorBlockPath });
2488
2545
  }
@@ -4708,8 +4765,8 @@
4708
4765
  }
4709
4766
  ],
4710
4767
  nestedStructureByKey: (_c = {},
4711
- _c[exports.ElementKinds.bulletedList] = [exports.ElementKinds.listItem],
4712
- _c[exports.ElementKinds.numberedList] = [exports.ElementKinds.listItem],
4768
+ _c[exports.ElementKinds.bulletedList] = exports.ElementKinds.listItem,
4769
+ _c[exports.ElementKinds.numberedList] = exports.ElementKinds.listItem,
4713
4770
  _c),
4714
4771
  toolbarItems: [
4715
4772
  {
@@ -12046,8 +12103,8 @@
12046
12103
  key: exports.PluginKeys.table,
12047
12104
  withOverrides: withTable,
12048
12105
  nestedStructureByKey: (_a = {},
12049
- _a[exports.ElementKinds.table] = [exports.ElementKinds.tableRow],
12050
- _a[exports.ElementKinds.tableRow] = [exports.ElementKinds.tableCell],
12106
+ _a[exports.ElementKinds.table] = exports.ElementKinds.tableRow,
12107
+ _a[exports.ElementKinds.tableRow] = exports.ElementKinds.tableCell,
12051
12108
  _a),
12052
12109
  toolbarItems: [
12053
12110
  {