@atlaskit/renderer 126.15.0 → 126.16.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 +19 -0
- package/dist/cjs/actions/index.js +9 -0
- package/dist/cjs/actions/selection.js +63 -0
- package/dist/cjs/react/nodes/table.js +3 -2
- package/dist/cjs/steps/index.js +7 -5
- 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/react/nodes/table.js +3 -2
- package/dist/es2019/steps/index.js +6 -6
- 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/react/nodes/table.js +3 -2
- package/dist/esm/steps/index.js +6 -6
- 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 +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 126.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`10f36a235eedd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/10f36a235eedd) -
|
|
8
|
+
Add getSelectionContext to RendererActions
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 126.15.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`4f700a8131d20`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4f700a8131d20) -
|
|
19
|
+
[FFCLEANUP-79468] fix "landmark-unique" violation in TableWrapper component
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 126.15.0
|
|
4
23
|
|
|
5
24
|
### Minor 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
|
+
};
|
|
@@ -147,6 +147,7 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
147
147
|
tabIndex = _ref2.tabIndex;
|
|
148
148
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
149
149
|
formatMessage = _useIntl.formatMessage;
|
|
150
|
+
var isScrollableRegion = tabIndex !== undefined && (0, _expValEquals.expValEquals)('platform_editor_a11y_table_wrapper_fix', 'isEnabled', true);
|
|
150
151
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
151
152
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
152
153
|
className: _styles.TableSharedCssClassName.TABLE_NODE_WRAPPER,
|
|
@@ -156,8 +157,8 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
156
157
|
// eslint-disable-next-line @atlassian/a11y/no-noninteractive-tabindex
|
|
157
158
|
,
|
|
158
159
|
tabIndex: tabIndex,
|
|
159
|
-
role:
|
|
160
|
-
"aria-label": formatMessage(_messages.tableMessages.tableScrollRegion)
|
|
160
|
+
role: isScrollableRegion ? 'region' : undefined,
|
|
161
|
+
"aria-label": isScrollableRegion ? formatMessage(_messages.tableMessages.tableScrollRegion) : undefined
|
|
161
162
|
}, children);
|
|
162
163
|
};
|
|
163
164
|
var tableCanBeSticky = exports.tableCanBeSticky = function tableCanBeSticky(node, children
|
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) {
|
|
@@ -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 = "
|
|
74
|
+
var packageVersion = "126.15.1";
|
|
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
|
+
};
|
|
@@ -118,6 +118,7 @@ const TableWrapper = ({
|
|
|
118
118
|
const {
|
|
119
119
|
formatMessage
|
|
120
120
|
} = useIntl();
|
|
121
|
+
const isScrollableRegion = tabIndex !== undefined && expValEquals('platform_editor_a11y_table_wrapper_fix', 'isEnabled', true);
|
|
121
122
|
return /*#__PURE__*/React.createElement("div", {
|
|
122
123
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
123
124
|
className: TableSharedCssClassName.TABLE_NODE_WRAPPER,
|
|
@@ -127,8 +128,8 @@ const TableWrapper = ({
|
|
|
127
128
|
// eslint-disable-next-line @atlassian/a11y/no-noninteractive-tabindex
|
|
128
129
|
,
|
|
129
130
|
tabIndex: tabIndex,
|
|
130
|
-
role:
|
|
131
|
-
"aria-label": formatMessage(tableMessages.tableScrollRegion)
|
|
131
|
+
role: isScrollableRegion ? 'region' : undefined,
|
|
132
|
+
"aria-label": isScrollableRegion ? formatMessage(tableMessages.tableScrollRegion) : undefined
|
|
132
133
|
}, children);
|
|
133
134
|
};
|
|
134
135
|
export const tableCanBeSticky = (node, children
|
|
@@ -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) {
|
|
@@ -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 = "
|
|
60
|
+
const packageVersion = "126.15.1";
|
|
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
|
+
};
|
|
@@ -140,6 +140,7 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
140
140
|
tabIndex = _ref2.tabIndex;
|
|
141
141
|
var _useIntl = useIntl(),
|
|
142
142
|
formatMessage = _useIntl.formatMessage;
|
|
143
|
+
var isScrollableRegion = tabIndex !== undefined && expValEquals('platform_editor_a11y_table_wrapper_fix', 'isEnabled', true);
|
|
143
144
|
return /*#__PURE__*/React.createElement("div", {
|
|
144
145
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
145
146
|
className: TableSharedCssClassName.TABLE_NODE_WRAPPER,
|
|
@@ -149,8 +150,8 @@ var TableWrapper = function TableWrapper(_ref2) {
|
|
|
149
150
|
// eslint-disable-next-line @atlassian/a11y/no-noninteractive-tabindex
|
|
150
151
|
,
|
|
151
152
|
tabIndex: tabIndex,
|
|
152
|
-
role:
|
|
153
|
-
"aria-label": formatMessage(tableMessages.tableScrollRegion)
|
|
153
|
+
role: isScrollableRegion ? 'region' : undefined,
|
|
154
|
+
"aria-label": isScrollableRegion ? formatMessage(tableMessages.tableScrollRegion) : undefined
|
|
154
155
|
}, children);
|
|
155
156
|
};
|
|
156
157
|
export var tableCanBeSticky = function tableCanBeSticky(node, children
|
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) {
|
|
@@ -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 = "
|
|
65
|
+
var packageVersion = "126.15.1";
|
|
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": "126.
|
|
3
|
+
"version": "126.16.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": "^33.
|
|
60
|
+
"@atlaskit/tmp-editor-statsig": "^33.2.0",
|
|
61
61
|
"@atlaskit/tokens": "^11.0.0",
|
|
62
62
|
"@atlaskit/tooltip": "^20.14.0",
|
|
63
63
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"uuid": "^3.1.0"
|
|
72
72
|
},
|
|
73
73
|
"peerDependencies": {
|
|
74
|
-
"@atlaskit/editor-common": "^111.
|
|
74
|
+
"@atlaskit/editor-common": "^111.28.0",
|
|
75
75
|
"@atlaskit/link-provider": "^4.2.0",
|
|
76
76
|
"@atlaskit/media-core": "^37.0.0",
|
|
77
77
|
"react": "^18.2.0",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"@atlaskit/mention": "^24.5.0",
|
|
91
91
|
"@atlaskit/modal-dialog": "^14.11.0",
|
|
92
92
|
"@atlaskit/navigation-next": "patch:@atlaskit/navigation-next@npm%3A9.0.17#~/.yarn/patches/@atlaskit-navigation-next-npm-9.0.17-958ca0ab9d.patch",
|
|
93
|
-
"@atlaskit/profilecard": "^24.
|
|
93
|
+
"@atlaskit/profilecard": "^24.40.0",
|
|
94
94
|
"@atlaskit/util-data-test": "^18.5.0",
|
|
95
95
|
"@atlassian/a11y-jest-testing": "^0.11.0",
|
|
96
96
|
"@atlassian/feature-flags-test-utils": "^1.0.0",
|
|
@@ -244,6 +244,10 @@
|
|
|
244
244
|
"platform_editor_native_embeds_fallback_transform": {
|
|
245
245
|
"type": "boolean"
|
|
246
246
|
},
|
|
247
|
+
"platform_editor_renderer_selection_context": {
|
|
248
|
+
"type": "boolean",
|
|
249
|
+
"referenceOnly": "true"
|
|
250
|
+
},
|
|
247
251
|
"platform_synced_block_patch_5": {
|
|
248
252
|
"type": "boolean"
|
|
249
253
|
}
|