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