@atlaskit/editor-plugin-synced-block 3.9.1 → 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 CHANGED
@@ -1,5 +1,22 @@
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
+
14
+ ## 3.9.2
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 3.9.1
4
21
 
5
22
  ### 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 localId = 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.localId;
89
- if (!localId) {
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(localId);
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 _ContentComponent = require("./ui/ContentComponent");
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(_ContentComponent.ContentComponent, {
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.ContentComponent = void 0;
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 ContentComponent = exports.ContentComponent = function ContentComponent(_ref) {
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.localId);
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 localId = 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.localId;
92
- if (!localId) {
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(localId);
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 { ContentComponent } from './ui/ContentComponent';
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(ContentComponent, {
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 ContentComponent = ({
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.localId);
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 localId = 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.localId;
82
- if (!localId) {
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(localId);
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 { ContentComponent } from './ui/ContentComponent';
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(ContentComponent, {
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 ContentComponent = function ContentComponent(_ref) {
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.localId);
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 ContentComponent: ({ syncBlockStoreManager, }: {
3
+ export declare const DeleteConfirmationModal: ({ syncBlockStoreManager, }: {
4
4
  syncBlockStoreManager: SyncBlockStoreManager;
5
5
  }) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
2
+ export declare const SyncBlockRefresher: ({ syncBlockStoreManager, }: {
3
+ syncBlockStoreManager: SyncBlockStoreManager;
4
+ }) => null;
@@ -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 ContentComponent: ({ syncBlockStoreManager, }: {
3
+ export declare const DeleteConfirmationModal: ({ syncBlockStoreManager, }: {
4
4
  syncBlockStoreManager: SyncBlockStoreManager;
5
5
  }) => React.JSX.Element;
@@ -0,0 +1,4 @@
1
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
2
+ export declare const SyncBlockRefresher: ({ syncBlockStoreManager, }: {
3
+ syncBlockStoreManager: SyncBlockStoreManager;
4
+ }) => null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "3.9.1",
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,16 +38,16 @@
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.2.0",
41
+ "@atlaskit/editor-synced-block-provider": "^2.3.0",
42
42
  "@atlaskit/editor-tables": "^2.9.0",
43
- "@atlaskit/editor-toolbar": "^0.16.0",
43
+ "@atlaskit/editor-toolbar": "^0.17.0",
44
44
  "@atlaskit/icon": "28.5.3",
45
45
  "@atlaskit/modal-dialog": "^14.6.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "react-intl-next": "npm:react-intl@^5.18.1"
48
48
  },
49
49
  "peerDependencies": {
50
- "@atlaskit/editor-common": "^110.18.0",
50
+ "@atlaskit/editor-common": "^110.19.0",
51
51
  "react": "^18.2.0"
52
52
  },
53
53
  "devDependencies": {
@@ -1,68 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.townsquare.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../townsquare/tsDist/@atlaskit__editor-plugin-synced-block/app",
6
- "rootDir": "../",
7
- "composite": true
8
- },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
13
- "exclude": [
14
- "../src/**/__tests__/*",
15
- "../src/**/*.test.*",
16
- "../src/**/test.*",
17
- "../src/**/examples.*",
18
- "../src/**/examples/*",
19
- "../src/**/examples/**/*",
20
- "../src/**/*.stories.*",
21
- "../src/**/stories/*",
22
- "../src/**/stories/**/*"
23
- ],
24
- "references": [
25
- {
26
- "path": "../../../design-system/button/afm-townsquare/tsconfig.json"
27
- },
28
- {
29
- "path": "../../editor-json-transformer/afm-townsquare/tsconfig.json"
30
- },
31
- {
32
- "path": "../../editor-plugin-analytics/afm-townsquare/tsconfig.json"
33
- },
34
- {
35
- "path": "../../editor-plugin-block-menu/afm-townsquare/tsconfig.json"
36
- },
37
- {
38
- "path": "../../editor-plugin-decorations/afm-townsquare/tsconfig.json"
39
- },
40
- {
41
- "path": "../../editor-plugin-floating-toolbar/afm-townsquare/tsconfig.json"
42
- },
43
- {
44
- "path": "../../editor-plugin-selection/afm-townsquare/tsconfig.json"
45
- },
46
- {
47
- "path": "../../editor-shared-styles/afm-townsquare/tsconfig.json"
48
- },
49
- {
50
- "path": "../../editor-synced-block-provider/afm-townsquare/tsconfig.json"
51
- },
52
- {
53
- "path": "../../editor-tables/afm-townsquare/tsconfig.json"
54
- },
55
- {
56
- "path": "../../editor-toolbar/afm-townsquare/tsconfig.json"
57
- },
58
- {
59
- "path": "../../../design-system/icon/afm-townsquare/tsconfig.json"
60
- },
61
- {
62
- "path": "../../../design-system/modal-dialog/afm-townsquare/tsconfig.json"
63
- },
64
- {
65
- "path": "../../editor-common/afm-townsquare/tsconfig.json"
66
- }
67
- ]
68
- }