@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,112 +1,130 @@
1
- import { __assign } from "tslib";
2
1
  import { Schema } from 'prosemirror-model';
3
2
  import { tableNodes } from 'prosemirror-tables';
4
- import { domToPmDoc, htmlToFragment, pmDocToFragment } from '../source';
5
- import { rowTypeAttr, colgroupAttr, resizableAttr } from './constants';
6
- var hole = 0;
7
- var blockquoteDOM = ['blockquote', hole], hrDOM = ['hr'], preDOM = ['pre', ['code', hole]];
8
- var olDOM = ['ol', 0], ulDOM = ['ul', 0], liDOM = ['li', 0];
9
- var domAttributes = function (dom) {
10
- var result = {};
11
- var attributes = dom.attributes;
12
- var attr;
13
- for (var i = 0; i < attributes.length; i++) {
3
+ import { domToPmDoc, htmlToFragment, pmDocToFragment } from '../source.js';
4
+ import { colgroupAttr, rowTypeAttr, resizableAttr } from './constants.js';
5
+
6
+ const hole = 0;
7
+ const blockquoteDOM = ['blockquote', hole], hrDOM = ['hr'], preDOM = ['pre', ['code', hole]];
8
+ const olDOM = ['ol', 0], ulDOM = ['ul', 0], liDOM = ['li', 0];
9
+ const domAttributes = (dom) => {
10
+ const result = {};
11
+ const attributes = dom.attributes;
12
+ let attr;
13
+ for (let i = 0; i < attributes.length; i++) {
14
14
  attr = attributes[i];
15
15
  result[attr.name] = attr.value;
16
16
  }
17
17
  return result;
18
18
  };
19
- var defaultAttrs = function (attrs) {
20
- var nodeAttrs = {};
21
- attrs.forEach(function (attr) {
19
+ const defaultAttrs = (attrs) => {
20
+ const nodeAttrs = {};
21
+ attrs.forEach(attr => {
22
22
  nodeAttrs[attr] = { default: null };
23
23
  });
24
24
  return nodeAttrs;
25
25
  };
26
- var commonAttributes = function () { return defaultAttrs(['style', 'class', 'id']); };
27
- var hasAttrs = function (attrs, exclude) {
28
- for (var attr in attrs) {
26
+ const commonAttributes = () => defaultAttrs(['style', 'class', 'id']);
27
+ const hasAttrs = (attrs, exclude) => {
28
+ for (const attr in attrs) {
29
29
  if (attr && attrs[attr] !== null && attr !== exclude) {
30
30
  return true;
31
31
  }
32
32
  }
33
33
  return false;
34
34
  };
35
- var pmAttributes = function (attrs, exclude) {
36
- if (exclude === void 0) { exclude = []; }
37
- var result = {};
38
- var _loop_1 = function (attr) {
39
- if (attr && attrs[attr] !== null && !exclude.find(function (e) { return e === attr; })) {
35
+ const pmAttributes = (attrs, exclude = []) => {
36
+ const result = {};
37
+ for (const attr in attrs) {
38
+ if (attr && attrs[attr] !== null && !exclude.find(e => e === attr)) {
40
39
  result[attr] = attrs[attr];
41
40
  }
42
- };
43
- for (var attr in attrs) {
44
- _loop_1(attr);
45
41
  }
46
42
  return result;
47
43
  };
48
- var tagMark = function (tag) {
49
- var _a;
50
- return _a = {},
51
- _a[tag] = {
44
+ const tagMark = tag => {
45
+ return {
46
+ [tag]: {
52
47
  name: tag,
53
- inclusive: true,
48
+ inclusive: true, // https://prosemirror.net/docs/ref/#model.MarkSpec.inclusive
54
49
  parseDOM: [{ tag: tag }],
55
- toDOM: function () { return [tag, hole]; }
56
- },
57
- _a;
50
+ toDOM: () => [tag, hole]
51
+ }
52
+ };
58
53
  };
59
- var marks = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({
54
+ const marks = {
60
55
  // :: MarkSpec A link. Has `href` and `title` attributes. `title`
61
56
  // defaults to the empty string. Rendered and parsed as an `<a>`
62
57
  // element.
63
58
  link: {
64
- attrs: __assign(__assign({}, commonAttributes()), { href: { default: null }, target: { default: null }, title: { default: null } }),
59
+ attrs: {
60
+ ...commonAttributes(),
61
+ href: { default: null },
62
+ target: { default: null },
63
+ title: { default: null }
64
+ },
65
65
  inclusive: false,
66
66
  parseDOM: [{ tag: 'a', getAttrs: domAttributes }],
67
- toDOM: function (node) { return ['a', pmAttributes(node.attrs), hole]; }
68
- } }, tagMark('strong')), tagMark('b')), tagMark('em')), tagMark('i')), tagMark('del')), tagMark('sub')), tagMark('sup')), tagMark('code')), { style: {
69
- attrs: __assign({}, commonAttributes()),
67
+ toDOM: (node) => ['a', pmAttributes(node.attrs), hole]
68
+ },
69
+ ...tagMark('strong'),
70
+ ...tagMark('b'),
71
+ ...tagMark('em'),
72
+ ...tagMark('i'),
73
+ ...tagMark('del'),
74
+ ...tagMark('sub'),
75
+ ...tagMark('sup'),
76
+ ...tagMark('code'),
77
+ style: {
78
+ attrs: {
79
+ ...commonAttributes()
80
+ },
70
81
  parseDOM: [{
71
82
  tag: 'span',
72
83
  getAttrs: domAttributes
73
84
  }],
74
- toDOM: function (node) { return hasAttrs(node.attrs) ?
75
- ['span', pmAttributes(node.attrs), hole] : ['span', hole]; }
76
- } }), tagMark('u'));
77
- var cellAttribute = function (name) {
78
- var _a;
79
- return _a = {},
80
- _a[name] = {
85
+ toDOM: node => hasAttrs(node.attrs) ?
86
+ ['span', pmAttributes(node.attrs), hole] : ['span', hole]
87
+ },
88
+ ...tagMark('u')
89
+ };
90
+ const cellAttribute = (name) => {
91
+ return {
92
+ [name]: {
81
93
  default: null,
82
- getFromDOM: function (cell) { return cell.getAttribute(name); },
83
- setDOMAttr: function (value, attrs) { attrs[name] = value; }
84
- },
85
- _a;
94
+ getFromDOM: (cell) => cell.getAttribute(name),
95
+ setDOMAttr: (value, attrs) => { attrs[name] = value; }
96
+ }
97
+ };
98
+ };
99
+ const cellAttributes = {
100
+ ...cellAttribute('style'),
101
+ ...cellAttribute('class'),
102
+ ...cellAttribute('id'),
103
+ ...cellAttribute('headers'),
104
+ ...cellAttribute('scope')
86
105
  };
87
- var cellAttributes = __assign(__assign(__assign(__assign(__assign({}, cellAttribute('style')), cellAttribute('class')), cellAttribute('id')), cellAttribute('headers')), cellAttribute('scope'));
88
- var colgroupNodes = {
106
+ const colgroupNodes = {
89
107
  doc: { content: 'colgroup*' },
90
108
  col: {
91
109
  attrs: defaultAttrs(['id', 'class', 'style', 'span']),
92
110
  parseDOM: [{ getAttrs: domAttributes, tag: 'col' }],
93
- toDOM: function (node) { return ['col', node.attrs]; }
111
+ toDOM: node => ['col', node.attrs]
94
112
  },
95
113
  colgroup: {
96
114
  attrs: defaultAttrs(['id', 'class', 'style', 'span']),
97
115
  content: 'col*',
98
116
  parseDOM: [{ getAttrs: domAttributes, tag: 'colgroup' }],
99
- toDOM: function (node) { return ['colgroup', node.attrs, 0]; }
117
+ toDOM: node => ['colgroup', node.attrs, 0]
100
118
  },
101
119
  text: { inline: true, group: 'inline' }
102
120
  };
103
- var colgroupSchema = new Schema({ nodes: colgroupNodes, marks: {} });
121
+ const colgroupSchema = new Schema({ nodes: colgroupNodes, marks: {} });
104
122
  // will be removed when we implement our own columnResizing
105
- var shouldSkipColgroup = function (node) {
106
- var shouldSkip = false;
107
- var row = node.child(0);
108
- for (var r = 0; r < row.childCount; r++) {
109
- var cell = row.child(r);
123
+ const shouldSkipColgroup = (node) => {
124
+ let shouldSkip = false;
125
+ const row = node.child(0);
126
+ for (let r = 0; r < row.childCount; r++) {
127
+ const cell = row.child(r);
110
128
  if (cell.attrs.colwidth) {
111
129
  shouldSkip = true;
112
130
  break;
@@ -114,24 +132,30 @@ var shouldSkipColgroup = function (node) {
114
132
  }
115
133
  return shouldSkip;
116
134
  };
117
- export var parseStrColgroup = function (colgroup) {
118
- var doc = domToPmDoc(htmlToFragment(colgroup), colgroupSchema, { preserveWhitespace: false });
119
- var fragment = pmDocToFragment(doc);
120
- var colgroupEl = fragment.firstChild;
135
+ const parseStrColgroup = (colgroup) => {
136
+ const doc = domToPmDoc(htmlToFragment(colgroup), colgroupSchema, { preserveWhitespace: false });
137
+ const fragment = pmDocToFragment(doc);
138
+ const colgroupEl = fragment.firstChild;
121
139
  return colgroupEl;
122
140
  };
123
- var tNodes = tableNodes({ tableGroup: 'block', cellContent: 'block+', cellAttributes: cellAttributes });
124
- tNodes.table_row.attrs = __assign(__assign({}, tNodes.table_row.attrs), defaultAttrs([rowTypeAttr, 'style', 'class', 'id']));
125
- tNodes.table_row.toDOM = function (node) { return ['tr', pmAttributes(node.attrs), 0]; };
141
+ const tNodes = tableNodes({ tableGroup: 'block', cellContent: 'block+', cellAttributes });
142
+ tNodes.table_row.attrs = {
143
+ ...tNodes.table_row.attrs,
144
+ ...defaultAttrs([rowTypeAttr, 'style', 'class', 'id'])
145
+ };
146
+ tNodes.table_row.toDOM = node => ['tr', pmAttributes(node.attrs), 0];
126
147
  tNodes.table_row.parseDOM = [{ tag: 'tr', getAttrs: domAttributes }];
127
- tNodes.table.attrs = __assign(__assign({}, tNodes.table.attrs), defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr]));
128
- tNodes.table.toDOM = function (node) {
129
- var tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
130
- var colgroup = null;
148
+ tNodes.table.attrs = {
149
+ ...tNodes.table.attrs,
150
+ ...defaultAttrs(['style', 'class', 'id', colgroupAttr, resizableAttr])
151
+ };
152
+ tNodes.table.toDOM = (node) => {
153
+ const tableAttrs = hasAttrs(node.attrs) ? pmAttributes(node.attrs, [colgroupAttr, resizableAttr]) : {};
154
+ let colgroup = null;
131
155
  if (node.attrs[colgroupAttr] && !shouldSkipColgroup(node)) {
132
- var colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
156
+ const colgroupEl = parseStrColgroup(node.attrs[colgroupAttr]);
133
157
  if (colgroupEl) {
134
- var cols = Array.from(colgroupEl.children).map(function (c) { return ['col', domAttributes(c)]; });
158
+ const cols = Array.from(colgroupEl.children).map((c) => ['col', domAttributes(c)]);
135
159
  colgroup = [
136
160
  'colgroup',
137
161
  domAttributes(colgroupEl)
@@ -143,32 +167,35 @@ tNodes.table.toDOM = function (node) {
143
167
  };
144
168
  tNodes.table.parseDOM = [{
145
169
  tag: 'table',
146
- getAttrs: function (node) {
147
- var attrs = domAttributes(node);
148
- var colgroup = Array.from(node.childNodes).find(function (c) { return c.nodeName === 'COLGROUP'; });
170
+ getAttrs: (node) => {
171
+ const attrs = domAttributes(node);
172
+ const colgroup = Array.from(node.childNodes).find(c => c.nodeName === 'COLGROUP');
149
173
  if (colgroup) {
150
174
  attrs[colgroupAttr] = colgroup.outerHTML;
151
175
  }
152
176
  return attrs;
153
177
  }
154
178
  }];
155
- var nodes = __assign({
179
+ const nodes = {
156
180
  // :: NodeSpec The top level document node.
157
181
  doc: {
158
182
  content: 'block+'
159
- },
183
+ },
160
184
  // :: NodeSpec A plain paragraph textblock. Represented in the DOM
161
185
  // as a `<p>` element.
162
186
  paragraph: {
163
187
  content: 'inline*',
164
188
  group: 'block',
165
- attrs: __assign({}, commonAttributes()),
189
+ attrs: {
190
+ ...commonAttributes()
191
+ },
166
192
  parseDOM: [{
167
193
  tag: 'p',
168
194
  getAttrs: domAttributes
169
195
  }],
170
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['p', pmAttributes(node.attrs), hole] : ['p', hole]; }
171
- }, table_wrapper: {
196
+ toDOM: node => hasAttrs(node.attrs) ? ['p', pmAttributes(node.attrs), hole] : ['p', hole]
197
+ },
198
+ table_wrapper: {
172
199
  content: '(table_caption_external | table)+',
173
200
  group: 'block',
174
201
  defining: true,
@@ -180,66 +207,78 @@ var nodes = __assign({
180
207
  tag: 'div[table]',
181
208
  getAttrs: domAttributes
182
209
  }],
183
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]; }
184
- }, table_caption_external: {
210
+ toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
211
+ },
212
+ table_caption_external: {
185
213
  content: 'inline+',
186
214
  group: 'block',
187
- attrs: __assign({ caption: { default: null } }, commonAttributes()),
215
+ attrs: {
216
+ caption: { default: null },
217
+ ...commonAttributes()
218
+ },
188
219
  parseDOM: [{
189
220
  tag: 'div[caption]',
190
221
  getAttrs: domAttributes
191
222
  }],
192
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]; }
193
- }, div: {
223
+ toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
224
+ },
225
+ div: {
194
226
  // Uncaught SyntaxError: Mixing inline and block content (in content expression '(block | inline)*')
195
227
  // content: '(block | inline)*',
196
228
  content: 'block*',
197
229
  group: 'block',
198
- attrs: __assign({}, commonAttributes()),
230
+ attrs: {
231
+ ...commonAttributes()
232
+ },
199
233
  parseDOM: [{
200
234
  tag: 'div',
201
235
  getAttrs: domAttributes
202
236
  }],
203
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]; }
204
- },
237
+ toDOM: node => hasAttrs(node.attrs) ? ['div', pmAttributes(node.attrs), hole] : ['div', hole]
238
+ },
205
239
  // :: NodeSpec A blockquote (`<blockquote>`) wrapping one or more blocks.
206
240
  blockquote: {
207
- attrs: __assign({}, commonAttributes()),
241
+ attrs: {
242
+ ...commonAttributes()
243
+ },
208
244
  content: 'block+',
209
245
  group: 'block',
210
- defining: true,
246
+ defining: true, // https://prosemirror.net/docs/ref/#model.NodeSpec.defining
211
247
  parseDOM: [{
212
248
  tag: 'blockquote',
213
249
  getAttrs: domAttributes
214
250
  }],
215
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['blockquote', pmAttributes(node.attrs), hole] : blockquoteDOM; }
216
- },
251
+ toDOM: node => hasAttrs(node.attrs) ? ['blockquote', pmAttributes(node.attrs), hole] : blockquoteDOM
252
+ },
217
253
  // :: NodeSpec A horizontal rule (`<hr>`).
218
254
  horizontal_rule: {
219
255
  group: 'block',
220
256
  parseDOM: [{ tag: 'hr' }],
221
- toDOM: function () { return hrDOM; }
222
- },
257
+ toDOM: () => hrDOM
258
+ },
223
259
  // :: NodeSpec A heading textblock, with a `level` attribute that
224
260
  // has to hold the numbers from 1 to 6. Parsed and serialized as `<h1>` to
225
261
  // `<h6>` elements.
226
262
  heading: {
227
- attrs: __assign(__assign({}, commonAttributes()), { level: { default: 1 } }),
263
+ attrs: {
264
+ ...commonAttributes(),
265
+ level: { default: 1 }
266
+ },
228
267
  content: 'inline*',
229
268
  group: 'block',
230
269
  defining: true,
231
270
  parseDOM: [
232
- { tag: 'h1', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 1 })); } },
233
- { tag: 'h2', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 2 })); } },
234
- { tag: 'h3', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 3 })); } },
235
- { tag: 'h4', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 4 })); } },
236
- { tag: 'h5', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 5 })); } },
237
- { tag: 'h6', getAttrs: function (node) { return (__assign(__assign({}, domAttributes(node)), { level: 6 })); } }
271
+ { tag: 'h1', getAttrs: node => ({ ...domAttributes(node), level: 1 }) },
272
+ { tag: 'h2', getAttrs: node => ({ ...domAttributes(node), level: 2 }) },
273
+ { tag: 'h3', getAttrs: node => ({ ...domAttributes(node), level: 3 }) },
274
+ { tag: 'h4', getAttrs: node => ({ ...domAttributes(node), level: 4 }) },
275
+ { tag: 'h5', getAttrs: node => ({ ...domAttributes(node), level: 5 }) },
276
+ { tag: 'h6', getAttrs: node => ({ ...domAttributes(node), level: 6 }) }
238
277
  ],
