@atlaskit/editor-plugin-synced-block 3.0.0 → 3.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 +8 -0
- package/afm-cc/tsconfig.json +9 -0
- package/afm-dev-agents/tsconfig.json +9 -0
- package/afm-jira/tsconfig.json +9 -0
- package/afm-passionfruit/tsconfig.json +9 -0
- package/afm-post-office/tsconfig.json +9 -0
- package/afm-rovo-extension/tsconfig.json +9 -0
- package/afm-townsquare/tsconfig.json +9 -0
- package/dist/cjs/pm-plugins/actions.js +57 -26
- package/dist/cjs/syncedBlockPlugin.js +1 -1
- package/dist/cjs/ui/floating-toolbar.js +52 -19
- package/dist/es2019/pm-plugins/actions.js +68 -25
- package/dist/es2019/syncedBlockPlugin.js +1 -1
- package/dist/es2019/ui/floating-toolbar.js +46 -16
- package/dist/esm/pm-plugins/actions.js +56 -24
- package/dist/esm/syncedBlockPlugin.js +1 -1
- package/dist/esm/ui/floating-toolbar.js +51 -20
- package/dist/types/pm-plugins/actions.d.ts +5 -2
- package/dist/types/syncedBlockPluginType.d.ts +3 -1
- package/dist/types/ui/floating-toolbar.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +5 -2
- package/dist/types-ts4.5/syncedBlockPluginType.d.ts +5 -1
- package/dist/types-ts4.5/ui/floating-toolbar.d.ts +4 -4
- package/package.json +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-synced-block
|
|
2
2
|
|
|
3
|
+
## 3.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6e2b6f72d4bc2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6e2b6f72d4bc2) -
|
|
8
|
+
Added floating toolbar for sync block
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
3
11
|
## 3.0.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-cc/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-cc/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-cc/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-cc/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-cc/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-cc/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-dev-agents/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-dev-agents/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-dev-agents/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-dev-agents/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-dev-agents/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-dev-agents/tsconfig.json"
|
|
33
42
|
},
|
package/afm-jira/tsconfig.json
CHANGED
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-jira/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-jira/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-jira/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-jira/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-jira/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-jira/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-passionfruit/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-passionfruit/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-passionfruit/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-passionfruit/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-passionfruit/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-passionfruit/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-post-office/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-post-office/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-post-office/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-post-office/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-post-office/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-post-office/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-rovo-extension/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-rovo-extension/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-rovo-extension/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-rovo-extension/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-rovo-extension/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-rovo-extension/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -25,9 +25,18 @@
|
|
|
25
25
|
{
|
|
26
26
|
"path": "../../../design-system/button/afm-townsquare/tsconfig.json"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"path": "../../editor-plugin-decorations/afm-townsquare/tsconfig.json"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"path": "../../editor-plugin-floating-toolbar/afm-townsquare/tsconfig.json"
|
|
33
|
+
},
|
|
28
34
|
{
|
|
29
35
|
"path": "../../editor-plugin-selection/afm-townsquare/tsconfig.json"
|
|
30
36
|
},
|
|
37
|
+
{
|
|
38
|
+
"path": "../../editor-shared-styles/afm-townsquare/tsconfig.json"
|
|
39
|
+
},
|
|
31
40
|
{
|
|
32
41
|
"path": "../../editor-synced-block-provider/afm-townsquare/tsconfig.json"
|
|
33
42
|
},
|
|
@@ -1,39 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboard = void 0;
|
|
8
|
-
var
|
|
9
|
-
var _copyButton = require("@atlaskit/editor-common/copy-button");
|
|
10
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
6
|
+
exports.removeSyncedBlock = exports.editSyncedBlockSource = exports.createSyncedBlock = exports.copySyncedBlockReferenceToClipboard = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
8
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
9
|
+
var _editorSyncedBlockProvider = require("@atlaskit/editor-synced-block-provider");
|
|
10
|
+
var _utils2 = require("./utils/utils");
|
|
12
11
|
var createSyncedBlock = exports.createSyncedBlock = function createSyncedBlock(state) {
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var node = state.schema.nodes.syncBlock.createChecked({
|
|
17
|
-
resourceId: id,
|
|
18
|
-
localId: id
|
|
19
|
-
}, null
|
|
20
|
-
// [breakout.create({ mode: 'wide' })],
|
|
21
|
-
);
|
|
12
|
+
var tr = state.tr,
|
|
13
|
+
syncBlock = state.schema.nodes.syncBlock;
|
|
14
|
+
var node = (0, _editorSyncedBlockProvider.createSyncBlockPMNode)(syncBlock);
|
|
22
15
|
(0, _utils.safeInsert)(node)(tr);
|
|
23
16
|
return tr;
|
|
24
17
|
};
|
|
25
|
-
var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
var nodeType = selection.node.type;
|
|
30
|
-
var domNode = (0, _copyButton.toDOM)(selection.node, schema);
|
|
31
|
-
// clear local-id
|
|
32
|
-
if (domNode instanceof HTMLElement) {
|
|
33
|
-
domNode.setAttribute('data-local-id', '');
|
|
18
|
+
var copySyncedBlockReferenceToClipboard = exports.copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(api) {
|
|
19
|
+
return function (state, dispatch, _view) {
|
|
20
|
+
if (!(api !== null && api !== void 0 && api.floatingToolbar) || !dispatch) {
|
|
21
|
+
return false;
|
|
34
22
|
}
|
|
35
|
-
|
|
23
|
+
var syncBlock = state.schema.nodes.syncBlock,
|
|
24
|
+
tr = state.tr;
|
|
25
|
+
var newTr = api.floatingToolbar.commands.copyNode(syncBlock, _analytics.INPUT_METHOD.FLOATING_TB)({
|
|
26
|
+
tr: tr
|
|
27
|
+
});
|
|
28
|
+
if (!newTr) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
dispatch(newTr);
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var editSyncedBlockSource = exports.editSyncedBlockSource = function editSyncedBlockSource(_api) {
|
|
36
|
+
return function (state, _dispatch, _view) {
|
|
37
|
+
var syncBlock = (0, _utils2.findSyncBlock)(state);
|
|
38
|
+
if (!syncBlock) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
var url = (0, _editorSyncedBlockProvider.generateSyncBlockSourceUrl)(syncBlock.node);
|
|
42
|
+
if (!url) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
window.open(url, '_blank');
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
var removeSyncedBlock = exports.removeSyncedBlock = function removeSyncedBlock(api) {
|
|
50
|
+
return function (state, dispatch, _view) {
|
|
51
|
+
var _state$selection = state.selection,
|
|
52
|
+
from = _state$selection.$from.pos,
|
|
53
|
+
to = _state$selection.$to.pos,
|
|
54
|
+
tr = state.tr;
|
|
55
|
+
var syncBlock = (0, _utils2.findSyncBlock)(state);
|
|
56
|
+
if (!syncBlock) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
if (!dispatch) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
var newTr = tr.deleteRange(from, to);
|
|
63
|
+
if (!newTr) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
dispatch(newTr);
|
|
67
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
36
68
|
return true;
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
69
|
+
};
|
|
39
70
|
};
|
|
@@ -53,7 +53,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
|
|
|
53
53
|
}];
|
|
54
54
|
},
|
|
55
55
|
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
56
|
-
return (0, _floatingToolbar.getToolbarConfig)(state, intl, config, providerFactory);
|
|
56
|
+
return (0, _floatingToolbar.getToolbarConfig)(state, intl, config, providerFactory, api);
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
59
|
contentComponent: function contentComponent() {
|
|
@@ -1,55 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.getToolbarConfig = void 0;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
8
12
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
+
var _consts = require("@atlaskit/editor-shared-styles/consts");
|
|
9
14
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
15
|
+
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
10
16
|
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
11
17
|
var _actions = require("../pm-plugins/actions");
|
|
12
18
|
var _utils2 = require("../pm-plugins/utils/utils");
|
|
13
|
-
var
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
23
|
+
var _api$decorations;
|
|
14
24
|
var _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
15
25
|
var _providerFactory = arguments.length > 3 ? arguments[3] : undefined;
|
|
26
|
+
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
16
27
|
var syncBlockObject = (0, _utils2.findSyncBlock)(state);
|
|
17
28
|
if (!syncBlockObject) {
|
|
18
29
|
return;
|
|
19
30
|
}
|
|
31
|
+
var formatMessage = intl.formatMessage;
|
|
20
32
|
var nodeType = state.schema.nodes.syncBlock;
|
|
33
|
+
var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
|
|
34
|
+
var hoverDecorationProps = function hoverDecorationProps(nodeType, className) {
|
|
35
|
+
return {
|
|
36
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
37
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
|
|
38
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
39
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
|
|
40
|
+
};
|
|
41
|
+
};
|
|
21
42
|
var items = [];
|
|
22
|
-
var copyButton = {
|
|
43
|
+
var copyButton = _objectSpread({
|
|
23
44
|
id: 'editor.syncedBlock.copy',
|
|
24
45
|
type: 'button',
|
|
25
46
|
appearance: 'subtle',
|
|
26
47
|
icon: _copy.default,
|
|
27
|
-
title:
|
|
48
|
+
title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
|
|
28
49
|
showTitle: true,
|
|
29
|
-
tooltipContent:
|
|
30
|
-
onClick: _actions.copySyncedBlockReferenceToClipboard
|
|
31
|
-
};
|
|
50
|
+
tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncBlockTooltip),
|
|
51
|
+
onClick: (0, _actions.copySyncedBlockReferenceToClipboard)(api)
|
|
52
|
+
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
32
53
|
items.push(copyButton);
|
|
33
54
|
if (syncBlockObject.node.attrs.resourceId !== syncBlockObject.node.attrs.localId) {
|
|
34
|
-
var editSourceButton = {
|
|
55
|
+
var editSourceButton = _objectSpread({
|
|
35
56
|
id: 'editor.syncedBlock.editSource',
|
|
36
57
|
type: 'button',
|
|
37
58
|
appearance: 'subtle',
|
|
38
59
|
icon: _linkExternal.default,
|
|
39
|
-
title:
|
|
60
|
+
title: formatMessage(_messages.syncBlockMessages.editSourceLabel),
|
|
40
61
|
showTitle: true,
|
|
41
|
-
tooltipContent:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!view) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
// to be implemented in a follow up PR
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
62
|
+
tooltipContent: formatMessage(_messages.syncBlockMessages.editSourceTooltip),
|
|
63
|
+
onClick: (0, _actions.editSyncedBlockSource)(api)
|
|
64
|
+
}, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
|
|
51
65
|
items.push(editSourceButton);
|
|
52
66
|
}
|
|
67
|
+
|
|
68
|
+
// testId is required to show focus on trigger button on ESC key press
|
|
69
|
+
// see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
|
|
70
|
+
var testId = 'synced-block-overflow-dropdown-trigger';
|
|
71
|
+
var overflowMenuConfig = [{
|
|
72
|
+
type: 'separator',
|
|
73
|
+
fullHeight: true
|
|
74
|
+
}, {
|
|
75
|
+
type: 'overflow-dropdown',
|
|
76
|
+
testId: testId,
|
|
77
|
+
options: [_objectSpread({
|
|
78
|
+
title: formatMessage(_messages.default.delete),
|
|
79
|
+
onClick: (0, _actions.removeSyncedBlock)(api),
|
|
80
|
+
icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
|
|
81
|
+
label: ""
|
|
82
|
+
})
|
|
83
|
+
}, hoverDecorationProps(nodeType))]
|
|
84
|
+
}];
|
|
85
|
+
items.push.apply(items, overflowMenuConfig);
|
|
53
86
|
var getDomRef = function getDomRef(editorView) {
|
|
54
87
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
55
88
|
var element = (0, _utils.findDomRefAtPos)(syncBlockObject.pos, domAtPos);
|
|
@@ -61,6 +94,6 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
|
|
|
61
94
|
nodeType: nodeType,
|
|
62
95
|
items: items,
|
|
63
96
|
scrollable: true,
|
|
64
|
-
groupLabel:
|
|
97
|
+
groupLabel: formatMessage(_messages.syncBlockMessages.syncBlockGroup)
|
|
65
98
|
};
|
|
66
99
|
};
|
|
@@ -1,34 +1,77 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
|
|
3
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { createSyncBlockPMNode, generateSyncBlockSourceUrl } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import { findSyncBlock } from './utils/utils';
|
|
5
5
|
export const createSyncedBlock = state => {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
6
|
+
const {
|
|
7
|
+
tr,
|
|
8
|
+
schema: {
|
|
9
|
+
nodes: {
|
|
10
|
+
syncBlock
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
} = state;
|
|
14
|
+
const node = createSyncBlockPMNode(syncBlock);
|
|
15
15
|
safeInsert(node)(tr);
|
|
16
16
|
return tr;
|
|
17
17
|
};
|
|
18
|
-
export const copySyncedBlockReferenceToClipboard = (state,
|
|
18
|
+
export const copySyncedBlockReferenceToClipboard = api => (state, dispatch, _view) => {
|
|
19
|
+
if (!(api !== null && api !== void 0 && api.floatingToolbar) || !dispatch) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
19
22
|
const {
|
|
20
|
-
schema
|
|
21
|
-
|
|
23
|
+
schema: {
|
|
24
|
+
nodes: {
|
|
25
|
+
syncBlock
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
tr
|
|
22
29
|
} = state;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const newTr = api.floatingToolbar.commands.copyNode(syncBlock, INPUT_METHOD.FLOATING_TB)({
|
|
31
|
+
tr
|
|
32
|
+
});
|
|
33
|
+
if (!newTr) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
dispatch(newTr);
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
export const editSyncedBlockSource = _api => (state, _dispatch, _view) => {
|
|
40
|
+
const syncBlock = findSyncBlock(state);
|
|
41
|
+
if (!syncBlock) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const url = generateSyncBlockSourceUrl(syncBlock.node);
|
|
45
|
+
if (!url) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
window.open(url, '_blank');
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
export const removeSyncedBlock = api => (state, dispatch, _view) => {
|
|
52
|
+
const {
|
|
53
|
+
selection: {
|
|
54
|
+
$from: {
|
|
55
|
+
pos: from
|
|
56
|
+
},
|
|
57
|
+
$to: {
|
|
58
|
+
pos: to
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
tr
|
|
62
|
+
} = state;
|
|
63
|
+
const syncBlock = findSyncBlock(state);
|
|
64
|
+
if (!syncBlock) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (!dispatch) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const newTr = tr.deleteRange(from, to);
|
|
71
|
+
if (!newTr) {
|
|
72
|
+
return false;
|
|
32
73
|
}
|
|
33
|
-
|
|
74
|
+
dispatch(newTr);
|
|
75
|
+
api === null || api === void 0 ? void 0 : api.core.actions.focus();
|
|
76
|
+
return true;
|
|
34
77
|
};
|
|
@@ -40,7 +40,7 @@ export const syncedBlockPlugin = ({
|
|
|
40
40
|
return createSyncedBlock(state);
|
|
41
41
|
}
|
|
42
42
|
}],
|
|
43
|
-
floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, config, providerFactory)
|
|
43
|
+
floatingToolbar: (state, intl, providerFactory) => getToolbarConfig(state, intl, config, providerFactory, api)
|
|
44
44
|
},
|
|
45
45
|
contentComponent: () => {
|
|
46
46
|
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
@@ -1,24 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import commonMessages, { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
1
3
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/consts';
|
|
2
5
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
6
|
+
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
3
7
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
4
|
-
import { copySyncedBlockReferenceToClipboard } from '../pm-plugins/actions';
|
|
8
|
+
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../pm-plugins/actions';
|
|
5
9
|
import { findSyncBlock } from '../pm-plugins/utils/utils';
|
|
6
|
-
export const getToolbarConfig = (state,
|
|
10
|
+
export const getToolbarConfig = (state, intl, _options = {}, _providerFactory, api) => {
|
|
11
|
+
var _api$decorations;
|
|
7
12
|
const syncBlockObject = findSyncBlock(state);
|
|
8
13
|
if (!syncBlockObject) {
|
|
9
14
|
return;
|
|
10
15
|
}
|
|
16
|
+
const {
|
|
17
|
+
formatMessage
|
|
18
|
+
} = intl;
|
|
11
19
|
const nodeType = state.schema.nodes.syncBlock;
|
|
20
|
+
const hoverDecoration = api === null || api === void 0 ? void 0 : (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
|
|
21
|
+
const hoverDecorationProps = (nodeType, className) => ({
|
|
22
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
23
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
|
|
24
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
25
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
|
|
26
|
+
});
|
|
12
27
|
const items = [];
|
|
13
28
|
const copyButton = {
|
|
14
29
|
id: 'editor.syncedBlock.copy',
|
|
15
30
|
type: 'button',
|
|
16
31
|
appearance: 'subtle',
|
|
17
32
|
icon: CopyIcon,
|
|
18
|
-
title:
|
|
33
|
+
title: formatMessage(messages.copySyncBlockLabel),
|
|
19
34
|
showTitle: true,
|
|
20
|
-
tooltipContent:
|
|
21
|
-
onClick: copySyncedBlockReferenceToClipboard
|
|
35
|
+
tooltipContent: formatMessage(messages.copySyncBlockTooltip),
|
|
36
|
+
onClick: copySyncedBlockReferenceToClipboard(api),
|
|
37
|
+
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
22
38
|
};
|
|
23
39
|
items.push(copyButton);
|
|
24
40
|
if (syncBlockObject.node.attrs.resourceId !== syncBlockObject.node.attrs.localId) {
|
|
@@ -27,20 +43,34 @@ export const getToolbarConfig = (state, _intl, _options = {}, _providerFactory)
|
|
|
27
43
|
type: 'button',
|
|
28
44
|
appearance: 'subtle',
|
|
29
45
|
icon: LinkExternalIcon,
|
|
30
|
-
title:
|
|
46
|
+
title: formatMessage(messages.editSourceLabel),
|
|
31
47
|
showTitle: true,
|
|
32
|
-
tooltipContent:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (!view) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
// to be implemented in a follow up PR
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
48
|
+
tooltipContent: formatMessage(messages.editSourceTooltip),
|
|
49
|
+
onClick: editSyncedBlockSource(api),
|
|
50
|
+
...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
|
|
41
51
|
};
|
|
42
52
|
items.push(editSourceButton);
|
|
43
53
|
}
|
|
54
|
+
|
|
55
|
+
// testId is required to show focus on trigger button on ESC key press
|
|
56
|
+
// see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
|
|
57
|
+
const testId = 'synced-block-overflow-dropdown-trigger';
|
|
58
|
+
const overflowMenuConfig = [{
|
|
59
|
+
type: 'separator',
|
|
60
|
+
fullHeight: true
|
|
61
|
+
}, {
|
|
62
|
+
type: 'overflow-dropdown',
|
|
63
|
+
testId,
|
|
64
|
+
options: [{
|
|
65
|
+
title: formatMessage(commonMessages.delete),
|
|
66
|
+
onClick: removeSyncedBlock(api),
|
|
67
|
+
icon: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
68
|
+
label: ""
|
|
69
|
+
}),
|
|
70
|
+
...hoverDecorationProps(nodeType)
|
|
71
|
+
}]
|
|
72
|
+
}];
|
|
73
|
+
items.push(...overflowMenuConfig);
|
|
44
74
|
const getDomRef = editorView => {
|
|
45
75
|
const domAtPos = editorView.domAtPos.bind(editorView);
|
|
46
76
|
const element = findDomRefAtPos(syncBlockObject.pos, domAtPos);
|
|
@@ -52,6 +82,6 @@ export const getToolbarConfig = (state, _intl, _options = {}, _providerFactory)
|
|
|
52
82
|
nodeType,
|
|
53
83
|
items,
|
|
54
84
|
scrollable: true,
|
|
55
|
-
groupLabel:
|
|
85
|
+
groupLabel: formatMessage(messages.syncBlockGroup)
|
|
56
86
|
};
|
|
57
87
|
};
|
|
@@ -1,32 +1,64 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { toDOM, copyDomNode } from '@atlaskit/editor-common/copy-button';
|
|
3
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { createSyncBlockPMNode, generateSyncBlockSourceUrl } from '@atlaskit/editor-synced-block-provider';
|
|
4
|
+
import { findSyncBlock } from './utils/utils';
|
|
5
5
|
export var createSyncedBlock = function createSyncedBlock(state) {
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var node = state.schema.nodes.syncBlock.createChecked({
|
|
10
|
-
resourceId: id,
|
|
11
|
-
localId: id
|
|
12
|
-
}, null
|
|
13
|
-
// [breakout.create({ mode: 'wide' })],
|
|
14
|
-
);
|
|
6
|
+
var tr = state.tr,
|
|
7
|
+
syncBlock = state.schema.nodes.syncBlock;
|
|
8
|
+
var node = createSyncBlockPMNode(syncBlock);
|
|
15
9
|
safeInsert(node)(tr);
|
|
16
10
|
return tr;
|
|
17
11
|
};
|
|
18
|
-
export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var nodeType = selection.node.type;
|
|
23
|
-
var domNode = toDOM(selection.node, schema);
|
|
24
|
-
// clear local-id
|
|
25
|
-
if (domNode instanceof HTMLElement) {
|
|
26
|
-
domNode.setAttribute('data-local-id', '');
|
|
12
|
+
export var copySyncedBlockReferenceToClipboard = function copySyncedBlockReferenceToClipboard(api) {
|
|
13
|
+
return function (state, dispatch, _view) {
|
|
14
|
+
if (!(api !== null && api !== void 0 && api.floatingToolbar) || !dispatch) {
|
|
15
|
+
return false;
|
|
27
16
|
}
|
|
28
|
-
|
|
17
|
+
var syncBlock = state.schema.nodes.syncBlock,
|
|
18
|
+
tr = state.tr;
|
|
19
|
+
var newTr = api.floatingToolbar.commands.copyNode(syncBlock, INPUT_METHOD.FLOATING_TB)({
|
|
20
|
+
tr: tr
|
|
21
|
+
});
|
|
22
|
+
if (!newTr) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
dispatch(newTr);
|
|
26
|
+
return true;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export var editSyncedBlockSource = function editSyncedBlockSource(_api) {
|
|
30
|
+
return function (state, _dispatch, _view) {
|
|
31
|
+
var syncBlock = findSyncBlock(state);
|
|
32
|
+
if (!syncBlock) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
var url = generateSyncBlockSourceUrl(syncBlock.node);
|
|
36
|
+
if (!url) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
window.open(url, '_blank');
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export var removeSyncedBlock = function removeSyncedBlock(api) {
|
|
44
|
+
return function (state, dispatch, _view) {
|
|
45
|
+
var _state$selection = state.selection,
|
|
46
|
+
from = _state$selection.$from.pos,
|
|
47
|
+
to = _state$selection.$to.pos,
|
|
48
|
+
tr = state.tr;
|
|
49
|
+
var syncBlock = findSyncBlock(state);
|
|
50
|
+
if (!syncBlock) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
if (!dispatch) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
var newTr = tr.deleteRange(from, to);
|
|
57
|
+
if (!newTr) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
dispatch(newTr);
|
|
61
|
+
api === null || api === void 0 || api.core.actions.focus();
|
|
29
62
|
return true;
|
|
30
|
-
}
|
|
31
|
-
return false;
|
|
63
|
+
};
|
|
32
64
|
};
|
|
@@ -46,7 +46,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref) {
|
|
|
46
46
|
}];
|
|
47
47
|
},
|
|
48
48
|
floatingToolbar: function floatingToolbar(state, intl, providerFactory) {
|
|
49
|
-
return getToolbarConfig(state, intl, config, providerFactory);
|
|
49
|
+
return getToolbarConfig(state, intl, config, providerFactory, api);
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
contentComponent: function contentComponent() {
|
|
@@ -1,48 +1,79 @@
|
|
|
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; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import commonMessages, { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
1
6
|
import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/consts';
|
|
2
8
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
9
|
+
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
3
10
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
4
|
-
import { copySyncedBlockReferenceToClipboard } from '../pm-plugins/actions';
|
|
11
|
+
import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock } from '../pm-plugins/actions';
|
|
5
12
|
import { findSyncBlock } from '../pm-plugins/utils/utils';
|
|
6
|
-
export var getToolbarConfig = function getToolbarConfig(state,
|
|
13
|
+
export var getToolbarConfig = function getToolbarConfig(state, intl) {
|
|
14
|
+
var _api$decorations;
|
|
7
15
|
var _options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
8
16
|
var _providerFactory = arguments.length > 3 ? arguments[3] : undefined;
|
|
17
|
+
var api = arguments.length > 4 ? arguments[4] : undefined;
|
|
9
18
|
var syncBlockObject = findSyncBlock(state);
|
|
10
19
|
if (!syncBlockObject) {
|
|
11
20
|
return;
|
|
12
21
|
}
|
|
22
|
+
var formatMessage = intl.formatMessage;
|
|
13
23
|
var nodeType = state.schema.nodes.syncBlock;
|
|
24
|
+
var hoverDecoration = api === null || api === void 0 || (_api$decorations = api.decorations) === null || _api$decorations === void 0 ? void 0 : _api$decorations.actions.hoverDecoration;
|
|
25
|
+
var hoverDecorationProps = function hoverDecorationProps(nodeType, className) {
|
|
26
|
+
return {
|
|
27
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
28
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className),
|
|
29
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true, className),
|
|
30
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false, className)
|
|
31
|
+
};
|
|
32
|
+
};
|
|
14
33
|
var items = [];
|
|
15
|
-
var copyButton = {
|
|
34
|
+
var copyButton = _objectSpread({
|
|
16
35
|
id: 'editor.syncedBlock.copy',
|
|
17
36
|
type: 'button',
|
|
18
37
|
appearance: 'subtle',
|
|
19
38
|
icon: CopyIcon,
|
|
20
|
-
title:
|
|
39
|
+
title: formatMessage(messages.copySyncBlockLabel),
|
|
21
40
|
showTitle: true,
|
|
22
|
-
tooltipContent:
|
|
23
|
-
onClick: copySyncedBlockReferenceToClipboard
|
|
24
|
-
};
|
|
41
|
+
tooltipContent: formatMessage(messages.copySyncBlockTooltip),
|
|
42
|
+
onClick: copySyncedBlockReferenceToClipboard(api)
|
|
43
|
+
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
25
44
|
items.push(copyButton);
|
|
26
45
|
if (syncBlockObject.node.attrs.resourceId !== syncBlockObject.node.attrs.localId) {
|
|
27
|
-
var editSourceButton = {
|
|
46
|
+
var editSourceButton = _objectSpread({
|
|
28
47
|
id: 'editor.syncedBlock.editSource',
|
|
29
48
|
type: 'button',
|
|
30
49
|
appearance: 'subtle',
|
|
31
50
|
icon: LinkExternalIcon,
|
|
32
|
-
title:
|
|
51
|
+
title: formatMessage(messages.editSourceLabel),
|
|
33
52
|
showTitle: true,
|
|
34
|
-
tooltipContent:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!view) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
// to be implemented in a follow up PR
|
|
41
|
-
return true;
|
|
42
|
-
}
|
|
43
|
-
};
|
|
53
|
+
tooltipContent: formatMessage(messages.editSourceTooltip),
|
|
54
|
+
onClick: editSyncedBlockSource(api)
|
|
55
|
+
}, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
|
|
44
56
|
items.push(editSourceButton);
|
|
45
57
|
}
|
|
58
|
+
|
|
59
|
+
// testId is required to show focus on trigger button on ESC key press
|
|
60
|
+
// see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
|
|
61
|
+
var testId = 'synced-block-overflow-dropdown-trigger';
|
|
62
|
+
var overflowMenuConfig = [{
|
|
63
|
+
type: 'separator',
|
|
64
|
+
fullHeight: true
|
|
65
|
+
}, {
|
|
66
|
+
type: 'overflow-dropdown',
|
|
67
|
+
testId: testId,
|
|
68
|
+
options: [_objectSpread({
|
|
69
|
+
title: formatMessage(commonMessages.delete),
|
|
70
|
+
onClick: removeSyncedBlock(api),
|
|
71
|
+
icon: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
72
|
+
label: ""
|
|
73
|
+
})
|
|
74
|
+
}, hoverDecorationProps(nodeType))]
|
|
75
|
+
}];
|
|
76
|
+
items.push.apply(items, overflowMenuConfig);
|
|
46
77
|
var getDomRef = function getDomRef(editorView) {
|
|
47
78
|
var domAtPos = editorView.domAtPos.bind(editorView);
|
|
48
79
|
var element = findDomRefAtPos(syncBlockObject.pos, domAtPos);
|
|
@@ -54,6 +85,6 @@ export var getToolbarConfig = function getToolbarConfig(state, _intl) {
|
|
|
54
85
|
nodeType: nodeType,
|
|
55
86
|
items: items,
|
|
56
87
|
scrollable: true,
|
|
57
|
-
groupLabel:
|
|
88
|
+
groupLabel: formatMessage(messages.syncBlockGroup)
|
|
58
89
|
};
|
|
59
90
|
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
3
4
|
export declare const createSyncedBlock: (state: EditorState) => Transaction;
|
|
4
|
-
export declare const copySyncedBlockReferenceToClipboard: Command;
|
|
5
|
+
export declare const copySyncedBlockReferenceToClipboard: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
6
|
+
export declare const editSyncedBlockSource: (_api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
7
|
+
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
@@ -2,6 +2,8 @@ import type { DocNode } from '@atlaskit/adf-schema';
|
|
|
2
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
5
|
+
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
|
+
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
7
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
7
9
|
import type { SyncBlockDataProvider, SyncedBlockProvider } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -37,7 +39,7 @@ export type SyncedBlockPluginOptions = {
|
|
|
37
39
|
syncedBlockProvider?: SyncedBlockProvider;
|
|
38
40
|
};
|
|
39
41
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
40
|
-
dependencies: [SelectionPlugin];
|
|
42
|
+
dependencies: [SelectionPlugin, FloatingToolbarPlugin, DecorationsPlugin];
|
|
41
43
|
pluginConfiguration: SyncedBlockPluginOptions | undefined;
|
|
42
44
|
}>;
|
|
43
45
|
export type SyncBlockAttrs = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/
|
|
5
|
-
import type { SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
6
|
-
export declare const getToolbarConfig: (state: EditorState,
|
|
3
|
+
import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
6
|
+
export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, _options: SyncedBlockPluginOptions | undefined, _providerFactory: ProviderFactory, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { Command } from '@atlaskit/editor-common/types';
|
|
1
|
+
import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
2
|
import { type EditorState, type Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
|
|
3
4
|
export declare const createSyncedBlock: (state: EditorState) => Transaction;
|
|
4
|
-
export declare const copySyncedBlockReferenceToClipboard: Command;
|
|
5
|
+
export declare const copySyncedBlockReferenceToClipboard: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
6
|
+
export declare const editSyncedBlockSource: (_api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
7
|
+
export declare const removeSyncedBlock: (api?: ExtractInjectionAPI<SyncedBlockPlugin>) => Command;
|
|
@@ -2,6 +2,8 @@ import type { DocNode } from '@atlaskit/adf-schema';
|
|
|
2
2
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
3
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
5
|
+
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
6
|
+
import type { FloatingToolbarPlugin } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
7
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
6
8
|
import type { EditorView } from '@atlaskit/editor-prosemirror/dist/types/view';
|
|
7
9
|
import type { SyncBlockDataProvider, SyncedBlockProvider } from '@atlaskit/editor-synced-block-provider';
|
|
@@ -38,7 +40,9 @@ export type SyncedBlockPluginOptions = {
|
|
|
38
40
|
};
|
|
39
41
|
export type SyncedBlockPlugin = NextEditorPlugin<'syncedBlock', {
|
|
40
42
|
dependencies: [
|
|
41
|
-
SelectionPlugin
|
|
43
|
+
SelectionPlugin,
|
|
44
|
+
FloatingToolbarPlugin,
|
|
45
|
+
DecorationsPlugin
|
|
42
46
|
];
|
|
43
47
|
pluginConfiguration: SyncedBlockPluginOptions | undefined;
|
|
44
48
|
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
3
|
-
import type { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/
|
|
5
|
-
import type { SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
6
|
-
export declare const getToolbarConfig: (state: EditorState,
|
|
3
|
+
import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import type { SyncedBlockPlugin, SyncedBlockPluginOptions } from '../syncedBlockPluginType';
|
|
6
|
+
export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, _options: SyncedBlockPluginOptions | undefined, _providerFactory: ProviderFactory, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined) => FloatingToolbarConfig | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-synced-block",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "SyncedBlock plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -30,17 +30,19 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@atlaskit/adf-schema": "^51.2.0",
|
|
32
32
|
"@atlaskit/button": "23.4.9",
|
|
33
|
+
"@atlaskit/editor-plugin-decorations": "^6.1.0",
|
|
34
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^8.1.0",
|
|
33
35
|
"@atlaskit/editor-plugin-selection": "^6.0.0",
|
|
34
36
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
37
|
+
"@atlaskit/editor-shared-styles": "^3.6.0",
|
|
35
38
|
"@atlaskit/editor-synced-block-provider": "^0.1.0",
|
|
36
39
|
"@atlaskit/icon": "28.3.0",
|
|
37
40
|
"@atlaskit/modal-dialog": "^14.4.0",
|
|
38
41
|
"@babel/runtime": "^7.0.0",
|
|
39
|
-
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
40
|
-
"uuid": "^3.1.0"
|
|
42
|
+
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
|
-
"@atlaskit/editor-common": "^110.
|
|
45
|
+
"@atlaskit/editor-common": "^110.2.0",
|
|
44
46
|
"react": "^18.2.0"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|