@atlaskit/editor-plugin-synced-block 4.6.4 → 4.7.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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 4.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.7.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`82d57d01a0f61`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/82d57d01a0f61) -
14
+ Distinguish between collab offline and internet offline cases for connectivity mode
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 4.6.4
4
21
 
5
22
  ### Patch Changes
@@ -13,6 +13,7 @@ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits
13
13
  var _react = _interopRequireDefault(require("react"));
14
14
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
15
15
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
16
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
16
17
  var _model = require("@atlaskit/editor-prosemirror/model");
17
18
  var _BodiedSyncBlockWrapper = require("../ui/BodiedSyncBlockWrapper");
18
19
  function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
@@ -43,7 +44,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
43
44
  nextViewMode = _ref.nextViewMode;
44
45
  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;
45
46
  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;
46
- var isOnline = connectivityMode !== 'offline';
47
+ var isOnline = !(0, _editorPluginConnectivity.isOfflineMode)(connectivityMode);
47
48
  var isEditMode = viewMode !== 'view';
48
49
  var shouldBeEditable = isOnline && isEditMode;
49
50
  contentDOM === null || contentDOM === void 0 || contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
@@ -10,6 +10,7 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _selection = require("@atlaskit/editor-common/selection");
11
11
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
13
14
  var _state = require("@atlaskit/editor-prosemirror/state");
14
15
  var _view = require("@atlaskit/editor-prosemirror/view");
15
16
  var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
@@ -96,7 +97,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
96
97
  var _syncedBlockPluginKey, _syncedBlockPluginKey2, _api$connectivity, _api$editorViewMode;
97
98
  var selectionDecorationSet = (_syncedBlockPluginKey = (_syncedBlockPluginKey2 = syncedBlockPluginKey.getState(state)) === null || _syncedBlockPluginKey2 === void 0 ? void 0 : _syncedBlockPluginKey2.selectionDecorationSet) !== null && _syncedBlockPluginKey !== void 0 ? _syncedBlockPluginKey : _view.DecorationSet.empty;
98
99
  var doc = state.doc;
99
- var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
100
+ var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode);
100
101
  var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
101
102
  var offlineDecorations = [];
102
103
  var viewModeDecorations = [];
@@ -165,7 +166,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
165
166
  },
166
167
  filterTransaction: function filterTransaction(tr, state) {
167
168
  var _api$connectivity2;
168
- var isOffline = (api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode) === 'offline';
169
+ var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
169
170
  var isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
170
171
  // Ignore transactions that don't change the document
171
172
  // or are from remote (collab) or already confirmed sync block deletion
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
13
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
15
  var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
15
16
  var _utils = require("../pm-plugins/utils/utils");
@@ -31,7 +32,7 @@ var CreateSyncedBlockButton = exports.CreateSyncedBlockButton = function CreateS
31
32
  // and converting existing block to synced block
32
33
  var canBeConverted = Boolean(selection && (0, _utils.canBeConvertedToSyncBlock)(selection));
33
34
  var canInsertEmptyBlock = Boolean(selection === null || selection === void 0 ? void 0 : selection.empty);
34
- var isDisabled = Boolean(mode === 'offline' || !canBeConverted && !canInsertEmptyBlock);
35
+ var isDisabled = Boolean((0, _editorPluginConnectivity.isOfflineMode)(mode) || !canBeConverted && !canInsertEmptyBlock);
35
36
  var onClick = (0, _react.useCallback)(function () {
36
37
  var _api$core, _api$core2;
37
38
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
@@ -10,6 +10,7 @@ var _react = _interopRequireWildcard(require("react"));
10
10
  var _reactIntlNext = require("react-intl-next");
11
11
  var _hooks = require("@atlaskit/editor-common/hooks");
12
12
  var _messages = require("@atlaskit/editor-common/messages");
13
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
13
14
  var _editorToolbar = require("@atlaskit/editor-toolbar");
14
15
  var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
15
16
  var _utils = require("../pm-plugins/utils/utils");
@@ -43,7 +44,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
43
44
  closeMenu: true
44
45
  }));
