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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/cdn/js/kendo-editor-common.js +1 -1
  2. package/dist/cdn/main.js +1 -1
  3. package/dist/es/DOMSerializer.js +6 -7
  4. package/dist/es/align.js +3 -6
  5. package/dist/es/blockNode.js +11 -14
  6. package/dist/es/blockquote.js +2 -5
  7. package/dist/es/cleanFormatting.js +3 -6
  8. package/dist/es/config/align-rules.js +5 -7
  9. package/dist/es/config/commands.js +13 -9
  10. package/dist/es/config/constants.js +7 -9
  11. package/dist/es/config/indent-rules.js +3 -6
  12. package/dist/es/config/keymap.js +7 -10
  13. package/dist/es/config/list-settings.js +3 -5
  14. package/dist/es/config/schema.js +4 -6
  15. package/dist/es/find-replace.js +8 -10
  16. package/dist/es/flatten-spans.js +2 -5
  17. package/dist/es/image.js +2 -5
  18. package/dist/es/indent.js +11 -14
  19. package/dist/es/inline-style.js +10 -12
  20. package/dist/es/link.js +5 -8
  21. package/dist/es/listConvert.js +8 -9
  22. package/dist/es/lists.js +12 -15
  23. package/dist/es/main.js +34 -33
  24. package/dist/es/mark.js +16 -17
  25. package/dist/es/paste.js +10 -13
  26. package/dist/es/plugins/caret-color.js +5 -8
  27. package/dist/es/plugins/csp-fix.js +2 -5
  28. package/dist/es/plugins/highlight.js +3 -6
  29. package/dist/es/plugins/image-resize.js +8 -11
  30. package/dist/es/plugins/list-markers-styles.js +2 -5
  31. package/dist/es/plugins/placeholder.js +2 -5
  32. package/dist/es/plugins/resize-utils.js +2 -4
  33. package/dist/es/plugins/spaces-fix.js +1 -4
  34. package/dist/es/plugins/table-resize/column-resize.js +21 -24
  35. package/dist/es/plugins/table-resize/index.js +6 -9
  36. package/dist/es/plugins/table-resize/row-resize.js +23 -24
  37. package/dist/es/plugins/table-resize/table-resize.js +17 -20
  38. package/dist/es/plugins/table-resize/table-view.js +6 -9
  39. package/dist/es/plugins/table-resize/utils.js +10 -13
  40. package/dist/es/source.js +15 -18
  41. package/dist/es/table.js +15 -18
  42. package/dist/es/text.js +1 -3
  43. package/dist/es/types/active-marks.js +1 -0
  44. package/dist/es/types/command.js +1 -0
  45. package/dist/es/types/dispatchFn.js +1 -0
  46. package/dist/es/types/paste-cleanup-settings.js +1 -0
  47. package/dist/es/types/predicate.js +1 -0
  48. package/dist/es/utils.js +18 -21
  49. package/dist/npm/DOMSerializer.d.ts +35 -0
  50. package/dist/npm/DOMSerializer.js +10 -9
  51. package/dist/npm/align.d.ts +4 -7
  52. package/dist/npm/align.js +9 -10
  53. package/dist/npm/blockNode.d.ts +15 -12
  54. package/dist/npm/blockNode.js +28 -29
  55. package/dist/npm/blockquote.d.ts +2 -5
  56. package/dist/npm/blockquote.js +6 -7
  57. package/dist/npm/cleanFormatting.d.ts +3 -6
  58. package/dist/npm/cleanFormatting.js +7 -8
  59. package/dist/npm/config/align-rules.d.ts +6 -8
  60. package/dist/npm/config/align-rules.js +8 -13
  61. package/dist/npm/config/commands.d.ts +19 -11
  62. package/dist/npm/config/commands.js +16 -17
  63. package/dist/npm/config/constants.d.ts +7 -0
  64. package/dist/npm/config/constants.js +10 -17
  65. package/dist/npm/config/indent-rules.d.ts +4 -6
  66. package/dist/npm/config/indent-rules.js +8 -11
  67. package/dist/npm/config/keymap.d.ts +2 -5
  68. package/dist/npm/config/keymap.js +21 -22
  69. package/dist/npm/config/list-settings.d.ts +30 -0
  70. package/dist/npm/config/list-settings.js +10 -13
  71. package/dist/npm/config/schema.d.ts +2 -3
  72. package/dist/npm/config/schema.js +19 -20
  73. package/dist/npm/find-replace.d.ts +7 -10
  74. package/dist/npm/find-replace.js +20 -20
  75. package/dist/npm/flatten-spans.d.ts +1 -3
  76. package/dist/npm/flatten-spans.js +6 -7
  77. package/dist/npm/image.d.ts +3 -6
  78. package/dist/npm/image.js +5 -6
  79. package/dist/npm/indent.d.ts +9 -12
  80. package/dist/npm/indent.js +37 -38
  81. package/dist/npm/inline-style.d.ts +4 -7
  82. package/dist/npm/inline-style.js +28 -28
  83. package/dist/npm/link.d.ts +2 -4
  84. package/dist/npm/link.js +21 -22
  85. package/dist/npm/listConvert.d.ts +1 -3
  86. package/dist/npm/listConvert.js +13 -12
  87. package/dist/npm/lists.d.ts +8 -8
  88. package/dist/npm/lists.js +26 -27
  89. package/dist/npm/main.d.ts +34 -35
  90. package/dist/npm/main.js +214 -391
  91. package/dist/npm/mark.d.ts +17 -12
  92. package/dist/npm/mark.js +30 -29
  93. package/dist/npm/paste.d.ts +8 -11
  94. package/dist/npm/paste.js +19 -20
  95. package/dist/npm/plugins/caret-color.d.ts +2 -5
  96. package/dist/npm/plugins/caret-color.js +15 -17
  97. package/dist/npm/plugins/csp-fix.d.ts +1 -4
  98. package/dist/npm/plugins/csp-fix.js +8 -9
  99. package/dist/npm/plugins/highlight.d.ts +4 -7
  100. package/dist/npm/plugins/highlight.js +11 -13
  101. package/dist/npm/plugins/image-resize.d.ts +5 -7
  102. package/dist/npm/plugins/image-resize.js +35 -37
  103. package/dist/npm/plugins/list-markers-styles.d.ts +2 -5
  104. package/dist/npm/plugins/list-markers-styles.js +14 -16
  105. package/dist/npm/plugins/placeholder.d.ts +1 -4
  106. package/dist/npm/plugins/placeholder.js +10 -12
  107. package/dist/npm/plugins/resize-utils.d.ts +35 -0
  108. package/dist/npm/plugins/resize-utils.js +5 -7
  109. package/dist/npm/plugins/spaces-fix.d.ts +1 -4
  110. package/dist/npm/plugins/spaces-fix.js +9 -10
  111. package/dist/npm/plugins/table-resize/column-resize.d.ts +2 -0
  112. package/dist/npm/plugins/table-resize/column-resize.js +44 -46
  113. package/dist/npm/plugins/table-resize/index.d.ts +2 -5
  114. package/dist/npm/plugins/table-resize/index.js +13 -14
  115. package/dist/npm/plugins/table-resize/row-resize.d.ts +2 -0
  116. package/dist/npm/plugins/table-resize/row-resize.js +40 -40
  117. package/dist/npm/plugins/table-resize/table-resize.d.ts +18 -0
  118. package/dist/npm/plugins/table-resize/table-resize.js +51 -52
  119. package/dist/npm/plugins/table-resize/table-view.d.ts +28 -0
  120. package/dist/npm/plugins/table-resize/table-view.js +23 -24
  121. package/dist/npm/plugins/table-resize/utils.d.ts +17 -7
  122. package/dist/npm/plugins/table-resize/utils.js +24 -28
  123. package/dist/npm/source.d.ts +13 -16
  124. package/dist/npm/source.js +35 -36
  125. package/dist/npm/table.d.ts +9 -10
  126. package/dist/npm/table.js +33 -49
  127. package/dist/npm/text.d.ts +3 -6
  128. package/dist/npm/text.js +3 -3
  129. package/dist/npm/types/active-marks.d.ts +1 -4
  130. package/dist/npm/types/active-marks.js +2 -0
  131. package/dist/npm/types/command.d.ts +2 -5
  132. package/dist/npm/types/command.js +2 -0
  133. package/dist/npm/types/dispatchFn.d.ts +1 -4
  134. package/dist/npm/types/dispatchFn.js +2 -0
  135. package/dist/npm/types/paste-cleanup-settings.d.ts +1 -3
  136. package/dist/npm/types/paste-cleanup-settings.js +2 -0
  137. package/dist/npm/types/predicate.d.ts +1 -0
  138. package/dist/npm/types/predicate.js +2 -0
  139. package/dist/npm/utils.d.ts +33 -14
  140. package/dist/npm/utils.js +38 -39
  141. package/package.json +3 -50
  142. package/dist/es2015/DOMSerializer.js +0 -184
  143. package/dist/es2015/align.js +0 -43
  144. package/dist/es2015/blockNode.js +0 -180
  145. package/dist/es2015/blockquote.js +0 -26
  146. package/dist/es2015/cleanFormatting.js +0 -20
  147. package/dist/es2015/config/align-rules.js +0 -30
  148. package/dist/es2015/config/commands.js +0 -50
  149. package/dist/es2015/config/constants.js +0 -9
  150. package/dist/es2015/config/indent-rules.js +0 -42
  151. package/dist/es2015/config/keymap.js +0 -51
  152. package/dist/es2015/config/list-settings.js +0 -21
  153. package/dist/es2015/config/schema.js +0 -314
  154. package/dist/es2015/find-replace.js +0 -122
  155. package/dist/es2015/flatten-spans.js +0 -112
  156. package/dist/es2015/image.js +0 -10
  157. package/dist/es2015/indent.js +0 -105
  158. package/dist/es2015/inline-style.js +0 -177
  159. package/dist/es2015/link.js +0 -105
  160. package/dist/es2015/listConvert.js +0 -184
  161. package/dist/es2015/lists.js +0 -266
  162. package/dist/es2015/main.js +0 -44
  163. package/dist/es2015/mark.js +0 -239
  164. package/dist/es2015/node_modules/tslib/tslib.es6.js +0 -35
  165. package/dist/es2015/paste.js +0 -162
  166. package/dist/es2015/plugins/caret-color.js +0 -34
  167. package/dist/es2015/plugins/csp-fix.js +0 -51
  168. package/dist/es2015/plugins/highlight.js +0 -23
  169. package/dist/es2015/plugins/image-resize.js +0 -225
  170. package/dist/es2015/plugins/list-markers-styles.js +0 -104
  171. package/dist/es2015/plugins/placeholder.js +0 -27
  172. package/dist/es2015/plugins/resize-utils.js +0 -13
  173. package/dist/es2015/plugins/spaces-fix.js +0 -46
  174. package/dist/es2015/plugins/table-resize/column-resize.js +0 -267
  175. package/dist/es2015/plugins/table-resize/index.js +0 -12
  176. package/dist/es2015/plugins/table-resize/row-resize.js +0 -234
  177. package/dist/es2015/plugins/table-resize/table-resize.js +0 -278
  178. package/dist/es2015/plugins/table-resize/table-view.js +0 -128
  179. package/dist/es2015/plugins/table-resize/utils.js +0 -93
  180. package/dist/es2015/source.js +0 -251
  181. package/dist/es2015/table.js +0 -132
  182. package/dist/es2015/text.js +0 -5
  183. package/dist/es2015/utils.js +0 -289
