@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
@@ -1,25 +1,10 @@
1
- import { setAttribute } from './utils';
2
- var DOMSerializer = /** @class */ (function () {
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
- function DOMSerializer(
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.
21
- DOMSerializer.renderSpec = function (docum, structure, xmlNS) {
22
- if (xmlNS === void 0) { xmlNS = null; }
7
+ static renderSpec(docum, structure, xmlNS = null) {
23
8
  if (typeof structure === 'string') {
24
9
  return { dom: docum.createTextNode(structure) };
25
10
  }
@@ -29,38 +14,38 @@ var DOMSerializer = /** @class */ (function () {
29
14
  if (structure.dom && structure.dom.nodeType != null) {
30
15
  return structure;
31
16
  }
32
- var tagName = structure[0], space = tagName.indexOf(' ');
17
+ let tagName = structure[0], space = tagName.indexOf(' ');
33
18
  if (space > 0) {
34
19
  xmlNS = tagName.slice(0, space);
35
20
  tagName = tagName.slice(space + 1);
36
21
  }
37
- var contentDOM;
38
- var dom = (xmlNS ? docum.createElementNS(xmlNS, tagName) : docum.createElement(tagName));
39
- var attrs = structure[1], start = 1;
22
+ let contentDOM;
23
+ const dom = (xmlNS ? docum.createElementNS(xmlNS, tagName) : docum.createElement(tagName));
24
+ let attrs = structure[1], start = 1;
40
25
  if (attrs && typeof attrs === 'object' && attrs.nodeType == null && !Array.isArray(attrs)) {
41
26
  start = 2;
42
- for (var name_1 in attrs) {
43
- if (attrs[name_1] != null) {
44
- space = name_1.indexOf(' ');
27
+ for (const name in attrs) {
28
+ if (attrs[name] != null) {
29
+ space = name.indexOf(' ');
45
30
  if (space > 0) {
46
- dom.setAttributeNS(name_1.slice(0, space), name_1.slice(space + 1), attrs[name_1]);
31
+ dom.setAttributeNS(name.slice(0, space), name.slice(space + 1), attrs[name]);
47
32
  }
48
33
  else {
49
- setAttribute(dom, name_1, attrs[name_1]);
34
+ setAttribute(dom, name, attrs[name]);
50
35
  }
51
36
  }
52
37
  }
53
38
  }
54
- for (var i = start; i < structure.length; i++) {
55
- var child = structure[i];
39
+ for (let i = start; i < structure.length; i++) {
40
+ const child = structure[i];
56
41
  if (child === 0) {
57
42
  if (i < structure.length - 1 || i > start) {
58
43
  throw new RangeError('Content hole must be the only child of its parent node');
59
44
  }
60
- return { dom: dom, contentDOM: dom };
45
+ return { dom, contentDOM: dom };
61
46
  }
62
47
  else {
63
- var _a = DOMSerializer.renderSpec(docum, child, xmlNS), inner = _a.dom, innerContent = _a.contentDOM;
48
+ const { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(docum, child, xmlNS);
64
49
  dom.appendChild(inner);
65
50
  if (innerContent) {
66
51
  if (contentDOM) {
@@ -70,44 +55,57 @@ var DOMSerializer = /** @class */ (function () {
70
55
  }
71
56
  }
72
57
  }
73
- return { dom: dom, contentDOM: contentDOM };
74
- };
58
+ return { dom, contentDOM };
59
+ }
75
60
  /// Build a serializer using the [`toDOM`](#model.NodeSpec.toDOM)
76
61
  /// properties in a schema's node and mark specs.
77
- DOMSerializer.fromSchema = function (schema) {
62
+ static fromSchema(schema) {
78
63
  return schema.cached.domSerializer ||
79
64
  (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));
80
- };
65
+ }
81
66
  /// Gather the serializers in a schema's node specs into an object.
82
67
  /// This can be useful as a base to build a custom serializer from.
83
- DOMSerializer.nodesFromSchema = function (schema) {
84
- var result = gatherToDOM(schema.nodes);
68
+ static nodesFromSchema(schema) {
69
+ const result = gatherToDOM(schema.nodes);
85
70
  if (!result.text) {
86
- result.text = function (node) { return node.text; };
71
+ result.text = node => node.text;
87
72
  }
88
73
  return result;
89
- };
74
+ }
90
75
  /// Gather the serializers in a schema's mark specs into an object.
91
- DOMSerializer.marksFromSchema = function (schema) {
76
+ static marksFromSchema(schema) {
92
77
  return gatherToDOM(schema.marks);
93
- };
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
94
  /// Serialize the content of this fragment to a DOM fragment. When
95
95
  /// not in the browser, the `document` option, containing a DOM
96
96
  /// document, should be passed so that the serializer can create
97
97
  /// nodes.
98
- DOMSerializer.prototype.serializeFragment = function (fragment, options, target) {
99
- var _this = this;
100
- if (options === void 0) { options = {}; }
98
+ serializeFragment(fragment, options = {}, target) {
101
99
  if (!target) {
102
100
  target = doc(options).createDocumentFragment();
103
101
  }
104
- var top = target, active = [];
105
- fragment.forEach(function (node) {
102
+ let top = target, active = [];
103
+ fragment.forEach(node => {
106
104
  if (active.length || node.marks.length) {
107
- var keep = 0, rendered = 0;
105
+ let keep = 0, rendered = 0;
108
106
  while (keep < active.length && rendered < node.marks.length) {
109
- var next = node.marks[rendered];
110
- if (!_this.marks[next.type.name]) {
107
+ const next = node.marks[rendered];
108
+ if (!this.marks[next.type.name]) {
111
109
  rendered++;
112
110
  continue;
113
111
  }
@@ -121,8 +119,8 @@ var DOMSerializer = /** @class */ (function () {
121
119
  top = active.pop()[1];
122
120
  }
123
121
  while (rendered < node.marks.length) {
124
- var add = node.marks[rendered++];
125
- var markDOM = _this.serializeMark(add, node.isInline, options);
122
+ const add = node.marks[rendered++];
123
+ const markDOM = this.serializeMark(add, node.isInline, options);
126
124
  if (markDOM) {
127
125
  active.push([add, top]);
128
126
  top.appendChild(markDOM.dom);
@@ -130,36 +128,34 @@ var DOMSerializer = /** @class */ (function () {
130
128
  }
131
129
  }
132
130
  }
133
- top.appendChild(_this.serializeNodeInner(node, options));
131
+ top.appendChild(this.serializeNodeInner(node, options));
134
132
  });
135
133
  return target;
136
- };
134
+ }
137
135
  /// Serialize this node to a DOM node. This can be useful when you
138
136
  /// need to serialize a part of a document, as opposed to the whole
139
137
  /// document. To serialize a whole document, use
140
138
  /// [`serializeFragment`](#model.DOMSerializer.serializeFragment) on
141
139
  /// its [content](#model.Node.content).
142
- DOMSerializer.prototype.serializeNode = function (node, options) {
143
- if (options === void 0) { options = {}; }
144
- var dom = this.serializeNodeInner(node, options);
145
- for (var i = node.marks.length - 1; i >= 0; i--) {
146
- var wrap = this.serializeMark(node.marks[i], node.isInline, options);
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);
147
144
  if (wrap) {
148
145
  (wrap.contentDOM || wrap.dom).appendChild(dom);
149
146
  dom = wrap.dom;
150
147
  }
151
148
  }
152
149
  return dom;
153
- };
150
+ }
154
151
  /// @internal
155
- DOMSerializer.prototype.serializeMark = function (mark, inline, options) {
156
- if (options === void 0) { options = {}; }
157
- var toDOM = this.marks[mark.type.name];
152
+ serializeMark(mark, inline, options = {}) {
153
+ const toDOM = this.marks[mark.type.name];
158
154
  return toDOM && DOMSerializer.renderSpec(doc(options), toDOM(mark, inline));
159
- };
155
+ }
160
156
  /// @internal
161
- DOMSerializer.prototype.serializeNodeInner = function (node, options) {
162
- var _a = DOMSerializer.renderSpec(doc(options), this.nodes[node.type.name](node)), dom = _a.dom, contentDOM = _a.contentDOM;
157
+ serializeNodeInner(node, options) {
158
+ const { dom, contentDOM } = DOMSerializer.renderSpec(doc(options), this.nodes[node.type.name](node));
163
159
  if (contentDOM) {
164
160
  if (node.isLeaf) {
165
161
  throw new RangeError('Content hole not allowed in a leaf node spec');
@@ -167,17 +163,15 @@ var DOMSerializer = /** @class */ (function () {
167
163
  this.serializeFragment(node.content, options, contentDOM);
168
164
  }
169
165
  return dom;
170
- };
171
- return DOMSerializer;
172
- }());
173
- export { DOMSerializer };
166
+ }
167
+ }
174
168
  function gatherToDOM(obj) {
175
- var result = {};
176
- for (var name_2 in obj) {
177
- if (obj[name_2]) {
178
- var toDOM = obj[name_2].spec.toDOM;
169
+ const result = {};
170
+ for (const name in obj) {
171
+ if (obj[name]) {
172
+ const toDOM = obj[name].spec.toDOM;
179
173
  if (toDOM) {
180
- result[name_2] = toDOM;
174
+ result[name] = toDOM;
181
175
  }
182
176
  }
183
177
  }
@@ -186,3 +180,5 @@ function gatherToDOM(obj) {
186
180
  function doc(options) {
187
181
  return options.document || window.document;
188
182
  }
183
+
184
+ export { DOMSerializer };
package/dist/es/align.js CHANGED
@@ -1,40 +1,43 @@
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 var alignBlocks = function (actions, commandName) { return function (state, dispatch) {
8
- var blocks = blockNodes(state);
9
- var tr = state.tr;
8
+ const alignBlocks = (actions, commandName) => (state, dispatch) => {
9
+ const blocks = blockNodes(state);
10
+ const tr = state.tr;
10
11
  tr.setMeta('commandName', commandName);
11
- blocks.forEach(function (node) {
12
+ blocks.forEach(node => {
12
13
  if (node.type.isTextblock) {
13
- var action = actions.find(function (n) { return n.node === node.type.name; });
14
+ const action = actions.find(n => n.node === node.type.name);
14
15
  if (action) {
15
- var newAttrs = addStyles(node, action.style);
16
+ const newAttrs = addStyles(node, action.style);
16
17
  changeTextBlock(tr, node, node.type, newAttrs);
17
18
  }
18
19
  }
19
20
  });
20
- var result = tr.docChanged;
21
+ const result = tr.docChanged;
21
22
  if (result) {
22
23
  dispatch(tr.scrollIntoView());
23
24
  }
24
25
  return result;
25
- }; };
26
- export var isAligned = function (state, actions) {
27
- var blocks = blockNodes(state);
28
- var result = false;
29
- blocks.forEach(function (node) {
26
+ };
27
+ const isAligned = (state, actions) => {
28
+ const blocks = blockNodes(state);
29
+ let result = false;
30
+ blocks.forEach(node => {
30
31
  if (!result && node.type.isTextblock && node.attrs.style) {
31
- var action = actions.find(function (a) { return a.node === node.type.name; });
32
+ const action = actions.find(a => a.node === node.type.name);
32
33
  if (action) {
33
- result = action.style.every(function (style) {
34
- return !!style.value && new RegExp("".concat(style.name, ":\\s?").concat(style.value), 'i').test(node.attrs.style);
34
+ result = action.style.every(style => {
35
+ return !!style.value && new RegExp(`${style.name}:\\s?${style.value}`, 'i').test(node.attrs.style);
35
36
  });
36
37
  }
37
38
  }
38
39
  });
39
40
  return result;
40
41
  };
42
+
43
+ export { alignBlocks, isAligned };
@@ -1,13 +1,13 @@
1
- import { __assign, __rest } from "tslib";
2
- import { changeStylesString } from './utils';
1
+ import { changeStylesString } from './utils.js';
3
2
  import { ReplaceAroundStep } from 'prosemirror-transform';
4
- import { Fragment, Slice } from 'prosemirror-model';
3
+ import { Slice, Fragment } from 'prosemirror-model';
5
4
  import { NodeSelection } from 'prosemirror-state';
5
+
6
6
  /**
7
7
  * @hidden
8
8
  */
9
- var canChangeType = function (stateDoc, pos, type) {
10
- var $pos = stateDoc.resolve(pos), index = $pos.index();
9
+ const canChangeType = (stateDoc, pos, type) => {
10
+ const $pos = stateDoc.resolve(pos), index = $pos.index();
11
11
  return $pos.parent.canReplaceWith(index, index + 1, type);
12
12
  };
13
13
  /**
@@ -16,25 +16,25 @@ var canChangeType = function (stateDoc, pos, type) {
16
16
  * @example
17
17
  * See `cleanTextBlockFormatting` or `formatBlockElements` function.
18
18
  */
19
- export var changeTextBlock = function (tr, node, nodeType, attrs) {
19
+ const changeTextBlock = (tr, node, nodeType, attrs) => {
20
20
  if (!nodeType.isTextblock) {
21
21
  return false;
22
22
  }
23
- var ranges = tr.selection.ranges;
24
- ranges.forEach(function (range) {
25
- var mapFrom = tr.steps.length;
26
- var from = range.$from.pos;
27
- var to = range.$to.pos;
28
- tr.doc.nodesBetween(from, to, function (currNode, pos) {
23
+ const { ranges } = tr.selection;
24
+ ranges.forEach(range => {
25
+ const mapFrom = tr.steps.length;
26
+ const from = range.$from.pos;
27
+ const to = range.$to.pos;
28
+ tr.doc.nodesBetween(from, to, (currNode, pos) => {
29
29
  if (currNode.eq(node) &&
30
30
  currNode.isTextblock &&
31
31
  !currNode.hasMarkup(nodeType, attrs) &&
32
32
  canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), nodeType)) {
33
33
  // Ensure all markup that isn't allowed in the new node type is cleared
34
34
  tr.clearIncompatible(tr.mapping.slice(mapFrom).map(pos, 1), nodeType);
35
- var mapping = tr.mapping.slice(mapFrom);
36
- var startM = mapping.map(pos, 1), endM = mapping.map(pos + currNode.nodeSize, 1);
37
- var slice = new Slice(Fragment.from(nodeType.create(attrs, null, currNode.marks)), 0, 0);
35
+ const mapping = tr.mapping.slice(mapFrom);
36
+ const startM = mapping.map(pos, 1), endM = mapping.map(pos + currNode.nodeSize, 1);
37
+ const slice = new Slice(Fragment.from(nodeType.create(attrs, null, currNode.marks)), 0, 0);
38
38
  tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, slice, 1, true));
39
39
  return false; // this will skip the node children
40
40
  }
@@ -47,17 +47,16 @@ export var changeTextBlock = function (tr, node, nodeType, attrs) {
47
47
  * @example
48
48
  * See `cleanTextBlockFormatting` function.
49
49
  */
50
- export var blockNodes = function (state, options) {
51
- if (options === void 0) { options = { blocksInSelection: false }; }
52
- var doc = state.doc, selection = state.selection;
53
- var $from = selection.$from, ranges = selection.ranges;
54
- var blocksInSelection = options.blocksInSelection;
55
- var result = [];
56
- var selNode = selection instanceof NodeSelection ? selection.node : undefined;
50
+ const blockNodes = (state, options = { blocksInSelection: false }) => {
51
+ const { doc, selection } = state;
52
+ const { $from, ranges } = selection;
53
+ const { blocksInSelection } = options;
54
+ const result = [];
55
+ const selNode = selection instanceof NodeSelection ? selection.node : undefined;
57
56
  if (selNode) {
58
57
  if (selNode.isBlock) {
59
58
  result.push(selNode);
60
- selNode.nodesBetween(0, selNode.content.size, function (node) {
59
+ selNode.nodesBetween(0, selNode.content.size, node => {
61
60
  if (node.isBlock) {
62
61
  result.push(node);
63
62
  }
@@ -68,10 +67,10 @@ export var blockNodes = function (state, options) {
68
67
  }
69
68
  }
70
69
  else {
71
- ranges.forEach(function (range) {
72
- var from = range.$from.pos;
73
- var to = range.$to.pos;
74
- doc.nodesBetween(from, to, function (node, pos) {
70
+ ranges.forEach(range => {
71
+ const from = range.$from.pos;
72
+ const to = range.$to.pos;
73
+ doc.nodesBetween(from, to, (node, pos) => {
75
74
  if (node.isBlock && (!blocksInSelection || (pos >= from && pos + node.content.size + 2 <= to))) {
76
75
  result.push(node);
77
76
  }
@@ -80,33 +79,31 @@ export var blockNodes = function (state, options) {
80
79
  }
81
80
  return result;
82
81
  };
83
- export var formatBlockElements = function (value, commandName) {
84
- return function (state, dispatch) {
85
- var blocks = blockNodes(state);
86
- var nodes = state.schema.nodes;
87
- var tr = state.tr;
88
- tr.setMeta('commandName', commandName);
89
- tr.setMeta('args', { value: value });
90
- blocks.forEach(function (node) {
91
- if (node.type.isTextblock) {
92
- if (value === 'p') {
93
- changeTextBlock(tr, node, nodes.paragraph, node.attrs);
94
- }
95
- else if (/^h[1-6]$/i.test(value)) {
96
- var level = parseInt(value.substr(1), 10);
97
- changeTextBlock(tr, node, nodes.heading, __assign(__assign({}, node.attrs), { level: level }));
98
- }
99
- else if (value === 'blockquote') {
100
- changeTextBlock(tr, node, nodes.blockquote, node.attrs);
101
- }
82
+ const formatBlockElements = (value, commandName) => (state, dispatch) => {
83
+ const blocks = blockNodes(state);
84
+ const nodes = state.schema.nodes;
85
+ const tr = state.tr;
86
+ tr.setMeta('commandName', commandName);
87
+ tr.setMeta('args', { value });
88
+ blocks.forEach(node => {
89
+ if (node.type.isTextblock) {
90
+ if (value === 'p') {
91
+ changeTextBlock(tr, node, nodes.paragraph, node.attrs);
92
+ }
93
+ else if (/^h[1-6]$/i.test(value)) {
94
+ const level = parseInt(value.substr(1), 10);
95
+ changeTextBlock(tr, node, nodes.heading, { ...node.attrs, level });
96
+ }
97
+ else if (value === 'blockquote') {
98
+ changeTextBlock(tr, node, nodes.blockquote, node.attrs);
102
99
  }
103
- });
104
- var result = tr.docChanged;
105
- if (result) {
106
- dispatch(tr.scrollIntoView());
107
100
  }
108
- return result;
109
- };
101
+ });
102
+ const result = tr.docChanged;
103
+ if (result) {
104
+ dispatch(tr.scrollIntoView());
105
+ }
106
+ return result;
110
107
  };
111
108
  /**
112
109
  * Removes the style and class attributes of text block elements.
@@ -115,30 +112,29 @@ export var formatBlockElements = function (value, commandName) {
115
112
  * @example
116
113
  * See `cleanFormatting` function.
117
114
  */
118
- export var cleanTextBlockFormatting = function (tr, options) {
119
- if (options === void 0) { options = { blocksInSelection: true }; }
120
- var doc = tr.doc, selection = tr.selection;
121
- var blocksInSelection = options.blocksInSelection, blockNodeType = options.blockNodeType;
122
- var nodes = blockNodes({ doc: doc, selection: selection }, { blocksInSelection: blocksInSelection });
123
- var textBlocks = nodes.filter(function (node) { return node.isTextblock; });
124
- textBlocks.forEach(function (node) {
125
- var _a = node.attrs || {}, _b = _a.style, style = _b === void 0 ? '' : _b, _c = _a.class, className = _c === void 0 ? '' : _c, attrs = __rest(_a, ["style", "class"]);
126
- var nodeType = blockNodeType || node.type;
115
+ const cleanTextBlockFormatting = (tr, options = { blocksInSelection: true }) => {
116
+ const { doc, selection } = tr;
117
+ const { blocksInSelection, blockNodeType } = options;
118
+ const nodes = blockNodes({ doc, selection }, { blocksInSelection });
119
+ const textBlocks = nodes.filter(node => node.isTextblock);
120
+ textBlocks.forEach(node => {
121
+ const { style = '', class: className = '', ...attrs } = node.attrs || {};
122
+ const nodeType = blockNodeType || node.type;
127
123
  if (style || className || nodeType !== node.type) {
128
124
  changeTextBlock(tr, node, nodeType, attrs);
129
125
  }
130
126
  });
131
127
  };
132
- export var getBlockFormats = function (state) {
133
- var blocks = blockNodes(state);
134
- var nodes = state.schema.nodes;
135
- var result = [];
136
- blocks.forEach(function (node) {
128
+ const getBlockFormats = (state) => {
129
+ const blocks = blockNodes(state);
130
+ const nodes = state.schema.nodes;
131
+ const result = [];
132
+ blocks.forEach((node) => {
137
133
  if (node.type === nodes.paragraph) {
138
134
  result.push('p');
139
135
  }
140
136
  else if (node.type === nodes.heading) {
141
- result.push("h".concat(node.attrs.level));
137
+ result.push(`h${node.attrs.level}`);
142
138
  }
143
139
  else if (node.type === nodes.blockquote && nodes.blockquote.isTextblock) {
144
140
  // In case the blockquote can have inline content.
@@ -147,35 +143,37 @@ export var getBlockFormats = function (state) {
147
143
  });
148
144
  return result;
149
145
  };
150
- export var addStyles = function (node, stylesToApply) {
151
- var currentStyles = node.attrs.style, changedStyleResult, toChange;
146
+ const addStyles = (node, stylesToApply) => {
147
+ let currentStyles = node.attrs.style, changedStyleResult, toChange;
152
148
  if (currentStyles) {
153
- stylesToApply.forEach(function (style) {
149
+ stylesToApply.forEach(style => {
154
150
  toChange = { style: style.name, value: /^.+$/, newValue: style.value };
155
151
  changedStyleResult = changeStylesString(currentStyles, toChange);
156
152
  currentStyles = changedStyleResult.changed ? changedStyleResult.style : currentStyles;
157
153
  });
158
154
  }
159
- var reducer = function (acc, curr) { return ((acc && curr.value ? acc + ' ' : '') + curr.value ? "".concat(curr.name, ": ").concat(curr.value, ";") : ''); };
155
+ const reducer = (acc, curr) => ((acc && curr.value ? acc + ' ' : '') + curr.value ? `${curr.name}: ${curr.value};` : '');
160
156
  currentStyles = currentStyles || stylesToApply.reduce(reducer, '');
161
157
  return Object.assign({}, node.attrs, { style: currentStyles || null });
162
158
  };
163
- export var hasNode = function (state, nodeType) {
164
- var _a = state.selection, from = _a.from, to = _a.to;
165
- var result = false;
166
- state.doc.nodesBetween(from, to, function (node) {
159
+ const hasNode = (state, nodeType) => {
160
+ const { from, to } = state.selection;
161
+ let result = false;
162
+ state.doc.nodesBetween(from, to, node => {
167
163
  result = result || node.type === nodeType;
168
164
  return !result;
169
165
  });
170
166
  return result;
171
167
  };
172
- export var parentBlockFormat = function (state) {
173
- var formats = getBlockFormats(state);
168
+ const parentBlockFormat = (state) => {
169
+ const formats = getBlockFormats(state);
174
170
  return new Set(formats).size === 1 ? formats[0] : null;
175
171
  };
176
172
  /**
177
173
  * **Deprecated.** Use `parentBlockFormat` function instead.
178
174
  */
179
- export var activeNode = function (state) {
175
+ const activeNode = (state) => {
180
176
  return { tag: parentBlockFormat(state) || '' };
181
177
  };
178
+
179
+ export { activeNode, addStyles, blockNodes, changeTextBlock, cleanTextBlockFormatting, formatBlockElements, getBlockFormats, hasNode, parentBlockFormat };
@@ -1,23 +1,26 @@
1
1
  import { wrapIn } from 'prosemirror-commands';
2
- export var blockquote = function (state, dispatch) {
2
+
3
+ const blockquote = (state, dispatch) => {
3
4
  return wrapIn(state.schema.nodes.blockquote)(state, dispatch);
4
5
  };
5
- export var liftBlockquote = function (state, dispatch) {
6
- var _a = state.selection, $from = _a.$from, $to = _a.$to;
7
- var nodeType = state.schema.nodes.blockquote;
8
- var doc = state.doc;
9
- var target = -1;
10
- var range = $from.blockRange($to);
6
+ const liftBlockquote = (state, dispatch) => {
7
+ const { $from, $to } = state.selection;
8
+ const nodeType = state.schema.nodes.blockquote;
9
+ const doc = state.doc;
10
+ let target = -1;
11
+ const range = $from.blockRange($to);
11
12
  if (range) {
12
- doc.nodesBetween(range.start, range.end, function (node, pos) {
13
+ doc.nodesBetween(range.start, range.end, (node, pos) => {
13
14
  if (node.type === nodeType) {
14
15
  target = pos;
15
16
  }
16
17
  });
17
18
  }
18
- var result = target !== -1;
19
+ const result = target !== -1;
19
20
  if (dispatch && result) {
20
21
  dispatch(state.tr.lift(range, doc.resolve(target).depth));
21
22
  }
22
23
  return result;
23
24
  };
25
+
26
+ export { blockquote, liftBlockquote };
@@ -1,20 +1,20 @@
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 var cleanFormatting = function (options) {
7
- if (options === void 0) { options = { blocksInSelection: true }; }
8
- return function (state, dispatch) {
9
- var tr = state.tr;
10
- var blocksInSelection = options.blocksInSelection, blockNodeType = options.blockNodeType, exceptMarks = options.exceptMarks;
11
- var except = (exceptMarks || [state.schema.marks.link]).filter(Boolean);
12
- cleanMarks(tr, { except: except });
13
- cleanTextBlockFormatting(tr, { blocksInSelection: blocksInSelection, blockNodeType: blockNodeType });
14
- var result = tr.docChanged;
15
- if (result && dispatch) {
16
- dispatch(tr);
17
- }
18
- return result;
19
- };
7
+ const cleanFormatting = (options = { blocksInSelection: true }) => (state, dispatch) => {
8
+ const tr = state.tr;
9
+ const { blocksInSelection, blockNodeType, exceptMarks } = options;
10
+ const except = (exceptMarks || [state.schema.marks.link]).filter(Boolean);
11
+ cleanMarks(tr, { except });
12
+ cleanTextBlockFormatting(tr, { blocksInSelection, blockNodeType });
13
+ const result = tr.docChanged;
14
+ if (result && dispatch) {
15
+ dispatch(tr);
16
+ }
17
+ return result;
20
18
  };
19
+
20
+ export { cleanFormatting };