@atlaskit/editor-plugin-synced-block 2.2.1 → 2.3.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/afm-cc/tsconfig.json +3 -0
  3. package/afm-dev-agents/tsconfig.json +3 -0
  4. package/afm-jira/tsconfig.json +3 -0
  5. package/afm-passionfruit/tsconfig.json +3 -0
  6. package/afm-post-office/tsconfig.json +3 -0
  7. package/afm-rovo-extension/tsconfig.json +3 -0
  8. package/afm-townsquare/tsconfig.json +3 -0
  9. package/dist/cjs/nodeviews/syncedBlock.js +51 -16
  10. package/dist/cjs/pm-plugins/main.js +5 -1
  11. package/dist/cjs/syncedBlockPlugin.js +2 -2
  12. package/dist/cjs/ui/SyncBlockEditorWrapper.js +17 -20
  13. package/dist/cjs/ui/SyncBlockRendererWrapper.js +7 -6
  14. package/dist/es2019/nodeviews/syncedBlock.js +43 -16
  15. package/dist/es2019/pm-plugins/main.js +5 -1
  16. package/dist/es2019/syncedBlockPlugin.js +1 -1
  17. package/dist/es2019/ui/SyncBlockEditorWrapper.js +13 -16
  18. package/dist/es2019/ui/SyncBlockRendererWrapper.js +7 -6
  19. package/dist/esm/nodeviews/syncedBlock.js +51 -16
  20. package/dist/esm/pm-plugins/main.js +5 -1
  21. package/dist/esm/syncedBlockPlugin.js +1 -1
  22. package/dist/esm/ui/SyncBlockEditorWrapper.js +17 -20
  23. package/dist/esm/ui/SyncBlockRendererWrapper.js +7 -6
  24. package/dist/types/nodeviews/syncedBlock.d.ts +1 -0
  25. package/dist/types/pm-plugins/main.d.ts +1 -1
  26. package/dist/types/pm-plugins/utils/track-sync-blocks.d.ts +1 -1
  27. package/dist/types/syncedBlockPluginType.d.ts +3 -2
  28. package/dist/types/ui/ContentComponent.d.ts +1 -1
  29. package/dist/types/ui/SyncBlockRendererWrapper.d.ts +2 -2
  30. package/dist/types-ts4.5/nodeviews/syncedBlock.d.ts +1 -0
  31. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  32. package/dist/types-ts4.5/pm-plugins/utils/track-sync-blocks.d.ts +1 -1
  33. package/dist/types-ts4.5/syncedBlockPluginType.d.ts +3 -2
  34. package/dist/types-ts4.5/ui/ContentComponent.d.ts +1 -1
  35. package/dist/types-ts4.5/ui/SyncBlockRendererWrapper.d.ts +2 -2
  36. package/package.json +6 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`687c1b8fa7801`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/687c1b8fa7801) -
8
+ EDITOR-1566 bump adf-schema + update validator
9
+ - [`578ac13fd9edd`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/578ac13fd9edd) -
10
+ Add Sync Block provider as new package
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 2.2.2
17
+
18
+ ### Patch Changes
19
+
20
+ - [`bd24a3afbfb65`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bd24a3afbfb65) -
21
+ Updated look and feel of the Synced Block Editor
22
+ - Updated dependencies
23
+
3
24
  ## 2.2.1
4
25
 
5
26
  ### Patch Changes
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-cc/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-cc/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-dev-agents/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-dev-agents/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-dev-agents/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-jira/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-jira/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-passionfruit/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-passionfruit/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-passionfruit/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-post-office/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-post-office/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-post-office/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-rovo-extension/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-rovo-extension/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-rovo-extension/tsconfig.json"
33
36
  },
@@ -28,6 +28,9 @@
28
28
  {
29
29
  "path": "../../editor-plugin-selection/afm-townsquare/tsconfig.json"
30
30
  },
31
+ {
32
+ "path": "../../editor-synced-block-provider/afm-townsquare/tsconfig.json"
33
+ },
31
34
  {
32
35
  "path": "../../../design-system/icon/afm-townsquare/tsconfig.json"
33
36
  },
@@ -13,7 +13,9 @@ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
13
13
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
16
+ var _syncBlock = require("@atlaskit/editor-common/sync-block");
16
17
  var _state = require("@atlaskit/editor-prosemirror/state");
18
+ var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
17
19
  var _SyncBlockEditorWrapper = require("../ui/SyncBlockEditorWrapper");
18
20
  var _SyncBlockRendererWrapper = require("../ui/SyncBlockRendererWrapper");
19
21
  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)); }
@@ -59,51 +61,81 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
59
61
  key: "createDomRef",
