@atlaskit/editor-plugin-synced-block 10.8.5 → 11.0.1
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/AGENTS.md +3 -3
- package/CHANGELOG.md +19 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +25 -193
- package/dist/cjs/nodeviews/syncedBlock.js +4 -25
- package/dist/cjs/pm-plugins/main.js +64 -130
- package/dist/cjs/pm-plugins/menu-and-toolbar-experiences.js +2 -7
- package/dist/cjs/pm-plugins/utils/has-synced-blocks.js +2 -2
- package/dist/cjs/syncedBlockPlugin.js +3 -12
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +9 -150
- package/dist/es2019/nodeviews/syncedBlock.js +3 -17
- package/dist/es2019/pm-plugins/main.js +65 -133
- package/dist/es2019/pm-plugins/menu-and-toolbar-experiences.js +2 -7
- package/dist/es2019/pm-plugins/utils/has-synced-blocks.js +2 -2
- package/dist/es2019/syncedBlockPlugin.js +3 -12
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +24 -192
- package/dist/esm/nodeviews/syncedBlock.js +4 -25
- package/dist/esm/pm-plugins/main.js +65 -131
- package/dist/esm/pm-plugins/menu-and-toolbar-experiences.js +2 -7
- package/dist/esm/pm-plugins/utils/has-synced-blocks.js +2 -2
- package/dist/esm/syncedBlockPlugin.js +3 -12
- package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +1 -13
- package/dist/types/pm-plugins/main.d.ts +6 -10
- package/dist/types/pm-plugins/utils/has-synced-blocks.d.ts +2 -2
- package/dist/types/types/index.d.ts +1 -2
- package/package.json +15 -15
- package/dist/cjs/ui/BodiedSyncBlockWrapper.js +0 -25
- package/dist/es2019/ui/BodiedSyncBlockWrapper.js +0 -19
- package/dist/esm/ui/BodiedSyncBlockWrapper.js +0 -18
- package/dist/types/ui/BodiedSyncBlockWrapper.d.ts +0 -9
|
@@ -4,7 +4,6 @@ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks'
|
|
|
4
4
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
5
5
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
7
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
8
7
|
import { flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks } from './editor-actions';
|
|
9
8
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
10
9
|
import { createPlugin, syncedBlockPluginKey } from './pm-plugins/main';
|
|
@@ -36,11 +35,7 @@ const LazySyncedBlockUI = ({
|
|
|
36
35
|
var _states$syncedBlockSt;
|
|
37
36
|
return (_states$syncedBlockSt = states.syncedBlockState) === null || _states$syncedBlockSt === void 0 ? void 0 : _states$syncedBlockSt.hasSyncedBlocks;
|
|
38
37
|
});
|
|
39
|
-
|
|
40
|
-
// Use expValEqualsNoExposure here because the exposure is already fired
|
|
41
|
-
// once at plugin creation time (see syncedBlockPlugin below).
|
|
42
|
-
// This component re-renders on every transaction — avoid redundant SDK evaluations.
|
|
43
|
-
if (!hasSyncBlocks && expValEqualsNoExposure('editor_synced_block_perf', 'isEnabled', true)) {
|
|
38
|
+
if (!hasSyncBlocks) {
|
|
44
39
|
return null;
|
|
45
40
|
}
|
|
46
41
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SyncBlockRefresher, {
|
|
@@ -63,7 +58,6 @@ export const syncedBlockPlugin = ({
|
|
|
63
58
|
const refs = {};
|
|
64
59
|
const viewMode = api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode;
|
|
65
60
|
const syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, viewMode, config === null || config === void 0 ? void 0 : config.__livePage);
|
|
66
|
-
const isPerfExperimentOn = expValEquals('editor_synced_block_perf', 'isEnabled', true);
|
|
67
61
|
syncBlockStore.setFireAnalyticsEvent(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent);
|
|
68
62
|
|
|
69
63
|
// --- Memoized getSharedState (EDITOR-6929 / PR-F) ---
|
|
@@ -135,10 +129,7 @@ export const syncedBlockPlugin = ({
|
|
|
135
129
|
// When the experiment is ON and the document has no synced blocks,
|
|
136
130
|
// skip the toolbar config entirely to avoid the per-selection-change
|
|
137
131
|
// cost of findSyncBlockOrBodiedSyncBlock (EDITOR-6931).
|
|
138
|
-
|
|
139
|
-
// because floatingToolbar is called on every selection change.
|
|
140
|
-
// computing it once at plugin initialisation is more efficient.
|
|
141
|
-
if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
|
|
132
|
+
if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks)) {
|
|
142
133
|
return undefined;
|
|
143
134
|
}
|
|
144
135
|
return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
|
|
@@ -175,7 +166,7 @@ export const syncedBlockPlugin = ({
|
|
|
175
166
|
|
|
176
167
|
// --- EDITOR-6929 / PR-F: return a stable reference when all
|
|
177
168
|
// fields are unchanged to prevent unnecessary React re-renders. ---
|
|
178
|
-
if (cachedSharedState !== undefined && cachedSharedState.activeFlag === activeFlag && cachedSharedState.syncBlockStore === currentSyncBlockStore && cachedSharedState.bodiedSyncBlockDeletionStatus === bodiedSyncBlockDeletionStatus && cachedSharedState.retryCreationPosMap === retryCreationPosMap && cachedSharedState.hasSyncedBlocks === hasSyncedBlocks && cachedSharedState.hasUnsavedBodiedSyncBlockChanges === hasUnsavedBodiedSyncBlockChanges
|
|
169
|
+
if (cachedSharedState !== undefined && cachedSharedState.activeFlag === activeFlag && cachedSharedState.syncBlockStore === currentSyncBlockStore && cachedSharedState.bodiedSyncBlockDeletionStatus === bodiedSyncBlockDeletionStatus && cachedSharedState.retryCreationPosMap === retryCreationPosMap && cachedSharedState.hasSyncedBlocks === hasSyncedBlocks && cachedSharedState.hasUnsavedBodiedSyncBlockChanges === hasUnsavedBodiedSyncBlockChanges) {
|
|
179
170
|
return cachedSharedState;
|
|
180
171
|
}
|
|
181
172
|
const nextSharedState = {
|
|
@@ -1,183 +1,15 @@
|
|
|
1
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
4
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
-
import _get from "@babel/runtime/helpers/get";
|
|
6
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
7
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
8
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
9
|
-
function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
10
3
|
import React from 'react';
|
|
11
4
|
import { ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
12
5
|
import { isSSR, isSSRStreaming } from '@atlaskit/editor-common/core-utils';
|
|
13
6
|
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
14
|
-
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
15
7
|
import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
16
8
|
import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
|
|
17
9
|
import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
|
|
18
10
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
19
|
-
import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
|
|
20
11
|
import { SyncBlockLabel } from '../ui/SyncBlockLabel';
|
|
21
12
|
import { isEmptySourceSyncBlock } from './isEmptySourceSyncBlock';
|
|
22
|
-
var toDOMOld = function toDOMOld() {
|
|
23
|
-
return ['div', {
|
|
24
|
-
class: BodiedSyncBlockSharedCssClassName.content,
|
|
25
|
-
contenteditable: true
|
|
26
|
-
}, 0];
|
|
27
|
-
};
|
|
28
|
-
var BodiedSyncBlockOld = /*#__PURE__*/function (_ReactNodeView) {
|
|
29
|
-
function BodiedSyncBlockOld(props) {
|
|
30
|
-
var _this;
|
|
31
|
-
_classCallCheck(this, BodiedSyncBlockOld);
|
|
32
|
-
_this = _callSuper(this, BodiedSyncBlockOld, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
33
|
-
_this.api = props.api;
|
|
34
|
-
_this.syncBlockStore = props.syncBlockStore;
|
|
35
|
-
_this.handleConnectivityModeChange();
|
|
36
|
-
_this.handleViewModeChange();
|
|
37
|
-
return _this;
|
|
38
|
-
}
|
|
39
|
-
_inherits(BodiedSyncBlockOld, _ReactNodeView);
|
|
40
|
-
return _createClass(BodiedSyncBlockOld, [{
|
|
41
|
-
key: "updateContentEditable",
|
|
42
|
-
value: function updateContentEditable(_ref) {
|
|
43
|
-
var _this$api, _this$api2;
|
|
44
|
-
var contentDOM = _ref.contentDOM,
|
|
45
|
-
nextConnectivityMode = _ref.nextConnectivityMode,
|
|
46
|
-
nextViewMode = _ref.nextViewMode;
|
|
47
|
-
var connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api = this.api) === null || _this$api === void 0 || (_this$api = _this$api.connectivity) === null || _this$api === void 0 || (_this$api = _this$api.sharedState) === null || _this$api === void 0 || (_this$api = _this$api.currentState()) === null || _this$api === void 0 ? void 0 : _this$api.mode;
|
|
48
|
-
var viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api2 = this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.editorViewMode) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.sharedState) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.currentState()) === null || _this$api2 === void 0 ? void 0 : _this$api2.mode;
|
|
49
|
-
var isOnline = !isOfflineMode(connectivityMode);
|
|
50
|
-
var isEditMode = viewMode !== 'view';
|
|
51
|
-
var shouldBeEditable = isOnline && isEditMode;
|
|
52
|
-
contentDOM === null || contentDOM === void 0 || contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
key: "handleConnectivityModeChange",
|
|
56
|
-
value: function handleConnectivityModeChange() {
|
|
57
|
-
var _this$api3,
|
|
58
|
-
_this2 = this;
|
|
59
|
-
if ((_this$api3 = this.api) !== null && _this$api3 !== void 0 && _this$api3.connectivity) {
|
|
60
|
-
this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref2) {
|
|
61
|
-
var nextSharedState = _ref2.nextSharedState;
|
|
62
|
-
_this2.updateContentEditable({
|
|
63
|
-
contentDOM: _this2.contentDOM,
|
|
64
|
-
nextConnectivityMode: nextSharedState.mode
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}, {
|
|
70
|
-
key: "handleViewModeChange",
|
|
71
|
-
value: function handleViewModeChange() {
|
|
72
|
-
var _this$api4,
|
|
73
|
-
_this3 = this;
|
|
74
|
-
if ((_this$api4 = this.api) !== null && _this$api4 !== void 0 && _this$api4.editorViewMode) {
|
|
75
|
-
this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref3) {
|
|
76
|
-
var nextSharedState = _ref3.nextSharedState;
|
|
77
|
-
_this3.updateContentEditable({
|
|
78
|
-
contentDOM: _this3.contentDOM,
|
|
79
|
-
nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "createDomRef",
|
|
86
|
-
value: function createDomRef() {
|
|
87
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView DOM must be created against active runtime document
|
|
88
|
-
var domRef = document.createElement('div');
|
|
89
|
-
domRef.classList.add(BodiedSyncBlockSharedCssClassName.prefix);
|
|
90
|
-
domRef.classList.toggle(BodiedSyncBlockSharedCssClassName.empty, isEmptySourceSyncBlock(this.node));
|
|
91
|
-
return domRef;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Keeps the empty marker class in sync so the source placeholder can be shown purely from
|
|
96
|
-
* document state. See `isEmptySourceSyncBlock` for why the DOM is not used to decide this.
|
|
97
|
-
*/
|
|
98
|
-
}, {
|
|
99
|
-
key: "update",
|
|
100
|
-
value: function update(node, decorations) {
|
|
101
|
-
var updated = _superPropGet(BodiedSyncBlockOld, "update", this, 3)([node, decorations]);
|
|
102
|
-
if (updated) {
|
|
103
|
-
// `ReactNodeView`'s `dom` getter throws rather than returning nullish once the view is
|
|
104
|
-
// destroyed, so optional chaining here would be misleading. `super.update()` only
|
|
105
|
-
// returns true while the view is still mounted, so the ref is guaranteed.
|
|
106
|
-
this.dom.classList.toggle(BodiedSyncBlockSharedCssClassName.empty, isEmptySourceSyncBlock(this.node));
|
|
107
|
-
}
|
|
108
|
-
return updated;
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "render",
|
|
112
|
-
value: function render(_props, forwardRef) {
|
|
113
|
-
var _this$api$syncedBlock, _this$api5, _this$api6;
|
|
114
|
-
// Use passed syncBlockStore for SSR where sharedState.currentState() is delayed
|
|
115
|
-
var syncBlockStore = (_this$api$syncedBlock = (_this$api5 = this.api) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.syncedBlock.sharedState) === null || _this$api5 === void 0 || (_this$api5 = _this$api5.currentState()) === null || _this$api5 === void 0 ? void 0 : _this$api5.syncBlockStore) !== null && _this$api$syncedBlock !== void 0 ? _this$api$syncedBlock : this.syncBlockStore;
|
|
116
|
-
if (!syncBlockStore) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
120
|
-
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
121
|
-
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,
|
|
122
|
-
fallbackComponent: null
|
|
123
|
-
}, /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
|
|
124
|
-
ref: forwardRef,
|
|
125
|
-
syncBlockStore: syncBlockStore,
|
|
126
|
-
node: this.node
|
|
127
|
-
}));
|
|
128
|
-
}
|
|
129
|
-
}, {
|
|
130
|
-
key: "getContentDOM",
|
|
131
|
-
value: function getContentDOM() {
|
|
132
|
-
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView serialization must target active runtime document
|
|
133
|
-
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOMOld()),
|
|
134
|
-
dom = _DOMSerializer$render.dom,
|
|
135
|
-
contentDOM = _DOMSerializer$render.contentDOM;
|
|
136
|
-
// In SSR, the first check won't work, so fallback to nodeType check
|
|
137
|
-
if (dom instanceof HTMLElement || dom.nodeType === 1) {
|
|
138
|
-
this.updateContentEditable({
|
|
139
|
-
contentDOM: contentDOM
|
|
140
|
-
});
|
|
141
|
-
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
142
|
-
return {
|
|
143
|
-
dom: dom,
|
|
144
|
-
contentDOM: contentDOM
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return undefined;
|
|
148
|
-
}
|
|
149
|
-
}, {
|
|
150
|
-
key: "destroy",
|
|
151
|
-
value: function destroy() {
|
|
152
|
-
if (this.cleanupConnectivityModeListener) {
|
|
153
|
-
this.cleanupConnectivityModeListener();
|
|
154
|
-
}
|
|
155
|
-
if (this.cleanupViewModeListener) {
|
|
156
|
-
this.cleanupViewModeListener();
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}]);
|
|
160
|
-
}(ReactNodeView);
|
|
161
|
-
export var bodiedSyncBlockNodeViewOld = function bodiedSyncBlockNodeViewOld(_ref4) {
|
|
162
|
-
var pluginOptions = _ref4.pluginOptions,
|
|
163
|
-
pmPluginFactoryParams = _ref4.pmPluginFactoryParams,
|
|
164
|
-
api = _ref4.api,
|
|
165
|
-
syncBlockStore = _ref4.syncBlockStore;
|
|
166
|
-
return function (node, view, getPos) {
|
|
167
|
-
var portalProviderAPI = pmPluginFactoryParams.portalProviderAPI,
|
|
168
|
-
eventDispatcher = pmPluginFactoryParams.eventDispatcher;
|
|
169
|
-
return new BodiedSyncBlockOld({
|
|
170
|
-
api: api,
|
|
171
|
-
pluginOptions: pluginOptions,
|
|
172
|
-
node: node,
|
|
173
|
-
view: view,
|
|
174
|
-
getPos: getPos,
|
|
175
|
-
portalProviderAPI: portalProviderAPI,
|
|
176
|
-
eventDispatcher: eventDispatcher,
|
|
177
|
-
syncBlockStore: syncBlockStore
|
|
178
|
-
}).init();
|
|
179
|
-
};
|
|
180
|
-
};
|
|
181
13
|
var toDOM = function toDOM(node) {
|
|
182
14
|
return ['div', {
|
|
183
15
|
class: "".concat(BodiedSyncBlockSharedCssClassName.prefix, " bodiedSyncBlockView-content-wrap"),
|
|
@@ -190,7 +22,7 @@ var toDOM = function toDOM(node) {
|
|
|
190
22
|
};
|
|
191
23
|
export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
192
24
|
function BodiedSyncBlock(node, view, getPos, api, nodeViewPortalProviderAPI) {
|
|
193
|
-
var
|
|
25
|
+
var _this = this;
|
|
194
26
|
_classCallCheck(this, BodiedSyncBlock);
|
|
195
27
|
this.node = node;
|
|
196
28
|
this.view = view;
|
|
@@ -198,9 +30,9 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
198
30
|
this.api = api;
|
|
199
31
|
this.nodeViewPortalProviderAPI = nodeViewPortalProviderAPI;
|
|
200
32
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- NodeView serialization must target active runtime document
|
|
201
|
-
var _DOMSerializer$
|
|
202
|
-
dom = _DOMSerializer$
|
|
203
|
-
contentDOM = _DOMSerializer$
|
|
33
|
+
var _DOMSerializer$render = DOMSerializer.renderSpec(document, toDOM(this.node)),
|
|
34
|
+
dom = _DOMSerializer$render.dom,
|
|
35
|
+
contentDOM = _DOMSerializer$render.contentDOM;
|
|
204
36
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
205
37
|
this.dom = dom;
|
|
206
38
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
@@ -224,11 +56,11 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
224
56
|
}
|
|
225
57
|
this.labelKey = crypto.randomUUID();
|
|
226
58
|
this.nodeViewPortalProviderAPI.render(function () {
|
|
227
|
-
var
|
|
59
|
+
var _this$api;
|
|
228
60
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
229
61
|
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
230
62
|
componentId: ACTION_SUBJECT_ID.SYNCED_BLOCK_LABEL,
|
|
231
|
-
dispatchAnalyticsEvent: (
|
|
63
|
+
dispatchAnalyticsEvent: (_this$api = _this.api) === null || _this$api === void 0 || (_this$api = _this$api.analytics) === null || _this$api === void 0 ? void 0 : _this$api.actions.fireAnalyticsEvent,
|
|
232
64
|
fallbackComponent: null
|
|
233
65
|
}, /*#__PURE__*/React.createElement(SyncBlockLabel, {
|
|
234
66
|
isSource: true,
|
|
@@ -245,12 +77,12 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
245
77
|
}
|
|
246
78
|
return _createClass(BodiedSyncBlock, [{
|
|
247
79
|
key: "updateContentEditable",
|
|
248
|
-
value: function updateContentEditable(
|
|
249
|
-
var _this$
|
|
250
|
-
var nextConnectivityMode =
|
|
251
|
-
nextViewMode =
|
|
252
|
-
var connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$
|
|
253
|
-
var viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$
|
|
80
|
+
value: function updateContentEditable(_ref) {
|
|
81
|
+
var _this$api2, _this$api3;
|
|
82
|
+
var nextConnectivityMode = _ref.nextConnectivityMode,
|
|
83
|
+
nextViewMode = _ref.nextViewMode;
|
|
84
|
+
var connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api2 = this.api) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.connectivity) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.sharedState) === null || _this$api2 === void 0 || (_this$api2 = _this$api2.currentState()) === null || _this$api2 === void 0 ? void 0 : _this$api2.mode;
|
|
85
|
+
var viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api3 = this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.editorViewMode) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.sharedState) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.currentState()) === null || _this$api3 === void 0 ? void 0 : _this$api3.mode;
|
|
254
86
|
var isOnline = !isOfflineMode(connectivityMode);
|
|
255
87
|
var isEditMode = viewMode !== 'view';
|
|
256
88
|
var shouldBeEditable = isOnline && isEditMode;
|
|
@@ -259,12 +91,12 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
259
91
|
}, {
|
|
260
92
|
key: "handleConnectivityModeChange",
|
|
261
93
|
value: function handleConnectivityModeChange() {
|
|
262
|
-
var _this$
|
|
263
|
-
|
|
264
|
-
if ((_this$
|
|
265
|
-
this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (
|
|
266
|
-
var nextSharedState =
|
|
267
|
-
|
|
94
|
+
var _this$api4,
|
|
95
|
+
_this2 = this;
|
|
96
|
+
if ((_this$api4 = this.api) !== null && _this$api4 !== void 0 && _this$api4.connectivity) {
|
|
97
|
+
this.cleanupConnectivityModeListener = this.api.connectivity.sharedState.onChange(function (_ref2) {
|
|
98
|
+
var nextSharedState = _ref2.nextSharedState;
|
|
99
|
+
_this2.updateContentEditable({
|
|
268
100
|
nextConnectivityMode: nextSharedState.mode
|
|
269
101
|
});
|
|
270
102
|
});
|
|
@@ -273,12 +105,12 @@ export var BodiedSyncBlock = /*#__PURE__*/function () {
|
|
|
273
105
|
}, {
|
|
274
106
|
key: "handleViewModeChange",
|
|
275
107
|
value: function handleViewModeChange() {
|
|
276
|
-
var _this$
|
|
277
|
-
|
|
278
|
-
if ((_this$
|
|
279
|
-
this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (
|
|
280
|
-
var nextSharedState =
|
|
281
|
-
|
|
108
|
+
var _this$api5,
|
|
109
|
+
_this3 = this;
|
|
110
|
+
if ((_this$api5 = this.api) !== null && _this$api5 !== void 0 && _this$api5.editorViewMode) {
|
|
111
|
+
this.cleanupViewModeListener = this.api.editorViewMode.sharedState.onChange(function (_ref3) {
|
|
112
|
+
var nextSharedState = _ref3.nextSharedState;
|
|
113
|
+
_this3.updateContentEditable({
|
|
282
114
|
nextViewMode: nextSharedState === null || nextSharedState === void 0 ? void 0 : nextSharedState.mode
|
|
283
115
|
});
|
|
284
116
|
});
|
|
@@ -15,7 +15,6 @@ import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
|
15
15
|
import { SyncBlockSharedCssClassName, SyncBlockLabelSharedCssClassName, SyncBlockActionsProvider } from '@atlaskit/editor-common/sync-block';
|
|
16
16
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
17
17
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
18
|
-
import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
|
|
19
18
|
import { removeSyncedBlockAtPos } from '../editor-commands';
|
|
20
19
|
import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
|
|
21
20
|
import { SyncBlockSSRReactContextsProvider } from '../ui/SyncBlockSSRReactContextsProvider';
|
|
@@ -188,12 +187,7 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
188
187
|
}, {
|
|
189
188
|
key: "render",
|
|
190
189
|
value: function render(_ref) {
|
|
191
|
-
var _this$options,
|
|
192
|
-
_this$api$syncedBlock2,
|
|
193
|
-
_this$api2,
|
|
194
|
-
_this$api3,
|
|
195
|
-
_this2 = this,
|
|
196
|
-
_this$options2;
|
|
190
|
+
var _this$options, _this$api$syncedBlock2, _this$api2, _this$api3, _this$options2;
|
|
197
191
|
var getPos = _ref.getPos;
|
|
198
192
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.syncedBlockRenderer)) {
|
|
199
193
|
return null;
|
|
@@ -209,10 +203,6 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
209
203
|
return null;
|
|
210
204
|
}
|
|
211
205
|
|
|
212
|
-
// Use expValEqualsNoExposure — the exposure is already fired once at plugin
|
|
213
|
-
// creation time in syncedBlockPlugin.tsx and main.ts createPlugin().
|
|
214
|
-
var isPerfEnabled = expValEqualsNoExposure('editor_synced_block_perf', 'isEnabled', true);
|
|
215
|
-
|
|
216
206
|
// get document node from data provider
|
|
217
207
|
return /*#__PURE__*/React.createElement(SyncBlockSSRReactContextsProvider, {
|
|
218
208
|
intl: this.intl
|
|
@@ -220,20 +210,9 @@ export var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
220
210
|
component: ACTION_SUBJECT.SYNCED_BLOCK,
|
|
221
211
|
dispatchAnalyticsEvent: (_this$api3 = this.api) === null || _this$api3 === void 0 || (_this$api3 = _this$api3.analytics) === null || _this$api3 === void 0 ? void 0 : _this$api3.actions.fireAnalyticsEvent,
|
|
222
212
|
fallbackComponent: null
|
|
223
|
-
}, /*#__PURE__*/React.createElement(SyncBlockActionsProvider
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
removeSyncBlock: isPerfEnabled ? this.removeSyncBlockStable : function () {
|
|
227
|
-
var pos = getPos();
|
|
228
|
-
if (pos !== undefined) {
|
|
229
|
-
removeSyncedBlockAtPos(_this2.api, pos);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
// eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
|
|
233
|
-
,
|
|
234
|
-
fetchSyncBlockSourceInfo: isPerfEnabled ? this.fetchSyncBlockSourceInfoStable : function (sourceAri) {
|
|
235
|
-
return syncBlockStore.referenceManager.fetchSyncBlockSourceInfoBySourceAri(sourceAri);
|
|
236
|
-
}
|
|
213
|
+
}, /*#__PURE__*/React.createElement(SyncBlockActionsProvider, {
|
|
214
|
+
removeSyncBlock: this.removeSyncBlockStable,
|
|
215
|
+
fetchSyncBlockSourceInfo: this.fetchSyncBlockSourceInfoStable
|
|
237
216
|
}, /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
238
217
|
localId: localId,
|
|
239
218
|
resourceId: resourceId,
|