@atlaskit/editor-plugin-toolbar 2.1.1 → 2.1.4
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/afm-dev-agents/tsconfig.json +3 -0
- package/afm-jira/tsconfig.json +3 -0
- package/afm-passionfruit/tsconfig.json +3 -0
- package/afm-post-office/tsconfig.json +3 -0
- package/afm-rovo-extension/tsconfig.json +3 -0
- package/afm-townsquare/tsconfig.json +3 -0
- package/dist/cjs/toolbarPlugin.js +68 -5
- package/dist/cjs/ui/SelectionToolbar/index.js +17 -8
- package/dist/cjs/ui/toolbar-components.js +3 -1
- package/dist/es2019/toolbarPlugin.js +66 -5
- package/dist/es2019/ui/SelectionToolbar/index.js +17 -8
- package/dist/es2019/ui/toolbar-components.js +3 -1
- package/dist/esm/toolbarPlugin.js +68 -5
- package/dist/esm/ui/SelectionToolbar/index.js +17 -8
- package/dist/esm/ui/toolbar-components.js +3 -1
- package/dist/types/toolbarPlugin.d.ts +0 -3
- package/dist/types/toolbarPluginType.d.ts +14 -4
- package/dist/types-ts4.5/toolbarPlugin.d.ts +0 -3
- package/dist/types-ts4.5/toolbarPluginType.d.ts +14 -4
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-toolbar
|
|
2
2
|
|
|
3
|
+
## 2.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e24c73c66f022`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e24c73c66f022) -
|
|
8
|
+
[ux] ED-29268 [SoftServ] Toolbar doesn’t move with text when text alignment change
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 2.1.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`553afc302139b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/553afc302139b) -
|
|
16
|
+
Add analytic emitter component which fires an event when dropdowns are viewed
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
19
|
+
## 2.1.2
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`30aad83e7ded7`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/30aad83e7ded7) -
|
|
24
|
+
When editorViewMode is undefined, default to 'edit' as the plugin may not be present.
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 2.1.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/afm-cc/tsconfig.json
CHANGED
package/afm-jira/tsconfig.json
CHANGED
|
@@ -9,7 +9,10 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _bindEventListener = require("bind-event-listener");
|
|
11
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
14
|
var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
|
|
15
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
13
16
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
14
17
|
var _consts = require("./ui/consts");
|
|
15
18
|
var _SelectionToolbar = require("./ui/SelectionToolbar");
|
|
@@ -17,6 +20,51 @@ var _toolbarComponents = require("./ui/toolbar-components");
|
|
|
17
20
|
var _toolbar = require("./ui/utils/toolbar");
|
|
18
21
|
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; }
|
|
19
22
|
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; }
|
|
23
|
+
function getSelectedNode(editorState) {
|
|
24
|
+
var selection = editorState.selection;
|
|
25
|
+
if (selection instanceof _state.NodeSelection) {
|
|
26
|
+
return {
|
|
27
|
+
node: selection.node,
|
|
28
|
+
pos: selection.from,
|
|
29
|
+
nodeType: selection.node.type.name,
|
|
30
|
+
marks: selection.node.marks.map(function (mark) {
|
|
31
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
32
|
+
})
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
var nodes = editorState.schema.nodes;
|
|
36
|
+
var selectedNode = (0, _utils.findSelectedNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.codeBlock])(selection);
|
|
37
|
+
if (selectedNode) {
|
|
38
|
+
return {
|
|
39
|
+
node: selectedNode.node,
|
|
40
|
+
pos: selectedNode.pos,
|
|
41
|
+
nodeType: selectedNode.node.type.name,
|
|
42
|
+
marks: selectedNode.node.marks.map(function (mark) {
|
|
43
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
44
|
+
})
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
var parentNode = (0, _utils.findParentNodeOfType)([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.listItem, nodes.taskItem])(selection);
|
|
48
|
+
if (parentNode) {
|
|
49
|
+
return {
|
|
50
|
+
node: parentNode.node,
|
|
51
|
+
pos: parentNode.pos,
|
|
52
|
+
nodeType: parentNode.node.type.name,
|
|
53
|
+
marks: parentNode.node.marks.map(function (mark) {
|
|
54
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
55
|
+
})
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
var $pos = selection.$from;
|
|
59
|
+
return {
|
|
60
|
+
node: $pos.parent,
|
|
61
|
+
pos: $pos.pos,
|
|
62
|
+
nodeType: $pos.parent.type.name,
|
|
63
|
+
marks: $pos.marks().map(function (mark) {
|
|
64
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
}
|
|
20
68
|
var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
21
69
|
var api = _ref.api,
|
|
22
70
|
_ref$config = _ref.config,
|
|
@@ -57,16 +105,28 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
57
105
|
return new _safePlugin.SafePlugin({
|
|
58
106
|
key: _pluginKey.editorToolbarPluginKey,
|
|
59
107
|
state: {
|
|
60
|
-
init: function init() {
|
|
108
|
+
init: function init(_, editorState) {
|
|
61
109
|
return {
|
|
62
|
-
shouldShowToolbar: false
|
|
110
|
+
shouldShowToolbar: false,
|
|
111
|
+
selectedNode: getSelectedNode(editorState)
|
|
63
112
|
};
|
|
64
113
|
},
|
|
65
|
-
apply: function apply(tr, pluginState) {
|
|
114
|
+
apply: function apply(tr, pluginState, _, newState) {
|
|
66
115
|
var meta = tr.getMeta(_pluginKey.editorToolbarPluginKey);
|
|
67
|
-
var newPluginState = pluginState;
|
|
116
|
+
var newPluginState = _objectSpread({}, pluginState);
|
|
117
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true)) {
|
|
118
|
+
var shouldUpdateNode = tr.docChanged || tr.selectionSet;
|
|
119
|
+
if (shouldUpdateNode) {
|
|
120
|
+
var newSelectedNode = getSelectedNode(newState);
|
|
121
|
+
var oldNode = pluginState.selectedNode;
|
|
122
|
+
var hasNodeChanged = !oldNode || !newSelectedNode || oldNode.nodeType !== newSelectedNode.nodeType || oldNode.pos !== newSelectedNode.pos || JSON.stringify(oldNode.marks) !== JSON.stringify(newSelectedNode.marks);
|
|
123
|
+
if (hasNodeChanged) {
|
|
124
|
+
newPluginState.selectedNode = newSelectedNode;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
68
128
|
if (meta) {
|
|
69
|
-
|
|
129
|
+
newPluginState = _objectSpread(_objectSpread({}, newPluginState), meta);
|
|
70
130
|
}
|
|
71
131
|
return newPluginState;
|
|
72
132
|
}
|
|
@@ -122,6 +182,9 @@ var toolbarPlugin = exports.toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
122
182
|
contentComponent: !disableSelectionToolbar ? function (_ref2) {
|
|
123
183
|
var editorView = _ref2.editorView,
|
|
124
184
|
popupsMountPoint = _ref2.popupsMountPoint;
|
|
185
|
+
if (!editorView) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
125
188
|
return /*#__PURE__*/_react.default.createElement(_SelectionToolbar.SelectionToolbar, {
|
|
126
189
|
api: api,
|
|
127
190
|
editorView: editorView,
|
|
@@ -28,11 +28,12 @@ var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(fun
|
|
|
28
28
|
return (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
29
29
|
}, function (api) {
|
|
30
30
|
return (0, _hooks.useSharedPluginStateWithSelector)(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], function (state) {
|
|
31
|
-
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
31
|
+
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$toolbarState2, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
32
32
|
return {
|
|
33
33
|
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
34
34
|
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 || (_state$userPreference = _state$userPreference.preferences) === null || _state$userPreference === void 0 ? void 0 : _state$userPreference.toolbarDockingPosition,
|
|
35
35
|
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
36
|
+
selectedNode: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.selectedNode,
|
|
36
37
|
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
37
38
|
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
38
39
|
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
@@ -44,19 +45,22 @@ var usePluginState = (0, _platformFeatureFlagsReact.conditionalHooksFactory)(fun
|
|
|
44
45
|
var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userIntent.currentUserIntent');
|
|
45
46
|
var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
|
|
46
47
|
var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['toolbar'], function (state) {
|
|
47
|
-
var _state$
|
|
48
|
+
var _state$toolbarState3, _state$toolbarState4;
|
|
48
49
|
return {
|
|
49
|
-
shouldShowToolbar: (_state$
|
|
50
|
+
shouldShowToolbar: (_state$toolbarState3 = state.toolbarState) === null || _state$toolbarState3 === void 0 ? void 0 : _state$toolbarState3.shouldShowToolbar,
|
|
51
|
+
selectedNode: (_state$toolbarState4 = state.toolbarState) === null || _state$toolbarState4 === void 0 ? void 0 : _state$toolbarState4.selectedNode
|
|
50
52
|
};
|
|
51
53
|
}),
|
|
52
|
-
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar
|
|
54
|
+
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar,
|
|
55
|
+
selectedNode = _useSharedPluginState.selectedNode;
|
|
53
56
|
return {
|
|
54
57
|
connectivityStateMode: connectivityStateMode,
|
|
55
58
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
56
59
|
currentUserIntent: currentUserIntent,
|
|
57
60
|
shouldShowToolbar: shouldShowToolbar,
|
|
58
61
|
selection: selection,
|
|
59
|
-
editorViewMode: undefined
|
|
62
|
+
editorViewMode: undefined,
|
|
63
|
+
selectedNode: selectedNode
|
|
60
64
|
};
|
|
61
65
|
});
|
|
62
66
|
var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref) {
|
|
@@ -89,8 +93,7 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
89
93
|
if (isCellSelection && isEditorControlsEnabled) {
|
|
90
94
|
return (0, _utils.calculateToolbarPositionOnCellSelection)(toolbarTitle)(editorView, position);
|
|
91
95
|
}
|
|
92
|
-
|
|
93
|
-
return calc(toolbarTitle)(editorView, position);
|
|
96
|
+
return (0, _utils.calculateToolbarPositionTrackHead)(toolbarTitle)(editorView, position);
|
|
94
97
|
}, [editorView]);
|
|
95
98
|
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
96
99
|
return null;
|
|
@@ -106,10 +109,16 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
|
|
|
106
109
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
|
|
107
110
|
editorView: editorView,
|
|
108
111
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
109
|
-
editorViewMode: editorViewMode
|
|
112
|
+
editorViewMode: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit' : editorViewMode
|
|
110
113
|
}, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarUIProvider, {
|
|
111
114
|
api: api,
|
|
112
115
|
isDisabled: isOffline
|
|
116
|
+
// supress type checks for now
|
|
117
|
+
,
|
|
118
|
+
fireAnalyticsEvent: (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? function (payload) {
|
|
119
|
+
var _api$analytics;
|
|
120
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent(payload);
|
|
121
|
+
} : undefined
|
|
113
122
|
}, /*#__PURE__*/_react.default.createElement(_editorToolbarModel.ToolbarModelRenderer, {
|
|
114
123
|
toolbar: toolbar,
|
|
115
124
|
components: components,
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getToolbarComponents = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
11
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
13
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
@@ -23,7 +24,8 @@ var getToolbarComponents = exports.getToolbarComponents = function getToolbarCom
|
|
|
23
24
|
component: function component(_ref) {
|
|
24
25
|
var children = _ref.children;
|
|
25
26
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.Toolbar, {
|
|
26
|
-
label: _consts.SELECTION_TOOLBAR_LABEL
|
|
27
|
+
label: _consts.SELECTION_TOOLBAR_LABEL,
|
|
28
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.SELECTION_TOOLBAR
|
|
27
29
|
}, children);
|
|
28
30
|
}
|
|
29
31
|
}, {
|
|
@@ -1,12 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { bind } from 'bind-event-listener';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import { findSelectedNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
4
6
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
7
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
5
8
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
6
9
|
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
7
10
|
import { SelectionToolbar } from './ui/SelectionToolbar';
|
|
8
11
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
9
12
|
import { isEventInContainer } from './ui/utils/toolbar';
|
|
13
|
+
function getSelectedNode(editorState) {
|
|
14
|
+
const {
|
|
15
|
+
selection
|
|
16
|
+
} = editorState;
|
|
17
|
+
if (selection instanceof NodeSelection) {
|
|
18
|
+
return {
|
|
19
|
+
node: selection.node,
|
|
20
|
+
pos: selection.from,
|
|
21
|
+
nodeType: selection.node.type.name,
|
|
22
|
+
marks: selection.node.marks.map(mark => `${mark.type.name}:${JSON.stringify(mark.attrs)}`)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
nodes
|
|
27
|
+
} = editorState.schema;
|
|
28
|
+
const selectedNode = findSelectedNodeOfType([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.codeBlock])(selection);
|
|
29
|
+
if (selectedNode) {
|
|
30
|
+
return {
|
|
31
|
+
node: selectedNode.node,
|
|
32
|
+
pos: selectedNode.pos,
|
|
33
|
+
nodeType: selectedNode.node.type.name,
|
|
34
|
+
marks: selectedNode.node.marks.map(mark => `${mark.type.name}:${JSON.stringify(mark.attrs)}`)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
const parentNode = findParentNodeOfType([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.listItem, nodes.taskItem])(selection);
|
|
38
|
+
if (parentNode) {
|
|
39
|
+
return {
|
|
40
|
+
node: parentNode.node,
|
|
41
|
+
pos: parentNode.pos,
|
|
42
|
+
nodeType: parentNode.node.type.name,
|
|
43
|
+
marks: parentNode.node.marks.map(mark => `${mark.type.name}:${JSON.stringify(mark.attrs)}`)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const $pos = selection.$from;
|
|
47
|
+
return {
|
|
48
|
+
node: $pos.parent,
|
|
49
|
+
pos: $pos.pos,
|
|
50
|
+
nodeType: $pos.parent.type.name,
|
|
51
|
+
marks: $pos.marks().map(mark => `${mark.type.name}:${JSON.stringify(mark.attrs)}`)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
10
54
|
export const toolbarPlugin = ({
|
|
11
55
|
api,
|
|
12
56
|
config = {
|
|
@@ -48,16 +92,30 @@ export const toolbarPlugin = ({
|
|
|
48
92
|
return new SafePlugin({
|
|
49
93
|
key: editorToolbarPluginKey,
|
|
50
94
|
state: {
|
|
51
|
-
init() {
|
|
95
|
+
init(_, editorState) {
|
|
52
96
|
return {
|
|
53
|
-
shouldShowToolbar: false
|
|
97
|
+
shouldShowToolbar: false,
|
|
98
|
+
selectedNode: getSelectedNode(editorState)
|
|
54
99
|
};
|
|
55
100
|
},
|
|
56
|
-
apply(tr, pluginState) {
|
|
101
|
+
apply(tr, pluginState, _, newState) {
|
|
57
102
|
const meta = tr.getMeta(editorToolbarPluginKey);
|
|
58
|
-
|
|
103
|
+
let newPluginState = {
|
|
104
|
+
...pluginState
|
|
105
|
+
};
|
|
106
|
+
if (expValEquals('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true)) {
|
|
107
|
+
const shouldUpdateNode = tr.docChanged || tr.selectionSet;
|
|
108
|
+
if (shouldUpdateNode) {
|
|
109
|
+
const newSelectedNode = getSelectedNode(newState);
|
|
110
|
+
const oldNode = pluginState.selectedNode;
|
|
111
|
+
const hasNodeChanged = !oldNode || !newSelectedNode || oldNode.nodeType !== newSelectedNode.nodeType || oldNode.pos !== newSelectedNode.pos || JSON.stringify(oldNode.marks) !== JSON.stringify(newSelectedNode.marks);
|
|
112
|
+
if (hasNodeChanged) {
|
|
113
|
+
newPluginState.selectedNode = newSelectedNode;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
59
117
|
if (meta) {
|
|
60
|
-
|
|
118
|
+
newPluginState = {
|
|
61
119
|
...newPluginState,
|
|
62
120
|
...meta
|
|
63
121
|
};
|
|
@@ -117,6 +175,9 @@ export const toolbarPlugin = ({
|
|
|
117
175
|
editorView,
|
|
118
176
|
popupsMountPoint
|
|
119
177
|
}) => {
|
|
178
|
+
if (!editorView) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
120
181
|
return /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
121
182
|
api: api,
|
|
122
183
|
editorView: editorView,
|
|
@@ -18,11 +18,12 @@ const isToolbarComponent = component => {
|
|
|
18
18
|
};
|
|
19
19
|
const usePluginState = conditionalHooksFactory(() => expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true), api => {
|
|
20
20
|
return useSharedPluginStateWithSelector(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], state => {
|
|
21
|
-
var _state$connectivitySt, _state$userPreference, _state$userPreference2, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
21
|
+
var _state$connectivitySt, _state$userPreference, _state$userPreference2, _state$toolbarState, _state$toolbarState2, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
22
22
|
return {
|
|
23
23
|
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
24
24
|
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 ? void 0 : (_state$userPreference2 = _state$userPreference.preferences) === null || _state$userPreference2 === void 0 ? void 0 : _state$userPreference2.toolbarDockingPosition,
|
|
25
25
|
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
26
|
+
selectedNode: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.selectedNode,
|
|
26
27
|
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
27
28
|
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
28
29
|
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
@@ -34,11 +35,13 @@ const usePluginState = conditionalHooksFactory(() => expValEquals('platform_edit
|
|
|
34
35
|
const currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
35
36
|
const selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
36
37
|
const {
|
|
37
|
-
shouldShowToolbar
|
|
38
|
+
shouldShowToolbar,
|
|
39
|
+
selectedNode
|
|
38
40
|
} = useSharedPluginStateWithSelector(api, ['toolbar'], state => {
|
|
39
|
-
var _state$
|
|
41
|
+
var _state$toolbarState3, _state$toolbarState4;
|
|
40
42
|
return {
|
|
41
|
-
shouldShowToolbar: (_state$
|
|
43
|
+
shouldShowToolbar: (_state$toolbarState3 = state.toolbarState) === null || _state$toolbarState3 === void 0 ? void 0 : _state$toolbarState3.shouldShowToolbar,
|
|
44
|
+
selectedNode: (_state$toolbarState4 = state.toolbarState) === null || _state$toolbarState4 === void 0 ? void 0 : _state$toolbarState4.selectedNode
|
|
42
45
|
};
|
|
43
46
|
});
|
|
44
47
|
return {
|
|
@@ -47,7 +50,8 @@ const usePluginState = conditionalHooksFactory(() => expValEquals('platform_edit
|
|
|
47
50
|
currentUserIntent,
|
|
48
51
|
shouldShowToolbar,
|
|
49
52
|
selection,
|
|
50
|
-
editorViewMode: undefined
|
|
53
|
+
editorViewMode: undefined,
|
|
54
|
+
selectedNode
|
|
51
55
|
};
|
|
52
56
|
});
|
|
53
57
|
export const SelectionToolbar = ({
|
|
@@ -81,8 +85,7 @@ export const SelectionToolbar = ({
|
|
|
81
85
|
if (isCellSelection && isEditorControlsEnabled) {
|
|
82
86
|
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
83
87
|
}
|
|
84
|
-
|
|
85
|
-
return calc(toolbarTitle)(editorView, position);
|
|
88
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
86
89
|
}, [editorView]);
|
|
87
90
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
88
91
|
return null;
|
|
@@ -98,10 +101,16 @@ export const SelectionToolbar = ({
|
|
|
98
101
|
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
99
102
|
editorView: editorView,
|
|
100
103
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
101
|
-
editorViewMode: editorViewMode
|
|
104
|
+
editorViewMode: expValEquals('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit' : editorViewMode
|
|
102
105
|
}, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
|
|
103
106
|
api: api,
|
|
104
107
|
isDisabled: isOffline
|
|
108
|
+
// supress type checks for now
|
|
109
|
+
,
|
|
110
|
+
fireAnalyticsEvent: expValEquals('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? payload => {
|
|
111
|
+
var _api$analytics;
|
|
112
|
+
api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.fireAnalyticsEvent(payload);
|
|
113
|
+
} : undefined
|
|
105
114
|
}, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
|
|
106
115
|
toolbar: toolbar,
|
|
107
116
|
components: components,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { INSERT_BLOCK_SECTION, LINKING_SECTION, OVERFLOW_GROUP, OVERFLOW_GROUP_PRIMARY_TOOLBAR, OVERFLOW_GROUP_PRIMARY_TOOLBAR_RANK, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_MENU_PRIMARY_TOOLBAR, OVERFLOW_SECTION, OVERFLOW_SECTION_PRIMARY_TOOLBAR, OVERFLOW_SECTION_PRIMARY_TOOLBAR_RANK, OVERFLOW_SECTION_RANK, PIN_SECTION, TEXT_COLLAPSED_GROUP, TEXT_SECTION, TEXT_SECTION_COLLAPSED, TEXT_COLLAPSED_MENU, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
3
4
|
import { PrimaryToolbar as PrimaryToolbarBase, Show, Toolbar } from '@atlaskit/editor-toolbar';
|
|
4
5
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -16,7 +17,8 @@ export const getToolbarComponents = (api, disableSelectionToolbar) => {
|
|
|
16
17
|
children
|
|
17
18
|
}) => {
|
|
18
19
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
19
|
-
label: SELECTION_TOOLBAR_LABEL
|
|
20
|
+
label: SELECTION_TOOLBAR_LABEL,
|
|
21
|
+
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR
|
|
20
22
|
}, children);
|
|
21
23
|
}
|
|
22
24
|
}, {
|
|
@@ -4,12 +4,60 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { bind } from 'bind-event-listener';
|
|
6
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import { findSelectedNodeOfType, findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
7
9
|
import { createComponentRegistry } from '@atlaskit/editor-toolbar-model';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
8
11
|
import { editorToolbarPluginKey } from './pm-plugins/plugin-key';
|
|
9
12
|
import { DEFAULT_POPUP_SELECTORS } from './ui/consts';
|
|
10
13
|
import { SelectionToolbar } from './ui/SelectionToolbar';
|
|
11
14
|
import { getToolbarComponents } from './ui/toolbar-components';
|
|
12
15
|
import { isEventInContainer } from './ui/utils/toolbar';
|
|
16
|
+
function getSelectedNode(editorState) {
|
|
17
|
+
var selection = editorState.selection;
|
|
18
|
+
if (selection instanceof NodeSelection) {
|
|
19
|
+
return {
|
|
20
|
+
node: selection.node,
|
|
21
|
+
pos: selection.from,
|
|
22
|
+
nodeType: selection.node.type.name,
|
|
23
|
+
marks: selection.node.marks.map(function (mark) {
|
|
24
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
var nodes = editorState.schema.nodes;
|
|
29
|
+
var selectedNode = findSelectedNodeOfType([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.codeBlock])(selection);
|
|
30
|
+
if (selectedNode) {
|
|
31
|
+
return {
|
|
32
|
+
node: selectedNode.node,
|
|
33
|
+
pos: selectedNode.pos,
|
|
34
|
+
nodeType: selectedNode.node.type.name,
|
|
35
|
+
marks: selectedNode.node.marks.map(function (mark) {
|
|
36
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
37
|
+
})
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
var parentNode = findParentNodeOfType([nodes.paragraph, nodes.heading, nodes.blockquote, nodes.panel, nodes.listItem, nodes.taskItem])(selection);
|
|
41
|
+
if (parentNode) {
|
|
42
|
+
return {
|
|
43
|
+
node: parentNode.node,
|
|
44
|
+
pos: parentNode.pos,
|
|
45
|
+
nodeType: parentNode.node.type.name,
|
|
46
|
+
marks: parentNode.node.marks.map(function (mark) {
|
|
47
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
48
|
+
})
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
var $pos = selection.$from;
|
|
52
|
+
return {
|
|
53
|
+
node: $pos.parent,
|
|
54
|
+
pos: $pos.pos,
|
|
55
|
+
nodeType: $pos.parent.type.name,
|
|
56
|
+
marks: $pos.marks().map(function (mark) {
|
|
57
|
+
return "".concat(mark.type.name, ":").concat(JSON.stringify(mark.attrs));
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
}
|
|
13
61
|
export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
14
62
|
var api = _ref.api,
|
|
15
63
|
_ref$config = _ref.config,
|
|
@@ -50,16 +98,28 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
50
98
|
return new SafePlugin({
|
|
51
99
|
key: editorToolbarPluginKey,
|
|
52
100
|
state: {
|
|
53
|
-
init: function init() {
|
|
101
|
+
init: function init(_, editorState) {
|
|
54
102
|
return {
|
|
55
|
-
shouldShowToolbar: false
|
|
103
|
+
shouldShowToolbar: false,
|
|
104
|
+
selectedNode: getSelectedNode(editorState)
|
|
56
105
|
};
|
|
57
106
|
},
|
|
58
|
-
apply: function apply(tr, pluginState) {
|
|
107
|
+
apply: function apply(tr, pluginState, _, newState) {
|
|
59
108
|
var meta = tr.getMeta(editorToolbarPluginKey);
|
|
60
|
-
var newPluginState = pluginState;
|
|
109
|
+
var newPluginState = _objectSpread({}, pluginState);
|
|
110
|
+
if (expValEquals('platform_editor_toolbar_aifc_patch_5', 'isEnabled', true)) {
|
|
111
|
+
var shouldUpdateNode = tr.docChanged || tr.selectionSet;
|
|
112
|
+
if (shouldUpdateNode) {
|
|
113
|
+
var newSelectedNode = getSelectedNode(newState);
|
|
114
|
+
var oldNode = pluginState.selectedNode;
|
|
115
|
+
var hasNodeChanged = !oldNode || !newSelectedNode || oldNode.nodeType !== newSelectedNode.nodeType || oldNode.pos !== newSelectedNode.pos || JSON.stringify(oldNode.marks) !== JSON.stringify(newSelectedNode.marks);
|
|
116
|
+
if (hasNodeChanged) {
|
|
117
|
+
newPluginState.selectedNode = newSelectedNode;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
61
121
|
if (meta) {
|
|
62
|
-
|
|
122
|
+
newPluginState = _objectSpread(_objectSpread({}, newPluginState), meta);
|
|
63
123
|
}
|
|
64
124
|
return newPluginState;
|
|
65
125
|
}
|
|
@@ -115,6 +175,9 @@ export var toolbarPlugin = function toolbarPlugin(_ref) {
|
|
|
115
175
|
contentComponent: !disableSelectionToolbar ? function (_ref2) {
|
|
116
176
|
var editorView = _ref2.editorView,
|
|
117
177
|
popupsMountPoint = _ref2.popupsMountPoint;
|
|
178
|
+
if (!editorView) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
118
181
|
return /*#__PURE__*/React.createElement(SelectionToolbar, {
|
|
119
182
|
api: api,
|
|
120
183
|
editorView: editorView,
|
|
@@ -20,11 +20,12 @@ var usePluginState = conditionalHooksFactory(function () {
|
|
|
20
20
|
return expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true);
|
|
21
21
|
}, function (api) {
|
|
22
22
|
return useSharedPluginStateWithSelector(api, ['connectivity', 'userPreferences', 'toolbar', 'selection', 'userIntent', 'editorViewMode'], function (state) {
|
|
23
|
-
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
23
|
+
var _state$connectivitySt, _state$userPreference, _state$toolbarState, _state$toolbarState2, _state$selectionState, _state$userIntentStat, _state$editorViewMode;
|
|
24
24
|
return {
|
|
25
25
|
connectivityStateMode: (_state$connectivitySt = state.connectivityState) === null || _state$connectivitySt === void 0 ? void 0 : _state$connectivitySt.mode,
|
|
26
26
|
editorToolbarDockingPreference: (_state$userPreference = state.userPreferencesState) === null || _state$userPreference === void 0 || (_state$userPreference = _state$userPreference.preferences) === null || _state$userPreference === void 0 ? void 0 : _state$userPreference.toolbarDockingPosition,
|
|
27
27
|
shouldShowToolbar: (_state$toolbarState = state.toolbarState) === null || _state$toolbarState === void 0 ? void 0 : _state$toolbarState.shouldShowToolbar,
|
|
28
|
+
selectedNode: (_state$toolbarState2 = state.toolbarState) === null || _state$toolbarState2 === void 0 ? void 0 : _state$toolbarState2.selectedNode,
|
|
28
29
|
selection: (_state$selectionState = state.selectionState) === null || _state$selectionState === void 0 ? void 0 : _state$selectionState.selection,
|
|
29
30
|
currentUserIntent: (_state$userIntentStat = state.userIntentState) === null || _state$userIntentStat === void 0 ? void 0 : _state$userIntentStat.currentUserIntent,
|
|
30
31
|
editorViewMode: (_state$editorViewMode = state.editorViewModeState) === null || _state$editorViewMode === void 0 ? void 0 : _state$editorViewMode.mode
|
|
@@ -36,19 +37,22 @@ var usePluginState = conditionalHooksFactory(function () {
|
|
|
36
37
|
var currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
|
|
37
38
|
var selection = useSharedPluginStateSelector(api, 'selection.selection');
|
|
38
39
|
var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['toolbar'], function (state) {
|
|
39
|
-
var _state$
|
|
40
|
+
var _state$toolbarState3, _state$toolbarState4;
|
|
40
41
|
return {
|
|
41
|
-
shouldShowToolbar: (_state$
|
|
42
|
+
shouldShowToolbar: (_state$toolbarState3 = state.toolbarState) === null || _state$toolbarState3 === void 0 ? void 0 : _state$toolbarState3.shouldShowToolbar,
|
|
43
|
+
selectedNode: (_state$toolbarState4 = state.toolbarState) === null || _state$toolbarState4 === void 0 ? void 0 : _state$toolbarState4.selectedNode
|
|
42
44
|
};
|
|
43
45
|
}),
|
|
44
|
-
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar
|
|
46
|
+
shouldShowToolbar = _useSharedPluginState.shouldShowToolbar,
|
|
47
|
+
selectedNode = _useSharedPluginState.selectedNode;
|
|
45
48
|
return {
|
|
46
49
|
connectivityStateMode: connectivityStateMode,
|
|
47
50
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
48
51
|
currentUserIntent: currentUserIntent,
|
|
49
52
|
shouldShowToolbar: shouldShowToolbar,
|
|
50
53
|
selection: selection,
|
|
51
|
-
editorViewMode: undefined
|
|
54
|
+
editorViewMode: undefined,
|
|
55
|
+
selectedNode: selectedNode
|
|
52
56
|
};
|
|
53
57
|
});
|
|
54
58
|
export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
@@ -81,8 +85,7 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
81
85
|
if (isCellSelection && isEditorControlsEnabled) {
|
|
82
86
|
return calculateToolbarPositionOnCellSelection(toolbarTitle)(editorView, position);
|
|
83
87
|
}
|
|
84
|
-
|
|
85
|
-
return calc(toolbarTitle)(editorView, position);
|
|
88
|
+
return calculateToolbarPositionTrackHead(toolbarTitle)(editorView, position);
|
|
86
89
|
}, [editorView]);
|
|
87
90
|
if (expValEquals('platform_editor_toolbar_aifc_template_editor', 'isEnabled', true) && editorToolbarDockingPreference === 'top' && disableSelectionToolbarWhenPinned || !components || !toolbar) {
|
|
88
91
|
return null;
|
|
@@ -98,10 +101,16 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
|
|
|
98
101
|
}, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
|
|
99
102
|
editorView: editorView,
|
|
100
103
|
editorToolbarDockingPreference: editorToolbarDockingPreference,
|
|
101
|
-
editorViewMode: editorViewMode
|
|
104
|
+
editorViewMode: expValEquals('platform_editor_toolbar_aifc_patch_4', 'isEnabled', true) ? editorViewMode !== null && editorViewMode !== void 0 ? editorViewMode : 'edit' : editorViewMode
|
|
102
105
|
}, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
|
|
103
106
|
api: api,
|
|
104
107
|
isDisabled: isOffline
|
|
108
|
+
// supress type checks for now
|
|
109
|
+
,
|
|
110
|
+
fireAnalyticsEvent: expValEquals('platform_editor_toolbar_aifc_toolbar_analytic', 'isEnabled', true) ? function (payload) {
|
|
111
|
+
var _api$analytics;
|
|
112
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.fireAnalyticsEvent(payload);
|
|
113
|
+
} : undefined
|
|
105
114
|
}, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
|
|
106
115
|
toolbar: toolbar,
|
|
107
116
|
components: components,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
3
4
|
import { INSERT_BLOCK_SECTION, LINKING_SECTION, OVERFLOW_GROUP, OVERFLOW_GROUP_PRIMARY_TOOLBAR, OVERFLOW_GROUP_PRIMARY_TOOLBAR_RANK, OVERFLOW_GROUP_RANK, OVERFLOW_MENU, OVERFLOW_MENU_PRIMARY_TOOLBAR, OVERFLOW_SECTION, OVERFLOW_SECTION_PRIMARY_TOOLBAR, OVERFLOW_SECTION_PRIMARY_TOOLBAR_RANK, OVERFLOW_SECTION_RANK, PIN_SECTION, TEXT_COLLAPSED_GROUP, TEXT_SECTION, TEXT_SECTION_COLLAPSED, TEXT_COLLAPSED_MENU, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
4
5
|
import { PrimaryToolbar as PrimaryToolbarBase, Show, Toolbar } from '@atlaskit/editor-toolbar';
|
|
5
6
|
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
@@ -16,7 +17,8 @@ export var getToolbarComponents = function getToolbarComponents(api, disableSele
|
|
|
16
17
|
component: function component(_ref) {
|
|
17
18
|
var children = _ref.children;
|
|
18
19
|
return /*#__PURE__*/React.createElement(Toolbar, {
|
|
19
|
-
label: SELECTION_TOOLBAR_LABEL
|
|
20
|
+
label: SELECTION_TOOLBAR_LABEL,
|
|
21
|
+
actionSubjectId: ACTION_SUBJECT_ID.SELECTION_TOOLBAR
|
|
20
22
|
}, children);
|
|
21
23
|
}
|
|
22
24
|
}, {
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
2
3
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
3
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
4
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
5
6
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
6
7
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
9
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
8
10
|
import type { RegisterComponentsAction, ToolbarPluginOptions } from './types';
|
|
11
|
+
export type EditorToolbarPluginState = {
|
|
12
|
+
selectedNode?: {
|
|
13
|
+
marks: string[];
|
|
14
|
+
node: PMNode;
|
|
15
|
+
nodeType: string;
|
|
16
|
+
pos: number;
|
|
17
|
+
};
|
|
18
|
+
shouldShowToolbar: boolean;
|
|
19
|
+
};
|
|
9
20
|
export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
10
21
|
actions: {
|
|
11
22
|
getComponents: () => Array<RegisterComponent>;
|
|
@@ -16,10 +27,9 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
|
16
27
|
OptionalPlugin<SelectionPlugin>,
|
|
17
28
|
OptionalPlugin<UserPreferencesPlugin>,
|
|
18
29
|
OptionalPlugin<EditorViewModePlugin>,
|
|
19
|
-
OptionalPlugin<ConnectivityPlugin
|
|
30
|
+
OptionalPlugin<ConnectivityPlugin>,
|
|
31
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
20
32
|
];
|
|
21
33
|
pluginConfiguration?: ToolbarPluginOptions;
|
|
22
|
-
sharedState:
|
|
23
|
-
shouldShowToolbar: boolean;
|
|
24
|
-
};
|
|
34
|
+
sharedState: EditorToolbarPluginState;
|
|
25
35
|
}>;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
2
3
|
import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
3
4
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
4
5
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
5
6
|
import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
|
|
6
7
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
8
|
+
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
7
9
|
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
8
10
|
import type { RegisterComponentsAction, ToolbarPluginOptions } from './types';
|
|
11
|
+
export type EditorToolbarPluginState = {
|
|
12
|
+
selectedNode?: {
|
|
13
|
+
marks: string[];
|
|
14
|
+
node: PMNode;
|
|
15
|
+
nodeType: string;
|
|
16
|
+
pos: number;
|
|
17
|
+
};
|
|
18
|
+
shouldShowToolbar: boolean;
|
|
19
|
+
};
|
|
9
20
|
export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
10
21
|
actions: {
|
|
11
22
|
getComponents: () => Array<RegisterComponent>;
|
|
@@ -16,10 +27,9 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
|
|
|
16
27
|
OptionalPlugin<SelectionPlugin>,
|
|
17
28
|
OptionalPlugin<UserPreferencesPlugin>,
|
|
18
29
|
OptionalPlugin<EditorViewModePlugin>,
|
|
19
|
-
OptionalPlugin<ConnectivityPlugin
|
|
30
|
+
OptionalPlugin<ConnectivityPlugin>,
|
|
31
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
20
32
|
];
|
|
21
33
|
pluginConfiguration?: ToolbarPluginOptions;
|
|
22
|
-
sharedState:
|
|
23
|
-
shouldShowToolbar: boolean;
|
|
24
|
-
};
|
|
34
|
+
sharedState: EditorToolbarPluginState;
|
|
25
35
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-toolbar",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,22 +28,23 @@
|
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"atlaskit:src": "src/index.ts",
|
|
30
30
|
"dependencies": {
|
|
31
|
+
"@atlaskit/editor-plugin-analytics": "^5.2.0",
|
|
31
32
|
"@atlaskit/editor-plugin-connectivity": "^5.0.0",
|
|
32
33
|
"@atlaskit/editor-plugin-editor-viewmode": "^7.0.0",
|
|
33
34
|
"@atlaskit/editor-plugin-selection": "^5.0.0",
|
|
34
35
|
"@atlaskit/editor-plugin-user-intent": "^3.0.0",
|
|
35
36
|
"@atlaskit/editor-plugin-user-preferences": "^3.0.0",
|
|
36
37
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
37
|
-
"@atlaskit/editor-toolbar": "^0.
|
|
38
|
+
"@atlaskit/editor-toolbar": "^0.9.0",
|
|
38
39
|
"@atlaskit/editor-toolbar-model": "^0.2.0",
|
|
39
40
|
"@atlaskit/platform-feature-flags-react": "^0.3.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
41
|
+
"@atlaskit/tmp-editor-statsig": "^12.24.0",
|
|
41
42
|
"@babel/runtime": "^7.0.0",
|
|
42
43
|
"bind-event-listener": "^3.0.0",
|
|
43
44
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
44
45
|
},
|
|
45
46
|
"peerDependencies": {
|
|
46
|
-
"@atlaskit/editor-common": "^109.
|
|
47
|
+
"@atlaskit/editor-common": "^109.8.0",
|
|
47
48
|
"react": "^18.2.0"
|
|
48
49
|
},
|
|
49
50
|
"techstack": {
|