60
62
  value: function createDomRef() {
61
63
  var domRef = document.createElement('div');
64
+ domRef.classList.add(_syncBlock.SyncBlockSharedCssClassName.prefix);
62
65
  return domRef;
63
66
  }
64
67
  }, {
65
68
  key: "handleContentChanges",
66
- value: function handleContentChanges(_updatedDoc) {
69
+ value: function handleContentChanges(updatedDoc) {
70
+ var _this$options;
71
+ if (!this.isSource) {
72
+ return;
73
+ }
67
74
  // write data
75
+ var node = (0, _editorSyncedBlockProvider.createSyncBlockNode)(this.node, false);
76
+ (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.syncedBlockProvider) === null || _this$options === void 0 || _this$options.writeNodesData([node], [{
77
+ content: updatedDoc.toJSON()
78
+ }]);
68
79
  }
69
80
  }, {
70
81
  key: "setInnerEditorView",
71
- value: function setInnerEditorView(_editorView) {
82
+ value: function setInnerEditorView(editorView) {
83
+ var _this$options2;
72
84
  // set inner editor view
85
+ var nodes = [(0, _editorSyncedBlockProvider.createSyncBlockNode)(this.node, false)];
86
+ (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.syncedBlockProvider) === null || _this$options2 === void 0 || _this$options2.fetchNodesData(nodes).then(function (data) {
87
+ var _data$;
88
+ var tr = editorView.state.tr;
89
+ if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
90
+ var newNode = editorView.state.schema.nodeFromJSON(data[0].content);
91
+ editorView.dispatch(tr.replaceWith(0, editorView.state.doc.nodeSize - 2, newNode));
92
+ }
93
+ });
73
94
  }
74
95
  }, {
75
96
  key: "renderEditor",
76
97
  value: function renderEditor() {
77
- var _this$options, _this$options2;
78
- var popupsBoundariesElement = this.dom.closest('.fabric-editor-popup-scroll-parent');
79
- if (!(popupsBoundariesElement instanceof HTMLElement)) {
98
+ var _this$options3,
99
+ _this2 = this,
100
+ _this$options4;
101
+ var fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
102
+ if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
80
103
  return null;
81
104
  }
82
- if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.getSyncedBlockEditor)) {
105
+ if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
83
106
  return null;
84
107
  }
85
108
  return /*#__PURE__*/_react.default.createElement(_SyncBlockEditorWrapper.SyncBlockEditorWrapper, {
86
- popupsBoundariesElement: popupsBoundariesElement,
87
- popupsMountPoint: this.dom,
109
+ popupsBoundariesElement: fabricEditorPopupScrollParent,
110
+ popupsMountPoint: fabricEditorPopupScrollParent,
88
111
  defaultDocument: defaultSyncBlockEditorDocument,
89
- handleContentChanges: this.handleContentChanges,
90
- setInnerEditorView: this.setInnerEditorView,
91
- getSyncedBlockEditor: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockEditor
112
+ handleContentChanges: function handleContentChanges(updatedDoc) {
113
+ return _this2.handleContentChanges(updatedDoc);
114
+ },
115
+ setInnerEditorView: function setInnerEditorView(editorView) {
116
+ return _this2.setInnerEditorView(editorView);
117
+ },
118
+ getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
92
119
  });
93
120
  }
94
121
  }, {
95
122
  key: "renderRenderer",
96
123
  value: function renderRenderer() {
97
- var _this$options3, _this$options4;
98
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockRenderer)) {
124
+ var _this$options5,
125
+ _this3 = this,
126
+ _this$options6;
127
+ if (!((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.getSyncedBlockRenderer)) {
99
128
  return null;
100
129
  }
101
130
 
102
131
  // get document node from data provider
103
- var docNode = defaultSyncBlockRendererDocument;
132
+
104
133
  return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
105
- docNode: docNode,
106
- getSyncedBlockRenderer: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockRenderer
134
+ useFetchDocNode: function useFetchDocNode() {
135
+ var _this3$options;
136
+ return (0, _editorSyncedBlockProvider.useFetchDocNode)(_this3.view, _this3.node, defaultSyncBlockRendererDocument, (_this3$options = _this3.options) === null || _this3$options === void 0 ? void 0 : _this3$options.syncedBlockProvider);
137
+ },
138
+ getSyncedBlockRenderer: (_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.getSyncedBlockRenderer
107
139
  });
108
140
  }
