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