@worktile/theia 3.0.0 → 3.0.3
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 +54 -24
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/core/utils/index.d.ts +1 -1
- package/core/utils/merge-array.d.ts +1 -0
- package/esm2015/constants/auto-format-rules.js +19 -2
- package/esm2015/core/create-plugin.js +3 -2
- package/esm2015/core/utils/flatten-deep-plugins.js +3 -2
- package/esm2015/core/utils/get-plugin-options.js +2 -2
- package/esm2015/core/utils/get-plugin.js +2 -3
- package/esm2015/core/utils/index.js +2 -2
- package/esm2015/core/utils/merge-array.js +18 -0
- package/esm2015/core/utils/merge-deep-plugins.js +1 -3
- package/esm2015/core/utils/merge-options.js +10 -8
- package/esm2015/editor.component.js +3 -2
- package/esm2015/interfaces/plugins/plugins.js +1 -1
- package/esm2015/plugins/autoformat/autoformat.plugin.js +1 -1
- package/esm2015/plugins/index.js +2 -2
- package/fesm2015/worktile-theia.js +50 -23
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/plugins/plugins.d.ts +3 -0
- package/package.json +1 -1
- package/plugins/autoformat/autoformat.plugin.d.ts +1 -1
- package/plugins/index.d.ts +1 -1
- package/core/utils/get-plugin-by-key.d.ts +0 -2
- package/esm2015/core/utils/get-plugin-by-key.js +0 -8
|
@@ -1410,7 +1410,7 @@
|
|
|
1410
1410
|
if (!plugins)
|
|
1411
1411
|
return;
|
|
1412
1412
|
plugins.forEach(function (plugin) {
|
|
1413
|
-
var p = plugin;
|
|
1413
|
+
var p = _.cloneDeep(plugin);
|
|
1414
1414
|
if (!p.options)
|
|
1415
1415
|
p.options = {};
|
|
1416
1416
|
if (!p.nestedStructureByKey)
|
|
@@ -1425,30 +1425,43 @@
|
|
|
1425
1425
|
return (_a = editor === null || editor === void 0 ? void 0 : editor.plugins) !== null && _a !== void 0 ? _a : [];
|
|
1426
1426
|
};
|
|
1427
1427
|
|
|
1428
|
-
var
|
|
1429
|
-
var plugins = {};
|
|
1430
|
-
if (editor === null || editor === void 0 ? void 0 : editor.pluginsByKey) {
|
|
1431
|
-
return editor.pluginsByKey;
|
|
1432
|
-
}
|
|
1433
|
-
return plugins;
|
|
1434
|
-
};
|
|
1428
|
+
var getPlugin = function (editor, key) { return editor.pluginsByKey[key]; };
|
|
1435
1429
|
|
|
1436
|
-
var
|
|
1430
|
+
var getPluginOptions = function (editor, key) { var _a, _b; return (_b = (_a = getPlugin(editor, key)) === null || _a === void 0 ? void 0 : _a.options) !== null && _b !== void 0 ? _b : {}; };
|
|
1437
1431
|
|
|
1438
|
-
var
|
|
1432
|
+
var mergeArray = function (origin, source) {
|
|
1433
|
+
if (!Array.isArray(source))
|
|
1434
|
+
return source;
|
|
1435
|
+
var _loop_1 = function (i) {
|
|
1436
|
+
var value = source[i];
|
|
1437
|
+
if (util.isObject(value) && (value === null || value === void 0 ? void 0 : value.key) && origin.some(function (item) { return (item === null || item === void 0 ? void 0 : item.key) === (value === null || value === void 0 ? void 0 : value.key); })) {
|
|
1438
|
+
var index = origin.findIndex(function (item) { return (item === null || item === void 0 ? void 0 : item.key) === (value === null || value === void 0 ? void 0 : value.key); });
|
|
1439
|
+
origin[index] = Object.assign(Object.assign({}, origin[index]), value);
|
|
1440
|
+
return "continue";
|
|
1441
|
+
}
|
|
1442
|
+
if (origin.includes(source[i]))
|
|
1443
|
+
return "continue";
|
|
1444
|
+
origin.push(source[i]);
|
|
1445
|
+
};
|
|
1446
|
+
for (var i = 0; i < source.length; i++) {
|
|
1447
|
+
_loop_1(i);
|
|
1448
|
+
}
|
|
1449
|
+
return origin;
|
|
1450
|
+
};
|
|
1439
1451
|
|
|
1440
1452
|
var mergeOptions = function (plugin, override) {
|
|
1441
1453
|
var options = plugin.options;
|
|
1442
|
-
var newOptions =
|
|
1443
|
-
for (var option in options) {
|
|
1444
|
-
if (Array.isArray(options[option])) {
|
|
1445
|
-
newOptions[option] =
|
|
1454
|
+
var newOptions = options;
|
|
1455
|
+
for (var option in override.options) {
|
|
1456
|
+
if (Array.isArray(override.options[option]) && newOptions[option]) {
|
|
1457
|
+
newOptions[option] = mergeArray(newOptions[option], override.options[option]);
|
|
1446
1458
|
continue;
|
|
1447
1459
|
}
|
|
1448
|
-
if (util.isObject(options[option])) {
|
|
1449
|
-
newOptions[option] = _.assign(
|
|
1460
|
+
if (util.isObject(override.options[option]) && newOptions[option]) {
|
|
1461
|
+
newOptions[option] = _.assign(newOptions[option], override.options[option]);
|
|
1462
|
+
continue;
|
|
1450
1463
|
}
|
|
1451
|
-
newOptions[option] = override.options[option]
|
|
1464
|
+
newOptions[option] = override.options[option];
|
|
1452
1465
|
}
|
|
1453
1466
|
plugin.options = newOptions;
|
|
1454
1467
|
};
|
|
@@ -1470,7 +1483,6 @@
|
|
|
1470
1483
|
newPlugins.forEach(function (p) {
|
|
1471
1484
|
if (editor.pluginsByKey[p.key]) {
|
|
1472
1485
|
mergeOptions(p, plugin.overrideByKey[p.key]);
|
|
1473
|
-
editor.pluginsByKey[p.key] = _.defaultsDeep(p, plugin.overrideByKey[p.key]);
|
|
1474
1486
|
}
|
|
1475
1487
|
});
|
|
1476
1488
|
}
|
|
@@ -1523,7 +1535,7 @@
|
|
|
1523
1535
|
|
|
1524
1536
|
var createPluginFactory = function (defaultPlugin) { return function (override, overrideByKey) {
|
|
1525
1537
|
if (overrideByKey === void 0) { overrideByKey = {}; }
|
|
1526
|
-
return defaultPlugin;
|
|
1538
|
+
return _.cloneDeep(defaultPlugin);
|
|
1527
1539
|
}; };
|
|
1528
1540
|
|
|
1529
1541
|
var toolbarInitialize = function (toolbarItems, global, inline, quick) {
|
|
@@ -6544,6 +6556,7 @@
|
|
|
6544
6556
|
|
|
6545
6557
|
var defaultAutoFormatRules = [
|
|
6546
6558
|
{
|
|
6559
|
+
key: exports.ElementKinds.heading_1,
|
|
6547
6560
|
type: exports.ElementKinds.heading_1,
|
|
6548
6561
|
markup: '#',
|
|
6549
6562
|
format: function (editor) {
|
|
@@ -6551,6 +6564,7 @@
|
|
|
6551
6564
|
}
|
|
6552
6565
|
},
|
|
6553
6566
|
{
|
|
6567
|
+
key: exports.ElementKinds.heading_2,
|
|
6554
6568
|
type: exports.ElementKinds.heading_2,
|
|
6555
6569
|
markup: '##',
|
|
6556
6570
|
format: function (editor) {
|
|
@@ -6558,6 +6572,7 @@
|
|
|
6558
6572
|
}
|
|
6559
6573
|
},
|
|
6560
6574
|
{
|
|
6575
|
+
key: exports.ElementKinds.heading_3,
|
|
6561
6576
|
type: exports.ElementKinds.heading_3,
|
|
6562
6577
|
markup: '###',
|
|
6563
6578
|
format: function (editor) {
|
|
@@ -6565,6 +6580,7 @@
|
|
|
6565
6580
|
}
|
|
6566
6581
|
},
|
|
6567
6582
|
{
|
|
6583
|
+
key: exports.ElementKinds.heading_4,
|
|
6568
6584
|
type: exports.ElementKinds.heading_4,
|
|
6569
6585
|
markup: '####',
|
|
6570
6586
|
format: function (editor) {
|
|
@@ -6572,6 +6588,7 @@
|
|
|
6572
6588
|
}
|
|
6573
6589
|
},
|
|
6574
6590
|
{
|
|
6591
|
+
key: exports.ElementKinds.heading_5,
|
|
6575
6592
|
type: exports.ElementKinds.heading_5,
|
|
6576
6593
|
markup: '#####',
|
|
6577
6594
|
format: function (editor) {
|
|
@@ -6579,6 +6596,7 @@
|
|
|
6579
6596
|
}
|
|
6580
6597
|
},
|
|
6581
6598
|
{
|
|
6599
|
+
key: exports.ElementKinds.heading_6,
|
|
6582
6600
|
type: exports.ElementKinds.heading_6,
|
|
6583
6601
|
markup: '######',
|
|
6584
6602
|
format: function (editor) {
|
|
@@ -6586,6 +6604,7 @@
|
|
|
6586
6604
|
}
|
|
6587
6605
|
},
|
|
6588
6606
|
{
|
|
6607
|
+
key: exports.ElementKinds.blockquote,
|
|
6589
6608
|
type: exports.ElementKinds.blockquote,
|
|
6590
6609
|
markup: ['>'],
|
|
6591
6610
|
format: function (editor) {
|
|
@@ -6593,30 +6612,35 @@
|
|
|
6593
6612
|
}
|
|
6594
6613
|
},
|
|
6595
6614
|
{
|
|
6615
|
+
key: exports.MarkTypes.bold,
|
|
6596
6616
|
type: exports.MarkTypes.bold,
|
|
6597
6617
|
between: ['**', '**'],
|
|
6598
6618
|
mode: 'inline',
|
|
6599
6619
|
insertTrigger: true
|
|
6600
6620
|
},
|
|
6601
6621
|
{
|
|
6622
|
+
key: exports.MarkTypes.bold + "__",
|
|
6602
6623
|
type: exports.MarkTypes.bold,
|
|
6603
6624
|
between: ['__', '__'],
|
|
6604
6625
|
mode: 'inline',
|
|
6605
6626
|
insertTrigger: true
|
|
6606
6627
|
},
|
|
6607
6628
|
{
|
|
6629
|
+
key: exports.MarkTypes.italic,
|
|
6608
6630
|
type: exports.MarkTypes.italic,
|
|
6609
6631
|
between: ['*', '*'],
|
|
6610
6632
|
mode: 'inline',
|
|
6611
6633
|
insertTrigger: true
|
|
6612
6634
|
},
|
|
6613
6635
|
{
|
|
6636
|
+
key: exports.MarkTypes.italic + "_",
|
|
6614
6637
|
type: exports.MarkTypes.italic,
|
|
6615
6638
|
between: ['_', '_'],
|
|
6616
6639
|
mode: 'inline',
|
|
6617
6640
|
insertTrigger: true
|
|
6618
6641
|
},
|
|
6619
6642
|
{
|
|
6643
|
+
key: exports.ElementKinds.inlineCode,
|
|
6620
6644
|
type: exports.ElementKinds.inlineCode,
|
|
6621
6645
|
between: ['`', '`'],
|
|
6622
6646
|
mode: 'inline',
|
|
@@ -6626,12 +6650,14 @@
|
|
|
6626
6650
|
}
|
|
6627
6651
|
},
|
|
6628
6652
|
{
|
|
6653
|
+
key: exports.MarkTypes.strike,
|
|
6629
6654
|
type: exports.MarkTypes.strike,
|
|
6630
6655
|
between: ['~~', '~~'],
|
|
6631
6656
|
mode: 'inline',
|
|
6632
6657
|
insertTrigger: true
|
|
6633
6658
|
},
|
|
6634
6659
|
{
|
|
6660
|
+
key: exports.ElementKinds.code,
|
|
6635
6661
|
type: exports.ElementKinds.code,
|
|
6636
6662
|
markup: '```',
|
|
6637
6663
|
format: function (editor) {
|
|
@@ -6639,6 +6665,7 @@
|
|
|
6639
6665
|
}
|
|
6640
6666
|
},
|
|
6641
6667
|
{
|
|
6668
|
+
key: exports.ElementKinds.listItem,
|
|
6642
6669
|
type: exports.ElementKinds.listItem,
|
|
6643
6670
|
markup: [],
|
|
6644
6671
|
match: function (editor) {
|
|
@@ -6649,8 +6676,8 @@
|
|
|
6649
6676
|
}
|
|
6650
6677
|
},
|
|
6651
6678
|
{
|
|
6652
|
-
type: exports.ElementKinds.listItem,
|
|
6653
6679
|
key: exports.ElementKinds.numberedList,
|
|
6680
|
+
type: exports.ElementKinds.listItem,
|
|
6654
6681
|
markup: [],
|
|
6655
6682
|
match: function (editor, textFromBlockStart) {
|
|
6656
6683
|
return isParagraph(editor) && /^-?\d+(\.|\))$/.test(textFromBlockStart) ? [textFromBlockStart] : [];
|
|
@@ -6667,6 +6694,7 @@
|
|
|
6667
6694
|
}
|
|
6668
6695
|
},
|
|
6669
6696
|
{
|
|
6697
|
+
key: exports.ElementKinds.checkItem,
|
|
6670
6698
|
type: exports.ElementKinds.checkItem,
|
|
6671
6699
|
markup: [],
|
|
6672
6700
|
match: function (editor) {
|
|
@@ -6677,6 +6705,7 @@
|
|
|
6677
6705
|
}
|
|
6678
6706
|
},
|
|
6679
6707
|
{
|
|
6708
|
+
key: exports.ElementKinds.hr,
|
|
6680
6709
|
type: exports.ElementKinds.hr,
|
|
6681
6710
|
markup: '---',
|
|
6682
6711
|
insertTrigger: true
|
|
@@ -13341,7 +13370,7 @@
|
|
|
13341
13370
|
]
|
|
13342
13371
|
});
|
|
13343
13372
|
|
|
13344
|
-
var internalPlugins = [
|
|
13373
|
+
var internalPlugins = function () { return [
|
|
13345
13374
|
createTheHistoryPlugin(),
|
|
13346
13375
|
createAutoInsertDataPlugin(),
|
|
13347
13376
|
createRemoveEmptyPlugin(),
|
|
@@ -13376,7 +13405,7 @@
|
|
|
13376
13405
|
createDeserializeMdPlugin(),
|
|
13377
13406
|
createQuickInsertPlugin(),
|
|
13378
13407
|
createInlineCodePlugin()
|
|
13379
|
-
];
|
|
13408
|
+
]; };
|
|
13380
13409
|
|
|
13381
13410
|
var HOTKEYS = {
|
|
13382
13411
|
'mod+b': exports.MarkTypes.bold,
|
|
@@ -14201,7 +14230,8 @@
|
|
|
14201
14230
|
TheEditorComponent.prototype.initialize = function () {
|
|
14202
14231
|
var _this = this;
|
|
14203
14232
|
var _a, _b;
|
|
14204
|
-
var
|
|
14233
|
+
var defaultPlugins = internalPlugins();
|
|
14234
|
+
var plugins = __spreadArray(__spreadArray([], __read(defaultPlugins)), __read(this.thePlugins));
|
|
14205
14235
|
this.editor = withTheia(slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)), plugins);
|
|
14206
14236
|
this.generateDecorate();
|
|
14207
14237
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
@@ -14909,7 +14939,6 @@
|
|
|
14909
14939
|
exports.getElementWidth = getElementWidth;
|
|
14910
14940
|
exports.getEndBlock = getEndBlock;
|
|
14911
14941
|
exports.getPlugin = getPlugin;
|
|
14912
|
-
exports.getPluginByKey = getPluginByKey;
|
|
14913
14942
|
exports.getPluginOptions = getPluginOptions;
|
|
14914
14943
|
exports.getPlugins = getPlugins;
|
|
14915
14944
|
exports.getRowsTotalHeight = getRowsTotalHeight;
|
|
@@ -14922,6 +14951,7 @@
|
|
|
14922
14951
|
exports.internalPlugins = internalPlugins;
|
|
14923
14952
|
exports.isCleanEmptyParagraph = isCleanEmptyParagraph;
|
|
14924
14953
|
exports.isPureEmptyParagraph = isPureEmptyParagraph;
|
|
14954
|
+
exports.mergeArray = mergeArray;
|
|
14925
14955
|
exports.mergeDeepPlugins = mergeDeepPlugins;
|
|
14926
14956
|
exports.mergeElementOptions = mergeElementOptions;
|
|
14927
14957
|
exports.mergeOptions = mergeOptions;
|