109
141
  }, {
@@ -138,6 +170,9 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
138
170
  key: "destroy",
139
171
  value: function destroy() {
140
172
  var _this$unsubscribe;
173
+ if (this.fetchIntervalId) {
174
+ window.clearInterval(this.fetchIntervalId);
175
+ }
141
176
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
142
177
  _superPropGet(SyncBlock, "destroy", this, 3)([]);
143
178
  }
@@ -19,7 +19,11 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
19
19
  init: function init() {
20
20
  return {};
21
21
  },
22
- apply: function apply(_tr, currentPluginState) {
22
+ apply: function apply(tr, currentPluginState) {
23
+ var meta = tr.getMeta(syncedBlockPluginKey);
24
+ if (meta) {
25
+ return meta;
26
+ }
23
27
  return currentPluginState;
24
28
  }
25
29
  },
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.syncedBlockPlugin = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _adfSchema = require("@atlaskit/adf-schema");
10
- var _syncBlock = require("@atlaskit/editor-common/sync-block");
10
+ var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
11
11
  var _smartLink = _interopRequireDefault(require("@atlaskit/icon/core/smart-link"));
12
12
  var _actions = require("./pm-plugins/actions");
13
13
  var _main = require("./pm-plugins/main");
@@ -16,7 +16,7 @@ var _floatingToolbar = require("./ui/floating-toolbar");
16
16
  var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_ref) {
17
17
  var config = _ref.config,
18
18
  api = _ref.api;
19
- var syncBlockStore = new _syncBlock.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.dataProvider);
19
+ var syncBlockStore = new _editorSyncedBlockProvider.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.dataProvider);
20
20
  return {
21
21
  name: 'syncedBlock',
22
22
  nodes: function nodes() {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _syncBlock = require("@atlaskit/editor-common/sync-block");
9
10
  var SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
10
11
  var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_ref) {
11
12
  var defaultDocument = _ref.defaultDocument,
@@ -14,25 +15,21 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
14
15
  popupsMountPoint = _ref.popupsMountPoint,
15
16
  setInnerEditorView = _ref.setInnerEditorView,
16
17
  handleContentChanges = _ref.handleContentChanges;
17
- return (
18
- /*#__PURE__*/
19
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
20
- _react.default.createElement("div", {
21
- "data-testid": SyncBlockEditorWrapperDataId,
22
- style: {
23
- border: 'purple solid 1px'
24
- }
25
- }, getSyncedBlockEditor({
26
- popupsBoundariesElement: popupsBoundariesElement,
27
- defaultDocument: defaultDocument,
28
- popupsMountPoint: popupsMountPoint,
29
- onChange: function onChange(value) {
30
- return handleContentChanges(value.state.doc);
31
- },
32
- onEditorReady: function onEditorReady(value) {
33
- return setInnerEditorView(value.editorView);
34
- }
35
- }))
36
- );
18
+ return /*#__PURE__*/_react.default.createElement("div", {
19
+ "data-testid": SyncBlockEditorWrapperDataId
20
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
21
+ ,
22
+ className: _syncBlock.SyncBlockSharedCssClassName.editor
23
+ }, getSyncedBlockEditor({
24
+ popupsBoundariesElement: popupsBoundariesElement,
25
+ defaultDocument: defaultDocument,
26
+ popupsMountPoint: popupsMountPoint,
27
+ onChange: function onChange(value) {
28
+ return handleContentChanges(value.state.doc);
29
+ },
30
+ onEditorReady: function onEditorReady(value) {
31
+ return setInnerEditorView(value.editorView);
32
+ }
33
+ }));
37
34
  };
38
35
  var SyncBlockEditorWrapper = exports.SyncBlockEditorWrapper = /*#__PURE__*/_react.default.memo(SyncBlockEditorWrapperComponent);
@@ -6,20 +6,21 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.SyncBlockRendererWrapper = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
+ var _syncBlock = require("@atlaskit/editor-common/sync-block");
9
10
  var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
10
11
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
11
12
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
12
- docNode = _ref.docNode;
13
+ useFetchDocNode = _ref.useFetchDocNode;
13
14
  return (
14
15
  /*#__PURE__*/
15
16
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
16
17
  _react.default.createElement("div", {
17
- "data-testid": SyncBlockRendererWrapperDataId,
18
- style: {
19
- border: 'blue solid 1px'
20
- }
18
+ "data-testid": SyncBlockRendererWrapperDataId
19
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
20
+ ,
21
+ className: _syncBlock.SyncBlockSharedCssClassName.renderer
21
22
  }, getSyncedBlockRenderer({
22
- docNode: docNode
23
+ useFetchDocNode: useFetchDocNode
23
24
  }))
24
25
  );
25
26
  };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
