@atlaskit/renderer 113.3.0 → 114.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 +20 -0
- package/dist/cjs/ui/Renderer/index.js +7 -5
- package/dist/cjs/ui/Renderer/rendererHelper.js +59 -0
- package/dist/es2019/ui/Renderer/index.js +7 -5
- package/dist/es2019/ui/Renderer/rendererHelper.js +51 -0
- package/dist/esm/ui/Renderer/index.js +7 -5
- package/dist/esm/ui/Renderer/rendererHelper.js +52 -0
- package/dist/types/ui/Renderer/index.d.ts +1 -0
- package/dist/types/ui/Renderer/rendererHelper.d.ts +2 -0
- package/dist/types/ui/renderer-props.d.ts +1 -0
- package/dist/types-ts4.5/ui/Renderer/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/Renderer/rendererHelper.d.ts +2 -0
- package/dist/types-ts4.5/ui/renderer-props.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 114.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#124272](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/124272)
|
|
8
|
+
[`5b434be943575`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5b434be943575) -
|
|
9
|
+
[ux] Added logic to not render empty text spaces around comment content
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 114.0.0
|
|
16
|
+
|
|
17
|
+
### Major Changes
|
|
18
|
+
|
|
19
|
+
- [#122089](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/122089)
|
|
20
|
+
[`f9eb90e04e1ec`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f9eb90e04e1ec) -
|
|
21
|
+
[ux] Adding new prop in comments renderer to remove empty space around comment content
|
|
22
|
+
|
|
3
23
|
## 113.3.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -53,6 +53,7 @@ var _truncatedWrapper = require("./truncated-wrapper");
|
|
|
53
53
|
var _ValidationContext = require("./ValidationContext");
|
|
54
54
|
var _RendererStyleContainer = require("./RendererStyleContainer");
|
|
55
55
|
var _getBaseFontSize = require("./get-base-font-size");
|
|
56
|
+
var _rendererHelper = require("./rendererHelper");
|
|
56
57
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
57
58
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
58
59
|
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; }
|
|
@@ -66,7 +67,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
66
67
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
67
68
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
68
69
|
var packageName = "@atlaskit/renderer";
|
|
69
|
-
var packageVersion = "
|
|
70
|
+
var packageVersion = "114.1.0";
|
|
70
71
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
71
72
|
containerName: 'ak-renderer-wrapper',
|
|
72
73
|
containerType: 'inline-size',
|
|
@@ -389,7 +390,7 @@ var __RendererClassComponent = exports.__RendererClassComponent = /*#__PURE__*/f
|
|
|
389
390
|
try {
|
|
390
391
|
var _rendererContext$feat;
|
|
391
392
|
var schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
392
|
-
var _renderDocument = (0, _.renderDocument)(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
|
|
393
|
+
var _renderDocument = (0, _.renderDocument)(this.props.shouldRemoveEmptySpaceAroundContent ? (0, _rendererHelper.removeEmptySpaceAroundContent)(adfDocument) : adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
|
|
393
394
|
result = _renderDocument.result,
|
|
394
395
|
stat = _renderDocument.stat,
|
|
395
396
|
pmDoc = _renderDocument.pmDoc;
|
|
@@ -613,7 +614,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
613
614
|
extensionHandlers: props.extensionHandlers,
|
|
614
615
|
portal: props.portal,
|
|
615
616
|
objectContext: _objectSpread({
|
|
616
|
-
adDoc: props.document,
|
|
617
|
+
adDoc: props.shouldRemoveEmptySpaceAroundContent ? (0, _rendererHelper.removeEmptySpaceAroundContent)(props.document) : props.document,
|
|
617
618
|
schema: props.schema
|
|
618
619
|
}, props.rendererContext),
|
|
619
620
|
appearance: props.appearance,
|
|
@@ -761,7 +762,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
761
762
|
try {
|
|
762
763
|
var _createRendererContex2, _props$media;
|
|
763
764
|
var schema = getSchema(props.schema, props.adfStage);
|
|
764
|
-
var _renderDocument2 = (0, _.renderDocument)(props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
|
|
765
|
+
var _renderDocument2 = (0, _.renderDocument)(props.shouldRemoveEmptySpaceAroundContent ? (0, _rendererHelper.removeEmptySpaceAroundContent)(props.document) : props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
|
|
765
766
|
result = _renderDocument2.result,
|
|
766
767
|
stat = _renderDocument2.stat,
|
|
767
768
|
pmDoc = _renderDocument2.pmDoc;
|
|
@@ -798,7 +799,8 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
798
799
|
onMouseDown: onMouseDownEditView,
|
|
799
800
|
ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
|
|
800
801
|
isInsideOfInlineExtension: props.isInsideOfInlineExtension,
|
|
801
|
-
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer
|
|
802
|
+
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer,
|
|
803
|
+
shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
|
|
802
804
|
}, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? (0, _react2.jsx)(_breakoutSsr.BreakoutSSRInlineScript, {
|
|
803
805
|
noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
|
|
804
806
|
}) : null, (0, _react2.jsx)(RendererActionsInternalUpdater, {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.removeEmptySpaceAroundContent = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
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; }
|
|
10
|
+
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; }
|
|
11
|
+
var removeEmptySpaceAroundContent = exports.removeEmptySpaceAroundContent = function removeEmptySpaceAroundContent(document) {
|
|
12
|
+
// Check if the document is valid
|
|
13
|
+
if (!document || !document.content || !Array.isArray(document.content)) {
|
|
14
|
+
return document;
|
|
15
|
+
}
|
|
16
|
+
var isParagraphWithContent = function isParagraphWithContent(node) {
|
|
17
|
+
if (node.type !== 'paragraph' || !node.content || node.content.length === 0) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
// Check if paragraph has any content other than `hardBreak` or whitespace text nodes
|
|
21
|
+
return node.content.some(function (child) {
|
|
22
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'hardBreak') {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'text' && typeof child.text === 'string' && child.text.trim() === '') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return true;
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
var content = document.content;
|
|
32
|
+
var firstContentIndex = -1;
|
|
33
|
+
var lastContentIndex = -1;
|
|
34
|
+
|
|
35
|
+
// Find the first and last paragraphs with content
|
|
36
|
+
for (var i = 0; i < content.length; i++) {
|
|
37
|
+
if (isParagraphWithContent(content[i])) {
|
|
38
|
+
if (firstContentIndex === -1) {
|
|
39
|
+
firstContentIndex = i;
|
|
40
|
+
}
|
|
41
|
+
lastContentIndex = i;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// If no content was found, return an empty document
|
|
46
|
+
if (firstContentIndex === -1) {
|
|
47
|
+
return _objectSpread(_objectSpread({}, document), {}, {
|
|
48
|
+
content: []
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Slice the content array to include only paragraphs between the first and last content
|
|
53
|
+
var trimmedContent = content.slice(firstContentIndex, lastContentIndex + 1);
|
|
54
|
+
|
|
55
|
+
// Return a new document with the trimmed content
|
|
56
|
+
return _objectSpread(_objectSpread({}, document), {}, {
|
|
57
|
+
content: trimmedContent
|
|
58
|
+
});
|
|
59
|
+
};
|
|
@@ -44,10 +44,11 @@ import { TruncatedWrapper } from './truncated-wrapper';
|
|
|
44
44
|
import { ValidationContext } from './ValidationContext';
|
|
45
45
|
import { RendererStyleContainer } from './RendererStyleContainer';
|
|
46
46
|
import { getBaseFontSize } from './get-base-font-size';
|
|
47
|
+
import { removeEmptySpaceAroundContent } from './rendererHelper';
|
|
47
48
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
48
49
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
49
50
|
const packageName = "@atlaskit/renderer";
|
|
50
|
-
const packageVersion = "
|
|
51
|
+
const packageVersion = "114.1.0";
|
|
51
52
|
const setAsQueryContainerStyles = css({
|
|
52
53
|
containerName: 'ak-renderer-wrapper',
|
|
53
54
|
containerType: 'inline-size',
|
|
@@ -371,7 +372,7 @@ export class __RendererClassComponent extends PureComponent {
|
|
|
371
372
|
result,
|
|
372
373
|
stat,
|
|
373
374
|
pmDoc
|
|
374
|
-
} = renderDocument(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation);
|
|
375
|
+
} = renderDocument(this.props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(adfDocument) : adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation);
|
|
375
376
|
if (onComplete) {
|
|
376
377
|
onComplete(stat);
|
|
377
378
|
}
|
|
@@ -592,7 +593,7 @@ const RendererFunctionalComponent = props => {
|
|
|
592
593
|
extensionHandlers: props.extensionHandlers,
|
|
593
594
|
portal: props.portal,
|
|
594
595
|
objectContext: {
|
|
595
|
-
adDoc: props.document,
|
|
596
|
+
adDoc: props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document,
|
|
596
597
|
schema: props.schema,
|
|
597
598
|
...props.rendererContext
|
|
598
599
|
},
|
|
@@ -744,7 +745,7 @@ const RendererFunctionalComponent = props => {
|
|
|
744
745
|
result,
|
|
745
746
|
stat,
|
|
746
747
|
pmDoc
|
|
747
|
-
} = renderDocument(props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation);
|
|
748
|
+
} = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation);
|
|
748
749
|
if (props.onComplete) {
|
|
749
750
|
props.onComplete(stat);
|
|
750
751
|
}
|
|
@@ -774,7 +775,8 @@ const RendererFunctionalComponent = props => {
|
|
|
774
775
|
onMouseDown: onMouseDownEditView,
|
|
775
776
|
ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
|
|
776
777
|
isInsideOfInlineExtension: props.isInsideOfInlineExtension,
|
|
777
|
-
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer
|
|
778
|
+
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer,
|
|
779
|
+
shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
|
|
778
780
|
}, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? jsx(BreakoutSSRInlineScript, {
|
|
779
781
|
noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
|
|
780
782
|
}) : null, jsx(RendererActionsInternalUpdater, {
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export const removeEmptySpaceAroundContent = document => {
|
|
2
|
+
// Check if the document is valid
|
|
3
|
+
if (!document || !document.content || !Array.isArray(document.content)) {
|
|
4
|
+
return document;
|
|
5
|
+
}
|
|
6
|
+
const isParagraphWithContent = node => {
|
|
7
|
+
if (node.type !== 'paragraph' || !node.content || node.content.length === 0) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
// Check if paragraph has any content other than `hardBreak` or whitespace text nodes
|
|
11
|
+
return node.content.some(child => {
|
|
12
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'hardBreak') {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'text' && typeof child.text === 'string' && child.text.trim() === '') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
const content = document.content;
|
|
22
|
+
let firstContentIndex = -1;
|
|
23
|
+
let lastContentIndex = -1;
|
|
24
|
+
|
|
25
|
+
// Find the first and last paragraphs with content
|
|
26
|
+
for (let i = 0; i < content.length; i++) {
|
|
27
|
+
if (isParagraphWithContent(content[i])) {
|
|
28
|
+
if (firstContentIndex === -1) {
|
|
29
|
+
firstContentIndex = i;
|
|
30
|
+
}
|
|
31
|
+
lastContentIndex = i;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If no content was found, return an empty document
|
|
36
|
+
if (firstContentIndex === -1) {
|
|
37
|
+
return {
|
|
38
|
+
...document,
|
|
39
|
+
content: []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Slice the content array to include only paragraphs between the first and last content
|
|
44
|
+
const trimmedContent = content.slice(firstContentIndex, lastContentIndex + 1);
|
|
45
|
+
|
|
46
|
+
// Return a new document with the trimmed content
|
|
47
|
+
return {
|
|
48
|
+
...document,
|
|
49
|
+
content: trimmedContent
|
|
50
|
+
};
|
|
51
|
+
};
|
|
@@ -53,10 +53,11 @@ import { TruncatedWrapper } from './truncated-wrapper';
|
|
|
53
53
|
import { ValidationContext } from './ValidationContext';
|
|
54
54
|
import { RendererStyleContainer } from './RendererStyleContainer';
|
|
55
55
|
import { getBaseFontSize } from './get-base-font-size';
|
|
56
|
+
import { removeEmptySpaceAroundContent } from './rendererHelper';
|
|
56
57
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
57
58
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
58
59
|
var packageName = "@atlaskit/renderer";
|
|
59
|
-
var packageVersion = "
|
|
60
|
+
var packageVersion = "114.1.0";
|
|
60
61
|
var setAsQueryContainerStyles = css({
|
|
61
62
|
containerName: 'ak-renderer-wrapper',
|
|
62
63
|
containerType: 'inline-size',
|
|
@@ -379,7 +380,7 @@ export var __RendererClassComponent = /*#__PURE__*/function (_PureComponent) {
|
|
|
379
380
|
try {
|
|
380
381
|
var _rendererContext$feat;
|
|
381
382
|
var schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
382
|
-
var _renderDocument = renderDocument(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
|
|
383
|
+
var _renderDocument = renderDocument(this.props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(adfDocument) : adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance, this.props.includeNodesCountInStats, skipValidation),
|
|
383
384
|
result = _renderDocument.result,
|
|
384
385
|
stat = _renderDocument.stat,
|
|
385
386
|
pmDoc = _renderDocument.pmDoc;
|
|
@@ -603,7 +604,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
603
604
|
extensionHandlers: props.extensionHandlers,
|
|
604
605
|
portal: props.portal,
|
|
605
606
|
objectContext: _objectSpread({
|
|
606
|
-
adDoc: props.document,
|
|
607
|
+
adDoc: props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document,
|
|
607
608
|
schema: props.schema
|
|
608
609
|
}, props.rendererContext),
|
|
609
610
|
appearance: props.appearance,
|
|
@@ -751,7 +752,7 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
751
752
|
try {
|
|
752
753
|
var _createRendererContex2, _props$media;
|
|
753
754
|
var schema = getSchema(props.schema, props.adfStage);
|
|
754
|
-
var _renderDocument2 = renderDocument(props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
|
|
755
|
+
var _renderDocument2 = renderDocument(props.shouldRemoveEmptySpaceAroundContent ? removeEmptySpaceAroundContent(props.document) : props.document, serializer, schema, props.adfStage, props.useSpecBasedValidator, id, _fireAnalyticsEvent, props.unsupportedContentLevelsTracking, props.appearance, props.includeNodesCountInStats, props.skipValidation),
|
|
755
756
|
result = _renderDocument2.result,
|
|
756
757
|
stat = _renderDocument2.stat,
|
|
757
758
|
pmDoc = _renderDocument2.pmDoc;
|
|
@@ -788,7 +789,8 @@ var RendererFunctionalComponent = function RendererFunctionalComponent(props) {
|
|
|
788
789
|
onMouseDown: onMouseDownEditView,
|
|
789
790
|
ssr: (_props$media = props.media) === null || _props$media === void 0 ? void 0 : _props$media.ssr,
|
|
790
791
|
isInsideOfInlineExtension: props.isInsideOfInlineExtension,
|
|
791
|
-
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer
|
|
792
|
+
isTopLevelRenderer: createRendererContext(props.featureFlags, props.isTopLevelRenderer).isTopLevelRenderer,
|
|
793
|
+
shouldRemoveEmptySpaceAroundContent: props.shouldRemoveEmptySpaceAroundContent
|
|
792
794
|
}, props.enableSsrInlineScripts || props.noOpSSRInlineScript ? jsx(BreakoutSSRInlineScript, {
|
|
793
795
|
noOpSSRInlineScript: Boolean(props.noOpSSRInlineScript)
|
|
794
796
|
}) : null, jsx(RendererActionsInternalUpdater, {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
export var removeEmptySpaceAroundContent = function removeEmptySpaceAroundContent(document) {
|
|
5
|
+
// Check if the document is valid
|
|
6
|
+
if (!document || !document.content || !Array.isArray(document.content)) {
|
|
7
|
+
return document;
|
|
8
|
+
}
|
|
9
|
+
var isParagraphWithContent = function isParagraphWithContent(node) {
|
|
10
|
+
if (node.type !== 'paragraph' || !node.content || node.content.length === 0) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
// Check if paragraph has any content other than `hardBreak` or whitespace text nodes
|
|
14
|
+
return node.content.some(function (child) {
|
|
15
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'hardBreak') {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if ((child === null || child === void 0 ? void 0 : child.type) === 'text' && typeof child.text === 'string' && child.text.trim() === '') {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
var content = document.content;
|
|
25
|
+
var firstContentIndex = -1;
|
|
26
|
+
var lastContentIndex = -1;
|
|
27
|
+
|
|
28
|
+
// Find the first and last paragraphs with content
|
|
29
|
+
for (var i = 0; i < content.length; i++) {
|
|
30
|
+
if (isParagraphWithContent(content[i])) {
|
|
31
|
+
if (firstContentIndex === -1) {
|
|
32
|
+
firstContentIndex = i;
|
|
33
|
+
}
|
|
34
|
+
lastContentIndex = i;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// If no content was found, return an empty document
|
|
39
|
+
if (firstContentIndex === -1) {
|
|
40
|
+
return _objectSpread(_objectSpread({}, document), {}, {
|
|
41
|
+
content: []
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Slice the content array to include only paragraphs between the first and last content
|
|
46
|
+
var trimmedContent = content.slice(firstContentIndex, lastContentIndex + 1);
|
|
47
|
+
|
|
48
|
+
// Return a new document with the trimmed content
|
|
49
|
+
return _objectSpread(_objectSpread({}, document), {}, {
|
|
50
|
+
content: trimmedContent
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -68,6 +68,7 @@ export interface RendererProps {
|
|
|
68
68
|
isInsideOfInlineExtension?: boolean;
|
|
69
69
|
isTopLevelRenderer?: boolean;
|
|
70
70
|
includeNodesCountInStats?: boolean;
|
|
71
|
+
shouldRemoveEmptySpaceAroundContent?: boolean;
|
|
71
72
|
/**
|
|
72
73
|
* When enabled a trailing telepointer will be added to the rendered document
|
|
73
74
|
* following content updates.
|
|
@@ -68,6 +68,7 @@ export interface RendererProps {
|
|
|
68
68
|
isInsideOfInlineExtension?: boolean;
|
|
69
69
|
isTopLevelRenderer?: boolean;
|
|
70
70
|
includeNodesCountInStats?: boolean;
|
|
71
|
+
shouldRemoveEmptySpaceAroundContent?: boolean;
|
|
71
72
|
/**
|
|
72
73
|
* When enabled a trailing telepointer will be added to the rendered document
|
|
73
74
|
* following content updates.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "114.1.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/task-decision": "^19.0.0",
|
|
55
55
|
"@atlaskit/theme": "^18.0.0",
|
|
56
56
|
"@atlaskit/tmp-editor-statsig": "^3.5.0",
|
|
57
|
-
"@atlaskit/tokens": "^4.
|
|
57
|
+
"@atlaskit/tokens": "^4.4.0",
|
|
58
58
|
"@atlaskit/tooltip": "^20.0.0",
|
|
59
59
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
60
60
|
"@babel/runtime": "^7.0.0",
|