package/dist/es/table.js CHANGED
@@ -1,14 +1,12 @@
1
- import { addRowAfter as addRowAfter$1, addRowBefore as addRowBefore$1, addColumnBefore as addColumnBefore$1, addColumnAfter as addColumnAfter$1, deleteColumn as deleteColumn$1, TableMap } from 'prosemirror-tables';
2
- export { addColumnAfter as pmAddColumnAfter, addColumnBefore as pmAddColumnBefore, addRowAfter as pmAddRowAfter, addRowBefore as pmAddRowBefore, deleteColumn as pmDeleteColumn } from 'prosemirror-tables';
3
- import { colgroupAttr, rowTypeAttr } from './config/constants.js';
4
- import { parseStrColgroup } from './config/schema.js';
5
-
1
+ import { addRowAfter as pmAddRowAfter, addRowBefore as pmAddRowBefore, addColumnBefore as pmAddColumnBefore, addColumnAfter as pmAddColumnAfter, deleteColumn as pmDeleteColumn, TableMap } from 'prosemirror-tables';
2
+ import { colgroupAttr, rowTypeAttr } from './config/constants';
3
+ import { parseStrColgroup } from './config/schema';
6
4
  /**
7
5
  * Creates a table.
8
6
  *
9
7
  * @returns Node
10
8
  */