3
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
+ import { createSyncBlockNode, useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
4
6
  import { SyncBlockEditorWrapper, SyncBlockEditorWrapperDataId } from '../ui/SyncBlockEditorWrapper';
5
7
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
6
8
  const defaultSyncBlockEditorDocument = {
@@ -38,43 +40,65 @@ class SyncBlock extends ReactNodeView {
38
40
  }
39
41
  createDomRef() {
40
42
  const domRef = document.createElement('div');
43
+ domRef.classList.add(SyncBlockSharedCssClassName.prefix);
41
44
  return domRef;
42
45
  }
43
- handleContentChanges(_updatedDoc) {
46
+ handleContentChanges(updatedDoc) {
47
+ var _this$options, _this$options$syncedB;
48
+ if (!this.isSource) {
49
+ return;
50
+ }
44
51
  // write data
52
+ const node = createSyncBlockNode(this.node, false);
53
+ (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$syncedB = _this$options.syncedBlockProvider) === null || _this$options$syncedB === void 0 ? void 0 : _this$options$syncedB.writeNodesData([node], [{
54
+ content: updatedDoc.toJSON()
55
+ }]);
45
56
  }
46
- setInnerEditorView(_editorView) {
57
+ setInnerEditorView(editorView) {
58
+ var _this$options2, _this$options2$synced;
47
59
  // set inner editor view
60
+ const nodes = [createSyncBlockNode(this.node, false)];
61
+ (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$synced = _this$options2.syncedBlockProvider) === null || _this$options2$synced === void 0 ? void 0 : _this$options2$synced.fetchNodesData(nodes).then(data => {
62
+ var _data$;
63
+ const tr = editorView.state.tr;
64
+ if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
65
+ const newNode = editorView.state.schema.nodeFromJSON(data[0].content);
66
+ editorView.dispatch(tr.replaceWith(0, editorView.state.doc.nodeSize - 2, newNode));
67
+ }
68
+ });
48
69
  }
49
70
  renderEditor() {
50
- var _this$options, _this$options2;
51
- const popupsBoundariesElement = this.dom.closest('.fabric-editor-popup-scroll-parent');
52
- if (!(popupsBoundariesElement instanceof HTMLElement)) {
71
+ var _this$options3, _this$options4;
72
+ const fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
73
+ if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
53
74
  return null;
54
75
  }
55
- if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.getSyncedBlockEditor)) {
76
+ if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
56
77
  return null;
57
78
  }
58
79
  return /*#__PURE__*/React.createElement(SyncBlockEditorWrapper, {
59
- popupsBoundariesElement: popupsBoundariesElement,
60
- popupsMountPoint: this.dom,
80
+ popupsBoundariesElement: fabricEditorPopupScrollParent,
81
+ popupsMountPoint: fabricEditorPopupScrollParent,
61
82
  defaultDocument: defaultSyncBlockEditorDocument,
62
- handleContentChanges: this.handleContentChanges,
63
- setInnerEditorView: this.setInnerEditorView,
64
- getSyncedBlockEditor: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockEditor
83
+ handleContentChanges: updatedDoc => this.handleContentChanges(updatedDoc),
84
+ setInnerEditorView: editorView => this.setInnerEditorView(editorView),
85
+ getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
65
86
  });
66
87
  }
67
88
  renderRenderer() {
68
- var _this$options3, _this$options4;
69
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockRenderer)) {
89
+ var _this$options5, _this$options7;
90
+ if (!((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.getSyncedBlockRenderer)) {
70
91
  return null;
71
92
  }
72
93
 
73
94
  // get document node from data provider
74
- const docNode = defaultSyncBlockRendererDocument;
95
+
75
96
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
76
- docNode: docNode,
77
- getSyncedBlockRenderer: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockRenderer
97
+ useFetchDocNode: () => {
98
+ var _this$options6;
99
+ return useFetchDocNode(this.view, this.node, defaultSyncBlockRendererDocument, (_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.syncedBlockProvider);
100
+ },
101
+ getSyncedBlockRenderer: (_this$options7 = this.options) === null || _this$options7 === void 0 ? void 0 : _this$options7.getSyncedBlockRenderer
78
102
  });
79
103
  }