239
- toDOM: function (node) { return hasAttrs(node.attrs, 'level') ?
278
+ toDOM: node => hasAttrs(node.attrs, 'level') ?
240
279
  ['h' + node.attrs.level, pmAttributes(node.attrs, ['level']), hole] :
241
- ['h' + node.attrs.level, hole]; }
242
- },
280
+ ['h' + node.attrs.level, hole]
281
+ },
243
282
  // :: NodeSpec A code listing. Disallows marks or non-text inline
244
283
  // nodes by default. Represented as a `<pre>` element with a
245
284
  // `<code>` element inside it.
@@ -250,36 +289,45 @@ var nodes = __assign({
250
289
  code: true,
251
290
  defining: true,
252
291
  parseDOM: [{ tag: 'pre', preserveWhitespace: 'full' }],
253
- toDOM: function () { return preDOM; }
254
- },
292
+ toDOM: () => preDOM
293
+ },
255
294
  // :: NodeSpec The text node.
256
295
  text: {
257
296
  inline: true,
258
297
  group: 'inline'
259
- },
298
+ },
260
299
  // :: NodeSpec An inline image (`<img>`) node. Supports `src`,
261
300
  // `alt`, and `href` attributes. The latter two default to an empty
262
301
  // string.
263
302
  image: {
264
303
  inline: true,
265
- attrs: __assign({ src: { default: null }, alt: { default: null }, title: { default: null }, width: { default: null }, height: { default: null } }, commonAttributes()),
304
+ attrs: {
305
+ src: { default: null },
306
+ alt: { default: null },
307
+ title: { default: null },
308
+ width: { default: null },
309
+ height: { default: null },
310
+ ...commonAttributes()
311
+ },
266
312
  group: 'inline',
267
313
  draggable: true,
268
314
  parseDOM: [{ tag: 'img', getAttrs: domAttributes }],
269
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['img', pmAttributes(node.attrs)] : ['img']; }
270
- },
315
+ toDOM: node => hasAttrs(node.attrs) ? ['img', pmAttributes(node.attrs)] : ['img']
316
+ },
271
317
  // :: NodeSpec A hard line break represented in the DOM as a `<br>` element.
