@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.
- package/dist/cdn/main.js +1 -1
- package/dist/es/DOMSerializer.js +71 -75
- package/dist/es/align.js +19 -16
- package/dist/es/blockNode.js +76 -78
- package/dist/es/blockquote.js +12 -9
- package/dist/es/cleanFormatting.js +16 -16
- package/dist/es/config/align-rules.js +8 -6
- package/dist/es/config/commands.js +9 -13
- package/dist/es/config/constants.js +9 -7
- package/dist/es/config/indent-rules.js +8 -6
- package/dist/es/config/keymap.js +20 -18
- package/dist/es/config/list-settings.js +7 -6
- package/dist/es/config/schema.js +184 -126
- package/dist/es/find-replace.js +34 -32
- package/dist/es/image.js +10 -7
- package/dist/es/indent.js +47 -44
- package/dist/es/inline-style.js +72 -70
- package/dist/es/link.js +51 -52
- package/dist/es/listConvert.js +37 -34
- package/dist/es/lists.js +83 -82
- package/dist/es/main.js +32 -33
- package/dist/es/mark.js +87 -92
- package/dist/es/paste.js +48 -46
- package/dist/es/plugins/caret-color.js +14 -11
- package/dist/es/plugins/csp-fix.js +23 -23
- package/dist/es/plugins/highlight.js +12 -10
- package/dist/es/plugins/image-resize.js +81 -81
- package/dist/es/plugins/list-markers-styles.js +43 -39
- package/dist/es/plugins/placeholder.js +12 -9
- package/dist/es/plugins/resize-utils.js +11 -9
- package/dist/es/plugins/spaces-fix.js +13 -10
- package/dist/es/plugins/table-resize/column-resize.js +104 -102
- package/dist/es/plugins/table-resize/index.js +10 -7
- package/dist/es/plugins/table-resize/row-resize.js +88 -89
- package/dist/es/plugins/table-resize/table-resize.js +129 -122
- package/dist/es/plugins/table-resize/table-view.js +46 -48
- package/dist/es/plugins/table-resize/utils.js +39 -41
- package/dist/es/source.js +78 -74
- package/dist/es/table.js +64 -66
- package/dist/es/text.js +4 -2
- package/dist/es/utils.js +107 -116
- package/dist/es2015/DOMSerializer.js +20 -17
- package/dist/es2015/align.js +6 -3
- package/dist/es2015/blockNode.js +15 -12
- package/dist/es2015/blockquote.js +5 -2
- package/dist/es2015/cleanFormatting.js +6 -3
- package/dist/es2015/config/align-rules.js +7 -5
- package/dist/es2015/config/commands.js +9 -13
- package/dist/es2015/config/constants.js +9 -7
- package/dist/es2015/config/indent-rules.js +6 -3
- package/dist/es2015/config/keymap.js +10 -7
- package/dist/es2015/config/list-settings.js +5 -3
- package/dist/es2015/config/schema.js +8 -6
- package/dist/es2015/find-replace.js +9 -6
- package/dist/es2015/image.js +5 -2
- package/dist/es2015/indent.js +14 -11
- package/dist/es2015/inline-style.js +9 -6
- package/dist/es2015/link.js +7 -4
- package/dist/es2015/listConvert.js +5 -2
- package/dist/es2015/lists.js +14 -11
- package/dist/es2015/main.js +32 -33
- package/dist/es2015/mark.js +15 -12
- package/dist/es2015/node_modules/tslib/tslib.es6.js +35 -0
- package/dist/es2015/paste.js +14 -11
- package/dist/es2015/plugins/caret-color.js +8 -5
- package/dist/es2015/plugins/csp-fix.js +5 -2
- package/dist/es2015/plugins/highlight.js +6 -3
- package/dist/es2015/plugins/image-resize.js +10 -7
- package/dist/es2015/plugins/list-markers-styles.js +6 -3
- package/dist/es2015/plugins/placeholder.js +5 -2
- package/dist/es2015/plugins/resize-utils.js +11 -9
- package/dist/es2015/plugins/spaces-fix.js +4 -1
- package/dist/es2015/plugins/table-resize/column-resize.js +24 -21
- package/dist/es2015/plugins/table-resize/index.js +9 -6
- package/dist/es2015/plugins/table-resize/row-resize.js +23 -20
- package/dist/es2015/plugins/table-resize/table-resize.js +20 -17
- package/dist/es2015/plugins/table-resize/table-view.js +9 -6
- package/dist/es2015/plugins/table-resize/utils.js +13 -10
- package/dist/es2015/source.js +24 -13
- package/dist/es2015/table.js +18 -15
- package/dist/es2015/text.js +3 -1
- package/dist/es2015/utils.js +22 -25
- package/dist/npm/DOMSerializer.js +73 -78
- package/dist/npm/align.d.ts +7 -4
- package/dist/npm/align.js +22 -21
- package/dist/npm/blockNode.d.ts +14 -15
- package/dist/npm/blockNode.js +91 -95
- package/dist/npm/blockquote.d.ts +5 -2
- package/dist/npm/blockquote.js +16 -15
- package/dist/npm/cleanFormatting.d.ts +6 -3
- package/dist/npm/cleanFormatting.js +17 -19
- package/dist/npm/config/align-rules.d.ts +8 -6
- package/dist/npm/config/align-rules.js +14 -9
- package/dist/npm/config/commands.d.ts +11 -19
- package/dist/npm/config/commands.js +17 -16
- package/dist/npm/config/constants.js +17 -10
- package/dist/npm/config/indent-rules.d.ts +6 -4
- package/dist/npm/config/indent-rules.js +11 -9
- package/dist/npm/config/keymap.d.ts +5 -2
- package/dist/npm/config/keymap.js +30 -30
- package/dist/npm/config/list-settings.js +13 -11
- package/dist/npm/config/schema.d.ts +4 -3
- package/dist/npm/config/schema.js +191 -134
- package/dist/npm/find-replace.d.ts +10 -7
- package/dist/npm/find-replace.js +47 -47
- package/dist/npm/image.d.ts +6 -3
- package/dist/npm/image.js +11 -10
- package/dist/npm/indent.d.ts +12 -9
- package/dist/npm/indent.js +68 -67
- package/dist/npm/inline-style.d.ts +7 -4
- package/dist/npm/inline-style.js +83 -83
- package/dist/npm/link.d.ts +4 -2
- package/dist/npm/link.js +58 -61
- package/dist/npm/listConvert.d.ts +3 -1
- package/dist/npm/listConvert.js +40 -39
- package/dist/npm/lists.d.ts +9 -9
- package/dist/npm/lists.js +94 -95
- package/dist/npm/main.d.ts +34 -33
- package/dist/npm/main.js +388 -198
- package/dist/npm/mark.d.ts +13 -18
- package/dist/npm/mark.js +104 -111
- package/dist/npm/paste.d.ts +12 -9
- package/dist/npm/paste.js +61 -61
- package/dist/npm/plugins/caret-color.d.ts +6 -3
- package/dist/npm/plugins/caret-color.js +21 -19
- package/dist/npm/plugins/csp-fix.d.ts +4 -1
- package/dist/npm/plugins/csp-fix.js +28 -30
- package/dist/npm/plugins/highlight.d.ts +7 -4
- package/dist/npm/plugins/highlight.js +17 -16
- package/dist/npm/plugins/image-resize.d.ts +7 -5
- package/dist/npm/plugins/image-resize.js +96 -97
- package/dist/npm/plugins/list-markers-styles.d.ts +5 -2
- package/dist/npm/plugins/list-markers-styles.js +49 -47
- package/dist/npm/plugins/placeholder.d.ts +4 -1
- package/dist/npm/plugins/placeholder.js +18 -17
- package/dist/npm/plugins/resize-utils.js +14 -12
- package/dist/npm/plugins/spaces-fix.d.ts +4 -1
- package/dist/npm/plugins/spaces-fix.js +19 -18
- package/dist/npm/plugins/table-resize/column-resize.js +117 -117
- package/dist/npm/plugins/table-resize/index.d.ts +5 -2
- package/dist/npm/plugins/table-resize/index.js +16 -15
- package/dist/npm/plugins/table-resize/row-resize.js +98 -101
- package/dist/npm/plugins/table-resize/table-resize.js +144 -139
- package/dist/npm/plugins/table-resize/table-view.js +59 -61
- package/dist/npm/plugins/table-resize/utils.d.ts +7 -17
- package/dist/npm/plugins/table-resize/utils.js +51 -52
- package/dist/npm/source.d.ts +18 -11
- package/dist/npm/source.js +94 -91
- package/dist/npm/table.d.ts +10 -9
- package/dist/npm/table.js +93 -82
- package/dist/npm/text.d.ts +6 -3
- package/dist/npm/text.js +5 -5
- package/dist/npm/types/active-marks.d.ts +4 -1
- package/dist/npm/types/command.d.ts +5 -2
- package/dist/npm/types/dispatchFn.d.ts +4 -1
- package/dist/npm/types/paste-cleanup-settings.d.ts +3 -1
- package/dist/npm/utils.d.ts +13 -32
- package/dist/npm/utils.js +133 -145
- package/package.json +34 -52
- package/dist/cdn/js/kendo-editor-common.js +0 -1
- package/dist/es/types/active-marks.js +0 -1
- package/dist/es/types/command.js +0 -1
- package/dist/es/types/dispatchFn.js +0 -1
- package/dist/es/types/paste-cleanup-settings.js +0 -1
- package/dist/es/types/predicate.js +0 -1
- package/dist/es2015/types/active-marks.js +0 -1
- package/dist/es2015/types/command.js +0 -1
- package/dist/es2015/types/dispatchFn.js +0 -1
- package/dist/es2015/types/paste-cleanup-settings.js +0 -1
- package/dist/es2015/types/predicate.js +0 -1
- package/dist/npm/DOMSerializer.d.ts +0 -35
- package/dist/npm/config/constants.d.ts +0 -7
- package/dist/npm/config/list-settings.d.ts +0 -30
- package/dist/npm/plugins/resize-utils.d.ts +0 -35
- package/dist/npm/plugins/table-resize/column-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/row-resize.d.ts +0 -2
- package/dist/npm/plugins/table-resize/table-resize.d.ts +0 -18
- package/dist/npm/plugins/table-resize/table-view.d.ts +0 -28
- package/dist/npm/types/active-marks.js +0 -2
- package/dist/npm/types/command.js +0 -2
- package/dist/npm/types/dispatchFn.js +0 -2
- package/dist/npm/types/paste-cleanup-settings.js +0 -2
- package/dist/npm/types/predicate.d.ts +0 -1
- package/dist/npm/types/predicate.js +0 -2
- package/dist/systemjs/kendo-editor-common.js +0 -1
package/dist/npm/find-replace.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var searchText = searchOptions.text;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorState = require('prosemirror-state');
|
|
4
|
+
|
|
5
|
+
const findAt = (doc, searchOptions, start, end, exit) => {
|
|
6
|
+
let result = [], exec, text, from, to, childText, nextSibling;
|
|
7
|
+
const nodes = [];
|
|
8
|
+
const { matchCase, matchWord, useRegExp } = searchOptions;
|
|
9
|
+
let searchText = searchOptions.text;
|
|
11
10
|
if (useRegExp && (/^\\$/.test(searchText) || /[^\\]\\$/.test(searchText))) {
|
|
12
11
|
// lookbehind doesn't work in Edge -> /((?<!\\)\\)$/.test(searchText)
|
|
13
12
|
searchText = searchText.substring(0, searchText.length - 1);
|
|
@@ -15,19 +14,19 @@ var findAt = function (doc, searchOptions, start, end, exit) {
|
|
|
15
14
|
if (!searchText) {
|
|
16
15
|
return result;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
doc.nodesBetween(start, end,
|
|
17
|
+
const flags = matchCase ? 'g' : 'gi';
|
|
18
|
+
const regExp = useRegExp ? new RegExp(searchText, flags) : createRegExp(searchText, flags);
|
|
19
|
+
doc.nodesBetween(start, end, (node, pos) => {
|
|
21
20
|
if (exit(result)) {
|
|
22
21
|
return false;
|
|
23
22
|
}
|
|
24
23
|
if (node.inlineContent && pos + node.content.size >= start) {
|
|
25
24
|
nodes.length = 0;
|
|
26
|
-
node.nodesBetween(0, node.content.size,
|
|
25
|
+
node.nodesBetween(0, node.content.size, (child, childPos, parent, i) => {
|
|
27
26
|
if (exit(result)) {
|
|
28
27
|
return false;
|
|
29
28
|
}
|
|
30
|
-
|
|
29
|
+
const posToDoc = 1 + pos + childPos;
|
|
31
30
|
if (child.isText && posToDoc + child.nodeSize >= start) {
|
|
32
31
|
childText = child.text || '';
|
|
33
32
|
nextSibling = parent.childCount - 1 >= i + 1 && parent.child(i + 1);
|
|
@@ -37,13 +36,13 @@ var findAt = function (doc, searchOptions, start, end, exit) {
|
|
|
37
36
|
if (nextSibling && nextSibling.isText) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
text = nodes.map(
|
|
39
|
+
text = nodes.map(t => t.text).join('');
|
|
41
40
|
exec = regExp.exec(text);
|
|
42
41
|
while (exec !== null) {
|
|
43
42
|
from = nodes[0].start + exec.index;
|
|
44
43
|
to = from + exec[0].length;
|
|
45
44
|
if (start <= from && end >= to && shouldMatchWord(exec, matchWord)) {
|
|
46
|
-
result.push(
|
|
45
|
+
result.push(prosemirrorState.TextSelection.create(doc, from, to));
|
|
47
46
|
}
|
|
48
47
|
if (exit(result)) {
|
|
49
48
|
break;
|
|
@@ -59,69 +58,70 @@ var findAt = function (doc, searchOptions, start, end, exit) {
|
|
|
59
58
|
});
|
|
60
59
|
return result;
|
|
61
60
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
var result = [];
|
|
61
|
+
const find = (state, searchOptions) => {
|
|
62
|
+
const { backward, matchCyclic, ...options } = searchOptions;
|
|
63
|
+
const exit = backward ? () => false : r => r.length > 0;
|
|
64
|
+
const { doc, selection } = state;
|
|
65
|
+
let result = [];
|
|
68
66
|
if (backward) {
|
|
69
|
-
result =
|
|
67
|
+
result = findAt(doc, options, 0, selection.from, exit);
|
|
70
68
|
if (!result.length && matchCyclic) {
|
|
71
|
-
result =
|
|
69
|
+
result = findAt(doc, options, selection.from, doc.content.size, exit);
|
|
72
70
|
}
|
|
73
71
|
}
|
|
74
72
|
else {
|
|
75
|
-
result =
|
|
73
|
+
result = findAt(doc, options, selection.to, doc.content.size, exit);
|
|
76
74
|
if (!result.length && matchCyclic) {
|
|
77
|
-
result =
|
|
75
|
+
result = findAt(doc, options, 0, selection.to, exit);
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
return result.length ? result[result.length - 1] : null;
|
|
81
79
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return (0, exports.findAt)(doc, searchOptions, 0, doc.content.size, function () { return false; });
|
|
80
|
+
const findAll = (doc, searchOptions) => {
|
|
81
|
+
return findAt(doc, searchOptions, 0, doc.content.size, () => false);
|
|
85
82
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var from = selection.from, to = selection.to;
|
|
83
|
+
const replace = (selection, text, transaction) => {
|
|
84
|
+
const { from, to } = selection;
|
|
89
85
|
transaction.insertText(text, from, to)
|
|
90
|
-
.setSelection(
|
|
86
|
+
.setSelection(prosemirrorState.TextSelection.create(transaction.doc, from, from + text.length));
|
|
91
87
|
return transaction;
|
|
92
88
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var result = (0, exports.findAll)(state.doc, searchOptions);
|
|
89
|
+
const replaceAll = (state, replaceText, searchOptions) => {
|
|
90
|
+
const result = findAll(state.doc, searchOptions);
|
|
96
91
|
if (result.length === 0) {
|
|
97
92
|
return null;
|
|
98
93
|
}
|
|
99
|
-
|
|
100
|
-
for (
|
|
94
|
+
const transaction = state.tr;
|
|
95
|
+
for (let i = result.length - 1; i >= 0; i--) {
|
|
101
96
|
transaction.insertText(replaceText, result[i].from, result[i].to);
|
|
102
97
|
}
|
|
103
98
|
return transaction;
|
|
104
99
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
var shouldMatchWord = function (exec, matchWord) {
|
|
100
|
+
const notLetter = /^[\s0-9~`!@#$%\^&*\(\)_\-=+\\|\[\]{};:'"\?/.,<>]?$/;
|
|
101
|
+
const shouldMatchWord = (exec, matchWord) => {
|
|
108
102
|
if (!matchWord) {
|
|
109
103
|
return true;
|
|
110
104
|
}
|
|
111
105
|
else if (matchWord === true) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
const text = exec.input;
|
|
107
|
+
const charBefore = text.charAt(exec.index - 1);
|
|
108
|
+
const charAfter = text.charAt(exec.index + exec[0].length);
|
|
115
109
|
return notLetter.test(charBefore) && notLetter.test(charAfter);
|
|
116
110
|
}
|
|
117
111
|
else {
|
|
118
112
|
return matchWord(exec);
|
|
119
113
|
}
|
|
120
114
|
};
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
const createRegExp = (inputString, flags) => {
|
|
116
|
+
const escaped = inputString
|
|
123
117
|
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
124
118
|
.replace(/-/g, '\\x2d')
|
|
125
119
|
.replace(/\s/g, '\\s');
|
|
126
120
|
return new RegExp(escaped, flags);
|
|
127
121
|
};
|
|
122
|
+
|
|
123
|
+
exports.find = find;
|
|
124
|
+
exports.findAll = findAll;
|
|
125
|
+
exports.findAt = findAt;
|
|
126
|
+
exports.replace = replace;
|
|
127
|
+
exports.replaceAll = replaceAll;
|
package/dist/npm/image.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { Command } from './types/command';
|
|
2
|
-
|
|
1
|
+
import { Command } from './types/command.js';
|
|
2
|
+
|
|
3
|
+
interface ImageData {
|
|
3
4
|
src: string;
|
|
4
5
|
alt?: string;
|
|
5
6
|
width?: string;
|
|
6
7
|
height?: string;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
declare const insertImage: (attrs: ImageData) => Command;
|
|
10
|
+
|
|
11
|
+
export { type ImageData, insertImage };
|
package/dist/npm/image.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var utils = require('./utils.js');
|
|
4
|
+
|
|
5
|
+
const insertImage = (attrs) => (state, dispatch) => {
|
|
6
|
+
const { image } = state.schema.nodes;
|
|
7
|
+
const commandName = 'insertImage';
|
|
8
|
+
const newImage = image.createAndFill(attrs);
|
|
9
|
+
utils.insertNode(newImage)(state, tr => dispatch(tr.setMeta('commandName', commandName).setMeta('args', attrs)));
|
|
10
|
+
};
|
|
11
|
+
|
|
11
12
|
exports.insertImage = insertImage;
|
package/dist/npm/indent.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { EditorState } from 'prosemirror-state';
|
|
2
2
|
import { NodeType } from 'prosemirror-model';
|
|
3
|
-
import { IndentRule, IndentationRules } from './config/indent-rules';
|
|
4
|
-
import { Command } from './types/command';
|
|
3
|
+
import { IndentRule, IndentationRules } from './config/indent-rules.js';
|
|
4
|
+
import { Command } from './types/command.js';
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
* Indenting block elements in the selection.
|
|
7
8
|
*
|
|
8
9
|
* @returns {boolean} - Returns true if any indentation is applied.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
declare const indentBlocks: (actions: Array<IndentRule>, command?: string, dir?: string) => Command;
|
|
12
|
+
declare const isIndented: (state: EditorState, rules: Array<IndentRule>, dir?: string) => boolean;
|
|
13
|
+
declare const canIndentAsListItem: (state: EditorState, nodeType: NodeType) => boolean;
|
|
14
|
+
declare const canOutdentAsListItem: (state: EditorState, rules: IndentationRules) => boolean;
|
|
15
|
+
declare const canBeIndented: (state: EditorState, rules: IndentationRules) => boolean;
|
|
16
|
+
declare const indent: Command;
|
|
17
|
+
declare const outdent: Command;
|
|
18
|
+
|
|
19
|
+
export { canBeIndented, canIndentAsListItem, canOutdentAsListItem, indent, indentBlocks, isIndented, outdent };
|
package/dist/npm/indent.js
CHANGED
|
@@ -1,112 +1,113 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var prosemirrorSchemaList = require('prosemirror-schema-list');
|
|
4
|
+
var indentRules = require('./config/indent-rules.js');
|
|
5
|
+
var blockNode = require('./blockNode.js');
|
|
6
|
+
var utils = require('./utils.js');
|
|
7
|
+
var blockquote = require('./blockquote.js');
|
|
8
|
+
|
|
9
9
|
/**
|
|
10
10
|
* Indenting block elements in the selection.
|
|
11
11
|
*
|
|
12
12
|
* @returns {boolean} - Returns true if any indentation is applied.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const indentBlocks = (actions, command, dir) => (state, dispatch) => {
|
|
15
|
+
const blocks = blockNode.blockNodes(state);
|
|
16
|
+
const tr = state.tr;
|
|
17
17
|
tr.setMeta('commandName', command);
|
|
18
|
-
blocks.forEach(
|
|
18
|
+
blocks.forEach(node => {
|
|
19
19
|
if (node.type.isTextblock) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
let newAttrs;
|
|
21
|
+
const action = actions.find(a => a.node === node.type.name);
|
|
22
22
|
if (action) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const style = dir === 'rtl' ? action.rtlStyle : action.style;
|
|
24
|
+
const newStyle = {
|
|
25
25
|
name: style,
|
|
26
|
-
value: action.step > 0 ?
|
|
26
|
+
value: action.step > 0 ? `${action.step}${action.unit}` : ''
|
|
27
27
|
};
|
|
28
28
|
if (node.attrs.style) {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const re = new RegExp(`${style}:\\s?(\\d+)${action.unit}`, 'i');
|
|
30
|
+
const match = node.attrs.style.match(re);
|
|
31
31
|
if (match) {
|
|
32
|
-
|
|
32
|
+
let newMargin = parseFloat(match[1]) + action.step;
|
|
33
33
|
newMargin = newMargin <= 0 ? '' : newMargin;
|
|
34
|
-
newStyle.value =
|
|
34
|
+
newStyle.value = `${newMargin}${newMargin ? action.unit : ''}`;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
newAttrs =
|
|
37
|
+
newAttrs = blockNode.addStyles(node, [newStyle]);
|
|
38
38
|
}
|
|
39
39
|
if (newAttrs) {
|
|
40
|
-
|
|
40
|
+
blockNode.changeTextBlock(tr, node, node.type, newAttrs);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
const result = tr.docChanged;
|
|
45
45
|
if (result) {
|
|
46
46
|
dispatch(tr.scrollIntoView());
|
|
47
47
|
}
|
|
48
48
|
return result;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
blocks.forEach(function (node) {
|
|
49
|
+
};
|
|
50
|
+
const isIndented = (state, rules, dir) => {
|
|
51
|
+
const blocks = blockNode.blockNodes(state);
|
|
52
|
+
let result = false;
|
|
53
|
+
blocks.forEach(node => {
|
|
55
54
|
if (!result && node.type.isTextblock && node.attrs.style) {
|
|
56
|
-
|
|
55
|
+
const action = rules.find(a => a.node === node.type.name);
|
|
57
56
|
if (action) {
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
const style = dir === 'rtl' ? action.rtlStyle : action.style;
|
|
58
|
+
const reIndent = new RegExp(`${style}:\\s?\\d+${action.unit}`, 'i');
|
|
60
59
|
result = reIndent.test(node.attrs.style);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
});
|
|
64
63
|
return result;
|
|
65
64
|
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return (0, prosemirror_schema_list_1.sinkListItem)(nodeType)(state);
|
|
65
|
+
const canIndentAsListItem = (state, nodeType) => {
|
|
66
|
+
return prosemirrorSchemaList.sinkListItem(nodeType)(state);
|
|
69
67
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return (isNestedInOL || isNestedInUL) && (0, prosemirror_schema_list_1.liftListItem)(listItem)(state);
|
|
68
|
+
const canOutdentAsListItem = (state, rules) => {
|
|
69
|
+
const listItem = state.schema.nodes[rules.listsTypes.listItem];
|
|
70
|
+
const orderedList = state.schema.nodes[rules.listsTypes.orderedList];
|
|
71
|
+
const bulletList = state.schema.nodes[rules.listsTypes.bulletList];
|
|
72
|
+
const isNestedInOL = !!utils.findNthParentNodeOfType(orderedList, 2)(state.selection);
|
|
73
|
+
const isNestedInUL = !!utils.findNthParentNodeOfType(bulletList, 2)(state.selection);
|
|
74
|
+
return (isNestedInOL || isNestedInUL) && prosemirrorSchemaList.liftListItem(listItem)(state);
|
|
78
75
|
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
!(0, blockNode_1.hasNode)(state, listItem));
|
|
76
|
+
const canBeIndented = (state, rules) => {
|
|
77
|
+
const nodes = state.schema.nodes;
|
|
78
|
+
const listItem = nodes[indentRules.indentRules.listsTypes.listItem];
|
|
79
|
+
return ((isIndented(state, rules.nodes) || indentRules.indentRules.nodes.some(rule => nodes[rule.node] && blockNode.hasNode(state, nodes[rule.node]))) &&
|
|
80
|
+
!blockNode.hasNode(state, listItem));
|
|
85
81
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
(0, prosemirror_schema_list_1.sinkListItem)(listItem)(state, dispatch);
|
|
82
|
+
const indent = (state, dispatch) => {
|
|
83
|
+
const listItem = state.schema.nodes[indentRules.indentRules.listsTypes.listItem];
|
|
84
|
+
const isIndentableBlock = canBeIndented(state, indentRules.indentRules);
|
|
85
|
+
if (canIndentAsListItem(state, listItem)) {
|
|
86
|
+
prosemirrorSchemaList.sinkListItem(listItem)(state, dispatch);
|
|
92
87
|
}
|
|
93
88
|
else if (isIndentableBlock) {
|
|
94
|
-
|
|
89
|
+
indentBlocks(indentRules.indentRules.nodes)(state, dispatch);
|
|
95
90
|
}
|
|
96
91
|
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
(0, blockquote_1.liftBlockquote)(state, dispatch);
|
|
92
|
+
const outdent = (state, dispatch) => {
|
|
93
|
+
const nodes = state.schema.nodes;
|
|
94
|
+
const listItem = nodes[indentRules.outdentRules.listsTypes.listItem];
|
|
95
|
+
const isIndentableBlock = canBeIndented(state, indentRules.outdentRules);
|
|
96
|
+
if (blockNode.hasNode(state, nodes.blockquote)) {
|
|
97
|
+
blockquote.liftBlockquote(state, dispatch);
|
|
104
98
|
}
|
|
105
|
-
else if (
|
|
106
|
-
|
|
99
|
+
else if (canOutdentAsListItem(state, indentRules.outdentRules)) {
|
|
100
|
+
prosemirrorSchemaList.liftListItem(listItem)(state, dispatch);
|
|
107
101
|
}
|
|
108
102
|
else if (isIndentableBlock) {
|
|
109
|
-
|
|
103
|
+
indentBlocks(indentRules.outdentRules.nodes)(state, dispatch);
|
|
110
104
|
}
|
|
111
105
|
};
|
|
106
|
+
|
|
107
|
+
exports.canBeIndented = canBeIndented;
|
|
108
|
+
exports.canIndentAsListItem = canIndentAsListItem;
|
|
109
|
+
exports.canOutdentAsListItem = canOutdentAsListItem;
|
|
110
|
+
exports.indent = indent;
|
|
111
|
+
exports.indentBlocks = indentBlocks;
|
|
112
|
+
exports.isIndented = isIndented;
|
|
112
113
|
exports.outdent = outdent;
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { InlineFormatOptions } from './config/commands';
|
|
2
|
+
import { InlineFormatOptions } from './config/commands.js';
|
|
3
|
+
|
|
3
4
|
/**
|
|
4
5
|
* Used by FontSize and FontName tools for getting their state.
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
+
declare const getInlineStyles: (state: EditorState, style: {
|
|
7
8
|
name: string;
|
|
8
9
|
value: RegExp;
|
|
9
10
|
}) => Array<string>;
|
|
10
11
|
/**
|
|
11
12
|
* Used by bold, italic, ... and link commands.
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare const toggleInlineFormat: (options: InlineFormatOptions, tr?: Transaction, markAttrs?: any) => (state: any, dispatch: any) => boolean;
|
|
14
15
|
/**
|
|
15
16
|
* Used by FontSize, FontName, Color and BackColor commands.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
+
declare const applyInlineStyle: (options: {
|
|
18
19
|
style: string;
|
|
19
20
|
value: string;
|
|
20
21
|
}, command?: string) => (state: any, dispatch: any) => boolean;
|
|
22
|
+
|
|
23
|
+
export { applyInlineStyle, getInlineStyles, toggleInlineFormat };
|