@worktile/theia 2.1.2 → 2.1.6
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 +426 -221
- package/bundles/worktile-theia.umd.js.map +1 -1
- package/components/toolbar/toolbar.component.d.ts +1 -3
- package/constants/default.d.ts +1 -1
- package/constants/node-types.d.ts +4 -3
- package/custom-types.d.ts +4 -1
- package/editor.component.d.ts +0 -2
- package/editor.module.d.ts +4 -5
- package/esm2015/components/inline-toolbar/inline-toolbar.component.js +1 -1
- package/esm2015/components/toolbar/toolbar.component.js +9 -8
- package/esm2015/components/toolbar-group/toolbar-group.component.js +1 -1
- package/esm2015/constants/auto-format-rules.js +8 -3
- package/esm2015/constants/default.js +2 -2
- package/esm2015/constants/node-types.js +5 -4
- package/esm2015/constants/toolbar.js +5 -5
- package/esm2015/custom-types.js +1 -1
- package/esm2015/editor.component.js +24 -22
- package/esm2015/editor.module.js +4 -4
- package/esm2015/interfaces/auto-format.js +1 -1
- package/esm2015/interfaces/editor.js +1 -1
- package/esm2015/interfaces/element.js +1 -1
- package/esm2015/plugins/autoformat/autoformat.plugin.js +2 -1
- package/esm2015/plugins/autoformat/transforms/auto-format-inline.js +27 -14
- package/esm2015/plugins/code/code.component.js +26 -10
- package/esm2015/plugins/deserializers/deserialize-md.plugin.js +2 -2
- package/esm2015/plugins/font-size/font-size.editor.js +35 -1
- package/esm2015/plugins/heading/heading.editor.js +3 -1
- package/esm2015/plugins/index.js +7 -3
- package/esm2015/plugins/inline-code/inline-code.component.js +27 -0
- package/esm2015/plugins/inline-code/inline-code.editor.js +45 -0
- package/esm2015/plugins/inline-code/inline-code.plugin.js +46 -0
- package/esm2015/plugins/inline-code/options.js +14 -0
- package/esm2015/plugins/link/link.component.js +4 -2
- package/esm2015/plugins/list/components/list-item.component.js +69 -1
- package/esm2015/plugins/list/transforms/insert-list-item.js +11 -7
- package/esm2015/plugins/mark/mark.plugin.js +15 -10
- package/esm2015/plugins/mark/options.js +1 -9
- package/esm2015/plugins/quick-insert/components/quick-insert.component.js +10 -9
- package/esm2015/services/context.service.js +9 -1
- package/esm2015/shortcuts/mark.js +10 -4
- package/esm2015/transforms/handle-continual-insert-break.js +1 -4
- package/esm2015/utils/index.js +2 -1
- package/fesm2015/worktile-theia.js +395 -204
- package/fesm2015/worktile-theia.js.map +1 -1
- package/interfaces/auto-format.d.ts +1 -1
- package/interfaces/editor.d.ts +3 -3
- package/interfaces/element.d.ts +1 -1
- package/package.json +1 -1
- package/plugins/autoformat/transforms/auto-format-inline.d.ts +3 -1
- package/plugins/code/code.component.d.ts +6 -3
- package/plugins/code/code.component.scss +17 -0
- package/plugins/font-size/font-size.editor.d.ts +2 -0
- package/plugins/inline-code/inline-code.component.d.ts +14 -0
- package/plugins/inline-code/inline-code.component.scss +13 -0
- package/plugins/inline-code/inline-code.editor.d.ts +7 -0
- package/plugins/inline-code/inline-code.plugin.d.ts +2 -0
- package/plugins/inline-code/options.d.ts +2 -0
- package/plugins/list/components/list-item.component.d.ts +7 -0
- package/plugins/quick-insert/components/quick-insert.component.d.ts +2 -1
- package/queries/get-container-blocks.d.ts +1 -1
- package/queries/get-selection-marks.d.ts +1 -1
- package/services/context.service.d.ts +5 -1
- package/styles/editor.scss +20 -1
- package/styles/index.scss +1 -1
- package/transforms/set-marks.d.ts +1 -1
- package/utils/index.d.ts +1 -0
- package/esm2015/plugins/placeholder/placeholder.component.js +0 -83
- package/plugins/placeholder/placeholder.component.d.ts +0 -21
- package/plugins/placeholder/placeholder.component.scss +0 -10
|
@@ -20,7 +20,7 @@ import * as i2 from '@angular/cdk/overlay';
|
|
|
20
20
|
import { Overlay, OverlayModule } from '@angular/cdk/overlay';
|
|
21
21
|
import * as i1$1 from 'ngx-tethys/alert';
|
|
22
22
|
import { ThyAlertModule } from 'ngx-tethys/alert';
|
|
23
|
-
import { map, take, delay, startWith, distinctUntilChanged, skip, share, filter, throttleTime,
|
|
23
|
+
import { map, takeUntil, take, delay, startWith, distinctUntilChanged, skip, share, filter, throttleTime, mapTo, debounceTime, pairwise } from 'rxjs/operators';
|
|
24
24
|
import { ThyUploadStatus } from 'ngx-tethys/uploader';
|
|
25
25
|
import * as i1$2 from '@angular/platform-browser';
|
|
26
26
|
import { fromEvent, timer, Subject, combineLatest, Observable, BehaviorSubject, merge, ReplaySubject } from 'rxjs';
|
|
@@ -65,10 +65,10 @@ const PICTURE_ACCEPTED_UPLOAD_SIZE = 20;
|
|
|
65
65
|
const A_TAG_REL_ATTR = 'noopener noreferrer nofollow external ugc';
|
|
66
66
|
const LINK_DEFAULT_TEXT = '链接';
|
|
67
67
|
const TAB_SPACE = ' ';
|
|
68
|
-
const ZERO_WIDTH_CHAR = '\u200B';
|
|
69
68
|
const CLIPBOARD_FORMAT_KEY = 'x-theia-fragment';
|
|
70
69
|
const DEFAULT_SCROLL_CONTAINER = '.the-editable-container';
|
|
71
70
|
const ELEMENT_UNIQUE_ID = 'key';
|
|
71
|
+
const ZERO_WIDTH_CHAR = '\u200B';
|
|
72
72
|
var TheMode;
|
|
73
73
|
(function (TheMode) {
|
|
74
74
|
TheMode["fullMode"] = "full";
|
|
@@ -99,6 +99,7 @@ var ElementKinds;
|
|
|
99
99
|
ElementKinds["hr"] = "hr";
|
|
100
100
|
ElementKinds["link"] = "link";
|
|
101
101
|
ElementKinds["default"] = "paragraph";
|
|
102
|
+
ElementKinds["inlineCode"] = "inline-code";
|
|
102
103
|
})(ElementKinds || (ElementKinds = {}));
|
|
103
104
|
var Alignment;
|
|
104
105
|
(function (Alignment) {
|
|
@@ -148,8 +149,8 @@ var MarkTypes;
|
|
|
148
149
|
MarkTypes["strike"] = "strike";
|
|
149
150
|
MarkTypes["color"] = "color";
|
|
150
151
|
MarkTypes["backgroundColor"] = "background-color";
|
|
151
|
-
MarkTypes["codeLine"] = "code-line";
|
|
152
152
|
MarkTypes["fontSize"] = "font-size";
|
|
153
|
+
MarkTypes["codeLine"] = "code-line";
|
|
153
154
|
})(MarkTypes || (MarkTypes = {}));
|
|
154
155
|
var ToolbarActionTypes;
|
|
155
156
|
(function (ToolbarActionTypes) {
|
|
@@ -174,12 +175,12 @@ var ToolbarActionTypes;
|
|
|
174
175
|
const MarkProps = [
|
|
175
176
|
MarkTypes.backgroundColor,
|
|
176
177
|
MarkTypes.bold,
|
|
177
|
-
MarkTypes.codeLine,
|
|
178
178
|
MarkTypes.color,
|
|
179
179
|
MarkTypes.italic,
|
|
180
180
|
MarkTypes.strike,
|
|
181
181
|
MarkTypes.underline,
|
|
182
|
-
MarkTypes.fontSize
|
|
182
|
+
MarkTypes.fontSize,
|
|
183
|
+
MarkTypes.codeLine
|
|
183
184
|
];
|
|
184
185
|
const THE_INLINE_TOOLBAR_TYPES = [ElementKinds.default, ElementKinds.listItem, ElementKinds.checkItem];
|
|
185
186
|
const STANDARD_HEADING_TYPES = [
|
|
@@ -215,7 +216,7 @@ const DefaultGlobalToolbarDefinition = [
|
|
|
215
216
|
MarkTypes.italic,
|
|
216
217
|
MarkTypes.underline,
|
|
217
218
|
MarkTypes.strike,
|
|
218
|
-
|
|
219
|
+
ElementKinds.inlineCode,
|
|
219
220
|
MarkTypes.color,
|
|
220
221
|
MarkTypes.backgroundColor,
|
|
221
222
|
ToolbarActionTypes.split,
|
|
@@ -224,7 +225,7 @@ const DefaultGlobalToolbarDefinition = [
|
|
|
224
225
|
ToolbarActionTypes.split,
|
|
225
226
|
ElementKinds.numberedList,
|
|
226
227
|
ElementKinds.bulletedList,
|
|
227
|
-
ElementKinds.checkItem,
|
|
228
|
+
// ElementKinds.checkItem,
|
|
228
229
|
ToolbarActionTypes.split,
|
|
229
230
|
ElementKinds.link,
|
|
230
231
|
ElementKinds.image,
|
|
@@ -239,7 +240,7 @@ const DefaultInlineToolbarDefinition = [
|
|
|
239
240
|
MarkTypes.italic,
|
|
240
241
|
MarkTypes.underline,
|
|
241
242
|
MarkTypes.strike,
|
|
242
|
-
|
|
243
|
+
ElementKinds.inlineCode,
|
|
243
244
|
MarkTypes.color,
|
|
244
245
|
MarkTypes.backgroundColor,
|
|
245
246
|
ToolbarActionTypes.split,
|
|
@@ -252,7 +253,7 @@ const DefaultQuickToolbarDefinition = [
|
|
|
252
253
|
ToolbarActionTypes.split,
|
|
253
254
|
ElementKinds.numberedList,
|
|
254
255
|
ElementKinds.bulletedList,
|
|
255
|
-
ElementKinds.checkItem,
|
|
256
|
+
// ElementKinds.checkItem,
|
|
256
257
|
ToolbarActionTypes.split,
|
|
257
258
|
ElementKinds.link,
|
|
258
259
|
ElementKinds.image,
|
|
@@ -1538,9 +1539,6 @@ function handleContinualInsertBreak(editor, lowestBlock, type) {
|
|
|
1538
1539
|
const aboveResult = Editor.above(editor, {
|
|
1539
1540
|
match: n => Editor.isBlock(editor, n) && n.type === type
|
|
1540
1541
|
});
|
|
1541
|
-
if (isEnd) {
|
|
1542
|
-
editor.marks = {};
|
|
1543
|
-
}
|
|
1544
1542
|
if (aboveResult && aboveResult[0] && isEnd && isEmpty) {
|
|
1545
1543
|
const wrapBlock = aboveResult[0];
|
|
1546
1544
|
if (wrapBlock.type === type) {
|
|
@@ -1747,6 +1745,49 @@ const BlockquoteEditor = {
|
|
|
1747
1745
|
}
|
|
1748
1746
|
};
|
|
1749
1747
|
|
|
1748
|
+
const InlineCodeEditor = {
|
|
1749
|
+
toggleInlineCode(editor, text) {
|
|
1750
|
+
const isActive = InlineCodeEditor.isInlineCodeActive(editor);
|
|
1751
|
+
if (isActive) {
|
|
1752
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
if (Range.isCollapsed(editor.selection)) {
|
|
1756
|
+
InlineCodeEditor.wrapInlineCode(editor, text);
|
|
1757
|
+
}
|
|
1758
|
+
else {
|
|
1759
|
+
const fragment = Node.fragment(editor, editor.selection)[0];
|
|
1760
|
+
const selectNode = Node.get(fragment, []);
|
|
1761
|
+
const selectText = Node.string(selectNode);
|
|
1762
|
+
InlineCodeEditor.wrapInlineCode(editor, selectText);
|
|
1763
|
+
}
|
|
1764
|
+
},
|
|
1765
|
+
wrapInlineCode(editor, text = '') {
|
|
1766
|
+
if (InlineCodeEditor.isInlineCodeActive(editor)) {
|
|
1767
|
+
InlineCodeEditor.unwrapInlineCode(editor);
|
|
1768
|
+
}
|
|
1769
|
+
const { selection } = editor;
|
|
1770
|
+
const isCollapsed = selection && Range.isCollapsed(selection);
|
|
1771
|
+
const inlineCode = {
|
|
1772
|
+
type: ElementKinds.inlineCode,
|
|
1773
|
+
children: isCollapsed ? [{ text: text ? text : ZERO_WIDTH_CHAR }] : []
|
|
1774
|
+
};
|
|
1775
|
+
if (isCollapsed) {
|
|
1776
|
+
Transforms.insertNodes(editor, inlineCode);
|
|
1777
|
+
}
|
|
1778
|
+
else {
|
|
1779
|
+
Transforms.wrapNodes(editor, inlineCode, { split: true });
|
|
1780
|
+
}
|
|
1781
|
+
},
|
|
1782
|
+
unwrapInlineCode(editor) {
|
|
1783
|
+
Transforms.unwrapNodes(editor, { match: n => Element$1.isElement(n) && n.type === ElementKinds.inlineCode });
|
|
1784
|
+
},
|
|
1785
|
+
isInlineCodeActive(editor) {
|
|
1786
|
+
const [inlineCode] = Editor.nodes(editor, { match: n => Element$1.isElement(n) && n.type === ElementKinds.inlineCode });
|
|
1787
|
+
return !!inlineCode;
|
|
1788
|
+
}
|
|
1789
|
+
};
|
|
1790
|
+
|
|
1750
1791
|
const autoFormatRules = [
|
|
1751
1792
|
{
|
|
1752
1793
|
type: ElementKinds.heading_1,
|
|
@@ -1804,10 +1845,13 @@ const autoFormatRules = [
|
|
|
1804
1845
|
insertTrigger: true
|
|
1805
1846
|
},
|
|
1806
1847
|
{
|
|
1807
|
-
type:
|
|
1848
|
+
type: ElementKinds.inlineCode,
|
|
1808
1849
|
between: ['`', '`'],
|
|
1809
1850
|
mode: 'inline',
|
|
1810
|
-
|
|
1851
|
+
format: (editor, text) => {
|
|
1852
|
+
InlineCodeEditor.toggleInlineCode(editor, text);
|
|
1853
|
+
Transforms.select(editor, Editor.after(editor, editor.selection));
|
|
1854
|
+
}
|
|
1811
1855
|
},
|
|
1812
1856
|
{
|
|
1813
1857
|
type: MarkTypes.strike,
|
|
@@ -2003,6 +2047,35 @@ const getToolbarClass = (editor) => {
|
|
|
2003
2047
|
const IS_MAC = typeof window != 'undefined' && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
|
|
2004
2048
|
const CONTROL_KEY = IS_MAC ? '⌘' : 'Ctrl';
|
|
2005
2049
|
|
|
2050
|
+
/**
|
|
2051
|
+
* whether the current node is a clean paragraph
|
|
2052
|
+
* @param editor
|
|
2053
|
+
* @param text
|
|
2054
|
+
* @returns boolean
|
|
2055
|
+
*/
|
|
2056
|
+
const isCleanEmptyParagraph = (editor) => {
|
|
2057
|
+
const isCollapsedCursor = TheEditor.isFocused(editor) && editor.selection && Range.isCollapsed(editor.selection);
|
|
2058
|
+
if (!isCollapsedCursor) {
|
|
2059
|
+
return false;
|
|
2060
|
+
}
|
|
2061
|
+
const block = Node.ancestor(editor, [editor.selection.anchor.path[0]]);
|
|
2062
|
+
const textIndent = 'textIndent';
|
|
2063
|
+
const align = 'align';
|
|
2064
|
+
const hasTextIndent = block[textIndent];
|
|
2065
|
+
const hasAlign = block[align];
|
|
2066
|
+
if (Node.string(block) === '' &&
|
|
2067
|
+
Element$1.isElement(block) &&
|
|
2068
|
+
block.type === ElementKinds.paragraph &&
|
|
2069
|
+
block.children.length === 1 &&
|
|
2070
|
+
Text.isText(block.children[0]) &&
|
|
2071
|
+
!Editor.isVoid(editor, block) &&
|
|
2072
|
+
!hasTextIndent &&
|
|
2073
|
+
!hasAlign) {
|
|
2074
|
+
return true;
|
|
2075
|
+
}
|
|
2076
|
+
return false;
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2006
2079
|
const withDeserializeMd = (options) => (editor) => {
|
|
2007
2080
|
const { insertData, onKeydown } = editor;
|
|
2008
2081
|
editor.onKeydown = (event) => {
|
|
@@ -2030,7 +2103,7 @@ const withDeserializeMd = (options) => (editor) => {
|
|
|
2030
2103
|
editor,
|
|
2031
2104
|
conversion: () => {
|
|
2032
2105
|
try {
|
|
2033
|
-
const html = marked(plainFragment, { gfm: true });
|
|
2106
|
+
const html = marked(plainFragment.replace(/\n```/g, "\n\n```"), { gfm: true });
|
|
2034
2107
|
const htmlDom = new DOMParser().parseFromString(html, 'text/html');
|
|
2035
2108
|
const fragment = TheiaConverter.convertToTheia(Array.from(htmlDom.body.children));
|
|
2036
2109
|
if (!isUnformatted(fragment)) {
|
|
@@ -2289,6 +2362,13 @@ class TheContextService {
|
|
|
2289
2362
|
}
|
|
2290
2363
|
return this.options;
|
|
2291
2364
|
}
|
|
2365
|
+
getTheOptions() {
|
|
2366
|
+
return this.options.theOptions;
|
|
2367
|
+
}
|
|
2368
|
+
getDefaultFontSize() {
|
|
2369
|
+
var _a;
|
|
2370
|
+
return ((_a = this.options.theOptions) === null || _a === void 0 ? void 0 : _a.fontSize) || FontSizes.fontSize14;
|
|
2371
|
+
}
|
|
2292
2372
|
getEditableElement() {
|
|
2293
2373
|
return this.options.nativeElement.querySelector('.the-editor-typo');
|
|
2294
2374
|
}
|
|
@@ -2963,14 +3043,17 @@ const insertListItem = (editor) => {
|
|
|
2963
3043
|
}
|
|
2964
3044
|
else {
|
|
2965
3045
|
/**
|
|
2966
|
-
* If end,
|
|
3046
|
+
* If end, split nodes
|
|
2967
3047
|
*/
|
|
2968
3048
|
Editor.withoutNormalizing(editor, () => {
|
|
2969
|
-
Transforms.
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
3049
|
+
Transforms.splitNodes(editor, {
|
|
3050
|
+
always: true,
|
|
3051
|
+
mode: 'highest',
|
|
3052
|
+
match: node => {
|
|
3053
|
+
const path = node && TheEditor.findPath(editor, node);
|
|
3054
|
+
return path && path.length === nextListItemPath.length;
|
|
3055
|
+
}
|
|
3056
|
+
});
|
|
2974
3057
|
});
|
|
2975
3058
|
}
|
|
2976
3059
|
/**
|
|
@@ -3341,9 +3424,73 @@ class TheListItemComponent extends TheBaseElementComponent {
|
|
|
3341
3424
|
ngOnInit() {
|
|
3342
3425
|
super.ngOnInit();
|
|
3343
3426
|
}
|
|
3427
|
+
onContextChange() {
|
|
3428
|
+
super.onContextChange();
|
|
3429
|
+
this.addFontSize();
|
|
3430
|
+
this.addMultiDigit();
|
|
3431
|
+
}
|
|
3344
3432
|
ngOnDestroy() {
|
|
3345
3433
|
super.ngOnDestroy();
|
|
3346
3434
|
}
|
|
3435
|
+
addFontSize() {
|
|
3436
|
+
var _a, _b;
|
|
3437
|
+
let firstText;
|
|
3438
|
+
for (const entry of Node.descendants(this.element)) {
|
|
3439
|
+
const node = entry[0];
|
|
3440
|
+
if (Text.isText(node) && !firstText) {
|
|
3441
|
+
firstText = node;
|
|
3442
|
+
break;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3445
|
+
if (!firstText) {
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
const { text } = firstText, rest = __rest(firstText, ["text"]);
|
|
3449
|
+
const size = rest[MarkTypes.fontSize];
|
|
3450
|
+
if (size) {
|
|
3451
|
+
const sizeClass = `font-size-${size}`;
|
|
3452
|
+
const isContains = (_b = (_a = this.elementRef.nativeElement) === null || _a === void 0 ? void 0 : _a.classList) === null || _b === void 0 ? void 0 : _b.contains(sizeClass);
|
|
3453
|
+
if (isContains) {
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
this.clearFontSize();
|
|
3457
|
+
this.elementRef.nativeElement.classList.add(sizeClass);
|
|
3458
|
+
this.fontSizeClass = sizeClass;
|
|
3459
|
+
}
|
|
3460
|
+
else {
|
|
3461
|
+
this.clearFontSize();
|
|
3462
|
+
}
|
|
3463
|
+
}
|
|
3464
|
+
clearFontSize() {
|
|
3465
|
+
if (this.fontSizeClass) {
|
|
3466
|
+
this.elementRef.nativeElement.classList.remove(this.fontSizeClass);
|
|
3467
|
+
this.fontSizeClass = null;
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
getStart() {
|
|
3471
|
+
const parent = this.elementRef.nativeElement.closest('.slate-element-numbered-list');
|
|
3472
|
+
const start = (parent === null || parent === void 0 ? void 0 : parent.getAttribute('start')) || 1;
|
|
3473
|
+
return Number(start);
|
|
3474
|
+
}
|
|
3475
|
+
getLiIndex() {
|
|
3476
|
+
const path = findPath(this.editor, this.element);
|
|
3477
|
+
const index = path[path.length - 1];
|
|
3478
|
+
return index || 0;
|
|
3479
|
+
}
|
|
3480
|
+
addMultiDigit() {
|
|
3481
|
+
const start = this.getStart();
|
|
3482
|
+
const index = this.getLiIndex();
|
|
3483
|
+
const multiDigit = 'data-multi-digit';
|
|
3484
|
+
// start number + index
|
|
3485
|
+
// when it is greater than 9, it is a multi-digit serial number
|
|
3486
|
+
// exclude Font size >= 20
|
|
3487
|
+
if (start + index > 9) {
|
|
3488
|
+
this.elementRef.nativeElement.setAttribute(multiDigit, true);
|
|
3489
|
+
}
|
|
3490
|
+
else {
|
|
3491
|
+
this.elementRef.nativeElement.removeAttribute(multiDigit);
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3347
3494
|
}
|
|
3348
3495
|
TheListItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheListItemComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
3349
3496
|
TheListItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheListItemComponent, selector: "li[theLi]", usesInheritance: true, ngImport: i0, template: `<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>`, isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
|
|
@@ -3860,11 +4007,14 @@ const withMark = () => (editor) => {
|
|
|
3860
4007
|
delete marks[key];
|
|
3861
4008
|
editor.marks = marks;
|
|
3862
4009
|
const text = Editor.string(e, selection.anchor.path);
|
|
3863
|
-
if (text
|
|
3864
|
-
|
|
4010
|
+
if (text !== '') {
|
|
4011
|
+
Editor.setNormalizing(editor, false);
|
|
4012
|
+
e.insertText('');
|
|
4013
|
+
editor.marks = marks;
|
|
4014
|
+
Editor.setNormalizing(editor, true);
|
|
3865
4015
|
}
|
|
3866
|
-
|
|
3867
|
-
e.
|
|
4016
|
+
else {
|
|
4017
|
+
Transforms.unsetNodes(e, key, { at: selection.anchor.path });
|
|
3868
4018
|
}
|
|
3869
4019
|
if (shouldChange) {
|
|
3870
4020
|
editor.onChange();
|
|
@@ -3882,11 +4032,14 @@ const withMark = () => (editor) => {
|
|
|
3882
4032
|
const marks = Object.assign(Object.assign({}, (Editor.marks(e) || {})), { [key]: value });
|
|
3883
4033
|
editor.marks = marks;
|
|
3884
4034
|
const text = Editor.string(e, selection.anchor.path);
|
|
3885
|
-
if (text
|
|
3886
|
-
|
|
4035
|
+
if (text !== '') {
|
|
4036
|
+
Editor.setNormalizing(editor, false);
|
|
4037
|
+
e.insertText('');
|
|
4038
|
+
editor.marks = marks;
|
|
4039
|
+
Editor.setNormalizing(editor, true);
|
|
3887
4040
|
}
|
|
3888
|
-
|
|
3889
|
-
e.
|
|
4041
|
+
else {
|
|
4042
|
+
Transforms.setNodes(e, { [key]: value }, { at: selection.anchor.path });
|
|
3890
4043
|
}
|
|
3891
4044
|
}
|
|
3892
4045
|
}
|
|
@@ -3955,7 +4108,7 @@ const autoFormatBlock = (editor, type, at, { preFormat, format }, markups) => {
|
|
|
3955
4108
|
}
|
|
3956
4109
|
};
|
|
3957
4110
|
|
|
3958
|
-
const autoFormatInline = (editor, { type, between, markup, ignoreTrim }) => {
|
|
4111
|
+
const autoFormatInline = (editor, { type, between, markup, ignoreTrim, format }) => {
|
|
3959
4112
|
const selection = editor.selection;
|
|
3960
4113
|
const startMarkup = between ? between[0] : markup;
|
|
3961
4114
|
const endMarkup = between ? between[1] : '';
|
|
@@ -3999,22 +4152,35 @@ const autoFormatInline = (editor, { type, between, markup, ignoreTrim }) => {
|
|
|
3999
4152
|
}
|
|
4000
4153
|
});
|
|
4001
4154
|
}
|
|
4002
|
-
// add mark to the text between the markups
|
|
4003
|
-
Transforms.select(editor, markupRange);
|
|
4004
|
-
editor.addMark(type, true);
|
|
4005
|
-
Transforms.collapse(editor, { edge: 'end' });
|
|
4006
|
-
editor.removeMark(type, false);
|
|
4007
|
-
// delete start markup
|
|
4008
4155
|
const startMarkupPointBefore = getPointBefore(editor, selection, {
|
|
4009
4156
|
matchString: startMarkup,
|
|
4010
4157
|
skipInvalid: true
|
|
4011
4158
|
});
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4159
|
+
if (format) {
|
|
4160
|
+
const markupText = getText(editor, markupRange);
|
|
4161
|
+
format(editor, markupText);
|
|
4162
|
+
// delete start to end selection
|
|
4163
|
+
Transforms.delete(editor, {
|
|
4164
|
+
at: {
|
|
4165
|
+
anchor: startMarkupPointBefore,
|
|
4166
|
+
focus: selection.anchor
|
|
4167
|
+
}
|
|
4168
|
+
});
|
|
4169
|
+
}
|
|
4170
|
+
else {
|
|
4171
|
+
// add mark to the text between the markups
|
|
4172
|
+
Transforms.select(editor, markupRange);
|
|
4173
|
+
editor.addMark(type, true);
|
|
4174
|
+
Transforms.collapse(editor, { edge: 'end' });
|
|
4175
|
+
editor.removeMark(type, false);
|
|
4176
|
+
// delete start markup
|
|
4177
|
+
Transforms.delete(editor, {
|
|
4178
|
+
at: {
|
|
4179
|
+
anchor: startMarkupPointBefore,
|
|
4180
|
+
focus: startMarkupPointAfter
|
|
4181
|
+
}
|
|
4182
|
+
});
|
|
4183
|
+
}
|
|
4018
4184
|
return true;
|
|
4019
4185
|
};
|
|
4020
4186
|
|
|
@@ -4087,6 +4253,7 @@ const withAutoFormat = ({ rules }) => (editor) => {
|
|
|
4087
4253
|
type,
|
|
4088
4254
|
between,
|
|
4089
4255
|
ignoreTrim,
|
|
4256
|
+
format,
|
|
4090
4257
|
markup: Array.isArray(markup) ? markup[0] : markup
|
|
4091
4258
|
})) {
|
|
4092
4259
|
return valid();
|
|
@@ -5413,14 +5580,6 @@ const MarkOptions = [
|
|
|
5413
5580
|
shortcutKey: `${CONTROL_KEY}+U`,
|
|
5414
5581
|
execute: editor => MarkEditor.toggleMark(editor, MarkTypes.underline),
|
|
5415
5582
|
active: editor => MarkEditor.isMarkActive(editor, MarkTypes.underline)
|
|
5416
|
-
},
|
|
5417
|
-
{
|
|
5418
|
-
key: MarkTypes.codeLine,
|
|
5419
|
-
icon: 'code',
|
|
5420
|
-
name: '行内代码',
|
|
5421
|
-
shortcutKey: `${CONTROL_KEY}+E`,
|
|
5422
|
-
execute: editor => MarkEditor.toggleMark(editor, MarkTypes.codeLine),
|
|
5423
|
-
active: editor => MarkEditor.isMarkActive(editor, MarkTypes.codeLine)
|
|
5424
5583
|
}
|
|
5425
5584
|
];
|
|
5426
5585
|
|
|
@@ -5484,7 +5643,9 @@ const HeadingEditor = {
|
|
|
5484
5643
|
};
|
|
5485
5644
|
if (entry) {
|
|
5486
5645
|
setMarks(editor, unMarks, entry[1]);
|
|
5646
|
+
return;
|
|
5487
5647
|
}
|
|
5648
|
+
setMarks(editor, unMarks, editor.selection);
|
|
5488
5649
|
});
|
|
5489
5650
|
},
|
|
5490
5651
|
isHeadingActive(editor, heading) {
|
|
@@ -6404,8 +6565,9 @@ class TheCodeComponent extends TheBaseElementComponent {
|
|
|
6404
6565
|
this.menus = CODE_MODES.map(item => {
|
|
6405
6566
|
return { key: item.value, name: item.showName };
|
|
6406
6567
|
});
|
|
6568
|
+
this.destroy$ = new Subject();
|
|
6407
6569
|
this.ToolbarItemMode = ToolbarItemMode;
|
|
6408
|
-
this.
|
|
6570
|
+
this.isHightLight = false;
|
|
6409
6571
|
this.resizeHeight = null;
|
|
6410
6572
|
this.options = {
|
|
6411
6573
|
mode: this.menus[0].key,
|
|
@@ -6442,13 +6604,21 @@ class TheCodeComponent extends TheBaseElementComponent {
|
|
|
6442
6604
|
if (this.resizeHeight !== this.element.height) {
|
|
6443
6605
|
this.useHeight();
|
|
6444
6606
|
}
|
|
6445
|
-
if (!this.isCollapsed) {
|
|
6446
|
-
this.isFocusCode = false;
|
|
6447
|
-
}
|
|
6448
6607
|
}
|
|
6449
6608
|
}
|
|
6450
6609
|
ngOnInit() {
|
|
6451
6610
|
super.ngOnInit();
|
|
6611
|
+
this.ngZone.runOutsideAngular(() => {
|
|
6612
|
+
fromEvent(this.nativeElement, 'mousedown')
|
|
6613
|
+
.pipe(takeUntil(this.destroy$))
|
|
6614
|
+
.subscribe(event => {
|
|
6615
|
+
event.stopPropagation();
|
|
6616
|
+
const isBlockOperation = this.isCollapsed &&
|
|
6617
|
+
this.nativeElement.querySelector('.the-code-block-operation').contains(event.target);
|
|
6618
|
+
const isCodemirror = this.nativeElement.querySelector('.ng-codemirror').contains(event.target);
|
|
6619
|
+
this.isHightLight = !isCodemirror && !isBlockOperation;
|
|
6620
|
+
});
|
|
6621
|
+
});
|
|
6452
6622
|
this.elementRef.nativeElement.classList.add('the-code-container');
|
|
6453
6623
|
}
|
|
6454
6624
|
ngAfterViewInit() {
|
|
@@ -6490,11 +6660,11 @@ class TheCodeComponent extends TheBaseElementComponent {
|
|
|
6490
6660
|
}
|
|
6491
6661
|
}
|
|
6492
6662
|
codeChange($event) {
|
|
6663
|
+
this.isHightLight = false;
|
|
6493
6664
|
CodeEditor.setCodeAttribute(this.editor, this.element, { content: $event });
|
|
6494
6665
|
}
|
|
6495
6666
|
onDelete(event) {
|
|
6496
6667
|
event.preventDefault();
|
|
6497
|
-
this.isFocusCode = false;
|
|
6498
6668
|
deleteElement(this.editor, this.element);
|
|
6499
6669
|
}
|
|
6500
6670
|
onCopy(event) {
|
|
@@ -6512,8 +6682,9 @@ class TheCodeComponent extends TheBaseElementComponent {
|
|
|
6512
6682
|
AngularEditor.deselect(this.editor);
|
|
6513
6683
|
}
|
|
6514
6684
|
focusChange(codeMirrorFocused) {
|
|
6515
|
-
if (codeMirrorFocused)
|
|
6516
|
-
this.
|
|
6685
|
+
if (codeMirrorFocused) {
|
|
6686
|
+
this.isHightLight = false;
|
|
6687
|
+
}
|
|
6517
6688
|
}
|
|
6518
6689
|
useMode() {
|
|
6519
6690
|
this.options = Object.assign(Object.assign({}, this.options), { mode: this.element.language });
|
|
@@ -6540,12 +6711,17 @@ class TheCodeComponent extends TheBaseElementComponent {
|
|
|
6540
6711
|
CodeEditor.setCodeAttribute(this.editor, this.element, { height: this.resizeHeight });
|
|
6541
6712
|
}
|
|
6542
6713
|
onChangeWrap(value) {
|
|
6714
|
+
this.isHightLight = false;
|
|
6543
6715
|
this.options = Object.assign(Object.assign({}, this.options), { lineWrapping: value || false });
|
|
6544
6716
|
CodeEditor.setCodeAttribute(this.editor, this.element, { autoWrap: value ? value : null });
|
|
6545
6717
|
}
|
|
6718
|
+
ngOnDestroy() {
|
|
6719
|
+
this.destroy$.next();
|
|
6720
|
+
this.destroy$.complete();
|
|
6721
|
+
}
|
|
6546
6722
|
}
|
|
6547
6723
|
TheCodeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheCodeComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i1$4.ThyNotifyService }, { token: TheContextService }, { token: i0.NgZone }, { token: THE_CODE_MODE_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
|
|
6548
|
-
TheCodeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheCodeComponent, selector: "div[theCode]", viewQueries: [{ propertyName: "codemirror", first: true, predicate: ["codemirror"], descendants: true, read: CodeMirrorComponent }], usesInheritance: true, ngImport: i0, template: "<div contenteditable=\"false\" class=\"the-code-block-operation\" *ngIf=\"
|
|
6724
|
+
TheCodeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheCodeComponent, selector: "div[theCode]", viewQueries: [{ propertyName: "codemirror", first: true, predicate: ["codemirror"], descendants: true, read: CodeMirrorComponent }], usesInheritance: true, ngImport: i0, template: "<div contenteditable=\"false\" class=\"the-code-block-operation\" *ngIf=\"isCollapsed && codemirror && !options.readOnly\">\n <thy-icon-nav>\n <the-toolbar-dropdown [menus]=\"menus\" [item]=\"actives\" [itemMousedownHandle]=\"onChangeLangulage\"> </the-toolbar-dropdown>\n <a\n href=\"javascript:;\"\n thyIconNavLink\n thyIconNavLinkIcon=\"copy\"\n thyTooltip=\"\u590D\u5236\"\n thyTooltipPlacement=\"top\"\n (mousedown)=\"onCopy($event)\"\n ></a>\n <a\n href=\"javascript:;\"\n thyIconNavLink\n thyIconNavLinkIcon=\"trash\"\n thyTooltip=\"\u5220\u9664\"\n class=\"remove-link\"\n thyTooltipPlacement=\"top\"\n (mousedown)=\"onDelete($event)\"\n ></a>\n <nav-split-line [mode]=\"ToolbarItemMode.vertical\"></nav-split-line>\n <span class=\"auto-wrap d-flex align-items-center\">\n <span>\u81EA\u52A8\u6362\u884C</span>\n <thy-switch\n class=\"auto-wrap-btn d-flex\"\n [(ngModel)]=\"options.lineWrapping\"\n (ngModelChange)=\"onChangeWrap($event)\"\n thySize=\"sm\"\n ></thy-switch>\n </span>\n </thy-icon-nav>\n</div>\n\n<slate-children [children]=\"children\" [context]=\"childrenContext\" [viewContext]=\"viewContext\"></slate-children>\n\n<!-- \u53EA\u8BFB\u6A21\u5F0F\u4E0BCodeMirror-sizer\u9AD8\u5EA6\u6BD4\u7F16\u8F91\u6A21\u5F0F\u4E0B\u591A2px\uFF0C\u8BBE\u7F6EthyMinHeight\u4E3A46px\u9632\u6B62\u62D6\u62FD\u5230\u6700\u5C0F\u9AD8\u5EA6\u65F6\u53EA\u8BFB\u6A21\u5F0F\u4E0B\u51FA\u73B0\u6EDA\u52A8\u6761 -->\n<div\n thyResizable\n [thyMinHeight]=\"46\"\n [thyBounds]=\"resizeBounds\"\n [style.height.px]=\"resizeHeight\"\n (thyResize)=\"onResize($event)\"\n (thyResizeEnd)=\"onEndResize()\"\n class=\"resize-code-container\"\n [ngClass]=\"{ focus: isCollapsed, readonly: options.readOnly, active: isHightLight && isCollapsed }\"\n>\n <ng-codemirror\n *ngIf=\"startRenderCodemirror\"\n #codemirror\n contenteditable=\"false\"\n class=\"ng-codemirror-wrapper\"\n [ngStyle]=\"{ maxHeight: maxHeight > 0 ? maxHeight + 'px' : 'auto' }\"\n [options]=\"options\"\n [ngModel]=\"code\"\n [delayRefreshTime]=\"300\"\n (ngModelChange)=\"codeChange($event)\"\n (focusChange)=\"focusChange($event)\"\n [autoMaxHeight]=\"maxHeight\"\n >\n </ng-codemirror>\n <thy-resize-handle thyDirection=\"bottom\" class=\"code-resize-icon\" *ngIf=\"isCollapsed && !options.readOnly\"></thy-resize-handle>\n</div>\n", components: [{ type: i3.ThyIconNavComponent, selector: "thy-icon-nav", inputs: ["thyType"] }, { type: TheToolbarDropdownComponent, selector: "the-toolbar-dropdown", inputs: ["toolbarItem", "menus", "mode", "item", "itemMousedownHandle"] }, { type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: NavSplitLineComponent, selector: "nav-split-line", inputs: ["mode"] }, { type: i6$1.ThySwitchComponent, selector: "thy-switch", inputs: ["thyType", "thySize", "thyDisabled"], outputs: ["thyChange"] }, { type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }, { type: i8.CodeMirrorComponent, selector: "ng-codemirror, [ngCodeMirror]", inputs: ["autoMaxHeight", "delayRefreshTime", "options"], outputs: ["focusChange"] }, { type: i9.ThyResizeHandleComponent, selector: "thy-resize-handle, [thy-resize-handle]", inputs: ["thyDirection"], outputs: ["thyMouseDown"], exportAs: ["thyResizeHandle"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i5$1.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }, { type: i4$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i9.ThyResizableDirective, selector: "[thyResizable]", inputs: ["thyBounds", "thyMaxHeight", "thyMaxWidth", "thyMinHeight", "thyMinWidth", "thyGridColumnCount", "thyMaxColumn", "thyMinColumn", "thyLockAspectRatio", "thyPreview", "thyDisabled"], outputs: ["thyResize", "thyResizeEnd", "thyResizeStart"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
6549
6725
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheCodeComponent, decorators: [{
|
|
6550
6726
|
type: Component,
|
|
6551
6727
|
args: [{
|
|
@@ -6827,7 +7003,9 @@ class TheBaseLinkComponent extends TheBaseElementComponent {
|
|
|
6827
7003
|
}
|
|
6828
7004
|
}
|
|
6829
7005
|
mousedownHandle(event) {
|
|
6830
|
-
this.
|
|
7006
|
+
if (!this.readonly && !this.editor.disabled) {
|
|
7007
|
+
this.openLinkHover();
|
|
7008
|
+
}
|
|
6831
7009
|
}
|
|
6832
7010
|
openLinkEdit(tag) {
|
|
6833
7011
|
if (this.linkHoverOpened) {
|
|
@@ -10641,35 +10819,6 @@ const PaintFormatOptions = [
|
|
|
10641
10819
|
}
|
|
10642
10820
|
];
|
|
10643
10821
|
|
|
10644
|
-
/**
|
|
10645
|
-
* whether the current node is a clean paragraph
|
|
10646
|
-
* @param editor
|
|
10647
|
-
* @param text
|
|
10648
|
-
* @returns boolean
|
|
10649
|
-
*/
|
|
10650
|
-
const isCleanEmptyParagraph = (editor) => {
|
|
10651
|
-
const isCollapsedCursor = TheEditor.isFocused(editor) && editor.selection && Range.isCollapsed(editor.selection);
|
|
10652
|
-
if (!isCollapsedCursor) {
|
|
10653
|
-
return false;
|
|
10654
|
-
}
|
|
10655
|
-
const block = Node.ancestor(editor, [editor.selection.anchor.path[0]]);
|
|
10656
|
-
const textIndent = 'textIndent';
|
|
10657
|
-
const align = 'align';
|
|
10658
|
-
const hasTextIndent = block[textIndent];
|
|
10659
|
-
const hasAlign = block[align];
|
|
10660
|
-
if (Node.string(block) === '' &&
|
|
10661
|
-
Element$1.isElement(block) &&
|
|
10662
|
-
block.type === ElementKinds.paragraph &&
|
|
10663
|
-
block.children.length === 1 &&
|
|
10664
|
-
Text.isText(block.children[0]) &&
|
|
10665
|
-
!Editor.isVoid(editor, block) &&
|
|
10666
|
-
!hasTextIndent &&
|
|
10667
|
-
!hasAlign) {
|
|
10668
|
-
return true;
|
|
10669
|
-
}
|
|
10670
|
-
return false;
|
|
10671
|
-
};
|
|
10672
|
-
|
|
10673
10822
|
class TheToolbarItemComponent extends TheToolbarBaseItemComponent {
|
|
10674
10823
|
constructor(ngZone, cfr) {
|
|
10675
10824
|
super();
|
|
@@ -10947,11 +11096,43 @@ const withSoftBreak = (options = { rules: [{ hotkey: 'shift+enter' }] }) => (edi
|
|
|
10947
11096
|
|
|
10948
11097
|
const FontSizeEditor = {
|
|
10949
11098
|
setFontSize(editor, size) {
|
|
11099
|
+
const contextService = editor.injector.get(TheContextService);
|
|
11100
|
+
const defaultFontSize = contextService.getDefaultFontSize();
|
|
11101
|
+
const marks = getSelectionMarks(editor);
|
|
11102
|
+
const fontSizeMark = marks[MarkTypes.fontSize];
|
|
11103
|
+
const isDefaultFontSize = size === defaultFontSize;
|
|
11104
|
+
if (!fontSizeMark && isDefaultFontSize) {
|
|
11105
|
+
return;
|
|
11106
|
+
}
|
|
11107
|
+
// unset fontSize
|
|
11108
|
+
if (FontSizeEditor.unsetFontSize(editor, size, fontSizeMark, isDefaultFontSize)) {
|
|
11109
|
+
return;
|
|
11110
|
+
}
|
|
11111
|
+
FontSizeEditor.setFontSizeMark(editor, size);
|
|
11112
|
+
},
|
|
11113
|
+
setFontSizeMark(editor, size) {
|
|
11114
|
+
// set Table selectedCells fontSize
|
|
10950
11115
|
if (TableEditor.toggleMark(editor, false, MarkTypes.fontSize, Number(size))) {
|
|
10951
11116
|
return;
|
|
10952
11117
|
}
|
|
11118
|
+
// set paragraph text fontSize
|
|
10953
11119
|
Editor.addMark(editor, MarkTypes.fontSize, Number(size));
|
|
10954
11120
|
},
|
|
11121
|
+
unsetFontSize(editor, size, fontSizeMark, isDefaultFontSize) {
|
|
11122
|
+
const isTable = TableEditor.isActive(editor);
|
|
11123
|
+
if (fontSizeMark && isDefaultFontSize) {
|
|
11124
|
+
// unset Table selectedCells fontSize
|
|
11125
|
+
if (isTable && TableEditor.toggleMark(editor, true, MarkTypes.fontSize, Number(size))) {
|
|
11126
|
+
return true;
|
|
11127
|
+
}
|
|
11128
|
+
// unset paragraph text fontSize
|
|
11129
|
+
setMarks(editor, {
|
|
11130
|
+
[MarkTypes.fontSize]: null
|
|
11131
|
+
}, editor.selection);
|
|
11132
|
+
return true;
|
|
11133
|
+
}
|
|
11134
|
+
return false;
|
|
11135
|
+
},
|
|
10955
11136
|
isFontSizeActive(editor, size) {
|
|
10956
11137
|
if (editor.selection) {
|
|
10957
11138
|
const anchorBlock$1 = anchorBlock(editor);
|
|
@@ -11010,6 +11191,81 @@ const FontSizeOptions = [
|
|
|
11010
11191
|
...sizeOptions()
|
|
11011
11192
|
];
|
|
11012
11193
|
|
|
11194
|
+
const InlineCodeOptions = [
|
|
11195
|
+
{
|
|
11196
|
+
key: ElementKinds.inlineCode,
|
|
11197
|
+
icon: 'code',
|
|
11198
|
+
name: '行内代码',
|
|
11199
|
+
shortcutKey: `${CONTROL_KEY}+E`,
|
|
11200
|
+
execute: editor => InlineCodeEditor.toggleInlineCode(editor),
|
|
11201
|
+
active: editor => InlineCodeEditor.isInlineCodeActive(editor)
|
|
11202
|
+
}
|
|
11203
|
+
];
|
|
11204
|
+
|
|
11205
|
+
class TheInlineCodeComponent extends TheBaseElementComponent {
|
|
11206
|
+
constructor(elementRef, cdr) {
|
|
11207
|
+
super(elementRef, cdr);
|
|
11208
|
+
this.elementRef = elementRef;
|
|
11209
|
+
this.cdr = cdr;
|
|
11210
|
+
}
|
|
11211
|
+
ngOnInit() {
|
|
11212
|
+
super.ngOnInit();
|
|
11213
|
+
}
|
|
11214
|
+
ngOnDestroy() {
|
|
11215
|
+
super.ngOnDestroy();
|
|
11216
|
+
}
|
|
11217
|
+
}
|
|
11218
|
+
TheInlineCodeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheInlineCodeComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
11219
|
+
TheInlineCodeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheInlineCodeComponent, selector: "span[theInlineCode]", usesInheritance: true, ngImport: i0, template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>', isInline: true, components: [{ type: i1.SlateChildrenComponent, selector: "slate-children", inputs: ["children", "context", "viewContext"] }] });
|
|
11220
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheInlineCodeComponent, decorators: [{
|
|
11221
|
+
type: Component,
|
|
11222
|
+
args: [{
|
|
11223
|
+
selector: 'span[theInlineCode]',
|
|
11224
|
+
template: '<slate-children [children]="children" [context]="childrenContext" [viewContext]="viewContext"></slate-children>'
|
|
11225
|
+
}]
|
|
11226
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }]; } });
|
|
11227
|
+
|
|
11228
|
+
const withInlineCode = (editor) => {
|
|
11229
|
+
const { isInline, renderElement, insertText } = editor;
|
|
11230
|
+
editor.isInline = (element) => {
|
|
11231
|
+
return element.type === ElementKinds.inlineCode ? true : isInline(element);
|
|
11232
|
+
};
|
|
11233
|
+
editor.renderElement = (element) => {
|
|
11234
|
+
if (element.type === ElementKinds.inlineCode) {
|
|
11235
|
+
return TheInlineCodeComponent;
|
|
11236
|
+
}
|
|
11237
|
+
return renderElement(element);
|
|
11238
|
+
};
|
|
11239
|
+
editor.insertText = text => {
|
|
11240
|
+
if (text && InlineCodeEditor.isInlineCodeActive(editor)) {
|
|
11241
|
+
let selection = editor.selection;
|
|
11242
|
+
const currentNodeText = Editor.string(editor, editor.selection.anchor.path);
|
|
11243
|
+
insertText(text);
|
|
11244
|
+
if (currentNodeText == ZERO_WIDTH_CHAR) {
|
|
11245
|
+
const inlineCodePath = Editor.path(editor, editor.selection);
|
|
11246
|
+
let range = {
|
|
11247
|
+
anchor: Editor.before(editor, selection.anchor),
|
|
11248
|
+
focus: selection.anchor
|
|
11249
|
+
};
|
|
11250
|
+
if (Editor.isStart(editor, selection.anchor, inlineCodePath)) {
|
|
11251
|
+
range = {
|
|
11252
|
+
anchor: editor.selection.anchor,
|
|
11253
|
+
focus: Editor.after(editor, editor.selection)
|
|
11254
|
+
};
|
|
11255
|
+
}
|
|
11256
|
+
Transforms.delete(editor, {
|
|
11257
|
+
at: range
|
|
11258
|
+
});
|
|
11259
|
+
}
|
|
11260
|
+
}
|
|
11261
|
+
else {
|
|
11262
|
+
insertText(text);
|
|
11263
|
+
}
|
|
11264
|
+
};
|
|
11265
|
+
editor = withRemoveEmptyNodes({ type: ElementKinds.inlineCode })(editor);
|
|
11266
|
+
return editor;
|
|
11267
|
+
};
|
|
11268
|
+
|
|
11013
11269
|
const internalPlugins = [
|
|
11014
11270
|
withTheHistory,
|
|
11015
11271
|
withAutoInsertData(),
|
|
@@ -11049,7 +11305,8 @@ const internalPlugins = [
|
|
|
11049
11305
|
withImage,
|
|
11050
11306
|
withDeserializeHMTL,
|
|
11051
11307
|
withDeserializeMd(),
|
|
11052
|
-
withQuickInsert
|
|
11308
|
+
withQuickInsert,
|
|
11309
|
+
withInlineCode
|
|
11053
11310
|
];
|
|
11054
11311
|
const internalToolbarItems = [
|
|
11055
11312
|
...AlignOptions,
|
|
@@ -11066,7 +11323,8 @@ const internalToolbarItems = [
|
|
|
11066
11323
|
...LinkOptions,
|
|
11067
11324
|
...TableOptions,
|
|
11068
11325
|
...VerticalAlignOptions,
|
|
11069
|
-
...PaintFormatOptions
|
|
11326
|
+
...PaintFormatOptions,
|
|
11327
|
+
...InlineCodeOptions
|
|
11070
11328
|
];
|
|
11071
11329
|
const toolbarCompose = (toolbarItems = []) => {
|
|
11072
11330
|
return [...internalToolbarItems, ...toolbarItems];
|
|
@@ -11088,14 +11346,19 @@ const HOTKEYS = {
|
|
|
11088
11346
|
'mod+b': MarkTypes.bold,
|
|
11089
11347
|
'mod+i': MarkTypes.italic,
|
|
11090
11348
|
'mod+u': MarkTypes.underline,
|
|
11091
|
-
'mod+e':
|
|
11349
|
+
'mod+e': ElementKinds.inlineCode
|
|
11092
11350
|
};
|
|
11093
11351
|
const markShortcuts = (editor, event) => {
|
|
11094
11352
|
for (const hotkey in HOTKEYS) {
|
|
11095
11353
|
if (isHotkey(hotkey, event)) {
|
|
11096
11354
|
event.preventDefault();
|
|
11097
11355
|
const mark = HOTKEYS[hotkey];
|
|
11098
|
-
|
|
11356
|
+
if (mark === ElementKinds.inlineCode) {
|
|
11357
|
+
InlineCodeEditor.toggleInlineCode(editor);
|
|
11358
|
+
}
|
|
11359
|
+
else {
|
|
11360
|
+
MarkEditor.toggleMark(editor, mark);
|
|
11361
|
+
}
|
|
11099
11362
|
}
|
|
11100
11363
|
}
|
|
11101
11364
|
};
|
|
@@ -11392,17 +11655,19 @@ class TheToolbarComponent {
|
|
|
11392
11655
|
return TheToolbarItemComponent;
|
|
11393
11656
|
}
|
|
11394
11657
|
getDropdownItem(item) {
|
|
11395
|
-
var _a;
|
|
11658
|
+
var _a, _b, _c;
|
|
11396
11659
|
let dropdownKey = item === null || item === void 0 ? void 0 : item.dropdownItemKey;
|
|
11397
11660
|
// modify the fontsize option externally
|
|
11398
|
-
|
|
11399
|
-
|
|
11661
|
+
const contextService = (_b = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.injector) === null || _b === void 0 ? void 0 : _b.get(TheContextService);
|
|
11662
|
+
const fontSize = contextService === null || contextService === void 0 ? void 0 : contextService.getDefaultFontSize();
|
|
11663
|
+
if (contextService && item.key === MarkTypes.fontSize && fontSize) {
|
|
11664
|
+
dropdownKey = fontSize;
|
|
11400
11665
|
}
|
|
11401
|
-
return (
|
|
11666
|
+
return (_c = item === null || item === void 0 ? void 0 : item.includes) === null || _c === void 0 ? void 0 : _c.find((item) => item.key === dropdownKey);
|
|
11402
11667
|
}
|
|
11403
11668
|
}
|
|
11404
11669
|
TheToolbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheToolbarComponent, deps: [{ token: i0.ComponentFactoryResolver }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: TheToolbarGroupToken }], target: i0.ɵɵFactoryTarget.Component });
|
|
11405
|
-
TheToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheToolbarComponent, selector: "the-toolbar", inputs: { editor: "editor", toolbarItems: "toolbarItems", align: "align",
|
|
11670
|
+
TheToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheToolbarComponent, selector: "the-toolbar", inputs: { editor: "editor", toolbarItems: "toolbarItems", align: "align", containerClass: "containerClass", isMore: "isMore", afterTemplate: "afterTemplate" }, host: { classAttribute: "the-toolbar-container" }, viewQueries: [{ propertyName: "toolbarContainer", first: true, predicate: ["toolbarContainer"], descendants: true, read: ViewContainerRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<thy-icon-nav [style.justifyContent]=\"align\">\n <ng-container #toolbarContainer></ng-container>\n <ng-content></ng-content>\n <ng-template *ngIf=\"afterTemplate\" [ngTemplateOutlet]=\"afterTemplate\"></ng-template>\n</thy-icon-nav>\n", components: [{ type: i3.ThyIconNavComponent, selector: "thy-icon-nav", inputs: ["thyType"] }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
|
|
11406
11671
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheToolbarComponent, decorators: [{
|
|
11407
11672
|
type: Component,
|
|
11408
11673
|
args: [{
|
|
@@ -11421,8 +11686,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
11421
11686
|
type: Input
|
|
11422
11687
|
}], align: [{
|
|
11423
11688
|
type: Input
|
|
11424
|
-
}], fontSize: [{
|
|
11425
|
-
type: Input
|
|
11426
11689
|
}], containerClass: [{
|
|
11427
11690
|
type: Input
|
|
11428
11691
|
}], isMore: [{
|
|
@@ -11536,7 +11799,7 @@ TheInlineToolbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.
|
|
|
11536
11799
|
[editor]="editor"
|
|
11537
11800
|
[toolbarItems]="toolbarItems"
|
|
11538
11801
|
[isMore]="false"
|
|
11539
|
-
></the-toolbar> `, isInline: true, components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "
|
|
11802
|
+
></the-toolbar> `, isInline: true, components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
11540
11803
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheInlineToolbarComponent, decorators: [{
|
|
11541
11804
|
type: Component,
|
|
11542
11805
|
args: [{
|
|
@@ -11567,6 +11830,7 @@ class TheQuickInsertComponent {
|
|
|
11567
11830
|
this.renderer = renderer;
|
|
11568
11831
|
this.elementRef = elementRef;
|
|
11569
11832
|
this.cdr = cdr;
|
|
11833
|
+
this.isVisible = false;
|
|
11570
11834
|
this.isHide = true;
|
|
11571
11835
|
this.defaultIconName = 'plus-circle-thin';
|
|
11572
11836
|
this.iconNameFill = 'plus-circle-thin-fill';
|
|
@@ -11577,14 +11841,12 @@ class TheQuickInsertComponent {
|
|
|
11577
11841
|
event.stopPropagation();
|
|
11578
11842
|
}
|
|
11579
11843
|
checkStatus() {
|
|
11844
|
+
var _a;
|
|
11580
11845
|
const { editor } = this;
|
|
11581
|
-
if (isCleanEmptyParagraph(editor)) {
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
11586
|
-
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
11587
|
-
});
|
|
11846
|
+
if (this.isVisible && isCleanEmptyParagraph(editor)) {
|
|
11847
|
+
const block = Node.ancestor(editor, [(_a = editor === null || editor === void 0 ? void 0 : editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path[0]]);
|
|
11848
|
+
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
11849
|
+
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
11588
11850
|
return;
|
|
11589
11851
|
}
|
|
11590
11852
|
this.isHide = true;
|
|
@@ -11609,7 +11871,7 @@ class TheQuickInsertComponent {
|
|
|
11609
11871
|
}
|
|
11610
11872
|
}
|
|
11611
11873
|
TheQuickInsertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheQuickInsertComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
11612
|
-
TheQuickInsertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: { editor: "editor", quickToolbarItems: "quickToolbarItems" }, host: { listeners: { "mousedown": "handleMousedownNativeElement($event)" }, properties: { "class.hide": "isHide" }, classAttribute: "the-quick-insert" }, viewQueries: [{ propertyName: "iconElement", first: true, predicate: ["iconElement"], descendants: true, read: ElementRef }], ngImport: i0, template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n", components: [{ type: i4$1.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }] });
|
|
11874
|
+
TheQuickInsertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: { editor: "editor", quickToolbarItems: "quickToolbarItems", isVisible: "isVisible" }, host: { listeners: { "mousedown": "handleMousedownNativeElement($event)" }, properties: { "class.hide": "isHide" }, classAttribute: "the-quick-insert" }, viewQueries: [{ propertyName: "iconElement", first: true, predicate: ["iconElement"], descendants: true, read: ElementRef }], ngImport: i0, template: "<thy-icon\n #iconElement\n [thyIconName]=\"displayIconName\"\n class=\"quick-insert-icon text-desc font-size-xlg\"\n (mouseenter)=\"mouseEnter($event)\"\n (mouseleave)=\"mouseLeave($event)\"\n (mousedown)=\"handleClick($event)\"\n></thy-icon>\n", components: [{ type: i4$1.ThyIconComponent, selector: "thy-icon", inputs: ["thyIconType", "thyTwotoneColor", "thyIconName", "thyIconRotate", "thyIconSet", "thyIconLegging", "thyIconLinearGradient"] }] });
|
|
11613
11875
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheQuickInsertComponent, decorators: [{
|
|
11614
11876
|
type: Component,
|
|
11615
11877
|
args: [{
|
|
@@ -11624,6 +11886,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
11624
11886
|
type: Input
|
|
11625
11887
|
}], quickToolbarItems: [{
|
|
11626
11888
|
type: Input
|
|
11889
|
+
}], isVisible: [{
|
|
11890
|
+
type: Input
|
|
11627
11891
|
}], iconElement: [{
|
|
11628
11892
|
type: ViewChild,
|
|
11629
11893
|
args: ['iconElement', { read: ElementRef, static: false }]
|
|
@@ -11632,82 +11896,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
11632
11896
|
args: ['mousedown', ['$event']]
|
|
11633
11897
|
}] } });
|
|
11634
11898
|
|
|
11635
|
-
class ThePlaceholderComponent {
|
|
11636
|
-
constructor(renderer, elementRef, contextService) {
|
|
11637
|
-
this.renderer = renderer;
|
|
11638
|
-
this.elementRef = elementRef;
|
|
11639
|
-
this.contextService = contextService;
|
|
11640
|
-
this.isHide = true;
|
|
11641
|
-
}
|
|
11642
|
-
handleCompositionStart() {
|
|
11643
|
-
var _a;
|
|
11644
|
-
if ((_a = this.editor) === null || _a === void 0 ? void 0 : _a.selection) {
|
|
11645
|
-
this.hide();
|
|
11646
|
-
}
|
|
11647
|
-
}
|
|
11648
|
-
handleCompositionEnd(event) {
|
|
11649
|
-
if (!event.data) {
|
|
11650
|
-
this.checkStatus();
|
|
11651
|
-
}
|
|
11652
|
-
}
|
|
11653
|
-
checkStatus() {
|
|
11654
|
-
var _a, _b, _c;
|
|
11655
|
-
const { editor } = this;
|
|
11656
|
-
const isEmptyShow = typeof ((_a = this.options) === null || _a === void 0 ? void 0 : _a.isEmptyShowPlaceholder) === 'undefined' ? true : this.options.isEmptyShowPlaceholder;
|
|
11657
|
-
const isMustShow = (_b = this.options) === null || _b === void 0 ? void 0 : _b.isMustShowPlaceholder;
|
|
11658
|
-
const isReadonly = (_c = this.options) === null || _c === void 0 ? void 0 : _c.readonly;
|
|
11659
|
-
// empty content and no selection processing
|
|
11660
|
-
if (!isReadonly && isEmptyShow && isEmptyContent(editor.children)) {
|
|
11661
|
-
const firstElementChild = this.contextService.getFirstElementChild();
|
|
11662
|
-
const offsetTop = firstElementChild.offsetTop;
|
|
11663
|
-
const offsetLeft = firstElementChild.offsetLeft;
|
|
11664
|
-
this.updatePosition(offsetLeft, offsetTop);
|
|
11665
|
-
return;
|
|
11666
|
-
}
|
|
11667
|
-
if (isMustShow && isCleanEmptyParagraph(editor)) {
|
|
11668
|
-
setTimeout(() => {
|
|
11669
|
-
var _a;
|
|
11670
|
-
const block = Node.ancestor(editor, [(_a = editor === null || editor === void 0 ? void 0 : editor.selection) === null || _a === void 0 ? void 0 : _a.anchor.path[0]]);
|
|
11671
|
-
const rootNode = AngularEditor.toDOMNode(editor, block);
|
|
11672
|
-
this.updatePosition(rootNode.offsetLeft, rootNode.offsetTop);
|
|
11673
|
-
});
|
|
11674
|
-
return;
|
|
11675
|
-
}
|
|
11676
|
-
this.isHide = true;
|
|
11677
|
-
}
|
|
11678
|
-
updatePosition(left, top) {
|
|
11679
|
-
this.isHide = false;
|
|
11680
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'top', `${top}px`);
|
|
11681
|
-
this.renderer.setStyle(this.elementRef.nativeElement, 'left', `${left}px`);
|
|
11682
|
-
}
|
|
11683
|
-
hide() {
|
|
11684
|
-
this.isHide = true;
|
|
11685
|
-
}
|
|
11686
|
-
}
|
|
11687
|
-
ThePlaceholderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: TheContextService }], target: i0.ɵɵFactoryTarget.Component });
|
|
11688
|
-
ThePlaceholderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: ThePlaceholderComponent, selector: "div[thePlaceholder]", inputs: { editor: "editor", options: "options" }, host: { listeners: { "document:compositionstart": "handleCompositionStart()", "document:compositionend": "handleCompositionEnd($event)" }, properties: { "class.hide": "isHide" }, classAttribute: "the-placeholder" }, ngImport: i0, template: `{{ options?.placeholder }}`, isInline: true });
|
|
11689
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: ThePlaceholderComponent, decorators: [{
|
|
11690
|
-
type: Component,
|
|
11691
|
-
args: [{
|
|
11692
|
-
selector: 'div[thePlaceholder]',
|
|
11693
|
-
template: `{{ options?.placeholder }}`,
|
|
11694
|
-
host: {
|
|
11695
|
-
class: 'the-placeholder',
|
|
11696
|
-
'[class.hide]': 'isHide'
|
|
11697
|
-
}
|
|
11698
|
-
}]
|
|
11699
|
-
}], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: TheContextService }]; }, propDecorators: { editor: [{
|
|
11700
|
-
type: Input
|
|
11701
|
-
}], options: [{
|
|
11702
|
-
type: Input
|
|
11703
|
-
}], handleCompositionStart: [{
|
|
11704
|
-
type: HostListener,
|
|
11705
|
-
args: ['document:compositionstart']
|
|
11706
|
-
}], handleCompositionEnd: [{
|
|
11707
|
-
type: HostListener,
|
|
11708
|
-
args: ['document:compositionend', ['$event']]
|
|
11709
|
-
}] } });
|
|
11710
|
-
|
|
11711
11899
|
class TheTemplateComponent {
|
|
11712
11900
|
constructor() {
|
|
11713
11901
|
this.renderElement = (element) => {
|
|
@@ -11797,14 +11985,14 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
|
|
|
11797
11985
|
return leaf ? leaf : null;
|
|
11798
11986
|
};
|
|
11799
11987
|
this.renderText = (text) => {
|
|
11800
|
-
if (text.text.length === 0) {
|
|
11801
|
-
return;
|
|
11802
|
-
}
|
|
11803
11988
|
for (const key in MarkTypes) {
|
|
11804
11989
|
if (text[MarkTypes[key]]) {
|
|
11805
11990
|
return TheTextComponent;
|
|
11806
11991
|
}
|
|
11807
11992
|
}
|
|
11993
|
+
if (text.text.length === 0) {
|
|
11994
|
+
return;
|
|
11995
|
+
}
|
|
11808
11996
|
};
|
|
11809
11997
|
this.onKeyDown = (event) => {
|
|
11810
11998
|
shortcuts(this.editor, event);
|
|
@@ -11919,12 +12107,14 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
|
|
|
11919
12107
|
this.editor.disabled = (_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.disabled;
|
|
11920
12108
|
this.editor.extraElementOptions = (_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.extraElementOptions;
|
|
11921
12109
|
setEditorUUID(this.editor, idCreator());
|
|
11922
|
-
this.theContextService.initialize({
|
|
12110
|
+
this.theContextService.initialize({
|
|
12111
|
+
theOptions: this.theOptions,
|
|
12112
|
+
nativeElement: this.elementRef.nativeElement,
|
|
12113
|
+
viewContainerRef: this.viewContainerRef
|
|
12114
|
+
});
|
|
11923
12115
|
this.toolbarCalculate();
|
|
11924
12116
|
setTimeout(() => {
|
|
11925
|
-
var _a;
|
|
11926
12117
|
this.theEditorCreated.emit(this.editor);
|
|
11927
|
-
(_a = this.placeholderInstance) === null || _a === void 0 ? void 0 : _a.checkStatus();
|
|
11928
12118
|
this.applyAutoFocus();
|
|
11929
12119
|
});
|
|
11930
12120
|
}
|
|
@@ -11975,13 +12165,16 @@ class TheEditorComponent extends mixinUnsubscribe(MixinBase) {
|
|
|
11975
12165
|
}
|
|
11976
12166
|
valueChange(value) {
|
|
11977
12167
|
var _a, _b, _c, _d, _e, _f;
|
|
11978
|
-
(_a = this.
|
|
11979
|
-
(
|
|
11980
|
-
|
|
12168
|
+
const isEditable = !((_a = this.theOptions) === null || _a === void 0 ? void 0 : _a.readonly) && !((_b = this.theOptions) === null || _b === void 0 ? void 0 : _b.disabled);
|
|
12169
|
+
(_c = this.theGlobalToolbarInstance) === null || _c === void 0 ? void 0 : _c.statusChange(this.editor);
|
|
12170
|
+
// quick insert button
|
|
12171
|
+
if (isEditable) {
|
|
12172
|
+
(_d = this.quickInsertInstance) === null || _d === void 0 ? void 0 : _d.checkStatus();
|
|
12173
|
+
}
|
|
11981
12174
|
// auto scroll view
|
|
11982
|
-
const scrollContainer = (
|
|
11983
|
-
const maxHeight = (
|
|
11984
|
-
if (
|
|
12175
|
+
const scrollContainer = (_e = this.theOptions) === null || _e === void 0 ? void 0 : _e.scrollContainer;
|
|
12176
|
+
const maxHeight = (_f = this.theOptions) === null || _f === void 0 ? void 0 : _f.maxHeight;
|
|
12177
|
+
if (isEditable && (scrollContainer || maxHeight)) {
|
|
11985
12178
|
const container = maxHeight ? DEFAULT_SCROLL_CONTAINER : scrollContainer;
|
|
11986
12179
|
this.autoScrollView(this.editor, container);
|
|
11987
12180
|
}
|
|
@@ -12106,12 +12299,13 @@ TheEditorComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", ver
|
|
|
12106
12299
|
useExisting: forwardRef(() => TheEditorComponent),
|
|
12107
12300
|
multi: true
|
|
12108
12301
|
}
|
|
12109
|
-
], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }
|
|
12302
|
+
], viewQueries: [{ propertyName: "templateInstance", first: true, predicate: ["templateInstance"], descendants: true, static: true }, { propertyName: "globalToolbarInstance", first: true, predicate: ["globalToolbar"], descendants: true }, { propertyName: "quickInsertInstance", first: true, predicate: ["quickInsert"], descendants: true, static: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<the-toolbar\n *ngIf=\"!theOptions?.readonly && !theGlobalToolbar\"\n [ngClass]=\"{\n 'the-toolbar-disabled': theOptions?.disabled\n }\"\n #globalToolbar\n [editor]=\"editor\"\n [toolbarItems]=\"toolbarEntity.global\"\n [containerClass]=\"globalToolbarClass\"\n [align]=\"theOptions?.toolbar?.align\"\n></the-toolbar>\n\n<div\n class=\"the-editable-container\"\n [ngClass]=\"{\n 'the-editor-disabled': theOptions?.disabled,\n 'max-height': maxHeight\n }\"\n [ngStyle]=\"{ 'max-height': maxHeight }\"\n>\n <slate-editable\n class=\"the-editor-typo\"\n [editor]=\"editor\"\n [ngModel]=\"editorValue\"\n (ngModelChange)=\"valueChange($event)\"\n [decorate]=\"decorate\"\n [placeholder]=\"theOptions?.placeholder\"\n [placeholderDecorate]=\"theOptions?.placeholderDecorate ? theOptions?.placeholderDecorate : null\"\n [renderElement]=\"renderElement\"\n [renderText]=\"renderText\"\n [renderLeaf]=\"renderLeaf\"\n [readonly]=\"theOptions?.readonly || theOptions?.disabled\"\n [keydown]=\"onKeyDown\"\n [click]=\"onClick\"\n [paste]=\"onSlaPaste\"\n [beforeInput]=\"onSlaBeforeInput\"\n [blur]=\"onSlaBlur\"\n [focus]=\"onSlaFocus\"\n [copy]=\"onSlaCopy\"\n [cut]=\"onSlaCut\"\n [isStrictDecorate]=\"false\"\n [compositionStart]=\"onSlaCompositionStart\"\n [compositionEnd]=\"onSlaCompositionEnd\"\n [dragStart]=\"onSlaDragStart\"\n [dragOver]=\"onSlaDragOver\"\n [drop]=\"onDrop\"\n (mousedown)=\"mousedown($event)\"\n ></slate-editable>\n <the-inline-toolbar *ngIf=\"!theOptions?.readonly\" [editor]=\"editor\" [toolbarItems]=\"toolbarEntity.inline\"></the-inline-toolbar>\n <div\n #quickInsert\n theQuickInsert\n [editor]=\"editor\"\n [quickToolbarItems]=\"quickToolbarItems\"\n [isVisible]=\"theOptions?.quickInsertVisible\"\n ></div>\n <the-template #templateInstance></the-template>\n</div>\n", components: [{ type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }, { type: i1.SlateEditableComponent, selector: "slate-editable", inputs: ["editor", "renderElement", "renderLeaf", "renderText", "decorate", "placeholderDecorate", "isStrictDecorate", "trackBy", "readonly", "placeholder", "beforeInput", "blur", "click", "compositionEnd", "compositionStart", "copy", "cut", "dragOver", "dragStart", "dragEnd", "drop", "focus", "keydown", "paste", "spellCheck", "autoCorrect", "autoCapitalize"] }, { type: TheInlineToolbarComponent, selector: "the-inline-toolbar", inputs: ["editor", "toolbarItems"] }, { type: TheQuickInsertComponent, selector: "[theQuickInsert]", inputs: ["editor", "quickToolbarItems", "isVisible"] }, { type: TheTemplateComponent, selector: "the-template,[theTemplate]" }], directives: [{ type: i6.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i6.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i4$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4$2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
12110
12303
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheEditorComponent, decorators: [{
|
|
12111
12304
|
type: Component,
|
|
12112
12305
|
args: [{
|
|
12113
12306
|
selector: 'the-editor, theEditor',
|
|
12114
12307
|
templateUrl: 'editor.component.html',
|
|
12308
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
12115
12309
|
providers: [
|
|
12116
12310
|
TheToolbarService,
|
|
12117
12311
|
TheContextService,
|
|
@@ -12152,9 +12346,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
12152
12346
|
}], quickInsertInstance: [{
|
|
12153
12347
|
type: ViewChild,
|
|
12154
12348
|
args: ['quickInsert', { static: true }]
|
|
12155
|
-
}], placeholderInstance: [{
|
|
12156
|
-
type: ViewChild,
|
|
12157
|
-
args: ['placeholder']
|
|
12158
12349
|
}] } });
|
|
12159
12350
|
|
|
12160
12351
|
const ENTRY_COMMON_COMPONENTS = [TheColumnResizeOverlayHandleComponent];
|
|
@@ -12270,7 +12461,7 @@ class TheToolbarGroupComponent {
|
|
|
12270
12461
|
}
|
|
12271
12462
|
}
|
|
12272
12463
|
TheToolbarGroupComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheToolbarGroupComponent, deps: [{ token: i0.ElementRef }, { token: i1$3.ThyPopover }, { token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
12273
|
-
TheToolbarGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheToolbarGroupComponent, selector: "the-toolbar-group", inputs: { menus: "menus", item: "item" }, host: { listeners: { "mousedown": "mousedownHandler($event)", "click": "clickHandle($event)" }, classAttribute: "the-toolbar-group" }, viewQueries: [{ propertyName: "groupTemplate", first: true, predicate: ["groupTemplate"], descendants: true, read: TemplateRef, static: true }], ngImport: i0, template: "<a thyIconNavLink [thyIconNavLinkIcon]=\"item.icon\" [thyTooltip]=\"item?.name\" thyTooltipPlacement=\"top\" [thyIconNavLinkActive]=\"active\"></a>\n\n<ng-template #groupTemplate>\n <the-toolbar class=\"group\" [editor]=\"editor\" [toolbarItems]=\"menus\" [isMore]=\"false\"></the-toolbar>\n</ng-template>\n", components: [{ type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "
|
|
12464
|
+
TheToolbarGroupComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.7", type: TheToolbarGroupComponent, selector: "the-toolbar-group", inputs: { menus: "menus", item: "item" }, host: { listeners: { "mousedown": "mousedownHandler($event)", "click": "clickHandle($event)" }, classAttribute: "the-toolbar-group" }, viewQueries: [{ propertyName: "groupTemplate", first: true, predicate: ["groupTemplate"], descendants: true, read: TemplateRef, static: true }], ngImport: i0, template: "<a thyIconNavLink [thyIconNavLinkIcon]=\"item.icon\" [thyTooltip]=\"item?.name\" thyTooltipPlacement=\"top\" [thyIconNavLinkActive]=\"active\"></a>\n\n<ng-template #groupTemplate>\n <the-toolbar class=\"group\" [editor]=\"editor\" [toolbarItems]=\"menus\" [isMore]=\"false\"></the-toolbar>\n</ng-template>\n", components: [{ type: i3.ThyIconNavLinkComponent, selector: "[thyIconNavLink]", inputs: ["thyIconNavLinkIcon", "thyIconNavLinkActive"] }, { type: TheToolbarComponent, selector: "the-toolbar", inputs: ["editor", "toolbarItems", "align", "containerClass", "isMore", "afterTemplate"] }], directives: [{ type: i5$1.ThyTooltipDirective, selector: "[thyTooltip],[thy-tooltip]", inputs: ["thyTooltip", "thyTooltipPlacement", "thyTooltipClass", "thyTooltipShowDelay", "thyTooltipHideDelay", "thyTooltipTrigger", "thyTooltipDisabled", "thyTooltipTemplateContext", "thyTooltipOffset", "thyTooltipPin"], exportAs: ["thyTooltip"] }] });
|
|
12274
12465
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: TheToolbarGroupComponent, decorators: [{
|
|
12275
12466
|
type: Component,
|
|
12276
12467
|
args: [{
|
|
@@ -12352,7 +12543,7 @@ const PLUGIN_COMPONENTS = [
|
|
|
12352
12543
|
TheTableComponent,
|
|
12353
12544
|
TheTableRowComponent,
|
|
12354
12545
|
TheTdComponent,
|
|
12355
|
-
|
|
12546
|
+
TheInlineCodeComponent
|
|
12356
12547
|
];
|
|
12357
12548
|
const PIPES = [ElementStylePipe, ElementClassPipe];
|
|
12358
12549
|
class TheEditorModule {
|
|
@@ -12392,7 +12583,7 @@ TheEditorModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version
|
|
|
12392
12583
|
TheTableComponent,
|
|
12393
12584
|
TheTableRowComponent,
|
|
12394
12585
|
TheTdComponent,
|
|
12395
|
-
|
|
12586
|
+
TheInlineCodeComponent], imports: [CommonModule, SlateModule, FormsModule, ThyIconModule,
|
|
12396
12587
|
ThyAvatarModule,
|
|
12397
12588
|
ThyNavModule,
|
|
12398
12589
|
ThyFormModule,
|
|
@@ -12441,5 +12632,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImpor
|
|
|
12441
12632
|
* Generated bundle index. Do not edit.
|
|
12442
12633
|
*/
|
|
12443
12634
|
|
|
12444
|
-
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, plainToTheia, toolbarCompose, withTheEditor };
|
|
12635
|
+
export { ALIGN_BLOCK_TYPES, A_TAG_REL_ATTR, AlignEditor, Alignment, BLOCK_DELETEBACKWARD_TYPES, BlockquoteEditor, CLIPBOARD_FORMAT_KEY, CODEMIRROR_PADDING_TOP, CODE_MODES, COMPONENTS, CONTAINER_BLOCKS, CONTROL_KEY, CodeEditor, CodeMode, ColorEditor, DEFAULT_LANGUAGE, DEFAULT_SCROLL_CONTAINER, DefaultElementOptions, DefaultGlobalToolbarDefinition, DefaultInlineToolbarDefinition, DefaultQuickToolbarDefinition, DropdownMode, ELEMENT_UNIQUE_ID, ElementKinds, ErrorCodes, FontSizeTypes, FontSizes, HEADING_TYPES, HeadingEditor, HrEditor, IS_MAC, ImageEditor, LINK_DEFAULT_TEXT, LIST_BLOCK_TYPES, LinkEditor, ListEditor, MarkEditor, MarkProps, MarkTypes, PICTURE_ACCEPTED_UPLOAD_MIME, PICTURE_ACCEPTED_UPLOAD_SIZE, PLUGIN_COMPONENTS, QUICK_TOOLBAR_HOTKEY, QuickInsertEditor, STANDARD_HEADING_TYPES, TAB_SPACE, THE_CODE_MODE_PROVIDER, THE_CODE_MODE_TOKEN, THE_EDITOR_CONVERSION_HINT_REF, THE_EDITOR_QUICK_TOOLBAR_REF, THE_EDITOR_UUID, THE_INLINE_TOOLBAR_TYPES, THE_UPLOAD_SERVICE_TOKEN, TableEditor, TheBaseElementComponent, TheCodeConfig, TheContextService, TheDataMode, TheDefaultElementComponent, TheEditor, TheEditorComponent, TheEditorModule, TheImageComponent, TheMode, index$1 as TheQueries, TheToolbarBaseItemComponent, TheToolbarComponent, TheToolbarDropdownComponent, TheToolbarGroupComponent, TheToolbarGroupToken, TheToolbarItemComponent, TheToolbarService, index as TheTransforms, TodoItemEditor, ToolbarActionTypes, ToolbarAlignment, ToolbarItemMode, ToolbarItemType, ToolbarMoreGroup, VOID_BLOCK_TYPES, VerticalAlignEditor, VerticalAlignment, ZERO_WIDTH_CHAR, createEmptyParagraph, dataDeserialize, dataSerializing, getToolbarClass, htmlToTheia, inValidTypes, isCleanEmptyParagraph, plainToTheia, toolbarCompose, withTheEditor };
|
|
12445
12636
|
//# sourceMappingURL=worktile-theia.js.map
|