272
318
  hard_break: {
273
319
  inline: true,
274
- attrs: __assign({}, commonAttributes()),
320
+ attrs: {
321
+ ...commonAttributes()
322
+ },
275
323
  group: 'inline',
276
324
  selectable: false,
277
325
  parseDOM: [{
278
326
  tag: 'br',
279
327
  getAttrs: domAttributes
280
328
  }],
281
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['br', pmAttributes(node.attrs)] : ['br']; }
282
- },
329
+ toDOM: node => hasAttrs(node.attrs) ? ['br', pmAttributes(node.attrs)] : ['br']
330
+ },
283
331
  // :: NodeSpec
284
332
  // An ordered list [node spec](#model.NodeSpec). Has a single
285
333
  // attribute, `order`, which determines the number at which the list
@@ -288,32 +336,42 @@ var nodes = __assign({
288
336
  ordered_list: {
289
337
  content: 'list_item+',
290
338
  group: 'block',
291
- attrs: __assign(__assign({}, commonAttributes()), { type: { default: null }, order: { default: 1 } }),
292
- parseDOM: [{ tag: 'ol', getAttrs: function (dom) {
293
- return __assign(__assign({}, domAttributes(dom)), { order: dom.hasAttribute('start') ? parseInt(dom.getAttribute('start') || '1', 10) : 1 });
339
+ attrs: {
340
+ ...commonAttributes(),
341
+ type: { default: null },
342
+ order: { default: 1 }
343
+ },
344
+ parseDOM: [{ tag: 'ol', getAttrs: (dom) => {
345
+ return {
346
+ ...domAttributes(dom),
347
+ order: dom.hasAttribute('start') ? parseInt(dom.getAttribute('start') || '1', 10) : 1
348
+ };
294
349
  } }],
295
- toDOM: function (node) {
350
+ toDOM: node => {
296
351
  return node.attrs.order === 1 ?
297
352
  (hasAttrs(node.attrs, 'order') ? ['ol', pmAttributes(node.attrs, ['order']), hole] : olDOM) :
298
- ['ol', __assign(__assign({}, pmAttributes(node.attrs, ['order'])), { start: node.attrs.order }), hole];
353
+ ['ol', { ...pmAttributes(node.attrs, ['order']), start: node.attrs.order }, hole];
299
354
  }
300
- },
355
+ },
301
356
  // :: NodeSpec
302
357
  // A bullet list node specification represented in the DOM as a `<ul>` element.
303
358
  bullet_list: {
304
359
  content: 'list_item+',
305
360
  group: 'block',
306
- attrs: __assign({}, commonAttributes()),
361
+ attrs: { ...commonAttributes() },
307
362
  parseDOM: [{ tag: 'ul', getAttrs: domAttributes }],
308
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['ul', pmAttributes(node.attrs), hole] : ulDOM; }
309
- },
363
+ toDOM: node => hasAttrs(node.attrs) ? ['ul', pmAttributes(node.attrs), hole] : ulDOM
364
+ },
310
365
  // :: NodeSpec
311
366
  // A list item (`<li>`) specification.
312
367
  list_item: {
313
368
  content: '(paragraph | heading) block*',
314
- attrs: __assign({}, commonAttributes()),
369
+ attrs: { ...commonAttributes() },
315
370
  parseDOM: [{ tag: 'li', getAttrs: domAttributes }],
316
- toDOM: function (node) { return hasAttrs(node.attrs) ? ['li', pmAttributes(node.attrs), hole] : liDOM; },
371
+ toDOM: node => hasAttrs(node.attrs) ? ['li', pmAttributes(node.attrs), hole] : liDOM,
317
372
  defining: true
318
- } }, tNodes);
319
- export { nodes, marks };
373
+ },
374
+ ...tNodes
375
+ };
376
+
377
+ export { marks, nodes, parseStrColgroup };
@@ -1,10 +1,10 @@
1
- import { __rest } from "tslib";
2
1
  import { TextSelection } from 'prosemirror-state';