11
- const createTable = (nodes, rows, columns) => {
9
+ export const createTable = (nodes, rows, columns) => {
12
10
  const { table, table_row, table_cell } = nodes;
13
11
  const tableRows = [];
14
12
  let cells;
@@ -37,7 +35,7 @@ const closest = (selection, name) => {
37
35
  }
38
36
  return null;
39
37
  };
40
- const addRowBefore = (state, dispatch) => {
38
+ export const addRowBefore = (state, dispatch) => {
41
39
  const cmdDispatch = dispatch && (tr => {
42
40
  const row = closest(tr.selection, reRow);
43
41
  const table = closest(tr.selection, reTable);
@@ -55,9 +53,9 @@ const addRowBefore = (state, dispatch) => {
55
53
  }
56
54
  return dispatch(tr);
57
55
  });
58
- return addRowBefore$1(state, cmdDispatch);
56
+ return pmAddRowBefore(state, cmdDispatch);
59
57
  };
60
- const addRowAfter = (state, dispatch) => {
58
+ export const addRowAfter = (state, dispatch) => {
61
59
  const cmdDispatch = dispatch && (tr => {
62
60
  const row = closest(tr.selection, reRow);
63
61
  if (row && row.node.attrs[rowTypeAttr]) {
@@ -66,7 +64,7 @@ const addRowAfter = (state, dispatch) => {
66
64
  }
67
65
  return dispatch(tr);
68
66
  });
69
- return addRowAfter$1(state, cmdDispatch);
67
+ return pmAddRowAfter(state, cmdDispatch);
70
68
  };
71
69
  const columnIndex = (table, selection) => {
72
70
  if (!table) {
@@ -92,7 +90,7 @@ const deleteCol = (tr, table, colIndex) => {
92
90
  colgroup.removeChild(colgroup.children[colIndex]);
93
91
  tr.setNodeMarkup(table.pos, null, { ...table.node.attrs, [colgroupAttr]: colgroup.outerHTML });
94
92
  };
95
- const addColumnBefore = (state, dispatch) => {
93
+ export const addColumnBefore = (state, dispatch) => {
96
94
  const cmdDispatch = dispatch && (tr => {
97
95
  const table = closest(tr.selection, reTable);
98
96
  if (!table.node.attrs[colgroupAttr]) {
@@ -101,9 +99,9 @@ const addColumnBefore = (state, dispatch) => {
101
99
  addCol(tr, table, -1);
102
100
  return dispatch(tr);
103
101
  });
104
- return addColumnBefore$1(state, cmdDispatch);
102
+ return pmAddColumnBefore(state, cmdDispatch);
105
103
  };
106
- const addColumnAfter = (state, dispatch) => {
104
+ export const addColumnAfter = (state, dispatch) => {
107
105
  const cmdDispatch = dispatch && (tr => {
108
106
  const table = closest(tr.selection, reTable);
109
107
  if (!table.node.attrs[colgroupAttr]) {
@@ -112,9 +110,9 @@ const addColumnAfter = (state, dispatch) => {
112
110
  addCol(tr, table, 1);
113
111
  return dispatch(tr);
114
112
  });
115
- return addColumnAfter$1(state, cmdDispatch);
113
+ return pmAddColumnAfter(state, cmdDispatch);
116
114
  };
117
- const deleteColumn = (state, dispatch) => {
115
+ export const deleteColumn = (state, dispatch) => {
118
116
  const parentTable = closest(state.selection, reTable);
119
117
  const colgroup = parentTable && parentTable.node.attrs[colgroupAttr];
120
118
  const colIndex = columnIndex(parentTable, state.selection);
@@ -126,7 +124,6 @@ const deleteColumn = (state, dispatch) => {
126
124
  deleteCol(tr, { node: table, pos: parentTable.pos }, colIndex);
127
125
  return dispatch(tr);
128
126
  });
129
- return deleteColumn$1(state, cmdDispatch);
127
+ return pmDeleteColumn(state, cmdDispatch);
130
128
  };
131
-
132
- export { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, createTable, deleteColumn };
129
+ export { pmAddRowBefore, pmAddRowAfter, pmAddColumnBefore, pmAddColumnAfter, pmDeleteColumn };
package/dist/es/text.js CHANGED
@@ -1,5 +1,3 @@
1
- const insertText = (attrs) => (state, dispatch) => {
1
+ export const insertText = (attrs) => (state, dispatch) => {
2
2
  dispatch(state.tr.insertText(attrs.text, attrs.from, attrs.to));
3
3
  };
4
-
5
- export { insertText };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/dist/es/utils.js CHANGED
@@ -1,8 +1,7 @@
1
1
  import { Node } from 'prosemirror-model';
2
2
  import { TextSelection, AllSelection, NodeSelection } from 'prosemirror-state';
3
3
  import { parseInlineStyles } from '@progress/kendo-common';
4
-
5
- const changeStylesString = (styleText, newStyle) => {
4
+ export const changeStylesString = (styleText, newStyle) => {
6
5
  const styleToChange = newStyle.style;
7
6
  const regExp = newStyle.value;
8
7
  const newValue = newStyle.newValue;
@@ -27,7 +26,7 @@ const changeStylesString = (styleText, newStyle) => {
27
26
  };
28
27
  };
29
28
  const reAnyValue = /^.+$/;
30
- function setNodeStyle(nodeAttrs, styleType, value) {
29
+ export function setNodeStyle(nodeAttrs, styleType, value) {
31
30
  let attrs;
32
31
  if (new RegExp('[^-]?' + styleType + ':').test(nodeAttrs.style || '')) {
33
32
  const { style } = changeStylesString(nodeAttrs.style || '', { style: styleType, value: reAnyValue, newValue: value });
@@ -44,7 +43,7 @@ function setNodeStyle(nodeAttrs, styleType, value) {
44
43
  /**
45
44
  * Determines if a given node type can be inserted at the current cursor position.
46
45
  */
47
- const canInsert = (state, nodeType) => {
46
+ export const canInsert = (state, nodeType) => {
48
47
  const $from = state.selection.$from;
49
48
  for (let d = $from.depth; d >= 0; d--) {
50
49
  const index = $from.index(d);
@@ -71,12 +70,12 @@ const findNthParentNode = (predicate, depth = 1) => {
71
70
  }
72
71
  };
73
72
  };
74
- const findNthParentNodeOfType = (nodeType, depth = 1) => {
73
+ export const findNthParentNodeOfType = (nodeType, depth = 1) => {
75
74
  return (selection) => {
76
75
  return findNthParentNode((node) => getTypeName(node) === getTypeName(nodeType), depth)(selection);
77
76
  };
78
77
  };
79
- function parentNode(pos, predicate) {
78
+ export function parentNode(pos, predicate) {
80
79
  for (let depth = pos.depth; depth > 0; depth--) {
81
80
  const node = pos.node(depth);
82
81
  if (predicate(node)) {
@@ -97,7 +96,7 @@ const filterEmptyAttrs = (attrs) => {
97
96
  /**
98
97
  * Inserts the given node at the place of current selection.
99
98
  */
100
- const insertNode = (node, scrollIntoView) => (state, dispatch) => {
99
+ export const insertNode = (node, scrollIntoView) => (state, dispatch) => {
101
100
  const { selection, tr } = state;
102
101
  if (selection instanceof NodeSelection
103
102
  && selection.node.type.name === node.type.name
@@ -113,7 +112,7 @@ const insertNode = (node, scrollIntoView) => (state, dispatch) => {
113
112
  }
114
113
  dispatch(tr);
115
114
  };
116
- const getSelectionText = (state) => {
115
+ export const getSelectionText = (state) => {
117
116
  const sel = state.selection;
118
117
  if (sel instanceof TextSelection || sel instanceof AllSelection) {
119
118
  const fragment = sel.content().content;
@@ -121,7 +120,7 @@ const getSelectionText = (state) => {
121
120
  }
122
121
  return '';
123
122
  };
124
- const getNodeFromSelection = (state) => {
123
+ export const getNodeFromSelection = (state) => {
125
124
  if (state.selection instanceof NodeSelection) {
126
125
  return state.selection.node;
127
126
  }
@@ -134,7 +133,7 @@ const getNodeFromSelection = (state) => {
134
133
  * Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
135
134
  * should be single line text only.
136
135
  */
137
- const selectedLineTextOnly = (state) => {
136
+ export const selectedLineTextOnly = (state) => {
138
137
  let result = '', hasLeafs = false;
139
138
  const { selection, doc } = state;
140
139
  const { $from, $to, from, to } = selection;
@@ -151,24 +150,24 @@ const selectedLineTextOnly = (state) => {
151
150
  /**
152
151
  * Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
153
152
  */
154
- const indentHtml = (content) => {
153
+ export const indentHtml = (content) => {
155
154
  return content.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/ig, '</$1>\n')
156
155
  .replace(/<(ul|ol)([^>]*)><li/ig, '<$1$2>\n<li')
157
156
  .replace(/<br \/>/ig, '<br />\n')
158
157
  .replace(/\n$/, '');
159
158
  };
160
- const shallowEqual = (object1, object2) => {
159
+ export const shallowEqual = (object1, object2) => {
161
160
  const keys1 = Object.keys(object1);
162
161
  const keys2 = Object.keys(object2);
163
162
  return keys1.length === keys2.length &&
164
163
  keys1.every(k => object1[k] === object2[k]);
165
164
  };
166
- const applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
165
+ const applyToWordDefault = { before: /[^ !,?.[\]{}()]+$/i, after: /^[^ !,?.[\]{}()]+/i };
167
166
  /**
168
167
  * if options.applyToWord is set, expands the selection to the word where the cursor is and
169
168
  * returns modified state and dispatch.
170
169
  */
171
- const expandSelection = (state, dispatch, options) => {
170
+ export const expandSelection = (state, dispatch, options) => {
172
171
  if (!options.applyToWord || !state.selection.empty) {
173
172
  return { state, dispatch };
174
173
  }
@@ -244,16 +243,16 @@ const expandSelection = (state, dispatch, options) => {
244
243
  * const command = expandToWordWrap(toggleInlineFormat, {...bold, applyToWord );
245
244
  * command(view.state, view.dispatch);
246
245
  */
247
- const expandToWordWrap = (command, options) => {
246
+ export const expandToWordWrap = (command, options) => {
248
247
  return (state, dispatch) => {
249
248
  const { state: cmdState, dispatch: cmdDispatch } = expandSelection(state, dispatch, options);
250
249
  return command(options)(cmdState, cmdDispatch);
251
250
  };
252
251
  };
253
- const parseStyle = (styleText) => {
252
+ export const parseStyle = (styleText) => {
254
253
  return parseInlineStyles(styleText);
255
254
  };
256
- const applyStyle = (styleText, styleType, styleValue) => {
255
+ export const applyStyle = (styleText, styleType, styleValue) => {
257
256
  const styles = parseStyle(styleText);
258
257
  styles[styleType] = styleValue;
259
258
  const result = Object.keys(styles)
@@ -262,7 +261,7 @@ const applyStyle = (styleText, styleType, styleValue) => {
262
261
  .join('; ');
263
262
  return result ? result + ';' : null;
264
263
  };
265
- const setStyleAttr = (element, styleString) => {
264
+ export const setStyleAttr = (element, styleString) => {
266
265
  const styles = parseStyle(styleString);
267
266
  for (const style in styles) {
268
267
  if (style && element.style[style] !== undefined) {
@@ -270,7 +269,7 @@ const setStyleAttr = (element, styleString) => {
270
269
  }
271
270
  }
272
271
  };
273
- const setAttribute = (node, attrName, value) => {
272
+ export const setAttribute = (node, attrName, value) => {
274
273
  const current = node.getAttribute(attrName);
275
274
  if (value !== undefined && value !== current) {
276
275
  if (attrName === 'style') {
@@ -285,5 +284,3 @@ const setAttribute = (node, attrName, value) => {
285
284
  node.removeAttribute(attrName);
286
285
  }
287
286
  };
288
-
289
- export { applyStyle, canInsert, changeStylesString, expandSelection, expandToWordWrap, findNthParentNodeOfType, getNodeFromSelection, getSelectionText, indentHtml, insertNode, parentNode, parseStyle, selectedLineTextOnly, setAttribute, setNodeStyle, setStyleAttr, shallowEqual };
@@ -0,0 +1,35 @@
1
+ import { DOMOutputSpec, Fragment, Mark, Node, Schema } from 'prosemirror-model';
2
+ type DOMNode = InstanceType<typeof window.Node>;
3
+ export declare class DOMSerializer {
4
+ readonly nodes: {
5
+ [node: string]: (node: Node) => DOMOutputSpec;
6
+ };
7
+ readonly marks: {
8
+ [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
9
+ };
10
+ static renderSpec(docum: Document, structure: DOMOutputSpec, xmlNS?: string | null): {
11
+ dom: DOMNode;
12
+ contentDOM?: HTMLElement;
13
+ };
14
+ static fromSchema(schema: Schema): DOMSerializer;
15
+ static nodesFromSchema(schema: Schema): {
16
+ [node: string]: (node: Node) => DOMOutputSpec;
17
+ };
18
+ static marksFromSchema(schema: Schema): {
19
+ [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
20
+ };
21
+ constructor(nodes: {
22
+ [node: string]: (node: Node) => DOMOutputSpec;
23
+ }, marks: {
24
+ [mark: string]: (mark: Mark, inline: boolean) => DOMOutputSpec;
25
+ });
26
+ serializeFragment(fragment: Fragment, options?: {
27
+ document?: Document;
28
+ }, target?: HTMLElement | DocumentFragment): HTMLElement | DocumentFragment;
29
+ serializeNode(node: Node, options?: {
30
+ document?: Document;
31
+ }): globalThis.Node;
32
+ private serializeMark;
33
+ private serializeNodeInner;
34
+ }
35
+ export {};
@@ -1,7 +1,7 @@
1
- 'use strict';
2
-
3
- var utils = require('./utils.js');
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DOMSerializer = void 0;
4
+ const utils_1 = require("./utils");
5
5
  class DOMSerializer {
6
6
  /// Render an [output spec](#model.DOMOutputSpec) to a DOM node. If
7
7
  /// the spec has a hole (zero) in it, `contentDOM` will point at the
@@ -23,7 +23,8 @@ class DOMSerializer {
23
23
  }
24
24
  let contentDOM;
25
25
  const dom = (xmlNS ? docum.createElementNS(xmlNS, tagName) : docum.createElement(tagName));
26
- let attrs = structure[1], start = 1;
26
+ const attrs = structure[1];
27
+ let start = 1;
27
28
  if (attrs && typeof attrs === 'object' && attrs.nodeType == null && !Array.isArray(attrs)) {
28
29
  start = 2;
29
30
  for (const name in attrs) {
@@ -33,7 +34,7 @@ class DOMSerializer {
33
34
  dom.setAttributeNS(name.slice(0, space), name.slice(space + 1), attrs[name]);
34
35
  }
35
36
  else {
36
- utils.setAttribute(dom, name, attrs[name]);
37
+ (0, utils_1.setAttribute)(dom, name, attrs[name]);
37
38
  }
38
39
  }
39
40
  }
@@ -101,7 +102,8 @@ class DOMSerializer {
101
102
  if (!target) {
102
103
  target = doc(options).createDocumentFragment();
103
104
  }
104
- let top = target, active = [];
105
+ let top = target;
106
+ const active = [];
105
107
  fragment.forEach(node => {
106
108
  if (active.length || node.marks.length) {
107
109
  let keep = 0, rendered = 0;
@@ -167,6 +169,7 @@ class DOMSerializer {
167
169
  return dom;
168
170
  }
169
171
  }
172
+ exports.DOMSerializer = DOMSerializer;
170
173
  function gatherToDOM(obj) {
171
174
  const result = {};
172
175
  for (const name in obj) {
@@ -182,5 +185,3 @@ function gatherToDOM(obj) {
182
185
  function doc(options) {
183
186
  return options.document || window.document;
184
187
  }
185
-
186
- exports.DOMSerializer = DOMSerializer;
@@ -1,13 +1,10 @@
1
1
  import { EditorState } from 'prosemirror-state';
2
- import { AlignRule } from './config/align-rules.js';
3
- import { Command } from './types/command.js';
4
-
2
+ import { AlignRule } from './config/align-rules';
3
+ import { Command } from './types/command';
5
4
  /**
6
5
  * Aligning block elements in the selection.
7
6
  *
8
7
  * @returns {boolean} - Returns true if any alignment is applied.
9
8
  */
10
- declare const alignBlocks: (actions: Array<AlignRule>, commandName?: string) => Command;
11
- declare const isAligned: (state: EditorState, actions: Array<AlignRule>) => boolean;
12
-
13
- export { alignBlocks, isAligned };
9
+ export declare const alignBlocks: (actions: Array<AlignRule>, commandName?: string) => Command;
10
+ export declare const isAligned: (state: EditorState, actions: Array<AlignRule>) => boolean;
package/dist/npm/align.js CHANGED
@@ -1,22 +1,22 @@
1
- 'use strict';
2
-
3
- var blockNode = require('./blockNode.js');
4
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAligned = exports.alignBlocks = void 0;
4
+ const blockNode_1 = require("./blockNode");
5
5
  /**
6
6
  * Aligning block elements in the selection.
7
7
  *
8
8
  * @returns {boolean} - Returns true if any alignment is applied.
9
9
  */
10
10
  const alignBlocks = (actions, commandName) => (state, dispatch) => {
11
- const blocks = blockNode.blockNodes(state);
11
+ const blocks = (0, blockNode_1.blockNodes)(state);
12
12
  const tr = state.tr;
13
13
  tr.setMeta('commandName', commandName);
14
14
  blocks.forEach(node => {
15
15
  if (node.type.isTextblock) {
16
16
  const action = actions.find(n => n.node === node.type.name);
17
17
  if (action) {
18
- const newAttrs = blockNode.addStyles(node, action.style);
19
- blockNode.changeTextBlock(tr, node, node.type, newAttrs);
18
+ const newAttrs = (0, blockNode_1.addStyles)(node, action.style);
19
+ (0, blockNode_1.changeTextBlock)(tr, node, node.type, newAttrs);
20
20
  }
21
21
  }
22
22
  });
@@ -26,8 +26,9 @@ const alignBlocks = (actions, commandName) => (state, dispatch) => {
26
26
  }
27
27
  return result;
28
28
  };
29
+ exports.alignBlocks = alignBlocks;
29
30
  const isAligned = (state, actions) => {
30
- const blocks = blockNode.blockNodes(state);
31
+ const blocks = (0, blockNode_1.blockNodes)(state);
31
32
  let result = false;
32
33
  blocks.forEach(node => {
33
34
  if (!result && node.type.isTextblock && node.attrs.style) {
@@ -41,6 +42,4 @@ const isAligned = (state, actions) => {
41
42
  });
42
43
  return result;
43
44
  };
44
-
45
- exports.alignBlocks = alignBlocks;
46
45
  exports.isAligned = isAligned;
@@ -1,14 +1,13 @@
1
1
  import { NodeType, Node } from 'prosemirror-model';
2
2
  import { EditorState, Transaction, Selection } from 'prosemirror-state';
3
- import { CleanFormattingOptions } from './cleanFormatting.js';
4
-
3
+ import { CleanFormattingOptions } from './cleanFormatting';
5
4
  /**
6
5
  * Changes the type or the attributes of the passed node.
7
6
  *
8
7
  * @example
9
8
  * See `cleanTextBlockFormatting` or `formatBlockElements` function.
10
9
  */
11
- declare const changeTextBlock: (tr: Transaction, node: Node, nodeType: NodeType, attrs?: {
10
+ export declare const changeTextBlock: (tr: Transaction, node: Node, nodeType: NodeType, attrs?: {
12
11
  [key: string]: any;
13
12
  }) => boolean;
14
13
  /**
@@ -17,13 +16,13 @@ declare const changeTextBlock: (tr: Transaction, node: Node, nodeType: NodeType,
17
16
  * @example
18
17
  * See `cleanTextBlockFormatting` function.
19
18
  */
20
- declare const blockNodes: (state: EditorState | {
19
+ export declare const blockNodes: (state: EditorState | {
21
20
  doc: Node;
22
21
  selection: Selection;
23
22
  }, options?: {
24
23
  blocksInSelection: boolean;
25
24
  }) => Array<Node>;
26
- declare const formatBlockElements: (value: "p" | "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6", commandName?: string) => (state: any, dispatch: any) => any;
25
+ export declare const formatBlockElements: (value: "p" | "blockquote" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6", commandName?: string) => (state: any, dispatch: any) => any;
27
26
  /**
28
27
  * Removes the style and class attributes of text block elements.
29
28
  * Requires to dispatch the transaction.
@@ -31,15 +30,19 @@ declare const formatBlockElements: (value: "p" | "blockquote" | "h1" | "h2" | "h
31
30
  * @example
32
31
  * See `cleanFormatting` function.
33
32
  */
34
- declare const cleanTextBlockFormatting: (tr: Transaction, options?: CleanFormattingOptions) => void;
35
- declare const getBlockFormats: (state: EditorState) => Array<string>;
36
- declare const hasNode: (state: EditorState, nodeType: NodeType) => boolean;
37
- declare const parentBlockFormat: (state: EditorState) => string | null;
33
+ export declare const cleanTextBlockFormatting: (tr: Transaction, options?: CleanFormattingOptions) => void;
34
+ export declare const getBlockFormats: (state: EditorState) => Array<string>;
35
+ export declare const addStyles: (node: Node, stylesToApply: Array<{
36
+ name: string;
37
+ value: string;
38
+ }>) => import("prosemirror-model").Attrs & {
39
+ style: string;
40
+ };
41
+ export declare const hasNode: (state: EditorState, nodeType: NodeType) => boolean;
42
+ export declare const parentBlockFormat: (state: EditorState) => string | null;
38
43
  /**
39
44
  * **Deprecated.** Use `parentBlockFormat` function instead.
40
45
  */
41
- declare const activeNode: (state: EditorState) => {
46
+ export declare const activeNode: (state: EditorState) => {
42
47
  tag: string;
43
48
  };
44
-
45
- export { activeNode, blockNodes, changeTextBlock, cleanTextBlockFormatting, formatBlockElements, getBlockFormats, hasNode, parentBlockFormat };
@@ -1,10 +1,10 @@
1
- 'use strict';
2
-
3
- var utils = require('./utils.js');
4
- var prosemirrorTransform = require('prosemirror-transform');
5
- var prosemirrorModel = require('prosemirror-model');
6
- var prosemirrorState = require('prosemirror-state');
7
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.activeNode = exports.parentBlockFormat = exports.hasNode = exports.addStyles = exports.getBlockFormats = exports.cleanTextBlockFormatting = exports.formatBlockElements = exports.blockNodes = exports.changeTextBlock = void 0;
4
+ const utils_1 = require("./utils");
5
+ const prosemirror_transform_1 = require("prosemirror-transform");
6
+ const prosemirror_model_1 = require("prosemirror-model");
7
+ const prosemirror_state_1 = require("prosemirror-state");
8
8
  /**
9
9
  * @hidden
10
10
  */
@@ -36,13 +36,14 @@ const changeTextBlock = (tr, node, nodeType, attrs) => {
36
36
  tr.clearIncompatible(tr.mapping.slice(mapFrom).map(pos, 1), nodeType);
37
37
  const mapping = tr.mapping.slice(mapFrom);
38
38
  const startM = mapping.map(pos, 1), endM = mapping.map(pos + currNode.nodeSize, 1);
39
- const slice = new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(nodeType.create(attrs, null, currNode.marks)), 0, 0);
40
- tr.step(new prosemirrorTransform.ReplaceAroundStep(startM, endM, startM + 1, endM - 1, slice, 1, true));
39
+ const slice = new prosemirror_model_1.Slice(prosemirror_model_1.Fragment.from(nodeType.create(attrs, null, currNode.marks)), 0, 0);
40
+ tr.step(new prosemirror_transform_1.ReplaceAroundStep(startM, endM, startM + 1, endM - 1, slice, 1, true));
41
41
  return false; // this will skip the node children
42
42
  }
43
43
  });
44
44
  });
45
45
  };
46
+ exports.changeTextBlock = changeTextBlock;
46
47
  /**
47
48
  * Traverses the selection and returns the block nodes in it.
48
49
  *
@@ -54,7 +55,7 @@ const blockNodes = (state, options = { blocksInSelection: false }) => {
54
55
  const { $from, ranges } = selection;
55
56
  const { blocksInSelection } = options;
56
57
  const result = [];
57
- const selNode = selection instanceof prosemirrorState.NodeSelection ? selection.node : undefined;
58
+ const selNode = selection instanceof prosemirror_state_1.NodeSelection ? selection.node : undefined;
58
59
  if (selNode) {
59
60
  if (selNode.isBlock) {
60
61
  result.push(selNode);
@@ -81,8 +82,9 @@ const blockNodes = (state, options = { blocksInSelection: false }) => {
81
82
  }
82
83
  return result;
83
84
  };
85
+ exports.blockNodes = blockNodes;
84
86
  const formatBlockElements = (value, commandName) => (state, dispatch) => {
85
- const blocks = blockNodes(state);
87
+ const blocks = (0, exports.blockNodes)(state);
86
88
  const nodes = state.schema.nodes;
87
89
  const tr = state.tr;
88
90
  tr.setMeta('commandName', commandName);
@@ -90,14 +92,14 @@ const formatBlockElements = (value, commandName) => (state, dispatch) => {
90
92
  blocks.forEach(node => {
91
93
  if (node.type.isTextblock) {
92
94
  if (value === 'p') {
93
- changeTextBlock(tr, node, nodes.paragraph, node.attrs);
95
+ (0, exports.changeTextBlock)(tr, node, nodes.paragraph, node.attrs);
94
96
  }
95
97
  else if (/^h[1-6]$/i.test(value)) {
96
98
  const level = parseInt(value.substr(1), 10);
97
- changeTextBlock(tr, node, nodes.heading, { ...node.attrs, level });
99
+ (0, exports.changeTextBlock)(tr, node, nodes.heading, { ...node.attrs, level });
98
100
  }
99
101
  else if (value === 'blockquote') {
100
- changeTextBlock(tr, node, nodes.blockquote, node.attrs);
102
+ (0, exports.changeTextBlock)(tr, node, nodes.blockquote, node.attrs);
101
103
  }
102
104
  }
103
105
  });
@@ -107,6 +109,7 @@ const formatBlockElements = (value, commandName) => (state, dispatch) => {
107
109
  }
108
110
  return result;
109
111
  };
112
+ exports.formatBlockElements = formatBlockElements;
110
113
  /**
111
114
  * Removes the style and class attributes of text block elements.
112
115
  * Requires to dispatch the transaction.
@@ -117,18 +120,19 @@ const formatBlockElements = (value, commandName) => (state, dispatch) => {
117
120
  const cleanTextBlockFormatting = (tr, options = { blocksInSelection: true }) => {
118
121
  const { doc, selection } = tr;
119
122
  const { blocksInSelection, blockNodeType } = options;
120
- const nodes = blockNodes({ doc, selection }, { blocksInSelection });
123
+ const nodes = (0, exports.blockNodes)({ doc, selection }, { blocksInSelection });
121
124
  const textBlocks = nodes.filter(node => node.isTextblock);
122
125
  textBlocks.forEach(node => {
123
126
  const { style = '', class: className = '', ...attrs } = node.attrs || {};
124
127
  const nodeType = blockNodeType || node.type;
125
128
  if (style || className || nodeType !== node.type) {
126
- changeTextBlock(tr, node, nodeType, attrs);
129
+ (0, exports.changeTextBlock)(tr, node, nodeType, attrs);
127
130
  }
128
131
  });
129
132
  };
133
+ exports.cleanTextBlockFormatting = cleanTextBlockFormatting;
130
134
  const getBlockFormats = (state) => {
131
- const blocks = blockNodes(state);
135
+ const blocks = (0, exports.blockNodes)(state);
132
136
  const nodes = state.schema.nodes;
133
137
  const result = [];
134
138
  blocks.forEach((node) => {
@@ -145,12 +149,13 @@ const getBlockFormats = (state) => {
145
149
  });
146
150
  return result;
147
151
  };
152
+ exports.getBlockFormats = getBlockFormats;
148
153
  const addStyles = (node, stylesToApply) => {
149
154
  let currentStyles = node.attrs.style, changedStyleResult, toChange;
150
155
  if (currentStyles) {
151
156
  stylesToApply.forEach(style => {
152
157
  toChange = { style: style.name, value: /^.+$/, newValue: style.value };
153
- changedStyleResult = utils.changeStylesString(currentStyles, toChange);
158
+ changedStyleResult = (0, utils_1.changeStylesString)(currentStyles, toChange);
154
159
  currentStyles = changedStyleResult.changed ? changedStyleResult.style : currentStyles;
155
160
  });
156
161
  }
@@ -158,6 +163,7 @@ const addStyles = (node, stylesToApply) => {
158
163
  currentStyles = currentStyles || stylesToApply.reduce(reducer, '');
159
164
  return Object.assign({}, node.attrs, { style: currentStyles || null });
160
165
  };
166
+ exports.addStyles = addStyles;
161
167
  const hasNode = (state, nodeType) => {
162
168
  const { from, to } = state.selection;
163
169
  let result = false;
@@ -167,23 +173,16 @@ const hasNode = (state, nodeType) => {
167
173
  });
168
174
  return result;
169
175
  };
176
+ exports.hasNode = hasNode;
170
177
  const parentBlockFormat = (state) => {
171
- const formats = getBlockFormats(state);
178
+ const formats = (0, exports.getBlockFormats)(state);
172
179
  return new Set(formats).size === 1 ? formats[0] : null;
173
180
  };
181
+ exports.parentBlockFormat = parentBlockFormat;
174
182
  /**
175
183
  * **Deprecated.** Use `parentBlockFormat` function instead.
176
184
  */
177
185
  const activeNode = (state) => {
178
- return { tag: parentBlockFormat(state) || '' };
186
+ return { tag: (0, exports.parentBlockFormat)(state) || '' };
179
187
  };
180
-
181
188
  exports.activeNode = activeNode;
182
- exports.addStyles = addStyles;
183
- exports.blockNodes = blockNodes;
184
- exports.changeTextBlock = changeTextBlock;
185
- exports.cleanTextBlockFormatting = cleanTextBlockFormatting;
186
- exports.formatBlockElements = formatBlockElements;
187
- exports.getBlockFormats = getBlockFormats;
188
- exports.hasNode = hasNode;
189
- exports.parentBlockFormat = parentBlockFormat;
@@ -1,6 +1,3 @@
1
1
  import { EditorState, Transaction } from 'prosemirror-state';
2
-
3
- declare const blockquote: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
4
- declare const liftBlockquote: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
5
-
6
- export { blockquote, liftBlockquote };
2
+ export declare const blockquote: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
3
+ export declare const liftBlockquote: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;