@atlaskit/editor-plugin-floating-toolbar 0.7.29 → 0.9.0
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 +12 -0
- package/dist/cjs/plugin.js +19 -4
- package/dist/es2019/plugin.js +19 -4
- package/dist/esm/plugin.js +19 -4
- package/dist/types/types.d.ts +3 -1
- package/dist/types-ts4.5/types.d.ts +3 -1
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-floating-toolbar
|
|
2
2
|
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#68824](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68824) [`2ce43bd09627`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2ce43bd09627) - [ux] When editor is in view mode, only show "Comment" floating toolbar item
|
|
8
|
+
|
|
9
|
+
## 0.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#68277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68277) [`fe0abf4abc01`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fe0abf4abc01) - Enable the selection toolbar to work with live pages view mode
|
|
14
|
+
|
|
3
15
|
## 0.7.29
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -194,9 +194,10 @@ function ContentComponent(_ref5) {
|
|
|
194
194
|
providerFactory = _ref5.providerFactory,
|
|
195
195
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
196
196
|
var featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.sharedState.currentState()) || {};
|
|
197
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled']),
|
|
197
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode']),
|
|
198
198
|
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
199
|
-
editorDisabledState = _useSharedPluginState.editorDisabledState
|
|
199
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
200
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
200
201
|
var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
|
|
201
202
|
configWithNodeInfo = _ref6.configWithNodeInfo,
|
|
202
203
|
floatingToolbarData = _ref6.floatingToolbarData;
|
|
@@ -205,10 +206,10 @@ function ContentComponent(_ref5) {
|
|
|
205
206
|
}
|
|
206
207
|
var config = configWithNodeInfo.config,
|
|
207
208
|
node = configWithNodeInfo.node;
|
|
209
|
+
var items = config.items;
|
|
208
210
|
var title = config.title,
|
|
209
211
|
_config$getDomRef = config.getDomRef,
|
|
210
212
|
getDomRef = _config$getDomRef === void 0 ? getDomRefFromSelection : _config$getDomRef,
|
|
211
|
-
items = config.items,
|
|
212
213
|
_config$align = config.align,
|
|
213
214
|
align = _config$align === void 0 ? 'center' : _config$align,
|
|
214
215
|
_config$className = config.className,
|
|
@@ -232,9 +233,23 @@ function ContentComponent(_ref5) {
|
|
|
232
233
|
_config$mediaAssistiv = config.mediaAssistiveMessage,
|
|
233
234
|
mediaAssistiveMessage = _config$mediaAssistiv === void 0 ? '' : _config$mediaAssistiv;
|
|
234
235
|
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
235
|
-
|
|
236
|
+
var isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
|
|
237
|
+
var isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
238
|
+
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
236
239
|
return null;
|
|
237
240
|
}
|
|
241
|
+
|
|
242
|
+
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
243
|
+
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
244
|
+
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
245
|
+
var iterableItems = Array.isArray(items) ? items : [];
|
|
246
|
+
if (isInViewMode) {
|
|
247
|
+
// Typescript note: Not all toolbar item types have the `supportsViewMode` prop.
|
|
248
|
+
var toolbarItemViewModeProp = 'supportsViewMode';
|
|
249
|
+
items = iterableItems.filter(function (item) {
|
|
250
|
+
return toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp];
|
|
251
|
+
});
|
|
252
|
+
}
|
|
238
253
|
var customPositionCalculation;
|
|
239
254
|
var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
240
255
|
if (onPositionCalculated) {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -184,8 +184,9 @@ function ContentComponent({
|
|
|
184
184
|
const featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.sharedState.currentState()) || {};
|
|
185
185
|
const {
|
|
186
186
|
floatingToolbarState,
|
|
187
|
-
editorDisabledState
|
|
188
|
-
|
|
187
|
+
editorDisabledState,
|
|
188
|
+
editorViewModeState
|
|
189
|
+
} = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode']);
|
|
189
190
|
const {
|
|
190
191
|
configWithNodeInfo,
|
|
191
192
|
floatingToolbarData
|
|
@@ -197,10 +198,12 @@ function ContentComponent({
|
|
|
197
198
|
config,
|
|
198
199
|
node
|
|
199
200
|
} = configWithNodeInfo;
|
|
201
|
+
let {
|
|
202
|
+
items
|
|
203
|
+
} = config;
|
|
200
204
|
const {
|
|
201
205
|
title,
|
|
202
206
|
getDomRef = getDomRefFromSelection,
|
|
203
|
-
items,
|
|
204
207
|
align = 'center',
|
|
205
208
|
className = '',
|
|
206
209
|
height,
|
|
@@ -220,9 +223,21 @@ function ContentComponent({
|
|
|
220
223
|
mediaAssistiveMessage = ''
|
|
221
224
|
} = config;
|
|
222
225
|
const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
223
|
-
|
|
226
|
+
const isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
|
|
227
|
+
const isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
228
|
+
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
224
229
|
return null;
|
|
225
230
|
}
|
|
231
|
+
|
|
232
|
+
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
233
|
+
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
234
|
+
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
235
|
+
const iterableItems = Array.isArray(items) ? items : [];
|
|
236
|
+
if (isInViewMode) {
|
|
237
|
+
// Typescript note: Not all toolbar item types have the `supportsViewMode` prop.
|
|
238
|
+
const toolbarItemViewModeProp = 'supportsViewMode';
|
|
239
|
+
items = iterableItems.filter(item => toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp]);
|
|
240
|
+
}
|
|
226
241
|
let customPositionCalculation;
|
|
227
242
|
const toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
228
243
|
if (onPositionCalculated) {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -185,9 +185,10 @@ function ContentComponent(_ref5) {
|
|
|
185
185
|
providerFactory = _ref5.providerFactory,
|
|
186
186
|
dispatchAnalyticsEvent = _ref5.dispatchAnalyticsEvent;
|
|
187
187
|
var featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.sharedState.currentState()) || {};
|
|
188
|
-
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled']),
|
|
188
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled', 'editorViewMode']),
|
|
189
189
|
floatingToolbarState = _useSharedPluginState.floatingToolbarState,
|
|
190
|
-
editorDisabledState = _useSharedPluginState.editorDisabledState
|
|
190
|
+
editorDisabledState = _useSharedPluginState.editorDisabledState,
|
|
191
|
+
editorViewModeState = _useSharedPluginState.editorViewModeState;
|
|
191
192
|
var _ref6 = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {},
|
|
192
193
|
configWithNodeInfo = _ref6.configWithNodeInfo,
|
|
193
194
|
floatingToolbarData = _ref6.floatingToolbarData;
|
|
@@ -196,10 +197,10 @@ function ContentComponent(_ref5) {
|
|
|
196
197
|
}
|
|
197
198
|
var config = configWithNodeInfo.config,
|
|
198
199
|
node = configWithNodeInfo.node;
|
|
200
|
+
var items = config.items;
|
|
199
201
|
var title = config.title,
|
|
200
202
|
_config$getDomRef = config.getDomRef,
|
|
201
203
|
getDomRef = _config$getDomRef === void 0 ? getDomRefFromSelection : _config$getDomRef,
|
|
202
|
-
items = config.items,
|
|
203
204
|
_config$align = config.align,
|
|
204
205
|
align = _config$align === void 0 ? 'center' : _config$align,
|
|
205
206
|
_config$className = config.className,
|
|
@@ -223,9 +224,23 @@ function ContentComponent(_ref5) {
|
|
|
223
224
|
_config$mediaAssistiv = config.mediaAssistiveMessage,
|
|
224
225
|
mediaAssistiveMessage = _config$mediaAssistiv === void 0 ? '' : _config$mediaAssistiv;
|
|
225
226
|
var targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
226
|
-
|
|
227
|
+
var isEditorDisabled = editorDisabledState && editorDisabledState.editorDisabled;
|
|
228
|
+
var isInViewMode = (editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode) === 'view';
|
|
229
|
+
if (!targetRef || isEditorDisabled && !isInViewMode) {
|
|
227
230
|
return null;
|
|
228
231
|
}
|
|
232
|
+
|
|
233
|
+
// TODO: MODES-3950 Update this view mode specific logic once we refactor view mode.
|
|
234
|
+
// We should inverse the responsibility here: A blacklist for toolbar items in view mode, rather than this white list.
|
|
235
|
+
// Also consider moving this logic to the more specific toolbar plugins (media and selection).
|
|
236
|
+
var iterableItems = Array.isArray(items) ? items : [];
|
|
237
|
+
if (isInViewMode) {
|
|
238
|
+
// Typescript note: Not all toolbar item types have the `supportsViewMode` prop.
|
|
239
|
+
var toolbarItemViewModeProp = 'supportsViewMode';
|
|
240
|
+
items = iterableItems.filter(function (item) {
|
|
241
|
+
return toolbarItemViewModeProp in item && !!item[toolbarItemViewModeProp];
|
|
242
|
+
});
|
|
243
|
+
}
|
|
229
244
|
var customPositionCalculation;
|
|
230
245
|
var toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.copyButton) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.hoverDecoration);
|
|
231
246
|
if (onPositionCalculated) {
|
package/dist/types/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
|
3
3
|
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
4
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
6
|
+
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
6
7
|
import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
|
|
7
8
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
9
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -30,7 +31,8 @@ export type FloatingToolbarPlugin = NextEditorPlugin<'floatingToolbar', {
|
|
|
30
31
|
OptionalPlugin<ContextPanelPlugin>,
|
|
31
32
|
OptionalPlugin<ExtensionPlugin>,
|
|
32
33
|
CopyButtonPlugin,
|
|
33
|
-
EditorDisabledPlugin
|
|
34
|
+
EditorDisabledPlugin,
|
|
35
|
+
OptionalPlugin<EditorViewModePlugin>
|
|
34
36
|
];
|
|
35
37
|
actions: {
|
|
36
38
|
forceFocusSelector: ForceFocusSelector;
|
|
@@ -3,6 +3,7 @@ import type { ContextPanelPlugin } from '@atlaskit/editor-plugin-context-panel';
|
|
|
3
3
|
import type { CopyButtonPlugin } from '@atlaskit/editor-plugin-copy-button';
|
|
4
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
6
|
+
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
6
7
|
import type { ExtensionPlugin } from '@atlaskit/editor-plugin-extension';
|
|
7
8
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
9
|
import type { Node } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -30,7 +31,8 @@ export type FloatingToolbarPlugin = NextEditorPlugin<'floatingToolbar', {
|
|
|
30
31
|
OptionalPlugin<ContextPanelPlugin>,
|
|
31
32
|
OptionalPlugin<ExtensionPlugin>,
|
|
32
33
|
CopyButtonPlugin,
|
|
33
|
-
EditorDisabledPlugin
|
|
34
|
+
EditorDisabledPlugin,
|
|
35
|
+
OptionalPlugin<EditorViewModePlugin>
|
|
34
36
|
];
|
|
35
37
|
actions: {
|
|
36
38
|
forceFocusSelector: ForceFocusSelector;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-floating-toolbar",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Floating toolbar plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,15 +28,16 @@
|
|
|
28
28
|
"@atlaskit/adf-utils": "^19.0.0",
|
|
29
29
|
"@atlaskit/button": "^17.2.0",
|
|
30
30
|
"@atlaskit/checkbox": "^13.0.0",
|
|
31
|
-
"@atlaskit/editor-common": "^77.
|
|
31
|
+
"@atlaskit/editor-common": "^77.1.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.2",
|
|
33
33
|
"@atlaskit/editor-plugin-context-panel": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-copy-button": "^1.0.0",
|
|
35
35
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
36
36
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|
|
37
|
+
"@atlaskit/editor-plugin-editor-viewmode": "^0.1.0",
|
|
37
38
|
"@atlaskit/editor-plugin-extension": "^0.6.0",
|
|
38
39
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
39
|
-
"@atlaskit/editor-plugin-table": "^7.
|
|
40
|
+
"@atlaskit/editor-plugin-table": "^7.1.0",
|
|
40
41
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
41
42
|
"@atlaskit/emoji": "^67.6.0",
|
|
42
43
|
"@atlaskit/icon": "^22.0.0",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"@atlaskit/modal-dialog": "^12.10.0",
|
|
45
46
|
"@atlaskit/select": "^17.0.3",
|
|
46
47
|
"@atlaskit/theme": "^12.6.0",
|
|
47
|
-
"@atlaskit/tokens": "^1.
|
|
48
|
+
"@atlaskit/tokens": "^1.35.0",
|
|
48
49
|
"@atlaskit/tooltip": "^18.1.0",
|
|
49
50
|
"@babel/runtime": "^7.0.0",
|
|
50
51
|
"@emotion/react": "^11.7.1",
|