@atlaskit/renderer 141.0.7 → 142.0.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 +22 -0
- package/dist/cjs/render-document.js +40 -50
- package/dist/cjs/ui/Renderer/index.js +2 -2
- package/dist/es2019/render-document.js +31 -38
- package/dist/es2019/ui/Renderer/index.js +2 -2
- package/dist/esm/render-document.js +40 -50
- package/dist/esm/ui/Renderer/index.js +2 -2
- package/dist/types/render-document.d.ts +1 -1
- package/dist/types/ui/renderer-props.d.ts +0 -2
- package/package.json +2 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 142.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`01047cd51f538`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/01047cd51f538) -
|
|
8
|
+
Clean up `platform_editor_renderer_rm_usespecbasedvalidator` and always use spec-based validation
|
|
9
|
+
in the renderer.
|
|
10
|
+
|
|
11
|
+
Remove the deprecated `useSpecBasedValidator` renderer prop and the fifth `renderDocument`
|
|
12
|
+
argument. Remove this prop from renderer usages and remove the fifth argument from direct
|
|
13
|
+
`renderDocument` calls, shifting any subsequent arguments one position to the left. The legacy
|
|
14
|
+
validator is no longer available through the renderer.
|
|
15
|
+
|
|
16
|
+
Update editor AI renderer consumers to use the permanent validation behavior.
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`90cc9e3c7fc0c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/90cc9e3c7fc0c) -
|
|
21
|
+
Support gated dark-background styling for the configured Rovo Chat agent mention in editors and
|
|
22
|
+
the renderer.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 141.0.7
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -11,7 +11,6 @@ var _schemaDefault = require("@atlaskit/adf-schema/schema-default");
|
|
|
11
11
|
var _transforms = require("@atlaskit/adf-utils/transforms");
|
|
12
12
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
|
-
var _validator = require("@atlaskit/editor-common/validator");
|
|
15
14
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
16
15
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
17
16
|
var _events = require("./analytics/events");
|
|
@@ -34,37 +33,34 @@ var withStopwatch = function withStopwatch(cb) {
|
|
|
34
33
|
|
|
35
34
|
/** Schema-variant escape hatches handed to the ADF validator. */
|
|
36
35
|
|
|
37
|
-
var _validation = function _validation(doc, schema, adfStage,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
54
|
-
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
55
|
-
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
56
|
-
// strictness and gets it. The legacy branch below reads the same value as a schema selector and
|
|
57
|
-
// so keeps its own `final` default.
|
|
58
|
-
result = skipValidation ? transformedAdf || doc : (0, _utils.validateADFEntity)(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
59
|
-
} else {
|
|
60
|
-
result = (0, _validator.getValidDocument)(doc, schema, adfStage !== null && adfStage !== void 0 ? adfStage : 'final');
|
|
36
|
+
var _validation = function _validation(doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides) {
|
|
37
|
+
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
38
|
+
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
39
|
+
var _transformMediaLinkMa = (0, _transforms.transformMediaLinkMarks)(doc),
|
|
40
|
+
transformedAdf = _transformMediaLinkMa.transformedAdf,
|
|
41
|
+
isTransformed = _transformMediaLinkMa.isTransformed;
|
|
42
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
43
|
+
dispatchAnalyticsEvent({
|
|
44
|
+
action: _analytics.ACTION.MEDIA_LINK_TRANSFORMED,
|
|
45
|
+
actionSubject: _analytics.ACTION_SUBJECT.RENDERER,
|
|
46
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
47
|
+
});
|
|
61
48
|
}
|
|
62
|
-
|
|
63
|
-
|
|
49
|
+
|
|
50
|
+
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
51
|
+
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
52
|
+
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
53
|
+
// strictness and gets it.
|
|
54
|
+
var result = skipValidation ? transformedAdf || doc : (0, _utils.validateADFEntity)(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
55
|
+
|
|
56
|
+
// The spec validator can return the original root object when malformed JSON has no node type.
|
|
57
|
+
// Reject it here, matching the legacy validator, before ProseMirror attempts to deserialize it.
|
|
58
|
+
if (!result || typeof result.type !== 'string' || result.type.length === 0) {
|
|
59
|
+
return null;
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
// ProseMirror always require a child under doc
|
|
67
|
-
if (result.type === 'doc'
|
|
63
|
+
if (result.type === 'doc') {
|
|
68
64
|
if (Array.isArray(result.content) && result.content.length === 0) {
|
|
69
65
|
result.content.push({
|
|
70
66
|
type: 'paragraph',
|
|
@@ -149,24 +145,22 @@ var _validation = function _validation(doc, schema, adfStage, useSpecBasedValida
|
|
|
149
145
|
return result;
|
|
150
146
|
};
|
|
151
147
|
var memoValidation = (0, _memoizeOne.default)(_validation, function (newArgs, lastArgs) {
|
|
152
|
-
var _newArgs = (0, _slicedToArray2.default)(newArgs,
|
|
148
|
+
var _newArgs = (0, _slicedToArray2.default)(newArgs, 6),
|
|
153
149
|
newDoc = _newArgs[0],
|
|
154
150
|
newSchema = _newArgs[1],
|
|
155
151
|
newADFStage = _newArgs[2],
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var _lastArgs = (0, _slicedToArray2.default)(lastArgs, 7),
|
|
152
|
+
/* ignoring dispatchAnalyticsEvent */newSkipValidation = _newArgs[4],
|
|
153
|
+
newValidationOverrides = _newArgs[5];
|
|
154
|
+
var _lastArgs = (0, _slicedToArray2.default)(lastArgs, 6),
|
|
160
155
|
oldDoc = _lastArgs[0],
|
|
161
156
|
oldSchema = _lastArgs[1],
|
|
162
157
|
oldADFStage = _lastArgs[2],
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
oldValidationOverrides = _lastArgs[6];
|
|
158
|
+
/* ignoring dispatchAnalyticsEvent */oldSkipValidation = _lastArgs[4],
|
|
159
|
+
oldValidationOverrides = _lastArgs[5];
|
|
166
160
|
|
|
167
161
|
// `areDocsEqual` may stringify the whole document, so it goes last and only runs once everything
|
|
168
162
|
// cheaper has matched.
|
|
169
|
-
return newSchema === oldSchema && newADFStage === oldADFStage &&
|
|
163
|
+
return newSchema === oldSchema && newADFStage === oldADFStage && newSkipValidation === oldSkipValidation && areValidationOverridesEqual(newValidationOverrides, oldValidationOverrides) && areDocsEqual(newDoc, oldDoc);
|
|
170
164
|
});
|
|
171
165
|
|
|
172
166
|
// Ignored via go/ees005
|
|
@@ -260,22 +254,18 @@ var memoCreateNodeAndCheck = (0, _memoizeOne.default)(_createNodeAndCheck, funct
|
|
|
260
254
|
var renderDocument = exports.renderDocument = function renderDocument(doc, serializer) {
|
|
261
255
|
var schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _schemaDefault.defaultSchema;
|
|
262
256
|
var adfStage = arguments.length > 3 ? arguments[3] : undefined;
|
|
263
|
-
var
|
|
264
|
-
var
|
|
265
|
-
var
|
|
266
|
-
var
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
-
var
|
|
270
|
-
var validationOverrides = arguments.length > 11 ? arguments[11] : undefined;
|
|
257
|
+
var rendererId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'noid';
|
|
258
|
+
var dispatchAnalyticsEvent = arguments.length > 5 ? arguments[5] : undefined;
|
|
259
|
+
var unsupportedContentLevelsTracking = arguments.length > 6 ? arguments[6] : undefined;
|
|
260
|
+
var appearance = arguments.length > 7 ? arguments[7] : undefined;
|
|
261
|
+
var includeNodesCountInStats = arguments.length > 8 ? arguments[8] : undefined;
|
|
262
|
+
var skipValidation = arguments.length > 9 ? arguments[9] : undefined;
|
|
263
|
+
var validationOverrides = arguments.length > 10 ? arguments[10] : undefined;
|
|
271
264
|
var stat = {
|
|
272
265
|
sanitizeTime: 0
|
|
273
266
|
};
|
|
274
|
-
if ((0, _fg.fg)('platform_editor_renderer_rm_usespecbasedvalidator')) {
|
|
275
|
-
useSpecBasedValidator = true;
|
|
276
|
-
}
|
|
277
267
|
var _withStopwatch = withStopwatch(function () {
|
|
278
|
-
return memoValidation(doc, schema, adfStage,
|
|
268
|
+
return memoValidation(doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides);
|
|
279
269
|
}),
|
|
280
270
|
validDoc = _withStopwatch.output,
|
|
281
271
|
sanitizeTime = _withStopwatch.time;
|
|
@@ -304,7 +294,7 @@ var renderDocument = exports.renderDocument = function renderDocument(doc, seria
|
|
|
304
294
|
|
|
305
295
|
// save serialize tree time to stats
|
|
306
296
|
stat.serializeTime = serializeTime;
|
|
307
|
-
if (dispatchAnalyticsEvent
|
|
297
|
+
if (dispatchAnalyticsEvent) {
|
|
308
298
|
(0, _utils.findAndTrackUnsupportedContentNodes)(node, schema, dispatchAnalyticsEvent);
|
|
309
299
|
if (unsupportedContentLevelsTracking !== null && unsupportedContentLevelsTracking !== void 0 && unsupportedContentLevelsTracking.enabled) {
|
|
310
300
|
var documentData = {
|
|
@@ -71,7 +71,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
71
71
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
72
72
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
73
73
|
var packageName = "@atlaskit/renderer";
|
|
74
|
-
var packageVersion = "141.0.
|
|
74
|
+
var packageVersion = "141.0.7";
|
|
75
75
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
76
76
|
containerName: 'ak-renderer-wrapper',
|
|
77
77
|
containerType: 'inline-size'
|
|
@@ -498,7 +498,7 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
498
498
|
try {
|
|
499
499
|
var _rendererContext$feat, _props$media;
|
|
500
500
|
var schema = getSchema(props.schema, props.adfStage);
|
|
501
|
-
var _renderDocument = (0, _.renderDocument)(props.shouldRemoveEmptySpaceAroundContent ? (0, _rendererHelper.removeEmptySpaceAroundContent)(props.document) : props.document, serializer, schema, props.adfStage,
|
|
501
|
+
var _renderDocument = (0, _.renderDocument)(props.shouldRemoveEmptySpaceAroundContent ? (0, _rendererHelper.removeEmptySpaceAroundContent)(props.document) : props.document, serializer, schema, props.adfStage, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation, validationOverrides),
|
|
502
502
|
result = _renderDocument.result,
|
|
503
503
|
stat = _renderDocument.stat,
|
|
504
504
|
pmDoc = _renderDocument.pmDoc;
|
|
@@ -6,7 +6,6 @@ import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
|
|
|
6
6
|
import { nativeEmbedsFallbackTransform, transformContainerNodes, transformMediaLinkMarks, transformNestedTablesIncomingDocument } from '@atlaskit/adf-utils/transforms';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { findAndTrackUnsupportedContentNodes, validateADFEntity } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { getValidDocument } from '@atlaskit/editor-common/validator';
|
|
10
9
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
11
10
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
11
|
import { PLATFORM } from './analytics/events';
|
|
@@ -26,38 +25,35 @@ const withStopwatch = cb => {
|
|
|
26
25
|
|
|
27
26
|
/** Schema-variant escape hatches handed to the ADF validator. */
|
|
28
27
|
|
|
29
|
-
const _validation = (doc, schema, adfStage,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
47
|
-
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
48
|
-
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
49
|
-
// strictness and gets it. The legacy branch below reads the same value as a schema selector and
|
|
50
|
-
// so keeps its own `final` default.
|
|
51
|
-
result = skipValidation ? transformedAdf || doc : validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
52
|
-
} else {
|
|
53
|
-
result = getValidDocument(doc, schema, adfStage !== null && adfStage !== void 0 ? adfStage : 'final');
|
|
28
|
+
const _validation = (doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides) => {
|
|
29
|
+
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
30
|
+
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
31
|
+
const {
|
|
32
|
+
transformedAdf,
|
|
33
|
+
isTransformed
|
|
34
|
+
} = transformMediaLinkMarks(doc);
|
|
35
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
36
|
+
dispatchAnalyticsEvent({
|
|
37
|
+
action: ACTION.MEDIA_LINK_TRANSFORMED,
|
|
38
|
+
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
39
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
40
|
+
});
|
|
54
41
|
}
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
|
|
43
|
+
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
44
|
+
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
45
|
+
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
46
|
+
// strictness and gets it.
|
|
47
|
+
let result = skipValidation ? transformedAdf || doc : validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
48
|
+
|
|
49
|
+
// The spec validator can return the original root object when malformed JSON has no node type.
|
|
50
|
+
// Reject it here, matching the legacy validator, before ProseMirror attempts to deserialize it.
|
|
51
|
+
if (!result || typeof result.type !== 'string' || result.type.length === 0) {
|
|
52
|
+
return null;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
// ProseMirror always require a child under doc
|
|
60
|
-
if (result.type === 'doc'
|
|
56
|
+
if (result.type === 'doc') {
|
|
61
57
|
if (Array.isArray(result.content) && result.content.length === 0) {
|
|
62
58
|
result.content.push({
|
|
63
59
|
type: 'paragraph',
|
|
@@ -145,12 +141,12 @@ const _validation = (doc, schema, adfStage, useSpecBasedValidator, dispatchAnaly
|
|
|
145
141
|
return result;
|
|
146
142
|
};
|
|
147
143
|
const memoValidation = memoizeOne(_validation, (newArgs, lastArgs) => {
|
|
148
|
-
const [newDoc, newSchema, newADFStage
|
|
149
|
-
const [oldDoc, oldSchema, oldADFStage
|
|
144
|
+
const [newDoc, newSchema, newADFStage,, /* ignoring dispatchAnalyticsEvent */newSkipValidation, newValidationOverrides] = newArgs;
|
|
145
|
+
const [oldDoc, oldSchema, oldADFStage,, /* ignoring dispatchAnalyticsEvent */oldSkipValidation, oldValidationOverrides] = lastArgs;
|
|
150
146
|
|
|
151
147
|
// `areDocsEqual` may stringify the whole document, so it goes last and only runs once everything
|
|
152
148
|
// cheaper has matched.
|
|
153
|
-
return newSchema === oldSchema && newADFStage === oldADFStage &&
|
|
149
|
+
return newSchema === oldSchema && newADFStage === oldADFStage && newSkipValidation === oldSkipValidation && areValidationOverridesEqual(newValidationOverrides, oldValidationOverrides) && areDocsEqual(newDoc, oldDoc);
|
|
154
150
|
});
|
|
155
151
|
|
|
156
152
|
// Ignored via go/ees005
|
|
@@ -228,18 +224,15 @@ const memoCreateNodeAndCheck = memoizeOne(_createNodeAndCheck, (newArgs, lastArg
|
|
|
228
224
|
const [oldSchema, oldDoc] = lastArgs;
|
|
229
225
|
return newSchema === oldSchema && areDocsEqual(newDoc, oldDoc);
|
|
230
226
|
});
|
|
231
|
-
export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage,
|
|
227
|
+
export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage, rendererId = 'noid', dispatchAnalyticsEvent, unsupportedContentLevelsTracking, appearance, includeNodesCountInStats, skipValidation, validationOverrides) => {
|
|
232
228
|
const stat = {
|
|
233
229
|
sanitizeTime: 0
|
|
234
230
|
};
|
|
235
|
-
if (fg('platform_editor_renderer_rm_usespecbasedvalidator')) {
|
|
236
|
-
useSpecBasedValidator = true;
|
|
237
|
-
}
|
|
238
231
|
const {
|
|
239
232
|
output: validDoc,
|
|
240
233
|
time: sanitizeTime
|
|
241
234
|
} = withStopwatch(() => {
|
|
242
|
-
return memoValidation(doc, schema, adfStage,
|
|
235
|
+
return memoValidation(doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides);
|
|
243
236
|
});
|
|
244
237
|
|
|
245
238
|
// save sanitize time to stats
|
|
@@ -268,7 +261,7 @@ export const renderDocument = (doc, serializer, schema = defaultSchema, adfStage
|
|
|
268
261
|
|
|
269
262
|
// save serialize tree time to stats
|
|
270
263
|
stat.serializeTime = serializeTime;
|
|
271
|
-
if (dispatchAnalyticsEvent
|
|
264
|
+
if (dispatchAnalyticsEvent) {
|
|
272
265
|
findAndTrackUnsupportedContentNodes(node, schema, dispatchAnalyticsEvent);
|
|
273
266
|
if (unsupportedContentLevelsTracking !== null && unsupportedContentLevelsTracking !== void 0 && unsupportedContentLevelsTracking.enabled) {
|
|
274
267
|
const documentData = {
|
|
@@ -56,7 +56,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
56
56
|
const TABLE_INFO_TIMEOUT = 10000;
|
|
57
57
|
const RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
58
58
|
const packageName = "@atlaskit/renderer";
|
|
59
|
-
const packageVersion = "141.0.
|
|
59
|
+
const packageVersion = "141.0.7";
|
|
60
60
|
const setAsQueryContainerStyles = css({
|
|
61
61
|
containerName: 'ak-renderer-wrapper',
|
|
62
62
|
containerType: 'inline-size'
|
|
@@ -494,7 +494,7 @@ export const RendererFunctionalComponent = props => {
|
|
|
494
494
|
result,
|
|
495
495
|
stat,
|
|
496
496
|
pmDoc
|
|
497
|
-
} = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage,
|
|
497
|
+
} = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, id, fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation, validationOverrides);
|
|
498
498
|
if (props.onComplete) {
|
|
499
499
|
pendingOnCompleteStatRef.current = stat;
|
|
500
500
|
}
|
|
@@ -7,7 +7,6 @@ import { defaultSchema } from '@atlaskit/adf-schema/schema-default';
|
|
|
7
7
|
import { nativeEmbedsFallbackTransform, transformContainerNodes, transformMediaLinkMarks, transformNestedTablesIncomingDocument } from '@atlaskit/adf-utils/transforms';
|
|
8
8
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { findAndTrackUnsupportedContentNodes, validateADFEntity } from '@atlaskit/editor-common/utils';
|
|
10
|
-
import { getValidDocument } from '@atlaskit/editor-common/validator';
|
|
11
10
|
import { fg } from '@atlaskit/platform-feature-flags/fg';
|
|
12
11
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
13
12
|
import { PLATFORM } from './analytics/events';
|
|
@@ -27,37 +26,34 @@ var withStopwatch = function withStopwatch(cb) {
|
|
|
27
26
|
|
|
28
27
|
/** Schema-variant escape hatches handed to the ADF validator. */
|
|
29
28
|
|
|
30
|
-
var _validation = function _validation(doc, schema, adfStage,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
47
|
-
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
48
|
-
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
49
|
-
// strictness and gets it. The legacy branch below reads the same value as a schema selector and
|
|
50
|
-
// so keeps its own `final` default.
|
|
51
|
-
result = skipValidation ? transformedAdf || doc : validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
52
|
-
} else {
|
|
53
|
-
result = getValidDocument(doc, schema, adfStage !== null && adfStage !== void 0 ? adfStage : 'final');
|
|
29
|
+
var _validation = function _validation(doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides) {
|
|
30
|
+
// link mark on mediaSingle is deprecated, need to move link mark to child media node
|
|
31
|
+
// https://product-fabric.atlassian.net/browse/ED-14043
|
|
32
|
+
var _transformMediaLinkMa = transformMediaLinkMarks(doc),
|
|
33
|
+
transformedAdf = _transformMediaLinkMa.transformedAdf,
|
|
34
|
+
isTransformed = _transformMediaLinkMa.isTransformed;
|
|
35
|
+
if (isTransformed && dispatchAnalyticsEvent) {
|
|
36
|
+
dispatchAnalyticsEvent({
|
|
37
|
+
action: ACTION.MEDIA_LINK_TRANSFORMED,
|
|
38
|
+
actionSubject: ACTION_SUBJECT.RENDERER,
|
|
39
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
40
|
+
});
|
|
54
41
|
}
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
|
|
43
|
+
// Forward `adfStage` only when a caller names one. Omitting it keeps stage-0 specs acceptable,
|
|
44
|
+
// which is what a renderer wants: stored documents can contain them, and wrapping such content
|
|
45
|
+
// as unsupported is worse than rendering it. A caller that declares `final` asks for full-ADF
|
|
46
|
+
// strictness and gets it.
|
|
47
|
+
var result = skipValidation ? transformedAdf || doc : validateADFEntity(schema, transformedAdf || doc, dispatchAnalyticsEvent, validationOverrides, adfStage);
|
|
48
|
+
|
|
49
|
+
// The spec validator can return the original root object when malformed JSON has no node type.
|
|
50
|
+
// Reject it here, matching the legacy validator, before ProseMirror attempts to deserialize it.
|
|
51
|
+
if (!result || typeof result.type !== 'string' || result.type.length === 0) {
|
|
52
|
+
return null;
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
// ProseMirror always require a child under doc
|
|
60
|
-
if (result.type === 'doc'
|
|
56
|
+
if (result.type === 'doc') {
|
|
61
57
|
if (Array.isArray(result.content) && result.content.length === 0) {
|
|
62
58
|
result.content.push({
|
|
63
59
|
type: 'paragraph',
|
|
@@ -142,24 +138,22 @@ var _validation = function _validation(doc, schema, adfStage, useSpecBasedValida
|
|
|
142
138
|
return result;
|
|
143
139
|
};
|
|
144
140
|
var memoValidation = memoizeOne(_validation, function (newArgs, lastArgs) {
|
|
145
|
-
var _newArgs = _slicedToArray(newArgs,
|
|
141
|
+
var _newArgs = _slicedToArray(newArgs, 6),
|
|
146
142
|
newDoc = _newArgs[0],
|
|
147
143
|
newSchema = _newArgs[1],
|
|
148
144
|
newADFStage = _newArgs[2],
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
var _lastArgs = _slicedToArray(lastArgs, 7),
|
|
145
|
+
/* ignoring dispatchAnalyticsEvent */newSkipValidation = _newArgs[4],
|
|
146
|
+
newValidationOverrides = _newArgs[5];
|
|
147
|
+
var _lastArgs = _slicedToArray(lastArgs, 6),
|
|
153
148
|
oldDoc = _lastArgs[0],
|
|
154
149
|
oldSchema = _lastArgs[1],
|
|
155
150
|
oldADFStage = _lastArgs[2],
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
oldValidationOverrides = _lastArgs[6];
|
|
151
|
+
/* ignoring dispatchAnalyticsEvent */oldSkipValidation = _lastArgs[4],
|
|
152
|
+
oldValidationOverrides = _lastArgs[5];
|
|
159
153
|
|
|
160
154
|
// `areDocsEqual` may stringify the whole document, so it goes last and only runs once everything
|
|
161
155
|
// cheaper has matched.
|
|
162
|
-
return newSchema === oldSchema && newADFStage === oldADFStage &&
|
|
156
|
+
return newSchema === oldSchema && newADFStage === oldADFStage && newSkipValidation === oldSkipValidation && areValidationOverridesEqual(newValidationOverrides, oldValidationOverrides) && areDocsEqual(newDoc, oldDoc);
|
|
163
157
|
});
|
|
164
158
|
|
|
165
159
|
// Ignored via go/ees005
|
|
@@ -253,22 +247,18 @@ var memoCreateNodeAndCheck = memoizeOne(_createNodeAndCheck, function (newArgs,
|
|
|
253
247
|
export var renderDocument = function renderDocument(doc, serializer) {
|
|
254
248
|
var schema = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : defaultSchema;
|
|
255
249
|
var adfStage = arguments.length > 3 ? arguments[3] : undefined;
|
|
256
|
-
var
|
|
257
|
-
var
|
|
258
|
-
var
|
|
259
|
-
var
|
|
260
|
-
var
|
|
261
|
-
var
|
|
262
|
-
var
|
|
263
|
-
var validationOverrides = arguments.length > 11 ? arguments[11] : undefined;
|
|
250
|
+
var rendererId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'noid';
|
|
251
|
+
var dispatchAnalyticsEvent = arguments.length > 5 ? arguments[5] : undefined;
|
|
252
|
+
var unsupportedContentLevelsTracking = arguments.length > 6 ? arguments[6] : undefined;
|
|
253
|
+
var appearance = arguments.length > 7 ? arguments[7] : undefined;
|
|
254
|
+
var includeNodesCountInStats = arguments.length > 8 ? arguments[8] : undefined;
|
|
255
|
+
var skipValidation = arguments.length > 9 ? arguments[9] : undefined;
|
|
256
|
+
var validationOverrides = arguments.length > 10 ? arguments[10] : undefined;
|
|
264
257
|
var stat = {
|
|
265
258
|
sanitizeTime: 0
|
|
266
259
|
};
|
|
267
|
-
if (fg('platform_editor_renderer_rm_usespecbasedvalidator')) {
|
|
268
|
-
useSpecBasedValidator = true;
|
|
269
|
-
}
|
|
270
260
|
var _withStopwatch = withStopwatch(function () {
|
|
271
|
-
return memoValidation(doc, schema, adfStage,
|
|
261
|
+
return memoValidation(doc, schema, adfStage, dispatchAnalyticsEvent, skipValidation, validationOverrides);
|
|
272
262
|
}),
|
|
273
263
|
validDoc = _withStopwatch.output,
|
|
274
264
|
sanitizeTime = _withStopwatch.time;
|
|
@@ -297,7 +287,7 @@ export var renderDocument = function renderDocument(doc, serializer) {
|
|
|
297
287
|
|
|
298
288
|
// save serialize tree time to stats
|
|
299
289
|
stat.serializeTime = serializeTime;
|
|
300
|
-
if (dispatchAnalyticsEvent
|
|
290
|
+
if (dispatchAnalyticsEvent) {
|
|
301
291
|
findAndTrackUnsupportedContentNodes(node, schema, dispatchAnalyticsEvent);
|
|
302
292
|
if (unsupportedContentLevelsTracking !== null && unsupportedContentLevelsTracking !== void 0 && unsupportedContentLevelsTracking.enabled) {
|
|
303
293
|
var documentData = {
|
|
@@ -61,7 +61,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
61
61
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
62
62
|
var RENDER_EVENT_SAMPLE_RATE = 0.1;
|
|
63
63
|
var packageName = "@atlaskit/renderer";
|
|
64
|
-
var packageVersion = "141.0.
|
|
64
|
+
var packageVersion = "141.0.7";
|
|
65
65
|
var setAsQueryContainerStyles = css({
|
|
66
66
|
containerName: 'ak-renderer-wrapper',
|
|
67
67
|
containerType: 'inline-size'
|
|
@@ -488,7 +488,7 @@ export var RendererFunctionalComponent = function RendererFunctionalComponent(pr
|
|
|
488
488
|
try {
|
|
489
489
|
var _rendererContext$feat, _props$media;
|
|
490
490
|
var schema = getSchema(props.schema, props.adfStage);
|
|
491
|
-
var _renderDocument = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage,
|
|
491
|
+
var _renderDocument = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation, validationOverrides),
|
|
492
492
|
result = _renderDocument.result,
|
|
493
493
|
stat = _renderDocument.stat,
|
|
494
494
|
pmDoc = _renderDocument.pmDoc;
|
|
@@ -25,5 +25,5 @@ type ValidationOverrides = {
|
|
|
25
25
|
allowNestedTables?: boolean;
|
|
26
26
|
allowTableInPanel?: boolean;
|
|
27
27
|
};
|
|
28
|
-
export declare const renderDocument: <T>(doc: any, serializer: Serializer<T>, schema?: Schema, adfStage?: ADFStage,
|
|
28
|
+
export declare const renderDocument: <T>(doc: any, serializer: Serializer<T>, schema?: Schema, adfStage?: ADFStage, rendererId?: string, dispatchAnalyticsEvent?: DispatchAnalyticsEvent, unsupportedContentLevelsTracking?: UnsupportedContentLevelsTracking, appearance?: RendererAppearance, includeNodesCountInStats?: boolean, skipValidation?: boolean, validationOverrides?: ValidationOverrides) => RenderOutput<T | null>;
|
|
29
29
|
export {};
|
|
@@ -230,7 +230,5 @@ export interface RendererProps {
|
|
|
230
230
|
/** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-26490 Internal documentation for deprecation (no external access)} This prop has been marked stable and therefore replaced by the `textHighlighter` prop. Please use `textHighlighter` prop instead. */
|
|
231
231
|
UNSTABLE_textHighlighter?: TextHighlighter;
|
|
232
232
|
unsupportedContentLevelsTracking?: UnsupportedContentLevelsTracking;
|
|
233
|
-
/** @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-3649 Internal documentation for deprecation (no external access)} This prop will be removed and set as default enabled, as the same flag on the Editor is also now default enabled. */
|
|
234
|
-
useSpecBasedValidator?: boolean;
|
|
235
233
|
}
|
|
236
234
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "142.0.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"uuid": "^11.1.1"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
|
-
"@atlaskit/editor-common": "^123.
|
|
91
|
+
"@atlaskit/editor-common": "^123.6.0",
|
|
92
92
|
"@atlaskit/link-provider": "^5.7.0",
|
|
93
93
|
"@atlaskit/media-core": "^38.2.0",
|
|
94
94
|
"react": "^18.2.0 || ^19.2.0",
|
|
@@ -194,9 +194,6 @@
|
|
|
194
194
|
"type": "boolean",
|
|
195
195
|
"referenceOnly": true
|
|
196
196
|
},
|
|
197
|
-
"platform_editor_renderer_rm_usespecbasedvalidator": {
|
|
198
|
-
"type": "boolean"
|
|
199
|
-
},
|
|
200
197
|
"platform_editor_bordered_panel_nested_in_table": {
|
|
201
198
|
"type": "boolean"
|
|
202
199
|
},
|