@atlaskit/editor-core 187.48.7 → 188.0.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 +92 -0
- package/dist/cjs/index.js +3 -305
- package/dist/cjs/labs/next/presets/default.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/index.js +16 -45
- package/dist/es2019/labs/next/presets/default.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/index.js +16 -45
- package/dist/esm/labs/next/presets/default.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +19 -63
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/index.d.ts +19 -63
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +4 -4
- package/report.api.md +8 -1116
- package/tmp/api-report-tmp.d.ts +8 -971
- package/dist/cjs/plugins/floating-toolbar/index.js +0 -386
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -73
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -26
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -16
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -9
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -16
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -25
- package/dist/cjs/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -5
- package/dist/cjs/plugins/floating-toolbar/ui/CheckboxModal.js +0 -83
- package/dist/cjs/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -22
- package/dist/cjs/plugins/floating-toolbar/ui/Dropdown.js +0 -208
- package/dist/cjs/plugins/floating-toolbar/ui/DropdownMenu.js +0 -205
- package/dist/cjs/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -32
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -120
- package/dist/cjs/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -179
- package/dist/cjs/plugins/floating-toolbar/ui/Input.js +0 -78
- package/dist/cjs/plugins/floating-toolbar/ui/ScrollButtons.js +0 -152
- package/dist/cjs/plugins/floating-toolbar/ui/Select.js +0 -74
- package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +0 -9
- package/dist/cjs/plugins/floating-toolbar/ui/SimpleModal.js +0 -42
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +0 -427
- package/dist/cjs/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -25
- package/dist/cjs/plugins/floating-toolbar/ui/messages.js +0 -55
- package/dist/cjs/plugins/floating-toolbar/ui/styles.js +0 -79
- package/dist/cjs/plugins/floating-toolbar/utils.js +0 -22
- package/dist/es2019/plugins/floating-toolbar/index.js +0 -368
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -63
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -10
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -16
- package/dist/es2019/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
- package/dist/es2019/plugins/floating-toolbar/ui/CheckboxModal.js +0 -71
- package/dist/es2019/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -13
- package/dist/es2019/plugins/floating-toolbar/ui/Dropdown.js +0 -180
- package/dist/es2019/plugins/floating-toolbar/ui/DropdownMenu.js +0 -191
- package/dist/es2019/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -107
- package/dist/es2019/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -100
- package/dist/es2019/plugins/floating-toolbar/ui/Input.js +0 -52
- package/dist/es2019/plugins/floating-toolbar/ui/ScrollButtons.js +0 -137
- package/dist/es2019/plugins/floating-toolbar/ui/Select.js +0 -62
- package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +0 -2
- package/dist/es2019/plugins/floating-toolbar/ui/SimpleModal.js +0 -35
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +0 -419
- package/dist/es2019/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -6
- package/dist/es2019/plugins/floating-toolbar/ui/messages.js +0 -48
- package/dist/es2019/plugins/floating-toolbar/ui/styles.js +0 -64
- package/dist/es2019/plugins/floating-toolbar/utils.js +0 -16
- package/dist/esm/plugins/floating-toolbar/index.js +0 -375
- package/dist/esm/plugins/floating-toolbar/pm-plugins/force-focus/index.js +0 -64
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.js +0 -18
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.js +0 -8
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.js +0 -2
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.js +0 -9
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.js +0 -17
- package/dist/esm/plugins/floating-toolbar/pm-plugins/toolbar-data/types.js +0 -1
- package/dist/esm/plugins/floating-toolbar/ui/CheckboxModal.js +0 -72
- package/dist/esm/plugins/floating-toolbar/ui/ConfirmationModal.js +0 -14
- package/dist/esm/plugins/floating-toolbar/ui/Dropdown.js +0 -199
- package/dist/esm/plugins/floating-toolbar/ui/DropdownMenu.js +0 -197
- package/dist/esm/plugins/floating-toolbar/ui/EditorEmojiAddIcon.js +0 -25
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +0 -113
- package/dist/esm/plugins/floating-toolbar/ui/ExtensionsPlaceholder.js +0 -168
- package/dist/esm/plugins/floating-toolbar/ui/Input.js +0 -70
- package/dist/esm/plugins/floating-toolbar/ui/ScrollButtons.js +0 -141
- package/dist/esm/plugins/floating-toolbar/ui/Select.js +0 -64
- package/dist/esm/plugins/floating-toolbar/ui/Separator.js +0 -2
- package/dist/esm/plugins/floating-toolbar/ui/SimpleModal.js +0 -31
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +0 -417
- package/dist/esm/plugins/floating-toolbar/ui/ToolbarLoader.js +0 -12
- package/dist/esm/plugins/floating-toolbar/ui/messages.js +0 -48
- package/dist/esm/plugins/floating-toolbar/ui/styles.js +0 -68
- package/dist/esm/plugins/floating-toolbar/utils.js +0 -16
- package/dist/types/plugins/floating-toolbar/index.d.ts +0 -13
- package/dist/types/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
- package/dist/types/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
- package/dist/types/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
- package/dist/types/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
- package/dist/types/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
- package/dist/types/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
- package/dist/types/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
- package/dist/types/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
- package/dist/types/plugins/floating-toolbar/ui/Input.d.ts +0 -23
- package/dist/types/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +0 -21
- package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
- package/dist/types/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
- package/dist/types/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
- package/dist/types/plugins/floating-toolbar/ui/messages.d.ts +0 -48
- package/dist/types/plugins/floating-toolbar/ui/styles.d.ts +0 -20
- package/dist/types/plugins/floating-toolbar/utils.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +0 -13
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/force-focus/index.d.ts +0 -21
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/commands.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-factory.d.ts +0 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin-key.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/plugin.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/reducer.d.ts +0 -3
- package/dist/types-ts4.5/plugins/floating-toolbar/pm-plugins/toolbar-data/types.d.ts +0 -8
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/CheckboxModal.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ConfirmationModal.d.ts +0 -6
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Dropdown.d.ts +0 -41
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/DropdownMenu.d.ts +0 -29
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/EditorEmojiAddIcon.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/EmojiPickerButton.d.ts +0 -15
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ExtensionsPlaceholder.d.ts +0 -16
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Input.d.ts +0 -23
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ScrollButtons.d.ts +0 -13
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Select.d.ts +0 -21
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +0 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/SimpleModal.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +0 -44
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/ToolbarLoader.d.ts +0 -4
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/messages.d.ts +0 -48
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/styles.d.ts +0 -20
- package/dist/types-ts4.5/plugins/floating-toolbar/utils.d.ts +0 -2
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
import { PluginKey, AllSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { findDomRefAtPos, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import camelCase from 'lodash/camelCase';
|
|
6
|
-
import { Popup } from '@atlaskit/editor-common/ui';
|
|
7
|
-
// AFP-2532 TODO: Fix automatic suppressions below
|
|
8
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
9
|
-
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
10
|
-
import { CONTENT_COMPONENT } from '../analytics/types';
|
|
11
|
-
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
|
-
import { pluginKey as dataPluginKey } from './pm-plugins/toolbar-data/plugin-key';
|
|
13
|
-
import { createPlugin as floatingToolbarDataPluginFactory } from './pm-plugins/toolbar-data/plugin';
|
|
14
|
-
import { hideConfirmDialog } from './pm-plugins/toolbar-data/commands';
|
|
15
|
-
import { ConfirmationModal } from './ui/ConfirmationModal';
|
|
16
|
-
import { ToolbarLoader } from './ui/ToolbarLoader';
|
|
17
|
-
import { findNode } from './utils';
|
|
18
|
-
import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
|
|
19
|
-
import forceFocusPlugin, { forceFocusSelector } from './pm-plugins/force-focus';
|
|
20
|
-
export const getRelevantConfig = (selection, configs) => {
|
|
21
|
-
// node selections always take precedence, see if
|
|
22
|
-
let configPair;
|
|
23
|
-
configs.find(config => {
|
|
24
|
-
const node = findSelectedNodeOfType(config.nodeType)(selection);
|
|
25
|
-
if (node) {
|
|
26
|
-
configPair = {
|
|
27
|
-
node: node.node,
|
|
28
|
-
pos: node.pos,
|
|
29
|
-
config
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return !!node;
|
|
33
|
-
});
|
|
34
|
-
if (configPair) {
|
|
35
|
-
return configPair;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// create mapping of node type name to configs
|
|
39
|
-
const configByNodeType = {};
|
|
40
|
-
configs.forEach(config => {
|
|
41
|
-
if (Array.isArray(config.nodeType)) {
|
|
42
|
-
config.nodeType.forEach(nodeType => {
|
|
43
|
-
configByNodeType[nodeType.name] = config;
|
|
44
|
-
});
|
|
45
|
-
} else {
|
|
46
|
-
configByNodeType[config.nodeType.name] = config;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// search up the tree from selection
|
|
51
|
-
const {
|
|
52
|
-
$from
|
|
53
|
-
} = selection;
|
|
54
|
-
for (let i = $from.depth; i > 0; i--) {
|
|
55
|
-
const node = $from.node(i);
|
|
56
|
-
const matchedConfig = configByNodeType[node.type.name];
|
|
57
|
-
if (matchedConfig) {
|
|
58
|
-
return {
|
|
59
|
-
config: matchedConfig,
|
|
60
|
-
node: node,
|
|
61
|
-
pos: $from.pos
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// if it is AllSelection (can be result of Cmd+A) - use first node
|
|
67
|
-
if (selection instanceof AllSelection) {
|
|
68
|
-
const docNode = $from.node(0);
|
|
69
|
-
let matchedConfig = null;
|
|
70
|
-
const firstChild = findNode(docNode, node => {
|
|
71
|
-
matchedConfig = configByNodeType[node.type.name];
|
|
72
|
-
return !!matchedConfig;
|
|
73
|
-
});
|
|
74
|
-
if (firstChild && matchedConfig) {
|
|
75
|
-
return {
|
|
76
|
-
config: matchedConfig,
|
|
77
|
-
node: firstChild,
|
|
78
|
-
pos: $from.pos
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return;
|
|
83
|
-
};
|
|
84
|
-
const getDomRefFromSelection = (view, dispatchAnalyticsEvent) => {
|
|
85
|
-
try {
|
|
86
|
-
return findDomRefAtPos(view.state.selection.from, view.domAtPos.bind(view));
|
|
87
|
-
} catch (error) {
|
|
88
|
-
// eslint-disable-next-line no-console
|
|
89
|
-
console.warn(error);
|
|
90
|
-
if (dispatchAnalyticsEvent) {
|
|
91
|
-
const payload = {
|
|
92
|
-
action: ACTION.ERRORED,
|
|
93
|
-
actionSubject: ACTION_SUBJECT.CONTENT_COMPONENT,
|
|
94
|
-
eventType: EVENT_TYPE.OPERATIONAL,
|
|
95
|
-
attributes: {
|
|
96
|
-
component: CONTENT_COMPONENT.FLOATING_TOOLBAR,
|
|
97
|
-
selection: view.state.selection.toJSON(),
|
|
98
|
-
position: view.state.selection.from,
|
|
99
|
-
docSize: view.state.doc.nodeSize,
|
|
100
|
-
error: error.toString(),
|
|
101
|
-
errorStack: error.stack || undefined
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
dispatchAnalyticsEvent(payload);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
function filterUndefined(x) {
|
|
109
|
-
return !!x;
|
|
110
|
-
}
|
|
111
|
-
const floatingToolbarPlugin = ({
|
|
112
|
-
api
|
|
113
|
-
}) => {
|
|
114
|
-
return {
|
|
115
|
-
name: 'floatingToolbar',
|
|
116
|
-
pmPlugins(floatingToolbarHandlers = []) {
|
|
117
|
-
return [{
|
|
118
|
-
// Should be after all toolbar plugins
|
|
119
|
-
name: 'floatingToolbar',
|
|
120
|
-
plugin: ({
|
|
121
|
-
dispatch,
|
|
122
|
-
providerFactory,
|
|
123
|
-
getIntl
|
|
124
|
-
}) => floatingToolbarPluginFactory({
|
|
125
|
-
floatingToolbarHandlers,
|
|
126
|
-
dispatch,
|
|
127
|
-
providerFactory,
|
|
128
|
-
getIntl
|
|
129
|
-
})
|
|
130
|
-
}, {
|
|
131
|
-
name: 'floatingToolbarData',
|
|
132
|
-
plugin: ({
|
|
133
|
-
dispatch
|
|
134
|
-
}) => floatingToolbarDataPluginFactory(dispatch)
|
|
135
|
-
}, {
|
|
136
|
-
name: 'forceFocus',
|
|
137
|
-
plugin: () => forceFocusPlugin()
|
|
138
|
-
}];
|
|
139
|
-
},
|
|
140
|
-
actions: {
|
|
141
|
-
forceFocusSelector
|
|
142
|
-
},
|
|
143
|
-
getSharedState(editorState) {
|
|
144
|
-
var _pluginKey$getState$g, _pluginKey$getState, _pluginKey$getState$g2;
|
|
145
|
-
if (!editorState) {
|
|
146
|
-
return undefined;
|
|
147
|
-
}
|
|
148
|
-
const configWithNodeInfo = (_pluginKey$getState$g = (_pluginKey$getState = pluginKey.getState(editorState)) === null || _pluginKey$getState === void 0 ? void 0 : (_pluginKey$getState$g2 = _pluginKey$getState.getConfigWithNodeInfo) === null || _pluginKey$getState$g2 === void 0 ? void 0 : _pluginKey$getState$g2.call(_pluginKey$getState, editorState)) !== null && _pluginKey$getState$g !== void 0 ? _pluginKey$getState$g : undefined;
|
|
149
|
-
return {
|
|
150
|
-
configWithNodeInfo,
|
|
151
|
-
floatingToolbarData: dataPluginKey.getState(editorState)
|
|
152
|
-
};
|
|
153
|
-
},
|
|
154
|
-
contentComponent({
|
|
155
|
-
popupsMountPoint,
|
|
156
|
-
popupsBoundariesElement,
|
|
157
|
-
popupsScrollableElement,
|
|
158
|
-
editorView,
|
|
159
|
-
providerFactory,
|
|
160
|
-
dispatchAnalyticsEvent
|
|
161
|
-
}) {
|
|
162
|
-
return /*#__PURE__*/React.createElement(ContentComponent, {
|
|
163
|
-
editorView: editorView,
|
|
164
|
-
pluginInjectionApi: api,
|
|
165
|
-
popupsMountPoint: popupsMountPoint,
|
|
166
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
167
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
168
|
-
providerFactory: providerFactory,
|
|
169
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
175
|
-
function ContentComponent({
|
|
176
|
-
pluginInjectionApi,
|
|
177
|
-
editorView,
|
|
178
|
-
popupsMountPoint,
|
|
179
|
-
popupsBoundariesElement,
|
|
180
|
-
popupsScrollableElement,
|
|
181
|
-
providerFactory,
|
|
182
|
-
dispatchAnalyticsEvent
|
|
183
|
-
}) {
|
|
184
|
-
var _pluginInjectionApi$f, _configWithNodeInfo$c, _configWithNodeInfo$c2;
|
|
185
|
-
const featureFlags = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f === void 0 ? void 0 : _pluginInjectionApi$f.sharedState.currentState()) || {};
|
|
186
|
-
const {
|
|
187
|
-
floatingToolbarState,
|
|
188
|
-
editorDisabledState
|
|
189
|
-
} = useSharedPluginState(pluginInjectionApi, ['floatingToolbar', 'editorDisabled']);
|
|
190
|
-
const {
|
|
191
|
-
configWithNodeInfo,
|
|
192
|
-
floatingToolbarData
|
|
193
|
-
} = floatingToolbarState !== null && floatingToolbarState !== void 0 ? floatingToolbarState : {};
|
|
194
|
-
if (!configWithNodeInfo || !configWithNodeInfo.config || typeof ((_configWithNodeInfo$c = configWithNodeInfo.config) === null || _configWithNodeInfo$c === void 0 ? void 0 : _configWithNodeInfo$c.visible) !== 'undefined' && !((_configWithNodeInfo$c2 = configWithNodeInfo.config) !== null && _configWithNodeInfo$c2 !== void 0 && _configWithNodeInfo$c2.visible)) {
|
|
195
|
-
return null;
|
|
196
|
-
}
|
|
197
|
-
const {
|
|
198
|
-
config,
|
|
199
|
-
node
|
|
200
|
-
} = configWithNodeInfo;
|
|
201
|
-
const {
|
|
202
|
-
title,
|
|
203
|
-
getDomRef = getDomRefFromSelection,
|
|
204
|
-
items,
|
|
205
|
-
align = 'center',
|
|
206
|
-
className = '',
|
|
207
|
-
height,
|
|
208
|
-
width,
|
|
209
|
-
zIndex,
|
|
210
|
-
offset = [0, 12],
|
|
211
|
-
forcePlacement,
|
|
212
|
-
preventPopupOverflow,
|
|
213
|
-
onPositionCalculated,
|
|
214
|
-
absoluteOffset = {
|
|
215
|
-
top: 0,
|
|
216
|
-
left: 0,
|
|
217
|
-
right: 0,
|
|
218
|
-
bottom: 0
|
|
219
|
-
},
|
|
220
|
-
focusTrap
|
|
221
|
-
} = config;
|
|
222
|
-
const targetRef = getDomRef(editorView, dispatchAnalyticsEvent);
|
|
223
|
-
if (!targetRef || editorDisabledState && editorDisabledState.editorDisabled) {
|
|
224
|
-
return null;
|
|
225
|
-
}
|
|
226
|
-
let customPositionCalculation;
|
|
227
|
-
const toolbarItems = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.copyButton.actions.processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.decorations.actions.hoverDecoration);
|
|
228
|
-
if (onPositionCalculated) {
|
|
229
|
-
customPositionCalculation = nextPos => {
|
|
230
|
-
return onPositionCalculated(editorView, nextPos);
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const dispatchCommand = fn => fn && fn(editorView.state, editorView.dispatch, editorView);
|
|
234
|
-
|
|
235
|
-
// Confirm dialog
|
|
236
|
-
const {
|
|
237
|
-
confirmDialogForItem
|
|
238
|
-
} = floatingToolbarData || {};
|
|
239
|
-
const confirmButtonItem = confirmDialogForItem ? toolbarItems[confirmDialogForItem] : undefined;
|
|
240
|
-
const scrollable = config.scrollable;
|
|
241
|
-
const confirmDialogOptions = typeof (confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog) === 'function' ? confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog() : confirmButtonItem === null || confirmButtonItem === void 0 ? void 0 : confirmButtonItem.confirmDialog;
|
|
242
|
-
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
243
|
-
component: ACTION_SUBJECT.FLOATING_TOOLBAR_PLUGIN,
|
|
244
|
-
componentId: camelCase(title),
|
|
245
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
246
|
-
fallbackComponent: null
|
|
247
|
-
}, /*#__PURE__*/React.createElement(Popup, {
|
|
248
|
-
ariaLabel: title,
|
|
249
|
-
offset: offset,
|
|
250
|
-
target: targetRef,
|
|
251
|
-
alignY: "bottom",
|
|
252
|
-
forcePlacement: forcePlacement,
|
|
253
|
-
fitHeight: height,
|
|
254
|
-
fitWidth: width,
|
|
255
|
-
absoluteOffset: absoluteOffset,
|
|
256
|
-
alignX: align,
|
|
257
|
-
stick: true,
|
|
258
|
-
zIndex: zIndex,
|
|
259
|
-
mountTo: popupsMountPoint,
|
|
260
|
-
boundariesElement: popupsBoundariesElement,
|
|
261
|
-
scrollableElement: popupsScrollableElement,
|
|
262
|
-
onPositionCalculated: customPositionCalculation,
|
|
263
|
-
style: scrollable ? {
|
|
264
|
-
maxWidth: '100%'
|
|
265
|
-
} : {},
|
|
266
|
-
focusTrap: focusTrap,
|
|
267
|
-
preventOverflow: preventPopupOverflow
|
|
268
|
-
}, /*#__PURE__*/React.createElement(WithProviders, {
|
|
269
|
-
providerFactory: providerFactory,
|
|
270
|
-
providers: ['extensionProvider'],
|
|
271
|
-
renderNode: providers => {
|
|
272
|
-
return /*#__PURE__*/React.createElement(ToolbarLoader, {
|
|
273
|
-
target: targetRef,
|
|
274
|
-
items: toolbarItems,
|
|
275
|
-
node: node,
|
|
276
|
-
dispatchCommand: dispatchCommand,
|
|
277
|
-
editorView: editorView,
|
|
278
|
-
className: className,
|
|
279
|
-
focusEditor: () => editorView.focus(),
|
|
280
|
-
providerFactory: providerFactory,
|
|
281
|
-
popupsMountPoint: popupsMountPoint,
|
|
282
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
283
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
284
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
285
|
-
extensionsProvider: providers.extensionProvider,
|
|
286
|
-
scrollable: scrollable,
|
|
287
|
-
featureFlags: featureFlags,
|
|
288
|
-
api: pluginInjectionApi
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
})), /*#__PURE__*/React.createElement(ConfirmationModal, {
|
|
292
|
-
testId: "ak-floating-toolbar-confirmation-modal",
|
|
293
|
-
options: confirmDialogOptions,
|
|
294
|
-
onConfirm: (isChecked = false) => {
|
|
295
|
-
if (!!confirmDialogOptions.onConfirm) {
|
|
296
|
-
dispatchCommand(confirmDialogOptions.onConfirm(isChecked));
|
|
297
|
-
} else {
|
|
298
|
-
dispatchCommand(confirmButtonItem.onClick);
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
onClose: () => {
|
|
302
|
-
dispatchCommand(hideConfirmDialog());
|
|
303
|
-
// Need to set focus to Editor here,
|
|
304
|
-
// As when the Confirmation dialog pop up, and user interacts with the dialog, Editor loses focus.
|
|
305
|
-
// So when Confirmation dialog is closed, Editor does not have the focus, then cursor goes to the position 1 of the doc,
|
|
306
|
-
// instead of the cursor position before the dialog pop up.
|
|
307
|
-
if (!editorView.hasFocus()) {
|
|
308
|
-
editorView.focus();
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}));
|
|
312
|
-
}
|
|
313
|
-
export default floatingToolbarPlugin;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
*
|
|
317
|
-
* ProseMirror Plugin
|
|
318
|
-
*
|
|
319
|
-
*/
|
|
320
|
-
// We throttle update of this plugin with RAF.
|
|
321
|
-
// So from other plugins you will always get the previous state.
|
|
322
|
-
export const pluginKey = new PluginKey('floatingToolbarPluginKey');
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* Clean up floating toolbar configs from undesired properties.
|
|
326
|
-
*/
|
|
327
|
-
function sanitizeFloatingToolbarConfig(config) {
|
|
328
|
-
// Cleanup from non existing node types
|
|
329
|
-
if (Array.isArray(config.nodeType)) {
|
|
330
|
-
return {
|
|
331
|
-
...config,
|
|
332
|
-
nodeType: config.nodeType.filter(filterUndefined)
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
return config;
|
|
336
|
-
}
|
|
337
|
-
function floatingToolbarPluginFactory(options) {
|
|
338
|
-
const {
|
|
339
|
-
floatingToolbarHandlers,
|
|
340
|
-
providerFactory,
|
|
341
|
-
getIntl
|
|
342
|
-
} = options;
|
|
343
|
-
const intl = getIntl();
|
|
344
|
-
const getConfigWithNodeInfo = editorState => {
|
|
345
|
-
const activeConfigs = floatingToolbarHandlers.map(handler => handler(editorState, intl, providerFactory)).filter(filterUndefined).map(config => sanitizeFloatingToolbarConfig(config));
|
|
346
|
-
const relevantConfig = activeConfigs && getRelevantConfig(editorState.selection, activeConfigs);
|
|
347
|
-
return relevantConfig;
|
|
348
|
-
};
|
|
349
|
-
const apply = (tr, pluginState) => {
|
|
350
|
-
const newPluginState = {
|
|
351
|
-
getConfigWithNodeInfo
|
|
352
|
-
};
|
|
353
|
-
return newPluginState;
|
|
354
|
-
};
|
|
355
|
-
return new SafePlugin({
|
|
356
|
-
key: pluginKey,
|
|
357
|
-
state: {
|
|
358
|
-
init: () => {
|
|
359
|
-
// Use this point to preload the UI
|
|
360
|
-
ToolbarLoader.preload();
|
|
361
|
-
return {
|
|
362
|
-
getConfigWithNodeInfo
|
|
363
|
-
};
|
|
364
|
-
},
|
|
365
|
-
apply
|
|
366
|
-
}
|
|
367
|
-
});
|
|
368
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export const forceFocusStateKey = new PluginKey('forceFocusStatePlugin');
|
|
4
|
-
/**
|
|
5
|
-
* Used in cases where a floating toolbar button opens a submenu which destroys
|
|
6
|
-
* the button, but the user has pressed ESC to close the submenu and focus needs
|
|
7
|
-
* to move back to the button. */
|
|
8
|
-
export default (() => new SafePlugin({
|
|
9
|
-
key: forceFocusStateKey,
|
|
10
|
-
state: {
|
|
11
|
-
init: () => ({
|
|
12
|
-
selector: null
|
|
13
|
-
}),
|
|
14
|
-
apply: (tr, prevState) => {
|
|
15
|
-
const meta = tr.getMeta(forceFocusStateKey);
|
|
16
|
-
if (meta && 'selector' in meta) {
|
|
17
|
-
return {
|
|
18
|
-
selector: meta.selector
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
return prevState;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* The provided selector should be the floating toolbar button that needs focus.
|
|
28
|
-
*/
|
|
29
|
-
export const forceFocusSelector = selector => tr => {
|
|
30
|
-
return tr.setMeta(forceFocusStateKey, {
|
|
31
|
-
selector
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* If a selector is set and the element exists, focus it.
|
|
37
|
-
*/
|
|
38
|
-
export function checkShouldForceFocusAndApply(view) {
|
|
39
|
-
const state = view === null || view === void 0 ? void 0 : view.state;
|
|
40
|
-
if (state) {
|
|
41
|
-
const {
|
|
42
|
-
selector
|
|
43
|
-
} = forceFocusStateKey.getState(state);
|
|
44
|
-
if (selector) {
|
|
45
|
-
const focusableElement = document.querySelector(selector);
|
|
46
|
-
if (focusableElement) {
|
|
47
|
-
focusableElement.scrollIntoView({
|
|
48
|
-
behavior: 'smooth',
|
|
49
|
-
block: 'center',
|
|
50
|
-
inline: 'nearest'
|
|
51
|
-
});
|
|
52
|
-
focusableElement.focus();
|
|
53
|
-
const {
|
|
54
|
-
state: {
|
|
55
|
-
tr
|
|
56
|
-
},
|
|
57
|
-
dispatch
|
|
58
|
-
} = view;
|
|
59
|
-
dispatch(forceFocusSelector(null)(tr));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createCommand } from './plugin-factory';
|
|
2
|
-
export const showConfirmDialog = buttonIndex => createCommand({
|
|
3
|
-
type: 'SHOW_CONFIRM_DIALOG',
|
|
4
|
-
data: {
|
|
5
|
-
buttonIndex
|
|
6
|
-
}
|
|
7
|
-
}, tr => tr.setMeta('addToHistory', false));
|
|
8
|
-
export const hideConfirmDialog = () => createCommand({
|
|
9
|
-
type: 'HIDE_CONFIRM_DIALOG'
|
|
10
|
-
}, tr => tr.setMeta('addToHistory', false));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { pluginKey } from './plugin-key';
|
|
3
|
-
import { createPluginState } from './plugin-factory';
|
|
4
|
-
export const createPlugin = dispatch => {
|
|
5
|
-
return new SafePlugin({
|
|
6
|
-
state: createPluginState(dispatch, {}),
|
|
7
|
-
key: pluginKey
|
|
8
|
-
});
|
|
9
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export const reducer = (pluginState, action) => {
|
|
2
|
-
switch (action.type) {
|
|
3
|
-
case 'SHOW_CONFIRM_DIALOG':
|
|
4
|
-
return {
|
|
5
|
-
...pluginState,
|
|
6
|
-
confirmDialogForItem: action.data.buttonIndex
|
|
7
|
-
};
|
|
8
|
-
case 'HIDE_CONFIRM_DIALOG':
|
|
9
|
-
return {
|
|
10
|
-
...pluginState,
|
|
11
|
-
confirmDialogForItem: undefined
|
|
12
|
-
};
|
|
13
|
-
default:
|
|
14
|
-
return pluginState;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React, { useState } from 'react';
|
|
3
|
-
import Button from '@atlaskit/button/standard-button';
|
|
4
|
-
import { Checkbox } from '@atlaskit/checkbox';
|
|
5
|
-
import Modal, { ModalBody, ModalTitle, ModalHeader, ModalFooter } from '@atlaskit/modal-dialog';
|
|
6
|
-
import messages from './messages';
|
|
7
|
-
export const CheckboxModal = props => {
|
|
8
|
-
var _options$getChildrenI;
|
|
9
|
-
const [isChecked, setCheckbox] = useState(false);
|
|
10
|
-
const {
|
|
11
|
-
onConfirm,
|
|
12
|
-
onClose,
|
|
13
|
-
options,
|
|
14
|
-
intl: {
|
|
15
|
-
formatMessage
|
|
16
|
-
},
|
|
17
|
-
testId
|
|
18
|
-
} = props;
|
|
19
|
-
const heading = (options === null || options === void 0 ? void 0 : options.title) || formatMessage(messages.confirmModalDefaultHeading);
|
|
20
|
-
const okButtonLabel = (options === null || options === void 0 ? void 0 : options.okButtonLabel) || formatMessage(messages.confirmModalOK);
|
|
21
|
-
const cancelButtonLabel = (options === null || options === void 0 ? void 0 : options.cancelButtonLabel) || formatMessage(messages.confirmModalCancel);
|
|
22
|
-
const checkboxlabel = options === null || options === void 0 ? void 0 : options.checkboxLabel;
|
|
23
|
-
const childrenInfo = options === null || options === void 0 ? void 0 : (_options$getChildrenI = options.getChildrenInfo) === null || _options$getChildrenI === void 0 ? void 0 : _options$getChildrenI.call(options);
|
|
24
|
-
const ListComponent = ({
|
|
25
|
-
nodes
|
|
26
|
-
}) => {
|
|
27
|
-
if (nodes.length === 0) {
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
return /*#__PURE__*/React.createElement("ul", null, nodes.map(node => /*#__PURE__*/React.createElement(ListItem, _extends({}, node, {
|
|
31
|
-
key: node.id
|
|
32
|
-
}))));
|
|
33
|
-
};
|
|
34
|
-
const ListItem = props => {
|
|
35
|
-
const {
|
|
36
|
-
id,
|
|
37
|
-
name,
|
|
38
|
-
amount
|
|
39
|
-
} = props;
|
|
40
|
-
return /*#__PURE__*/React.createElement("li", {
|
|
41
|
-
id: id
|
|
42
|
-
}, formatMessage(messages.confirmModalListUnit, {
|
|
43
|
-
name,
|
|
44
|
-
amount
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
|
-
return /*#__PURE__*/React.createElement(Modal, {
|
|
48
|
-
onClose: onClose,
|
|
49
|
-
testId: testId
|
|
50
|
-
}, /*#__PURE__*/React.createElement(ModalHeader, null, /*#__PURE__*/React.createElement(ModalTitle, {
|
|
51
|
-
appearance: "warning"
|
|
52
|
-
}, heading)), /*#__PURE__*/React.createElement(ModalBody, null, /*#__PURE__*/React.createElement("p", null, options === null || options === void 0 ? void 0 : options.message), !!(childrenInfo !== null && childrenInfo !== void 0 && childrenInfo.length) && /*#__PURE__*/React.createElement(ListComponent, {
|
|
53
|
-
nodes: childrenInfo
|
|
54
|
-
}), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Checkbox, {
|
|
55
|
-
isChecked: isChecked,
|
|
56
|
-
onChange: () => setCheckbox(!isChecked),
|
|
57
|
-
label: checkboxlabel,
|
|
58
|
-
testId: testId ? `${testId}-checkbox` : undefined
|
|
59
|
-
}))), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
|
|
60
|
-
appearance: "default",
|
|
61
|
-
onClick: onClose,
|
|
62
|
-
testId: testId ? `${testId}-cancel-button` : undefined
|
|
63
|
-
}, cancelButtonLabel), /*#__PURE__*/React.createElement(Button, {
|
|
64
|
-
appearance: "warning",
|
|
65
|
-
onClick: () => {
|
|
66
|
-
onConfirm(isChecked);
|
|
67
|
-
onClose();
|
|
68
|
-
},
|
|
69
|
-
testId: testId ? `${testId}-confirm-button` : undefined
|
|
70
|
-
}, okButtonLabel)));
|
|
71
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { injectIntl } from 'react-intl-next';
|
|
3
|
-
import { SimpleModal } from './SimpleModal';
|
|
4
|
-
import { CheckboxModal } from './CheckboxModal';
|
|
5
|
-
import { ModalTransition } from '@atlaskit/modal-dialog';
|
|
6
|
-
const ConfirmationModalImpl = props => {
|
|
7
|
-
const {
|
|
8
|
-
options
|
|
9
|
-
} = props;
|
|
10
|
-
const renderModel = (isReferentialityDialog = false) => isReferentialityDialog ? /*#__PURE__*/React.createElement(CheckboxModal, props) : /*#__PURE__*/React.createElement(SimpleModal, props);
|
|
11
|
-
return options ? /*#__PURE__*/React.createElement(ModalTransition, null, renderModel(options === null || options === void 0 ? void 0 : options.isReferentialityDialog)) : null;
|
|
12
|
-
};
|
|
13
|
-
export const ConfirmationModal = injectIntl(ConfirmationModalImpl);
|