80
104
  render() {
@@ -101,6 +125,9 @@ class SyncBlock extends ReactNodeView {
101
125
  }
102
126
  destroy() {
103
127
  var _this$unsubscribe;
128
+ if (this.fetchIntervalId) {
129
+ window.clearInterval(this.fetchIntervalId);
130
+ }
104
131
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
105
132
  super.destroy();
106
133
  }
@@ -13,7 +13,11 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
13
13
  init() {
14
14
  return {};
15
15
  },
16
- apply: (_tr, currentPluginState) => {
16
+ apply: (tr, currentPluginState) => {
17
+ const meta = tr.getMeta(syncedBlockPluginKey);
18
+ if (meta) {
19
+ return meta;
20
+ }
17
21
  return currentPluginState;
18
22
  }
19
23
  },
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { syncBlock } from '@atlaskit/adf-schema';
3
- import { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
3
+ import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import SmartLinkIcon from '@atlaskit/icon/core/smart-link';
5
5
  import { createSyncedBlock } from './pm-plugins/actions';
6
6
  import { createPlugin } from './pm-plugins/main';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  export const SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
3
4
  const SyncBlockEditorWrapperComponent = ({
4
5
  defaultDocument,
@@ -8,21 +9,17 @@ const SyncBlockEditorWrapperComponent = ({
8
9
  setInnerEditorView,
9
10
  handleContentChanges
10
11
  }) => {
11
- return (
12
- /*#__PURE__*/
13
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
14
- React.createElement("div", {
15
- "data-testid": SyncBlockEditorWrapperDataId,
16
- style: {
17
- border: 'purple solid 1px'
18
- }
19
- }, getSyncedBlockEditor({
20
- popupsBoundariesElement,
21
- defaultDocument,
22
- popupsMountPoint,
23
- onChange: value => handleContentChanges(value.state.doc),
24
- onEditorReady: value => setInnerEditorView(value.editorView)
25
- }))
26
- );
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ "data-testid": SyncBlockEditorWrapperDataId
14
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
15
+ ,
16
+ className: SyncBlockSharedCssClassName.editor
17
+ }, getSyncedBlockEditor({
18
+ popupsBoundariesElement,
19
+ defaultDocument,
20
+ popupsMountPoint,
21
+ onChange: value => handleContentChanges(value.state.doc),
22
+ onEditorReady: value => setInnerEditorView(value.editorView)
23
+ }));
27
24
  };
28
25
  export const SyncBlockEditorWrapper = /*#__PURE__*/React.memo(SyncBlockEditorWrapperComponent);
@@ -1,19 +1,20 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  const SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
3
4
  const SyncBlockRendererWrapperComponent = ({
4
5
  getSyncedBlockRenderer,
5
- docNode
6
+ useFetchDocNode
6
7
  }) => {
7
8
  return (
8
9
  /*#__PURE__*/
9
10
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
10
11
  React.createElement("div", {
11
- "data-testid": SyncBlockRendererWrapperDataId,
12
- style: {
13
- border: 'blue solid 1px'
14
- }
12
+ "data-testid": SyncBlockRendererWrapperDataId
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
14
+ ,
15
+ className: SyncBlockSharedCssClassName.renderer
15
16
  }, getSyncedBlockRenderer({
16
- docNode
17
+ useFetchDocNode
17
18
  }))
18
19
  );
19
20
  };
@@ -9,7 +9,9 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
9
9
  function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
10
10
  import React from 'react';
11
11
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
12
13
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
+ import { createSyncBlockNode, useFetchDocNode as _useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
13
15
  import { SyncBlockEditorWrapper, SyncBlockEditorWrapperDataId } from '../ui/SyncBlockEditorWrapper';
14
16
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
15
17
  var defaultSyncBlockEditorDocument = {
@@ -52,51 +54,81 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
52
54
  key: "createDomRef",
53
55
  value: function createDomRef() {
54
56
  var domRef = document.createElement('div');
57
+ domRef.classList.add(SyncBlockSharedCssClassName.prefix);
55
58
  return domRef;
56
59
  }
57
60
  }, {
58
61
  key: "handleContentChanges",
59
- value: function handleContentChanges(_updatedDoc) {
62
+ value: function handleContentChanges(updatedDoc) {
63
+ var _this$options;
64
+ if (!this.isSource) {
65
+ return;
66
+ }
60
67
  // write data
68
+ var node = createSyncBlockNode(this.node, false);
69
+ (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.syncedBlockProvider) === null || _this$options === void 0 || _this$options.writeNodesData([node], [{
70
+ content: updatedDoc.toJSON()
71
+ }]);
61
72
  }
62
73
  }, {
63
74
  key: "setInnerEditorView",
64
- value: function setInnerEditorView(_editorView) {
75
+ value: function setInnerEditorView(editorView) {
76
+ var _this$options2;
65
77
  // set inner editor view
78
+ var nodes = [createSyncBlockNode(this.node, false)];
79
+ (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.syncedBlockProvider) === null || _this$options2 === void 0 || _this$options2.fetchNodesData(nodes).then(function (data) {
80
+ var _data$;
81
+ var tr = editorView.state.tr;
82
+ if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
83
+ var newNode = editorView.state.schema.nodeFromJSON(data[0].content);
84
+ editorView.dispatch(tr.replaceWith(0, editorView.state.doc.nodeSize - 2, newNode));
85
+ }
86
+ });
66
87
  }
67
88
  }, {
68
89
  key: "renderEditor",
69
90
  value: function renderEditor() {
70
- var _this$options, _this$options2;
71
- var popupsBoundariesElement = this.dom.closest('.fabric-editor-popup-scroll-parent');
72
- if (!(popupsBoundariesElement instanceof HTMLElement)) {
91
+ var _this$options3,
92
+ _this2 = this,
93
+ _this$options4;
94
+ var fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
95
+ if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
73
96
  return null;
74
97
  }
75
- if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.getSyncedBlockEditor)) {
98
+ if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
76
99
  return null;
77
100
  }
78
101
  return /*#__PURE__*/React.createElement(SyncBlockEditorWrapper, {
79
- popupsBoundariesElement: popupsBoundariesElement,
80
- popupsMountPoint: this.dom,
102
+ popupsBoundariesElement: fabricEditorPopupScrollParent,
103
+ popupsMountPoint: fabricEditorPopupScrollParent,
81
104
  defaultDocument: defaultSyncBlockEditorDocument,
82
- handleContentChanges: this.handleContentChanges,
83
- setInnerEditorView: this.setInnerEditorView,
84
- getSyncedBlockEditor: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockEditor
105
+ handleContentChanges: function handleContentChanges(updatedDoc) {
106
+ return _this2.handleContentChanges(updatedDoc);
107
+ },
108
+ setInnerEditorView: function setInnerEditorView(editorView) {
109
+ return _this2.setInnerEditorView(editorView);
110
+ },
111
+ getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
85
112
  });
86
113
  }
87
114
  }, {
88
115
  key: "renderRenderer",
89
116
  value: function renderRenderer() {
90
- var _this$options3, _this$options4;
91
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockRenderer)) {
117
+ var _this$options5,
118
+ _this3 = this,
119
+ _this$options6;
120
+ if (!((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.getSyncedBlockRenderer)) {
92
121
  return null;
93
122
  }
94
123
 
95
124
  // get document node from data provider
96
- var docNode = defaultSyncBlockRendererDocument;
125
+
97
126
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
98
- docNode: docNode,
99
- getSyncedBlockRenderer: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockRenderer
127
+ useFetchDocNode: function useFetchDocNode() {
128
+ var _this3$options;
129
+ return _useFetchDocNode(_this3.view, _this3.node, defaultSyncBlockRendererDocument, (_this3$options = _this3.options) === null || _this3$options === void 0 ? void 0 : _this3$options.syncedBlockProvider);
130
+ },
131
+ getSyncedBlockRenderer: (_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.getSyncedBlockRenderer
100
132
  });
101
133
  }
102
134
  }, {
@@ -131,6 +163,9 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
131
163
  key: "destroy",
132
164
  value: function destroy() {
133
165
  var _this$unsubscribe;
166
+ if (this.fetchIntervalId) {
167
+ window.clearInterval(this.fetchIntervalId);
168
+ }
134
169
  (_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 || _this$unsubscribe.call(this);
135
170
  _superPropGet(SyncBlock, "destroy", this, 3)([]);
136
171
  }
@@ -13,7 +13,11 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
13
13
  init: function init() {
14
14
  return {};
15
15
  },
16
- apply: function apply(_tr, currentPluginState) {
16
+ apply: function apply(tr, currentPluginState) {
17
+ var meta = tr.getMeta(syncedBlockPluginKey);
18
+ if (meta) {
19
+ return meta;
20
+ }
17
21
  return currentPluginState;
18
22
  }
19
23
  },
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { syncBlock } from '@atlaskit/adf-schema';
3
- import { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
3
+ import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
4
4
  import SmartLinkIcon from '@atlaskit/icon/core/smart-link';
5
5
  import { createSyncedBlock } from './pm-plugins/actions';
6
6
  import { createPlugin } from './pm-plugins/main';
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  export var SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
3
4
  var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_ref) {
4
5
  var defaultDocument = _ref.defaultDocument,
@@ -7,25 +8,21 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
7
8
  popupsMountPoint = _ref.popupsMountPoint,
8
9
  setInnerEditorView = _ref.setInnerEditorView,
9
10
  handleContentChanges = _ref.handleContentChanges;
10
- return (
11
- /*#__PURE__*/
12
- // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
13
- React.createElement("div", {
14
- "data-testid": SyncBlockEditorWrapperDataId,
15
- style: {
16
- border: 'purple solid 1px'
17
- }
18
- }, getSyncedBlockEditor({
19
- popupsBoundariesElement: popupsBoundariesElement,
20
- defaultDocument: defaultDocument,
21
- popupsMountPoint: popupsMountPoint,
22
- onChange: function onChange(value) {
23
- return handleContentChanges(value.state.doc);
24
- },
25
- onEditorReady: function onEditorReady(value) {
26
- return setInnerEditorView(value.editorView);
27
- }
28
- }))
29
- );
11
+ return /*#__PURE__*/React.createElement("div", {
12
+ "data-testid": SyncBlockEditorWrapperDataId
13
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
14
+ ,
15
+ className: SyncBlockSharedCssClassName.editor
16
+ }, getSyncedBlockEditor({
17
+ popupsBoundariesElement: popupsBoundariesElement,
18
+ defaultDocument: defaultDocument,
19
+ popupsMountPoint: popupsMountPoint,
20
+ onChange: function onChange(value) {
21
+ return handleContentChanges(value.state.doc);
22
+ },
23
+ onEditorReady: function onEditorReady(value) {
24
+ return setInnerEditorView(value.editorView);
25
+ }
26
+ }));
30
27
  };
31
28
  export var SyncBlockEditorWrapper = /*#__PURE__*/React.memo(SyncBlockEditorWrapperComponent);
@@ -1,18 +1,19 @@
1
1
  import React from 'react';
2
+ import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
2
3
  var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
3
4
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
4
5
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
5
- docNode = _ref.docNode;
6
+ useFetchDocNode = _ref.useFetchDocNode;
6
7
  return (
7
8
  /*#__PURE__*/
8
9
  // eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop, @atlaskit/design-system/ensure-design-token-usage
9
10
  React.createElement("div", {
10
- "data-testid": SyncBlockRendererWrapperDataId,
11
- style: {
12
- border: 'blue solid 1px'
13
- }
11
+ "data-testid": SyncBlockRendererWrapperDataId
12
+ // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
13
+ ,
14
+ className: SyncBlockSharedCssClassName.renderer
14
15
  }, getSyncedBlockRenderer({
15
- docNode: docNode
16
+ useFetchDocNode: useFetchDocNode
16
17
  }))
17
18
  );
18
19
  };
@@ -20,6 +20,7 @@ export interface SyncBlockNodeViewProps extends ReactComponentProps {
20
20
  declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
21
21
  private isSource;
22
22
  private options;
23
+ private fetchIntervalId;
23
24
  constructor(props: SyncBlockNodeViewProps);
24
25
  unsubscribe: (() => void) | undefined;
25
26
  createDomRef(): HTMLElement;
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
3
2
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
4
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
5
5
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
6
6
  export declare const syncedBlockPluginKey: PluginKey<any>;
7
7
  type SyncedBlockPluginState = {};
@@ -1,5 +1,5 @@
1
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
2
1
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncBlockAttrs } from '../../syncedBlockPluginType';
4
4
  export declare const trackSyncBlocks: (storeManager: SyncBlockStoreManager, tr: Transaction, state: EditorState) => {
5
5
  removed: SyncBlockAttrs[];
@@ -1,10 +1,10 @@
1
1
  import type { DocNode } from '@atlaskit/adf-schema';
2
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
- import type { SyncBlockDataProvider } from '@atlaskit/editor-common/sync-block';
4
3
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
5
4
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
6
5
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
7
+ import type { SyncBlockDataProvider, SyncedBlockProvider } from '@atlaskit/editor-synced-block-provider';
8
8
  export type SyncedBlockEditorProps = {
9
9
  defaultDocument: JSONDocNode;
10
10
  onChange: (editorView: EditorView, meta: {
@@ -28,12 +28,13 @@ export type SyncedBlockEditorProps = {
28
28
  popupsMountPoint: HTMLElement;
29
29
  };
30
30
  export type SyncedBlockRendererProps = {
31
- docNode: DocNode;
31
+ useFetchDocNode: () => DocNode;
32
32
  };
33
33
  export type SyncedBlockPluginOptions = {
34
34
  dataProvider?: SyncBlockDataProvider;
35
35
  getSyncedBlockEditor?: (props: SyncedBlockEditorProps) => React.JSX.Element;
36
36
  getSyncedBlockRenderer?: (props: SyncedBlockRendererProps) => React.JSX.Element;
37
+ syncedBlockProvider?: SyncedBlockProvider;
37
38
  };
38
39
  export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
39
40
  dependencies: [SelectionPlugin];
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
2
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  export declare const ContentComponent: ({ syncBlockStoreManager, }: {
4
4
  syncBlockStoreManager: SyncBlockStoreManager;
5
5
  }) => React.JSX.Element;
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import type { DocNode } from '@atlaskit/adf-schema';
3
3
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
4
  type Props = {
5
- docNode: DocNode;
6
5
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
+ useFetchDocNode: () => DocNode;
7
7
  };
8
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, docNode }: Props) => React.JSX.Element>;
8
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchDocNode }: Props) => React.JSX.Element>;
9
9
  export {};
@@ -20,6 +20,7 @@ export interface SyncBlockNodeViewProps extends ReactComponentProps {
20
20
  declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
21
21
  private isSource;
22
22
  private options;
23
+ private fetchIntervalId;
23
24
  constructor(props: SyncBlockNodeViewProps);
24
25
  unsubscribe: (() => void) | undefined;
25
26
  createDomRef(): HTMLElement;
@@ -1,7 +1,7 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
3
2
  import type { ExtractInjectionAPI, PMPluginFactoryParams } from '@atlaskit/editor-common/types';
4
3
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
4
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
5
5
  import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
6
6
  export declare const syncedBlockPluginKey: PluginKey<any>;
7
7
  type SyncedBlockPluginState = {};
@@ -1,5 +1,5 @@
1
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
2
1
  import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
2
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  import type { SyncBlockAttrs } from '../../syncedBlockPluginType';
4
4
  export declare const trackSyncBlocks: (storeManager: SyncBlockStoreManager, tr: Transaction, state: EditorState) => {
5
5
  removed: SyncBlockAttrs[];
@@ -1,10 +1,10 @@
1
1
  import type { DocNode } from '@atlaskit/adf-schema';
2
2
  import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
3
- import type { SyncBlockDataProvider } from '@atlaskit/editor-common/sync-block';
4
3
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
5
4
  import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
6
5
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
7
6
  import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
7
+ import type { SyncBlockDataProvider, SyncedBlockProvider } from '@atlaskit/editor-synced-block-provider';
8
8
  export type SyncedBlockEditorProps = {
9
9
  defaultDocument: JSONDocNode;
10
10
  onChange: (editorView: EditorView, meta: {
@@ -28,12 +28,13 @@ export type SyncedBlockEditorProps = {
28
28
  popupsMountPoint: HTMLElement;
29
29
  };
30
30
  export type SyncedBlockRendererProps = {
31
- docNode: DocNode;
31
+ useFetchDocNode: () => DocNode;
32
32
  };
33
33
  export type SyncedBlockPluginOptions = {
34
34
  dataProvider?: SyncBlockDataProvider;
35
35
  getSyncedBlockEditor?: (props: SyncedBlockEditorProps) => React.JSX.Element;
36
36
  getSyncedBlockRenderer?: (props: SyncedBlockRendererProps) => React.JSX.Element;
37
+ syncedBlockProvider?: SyncedBlockProvider;
37
38
  };
38
39
  export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
39
40
  dependencies: [
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import type { SyncBlockStoreManager } from '@atlaskit/editor-common/sync-block';
2
+ import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
3
3
  export declare const ContentComponent: ({ syncBlockStoreManager, }: {
4
4
  syncBlockStoreManager: SyncBlockStoreManager;
5
5
  }) => React.JSX.Element;
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import type { DocNode } from '@atlaskit/adf-schema';
3
3
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
4
4
  type Props = {
5
- docNode: DocNode;
6
5
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
6
+ useFetchDocNode: () => DocNode;
7
7
  };
8
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, docNode }: Props) => React.JSX.Element>;
8
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchDocNode }: 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": "2.2.1",
3
+ "version": "2.3.0",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -8,7 +8,7 @@
8
8
  "registry": "https://registry.npmjs.org/"
9
9
  },
10
10
  "atlassian": {
11
- "team": "Editor: Lego",
11
+ "team": "Editor: Jenga",
12
12
  "releaseModel": "continuous",
13
13
  "singleton": true
14
14
  },
@@ -28,18 +28,19 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.1.2",
31
+ "@atlaskit/adf-schema": "^51.2.0",
32
32
  "@atlaskit/button": "23.4.9",
33
33
  "@atlaskit/editor-plugin-selection": "^5.0.0",
34
34
  "@atlaskit/editor-prosemirror": "7.0.0",
35
+ "@atlaskit/editor-synced-block-provider": "^0.1.0",
35
36
  "@atlaskit/icon": "28.3.0",
36
- "@atlaskit/modal-dialog": "^14.3.0",
37
+ "@atlaskit/modal-dialog": "^14.4.0",
37
38
  "@babel/runtime": "^7.0.0",
38
39
  "react-intl-next": "npm:react-intl@^5.18.1",
39
40
  "uuid": "^3.1.0"
40
41
  },
41
42
  "peerDependencies": {
42
- "@atlaskit/editor-common": "^109.14.0",
43
+ "@atlaskit/editor-common": "^109.16.0",
43
44
  "react": "^18.2.0"
44
45
  },
45
46
  "devDependencies": {