@atlaskit/renderer 109.8.4 → 109.10.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 +16 -0
- package/dist/cjs/react/nodes/mediaSingle/index.js +4 -2
- package/dist/cjs/ui/MediaCard.js +16 -3
- package/dist/cjs/ui/Renderer/index.js +6 -6
- package/dist/cjs/ui/annotations/contexts/AnnotationRangeContext.js +136 -0
- package/dist/cjs/ui/annotations/element/mark.js +1 -1
- package/dist/cjs/ui/annotations/hooks/user-selection.js +10 -11
- package/dist/cjs/ui/annotations/hover/index.js +12 -0
- package/dist/cjs/ui/annotations/hover/mounter.js +134 -0
- package/dist/cjs/ui/annotations/hover/range-validator.js +43 -0
- package/dist/cjs/ui/annotations/index.js +7 -3
- package/dist/cjs/ui/annotations/selection/index.js +3 -3
- package/dist/cjs/ui/annotations/{selection/wrapper.js → wrapper.js} +15 -7
- package/dist/es2019/react/nodes/mediaSingle/index.js +4 -2
- package/dist/es2019/ui/MediaCard.js +17 -3
- package/dist/es2019/ui/Renderer/index.js +6 -6
- package/dist/es2019/ui/annotations/contexts/AnnotationRangeContext.js +112 -0
- package/dist/es2019/ui/annotations/element/mark.js +5 -1
- package/dist/es2019/ui/annotations/hooks/user-selection.js +13 -7
- package/dist/es2019/ui/annotations/hover/index.js +1 -0
- package/dist/es2019/ui/annotations/hover/mounter.js +121 -0
- package/dist/es2019/ui/annotations/hover/range-validator.js +38 -0
- package/dist/es2019/ui/annotations/index.js +7 -3
- package/dist/es2019/ui/annotations/selection/index.js +1 -1
- package/dist/es2019/ui/annotations/{selection/wrapper.js → wrapper.js} +14 -6
- package/dist/esm/react/nodes/mediaSingle/index.js +4 -2
- package/dist/esm/ui/MediaCard.js +16 -3
- package/dist/esm/ui/Renderer/index.js +6 -6
- package/dist/esm/ui/annotations/contexts/AnnotationRangeContext.js +126 -0
- package/dist/esm/ui/annotations/element/mark.js +2 -2
- package/dist/esm/ui/annotations/hooks/user-selection.js +11 -11
- package/dist/esm/ui/annotations/hover/index.js +1 -0
- package/dist/esm/ui/annotations/hover/mounter.js +124 -0
- package/dist/esm/ui/annotations/hover/range-validator.js +34 -0
- package/dist/esm/ui/annotations/index.js +7 -3
- package/dist/esm/ui/annotations/selection/index.js +1 -1
- package/dist/esm/ui/annotations/{selection/wrapper.js → wrapper.js} +14 -6
- package/dist/types/react/nodes/mediaSingle/index.d.ts +1 -0
- package/dist/types/ui/MediaCard.d.ts +1 -0
- package/dist/types/ui/annotations/contexts/AnnotationRangeContext.d.ts +22 -0
- package/dist/types/ui/annotations/hover/index.d.ts +1 -0
- package/dist/types/ui/annotations/hover/mounter.d.ts +20 -0
- package/dist/types/ui/annotations/hover/range-validator.d.ts +13 -0
- package/dist/types/ui/annotations/selection/index.d.ts +1 -1
- package/dist/{types-ts4.5/ui/annotations/selection → types/ui/annotations}/wrapper.d.ts +1 -1
- package/dist/types-ts4.5/react/nodes/mediaSingle/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/MediaCard.d.ts +1 -0
- package/dist/types-ts4.5/ui/annotations/contexts/AnnotationRangeContext.d.ts +22 -0
- package/dist/types-ts4.5/ui/annotations/hover/index.d.ts +1 -0
- package/dist/types-ts4.5/ui/annotations/hover/mounter.d.ts +20 -0
- package/dist/types-ts4.5/ui/annotations/hover/range-validator.d.ts +13 -0
- package/dist/types-ts4.5/ui/annotations/selection/index.d.ts +1 -1
- package/dist/{types/ui/annotations/selection → types-ts4.5/ui/annotations}/wrapper.d.ts +1 -1
- package/package.json +5 -4
|
@@ -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.
|
|
49
|
+
var packageVersion = "109.10.0";
|
|
50
50
|
export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
51
51
|
_inherits(Renderer, _PureComponent);
|
|
52
52
|
var _super = _createSuper(Renderer);
|
|
@@ -344,7 +344,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
try {
|
|
347
|
-
var _featureFlags$feature,
|
|
347
|
+
var _featureFlags$feature, _featureFlags$feature2;
|
|
348
348
|
var schema = this.getSchema(this.props.schema, this.props.adfStage);
|
|
349
349
|
var _renderDocument = renderDocument(adfDocument, this.serializer, schema, adfStage, this.props.useSpecBasedValidator, this.id, this.fireAnalyticsEvent, this.props.unsupportedContentLevelsTracking, this.props.appearance),
|
|
350
350
|
result = _renderDocument.result,
|
|
@@ -354,7 +354,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
354
354
|
onComplete(stat);
|
|
355
355
|
}
|
|
356
356
|
var rendererOutput = jsx(RendererContextProvider, {
|
|
357
|
-
value:
|
|
357
|
+
value: featureFlags
|
|
358
358
|
}, jsx(ActiveHeaderIdProvider, {
|
|
359
359
|
value: getActiveHeadingId(allowHeadingAnchorLinks)
|
|
360
360
|
}, jsx(AnalyticsContext.Provider, {
|
|
@@ -389,7 +389,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
389
389
|
height: maxHeight,
|
|
390
390
|
fadeHeight: fadeOutHeight
|
|
391
391
|
}, rendererOutput) : rendererOutput;
|
|
392
|
-
var rendererRenderTracking =
|
|
392
|
+
var rendererRenderTracking = featureFlags === null || featureFlags === void 0 || (_featureFlags$feature2 = featureFlags.featureFlags) === null || _featureFlags$feature2 === void 0 || (_featureFlags$feature2 = _featureFlags$feature2.rendererRenderTracking) === null || _featureFlags$feature2 === void 0 ? void 0 : _featureFlags$feature2[ACTION_SUBJECT.RENDERER];
|
|
393
393
|
var reRenderTracking = (rendererRenderTracking === null || rendererRenderTracking === void 0 ? void 0 : rendererRenderTracking.enabled) && jsx(RenderTracking, {
|
|
394
394
|
componentProps: this.props,
|
|
395
395
|
action: ACTION.RE_RENDERED,
|
|
@@ -399,7 +399,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
399
399
|
});
|
|
400
400
|
return jsx(Fragment, null, reRenderTracking, rendererResult);
|
|
401
401
|
} catch (e) {
|
|
402
|
-
var _featureFlags$
|
|
402
|
+
var _featureFlags$feature3;
|
|
403
403
|
if (onError) {
|
|
404
404
|
onError(e);
|
|
405
405
|
}
|
|
@@ -410,7 +410,7 @@ export var Renderer = /*#__PURE__*/function (_PureComponent) {
|
|
|
410
410
|
allowPlaceholderText: allowPlaceholderText,
|
|
411
411
|
allowColumnSorting: allowColumnSorting,
|
|
412
412
|
allowNestedHeaderLinks: allowNestedHeaderLinks,
|
|
413
|
-
useBlockRenderForCodeBlock: (_featureFlags$
|
|
413
|
+
useBlockRenderForCodeBlock: (_featureFlags$feature3 = featureFlags.featureFlags.useBlockRenderForCodeBlock) !== null && _featureFlags$feature3 !== void 0 ? _featureFlags$feature3 : true,
|
|
414
414
|
addTelepointer: this.props.addTelepointer,
|
|
415
415
|
onClick: handleWrapperOnClick
|
|
416
416
|
}, jsx(UnsupportedBlock, null));
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { createContext, useCallback, useContext, useMemo, useReducer } from 'react';
|
|
3
|
+
function reducer(state, action) {
|
|
4
|
+
switch (action.type) {
|
|
5
|
+
case 'clear':
|
|
6
|
+
if (!!state.range || !!state.type) {
|
|
7
|
+
return {
|
|
8
|
+
range: null,
|
|
9
|
+
type: null
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
return state;
|
|
13
|
+
case 'clearSelection':
|
|
14
|
+
if (state.type === 'selection') {
|
|
15
|
+
return {
|
|
16
|
+
range: null,
|
|
17
|
+
type: null
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
return state;
|
|
21
|
+
case 'clearHover':
|
|
22
|
+
if (state.type === 'hover') {
|
|
23
|
+
return {
|
|
24
|
+
range: null,
|
|
25
|
+
type: null
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return state;
|
|
29
|
+
case 'setSelection':
|
|
30
|
+
if (state.range !== action.range || state.type !== 'selection') {
|
|
31
|
+
return {
|
|
32
|
+
range: action.range,
|
|
33
|
+
type: 'selection'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return state;
|
|
37
|
+
case 'setHover':
|
|
38
|
+
if (state.range !== action.range || state.type !== 'hover') {
|
|
39
|
+
return {
|
|
40
|
+
range: action.range,
|
|
41
|
+
type: 'hover'
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return state;
|
|
45
|
+
}
|
|
46
|
+
return state;
|
|
47
|
+
}
|
|
48
|
+
export var AnnotationRangeStateContext = /*#__PURE__*/createContext({
|
|
49
|
+
range: null,
|
|
50
|
+
type: null
|
|
51
|
+
});
|
|
52
|
+
export var AnnotationRangeDispatchContext = /*#__PURE__*/createContext({
|
|
53
|
+
clearRange: function clearRange() {},
|
|
54
|
+
clearSelectionRange: function clearSelectionRange() {},
|
|
55
|
+
clearHoverRange: function clearHoverRange() {},
|
|
56
|
+
setRange: function setRange() {}
|
|
57
|
+
});
|
|
58
|
+
export var AnnotationRangeProvider = function AnnotationRangeProvider(_ref) {
|
|
59
|
+
var children = _ref.children,
|
|
60
|
+
allowCommentsOnMedia = _ref.allowCommentsOnMedia;
|
|
61
|
+
var _useReducer = useReducer(reducer, {
|
|
62
|
+
range: null,
|
|
63
|
+
type: null
|
|
64
|
+
}),
|
|
65
|
+
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
66
|
+
_useReducer2$ = _useReducer2[0],
|
|
67
|
+
range = _useReducer2$.range,
|
|
68
|
+
type = _useReducer2$.type,
|
|
69
|
+
dispatch = _useReducer2[1];
|
|
70
|
+
var clearRange = useCallback(function () {
|
|
71
|
+
return dispatch({
|
|
72
|
+
type: 'clear'
|
|
73
|
+
});
|
|
74
|
+
}, []);
|
|
75
|
+
var clearSelectionRange = useCallback(function () {
|
|
76
|
+
return dispatch({
|
|
77
|
+
type: 'clearSelection'
|
|
78
|
+
});
|
|
79
|
+
}, []);
|
|
80
|
+
var clearHoverRange = useCallback(function () {
|
|
81
|
+
return dispatch({
|
|
82
|
+
type: 'clearHover'
|
|
83
|
+
});
|
|
84
|
+
}, []);
|
|
85
|
+
var setRange = useCallback(function (range) {
|
|
86
|
+
return dispatch({
|
|
87
|
+
type: 'setSelection',
|
|
88
|
+
range: range
|
|
89
|
+
});
|
|
90
|
+
}, []);
|
|
91
|
+
var setHoverTarget = useCallback(function (target) {
|
|
92
|
+
var range = document.createRange();
|
|
93
|
+
range.setStartBefore(target);
|
|
94
|
+
range.setEndAfter(target);
|
|
95
|
+
dispatch({
|
|
96
|
+
type: 'setHover',
|
|
97
|
+
range: range
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
100
|
+
var stateData = useMemo(function () {
|
|
101
|
+
return {
|
|
102
|
+
range: range,
|
|
103
|
+
type: type
|
|
104
|
+
};
|
|
105
|
+
}, [range, type]);
|
|
106
|
+
var dispatchData = useMemo(function () {
|
|
107
|
+
return {
|
|
108
|
+
clearRange: clearRange,
|
|
109
|
+
clearSelectionRange: clearSelectionRange,
|
|
110
|
+
clearHoverRange: clearHoverRange,
|
|
111
|
+
setRange: setRange,
|
|
112
|
+
setHoverTarget: !!allowCommentsOnMedia ? setHoverTarget : undefined
|
|
113
|
+
};
|
|
114
|
+
}, [allowCommentsOnMedia, clearRange, clearSelectionRange, clearHoverRange, setRange, setHoverTarget]);
|
|
115
|
+
return /*#__PURE__*/React.createElement(AnnotationRangeStateContext.Provider, {
|
|
116
|
+
value: stateData
|
|
117
|
+
}, /*#__PURE__*/React.createElement(AnnotationRangeDispatchContext.Provider, {
|
|
118
|
+
value: dispatchData
|
|
119
|
+
}, children));
|
|
120
|
+
};
|
|
121
|
+
export var useAnnotationRangeState = function useAnnotationRangeState() {
|
|
122
|
+
return useContext(AnnotationRangeStateContext);
|
|
123
|
+
};
|
|
124
|
+
export var useAnnotationRangeDispatch = function useAnnotationRangeDispatch() {
|
|
125
|
+
return useContext(AnnotationRangeDispatchContext);
|
|
126
|
+
};
|
|
@@ -9,13 +9,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
9
9
|
|
|
10
10
|
import React, { useMemo, useCallback } from 'react';
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
|
-
import { AnnotationSharedCSSByState } from '@atlaskit/editor-common/styles';
|
|
12
|
+
import { AnnotationSharedCSSByState, mediaAnnotationStyles } from '@atlaskit/editor-common/styles';
|
|
13
13
|
import { AnnotationMarkStates } from '@atlaskit/adf-schema';
|
|
14
14
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
15
15
|
|
|
16
16
|
// eslint-disable-next-line @atlaskit/design-system/no-css-tagged-template-expression -- `AnnotationSharedCSSByState` is not object-safe
|
|
17
17
|
var markStyles = function markStyles() {
|
|
18
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n }\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus);
|
|
18
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: inherit;\n background-color: unset;\n -webkit-tap-highlight-color: transparent;\n\n &[data-mark-annotation-state='", "'] {\n ", ";\n\n &:focus,\n &[data-has-focus='true'] {\n ", ";\n }\n\n & div.rich-media-item {\n ", ";\n }\n }\n"])), AnnotationMarkStates.ACTIVE, AnnotationSharedCSSByState().blur, AnnotationSharedCSSByState().focus, mediaAnnotationStyles);
|
|
19
19
|
};
|
|
20
20
|
export var MarkComponent = function MarkComponent(_ref) {
|
|
21
21
|
var annotationParentIds = _ref.annotationParentIds,
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { useContext, useEffect } from 'react';
|
|
2
|
+
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
3
3
|
import { AnnotationsDraftContext } from '../context';
|
|
4
4
|
import { isRangeInsideOfRendererContainer } from './utils';
|
|
5
5
|
export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
6
6
|
var rendererDOM = props.rendererRef.current;
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
var _useAnnotationRangeDi = useAnnotationRangeDispatch(),
|
|
8
|
+
clearSelectionRange = _useAnnotationRangeDi.clearSelectionRange,
|
|
9
|
+
setRange = _useAnnotationRangeDi.setRange;
|
|
10
|
+
var _useAnnotationRangeSt = useAnnotationRangeState(),
|
|
11
|
+
range = _useAnnotationRangeSt.range,
|
|
12
|
+
type = _useAnnotationRangeSt.type;
|
|
11
13
|
var annotationDraftPosition = useContext(AnnotationsDraftContext);
|
|
12
14
|
var hasAnnotationDraft = !!annotationDraftPosition;
|
|
13
15
|
useEffect(function () {
|
|
@@ -27,10 +29,8 @@ export var useUserSelectionRange = function useUserSelectionRange(props) {
|
|
|
27
29
|
document.addEventListener('selectionchange', onSelectionChange);
|
|
28
30
|
return function () {
|
|
29
31
|
document.removeEventListener('selectionchange', onSelectionChange);
|
|
32
|
+
clearSelectionRange();
|
|
30
33
|
};
|
|
31
|
-
}, [rendererDOM,
|
|
32
|
-
|
|
33
|
-
setRange(null);
|
|
34
|
-
}, []);
|
|
35
|
-
return [range, clearRange];
|
|
34
|
+
}, [rendererDOM, hasAnnotationDraft, setRange, clearSelectionRange]);
|
|
35
|
+
return [type === 'selection' ? range : null, clearSelectionRange];
|
|
36
36
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RangeValidator as HoverRangeValidator } from './range-validator';
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import React, { useCallback, useState, useContext } from 'react';
|
|
3
|
+
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
4
|
+
import { updateWindowSelectionAroundDraft } from '../draft';
|
|
5
|
+
import { FabricChannel } from '@atlaskit/analytics-listeners';
|
|
6
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
8
|
+
export var Mounter = /*#__PURE__*/React.memo(function (props) {
|
|
9
|
+
var Component = props.component,
|
|
10
|
+
range = props.range,
|
|
11
|
+
isAnnotationAllowed = props.isAnnotationAllowed,
|
|
12
|
+
wrapperDOM = props.wrapperDOM,
|
|
13
|
+
onCloseProps = props.onClose,
|
|
14
|
+
clearAnnotationDraft = props.clearAnnotationDraft,
|
|
15
|
+
applyAnnotationDraftAt = props.applyAnnotationDraftAt,
|
|
16
|
+
documentPosition = props.documentPosition,
|
|
17
|
+
applyAnnotation = props.applyAnnotation,
|
|
18
|
+
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
19
|
+
generateIndexMatch = props.generateIndexMatch;
|
|
20
|
+
var _useState = useState(),
|
|
21
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
22
|
+
draftDocumentPosition = _useState2[0],
|
|
23
|
+
setDraftDocumentPosition = _useState2[1];
|
|
24
|
+
var actions = useContext(ActionsContext);
|
|
25
|
+
var onCreateCallback = useCallback(function (annotationId) {
|
|
26
|
+
if (!isAnnotationAllowed || !documentPosition || !applyAnnotation) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
var annotation = {
|
|
30
|
+
annotationId: annotationId,
|
|
31
|
+
annotationType: AnnotationTypes.INLINE_COMMENT
|
|
32
|
+
};
|
|
33
|
+
if (createAnalyticsEvent) {
|
|
34
|
+
createAnalyticsEvent({
|
|
35
|
+
action: ACTION.INSERTED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.ANNOTATION,
|
|
37
|
+
actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
|
|
38
|
+
attributes: {},
|
|
39
|
+
eventType: EVENT_TYPE.TRACK
|
|
40
|
+
}).fire(FabricChannel.editor);
|
|
41
|
+
}
|
|
42
|
+
return applyAnnotation(draftDocumentPosition || documentPosition, annotation);
|
|
43
|
+
}, [isAnnotationAllowed, documentPosition, applyAnnotation, draftDocumentPosition, createAnalyticsEvent]);
|
|
44
|
+
var createIndexCallback = useCallback(function () {
|
|
45
|
+
if (!documentPosition || !generateIndexMatch) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
var result = generateIndexMatch(documentPosition);
|
|
49
|
+
if (!result) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}, [documentPosition, generateIndexMatch]);
|
|
54
|
+
var applyDraftModeCallback = useCallback(function () {
|
|
55
|
+
var keepNativeSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
56
|
+
if (!documentPosition || !isAnnotationAllowed) {
|
|
57
|
+
if (createAnalyticsEvent) {
|
|
58
|
+
createAnalyticsEvent({
|
|
59
|
+
action: ACTION.CREATE_NOT_ALLOWED,
|
|
60
|
+
actionSubject: ACTION_SUBJECT.ANNOTATION,
|
|
61
|
+
actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
|
|
62
|
+
attributes: {},
|
|
63
|
+
eventType: EVENT_TYPE.TRACK
|
|
64
|
+
}).fire(FabricChannel.editor);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setDraftDocumentPosition(documentPosition);
|
|
69
|
+
applyAnnotationDraftAt(documentPosition);
|
|
70
|
+
if (createAnalyticsEvent) {
|
|
71
|
+
var uniqueAnnotationsInRange = actions.getAnnotationsByPosition(range);
|
|
72
|
+
createAnalyticsEvent({
|
|
73
|
+
action: ACTION.OPENED,
|
|
74
|
+
actionSubject: ACTION_SUBJECT.ANNOTATION,
|
|
75
|
+
actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
|
|
76
|
+
eventType: EVENT_TYPE.TRACK,
|
|
77
|
+
attributes: {
|
|
78
|
+
overlap: uniqueAnnotationsInRange.length
|
|
79
|
+
}
|
|
80
|
+
}).fire(FabricChannel.editor);
|
|
81
|
+
}
|
|
82
|
+
window.requestAnimationFrame(function () {
|
|
83
|
+
if (keepNativeSelection) {
|
|
84
|
+
updateWindowSelectionAroundDraft(documentPosition);
|
|
85
|
+
} else {
|
|
86
|
+
var sel = window.getSelection();
|
|
87
|
+
if (sel) {
|
|
88
|
+
sel.removeAllRanges();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}, [documentPosition, isAnnotationAllowed, applyAnnotationDraftAt, createAnalyticsEvent, actions, range]);
|
|
93
|
+
var removeDraftModeCallback = useCallback(function () {
|
|
94
|
+
clearAnnotationDraft();
|
|
95
|
+
setDraftDocumentPosition(null);
|
|
96
|
+
var sel = window.getSelection();
|
|
97
|
+
if (sel) {
|
|
98
|
+
sel.removeAllRanges();
|
|
99
|
+
}
|
|
100
|
+
}, [clearAnnotationDraft]);
|
|
101
|
+
var onCloseCallback = useCallback(function () {
|
|
102
|
+
if (createAnalyticsEvent) {
|
|
103
|
+
createAnalyticsEvent({
|
|
104
|
+
action: ACTION.CLOSED,
|
|
105
|
+
actionSubject: ACTION_SUBJECT.ANNOTATION,
|
|
106
|
+
actionSubjectId: ACTION_SUBJECT_ID.INLINE_COMMENT,
|
|
107
|
+
eventType: EVENT_TYPE.TRACK,
|
|
108
|
+
attributes: {}
|
|
109
|
+
}).fire(FabricChannel.editor);
|
|
110
|
+
}
|
|
111
|
+
removeDraftModeCallback();
|
|
112
|
+
onCloseProps();
|
|
113
|
+
}, [onCloseProps, removeDraftModeCallback, createAnalyticsEvent]);
|
|
114
|
+
return /*#__PURE__*/React.createElement(Component, {
|
|
115
|
+
range: range,
|
|
116
|
+
wrapperDOM: wrapperDOM.current,
|
|
117
|
+
isAnnotationAllowed: isAnnotationAllowed,
|
|
118
|
+
onClose: onCloseCallback,
|
|
119
|
+
onCreate: onCreateCallback,
|
|
120
|
+
getAnnotationIndexMatch: createIndexCallback,
|
|
121
|
+
applyDraftMode: applyDraftModeCallback,
|
|
122
|
+
removeDraftMode: removeDraftModeCallback
|
|
123
|
+
});
|
|
124
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import { Mounter } from './mounter';
|
|
3
|
+
import { RendererContext as ActionsContext } from '../../RendererActionsContext';
|
|
4
|
+
import { useAnnotationRangeDispatch, useAnnotationRangeState } from '../contexts/AnnotationRangeContext';
|
|
5
|
+
export var RangeValidator = function RangeValidator(props) {
|
|
6
|
+
var component = props.component,
|
|
7
|
+
rendererRef = props.rendererRef,
|
|
8
|
+
applyAnnotationDraftAt = props.applyAnnotationDraftAt,
|
|
9
|
+
clearAnnotationDraft = props.clearAnnotationDraft,
|
|
10
|
+
createAnalyticsEvent = props.createAnalyticsEvent;
|
|
11
|
+
var actions = useContext(ActionsContext);
|
|
12
|
+
var _useAnnotationRangeDi = useAnnotationRangeDispatch(),
|
|
13
|
+
clearHoverRange = _useAnnotationRangeDi.clearHoverRange;
|
|
14
|
+
var _useAnnotationRangeSt = useAnnotationRangeState(),
|
|
15
|
+
range = _useAnnotationRangeSt.range,
|
|
16
|
+
type = _useAnnotationRangeSt.type;
|
|
17
|
+
if (!range || type !== 'hover') {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var documentPosition = actions.getPositionFromRange(range);
|
|
21
|
+
return /*#__PURE__*/React.createElement(Mounter, {
|
|
22
|
+
range: range,
|
|
23
|
+
wrapperDOM: rendererRef,
|
|
24
|
+
component: component,
|
|
25
|
+
onClose: clearHoverRange,
|
|
26
|
+
documentPosition: documentPosition,
|
|
27
|
+
isAnnotationAllowed: true,
|
|
28
|
+
applyAnnotation: actions.applyAnnotation.bind(actions),
|
|
29
|
+
applyAnnotationDraftAt: applyAnnotationDraftAt,
|
|
30
|
+
generateIndexMatch: actions.generateAnnotationIndexMatch.bind(actions),
|
|
31
|
+
clearAnnotationDraft: clearAnnotationDraft,
|
|
32
|
+
createAnalyticsEvent: createAnalyticsEvent
|
|
33
|
+
});
|
|
34
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
3
3
|
import { AnnotationView } from './view';
|
|
4
|
-
import {
|
|
4
|
+
import { AnnotationsContextWrapper } from './wrapper';
|
|
5
5
|
import { ProvidersContext, InlineCommentsStateContext } from './context';
|
|
6
6
|
import { useLoadAnnotations } from './hooks/use-load-annotations';
|
|
7
7
|
import { useAnnotationStateByTypeEvent } from './hooks/use-events';
|
|
8
8
|
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
9
|
+
import { AnnotationRangeProvider } from './contexts/AnnotationRangeContext';
|
|
9
10
|
var LoadAnnotations = /*#__PURE__*/React.memo(function (_ref) {
|
|
10
11
|
var adfDocument = _ref.adfDocument;
|
|
11
12
|
useLoadAnnotations({
|
|
@@ -14,6 +15,7 @@ var LoadAnnotations = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
14
15
|
return null;
|
|
15
16
|
});
|
|
16
17
|
export var AnnotationsWrapper = function AnnotationsWrapper(props) {
|
|
18
|
+
var _annotationProvider$i, _annotationProvider$i2;
|
|
17
19
|
var children = props.children,
|
|
18
20
|
annotationProvider = props.annotationProvider,
|
|
19
21
|
rendererRef = props.rendererRef,
|
|
@@ -29,14 +31,16 @@ export var AnnotationsWrapper = function AnnotationsWrapper(props) {
|
|
|
29
31
|
value: annotationProvider
|
|
30
32
|
}, /*#__PURE__*/React.createElement(InlineCommentsStateContext.Provider, {
|
|
31
33
|
value: inlineCommentAnnotationsState
|
|
32
|
-
}, /*#__PURE__*/React.createElement(
|
|
34
|
+
}, /*#__PURE__*/React.createElement(AnnotationRangeProvider, {
|
|
35
|
+
allowCommentsOnMedia: (_annotationProvider$i = annotationProvider === null || annotationProvider === void 0 || (_annotationProvider$i2 = annotationProvider.inlineComment) === null || _annotationProvider$i2 === void 0 ? void 0 : _annotationProvider$i2.allowCommentsOnMedia) !== null && _annotationProvider$i !== void 0 ? _annotationProvider$i : false
|
|
36
|
+
}, /*#__PURE__*/React.createElement(AnnotationsContextWrapper, {
|
|
33
37
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
34
38
|
rendererRef: rendererRef
|
|
35
39
|
}, /*#__PURE__*/React.createElement(LoadAnnotations, {
|
|
36
40
|
adfDocument: adfDocument
|
|
37
41
|
}), /*#__PURE__*/React.createElement(AnnotationView, {
|
|
38
42
|
createAnalyticsEvent: createAnalyticsEvent
|
|
39
|
-
}), children)));
|
|
43
|
+
}), children))));
|
|
40
44
|
};
|
|
41
45
|
export { TextWithAnnotationDraft } from './draft';
|
|
42
46
|
export { MarkElement as AnnotationMark } from './element';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { SelectionRangeValidator } from './range-validator';
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
import React, { useCallback, useContext } from 'react';
|
|
2
|
-
import { AnnotationsDraftContextWrapper, ProvidersContext } from '
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { AnnotationsDraftContextWrapper, ProvidersContext } from './context';
|
|
3
|
+
import { HoverRangeValidator } from './hover';
|
|
4
|
+
import { SelectionRangeValidator } from './selection';
|
|
5
|
+
export var AnnotationsContextWrapper = function AnnotationsContextWrapper(props) {
|
|
5
6
|
var providers = useContext(ProvidersContext);
|
|
6
7
|
var rendererRef = props.rendererRef,
|
|
7
8
|
createAnalyticsEvent = props.createAnalyticsEvent,
|
|
8
9
|
children = props.children;
|
|
9
10
|
var inlineCommentProvider = providers && providers.inlineComment;
|
|
10
11
|
var selectionComponent = inlineCommentProvider && inlineCommentProvider.selectionComponent;
|
|
12
|
+
var hoverComponent = inlineCommentProvider && inlineCommentProvider.hoverComponent;
|
|
11
13
|
var render = useCallback(function (_ref) {
|
|
12
14
|
var applyAnnotationDraftAt = _ref.applyAnnotationDraftAt,
|
|
13
15
|
clearAnnotationDraft = _ref.clearAnnotationDraft;
|
|
14
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement(
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, !!hoverComponent && /*#__PURE__*/React.createElement(HoverRangeValidator, {
|
|
17
|
+
createAnalyticsEvent: createAnalyticsEvent,
|
|
18
|
+
rendererRef: rendererRef,
|
|
19
|
+
component: hoverComponent,
|
|
20
|
+
applyAnnotationDraftAt: applyAnnotationDraftAt,
|
|
21
|
+
clearAnnotationDraft: clearAnnotationDraft
|
|
22
|
+
}), !!selectionComponent && /*#__PURE__*/React.createElement(SelectionRangeValidator, {
|
|
15
23
|
createAnalyticsEvent: createAnalyticsEvent,
|
|
16
24
|
rendererRef: rendererRef,
|
|
17
25
|
selectionComponent: selectionComponent,
|
|
18
26
|
applyAnnotationDraftAt: applyAnnotationDraftAt,
|
|
19
27
|
clearAnnotationDraft: clearAnnotationDraft
|
|
20
28
|
}));
|
|
21
|
-
}, [selectionComponent, children, rendererRef, createAnalyticsEvent]);
|
|
22
|
-
if (!selectionComponent) {
|
|
29
|
+
}, [hoverComponent, selectionComponent, children, rendererRef, createAnalyticsEvent]);
|
|
30
|
+
if (!selectionComponent && !hoverComponent) {
|
|
23
31
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
24
32
|
}
|
|
25
33
|
return /*#__PURE__*/React.createElement(AnnotationsDraftContextWrapper, null, render);
|
|
@@ -17,6 +17,7 @@ export interface Props {
|
|
|
17
17
|
featureFlags?: MediaFeatureFlags;
|
|
18
18
|
allowCaptions?: boolean;
|
|
19
19
|
isInsideOfInlineExtension?: boolean;
|
|
20
|
+
dataAttributes?: Record<string, any>;
|
|
20
21
|
}
|
|
21
22
|
export declare const getMediaContainerWidth: (currentContainerWidth: number, layout: MediaSingleLayout) => number;
|
|
22
23
|
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
@@ -48,6 +48,7 @@ export declare const mediaIdentifierMap: Map<string, Identifier>;
|
|
|
48
48
|
export declare const getListOfIdentifiersFromDoc: (doc?: ADFEntity) => Identifier[];
|
|
49
49
|
export declare class MediaCardView extends Component<MediaCardProps & {
|
|
50
50
|
mediaClient?: MediaClient;
|
|
51
|
+
setHoverTarget?: (target: HTMLElement) => void;
|
|
51
52
|
}, State> {
|
|
52
53
|
state: State;
|
|
53
54
|
componentDidMount(): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface AnnotationRangeStateContext {
|
|
4
|
+
range: Range | null;
|
|
5
|
+
type: 'selection' | 'hover' | null;
|
|
6
|
+
}
|
|
7
|
+
interface AnnotationRangeDispatchContext {
|
|
8
|
+
clearRange: () => void;
|
|
9
|
+
clearSelectionRange: () => void;
|
|
10
|
+
clearHoverRange: () => void;
|
|
11
|
+
setRange: (range: Range) => void;
|
|
12
|
+
setHoverTarget?: (target: HTMLElement) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const AnnotationRangeStateContext: React.Context<AnnotationRangeStateContext>;
|
|
15
|
+
export declare const AnnotationRangeDispatchContext: React.Context<AnnotationRangeDispatchContext>;
|
|
16
|
+
export declare const AnnotationRangeProvider: ({ children, allowCommentsOnMedia, }: {
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
allowCommentsOnMedia?: boolean | undefined;
|
|
19
|
+
}) => JSX.Element;
|
|
20
|
+
export declare const useAnnotationRangeState: () => AnnotationRangeStateContext;
|
|
21
|
+
export declare const useAnnotationRangeDispatch: () => AnnotationRangeDispatchContext;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RangeValidator as HoverRangeValidator } from './range-validator';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AnnotationByMatches, InlineCommentSelectionComponentProps } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ApplyAnnotation } from '../../../actions/index';
|
|
4
|
+
import type { Position } from '../types';
|
|
5
|
+
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
|
+
type Props = {
|
|
7
|
+
range: Range;
|
|
8
|
+
component: React.ComponentType<InlineCommentSelectionComponentProps>;
|
|
9
|
+
wrapperDOM: React.RefObject<HTMLDivElement>;
|
|
10
|
+
documentPosition: Position | false;
|
|
11
|
+
isAnnotationAllowed: boolean;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
applyAnnotation: ApplyAnnotation;
|
|
14
|
+
applyAnnotationDraftAt: (position: Position) => void;
|
|
15
|
+
clearAnnotationDraft: () => void;
|
|
16
|
+
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
17
|
+
generateIndexMatch?: (pos: Position) => false | AnnotationByMatches;
|
|
18
|
+
};
|
|
19
|
+
export declare const Mounter: React.MemoExoticComponent<(props: Props) => JSX.Element>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Position } from '../types';
|
|
3
|
+
import type { InlineCommentHoverComponentProps } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
5
|
+
type Props = {
|
|
6
|
+
component: React.ComponentType<InlineCommentHoverComponentProps>;
|
|
7
|
+
rendererRef: React.RefObject<HTMLDivElement>;
|
|
8
|
+
applyAnnotationDraftAt: (position: Position) => void;
|
|
9
|
+
clearAnnotationDraft: () => void;
|
|
10
|
+
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
11
|
+
};
|
|
12
|
+
export declare const RangeValidator: (props: Props) => JSX.Element | null;
|
|
13
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { SelectionRangeValidator } from './range-validator';
|
|
@@ -4,5 +4,5 @@ type Props = {
|
|
|
4
4
|
rendererRef: React.RefObject<HTMLDivElement>;
|
|
5
5
|
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
6
6
|
};
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const AnnotationsContextWrapper: (props: React.PropsWithChildren<Props>) => JSX.Element;
|
|
8
8
|
export {};
|
|
@@ -17,6 +17,7 @@ export interface Props {
|
|
|
17
17
|
featureFlags?: MediaFeatureFlags;
|
|
18
18
|
allowCaptions?: boolean;
|
|
19
19
|
isInsideOfInlineExtension?: boolean;
|
|
20
|
+
dataAttributes?: Record<string, any>;
|
|
20
21
|
}
|
|
21
22
|
export declare const getMediaContainerWidth: (currentContainerWidth: number, layout: MediaSingleLayout) => number;
|
|
22
23
|
declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
@@ -48,6 +48,7 @@ export declare const mediaIdentifierMap: Map<string, Identifier>;
|
|
|
48
48
|
export declare const getListOfIdentifiersFromDoc: (doc?: ADFEntity) => Identifier[];
|
|
49
49
|
export declare class MediaCardView extends Component<MediaCardProps & {
|
|
50
50
|
mediaClient?: MediaClient;
|
|
51
|
+
setHoverTarget?: (target: HTMLElement) => void;
|
|
51
52
|
}, State> {
|
|
52
53
|
state: State;
|
|
53
54
|
componentDidMount(): Promise<void>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface AnnotationRangeStateContext {
|
|
4
|
+
range: Range | null;
|
|
5
|
+
type: 'selection' | 'hover' | null;
|
|
6
|
+
}
|
|
7
|
+
interface AnnotationRangeDispatchContext {
|
|
8
|
+
clearRange: () => void;
|
|
9
|
+
clearSelectionRange: () => void;
|
|
10
|
+
clearHoverRange: () => void;
|
|
11
|
+
setRange: (range: Range) => void;
|
|
12
|
+
setHoverTarget?: (target: HTMLElement) => void;
|
|
13
|
+
}
|
|
14
|
+
export declare const AnnotationRangeStateContext: React.Context<AnnotationRangeStateContext>;
|
|
15
|
+
export declare const AnnotationRangeDispatchContext: React.Context<AnnotationRangeDispatchContext>;
|
|
16
|
+
export declare const AnnotationRangeProvider: ({ children, allowCommentsOnMedia, }: {
|
|
17
|
+
children?: ReactNode;
|
|
18
|
+
allowCommentsOnMedia?: boolean | undefined;
|
|
19
|
+
}) => JSX.Element;
|
|
20
|
+
export declare const useAnnotationRangeState: () => AnnotationRangeStateContext;
|
|
21
|
+
export declare const useAnnotationRangeDispatch: () => AnnotationRangeDispatchContext;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RangeValidator as HoverRangeValidator } from './range-validator';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AnnotationByMatches, InlineCommentSelectionComponentProps } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ApplyAnnotation } from '../../../actions/index';
|
|
4
|
+
import type { Position } from '../types';
|
|
5
|
+
import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
6
|
+
type Props = {
|
|
7
|
+
range: Range;
|
|
8
|
+
component: React.ComponentType<InlineCommentSelectionComponentProps>;
|
|
9
|
+
wrapperDOM: React.RefObject<HTMLDivElement>;
|
|
10
|
+
documentPosition: Position | false;
|
|
11
|
+
isAnnotationAllowed: boolean;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
applyAnnotation: ApplyAnnotation;
|
|
14
|
+
applyAnnotationDraftAt: (position: Position) => void;
|
|
15
|
+
clearAnnotationDraft: () => void;
|
|
16
|
+
createAnalyticsEvent?: CreateUIAnalyticsEvent;
|
|
17
|
+
generateIndexMatch?: (pos: Position) => false | AnnotationByMatches;
|
|
18
|
+
};
|
|
19
|
+
export declare const Mounter: React.MemoExoticComponent<(props: Props) => JSX.Element>;
|
|
20
|
+
export {};
|