@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
package/dist/fesm2015/index.js
CHANGED
|
@@ -5,19 +5,19 @@
|
|
|
5
5
|
import { __decorate, __param, __metadata } from 'tslib';
|
|
6
6
|
import { Inject, Optional, Input, ViewChild, ElementRef, Component, Injectable, EventEmitter, isDevMode, Output, HostBinding, ContentChild, ViewContainerRef, forwardRef, ChangeDetectorRef, NgZone, TemplateRef, Host, Directive, NgModule } from '@angular/core';
|
|
7
7
|
import { FormControl, Validators, FormGroup, NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
-
import { Subject, BehaviorSubject, zip, fromEvent,
|
|
9
|
-
import { take,
|
|
8
|
+
import { Subject, BehaviorSubject, zip, fromEvent, interval } from 'rxjs';
|
|
9
|
+
import { take, map, filter, concatMap, takeUntil } from 'rxjs/operators';
|
|
10
10
|
import { ToolBarComponent, ToolBarToolComponent, ToolBarButtonComponent, ToolBarModule } from '@progress/kendo-angular-toolbar';
|
|
11
11
|
import { DialogContentBase, DialogRef, DialogService, DialogModule } from '@progress/kendo-angular-dialog';
|
|
12
|
-
import { isDocumentAvailable, guid, KendoInput, Keys } from '@progress/kendo-angular-common';
|
|
13
|
-
import { nodes, Schema, marks,
|
|
12
|
+
import { isDocumentAvailable, guid, PreventableEvent, hasObservers, KendoInput, Keys } from '@progress/kendo-angular-common';
|
|
13
|
+
import { nodes, Schema, marks, createTable, insertNode, expandToWordWrap, toggleInlineFormat, bold, cleanFormatting, applyLink, applyInlineStyle, insertText, italic, strikethrough, subscript, superscript, underline, removeLink, link, selectAll, isAligned, alignCenterRules, alignBlocks, alignRemoveRules, alignJustifyRules, alignLeftRules, alignRightRules, formatBlockElements, getHtml, indent, insertImage, toggleOrderedList, toggleUnorderedList, outdent, redo, setHtml, undo, blockquote, addColumnBefore, addColumnAfter, addRowBefore, addRowAfter, deleteRow, deleteColumn, mergeCells, splitCell, deleteTable, hasMark, activeNode, canIndentAsListItem, canBeIndented, indentRules, hasNode, canOutdentAsListItem, outdentRules, isIndented, getActiveMarks, expandSelection, getNodeFromSelection, getMark, getSelectionText, pasteCleanup, parseContent, AllSelection, TextSelection, Plugin, PluginKey, history, keymap, buildListKeymap, buildKeymap, baseKeymap, gapCursor, imageResizing, tableEditing, placeholder, EditorState, EditorView, removeComments, sanitize, removeAttribute, sanitizeStyleAttr, sanitizeClassAttr } from '@progress/kendo-editor-common';
|
|
14
14
|
export { Schema, EditorState, Plugin, PluginKey, Transaction, EditorView, Decoration, DecorationSet, NodeType, Node, MarkType, Mark, InputRule, inputRules, wrappingInputRule, textblockTypeInputRule, keymap, baseKeymap, history, dropCursor, gapCursor, tableNodes, getSelectionText } from '@progress/kendo-editor-common';
|
|
15
15
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
16
16
|
import { LocalizationService, L10N_PREFIX, RTL, MessageService, ComponentMessages } from '@progress/kendo-angular-l10n';
|
|
17
17
|
import { CommonModule } from '@angular/common';
|
|
18
18
|
import { DropDownListComponent, DropDownsModule } from '@progress/kendo-angular-dropdowns';
|
|
19
19
|
import { ButtonModule } from '@progress/kendo-angular-buttons';
|
|
20
|
-
import { ColorPickerComponent, ColorPickerModule, NumericTextBoxModule, TextBoxModule } from '@progress/kendo-angular-inputs';
|
|
20
|
+
import { ColorPickerComponent, ColorPickerModule, NumericTextBoxModule, CheckBoxModule, TextBoxModule } from '@progress/kendo-angular-inputs';
|
|
21
21
|
import { PopupService } from '@progress/kendo-angular-popup';
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -27,7 +27,7 @@ const packageMetadata = {
|
|
|
27
27
|
name: '@progress/kendo-angular-editor',
|
|
28
28
|
productName: 'Kendo UI for Angular',
|
|
29
29
|
productCodes: ['KENDOUIANGULAR', 'KENDOUICOMPLETE'],
|
|
30
|
-
publishDate:
|
|
30
|
+
publishDate: 1642603748,
|
|
31
31
|
version: '',
|
|
32
32
|
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/?utm_medium=product&utm_source=kendoangular&utm_campaign=kendo-ui-angular-purchase-license-keys-warning'
|
|
33
33
|
};
|
|
@@ -67,11 +67,6 @@ const getAttributes = (dom) => {
|
|
|
67
67
|
}
|
|
68
68
|
return result;
|
|
69
69
|
};
|
|
70
|
-
/**
|
|
71
|
-
* @hidden
|
|
72
|
-
*/
|
|
73
|
-
const serializeDOMAttrs = (el) => Array.from(el.attributes)
|
|
74
|
-
.reduce((acc, curr) => Object.assign({}, acc, { [curr.name]: curr.value }), {});
|
|
75
70
|
/**
|
|
76
71
|
* @hidden
|
|
77
72
|
*/
|
|
@@ -88,38 +83,6 @@ const createDefaultAttributes = (attrs = []) => {
|
|
|
88
83
|
* @hidden
|
|
89
84
|
*/
|
|
90
85
|
const hole = 0;
|
|
91
|
-
/**
|
|
92
|
-
* @hidden
|
|
93
|
-
*/
|
|
94
|
-
const isSchemaNode = (schemaNodeName) => (node) => node.type.name === schemaNodeName;
|
|
95
|
-
/**
|
|
96
|
-
* @hidden
|
|
97
|
-
*/
|
|
98
|
-
const isTable = isSchemaNode('table');
|
|
99
|
-
/**
|
|
100
|
-
* @hidden
|
|
101
|
-
*/
|
|
102
|
-
const isTableBody = isSchemaNode('table_body');
|
|
103
|
-
/**
|
|
104
|
-
* @hidden
|
|
105
|
-
*/
|
|
106
|
-
const isTableHead = isSchemaNode('table_head');
|
|
107
|
-
/**
|
|
108
|
-
* @hidden
|
|
109
|
-
*/
|
|
110
|
-
const isTableFoot = isSchemaNode('table_foot');
|
|
111
|
-
/**
|
|
112
|
-
* @hidden
|
|
113
|
-
*/
|
|
114
|
-
const isTableRow = isSchemaNode('table_row');
|
|
115
|
-
/**
|
|
116
|
-
* @hidden
|
|
117
|
-
*/
|
|
118
|
-
const isTableCell = isSchemaNode('table_cell');
|
|
119
|
-
/**
|
|
120
|
-
* @hidden
|
|
121
|
-
*/
|
|
122
|
-
const isTableHeaderCell = isSchemaNode('table_header');
|
|
123
86
|
|
|
124
87
|
const createSemanticNode = (tagName) => ({
|
|
125
88
|
// Uncaught SyntaxError: Mixing inline and block content (in content expression '(block | inline)*')
|
|
@@ -132,1492 +95,52 @@ const createSemanticNode = (tagName) => ({
|
|
|
132
95
|
getAttrs: getAttributes
|
|
133
96
|
}],
|
|
134
97
|
toDOM: node => hasAttrs(node.attrs) ? [tagName, getAttrs(node.attrs), hole] : [tagName, hole]
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* @hidden
|
|
138
|
-
*/
|
|
139
|
-
const semanticTagNames = ['article', 'main', 'nav', 'header', 'footer', 'aside', 'section'];
|
|
140
|
-
const ɵ1 = (acc, curr) => Object.assign(acc, { [curr]: createSemanticNode(curr) });
|
|
141
|
-
/**
|
|
142
|
-
* @hidden
|
|
143
|
-
*/
|
|
144
|
-
const semanticNodes = semanticTagNames.reduce(ɵ1, {});
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* @hidden
|
|
148
|
-
*/
|
|
149
|
-
function outerWidth(element) {
|
|
150
|
-
let width = element.offsetWidth;
|
|
151
|
-
const style = getComputedStyle(element);
|
|
152
|
-
width += parseFloat(style.marginLeft) || 0 + parseFloat(style.marginRight) || 0;
|
|
153
|
-
return width;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* @hidden
|
|
157
|
-
*/
|
|
158
|
-
const removeEntries = (obj, predicate) => Object.keys(obj)
|
|
159
|
-
.filter(key => predicate(key))
|
|
160
|
-
.reduce((acc, curr) => Object.assign(acc, { [curr]: obj[curr] }), {});
|
|
161
|
-
/**
|
|
162
|
-
* @hidden
|
|
163
|
-
*/
|
|
164
|
-
const removeEmptyEntries = (obj) => {
|
|
165
|
-
const predicate = key => obj[key] !== null && obj[key] !== undefined && obj[key] !== '';
|
|
166
|
-
return removeEntries(obj, predicate);
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* @hidden
|
|
170
|
-
*/
|
|
171
|
-
const isNullOrUndefined = (value) => value === undefined || value === null;
|
|
172
|
-
/**
|
|
173
|
-
* @hidden
|
|
174
|
-
*/
|
|
175
|
-
const isPresent = (value) => !isNullOrUndefined(value);
|
|
176
|
-
/**
|
|
177
|
-
* @hidden
|
|
178
|
-
*/
|
|
179
|
-
const detectIE = () => {
|
|
180
|
-
if (!isDocumentAvailable()) {
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
const ua = window.navigator.userAgent;
|
|
184
|
-
const msie = ua.indexOf('MSIE ');
|
|
185
|
-
const trident = ua.indexOf('Trident/');
|
|
186
|
-
return msie > 0 || trident > 0;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* @hidden
|
|
190
|
-
*/
|
|
191
|
-
const safeString = (value) => (isNullOrUndefined(value) ? '' : value.toString());
|
|
192
|
-
/**
|
|
193
|
-
* @hidden
|
|
194
|
-
*/
|
|
195
|
-
const first = (arr) => arr[0];
|
|
196
|
-
/**
|
|
197
|
-
* @hidden
|
|
198
|
-
*/
|
|
199
|
-
const last = (arr) => arr[arr.length - 1];
|
|
200
|
-
/**
|
|
201
|
-
* @hidden
|
|
202
|
-
*/
|
|
203
|
-
const split = (splitter) => (value) => value.split(splitter);
|
|
204
|
-
/**
|
|
205
|
-
* @hidden
|
|
206
|
-
*/
|
|
207
|
-
const trim = (value) => value.trim();
|
|
208
|
-
/**
|
|
209
|
-
* @hidden
|
|
210
|
-
*/
|
|
211
|
-
const filter$1 = (predicate) => (arr) => arr.filter(predicate);
|
|
212
|
-
/**
|
|
213
|
-
* @hidden
|
|
214
|
-
*/
|
|
215
|
-
const getUniqueStyleValues = (style, cssStyle) => {
|
|
216
|
-
if (style.hasNodesWithoutMarks) {
|
|
217
|
-
return '';
|
|
218
|
-
}
|
|
219
|
-
const uniqueMarkValues = style.marks
|
|
220
|
-
.filter(m => m.type.name === 'style')
|
|
221
|
-
.map(m => m.attrs.style)
|
|
222
|
-
.map(safeString)
|
|
223
|
-
.map(split(';'))
|
|
224
|
-
.map(filter$1((m) => m.includes(cssStyle)))
|
|
225
|
-
// guards against empty array
|
|
226
|
-
.map((cssStyleValues) => (cssStyleValues.length !== 0 ? cssStyleValues : [`${cssStyle}: INVALID`]))
|
|
227
|
-
.map(first)
|
|
228
|
-
.map(split(':'))
|
|
229
|
-
.map(last)
|
|
230
|
-
.map(trim)
|
|
231
|
-
.reduce((acc, curr) => (acc.indexOf(curr) > -1 ? acc : [...acc, curr]), []);
|
|
232
|
-
if (uniqueMarkValues.indexOf('INVALID') > -1 || uniqueMarkValues.length !== 1) {
|
|
233
|
-
return '';
|
|
234
|
-
}
|
|
235
|
-
return uniqueMarkValues[0];
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* @hidden
|
|
239
|
-
*/
|
|
240
|
-
const conditionallyExecute = (fn) => (condition) => (param) => (condition ? fn(param) : param);
|
|
241
|
-
/**
|
|
242
|
-
* @hidden
|
|
243
|
-
*/
|
|
244
|
-
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
|
|
245
|
-
|
|
246
|
-
const setCellAttrs = nodeAttributes => {
|
|
247
|
-
let attrs = Object.assign({}, nodeAttributes);
|
|
248
|
-
if (nodeAttributes.colspan !== 1) {
|
|
249
|
-
attrs.colspan = nodeAttributes.colspan;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
attrs.colspan = null;
|
|
253
|
-
}
|
|
254
|
-
if (nodeAttributes.rowspan !== 1) {
|
|
255
|
-
attrs.rowspan = nodeAttributes.rowspan;
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
attrs.rowspan = null;
|
|
259
|
-
}
|
|
260
|
-
return removeEmptyEntries(attrs);
|
|
261
|
-
};
|
|
262
|
-
const ɵ1$1 = node => ['table', removeEmptyEntries(node.attrs), 0], ɵ2 = node => ['tr', removeEmptyEntries(node.attrs), 0], ɵ3 = node => ['td', setCellAttrs(node.attrs), 0], ɵ4 = node => ['th', setCellAttrs(node.attrs), 0], ɵ5 = node => ['tbody', removeEmptyEntries(node.attrs), 0], ɵ6 = node => ['tfoot', removeEmptyEntries(node.attrs), 0], ɵ7 = node => ['thead', removeEmptyEntries(node.attrs), 0], ɵ8 = node => ['col', removeEmptyEntries(node.attrs)], ɵ9 = node => ['colgroup', removeEmptyEntries(node.attrs), 0];
|
|
263
|
-
/**
|
|
264
|
-
* @hidden
|
|
265
|
-
*/
|
|
266
|
-
const tableNodes = {
|
|
267
|
-
// all table node names must start with table - this is needed for the commands to work properly
|
|
268
|
-
table: {
|
|
269
|
-
attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['cellspacing', 'cellpadding'])),
|
|
270
|
-
content: '(table_body | table_head | table_foot | table_colgroup)+',
|
|
271
|
-
tableRole: 'table',
|
|
272
|
-
isolating: true,
|
|
273
|
-
group: 'block',
|
|
274
|
-
parseDOM: [
|
|
275
|
-
{
|
|
276
|
-
getAttrs: serializeDOMAttrs,
|
|
277
|
-
tag: 'table'
|
|
278
|
-
}
|
|
279
|
-
],
|
|
280
|
-
toDOM: ɵ1$1
|
|
281
|
-
},
|
|
282
|
-
table_row: {
|
|
283
|
-
content: '(table_cell | table_header)*',
|
|
284
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
285
|
-
tableRole: 'row',
|
|
286
|
-
parseDOM: [
|
|
287
|
-
{
|
|
288
|
-
getAttrs: serializeDOMAttrs,
|
|
289
|
-
tag: 'tr'
|
|
290
|
-
}
|
|
291
|
-
],
|
|
292
|
-
toDOM: ɵ2
|
|
293
|
-
},
|
|
294
|
-
table_cell: {
|
|
295
|
-
content: 'block+',
|
|
296
|
-
attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['headers']), {
|
|
297
|
-
// this is needed for the commands
|
|
298
|
-
colspan: { default: 1 }, rowspan: { default: 1 } }),
|
|
299
|
-
tableRole: 'cell',
|
|
300
|
-
isolating: true,
|
|
301
|
-
parseDOM: [
|
|
302
|
-
{
|
|
303
|
-
getAttrs: serializeDOMAttrs,
|
|
304
|
-
tag: 'td'
|
|
305
|
-
}
|
|
306
|
-
],
|
|
307
|
-
toDOM: ɵ3
|
|
308
|
-
},
|
|
309
|
-
table_header: {
|
|
310
|
-
content: 'block+',
|
|
311
|
-
attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['headers', 'abbr', 'scope']), { colspan: { default: 1 }, rowspan: { default: 1 } }),
|
|
312
|
-
tableRole: 'header_cell',
|
|
313
|
-
isolating: true,
|
|
314
|
-
parseDOM: [
|
|
315
|
-
{
|
|
316
|
-
getAttrs: serializeDOMAttrs,
|
|
317
|
-
tag: 'th'
|
|
318
|
-
}
|
|
319
|
-
],
|
|
320
|
-
toDOM: ɵ4
|
|
321
|
-
},
|
|
322
|
-
table_body: {
|
|
323
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
324
|
-
content: 'table_row+',
|
|
325
|
-
isolating: true,
|
|
326
|
-
parseDOM: [
|
|
327
|
-
{
|
|
328
|
-
getAttrs: serializeDOMAttrs,
|
|
329
|
-
tag: 'tbody'
|
|
330
|
-
}
|
|
331
|
-
],
|
|
332
|
-
toDOM: ɵ5
|
|
333
|
-
},
|
|
334
|
-
table_foot: {
|
|
335
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
336
|
-
content: 'table_row+',
|
|
337
|
-
isolating: true,
|
|
338
|
-
parseDOM: [
|
|
339
|
-
{
|
|
340
|
-
getAttrs: serializeDOMAttrs,
|
|
341
|
-
tag: 'tfoot'
|
|
342
|
-
}
|
|
343
|
-
],
|
|
344
|
-
toDOM: ɵ6
|
|
345
|
-
},
|
|
346
|
-
table_head: {
|
|
347
|
-
attrs: Object.assign({}, commonAttributes()),
|
|
348
|
-
content: 'table_row+',
|
|
349
|
-
isolating: true,
|
|
350
|
-
parseDOM: [
|
|
351
|
-
{
|
|
352
|
-
getAttrs: serializeDOMAttrs,
|
|
353
|
-
tag: 'thead'
|
|
354
|
-
}
|
|
355
|
-
],
|
|
356
|
-
toDOM: ɵ7
|
|
357
|
-
},
|
|
358
|
-
table_col: {
|
|
359
|
-
attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['span'])),
|
|
360
|
-
selectable: false,
|
|
361
|
-
atom: true,
|
|
362
|
-
parseDOM: [
|
|
363
|
-
{
|
|
364
|
-
getAttrs: serializeDOMAttrs,
|
|
365
|
-
tag: 'col'
|
|
366
|
-
}
|
|
367
|
-
],
|
|
368
|
-
toDOM: ɵ8
|
|
369
|
-
},
|
|
370
|
-
table_colgroup: {
|
|
371
|
-
attrs: Object.assign({}, commonAttributes(), createDefaultAttributes(['span'])),
|
|
372
|
-
content: 'table_col*',
|
|
373
|
-
selectable: false,
|
|
374
|
-
parseDOM: [
|
|
375
|
-
{
|
|
376
|
-
getAttrs: serializeDOMAttrs,
|
|
377
|
-
tag: 'colgroup'
|
|
378
|
-
}
|
|
379
|
-
],
|
|
380
|
-
toDOM: ɵ9
|
|
381
|
-
}
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* @hidden
|
|
386
|
-
*/
|
|
387
|
-
const marks$1 = marks;
|
|
388
|
-
const nodes$1 = Object.assign(nodes, tableNodes, semanticNodes);
|
|
389
|
-
/**
|
|
390
|
-
* @hidden
|
|
391
|
-
*/
|
|
392
|
-
const schema = new Schema({
|
|
393
|
-
marks: marks$1,
|
|
394
|
-
nodes: Object.assign({}, nodes$1, { blockquote: Object.assign({}, nodes$1.blockquote, { content: 'inline*' }) })
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
// Because working with row and column-spanning cells is not quite
|
|
398
|
-
// trivial, this code builds up a descriptive structure for a given
|
|
399
|
-
// table node. The structures are cached with the (persistent) table
|
|
400
|
-
// nodes as key, so that they only have to be recomputed when the
|
|
401
|
-
// content of the table changes.
|
|
402
|
-
//
|
|
403
|
-
// This does mean that they have to store table-relative, not
|
|
404
|
-
// document-relative positions. So code that uses them will typically
|
|
405
|
-
// compute the start position of the table and offset positions passed
|
|
406
|
-
// to or gotten from this structure by that amount.
|
|
407
|
-
let readFromCache;
|
|
408
|
-
let addToCache;
|
|
409
|
-
// Prefer using a weak map to cache table maps. Fall back on a
|
|
410
|
-
// fixed-size cache if that's not supported.
|
|
411
|
-
if (typeof WeakMap !== 'undefined') {
|
|
412
|
-
let cache = new WeakMap();
|
|
413
|
-
readFromCache = key => cache.get(key);
|
|
414
|
-
addToCache = (key, value) => {
|
|
415
|
-
cache.set(key, value);
|
|
416
|
-
return value;
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
let cache = [];
|
|
421
|
-
let cacheSize = 10;
|
|
422
|
-
let cachePos = 0;
|
|
423
|
-
readFromCache = key => {
|
|
424
|
-
for (let i = 0; i < cache.length; i += 2) {
|
|
425
|
-
if (cache[i] === key) {
|
|
426
|
-
return cache[i + 1];
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
addToCache = (key, value) => {
|
|
431
|
-
if (cachePos === cacheSize) {
|
|
432
|
-
cachePos = 0;
|
|
433
|
-
}
|
|
434
|
-
cache[cachePos++] = key;
|
|
435
|
-
return (cache[cachePos++] = value);
|
|
436
|
-
};
|
|
437
|
-
}
|
|
438
|
-
const findWidth = (table) => {
|
|
439
|
-
let width = -1;
|
|
440
|
-
let hasRowSpan = false;
|
|
441
|
-
for (let row = 0; row < table.childCount; row++) {
|
|
442
|
-
const rowNode = table.child(row);
|
|
443
|
-
let rowWidth = 0;
|
|
444
|
-
if (hasRowSpan) {
|
|
445
|
-
for (let j = 0; j < row; j++) {
|
|
446
|
-
const prevRow = table.child(j);
|
|
447
|
-
for (let i = 0; i < prevRow.childCount; i++) {
|
|
448
|
-
const cell = prevRow.child(i);
|
|
449
|
-
if (j + cell.attrs.rowspan > row) {
|
|
450
|
-
rowWidth += cell.attrs.colspan;
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
// check if the cell spans accross multiple columns
|
|
456
|
-
for (let i = 0; i < rowNode.childCount; i++) {
|
|
457
|
-
const cell = rowNode.child(i);
|
|
458
|
-
rowWidth += cell.attrs.colspan;
|
|
459
|
-
if (cell.attrs.rowspan > 1) {
|
|
460
|
-
hasRowSpan = true;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
if (width === -1) {
|
|
464
|
-
width = rowWidth;
|
|
465
|
-
}
|
|
466
|
-
else if (width !== rowWidth) {
|
|
467
|
-
width = Math.max(width, rowWidth);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return width;
|
|
471
|
-
};
|
|
472
|
-
const freshColWidth = attrs => {
|
|
473
|
-
if (attrs.colwidth) {
|
|
474
|
-
return attrs.colwidth.slice();
|
|
475
|
-
}
|
|
476
|
-
const result = [];
|
|
477
|
-
for (let i = 0; i < attrs.colspan; i++) {
|
|
478
|
-
result.push(0);
|
|
479
|
-
}
|
|
480
|
-
return result;
|
|
481
|
-
};
|
|
482
|
-
const findBadColWidths = (map$$1, colWidths, table) => {
|
|
483
|
-
if (!map$$1.problems) {
|
|
484
|
-
map$$1.problems = [];
|
|
485
|
-
}
|
|
486
|
-
for (let i = 0, seen = {}; i < map$$1.map.length; i++) {
|
|
487
|
-
const pos = map$$1.map[i];
|
|
488
|
-
if (seen[pos]) {
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
seen[pos] = true;
|
|
492
|
-
let node = table.nodeAt(pos);
|
|
493
|
-
let updated = null;
|
|
494
|
-
for (let j = 0; j < node.attrs.colspan; j++) {
|
|
495
|
-
const col = (i + j) % map$$1.width;
|
|
496
|
-
const colWidth = colWidths[col * 2];
|
|
497
|
-
if (colWidth != null && (!node.attrs.colwidth || node.attrs.colwidth[j] !== colWidth)) {
|
|
498
|
-
(updated || (updated = freshColWidth(node.attrs)))[j] = colWidth;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
if (updated) {
|
|
502
|
-
map$$1.problems.unshift({ type: 'colwidth mismatch', pos, colwidth: updated });
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
// Compute a table map.
|
|
507
|
-
const computeMap = tableNode => {
|
|
508
|
-
if (!isTable(tableNode) && !isTableBody(tableNode) && !isTableHead(tableNode) && !isTableFoot(tableNode)) {
|
|
509
|
-
throw new RangeError('Not a table node: ' + tableNode.type.name);
|
|
510
|
-
}
|
|
511
|
-
const width = findWidth(tableNode);
|
|
512
|
-
const height = tableNode.childCount;
|
|
513
|
-
const map$$1 = [];
|
|
514
|
-
let mapPos = 0;
|
|
515
|
-
let problems = null;
|
|
516
|
-
const colWidths = [];
|
|
517
|
-
for (let i = 0, e = width * height; i < e; i++) {
|
|
518
|
-
map$$1[i] = 0;
|
|
519
|
-
}
|
|
520
|
-
for (let row = 0, pos = 0; row < height; row++) {
|
|
521
|
-
const rowNode = tableNode.child(row);
|
|
522
|
-
pos++;
|
|
523
|
-
for (let i = 0;; i++) {
|
|
524
|
-
while (mapPos < map$$1.length && map$$1[mapPos] !== 0) {
|
|
525
|
-
mapPos++;
|
|
526
|
-
}
|
|
527
|
-
if (i === rowNode.childCount) {
|
|
528
|
-
break;
|
|
529
|
-
}
|
|
530
|
-
const cellNode = rowNode.child(i);
|
|
531
|
-
const { colspan, rowspan, colwidth } = cellNode.attrs;
|
|
532
|
-
for (let h = 0; h < rowspan; h++) {
|
|
533
|
-
if (h + row >= height) {
|
|
534
|
-
(problems || (problems = [])).push({ type: 'overlong_rowspan', pos, n: rowspan - h });
|
|
535
|
-
break;
|
|
536
|
-
}
|
|
537
|
-
const start = mapPos + h * width;
|
|
538
|
-
for (let w = 0; w < colspan; w++) {
|
|
539
|
-
if (map$$1[start + w] === 0) {
|
|
540
|
-
map$$1[start + w] = pos;
|
|
541
|
-
}
|
|
542
|
-
else {
|
|
543
|
-
(problems || (problems = [])).push({ type: 'collision', row, pos, n: colspan - w });
|
|
544
|
-
}
|
|
545
|
-
const colW = colwidth && colwidth[w];
|
|
546
|
-
if (colW) {
|
|
547
|
-
const widthIndex = ((start + w) % width) * 2, prev = colWidths[widthIndex];
|
|
548
|
-
if (prev == null || (prev !== colW && colWidths[widthIndex + 1] === 1)) {
|
|
549
|
-
colWidths[widthIndex] = colW;
|
|
550
|
-
colWidths[widthIndex + 1] = 1;
|
|
551
|
-
}
|
|
552
|
-
else if (prev === colW) {
|
|
553
|
-
colWidths[widthIndex + 1]++;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
mapPos += colspan;
|
|
559
|
-
pos += cellNode.nodeSize;
|
|
560
|
-
}
|
|
561
|
-
const expectedPos = (row + 1) * width;
|
|
562
|
-
let missing = 0;
|
|
563
|
-
while (mapPos < expectedPos) {
|
|
564
|
-
if (map$$1[mapPos++] === 0) {
|
|
565
|
-
missing++;
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
if (missing) {
|
|
569
|
-
(problems || (problems = [])).push({ type: 'missing', row, n: missing });
|
|
570
|
-
}
|
|
571
|
-
pos++;
|
|
572
|
-
}
|
|
573
|
-
const tableMap = new TableMap(width, height, map$$1, problems);
|
|
574
|
-
let badWidths = false;
|
|
575
|
-
// For columns that have defined widths, but whose widths disagree
|
|
576
|
-
// between rows, fix up the cells whose width doesn't match the
|
|
577
|
-
// computed one.
|
|
578
|
-
for (let i = 0; !badWidths && i < colWidths.length; i += 2) {
|
|
579
|
-
if (colWidths[i] != null && colWidths[i + 1] < height) {
|
|
580
|
-
badWidths = true;
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
if (badWidths) {
|
|
584
|
-
findBadColWidths(tableMap, colWidths, tableNode);
|
|
585
|
-
}
|
|
586
|
-
return tableMap;
|
|
587
|
-
};
|
|
588
|
-
/**
|
|
589
|
-
* @hidden
|
|
590
|
-
*/
|
|
591
|
-
class Rect {
|
|
592
|
-
constructor(left, top, right, bottom) {
|
|
593
|
-
this.left = left;
|
|
594
|
-
this.top = top;
|
|
595
|
-
this.right = right;
|
|
596
|
-
this.bottom = bottom;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* @hidden
|
|
601
|
-
*/
|
|
602
|
-
class TableMap {
|
|
603
|
-
// :: (Node) → TableMap
|
|
604
|
-
// Find the table map for the given table node.
|
|
605
|
-
static get(table) {
|
|
606
|
-
return readFromCache(table) || addToCache(table, computeMap(table));
|
|
607
|
-
}
|
|
608
|
-
constructor(width, height, map$$1, problems) {
|
|
609
|
-
// :: number The width of the table
|
|
610
|
-
this.width = width;
|
|
611
|
-
// :: number The table's height
|
|
612
|
-
this.height = height;
|
|
613
|
-
// :: [number] A width * height array with the start position of
|
|
614
|
-
// the cell covering that part of the table in each slot
|
|
615
|
-
this.map = map$$1;
|
|
616
|
-
// An optional array of problems (cell overlap or non-rectangular
|
|
617
|
-
// shape) for the table, used by the table normalizer.
|
|
618
|
-
this.problems = problems;
|
|
619
|
-
}
|
|
620
|
-
// :: (number) → Rect
|
|
621
|
-
// Find the dimensions of the cell at the given position.
|
|
622
|
-
findCell(pos) {
|
|
623
|
-
for (let i = 0; i < this.map.length; i++) {
|
|
624
|
-
const curPos = this.map[i];
|
|
625
|
-
if (curPos !== pos) {
|
|
626
|
-
continue;
|
|
627
|
-
}
|
|
628
|
-
const left = i % this.width;
|
|
629
|
-
const top = Math.floor(i / this.width);
|
|
630
|
-
let right = left + 1;
|
|
631
|
-
let bottom = top + 1;
|
|
632
|
-
for (let j = 1; right < this.width && this.map[i + j] === curPos; j++) {
|
|
633
|
-
right++;
|
|
634
|
-
}
|
|
635
|
-
for (let j = 1; bottom < this.height && this.map[i + this.width * j] === curPos; j++) {
|
|
636
|
-
bottom++;
|
|
637
|
-
}
|
|
638
|
-
return new Rect(left, top, right, bottom);
|
|
639
|
-
}
|
|
640
|
-
throw new RangeError('No cell with offset ' + pos + ' found');
|
|
641
|
-
}
|
|
642
|
-
// :: (number) → number
|
|
643
|
-
// Find the left side of the cell at the given position.
|
|
644
|
-
colCount(pos) {
|
|
645
|
-
for (let i = 0; i < this.map.length; i++) {
|
|
646
|
-
if (this.map[i] === pos) {
|
|
647
|
-
return i % this.width;
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
throw new RangeError('No cell with offset ' + pos + ' found');
|
|
651
|
-
}
|
|
652
|
-
// :: (number, string, number) → ?number
|
|
653
|
-
// Find the next cell in the given direction, starting from the cell
|
|
654
|
-
// at `pos`, if any.
|
|
655
|
-
nextCell(pos, axis, dir) {
|
|
656
|
-
const { left, right, top, bottom } = this.findCell(pos);
|
|
657
|
-
if (axis === 'horiz') {
|
|
658
|
-
if (dir < 0 ? left === 0 : right === this.width) {
|
|
659
|
-
return null;
|
|
660
|
-
}
|
|
661
|
-
return this.map[top * this.width + (dir < 0 ? left - 1 : right)];
|
|
662
|
-
}
|
|
663
|
-
else {
|
|
664
|
-
if (dir < 0 ? top === 0 : bottom === this.height) {
|
|
665
|
-
return null;
|
|
666
|
-
}
|
|
667
|
-
return this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];
|
|
668
|
-
}
|
|
669
|
-
}
|
|
670
|
-
// :: (number, number) → Rect
|
|
671
|
-
// Get the rectangle spanning the two given cells.
|
|
672
|
-
rectBetween(a, b) {
|
|
673
|
-
const { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);
|
|
674
|
-
const { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);
|
|
675
|
-
return new Rect(Math.min(leftA, leftB), Math.min(topA, topB), Math.max(rightA, rightB), Math.max(bottomA, bottomB));
|
|
676
|
-
}
|
|
677
|
-
// :: (Rect) → [number]
|
|
678
|
-
// Return the position of all cells that have the top left corner in
|
|
679
|
-
// the given rectangle.
|
|
680
|
-
cellsInRect(rect) {
|
|
681
|
-
const result = [];
|
|
682
|
-
const seen = {};
|
|
683
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
684
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
685
|
-
const index = row * this.width + col, pos = this.map[index];
|
|
686
|
-
if (seen[pos]) {
|
|
687
|
-
continue;
|
|
688
|
-
}
|
|
689
|
-
seen[pos] = true;
|
|
690
|
-
if ((col !== rect.left || !col || this.map[index - 1] !== pos) &&
|
|
691
|
-
(row !== rect.top || !row || this.map[index - this.width] !== pos)) {
|
|
692
|
-
result.push(pos);
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
}
|
|
696
|
-
return result;
|
|
697
|
-
}
|
|
698
|
-
// :: (number, number, Node) → number
|
|
699
|
-
// Return the position at which the cell at the given row and column
|
|
700
|
-
// starts, or would start, if a cell started there.
|
|
701
|
-
positionAt(row, col, table) {
|
|
702
|
-
for (let i = 0, rowStart = 0;; i++) {
|
|
703
|
-
const rowEnd = rowStart + table.child(i).nodeSize;
|
|
704
|
-
if (i === row) {
|
|
705
|
-
let index = col + row * this.width, rowEndIndex = (row + 1) * this.width;
|
|
706
|
-
// Skip past cells from previous rows (via rowspan)
|
|
707
|
-
while (index < rowEndIndex && this.map[index] < rowStart) {
|
|
708
|
-
index++;
|
|
709
|
-
}
|
|
710
|
-
return index === rowEndIndex ? rowEnd - 1 : this.map[index];
|
|
711
|
-
}
|
|
712
|
-
rowStart = rowEnd;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
/**
|
|
718
|
-
* @hidden
|
|
719
|
-
*/
|
|
720
|
-
// ::- A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)
|
|
721
|
-
// subclass that represents a cell selection spanning part of a table.
|
|
722
|
-
// With the plugin enabled, these will be created when the user
|
|
723
|
-
// selects across cells, and will be drawn by giving selected cells a
|
|
724
|
-
// `selectedCell` CSS class.
|
|
725
|
-
class CellSelection extends Selection {
|
|
726
|
-
// :: (ResolvedPos, ?ResolvedPos) → CellSelection
|
|
727
|
-
// Returns the smallest column selection that covers the given anchor
|
|
728
|
-
// and head cell.
|
|
729
|
-
static colSelection($anchorCell, $headCell = $anchorCell) {
|
|
730
|
-
let map$$1 = TableMap.get($anchorCell.node(-1));
|
|
731
|
-
let start = $anchorCell.start(-1);
|
|
732
|
-
let anchorRect = map$$1.findCell($anchorCell.pos - start);
|
|
733
|
-
let headRect = map$$1.findCell($headCell.pos - start);
|
|
734
|
-
let doc = $anchorCell.node(0);
|
|
735
|
-
if (anchorRect.top <= headRect.top) {
|
|
736
|
-
if (anchorRect.top > 0) {
|
|
737
|
-
$anchorCell = doc.resolve(start + map$$1.map[anchorRect.left]);
|
|
738
|
-
}
|
|
739
|
-
if (headRect.bottom < map$$1.height) {
|
|
740
|
-
$headCell = doc.resolve(start + map$$1.map[map$$1.width * (map$$1.height - 1) + headRect.right - 1]);
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
if (headRect.top > 0) {
|
|
745
|
-
$headCell = doc.resolve(start + map$$1.map[headRect.left]);
|
|
746
|
-
}
|
|
747
|
-
if (anchorRect.bottom < map$$1.height) {
|
|
748
|
-
$anchorCell = doc.resolve(start + map$$1.map[map$$1.width * (map$$1.height - 1) + anchorRect.right - 1]);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
return new CellSelection($anchorCell, $headCell);
|
|
752
|
-
}
|
|
753
|
-
// :: (ResolvedPos, ?ResolvedPos) → CellSelection
|
|
754
|
-
// Returns the smallest row selection that covers the given anchor
|
|
755
|
-
// and head cell.
|
|
756
|
-
static rowSelection($anchorCell, $headCell = $anchorCell) {
|
|
757
|
-
let map$$1 = TableMap.get($anchorCell.node(-1));
|
|
758
|
-
let start = $anchorCell.start(-1);
|
|
759
|
-
let anchorRect = map$$1.findCell($anchorCell.pos - start);
|
|
760
|
-
let headRect = map$$1.findCell($headCell.pos - start);
|
|
761
|
-
let doc = $anchorCell.node(0);
|
|
762
|
-
if (anchorRect.left <= headRect.left) {
|
|
763
|
-
if (anchorRect.left > 0) {
|
|
764
|
-
$anchorCell = doc.resolve(start + map$$1.map[anchorRect.top * map$$1.width]);
|
|
765
|
-
}
|
|
766
|
-
if (headRect.right < map$$1.width) {
|
|
767
|
-
$headCell = doc.resolve(start + map$$1.map[map$$1.width * (headRect.top + 1) - 1]);
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
else {
|
|
771
|
-
if (headRect.left > 0) {
|
|
772
|
-
$headCell = doc.resolve(start + map$$1.map[headRect.top * map$$1.width]);
|
|
773
|
-
}
|
|
774
|
-
if (anchorRect.right < map$$1.width) {
|
|
775
|
-
$anchorCell = doc.resolve(start + map$$1.map[map$$1.width * (anchorRect.top + 1) - 1]);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
return new CellSelection($anchorCell, $headCell);
|
|
779
|
-
}
|
|
780
|
-
static fromJSON(doc, json) {
|
|
781
|
-
return new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));
|
|
782
|
-
}
|
|
783
|
-
// :: (Node, number, ?number) → CellSelection
|
|
784
|
-
static create(doc, anchorCell, headCell = anchorCell) {
|
|
785
|
-
return new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));
|
|
786
|
-
}
|
|
787
|
-
// :: (ResolvedPos, ?ResolvedPos)
|
|
788
|
-
// A table selection is identified by its anchor and head cells. The
|
|
789
|
-
// positions given to this constructor should point _before_ two
|
|
790
|
-
// cells in the same table. They may be the same, to select a single
|
|
791
|
-
// cell.
|
|
792
|
-
constructor($anchorCell, $headCell = $anchorCell) {
|
|
793
|
-
let table = $anchorCell.node(-1), map$$1 = TableMap.get(table), start = $anchorCell.start(-1);
|
|
794
|
-
let rect = map$$1.rectBetween($anchorCell.pos - start, $headCell.pos - start);
|
|
795
|
-
let doc = $anchorCell.node(0);
|
|
796
|
-
let cells = map$$1.cellsInRect(rect).filter(p => p !== $headCell.pos - start);
|
|
797
|
-
// Make the head cell the first range, so that it counts as the
|
|
798
|
-
// primary part of the selection
|
|
799
|
-
cells.unshift($headCell.pos - start);
|
|
800
|
-
let ranges = cells.map(pos => {
|
|
801
|
-
let cell = table.nodeAt(pos), from = pos + start + 1;
|
|
802
|
-
return new SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));
|
|
803
|
-
});
|
|
804
|
-
super(ranges[0].$from, ranges[0].$to, ranges);
|
|
805
|
-
// :: ResolvedPos
|
|
806
|
-
// A resolved position pointing _in front of_ the anchor cell (the one
|
|
807
|
-
// that doesn't move when extending the selection).
|
|
808
|
-
this.$anchorCell = $anchorCell;
|
|
809
|
-
// :: ResolvedPos
|
|
810
|
-
// A resolved position pointing in front of the head cell (the one
|
|
811
|
-
// moves when extending the selection).
|
|
812
|
-
this.$headCell = $headCell;
|
|
813
|
-
}
|
|
814
|
-
map(doc, mapping) {
|
|
815
|
-
let $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));
|
|
816
|
-
let $headCell = doc.resolve(mapping.map(this.$headCell.pos));
|
|
817
|
-
if (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {
|
|
818
|
-
let tableChanged = this.$anchorCell.node(-1) !== $anchorCell.node(-1);
|
|
819
|
-
if (tableChanged && this.isRowSelection()) {
|
|
820
|
-
return CellSelection.rowSelection($anchorCell, $headCell);
|
|
821
|
-
}
|
|
822
|
-
else {
|
|
823
|
-
if (tableChanged && this.isColSelection()) {
|
|
824
|
-
return CellSelection.colSelection($anchorCell, $headCell);
|
|
825
|
-
}
|
|
826
|
-
else {
|
|
827
|
-
return new CellSelection($anchorCell, $headCell);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
return TextSelection.between($anchorCell, $headCell);
|
|
832
|
-
}
|
|
833
|
-
// :: () → Slice
|
|
834
|
-
// Returns a rectangular slice of table rows containing the selected
|
|
835
|
-
// cells.
|
|
836
|
-
content() {
|
|
837
|
-
let table = this.$anchorCell.node(-1), map$$1 = TableMap.get(table), start = this.$anchorCell.start(-1);
|
|
838
|
-
let rect = map$$1.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start);
|
|
839
|
-
let seen = {}, rows = [];
|
|
840
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
841
|
-
let rowContent = [];
|
|
842
|
-
for (let index = row * map$$1.width + rect.left, col = rect.left; col < rect.right; col++, index++) {
|
|
843
|
-
let pos = map$$1.map[index];
|
|
844
|
-
if (!seen[pos]) {
|
|
845
|
-
seen[pos] = true;
|
|
846
|
-
let cellRect = map$$1.findCell(pos), cell = table.nodeAt(pos);
|
|
847
|
-
let extraLeft = rect.left - cellRect.left, extraRight = cellRect.right - rect.right;
|
|
848
|
-
if (extraLeft > 0 || extraRight > 0) {
|
|
849
|
-
let attrs = cell.attrs;
|
|
850
|
-
if (extraLeft > 0) {
|
|
851
|
-
attrs = removeColSpan(attrs, 0, extraLeft);
|
|
852
|
-
}
|
|
853
|
-
if (extraRight > 0) {
|
|
854
|
-
attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);
|
|
855
|
-
}
|
|
856
|
-
if (cellRect.left < rect.left) {
|
|
857
|
-
cell = cell.type.createAndFill(attrs);
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
cell = cell.type.create(attrs, cell.content);
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
if (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {
|
|
864
|
-
let attrs = setAttr(cell.attrs, 'rowspan', Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top));
|
|
865
|
-
if (cellRect.top < rect.top) {
|
|
866
|
-
cell = cell.type.createAndFill(attrs);
|
|
867
|
-
}
|
|
868
|
-
else {
|
|
869
|
-
cell = cell.type.create(attrs, cell.content);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
rowContent.push(cell);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
rows.push(table.child(row).copy(Fragment.from(rowContent)));
|
|
876
|
-
}
|
|
877
|
-
const fragment = this.isColSelection() && this.isRowSelection() ? table : rows;
|
|
878
|
-
return new Slice(Fragment.from(fragment), 1, 1);
|
|
879
|
-
}
|
|
880
|
-
replace(tr, content = Slice.empty) {
|
|
881
|
-
let mapFrom = tr.steps.length;
|
|
882
|
-
let ranges = this.ranges;
|
|
883
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
884
|
-
let { $from, $to } = ranges[i];
|
|
885
|
-
let mapping = tr.mapping.slice(mapFrom);
|
|
886
|
-
tr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? Slice.empty : content);
|
|
887
|
-
}
|
|
888
|
-
let sel = Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);
|
|
889
|
-
if (sel) {
|
|
890
|
-
tr.setSelection(sel);
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
replaceWith(tr, node) {
|
|
894
|
-
this.replace(tr, new Slice(Fragment.from(node), 0, 0));
|
|
895
|
-
}
|
|
896
|
-
forEachCell(f) {
|
|
897
|
-
let table = this.$anchorCell.node(-1);
|
|
898
|
-
let map$$1 = TableMap.get(table);
|
|
899
|
-
let start = this.$anchorCell.start(-1);
|
|
900
|
-
let cells = map$$1.cellsInRect(map$$1.rectBetween(this.$anchorCell.pos - start, this.$headCell.pos - start));
|
|
901
|
-
for (let i = 0; i < cells.length; i++) {
|
|
902
|
-
f(table.nodeAt(cells[i]), start + cells[i]);
|
|
903
|
-
}
|
|
904
|
-
}
|
|
905
|
-
// :: () → bool
|
|
906
|
-
// True if this selection goes all the way from the top to the
|
|
907
|
-
// bottom of the table.
|
|
908
|
-
isColSelection() {
|
|
909
|
-
let anchorTop = this.$anchorCell.index(-1), headTop = this.$headCell.index(-1);
|
|
910
|
-
if (Math.min(anchorTop, headTop) > 0) {
|
|
911
|
-
return false;
|
|
912
|
-
}
|
|
913
|
-
let anchorBot = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;
|
|
914
|
-
let headBot = headTop + this.$headCell.nodeAfter.attrs.rowspan;
|
|
915
|
-
return Math.max(anchorBot, headBot) === this.$headCell.node(-1).childCount;
|
|
916
|
-
}
|
|
917
|
-
// :: () → bool
|
|
918
|
-
// True if this selection goes all the way from the left to the
|
|
919
|
-
// right of the table.
|
|
920
|
-
isRowSelection() {
|
|
921
|
-
let map$$1 = TableMap.get(this.$anchorCell.node(-1));
|
|
922
|
-
let start = this.$anchorCell.start(-1);
|
|
923
|
-
let anchorLeft = map$$1.colCount(this.$anchorCell.pos - start);
|
|
924
|
-
let headLeft = map$$1.colCount(this.$headCell.pos - start);
|
|
925
|
-
if (Math.min(anchorLeft, headLeft) > 0) {
|
|
926
|
-
return false;
|
|
927
|
-
}
|
|
928
|
-
let anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;
|
|
929
|
-
let headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;
|
|
930
|
-
return Math.max(anchorRight, headRight) === map$$1.width;
|
|
931
|
-
}
|
|
932
|
-
eq(other) {
|
|
933
|
-
return (other instanceof CellSelection && other.$anchorCell.pos === this.$anchorCell.pos && other.$headCell.pos === this.$headCell.pos);
|
|
934
|
-
}
|
|
935
|
-
toJSON() {
|
|
936
|
-
return { type: 'cell', anchor: this.$anchorCell.pos, head: this.$headCell.pos };
|
|
937
|
-
}
|
|
938
|
-
getBookmark() {
|
|
939
|
-
return new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
CellSelection.prototype.visible = false;
|
|
943
|
-
Selection.jsonID('table_cell', CellSelection);
|
|
944
|
-
class CellBookmark {
|
|
945
|
-
constructor(anchor, head) {
|
|
946
|
-
this.anchor = anchor;
|
|
947
|
-
this.head = head;
|
|
948
|
-
}
|
|
949
|
-
map(mapping) {
|
|
950
|
-
return new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));
|
|
951
|
-
}
|
|
952
|
-
resolve(doc) {
|
|
953
|
-
let $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);
|
|
954
|
-
if ($anchorCell.parent.type.spec.tableRole === 'row' &&
|
|
955
|
-
$headCell.parent.type.spec.tableRole === 'row' &&
|
|
956
|
-
$anchorCell.index() < $anchorCell.parent.childCount &&
|
|
957
|
-
$headCell.index() < $headCell.parent.childCount &&
|
|
958
|
-
inSameTable($anchorCell, $headCell)) {
|
|
959
|
-
return new CellSelection($anchorCell, $headCell);
|
|
960
|
-
}
|
|
961
|
-
else {
|
|
962
|
-
return Selection.near($headCell, 1);
|
|
963
|
-
}
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
/**
|
|
968
|
-
* @hidden
|
|
969
|
-
*/
|
|
970
|
-
const findParentNodeClosestToPos = ($pos, predicate) => {
|
|
971
|
-
for (let i = $pos.depth; i > 0; i--) {
|
|
972
|
-
const node = $pos.node(i);
|
|
973
|
-
if (predicate(node)) {
|
|
974
|
-
return {
|
|
975
|
-
start: $pos.start(i),
|
|
976
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
977
|
-
depth: i,
|
|
978
|
-
node
|
|
979
|
-
};
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
};
|
|
983
|
-
/**
|
|
984
|
-
* @hidden
|
|
985
|
-
*/
|
|
986
|
-
const createTable = (nodes$$1, rows, columns) => {
|
|
987
|
-
const { table, table_body, table_row, table_cell } = nodes$$1;
|
|
988
|
-
const tableRows = [];
|
|
989
|
-
let cells;
|
|
990
|
-
for (let r = 0; r < rows + 1; r++) {
|
|
991
|
-
cells = [];
|
|
992
|
-
for (let c = 0; c < columns + 1; c++) {
|
|
993
|
-
cells.push(table_cell.createAndFill());
|
|
994
|
-
}
|
|
995
|
-
tableRows.push(table_row.createAndFill(undefined, cells));
|
|
996
|
-
}
|
|
997
|
-
const body = table_body.createAndFill(undefined, tableRows);
|
|
998
|
-
return table.createAndFill(undefined, body);
|
|
999
|
-
};
|
|
1000
|
-
/**
|
|
1001
|
-
* @hidden
|
|
1002
|
-
*/
|
|
1003
|
-
const isInTable = (state) => {
|
|
1004
|
-
const $head = state.selection.$head;
|
|
1005
|
-
for (let d = $head.depth; d > 0; d--) {
|
|
1006
|
-
if (isTableRow($head.node(d))) {
|
|
1007
|
-
return true;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
return false;
|
|
1011
|
-
};
|
|
1012
|
-
/**
|
|
1013
|
-
* @hidden
|
|
1014
|
-
*/
|
|
1015
|
-
const setAttr = (attrs, name, value) => {
|
|
1016
|
-
const result = {};
|
|
1017
|
-
// tslint:disable-next-line
|
|
1018
|
-
for (const prop in attrs) {
|
|
1019
|
-
result[prop] = attrs[prop];
|
|
1020
|
-
}
|
|
1021
|
-
result[name] = value;
|
|
1022
|
-
return result;
|
|
1023
|
-
};
|
|
1024
|
-
const cellNear = ($pos) => {
|
|
1025
|
-
for (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {
|
|
1026
|
-
const role = after.type.spec.tableRole;
|
|
1027
|
-
if (role === 'cell' || role === 'header_cell') {
|
|
1028
|
-
return $pos.doc.resolve(pos);
|
|
1029
|
-
}
|
|
1030
|
-
}
|
|
1031
|
-
for (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {
|
|
1032
|
-
const role = before.type.spec.tableRole;
|
|
1033
|
-
if (role === 'cell' || role === 'header_cell') {
|
|
1034
|
-
return $pos.doc.resolve(pos - before.nodeSize);
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
};
|
|
1038
|
-
const cellAround = ($pos) => {
|
|
1039
|
-
for (let d = $pos.depth - 1; d > 0; d--) {
|
|
1040
|
-
if (isTableRow($pos.node(d))) {
|
|
1041
|
-
return $pos.node(0).resolve($pos.before(d + 1));
|
|
1042
|
-
}
|
|
1043
|
-
}
|
|
1044
|
-
return null;
|
|
1045
|
-
};
|
|
1046
|
-
const selectionCell = (sel) => {
|
|
1047
|
-
if (sel instanceof CellSelection && sel.$anchorCell) {
|
|
1048
|
-
return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;
|
|
1049
|
-
}
|
|
1050
|
-
else if (sel instanceof NodeSelection && sel.node && isTableCell(sel.node)) {
|
|
1051
|
-
return sel.$anchor;
|
|
1052
|
-
}
|
|
1053
|
-
return cellAround(sel.$head) || cellNear(sel.$head);
|
|
1054
|
-
};
|
|
1055
|
-
/**
|
|
1056
|
-
* @hidden
|
|
1057
|
-
*/
|
|
1058
|
-
// Helper to get the selected rectangle in a table, if any. Adds table
|
|
1059
|
-
// map, table node, and table start offset to the object for
|
|
1060
|
-
// convenience.
|
|
1061
|
-
const selectedRect = (sel) => {
|
|
1062
|
-
// create arr of rect for each table section
|
|
1063
|
-
// there has to be a rect for thead, tbody and tfoot(if each exists)
|
|
1064
|
-
// and NOT for colgroups
|
|
1065
|
-
const $pos = selectionCell(sel);
|
|
1066
|
-
const table = $pos.node(-1);
|
|
1067
|
-
const tableStart = $pos.start(-1);
|
|
1068
|
-
const map$$1 = TableMap.get(table);
|
|
1069
|
-
const rect = sel instanceof CellSelection
|
|
1070
|
-
? map$$1.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart)
|
|
1071
|
-
: map$$1.findCell($pos.pos - tableStart);
|
|
1072
|
-
rect.tableStart = tableStart;
|
|
1073
|
-
rect.map = map$$1;
|
|
1074
|
-
rect.table = table;
|
|
1075
|
-
return rect;
|
|
1076
|
-
};
|
|
1077
|
-
/**
|
|
1078
|
-
* @hidden
|
|
1079
|
-
*/
|
|
1080
|
-
// this has to be removed since the schema should not have roles inside NodeSpec.
|
|
1081
|
-
const tableNodeTypes = (schema) => {
|
|
1082
|
-
let result = schema.cached.tableNodeTypes;
|
|
1083
|
-
if (!result) {
|
|
1084
|
-
result = schema.cached.tableNodeTypes = {};
|
|
1085
|
-
// tslint:disable-next-line
|
|
1086
|
-
for (const name in schema.nodes) {
|
|
1087
|
-
const type = schema.nodes[name];
|
|
1088
|
-
const role = type.spec.tableRole;
|
|
1089
|
-
if (role) {
|
|
1090
|
-
result[role] = type;
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
return result;
|
|
1095
|
-
};
|
|
1096
|
-
/**
|
|
1097
|
-
* @hidden
|
|
1098
|
-
*/
|
|
1099
|
-
const rowIsHeader = (map$$1, table, row) => {
|
|
1100
|
-
const headerCell = tableNodeTypes(table.type.schema).header_cell;
|
|
1101
|
-
for (let col = 0; col < map$$1.width; col++) {
|
|
1102
|
-
if (table.nodeAt(map$$1.map[col + row * map$$1.width]).type !== headerCell) {
|
|
1103
|
-
return false;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
return true;
|
|
1107
|
-
};
|
|
1108
|
-
/**
|
|
1109
|
-
* @hidden
|
|
1110
|
-
*/
|
|
1111
|
-
const addColSpan = (attrs, pos, n = 1) => {
|
|
1112
|
-
const result = setAttr(attrs, 'colspan', attrs.colspan + n);
|
|
1113
|
-
if (result.colwidth) {
|
|
1114
|
-
result.colwidth = result.colwidth.slice();
|
|
1115
|
-
for (let i = 0; i < n; i++) {
|
|
1116
|
-
result.colwidth.splice(pos, 0, 0);
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
return result;
|
|
1120
|
-
};
|
|
1121
|
-
/**
|
|
1122
|
-
* @hidden
|
|
1123
|
-
*/
|
|
1124
|
-
const removeColSpan = (attrs, pos, n = 1) => {
|
|
1125
|
-
const result = setAttr(attrs, 'colspan', attrs.colspan - n);
|
|
1126
|
-
if (result.colwidth) {
|
|
1127
|
-
result.colwidth = result.colwidth.slice();
|
|
1128
|
-
result.colwidth.splice(pos, n);
|
|
1129
|
-
if (!result.colwidth.some(w => w > 0)) {
|
|
1130
|
-
result.colwidth = null;
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
return result;
|
|
1134
|
-
};
|
|
1135
|
-
/**
|
|
1136
|
-
* @hidden
|
|
1137
|
-
*/
|
|
1138
|
-
const isCellEmpty = cell => {
|
|
1139
|
-
const c = cell.content;
|
|
1140
|
-
return c.childCount === 1 && c.firstChild.isTextblock && c.firstChild.childCount === 0;
|
|
1141
|
-
};
|
|
1142
|
-
const cellWrapping = ($pos) => {
|
|
1143
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
1144
|
-
// Sometimes the cell can be in the same depth.
|
|
1145
|
-
const role = $pos.node(d).type.spec.tableRole;
|
|
1146
|
-
if (role === 'cell' || role === 'header_cell') {
|
|
1147
|
-
return $pos.node(d);
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
return null;
|
|
1151
|
-
};
|
|
1152
|
-
/**
|
|
1153
|
-
* @hidden
|
|
1154
|
-
*/
|
|
1155
|
-
// Split a selected cell, whose rowpan or colspan is greater than one,
|
|
1156
|
-
// into smaller cells with the cell type (th, td) returned by getType function.
|
|
1157
|
-
const splitCellWithType = getCellType => {
|
|
1158
|
-
return (state, dispatch) => {
|
|
1159
|
-
const sel = state.selection;
|
|
1160
|
-
let cellNode;
|
|
1161
|
-
let cellPos;
|
|
1162
|
-
if (!(sel instanceof CellSelection)) {
|
|
1163
|
-
cellNode = cellWrapping(sel.$from);
|
|
1164
|
-
if (!cellNode) {
|
|
1165
|
-
return false;
|
|
1166
|
-
}
|
|
1167
|
-
cellPos = cellAround(sel.$from).pos;
|
|
1168
|
-
}
|
|
1169
|
-
else {
|
|
1170
|
-
if (sel.$anchorCell.pos !== sel.$headCell.pos) {
|
|
1171
|
-
return false;
|
|
1172
|
-
}
|
|
1173
|
-
cellNode = sel.$anchorCell.nodeAfter;
|
|
1174
|
-
cellPos = sel.$anchorCell.pos;
|
|
1175
|
-
}
|
|
1176
|
-
if (cellNode.attrs.colspan === 1 && cellNode.attrs.rowspan === 1) {
|
|
1177
|
-
return false;
|
|
1178
|
-
}
|
|
1179
|
-
if (dispatch) {
|
|
1180
|
-
let baseAttrs = cellNode.attrs;
|
|
1181
|
-
const attrs = [];
|
|
1182
|
-
const colwidth = baseAttrs.colwidth;
|
|
1183
|
-
if (baseAttrs.rowspan > 1) {
|
|
1184
|
-
baseAttrs = setAttr(baseAttrs, 'rowspan', 1);
|
|
1185
|
-
}
|
|
1186
|
-
if (baseAttrs.colspan > 1) {
|
|
1187
|
-
baseAttrs = setAttr(baseAttrs, 'colspan', 1);
|
|
1188
|
-
}
|
|
1189
|
-
const rect = selectedRect(state);
|
|
1190
|
-
const tr = state.tr;
|
|
1191
|
-
for (let i = 0; i < rect.right - rect.left; i++) {
|
|
1192
|
-
attrs.push(colwidth ? setAttr(baseAttrs, 'colwidth', colwidth && colwidth[i] ? [colwidth[i]] : null) : baseAttrs);
|
|
1193
|
-
}
|
|
1194
|
-
let lastCell;
|
|
1195
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
1196
|
-
let pos = rect.map.positionAt(row, rect.left, rect.table);
|
|
1197
|
-
if (row === rect.top) {
|
|
1198
|
-
pos += cellNode.nodeSize;
|
|
1199
|
-
}
|
|
1200
|
-
for (let col = rect.left, i = 0; col < rect.right; col++, i++) {
|
|
1201
|
-
if (col === rect.left && row === rect.top) {
|
|
1202
|
-
continue;
|
|
1203
|
-
}
|
|
1204
|
-
tr.insert((lastCell = tr.mapping.map(pos + rect.tableStart, 1)), getCellType({ node: cellNode, row, col }).createAndFill(attrs[i]));
|
|
1205
|
-
}
|
|
1206
|
-
}
|
|
1207
|
-
tr.setNodeMarkup(cellPos, getCellType({ node: cellNode, row: rect.top, col: rect.left }), attrs[0]);
|
|
1208
|
-
if (sel instanceof CellSelection) {
|
|
1209
|
-
tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell && tr.doc.resolve(lastCell)));
|
|
1210
|
-
}
|
|
1211
|
-
dispatch(tr);
|
|
1212
|
-
}
|
|
1213
|
-
return true;
|
|
1214
|
-
};
|
|
1215
|
-
};
|
|
1216
|
-
/**
|
|
1217
|
-
* @hidden
|
|
1218
|
-
*/
|
|
1219
|
-
const pointsAtCell = ($pos) => {
|
|
1220
|
-
return isTableRow($pos.parent) && $pos.nodeAfter;
|
|
1221
|
-
};
|
|
1222
|
-
/**
|
|
1223
|
-
* @hidden
|
|
1224
|
-
*/
|
|
1225
|
-
const inSameTable = ($a, $b) => {
|
|
1226
|
-
return $a.depth === $b.depth && $a.pos >= $b.start(-1) && $a.pos <= $b.end(-1);
|
|
1227
|
-
};
|
|
1228
|
-
/**
|
|
1229
|
-
* @hidden
|
|
1230
|
-
*/
|
|
1231
|
-
const cellsOverlapRectangle = ({ width, height, map: map$$1 }, rect) => {
|
|
1232
|
-
let indexTop = rect.top * width + rect.left;
|
|
1233
|
-
let indexLeft = indexTop;
|
|
1234
|
-
let indexBottom = (rect.bottom - 1) * width + rect.left;
|
|
1235
|
-
let indexRight = indexTop + (rect.right - rect.left - 1);
|
|
1236
|
-
for (let i = rect.top; i < rect.bottom; i++) {
|
|
1237
|
-
if ((rect.left > 0 && map$$1[indexLeft] === map$$1[indexLeft - 1]) || (rect.right < width && map$$1[indexRight] === map$$1[indexRight + 1])) {
|
|
1238
|
-
return true;
|
|
1239
|
-
}
|
|
1240
|
-
indexLeft += width;
|
|
1241
|
-
indexRight += width;
|
|
1242
|
-
}
|
|
1243
|
-
for (let i = rect.left; i < rect.right; i++) {
|
|
1244
|
-
if ((rect.top > 0 && map$$1[indexTop] === map$$1[indexTop - width]) ||
|
|
1245
|
-
(rect.bottom < height && map$$1[indexBottom] === map$$1[indexBottom + width])) {
|
|
1246
|
-
return true;
|
|
1247
|
-
}
|
|
1248
|
-
indexTop++;
|
|
1249
|
-
indexBottom++;
|
|
1250
|
-
}
|
|
1251
|
-
return false;
|
|
1252
|
-
};
|
|
1253
|
-
|
|
1254
|
-
/**
|
|
1255
|
-
* @hidden
|
|
1256
|
-
*/
|
|
1257
|
-
const insertTable = (attrs) => (state, dispatch) => {
|
|
1258
|
-
const newTable = createTable(state.schema.nodes, attrs.rows, attrs.cols);
|
|
1259
|
-
if (newTable) {
|
|
1260
|
-
insertNode(newTable, true)(state, dispatch);
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
const addTableGroupColumn = (tr, { left, right }, col, mainTable, requiredGroup, doc) => {
|
|
1264
|
-
let refColumn = col > 0 ? -1 : 0;
|
|
1265
|
-
// not sure if this should be deleted
|
|
1266
|
-
// if (columnIsHeader(map, table, col + refColumn)) {
|
|
1267
|
-
// refColumn = col === 0 || col === map.width ? null : 0;
|
|
1268
|
-
// }
|
|
1269
|
-
let rect;
|
|
1270
|
-
mainTable.node.descendants((tableChildNode, offset) => {
|
|
1271
|
-
if (requiredGroup(tableChildNode)) {
|
|
1272
|
-
let i = -1;
|
|
1273
|
-
tableChildNode.firstChild.descendants((childNode, pos) => {
|
|
1274
|
-
if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
|
|
1275
|
-
i = i + 1;
|
|
1276
|
-
if (i === right || i === left) {
|
|
1277
|
-
const selection = new Selection(doc.resolve(pos + offset + mainTable.start), doc.resolve(pos + offset + mainTable.start));
|
|
1278
|
-
rect = selectedRect(selection);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
});
|
|
1282
|
-
}
|
|
1283
|
-
});
|
|
1284
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
1285
|
-
if (!rect) {
|
|
1286
|
-
return tr;
|
|
1287
|
-
}
|
|
1288
|
-
for (let row = 0; row < rect.map.height; row++) {
|
|
1289
|
-
const index = row * rect.map.width + col;
|
|
1290
|
-
// If this position falls inside a col-spanning cell
|
|
1291
|
-
if (col > 0 && col < rect.map.width && rect.map.map[index - 1] === rect.map.map[index]) {
|
|
1292
|
-
const pos = rect.map.map[index];
|
|
1293
|
-
const cell = rect.table.nodeAt(pos);
|
|
1294
|
-
tr.setNodeMarkup(tr.mapping.map(rect.tableStart + pos), null, addColSpan(cell.attrs, col - rect.map.colCount(pos)));
|
|
1295
|
-
// Skip ahead if rowspan > 1
|
|
1296
|
-
row += cell.attrs.rowspan - 1;
|
|
1297
|
-
}
|
|
1298
|
-
else {
|
|
1299
|
-
const type = rect.table.nodeAt(rect.map.map[index + refColumn]).type;
|
|
1300
|
-
const pos = rect.map.positionAt(row, col, rect.table);
|
|
1301
|
-
tr.insert(tr.mapping.map(rect.tableStart + pos), type.createAndFill());
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
return tr;
|
|
1305
|
-
};
|
|
1306
|
-
const removeTableGroupColumn = (tr, { right, left }, mainTable, requiredGroup, doc) => {
|
|
1307
|
-
let rect;
|
|
1308
|
-
mainTable.node.descendants((tableChildNode, offset) => {
|
|
1309
|
-
if (requiredGroup(tableChildNode)) {
|
|
1310
|
-
let i = -1;
|
|
1311
|
-
tableChildNode.firstChild.descendants((childNode, pos) => {
|
|
1312
|
-
if (isTableCell(childNode) || isTableHeaderCell(childNode)) {
|
|
1313
|
-
i = i + 1;
|
|
1314
|
-
if (i >= left && i < right) {
|
|
1315
|
-
const resolvedPos = doc.resolve(pos + offset + mainTable.start + childNode.nodeSize);
|
|
1316
|
-
const selection = new Selection(resolvedPos, resolvedPos);
|
|
1317
|
-
rect = selectedRect(selection);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
});
|
|
1321
|
-
}
|
|
1322
|
-
});
|
|
1323
|
-
// Do nothing if thead, tfoot or tbody is missing
|
|
1324
|
-
if (!rect) {
|
|
1325
|
-
return;
|
|
1326
|
-
}
|
|
1327
|
-
for (let i = rect.right - 1;; i--) {
|
|
1328
|
-
removeColumn(tr, rect, i);
|
|
1329
|
-
if (i === rect.left) {
|
|
1330
|
-
break;
|
|
1331
|
-
}
|
|
1332
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
1333
|
-
rect.map = TableMap.get(rect.table);
|
|
1334
|
-
}
|
|
1335
|
-
return;
|
|
1336
|
-
};
|
|
1337
|
-
const removeColumn = (tr, { map: map$$1, table, tableStart }, col) => {
|
|
1338
|
-
for (let row = 0; row < map$$1.height;) {
|
|
1339
|
-
const index = row * map$$1.width + col;
|
|
1340
|
-
const pos = map$$1.map[index];
|
|
1341
|
-
const cell = table.nodeAt(pos);
|
|
1342
|
-
// If this is part of a col-spanning cell
|
|
1343
|
-
if ((col > 0 && map$$1.map[index - 1] === pos) || (col < map$$1.width - 1 && map$$1.map[index + 1] === pos)) {
|
|
1344
|
-
tr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, removeColSpan(cell.attrs, col - map$$1.colCount(pos)));
|
|
1345
|
-
}
|
|
1346
|
-
else {
|
|
1347
|
-
const start = tr.mapping.map(tableStart + pos);
|
|
1348
|
-
tr.delete(start, start + cell.nodeSize);
|
|
1349
|
-
}
|
|
1350
|
-
row += cell.attrs.rowspan;
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
|
-
/**
|
|
1354
|
-
* @hidden
|
|
1355
|
-
*/
|
|
1356
|
-
// Command to add a column before the column with the selection.
|
|
1357
|
-
const addColumnBefore$1 = (state, dispatch) => {
|
|
1358
|
-
if (!isInTable(state)) {
|
|
1359
|
-
return false;
|
|
1360
|
-
}
|
|
1361
|
-
if (dispatch) {
|
|
1362
|
-
const rect = selectedRect(state.selection);
|
|
1363
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
1364
|
-
const tHeadTr = addTableGroupColumn(state.tr, rect, rect.left, mainTable, isTableHead, state.doc);
|
|
1365
|
-
const tBodyTr = addTableGroupColumn(tHeadTr, rect, rect.left, mainTable, isTableBody, state.doc);
|
|
1366
|
-
const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.left, mainTable, isTableFoot, state.doc);
|
|
1367
|
-
dispatch(tFootTr);
|
|
1368
|
-
}
|
|
1369
|
-
return true;
|
|
1370
|
-
};
|
|
1371
|
-
/**
|
|
1372
|
-
* @hidden
|
|
1373
|
-
*/
|
|
1374
|
-
// Command to add a column after the column with the selection.
|
|
1375
|
-
const addColumnAfter$1 = (state, dispatch) => {
|
|
1376
|
-
if (!isInTable(state)) {
|
|
1377
|
-
return false;
|
|
1378
|
-
}
|
|
1379
|
-
if (dispatch) {
|
|
1380
|
-
const rect = selectedRect(state.selection);
|
|
1381
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
1382
|
-
const theadTr = addTableGroupColumn(state.tr, rect, rect.right, mainTable, isTableHead, state.doc);
|
|
1383
|
-
const tBodyTr = addTableGroupColumn(theadTr, rect, rect.right, mainTable, isTableBody, state.doc);
|
|
1384
|
-
const tFootTr = addTableGroupColumn(tBodyTr, rect, rect.right, mainTable, isTableFoot, state.doc);
|
|
1385
|
-
dispatch(tFootTr);
|
|
1386
|
-
}
|
|
1387
|
-
return true;
|
|
1388
|
-
};
|
|
1389
|
-
const addRow = (tr, { map: map$$1, tableStart, table }, row) => {
|
|
1390
|
-
let rowPos = tableStart;
|
|
1391
|
-
for (let i = 0; i < row; i++) {
|
|
1392
|
-
rowPos += table.child(i).nodeSize;
|
|
1393
|
-
}
|
|
1394
|
-
const cells = [];
|
|
1395
|
-
let refRow = row > 0 ? -1 : 0;
|
|
1396
|
-
if (rowIsHeader(map$$1, table, row + refRow)) {
|
|
1397
|
-
refRow = row === 0 || row === map$$1.height ? null : 0;
|
|
1398
|
-
}
|
|
1399
|
-
for (let col = 0, index = map$$1.width * row; col < map$$1.width; col++, index++) {
|
|
1400
|
-
// Covered by a rowspan cell
|
|
1401
|
-
if (row > 0 && row < map$$1.height && map$$1.map[index] === map$$1.map[index - map$$1.width]) {
|
|
1402
|
-
const pos = map$$1.map[index];
|
|
1403
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
1404
|
-
tr.setNodeMarkup(tableStart + pos, null, setAttr(attrs, 'rowspan', attrs.rowspan + 1));
|
|
1405
|
-
col += attrs.colspan - 1;
|
|
1406
|
-
}
|
|
1407
|
-
else {
|
|
1408
|
-
const type = refRow == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map$$1.map[index + refRow * map$$1.width]).type;
|
|
1409
|
-
cells.push(type.createAndFill());
|
|
1410
|
-
}
|
|
1411
|
-
}
|
|
1412
|
-
tr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));
|
|
1413
|
-
return tr;
|
|
1414
|
-
};
|
|
1415
|
-
/**
|
|
1416
|
-
* @hidden
|
|
1417
|
-
*/
|
|
1418
|
-
// Add a table row before the selection.
|
|
1419
|
-
const addRowBefore$1 = (state, dispatch) => {
|
|
1420
|
-
if (!isInTable(state)) {
|
|
1421
|
-
return false;
|
|
1422
|
-
}
|
|
1423
|
-
if (dispatch) {
|
|
1424
|
-
const rect = selectedRect(state.selection);
|
|
1425
|
-
dispatch(addRow(state.tr, rect, rect.top));
|
|
1426
|
-
}
|
|
1427
|
-
return true;
|
|
1428
|
-
};
|
|
1429
|
-
/**
|
|
1430
|
-
* @hidden
|
|
1431
|
-
*/
|
|
1432
|
-
// Add a table row after the selection.
|
|
1433
|
-
const addRowAfter$1 = (state, dispatch) => {
|
|
1434
|
-
if (!isInTable(state)) {
|
|
1435
|
-
return false;
|
|
1436
|
-
}
|
|
1437
|
-
if (dispatch) {
|
|
1438
|
-
const rect = selectedRect(state.selection);
|
|
1439
|
-
dispatch(addRow(state.tr, rect, rect.bottom));
|
|
1440
|
-
}
|
|
1441
|
-
return true;
|
|
1442
|
-
};
|
|
98
|
+
});
|
|
1443
99
|
/**
|
|
1444
100
|
* @hidden
|
|
1445
101
|
*/
|
|
1446
|
-
|
|
1447
|
-
const
|
|
1448
|
-
if (!isInTable(state)) {
|
|
1449
|
-
return false;
|
|
1450
|
-
}
|
|
1451
|
-
if (dispatch) {
|
|
1452
|
-
const rect = selectedRect(state.selection);
|
|
1453
|
-
// if only one column left - delete the whole table
|
|
1454
|
-
if (rect.left === 0 && rect.right === rect.map.width) {
|
|
1455
|
-
return deleteTable$1(state, dispatch);
|
|
1456
|
-
}
|
|
1457
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
1458
|
-
const tr = state.tr;
|
|
1459
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableFoot, tr.doc);
|
|
1460
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableBody, tr.doc);
|
|
1461
|
-
removeTableGroupColumn(tr, rect, mainTable, isTableHead, tr.doc);
|
|
1462
|
-
dispatch(tr);
|
|
1463
|
-
}
|
|
1464
|
-
return true;
|
|
1465
|
-
};
|
|
1466
|
-
const removeRow = (tr, { map: map$$1, table, tableStart }, row) => {
|
|
1467
|
-
let rowPos = 0;
|
|
1468
|
-
for (let i = 0; i < row; i++) {
|
|
1469
|
-
rowPos += table.child(i).nodeSize;
|
|
1470
|
-
}
|
|
1471
|
-
const nextRow = rowPos + table.child(row).nodeSize;
|
|
1472
|
-
const mapFrom = tr.mapping.maps.length;
|
|
1473
|
-
tr.delete(rowPos + tableStart, nextRow + tableStart);
|
|
1474
|
-
for (let col = 0, index = row * map$$1.width; col < map$$1.width; col++, index++) {
|
|
1475
|
-
const pos = map$$1.map[index];
|
|
1476
|
-
if (row > 0 && pos === map$$1.map[index - map$$1.width]) {
|
|
1477
|
-
// If this cell starts in the row above, simply reduce its rowspan
|
|
1478
|
-
const attrs = table.nodeAt(pos).attrs;
|
|
1479
|
-
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, setAttr(attrs, 'rowspan', attrs.rowspan - 1));
|
|
1480
|
-
col += attrs.colspan - 1;
|
|
1481
|
-
}
|
|
1482
|
-
else if (row < map$$1.width && pos === map$$1.map[index + map$$1.width]) {
|
|
1483
|
-
// Else, if it continues in the row below, it has to be moved down
|
|
1484
|
-
const cell = table.nodeAt(pos);
|
|
1485
|
-
const copy = cell.type.create(setAttr(cell.attrs, 'rowspan', cell.attrs.rowspan - 1), cell.content);
|
|
1486
|
-
const newPos = map$$1.positionAt(row + 1, col, table);
|
|
1487
|
-
tr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);
|
|
1488
|
-
col += cell.attrs.colspan - 1;
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
102
|
+
const semanticTagNames = ['article', 'main', 'nav', 'header', 'footer', 'aside', 'section'];
|
|
103
|
+
const ɵ1 = (acc, curr) => Object.assign(acc, { [curr]: createSemanticNode(curr) });
|
|
1492
104
|
/**
|
|
1493
105
|
* @hidden
|
|
1494
106
|
*/
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
if (!isInTable(state)) {
|
|
1498
|
-
return false;
|
|
1499
|
-
}
|
|
1500
|
-
if (dispatch) {
|
|
1501
|
-
const rect = selectedRect(state.selection);
|
|
1502
|
-
const tr = state.tr;
|
|
1503
|
-
if (rect.top === 0 && rect.bottom === rect.map.height) {
|
|
1504
|
-
const mainTable = findParentNodeClosestToPos(state.selection.$anchor, isTable);
|
|
1505
|
-
if (mainTable.node.childCount === 1) {
|
|
1506
|
-
deleteTable$1(state, dispatch);
|
|
1507
|
-
}
|
|
1508
|
-
else {
|
|
1509
|
-
deleteTableElement(n => n.type.name === rect.table.type.name)(state, dispatch);
|
|
1510
|
-
}
|
|
1511
|
-
return true;
|
|
1512
|
-
}
|
|
1513
|
-
for (let i = rect.bottom - 1;; i--) {
|
|
1514
|
-
removeRow(tr, rect, i);
|
|
1515
|
-
if (i === rect.top) {
|
|
1516
|
-
break;
|
|
1517
|
-
}
|
|
1518
|
-
rect.table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;
|
|
1519
|
-
rect.map = TableMap.get(rect.table);
|
|
1520
|
-
}
|
|
1521
|
-
dispatch(tr);
|
|
1522
|
-
}
|
|
1523
|
-
return true;
|
|
1524
|
-
};
|
|
107
|
+
const semanticNodes = semanticTagNames.reduce(ɵ1, {});
|
|
108
|
+
|
|
1525
109
|
/**
|
|
1526
110
|
* @hidden
|
|
1527
111
|
*/
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
const mergeCells$1 = (state, dispatch) => {
|
|
1531
|
-
const sel = state.selection;
|
|
1532
|
-
if (!(sel instanceof CellSelection) || sel.$anchorCell.pos === sel.$headCell.pos) {
|
|
1533
|
-
return false;
|
|
1534
|
-
}
|
|
1535
|
-
const rect = selectedRect(state.selection);
|
|
1536
|
-
const { map: map$$1 } = rect;
|
|
1537
|
-
if (cellsOverlapRectangle(map$$1, rect)) {
|
|
1538
|
-
return false;
|
|
1539
|
-
}
|
|
1540
|
-
if (dispatch) {
|
|
1541
|
-
const tr = state.tr;
|
|
1542
|
-
const seen = {};
|
|
1543
|
-
let content = Fragment.empty;
|
|
1544
|
-
let mergedPos;
|
|
1545
|
-
let mergedCell;
|
|
1546
|
-
for (let row = rect.top; row < rect.bottom; row++) {
|
|
1547
|
-
for (let col = rect.left; col < rect.right; col++) {
|
|
1548
|
-
const cellPos = map$$1.map[row * map$$1.width + col], cell = rect.table.nodeAt(cellPos);
|
|
1549
|
-
if (seen[cellPos]) {
|
|
1550
|
-
continue;
|
|
1551
|
-
}
|
|
1552
|
-
seen[cellPos] = true;
|
|
1553
|
-
if (mergedPos === null) {
|
|
1554
|
-
mergedPos = cellPos;
|
|
1555
|
-
mergedCell = cell;
|
|
1556
|
-
}
|
|
1557
|
-
else {
|
|
1558
|
-
if (!isCellEmpty(cell)) {
|
|
1559
|
-
content = content.append(cell.content);
|
|
1560
|
-
}
|
|
1561
|
-
const mapped = tr.mapping.map(cellPos + rect.tableStart);
|
|
1562
|
-
tr.delete(mapped, mapped + cell.nodeSize);
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
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));
|
|
1567
|
-
if (content.size) {
|
|
1568
|
-
const end = mergedPos + 1 + mergedCell.content.size;
|
|
1569
|
-
const start = isCellEmpty(mergedCell) ? mergedPos + 1 : end;
|
|
1570
|
-
tr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);
|
|
1571
|
-
}
|
|
1572
|
-
tr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));
|
|
1573
|
-
dispatch(tr);
|
|
1574
|
-
}
|
|
1575
|
-
return true;
|
|
1576
|
-
};
|
|
112
|
+
const marks$1 = marks;
|
|
113
|
+
const nodes$1 = Object.assign(nodes, semanticNodes);
|
|
1577
114
|
/**
|
|
1578
115
|
* @hidden
|
|
1579
116
|
*/
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
return nodeTypes[node.type.spec.tableRole];
|
|
1586
|
-
})(state, dispatch);
|
|
1587
|
-
};
|
|
1588
|
-
const deleteTableElement = (selector) => (state, dispatch) => {
|
|
1589
|
-
const $pos = state.selection.$anchor;
|
|
1590
|
-
for (let d = $pos.depth; d > 0; d--) {
|
|
1591
|
-
const node = $pos.node(d);
|
|
1592
|
-
if (selector(node)) {
|
|
1593
|
-
if (dispatch) {
|
|
1594
|
-
const tr = state.tr;
|
|
1595
|
-
tr.delete($pos.before(d), $pos.after(d)).scrollIntoView();
|
|
1596
|
-
dispatch(tr);
|
|
1597
|
-
}
|
|
1598
|
-
return true;
|
|
1599
|
-
}
|
|
1600
|
-
}
|
|
1601
|
-
return false;
|
|
1602
|
-
};
|
|
117
|
+
const schema = new Schema({
|
|
118
|
+
marks: marks$1,
|
|
119
|
+
nodes: nodes$1
|
|
120
|
+
});
|
|
121
|
+
|
|
1603
122
|
/**
|
|
1604
123
|
* @hidden
|
|
1605
124
|
*/
|
|
1606
|
-
|
|
1607
|
-
const
|
|
125
|
+
const insertTable = (attrs) => (state, dispatch) => {
|
|
126
|
+
const newTable = createTable(state.schema.nodes, attrs.rows, attrs.cols);
|
|
127
|
+
if (newTable) {
|
|
128
|
+
insertNode(newTable, true)(state, dispatch);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
1608
131
|
|
|
1609
132
|
const alignRemove = (state, dispatch) => alignBlocks(alignRemoveRules)(state, dispatch);
|
|
1610
|
-
const ɵ1$
|
|
133
|
+
const ɵ1$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);
|
|
1611
134
|
const inlineCommand = {
|
|
1612
|
-
bold: ɵ1$
|
|
1613
|
-
cleanFormatting: ɵ2
|
|
1614
|
-
createLink: ɵ3
|
|
1615
|
-
fontFamily: ɵ4
|
|
1616
|
-
fontSize: ɵ5
|
|
1617
|
-
insertFile: ɵ6
|
|
1618
|
-
insertText: ɵ7
|
|
1619
|
-
italic: ɵ8
|
|
1620
|
-
strikethrough: ɵ9
|
|
135
|
+
bold: ɵ1$1,
|
|
136
|
+
cleanFormatting: ɵ2,
|
|
137
|
+
createLink: ɵ3,
|
|
138
|
+
fontFamily: ɵ4,
|
|
139
|
+
fontSize: ɵ5,
|
|
140
|
+
insertFile: ɵ6,
|
|
141
|
+
insertText: ɵ7,
|
|
142
|
+
italic: ɵ8,
|
|
143
|
+
strikethrough: ɵ9,
|
|
1621
144
|
subscript: ɵ10,
|
|
1622
145
|
superscript: ɵ11,
|
|
1623
146
|
underline: ɵ12,
|
|
@@ -1626,7 +149,7 @@ const inlineCommand = {
|
|
|
1626
149
|
backColor: ɵ15,
|
|
1627
150
|
selectAll: ɵ16
|
|
1628
151
|
};
|
|
1629
|
-
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;
|
|
152
|
+
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;
|
|
1630
153
|
const blockCommand = {
|
|
1631
154
|
alignCenter: ɵ17,
|
|
1632
155
|
alignJustify: ɵ18,
|
|
@@ -1643,20 +166,21 @@ const blockCommand = {
|
|
|
1643
166
|
outdent: ɵ27,
|
|
1644
167
|
redo: ɵ28,
|
|
1645
168
|
setHTML: ɵ29,
|
|
1646
|
-
undo: ɵ30
|
|
169
|
+
undo: ɵ30,
|
|
170
|
+
blockquote: ɵ31
|
|
1647
171
|
};
|
|
1648
|
-
const ɵ
|
|
172
|
+
const ɵ32 = attr => insertTable(attr), ɵ33 = () => addColumnBefore, ɵ34 = () => addColumnAfter, ɵ35 = () => addRowBefore, ɵ36 = () => addRowAfter, ɵ37 = () => deleteRow, ɵ38 = () => deleteColumn, ɵ39 = () => mergeCells, ɵ40 = () => splitCell, ɵ41 = () => deleteTable;
|
|
1649
173
|
const tableCommand = {
|
|
1650
|
-
insertTable: ɵ
|
|
1651
|
-
addColumnBefore: ɵ
|
|
1652
|
-
addColumnAfter: ɵ
|
|
1653
|
-
addRowBefore: ɵ
|
|
1654
|
-
addRowAfter: ɵ
|
|
1655
|
-
deleteRow: ɵ
|
|
1656
|
-
deleteColumn: ɵ
|
|
1657
|
-
mergeCells: ɵ
|
|
1658
|
-
splitCell: ɵ
|
|
1659
|
-
deleteTable: ɵ
|
|
174
|
+
insertTable: ɵ32,
|
|
175
|
+
addColumnBefore: ɵ33,
|
|
176
|
+
addColumnAfter: ɵ34,
|
|
177
|
+
addRowBefore: ɵ35,
|
|
178
|
+
addRowAfter: ɵ36,
|
|
179
|
+
deleteRow: ɵ37,
|
|
180
|
+
deleteColumn: ɵ38,
|
|
181
|
+
mergeCells: ɵ39,
|
|
182
|
+
splitCell: ɵ40,
|
|
183
|
+
deleteTable: ɵ41
|
|
1660
184
|
};
|
|
1661
185
|
/**
|
|
1662
186
|
* @hidden
|
|
@@ -1695,6 +219,10 @@ const getToolbarState = (state, options) => ({
|
|
|
1695
219
|
selected: activeNode(state),
|
|
1696
220
|
disabled: false
|
|
1697
221
|
},
|
|
222
|
+
blockquote: {
|
|
223
|
+
selected: false,
|
|
224
|
+
disabled: !blockquote(state)
|
|
225
|
+
},
|
|
1698
226
|
indent: {
|
|
1699
227
|
selected: false,
|
|
1700
228
|
disabled: !(canIndentAsListItem(state, state.schema.nodes.list_item) || canBeIndented(state, indentRules))
|
|
@@ -1717,7 +245,11 @@ const getToolbarState = (state, options) => ({
|
|
|
1717
245
|
},
|
|
1718
246
|
outdent: {
|
|
1719
247
|
selected: false,
|
|
1720
|
-
disabled
|
|
248
|
+
get disabled() {
|
|
249
|
+
return !(hasNode(state, state.schema.nodes.blockquote) ||
|
|
250
|
+
canOutdentAsListItem(state, outdentRules) ||
|
|
251
|
+
isIndented(state, outdentRules.nodes));
|
|
252
|
+
}
|
|
1721
253
|
},
|
|
1722
254
|
redo: {
|
|
1723
255
|
selected: false,
|
|
@@ -1843,6 +375,7 @@ const initialToolBarState = {
|
|
|
1843
375
|
format: { selected: { text: 'Format', tag: null }, disabled: false },
|
|
1844
376
|
style: { selected: { marks: [], hasNodesWithoutMarks: false }, disabled: false },
|
|
1845
377
|
cleanFormatting: { selected: false, disabled: true },
|
|
378
|
+
blockquote: { selected: false, disabled: false },
|
|
1846
379
|
//indent
|
|
1847
380
|
indent: { selected: false, disabled: false },
|
|
1848
381
|
outdent: { selected: false, disabled: false },
|
|
@@ -1895,6 +428,7 @@ const disabledToolBarState = {
|
|
|
1895
428
|
format: { selected: { text: 'Format', tag: null }, disabled: true },
|
|
1896
429
|
style: { selected: { marks: [], hasNodesWithoutMarks: false }, disabled: true },
|
|
1897
430
|
cleanFormatting: { selected: false, disabled: true },
|
|
431
|
+
blockquote: { selected: false, disabled: true },
|
|
1898
432
|
//indent
|
|
1899
433
|
indent: { selected: false, disabled: true },
|
|
1900
434
|
outdent: { selected: false, disabled: true },
|
|
@@ -1928,6 +462,106 @@ const disabledToolBarState = {
|
|
|
1928
462
|
selectAll: { selected: false, disabled: true }
|
|
1929
463
|
};
|
|
1930
464
|
|
|
465
|
+
/**
|
|
466
|
+
* @hidden
|
|
467
|
+
*/
|
|
468
|
+
function outerWidth(element) {
|
|
469
|
+
let width = element.offsetWidth;
|
|
470
|
+
const style = getComputedStyle(element);
|
|
471
|
+
width += parseFloat(style.marginLeft) || 0 + parseFloat(style.marginRight) || 0;
|
|
472
|
+
return width;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* @hidden
|
|
476
|
+
*/
|
|
477
|
+
const removeEntries = (obj, predicate) => Object.keys(obj)
|
|
478
|
+
.filter(key => predicate(key))
|
|
479
|
+
.reduce((acc, curr) => Object.assign(acc, { [curr]: obj[curr] }), {});
|
|
480
|
+
/**
|
|
481
|
+
* @hidden
|
|
482
|
+
*/
|
|
483
|
+
const removeEmptyEntries = (obj) => {
|
|
484
|
+
const predicate = key => obj[key] !== null && obj[key] !== undefined && obj[key] !== '';
|
|
485
|
+
return removeEntries(obj, predicate);
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* @hidden
|
|
489
|
+
*/
|
|
490
|
+
const isNullOrUndefined = (value) => value === undefined || value === null;
|
|
491
|
+
/**
|
|
492
|
+
* @hidden
|
|
493
|
+
*/
|
|
494
|
+
const isPresent = (value) => !isNullOrUndefined(value);
|
|
495
|
+
/**
|
|
496
|
+
* @hidden
|
|
497
|
+
*/
|
|
498
|
+
const detectIE = () => {
|
|
499
|
+
if (!isDocumentAvailable()) {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
const ua = window.navigator.userAgent;
|
|
503
|
+
const msie = ua.indexOf('MSIE ');
|
|
504
|
+
const trident = ua.indexOf('Trident/');
|
|
505
|
+
return msie > 0 || trident > 0;
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* @hidden
|
|
509
|
+
*/
|
|
510
|
+
const safeString = (value) => (isNullOrUndefined(value) ? '' : value.toString());
|
|
511
|
+
/**
|
|
512
|
+
* @hidden
|
|
513
|
+
*/
|
|
514
|
+
const first = (arr) => arr[0];
|
|
515
|
+
/**
|
|
516
|
+
* @hidden
|
|
517
|
+
*/
|
|
518
|
+
const last = (arr) => arr[arr.length - 1];
|
|
519
|
+
/**
|
|
520
|
+
* @hidden
|
|
521
|
+
*/
|
|
522
|
+
const split = (splitter) => (value) => value.split(splitter);
|
|
523
|
+
/**
|
|
524
|
+
* @hidden
|
|
525
|
+
*/
|
|
526
|
+
const trim = (value) => value.trim();
|
|
527
|
+
/**
|
|
528
|
+
* @hidden
|
|
529
|
+
*/
|
|
530
|
+
const filter$1 = (predicate) => (arr) => arr.filter(predicate);
|
|
531
|
+
/**
|
|
532
|
+
* @hidden
|
|
533
|
+
*/
|
|
534
|
+
const getUniqueStyleValues = (style, cssStyle) => {
|
|
535
|
+
if (style.hasNodesWithoutMarks) {
|
|
536
|
+
return '';
|
|
537
|
+
}
|
|
538
|
+
const uniqueMarkValues = style.marks
|
|
539
|
+
.filter(m => m.type.name === 'style')
|
|
540
|
+
.map(m => m.attrs.style)
|
|
541
|
+
.map(safeString)
|
|
542
|
+
.map(split(';'))
|
|
543
|
+
.map(filter$1((m) => m.includes(cssStyle)))
|
|
544
|
+
// guards against empty array
|
|
545
|
+
.map((cssStyleValues) => (cssStyleValues.length !== 0 ? cssStyleValues : [`${cssStyle}: INVALID`]))
|
|
546
|
+
.map(first)
|
|
547
|
+
.map(split(':'))
|
|
548
|
+
.map(last)
|
|
549
|
+
.map(trim)
|
|
550
|
+
.reduce((acc, curr) => (acc.indexOf(curr) > -1 ? acc : [...acc, curr]), []);
|
|
551
|
+
if (uniqueMarkValues.indexOf('INVALID') > -1 || uniqueMarkValues.length !== 1) {
|
|
552
|
+
return '';
|
|
553
|
+
}
|
|
554
|
+
return uniqueMarkValues[0];
|
|
555
|
+
};
|
|
556
|
+
/**
|
|
557
|
+
* @hidden
|
|
558
|
+
*/
|
|
559
|
+
const conditionallyExecute = (fn) => (condition) => (param) => (condition ? fn(param) : param);
|
|
560
|
+
/**
|
|
561
|
+
* @hidden
|
|
562
|
+
*/
|
|
563
|
+
const pipe = (...fns) => x => fns.reduce((y, f) => f(y), x);
|
|
564
|
+
|
|
1931
565
|
/**
|
|
1932
566
|
* @hidden
|
|
1933
567
|
*/
|
|
@@ -2106,25 +740,25 @@ ImageDialogComponent = __decorate([
|
|
|
2106
740
|
<label [for]="srcInputId">{{ textFor('imageWebAddress') }}</label>
|
|
2107
741
|
</div>
|
|
2108
742
|
<div class="k-edit-field">
|
|
2109
|
-
<input [id]="srcInputId" #srcInput [formControl]="src" type="text" class="k-textbox" />
|
|
743
|
+
<input [id]="srcInputId" #srcInput [formControl]="src" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2110
744
|
</div>
|
|
2111
745
|
<div class="k-edit-label">
|
|
2112
746
|
<label [for]="altTextInputId">{{ textFor('imageAltText') }}</label>
|
|
2113
747
|
</div>
|
|
2114
748
|
<div class="k-edit-field">
|
|
2115
|
-
<input [id]="altTextInputId" [formControl]="alt" type="text" class="k-textbox" />
|
|
749
|
+
<input [id]="altTextInputId" [formControl]="alt" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2116
750
|
</div>
|
|
2117
751
|
<div class="k-edit-label">
|
|
2118
752
|
<label [for]="widthInputId">{{ textFor('imageWidth') }}</label>
|
|
2119
753
|
</div>
|
|
2120
754
|
<div class="k-edit-field">
|
|
2121
|
-
<input [id]="widthInputId" [formControl]="width" type="text" class="k-textbox" />
|
|
755
|
+
<input [id]="widthInputId" [formControl]="width" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2122
756
|
</div>
|
|
2123
757
|
<div class="k-edit-label">
|
|
2124
758
|
<label [for]="heightInputId">{{ textFor('imageHeight') }}</label>
|
|
2125
759
|
</div>
|
|
2126
760
|
<div class="k-edit-field">
|
|
2127
|
-
<input [id]="heightInputId" [formControl]="height" type="text" class="k-textbox" />
|
|
761
|
+
<input [id]="heightInputId" [formControl]="height" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2128
762
|
</div>
|
|
2129
763
|
</div>
|
|
2130
764
|
</div>
|
|
@@ -2254,26 +888,26 @@ FileLinkDialogComponent = __decorate([
|
|
|
2254
888
|
<label (click)="hrefInput.focus()">{{ textForWithPrefix('WebAddress') }}</label>
|
|
2255
889
|
</div>
|
|
2256
890
|
<div class="k-edit-field">
|
|
2257
|
-
<input #hrefInput formControlName="href" type="text" class="k-textbox" />
|
|
891
|
+
<input #hrefInput formControlName="href" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2258
892
|
</div>
|
|
2259
893
|
|
|
2260
894
|
<div class="k-edit-label">
|
|
2261
895
|
<label (click)="textInput.focus()">{{ textForWithPrefix('Text') }}</label>
|
|
2262
896
|
</div>
|
|
2263
897
|
<div class="k-edit-field">
|
|
2264
|
-
<input #textInput formControlName="text" type="text" class="k-textbox" />
|
|
898
|
+
<input #textInput formControlName="text" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2265
899
|
</div>
|
|
2266
900
|
|
|
2267
901
|
<div class="k-edit-label">
|
|
2268
902
|
<label (click)="titleInput.focus()">{{ textForWithPrefix('Title') }}</label>
|
|
2269
903
|
</div>
|
|
2270
904
|
<div class="k-edit-field">
|
|
2271
|
-
<input #titleInput formControlName="title" type="text" class="k-textbox" />
|
|
905
|
+
<input #titleInput formControlName="title" type="text" class="k-textbox k-input k-rounded-md" />
|
|
2272
906
|
</div>
|
|
2273
907
|
<ng-container *ngIf="command === 'createLink'">
|
|
2274
908
|
<div class="k-edit-label"></div>
|
|
2275
909
|
<div class="k-edit-field">
|
|
2276
|
-
<input type="checkbox" id="k-target-blank"
|
|
910
|
+
<input type="checkbox" id="k-target-blank" kendoCheckBox formControlName="target" />
|
|
2277
911
|
<label class="k-checkbox-label" for="k-target-blank">{{ textForWithPrefix('OpenInNewWindow') }}</label>
|
|
2278
912
|
</div>
|
|
2279
913
|
</ng-container>
|
|
@@ -2533,7 +1167,7 @@ const tablesStyles = `
|
|
|
2533
1167
|
*/
|
|
2534
1168
|
const rtlStyles = 'body { direction: rtl }';
|
|
2535
1169
|
|
|
2536
|
-
const ɵ0$
|
|
1170
|
+
const ɵ0$2 = (arg) => `plugins must be a function, but received ${JSON.stringify(arg)}.`, ɵ1$2 = (arg) => `pastedContent must be a function, but received ${JSON.stringify(arg)}.`;
|
|
2537
1171
|
/* tslint:disable:variable-name */
|
|
2538
1172
|
/**
|
|
2539
1173
|
* @hidden
|
|
@@ -2541,9 +1175,10 @@ const ɵ0$6 = (arg) => `plugins must be a function, but received ${JSON.stringif
|
|
|
2541
1175
|
const EditorErrorMessages = {
|
|
2542
1176
|
schemaType: 'Expected value of type Schema. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
2543
1177
|
setSchemaOnce: 'The Schema cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/schema/',
|
|
2544
|
-
pluginsCallbackType: ɵ0$
|
|
1178
|
+
pluginsCallbackType: ɵ0$2,
|
|
1179
|
+
pastedContentCallbackType: ɵ1$2,
|
|
2545
1180
|
setPluginsOnce: 'The plugins cannot be changed dynamically. See http://www.telerik.com/kendo-angular-ui/components/editor/plugins/',
|
|
2546
|
-
setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See
|
|
1181
|
+
setPlaceHolderOnce: 'The placeholder cannot be changed dynamically. See https://www.telerik.com/kendo-angular-ui/components/editor/plugins/#toc-custom-plugins/',
|
|
2547
1182
|
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/'
|
|
2548
1183
|
};
|
|
2549
1184
|
|
|
@@ -2562,16 +1197,32 @@ EditorToolsService = __decorate([
|
|
|
2562
1197
|
Injectable()
|
|
2563
1198
|
], EditorToolsService);
|
|
2564
1199
|
|
|
1200
|
+
/**
|
|
1201
|
+
* The Editor [`paste`]({% slug api_editor_editorcomponent %}#toc-paste) event.
|
|
1202
|
+
*/
|
|
1203
|
+
class EditorPasteEvent extends PreventableEvent {
|
|
1204
|
+
/**
|
|
1205
|
+
* Constructs the event arguments for the `paste` event.
|
|
1206
|
+
* @hidden
|
|
1207
|
+
*/
|
|
1208
|
+
constructor(cleanedHtml, originalHtml, originalEvent) {
|
|
1209
|
+
super();
|
|
1210
|
+
this.cleanedHtml = cleanedHtml;
|
|
1211
|
+
this.originalHtml = originalHtml;
|
|
1212
|
+
this.originalEvent = originalEvent;
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
2565
1216
|
var EditorComponent_1;
|
|
2566
1217
|
const EMPTY_PARAGRAPH = '<p></p>';
|
|
2567
1218
|
const defaultPasteCleanupSettings = {
|
|
2568
1219
|
convertMsLists: false,
|
|
2569
1220
|
removeAttributes: [],
|
|
2570
1221
|
removeHtmlComments: false,
|
|
2571
|
-
removeInvalidHTML:
|
|
1222
|
+
removeInvalidHTML: true,
|
|
2572
1223
|
removeMsClasses: false,
|
|
2573
1224
|
removeMsStyles: false,
|
|
2574
|
-
stripTags: [
|
|
1225
|
+
stripTags: []
|
|
2575
1226
|
};
|
|
2576
1227
|
const removeCommentsIf = conditionallyExecute(removeComments);
|
|
2577
1228
|
const removeInvalidHTMLIf = conditionallyExecute(sanitize);
|
|
@@ -2607,14 +1258,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2607
1258
|
* @default false
|
|
2608
1259
|
*/
|
|
2609
1260
|
this.applyToWord = false;
|
|
2610
|
-
/**
|
|
2611
|
-
* By design, the Editor emits `valueChange`, updates the model and the ToolBar state on each keystroke.
|
|
2612
|
-
* When you are interested in ignoring the new values for a given amout of time and take only the most recent one, you can use the `updateInterval` property.
|
|
2613
|
-
* A possible use case is to get the new values and to update the ToolBar state at a maximum rate per second in order to speed up your application.
|
|
2614
|
-
* The specified interval (in milliseconds) should be a positive number.
|
|
2615
|
-
* By default the `updateInterval` is set to 100 miliseconds. If set to zero the delay will be disabled entirely.
|
|
2616
|
-
*/
|
|
2617
|
-
this.updateInterval = 100;
|
|
2618
1261
|
/**
|
|
2619
1262
|
* By default, whitespace is collapsed as per HTML's rules.
|
|
2620
1263
|
* Set to `true` to preserve whitespace, but normalize newlines to spaces.
|
|
@@ -2640,6 +1283,11 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2640
1283
|
* Fires when the content area of the Editor is focused ([see example]({% slug overview_editor %}#toc-events)).
|
|
2641
1284
|
*/
|
|
2642
1285
|
this.onFocus = new EventEmitter();
|
|
1286
|
+
/**
|
|
1287
|
+
* Fires when the user performs paste in the content area of the Editor ([see example]({% slug overview_editor %}#toc-events)).
|
|
1288
|
+
* The event is preventable. If you cancel it, the Editor content will not change.
|
|
1289
|
+
*/
|
|
1290
|
+
this.paste = new EventEmitter();
|
|
2643
1291
|
/**
|
|
2644
1292
|
* Fires when the content area of the Editor is blurred ([see example]({% slug overview_editor %}#toc-events)).
|
|
2645
1293
|
*/
|
|
@@ -2655,10 +1303,76 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2655
1303
|
this.valueModified = new Subject();
|
|
2656
1304
|
this._readonly = false;
|
|
2657
1305
|
this._placeholder = '';
|
|
1306
|
+
this.inForm = false;
|
|
2658
1307
|
this.afterViewInit = new Subject();
|
|
2659
1308
|
this.contentAreaLoaded = new Subject();
|
|
2660
|
-
this.
|
|
1309
|
+
this.dispatchTransaction = (tr) => {
|
|
1310
|
+
const docChanged = tr.docChanged;
|
|
1311
|
+
if (this.disabled || (this.readonly && docChanged)) {
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (docChanged) {
|
|
1315
|
+
const doc = tr.doc;
|
|
1316
|
+
const html = getHtml({ doc });
|
|
1317
|
+
this.trOnChange = tr;
|
|
1318
|
+
this.htmlOnChange = html;
|
|
1319
|
+
this.ngZone.run(() => {
|
|
1320
|
+
this.valueModified.next(html);
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1323
|
+
if (!docChanged || this.inForm) {
|
|
1324
|
+
this.view.updateState(this.view.state.apply(tr));
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
this.transformPastedHTML = (dirtyHtml) => {
|
|
1328
|
+
const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
|
|
1329
|
+
const html = pipe(removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML), removeCommentsIf(pasteCleanupSettings.removeHtmlComments))(dirtyHtml);
|
|
1330
|
+
const clean = pasteCleanup(html, {
|
|
1331
|
+
convertMsLists: pasteCleanupSettings.convertMsLists,
|
|
1332
|
+
stripTags: pasteCleanupSettings.stripTags.join('|'),
|
|
1333
|
+
attributes: getPasteCleanupAttributes(pasteCleanupSettings)
|
|
1334
|
+
});
|
|
1335
|
+
if (hasObservers(this.paste)) {
|
|
1336
|
+
const event = new EditorPasteEvent(clean, dirtyHtml, this._pasteEvent);
|
|
1337
|
+
this.ngZone.run(() => this.paste.emit(event));
|
|
1338
|
+
return event.isDefaultPrevented() ? '' : event.cleanedHtml;
|
|
1339
|
+
}
|
|
1340
|
+
return clean;
|
|
1341
|
+
};
|
|
1342
|
+
this.changeValue = (value) => {
|
|
1343
|
+
const prev = this._value;
|
|
1344
|
+
this._value = value;
|
|
1345
|
+
if (!this._view) {
|
|
1346
|
+
return;
|
|
1347
|
+
}
|
|
1348
|
+
if (this.htmlOnChange === value && this.trOnChange) {
|
|
1349
|
+
this.view.updateState(this.view.state.apply(this.trOnChange));
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
if ((prev || '') !== (value || '')) {
|
|
1353
|
+
const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
|
|
1354
|
+
if (iframeContentWindowNotPresent) {
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
const state = this.view.state;
|
|
1358
|
+
const nextDoc = parseContent(value || '', state.schema, { preserveWhitespace: this.preserveWhitespace });
|
|
1359
|
+
const tr = state.tr
|
|
1360
|
+
.setSelection(new AllSelection(state.doc))
|
|
1361
|
+
.replaceSelectionWith(nextDoc);
|
|
1362
|
+
this.view.updateState(state.apply(tr));
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
this.trOnChange = null;
|
|
1366
|
+
this.htmlOnChange = null;
|
|
1367
|
+
};
|
|
1368
|
+
this.onChangeCallback = (value) => {
|
|
1369
|
+
this.changeValue(value);
|
|
1370
|
+
};
|
|
2661
1371
|
this.onTouchedCallback = (_) => { }; // tslint:disable-line:no-empty
|
|
1372
|
+
this.onPaste = (_view, nativeEvent) => {
|
|
1373
|
+
this._pasteEvent = nativeEvent;
|
|
1374
|
+
return false;
|
|
1375
|
+
};
|
|
2662
1376
|
validatePackage(packageMetadata);
|
|
2663
1377
|
this.direction = localization.rtl ? 'rtl' : 'ltr';
|
|
2664
1378
|
// https://stackoverflow.com/questions/56572483/chrome-is-synchronously-handling-iframe-loading-whereas-firefox-handles-it-asyn
|
|
@@ -2668,25 +1382,12 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2668
1382
|
* Sets the value of the Editor ([see example]({% slug overview_editor %}#toc-basic-usage)).
|
|
2669
1383
|
*/
|
|
2670
1384
|
set value(value) {
|
|
2671
|
-
|
|
2672
|
-
return;
|
|
2673
|
-
}
|
|
2674
|
-
this._value = value;
|
|
2675
|
-
this._previousValue = value;
|
|
2676
|
-
if (this._view) {
|
|
2677
|
-
const iframeContentWindowNotPresent = this.iframe && !this.container.element.nativeElement.contentWindow;
|
|
2678
|
-
if (iframeContentWindowNotPresent) {
|
|
2679
|
-
return;
|
|
2680
|
-
}
|
|
2681
|
-
this.exec('setHTML', {
|
|
2682
|
-
content: this._value || '',
|
|
2683
|
-
parseOptions: {
|
|
2684
|
-
preserveWhitespace: this.preserveWhitespace
|
|
2685
|
-
}
|
|
2686
|
-
});
|
|
2687
|
-
}
|
|
1385
|
+
this.changeValue(value);
|
|
2688
1386
|
}
|
|
2689
1387
|
get value() {
|
|
1388
|
+
if (this.trOnChange) {
|
|
1389
|
+
return this.htmlOnChange;
|
|
1390
|
+
}
|
|
2690
1391
|
let value = this._view ? this.getSource() : this._value;
|
|
2691
1392
|
if (value === EMPTY_PARAGRAPH) {
|
|
2692
1393
|
return this._value ? '' : this._value;
|
|
@@ -2876,6 +1577,9 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2876
1577
|
}
|
|
2877
1578
|
}
|
|
2878
1579
|
ngOnChanges(changes) {
|
|
1580
|
+
if (changes.value && this.view) {
|
|
1581
|
+
this.changeValue(changes.value.currentValue);
|
|
1582
|
+
}
|
|
2879
1583
|
if (changes.iframe && !changes.iframe.isFirstChange()) {
|
|
2880
1584
|
this.ngZone.onStable.pipe(take(1)).subscribe(() => this.initialize());
|
|
2881
1585
|
}
|
|
@@ -2903,7 +1607,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2903
1607
|
* @param {any} attr - Optional parameters for the command. Apart from the following list,
|
|
2904
1608
|
* the parameters do not expect specific attributes when you call them:
|
|
2905
1609
|
* - `format` - Accepts an object with the `tag` property.
|
|
2906
|
-
* The supported tags are `p
|
|
1610
|
+
* The supported tags are `p` and any of the `h1` to `h6` heading tags.
|
|
2907
1611
|
* - `createLink` - Accepts an object with the `href`, `title`, and `target` properties. The `href` property is mandatory.
|
|
2908
1612
|
* - `setHTML` - Accepts a `string` parameter.
|
|
2909
1613
|
* - `insertTable` - Accepts an object with the `rows` and `cols` properties. The number values are zero based.
|
|
@@ -2961,8 +1665,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
2961
1665
|
const command = editorCommands[commandName](attr);
|
|
2962
1666
|
// Executes a ProseMirror command.
|
|
2963
1667
|
command(this._view.state, this._view.dispatch, this._view);
|
|
2964
|
-
// See the `dispatchTransaction` comments.
|
|
2965
|
-
// this.stateChange.emit(updateToolBar(this.view));
|
|
2966
1668
|
}
|
|
2967
1669
|
/**
|
|
2968
1670
|
* Opens a dialog.
|
|
@@ -3047,6 +1749,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3047
1749
|
* @hidden
|
|
3048
1750
|
*/
|
|
3049
1751
|
writeValue(value) {
|
|
1752
|
+
this.inForm = true;
|
|
3050
1753
|
// To avoid confusion, non-existent values are always undefined.
|
|
3051
1754
|
this.value = value === null ? undefined : value;
|
|
3052
1755
|
}
|
|
@@ -3074,7 +1777,6 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3074
1777
|
return;
|
|
3075
1778
|
}
|
|
3076
1779
|
const currentSchema = this.schema || schema;
|
|
3077
|
-
const that = this;
|
|
3078
1780
|
const containerNativeElement = this.container.element.nativeElement;
|
|
3079
1781
|
const contentNode = parseContent((this.value || '').trim(), currentSchema, { preserveWhitespace: this.preserveWhitespace });
|
|
3080
1782
|
if (this.iframe) {
|
|
@@ -3116,16 +1818,13 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3116
1818
|
}
|
|
3117
1819
|
})
|
|
3118
1820
|
}),
|
|
3119
|
-
new Plugin({
|
|
3120
|
-
key: new PluginKey('editor-filter-disabled-state'),
|
|
3121
|
-
filterTransaction: () => !this.disabled
|
|
3122
|
-
}),
|
|
3123
1821
|
history(),
|
|
3124
1822
|
keymap(buildListKeymap(currentSchema)),
|
|
3125
1823
|
keymap(buildKeymap(currentSchema, { applyToWord: this.applyToWord })),
|
|
3126
1824
|
keymap(baseKeymap),
|
|
3127
1825
|
gapCursor(),
|
|
3128
|
-
imageResizing()
|
|
1826
|
+
imageResizing(),
|
|
1827
|
+
tableEditing()
|
|
3129
1828
|
];
|
|
3130
1829
|
if (this.placeholder) {
|
|
3131
1830
|
defaultPlugins.push(placeholder(this.placeholder));
|
|
@@ -3145,31 +1844,10 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3145
1844
|
this._view = new EditorView({ mount: this.viewMountElement }, {
|
|
3146
1845
|
state,
|
|
3147
1846
|
editable: () => !this.readonly,
|
|
3148
|
-
dispatchTransaction:
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
// When the user utilizes keyboard shortcuts—for example, `Ctrl`+`b`—
|
|
3153
|
-
// `tr.docChanged` is `true` and the toolbar is not updated.
|
|
3154
|
-
// A possible future solution is to move the keymaps to the service.
|
|
3155
|
-
// if (!tr.docChanged) {
|
|
3156
|
-
// that.stateChange.emit(updateToolBar(that.view));
|
|
3157
|
-
// }
|
|
3158
|
-
const value = that.value;
|
|
3159
|
-
if (!hasSameMarkup(value, that._previousValue, this.state.schema)) {
|
|
3160
|
-
that._previousValue = value;
|
|
3161
|
-
that.ngZone.run(() => that.valueModified.next(value));
|
|
3162
|
-
}
|
|
3163
|
-
},
|
|
3164
|
-
transformPastedHTML: (html) => {
|
|
3165
|
-
const pasteCleanupSettings = Object.assign({}, defaultPasteCleanupSettings, this.pasteCleanupSettings);
|
|
3166
|
-
const clean = pipe(removeCommentsIf(pasteCleanupSettings.removeHtmlComments), removeInvalidHTMLIf(pasteCleanupSettings.removeInvalidHTML))(html);
|
|
3167
|
-
const attributes = getPasteCleanupAttributes(pasteCleanupSettings);
|
|
3168
|
-
return pasteCleanup(clean, {
|
|
3169
|
-
convertMsLists: pasteCleanupSettings.convertMsLists,
|
|
3170
|
-
stripTags: pasteCleanupSettings.stripTags.join('|'),
|
|
3171
|
-
attributes
|
|
3172
|
-
});
|
|
1847
|
+
dispatchTransaction: this.dispatchTransaction,
|
|
1848
|
+
transformPastedHTML: this.transformPastedHTML,
|
|
1849
|
+
handleDOMEvents: {
|
|
1850
|
+
paste: this.onPaste
|
|
3173
1851
|
}
|
|
3174
1852
|
});
|
|
3175
1853
|
});
|
|
@@ -3185,7 +1863,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3185
1863
|
this.subs.add(fromEvent(containerElement, 'focusin')
|
|
3186
1864
|
.subscribe(() => {
|
|
3187
1865
|
if (this.readonly) {
|
|
3188
|
-
contentAreaClasslist.add('k-
|
|
1866
|
+
contentAreaClasslist.add('k-focus');
|
|
3189
1867
|
}
|
|
3190
1868
|
if (!this.focusChangedProgrammatically || this.shouldEmitFocus) {
|
|
3191
1869
|
this.ngZone.run(() => this.onFocus.emit());
|
|
@@ -3195,7 +1873,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3195
1873
|
this.subs.add(fromEvent(containerElement, 'focusout')
|
|
3196
1874
|
.subscribe(() => {
|
|
3197
1875
|
if (this.readonly) {
|
|
3198
|
-
contentAreaClasslist.remove('k-
|
|
1876
|
+
contentAreaClasslist.remove('k-focus');
|
|
3199
1877
|
}
|
|
3200
1878
|
if (!this.focusChangedProgrammatically) {
|
|
3201
1879
|
this.ngZone.run(() => this.onBlur.emit());
|
|
@@ -3210,7 +1888,7 @@ let EditorComponent = EditorComponent_1 = class EditorComponent {
|
|
|
3210
1888
|
this.cdr.detectChanges();
|
|
3211
1889
|
}
|
|
3212
1890
|
}));
|
|
3213
|
-
this.subs.add(
|
|
1891
|
+
this.subs.add(this.valueModified.subscribe((value) => {
|
|
3214
1892
|
this.onChangeCallback(value);
|
|
3215
1893
|
this.valueChange.emit(value);
|
|
3216
1894
|
this.cdr.markForCheck();
|
|
@@ -3303,10 +1981,6 @@ __decorate([
|
|
|
3303
1981
|
__metadata("design:type", String),
|
|
3304
1982
|
__metadata("design:paramtypes", [String])
|
|
3305
1983
|
], EditorComponent.prototype, "placeholder", null);
|
|
3306
|
-
__decorate([
|
|
3307
|
-
Input(),
|
|
3308
|
-
__metadata("design:type", Number)
|
|
3309
|
-
], EditorComponent.prototype, "updateInterval", void 0);
|
|
3310
1984
|
__decorate([
|
|
3311
1985
|
Input(),
|
|
3312
1986
|
__metadata("design:type", Object)
|
|
@@ -3327,6 +2001,10 @@ __decorate([
|
|
|
3327
2001
|
Output('focus'),
|
|
3328
2002
|
__metadata("design:type", EventEmitter)
|
|
3329
2003
|
], EditorComponent.prototype, "onFocus", void 0);
|
|
2004
|
+
__decorate([
|
|
2005
|
+
Output(),
|
|
2006
|
+
__metadata("design:type", EventEmitter)
|
|
2007
|
+
], EditorComponent.prototype, "paste", void 0);
|
|
3330
2008
|
__decorate([
|
|
3331
2009
|
Output('blur'),
|
|
3332
2010
|
__metadata("design:type", EventEmitter)
|
|
@@ -3341,7 +2019,7 @@ __decorate([
|
|
|
3341
2019
|
__metadata("design:paramtypes", [])
|
|
3342
2020
|
], EditorComponent.prototype, "resizableClass", null);
|
|
3343
2021
|
__decorate([
|
|
3344
|
-
HostBinding('class.k-
|
|
2022
|
+
HostBinding('class.k-disabled'),
|
|
3345
2023
|
__metadata("design:type", Boolean),
|
|
3346
2024
|
__metadata("design:paramtypes", [])
|
|
3347
2025
|
], EditorComponent.prototype, "isDisabled", null);
|
|
@@ -3447,6 +2125,8 @@ EditorComponent = EditorComponent_1 = __decorate([
|
|
|
3447
2125
|
alignRight="Align text right"
|
|
3448
2126
|
i18n-backColor="kendo.editor.backColor|The title of the tool that changes the text background color."
|
|
3449
2127
|
backColor="Background color"
|
|
2128
|
+
i18n-blockquote="kendo.editor.blockquote|The title of the tool that wraps an element in a blockquote"
|
|
2129
|
+
blockquote="Quotation"
|
|
3450
2130
|
i18n-bold="kendo.editor.bold|The title of the tool that makes text bold."
|
|
3451
2131
|
bold="Bold"
|
|
3452
2132
|
i18n-cleanFormatting="kendo.editor.cleanFormatting|The title of the Clean Formatting tool."
|
|
@@ -3574,7 +2254,7 @@ EditorComponent = EditorComponent_1 = __decorate([
|
|
|
3574
2254
|
<div *ngIf="!iframe" #content [attr.dir]="direction" class="k-editor-content"></div>
|
|
3575
2255
|
|
|
3576
2256
|
<div class="k-editor-content" *ngIf="iframe">
|
|
3577
|
-
<iframe #content frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
|
|
2257
|
+
<iframe #content srcdoc="<!DOCTYPE html>" frameborder="0" class="k-iframe" (load)="iframeOnLoad()"></iframe>
|
|
3578
2258
|
</div>
|
|
3579
2259
|
|
|
3580
2260
|
<ng-container #dialogsContainer></ng-container>
|
|
@@ -3712,10 +2392,6 @@ FormatDropDownListComponent = __decorate([
|
|
|
3712
2392
|
{{ dataItem.text }}
|
|
3713
2393
|
</span>
|
|
3714
2394
|
|
|
3715
|
-
<span *ngSwitchCase="'blockquote'" style="display: block; margin-left: 0;">
|
|
3716
|
-
{{ dataItem.text }}
|
|
3717
|
-
</span>
|
|
3718
|
-
|
|
3719
2395
|
<span *ngSwitchDefault>{{ dataItem.text }}</span>
|
|
3720
2396
|
</ng-container>
|
|
3721
2397
|
</ng-template>
|
|
@@ -3856,7 +2532,7 @@ ColorPickerDialogComponent = __decorate([
|
|
|
3856
2532
|
<div class="k-edit-form-container k-window-content" style="text-align: center;">
|
|
3857
2533
|
<kendo-colorpicker
|
|
3858
2534
|
#colorpicker
|
|
3859
|
-
[
|
|
2535
|
+
[views]="['palette']"
|
|
3860
2536
|
[format]="'hex'"
|
|
3861
2537
|
[attr.title]="title"
|
|
3862
2538
|
[icon]="icon"
|
|
@@ -4118,7 +2794,6 @@ let EditorFormatComponent = EditorFormatComponent_1 = class EditorFormatComponen
|
|
|
4118
2794
|
this.valueChange = new EventEmitter();
|
|
4119
2795
|
this._data = [
|
|
4120
2796
|
{ text: 'Paragraph', tag: 'p' },
|
|
4121
|
-
{ text: 'Quotation', tag: 'blockquote' },
|
|
4122
2797
|
{ text: 'Heading 1', tag: 'h1' },
|
|
4123
2798
|
{ text: 'Heading 2', tag: 'h2' },
|
|
4124
2799
|
{ text: 'Heading 3', tag: 'h3' },
|
|
@@ -4884,11 +3559,19 @@ let EditorColorPickerComponent = EditorColorPickerComponent_1 = class EditorColo
|
|
|
4884
3559
|
*/
|
|
4885
3560
|
this.disabled = false;
|
|
4886
3561
|
/**
|
|
4887
|
-
* Specifies whether the ColorPicker will render a gradient, palette or
|
|
3562
|
+
* Specifies whether the ColorPicker will render a gradient, palette, or both in its popup.
|
|
4888
3563
|
*
|
|
4889
|
-
* @default 'palette'
|
|
3564
|
+
* @default ['palette']
|
|
4890
3565
|
*/
|
|
4891
|
-
this.
|
|
3566
|
+
this.views = ['palette'];
|
|
3567
|
+
}
|
|
3568
|
+
/**
|
|
3569
|
+
* @hidden
|
|
3570
|
+
*
|
|
3571
|
+
* For backward compatibility with configurations using the deprecated "view" input.
|
|
3572
|
+
*/
|
|
3573
|
+
set view(view) {
|
|
3574
|
+
this.views = [view];
|
|
4892
3575
|
}
|
|
4893
3576
|
/**
|
|
4894
3577
|
* @hidden
|
|
@@ -4960,7 +3643,7 @@ let EditorColorPickerComponent = EditorColorPickerComponent_1 = class EditorColo
|
|
|
4960
3643
|
editorCommand: this.editorCommand,
|
|
4961
3644
|
paletteSettings: this.paletteSettings,
|
|
4962
3645
|
icon: this.icon,
|
|
4963
|
-
|
|
3646
|
+
views: this.views
|
|
4964
3647
|
});
|
|
4965
3648
|
}
|
|
4966
3649
|
/**
|
|
@@ -5011,8 +3694,13 @@ __decorate([
|
|
|
5011
3694
|
], EditorColorPickerComponent.prototype, "disabled", void 0);
|
|
5012
3695
|
__decorate([
|
|
5013
3696
|
Input(),
|
|
5014
|
-
__metadata("design:type",
|
|
5015
|
-
], EditorColorPickerComponent.prototype, "
|
|
3697
|
+
__metadata("design:type", Array)
|
|
3698
|
+
], EditorColorPickerComponent.prototype, "views", void 0);
|
|
3699
|
+
__decorate([
|
|
3700
|
+
Input(),
|
|
3701
|
+
__metadata("design:type", String),
|
|
3702
|
+
__metadata("design:paramtypes", [String])
|
|
3703
|
+
], EditorColorPickerComponent.prototype, "view", null);
|
|
5016
3704
|
__decorate([
|
|
5017
3705
|
ViewChild('toolbarTemplate', { static: true }),
|
|
5018
3706
|
__metadata("design:type", TemplateRef)
|
|
@@ -5041,7 +3729,7 @@ EditorColorPickerComponent = EditorColorPickerComponent_1 = __decorate([
|
|
|
5041
3729
|
<ng-template #toolbarTemplate>
|
|
5042
3730
|
<kendo-colorpicker
|
|
5043
3731
|
#colorpicker
|
|
5044
|
-
[
|
|
3732
|
+
[views]="['palette']"
|
|
5045
3733
|
[format]="'hex'"
|
|
5046
3734
|
[attr.title]="title"
|
|
5047
3735
|
[icon]="icon"
|
|
@@ -5340,8 +4028,8 @@ PopupTableGridComponent = __decorate([
|
|
|
5340
4028
|
<div style="border-color: inherit;" (mouseleave)="resetState()" (click)="insertTable()">
|
|
5341
4029
|
<span *ngFor="let i of cells"
|
|
5342
4030
|
class="k-ct-cell"
|
|
5343
|
-
[class.k-
|
|
5344
|
-
[class.k-
|
|
4031
|
+
[class.k-selected]="selected(i)"
|
|
4032
|
+
[class.k-disabled]="!selected(i)"
|
|
5345
4033
|
(mouseenter)="setState(i)">
|
|
5346
4034
|
</span>
|
|
5347
4035
|
</div>
|
|
@@ -5364,6 +4052,7 @@ const commandIcons = {
|
|
|
5364
4052
|
alignLeft: 'align-left',
|
|
5365
4053
|
alignRight: 'align-right',
|
|
5366
4054
|
backColor: 'background',
|
|
4055
|
+
blockquote: 'blockquote',
|
|
5367
4056
|
bold: 'bold',
|
|
5368
4057
|
cleanFormatting: 'clear-css',
|
|
5369
4058
|
createLink: 'link-horizontal',
|
|
@@ -5602,6 +4291,40 @@ EditorAlignJustifyButtonDirective = __decorate([
|
|
|
5602
4291
|
EditorToolsService])
|
|
5603
4292
|
], EditorAlignJustifyButtonDirective);
|
|
5604
4293
|
|
|
4294
|
+
/**
|
|
4295
|
+
* A directive which configures an existing `ToolBarButtonComponent` as an Editor Blockquote tool
|
|
4296
|
+
* ([see example]({% slug toolbartools_editor %}#toc-built-in-tools)).
|
|
4297
|
+
* The directive will predefine the `icon` and `click` event handlers of the button.
|
|
4298
|
+
*
|
|
4299
|
+
* @example
|
|
4300
|
+
* ```ts-no-run
|
|
4301
|
+
* <kendo-toolbar-button kendoEditorBlockquoteButton></kendo-toolbar-button>
|
|
4302
|
+
* ```
|
|
4303
|
+
*
|
|
4304
|
+
* The following example demonstrates how to change the default icon that is applied by the directive.
|
|
4305
|
+
*
|
|
4306
|
+
* @example
|
|
4307
|
+
* ```ts-no-run
|
|
4308
|
+
* <kendo-toolbar-button kendoEditorBlockquoteButton icon="blogger"></kendo-toolbar-button>
|
|
4309
|
+
* ```
|
|
4310
|
+
*/
|
|
4311
|
+
let EditorBlockquoteDirective = class EditorBlockquoteDirective extends EditorCommandButton {
|
|
4312
|
+
constructor(button, editor, localization, toolsService) {
|
|
4313
|
+
super('blockquote', button, editor, localization, toolsService);
|
|
4314
|
+
this.editor = editor;
|
|
4315
|
+
}
|
|
4316
|
+
};
|
|
4317
|
+
EditorBlockquoteDirective = __decorate([
|
|
4318
|
+
Directive({
|
|
4319
|
+
selector: 'kendo-toolbar-button[kendoEditorBlockquoteButton]'
|
|
4320
|
+
}),
|
|
4321
|
+
__param(1, Host()),
|
|
4322
|
+
__metadata("design:paramtypes", [ToolBarButtonComponent,
|
|
4323
|
+
EditorComponent,
|
|
4324
|
+
EditorLocalizationService,
|
|
4325
|
+
EditorToolsService])
|
|
4326
|
+
], EditorBlockquoteDirective);
|
|
4327
|
+
|
|
5605
4328
|
/**
|
|
5606
4329
|
* A directive which configures an existing `ToolBarButtonComponent` as an Editor Redo tool
|
|
5607
4330
|
* ([see example]({% slug toolbartools_editor %}#toc-built-in-tools)).
|
|
@@ -6534,6 +5257,10 @@ __decorate([
|
|
|
6534
5257
|
Input(),
|
|
6535
5258
|
__metadata("design:type", String)
|
|
6536
5259
|
], Messages.prototype, "backColor", void 0);
|
|
5260
|
+
__decorate([
|
|
5261
|
+
Input(),
|
|
5262
|
+
__metadata("design:type", String)
|
|
5263
|
+
], Messages.prototype, "blockquote", void 0);
|
|
6537
5264
|
__decorate([
|
|
6538
5265
|
Input(),
|
|
6539
5266
|
__metadata("design:type", String)
|
|
@@ -6948,7 +5675,9 @@ const COMPONENT_DIRECTIVES = [
|
|
|
6948
5675
|
// print
|
|
6949
5676
|
EditorPrintDirective,
|
|
6950
5677
|
// select all
|
|
6951
|
-
EditorSelectAllButtonDirective
|
|
5678
|
+
EditorSelectAllButtonDirective,
|
|
5679
|
+
// blockquote
|
|
5680
|
+
EditorBlockquoteDirective
|
|
6952
5681
|
];
|
|
6953
5682
|
const TOOLBAR_TOOLS = [
|
|
6954
5683
|
EditorFontSizeComponent,
|
|
@@ -7052,6 +5781,7 @@ EditorModule = __decorate([
|
|
|
7052
5781
|
DialogModule,
|
|
7053
5782
|
DropDownsModule,
|
|
7054
5783
|
NumericTextBoxModule,
|
|
5784
|
+
CheckBoxModule,
|
|
7055
5785
|
ToolBarModule,
|
|
7056
5786
|
TextBoxModule
|
|
7057
5787
|
]
|
|
@@ -7062,4 +5792,4 @@ EditorModule = __decorate([
|
|
|
7062
5792
|
* Generated bundle index. Do not edit.
|
|
7063
5793
|
*/
|
|
7064
5794
|
|
|
7065
|
-
export { ColorPickerDialogComponent, FileLinkDialogComponent, FontFamilyDialogComponent, FontSizeDialogComponent, FormatDialogComponent, ImageDialogComponent, InsertTableDialogComponent, SourceDialogComponent, CustomMessagesComponent, EditorLocalizationService, LocalizedMessagesDirective, Messages, EditorAlignCenterButtonDirective, EditorAlignJustifyButtonDirective, EditorAlignLeftButtonDirective, EditorAlignRightButtonDirective, EditorBackColorDirective, EditorColorPickerComponent, EditorForeColorDirective, EditorCleanFormattingButtonDirective, FontFamilyDropDownListComponent, EditorFontFamilyComponent, FontSizeDropDownListComponent, EditorFontSizeComponent, FormatDropDownListComponent, EditorFormatComponent, EditorRedoButtonDirective, EditorUndoButtonDirective, EditorInsertImageButtonDirective, EditorIndentButtonDirective, EditorOutdentButtonDirective, EditorCreateLinkButtonDirective, EditorInsertFileButtonDirective, EditorUnlinkButtonDirective, EditorInsertOrderedListButtonDirective, EditorInsertUnorderedListButtonDirective, EditorPrintDirective, EditorSelectAllButtonDirective, DropDownToolDirective, EditorCommandBase, EditorCommandButton, EditorCommandDialog, EditorViewSourceButtonDirective, EditorAddColumnAfterButtonDirective, EditorAddColumnBeforeButtonDirective, EditorAddRowAfterButtonDirective, EditorAddRowBeforeButtonDirective, EditorDeleteColumnButtonDirective, EditorDeleteRowButtonDirective, EditorDeleteTableButtonDirective, EditorInsertTableButtonComponent, EditorMergeCellsButtonDirective, EditorSplitCellButtonDirective, PopupTableGridComponent, EditorToolsService, EditorBoldButtonDirective, EditorItalicButtonDirective, EditorStrikethroughButtonDirective, EditorSubscriptButtonDirective, EditorSuperscriptButtonDirective, EditorUnderlineButtonDirective, EditorComponent, EditorModule, schema };
|
|
5795
|
+
export { semanticNodes, semanticTagNames, ColorPickerDialogComponent, FileLinkDialogComponent, FontFamilyDialogComponent, FontSizeDialogComponent, FormatDialogComponent, ImageDialogComponent, InsertTableDialogComponent, SourceDialogComponent, CustomMessagesComponent, EditorLocalizationService, LocalizedMessagesDirective, Messages, EditorAlignCenterButtonDirective, EditorAlignJustifyButtonDirective, EditorAlignLeftButtonDirective, EditorAlignRightButtonDirective, EditorBlockquoteDirective, EditorBackColorDirective, EditorColorPickerComponent, EditorForeColorDirective, EditorCleanFormattingButtonDirective, FontFamilyDropDownListComponent, EditorFontFamilyComponent, FontSizeDropDownListComponent, EditorFontSizeComponent, FormatDropDownListComponent, EditorFormatComponent, EditorRedoButtonDirective, EditorUndoButtonDirective, EditorInsertImageButtonDirective, EditorIndentButtonDirective, EditorOutdentButtonDirective, EditorCreateLinkButtonDirective, EditorInsertFileButtonDirective, EditorUnlinkButtonDirective, EditorInsertOrderedListButtonDirective, EditorInsertUnorderedListButtonDirective, EditorPrintDirective, EditorSelectAllButtonDirective, DropDownToolDirective, EditorCommandBase, EditorCommandButton, EditorCommandDialog, EditorViewSourceButtonDirective, EditorAddColumnAfterButtonDirective, EditorAddColumnBeforeButtonDirective, EditorAddRowAfterButtonDirective, EditorAddRowBeforeButtonDirective, EditorDeleteColumnButtonDirective, EditorDeleteRowButtonDirective, EditorDeleteTableButtonDirective, EditorInsertTableButtonComponent, EditorMergeCellsButtonDirective, EditorSplitCellButtonDirective, PopupTableGridComponent, EditorToolsService, EditorBoldButtonDirective, EditorItalicButtonDirective, EditorStrikethroughButtonDirective, EditorSubscriptButtonDirective, EditorSuperscriptButtonDirective, EditorUnderlineButtonDirective, EditorComponent, EditorModule, schema, EditorPasteEvent };
|