@atlaskit/renderer 118.6.7 → 118.6.9
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/actions/index.js +7 -173
- package/dist/cjs/ui/ExtensionRenderer.js +9 -14
- package/dist/cjs/ui/Renderer/index.js +22 -7
- package/dist/cjs/ui/annotations/selection/mounter.js +1 -27
- package/dist/es2019/actions/index.js +5 -169
- package/dist/es2019/ui/ExtensionRenderer.js +8 -12
- package/dist/es2019/ui/Renderer/index.js +22 -7
- package/dist/es2019/ui/annotations/selection/mounter.js +1 -27
- package/dist/esm/actions/index.js +7 -173
- package/dist/esm/ui/ExtensionRenderer.js +9 -14
- package/dist/esm/ui/Renderer/index.js +22 -7
- package/dist/esm/ui/annotations/selection/mounter.js +1 -27
- package/dist/types/actions/index.d.ts +0 -6
- package/dist/types/ui/ExtensionRenderer.d.ts +1 -3
- package/dist/types/ui/Renderer/RendererStyleContainer.d.ts +1 -1
- package/dist/types/ui/Renderer/index.d.ts +1 -0
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/dist/types-ts4.5/actions/index.d.ts +0 -6
- package/dist/types-ts4.5/ui/ExtensionRenderer.d.ts +1 -3
- package/dist/types-ts4.5/ui/Renderer/RendererStyleContainer.d.ts +1 -1
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/renderer-props.d.ts +1 -0
- package/package.json +7 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 118.6.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#164686](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/164686)
|
|
8
|
+
[`4b2aaa6783398`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4b2aaa6783398) -
|
|
9
|
+
Removed extra debug logging which was adding behind gate
|
|
10
|
+
platform_renderer_annotations_create_debug_logging
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 118.6.8
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#166323](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/166323)
|
|
18
|
+
[`51519a7335b4d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/51519a7335b4d) -
|
|
19
|
+
[ux] Remove 1px margin top from inline macro wrapper that is causing hydration shift
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 118.6.7
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -22,6 +22,10 @@ var _matchesUtils = require("./matches-utils");
|
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
24
|
var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
25
|
+
// Any kind of refence is allowed
|
|
26
|
+
// Ignored via go/ees005
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
+
|
|
25
29
|
function RendererActions() {
|
|
26
30
|
var initFromContext = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
27
31
|
(0, _classCallCheck2.default)(this, RendererActions);
|
|
@@ -29,55 +33,6 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
29
33
|
// This module can only be used when wrapped with
|
|
30
34
|
// the <RendererContext> component for now.
|
|
31
35
|
(0, _defineProperty2.default)(this, "initFromContext", false);
|
|
32
|
-
(0, _defineProperty2.default)(this, "debugAnalyticLoggingEnabled", false);
|
|
33
|
-
// TODO: EDITOR-595 - This method is temporary and should be removed once the following issue
|
|
34
|
-
// has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
|
|
35
|
-
// This is a copy of the original canApplyAnnotationOnRange. If that returns false this is run to figure out exactly why
|
|
36
|
-
// the annotation cannot be applied to the range.
|
|
37
|
-
(0, _defineProperty2.default)(this, "_privateWhyCannotApplyAnnotationOnRange", function (pos, doc, schema) {
|
|
38
|
-
var from = pos.from,
|
|
39
|
-
to = pos.to;
|
|
40
|
-
if (isNaN(from + to) || to - from <= 0 || to < 0 || from < 0) {
|
|
41
|
-
return 'position invalid';
|
|
42
|
-
}
|
|
43
|
-
var reasons = [];
|
|
44
|
-
doc.nodesBetween(from, to, function (node, _pos, parent) {
|
|
45
|
-
// Special exception for hardBreak nodes
|
|
46
|
-
if (schema.nodes.hardBreak === node.type) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// For block elements or text nodes, we want to check
|
|
51
|
-
// if annotations are allowed inside this tree
|
|
52
|
-
// or if we're leaf and not text
|
|
53
|
-
if ((0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')) {
|
|
54
|
-
var isAllowedInlineNode = ['emoji', 'status', 'date', 'mention', 'inlineCard'].includes(node.type.name);
|
|
55
|
-
if (node.isInline && !node.isText && !isAllowedInlineNode) {
|
|
56
|
-
reasons.push("Err 1 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf));
|
|
57
|
-
return false;
|
|
58
|
-
} else if (node.isLeaf && !node.isText && !isAllowedInlineNode) {
|
|
59
|
-
reasons.push("Err 2 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf));
|
|
60
|
-
return false;
|
|
61
|
-
} else if (node.isText && !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(schema.marks.annotation))) {
|
|
62
|
-
reasons.push("Err 3 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf, ", parent: ").concat(parent === null || parent === void 0 ? void 0 : parent.type.name));
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
} else {
|
|
66
|
-
if (node.isInline && !node.isText) {
|
|
67
|
-
reasons.push("Err 4 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf));
|
|
68
|
-
return false;
|
|
69
|
-
} else if (node.isLeaf && !node.isText) {
|
|
70
|
-
reasons.push("Err 5 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf));
|
|
71
|
-
return false;
|
|
72
|
-
} else if (node.isText && !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(schema.marks.annotation))) {
|
|
73
|
-
reasons.push("Err 6 - type: ".concat(node.type.name, ", isInline: ").concat(node.isInline, ", isText: ").concat(node.isText, ", isLeaf: ").concat(node.isLeaf, ", parent: ").concat(parent === null || parent === void 0 ? void 0 : parent.type.name));
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return true;
|
|
78
|
-
});
|
|
79
|
-
return reasons.join(', ');
|
|
80
|
-
});
|
|
81
36
|
this.initFromContext = initFromContext;
|
|
82
37
|
this.transformer = new _editorJsonTransformer.JSONTransformer();
|
|
83
38
|
}
|
|
@@ -112,82 +67,23 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
112
67
|
key: "_privateValidatePositionsForAnnotation",
|
|
113
68
|
value: function _privateValidatePositionsForAnnotation(from, to) {
|
|
114
69
|
if (!this.doc || !this.schema) {
|
|
115
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
116
|
-
this.onAnalyticsEvent({
|
|
117
|
-
// @ts-ignore
|
|
118
|
-
action: 'failed',
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
actionSubject: 'applyAnnotation',
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
123
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
124
|
-
attributes: {
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
reason: "Annotation Position validation failed - Missing doc or schema",
|
|
127
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes'),
|
|
128
|
-
isDocValid: !!this.doc,
|
|
129
|
-
isSchemaValid: !!this.schema
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
70
|
return false;
|
|
134
71
|
}
|
|
135
72
|
var currentSelection = _state.TextSelection.create(this.doc, from, to);
|
|
136
73
|
if ((0, _utils.isEmptyTextSelection)(currentSelection, this.schema)) {
|
|
137
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
138
|
-
this.onAnalyticsEvent({
|
|
139
|
-
// @ts-ignore
|
|
140
|
-
action: 'failed',
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
actionSubject: 'applyAnnotation',
|
|
143
|
-
// @ts-ignore
|
|
144
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
145
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
146
|
-
attributes: {
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
reason: "Annotation Position validation - Empty Text Selection",
|
|
149
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes'),
|
|
150
|
-
from: from,
|
|
151
|
-
to: to
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
74
|
return false;
|
|
156
75
|
}
|
|
157
76
|
var result = (0, _utils.canApplyAnnotationOnRange)({
|
|
158
77
|
from: from,
|
|
159
78
|
to: to
|
|
160
79
|
}, this.doc, this.schema);
|
|
161
|
-
if (this.debugAnalyticLoggingEnabled && !result && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
162
|
-
this.onAnalyticsEvent({
|
|
163
|
-
// @ts-ignore
|
|
164
|
-
action: 'failed',
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
actionSubject: 'applyAnnotation',
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
169
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
170
|
-
attributes: {
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
reason: "Annotation canApplyAnnotationOnRange failed",
|
|
173
|
-
details: this._privateWhyCannotApplyAnnotationOnRange({
|
|
174
|
-
from: from,
|
|
175
|
-
to: to
|
|
176
|
-
}, this.doc, this.schema),
|
|
177
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes'),
|
|
178
|
-
from: from,
|
|
179
|
-
to: to
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
80
|
return result;
|
|
184
81
|
}
|
|
82
|
+
|
|
83
|
+
//#endregion
|
|
185
84
|
}, {
|
|
186
85
|
key: "deleteAnnotation",
|
|
187
|
-
value:
|
|
188
|
-
//#endregion
|
|
189
|
-
|
|
190
|
-
function deleteAnnotation(annotationId, annotationType) {
|
|
86
|
+
value: function deleteAnnotation(annotationId, annotationType) {
|
|
191
87
|
if (!this.doc || !this.schema || !this.schema.marks.annotation) {
|
|
192
88
|
return false;
|
|
193
89
|
}
|
|
@@ -338,24 +234,6 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
338
234
|
key: "isValidAnnotationPosition",
|
|
339
235
|
value: function isValidAnnotationPosition(pos) {
|
|
340
236
|
if (!pos || !this.doc) {
|
|
341
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
342
|
-
this.onAnalyticsEvent({
|
|
343
|
-
// @ts-ignore
|
|
344
|
-
action: 'failed',
|
|
345
|
-
// @ts-ignore
|
|
346
|
-
actionSubject: 'applyAnnotation',
|
|
347
|
-
// @ts-ignore
|
|
348
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
349
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
350
|
-
attributes: {
|
|
351
|
-
// @ts-ignore
|
|
352
|
-
reason: "Annotation Position validation failed - Missing doc or position",
|
|
353
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes'),
|
|
354
|
-
isPosValid: !!pos,
|
|
355
|
-
isDocValid: !!this.doc
|
|
356
|
-
}
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
237
|
return false;
|
|
360
238
|
}
|
|
361
239
|
return this._privateValidatePositionsForAnnotation(pos.from, pos.to);
|
|
@@ -417,25 +295,6 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
417
295
|
key: "applyAnnotation",
|
|
418
296
|
value: function applyAnnotation(pos, annotation) {
|
|
419
297
|
if (!this.doc || !pos || !this.schema) {
|
|
420
|
-
if (this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
421
|
-
this.onAnalyticsEvent({
|
|
422
|
-
// @ts-ignore
|
|
423
|
-
action: 'failed',
|
|
424
|
-
// @ts-ignore
|
|
425
|
-
actionSubject: 'applyAnnotation',
|
|
426
|
-
// @ts-ignore
|
|
427
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
428
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
429
|
-
attributes: {
|
|
430
|
-
// @ts-ignore
|
|
431
|
-
reason: "Annotation applyAnnotation failed - Missing doc, position or schema",
|
|
432
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes'),
|
|
433
|
-
isPosValid: !!pos,
|
|
434
|
-
isDocValid: !!this.doc,
|
|
435
|
-
isSchemaValid: !!this.schema
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
298
|
return false;
|
|
440
299
|
}
|
|
441
300
|
var from = pos.from,
|
|
@@ -469,22 +328,6 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
469
328
|
doc = _step$apply2.doc,
|
|
470
329
|
failed = _step$apply2.failed;
|
|
471
330
|
if (failed || !doc) {
|
|
472
|
-
if (this.onAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
473
|
-
this.onAnalyticsEvent({
|
|
474
|
-
// @ts-ignore
|
|
475
|
-
action: 'failed',
|
|
476
|
-
// @ts-ignore
|
|
477
|
-
actionSubject: 'applyAnnotation',
|
|
478
|
-
// @ts-ignore
|
|
479
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
480
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL,
|
|
481
|
-
attributes: {
|
|
482
|
-
// @ts-ignore
|
|
483
|
-
reason: "Annotation applyAnnotation failed - ".concat(failed),
|
|
484
|
-
commentsOnInlineNodesAllowed: (0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes')
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
331
|
return false;
|
|
489
332
|
}
|
|
490
333
|
var originalSelection = doc.textBetween(from, to);
|
|
@@ -545,14 +388,5 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
545
388
|
schema: this.schema
|
|
546
389
|
}, annotationId);
|
|
547
390
|
}
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* This is a temporary method used for controlling when extra analytics shoulw be logged.
|
|
551
|
-
*/
|
|
552
|
-
}, {
|
|
553
|
-
key: "_setDebugLogging",
|
|
554
|
-
value: function _setDebugLogging(enabled) {
|
|
555
|
-
this.debugAnalyticLoggingEnabled = enabled;
|
|
556
|
-
}
|
|
557
391
|
}]);
|
|
558
392
|
}();
|
|
@@ -19,21 +19,18 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
19
19
|
*/
|
|
20
20
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
21
21
|
|
|
22
|
-
// When running on server-side emotion will generate style tags before elements.
|
|
23
|
-
// This caused packages/editor/editor-common/src/styles/shared/block-marks.ts to override the margin-top.
|
|
24
|
-
// However as soon as the styles are extracted to <head> it adds back the margin.
|
|
25
|
-
// The timing is tricky as it happens to be when UFO collects the dimension for the placeholder for TTVC calculation.
|
|
26
|
-
// This resulted 1px mismatch on the image. Further cause everything on page to shift by 1px.
|
|
27
|
-
var forceMarginTopStyle = (0, _react.css)({
|
|
28
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-important-styles
|
|
29
|
-
marginTop: "1px !important"
|
|
30
|
-
});
|
|
31
22
|
var inlineExtensionStyle = (0, _react.css)({
|
|
32
23
|
display: 'inline-block',
|
|
33
24
|
maxWidth: '100%',
|
|
34
25
|
verticalAlign: 'middle',
|
|
26
|
+
// 0px margin top is important here.
|
|
27
|
+
// When running on server-side emotion will generate style tags before elements.
|
|
28
|
+
// This caused packages/editor/editor-common/src/styles/shared/block-marks.ts to override the margin-top.
|
|
29
|
+
// However as soon as the styles are extracted to <head> it adds back the margin.
|
|
30
|
+
// The timing is tricky as it happens to be when UFO collects the dimension for the placeholder for TTVC calculation.
|
|
31
|
+
// This resulted 1px mismatch on the image. Further cause everything on page to shift by 1px.
|
|
35
32
|
// es-lint-disable-next-line @atlaskit/design-system/ensure-design-token-usage
|
|
36
|
-
margin: "
|
|
33
|
+
margin: "0px 1px ".concat("var(--ds-space-050, 4px)"),
|
|
37
34
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
|
|
38
35
|
'& .rich-media-item': {
|
|
39
36
|
maxWidth: '100%'
|
|
@@ -137,12 +134,10 @@ function ExtensionRenderer(props) {
|
|
|
137
134
|
});
|
|
138
135
|
}
|
|
139
136
|
var InlineNodeRendererWrapper = exports.InlineNodeRendererWrapper = function InlineNodeRendererWrapper(_ref) {
|
|
140
|
-
var
|
|
141
|
-
forceMarginTop = _ref$forceMarginTop === void 0 ? false : _ref$forceMarginTop,
|
|
142
|
-
children = _ref.children;
|
|
137
|
+
var children = _ref.children;
|
|
143
138
|
return (0, _react.jsx)("div", {
|
|
144
139
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
145
140
|
className: "inline-extension-renderer",
|
|
146
|
-
css:
|
|
141
|
+
css: inlineExtensionStyle
|
|
147
142
|
}, children);
|
|
148
143
|
};
|
|
@@ -62,7 +62,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
62
62
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
63
63
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
64
64
|
var packageName = "@atlaskit/renderer";
|
|
65
|
-
var packageVersion = "118.6.
|
|
65
|
+
var packageVersion = "118.6.9";
|
|
66
66
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
67
67
|
containerName: 'ak-renderer-wrapper',
|
|
68
68
|
containerType: 'inline-size'
|
|
@@ -422,7 +422,8 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
422
422
|
ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
|
|
423
423
|
isInsideOfInlineExtension: props.isInsideOfInlineExtension,
|
|
424
424
|
isTopLevelRenderer: rendererContext.isTopLevelRenderer,
|
|
425
|
-
shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
|
|
425
|
+
shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent,
|
|
426
|
+
allowRendererContainerStyles: props.allowRendererContainerStyles
|
|
426
427
|
}, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? (0, _react2.jsx)(_breakoutSsr.BreakoutSSRInlineScript, {
|
|
427
428
|
noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
|
|
428
429
|
}) : null, (0, _react2.jsx)(RendererActionsInternalUpdater, {
|
|
@@ -453,7 +454,8 @@ var RendererFunctionalComponent = exports.RendererFunctionalComponent = function
|
|
|
453
454
|
onClick: function onClick(event) {
|
|
454
455
|
return handleWrapperOnClick(event, props, mouseDownSelection);
|
|
455
456
|
},
|
|
456
|
-
isTopLevelRenderer: rendererContext.isTopLevelRenderer
|
|
457
|
+
isTopLevelRenderer: rendererContext.isTopLevelRenderer,
|
|
458
|
+
allowRendererContainerStyles: props.allowRendererContainerStyles
|
|
457
459
|
}, (0, _react2.jsx)(_ui.UnsupportedBlock, null));
|
|
458
460
|
}
|
|
459
461
|
};
|
|
@@ -545,7 +547,8 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
545
547
|
ssr = props.ssr,
|
|
546
548
|
isInsideOfInlineExtension = props.isInsideOfInlineExtension,
|
|
547
549
|
allowTableResizing = props.allowTableResizing,
|
|
548
|
-
isTopLevelRenderer = props.isTopLevelRenderer
|
|
550
|
+
isTopLevelRenderer = props.isTopLevelRenderer,
|
|
551
|
+
allowRendererContainerStyles = props.allowRendererContainerStyles;
|
|
549
552
|
var createTelepointer = function createTelepointer() {
|
|
550
553
|
var telepointer = document.createElement('span');
|
|
551
554
|
telepointer.textContent = "\u200B";
|
|
@@ -620,20 +623,32 @@ var RendererWrapper = /*#__PURE__*/_react.default.memo(function (props) {
|
|
|
620
623
|
allowColumnSorting: !!allowColumnSorting,
|
|
621
624
|
useBlockRenderForCodeBlock: useBlockRenderForCodeBlock,
|
|
622
625
|
allowAnnotations: props.allowAnnotations,
|
|
623
|
-
allowTableResizing: allowTableResizing
|
|
626
|
+
allowTableResizing: allowTableResizing,
|
|
627
|
+
allowRendererContainerStyles: allowRendererContainerStyles
|
|
624
628
|
}, children))));
|
|
625
629
|
|
|
626
630
|
// We can only make the wrapper div query container when we have a known width.
|
|
627
631
|
// This is also required for SSR to work correctly. As WidthProvider/WithConsumer will not have the correct width during SSR.
|
|
628
632
|
//
|
|
633
|
+
|
|
634
|
+
// allowRendererContainerStyles is not needed for comment container styling as container should always be set for comments
|
|
635
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
636
|
+
if (appearance === 'comment' && isTopLevelRenderer && (0, _platformFeatureFlags.fg)('platform-ssr-table-resize')) {
|
|
637
|
+
return (0, _react2.jsx)("div", {
|
|
638
|
+
css: setAsQueryContainerStyles
|
|
639
|
+
}, renderer);
|
|
640
|
+
}
|
|
641
|
+
|
|
629
642
|
// We are setting this wrapper div as query container conditionally.
|
|
630
643
|
// Only apply container-type = inline-size when having a known width in full-page/full-width/comment mode.
|
|
631
644
|
// Otherwise when appearance is unspecified the renderer size is decided by the content.
|
|
632
645
|
// In this case we can't set the container-type = inline-size as it will collapse width to 0.
|
|
633
|
-
return (appearance === 'full-page' || appearance === 'full-width'
|
|
646
|
+
return (appearance === 'full-page' || appearance === 'full-width') &&
|
|
634
647
|
// In case of having excerpt-include on page there are multiple renderers nested.
|
|
635
648
|
// Make sure only the root renderer is set to be query container.
|
|
636
|
-
isTopLevelRenderer &&
|
|
649
|
+
isTopLevelRenderer && allowRendererContainerStyles &&
|
|
650
|
+
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
651
|
+
(0, _platformFeatureFlags.fg)('platform-ssr-table-resize') ? (0, _react2.jsx)("div", {
|
|
637
652
|
css: setAsQueryContainerStyles
|
|
638
653
|
}, renderer) : renderer;
|
|
639
654
|
});
|
|
@@ -70,28 +70,8 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
70
70
|
// !!! at this point, the documentPosition can be the wrong position if the user select something else
|
|
71
71
|
var positionToAnnotate = selectionDraftDocumentPosition || documentPosition;
|
|
72
72
|
if (!positionToAnnotate || !applyAnnotation) {
|
|
73
|
-
// TODO: EDITOR-595 - This analytic event is temporary and should be removed once the following issue
|
|
74
|
-
// has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
|
|
75
|
-
if (createAnalyticsEvent && (0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
76
|
-
createAnalyticsEvent({
|
|
77
|
-
action: 'failed',
|
|
78
|
-
actionSubject: 'applyAnnotation',
|
|
79
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
80
|
-
attributes: {
|
|
81
|
-
reason: 'Annotation Position invalid',
|
|
82
|
-
draftDocumentPosition: selectionDraftDocumentPosition,
|
|
83
|
-
documentPosition: documentPosition,
|
|
84
|
-
applyAnnotation: !!applyAnnotation,
|
|
85
|
-
isDraftPositionFixEnabled: true
|
|
86
|
-
},
|
|
87
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
88
|
-
}).fire(_types.FabricChannel.editor);
|
|
89
|
-
}
|
|
90
73
|
return false;
|
|
91
74
|
}
|
|
92
|
-
if ((0, _platformFeatureFlags.fg)('platform_renderer_annotations_create_debug_logging')) {
|
|
93
|
-
actions._setDebugLogging(true);
|
|
94
|
-
}
|
|
95
75
|
|
|
96
76
|
// Evaluate position validity when the user commits the position to be annotated
|
|
97
77
|
var isCreateAllowedOnPosition = actions.isValidAnnotationPosition(positionToAnnotate);
|
|
@@ -113,13 +93,7 @@ var SelectionInlineCommentMounter = exports.SelectionInlineCommentMounter = /*#_
|
|
|
113
93
|
eventType: _analytics.EVENT_TYPE.TRACK
|
|
114
94
|
}).fire(_types.FabricChannel.editor);
|
|
115
95
|
}
|
|
116
|
-
|
|
117
|
-
var result = applyAnnotation(positionToAnnotate, annotation);
|
|
118
|
-
actions._setDebugLogging(false);
|
|
119
|
-
return result;
|
|
120
|
-
} else {
|
|
121
|
-
return applyAnnotation(positionToAnnotate, annotation);
|
|
122
|
-
}
|
|
96
|
+
return applyAnnotation(positionToAnnotate, annotation);
|
|
123
97
|
}, [actions, documentPosition, applyAnnotation, createAnalyticsEvent, inlineNodeTypes, selectionDraftDocumentPosition]);
|
|
124
98
|
var createIndexCallback = (0, _react.useCallback)(function () {
|
|
125
99
|
if (!documentPosition || !generateIndexMatch) {
|
|
@@ -10,62 +10,15 @@ import { createAnnotationStep, getPosFromRange } from '../steps';
|
|
|
10
10
|
import { getRendererRangeInlineNodeNames } from './get-renderer-range-inline-node-names';
|
|
11
11
|
import { getIndexMatch } from './matches-utils';
|
|
12
12
|
export default class RendererActions {
|
|
13
|
+
// Any kind of refence is allowed
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
|
|
13
17
|
constructor(initFromContext = false) {
|
|
14
18
|
// This is our psuedo feature flag for now
|
|
15
19
|
// This module can only be used when wrapped with
|
|
16
20
|
// the <RendererContext> component for now.
|
|
17
21
|
_defineProperty(this, "initFromContext", false);
|
|
18
|
-
_defineProperty(this, "debugAnalyticLoggingEnabled", false);
|
|
19
|
-
// TODO: EDITOR-595 - This method is temporary and should be removed once the following issue
|
|
20
|
-
// has been identified and fixed: https://atlassian.slack.com/archives/C08JK0WSCH5/p1745902609966999
|
|
21
|
-
// This is a copy of the original canApplyAnnotationOnRange. If that returns false this is run to figure out exactly why
|
|
22
|
-
// the annotation cannot be applied to the range.
|
|
23
|
-
_defineProperty(this, "_privateWhyCannotApplyAnnotationOnRange", (pos, doc, schema) => {
|
|
24
|
-
const {
|
|
25
|
-
from,
|
|
26
|
-
to
|
|
27
|
-
} = pos;
|
|
28
|
-
if (isNaN(from + to) || to - from <= 0 || to < 0 || from < 0) {
|
|
29
|
-
return 'position invalid';
|
|
30
|
-
}
|
|
31
|
-
const reasons = [];
|
|
32
|
-
doc.nodesBetween(from, to, (node, _pos, parent) => {
|
|
33
|
-
// Special exception for hardBreak nodes
|
|
34
|
-
if (schema.nodes.hardBreak === node.type) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// For block elements or text nodes, we want to check
|
|
39
|
-
// if annotations are allowed inside this tree
|
|
40
|
-
// or if we're leaf and not text
|
|
41
|
-
if (fg('editor_inline_comments_on_inline_nodes')) {
|
|
42
|
-
const isAllowedInlineNode = ['emoji', 'status', 'date', 'mention', 'inlineCard'].includes(node.type.name);
|
|
43
|
-
if (node.isInline && !node.isText && !isAllowedInlineNode) {
|
|
44
|
-
reasons.push(`Err 1 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}`);
|
|
45
|
-
return false;
|
|
46
|
-
} else if (node.isLeaf && !node.isText && !isAllowedInlineNode) {
|
|
47
|
-
reasons.push(`Err 2 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}`);
|
|
48
|
-
return false;
|
|
49
|
-
} else if (node.isText && !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(schema.marks.annotation))) {
|
|
50
|
-
reasons.push(`Err 3 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}, parent: ${parent === null || parent === void 0 ? void 0 : parent.type.name}`);
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
} else {
|
|
54
|
-
if (node.isInline && !node.isText) {
|
|
55
|
-
reasons.push(`Err 4 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}`);
|
|
56
|
-
return false;
|
|
57
|
-
} else if (node.isLeaf && !node.isText) {
|
|
58
|
-
reasons.push(`Err 5 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}`);
|
|
59
|
-
return false;
|
|
60
|
-
} else if (node.isText && !(parent !== null && parent !== void 0 && parent.type.allowsMarkType(schema.marks.annotation))) {
|
|
61
|
-
reasons.push(`Err 6 - type: ${node.type.name}, isInline: ${node.isInline}, isText: ${node.isText}, isLeaf: ${node.isLeaf}, parent: ${parent === null || parent === void 0 ? void 0 : parent.type.name}`);
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return true;
|
|
66
|
-
});
|
|
67
|
-
return reasons.join(', ');
|
|
68
|
-
});
|
|
69
22
|
this.initFromContext = initFromContext;
|
|
70
23
|
this.transformer = new JSONTransformer();
|
|
71
24
|
}
|
|
@@ -94,76 +47,19 @@ export default class RendererActions {
|
|
|
94
47
|
*/
|
|
95
48
|
_privateValidatePositionsForAnnotation(from, to) {
|
|
96
49
|
if (!this.doc || !this.schema) {
|
|
97
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
98
|
-
this.onAnalyticsEvent({
|
|
99
|
-
// @ts-ignore
|
|
100
|
-
action: 'failed',
|
|
101
|
-
// @ts-ignore
|
|
102
|
-
actionSubject: 'applyAnnotation',
|
|
103
|
-
// @ts-ignore
|
|
104
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
105
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
106
|
-
attributes: {
|
|
107
|
-
// @ts-ignore
|
|
108
|
-
reason: `Annotation Position validation failed - Missing doc or schema`,
|
|
109
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes'),
|
|
110
|
-
isDocValid: !!this.doc,
|
|
111
|
-
isSchemaValid: !!this.schema
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
50
|
return false;
|
|
116
51
|
}
|
|
117
52
|
const currentSelection = TextSelection.create(this.doc, from, to);
|
|
118
53
|
if (isEmptyTextSelection(currentSelection, this.schema)) {
|
|
119
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
120
|
-
this.onAnalyticsEvent({
|
|
121
|
-
// @ts-ignore
|
|
122
|
-
action: 'failed',
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
actionSubject: 'applyAnnotation',
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
127
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
128
|
-
attributes: {
|
|
129
|
-
// @ts-ignore
|
|
130
|
-
reason: `Annotation Position validation - Empty Text Selection`,
|
|
131
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes'),
|
|
132
|
-
from,
|
|
133
|
-
to
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
54
|
return false;
|
|
138
55
|
}
|
|
139
56
|
const result = canApplyAnnotationOnRange({
|
|
140
57
|
from,
|
|
141
58
|
to
|
|
142
59
|
}, this.doc, this.schema);
|
|
143
|
-
if (this.debugAnalyticLoggingEnabled && !result && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
144
|
-
this.onAnalyticsEvent({
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
action: 'failed',
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
actionSubject: 'applyAnnotation',
|
|
149
|
-
// @ts-ignore
|
|
150
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
151
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
152
|
-
attributes: {
|
|
153
|
-
// @ts-ignore
|
|
154
|
-
reason: `Annotation canApplyAnnotationOnRange failed`,
|
|
155
|
-
details: this._privateWhyCannotApplyAnnotationOnRange({
|
|
156
|
-
from,
|
|
157
|
-
to
|
|
158
|
-
}, this.doc, this.schema),
|
|
159
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes'),
|
|
160
|
-
from,
|
|
161
|
-
to
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
60
|
return result;
|
|
166
61
|
}
|
|
62
|
+
|
|
167
63
|
//#endregion
|
|
168
64
|
|
|
169
65
|
deleteAnnotation(annotationId, annotationType) {
|
|
@@ -314,24 +210,6 @@ export default class RendererActions {
|
|
|
314
210
|
}
|
|
315
211
|
isValidAnnotationPosition(pos) {
|
|
316
212
|
if (!pos || !this.doc) {
|
|
317
|
-
if (this.debugAnalyticLoggingEnabled && this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
318
|
-
this.onAnalyticsEvent({
|
|
319
|
-
// @ts-ignore
|
|
320
|
-
action: 'failed',
|
|
321
|
-
// @ts-ignore
|
|
322
|
-
actionSubject: 'applyAnnotation',
|
|
323
|
-
// @ts-ignore
|
|
324
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
325
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
326
|
-
attributes: {
|
|
327
|
-
// @ts-ignore
|
|
328
|
-
reason: `Annotation Position validation failed - Missing doc or position`,
|
|
329
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes'),
|
|
330
|
-
isPosValid: !!pos,
|
|
331
|
-
isDocValid: !!this.doc
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
213
|
return false;
|
|
336
214
|
}
|
|
337
215
|
return this._privateValidatePositionsForAnnotation(pos.from, pos.to);
|
|
@@ -389,25 +267,6 @@ export default class RendererActions {
|
|
|
389
267
|
}
|
|
390
268
|
applyAnnotation(pos, annotation) {
|
|
391
269
|
if (!this.doc || !pos || !this.schema) {
|
|
392
|
-
if (this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
393
|
-
this.onAnalyticsEvent({
|
|
394
|
-
// @ts-ignore
|
|
395
|
-
action: 'failed',
|
|
396
|
-
// @ts-ignore
|
|
397
|
-
actionSubject: 'applyAnnotation',
|
|
398
|
-
// @ts-ignore
|
|
399
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
400
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
401
|
-
attributes: {
|
|
402
|
-
// @ts-ignore
|
|
403
|
-
reason: `Annotation applyAnnotation failed - Missing doc, position or schema`,
|
|
404
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes'),
|
|
405
|
-
isPosValid: !!pos,
|
|
406
|
-
isDocValid: !!this.doc,
|
|
407
|
-
isSchemaValid: !!this.schema
|
|
408
|
-
}
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
270
|
return false;
|
|
412
271
|
}
|
|
413
272
|
const {
|
|
@@ -446,22 +305,6 @@ export default class RendererActions {
|
|
|
446
305
|
failed
|
|
447
306
|
} = step.apply(this.doc);
|
|
448
307
|
if (failed || !doc) {
|
|
449
|
-
if (this.onAnalyticsEvent && fg('platform_renderer_annotations_create_debug_logging')) {
|
|
450
|
-
this.onAnalyticsEvent({
|
|
451
|
-
// @ts-ignore
|
|
452
|
-
action: 'failed',
|
|
453
|
-
// @ts-ignore
|
|
454
|
-
actionSubject: 'applyAnnotation',
|
|
455
|
-
// @ts-ignore
|
|
456
|
-
actionSubjectId: 'inlineCommentFailureReason',
|
|
457
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
458
|
-
attributes: {
|
|
459
|
-
// @ts-ignore
|
|
460
|
-
reason: `Annotation applyAnnotation failed - ${failed}`,
|
|
461
|
-
commentsOnInlineNodesAllowed: fg('editor_inline_comments_on_inline_nodes')
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
}
|
|
465
308
|
return false;
|
|
466
309
|
}
|
|
467
310
|
const originalSelection = doc.textBetween(from, to);
|
|
@@ -523,11 +366,4 @@ export default class RendererActions {
|
|
|
523
366
|
schema: this.schema
|
|
524
367
|
}, annotationId);
|
|
525
368
|
}
|
|
526
|
-
|
|
527
|
-
/**
|
|
528
|
-
* This is a temporary method used for controlling when extra analytics shoulw be logged.
|
|
529
|
-
*/
|
|
530
|
-
_setDebugLogging(enabled) {
|
|
531
|
-
this.debugAnalyticLoggingEnabled = enabled;
|
|
532
|
-
}
|
|
533
369
|
}
|