@atlaskit/editor-plugin-synced-block 3.9.2 → 3.10.0
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 +11 -0
- package/dist/cjs/editor-commands/index.js +3 -3
- package/dist/cjs/syncedBlockPlugin.js +6 -3
- package/dist/cjs/ui/{ContentComponent.js → DeleteConfirmationModal.js} +2 -2
- package/dist/cjs/ui/SyncBlockRefresher.js +27 -0
- package/dist/cjs/ui/floating-toolbar.js +1 -1
- package/dist/es2019/editor-commands/index.js +3 -3
- package/dist/es2019/syncedBlockPlugin.js +6 -3
- package/dist/es2019/ui/{ContentComponent.js → DeleteConfirmationModal.js} +1 -1
- package/dist/es2019/ui/SyncBlockRefresher.js +22 -0
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/esm/editor-commands/index.js +3 -3
- package/dist/esm/syncedBlockPlugin.js +6 -3
- package/dist/esm/ui/{ContentComponent.js → DeleteConfirmationModal.js} +1 -1
- package/dist/esm/ui/SyncBlockRefresher.js +21 -0
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/{types-ts4.5/ui/ContentComponent.d.ts → types/ui/DeleteConfirmationModal.d.ts} +1 -1
- package/dist/types/ui/SyncBlockRefresher.d.ts +4 -0
- package/dist/{types/ui/ContentComponent.d.ts → types-ts4.5/ui/DeleteConfirmationModal.d.ts} +1 -1
- package/dist/types-ts4.5/ui/SyncBlockRefresher.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 3.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6f9f13ab4687d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6f9f13ab4687d) -
|
|
8
|
+
EDITOR-2451 update sync-block refreshed logic based on experience principles
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
3
14
|
## 3.9.2
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
|
@@ -85,11 +85,11 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
|
|
|
85
85
|
return function (state, dispatch, _view) {
|
|
86
86
|
var _syncBlock$node;
|
|
87
87
|
var syncBlock = (0, _utils2.findSyncBlock)(state);
|
|
88
|
-
var
|
|
89
|
-
if (!
|
|
88
|
+
var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
|
|
89
|
+
if (!resourceId) {
|
|
90
90
|
return false;
|
|
91
91
|
}
|
|
92
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
92
|
+
var syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
93
93
|
if (syncBlockURL) {
|
|
94
94
|
window.open(syncBlockURL, '_blank');
|
|
95
95
|
} else {
|
|
@@ -14,8 +14,9 @@ var _editorActions = require("./editor-actions");
|
|
|
14
14
|
var _editorCommands = require("./editor-commands");
|
|
15
15
|
var _main = require("./pm-plugins/main");
|
|
16
16
|
var _blockMenuComponents = require("./ui/block-menu-components");
|
|
17
|
-
var
|
|
17
|
+
var _DeleteConfirmationModal = require("./ui/DeleteConfirmationModal");
|
|
18
18
|
var _floatingToolbar = require("./ui/floating-toolbar");
|
|
19
|
+
var _SyncBlockRefresher = require("./ui/SyncBlockRefresher");
|
|
19
20
|
var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
20
21
|
var _api$blockMenu;
|
|
21
22
|
var config = _ref.config,
|
|
@@ -86,9 +87,11 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
86
87
|
}
|
|
87
88
|
},
|
|
88
89
|
contentComponent: function contentComponent() {
|
|
89
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
90
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_SyncBlockRefresher.SyncBlockRefresher, {
|
|
90
91
|
syncBlockStoreManager: syncBlockStore
|
|
91
|
-
})
|
|
92
|
+
}), /*#__PURE__*/_react.default.createElement(_DeleteConfirmationModal.DeleteConfirmationModal, {
|
|
93
|
+
syncBlockStoreManager: syncBlockStore
|
|
94
|
+
}));
|
|
92
95
|
}
|
|
93
96
|
};
|
|
94
97
|
};
|
|
@@ -5,13 +5,13 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.DeleteConfirmationModal = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
12
12
|
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
13
13
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
-
var
|
|
14
|
+
var DeleteConfirmationModal = exports.DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
15
15
|
var syncBlockStoreManager = _ref.syncBlockStoreManager;
|
|
16
16
|
var _useState = (0, _react.useState)(false),
|
|
17
17
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SyncBlockRefresher = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var REFRESH_INTERVAL = 3000;
|
|
9
|
+
|
|
10
|
+
// Component that refreshes synced block subscriptions at regular intervals
|
|
11
|
+
// this is a workaround for the subscription mechanism not being real-time
|
|
12
|
+
var SyncBlockRefresher = exports.SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
13
|
+
var syncBlockStoreManager = _ref.syncBlockStoreManager;
|
|
14
|
+
(0, _react.useEffect)(function () {
|
|
15
|
+
var interval = window.setInterval(function () {
|
|
16
|
+
var _document;
|
|
17
|
+
// check if document is visible to avoid unnecessary refreshes
|
|
18
|
+
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
19
|
+
syncBlockStoreManager.refreshSubscriptions();
|
|
20
|
+
}
|
|
21
|
+
}, REFRESH_INTERVAL);
|
|
22
|
+
return function () {
|
|
23
|
+
window.clearInterval(interval);
|
|
24
|
+
};
|
|
25
|
+
}, [syncBlockStoreManager]);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
@@ -54,7 +54,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
54
54
|
onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(api)
|
|
55
55
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
56
56
|
items.push(copyButton);
|
|
57
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
57
|
+
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
58
58
|
if (!isBodiedSyncBlock) {
|
|
59
59
|
var editSourceButton = _objectSpread({
|
|
60
60
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -88,11 +88,11 @@ export const copySyncedBlockReferenceToClipboard = api => (state, _dispatch, _vi
|
|
|
88
88
|
export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch, _view) => {
|
|
89
89
|
var _syncBlock$node, _syncBlock$node$attrs;
|
|
90
90
|
const syncBlock = findSyncBlock(state);
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
91
|
+
const resourceId = syncBlock === null || syncBlock === void 0 ? void 0 : (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 ? void 0 : (_syncBlock$node$attrs = _syncBlock$node.attrs) === null || _syncBlock$node$attrs === void 0 ? void 0 : _syncBlock$node$attrs.resourceId;
|
|
92
|
+
if (!resourceId) {
|
|
93
93
|
return false;
|
|
94
94
|
}
|
|
95
|
-
const syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
95
|
+
const syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
96
96
|
if (syncBlockURL) {
|
|
97
97
|
window.open(syncBlockURL, '_blank');
|
|
98
98
|
} else {
|
|
@@ -7,8 +7,9 @@ import { flushBodiedSyncBlocks } from './editor-actions';
|
|
|
7
7
|
import { createSyncedBlock } from './editor-commands';
|
|
8
8
|
import { createPlugin } from './pm-plugins/main';
|
|
9
9
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
10
|
-
import {
|
|
10
|
+
import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
|
|
11
11
|
import { getToolbarConfig } from './ui/floating-toolbar';
|
|
12
|
+
import { SyncBlockRefresher } from './ui/SyncBlockRefresher';
|
|
12
13
|
export const syncedBlockPlugin = ({
|
|
13
14
|
config,
|
|
14
15
|
api
|
|
@@ -70,9 +71,11 @@ export const syncedBlockPlugin = ({
|
|
|
70
71
|
floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, config, providerFactory, api, syncBlockStore)
|
|
71
72
|
},
|
|
72
73
|
contentComponent: () => {
|
|
73
|
-
return /*#__PURE__*/React.createElement(
|
|
74
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SyncBlockRefresher, {
|
|
74
75
|
syncBlockStoreManager: syncBlockStore
|
|
75
|
-
})
|
|
76
|
+
}), /*#__PURE__*/React.createElement(DeleteConfirmationModal, {
|
|
77
|
+
syncBlockStoreManager: syncBlockStore
|
|
78
|
+
}));
|
|
76
79
|
}
|
|
77
80
|
};
|
|
78
81
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import Button from '@atlaskit/button/new';
|
|
3
3
|
import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
4
|
-
export const
|
|
4
|
+
export const DeleteConfirmationModal = ({
|
|
5
5
|
syncBlockStoreManager
|
|
6
6
|
}) => {
|
|
7
7
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
const REFRESH_INTERVAL = 3000;
|
|
3
|
+
|
|
4
|
+
// Component that refreshes synced block subscriptions at regular intervals
|
|
5
|
+
// this is a workaround for the subscription mechanism not being real-time
|
|
6
|
+
export const SyncBlockRefresher = ({
|
|
7
|
+
syncBlockStoreManager
|
|
8
|
+
}) => {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const interval = window.setInterval(() => {
|
|
11
|
+
var _document;
|
|
12
|
+
// check if document is visible to avoid unnecessary refreshes
|
|
13
|
+
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
14
|
+
syncBlockStoreManager.refreshSubscriptions();
|
|
15
|
+
}
|
|
16
|
+
}, REFRESH_INTERVAL);
|
|
17
|
+
return () => {
|
|
18
|
+
window.clearInterval(interval);
|
|
19
|
+
};
|
|
20
|
+
}, [syncBlockStoreManager]);
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
@@ -45,7 +45,7 @@ export const getToolbarConfig = (state, intl, _options = {}, _providerFactory, a
|
|
|
45
45
|
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
46
46
|
};
|
|
47
47
|
items.push(copyButton);
|
|
48
|
-
const disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
48
|
+
const disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
49
49
|
if (!isBodiedSyncBlock) {
|
|
50
50
|
const editSourceButton = {
|
|
51
51
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -78,11 +78,11 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
|
|
|
78
78
|
return function (state, dispatch, _view) {
|
|
79
79
|
var _syncBlock$node;
|
|
80
80
|
var syncBlock = findSyncBlock(state);
|
|
81
|
-
var
|
|
82
|
-
if (!
|
|
81
|
+
var resourceId = syncBlock === null || syncBlock === void 0 || (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 || (_syncBlock$node = _syncBlock$node.attrs) === null || _syncBlock$node === void 0 ? void 0 : _syncBlock$node.resourceId;
|
|
82
|
+
if (!resourceId) {
|
|
83
83
|
return false;
|
|
84
84
|
}
|
|
85
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
85
|
+
var syncBlockURL = syncBlockStore.getSyncBlockURL(resourceId);
|
|
86
86
|
if (syncBlockURL) {
|
|
87
87
|
window.open(syncBlockURL, '_blank');
|
|
88
88
|
} else {
|
|
@@ -7,8 +7,9 @@ import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks } from './editor-action
|
|
|
7
7
|
import { createSyncedBlock } from './editor-commands';
|
|
8
8
|
import { createPlugin } from './pm-plugins/main';
|
|
9
9
|
import { getBlockMenuComponents } from './ui/block-menu-components';
|
|
10
|
-
import {
|
|
10
|
+
import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
|
|
11
11
|
import { getToolbarConfig } from './ui/floating-toolbar';
|
|
12
|
+
import { SyncBlockRefresher } from './ui/SyncBlockRefresher';
|
|
12
13
|
export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
13
14
|
var _api$blockMenu;
|
|
14
15
|
var config = _ref.config,
|
|
@@ -79,9 +80,11 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
79
80
|
}
|
|
80
81
|
},
|
|
81
82
|
contentComponent: function contentComponent() {
|
|
82
|
-
return /*#__PURE__*/React.createElement(
|
|
83
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SyncBlockRefresher, {
|
|
83
84
|
syncBlockStoreManager: syncBlockStore
|
|
84
|
-
})
|
|
85
|
+
}), /*#__PURE__*/React.createElement(DeleteConfirmationModal, {
|
|
86
|
+
syncBlockStoreManager: syncBlockStore
|
|
87
|
+
}));
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
};
|
|
@@ -2,7 +2,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
2
2
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
3
|
import Button from '@atlaskit/button/new';
|
|
4
4
|
import ModalDialog, { ModalBody, ModalFooter, ModalHeader, ModalTitle, ModalTransition } from '@atlaskit/modal-dialog';
|
|
5
|
-
export var
|
|
5
|
+
export var DeleteConfirmationModal = function DeleteConfirmationModal(_ref) {
|
|
6
6
|
var syncBlockStoreManager = _ref.syncBlockStoreManager;
|
|
7
7
|
var _useState = useState(false),
|
|
8
8
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
var REFRESH_INTERVAL = 3000;
|
|
3
|
+
|
|
4
|
+
// Component that refreshes synced block subscriptions at regular intervals
|
|
5
|
+
// this is a workaround for the subscription mechanism not being real-time
|
|
6
|
+
export var SyncBlockRefresher = function SyncBlockRefresher(_ref) {
|
|
7
|
+
var syncBlockStoreManager = _ref.syncBlockStoreManager;
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
var interval = window.setInterval(function () {
|
|
10
|
+
var _document;
|
|
11
|
+
// check if document is visible to avoid unnecessary refreshes
|
|
12
|
+
if (((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible') {
|
|
13
|
+
syncBlockStoreManager.refreshSubscriptions();
|
|
14
|
+
}
|
|
15
|
+
}, REFRESH_INTERVAL);
|
|
16
|
+
return function () {
|
|
17
|
+
window.clearInterval(interval);
|
|
18
|
+
};
|
|
19
|
+
}, [syncBlockStoreManager]);
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
@@ -45,7 +45,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
|
45
45
|
onClick: copySyncedBlockReferenceToClipboard(api)
|
|
46
46
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
47
47
|
items.push(copyButton);
|
|
48
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
48
|
+
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
49
49
|
if (!isBodiedSyncBlock) {
|
|
50
50
|
var editSourceButton = _objectSpread({
|
|
51
51
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DeleteConfirmationModal: ({ syncBlockStoreManager, }: {
|
|
4
4
|
syncBlockStoreManager: SyncBlockStoreManager;
|
|
5
5
|
}) => React.JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const DeleteConfirmationModal: ({ syncBlockStoreManager, }: {
|
|
4
4
|
syncBlockStoreManager: SyncBlockStoreManager;
|
|
5
5
|
}) => React.JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.10.0",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
41
|
-
"@atlaskit/editor-synced-block-provider": "^2.
|
|
41
|
+
"@atlaskit/editor-synced-block-provider": "^2.3.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-toolbar": "^0.17.0",
|
|
44
44
|
"@atlaskit/icon": "28.5.3",
|