@progress/kendo-angular-editor 2.5.0-dev.202111291334 → 3.0.0-dev.202201121158

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