@atlaskit/editor-plugin-synced-block 5.3.12 → 5.3.14
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/afm-cc/tsconfig.json +0 -3
- package/afm-jira/tsconfig.json +0 -3
- package/afm-products/tsconfig.json +0 -3
- package/dist/cjs/editor-commands/index.js +34 -38
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/cjs/nodeviews/syncedBlock.js +4 -18
- package/dist/cjs/pm-plugins/main.js +120 -67
- package/dist/cjs/pm-plugins/utils/handle-bodied-sync-block-creation.js +141 -0
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/cjs/pm-plugins/utils/utils.js +1 -46
- package/dist/cjs/syncedBlockPlugin.js +7 -7
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/DeleteConfirmationModal.js +4 -20
- package/dist/cjs/ui/Flag.js +5 -1
- package/dist/cjs/ui/SyncBlockLabel.js +4 -10
- package/dist/cjs/ui/SyncBlockRefresher.js +7 -9
- package/dist/cjs/ui/floating-toolbar.js +6 -3
- package/dist/es2019/editor-commands/index.js +34 -38
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/es2019/nodeviews/syncedBlock.js +4 -15
- package/dist/es2019/pm-plugins/main.js +99 -58
- package/dist/es2019/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/es2019/pm-plugins/utils/utils.js +0 -47
- package/dist/es2019/syncedBlockPlugin.js +7 -6
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/DeleteConfirmationModal.js +4 -20
- package/dist/es2019/ui/Flag.js +5 -0
- package/dist/es2019/ui/SyncBlockLabel.js +4 -10
- package/dist/es2019/ui/SyncBlockRefresher.js +7 -9
- package/dist/es2019/ui/floating-toolbar.js +6 -3
- package/dist/esm/editor-commands/index.js +34 -38
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +2 -7
- package/dist/esm/nodeviews/syncedBlock.js +4 -18
- package/dist/esm/pm-plugins/main.js +120 -67
- package/dist/esm/pm-plugins/utils/handle-bodied-sync-block-creation.js +134 -0
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +2 -2
- package/dist/esm/pm-plugins/utils/utils.js +0 -45
- package/dist/esm/syncedBlockPlugin.js +7 -7
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/DeleteConfirmationModal.js +4 -20
- package/dist/esm/ui/Flag.js +5 -1
- package/dist/esm/ui/SyncBlockLabel.js +4 -10
- package/dist/esm/ui/SyncBlockRefresher.js +7 -9
- package/dist/esm/ui/floating-toolbar.js +6 -3
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
- package/dist/types/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
- package/dist/types/pm-plugins/utils/utils.d.ts +1 -3
- package/dist/types/types/index.d.ts +19 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-creation.d.ts +9 -0
- package/dist/types-ts4.5/pm-plugins/utils/handle-bodied-sync-block-removal.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/utils/utils.d.ts +1 -3
- package/dist/types-ts4.5/types/index.d.ts +19 -1
- package/package.json +1 -5
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.handleBodiedSyncBlockCreation = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
|
+
var _types = require("../../types");
|
|
11
|
+
var _main = require("../main");
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
var onRetry = function onRetry(api, resourceId) {
|
|
15
|
+
return function () {
|
|
16
|
+
var _api$core, _api$core2;
|
|
17
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.focus();
|
|
18
|
+
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute(function (_ref) {
|
|
19
|
+
var _api$syncedBlock, _api$syncedBlock2;
|
|
20
|
+
var tr = _ref.tr;
|
|
21
|
+
var pos = api === null || api === void 0 || (_api$syncedBlock = api.syncedBlock) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.sharedState.currentState()) === null || _api$syncedBlock === void 0 || (_api$syncedBlock = _api$syncedBlock.retryCreationPosMap) === null || _api$syncedBlock === void 0 ? void 0 : _api$syncedBlock.get(resourceId);
|
|
22
|
+
var from = pos === null || pos === void 0 ? void 0 : pos.from;
|
|
23
|
+
var to = pos === null || pos === void 0 ? void 0 : pos.to;
|
|
24
|
+
if (from === undefined || to === undefined) {
|
|
25
|
+
return tr;
|
|
26
|
+
}
|
|
27
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, from, to)).setMeta(_main.syncedBlockPluginKey, {
|
|
28
|
+
activeFlag: false
|
|
29
|
+
});
|
|
30
|
+
api === null || api === void 0 || (_api$syncedBlock2 = api.syncedBlock) === null || _api$syncedBlock2 === void 0 || _api$syncedBlock2.commands.insertSyncedBlock()({
|
|
31
|
+
tr: tr
|
|
32
|
+
});
|
|
33
|
+
return tr;
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var getRevertCreationPos = function getRevertCreationPos(api, doc, resourceId) {
|
|
38
|
+
var _api$syncedBlock3;
|
|
39
|
+
var retryCreationPos = api === null || api === void 0 || (_api$syncedBlock3 = api.syncedBlock) === null || _api$syncedBlock3 === void 0 || (_api$syncedBlock3 = _api$syncedBlock3.sharedState.currentState()) === null || _api$syncedBlock3 === void 0 || (_api$syncedBlock3 = _api$syncedBlock3.retryCreationPosMap) === null || _api$syncedBlock3 === void 0 ? void 0 : _api$syncedBlock3.get(resourceId);
|
|
40
|
+
if (retryCreationPos) {
|
|
41
|
+
return retryCreationPos;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Fallback to find the positions in case BE call returns before plugin state becomes available
|
|
45
|
+
// which is highly unlikely
|
|
46
|
+
var currentPos;
|
|
47
|
+
doc.descendants(function (node, pos) {
|
|
48
|
+
if (currentPos) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
if (node.type.name === 'bodiedSyncBlock' && resourceId === node.attrs.resourceId) {
|
|
52
|
+
currentPos = {
|
|
53
|
+
from: pos,
|
|
54
|
+
to: pos + node.nodeSize
|
|
55
|
+
};
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return currentPos;
|
|
60
|
+
};
|
|
61
|
+
var buildRevertCreationTr = function buildRevertCreationTr(tr, pos) {
|
|
62
|
+
var _tr$doc$nodeAt;
|
|
63
|
+
var content = (_tr$doc$nodeAt = tr.doc.nodeAt(pos.from)) === null || _tr$doc$nodeAt === void 0 ? void 0 : _tr$doc$nodeAt.content;
|
|
64
|
+
if (content) {
|
|
65
|
+
tr.replaceWith(pos.from, pos.to, content);
|
|
66
|
+
var contentFrom = tr.mapping.map(pos.from);
|
|
67
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, contentFrom, contentFrom + content.size));
|
|
68
|
+
} else {
|
|
69
|
+
tr.delete(pos.from, pos.to);
|
|
70
|
+
}
|
|
71
|
+
return tr;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* Save the new bodiedSyncBlock to backend with empty content and handles revert (if failed) and retry flow
|
|
77
|
+
*/
|
|
78
|
+
var handleBodiedSyncBlockCreation = exports.handleBodiedSyncBlockCreation = function handleBodiedSyncBlockCreation(bodiedSyncBlockAdded, editorState, api) {
|
|
79
|
+
var syncBlockStore = _main.syncedBlockPluginKey.getState(editorState).syncBlockStore;
|
|
80
|
+
bodiedSyncBlockAdded.forEach(function (node) {
|
|
81
|
+
if (node.from === undefined || node.to === undefined) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
var retryCreationPos = {
|
|
85
|
+
from: node.from,
|
|
86
|
+
to: node.to
|
|
87
|
+
};
|
|
88
|
+
var resourceId = node.attrs.resourceId;
|
|
89
|
+
setTimeout(function () {
|
|
90
|
+
var _api$core3;
|
|
91
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(function (_ref2) {
|
|
92
|
+
var tr = _ref2.tr;
|
|
93
|
+
return tr.setMeta(_main.syncedBlockPluginKey, {
|
|
94
|
+
retryCreationPos: {
|
|
95
|
+
resourceId: resourceId,
|
|
96
|
+
pos: retryCreationPos
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(node.attrs, function (success) {
|
|
102
|
+
if (success) {
|
|
103
|
+
var _api$core4, _api$core5;
|
|
104
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(function (_ref3) {
|
|
105
|
+
var tr = _ref3.tr;
|
|
106
|
+
return tr.setMeta(_main.syncedBlockPluginKey, {
|
|
107
|
+
retryCreationPos: {
|
|
108
|
+
resourceId: resourceId,
|
|
109
|
+
pos: undefined
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
api === null || api === void 0 || (_api$core5 = api.core) === null || _api$core5 === void 0 || _api$core5.actions.focus();
|
|
114
|
+
} else {
|
|
115
|
+
var _api$core6;
|
|
116
|
+
api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 || _api$core6.actions.execute(function (_ref4) {
|
|
117
|
+
var tr = _ref4.tr;
|
|
118
|
+
var revertCreationPos = getRevertCreationPos(api, tr.doc, resourceId);
|
|
119
|
+
if (!revertCreationPos) {
|
|
120
|
+
return tr;
|
|
121
|
+
}
|
|
122
|
+
var revertTr = buildRevertCreationTr(tr, revertCreationPos);
|
|
123
|
+
return revertTr.setMeta('isConfirmedSyncBlockDeletion', true).setMeta('addToHistory', false).setMeta(_main.syncedBlockPluginKey, {
|
|
124
|
+
activeFlag: {
|
|
125
|
+
id: _types.FLAG_ID.CANNOT_CREATE_SYNC_BLOCK,
|
|
126
|
+
onRetry: onRetry(api, resourceId),
|
|
127
|
+
onDismissed: function onDismissed(tr) {
|
|
128
|
+
return tr.setMeta(_main.syncedBlockPluginKey, _objectSpread(_objectSpread({}, tr.getMeta(_main.syncedBlockPluginKey)), {}, {
|
|
129
|
+
retryCreationPos: {
|
|
130
|
+
resourceId: resourceId,
|
|
131
|
+
pos: undefined
|
|
132
|
+
}
|
|
133
|
+
}));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}, node.node);
|
|
140
|
+
});
|
|
141
|
+
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.trackSyncBlocks = exports.hasEditInSyncBlock = void 0;
|
|
7
7
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
8
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
9
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
11
10
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
12
11
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -29,7 +28,7 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
|
|
|
29
28
|
var hasBodiedSyncBlockChanges = replaceSteps.some(function (step, idx) {
|
|
30
29
|
var from = step.from,
|
|
31
30
|
to = step.to;
|
|
32
|
-
var docAtStep =
|
|
31
|
+
var docAtStep = tr.docs[idx];
|
|
33
32
|
var hasChange = false;
|
|
34
33
|
if (from !== to) {
|
|
35
34
|
step.getMap().forEach(function (oldStart, oldEnd) {
|
|
@@ -76,6 +75,7 @@ var trackSyncBlocks = exports.trackSyncBlocks = function trackSyncBlocks(predica
|
|
|
76
75
|
var syncBlockAttr = node.attrs;
|
|
77
76
|
syncBlockMapNew[syncBlockAttr.localId] = {
|
|
78
77
|
attrs: syncBlockAttr,
|
|
78
|
+
node: node,
|
|
79
79
|
from: offset,
|
|
80
80
|
to: offset + node.nodeSize
|
|
81
81
|
};
|
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.sliceFullyContainsNode = exports.isBodiedSyncBlockNode = exports.findSyncBlockOrBodiedSyncBlock = exports.findSyncBlock = exports.findBodiedSyncBlock = exports.
|
|
6
|
+
exports.sliceFullyContainsNode = exports.isBodiedSyncBlockNode = exports.findSyncBlockOrBodiedSyncBlock = exports.findSyncBlock = exports.findBodiedSyncBlock = exports.canBeConvertedToSyncBlock = void 0;
|
|
7
7
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
var _editorTables = require("@atlaskit/editor-tables");
|
|
12
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
10
|
var findSyncBlock = exports.findSyncBlock = function findSyncBlock(schema, selection) {
|
|
14
11
|
var syncBlock = schema.nodes.syncBlock;
|
|
15
12
|
return (0, _utils.findSelectedNodeOfType)(syncBlock)(selection);
|
|
@@ -34,48 +31,6 @@ var UNSUPPORTED_NODE_TYPES = new Set(['inlineExtension', 'extension', 'bodiedExt
|
|
|
34
31
|
* or false if conversion is not possible
|
|
35
32
|
*/
|
|
36
33
|
var canBeConvertedToSyncBlock = exports.canBeConvertedToSyncBlock = function canBeConvertedToSyncBlock(selection) {
|
|
37
|
-
return (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? canBeConvertedToSyncBlockNew(selection) : canBeConvertedToSyncBlockOld(selection);
|
|
38
|
-
};
|
|
39
|
-
var canBeConvertedToSyncBlockOld = exports.canBeConvertedToSyncBlockOld = function canBeConvertedToSyncBlockOld(selection) {
|
|
40
|
-
var schema = selection.$from.doc.type.schema;
|
|
41
|
-
var nodes = schema.nodes;
|
|
42
|
-
var from = selection.from;
|
|
43
|
-
var to = selection.to;
|
|
44
|
-
var contentToInclude = selection.content().content;
|
|
45
|
-
if (selection instanceof _editorTables.CellSelection) {
|
|
46
|
-
var table = (0, _editorTables.findTable)(selection);
|
|
47
|
-
if (!table) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
contentToInclude = _model.Fragment.from([table.node]);
|
|
51
|
-
from = table.pos;
|
|
52
|
-
to = table.pos + table.node.nodeSize;
|
|
53
|
-
} else if (selection instanceof _state.TextSelection) {
|
|
54
|
-
var trueParent = (0, _utils.findParentNodeOfType)([nodes.bulletList, nodes.orderedList, nodes.taskList, nodes.blockquote])(selection);
|
|
55
|
-
if (trueParent) {
|
|
56
|
-
contentToInclude = _model.Fragment.from([trueParent.node]);
|
|
57
|
-
from = trueParent.pos;
|
|
58
|
-
to = trueParent.pos + trueParent.node.nodeSize;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
var canBeConverted = true;
|
|
62
|
-
selection.$from.doc.nodesBetween(from, to, function (node) {
|
|
63
|
-
if (UNSUPPORTED_NODE_TYPES.has(node.type.name)) {
|
|
64
|
-
canBeConverted = false;
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
if (!canBeConverted) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
contentToInclude = removeBreakoutMarks(contentToInclude);
|
|
72
|
-
return {
|
|
73
|
-
contentToInclude: contentToInclude,
|
|
74
|
-
from: from,
|
|
75
|
-
to: to
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
var canBeConvertedToSyncBlockNew = exports.canBeConvertedToSyncBlockNew = function canBeConvertedToSyncBlockNew(selection) {
|
|
79
34
|
var _expandSelectionToBlo = (0, _selection.expandSelectionToBlockRange)(selection),
|
|
80
35
|
$from = _expandSelectionToBlo.$from,
|
|
81
36
|
range = _expandSelectionToBlo.range;
|
|
@@ -5,14 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.syncedBlockPlugin = void 0;
|
|
8
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
8
|
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
11
10
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
11
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
13
12
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
14
13
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
14
|
var _editorActions = require("./editor-actions");
|
|
17
15
|
var _editorCommands = require("./editor-commands");
|
|
18
16
|
var _main = require("./pm-plugins/main");
|
|
@@ -50,7 +48,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
50
48
|
plugin: function plugin(params) {
|
|
51
49
|
return (0, _main.createPlugin)(config, params, syncBlockStore, api);
|
|
52
50
|
}
|
|
53
|
-
}
|
|
51
|
+
}, {
|
|
54
52
|
name: 'menuAndToolbarExperiencesPlugin',
|
|
55
53
|
plugin: function plugin() {
|
|
56
54
|
return (0, _menuAndToolbarExperiences.getMenuAndToolbarExperiencesPlugin)({
|
|
@@ -61,7 +59,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
|
-
}]
|
|
62
|
+
}];
|
|
65
63
|
},
|
|
66
64
|
commands: {
|
|
67
65
|
copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard(inputMethod) {
|
|
@@ -121,7 +119,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
121
119
|
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions.fireAnalyticsEvent
|
|
122
120
|
});
|
|
123
121
|
},
|
|
124
|
-
testId:
|
|
122
|
+
testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.quickInsertCreate
|
|
125
123
|
}];
|
|
126
124
|
},
|
|
127
125
|
floatingToolbar: function floatingToolbar(state, intl) {
|
|
@@ -152,11 +150,13 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
152
150
|
var _syncedBlockPluginKey = _main.syncedBlockPluginKey.getState(editorState),
|
|
153
151
|
activeFlag = _syncedBlockPluginKey.activeFlag,
|
|
154
152
|
currentSyncBlockStore = _syncedBlockPluginKey.syncBlockStore,
|
|
155
|
-
bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus
|
|
153
|
+
bodiedSyncBlockDeletionStatus = _syncedBlockPluginKey.bodiedSyncBlockDeletionStatus,
|
|
154
|
+
retryCreationPosMap = _syncedBlockPluginKey.retryCreationPosMap;
|
|
156
155
|
return {
|
|
157
156
|
activeFlag: activeFlag,
|
|
158
157
|
syncBlockStore: currentSyncBlockStore,
|
|
159
|
-
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus
|
|
158
|
+
bodiedSyncBlockDeletionStatus: bodiedSyncBlockDeletionStatus,
|
|
159
|
+
retryCreationPosMap: retryCreationPosMap
|
|
160
160
|
};
|
|
161
161
|
}
|
|
162
162
|
};
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var FLAG_ID = exports.FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
11
11
|
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
12
12
|
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
13
13
|
FLAG_ID["UNPUBLISHED_SYNC_BLOCK_PASTED"] = "unpublished-sync-block-pasted";
|
|
14
|
+
FLAG_ID["CANNOT_CREATE_SYNC_BLOCK"] = "cannot-create-sync-block";
|
|
14
15
|
return FLAG_ID;
|
|
15
16
|
}({});
|
|
16
17
|
var SYNCED_BLOCK_BUTTON_TEST_ID = exports.SYNCED_BLOCK_BUTTON_TEST_ID = {
|
|
@@ -19,7 +19,6 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
19
19
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
20
20
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
21
21
|
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
22
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
22
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
24
23
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
25
24
|
var _main = require("../pm-plugins/main");
|
|
@@ -44,7 +43,7 @@ var styles = {
|
|
|
44
43
|
spinner: "_1mou1wug _195g1wug"
|
|
45
44
|
};
|
|
46
45
|
var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
47
|
-
var _api$core2, _api$core4, _api$core6
|
|
46
|
+
var _api$core2, _api$core4, _api$core6;
|
|
48
47
|
var syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
49
48
|
api = _ref.api;
|
|
50
49
|
var _useState = (0, _react.useState)(false),
|
|
@@ -139,7 +138,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
139
138
|
}
|
|
140
139
|
}, [api === null || api === void 0 || (_api$core6 = api.core) === null || _api$core6 === void 0 ? void 0 : _api$core6.actions, bodiedSyncBlockDeletionStatus, isOpen]);
|
|
141
140
|
(0, _react.useEffect)(function () {
|
|
142
|
-
if (isOpen && syncBlockIds !== undefined
|
|
141
|
+
if (isOpen && syncBlockIds !== undefined) {
|
|
143
142
|
var fetchReferences = /*#__PURE__*/function () {
|
|
144
143
|
var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
145
144
|
var references, totalCount;
|
|
@@ -205,7 +204,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
205
204
|
onClose: handleClick(false),
|
|
206
205
|
testId: "sync-block-delete-confirmation",
|
|
207
206
|
height: 184
|
|
208
|
-
},
|
|
207
|
+
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, referenceCount === undefined ? /*#__PURE__*/_react.default.createElement(_compiled.Box, {
|
|
209
208
|
xcss: styles.spinner
|
|
210
209
|
}, /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
211
210
|
size: "large"
|
|
@@ -218,22 +217,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
218
217
|
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
219
218
|
deleteReason: deleteReason,
|
|
220
219
|
sourceCount: (syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) || 0
|
|
221
|
-
}))
|
|
222
|
-
hasCloseButton: true
|
|
223
|
-
}, /*#__PURE__*/_react.default.createElement(_modalDialog.ModalTitle, {
|
|
224
|
-
appearance: "warning"
|
|
225
|
-
}, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalTitleSingle))), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalBody, null, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalDescription, {
|
|
226
|
-
syncBlockCount: (_syncBlockIds$length = syncBlockIds === null || syncBlockIds === void 0 ? void 0 : syncBlockIds.length) !== null && _syncBlockIds$length !== void 0 ? _syncBlockIds$length : 1
|
|
227
|
-
}))), /*#__PURE__*/_react.default.createElement(_modalDialog.ModalFooter, null, /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
228
|
-
appearance: "subtle",
|
|
229
|
-
onClick: handleClick(false)
|
|
230
|
-
}, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalCancelButton)), /*#__PURE__*/_react.default.createElement(_new.default, {
|
|
231
|
-
appearance: "warning",
|
|
232
|
-
onClick: handleClick(true),
|
|
233
|
-
autoFocus: true,
|
|
234
|
-
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
235
|
-
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
236
|
-
}, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalDeleteButton))))));
|
|
220
|
+
}))));
|
|
237
221
|
};
|
|
238
222
|
var ModalContent = function ModalContent(_ref7) {
|
|
239
223
|
var content = _ref7.content,
|
package/dist/cjs/ui/Flag.js
CHANGED
|
@@ -20,7 +20,7 @@ var _types = require("../types");
|
|
|
20
20
|
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); }
|
|
21
21
|
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; }
|
|
22
22
|
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; }
|
|
23
|
-
var flagMap = (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, {
|
|
23
|
+
var flagMap = (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
24
|
title: _messages.syncBlockMessages.failToDeleteTitle,
|
|
25
25
|
description: _messages.syncBlockMessages.failToDeleteWhenOfflineDescription,
|
|
26
26
|
type: 'error'
|
|
@@ -43,6 +43,10 @@ var flagMap = (0, _defineProperty2.default)((0, _defineProperty2.default)((0, _d
|
|
|
43
43
|
title: _messages.syncBlockMessages.unpublishedSyncBlockPastedTitle,
|
|
44
44
|
description: _messages.syncBlockMessages.unpublishedSyncBlockPastedDescription,
|
|
45
45
|
type: 'info'
|
|
46
|
+
}), _types.FLAG_ID.CANNOT_CREATE_SYNC_BLOCK, {
|
|
47
|
+
title: _messages.syncBlockMessages.cannotCreateSyncBlockTitle,
|
|
48
|
+
description: _messages.syncBlockMessages.CannotCreateSyncBlockDescription,
|
|
49
|
+
type: 'error'
|
|
46
50
|
});
|
|
47
51
|
var Flag = exports.Flag = function Flag(_ref) {
|
|
48
52
|
var api = _ref.api;
|
|
@@ -12,7 +12,6 @@ var _reactIntlNext = require("react-intl-next");
|
|
|
12
12
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
13
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
14
14
|
var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
|
|
15
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
16
15
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
17
16
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
18
17
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
@@ -32,17 +31,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
32
31
|
tooltipContent = _useState2[0],
|
|
33
32
|
setTooltipContent = _useState2[1];
|
|
34
33
|
var tooltipMessage = formatMessage(_messages.syncBlockMessages.defaultSyncBlockTooltip);
|
|
35
|
-
if (
|
|
36
|
-
tooltipMessage = formatMessage(_messages.syncBlockMessages.sourceSyncBlockTooltip);
|
|
37
|
-
} else if (title) {
|
|
34
|
+
if (title) {
|
|
38
35
|
tooltipMessage = formatMessage(_messages.syncBlockMessages.referenceSyncBlockTooltip, {
|
|
39
36
|
title: title
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
var updateTooltipContent = (0, _react.useCallback)(function () {
|
|
43
|
-
if (!(0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding')) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
40
|
var tooltipContent = tooltipMessage;
|
|
47
41
|
if (contentUpdatedAt) {
|
|
48
42
|
var elapsedTime = (0, _time.formatElapsedTime)(contentUpdatedAt, intl);
|
|
@@ -62,7 +56,7 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
62
56
|
}, [contentUpdatedAt, formatMessage, intl, tooltipMessage]);
|
|
63
57
|
var ariaDescribedById = "sync-block-label-description-".concat(localId);
|
|
64
58
|
var getLabelContent = (0, _react.useMemo)(function () {
|
|
65
|
-
if (isUnsyncedBlock
|
|
59
|
+
if (isUnsyncedBlock) {
|
|
66
60
|
return /*#__PURE__*/_react.default.createElement(_compiled.Text, {
|
|
67
61
|
size: "small",
|
|
68
62
|
color: "color.text.subtle"
|
|
@@ -91,12 +85,12 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
91
85
|
size: "small",
|
|
92
86
|
label: ""
|
|
93
87
|
}), getLabelContent);
|
|
94
|
-
if (
|
|
88
|
+
if (isSource || isUnsyncedBlock) {
|
|
95
89
|
return label;
|
|
96
90
|
}
|
|
97
91
|
return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
|
|
98
92
|
position: "top",
|
|
99
|
-
content:
|
|
93
|
+
content: tooltipContent
|
|
100
94
|
// workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
|
|
101
95
|
// this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
|
|
102
96
|
// tooltip content is available for screen readers in visually hidden content after the label
|
|
@@ -7,13 +7,12 @@ exports.SyncBlockRefresher = exports.SYNC_BLOCK_FETCH_INTERVAL = void 0;
|
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
9
9
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
10
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
10
|
var SYNC_BLOCK_FETCH_INTERVAL = exports.SYNC_BLOCK_FETCH_INTERVAL = 3000;
|
|
12
11
|
|
|
13
12
|
// Component that manages synced block data synchronization.
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
13
|
+
// Component that manages synced block data synchronization.
|
|
14
|
+
// Uses provider-based GraphQL subscriptions for updates when online.
|
|
15
|
+
// Falls back to polling at regular intervals when offline.
|
|
17
16
|
var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
18
17
|
var syncBlockStoreManager = _ref.syncBlockStoreManager,
|
|
19
18
|
api = _ref.api;
|
|
@@ -24,14 +23,13 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
|
|
|
24
23
|
};
|
|
25
24
|
}),
|
|
26
25
|
mode = _useSharedPluginState.mode;
|
|
27
|
-
var featureFlagEnabled = (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding');
|
|
28
26
|
var isOnline = !(0, _editorPluginConnectivity.isOfflineMode)(mode);
|
|
29
27
|
(0, _react.useEffect)(function () {
|
|
30
|
-
var useRealTimeSubscriptions =
|
|
28
|
+
var useRealTimeSubscriptions = isOnline;
|
|
31
29
|
syncBlockStoreManager.referenceManager.setRealTimeSubscriptionsEnabled(useRealTimeSubscriptions);
|
|
32
|
-
}, [syncBlockStoreManager,
|
|
30
|
+
}, [syncBlockStoreManager, isOnline]);
|
|
33
31
|
(0, _react.useEffect)(function () {
|
|
34
|
-
var useRealTimeSubscriptions =
|
|
32
|
+
var useRealTimeSubscriptions = isOnline;
|
|
35
33
|
if (useRealTimeSubscriptions) {
|
|
36
34
|
return;
|
|
37
35
|
}
|
|
@@ -50,6 +48,6 @@ var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefreshe
|
|
|
50
48
|
return function () {
|
|
51
49
|
window.clearInterval(interval);
|
|
52
50
|
};
|
|
53
|
-
}, [syncBlockStoreManager, isOnline
|
|
51
|
+
}, [syncBlockStoreManager, isOnline]);
|
|
54
52
|
return null;
|
|
55
53
|
};
|
|
@@ -32,6 +32,9 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
32
32
|
if (!syncBlockObject) {
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
+
if (syncBlockStore.sourceManager.isPendingCreation(syncBlockObject.node.attrs.resourceId) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
35
38
|
var syncBlockInstance = syncBlockStore.referenceManager.getFromCache(syncBlockObject.node.attrs.resourceId);
|
|
36
39
|
var isUnsyncedBlock = (syncBlockInstance === null || syncBlockInstance === void 0 || (_syncBlockInstance$er = syncBlockInstance.error) === null || _syncBlockInstance$er === void 0 ? void 0 : _syncBlockInstance$er.type) === _editorSyncedBlockProvider.SyncBlockError.NotFound;
|
|
37
40
|
var isErroredBlock = syncBlockInstance === null || syncBlockInstance === void 0 ? void 0 : syncBlockInstance.error;
|
|
@@ -58,11 +61,11 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
58
61
|
title: formatMessage(_messages.default.delete),
|
|
59
62
|
onClick: (0, _editorCommands.removeSyncedBlock)(api),
|
|
60
63
|
icon: _delete.default,
|
|
61
|
-
testId:
|
|
62
|
-
}, hoverDecorationProps(nodeType,
|
|
64
|
+
testId: _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete
|
|
65
|
+
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
63
66
|
items.push(deleteButton);
|
|
64
67
|
} else {
|
|
65
|
-
if (!isErroredBlock
|
|
68
|
+
if (!isErroredBlock) {
|
|
66
69
|
var syncedLocation = {
|
|
67
70
|
type: 'custom',
|
|
68
71
|
fallback: [],
|
|
@@ -30,23 +30,23 @@ export const createSyncedBlock = ({
|
|
|
30
30
|
const paragraphNode = paragraph.createAndFill({});
|
|
31
31
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, paragraphNode ? [paragraphNode] : []);
|
|
32
32
|
if (!newBodiedSyncBlockNode) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
}
|
|
33
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
|
|
34
|
+
action: ACTION.ERROR,
|
|
35
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
36
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
37
|
+
attributes: {
|
|
38
|
+
error: 'Create and fill for empty content failed'
|
|
39
|
+
},
|
|
40
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
41
|
+
});
|
|
44
42
|
return false;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
// Save the new node with empty content to backend
|
|
48
46
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
49
|
-
|
|
47
|
+
if (!fg('platform_synced_block_patch_1')) {
|
|
48
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs, () => {});
|
|
49
|
+
}
|
|
50
50
|
if (typeAheadInsert) {
|
|
51
51
|
tr = typeAheadInsert(newBodiedSyncBlockNode);
|
|
52
52
|
} else {
|
|
@@ -55,47 +55,43 @@ export const createSyncedBlock = ({
|
|
|
55
55
|
} else {
|
|
56
56
|
const conversionInfo = canBeConvertedToSyncBlock(tr.selection);
|
|
57
57
|
if (!conversionInfo) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
}
|
|
58
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
|
|
59
|
+
action: ACTION.ERROR,
|
|
60
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
61
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
62
|
+
attributes: {
|
|
63
|
+
error: 'Content cannot be converted to sync block'
|
|
64
|
+
},
|
|
65
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
66
|
+
});
|
|
69
67
|
return false;
|
|
70
68
|
}
|
|
71
69
|
const attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
72
70
|
const newBodiedSyncBlockNode = bodiedSyncBlock.createAndFill(attrs, conversionInfo.contentToInclude);
|
|
73
71
|
if (!newBodiedSyncBlockNode) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
});
|
|
84
|
-
}
|
|
72
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 ? void 0 : fireAnalyticsEvent({
|
|
73
|
+
action: ACTION.ERROR,
|
|
74
|
+
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
75
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
76
|
+
attributes: {
|
|
77
|
+
error: 'Create and fill for content failed'
|
|
78
|
+
},
|
|
79
|
+
eventType: EVENT_TYPE.OPERATIONAL
|
|
80
|
+
});
|
|
85
81
|
return false;
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
// Save the new node with empty content to backend
|
|
89
85
|
// This is so that the node can be copied and referenced without the source being saved/published
|
|
90
|
-
|
|
86
|
+
if (!fg('platform_synced_block_patch_1')) {
|
|
87
|
+
// Moved to appendTransaction
|
|
88
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs, () => {}, newBodiedSyncBlockNode);
|
|
89
|
+
}
|
|
91
90
|
tr.replaceWith(conversionInfo.from, conversionInfo.to, newBodiedSyncBlockNode).scrollIntoView();
|
|
92
91
|
|
|
93
92
|
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
94
93
|
tr.setSelection(TextSelection.create(tr.doc, conversionInfo.from));
|
|
95
94
|
}
|
|
96
|
-
|
|
97
|
-
// This transaction will be intercepted in filterTransaction and dispatched when saving to backend succeeds
|
|
98
|
-
// see filterTransaction for more details
|
|
99
95
|
return tr;
|
|
100
96
|
};
|
|
101
97
|
export const copySyncedBlockReferenceToClipboardEditorCommand = (syncBlockStore, inputMethod, api) => ({
|
|
@@ -5,7 +5,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
5
5
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
6
6
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
7
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
8
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
10
9
|
const toDOM = () => ['div', {
|
|
11
10
|
class: BodiedSyncBlockSharedCssClassName.content,
|
|
@@ -68,7 +67,7 @@ class BodiedSyncBlock extends ReactNodeView {
|
|
|
68
67
|
if (!syncBlockStore) {
|
|
69
68
|
return null;
|
|
70
69
|
}
|
|
71
|
-
return
|
|
70
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
72
71
|
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
73
72
|
dispatchAnalyticsEvent: (_this$api6 = this.api) === null || _this$api6 === void 0 ? void 0 : (_this$api6$analytics = _this$api6.analytics) === null || _this$api6$analytics === void 0 ? void 0 : _this$api6$analytics.actions.fireAnalyticsEvent,
|
|
74
73
|
fallbackComponent: null
|
|
@@ -76,11 +75,7 @@ class BodiedSyncBlock extends ReactNodeView {
|
|
|
76
75
|
ref: forwardRef,
|
|
77
76
|
syncBlockStore: syncBlockStore,
|
|
78
77
|
node: this.node
|
|
79
|
-
}))
|
|
80
|
-
ref: forwardRef,
|
|
81
|
-
syncBlockStore: syncBlockStore,
|
|
82
|
-
node: this.node
|
|
83
|
-
});
|
|
78
|
+
}));
|
|
84
79
|
}
|
|
85
80
|
getContentDOM() {
|
|
86
81
|
const {
|