@atlaskit/editor-plugin-synced-block 4.8.0 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/pm-plugins/main.js +3 -7
- package/dist/cjs/syncedBlockPlugin.js +9 -3
- package/dist/cjs/ui/CreateSyncedBlockDropdownItem.js +5 -2
- package/dist/cjs/ui/block-menu-components.js +3 -2
- package/dist/cjs/ui/toolbar-components.js +4 -1
- package/dist/es2019/pm-plugins/main.js +3 -7
- package/dist/es2019/syncedBlockPlugin.js +38 -28
- package/dist/es2019/ui/CreateSyncedBlockDropdownItem.js +5 -2
- package/dist/es2019/ui/block-menu-components.js +3 -2
- package/dist/es2019/ui/toolbar-components.js +4 -1
- package/dist/esm/pm-plugins/main.js +3 -7
- package/dist/esm/syncedBlockPlugin.js +9 -3
- package/dist/esm/ui/CreateSyncedBlockDropdownItem.js +5 -2
- package/dist/esm/ui/block-menu-components.js +3 -2
- package/dist/esm/ui/toolbar-components.js +4 -1
- package/dist/types/syncedBlockPluginType.d.ts +1 -0
- package/dist/types/ui/CreateSyncedBlockDropdownItem.d.ts +3 -2
- package/dist/types/ui/block-menu-components.d.ts +1 -1
- package/dist/types/ui/toolbar-components.d.ts +1 -1
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +1 -0
- package/dist/types-ts4.5/ui/CreateSyncedBlockDropdownItem.d.ts +3 -2
- package/dist/types-ts4.5/ui/block-menu-components.d.ts +1 -1
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 4.8.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`98568bfc82648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/98568bfc82648) -
|
|
8
|
+
EDITOR-3594 Synced Block creation to be prop driven
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 4.8.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`36f3146f35457`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/36f3146f35457) -
|
|
16
|
+
Early return on transformCopied when action is not copy
|
|
17
|
+
|
|
3
18
|
## 4.8.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -141,14 +141,12 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
141
141
|
var schema = state.schema;
|
|
142
142
|
var isCopy = isCopyEvent;
|
|
143
143
|
isCopyEvent = false;
|
|
144
|
-
if (!syncBlockStore) {
|
|
144
|
+
if (!syncBlockStore || !isCopy) {
|
|
145
145
|
return slice;
|
|
146
146
|
}
|
|
147
147
|
return (0, _utils.mapSlice)(slice, function (node) {
|
|
148
148
|
if (node.type.name === 'syncBlock') {
|
|
149
|
-
|
|
150
|
-
showCopiedFlag(api);
|
|
151
|
-
}
|
|
149
|
+
showCopiedFlag(api);
|
|
152
150
|
return node;
|
|
153
151
|
}
|
|
154
152
|
if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
|
|
@@ -157,9 +155,7 @@ var createPlugin = exports.createPlugin = function createPlugin(options, pmPlugi
|
|
|
157
155
|
if (!(0, _utils2.sliceFullyContainsNode)(slice, node)) {
|
|
158
156
|
return node.content;
|
|
159
157
|
}
|
|
160
|
-
|
|
161
|
-
showCopiedFlag(api);
|
|
162
|
-
}
|
|
158
|
+
showCopiedFlag(api);
|
|
163
159
|
var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
|
|
164
160
|
// Convert bodiedSyncBlock to syncBlock
|
|
165
161
|
// The paste transformation will regenrate the localId
|
|
@@ -21,12 +21,12 @@ var _floatingToolbar = require("./ui/floating-toolbar");
|
|
|
21
21
|
var _SyncBlockRefresher = require("./ui/SyncBlockRefresher");
|
|
22
22
|
var _toolbarComponents = require("./ui/toolbar-components");
|
|
23
23
|
var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
24
|
-
var _api$analytics, _api$blockMenu, _api$toolbar;
|
|
24
|
+
var _api$analytics, _api$blockMenu, _config$enableSourceC, _api$toolbar, _config$enableSourceC2;
|
|
25
25
|
var config = _ref.config,
|
|
26
26
|
api = _ref.api;
|
|
27
27
|
var syncBlockStore = new _editorSyncedBlockProvider.SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent);
|
|
28
|
-
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _blockMenuComponents.getBlockMenuComponents)(api));
|
|
29
|
-
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api));
|
|
28
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents((0, _blockMenuComponents.getBlockMenuComponents)(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
|
|
29
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
|
|
30
30
|
return {
|
|
31
31
|
name: 'syncedBlock',
|
|
32
32
|
nodes: function nodes() {
|
|
@@ -53,6 +53,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
53
53
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
54
54
|
return function (_ref2) {
|
|
55
55
|
var tr = _ref2.tr;
|
|
56
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
56
59
|
return (0, _editorCommands.createSyncedBlock)({
|
|
57
60
|
tr: tr,
|
|
58
61
|
syncBlockStore: syncBlockStore
|
|
@@ -71,6 +74,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
71
74
|
pluginsOptions: {
|
|
72
75
|
quickInsert: function quickInsert(_ref3) {
|
|
73
76
|
var formatMessage = _ref3.formatMessage;
|
|
77
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
78
|
+
return [];
|
|
79
|
+
}
|
|
74
80
|
return [{
|
|
75
81
|
id: 'syncBlock',
|
|
76
82
|
title: formatMessage(_messages.blockTypeMessages.syncedBlock),
|
|
@@ -86,7 +86,8 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
86
86
|
}, formatMessage(_messages.blockMenuMessages.copySyncedBlock));
|
|
87
87
|
};
|
|
88
88
|
var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref3) {
|
|
89
|
-
var api = _ref3.api
|
|
89
|
+
var api = _ref3.api,
|
|
90
|
+
enableSourceSyncedBlockCreation = _ref3.enableSourceSyncedBlockCreation;
|
|
90
91
|
var _useSharedPluginState3 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['blockControls'], function (states) {
|
|
91
92
|
var _states$blockControls3, _states$blockControls4;
|
|
92
93
|
return {
|
|
@@ -98,9 +99,11 @@ var CreateOrCopySyncedBlockDropdownItem = exports.CreateOrCopySyncedBlockDropdow
|
|
|
98
99
|
return /*#__PURE__*/_react.default.createElement(CopySyncedBlockDropdownItem, {
|
|
99
100
|
api: api
|
|
100
101
|
});
|
|
101
|
-
} else {
|
|
102
|
+
} else if (enableSourceSyncedBlockCreation) {
|
|
102
103
|
return /*#__PURE__*/_react.default.createElement(CreateSyncedBlockDropdownItem, {
|
|
103
104
|
api: api
|
|
104
105
|
});
|
|
106
|
+
} else {
|
|
107
|
+
return null;
|
|
105
108
|
}
|
|
106
109
|
};
|
|
@@ -8,7 +8,7 @@ exports.getBlockMenuComponents = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _blockMenu = require("@atlaskit/editor-common/block-menu");
|
|
10
10
|
var _CreateSyncedBlockDropdownItem = require("./CreateSyncedBlockDropdownItem");
|
|
11
|
-
var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(api) {
|
|
11
|
+
var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockMenuComponents(api, enableSourceSyncedBlockCreation) {
|
|
12
12
|
return [{
|
|
13
13
|
type: 'block-menu-item',
|
|
14
14
|
key: _blockMenu.BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM.key,
|
|
@@ -19,7 +19,8 @@ var getBlockMenuComponents = exports.getBlockMenuComponents = function getBlockM
|
|
|
19
19
|
},
|
|
20
20
|
component: function component() {
|
|
21
21
|
return /*#__PURE__*/_react.default.createElement(_CreateSyncedBlockDropdownItem.CreateOrCopySyncedBlockDropdownItem, {
|
|
22
|
-
api: api
|
|
22
|
+
api: api,
|
|
23
|
+
enableSourceSyncedBlockCreation: enableSourceSyncedBlockCreation
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
}];
|
|
@@ -25,7 +25,10 @@ var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
|
25
25
|
rank: _toolbar.INSERT_BLOCK_SECTION_RANK[_toolbar.SYNCED_BLOCK_GROUP.key]
|
|
26
26
|
}]
|
|
27
27
|
};
|
|
28
|
-
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api) {
|
|
28
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api, enableSourceSyncedBlockCreation) {
|
|
29
|
+
if (!enableSourceSyncedBlockCreation) {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
29
32
|
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
|
|
30
33
|
type: _toolbar.SYNCED_BLOCK_BUTTON.type,
|
|
31
34
|
key: _toolbar.SYNCED_BLOCK_BUTTON.key,
|
|
@@ -132,14 +132,12 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
132
132
|
} = state;
|
|
133
133
|
const isCopy = isCopyEvent;
|
|
134
134
|
isCopyEvent = false;
|
|
135
|
-
if (!syncBlockStore) {
|
|
135
|
+
if (!syncBlockStore || !isCopy) {
|
|
136
136
|
return slice;
|
|
137
137
|
}
|
|
138
138
|
return mapSlice(slice, node => {
|
|
139
139
|
if (node.type.name === 'syncBlock') {
|
|
140
|
-
|
|
141
|
-
showCopiedFlag(api);
|
|
142
|
-
}
|
|
140
|
+
showCopiedFlag(api);
|
|
143
141
|
return node;
|
|
144
142
|
}
|
|
145
143
|
if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
|
|
@@ -148,9 +146,7 @@ export const createPlugin = (options, pmPluginFactoryParams, syncBlockStore, api
|
|
|
148
146
|
if (!sliceFullyContainsNode(slice, node)) {
|
|
149
147
|
return node.content;
|
|
150
148
|
}
|
|
151
|
-
|
|
152
|
-
showCopiedFlag(api);
|
|
153
|
-
}
|
|
149
|
+
showCopiedFlag(api);
|
|
154
150
|
const newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
|
|
155
151
|
// Convert bodiedSyncBlock to syncBlock
|
|
156
152
|
// The paste transformation will regenrate the localId
|
|
@@ -17,10 +17,10 @@ export const syncedBlockPlugin = ({
|
|
|
17
17
|
config,
|
|
18
18
|
api
|
|
19
19
|
}) => {
|
|
20
|
-
var _api$analytics, _api$analytics$action, _api$blockMenu, _api$toolbar;
|
|
20
|
+
var _api$analytics, _api$analytics$action, _api$blockMenu, _config$enableSourceC, _api$toolbar, _config$enableSourceC2;
|
|
21
21
|
const syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : (_api$analytics$action = _api$analytics.actions) === null || _api$analytics$action === void 0 ? void 0 : _api$analytics$action.fireAnalyticsEvent);
|
|
22
|
-
api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api));
|
|
23
|
-
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents(api));
|
|
22
|
+
api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
|
|
23
|
+
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
|
|
24
24
|
return {
|
|
25
25
|
name: 'syncedBlock',
|
|
26
26
|
nodes() {
|
|
@@ -42,10 +42,15 @@ export const syncedBlockPlugin = ({
|
|
|
42
42
|
copySyncedBlockReferenceToClipboard: () => copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, api),
|
|
43
43
|
insertSyncedBlock: () => ({
|
|
44
44
|
tr
|
|
45
|
-
}) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
}) => {
|
|
46
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return createSyncedBlock({
|
|
50
|
+
tr,
|
|
51
|
+
syncBlockStore
|
|
52
|
+
}) || null;
|
|
53
|
+
}
|
|
49
54
|
},
|
|
50
55
|
actions: {
|
|
51
56
|
flushBodiedSyncBlocks: () => {
|
|
@@ -58,28 +63,33 @@ export const syncedBlockPlugin = ({
|
|
|
58
63
|
pluginsOptions: {
|
|
59
64
|
quickInsert: ({
|
|
60
65
|
formatMessage
|
|
61
|
-
}) =>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
description: formatMessage(blockTypeMessages.syncedBlockDescription),
|
|
65
|
-
priority: 800,
|
|
66
|
-
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect'],
|
|
67
|
-
isDisabledOffline: true,
|
|
68
|
-
keyshortcut: '',
|
|
69
|
-
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
70
|
-
appearance: "new"
|
|
71
|
-
}, formatMessage(blockTypeMessages.newLozenge)),
|
|
72
|
-
icon: () => /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
73
|
-
label: formatMessage(blockTypeMessages.syncedBlock)
|
|
74
|
-
}),
|
|
75
|
-
action: (insert, state) => {
|
|
76
|
-
return createSyncedBlock({
|
|
77
|
-
tr: state.tr,
|
|
78
|
-
syncBlockStore,
|
|
79
|
-
typeAheadInsert: insert
|
|
80
|
-
});
|
|
66
|
+
}) => {
|
|
67
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
68
|
+
return [];
|
|
81
69
|
}
|
|
82
|
-
|
|
70
|
+
return [{
|
|
71
|
+
id: 'syncBlock',
|
|
72
|
+
title: formatMessage(blockTypeMessages.syncedBlock),
|
|
73
|
+
description: formatMessage(blockTypeMessages.syncedBlockDescription),
|
|
74
|
+
priority: 800,
|
|
75
|
+
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect'],
|
|
76
|
+
isDisabledOffline: true,
|
|
77
|
+
keyshortcut: '',
|
|
78
|
+
lozenge: /*#__PURE__*/React.createElement(Lozenge, {
|
|
79
|
+
appearance: "new"
|
|
80
|
+
}, formatMessage(blockTypeMessages.newLozenge)),
|
|
81
|
+
icon: () => /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
82
|
+
label: formatMessage(blockTypeMessages.syncedBlock)
|
|
83
|
+
}),
|
|
84
|
+
action: (insert, state) => {
|
|
85
|
+
return createSyncedBlock({
|
|
86
|
+
tr: state.tr,
|
|
87
|
+
syncBlockStore,
|
|
88
|
+
typeAheadInsert: insert
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}];
|
|
92
|
+
},
|
|
83
93
|
floatingToolbar: (state, intl) => getToolbarConfig(state, intl, api, syncBlockStore)
|
|
84
94
|
},
|
|
85
95
|
contentComponent: () => {
|
|
@@ -81,7 +81,8 @@ const CopySyncedBlockDropdownItem = ({
|
|
|
81
81
|
}, formatMessage(blockMenuMessages.copySyncedBlock));
|
|
82
82
|
};
|
|
83
83
|
export const CreateOrCopySyncedBlockDropdownItem = ({
|
|
84
|
-
api
|
|
84
|
+
api,
|
|
85
|
+
enableSourceSyncedBlockCreation
|
|
85
86
|
}) => {
|
|
86
87
|
const {
|
|
87
88
|
menuTriggerByNode
|
|
@@ -95,9 +96,11 @@ export const CreateOrCopySyncedBlockDropdownItem = ({
|
|
|
95
96
|
return /*#__PURE__*/React.createElement(CopySyncedBlockDropdownItem, {
|
|
96
97
|
api: api
|
|
97
98
|
});
|
|
98
|
-
} else {
|
|
99
|
+
} else if (enableSourceSyncedBlockCreation) {
|
|
99
100
|
return /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
|
|
100
101
|
api: api
|
|
101
102
|
});
|
|
103
|
+
} else {
|
|
104
|
+
return null;
|
|
102
105
|
}
|
|
103
106
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { CreateOrCopySyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
|
|
4
|
-
export const getBlockMenuComponents = api => {
|
|
4
|
+
export const getBlockMenuComponents = (api, enableSourceSyncedBlockCreation) => {
|
|
5
5
|
return [{
|
|
6
6
|
type: 'block-menu-item',
|
|
7
7
|
key: BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM.key,
|
|
@@ -11,7 +11,8 @@ export const getBlockMenuComponents = api => {
|
|
|
11
11
|
rank: BLOCK_ACTIONS_MENU_SECTION_RANK[BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM.key]
|
|
12
12
|
},
|
|
13
13
|
component: () => /*#__PURE__*/React.createElement(CreateOrCopySyncedBlockDropdownItem, {
|
|
14
|
-
api: api
|
|
14
|
+
api: api,
|
|
15
|
+
enableSourceSyncedBlockCreation: enableSourceSyncedBlockCreation
|
|
15
16
|
})
|
|
16
17
|
}];
|
|
17
18
|
};
|
|
@@ -17,7 +17,10 @@ const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
|
17
17
|
rank: INSERT_BLOCK_SECTION_RANK[SYNCED_BLOCK_GROUP.key]
|
|
18
18
|
}]
|
|
19
19
|
};
|
|
20
|
-
export const getToolbarComponents = api => {
|
|
20
|
+
export const getToolbarComponents = (api, enableSourceSyncedBlockCreation) => {
|
|
21
|
+
if (!enableSourceSyncedBlockCreation) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
21
24
|
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
|
|
22
25
|
type: SYNCED_BLOCK_BUTTON.type,
|
|
23
26
|
key: SYNCED_BLOCK_BUTTON.key,
|
|
@@ -134,14 +134,12 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
134
134
|
var schema = state.schema;
|
|
135
135
|
var isCopy = isCopyEvent;
|
|
136
136
|
isCopyEvent = false;
|
|
137
|
-
if (!syncBlockStore) {
|
|
137
|
+
if (!syncBlockStore || !isCopy) {
|
|
138
138
|
return slice;
|
|
139
139
|
}
|
|
140
140
|
return mapSlice(slice, function (node) {
|
|
141
141
|
if (node.type.name === 'syncBlock') {
|
|
142
|
-
|
|
143
|
-
showCopiedFlag(api);
|
|
144
|
-
}
|
|
142
|
+
showCopiedFlag(api);
|
|
145
143
|
return node;
|
|
146
144
|
}
|
|
147
145
|
if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
|
|
@@ -150,9 +148,7 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
150
148
|
if (!sliceFullyContainsNode(slice, node)) {
|
|
151
149
|
return node.content;
|
|
152
150
|
}
|
|
153
|
-
|
|
154
|
-
showCopiedFlag(api);
|
|
155
|
-
}
|
|
151
|
+
showCopiedFlag(api);
|
|
156
152
|
var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
|
|
157
153
|
// Convert bodiedSyncBlock to syncBlock
|
|
158
154
|
// The paste transformation will regenrate the localId
|
|
@@ -14,12 +14,12 @@ import { getToolbarConfig } from './ui/floating-toolbar';
|
|
|
14
14
|
import { SyncBlockRefresher } from './ui/SyncBlockRefresher';
|
|
15
15
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
16
16
|
export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
17
|
-
var _api$analytics, _api$blockMenu, _api$toolbar;
|
|
17
|
+
var _api$analytics, _api$blockMenu, _config$enableSourceC, _api$toolbar, _config$enableSourceC2;
|
|
18
18
|
var config = _ref.config,
|
|
19
19
|
api = _ref.api;
|
|
20
20
|
var syncBlockStore = new SyncBlockStoreManager(config === null || config === void 0 ? void 0 : config.syncBlockDataProvider, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || (_api$analytics = _api$analytics.actions) === null || _api$analytics === void 0 ? void 0 : _api$analytics.fireAnalyticsEvent);
|
|
21
|
-
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api));
|
|
22
|
-
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(api));
|
|
21
|
+
api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents(getBlockMenuComponents(api, (_config$enableSourceC = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC !== void 0 ? _config$enableSourceC : false));
|
|
22
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(api, (_config$enableSourceC2 = config === null || config === void 0 ? void 0 : config.enableSourceCreation) !== null && _config$enableSourceC2 !== void 0 ? _config$enableSourceC2 : false));
|
|
23
23
|
return {
|
|
24
24
|
name: 'syncedBlock',
|
|
25
25
|
nodes: function nodes() {
|
|
@@ -46,6 +46,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
46
46
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
47
47
|
return function (_ref2) {
|
|
48
48
|
var tr = _ref2.tr;
|
|
49
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
49
52
|
return createSyncedBlock({
|
|
50
53
|
tr: tr,
|
|
51
54
|
syncBlockStore: syncBlockStore
|
|
@@ -64,6 +67,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
64
67
|
pluginsOptions: {
|
|
65
68
|
quickInsert: function quickInsert(_ref3) {
|
|
66
69
|
var formatMessage = _ref3.formatMessage;
|
|
70
|
+
if (!(config !== null && config !== void 0 && config.enableSourceCreation)) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
67
73
|
return [{
|
|
68
74
|
id: 'syncBlock',
|
|
69
75
|
title: formatMessage(blockTypeMessages.syncedBlock),
|
|
@@ -77,7 +77,8 @@ var CopySyncedBlockDropdownItem = function CopySyncedBlockDropdownItem(_ref2) {
|
|
|
77
77
|
}, formatMessage(blockMenuMessages.copySyncedBlock));
|
|
78
78
|
};
|
|
79
79
|
export var CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBlockDropdownItem(_ref3) {
|
|
80
|
-
var api = _ref3.api
|
|
80
|
+
var api = _ref3.api,
|
|
81
|
+
enableSourceSyncedBlockCreation = _ref3.enableSourceSyncedBlockCreation;
|
|
81
82
|
var _useSharedPluginState3 = useSharedPluginStateWithSelector(api, ['blockControls'], function (states) {
|
|
82
83
|
var _states$blockControls3, _states$blockControls4;
|
|
83
84
|
return {
|
|
@@ -89,9 +90,11 @@ export var CreateOrCopySyncedBlockDropdownItem = function CreateOrCopySyncedBloc
|
|
|
89
90
|
return /*#__PURE__*/React.createElement(CopySyncedBlockDropdownItem, {
|
|
90
91
|
api: api
|
|
91
92
|
});
|
|
92
|
-
} else {
|
|
93
|
+
} else if (enableSourceSyncedBlockCreation) {
|
|
93
94
|
return /*#__PURE__*/React.createElement(CreateSyncedBlockDropdownItem, {
|
|
94
95
|
api: api
|
|
95
96
|
});
|
|
97
|
+
} else {
|
|
98
|
+
return null;
|
|
96
99
|
}
|
|
97
100
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { BLOCK_ACTIONS_MENU_SECTION, BLOCK_ACTIONS_MENU_SECTION_RANK, BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/block-menu';
|
|
3
3
|
import { CreateOrCopySyncedBlockDropdownItem } from './CreateSyncedBlockDropdownItem';
|
|
4
|
-
export var getBlockMenuComponents = function getBlockMenuComponents(api) {
|
|
4
|
+
export var getBlockMenuComponents = function getBlockMenuComponents(api, enableSourceSyncedBlockCreation) {
|
|
5
5
|
return [{
|
|
6
6
|
type: 'block-menu-item',
|
|
7
7
|
key: BLOCK_ACTIONS_CREATE_SYNCED_BLOCK_MENU_ITEM.key,
|
|
@@ -12,7 +12,8 @@ export var getBlockMenuComponents = function getBlockMenuComponents(api) {
|
|
|
12
12
|
},
|
|
13
13
|
component: function component() {
|
|
14
14
|
return /*#__PURE__*/React.createElement(CreateOrCopySyncedBlockDropdownItem, {
|
|
15
|
-
api: api
|
|
15
|
+
api: api,
|
|
16
|
+
enableSourceSyncedBlockCreation: enableSourceSyncedBlockCreation
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
}];
|
|
@@ -18,7 +18,10 @@ var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
|
18
18
|
rank: INSERT_BLOCK_SECTION_RANK[SYNCED_BLOCK_GROUP.key]
|
|
19
19
|
}]
|
|
20
20
|
};
|
|
21
|
-
export var getToolbarComponents = function getToolbarComponents(api) {
|
|
21
|
+
export var getToolbarComponents = function getToolbarComponents(api, enableSourceSyncedBlockCreation) {
|
|
22
|
+
if (!enableSourceSyncedBlockCreation) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
22
25
|
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
|
|
23
26
|
type: SYNCED_BLOCK_BUTTON.type,
|
|
24
27
|
key: SYNCED_BLOCK_BUTTON.key,
|
|
@@ -40,6 +40,7 @@ export type SyncedBlockRendererProps = {
|
|
|
40
40
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
41
41
|
};
|
|
42
42
|
export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
|
|
43
|
+
enableSourceCreation?: boolean;
|
|
43
44
|
syncBlockDataProvider: SyncBlockDataProvider;
|
|
44
45
|
syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
45
46
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, }: {
|
|
4
|
+
export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, enableSourceSyncedBlockCreation, }: {
|
|
5
5
|
api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
|
|
6
|
-
|
|
6
|
+
enableSourceSyncedBlockCreation: boolean;
|
|
7
|
+
}) => React.JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { RegisterBlockMenuComponent } from '@atlaskit/editor-plugin-block-menu';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const getBlockMenuComponents: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => RegisterBlockMenuComponent[];
|
|
4
|
+
export declare const getBlockMenuComponents: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, enableSourceSyncedBlockCreation: boolean) => RegisterBlockMenuComponent[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SyncedBlockPlugin
|
|
4
|
+
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SyncedBlockPlugin>, enableSourceSyncedBlockCreation?: boolean) => RegisterComponent[];
|
|
@@ -40,6 +40,7 @@ export type SyncedBlockRendererProps = {
|
|
|
40
40
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
41
41
|
};
|
|
42
42
|
export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
|
|
43
|
+
enableSourceCreation?: boolean;
|
|
43
44
|
syncBlockDataProvider: SyncBlockDataProvider;
|
|
44
45
|
syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
45
46
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, }: {
|
|
4
|
+
export declare const CreateOrCopySyncedBlockDropdownItem: ({ api, enableSourceSyncedBlockCreation, }: {
|
|
5
5
|
api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
|
|
6
|
-
|
|
6
|
+
enableSourceSyncedBlockCreation: boolean;
|
|
7
|
+
}) => React.JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { RegisterBlockMenuComponent } from '@atlaskit/editor-plugin-block-menu';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const getBlockMenuComponents: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => RegisterBlockMenuComponent[];
|
|
4
|
+
export declare const getBlockMenuComponents: (api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, enableSourceSyncedBlockCreation: boolean) => RegisterBlockMenuComponent[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
3
|
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
4
|
-
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SyncedBlockPlugin
|
|
4
|
+
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<SyncedBlockPlugin>, enableSourceSyncedBlockCreation?: boolean) => RegisterComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.2",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@atlaskit/lozenge": "^13.3.0",
|
|
49
49
|
"@atlaskit/modal-dialog": "^14.9.0",
|
|
50
50
|
"@atlaskit/primitives": "^17.0.0",
|
|
51
|
-
"@atlaskit/tmp-editor-statsig": "^16.
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^16.3.0",
|
|
52
52
|
"@atlaskit/tokens": "9.0.0",
|
|
53
53
|
"@atlaskit/tooltip": "^20.11.0",
|
|
54
54
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@atlaskit/editor-common": "^110.
|
|
59
|
+
"@atlaskit/editor-common": "^110.50.0",
|
|
60
60
|
"react": "^18.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|