@atlaskit/editor-plugin-card 6.0.0 → 6.0.1
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 +9 -0
- package/dist/cjs/nodeviews/embedCard.js +25 -6
- package/dist/cjs/nodeviews/genericCard.js +16 -3
- package/dist/cjs/nodeviews/inlineCard.js +23 -6
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +17 -4
- package/dist/cjs/ui/DatasourceModal/ModalWithState.js +24 -5
- package/dist/cjs/ui/LayoutButton/index.js +20 -9
- package/dist/es2019/nodeviews/embedCard.js +27 -7
- package/dist/es2019/nodeviews/genericCard.js +18 -4
- package/dist/es2019/nodeviews/inlineCard.js +25 -7
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +19 -5
- package/dist/es2019/ui/DatasourceModal/ModalWithState.js +26 -8
- package/dist/es2019/ui/LayoutButton/index.js +22 -11
- package/dist/esm/nodeviews/embedCard.js +26 -7
- package/dist/esm/nodeviews/genericCard.js +17 -4
- package/dist/esm/nodeviews/inlineCard.js +24 -7
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -5
- package/dist/esm/ui/DatasourceModal/ModalWithState.js +25 -6
- package/dist/esm/ui/LayoutButton/index.js +21 -10
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 6.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#147070](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/147070)
|
|
8
|
+
[`9fec1cb4ec861`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9fec1cb4ec861) -
|
|
9
|
+
Migrate Card plugin to use useSharedPluginStateSelector
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 6.0.0
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -20,6 +20,7 @@ var _steps = require("@atlaskit/adf-schema/steps");
|
|
|
20
20
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
21
21
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
22
22
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
23
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
23
24
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
24
25
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
25
26
|
var _smartCard = require("@atlaskit/smart-card");
|
|
@@ -31,6 +32,25 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
31
32
|
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; }
|
|
32
33
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
33
34
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
35
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
36
|
+
var lineLength = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'width.lineLength');
|
|
37
|
+
var width = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'width.width');
|
|
38
|
+
var editorDisabled = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
39
|
+
return {
|
|
40
|
+
widthStateLineLength: lineLength || 0,
|
|
41
|
+
widthStateWidth: width || 0,
|
|
42
|
+
editorDisabled: editorDisabled
|
|
43
|
+
};
|
|
44
|
+
}, function (pluginInjectionApi) {
|
|
45
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['width', 'editorDisabled']),
|
|
46
|
+
widthState = _useSharedPluginState.widthState,
|
|
47
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState;
|
|
48
|
+
return {
|
|
49
|
+
widthStateLineLength: (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0,
|
|
50
|
+
widthStateWidth: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
|
|
51
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
|
|
52
|
+
};
|
|
53
|
+
});
|
|
34
54
|
var CardInner = function CardInner(_ref) {
|
|
35
55
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
36
56
|
getPosSafely = _ref.getPosSafely,
|
|
@@ -46,11 +66,10 @@ var CardInner = function CardInner(_ref) {
|
|
|
46
66
|
heightAlone = _ref.heightAlone,
|
|
47
67
|
cardProps = _ref.cardProps,
|
|
48
68
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
var widthStateWidth = (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0;
|
|
69
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
70
|
+
widthStateLineLength = _useSharedState.widthStateLineLength,
|
|
71
|
+
widthStateWidth = _useSharedState.widthStateWidth,
|
|
72
|
+
editorDisabled = _useSharedState.editorDisabled;
|
|
54
73
|
var pos = getPosSafely();
|
|
55
74
|
if (pos === undefined) {
|
|
56
75
|
return null;
|
|
@@ -103,7 +122,7 @@ var CardInner = function CardInner(_ref) {
|
|
|
103
122
|
displayGrid: displayGrid,
|
|
104
123
|
updateSize: updateSize,
|
|
105
124
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
106
|
-
isResizeDisabled:
|
|
125
|
+
isResizeDisabled: editorDisabled
|
|
107
126
|
}), smartCard);
|
|
108
127
|
};
|
|
109
128
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -17,6 +17,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
17
17
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
18
18
|
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
19
19
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
20
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
20
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
22
23
|
var _doc = require("../pm-plugins/doc");
|
|
@@ -27,14 +28,26 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
27
28
|
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 && {}.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; }
|
|
28
29
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
29
30
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
31
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
32
|
+
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode');
|
|
33
|
+
return {
|
|
34
|
+
mode: mode
|
|
35
|
+
};
|
|
36
|
+
}, function (pluginInjectionApi) {
|
|
37
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['editorViewMode']),
|
|
38
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
39
|
+
return {
|
|
40
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
41
|
+
};
|
|
42
|
+
});
|
|
30
43
|
var WithClickHandler = function WithClickHandler(_ref) {
|
|
31
44
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
32
45
|
url = _ref.url,
|
|
33
46
|
onClickCallback = _ref.onClickCallback,
|
|
34
47
|
children = _ref.children,
|
|
35
48
|
__livePage = _ref.__livePage;
|
|
36
|
-
var
|
|
37
|
-
|
|
49
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
50
|
+
mode = _useSharedState.mode;
|
|
38
51
|
var onClick = (0, _react.useCallback)(function (event) {
|
|
39
52
|
if (typeof onClickCallback === 'function') {
|
|
40
53
|
try {
|
|
@@ -63,7 +76,7 @@ var WithClickHandler = function WithClickHandler(_ref) {
|
|
|
63
76
|
|
|
64
77
|
// Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
|
|
65
78
|
// If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
|
|
66
|
-
var allowNavigation =
|
|
79
|
+
var allowNavigation = mode === 'view' && !onClickCallback;
|
|
67
80
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children({
|
|
68
81
|
onClick: allowNavigation ? undefined : onClick
|
|
69
82
|
}));
|
|
@@ -16,6 +16,7 @@ var _v = _interopRequireDefault(require("uuid/v4"));
|
|
|
16
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
17
17
|
var _link = require("@atlaskit/editor-common/link");
|
|
18
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
19
20
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
20
21
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
22
|
var _smartCard = require("@atlaskit/smart-card");
|
|
@@ -137,6 +138,22 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
137
138
|
});
|
|
138
139
|
var WrappedInlineCardWithAwareness = (0, _genericCard.Card)(_inlineCardWithAwareness.InlineCardWithAwareness, _ui.UnsupportedInline);
|
|
139
140
|
var WrappedInlineCard = (0, _genericCard.Card)(InlineCard, _ui.UnsupportedInline);
|
|
141
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
142
|
+
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode');
|
|
143
|
+
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'selection.selection');
|
|
144
|
+
return {
|
|
145
|
+
mode: mode,
|
|
146
|
+
selection: selection
|
|
147
|
+
};
|
|
148
|
+
}, function (pluginInjectionApi) {
|
|
149
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['selection', 'editorViewMode']),
|
|
150
|
+
selectionState = _useSharedPluginState.selectionState,
|
|
151
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
152
|
+
return {
|
|
153
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
154
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
155
|
+
};
|
|
156
|
+
});
|
|
140
157
|
function InlineCardNodeView(props) {
|
|
141
158
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
142
159
|
node = props.node,
|
|
@@ -154,10 +171,10 @@ function InlineCardNodeView(props) {
|
|
|
154
171
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
155
172
|
isOverlayHovered = _useState2[0],
|
|
156
173
|
setIsOverlayHovered = _useState2[1];
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
var floatingToolbarNode =
|
|
174
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
175
|
+
mode = _useSharedState.mode,
|
|
176
|
+
selection = _useSharedState.selection;
|
|
177
|
+
var floatingToolbarNode = selection instanceof _state.NodeSelection && selection.node;
|
|
161
178
|
if (__livePage && (0, _platformFeatureFlags.fg)('linking_platform_smart_links_in_live_pages')) {
|
|
162
179
|
var showHoverPreview = floatingToolbarNode !== node;
|
|
163
180
|
var livePagesHoverCardFadeInDelay = 800;
|
|
@@ -175,7 +192,7 @@ function InlineCardNodeView(props) {
|
|
|
175
192
|
},
|
|
176
193
|
isPageSSRed: isPageSSRed
|
|
177
194
|
});
|
|
178
|
-
return
|
|
195
|
+
return mode === 'view' ? inlineCard : /*#__PURE__*/_react.default.createElement(_ConfigureOverlay.default, {
|
|
179
196
|
targetElementPos: getPos(),
|
|
180
197
|
view: view,
|
|
181
198
|
isHoveredCallback: setIsOverlayHovered,
|
|
@@ -202,7 +219,7 @@ function InlineCardNodeView(props) {
|
|
|
202
219
|
appearance: "inline"
|
|
203
220
|
// Ignored via go/ees005
|
|
204
221
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
205
|
-
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, !(0, _experiments.editorExperiment)('live_pages_graceful_edit', 'control') ? true :
|
|
222
|
+
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, !(0, _experiments.editorExperiment)('live_pages_graceful_edit', 'control') ? true : mode === 'view')));
|
|
206
223
|
}
|
|
207
224
|
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
208
225
|
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
@@ -9,6 +9,7 @@ exports.InlineCardWithAwareness = void 0;
|
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
12
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
14
15
|
var _actions = require("../pm-plugins/actions");
|
|
@@ -18,6 +19,18 @@ var _OpenButtonOverlay = _interopRequireDefault(require("../ui/OpenButtonOverlay
|
|
|
18
19
|
var _inlineCard = require("./inlineCard");
|
|
19
20
|
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); }
|
|
20
21
|
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 && {}.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; }
|
|
22
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
23
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['editorViewMode']),
|
|
24
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
25
|
+
return {
|
|
26
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
27
|
+
};
|
|
28
|
+
}, function (pluginInjectionApi) {
|
|
29
|
+
var mode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'editorViewMode.mode');
|
|
30
|
+
return {
|
|
31
|
+
mode: mode
|
|
32
|
+
};
|
|
33
|
+
});
|
|
21
34
|
var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
22
35
|
var _pluginInjectionApi$c, _pluginInjectionApi$a;
|
|
23
36
|
var node = _ref.node,
|
|
@@ -73,8 +86,8 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
73
86
|
setIsHovered(isHovered);
|
|
74
87
|
}
|
|
75
88
|
}, [isOverlayEnabled]);
|
|
76
|
-
var
|
|
77
|
-
|
|
89
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
90
|
+
mode = _useSharedState.mode;
|
|
78
91
|
var innerCardWithOpenButtonOverlay = (0, _react.useMemo)(function () {
|
|
79
92
|
return /*#__PURE__*/_react.default.createElement(_OpenButtonOverlay.default, {
|
|
80
93
|
isVisible: isResolvedViewRendered,
|
|
@@ -111,8 +124,8 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
111
124
|
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed]);
|
|
112
125
|
var shouldShowOpenButtonOverlay = (0, _react.useMemo)(function () {
|
|
113
126
|
var shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless' && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_8');
|
|
114
|
-
return (
|
|
115
|
-
}, [
|
|
127
|
+
return (mode === 'edit' || editorAppearance === 'comment' && (0, _platformFeatureFlags.fg)('platform_editor_controls_patch_6') || shouldShowOpenButtonOverlayInChomeless) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1');
|
|
128
|
+
}, [mode, editorAppearance]);
|
|
116
129
|
var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
117
130
|
var getPosFunction = typeof getPos === 'function' ? getPos : undefined;
|
|
118
131
|
var placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
|
|
@@ -7,21 +7,40 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.modalTypeToComponentMap = exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(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 _linkDatasource = require("@atlaskit/link-datasource");
|
|
11
12
|
var _linkProvider = require("@atlaskit/link-provider");
|
|
13
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
14
|
var _datasourceErrorBoundary = require("../datasourceErrorBoundary");
|
|
13
15
|
var _index = require("./index");
|
|
16
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
17
|
+
var showDatasourceModal = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'card.showDatasourceModal');
|
|
18
|
+
var datasourceModalType = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'card.datasourceModalType');
|
|
19
|
+
return {
|
|
20
|
+
cardState: undefined,
|
|
21
|
+
showDatasourceModal: showDatasourceModal,
|
|
22
|
+
datasourceModalType: datasourceModalType
|
|
23
|
+
};
|
|
24
|
+
}, function (pluginInjectionApi) {
|
|
25
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['card']),
|
|
26
|
+
cardState = _useSharedPluginState.cardState;
|
|
27
|
+
return {
|
|
28
|
+
cardState: cardState,
|
|
29
|
+
showDatasourceModal: cardState === null || cardState === void 0 ? void 0 : cardState.showDatasourceModal,
|
|
30
|
+
datasourceModalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
|
|
31
|
+
};
|
|
32
|
+
});
|
|
14
33
|
var ModalWithState = function ModalWithState(_ref) {
|
|
15
34
|
var api = _ref.api,
|
|
16
35
|
editorView = _ref.editorView;
|
|
17
36
|
var cardContext = (0, _linkProvider.useSmartLinkContext)();
|
|
18
|
-
var
|
|
19
|
-
cardState =
|
|
20
|
-
|
|
37
|
+
var _useSharedState = useSharedState(api),
|
|
38
|
+
cardState = _useSharedState.cardState,
|
|
39
|
+
showDatasourceModal = _useSharedState.showDatasourceModal,
|
|
40
|
+
datasourceModalType = _useSharedState.datasourceModalType;
|
|
41
|
+
if (!cardState && (0, _experiments.editorExperiment)('platform_editor_usesharedpluginstateselector', false)) {
|
|
21
42
|
return null;
|
|
22
43
|
}
|
|
23
|
-
var showDatasourceModal = cardState.showDatasourceModal,
|
|
24
|
-
datasourceModalType = cardState.datasourceModalType;
|
|
25
44
|
if (!showDatasourceModal || !datasourceModalType) {
|
|
26
45
|
return null;
|
|
27
46
|
}
|
|
@@ -12,6 +12,7 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
12
12
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
13
13
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
14
14
|
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
15
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
15
16
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
17
|
var _growHorizontalEditorExpand = _interopRequireDefault(require("@atlaskit/icon/core/migration/grow-horizontal--editor-expand"));
|
|
17
18
|
var _shrinkHorizontalEditorCollapse = _interopRequireDefault(require("@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse"));
|
|
@@ -77,6 +78,21 @@ var LayoutButton = exports.LayoutButton = function LayoutButton(_ref) {
|
|
|
77
78
|
})
|
|
78
79
|
}));
|
|
79
80
|
};
|
|
81
|
+
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
82
|
+
var layout = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'card.layout');
|
|
83
|
+
var datasourceTableRef = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'card.datasourceTableRef');
|
|
84
|
+
return {
|
|
85
|
+
layout: layout,
|
|
86
|
+
datasourceTableRef: datasourceTableRef
|
|
87
|
+
};
|
|
88
|
+
}, function (pluginInjectionApi) {
|
|
89
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['card']),
|
|
90
|
+
cardState = _useSharedPluginState.cardState;
|
|
91
|
+
return {
|
|
92
|
+
layout: cardState === null || cardState === void 0 ? void 0 : cardState.layout,
|
|
93
|
+
datasourceTableRef: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceTableRef
|
|
94
|
+
};
|
|
95
|
+
});
|
|
80
96
|
var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
81
97
|
var _node$attrs;
|
|
82
98
|
var editorView = _ref2.editorView,
|
|
@@ -85,22 +101,17 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
85
101
|
boundariesElement = _ref2.boundariesElement,
|
|
86
102
|
intl = _ref2.intl,
|
|
87
103
|
api = _ref2.api;
|
|
88
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['card']),
|
|
89
|
-
cardState = _useSharedPluginState.cardState;
|
|
90
104
|
var _getDatasource = (0, _utils3.getDatasource)(editorView),
|
|
91
105
|
node = _getDatasource.node,
|
|
92
106
|
pos = _getDatasource.pos;
|
|
107
|
+
var _useSharedState = useSharedState(api),
|
|
108
|
+
_useSharedState$layou = _useSharedState.layout,
|
|
109
|
+
layout = _useSharedState$layou === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _useSharedState$layou,
|
|
110
|
+
datasourceTableRef = _useSharedState.datasourceTableRef;
|
|
93
111
|
var isDatasource = (0, _utils2.isDatasourceNode)(node);
|
|
94
112
|
if (!isDatasource) {
|
|
95
113
|
return null;
|
|
96
114
|
}
|
|
97
|
-
|
|
98
|
-
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
99
|
-
// which results in default parameter value being used in LayoutButton.
|
|
100
|
-
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
101
|
-
datasourceTableRef = _ref3.datasourceTableRef,
|
|
102
|
-
_ref3$layout = _ref3.layout,
|
|
103
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _ref3$layout;
|
|
104
115
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
105
116
|
var _getDatasource$node;
|
|
106
117
|
if (pos === undefined) {
|
|
@@ -4,15 +4,36 @@ import React from 'react';
|
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import uuid from 'uuid/v4';
|
|
6
6
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
7
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
9
9
|
import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
10
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
10
11
|
import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
11
12
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
12
13
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
13
14
|
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
15
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
15
16
|
import { Card } from './genericCard';
|
|
17
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
18
|
+
const lineLength = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength');
|
|
19
|
+
const width = useSharedPluginStateSelector(pluginInjectionApi, 'width.width');
|
|
20
|
+
const editorDisabled = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
21
|
+
return {
|
|
22
|
+
widthStateLineLength: lineLength || 0,
|
|
23
|
+
widthStateWidth: width || 0,
|
|
24
|
+
editorDisabled
|
|
25
|
+
};
|
|
26
|
+
}, pluginInjectionApi => {
|
|
27
|
+
const {
|
|
28
|
+
widthState,
|
|
29
|
+
editorDisabledState
|
|
30
|
+
} = useSharedPluginState(pluginInjectionApi, ['width', 'editorDisabled']);
|
|
31
|
+
return {
|
|
32
|
+
widthStateLineLength: (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0,
|
|
33
|
+
widthStateWidth: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
|
|
34
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
|
|
35
|
+
};
|
|
36
|
+
});
|
|
16
37
|
const CardInner = ({
|
|
17
38
|
pluginInjectionApi,
|
|
18
39
|
getPosSafely,
|
|
@@ -30,11 +51,10 @@ const CardInner = ({
|
|
|
30
51
|
dispatchAnalyticsEvent
|
|
31
52
|
}) => {
|
|
32
53
|
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const widthStateWidth = (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0;
|
|
54
|
+
widthStateLineLength,
|
|
55
|
+
widthStateWidth,
|
|
56
|
+
editorDisabled
|
|
57
|
+
} = useSharedState(pluginInjectionApi);
|
|
38
58
|
const pos = getPosSafely();
|
|
39
59
|
if (pos === undefined) {
|
|
40
60
|
return null;
|
|
@@ -87,7 +107,7 @@ const CardInner = ({
|
|
|
87
107
|
displayGrid: displayGrid,
|
|
88
108
|
updateSize: updateSize,
|
|
89
109
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
90
|
-
isResizeDisabled:
|
|
110
|
+
isResizeDisabled: editorDisabled
|
|
91
111
|
}), smartCard);
|
|
92
112
|
};
|
|
93
113
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -3,13 +3,27 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import React, { useCallback } from 'react';
|
|
4
4
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
5
5
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
6
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
7
8
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
10
11
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
11
12
|
import { titleUrlPairFromNode } from '../pm-plugins/utils';
|
|
12
13
|
import { WithCardContext } from '../ui/WithCardContext';
|
|
14
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
15
|
+
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
16
|
+
return {
|
|
17
|
+
mode
|
|
18
|
+
};
|
|
19
|
+
}, pluginInjectionApi => {
|
|
20
|
+
const {
|
|
21
|
+
editorViewModeState
|
|
22
|
+
} = useSharedPluginState(pluginInjectionApi, ['editorViewMode']);
|
|
23
|
+
return {
|
|
24
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
25
|
+
};
|
|
26
|
+
});
|
|
13
27
|
const WithClickHandler = ({
|
|
14
28
|
pluginInjectionApi,
|
|
15
29
|
url,
|
|
@@ -18,8 +32,8 @@ const WithClickHandler = ({
|
|
|
18
32
|
__livePage
|
|
19
33
|
}) => {
|
|
20
34
|
const {
|
|
21
|
-
|
|
22
|
-
} =
|
|
35
|
+
mode
|
|
36
|
+
} = useSharedState(pluginInjectionApi);
|
|
23
37
|
const onClick = useCallback(event => {
|
|
24
38
|
if (typeof onClickCallback === 'function') {
|
|
25
39
|
try {
|
|
@@ -48,7 +62,7 @@ const WithClickHandler = ({
|
|
|
48
62
|
|
|
49
63
|
// Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
|
|
50
64
|
// If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
|
|
51
|
-
const allowNavigation =
|
|
65
|
+
const allowNavigation = mode === 'view' && !onClickCallback;
|
|
52
66
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children({
|
|
53
67
|
onClick: allowNavigation ? undefined : onClick
|
|
54
68
|
}));
|
|
@@ -2,9 +2,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
4
|
import uuid from 'uuid/v4';
|
|
5
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
6
|
import { handleNavigation } from '@atlaskit/editor-common/link';
|
|
7
7
|
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
8
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
8
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
11
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
@@ -130,6 +131,23 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
130
131
|
});
|
|
131
132
|
const WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
132
133
|
const WrappedInlineCard = Card(InlineCard, UnsupportedInline);
|
|
134
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
135
|
+
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
136
|
+
const selection = useSharedPluginStateSelector(pluginInjectionApi, 'selection.selection');
|
|
137
|
+
return {
|
|
138
|
+
mode,
|
|
139
|
+
selection
|
|
140
|
+
};
|
|
141
|
+
}, pluginInjectionApi => {
|
|
142
|
+
const {
|
|
143
|
+
selectionState,
|
|
144
|
+
editorViewModeState
|
|
145
|
+
} = useSharedPluginState(pluginInjectionApi, ['selection', 'editorViewMode']);
|
|
146
|
+
return {
|
|
147
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
148
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
149
|
+
};
|
|
150
|
+
});
|
|
133
151
|
export function InlineCardNodeView(props) {
|
|
134
152
|
const {
|
|
135
153
|
useAlternativePreloader,
|
|
@@ -147,10 +165,10 @@ export function InlineCardNodeView(props) {
|
|
|
147
165
|
} = props;
|
|
148
166
|
const [isOverlayHovered, setIsOverlayHovered] = useState(false);
|
|
149
167
|
const {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
} =
|
|
153
|
-
const floatingToolbarNode =
|
|
168
|
+
mode,
|
|
169
|
+
selection
|
|
170
|
+
} = useSharedState(pluginInjectionApi);
|
|
171
|
+
const floatingToolbarNode = selection instanceof NodeSelection && selection.node;
|
|
154
172
|
if (__livePage && fg('linking_platform_smart_links_in_live_pages')) {
|
|
155
173
|
const showHoverPreview = floatingToolbarNode !== node;
|
|
156
174
|
const livePagesHoverCardFadeInDelay = 800;
|
|
@@ -168,7 +186,7 @@ export function InlineCardNodeView(props) {
|
|
|
168
186
|
},
|
|
169
187
|
isPageSSRed: isPageSSRed
|
|
170
188
|
});
|
|
171
|
-
return
|
|
189
|
+
return mode === 'view' ? inlineCard : /*#__PURE__*/React.createElement(OverlayWrapper, {
|
|
172
190
|
targetElementPos: getPos(),
|
|
173
191
|
view: view,
|
|
174
192
|
isHoveredCallback: setIsOverlayHovered,
|
|
@@ -195,7 +213,7 @@ export function InlineCardNodeView(props) {
|
|
|
195
213
|
appearance: "inline"
|
|
196
214
|
// Ignored via go/ees005
|
|
197
215
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
198
|
-
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true :
|
|
216
|
+
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true : mode === 'view')));
|
|
199
217
|
}
|
|
200
218
|
export const inlineCardNodeView = ({
|
|
201
219
|
inlineCardViewProducer
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
@@ -7,6 +8,19 @@ import { pluginKey } from '../pm-plugins/plugin-key';
|
|
|
7
8
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
8
9
|
import OpenButtonOverlay from '../ui/OpenButtonOverlay';
|
|
9
10
|
import { InlineCard } from './inlineCard';
|
|
11
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
12
|
+
const {
|
|
13
|
+
editorViewModeState
|
|
14
|
+
} = useSharedPluginState(pluginInjectionApi, ['editorViewMode']);
|
|
15
|
+
return {
|
|
16
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
17
|
+
};
|
|
18
|
+
}, pluginInjectionApi => {
|
|
19
|
+
const mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
20
|
+
return {
|
|
21
|
+
mode
|
|
22
|
+
};
|
|
23
|
+
});
|
|
10
24
|
export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
11
25
|
node,
|
|
12
26
|
cardContext,
|
|
@@ -52,8 +66,8 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
52
66
|
}
|
|
53
67
|
}, [isOverlayEnabled]);
|
|
54
68
|
const {
|
|
55
|
-
|
|
56
|
-
} =
|
|
69
|
+
mode
|
|
70
|
+
} = useSharedState(pluginInjectionApi);
|
|
57
71
|
const innerCardWithOpenButtonOverlay = useMemo(() => /*#__PURE__*/React.createElement(OpenButtonOverlay, {
|
|
58
72
|
isVisible: isResolvedViewRendered,
|
|
59
73
|
url: node.attrs.url,
|
|
@@ -86,8 +100,8 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
86
100
|
}), [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed]);
|
|
87
101
|
const shouldShowOpenButtonOverlay = useMemo(() => {
|
|
88
102
|
const shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless' && fg('platform_editor_controls_patch_8');
|
|
89
|
-
return (
|
|
90
|
-
}, [
|
|
103
|
+
return (mode === 'edit' || editorAppearance === 'comment' && fg('platform_editor_controls_patch_6') || shouldShowOpenButtonOverlayInChomeless) && editorExperiment('platform_editor_controls', 'variant1');
|
|
104
|
+
}, [mode, editorAppearance]);
|
|
91
105
|
const innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
92
106
|
const getPosFunction = typeof getPos === 'function' ? getPos : undefined;
|
|
93
107
|
const placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
|
|
@@ -1,24 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
4
5
|
import { EditorSmartCardProviderValueGuard, useSmartLinkContext } from '@atlaskit/link-provider';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
|
|
6
8
|
import { DatasourceModal } from './index';
|
|
9
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
10
|
+
const showDatasourceModal = useSharedPluginStateSelector(pluginInjectionApi, 'card.showDatasourceModal');
|
|
11
|
+
const datasourceModalType = useSharedPluginStateSelector(pluginInjectionApi, 'card.datasourceModalType');
|
|
12
|
+
return {
|
|
13
|
+
cardState: undefined,
|
|
14
|
+
showDatasourceModal,
|
|
15
|
+
datasourceModalType
|
|
16
|
+
};
|
|
17
|
+
}, pluginInjectionApi => {
|
|
18
|
+
const {
|
|
19
|
+
cardState
|
|
20
|
+
} = useSharedPluginState(pluginInjectionApi, ['card']);
|
|
21
|
+
return {
|
|
22
|
+
cardState,
|
|
23
|
+
showDatasourceModal: cardState === null || cardState === void 0 ? void 0 : cardState.showDatasourceModal,
|
|
24
|
+
datasourceModalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
|
|
25
|
+
};
|
|
26
|
+
});
|
|
7
27
|
const ModalWithState = ({
|
|
8
28
|
api,
|
|
9
29
|
editorView
|
|
10
30
|
}) => {
|
|
11
31
|
const cardContext = useSmartLinkContext();
|
|
12
32
|
const {
|
|
13
|
-
cardState
|
|
14
|
-
} = useSharedPluginState(api, ['card']);
|
|
15
|
-
if (!cardState) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const {
|
|
33
|
+
cardState,
|
|
19
34
|
showDatasourceModal,
|
|
20
35
|
datasourceModalType
|
|
21
|
-
} =
|
|
36
|
+
} = useSharedState(api);
|
|
37
|
+
if (!cardState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
22
40
|
if (!showDatasourceModal || !datasourceModalType) {
|
|
23
41
|
return null;
|
|
24
42
|
}
|
|
@@ -7,9 +7,10 @@ import { useCallback, useMemo } from 'react';
|
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
8
|
import { css, jsx } from '@emotion/react';
|
|
9
9
|
import { injectIntl } from 'react-intl-next';
|
|
10
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
11
11
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
12
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
13
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
13
14
|
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
14
15
|
import GrowHorizontalIcon from '@atlaskit/icon/core/migration/grow-horizontal--editor-expand';
|
|
15
16
|
import ShrinkHorizontalIcon from '@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse';
|
|
@@ -71,6 +72,22 @@ export const LayoutButton = ({
|
|
|
71
72
|
})
|
|
72
73
|
}));
|
|
73
74
|
};
|
|
75
|
+
const useSharedState = sharedPluginStateHookMigratorFactory(pluginInjectionApi => {
|
|
76
|
+
const layout = useSharedPluginStateSelector(pluginInjectionApi, 'card.layout');
|
|
77
|
+
const datasourceTableRef = useSharedPluginStateSelector(pluginInjectionApi, 'card.datasourceTableRef');
|
|
78
|
+
return {
|
|
79
|
+
layout,
|
|
80
|
+
datasourceTableRef
|
|
81
|
+
};
|
|
82
|
+
}, pluginInjectionApi => {
|
|
83
|
+
const {
|
|
84
|
+
cardState
|
|
85
|
+
} = useSharedPluginState(pluginInjectionApi, ['card']);
|
|
86
|
+
return {
|
|
87
|
+
layout: cardState === null || cardState === void 0 ? void 0 : cardState.layout,
|
|
88
|
+
datasourceTableRef: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceTableRef
|
|
89
|
+
};
|
|
90
|
+
});
|
|
74
91
|
const LayoutButtonWrapper = ({
|
|
75
92
|
editorView,
|
|
76
93
|
mountPoint,
|
|
@@ -80,24 +97,18 @@ const LayoutButtonWrapper = ({
|
|
|
80
97
|
api
|
|
81
98
|
}) => {
|
|
82
99
|
var _node$attrs;
|
|
83
|
-
const {
|
|
84
|
-
cardState
|
|
85
|
-
} = useSharedPluginState(api, ['card']);
|
|
86
100
|
const {
|
|
87
101
|
node,
|
|
88
102
|
pos
|
|
89
103
|
} = getDatasource(editorView);
|
|
104
|
+
const {
|
|
105
|
+
layout = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined,
|
|
106
|
+
datasourceTableRef
|
|
107
|
+
} = useSharedState(api);
|
|
90
108
|
const isDatasource = isDatasourceNode(node);
|
|
91
109
|
if (!isDatasource) {
|
|
92
110
|
return null;
|
|
93
111
|
}
|
|
94
|
-
|
|
95
|
-
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
96
|
-
// which results in default parameter value being used in LayoutButton.
|
|
97
|
-
const {
|
|
98
|
-
datasourceTableRef,
|
|
99
|
-
layout = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined
|
|
100
|
-
} = cardState !== null && cardState !== void 0 ? cardState : {};
|
|
101
112
|
const onLayoutChange = layout => {
|
|
102
113
|
var _getDatasource$node;
|
|
103
114
|
if (pos === undefined) {
|
|
@@ -15,15 +15,35 @@ import React from 'react';
|
|
|
15
15
|
import rafSchedule from 'raf-schd';
|
|
16
16
|
import uuid from 'uuid/v4';
|
|
17
17
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
18
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
19
19
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
20
20
|
import { findOverflowScrollParent, MediaSingle as RichMediaWrapper, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
21
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
21
22
|
import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
22
23
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
23
24
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
24
25
|
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
25
26
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
26
27
|
import { Card } from './genericCard';
|
|
28
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
29
|
+
var lineLength = useSharedPluginStateSelector(pluginInjectionApi, 'width.lineLength');
|
|
30
|
+
var width = useSharedPluginStateSelector(pluginInjectionApi, 'width.width');
|
|
31
|
+
var editorDisabled = useSharedPluginStateSelector(pluginInjectionApi, 'editorDisabled.editorDisabled');
|
|
32
|
+
return {
|
|
33
|
+
widthStateLineLength: lineLength || 0,
|
|
34
|
+
widthStateWidth: width || 0,
|
|
35
|
+
editorDisabled: editorDisabled
|
|
36
|
+
};
|
|
37
|
+
}, function (pluginInjectionApi) {
|
|
38
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['width', 'editorDisabled']),
|
|
39
|
+
widthState = _useSharedPluginState.widthState,
|
|
40
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState;
|
|
41
|
+
return {
|
|
42
|
+
widthStateLineLength: (widthState === null || widthState === void 0 ? void 0 : widthState.lineLength) || 0,
|
|
43
|
+
widthStateWidth: (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0,
|
|
44
|
+
editorDisabled: editorDisabledState === null || editorDisabledState === void 0 ? void 0 : editorDisabledState.editorDisabled
|
|
45
|
+
};
|
|
46
|
+
});
|
|
27
47
|
var CardInner = function CardInner(_ref) {
|
|
28
48
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
29
49
|
getPosSafely = _ref.getPosSafely,
|
|
@@ -39,11 +59,10 @@ var CardInner = function CardInner(_ref) {
|
|
|
39
59
|
heightAlone = _ref.heightAlone,
|
|
40
60
|
cardProps = _ref.cardProps,
|
|
41
61
|
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent;
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var widthStateWidth = (widthState === null || widthState === void 0 ? void 0 : widthState.width) || 0;
|
|
62
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
63
|
+
widthStateLineLength = _useSharedState.widthStateLineLength,
|
|
64
|
+
widthStateWidth = _useSharedState.widthStateWidth,
|
|
65
|
+
editorDisabled = _useSharedState.editorDisabled;
|
|
47
66
|
var pos = getPosSafely();
|
|
48
67
|
if (pos === undefined) {
|
|
49
68
|
return null;
|
|
@@ -96,7 +115,7 @@ var CardInner = function CardInner(_ref) {
|
|
|
96
115
|
displayGrid: displayGrid,
|
|
97
116
|
updateSize: updateSize,
|
|
98
117
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
99
|
-
isResizeDisabled:
|
|
118
|
+
isResizeDisabled: editorDisabled
|
|
100
119
|
}), smartCard);
|
|
101
120
|
};
|
|
102
121
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
@@ -10,21 +10,34 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
10
10
|
import React, { useCallback } from 'react';
|
|
11
11
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
12
12
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
13
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
14
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
14
15
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
15
16
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
16
17
|
import { changeSelectedCardToLinkFallback } from '../pm-plugins/doc';
|
|
17
18
|
import { getPluginState } from '../pm-plugins/util/state';
|
|
18
19
|
import { titleUrlPairFromNode } from '../pm-plugins/utils';
|
|
19
20
|
import { WithCardContext } from '../ui/WithCardContext';
|
|
21
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
22
|
+
var mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
23
|
+
return {
|
|
24
|
+
mode: mode
|
|
25
|
+
};
|
|
26
|
+
}, function (pluginInjectionApi) {
|
|
27
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
|
|
28
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
29
|
+
return {
|
|
30
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
31
|
+
};
|
|
32
|
+
});
|
|
20
33
|
var WithClickHandler = function WithClickHandler(_ref) {
|
|
21
34
|
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
22
35
|
url = _ref.url,
|
|
23
36
|
onClickCallback = _ref.onClickCallback,
|
|
24
37
|
children = _ref.children,
|
|
25
38
|
__livePage = _ref.__livePage;
|
|
26
|
-
var
|
|
27
|
-
|
|
39
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
40
|
+
mode = _useSharedState.mode;
|
|
28
41
|
var onClick = useCallback(function (event) {
|
|
29
42
|
if (typeof onClickCallback === 'function') {
|
|
30
43
|
try {
|
|
@@ -53,7 +66,7 @@ var WithClickHandler = function WithClickHandler(_ref) {
|
|
|
53
66
|
|
|
54
67
|
// Setting `onClick` to `undefined` ensures clicks on smartcards navigate to the URL.
|
|
55
68
|
// If in view mode and not overriding with onClickCallback option, then allow smartlinks to navigate on click.
|
|
56
|
-
var allowNavigation =
|
|
69
|
+
var allowNavigation = mode === 'view' && !onClickCallback;
|
|
57
70
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children({
|
|
58
71
|
onClick: allowNavigation ? undefined : onClick
|
|
59
72
|
}));
|
|
@@ -3,9 +3,10 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
3
3
|
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
5
|
import uuid from 'uuid/v4';
|
|
6
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { handleNavigation } from '@atlaskit/editor-common/link';
|
|
8
8
|
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
9
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
9
10
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
@@ -125,6 +126,22 @@ export var InlineCard = /*#__PURE__*/memo(function (_ref) {
|
|
|
125
126
|
});
|
|
126
127
|
var WrappedInlineCardWithAwareness = Card(InlineCardWithAwareness, UnsupportedInline);
|
|
127
128
|
var WrappedInlineCard = Card(InlineCard, UnsupportedInline);
|
|
129
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
130
|
+
var mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
131
|
+
var selection = useSharedPluginStateSelector(pluginInjectionApi, 'selection.selection');
|
|
132
|
+
return {
|
|
133
|
+
mode: mode,
|
|
134
|
+
selection: selection
|
|
135
|
+
};
|
|
136
|
+
}, function (pluginInjectionApi) {
|
|
137
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['selection', 'editorViewMode']),
|
|
138
|
+
selectionState = _useSharedPluginState.selectionState,
|
|
139
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
140
|
+
return {
|
|
141
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode,
|
|
142
|
+
selection: selectionState === null || selectionState === void 0 ? void 0 : selectionState.selection
|
|
143
|
+
};
|
|
144
|
+
});
|
|
128
145
|
export function InlineCardNodeView(props) {
|
|
129
146
|
var useAlternativePreloader = props.useAlternativePreloader,
|
|
130
147
|
node = props.node,
|
|
@@ -142,10 +159,10 @@ export function InlineCardNodeView(props) {
|
|
|
142
159
|
_useState2 = _slicedToArray(_useState, 2),
|
|
143
160
|
isOverlayHovered = _useState2[0],
|
|
144
161
|
setIsOverlayHovered = _useState2[1];
|
|
145
|
-
var
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
var floatingToolbarNode =
|
|
162
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
163
|
+
mode = _useSharedState.mode,
|
|
164
|
+
selection = _useSharedState.selection;
|
|
165
|
+
var floatingToolbarNode = selection instanceof NodeSelection && selection.node;
|
|
149
166
|
if (__livePage && fg('linking_platform_smart_links_in_live_pages')) {
|
|
150
167
|
var showHoverPreview = floatingToolbarNode !== node;
|
|
151
168
|
var livePagesHoverCardFadeInDelay = 800;
|
|
@@ -163,7 +180,7 @@ export function InlineCardNodeView(props) {
|
|
|
163
180
|
},
|
|
164
181
|
isPageSSRed: isPageSSRed
|
|
165
182
|
});
|
|
166
|
-
return
|
|
183
|
+
return mode === 'view' ? inlineCard : /*#__PURE__*/React.createElement(OverlayWrapper, {
|
|
167
184
|
targetElementPos: getPos(),
|
|
168
185
|
view: view,
|
|
169
186
|
isHoveredCallback: setIsOverlayHovered,
|
|
@@ -190,7 +207,7 @@ export function InlineCardNodeView(props) {
|
|
|
190
207
|
appearance: "inline"
|
|
191
208
|
// Ignored via go/ees005
|
|
192
209
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
193
|
-
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true :
|
|
210
|
+
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true : mode === 'view')));
|
|
194
211
|
}
|
|
195
212
|
export var inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
196
213
|
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
@@ -8,6 +9,18 @@ import { pluginKey } from '../pm-plugins/plugin-key';
|
|
|
8
9
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
9
10
|
import OpenButtonOverlay from '../ui/OpenButtonOverlay';
|
|
10
11
|
import { InlineCard } from './inlineCard';
|
|
12
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
13
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorViewMode']),
|
|
14
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
15
|
+
return {
|
|
16
|
+
mode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
17
|
+
};
|
|
18
|
+
}, function (pluginInjectionApi) {
|
|
19
|
+
var mode = useSharedPluginStateSelector(pluginInjectionApi, 'editorViewMode.mode');
|
|
20
|
+
return {
|
|
21
|
+
mode: mode
|
|
22
|
+
};
|
|
23
|
+
});
|
|
11
24
|
export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
12
25
|
var _pluginInjectionApi$c, _pluginInjectionApi$a;
|
|
13
26
|
var node = _ref.node,
|
|
@@ -63,8 +76,8 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
63
76
|
setIsHovered(isHovered);
|
|
64
77
|
}
|
|
65
78
|
}, [isOverlayEnabled]);
|
|
66
|
-
var
|
|
67
|
-
|
|
79
|
+
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
80
|
+
mode = _useSharedState.mode;
|
|
68
81
|
var innerCardWithOpenButtonOverlay = useMemo(function () {
|
|
69
82
|
return /*#__PURE__*/React.createElement(OpenButtonOverlay, {
|
|
70
83
|
isVisible: isResolvedViewRendered,
|
|
@@ -101,8 +114,8 @@ export var InlineCardWithAwareness = /*#__PURE__*/memo(function (_ref) {
|
|
|
101
114
|
}, [actionOptions, cardContext, getPos, isHovered, node, onClick, onResolve, useAlternativePreloader, view, isPageSSRed]);
|
|
102
115
|
var shouldShowOpenButtonOverlay = useMemo(function () {
|
|
103
116
|
var shouldShowOpenButtonOverlayInChomeless = editorAppearance === 'chromeless' && fg('platform_editor_controls_patch_8');
|
|
104
|
-
return (
|
|
105
|
-
}, [
|
|
117
|
+
return (mode === 'edit' || editorAppearance === 'comment' && fg('platform_editor_controls_patch_6') || shouldShowOpenButtonOverlayInChomeless) && editorExperiment('platform_editor_controls', 'variant1');
|
|
118
|
+
}, [mode, editorAppearance]);
|
|
106
119
|
var innerCard = shouldShowOpenButtonOverlay ? innerCardWithOpenButtonOverlay : innerCardOriginal;
|
|
107
120
|
var getPosFunction = typeof getPos === 'function' ? getPos : undefined;
|
|
108
121
|
var placeholderUniqId = (getPosFunction === null || getPosFunction === void 0 ? void 0 : getPosFunction()) || 0;
|
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
2
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
3
4
|
import { ASSETS_LIST_OF_LINKS_DATASOURCE_ID, AssetsConfigModal, CONFLUENCE_SEARCH_DATASOURCE_ID, ConfluenceSearchConfigModal, JIRA_LIST_OF_LINKS_DATASOURCE_ID, JiraIssuesConfigModal } from '@atlaskit/link-datasource';
|
|
4
5
|
import { EditorSmartCardProviderValueGuard, useSmartLinkContext } from '@atlaskit/link-provider';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
7
|
import { DatasourceErrorBoundary } from '../datasourceErrorBoundary';
|
|
6
8
|
import { DatasourceModal } from './index';
|
|
9
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
10
|
+
var showDatasourceModal = useSharedPluginStateSelector(pluginInjectionApi, 'card.showDatasourceModal');
|
|
11
|
+
var datasourceModalType = useSharedPluginStateSelector(pluginInjectionApi, 'card.datasourceModalType');
|
|
12
|
+
return {
|
|
13
|
+
cardState: undefined,
|
|
14
|
+
showDatasourceModal: showDatasourceModal,
|
|
15
|
+
datasourceModalType: datasourceModalType
|
|
16
|
+
};
|
|
17
|
+
}, function (pluginInjectionApi) {
|
|
18
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['card']),
|
|
19
|
+
cardState = _useSharedPluginState.cardState;
|
|
20
|
+
return {
|
|
21
|
+
cardState: cardState,
|
|
22
|
+
showDatasourceModal: cardState === null || cardState === void 0 ? void 0 : cardState.showDatasourceModal,
|
|
23
|
+
datasourceModalType: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceModalType
|
|
24
|
+
};
|
|
25
|
+
});
|
|
7
26
|
var ModalWithState = function ModalWithState(_ref) {
|
|
8
27
|
var api = _ref.api,
|
|
9
28
|
editorView = _ref.editorView;
|
|
10
29
|
var cardContext = useSmartLinkContext();
|
|
11
|
-
var
|
|
12
|
-
cardState =
|
|
13
|
-
|
|
30
|
+
var _useSharedState = useSharedState(api),
|
|
31
|
+
cardState = _useSharedState.cardState,
|
|
32
|
+
showDatasourceModal = _useSharedState.showDatasourceModal,
|
|
33
|
+
datasourceModalType = _useSharedState.datasourceModalType;
|
|
34
|
+
if (!cardState && editorExperiment('platform_editor_usesharedpluginstateselector', false)) {
|
|
14
35
|
return null;
|
|
15
36
|
}
|
|
16
|
-
var showDatasourceModal = cardState.showDatasourceModal,
|
|
17
|
-
datasourceModalType = cardState.datasourceModalType;
|
|
18
37
|
if (!showDatasourceModal || !datasourceModalType) {
|
|
19
38
|
return null;
|
|
20
39
|
}
|
|
@@ -10,9 +10,10 @@ import { useCallback, useMemo } from 'react';
|
|
|
10
10
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
11
11
|
import { css, jsx } from '@emotion/react';
|
|
12
12
|
import { injectIntl } from 'react-intl-next';
|
|
13
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
13
|
+
import { sharedPluginStateHookMigratorFactory, useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
14
14
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
15
15
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
16
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
16
17
|
import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
|
|
17
18
|
import GrowHorizontalIcon from '@atlaskit/icon/core/migration/grow-horizontal--editor-expand';
|
|
18
19
|
import ShrinkHorizontalIcon from '@atlaskit/icon/core/migration/shrink-horizontal--editor-collapse';
|
|
@@ -73,6 +74,21 @@ export var LayoutButton = function LayoutButton(_ref) {
|
|
|
73
74
|
})
|
|
74
75
|
}));
|
|
75
76
|
};
|
|
77
|
+
var useSharedState = sharedPluginStateHookMigratorFactory(function (pluginInjectionApi) {
|
|
78
|
+
var layout = useSharedPluginStateSelector(pluginInjectionApi, 'card.layout');
|
|
79
|
+
var datasourceTableRef = useSharedPluginStateSelector(pluginInjectionApi, 'card.datasourceTableRef');
|
|
80
|
+
return {
|
|
81
|
+
layout: layout,
|
|
82
|
+
datasourceTableRef: datasourceTableRef
|
|
83
|
+
};
|
|
84
|
+
}, function (pluginInjectionApi) {
|
|
85
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['card']),
|
|
86
|
+
cardState = _useSharedPluginState.cardState;
|
|
87
|
+
return {
|
|
88
|
+
layout: cardState === null || cardState === void 0 ? void 0 : cardState.layout,
|
|
89
|
+
datasourceTableRef: cardState === null || cardState === void 0 ? void 0 : cardState.datasourceTableRef
|
|
90
|
+
};
|
|
91
|
+
});
|
|
76
92
|
var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
77
93
|
var _node$attrs;
|
|
78
94
|
var editorView = _ref2.editorView,
|
|
@@ -81,22 +97,17 @@ var LayoutButtonWrapper = function LayoutButtonWrapper(_ref2) {
|
|
|
81
97
|
boundariesElement = _ref2.boundariesElement,
|
|
82
98
|
intl = _ref2.intl,
|
|
83
99
|
api = _ref2.api;
|
|
84
|
-
var _useSharedPluginState = useSharedPluginState(api, ['card']),
|
|
85
|
-
cardState = _useSharedPluginState.cardState;
|
|
86
100
|
var _getDatasource = getDatasource(editorView),
|
|
87
101
|
node = _getDatasource.node,
|
|
88
102
|
pos = _getDatasource.pos;
|
|
103
|
+
var _useSharedState = useSharedState(api),
|
|
104
|
+
_useSharedState$layou = _useSharedState.layout,
|
|
105
|
+
layout = _useSharedState$layou === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _useSharedState$layou,
|
|
106
|
+
datasourceTableRef = _useSharedState.datasourceTableRef;
|
|
89
107
|
var isDatasource = isDatasourceNode(node);
|
|
90
108
|
if (!isDatasource) {
|
|
91
109
|
return null;
|
|
92
110
|
}
|
|
93
|
-
|
|
94
|
-
// If layout doesn't exist in ADF it returns null, we want to change to undefined
|
|
95
|
-
// which results in default parameter value being used in LayoutButton.
|
|
96
|
-
var _ref3 = cardState !== null && cardState !== void 0 ? cardState : {},
|
|
97
|
-
datasourceTableRef = _ref3.datasourceTableRef,
|
|
98
|
-
_ref3$layout = _ref3.layout,
|
|
99
|
-
layout = _ref3$layout === void 0 ? (node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.layout) || undefined : _ref3$layout;
|
|
100
111
|
var onLayoutChange = function onLayoutChange(layout) {
|
|
101
112
|
var _getDatasource$node;
|
|
102
113
|
if (pos === undefined) {
|