@progress/kendo-angular-editor 2.5.0 → 3.0.0-dev.202201191455
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/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/README.md +1 -1
- package/dist/cdn/js/kendo-angular-editor.js +2 -2
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/error-messages.js +4 -3
- package/dist/es/config/command-icons.js +1 -0
- package/dist/es/config/commands.js +18 -17
- package/dist/es/config/schema.js +2 -4
- package/dist/es/config/table-commands.js +1 -363
- package/dist/es/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/es/dialogs/file-link-dialog.component.js +1 -1
- package/dist/es/dialogs/image-dialog.component.js +1 -1
- package/dist/es/editor-toolbar-state.js +12 -2
- package/dist/es/editor.component.js +103 -75
- package/dist/es/editor.module.js +6 -3
- package/dist/es/index.js +2 -0
- package/dist/es/localization/messages.js +4 -0
- package/dist/es/main.js +1 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/{es2015/config/table-nodes.d.ts → es/preventable-events/paste-event-data.js} +0 -5
- package/dist/es/preventable-events/paste-event.js +25 -0
- package/dist/es/tools/blockquote/editor-blockquote-button.directive.js +48 -0
- package/dist/es/tools/colorpicker/editor-colorpicker.component.js +24 -7
- package/dist/es/tools/format/editor-format-dropdownlist.component.js +1 -1
- package/dist/es/tools/format/editor-format.component.js +0 -1
- package/dist/es/tools/tables/popup-table-grid.component.js +1 -1
- package/dist/es2015/common/commands.d.ts +1 -1
- package/dist/es2015/common/error-messages.js +4 -3
- package/dist/es2015/common/format-item.interface.d.ts +1 -1
- package/dist/es2015/common/paste-cleanup-settings.d.ts +14 -0
- package/dist/es2015/config/command-icons.js +1 -0
- package/dist/es2015/config/commands.js +18 -17
- package/dist/es2015/config/schema.d.ts +1 -1
- package/dist/es2015/config/schema.js +2 -3
- package/dist/es2015/config/table-commands.d.ts +0 -36
- package/dist/es2015/config/table-commands.js +1 -357
- package/dist/es2015/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/es2015/dialogs/file-link-dialog.component.js +4 -4
- package/dist/es2015/dialogs/image-dialog.component.js +4 -4
- package/dist/es2015/editor-toolbar-state.js +12 -2
- package/dist/es2015/editor.component.d.ts +16 -11
- package/dist/es2015/editor.component.js +105 -75
- package/dist/es2015/editor.module.js +6 -3
- package/dist/es2015/index.d.ts +2 -0
- package/dist/es2015/index.js +2 -0
- package/dist/es2015/index.metadata.json +1 -1
- package/dist/es2015/localization/messages.d.ts +4 -0
- package/dist/es2015/localization/messages.js +4 -0
- package/dist/es2015/main.d.ts +2 -0
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/package-metadata.js +1 -1
- package/dist/es2015/preventable-events/paste-event-data.d.ts +21 -0
- package/dist/es2015/preventable-events/paste-event-data.js +4 -0
- package/dist/es2015/preventable-events/paste-event.d.ts +27 -0
- package/dist/es2015/preventable-events/paste-event.js +20 -0
- package/dist/es2015/tools/blockquote/editor-blockquote-button.directive.d.ts +30 -0
- package/dist/es2015/tools/blockquote/editor-blockquote-button.directive.js +45 -0
- package/dist/es2015/tools/colorpicker/editor-colorpicker.component.d.ts +8 -2
- package/dist/es2015/tools/colorpicker/editor-colorpicker.component.js +20 -7
- package/dist/es2015/tools/format/editor-format-dropdownlist.component.js +0 -4
- package/dist/es2015/tools/format/editor-format.component.js +0 -1
- package/dist/es2015/tools/tables/popup-table-grid.component.js +2 -2
- package/dist/fesm2015/index.js +354 -1624
- package/dist/fesm5/index.js +365 -1649
- package/dist/npm/common/error-messages.js +4 -2
- package/dist/npm/config/command-icons.js +1 -0
- package/dist/npm/config/commands.js +16 -14
- package/dist/npm/config/schema.js +2 -4
- package/dist/npm/config/table-commands.js +1 -368
- package/dist/npm/dialogs/colorpicker-dialog.component.js +1 -1
- package/dist/npm/dialogs/file-link-dialog.component.js +1 -1
- package/dist/npm/dialogs/image-dialog.component.js +1 -1
- package/dist/npm/editor-toolbar-state.js +11 -1
- package/dist/npm/editor.component.js +99 -71
- package/dist/npm/editor.module.js +7 -4
- package/dist/npm/index.js +5 -0
- package/dist/npm/localization/messages.js +4 -0
- package/dist/npm/main.js +2 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/preventable-events/paste-event-data.js +6 -0
- package/dist/npm/preventable-events/paste-event.js +27 -0
- package/dist/npm/tools/blockquote/editor-blockquote-button.directive.js +50 -0
- package/dist/npm/tools/colorpicker/editor-colorpicker.component.js +24 -7
- package/dist/npm/tools/format/editor-format-dropdownlist.component.js +1 -1
- package/dist/npm/tools/format/editor-format.component.js +0 -1
- package/dist/npm/tools/tables/popup-table-grid.component.js +1 -1
- package/dist/systemjs/kendo-angular-editor.js +1 -1
- package/package.json +18 -18
- package/dist/es/config/table-nodes.js +0 -146
- package/dist/es/config/tables/CellSelection.js +0 -268
- package/dist/es/config/tables/TableMap.js +0 -333
- package/dist/es/config/tables/table-utils.js +0 -302
- package/dist/es2015/config/table-nodes.js +0 -145
- package/dist/es2015/config/tables/CellSelection.d.ts +0 -35
- package/dist/es2015/config/tables/CellSelection.js +0 -256
- package/dist/es2015/config/tables/TableMap.d.ts +0 -35
- package/dist/es2015/config/tables/TableMap.js +0 -329
- package/dist/es2015/config/tables/table-utils.d.ts +0 -77
- package/dist/es2015/config/tables/table-utils.js +0 -299
- package/dist/npm/config/table-nodes.js +0 -157
- package/dist/npm/config/tables/CellSelection.js +0 -270
- package/dist/npm/config/tables/TableMap.js +0 -338
- package/dist/npm/config/tables/table-utils.js +0 -307
|
@@ -62,7 +62,7 @@ var FormatDropDownListComponent = /** @class */ (function () {
|
|
|
62
62
|
Component({
|
|
63
63
|
// tslint:disable-next-line:no-forward-ref
|
|
64
64
|
selector: 'kendo-editor-format-dropdownlist',
|
|
65
|
-
template: "\n <kendo-dropdownlist\n #element\n kendoEditorDropDownTool\n [defaultItem]=\"defaultItem\"\n [textField]=\"'text'\"\n [valueField]=\"'tag'\"\n [data]=\"data\"\n [(value)]=\"value\"\n [valuePrimitive]=\"true\"\n [itemDisabled]=\"itemDisabled\"\n [attr.title]=\"title\"\n [disabled]=\"disabled\"\n [tabindex]=\"tabindex\"\n (valueChange)=\"onValueChange($event)\"\n >\n <ng-template kendoDropDownListItemTemplate let-dataItem>\n <ng-container [ngSwitch]=\"dataItem.tag\">\n <span *ngSwitchCase=\"'h1'\" style=\"display: block; font-size: 2em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h2'\" style=\"display: block; font-size: 1.5em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h3'\" style=\"display: block; font-size: 1.17em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h4'\" style=\"display: block; font-size: 1em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h5'\" style=\"display: block; font-size: .83em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h6'\" style=\"display: block; font-size: .67em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'p'\" style=\"display: block; margin-left: 0;\">\n {{ dataItem.text }}\n </span>\n\n <span *
|
|
65
|
+
template: "\n <kendo-dropdownlist\n #element\n kendoEditorDropDownTool\n [defaultItem]=\"defaultItem\"\n [textField]=\"'text'\"\n [valueField]=\"'tag'\"\n [data]=\"data\"\n [(value)]=\"value\"\n [valuePrimitive]=\"true\"\n [itemDisabled]=\"itemDisabled\"\n [attr.title]=\"title\"\n [disabled]=\"disabled\"\n [tabindex]=\"tabindex\"\n (valueChange)=\"onValueChange($event)\"\n >\n <ng-template kendoDropDownListItemTemplate let-dataItem>\n <ng-container [ngSwitch]=\"dataItem.tag\">\n <span *ngSwitchCase=\"'h1'\" style=\"display: block; font-size: 2em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h2'\" style=\"display: block; font-size: 1.5em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h3'\" style=\"display: block; font-size: 1.17em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h4'\" style=\"display: block; font-size: 1em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h5'\" style=\"display: block; font-size: .83em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'h6'\" style=\"display: block; font-size: .67em; margin-left: 0; font-weight: bold;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchCase=\"'p'\" style=\"display: block; margin-left: 0;\">\n {{ dataItem.text }}\n </span>\n\n <span *ngSwitchDefault>{{ dataItem.text }}</span>\n </ng-container>\n </ng-template>\n </kendo-dropdownlist>\n "
|
|
66
66
|
})
|
|
67
67
|
], FormatDropDownListComponent);
|
|
68
68
|
return FormatDropDownListComponent;
|
|
@@ -39,7 +39,6 @@ var EditorFormatComponent = /** @class */ (function (_super) {
|
|
|
39
39
|
_this.valueChange = new EventEmitter();
|
|
40
40
|
_this._data = [
|
|
41
41
|
{ text: 'Paragraph', tag: 'p' },
|
|
42
|
-
{ text: 'Quotation', tag: 'blockquote' },
|
|
43
42
|
{ text: 'Heading 1', tag: 'h1' },
|
|
44
43
|
{ text: 'Heading 2', tag: 'h2' },
|
|
45
44
|
{ text: 'Heading 3', tag: 'h3' },
|
|
@@ -61,7 +61,7 @@ var PopupTableGridComponent = /** @class */ (function () {
|
|
|
61
61
|
PopupTableGridComponent = tslib_1.__decorate([
|
|
62
62
|
Component({
|
|
63
63
|
selector: 'kendo-popup-table-grid',
|
|
64
|
-
template: "\n <div style=\"border-color: inherit;\" (mouseleave)=\"resetState()\" (click)=\"insertTable()\">\n <span *ngFor=\"let i of cells\"\n class=\"k-ct-cell\"\n [class.k-
|
|
64
|
+
template: "\n <div style=\"border-color: inherit;\" (mouseleave)=\"resetState()\" (click)=\"insertTable()\">\n <span *ngFor=\"let i of cells\"\n class=\"k-ct-cell\"\n [class.k-selected]=\"selected(i)\"\n [class.k-disabled]=\"!selected(i)\"\n (mouseenter)=\"setState(i)\">\n </span>\n </div>\n <div class=\"k-status\" unselectable=\"on\">{{ message }}</div>\n <!-- uncomment when TableWizard is completed\n <div class=\"k-editor-toolbar\" unselectable=\"on\">\n <button type=\"button\" kendoButton class=\"k-tool\" [icon]=\"'table-wizard'\" (click)=\"openTableWizard()\" title=\"Table Wizard\">Table Wizard</button>\n </div>\n -->\n "
|
|
65
65
|
})
|
|
66
66
|
], PopupTableGridComponent);
|
|
67
67
|
return PopupTableGridComponent;
|
|
@@ -18,7 +18,7 @@ export declare type EditorInternalCommand = 'print';
|
|
|
18
18
|
/**
|
|
19
19
|
* The list of the command names that are accepted by the `exec` method.
|
|
20
20
|
*/
|
|
21
|
-
export declare type EditorCommand = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'createLink' | 'unlink' | 'insertFile' | 'insertImage' | 'insertOrderedList' | 'insertUnorderedList' | 'insertText' | 'indent' | 'outdent' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'format' | 'fontFamily' | 'fontSize' | 'cleanFormat' | 'setHTML' | 'undo' | 'redo' | 'subscript' | 'superscript' | 'cleanFormatting' | 'foreColor' | 'backColor' | 'insertTable' | 'addColumnBefore' | 'addColumnAfter' | 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'deleteTable' | 'selectAll';
|
|
21
|
+
export declare type EditorCommand = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'createLink' | 'unlink' | 'insertFile' | 'insertImage' | 'insertOrderedList' | 'insertUnorderedList' | 'insertText' | 'indent' | 'outdent' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'format' | 'fontFamily' | 'fontSize' | 'cleanFormat' | 'setHTML' | 'undo' | 'redo' | 'subscript' | 'superscript' | 'cleanFormatting' | 'foreColor' | 'backColor' | 'insertTable' | 'addColumnBefore' | 'addColumnAfter' | 'addRowBefore' | 'addRowAfter' | 'deleteRow' | 'deleteColumn' | 'mergeCells' | 'splitCell' | 'deleteTable' | 'selectAll' | 'blockquote';
|
|
22
22
|
/**
|
|
23
23
|
* The list of the dialog names that are accepted by the `openDialog` method.
|
|
24
24
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
const ɵ0 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`;
|
|
5
|
+
const ɵ0 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`, ɵ1 = (arg) => `pastedContent must be a function, but received ${JSON.stringify(arg)}.`;
|
|
6
6
|
/* tslint:disable:variable-name */
|
|
7
7
|
/**
|
|
8
8
|
* @hidden
|
|
@@ -11,8 +11,9 @@ export const EditorErrorMessages = {
|
|
|
11
11
|
schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
12
12
|
setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
13
13
|
pluginsCallbackType: ɵ0,
|
|
14
|
+
pastedContentCallbackType: ɵ1,
|
|
14
15
|
setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
|
|
15
|
-
setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See
|
|
16
|
+
setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See https://www.telerik.com/kendo-angular-ui/components/editor/plugins/#toc-custom-plugins/',
|
|
16
17
|
printTool: 'The Print tool and functionality are supported only in iframe mode. See https://www.telerik.com/kendo-angular-ui-develop/components/editor/api/EditorPrintButtonDirective/'
|
|
17
18
|
};
|
|
18
|
-
export { ɵ0 };
|
|
19
|
+
export { ɵ0, ɵ1 };
|
|
@@ -13,7 +13,7 @@ export interface FormatItem {
|
|
|
13
13
|
* 'h1'
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
tag: 'p' | '
|
|
16
|
+
tag: 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
17
17
|
/**
|
|
18
18
|
* The text for the defined tag that will be displayed in the drop-down list.
|
|
19
19
|
* @example
|
|
@@ -8,12 +8,16 @@
|
|
|
8
8
|
export interface PasteCleanupSettings {
|
|
9
9
|
/**
|
|
10
10
|
* If set to `true`, MS Word lists will be converted into HTML lists.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
11
13
|
*/
|
|
12
14
|
convertMsLists?: boolean;
|
|
13
15
|
/**
|
|
14
16
|
* If set to `true`, comments will be removed from the HTML.
|
|
15
17
|
*
|
|
16
18
|
* For example `<!-- comment --> <p> content </p>` will result in `<p> content </p>`
|
|
19
|
+
*
|
|
20
|
+
* @default false
|
|
17
21
|
*/
|
|
18
22
|
removeHtmlComments?: boolean;
|
|
19
23
|
/**
|
|
@@ -21,6 +25,8 @@ export interface PasteCleanupSettings {
|
|
|
21
25
|
* > Child nodes of removed tags will be kept in place.
|
|
22
26
|
*
|
|
23
27
|
* For example when `stripTags: ['span']`, `<p><span lang=EN-US>content</span></p>` will result in `<p>content</p>`
|
|
28
|
+
*
|
|
29
|
+
* @default []
|
|
24
30
|
*/
|
|
25
31
|
stripTags?: string[];
|
|
26
32
|
/**
|
|
@@ -32,12 +38,16 @@ export interface PasteCleanupSettings {
|
|
|
32
38
|
*
|
|
33
39
|
* For example when `removeAttributes: ['lang']`, `<p><span lang=EN-US>content</span></p>`
|
|
34
40
|
* will result in `<p><span>content</span></p>`
|
|
41
|
+
*
|
|
42
|
+
* @default []
|
|
35
43
|
*/
|
|
36
44
|
removeAttributes?: string[] | 'all';
|
|
37
45
|
/**
|
|
38
46
|
* If set to `true`, class attributes starting with 'Mso' will be removed from the HTML.
|
|
39
47
|
*
|
|
40
48
|
* For example `<p class="MsoNormal">pasted from MS Word</p>` will result in `<p>pasted from MS Word</p>`
|
|
49
|
+
*
|
|
50
|
+
* @default false
|
|
41
51
|
*/
|
|
42
52
|
removeMsClasses?: boolean;
|
|
43
53
|
/**
|
|
@@ -45,12 +55,16 @@ export interface PasteCleanupSettings {
|
|
|
45
55
|
*
|
|
46
56
|
* For example `<p><span style="color:#7C7C7C; mso-themecolor:accent3; mso-themeshade:191;">content</span></p>`
|
|
47
57
|
* will result in `<p><span style="color: #7C7C7C; background: silver;">content</span></p>`
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
48
60
|
*/
|
|
49
61
|
removeMsStyles?: boolean;
|
|
50
62
|
/**
|
|
51
63
|
* Determines whether invalid HTML should be removed.
|
|
52
64
|
*
|
|
53
65
|
* For example `<p>content <o:p>, <w:sdtPr></p>` will result in `<p>content </p>`
|
|
66
|
+
*
|
|
67
|
+
* @default true
|
|
54
68
|
*/
|
|
55
69
|
removeInvalidHTML?: boolean;
|
|
56
70
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { alignBlocks, alignLeftRules, alignCenterRules, alignRightRules, alignJustifyRules, alignRemoveRules, indent, outdent, setHtml, getHtml, insertImage, insertText, applyLink, removeLink, expandToWordWrap,
|
|
5
|
+
import { alignBlocks, alignLeftRules, alignCenterRules, alignRightRules, alignJustifyRules, alignRemoveRules, indent, outdent, setHtml, getHtml, insertImage, insertText, applyLink, removeLink, expandToWordWrap, blockquote,
|
|
6
6
|
//marks
|
|
7
|
-
bold, italic, underline, strikethrough, subscript, superscript, link, toggleInlineFormat, applyInlineStyle, formatBlockElements, toggleOrderedList, toggleUnorderedList, isAligned, undo, redo, cleanFormatting, selectAll } from '@progress/kendo-editor-common';
|
|
8
|
-
import { insertTable
|
|
7
|
+
bold, italic, underline, strikethrough, subscript, superscript, link, toggleInlineFormat, applyInlineStyle, formatBlockElements, toggleOrderedList, toggleUnorderedList, isAligned, undo, redo, cleanFormatting, selectAll, addColumnBefore, addColumnAfter, addRowBefore, addRowAfter, deleteRow, deleteColumn, deleteTable, mergeCells, splitCell } from '@progress/kendo-editor-common';
|
|
8
|
+
import { insertTable } from './table-commands';
|
|
9
9
|
const alignRemove = (state, dispatch) => alignBlocks(alignRemoveRules)(state, dispatch);
|
|
10
10
|
const ɵ0 = alignRemove;
|
|
11
11
|
const ɵ1 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, bold, { applyToWord })), ɵ2 = (options) => cleanFormatting(options), ɵ3 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs.value, applyToWord: attrs.applyToWord }), ɵ4 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-family', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ5 = attrs => expandToWordWrap(applyInlineStyle, { style: 'font-size', value: attrs.value + 'px', applyToWord: attrs.applyToWord }), ɵ6 = attrs => expandToWordWrap(applyLink, { mark: 'link', attrs: attrs, applyToWord: attrs.applyToWord }), ɵ7 = text => insertText(text), ɵ8 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, italic, { applyToWord })), ɵ9 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, strikethrough, { applyToWord })), ɵ10 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, subscript, { applyToWord })), ɵ11 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, superscript, { applyToWord })), ɵ12 = (applyToWord) => expandToWordWrap(toggleInlineFormat, Object.assign({}, underline, { applyToWord })), ɵ13 = () => removeLink(link), ɵ14 = attrs => expandToWordWrap(applyInlineStyle, { style: 'color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ15 = attrs => expandToWordWrap(applyInlineStyle, { style: 'background-color', value: attrs.value, applyToWord: attrs.applyToWord }), ɵ16 = () => (state, dispatch) => selectAll(state, dispatch);
|
|
@@ -27,7 +27,7 @@ const inlineCommand = {
|
|
|
27
27
|
backColor: ɵ15,
|
|
28
28
|
selectAll: ɵ16
|
|
29
29
|
};
|
|
30
|
-
const ɵ17 = () => (state, dispatch) => isAligned(state, alignCenterRules) ? alignRemove(state, dispatch) : alignBlocks(alignCenterRules)(state, dispatch), ɵ18 = () => (state, dispatch) => isAligned(state, alignJustifyRules) ? alignRemove(state, dispatch) : alignBlocks(alignJustifyRules)(state, dispatch), ɵ19 = () => (state, dispatch) => isAligned(state, alignLeftRules) ? alignRemove(state, dispatch) : alignBlocks(alignLeftRules)(state, dispatch), ɵ20 = () => (state, dispatch) => isAligned(state, alignRightRules) ? alignRemove(state, dispatch) : alignBlocks(alignRightRules)(state, dispatch), ɵ21 = formatAttr => formatBlockElements(formatAttr.tag), ɵ22 = () => getHtml, ɵ23 = () => indent, ɵ24 = attrs => insertImage(attrs), ɵ25 = () => toggleOrderedList, ɵ26 = () => toggleUnorderedList, ɵ27 = () => outdent, ɵ28 = () => redo, ɵ29 = ({ content, parseOptions }) => setHtml(content, 'setHTML', parseOptions), ɵ30 = () => undo;
|
|
30
|
+
const ɵ17 = () => (state, dispatch) => isAligned(state, alignCenterRules) ? alignRemove(state, dispatch) : alignBlocks(alignCenterRules)(state, dispatch), ɵ18 = () => (state, dispatch) => isAligned(state, alignJustifyRules) ? alignRemove(state, dispatch) : alignBlocks(alignJustifyRules)(state, dispatch), ɵ19 = () => (state, dispatch) => isAligned(state, alignLeftRules) ? alignRemove(state, dispatch) : alignBlocks(alignLeftRules)(state, dispatch), ɵ20 = () => (state, dispatch) => isAligned(state, alignRightRules) ? alignRemove(state, dispatch) : alignBlocks(alignRightRules)(state, dispatch), ɵ21 = formatAttr => formatBlockElements(formatAttr.tag), ɵ22 = () => getHtml, ɵ23 = () => indent, ɵ24 = attrs => insertImage(attrs), ɵ25 = () => toggleOrderedList, ɵ26 = () => toggleUnorderedList, ɵ27 = () => outdent, ɵ28 = () => redo, ɵ29 = ({ content, parseOptions }) => setHtml(content, 'setHTML', parseOptions), ɵ30 = () => undo, ɵ31 = () => blockquote;
|
|
31
31
|
const blockCommand = {
|
|
32
32
|
alignCenter: ɵ17,
|
|
33
33
|
alignJustify: ɵ18,
|
|
@@ -44,23 +44,24 @@ const blockCommand = {
|
|
|
44
44
|
outdent: ɵ27,
|
|
45
45
|
redo: ɵ28,
|
|
46
46
|
setHTML: ɵ29,
|
|
47
|
-
undo: ɵ30
|
|
47
|
+
undo: ɵ30,
|
|
48
|
+
blockquote: ɵ31
|
|
48
49
|
};
|
|
49
|
-
const ɵ
|
|
50
|
+
const ɵ32 = attr => insertTable(attr), ɵ33 = () => addColumnBefore, ɵ34 = () => addColumnAfter, ɵ35 = () => addRowBefore, ɵ36 = () => addRowAfter, ɵ37 = () => deleteRow, ɵ38 = () => deleteColumn, ɵ39 = () => mergeCells, ɵ40 = () => splitCell, ɵ41 = () => deleteTable;
|
|
50
51
|
const tableCommand = {
|
|
51
|
-
insertTable: ɵ
|
|
52
|
-
addColumnBefore: ɵ
|
|
53
|
-
addColumnAfter: ɵ
|
|
54
|
-
addRowBefore: ɵ
|
|
55
|
-
addRowAfter: ɵ
|
|
56
|
-
deleteRow: ɵ
|
|
57
|
-
deleteColumn: ɵ
|
|
58
|
-
mergeCells: ɵ
|
|
59
|
-
splitCell: ɵ
|
|
60
|
-
deleteTable: ɵ
|
|
52
|
+
insertTable: ɵ32,
|
|
53
|
+
addColumnBefore: ɵ33,
|
|
54
|
+
addColumnAfter: ɵ34,
|
|
55
|
+
addRowBefore: ɵ35,
|
|
56
|
+
addRowAfter: ɵ36,
|
|
57
|
+
deleteRow: ɵ37,
|
|
58
|
+
deleteColumn: ɵ38,
|
|
59
|
+
mergeCells: ɵ39,
|
|
60
|
+
splitCell: ɵ40,
|
|
61
|
+
deleteTable: ɵ41
|
|
61
62
|
};
|
|
62
63
|
/**
|
|
63
64
|
* @hidden
|
|
64
65
|
*/
|
|
65
66
|
export const editorCommands = Object.assign({}, inlineCommand, blockCommand, tableCommand);
|
|
66
|
-
export { ɵ0, ɵ1, ɵ2, ɵ3, ɵ4, ɵ5, ɵ6, ɵ7, ɵ8, ɵ9, ɵ10, ɵ11, ɵ12, ɵ13, ɵ14, ɵ15, ɵ16, ɵ17, ɵ18, ɵ19, ɵ20, ɵ21, ɵ22, ɵ23, ɵ24, ɵ25, ɵ26, ɵ27, ɵ28, ɵ29, ɵ30, ɵ31, ɵ32, ɵ33, ɵ34, ɵ35, ɵ36, ɵ37, ɵ38, ɵ39, ɵ40 };
|
|
67
|
+
export { ɵ0, ɵ1, ɵ2, ɵ3, ɵ4, ɵ5, ɵ6, ɵ7, ɵ8, ɵ9, ɵ10, ɵ11, ɵ12, ɵ13, ɵ14, ɵ15, ɵ16, ɵ17, ɵ18, ɵ19, ɵ20, ɵ21, ɵ22, ɵ23, ɵ24, ɵ25, ɵ26, ɵ27, ɵ28, ɵ29, ɵ30, ɵ31, ɵ32, ɵ33, ɵ34, ɵ35, ɵ36, ɵ37, ɵ38, ɵ39, ɵ40, ɵ41 };
|
|
@@ -4,18 +4,17 @@
|
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { semanticNodes } from './semantic-nodes';
|
|
6
6
|
import { marks as commonMarks, nodes as commonNodes, Schema } from '@progress/kendo-editor-common';
|
|
7
|
-
import { tableNodes } from './table-nodes';
|
|
8
7
|
/**
|
|
9
8
|
* @hidden
|
|
10
9
|
*/
|
|
11
10
|
const marks = commonMarks;
|
|
12
|
-
const nodes = Object.assign(commonNodes,
|
|
11
|
+
const nodes = Object.assign(commonNodes, semanticNodes);
|
|
13
12
|
/**
|
|
14
13
|
* @hidden
|
|
15
14
|
*/
|
|
16
15
|
export const schema = new Schema({
|
|
17
16
|
marks,
|
|
18
|
-
nodes
|
|
17
|
+
nodes
|
|
19
18
|
});
|
|
20
19
|
/**
|
|
21
20
|
* @hidden
|
|
@@ -8,39 +8,3 @@ import { Command } from '../common/commands';
|
|
|
8
8
|
* @hidden
|
|
9
9
|
*/
|
|
10
10
|
export declare const insertTable: (attrs: TableData) => Command;
|
|
11
|
-
/**
|
|
12
|
-
* @hidden
|
|
13
|
-
*/
|
|
14
|
-
export declare const addColumnBefore: Command;
|
|
15
|
-
/**
|
|
16
|
-
* @hidden
|
|
17
|
-
*/
|
|
18
|
-
export declare const addColumnAfter: Command;
|
|
19
|
-
/**
|
|
20
|
-
* @hidden
|
|
21
|
-
*/
|
|
22
|
-
export declare const addRowBefore: Command;
|
|
23
|
-
/**
|
|
24
|
-
* @hidden
|
|
25
|
-
*/
|
|
26
|
-
export declare const addRowAfter: Command;
|
|
27
|
-
/**
|
|
28
|
-
* @hidden
|
|
29
|
-
*/
|
|
30
|
-
export declare const deleteColumn: Command;
|
|
31
|
-
/**
|
|
32
|
-
* @hidden
|
|
33
|
-
*/
|
|
34
|
-
export declare const deleteRow: Command;
|
|
35
|
-
/**
|
|
36
|
-
* @hidden
|
|
37
|
-
*/
|
|
38
|
-
export declare const mergeCells: Command;
|
|
39
|
-
/**
|
|
40
|
-
* @hidden
|
|
41
|
-
*/
|
|
42
|
-
export declare const splitCell: Command;
|
|
43
|
-
/**
|
|
44
|
-
* @hidden
|
|
45
|
-
*/
|
|
46
|
-
export declare const deleteTable: Command;
|
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
* Copyright © 2021 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { insertNode,
|
|
6
|
-
import { createTable, isInTable, selectedRect, tableNodeTypes, rowIsHeader, setAttr, addColSpan, removeColSpan, isCellEmpty, splitCellWithType, cellsOverlapRectangle, findParentNodeClosestToPos } from './tables/table-utils';
|
|
7
|
-
import { isTable, isTableBody, isTableHead, isTableFoot, isTableHeaderCell, isTableCell } from './utils';
|
|
8
|
-
import { TableMap } from './tables/TableMap';
|
|
9
|
-
import { CellSelection } from './tables/CellSelection';
|
|
5
|
+
import { insertNode, createTable } from '@progress/kendo-editor-common';
|
|
10
6
|
/**
|
|
11
7
|
* @hidden
|
|
12
8
|
*/
|
|
@@ -16,355 +12,3 @@ export const insertTable = (attrs) => (state, dispatch) => {
|
|
|
16
12
|
insertNode(newTable, true)(state, dispatch);
|
|
17
13
|
}
|
|
18
14
|
};
|
|
19
|
-
const addTableGroupColumn = (tr, { left, right }, col, mainTable, requiredGroup, doc) => {
|
|
20
|
-
let refColumn = col > 0 ? -1 : 0;
|
|
21
|
-
// not sure if this should be deleted
|
|
22
|
-
// if (columnIsHeader(map, table, col + refColumn)) {
|
|
23
|
-
// refColumn = col === 0 || col === map.width ? null : 0;
|
|
24
|
-
// }
|
|
25
|
-
let rect;
|
|
26
|
-
mainTable.node.descendants((tableChildNode, offset) => {
|
|
27
|
-
if (requiredGroup(tableChildNode)) {
|
|
28
|
-
let i = -1;
|
|
29
|
-
tableChildNode.firstChild.descendants((childNode, pos) => {
|
|
30
|
-
if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
|
|
31
|
-
i = i + 1;
|
|
32
|
-
if (i === right || i === left) {
|
|
33
|
-
const selection = new Selection(doc.resolve(pos + offset + mainTable.start), doc.resolve(pos + offset + mainTable.start));
|
|
34
|
-
rect = selectedRect(selection);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
41
|
-
if (!rect) {
|
|
42
|
-
return tr;
|
|
43
|
-
}
|
|
44
|
-
for (let row = 0; row < rect.map.height; row++) {
|
|
45
|
-
const index = row * rect.map.width + col;
|
|
46
|
-
// If this position falls inside a col-spanning cell
|
|
47
|
-
if (col > 0 && col < rect.map.width && rect.map.map[index - 1] === rect.map.map[index]) {
|
|
48
|
-
const pos = rect.map.map[index];
|
|
49
|
-
const cell = rect.table.nodeAt(pos);
|
|
50
|
-
tr.setNodeMarkup(tr.mapping.map(rect.tableStart + pos), null, addColSpan(cell.attrs, col - rect.map.colCount(pos)));
|
|
51
|
-
// Skip ahead if rowspan > 1
|
|
52
|
-
row += cell.attrs.rowspan - 1;
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
const type = rect.table.nodeAt(rect.map.map[index + refColumn]).type;
|
|
56
|
-
const pos = rect.map.positionAt(row, col, rect.table);
|
|
57
|
-
tr.insert(tr.mapping.map(rect.tableStart + pos), type.createAndFill());
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return tr;
|
|
61
|
-
};
|
|
62
|
-
const ɵ0 = addTableGroupColumn;
|
|
63
|
-
const removeTableGroupColumn = (tr, { right, left }, mainTable, requiredGroup, doc) => {
|
|
64
|
-
let rect;
|
|
65
|
-
mainTable.node.descendants((tableChildNode, offset) => {
|
|
66
|
-
if (requiredGroup(tableChildNode)) {
|
|
67
|
-
let i = -1;
|
|
68
|
-
tableChildNode.firstChild.descendants((childNode, pos) => {
|
|
69
|
-
if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
|
|
70
|
-
i = i + 1;
|
|
71
|
-
if (i >= left && i < right) {
|
|
72
|
-
const resolvedPos = doc.resolve(pos + offset + mainTable.start + childNode.nodeSize);
|
|
73
|
-
const selection = new Selection(resolvedPos, resolvedPos);
|
|
74
|
-
rect = selectedRect(selection);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
81
|
-
if (!rect) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
for (let i = rect.right - 1;; i--) {
|
|
85
|
-
removeColumn(tr, rect, i);
|
|
86
|
-
if (i === rect.left) {
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
90
|
-
rect.map = TableMap.get(rect.table);
|
|
91
|
-
}
|
|
92
|
-
return;
|
|
93
|
-
};
|
|
94
|
-
const ɵ1 = removeTableGroupColumn;
|
|
95
|
-
const removeColumn = (tr, { map, table, tableStart }, col) => {
|
|
96
|
-
for (let row = 0; row < map.height;) {
|
|
97
|
-
const index = row * map.width + col;
|
|
98
|
-
const pos = map.map[index];
|
|
99
|
-
const cell = table.nodeAt(pos);
|
|
100
|
-
// If this is part of a col-spanning cell
|
|
101
|
-
if ((col > 0 && map.map[index - 1] === pos) || (col < map.width - 1 && map.map[index + 1] === pos)) {
|
|
102
|
-
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, removeColSpan(cell.attrs, col - map.colCount(pos)));
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const start = tr.mapping.map(tableStart + pos);
|
|
106
|
-
tr.delete(start, start + cell.nodeSize);
|
|
107
|
-
}
|
|
108
|
-
row += cell.attrs.rowspan;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const ɵ2 = removeColumn;
|
|
112
|
-
/**
|
|
113
|
-
* @hidden
|
|
114
|
-
*/
|
|
115
|
-
// Command to add a column before the column with the selection.
|
|
116
|
-
export const addColumnBefore = (state, dispatch) => {
|
|
117
|
-
if (!isInTable(state)) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if (dispatch) {
|
|
121
|
-
const rect = selectedRect(state.selection);
|
|
122
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
123
|
-
const tHeadTr = addTableGroupColumn(state.tr, rect, rect.left, mainTable, isTableHead, state.doc);
|
|
124
|
-
const tBodyTr = addTableGroupColumn(tHeadTr, rect, rect.left, mainTable, isTableBody, state.doc);
|
|
125
|
-
const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.left, mainTable, isTableFoot, state.doc);
|
|
126
|
-
dispatch(tFootTr);
|
|
127
|
-
}
|
|
128
|
-
return true;
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* @hidden
|
|
132
|
-
*/
|
|
133
|
-
// Command to add a column after the column with the selection.
|
|
134
|
-
export const addColumnAfter = (state, dispatch) => {
|
|
135
|
-
if (!isInTable(state)) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
if (dispatch) {
|
|
139
|
-
const rect = selectedRect(state.selection);
|
|
140
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
141
|
-
const theadTr = addTableGroupColumn(state.tr, rect, rect.right, mainTable, isTableHead, state.doc);
|
|
142
|
-
const tBodyTr = addTableGroupColumn(theadTr, rect, rect.right, mainTable, isTableBody, state.doc);
|
|
143
|
-
const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.right, mainTable, isTableFoot, state.doc);
|
|
144
|
-
dispatch(tFootTr);
|
|
145
|
-
}
|
|
146
|
-
return true;
|
|
147
|
-
};
|
|
148
|
-
const addRow = (tr, { map, tableStart, table }, row) => {
|
|
149
|
-
let rowPos = tableStart;
|
|
150
|
-
for (let i = 0; i < row; i++) {
|
|
151
|
-
rowPos += table.child(i).nodeSize;
|
|
152
|
-
}
|
|
153
|
-
const cells = [];
|
|
154
|
-
let refRow = row > 0 ? -1 : 0;
|
|
155
|
-
if (rowIsHeader(map, table, row + refRow)) {
|
|
156
|
-
refRow = row === 0 || row === map.height ? null : 0;
|
|
157
|
-
}
|
|
158
|
-
for (let col = 0, index = map.width * row; col < map.width; col++, index++) {
|
|
159
|
-
// Covered by a rowspan cell
|
|
160
|
-
if (row > 0 && row < map.height && map.map[index] === map.map[index - map.width]) {
|
|
161
|
-
const pos = map.map[index];
|
|
162
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
163
|
-
tr.setNodeMarkup(tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1));
|
|
164
|
-
col += attrs.colspan - 1;
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
const type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refRow * map.width]).type;
|
|
168
|
-
cells.push(type.createAndFill());
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
172
|
-
return tr;
|
|
173
|
-
};
|
|
174
|
-
const ɵ3 = addRow;
|
|
175
|
-
/**
|
|
176
|
-
* @hidden
|
|
177
|
-
*/
|
|
178
|
-
// Add a table row before the selection.
|
|
179
|
-
export const addRowBefore = (state, dispatch) => {
|
|
180
|
-
if (!isInTable(state)) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
if (dispatch) {
|
|
184
|
-
const rect = selectedRect(state.selection);
|
|
185
|
-
dispatch(addRow(state.tr, rect, rect.top));
|
|
186
|
-
}
|
|
187
|
-
return true;
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* @hidden
|
|
191
|
-
*/
|
|
192
|
-
// Add a table row after the selection.
|
|
193
|
-
export const addRowAfter = (state, dispatch) => {
|
|
194
|
-
if (!isInTable(state)) {
|
|
195
|
-
return false;
|
|
196
|
-
}
|
|
197
|
-
if (dispatch) {
|
|
198
|
-
const rect = selectedRect(state.selection);
|
|
199
|
-
dispatch(addRow(state.tr, rect, rect.bottom));
|
|
200
|
-
}
|
|
201
|
-
return true;
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* @hidden
|
|
205
|
-
*/
|
|
206
|
-
// Command function that removes the selected columns from a table.
|
|
207
|
-
export const deleteColumn = (state, dispatch) => {
|
|
208
|
-
if (!isInTable(state)) {
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
if (dispatch) {
|
|
212
|
-
const rect = selectedRect(state.selection);
|
|
213
|
-
// if only one column left - delete the whole table
|
|
214
|
-
if (rect.left === 0 && rect.right === rect.map.width) {
|
|
215
|
-
return deleteTable(state, dispatch);
|
|
216
|
-
}
|
|
217
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
218
|
-
const tr = state.tr;
|
|
219
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableFoot, tr.doc);
|
|
220
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableBody, tr.doc);
|
|
221
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableHead, tr.doc);
|
|
222
|
-
dispatch(tr);
|
|
223
|
-
}
|
|
224
|
-
return true;
|
|
225
|
-
};
|
|
226
|
-
const removeRow = (tr, { map, table, tableStart }, row) => {
|
|
227
|
-
let rowPos = 0;
|
|
228
|
-
for (let i = 0; i < row; i++) {
|
|
229
|
-
rowPos += table.child(i).nodeSize;
|
|
230
|
-
}
|
|
231
|
-
const nextRow = rowPos + table.child(row).nodeSize;
|
|
232
|
-
const mapFrom = tr.mapping.maps.length;
|
|
233
|
-
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
234
|
-
for (let col = 0, index = row * map.width; col < map.width; col++, index++) {
|
|
235
|
-
const pos = map.map[index];
|
|
236
|
-
if (row > 0 && pos === map.map[index - map.width]) {
|
|
237
|
-
// If this cell starts in the row above, simply reduce its rowspan
|
|
238
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
239
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, 'rowspan', attrs.rowspan - 1));
|
|
240
|
-
col += attrs.colspan - 1;
|
|
241
|
-
}
|
|
242
|
-
else if (row < map.width && pos === map.map[index + map.width]) {
|
|
243
|
-
// Else, if it continues in the row below, it has to be moved down
|
|
244
|
-
const cell = table.nodeAt(pos);
|
|
245
|
-
const copy = cell.type.create(setAttr(cell.attrs, 'rowspan', cell.attrs.rowspan - 1), cell.content);
|
|
246
|
-
const newPos = map.positionAt(row + 1, col, table);
|
|
247
|
-
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
248
|
-
col += cell.attrs.colspan - 1;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const ɵ4 = removeRow;
|
|
253
|
-
/**
|
|
254
|
-
* @hidden
|
|
255
|
-
*/
|
|
256
|
-
// Remove the selected rows from a table.
|
|
257
|
-
export const deleteRow = (state, dispatch) => {
|
|
258
|
-
if (!isInTable(state)) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
if (dispatch) {
|
|
262
|
-
const rect = selectedRect(state.selection);
|
|
263
|
-
const tr = state.tr;
|
|
264
|
-
if (rect.top === 0 && rect.bottom === rect.map.height) {
|
|
265
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
266
|
-
if (mainTable.node.childCount === 1) {
|
|
267
|
-
deleteTable(state, dispatch);
|
|
268
|
-
}
|
|
269
|
-
else {
|
|
270
|
-
deleteTableElement(n => n.type.name === rect.table.type.name)(state, dispatch);
|
|
271
|
-
}
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
for (let i = rect.bottom - 1;; i--) {
|
|
275
|
-
removeRow(tr, rect, i);
|
|
276
|
-
if (i === rect.top) {
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
280
|
-
rect.map = TableMap.get(rect.table);
|
|
281
|
-
}
|
|
282
|
-
dispatch(tr);
|
|
283
|
-
}
|
|
284
|
-
return true;
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* @hidden
|
|
288
|
-
*/
|
|
289
|
-
// Merge the selected cells into a single cell. Only available when
|
|
290
|
-
// the selected cells' outline forms a rectangle.
|
|
291
|
-
export const mergeCells = (state, dispatch) => {
|
|
292
|
-
const sel = state.selection;
|
|
293
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos === sel.$headCell.pos) {
|
|
294
|
-
return false;
|
|
295
|
-
}
|
|
296
|
-
const rect = selectedRect(state.selection);
|
|
297
|
-
const { map } = rect;
|
|
298
|
-
if (cellsOverlapRectangle(map, rect)) {
|
|
299
|
-
return false;
|
|
300
|
-
}
|
|
301
|
-
if (dispatch) {
|
|
302
|
-
const tr = state.tr;
|
|
303
|
-
const seen = {};
|
|
304
|
-
let content = Fragment.empty;
|
|
305
|
-
let mergedPos;
|
|
306
|
-
let mergedCell;
|
|
307
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
308
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
309
|
-
const cellPos = map.map[row * map.width + col], cell = rect.table.nodeAt(cellPos);
|
|
310
|
-
if (seen[cellPos]) {
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
seen[cellPos] = true;
|
|
314
|
-
if (mergedPos === null) {
|
|
315
|
-
mergedPos = cellPos;
|
|
316
|
-
mergedCell = cell;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
if (!isCellEmpty(cell)) {
|
|
320
|
-
content = content.append(cell.content);
|
|
321
|
-
}
|
|
322
|
-
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
323
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
tr.setNodeMarkup(mergedPos + rect.tableStart, null, setAttr(addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan), 'rowspan', rect.bottom - rect.top));
|
|
328
|
-
if (content.size) {
|
|
329
|
-
const end = mergedPos + 1 + mergedCell.content.size;
|
|
330
|
-
const start = isCellEmpty(mergedCell) ? mergedPos + 1 : end;
|
|
331
|
-
tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
|
|
332
|
-
}
|
|
333
|
-
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
334
|
-
dispatch(tr);
|
|
335
|
-
}
|
|
336
|
-
return true;
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* @hidden
|
|
340
|
-
*/
|
|
341
|
-
// Split a selected cell, whose rowpan or colspan is greater than one,
|
|
342
|
-
// into smaller cells. Use the first cell type for the new cells.
|
|
343
|
-
export const splitCell = (state, dispatch) => {
|
|
344
|
-
const nodeTypes = tableNodeTypes(state.schema);
|
|
345
|
-
return splitCellWithType(({ node }) => {
|
|
346
|
-
return nodeTypes[node.type.spec.tableRole];
|
|
347
|
-
})(state, dispatch);
|
|
348
|
-
};
|
|
349
|
-
const deleteTableElement = (selector) => (state, dispatch) => {
|
|
350
|
-
const $pos = state.selection.$anchor;
|
|
351
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
352
|
-
const node = $pos.node(d);
|
|
353
|
-
if (selector(node)) {
|
|
354
|
-
if (dispatch) {
|
|
355
|
-
const tr = state.tr;
|
|
356
|
-
tr.delete($pos.before(d), $pos.after(d)).scrollIntoView();
|
|
357
|
-
dispatch(tr);
|
|
358
|
-
}
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return false;
|
|
363
|
-
};
|
|
364
|
-
const ɵ5 = deleteTableElement;
|
|
365
|
-
/**
|
|
366
|
-
* @hidden
|
|
367
|
-
*/
|
|
368
|
-
// Deletes the table around the selection, if any.
|
|
369
|
-
export const deleteTable = deleteTableElement(isTable);
|
|
370
|
-
export { ɵ0, ɵ1, ɵ2, ɵ3, ɵ4, ɵ5 };
|