@atlaskit/editor-plugin-selection-marker 1.5.19 → 1.7.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 +20 -0
- package/dist/cjs/selectionMarkerPlugin.js +31 -12
- package/dist/cjs/ui/widget-decoration.js +1 -4
- package/dist/es2019/selectionMarkerPlugin.js +27 -7
- package/dist/es2019/ui/widget-decoration.js +1 -4
- package/dist/esm/selectionMarkerPlugin.js +31 -12
- package/dist/esm/ui/widget-decoration.js +1 -4
- package/dist/types/selectionMarkerPluginType.d.ts +5 -0
- package/dist/types-ts4.5/selectionMarkerPluginType.d.ts +5 -0
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-selection-marker
|
|
2
2
|
|
|
3
|
+
## 1.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#109060](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109060)
|
|
8
|
+
[`4660ec858a305`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4660ec858a305) -
|
|
9
|
+
Update `React` from v16 to v18
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 1.6.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#107185](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107185)
|
|
20
|
+
[`ba993865b0f02`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ba993865b0f02) -
|
|
21
|
+
Add queueHideDecoration action to hide decoration when the lock becomes available.
|
|
22
|
+
|
|
3
23
|
## 1.5.19
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.selectionMarkerPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
10
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
10
11
|
var _main = require("./pm-plugins/main");
|
|
11
12
|
var _globalStyles = require("./ui/global-styles");
|
|
12
13
|
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); }
|
|
@@ -24,12 +25,13 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
|
|
|
24
25
|
}];
|
|
25
26
|
},
|
|
26
27
|
getSharedState: function getSharedState(editorState) {
|
|
27
|
-
var _key$getState$forceHi, _key$getState;
|
|
28
|
+
var _key$getState$forceHi, _key$getState, _key$getState2;
|
|
28
29
|
if (!editorState) {
|
|
29
30
|
return undefined;
|
|
30
31
|
}
|
|
31
32
|
return {
|
|
32
|
-
isForcedHidden: (_key$getState$forceHi = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false
|
|
33
|
+
isForcedHidden: (_key$getState$forceHi = (_key$getState = _main.key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false,
|
|
34
|
+
isMarkerActive: !((_key$getState2 = _main.key.getState(editorState)) !== null && _key$getState2 !== void 0 && _key$getState2.shouldHideDecorations)
|
|
33
35
|
};
|
|
34
36
|
},
|
|
35
37
|
actions: {
|
|
@@ -50,17 +52,34 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
|
|
|
50
52
|
return undefined;
|
|
51
53
|
}
|
|
52
54
|
return cleanupHiddenDecoration(api);
|
|
55
|
+
},
|
|
56
|
+
queueHideDecoration: function queueHideDecoration(setCleanup) {
|
|
57
|
+
var result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
58
|
+
if (result === undefined) {
|
|
59
|
+
var _api$selectionMarker2;
|
|
60
|
+
var cleanup = api === null || api === void 0 || (_api$selectionMarker2 = api.selectionMarker) === null || _api$selectionMarker2 === void 0 ? void 0 : _api$selectionMarker2.sharedState.onChange(function (_ref3) {
|
|
61
|
+
var nextSharedState = _ref3.nextSharedState;
|
|
62
|
+
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isForcedHidden) === false && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isMarkerActive) === false) {
|
|
63
|
+
var _result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
64
|
+
setCleanup(_result);
|
|
65
|
+
cleanup === null || cleanup === void 0 || cleanup();
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
return cleanup;
|
|
69
|
+
}
|
|
70
|
+
setCleanup(result);
|
|
71
|
+
return function () {};
|
|
53
72
|
}
|
|
54
73
|
},
|
|
55
|
-
usePluginHook: function usePluginHook(
|
|
56
|
-
var editorView =
|
|
74
|
+
usePluginHook: function usePluginHook(_ref4) {
|
|
75
|
+
var editorView = _ref4.editorView;
|
|
57
76
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['focus', 'typeAhead', 'editorDisabled', 'selectionMarker']),
|
|
58
77
|
focusState = _useSharedPluginState.focusState,
|
|
59
78
|
typeAheadState = _useSharedPluginState.typeAheadState,
|
|
60
|
-
selectionMarkerState = _useSharedPluginState.selectionMarkerState,
|
|
61
79
|
editorDisabledState = _useSharedPluginState.editorDisabledState;
|
|
80
|
+
var isForcedHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selectionMarker.isForcedHidden');
|
|
62
81
|
(0, _react.useEffect)(function () {
|
|
63
|
-
var
|
|
82
|
+
var _ref5, _typeAheadState$isOpe, _editorDisabledState$;
|
|
64
83
|
/**
|
|
65
84
|
* There are a number of conditions we should not show the marker,
|
|
66
85
|
* - Focus: to ensure it doesn't interrupt the normal cursor
|
|
@@ -68,11 +87,11 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
|
|
|
68
87
|
* - Disabled: So that it behaves similar to the renderer in live pages/disabled
|
|
69
88
|
* - Via the API: If another plugin has requested it to be hidden (force hidden).
|
|
70
89
|
*/
|
|
71
|
-
var shouldHide = (
|
|
90
|
+
var shouldHide = (_ref5 = (focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus) || ((_typeAheadState$isOpe = typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen) !== null && _typeAheadState$isOpe !== void 0 ? _typeAheadState$isOpe : false) || isForcedHidden || ((_editorDisabledState$ = editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) !== null && _editorDisabledState$ !== void 0 ? _editorDisabledState$ : false)) !== null && _ref5 !== void 0 ? _ref5 : true;
|
|
72
91
|
requestAnimationFrame(function () {
|
|
73
92
|
return (0, _main.dispatchShouldHideDecorations)(editorView, shouldHide);
|
|
74
93
|
});
|
|
75
|
-
}, [editorView, focusState, typeAheadState,
|
|
94
|
+
}, [editorView, focusState, typeAheadState, isForcedHidden, editorDisabledState]);
|
|
76
95
|
},
|
|
77
96
|
contentComponent: function contentComponent() {
|
|
78
97
|
return /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null);
|
|
@@ -82,12 +101,12 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
|
|
|
82
101
|
function cleanupHiddenDecoration(api) {
|
|
83
102
|
var hasRun = false;
|
|
84
103
|
return function () {
|
|
85
|
-
var _api$
|
|
86
|
-
if (!hasRun && api !== null && api !== void 0 && (_api$
|
|
104
|
+
var _api$selectionMarker3;
|
|
105
|
+
if (!hasRun && api !== null && api !== void 0 && (_api$selectionMarker3 = api.selectionMarker) !== null && _api$selectionMarker3 !== void 0 && (_api$selectionMarker3 = _api$selectionMarker3.sharedState.currentState()) !== null && _api$selectionMarker3 !== void 0 && _api$selectionMarker3.isForcedHidden) {
|
|
87
106
|
var _api$core2;
|
|
88
107
|
hasRun = true;
|
|
89
|
-
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (
|
|
90
|
-
var tr =
|
|
108
|
+
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref6) {
|
|
109
|
+
var tr = _ref6.tr;
|
|
91
110
|
return tr.setMeta(_main.key, {
|
|
92
111
|
forceHide: false
|
|
93
112
|
});
|
|
@@ -89,10 +89,7 @@ var containsText = function containsText(resolvedPos) {
|
|
|
89
89
|
nodeAfter = resolvedPos.nodeAfter;
|
|
90
90
|
return (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.isInline) || (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.isInline);
|
|
91
91
|
};
|
|
92
|
-
var createWidgetDecoration = exports.createWidgetDecoration = function createWidgetDecoration(resolvedPos, type, selection, isHighlight
|
|
93
|
-
// Ignored via go/ees005
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
95
|
-
) {
|
|
92
|
+
var createWidgetDecoration = exports.createWidgetDecoration = function createWidgetDecoration(resolvedPos, type, selection, isHighlight) {
|
|
96
93
|
// We don't want the cursor to show if it's not text selection
|
|
97
94
|
// ie. if it's on media selection
|
|
98
95
|
if (!(selection instanceof _state.TextSelection) || containsText(resolvedPos) === false || !selection.empty) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
|
|
4
5
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
5
6
|
export const selectionMarkerPlugin = ({
|
|
@@ -14,12 +15,13 @@ export const selectionMarkerPlugin = ({
|
|
|
14
15
|
}];
|
|
15
16
|
},
|
|
16
17
|
getSharedState(editorState) {
|
|
17
|
-
var _key$getState$forceHi, _key$getState;
|
|
18
|
+
var _key$getState$forceHi, _key$getState, _key$getState2;
|
|
18
19
|
if (!editorState) {
|
|
19
20
|
return undefined;
|
|
20
21
|
}
|
|
21
22
|
return {
|
|
22
|
-
isForcedHidden: (_key$getState$forceHi = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false
|
|
23
|
+
isForcedHidden: (_key$getState$forceHi = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false,
|
|
24
|
+
isMarkerActive: !((_key$getState2 = key.getState(editorState)) !== null && _key$getState2 !== void 0 && _key$getState2.shouldHideDecorations)
|
|
23
25
|
};
|
|
24
26
|
},
|
|
25
27
|
actions: {
|
|
@@ -39,6 +41,24 @@ export const selectionMarkerPlugin = ({
|
|
|
39
41
|
return undefined;
|
|
40
42
|
}
|
|
41
43
|
return cleanupHiddenDecoration(api);
|
|
44
|
+
},
|
|
45
|
+
queueHideDecoration: setCleanup => {
|
|
46
|
+
const result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
47
|
+
if (result === undefined) {
|
|
48
|
+
var _api$selectionMarker2;
|
|
49
|
+
const cleanup = api === null || api === void 0 ? void 0 : (_api$selectionMarker2 = api.selectionMarker) === null || _api$selectionMarker2 === void 0 ? void 0 : _api$selectionMarker2.sharedState.onChange(({
|
|
50
|
+
nextSharedState
|
|
51
|
+
}) => {
|
|
52
|
+
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isForcedHidden) === false && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isMarkerActive) === false) {
|
|
53
|
+
const result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
54
|
+
setCleanup(result);
|
|
55
|
+
cleanup === null || cleanup === void 0 ? void 0 : cleanup();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
return cleanup;
|
|
59
|
+
}
|
|
60
|
+
setCleanup(result);
|
|
61
|
+
return () => {};
|
|
42
62
|
}
|
|
43
63
|
},
|
|
44
64
|
usePluginHook({
|
|
@@ -47,9 +67,9 @@ export const selectionMarkerPlugin = ({
|
|
|
47
67
|
const {
|
|
48
68
|
focusState,
|
|
49
69
|
typeAheadState,
|
|
50
|
-
selectionMarkerState,
|
|
51
70
|
editorDisabledState
|
|
52
71
|
} = useSharedPluginState(api, ['focus', 'typeAhead', 'editorDisabled', 'selectionMarker']);
|
|
72
|
+
const isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
|
|
53
73
|
useEffect(() => {
|
|
54
74
|
var _ref, _typeAheadState$isOpe, _editorDisabledState$;
|
|
55
75
|
/**
|
|
@@ -59,9 +79,9 @@ export const selectionMarkerPlugin = ({
|
|
|
59
79
|
* - Disabled: So that it behaves similar to the renderer in live pages/disabled
|
|
60
80
|
* - Via the API: If another plugin has requested it to be hidden (force hidden).
|
|
61
81
|
*/
|
|
62
|
-
const shouldHide = (_ref = (focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus) || ((_typeAheadState$isOpe = typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen) !== null && _typeAheadState$isOpe !== void 0 ? _typeAheadState$isOpe : false) ||
|
|
82
|
+
const shouldHide = (_ref = (focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus) || ((_typeAheadState$isOpe = typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen) !== null && _typeAheadState$isOpe !== void 0 ? _typeAheadState$isOpe : false) || isForcedHidden || ((_editorDisabledState$ = editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) !== null && _editorDisabledState$ !== void 0 ? _editorDisabledState$ : false)) !== null && _ref !== void 0 ? _ref : true;
|
|
63
83
|
requestAnimationFrame(() => dispatchShouldHideDecorations(editorView, shouldHide));
|
|
64
|
-
}, [editorView, focusState, typeAheadState,
|
|
84
|
+
}, [editorView, focusState, typeAheadState, isForcedHidden, editorDisabledState]);
|
|
65
85
|
},
|
|
66
86
|
contentComponent() {
|
|
67
87
|
return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
|
|
@@ -71,8 +91,8 @@ export const selectionMarkerPlugin = ({
|
|
|
71
91
|
function cleanupHiddenDecoration(api) {
|
|
72
92
|
let hasRun = false;
|
|
73
93
|
return () => {
|
|
74
|
-
var _api$
|
|
75
|
-
if (!hasRun && api !== null && api !== void 0 && (_api$
|
|
94
|
+
var _api$selectionMarker3, _api$selectionMarker4;
|
|
95
|
+
if (!hasRun && api !== null && api !== void 0 && (_api$selectionMarker3 = api.selectionMarker) !== null && _api$selectionMarker3 !== void 0 && (_api$selectionMarker4 = _api$selectionMarker3.sharedState.currentState()) !== null && _api$selectionMarker4 !== void 0 && _api$selectionMarker4.isForcedHidden) {
|
|
76
96
|
var _api$core2;
|
|
77
97
|
hasRun = true;
|
|
78
98
|
return api === null || api === void 0 ? void 0 : (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(({
|
|
@@ -79,10 +79,7 @@ const containsText = resolvedPos => {
|
|
|
79
79
|
} = resolvedPos;
|
|
80
80
|
return (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.isInline) || (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.isInline);
|
|
81
81
|
};
|
|
82
|
-
export const createWidgetDecoration = (resolvedPos, type, selection, isHighlight
|
|
83
|
-
// Ignored via go/ees005
|
|
84
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
85
|
-
) => {
|
|
82
|
+
export const createWidgetDecoration = (resolvedPos, type, selection, isHighlight) => {
|
|
86
83
|
// We don't want the cursor to show if it's not text selection
|
|
87
84
|
// ie. if it's on media selection
|
|
88
85
|
if (!(selection instanceof TextSelection) || containsText(resolvedPos) === false || !selection.empty) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
|
|
4
5
|
import { GlobalStylesWrapper } from './ui/global-styles';
|
|
5
6
|
export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
|
|
@@ -15,12 +16,13 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
|
|
|
15
16
|
}];
|
|
16
17
|
},
|
|
17
18
|
getSharedState: function getSharedState(editorState) {
|
|
18
|
-
var _key$getState$forceHi, _key$getState;
|
|
19
|
+
var _key$getState$forceHi, _key$getState, _key$getState2;
|
|
19
20
|
if (!editorState) {
|
|
20
21
|
return undefined;
|
|
21
22
|
}
|
|
22
23
|
return {
|
|
23
|
-
isForcedHidden: (_key$getState$forceHi = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false
|
|
24
|
+
isForcedHidden: (_key$getState$forceHi = (_key$getState = key.getState(editorState)) === null || _key$getState === void 0 ? void 0 : _key$getState.forceHide) !== null && _key$getState$forceHi !== void 0 ? _key$getState$forceHi : false,
|
|
25
|
+
isMarkerActive: !((_key$getState2 = key.getState(editorState)) !== null && _key$getState2 !== void 0 && _key$getState2.shouldHideDecorations)
|
|
24
26
|
};
|
|
25
27
|
},
|
|
26
28
|
actions: {
|
|
@@ -41,17 +43,34 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
|
|
|
41
43
|
return undefined;
|
|
42
44
|
}
|
|
43
45
|
return cleanupHiddenDecoration(api);
|
|
46
|
+
},
|
|
47
|
+
queueHideDecoration: function queueHideDecoration(setCleanup) {
|
|
48
|
+
var result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
49
|
+
if (result === undefined) {
|
|
50
|
+
var _api$selectionMarker2;
|
|
51
|
+
var cleanup = api === null || api === void 0 || (_api$selectionMarker2 = api.selectionMarker) === null || _api$selectionMarker2 === void 0 ? void 0 : _api$selectionMarker2.sharedState.onChange(function (_ref3) {
|
|
52
|
+
var nextSharedState = _ref3.nextSharedState;
|
|
53
|
+
if ((nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isForcedHidden) === false && (nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.isMarkerActive) === false) {
|
|
54
|
+
var _result = api === null || api === void 0 ? void 0 : api.selectionMarker.actions.hideDecoration();
|
|
55
|
+
setCleanup(_result);
|
|
56
|
+
cleanup === null || cleanup === void 0 || cleanup();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return cleanup;
|
|
60
|
+
}
|
|
61
|
+
setCleanup(result);
|
|
62
|
+
return function () {};
|
|
44
63
|
}
|
|
45
64
|
},
|
|
46
|
-
usePluginHook: function usePluginHook(
|
|
47
|
-
var editorView =
|
|
65
|
+
usePluginHook: function usePluginHook(_ref4) {
|
|
66
|
+
var editorView = _ref4.editorView;
|
|
48
67
|
var _useSharedPluginState = useSharedPluginState(api, ['focus', 'typeAhead', 'editorDisabled', 'selectionMarker']),
|
|
49
68
|
focusState = _useSharedPluginState.focusState,
|
|
50
69
|
typeAheadState = _useSharedPluginState.typeAheadState,
|
|
51
|
-
selectionMarkerState = _useSharedPluginState.selectionMarkerState,
|
|
52
70
|
editorDisabledState = _useSharedPluginState.editorDisabledState;
|
|
71
|
+
var isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
|
|
53
72
|
useEffect(function () {
|
|
54
|
-
var
|
|
73
|
+
var _ref5, _typeAheadState$isOpe, _editorDisabledState$;
|
|
55
74
|
/**
|
|
56
75
|
* There are a number of conditions we should not show the marker,
|
|
57
76
|
* - Focus: to ensure it doesn't interrupt the normal cursor
|
|
@@ -59,11 +78,11 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
|
|
|
59
78
|
* - Disabled: So that it behaves similar to the renderer in live pages/disabled
|
|
60
79
|
* - Via the API: If another plugin has requested it to be hidden (force hidden).
|
|
61
80
|
*/
|
|
62
|
-
var shouldHide = (
|
|
81
|
+
var shouldHide = (_ref5 = (focusState === null || focusState === void 0 ? void 0 : focusState.hasFocus) || ((_typeAheadState$isOpe = typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isOpen) !== null && _typeAheadState$isOpe !== void 0 ? _typeAheadState$isOpe : false) || isForcedHidden || ((_editorDisabledState$ = editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled) !== null && _editorDisabledState$ !== void 0 ? _editorDisabledState$ : false)) !== null && _ref5 !== void 0 ? _ref5 : true;
|
|
63
82
|
requestAnimationFrame(function () {
|
|
64
83
|
return dispatchShouldHideDecorations(editorView, shouldHide);
|
|
65
84
|
});
|
|
66
|
-
}, [editorView, focusState, typeAheadState,
|
|
85
|
+
}, [editorView, focusState, typeAheadState, isForcedHidden, editorDisabledState]);
|
|
67
86
|
},
|
|
68
87
|
contentComponent: function contentComponent() {
|
|
69
88
|
return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
|
|
@@ -73,12 +92,12 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
|
|
|
73
92
|
function cleanupHiddenDecoration(api) {
|
|
74
93
|
var hasRun = false;
|
|
75
94
|
return function () {
|
|
76
|
-
var _api$
|
|
77
|
-
if (!hasRun && api !== null && api !== void 0 && (_api$
|
|
95
|
+
var _api$selectionMarker3;
|
|
96
|
+
if (!hasRun && api !== null && api !== void 0 && (_api$selectionMarker3 = api.selectionMarker) !== null && _api$selectionMarker3 !== void 0 && (_api$selectionMarker3 = _api$selectionMarker3.sharedState.currentState()) !== null && _api$selectionMarker3 !== void 0 && _api$selectionMarker3.isForcedHidden) {
|
|
78
97
|
var _api$core2;
|
|
79
98
|
hasRun = true;
|
|
80
|
-
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (
|
|
81
|
-
var tr =
|
|
99
|
+
return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref6) {
|
|
100
|
+
var tr = _ref6.tr;
|
|
82
101
|
return tr.setMeta(key, {
|
|
83
102
|
forceHide: false
|
|
84
103
|
});
|
|
@@ -82,10 +82,7 @@ var containsText = function containsText(resolvedPos) {
|
|
|
82
82
|
nodeAfter = resolvedPos.nodeAfter;
|
|
83
83
|
return (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.isInline) || (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.isInline);
|
|
84
84
|
};
|
|
85
|
-
export var createWidgetDecoration = function createWidgetDecoration(resolvedPos, type, selection, isHighlight
|
|
86
|
-
// Ignored via go/ees005
|
|
87
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
88
|
-
) {
|
|
85
|
+
export var createWidgetDecoration = function createWidgetDecoration(resolvedPos, type, selection, isHighlight) {
|
|
89
86
|
// We don't want the cursor to show if it's not text selection
|
|
90
87
|
// ie. if it's on media selection
|
|
91
88
|
if (!(selection instanceof TextSelection) || containsText(resolvedPos) === false || !selection.empty) {
|
|
@@ -3,6 +3,8 @@ import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabl
|
|
|
3
3
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
4
4
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
5
5
|
export type ReleaseHiddenDecoration = () => boolean | undefined;
|
|
6
|
+
type SetCleanup = (cb: ReleaseHiddenDecoration | undefined) => void;
|
|
7
|
+
type CancelQueue = (() => void) | undefined;
|
|
6
8
|
export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
|
|
7
9
|
dependencies: [
|
|
8
10
|
FocusPlugin,
|
|
@@ -11,8 +13,11 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
|
|
|
11
13
|
];
|
|
12
14
|
sharedState: {
|
|
13
15
|
isForcedHidden: boolean;
|
|
16
|
+
isMarkerActive: boolean;
|
|
14
17
|
} | undefined;
|
|
15
18
|
actions: {
|
|
16
19
|
hideDecoration: () => ReleaseHiddenDecoration | undefined;
|
|
20
|
+
queueHideDecoration: (setCleanup: SetCleanup) => CancelQueue;
|
|
17
21
|
};
|
|
18
22
|
}>;
|
|
23
|
+
export {};
|
|
@@ -3,6 +3,8 @@ import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabl
|
|
|
3
3
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
4
4
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
5
5
|
export type ReleaseHiddenDecoration = () => boolean | undefined;
|
|
6
|
+
type SetCleanup = (cb: ReleaseHiddenDecoration | undefined) => void;
|
|
7
|
+
type CancelQueue = (() => void) | undefined;
|
|
6
8
|
export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
|
|
7
9
|
dependencies: [
|
|
8
10
|
FocusPlugin,
|
|
@@ -11,8 +13,11 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
|
|
|
11
13
|
];
|
|
12
14
|
sharedState: {
|
|
13
15
|
isForcedHidden: boolean;
|
|
16
|
+
isMarkerActive: boolean;
|
|
14
17
|
} | undefined;
|
|
15
18
|
actions: {
|
|
16
19
|
hideDecoration: () => ReleaseHiddenDecoration | undefined;
|
|
20
|
+
queueHideDecoration: (setCleanup: SetCleanup) => CancelQueue;
|
|
17
21
|
};
|
|
18
22
|
}>;
|
|
23
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-selection-marker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Selection marker plugin for @atlaskit/editor-core.",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
".": "./src/index.ts"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@atlaskit/editor-common": "^99.
|
|
33
|
-
"@atlaskit/editor-plugin-editor-disabled": "^1.
|
|
32
|
+
"@atlaskit/editor-common": "^99.6.0",
|
|
33
|
+
"@atlaskit/editor-plugin-editor-disabled": "^1.4.0",
|
|
34
34
|
"@atlaskit/editor-plugin-focus": "^1.4.0",
|
|
35
|
-
"@atlaskit/editor-plugin-type-ahead": "^1.
|
|
35
|
+
"@atlaskit/editor-plugin-type-ahead": "^1.12.0",
|
|
36
36
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
38
|
-
"@atlaskit/primitives": "^13.
|
|
39
|
-
"@atlaskit/theme": "^14.
|
|
40
|
-
"@atlaskit/tokens": "^3.
|
|
38
|
+
"@atlaskit/primitives": "^13.4.0",
|
|
39
|
+
"@atlaskit/theme": "^14.1.0",
|
|
40
|
+
"@atlaskit/tokens": "^3.3.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"@emotion/react": "^11.7.1",
|
|
43
43
|
"lodash": "^4.17.21"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@af/visual-regression": "*",
|
|
52
52
|
"@atlaskit/ssr": "*",
|
|
53
53
|
"@atlaskit/visual-regression": "*",
|
|
54
|
-
"@testing-library/react": "^
|
|
54
|
+
"@testing-library/react": "^13.4.0",
|
|
55
55
|
"typescript": "~5.4.2",
|
|
56
56
|
"wait-for-expect": "^1.2.0"
|
|
57
57
|
},
|