@atlaskit/editor-plugin-synced-block 3.6.1 → 3.7.1
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 +19 -0
- package/dist/cjs/nodeviews/bodiedSyncedBlock.js +2 -3
- package/dist/cjs/nodeviews/syncedBlock.js +1 -3
- package/dist/cjs/pm-plugins/actions.js +3 -3
- package/dist/cjs/pm-plugins/main.js +15 -0
- package/dist/cjs/syncedBlockPlugin.js +1 -3
- package/dist/cjs/ui/BodiedSyncBlockWrapper.js +2 -7
- package/dist/cjs/ui/floating-toolbar.js +1 -1
- package/dist/es2019/nodeviews/bodiedSyncedBlock.js +2 -3
- package/dist/es2019/nodeviews/syncedBlock.js +3 -7
- package/dist/es2019/pm-plugins/actions.js +3 -3
- package/dist/es2019/pm-plugins/main.js +15 -0
- package/dist/es2019/syncedBlockPlugin.js +1 -3
- package/dist/es2019/ui/BodiedSyncBlockWrapper.js +2 -7
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/esm/nodeviews/bodiedSyncedBlock.js +2 -3
- package/dist/esm/nodeviews/syncedBlock.js +1 -3
- package/dist/esm/pm-plugins/actions.js +3 -3
- package/dist/esm/pm-plugins/main.js +15 -0
- package/dist/esm/syncedBlockPlugin.js +1 -3
- package/dist/esm/ui/BodiedSyncBlockWrapper.js +2 -7
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/types/nodeviews/bodiedSyncedBlock.d.ts +1 -0
- package/dist/types/pm-plugins/actions.d.ts +1 -2
- package/dist/types/ui/BodiedSyncBlockWrapper.d.ts +2 -2
- package/dist/types-ts4.5/nodeviews/bodiedSyncedBlock.d.ts +1 -0
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +1 -2
- package/dist/types-ts4.5/ui/BodiedSyncBlockWrapper.d.ts +2 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 3.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`cdf397d4529c6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cdf397d4529c6) -
|
|
8
|
+
EDITOR-2443 Temporary fix for inserting 'random' node into sync block on enter
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 3.7.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [`7b80545f98f03`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7b80545f98f03) -
|
|
16
|
+
Refactor to suit provider changes
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 3.6.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -28,7 +28,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
28
28
|
var _this;
|
|
29
29
|
(0, _classCallCheck2.default)(this, BodiedSyncBlock);
|
|
30
30
|
_this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
31
|
-
_this.
|
|
31
|
+
_this.syncBlockStore = props.syncBlockStore;
|
|
32
32
|
return _this;
|
|
33
33
|
}
|
|
34
34
|
(0, _inherits2.default)(BodiedSyncBlock, _ReactNodeView);
|
|
@@ -42,10 +42,9 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
42
42
|
}, {
|
|
43
43
|
key: "render",
|
|
44
44
|
value: function render(_props, forwardRef) {
|
|
45
|
-
var _this$pluginOptions;
|
|
46
45
|
return /*#__PURE__*/_react.default.createElement(_BodiedSyncBlockWrapper.BodiedSyncBlockWrapper, {
|
|
47
46
|
ref: forwardRef,
|
|
48
|
-
|
|
47
|
+
syncBlockStore: this.syncBlockStore,
|
|
49
48
|
node: this.node
|
|
50
49
|
});
|
|
51
50
|
}
|
|
@@ -37,7 +37,6 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
37
37
|
_this = _callSuper(this, SyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
38
38
|
_this.options = props.options;
|
|
39
39
|
_this.syncBlockStore = props.syncBlockStore;
|
|
40
|
-
_this.syncBlockStore.updateSyncBlockNode(_this.node);
|
|
41
40
|
return _this;
|
|
42
41
|
}
|
|
43
42
|
(0, _inherits2.default)(SyncBlock, _ReactNodeView);
|
|
@@ -62,8 +61,7 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
62
61
|
|
|
63
62
|
return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
|
|
64
63
|
useFetchDocNode: function useFetchDocNode() {
|
|
65
|
-
|
|
66
|
-
return (0, _editorSyncedBlockProvider.useFetchDocNode)(_this2.view, _this2.node, defaultSyncBlockRendererDocument, (_this2$options = _this2.options) === null || _this2$options === void 0 ? void 0 : _this2$options.dataProvider);
|
|
64
|
+
return (0, _editorSyncedBlockProvider.useFetchDocNode)(_this2.syncBlockStore, _this2.node, defaultSyncBlockRendererDocument);
|
|
67
65
|
},
|
|
68
66
|
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
69
67
|
});
|
|
@@ -84,11 +84,11 @@ var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedB
|
|
|
84
84
|
return function (state, dispatch, _view) {
|
|
85
85
|
var _syncBlock$node;
|
|
86
86
|
var syncBlock = (0, _utils.findSyncBlock)(state);
|
|
87
|
-
var
|
|
88
|
-
if (!
|
|
87
|
+
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
|
+
if (!localId) {
|
|
89
89
|
return false;
|
|
90
90
|
}
|
|
91
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
91
|
+
var syncBlockURL = syncBlockStore.getSyncBlockURL(localId);
|
|
92
92
|
if (syncBlockURL) {
|
|
93
93
|
window.open(syncBlockURL, '_blank');
|
|
94
94
|
} else {
|
|
@@ -9,10 +9,14 @@ 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");
|
|
12
13
|
var syncedBlockPluginKey = exports.syncedBlockPluginKey = new _state.PluginKey('syncedBlockPlugin');
|
|
13
14
|
|
|
14
15
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
15
16
|
|
|
17
|
+
function isInsideBodiedSyncBlock(state, selection) {
|
|
18
|
+
return (0, _utils.findBodiedSyncBlock)(state, selection) !== undefined;
|
|
19
|
+
}
|
|
16
20
|
var createPlugin = exports.createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
17
21
|
return new _safePlugin.SafePlugin({
|
|
18
22
|
key: syncedBlockPluginKey,
|
|
@@ -42,6 +46,17 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
42
46
|
api: api,
|
|
43
47
|
syncBlockStore: syncBlockStore
|
|
44
48
|
})
|
|
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;
|
|
45
60
|
}
|
|
46
61
|
},
|
|
47
62
|
view: function view(editorView) {
|
|
@@ -46,8 +46,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
46
46
|
var tr = _ref2.tr;
|
|
47
47
|
return (0, _actions.createSyncedBlock)({
|
|
48
48
|
tr: tr,
|
|
49
|
-
syncBlockStore: syncBlockStore
|
|
50
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider
|
|
49
|
+
syncBlockStore: syncBlockStore
|
|
51
50
|
}) || null;
|
|
52
51
|
};
|
|
53
52
|
}
|
|
@@ -71,7 +70,6 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
71
70
|
return (0, _actions.createSyncedBlock)({
|
|
72
71
|
tr: state.tr,
|
|
73
72
|
syncBlockStore: syncBlockStore,
|
|
74
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider,
|
|
75
73
|
typeAheadInsert: insert
|
|
76
74
|
});
|
|
77
75
|
}
|
|
@@ -10,14 +10,9 @@ var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider
|
|
|
10
10
|
var _SyncBlockLabel = require("./SyncBlockLabel");
|
|
11
11
|
var BodiedSyncBlockWrapper = exports.BodiedSyncBlockWrapper = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
12
12
|
var node = _ref.node,
|
|
13
|
-
|
|
13
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
14
14
|
// TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
|
|
15
|
-
|
|
16
|
-
version: 1,
|
|
17
|
-
type: 'doc',
|
|
18
|
-
content: node.content.toJSON()
|
|
19
|
-
};
|
|
20
|
-
(0, _editorSyncedBlockProvider.useHandleContentChanges)(docJSON, true, node, dataProvider);
|
|
15
|
+
(0, _editorSyncedBlockProvider.useHandleContentChanges)(syncBlockStore, node);
|
|
21
16
|
return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, null), /*#__PURE__*/_react.default.createElement("div", {
|
|
22
17
|
"data-testid": "bodied-sync-block-wrapper",
|
|
23
18
|
ref: ref
|
|
@@ -54,7 +54,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
54
54
|
onClick: (0, _actions.copySyncedBlockReferenceToClipboard)(api)
|
|
55
55
|
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
56
56
|
items.push(copyButton);
|
|
57
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
57
|
+
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.localId);
|
|
58
58
|
if (!isBodiedSyncBlock) {
|
|
59
59
|
var editSourceButton = _objectSpread({
|
|
60
60
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -10,7 +10,7 @@ const toDOM = () => ['div', {
|
|
|
10
10
|
class BodiedSyncBlock extends ReactNodeView {
|
|
11
11
|
constructor(props) {
|
|
12
12
|
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
13
|
-
this.
|
|
13
|
+
this.syncBlockStore = props.syncBlockStore;
|
|
14
14
|
}
|
|
15
15
|
createDomRef() {
|
|
16
16
|
const domRef = document.createElement('div');
|
|
@@ -18,10 +18,9 @@ class BodiedSyncBlock extends ReactNodeView {
|
|
|
18
18
|
return domRef;
|
|
19
19
|
}
|
|
20
20
|
render(_props, forwardRef) {
|
|
21
|
-
var _this$pluginOptions;
|
|
22
21
|
return /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
|
|
23
22
|
ref: forwardRef,
|
|
24
|
-
|
|
23
|
+
syncBlockStore: this.syncBlockStore,
|
|
25
24
|
node: this.node
|
|
26
25
|
});
|
|
27
26
|
}
|
|
@@ -19,7 +19,6 @@ class SyncBlock extends ReactNodeView {
|
|
|
19
19
|
super(props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props);
|
|
20
20
|
this.options = props.options;
|
|
21
21
|
this.syncBlockStore = props.syncBlockStore;
|
|
22
|
-
this.syncBlockStore.updateSyncBlockNode(this.node);
|
|
23
22
|
}
|
|
24
23
|
createDomRef() {
|
|
25
24
|
const domRef = document.createElement('div');
|
|
@@ -27,7 +26,7 @@ class SyncBlock extends ReactNodeView {
|
|
|
27
26
|
return domRef;
|
|
28
27
|
}
|
|
29
28
|
render() {
|
|
30
|
-
var _this$options, _this$
|
|
29
|
+
var _this$options, _this$options2;
|
|
31
30
|
if (!((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.getSyncedBlockRenderer)) {
|
|
32
31
|
return null;
|
|
33
32
|
}
|
|
@@ -35,11 +34,8 @@ class SyncBlock extends ReactNodeView {
|
|
|
35
34
|
// get document node from data provider
|
|
36
35
|
|
|
37
36
|
return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
38
|
-
useFetchDocNode: () =>
|
|
39
|
-
|
|
40
|
-
return useFetchDocNode(this.view, this.node, defaultSyncBlockRendererDocument, (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.dataProvider);
|
|
41
|
-
},
|
|
42
|
-
getSyncedBlockRenderer: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.getSyncedBlockRenderer
|
|
37
|
+
useFetchDocNode: () => useFetchDocNode(this.syncBlockStore, this.node, defaultSyncBlockRendererDocument),
|
|
38
|
+
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
41
|
destroy() {
|
|
@@ -87,11 +87,11 @@ export const copySyncedBlockReferenceToClipboard = api => (state, _dispatch, _vi
|
|
|
87
87
|
export const editSyncedBlockSource = (syncBlockStore, api) => (state, dispatch, _view) => {
|
|
88
88
|
var _syncBlock$node, _syncBlock$node$attrs;
|
|
89
89
|
const syncBlock = findSyncBlock(state);
|
|
90
|
-
const
|
|
91
|
-
if (!
|
|
90
|
+
const localId = syncBlock === null || syncBlock === void 0 ? void 0 : (_syncBlock$node = syncBlock.node) === null || _syncBlock$node === void 0 ? void 0 : (_syncBlock$node$attrs = _syncBlock$node.attrs) === null || _syncBlock$node$attrs === void 0 ? void 0 : _syncBlock$node$attrs.localId;
|
|
91
|
+
if (!localId) {
|
|
92
92
|
return false;
|
|
93
93
|
}
|
|
94
|
-
const syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
94
|
+
const syncBlockURL = syncBlockStore.getSyncBlockURL(localId);
|
|
95
95
|
if (syncBlockURL) {
|
|
96
96
|
window.open(syncBlockURL, '_blank');
|
|
97
97
|
} else {
|
|
@@ -3,10 +3,14 @@ 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';
|
|
6
7
|
export const syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
7
8
|
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
9
10
|
|
|
11
|
+
function isInsideBodiedSyncBlock(state, selection) {
|
|
12
|
+
return findBodiedSyncBlock(state, selection) !== undefined;
|
|
13
|
+
}
|
|
10
14
|
export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api) => {
|
|
11
15
|
return new SafePlugin({
|
|
12
16
|
key: syncedBlockPluginKey,
|
|
@@ -36,6 +40,17 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
36
40
|
api,
|
|
37
41
|
syncBlockStore
|
|
38
42
|
})
|
|
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;
|
|
39
54
|
}
|
|
40
55
|
},
|
|
41
56
|
view: editorView => {
|
|
@@ -37,8 +37,7 @@ export const syncedBlockPlugin = ({
|
|
|
37
37
|
tr
|
|
38
38
|
}) => createSyncedBlock({
|
|
39
39
|
tr,
|
|
40
|
-
syncBlockStore
|
|
41
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider
|
|
40
|
+
syncBlockStore
|
|
42
41
|
}) || null
|
|
43
42
|
},
|
|
44
43
|
pluginsOptions: {
|
|
@@ -58,7 +57,6 @@ export const syncedBlockPlugin = ({
|
|
|
58
57
|
return createSyncedBlock({
|
|
59
58
|
tr: state.tr,
|
|
60
59
|
syncBlockStore,
|
|
61
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider,
|
|
62
60
|
typeAheadInsert: insert
|
|
63
61
|
});
|
|
64
62
|
}
|
|
@@ -3,15 +3,10 @@ import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider'
|
|
|
3
3
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
4
4
|
export const BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(({
|
|
5
5
|
node,
|
|
6
|
-
|
|
6
|
+
syncBlockStore
|
|
7
7
|
}, ref) => {
|
|
8
8
|
// TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
|
|
9
|
-
|
|
10
|
-
version: 1,
|
|
11
|
-
type: 'doc',
|
|
12
|
-
content: node.content.toJSON()
|
|
13
|
-
};
|
|
14
|
-
useHandleContentChanges(docJSON, true, node, dataProvider);
|
|
9
|
+
useHandleContentChanges(syncBlockStore, node);
|
|
15
10
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
|
|
16
11
|
"data-testid": "bodied-sync-block-wrapper",
|
|
17
12
|
ref: ref
|
|
@@ -45,7 +45,7 @@ export const getToolbarConfig = (state, intl, _options = {}, _providerFactory, a
|
|
|
45
45
|
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
46
46
|
};
|
|
47
47
|
items.push(copyButton);
|
|
48
|
-
const disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
48
|
+
const disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.localId);
|
|
49
49
|
if (!isBodiedSyncBlock) {
|
|
50
50
|
const editSourceButton = {
|
|
51
51
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -21,7 +21,7 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
21
21
|
var _this;
|
|
22
22
|
_classCallCheck(this, BodiedSyncBlock);
|
|
23
23
|
_this = _callSuper(this, BodiedSyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
24
|
-
_this.
|
|
24
|
+
_this.syncBlockStore = props.syncBlockStore;
|
|
25
25
|
return _this;
|
|
26
26
|
}
|
|
27
27
|
_inherits(BodiedSyncBlock, _ReactNodeView);
|
|
@@ -35,10 +35,9 @@ var BodiedSyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
35
35
|
}, {
|
|
36
36
|
key: "render",
|
|
37
37
|
value: function render(_props, forwardRef) {
|
|
38
|
-
var _this$pluginOptions;
|
|
39
38
|
return /*#__PURE__*/React.createElement(BodiedSyncBlockWrapper, {
|
|
40
39
|
ref: forwardRef,
|
|
41
|
-
|
|
40
|
+
syncBlockStore: this.syncBlockStore,
|
|
42
41
|
node: this.node
|
|
43
42
|
});
|
|
44
43
|
}
|
|
@@ -30,7 +30,6 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
30
30
|
_this = _callSuper(this, SyncBlock, [props.node, props.view, props.getPos, props.portalProviderAPI, props.eventDispatcher, props]);
|
|
31
31
|
_this.options = props.options;
|
|
32
32
|
_this.syncBlockStore = props.syncBlockStore;
|
|
33
|
-
_this.syncBlockStore.updateSyncBlockNode(_this.node);
|
|
34
33
|
return _this;
|
|
35
34
|
}
|
|
36
35
|
_inherits(SyncBlock, _ReactNodeView);
|
|
@@ -55,8 +54,7 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
55
54
|
|
|
56
55
|
return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
|
|
57
56
|
useFetchDocNode: function useFetchDocNode() {
|
|
58
|
-
|
|
59
|
-
return _useFetchDocNode(_this2.view, _this2.node, defaultSyncBlockRendererDocument, (_this2$options = _this2.options) === null || _this2$options === void 0 ? void 0 : _this2$options.dataProvider);
|
|
57
|
+
return _useFetchDocNode(_this2.syncBlockStore, _this2.node, defaultSyncBlockRendererDocument);
|
|
60
58
|
},
|
|
61
59
|
getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer
|
|
62
60
|
});
|
|
@@ -77,11 +77,11 @@ export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore
|
|
|
77
77
|
return function (state, dispatch, _view) {
|
|
78
78
|
var _syncBlock$node;
|
|
79
79
|
var syncBlock = findSyncBlock(state);
|
|
80
|
-
var
|
|
81
|
-
if (!
|
|
80
|
+
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;
|
|
81
|
+
if (!localId) {
|
|
82
82
|
return false;
|
|
83
83
|
}
|
|
84
|
-
var syncBlockURL = syncBlockStore.getSyncBlockURL(
|
|
84
|
+
var syncBlockURL = syncBlockStore.getSyncBlockURL(localId);
|
|
85
85
|
if (syncBlockURL) {
|
|
86
86
|
window.open(syncBlockURL, '_blank');
|
|
87
87
|
} else {
|
|
@@ -3,10 +3,14 @@ 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';
|
|
6
7
|
export var syncedBlockPluginKey = new PluginKey('syncedBlockPlugin');
|
|
7
8
|
|
|
8
9
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
9
10
|
|
|
11
|
+
function isInsideBodiedSyncBlock(state, selection) {
|
|
12
|
+
return findBodiedSyncBlock(state, selection) !== undefined;
|
|
13
|
+
}
|
|
10
14
|
export var createPlugin = function createPlugin(options, pmPluginFactoryParams, syncBlockStore, api) {
|
|
11
15
|
return new SafePlugin({
|
|
12
16
|
key: syncedBlockPluginKey,
|
|
@@ -36,6 +40,17 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
36
40
|
api: api,
|
|
37
41
|
syncBlockStore: syncBlockStore
|
|
38
42
|
})
|
|
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;
|
|
39
54
|
}
|
|
40
55
|
},
|
|
41
56
|
view: function view(editorView) {
|
|
@@ -39,8 +39,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
39
39
|
var tr = _ref2.tr;
|
|
40
40
|
return createSyncedBlock({
|
|
41
41
|
tr: tr,
|
|
42
|
-
syncBlockStore: syncBlockStore
|
|
43
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider
|
|
42
|
+
syncBlockStore: syncBlockStore
|
|
44
43
|
}) || null;
|
|
45
44
|
};
|
|
46
45
|
}
|
|
@@ -64,7 +63,6 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
64
63
|
return createSyncedBlock({
|
|
65
64
|
tr: state.tr,
|
|
66
65
|
syncBlockStore: syncBlockStore,
|
|
67
|
-
dataProvider: config === null || config === void 0 ? void 0 : config.dataProvider,
|
|
68
66
|
typeAheadInsert: insert
|
|
69
67
|
});
|
|
70
68
|
}
|
|
@@ -3,14 +3,9 @@ import { useHandleContentChanges } from '@atlaskit/editor-synced-block-provider'
|
|
|
3
3
|
import { SyncBlockLabel } from './SyncBlockLabel';
|
|
4
4
|
export var BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
5
5
|
var node = _ref.node,
|
|
6
|
-
|
|
6
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
7
7
|
// TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
|
|
8
|
-
|
|
9
|
-
version: 1,
|
|
10
|
-
type: 'doc',
|
|
11
|
-
content: node.content.toJSON()
|
|
12
|
-
};
|
|
13
|
-
useHandleContentChanges(docJSON, true, node, dataProvider);
|
|
8
|
+
useHandleContentChanges(syncBlockStore, node);
|
|
14
9
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
|
|
15
10
|
"data-testid": "bodied-sync-block-wrapper",
|
|
16
11
|
ref: ref
|
|
@@ -45,7 +45,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
|
45
45
|
onClick: copySyncedBlockReferenceToClipboard(api)
|
|
46
46
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
47
47
|
items.push(copyButton);
|
|
48
|
-
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.
|
|
48
|
+
var disabled = !syncBlockStore.getSyncBlockURL(syncBlockObject.node.attrs.localId);
|
|
49
49
|
if (!isBodiedSyncBlock) {
|
|
50
50
|
var editSourceButton = _objectSpread({
|
|
51
51
|
id: 'editor.syncedBlock.editSource',
|
|
@@ -15,6 +15,7 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
|
|
|
15
15
|
pluginOptions: SyncedBlockPluginOptions | undefined;
|
|
16
16
|
portalProviderAPI: PortalProviderAPI;
|
|
17
17
|
view: EditorView;
|
|
18
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
18
19
|
}
|
|
19
20
|
export interface BodiedSyncBlockNodeViewProperties {
|
|
20
21
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Command, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
5
5
|
type createSyncedBlockProps = {
|
|
6
|
-
dataProvider?: SyncBlockDataProvider;
|
|
7
6
|
syncBlockStore: SyncBlockStoreManager;
|
|
8
7
|
tr: Transaction;
|
|
9
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { type
|
|
3
|
+
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
interface BodiedSyncBlockWrapperProps {
|
|
5
|
-
dataProvider?: SyncBlockDataProvider | undefined;
|
|
6
5
|
node: PMNode;
|
|
6
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
7
7
|
}
|
|
8
8
|
export declare const BodiedSyncBlockWrapper: React.ForwardRefExoticComponent<BodiedSyncBlockWrapperProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
export {};
|
|
@@ -15,6 +15,7 @@ export interface BodiedSyncBlockNodeViewProps extends ReactComponentProps {
|
|
|
15
15
|
pluginOptions: SyncedBlockPluginOptions | undefined;
|
|
16
16
|
portalProviderAPI: PortalProviderAPI;
|
|
17
17
|
view: EditorView;
|
|
18
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
18
19
|
}
|
|
19
20
|
export interface BodiedSyncBlockNodeViewProperties {
|
|
20
21
|
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Command, ExtractInjectionAPI, TypeAheadInsert } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
5
5
|
type createSyncedBlockProps = {
|
|
6
|
-
dataProvider?: SyncBlockDataProvider;
|
|
7
6
|
syncBlockStore: SyncBlockStoreManager;
|
|
8
7
|
tr: Transaction;
|
|
9
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
|
-
import { type
|
|
3
|
+
import { type SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
4
|
interface BodiedSyncBlockWrapperProps {
|
|
5
|
-
dataProvider?: SyncBlockDataProvider | undefined;
|
|
6
5
|
node: PMNode;
|
|
6
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
7
7
|
}
|
|
8
8
|
export declare const BodiedSyncBlockWrapper: React.ForwardRefExoticComponent<BodiedSyncBlockWrapperProps & React.RefAttributes<HTMLDivElement>>;
|
|
9
9
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.1",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
40
40
|
"@atlaskit/editor-shared-styles": "^3.8.0",
|
|
41
|
-
"@atlaskit/editor-synced-block-provider": "^
|
|
41
|
+
"@atlaskit/editor-synced-block-provider": "^2.0.0",
|
|
42
42
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
43
43
|
"@atlaskit/editor-toolbar": "^0.15.0",
|
|
44
44
|
"@atlaskit/icon": "28.5.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^110.
|
|
50
|
+
"@atlaskit/editor-common": "^110.16.0",
|
|
51
51
|
"react": "^18.2.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|