@progress/kendo-editor-common 1.9.1-dev.202205300804 → 1.9.1-dev.202206231329
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/js/kendo-editor-common.js +1 -16
- package/dist/cdn/main.js +1 -1
- package/dist/es/blockNode.js +5 -5
- package/dist/es/config/indent-rules.js +3 -3
- package/dist/es/config/keymap.js +4 -4
- package/dist/es/config/list-settings.js +3 -3
- package/dist/es/config/schema.js +27 -27
- package/dist/es/find-replace.js +2 -2
- package/dist/es/inline-style.js +5 -5
- package/dist/es/lists.js +3 -3
- package/dist/es/main.js +1 -1
- package/dist/es/mark.js +2 -2
- package/dist/es/plugins/image-resize.js +3 -3
- package/dist/es/plugins/table-resize/column-resize.js +4 -4
- package/dist/es/plugins/table-resize/row-resize.js +1 -1
- package/dist/es/plugins/table-resize/table-resize.js +9 -9
- package/dist/es/plugins/table-resize/utils.js +5 -5
- package/dist/es/table.js +1 -1
- package/dist/es/types/active-marks.js +1 -0
- package/dist/es/types/command.js +1 -0
- package/dist/es/types/dispatchFn.js +1 -0
- package/dist/es/types/paste-cleanup-settings.js +1 -0
- package/dist/es/types/predicate.js +1 -0
- package/dist/es2015/blockNode.js +5 -5
- package/dist/es2015/config/keymap.js +3 -3
- package/dist/es2015/config/schema.js +17 -17
- package/dist/es2015/find-replace.js +2 -2
- package/dist/es2015/inline-style.js +3 -3
- package/dist/es2015/main.js +1 -1
- package/dist/es2015/plugins/image-resize.js +2 -2
- package/dist/es2015/plugins/table-resize/column-resize.js +3 -3
- package/dist/es2015/plugins/table-resize/row-resize.js +1 -1
- package/dist/es2015/plugins/table-resize/table-resize.js +5 -5
- package/dist/es2015/plugins/table-resize/utils.js +4 -4
- package/dist/es2015/table.js +1 -1
- package/dist/es2015/types/active-marks.js +1 -0
- package/dist/es2015/types/command.js +1 -0
- package/dist/es2015/types/dispatchFn.js +1 -0
- package/dist/es2015/types/paste-cleanup-settings.js +1 -0
- package/dist/es2015/types/predicate.js +1 -0
- package/dist/npm/align.d.ts +2 -2
- package/dist/npm/align.js +5 -2
- package/dist/npm/blockNode.d.ts +13 -13
- package/dist/npm/blockNode.js +20 -10
- package/dist/npm/blockquote.d.ts +2 -2
- package/dist/npm/blockquote.js +5 -2
- package/dist/npm/cleanFormatting.d.ts +1 -1
- package/dist/npm/cleanFormatting.js +3 -1
- package/dist/npm/config/align-rules.js +1 -0
- package/dist/npm/config/commands.js +1 -0
- package/dist/npm/config/constants.js +1 -0
- package/dist/npm/config/indent-rules.js +1 -0
- package/dist/npm/config/keymap.d.ts +2 -2
- package/dist/npm/config/keymap.js +8 -5
- package/dist/npm/config/list-settings.js +1 -0
- package/dist/npm/config/schema.js +21 -19
- package/dist/npm/find-replace.d.ts +9 -9
- package/dist/npm/find-replace.js +11 -5
- package/dist/npm/image.js +3 -1
- package/dist/npm/indent.d.ts +5 -5
- package/dist/npm/indent.js +15 -7
- package/dist/npm/inline-style.d.ts +3 -3
- package/dist/npm/inline-style.js +11 -7
- package/dist/npm/link.js +5 -2
- package/dist/npm/listConvert.js +3 -1
- package/dist/npm/lists.d.ts +4 -6
- package/dist/npm/lists.js +7 -3
- package/dist/npm/main.d.ts +1 -1
- package/dist/npm/main.js +146 -143
- package/dist/npm/mark.d.ts +10 -10
- package/dist/npm/mark.js +25 -13
- package/dist/npm/paste.js +17 -8
- package/dist/npm/plugins/caret-color.d.ts +1 -1
- package/dist/npm/plugins/caret-color.js +1 -0
- package/dist/npm/plugins/highlight.d.ts +1 -1
- package/dist/npm/plugins/highlight.js +1 -0
- package/dist/npm/plugins/image-resize.d.ts +24 -3
- package/dist/npm/plugins/image-resize.js +5 -3
- package/dist/npm/plugins/placeholder.js +1 -0
- package/dist/npm/plugins/resize-utils.d.ts +8 -8
- package/dist/npm/plugins/resize-utils.js +1 -0
- package/dist/npm/plugins/spaces-fix.d.ts +1 -1
- package/dist/npm/plugins/spaces-fix.js +3 -1
- package/dist/npm/plugins/table-resize/column-resize.js +8 -7
- package/dist/npm/plugins/table-resize/index.d.ts +1 -1
- package/dist/npm/plugins/table-resize/index.js +6 -4
- package/dist/npm/plugins/table-resize/row-resize.js +5 -4
- package/dist/npm/plugins/table-resize/table-resize.d.ts +16 -2
- package/dist/npm/plugins/table-resize/table-resize.js +8 -6
- package/dist/npm/plugins/table-resize/table-view.js +1 -0
- package/dist/npm/plugins/table-resize/utils.d.ts +4 -4
- package/dist/npm/plugins/table-resize/utils.js +7 -5
- package/dist/npm/source.d.ts +6 -6
- package/dist/npm/source.js +15 -7
- package/dist/npm/table.d.ts +7 -7
- package/dist/npm/table.js +12 -8
- package/dist/npm/text.js +3 -1
- package/dist/npm/utils.d.ts +8 -8
- package/dist/npm/utils.js +25 -12
- package/dist/systemjs/kendo-editor-common.js +1 -1
- package/package.json +15 -26
package/dist/npm/source.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setHtml = exports.getHtml = exports.parseContent = exports.domToPmDoc = exports.pmDocToFragment = exports.htmlToFragment = exports.trimWhitespace = void 0;
|
|
3
4
|
var prosemirror_model_1 = require("prosemirror-model");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
6
|
var constants_1 = require("./config/constants");
|
|
@@ -67,19 +68,20 @@ var validateTablesToPmSchema = function (fragment) {
|
|
|
67
68
|
*
|
|
68
69
|
* @returns The trimmed HTML content
|
|
69
70
|
*/
|
|
70
|
-
|
|
71
|
+
var trimWhitespace = function (html, trimAroundTags) {
|
|
71
72
|
if (trimAroundTags === void 0) { trimAroundTags = blockWrappers; }
|
|
72
73
|
var tags = trimAroundTags.join('|');
|
|
73
74
|
return html.replace(new RegExp('\\s*(<(?:' + tags + ')(?:\\s[^>]*?)?>)', 'g'), '$1')
|
|
74
75
|
.replace(new RegExp('(<\\/(?:' + tags + ')(?:\\s[^>]*?)?>)\\s*', 'g'), '$1');
|
|
75
76
|
};
|
|
77
|
+
exports.trimWhitespace = trimWhitespace;
|
|
76
78
|
/**
|
|
77
79
|
* Creates a DocumentFragment from the given HTML content.
|
|
78
80
|
*
|
|
79
81
|
* @param html
|
|
80
82
|
* @returns DocumentFragment
|
|
81
83
|
*/
|
|
82
|
-
|
|
84
|
+
var htmlToFragment = function (html) {
|
|
83
85
|
var template = document.createElement('template');
|
|
84
86
|
var fragment;
|
|
85
87
|
if ('content' in template) {
|
|
@@ -97,16 +99,18 @@ exports.htmlToFragment = function (html) {
|
|
|
97
99
|
}
|
|
98
100
|
return fragment;
|
|
99
101
|
};
|
|
102
|
+
exports.htmlToFragment = htmlToFragment;
|
|
100
103
|
/**
|
|
101
104
|
* Creates a DocumentFragment from the given ProseMirrorNode.
|
|
102
105
|
* @param doc ProseMirrorNode
|
|
103
106
|
* @returns DocumentFragment
|
|
104
107
|
*/
|
|
105
|
-
|
|
108
|
+
var pmDocToFragment = function (doc) {
|
|
106
109
|
var fragment = prosemirror_model_1.DOMSerializer.fromSchema(doc.type.schema).serializeFragment(doc.content);
|
|
107
110
|
restoreTables(fragment);
|
|
108
111
|
return fragment;
|
|
109
112
|
};
|
|
113
|
+
exports.pmDocToFragment = pmDocToFragment;
|
|
110
114
|
/**
|
|
111
115
|
* Creates a ProseMirrorNode from the given DOM element.
|
|
112
116
|
*
|
|
@@ -115,9 +119,10 @@ exports.pmDocToFragment = function (doc) {
|
|
|
115
119
|
* @param parseOptions
|
|
116
120
|
* @returns ProseMirrorNode
|
|
117
121
|
*/
|
|
118
|
-
|
|
122
|
+
var domToPmDoc = function (dom, schema, parseOptions) {
|
|
119
123
|
return prosemirror_model_1.DOMParser.fromSchema(schema).parse(dom, parseOptions);
|
|
120
124
|
};
|
|
125
|
+
exports.domToPmDoc = domToPmDoc;
|
|
121
126
|
/**
|
|
122
127
|
* Creates a ProseMirrorNode from the given HTML content.
|
|
123
128
|
*
|
|
@@ -126,23 +131,25 @@ exports.domToPmDoc = function (dom, schema, parseOptions) {
|
|
|
126
131
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
127
132
|
* @returns - New ProseMirrorNode instance.
|
|
128
133
|
*/
|
|
129
|
-
|
|
134
|
+
var parseContent = function (content, schema, parseOptions) {
|
|
130
135
|
var dom = exports.htmlToFragment(content);
|
|
131
136
|
validateTablesToPmSchema(dom);
|
|
132
137
|
return exports.domToPmDoc(dom, schema, parseOptions);
|
|
133
138
|
};
|
|
139
|
+
exports.parseContent = parseContent;
|
|
134
140
|
/**
|
|
135
141
|
* A function that serializes the Editor State content as HTML string.
|
|
136
142
|
*
|
|
137
143
|
* @param state - The Editor State
|
|
138
144
|
* @returns - The serialized content
|
|
139
145
|
*/
|
|
140
|
-
|
|
146
|
+
var getHtml = function (state) {
|
|
141
147
|
var fragment = exports.pmDocToFragment(state.doc);
|
|
142
148
|
var container = document.createElement('div');
|
|
143
149
|
container.appendChild(fragment);
|
|
144
150
|
return container.innerHTML;
|
|
145
151
|
};
|
|
152
|
+
exports.getHtml = getHtml;
|
|
146
153
|
/**
|
|
147
154
|
* Replaces the content of the editor with a new one.
|
|
148
155
|
*
|
|
@@ -151,7 +158,7 @@ exports.getHtml = function (state) {
|
|
|
151
158
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
152
159
|
* @returns - Command function that takes an editor `state` and `dispatch` function.
|
|
153
160
|
*/
|
|
154
|
-
|
|
161
|
+
var setHtml = function (content, command, parseOptions) {
|
|
155
162
|
if (command === void 0) { command = 'setHTML'; }
|
|
156
163
|
if (parseOptions === void 0) { parseOptions = { preserveWhitespace: 'full' }; }
|
|
157
164
|
return function (state, dispatch) {
|
|
@@ -161,3 +168,4 @@ exports.setHtml = function (content, command, parseOptions) {
|
|
|
161
168
|
.setMeta('commandName', command));
|
|
162
169
|
};
|
|
163
170
|
};
|
|
171
|
+
exports.setHtml = setHtml;
|
package/dist/npm/table.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Node, NodeType } from 'prosemirror-model';
|
|
2
2
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
-
import { addRowAfter as pmAddRowAfter, addRowBefore as pmAddRowBefore } from 'prosemirror-tables';
|
|
3
|
+
import { addRowAfter as pmAddRowAfter, addRowBefore as pmAddRowBefore } from 'prosemirror-tables-ts';
|
|
4
4
|
/**
|
|
5
5
|
* Creates a table.
|
|
6
6
|
* @returns Node
|
|
7
7
|
*/
|
|
8
8
|
export declare const createTable: (nodes: {
|
|
9
|
-
table: NodeType
|
|
10
|
-
table_row: NodeType
|
|
11
|
-
table_cell: NodeType
|
|
12
|
-
}, rows: number, columns: number) => Node
|
|
13
|
-
export declare const addRowBefore: (state: EditorState
|
|
14
|
-
export declare const addRowAfter: (state: EditorState
|
|
9
|
+
table: NodeType;
|
|
10
|
+
table_row: NodeType;
|
|
11
|
+
table_cell: NodeType;
|
|
12
|
+
}, rows: number, columns: number) => Node;
|
|
13
|
+
export declare const addRowBefore: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
14
|
+
export declare const addRowAfter: (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
15
15
|
export { pmAddRowBefore, pmAddRowAfter };
|
package/dist/npm/table.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports
|
|
3
|
+
exports.pmAddRowAfter = exports.pmAddRowBefore = exports.addRowAfter = exports.addRowBefore = exports.createTable = void 0;
|
|
4
|
+
var prosemirror_tables_ts_1 = require("prosemirror-tables-ts");
|
|
5
|
+
Object.defineProperty(exports, "pmAddRowAfter", { enumerable: true, get: function () { return prosemirror_tables_ts_1.addRowAfter; } });
|
|
6
|
+
Object.defineProperty(exports, "pmAddRowBefore", { enumerable: true, get: function () { return prosemirror_tables_ts_1.addRowBefore; } });
|
|
6
7
|
var constants_1 = require("./config/constants");
|
|
7
8
|
/**
|
|
8
9
|
* Creates a table.
|
|
9
10
|
* @returns Node
|
|
10
11
|
*/
|
|
11
|
-
|
|
12
|
+
var createTable = function (nodes, rows, columns) {
|
|
12
13
|
var table = nodes.table, table_row = nodes.table_row, table_cell = nodes.table_cell;
|
|
13
14
|
var tableRows = [];
|
|
14
15
|
var cells;
|
|
@@ -21,6 +22,7 @@ exports.createTable = function (nodes, rows, columns) {
|
|
|
21
22
|
}
|
|
22
23
|
return table.createAndFill(undefined, tableRows);
|
|
23
24
|
};
|
|
25
|
+
exports.createTable = createTable;
|
|
24
26
|
var closest = function (selection, name) {
|
|
25
27
|
var pos = selection.$head;
|
|
26
28
|
for (var i = pos.depth; i > 0; i--) {
|
|
@@ -34,7 +36,7 @@ var closest = function (selection, name) {
|
|
|
34
36
|
}
|
|
35
37
|
return null;
|
|
36
38
|
};
|
|
37
|
-
|
|
39
|
+
var addRowBefore = function (state, dispatch) {
|
|
38
40
|
var cmdDispatch = dispatch && (function (tr) {
|
|
39
41
|
var _a;
|
|
40
42
|
var row = closest(tr.selection, 'table_row');
|
|
@@ -53,9 +55,10 @@ exports.addRowBefore = function (state, dispatch) {
|
|
|
53
55
|
}
|
|
54
56
|
return dispatch(tr);
|
|
55
57
|
});
|
|
56
|
-
return
|
|
58
|
+
return prosemirror_tables_ts_1.addRowBefore(state, cmdDispatch);
|
|
57
59
|
};
|
|
58
|
-
exports.
|
|
60
|
+
exports.addRowBefore = addRowBefore;
|
|
61
|
+
var addRowAfter = function (state, dispatch) {
|
|
59
62
|
var cmdDispatch = dispatch && (function (tr) {
|
|
60
63
|
var _a;
|
|
61
64
|
var row = closest(tr.selection, 'table_row');
|
|
@@ -65,5 +68,6 @@ exports.addRowAfter = function (state, dispatch) {
|
|
|
65
68
|
}
|
|
66
69
|
return dispatch(tr);
|
|
67
70
|
});
|
|
68
|
-
return
|
|
71
|
+
return prosemirror_tables_ts_1.addRowAfter(state, cmdDispatch);
|
|
69
72
|
};
|
|
73
|
+
exports.addRowAfter = addRowAfter;
|
package/dist/npm/text.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.insertText =
|
|
3
|
+
exports.insertText = void 0;
|
|
4
|
+
var insertText = function (attrs) { return function (state, dispatch) {
|
|
4
5
|
dispatch(state.tr.insertText(attrs.text, attrs.from, attrs.to));
|
|
5
6
|
}; };
|
|
7
|
+
exports.insertText = insertText;
|
package/dist/npm/utils.d.ts
CHANGED
|
@@ -7,20 +7,20 @@ export declare const changeStylesString: (styleText: string, newStyle: {
|
|
|
7
7
|
newValue?: string;
|
|
8
8
|
}) => {
|
|
9
9
|
changed: boolean;
|
|
10
|
-
style: string;
|
|
10
|
+
style: string | null;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Determines if a given node type can be inserted at the current cursor position.
|
|
14
14
|
*/
|
|
15
|
-
export declare const canInsert: (state: EditorState
|
|
16
|
-
export declare const findNthParentNodeOfType: (nodeType: NodeType
|
|
15
|
+
export declare const canInsert: (state: EditorState, nodeType: NodeType) => boolean;
|
|
16
|
+
export declare const findNthParentNodeOfType: (nodeType: NodeType, depth?: number) => Function;
|
|
17
17
|
/**
|
|
18
18
|
* Inserts the given node at the place of current selection.
|
|
19
19
|
*/
|
|
20
|
-
export declare const insertNode: (node: Node
|
|
21
|
-
export declare const hasSameMarkup: (dom1: string, dom2: string, schema: Schema
|
|
22
|
-
export declare const getSelectionText: (state: EditorState
|
|
23
|
-
export declare const getNodeFromSelection: (state: EditorState
|
|
20
|
+
export declare const insertNode: (node: Node, scrollIntoView?: boolean) => Command;
|
|
21
|
+
export declare const hasSameMarkup: (dom1: string, dom2: string, schema: Schema, parseOptions?: ParseOptions) => boolean;
|
|
22
|
+
export declare const getSelectionText: (state: EditorState) => string;
|
|
23
|
+
export declare const getNodeFromSelection: (state: EditorState) => Node;
|
|
24
24
|
/**
|
|
25
25
|
* Returns the text from the selection if only text is selected on a single line.
|
|
26
26
|
* If selection contains leaf nodes (br, image) between text elements or
|
|
@@ -29,7 +29,7 @@ export declare const getNodeFromSelection: (state: EditorState<any>) => Node<any
|
|
|
29
29
|
* Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
|
|
30
30
|
* should be single line text only.
|
|
31
31
|
*/
|
|
32
|
-
export declare const selectedLineTextOnly: (state: EditorState
|
|
32
|
+
export declare const selectedLineTextOnly: (state: EditorState) => string;
|
|
33
33
|
/**
|
|
34
34
|
* Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
|
|
35
35
|
*/
|
package/dist/npm/utils.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.expandToWordWrap = exports.expandSelection = exports.shallowEqual = exports.indentHtml = exports.selectedLineTextOnly = exports.getNodeFromSelection = exports.getSelectionText = exports.hasSameMarkup = exports.insertNode = exports.findNthParentNodeOfType = exports.canInsert = exports.changeStylesString = void 0;
|
|
3
4
|
var prosemirror_model_1 = require("prosemirror-model");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
6
|
var source_1 = require("./source");
|
|
6
|
-
|
|
7
|
+
var changeStylesString = function (styleText, newStyle) {
|
|
7
8
|
var styleToChange = newStyle.style;
|
|
8
9
|
var regExp = newStyle.value;
|
|
9
10
|
var newValue = newStyle.newValue;
|
|
@@ -23,10 +24,11 @@ exports.changeStylesString = function (styleText, newStyle) {
|
|
|
23
24
|
changed: Boolean(newValue) || filtered.length !== styles.length
|
|
24
25
|
};
|
|
25
26
|
};
|
|
27
|
+
exports.changeStylesString = changeStylesString;
|
|
26
28
|
/**
|
|
27
29
|
* Determines if a given node type can be inserted at the current cursor position.
|
|
28
30
|
*/
|
|
29
|
-
|
|
31
|
+
var canInsert = function (state, nodeType) {
|
|
30
32
|
var $from = state.selection.$from;
|
|
31
33
|
for (var d = $from.depth; d >= 0; d--) {
|
|
32
34
|
var index = $from.index(d);
|
|
@@ -36,6 +38,7 @@ exports.canInsert = function (state, nodeType) {
|
|
|
36
38
|
}
|
|
37
39
|
return false;
|
|
38
40
|
};
|
|
41
|
+
exports.canInsert = canInsert;
|
|
39
42
|
var getTypeName = function (n) {
|
|
40
43
|
return n instanceof prosemirror_model_1.Node ? n.type.name : n.name;
|
|
41
44
|
};
|
|
@@ -54,28 +57,31 @@ var findNthParentNode = function (predicate, depth) {
|
|
|
54
57
|
}
|
|
55
58
|
};
|
|
56
59
|
};
|
|
57
|
-
|
|
60
|
+
var findNthParentNodeOfType = function (nodeType, depth) {
|
|
58
61
|
if (depth === void 0) { depth = 1; }
|
|
59
62
|
return function (selection) {
|
|
60
63
|
return findNthParentNode(function (node) { return getTypeName(node) === getTypeName(nodeType); }, depth)(selection);
|
|
61
64
|
};
|
|
62
65
|
};
|
|
66
|
+
exports.findNthParentNodeOfType = findNthParentNodeOfType;
|
|
63
67
|
/**
|
|
64
68
|
* Inserts the given node at the place of current selection.
|
|
65
69
|
*/
|
|
66
|
-
|
|
70
|
+
var insertNode = function (node, scrollIntoView) { return function (state, dispatch) {
|
|
67
71
|
var tr = state.tr.replaceSelectionWith(node);
|
|
68
72
|
if (scrollIntoView) {
|
|
69
73
|
tr.scrollIntoView();
|
|
70
74
|
}
|
|
71
75
|
dispatch(tr);
|
|
72
76
|
}; };
|
|
73
|
-
exports.
|
|
77
|
+
exports.insertNode = insertNode;
|
|
78
|
+
var hasSameMarkup = function (dom1, dom2, schema, parseOptions) {
|
|
74
79
|
var fragment1 = prosemirror_model_1.Fragment.from(source_1.parseContent(dom1, schema, parseOptions));
|
|
75
80
|
var fragment2 = prosemirror_model_1.Fragment.from(source_1.parseContent(dom2, schema, parseOptions));
|
|
76
81
|
return fragment1.eq(fragment2);
|
|
77
82
|
};
|
|
78
|
-
exports.
|
|
83
|
+
exports.hasSameMarkup = hasSameMarkup;
|
|
84
|
+
var getSelectionText = function (state) {
|
|
79
85
|
var sel = state.selection;
|
|
80
86
|
if (sel instanceof prosemirror_state_1.TextSelection || sel instanceof prosemirror_state_1.AllSelection) {
|
|
81
87
|
var fragment = sel.content().content;
|
|
@@ -83,11 +89,13 @@ exports.getSelectionText = function (state) {
|
|
|
83
89
|
}
|
|
84
90
|
return '';
|
|
85
91
|
};
|
|
86
|
-
exports.
|
|
92
|
+
exports.getSelectionText = getSelectionText;
|
|
93
|
+
var getNodeFromSelection = function (state) {
|
|
87
94
|
if (state.selection instanceof prosemirror_state_1.NodeSelection) {
|
|
88
95
|
return state.selection.node;
|
|
89
96
|
}
|
|
90
97
|
};
|
|
98
|
+
exports.getNodeFromSelection = getNodeFromSelection;
|
|
91
99
|
/**
|
|
92
100
|
* Returns the text from the selection if only text is selected on a single line.
|
|
93
101
|
* If selection contains leaf nodes (br, image) between text elements or
|
|
@@ -96,7 +104,7 @@ exports.getNodeFromSelection = function (state) {
|
|
|
96
104
|
* Useful for values of the inputs of Link and Find&Replace dialogs where the inputs value has been retrieved from the selection and
|
|
97
105
|
* should be single line text only.
|
|
98
106
|
*/
|
|
99
|
-
|
|
107
|
+
var selectedLineTextOnly = function (state) {
|
|
100
108
|
var result = '', hasLeafs = false;
|
|
101
109
|
var selection = state.selection, doc = state.doc;
|
|
102
110
|
var $from = selection.$from, $to = selection.$to, from = selection.from, to = selection.to;
|
|
@@ -110,27 +118,30 @@ exports.selectedLineTextOnly = function (state) {
|
|
|
110
118
|
}
|
|
111
119
|
return result;
|
|
112
120
|
};
|
|
121
|
+
exports.selectedLineTextOnly = selectedLineTextOnly;
|
|
113
122
|
/**
|
|
114
123
|
* Used by ViewHtml/ViewSource dialogs for making the HTML more readable.
|
|
115
124
|
*/
|
|
116
|
-
|
|
125
|
+
var indentHtml = function (content) {
|
|
117
126
|
return content.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/ig, '</$1>\n')
|
|
118
127
|
.replace(/<(ul|ol)([^>]*)><li/ig, '<$1$2>\n<li')
|
|
119
128
|
.replace(/<br \/>/ig, '<br />\n')
|
|
120
129
|
.replace(/\n$/, '');
|
|
121
130
|
};
|
|
122
|
-
exports.
|
|
131
|
+
exports.indentHtml = indentHtml;
|
|
132
|
+
var shallowEqual = function (object1, object2) {
|
|
123
133
|
var keys1 = Object.keys(object1);
|
|
124
134
|
var keys2 = Object.keys(object2);
|
|
125
135
|
return keys1.length === keys2.length &&
|
|
126
136
|
keys1.every(function (k) { return object1[k] === object2[k]; });
|
|
127
137
|
};
|
|
138
|
+
exports.shallowEqual = shallowEqual;
|
|
128
139
|
var applyToWordDefault = { before: /[^ !,?.\[\]{}()]+$/i, after: /^[^ !,?.\[\]{}()]+/i };
|
|
129
140
|
/**
|
|
130
141
|
* if options.applyToWord is set, expands the selection to the word where the cursor is and
|
|
131
142
|
* returns modified state and dispatch.
|
|
132
143
|
*/
|
|
133
|
-
|
|
144
|
+
var expandSelection = function (state, dispatch, options) {
|
|
134
145
|
if (!options.applyToWord || !state.selection.empty) {
|
|
135
146
|
return { state: state, dispatch: dispatch };
|
|
136
147
|
}
|
|
@@ -197,6 +208,7 @@ exports.expandSelection = function (state, dispatch, options) {
|
|
|
197
208
|
}
|
|
198
209
|
return { state: state, dispatch: dispatch };
|
|
199
210
|
};
|
|
211
|
+
exports.expandSelection = expandSelection;
|
|
200
212
|
/**
|
|
201
213
|
* if options.applyToWord is set, expands the selection to the word where the cursor is and
|
|
202
214
|
* use the modified state for the passed command.
|
|
@@ -209,9 +221,10 @@ exports.expandSelection = function (state, dispatch, options) {
|
|
|
209
221
|
* const command = expandToWordWrap(toggleInlineFormat, {...bold, applyToWord );
|
|
210
222
|
* command(view.state, view.dispatch);
|
|
211
223
|
*/
|
|
212
|
-
|
|
224
|
+
var expandToWordWrap = function (command, options) {
|
|
213
225
|
return function (state, dispatch, _view) {
|
|
214
226
|
var _a = exports.expandSelection(state, dispatch, options), cmdState = _a.state, cmdDispatch = _a.dispatch;
|
|
215
227
|
return command(options)(cmdState, cmdDispatch);
|
|
216
228
|
};
|
|
217
229
|
};
|
|
230
|
+
exports.expandToWordWrap = expandToWordWrap;
|