@atlaskit/editor-plugin-synced-block 5.4.4 → 5.4.6
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 +18 -0
- package/afm-cc/tsconfig.json +12 -0
- package/afm-jira/tsconfig.json +12 -0
- package/afm-products/tsconfig.json +12 -0
- package/dist/cjs/nodeviews/bodiedLazySyncedBlock.js +1 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +137 -11
- package/dist/cjs/nodeviews/syncedBlock.js +15 -0
- package/dist/cjs/pm-plugins/main.js +42 -58
- package/dist/cjs/pm-plugins/utils/track-sync-blocks.js +24 -66
- package/dist/cjs/syncedBlockPlugin.js +6 -1
- package/dist/cjs/ui/BodiedSyncBlockWrapper.js +1 -0
- package/dist/cjs/ui/DeleteConfirmationModal.js +1 -1
- package/dist/cjs/ui/SyncBlockLabel.js +4 -1
- package/dist/cjs/ui/SyncedLocationDropdown.js +12 -21
- package/dist/cjs/ui/quick-insert.js +1 -1
- package/dist/es2019/nodeviews/bodiedLazySyncedBlock.js +1 -0
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +121 -6
- package/dist/es2019/nodeviews/syncedBlock.js +11 -0
- package/dist/es2019/pm-plugins/main.js +43 -59
- package/dist/es2019/pm-plugins/utils/track-sync-blocks.js +25 -58
- package/dist/es2019/syncedBlockPlugin.js +7 -2
- package/dist/es2019/ui/BodiedSyncBlockWrapper.js +1 -0
- package/dist/es2019/ui/DeleteConfirmationModal.js +1 -1
- package/dist/es2019/ui/SyncBlockLabel.js +4 -1
- package/dist/es2019/ui/SyncedLocationDropdown.js +13 -22
- package/dist/es2019/ui/quick-insert.js +1 -1
- package/dist/esm/nodeviews/bodiedLazySyncedBlock.js +1 -0
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +137 -11
- package/dist/esm/nodeviews/syncedBlock.js +15 -0
- package/dist/esm/pm-plugins/main.js +43 -59
- package/dist/esm/pm-plugins/utils/track-sync-blocks.js +24 -66
- package/dist/esm/syncedBlockPlugin.js +7 -2
- package/dist/esm/ui/BodiedSyncBlockWrapper.js +1 -0
- package/dist/esm/ui/DeleteConfirmationModal.js +1 -1
- package/dist/esm/ui/SyncBlockLabel.js +4 -1
- package/dist/esm/ui/SyncedLocationDropdown.js +12 -21
- package/dist/esm/ui/quick-insert.js +1 -1
- package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +27 -21
- package/dist/types/nodeviews/syncedBlock.d.ts +3 -1
- package/dist/types/syncedBlockPluginType.d.ts +3 -1
- package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +27 -21
- package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +3 -1
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +3 -1
- package/package.json +7 -6
|
@@ -9,6 +9,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
9
9
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
10
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
11
11
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
13
|
var _editorActions = require("./editor-actions");
|
|
13
14
|
var _editorCommands = require("./editor-commands");
|
|
14
15
|
var _bodiedSyncBlockNodeWithToDOMFixed = require("./nodeviews/bodiedSyncBlockNodeWithToDOMFixed");
|
|
@@ -38,7 +39,11 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
38
39
|
node: _adfSchema.syncBlock
|
|
39
40
|
}, {
|
|
40
41
|
name: 'bodiedSyncBlock',
|
|
41
|
-
node: (0,
|
|
42
|
+
node: !(0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
43
|
+
exposure: true
|
|
44
|
+
}) ?
|
|
45
|
+
// delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
|
|
46
|
+
(0, _bodiedSyncBlockNodeWithToDOMFixed.bodiedSyncBlockNodeWithToDOMFixed)() : _adfSchema.bodiedSyncBlock
|
|
42
47
|
}];
|
|
43
48
|
},
|
|
44
49
|
pmPlugins: function pmPlugins() {
|
|
@@ -8,6 +8,7 @@ exports.BodiedSyncBlockWrapper = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
10
10
|
var _SyncBlockLabel = require("./SyncBlockLabel");
|
|
11
|
+
// Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
|
|
11
12
|
var BodiedSyncBlockWrapper = exports.BodiedSyncBlockWrapper = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
12
13
|
var node = _ref.node,
|
|
13
14
|
syncBlockStore = _ref.syncBlockStore;
|
|
@@ -13,6 +13,7 @@ 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
15
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
16
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
16
17
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
17
18
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
18
19
|
var _time = require("./utils/time");
|
|
@@ -79,7 +80,9 @@ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
|
|
|
79
80
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
80
81
|
,
|
|
81
82
|
className: _syncBlock.SyncBlockLabelSharedCssClassName.labelClassName,
|
|
82
|
-
"aria-describedby":
|
|
83
|
+
"aria-describedby": (isSource || isUnsyncedBlock) && (0, _experiments.editorExperiment)('platform_synced_block_patch_6', true, {
|
|
84
|
+
exposure: true
|
|
85
|
+
}) ? undefined : ariaDescribedById
|
|
83
86
|
}, /*#__PURE__*/_react.default.createElement(_blockSynced.default, {
|
|
84
87
|
color: "var(--ds-icon-subtle, #505258)",
|
|
85
88
|
size: "small",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.
|
|
1
|
+
/* SyncedLocationDropdown.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
@@ -31,7 +31,6 @@ var _quotationMark = _interopRequireDefault(require("@atlaskit/icon/core/quotati
|
|
|
31
31
|
var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
|
|
32
32
|
var _logo = require("@atlaskit/logo");
|
|
33
33
|
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
34
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
35
34
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
36
35
|
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
37
36
|
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
@@ -89,31 +88,23 @@ var productIconMap = {
|
|
|
89
88
|
'jira-work-item': _logo.JiraIcon
|
|
90
89
|
};
|
|
91
90
|
var subTypeIconMap = {
|
|
92
|
-
live: _pageLiveDoc.default,
|
|
93
|
-
page: _page.default,
|
|
94
|
-
blogpost: _quotationMark.default
|
|
95
|
-
};
|
|
96
|
-
var subTypeIconMapNew = {
|
|
97
91
|
live: _pageLiveDoc.default,
|
|
98
92
|
page: _page.default
|
|
99
93
|
};
|
|
100
94
|
var getConfluenceSubTypeIcon = function getConfluenceSubTypeIcon(sourceAri, subType) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return subType && subType in subTypeIconMapNew ? subTypeIconMapNew[subType] : _page.default;
|
|
111
|
-
}
|
|
112
|
-
} catch (_unused) {
|
|
113
|
-
return _page.default;
|
|
95
|
+
try {
|
|
96
|
+
var _getPageIdAndTypeFrom = (0, _editorSyncedBlockProvider.getPageIdAndTypeFromConfluencePageAri)({
|
|
97
|
+
ari: sourceAri
|
|
98
|
+
}),
|
|
99
|
+
pageType = _getPageIdAndTypeFrom.type;
|
|
100
|
+
if (pageType === 'blogpost') {
|
|
101
|
+
return _quotationMark.default;
|
|
102
|
+
} else {
|
|
103
|
+
return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : _page.default;
|
|
114
104
|
}
|
|
105
|
+
} catch (_unused) {
|
|
106
|
+
return _page.default;
|
|
115
107
|
}
|
|
116
|
-
return subType && subType in subTypeIconMap ? subTypeIconMap[subType] : _page.default;
|
|
117
108
|
};
|
|
118
109
|
var ProductIcon = function ProductIcon(_ref2) {
|
|
119
110
|
var _productIconMap$produ;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
4
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
@@ -7,11 +7,12 @@ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
|
7
7
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
10
|
-
|
|
10
|
+
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
11
|
+
const toDOMOld = () => ['div', {
|
|
11
12
|
class: BodiedSyncBlockSharedCssClassName.content,
|
|
12
13
|
contenteditable: true
|
|
13
14
|
}, 0];
|
|
14
|
-
|
|
15
|
+
class BodiedSyncBlockOld extends ReactNodeView {
|
|
15
16
|
constructor(props) {
|
|
16
17
|
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
17
18
|
this.api = props.api;
|
|
@@ -84,7 +85,7 @@ export class BodiedSyncBlock extends ReactNodeView {
|
|
|
84
85
|
const {
|
|
85
86
|
dom,
|
|
86
87
|
contentDOM
|
|
87
|
-
} = DOMSerializer.renderSpec(document,
|
|
88
|
+
} = DOMSerializer.renderSpec(document, toDOMOld());
|
|
88
89
|
// In SSR, the first check won't work, so fallback to nodeType check
|
|
89
90
|
if (dom instanceof HTMLElement || dom.nodeType === 1 && fg('platform_synced_block_patch_5')) {
|
|
90
91
|
this.updateContentEditable({
|
|
@@ -107,7 +108,7 @@ export class BodiedSyncBlock extends ReactNodeView {
|
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
export const
|
|
111
|
+
export const bodiedSyncBlockNodeViewOld = ({
|
|
111
112
|
pluginOptions,
|
|
112
113
|
pmPluginFactoryParams,
|
|
113
114
|
api,
|
|
@@ -117,7 +118,7 @@ export const bodiedSyncBlockNodeView = ({
|
|
|
117
118
|
portalProviderAPI,
|
|
118
119
|
eventDispatcher
|
|
119
120
|
} = pmPluginFactoryParams;
|
|
120
|
-
return new
|
|
121
|
+
return new BodiedSyncBlockOld({
|
|
121
122
|
api,
|
|
122
123
|
pluginOptions,
|
|
123
124
|
node,
|
|
@@ -127,4 +128,118 @@ export const bodiedSyncBlockNodeView = ({
|
|
|
127
128
|
eventDispatcher,
|
|
128
129
|
syncBlockStore
|
|
129
130
|
}).init();
|
|
131
|
+
};
|
|
132
|
+
const toDOM = node => ['div', {
|
|
133
|
+
class: `${BodiedSyncBlockSharedCssClassName.prefix} bodiedSyncBlockView-content-wrap`,
|
|
134
|
+
localid: node.attrs.localId,
|
|
135
|
+
resourceid: node.attrs.resourceId
|
|
136
|
+
}, ['div', {
|
|
137
|
+
class: BodiedSyncBlockSharedCssClassName.content,
|
|
138
|
+
contenteditable: 'true'
|
|
139
|
+
}, 0]];
|
|
140
|
+
export class BodiedSyncBlock {
|
|
141
|
+
constructor(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore) {
|
|
142
|
+
this.node = node;
|
|
143
|
+
this.view = view;
|
|
144
|
+
this.getPos = getPos;
|
|
145
|
+
this.api = api;
|
|
146
|
+
this.syncBlockStore = syncBlockStore;
|
|
147
|
+
this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
|
|
148
|
+
const {
|
|
149
|
+
dom,
|
|
150
|
+
contentDOM
|
|
151
|
+
} = DOMSerializer.renderSpec(document, toDOM(this.node));
|
|
152
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
153
|
+
this.dom = dom;
|
|
154
|
+
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
155
|
+
this.contentDOM = contentDOM;
|
|
156
|
+
this.labelKey = crypto.randomUUID();
|
|
157
|
+
this.nodeViewPortalProviderAPI.render(() => {
|
|
158
|
+
var _this$api7, _this$api7$analytics;
|
|
159
|
+
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
160
|
+
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
161
|
+
componentId: ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
|
|
162
|
+
dispatchAnalyticsEvent: (_this$api7 = this.api) === null || _this$api7 === void 0 ? void 0 : (_this$api7$analytics = _this$api7.analytics) === null || _this$api7$analytics === void 0 ? void 0 : _this$api7$analytics.actions.fireAnalyticsEvent,
|
|
163
|
+
fallbackComponent: null
|
|
164
|
+
}, /*#__PURE__*/React.createElement(SyncBlockLabel, {
|
|
165
|
+
isSource: true,
|
|
166
|
+
localId: node.attrs.localId
|
|
167
|
+
}));
|
|
168
|
+
}, this.dom, this.labelKey);
|
|
169
|
+
this.updateContentEditable({});
|
|
170
|
+
this.handleConnectivityModeChange();
|
|
171
|
+
this.handleViewModeChange();
|
|
172
|
+
}
|
|
173
|
+
updateContentEditable({
|
|
174
|
+
nextConnectivityMode,
|
|
175
|
+
nextViewMode
|
|
176
|
+
}) {
|
|
177
|
+
var _this$api8, _this$api8$connectivi, _this$api8$connectivi2, _this$api8$connectivi3, _this$api9, _this$api9$editorView, _this$api9$editorView2, _this$api9$editorView3;
|
|
178
|
+
const connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api8 = this.api) === null || _this$api8 === void 0 ? void 0 : (_this$api8$connectivi = _this$api8.connectivity) === null || _this$api8$connectivi === void 0 ? void 0 : (_this$api8$connectivi2 = _this$api8$connectivi.sharedState) === null || _this$api8$connectivi2 === void 0 ? void 0 : (_this$api8$connectivi3 = _this$api8$connectivi2.currentState()) === null || _this$api8$connectivi3 === void 0 ? void 0 : _this$api8$connectivi3.mode;
|
|
179
|
+
const viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api9 = this.api) === null || _this$api9 === void 0 ? void 0 : (_this$api9$editorView = _this$api9.editorViewMode) === null || _this$api9$editorView === void 0 ? void 0 : (_this$api9$editorView2 = _this$api9$editorView.sharedState) === null || _this$api9$editorView2 === void 0 ? void 0 : (_this$api9$editorView3 = _this$api9$editorView2.currentState()) === null || _this$api9$editorView3 === void 0 ? void 0 : _this$api9$editorView3.mode;
|
|
180
|
+
const isOnline = !isOfflineMode(connectivityMode);
|
|
181
|
+
const isEditMode = viewMode !== 'view';
|
|
182
|
+
const shouldBeEditable = isOnline && isEditMode;
|
|
183
|
+
this.contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
|
|
184
|
+
}
|
|
185
|
+
handleConnectivityModeChange() {
|
|
186
|
+
var _this$api0;
|
|
187
|
+
if ((_this$api0 = this.api) !== null && _this$api0 !== void 0 && _this$api0.connectivity) {
|
|
188
|
+
this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(({
|
|
189
|
+
nextSharedState
|
|
190
|
+
}) => {
|
|
191
|
+
this.updateContentEditable({
|
|
192
|
+
nextConnectivityMode: nextSharedState.mode
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
handleViewModeChange() {
|
|
198
|
+
var _this$api1;
|
|
199
|
+
if ((_this$api1 = this.api) !== null && _this$api1 !== void 0 && _this$api1.editorViewMode) {
|
|
200
|
+
this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(({
|
|
201
|
+
nextSharedState
|
|
202
|
+
}) => {
|
|
203
|
+
this.updateContentEditable({
|
|
204
|
+
nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
update(node) {
|
|
210
|
+
if (this.node.type !== node.type) {
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
if (node !== this.node) {
|
|
214
|
+
var _this$api$syncedBlock2, _this$api10, _this$api10$syncedBlo, _this$api10$syncedBlo2;
|
|
215
|
+
const syncBlockStore = (_this$api$syncedBlock2 = (_this$api10 = this.api) === null || _this$api10 === void 0 ? void 0 : (_this$api10$syncedBlo = _this$api10.syncedBlock.sharedState) === null || _this$api10$syncedBlo === void 0 ? void 0 : (_this$api10$syncedBlo2 = _this$api10$syncedBlo.currentState()) === null || _this$api10$syncedBlo2 === void 0 ? void 0 : _this$api10$syncedBlo2.syncBlockStore) !== null && _this$api$syncedBlock2 !== void 0 ? _this$api$syncedBlock2 : this.syncBlockStore;
|
|
216
|
+
syncBlockStore === null || syncBlockStore === void 0 ? void 0 : syncBlockStore.sourceManager.updateSyncBlockData(node);
|
|
217
|
+
}
|
|
218
|
+
this.node = node;
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
221
|
+
ignoreMutation(mutation) {
|
|
222
|
+
if (mutation.type === 'selection') {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
destroy() {
|
|
228
|
+
var _this$cleanupConnecti, _this$cleanupViewMode;
|
|
229
|
+
(_this$cleanupConnecti = this.cleanupConnectivityModeListener) === null || _this$cleanupConnecti === void 0 ? void 0 : _this$cleanupConnecti.call(this);
|
|
230
|
+
(_this$cleanupViewMode = this.cleanupViewModeListener) === null || _this$cleanupViewMode === void 0 ? void 0 : _this$cleanupViewMode.call(this);
|
|
231
|
+
this.nodeViewPortalProviderAPI.remove(this.labelKey);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
export const bodiedSyncBlockNodeView = props => {
|
|
235
|
+
const {
|
|
236
|
+
api,
|
|
237
|
+
syncBlockStore,
|
|
238
|
+
pmPluginFactoryParams: {
|
|
239
|
+
nodeViewPortalProviderAPI
|
|
240
|
+
}
|
|
241
|
+
} = props;
|
|
242
|
+
return (node, view, getPos) => {
|
|
243
|
+
return new BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI, syncBlockStore);
|
|
244
|
+
};
|
|
130
245
|
};
|
|
@@ -4,6 +4,7 @@ import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
|
4
4
|
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import { SyncBlockSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
|
|
6
6
|
import { useFetchSyncBlockData, useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
|
|
7
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
7
8
|
import { removeSyncedBlockAtPos } from '../editor-commands';
|
|
8
9
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
9
10
|
export class SyncBlock extends ReactNodeView {
|
|
@@ -18,6 +19,16 @@ export class SyncBlock extends ReactNodeView {
|
|
|
18
19
|
domRef.classList.add(SyncBlockSharedCssClassName.prefix);
|
|
19
20
|
return domRef;
|
|
20
21
|
}
|
|
22
|
+
validUpdate(currentNode, newNode) {
|
|
23
|
+
// Only consider as the valid update if the localId and resourceId are the same
|
|
24
|
+
// This prevents PM reusing the same node view for different sync block node in live page transition
|
|
25
|
+
return currentNode.attrs.localId === newNode.attrs.localId && currentNode.attrs.resourceId === newNode.attrs.resourceId;
|
|
26
|
+
}
|
|
27
|
+
update(node, decorations, innerDecorations) {
|
|
28
|
+
return super.update(node, decorations, innerDecorations, editorExperiment('platform_synced_block_patch_6', true, {
|
|
29
|
+
exposure: true
|
|
30
|
+
}) ? this.validUpdate : undefined);
|
|
31
|
+
}
|
|
21
32
|
render({
|
|
22
33
|
getPos
|
|
23
34
|
}) {
|
|
@@ -9,8 +9,9 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
9
9
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
10
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
12
13
|
import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
|
|
13
|
-
import { bodiedSyncBlockNodeView } from '../nodeviews/bodiedSyncedBlock';
|
|
14
|
+
import { bodiedSyncBlockNodeView, bodiedSyncBlockNodeViewOld } from '../nodeviews/bodiedSyncedBlock';
|
|
14
15
|
import { SyncBlock as SyncBlockView } from '../nodeviews/syncedBlock';
|
|
15
16
|
import { FLAG_ID } from '../types';
|
|
16
17
|
import { handleBodiedSyncBlockCreation } from './utils/handle-bodied-sync-block-creation';
|
|
@@ -57,9 +58,6 @@ const showCopiedFlag = api => {
|
|
|
57
58
|
};
|
|
58
59
|
const showInlineExtensionInSyncBlockWarningIfNeeded = (tr, state, api, inlineExtensionFlagShown) => {
|
|
59
60
|
var _api$connectivity, _api$connectivity$sha;
|
|
60
|
-
if (!fg('platform_synced_block_patch_3')) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
61
|
if (!tr.docChanged || tr.getMeta('isRemote') || Boolean(tr.getMeta(pmHistoryPluginKey)) || isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 ? void 0 : (_api$connectivity$sha = _api$connectivity.sharedState.currentState()) === null || _api$connectivity$sha === void 0 ? void 0 : _api$connectivity$sha.mode)) {
|
|
64
62
|
return;
|
|
65
63
|
}
|
|
@@ -113,31 +111,17 @@ const filterTransactionOnline = ({
|
|
|
113
111
|
});
|
|
114
112
|
});
|
|
115
113
|
syncBlockAdded.forEach(syncBlock => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
});
|
|
128
|
-
} else {
|
|
129
|
-
var _api$analytics3, _api$analytics3$actio;
|
|
130
|
-
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
|
|
131
|
-
action: ACTION.INSERTED,
|
|
132
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
133
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
134
|
-
attributes: {
|
|
135
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
136
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
137
|
-
},
|
|
138
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
139
|
-
});
|
|
140
|
-
}
|
|
114
|
+
var _api$analytics2, _api$analytics2$actio;
|
|
115
|
+
api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : (_api$analytics2$actio = _api$analytics2.actions) === null || _api$analytics2$actio === void 0 ? void 0 : _api$analytics2$actio.fireAnalyticsEvent({
|
|
116
|
+
action: ACTION.INSERTED,
|
|
117
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
118
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
119
|
+
attributes: {
|
|
120
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
121
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
122
|
+
},
|
|
123
|
+
eventType: EVENT_TYPE.TRACK
|
|
124
|
+
});
|
|
141
125
|
});
|
|
142
126
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
143
127
|
// eslint-disable-next-line no-param-reassign
|
|
@@ -314,7 +298,14 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
314
298
|
eventDispatcher: pmPluginFactoryParams.eventDispatcher,
|
|
315
299
|
syncBlockStore: syncBlockStore
|
|
316
300
|
}).init(),
|
|
317
|
-
bodiedSyncBlock: fg('platform_synced_block_patch_5') ?
|
|
301
|
+
bodiedSyncBlock: fg('platform_synced_block_patch_5') ? editorExperiment('platform_synced_block_use_new_source_nodeview', true, {
|
|
302
|
+
exposure: true
|
|
303
|
+
}) ? bodiedSyncBlockNodeView({
|
|
304
|
+
pluginOptions: options,
|
|
305
|
+
pmPluginFactoryParams,
|
|
306
|
+
api,
|
|
307
|
+
syncBlockStore
|
|
308
|
+
}) : bodiedSyncBlockNodeViewOld({
|
|
318
309
|
pluginOptions: options,
|
|
319
310
|
pmPluginFactoryParams,
|
|
320
311
|
api,
|
|
@@ -326,7 +317,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
326
317
|
})
|
|
327
318
|
},
|
|
328
319
|
decorations: state => {
|
|
329
|
-
var _currentPluginState$s, _api$connectivity2, _api$connectivity2$sh, _api$editorViewMode, _api$editorViewMode$s, _api$userIntent, _api$userIntent$share;
|
|
320
|
+
var _currentPluginState$s, _api$connectivity2, _api$connectivity2$sh, _api$editorViewMode, _api$editorViewMode$s, _api$userIntent, _api$userIntent$share, _api$focus, _api$focus$sharedStat, _api$focus$sharedStat2;
|
|
330
321
|
const currentPluginState = syncedBlockPluginKey.getState(state);
|
|
331
322
|
const selectionDecorationSet = (_currentPluginState$s = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.selectionDecorationSet) !== null && _currentPluginState$s !== void 0 ? _currentPluginState$s : DecorationSet.empty;
|
|
332
323
|
const syncBlockStore = currentPluginState === null || currentPluginState === void 0 ? void 0 : currentPluginState.syncBlockStore;
|
|
@@ -364,7 +355,14 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
364
355
|
}));
|
|
365
356
|
}
|
|
366
357
|
});
|
|
367
|
-
|
|
358
|
+
if (api !== null && api !== void 0 && (_api$focus = api.focus) !== null && _api$focus !== void 0 && (_api$focus$sharedStat = _api$focus.sharedState) !== null && _api$focus$sharedStat !== void 0 && (_api$focus$sharedStat2 = _api$focus$sharedStat.currentState()) !== null && _api$focus$sharedStat2 !== void 0 && _api$focus$sharedStat2.hasFocus || !editorExperiment('platform_synced_block_patch_6', true, {
|
|
359
|
+
exposure: true
|
|
360
|
+
})) {
|
|
361
|
+
// Don't show decorations if the editor is not focused
|
|
362
|
+
return selectionDecorationSet.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
|
|
363
|
+
} else {
|
|
364
|
+
return DecorationSet.empty.add(doc, offlineDecorations).add(doc, viewModeDecorations).add(doc, loadingDecorations).add(doc, dragDecorations);
|
|
365
|
+
}
|
|
368
366
|
},
|
|
369
367
|
handleClickOn: createSelectionClickHandler(['bodiedSyncBlock'], target => !!target.closest(`.${BodiedSyncBlockSharedCssClassName.prefix}`), {
|
|
370
368
|
useLongPressSelection
|
|
@@ -478,8 +476,8 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
478
476
|
added: syncBlockAdded
|
|
479
477
|
} = trackSyncBlocks(node => node.type.name === 'syncBlock', tr, state);
|
|
480
478
|
syncBlockRemoved.forEach(syncBlock => {
|
|
481
|
-
var _api$
|
|
482
|
-
api === null || api === void 0 ? void 0 : (_api$
|
|
479
|
+
var _api$analytics3, _api$analytics3$actio;
|
|
480
|
+
api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : (_api$analytics3$actio = _api$analytics3.actions) === null || _api$analytics3$actio === void 0 ? void 0 : _api$analytics3$actio.fireAnalyticsEvent({
|
|
483
481
|
action: ACTION.DELETED,
|
|
484
482
|
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
485
483
|
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_DELETE,
|
|
@@ -491,31 +489,17 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
491
489
|
});
|
|
492
490
|
});
|
|
493
491
|
syncBlockAdded.forEach(syncBlock => {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
});
|
|
506
|
-
} else {
|
|
507
|
-
var _api$analytics6, _api$analytics6$actio;
|
|
508
|
-
api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : (_api$analytics6$actio = _api$analytics6.actions) === null || _api$analytics6$actio === void 0 ? void 0 : _api$analytics6$actio.fireAnalyticsEvent({
|
|
509
|
-
action: ACTION.INSERTED,
|
|
510
|
-
actionSubject: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
511
|
-
actionSubjectId: ACTION_SUBJECT_ID.REFERENCE_SYNCED_BLOCK_CREATE,
|
|
512
|
-
attributes: {
|
|
513
|
-
resourceId: syncBlock.attrs.resourceId,
|
|
514
|
-
blockInstanceId: syncBlock.attrs.localId
|
|
515
|
-
},
|
|
516
|
-
eventType: EVENT_TYPE.OPERATIONAL
|
|
517
|
-
});
|
|
518
|
-
}
|
|
492
|
+
var _api$analytics4, _api$analytics4$actio;
|
|
493
|
+
api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : (_api$analytics4$actio = _api$analytics4.actions) === null || _api$analytics4$actio === void 0 ? void 0 : _api$analytics4$actio.fireAnalyticsEvent({
|
|
494
|
+
action: ACTION.INSERTED,
|
|
495
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
496
|
+
actionSubjectId: ACTION_SUBJECT_ID.SYNCED_BLOCK,
|
|
497
|
+
attributes: {
|
|
498
|
+
resourceId: syncBlock.attrs.resourceId,
|
|
499
|
+
blockInstanceId: syncBlock.attrs.localId
|
|
500
|
+
},
|
|
501
|
+
eventType: EVENT_TYPE.TRACK
|
|
502
|
+
});
|
|
519
503
|
});
|
|
520
504
|
if (bodiedSyncBlockRemoved.length > 0) {
|
|
521
505
|
confirmationTransactionRef.current = tr;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReplaceAroundStep, ReplaceStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
3
|
export const trackSyncBlocks = (predicate, tr, state) => {
|
|
5
4
|
const removed = {};
|
|
6
5
|
const added = {};
|
|
@@ -15,12 +14,12 @@ export const trackSyncBlocks = (predicate, tr, state) => {
|
|
|
15
14
|
const replaceSteps = tr.steps.filter(step => step instanceof ReplaceStep || step instanceof ReplaceAroundStep);
|
|
16
15
|
|
|
17
16
|
// this is a quick check to see if any insertion/deletion of bodiedSyncBlock happened
|
|
18
|
-
const hasBodiedSyncBlockChanges = replaceSteps.some(
|
|
17
|
+
const hasBodiedSyncBlockChanges = replaceSteps.some(step => {
|
|
19
18
|
const {
|
|
20
19
|
from,
|
|
21
20
|
to
|
|
22
21
|
} = step;
|
|
23
|
-
const docAtStep =
|
|
22
|
+
const docAtStep = tr.docs[tr.steps.indexOf(step)];
|
|
24
23
|
let hasChange = false;
|
|
25
24
|
if (from !== to) {
|
|
26
25
|
step.getMap().forEach((oldStart, oldEnd) => {
|
|
@@ -102,63 +101,31 @@ export const hasEditInSyncBlock = (tr, state) => {
|
|
|
102
101
|
const {
|
|
103
102
|
bodiedSyncBlock
|
|
104
103
|
} = state.schema.nodes;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const positions = [];
|
|
104
|
+
for (let i = 0; i < tr.steps.length; i++) {
|
|
105
|
+
var _tr$docs;
|
|
106
|
+
const step = tr.steps[i];
|
|
107
|
+
const map = step.getMap();
|
|
108
|
+
const docAfterStep = (_tr$docs = tr.docs[i + 1]) !== null && _tr$docs !== void 0 ? _tr$docs : tr.doc;
|
|
109
|
+
const positions = [];
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const {
|
|
116
|
-
from,
|
|
117
|
-
to
|
|
118
|
-
} = step;
|
|
119
|
-
positions.push(from, to);
|
|
120
|
-
} else if ('pos' in step && typeof step.pos === 'number') {
|
|
121
|
-
const {
|
|
122
|
-
pos
|
|
123
|
-
} = step;
|
|
124
|
-
positions.push(pos);
|
|
125
|
-
}
|
|
126
|
-
for (const pos of positions) {
|
|
127
|
-
const newPos = map.map(pos);
|
|
128
|
-
if (newPos >= 0 && newPos <= docAfterStep.content.size) {
|
|
129
|
-
if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
|
|
130
|
-
return true;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
} else {
|
|
136
|
-
for (const step of tr.steps) {
|
|
137
|
-
const map = step.getMap();
|
|
111
|
+
// Extract positions from steps dynamically based on applicable properties
|
|
112
|
+
if ('from' in step && typeof step.from === 'number' && 'to' in step && typeof step.to === 'number') {
|
|
138
113
|
const {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
positions.push(pos);
|
|
155
|
-
}
|
|
156
|
-
for (const pos of positions) {
|
|
157
|
-
const newPos = map.map(pos);
|
|
158
|
-
if (newPos >= 0 && newPos <= doc.content.size) {
|
|
159
|
-
if (findParentNodeOfTypeClosestToPos(doc.resolve(newPos), bodiedSyncBlock)) {
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
114
|
+
from,
|
|
115
|
+
to
|
|
116
|
+
} = step;
|
|
117
|
+
positions.push(from, to);
|
|
118
|
+
} else if ('pos' in step && typeof step.pos === 'number') {
|
|
119
|
+
const {
|
|
120
|
+
pos
|
|
121
|
+
} = step;
|
|
122
|
+
positions.push(pos);
|
|
123
|
+
}
|
|
124
|
+
for (const pos of positions) {
|
|
125
|
+
const newPos = map.map(pos);
|
|
126
|
+
if (newPos >= 0 && newPos <= docAfterStep.content.size) {
|
|
127
|
+
if (findParentNodeOfTypeClosestToPos(docAfterStep.resolve(newPos), bodiedSyncBlock)) {
|
|
128
|
+
return true;
|
|
162
129
|
}
|
|
163
130
|
}
|
|
164
131
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
6
|
import { flushBodiedSyncBlocks, flushSyncBlocks } from './editor-actions';
|
|
6
7
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
7
8
|
import { bodiedSyncBlockNodeWithToDOMFixed } from './nodeviews/bodiedSyncBlockNodeWithToDOMFixed';
|
|
@@ -32,7 +33,11 @@ export const syncedBlockPlugin = ({
|
|
|
32
33
|
node: syncBlock
|
|
33
34
|
}, {
|
|
34
35
|
name: 'bodiedSyncBlock',
|
|
35
|
-
node:
|
|
36
|
+
node: !editorExperiment('platform_synced_block_patch_6', true, {
|
|
37
|
+
exposure: true
|
|
38
|
+
}) ?
|
|
39
|
+
// delete bodiedSyncBlockNodeWithToDOMFixed when cleaning up platform_synced_block_patch_6
|
|
40
|
+
bodiedSyncBlockNodeWithToDOMFixed() : bodiedSyncBlock
|
|
36
41
|
}];
|
|
37
42
|
},
|
|
38
43
|
pmPlugins() {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
|
|
3
3
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
4
|
+
// Delete this file when cleaning up platform_synced_block_use_new_source_nodeview
|
|
4
5
|
export const BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(({
|
|
5
6
|
node,
|
|
6
7
|
syncBlockStore
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.
|
|
1
|
+
/* DeleteConfirmationModal.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
2
|
import "./DeleteConfirmationModal.compiled.css";
|
|
3
3
|
import { ax, ix } from "@compiled/react/runtime";
|
|
4
4
|
import React, { useCallback, useEffect, useState } from 'react';
|