@atlaskit/renderer 124.1.0 → 124.1.1
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 +8 -0
- package/dist/cjs/react/index.js +12 -1
- package/dist/cjs/react/marks/backgroundColor.js +17 -0
- package/dist/cjs/react/nodes/heading-anchor.js +3 -1
- package/dist/cjs/react/nodes/table.js +1 -1
- package/dist/cjs/react/utils/getStandaloneBackgroundColorMarks.js +81 -0
- package/dist/cjs/render-document.js +2 -2
- package/dist/cjs/ui/Renderer/RendererStyleContainer.js +19 -2
- package/dist/es2019/react/index.js +10 -1
- package/dist/es2019/react/marks/backgroundColor.js +17 -0
- package/dist/es2019/react/nodes/heading-anchor.js +3 -1
- package/dist/es2019/react/nodes/table.js +1 -1
- package/dist/es2019/react/utils/getStandaloneBackgroundColorMarks.js +68 -0
- package/dist/es2019/render-document.js +2 -8
- package/dist/es2019/ui/Renderer/RendererStyleContainer.js +18 -1
- package/dist/esm/react/index.js +12 -1
- package/dist/esm/react/marks/backgroundColor.js +17 -0
- package/dist/esm/react/nodes/heading-anchor.js +3 -1
- package/dist/esm/react/nodes/table.js +1 -1
- package/dist/esm/react/utils/getStandaloneBackgroundColorMarks.js +74 -0
- package/dist/esm/render-document.js +2 -2
- package/dist/esm/ui/Renderer/RendererStyleContainer.js +18 -1
- package/dist/types/react/index.d.ts +1 -0
- package/dist/types/react/utils/getStandaloneBackgroundColorMarks.d.ts +12 -0
- package/dist/types/ui/Renderer/RendererStyleContainer.d.ts +1 -0
- package/dist/types-ts4.5/react/index.d.ts +1 -0
- package/dist/types-ts4.5/react/utils/getStandaloneBackgroundColorMarks.d.ts +12 -0
- package/dist/types-ts4.5/ui/Renderer/RendererStyleContainer.d.ts +1 -0
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 124.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`bf06894c2fcd4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bf06894c2fcd4) -
|
|
8
|
+
[ux] in renderer, add text highlight padding
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 124.1.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
package/dist/cjs/react/index.js
CHANGED
|
@@ -28,6 +28,7 @@ var _code = require("./marks/code");
|
|
|
28
28
|
var _rendererNode = require("./renderer-node");
|
|
29
29
|
var _renderTextSegments = require("./utils/render-text-segments");
|
|
30
30
|
var _segmentText = require("./utils/segment-text");
|
|
31
|
+
var _getStandaloneBackgroundColorMarks = require("./utils/getStandaloneBackgroundColorMarks");
|
|
31
32
|
var _excluded = ["key"];
|
|
32
33
|
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; }
|
|
33
34
|
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; }
|
|
@@ -62,6 +63,7 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
62
63
|
(0, _defineProperty2.default)(this, "allowCustomPanels", false);
|
|
63
64
|
(0, _defineProperty2.default)(this, "surroundTextNodesWithTextWrapper", false);
|
|
64
65
|
(0, _defineProperty2.default)(this, "allowAnnotations", false);
|
|
66
|
+
(0, _defineProperty2.default)(this, "standaloneBackgroundColorMarks", []);
|
|
65
67
|
(0, _defineProperty2.default)(this, "serializeFragmentChild", function (node, _ref) {
|
|
66
68
|
var index = _ref.index,
|
|
67
69
|
parentInfo = _ref.parentInfo;
|
|
@@ -301,6 +303,10 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
301
303
|
parentInfo = _ref2.parentInfo;
|
|
302
304
|
var currentPath = parentInfo && parentInfo.path || [];
|
|
303
305
|
var nodePosition = parentInfo && parentInfo.pos || 1;
|
|
306
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
307
|
+
var _this$standaloneBackg;
|
|
308
|
+
(_this$standaloneBackg = this.standaloneBackgroundColorMarks).push.apply(_this$standaloneBackg, (0, _toConsumableArray2.default)((0, _getStandaloneBackgroundColorMarks.getStandaloneBackgroundColorMarks)(content)));
|
|
309
|
+
}
|
|
304
310
|
return ReactSerializer.buildMarkStructure(content).map(function (mark, index) {
|
|
305
311
|
return _this3.serializeMark({
|
|
306
312
|
mark: mark,
|
|
@@ -336,7 +342,12 @@ var ReactSerializer = exports.default = /*#__PURE__*/function () {
|
|
|
336
342
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
337
343
|
var content = (mark.content || []).map(serializeContent);
|
|
338
344
|
var markKey = "".concat(mark.type.name, "-component__").concat(this.startPos, "__").concat(parentMark.path.length);
|
|
339
|
-
|
|
345
|
+
var isStandalone = (0, _expValEquals.expValEquals)('platform_editor_text_highlight_padding', 'isEnabled', true) && this.standaloneBackgroundColorMarks.some(function (m) {
|
|
346
|
+
return mark.eq(m);
|
|
347
|
+
});
|
|
348
|
+
return this.renderMark((0, _marks.toReact)(mark), _objectSpread(_objectSpread({}, this.getMarkProps(mark, parentMark.path)), {}, {
|
|
349
|
+
isStandalone: isStandalone
|
|
350
|
+
}), markKey, content);
|
|
340
351
|
}
|
|
341
352
|
var startPos = this.startPos;
|
|
342
353
|
var endPos = startPos + mark.nodeSize;
|
|
@@ -12,6 +12,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
12
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
13
|
var _editorPalette = require("@atlaskit/editor-palette");
|
|
14
14
|
var _tokens = require("@atlaskit/tokens");
|
|
15
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
15
16
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
16
17
|
function BackgroundColor(props) {
|
|
17
18
|
var _useThemeObserver = (0, _tokens.useThemeObserver)(),
|
|
@@ -49,6 +50,22 @@ function BackgroundColor(props) {
|
|
|
49
50
|
var style = (0, _react.useMemo)(function () {
|
|
50
51
|
return (0, _defineProperty2.default)({}, '--custom-palette-color', paletteColorValue);
|
|
51
52
|
}, [paletteColorValue]);
|
|
53
|
+
if (props.isStandalone && (0, _expValEquals.expValEquals)('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
55
|
+
"data-block-mark": props.dataAttributes['data-block-mark'],
|
|
56
|
+
"data-renderer-mark": props.dataAttributes['data-renderer-mark'],
|
|
57
|
+
"data-background-custom-color": props.color
|
|
58
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
59
|
+
,
|
|
60
|
+
className: "fabric-background-color-mark"
|
|
61
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
62
|
+
,
|
|
63
|
+
style: style
|
|
64
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
65
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
66
|
+
className: "background-color-padding-left background-color-padding-right"
|
|
67
|
+
}, props.children));
|
|
68
|
+
}
|
|
52
69
|
return /*#__PURE__*/_react.default.createElement("span", (0, _extends2.default)({}, props.dataAttributes, {
|
|
53
70
|
"data-background-custom-color": props.color
|
|
54
71
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -113,7 +113,9 @@ var HeadingAnchor = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
113
113
|
headingId = _this$props.headingId;
|
|
114
114
|
return (0, _react2.jsx)("button", {
|
|
115
115
|
"data-testid": "anchor-button",
|
|
116
|
-
css: copyAnchorButtonStyles
|
|
116
|
+
css: copyAnchorButtonStyles
|
|
117
|
+
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
118
|
+
,
|
|
117
119
|
onMouseLeave: _this.resetMessage,
|
|
118
120
|
onClick: _this.copyToClipboard,
|
|
119
121
|
"aria-hidden": hideFromScreenReader,
|
|
@@ -153,7 +153,7 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
153
153
|
ref: wrapperRef,
|
|
154
154
|
onScroll: stickyHeaders ? onScroll : undefined
|
|
155
155
|
// Adding tabIndex here because this is a scrollable container and it needs to be focusable so keyboard users can scroll it.
|
|
156
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
156
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex, @atlassian/a11y/no-noninteractive-tabindex
|
|
157
157
|
,
|
|
158
158
|
tabIndex: 0,
|
|
159
159
|
role: "region",
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getStandaloneBackgroundColorMarks = void 0;
|
|
8
|
+
var _ = _interopRequireDefault(require(".."));
|
|
9
|
+
/**
|
|
10
|
+
* Returns an array of **backgroundColor marks** that should be considered "standalone"
|
|
11
|
+
* for highlight padding purposes.
|
|
12
|
+
*
|
|
13
|
+
* Standalone backgroundColor marks are determined by scanning the content array and
|
|
14
|
+
* checking for backgroundColor marks that are separated by whitespace boundaries.
|
|
15
|
+
*
|
|
16
|
+
* @param content Array of ProseMirror nodes to scan for standalone backgroundColor marks.
|
|
17
|
+
* @returns Array of backgroundColor marks that are standalone.
|
|
18
|
+
*/
|
|
19
|
+
var getStandaloneBackgroundColorMarks = exports.getStandaloneBackgroundColorMarks = function getStandaloneBackgroundColorMarks(content) {
|
|
20
|
+
var standaloneMarks = [];
|
|
21
|
+
// keep track of the previous node's state
|
|
22
|
+
var prev = {
|
|
23
|
+
selfSpaceOnTheRight: true // initial value to handle leading BackgroundColor
|
|
24
|
+
};
|
|
25
|
+
var prevNode = null;
|
|
26
|
+
// Iterates through each node in the content array.
|
|
27
|
+
// Tracks if the previous node had a backgroundColor mark and if it ended with a space.
|
|
28
|
+
// If a backgroundColor mark is followed by a text node that starts with a space,
|
|
29
|
+
// and the previous node ended with a space, the previous backgroundColor mark is considered standalone.
|
|
30
|
+
// At the end, flushes any remaining node that meets the standalone criteria.
|
|
31
|
+
for (var i = 0; i < content.length; i++) {
|
|
32
|
+
var node = content[i];
|
|
33
|
+
var nodeMarks = _.default.getMarks(node);
|
|
34
|
+
var isBackgroundColor = nodeMarks.some(function (m) {
|
|
35
|
+
return m.type.name === 'backgroundColor';
|
|
36
|
+
});
|
|
37
|
+
var selfSpaceOnTheLeft = false;
|
|
38
|
+
var selfSpaceOnTheRight = false;
|
|
39
|
+
if (node.text) {
|
|
40
|
+
selfSpaceOnTheLeft = node.text.startsWith(' ');
|
|
41
|
+
selfSpaceOnTheRight = node.text.endsWith(' ');
|
|
42
|
+
}
|
|
43
|
+
if (isBackgroundColor) {
|
|
44
|
+
prevNode = node;
|
|
45
|
+
prev = {
|
|
46
|
+
selfSpaceOnTheRight: false,
|
|
47
|
+
hasBackgroundColor: true,
|
|
48
|
+
spaceToTheLeft: prev !== null && prev.selfSpaceOnTheRight
|
|
49
|
+
};
|
|
50
|
+
} else {
|
|
51
|
+
// If prev exists, check for standalone logic
|
|
52
|
+
if (prev && prev.hasBackgroundColor && prevNode) {
|
|
53
|
+
// If prev had space on the left and current is a TextNode and has space on the left
|
|
54
|
+
if (prev.spaceToTheLeft && selfSpaceOnTheLeft) {
|
|
55
|
+
var mark = _.default.getMarks(prevNode).find(function (m) {
|
|
56
|
+
return m.type.name === 'backgroundColor';
|
|
57
|
+
});
|
|
58
|
+
if (mark) {
|
|
59
|
+
standaloneMarks.push(mark);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
prevNode = null;
|
|
64
|
+
prev = {
|
|
65
|
+
selfSpaceOnTheRight: selfSpaceOnTheRight,
|
|
66
|
+
hasBackgroundColor: false
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (prevNode) {
|
|
71
|
+
if (prev && prev.hasBackgroundColor && prev.spaceToTheLeft) {
|
|
72
|
+
var _mark = _.default.getMarks(prevNode).find(function (m) {
|
|
73
|
+
return m.type.name === 'backgroundColor';
|
|
74
|
+
});
|
|
75
|
+
if (_mark) {
|
|
76
|
+
standaloneMarks.push(_mark);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return standaloneMarks;
|
|
81
|
+
};
|
|
@@ -103,14 +103,14 @@ var memoValidation = (0, _memoizeOne.default)(_validation, function (newArgs, la
|
|
|
103
103
|
newSchema = _newArgs[1],
|
|
104
104
|
newADFStage = _newArgs[2],
|
|
105
105
|
newUseSpecValidator = _newArgs[3],
|
|
106
|
-
newSkipValidation = _newArgs[5],
|
|
106
|
+
/* ignoring dispatchAnalyticsEvent */newSkipValidation = _newArgs[5],
|
|
107
107
|
newValidationOverrides = _newArgs[6];
|
|
108
108
|
var _lastArgs = (0, _slicedToArray2.default)(lastArgs, 7),
|
|
109
109
|
oldDoc = _lastArgs[0],
|
|
110
110
|
oldSchema = _lastArgs[1],
|
|
111
111
|
oldADFStage = _lastArgs[2],
|
|
112
112
|
oldUseSpecValidator = _lastArgs[3],
|
|
113
|
-
oldSkipValidation = _lastArgs[5],
|
|
113
|
+
/* ignoring dispatchAnalyticsEvent */oldSkipValidation = _lastArgs[5],
|
|
114
114
|
oldValidationOverrides = _lastArgs[6];
|
|
115
115
|
return areDocsEqual(newDoc, oldDoc) && newSchema === oldSchema && newADFStage === oldADFStage && newUseSpecValidator === oldUseSpecValidator && newSkipValidation === oldSkipValidation && newValidationOverrides === oldValidationOverrides;
|
|
116
116
|
});
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.RendererStyleContainer = void 0;
|
|
7
|
+
exports.textHighlightPaddingStyles = exports.RendererStyleContainer = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _react = require("@emotion/react");
|
|
10
10
|
var _useScrollToLocalId = require("../hooks/useScrollToLocalId");
|
|
@@ -26,6 +26,7 @@ var _table2 = require("@atlaskit/editor-common/table");
|
|
|
26
26
|
var _lightWeightCodeBlock = require("../../react/nodes/codeBlock/components/lightWeightCodeBlock");
|
|
27
27
|
var _ugcTokens = require("@atlaskit/editor-common/ugc-tokens");
|
|
28
28
|
var _getBaseFontSize = require("./get-base-font-size");
|
|
29
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
29
30
|
var _css, _css8;
|
|
30
31
|
/* eslint-disable @atlaskit/ui-styling-standard/no-important-styles */
|
|
31
32
|
/* eslint-disable @atlaskit/ui-styling-standard/no-imported-style-values */
|
|
@@ -753,6 +754,20 @@ var backgroundColorStyles = (0, _react.css)({
|
|
|
753
754
|
backgroundColor: 'unset'
|
|
754
755
|
}
|
|
755
756
|
});
|
|
757
|
+
|
|
758
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
759
|
+
var textHighlightPaddingStyles = exports.textHighlightPaddingStyles = (0, _react.css)({
|
|
760
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
761
|
+
'.fabric-background-color-mark:has(.background-color-padding-left)': {
|
|
762
|
+
paddingLeft: "var(--ds-space-025, 2px)",
|
|
763
|
+
marginLeft: "var(--ds-space-negative-025, -2px)"
|
|
764
|
+
},
|
|
765
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
766
|
+
'.fabric-background-color-mark:has(.background-color-padding-right)': {
|
|
767
|
+
paddingRight: "var(--ds-space-025, 2px)",
|
|
768
|
+
marginRight: "var(--ds-space-negative-025, -2px)"
|
|
769
|
+
}
|
|
770
|
+
});
|
|
756
771
|
var tasksAndDecisionsStyles = (0, _react.css)({
|
|
757
772
|
'.ProseMirror': (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, ".taskItemView-content-wrap,\n\t\t.".concat(_styles.TaskDecisionSharedCssClassName.DECISION_CONTAINER), {
|
|
758
773
|
position: 'relative',
|
|
@@ -1505,7 +1520,9 @@ var RendererStyleContainer = exports.RendererStyleContainer = function RendererS
|
|
|
1505
1520
|
'--ak-renderer-editor-font-heading-h6': "".concat((0, _ugcTokens.editorUGCToken)('editor.font.heading.h6')),
|
|
1506
1521
|
'--ak-renderer-editor-font-normal-text': "".concat((0, _ugcTokens.editorUGCToken)('editor.font.body'))
|
|
1507
1522
|
},
|
|
1508
|
-
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !(0, _table.isTableResizingEnabled)(appearance) && rendererFullWidthStylesForTableResizing, !(0, _platformFeatureFlags.fg)('aifc_create_enabled') && telepointerStyles, (0, _platformFeatureFlags.fg)('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, _browser.browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles,
|
|
1523
|
+
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !(0, _table.isTableResizingEnabled)(appearance) && rendererFullWidthStylesForTableResizing, !(0, _platformFeatureFlags.fg)('aifc_create_enabled') && telepointerStyles, (0, _platformFeatureFlags.fg)('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, _browser.browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, (0, _platformFeatureFlags.fg)('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, (0, _expValEquals.expValEquals)('platform_editor_text_highlight_padding', 'isEnabled', true) &&
|
|
1524
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
1525
|
+
textHighlightPaddingStyles, tasksAndDecisionsStyles, smartCardStyles, smartCardStylesAvatarFix, (0, _experiments.editorExperiment)('platform_editor_preview_panel_linking_exp', true) && headerSmartCardStyles, (0, _platformFeatureFlags.fg)('smartcard_avatar_margin_fix') && smartCardStylesAvatarMarginFix, smartCardStylesAvatarListZeroMarginTop,
|
|
1509
1526
|
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
1510
1527
|
(0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
|
|
1511
1528
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
|
|
@@ -17,6 +17,7 @@ import { isCodeMark } from './marks/code';
|
|
|
17
17
|
import { insideBlockNode, insideBreakoutLayout, insideMultiBodiedExtension, insideTable } from './renderer-node';
|
|
18
18
|
import { renderTextSegments } from './utils/render-text-segments';
|
|
19
19
|
import { segmentText } from './utils/segment-text';
|
|
20
|
+
import { getStandaloneBackgroundColorMarks } from './utils/getStandaloneBackgroundColorMarks';
|
|
20
21
|
function mergeMarks(marksAndNodes) {
|
|
21
22
|
return marksAndNodes.reduce((acc, markOrNode) => {
|
|
22
23
|
const prev = acc.length && acc[acc.length - 1] || null;
|
|
@@ -46,6 +47,7 @@ export default class ReactSerializer {
|
|
|
46
47
|
_defineProperty(this, "allowCustomPanels", false);
|
|
47
48
|
_defineProperty(this, "surroundTextNodesWithTextWrapper", false);
|
|
48
49
|
_defineProperty(this, "allowAnnotations", false);
|
|
50
|
+
_defineProperty(this, "standaloneBackgroundColorMarks", []);
|
|
49
51
|
_defineProperty(this, "serializeFragmentChild", (node, {
|
|
50
52
|
index,
|
|
51
53
|
parentInfo
|
|
@@ -280,6 +282,9 @@ export default class ReactSerializer {
|
|
|
280
282
|
}) {
|
|
281
283
|
const currentPath = parentInfo && parentInfo.path || [];
|
|
282
284
|
const nodePosition = parentInfo && parentInfo.pos || 1;
|
|
285
|
+
if (expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
286
|
+
this.standaloneBackgroundColorMarks.push(...getStandaloneBackgroundColorMarks(content));
|
|
287
|
+
}
|
|
283
288
|
return ReactSerializer.buildMarkStructure(content).map((mark, index) => {
|
|
284
289
|
return this.serializeMark({
|
|
285
290
|
mark,
|
|
@@ -311,7 +316,11 @@ export default class ReactSerializer {
|
|
|
311
316
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
312
317
|
const content = (mark.content || []).map(serializeContent);
|
|
313
318
|
const markKey = `${mark.type.name}-component__${this.startPos}__${parentMark.path.length}`;
|
|
314
|
-
|
|
319
|
+
const isStandalone = expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true) && this.standaloneBackgroundColorMarks.some(m => mark.eq(m));
|
|
320
|
+
return this.renderMark(markToReact(mark), {
|
|
321
|
+
...this.getMarkProps(mark, parentMark.path),
|
|
322
|
+
isStandalone
|
|
323
|
+
}, markKey, content);
|
|
315
324
|
}
|
|
316
325
|
const startPos = this.startPos;
|
|
317
326
|
const endPos = startPos + mark.nodeSize;
|
|
@@ -3,6 +3,7 @@ import React, { useMemo } from 'react';
|
|
|
3
3
|
import { getDarkModeLCHColor } from '@atlaskit/adf-schema';
|
|
4
4
|
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
5
5
|
import { useThemeObserver } from '@atlaskit/tokens';
|
|
6
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
export default function BackgroundColor(props) {
|
|
7
8
|
const {
|
|
8
9
|
colorMode
|
|
@@ -40,6 +41,22 @@ export default function BackgroundColor(props) {
|
|
|
40
41
|
const style = useMemo(() => ({
|
|
41
42
|
['--custom-palette-color']: paletteColorValue
|
|
42
43
|
}), [paletteColorValue]);
|
|
44
|
+
if (props.isStandalone && expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
45
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
"data-block-mark": props.dataAttributes['data-block-mark'],
|
|
47
|
+
"data-renderer-mark": props.dataAttributes['data-renderer-mark'],
|
|
48
|
+
"data-background-custom-color": props.color
|
|
49
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
50
|
+
,
|
|
51
|
+
className: "fabric-background-color-mark"
|
|
52
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
53
|
+
,
|
|
54
|
+
style: style
|
|
55
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
56
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
57
|
+
className: "background-color-padding-left background-color-padding-right"
|
|
58
|
+
}, props.children));
|
|
59
|
+
}
|
|
43
60
|
return /*#__PURE__*/React.createElement("span", _extends({}, props.dataAttributes, {
|
|
44
61
|
"data-background-custom-color": props.color
|
|
45
62
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -78,7 +78,9 @@ class HeadingAnchor extends React.PureComponent {
|
|
|
78
78
|
} = this.props;
|
|
79
79
|
return jsx("button", {
|
|
80
80
|
"data-testid": "anchor-button",
|
|
81
|
-
css: copyAnchorButtonStyles
|
|
81
|
+
css: copyAnchorButtonStyles
|
|
82
|
+
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
83
|
+
,
|
|
82
84
|
onMouseLeave: this.resetMessage,
|
|
83
85
|
onClick: this.copyToClipboard,
|
|
84
86
|
"aria-hidden": hideFromScreenReader,
|
|
@@ -124,7 +124,7 @@ const TableWrapper = ({
|
|
|
124
124
|
ref: wrapperRef,
|
|
125
125
|
onScroll: stickyHeaders ? onScroll : undefined
|
|
126
126
|
// Adding tabIndex here because this is a scrollable container and it needs to be focusable so keyboard users can scroll it.
|
|
127
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
127
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex, @atlassian/a11y/no-noninteractive-tabindex
|
|
128
128
|
,
|
|
129
129
|
tabIndex: 0,
|
|
130
130
|
role: "region",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import ReactSerializer from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of **backgroundColor marks** that should be considered "standalone"
|
|
4
|
+
* for highlight padding purposes.
|
|
5
|
+
*
|
|
6
|
+
* Standalone backgroundColor marks are determined by scanning the content array and
|
|
7
|
+
* checking for backgroundColor marks that are separated by whitespace boundaries.
|
|
8
|
+
*
|
|
9
|
+
* @param content Array of ProseMirror nodes to scan for standalone backgroundColor marks.
|
|
10
|
+
* @returns Array of backgroundColor marks that are standalone.
|
|
11
|
+
*/
|
|
12
|
+
export const getStandaloneBackgroundColorMarks = content => {
|
|
13
|
+
const standaloneMarks = [];
|
|
14
|
+
// keep track of the previous node's state
|
|
15
|
+
let prev = {
|
|
16
|
+
selfSpaceOnTheRight: true // initial value to handle leading BackgroundColor
|
|
17
|
+
};
|
|
18
|
+
let prevNode = null;
|
|
19
|
+
// Iterates through each node in the content array.
|
|
20
|
+
// Tracks if the previous node had a backgroundColor mark and if it ended with a space.
|
|
21
|
+
// If a backgroundColor mark is followed by a text node that starts with a space,
|
|
22
|
+
// and the previous node ended with a space, the previous backgroundColor mark is considered standalone.
|
|
23
|
+
// At the end, flushes any remaining node that meets the standalone criteria.
|
|
24
|
+
for (let i = 0; i < content.length; i++) {
|
|
25
|
+
const node = content[i];
|
|
26
|
+
const nodeMarks = ReactSerializer.getMarks(node);
|
|
27
|
+
const isBackgroundColor = nodeMarks.some(m => m.type.name === 'backgroundColor');
|
|
28
|
+
let selfSpaceOnTheLeft = false;
|
|
29
|
+
let selfSpaceOnTheRight = false;
|
|
30
|
+
if (node.text) {
|
|
31
|
+
selfSpaceOnTheLeft = node.text.startsWith(' ');
|
|
32
|
+
selfSpaceOnTheRight = node.text.endsWith(' ');
|
|
33
|
+
}
|
|
34
|
+
if (isBackgroundColor) {
|
|
35
|
+
prevNode = node;
|
|
36
|
+
prev = {
|
|
37
|
+
selfSpaceOnTheRight: false,
|
|
38
|
+
hasBackgroundColor: true,
|
|
39
|
+
spaceToTheLeft: prev !== null && prev.selfSpaceOnTheRight
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
// If prev exists, check for standalone logic
|
|
43
|
+
if (prev && prev.hasBackgroundColor && prevNode) {
|
|
44
|
+
// If prev had space on the left and current is a TextNode and has space on the left
|
|
45
|
+
if (prev.spaceToTheLeft && selfSpaceOnTheLeft) {
|
|
46
|
+
const mark = ReactSerializer.getMarks(prevNode).find(m => m.type.name === 'backgroundColor');
|
|
47
|
+
if (mark) {
|
|
48
|
+
standaloneMarks.push(mark);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
prevNode = null;
|
|
53
|
+
prev = {
|
|
54
|
+
selfSpaceOnTheRight,
|
|
55
|
+
hasBackgroundColor: false
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (prevNode) {
|
|
60
|
+
if (prev && prev.hasBackgroundColor && prev.spaceToTheLeft) {
|
|
61
|
+
const mark = ReactSerializer.getMarks(prevNode).find(m => m.type.name === 'backgroundColor');
|
|
62
|
+
if (mark) {
|
|
63
|
+
standaloneMarks.push(mark);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return standaloneMarks;
|
|
68
|
+
};
|
|
@@ -92,14 +92,8 @@ const _validation = (doc, schema, adfStage, useSpecBasedValidator, dispatchAnaly
|
|
|
92
92
|
return result;
|
|
93
93
|
};
|
|
94
94
|
const memoValidation = memoizeOne(_validation, (newArgs, lastArgs) => {
|
|
95
|
-
const [newDoc, newSchema, newADFStage, newUseSpecValidator,
|
|
96
|
-
|
|
97
|
-
/* ignoring dispatchAnalyticsEvent */
|
|
98
|
-
, newSkipValidation, newValidationOverrides] = newArgs;
|
|
99
|
-
const [oldDoc, oldSchema, oldADFStage, oldUseSpecValidator,
|
|
100
|
-
|
|
101
|
-
/* ignoring dispatchAnalyticsEvent */
|
|
102
|
-
, oldSkipValidation, oldValidationOverrides] = lastArgs;
|
|
95
|
+
const [newDoc, newSchema, newADFStage, newUseSpecValidator,, /* ignoring dispatchAnalyticsEvent */newSkipValidation, newValidationOverrides] = newArgs;
|
|
96
|
+
const [oldDoc, oldSchema, oldADFStage, oldUseSpecValidator,, /* ignoring dispatchAnalyticsEvent */oldSkipValidation, oldValidationOverrides] = lastArgs;
|
|
103
97
|
return areDocsEqual(newDoc, oldDoc) && newSchema === oldSchema && newADFStage === oldADFStage && newUseSpecValidator === oldUseSpecValidator && newSkipValidation === oldSkipValidation && newValidationOverrides === oldValidationOverrides;
|
|
104
98
|
});
|
|
105
99
|
|
|
@@ -26,6 +26,7 @@ import { SORTABLE_COLUMN_ICON_CLASSNAME } from '@atlaskit/editor-common/table';
|
|
|
26
26
|
import { LightWeightCodeBlockCssClassName } from '../../react/nodes/codeBlock/components/lightWeightCodeBlock';
|
|
27
27
|
import { editorUGCToken } from '@atlaskit/editor-common/ugc-tokens';
|
|
28
28
|
import { getBaseFontSize } from './get-base-font-size';
|
|
29
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
29
30
|
const wrappedMediaBreakoutPoint = 410;
|
|
30
31
|
const TELEPOINTER_ID = 'ai-streaming-telepointer';
|
|
31
32
|
const tableShadowWidth = 32;
|
|
@@ -876,6 +877,20 @@ const backgroundColorStyles = css({
|
|
|
876
877
|
backgroundColor: 'unset'
|
|
877
878
|
}
|
|
878
879
|
});
|
|
880
|
+
|
|
881
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
882
|
+
export const textHighlightPaddingStyles = css({
|
|
883
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
884
|
+
'.fabric-background-color-mark:has(.background-color-padding-left)': {
|
|
885
|
+
paddingLeft: "var(--ds-space-025, 2px)",
|
|
886
|
+
marginLeft: "var(--ds-space-negative-025, -2px)"
|
|
887
|
+
},
|
|
888
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
889
|
+
'.fabric-background-color-mark:has(.background-color-padding-right)': {
|
|
890
|
+
paddingRight: "var(--ds-space-025, 2px)",
|
|
891
|
+
marginRight: "var(--ds-space-negative-025, -2px)"
|
|
892
|
+
}
|
|
893
|
+
});
|
|
879
894
|
const tasksAndDecisionsStyles = css({
|
|
880
895
|
'.ProseMirror': {
|
|
881
896
|
[`.taskItemView-content-wrap,
|
|
@@ -1906,7 +1921,9 @@ export const RendererStyleContainer = props => {
|
|
|
1906
1921
|
'--ak-renderer-editor-font-heading-h6': `${editorUGCToken('editor.font.heading.h6')}`,
|
|
1907
1922
|
'--ak-renderer-editor-font-normal-text': `${editorUGCToken('editor.font.body')}`
|
|
1908
1923
|
},
|
|
1909
|
-
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, !fg('aifc_create_enabled') && telepointerStyles, fg('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, fg('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles,
|
|
1924
|
+
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, !fg('aifc_create_enabled') && telepointerStyles, fg('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, fg('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true) &&
|
|
1925
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
1926
|
+
textHighlightPaddingStyles, tasksAndDecisionsStyles, smartCardStyles, smartCardStylesAvatarFix, editorExperiment('platform_editor_preview_panel_linking_exp', true) && headerSmartCardStyles, fg('smartcard_avatar_margin_fix') && smartCardStylesAvatarMarginFix, smartCardStylesAvatarListZeroMarginTop,
|
|
1910
1927
|
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
1911
1928
|
fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
|
|
1912
1929
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
|
package/dist/esm/react/index.js
CHANGED
|
@@ -24,6 +24,7 @@ import { isCodeMark } from './marks/code';
|
|
|
24
24
|
import { insideBlockNode, insideBreakoutLayout, insideMultiBodiedExtension, insideTable } from './renderer-node';
|
|
25
25
|
import { renderTextSegments } from './utils/render-text-segments';
|
|
26
26
|
import { segmentText } from './utils/segment-text';
|
|
27
|
+
import { getStandaloneBackgroundColorMarks } from './utils/getStandaloneBackgroundColorMarks';
|
|
27
28
|
function mergeMarks(marksAndNodes) {
|
|
28
29
|
return marksAndNodes.reduce(function (acc, markOrNode) {
|
|
29
30
|
var prev = acc.length && acc[acc.length - 1] || null;
|
|
@@ -55,6 +56,7 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
55
56
|
_defineProperty(this, "allowCustomPanels", false);
|
|
56
57
|
_defineProperty(this, "surroundTextNodesWithTextWrapper", false);
|
|
57
58
|
_defineProperty(this, "allowAnnotations", false);
|
|
59
|
+
_defineProperty(this, "standaloneBackgroundColorMarks", []);
|
|
58
60
|
_defineProperty(this, "serializeFragmentChild", function (node, _ref) {
|
|
59
61
|
var index = _ref.index,
|
|
60
62
|
parentInfo = _ref.parentInfo;
|
|
@@ -294,6 +296,10 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
294
296
|
parentInfo = _ref2.parentInfo;
|
|
295
297
|
var currentPath = parentInfo && parentInfo.path || [];
|
|
296
298
|
var nodePosition = parentInfo && parentInfo.pos || 1;
|
|
299
|
+
if (expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
300
|
+
var _this$standaloneBackg;
|
|
301
|
+
(_this$standaloneBackg = this.standaloneBackgroundColorMarks).push.apply(_this$standaloneBackg, _toConsumableArray(getStandaloneBackgroundColorMarks(content)));
|
|
302
|
+
}
|
|
297
303
|
return ReactSerializer.buildMarkStructure(content).map(function (mark, index) {
|
|
298
304
|
return _this3.serializeMark({
|
|
299
305
|
mark: mark,
|
|
@@ -329,7 +335,12 @@ var ReactSerializer = /*#__PURE__*/function () {
|
|
|
329
335
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
330
336
|
var content = (mark.content || []).map(serializeContent);
|
|
331
337
|
var markKey = "".concat(mark.type.name, "-component__").concat(this.startPos, "__").concat(parentMark.path.length);
|
|
332
|
-
|
|
338
|
+
var isStandalone = expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true) && this.standaloneBackgroundColorMarks.some(function (m) {
|
|
339
|
+
return mark.eq(m);
|
|
340
|
+
});
|
|
341
|
+
return this.renderMark(markToReact(mark), _objectSpread(_objectSpread({}, this.getMarkProps(mark, parentMark.path)), {}, {
|
|
342
|
+
isStandalone: isStandalone
|
|
343
|
+
}), markKey, content);
|
|
333
344
|
}
|
|
334
345
|
var startPos = this.startPos;
|
|
335
346
|
var endPos = startPos + mark.nodeSize;
|
|
@@ -4,6 +4,7 @@ import React, { useMemo } from 'react';
|
|
|
4
4
|
import { getDarkModeLCHColor } from '@atlaskit/adf-schema';
|
|
5
5
|
import { hexToEditorTextBackgroundPaletteColor } from '@atlaskit/editor-palette';
|
|
6
6
|
import { useThemeObserver } from '@atlaskit/tokens';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
8
|
export default function BackgroundColor(props) {
|
|
8
9
|
var _useThemeObserver = useThemeObserver(),
|
|
9
10
|
colorMode = _useThemeObserver.colorMode;
|
|
@@ -40,6 +41,22 @@ export default function BackgroundColor(props) {
|
|
|
40
41
|
var style = useMemo(function () {
|
|
41
42
|
return _defineProperty({}, '--custom-palette-color', paletteColorValue);
|
|
42
43
|
}, [paletteColorValue]);
|
|
44
|
+
if (props.isStandalone && expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true)) {
|
|
45
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
"data-block-mark": props.dataAttributes['data-block-mark'],
|
|
47
|
+
"data-renderer-mark": props.dataAttributes['data-renderer-mark'],
|
|
48
|
+
"data-background-custom-color": props.color
|
|
49
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
50
|
+
,
|
|
51
|
+
className: "fabric-background-color-mark"
|
|
52
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
53
|
+
,
|
|
54
|
+
style: style
|
|
55
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
56
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
57
|
+
className: "background-color-padding-left background-color-padding-right"
|
|
58
|
+
}, props.children));
|
|
59
|
+
}
|
|
43
60
|
return /*#__PURE__*/React.createElement("span", _extends({}, props.dataAttributes, {
|
|
44
61
|
"data-background-custom-color": props.color
|
|
45
62
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -107,7 +107,9 @@ var HeadingAnchor = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
107
107
|
headingId = _this$props.headingId;
|
|
108
108
|
return jsx("button", {
|
|
109
109
|
"data-testid": "anchor-button",
|
|
110
|
-
css: copyAnchorButtonStyles
|
|
110
|
+
css: copyAnchorButtonStyles
|
|
111
|
+
// eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
|
|
112
|
+
,
|
|
111
113
|
onMouseLeave: _this.resetMessage,
|
|
112
114
|
onClick: _this.copyToClipboard,
|
|
113
115
|
"aria-hidden": hideFromScreenReader,
|
|
@@ -146,7 +146,7 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
146
146
|
ref: wrapperRef,
|
|
147
147
|
onScroll: stickyHeaders ? onScroll : undefined
|
|
148
148
|
// Adding tabIndex here because this is a scrollable container and it needs to be focusable so keyboard users can scroll it.
|
|
149
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
149
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex, @atlassian/a11y/no-noninteractive-tabindex
|
|
150
150
|
,
|
|
151
151
|
tabIndex: 0,
|
|
152
152
|
role: "region",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import ReactSerializer from '..';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of **backgroundColor marks** that should be considered "standalone"
|
|
4
|
+
* for highlight padding purposes.
|
|
5
|
+
*
|
|
6
|
+
* Standalone backgroundColor marks are determined by scanning the content array and
|
|
7
|
+
* checking for backgroundColor marks that are separated by whitespace boundaries.
|
|
8
|
+
*
|
|
9
|
+
* @param content Array of ProseMirror nodes to scan for standalone backgroundColor marks.
|
|
10
|
+
* @returns Array of backgroundColor marks that are standalone.
|
|
11
|
+
*/
|
|
12
|
+
export var getStandaloneBackgroundColorMarks = function getStandaloneBackgroundColorMarks(content) {
|
|
13
|
+
var standaloneMarks = [];
|
|
14
|
+
// keep track of the previous node's state
|
|
15
|
+
var prev = {
|
|
16
|
+
selfSpaceOnTheRight: true // initial value to handle leading BackgroundColor
|
|
17
|
+
};
|
|
18
|
+
var prevNode = null;
|
|
19
|
+
// Iterates through each node in the content array.
|
|
20
|
+
// Tracks if the previous node had a backgroundColor mark and if it ended with a space.
|
|
21
|
+
// If a backgroundColor mark is followed by a text node that starts with a space,
|
|
22
|
+
// and the previous node ended with a space, the previous backgroundColor mark is considered standalone.
|
|
23
|
+
// At the end, flushes any remaining node that meets the standalone criteria.
|
|
24
|
+
for (var i = 0; i < content.length; i++) {
|
|
25
|
+
var node = content[i];
|
|
26
|
+
var nodeMarks = ReactSerializer.getMarks(node);
|
|
27
|
+
var isBackgroundColor = nodeMarks.some(function (m) {
|
|
28
|
+
return m.type.name === 'backgroundColor';
|
|
29
|
+
});
|
|
30
|
+
var selfSpaceOnTheLeft = false;
|
|
31
|
+
var selfSpaceOnTheRight = false;
|
|
32
|
+
if (node.text) {
|
|
33
|
+
selfSpaceOnTheLeft = node.text.startsWith(' ');
|
|
34
|
+
selfSpaceOnTheRight = node.text.endsWith(' ');
|
|
35
|
+
}
|
|
36
|
+
if (isBackgroundColor) {
|
|
37
|
+
prevNode = node;
|
|
38
|
+
prev = {
|
|
39
|
+
selfSpaceOnTheRight: false,
|
|
40
|
+
hasBackgroundColor: true,
|
|
41
|
+
spaceToTheLeft: prev !== null && prev.selfSpaceOnTheRight
|
|
42
|
+
};
|
|
43
|
+
} else {
|
|
44
|
+
// If prev exists, check for standalone logic
|
|
45
|
+
if (prev && prev.hasBackgroundColor && prevNode) {
|
|
46
|
+
// If prev had space on the left and current is a TextNode and has space on the left
|
|
47
|
+
if (prev.spaceToTheLeft && selfSpaceOnTheLeft) {
|
|
48
|
+
var mark = ReactSerializer.getMarks(prevNode).find(function (m) {
|
|
49
|
+
return m.type.name === 'backgroundColor';
|
|
50
|
+
});
|
|
51
|
+
if (mark) {
|
|
52
|
+
standaloneMarks.push(mark);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
prevNode = null;
|
|
57
|
+
prev = {
|
|
58
|
+
selfSpaceOnTheRight: selfSpaceOnTheRight,
|
|
59
|
+
hasBackgroundColor: false
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (prevNode) {
|
|
64
|
+
if (prev && prev.hasBackgroundColor && prev.spaceToTheLeft) {
|
|
65
|
+
var _mark = ReactSerializer.getMarks(prevNode).find(function (m) {
|
|
66
|
+
return m.type.name === 'backgroundColor';
|
|
67
|
+
});
|
|
68
|
+
if (_mark) {
|
|
69
|
+
standaloneMarks.push(_mark);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return standaloneMarks;
|
|
74
|
+
};
|
|
@@ -96,14 +96,14 @@ var memoValidation = memoizeOne(_validation, function (newArgs, lastArgs) {
|
|
|
96
96
|
newSchema = _newArgs[1],
|
|
97
97
|
newADFStage = _newArgs[2],
|
|
98
98
|
newUseSpecValidator = _newArgs[3],
|
|
99
|
-
newSkipValidation = _newArgs[5],
|
|
99
|
+
/* ignoring dispatchAnalyticsEvent */newSkipValidation = _newArgs[5],
|
|
100
100
|
newValidationOverrides = _newArgs[6];
|
|
101
101
|
var _lastArgs = _slicedToArray(lastArgs, 7),
|
|
102
102
|
oldDoc = _lastArgs[0],
|
|
103
103
|
oldSchema = _lastArgs[1],
|
|
104
104
|
oldADFStage = _lastArgs[2],
|
|
105
105
|
oldUseSpecValidator = _lastArgs[3],
|
|
106
|
-
oldSkipValidation = _lastArgs[5],
|
|
106
|
+
/* ignoring dispatchAnalyticsEvent */oldSkipValidation = _lastArgs[5],
|
|
107
107
|
oldValidationOverrides = _lastArgs[6];
|
|
108
108
|
return areDocsEqual(newDoc, oldDoc) && newSchema === oldSchema && newADFStage === oldADFStage && newUseSpecValidator === oldUseSpecValidator && newSkipValidation === oldSkipValidation && newValidationOverrides === oldValidationOverrides;
|
|
109
109
|
});
|
|
@@ -28,6 +28,7 @@ import { SORTABLE_COLUMN_ICON_CLASSNAME } from '@atlaskit/editor-common/table';
|
|
|
28
28
|
import { LightWeightCodeBlockCssClassName } from '../../react/nodes/codeBlock/components/lightWeightCodeBlock';
|
|
29
29
|
import { editorUGCToken } from '@atlaskit/editor-common/ugc-tokens';
|
|
30
30
|
import { getBaseFontSize } from './get-base-font-size';
|
|
31
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
31
32
|
var wrappedMediaBreakoutPoint = 410;
|
|
32
33
|
var TELEPOINTER_ID = 'ai-streaming-telepointer';
|
|
33
34
|
var tableShadowWidth = 32;
|
|
@@ -746,6 +747,20 @@ var backgroundColorStyles = css({
|
|
|
746
747
|
backgroundColor: 'unset'
|
|
747
748
|
}
|
|
748
749
|
});
|
|
750
|
+
|
|
751
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
|
|
752
|
+
export var textHighlightPaddingStyles = css({
|
|
753
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
754
|
+
'.fabric-background-color-mark:has(.background-color-padding-left)': {
|
|
755
|
+
paddingLeft: "var(--ds-space-025, 2px)",
|
|
756
|
+
marginLeft: "var(--ds-space-negative-025, -2px)"
|
|
757
|
+
},
|
|
758
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
759
|
+
'.fabric-background-color-mark:has(.background-color-padding-right)': {
|
|
760
|
+
paddingRight: "var(--ds-space-025, 2px)",
|
|
761
|
+
marginRight: "var(--ds-space-negative-025, -2px)"
|
|
762
|
+
}
|
|
763
|
+
});
|
|
749
764
|
var tasksAndDecisionsStyles = css({
|
|
750
765
|
'.ProseMirror': _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ".taskItemView-content-wrap,\n\t\t.".concat(TaskDecisionSharedCssClassName.DECISION_CONTAINER), {
|
|
751
766
|
position: 'relative',
|
|
@@ -1498,7 +1513,9 @@ export var RendererStyleContainer = function RendererStyleContainer(props) {
|
|
|
1498
1513
|
'--ak-renderer-editor-font-heading-h6': "".concat(editorUGCToken('editor.font.heading.h6')),
|
|
1499
1514
|
'--ak-renderer-editor-font-normal-text': "".concat(editorUGCToken('editor.font.body'))
|
|
1500
1515
|
},
|
|
1501
|
-
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, !fg('aifc_create_enabled') && telepointerStyles, fg('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, fg('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles,
|
|
1516
|
+
css: [baseStyles, hideHeadingCopyLinkWrapperStyles, appearance === 'full-page' && isPreviewPanelResponsivenessOn && rendererFullPageStylesWithReducedPadding, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && rendererFullPageStyles, appearance === 'full-width' && rendererFullWidthStyles, appearance === 'full-width' && !isTableResizingEnabled(appearance) && rendererFullWidthStylesForTableResizing, !fg('aifc_create_enabled') && telepointerStyles, fg('aifc_create_enabled') && rovoTelepointerStyles, whitespaceSharedStyles, blockquoteSharedStyles, fg('platform_editor_typography_ugc') ? headingsSharedStylesWithEditorUGC : headingsSharedStyles, headingWithAlignmentStyles, ruleSharedStyles, fg('platform_editor_typography_ugc') ? paragraphSharedStylesWithEditorUGC : paragraphSharedStyles, listsSharedStyles, browser.gecko && listsSharedStylesForGekko, indentationSharedStyles, fg('platform_editor__renderer_indentation_text_margin') && indentationSharedStylesWithMarginFix, blockMarksSharedStyles, codeMarkSharedStyles, shadowSharedStyle, dateSharedStyle, textColorStyles, backgroundColorStyles, expValEquals('platform_editor_text_highlight_padding', 'isEnabled', true) &&
|
|
1517
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values
|
|
1518
|
+
textHighlightPaddingStyles, tasksAndDecisionsStyles, smartCardStyles, smartCardStylesAvatarFix, editorExperiment('platform_editor_preview_panel_linking_exp', true) && headerSmartCardStyles, fg('smartcard_avatar_margin_fix') && smartCardStylesAvatarMarginFix, smartCardStylesAvatarListZeroMarginTop,
|
|
1502
1519
|
// eslint-disable-next-line @atlaskit/platform/ensure-feature-flag-prefix
|
|
1503
1520
|
fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStyles,
|
|
1504
1521
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning, @atlaskit/platform/ensure-feature-flag-prefix
|
|
@@ -107,6 +107,7 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
|
|
|
107
107
|
private allowTableResizing?;
|
|
108
108
|
private isPresentational?;
|
|
109
109
|
private disableTableOverflowShadow?;
|
|
110
|
+
private standaloneBackgroundColorMarks;
|
|
110
111
|
constructor(init: ReactSerializerInit);
|
|
111
112
|
private resetState;
|
|
112
113
|
private getNodeProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mark, Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of **backgroundColor marks** that should be considered "standalone"
|
|
4
|
+
* for highlight padding purposes.
|
|
5
|
+
*
|
|
6
|
+
* Standalone backgroundColor marks are determined by scanning the content array and
|
|
7
|
+
* checking for backgroundColor marks that are separated by whitespace boundaries.
|
|
8
|
+
*
|
|
9
|
+
* @param content Array of ProseMirror nodes to scan for standalone backgroundColor marks.
|
|
10
|
+
* @returns Array of backgroundColor marks that are standalone.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getStandaloneBackgroundColorMarks: (content: Node[]) => Mark[];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { type RendererWrapperProps } from './index';
|
|
7
|
+
export declare const textHighlightPaddingStyles: import("@emotion/react").SerializedStyles;
|
|
7
8
|
type RendererStyleContainerProps = Pick<RendererWrapperProps, 'onClick' | 'onMouseDown' | 'appearance' | 'contentMode' | 'allowNestedHeaderLinks' | 'allowColumnSorting' | 'useBlockRenderForCodeBlock' | 'allowAnnotations' | 'allowTableResizing' | 'innerRef' | 'children' | 'allowRendererContainerStyles'> & {
|
|
8
9
|
testId?: string;
|
|
9
10
|
};
|
|
@@ -107,6 +107,7 @@ export default class ReactSerializer implements Serializer<JSX.Element> {
|
|
|
107
107
|
private allowTableResizing?;
|
|
108
108
|
private isPresentational?;
|
|
109
109
|
private disableTableOverflowShadow?;
|
|
110
|
+
private standaloneBackgroundColorMarks;
|
|
110
111
|
constructor(init: ReactSerializerInit);
|
|
111
112
|
private resetState;
|
|
112
113
|
private getNodeProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Mark, Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of **backgroundColor marks** that should be considered "standalone"
|
|
4
|
+
* for highlight padding purposes.
|
|
5
|
+
*
|
|
6
|
+
* Standalone backgroundColor marks are determined by scanning the content array and
|
|
7
|
+
* checking for backgroundColor marks that are separated by whitespace boundaries.
|
|
8
|
+
*
|
|
9
|
+
* @param content Array of ProseMirror nodes to scan for standalone backgroundColor marks.
|
|
10
|
+
* @returns Array of backgroundColor marks that are standalone.
|
|
11
|
+
*/
|
|
12
|
+
export declare const getStandaloneBackgroundColorMarks: (content: Node[]) => Mark[];
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { jsx } from '@emotion/react';
|
|
6
6
|
import { type RendererWrapperProps } from './index';
|
|
7
|
+
export declare const textHighlightPaddingStyles: import("@emotion/react").SerializedStyles;
|
|
7
8
|
type RendererStyleContainerProps = Pick<RendererWrapperProps, 'onClick' | 'onMouseDown' | 'appearance' | 'contentMode' | 'allowNestedHeaderLinks' | 'allowColumnSorting' | 'useBlockRenderForCodeBlock' | 'allowAnnotations' | 'allowTableResizing' | 'innerRef' | 'children' | 'allowRendererContainerStyles'> & {
|
|
8
9
|
testId?: string;
|
|
9
10
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "124.1.
|
|
3
|
+
"version": "124.1.1",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@atlaskit/status": "^3.0.0",
|
|
57
57
|
"@atlaskit/task-decision": "^19.2.0",
|
|
58
58
|
"@atlaskit/theme": "^21.0.0",
|
|
59
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
59
|
+
"@atlaskit/tmp-editor-statsig": "^12.33.0",
|
|
60
60
|
"@atlaskit/tokens": "^6.4.0",
|
|
61
61
|
"@atlaskit/tooltip": "^20.5.0",
|
|
62
62
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"uuid": "^3.1.0"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
|
-
"@atlaskit/editor-common": "^110.
|
|
73
|
+
"@atlaskit/editor-common": "^110.4.0",
|
|
74
74
|
"@atlaskit/link-provider": "^4.0.0",
|
|
75
75
|
"@atlaskit/media-core": "^37.0.0",
|
|
76
76
|
"react": "^18.2.0",
|
|
@@ -246,6 +246,9 @@
|
|
|
246
246
|
},
|
|
247
247
|
"jfp-magma-ssr-iv-editor-links": {
|
|
248
248
|
"type": "boolean"
|
|
249
|
+
},
|
|
250
|
+
"platform_editor_text_highlight_padding": {
|
|
251
|
+
"type": "boolean"
|
|
249
252
|
}
|
|
250
253
|
}
|
|
251
254
|
}
|