@atlaskit/editor-plugin-synced-block 5.1.9 → 5.1.11
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 +22 -0
- package/dist/cjs/editor-commands/index.js +2 -2
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +13 -2
- package/dist/cjs/nodeviews/syncedBlock.js +21 -2
- package/dist/cjs/pm-plugins/experience-tracking/create-reference-experience.js +26 -26
- package/dist/cjs/pm-plugins/experience-tracking/create-source-experience.js +14 -30
- package/dist/cjs/pm-plugins/experience-tracking/delete-reference-experience.js +175 -0
- package/dist/cjs/pm-plugins/experience-tracking/delete-source-experience.js +103 -0
- package/dist/cjs/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +30 -0
- package/dist/cjs/pm-plugins/experience-tracking/provider-only-experiences.js +128 -0
- package/dist/cjs/pm-plugins/utils/experience-tracking-utils.js +85 -0
- package/dist/cjs/types/index.js +5 -2
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +40 -8
- package/dist/cjs/ui/DeleteConfirmationModal.js +3 -1
- package/dist/cjs/ui/floating-toolbar.js +4 -2
- package/dist/es2019/editor-commands/index.js +2 -2
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +13 -2
- package/dist/es2019/nodeviews/syncedBlock.js +19 -4
- package/dist/es2019/pm-plugins/experience-tracking/create-reference-experience.js +27 -23
- package/dist/es2019/pm-plugins/experience-tracking/create-source-experience.js +14 -27
- package/dist/es2019/pm-plugins/experience-tracking/delete-reference-experience.js +181 -0
- package/dist/es2019/pm-plugins/experience-tracking/delete-source-experience.js +98 -0
- package/dist/es2019/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +24 -0
- package/dist/es2019/pm-plugins/experience-tracking/provider-only-experiences.js +127 -0
- package/dist/es2019/pm-plugins/utils/experience-tracking-utils.js +65 -0
- package/dist/es2019/types/index.js +4 -1
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +38 -3
- package/dist/es2019/ui/DeleteConfirmationModal.js +3 -1
- package/dist/es2019/ui/floating-toolbar.js +3 -1
- package/dist/esm/editor-commands/index.js +2 -2
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +13 -2
- package/dist/esm/nodeviews/syncedBlock.js +21 -2
- package/dist/esm/pm-plugins/experience-tracking/create-reference-experience.js +26 -25
- package/dist/esm/pm-plugins/experience-tracking/create-source-experience.js +14 -29
- package/dist/esm/pm-plugins/experience-tracking/delete-reference-experience.js +169 -0
- package/dist/esm/pm-plugins/experience-tracking/delete-source-experience.js +97 -0
- package/dist/esm/pm-plugins/experience-tracking/get-experience-tracking-plugins.js +30 -0
- package/dist/esm/pm-plugins/experience-tracking/provider-only-experiences.js +122 -0
- package/dist/esm/pm-plugins/utils/experience-tracking-utils.js +79 -0
- package/dist/esm/types/index.js +4 -1
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +40 -8
- package/dist/esm/ui/DeleteConfirmationModal.js +3 -1
- package/dist/esm/ui/floating-toolbar.js +4 -2
- package/dist/types/pm-plugins/experience-tracking/create-reference-experience.d.ts +2 -9
- package/dist/types/pm-plugins/experience-tracking/create-source-experience.d.ts +4 -15
- package/dist/types/pm-plugins/experience-tracking/delete-reference-experience.d.ts +13 -0
- package/dist/types/pm-plugins/experience-tracking/delete-source-experience.d.ts +12 -0
- package/dist/types/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +2 -13
- package/dist/types/pm-plugins/experience-tracking/provider-only-experiences.d.ts +3 -0
- package/dist/types/pm-plugins/utils/experience-tracking-utils.d.ts +9 -0
- package/dist/types/types/index.d.ts +15 -0
- package/dist/types-ts4.5/pm-plugins/experience-tracking/create-reference-experience.d.ts +2 -9
- package/dist/types-ts4.5/pm-plugins/experience-tracking/create-source-experience.d.ts +4 -15
- package/dist/types-ts4.5/pm-plugins/experience-tracking/delete-reference-experience.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/experience-tracking/delete-source-experience.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/experience-tracking/get-experience-tracking-plugins.d.ts +2 -13
- package/dist/types-ts4.5/pm-plugins/experience-tracking/provider-only-experiences.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/utils/experience-tracking-utils.d.ts +9 -0
- package/dist/types-ts4.5/types/index.d.ts +15 -0
- package/package.json +5 -5
- package/build/tsconfig.json +0 -22
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getProviderOnlyExperiencesPlugin = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _experiences = require("@atlaskit/editor-common/experiences");
|
|
9
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
11
|
+
var _types = require("../../types");
|
|
12
|
+
var pluginKey = new _state.PluginKey('providerOnlySyncBlockExperiences');
|
|
13
|
+
var getProviderOnlyExperiencesPlugin = exports.getProviderOnlyExperiencesPlugin = function getProviderOnlyExperiencesPlugin(_ref) {
|
|
14
|
+
var refs = _ref.refs,
|
|
15
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
16
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
17
|
+
var saveSourceExperience = getSaveSourceExperience({
|
|
18
|
+
refs: refs,
|
|
19
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
20
|
+
});
|
|
21
|
+
syncBlockStore.sourceManager.setSaveExperience(saveSourceExperience);
|
|
22
|
+
var saveReferenceExperience = getSaveReferenceExperience({
|
|
23
|
+
refs: refs,
|
|
24
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
25
|
+
});
|
|
26
|
+
var fetchExperience = getFetchExperience({
|
|
27
|
+
refs: refs,
|
|
28
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
29
|
+
});
|
|
30
|
+
var fetchSourceInfoExperience = getFetchSourceInfoExperience({
|
|
31
|
+
refs: refs,
|
|
32
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
33
|
+
});
|
|
34
|
+
syncBlockStore.referenceManager.setExperiences(fetchExperience, fetchSourceInfoExperience, saveReferenceExperience);
|
|
35
|
+
return new _safePlugin.SafePlugin({
|
|
36
|
+
key: pluginKey,
|
|
37
|
+
view: function view() {
|
|
38
|
+
return {
|
|
39
|
+
destroy: function destroy() {
|
|
40
|
+
saveSourceExperience.abort({
|
|
41
|
+
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
42
|
+
});
|
|
43
|
+
saveReferenceExperience.abort({
|
|
44
|
+
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
45
|
+
});
|
|
46
|
+
fetchExperience.abort({
|
|
47
|
+
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
48
|
+
});
|
|
49
|
+
fetchSourceInfoExperience.abort({
|
|
50
|
+
reason: _types.EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This experience tracks when a source sync block is saved to the BE.
|
|
60
|
+
*
|
|
61
|
+
* Start: When the flush source sync block function is called.
|
|
62
|
+
* Success: When the sync block save is successful within 1500ms of start.
|
|
63
|
+
* Failure: When 1500ms passes without the sync block being successfully saved
|
|
64
|
+
*/
|
|
65
|
+
var getSaveSourceExperience = function getSaveSourceExperience(_ref2) {
|
|
66
|
+
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
|
|
67
|
+
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
68
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_UPDATE,
|
|
69
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
70
|
+
checks: [new _experiences.ExperienceCheckTimeout({
|
|
71
|
+
durationMs: 1500
|
|
72
|
+
})]
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This experience tracks when a reference sync block is saved to the BE.
|
|
78
|
+
*
|
|
79
|
+
* Start: When the flush sync block function is called.
|
|
80
|
+
* Success: When the sync block save is successful within 1500ms of start.
|
|
81
|
+
* Failure: When 1500ms passes without the sync block being successfully saved
|
|
82
|
+
*/
|
|
83
|
+
var getSaveReferenceExperience = function getSaveReferenceExperience(_ref3) {
|
|
84
|
+
var dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
85
|
+
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
86
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_UPDATE,
|
|
87
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
88
|
+
checks: [new _experiences.ExperienceCheckTimeout({
|
|
89
|
+
durationMs: 1500
|
|
90
|
+
})]
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* This experience tracks when a reference sync block data is fetched from the BE.
|
|
96
|
+
*
|
|
97
|
+
* Start: When the fetchNodesData function is called.
|
|
98
|
+
* Success: When the fetching the data is successful within 1500ms of start.
|
|
99
|
+
* Failure: When 1500ms passes without the data being successfully fetched, or the fetch fails
|
|
100
|
+
*/
|
|
101
|
+
var getFetchExperience = function getFetchExperience(_ref4) {
|
|
102
|
+
var dispatchAnalyticsEvent = _ref4.dispatchAnalyticsEvent;
|
|
103
|
+
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
104
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_FETCH,
|
|
105
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
106
|
+
checks: [new _experiences.ExperienceCheckTimeout({
|
|
107
|
+
durationMs: 1500
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* This experience tracks when a reference sync block source info data (title, url) is fetched from the BE.
|
|
114
|
+
*
|
|
115
|
+
* Start: When the fetchSourceInfo function is called.
|
|
116
|
+
* Success: When the fetching the data is successful within 2500ms of start.
|
|
117
|
+
* Failure: When 2500ms passes without the data being successfully fetched, or the fetch fails
|
|
118
|
+
*/
|
|
119
|
+
var getFetchSourceInfoExperience = function getFetchSourceInfoExperience(_ref5) {
|
|
120
|
+
var dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
121
|
+
return new _experiences.Experience(_analytics.ACTION_SUBJECT.SYNCED_BLOCK, {
|
|
122
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SYNCED_BLOCK_GET_SOURCE_INFO,
|
|
123
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
124
|
+
checks: [new _experiences.ExperienceCheckTimeout({
|
|
125
|
+
durationMs: 2500
|
|
126
|
+
})]
|
|
127
|
+
});
|
|
128
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.wasSyncBlockDeletedOrAddedByHistory = exports.getTarget = exports.getRemovedResourceIds = exports.getAddedResourceIds = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var targetEl;
|
|
10
|
+
var getTarget = exports.getTarget = function getTarget(containerElement) {
|
|
11
|
+
if (!targetEl) {
|
|
12
|
+
var element = containerElement === null || containerElement === void 0 ? void 0 : containerElement.querySelector('.ProseMirror');
|
|
13
|
+
if (!element || !(element instanceof HTMLElement)) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
targetEl = element;
|
|
17
|
+
}
|
|
18
|
+
return targetEl;
|
|
19
|
+
};
|
|
20
|
+
var wasSyncBlockDeletedOrAddedByHistory = exports.wasSyncBlockDeletedOrAddedByHistory = function wasSyncBlockDeletedOrAddedByHistory(tr, oldState, newState) {
|
|
21
|
+
var historyMeta = tr.getMeta(_utils.pmHistoryPluginKey);
|
|
22
|
+
if (!Boolean(historyMeta)) {
|
|
23
|
+
return {};
|
|
24
|
+
}
|
|
25
|
+
var syncBlock = newState.schema.nodes.syncBlock;
|
|
26
|
+
var oldSyncBlockNodes = (0, _utils2.findChildren)(oldState.doc, function (node) {
|
|
27
|
+
return node.type === syncBlock;
|
|
28
|
+
});
|
|
29
|
+
var newSyncBlockNodes = (0, _utils2.findChildren)(newState.doc, function (node) {
|
|
30
|
+
return node.type === syncBlock;
|
|
31
|
+
});
|
|
32
|
+
var oldSyncBlockIds = new Set(oldSyncBlockNodes.map(function (nodeWithPos) {
|
|
33
|
+
return nodeWithPos.node.attrs.localId;
|
|
34
|
+
}).filter(function (localId) {
|
|
35
|
+
return Boolean(localId);
|
|
36
|
+
}));
|
|
37
|
+
var newSyncBlockIds = new Set(newSyncBlockNodes.map(function (nodeWithPos) {
|
|
38
|
+
return nodeWithPos.node.attrs.localId;
|
|
39
|
+
}).filter(function (localId) {
|
|
40
|
+
return Boolean(localId);
|
|
41
|
+
}));
|
|
42
|
+
var hasDeletedSyncBlock = Array.from(oldSyncBlockIds).some(function (localId) {
|
|
43
|
+
return !newSyncBlockIds.has(localId);
|
|
44
|
+
});
|
|
45
|
+
var hasAddedSyncBlock = Array.from(newSyncBlockIds).some(function (localId) {
|
|
46
|
+
return !oldSyncBlockIds.has(localId);
|
|
47
|
+
});
|
|
48
|
+
return {
|
|
49
|
+
hasDeletedSyncBlock: hasDeletedSyncBlock,
|
|
50
|
+
hasAddedSyncBlock: hasAddedSyncBlock,
|
|
51
|
+
isUndo: historyMeta.redo === false
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
var getResourceIds = function getResourceIds(nodes, resourceIds, query) {
|
|
55
|
+
nodes.forEach(function (node) {
|
|
56
|
+
if (!(node instanceof HTMLElement)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var syncBlockElements = node.querySelectorAll(query);
|
|
60
|
+
syncBlockElements.forEach(function (element) {
|
|
61
|
+
var resourceId = element.getAttribute('resourceid');
|
|
62
|
+
if (resourceId) {
|
|
63
|
+
resourceIds.push(resourceId);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
var getAddedResourceIds = exports.getAddedResourceIds = function getAddedResourceIds(mutations, query) {
|
|
69
|
+
var resourceIds = [];
|
|
70
|
+
mutations.forEach(function (mutation) {
|
|
71
|
+
if (mutation.type === 'childList') {
|
|
72
|
+
getResourceIds(mutation.addedNodes, resourceIds, query);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return resourceIds;
|
|
76
|
+
};
|
|
77
|
+
var getRemovedResourceIds = exports.getRemovedResourceIds = function getRemovedResourceIds(mutations, query) {
|
|
78
|
+
var resourceIds = [];
|
|
79
|
+
mutations.forEach(function (mutation) {
|
|
80
|
+
if (mutation.type === 'childList') {
|
|
81
|
+
getResourceIds(mutation.removedNodes, resourceIds, query);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return resourceIds;
|
|
85
|
+
};
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.FLAG_ID = void 0;
|
|
6
|
+
exports.FLAG_ID = exports.EXPERIENCE_ABORT_REASON = void 0;
|
|
7
7
|
var FLAG_ID = exports.FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
8
8
|
FLAG_ID["CANNOT_DELETE_WHEN_OFFLINE"] = "cannot-delete-when-offline";
|
|
9
9
|
FLAG_ID["CANNOT_EDIT_WHEN_OFFLINE"] = "cannot-edit-when-offline";
|
|
@@ -11,4 +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
|
return FLAG_ID;
|
|
14
|
-
}({});
|
|
14
|
+
}({});
|
|
15
|
+
var EXPERIENCE_ABORT_REASON = exports.EXPERIENCE_ABORT_REASON = {
|
|
16
|
+
EDITOR_DESTROYED: 'editor-destroyed'
|
|
17
|
+
};
|
|
@@ -51,24 +51,56 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
|
|
|
51
51
|
}),
|
|
52
52
|
onClick: onClick,
|
|
53
53
|
isDisabled: isOffline,
|
|
54
|
-
testId:
|
|
54
|
+
testId: "create-synced-block-block-menu-btn",
|
|
55
55
|
elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
56
56
|
appearance: "new"
|
|
57
57
|
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
58
58
|
}, formatMessage(_messages.blockMenuMessages.createSyncedBlock));
|
|
59
59
|
};
|
|
60
|
-
var
|
|
61
|
-
var
|
|
62
|
-
var
|
|
63
|
-
|
|
64
|
-
var _useSharedPluginState2 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['
|
|
60
|
+
var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
61
|
+
var api = _ref2.api;
|
|
62
|
+
var _useIntl2 = (0, _reactIntlNext.useIntl)(),
|
|
63
|
+
formatMessage = _useIntl2.formatMessage;
|
|
64
|
+
var _useSharedPluginState2 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity'], function (states) {
|
|
65
|
+
var _states$connectivityS2;
|
|
66
|
+
return {
|
|
67
|
+
mode: (_states$connectivityS2 = states.connectivityState) === null || _states$connectivityS2 === void 0 ? void 0 : _states$connectivityS2.mode
|
|
68
|
+
};
|
|
69
|
+
}),
|
|
70
|
+
mode = _useSharedPluginState2.mode;
|
|
71
|
+
var onClick = function onClick() {
|
|
72
|
+
var _api$core3, _api$core4, _api$blockControls2;
|
|
73
|
+
api === null || api === void 0 || (_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute(api === null || api === void 0 ? void 0 : api.syncedBlock.commands.copySyncedBlockReferenceToClipboard());
|
|
74
|
+
api === null || api === void 0 || (_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute(api === null || api === void 0 || (_api$blockControls2 = api.blockControls) === null || _api$blockControls2 === void 0 || (_api$blockControls2 = _api$blockControls2.commands) === null || _api$blockControls2 === void 0 ? void 0 : _api$blockControls2.toggleBlockMenu({
|
|
75
|
+
closeMenu: true
|
|
76
|
+
}));
|
|
77
|
+
};
|
|
78
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
79
|
+
elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
|
|
80
|
+
label: ""
|
|
81
|
+
}),
|
|
82
|
+
onClick: onClick,
|
|
83
|
+
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
84
|
+
elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
85
|
+
appearance: "new"
|
|
86
|
+
}, formatMessage(_messages.blockMenuMessages.newLozenge))
|
|
87
|
+
}, formatMessage(_messages.blockMenuMessages.copySyncedBlock));
|
|
88
|
+
};
|
|
89
|
+
var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref3) {
|
|
90
|
+
var api = _ref3.api,
|
|
91
|
+
enableSourceSyncedBlockCreation = _ref3.enableSourceSyncedBlockCreation;
|
|
92
|
+
var _useSharedPluginState3 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
65
93
|
var _states$blockControls3, _states$blockControls4;
|
|
66
94
|
return {
|
|
67
95
|
menuTriggerByNode: (_states$blockControls3 = (_states$blockControls4 = states.blockControlsState) === null || _states$blockControls4 === void 0 ? void 0 : _states$blockControls4.menuTriggerByNode) !== null && _states$blockControls3 !== void 0 ? _states$blockControls3 : undefined
|
|
68
96
|
};
|
|
69
97
|
}),
|
|
70
|
-
menuTriggerByNode =
|
|
71
|
-
if (
|
|
98
|
+
menuTriggerByNode = _useSharedPluginState3.menuTriggerByNode;
|
|
99
|
+
if ((menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.nodeType) === 'syncBlock' || (menuTriggerByNode === null || menuTriggerByNode === void 0 ? void 0 : menuTriggerByNode.nodeType) === 'bodiedSyncBlock') {
|
|
100
|
+
return /*#__PURE__*/_react.default.createElement(CopySyncedBlockDropdownItem, {
|
|
101
|
+
api: api
|
|
102
|
+
});
|
|
103
|
+
} else if (enableSourceSyncedBlockCreation) {
|
|
72
104
|
return /*#__PURE__*/_react.default.createElement(CreateSyncedBlockDropdownItem, {
|
|
73
105
|
api: api
|
|
74
106
|
});
|
|
@@ -14,6 +14,7 @@ var _hooks = require("@atlaskit/editor-common/hooks");
|
|
|
14
14
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
15
15
|
var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
|
|
16
16
|
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
17
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
18
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
18
19
|
var _main = require("../pm-plugins/main");
|
|
19
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); }
|
|
@@ -117,6 +118,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
|
|
|
117
118
|
onClick: handleClick(true),
|
|
118
119
|
autoFocus: true,
|
|
119
120
|
isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
|
|
120
|
-
isLoading: bodiedSyncBlockDeletionStatus === 'processing'
|
|
121
|
+
isLoading: bodiedSyncBlockDeletionStatus === 'processing',
|
|
122
|
+
testId: (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? 'synced-block-delete-confirmation-modal-delete-button' : undefined
|
|
121
123
|
}, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalDeleteButton)))));
|
|
122
124
|
};
|
|
@@ -15,6 +15,7 @@ var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider
|
|
|
15
15
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
16
16
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
17
17
|
var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
|
|
18
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
18
19
|
var _editorCommands = require("../editor-commands");
|
|
19
20
|
var _utils2 = require("../pm-plugins/utils/utils");
|
|
20
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); }
|
|
@@ -47,7 +48,8 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
47
48
|
type: 'button',
|
|
48
49
|
title: formatMessage(_messages.default.delete),
|
|
49
50
|
onClick: (0, _editorCommands.removeSyncedBlock)(api),
|
|
50
|
-
icon: _delete.default
|
|
51
|
+
icon: _delete.default,
|
|
52
|
+
testId: (0, _platformFeatureFlags.fg)('platform_synced_block_dogfooding') ? 'reference-synced-block-delete-button' : undefined
|
|
51
53
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
52
54
|
items.push(deleteButton);
|
|
53
55
|
} else {
|
|
@@ -58,7 +60,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
58
60
|
icon: _copy.default,
|
|
59
61
|
title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
|
|
60
62
|
showTitle: false,
|
|
61
|
-
tooltipContent: formatMessage(_messages.syncBlockMessages.
|
|
63
|
+
tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncedBlockTooltip),
|
|
62
64
|
onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(syncBlockStore, api)
|
|
63
65
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
64
66
|
items.push(copyButton);
|
|
@@ -59,8 +59,8 @@ export const createSyncedBlock = ({
|
|
|
59
59
|
syncBlockStore.sourceManager.createBodiedSyncBlockNode(attrs);
|
|
60
60
|
tr.replaceWith(conversionInfo.from > 0 ? conversionInfo.from - 1 : 0, conversionInfo.to, newBodiedSyncBlockNode).scrollIntoView();
|
|
61
61
|
|
|
62
|
-
// set selection to the
|
|
63
|
-
tr.setSelection(TextSelection.create(tr.doc, conversionInfo.
|
|
62
|
+
// set selection to the start of the previous selection for the position taken up by the start of the new synced block
|
|
63
|
+
tr.setSelection(TextSelection.create(tr.doc, conversionInfo.from));
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
// This transaction will be intercepted in filterTransaction and dispatched when saving to backend succeeds
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
2
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
3
5
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
4
6
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
5
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
9
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
7
10
|
const toDOM = () => ['div', {
|
|
8
11
|
class: BodiedSyncBlockSharedCssClassName.content,
|
|
@@ -60,12 +63,20 @@ class BodiedSyncBlock extends ReactNodeView {
|
|
|
60
63
|
return domRef;
|
|
61
64
|
}
|
|
62
65
|
render(_props, forwardRef) {
|
|
63
|
-
var _this$api5, _this$api5$syncedBloc, _this$api5$syncedBloc2;
|
|
66
|
+
var _this$api5, _this$api5$syncedBloc, _this$api5$syncedBloc2, _this$api6, _this$api6$analytics;
|
|
64
67
|
const syncBlockStore = (_this$api5 = this.api) === null || _this$api5 === void 0 ? void 0 : (_this$api5$syncedBloc = _this$api5.syncedBlock.sharedState) === null || _this$api5$syncedBloc === void 0 ? void 0 : (_this$api5$syncedBloc2 = _this$api5$syncedBloc.currentState()) === null || _this$api5$syncedBloc2 === void 0 ? void 0 : _this$api5$syncedBloc2.syncBlockStore;
|
|
65
68
|
if (!syncBlockStore) {
|
|
66
69
|
return null;
|
|
67
70
|
}
|
|
68
|
-
return /*#__PURE__*/React.createElement(
|
|
71
|
+
return fg('platform_synced_block_dogfooding') ? /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
72
|
+
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
73
|
+
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
|
+
fallbackComponent: null
|
|
75
|
+
}, /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
|
|
76
|
+
ref: forwardRef,
|
|
77
|
+
syncBlockStore: syncBlockStore,
|
|
78
|
+
node: this.node
|
|
79
|
+
})) : /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
|
|
69
80
|
ref: forwardRef,
|
|
70
81
|
syncBlockStore: syncBlockStore,
|
|
71
82
|
node: this.node
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
2
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
3
5
|
import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
4
6
|
import { useFetchSyncBlockData, useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -17,7 +19,7 @@ export class SyncBlock extends ReactNodeView {
|
|
|
17
19
|
return domRef;
|
|
18
20
|
}
|
|
19
21
|
render() {
|
|
20
|
-
var _this$options, _this$api$syncedBlock, _this$api, _this$api$syncedBlock2, _this$api$syncedBlock3, _this$options2;
|
|
22
|
+
var _this$options, _this$api$syncedBlock, _this$api, _this$api$syncedBlock2, _this$api$syncedBlock3, _this$api2, _this$api2$analytics, _this$options2, _this$options3;
|
|
21
23
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
22
24
|
return null;
|
|
23
25
|
}
|
|
@@ -35,13 +37,26 @@ export class SyncBlock extends ReactNodeView {
|
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
// get document node from data provider
|
|
38
|
-
return /*#__PURE__*/React.createElement(
|
|
40
|
+
return fg('platform_synced_block_dogfooding') ? /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
41
|
+
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
42
|
+
dispatchAnalyticsEvent: (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : (_this$api2$analytics = _this$api2.analytics) === null || _this$api2$analytics === void 0 ? void 0 : _this$api2$analytics.actions.fireAnalyticsEvent,
|
|
43
|
+
fallbackComponent: null
|
|
44
|
+
}, /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
39
45
|
localId: this.node.attrs.localId,
|
|
40
46
|
syncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.syncedBlockRenderer,
|
|
41
47
|
useFetchSyncBlockTitle: () => useFetchSyncBlockTitle(syncBlockStore, this.node),
|
|
42
48
|
useFetchSyncBlockData: () => {
|
|
43
|
-
var _this$
|
|
44
|
-
return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$
|
|
49
|
+
var _this$api3, _this$api3$analytics, _this$api3$analytics$;
|
|
50
|
+
return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api3 = this.api) === null || _this$api3 === void 0 ? void 0 : (_this$api3$analytics = _this$api3.analytics) === null || _this$api3$analytics === void 0 ? void 0 : (_this$api3$analytics$ = _this$api3$analytics.actions) === null || _this$api3$analytics$ === void 0 ? void 0 : _this$api3$analytics$.fireAnalyticsEvent);
|
|
51
|
+
},
|
|
52
|
+
api: this.api
|
|
53
|
+
})) : /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
54
|
+
localId: this.node.attrs.localId,
|
|
55
|
+
syncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncedBlockRenderer,
|
|
56
|
+
useFetchSyncBlockTitle: () => useFetchSyncBlockTitle(syncBlockStore, this.node),
|
|
57
|
+
useFetchSyncBlockData: () => {
|
|
58
|
+
var _this$api4, _this$api4$analytics, _this$api4$analytics$;
|
|
59
|
+
return useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this$api4 = this.api) === null || _this$api4 === void 0 ? void 0 : (_this$api4$analytics = _this$api4.analytics) === null || _this$api4$analytics === void 0 ? void 0 : (_this$api4$analytics$ = _this$api4$analytics.actions) === null || _this$api4$analytics$ === void 0 ? void 0 : _this$api4$analytics$.fireAnalyticsEvent);
|
|
45
60
|
},
|
|
46
61
|
api: this.api
|
|
47
62
|
});
|
|
@@ -2,13 +2,14 @@ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analy
|
|
|
2
2
|
import { Experience, ExperienceCheckDomMutation, ExperienceCheckTimeout } from '@atlaskit/editor-common/experiences';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
4
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { EXPERIENCE_ABORT_REASON } from '../../types';
|
|
6
|
+
import { getAddedResourceIds, wasSyncBlockDeletedOrAddedByHistory, getTarget } from '../utils/experience-tracking-utils';
|
|
5
7
|
const isPastedFromFabricEditor = html => !!html && html.indexOf('data-pm-slice="') >= 0;
|
|
6
8
|
const pluginKey = new PluginKey('createReferenceSyncBlockExperience');
|
|
7
9
|
const START_METHOD = {
|
|
8
|
-
PASTE: 'paste'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
EDITOR_DESTROYED: 'editor-destroyed'
|
|
10
|
+
PASTE: 'paste',
|
|
11
|
+
UNDO: 'undo',
|
|
12
|
+
REDO: 'redo'
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -32,7 +33,7 @@ export const getCreateReferenceExperiencePlugin = ({
|
|
|
32
33
|
return {
|
|
33
34
|
destroy: () => {
|
|
34
35
|
experience.abort({
|
|
35
|
-
reason:
|
|
36
|
+
reason: EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
39
|
};
|
|
@@ -54,6 +55,20 @@ export const getCreateReferenceExperiencePlugin = ({
|
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
}
|
|
58
|
+
},
|
|
59
|
+
appendTransaction: (transactions, oldState, newState) => {
|
|
60
|
+
transactions.forEach(tr => {
|
|
61
|
+
const {
|
|
62
|
+
hasAddedSyncBlock,
|
|
63
|
+
isUndo
|
|
64
|
+
} = wasSyncBlockDeletedOrAddedByHistory(tr, oldState, newState);
|
|
65
|
+
if (hasAddedSyncBlock) {
|
|
66
|
+
experience.start({
|
|
67
|
+
method: isUndo ? START_METHOD.UNDO : START_METHOD.REDO
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return null;
|
|
57
72
|
}
|
|
58
73
|
});
|
|
59
74
|
};
|
|
@@ -70,21 +85,20 @@ const getCreateReferenceExperience = ({
|
|
|
70
85
|
onDomMutation: ({
|
|
71
86
|
mutations
|
|
72
87
|
}) => {
|
|
73
|
-
|
|
88
|
+
const insertedResourceIds = getAddedResourceIds(mutations, '[data-prosemirror-node-name="syncBlock"]');
|
|
89
|
+
if (insertedResourceIds.length > 0) {
|
|
74
90
|
return {
|
|
75
|
-
status: 'success'
|
|
91
|
+
status: 'success',
|
|
92
|
+
metadata: {
|
|
93
|
+
insertedResourceIds
|
|
94
|
+
}
|
|
76
95
|
};
|
|
77
96
|
}
|
|
78
97
|
return undefined;
|
|
79
98
|
},
|
|
80
99
|
observeConfig: () => {
|
|
81
|
-
var _refs$containerElemen;
|
|
82
|
-
const proseMirrorElement = (_refs$containerElemen = refs.containerElement) === null || _refs$containerElemen === void 0 ? void 0 : _refs$containerElemen.querySelector('.ProseMirror');
|
|
83
|
-
if (!proseMirrorElement || !(proseMirrorElement instanceof HTMLElement)) {
|
|
84
|
-
return null;
|
|
85
|
-
}
|
|
86
100
|
return {
|
|
87
|
-
target:
|
|
101
|
+
target: getTarget(refs.containerElement),
|
|
88
102
|
options: {
|
|
89
103
|
childList: true
|
|
90
104
|
}
|
|
@@ -92,14 +106,4 @@ const getCreateReferenceExperience = ({
|
|
|
92
106
|
}
|
|
93
107
|
})]
|
|
94
108
|
});
|
|
95
|
-
};
|
|
96
|
-
const isReferenceSyncBlockAddedInMutation = ({
|
|
97
|
-
type,
|
|
98
|
-
addedNodes
|
|
99
|
-
}) => type === 'childList' && [...addedNodes].some(isReferenceSyncBlockNode);
|
|
100
|
-
const isReferenceSyncBlockNode = node => {
|
|
101
|
-
if (!(node instanceof HTMLElement)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return !!node.querySelector('[data-prosemirror-node-name="syncBlock"]');
|
|
105
109
|
};
|
|
@@ -3,10 +3,9 @@ import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analy
|
|
|
3
3
|
import { Experience, ExperienceCheckDomMutation, ExperienceCheckTimeout, getPopupContainerFromEditorView, popupWithNestedElement } from '@atlaskit/editor-common/experiences';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { EXPERIENCE_ABORT_REASON } from '../../types';
|
|
7
|
+
import { getAddedResourceIds, getTarget } from '../utils/experience-tracking-utils';
|
|
6
8
|
const pluginKey = new PluginKey('createSourceSyncBlockExperience');
|
|
7
|
-
const ABORT_REASON = {
|
|
8
|
-
EDITOR_DESTROYED: 'editor-destroyed'
|
|
9
|
-
};
|
|
10
9
|
const START_METHOD = {
|
|
11
10
|
BLOCK_MENU: 'block-menu',
|
|
12
11
|
PINNED_TOOLBAR: 'pinned-toolbar',
|
|
@@ -19,8 +18,8 @@ const syncedBlockCreateButtonIds = new Set(SYNCED_BLOCK_CREATE_BUTTON_IDS);
|
|
|
19
18
|
* This experience tracks when a source sync block is inserted.
|
|
20
19
|
*
|
|
21
20
|
* Start: When user inserts a sync block via block menu, quick insert or pinned toolbar
|
|
22
|
-
* Success: When the sync block is added to the DOM within
|
|
23
|
-
* Failure: When
|
|
21
|
+
* Success: When the sync block is added to the DOM within 3000ms of start
|
|
22
|
+
* Failure: When 3000ms passes without the source sync block being added to the DOM
|
|
24
23
|
*/
|
|
25
24
|
export const getCreateSourceExperiencePlugin = ({
|
|
26
25
|
refs,
|
|
@@ -37,8 +36,7 @@ export const getCreateSourceExperiencePlugin = ({
|
|
|
37
36
|
};
|
|
38
37
|
const experience = getCreateSourceExperience({
|
|
39
38
|
refs,
|
|
40
|
-
dispatchAnalyticsEvent
|
|
41
|
-
syncBlockStore
|
|
39
|
+
dispatchAnalyticsEvent
|
|
42
40
|
});
|
|
43
41
|
syncBlockStore.sourceManager.setCreateExperience(experience);
|
|
44
42
|
const unbindClickListener = bind(document, {
|
|
@@ -90,7 +88,7 @@ export const getCreateSourceExperiencePlugin = ({
|
|
|
90
88
|
return {
|
|
91
89
|
destroy: () => {
|
|
92
90
|
experience.abort({
|
|
93
|
-
reason:
|
|
91
|
+
reason: EXPERIENCE_ABORT_REASON.EDITOR_DESTROYED
|
|
94
92
|
});
|
|
95
93
|
unbindClickListener();
|
|
96
94
|
unbindKeydownListener();
|
|
@@ -107,26 +105,25 @@ const getCreateSourceExperience = ({
|
|
|
107
105
|
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK_CREATE,
|
|
108
106
|
dispatchAnalyticsEvent,
|
|
109
107
|
checks: [new ExperienceCheckTimeout({
|
|
110
|
-
durationMs:
|
|
108
|
+
durationMs: 3000
|
|
111
109
|
}), new ExperienceCheckDomMutation({
|
|
112
110
|
onDomMutation: ({
|
|
113
111
|
mutations
|
|
114
112
|
}) => {
|
|
115
|
-
|
|
113
|
+
const createdResourceIds = getAddedResourceIds(mutations, '[data-prosemirror-node-name="bodiedSyncBlock"]');
|
|
114
|
+
if (createdResourceIds.length > 0) {
|
|
116
115
|
return {
|
|
117
|
-
status: 'success'
|
|
116
|
+
status: 'success',
|
|
117
|
+
metadata: {
|
|
118
|
+
createdResourceIds
|
|
119
|
+
}
|
|
118
120
|
};
|
|
119
121
|
}
|
|
120
122
|
return undefined;
|
|
121
123
|
},
|
|
122
124
|
observeConfig: () => {
|
|
123
|
-
var _refs$containerElemen;
|
|
124
|
-
const proseMirrorElement = (_refs$containerElemen = refs.containerElement) === null || _refs$containerElemen === void 0 ? void 0 : _refs$containerElemen.querySelector('.ProseMirror');
|
|
125
|
-
if (!proseMirrorElement || !(proseMirrorElement instanceof HTMLElement)) {
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
125
|
return {
|
|
129
|
-
target:
|
|
126
|
+
target: getTarget(refs.containerElement),
|
|
130
127
|
options: {
|
|
131
128
|
childList: true
|
|
132
129
|
}
|
|
@@ -166,14 +163,4 @@ const handleButtonClick = (testId, experience) => {
|
|
|
166
163
|
};
|
|
167
164
|
const isEnterKey = key => {
|
|
168
165
|
return key === 'Enter';
|
|
169
|
-
};
|
|
170
|
-
const isSourceSyncBlockAddedInMutation = ({
|
|
171
|
-
type,
|
|
172
|
-
addedNodes
|
|
173
|
-
}) => type === 'childList' && [...addedNodes].some(isSourceSyncBlockNode);
|
|
174
|
-
const isSourceSyncBlockNode = node => {
|
|
175
|
-
if (!(node instanceof HTMLElement)) {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
return !!node.querySelector('[data-prosemirror-node-name="bodiedSyncBlock"]');
|
|
179
166
|
};
|