@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,13 +1,10 @@
1
1
  import { MarkType, Mark } from 'prosemirror-model';
2
- import { EditorState, Transaction } from 'prosemirror-state';
3
- import { InlineFormatOptions } from './config/commands';
4
- import { Command } from './types/command';
5
- import { ActiveMarks } from './types/active-marks';
6
- export declare const markApplies: (doc: any, ranges: any, type: any) => boolean;
7
- export declare const toggleMark: (markType: MarkType, attrs: any, tr: Transaction) => (state: any, dispatch: any) => boolean;
8
- export declare const removeMark: (tr: any, from: any, to: any, mark: any) => any;
9
- export declare const removeMarks: (marks: any, state: any, dispatch: any, tr: any) => boolean;
10
- export declare const removeAllMarks: ({ except }?: {
2
+ import { Transaction, EditorState } from 'prosemirror-state';
3
+ import { InlineFormatOptions } from './config/commands.js';
4
+ import { Command } from './types/command.js';
5
+ import { ActiveMarks } from './types/active-marks.js';
6
+
7
+ declare const removeAllMarks: ({ except }?: {
11
8
  except?: MarkType | MarkType[];
12
9
  }) => Command;
13
10
  /**
@@ -17,28 +14,26 @@ export declare const removeAllMarks: ({ except }?: {
17
14
  * @example
18
15
  * See `removeAllMarks` or `cleanFormatting` function.
19
16
  */
20
- export declare const cleanMarks: (tr: Transaction, { except }: {
17
+ declare const cleanMarks: (tr: Transaction, { except }: {
21
18
  except?: MarkType[];
22
19
  }) => void;
23
20
  /**
24
21
  * Checks if a mark exists in the selection.
25
22
  * Used for checking the state of bold, italic, ... and unlink tools.
26
23
  */
27
- export declare const hasMark: (state: EditorState, options: InlineFormatOptions) => boolean;
28
- export declare const styleValue: (mark: Mark | undefined, style: {
29
- name: string;
30
- value: RegExp;
31
- }) => string | null;
24
+ declare const hasMark: (state: EditorState, options: InlineFormatOptions) => boolean;
32
25
  /**
33
26
  * Returns the marks of a specific type for every inline node in the selection.
34
27
  */
35
- export declare const selectionMarks: (state: EditorState, markType: MarkType) => Array<Mark | undefined>;
28
+ declare const selectionMarks: (state: EditorState, markType: MarkType) => Array<Mark | undefined>;
36
29
  /**
37
30
  * Returns the specified mark which wraps the selection.
38
31
  * Used by link tools.
39
32
  */
40
- export declare const getMark: (state: EditorState, markType: MarkType) => Mark | undefined;
33
+ declare const getMark: (state: EditorState, markType: MarkType) => Mark | undefined;
41
34
  /**
42
35
  * **Deprecated.** Use `selectionMarks` function instead.
43
36
  */
44
- export declare const getActiveMarks: (state: EditorState, markType: MarkType) => ActiveMarks;
37
+ declare const getActiveMarks: (state: EditorState, markType: MarkType) => ActiveMarks;
38
+
39
+ export { cleanMarks, getActiveMarks, getMark, hasMark, removeAllMarks, selectionMarks };
package/dist/npm/mark.js CHANGED
@@ -1,16 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getActiveMarks = exports.getMark = exports.selectionMarks = exports.styleValue = exports.hasMark = exports.cleanMarks = exports.removeAllMarks = exports.removeMarks = exports.removeMark = exports.toggleMark = exports.markApplies = void 0;
4
- var prosemirror_transform_1 = require("prosemirror-transform");
5
- var prosemirror_model_1 = require("prosemirror-model");
6
- var utils_1 = require("./utils");
7
- var markApplies = function (doc, ranges, type) {
8
- var loop = function (i) {
9
- var ref = ranges[i];
10
- var $from = ref.$from;
11
- var $to = ref.$to;
12
- var can = $from.depth === 0 ? doc.type.allowsMarkType(type) : false;
13
- doc.nodesBetween($from.pos, $to.pos, function (node) {
1
+ 'use strict';
2
+
3
+ var prosemirrorTransform = require('prosemirror-transform');
4
+ var prosemirrorModel = require('prosemirror-model');
5
+ var utils = require('./utils.js');
6
+
7
+ const markApplies = (doc, ranges, type) => {
8
+ const loop = i => {
9
+ const ref = ranges[i];
10
+ const $from = ref.$from;
11
+ const $to = ref.$to;
12
+ let can = $from.depth === 0 ? doc.type.allowsMarkType(type) : false;
13
+ doc.nodesBetween($from.pos, $to.pos, node => {
14
14
  if (can) {
15
15
  return false;
16
16
  }
@@ -20,18 +20,17 @@ var markApplies = function (doc, ranges, type) {
20
20
  return { v: true };
21
21
  }
22
22
  };
23
- for (var i = 0; i < ranges.length; i++) {
24
- var returned = loop(i);
23
+ for (let i = 0; i < ranges.length; i++) {
24
+ const returned = loop(i);
25
25
  if (returned) {
26
26
  return returned.v;
27
27
  }
28
28
  }
29
29
  return false;
30
30
  };
31
- exports.markApplies = markApplies;
32
- var toggleMark = function (markType, attrs, tr) { return function (state, dispatch) {
33
- var _a = state.selection, empty = _a.empty, $cursor = _a.$cursor, ranges = _a.ranges;
34
- if ((empty && !$cursor) || !(0, exports.markApplies)(state.doc, ranges, markType)) {
31
+ const toggleMark = (markType, attrs, tr) => (state, dispatch) => {
32
+ const { empty, $cursor, ranges } = state.selection;
33
+ if ((empty && !$cursor) || !markApplies(state.doc, ranges, markType)) {
35
34
  return false;
36
35
  }
37
36
  if (dispatch) {
@@ -44,13 +43,13 @@ var toggleMark = function (markType, attrs, tr) { return function (state, dispat
44
43
  }
45
44
  }
46
45
  else {
47
- var has = false;
48
- for (var i = 0; !has && i < ranges.length; i++) {
49
- var _b = ranges[i], $from = _b.$from, $to = _b.$to;
46
+ let has = false;
47
+ for (let i = 0; !has && i < ranges.length; i++) {
48
+ const { $from, $to } = ranges[i];
50
49
  has = state.doc.rangeHasMark($from.pos, $to.pos, markType);
51
50
  }
52
- for (var i = 0; i < ranges.length; i++) {
53
- var _c = ranges[i], $from = _c.$from, $to = _c.$to;
51
+ for (let i = 0; i < ranges.length; i++) {
52
+ const { $from, $to } = ranges[i];
54
53
  if (has) {
55
54
  tr.removeMark($from.pos, $to.pos, markType);
56
55
  }
@@ -62,21 +61,20 @@ var toggleMark = function (markType, attrs, tr) { return function (state, dispat
62
61
  }
63
62
  }
64
63
  return true;
65
- }; };
66
- exports.toggleMark = toggleMark;
67
- var removeMark = function (tr, from, to, mark) {
64
+ };
65
+ const removeMark = (tr, from, to, mark) => {
68
66
  if (mark === void 0) {
69
67
  mark = null;
70
68
  }
71
- var matched = [], step = 0;
72
- tr.doc.nodesBetween(from, to, function (node, pos) {
69
+ let matched = [], step = 0;
70
+ tr.doc.nodesBetween(from, to, (node, pos) => {
73
71
  if (!node.isInline) {
74
72
  return;
75
73
  }
76
74
  step++;
77
- var toRemove = null;
78
- if (mark instanceof prosemirror_model_1.MarkType) {
79
- var found = mark.isInSet(node.marks);
75
+ let toRemove = null;
76
+ if (mark instanceof prosemirrorModel.MarkType) {
77
+ const found = mark.isInSet(node.marks);
80
78
  if (found) {
81
79
  toRemove = [found];
82
80
  }
@@ -90,11 +88,11 @@ var removeMark = function (tr, from, to, mark) {
90
88
  toRemove = node.marks;
91
89
  }
92
90
  if (toRemove && toRemove.length) {
93
- var end = Math.min(pos + node.nodeSize, to);
94
- for (var i = 0; i < toRemove.length; i++) {
95
- var style = toRemove[i], found$1 = (void 0);
96
- for (var j = 0; j < matched.length; j++) {
97
- var m = matched[j];
91
+ const end = Math.min(pos + node.nodeSize, to);
92
+ for (let i = 0; i < toRemove.length; i++) {
93
+ let style = toRemove[i], found$1 = (void 0);
94
+ for (let j = 0; j < matched.length; j++) {
95
+ const m = matched[j];
98
96
  if (m.step === step - 1 && style.eq(m.style)) {
99
97
  found$1 = m;
100
98
  }
@@ -109,47 +107,38 @@ var removeMark = function (tr, from, to, mark) {
109
107
  }
110
108
  }
111
109
  });
112
- matched.forEach(function (m) { return tr.step(new prosemirror_transform_1.RemoveMarkStep(m.from, m.to, m.style)); });
110
+ matched.forEach((m) => { return tr.step(new prosemirrorTransform.RemoveMarkStep(m.from, m.to, m.style)); });
113
111
  return tr;
114
112
  };
115
- exports.removeMark = removeMark;
116
- var removeMarks = function (marks, state, dispatch, tr) {
117
- var _a = state.selection, $cursor = _a.$cursor, ranges = _a.ranges;
113
+ const removeMarks = (marks, state, dispatch, tr) => {
114
+ const { $cursor, ranges } = state.selection;
118
115
  tr = tr || state.tr;
119
116
  if ($cursor) {
120
- marks.forEach(function (m) {
117
+ marks.forEach(m => {
121
118
  if (m.isInSet(state.storedMarks || $cursor.marks())) {
122
119
  dispatch(tr.removeStoredMark(m));
123
120
  }
124
121
  });
125
122
  }
126
123
  else {
127
- var _loop_1 = function (i) {
128
- var _b = ranges[i], $from = _b.$from, $to = _b.$to;
129
- marks.forEach(function (m) {
130
- (0, exports.removeMark)(tr, $from.pos, $to.pos, m);
124
+ for (let i = 0; i < ranges.length; i++) {
125
+ const { $from, $to } = ranges[i];
126
+ marks.forEach(m => {
127
+ removeMark(tr, $from.pos, $to.pos, m);
131
128
  });
132
- };
133
- for (var i = 0; i < ranges.length; i++) {
134
- _loop_1(i);
135
129
  }
136
130
  dispatch(tr.scrollIntoView());
137
131
  }
138
132
  return true;
139
133
  };
140
- exports.removeMarks = removeMarks;
141
- var toArray = function (x) { return x instanceof Array ? x : [x]; };
142
- var removeAllMarks = function (_a) {
143
- var _b = _a === void 0 ? {} : _a, _c = _b.except, except = _c === void 0 ? [] : _c;
144
- return function (state, dispatch) {
145
- var tr = state.tr;
146
- (0, exports.cleanMarks)(tr, { except: toArray(except) });
147
- if (tr.docChanged) {
148
- dispatch(tr);
149
- }
150
- };
134
+ const toArray = (x) => x instanceof Array ? x : [x];
135
+ const removeAllMarks = ({ except = [] } = {}) => (state, dispatch) => {
136
+ const tr = state.tr;
137
+ cleanMarks(tr, { except: toArray(except) });
138
+ if (tr.docChanged) {
139
+ dispatch(tr);
140
+ }
151
141
  };
152
- exports.removeAllMarks = removeAllMarks;
153
142
  /**
154
143
  * Removes the marks from the selection base on the passed parameter.
155
144
  * Requires to dispatch the transaction.
@@ -157,74 +146,69 @@ exports.removeAllMarks = removeAllMarks;
157
146
  * @example
158
147
  * See `removeAllMarks` or `cleanFormatting` function.
159
148
  */
160
- var cleanMarks = function (tr, _a) {
161
- var except = _a.except;
162
- var doc = tr.doc, selection = tr.selection;
163
- var schema = doc.type.schema;
164
- var empty = selection.empty, ranges = selection.ranges;
165
- var excludedMarkTypes = (except || []).map(function (mt) { return mt.name; });
149
+ const cleanMarks = (tr, { except }) => {
150
+ const { doc, selection } = tr;
151
+ const schema = doc.type.schema;
152
+ const { empty, ranges } = selection;
153
+ const excludedMarkTypes = (except || []).map(mt => mt.name);
166
154
  if (!empty) {
167
- var marks_1 = Object.keys(schema.marks)
168
- .map(function (m) { return schema.marks[m]; })
169
- .filter(function (mt) { return excludedMarkTypes.indexOf(mt.name) === -1; });
170
- ranges.forEach(function (_a) {
171
- var $from = _a.$from, $to = _a.$to;
172
- marks_1.forEach(function (mark) { return tr.removeMark($from.pos, $to.pos, mark); });
155
+ const marks = Object.keys(schema.marks)
156
+ .map(m => schema.marks[m])
157
+ .filter(mt => excludedMarkTypes.indexOf(mt.name) === -1);
158
+ ranges.forEach(({ $from, $to }) => {
159
+ marks.forEach(mark => tr.removeMark($from.pos, $to.pos, mark));
173
160
  });
174
161
  }
175
162
  };
176
- exports.cleanMarks = cleanMarks;
177
163
  /**
178
164
  * Checks if a mark exists in the selection.
179
165
  * Used for checking the state of bold, italic, ... and unlink tools.
180
166
  */
181
- var hasMark = function (state, options) {
182
- var marks = state.schema.marks;
183
- var altMarks = (options.altMarks || []).filter(function (m) { return marks[m]; });
184
- var altStyle = options.altStyle;
185
- var _a = state.selection, from = _a.from, $from = _a.$from, to = _a.to, empty = _a.empty;
186
- var type = marks[options.mark];
187
- var doc = state.doc;
188
- var result = false;
189
- var currMarks;
167
+ const hasMark = (state, options) => {
168
+ const marks = state.schema.marks;
169
+ const altMarks = (options.altMarks || []).filter(m => marks[m]);
170
+ const altStyle = options.altStyle;
171
+ const { from, $from, to, empty } = state.selection;
172
+ const type = marks[options.mark];
173
+ const doc = state.doc;
174
+ let result = false;
175
+ let currMarks;
190
176
  if (empty) {
191
177
  currMarks = state.storedMarks || $from.marks();
192
- result = (type && type.isInSet(currMarks)) || altMarks.some(function (m) { return marks[m].isInSet(currMarks); });
178
+ result = (type && type.isInSet(currMarks)) || altMarks.some(m => marks[m].isInSet(currMarks));
193
179
  }
194
180
  else {
195
- result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(function (m) { return doc.rangeHasMark(from, to, marks[m]); });
181
+ result = (type && doc.rangeHasMark(from, to, type)) || altMarks.some(m => doc.rangeHasMark(from, to, marks[m]));
196
182
  }
197
183
  if (!result && altStyle && marks.style) {
198
- return (0, exports.selectionMarks)(state, marks.style)
199
- .some(function (mark) { return (0, exports.styleValue)(mark, altStyle) !== null; });
184
+ return selectionMarks(state, marks.style)
185
+ .some(mark => styleValue(mark, altStyle) !== null);
200
186
  }
201
187
  return Boolean(result);
202
188
  };
203
- exports.hasMark = hasMark;
204
- var styleValue = function (mark, style) {
205
- var styleText = (mark && mark.attrs.style) || '';
206
- var styles = (0, utils_1.parseStyle)(styleText);
207
- var styleNames = Object.keys(styles);
208
- for (var i = 0; i < styleNames.length; i++) {
209
- var name_1 = styleNames[i];
210
- if (name_1.toLowerCase() === style.name && style.value.test(styles[name_1])) {
211
- return styles[name_1];
189
+ const styleValue = (mark, style) => {
190
+ const styleText = (mark && mark.attrs.style) || '';
191
+ const styles = utils.parseStyle(styleText);
192
+ const styleNames = Object.keys(styles);
193
+ for (let i = 0; i < styleNames.length; i++) {
194
+ const name = styleNames[i];
195
+ if (name.toLowerCase() === style.name && style.value.test(styles[name])) {
196
+ return styles[name];
212
197
  }
213
198
  }
214
199
  return null;
215
200
  };
216
- exports.styleValue = styleValue;
217
201
  /**
218
202
  * Returns the marks of a specific type for every inline node in the selection.
219
203
  */
220
- var selectionMarks = function (state, markType) {
221
- var _a = state.selection, from = _a.from, $from = _a.$from, to = _a.to, empty = _a.empty;
222
- var marks = [];
204
+ const selectionMarks = (state, markType) => {
205
+ const { from, $from, to, empty } = state.selection;
206
+ const marks = [];
223
207
  if (empty) {
224
208
  marks.push(markType.isInSet(state.storedMarks || $from.marks()));
225
209
  }
226
210
  else {
227
- state.doc.nodesBetween(from, to, function (node) {
211
+ state.doc.nodesBetween(from, to, node => {
228
212
  if (node.isInline) {
229
213
  marks.push(markType.isInSet(node.marks));
230
214
  }
@@ -232,27 +216,36 @@ var selectionMarks = function (state, markType) {
232
216
  }
233
217
  return marks;
234
218
  };
235
- exports.selectionMarks = selectionMarks;
236
219
  /**
237
220
  * Returns the specified mark which wraps the selection.
238
221
  * Used by link tools.
239
222
  */
240
- var getMark = function (state, markType) {
241
- var marks = (0, exports.selectionMarks)(state, markType);
242
- var filtered = marks.filter(function (m) { return Boolean(m); });
223
+ const getMark = (state, markType) => {
224
+ const marks = selectionMarks(state, markType);
225
+ const filtered = marks.filter(m => Boolean(m));
243
226
  return marks.length === filtered.length ? marks[0] : undefined;
244
227
  };
245
- exports.getMark = getMark;
246
228
  /**
247
229
  * **Deprecated.** Use `selectionMarks` function instead.
248
230
  */
249
- var getActiveMarks = function (state, markType) {
250
- var marks = (0, exports.selectionMarks)(state, markType);
251
- var filtered = marks.filter(function (m) { return Boolean(m); });
252
- var hasNodesWithoutMarks = marks.length !== filtered.length;
231
+ const getActiveMarks = (state, markType) => {
232
+ const marks = selectionMarks(state, markType);
233
+ const filtered = marks.filter(m => Boolean(m));
234
+ const hasNodesWithoutMarks = marks.length !== filtered.length;
253
235
  return {
254
- hasNodesWithoutMarks: hasNodesWithoutMarks,
236
+ hasNodesWithoutMarks,
255
237
  marks: filtered
256
238
  };
257
239
  };
240
+
241
+ exports.cleanMarks = cleanMarks;
258
242
  exports.getActiveMarks = getActiveMarks;
243
+ exports.getMark = getMark;
244
+ exports.hasMark = hasMark;
245
+ exports.markApplies = markApplies;
246
+ exports.removeAllMarks = removeAllMarks;
247
+ exports.removeMark = removeMark;
248
+ exports.removeMarks = removeMarks;
249
+ exports.selectionMarks = selectionMarks;
250
+ exports.styleValue = styleValue;
251
+ exports.toggleMark = toggleMark;
@@ -1,33 +1,34 @@
1
- import { PasteCleanupSettings } from './types/paste-cleanup-settings';
1
+ import { PasteCleanupSettings } from './types/paste-cleanup-settings.js';
2
+
2
3
  /**
3
4
  * Removes the invalid HTML. Use it as a first step for cleaning the HTML.
4
5
  */
5
- export declare const sanitize: (html: string) => string;
6
+ declare const sanitize: (html: string) => string;
6
7
  /**
7
8
  * Removes comments in HTML.
8
9
  */
9
- export declare const removeComments: (html: string) => string;
10
+ declare const removeComments: (html: string) => string;
10
11
  /**
11
12
  * Removes the specified tag(s).
12
13
  */
13
- export declare const removeTag: (html: string, tagPattern: string) => string;
14
+ declare const removeTag: (html: string, tagPattern: string) => string;
14
15
  /**
15
16
  * Removes the passed attribute.
16
17
  */
17
- export declare const removeAttribute: (attr: Attr) => void;
18
+ declare const removeAttribute: (attr: Attr) => void;
18
19
  /**
19
20
  * Remove the attribute if its value matches /^Mso/ regex.
20
21
  */
21
- export declare const sanitizeClassAttr: (attr: Attr) => void;
22
+ declare const sanitizeClassAttr: (attr: Attr) => void;
22
23
  /**
23
24
  * Removes invalid HTML styles.
24
25
  */
25
- export declare const sanitizeStyleAttr: (attr: Attr) => void;
26
+ declare const sanitizeStyleAttr: (attr: Attr) => void;
26
27
  /**
27
28
  * Cleans the HTML based on passed settings.
28
29
  * Before using it, clean the HTML with the `sanitize` function.
29
30
  */
30
- export declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => string;
31
+ declare const pasteCleanup: (html: string, settings: PasteCleanupSettings) => string;
31
32
  /**
32
33
  * If the input HTML contains images with 'src' pointing to local file system (it happens when pasting images and text from MS Word),
33
34
  * the function will extract the image sources form the RTF and replace the image 'src' with extracted base64 format data in `html` string.
@@ -36,4 +37,6 @@ export declare const pasteCleanup: (html: string, settings: PasteCleanupSettings
36
37
  * @param clipboardData - The paste event clipboardData object (event.clipboardData).
37
38
  * @returns - The html with the replaced images sources.
38
39
  */
39
- export declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
40
+ declare const replaceImageSourcesFromRtf: (html: string, clipboardData: DataTransfer) => string;
41
+
42
+ export { pasteCleanup, removeAttribute, removeComments, removeTag, replaceImageSourcesFromRtf, sanitize, sanitizeClassAttr, sanitizeStyleAttr };