@atlaskit/editor-plugin-synced-block 12.1.0 → 13.0.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 +14 -0
- package/afm-cc/tsconfig.json +6 -0
- package/dist/cjs/syncedBlockPlugin.js +17 -3
- package/dist/cjs/ui/quick-insert/SyncedBlockQuickInsertMenuItem.js +50 -0
- package/dist/cjs/ui/quick-insert/getSyncedBlockQuickInsertComponents.js +41 -0
- package/dist/es2019/syncedBlockPlugin.js +13 -1
- package/dist/es2019/ui/quick-insert/SyncedBlockQuickInsertMenuItem.js +46 -0
- package/dist/es2019/ui/quick-insert/getSyncedBlockQuickInsertComponents.js +30 -0
- package/dist/esm/syncedBlockPlugin.js +17 -3
- package/dist/esm/ui/quick-insert/SyncedBlockQuickInsertMenuItem.js +42 -0
- package/dist/esm/ui/quick-insert/getSyncedBlockQuickInsertComponents.js +34 -0
- package/dist/types/syncedBlockPluginType.d.ts +5 -1
- package/dist/types/ui/quick-insert/SyncedBlockQuickInsertMenuItem.d.ts +8 -0
- package/dist/types/ui/quick-insert/getSyncedBlockQuickInsertComponents.d.ts +8 -0
- package/package.json +14 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 13.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4273da2e1a648`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4273da2e1a648) -
|
|
8
|
+
Register native Quick Insert items behind `platform_editor_slash_command`.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 13.0.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 12.1.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -49,6 +49,9 @@
|
|
|
49
49
|
{
|
|
50
50
|
"path": "../../editor-plugin-decorations/afm-cc/tsconfig.json"
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
"path": "../../editor-plugin-editor-disabled/afm-cc/tsconfig.json"
|
|
54
|
+
},
|
|
52
55
|
{
|
|
53
56
|
"path": "../../editor-plugin-floating-toolbar/afm-cc/tsconfig.json"
|
|
54
57
|
},
|
|
@@ -91,6 +94,9 @@
|
|
|
91
94
|
{
|
|
92
95
|
"path": "../../../design-system/modal-dialog/afm-cc/tsconfig.json"
|
|
93
96
|
},
|
|
97
|
+
{
|
|
98
|
+
"path": "../../../platform/feature-experiments/afm-cc/tsconfig.json"
|
|
99
|
+
},
|
|
94
100
|
{
|
|
95
101
|
"path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
|
|
96
102
|
},
|
|
@@ -5,10 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.syncedBlockPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
12
|
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
13
|
+
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
12
14
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
15
|
var _editorActions = require("./editor-actions");
|
|
14
16
|
var _editorCommands = require("./editor-commands");
|
|
@@ -19,9 +21,12 @@ var _DeleteConfirmationModal = require("./ui/DeleteConfirmationModal");
|
|
|
19
21
|
var _Flag = require("./ui/Flag");
|
|
20
22
|
var _floatingToolbar = require("./ui/floating-toolbar");
|
|
21
23
|
var _quickInsert = require("./ui/quick-insert");
|
|
24
|
+
var _getSyncedBlockQuickInsertComponents = require("./ui/quick-insert/getSyncedBlockQuickInsertComponents");
|
|
22
25
|
var _SourceSyncBlockPlaceholder = require("./ui/SourceSyncBlockPlaceholder");
|
|
23
26
|
var _SyncBlockRefresher = require("./ui/SyncBlockRefresher");
|
|
24
27
|
var _toolbarComponents = require("./ui/toolbar-components");
|
|
28
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
29
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
25
30
|
/**
|
|
26
31
|
* EDITOR-6929 / PR-G: Guard contentComponent rendering.
|
|
27
32
|
* When `hasSyncedBlocks` is false return null
|
|
@@ -73,6 +78,14 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
73
78
|
var cachedSharedState;
|
|
74
79
|
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));
|
|
75
80
|
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));
|
|
81
|
+
var isRegisteredSlashCommandEnabled = (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_slash_command');
|
|
82
|
+
if (isRegisteredSlashCommandEnabled && (0, _isExperimentEnabled.isExperimentEnabled)('platform_synced_block') && config !== null && config !== void 0 && config.enableSourceCreation) {
|
|
83
|
+
var _api$uiControlRegistr;
|
|
84
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register((0, _getSyncedBlockQuickInsertComponents.getSyncedBlockQuickInsertComponents)({
|
|
85
|
+
api: api,
|
|
86
|
+
syncBlockStore: syncBlockStore
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
76
89
|
return {
|
|
77
90
|
name: 'syncedBlock',
|
|
78
91
|
nodes: function nodes() {
|
|
@@ -134,8 +147,9 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
134
147
|
return (0, _editorActions.discardUnpublishedSyncBlocks)(syncBlockStore);
|
|
135
148
|
}
|
|
136
149
|
},
|
|
137
|
-
pluginsOptions: {
|
|
138
|
-
quickInsert: (0, _quickInsert.getQuickInsertConfig)(config, api, syncBlockStore)
|
|
150
|
+
pluginsOptions: _objectSpread(_objectSpread({}, !isRegisteredSlashCommandEnabled && {
|
|
151
|
+
quickInsert: (0, _quickInsert.getQuickInsertConfig)(config, api, syncBlockStore)
|
|
152
|
+
}), {}, {
|
|
139
153
|
floatingToolbar: function floatingToolbar(state, intl) {
|
|
140
154
|
var _syncedBlockPluginKey;
|
|
141
155
|
// When the experiment is ON and the document has no synced blocks,
|
|
@@ -146,7 +160,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
146
160
|
}
|
|
147
161
|
return (0, _floatingToolbar.getToolbarConfig)(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
|
|
148
162
|
}
|
|
149
|
-
},
|
|
163
|
+
}),
|
|
150
164
|
contentComponent: function contentComponent(_ref4) {
|
|
151
165
|
var containerElement = _ref4.containerElement,
|
|
152
166
|
wrapperElement = _ref4.wrapperElement,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.SyncedBlockQuickInsertMenuItem = void 0;
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _reactIntl = require("react-intl");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _assets = require("@atlaskit/editor-common/assets");
|
|
14
|
+
var _menuItem = require("@atlaskit/editor-common/quick-insert/menu-item");
|
|
15
|
+
var _editorCommands = require("../../editor-commands");
|
|
16
|
+
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); }
|
|
17
|
+
var SyncedBlockQuickInsertMenuItem = exports.SyncedBlockQuickInsertMenuItem = function SyncedBlockQuickInsertMenuItem(_ref) {
|
|
18
|
+
var api = _ref.api,
|
|
19
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
20
|
+
var _useIntl = (0, _reactIntl.useIntl)(),
|
|
21
|
+
formatMessage = _useIntl.formatMessage;
|
|
22
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['editorDisabled'], function (states) {
|
|
23
|
+
var _states$editorDisable;
|
|
24
|
+
return {
|
|
25
|
+
editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
editorDisabled = _useSharedPluginState.editorDisabled;
|
|
29
|
+
var onSelect = (0, _react.useCallback)(function (_ref2) {
|
|
30
|
+
var _api$analytics;
|
|
31
|
+
var editorView = _ref2.editorView,
|
|
32
|
+
insert = _ref2.insert,
|
|
33
|
+
source = _ref2.source;
|
|
34
|
+
return (0, _editorCommands.createSyncedBlock)({
|
|
35
|
+
tr: editorView.state.tr,
|
|
36
|
+
syncBlockStore: syncBlockStore,
|
|
37
|
+
typeAheadInsert: insert,
|
|
38
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent,
|
|
39
|
+
inputMethod: source !== null && source !== void 0 ? source : _analytics.INPUT_METHOD.QUICK_INSERT
|
|
40
|
+
});
|
|
41
|
+
}, [api, syncBlockStore]);
|
|
42
|
+
return /*#__PURE__*/_react.default.createElement(_menuItem.QuickInsertMenuItem, {
|
|
43
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_assets.IconSyncBlock, {
|
|
44
|
+
label: ""
|
|
45
|
+
}),
|
|
46
|
+
isDisabled: editorDisabled,
|
|
47
|
+
onSelect: onSelect,
|
|
48
|
+
title: formatMessage(_messages.blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getSyncedBlockQuickInsertComponents = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
10
|
+
var _createQuickInsertMatcher = require("@atlaskit/editor-common/quick-insert/create-quick-insert-matcher");
|
|
11
|
+
var _keys = require("@atlaskit/editor-common/quick-insert/keys");
|
|
12
|
+
var _rank = require("@atlaskit/editor-common/quick-insert/rank");
|
|
13
|
+
var _SyncedBlockQuickInsertMenuItem = require("./SyncedBlockQuickInsertMenuItem");
|
|
14
|
+
var getSyncedBlockQuickInsertComponents = exports.getSyncedBlockQuickInsertComponents = function getSyncedBlockQuickInsertComponents(_ref) {
|
|
15
|
+
var api = _ref.api,
|
|
16
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
17
|
+
return [{
|
|
18
|
+
key: _keys.SYNCED_BLOCK_MENU_ITEM.key,
|
|
19
|
+
type: _keys.SYNCED_BLOCK_MENU_ITEM.type,
|
|
20
|
+
parents: [{
|
|
21
|
+
key: _keys.STRUCTURE_SECTION.key,
|
|
22
|
+
type: _keys.STRUCTURE_SECTION.type,
|
|
23
|
+
rank: _rank.STRUCTURE_SECTION_RANK[_keys.SYNCED_BLOCK_MENU_ITEM.key]
|
|
24
|
+
}],
|
|
25
|
+
match: (0, _createQuickInsertMatcher.createQuickInsertMatcher)(function (_ref2) {
|
|
26
|
+
var formatMessage = _ref2.formatMessage;
|
|
27
|
+
return {
|
|
28
|
+
description: formatMessage(_messages.blockTypeMessages.syncedBlockDescription),
|
|
29
|
+
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect', 'create'],
|
|
30
|
+
shortcut: '',
|
|
31
|
+
title: formatMessage(_messages.blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
32
|
+
};
|
|
33
|
+
}),
|
|
34
|
+
component: function component() {
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_SyncedBlockQuickInsertMenuItem.SyncedBlockQuickInsertMenuItem, {
|
|
36
|
+
api: api,
|
|
37
|
+
syncBlockStore: syncBlockStore
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}];
|
|
41
|
+
};
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
3
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
4
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
5
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
7
|
import { flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks } from './editor-actions';
|
|
7
8
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -12,6 +13,7 @@ import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
|
|
|
12
13
|
import { Flag } from './ui/Flag';
|
|
13
14
|
import { getToolbarConfig } from './ui/floating-toolbar';
|
|
14
15
|
import { getQuickInsertConfig } from './ui/quick-insert';
|
|
16
|
+
import { getSyncedBlockQuickInsertComponents } from './ui/quick-insert/getSyncedBlockQuickInsertComponents';
|
|
15
17
|
import { SourceSyncBlockPlaceholder } from './ui/SourceSyncBlockPlaceholder';
|
|
16
18
|
import { SyncBlockRefresher } from './ui/SyncBlockRefresher';
|
|
17
19
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
@@ -69,6 +71,14 @@ export const syncedBlockPlugin = ({
|
|
|
69
71
|
let cachedSharedState;
|
|
70
72
|
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));
|
|
71
73
|
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));
|
|
74
|
+
const isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
75
|
+
if (isRegisteredSlashCommandEnabled && isExperimentEnabled('platform_synced_block') && config !== null && config !== void 0 && config.enableSourceCreation) {
|
|
76
|
+
var _api$uiControlRegistr;
|
|
77
|
+
api === null || api === void 0 ? void 0 : (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 ? void 0 : _api$uiControlRegistr.actions.register(getSyncedBlockQuickInsertComponents({
|
|
78
|
+
api,
|
|
79
|
+
syncBlockStore
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
72
82
|
return {
|
|
73
83
|
name: 'syncedBlock',
|
|
74
84
|
nodes() {
|
|
@@ -124,7 +134,9 @@ export const syncedBlockPlugin = ({
|
|
|
124
134
|
}
|
|
125
135
|
},
|
|
126
136
|
pluginsOptions: {
|
|
127
|
-
|
|
137
|
+
...(!isRegisteredSlashCommandEnabled && {
|
|
138
|
+
quickInsert: getQuickInsertConfig(config, api, syncBlockStore)
|
|
139
|
+
}),
|
|
128
140
|
floatingToolbar: (state, intl) => {
|
|
129
141
|
var _syncedBlockPluginKey;
|
|
130
142
|
// When the experiment is ON and the document has no synced blocks,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { IconSyncBlock } from '@atlaskit/editor-common/assets';
|
|
7
|
+
import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
|
|
8
|
+
import { createSyncedBlock } from '../../editor-commands';
|
|
9
|
+
export const SyncedBlockQuickInsertMenuItem = ({
|
|
10
|
+
api,
|
|
11
|
+
syncBlockStore
|
|
12
|
+
}) => {
|
|
13
|
+
const {
|
|
14
|
+
formatMessage
|
|
15
|
+
} = useIntl();
|
|
16
|
+
const {
|
|
17
|
+
editorDisabled
|
|
18
|
+
} = useSharedPluginStateWithSelector(api, ['editorDisabled'], states => {
|
|
19
|
+
var _states$editorDisable;
|
|
20
|
+
return {
|
|
21
|
+
editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
const onSelect = useCallback(({
|
|
25
|
+
editorView,
|
|
26
|
+
insert,
|
|
27
|
+
source
|
|
28
|
+
}) => {
|
|
29
|
+
var _api$analytics;
|
|
30
|
+
return createSyncedBlock({
|
|
31
|
+
tr: editorView.state.tr,
|
|
32
|
+
syncBlockStore,
|
|
33
|
+
typeAheadInsert: insert,
|
|
34
|
+
fireAnalyticsEvent: api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent,
|
|
35
|
+
inputMethod: source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT
|
|
36
|
+
});
|
|
37
|
+
}, [api, syncBlockStore]);
|
|
38
|
+
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
39
|
+
iconBefore: /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
40
|
+
label: ""
|
|
41
|
+
}),
|
|
42
|
+
isDisabled: editorDisabled,
|
|
43
|
+
onSelect: onSelect,
|
|
44
|
+
title: formatMessage(blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
|
|
4
|
+
import { STRUCTURE_SECTION, SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
|
|
5
|
+
import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
|
|
6
|
+
import { SyncedBlockQuickInsertMenuItem } from './SyncedBlockQuickInsertMenuItem';
|
|
7
|
+
export const getSyncedBlockQuickInsertComponents = ({
|
|
8
|
+
api,
|
|
9
|
+
syncBlockStore
|
|
10
|
+
}) => [{
|
|
11
|
+
key: SYNCED_BLOCK_MENU_ITEM.key,
|
|
12
|
+
type: SYNCED_BLOCK_MENU_ITEM.type,
|
|
13
|
+
parents: [{
|
|
14
|
+
key: STRUCTURE_SECTION.key,
|
|
15
|
+
type: STRUCTURE_SECTION.type,
|
|
16
|
+
rank: STRUCTURE_SECTION_RANK[SYNCED_BLOCK_MENU_ITEM.key]
|
|
17
|
+
}],
|
|
18
|
+
match: createQuickInsertMatcher(({
|
|
19
|
+
formatMessage
|
|
20
|
+
}) => ({
|
|
21
|
+
description: formatMessage(blockTypeMessages.syncedBlockDescription),
|
|
22
|
+
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect', 'create'],
|
|
23
|
+
shortcut: '',
|
|
24
|
+
title: formatMessage(blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
25
|
+
})),
|
|
26
|
+
component: () => /*#__PURE__*/React.createElement(SyncedBlockQuickInsertMenuItem, {
|
|
27
|
+
api: api,
|
|
28
|
+
syncBlockStore: syncBlockStore
|
|
29
|
+
})
|
|
30
|
+
}];
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { syncBlock, bodiedSyncBlock } from '@atlaskit/adf-schema';
|
|
3
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
7
|
import { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
8
|
+
import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
|
|
5
9
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
6
10
|
import { flushBodiedSyncBlocks as _flushBodiedSyncBlocks, flushSyncBlocks, discardUnpublishedSyncBlocks as _discardUnpublishedSyncBlocks } from './editor-actions';
|
|
7
11
|
import { copySyncedBlockReferenceToClipboardEditorCommand, createSyncedBlock } from './editor-commands';
|
|
@@ -12,6 +16,7 @@ import { DeleteConfirmationModal } from './ui/DeleteConfirmationModal';
|
|
|
12
16
|
import { Flag } from './ui/Flag';
|
|
13
17
|
import { getToolbarConfig } from './ui/floating-toolbar';
|
|
14
18
|
import { getQuickInsertConfig } from './ui/quick-insert';
|
|
19
|
+
import { getSyncedBlockQuickInsertComponents } from './ui/quick-insert/getSyncedBlockQuickInsertComponents';
|
|
15
20
|
import { SourceSyncBlockPlaceholder } from './ui/SourceSyncBlockPlaceholder';
|
|
16
21
|
import { SyncBlockRefresher } from './ui/SyncBlockRefresher';
|
|
17
22
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
@@ -67,6 +72,14 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
|
|
|
67
72
|
var cachedSharedState;
|
|
68
73
|
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));
|
|
69
74
|
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));
|
|
75
|
+
var isRegisteredSlashCommandEnabled = isExperimentEnabled('platform_editor_slash_command');
|
|
76
|
+
if (isRegisteredSlashCommandEnabled && isExperimentEnabled('platform_synced_block') && config !== null && config !== void 0 && config.enableSourceCreation) {
|
|
77
|
+
var _api$uiControlRegistr;
|
|
78
|
+
api === null || api === void 0 || (_api$uiControlRegistr = api.uiControlRegistry) === null || _api$uiControlRegistr === void 0 || _api$uiControlRegistr.actions.register(getSyncedBlockQuickInsertComponents({
|
|
79
|
+
api: api,
|
|
80
|
+
syncBlockStore: syncBlockStore
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
70
83
|
return {
|
|
71
84
|
name: 'syncedBlock',
|
|
72
85
|
nodes: function nodes() {
|
|
@@ -128,8 +141,9 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
|
|
|
128
141
|
return _discardUnpublishedSyncBlocks(syncBlockStore);
|
|
129
142
|
}
|
|
130
143
|
},
|
|
131
|
-
pluginsOptions: {
|
|
132
|
-
quickInsert: getQuickInsertConfig(config, api, syncBlockStore)
|
|
144
|
+
pluginsOptions: _objectSpread(_objectSpread({}, !isRegisteredSlashCommandEnabled && {
|
|
145
|
+
quickInsert: getQuickInsertConfig(config, api, syncBlockStore)
|
|
146
|
+
}), {}, {
|
|
133
147
|
floatingToolbar: function floatingToolbar(state, intl) {
|
|
134
148
|
var _syncedBlockPluginKey;
|
|
135
149
|
// When the experiment is ON and the document has no synced blocks,
|
|
@@ -140,7 +154,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
|
|
|
140
154
|
}
|
|
141
155
|
return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
|
|
142
156
|
}
|
|
143
|
-
},
|
|
157
|
+
}),
|
|
144
158
|
contentComponent: function contentComponent(_ref4) {
|
|
145
159
|
var containerElement = _ref4.containerElement,
|
|
146
160
|
wrapperElement = _ref4.wrapperElement,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import { IconSyncBlock } from '@atlaskit/editor-common/assets';
|
|
7
|
+
import { QuickInsertMenuItem } from '@atlaskit/editor-common/quick-insert/menu-item';
|
|
8
|
+
import { createSyncedBlock } from '../../editor-commands';
|
|
9
|
+
export var SyncedBlockQuickInsertMenuItem = function SyncedBlockQuickInsertMenuItem(_ref) {
|
|
10
|
+
var api = _ref.api,
|
|
11
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
12
|
+
var _useIntl = useIntl(),
|
|
13
|
+
formatMessage = _useIntl.formatMessage;
|
|
14
|
+
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['editorDisabled'], function (states) {
|
|
15
|
+
var _states$editorDisable;
|
|
16
|
+
return {
|
|
17
|
+
editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
|
|
18
|
+
};
|
|
19
|
+
}),
|
|
20
|
+
editorDisabled = _useSharedPluginState.editorDisabled;
|
|
21
|
+
var onSelect = useCallback(function (_ref2) {
|
|
22
|
+
var _api$analytics;
|
|
23
|
+
var editorView = _ref2.editorView,
|
|
24
|
+
insert = _ref2.insert,
|
|
25
|
+
source = _ref2.source;
|
|
26
|
+
return createSyncedBlock({
|
|
27
|
+
tr: editorView.state.tr,
|
|
28
|
+
syncBlockStore: syncBlockStore,
|
|
29
|
+
typeAheadInsert: insert,
|
|
30
|
+
fireAnalyticsEvent: api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent,
|
|
31
|
+
inputMethod: source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT
|
|
32
|
+
});
|
|
33
|
+
}, [api, syncBlockStore]);
|
|
34
|
+
return /*#__PURE__*/React.createElement(QuickInsertMenuItem, {
|
|
35
|
+
iconBefore: /*#__PURE__*/React.createElement(IconSyncBlock, {
|
|
36
|
+
label: ""
|
|
37
|
+
}),
|
|
38
|
+
isDisabled: editorDisabled,
|
|
39
|
+
onSelect: onSelect,
|
|
40
|
+
title: formatMessage(blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
41
|
+
});
|
|
42
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { blockTypeMessages } from '@atlaskit/editor-common/messages';
|
|
3
|
+
import { createQuickInsertMatcher } from '@atlaskit/editor-common/quick-insert/create-quick-insert-matcher';
|
|
4
|
+
import { STRUCTURE_SECTION, SYNCED_BLOCK_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
|
|
5
|
+
import { STRUCTURE_SECTION_RANK } from '@atlaskit/editor-common/quick-insert/rank';
|
|
6
|
+
import { SyncedBlockQuickInsertMenuItem } from './SyncedBlockQuickInsertMenuItem';
|
|
7
|
+
export var getSyncedBlockQuickInsertComponents = function getSyncedBlockQuickInsertComponents(_ref) {
|
|
8
|
+
var api = _ref.api,
|
|
9
|
+
syncBlockStore = _ref.syncBlockStore;
|
|
10
|
+
return [{
|
|
11
|
+
key: SYNCED_BLOCK_MENU_ITEM.key,
|
|
12
|
+
type: SYNCED_BLOCK_MENU_ITEM.type,
|
|
13
|
+
parents: [{
|
|
14
|
+
key: STRUCTURE_SECTION.key,
|
|
15
|
+
type: STRUCTURE_SECTION.type,
|
|
16
|
+
rank: STRUCTURE_SECTION_RANK[SYNCED_BLOCK_MENU_ITEM.key]
|
|
17
|
+
}],
|
|
18
|
+
match: createQuickInsertMatcher(function (_ref2) {
|
|
19
|
+
var formatMessage = _ref2.formatMessage;
|
|
20
|
+
return {
|
|
21
|
+
description: formatMessage(blockTypeMessages.syncedBlockDescription),
|
|
22
|
+
keywords: ['synced', 'block', 'synced-block', 'sync', 'sync-block', 'auto', 'update', 'excerpt', 'connect', 'create'],
|
|
23
|
+
shortcut: '',
|
|
24
|
+
title: formatMessage(blockTypeMessages.syncedBlockQuickInsertTitle)
|
|
25
|
+
};
|
|
26
|
+
}),
|
|
27
|
+
component: function component() {
|
|
28
|
+
return /*#__PURE__*/React.createElement(SyncedBlockQuickInsertMenuItem, {
|
|
29
|
+
api: api,
|
|
30
|
+
syncBlockStore: syncBlockStore
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}];
|
|
34
|
+
};
|
|
@@ -8,12 +8,14 @@ import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
|
|
|
8
8
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
9
9
|
import type { ContentFormatPlugin } from '@atlaskit/editor-plugin-content-format';
|
|
10
10
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
11
|
+
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
11
12
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
12
13
|
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
13
14
|
import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
|
|
14
15
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
15
16
|
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
16
17
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
18
|
+
import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
|
|
17
19
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
18
20
|
import type { SyncBlockDataProviderInterface, UseFetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
|
|
19
21
|
import type { SyncedBlockSharedState } from './types';
|
|
@@ -121,10 +123,12 @@ export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
|
121
123
|
OptionalPlugin<BlockMenuPlugin>,
|
|
122
124
|
OptionalPlugin<AnalyticsPlugin>,
|
|
123
125
|
OptionalPlugin<ConnectivityPlugin>,
|
|
126
|
+
OptionalPlugin<EditorDisabledPlugin>,
|
|
124
127
|
OptionalPlugin<EditorViewModePlugin>,
|
|
125
128
|
OptionalPlugin<ContentFormatPlugin>,
|
|
126
129
|
OptionalPlugin<UserIntentPlugin>,
|
|
127
|
-
OptionalPlugin<FocusPlugin
|
|
130
|
+
OptionalPlugin<FocusPlugin>,
|
|
131
|
+
OptionalPlugin<UiControlRegistryPlugin>
|
|
128
132
|
];
|
|
129
133
|
pluginConfiguration: SyncedBlockPluginOptions | undefined;
|
|
130
134
|
sharedState: SyncedBlockSharedState | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
5
|
+
export declare const SyncedBlockQuickInsertMenuItem: ({ api, syncBlockStore, }: {
|
|
6
|
+
api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
|
|
7
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
8
|
+
}) => React.JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
+
import type { RegisterMenuItem } from '@atlaskit/editor-ui-control-model/types';
|
|
4
|
+
import type { SyncedBlockPlugin } from '../../syncedBlockPluginType';
|
|
5
|
+
export declare const getSyncedBlockQuickInsertComponents: ({ api, syncBlockStore, }: {
|
|
6
|
+
api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined;
|
|
7
|
+
syncBlockStore: SyncBlockStoreManager;
|
|
8
|
+
}) => RegisterMenuItem[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.1",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,18 +24,19 @@
|
|
|
24
24
|
"@atlaskit/button": "25.0.4",
|
|
25
25
|
"@atlaskit/dropdown-menu": "18.0.3",
|
|
26
26
|
"@atlaskit/editor-json-transformer": "^9.2.0",
|
|
27
|
-
"@atlaskit/editor-plugin-analytics": "^
|
|
28
|
-
"@atlaskit/editor-plugin-block-menu": "^
|
|
29
|
-
"@atlaskit/editor-plugin-connectivity": "
|
|
30
|
-
"@atlaskit/editor-plugin-content-format": "^
|
|
31
|
-
"@atlaskit/editor-plugin-decorations": "^
|
|
32
|
-
"@atlaskit/editor-plugin-
|
|
33
|
-
"@atlaskit/editor-plugin-
|
|
34
|
-
"@atlaskit/editor-plugin-
|
|
35
|
-
"@atlaskit/editor-plugin-
|
|
27
|
+
"@atlaskit/editor-plugin-analytics": "^15.0.0",
|
|
28
|
+
"@atlaskit/editor-plugin-block-menu": "^14.0.0",
|
|
29
|
+
"@atlaskit/editor-plugin-connectivity": "15.0.0",
|
|
30
|
+
"@atlaskit/editor-plugin-content-format": "^9.0.0",
|
|
31
|
+
"@atlaskit/editor-plugin-decorations": "^15.0.0",
|
|
32
|
+
"@atlaskit/editor-plugin-editor-disabled": "^15.0.0",
|
|
33
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^17.0.0",
|
|
34
|
+
"@atlaskit/editor-plugin-focus": "^14.0.0",
|
|
35
|
+
"@atlaskit/editor-plugin-selection": "^15.0.0",
|
|
36
|
+
"@atlaskit/editor-plugin-user-intent": "^13.0.0",
|
|
36
37
|
"@atlaskit/editor-prosemirror": "^8.0.0",
|
|
37
38
|
"@atlaskit/editor-shared-styles": "^4.0.0",
|
|
38
|
-
"@atlaskit/editor-synced-block-provider": "^
|
|
39
|
+
"@atlaskit/editor-synced-block-provider": "^11.0.0",
|
|
39
40
|
"@atlaskit/editor-toolbar": "^2.4.0",
|
|
40
41
|
"@atlaskit/flag": "^18.2.0",
|
|
41
42
|
"@atlaskit/icon": "37.3.0",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"@atlaskit/logo": "^21.4.0",
|
|
44
45
|
"@atlaskit/lozenge": "^15.0.0",
|
|
45
46
|
"@atlaskit/modal-dialog": "^16.3.0",
|
|
47
|
+
"@atlaskit/platform-feature-experiments": "^0.3.0",
|
|
46
48
|
"@atlaskit/platform-feature-flags": "^2.1.0",
|
|
47
49
|
"@atlaskit/primitives": "^22.2.0",
|
|
48
50
|
"@atlaskit/spinner": "20.1.2",
|
|
@@ -58,7 +60,7 @@
|
|
|
58
60
|
"memoize-one": "^6.0.0"
|
|
59
61
|
},
|
|
60
62
|
"peerDependencies": {
|
|
61
|
-
"@atlaskit/editor-common": "^
|
|
63
|
+
"@atlaskit/editor-common": "^119.1.0",
|
|
62
64
|
"react": "^18.2.0 || ^19.2.0",
|
|
63
65
|
"react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
|
|
64
66
|
},
|