@progress/kendo-editor-common 1.12.2-develop.4 → 1.12.2-develop.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/cdn/js/kendo-editor-common.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/DOMSerializer.js +6 -7
  4. package/dist/es/align.js +3 -6
  5. package/dist/es/blockNode.js +11 -14
  6. package/dist/es/blockquote.js +2 -5
  7. package/dist/es/cleanFormatting.js +3 -6
  8. package/dist/es/config/align-rules.js +5 -7
  9. package/dist/es/config/commands.js +13 -9
  10. package/dist/es/config/constants.js +7 -9
  11. package/dist/es/config/indent-rules.js +3 -6
  12. package/dist/es/config/keymap.js +7 -10
  13. package/dist/es/config/list-settings.js +3 -5
  14. package/dist/es/config/schema.js +4 -6
  15. package/dist/es/find-replace.js +8 -10
  16. package/dist/es/flatten-spans.js +2 -5
  17. package/dist/es/image.js +2 -5
  18. package/dist/es/indent.js +11 -14
  19. package/dist/es/inline-style.js +10 -12
  20. package/dist/es/link.js +5 -8
  21. package/dist/es/listConvert.js +8 -9
  22. package/dist/es/lists.js +12 -15
  23. package/dist/es/main.js +34 -33
  24. package/dist/es/mark.js +16 -17
  25. package/dist/es/paste.js +10 -13
  26. package/dist/es/plugins/caret-color.js +5 -8
  27. package/dist/es/plugins/csp-fix.js +2 -5
  28. package/dist/es/plugins/highlight.js +3 -6
  29. package/dist/es/plugins/image-resize.js +8 -11
  30. package/dist/es/plugins/list-markers-styles.js +2 -5
  31. package/dist/es/plugins/placeholder.js +2 -5
  32. package/dist/es/plugins/resize-utils.js +2 -4
  33. package/dist/es/plugins/spaces-fix.js +1 -4
  34. package/dist/es/plugins/table-resize/column-resize.js +21 -24
  35. package/dist/es/plugins/table-resize/index.js +6 -9
  36. package/dist/es/plugins/table-resize/row-resize.js +23 -24
  37. package/dist/es/plugins/table-resize/table-resize.js +17 -20
  38. package/dist/es/plugins/table-resize/table-view.js +6 -9
  39. package/dist/es/plugins/table-resize/utils.js +10 -13
  40. package/dist/es/source.js +15 -18
  41. package/dist/es/table.js +15 -18
  42. package/dist/es/text.js +1 -3
  43. package/dist/es/types/active-marks.js +1 -0
  44. package/dist/es/types/command.js +1 -0
  45. package/dist/es/types/dispatchFn.js +1 -0
  46. package/dist/es/types/paste-cleanup-settings.js +1 -0
  47. package/dist/es/types/predicate.js +1 -0
  48. package/dist/es/utils.js +18 -21
  49. package/dist/npm/DOMSerializer.d.ts +35 -0
  50. package/dist/npm/DOMSerializer.js +10 -9
  51. package/dist/npm/align.d.ts +4 -7
  52. package/dist/npm/align.js +9 -10
  53. package/dist/npm/blockNode.d.ts +15 -12
  54. package/dist/npm/blockNode.js +28 -29
  55. package/dist/npm/blockquote.d.ts +2 -5
  56. package/dist/npm/blockquote.js +6 -7
  57. package/dist/npm/cleanFormatting.d.ts +3 -6
  58. package/dist/npm/cleanFormatting.js +7 -8
  59. package/dist/npm/config/align-rules.d.ts +6 -8
  60. package/dist/npm/config/align-rules.js +8 -13
  61. package/dist/npm/config/commands.d.ts +19 -11
  62. package/dist/npm/config/commands.js +16 -17
  63. package/dist/npm/config/constants.d.ts +7 -0
  64. package/dist/npm/config/constants.js +10 -17
  65. package/dist/npm/config/indent-rules.d.ts +4 -6
  66. package/dist/npm/config/indent-rules.js +8 -11
  67. package/dist/npm/config/keymap.d.ts +2 -5
  68. package/dist/npm/config/keymap.js +21 -22
  69. package/dist/npm/config/list-settings.d.ts +30 -0
  70. package/dist/npm/config/list-settings.js +10 -13
  71. package/dist/npm/config/schema.d.ts +2 -3
  72. package/dist/npm/config/schema.js +19 -20
  73. package/dist/npm/find-replace.d.ts +7 -10
  74. package/dist/npm/find-replace.js +20 -20
  75. package/dist/npm/flatten-spans.d.ts +1 -3
  76. package/dist/npm/flatten-spans.js +6 -7
  77. package/dist/npm/image.d.ts +3 -6
  78. package/dist/npm/image.js +5 -6
  79. package/dist/npm/indent.d.ts +9 -12
  80. package/dist/npm/indent.js +37 -38
  81. package/dist/npm/inline-style.d.ts +4 -7
  82. package/dist/npm/inline-style.js +28 -28
  83. package/dist/npm/link.d.ts +2 -4
  84. package/dist/npm/link.js +21 -22
  85. package/dist/npm/listConvert.d.ts +1 -3
  86. package/dist/npm/listConvert.js +13 -12
  87. package/dist/npm/lists.d.ts +8 -8
  88. package/dist/npm/lists.js +26 -27
  89. package/dist/npm/main.d.ts +34 -35
  90. package/dist/npm/main.js +214 -391
  91. package/dist/npm/mark.d.ts +17 -12
  92. package/dist/npm/mark.js +30 -29
  93. package/dist/npm/paste.d.ts +8 -11
  94. package/dist/npm/paste.js +19 -20
  95. package/dist/npm/plugins/caret-color.d.ts +2 -5
  96. package/dist/npm/plugins/caret-color.js +15 -17
  97. package/dist/npm/plugins/csp-fix.d.ts +1 -4
  98. package/dist/npm/plugins/csp-fix.js +8 -9
  99. package/dist/npm/plugins/highlight.d.ts +4 -7
  100. package/dist/npm/plugins/highlight.js +11 -13
  101. package/dist/npm/plugins/image-resize.d.ts +5 -7
  102. package/dist/npm/plugins/image-resize.js +35 -37
  103. package/dist/npm/plugins/list-markers-styles.d.ts +2 -5
  104. package/dist/npm/plugins/list-markers-styles.js +14 -16
  105. package/dist/npm/plugins/placeholder.d.ts +1 -4
  106. package/dist/npm/plugins/placeholder.js +10 -12
  107. package/dist/npm/plugins/resize-utils.d.ts +35 -0
  108. package/dist/npm/plugins/resize-utils.js +5 -7
  109. package/dist/npm/plugins/spaces-fix.d.ts +1 -4
  110. package/dist/npm/plugins/spaces-fix.js +9 -10
  111. package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
  112. package/dist/npm/plugins/table-resize/column-resize.js +44 -46
  113. package/dist/npm/plugins/table-resize/index.d.ts +2 -5
  114. package/dist/npm/plugins/table-resize/index.js +13 -14
  115. package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
  116. package/dist/npm/plugins/table-resize/row-resize.js +40 -40
  117. package/dist/npm/plugins/table-resize/table-resize.d.ts +18 -0
  118. package/dist/npm/plugins/table-resize/table-resize.js +51 -52
  119. package/dist/npm/plugins/table-resize/table-view.d.ts +28 -0
  120. package/dist/npm/plugins/table-resize/table-view.js +23 -24
  121. package/dist/npm/plugins/table-resize/utils.d.ts +17 -7
  122. package/dist/npm/plugins/table-resize/utils.js +24 -28
  123. package/dist/npm/source.d.ts +13 -16
  124. package/dist/npm/source.js +35 -36
  125. package/dist/npm/table.d.ts +9 -10
  126. package/dist/npm/table.js +33 -49
  127. package/dist/npm/text.d.ts +3 -6
  128. package/dist/npm/text.js +3 -3
  129. package/dist/npm/types/active-marks.d.ts +1 -4
  130. package/dist/npm/types/active-marks.js +2 -0
  131. package/dist/npm/types/command.d.ts +2 -5
  132. package/dist/npm/types/command.js +2 -0
  133. package/dist/npm/types/dispatchFn.d.ts +1 -4
  134. package/dist/npm/types/dispatchFn.js +2 -0
  135. package/dist/npm/types/paste-cleanup-settings.d.ts +1 -3
  136. package/dist/npm/types/paste-cleanup-settings.js +2 -0
  137. package/dist/npm/types/predicate.d.ts +1 -0
  138. package/dist/npm/types/predicate.js +2 -0
  139. package/dist/npm/utils.d.ts +33 -14
  140. package/dist/npm/utils.js +38 -39
  141. package/package.json +3 -50
  142. package/dist/es2015/DOMSerializer.js +0 -184
  143. package/dist/es2015/align.js +0 -43
  144. package/dist/es2015/blockNode.js +0 -180
  145. package/dist/es2015/blockquote.js +0 -26
  146. package/dist/es2015/cleanFormatting.js +0 -20
  147. package/dist/es2015/config/align-rules.js +0 -30
  148. package/dist/es2015/config/commands.js +0 -50
  149. package/dist/es2015/config/constants.js +0 -9
  150. package/dist/es2015/config/indent-rules.js +0 -42
  151. package/dist/es2015/config/keymap.js +0 -51
  152. package/dist/es2015/config/list-settings.js +0 -21
  153. package/dist/es2015/config/schema.js +0 -314
  154. package/dist/es2015/find-replace.js +0 -122
  155. package/dist/es2015/flatten-spans.js +0 -112
  156. package/dist/es2015/image.js +0 -10
  157. package/dist/es2015/indent.js +0 -105
  158. package/dist/es2015/inline-style.js +0 -177
  159. package/dist/es2015/link.js +0 -105
  160. package/dist/es2015/listConvert.js +0 -184
  161. package/dist/es2015/lists.js +0 -266
  162. package/dist/es2015/main.js +0 -44
  163. package/dist/es2015/mark.js +0 -239
  164. package/dist/es2015/node_modules/tslib/tslib.es6.js +0 -35
  165. package/dist/es2015/paste.js +0 -162
  166. package/dist/es2015/plugins/caret-color.js +0 -34
  167. package/dist/es2015/plugins/csp-fix.js +0 -51
  168. package/dist/es2015/plugins/highlight.js +0 -23
  169. package/dist/es2015/plugins/image-resize.js +0 -225
  170. package/dist/es2015/plugins/list-markers-styles.js +0 -104
  171. package/dist/es2015/plugins/placeholder.js +0 -27
  172. package/dist/es2015/plugins/resize-utils.js +0 -13
  173. package/dist/es2015/plugins/spaces-fix.js +0 -46
  174. package/dist/es2015/plugins/table-resize/column-resize.js +0 -267
  175. package/dist/es2015/plugins/table-resize/index.js +0 -12
  176. package/dist/es2015/plugins/table-resize/row-resize.js +0 -234
  177. package/dist/es2015/plugins/table-resize/table-resize.js +0 -278
  178. package/dist/es2015/plugins/table-resize/table-view.js +0 -128
  179. package/dist/es2015/plugins/table-resize/utils.js +0 -93
  180. package/dist/es2015/source.js +0 -251
  181. package/dist/es2015/table.js +0 -132
  182. package/dist/es2015/text.js +0 -5
  183. package/dist/es2015/utils.js +0 -289
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,21 +1,34 @@
1
1
  import { Node, NodeType, ResolvedPos } from 'prosemirror-model';
