@atlaskit/editor-plugin-synced-block 3.2.1 → 3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3ebbf8e97e2d9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3ebbf8e97e2d9) -
8
+ Update for new sync block provider API
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 3.2.1
4
15
 
5
16
  ### Patch Changes
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-cc/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-cc/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-cc/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-dev-agents/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-dev-agents/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-dev-agents/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-jira/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-jira/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-jira/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-passionfruit/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-passionfruit/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-passionfruit/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-post-office/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-post-office/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-post-office/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-rovo-extension/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-rovo-extension/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-rovo-extension/tsconfig.json"
30
33
  },
@@ -25,6 +25,9 @@
25
25
  {
26
26
  "path": "../../../design-system/button/afm-townsquare/tsconfig.json"
27
27
  },
28
+ {
29
+ "path": "../../editor-json-transformer/afm-townsquare/tsconfig.json"
30
+ },
28
31
  {
29
32
  "path": "../../editor-plugin-block-menu/afm-townsquare/tsconfig.json"
30
33
  },
@@ -65,26 +65,13 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
65
65
  value: function isSource() {
66
66
  return this.syncBlockStore.isSourceBlock(this.node);
67
67
  }
68
- }, {
69
- key: "handleContentChanges",
70
- value: function handleContentChanges(updatedDoc) {
71
- var _this$options;
72
- if (!this.isSource) {
73
- return;
74
- }
75
- // write data
76
- var node = (0, _editorSyncedBlockProvider.convertSyncBlockPMNodeToSyncBlockData)(this.node, false);
77
- (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.dataProvider) === null || _this$options === void 0 || _this$options.writeNodesData([node], [{
78
- content: updatedDoc.toJSON()
79
- }]);
80
- }
81
68
  }, {
82
69
  key: "setInnerEditorView",
83
70
  value: function setInnerEditorView(editorView) {
84
- var _this$options2;
71
+ var _this$options;
85
72
  // set inner editor view
86
73
  var nodes = [(0, _editorSyncedBlockProvider.convertSyncBlockPMNodeToSyncBlockData)(this.node, false)];
87
- (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.dataProvider) === null || _this$options2 === void 0 || _this$options2.fetchNodesData(nodes).then(function (data) {
74
+ (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.dataProvider) === null || _this$options === void 0 || _this$options.fetchNodesData(nodes).then(function (data) {
88
75
  var _data$;
89
76
  var tr = editorView.state.tr;
90
77
  if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
@@ -96,36 +83,37 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
96
83
  }, {
97
84
  key: "renderEditor",
98
85
  value: function renderEditor() {
99
- var _this$options3,
86
+ var _this$options2,
100
87
  _this2 = this,
101
- _this$options4;
88
+ _this$options3;
102
89
  var fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
103
90
  if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
104
91
  return null;
105
92
  }
106
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
93
+ if (!((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.getSyncedBlockEditor)) {
107
94
  return null;
108
95
  }
109
96
  return /*#__PURE__*/_react.default.createElement(_SyncBlockEditorWrapper.SyncBlockEditorWrapper, {
110
97
  popupsBoundariesElement: fabricEditorPopupScrollParent,
111
98
  popupsMountPoint: fabricEditorPopupScrollParent,
112
99
  defaultDocument: defaultSyncBlockEditorDocument,
113
- handleContentChanges: function handleContentChanges(updatedDoc) {
114
- return _this2.handleContentChanges(updatedDoc);
100
+ useHandleContentChanges: function useHandleContentChanges(updatedDoc) {
101
+ var _this2$options;
102
+ return (0, _editorSyncedBlockProvider.useHandleContentChanges)(updatedDoc, _this2.isSource(), _this2.node, (_this2$options = _this2.options) === null || _this2$options === void 0 ? void 0 : _this2$options.dataProvider);
115
103
  },
116
104
  setInnerEditorView: function setInnerEditorView(editorView) {
117
105
  return _this2.setInnerEditorView(editorView);
118
106
  },
119
- getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
107
+ getSyncedBlockEditor: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.getSyncedBlockEditor
120
108
  });
121
109
  }
122
110
  }, {
123
111
  key: "renderRenderer",
124
112
  value: function renderRenderer() {
125
- var _this$options5,
113
+ var _this$options4,
126
114
  _this3 = this,
127
- _this$options6;
128
- if (!((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.getSyncedBlockRenderer)) {
115
+ _this$options5;
116
+ if (!((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.getSyncedBlockRenderer)) {
129
117
  return null;
130
118
  }
131
119
 
@@ -136,7 +124,7 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
136
124
  var _this3$options;
137
125
  return (0, _editorSyncedBlockProvider.useFetchDocNode)(_this3.view, _this3.node, defaultSyncBlockRendererDocument, (_this3$options = _this3.options) === null || _this3$options === void 0 ? void 0 : _this3$options.dataProvider);
138
126
  },
139
- getSyncedBlockRenderer: (_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.getSyncedBlockRenderer
127
+ getSyncedBlockRenderer: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.getSyncedBlockRenderer
140
128
  });
141
129
  }
142
130
  }, {
@@ -1,12 +1,16 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapper = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
+ var _react = _interopRequireWildcard(require("react"));
9
11
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
12
+ var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
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); }
10
14
  var SyncBlockEditorWrapperDataId = exports.SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
11
15
  var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_ref) {
12
16
  var defaultDocument = _ref.defaultDocument,
@@ -14,7 +18,12 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
14
18
  popupsBoundariesElement = _ref.popupsBoundariesElement,
15
19
  popupsMountPoint = _ref.popupsMountPoint,
16
20
  setInnerEditorView = _ref.setInnerEditorView,
17
- handleContentChanges = _ref.handleContentChanges;
21
+ useHandleContentChanges = _ref.useHandleContentChanges;
22
+ var _useState = (0, _react.useState)(new _editorJsonTransformer.JSONTransformer().parse(defaultDocument)),
23
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
24
+ updatedDoc = _useState2[0],
25
+ setUpdatedDoc = _useState2[1];
26
+ useHandleContentChanges(updatedDoc);
18
27
  return /*#__PURE__*/_react.default.createElement("div", {
19
28
  "data-testid": SyncBlockEditorWrapperDataId
20
29
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -25,7 +34,7 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
25
34
  defaultDocument: defaultDocument,
26
35
  popupsMountPoint: popupsMountPoint,
27
36
  onChange: function onChange(value) {
28
- return handleContentChanges(value.state.doc);
37
+ return setUpdatedDoc(value.state.doc);
29
38
  },
30
39
  onEditorReady: function onEditorReady(value) {
31
40
  return setInnerEditorView(value.editorView);
@@ -2,7 +2,7 @@ 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
4
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
- import { convertSyncBlockPMNodeToSyncBlockData, useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
5
+ import { convertSyncBlockPMNodeToSyncBlockData, useFetchDocNode, useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
6
6
  import { SyncBlockEditorWrapper, SyncBlockEditorWrapperDataId } from '../ui/SyncBlockEditorWrapper';
7
7
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
8
8
  const defaultSyncBlockEditorDocument = {
@@ -41,22 +41,11 @@ class SyncBlock extends ReactNodeView {
41
41
  isSource() {
42
42
  return this.syncBlockStore.isSourceBlock(this.node);
43
43
  }
44
- handleContentChanges(updatedDoc) {
45
- var _this$options, _this$options$dataPro;
46
- if (!this.isSource) {
47
- return;
48
- }
49
- // write data
50
- const node = convertSyncBlockPMNodeToSyncBlockData(this.node, false);
51
- (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dataPro = _this$options.dataProvider) === null || _this$options$dataPro === void 0 ? void 0 : _this$options$dataPro.writeNodesData([node], [{
52
- content: updatedDoc.toJSON()
53
- }]);
54
- }
55
44
  setInnerEditorView(editorView) {
56
- var _this$options2, _this$options2$dataPr;
45
+ var _this$options, _this$options$dataPro;
57
46
  // set inner editor view
58
47
  const nodes = [convertSyncBlockPMNodeToSyncBlockData(this.node, false)];
59
- (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$dataPr = _this$options2.dataProvider) === null || _this$options2$dataPr === void 0 ? void 0 : _this$options2$dataPr.fetchNodesData(nodes).then(data => {
48
+ (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dataPro = _this$options.dataProvider) === null || _this$options$dataPro === void 0 ? void 0 : _this$options$dataPro.fetchNodesData(nodes).then(data => {
60
49
  var _data$;
61
50
  const tr = editorView.state.tr;
62
51
  if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
@@ -66,19 +55,22 @@ class SyncBlock extends ReactNodeView {
66
55
  });
67
56
  }
68
57
  renderEditor() {
69
- var _this$options3, _this$options4;
58
+ var _this$options2, _this$options4;
70
59
  const fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
71
60
  if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
72
61
  return null;
73
62
  }
74
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
63
+ if (!((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.getSyncedBlockEditor)) {
75
64
  return null;
76
65
  }
77
66
  return /*#__PURE__*/React.createElement(SyncBlockEditorWrapper, {
78
67
  popupsBoundariesElement: fabricEditorPopupScrollParent,
79
68
  popupsMountPoint: fabricEditorPopupScrollParent,
80
69
  defaultDocument: defaultSyncBlockEditorDocument,
81
- handleContentChanges: updatedDoc => this.handleContentChanges(updatedDoc),
70
+ useHandleContentChanges: updatedDoc => {
71
+ var _this$options3;
72
+ return useHandleContentChanges(updatedDoc, this.isSource(), this.node, (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.dataProvider);
73
+ },
82
74
  setInnerEditorView: editorView => this.setInnerEditorView(editorView),
83
75
  getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
84
76
  });
@@ -1,5 +1,6 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
3
+ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
4
  export const SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
4
5
  const SyncBlockEditorWrapperComponent = ({
5
6
  defaultDocument,
@@ -7,8 +8,10 @@ const SyncBlockEditorWrapperComponent = ({
7
8
  popupsBoundariesElement,
8
9
  popupsMountPoint,
9
10
  setInnerEditorView,
10
- handleContentChanges
11
+ useHandleContentChanges
11
12
  }) => {
13
+ const [updatedDoc, setUpdatedDoc] = useState(new JSONTransformer().parse(defaultDocument));
14
+ useHandleContentChanges(updatedDoc);
12
15
  return /*#__PURE__*/React.createElement("div", {
13
16
  "data-testid": SyncBlockEditorWrapperDataId
14
17
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -18,7 +21,7 @@ const SyncBlockEditorWrapperComponent = ({
18
21
  popupsBoundariesElement,
19
22
  defaultDocument,
20
23
  popupsMountPoint,
21
- onChange: value => handleContentChanges(value.state.doc),
24
+ onChange: value => setUpdatedDoc(value.state.doc),
22
25
  onEditorReady: value => setInnerEditorView(value.editorView)
23
26
  }));
24
27
  };
@@ -11,7 +11,7 @@ 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
13
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
14
- import { convertSyncBlockPMNodeToSyncBlockData, useFetchDocNode as _useFetchDocNode } from '@atlaskit/editor-synced-block-provider';
14
+ import { convertSyncBlockPMNodeToSyncBlockData, useFetchDocNode as _useFetchDocNode, useHandleContentChanges as _useHandleContentChanges } from '@atlaskit/editor-synced-block-provider';
15
15
  import { SyncBlockEditorWrapper, SyncBlockEditorWrapperDataId } from '../ui/SyncBlockEditorWrapper';
16
16
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
17
17
  var defaultSyncBlockEditorDocument = {
@@ -58,26 +58,13 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
58
58
  value: function isSource() {
59
59
  return this.syncBlockStore.isSourceBlock(this.node);
60
60
  }
61
- }, {
62
- key: "handleContentChanges",
63
- value: function handleContentChanges(updatedDoc) {
64
- var _this$options;
65
- if (!this.isSource) {
66
- return;
67
- }
68
- // write data
69
- var node = convertSyncBlockPMNodeToSyncBlockData(this.node, false);
70
- (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.dataProvider) === null || _this$options === void 0 || _this$options.writeNodesData([node], [{
71
- content: updatedDoc.toJSON()
72
- }]);
73
- }
74
61
  }, {
75
62
  key: "setInnerEditorView",
76
63
  value: function setInnerEditorView(editorView) {
77
- var _this$options2;
64
+ var _this$options;
78
65
  // set inner editor view
79
66
  var nodes = [convertSyncBlockPMNodeToSyncBlockData(this.node, false)];
80
- (_this$options2 = this.options) === null || _this$options2 === void 0 || (_this$options2 = _this$options2.dataProvider) === null || _this$options2 === void 0 || _this$options2.fetchNodesData(nodes).then(function (data) {
67
+ (_this$options = this.options) === null || _this$options === void 0 || (_this$options = _this$options.dataProvider) === null || _this$options === void 0 || _this$options.fetchNodesData(nodes).then(function (data) {
81
68
  var _data$;
82
69
  var tr = editorView.state.tr;
83
70
  if (data && (_data$ = data[0]) !== null && _data$ !== void 0 && _data$.content) {
@@ -89,36 +76,37 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
89
76
  }, {
90
77
  key: "renderEditor",
91
78
  value: function renderEditor() {
92
- var _this$options3,
79
+ var _this$options2,
93
80
  _this2 = this,
94
- _this$options4;
81
+ _this$options3;
95
82
  var fabricEditorPopupScrollParent = this.view.dom.closest('.fabric-editor-popup-scroll-parent');
96
83
  if (!(fabricEditorPopupScrollParent instanceof HTMLElement)) {
97
84
  return null;
98
85
  }
99
- if (!((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.getSyncedBlockEditor)) {
86
+ if (!((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.getSyncedBlockEditor)) {
100
87
  return null;
101
88
  }
102
89
  return /*#__PURE__*/React.createElement(SyncBlockEditorWrapper, {
103
90
  popupsBoundariesElement: fabricEditorPopupScrollParent,
104
91
  popupsMountPoint: fabricEditorPopupScrollParent,
105
92
  defaultDocument: defaultSyncBlockEditorDocument,
106
- handleContentChanges: function handleContentChanges(updatedDoc) {
107
- return _this2.handleContentChanges(updatedDoc);
93
+ useHandleContentChanges: function useHandleContentChanges(updatedDoc) {
94
+ var _this2$options;
95
+ return _useHandleContentChanges(updatedDoc, _this2.isSource(), _this2.node, (_this2$options = _this2.options) === null || _this2$options === void 0 ? void 0 : _this2$options.dataProvider);
108
96
  },
109
97
  setInnerEditorView: function setInnerEditorView(editorView) {
110
98
  return _this2.setInnerEditorView(editorView);
111
99
  },
112
- getSyncedBlockEditor: (_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.getSyncedBlockEditor
100
+ getSyncedBlockEditor: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.getSyncedBlockEditor
113
101
  });
114
102
  }
115
103
  }, {
116
104
  key: "renderRenderer",
117
105
  value: function renderRenderer() {
118
- var _this$options5,
106
+ var _this$options4,
119
107
  _this3 = this,
120
- _this$options6;
121
- if (!((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.getSyncedBlockRenderer)) {
108
+ _this$options5;
109
+ if (!((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.getSyncedBlockRenderer)) {
122
110
  return null;
123
111
  }
124
112
 
@@ -129,7 +117,7 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
129
117
  var _this3$options;
130
118
  return _useFetchDocNode(_this3.view, _this3.node, defaultSyncBlockRendererDocument, (_this3$options = _this3.options) === null || _this3$options === void 0 ? void 0 : _this3$options.dataProvider);
131
119
  },
132
- getSyncedBlockRenderer: (_this$options6 = this.options) === null || _this$options6 === void 0 ? void 0 : _this$options6.getSyncedBlockRenderer
120
+ getSyncedBlockRenderer: (_this$options5 = this.options) === null || _this$options5 === void 0 ? void 0 : _this$options5.getSyncedBlockRenderer
133
121
  });
134
122
  }
135
123
  }, {
@@ -1,5 +1,7 @@
1
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useState } from 'react';
2
3
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
4
+ import { JSONTransformer } from '@atlaskit/editor-json-transformer';
3
5
  export var SyncBlockEditorWrapperDataId = 'sync-block-plugin-editor-wrapper';
4
6
  var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_ref) {
5
7
  var defaultDocument = _ref.defaultDocument,
@@ -7,7 +9,12 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
7
9
  popupsBoundariesElement = _ref.popupsBoundariesElement,
8
10
  popupsMountPoint = _ref.popupsMountPoint,
9
11
  setInnerEditorView = _ref.setInnerEditorView,
10
- handleContentChanges = _ref.handleContentChanges;
12
+ useHandleContentChanges = _ref.useHandleContentChanges;
13
+ var _useState = useState(new JSONTransformer().parse(defaultDocument)),
14
+ _useState2 = _slicedToArray(_useState, 2),
15
+ updatedDoc = _useState2[0],
16
+ setUpdatedDoc = _useState2[1];
17
+ useHandleContentChanges(updatedDoc);
11
18
  return /*#__PURE__*/React.createElement("div", {
12
19
  "data-testid": SyncBlockEditorWrapperDataId
13
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
@@ -18,7 +25,7 @@ var SyncBlockEditorWrapperComponent = function SyncBlockEditorWrapperComponent(_
18
25
  defaultDocument: defaultDocument,
19
26
  popupsMountPoint: popupsMountPoint,
20
27
  onChange: function onChange(value) {
21
- return handleContentChanges(value.state.doc);
28
+ return setUpdatedDoc(value.state.doc);
22
29
  },
23
30
  onEditorReady: function onEditorReady(value) {
24
31
  return setInnerEditorView(value.editorView);
@@ -27,7 +27,6 @@ declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
29
  private isSource;
30
- private handleContentChanges;
31
30
  private setInnerEditorView;
32
31
  private renderEditor;
33
32
  private renderRenderer;
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
- import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import { type JSONDocNode } from '@atlaskit/editor-json-transformer';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SyncedBlockEditorProps } from '../syncedBlockPluginType';
6
6
  type Props = {
7
7
  defaultDocument: JSONDocNode;
8
8
  getSyncedBlockEditor: (props: SyncedBlockEditorProps) => React.JSX.Element;
9
- handleContentChanges: (updatedDoc: PMNode) => void;
10
9
  popupsBoundariesElement: HTMLElement;
11
10
  popupsMountPoint: HTMLElement;
12
11
  setInnerEditorView: (editorView: EditorView) => void;
12
+ useHandleContentChanges: (updatedDoc: PMNode) => void;
13
13
  };
14
14
  export declare const SyncBlockEditorWrapperDataId = "sync-block-plugin-editor-wrapper";
15
- export declare const SyncBlockEditorWrapper: React.MemoExoticComponent<({ defaultDocument, getSyncedBlockEditor, popupsBoundariesElement, popupsMountPoint, setInnerEditorView, handleContentChanges, }: Props) => React.JSX.Element>;
15
+ export declare const SyncBlockEditorWrapper: React.MemoExoticComponent<({ defaultDocument, getSyncedBlockEditor, popupsBoundariesElement, popupsMountPoint, setInnerEditorView, useHandleContentChanges, }: Props) => React.JSX.Element>;
16
16
  export {};
@@ -27,7 +27,6 @@ declare class SyncBlock extends ReactNodeView<SyncBlockNodeViewProps> {
27
27
  unsubscribe: (() => void) | undefined;
28
28
  createDomRef(): HTMLElement;
29
29
  private isSource;
30
- private handleContentChanges;
31
30
  private setInnerEditorView;
32
31
  private renderEditor;
33
32
  private renderRenderer;
@@ -1,16 +1,16 @@
1
1
  import React from 'react';
2
- import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
2
+ import { type JSONDocNode } from '@atlaskit/editor-json-transformer';
3
3
  import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
4
4
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
5
  import type { SyncedBlockEditorProps } from '../syncedBlockPluginType';
6
6
  type Props = {
7
7
  defaultDocument: JSONDocNode;
8
8
  getSyncedBlockEditor: (props: SyncedBlockEditorProps) => React.JSX.Element;
9
- handleContentChanges: (updatedDoc: PMNode) => void;
10
9
  popupsBoundariesElement: HTMLElement;
11
10
  popupsMountPoint: HTMLElement;
12
11
  setInnerEditorView: (editorView: EditorView) => void;
12
+ useHandleContentChanges: (updatedDoc: PMNode) => void;
13
13
  };
14
14
  export declare const SyncBlockEditorWrapperDataId = "sync-block-plugin-editor-wrapper";
15
- export declare const SyncBlockEditorWrapper: React.MemoExoticComponent<({ defaultDocument, getSyncedBlockEditor, popupsBoundariesElement, popupsMountPoint, setInnerEditorView, handleContentChanges, }: Props) => React.JSX.Element>;
15
+ export declare const SyncBlockEditorWrapper: React.MemoExoticComponent<({ defaultDocument, getSyncedBlockEditor, popupsBoundariesElement, popupsMountPoint, setInnerEditorView, useHandleContentChanges, }: Props) => React.JSX.Element>;
16
16
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -30,13 +30,14 @@
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.2.0",
32
32
  "@atlaskit/button": "23.5.0",
33
+ "@atlaskit/editor-json-transformer": "^8.30.0",
33
34
  "@atlaskit/editor-plugin-block-menu": "^4.0.0",
34
35
  "@atlaskit/editor-plugin-decorations": "^6.1.0",
35
36
  "@atlaskit/editor-plugin-floating-toolbar": "^8.2.0",
36
37
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
38
  "@atlaskit/editor-prosemirror": "7.0.0",
38
39
  "@atlaskit/editor-shared-styles": "^3.6.0",
39
- "@atlaskit/editor-synced-block-provider": "^0.4.0",
40
+ "@atlaskit/editor-synced-block-provider": "^0.5.0",
40
41
  "@atlaskit/editor-toolbar": "^0.14.0",
41
42
  "@atlaskit/icon": "28.5.0",
42
43
  "@atlaskit/modal-dialog": "^14.4.0",
@@ -44,7 +45,7 @@
44
45
  "react-intl-next": "npm:react-intl@^5.18.1"
45
46
  },
46
47
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^110.7.0",
48
+ "@atlaskit/editor-common": "^110.8.0",
48
49
  "react": "^18.2.0"
49
50
  },
50
51
  "devDependencies": {