45
46
  };
46
- var isOffline = mode === 'offline';
47
+ var isOffline = (0, _editorPluginConnectivity.isOfflineMode)(mode);
47
48
  return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
48
49
  elemBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.SyncBlocksIcon, {
49
50
  label: ""
@@ -78,7 +79,7 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
78
79
  label: ""
79
80
  }),
80
81
  onClick: onClick,
81
- isDisabled: mode === 'offline',
82
+ isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
82
83
  elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
83
84
  appearance: "new"
84
85
  }, formatMessage(_messages.blockMenuMessages.newLozenge))
@@ -12,6 +12,7 @@ var _reactIntlNext = require("react-intl-next");
12
12
  var _new = _interopRequireDefault(require("@atlaskit/button/new"));
13
13
  var _hooks = require("@atlaskit/editor-common/hooks");
14
14
  var _messages = require("@atlaskit/editor-common/messages");
15
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
15
16
  var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
16
17
  var _compiled = require("@atlaskit/primitives/compiled");
17
18
  var _main = require("../pm-plugins/main");
@@ -115,7 +116,7 @@ var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteC
115
116
  appearance: "warning",
116
117
  onClick: handleClick(true),
117
118
  autoFocus: true,
118
- isDisabled: mode === 'offline',
119
+ isDisabled: (0, _editorPluginConnectivity.isOfflineMode)(mode),
119
120
  isLoading: bodiedSyncBlockDeletionStatus === 'processing'
120
121
  }, formatMessage(_messages.syncBlockMessages.deleteConfirmationModalDeleteButton)))));
121
122
  };
@@ -11,6 +11,7 @@ var _react = _interopRequireDefault(require("react"));
11
11
  var _reactIntlNext = require("react-intl-next");
12
12
  var _hooks = require("@atlaskit/editor-common/hooks");
13
13
  var _messages = require("@atlaskit/editor-common/messages");
14
+ var _editorPluginConnectivity = require("@atlaskit/editor-plugin-connectivity");
14
15
  var _flag = _interopRequireWildcard(require("@atlaskit/flag"));
15
16
  var _image = _interopRequireDefault(require("@atlaskit/icon/core/image"));
16
17
  var _statusWarning = _interopRequireDefault(require("@atlaskit/icon/core/status-warning"));