3
- export var findAt = function (doc, searchOptions, start, end, exit) {
4
- var result = [], exec, text, from, to, childText, nextSibling;
5
- var nodes = [];
6
- var matchCase = searchOptions.matchCase, matchWord = searchOptions.matchWord, useRegExp = searchOptions.useRegExp;
7
- var searchText = searchOptions.text;
2
+
3
+ const findAt = (doc, searchOptions, start, end, exit) => {
4
+ let result = [], exec, text, from, to, childText, nextSibling;
5
+ const nodes = [];
6
+ const { matchCase, matchWord, useRegExp } = searchOptions;
7
+ let searchText = searchOptions.text;
8
8
  if (useRegExp && (/^\\$/.test(searchText) || /[^\\]\\$/.test(searchText))) {
9
9
  // lookbehind doesn't work in Edge -> /((?<!\\)\\)$/.test(searchText)
10
10
  searchText = searchText.substring(0, searchText.length - 1);
@@ -12,19 +12,19 @@ export var findAt = function (doc, searchOptions, start, end, exit) {
12
12
  if (!searchText) {
13
13
  return result;
14
14
  }
15
- var flags = matchCase ? 'g' : 'gi';
16
- var regExp = useRegExp ? new RegExp(searchText, flags) : createRegExp(searchText, flags);
17
- doc.nodesBetween(start, end, function (node, pos) {
15
+ const flags = matchCase ? 'g' : 'gi';
16
+ const regExp = useRegExp ? new RegExp(searchText, flags) : createRegExp(searchText, flags);
17
+ doc.nodesBetween(start, end, (node, pos) => {
18
18
  if (exit(result)) {
19
19
  return false;
20
20
  }
21
21
  if (node.inlineContent && pos + node.content.size >= start) {
22
22
  nodes.length = 0;
23
- node.nodesBetween(0, node.content.size, function (child, childPos, parent, i) {
23
+ node.nodesBetween(0, node.content.size, (child, childPos, parent, i) => {
24
24
  if (exit(result)) {
25
25
  return false;
26
26
  }
27
- var posToDoc = 1 + pos + childPos;
27
+ const posToDoc = 1 + pos + childPos;
28
28
  if (child.isText && posToDoc + child.nodeSize >= start) {
29
29
  childText = child.text || '';
30
30
  nextSibling = parent.childCount - 1 >= i + 1 && parent.child(i + 1);
@@ -34,7 +34,7 @@ export var findAt = function (doc, searchOptions, start, end, exit) {
34
34
  if (nextSibling && nextSibling.isText) {
35
35
  return;
36
36
  }
37
- text = nodes.map(function (t) { return t.text; }).join('');
37
+ text = nodes.map(t => t.text).join('');
38
38
  exec = regExp.exec(text);
39
39
  while (exec !== null) {
40
40
  from = nodes[0].start + exec.index;
@@ -56,11 +56,11 @@ export var findAt = function (doc, searchOptions, start, end, exit) {
56
56
  });
57
57
  return result;
58
58
  };
59
- export var find = function (state, searchOptions) {
60
- var backward = searchOptions.backward, matchCyclic = searchOptions.matchCyclic, options = __rest(searchOptions, ["backward", "matchCyclic"]);
61
- var exit = backward ? function () { return false; } : function (r) { return r.length > 0; };
62
- var doc = state.doc, selection = state.selection;
63
- var result = [];
59
+ const find = (state, searchOptions) => {
60
+ const { backward, matchCyclic, ...options } = searchOptions;
61
+ const exit = backward ? () => false : r => r.length > 0;
62
+ const { doc, selection } = state;
63
+ let result = [];
64
64
  if (backward) {
65
65
  result = findAt(doc, options, 0, selection.from, exit);
66
66
  if (!result.length && matchCyclic) {
@@ -75,45 +75,47 @@ export var find = function (state, searchOptions) {
75
75
  }
76
76
  return result.length ? result[result.length - 1] : null;
77
77
  };
78
- export var findAll = function (doc, searchOptions) {
79
- return findAt(doc, searchOptions, 0, doc.content.size, function () { return false; });
78
+ const findAll = (doc, searchOptions) => {
79
+ return findAt(doc, searchOptions, 0, doc.content.size, () => false);
80
80
  };
81
- export var replace = function (selection, text, transaction) {
82
- var from = selection.from, to = selection.to;
81
+ const replace = (selection, text, transaction) => {
82
+ const { from, to } = selection;
83
83
  transaction.insertText(text, from, to)
84
84
  .setSelection(TextSelection.create(transaction.doc, from, from + text.length));
85
85
  return transaction;
86
86
  };
87
- export var replaceAll = function (state, replaceText, searchOptions) {
88
- var result = findAll(state.doc, searchOptions);
87
+ const replaceAll = (state, replaceText, searchOptions) => {
88
+ const result = findAll(state.doc, searchOptions);
89
89
  if (result.length === 0) {
90
90
  return null;
91
91
  }
92
- var transaction = state.tr;
93
- for (var i = result.length - 1; i >= 0; i--) {
92
+ const transaction = state.tr;
93
+ for (let i = result.length - 1; i >= 0; i--) {
94
94
  transaction.insertText(replaceText, result[i].from, result[i].to);
95
95
  }
96
96
  return transaction;
97
97
  };
98
- var notLetter = /^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/;
99
- var shouldMatchWord = function (exec, matchWord) {
98
+ const notLetter = /^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/;
99
+ const shouldMatchWord = (exec, matchWord) => {
100
100
  if (!matchWord) {
101
101
  return true;
102
102
  }
103
103
  else if (matchWord === true) {
104
- var text = exec.input;
105
- var charBefore = text.charAt(exec.index - 1);
106
- var charAfter = text.charAt(exec.index + exec[0].length);
104
+ const text = exec.input;
105
+ const charBefore = text.charAt(exec.index - 1);
106
+ const charAfter = text.charAt(exec.index + exec[0].length);
107
107
  return notLetter.test(charBefore) && notLetter.test(charAfter);
108
108
  }
109
109
  else {
110
110
  return matchWord(exec);
111
111
  }
112
112
  };
113
- var createRegExp = function (inputString, flags) {
114
- var escaped = inputString
113
+ const createRegExp = (inputString, flags) => {
114
+ const escaped = inputString
115
115
  .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
116
116
  .replace(/-/g, '\\x2d')
117
117
  .replace(/\s/g, '\\s');
118
118
  return new RegExp(escaped, flags);
119
119
  };
120
+
121
+ export { find, findAll, findAt, replace, replaceAll };
package/dist/es/image.js CHANGED
@@ -1,7 +1,10 @@
1
- import { insertNode } from './utils';
2
- export var insertImage = function (attrs) { return function (state, dispatch) {
3
- var image = state.schema.nodes.image;
4
- var commandName = 'insertImage';
5
- var newImage = image.createAndFill(attrs);
6
- insertNode(newImage)(state, function (tr) { return dispatch(tr.setMeta('commandName', commandName).setMeta('args', attrs)); });
7
- }; };
1
+ import { insertNode } from './utils.js';
2
+
3
+ const insertImage = (attrs) => (state, dispatch) => {
4
+ const { image } = state.schema.nodes;
5
+ const commandName = 'insertImage';
6
+ const newImage = image.createAndFill(attrs);
7
+ insertNode(newImage)(state, tr => dispatch(tr.setMeta('commandName', commandName).setMeta('args', attrs)));
8
+ };
9
+
10
+ export { insertImage };