@atlaskit/renderer 126.15.1 → 127.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/cjs/actions/index.js +9 -0
- package/dist/cjs/actions/selection.js +63 -0
- package/dist/cjs/steps/index.js +7 -5
- package/dist/cjs/ui/Renderer/RendererStyleContainer.js +1 -1
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/es2019/actions/index.js +7 -0
- package/dist/es2019/actions/selection.js +58 -0
- package/dist/es2019/steps/index.js +6 -6
- package/dist/es2019/ui/Renderer/RendererStyleContainer.js +1 -1
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/esm/actions/index.js +9 -0
- package/dist/esm/actions/selection.js +57 -0
- package/dist/esm/steps/index.js +6 -6
- package/dist/esm/ui/Renderer/RendererStyleContainer.js +1 -1
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/types/actions/index.d.ts +6 -2
- package/dist/types/actions/selection.d.ts +8 -0
- package/dist/types/steps/index.d.ts +3 -1
- package/dist/types-ts4.5/actions/index.d.ts +6 -2
- package/dist/types-ts4.5/actions/selection.d.ts +8 -0
- package/dist/types-ts4.5/steps/index.d.ts +3 -1
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 127.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`451c2f1a9f5f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/451c2f1a9f5f0) -
|
|
8
|
+
Clean up confluence_insert_excerpt_inline_vertical_align experiment, which removes block nodes
|
|
9
|
+
vertical margin from inline extension elements to fix the inline vertical positioning of inline
|
|
10
|
+
extensions to match its surrounding text content.
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 126.16.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- [`10f36a235eedd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/10f36a235eedd) -
|
|
21
|
+
Add getSelectionContext to RendererActions
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 126.15.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
|
@@ -19,6 +19,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
19
19
|
var _steps = require("../steps");
|
|
20
20
|
var _getRendererRangeInlineNodeNames = require("./get-renderer-range-inline-node-names");
|
|
21
21
|
var _matchesUtils = require("./matches-utils");
|
|
22
|
+
var _selection = require("./selection");
|
|
22
23
|
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
24
|
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
25
|
var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
@@ -250,6 +251,14 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
250
251
|
}
|
|
251
252
|
return (0, _steps.getPosFromRange)(range);
|
|
252
253
|
}
|
|
254
|
+
}, {
|
|
255
|
+
key: "getSelectionContext",
|
|
256
|
+
value: function getSelectionContext() {
|
|
257
|
+
return (0, _selection.getSelectionContext)({
|
|
258
|
+
doc: this.doc,
|
|
259
|
+
schema: this.schema
|
|
260
|
+
});
|
|
261
|
+
}
|
|
253
262
|
}, {
|
|
254
263
|
key: "getAnnotationMarks",
|
|
255
264
|
value: function getAnnotationMarks() {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSelectionContext = void 0;
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
|
+
var _steps = require("../steps");
|
|
10
|
+
var getSelectionContext = exports.getSelectionContext = function getSelectionContext(_ref) {
|
|
11
|
+
var doc = _ref.doc,
|
|
12
|
+
schema = _ref.schema;
|
|
13
|
+
if (!doc || !schema) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var selection = document.getSelection();
|
|
17
|
+
if (!selection || selection.type !== 'Range' || selection.rangeCount !== 1) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var range = selection.getRangeAt(0);
|
|
21
|
+
if (range.collapsed) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
var startNode = (0, _steps.findParent)(range.startContainer);
|
|
25
|
+
var endNode = (0, _steps.findParent)(range.endContainer);
|
|
26
|
+
if (!startNode || !endNode) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
var startPos = (0, _steps.getStartPos)(startNode);
|
|
30
|
+
var endPos = (0, _steps.getStartPos)(endNode);
|
|
31
|
+
if (startPos === null || endPos === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
var pos = (0, _steps.getPosFromRange)(range);
|
|
35
|
+
if (!pos) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
var from = Math.min(pos.from, pos.to);
|
|
39
|
+
var to = Math.max(pos.from, pos.to);
|
|
40
|
+
if (from === to) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var pmSelection;
|
|
44
|
+
try {
|
|
45
|
+
pmSelection = _state.TextSelection.create(doc, from, to);
|
|
46
|
+
} catch (_unused) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
var startIndex = from - startPos;
|
|
50
|
+
var endIndex = to - endPos;
|
|
51
|
+
if (startIndex < 0 || endIndex < 0) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
var selectionFragment = (0, _selection.getFragmentsFromSelection)(pmSelection);
|
|
55
|
+
var localIds = (0, _selection.getLocalIdsFromSelection)(pmSelection);
|
|
56
|
+
return {
|
|
57
|
+
localIds: localIds,
|
|
58
|
+
selectionFragment: selectionFragment,
|
|
59
|
+
selectionMarkdown: null,
|
|
60
|
+
startIndex: startIndex,
|
|
61
|
+
endIndex: endIndex
|
|
62
|
+
};
|
|
63
|
+
};
|
package/dist/cjs/steps/index.js
CHANGED
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createAnnotationStep = createAnnotationStep;
|
|
7
|
+
exports.findParent = findParent;
|
|
7
8
|
exports.getPosFromRange = getPosFromRange;
|
|
8
|
-
exports.
|
|
9
|
+
exports.getStartPos = getStartPos;
|
|
10
|
+
exports.isRendererRoot = isRendererRoot;
|
|
9
11
|
exports.resolvePos = resolvePos;
|
|
10
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
13
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
@@ -20,7 +22,7 @@ function isPositionPointer(element) {
|
|
|
20
22
|
}
|
|
21
23
|
function findParent(element) {
|
|
22
24
|
var parentElement = element.parentElement;
|
|
23
|
-
if (!parentElement ||
|
|
25
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
24
26
|
return null;
|
|
25
27
|
}
|
|
26
28
|
if (isPositionPointer(parentElement)) {
|
|
@@ -30,7 +32,7 @@ function findParent(element) {
|
|
|
30
32
|
}
|
|
31
33
|
function findMediaParent(element) {
|
|
32
34
|
var parentElement = element.parentElement;
|
|
33
|
-
if (!parentElement ||
|
|
35
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
34
36
|
return null;
|
|
35
37
|
}
|
|
36
38
|
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
@@ -40,7 +42,7 @@ function findMediaParent(element) {
|
|
|
40
42
|
}
|
|
41
43
|
function findParentBeforePointer(element) {
|
|
42
44
|
var parentElement = element.parentElement;
|
|
43
|
-
if (
|
|
45
|
+
if (isRendererRoot(parentElement) || !parentElement) {
|
|
44
46
|
return null;
|
|
45
47
|
}
|
|
46
48
|
if (isPositionPointer(parentElement)) {
|
|
@@ -137,7 +139,7 @@ function resolveNodePos(node) {
|
|
|
137
139
|
}
|
|
138
140
|
return resolvedPos;
|
|
139
141
|
}
|
|
140
|
-
function
|
|
142
|
+
function isRendererRoot(element) {
|
|
141
143
|
return !!element && element.classList.contains('ak-renderer-document');
|
|
142
144
|
}
|
|
143
145
|
function resolvePos(node, offset) {
|
|
@@ -1981,7 +1981,7 @@ var RendererStyleContainer = exports.RendererStyleContainer = function RendererS
|
|
|
1981
1981
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
1982
1982
|
(0, _platformFeatureFlags.fg)('editor_inline_comments_on_inline_nodes') && rendererAnnotationStylesCommentHeightFix, (0, _expValEquals.expValEquals)('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? baseOtherStyles : baseOtherStylesDuplicateAnchor, !(0, _expValEquals.expValEquals)('platform_editor_flex_based_centering', 'isEnabled', true) && extensionCenterAlignLegacyStyles,
|
|
1983
1983
|
// this should be placed after baseOtherStyles
|
|
1984
|
-
(0, _expValEquals.expValEquals)('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && ((0, _expValEquals.expValEquals)('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle),
|
|
1984
|
+
(0, _expValEquals.expValEquals)('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && ((0, _expValEquals.expValEquals)('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle), inlineExtensionRendererMarginFix, allowNestedHeaderLinks && ((0, _expValEquals.expValEquals)('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? alignedHeadingAnchorStyle : alignedHeadingAnchorStyleDuplicateAnchor), mediaSingleSharedStyle,
|
|
1985
1985
|
// merge firstWrappedMediaStyles with mediaSingleSharedStyle when clean up platform_editor_fix_media_in_renderer
|
|
1986
1986
|
(0, _platformFeatureFlags.fg)('platform_editor_fix_media_in_renderer') && firstWrappedMediaStyles, tableSharedStyle, tableRendererHeaderStylesForTableCellOnly, (0, _platformFeatureFlags.fg)('platform_editor_bordered_panel_nested_in_table') && tableRendererNestedPanelStyles, isBackgroundClipBrowserFixNeeded() && tableStylesBackGroundClipForGeckoForTableCellOnly, (0, _platformFeatureFlags.fg)('platform_editor_nested_dnd_styles_changes') ? firstNodeWithNotMarginTopWithNestedDnD : firstNodeWithNotMarginTop, rendererTableStyles, (0, _table.isStickyScrollbarEnabled)(appearance) && stickyScrollbarStyles, rendererTableHeaderEqualHeightStylesForTableCellOnly, allowColumnSorting && rendererTableSortableColumnStyles, allowColumnSorting && allowNestedHeaderLinks && ((0, _expValEquals.expValEquals)('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinks : rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinksDuplicateAnchor), rendererTableColumnStyles, stickyHeaderStyles, codeBlockAndLayoutStyles, columnLayoutSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveRendererStyles, isAdvancedLayoutsOn && layoutSectionForAdvancedLayoutsStyles, !useBlockRenderForCodeBlock && gridRenderForCodeBlockStyles, browser.safari && codeBlockInListSafariFixStyles, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && responsiveBreakoutWidth, appearance === 'full-page' && isPreviewPanelResponsivenessOn && responsiveBreakoutWidthWithReducedPadding, (appearance === 'full-width' || appearance === 'max' && ((0, _expValEquals.expValEquals)('editor_tinymce_full_width_mode', 'isEnabled', true) || (0, _expValEquals.expValEquals)('confluence_max_width_content_appearance', 'isEnabled', true))) && responsiveBreakoutWidthFullWidth, (0, _expValEquals.expValEquals)('platform_editor_lovability_emoji_scaling', 'isEnabled', true) ? isCompactModeEnabled ? scaledDenseEmojiStyles : scaledEmojiStyles : isCompactModeEnabled ? denseStyles : undefined, (0, _experiments.editorExperiment)('platform_synced_block', true) && syncBlockStyles, centerWrapperStyles],
|
|
1987
1987
|
"data-testid": testId
|
|
@@ -71,7 +71,7 @@ var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
71
71
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
72
72
|
var RENDER_EVENT_SAMPLE_RATE = 0.2;
|
|
73
73
|
var packageName = "@atlaskit/renderer";
|
|
74
|
-
var packageVersion = "126.
|
|
74
|
+
var packageVersion = "126.16.0";
|
|
75
75
|
var setAsQueryContainerStyles = (0, _react2.css)({
|
|
76
76
|
containerName: 'ak-renderer-wrapper',
|
|
77
77
|
containerType: 'inline-size'
|
|
@@ -9,6 +9,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
9
9
|
import { createAnnotationStep, getPosFromRange } from '../steps';
|
|
10
10
|
import { getRendererRangeInlineNodeNames, getRendererRangeAncestorNodeNames } from './get-renderer-range-inline-node-names';
|
|
11
11
|
import { getIndexMatch } from './matches-utils';
|
|
12
|
+
import { getSelectionContext } from './selection';
|
|
12
13
|
export default class RendererActions {
|
|
13
14
|
// Any kind of refence is allowed
|
|
14
15
|
// Ignored via go/ees005
|
|
@@ -224,6 +225,12 @@ export default class RendererActions {
|
|
|
224
225
|
}
|
|
225
226
|
return getPosFromRange(range);
|
|
226
227
|
}
|
|
228
|
+
getSelectionContext() {
|
|
229
|
+
return getSelectionContext({
|
|
230
|
+
doc: this.doc,
|
|
231
|
+
schema: this.schema
|
|
232
|
+
});
|
|
233
|
+
}
|
|
227
234
|
getAnnotationMarks() {
|
|
228
235
|
const {
|
|
229
236
|
schema,
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { getFragmentsFromSelection, getLocalIdsFromSelection } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { getPosFromRange, getStartPos, findParent } from '../steps';
|
|
4
|
+
export const getSelectionContext = ({
|
|
5
|
+
doc,
|
|
6
|
+
schema
|
|
7
|
+
}) => {
|
|
8
|
+
if (!doc || !schema) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const selection = document.getSelection();
|
|
12
|
+
if (!selection || selection.type !== 'Range' || selection.rangeCount !== 1) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
const range = selection.getRangeAt(0);
|
|
16
|
+
if (range.collapsed) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const startNode = findParent(range.startContainer);
|
|
20
|
+
const endNode = findParent(range.endContainer);
|
|
21
|
+
if (!startNode || !endNode) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const startPos = getStartPos(startNode);
|
|
25
|
+
const endPos = getStartPos(endNode);
|
|
26
|
+
if (startPos === null || endPos === null) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const pos = getPosFromRange(range);
|
|
30
|
+
if (!pos) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const from = Math.min(pos.from, pos.to);
|
|
34
|
+
const to = Math.max(pos.from, pos.to);
|
|
35
|
+
if (from === to) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
let pmSelection;
|
|
39
|
+
try {
|
|
40
|
+
pmSelection = TextSelection.create(doc, from, to);
|
|
41
|
+
} catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
const startIndex = from - startPos;
|
|
45
|
+
const endIndex = to - endPos;
|
|
46
|
+
if (startIndex < 0 || endIndex < 0) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const selectionFragment = getFragmentsFromSelection(pmSelection);
|
|
50
|
+
const localIds = getLocalIdsFromSelection(pmSelection);
|
|
51
|
+
return {
|
|
52
|
+
localIds,
|
|
53
|
+
selectionFragment,
|
|
54
|
+
selectionMarkdown: null,
|
|
55
|
+
startIndex,
|
|
56
|
+
endIndex
|
|
57
|
+
};
|
|
58
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
function getStartPos(element) {
|
|
3
|
+
export function getStartPos(element) {
|
|
4
4
|
return parseInt(element.dataset.rendererStartPos || '-1', 10);
|
|
5
5
|
}
|
|
6
6
|
const getNodeType = element => element.dataset.nodeType;
|
|
7
7
|
function isPositionPointer(element) {
|
|
8
8
|
return getStartPos(element) > -1;
|
|
9
9
|
}
|
|
10
|
-
function findParent(element) {
|
|
10
|
+
export function findParent(element) {
|
|
11
11
|
const {
|
|
12
12
|
parentElement
|
|
13
13
|
} = element;
|
|
14
|
-
if (!parentElement ||
|
|
14
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
if (isPositionPointer(parentElement)) {
|
|
@@ -23,7 +23,7 @@ function findMediaParent(element) {
|
|
|
23
23
|
const {
|
|
24
24
|
parentElement
|
|
25
25
|
} = element;
|
|
26
|
-
if (!parentElement ||
|
|
26
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
29
|
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
@@ -35,7 +35,7 @@ function findParentBeforePointer(element) {
|
|
|
35
35
|
const {
|
|
36
36
|
parentElement
|
|
37
37
|
} = element;
|
|
38
|
-
if (
|
|
38
|
+
if (isRendererRoot(parentElement) || !parentElement) {
|
|
39
39
|
return null;
|
|
40
40
|
}
|
|
41
41
|
if (isPositionPointer(parentElement)) {
|
|
@@ -132,7 +132,7 @@ function resolveNodePos(node) {
|
|
|
132
132
|
}
|
|
133
133
|
return resolvedPos;
|
|
134
134
|
}
|
|
135
|
-
export function
|
|
135
|
+
export function isRendererRoot(element) {
|
|
136
136
|
return !!element && element.classList.contains('ak-renderer-document');
|
|
137
137
|
}
|
|
138
138
|
export function resolvePos(node, offset, findEnd = false) {
|
|
@@ -2524,7 +2524,7 @@ export const RendererStyleContainer = props => {
|
|
|
2524
2524
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
2525
2525
|
fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStylesCommentHeightFix, expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? baseOtherStyles : baseOtherStylesDuplicateAnchor, !expValEquals('platform_editor_flex_based_centering', 'isEnabled', true) && extensionCenterAlignLegacyStyles,
|
|
2526
2526
|
// this should be placed after baseOtherStyles
|
|
2527
|
-
expValEquals('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && (expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle),
|
|
2527
|
+
expValEquals('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && (expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle), inlineExtensionRendererMarginFix, allowNestedHeaderLinks && (expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? alignedHeadingAnchorStyle : alignedHeadingAnchorStyleDuplicateAnchor), mediaSingleSharedStyle,
|
|
2528
2528
|
// merge firstWrappedMediaStyles with mediaSingleSharedStyle when clean up platform_editor_fix_media_in_renderer
|
|
2529
2529
|
fg('platform_editor_fix_media_in_renderer') && firstWrappedMediaStyles, tableSharedStyle, tableRendererHeaderStylesForTableCellOnly, fg('platform_editor_bordered_panel_nested_in_table') && tableRendererNestedPanelStyles, isBackgroundClipBrowserFixNeeded() && tableStylesBackGroundClipForGeckoForTableCellOnly, fg('platform_editor_nested_dnd_styles_changes') ? firstNodeWithNotMarginTopWithNestedDnD : firstNodeWithNotMarginTop, rendererTableStyles, isStickyScrollbarEnabled(appearance) && stickyScrollbarStyles, rendererTableHeaderEqualHeightStylesForTableCellOnly, allowColumnSorting && rendererTableSortableColumnStyles, allowColumnSorting && allowNestedHeaderLinks && (expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinks : rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinksDuplicateAnchor), rendererTableColumnStyles, stickyHeaderStyles, codeBlockAndLayoutStyles, columnLayoutSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveRendererStyles, isAdvancedLayoutsOn && layoutSectionForAdvancedLayoutsStyles, !useBlockRenderForCodeBlock && gridRenderForCodeBlockStyles, browser.safari && codeBlockInListSafariFixStyles, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && responsiveBreakoutWidth, appearance === 'full-page' && isPreviewPanelResponsivenessOn && responsiveBreakoutWidthWithReducedPadding, (appearance === 'full-width' || appearance === 'max' && (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true))) && responsiveBreakoutWidthFullWidth, expValEquals('platform_editor_lovability_emoji_scaling', 'isEnabled', true) ? isCompactModeEnabled ? scaledDenseEmojiStyles : scaledEmojiStyles : isCompactModeEnabled ? denseStyles : undefined, editorExperiment('platform_synced_block', true) && syncBlockStyles, centerWrapperStyles],
|
|
2530
2530
|
"data-testid": testId
|
|
@@ -57,7 +57,7 @@ export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
57
57
|
const TABLE_INFO_TIMEOUT = 10000;
|
|
58
58
|
const RENDER_EVENT_SAMPLE_RATE = 0.2;
|
|
59
59
|
const packageName = "@atlaskit/renderer";
|
|
60
|
-
const packageVersion = "126.
|
|
60
|
+
const packageVersion = "126.16.0";
|
|
61
61
|
const setAsQueryContainerStyles = css({
|
|
62
62
|
containerName: 'ak-renderer-wrapper',
|
|
63
63
|
containerType: 'inline-size'
|
|
@@ -14,6 +14,7 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
14
14
|
import { createAnnotationStep, getPosFromRange } from '../steps';
|
|
15
15
|
import { getRendererRangeInlineNodeNames, getRendererRangeAncestorNodeNames } from './get-renderer-range-inline-node-names';
|
|
16
16
|
import { getIndexMatch } from './matches-utils';
|
|
17
|
+
import { getSelectionContext as _getSelectionContext } from './selection';
|
|
17
18
|
var RendererActions = /*#__PURE__*/function () {
|
|
18
19
|
// Any kind of refence is allowed
|
|
19
20
|
// Ignored via go/ees005
|
|
@@ -243,6 +244,14 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
243
244
|
}
|
|
244
245
|
return getPosFromRange(range);
|
|
245
246
|
}
|
|
247
|
+
}, {
|
|
248
|
+
key: "getSelectionContext",
|
|
249
|
+
value: function getSelectionContext() {
|
|
250
|
+
return _getSelectionContext({
|
|
251
|
+
doc: this.doc,
|
|
252
|
+
schema: this.schema
|
|
253
|
+
});
|
|
254
|
+
}
|
|
246
255
|
}, {
|
|
247
256
|
key: "getAnnotationMarks",
|
|
248
257
|
value: function getAnnotationMarks() {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import { getFragmentsFromSelection, getLocalIdsFromSelection } from '@atlaskit/editor-common/selection';
|
|
3
|
+
import { getPosFromRange, getStartPos, findParent } from '../steps';
|
|
4
|
+
export var getSelectionContext = function getSelectionContext(_ref) {
|
|
5
|
+
var doc = _ref.doc,
|
|
6
|
+
schema = _ref.schema;
|
|
7
|
+
if (!doc || !schema) {
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
var selection = document.getSelection();
|
|
11
|
+
if (!selection || selection.type !== 'Range' || selection.rangeCount !== 1) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
var range = selection.getRangeAt(0);
|
|
15
|
+
if (range.collapsed) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
var startNode = findParent(range.startContainer);
|
|
19
|
+
var endNode = findParent(range.endContainer);
|
|
20
|
+
if (!startNode || !endNode) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
var startPos = getStartPos(startNode);
|
|
24
|
+
var endPos = getStartPos(endNode);
|
|
25
|
+
if (startPos === null || endPos === null) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
var pos = getPosFromRange(range);
|
|
29
|
+
if (!pos) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
var from = Math.min(pos.from, pos.to);
|
|
33
|
+
var to = Math.max(pos.from, pos.to);
|
|
34
|
+
if (from === to) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
var pmSelection;
|
|
38
|
+
try {
|
|
39
|
+
pmSelection = TextSelection.create(doc, from, to);
|
|
40
|
+
} catch (_unused) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
var startIndex = from - startPos;
|
|
44
|
+
var endIndex = to - endPos;
|
|
45
|
+
if (startIndex < 0 || endIndex < 0) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
var selectionFragment = getFragmentsFromSelection(pmSelection);
|
|
49
|
+
var localIds = getLocalIdsFromSelection(pmSelection);
|
|
50
|
+
return {
|
|
51
|
+
localIds: localIds,
|
|
52
|
+
selectionFragment: selectionFragment,
|
|
53
|
+
selectionMarkdown: null,
|
|
54
|
+
startIndex: startIndex,
|
|
55
|
+
endIndex: endIndex
|
|
56
|
+
};
|
|
57
|
+
};
|
package/dist/esm/steps/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
function getStartPos(element) {
|
|
3
|
+
export function getStartPos(element) {
|
|
4
4
|
return parseInt(element.dataset.rendererStartPos || '-1', 10);
|
|
5
5
|
}
|
|
6
6
|
var getNodeType = function getNodeType(element) {
|
|
@@ -9,9 +9,9 @@ var getNodeType = function getNodeType(element) {
|
|
|
9
9
|
function isPositionPointer(element) {
|
|
10
10
|
return getStartPos(element) > -1;
|
|
11
11
|
}
|
|
12
|
-
function findParent(element) {
|
|
12
|
+
export function findParent(element) {
|
|
13
13
|
var parentElement = element.parentElement;
|
|
14
|
-
if (!parentElement ||
|
|
14
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
17
|
if (isPositionPointer(parentElement)) {
|
|
@@ -21,7 +21,7 @@ function findParent(element) {
|
|
|
21
21
|
}
|
|
22
22
|
function findMediaParent(element) {
|
|
23
23
|
var parentElement = element.parentElement;
|
|
24
|
-
if (!parentElement ||
|
|
24
|
+
if (!parentElement || isRendererRoot(parentElement)) {
|
|
25
25
|
return null;
|
|
26
26
|
}
|
|
27
27
|
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
@@ -31,7 +31,7 @@ function findMediaParent(element) {
|
|
|
31
31
|
}
|
|
32
32
|
function findParentBeforePointer(element) {
|
|
33
33
|
var parentElement = element.parentElement;
|
|
34
|
-
if (
|
|
34
|
+
if (isRendererRoot(parentElement) || !parentElement) {
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
if (isPositionPointer(parentElement)) {
|
|
@@ -128,7 +128,7 @@ function resolveNodePos(node) {
|
|
|
128
128
|
}
|
|
129
129
|
return resolvedPos;
|
|
130
130
|
}
|
|
131
|
-
export function
|
|
131
|
+
export function isRendererRoot(element) {
|
|
132
132
|
return !!element && element.classList.contains('ak-renderer-document');
|
|
133
133
|
}
|
|
134
134
|
export function resolvePos(node, offset) {
|
|
@@ -1974,7 +1974,7 @@ export var RendererStyleContainer = function RendererStyleContainer(props) {
|
|
|
1974
1974
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
1975
1975
|
fg('editor_inline_comments_on_inline_nodes') && rendererAnnotationStylesCommentHeightFix, expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? baseOtherStyles : baseOtherStylesDuplicateAnchor, !expValEquals('platform_editor_flex_based_centering', 'isEnabled', true) && extensionCenterAlignLegacyStyles,
|
|
1976
1976
|
// this should be placed after baseOtherStyles
|
|
1977
|
-
expValEquals('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && (expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle),
|
|
1977
|
+
expValEquals('platform_editor_render_bodied_extension_as_inline', 'isEnabled', true) && (expValEquals('platform_editor_remove_important_in_render_ext', 'isEnabled', true) ? extensionAsInlineStyle : oldExtensionAsInlineStyle), inlineExtensionRendererMarginFix, allowNestedHeaderLinks && (expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? alignedHeadingAnchorStyle : alignedHeadingAnchorStyleDuplicateAnchor), mediaSingleSharedStyle,
|
|
1978
1978
|
// merge firstWrappedMediaStyles with mediaSingleSharedStyle when clean up platform_editor_fix_media_in_renderer
|
|
1979
1979
|
fg('platform_editor_fix_media_in_renderer') && firstWrappedMediaStyles, tableSharedStyle, tableRendererHeaderStylesForTableCellOnly, fg('platform_editor_bordered_panel_nested_in_table') && tableRendererNestedPanelStyles, isBackgroundClipBrowserFixNeeded() && tableStylesBackGroundClipForGeckoForTableCellOnly, fg('platform_editor_nested_dnd_styles_changes') ? firstNodeWithNotMarginTopWithNestedDnD : firstNodeWithNotMarginTop, rendererTableStyles, isStickyScrollbarEnabled(appearance) && stickyScrollbarStyles, rendererTableHeaderEqualHeightStylesForTableCellOnly, allowColumnSorting && rendererTableSortableColumnStyles, allowColumnSorting && allowNestedHeaderLinks && (expValEquals('platform_editor_copy_link_a11y_inconsistency_fix', 'isEnabled', true) ? rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinks : rendererTableHeaderEqualHeightStylesAllowNestedHeaderLinksDuplicateAnchor), rendererTableColumnStyles, stickyHeaderStyles, codeBlockAndLayoutStyles, columnLayoutSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveSharedStyle, isAdvancedLayoutsOn && columnLayoutResponsiveRendererStyles, isAdvancedLayoutsOn && layoutSectionForAdvancedLayoutsStyles, !useBlockRenderForCodeBlock && gridRenderForCodeBlockStyles, browser.safari && codeBlockInListSafariFixStyles, appearance === 'full-page' && !isPreviewPanelResponsivenessOn && responsiveBreakoutWidth, appearance === 'full-page' && isPreviewPanelResponsivenessOn && responsiveBreakoutWidthWithReducedPadding, (appearance === 'full-width' || appearance === 'max' && (expValEquals('editor_tinymce_full_width_mode', 'isEnabled', true) || expValEquals('confluence_max_width_content_appearance', 'isEnabled', true))) && responsiveBreakoutWidthFullWidth, expValEquals('platform_editor_lovability_emoji_scaling', 'isEnabled', true) ? isCompactModeEnabled ? scaledDenseEmojiStyles : scaledEmojiStyles : isCompactModeEnabled ? denseStyles : undefined, editorExperiment('platform_synced_block', true) && syncBlockStyles, centerWrapperStyles],
|
|
1980
1980
|
"data-testid": testId
|
|
@@ -62,7 +62,7 @@ export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
|
62
62
|
var TABLE_INFO_TIMEOUT = 10000;
|
|
63
63
|
var RENDER_EVENT_SAMPLE_RATE = 0.2;
|
|
64
64
|
var packageName = "@atlaskit/renderer";
|
|
65
|
-
var packageVersion = "126.
|
|
65
|
+
var packageVersion = "126.16.0";
|
|
66
66
|
var setAsQueryContainerStyles = css({
|
|
67
67
|
containerName: 'ak-renderer-wrapper',
|
|
68
68
|
containerType: 'inline-size'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { AnnotationActionResult, AnnotationByMatches } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnnotationActionResult, AnnotationByMatches, SelectionContext } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { Mark, Node, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
@@ -31,7 +31,10 @@ interface AnnotationsRendererActionsOptions {
|
|
|
31
31
|
interface PositionRendererActionsOptions {
|
|
32
32
|
getPositionFromRange: (range: Range) => Position | false;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
interface SelectionRendererActionsOptions {
|
|
35
|
+
getSelectionContext: () => SelectionContext | null;
|
|
36
|
+
}
|
|
37
|
+
export default class RendererActions implements RendererActionsOptions, AnnotationsRendererActionsOptions, PositionRendererActionsOptions, SelectionRendererActionsOptions {
|
|
35
38
|
private initFromContext;
|
|
36
39
|
private transformer;
|
|
37
40
|
doc?: Node;
|
|
@@ -63,6 +66,7 @@ export default class RendererActions implements RendererActionsOptions, Annotati
|
|
|
63
66
|
* Note: False indicates that the selection not able to be calculated.
|
|
64
67
|
*/
|
|
65
68
|
getPositionFromRange(range: Range | null): Position | false;
|
|
69
|
+
getSelectionContext(): SelectionContext | null;
|
|
66
70
|
getAnnotationMarks(): Mark[];
|
|
67
71
|
getAnnotationsByPosition(range: Range): string[];
|
|
68
72
|
applyAnnotation(pos: Position, annotation: Annotation): AnnotationActionResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectionContext } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
type GetSelectionContextOptions = {
|
|
4
|
+
doc?: PMNode;
|
|
5
|
+
schema?: Schema;
|
|
6
|
+
};
|
|
7
|
+
export declare const getSelectionContext: ({ doc, schema, }: GetSelectionContextOptions) => SelectionContext | null;
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getStartPos(element: HTMLElement): number;
|
|
4
|
+
export declare function findParent(element: ChildNode | Node): HTMLElement | null;
|
|
5
|
+
export declare function isRendererRoot(element: HTMLElement | null): boolean;
|
|
4
6
|
export declare function resolvePos(node: Node | null, offset: number, findEnd?: boolean): number | false;
|
|
5
7
|
interface AnnotationStepOptions {
|
|
6
8
|
annotationId: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { AnnotationActionResult, AnnotationByMatches } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnnotationActionResult, AnnotationByMatches, SelectionContext } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { Mark, Node, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { Step } from '@atlaskit/editor-prosemirror/transform';
|
|
@@ -31,7 +31,10 @@ interface AnnotationsRendererActionsOptions {
|
|
|
31
31
|
interface PositionRendererActionsOptions {
|
|
32
32
|
getPositionFromRange: (range: Range) => Position | false;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
interface SelectionRendererActionsOptions {
|
|
35
|
+
getSelectionContext: () => SelectionContext | null;
|
|
36
|
+
}
|
|
37
|
+
export default class RendererActions implements RendererActionsOptions, AnnotationsRendererActionsOptions, PositionRendererActionsOptions, SelectionRendererActionsOptions {
|
|
35
38
|
private initFromContext;
|
|
36
39
|
private transformer;
|
|
37
40
|
doc?: Node;
|
|
@@ -63,6 +66,7 @@ export default class RendererActions implements RendererActionsOptions, Annotati
|
|
|
63
66
|
* Note: False indicates that the selection not able to be calculated.
|
|
64
67
|
*/
|
|
65
68
|
getPositionFromRange(range: Range | null): Position | false;
|
|
69
|
+
getSelectionContext(): SelectionContext | null;
|
|
66
70
|
getAnnotationMarks(): Mark[];
|
|
67
71
|
getAnnotationsByPosition(range: Range): string[];
|
|
68
72
|
applyAnnotation(pos: Position, annotation: Annotation): AnnotationActionResult;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectionContext } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
+
type GetSelectionContextOptions = {
|
|
4
|
+
doc?: PMNode;
|
|
5
|
+
schema?: Schema;
|
|
6
|
+
};
|
|
7
|
+
export declare const getSelectionContext: ({ doc, schema, }: GetSelectionContextOptions) => SelectionContext | null;
|
|
8
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function getStartPos(element: HTMLElement): number;
|
|
4
|
+
export declare function findParent(element: ChildNode | Node): HTMLElement | null;
|
|
5
|
+
export declare function isRendererRoot(element: HTMLElement | null): boolean;
|
|
4
6
|
export declare function resolvePos(node: Node | null, offset: number, findEnd?: boolean): number | false;
|
|
5
7
|
interface AnnotationStepOptions {
|
|
6
8
|
annotationId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "127.0.0",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@atlaskit/status": "^3.1.0",
|
|
58
58
|
"@atlaskit/task-decision": "^19.3.0",
|
|
59
59
|
"@atlaskit/theme": "^22.0.0",
|
|
60
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
60
|
+
"@atlaskit/tmp-editor-statsig": "^34.0.0",
|
|
61
61
|
"@atlaskit/tokens": "^11.0.0",
|
|
62
62
|
"@atlaskit/tooltip": "^20.14.0",
|
|
63
63
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -235,15 +235,16 @@
|
|
|
235
235
|
"platform_editor_table_fixed_column_width_prop": {
|
|
236
236
|
"type": "boolean"
|
|
237
237
|
},
|
|
238
|
-
"confluence_insert_excerpt_inline_vertical_align": {
|
|
239
|
-
"type": "boolean"
|
|
240
|
-
},
|
|
241
238
|
"confluence_ttvc_inline_extensions": {
|
|
242
239
|
"type": "boolean"
|
|
243
240
|
},
|
|
244
241
|
"platform_editor_native_embeds_fallback_transform": {
|
|
245
242
|
"type": "boolean"
|
|
246
243
|
},
|
|
244
|
+
"platform_editor_renderer_selection_context": {
|
|
245
|
+
"type": "boolean",
|
|
246
|
+
"referenceOnly": "true"
|
|
247
|
+
},
|
|
247
248
|
"platform_synced_block_patch_5": {
|
|
248
249
|
"type": "boolean"
|
|
249
250
|
}
|