@@ -66,7 +67,7 @@ var Flag = exports.Flag = function Flag(_ref) {
66
67
  onDismissedCallback = activeFlag.onDismissed;
67
68
 
68
69
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
69
- if (mode === 'offline' && !!onRetry) {
70
+ if ((0, _editorPluginConnectivity.isOfflineMode)(mode) && !!onRetry) {
70
71
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
71
72
  var tr = _ref2.tr;
72
73
  tr.setMeta(_main.syncedBlockPluginKey, {
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
3
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
4
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
4
5
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
5
6
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
6
7
  const toDOM = () => ['div', {
@@ -22,7 +23,7 @@ class BodiedSyncBlock extends ReactNodeView {
22
23
  var _this$api, _this$api$connectivit, _this$api$connectivit2, _this$api$connectivit3, _this$api2, _this$api2$editorView, _this$api2$editorView2, _this$api2$editorView3;
23
24
  const connectivityMode = nextConnectivityMode !== null && nextConnectivityMode !== void 0 ? nextConnectivityMode : (_this$api = this.api) === null || _this$api === void 0 ? void 0 : (_this$api$connectivit = _this$api.connectivity) === null || _this$api$connectivit === void 0 ? void 0 : (_this$api$connectivit2 = _this$api$connectivit.sharedState) === null || _this$api$connectivit2 === void 0 ? void 0 : (_this$api$connectivit3 = _this$api$connectivit2.currentState()) === null || _this$api$connectivit3 === void 0 ? void 0 : _this$api$connectivit3.mode;
24
25
  const viewMode = nextViewMode !== null && nextViewMode !== void 0 ? nextViewMode : (_this$api2 = this.api) === null || _this$api2 === void 0 ? void 0 : (_this$api2$editorView = _this$api2.editorViewMode) === null || _this$api2$editorView === void 0 ? void 0 : (_this$api2$editorView2 = _this$api2$editorView.sharedState) === null || _this$api2$editorView2 === void 0 ? void 0 : (_this$api2$editorView3 = _this$api2$editorView2.currentState()) === null || _this$api2$editorView3 === void 0 ? void 0 : _this$api2$editorView3.mode;
25
- const isOnline = connectivityMode !== 'offline';
26
+ const isOnline = !isOfflineMode(connectivityMode);
26
27
  const isEditMode = viewMode !== 'view';
27
28
  const shouldBeEditable = isOnline && isEditMode;
28
29
  contentDOM === null || contentDOM === void 0 ? void 0 : contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
@@ -2,6 +2,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
2
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
3
3
  import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
4
4
  import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
7
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
7
8
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
@@ -86,7 +87,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
86
87
  const {
87
88
  doc
88
89
  } = state;
89
- const isOffline = (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) === 'offline';
90
+ const isOffline = 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);
90
91
  const isViewMode = (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) === 'view';
91
92
  const offlineDecorations = [];
92
93
  const viewModeDecorations = [];
@@ -157,7 +158,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
157
158
  },
158
159
  filterTransaction: (tr, state) => {
159
160
  var _api$connectivity2, _api$connectivity2$sh;
160
- const isOffline = (api === null || api === void 0 ? void 0 : (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 ? void 0 : (_api$connectivity2$sh = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2$sh === void 0 ? void 0 : _api$connectivity2$sh.mode) === 'offline';
161
+ const isOffline = isOfflineMode(api === null || api === void 0 ? void 0 : (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 ? void 0 : (_api$connectivity2$sh = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2$sh === void 0 ? void 0 : _api$connectivity2$sh.mode);
161
162
  const isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
162
163
  // Ignore transactions that don't change the document
163
164
  // or are from remote (collab) or already confirmed sync block deletion
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { syncBlockMessages } from '@atlaskit/editor-common/messages';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import { ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
6
7
  import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
7
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
@@ -24,7 +25,7 @@ export const CreateSyncedBlockButton = ({
24
25
  // and converting existing block to synced block
25
26
  const canBeConverted = Boolean(selection && canBeConvertedToSyncBlock(selection));
26
27
  const canInsertEmptyBlock = Boolean(selection === null || selection === void 0 ? void 0 : selection.empty);
27
- const isDisabled = Boolean(mode === 'offline' || !canBeConverted && !canInsertEmptyBlock);
28
+ const isDisabled = Boolean(isOfflineMode(mode) || !canBeConverted && !canInsertEmptyBlock);
28
29
  const onClick = useCallback(() => {
29
30
  var _api$core, _api$core2;
30
31
  api === null || api === void 0 ? void 0 : (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(({
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
7
  import Lozenge from '@atlaskit/lozenge';
7
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
@@ -35,7 +36,7 @@ const CreateSyncedBlockDropdownItem = ({
35
36
  closeMenu: true
36
37
  }));
37
38
  };
38
- const isOffline = mode === 'offline';
39
+ const isOffline = isOfflineMode(mode);
39
40
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
40
41
  elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
41
42
  label: ""
@@ -73,7 +74,7 @@ const CopySyncedBlockDropdownItem = ({
73
74
  label: ""
74
75
  }),
75
76
  onClick: onClick,
76
- isDisabled: mode === 'offline',
77
+ isDisabled: isOfflineMode(mode),
77
78
  elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
78
79
  appearance: "new"
79
80
  }, formatMessage(blockMenuMessages.newLozenge))
@@ -3,6 +3,7 @@ import { useIntl } from 'react-intl-next';
3
3
  import Button from '@atlaskit/button/new';
4
4
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
5
5
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
6
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
6
7
  import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
7
8
  import { Text } from '@atlaskit/primitives/compiled';
8
9
  import { syncedBlockPluginKey } from '../pm-plugins/main';
@@ -103,7 +104,7 @@ export const DeleteConfirmationModal = ({
103
104
  appearance: "warning",
104
105
  onClick: handleClick(true),
105
106
  autoFocus: true,
106
- isDisabled: mode === 'offline',
107
+ isDisabled: isOfflineMode(mode),
107
108
  isLoading: bodiedSyncBlockDeletionStatus === 'processing'
108
109
  }, formatMessage(messages.deleteConfirmationModalDeleteButton)))));
109
110
  };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
6
7
  import ImageIcon from '@atlaskit/icon/core/image';
7
8
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
@@ -66,7 +67,7 @@ export const Flag = ({
66
67
  } = activeFlag;
67
68
 
68
69
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
69
- if (mode === 'offline' && !!onRetry) {
70
+ if (isOfflineMode(mode) && !!onRetry) {
70
71
  api === null || api === void 0 ? void 0 : api.core.actions.execute(({
71
72
  tr
72
73
  }) => {
@@ -8,6 +8,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
8
8
  import React from 'react';
9
9
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
10
10
  import { BodiedSyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
11
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
11
12
  import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
12
13
  import { BodiedSyncBlockWrapper } from '../ui/BodiedSyncBlockWrapper';
13
14
  var toDOM = function toDOM() {
@@ -36,7 +37,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
36
37
  nextViewMode = _ref.nextViewMode;
37
38
  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;
38
39
  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;
39
- var isOnline = connectivityMode !== 'offline';
40
+ var isOnline = !isOfflineMode(connectivityMode);
40
41
  var isEditMode = viewMode !== 'view';
41
42
  var shouldBeEditable = isOnline && isEditMode;
42
43
  contentDOM === null || contentDOM === void 0 || contentDOM.setAttribute('contenteditable', shouldBeEditable ? 'true' : 'false');
@@ -8,6 +8,7 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
8
  import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
9
9
  import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
10
10
  import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
11
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
11
12
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
12
13
  import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
13
14
  import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
@@ -89,7 +90,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
89
90
  var _syncedBlockPluginKey, _syncedBlockPluginKey2, _api$connectivity, _api$editorViewMode;
90
91
  var selectionDecorationSet = (_syncedBlockPluginKey = (_syncedBlockPluginKey2 = syncedBlockPluginKey.getState(state)) === null || _syncedBlockPluginKey2 === void 0 ? void 0 : _syncedBlockPluginKey2.selectionDecorationSet) !== null && _syncedBlockPluginKey !== void 0 ? _syncedBlockPluginKey : DecorationSet.empty;
91
92
  var doc = state.doc;
92
- var isOffline = (api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode) === 'offline';
93
+ var isOffline = isOfflineMode(api === null || api === void 0 || (_api$connectivity = api.connectivity) === null || _api$connectivity === void 0 || (_api$connectivity = _api$connectivity.sharedState.currentState()) === null || _api$connectivity === void 0 ? void 0 : _api$connectivity.mode);
93
94
  var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
94
95
  var offlineDecorations = [];
95
96
  var viewModeDecorations = [];
@@ -158,7 +159,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
158
159
  },
159
160
  filterTransaction: function filterTransaction(tr, state) {
160
161
  var _api$connectivity2;
161
- var isOffline = (api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode) === 'offline';
162
+ var isOffline = isOfflineMode(api === null || api === void 0 || (_api$connectivity2 = api.connectivity) === null || _api$connectivity2 === void 0 || (_api$connectivity2 = _api$connectivity2.sharedState.currentState()) === null || _api$connectivity2 === void 0 ? void 0 : _api$connectivity2.mode);
162
163
  var isConfirmedSyncBlockDeletion = Boolean(tr.getMeta('isConfirmedSyncBlockDeletion'));
163
164
  // Ignore transactions that don't change the document
164
165
  // or are from remote (collab) or already confirmed sync block deletion
@@ -2,6 +2,7 @@ import React, { useCallback } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { syncBlockMessages } from '@atlaskit/editor-common/messages';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import { ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
6
7
  import BlockSyncedIcon from '@atlaskit/icon-lab/core/block-synced';
7
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
@@ -22,7 +23,7 @@ export var CreateSyncedBlockButton = function CreateSyncedBlockButton(_ref) {
22
23
  // and converting existing block to synced block
23
24
  var canBeConverted = Boolean(selection && canBeConvertedToSyncBlock(selection));
24
25
  var canInsertEmptyBlock = Boolean(selection === null || selection === void 0 ? void 0 : selection.empty);
25
- var isDisabled = Boolean(mode === 'offline' || !canBeConverted && !canInsertEmptyBlock);
26
+ var isDisabled = Boolean(isOfflineMode(mode) || !canBeConverted && !canInsertEmptyBlock);
26
27
  var onClick = useCallback(function () {
27
28
  var _api$core, _api$core2;
28
29
  api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
@@ -2,6 +2,7 @@ import React, { useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
5
6
  import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
6
7
  import Lozenge from '@atlaskit/lozenge';
7
8
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
@@ -34,7 +35,7 @@ var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref)
34
35
  closeMenu: true
35
36
  }));
36
37
  };
37
- var isOffline = mode === 'offline';
38
+ var isOffline = isOfflineMode(mode);
38
39
  return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
39
40
  elemBefore: /*#__PURE__*/React.createElement(SyncBlocksIcon, {
40
41
  label: ""
@@ -69,7 +70,7 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
69
70
  label: ""
70
71
  }),
71
72
  onClick: onClick,
72
- isDisabled: mode === 'offline',
73
+ isDisabled: isOfflineMode(mode),
73
74
  elemAfter: /*#__PURE__*/React.createElement(Lozenge, {
74
75
  appearance: "new"
75
76
  }, formatMessage(blockMenuMessages.newLozenge))
@@ -4,6 +4,7 @@ import { useIntl } from 'react-intl-next';
4
4
  import Button from '@atlaskit/button/new';
5
5
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
6
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
7
8
  import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
8
9
  import { Text } from '@atlaskit/primitives/compiled';
9
10
  import { syncedBlockPluginKey } from '../pm-plugins/main';
@@ -106,7 +107,7 @@ export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
106
107
  appearance: "warning",
107
108
  onClick: handleClick(true),
108
109
  autoFocus: true,
109
- isDisabled: mode === 'offline',
110
+ isDisabled: isOfflineMode(mode),
110
111
  isLoading: bodiedSyncBlockDeletionStatus === 'processing'
111
112
  }, formatMessage(messages.deleteConfirmationModalDeleteButton)))));
112
113
  };
@@ -5,6 +5,7 @@ import React from 'react';
5
5
  import { useIntl } from 'react-intl-next';
6
6
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
7
7
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
8
+ import { isOfflineMode } from '@atlaskit/editor-plugin-connectivity';
8
9
  import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
9
10
  import ImageIcon from '@atlaskit/icon/core/image';
10
11
  import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
@@ -57,7 +58,7 @@ export var Flag = function Flag(_ref) {
57
58
  onDismissedCallback = activeFlag.onDismissed;
58
59
 
59
60
  // Retry button often involves network request, hence we dismiss the flag in offline mode to avoid retry
60
- if (mode === 'offline' && !!onRetry) {
61
+ if (isOfflineMode(mode) && !!onRetry) {
61
62
  api === null || api === void 0 || api.core.actions.execute(function (_ref2) {
62
63
  var tr = _ref2.tr;
63
64
  tr.setMeta(syncedBlockPluginKey, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "4.6.4",
3
+ "version": "4.7.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,11 +29,11 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.5.0",
32
- "@atlaskit/button": "23.9.1",
32
+ "@atlaskit/button": "23.9.2",
33
33
  "@atlaskit/editor-json-transformer": "^8.31.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^6.2.0",
35
35
  "@atlaskit/editor-plugin-block-menu": "^5.2.0",
36
- "@atlaskit/editor-plugin-connectivity": "6.0.0",
36
+ "@atlaskit/editor-plugin-connectivity": "6.1.0",
37
37
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
38
38
  "@atlaskit/editor-plugin-floating-toolbar": "^8.3.0",
39
39
  "@atlaskit/editor-plugin-selection": "^6.1.0",