@atlaskit/editor-plugin-synced-block 4.4.1 → 4.5.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 +24 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/editor-commands/index.js +19 -5
- package/dist/cjs/nodeviews/syncedBlock.js +2 -1
- package/dist/cjs/pm-plugins/main.js +42 -2
- package/dist/cjs/syncedBlockPlugin.js +1 -1
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/ui/Flag.js +49 -14
- package/dist/cjs/ui/SyncBlockRendererWrapper.js +4 -2
- package/dist/cjs/ui/floating-toolbar.js +1 -1
- package/dist/cjs/ui/toolbar-components.js +9 -29
- package/dist/es2019/editor-commands/index.js +20 -5
- package/dist/es2019/nodeviews/syncedBlock.js +2 -1
- package/dist/es2019/pm-plugins/main.js +42 -1
- package/dist/es2019/syncedBlockPlugin.js +1 -1
- package/dist/es2019/types/index.js +1 -0
- package/dist/es2019/ui/Flag.js +50 -14
- package/dist/es2019/ui/SyncBlockRendererWrapper.js +4 -2
- package/dist/es2019/ui/floating-toolbar.js +1 -1
- package/dist/es2019/ui/toolbar-components.js +9 -31
- package/dist/esm/editor-commands/index.js +19 -5
- package/dist/esm/nodeviews/syncedBlock.js +2 -1
- package/dist/esm/pm-plugins/main.js +42 -3
- package/dist/esm/syncedBlockPlugin.js +1 -1
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/ui/Flag.js +50 -15
- package/dist/esm/ui/SyncBlockRendererWrapper.js +4 -2
- package/dist/esm/ui/floating-toolbar.js +1 -1
- package/dist/esm/ui/toolbar-components.js +10 -30
- package/dist/types/editor-commands/index.d.ts +2 -2
- package/dist/types/syncedBlockPluginType.d.ts +2 -1
- package/dist/types/types/index.d.ts +2 -1
- package/dist/types/ui/SyncBlockRendererWrapper.d.ts +5 -3
- package/dist/types-ts4.5/editor-commands/index.d.ts +2 -2
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +2 -1
- package/dist/types-ts4.5/types/index.d.ts +2 -1
- package/dist/types-ts4.5/ui/SyncBlockRendererWrapper.d.ts +5 -3
- package/package.json +3 -2
- package/dist/cjs/ui/CreateSyncedBlockItem.js +0 -53
- package/dist/cjs/ui/OverflowMenuSection.js +0 -20
- package/dist/es2019/ui/CreateSyncedBlockItem.js +0 -46
- package/dist/es2019/ui/OverflowMenuSection.js +0 -15
- package/dist/esm/ui/CreateSyncedBlockItem.js +0 -44
- package/dist/esm/ui/OverflowMenuSection.js +0 -13
- package/dist/types/ui/CreateSyncedBlockItem.d.ts +0 -8
- package/dist/types/ui/OverflowMenuSection.d.ts +0 -6
- package/dist/types-ts4.5/ui/CreateSyncedBlockItem.d.ts +0 -8
- package/dist/types-ts4.5/ui/OverflowMenuSection.d.ts +0 -6
|
@@ -6,7 +6,8 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
6
6
|
syncedBlockRenderer,
|
|
7
7
|
useFetchSyncBlockData,
|
|
8
8
|
localId,
|
|
9
|
-
useFetchSyncBlockTitle
|
|
9
|
+
useFetchSyncBlockTitle,
|
|
10
|
+
api
|
|
10
11
|
}) => {
|
|
11
12
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
12
13
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
@@ -14,7 +15,8 @@ const SyncBlockRendererWrapperComponent = ({
|
|
|
14
15
|
,
|
|
15
16
|
className: SyncBlockSharedCssClassName.renderer
|
|
16
17
|
}, syncedBlockRenderer({
|
|
17
|
-
useFetchSyncBlockData
|
|
18
|
+
useFetchSyncBlockData,
|
|
19
|
+
api
|
|
18
20
|
})), /*#__PURE__*/React.createElement(SyncBlockLabel, {
|
|
19
21
|
isSource: false,
|
|
20
22
|
useFetchSyncBlockTitle: useFetchSyncBlockTitle,
|
|
@@ -41,7 +41,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
|
|
|
41
41
|
title: formatMessage(messages.copySyncBlockLabel),
|
|
42
42
|
showTitle: false,
|
|
43
43
|
tooltipContent: formatMessage(messages.copySyncBlockTooltip),
|
|
44
|
-
onClick: copySyncedBlockReferenceToClipboard(syncBlockStore),
|
|
44
|
+
onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, api),
|
|
45
45
|
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
46
46
|
};
|
|
47
47
|
items.push(copyButton);
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK,
|
|
2
|
+
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
5
|
import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
|
|
4
|
-
import { CreateSyncedBlockItem } from './CreateSyncedBlockItem';
|
|
5
|
-
import { OverflowMenuSection } from './OverflowMenuSection';
|
|
6
|
-
const SYNCED_BLOCK_OVERFLOW_MENU_SECTION = {
|
|
7
|
-
type: SYNCED_BLOCK_SECTION.type,
|
|
8
|
-
key: SYNCED_BLOCK_SECTION.key,
|
|
9
|
-
parents: [{
|
|
10
|
-
type: OVERFLOW_MENU.type,
|
|
11
|
-
key: OVERFLOW_MENU.key,
|
|
12
|
-
rank: OVERFLOW_MENU_RANK[SYNCED_BLOCK_SECTION.key]
|
|
13
|
-
}],
|
|
14
|
-
component: ({
|
|
15
|
-
children
|
|
16
|
-
}) => {
|
|
17
|
-
return /*#__PURE__*/React.createElement(OverflowMenuSection, null, children);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
6
|
const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
21
7
|
type: SYNCED_BLOCK_GROUP.type,
|
|
22
8
|
key: SYNCED_BLOCK_GROUP.key,
|
|
9
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? ({
|
|
10
|
+
children
|
|
11
|
+
}) => /*#__PURE__*/React.createElement(Show, {
|
|
12
|
+
above: "md"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children)) : undefined,
|
|
23
14
|
parents: [{
|
|
24
15
|
type: INSERT_BLOCK_SECTION.type,
|
|
25
16
|
key: INSERT_BLOCK_SECTION.key,
|
|
@@ -27,7 +18,7 @@ const SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
|
27
18
|
}]
|
|
28
19
|
};
|
|
29
20
|
export const getToolbarComponents = api => {
|
|
30
|
-
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP,
|
|
21
|
+
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
|
|
31
22
|
type: SYNCED_BLOCK_BUTTON.type,
|
|
32
23
|
key: SYNCED_BLOCK_BUTTON.key,
|
|
33
24
|
component: () => /*#__PURE__*/React.createElement(CreateSyncedBlockButton, {
|
|
@@ -38,18 +29,5 @@ export const getToolbarComponents = api => {
|
|
|
38
29
|
key: SYNCED_BLOCK_GROUP.key,
|
|
39
30
|
rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_BUTTON.key]
|
|
40
31
|
}]
|
|
41
|
-
}, {
|
|
42
|
-
type: SYNCED_BLOCK_ITEM.type,
|
|
43
|
-
key: SYNCED_BLOCK_ITEM.key,
|
|
44
|
-
parents: [{
|
|
45
|
-
type: SYNCED_BLOCK_SECTION.type,
|
|
46
|
-
key: SYNCED_BLOCK_SECTION.key,
|
|
47
|
-
rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_ITEM.key]
|
|
48
|
-
}],
|
|
49
|
-
component: () => {
|
|
50
|
-
return /*#__PURE__*/React.createElement(CreateSyncedBlockItem, {
|
|
51
|
-
api: api
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
32
|
}];
|
|
55
33
|
};
|
|
@@ -2,7 +2,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
2
2
|
import { copyDomNode, toDOM } from '@atlaskit/editor-common/copy-button';
|
|
3
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
5
6
|
import { canBeConvertedToSyncBlock, findSyncBlock, findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
|
|
7
|
+
import { FLAG_ID } from '../types';
|
|
6
8
|
export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
7
9
|
var tr = _ref.tr,
|
|
8
10
|
syncBlockStore = _ref.syncBlockStore,
|
|
@@ -53,21 +55,21 @@ export var createSyncedBlock = function createSyncedBlock(_ref) {
|
|
|
53
55
|
// see filterTransaction for more details
|
|
54
56
|
return tr;
|
|
55
57
|
};
|
|
56
|
-
export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore) {
|
|
58
|
+
export var copySyncedBlockReferenceToClipboardEditorCommand = function copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, api) {
|
|
57
59
|
return function (_ref2) {
|
|
58
60
|
var tr = _ref2.tr;
|
|
59
|
-
if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore)) {
|
|
61
|
+
if (copySyncedBlockReferenceToClipboardInternal(tr.doc.type.schema, tr.selection, syncBlockStore, api)) {
|
|
60
62
|
return tr;
|
|
61
63
|
}
|
|
62
64
|
return null;
|
|
63
65
|
};
|
|
64
66
|
};
|
|
65
|
-
export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore) {
|
|
67
|
+
export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(syncBlockStore, api) {
|
|
66
68
|
return function (state, _dispatch, _view) {
|
|
67
|
-
return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore);
|
|
69
|
+
return copySyncedBlockReferenceToClipboardInternal(state.tr.doc.type.schema, state.tr.selection, syncBlockStore, api);
|
|
68
70
|
};
|
|
69
71
|
};
|
|
70
|
-
var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore) {
|
|
72
|
+
var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockReferenceToClipboardInternal(schema, selection, syncBlockStore, api) {
|
|
71
73
|
var syncBlockFindResult = findSyncBlockOrBodiedSyncBlock(schema, selection);
|
|
72
74
|
if (!syncBlockFindResult) {
|
|
73
75
|
return false;
|
|
@@ -92,6 +94,18 @@ var copySyncedBlockReferenceToClipboardInternal = function copySyncedBlockRefere
|
|
|
92
94
|
}
|
|
93
95
|
var domNode = toDOM(referenceSyncBlockNode, schema);
|
|
94
96
|
copyDomNode(domNode, referenceSyncBlockNode.type, selection);
|
|
97
|
+
|
|
98
|
+
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
99
|
+
setTimeout(function () {
|
|
100
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
101
|
+
var tr = _ref3.tr;
|
|
102
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
103
|
+
activeFlag: {
|
|
104
|
+
id: FLAG_ID.SYNC_BLOCK_COPIED
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}, 0);
|
|
95
109
|
return true;
|
|
96
110
|
};
|
|
97
111
|
export var editSyncedBlockSource = function editSyncedBlockSource(syncBlockStore, api) {
|
|
@@ -60,7 +60,8 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
60
60
|
useFetchSyncBlockData: function useFetchSyncBlockData() {
|
|
61
61
|
var _this2$api;
|
|
62
62
|
return _useFetchSyncBlockData(syncBlockStore, resourceId, localId, (_this2$api = _this2.api) === null || _this2$api === void 0 || (_this2$api = _this2$api.analytics) === null || _this2$api === void 0 || (_this2$api = _this2$api.actions) === null || _this2$api === void 0 ? void 0 : _this2$api.fireAnalyticsEvent);
|
|
63
|
-
}
|
|
63
|
+
},
|
|
64
|
+
api: this.api
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
}, {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
2
3
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
4
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
4
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
8
|
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
|
|
6
9
|
import { BodiedSyncBlockSharedCssClassName, SyncBlockStateCssClassName } from '@atlaskit/editor-common/sync-block';
|
|
7
|
-
import { pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import { mapSlice, pmHistoryPluginKey } from '@atlaskit/editor-common/utils';
|
|
8
11
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
9
12
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
10
13
|
import { convertPMNodesToSyncBlockNodes, rebaseTransaction } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -102,6 +105,42 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
102
105
|
mousedown: function mousedown(view, event) {
|
|
103
106
|
return shouldIgnoreDomEvent(view, event, api);
|
|
104
107
|
}
|
|
108
|
+
},
|
|
109
|
+
transformCopied: function transformCopied(slice, _ref2) {
|
|
110
|
+
var state = _ref2.state;
|
|
111
|
+
var pluginState = syncedBlockPluginKey.getState(state);
|
|
112
|
+
var syncBlockStore = pluginState === null || pluginState === void 0 ? void 0 : pluginState.syncBlockStore;
|
|
113
|
+
var schema = state.schema;
|
|
114
|
+
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
115
|
+
setTimeout(function () {
|
|
116
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref3) {
|
|
117
|
+
var tr = _ref3.tr;
|
|
118
|
+
return tr.setMeta(syncedBlockPluginKey, {
|
|
119
|
+
activeFlag: {
|
|
120
|
+
id: FLAG_ID.SYNC_BLOCK_COPIED
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}, 0);
|
|
125
|
+
if (!syncBlockStore) {
|
|
126
|
+
return slice;
|
|
127
|
+
}
|
|
128
|
+
return mapSlice(slice, function (node) {
|
|
129
|
+
if (node.type.name === 'bodiedSyncBlock' && node.attrs.resourceId) {
|
|
130
|
+
var newResourceId = syncBlockStore.referenceManager.generateResourceIdForReference(node.attrs.resourceId);
|
|
131
|
+
// Convert bodiedSyncBlock to syncBlock
|
|
132
|
+
// The paste transformation will regenrate the localId
|
|
133
|
+
var newAttrs = _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
134
|
+
resourceId: newResourceId
|
|
135
|
+
});
|
|
136
|
+
var newMarks = schema.nodes.syncBlock.markSet ? node.marks.filter(function (mark) {
|
|
137
|
+
var _schema$nodes$syncBlo;
|
|
138
|
+
return (_schema$nodes$syncBlo = schema.nodes.syncBlock.markSet) === null || _schema$nodes$syncBlo === void 0 ? void 0 : _schema$nodes$syncBlo.includes(mark.type);
|
|
139
|
+
}) : node.marks;
|
|
140
|
+
return schema.nodes.syncBlock.create(newAttrs, null, newMarks);
|
|
141
|
+
}
|
|
142
|
+
return node;
|
|
143
|
+
});
|
|
105
144
|
}
|
|
106
145
|
},
|
|
107
146
|
filterTransaction: function filterTransaction(tr, state) {
|
|
@@ -162,8 +201,8 @@ export var createPlugin = function createPlugin(options, pmPluginFactoryParams,
|
|
|
162
201
|
if (errorFlag) {
|
|
163
202
|
// Use setTimeout to dispatch transaction in next tick and avoid re-entrant dispatch
|
|
164
203
|
setTimeout(function () {
|
|
165
|
-
api === null || api === void 0 || api.core.actions.execute(function (
|
|
166
|
-
var tr =
|
|
204
|
+
api === null || api === void 0 || api.core.actions.execute(function (_ref4) {
|
|
205
|
+
var tr = _ref4.tr;
|
|
167
206
|
return tr.setMeta(syncedBlockPluginKey, {
|
|
168
207
|
activeFlag: {
|
|
169
208
|
id: errorFlag
|
|
@@ -41,7 +41,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
41
41
|
},
|
|
42
42
|
commands: {
|
|
43
43
|
copySyncedBlockReferenceToClipboard: function copySyncedBlockReferenceToClipboard() {
|
|
44
|
-
return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore);
|
|
44
|
+
return copySyncedBlockReferenceToClipboardEditorCommand(syncBlockStore, api);
|
|
45
45
|
},
|
|
46
46
|
insertSyncedBlock: function insertSyncedBlock() {
|
|
47
47
|
return function (_ref2) {
|
package/dist/esm/types/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export var FLAG_ID = /*#__PURE__*/function (FLAG_ID) {
|
|
|
3
3
|
FLAG_ID["CANNOT_EDIT_WHEN_OFFLINE"] = "cannot-edit-when-offline";
|
|
4
4
|
FLAG_ID["CANNOT_CREATE_WHEN_OFFLINE"] = "cannot-create-when-offline";
|
|
5
5
|
FLAG_ID["FAIL_TO_DELETE"] = "fail-to-delete";
|
|
6
|
+
FLAG_ID["SYNC_BLOCK_COPIED"] = "sync-block-copied";
|
|
6
7
|
return FLAG_ID;
|
|
7
8
|
}({});
|
package/dist/esm/ui/Flag.js
CHANGED
|
@@ -5,22 +5,32 @@ import React from 'react';
|
|
|
5
5
|
import { useIntl } from 'react-intl-next';
|
|
6
6
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
7
7
|
import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
8
|
-
import AkFlag, { FlagGroup } from '@atlaskit/flag';
|
|
8
|
+
import AkFlag, { AutoDismissFlag, FlagGroup } from '@atlaskit/flag';
|
|
9
|
+
import ImageIcon from '@atlaskit/icon/core/image';
|
|
9
10
|
import StatusWarningIcon from '@atlaskit/icon/core/status-warning';
|
|
10
11
|
import { syncedBlockPluginKey } from '../pm-plugins/main';
|
|
11
12
|
import { FLAG_ID } from '../types';
|
|
12
|
-
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
13
|
+
var flagMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, FLAG_ID.CANNOT_DELETE_WHEN_OFFLINE, {
|
|
13
14
|
title: messages.failToDeleteTitle,
|
|
14
|
-
description: messages.failToDeleteWhenOfflineDescription
|
|
15
|
+
description: messages.failToDeleteWhenOfflineDescription,
|
|
16
|
+
type: 'error'
|
|
15
17
|
}), FLAG_ID.CANNOT_EDIT_WHEN_OFFLINE, {
|
|
16
18
|
title: messages.failToEditTitle,
|
|
17
|
-
description: messages.failToEditWhenOfflineDescription
|
|
19
|
+
description: messages.failToEditWhenOfflineDescription,
|
|
20
|
+
type: 'error'
|
|
18
21
|
}), FLAG_ID.CANNOT_CREATE_WHEN_OFFLINE, {
|
|
19
22
|
title: messages.failToCreateTitle,
|
|
20
|
-
description: messages.failToCreateWhenOfflineDescription
|
|
23
|
+
description: messages.failToCreateWhenOfflineDescription,
|
|
24
|
+
type: 'error'
|
|
21
25
|
}), FLAG_ID.FAIL_TO_DELETE, {
|
|
22
26
|
title: messages.cannotDeleteTitle,
|
|
23
|
-
description: messages.cannotDeleteDescription
|
|
27
|
+
description: messages.cannotDeleteDescription,
|
|
28
|
+
type: 'error'
|
|
29
|
+
}), FLAG_ID.SYNC_BLOCK_COPIED, {
|
|
30
|
+
title: messages.syncBlockCopiedTitle,
|
|
31
|
+
description: messages.syncBlockCopiedDescription,
|
|
32
|
+
action: messages.syncBlockCopiedAction,
|
|
33
|
+
type: 'info'
|
|
24
34
|
});
|
|
25
35
|
export var Flag = function Flag(_ref) {
|
|
26
36
|
var api = _ref.api;
|
|
@@ -40,7 +50,9 @@ export var Flag = function Flag(_ref) {
|
|
|
40
50
|
}
|
|
41
51
|
var _flagMap$activeFlag$i = flagMap[activeFlag.id],
|
|
42
52
|
title = _flagMap$activeFlag$i.title,
|
|
43
|
-
description = _flagMap$activeFlag$i.description
|
|
53
|
+
description = _flagMap$activeFlag$i.description,
|
|
54
|
+
action = _flagMap$activeFlag$i.action,
|
|
55
|
+
type = _flagMap$activeFlag$i.type;
|
|
44
56
|
var onRetry = activeFlag.onRetry,
|
|
45
57
|
onDismissedCallback = activeFlag.onDismissed;
|
|
46
58
|
|
|
@@ -67,19 +79,42 @@ export var Flag = function Flag(_ref) {
|
|
|
67
79
|
});
|
|
68
80
|
api === null || api === void 0 || api.core.actions.focus();
|
|
69
81
|
};
|
|
70
|
-
|
|
82
|
+
var typeToActions = function typeToActions() {
|
|
83
|
+
if (type === 'error') {
|
|
84
|
+
if (onRetry) {
|
|
85
|
+
return [{
|
|
86
|
+
content: formatMessage(messages.deleteRetryButton),
|
|
87
|
+
onClick: onRetry
|
|
88
|
+
}];
|
|
89
|
+
}
|
|
90
|
+
} else if (type === 'info' && action) {
|
|
91
|
+
return [{
|
|
92
|
+
content: formatMessage(action),
|
|
93
|
+
href: 'https://atlaskit.atlassian.com/',
|
|
94
|
+
target: '_blank'
|
|
95
|
+
}];
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
};
|
|
99
|
+
var FlagComponent = type === 'info' ? AutoDismissFlag : AkFlag;
|
|
100
|
+
return /*#__PURE__*/React.createElement(FlagGroup, null, /*#__PURE__*/React.createElement(FlagComponent, {
|
|
71
101
|
onDismissed: onDismissed,
|
|
72
102
|
title: formatMessage(title),
|
|
73
103
|
description: formatMessage(description),
|
|
74
104
|
id: activeFlag.id,
|
|
75
105
|
testId: activeFlag.id,
|
|
76
|
-
icon:
|
|
106
|
+
icon: typeToIcon(type),
|
|
107
|
+
actions: typeToActions()
|
|
108
|
+
}));
|
|
109
|
+
};
|
|
110
|
+
var typeToIcon = function typeToIcon(type) {
|
|
111
|
+
if (type === 'error') {
|
|
112
|
+
return /*#__PURE__*/React.createElement(StatusWarningIcon, {
|
|
77
113
|
label: "",
|
|
78
114
|
color: "var(--ds-icon-warning, #E06C00)"
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}));
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return /*#__PURE__*/React.createElement(ImageIcon, {
|
|
118
|
+
label: ""
|
|
119
|
+
});
|
|
85
120
|
};
|
|
@@ -6,14 +6,16 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
|
|
|
6
6
|
var syncedBlockRenderer = _ref.syncedBlockRenderer,
|
|
7
7
|
useFetchSyncBlockData = _ref.useFetchSyncBlockData,
|
|
8
8
|
localId = _ref.localId,
|
|
9
|
-
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle
|
|
9
|
+
useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
|
|
10
|
+
api = _ref.api;
|
|
10
11
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
11
12
|
"data-testid": SyncBlockRendererWrapperDataId
|
|
12
13
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
13
14
|
,
|
|
14
15
|
className: SyncBlockSharedCssClassName.renderer
|
|
15
16
|
}, syncedBlockRenderer({
|
|
16
|
-
useFetchSyncBlockData: useFetchSyncBlockData
|
|
17
|
+
useFetchSyncBlockData: useFetchSyncBlockData,
|
|
18
|
+
api: api
|
|
17
19
|
})), /*#__PURE__*/React.createElement(SyncBlockLabel, {
|
|
18
20
|
isSource: false,
|
|
19
21
|
useFetchSyncBlockTitle: useFetchSyncBlockTitle,
|
|
@@ -38,7 +38,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
|
|
|
38
38
|
title: formatMessage(messages.copySyncBlockLabel),
|
|
39
39
|
showTitle: false,
|
|
40
40
|
tooltipContent: formatMessage(messages.copySyncBlockTooltip),
|
|
41
|
-
onClick: copySyncedBlockReferenceToClipboard(syncBlockStore)
|
|
41
|
+
onClick: copySyncedBlockReferenceToClipboard(syncBlockStore, api)
|
|
42
42
|
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
43
43
|
items.push(copyButton);
|
|
44
44
|
var disabled = !syncBlockStore.referenceManager.getSyncBlockURL(syncBlockObject.node.attrs.resourceId);
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK,
|
|
2
|
+
import { INSERT_BLOCK_SECTION, INSERT_BLOCK_SECTION_RANK, SYNCED_BLOCK_BUTTON, SYNCED_BLOCK_GROUP, SYNCED_BLOCK_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { Show, ToolbarButtonGroup } from '@atlaskit/editor-toolbar';
|
|
4
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
3
5
|
import { CreateSyncedBlockButton } from './CreateSyncedBlockButton';
|
|
4
|
-
import { CreateSyncedBlockItem } from './CreateSyncedBlockItem';
|
|
5
|
-
import { OverflowMenuSection } from './OverflowMenuSection';
|
|
6
|
-
var SYNCED_BLOCK_OVERFLOW_MENU_SECTION = {
|
|
7
|
-
type: SYNCED_BLOCK_SECTION.type,
|
|
8
|
-
key: SYNCED_BLOCK_SECTION.key,
|
|
9
|
-
parents: [{
|
|
10
|
-
type: OVERFLOW_MENU.type,
|
|
11
|
-
key: OVERFLOW_MENU.key,
|
|
12
|
-
rank: OVERFLOW_MENU_RANK[SYNCED_BLOCK_SECTION.key]
|
|
13
|
-
}],
|
|
14
|
-
component: function component(_ref) {
|
|
15
|
-
var children = _ref.children;
|
|
16
|
-
return /*#__PURE__*/React.createElement(OverflowMenuSection, null, children);
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
6
|
var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
20
7
|
type: SYNCED_BLOCK_GROUP.type,
|
|
21
8
|
key: SYNCED_BLOCK_GROUP.key,
|
|
9
|
+
component: expValEquals('platform_editor_toolbar_aifc_responsive', 'isEnabled', true) ? function (_ref) {
|
|
10
|
+
var children = _ref.children;
|
|
11
|
+
return /*#__PURE__*/React.createElement(Show, {
|
|
12
|
+
above: "md"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(ToolbarButtonGroup, null, children));
|
|
14
|
+
} : undefined,
|
|
22
15
|
parents: [{
|
|
23
16
|
type: INSERT_BLOCK_SECTION.type,
|
|
24
17
|
key: INSERT_BLOCK_SECTION.key,
|
|
@@ -26,7 +19,7 @@ var SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP = {
|
|
|
26
19
|
}]
|
|
27
20
|
};
|
|
28
21
|
export var getToolbarComponents = function getToolbarComponents(api) {
|
|
29
|
-
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP,
|
|
22
|
+
return [SYNCED_BLOCK_PRIMARY_TOOLBAR_GROUP, {
|
|
30
23
|
type: SYNCED_BLOCK_BUTTON.type,
|
|
31
24
|
key: SYNCED_BLOCK_BUTTON.key,
|
|
32
25
|
component: function component() {
|
|
@@ -39,18 +32,5 @@ export var getToolbarComponents = function getToolbarComponents(api) {
|
|
|
39
32
|
key: SYNCED_BLOCK_GROUP.key,
|
|
40
33
|
rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_BUTTON.key]
|
|
41
34
|
}]
|
|
42
|
-
}, {
|
|
43
|
-
type: SYNCED_BLOCK_ITEM.type,
|
|
44
|
-
key: SYNCED_BLOCK_ITEM.key,
|
|
45
|
-
parents: [{
|
|
46
|
-
type: SYNCED_BLOCK_SECTION.type,
|
|
47
|
-
key: SYNCED_BLOCK_SECTION.key,
|
|
48
|
-
rank: SYNCED_BLOCK_SECTION_RANK[SYNCED_BLOCK_ITEM.key]
|
|
49
|
-
}],
|
|
50
|
-
component: function component() {
|
|
51
|
-
return /*#__PURE__*/React.createElement(CreateSyncedBlockItem, {
|
|
52
|
-
api: api
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
35
|
}];
|
|
56
36
|
};
|
|
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
|
|
|
8
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
9
|
};
|
|
10
10
|
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
11
|
-
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
|
|
12
|
-
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
|
|
11
|
+
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
|
|
12
|
+
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
13
13
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
14
14
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
-
import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorCommand, ExtractInjectionAPI, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
5
|
import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
|
|
@@ -36,6 +36,7 @@ export type SyncedBlockEditorProps = {
|
|
|
36
36
|
popupsMountPoint: HTMLElement;
|
|
37
37
|
};
|
|
38
38
|
export type SyncedBlockRendererProps = {
|
|
39
|
+
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
39
40
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
40
41
|
};
|
|
41
42
|
export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
|
|
@@ -4,7 +4,8 @@ export declare enum FLAG_ID {
|
|
|
4
4
|
CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
|
|
5
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
6
6
|
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
|
-
FAIL_TO_DELETE = "fail-to-delete"
|
|
7
|
+
FAIL_TO_DELETE = "fail-to-delete",
|
|
8
|
+
SYNC_BLOCK_COPIED = "sync-block-copied"
|
|
8
9
|
}
|
|
9
10
|
type FlagConfig = {
|
|
10
11
|
id: FLAG_ID;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { UseFetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
-
import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
|
+
import type { SyncedBlockPlugin, SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
5
|
type Props = {
|
|
5
|
-
|
|
6
|
+
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
6
7
|
localId: string;
|
|
8
|
+
syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
7
9
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
8
10
|
useFetchSyncBlockTitle: () => string | undefined;
|
|
9
11
|
};
|
|
10
|
-
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
|
|
12
|
+
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, api, }: Props) => React.JSX.Element>;
|
|
11
13
|
export {};
|
|
@@ -8,8 +8,8 @@ type createSyncedBlockProps = {
|
|
|
8
8
|
typeAheadInsert?: TypeAheadInsert;
|
|
9
9
|
};
|
|
10
10
|
export declare const createSyncedBlock: ({ tr, syncBlockStore, typeAheadInsert, }: createSyncedBlockProps) => false | Transaction;
|
|
11
|
-
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager) => EditorCommand;
|
|
12
|
-
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager) => Command;
|
|
11
|
+
export declare const copySyncedBlockReferenceToClipboardEditorCommand: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => EditorCommand;
|
|
12
|
+
export declare const copySyncedBlockReferenceToClipboard: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
13
13
|
export declare const editSyncedBlockSource: (syncBlockStore: SyncBlockStoreManager, api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
14
14
|
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
-
import type { EditorCommand, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { EditorCommand, ExtractInjectionAPI, LongPressSelectionPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
4
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
5
|
import type { BlockControlsPlugin } from '@atlaskit/editor-plugin-block-controls';
|
|
@@ -36,6 +36,7 @@ export type SyncedBlockEditorProps = {
|
|
|
36
36
|
popupsMountPoint: HTMLElement;
|
|
37
37
|
};
|
|
38
38
|
export type SyncedBlockRendererProps = {
|
|
39
|
+
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
39
40
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
40
41
|
};
|
|
41
42
|
export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
|
|
@@ -4,7 +4,8 @@ export declare enum FLAG_ID {
|
|
|
4
4
|
CANNOT_DELETE_WHEN_OFFLINE = "cannot-delete-when-offline",
|
|
5
5
|
CANNOT_EDIT_WHEN_OFFLINE = "cannot-edit-when-offline",
|
|
6
6
|
CANNOT_CREATE_WHEN_OFFLINE = "cannot-create-when-offline",
|
|
7
|
-
FAIL_TO_DELETE = "fail-to-delete"
|
|
7
|
+
FAIL_TO_DELETE = "fail-to-delete",
|
|
8
|
+
SYNC_BLOCK_COPIED = "sync-block-copied"
|
|
8
9
|
}
|
|
9
10
|
type FlagConfig = {
|
|
10
11
|
id: FLAG_ID;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { UseFetchSyncBlockDataResult } from '@atlaskit/editor-synced-block-provider';
|
|
3
|
-
import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
|
+
import type { SyncedBlockPlugin, SyncedBlockRendererProps } from '../syncedBlockPluginType';
|
|
4
5
|
type Props = {
|
|
5
|
-
|
|
6
|
+
api?: ExtractInjectionAPI<SyncedBlockPlugin>;
|
|
6
7
|
localId: string;
|
|
8
|
+
syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
|
|
7
9
|
useFetchSyncBlockData: () => UseFetchSyncBlockDataResult;
|
|
8
10
|
useFetchSyncBlockTitle: () => string | undefined;
|
|
9
11
|
};
|
|
10
|
-
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
|
|
12
|
+
export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ syncedBlockRenderer, useFetchSyncBlockData, localId, useFetchSyncBlockTitle, api, }: Props) => React.JSX.Element>;
|
|
11
13
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.1",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
41
|
"@atlaskit/editor-shared-styles": "^3.10.0",
|
|
42
|
-
"@atlaskit/editor-synced-block-provider": "^2.
|
|
42
|
+
"@atlaskit/editor-synced-block-provider": "^2.15.0",
|
|
43
43
|
"@atlaskit/editor-tables": "^2.9.0",
|
|
44
44
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
45
45
|
"@atlaskit/flag": "^17.6.0",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@atlaskit/lozenge": "^13.1.0",
|
|
50
50
|
"@atlaskit/modal-dialog": "^14.8.0",
|
|
51
51
|
"@atlaskit/primitives": "^16.4.0",
|
|
52
|
+
"@atlaskit/tmp-editor-statsig": "^15.9.0",
|
|
52
53
|
"@atlaskit/tokens": "8.4.1",
|
|
53
54
|
"@atlaskit/tooltip": "^20.11.0",
|
|
54
55
|
"@atlaskit/visually-hidden": "^3.0.0",
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.CreateSyncedBlockItem = void 0;
|
|
9
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactIntlNext = require("react-intl-next");
|
|
11
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
12
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
-
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
14
|
-
var _blockSynced = _interopRequireDefault(require("@atlaskit/icon-lab/core/block-synced"));
|
|
15
|
-
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
|
|
16
|
-
var _utils = require("../pm-plugins/utils/utils");
|
|
17
|
-
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); }
|
|
18
|
-
var CreateSyncedBlockItem = exports.CreateSyncedBlockItem = function CreateSyncedBlockItem(_ref) {
|
|
19
|
-
var api = _ref.api;
|
|
20
|
-
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
21
|
-
formatMessage = _useIntl.formatMessage;
|
|
22
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['selection', 'connectivity'], function (states) {
|
|
23
|
-
var _states$selectionStat, _states$connectivityS;
|
|
24
|
-
return {
|
|
25
|
-
selection: (_states$selectionStat = states.selectionState) === null || _states$selectionStat === void 0 ? void 0 : _states$selectionStat.selection,
|
|
26
|
-
mode: (_states$connectivityS = states.connectivityState) === null || _states$connectivityS === void 0 ? void 0 : _states$connectivityS.mode
|
|
27
|
-
};
|
|
28
|
-
}),
|
|
29
|
-
selection = _useSharedPluginState.selection,
|
|
30
|
-
mode = _useSharedPluginState.mode;
|
|
31
|
-
var isDisabled = Boolean(!selection || !(0, _utils.canBeConvertedToSyncBlock)(selection) || mode === 'offline');
|
|
32
|
-
var onClick = (0, _react.useCallback)(function () {
|
|
33
|
-
var _api$core, _api$core2;
|
|
34
|
-
api === null || api === void 0 || (_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(function (_ref2) {
|
|
35
|
-
var tr = _ref2.tr;
|
|
36
|
-
return api === null || api === void 0 ? void 0 : api.syncedBlock.commands.insertSyncedBlock()({
|
|
37
|
-
tr: tr
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.focus();
|
|
41
|
-
}, [api]);
|
|
42
|
-
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
43
|
-
onClick: onClick,
|
|
44
|
-
isDisabled: isDisabled,
|
|
45
|
-
elemBefore: /*#__PURE__*/_react.default.createElement(_blockSynced.default, {
|
|
46
|
-
size: "small",
|
|
47
|
-
label: ""
|
|
48
|
-
}),
|
|
49
|
-
elemAfter: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
|
|
50
|
-
appearance: "new"
|
|
51
|
-
}, formatMessage(_messages.syncBlockMessages.newLozenge))
|
|
52
|
-
}, formatMessage(_messages.syncBlockMessages.createSyncBlockLabel));
|
|
53
|
-
};
|