@worktile/theia 3.0.0-next.1 → 3.0.0-next.4
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 +201 -210
- 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 +1 -1
- 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 +5 -5
- 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/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/quick-insert/quick-insert.plugin.js +4 -4
- 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/transforms/index.js +3 -4
- package/esm2015/transforms/insert-elements.js +40 -0
- package/fesm2015/worktile-theia.js +189 -203
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/editor.d.ts +1 -7
- 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/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/transforms/insert-element-next.js +0 -40
- package/esm2015/transforms/insert-element.js +0 -2
- package/transforms/insert-element-next.d.ts +0 -2
- package/transforms/insert-element.d.ts +0 -3
|
@@ -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,49 +1433,183 @@
|
|
|
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
|
|
|
1457
|
-
var mergeOptions = function (plugin,
|
|
1458
|
-
|
|
1459
|
-
var options = overrideByKey[plugin.key].options;
|
|
1440
|
+
var mergeOptions = function (plugin, override) {
|
|
1441
|
+
var options = plugin.options;
|
|
1460
1442
|
var newOptions = {};
|
|
1461
1443
|
for (var option in options) {
|
|
1462
1444
|
if (Array.isArray(options[option])) {
|
|
1463
|
-
newOptions[option] = _.union(options[option],
|
|
1445
|
+
newOptions[option] = _.union(options[option], override.options[option]);
|
|
1464
1446
|
continue;
|
|
1465
1447
|
}
|
|
1466
|
-
newOptions[option] =
|
|
1448
|
+
newOptions[option] = options[option];
|
|
1467
1449
|
}
|
|
1468
1450
|
plugin.options = newOptions;
|
|
1469
1451
|
return plugin;
|
|
1470
1452
|
};
|
|
1471
1453
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1454
|
+
var combinePlugins = function (editor) {
|
|
1455
|
+
// withOverrides
|
|
1456
|
+
editor.plugins.forEach(function (plugin) {
|
|
1457
|
+
if (plugin.withOverrides) {
|
|
1458
|
+
editor = plugin.withOverrides(editor, plugin);
|
|
1459
|
+
}
|
|
1460
|
+
});
|
|
1461
|
+
return editor;
|
|
1462
|
+
};
|
|
1463
|
+
|
|
1464
|
+
var mergeDeepPlugins = function (editor, _plugins) {
|
|
1465
|
+
_plugins.forEach(function (plugin) {
|
|
1466
|
+
if (plugin.overrideByKey) {
|
|
1467
|
+
var newPlugins = _plugins.filter(function (p) { return plugin.overrideByKey[p.key]; });
|
|
1468
|
+
newPlugins.forEach(function (p) {
|
|
1469
|
+
if (editor.pluginsByKey[p.key]) {
|
|
1470
|
+
p = mergeOptions(p, plugin.overrideByKey[p.key]);
|
|
1471
|
+
editor.pluginsByKey[p.key] = _.defaultsDeep(p, plugin.overrideByKey[p.key]);
|
|
1472
|
+
}
|
|
1488
1473
|
});
|
|
1489
1474
|
}
|
|
1475
|
+
});
|
|
1476
|
+
};
|
|
1477
|
+
|
|
1478
|
+
var nestedStructureByKey = function (editor, plugins) {
|
|
1479
|
+
// 如果有 key 重复则进行覆盖
|
|
1480
|
+
plugins.forEach(function (p) {
|
|
1481
|
+
for (var key in p.nestedStructureByKey) {
|
|
1482
|
+
if (!editor.nestedStructureByKey[key]) {
|
|
1483
|
+
editor.nestedStructureByKey[key] = p.nestedStructureByKey[key];
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
});
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
var pluginsByKey = function (editor, plugins) {
|
|
1490
|
+
if (!plugins)
|
|
1491
|
+
return;
|
|
1492
|
+
plugins.forEach(function (p) {
|
|
1493
|
+
if (!editor.pluginsByKey[p.key]) {
|
|
1494
|
+
editor.pluginsByKey[p.key] = p;
|
|
1495
|
+
}
|
|
1496
|
+
});
|
|
1497
|
+
};
|
|
1498
|
+
|
|
1499
|
+
var withTheia = function (editor, plugins) {
|
|
1500
|
+
if (plugins === void 0) { plugins = []; }
|
|
1501
|
+
var e = editor;
|
|
1502
|
+
e.renderElement = function (element) { return null; };
|
|
1503
|
+
e.renderLeaf = function (text) { return null; };
|
|
1504
|
+
e.isContainer = function (value) { return false; };
|
|
1505
|
+
e.extraElementOptions = [];
|
|
1506
|
+
e.disabled = false;
|
|
1507
|
+
e.plugins = [];
|
|
1508
|
+
e.pluginsByKey = {};
|
|
1509
|
+
e.nestedStructureByKey = {};
|
|
1510
|
+
// withOverridesByKey
|
|
1511
|
+
flattenDeepPlugins(e, plugins);
|
|
1512
|
+
// mount pluginsByKey
|
|
1513
|
+
pluginsByKey(e, plugins);
|
|
1514
|
+
// mount nestedStructureByKey
|
|
1515
|
+
nestedStructureByKey(e, e.plugins);
|
|
1516
|
+
// merge plugin to pluginByKey
|
|
1517
|
+
mergeDeepPlugins(e, e.plugins);
|
|
1518
|
+
e = combinePlugins(e);
|
|
1519
|
+
return e;
|
|
1520
|
+
};
|
|
1521
|
+
|
|
1522
|
+
var createPluginFactory = function (defaultPlugin) { return function (override, overrideByKey) {
|
|
1523
|
+
if (overrideByKey === void 0) { overrideByKey = {}; }
|
|
1524
|
+
return defaultPlugin;
|
|
1525
|
+
}; };
|
|
1526
|
+
|
|
1527
|
+
var toolbarInitialize = function (toolbarItems, global, inline, quick) {
|
|
1528
|
+
if (global === void 0) { global = DefaultGlobalToolbarDefinition; }
|
|
1529
|
+
if (inline === void 0) { inline = DefaultInlineToolbarDefinition; }
|
|
1530
|
+
if (quick === void 0) { quick = DefaultQuickToolbarDefinition; }
|
|
1531
|
+
var toolbarDefinition = {
|
|
1532
|
+
global: global,
|
|
1533
|
+
inline: inline,
|
|
1534
|
+
quick: quick
|
|
1535
|
+
};
|
|
1536
|
+
var toolbarOperations = new Map();
|
|
1537
|
+
toolbarItems.forEach(function (i) { return toolbarOperations.set(i.key, i); });
|
|
1538
|
+
var toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
|
|
1539
|
+
return {
|
|
1540
|
+
toolbarDefinition: toolbarDefinition,
|
|
1541
|
+
toolbarOperations: toolbarOperations,
|
|
1542
|
+
toolbarEntity: toolbarEntity
|
|
1543
|
+
};
|
|
1544
|
+
};
|
|
1545
|
+
var nextToolbarEntity = function (toolbarDefinition, toolbarItems) {
|
|
1546
|
+
var entity = {};
|
|
1547
|
+
for (var defKey in toolbarDefinition) {
|
|
1548
|
+
entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
|
|
1490
1549
|
}
|
|
1491
|
-
|
|
1492
|
-
|
|
1550
|
+
return entity;
|
|
1551
|
+
};
|
|
1552
|
+
var getToolbarItemByKeys = function (keys, toolbarItems) {
|
|
1553
|
+
var items = [];
|
|
1554
|
+
keys.forEach(function (key) {
|
|
1555
|
+
if (key === "split") {
|
|
1556
|
+
items.push({ key: "split" });
|
|
1557
|
+
return;
|
|
1558
|
+
}
|
|
1559
|
+
var item = toolbarItems.get(key);
|
|
1560
|
+
if (item && item.includes) {
|
|
1561
|
+
items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
|
|
1562
|
+
return;
|
|
1563
|
+
}
|
|
1564
|
+
if (item) {
|
|
1565
|
+
items.push(item);
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
return items;
|
|
1569
|
+
};
|
|
1570
|
+
var createToolbar = function (editor, toolbar) {
|
|
1571
|
+
var toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce(function (prevItems, nextPlugin) {
|
|
1572
|
+
var _a;
|
|
1573
|
+
prevItems.push.apply(prevItems, __spreadArray([], __read(((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []))));
|
|
1574
|
+
return prevItems;
|
|
1575
|
+
}, []);
|
|
1576
|
+
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);
|
|
1577
|
+
var globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
|
|
1578
|
+
var toolbarEntity = toolbarOption.toolbarEntity;
|
|
1579
|
+
return {
|
|
1580
|
+
globalToolbarClass: globalToolbarClass,
|
|
1581
|
+
toolbarEntity: toolbarEntity
|
|
1582
|
+
};
|
|
1583
|
+
};
|
|
1584
|
+
|
|
1585
|
+
var UNDOING = new WeakMap();
|
|
1586
|
+
var REDOING = new WeakMap();
|
|
1587
|
+
var withTheHistory = function (editor) {
|
|
1588
|
+
var undo = editor.undo, redo = editor.redo;
|
|
1589
|
+
editor.undo = function () {
|
|
1590
|
+
UNDOING.set(editor, true);
|
|
1591
|
+
undo();
|
|
1592
|
+
UNDOING.set(editor, false);
|
|
1593
|
+
};
|
|
1594
|
+
editor.redo = function () {
|
|
1595
|
+
REDOING.set(editor, true);
|
|
1596
|
+
redo();
|
|
1597
|
+
REDOING.set(editor, false);
|
|
1598
|
+
};
|
|
1599
|
+
return editor;
|
|
1600
|
+
};
|
|
1601
|
+
var TheHistoryEditor = {
|
|
1602
|
+
isUndoing: function (editor) {
|
|
1603
|
+
return UNDOING.get(editor);
|
|
1604
|
+
},
|
|
1605
|
+
isRedoing: function (editor) {
|
|
1606
|
+
return REDOING.get(editor);
|
|
1493
1607
|
}
|
|
1494
|
-
return plugin;
|
|
1495
1608
|
};
|
|
1609
|
+
var createTheHistoryPlugin = createPluginFactory({
|
|
1610
|
+
key: exports.PluginKeys.theHistory,
|
|
1611
|
+
withOverrides: withTheHistory
|
|
1612
|
+
});
|
|
1496
1613
|
|
|
1497
1614
|
var setMarks = function (editor, marks, at) {
|
|
1498
1615
|
slate.Transforms.setNodes(editor, marks, {
|
|
@@ -1522,8 +1639,6 @@
|
|
|
1522
1639
|
}
|
|
1523
1640
|
};
|
|
1524
1641
|
|
|
1525
|
-
var insertElement = function (editor, element) { return editor.insertElement(element); };
|
|
1526
|
-
|
|
1527
1642
|
var isAncestor = function (node) { return slate.Element.isElement(node) || slate.Editor.isEditor(node); };
|
|
1528
1643
|
|
|
1529
1644
|
var getLastChild$1 = function (node, level) {
|
|
@@ -2348,7 +2463,7 @@
|
|
|
2348
2463
|
someNode: someNode
|
|
2349
2464
|
});
|
|
2350
2465
|
|
|
2351
|
-
var
|
|
2466
|
+
var insertElements = function (editor, element) {
|
|
2352
2467
|
var _a;
|
|
2353
2468
|
if (slate.Range.isExpanded(editor.selection)) {
|
|
2354
2469
|
slate.Editor.deleteFragment(editor);
|
|
@@ -2576,8 +2691,7 @@
|
|
|
2576
2691
|
__proto__: null,
|
|
2577
2692
|
setMarks: setMarks,
|
|
2578
2693
|
clearMarks: clearMarks,
|
|
2579
|
-
|
|
2580
|
-
insertElementNext: insertElementNext,
|
|
2694
|
+
insertElements: insertElements,
|
|
2581
2695
|
insertParagraph: insertParagraph,
|
|
2582
2696
|
setNode: setNode,
|
|
2583
2697
|
unwrapNodesByType: unwrapNodesByType,
|
|
@@ -2594,134 +2708,6 @@
|
|
|
2594
2708
|
handleContinualInsertBreak: handleContinualInsertBreak
|
|
2595
2709
|
});
|
|
2596
2710
|
|
|
2597
|
-
var withTheia = function (editor, plugins) {
|
|
2598
|
-
if (plugins === void 0) { plugins = []; }
|
|
2599
|
-
var e = editor;
|
|
2600
|
-
e.renderElement = function (element) { return null; };
|
|
2601
|
-
e.renderLeaf = function (text) { return null; };
|
|
2602
|
-
e.insertElement = function (element) { return insertElementNext(e, element); };
|
|
2603
|
-
e.isContainer = function (value) { return false; };
|
|
2604
|
-
e.extraElementOptions = [];
|
|
2605
|
-
e.disabled = false;
|
|
2606
|
-
e.plugins = [];
|
|
2607
|
-
e.pluginsByKey = {};
|
|
2608
|
-
e.nestedStructureByKey = {};
|
|
2609
|
-
// withOverridesByKey
|
|
2610
|
-
flattenDeepPlugins(e, plugins);
|
|
2611
|
-
// 如果 plugin.overrideByKey 存在,则把 plugin.overrideByKey 中的所有 key 覆盖到 editor.pluginsByKey 中
|
|
2612
|
-
editor.plugins.forEach(function (plugin) {
|
|
2613
|
-
if (plugin.overrideByKey) {
|
|
2614
|
-
var newPlugins = editor.plugins.map(function (p) {
|
|
2615
|
-
return overridePluginsByKey(p, plugin.overrideByKey);
|
|
2616
|
-
});
|
|
2617
|
-
editor.plugins = [];
|
|
2618
|
-
editor.pluginsByKey = {};
|
|
2619
|
-
// 再次扁平化覆盖
|
|
2620
|
-
flattenDeepPlugins(editor, newPlugins);
|
|
2621
|
-
}
|
|
2622
|
-
});
|
|
2623
|
-
// withOverrides
|
|
2624
|
-
e.plugins.forEach(function (plugin) {
|
|
2625
|
-
if (plugin.withOverrides) {
|
|
2626
|
-
e = plugin.withOverrides(e, plugin);
|
|
2627
|
-
}
|
|
2628
|
-
});
|
|
2629
|
-
return e;
|
|
2630
|
-
};
|
|
2631
|
-
|
|
2632
|
-
var createPluginFactory = function (defaultPlugin) { return function (override, overrideByKey) {
|
|
2633
|
-
if (overrideByKey === void 0) { overrideByKey = {}; }
|
|
2634
|
-
overrideByKey[defaultPlugin.key] = override;
|
|
2635
|
-
return overridePluginsByKey(Object.assign({}, defaultPlugin), overrideByKey);
|
|
2636
|
-
}; };
|
|
2637
|
-
|
|
2638
|
-
var toolbarInitialize = function (toolbarItems, global, inline, quick) {
|
|
2639
|
-
if (global === void 0) { global = DefaultGlobalToolbarDefinition; }
|
|
2640
|
-
if (inline === void 0) { inline = DefaultInlineToolbarDefinition; }
|
|
2641
|
-
if (quick === void 0) { quick = DefaultQuickToolbarDefinition; }
|
|
2642
|
-
var toolbarDefinition = {
|
|
2643
|
-
global: global,
|
|
2644
|
-
inline: inline,
|
|
2645
|
-
quick: quick
|
|
2646
|
-
};
|
|
2647
|
-
var toolbarOperations = new Map();
|
|
2648
|
-
toolbarItems.forEach(function (i) { return toolbarOperations.set(i.key, i); });
|
|
2649
|
-
var toolbarEntity = nextToolbarEntity(toolbarDefinition, toolbarOperations);
|
|
2650
|
-
return {
|
|
2651
|
-
toolbarDefinition: toolbarDefinition,
|
|
2652
|
-
toolbarOperations: toolbarOperations,
|
|
2653
|
-
toolbarEntity: toolbarEntity
|
|
2654
|
-
};
|
|
2655
|
-
};
|
|
2656
|
-
var nextToolbarEntity = function (toolbarDefinition, toolbarItems) {
|
|
2657
|
-
var entity = {};
|
|
2658
|
-
for (var defKey in toolbarDefinition) {
|
|
2659
|
-
entity[defKey] = getToolbarItemByKeys(toolbarDefinition[defKey], toolbarItems);
|
|
2660
|
-
}
|
|
2661
|
-
return entity;
|
|
2662
|
-
};
|
|
2663
|
-
var getToolbarItemByKeys = function (keys, toolbarItems) {
|
|
2664
|
-
var items = [];
|
|
2665
|
-
keys.forEach(function (key) {
|
|
2666
|
-
if (key === "split") {
|
|
2667
|
-
items.push({ key: "split" });
|
|
2668
|
-
return;
|
|
2669
|
-
}
|
|
2670
|
-
var item = toolbarItems.get(key);
|
|
2671
|
-
if (item && item.includes) {
|
|
2672
|
-
items.push(Object.assign(Object.assign({}, item), { includes: getToolbarItemByKeys(item.includes, toolbarItems) }));
|
|
2673
|
-
return;
|
|
2674
|
-
}
|
|
2675
|
-
if (item) {
|
|
2676
|
-
items.push(item);
|
|
2677
|
-
}
|
|
2678
|
-
});
|
|
2679
|
-
return items;
|
|
2680
|
-
};
|
|
2681
|
-
var createToolbar = function (editor, toolbar) {
|
|
2682
|
-
var toolbarItems = editor === null || editor === void 0 ? void 0 : editor.plugins.reduce(function (prevItems, nextPlugin) {
|
|
2683
|
-
var _a;
|
|
2684
|
-
prevItems.push.apply(prevItems, __spreadArray([], __read(((_a = nextPlugin === null || nextPlugin === void 0 ? void 0 : nextPlugin.toolbarItems) !== null && _a !== void 0 ? _a : []))));
|
|
2685
|
-
return prevItems;
|
|
2686
|
-
}, []);
|
|
2687
|
-
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);
|
|
2688
|
-
var globalToolbarClass = ['the-global-toolbar', getToolbarClass(editor)];
|
|
2689
|
-
var toolbarEntity = toolbarOption.toolbarEntity;
|
|
2690
|
-
return {
|
|
2691
|
-
globalToolbarClass: globalToolbarClass,
|
|
2692
|
-
toolbarEntity: toolbarEntity
|
|
2693
|
-
};
|
|
2694
|
-
};
|
|
2695
|
-
|
|
2696
|
-
var UNDOING = new WeakMap();
|
|
2697
|
-
var REDOING = new WeakMap();
|
|
2698
|
-
var withTheHistory = function (editor) {
|
|
2699
|
-
var undo = editor.undo, redo = editor.redo;
|
|
2700
|
-
editor.undo = function () {
|
|
2701
|
-
UNDOING.set(editor, true);
|
|
2702
|
-
undo();
|
|
2703
|
-
UNDOING.set(editor, false);
|
|
2704
|
-
};
|
|
2705
|
-
editor.redo = function () {
|
|
2706
|
-
REDOING.set(editor, true);
|
|
2707
|
-
redo();
|
|
2708
|
-
REDOING.set(editor, false);
|
|
2709
|
-
};
|
|
2710
|
-
return editor;
|
|
2711
|
-
};
|
|
2712
|
-
var TheHistoryEditor = {
|
|
2713
|
-
isUndoing: function (editor) {
|
|
2714
|
-
return UNDOING.get(editor);
|
|
2715
|
-
},
|
|
2716
|
-
isRedoing: function (editor) {
|
|
2717
|
-
return REDOING.get(editor);
|
|
2718
|
-
}
|
|
2719
|
-
};
|
|
2720
|
-
var createTheHistoryPlugin = createPluginFactory({
|
|
2721
|
-
key: exports.PluginKeys.theHistory,
|
|
2722
|
-
withOverrides: withTheHistory
|
|
2723
|
-
});
|
|
2724
|
-
|
|
2725
2711
|
var TheConversionHintComponent = /** @class */ (function () {
|
|
2726
2712
|
function TheConversionHintComponent() {
|
|
2727
2713
|
this.duration = 10000;
|
|
@@ -4411,7 +4397,6 @@
|
|
|
4411
4397
|
}
|
|
4412
4398
|
// wrap
|
|
4413
4399
|
ListEditor.buildListItem(editor);
|
|
4414
|
-
// Todo: types
|
|
4415
4400
|
slate.Transforms.wrapNodes(editor, { type: type, children: [], start: startIndex }, {
|
|
4416
4401
|
at: editor.selection,
|
|
4417
4402
|
match: function (node) { return slate.Element.isElement(node) && node.type === exports.ElementKinds.listItem; }
|
|
@@ -4764,18 +4749,21 @@
|
|
|
4764
4749
|
enumerable: false,
|
|
4765
4750
|
configurable: true
|
|
4766
4751
|
});
|
|
4752
|
+
Object.defineProperty(TheTodoItemComponent.prototype, "editableWithReadonly", {
|
|
4753
|
+
get: function () {
|
|
4754
|
+
var _a;
|
|
4755
|
+
return (_a = getPluginOptions(this.editor, exports.PluginKeys.checkItem)) === null || _a === void 0 ? void 0 : _a.editableWithReadonly;
|
|
4756
|
+
},
|
|
4757
|
+
enumerable: false,
|
|
4758
|
+
configurable: true
|
|
4759
|
+
});
|
|
4767
4760
|
TheTodoItemComponent.prototype.ngOnInit = function () {
|
|
4768
4761
|
_super.prototype.ngOnInit.call(this);
|
|
4769
4762
|
};
|
|
4770
4763
|
TheTodoItemComponent.prototype.onCheck = function (checked) {
|
|
4771
|
-
|
|
4772
|
-
var noBindReadonly = options.noBindReadonlyPlugins && options.noBindReadonlyPlugins.includes(exports.ElementKinds.checkItem);
|
|
4773
|
-
if (!noBindReadonly && this.readonly) {
|
|
4764
|
+
if (this.readonly && !this.editableWithReadonly) {
|
|
4774
4765
|
return false;
|
|
4775
4766
|
}
|
|
4776
|
-
else {
|
|
4777
|
-
setNode(this.editor, { checked: checked }, this.element);
|
|
4778
|
-
}
|
|
4779
4767
|
setNode(this.editor, { checked: checked }, this.element);
|
|
4780
4768
|
};
|
|
4781
4769
|
return TheTodoItemComponent;
|
|
@@ -4891,7 +4879,8 @@
|
|
|
4891
4879
|
}
|
|
4892
4880
|
],
|
|
4893
4881
|
options: {
|
|
4894
|
-
allowParentTypes: [exports.ElementKinds.tableCell, exports.ElementKinds.blockquote]
|
|
4882
|
+
allowParentTypes: [exports.ElementKinds.tableCell, exports.ElementKinds.blockquote],
|
|
4883
|
+
editableWithReadonly: false
|
|
4895
4884
|
}
|
|
4896
4885
|
});
|
|
4897
4886
|
|
|
@@ -4926,7 +4915,7 @@
|
|
|
4926
4915
|
|
|
4927
4916
|
var HrEditor = {
|
|
4928
4917
|
insertHr: function (editor) {
|
|
4929
|
-
|
|
4918
|
+
insertElements(editor, { type: exports.ElementKinds.hr, children: [{ text: '' }] });
|
|
4930
4919
|
}
|
|
4931
4920
|
};
|
|
4932
4921
|
|
|
@@ -5546,7 +5535,7 @@
|
|
|
5546
5535
|
}
|
|
5547
5536
|
// Create the table node
|
|
5548
5537
|
var table = createTable(opts, columns, rows, getCellContent);
|
|
5549
|
-
|
|
5538
|
+
insertElements(editor, table);
|
|
5550
5539
|
}
|
|
5551
5540
|
|
|
5552
5541
|
/**
|
|
@@ -6417,13 +6406,13 @@
|
|
|
6417
6406
|
|
|
6418
6407
|
var BlockquoteEditor = {
|
|
6419
6408
|
toggleBlockquote: function (editor) {
|
|
6409
|
+
var _a;
|
|
6420
6410
|
var isActive = isBlockActive(editor, exports.ElementKinds.blockquote);
|
|
6411
|
+
var allowParentTypes = ((_a = getPluginOptions(editor, exports.PluginKeys.blockquote)) === null || _a === void 0 ? void 0 : _a.allowParentTypes) || [];
|
|
6421
6412
|
if (!isActive) {
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
};
|
|
6426
|
-
insertElement(editor, blockquoteElement);
|
|
6413
|
+
slate.Transforms.wrapNodes(editor, { type: exports.ElementKinds.blockquote, children: [] }, {
|
|
6414
|
+
mode: 'lowest'
|
|
6415
|
+
});
|
|
6427
6416
|
}
|
|
6428
6417
|
else {
|
|
6429
6418
|
slate.Transforms.unwrapNodes(editor, { match: function (n) { return slate.Element.isElement(n) && n.type === exports.ElementKinds.blockquote; } });
|
|
@@ -6511,7 +6500,7 @@
|
|
|
6511
6500
|
language: DEFAULT_LANGUAGE.value,
|
|
6512
6501
|
children: [{ text: '' }]
|
|
6513
6502
|
};
|
|
6514
|
-
|
|
6503
|
+
insertElements(editor, codeElement);
|
|
6515
6504
|
}
|
|
6516
6505
|
else {
|
|
6517
6506
|
var codeElement = {
|
|
@@ -6520,7 +6509,7 @@
|
|
|
6520
6509
|
language: DEFAULT_LANGUAGE.value,
|
|
6521
6510
|
children: [{ text: '' }]
|
|
6522
6511
|
};
|
|
6523
|
-
|
|
6512
|
+
insertElements(editor, codeElement);
|
|
6524
6513
|
}
|
|
6525
6514
|
}
|
|
6526
6515
|
};
|
|
@@ -6666,10 +6655,9 @@
|
|
|
6666
6655
|
}
|
|
6667
6656
|
];
|
|
6668
6657
|
|
|
6669
|
-
var mergAutoFormateRules = function (
|
|
6670
|
-
var combinationData = __spreadArray(__spreadArray([], __read(defaultAutoFormatRules)), __read(extraAutoFormatRules));
|
|
6658
|
+
var mergAutoFormateRules = function (rules) {
|
|
6671
6659
|
var dataInfo = {};
|
|
6672
|
-
|
|
6660
|
+
rules.forEach(function (item) {
|
|
6673
6661
|
if (!dataInfo[item.type + item.key]) {
|
|
6674
6662
|
dataInfo[item.type + item.key] = Object.assign({}, item);
|
|
6675
6663
|
}
|
|
@@ -6682,11 +6670,9 @@
|
|
|
6682
6670
|
editor.insertText = function (text) {
|
|
6683
6671
|
var e_1, _d;
|
|
6684
6672
|
var _a, _b;
|
|
6685
|
-
var autoFormatRules =
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
autoFormatRules = Object.values(extraRules);
|
|
6689
|
-
}
|
|
6673
|
+
var autoFormatRules = (_a = getPluginOptions(editor, exports.PluginKeys.autoFormat)) === null || _a === void 0 ? void 0 : _a.autoFormatRules;
|
|
6674
|
+
var extraRules = mergAutoFormateRules(autoFormatRules);
|
|
6675
|
+
autoFormatRules = Object.values(extraRules);
|
|
6690
6676
|
if (!isCollapsed(editor.selection)) {
|
|
6691
6677
|
return insertText(text);
|
|
6692
6678
|
}
|
|
@@ -6780,7 +6766,10 @@
|
|
|
6780
6766
|
};
|
|
6781
6767
|
var createAutoFormatPlugin = createPluginFactory({
|
|
6782
6768
|
key: exports.PluginKeys.autoFormat,
|
|
6783
|
-
withOverrides: withAutoFormat
|
|
6769
|
+
withOverrides: withAutoFormat,
|
|
6770
|
+
options: {
|
|
6771
|
+
autoFormatRules: defaultAutoFormatRules
|
|
6772
|
+
}
|
|
6784
6773
|
});
|
|
6785
6774
|
|
|
6786
6775
|
var withTransforms = function (editor) {
|
|
@@ -12333,10 +12322,10 @@
|
|
|
12333
12322
|
var onKeydown = editor.onKeydown, deleteBackward = editor.deleteBackward, onChange = editor.onChange;
|
|
12334
12323
|
var presseingQuickInsertHotkey = false;
|
|
12335
12324
|
editor.onKeydown = function (event) {
|
|
12336
|
-
var
|
|
12337
|
-
var hotkey =
|
|
12325
|
+
var options = getPluginOptions(editor, exports.PluginKeys.quickInsert);
|
|
12326
|
+
var hotkey = options.hotkey, allowHotkeyInTypes = options.allowHotkeyInTypes;
|
|
12338
12327
|
if (event.key === hotkey) {
|
|
12339
|
-
var types = __spreadArray([], __read((
|
|
12328
|
+
var types = __spreadArray([], __read((allowHotkeyInTypes || [])));
|
|
12340
12329
|
var _c = __read(getBlockAbove(editor), 1), block = _c[0];
|
|
12341
12330
|
if (isPureEmptyParagraph(editor, block) && allowOpenQuickToolbar(editor, types)) {
|
|
12342
12331
|
presseingQuickInsertHotkey = true;
|
|
@@ -14182,13 +14171,12 @@
|
|
|
14182
14171
|
};
|
|
14183
14172
|
TheEditorComponent.prototype.initialize = function () {
|
|
14184
14173
|
var _this = this;
|
|
14185
|
-
var _a, _b
|
|
14174
|
+
var _a, _b;
|
|
14186
14175
|
var plugins = __spreadArray(__spreadArray([], __read(internalPlugins)), __read(this.thePlugins));
|
|
14187
14176
|
this.editor = withTheia(slateHistory.withHistory(i1.withAngular(slate.createEditor(), CLIPBOARD_FORMAT_KEY)), plugins);
|
|
14188
14177
|
this.generateDecorate();
|
|
14189
14178
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
14190
14179
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
14191
|
-
this.editor.extraAutoFormatRules = (_c = this.theOptions) === null || _c === void 0 ? void 0 : _c.extraAutoFormatRules;
|
|
14192
14180
|
this.editor.options = this.theOptions;
|
|
14193
14181
|
setEditorUUID(this.editor, idCreator());
|
|
14194
14182
|
this.theContextService.initialize({
|
|
@@ -14874,6 +14862,7 @@
|
|
|
14874
14862
|
exports.autoFocus = autoFocus;
|
|
14875
14863
|
exports.autoScrollViewHandle = autoScrollViewHandle;
|
|
14876
14864
|
exports.coercePixelsFromCssValue = coercePixelsFromCssValue;
|
|
14865
|
+
exports.combinePlugins = combinePlugins;
|
|
14877
14866
|
exports.createEmptyParagraph = createEmptyParagraph;
|
|
14878
14867
|
exports.createPluginFactory = createPluginFactory;
|
|
14879
14868
|
exports.createToolbar = createToolbar;
|
|
@@ -14891,9 +14880,9 @@
|
|
|
14891
14880
|
exports.getElementWidth = getElementWidth;
|
|
14892
14881
|
exports.getEndBlock = getEndBlock;
|
|
14893
14882
|
exports.getPlugin = getPlugin;
|
|
14883
|
+
exports.getPluginByKey = getPluginByKey;
|
|
14894
14884
|
exports.getPluginOptions = getPluginOptions;
|
|
14895
14885
|
exports.getPlugins = getPlugins;
|
|
14896
|
-
exports.getPluginsByKey = getPluginsByKey;
|
|
14897
14886
|
exports.getRowsTotalHeight = getRowsTotalHeight;
|
|
14898
14887
|
exports.getStartBlock = getStartBlock;
|
|
14899
14888
|
exports.getToolbarClass = getToolbarClass;
|
|
@@ -14904,10 +14893,12 @@
|
|
|
14904
14893
|
exports.internalPlugins = internalPlugins;
|
|
14905
14894
|
exports.isCleanEmptyParagraph = isCleanEmptyParagraph;
|
|
14906
14895
|
exports.isPureEmptyParagraph = isPureEmptyParagraph;
|
|
14896
|
+
exports.mergeDeepPlugins = mergeDeepPlugins;
|
|
14907
14897
|
exports.mergeElementOptions = mergeElementOptions;
|
|
14908
14898
|
exports.mergeOptions = mergeOptions;
|
|
14909
|
-
exports.
|
|
14899
|
+
exports.nestedStructureByKey = nestedStructureByKey;
|
|
14910
14900
|
exports.plainToTheia = plainToTheia;
|
|
14901
|
+
exports.pluginsByKey = pluginsByKey;
|
|
14911
14902
|
exports.setEditorUUID = setEditorUUID;
|
|
14912
14903
|
exports.useElementStyle = useElementStyle;
|
|
14913
14904
|
exports.withTheia = withTheia;
|