@atlaskit/editor-plugin-synced-block 5.4.6 → 5.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/pm-plugins/main.js +14 -12
- package/dist/cjs/pm-plugins/utils/utils.js +20 -10
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +2 -2
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/cjs/ui/quick-insert.js +2 -1
- package/dist/es2019/pm-plugins/main.js +15 -13
- package/dist/es2019/pm-plugins/utils/utils.js +18 -8
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +2 -2
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/es2019/ui/quick-insert.js +2 -1
- package/dist/esm/pm-plugins/main.js +15 -13
- package/dist/esm/pm-plugins/utils/utils.js +19 -9
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +2 -2
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/esm/ui/quick-insert.js +2 -1
- package/dist/types/pm-plugins/utils/utils.d.ts +1 -1
- package/dist/types/types/index.d.ts +6 -5
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +6 -5
- package/package.json +7 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.4.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ef315dbd33cd4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ef315dbd33cd4) -
|
|
8
|
+
EDITOR-5603 update lozenge and tag usage in editor for Team 26 ADS changes
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.4.7
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`dc717554783a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dc717554783a6) -
|
|
16
|
+
[ux] EDITOR-5556 show warning flag when extensions are added inside synced blocks
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 5.4.6
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -81,21 +81,23 @@ var showCopiedFlag = function showCopiedFlag(api) {
|
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
};
|
|
84
|
-
var
|
|
84
|
+
var showExtensionInSyncBlockWarningIfNeeded = function showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown) {
|
|
85
85
|
var _api$connectivity;
|
|
86
86
|
if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(_utils.pmHistoryPluginKey)) || (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode)) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
|
-
var resourceId = (0, _utils2.
|
|
89
|
+
var resourceId = (0, _utils2.wasExtensionInsertedInBodiedSyncBlock)(tr, state);
|
|
90
90
|
// Only show the flag on the first instance per sync block (same as UNPUBLISHED_SYNC_BLOCK_PASTED)
|
|
91
|
-
if (resourceId && !
|
|
92
|
-
|
|
91
|
+
if (resourceId && !extensionFlagShown.has(resourceId)) {
|
|
92
|
+
extensionFlagShown.add(resourceId);
|
|
93
93
|
(0, _utils2.deferDispatch)(function () {
|
|
94
94
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
95
95
|
var tr = _ref2.tr;
|
|
96
96
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
97
97
|
activeFlag: {
|
|
98
|
-
id:
|
|
98
|
+
id: (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
99
|
+
exposure: true
|
|
100
|
+
}) ? _types.FLAG_ID.EXTENSION_IN_SYNC_BLOCK : _types.FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK
|
|
99
101
|
}
|
|
100
102
|
});
|
|
101
103
|
});
|
|
@@ -117,7 +119,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
117
119
|
confirmationTransactionRef = _ref3.confirmationTransactionRef,
|
|
118
120
|
bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
|
|
119
121
|
bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
|
|
120
|
-
|
|
122
|
+
extensionFlagShown = _ref3.extensionFlagShown;
|
|
121
123
|
var _trackSyncBlocks = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
|
|
122
124
|
return node.type.name === 'syncBlock';
|
|
123
125
|
}, tr, state),
|
|
@@ -164,7 +166,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
164
166
|
(0, _handleBodiedSyncBlockCreation.handleBodiedSyncBlockCreation)(bodiedSyncBlockAdded, state, api);
|
|
165
167
|
return true;
|
|
166
168
|
}
|
|
167
|
-
|
|
169
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
168
170
|
return true;
|
|
169
171
|
};
|
|
170
172
|
var filterTransactionOffline = function filterTransactionOffline(_ref4) {
|
|
@@ -216,7 +218,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
216
218
|
});
|
|
217
219
|
(0, _defineProperty2.default)(this, "_isCopyEvent", false);
|
|
218
220
|
(0, _defineProperty2.default)(this, "unpublishedFlagShown", new Set());
|
|
219
|
-
(0, _defineProperty2.default)(this, "
|
|
221
|
+
(0, _defineProperty2.default)(this, "extensionFlagShown", new Set());
|
|
220
222
|
}
|
|
221
223
|
return (0, _createClass2.default)(SyncedBlockPluginContext, [{
|
|
222
224
|
key: "isCopyEvent",
|
|
@@ -238,7 +240,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
238
240
|
}]);
|
|
239
241
|
}();
|
|
240
242
|
var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
241
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$
|
|
243
|
+
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
242
244
|
var _ref6 = options || {},
|
|
243
245
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
244
246
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
@@ -248,7 +250,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
248
250
|
};
|
|
249
251
|
var isCopyEvent = false;
|
|
250
252
|
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
251
|
-
var
|
|
253
|
+
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
252
254
|
|
|
253
255
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
254
256
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -502,7 +504,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
502
504
|
confirmationTransactionRef: confirmationTransactionRef,
|
|
503
505
|
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
504
506
|
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
505
|
-
|
|
507
|
+
extensionFlagShown: extensionFlagShown
|
|
506
508
|
});
|
|
507
509
|
}
|
|
508
510
|
if (!isOffline) {
|
|
@@ -551,7 +553,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
551
553
|
(0, _handleBodiedSyncBlockCreation.handleBodiedSyncBlockCreation)(bodiedSyncBlockAdded, state, api);
|
|
552
554
|
return true;
|
|
553
555
|
}
|
|
554
|
-
|
|
556
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
555
557
|
return true;
|
|
556
558
|
}
|
|
557
559
|
var _trackSyncBlocks6 = (0, _trackSyncBlocks8.trackSyncBlocks)(function (node) {
|
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.wasExtensionInsertedInBodiedSyncBlock = exports.sliceFullyContainsNode = exports.isBodiedSyncBlockNode = exports.findSyncBlockOrBodiedSyncBlock = exports.findSyncBlock = exports.findBodiedSyncBlock = exports.deferDispatch = exports.canBeConvertedToSyncBlock = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
9
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
10
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
/**
|
|
13
14
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
14
15
|
* Used to avoid re-entrant ProseMirror dispatch cycles.
|
|
@@ -97,31 +98,36 @@ var sliceFullyContainsNode = exports.sliceFullyContainsNode = function sliceFull
|
|
|
97
98
|
}
|
|
98
99
|
return true;
|
|
99
100
|
};
|
|
100
|
-
|
|
101
|
+
|
|
102
|
+
// even though extension and bodiedExtension are explicitly not allowed by the schema, they can still be inserted nested inside other nodes e.g. layouts
|
|
103
|
+
var EXTENSION_NODES = new Set(['inlineExtension', 'extension', 'bodiedExtension']);
|
|
104
|
+
var _fragmentContainsExtension = function fragmentContainsExtension(fragment) {
|
|
101
105
|
var found = false;
|
|
102
106
|
fragment.forEach(function (node) {
|
|
103
107
|
if (found) {
|
|
104
108
|
return;
|
|
105
109
|
}
|
|
106
|
-
if (
|
|
110
|
+
if ((0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
111
|
+
exposure: true
|
|
112
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
107
113
|
found = true;
|
|
108
114
|
} else if (node.content.size) {
|
|
109
|
-
if (
|
|
115
|
+
if (_fragmentContainsExtension(node.content)) {
|
|
110
116
|
found = true;
|
|
111
117
|
}
|
|
112
118
|
}
|
|
113
119
|
});
|
|
114
120
|
return found;
|
|
115
121
|
};
|
|
116
|
-
var
|
|
117
|
-
return
|
|
122
|
+
var sliceContainsExtension = function sliceContainsExtension(slice) {
|
|
123
|
+
return _fragmentContainsExtension(slice.content);
|
|
118
124
|
};
|
|
119
125
|
|
|
120
126
|
/**
|
|
121
127
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
122
128
|
* Used to show a warning flag only on the first instance per sync block.
|
|
123
129
|
*/
|
|
124
|
-
var
|
|
130
|
+
var wasExtensionInsertedInBodiedSyncBlock = exports.wasExtensionInsertedInBodiedSyncBlock = function wasExtensionInsertedInBodiedSyncBlock(tr, state) {
|
|
125
131
|
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
126
132
|
return undefined;
|
|
127
133
|
}
|
|
@@ -141,7 +147,7 @@ var wasInlineExtensionInsertedInBodiedSyncBlock = exports.wasInlineExtensionInse
|
|
|
141
147
|
continue;
|
|
142
148
|
}
|
|
143
149
|
var replaceStep = step;
|
|
144
|
-
if (!
|
|
150
|
+
if (!sliceContainsExtension(replaceStep.slice)) {
|
|
145
151
|
continue;
|
|
146
152
|
}
|
|
147
153
|
var docAfterStep = (_docs = docs[i + 1]) !== null && _docs !== void 0 ? _docs : tr.doc;
|
|
@@ -164,13 +170,17 @@ var wasInlineExtensionInsertedInBodiedSyncBlock = exports.wasInlineExtensionInse
|
|
|
164
170
|
if (resourceId !== undefined) {
|
|
165
171
|
return false;
|
|
166
172
|
}
|
|
167
|
-
if (
|
|
173
|
+
if ((0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
174
|
+
exposure: true
|
|
175
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
168
176
|
var _$pos = tr.doc.resolve(pos);
|
|
169
177
|
var _parent = (0, _utils.findParentNodeOfTypeClosestToPos)(_$pos, bodiedSyncBlock);
|
|
170
178
|
if (_parent !== null && _parent !== void 0 && _parent.node.attrs.resourceId) {
|
|
171
179
|
var mappedPos = tr.mapping.invert().map(pos);
|
|
172
180
|
var nodeBefore = state.doc.nodeAt(mappedPos);
|
|
173
|
-
if (!nodeBefore ||
|
|
181
|
+
if (!nodeBefore || ((0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
182
|
+
exposure: true
|
|
183
|
+
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
174
184
|
resourceId = _parent.node.attrs.resourceId;
|
|
175
185
|
return false;
|
|
176
186
|
}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var FLAG_ID = exports.FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
13
13
|
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
14
14
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
15
15
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
16
|
+
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
16
17
|
return FLAG_ID;
|
|
17
18
|
}({});
|
|
18
19
|
var SYNCED_BLOCK_BUTTON_TEST_ID = exports.SYNCED_BLOCK_BUTTON_TEST_ID = {
|
|
@@ -67,7 +67,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
67
67
|
isDisabled: isOffline,
|
|
68
68
|
testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.blockMenuCreate,
|
|
69
69
|
elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
70
|
-
appearance:
|
|
70
|
+
appearance: (0, _platformFeatureFlags.fg)('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
71
71
|
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
72
72
|
}, formatMessage(message));
|
|
73
73
|
};
|
|
@@ -102,7 +102,7 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
102
102
|
onClick: onClick,
|
|
103
103
|
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
104
104
|
elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
105
|
-
appearance:
|
|
105
|
+
appearance: (0, _platformFeatureFlags.fg)('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
106
106
|
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
107
107
|
}, formatMessage(_messages.blockMenuMessages.copySyncedBlock));
|
|
108
108
|
};
|
package/dist/cjs/ui/Flag.js
CHANGED
|
@@ -21,7 +21,7 @@ var _types = require("../types");
|
|
|
21
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
22
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
23
|
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; }
|
|
24
|
-
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
24
|
+
var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)((0, _defineProperty2.default)({}, _types.FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
25
25
|
title: _messages.syncBlockMessages.failToDeleteTitle,
|
|
26
26
|
description: _messages.syncBlockMessages.failToDeleteWhenOfflineDescription,
|
|
27
27
|
type: 'error'
|
|
@@ -48,6 +48,10 @@ var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _d
|
|
|
48
48
|
title: _messages.syncBlockMessages.cannotCreateSyncBlockTitle,
|
|
49
49
|
description: _messages.syncBlockMessages.CannotCreateSyncBlockDescription,
|
|
50
50
|
type: 'error'
|
|
51
|
+
}), _types.FLAG_ID.EXTENSION_IN_SYNC_BLOCK, {
|
|
52
|
+
title: _messages.syncBlockMessages.extensionInSyncBlockTitle,
|
|
53
|
+
description: _messages.syncBlockMessages.extensionInSyncBlockDescription,
|
|
54
|
+
type: 'error'
|
|
51
55
|
}), _types.FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK, {
|
|
52
56
|
title: _messages.syncBlockMessages.inlineExtensionInSyncBlockTitle,
|
|
53
57
|
description: _messages.syncBlockMessages.inlineExtensionInSyncBlockDescription,
|
|
@@ -13,6 +13,7 @@ var _runtime = require("@compiled/react/runtime");
|
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
14
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
15
15
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
16
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
17
|
var _editorCommands = require("../editor-commands");
|
|
17
18
|
var _types = require("../types");
|
|
18
19
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -34,7 +35,7 @@ var getQuickInsertConfig = exports.getQuickInsertConfig = function getQuickInser
|
|
|
34
35
|
lozenge: /*#__PURE__*/React.createElement("span", {
|
|
35
36
|
className: (0, _runtime.ax)(["_1o9zidpf _16jlidpf _1e0c116y"])
|
|
36
37
|
}, /*#__PURE__*/React.createElement(_lozenge.default, {
|
|
37
|
-
appearance:
|
|
38
|
+
appearance: (0, _platformFeatureFlags.fg)('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
38
39
|
}, formatMessage(_messages.blockTypeMessages.newLozenge))),
|
|
39
40
|
icon: function icon() {
|
|
40
41
|
return /*#__PURE__*/React.createElement(_quickInsert.IconSyncBlock, {
|
|
@@ -19,7 +19,7 @@ import { handleBodiedSyncBlockRemoval } from './utils/handle-bodied-sync-block-r
|
|
|
19
19
|
import { shouldIgnoreDomEvent } from './utils/ignore-dom-event';
|
|
20
20
|
import { calculateDecorations } from './utils/selection-decorations';
|
|
21
21
|
import { hasEditInSyncBlock, trackSyncBlocks } from './utils/track-sync-blocks';
|
|
22
|
-
import { deferDispatch,
|
|
22
|
+
import { deferDispatch, wasExtensionInsertedInBodiedSyncBlock, sliceFullyContainsNode } from './utils/utils';
|
|
23
23
|
export const syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
24
24
|
const mapRetryCreationPosMap = (oldMap, newRetryCreationPos, mapPos) => {
|
|
25
25
|
const resourceId = newRetryCreationPos === null || newRetryCreationPos === void 0 ? void 0 : newRetryCreationPos.resourceId;
|
|
@@ -56,21 +56,23 @@ const showCopiedFlag = api => {
|
|
|
56
56
|
}));
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
|
-
const
|
|
59
|
+
const showExtensionInSyncBlockWarningIfNeeded = (tr, state, api, extensionFlagShown) => {
|
|
60
60
|
var _api$connectivity, _api$connectivity$sha;
|
|
61
61
|
if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode)) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
const resourceId =
|
|
64
|
+
const resourceId = wasExtensionInsertedInBodiedSyncBlock(tr, state);
|
|
65
65
|
// Only show the flag on the first instance per sync block (same as UNPUBLISHED_SYNC_BLOCK_PASTED)
|
|
66
|
-
if (resourceId && !
|
|
67
|
-
|
|
66
|
+
if (resourceId && !extensionFlagShown.has(resourceId)) {
|
|
67
|
+
extensionFlagShown.add(resourceId);
|
|
68
68
|
deferDispatch(() => {
|
|
69
69
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(({
|
|
70
70
|
tr
|
|
71
71
|
}) => tr.setMeta(syncedBlockPluginKey, {
|
|
72
72
|
activeFlag: {
|
|
73
|
-
id:
|
|
73
|
+
id: editorExperiment('platform_synced_block_patch_6', true, {
|
|
74
|
+
exposure: true
|
|
75
|
+
}) ? FLAG_ID.EXTENSION_IN_SYNC_BLOCK : FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK
|
|
74
76
|
}
|
|
75
77
|
}));
|
|
76
78
|
});
|
|
@@ -91,7 +93,7 @@ const filterTransactionOnline = ({
|
|
|
91
93
|
confirmationTransactionRef,
|
|
92
94
|
bodiedSyncBlockRemoved,
|
|
93
95
|
bodiedSyncBlockAdded,
|
|
94
|
-
|
|
96
|
+
extensionFlagShown
|
|
95
97
|
}) => {
|
|
96
98
|
const {
|
|
97
99
|
removed: syncBlockRemoved,
|
|
@@ -138,7 +140,7 @@ const filterTransactionOnline = ({
|
|
|
138
140
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
139
141
|
return true;
|
|
140
142
|
}
|
|
141
|
-
|
|
143
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
142
144
|
return true;
|
|
143
145
|
};
|
|
144
146
|
const filterTransactionOffline = ({
|
|
@@ -188,7 +190,7 @@ class SyncedBlockPluginContext {
|
|
|
188
190
|
});
|
|
189
191
|
_defineProperty(this, "_isCopyEvent", false);
|
|
190
192
|
_defineProperty(this, "unpublishedFlagShown", new Set());
|
|
191
|
-
_defineProperty(this, "
|
|
193
|
+
_defineProperty(this, "extensionFlagShown", new Set());
|
|
192
194
|
}
|
|
193
195
|
get isCopyEvent() {
|
|
194
196
|
return this._isCopyEvent;
|
|
@@ -203,7 +205,7 @@ class SyncedBlockPluginContext {
|
|
|
203
205
|
}
|
|
204
206
|
}
|
|
205
207
|
export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
|
|
206
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$
|
|
208
|
+
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
207
209
|
const {
|
|
208
210
|
useLongPressSelection = false
|
|
209
211
|
} = options || {};
|
|
@@ -213,7 +215,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
213
215
|
};
|
|
214
216
|
let isCopyEvent = false;
|
|
215
217
|
const unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
216
|
-
const
|
|
218
|
+
const extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
217
219
|
|
|
218
220
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
219
221
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(resourceId => {
|
|
@@ -467,7 +469,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
467
469
|
confirmationTransactionRef,
|
|
468
470
|
bodiedSyncBlockRemoved,
|
|
469
471
|
bodiedSyncBlockAdded,
|
|
470
|
-
|
|
472
|
+
extensionFlagShown
|
|
471
473
|
});
|
|
472
474
|
}
|
|
473
475
|
if (!isOffline) {
|
|
@@ -515,7 +517,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
515
517
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
516
518
|
return true;
|
|
517
519
|
}
|
|
518
|
-
|
|
520
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
519
521
|
return true;
|
|
520
522
|
}
|
|
521
523
|
const {
|
|
@@ -3,6 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
@@ -91,29 +92,34 @@ export const sliceFullyContainsNode = (slice, node) => {
|
|
|
91
92
|
}
|
|
92
93
|
return true;
|
|
93
94
|
};
|
|
94
|
-
|
|
95
|
+
|
|
96
|
+
// even though extension and bodiedExtension are explicitly not allowed by the schema, they can still be inserted nested inside other nodes e.g. layouts
|
|
97
|
+
const EXTENSION_NODES = new Set(['inlineExtension', 'extension', 'bodiedExtension']);
|
|
98
|
+
const fragmentContainsExtension = fragment => {
|
|
95
99
|
let found = false;
|
|
96
100
|
fragment.forEach(node => {
|
|
97
101
|
if (found) {
|
|
98
102
|
return;
|
|
99
103
|
}
|
|
100
|
-
if (
|
|
104
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
105
|
+
exposure: true
|
|
106
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
101
107
|
found = true;
|
|
102
108
|
} else if (node.content.size) {
|
|
103
|
-
if (
|
|
109
|
+
if (fragmentContainsExtension(node.content)) {
|
|
104
110
|
found = true;
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
});
|
|
108
114
|
return found;
|
|
109
115
|
};
|
|
110
|
-
const
|
|
116
|
+
const sliceContainsExtension = slice => fragmentContainsExtension(slice.content);
|
|
111
117
|
|
|
112
118
|
/**
|
|
113
119
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
114
120
|
* Used to show a warning flag only on the first instance per sync block.
|
|
115
121
|
*/
|
|
116
|
-
export const
|
|
122
|
+
export const wasExtensionInsertedInBodiedSyncBlock = (tr, state) => {
|
|
117
123
|
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
118
124
|
return undefined;
|
|
119
125
|
}
|
|
@@ -135,7 +141,7 @@ export const wasInlineExtensionInsertedInBodiedSyncBlock = (tr, state) => {
|
|
|
135
141
|
continue;
|
|
136
142
|
}
|
|
137
143
|
const replaceStep = step;
|
|
138
|
-
if (!
|
|
144
|
+
if (!sliceContainsExtension(replaceStep.slice)) {
|
|
139
145
|
continue;
|
|
140
146
|
}
|
|
141
147
|
const docAfterStep = (_docs = docs[i + 1]) !== null && _docs !== void 0 ? _docs : tr.doc;
|
|
@@ -158,13 +164,17 @@ export const wasInlineExtensionInsertedInBodiedSyncBlock = (tr, state) => {
|
|
|
158
164
|
if (resourceId !== undefined) {
|
|
159
165
|
return false;
|
|
160
166
|
}
|
|
161
|
-
if (
|
|
167
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
168
|
+
exposure: true
|
|
169
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
162
170
|
const $pos = tr.doc.resolve(pos);
|
|
163
171
|
const parent = findParentNodeOfTypeClosestToPos($pos, bodiedSyncBlock);
|
|
164
172
|
if (parent !== null && parent !== void 0 && parent.node.attrs.resourceId) {
|
|
165
173
|
const mappedPos = tr.mapping.invert().map(pos);
|
|
166
174
|
const nodeBefore = state.doc.nodeAt(mappedPos);
|
|
167
|
-
if (!nodeBefore ||
|
|
175
|
+
if (!nodeBefore || (editorExperiment('platform_synced_block_patch_6', true, {
|
|
176
|
+
exposure: true
|
|
177
|
+
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
168
178
|
resourceId = parent.node.attrs.resourceId;
|
|
169
179
|
return false;
|
|
170
180
|
}
|
|
@@ -7,6 +7,7 @@ export let FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
7
7
|
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
8
8
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
9
9
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
10
|
+
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
10
11
|
return FLAG_ID;
|
|
11
12
|
}({});
|
|
12
13
|
export const SYNCED_BLOCK_BUTTON_TEST_ID = {
|
|
@@ -59,7 +59,7 @@ const CreateSyncedBlockDropdownItem = ({
|
|
|
59
59
|
isDisabled: isOffline,
|
|
60
60
|
testId: SYNCED_BLOCK_BUTTON_TEST_ID.blockMenuCreate,
|
|
61
61
|
elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
|
|
62
|
-
appearance:
|
|
62
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
63
63
|
}, formatMessage(blockMenuMessages.newLozenge))
|
|
64
64
|
}, formatMessage(message));
|
|
65
65
|
};
|
|
@@ -97,7 +97,7 @@ const CopySyncedBlockDropdownItem = ({
|
|
|
97
97
|
onClick: onClick,
|
|
98
98
|
isDisabled: isOfflineMode(mode),
|
|
99
99
|
elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
|
|
100
|
-
appearance:
|
|
100
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
101
101
|
}, formatMessage(blockMenuMessages.newLozenge))
|
|
102
102
|
}, formatMessage(blockMenuMessages.copySyncedBlock));
|
|
103
103
|
};
|
package/dist/es2019/ui/Flag.js
CHANGED
|
@@ -44,6 +44,11 @@ const flagMap = {
|
|
|
44
44
|
description: messages.CannotCreateSyncBlockDescription,
|
|
45
45
|
type: 'error'
|
|
46
46
|
},
|
|
47
|
+
[FLAG_ID.EXTENSION_IN_SYNC_BLOCK]: {
|
|
48
|
+
title: messages.extensionInSyncBlockTitle,
|
|
49
|
+
description: messages.extensionInSyncBlockDescription,
|
|
50
|
+
type: 'error'
|
|
51
|
+
},
|
|
47
52
|
[FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK]: {
|
|
48
53
|
title: messages.inlineExtensionInSyncBlockTitle,
|
|
49
54
|
description: messages.inlineExtensionInSyncBlockDescription,
|
|
@@ -5,6 +5,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
5
5
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
|
|
7
7
|
import Lozenge from '@atlaskit/lozenge';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { createSyncedBlock } from '../editor-commands';
|
|
9
10
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
10
11
|
const lozengeWrapperStyles = null;
|
|
@@ -26,7 +27,7 @@ export const getQuickInsertConfig = (config, api, syncBlockStore) => {
|
|
|
26
27
|
lozenge: /*#__PURE__*/React.createElement("span", {
|
|
27
28
|
className: ax(["_1o9zidpf _16jlidpf _1e0c116y"])
|
|
28
29
|
}, /*#__PURE__*/React.createElement(Lozenge, {
|
|
29
|
-
appearance:
|
|
30
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
30
31
|
}, formatMessage(blockTypeMessages.newLozenge))),
|
|
31
32
|
icon: () => /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
32
33
|
label: formatMessage(blockTypeMessages.syncedBlock)
|
|
@@ -27,7 +27,7 @@ import { handleBodiedSyncBlockRemoval } from './utils/handle-bodied-sync-block-r
|
|
|
27
27
|
import { shouldIgnoreDomEvent } from './utils/ignore-dom-event';
|
|
28
28
|
import { calculateDecorations } from './utils/selection-decorations';
|
|
29
29
|
import { hasEditInSyncBlock, trackSyncBlocks } from './utils/track-sync-blocks';
|
|
30
|
-
import { deferDispatch,
|
|
30
|
+
import { deferDispatch, wasExtensionInsertedInBodiedSyncBlock, sliceFullyContainsNode } from './utils/utils';
|
|
31
31
|
export var syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
32
32
|
var mapRetryCreationPosMap = function mapRetryCreationPosMap(oldMap, newRetryCreationPos, mapPos) {
|
|
33
33
|
var resourceId = newRetryCreationPos === null || newRetryCreationPos === void 0 ? void 0 : newRetryCreationPos.resourceId;
|
|
@@ -74,21 +74,23 @@ var showCopiedFlag = function showCopiedFlag(api) {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
|
-
var
|
|
77
|
+
var showExtensionInSyncBlockWarningIfNeeded = function showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown) {
|
|
78
78
|
var _api$connectivity;
|
|
79
79
|
if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode)) {
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
|
-
var resourceId =
|
|
82
|
+
var resourceId = wasExtensionInsertedInBodiedSyncBlock(tr, state);
|
|
83
83
|
// Only show the flag on the first instance per sync block (same as UNPUBLISHED_SYNC_BLOCK_PASTED)
|
|
84
|
-
if (resourceId && !
|
|
85
|
-
|
|
84
|
+
if (resourceId && !extensionFlagShown.has(resourceId)) {
|
|
85
|
+
extensionFlagShown.add(resourceId);
|
|
86
86
|
deferDispatch(function () {
|
|
87
87
|
api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
|
|
88
88
|
var tr = _ref2.tr;
|
|
89
89
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
90
90
|
activeFlag: {
|
|
91
|
-
id:
|
|
91
|
+
id: editorExperiment('platform_synced_block_patch_6', true, {
|
|
92
|
+
exposure: true
|
|
93
|
+
}) ? FLAG_ID.EXTENSION_IN_SYNC_BLOCK : FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK
|
|
92
94
|
}
|
|
93
95
|
});
|
|
94
96
|
});
|
|
@@ -110,7 +112,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
110
112
|
confirmationTransactionRef = _ref3.confirmationTransactionRef,
|
|
111
113
|
bodiedSyncBlockRemoved = _ref3.bodiedSyncBlockRemoved,
|
|
112
114
|
bodiedSyncBlockAdded = _ref3.bodiedSyncBlockAdded,
|
|
113
|
-
|
|
115
|
+
extensionFlagShown = _ref3.extensionFlagShown;
|
|
114
116
|
var _trackSyncBlocks = trackSyncBlocks(function (node) {
|
|
115
117
|
return node.type.name === 'syncBlock';
|
|
116
118
|
}, tr, state),
|
|
@@ -157,7 +159,7 @@ var filterTransactionOnline = function filterTransactionOnline(_ref3) {
|
|
|
157
159
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
158
160
|
return true;
|
|
159
161
|
}
|
|
160
|
-
|
|
162
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
161
163
|
return true;
|
|
162
164
|
};
|
|
163
165
|
var filterTransactionOffline = function filterTransactionOffline(_ref4) {
|
|
@@ -209,7 +211,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
209
211
|
});
|
|
210
212
|
_defineProperty(this, "_isCopyEvent", false);
|
|
211
213
|
_defineProperty(this, "unpublishedFlagShown", new Set());
|
|
212
|
-
_defineProperty(this, "
|
|
214
|
+
_defineProperty(this, "extensionFlagShown", new Set());
|
|
213
215
|
}
|
|
214
216
|
return _createClass(SyncedBlockPluginContext, [{
|
|
215
217
|
key: "isCopyEvent",
|
|
@@ -231,7 +233,7 @@ var SyncedBlockPluginContext = /*#__PURE__*/function () {
|
|
|
231
233
|
}]);
|
|
232
234
|
}();
|
|
233
235
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
234
|
-
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$
|
|
236
|
+
var _ctx$confirmationTran, _ctx$unpublishedFlagS, _ctx$extensionFlagSho;
|
|
235
237
|
var _ref6 = options || {},
|
|
236
238
|
_ref6$useLongPressSel = _ref6.useLongPressSelection,
|
|
237
239
|
useLongPressSelection = _ref6$useLongPressSel === void 0 ? false : _ref6$useLongPressSel;
|
|
@@ -241,7 +243,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
241
243
|
};
|
|
242
244
|
var isCopyEvent = false;
|
|
243
245
|
var unpublishedFlagShown = (_ctx$unpublishedFlagS = ctx === null || ctx === void 0 ? void 0 : ctx.unpublishedFlagShown) !== null && _ctx$unpublishedFlagS !== void 0 ? _ctx$unpublishedFlagS : new Set();
|
|
244
|
-
var
|
|
246
|
+
var extensionFlagShown = (_ctx$extensionFlagSho = ctx === null || ctx === void 0 ? void 0 : ctx.extensionFlagShown) !== null && _ctx$extensionFlagSho !== void 0 ? _ctx$extensionFlagSho : new Set();
|
|
245
247
|
|
|
246
248
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
247
249
|
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
@@ -495,7 +497,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
495
497
|
confirmationTransactionRef: confirmationTransactionRef,
|
|
496
498
|
bodiedSyncBlockRemoved: bodiedSyncBlockRemoved,
|
|
497
499
|
bodiedSyncBlockAdded: bodiedSyncBlockAdded,
|
|
498
|
-
|
|
500
|
+
extensionFlagShown: extensionFlagShown
|
|
499
501
|
});
|
|
500
502
|
}
|
|
501
503
|
if (!isOffline) {
|
|
@@ -544,7 +546,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
544
546
|
handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, state, api);
|
|
545
547
|
return true;
|
|
546
548
|
}
|
|
547
|
-
|
|
549
|
+
showExtensionInSyncBlockWarningIfNeeded(tr, state, api, extensionFlagShown);
|
|
548
550
|
return true;
|
|
549
551
|
}
|
|
550
552
|
var _trackSyncBlocks6 = trackSyncBlocks(function (node) {
|
|
@@ -3,6 +3,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
4
4
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Defers a callback to the next microtask (when gated) or next macrotask via setTimeout(0).
|
|
@@ -92,31 +93,36 @@ export var sliceFullyContainsNode = function sliceFullyContainsNode(slice, node)
|
|
|
92
93
|
}
|
|
93
94
|
return true;
|
|
94
95
|
};
|
|
95
|
-
|
|
96
|
+
|
|
97
|
+
// even though extension and bodiedExtension are explicitly not allowed by the schema, they can still be inserted nested inside other nodes e.g. layouts
|
|
98
|
+
var EXTENSION_NODES = new Set(['inlineExtension', 'extension', 'bodiedExtension']);
|
|
99
|
+
var _fragmentContainsExtension = function fragmentContainsExtension(fragment) {
|
|
96
100
|
var found = false;
|
|
97
101
|
fragment.forEach(function (node) {
|
|
98
102
|
if (found) {
|
|
99
103
|
return;
|
|
100
104
|
}
|
|
101
|
-
if (
|
|
105
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
106
|
+
exposure: true
|
|
107
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
102
108
|
found = true;
|
|
103
109
|
} else if (node.content.size) {
|
|
104
|
-
if (
|
|
110
|
+
if (_fragmentContainsExtension(node.content)) {
|
|
105
111
|
found = true;
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
});
|
|
109
115
|
return found;
|
|
110
116
|
};
|
|
111
|
-
var
|
|
112
|
-
return
|
|
117
|
+
var sliceContainsExtension = function sliceContainsExtension(slice) {
|
|
118
|
+
return _fragmentContainsExtension(slice.content);
|
|
113
119
|
};
|
|
114
120
|
|
|
115
121
|
/**
|
|
116
122
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
117
123
|
* Used to show a warning flag only on the first instance per sync block.
|
|
118
124
|
*/
|
|
119
|
-
export var
|
|
125
|
+
export var wasExtensionInsertedInBodiedSyncBlock = function wasExtensionInsertedInBodiedSyncBlock(tr, state) {
|
|
120
126
|
if (!tr.docChanged || tr.getMeta('isRemote')) {
|
|
121
127
|
return undefined;
|
|
122
128
|
}
|
|
@@ -136,7 +142,7 @@ export var wasInlineExtensionInsertedInBodiedSyncBlock = function wasInlineExten
|
|
|
136
142
|
continue;
|
|
137
143
|
}
|
|
138
144
|
var replaceStep = step;
|
|
139
|
-
if (!
|
|
145
|
+
if (!sliceContainsExtension(replaceStep.slice)) {
|
|
140
146
|
continue;
|
|
141
147
|
}
|
|
142
148
|
var docAfterStep = (_docs = docs[i + 1]) !== null && _docs !== void 0 ? _docs : tr.doc;
|
|
@@ -159,13 +165,17 @@ export var wasInlineExtensionInsertedInBodiedSyncBlock = function wasInlineExten
|
|
|
159
165
|
if (resourceId !== undefined) {
|
|
160
166
|
return false;
|
|
161
167
|
}
|
|
162
|
-
if (
|
|
168
|
+
if (editorExperiment('platform_synced_block_patch_6', true, {
|
|
169
|
+
exposure: true
|
|
170
|
+
}) ? EXTENSION_NODES.has(node.type.name) : node.type.name === 'inlineExtension') {
|
|
163
171
|
var _$pos = tr.doc.resolve(pos);
|
|
164
172
|
var _parent = findParentNodeOfTypeClosestToPos(_$pos, bodiedSyncBlock);
|
|
165
173
|
if (_parent !== null && _parent !== void 0 && _parent.node.attrs.resourceId) {
|
|
166
174
|
var mappedPos = tr.mapping.invert().map(pos);
|
|
167
175
|
var nodeBefore = state.doc.nodeAt(mappedPos);
|
|
168
|
-
if (!nodeBefore ||
|
|
176
|
+
if (!nodeBefore || (editorExperiment('platform_synced_block_patch_6', true, {
|
|
177
|
+
exposure: true
|
|
178
|
+
}) ? EXTENSION_NODES.has(nodeBefore.type.name) : nodeBefore.type.name !== 'inlineExtension')) {
|
|
169
179
|
resourceId = _parent.node.attrs.resourceId;
|
|
170
180
|
return false;
|
|
171
181
|
}
|
package/dist/esm/types/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
7
7
|
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
8
8
|
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
9
9
|
FLAG_ID["INLINE_EXTENSION_IN_SYNC_BLOCK"] = "inline-extension-in-sync-block";
|
|
10
|
+
FLAG_ID["EXTENSION_IN_SYNC_BLOCK"] = "extension-in-sync-block";
|
|
10
11
|
return FLAG_ID;
|
|
11
12
|
}({});
|
|
12
13
|
export var SYNCED_BLOCK_BUTTON_TEST_ID = {
|
|
@@ -58,7 +58,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
58
58
|
isDisabled: isOffline,
|
|
59
59
|
testId: SYNCED_BLOCK_BUTTON_TEST_ID.blockMenuCreate,
|
|
60
60
|
elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
|
|
61
|
-
appearance:
|
|
61
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
62
62
|
}, formatMessage(blockMenuMessages.newLozenge))
|
|
63
63
|
}, formatMessage(message));
|
|
64
64
|
};
|
|
@@ -93,7 +93,7 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
93
93
|
onClick: onClick,
|
|
94
94
|
isDisabled: isOfflineMode(mode),
|
|
95
95
|
elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
|
|
96
|
-
appearance:
|
|
96
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
97
97
|
}, formatMessage(blockMenuMessages.newLozenge))
|
|
98
98
|
}, formatMessage(blockMenuMessages.copySyncedBlock));
|
|
99
99
|
};
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -12,7 +12,7 @@ import StatusSuccessIcon from '@atlaskit/icon/core/status-success';
|
|
|
12
12
|
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
13
13
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
14
14
|
import { FLAG_ID } from '../types';
|
|
15
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
15
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
16
16
|
title: messages.failToDeleteTitle,
|
|
17
17
|
description: messages.failToDeleteWhenOfflineDescription,
|
|
18
18
|
type: 'error'
|
|
@@ -39,6 +39,10 @@ var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_d
|
|
|
39
39
|
title: messages.cannotCreateSyncBlockTitle,
|
|
40
40
|
description: messages.CannotCreateSyncBlockDescription,
|
|
41
41
|
type: 'error'
|
|
42
|
+
}), FLAG_ID.EXTENSION_IN_SYNC_BLOCK, {
|
|
43
|
+
title: messages.extensionInSyncBlockTitle,
|
|
44
|
+
description: messages.extensionInSyncBlockDescription,
|
|
45
|
+
type: 'error'
|
|
42
46
|
}), FLAG_ID.INLINE_EXTENSION_IN_SYNC_BLOCK, {
|
|
43
47
|
title: messages.inlineExtensionInSyncBlockTitle,
|
|
44
48
|
description: messages.inlineExtensionInSyncBlockDescription,
|
|
@@ -5,6 +5,7 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
5
5
|
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { IconSyncBlock } from '@atlaskit/editor-common/quick-insert';
|
|
7
7
|
import Lozenge from '@atlaskit/lozenge';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { createSyncedBlock } from '../editor-commands';
|
|
9
10
|
import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
|
|
10
11
|
var lozengeWrapperStyles = null;
|
|
@@ -25,7 +26,7 @@ export var getQuickInsertConfig = function getQuickInsertConfig(config, api, syn
|
|
|
25
26
|
lozenge: /*#__PURE__*/React.createElement("span", {
|
|
26
27
|
className: ax(["_1o9zidpf _16jlidpf _1e0c116y"])
|
|
27
28
|
}, /*#__PURE__*/React.createElement(Lozenge, {
|
|
28
|
-
appearance:
|
|
29
|
+
appearance: fg('confluence_fronend_labels_categorization_migration') ? 'discovery' : 'new'
|
|
29
30
|
}, formatMessage(blockTypeMessages.newLozenge))),
|
|
30
31
|
icon: function icon() {
|
|
31
32
|
return /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
@@ -30,4 +30,4 @@ export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boo
|
|
|
30
30
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
31
31
|
* Used to show a warning flag only on the first instance per sync block.
|
|
32
32
|
*/
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const wasExtensionInsertedInBodiedSyncBlock: (tr: Transaction, state: EditorState) => string | undefined;
|
|
@@ -9,7 +9,8 @@ export declare enum FLAG_ID {
|
|
|
9
9
|
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
|
-
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block"
|
|
12
|
+
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
14
|
}
|
|
14
15
|
type FlagConfig = {
|
|
15
16
|
id: FLAG_ID;
|
|
@@ -36,6 +37,10 @@ export type SyncedBlockSharedState = {
|
|
|
36
37
|
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
37
38
|
*/
|
|
38
39
|
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
42
|
+
*/
|
|
43
|
+
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
39
44
|
/**
|
|
40
45
|
* Positions of pending creations keyed by resourceId, used for retry/revert flow.
|
|
41
46
|
* When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
|
|
@@ -46,10 +51,6 @@ export type SyncedBlockSharedState = {
|
|
|
46
51
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
47
52
|
*/
|
|
48
53
|
syncBlockStore: SyncBlockStoreManager;
|
|
49
|
-
/**
|
|
50
|
-
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
51
|
-
*/
|
|
52
|
-
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
53
54
|
};
|
|
54
55
|
export type SyncBlockAttrs = {
|
|
55
56
|
localId: string;
|
|
@@ -30,4 +30,4 @@ export declare const sliceFullyContainsNode: (slice: Slice, node: PMNode) => boo
|
|
|
30
30
|
* Returns the resourceId of the bodied sync block where an inline extension was inserted, or undefined.
|
|
31
31
|
* Used to show a warning flag only on the first instance per sync block.
|
|
32
32
|
*/
|
|
33
|
-
export declare const
|
|
33
|
+
export declare const wasExtensionInsertedInBodiedSyncBlock: (tr: Transaction, state: EditorState) => string | undefined;
|
|
@@ -9,7 +9,8 @@ export declare enum FLAG_ID {
|
|
|
9
9
|
SYNC_BLOCK_COPIED = "sync-block-copied",
|
|
10
10
|
UNPUBLISHED_SYNC_BLOCK_PASTED = "unpublished-sync-block-pasted",
|
|
11
11
|
CANNOT_CREATE_SYNC_BLOCK = "cannot-create-sync-block",
|
|
12
|
-
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block"
|
|
12
|
+
INLINE_EXTENSION_IN_SYNC_BLOCK = "inline-extension-in-sync-block",
|
|
13
|
+
EXTENSION_IN_SYNC_BLOCK = "extension-in-sync-block"
|
|
13
14
|
}
|
|
14
15
|
type FlagConfig = {
|
|
15
16
|
id: FLAG_ID;
|
|
@@ -36,6 +37,10 @@ export type SyncedBlockSharedState = {
|
|
|
36
37
|
* Whether the plugin is currently saving bodiedSyncBlock deletion to backend
|
|
37
38
|
*/
|
|
38
39
|
bodiedSyncBlockDeletionStatus?: BodiedSyncBlockDeletionStatus;
|
|
40
|
+
/**
|
|
41
|
+
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
42
|
+
*/
|
|
43
|
+
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
39
44
|
/**
|
|
40
45
|
* Positions of pending creations keyed by resourceId, used for retry/revert flow.
|
|
41
46
|
* When a new bodiedSyncBlock is added, a new entry is added to map for mapping. The entry is removed when creation succeeds or retry option is dismissed.
|
|
@@ -46,10 +51,6 @@ export type SyncedBlockSharedState = {
|
|
|
46
51
|
* The current sync block store manager, used to manage fetching and updating sync block data
|
|
47
52
|
*/
|
|
48
53
|
syncBlockStore: SyncBlockStoreManager;
|
|
49
|
-
/**
|
|
50
|
-
* Whether there are unsaved bodiedSyncBlock changes in the cache
|
|
51
|
-
*/
|
|
52
|
-
hasUnsavedBodiedSyncBlockChanges: boolean;
|
|
53
54
|
};
|
|
54
55
|
export type SyncBlockAttrs = {
|
|
55
56
|
localId: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "5.4.
|
|
3
|
+
"version": "5.4.8",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@atlaskit/editor-plugin-user-intent": "^5.0.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "^7.3.0",
|
|
45
45
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
46
|
-
"@atlaskit/editor-synced-block-provider": "^3.
|
|
46
|
+
"@atlaskit/editor-synced-block-provider": "^3.32.0",
|
|
47
47
|
"@atlaskit/editor-toolbar": "^0.19.0",
|
|
48
48
|
"@atlaskit/flag": "^17.8.0",
|
|
49
49
|
"@atlaskit/icon": "32.0.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
55
55
|
"@atlaskit/primitives": "^18.0.0",
|
|
56
56
|
"@atlaskit/spinner": "19.0.11",
|
|
57
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
57
|
+
"@atlaskit/tmp-editor-statsig": "^35.0.0",
|
|
58
58
|
"@atlaskit/tokens": "11.0.2",
|
|
59
59
|
"@atlaskit/tooltip": "^20.14.0",
|
|
60
60
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@atlaskit/editor-common": "^111.
|
|
68
|
+
"@atlaskit/editor-common": "^111.30.0",
|
|
69
69
|
"react": "^18.2.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -113,6 +113,9 @@
|
|
|
113
113
|
},
|
|
114
114
|
"platform_editor_block_menu_v2_patch_3": {
|
|
115
115
|
"type": "boolean"
|
|
116
|
+
},
|
|
117
|
+
"confluence_fronend_labels_categorization_migration": {
|
|
118
|
+
"type": "boolean"
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
}
|