@worktile/theia 3.0.0-next.2 → 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.
- package/bundles/worktile-theia.umd.js +281 -232
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/core/utils/combine-plugins.d.ts +2 -0
- package/core/utils/get-plugin-by-key.d.ts +2 -0
- package/core/utils/index.d.ts +5 -2
- package/core/utils/merge-deep-plugins.d.ts +2 -0
- package/core/utils/merge-options.d.ts +2 -2
- package/core/utils/nested-structure-by-key.d.ts +2 -0
- package/core/utils/plugins-by-key.d.ts +2 -0
- package/esm2015/core/create-plugin.js +2 -4
- package/esm2015/core/utils/combine-plugins.js +10 -0
- package/esm2015/core/utils/flatten-deep-plugins.js +2 -20
- package/esm2015/core/utils/get-plugin-by-key.js +8 -0
- package/esm2015/core/utils/get-plugin.js +3 -3
- package/esm2015/core/utils/index.js +6 -3
- package/esm2015/core/utils/merge-deep-plugins.js +16 -0
- package/esm2015/core/utils/merge-options.js +6 -2
- package/esm2015/core/utils/nested-structure-by-key.js +11 -0
- package/esm2015/core/utils/plugins-by-key.js +10 -0
- package/esm2015/core/with-theia.js +9 -22
- package/esm2015/editor.component.js +2 -3
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/interfaces/utility/nested-structure-by-key.js +1 -1
- package/esm2015/plugins/autoformat/autoformat.plugin.js +11 -11
- package/esm2015/plugins/blockquote/blockquote.editor.js +8 -8
- package/esm2015/plugins/code/code.editor.js +3 -3
- package/esm2015/plugins/hr/hr.editor.js +2 -2
- package/esm2015/plugins/list/list.editor.js +1 -2
- package/esm2015/plugins/list/list.plugin.js +3 -3
- package/esm2015/plugins/quick-insert/quick-insert.plugin.js +4 -4
- package/esm2015/plugins/table/table.plugin.js +3 -3
- package/esm2015/plugins/table/transforms/insert-table.js +2 -2
- package/esm2015/plugins/todo-item/todo-item.component.js +8 -9
- package/esm2015/plugins/todo-item/todo-item.plugin.js +3 -2
- package/esm2015/queries/get-insert-elements-path.js +73 -0
- package/esm2015/queries/index.js +3 -3
- package/esm2015/transforms/index.js +3 -4
- package/esm2015/transforms/insert-elements.js +34 -0
- package/fesm2015/worktile-theia.js +262 -223
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/editor.d.ts +1 -7
- package/interfaces/utility/nested-structure-by-key.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/autoformat/autoformat.plugin.d.ts +5 -1
- package/plugins/quick-insert/quick-insert.plugin.d.ts +2 -0
- package/plugins/todo-item/todo-item.component.d.ts +1 -0
- package/plugins/todo-item/todo-item.plugin.d.ts +4 -1
- package/queries/get-insert-elements-path.d.ts +4 -0
- package/queries/index.d.ts +2 -2
- package/transforms/index.d.ts +2 -3
- package/transforms/insert-elements.d.ts +2 -0
- package/core/utils/get-plugins-by-key.d.ts +0 -2
- package/core/utils/override-plugins-by-key.d.ts +0 -5
- package/esm2015/core/utils/get-plugins-by-key.js +0 -8
- package/esm2015/core/utils/override-plugins-by-key.js +0 -27
- package/esm2015/queries/is-types-in-parent.js +0 -16
- package/esm2015/transforms/insert-element-next.js +0 -40
- package/esm2015/transforms/insert-element.js +0 -2
- package/queries/is-types-in-parent.d.ts +0 -2
- package/transforms/insert-element-next.d.ts +0 -2
- package/transforms/insert-element.d.ts +0 -3
|
@@ -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
|
|
|
@@ -1415,24 +1415,7 @@
|
|
|
1415
1415
|
p.options = {};
|
|
1416
1416
|
if (!p.nestedStructureByKey)
|
|
1417
1417
|
p.nestedStructureByKey = {};
|
|
1418
|
-
|
|
1419
|
-
for (var key in p.nestedStructureByKey) {
|
|
1420
|
-
if (!editor.nestedStructureByKey[key]) {
|
|
1421
|
-
editor.nestedStructureByKey[key] = p.nestedStructureByKey[key];
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
if (!editor.pluginsByKey[p.key]) {
|
|
1425
|
-
editor.plugins.push(p);
|
|
1426
|
-
editor.pluginsByKey[p.key] = p;
|
|
1427
|
-
}
|
|
1428
|
-
else {
|
|
1429
|
-
var index = editor.plugins.indexOf(editor.pluginsByKey[p.key]);
|
|
1430
|
-
var mergedPlugin = _.defaultsDeep(p, editor.pluginsByKey[p.key]);
|
|
1431
|
-
if (index >= 0) {
|
|
1432
|
-
editor.plugins[index] = mergedPlugin;
|
|
1433
|
-
}
|
|
1434
|
-
editor.pluginsByKey[p.key] = mergedPlugin;
|
|
1435
|
-
}
|
|
1418
|
+
editor.plugins.push(p);
|
|
1436
1419
|
flattenDeepPlugins(editor, p.plugins);
|
|
1437
1420
|
});
|
|
1438
1421
|
};
|
|
@@ -1442,7 +1425,7 @@
|
|
|
1442
1425
|
return (_a = editor === null || editor === void 0 ? void 0 : editor.plugins) !== null && _a !== void 0 ? _a : [];
|
|
1443
1426
|
};
|
|
1444
1427
|
|
|
1445
|
-
var
|
|
1428
|
+
var getPluginByKey = function (editor) {
|
|
1446
1429
|
var plugins = {};
|
|
1447
1430
|
if (editor === null || editor === void 0 ? void 0 : editor.pluginsByKey) {
|
|
1448
1431
|
return editor.pluginsByKey;
|
|
@@ -1450,7 +1433,7 @@
|
|
|
1450
1433
|
return plugins;
|
|
1451
1434
|
};
|
|
1452
1435
|
|
|
1453
|
-
var getPlugin = function (editor, key) { return
|
|
1436
|
+
var getPlugin = function (editor, key) { return getPluginByKey(editor)[key]; };
|
|
1454
1437
|
|
|
1455
1438
|
var getPluginOptions = function (editor, key) { var _a; return (_a = getPlugin(editor, key).options) !== null && _a !== void 0 ? _a : {}; };
|
|
1456
1439
|
|
|
@@ -1462,36 +1445,174 @@
|
|
|
1462
1445
|
newOptions[option] = _.union(options[option], override.options[option]);
|
|
1463
1446
|
continue;
|
|
1464
1447
|
}
|
|
1465
|
-
|
|
1448
|
+
if (util.isObject(options[option])) {
|
|
1449
|
+
newOptions[option] = _.assign(options[option], override.options[option]);
|
|
1450
|
+
}
|
|
1451
|
+
newOptions[option] = override.options[option];
|
|
1466
1452
|
}
|
|
1467
1453
|
plugin.options = newOptions;
|
|
1468
1454
|
return plugin;
|
|
1469
1455
|
};
|
|
1470
1456
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1457
|
+
var combinePlugins = function (editor) {
|
|
1458
|
+
// withOverrides
|
|
1459
|
+
editor.plugins.forEach(function (plugin) {
|
|
1460
|
+
if (plugin.withOverrides) {
|
|
1461
|
+
editor = plugin.withOverrides(editor, plugin);
|
|
1462
|
+
}
|
|
1463
|
+
});
|
|
1464
|
+
return editor;
|
|
1465
|
+
};
|
|
1466
|
+
|
|
1467
|
+
var mergeDeepPlugins = function (editor, _plugins) {
|
|
1468
|
+
_plugins.forEach(function (plugin) {
|
|
1469
|
+
if (plugin.overrideByKey) {
|
|
1470
|
+
var newPlugins = _plugins.filter(function (p) { return plugin.overrideByKey[p.key]; });
|
|
1471
|
+
newPlugins.forEach(function (p) {
|
|
1472
|
+
if (editor.pluginsByKey[p.key]) {
|
|
1473
|
+
p = mergeOptions(p, plugin.overrideByKey[p.key]);
|
|
1474
|
+
editor.pluginsByKey[p.key] = _.defaultsDeep(p, plugin.overrideByKey[p.key]);
|
|
1475
|
+
}
|
|
1487
1476
|
});
|
|
1488
1477
|
}
|
|
1478
|
+
});
|
|
1479
|
+
};
|
|
1480
|
+
|
|
1481
|
+
var nestedStructureByKey = function (editor, plugins) {
|
|
1482
|
+
// 如果有 key 重复则进行覆盖
|
|
1483
|
+
plugins.forEach(function (p) {
|
|
1484
|
+
for (var key in p.nestedStructureByKey) {
|
|
1485
|
+
if (!editor.nestedStructureByKey[key]) {
|
|
1486
|
+
editor.nestedStructureByKey[key] = p.nestedStructureByKey[key];
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
});
|
|
1490
|
+
};
|
|
1491
|
+
|
|
1492
|
+
var pluginsByKey = function (editor, plugins) {
|
|
1493
|
+
if (!plugins)
|
|
1494
|
+
return;
|
|
1495
|
+
plugins.forEach(function (p) {
|
|
1496
|
+
if (!editor.pluginsByKey[p.key]) {
|
|
1497
|
+
editor.pluginsByKey[p.key] = p;
|
|
1498
|
+
}
|
|
1499
|
+
});
|
|
1500
|
+
};
|
|
1501
|
+
|
|
1502
|
+
var withTheia = function (editor, plugins) {
|
|
1503
|
+
if (plugins === void 0) { plugins = []; }
|
|
1504
|
+
var e = editor;
|
|
1505
|
+
e.renderElement = function (element) { return null; };
|
|
1506
|
+
e.renderLeaf = function (text) { return null; };
|
|
1507
|
+
e.isContainer = function (value) { return false; };
|
|
1508
|
+
e.extraElementOptions = [];
|
|
1509
|
+
e.disabled = false;
|
|
1510
|
+
e.plugins = [];
|
|
1511
|
+
e.pluginsByKey = {};
|
|
1512
|
+
e.nestedStructureByKey = {};
|
|
1513
|
+
// withOverridesByKey
|
|
1514
|
+
flattenDeepPlugins(e, plugins);
|
|
1515
|
+
// mount pluginsByKey
|
|
1516
|
+
pluginsByKey(e, plugins);
|
|
1517
|
+
// mount nestedStructureByKey
|
|
1518
|
+
nestedStructureByKey(e, e.plugins);
|
|
1519
|
+
// merge plugin to pluginByKey
|
|
1520
|
+
mergeDeepPlugins(e, e.plugins);
|
|
1521
|
+
e = combinePlugins(e);
|
|
1522
|
+
return e;
|
|
1523
|
+
};
|
|
1524
|
+
|
|
1525
|
+
var createPluginFactory = function (defaultPlugin) { return function (override, overrideByKey) {
|
|
1526
|
+
if (overrideByKey === void 0) { overrideByKey = {}; }
|
|
1527
|
+
return defaultPlugin;
|
|
1528
|
+
}; };
|
|
1529
|
+
|
|
1530
|
+
var toolbarInitialize = function (toolbarItems, global, inline, quick) {
|
|
1531
|
+
if (global === void 0) { global = DefaultGlobalToolbarDefinition; }
|
|
1532
|
+
if (inline === void 0) { inline = DefaultInlineToolbarDefinition; }
|
|
1533
|
+
if (quick === void 0) { quick = DefaultQuickToolbarDefinition; }
|
|
1534
|
+
var toolbarDefinition = {
|
|
1535
|
+
global: global,
|
|
1536
|
+
inline: inline,
|
|
1537
|
+
quick: quick
|
|
1538
|
+
};
|
|
1539
|
+
var toolbarOperations = new Map();
|
|
1540
|
+
toolbarItems.forEach(function (i) { return toolbarOperations.set(i.key, i); });
|
|
1541
|
+
var toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
|
|
1542
|
+
return {
|
|
1543
|
+
toolbarDefinition: toolbarDefinition,
|
|
1544
|
+
toolbarOperations: toolbarOperations,
|
|
1545
|
+
toolbarEntity: toolbarEntity
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
var nextToolbarEntity = function (toolbarDefinition, toolbarItems) {
|
|
1549
|
+
var entity = {};
|
|
1550
|
+
for (var defKey in toolbarDefinition) {
|
|
1551
|
+
entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
|
|
1489
1552
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1553
|
+
return entity;
|
|
1554
|
+
};
|
|
1555
|
+
var getToolbarItemByKeys = function (keys, toolbarItems) {
|
|
1556
|
+
var items = [];
|
|
1557
|
+
keys.forEach(function (key) {
|
|
1558
|
+
if (key === "split") {
|
|
1559
|
+
items.push({ key: "split" });
|
|
1560
|
+
return;
|
|
1561
|
+
}
|
|
1562
|
+
var item = toolbarItems.get(key);
|
|
1563
|
+
if (item && item.includes) {
|
|
1564
|
+
items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
if (item) {
|
|
1568
|
+
items.push(item);
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
return items;
|
|
1572
|
+
};
|
|
1573
|
+
var createToolbar = function (editor, toolbar) {
|
|
1574
|
+
var toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce(function (prevItems, nextPlugin) {
|
|
1575
|
+
var _a;
|
|
1576
|
+
prevItems.push.apply(prevItems, __spreadArray([], __read(((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []))));
|
|
1577
|
+
return prevItems;
|
|
1578
|
+
}, []);
|
|
1579
|
+
var toolbarOption = toolbarInitialize(toolbarItems, toolbar === null || toolbar === void 0 ? void 0 : toolbar.global, toolbar === null || toolbar === void 0 ? void 0 : toolbar.inline, toolbar === null || toolbar === void 0 ? void 0 : toolbar.quick);
|
|
1580
|
+
var globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
|
|
1581
|
+
var toolbarEntity = toolbarOption.toolbarEntity;
|
|
1582
|
+
return {
|
|
1583
|
+
globalToolbarClass: globalToolbarClass,
|
|
1584
|
+
toolbarEntity: toolbarEntity
|
|
1585
|
+
};
|
|
1586
|
+
};
|
|
1587
|
+
|
|
1588
|
+
var UNDOING = new WeakMap();
|
|
1589
|
+
var REDOING = new WeakMap();
|
|
1590
|
+
var withTheHistory = function (editor) {
|
|
1591
|
+
var undo = editor.undo, redo = editor.redo;
|
|
1592
|
+
editor.undo = function () {
|
|
1593
|
+
UNDOING.set(editor, true);
|
|
1594
|
+
undo();
|
|
1595
|
+
UNDOING.set(editor, false);
|
|
1596
|
+
};
|
|
1597
|
+
editor.redo = function () {
|
|
1598
|
+
REDOING.set(editor, true);
|
|
1599
|
+
redo();
|
|
1600
|
+
REDOING.set(editor, false);
|
|
1601
|
+
};
|
|
1602
|
+
return editor;
|
|
1603
|
+
};
|
|
1604
|
+
var TheHistoryEditor = {
|
|
1605
|
+
isUndoing: function (editor) {
|
|
1606
|
+
return UNDOING.get(editor);
|
|
1607
|
+
},
|
|
1608
|
+
isRedoing: function (editor) {
|
|
1609
|
+
return REDOING.get(editor);
|
|
1492
1610
|
}
|
|
1493
|
-
return plugin;
|
|
1494
1611
|
};
|
|
1612
|
+
var createTheHistoryPlugin = createPluginFactory({
|
|
1613
|
+
key: exports.PluginKeys.theHistory,
|
|
1614
|
+
withOverrides: withTheHistory
|
|
1615
|
+
});
|
|
1495
1616
|
|
|
1496
1617
|
var setMarks = function (editor, marks, at) {
|
|
1497
1618
|
slate.Transforms.setNodes(editor, marks, {
|
|
@@ -1521,8 +1642,6 @@
|
|
|
1521
1642
|
}
|
|
1522
1643
|
};
|
|
1523
1644
|
|
|
1524
|
-
var insertElement = function (editor, element) { return editor.insertElement(element); };
|
|
1525
|
-
|
|
1526
1645
|
var isAncestor = function (node) { return slate.Element.isElement(node) || slate.Editor.isEditor(node); };
|
|
1527
1646
|
|
|
1528
1647
|
var getLastChild$1 = function (node, level) {
|
|
@@ -2247,18 +2366,78 @@
|
|
|
2247
2366
|
return parentEntry;
|
|
2248
2367
|
};
|
|
2249
2368
|
|
|
2250
|
-
var
|
|
2251
|
-
if (!Array.isArray(types)) {
|
|
2252
|
-
types = [types];
|
|
2253
|
-
}
|
|
2369
|
+
var getInsertElementsPath = function (editor, allowParentTypes) {
|
|
2254
2370
|
var _a = __read(getBlockAbove(editor), 2), anchorPath = _a[1];
|
|
2255
2371
|
if (!anchorPath)
|
|
2256
2372
|
return false;
|
|
2257
|
-
var parentEntry = slate.Editor.above(editor, { match: function (n) { return
|
|
2373
|
+
var parentEntry = slate.Editor.above(editor, { match: function (n) { return slate.Editor.isBlock(editor, n) && allowParentTypes.includes(n.type); } });
|
|
2258
2374
|
if (!parentEntry)
|
|
2259
2375
|
return false;
|
|
2260
|
-
var _b = __read(
|
|
2261
|
-
|
|
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
|
+
}
|
|
2262
2441
|
};
|
|
2263
2442
|
|
|
2264
2443
|
var isContainNestedType = function (editor, types) {
|
|
@@ -2336,7 +2515,7 @@
|
|
|
2336
2515
|
isBlockCardCursor: isBlockCardCursor,
|
|
2337
2516
|
isEmptyParagraphByPath: isEmptyParagraphByPath,
|
|
2338
2517
|
isContainer: isContainer,
|
|
2339
|
-
|
|
2518
|
+
getInsertElementsPath: getInsertElementsPath,
|
|
2340
2519
|
isContainNestedType: isContainNestedType,
|
|
2341
2520
|
anchorBlock: anchorBlock,
|
|
2342
2521
|
anchorBlockEntry: anchorBlockEntry,
|
|
@@ -2347,26 +2526,20 @@
|
|
|
2347
2526
|
someNode: someNode
|
|
2348
2527
|
});
|
|
2349
2528
|
|
|
2350
|
-
var
|
|
2529
|
+
var insertElements = function (editor, element) {
|
|
2351
2530
|
var _a;
|
|
2352
2531
|
if (slate.Range.isExpanded(editor.selection)) {
|
|
2353
2532
|
slate.Editor.deleteFragment(editor);
|
|
2354
2533
|
}
|
|
2355
2534
|
var type = element.type;
|
|
2356
2535
|
var allowParentTypes = ((_a = getPluginOptions(editor, type)) === null || _a === void 0 ? void 0 : _a.allowParentTypes) || [];
|
|
2357
|
-
var
|
|
2536
|
+
var insertNodePath = getInsertElementsPath(editor, allowParentTypes);
|
|
2358
2537
|
var _b = __read(anchorBlockEntry(editor), 2), anchorBlock = _b[0], anchorBlockPath = _b[1];
|
|
2359
2538
|
var isEmpty = slate.Editor.isEmpty(editor, anchorBlock);
|
|
2360
|
-
|
|
2361
|
-
if (isAllowInsert && isContainNested) {
|
|
2362
|
-
var _c = __read(slate.Editor.above(editor, {
|
|
2363
|
-
match: function (n) { return slate.Editor.isBlock(editor, n) && allowParentTypes.includes(n.type); },
|
|
2364
|
-
at: editor.selection
|
|
2365
|
-
}), 2), containerPath_1 = _c[1];
|
|
2539
|
+
if (insertNodePath) {
|
|
2366
2540
|
slate.Editor.withoutNormalizing(editor, function () {
|
|
2367
|
-
|
|
2368
|
-
slate.Transforms.
|
|
2369
|
-
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));
|
|
2370
2543
|
if (isEmpty) {
|
|
2371
2544
|
slate.Transforms.removeNodes(editor, { at: anchorBlockPath });
|
|
2372
2545
|
}
|
|
@@ -2575,8 +2748,7 @@
|
|
|
2575
2748
|
__proto__: null,
|
|
2576
2749
|
setMarks: setMarks,
|
|
2577
2750
|
clearMarks: clearMarks,
|
|
2578
|
-
|
|
2579
|
-
insertElementNext: insertElementNext,
|
|
2751
|
+
insertElements: insertElements,
|
|
2580
2752
|
insertParagraph: insertParagraph,
|
|
2581
2753
|
setNode: setNode,
|
|
2582
2754
|
unwrapNodesByType: unwrapNodesByType,
|
|
@@ -2593,134 +2765,6 @@
|
|
|
2593
2765
|
handleContinualInsertBreak: handleContinualInsertBreak
|
|
2594
2766
|
});
|
|
2595
2767
|
|
|
2596
|
-
var withTheia = function (editor, plugins) {
|
|
2597
|
-
if (plugins === void 0) { plugins = []; }
|
|
2598
|
-
var e = editor;
|
|
2599
|
-
e.renderElement = function (element) { return null; };
|
|
2600
|
-
e.renderLeaf = function (text) { return null; };
|
|
2601
|
-
e.insertElement = function (element) { return insertElementNext(e, element); };
|
|
2602
|
-
e.isContainer = function (value) { return false; };
|
|
2603
|
-
e.extraElementOptions = [];
|
|
2604
|
-
e.disabled = false;
|
|
2605
|
-
e.plugins = [];
|
|
2606
|
-
e.pluginsByKey = {};
|
|
2607
|
-
e.nestedStructureByKey = {};
|
|
2608
|
-
// withOverridesByKey
|
|
2609
|
-
flattenDeepPlugins(e, plugins);
|
|
2610
|
-
// 如果 plugin.overrideByKey 存在,则把 plugin.overrideByKey 中的所有 key 覆盖到 editor.pluginsByKey 中
|
|
2611
|
-
editor.plugins.forEach(function (plugin) {
|
|
2612
|
-
if (plugin.overrideByKey) {
|
|
2613
|
-
var newPlugins = editor.plugins.map(function (p) {
|
|
2614
|
-
return overridePluginsByKey(p, plugin.overrideByKey);
|
|
2615
|
-
});
|
|
2616
|
-
editor.plugins = [];
|
|
2617
|
-
editor.pluginsByKey = {};
|
|
2618
|
-
// 再次扁平化覆盖
|
|
2619
|
-
flattenDeepPlugins(editor, newPlugins);
|
|
2620
|
-
}
|
|
2621
|
-
});
|
|
2622
|
-
// withOverrides
|
|
2623
|
-
e.plugins.forEach(function (plugin) {
|
|
2624
|
-
if (plugin.withOverrides) {
|
|
2625
|
-
e = plugin.withOverrides(e, plugin);
|
|
2626
|
-
}
|
|
2627
|
-
});
|
|
2628
|
-
return e;
|
|
2629
|
-
};
|
|
2630
|
-
|
|
2631
|
-
var createPluginFactory = function (defaultPlugin) { return function (override, overrideByKey) {
|
|
2632
|
-
if (overrideByKey === void 0) { overrideByKey = {}; }
|
|
2633
|
-
overrideByKey[defaultPlugin.key] = override;
|
|
2634
|
-
return overridePluginsByKey(Object.assign({}, defaultPlugin), overrideByKey);
|
|
2635
|
-
}; };
|
|
2636
|
-
|
|
2637
|
-
var toolbarInitialize = function (toolbarItems, global, inline, quick) {
|
|
2638
|
-
if (global === void 0) { global = DefaultGlobalToolbarDefinition; }
|
|
2639
|
-
if (inline === void 0) { inline = DefaultInlineToolbarDefinition; }
|
|
2640
|
-
if (quick === void 0) { quick = DefaultQuickToolbarDefinition; }
|
|
2641
|
-
var toolbarDefinition = {
|
|
2642
|
-
global: global,
|
|
2643
|
-
inline: inline,
|
|
2644
|
-
quick: quick
|
|
2645
|
-
};
|
|
2646
|
-
var toolbarOperations = new Map();
|
|
2647
|
-
toolbarItems.forEach(function (i) { return toolbarOperations.set(i.key, i); });
|
|
2648
|
-
var toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
|
|
2649
|
-
return {
|
|
2650
|
-
toolbarDefinition: toolbarDefinition,
|
|
2651
|
-
toolbarOperations: toolbarOperations,
|
|
2652
|
-
toolbarEntity: toolbarEntity
|
|
2653
|
-
};
|
|
2654
|
-
};
|
|
2655
|
-
var nextToolbarEntity = function (toolbarDefinition, toolbarItems) {
|
|
2656
|
-
var entity = {};
|
|
2657
|
-
for (var defKey in toolbarDefinition) {
|
|
2658
|
-
entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
|
|
2659
|
-
}
|
|
2660
|
-
return entity;
|
|
2661
|
-
};
|
|
2662
|
-
var getToolbarItemByKeys = function (keys, toolbarItems) {
|
|
2663
|
-
var items = [];
|
|
2664
|
-
keys.forEach(function (key) {
|
|
2665
|
-
if (key === "split") {
|
|
2666
|
-
items.push({ key: "split" });
|
|
2667
|
-
return;
|
|
2668
|
-
}
|
|
2669
|
-
var item = toolbarItems.get(key);
|
|
2670
|
-
if (item && item.includes) {
|
|
2671
|
-
items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
|
|
2672
|
-
return;
|
|
2673
|
-
}
|
|
2674
|
-
if (item) {
|
|
2675
|
-
items.push(item);
|
|
2676
|
-
}
|
|
2677
|
-
});
|
|
2678
|
-
return items;
|
|
2679
|
-
};
|
|
2680
|
-
var createToolbar = function (editor, toolbar) {
|
|
2681
|
-
var toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce(function (prevItems, nextPlugin) {
|
|
2682
|
-
var _a;
|
|
2683
|
-
prevItems.push.apply(prevItems, __spreadArray([], __read(((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []))));
|
|
2684
|
-
return prevItems;
|
|
2685
|
-
}, []);
|
|
2686
|
-
var toolbarOption = toolbarInitialize(toolbarItems, toolbar === null || toolbar === void 0 ? void 0 : toolbar.global, toolbar === null || toolbar === void 0 ? void 0 : toolbar.inline, toolbar === null || toolbar === void 0 ? void 0 : toolbar.quick);
|
|
2687
|
-
var globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
|
|
2688
|
-
var toolbarEntity = toolbarOption.toolbarEntity;
|
|
2689
|
-
return {
|
|
2690
|
-
globalToolbarClass: globalToolbarClass,
|
|
2691
|
-
toolbarEntity: toolbarEntity
|
|
2692
|
-
};
|
|
2693
|
-
};
|
|
2694
|
-
|
|
2695
|
-
var UNDOING = new WeakMap();
|
|
2696
|
-
var REDOING = new WeakMap();
|
|
2697
|
-
var withTheHistory = function (editor) {
|
|
2698
|
-
var undo = editor.undo, redo = editor.redo;
|
|
2699
|
-
editor.undo = function () {
|
|
2700
|
-
UNDOING.set(editor, true);
|
|
2701
|
-
undo();
|
|
2702
|
-
UNDOING.set(editor, false);
|
|
2703
|
-
};
|
|
2704
|
-
editor.redo = function () {
|
|
2705
|
-
REDOING.set(editor, true);
|
|
2706
|
-
redo();
|
|
2707
|
-
REDOING.set(editor, false);
|
|
2708
|
-
};
|
|
2709
|
-
return editor;
|
|
2710
|
-
};
|
|
2711
|
-
var TheHistoryEditor = {
|
|
2712
|
-
isUndoing: function (editor) {
|
|
2713
|
-
return UNDOING.get(editor);
|
|
2714
|
-
},
|
|
2715
|
-
isRedoing: function (editor) {
|
|
2716
|
-
return REDOING.get(editor);
|
|
2717
|
-
}
|
|
2718
|
-
};
|
|
2719
|
-
var createTheHistoryPlugin = createPluginFactory({
|
|
2720
|
-
key: exports.PluginKeys.theHistory,
|
|
2721
|
-
withOverrides: withTheHistory
|
|
2722
|
-
});
|
|
2723
|
-
|
|
2724
2768
|
var TheConversionHintComponent = /** @class */ (function () {
|
|
2725
2769
|
function TheConversionHintComponent() {
|
|
2726
2770
|
this.duration = 10000;
|
|
@@ -4410,7 +4454,6 @@
|
|
|
4410
4454
|
}
|
|
4411
4455
|
// wrap
|
|
4412
4456
|
ListEditor.buildListItem(editor);
|
|
4413
|
-
// Todo: types
|
|
4414
4457
|
slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
|
|
4415
4458
|
at: editor.selection,
|
|
4416
4459
|
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
@@ -4722,8 +4765,8 @@
|
|
|
4722
4765
|
}
|
|
4723
4766
|
],
|
|
4724
4767
|
nestedStructureByKey: (_c = {},
|
|
4725
|
-
_c[exports.ElementKinds.bulletedList] =
|
|
4726
|
-
_c[exports.ElementKinds.numberedList] =
|
|
4768
|
+
_c[exports.ElementKinds.bulletedList] = exports.ElementKinds.listItem,
|
|
4769
|
+
_c[exports.ElementKinds.numberedList] = exports.ElementKinds.listItem,
|
|
4727
4770
|
_c),
|
|
4728
4771
|
toolbarItems: [
|
|
4729
4772
|
{
|
|
@@ -4763,18 +4806,21 @@
|
|
|
4763
4806
|
enumerable: false,
|
|
4764
4807
|
configurable: true
|
|
4765
4808
|
});
|
|
4809
|
+
Object.defineProperty(TheTodoItemComponent.prototype, "editableWithReadonly", {
|
|
4810
|
+
get: function () {
|
|
4811
|
+
var _a;
|
|
4812
|
+
return (_a = getPluginOptions(this.editor, exports.PluginKeys.checkItem)) === null || _a === void 0 ? void 0 : _a.editableWithReadonly;
|
|
4813
|
+
},
|
|
4814
|
+
enumerable: false,
|
|
4815
|
+
configurable: true
|
|
4816
|
+
});
|
|
4766
4817
|
TheTodoItemComponent.prototype.ngOnInit = function () {
|
|
4767
4818
|
_super.prototype.ngOnInit.call(this);
|
|
4768
4819
|
};
|
|
4769
4820
|
TheTodoItemComponent.prototype.onCheck = function (checked) {
|
|
4770
|
-
|
|
4771
|
-
var noBindReadonly = options.noBindReadonlyPlugins && options.noBindReadonlyPlugins.includes(exports.ElementKinds.checkItem);
|
|
4772
|
-
if (!noBindReadonly && this.readonly) {
|
|
4821
|
+
if (this.readonly && !this.editableWithReadonly) {
|
|
4773
4822
|
return false;
|
|
4774
4823
|
}
|
|
4775
|
-
else {
|
|
4776
|
-
setNode(this.editor, { checked: checked }, this.element);
|
|
4777
|
-
}
|
|
4778
4824
|
setNode(this.editor, { checked: checked }, this.element);
|
|
4779
4825
|
};
|
|
4780
4826
|
return TheTodoItemComponent;
|
|
@@ -4890,7 +4936,8 @@
|
|
|
4890
4936
|
}
|
|
4891
4937
|
],
|
|
4892
4938
|
options: {
|
|
4893
|
-
allowParentTypes: [exports.ElementKinds.tableCell, exports.ElementKinds.blockquote]
|
|
4939
|
+
allowParentTypes: [exports.ElementKinds.tableCell, exports.ElementKinds.blockquote],
|
|
4940
|
+
editableWithReadonly: false
|
|
4894
4941
|
}
|
|
4895
4942
|
});
|
|
4896
4943
|
|
|
@@ -4925,7 +4972,7 @@
|
|
|
4925
4972
|
|
|
4926
4973
|
var HrEditor = {
|
|
4927
4974
|
insertHr: function (editor) {
|
|
4928
|
-
|
|
4975
|
+
insertElements(editor, { type: exports.ElementKinds.hr, children: [{ text: '' }] });
|
|
4929
4976
|
}
|
|
4930
4977
|
};
|
|
4931
4978
|
|
|
@@ -5545,7 +5592,7 @@
|
|
|
5545
5592
|
}
|
|
5546
5593
|
// Create the table node
|
|
5547
5594
|
var table = createTable(opts, columns, rows, getCellContent);
|
|
5548
|
-
|
|
5595
|
+
insertElements(editor, table);
|
|
5549
5596
|
}
|
|
5550
5597
|
|
|
5551
5598
|
/**
|
|
@@ -6416,13 +6463,13 @@
|
|
|
6416
6463
|
|
|
6417
6464
|
var BlockquoteEditor = {
|
|
6418
6465
|
toggleBlockquote: function (editor) {
|
|
6466
|
+
var _a;
|
|
6419
6467
|
var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
|
|
6468
|
+
var allowParentTypes = ((_a = getPluginOptions(editor, exports.PluginKeys.blockquote)) === null || _a === void 0 ? void 0 : _a.allowParentTypes) || [];
|
|
6420
6469
|
if (!isActive) {
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
};
|
|
6425
|
-
insertElement(editor, blockquoteElement);
|
|
6470
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
|
|
6471
|
+
mode: 'lowest'
|
|
6472
|
+
});
|
|
6426
6473
|
}
|
|
6427
6474
|
else {
|
|
6428
6475
|
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
|
|
@@ -6510,7 +6557,7 @@
|
|
|
6510
6557
|
language: DEFAULT_LANGUAGE.value,
|
|
6511
6558
|
children: [{ text: '' }]
|
|
6512
6559
|
};
|
|
6513
|
-
|
|
6560
|
+
insertElements(editor, codeElement);
|
|
6514
6561
|
}
|
|
6515
6562
|
else {
|
|
6516
6563
|
var codeElement = {
|
|
@@ -6519,7 +6566,7 @@
|
|
|
6519
6566
|
language: DEFAULT_LANGUAGE.value,
|
|
6520
6567
|
children: [{ text: '' }]
|
|
6521
6568
|
};
|
|
6522
|
-
|
|
6569
|
+
insertElements(editor, codeElement);
|
|
6523
6570
|
}
|
|
6524
6571
|
}
|
|
6525
6572
|
};
|
|
@@ -6665,10 +6712,9 @@
|
|
|
6665
6712
|
}
|
|
6666
6713
|
];
|
|
6667
6714
|
|
|
6668
|
-
var mergAutoFormateRules = function (
|
|
6669
|
-
var combinationData = __spreadArray(__spreadArray([], __read(defaultAutoFormatRules)), __read(extraAutoFormatRules));
|
|
6715
|
+
var mergAutoFormateRules = function (rules) {
|
|
6670
6716
|
var dataInfo = {};
|
|
6671
|
-
|
|
6717
|
+
rules.forEach(function (item) {
|
|
6672
6718
|
if (!dataInfo[item.type + item.key]) {
|
|
6673
6719
|
dataInfo[item.type + item.key] = Object.assign({}, item);
|
|
6674
6720
|
}
|
|
@@ -6681,11 +6727,9 @@
|
|
|
6681
6727
|
editor.insertText = function (text) {
|
|
6682
6728
|
var e_1, _d;
|
|
6683
6729
|
var _a, _b;
|
|
6684
|
-
var autoFormatRules =
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
autoFormatRules = Object.values(extraRules);
|
|
6688
|
-
}
|
|
6730
|
+
var autoFormatRules = (_a = getPluginOptions(editor, exports.PluginKeys.autoFormat)) === null || _a === void 0 ? void 0 : _a.autoFormatRules;
|
|
6731
|
+
var extraRules = mergAutoFormateRules(autoFormatRules);
|
|
6732
|
+
autoFormatRules = Object.values(extraRules);
|
|
6689
6733
|
if (!isCollapsed(editor.selection)) {
|
|
6690
6734
|
return insertText(text);
|
|
6691
6735
|
}
|
|
@@ -6779,7 +6823,10 @@
|
|
|
6779
6823
|
};
|
|
6780
6824
|
var createAutoFormatPlugin = createPluginFactory({
|
|
6781
6825
|
key: exports.PluginKeys.autoFormat,
|
|
6782
|
-
withOverrides: withAutoFormat
|
|
6826
|
+
withOverrides: withAutoFormat,
|
|
6827
|
+
options: {
|
|
6828
|
+
autoFormatRules: defaultAutoFormatRules
|
|
6829
|
+
}
|
|
6783
6830
|
});
|
|
6784
6831
|
|
|
6785
6832
|
var withTransforms = function (editor) {
|
|
@@ -12056,8 +12103,8 @@
|
|
|
12056
12103
|
key: exports.PluginKeys.table,
|
|
12057
12104
|
withOverrides: withTable,
|
|
12058
12105
|
nestedStructureByKey: (_a = {},
|
|
12059
|
-
_a[exports.ElementKinds.table] =
|
|
12060
|
-
_a[exports.ElementKinds.tableRow] =
|
|
12106
|
+
_a[exports.ElementKinds.table] = exports.ElementKinds.tableRow,
|
|
12107
|
+
_a[exports.ElementKinds.tableRow] = exports.ElementKinds.tableCell,
|
|
12061
12108
|
_a),
|
|
12062
12109
|
toolbarItems: [
|
|
12063
12110
|
{
|
|
@@ -12332,10 +12379,10 @@
|
|
|
12332
12379
|
var onKeydown = editor.onKeydown, deleteBackward = editor.deleteBackward, onChange = editor.onChange;
|
|
12333
12380
|
var presseingQuickInsertHotkey = false;
|
|
12334
12381
|
editor.onKeydown = function (event) {
|
|
12335
|
-
var
|
|
12336
|
-
var hotkey =
|
|
12382
|
+
var options = getPluginOptions(editor, exports.PluginKeys.quickInsert);
|
|
12383
|
+
var hotkey = options.hotkey, allowHotkeyInTypes = options.allowHotkeyInTypes;
|
|
12337
12384
|
if (event.key === hotkey) {
|
|
12338
|
-
var types = __spreadArray([], __read((
|
|
12385
|
+
var types = __spreadArray([], __read((allowHotkeyInTypes || [])));
|
|
12339
12386
|
var _c = __read(getBlockAbove(editor), 1), block = _c[0];
|
|
12340
12387
|
if (isPureEmptyParagraph(editor, block) && allowOpenQuickToolbar(editor, types)) {
|
|
12341
12388
|
presseingQuickInsertHotkey = true;
|
|
@@ -14181,13 +14228,12 @@
|
|
|
14181
14228
|
};
|
|
14182
14229
|
TheEditorComponent.prototype.initialize = function () {
|
|
14183
14230
|
var _this = this;
|
|
14184
|
-
var _a, _b
|
|
14231
|
+
var _a, _b;
|
|
14185
14232
|
var plugins = __spreadArray(__spreadArray([], __read(internalPlugins)), __read(this.thePlugins));
|
|
14186
14233
|
this.editor = withTheia(slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)), plugins);
|
|
14187
14234
|
this.generateDecorate();
|
|
14188
14235
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
14189
14236
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
14190
|
-
this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
|
|
14191
14237
|
this.editor.options = this.theOptions;
|
|
14192
14238
|
setEditorUUID(this.editor, idCreator());
|
|
14193
14239
|
this.theContextService.initialize({
|
|
@@ -14873,6 +14919,7 @@
|
|
|
14873
14919
|
exports.autoFocus = autoFocus;
|
|
14874
14920
|
exports.autoScrollViewHandle = autoScrollViewHandle;
|
|
14875
14921
|
exports.coercePixelsFromCssValue = coercePixelsFromCssValue;
|
|
14922
|
+
exports.combinePlugins = combinePlugins;
|
|
14876
14923
|
exports.createEmptyParagraph = createEmptyParagraph;
|
|
14877
14924
|
exports.createPluginFactory = createPluginFactory;
|
|
14878
14925
|
exports.createToolbar = createToolbar;
|
|
@@ -14890,9 +14937,9 @@
|
|
|
14890
14937
|
exports.getElementWidth = getElementWidth;
|
|
14891
14938
|
exports.getEndBlock = getEndBlock;
|
|
14892
14939
|
exports.getPlugin = getPlugin;
|
|
14940
|
+
exports.getPluginByKey = getPluginByKey;
|
|
14893
14941
|
exports.getPluginOptions = getPluginOptions;
|
|
14894
14942
|
exports.getPlugins = getPlugins;
|
|
14895
|
-
exports.getPluginsByKey = getPluginsByKey;
|
|
14896
14943
|
exports.getRowsTotalHeight = getRowsTotalHeight;
|
|
14897
14944
|
exports.getStartBlock = getStartBlock;
|
|
14898
14945
|
exports.getToolbarClass = getToolbarClass;
|
|
@@ -14903,10 +14950,12 @@
|
|
|
14903
14950
|
exports.internalPlugins = internalPlugins;
|
|
14904
14951
|
exports.isCleanEmptyParagraph = isCleanEmptyParagraph;
|
|
14905
14952
|
exports.isPureEmptyParagraph = isPureEmptyParagraph;
|
|
14953
|
+
exports.mergeDeepPlugins = mergeDeepPlugins;
|
|
14906
14954
|
exports.mergeElementOptions = mergeElementOptions;
|
|
14907
14955
|
exports.mergeOptions = mergeOptions;
|
|
14908
|
-
exports.
|
|
14956
|
+
exports.nestedStructureByKey = nestedStructureByKey;
|
|
14909
14957
|
exports.plainToTheia = plainToTheia;
|
|
14958
|
+
exports.pluginsByKey = pluginsByKey;
|
|
14910
14959
|
exports.setEditorUUID = setEditorUUID;
|
|
14911
14960
|
exports.useElementStyle = useElementStyle;
|
|
14912
14961
|
exports.withTheia = withTheia;
|