@progress/kendo-editor-common 1.11.9-dev.202412020819 → 1.11.9-develop.1

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 (185) hide show
  1. package/dist/cdn/main.js +1 -1
  2. package/dist/es/DOMSerializer.js +71 -75
  3. package/dist/es/align.js +19 -16
  4. package/dist/es/blockNode.js +76 -78
  5. package/dist/es/blockquote.js +12 -9
  6. package/dist/es/cleanFormatting.js +16 -16
  7. package/dist/es/config/align-rules.js +8 -6
  8. package/dist/es/config/commands.js +9 -13
  9. package/dist/es/config/constants.js +9 -7
  10. package/dist/es/config/indent-rules.js +8 -6
  11. package/dist/es/config/keymap.js +20 -18
  12. package/dist/es/config/list-settings.js +7 -6
  13. package/dist/es/config/schema.js +184 -126
  14. package/dist/es/find-replace.js +34 -32
  15. package/dist/es/image.js +10 -7
  16. package/dist/es/indent.js +47 -44
  17. package/dist/es/inline-style.js +72 -70
  18. package/dist/es/link.js +51 -52
  19. package/dist/es/listConvert.js +37 -34
  20. package/dist/es/lists.js +83 -82
  21. package/dist/es/main.js +32 -33
  22. package/dist/es/mark.js +87 -92
  23. package/dist/es/paste.js +48 -46
  24. package/dist/es/plugins/caret-color.js +14 -11
  25. package/dist/es/plugins/csp-fix.js +23 -23
  26. package/dist/es/plugins/highlight.js +12 -10
  27. package/dist/es/plugins/image-resize.js +81 -81
  28. package/dist/es/plugins/list-markers-styles.js +43 -39
  29. package/dist/es/plugins/placeholder.js +12 -9
  30. package/dist/es/plugins/resize-utils.js +11 -9
  31. package/dist/es/plugins/spaces-fix.js +13 -10
  32. package/dist/es/plugins/table-resize/column-resize.js +104 -102
  33. package/dist/es/plugins/table-resize/index.js +10 -7
  34. package/dist/es/plugins/table-resize/row-resize.js +88 -89
  35. package/dist/es/plugins/table-resize/table-resize.js +129 -122
  36. package/dist/es/plugins/table-resize/table-view.js +46 -48
  37. package/dist/es/plugins/table-resize/utils.js +39 -41
  38. package/dist/es/source.js +78 -74
  39. package/dist/es/table.js +64 -66
  40. package/dist/es/text.js +4 -2
  41. package/dist/es/utils.js +107 -116
  42. package/dist/es2015/DOMSerializer.js +20 -17
  43. package/dist/es2015/align.js +6 -3
  44. package/dist/es2015/blockNode.js +15 -12
  45. package/dist/es2015/blockquote.js +5 -2
  46. package/dist/es2015/cleanFormatting.js +6 -3
  47. package/dist/es2015/config/align-rules.js +7 -5
  48. package/dist/es2015/config/commands.js +9 -13
  49. package/dist/es2015/config/constants.js +9 -7
  50. package/dist/es2015/config/indent-rules.js +6 -3
  51. package/dist/es2015/config/keymap.js +10 -7
  52. package/dist/es2015/config/list-settings.js +5 -3
  53. package/dist/es2015/config/schema.js +8 -6
  54. package/dist/es2015/find-replace.js +9 -6
  55. package/dist/es2015/image.js +5 -2
  56. package/dist/es2015/indent.js +14 -11
  57. package/dist/es2015/inline-style.js +9 -6
  58. package/dist/es2015/link.js +7 -4
  59. package/dist/es2015/listConvert.js +5 -2
  60. package/dist/es2015/lists.js +14 -11
  61. package/dist/es2015/main.js +32 -33
  62. package/dist/es2015/mark.js +15 -12
  63. package/dist/es2015/node_modules/tslib/tslib.es6.js +35 -0
  64. package/dist/es2015/paste.js +14 -11
  65. package/dist/es2015/plugins/caret-color.js +8 -5
  66. package/dist/es2015/plugins/csp-fix.js +5 -2
  67. package/dist/es2015/plugins/highlight.js +6 -3
  68. package/dist/es2015/plugins/image-resize.js +10 -7
  69. package/dist/es2015/plugins/list-markers-styles.js +6 -3
  70. package/dist/es2015/plugins/placeholder.js +5 -2
  71. package/dist/es2015/plugins/resize-utils.js +11 -9
  72. package/dist/es2015/plugins/spaces-fix.js +4 -1
  73. package/dist/es2015/plugins/table-resize/column-resize.js +24 -21
  74. package/dist/es2015/plugins/table-resize/index.js +9 -6
  75. package/dist/es2015/plugins/table-resize/row-resize.js +23 -20
  76. package/dist/es2015/plugins/table-resize/table-resize.js +20 -17
  77. package/dist/es2015/plugins/table-resize/table-view.js +9 -6
  78. package/dist/es2015/plugins/table-resize/utils.js +13 -10
  79. package/dist/es2015/source.js +24 -13
  80. package/dist/es2015/table.js +18 -15
  81. package/dist/es2015/text.js +3 -1
  82. package/dist/es2015/utils.js +22 -25
  83. package/dist/npm/DOMSerializer.js +73 -78
  84. package/dist/npm/align.d.ts +7 -4
  85. package/dist/npm/align.js +22 -21
  86. package/dist/npm/blockNode.d.ts +14 -15
  87. package/dist/npm/blockNode.js +91 -95
  88. package/dist/npm/blockquote.d.ts +5 -2
  89. package/dist/npm/blockquote.js +16 -15
  90. package/dist/npm/cleanFormatting.d.ts +6 -3
  91. package/dist/npm/cleanFormatting.js +17 -19
  92. package/dist/npm/config/align-rules.d.ts +8 -6
  93. package/dist/npm/config/align-rules.js +14 -9
  94. package/dist/npm/config/commands.d.ts +11 -19
  95. package/dist/npm/config/commands.js +17 -16
  96. package/dist/npm/config/constants.js +17 -10
  97. package/dist/npm/config/indent-rules.d.ts +6 -4
  98. package/dist/npm/config/indent-rules.js +11 -9
  99. package/dist/npm/config/keymap.d.ts +5 -2
  100. package/dist/npm/config/keymap.js +30 -30
  101. package/dist/npm/config/list-settings.js +13 -11
  102. package/dist/npm/config/schema.d.ts +4 -3
  103. package/dist/npm/config/schema.js +191 -134
  104. package/dist/npm/find-replace.d.ts +10 -7
  105. package/dist/npm/find-replace.js +47 -47
  106. package/dist/npm/image.d.ts +6 -3
  107. package/dist/npm/image.js +11 -10
  108. package/dist/npm/indent.d.ts +12 -9
  109. package/dist/npm/indent.js +68 -67
  110. package/dist/npm/inline-style.d.ts +7 -4
  111. package/dist/npm/inline-style.js +83 -83
  112. package/dist/npm/link.d.ts +4 -2
  113. package/dist/npm/link.js +58 -61
  114. package/dist/npm/listConvert.d.ts +3 -1
  115. package/dist/npm/listConvert.js +40 -39
  116. package/dist/npm/lists.d.ts +9 -9
  117. package/dist/npm/lists.js +94 -95
  118. package/dist/npm/main.d.ts +34 -33
  119. package/dist/npm/main.js +388 -198
  120. package/dist/npm/mark.d.ts +13 -18
  121. package/dist/npm/mark.js +104 -111
  122. package/dist/npm/paste.d.ts +12 -9
  123. package/dist/npm/paste.js +61 -61
  124. package/dist/npm/plugins/caret-color.d.ts +6 -3
  125. package/dist/npm/plugins/caret-color.js +21 -19
  126. package/dist/npm/plugins/csp-fix.d.ts +4 -1
  127. package/dist/npm/plugins/csp-fix.js +28 -30
  128. package/dist/npm/plugins/highlight.d.ts +7 -4
  129. package/dist/npm/plugins/highlight.js +17 -16
  130. package/dist/npm/plugins/image-resize.d.ts +7 -5
  131. package/dist/npm/plugins/image-resize.js +96 -97
  132. package/dist/npm/plugins/list-markers-styles.d.ts +5 -2
  133. package/dist/npm/plugins/list-markers-styles.js +49 -47
  134. package/dist/npm/plugins/placeholder.d.ts +4 -1
  135. package/dist/npm/plugins/placeholder.js +18 -17
  136. package/dist/npm/plugins/resize-utils.js +14 -12
  137. package/dist/npm/plugins/spaces-fix.d.ts +4 -1
  138. package/dist/npm/plugins/spaces-fix.js +19 -18
  139. package/dist/npm/plugins/table-resize/column-resize.js +117 -117
  140. package/dist/npm/plugins/table-resize/index.d.ts +5 -2
  141. package/dist/npm/plugins/table-resize/index.js +16 -15
  142. package/dist/npm/plugins/table-resize/row-resize.js +98 -101
  143. package/dist/npm/plugins/table-resize/table-resize.js +144 -139
  144. package/dist/npm/plugins/table-resize/table-view.js +59 -61
  145. package/dist/npm/plugins/table-resize/utils.d.ts +7 -17
  146. package/dist/npm/plugins/table-resize/utils.js +51 -52
  147. package/dist/npm/source.d.ts +18 -11
  148. package/dist/npm/source.js +94 -91
  149. package/dist/npm/table.d.ts +10 -9
  150. package/dist/npm/table.js +93 -82
  151. package/dist/npm/text.d.ts +6 -3
  152. package/dist/npm/text.js +5 -5
  153. package/dist/npm/types/active-marks.d.ts +4 -1
  154. package/dist/npm/types/command.d.ts +5 -2
  155. package/dist/npm/types/dispatchFn.d.ts +4 -1
  156. package/dist/npm/types/paste-cleanup-settings.d.ts +3 -1
  157. package/dist/npm/utils.d.ts +13 -32
  158. package/dist/npm/utils.js +133 -145
  159. package/package.json +34 -52
  160. package/dist/cdn/js/kendo-editor-common.js +0 -1
  161. package/dist/es/types/active-marks.js +0 -1
  162. package/dist/es/types/command.js +0 -1
  163. package/dist/es/types/dispatchFn.js +0 -1
  164. package/dist/es/types/paste-cleanup-settings.js +0 -1
  165. package/dist/es/types/predicate.js +0 -1
  166. package/dist/es2015/types/active-marks.js +0 -1
  167. package/dist/es2015/types/command.js +0 -1
  168. package/dist/es2015/types/dispatchFn.js +0 -1
  169. package/dist/es2015/types/paste-cleanup-settings.js +0 -1
  170. package/dist/es2015/types/predicate.js +0 -1
  171. package/dist/npm/DOMSerializer.d.ts +0 -35
  172. package/dist/npm/config/constants.d.ts +0 -7
  173. package/dist/npm/config/list-settings.d.ts +0 -30
  174. package/dist/npm/plugins/resize-utils.d.ts +0 -35
  175. package/dist/npm/plugins/table-resize/column-resize.d.ts +0 -2
  176. package/dist/npm/plugins/table-resize/row-resize.d.ts +0 -2
  177. package/dist/npm/plugins/table-resize/table-resize.d.ts +0 -18
  178. package/dist/npm/plugins/table-resize/table-view.d.ts +0 -28
  179. package/dist/npm/types/active-marks.js +0 -2
  180. package/dist/npm/types/command.js +0 -2
  181. package/dist/npm/types/dispatchFn.js +0 -2
  182. package/dist/npm/types/paste-cleanup-settings.js +0 -2
  183. package/dist/npm/types/predicate.d.ts +0 -1
  184. package/dist/npm/types/predicate.js +0 -2
  185. package/dist/systemjs/kendo-editor-common.js +0 -1
