@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/paste.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceImageSourcesFromRtf = exports.pasteCleanup = exports.sanitizeStyleAttr = exports.sanitizeClassAttr = exports.removeAttribute = exports.removeTag = exports.removeComments = exports.sanitize = void 0;
|
|
3
4
|
var listConvert_1 = require("./listConvert");
|
|
4
5
|
/**
|
|
5
6
|
* Removes the invalid HTML. Use it as a first step for cleaning the HTML.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
var sanitize = function (html) {
|
|
8
9
|
html = html.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/, '$1');
|
|
9
10
|
html = html.replace(/<\/?[ovw]:[^>]*?>/gi, ''); // MS elements, e.g. <o:p>, <w:sdtPr>, <v:
|
|
10
11
|
html = html.replace(/<\\?\??xml[^>]*>/gi, ''); // XML namespaces
|
|
@@ -17,40 +18,45 @@ exports.sanitize = function (html) {
|
|
|
17
18
|
html = html.replace(/<!\[endif\]>/ig, '');
|
|
18
19
|
return html;
|
|
19
20
|
};
|
|
21
|
+
exports.sanitize = sanitize;
|
|
20
22
|
/**
|
|
21
23
|
* Removes comments in HTML.
|
|
22
24
|
*/
|
|
23
|
-
|
|
25
|
+
var removeComments = function (html) {
|
|
24
26
|
return html.replace(/<!--[\s\S]+?-->/g, '');
|
|
25
27
|
};
|
|
28
|
+
exports.removeComments = removeComments;
|
|
26
29
|
/**
|
|
27
30
|
* Removes the specified tag(s).
|
|
28
31
|
*/
|
|
29
|
-
|
|
32
|
+
var removeTag = function (html, tagPattern) {
|
|
30
33
|
return html.replace(new RegExp('<\\/?(' + tagPattern + ')(?:\\s[^>]*?)?>', 'gi'), '');
|
|
31
34
|
};
|
|
35
|
+
exports.removeTag = removeTag;
|
|
32
36
|
/**
|
|
33
37
|
* Removes the passed attribute.
|
|
34
38
|
*/
|
|
35
|
-
|
|
39
|
+
var removeAttribute = function (attr) {
|
|
36
40
|
if (attr.ownerElement) {
|
|
37
41
|
attr.ownerElement.removeAttribute(attr.name);
|
|
38
42
|
}
|
|
39
43
|
};
|
|
44
|
+
exports.removeAttribute = removeAttribute;
|
|
40
45
|
/**
|
|
41
46
|
* Remove the attribute if its value matches /^Mso/ regex.
|
|
42
47
|
*/
|
|
43
|
-
|
|
48
|
+
var sanitizeClassAttr = function (attr) {
|
|
44
49
|
if (/^Mso/.test(attr.value)) {
|
|
45
50
|
exports.removeAttribute(attr);
|
|
46
51
|
}
|
|
47
52
|
};
|
|
53
|
+
exports.sanitizeClassAttr = sanitizeClassAttr;
|
|
48
54
|
var stylesSplit = /\s*;\s*/;
|
|
49
55
|
var styleValueSplit = /\s*:\s*/;
|
|
50
56
|
/**
|
|
51
57
|
* Removes invalid HTML styles.
|
|
52
58
|
*/
|
|
53
|
-
|
|
59
|
+
var sanitizeStyleAttr = function (attr) {
|
|
54
60
|
var styles = attr.value.split(stylesSplit).filter(function (st) { return Boolean(st); });
|
|
55
61
|
var element = attr.ownerElement;
|
|
56
62
|
var supportedStyles = element.style;
|
|
@@ -70,6 +76,7 @@ exports.sanitizeStyleAttr = function (attr) {
|
|
|
70
76
|
exports.removeAttribute(attr);
|
|
71
77
|
}
|
|
72
78
|
};
|
|
79
|
+
exports.sanitizeStyleAttr = sanitizeStyleAttr;
|
|
73
80
|
var removeNode = function (node) {
|
|
74
81
|
var parentNode = node.parentNode;
|
|
75
82
|
if (parentNode) {
|
|
@@ -99,7 +106,7 @@ var sanitizeNode = function (node, attributes) {
|
|
|
99
106
|
* Cleans the HTML based on passed settings.
|
|
100
107
|
* Before using it, clean the HTML with the `sanitize` function.
|
|
101
108
|
*/
|
|
102
|
-
|
|
109
|
+
var pasteCleanup = function (html, settings) {
|
|
103
110
|
var result = html;
|
|
104
111
|
if (settings.convertMsLists) {
|
|
105
112
|
result = listConvert_1.convertMsLists(result);
|
|
@@ -115,6 +122,7 @@ exports.pasteCleanup = function (html, settings) {
|
|
|
115
122
|
}
|
|
116
123
|
return result;
|
|
117
124
|
};
|
|
125
|
+
exports.pasteCleanup = pasteCleanup;
|
|
118
126
|
function convertHexToBase64(hex) {
|
|
119
127
|
var length = hex.length;
|
|
120
128
|
var data = new Array(length / 2);
|
|
@@ -138,7 +146,7 @@ var textRtfType = 'text/rtf';
|
|
|
138
146
|
* @param clipboardData - The paste event clipboardData object (event.clipboardData).
|
|
139
147
|
* @returns - The html with the replaced images sources.
|
|
140
148
|
*/
|
|
141
|
-
|
|
149
|
+
var replaceImageSourcesFromRtf = function (html, clipboardData) {
|
|
142
150
|
var htmlImages = html.match(reHtmlImg);
|
|
143
151
|
if (!htmlImages || clipboardData.types.indexOf(textRtfType) === -1) {
|
|
144
152
|
return html;
|
|
@@ -165,3 +173,4 @@ exports.replaceImageSourcesFromRtf = function (html, clipboardData) {
|
|
|
165
173
|
return img.replace(reLocalFile, src);
|
|
166
174
|
});
|
|
167
175
|
};
|
|
176
|
+
exports.replaceImageSourcesFromRtf = replaceImageSourcesFromRtf;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.caretColor = exports.caretColorKey = void 0;
|
|
3
4
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
4
5
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
5
6
|
var mark_1 = require("./../mark");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.textHighlight = exports.textHighlightKey = void 0;
|
|
3
4
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
4
5
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
5
6
|
// https://discuss.prosemirror.net/t/passing-data-between-plugins/1843
|
|
@@ -1,7 +1,28 @@
|
|
|
1
|
-
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
-
export declare const imageResizeKey: PluginKey<any
|
|
1
|
+
import { Plugin, PluginKey, Transaction } from "prosemirror-state";
|
|
2
|
+
export declare const imageResizeKey: PluginKey<any>;
|
|
3
|
+
interface Rect {
|
|
4
|
+
top: number;
|
|
5
|
+
left: number;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
declare class ResizeState {
|
|
10
|
+
activeHandle: string;
|
|
11
|
+
dragging: {
|
|
12
|
+
startX: number;
|
|
13
|
+
startY: number;
|
|
14
|
+
} | null;
|
|
15
|
+
rect: Rect | null;
|
|
16
|
+
nodePosition: number;
|
|
17
|
+
constructor(activeHandle: string, dragging: {
|
|
18
|
+
startX: number;
|
|
19
|
+
startY: number;
|
|
20
|
+
} | null, rect: Rect | null, nodePosition: number);
|
|
21
|
+
apply(tr: Transaction): ResizeState;
|
|
22
|
+
}
|
|
3
23
|
export interface ImageResizeOptions {
|
|
4
24
|
node: string;
|
|
5
25
|
lockRatio: boolean;
|
|
6
26
|
}
|
|
7
|
-
export declare const imageResizing: (options?: ImageResizeOptions) => Plugin<
|
|
27
|
+
export declare const imageResizing: (options?: ImageResizeOptions) => Plugin<ResizeState>;
|
|
28
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.imageResizing = exports.imageResizeKey = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
6
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
@@ -77,10 +78,10 @@ var handleMouseUp = function (view) {
|
|
|
77
78
|
if (reSize.test(currAttrs.style || '')) {
|
|
78
79
|
var changedWidth = utils_1.changeStylesString(currAttrs.style, { style: 'width', value: reAnyValue, newValue: width + 'px' });
|
|
79
80
|
var style = utils_1.changeStylesString(changedWidth.style || '', { style: 'height', value: reAnyValue, newValue: height + 'px' }).style;
|
|
80
|
-
attrs = tslib_1.__assign({}, currAttrs, { style: style });
|
|
81
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, currAttrs), { style: style });
|
|
81
82
|
}
|
|
82
83
|
else {
|
|
83
|
-
attrs = tslib_1.__assign({}, currAttrs, { width: width, height: height });
|
|
84
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, currAttrs), { width: width, height: height });
|
|
84
85
|
}
|
|
85
86
|
var newImage = selection.node.type.createAndFill(attrs);
|
|
86
87
|
if (newImage) {
|
|
@@ -129,7 +130,7 @@ var handleMouseDown = function (view, event, options) {
|
|
|
129
130
|
event.view.addEventListener('mousemove', move);
|
|
130
131
|
return true;
|
|
131
132
|
};
|
|
132
|
-
|
|
133
|
+
var imageResizing = function (options) {
|
|
133
134
|
if (options === void 0) { options = { node: 'image', lockRatio: true }; }
|
|
134
135
|
return new prosemirror_state_1.Plugin({
|
|
135
136
|
key: exports.imageResizeKey,
|
|
@@ -225,3 +226,4 @@ exports.imageResizing = function (options) {
|
|
|
225
226
|
}
|
|
226
227
|
});
|
|
227
228
|
};
|
|
229
|
+
exports.imageResizing = imageResizing;
|
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
export declare const directions: {
|
|
2
|
-
|
|
2
|
+
southeast: {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
east: {
|
|
7
7
|
x: number;
|
|
8
8
|
y: number;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
south: {
|
|
11
11
|
x: number;
|
|
12
12
|
y: number;
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
north: {
|
|
15
15
|
x: number;
|
|
16
16
|
y: number;
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
west: {
|
|
19
19
|
x: number;
|
|
20
20
|
y: number;
|
|
21
21
|
};
|
|
22
|
-
|
|
22
|
+
southwest: {
|
|
23
23
|
x: number;
|
|
24
24
|
y: number;
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
northwest: {
|
|
27
27
|
x: number;
|
|
28
28
|
y: number;
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
northeast: {
|
|
31
31
|
x: number;
|
|
32
32
|
y: number;
|
|
33
33
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Plugin } from 'prosemirror-state';
|
|
2
|
-
export declare const spacesFix: () => Plugin<any
|
|
2
|
+
export declare const spacesFix: () => Plugin<any>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.spacesFix = void 0;
|
|
3
4
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
4
5
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
5
6
|
// The plugin resolves the following problems:
|
|
@@ -15,7 +16,7 @@ var prosemirror_view_1 = require("prosemirror-view");
|
|
|
15
16
|
var spaces = /\s+/g;
|
|
16
17
|
var align = /text-align/;
|
|
17
18
|
var aligned = function (node) { return align.test((node && node.attrs && node.attrs.style) || ''); };
|
|
18
|
-
|
|
19
|
+
var spacesFix = function () { return new prosemirror_state_1.Plugin({
|
|
19
20
|
key: new prosemirror_state_1.PluginKey('spaces-fix'),
|
|
20
21
|
props: {
|
|
21
22
|
decorations: function (state) {
|
|
@@ -43,3 +44,4 @@ exports.spacesFix = function () { return new prosemirror_state_1.Plugin({
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
}); };
|
|
47
|
+
exports.spacesFix = spacesFix;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.columnResizing = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
-
var
|
|
6
|
+
var prosemirror_tables_ts_1 = require("prosemirror-tables-ts");
|
|
6
7
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
7
8
|
var constants_1 = require("../../config/constants");
|
|
8
9
|
var table_view_1 = require("./table-view");
|
|
@@ -14,7 +15,7 @@ function columnResizing() {
|
|
|
14
15
|
key: utils_1.tableColumnResizeKey,
|
|
15
16
|
state: {
|
|
16
17
|
init: function (_, state) {
|
|
17
|
-
this.spec.props.nodeViews[
|
|
18
|
+
this.spec.props.nodeViews[prosemirror_tables_ts_1.tableNodeTypes(state.schema).table.name] = function (node, view) { return new View(node, view); };
|
|
18
19
|
return new ResizeState(-1, null);
|
|
19
20
|
},
|
|
20
21
|
apply: function (tr, prev) {
|
|
@@ -151,7 +152,7 @@ function handleMouseDown(view, event, cellMinWidth) {
|
|
|
151
152
|
tableDom.insertBefore(colgroup, tableDom.firstChild);
|
|
152
153
|
col = cols[cellIndex];
|
|
153
154
|
col.style.width = col.offsetWidth + 'px';
|
|
154
|
-
tableAttrs = tslib_1.__assign({}, tableNode.attrs, (_a = {}, _a[constants_1.colgroupAttr] = '<colgroup>' + cols.reduce(function (acc, cur) { return acc + cur.outerHTML; }, '') + '</colgroup>', _a));
|
|
155
|
+
tableAttrs = tslib_1.__assign(tslib_1.__assign({}, tableNode.attrs), (_a = {}, _a[constants_1.colgroupAttr] = '<colgroup>' + cols.reduce(function (acc, cur) { return acc + cur.outerHTML; }, '') + '</colgroup>', _a));
|
|
155
156
|
}
|
|
156
157
|
var width = parseFloat(col.style.width);
|
|
157
158
|
var tr = view.state.tr.setMeta(utils_1.tableColumnResizeKey, { setDragging: { startX: event.clientX, startWidth: width } });
|
|
@@ -202,7 +203,7 @@ function edgeCell(view, event, indexes) {
|
|
|
202
203
|
}
|
|
203
204
|
var tablePos = $pos.start(parentTable.depth);
|
|
204
205
|
var tableNode = parentTable.node;
|
|
205
|
-
var map =
|
|
206
|
+
var map = prosemirror_tables_ts_1.TableMap.get(tableNode);
|
|
206
207
|
var cell = tablePos + map.map[(map.width * indexes.rowIndex) + indexes.cellIndex];
|
|
207
208
|
return cell;
|
|
208
209
|
}
|
|
@@ -225,7 +226,7 @@ function updateColumnWidth(view, tr, cell, _width) {
|
|
|
225
226
|
var attrs = tableNode.attrs;
|
|
226
227
|
if (tableNode && attrs[constants_1.colgroupAttr]) {
|
|
227
228
|
var colgroup = tableDom.firstChild;
|
|
228
|
-
attrs = tslib_1.__assign({}, attrs, (_a = {}, _a[constants_1.colgroupAttr] = colgroup.outerHTML, _a));
|
|
229
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, attrs), (_a = {}, _a[constants_1.colgroupAttr] = colgroup.outerHTML, _a));
|
|
229
230
|
}
|
|
230
231
|
var tableDomWidth = tableDom.style.width;
|
|
231
232
|
if (tableDom && tableDomWidth && utils_1.parseStyle(attrs.style).width !== tableDomWidth) {
|
|
@@ -236,7 +237,7 @@ function updateColumnWidth(view, tr, cell, _width) {
|
|
|
236
237
|
function displayColumnWidth(view, cell, width, _cellMinWidth) {
|
|
237
238
|
var $cell = view.state.doc.resolve(cell);
|
|
238
239
|
var table = $cell.node(-1), start = $cell.start(-1);
|
|
239
|
-
var col =
|
|
240
|
+
var col = prosemirror_tables_ts_1.TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;
|
|
240
241
|
var dom = view.domAtPos($cell.start(-1)).node;
|
|
241
242
|
if (dom.nodeName !== 'TABLE') {
|
|
242
243
|
dom = dom.closest('table');
|
|
@@ -256,7 +257,7 @@ function displayColumnWidth(view, cell, width, _cellMinWidth) {
|
|
|
256
257
|
function handleDecorations(state, cell) {
|
|
257
258
|
var decorations = [];
|
|
258
259
|
var $cell = state.doc.resolve(cell);
|
|
259
|
-
var table = $cell.node(-1), map =
|
|
260
|
+
var table = $cell.node(-1), map = prosemirror_tables_ts_1.TableMap.get(table), start = $cell.start(-1);
|
|
260
261
|
var col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan;
|
|
261
262
|
for (var row = 0; row < map.height; row++) {
|
|
262
263
|
var index = col + row * map.width - 1;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const tableResizing: () => import("prosemirror-state").Plugin<any
|
|
1
|
+
export declare const tableResizing: () => import("prosemirror-state").Plugin<any>[];
|
|
2
2
|
export { tableResizeKey, tableColumnResizeKey, tableRowResizeKey } from './utils';
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableRowResizeKey = exports.tableColumnResizeKey = exports.tableResizeKey = exports.tableResizing = void 0;
|
|
3
4
|
var column_resize_1 = require("./column-resize");
|
|
4
5
|
var table_resize_1 = require("./table-resize");
|
|
5
6
|
var row_resize_1 = require("./row-resize");
|
|
6
|
-
|
|
7
|
+
var tableResizing = function () { return [
|
|
7
8
|
table_resize_1.tableResizing(),
|
|
8
9
|
column_resize_1.columnResizing(),
|
|
9
10
|
row_resize_1.rowResizing()
|
|
10
11
|
]; };
|
|
12
|
+
exports.tableResizing = tableResizing;
|
|
11
13
|
var utils_1 = require("./utils");
|
|
12
|
-
exports
|
|
13
|
-
exports
|
|
14
|
-
exports
|
|
14
|
+
Object.defineProperty(exports, "tableResizeKey", { enumerable: true, get: function () { return utils_1.tableResizeKey; } });
|
|
15
|
+
Object.defineProperty(exports, "tableColumnResizeKey", { enumerable: true, get: function () { return utils_1.tableColumnResizeKey; } });
|
|
16
|
+
Object.defineProperty(exports, "tableRowResizeKey", { enumerable: true, get: function () { return utils_1.tableRowResizeKey; } });
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rowResizing = void 0;
|
|
3
4
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
4
|
-
var
|
|
5
|
+
var prosemirror_tables_ts_1 = require("prosemirror-tables-ts");
|
|
5
6
|
var prosemirror_view_1 = require("prosemirror-view");
|
|
6
7
|
var utils_1 = require("./utils");
|
|
7
8
|
var TableRowView = /** @class */ (function () {
|
|
@@ -18,7 +19,7 @@ function rowResizing() {
|
|
|
18
19
|
key: utils_1.tableRowResizeKey,
|
|
19
20
|
state: {
|
|
20
21
|
init: function (_, state) {
|
|
21
|
-
this.spec.props.nodeViews[
|
|
22
|
+
this.spec.props.nodeViews[prosemirror_tables_ts_1.tableNodeTypes(state.schema).row.name] = function (_node, _view) { return new TableRowView(); };
|
|
22
23
|
return new ResizeState(-1, null);
|
|
23
24
|
},
|
|
24
25
|
apply: function (tr, prev) {
|
|
@@ -173,7 +174,7 @@ function edgeRow(view, event, rowIndex) {
|
|
|
173
174
|
}
|
|
174
175
|
var tablePos = $pos.start(parentTable.depth);
|
|
175
176
|
var tableNode = parentTable.node;
|
|
176
|
-
var map =
|
|
177
|
+
var map = prosemirror_tables_ts_1.TableMap.get(tableNode);
|
|
177
178
|
var row = tablePos + map.map[(map.width * rowIndex)] - 1;
|
|
178
179
|
return row;
|
|
179
180
|
}
|
|
@@ -222,7 +223,7 @@ function handleDecorations(state, pos) {
|
|
|
222
223
|
if (typeof pos !== 'number') {
|
|
223
224
|
return prosemirror_view_1.DecorationSet.empty;
|
|
224
225
|
}
|
|
225
|
-
var $row = state.doc.resolve(pos), table = $row.parent, map =
|
|
226
|
+
var $row = state.doc.resolve(pos), table = $row.parent, map = prosemirror_tables_ts_1.TableMap.get(table), rowIndex = $row.index($row.depth), start = $row.start($row.depth);
|
|
226
227
|
for (var col = 0; col < map.width; col++) {
|
|
227
228
|
var index = col + rowIndex * map.width;
|
|
228
229
|
var cellPos = map.map[index];
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { Plugin } from 'prosemirror-state';
|
|
1
|
+
import { Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
+
declare class ResizeState {
|
|
3
|
+
activeHandle: string;
|
|
4
|
+
dragging: {
|
|
5
|
+
startX: number;
|
|
6
|
+
startY: number;
|
|
7
|
+
} | null;
|
|
8
|
+
nodePosition: number;
|
|
9
|
+
constructor(activeHandle: string, dragging: {
|
|
10
|
+
startX: number;
|
|
11
|
+
startY: number;
|
|
12
|
+
} | null, nodePosition: number);
|
|
13
|
+
apply(tr: Transaction): ResizeState;
|
|
14
|
+
}
|
|
2
15
|
export declare const tableResizing: (options?: {
|
|
3
16
|
node: string;
|
|
4
|
-
}) => Plugin<
|
|
17
|
+
}) => Plugin<ResizeState>;
|
|
18
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tableResizing = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
6
|
var constants_1 = require("../../config/constants");
|
|
@@ -188,7 +189,7 @@ var handleMouseDown = function (view, event) {
|
|
|
188
189
|
curWindow.addEventListener('mousemove', move);
|
|
189
190
|
return true;
|
|
190
191
|
};
|
|
191
|
-
|
|
192
|
+
var tableResizing = function (options) {
|
|
192
193
|
if (options === void 0) { options = { node: 'table' }; }
|
|
193
194
|
return new prosemirror_state_1.Plugin({
|
|
194
195
|
key: utils_1.tableResizeKey,
|
|
@@ -224,22 +225,22 @@ exports.tableResizing = function (options) {
|
|
|
224
225
|
tr.setMeta('addToHistory', false);
|
|
225
226
|
if (selected && prevSelected && selected.pos !== prevSelected.pos) {
|
|
226
227
|
tr.setMeta(utils_1.tableResizeKey, { nodePosition: selected.pos });
|
|
227
|
-
tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign({}, prevSelected.node.attrs, (_a = {}, _a[constants_1.resizableAttr] = false, _a)));
|
|
228
|
-
tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_b = {}, _b[constants_1.resizableAttr] = true, _b)));
|
|
228
|
+
tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign(tslib_1.__assign({}, prevSelected.node.attrs), (_a = {}, _a[constants_1.resizableAttr] = false, _a)));
|
|
229
|
+
tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign(tslib_1.__assign({}, selected.node.attrs), (_b = {}, _b[constants_1.resizableAttr] = true, _b)));
|
|
229
230
|
view.dispatch(tr);
|
|
230
231
|
}
|
|
231
232
|
else if (selected && prevSelected && selected.pos === prevSelected.pos &&
|
|
232
233
|
!selected.node.attrs[constants_1.resizableAttr] && !state.selection.eq(prevState.selection)) {
|
|
233
234
|
tr.setMeta(utils_1.tableResizeKey, { nodePosition: selected.pos });
|
|
234
|
-
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_c = {}, _c[constants_1.resizableAttr] = true, _c))));
|
|
235
|
+
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign(tslib_1.__assign({}, selected.node.attrs), (_c = {}, _c[constants_1.resizableAttr] = true, _c))));
|
|
235
236
|
}
|
|
236
237
|
else if (selected && !prevSelected) {
|
|
237
238
|
tr.setMeta(utils_1.tableResizeKey, { nodePosition: selected.pos });
|
|
238
|
-
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign({}, selected.node.attrs, (_d = {}, _d[constants_1.resizableAttr] = true, _d))));
|
|
239
|
+
view.dispatch(tr.setNodeMarkup(selected.pos, nodeType, tslib_1.__assign(tslib_1.__assign({}, selected.node.attrs), (_d = {}, _d[constants_1.resizableAttr] = true, _d))));
|
|
239
240
|
}
|
|
240
241
|
else if (!selected && prevSelected) {
|
|
241
242
|
tr.setMeta(utils_1.tableResizeKey, { nodePosition: -1 });
|
|
242
|
-
view.dispatch(tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign({}, prevSelected.node.attrs, (_f = {}, _f[constants_1.resizableAttr] = false, _f))));
|
|
243
|
+
view.dispatch(tr.setNodeMarkup(prevSelected.pos, nodeType, tslib_1.__assign(tslib_1.__assign({}, prevSelected.node.attrs), (_f = {}, _f[constants_1.resizableAttr] = false, _f))));
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
246
|
}
|
|
@@ -261,3 +262,4 @@ exports.tableResizing = function (options) {
|
|
|
261
262
|
}
|
|
262
263
|
});
|
|
263
264
|
};
|
|
265
|
+
exports.tableResizing = tableResizing;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Node, ResolvedPos } from 'prosemirror-model';
|
|
2
2
|
import { EditorState, PluginKey } from 'prosemirror-state';
|
|
3
3
|
export declare const reAnyValue: RegExp;
|
|
4
|
-
export declare const parseStyle: (styleText: string) => {
|
|
4
|
+
export declare const parseStyle: (styleText: string | null) => {
|
|
5
5
|
[x: string]: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function setNodeStyle(nodeAttrs: any, styleType: string, value: string): any;
|
|
8
|
-
export declare const tableResizeKey: PluginKey<any
|
|
9
|
-
export declare const tableColumnResizeKey: PluginKey<any
|
|
10
|
-
export declare const tableRowResizeKey: PluginKey<any
|
|
8
|
+
export declare const tableResizeKey: PluginKey<any>;
|
|
9
|
+
export declare const tableColumnResizeKey: PluginKey<any>;
|
|
10
|
+
export declare const tableRowResizeKey: PluginKey<any>;
|
|
11
11
|
export declare function otherResizing(current: PluginKey, state: EditorState): boolean;
|
|
12
12
|
export declare function otherResizeHandle(current: PluginKey, state: EditorState): boolean;
|
|
13
13
|
export declare function getTable(dom: HTMLElement): HTMLTableElement;
|
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parentNode = exports.cellIndexes = exports.domCellAround = exports.getTable = exports.otherResizeHandle = exports.otherResizing = exports.tableRowResizeKey = exports.tableColumnResizeKey = exports.tableResizeKey = exports.setNodeStyle = exports.parseStyle = exports.reAnyValue = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var prosemirror_state_1 = require("prosemirror-state");
|
|
5
6
|
var utils_1 = require("../../utils");
|
|
6
7
|
exports.reAnyValue = /^.+$/;
|
|
7
|
-
|
|
8
|
+
var parseStyle = function (styleText) {
|
|
8
9
|
var styles = (styleText || '').split(/\s*;\s*/).filter(Boolean).map(function (s) {
|
|
9
10
|
var _a;
|
|
10
11
|
var nameValue = s.split(/\s*:\s*/);
|
|
11
12
|
return _a = {}, _a[nameValue[0]] = nameValue[1], _a;
|
|
12
|
-
}).reduce(function (acc, val) { return (tslib_1.__assign({}, acc, val)); }, {});
|
|
13
|
+
}).reduce(function (acc, val) { return (tslib_1.__assign(tslib_1.__assign({}, acc), val)); }, {});
|
|
13
14
|
return styles;
|
|
14
15
|
};
|
|
16
|
+
exports.parseStyle = parseStyle;
|
|
15
17
|
function setNodeStyle(nodeAttrs, styleType, value) {
|
|
16
18
|
var attrs;
|
|
17
19
|
if (new RegExp('[^-]?' + styleType + ':').test(nodeAttrs.style || '')) {
|
|
18
20
|
var style = utils_1.changeStylesString(nodeAttrs.style || '', { style: styleType, value: exports.reAnyValue, newValue: value }).style;
|
|
19
|
-
attrs = tslib_1.__assign({}, nodeAttrs, { style: style });
|
|
21
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, nodeAttrs), { style: style });
|
|
20
22
|
}
|
|
21
23
|
else if (nodeAttrs.style) {
|
|
22
|
-
attrs = tslib_1.__assign({}, nodeAttrs, { style: nodeAttrs.style.replace(/;$/, '') + '; ' + styleType + ': ' + value + ';' });
|
|
24
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, nodeAttrs), { style: nodeAttrs.style.replace(/;$/, '') + '; ' + styleType + ': ' + value + ';' });
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
|
-
attrs = tslib_1.__assign({}, nodeAttrs, { style: styleType + ': ' + value + ';' });
|
|
27
|
+
attrs = tslib_1.__assign(tslib_1.__assign({}, nodeAttrs), { style: styleType + ': ' + value + ';' });
|
|
26
28
|
}
|
|
27
29
|
return attrs;
|
|
28
30
|
}
|
package/dist/npm/source.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const htmlToFragment: (html: string) => DocumentFragment;
|
|
|
26
26
|
* @param doc ProseMirrorNode
|
|
27
27
|
* @returns DocumentFragment
|
|
28
28
|
*/
|
|
29
|
-
export declare const pmDocToFragment: (doc: ProseMirrorNode
|
|
29
|
+
export declare const pmDocToFragment: (doc: ProseMirrorNode) => DocumentFragment;
|
|
30
30
|
/**
|
|
31
31
|
* Creates a ProseMirrorNode from the given DOM element.
|
|
32
32
|
*
|
|
@@ -35,7 +35,7 @@ export declare const pmDocToFragment: (doc: ProseMirrorNode<any>) => DocumentFra
|
|
|
35
35
|
* @param parseOptions
|
|
36
36
|
* @returns ProseMirrorNode
|
|
37
37
|
*/
|
|
38
|
-
export declare const domToPmDoc: (dom: Node, schema: Schema
|
|
38
|
+
export declare const domToPmDoc: (dom: Node, schema: Schema, parseOptions: ParseOptions) => ProseMirrorNode;
|
|
39
39
|
/**
|
|
40
40
|
* Creates a ProseMirrorNode from the given HTML content.
|
|
41
41
|
*
|
|
@@ -44,15 +44,15 @@ export declare const domToPmDoc: (dom: Node, schema: Schema<any, any>, parseOpti
|
|
|
44
44
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
45
45
|
* @returns - New ProseMirrorNode instance.
|
|
46
46
|
*/
|
|
47
|
-
export declare const parseContent: (content: string, schema: Schema
|
|
47
|
+
export declare const parseContent: (content: string, schema: Schema, parseOptions?: ParseOptions) => ProseMirrorNode;
|
|
48
48
|
/**
|
|
49
49
|
* A function that serializes the Editor State content as HTML string.
|
|
50
50
|
*
|
|
51
51
|
* @param state - The Editor State
|
|
52
52
|
* @returns - The serialized content
|
|
53
53
|
*/
|
|
54
|
-
export declare const getHtml: (state: EditorState
|
|
55
|
-
doc: ProseMirrorNode
|
|
54
|
+
export declare const getHtml: (state: EditorState | {
|
|
55
|
+
doc: ProseMirrorNode;
|
|
56
56
|
}) => string;
|
|
57
57
|
/**
|
|
58
58
|
* Replaces the content of the editor with a new one.
|
|
@@ -62,4 +62,4 @@ export declare const getHtml: (state: EditorState<any> | {
|
|
|
62
62
|
* @param parseOptions - ProseMirror parse options recognized by the `parse` and `parseSlice` methods.
|
|
63
63
|
* @returns - Command function that takes an editor `state` and `dispatch` function.
|
|
64
64
|
*/
|
|
65
|
-
export declare const setHtml: (content: string, command?: string, parseOptions?: ParseOptions
|
|
65
|
+
export declare const setHtml: (content: string, command?: string, parseOptions?: ParseOptions) => Command;
|