@atlaskit/editor-plugin-show-diff 3.0.1 → 3.1.0
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/CHANGELOG.md +19 -0
- package/dist/cjs/pm-plugins/NodeViewSerializer.js +56 -34
- package/dist/cjs/pm-plugins/decorations.js +7 -2
- package/dist/es2019/pm-plugins/NodeViewSerializer.js +50 -30
- package/dist/es2019/pm-plugins/decorations.js +7 -2
- package/dist/esm/pm-plugins/NodeViewSerializer.js +56 -34
- package/dist/esm/pm-plugins/decorations.js +7 -2
- package/dist/types/pm-plugins/NodeViewSerializer.d.ts +6 -2
- package/dist/types-ts4.5/pm-plugins/NodeViewSerializer.d.ts +6 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-show-diff
|
|
2
2
|
|
|
3
|
+
## 3.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
|
|
8
|
+
[EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`38fb1054b8b7a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/38fb1054b8b7a) -
|
|
13
|
+
Recover from invalid deletion decorations
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 3.0.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 3.0.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -74,6 +74,21 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
74
74
|
this.nodeViews = (_ref = nodeViews !== null && nodeViews !== void 0 ? nodeViews : (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.nodeViews) !== null && _ref !== void 0 ? _ref : {};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Appends serialized child nodes to the given contentDOM element.
|
|
79
|
+
*/
|
|
80
|
+
}, {
|
|
81
|
+
key: "appendChildNodes",
|
|
82
|
+
value: function appendChildNodes(children, contentDOM) {
|
|
83
|
+
var _this = this;
|
|
84
|
+
children.forEach(function (child) {
|
|
85
|
+
var childNode = _this.tryCreateNodeView(child) || _this.serializeNode(child);
|
|
86
|
+
if (childNode) {
|
|
87
|
+
contentDOM === null || contentDOM === void 0 || contentDOM.append(childNode);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
77
92
|
/**
|
|
78
93
|
* Attempts to create a node view for the given node.
|
|
79
94
|
*
|
|
@@ -83,8 +98,7 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
83
98
|
}, {
|
|
84
99
|
key: "tryCreateNodeView",
|
|
85
100
|
value: function tryCreateNodeView(targetNode) {
|
|
86
|
-
var _this$nodeViews
|
|
87
|
-
_this = this;
|
|
101
|
+
var _this$nodeViews;
|
|
88
102
|
if (!this.editorView) {
|
|
89
103
|
return null;
|
|
90
104
|
}
|
|
@@ -92,40 +106,40 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
92
106
|
if (this.nodeViewBlocklist.has(targetNode.type.name)) {
|
|
93
107
|
return null;
|
|
94
108
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var toDOMResult = (_targetNode$type$spec = (_targetNode$type$spec2 = targetNode.type.spec).toDOM) === null || _targetNode$type$spec === void 0 ? void 0 : _targetNode$type$spec.call(_targetNode$type$spec2, targetNode);
|
|
101
|
-
if (!toDOMResult) {
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOMResult),
|
|
105
|
-
_dom = _DOMSerializer$render.dom,
|
|
106
|
-
_contentDOM = _DOMSerializer$render.contentDOM;
|
|
107
|
-
if (_dom instanceof HTMLElement) {
|
|
108
|
-
if (targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
109
|
-
return this.serializeFragment(targetNode.content);
|
|
109
|
+
try {
|
|
110
|
+
if (!constructor) {
|
|
111
|
+
var _targetNode$type$spec, _targetNode$type$spec2;
|
|
112
|
+
if (targetNode.isInline) {
|
|
113
|
+
return null;
|
|
110
114
|
}
|
|
115
|
+
var toDOMResult = (_targetNode$type$spec = (_targetNode$type$spec2 = targetNode.type.spec).toDOM) === null || _targetNode$type$spec === void 0 ? void 0 : _targetNode$type$spec.call(_targetNode$type$spec2, targetNode);
|
|
116
|
+
if (!toDOMResult) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, toDOMResult),
|
|
120
|
+
_dom = _DOMSerializer$render.dom,
|
|
121
|
+
_contentDOM = _DOMSerializer$render.contentDOM;
|
|
122
|
+
if (_dom instanceof HTMLElement) {
|
|
123
|
+
if (targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
124
|
+
return this.serializeFragment(targetNode.content);
|
|
125
|
+
}
|
|
111
126
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
127
|
+
// Iteratively populate children
|
|
128
|
+
this.appendChildNodes(targetNode.children, _contentDOM);
|
|
129
|
+
}
|
|
130
|
+
return _dom;
|
|
116
131
|
}
|
|
117
|
-
|
|
132
|
+
var _constructor = constructor(targetNode, this.editorView, function () {
|
|
133
|
+
return 0;
|
|
134
|
+
}, [], {}),
|
|
135
|
+
dom = _constructor.dom,
|
|
136
|
+
contentDOM = _constructor.contentDOM;
|
|
137
|
+
// Iteratively populate children
|
|
138
|
+
this.appendChildNodes(targetNode.children, contentDOM);
|
|
139
|
+
return dom;
|
|
140
|
+
} catch (e) {
|
|
141
|
+
return null;
|
|
118
142
|
}
|
|
119
|
-
var _constructor = constructor(targetNode, this.editorView, function () {
|
|
120
|
-
return 0;
|
|
121
|
-
}, [], {}),
|
|
122
|
-
dom = _constructor.dom,
|
|
123
|
-
contentDOM = _constructor.contentDOM;
|
|
124
|
-
// Iteratively populate children
|
|
125
|
-
targetNode.children.forEach(function (child) {
|
|
126
|
-
contentDOM === null || contentDOM === void 0 || contentDOM.append(_this.tryCreateNodeView(child) || _this.serializeNode(child));
|
|
127
|
-
});
|
|
128
|
-
return dom;
|
|
129
143
|
}
|
|
130
144
|
|
|
131
145
|
/**
|
|
@@ -137,7 +151,11 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
137
151
|
if (!this.serializer) {
|
|
138
152
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
139
153
|
}
|
|
140
|
-
|
|
154
|
+
try {
|
|
155
|
+
return this.serializer.serializeNode(node);
|
|
156
|
+
} catch (e) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
141
159
|
}
|
|
142
160
|
|
|
143
161
|
/**
|
|
@@ -149,7 +167,11 @@ var NodeViewSerializer = exports.NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
149
167
|
if (!this.serializer) {
|
|
150
168
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
151
169
|
}
|
|
152
|
-
|
|
170
|
+
try {
|
|
171
|
+
return this.serializer.serializeFragment(fragment);
|
|
172
|
+
} catch (e) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
153
175
|
}
|
|
154
176
|
|
|
155
177
|
/**
|
|
@@ -203,7 +203,9 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
203
203
|
} else {
|
|
204
204
|
// Fallback to serializing the individual child node
|
|
205
205
|
var serializedChild = serializer.serializeNode(childNode);
|
|
206
|
-
|
|
206
|
+
if (serializedChild) {
|
|
207
|
+
dom.append(serializedChild);
|
|
208
|
+
}
|
|
207
209
|
}
|
|
208
210
|
});
|
|
209
211
|
return true; // Indicates we handled multiple children
|
|
@@ -265,7 +267,10 @@ var createDeletedContentDecoration = exports.createDeletedContentDecoration = fu
|
|
|
265
267
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
|
266
268
|
return;
|
|
267
269
|
} else {
|
|
268
|
-
|
|
270
|
+
var fallbackNode = fallbackSerialization();
|
|
271
|
+
if (fallbackNode) {
|
|
272
|
+
dom.append(fallbackNode);
|
|
273
|
+
}
|
|
269
274
|
}
|
|
270
275
|
});
|
|
271
276
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
@@ -62,6 +62,18 @@ export class NodeViewSerializer {
|
|
|
62
62
|
this.nodeViews = (_ref = nodeViews !== null && nodeViews !== void 0 ? nodeViews : (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.nodeViews) !== null && _ref !== void 0 ? _ref : {};
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Appends serialized child nodes to the given contentDOM element.
|
|
67
|
+
*/
|
|
68
|
+
appendChildNodes(children, contentDOM) {
|
|
69
|
+
children.forEach(child => {
|
|
70
|
+
const childNode = this.tryCreateNodeView(child) || this.serializeNode(child);
|
|
71
|
+
if (childNode) {
|
|
72
|
+
contentDOM === null || contentDOM === void 0 ? void 0 : contentDOM.append(childNode);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
/**
|
|
66
78
|
* Attempts to create a node view for the given node.
|
|
67
79
|
*
|
|
@@ -77,40 +89,40 @@ export class NodeViewSerializer {
|
|
|
77
89
|
if (this.nodeViewBlocklist.has(targetNode.type.name)) {
|
|
78
90
|
return null;
|
|
79
91
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
try {
|
|
93
|
+
if (!constructor) {
|
|
94
|
+
var _targetNode$type$spec, _targetNode$type$spec2;
|
|
95
|
+
if (targetNode.isInline) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const toDOMResult = (_targetNode$type$spec = (_targetNode$type$spec2 = targetNode.type.spec).toDOM) === null || _targetNode$type$spec === void 0 ? void 0 : _targetNode$type$spec.call(_targetNode$type$spec2, targetNode);
|
|
99
|
+
if (!toDOMResult) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
const {
|
|
103
|
+
dom,
|
|
104
|
+
contentDOM
|
|
105
|
+
} = DOMSerializer.renderSpec(document, toDOMResult);
|
|
106
|
+
if (dom instanceof HTMLElement) {
|
|
107
|
+
if (targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
108
|
+
return this.serializeFragment(targetNode.content);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Iteratively populate children
|
|
112
|
+
this.appendChildNodes(targetNode.children, contentDOM);
|
|
113
|
+
}
|
|
114
|
+
return dom;
|
|
88
115
|
}
|
|
89
116
|
const {
|
|
90
117
|
dom,
|
|
91
118
|
contentDOM
|
|
92
|
-
} =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return this.serializeFragment(targetNode.content);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Iteratively populate children
|
|
99
|
-
targetNode.children.forEach(child => {
|
|
100
|
-
contentDOM === null || contentDOM === void 0 ? void 0 : contentDOM.append(this.tryCreateNodeView(child) || this.serializeNode(child));
|
|
101
|
-
});
|
|
102
|
-
}
|
|
119
|
+
} = constructor(targetNode, this.editorView, () => 0, [], {});
|
|
120
|
+
// Iteratively populate children
|
|
121
|
+
this.appendChildNodes(targetNode.children, contentDOM);
|
|
103
122
|
return dom;
|
|
123
|
+
} catch (e) {
|
|
124
|
+
return null;
|
|
104
125
|
}
|
|
105
|
-
const {
|
|
106
|
-
dom,
|
|
107
|
-
contentDOM
|
|
108
|
-
} = constructor(targetNode, this.editorView, () => 0, [], {});
|
|
109
|
-
// Iteratively populate children
|
|
110
|
-
targetNode.children.forEach(child => {
|
|
111
|
-
contentDOM === null || contentDOM === void 0 ? void 0 : contentDOM.append(this.tryCreateNodeView(child) || this.serializeNode(child));
|
|
112
|
-
});
|
|
113
|
-
return dom;
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
/**
|
|
@@ -120,7 +132,11 @@ export class NodeViewSerializer {
|
|
|
120
132
|
if (!this.serializer) {
|
|
121
133
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
122
134
|
}
|
|
123
|
-
|
|
135
|
+
try {
|
|
136
|
+
return this.serializer.serializeNode(node);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
124
140
|
}
|
|
125
141
|
|
|
126
142
|
/**
|
|
@@ -130,7 +146,11 @@ export class NodeViewSerializer {
|
|
|
130
146
|
if (!this.serializer) {
|
|
131
147
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
132
148
|
}
|
|
133
|
-
|
|
149
|
+
try {
|
|
150
|
+
return this.serializer.serializeFragment(fragment);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
/**
|
|
@@ -186,7 +186,9 @@ export const createDeletedContentDecoration = ({
|
|
|
186
186
|
} else {
|
|
187
187
|
// Fallback to serializing the individual child node
|
|
188
188
|
const serializedChild = serializer.serializeNode(childNode);
|
|
189
|
-
|
|
189
|
+
if (serializedChild) {
|
|
190
|
+
dom.append(serializedChild);
|
|
191
|
+
}
|
|
190
192
|
}
|
|
191
193
|
});
|
|
192
194
|
return true; // Indicates we handled multiple children
|
|
@@ -244,7 +246,10 @@ export const createDeletedContentDecoration = ({
|
|
|
244
246
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
|
245
247
|
return;
|
|
246
248
|
} else {
|
|
247
|
-
|
|
249
|
+
const fallbackNode = fallbackSerialization();
|
|
250
|
+
if (fallbackNode) {
|
|
251
|
+
dom.append(fallbackNode);
|
|
252
|
+
}
|
|
248
253
|
}
|
|
249
254
|
});
|
|
250
255
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
@@ -67,6 +67,21 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
67
67
|
this.nodeViews = (_ref = nodeViews !== null && nodeViews !== void 0 ? nodeViews : (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.nodeViews) !== null && _ref !== void 0 ? _ref : {};
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Appends serialized child nodes to the given contentDOM element.
|
|
72
|
+
*/
|
|
73
|
+
}, {
|
|
74
|
+
key: "appendChildNodes",
|
|
75
|
+
value: function appendChildNodes(children, contentDOM) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
children.forEach(function (child) {
|
|
78
|
+
var childNode = _this.tryCreateNodeView(child) || _this.serializeNode(child);
|
|
79
|
+
if (childNode) {
|
|
80
|
+
contentDOM === null || contentDOM === void 0 || contentDOM.append(childNode);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
70
85
|
/**
|
|
71
86
|
* Attempts to create a node view for the given node.
|
|
72
87
|
*
|
|
@@ -76,8 +91,7 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
76
91
|
}, {
|
|
77
92
|
key: "tryCreateNodeView",
|
|
78
93
|
value: function tryCreateNodeView(targetNode) {
|
|
79
|
-
var _this$nodeViews
|
|
80
|
-
_this = this;
|
|
94
|
+
var _this$nodeViews;
|
|
81
95
|
if (!this.editorView) {
|
|
82
96
|
return null;
|
|
83
97
|
}
|
|
@@ -85,40 +99,40 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
85
99
|
if (this.nodeViewBlocklist.has(targetNode.type.name)) {
|
|
86
100
|
return null;
|
|
87
101
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var toDOMResult = (_targetNode$type$spec = (_targetNode$type$spec2 = targetNode.type.spec).toDOM) === null || _targetNode$type$spec === void 0 ? void 0 : _targetNode$type$spec.call(_targetNode$type$spec2, targetNode);
|
|
94
|
-
if (!toDOMResult) {
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOMResult),
|
|
98
|
-
_dom = _DOMSerializer$render.dom,
|
|
99
|
-
_contentDOM = _DOMSerializer$render.contentDOM;
|
|
100
|
-
if (_dom instanceof HTMLElement) {
|
|
101
|
-
if (targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
102
|
-
return this.serializeFragment(targetNode.content);
|
|
102
|
+
try {
|
|
103
|
+
if (!constructor) {
|
|
104
|
+
var _targetNode$type$spec, _targetNode$type$spec2;
|
|
105
|
+
if (targetNode.isInline) {
|
|
106
|
+
return null;
|
|
103
107
|
}
|
|
108
|
+
var toDOMResult = (_targetNode$type$spec = (_targetNode$type$spec2 = targetNode.type.spec).toDOM) === null || _targetNode$type$spec === void 0 ? void 0 : _targetNode$type$spec.call(_targetNode$type$spec2, targetNode);
|
|
109
|
+
if (!toDOMResult) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOMResult),
|
|
113
|
+
_dom = _DOMSerializer$render.dom,
|
|
114
|
+
_contentDOM = _DOMSerializer$render.contentDOM;
|
|
115
|
+
if (_dom instanceof HTMLElement) {
|
|
116
|
+
if (targetNode.type.name === 'paragraph' && targetNode.children.length === 1) {
|
|
117
|
+
return this.serializeFragment(targetNode.content);
|
|
118
|
+
}
|
|
104
119
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
// Iteratively populate children
|
|
121
|
+
this.appendChildNodes(targetNode.children, _contentDOM);
|
|
122
|
+
}
|
|
123
|
+
return _dom;
|
|
109
124
|
}
|
|
110
|
-
|
|
125
|
+
var _constructor = constructor(targetNode, this.editorView, function () {
|
|
126
|
+
return 0;
|
|
127
|
+
}, [], {}),
|
|
128
|
+
dom = _constructor.dom,
|
|
129
|
+
contentDOM = _constructor.contentDOM;
|
|
130
|
+
// Iteratively populate children
|
|
131
|
+
this.appendChildNodes(targetNode.children, contentDOM);
|
|
132
|
+
return dom;
|
|
133
|
+
} catch (e) {
|
|
134
|
+
return null;
|
|
111
135
|
}
|
|
112
|
-
var _constructor = constructor(targetNode, this.editorView, function () {
|
|
113
|
-
return 0;
|
|
114
|
-
}, [], {}),
|
|
115
|
-
dom = _constructor.dom,
|
|
116
|
-
contentDOM = _constructor.contentDOM;
|
|
117
|
-
// Iteratively populate children
|
|
118
|
-
targetNode.children.forEach(function (child) {
|
|
119
|
-
contentDOM === null || contentDOM === void 0 || contentDOM.append(_this.tryCreateNodeView(child) || _this.serializeNode(child));
|
|
120
|
-
});
|
|
121
|
-
return dom;
|
|
122
136
|
}
|
|
123
137
|
|
|
124
138
|
/**
|
|
@@ -130,7 +144,11 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
130
144
|
if (!this.serializer) {
|
|
131
145
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
132
146
|
}
|
|
133
|
-
|
|
147
|
+
try {
|
|
148
|
+
return this.serializer.serializeNode(node);
|
|
149
|
+
} catch (e) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
134
152
|
}
|
|
135
153
|
|
|
136
154
|
/**
|
|
@@ -142,7 +160,11 @@ export var NodeViewSerializer = /*#__PURE__*/function () {
|
|
|
142
160
|
if (!this.serializer) {
|
|
143
161
|
throw new Error('NodeViewSerializer must be initialized with init() before use');
|
|
144
162
|
}
|
|
145
|
-
|
|
163
|
+
try {
|
|
164
|
+
return this.serializer.serializeFragment(fragment);
|
|
165
|
+
} catch (e) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
146
168
|
}
|
|
147
169
|
|
|
148
170
|
/**
|
|
@@ -197,7 +197,9 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
197
197
|
} else {
|
|
198
198
|
// Fallback to serializing the individual child node
|
|
199
199
|
var serializedChild = serializer.serializeNode(childNode);
|
|
200
|
-
|
|
200
|
+
if (serializedChild) {
|
|
201
|
+
dom.append(serializedChild);
|
|
202
|
+
}
|
|
201
203
|
}
|
|
202
204
|
});
|
|
203
205
|
return true; // Indicates we handled multiple children
|
|
@@ -259,7 +261,10 @@ export var createDeletedContentDecoration = function createDeletedContentDecorat
|
|
|
259
261
|
// Skip the case where the node is a paragraph or table row that way it can still be rendered and delete the entire table
|
|
260
262
|
return;
|
|
261
263
|
} else {
|
|
262
|
-
|
|
264
|
+
var fallbackNode = fallbackSerialization();
|
|
265
|
+
if (fallbackNode) {
|
|
266
|
+
dom.append(fallbackNode);
|
|
267
|
+
}
|
|
263
268
|
}
|
|
264
269
|
});
|
|
265
270
|
dom.setAttribute('data-testid', 'show-diff-deleted-decoration');
|
|
@@ -49,6 +49,10 @@ export declare class NodeViewSerializer {
|
|
|
49
49
|
init(params: {
|
|
50
50
|
editorView: EditorView;
|
|
51
51
|
}): void;
|
|
52
|
+
/**
|
|
53
|
+
* Appends serialized child nodes to the given contentDOM element.
|
|
54
|
+
*/
|
|
55
|
+
private appendChildNodes;
|
|
52
56
|
/**
|
|
53
57
|
* Attempts to create a node view for the given node.
|
|
54
58
|
*
|
|
@@ -59,11 +63,11 @@ export declare class NodeViewSerializer {
|
|
|
59
63
|
/**
|
|
60
64
|
* Serializes a node to a DOM `Node` using the schema's `DOMSerializer`.
|
|
61
65
|
*/
|
|
62
|
-
serializeNode(node: PMNode): Node;
|
|
66
|
+
serializeNode(node: PMNode): Node | null;
|
|
63
67
|
/**
|
|
64
68
|
* Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
|
|
65
69
|
*/
|
|
66
|
-
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement;
|
|
70
|
+
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
|
|
67
71
|
/**
|
|
68
72
|
* Returns a copy of the current node view blocklist.
|
|
69
73
|
*/
|
|
@@ -49,6 +49,10 @@ export declare class NodeViewSerializer {
|
|
|
49
49
|
init(params: {
|
|
50
50
|
editorView: EditorView;
|
|
51
51
|
}): void;
|
|
52
|
+
/**
|
|
53
|
+
* Appends serialized child nodes to the given contentDOM element.
|
|
54
|
+
*/
|
|
55
|
+
private appendChildNodes;
|
|
52
56
|
/**
|
|
53
57
|
* Attempts to create a node view for the given node.
|
|
54
58
|
*
|
|
@@ -59,11 +63,11 @@ export declare class NodeViewSerializer {
|
|
|
59
63
|
/**
|
|
60
64
|
* Serializes a node to a DOM `Node` using the schema's `DOMSerializer`.
|
|
61
65
|
*/
|
|
62
|
-
serializeNode(node: PMNode): Node;
|
|
66
|
+
serializeNode(node: PMNode): Node | null;
|
|
63
67
|
/**
|
|
64
68
|
* Serializes a fragment to a `DocumentFragment` using the schema's `DOMSerializer`.
|
|
65
69
|
*/
|
|
66
|
-
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement;
|
|
70
|
+
serializeFragment(fragment: Fragment): DocumentFragment | HTMLElement | null;
|
|
67
71
|
/**
|
|
68
72
|
* Returns a copy of the current node view blocklist.
|
|
69
73
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-show-diff",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "ShowDiff plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@atlaskit/adf-schema": "^51.
|
|
31
|
+
"@atlaskit/adf-schema": "^51.3.0",
|
|
32
32
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
33
|
-
"@atlaskit/tokens": "^
|
|
33
|
+
"@atlaskit/tokens": "^7.0.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0",
|
|
35
35
|
"lodash": "^4.17.21",
|
|
36
36
|
"memoize-one": "^6.0.0",
|
|
37
37
|
"prosemirror-changeset": "^2.2.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@atlaskit/editor-common": "^110.
|
|
40
|
+
"@atlaskit/editor-common": "^110.14.0",
|
|
41
41
|
"react": "^18.2.0"
|
|
42
42
|
},
|
|
43
43
|
"techstack": {
|