package/dist/es/utils.js CHANGED
@@ -1,96 +1,93 @@
1
- import { __assign } from "tslib";
2
- import { Node, Fragment } from 'prosemirror-model';
3
- import { TextSelection, AllSelection, NodeSelection } from 'prosemirror-state';
1
+ import { Node } from 'prosemirror-model';
2
+ import { NodeSelection, TextSelection, AllSelection } from 'prosemirror-state';
4
3
  import { parseInlineStyles } from '@progress/kendo-common';
5
- import { parseContent } from './source';
6
- export var changeStylesString = function (styleText, newStyle) {
7
- var styleToChange = newStyle.style;
8
- var regExp = newStyle.value;
9
- var newValue = newStyle.newValue;
4
+
5
+ const changeStylesString = (styleText, newStyle) => {
6
+ const styleToChange = newStyle.style;
7
+ const regExp = newStyle.value;
8
+ const newValue = newStyle.newValue;
10
9
  if (!styleText) {
11
10
  return { changed: false, style: null };
12
11
  }
13
- var styles = parseStyle(styleText);
14
- var styleNames = Object.keys(styles);
15
- var filtered = [];
16
- for (var i = 0; i < styleNames.length; i++) {
17
- var name_1 = styleNames[i];
18
- if (name_1.toLowerCase() !== styleToChange || !regExp.test(styles[name_1])) {
19
- filtered.push("".concat(name_1, ": ").concat(styles[name_1]));
12
+ const styles = parseStyle(styleText);
13
+ const styleNames = Object.keys(styles);
14
+ const filtered = [];
15
+ for (let i = 0; i < styleNames.length; i++) {
16
+ const name = styleNames[i];
17
+ if (name.toLowerCase() !== styleToChange || !regExp.test(styles[name])) {
18
+ filtered.push(`${name}: ${styles[name]}`);
20
19
  }
21
20
  }
22
21
  if (newValue) {
23
- filtered.push("".concat(styleToChange, ": ").concat(newValue));
22
+ filtered.push(`${styleToChange}: ${newValue}`);
24
23
  }
25
24
  return {
26
25
  style: filtered.join('; ') + (filtered.length ? ';' : ''),
27
26
  changed: Boolean(newValue) || filtered.length !== styleNames.length
28
27
  };
29
28
  };
30
- var reAnyValue = /^.+$/;
31
- export function setNodeStyle(nodeAttrs, styleType, value) {
32
- var attrs;
29
+ const reAnyValue = /^.+$/;
30
+ function setNodeStyle(nodeAttrs, styleType, value) {
31
+ let attrs;
33
32
  if (new RegExp('[^-]?' + styleType + ':').test(nodeAttrs.style || '')) {
34
- var style = changeStylesString(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value }).style;
35
- attrs = __assign(__assign({}, nodeAttrs), { style: style });
33
+ const { style } = changeStylesString(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value });
34
+ attrs = { ...nodeAttrs, style };
36
35
  }
37
36
  else if (nodeAttrs.style) {
38
- attrs = __assign(__assign({}, nodeAttrs), { style: nodeAttrs.style.replace(/;$/, '') + '; ' + styleType + ': ' + value + ';' });
37
+ attrs = { ...nodeAttrs, style: nodeAttrs.style.replace(/;$/, '') + '; ' + styleType + ': ' + value + ';' };
39
38
  }
40
39
  else {
41
- attrs = __assign(__assign({}, nodeAttrs), { style: styleType + ': ' + value + ';' });
40
+ attrs = { ...nodeAttrs, style: styleType + ': ' + value + ';' };
42
41
  }
43
42
  return attrs;
44
43
  }
45
44
  /**
46
45
  * Determines if a given node type can be inserted at the current cursor position.
47
46
  */
48
- export var canInsert = function (state, nodeType) {
49
- var $from = state.selection.$from;
50
- for (var d = $from.depth; d >= 0; d--) {
51
- var index = $from.index(d);
47
+ const canInsert = (state, nodeType) => {
48
+ const $from = state.selection.$from;
49
+ for (let d = $from.depth; d >= 0; d--) {
50
+ const index = $from.index(d);
52
51
  if ($from.node(d).canReplaceWith(index, index, nodeType)) {
53
52
  return true;
54
53
  }
55
54
  }
56
55
  return false;
57
56
  };
58
- var getTypeName = function (n) {
57
+ const getTypeName = (n) => {
59
58
  return n instanceof Node ? n.type.name : n.name;
60
59
  };
61
- var findNthParentNode = function (predicate, depth) {
62
- if (depth === void 0) { depth = 1; }
63
- return function (selection) {
64
- var $from = selection.$from;
65
- for (var i = $from.depth; i > 0; i--) {
66
- var node = $from.node(i);
60
+ const findNthParentNode = (predicate, depth = 1) => {
61
+ return (selection) => {
62
+ const { $from } = selection;
63
+ for (let i = $from.depth; i > 0; i--) {
64
+ const node = $from.node(i);
67
65
  if (predicate(node)) {
68
66
  depth = depth - 1;
69
67
  if (depth === 0) {
70
- return { depth: i, node: node };
68
+ return { depth: i, node };
71
69
  }
72
70
  }
73
71
  }
74
72
  };
75
73
  };
76
- export var findNthParentNodeOfType = function (nodeType, depth) {
77
- if (depth === void 0) { depth = 1; }
78
- return function (selection) {
79
- return findNthParentNode(function (node) { return getTypeName(node) === getTypeName(nodeType); }, depth)(selection);
74
+ const findNthParentNodeOfType = (nodeType, depth = 1) => {
75
+ return (selection) => {
76
+ return findNthParentNode((node) => getTypeName(node) === getTypeName(nodeType), depth)(selection);
80
77
  };
81
78
  };
82
- export function parentNode(pos, predicate) {
83
- for (var depth = pos.depth; depth > 0; depth--) {
84
- var node = pos.node(depth);
79
+ function parentNode(pos, predicate) {
80
+ for (let depth = pos.depth; depth > 0; depth--) {
81
+ const node = pos.node(depth);
85
82
  if (predicate(node)) {
86
- return { node: node, depth: depth };
83
+ return { node, depth };
87
84
  }
88
85
  }
89
86
  return null;
90
87
  }
91
- var filterEmptyAttrs = function (attrs) {
92
- var result = {};
93
- for (var attr in attrs) {
88
+ const filterEmptyAttrs = (attrs) => {
89
+ const result = {};
90
+ for (const attr in attrs) {
94
91
  if (attr && (attrs[attr] || attrs[attr] === 0)) {
95
92
  result[attr] = attrs[attr];
96
93
  }
@@ -100,12 +97,12 @@ var filterEmptyAttrs = function (attrs) {
100
97
  /**
101
98
  * Inserts the given node at the place of current selection.
102
99
  */
103
- export var insertNode = function (node, scrollIntoView) { return function (state, dispatch) {
104
- var selection = state.selection, tr = state.tr;
100
+ const insertNode = (node, scrollIntoView) => (state, dispatch) => {
101
+ const { selection, tr } = state;
105
102
  if (selection instanceof NodeSelection
106
103
  && selection.node.type.name === node.type.name
107
104
  && node.isLeaf && !node.isText && node.nodeSize === 1) {
108
- tr.setNodeMarkup(selection.from, null, __assign(__assign({}, filterEmptyAttrs(selection.node.attrs)), filterEmptyAttrs(node.attrs)));
105
+ tr.setNodeMarkup(selection.from, null, { ...filterEmptyAttrs(selection.node.attrs), ...filterEmptyAttrs(node.attrs) });
109
106
  tr.setSelection(NodeSelection.create(tr.doc, selection.from));
110
107
  }
111
108
  else {
@@ -115,21 +112,16 @@ export var insertNode = function (node, scrollIntoView) { return function (state
115
112
  tr.scrollIntoView();
116
113
  }
117
114
  dispatch(tr);
118
- }; };
119
- export var hasSameMarkup = function (dom1, dom2, schema, parseOptions) {
120
- var fragment1 = Fragment.from(parseContent(dom1, schema, parseOptions));
121
- var fragment2 = Fragment.from(parseContent(dom2, schema, parseOptions));
122
- return fragment1.eq(fragment2);
123
115
  };
124
- export var getSelectionText = function (state) {
125
- var sel = state.selection;
116
+ const getSelectionText = (state) => {
117
+ const sel = state.selection;
126
118
  if (sel instanceof TextSelection || sel instanceof AllSelection) {
127
- var fragment = sel.content().content;
119
+ const fragment = sel.content().content;
128
120
  return fragment.textBetween(0, fragment.size);
129
121
  }
130
122
  return '';
131
123
  };
132
- export var getNodeFromSelection = function (state) {
124
+ const getNodeFromSelection = (state) => {
133
125
  if (state.selection instanceof NodeSelection) {
134
126
  return state.selection.node;
135
127
  }
@@ -142,12 +134,12 @@ export var getNodeFromSelection = function (state) {
142
134
  * Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
143
135
  * should be single line text only.
144
136
  */
145
- export var selectedLineTextOnly = function (state) {
146
- var result = '', hasLeafs = false;
147
- var selection = state.selection, doc = state.doc;
148
- var $from = selection.$from, $to = selection.$to, from = selection.from, to = selection.to;
137
+ const selectedLineTextOnly = (state) => {
138
+ let result = '', hasLeafs = false;
139
+ const { selection, doc } = state;
140
+ const { $from, $to, from, to } = selection;
149
141
  if ($from.sameParent($to)) {
150
- doc.nodesBetween(from, to, function (node) {
142
+ doc.nodesBetween(from, to, (node) => {
151
143
  hasLeafs = hasLeafs || (node.isLeaf && !node.isText);
152
144
  });
153
145
  if (!hasLeafs) {
@@ -159,58 +151,55 @@ export var selectedLineTextOnly = function (state) {
159
151
  /**
160
152
  * Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
161
153
  */
162
- export var indentHtml = function (content) {
154
+ const indentHtml = (content) => {
163
155
  return content.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/ig, '</$1>\n')
164
156
  .replace(/<(ul|ol)([^>]*)><li/ig, '<$1$2>\n<li')
165
157
  .replace(/<br \/>/ig, '<br />\n')
166
158
  .replace(/\n$/, '');
167
159
  };
168
- export var shallowEqual = function (object1, object2) {
169
- var keys1 = Object.keys(object1);
170
- var keys2 = Object.keys(object2);
160
+ const shallowEqual = (object1, object2) => {
161
+ const keys1 = Object.keys(object1);
162
+ const keys2 = Object.keys(object2);
171
163
  return keys1.length === keys2.length &&
172
- keys1.every(function (k) { return object1[k] === object2[k]; });
164
+ keys1.every(k => object1[k] === object2[k]);
173
165
  };
174
- var applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
166
+ const applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
175
167
  /**
176
168
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
177
169
  * returns modified state and dispatch.
178
170
  */
179
- export var expandSelection = function (state, dispatch, options) {
171
+ const expandSelection = (state, dispatch, options) => {
180
172
  if (!options.applyToWord || !state.selection.empty) {
181
- return { state: state, dispatch: dispatch };
173
+ return { state, dispatch };
182
174
  }
183
- var applyToWordOptions = options.applyToWord === true ? applyToWordDefault : options.applyToWord;
184
- var initialPosition = null;
185
- var tr = state.tr;
186
- var selection = state.selection;
187
- var before = selection.$head.nodeBefore;
188
- var after = selection.$head.nodeAfter;
175
+ const applyToWordOptions = options.applyToWord === true ? applyToWordDefault : options.applyToWord;
176
+ let initialPosition = null;
177
+ const tr = state.tr;
178
+ const selection = state.selection;
179
+ const before = selection.$head.nodeBefore;
180
+ const after = selection.$head.nodeAfter;
189
181
  if (before && before.type.name === 'text' && before.text && after && after.type.name === 'text' && after.text) {
190
- var children_1 = [];
191
- selection.$head.parent.descendants(function (node, pos) {
192
- children_1.push({ node: node, pos: pos });
182
+ const children = [];
183
+ selection.$head.parent.descendants((node, pos) => {
184
+ children.push({ node, pos });
193
185
  return false;
194
186
  });
195
- var cursor_1 = selection.$head.parentOffset;
196
- var nodeIndex = children_1.findIndex(function (_a) {
197
- var node = _a.node, pos = _a.pos;
198
- return pos <= cursor_1 && pos + node.nodeSize >= cursor_1;
199
- });
200
- var text = children_1[nodeIndex].node.text;
201
- var skip = false;
202
- for (var i = nodeIndex - 1; i >= 0; i--) {
203
- var element = children_1[i];
187
+ let cursor = selection.$head.parentOffset;
188
+ const nodeIndex = children.findIndex(({ node, pos }) => pos <= cursor && pos + node.nodeSize >= cursor);
189
+ let text = children[nodeIndex].node.text;
190
+ let skip = false;
191
+ for (let i = nodeIndex - 1; i >= 0; i--) {
192
+ const element = children[i];
204
193
  if (!skip && element && element.node.type.name === 'text') {
205
194
  text = element.node.text + text;
206
195
  }
207
196
  else {
208
197
  skip = true;
209
- cursor_1 -= element.node.nodeSize;
198
+ cursor -= element.node.nodeSize;
210
199
  }
211
200
  }
212
- for (var i = nodeIndex + 1; i < children_1.length; i++) {
213
- var element = children_1[i];
201
+ for (let i = nodeIndex + 1; i < children.length; i++) {
202
+ const element = children[i];
214
203
  if (element && element.node.type.name === 'text') {
215
204
  text = text + element.node.text;
216
205
  }
@@ -218,30 +207,30 @@ export var expandSelection = function (state, dispatch, options) {
218
207
  break;
219
208
  }
220
209
  }
221
- var textBefore = text.substring(0, cursor_1);
222
- var textAfter = text.substring(cursor_1);
223
- var matchBefore = applyToWordOptions.before.exec(textBefore);
224
- var matchAfter = applyToWordOptions.after.exec(textAfter);
210
+ const textBefore = text.substring(0, cursor);
211
+ const textAfter = text.substring(cursor);
212
+ const matchBefore = applyToWordOptions.before.exec(textBefore);
213
+ const matchAfter = applyToWordOptions.after.exec(textAfter);
225
214
  if (matchBefore && matchAfter) {
226
- var extendLeft = matchBefore[0].length;
227
- var extendRight = matchAfter[0].length;
228
- var pos = initialPosition = selection.from;
215
+ const extendLeft = matchBefore[0].length;
216
+ const extendRight = matchAfter[0].length;
217
+ const pos = initialPosition = selection.from;
229
218
  tr.setSelection(TextSelection.create(state.doc, pos - extendLeft, pos + extendRight));
230
- var cmdState = {
231
- tr: tr,
219
+ const cmdState = {
220
+ tr,
232
221
  selection: tr.selection,
233
222
  doc: tr.doc,
234
223
  storedMarks: null,
235
224
  schema: tr.doc.type.schema
236
225
  };
237
- var cmdDispatch = function (tran) {
226
+ const cmdDispatch = tran => {
238
227
  tran.setSelection(TextSelection.create(tran.doc, initialPosition));
239
228
  dispatch(tran);
240
229
  };
241
230
  return { state: cmdState, dispatch: cmdDispatch };
242
231
  }
243
232
  }
244
- return { state: state, dispatch: dispatch };
233
+ return { state, dispatch };
245
234
  };
246
235
  /**
247
236
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
@@ -255,34 +244,34 @@ export var expandSelection = function (state, dispatch, options) {
255
244
  * const command = expandToWordWrap(toggleInlineFormat, {...bold, applyToWord );
256
245
  * command(view.state, view.dispatch);
257
246
  */
258
- export var expandToWordWrap = function (command, options) {
259
- return function (state, dispatch) {
260
- var _a = expandSelection(state, dispatch, options), cmdState = _a.state, cmdDispatch = _a.dispatch;
247
+ const expandToWordWrap = (command, options) => {
248
+ return (state, dispatch) => {
249
+ const { state: cmdState, dispatch: cmdDispatch } = expandSelection(state, dispatch, options);
261
250
  return command(options)(cmdState, cmdDispatch);
262
251
  };
263
252
  };
264
- export var parseStyle = function (styleText) {
253
+ const parseStyle = (styleText) => {
265
254
  return parseInlineStyles(styleText);
266
255
  };
267
- export var applyStyle = function (styleText, styleType, styleValue) {
268
- var styles = parseStyle(styleText);
256
+ const applyStyle = (styleText, styleType, styleValue) => {
257
+ const styles = parseStyle(styleText);
269
258
  styles[styleType] = styleValue;
270
- var result = Object.keys(styles)
271
- .map(function (name) { return styles[name] ? "".concat(name, ": ").concat(styles[name]) : null; })
259
+ const result = Object.keys(styles)
260
+ .map(name => styles[name] ? `${name}: ${styles[name]}` : null)
272
261
  .filter(Boolean)
273
262
  .join('; ');
274
263
  return result ? result + ';' : null;
275
264
  };
276
- export var setStyleAttr = function (element, styleString) {
277
- var styles = parseStyle(styleString);
278
- for (var style in styles) {
265
+ const setStyleAttr = (element, styleString) => {
266
+ const styles = parseStyle(styleString);
267
+ for (const style in styles) {
279
268
  if (style && typeof element.style[style] !== 'undefined') {
280
269
  element.style[style] = styles[style];
281
270
  }
282
271
  }
283
272
  };
284
- export var setAttribute = function (node, attrName, value) {
285
- var current = node.getAttribute(attrName);
273
+ const setAttribute = (node, attrName, value) => {
274
+ const current = node.getAttribute(attrName);
286
275
  if (value !== undefined && value !== current) {
287
276
  if (attrName === 'style') {
288
277
  node.removeAttribute(attrName);
@@ -296,3 +285,5 @@ export var setAttribute = function (node, attrName, value) {
296
285
  node.removeAttribute(attrName);
297
286
  }
298
287
  };
288
+
289
+ export { applyStyle, canInsert, changeStylesString, expandSelection, expandToWordWrap, findNthParentNodeOfType, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, parseStyle, selectedLineTextOnly, setAttribute, setNodeStyle, setStyleAttr, shallowEqual };
@@ -1,20 +1,6 @@
1
- import { setAttribute } from './utils';
2
- export class DOMSerializer {
3
- /// Create a serializer. `nodes` should map node names to functions
4
- /// that take a node and return a description of the corresponding
5
- /// DOM. `marks` does the same for mark names, but also gets an
6
- /// argument that tells it whether the mark's content is block or
7
- /// inline content (for typical use, it'll always be inline). A mark
8
- /// serializer may be `null` to indicate that marks of that type
9
- /// should not be serialized.
10
- constructor(
11
- /// The node serialization functions.
12
- nodes,
13
- /// The mark serialization functions.
14
- marks) {
15
- this.nodes = nodes;
16
- this.marks = marks;
17
- }
1
+ import { setAttribute } from './utils.js';
2
+
3
+ class DOMSerializer {
18
4
  /// Render an [output spec](#model.DOMOutputSpec) to a DOM node. If
19
5
  /// the spec has a hole (zero) in it, `contentDOM` will point at the
20
6
  /// node with the hole.
@@ -90,6 +76,21 @@ export class DOMSerializer {
90
76
  static marksFromSchema(schema) {
91
77
  return gatherToDOM(schema.marks);
92
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
+ }
93
94
  /// Serialize the content of this fragment to a DOM fragment. When
94
95
  /// not in the browser, the `document` option, containing a DOM
95
96
  /// document, should be passed so that the serializer can create
@@ -179,3 +180,5 @@ function gatherToDOM(obj) {
179
180
  function doc(options) {
180
181
  return options.document || window.document;
181
182
  }
183
+
184
+ export { DOMSerializer };
@@ -1,10 +1,11 @@
1
- import { blockNodes, addStyles, changeTextBlock } from './blockNode';
1
+ import { blockNodes, addStyles, changeTextBlock } from './blockNode.js';
2
+
2
3
  /**
3
4
  * Aligning block elements in the selection.
4
5
  *
5
6
  * @returns {boolean} - Returns true if any alignment is applied.
6
7
  */
7
- export const alignBlocks = (actions, commandName) => (state, dispatch) => {
8
+ const alignBlocks = (actions, commandName) => (state, dispatch) => {
8
9
  const blocks = blockNodes(state);
9
10
  const tr = state.tr;
10
11
  tr.setMeta('commandName', commandName);
@@ -23,7 +24,7 @@ export const alignBlocks = (actions, commandName) => (state, dispatch) => {
23
24
  }
24
25
  return result;
25
26
  };
26
- export const isAligned = (state, actions) => {
27
+ const isAligned = (state, actions) => {
27
28
  const blocks = blockNodes(state);
28
29
  let result = false;
29
30
  blocks.forEach(node => {
@@ -38,3 +39,5 @@ export const isAligned = (state, actions) => {
38
39
  });
39
40
  return result;
40
41
  };
42
+
43
+ export { alignBlocks, isAligned };
@@ -1,8 +1,9 @@
1
- import { __rest } from "tslib";
2
- import { changeStylesString } from './utils';
1
+ import { __rest } from './node_modules/tslib/tslib.es6.js';
2
+ import { changeStylesString } from './utils.js';
3
3
  import { ReplaceAroundStep } from 'prosemirror-transform';
4
- import { Fragment, Slice } from 'prosemirror-model';
4
+ import { Slice, Fragment } from 'prosemirror-model';
5
5
  import { NodeSelection } from 'prosemirror-state';
6
+
6
7
  /**
7
8
  * @hidden
8
9
  */
@@ -16,7 +17,7 @@ const canChangeType = (stateDoc, pos, type) => {
16
17
  * @example
17
18
  * See `cleanTextBlockFormatting` or `formatBlockElements` function.
18
19
  */
19
- export const changeTextBlock = (tr, node, nodeType, attrs) => {
20
+ const changeTextBlock = (tr, node, nodeType, attrs) => {
20
21
  if (!nodeType.isTextblock) {
21
22
  return false;
22
23
  }
@@ -47,7 +48,7 @@ export const changeTextBlock = (tr, node, nodeType, attrs) => {
47
48
  * @example
48
49
  * See `cleanTextBlockFormatting` function.
49
50
  */
50
- export const blockNodes = (state, options = { blocksInSelection: false }) => {
51
+ const blockNodes = (state, options = { blocksInSelection: false }) => {
51
52
  const { doc, selection } = state;
52
53
  const { $from, ranges } = selection;
53
54
  const { blocksInSelection } = options;
@@ -79,7 +80,7 @@ export const blockNodes = (state, options = { blocksInSelection: false }) => {
79
80
  }
80
81
  return result;
81
82
  };
82
- export const formatBlockElements = (value, commandName) => (state, dispatch) => {
83
+ const formatBlockElements = (value, commandName) => (state, dispatch) => {
83
84
  const blocks = blockNodes(state);
84
85
  const nodes = state.schema.nodes;
85
86
  const tr = state.tr;
@@ -112,7 +113,7 @@ export const formatBlockElements = (value, commandName) => (state, dispatch) =>
112
113
  * @example
113
114
  * See `cleanFormatting` function.
114
115
  */
115
- export const cleanTextBlockFormatting = (tr, options = { blocksInSelection: true }) => {
116
+ const cleanTextBlockFormatting = (tr, options = { blocksInSelection: true }) => {
116
117
  const { doc, selection } = tr;
117
118
  const { blocksInSelection, blockNodeType } = options;
118
119
  const nodes = blockNodes({ doc, selection }, { blocksInSelection });
@@ -125,7 +126,7 @@ export const cleanTextBlockFormatting = (tr, options = { blocksInSelection: true
125
126
  }
126
127
  });
127
128
  };
128
- export const getBlockFormats = (state) => {
129
+ const getBlockFormats = (state) => {
129
130
  const blocks = blockNodes(state);
130
131
  const nodes = state.schema.nodes;
131
132
  const result = [];
@@ -143,7 +144,7 @@ export const getBlockFormats = (state) => {
143
144
  });
144
145
  return result;
145
146
  };
146
- export const addStyles = (node, stylesToApply) => {
147
+ const addStyles = (node, stylesToApply) => {
147
148
  let currentStyles = node.attrs.style, changedStyleResult, toChange;
148
149
  if (currentStyles) {
149
150
  stylesToApply.forEach(style => {
@@ -156,7 +157,7 @@ export const addStyles = (node, stylesToApply) => {
156
157
  currentStyles = currentStyles || stylesToApply.reduce(reducer, '');
157
158
  return Object.assign({}, node.attrs, { style: currentStyles || null });
158
159
  };
159
- export const hasNode = (state, nodeType) => {
160
+ const hasNode = (state, nodeType) => {
160
161
  const { from, to } = state.selection;
161
162
  let result = false;
162
163
  state.doc.nodesBetween(from, to, node => {
@@ -165,13 +166,15 @@ export const hasNode = (state, nodeType) => {
165
166
  });
166
167
  return result;
167
168
  };
168
- export const parentBlockFormat = (state) => {
169
+ const parentBlockFormat = (state) => {
169
170
  const formats = getBlockFormats(state);
170
171
  return new Set(formats).size === 1 ? formats[0] : null;
171
172
  };
172
173
  /**
173
174
  * **Deprecated.** Use `parentBlockFormat` function instead.
174
175
  */
175
- export const activeNode = (state) => {
176
+ const activeNode = (state) => {
176
177
  return { tag: parentBlockFormat(state) || '' };
177
178
  };
179
+
180
+ export { activeNode, addStyles, blockNodes, changeTextBlock, cleanTextBlockFormatting, formatBlockElements, getBlockFormats, hasNode, parentBlockFormat };
@@ -1,8 +1,9 @@
1
1
  import { wrapIn } from 'prosemirror-commands';
2
- export const blockquote = (state, dispatch) => {
2
+
3
+ const blockquote = (state, dispatch) => {
3
4
  return wrapIn(state.schema.nodes.blockquote)(state, dispatch);
4
5
  };
5
- export const liftBlockquote = (state, dispatch) => {
6
+ const liftBlockquote = (state, dispatch) => {
6
7
  const { $from, $to } = state.selection;
7
8
  const nodeType = state.schema.nodes.blockquote;
8
9
  const doc = state.doc;
@@ -21,3 +22,5 @@ export const liftBlockquote = (state, dispatch) => {
21
22
  }
22
23
  return result;
23
24
  };
25
+
26
+ export { blockquote, liftBlockquote };
@@ -1,9 +1,10 @@
1
- import { cleanTextBlockFormatting } from './blockNode';
2
- import { cleanMarks } from './mark';
1
+ import { cleanTextBlockFormatting } from './blockNode.js';
2
+ import { cleanMarks } from './mark.js';
3
+
3
4
  /**
4
5
  * A command which removes the inline formatting, class and style attributes of paragraph and heading elements in the selection.
5
6
  */
6
- export const cleanFormatting = (options = { blocksInSelection: true }) => (state, dispatch) => {
7
+ const cleanFormatting = (options = { blocksInSelection: true }) => (state, dispatch) => {
7
8
  const tr = state.tr;
8
9
  const { blocksInSelection, blockNodeType, exceptMarks } = options;
9
10
  const except = (exceptMarks || [state.schema.marks.link]).filter(Boolean);
@@ -15,3 +16,5 @@ export const cleanFormatting = (options = { blocksInSelection: true }) => (state
15
16
  }
16
17
  return result;
17
18
  };
19
+
20
+ export { cleanFormatting };
@@ -1,28 +1,30 @@
1
1
  const style = (name, value) => {
2
2
  return { name: name, value: value };
3
3
  };
4
- export const alignLeftRules = [
4
+ const alignLeftRules = [
5
5
  { node: 'paragraph', style: [style('text-align', 'left')] },
6
6
  { node: 'heading', style: [style('text-align', 'left')] },
7
7
  { node: 'table_caption_external', style: [style('text-align', 'left')] }
8
8
  ];
9
- export const alignRightRules = [
9
+ const alignRightRules = [
10
10
  { node: 'paragraph', style: [style('text-align', 'right')] },
11
11
  { node: 'heading', style: [style('text-align', 'right')] },
12
12
  { node: 'table_caption_external', style: [style('text-align', 'right')] }
13
13
  ];
14
- export const alignCenterRules = [
14
+ const alignCenterRules = [
15
15
  { node: 'paragraph', style: [style('text-align', 'center')] },
16
16
  { node: 'heading', style: [style('text-align', 'center')] },
17
17
  { node: 'table_caption_external', style: [style('text-align', 'center')] }
18
18
  ];
19
- export const alignJustifyRules = [
19
+ const alignJustifyRules = [
20
20
  { node: 'paragraph', style: [style('text-align', 'justify')] },
21
21
  { node: 'heading', style: [style('text-align', 'justify')] },
22
22
  { node: 'table_caption_external', style: [style('text-align', 'justify')] }
23
23
  ];
24
- export const alignRemoveRules = [
24
+ const alignRemoveRules = [
25
25
  { node: 'paragraph', style: [style('text-align', '')] },
26
26
  { node: 'heading', style: [style('text-align', '')] },
27
27
  { node: 'table_caption_external', style: [style('text-align', '')] }
28
28
  ];
29
+
30
+ export { alignCenterRules, alignJustifyRules, alignLeftRules, alignRemoveRules, alignRightRules };