2
- import { EditorState } from 'prosemirror-state';
3
- import { Command } from './types/command.js';
4
-
2
+ import { EditorState, Selection } from 'prosemirror-state';
3
+ import { Command } from './types/command';
4
+ interface NodeDepth {
5
+ depth: number;
6
+ node: Node;
7
+ }
8
+ export declare const changeStylesString: (styleText: string, newStyle: {
9
+ style: string;
10
+ value: RegExp;
11
+ newValue?: string;
12
+ }) => {
13
+ changed: boolean;
14
+ style: string | null;
15
+ };
16
+ export declare function setNodeStyle(nodeAttrs: any, styleType: string, value: string): any;
5
17
  /**
6
18
  * Determines if a given node type can be inserted at the current cursor position.
7
19
  */
8
- declare const canInsert: (state: EditorState, nodeType: NodeType) => boolean;
9
- declare function parentNode(pos: ResolvedPos, predicate: (node: Node) => boolean): {
20
+ export declare const canInsert: (state: EditorState, nodeType: NodeType) => boolean;
21
+ export declare const findNthParentNodeOfType: (nodeType: NodeType, depth?: number) => (selection: Selection) => NodeDepth;
22
+ export declare function parentNode(pos: ResolvedPos, predicate: (node: Node) => boolean): {
10
23
  node: Node;
11
24
  depth: number;
12
25
  } | null;
13
26
  /**
14
27
  * Inserts the given node at the place of current selection.
15
28
  */
16
- declare const insertNode: (node: Node, scrollIntoView?: boolean) => Command;
17
- declare const getSelectionText: (state: EditorState) => string;
18
- declare const getNodeFromSelection: (state: EditorState) => Node;
29
+ export declare const insertNode: (node: Node, scrollIntoView?: boolean) => Command;
30
+ export declare const getSelectionText: (state: EditorState) => string;
31
+ export declare const getNodeFromSelection: (state: EditorState) => Node;
19
32
  /**
20
33
  * Returns the text from the selection if only text is selected on a single line.
21
34
  * If selection contains leaf nodes (br, image) between text elements or
@@ -24,16 +37,17 @@ declare const getNodeFromSelection: (state: EditorState) => Node;
24
37
  * Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
25
38
  * should be single line text only.
26
39
  */
27
- declare const selectedLineTextOnly: (state: EditorState) => string;
40
+ export declare const selectedLineTextOnly: (state: EditorState) => string;
28
41
  /**
29
42
  * Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
30
43
  */
31
- declare const indentHtml: (content: string) => string;
44
+ export declare const indentHtml: (content: string) => string;
45
+ export declare const shallowEqual: (object1: any, object2: any) => boolean;
32
46
  /**
33
47
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
34
48
  * returns modified state and dispatch.
35
49
  */
36
- declare const expandSelection: (state: any, dispatch: any, options: any) => {
50
+ export declare const expandSelection: (state: any, dispatch: any, options: any) => {
37
51
  state: any;
38
52
  dispatch: any;
39
53
  };
@@ -49,6 +63,11 @@ declare const expandSelection: (state: any, dispatch: any, options: any) => {
49
63
  * const command = expandToWordWrap(toggleInlineFormat, {...bold, applyToWord );
50
64
  * command(view.state, view.dispatch);
51
65
  */
52
- declare const expandToWordWrap: (command: any, options: any) => (state: any, dispatch: any) => any;
53
-
54
- export { canInsert, expandSelection, expandToWordWrap, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, selectedLineTextOnly };
66
+ export declare const expandToWordWrap: (command: any, options: any) => (state: any, dispatch: any) => any;
67
+ export declare const parseStyle: (styleText: string | null) => {
68
+ [key: string]: string;
69
+ };
70
+ export declare const applyStyle: (styleText: string | null, styleType: string, styleValue: string) => string;
71
+ export declare const setStyleAttr: (element: HTMLElement, styleString: string) => void;
72
+ export declare const setAttribute: (node: HTMLElement, attrName: string, value?: string) => void;
73
+ export {};
package/dist/npm/utils.js CHANGED
@@ -1,9 +1,11 @@
1
- 'use strict';
2
-
3
- var prosemirrorModel = require('prosemirror-model');
4
- var prosemirrorState = require('prosemirror-state');
5
- var kendoCommon = require('@progress/kendo-common');
6
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setAttribute = exports.setStyleAttr = exports.applyStyle = exports.parseStyle = exports.expandToWordWrap = exports.expandSelection = exports.shallowEqual = exports.indentHtml = exports.selectedLineTextOnly = exports.getNodeFromSelection = exports.getSelectionText = exports.insertNode = exports.findNthParentNodeOfType = exports.canInsert = exports.changeStylesString = void 0;
4
+ exports.setNodeStyle = setNodeStyle;
5
+ exports.parentNode = parentNode;
6
+ const prosemirror_model_1 = require("prosemirror-model");
7
+ const prosemirror_state_1 = require("prosemirror-state");
8
+ const kendo_common_1 = require("@progress/kendo-common");
7
9
  const changeStylesString = (styleText, newStyle) => {
8
10
  const styleToChange = newStyle.style;
9
11
  const regExp = newStyle.value;
@@ -11,7 +13,7 @@ const changeStylesString = (styleText, newStyle) => {
11
13
  if (!styleText) {
12
14
  return { changed: false, style: null };
13
15
  }
14
- const styles = parseStyle(styleText);
16
+ const styles = (0, exports.parseStyle)(styleText);
15
17
  const styleNames = Object.keys(styles);
16
18
  const filtered = [];
17
19
  for (let i = 0; i < styleNames.length; i++) {
@@ -28,11 +30,12 @@ const changeStylesString = (styleText, newStyle) => {
28
30
  changed: Boolean(newValue) || filtered.length !== styleNames.length
29
31
  };
30
32
  };
33
+ exports.changeStylesString = changeStylesString;
31
34
  const reAnyValue = /^.+$/;
32
35
  function setNodeStyle(nodeAttrs, styleType, value) {
33
36
  let attrs;
34
37
  if (new RegExp('[^-]?' + styleType + ':').test(nodeAttrs.style || '')) {
35
- const { style } = changeStylesString(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value });
38
+ const { style } = (0, exports.changeStylesString)(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value });
36
39
  attrs = { ...nodeAttrs, style };
37
40
  }
38
41
  else if (nodeAttrs.style) {
@@ -56,8 +59,9 @@ const canInsert = (state, nodeType) => {
56
59
  }
57
60
  return false;
58
61
  };
62
+ exports.canInsert = canInsert;
59
63
  const getTypeName = (n) => {
60
- return n instanceof prosemirrorModel.Node ? n.type.name : n.name;
64
+ return n instanceof prosemirror_model_1.Node ? n.type.name : n.name;
61
65
  };
62
66
  const findNthParentNode = (predicate, depth = 1) => {
63
67
  return (selection) => {
@@ -78,6 +82,7 @@ const findNthParentNodeOfType = (nodeType, depth = 1) => {
78
82
  return findNthParentNode((node) => getTypeName(node) === getTypeName(nodeType), depth)(selection);
79
83
  };
80
84
  };
85
+ exports.findNthParentNodeOfType = findNthParentNodeOfType;
81
86
  function parentNode(pos, predicate) {
82
87
  for (let depth = pos.depth; depth > 0; depth--) {
83
88
  const node = pos.node(depth);
@@ -101,11 +106,11 @@ const filterEmptyAttrs = (attrs) => {
101
106
  */
102
107
  const insertNode = (node, scrollIntoView) => (state, dispatch) => {
103
108
  const { selection, tr } = state;
104
- if (selection instanceof prosemirrorState.NodeSelection
109
+ if (selection instanceof prosemirror_state_1.NodeSelection
105
110
  && selection.node.type.name === node.type.name
106
111
  && node.isLeaf && !node.isText && node.nodeSize === 1) {
107
112
  tr.setNodeMarkup(selection.from, null, { ...filterEmptyAttrs(selection.node.attrs), ...filterEmptyAttrs(node.attrs) });
108
- tr.setSelection(prosemirrorState.NodeSelection.create(tr.doc, selection.from));
113
+ tr.setSelection(prosemirror_state_1.NodeSelection.create(tr.doc, selection.from));
109
114
  }
110
115
  else {
111
116
  tr.replaceSelectionWith(node);
@@ -115,19 +120,22 @@ const insertNode = (node, scrollIntoView) => (state, dispatch) => {
115
120
  }
116
121
  dispatch(tr);
117
122
  };
123
+ exports.insertNode = insertNode;
118
124
  const getSelectionText = (state) => {
119
125
  const sel = state.selection;
120
- if (sel instanceof prosemirrorState.TextSelection || sel instanceof prosemirrorState.AllSelection) {
126
+ if (sel instanceof prosemirror_state_1.TextSelection || sel instanceof prosemirror_state_1.AllSelection) {
121
127
  const fragment = sel.content().content;
122
128
  return fragment.textBetween(0, fragment.size);
123
129
  }
124
130
  return '';
125
131
  };
132
+ exports.getSelectionText = getSelectionText;
126
133
  const getNodeFromSelection = (state) => {
127
- if (state.selection instanceof prosemirrorState.NodeSelection) {
134
+ if (state.selection instanceof prosemirror_state_1.NodeSelection) {
128
135
  return state.selection.node;
129
136
  }
130
137
  };
138
+ exports.getNodeFromSelection = getNodeFromSelection;
131
139
  /**
132
140
  * Returns the text from the selection if only text is selected on a single line.
133
141
  * If selection contains leaf nodes (br, image) between text elements or
@@ -145,11 +153,12 @@ const selectedLineTextOnly = (state) => {
145
153
  hasLeafs = hasLeafs || (node.isLeaf && !node.isText);
146
154
  });
147
155
  if (!hasLeafs) {
148
- result = getSelectionText(state);
156
+ result = (0, exports.getSelectionText)(state);
149
157
  }
150
158
  }
151
159
  return result;
152
160
  };
161
+ exports.selectedLineTextOnly = selectedLineTextOnly;
153
162
  /**
154
163
  * Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
155
164
  */
@@ -159,13 +168,15 @@ const indentHtml = (content) => {
159
168
  .replace(/<br \/>/ig, '<br />\n')
160
169
  .replace(/\n$/, '');
161
170
  };
171
+ exports.indentHtml = indentHtml;
162
172
  const shallowEqual = (object1, object2) => {
163
173
  const keys1 = Object.keys(object1);
164
174
  const keys2 = Object.keys(object2);
165
175
  return keys1.length === keys2.length &&
166
176
  keys1.every(k => object1[k] === object2[k]);
167
177
  };
168
- const applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
178
+ exports.shallowEqual = shallowEqual;
179
+ const applyToWordDefault = { before: /[^ !,?.[\]{}()]+$/i, after: /^[^ !,?.[\]{}()]+/i };
169
180
  /**
170
181
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
171
182
  * returns modified state and dispatch.
@@ -217,7 +228,7 @@ const expandSelection = (state, dispatch, options) => {
217
228
  const extendLeft = matchBefore[0].length;
218
229
  const extendRight = matchAfter[0].length;
219
230
  const pos = initialPosition = selection.from;
220
- tr.setSelection(prosemirrorState.TextSelection.create(state.doc, pos - extendLeft, pos + extendRight));
231
+ tr.setSelection(prosemirror_state_1.TextSelection.create(state.doc, pos - extendLeft, pos + extendRight));
221
232
  const cmdState = {
222
233
  tr,
223
234
  selection: tr.selection,
@@ -226,7 +237,7 @@ const expandSelection = (state, dispatch, options) => {
226
237
  schema: tr.doc.type.schema
227
238
  };
228
239
  const cmdDispatch = tran => {
229
- tran.setSelection(prosemirrorState.TextSelection.create(tran.doc, initialPosition));
240
+ tran.setSelection(prosemirror_state_1.TextSelection.create(tran.doc, initialPosition));
230
241
  dispatch(tran);
231
242
  };
232
243
  return { state: cmdState, dispatch: cmdDispatch };
@@ -234,6 +245,7 @@ const expandSelection = (state, dispatch, options) => {
234
245
  }
235
246
  return { state, dispatch };
236
247
  };
248
+ exports.expandSelection = expandSelection;
237
249
  /**
238
250
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
239
251
  * use the modified state for the passed command.
@@ -248,15 +260,17 @@ const expandSelection = (state, dispatch, options) => {
248
260
  */
249
261
  const expandToWordWrap = (command, options) => {
250
262
  return (state, dispatch) => {
251
- const { state: cmdState, dispatch: cmdDispatch } = expandSelection(state, dispatch, options);
263
+ const { state: cmdState, dispatch: cmdDispatch } = (0, exports.expandSelection)(state, dispatch, options);
252
264
  return command(options)(cmdState, cmdDispatch);
253
265
  };
254
266
  };
267
+ exports.expandToWordWrap = expandToWordWrap;
255
268
  const parseStyle = (styleText) => {
256
- return kendoCommon.parseInlineStyles(styleText);
269
+ return (0, kendo_common_1.parseInlineStyles)(styleText);
257
270
  };
271
+ exports.parseStyle = parseStyle;
258
272
  const applyStyle = (styleText, styleType, styleValue) => {
259
- const styles = parseStyle(styleText);
273
+ const styles = (0, exports.parseStyle)(styleText);
260
274
  styles[styleType] = styleValue;
261
275
  const result = Object.keys(styles)
262
276
  .map(name => styles[name] ? `${name}: ${styles[name]}` : null)
@@ -264,20 +278,22 @@ const applyStyle = (styleText, styleType, styleValue) => {
264
278
  .join('; ');
265
279
  return result ? result + ';' : null;
266
280
  };
281
+ exports.applyStyle = applyStyle;
267
282
  const setStyleAttr = (element, styleString) => {
268
- const styles = parseStyle(styleString);
283
+ const styles = (0, exports.parseStyle)(styleString);
269
284
  for (const style in styles) {
270
285
  if (style && element.style[style] !== undefined) {
271
286
  element.style[style] = styles[style];
272
287
  }
273
288
  }
274
289
  };
290
+ exports.setStyleAttr = setStyleAttr;
275
291
  const setAttribute = (node, attrName, value) => {
276
292
  const current = node.getAttribute(attrName);
277
293
  if (value !== undefined && value !== current) {
278
294
  if (attrName === 'style') {
279
295
  node.removeAttribute(attrName);
280
- setStyleAttr(node, value);
296
+ (0, exports.setStyleAttr)(node, value);
281
297
  }
282
298
  else {
283
299
  node.setAttribute(attrName, value);
@@ -287,21 +303,4 @@ const setAttribute = (node, attrName, value) => {
287
303
  node.removeAttribute(attrName);
288
304
  }
289
305
  };
290
-
291
- exports.applyStyle = applyStyle;
292
- exports.canInsert = canInsert;
293
- exports.changeStylesString = changeStylesString;
294
- exports.expandSelection = expandSelection;
295
- exports.expandToWordWrap = expandToWordWrap;
296
- exports.findNthParentNodeOfType = findNthParentNodeOfType;
297
- exports.getNodeFromSelection = getNodeFromSelection;
298
- exports.getSelectionText = getSelectionText;
299
- exports.indentHtml = indentHtml;
300
- exports.insertNode = insertNode;
301
- exports.parentNode = parentNode;
302
- exports.parseStyle = parseStyle;
303
- exports.selectedLineTextOnly = selectedLineTextOnly;
304
306
  exports.setAttribute = setAttribute;
305
- exports.setNodeStyle = setNodeStyle;
306
- exports.setStyleAttr = setStyleAttr;
307
- exports.shallowEqual = shallowEqual;
package/package.json CHANGED
@@ -1,28 +1,17 @@
1
1
  {
2
2
  "name": "@progress/kendo-editor-common",
3
3
  "description": "Kendo UI TypeScript package exporting functions for Editor component",
4
- "version": "1.12.2-develop.4",
4
+ "version": "1.12.2-develop.6",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],
8
- "type": "module",
9
8
  "author": "Progress",
10
9
  "license": "SEE LICENSE IN LICENSE.md",
11
10
  "main": "dist/npm/main.js",
12
11
  "module": "dist/es/main.js",
13
- "jsnext:main": "dist/es/main.js",
14
- "es2015": "dist/es2015/main.js",
15
12
  "typings": "dist/npm/main.d.ts",
16
13
  "jsdelivr": "dist/cdn/main.js",
17
14
  "unpkg": "dist/cdn/main.js",
18
- "scripts": {
19
- "start": "vite",
20
- "test:ci": "jest",
21
- "test": "jest",
22
- "lint": "eslint .",
23
- "build": "rollup -c",
24
- "prepare": "husky"
25
- },
26
15
  "dependencies": {
27
16
  "@progress/kendo-common": "^1.0.2",
28
17
  "prosemirror-commands": "1.7.0",
@@ -31,37 +20,14 @@
31
20
  "prosemirror-history": "1.4.1",
32
21
  "prosemirror-inputrules": "1.4.0",
33
22
  "prosemirror-keymap": "1.2.2",
34
- "prosemirror-model": "1.24.1",
23
+ "prosemirror-model": "1.25.0",
35
24
  "prosemirror-schema-list": "1.5.0",
36
25
  "prosemirror-state": "1.4.3",
37
26
  "prosemirror-tables": "1.6.4",
38
27
  "prosemirror-transform": "1.10.2",
39
- "prosemirror-view": "1.37.2",
28
+ "prosemirror-view": "1.39.1",
40
29
  "tslib": "^2.8.1"
41
30
  },
42
- "devDependencies": {
43
- "@rollup/plugin-commonjs": "^28.0.1",
44
- "@rollup/plugin-node-resolve": "^15.3.0",
45
- "@rollup/plugin-terser": "^0.4.4",
46
- "@rollup/plugin-typescript": "^12.1.1",
47
- "@types/jest": "^29.5.14",
48
- "@typescript-eslint/eslint-plugin": "^7.0.1",
49
- "eslint": "^8.56.0",
50
- "eslint-plugin-jest": "^27.8.0",
51
- "eslint-plugin-jsdoc": "^48.1.0",
52
- "eslint-plugin-typescript": "^0.14.0",
53
- "husky": "^9.1.7",
54
- "jest": "^29.7.0",
55
- "jest-environment-jsdom": "^29.7.0",
56
- "jest-preset-typescript": "^1.2.0",
57
- "rollup": "^4.28.0",
58
- "rollup-plugin-dts": "^6.1.1",
59
- "semantic-release": "^24.2.0",
60
- "ts-jest": "^29.2.5",
61
- "typescript": "^5.7.2",
62
- "typescript-eslint": "^7.0.1",
63
- "vite": "^6.0.2"
64
- },
65
31
  "jest": {
66
32
  "preset": "jest-preset-typescript",
67
33
  "testEnvironment": "jsdom"
@@ -73,19 +39,6 @@
73
39
  "bugs": {
74
40
  "url": "https://github.com/telerik/kendo-angular"
75
41
  },
76
- "release": {
77
- "branches": [
78
- {
79
- "name": "master",
80
- "channel": "latest"
81
- },
82
- {
83
- "name": "develop",
84
- "prerelease": true,
85
- "channel": "dev"
86
- }
87
- ]
88
- },
89
42
  "publishConfig": {
90
43
  "access": "public"
91
44
  },
@@ -1,184 +0,0 @@
1
- import { setAttribute } from './utils.js';
2
-
3
- class DOMSerializer {
4
- /// Render an [output spec](#model.DOMOutputSpec) to a DOM node. If
5
- /// the spec has a hole (zero) in it, `contentDOM` will point at the
6
- /// node with the hole.
7
- static renderSpec(docum, structure, xmlNS = null) {
8
- if (typeof structure === 'string') {
9
- return { dom: docum.createTextNode(structure) };
10
- }
11
- if (structure.nodeType != null) {
12
- return { dom: structure };
13
- }
14
- if (structure.dom && structure.dom.nodeType != null) {
15
- return structure;
16
- }
17
- let tagName = structure[0], space = tagName.indexOf(' ');
18
- if (space > 0) {
19
- xmlNS = tagName.slice(0, space);
20
- tagName = tagName.slice(space + 1);
21
- }
22
- let contentDOM;
23
- const dom = (xmlNS ? docum.createElementNS(xmlNS, tagName) : docum.createElement(tagName));
24
- let attrs = structure[1], start = 1;
25
- if (attrs && typeof attrs === 'object' && attrs.nodeType == null && !Array.isArray(attrs)) {
26
- start = 2;
27
- for (const name in attrs) {
28
- if (attrs[name] != null) {
29
- space = name.indexOf(' ');
30
- if (space > 0) {
31
- dom.setAttributeNS(name.slice(0, space), name.slice(space + 1), attrs[name]);
32
- }
33
- else {
34
- setAttribute(dom, name, attrs[name]);
35
- }
36
- }
37
- }
38
- }
39
- for (let i = start; i < structure.length; i++) {
40
- const child = structure[i];
41
- if (child === 0) {
42
- if (i < structure.length - 1 || i > start) {
43
- throw new RangeError('Content hole must be the only child of its parent node');
44
- }
45
- return { dom, contentDOM: dom };
46
- }
47
- else {
48
- const { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(docum, child, xmlNS);
49
- dom.appendChild(inner);
50
- if (innerContent) {
51
- if (contentDOM) {
52
- throw new RangeError('Multiple content holes');
53
- }
54
- contentDOM = innerContent;
55
- }
56
- }
57
- }
58
- return { dom, contentDOM };
59
- }
60
- /// Build a serializer using the [`toDOM`](#model.NodeSpec.toDOM)
61
- /// properties in a schema's node and mark specs.
62
- static fromSchema(schema) {
63
- return schema.cached.domSerializer ||
64
- (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));
65
- }
66
- /// Gather the serializers in a schema's node specs into an object.
67
- /// This can be useful as a base to build a custom serializer from.
68
- static nodesFromSchema(schema) {
69
- const result = gatherToDOM(schema.nodes);
70
- if (!result.text) {
71
- result.text = node => node.text;
72
- }
73
- return result;
74
- }
75
- /// Gather the serializers in a schema's mark specs into an object.
76
- static marksFromSchema(schema) {
77
- return gatherToDOM(schema.marks);
78
- }
79
- /// Create a serializer. `nodes` should map node names to functions
80
- /// that take a node and return a description of the corresponding
81
- /// DOM. `marks` does the same for mark names, but also gets an
82
- /// argument that tells it whether the mark's content is block or
83
- /// inline content (for typical use, it'll always be inline). A mark
84
- /// serializer may be `null` to indicate that marks of that type
85
- /// should not be serialized.
86
- constructor(
87
- /// The node serialization functions.
88
- nodes,
89
- /// The mark serialization functions.
90
- marks) {
91
- this.nodes = nodes;
92
- this.marks = marks;
93
- }
94
- /// Serialize the content of this fragment to a DOM fragment. When
95
- /// not in the browser, the `document` option, containing a DOM
96
- /// document, should be passed so that the serializer can create
97
- /// nodes.
98
- serializeFragment(fragment, options = {}, target) {
99
- if (!target) {
100
- target = doc(options).createDocumentFragment();
101
- }
102
- let top = target, active = [];
103
- fragment.forEach(node => {
104
- if (active.length || node.marks.length) {
105
- let keep = 0, rendered = 0;
106
- while (keep < active.length && rendered < node.marks.length) {
107
- const next = node.marks[rendered];
108
- if (!this.marks[next.type.name]) {
109
- rendered++;
110
- continue;
111
- }
112
- if (!next.eq(active[keep][0]) || next.type.spec.spanning === false) {
113
- break;
114
- }
115
- keep++;
116
- rendered++;
117
- }
118
- while (keep < active.length) {
119
- top = active.pop()[1];
120
- }
121
- while (rendered < node.marks.length) {
122
- const add = node.marks[rendered++];
123
- const markDOM = this.serializeMark(add, node.isInline, options);
124
- if (markDOM) {
125
- active.push([add, top]);
126
- top.appendChild(markDOM.dom);
127
- top = markDOM.contentDOM || markDOM.dom;
128
- }
129
- }
130
- }
131
- top.appendChild(this.serializeNodeInner(node, options));
132
- });
133
- return target;
134
- }
135
- /// Serialize this node to a DOM node. This can be useful when you
136
- /// need to serialize a part of a document, as opposed to the whole
137
- /// document. To serialize a whole document, use
138
- /// [`serializeFragment`](#model.DOMSerializer.serializeFragment) on
139
- /// its [content](#model.Node.content).
140
- serializeNode(node, options = {}) {
141
- let dom = this.serializeNodeInner(node, options);
142
- for (let i = node.marks.length - 1; i >= 0; i--) {
143
- const wrap = this.serializeMark(node.marks[i], node.isInline, options);
144
- if (wrap) {
145
- (wrap.contentDOM || wrap.dom).appendChild(dom);
146
- dom = wrap.dom;
147
- }
148
- }
149
- return dom;
150
- }
151
- /// @internal
152
- serializeMark(mark, inline, options = {}) {
153
- const toDOM = this.marks[mark.type.name];
154
- return toDOM && DOMSerializer.renderSpec(doc(options), toDOM(mark, inline));
155
- }
156
- /// @internal
157
- serializeNodeInner(node, options) {
158
- const { dom, contentDOM } = DOMSerializer.renderSpec(doc(options), this.nodes[node.type.name](node));
159
- if (contentDOM) {
160
- if (node.isLeaf) {
161
- throw new RangeError('Content hole not allowed in a leaf node spec');
162
- }
163
- this.serializeFragment(node.content, options, contentDOM);
164
- }
165
- return dom;
166
- }
167
- }
168
- function gatherToDOM(obj) {
169
- const result = {};
170
- for (const name in obj) {
171
- if (obj[name]) {
172
- const toDOM = obj[name].spec.toDOM;
173
- if (toDOM) {
174
- result[name] = toDOM;
175
- }
176
- }
177
- }
178
- return result;
179
- }
180
- function doc(options) {
181
- return options.document || window.document;
182
- }
183
-
184
- export { DOMSerializer };
@@ -1,43 +0,0 @@
1
- import { blockNodes, addStyles, changeTextBlock } from './blockNode.js';
2
-
3
- /**
4
- * Aligning block elements in the selection.
5
- *
6
- * @returns {boolean} - Returns true if any alignment is applied.
7
- */
8
- const alignBlocks = (actions, commandName) => (state, dispatch) => {
9
- const blocks = blockNodes(state);
10
- const tr = state.tr;
11
- tr.setMeta('commandName', commandName);
12
- blocks.forEach(node => {
13
- if (node.type.isTextblock) {
14
- const action = actions.find(n => n.node === node.type.name);
15
- if (action) {
16
- const newAttrs = addStyles(node, action.style);
17
- changeTextBlock(tr, node, node.type, newAttrs);
18
- }
19
- }
20
- });
21
- const result = tr.docChanged;
22
- if (result) {
23
- dispatch(tr.scrollIntoView());
24
- }
25
- return result;
26
- };
27
- const isAligned = (state, actions) => {
28
- const blocks = blockNodes(state);
29
- let result = false;
30
- blocks.forEach(node => {
31
- if (!result && node.type.isTextblock && node.attrs.style) {
32
- const action = actions.find(a => a.node === node.type.name);
33
- if (action) {
34
- result = action.style.every(style => {
35
- return !!style.value && new RegExp(`${style.name}:\\s?${style.value}`, 'i').test(node.attrs.style);
36
- });
37
- }
38
- }
39
- });
40
- return result;
41
- };
42
-
43
- export { alignBlocks, isAligned };