@atlaskit/editor-plugin-card 4.5.17 → 4.5.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/nodeviews/blockCard.js +18 -2
- package/dist/cjs/nodeviews/embedCard.js +16 -1
- package/dist/cjs/nodeviews/inlineCard.js +18 -2
- package/dist/cjs/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/cjs/pm-plugins/actions.js +12 -3
- package/dist/cjs/pm-plugins/reducers.js +13 -0
- package/dist/es2019/nodeviews/blockCard.js +19 -3
- package/dist/es2019/nodeviews/embedCard.js +17 -2
- package/dist/es2019/nodeviews/inlineCard.js +22 -4
- package/dist/es2019/nodeviews/inlineCardWithAwareness.js +12 -1
- package/dist/es2019/pm-plugins/actions.js +7 -2
- package/dist/es2019/pm-plugins/reducers.js +12 -0
- package/dist/esm/nodeviews/blockCard.js +19 -3
- package/dist/esm/nodeviews/embedCard.js +17 -2
- package/dist/esm/nodeviews/inlineCard.js +20 -4
- package/dist/esm/nodeviews/inlineCardWithAwareness.js +18 -3
- package/dist/esm/pm-plugins/actions.js +11 -2
- package/dist/esm/pm-plugins/reducers.js +13 -0
- package/dist/types/nodeviews/blockCard.d.ts +11 -5
- package/dist/types/nodeviews/embedCard.d.ts +10 -4
- package/dist/types/nodeviews/genericCard.d.ts +3 -1
- package/dist/types/nodeviews/inlineCard.d.ts +2 -2
- package/dist/types/nodeviews/inlineCardWithAwareness.d.ts +1 -1
- package/dist/types/pm-plugins/actions.d.ts +2 -1
- package/dist/types/pm-plugins/util/state.d.ts +1 -0
- package/dist/types/types/index.d.ts +7 -1
- package/dist/types/ui/DatasourceIcon/index.d.ts +2 -2
- package/dist/types/ui/DatasourceModal/ModalWithState.d.ts +1 -1
- package/dist/types/ui/DatasourceModal/index.d.ts +2 -2
- package/dist/types/ui/EditLinkToolbar.d.ts +2 -2
- package/dist/types/ui/EditorAnalyticsContext.d.ts +1 -1
- package/dist/types/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
- package/dist/types/ui/HyperlinkToolbarAppearance.d.ts +2 -2
- package/dist/types/ui/LinkToolbarAppearance.d.ts +2 -2
- package/dist/types/ui/Pulse/index.d.ts +2 -2
- package/dist/types/ui/ToolbarViewedEvent.d.ts +2 -2
- package/dist/types/ui/WithCardContext.d.ts +1 -1
- package/dist/types/ui/datasourceErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/blockCard.d.ts +11 -5
- package/dist/types-ts4.5/nodeviews/embedCard.d.ts +10 -4
- package/dist/types-ts4.5/nodeviews/genericCard.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/inlineCard.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/inlineCardWithAwareness.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/util/state.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +7 -1
- package/dist/types-ts4.5/ui/DatasourceIcon/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/DatasourceModal/ModalWithState.d.ts +1 -1
- package/dist/types-ts4.5/ui/DatasourceModal/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/EditLinkToolbar.d.ts +2 -2
- package/dist/types-ts4.5/ui/EditorAnalyticsContext.d.ts +1 -1
- package/dist/types-ts4.5/ui/EditorLinkingPlatformAnalytics/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/HyperlinkToolbarAppearance.d.ts +2 -2
- package/dist/types-ts4.5/ui/LinkToolbarAppearance.d.ts +2 -2
- package/dist/types-ts4.5/ui/Pulse/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/ToolbarViewedEvent.d.ts +2 -2
- package/dist/types-ts4.5/ui/WithCardContext.d.ts +1 -1
- package/dist/types-ts4.5/ui/datasourceErrorBoundary.d.ts +1 -1
- package/package.json +15 -11
package/CHANGELOG.md
CHANGED
|
@@ -14,6 +14,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
|
|
|
14
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
15
|
var _react = _interopRequireDefault(require("react"));
|
|
16
16
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
17
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
17
18
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
18
19
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
19
20
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -54,7 +55,8 @@ var BlockCardComponent = exports.BlockCardComponent = /*#__PURE__*/function (_Re
|
|
|
54
55
|
view.dispatch((0, _actions.registerCard)({
|
|
55
56
|
title: title,
|
|
56
57
|
url: url,
|
|
57
|
-
pos: pos
|
|
58
|
+
pos: pos,
|
|
59
|
+
id: _this.props.id
|
|
58
60
|
})(view.state.tr));
|
|
59
61
|
})();
|
|
60
62
|
});
|
|
@@ -120,6 +122,7 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
120
122
|
args[_key] = arguments[_key];
|
|
121
123
|
}
|
|
122
124
|
_this2 = _callSuper(this, BlockCard, [].concat(args));
|
|
125
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
123
126
|
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
124
127
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
125
128
|
});
|
|
@@ -177,7 +180,8 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
177
180
|
getPos: this.getPos,
|
|
178
181
|
actionOptions: actionOptions,
|
|
179
182
|
pluginInjectionApi: pluginInjectionApi,
|
|
180
|
-
onClickCallback: onClickCallback
|
|
183
|
+
onClickCallback: onClickCallback,
|
|
184
|
+
id: this.id
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
187
|
}, {
|
|
@@ -185,6 +189,18 @@ var BlockCard = exports.BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
185
189
|
value: function destroy() {
|
|
186
190
|
var _this$unsubscribe;
|
|
187
191
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
192
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
193
|
+
this.removeCard();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "removeCard",
|
|
198
|
+
value: function removeCard() {
|
|
199
|
+
var tr = this.view.state.tr;
|
|
200
|
+
(0, _actions.removeCard)({
|
|
201
|
+
id: this.id
|
|
202
|
+
})(tr);
|
|
203
|
+
this.view.dispatch(tr);
|
|
188
204
|
}
|
|
189
205
|
}]);
|
|
190
206
|
}(_reactNodeView.default);
|
|
@@ -15,6 +15,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
15
15
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
16
16
|
var _react = _interopRequireDefault(require("react"));
|
|
17
17
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
18
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
18
19
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
19
20
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
20
21
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
@@ -162,7 +163,8 @@ var EmbedCardComponent = exports.EmbedCardComponent = /*#__PURE__*/function (_Re
|
|
|
162
163
|
return view.dispatch((0, _actions.registerCard)({
|
|
163
164
|
title: title,
|
|
164
165
|
url: url,
|
|
165
|
-
pos: pos
|
|
166
|
+
pos: pos,
|
|
167
|
+
id: _this.props.id
|
|
166
168
|
})(view.state.tr));
|
|
167
169
|
})();
|
|
168
170
|
try {
|
|
@@ -345,6 +347,7 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
345
347
|
args[_key] = arguments[_key];
|
|
346
348
|
}
|
|
347
349
|
_this2 = _callSuper(this, EmbedCard, [].concat(args));
|
|
350
|
+
(0, _defineProperty2.default)(_this2, "id", (0, _v.default)());
|
|
348
351
|
(0, _defineProperty2.default)(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
349
352
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
350
353
|
});
|
|
@@ -405,6 +408,18 @@ var EmbedCard = exports.EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
405
408
|
value: function destroy() {
|
|
406
409
|
var _this$unsubscribe;
|
|
407
410
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
411
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
412
|
+
this.removeCard();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, {
|
|
416
|
+
key: "removeCard",
|
|
417
|
+
value: function removeCard() {
|
|
418
|
+
var tr = this.view.state.tr;
|
|
419
|
+
(0, _actions.removeCard)({
|
|
420
|
+
id: this.id
|
|
421
|
+
})(tr);
|
|
422
|
+
this.view.dispatch(tr);
|
|
408
423
|
}
|
|
409
424
|
}]);
|
|
410
425
|
}(_reactNodeView.default);
|
|
@@ -12,12 +12,14 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
12
12
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
13
|
var _react = _interopRequireWildcard(require("react"));
|
|
14
14
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
15
|
+
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
15
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
16
17
|
var _link = require("@atlaskit/editor-common/link");
|
|
17
18
|
var _ui = require("@atlaskit/editor-common/ui");
|
|
18
19
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
19
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
21
|
var _smartCard = require("@atlaskit/smart-card");
|
|
22
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
21
23
|
var _actions = require("../pm-plugins/actions");
|
|
22
24
|
var _utils = require("../pm-plugins/utils");
|
|
23
25
|
var _ConfigureOverlay = _interopRequireDefault(require("../ui/ConfigureOverlay"));
|
|
@@ -40,6 +42,19 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
40
42
|
var _node$attrs = node.attrs,
|
|
41
43
|
url = _node$attrs.url,
|
|
42
44
|
data = _node$attrs.data;
|
|
45
|
+
var refId = (0, _react.useRef)((0, _v.default)());
|
|
46
|
+
(0, _react.useEffect)(function () {
|
|
47
|
+
var id = refId.current;
|
|
48
|
+
return function () {
|
|
49
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
50
|
+
var tr = view.state.tr;
|
|
51
|
+
(0, _actions.removeCard)({
|
|
52
|
+
id: id
|
|
53
|
+
})(tr);
|
|
54
|
+
view.dispatch(tr);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}, [getPos, view]);
|
|
43
58
|
var scrollContainer = (0, _react.useMemo)(
|
|
44
59
|
// Ignored via go/ees005
|
|
45
60
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -64,7 +79,8 @@ var InlineCard = exports.InlineCard = /*#__PURE__*/(0, _react.memo)(function (_r
|
|
|
64
79
|
(0, _actions.registerCard)({
|
|
65
80
|
title: title,
|
|
66
81
|
url: url,
|
|
67
|
-
pos: pos
|
|
82
|
+
pos: pos,
|
|
83
|
+
id: refId.current
|
|
68
84
|
})(tr);
|
|
69
85
|
onRes === null || onRes === void 0 || onRes(tr, title);
|
|
70
86
|
view.dispatch(tr);
|
|
@@ -166,7 +182,7 @@ function InlineCardNodeView(props) {
|
|
|
166
182
|
onClickCallback: onClickCallback
|
|
167
183
|
// Ignored via go/ees005
|
|
168
184
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
169
|
-
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
|
|
185
|
+
}, enableInlineUpgradeFeatures && (0, _utils.getAwarenessProps)(view.state, getPos, allowEmbeds, allowBlockCards, !(0, _experiments.editorExperiment)('live_pages_graceful_edit', 'control') ? true : (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
|
|
170
186
|
}
|
|
171
187
|
var inlineCardNodeView = exports.inlineCardNodeView = function inlineCardNodeView(_ref2) {
|
|
172
188
|
var inlineCardViewProducer = _ref2.inlineCardViewProducer;
|
|
@@ -8,7 +8,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.InlineCardWithAwareness = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var _actions = require("../pm-plugins/actions");
|
|
13
|
+
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
12
14
|
var _AwarenessWrapper = require("../ui/AwarenessWrapper");
|
|
13
15
|
var _inlineCard = require("./inlineCard");
|
|
14
16
|
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); }
|
|
@@ -38,9 +40,22 @@ var InlineCardWithAwareness = exports.InlineCardWithAwareness = /*#__PURE__*/(0,
|
|
|
38
40
|
isResolvedViewRendered = _useState6[0],
|
|
39
41
|
setIsResolvedViewRendered = _useState6[1];
|
|
40
42
|
var onResolve = (0, _react.useCallback)(function (tr, title) {
|
|
41
|
-
(0,
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_fix_card_plugin_state')) {
|
|
44
|
+
var metadata = tr.getMeta(_pluginKey.pluginKey);
|
|
45
|
+
if (metadata && metadata.type === 'REGISTER') {
|
|
46
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
47
|
+
return setIsInserted(false);
|
|
48
|
+
}, metadata.info)(tr);
|
|
49
|
+
} else {
|
|
50
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
51
|
+
return setIsInserted(false);
|
|
52
|
+
})(tr);
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
(0, _actions.registerRemoveOverlay)(function () {
|
|
56
|
+
return setIsInserted(false);
|
|
57
|
+
})(tr);
|
|
58
|
+
}
|
|
44
59
|
if (title) {
|
|
45
60
|
setIsResolvedViewRendered(true);
|
|
46
61
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
|
|
6
|
+
exports.showLinkToolbar = exports.showDatasourceModal = exports.setProvider = exports.setDatasourceTableRef = exports.setDatasourceStash = exports.setCardLayoutAndDatasourceTableRef = exports.setCardLayout = exports.resolveCard = exports.removeDatasourceStash = exports.removeCard = exports.registerSmartCardEvents = exports.registerRemoveOverlay = exports.registerCard = exports.queueCards = exports.hideLinkToolbar = exports.hideDatasourceModal = exports.clearOverlayCandidate = exports.cardAction = void 0;
|
|
7
7
|
var _pluginKey = require("./plugin-key");
|
|
8
8
|
var cardAction = exports.cardAction = function cardAction(tr, action) {
|
|
9
9
|
return tr.setMeta(_pluginKey.pluginKey, action);
|
|
@@ -32,11 +32,20 @@ var registerCard = exports.registerCard = function registerCard(info) {
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
var
|
|
35
|
+
var removeCard = exports.removeCard = function removeCard(info) {
|
|
36
|
+
return function (tr) {
|
|
37
|
+
return cardAction(tr, {
|
|
38
|
+
type: 'REMOVE_CARD',
|
|
39
|
+
info: info
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
var registerRemoveOverlay = exports.registerRemoveOverlay = function registerRemoveOverlay(callback, info) {
|
|
36
44
|
return function (tr) {
|
|
37
45
|
return cardAction(tr, {
|
|
38
46
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
|
|
39
|
-
callback: callback
|
|
47
|
+
callback: callback,
|
|
48
|
+
info: info
|
|
40
49
|
});
|
|
41
50
|
};
|
|
42
51
|
};
|
|
@@ -35,6 +35,13 @@ var register = function register(state, action) {
|
|
|
35
35
|
}).concat(action.info)
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
|
+
var removeCard = function removeCard(state, action) {
|
|
39
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
|
+
cards: state.cards.filter(function (card) {
|
|
41
|
+
return card.id !== action.info.id;
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
};
|
|
38
45
|
var setProvider = function setProvider(state, action) {
|
|
39
46
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
40
47
|
provider: action.provider
|
|
@@ -85,6 +92,10 @@ var clearOverlayCandidate = function clearOverlayCandidate(state) {
|
|
|
85
92
|
};
|
|
86
93
|
var registerRemoveOverlayOnInsertedLink = function registerRemoveOverlayOnInsertedLink(state, action) {
|
|
87
94
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
95
|
+
cards: action.info ? state.cards.filter(function (card) {
|
|
96
|
+
var _action$info;
|
|
97
|
+
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
98
|
+
}).concat(action.info) : state.cards,
|
|
88
99
|
removeOverlay: action.callback
|
|
89
100
|
});
|
|
90
101
|
};
|
|
@@ -114,6 +125,8 @@ var _default = exports.default = function _default(state, action) {
|
|
|
114
125
|
return resolve(state, action);
|
|
115
126
|
case 'REGISTER':
|
|
116
127
|
return register(state, action);
|
|
128
|
+
case 'REMOVE_CARD':
|
|
129
|
+
return removeCard(state, action);
|
|
117
130
|
case 'REGISTER_EVENTS':
|
|
118
131
|
return registerEvents(state, action);
|
|
119
132
|
case 'SET_DATASOURCE_TABLE_REF':
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
4
5
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
6
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
6
7
|
import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
7
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
9
10
|
import { Datasource } from '../nodeviews/datasource';
|
|
10
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
11
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
11
12
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
12
13
|
import { Card } from './genericCard';
|
|
13
14
|
|
|
@@ -40,7 +41,8 @@ export class BlockCardComponent extends React.PureComponent {
|
|
|
40
41
|
view.dispatch(registerCard({
|
|
41
42
|
title,
|
|
42
43
|
url,
|
|
43
|
-
pos
|
|
44
|
+
pos,
|
|
45
|
+
id: this.props.id
|
|
44
46
|
})(view.state.tr));
|
|
45
47
|
})();
|
|
46
48
|
});
|
|
@@ -99,6 +101,7 @@ const WrappedBlockCard = Card(BlockCardComponent, UnsupportedBlock);
|
|
|
99
101
|
export class BlockCard extends ReactNodeView {
|
|
100
102
|
constructor(...args) {
|
|
101
103
|
super(...args);
|
|
104
|
+
_defineProperty(this, "id", uuid());
|
|
102
105
|
_defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
|
|
103
106
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
104
107
|
});
|
|
@@ -144,12 +147,25 @@ export class BlockCard extends ReactNodeView {
|
|
|
144
147
|
getPos: this.getPos,
|
|
145
148
|
actionOptions: actionOptions,
|
|
146
149
|
pluginInjectionApi: pluginInjectionApi,
|
|
147
|
-
onClickCallback: onClickCallback
|
|
150
|
+
onClickCallback: onClickCallback,
|
|
151
|
+
id: this.id
|
|
148
152
|
});
|
|
149
153
|
}
|
|
150
154
|
destroy() {
|
|
151
155
|
var _this$unsubscribe;
|
|
152
156
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
157
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
158
|
+
this.removeCard();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
removeCard() {
|
|
162
|
+
const {
|
|
163
|
+
tr
|
|
164
|
+
} = this.view.state;
|
|
165
|
+
removeCard({
|
|
166
|
+
id: this.id
|
|
167
|
+
})(tr);
|
|
168
|
+
this.view.dispatch(tr);
|
|
153
169
|
}
|
|
154
170
|
}
|
|
155
171
|
export const blockCardNodeView = ({
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import rafSchedule from 'raf-schd';
|
|
5
|
+
import uuid from 'uuid/v4';
|
|
5
6
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
6
7
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
8
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -10,7 +11,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
10
11
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
11
12
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
13
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
14
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
14
15
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
15
16
|
import { Card } from './genericCard';
|
|
16
17
|
const CardInner = ({
|
|
@@ -151,7 +152,8 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
151
152
|
return view.dispatch(registerCard({
|
|
152
153
|
title,
|
|
153
154
|
url,
|
|
154
|
-
pos
|
|
155
|
+
pos,
|
|
156
|
+
id: this.props.id
|
|
155
157
|
})(view.state.tr));
|
|
156
158
|
})();
|
|
157
159
|
try {
|
|
@@ -332,6 +334,7 @@ const WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
|
|
|
332
334
|
export class EmbedCard extends ReactNodeView {
|
|
333
335
|
constructor(...args) {
|
|
334
336
|
super(...args);
|
|
337
|
+
_defineProperty(this, "id", uuid());
|
|
335
338
|
_defineProperty(this, "updateContentEditable", (editorViewModeState, divElement) => {
|
|
336
339
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
337
340
|
});
|
|
@@ -381,6 +384,18 @@ export class EmbedCard extends ReactNodeView {
|
|
|
381
384
|
destroy() {
|
|
382
385
|
var _this$unsubscribe;
|
|
383
386
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
387
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
388
|
+
this.removeCard();
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
removeCard() {
|
|
392
|
+
const {
|
|
393
|
+
tr
|
|
394
|
+
} = this.view.state;
|
|
395
|
+
removeCard({
|
|
396
|
+
id: this.id
|
|
397
|
+
})(tr);
|
|
398
|
+
this.view.dispatch(tr);
|
|
384
399
|
}
|
|
385
400
|
}
|
|
386
401
|
export const embedCardNodeView = ({
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
3
|
import rafSchedule from 'raf-schd';
|
|
4
|
+
import uuid from 'uuid/v4';
|
|
4
5
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
6
|
import { handleNavigation } from '@atlaskit/editor-common/link';
|
|
6
7
|
import { findOverflowScrollParent, UnsupportedInline } from '@atlaskit/editor-common/ui';
|
|
7
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
10
|
-
import {
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
|
+
import { registerCard, removeCard } from '../pm-plugins/actions';
|
|
11
13
|
import { getAwarenessProps } from '../pm-plugins/utils';
|
|
12
14
|
import OverlayWrapper from '../ui/ConfigureOverlay';
|
|
13
15
|
import { Card } from './genericCard';
|
|
@@ -29,6 +31,21 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
29
31
|
url,
|
|
30
32
|
data
|
|
31
33
|
} = node.attrs;
|
|
34
|
+
const refId = useRef(uuid());
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const id = refId.current;
|
|
37
|
+
return () => {
|
|
38
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
39
|
+
const {
|
|
40
|
+
tr
|
|
41
|
+
} = view.state;
|
|
42
|
+
removeCard({
|
|
43
|
+
id
|
|
44
|
+
})(tr);
|
|
45
|
+
view.dispatch(tr);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, [getPos, view]);
|
|
32
49
|
const scrollContainer = useMemo(
|
|
33
50
|
// Ignored via go/ees005
|
|
34
51
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -53,7 +70,8 @@ export const InlineCard = /*#__PURE__*/memo(({
|
|
|
53
70
|
registerCard({
|
|
54
71
|
title,
|
|
55
72
|
url,
|
|
56
|
-
pos
|
|
73
|
+
pos,
|
|
74
|
+
id: refId.current
|
|
57
75
|
})(tr);
|
|
58
76
|
onRes === null || onRes === void 0 ? void 0 : onRes(tr, title);
|
|
59
77
|
view.dispatch(tr);
|
|
@@ -155,7 +173,7 @@ export function InlineCardNodeView(props) {
|
|
|
155
173
|
onClickCallback: onClickCallback
|
|
156
174
|
// Ignored via go/ees005
|
|
157
175
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
158
|
-
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
|
|
176
|
+
}, enableInlineUpgradeFeatures && getAwarenessProps(view.state, getPos, allowEmbeds, allowBlockCards, !editorExperiment('live_pages_graceful_edit', 'control') ? true : (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view')));
|
|
159
177
|
}
|
|
160
178
|
export const inlineCardNodeView = ({
|
|
161
179
|
inlineCardViewProducer
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { registerRemoveOverlay } from '../pm-plugins/actions';
|
|
4
|
+
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
3
5
|
import { AwarenessWrapper } from '../ui/AwarenessWrapper';
|
|
4
6
|
import { InlineCard } from './inlineCard';
|
|
5
7
|
export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
@@ -19,7 +21,16 @@ export const InlineCardWithAwareness = /*#__PURE__*/memo(({
|
|
|
19
21
|
const [isInserted, setIsInserted] = useState(false);
|
|
20
22
|
const [isResolvedViewRendered, setIsResolvedViewRendered] = useState(false);
|
|
21
23
|
const onResolve = useCallback((tr, title) => {
|
|
22
|
-
|
|
24
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
25
|
+
const metadata = tr.getMeta(pluginKey);
|
|
26
|
+
if (metadata && metadata.type === 'REGISTER') {
|
|
27
|
+
registerRemoveOverlay(() => setIsInserted(false), metadata.info)(tr);
|
|
28
|
+
} else {
|
|
29
|
+
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
registerRemoveOverlay(() => setIsInserted(false))(tr);
|
|
33
|
+
}
|
|
23
34
|
if (title) {
|
|
24
35
|
setIsResolvedViewRendered(true);
|
|
25
36
|
}
|
|
@@ -14,9 +14,14 @@ export const registerCard = info => tr => cardAction(tr, {
|
|
|
14
14
|
type: 'REGISTER',
|
|
15
15
|
info
|
|
16
16
|
});
|
|
17
|
-
export const
|
|
17
|
+
export const removeCard = info => tr => cardAction(tr, {
|
|
18
|
+
type: 'REMOVE_CARD',
|
|
19
|
+
info
|
|
20
|
+
});
|
|
21
|
+
export const registerRemoveOverlay = (callback, info) => tr => cardAction(tr, {
|
|
18
22
|
type: 'REGISTER_REMOVE_OVERLAY_ON_INSERTED_LINK',
|
|
19
|
-
callback
|
|
23
|
+
callback,
|
|
24
|
+
info
|
|
20
25
|
});
|
|
21
26
|
export const registerSmartCardEvents = smartLinkEvents => tr => cardAction(tr, {
|
|
22
27
|
type: 'REGISTER_EVENTS',
|
|
@@ -22,6 +22,12 @@ const register = (state, action) => {
|
|
|
22
22
|
cards: state.cards.filter(card => card.pos !== action.info.pos).concat(action.info)
|
|
23
23
|
};
|
|
24
24
|
};
|
|
25
|
+
const removeCard = (state, action) => {
|
|
26
|
+
return {
|
|
27
|
+
...state,
|
|
28
|
+
cards: state.cards.filter(card => card.id !== action.info.id)
|
|
29
|
+
};
|
|
30
|
+
};
|
|
25
31
|
const setProvider = (state, action) => {
|
|
26
32
|
return {
|
|
27
33
|
...state,
|
|
@@ -82,6 +88,10 @@ const clearOverlayCandidate = state => {
|
|
|
82
88
|
const registerRemoveOverlayOnInsertedLink = (state, action) => {
|
|
83
89
|
return {
|
|
84
90
|
...state,
|
|
91
|
+
cards: action.info ? state.cards.filter(card => {
|
|
92
|
+
var _action$info;
|
|
93
|
+
return card.pos !== ((_action$info = action.info) === null || _action$info === void 0 ? void 0 : _action$info.pos);
|
|
94
|
+
}).concat(action.info) : state.cards,
|
|
85
95
|
removeOverlay: action.callback
|
|
86
96
|
};
|
|
87
97
|
};
|
|
@@ -116,6 +126,8 @@ export default ((state, action) => {
|
|
|
116
126
|
return resolve(state, action);
|
|
117
127
|
case 'REGISTER':
|
|
118
128
|
return register(state, action);
|
|
129
|
+
case 'REMOVE_CARD':
|
|
130
|
+
return removeCard(state, action);
|
|
119
131
|
case 'REGISTER_EVENTS':
|
|
120
132
|
return registerEvents(state, action);
|
|
121
133
|
case 'SET_DATASOURCE_TABLE_REF':
|
|
@@ -10,13 +10,14 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import rafSchedule from 'raf-schd';
|
|
13
|
+
import uuid from 'uuid/v4';
|
|
13
14
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
14
15
|
import { findOverflowScrollParent, UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
15
16
|
import { browser, canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
16
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
17
18
|
import { Card as SmartCard } from '@atlaskit/smart-card';
|
|
18
19
|
import { Datasource } from '../nodeviews/datasource';
|
|
19
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
20
|
+
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
20
21
|
import { isDatasourceNode } from '../pm-plugins/utils';
|
|
21
22
|
import { Card } from './genericCard';
|
|
22
23
|
|
|
@@ -48,7 +49,8 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
48
49
|
view.dispatch(registerCard({
|
|
49
50
|
title: title,
|
|
50
51
|
url: url,
|
|
51
|
-
pos: pos
|
|
52
|
+
pos: pos,
|
|
53
|
+
id: _this.props.id
|
|
52
54
|
})(view.state.tr));
|
|
53
55
|
})();
|
|
54
56
|
});
|
|
@@ -114,6 +116,7 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
114
116
|
args[_key] = arguments[_key];
|
|
115
117
|
}
|
|
116
118
|
_this2 = _callSuper(this, BlockCard, [].concat(args));
|
|
119
|
+
_defineProperty(_this2, "id", uuid());
|
|
117
120
|
_defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
118
121
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
119
122
|
});
|
|
@@ -171,7 +174,8 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
171
174
|
getPos: this.getPos,
|
|
172
175
|
actionOptions: actionOptions,
|
|
173
176
|
pluginInjectionApi: pluginInjectionApi,
|
|
174
|
-
onClickCallback: onClickCallback
|
|
177
|
+
onClickCallback: onClickCallback,
|
|
178
|
+
id: this.id
|
|
175
179
|
});
|
|
176
180
|
}
|
|
177
181
|
}, {
|
|
@@ -179,6 +183,18 @@ export var BlockCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
179
183
|
value: function destroy() {
|
|
180
184
|
var _this$unsubscribe;
|
|
181
185
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
186
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
187
|
+
this.removeCard();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, {
|
|
191
|
+
key: "removeCard",
|
|
192
|
+
value: function removeCard() {
|
|
193
|
+
var tr = this.view.state.tr;
|
|
194
|
+
_removeCard({
|
|
195
|
+
id: this.id
|
|
196
|
+
})(tr);
|
|
197
|
+
this.view.dispatch(tr);
|
|
182
198
|
}
|
|
183
199
|
}]);
|
|
184
200
|
}(ReactNodeView);
|
|
@@ -13,6 +13,7 @@ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstruct
|
|
|
13
13
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import rafSchedule from 'raf-schd';
|
|
16
|
+
import uuid from 'uuid/v4';
|
|
16
17
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
17
18
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
18
19
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
@@ -21,7 +22,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
21
22
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
22
23
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
import { EmbedResizeMessageListener, Card as SmartCard } from '@atlaskit/smart-card';
|
|
24
|
-
import { registerCard } from '../pm-plugins/actions';
|
|
25
|
+
import { registerCard, removeCard as _removeCard } from '../pm-plugins/actions';
|
|
25
26
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
26
27
|
import { Card } from './genericCard';
|
|
27
28
|
var CardInner = function CardInner(_ref) {
|
|
@@ -155,7 +156,8 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
155
156
|
return view.dispatch(registerCard({
|
|
156
157
|
title: title,
|
|
157
158
|
url: url,
|
|
158
|
-
pos: pos
|
|
159
|
+
pos: pos,
|
|
160
|
+
id: _this.props.id
|
|
159
161
|
})(view.state.tr));
|
|
160
162
|
})();
|
|
161
163
|
try {
|
|
@@ -338,6 +340,7 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
338
340
|
args[_key] = arguments[_key];
|
|
339
341
|
}
|
|
340
342
|
_this2 = _callSuper(this, EmbedCard, [].concat(args));
|
|
343
|
+
_defineProperty(_this2, "id", uuid());
|
|
341
344
|
_defineProperty(_this2, "updateContentEditable", function (editorViewModeState, divElement) {
|
|
342
345
|
divElement.contentEditable = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view' ? 'false' : 'true';
|
|
343
346
|
});
|
|
@@ -398,6 +401,18 @@ export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
398
401
|
value: function destroy() {
|
|
399
402
|
var _this$unsubscribe;
|
|
400
403
|
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
|
|
404
|
+
if (fg('platform_editor_fix_card_plugin_state')) {
|
|
405
|
+
this.removeCard();
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
}, {
|
|
409
|
+
key: "removeCard",
|
|
410
|
+
value: function removeCard() {
|
|
411
|
+
var tr = this.view.state.tr;
|
|
412
|
+
_removeCard({
|
|
413
|
+
id: this.id
|
|
414
|
+
})(tr);
|
|
415
|
+
this.view.dispatch(tr);
|
|
401
416
|
}
|
|
402
417
|
}]);
|
|
403
418
|
}(ReactNodeView);
|