@atlaskit/renderer 109.19.1 → 109.19.3
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 +12 -0
- package/dist/cjs/actions/index.js +1 -1
- package/dist/cjs/react/nodes/media/index.js +14 -7
- package/dist/cjs/steps/index.js +12 -5
- package/dist/cjs/ui/Renderer/index.js +1 -1
- package/dist/cjs/ui/annotations/element/mark.js +5 -0
- package/dist/es2019/actions/index.js +1 -1
- package/dist/es2019/react/nodes/media/index.js +24 -5
- package/dist/es2019/steps/index.js +14 -3
- package/dist/es2019/ui/Renderer/index.js +1 -1
- package/dist/es2019/ui/annotations/element/mark.js +5 -0
- package/dist/esm/actions/index.js +1 -1
- package/dist/esm/react/nodes/media/index.js +12 -5
- package/dist/esm/steps/index.js +12 -5
- package/dist/esm/ui/Renderer/index.js +1 -1
- package/dist/esm/ui/annotations/element/mark.js +5 -0
- package/dist/types/react/nodes/media/index.d.ts +2 -0
- package/dist/types/react/types.d.ts +1 -0
- package/dist/types-ts4.5/react/nodes/media/index.d.ts +2 -0
- package/dist/types-ts4.5/react/types.d.ts +1 -0
- package/package.json +2 -2
- package/dist/cjs/react/nodes/media/styles.js +0 -14
- package/dist/es2019/react/nodes/media/styles.js +0 -19
- package/dist/esm/react/nodes/media/styles.js +0 -7
- package/dist/types/react/nodes/media/styles.d.ts +0 -2
- package/dist/types-ts4.5/react/nodes/media/styles.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/renderer
|
|
2
2
|
|
|
3
|
+
## 109.19.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92483](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92483) [`bd8804c2b4ad`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bd8804c2b4ad) - Allow realtime comments to correctly infer position of comment on media
|
|
8
|
+
|
|
9
|
+
## 109.19.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#91468](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91468) [`4ad8a0bc6051`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4ad8a0bc6051) - Fixes preview linking and annotation flow on media with annotation
|
|
14
|
+
|
|
3
15
|
## 109.19.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -230,7 +230,7 @@ var RendererActions = exports.default = /*#__PURE__*/function () {
|
|
|
230
230
|
|
|
231
231
|
// If from points to a node position,
|
|
232
232
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
233
|
-
var beforeNodePos = Math.max(from
|
|
233
|
+
var beforeNodePos = Math.max(from, 0);
|
|
234
234
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
235
235
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
236
236
|
step = new _transform.AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default = void 0;
|
|
8
|
+
exports.linkStyle = exports.default = exports.borderStyle = void 0;
|
|
9
9
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
11
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
@@ -16,6 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
16
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
17
17
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
18
18
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
19
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
19
20
|
var _react = _interopRequireWildcard(require("react"));
|
|
20
21
|
var _react2 = require("@emotion/react");
|
|
21
22
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
@@ -30,12 +31,12 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
30
31
|
var _events = require("../../../analytics/events");
|
|
31
32
|
var _annotation = _interopRequireDefault(require("../../marks/annotation"));
|
|
32
33
|
var _context = require("../../../ui/annotations/context");
|
|
33
|
-
var _styles = require("./styles");
|
|
34
34
|
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
35
35
|
var _reactIntlNext = require("react-intl-next");
|
|
36
36
|
var _hooks = require("../../../ui/annotations/hooks");
|
|
37
37
|
var _types = require("@atlaskit/editor-common/types");
|
|
38
38
|
var _excluded = ["marks", "mediaElement", "isDrafting"];
|
|
39
|
+
var _templateObject, _templateObject2;
|
|
39
40
|
/** @jsx jsx */
|
|
40
41
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
41
42
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -43,6 +44,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
43
44
|
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; }
|
|
44
45
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
45
46
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
47
|
+
var linkStyle = exports.linkStyle = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n background: transparent;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n cursor: pointer;\n width: 100% !important;\n height: 100% !important;\n"])));
|
|
48
|
+
var borderStyle = exports.borderStyle = function borderStyle(color, width) {
|
|
49
|
+
return (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 100% !important;\n height: 100% !important;\n border-radius: ", "px;\n box-shadow: 0 0 0 ", "px ", ";\n"])), width, width, color);
|
|
50
|
+
};
|
|
46
51
|
var MediaBorder = function MediaBorder(_ref) {
|
|
47
52
|
var _mark$attrs$color, _mark$attrs$size;
|
|
48
53
|
var mark = _ref.mark,
|
|
@@ -57,7 +62,7 @@ var MediaBorder = function MediaBorder(_ref) {
|
|
|
57
62
|
"data-mark-type": "border",
|
|
58
63
|
"data-color": borderColor,
|
|
59
64
|
"data-size": borderWidth,
|
|
60
|
-
css:
|
|
65
|
+
css: borderStyle(paletteColorValue, borderWidth)
|
|
61
66
|
}, (0, _react2.jsx)(_ui.MediaBorderGapFiller, {
|
|
62
67
|
borderColor: borderColor
|
|
63
68
|
}), children);
|
|
@@ -75,7 +80,7 @@ var MediaLink = function MediaLink(_ref2) {
|
|
|
75
80
|
rel: "noreferrer noopener",
|
|
76
81
|
onClick: onClick,
|
|
77
82
|
"data-block-link": linkHref,
|
|
78
|
-
css:
|
|
83
|
+
css: linkStyle
|
|
79
84
|
}, children);
|
|
80
85
|
};
|
|
81
86
|
var MediaAnnotation = function MediaAnnotation(_ref3) {
|
|
@@ -88,7 +93,8 @@ var MediaAnnotation = function MediaAnnotation(_ref3) {
|
|
|
88
93
|
id: mark.attrs.id,
|
|
89
94
|
annotationType: mark.attrs.annotationType,
|
|
90
95
|
dataAttributes: {
|
|
91
|
-
'data-renderer-mark': true
|
|
96
|
+
'data-renderer-mark': true,
|
|
97
|
+
'data-block-mark': true
|
|
92
98
|
}
|
|
93
99
|
// This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
|
|
94
100
|
,
|
|
@@ -166,6 +172,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
166
172
|
return null;
|
|
167
173
|
}
|
|
168
174
|
var onClick = function onClick(e) {
|
|
175
|
+
e.preventDefault();
|
|
169
176
|
if (updateSubscriber) {
|
|
170
177
|
updateSubscriber.emit(_types.AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
171
178
|
annotationIds: activeParentIds,
|
|
@@ -300,9 +307,9 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
300
307
|
if (pos === undefined) {
|
|
301
308
|
return;
|
|
302
309
|
}
|
|
303
|
-
if (draftPosition !== null && draftPosition.from === pos) {
|
|
310
|
+
if (draftPosition !== null && draftPosition.from + 1 === pos) {
|
|
304
311
|
setShouldApplyDraftAnnotation(true);
|
|
305
|
-
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
312
|
+
setPosition((draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) + 1);
|
|
306
313
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
307
314
|
setShouldApplyDraftAnnotation(false);
|
|
308
315
|
setPosition(undefined);
|
package/dist/cjs/steps/index.js
CHANGED
|
@@ -10,9 +10,6 @@ var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
|
10
10
|
function getStartPos(element) {
|
|
11
11
|
return parseInt(element.dataset.rendererStartPos || '-1', 10);
|
|
12
12
|
}
|
|
13
|
-
var getNodeType = function getNodeType(element) {
|
|
14
|
-
return element.dataset.nodeType;
|
|
15
|
-
};
|
|
16
13
|
function isPositionPointer(element) {
|
|
17
14
|
return getStartPos(element) > -1;
|
|
18
15
|
}
|
|
@@ -26,6 +23,16 @@ function findParent(element) {
|
|
|
26
23
|
}
|
|
27
24
|
return findParent(parentElement);
|
|
28
25
|
}
|
|
26
|
+
function findMediaParent(element) {
|
|
27
|
+
var parentElement = element.parentElement;
|
|
28
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
32
|
+
return parentElement;
|
|
33
|
+
}
|
|
34
|
+
return findParent(parentElement);
|
|
35
|
+
}
|
|
29
36
|
function findParentBeforePointer(element) {
|
|
30
37
|
var parentElement = element.parentElement;
|
|
31
38
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -135,8 +142,8 @@ function getPosFromRange(range) {
|
|
|
135
142
|
startOffset = range.startOffset,
|
|
136
143
|
endContainer = range.endContainer,
|
|
137
144
|
endOffset = range.endOffset;
|
|
138
|
-
var parent =
|
|
139
|
-
if (parent
|
|
145
|
+
var parent = findMediaParent(startContainer);
|
|
146
|
+
if (parent) {
|
|
140
147
|
var pos = getStartPos(parent);
|
|
141
148
|
return {
|
|
142
149
|
from: pos,
|
|
@@ -55,7 +55,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
55
55
|
var NORMAL_SEVERITY_THRESHOLD = exports.NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
56
56
|
var DEGRADED_SEVERITY_THRESHOLD = exports.DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
57
57
|
var packageName = "@atlaskit/renderer";
|
|
58
|
-
var packageVersion = "109.19.
|
|
58
|
+
var packageVersion = "109.19.3";
|
|
59
59
|
var Renderer = exports.Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
60
60
|
(0, _inherits2.default)(Renderer, _PureComponent);
|
|
61
61
|
var _super = _createSuper(Renderer);
|
|
@@ -34,6 +34,11 @@ var MarkComponent = exports.MarkComponent = function MarkComponent(_ref) {
|
|
|
34
34
|
return (0, _toConsumableArray2.default)(new Set([].concat((0, _toConsumableArray2.default)(annotationParentIds), [id])));
|
|
35
35
|
}, [id, annotationParentIds]);
|
|
36
36
|
var onMarkClick = (0, _react.useCallback)(function (event) {
|
|
37
|
+
// prevent inline mark logic for media block marks
|
|
38
|
+
if (event.currentTarget.getAttribute('data-block-mark')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
37
42
|
// prevents multiple callback on overlapping annotations
|
|
38
43
|
if (event.defaultPrevented || state !== _adfSchema.AnnotationMarkStates.ACTIVE) {
|
|
39
44
|
return;
|
|
@@ -208,7 +208,7 @@ export default class RendererActions {
|
|
|
208
208
|
|
|
209
209
|
// If from points to a node position,
|
|
210
210
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
211
|
-
const beforeNodePos = Math.max(from
|
|
211
|
+
const beforeNodePos = Math.max(from, 0);
|
|
212
212
|
const possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
213
213
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
214
214
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
|
|
5
5
|
import React, { PureComponent, Fragment, useEffect, useState, useMemo } from 'react';
|
|
6
|
-
import { jsx } from '@emotion/react';
|
|
6
|
+
import { jsx, css } from '@emotion/react';
|
|
7
7
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
8
8
|
import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
9
9
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -16,11 +16,28 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
16
16
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
17
17
|
import AnnotationComponent from '../../marks/annotation';
|
|
18
18
|
import { AnnotationsDraftContext } from '../../../ui/annotations/context';
|
|
19
|
-
import { linkStyle, borderStyle } from './styles';
|
|
20
19
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
21
20
|
import { injectIntl } from 'react-intl-next';
|
|
22
21
|
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
23
22
|
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
23
|
+
export const linkStyle = css`
|
|
24
|
+
position: absolute;
|
|
25
|
+
background: transparent;
|
|
26
|
+
top: 0;
|
|
27
|
+
right: 0;
|
|
28
|
+
bottom: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
width: 100% !important;
|
|
32
|
+
height: 100% !important;
|
|
33
|
+
`;
|
|
34
|
+
export const borderStyle = (color, width) => css`
|
|
35
|
+
position: absolute;
|
|
36
|
+
width: 100% !important;
|
|
37
|
+
height: 100% !important;
|
|
38
|
+
border-radius: ${width}px;
|
|
39
|
+
box-shadow: 0 0 0 ${width}px ${color};
|
|
40
|
+
`;
|
|
24
41
|
const MediaBorder = ({
|
|
25
42
|
mark,
|
|
26
43
|
children
|
|
@@ -69,7 +86,8 @@ const MediaAnnotation = ({
|
|
|
69
86
|
id: mark.attrs.id,
|
|
70
87
|
annotationType: mark.attrs.annotationType,
|
|
71
88
|
dataAttributes: {
|
|
72
|
-
'data-renderer-mark': true
|
|
89
|
+
'data-renderer-mark': true,
|
|
90
|
+
'data-block-mark': true
|
|
73
91
|
}
|
|
74
92
|
// This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
|
|
75
93
|
,
|
|
@@ -139,6 +157,7 @@ const CommentBadgeWrapper = ({
|
|
|
139
157
|
return null;
|
|
140
158
|
}
|
|
141
159
|
const onClick = e => {
|
|
160
|
+
e.preventDefault();
|
|
142
161
|
if (updateSubscriber) {
|
|
143
162
|
updateSubscriber.emit(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
144
163
|
annotationIds: activeParentIds,
|
|
@@ -262,9 +281,9 @@ const MediaWithDraftAnnotation = props => {
|
|
|
262
281
|
if (pos === undefined) {
|
|
263
282
|
return;
|
|
264
283
|
}
|
|
265
|
-
if (draftPosition !== null && draftPosition.from === pos) {
|
|
284
|
+
if (draftPosition !== null && draftPosition.from + 1 === pos) {
|
|
266
285
|
setShouldApplyDraftAnnotation(true);
|
|
267
|
-
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
286
|
+
setPosition((draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) + 1);
|
|
268
287
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
269
288
|
setShouldApplyDraftAnnotation(false);
|
|
270
289
|
setPosition(undefined);
|
|
@@ -2,7 +2,6 @@ import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
2
2
|
function getStartPos(element) {
|
|
3
3
|
return parseInt(element.dataset.rendererStartPos || '-1', 10);
|
|
4
4
|
}
|
|
5
|
-
const getNodeType = element => element.dataset.nodeType;
|
|
6
5
|
function isPositionPointer(element) {
|
|
7
6
|
return getStartPos(element) > -1;
|
|
8
7
|
}
|
|
@@ -18,6 +17,18 @@ function findParent(element) {
|
|
|
18
17
|
}
|
|
19
18
|
return findParent(parentElement);
|
|
20
19
|
}
|
|
20
|
+
function findMediaParent(element) {
|
|
21
|
+
const {
|
|
22
|
+
parentElement
|
|
23
|
+
} = element;
|
|
24
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
28
|
+
return parentElement;
|
|
29
|
+
}
|
|
30
|
+
return findParent(parentElement);
|
|
31
|
+
}
|
|
21
32
|
function findParentBeforePointer(element) {
|
|
22
33
|
const {
|
|
23
34
|
parentElement
|
|
@@ -131,8 +142,8 @@ export function getPosFromRange(range) {
|
|
|
131
142
|
endContainer,
|
|
132
143
|
endOffset
|
|
133
144
|
} = range;
|
|
134
|
-
const parent =
|
|
135
|
-
if (parent
|
|
145
|
+
const parent = findMediaParent(startContainer);
|
|
146
|
+
if (parent) {
|
|
136
147
|
const pos = getStartPos(parent);
|
|
137
148
|
return {
|
|
138
149
|
from: pos,
|
|
@@ -36,7 +36,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
36
36
|
export const NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
37
37
|
export const DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
38
38
|
const packageName = "@atlaskit/renderer";
|
|
39
|
-
const packageVersion = "109.19.
|
|
39
|
+
const packageVersion = "109.19.3";
|
|
40
40
|
export class Renderer extends PureComponent {
|
|
41
41
|
constructor(props) {
|
|
42
42
|
super(props);
|
|
@@ -33,6 +33,11 @@ export const MarkComponent = ({
|
|
|
33
33
|
}) => {
|
|
34
34
|
const annotationIds = useMemo(() => [...new Set([...annotationParentIds, id])], [id, annotationParentIds]);
|
|
35
35
|
const onMarkClick = useCallback(event => {
|
|
36
|
+
// prevent inline mark logic for media block marks
|
|
37
|
+
if (event.currentTarget.getAttribute('data-block-mark')) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
36
41
|
// prevents multiple callback on overlapping annotations
|
|
37
42
|
if (event.defaultPrevented || state !== AnnotationMarkStates.ACTIVE) {
|
|
38
43
|
return;
|
|
@@ -223,7 +223,7 @@ var RendererActions = /*#__PURE__*/function () {
|
|
|
223
223
|
|
|
224
224
|
// If from points to a node position,
|
|
225
225
|
// we need to 1 position before it for nodeAt to return the node itself
|
|
226
|
-
var beforeNodePos = Math.max(from
|
|
226
|
+
var beforeNodePos = Math.max(from, 0);
|
|
227
227
|
var possibleNode = this.doc.nodeAt(beforeNodePos);
|
|
228
228
|
if ((possibleNode === null || possibleNode === void 0 ? void 0 : possibleNode.type.name) === 'media') {
|
|
229
229
|
step = new AddNodeMarkStep(beforeNodePos, this.schema.marks.annotation.create({
|
|
@@ -8,7 +8,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
8
8
|
import _extends from "@babel/runtime/helpers/extends";
|
|
9
9
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
10
10
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
11
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
11
12
|
var _excluded = ["marks", "mediaElement", "isDrafting"];
|
|
13
|
+
var _templateObject, _templateObject2;
|
|
12
14
|
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; }
|
|
13
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
16
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -16,7 +18,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
16
18
|
/** @jsx jsx */
|
|
17
19
|
|
|
18
20
|
import React, { PureComponent, Fragment, useEffect, useState, useMemo } from 'react';
|
|
19
|
-
import { jsx } from '@emotion/react';
|
|
21
|
+
import { jsx, css } from '@emotion/react';
|
|
20
22
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
21
23
|
import { MEDIA_CONTEXT } from '@atlaskit/analytics-namespaced-context';
|
|
22
24
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -29,11 +31,14 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
29
31
|
import { MODE, PLATFORM } from '../../../analytics/events';
|
|
30
32
|
import AnnotationComponent from '../../marks/annotation';
|
|
31
33
|
import { AnnotationsDraftContext } from '../../../ui/annotations/context';
|
|
32
|
-
import { linkStyle, borderStyle } from './styles';
|
|
33
34
|
import { CommentBadge as CommentBadgeComponent } from '@atlaskit/editor-common/media-single';
|
|
34
35
|
import { injectIntl } from 'react-intl-next';
|
|
35
36
|
import { useInlineCommentSubscriberContext, useInlineCommentsFilter } from '../../../ui/annotations/hooks';
|
|
36
37
|
import { AnnotationUpdateEvent } from '@atlaskit/editor-common/types';
|
|
38
|
+
export var linkStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n background: transparent;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n cursor: pointer;\n width: 100% !important;\n height: 100% !important;\n"])));
|
|
39
|
+
export var borderStyle = function borderStyle(color, width) {
|
|
40
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n width: 100% !important;\n height: 100% !important;\n border-radius: ", "px;\n box-shadow: 0 0 0 ", "px ", ";\n"])), width, width, color);
|
|
41
|
+
};
|
|
37
42
|
var MediaBorder = function MediaBorder(_ref) {
|
|
38
43
|
var _mark$attrs$color, _mark$attrs$size;
|
|
39
44
|
var mark = _ref.mark,
|
|
@@ -79,7 +84,8 @@ var MediaAnnotation = function MediaAnnotation(_ref3) {
|
|
|
79
84
|
id: mark.attrs.id,
|
|
80
85
|
annotationType: mark.attrs.annotationType,
|
|
81
86
|
dataAttributes: {
|
|
82
|
-
'data-renderer-mark': true
|
|
87
|
+
'data-renderer-mark': true,
|
|
88
|
+
'data-block-mark': true
|
|
83
89
|
}
|
|
84
90
|
// This should be fine being empty [] since the serializer serializeFragmentChild getMarkProps call always passes
|
|
85
91
|
,
|
|
@@ -157,6 +163,7 @@ var CommentBadgeWrapper = function CommentBadgeWrapper(_ref5) {
|
|
|
157
163
|
return null;
|
|
158
164
|
}
|
|
159
165
|
var onClick = function onClick(e) {
|
|
166
|
+
e.preventDefault();
|
|
160
167
|
if (updateSubscriber) {
|
|
161
168
|
updateSubscriber.emit(AnnotationUpdateEvent.ON_ANNOTATION_CLICK, {
|
|
162
169
|
annotationIds: activeParentIds,
|
|
@@ -291,9 +298,9 @@ var MediaWithDraftAnnotation = function MediaWithDraftAnnotation(props) {
|
|
|
291
298
|
if (pos === undefined) {
|
|
292
299
|
return;
|
|
293
300
|
}
|
|
294
|
-
if (draftPosition !== null && draftPosition.from === pos) {
|
|
301
|
+
if (draftPosition !== null && draftPosition.from + 1 === pos) {
|
|
295
302
|
setShouldApplyDraftAnnotation(true);
|
|
296
|
-
setPosition(draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from);
|
|
303
|
+
setPosition((draftPosition === null || draftPosition === void 0 ? void 0 : draftPosition.from) + 1);
|
|
297
304
|
} else if (draftPosition === null && shouldApplyDraftAnnotation) {
|
|
298
305
|
setShouldApplyDraftAnnotation(false);
|
|
299
306
|
setPosition(undefined);
|
package/dist/esm/steps/index.js
CHANGED
|
@@ -2,9 +2,6 @@ import { AddMarkStep } from '@atlaskit/editor-prosemirror/transform';
|
|
|
2
2
|
function getStartPos(element) {
|
|
3
3
|
return parseInt(element.dataset.rendererStartPos || '-1', 10);
|
|
4
4
|
}
|
|
5
|
-
var getNodeType = function getNodeType(element) {
|
|
6
|
-
return element.dataset.nodeType;
|
|
7
|
-
};
|
|
8
5
|
function isPositionPointer(element) {
|
|
9
6
|
return getStartPos(element) > -1;
|
|
10
7
|
}
|
|
@@ -18,6 +15,16 @@ function findParent(element) {
|
|
|
18
15
|
}
|
|
19
16
|
return findParent(parentElement);
|
|
20
17
|
}
|
|
18
|
+
function findMediaParent(element) {
|
|
19
|
+
var parentElement = element.parentElement;
|
|
20
|
+
if (!parentElement || isRoot(parentElement)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
if (parentElement.dataset.nodeType === 'mediaSingle') {
|
|
24
|
+
return parentElement;
|
|
25
|
+
}
|
|
26
|
+
return findParent(parentElement);
|
|
27
|
+
}
|
|
21
28
|
function findParentBeforePointer(element) {
|
|
22
29
|
var parentElement = element.parentElement;
|
|
23
30
|
if (isRoot(parentElement) || !parentElement) {
|
|
@@ -127,8 +134,8 @@ export function getPosFromRange(range) {
|
|
|
127
134
|
startOffset = range.startOffset,
|
|
128
135
|
endContainer = range.endContainer,
|
|
129
136
|
endOffset = range.endOffset;
|
|
130
|
-
var parent =
|
|
131
|
-
if (parent
|
|
137
|
+
var parent = findMediaParent(startContainer);
|
|
138
|
+
if (parent) {
|
|
132
139
|
var pos = getStartPos(parent);
|
|
133
140
|
return {
|
|
134
141
|
from: pos,
|
|
@@ -46,7 +46,7 @@ import { EditorMediaClientProvider } from '../../react/utils/EditorMediaClientPr
|
|
|
46
46
|
export var NORMAL_SEVERITY_THRESHOLD = 2000;
|
|
47
47
|
export var DEGRADED_SEVERITY_THRESHOLD = 3000;
|
|
48
48
|
var packageName = "@atlaskit/renderer";
|
|
49
|
-
var packageVersion = "109.19.
|
|
49
|
+
var packageVersion = "109.19.3";
|
|
50
50
|
export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
51
51
|
_inherits(Renderer, _PureComponent);
|
|
52
52
|
var _super = _createSuper(Renderer);
|
|
@@ -29,6 +29,11 @@ export var MarkComponent = function MarkComponent(_ref) {
|
|
|
29
29
|
return _toConsumableArray(new Set([].concat(_toConsumableArray(annotationParentIds), [id])));
|
|
30
30
|
}, [id, annotationParentIds]);
|
|
31
31
|
var onMarkClick = useCallback(function (event) {
|
|
32
|
+
// prevent inline mark logic for media block marks
|
|
33
|
+
if (event.currentTarget.getAttribute('data-block-mark')) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
32
37
|
// prevents multiple callback on overlapping annotations
|
|
33
38
|
if (event.defaultPrevented || state !== AnnotationMarkStates.ACTIVE) {
|
|
34
39
|
return;
|
|
@@ -27,5 +27,7 @@ export type MediaProps = MediaCardProps & {
|
|
|
27
27
|
height?: number;
|
|
28
28
|
isDrafting: boolean;
|
|
29
29
|
};
|
|
30
|
+
export declare const linkStyle: import("@emotion/react").SerializedStyles;
|
|
31
|
+
export declare const borderStyle: (color: string, width: number) => import("@emotion/react").SerializedStyles;
|
|
30
32
|
declare const MediaWithDraftAnnotation: (props: PropsWithChildren<MediaProps>) => jsx.JSX.Element;
|
|
31
33
|
export default MediaWithDraftAnnotation;
|
|
@@ -27,5 +27,7 @@ export type MediaProps = MediaCardProps & {
|
|
|
27
27
|
height?: number;
|
|
28
28
|
isDrafting: boolean;
|
|
29
29
|
};
|
|
30
|
+
export declare const linkStyle: import("@emotion/react").SerializedStyles;
|
|
31
|
+
export declare const borderStyle: (color: string, width: number) => import("@emotion/react").SerializedStyles;
|
|
30
32
|
declare const MediaWithDraftAnnotation: (props: PropsWithChildren<MediaProps>) => jsx.JSX.Element;
|
|
31
33
|
export default MediaWithDraftAnnotation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/renderer",
|
|
3
|
-
"version": "109.19.
|
|
3
|
+
"version": "109.19.3",
|
|
4
4
|
"description": "Renderer component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
39
39
|
"@atlaskit/emoji": "^67.6.0",
|
|
40
40
|
"@atlaskit/icon": "^22.1.0",
|
|
41
|
-
"@atlaskit/link-datasource": "^1.
|
|
41
|
+
"@atlaskit/link-datasource": "^1.28.0",
|
|
42
42
|
"@atlaskit/media-card": "^77.11.0",
|
|
43
43
|
"@atlaskit/media-client": "^26.3.0",
|
|
44
44
|
"@atlaskit/media-client-react": "^2.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.linkStyle = exports.borderStyle = void 0;
|
|
8
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _templateObject, _templateObject2;
|
|
11
|
-
var linkStyle = exports.linkStyle = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n background: transparent;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n cursor: pointer;\n width: 100% !important;\n height: 100% !important;\n"])));
|
|
12
|
-
var borderStyle = exports.borderStyle = function borderStyle(color, width) {
|
|
13
|
-
return (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n position: absolute;\n width: 100% !important;\n height: 100% !important;\n border-radius: ", "px;\n box-shadow: 0 0 0 ", "px ", ";\n"])), width, width, color);
|
|
14
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { css } from '@emotion/react';
|
|
2
|
-
export const linkStyle = css`
|
|
3
|
-
position: absolute;
|
|
4
|
-
background: transparent;
|
|
5
|
-
top: 0;
|
|
6
|
-
right: 0;
|
|
7
|
-
bottom: 0;
|
|
8
|
-
left: 0;
|
|
9
|
-
cursor: pointer;
|
|
10
|
-
width: 100% !important;
|
|
11
|
-
height: 100% !important;
|
|
12
|
-
`;
|
|
13
|
-
export const borderStyle = (color, width) => css`
|
|
14
|
-
position: absolute;
|
|
15
|
-
width: 100% !important;
|
|
16
|
-
height: 100% !important;
|
|
17
|
-
border-radius: ${width}px;
|
|
18
|
-
box-shadow: 0 0 0 ${width}px ${color};
|
|
19
|
-
`;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2;
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
export var linkStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: absolute;\n background: transparent;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n cursor: pointer;\n width: 100% !important;\n height: 100% !important;\n"])));
|
|
5
|
-
export var borderStyle = function borderStyle(color, width) {
|
|
6
|
-
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n width: 100% !important;\n height: 100% !important;\n border-radius: ", "px;\n box-shadow: 0 0 0 ", "px ", ";\n"])), width, width, color);
|
|
7
|
-
};
|