@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 5.3.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`ab4e4e442ad49`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/ab4e4e442ad49) -
|
|
8
|
+
[ux] [EDITOR-3694] Add loading state to bodiedSyncBlock for when saving new block to BE
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 5.3.13
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`7ba3979b92b42`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7ba3979b92b42) -
|
|
16
|
+
Remove platform_synced_block_dogfooding feature gate
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 5.3.12
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -30,23 +30,23 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
30
30
|
var paragraphNode = paragraph.createAndFill({});
|
|
31
31
|
var 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 || fireAnalyticsEvent({
|
|
34
|
+
action: _analytics.ACTION.ERROR,
|
|
35
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
36
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
37
|
+
attributes: {
|
|
38
|
+
error: 'Create and fill for empty content failed'
|
|
39
|
+
},
|
|
40
|
+
eventType: _analytics.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 (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
48
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs, function () {});
|
|
49
|
+
}
|
|
50
50
|
if (typeAheadInsert) {
|
|
51
51
|
tr = typeAheadInsert(newBodiedSyncBlockNode);
|
|
52
52
|
} else {
|
|
@@ -55,47 +55,43 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
|
|
|
55
55
|
} else {
|
|
56
56
|
var conversionInfo = (0, _utils2.canBeConvertedToSyncBlock)(tr.selection);
|
|
57
57
|
if (!conversionInfo) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
}
|
|
58
|
+
fireAnalyticsEvent === null || fireAnalyticsEvent === void 0 || fireAnalyticsEvent({
|
|
59
|
+
action: _analytics.ACTION.ERROR,
|
|
60
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
61
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
62
|
+
attributes: {
|
|
63
|
+
error: 'Content cannot be converted to sync block'
|
|
64
|
+
},
|
|
65
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
66
|
+
});
|
|
69
67
|
return false;
|
|
70
68
|
}
|
|
71
69
|
var _attrs = syncBlockStore.sourceManager.generateBodiedSyncBlockAttrs();
|
|
72
70
|
var _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 || fireAnalyticsEvent({
|
|
73
|
+
action: _analytics.ACTION.ERROR,
|
|
74
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
75
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
76
|
+
attributes: {
|
|
77
|
+
error: 'Create and fill for content failed'
|
|
78
|
+
},
|
|
79
|
+
eventType: _analytics.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 (!(0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
87
|
+
// Moved to appendTransaction
|
|
88
|
+
syncBlockStore.sourceManager.createBodiedSyncBlockNode(_attrs, function () {}, _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(_state.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
|
var copySyncedBlockReferenceToClipboardEditorCommand = exports.copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, inputMethod, api) {
|
|
@@ -17,7 +17,6 @@ var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/rea
|
|
|
17
17
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
18
18
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
19
19
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
20
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
20
|
var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
|
|
22
21
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
23
22
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -97,7 +96,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
97
96
|
if (!syncBlockStore) {
|
|
98
97
|
return null;
|
|
99
98
|
}
|
|
100
|
-
return
|
|
99
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
101
100
|
component: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
102
101
|
dispatchAnalyticsEvent: (_this$api6 = this.api) === null || _this$api6 === void 0 || (_this$api6 = _this$api6.analytics) === null || _this$api6 === void 0 ? void 0 : _this$api6.actions.fireAnalyticsEvent,
|
|
103
102
|
fallbackComponent: null
|
|
@@ -105,11 +104,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
105
104
|
ref: forwardRef,
|
|
106
105
|
syncBlockStore: syncBlockStore,
|
|
107
106
|
node: this.node
|
|
108
|
-
}))
|
|
109
|
-
ref: forwardRef,
|
|
110
|
-
syncBlockStore: syncBlockStore,
|
|
111
|
-
node: this.node
|
|
112
|
-
});
|
|
107
|
+
}));
|
|
113
108
|
}
|
|
114
109
|
}, {
|
|
115
110
|
key: "getContentDOM",
|
|
@@ -17,7 +17,6 @@ var _errorBoundary = require("@atlaskit/editor-common/error-boundary");
|
|
|
17
17
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
18
18
|
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
19
19
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
20
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
20
|
var _editorCommands = require("../editor-commands");
|
|
22
21
|
var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
|
|
23
22
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
@@ -49,8 +48,7 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
49
48
|
_this$api,
|
|
50
49
|
_this$api2,
|
|
51
50
|
_this2 = this,
|
|
52
|
-
_this$options2
|
|
53
|
-
_this$options3;
|
|
51
|
+
_this$options2;
|
|
54
52
|
var getPos = _ref.getPos;
|
|
55
53
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
56
54
|
return null;
|
|
@@ -61,14 +59,13 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
61
59
|
if (!resourceId || !localId) {
|
|
62
60
|
return null;
|
|
63
61
|
}
|
|
64
|
-
var
|
|
65
|
-
var syncBlockStore = (_this$api$syncedBlock = (_this$api = this.api) === null || _this$api === void 0 || (_this$api = _this$api.syncedBlock) === null || _this$api === void 0 || (_this$api = _this$api.sharedState.currentState()) === null || _this$api === void 0 ? void 0 : _this$api.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : initialSyncBlockStore;
|
|
62
|
+
var syncBlockStore = (_this$api$syncedBlock = (_this$api = this.api) === null || _this$api === void 0 || (_this$api = _this$api.syncedBlock) === null || _this$api === void 0 || (_this$api = _this$api.sharedState.currentState()) === null || _this$api === void 0 ? void 0 : _this$api.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
|
|
66
63
|
if (!syncBlockStore) {
|
|
67
64
|
return null;
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
// get document node from data provider
|
|
71
|
-
return
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement(_errorBoundary.ErrorBoundary, {
|
|
72
69
|
component: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
73
70
|
dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.analytics) === null || _this$api2 === void 0 ? void 0 : _this$api2.actions.fireAnalyticsEvent,
|
|
74
71
|
fallbackComponent: null
|
|
@@ -93,18 +90,7 @@ var SyncBlock = exports.SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
93
90
|
return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
|
|
94
91
|
},
|
|
95
92
|
api: this.api
|
|
96
|
-
})))
|
|
97
|
-
localId: this.node.attrs.localId,
|
|
98
|
-
syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
|
|
99
|
-
useFetchSyncBlockTitle: function useFetchSyncBlockTitle() {
|
|
100
|
-
return (0, _editorSyncedBlockProvider.useFetchSyncBlockTitle)(syncBlockStore, _this2.node);
|
|
101
|
-
},
|
|
102
|
-
useFetchSyncBlockData: function useFetchSyncBlockData() {
|
|
103
|
-
var _this2$api2;
|
|
104
|
-
return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(syncBlockStore, resourceId, localId, (_this2$api2 = _this2.api) === null || _this2$api2 === void 0 || (_this2$api2 = _this2$api2.analytics) === null || _this2$api2 === void 0 || (_this2$api2 = _this2$api2.actions) === null || _this2$api2 === void 0 ? void 0 : _this2$api2.fireAnalyticsEvent);
|
|
105
|
-
},
|
|
106
|
-
api: this.api
|
|
107
|
-
});
|
|
93
|
+
})));
|
|
108
94
|
}
|
|
109
95
|
}, {
|
|
110
96
|
key: "destroy",
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.syncedBlockPluginKey = exports.createPlugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
12
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
@@ -17,20 +18,53 @@ var _view = require("@atlaskit/editor-prosemirror/view");
|
|
|
17
18
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
18
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
20
|
var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
|
|
20
|
-
var _lazySyncedBlock = require("../nodeviews/lazySyncedBlock");
|
|
21
21
|
var _syncedBlock = require("../nodeviews/syncedBlock");
|
|
22
22
|
var _types = require("../types");
|
|
23
|
+
var _handleBodiedSyncBlockCreation = require("./utils/handle-bodied-sync-block-creation");
|
|
23
24
|
var _handleBodiedSyncBlockRemoval = require("./utils/handle-bodied-sync-block-removal");
|
|
24
25
|
var _ignoreDomEvent = require("./utils/ignore-dom-event");
|
|
25
26
|
var _selectionDecorations = require("./utils/selection-decorations");
|
|
26
27
|
var _trackSyncBlocks6 = require("./utils/track-sync-blocks");
|
|
27
28
|
var _utils2 = require("./utils/utils");
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
28
31
|
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; } } }; }
|
|
29
32
|
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; } }
|
|
30
33
|
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; }
|
|
31
|
-
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; }
|
|
32
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
33
34
|
var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
|
|
35
|
+
var mapRetryCreationPosMap = function mapRetryCreationPosMap(oldMap, newRetryCreationPos, mapPos) {
|
|
36
|
+
var resourceId = newRetryCreationPos === null || newRetryCreationPos === void 0 ? void 0 : newRetryCreationPos.resourceId;
|
|
37
|
+
var newMap = new Map(oldMap);
|
|
38
|
+
if (resourceId) {
|
|
39
|
+
var pos = newRetryCreationPos.pos;
|
|
40
|
+
if (!pos) {
|
|
41
|
+
newMap.delete(resourceId);
|
|
42
|
+
} else {
|
|
43
|
+
newMap.set(resourceId, pos);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (newMap.size === 0) {
|
|
47
|
+
return newMap;
|
|
48
|
+
}
|
|
49
|
+
var _iterator = _createForOfIteratorHelper(newMap.entries()),
|
|
50
|
+
_step;
|
|
51
|
+
try {
|
|
52
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
53
|
+
var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
|
|
54
|
+
id = _step$value[0],
|
|
55
|
+
_pos = _step$value[1];
|
|
56
|
+
newMap.set(id, {
|
|
57
|
+
from: mapPos(_pos.from),
|
|
58
|
+
to: mapPos(_pos.to)
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
} catch (err) {
|
|
62
|
+
_iterator.e(err);
|
|
63
|
+
} finally {
|
|
64
|
+
_iterator.f();
|
|
65
|
+
}
|
|
66
|
+
return newMap;
|
|
67
|
+
};
|
|
34
68
|
var showCopiedFlag = function showCopiedFlag(api) {
|
|
35
69
|
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
36
70
|
setTimeout(function () {
|
|
@@ -64,7 +98,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
64
98
|
var unpublishedFlagShown = new Set();
|
|
65
99
|
|
|
66
100
|
// Set up callback to detect unpublished sync blocks when they're fetched
|
|
67
|
-
|
|
101
|
+
syncBlockStore.referenceManager.setOnUnpublishedSyncBlockDetected(function (resourceId) {
|
|
68
102
|
// Only show the flag once per sync block
|
|
69
103
|
if (!unpublishedFlagShown.has(resourceId)) {
|
|
70
104
|
unpublishedFlagShown.add(resourceId);
|
|
@@ -92,7 +126,8 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
92
126
|
return {
|
|
93
127
|
selectionDecorationSet: (0, _selectionDecorations.calculateDecorations)(instance.doc, instance.selection, instance.schema),
|
|
94
128
|
activeFlag: false,
|
|
95
|
-
syncBlockStore: syncBlockStore
|
|
129
|
+
syncBlockStore: syncBlockStore,
|
|
130
|
+
retryCreationPosMap: new Map()
|
|
96
131
|
};
|
|
97
132
|
},
|
|
98
133
|
apply: function apply(tr, currentPluginState, oldEditorState) {
|
|
@@ -100,22 +135,29 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
100
135
|
var meta = tr.getMeta(syncedBlockPluginKey);
|
|
101
136
|
var activeFlag = currentPluginState.activeFlag,
|
|
102
137
|
selectionDecorationSet = currentPluginState.selectionDecorationSet,
|
|
103
|
-
bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus
|
|
138
|
+
bodiedSyncBlockDeletionStatus = currentPluginState.bodiedSyncBlockDeletionStatus,
|
|
139
|
+
retryCreationPosMap = currentPluginState.retryCreationPosMap;
|
|
104
140
|
var newDecorationSet = selectionDecorationSet.map(tr.mapping, tr.doc);
|
|
105
141
|
if (!tr.selection.eq(oldEditorState.selection)) {
|
|
106
142
|
newDecorationSet = (0, _selectionDecorations.calculateDecorations)(tr.doc, tr.selection, tr.doc.type.schema);
|
|
107
143
|
}
|
|
144
|
+
var newRetryCreationPosMap = retryCreationPosMap;
|
|
145
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
146
|
+
var newPosEntry = meta === null || meta === void 0 ? void 0 : meta.retryCreationPos;
|
|
147
|
+
newRetryCreationPosMap = mapRetryCreationPosMap(retryCreationPosMap, newPosEntry, tr.mapping.map.bind(tr.mapping));
|
|
148
|
+
}
|
|
108
149
|
return {
|
|
109
150
|
activeFlag: (_meta$activeFlag = meta === null || meta === void 0 ? void 0 : meta.activeFlag) !== null && _meta$activeFlag !== void 0 ? _meta$activeFlag : activeFlag,
|
|
110
151
|
selectionDecorationSet: newDecorationSet,
|
|
111
152
|
syncBlockStore: syncBlockStore,
|
|
153
|
+
retryCreationPosMap: newRetryCreationPosMap,
|
|
112
154
|
bodiedSyncBlockDeletionStatus: (_meta$bodiedSyncBlock = meta === null || meta === void 0 ? void 0 : meta.bodiedSyncBlockDeletionStatus) !== null && _meta$bodiedSyncBlock !== void 0 ? _meta$bodiedSyncBlock : bodiedSyncBlockDeletionStatus
|
|
113
155
|
};
|
|
114
156
|
}
|
|
115
157
|
},
|
|
116
158
|
props: {
|
|
117
159
|
nodeViews: {
|
|
118
|
-
syncBlock:
|
|
160
|
+
syncBlock: function syncBlock(node, view, getPos, _decorations) {
|
|
119
161
|
// To support SSR, pass `syncBlockStore` here
|
|
120
162
|
// and do not use lazy loading.
|
|
121
163
|
// We cannot start rendering and then load `syncBlockStore` asynchronously,
|
|
@@ -130,11 +172,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
130
172
|
eventDispatcher: pmPluginFactoryParams.eventDispatcher,
|
|
131
173
|
syncBlockStore: syncBlockStore
|
|
132
174
|
}).init();
|
|
133
|
-
}
|
|
134
|
-
options: options,
|
|
135
|
-
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
136
|
-
api: api
|
|
137
|
-
}),
|
|
175
|
+
},
|
|
138
176
|
bodiedSyncBlock: (0, _bodiedLazySyncedBlock.lazyBodiedSyncBlockView)({
|
|
139
177
|
pluginOptions: options,
|
|
140
178
|
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
@@ -142,13 +180,16 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
142
180
|
})
|
|
143
181
|
},
|
|
144
182
|
decorations: function decorations(state) {
|
|
145
|
-
var
|
|
146
|
-
var
|
|
183
|
+
var _currentPluginState$s, _api$connectivity, _api$editorViewMode;
|
|
184
|
+
var currentPluginState = syncedBlockPluginKey.getState(state);
|
|
185
|
+
var selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : _view.DecorationSet.empty;
|
|
186
|
+
var syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
|
|
147
187
|
var doc = state.doc;
|
|
148
188
|
var isOffline = (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);
|
|
149
189
|
var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
|
|
150
190
|
var offlineDecorations = [];
|
|
151
191
|
var viewModeDecorations = [];
|
|
192
|
+
var loadingDecorations = [];
|
|
152
193
|
state.doc.descendants(function (node, pos) {
|
|
153
194
|
if (node.type.name === 'bodiedSyncBlock' && isOffline) {
|
|
154
195
|
offlineDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
@@ -160,8 +201,13 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
160
201
|
class: _syncBlock.SyncBlockStateCssClassName.viewModeClassName
|
|
161
202
|
}));
|
|
162
203
|
}
|
|
204
|
+
if (node.type.name === 'bodiedSyncBlock' && syncBlockStore.sourceManager.isPendingCreation(node.attrs.resourceId) && (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
205
|
+
loadingDecorations.push(_view.Decoration.node(pos, pos + node.nodeSize, {
|
|
206
|
+
class: _syncBlock.SyncBlockStateCssClassName.creationLoadingClassName
|
|
207
|
+
}));
|
|
208
|
+
}
|
|
163
209
|
});
|
|
164
|
-
return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations);
|
|
210
|
+
return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations);
|
|
165
211
|
},
|
|
166
212
|
handleClickOn: (0, _selection.createSelectionClickHandler)(['bodiedSyncBlock'], function (target) {
|
|
167
213
|
return !!target.closest(".".concat(_syncBlock.BodiedSyncBlockSharedCssClassName.prefix));
|
|
@@ -222,9 +268,15 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
222
268
|
var _api$connectivity2;
|
|
223
269
|
var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
|
|
224
270
|
var isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
|
|
271
|
+
var hasNoPendingRequest = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? false :
|
|
272
|
+
// requireConfirmationBeforeDelete is always true, so this evaluates to false and hence redundant
|
|
273
|
+
!(syncBlockStore !== null && syncBlockStore !== void 0 && syncBlockStore.sourceManager.requireConfirmationBeforeDelete()) && !syncBlockStore.sourceManager.hasPendingCreation();
|
|
274
|
+
var isCommitsCreation = (0, _platformFeatureFlags.fg)('platform_synced_block_patch_1') ? false :
|
|
275
|
+
// For patch 1, we don't intercept the insert transaction, hence it's redundant
|
|
276
|
+
Boolean(tr.getMeta('isCommitSyncBlockCreation'));
|
|
225
277
|
|
|
226
278
|
// Track newly added reference sync blocks before processing the transaction
|
|
227
|
-
if (tr.docChanged && !tr.getMeta('isRemote')
|
|
279
|
+
if (tr.docChanged && !tr.getMeta('isRemote')) {
|
|
228
280
|
var _trackSyncBlocks = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
229
281
|
return node.type.name === 'syncBlock';
|
|
230
282
|
}, tr, state),
|
|
@@ -242,50 +294,47 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
242
294
|
// or are from remote (collab) or already confirmed sync block deletion
|
|
243
295
|
// We only care about local changes that change the document
|
|
244
296
|
// and are not yet confirmed for sync block deletion
|
|
245
|
-
if (!tr.docChanged ||
|
|
297
|
+
if (!tr.docChanged || hasNoPendingRequest || Boolean(tr.getMeta('isRemote')) || isCommitsCreation || !isOffline && isConfirmedSyncBlockDeletion) {
|
|
246
298
|
return true;
|
|
247
299
|
}
|
|
248
300
|
var _trackSyncBlocks2 = (0, _trackSyncBlocks6.trackSyncBlocks)(syncBlockStore.sourceManager.isSourceBlock, tr, state),
|
|
249
301
|
bodiedSyncBlockRemoved = _trackSyncBlocks2.removed,
|
|
250
302
|
bodiedSyncBlockAdded = _trackSyncBlocks2.added;
|
|
251
303
|
if (!isOffline) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
269
|
-
});
|
|
304
|
+
var _trackSyncBlocks3 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
305
|
+
return node.type.name === 'syncBlock';
|
|
306
|
+
}, tr, state),
|
|
307
|
+
syncBlockRemoved = _trackSyncBlocks3.removed,
|
|
308
|
+
syncBlockAdded = _trackSyncBlocks3.added;
|
|
309
|
+
syncBlockRemoved.forEach(function (syncBlock) {
|
|
310
|
+
var _api$analytics;
|
|
311
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 || _api$analytics.fireAnalyticsEvent({
|
|
312
|
+
action: _analytics.ACTION.DELETED,
|
|
313
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
314
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
315
|
+
attributes: {
|
|
316
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
317
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
318
|
+
},
|
|
319
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
270
320
|
});
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
321
|
+
});
|
|
322
|
+
syncBlockAdded.forEach(function (syncBlock) {
|
|
323
|
+
var _api$analytics2;
|
|
324
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || (_api$analytics2 = _api$analytics2.actions) === null || _api$analytics2 === void 0 || _api$analytics2.fireAnalyticsEvent({
|
|
325
|
+
action: _analytics.ACTION.INSERTED,
|
|
326
|
+
actionSubject: _analytics.ACTION_SUBJECT.SYNCED_BLOCK,
|
|
327
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
328
|
+
attributes: {
|
|
329
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
330
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
331
|
+
},
|
|
332
|
+
eventType: _analytics.EVENT_TYPE.OPERATIONAL
|
|
283
333
|
});
|
|
284
|
-
}
|
|
285
|
-
;
|
|
334
|
+
});
|
|
286
335
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
287
336
|
confirmationTransactionRef.current = tr;
|
|
288
|
-
return (0, _handleBodiedSyncBlockRemoval.handleBodiedSyncBlockRemoval)(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef,
|
|
337
|
+
return (0, _handleBodiedSyncBlockRemoval.handleBodiedSyncBlockRemoval)(bodiedSyncBlockRemoved, syncBlockStore, api, confirmationTransactionRef, getDeleteReason(tr));
|
|
289
338
|
}
|
|
290
339
|
if (bodiedSyncBlockAdded.length > 0) {
|
|
291
340
|
if (Boolean(tr.getMeta(_utils.pmHistoryPluginKey))) {
|
|
@@ -294,18 +343,22 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
294
343
|
// After true is returned here and the node is created, we delete the node in the filterTransaction immediately, which cancels out the creation
|
|
295
344
|
return true;
|
|
296
345
|
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
346
|
+
if ((0, _platformFeatureFlags.fg)('platform_synced_block_patch_1')) {
|
|
347
|
+
(0, _handleBodiedSyncBlockCreation.handleBodiedSyncBlockCreation)(bodiedSyncBlockAdded, state, api);
|
|
348
|
+
return true;
|
|
349
|
+
} else {
|
|
350
|
+
// If there is bodiedSyncBlock node addition and it's waiting for the result of saving the node to backend (syncBlockStore.hasPendingCreation()),
|
|
351
|
+
// we need to intercept the transaction and save it in insert callback so that we only insert it to the document when backend call if backend call is successful
|
|
352
|
+
// The callback will be evoked by in SourceSyncBlockStoreManager.commitPendingCreation
|
|
353
|
+
syncBlockStore.sourceManager.registerCreationCallback(function () {
|
|
354
|
+
var _api$core;
|
|
355
|
+
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function () {
|
|
356
|
+
return tr.setMeta('isCommitSyncBlockCreation', true);
|
|
357
|
+
});
|
|
358
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
305
359
|
});
|
|
306
|
-
|
|
307
|
-
}
|
|
308
|
-
return false;
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
309
362
|
}
|
|
310
363
|
} else {
|
|
311
364
|
var _trackSyncBlocks4 = (0, _trackSyncBlocks6.trackSyncBlocks)(function (node) {
|
|
@@ -348,11 +401,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
348
401
|
confirmationTransactionRef.current = (0, _editorSyncedBlockProvider.rebaseTransaction)(confirmationTransactionRef.current, tr, newState);
|
|
349
402
|
}
|
|
350
403
|
});
|
|
351
|
-
var
|
|
352
|
-
|
|
404
|
+
var _iterator2 = _createForOfIteratorHelper(trs),
|
|
405
|
+
_step2;
|
|
353
406
|
try {
|
|
354
407
|
var _loop = function _loop() {
|
|
355
|
-
var tr =
|
|
408
|
+
var tr = _step2.value;
|
|
356
409
|
if (!tr.getMeta(_utils.pmHistoryPluginKey)) {
|
|
357
410
|
return 0; // continue
|
|
358
411
|
}
|
|
@@ -373,15 +426,15 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
373
426
|
}
|
|
374
427
|
},
|
|
375
428
|
_ret;
|
|
376
|
-
for (
|
|
429
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
377
430
|
_ret = _loop();
|
|
378
431
|
if (_ret === 0) continue;
|
|
379
432
|
if (_ret) return _ret.v;
|
|
380
433
|
}
|
|
381
434
|
} catch (err) {
|
|
382
|
-
|
|
435
|
+
_iterator2.e(err);
|
|
383
436
|
} finally {
|
|
384
|
-
|
|
437
|
+
_iterator2.f();
|
|
385
438
|
}
|
|
386
439
|
return null;
|
|
387
440
|
}
|