@atlaskit/editor-plugin-synced-block 3.8.1 → 3.8.2

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,13 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 3.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`62d0954696c7e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/62d0954696c7e) -
8
+ [ux] EDITOR-1648 handle permission denied, not found and any generic error for sync block
9
+ - Updated dependencies
10
+
3
11
  ## 3.8.1
4
12
 
5
13
  ### Patch Changes
@@ -19,17 +19,6 @@ var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
19
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)); }
20
20
  function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
21
  function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
22
- var defaultSyncBlockRendererDocument = {
23
- version: 1,
24
- type: 'doc',
25
- content: [{
26
- type: 'paragraph',
27
- content: [{
28
- type: 'text',
29
- text: 'This is a reference sync block. Stay tuned for updates...'
30
- }]
31
- }]
32
- };
33
22
  var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
34
23
  function SyncBlock(props) {
35
24
  var _this;
@@ -60,8 +49,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
60
49
  // get document node from data provider
61
50
 
62
51
  return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
63
- useFetchDocNode: function useFetchDocNode() {
64
- return (0, _editorSyncedBlockProvider.useFetchDocNode)(_this2.syncBlockStore, _this2.node, defaultSyncBlockRendererDocument);
52
+ useFetchSyncBlockData: function useFetchSyncBlockData() {
53
+ return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(_this2.syncBlockStore, _this2.node);
65
54
  },
66
55
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
67
56
  });
@@ -8,7 +8,8 @@ exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSynced
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _copyButton = require("@atlaskit/editor-common/copy-button");
11
- var _utils = require("./utils/utils");
11
+ var _utils = require("@atlaskit/editor-prosemirror/utils");
12
+ var _utils2 = require("./utils/utils");
12
13
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
14
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
15
  var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_ref) {
@@ -33,7 +34,7 @@ var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(_
33
34
  tr = tr.replaceSelectionWith(newBodiedSyncBlockNode).scrollIntoView();
34
35
  }
35
36
  } else {
36
- var conversionInfo = (0, _utils.canBeConvertedToSyncBlock)(tr.selection);
37
+ var conversionInfo = (0, _utils2.canBeConvertedToSyncBlock)(tr.selection);
37
38
  if (!conversionInfo) {
38
39
  // TODO: EDITOR-1665 - Raise an error analytics event
39
40
  return false;
@@ -53,11 +54,11 @@ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClip
53
54
  if (!(api !== null && api !== void 0 && api.floatingToolbar)) {
54
55
  return false;
55
56
  }
56
- var syncBlockFindResult = (0, _utils.findSyncBlockOrBodiedSyncBlock)(state);
57
+ var syncBlockFindResult = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state);
57
58
  if (!syncBlockFindResult) {
58
59
  return false;
59
60
  }
60
- var isBodiedSyncBlock = (0, _utils.isBodiedSyncBlockNode)(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
61
+ var isBodiedSyncBlock = (0, _utils2.isBodiedSyncBlockNode)(syncBlockFindResult.node, state.schema.nodes.bodiedSyncBlock);
61
62
  var referenceSyncBlockNode = null;
62
63
  if (isBodiedSyncBlock) {
63
64
  var syncBlock = state.tr.doc.type.schema.nodes.syncBlock;
@@ -83,7 +84,7 @@ var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClip
83
84
  var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
84
85
  return function (state, dispatch, _view) {
85
86
  var _syncBlock$node;
86
- var syncBlock = (0, _utils.findSyncBlock)(state);
87
+ var syncBlock = (0, _utils2.findSyncBlock)(state);
87
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;
88
89
  if (!localId) {
89
90
  return false;
@@ -110,16 +111,21 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
110
111
  };
111
112
  var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(api) {
112
113
  return function (state, dispatch, _view) {
113
- var tr = state.tr;
114
- var syncBlockFindResult = (0, _utils.findSyncBlockOrBodiedSyncBlock)(state);
115
- if (!syncBlockFindResult) {
114
+ var nodes = state.schema.nodes,
115
+ tr = state.tr;
116
+ if (!dispatch) {
116
117
  return false;
117
118
  }
118
- var newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
119
- if (!newTr) {
119
+ var removeTr = tr;
120
+ if ((0, _utils.findSelectedNodeOfType)(nodes.syncBlock)(tr.selection) || (0, _utils.findSelectedNodeOfType)(nodes.bodiedSyncBlock)(tr.selection)) {
121
+ removeTr = (0, _utils.removeSelectedNode)(tr);
122
+ } else {
123
+ removeTr = (0, _utils.removeParentNodeOfType)(nodes.bodiedSyncBlock)(tr);
124
+ }
125
+ if (!removeTr) {
120
126
  return false;
121
127
  }
122
- dispatch === null || dispatch === void 0 || dispatch(newTr);
128
+ dispatch(removeTr);
123
129
  api === null || api === void 0 || api.core.actions.focus();
124
130
  return true;
125
131
  };
@@ -9,14 +9,10 @@ var _state = require("@atlaskit/editor-prosemirror/state");
9
9
  var _bodiedLazySyncedBlock = require("../nodeviews/bodiedLazySyncedBlock");
10
10
  var _lazySyncedBlock = require("../nodeviews/lazySyncedBlock");
11
11
  var _trackSyncBlocks2 = require("./utils/track-sync-blocks");
12
- var _utils = require("./utils/utils");
13
12
  var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
14
13
 
15
14
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
16
15
 
17
- function isInsideBodiedSyncBlock(state, selection) {
18
- return (0, _utils.findBodiedSyncBlock)(state, selection) !== undefined;
19
- }
20
16
  var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
21
17
  return new _safePlugin.SafePlugin({
22
18
  key: syncedBlockPluginKey,
@@ -46,17 +42,6 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
46
42
  api: api,
47
43
  syncBlockStore: syncBlockStore
48
44
  })
49
- },
50
- handleKeyDown: function handleKeyDown(view, event) {
51
- if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
52
- event.preventDefault();
53
- // Insert a new paragraph instead of letting browser handle it
54
- var tr = view.state.tr;
55
- tr.split(view.state.selection.from);
56
- view.dispatch(tr);
57
- return true;
58
- }
59
- return false;
60
45
  }
61
46
  },
62
47
  view: function view(editorView) {
@@ -11,14 +11,14 @@ var _SyncBlockLabel = require("./SyncBlockLabel");
11
11
  var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
12
12
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
13
13
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
14
- useFetchDocNode = _ref.useFetchDocNode;
14
+ useFetchSyncBlockData = _ref.useFetchSyncBlockData;
15
15
  return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, null), /*#__PURE__*/_react.default.createElement("div", {
16
16
  "data-testid": SyncBlockRendererWrapperDataId
17
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
18
18
  ,
19
19
  className: _syncBlock.SyncBlockSharedCssClassName.renderer
20
20
  }, getSyncedBlockRenderer({
21
- useFetchDocNode: useFetchDocNode
21
+ useFetchSyncBlockData: useFetchSyncBlockData
22
22
  })));
23
23
  };
24
24
  var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);
@@ -1,19 +1,8 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
3
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
4
- import { useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
4
+ import { useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
5
5
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
6
- const defaultSyncBlockRendererDocument = {
7
- version: 1,
8
- type: 'doc',
9
- content: [{
10
- type: 'paragraph',
11
- content: [{
12
- type: 'text',
13
- text: 'This is a reference sync block. Stay tuned for updates...'
14
- }]
15
- }]
16
- };
17
6
  class SyncBlock extends ReactNodeView {
18
7
  constructor(props) {
19
8
  super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
@@ -34,7 +23,7 @@ class SyncBlock extends ReactNodeView {
34
23
  // get document node from data provider
35
24
 
36
25
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
37
- useFetchDocNode: () => useFetchDocNode(this.syncBlockStore, this.node, defaultSyncBlockRendererDocument),
26
+ useFetchSyncBlockData: () => useFetchSyncBlockData(this.syncBlockStore, this.node),
38
27
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
39
28
  });
40
29
  }
@@ -1,5 +1,6 @@
1
1
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
2
2
  import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
3
+ import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
3
4
  import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from './utils/utils';
4
5
  export const createSyncedBlock = ({
5
6
  tr,
@@ -111,16 +112,25 @@ export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch,
111
112
  return true;
112
113
  };
113
114
  export const removeSyncedBlock = api => (state, dispatch, _view) => {
114
- const tr = state.tr;
115
- const syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
116
- if (!syncBlockFindResult) {
115
+ const {
116
+ schema: {
117
+ nodes
118
+ },
119
+ tr
120
+ } = state;
121
+ if (!dispatch) {
117
122
  return false;
118
123
  }
119
- const newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
120
- if (!newTr) {
124
+ let removeTr = tr;
125
+ if (findSelectedNodeOfType(nodes.syncBlock)(tr.selection) || findSelectedNodeOfType(nodes.bodiedSyncBlock)(tr.selection)) {
126
+ removeTr = removeSelectedNode(tr);
127
+ } else {
128
+ removeTr = removeParentNodeOfType(nodes.bodiedSyncBlock)(tr);
129
+ }
130
+ if (!removeTr) {
121
131
  return false;
122
132
  }
123
- dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
133
+ dispatch(removeTr);
124
134
  api === null || api === void 0 ? void 0 : api.core.actions.focus();
125
135
  return true;
126
136
  };
@@ -3,14 +3,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
4
4
  import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
5
5
  import { trackSyncBlocks } from './utils/track-sync-blocks';
6
- import { findBodiedSyncBlock } from './utils/utils';
7
6
  export const syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
8
7
 
9
8
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
10
9
 
11
- function isInsideBodiedSyncBlock(state, selection) {
12
- return findBodiedSyncBlock(state, selection) !== undefined;
13
- }
14
10
  export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
15
11
  return new SafePlugin({
16
12
  key: syncedBlockPluginKey,
@@ -40,17 +36,6 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
40
36
  api,
41
37
  syncBlockStore
42
38
  })
43
- },
44
- handleKeyDown: (view, event) => {
45
- if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
46
- event.preventDefault();
47
- // Insert a new paragraph instead of letting browser handle it
48
- const tr = view.state.tr;
49
- tr.split(view.state.selection.from);
50
- view.dispatch(tr);
51
- return true;
52
- }
53
- return false;
54
39
  }
55
40
  },
56
41
  view: editorView => {
@@ -4,7 +4,7 @@ import { SyncBlockLabel } from './SyncBlockLabel';
4
4
  const SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
5
5
  const SyncBlockRendererWrapperComponent = ({
6
6
  getSyncedBlockRenderer,
7
- useFetchDocNode
7
+ useFetchSyncBlockData
8
8
  }) => {
9
9
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
10
10
  "data-testid": SyncBlockRendererWrapperDataId
@@ -12,7 +12,7 @@ const SyncBlockRendererWrapperComponent = ({
12
12
  ,
13
13
  className: SyncBlockSharedCssClassName.renderer
14
14
  }, getSyncedBlockRenderer({
15
- useFetchDocNode
15
+ useFetchSyncBlockData
16
16
  })));
17
17
  };
18
18
  export const SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
@@ -10,19 +10,8 @@ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prot
10
10
  import React from 'react';
11
11
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
12
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
13
- import { useFetchDocNode as _useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
13
+ import { useFetchSyncBlockData as _useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
14
14
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
15
- var defaultSyncBlockRendererDocument = {
16
- version: 1,
17
- type: 'doc',
18
- content: [{
19
- type: 'paragraph',
20
- content: [{
21
- type: 'text',
22
- text: 'This is a reference sync block. Stay tuned for updates...'
23
- }]
24
- }]
25
- };
26
15
  var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
27
16
  function SyncBlock(props) {
28
17
  var _this;
@@ -53,8 +42,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
53
42
  // get document node from data provider
54
43
 
55
44
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
56
- useFetchDocNode: function useFetchDocNode() {
57
- return _useFetchDocNode(_this2.syncBlockStore, _this2.node, defaultSyncBlockRendererDocument);
45
+ useFetchSyncBlockData: function useFetchSyncBlockData() {
46
+ return _useFetchSyncBlockData(_this2.syncBlockStore, _this2.node);
58
47
  },
59
48
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
60
49
  });
@@ -3,6 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
4
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
5
5
  import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
6
+ import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
6
7
  import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from './utils/utils';
7
8
  export var createSyncedBlock = function createSyncedBlock(_ref) {
8
9
  var tr = _ref.tr,
@@ -103,16 +104,21 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
103
104
  };
104
105
  export var removeSyncedBlock = function removeSyncedBlock(api) {
105
106
  return function (state, dispatch, _view) {
106
- var tr = state.tr;
107
- var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(state);
108
- if (!syncBlockFindResult) {
107
+ var nodes = state.schema.nodes,
108
+ tr = state.tr;
109
+ if (!dispatch) {
109
110
  return false;
110
111
  }
111
- var newTr = tr.deleteRange(syncBlockFindResult.pos, syncBlockFindResult.pos + syncBlockFindResult.node.nodeSize);
112
- if (!newTr) {
112
+ var removeTr = tr;
113
+ if (findSelectedNodeOfType(nodes.syncBlock)(tr.selection) || findSelectedNodeOfType(nodes.bodiedSyncBlock)(tr.selection)) {
114
+ removeTr = removeSelectedNode(tr);
115
+ } else {
116
+ removeTr = removeParentNodeOfType(nodes.bodiedSyncBlock)(tr);
117
+ }
118
+ if (!removeTr) {
113
119
  return false;
114
120
  }
115
- dispatch === null || dispatch === void 0 || dispatch(newTr);
121
+ dispatch(removeTr);
116
122
  api === null || api === void 0 || api.core.actions.focus();
117
123
  return true;
118
124
  };
@@ -3,14 +3,10 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
3
  import { lazyBodiedSyncBlockView } from '../nodeviews/bodiedLazySyncedBlock';
4
4
  import { lazySyncBlockView } from '../nodeviews/lazySyncedBlock';
5
5
  import { trackSyncBlocks } from './utils/track-sync-blocks';
6
- import { findBodiedSyncBlock } from './utils/utils';
7
6
  export var syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
8
7
 
9
8
  // eslint-disable-next-line @typescript-eslint/no-empty-object-type
10
9
 
11
- function isInsideBodiedSyncBlock(state, selection) {
12
- return findBodiedSyncBlock(state, selection) !== undefined;
13
- }
14
10
  export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
15
11
  return new SafePlugin({
16
12
  key: syncedBlockPluginKey,
@@ -40,17 +36,6 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
40
36
  api: api,
41
37
  syncBlockStore: syncBlockStore
42
38
  })
43
- },
44
- handleKeyDown: function handleKeyDown(view, event) {
45
- if (event.key === 'Enter' && isInsideBodiedSyncBlock(view.state, view.state.selection)) {
46
- event.preventDefault();
47
- // Insert a new paragraph instead of letting browser handle it
48
- var tr = view.state.tr;
49
- tr.split(view.state.selection.from);
50
- view.dispatch(tr);
51
- return true;
52
- }
53
- return false;
54
39
  }
55
40
  },
56
41
  view: function view(editorView) {
@@ -4,14 +4,14 @@ import { SyncBlockLabel } from './SyncBlockLabel';
4
4
  var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
5
5
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
6
6
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
7
- useFetchDocNode = _ref.useFetchDocNode;
7
+ useFetchSyncBlockData = _ref.useFetchSyncBlockData;
8
8
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
9
9
  "data-testid": SyncBlockRendererWrapperDataId
10
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
11
11
  ,
12
12
  className: SyncBlockSharedCssClassName.renderer
13
13
  }, getSyncedBlockRenderer({
14
- useFetchDocNode: useFetchDocNode
14
+ useFetchSyncBlockData: useFetchSyncBlockData
15
15
  })));
16
16
  };
17
17
  export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
@@ -1,4 +1,3 @@
1
- import type { DocNode } from '@atlaskit/adf-schema';
2
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
2
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
@@ -9,7 +8,7 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
9
8
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
10
9
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
11
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
12
- import type { SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
11
+ import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
13
12
  export type SyncedBlockEditorProps = {
14
13
  defaultDocument: JSONDocNode;
15
14
  onChange: (editorView: EditorView, meta: {
@@ -33,7 +32,7 @@ export type SyncedBlockEditorProps = {
33
32
  popupsMountPoint: HTMLElement;
34
33
  };
35
34
  export type SyncedBlockRendererProps = {
36
- useFetchDocNode: () => DocNode;
35
+ useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
37
36
  };
38
37
  export type SyncedBlockPluginOptions = {
39
38
  dataProvider?: SyncBlockDataProvider;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import type { DocNode } from '@atlaskit/adf-schema';
2
+ import type { FetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
4
  type Props = {
5
5
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
- useFetchDocNode: () => DocNode;
6
+ useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
7
7
  };
8
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchDocNode }: Props) => React.JSX.Element>;
8
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, }: Props) => React.JSX.Element>;
9
9
  export {};
@@ -1,4 +1,3 @@
1
- import type { DocNode } from '@atlaskit/adf-schema';
2
1
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
2
  import type { EditorCommand, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
3
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
@@ -9,7 +8,7 @@ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
9
8
  import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
10
9
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
11
10
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
12
- import type { SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
11
+ import type { FetchSyncBlockDataResult, SyncBlockDataProvider } from '@atlaskit/editor-synced-block-provider';
13
12
  export type SyncedBlockEditorProps = {
14
13
  defaultDocument: JSONDocNode;
15
14
  onChange: (editorView: EditorView, meta: {
@@ -33,7 +32,7 @@ export type SyncedBlockEditorProps = {
33
32
  popupsMountPoint: HTMLElement;
34
33
  };
35
34
  export type SyncedBlockRendererProps = {
36
- useFetchDocNode: () => DocNode;
35
+ useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
37
36
  };
38
37
  export type SyncedBlockPluginOptions = {
39
38
  dataProvider?: SyncBlockDataProvider;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
- import type { DocNode } from '@atlaskit/adf-schema';
2
+ import type { FetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
4
  type Props = {
5
5
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
- useFetchDocNode: () => DocNode;
6
+ useFetchSyncBlockData: () => FetchSyncBlockDataResult | null;
7
7
  };
8
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchDocNode }: Props) => React.JSX.Element>;
8
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, }: Props) => React.JSX.Element>;
9
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  "@atlaskit/editor-tables": "^2.9.0",
43
43
  "@atlaskit/editor-toolbar": "^0.16.0",
44
44
  "@atlaskit/icon": "28.5.3",
45
- "@atlaskit/modal-dialog": "^14.5.0",
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
  },
@@ -1,68 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.dev-agents.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../dev-agents/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-dev-agents/tsconfig.json"
27
- },
28
- {
29
- "path": "../../editor-json-transformer/afm-dev-agents/tsconfig.json"
30
- },
31
- {
32
- "path": "../../editor-plugin-analytics/afm-dev-agents/tsconfig.json"
33
- },
34
- {
35
- "path": "../../editor-plugin-block-menu/afm-dev-agents/tsconfig.json"
36
- },
37
- {
38
- "path": "../../editor-plugin-decorations/afm-dev-agents/tsconfig.json"
39
- },
40
- {
41
- "path": "../../editor-plugin-floating-toolbar/afm-dev-agents/tsconfig.json"
42
- },
43
- {
44
- "path": "../../editor-plugin-selection/afm-dev-agents/tsconfig.json"
45
- },
46
- {
47
- "path": "../../editor-shared-styles/afm-dev-agents/tsconfig.json"
48
- },
49
- {
50
- "path": "../../editor-synced-block-provider/afm-dev-agents/tsconfig.json"
51
- },
52
- {
53
- "path": "../../editor-tables/afm-dev-agents/tsconfig.json"
54
- },
55
- {
56
- "path": "../../editor-toolbar/afm-dev-agents/tsconfig.json"
57
- },
58
- {
59
- "path": "../../../design-system/icon/afm-dev-agents/tsconfig.json"
60
- },
61
- {
62
- "path": "../../../design-system/modal-dialog/afm-dev-agents/tsconfig.json"
63
- },
64
- {
65
- "path": "../../editor-common/afm-dev-agents/tsconfig.json"
66
- }
67
- ]
68
- }
@@ -1,68 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.passionfruit.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../passionfruit/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-passionfruit/tsconfig.json"
27
- },
28
- {
29
- "path": "../../editor-json-transformer/afm-passionfruit/tsconfig.json"
30
- },
31
- {
32
- "path": "../../editor-plugin-analytics/afm-passionfruit/tsconfig.json"
33
- },
34
- {
35
- "path": "../../editor-plugin-block-menu/afm-passionfruit/tsconfig.json"
36
- },
37
- {
38
- "path": "../../editor-plugin-decorations/afm-passionfruit/tsconfig.json"
39
- },
40
- {
41
- "path": "../../editor-plugin-floating-toolbar/afm-passionfruit/tsconfig.json"
42
- },
43
- {
44
- "path": "../../editor-plugin-selection/afm-passionfruit/tsconfig.json"
45
- },
46
- {
47
- "path": "../../editor-shared-styles/afm-passionfruit/tsconfig.json"
48
- },
49
- {
50
- "path": "../../editor-synced-block-provider/afm-passionfruit/tsconfig.json"
51
- },
52
- {
53
- "path": "../../editor-tables/afm-passionfruit/tsconfig.json"
54
- },
55
- {
56
- "path": "../../editor-toolbar/afm-passionfruit/tsconfig.json"
57
- },
58
- {
59
- "path": "../../../design-system/icon/afm-passionfruit/tsconfig.json"
60
- },
61
- {
62
- "path": "../../../design-system/modal-dialog/afm-passionfruit/tsconfig.json"
63
- },
64
- {
65
- "path": "../../editor-common/afm-passionfruit/tsconfig.json"
66
- }
67
- ]
68
- }
@@ -1,68 +0,0 @@
1
- {
2
- "extends": "../../../../tsconfig.entry-points.rovo-extension.json",
3
- "compilerOptions": {
4
- "target": "es5",
5
- "outDir": "../../../../../rovo-extension/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-rovo-extension/tsconfig.json"
27
- },
28
- {
29
- "path": "../../editor-json-transformer/afm-rovo-extension/tsconfig.json"
30
- },
31
- {
32
- "path": "../../editor-plugin-analytics/afm-rovo-extension/tsconfig.json"
33
- },
34
- {
35
- "path": "../../editor-plugin-block-menu/afm-rovo-extension/tsconfig.json"
36
- },
37
- {
38
- "path": "../../editor-plugin-decorations/afm-rovo-extension/tsconfig.json"
39
- },
40
- {
41
- "path": "../../editor-plugin-floating-toolbar/afm-rovo-extension/tsconfig.json"
42
- },
43
- {
44
- "path": "../../editor-plugin-selection/afm-rovo-extension/tsconfig.json"
45
- },
46
- {
47
- "path": "../../editor-shared-styles/afm-rovo-extension/tsconfig.json"
48
- },
49
- {
50
- "path": "../../editor-synced-block-provider/afm-rovo-extension/tsconfig.json"
51
- },
52
- {
53
- "path": "../../editor-tables/afm-rovo-extension/tsconfig.json"
54
- },
55
- {
56
- "path": "../../editor-toolbar/afm-rovo-extension/tsconfig.json"
57
- },
58
- {
59
- "path": "../../../design-system/icon/afm-rovo-extension/tsconfig.json"
60
- },
61
- {
62
- "path": "../../../design-system/modal-dialog/afm-rovo-extension/tsconfig.json"
63
- },
64
- {
65
- "path": "../../editor-common/afm-rovo-extension/tsconfig.json"
66
- }
67
- ]
68
- }