@atlaskit/editor-core 184.0.4 → 185.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 +38 -0
- package/dist/cjs/create-editor/feature-flags-from-props.js +1 -2
- package/dist/cjs/editor-next/index.js +41 -34
- package/dist/cjs/editor.js +30 -269
- package/dist/cjs/i18n/en_ZZ.js +32 -6
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/labs/next/presets/default.js +2 -1
- package/dist/cjs/plugins/base/index.js +0 -12
- package/dist/cjs/plugins/card/nodeviews/blockCard.js +7 -0
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +7 -0
- package/dist/cjs/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/cjs/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/cjs/plugins/card/toolbar.js +11 -9
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +4 -4
- package/dist/cjs/plugins/code-block/index.js +7 -5
- package/dist/cjs/plugins/code-block/toolbar.js +5 -5
- package/dist/cjs/plugins/copy-button/commands.js +2 -3
- package/dist/cjs/plugins/copy-button/toolbar.js +7 -8
- package/dist/cjs/plugins/expand/index.js +1 -1
- package/dist/cjs/plugins/expand/toolbar.js +40 -39
- package/dist/cjs/plugins/extension/index.js +1 -1
- package/dist/cjs/plugins/extension/toolbar.js +5 -5
- package/dist/cjs/plugins/floating-toolbar/index.js +3 -2
- package/dist/cjs/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/cjs/plugins/layout/index.js +8 -4
- package/dist/cjs/plugins/layout/toolbar.js +5 -6
- package/dist/cjs/plugins/media/toolbar/index.js +31 -24
- package/dist/cjs/plugins/panel/index.js +2 -1
- package/dist/cjs/plugins/panel/toolbar.js +7 -7
- package/dist/cjs/plugins/placeholder-text/index.js +7 -5
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
- package/dist/cjs/ui/CollapsedEditor/index.js +1 -2
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/feature-flags-from-props.js +1 -2
- package/dist/es2019/editor-next/index.js +39 -30
- package/dist/es2019/editor.js +29 -232
- package/dist/es2019/i18n/en_ZZ.js +32 -6
- package/dist/es2019/index.js +1 -2
- package/dist/es2019/labs/next/presets/default.js +2 -1
- package/dist/es2019/plugins/base/index.js +0 -7
- package/dist/es2019/plugins/card/nodeviews/blockCard.js +8 -0
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +8 -0
- package/dist/es2019/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/es2019/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/es2019/plugins/card/toolbar.js +8 -6
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +2 -2
- package/dist/es2019/plugins/code-block/index.js +7 -5
- package/dist/es2019/plugins/code-block/toolbar.js +5 -6
- package/dist/es2019/plugins/copy-button/commands.js +2 -3
- package/dist/es2019/plugins/copy-button/toolbar.js +7 -8
- package/dist/es2019/plugins/expand/index.js +1 -1
- package/dist/es2019/plugins/expand/toolbar.js +5 -6
- package/dist/es2019/plugins/extension/index.js +1 -1
- package/dist/es2019/plugins/extension/toolbar.js +5 -6
- package/dist/es2019/plugins/floating-toolbar/index.js +3 -2
- package/dist/es2019/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/es2019/plugins/layout/index.js +8 -5
- package/dist/es2019/plugins/layout/toolbar.js +5 -6
- package/dist/es2019/plugins/media/toolbar/index.js +35 -24
- package/dist/es2019/plugins/panel/index.js +2 -2
- package/dist/es2019/plugins/panel/toolbar.js +7 -8
- package/dist/es2019/plugins/placeholder-text/index.js +7 -5
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +21 -0
- package/dist/es2019/ui/CollapsedEditor/index.js +1 -2
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/feature-flags-from-props.js +1 -2
- package/dist/esm/editor-next/index.js +42 -33
- package/dist/esm/editor.js +29 -270
- package/dist/esm/i18n/en_ZZ.js +32 -6
- package/dist/esm/index.js +1 -2
- package/dist/esm/labs/next/presets/default.js +2 -1
- package/dist/esm/plugins/base/index.js +0 -9
- package/dist/esm/plugins/card/nodeviews/blockCard.js +7 -0
- package/dist/esm/plugins/card/nodeviews/embedCard.js +7 -0
- package/dist/esm/plugins/card/nodeviews/inlineCard.js +5 -1
- package/dist/esm/plugins/card/pm-plugins/doc.js +1 -2
- package/dist/esm/plugins/card/toolbar.js +7 -6
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +2 -2
- package/dist/esm/plugins/code-block/index.js +7 -5
- package/dist/esm/plugins/code-block/toolbar.js +5 -5
- package/dist/esm/plugins/copy-button/commands.js +2 -3
- package/dist/esm/plugins/copy-button/toolbar.js +7 -8
- package/dist/esm/plugins/expand/index.js +1 -1
- package/dist/esm/plugins/expand/toolbar.js +40 -39
- package/dist/esm/plugins/extension/index.js +1 -1
- package/dist/esm/plugins/extension/toolbar.js +5 -5
- package/dist/esm/plugins/floating-toolbar/index.js +3 -2
- package/dist/esm/plugins/floating-toolbar/ui/Toolbar.js +2 -4
- package/dist/esm/plugins/layout/index.js +8 -4
- package/dist/esm/plugins/layout/toolbar.js +5 -6
- package/dist/esm/plugins/media/toolbar/index.js +31 -24
- package/dist/esm/plugins/panel/index.js +2 -1
- package/dist/esm/plugins/panel/toolbar.js +7 -7
- package/dist/esm/plugins/placeholder-text/index.js +7 -5
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +19 -0
- package/dist/esm/ui/CollapsedEditor/index.js +1 -2
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/editor-next/index.d.ts +0 -6
- package/dist/types/editor.d.ts +1 -137
- package/dist/types/i18n/en_ZZ.d.ts +28 -2
- package/dist/types/index.d.ts +0 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +106 -0
- package/dist/types/labs/next/presets/default.d.ts +212 -0
- package/dist/types/labs/next/presets/mobile.d.ts +106 -0
- package/dist/types/plugins/base/index.d.ts +0 -4
- package/dist/types/plugins/card/index.d.ts +2 -2
- package/dist/types/plugins/card/nodeviews/blockCard.d.ts +3 -0
- package/dist/types/plugins/card/nodeviews/embedCard.d.ts +3 -0
- package/dist/types/plugins/card/nodeviews/inlineCard.d.ts +1 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/keymap.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/main.d.ts +1 -2
- package/dist/types/plugins/card/toolbar.d.ts +1 -2
- package/dist/types/plugins/card/types.d.ts +1 -1
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
- package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
- package/dist/types/plugins/card/ui/types.d.ts +1 -1
- package/dist/types/plugins/code-block/index.d.ts +7 -1
- package/dist/types/plugins/code-block/toolbar.d.ts +2 -1
- package/dist/types/plugins/copy-button/commands.d.ts +2 -1
- package/dist/types/plugins/copy-button/toolbar.d.ts +3 -2
- package/dist/types/plugins/expand/index.d.ts +2 -1
- package/dist/types/plugins/expand/toolbar.d.ts +2 -1
- package/dist/types/plugins/extension/index.d.ts +7 -2
- package/dist/types/plugins/extension/toolbar.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/index.d.ts +2 -1
- package/dist/types/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
- package/dist/types/plugins/layout/index.d.ts +7 -1
- package/dist/types/plugins/layout/toolbar.d.ts +2 -1
- package/dist/types/plugins/media/index.d.ts +3 -1
- package/dist/types/plugins/panel/index.d.ts +2 -0
- package/dist/types/plugins/panel/toolbar.d.ts +3 -2
- package/dist/types/plugins/placeholder-text/index.d.ts +3 -1
- package/dist/types/ui/CollapsedEditor/index.d.ts +1 -2
- package/dist/types-ts4.5/editor-next/index.d.ts +0 -6
- package/dist/types-ts4.5/editor.d.ts +1 -137
- package/dist/types-ts4.5/i18n/en_ZZ.d.ts +28 -2
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +122 -0
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +244 -0
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +122 -0
- package/dist/types-ts4.5/plugins/base/index.d.ts +0 -4
- package/dist/types-ts4.5/plugins/card/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/card/nodeviews/blockCard.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +3 -0
- package/dist/types-ts4.5/plugins/card/nodeviews/inlineCard.d.ts +1 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/keymap.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/main.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/toolbar.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/EditLinkToolbar.d.ts +1 -2
- package/dist/types-ts4.5/plugins/card/ui/link-toolbar-button-group-options.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/ui/types.d.ts +1 -1
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +7 -1
- package/dist/types-ts4.5/plugins/code-block/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/copy-button/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/copy-button/toolbar.d.ts +3 -2
- package/dist/types-ts4.5/plugins/expand/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/expand/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/extension/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/extension/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Toolbar.d.ts +3 -1
- package/dist/types-ts4.5/plugins/layout/index.d.ts +7 -1
- package/dist/types-ts4.5/plugins/layout/toolbar.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/panel/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/panel/toolbar.d.ts +3 -2
- package/dist/types-ts4.5/plugins/placeholder-text/index.d.ts +5 -1
- package/dist/types-ts4.5/ui/CollapsedEditor/index.d.ts +1 -2
- package/package.json +13 -8
- package/report.api.md +5 -93
- package/dist/cjs/editor-next/editor-migration-component.js +0 -54
- package/dist/cjs/plugins/base/pm-plugins/decoration.js +0 -122
- package/dist/es2019/editor-next/editor-migration-component.js +0 -30
- package/dist/es2019/plugins/base/pm-plugins/decoration.js +0 -111
- package/dist/esm/editor-next/editor-migration-component.js +0 -47
- package/dist/esm/plugins/base/pm-plugins/decoration.js +0 -113
- package/dist/types/editor-next/editor-migration-component.d.ts +0 -6
- package/dist/types/plugins/base/pm-plugins/decoration.d.ts +0 -24
- package/dist/types-ts4.5/editor-next/editor-migration-component.d.ts +0 -6
- package/dist/types-ts4.5/plugins/base/pm-plugins/decoration.d.ts +0 -24
|
@@ -228,6 +228,13 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
228
228
|
});
|
|
229
229
|
this.saveOriginalDimensionsAttributes(height, undefined);
|
|
230
230
|
});
|
|
231
|
+
_defineProperty(this, "onError", ({
|
|
232
|
+
err
|
|
233
|
+
}) => {
|
|
234
|
+
if (err) {
|
|
235
|
+
throw err;
|
|
236
|
+
}
|
|
237
|
+
});
|
|
231
238
|
}
|
|
232
239
|
UNSAFE_componentWillMount() {
|
|
233
240
|
const {
|
|
@@ -282,6 +289,7 @@ export class EmbedCardComponent extends React.PureComponent {
|
|
|
282
289
|
appearance: "embed",
|
|
283
290
|
onClick: this.onClick,
|
|
284
291
|
onResolve: this.onResolve,
|
|
292
|
+
onError: this.onError,
|
|
285
293
|
showActions: platform === 'web',
|
|
286
294
|
isFrameVisible: true,
|
|
287
295
|
inheritDimensions: true,
|
|
@@ -2,8 +2,7 @@ import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
|
2
2
|
import { closeHistory } from 'prosemirror-history';
|
|
3
3
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
4
4
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
5
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
-
import { SMART_LINK_TYPE } from '../../../plugins/analytics/types/node-events';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE } from '@atlaskit/editor-common/analytics';
|
|
7
6
|
import { nodesBetweenChanged, processRawValue } from '../../../utils';
|
|
8
7
|
import { unlinkPayload } from '../../../utils/linking-utils';
|
|
9
8
|
import { isFromCurrentDomain, getLinkCreationAnalyticsEvent } from '@atlaskit/editor-common/utils';
|
|
@@ -5,8 +5,8 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
5
5
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
6
6
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
7
7
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
8
|
-
import { linkToolbarMessages
|
|
9
|
-
import commonMessages from '
|
|
8
|
+
import { linkToolbarMessages } from '../../messages';
|
|
9
|
+
import commonMessages, { linkMessages } from '@atlaskit/editor-common/messages';
|
|
10
10
|
import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
11
11
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
12
12
|
import { pluginKey } from './pm-plugins/main';
|
|
@@ -165,7 +165,7 @@ const withToolbarMetadata = command => commandWithMetadata(command, {
|
|
|
165
165
|
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
166
166
|
});
|
|
167
167
|
const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) => node => {
|
|
168
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
168
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
169
169
|
const {
|
|
170
170
|
url
|
|
171
171
|
} = titleUrlPairFromNode(node);
|
|
@@ -186,7 +186,9 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
|
|
|
186
186
|
}
|
|
187
187
|
const pluginState = pluginKey.getState(state);
|
|
188
188
|
const currentAppearance = appearanceForNodeType(node.type);
|
|
189
|
-
const
|
|
189
|
+
const {
|
|
190
|
+
hoverDecoration
|
|
191
|
+
} = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.decorations) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {};
|
|
190
192
|
|
|
191
193
|
/* mobile builds toolbar natively using toolbarItems */
|
|
192
194
|
if (pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -245,8 +247,8 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
|
|
|
245
247
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
246
248
|
}];
|
|
247
249
|
if (currentAppearance === 'embed') {
|
|
248
|
-
var _pluginInjectionApi$
|
|
249
|
-
const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
250
|
+
var _pluginInjectionApi$d6;
|
|
251
|
+
const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.width, cardOptions);
|
|
250
252
|
if (alignmentOptions.length) {
|
|
251
253
|
alignmentOptions.push({
|
|
252
254
|
type: 'separator'
|
|
@@ -3,8 +3,8 @@ import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Fragment } from 'prosemirror-model';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import nodeNames from '
|
|
7
|
-
import { isSupportedInParent } from '
|
|
6
|
+
import nodeNames from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { messages } from '../messages';
|
|
9
9
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
10
10
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
@@ -5,11 +5,11 @@ import { getToolbarConfig } from './toolbar';
|
|
|
5
5
|
import keymap from './pm-plugins/keymaps';
|
|
6
6
|
import ideUX from './pm-plugins/ide-ux';
|
|
7
7
|
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
8
|
-
import {
|
|
8
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { IconCode } from '../quick-insert/assets';
|
|
10
10
|
import { messages } from '../block-type/messages';
|
|
11
11
|
import refreshBrowserSelectionOnChange from './refresh-browser-selection';
|
|
12
|
-
const codeBlockPlugin = options => ({
|
|
12
|
+
const codeBlockPlugin = (options, api) => ({
|
|
13
13
|
name: 'codeBlock',
|
|
14
14
|
nodes() {
|
|
15
15
|
return [{
|
|
@@ -57,9 +57,10 @@ const codeBlockPlugin = options => ({
|
|
|
57
57
|
keyshortcut: '```',
|
|
58
58
|
icon: () => /*#__PURE__*/React.createElement(IconCode, null),
|
|
59
59
|
action(insert, state) {
|
|
60
|
+
var _api$dependencies$ana;
|
|
60
61
|
const schema = state.schema;
|
|
61
62
|
const tr = insert(schema.nodes.codeBlock.createChecked());
|
|
62
|
-
|
|
63
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions.attachAnalyticsEvent({
|
|
63
64
|
action: ACTION.INSERTED,
|
|
64
65
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
65
66
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -67,10 +68,11 @@ const codeBlockPlugin = options => ({
|
|
|
67
68
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
68
69
|
},
|
|
69
70
|
eventType: EVENT_TYPE.TRACK
|
|
70
|
-
});
|
|
71
|
+
})(tr);
|
|
72
|
+
return tr;
|
|
71
73
|
}
|
|
72
74
|
}],
|
|
73
|
-
floatingToolbar: getToolbarConfig(options.allowCopyToClipboard)
|
|
75
|
+
floatingToolbar: getToolbarConfig(options.allowCopyToClipboard, api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration)
|
|
74
76
|
}
|
|
75
77
|
});
|
|
76
78
|
export default codeBlockPlugin;
|
|
@@ -6,7 +6,6 @@ import { removeCodeBlock, changeLanguage, copyContentToClipboard, resetCopiedSta
|
|
|
6
6
|
import commonMessages from '../../messages';
|
|
7
7
|
import { codeBlockButtonMessages } from '@atlaskit/editor-common/messages';
|
|
8
8
|
import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
9
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
10
9
|
import { pluginKey } from './plugin-key';
|
|
11
10
|
import { createLanguageList, getLanguageIdentifier, DEFAULT_LANGUAGES } from './language-list';
|
|
12
11
|
export const messages = defineMessages({
|
|
@@ -17,7 +16,7 @@ export const messages = defineMessages({
|
|
|
17
16
|
}
|
|
18
17
|
});
|
|
19
18
|
const languageList = createLanguageList(DEFAULT_LANGUAGES);
|
|
20
|
-
export const getToolbarConfig = (allowCopyToClipboard = false) => (state, {
|
|
19
|
+
export const getToolbarConfig = (allowCopyToClipboard = false, hoverDecoration) => (state, {
|
|
21
20
|
formatMessage
|
|
22
21
|
}) => {
|
|
23
22
|
var _codeBlockState$pos, _node$attrs;
|
|
@@ -77,10 +76,10 @@ export const getToolbarConfig = (allowCopyToClipboard = false) => (state, {
|
|
|
77
76
|
type: 'button',
|
|
78
77
|
appearance: 'danger',
|
|
79
78
|
icon: RemoveIcon,
|
|
80
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
81
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
82
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
83
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
79
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
80
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
81
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
82
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
84
83
|
onClick: removeCodeBlock,
|
|
85
84
|
title: formatMessage(commonMessages.remove),
|
|
86
85
|
tabIndex: null
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { copyButtonPluginKey } from './pm-plugins/plugin-key';
|
|
2
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
3
2
|
import { NodeSelection } from 'prosemirror-state';
|
|
4
3
|
import { copyHTMLToClipboard, copyHTMLToClipboardPolyfill } from '../../utils/clipboard';
|
|
5
4
|
import { getSelectedNodeOrNodeParentByNodeType, toDOM } from './utils';
|
|
@@ -135,7 +134,7 @@ export const createToolbarCopyCommandForNode = nodeType => (state, dispatch) =>
|
|
|
135
134
|
}
|
|
136
135
|
return true;
|
|
137
136
|
};
|
|
138
|
-
export const resetCopiedState = (nodeType, onMouseLeave) => (state, dispatch) => {
|
|
137
|
+
export const resetCopiedState = (nodeType, hoverDecoration, onMouseLeave) => (state, dispatch) => {
|
|
139
138
|
let customTr = state.tr;
|
|
140
139
|
|
|
141
140
|
// Avoid multipe dispatch
|
|
@@ -143,7 +142,7 @@ export const resetCopiedState = (nodeType, onMouseLeave) => (state, dispatch) =>
|
|
|
143
142
|
const customDispatch = tr => {
|
|
144
143
|
customTr = tr;
|
|
145
144
|
};
|
|
146
|
-
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
145
|
+
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
147
146
|
const copyButtonState = copyButtonPluginKey.getState(state);
|
|
148
147
|
if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
|
|
149
148
|
customTr.setMeta(copyButtonPluginKey, {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
2
2
|
import commonMessages from '../../messages';
|
|
3
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
4
3
|
import { createToolbarCopyCommandForNode, createToolbarCopyCommandForMark, resetCopiedState, getProvideMarkVisualFeedbackForCopyButtonCommand, removeMarkVisualFeedbackForCopyButtonCommand } from './commands';
|
|
5
4
|
import { copyButtonPluginKey } from './pm-plugins/plugin-key';
|
|
6
5
|
function isSeparator(item) {
|
|
@@ -9,7 +8,7 @@ function isSeparator(item) {
|
|
|
9
8
|
function isNodeOptions(options) {
|
|
10
9
|
return 'nodeType' in options && options.nodeType !== undefined;
|
|
11
10
|
}
|
|
12
|
-
export function getCopyButtonConfig(options) {
|
|
11
|
+
export function getCopyButtonConfig(options, hoverDecoration) {
|
|
13
12
|
const {
|
|
14
13
|
state,
|
|
15
14
|
formatMessage,
|
|
@@ -25,12 +24,12 @@ export function getCopyButtonConfig(options) {
|
|
|
25
24
|
onClick: createToolbarCopyCommandForNode(options.nodeType),
|
|
26
25
|
// Note for future changes: these two handlers should perform
|
|
27
26
|
// the same action.
|
|
28
|
-
onMouseEnter: onMouseEnter || hoverDecoration(options.nodeType, true, 'ak-editor-selected-node'),
|
|
29
|
-
onFocus: onFocus || hoverDecoration(options.nodeType, true, 'ak-editor-selected-node'),
|
|
27
|
+
onMouseEnter: onMouseEnter || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
28
|
+
onFocus: onFocus || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
30
29
|
// Note for future changes: these two handlers should perform
|
|
31
30
|
// the same action.
|
|
32
|
-
onMouseLeave: resetCopiedState(options.nodeType, onMouseLeave),
|
|
33
|
-
onBlur: resetCopiedState(options.nodeType, onBlur)
|
|
31
|
+
onMouseLeave: resetCopiedState(options.nodeType, hoverDecoration, onMouseLeave),
|
|
32
|
+
onBlur: resetCopiedState(options.nodeType, hoverDecoration, onBlur)
|
|
34
33
|
};
|
|
35
34
|
} else {
|
|
36
35
|
buttonActionHandlers = {
|
|
@@ -69,13 +68,13 @@ export const showCopyButton = state => {
|
|
|
69
68
|
* else process copy button to standard floatingtoobarbutton
|
|
70
69
|
*/
|
|
71
70
|
export function processCopyButtonItems(state) {
|
|
72
|
-
return items => items.flatMap(item => {
|
|
71
|
+
return (items, hoverDecoration) => items.flatMap(item => {
|
|
73
72
|
switch (item.type) {
|
|
74
73
|
case 'copy-button':
|
|
75
74
|
if (item !== null && item !== void 0 && item.hidden || !showCopyButton(state)) {
|
|
76
75
|
return [];
|
|
77
76
|
}
|
|
78
|
-
return item === null || item === void 0 ? void 0 : item.items.map(copyButtonItem => isSeparator(copyButtonItem) ? copyButtonItem : getCopyButtonConfig(copyButtonItem));
|
|
77
|
+
return item === null || item === void 0 ? void 0 : item.items.map(copyButtonItem => isSeparator(copyButtonItem) ? copyButtonItem : getCopyButtonConfig(copyButtonItem, hoverDecoration));
|
|
79
78
|
default:
|
|
80
79
|
return [item];
|
|
81
80
|
}
|
|
@@ -36,7 +36,7 @@ const expandPlugin = (options = {}, api) => {
|
|
|
36
36
|
}];
|
|
37
37
|
},
|
|
38
38
|
pluginsOptions: {
|
|
39
|
-
floatingToolbar: getToolbarConfig,
|
|
39
|
+
floatingToolbar: getToolbarConfig(api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration),
|
|
40
40
|
quickInsert: ({
|
|
41
41
|
formatMessage
|
|
42
42
|
}) => {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
2
2
|
import commonMessages from '../../messages';
|
|
3
3
|
import { deleteExpand } from './commands';
|
|
4
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
5
4
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
6
|
-
export const getToolbarConfig = (state, {
|
|
5
|
+
export const getToolbarConfig = hoverDecoration => (state, {
|
|
7
6
|
formatMessage
|
|
8
7
|
}) => {
|
|
9
8
|
const {
|
|
@@ -35,10 +34,10 @@ export const getToolbarConfig = (state, {
|
|
|
35
34
|
focusEditoronEnter: true,
|
|
36
35
|
icon: RemoveIcon,
|
|
37
36
|
onClick: deleteExpand(),
|
|
38
|
-
onMouseEnter: hoverDecoration([nestedExpand, expand], true),
|
|
39
|
-
onMouseLeave: hoverDecoration([nestedExpand, expand], false),
|
|
40
|
-
onFocus: hoverDecoration([nestedExpand, expand], true),
|
|
41
|
-
onBlur: hoverDecoration([nestedExpand, expand], false),
|
|
37
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], true),
|
|
38
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], false),
|
|
39
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], true),
|
|
40
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration([nestedExpand, expand], false),
|
|
42
41
|
title: formatMessage(commonMessages.remove),
|
|
43
42
|
tabIndex: null
|
|
44
43
|
}]
|
|
@@ -44,7 +44,7 @@ const extensionPlugin = (options = {}, api) => {
|
|
|
44
44
|
}];
|
|
45
45
|
},
|
|
46
46
|
pluginsOptions: {
|
|
47
|
-
floatingToolbar: getToolbarConfig(options.breakoutEnabled),
|
|
47
|
+
floatingToolbar: getToolbarConfig(options.breakoutEnabled, api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration),
|
|
48
48
|
contextPanel: getContextPanel(options.allowAutoSave, featureFlags)
|
|
49
49
|
}
|
|
50
50
|
};
|
|
@@ -6,7 +6,6 @@ import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
|
6
6
|
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
7
7
|
import CenterIcon from '@atlaskit/icon/glyph/editor/media-center';
|
|
8
8
|
import commonMessages from '../../messages';
|
|
9
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
10
9
|
import { editExtension } from './actions';
|
|
11
10
|
import { getPluginState } from './pm-plugins/main';
|
|
12
11
|
import { getSelectedExtension } from './utils';
|
|
@@ -119,7 +118,7 @@ const editButton = (formatMessage, extensionState) => {
|
|
|
119
118
|
focusEditoronEnter: true
|
|
120
119
|
}];
|
|
121
120
|
};
|
|
122
|
-
export const getToolbarConfig = (breakoutEnabled = true) => (state, intl) => {
|
|
121
|
+
export const getToolbarConfig = (breakoutEnabled = true, hoverDecoration) => (state, intl) => {
|
|
123
122
|
const {
|
|
124
123
|
formatMessage
|
|
125
124
|
} = intl;
|
|
@@ -173,10 +172,10 @@ export const getToolbarConfig = (breakoutEnabled = true) => (state, intl) => {
|
|
|
173
172
|
icon: RemoveIcon,
|
|
174
173
|
appearance: 'danger',
|
|
175
174
|
onClick: removeExtension(),
|
|
176
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
177
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
178
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
179
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
175
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
176
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
177
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
178
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
180
179
|
focusEditoronEnter: true,
|
|
181
180
|
title: formatMessage(commonMessages.remove),
|
|
182
181
|
tabIndex: null,
|
|
@@ -190,7 +190,7 @@ const floatingToolbarPlugin = (_, api) => {
|
|
|
190
190
|
return null;
|
|
191
191
|
}
|
|
192
192
|
let customPositionCalculation;
|
|
193
|
-
const toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node));
|
|
193
|
+
const toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration);
|
|
194
194
|
if (onPositionCalculated) {
|
|
195
195
|
customPositionCalculation = nextPos => {
|
|
196
196
|
return onPositionCalculated(editorView, nextPos);
|
|
@@ -245,7 +245,8 @@ const floatingToolbarPlugin = (_, api) => {
|
|
|
245
245
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
246
246
|
extensionsProvider: extensionsState === null || extensionsState === void 0 ? void 0 : extensionsState.extensionProvider,
|
|
247
247
|
scrollable: scrollable,
|
|
248
|
-
featureFlags: featureFlags
|
|
248
|
+
featureFlags: featureFlags,
|
|
249
|
+
api: api
|
|
249
250
|
})), /*#__PURE__*/React.createElement(ConfirmationModal, {
|
|
250
251
|
testId: "ak-floating-toolbar-confirmation-modal",
|
|
251
252
|
options: confirmDialogOptions,
|
|
@@ -23,7 +23,6 @@ import { EmojiPickerButton } from './EmojiPickerButton';
|
|
|
23
23
|
import Announcer from '../../../utils/announcer/announcer';
|
|
24
24
|
import { injectIntl } from 'react-intl-next';
|
|
25
25
|
import messages from './messages';
|
|
26
|
-
import { decorationStateKey, ACTIONS } from '../../base/pm-plugins/decoration';
|
|
27
26
|
import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
|
|
28
27
|
import ScrollButtons from './ScrollButtons';
|
|
29
28
|
import { ToolbarArrowKeyNavigationProvider } from '../../../ui/ToolbarArrowKeyNavigationProvider';
|
|
@@ -365,6 +364,7 @@ class Toolbar extends Component {
|
|
|
365
364
|
table
|
|
366
365
|
}) {
|
|
367
366
|
if (this.props.editorView) {
|
|
367
|
+
var _this$props$api;
|
|
368
368
|
const {
|
|
369
369
|
state,
|
|
370
370
|
dispatch
|
|
@@ -372,9 +372,7 @@ class Toolbar extends Component {
|
|
|
372
372
|
if (table) {
|
|
373
373
|
return clearHoverSelection()(state, dispatch);
|
|
374
374
|
}
|
|
375
|
-
|
|
376
|
-
action: ACTIONS.DECORATION_REMOVE
|
|
377
|
-
}));
|
|
375
|
+
(_this$props$api = this.props.api) === null || _this$props$api === void 0 ? void 0 : _this$props$api.dependencies.decorations.actions.removeDecoration(state, dispatch);
|
|
378
376
|
}
|
|
379
377
|
}
|
|
380
378
|
setDisableScroll(disabled) {
|
|
@@ -4,11 +4,11 @@ import { default as createLayoutPlugin } from './pm-plugins/main';
|
|
|
4
4
|
import { buildToolbar } from './toolbar';
|
|
5
5
|
import { createDefaultLayoutSection } from './actions';
|
|
6
6
|
import { IconLayout } from '../quick-insert/assets';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID,
|
|
7
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
9
9
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
10
10
|
export { pluginKey };
|
|
11
|
-
const layoutPlugin = (options = {}) => ({
|
|
11
|
+
const layoutPlugin = (options = {}, api) => ({
|
|
12
12
|
name: 'layout',
|
|
13
13
|
nodes() {
|
|
14
14
|
return [{
|
|
@@ -34,7 +34,8 @@ const layoutPlugin = (options = {}) => ({
|
|
|
34
34
|
allowSingleColumnLayout
|
|
35
35
|
} = pluginKey.getState(state);
|
|
36
36
|
if (pos !== null) {
|
|
37
|
-
|
|
37
|
+
var _api$dependencies$dec;
|
|
38
|
+
return buildToolbar(state, intl, pos, allowBreakout, addSidebarLayouts, allowSingleColumnLayout, api === null || api === void 0 ? void 0 : (_api$dependencies$dec = api.dependencies.decorations.actions) === null || _api$dependencies$dec === void 0 ? void 0 : _api$dependencies$dec.hoverDecoration);
|
|
38
39
|
}
|
|
39
40
|
return undefined;
|
|
40
41
|
},
|
|
@@ -48,8 +49,9 @@ const layoutPlugin = (options = {}) => ({
|
|
|
48
49
|
priority: 1100,
|
|
49
50
|
icon: () => /*#__PURE__*/React.createElement(IconLayout, null),
|
|
50
51
|
action(insert, state) {
|
|
52
|
+
var _api$dependencies$ana, _api$dependencies$ana2;
|
|
51
53
|
const tr = insert(createDefaultLayoutSection(state));
|
|
52
|
-
|
|
54
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : (_api$dependencies$ana2 = _api$dependencies$ana.actions) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.attachAnalyticsEvent({
|
|
53
55
|
action: ACTION.INSERTED,
|
|
54
56
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
55
57
|
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|
|
@@ -57,7 +59,8 @@ const layoutPlugin = (options = {}) => ({
|
|
|
57
59
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
58
60
|
},
|
|
59
61
|
eventType: EVENT_TYPE.TRACK
|
|
60
|
-
});
|
|
62
|
+
})(tr);
|
|
63
|
+
return tr;
|
|
61
64
|
}
|
|
62
65
|
}]
|
|
63
66
|
}
|
|
@@ -9,7 +9,6 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
9
9
|
import { toolbarMessages } from './toolbar-messages';
|
|
10
10
|
import commonMessages from '../../messages';
|
|
11
11
|
import { setPresetLayout, deleteActiveLayoutNode, getPresetLayout } from './actions';
|
|
12
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
13
12
|
const LAYOUT_TYPES = [{
|
|
14
13
|
id: 'editor.layout.twoEquals',
|
|
15
14
|
type: 'two_equal',
|
|
@@ -54,7 +53,7 @@ const buildLayoutButton = (intl, item, currentLayout) => ({
|
|
|
54
53
|
tabIndex: null
|
|
55
54
|
});
|
|
56
55
|
export const layoutToolbarTitle = 'Layout floating controls';
|
|
57
|
-
export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout) => {
|
|
56
|
+
export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, hoverDecoration) => {
|
|
58
57
|
const node = state.doc.nodeAt(pos);
|
|
59
58
|
if (node) {
|
|
60
59
|
const currentLayout = getPresetLayout(node);
|
|
@@ -71,10 +70,10 @@ export const buildToolbar = (state, intl, pos, _allowBreakout, addSidebarLayouts
|
|
|
71
70
|
testId: commonMessages.remove.id,
|
|
72
71
|
title: intl.formatMessage(commonMessages.remove),
|
|
73
72
|
onClick: deleteActiveLayoutNode,
|
|
74
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
75
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
76
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
77
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
73
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
74
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
75
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
76
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
78
77
|
tabIndex: null
|
|
79
78
|
};
|
|
80
79
|
const layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
|
|
@@ -6,7 +6,6 @@ import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
|
6
6
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
7
7
|
import commonMessages from '../../../messages';
|
|
8
8
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
9
|
-
import { hoverDecoration } from '../../base/pm-plugins/decoration';
|
|
10
9
|
import { getLinkingToolbar, shouldShowMediaLinkToolbar } from './linking';
|
|
11
10
|
import buildLayoutButtons from '../../../ui/MediaAndEmbedsToolbar';
|
|
12
11
|
import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
@@ -14,7 +13,7 @@ import { getPluginState as getMediaAltTextPluginState } from '../pm-plugins/alt-
|
|
|
14
13
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
15
14
|
import { showLinkingToolbar } from '../commands/linking';
|
|
16
15
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
17
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID,
|
|
16
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
18
17
|
import { messages } from '@atlaskit/media-ui';
|
|
19
18
|
import { messages as cardMessages } from '../../card/messages';
|
|
20
19
|
import { FilePreviewItem } from './filePreviewItem';
|
|
@@ -37,7 +36,7 @@ const handleRemoveMediaGroup = (state, dispatch) => {
|
|
|
37
36
|
}
|
|
38
37
|
return true;
|
|
39
38
|
};
|
|
40
|
-
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
39
|
+
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration) => {
|
|
41
40
|
const {
|
|
42
41
|
mediaGroup
|
|
43
42
|
} = state.schema.nodes;
|
|
@@ -102,17 +101,17 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
|
102
101
|
appearance: 'danger',
|
|
103
102
|
focusEditoronEnter: true,
|
|
104
103
|
icon: RemoveIcon,
|
|
105
|
-
onMouseEnter: hoverDecoration(mediaGroup, true),
|
|
106
|
-
onMouseLeave: hoverDecoration(mediaGroup, false),
|
|
107
|
-
onFocus: hoverDecoration(mediaGroup, true),
|
|
108
|
-
onBlur: hoverDecoration(mediaGroup, false),
|
|
104
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
|
|
105
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
|
|
106
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, true),
|
|
107
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaGroup, false),
|
|
109
108
|
title: intl.formatMessage(commonMessages.remove),
|
|
110
109
|
onClick: handleRemoveMediaGroup,
|
|
111
110
|
testId: 'media-toolbar-remove-button'
|
|
112
111
|
}];
|
|
113
112
|
return items;
|
|
114
113
|
};
|
|
115
|
-
const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
114
|
+
const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration) => {
|
|
116
115
|
const {
|
|
117
116
|
mediaInline
|
|
118
117
|
} = state.schema.nodes;
|
|
@@ -177,17 +176,18 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
|
177
176
|
appearance: 'danger',
|
|
178
177
|
focusEditoronEnter: true,
|
|
179
178
|
icon: RemoveIcon,
|
|
180
|
-
onMouseEnter: hoverDecoration(mediaInline, true),
|
|
181
|
-
onMouseLeave: hoverDecoration(mediaInline, false),
|
|
182
|
-
onFocus: hoverDecoration(mediaInline, true),
|
|
183
|
-
onBlur: hoverDecoration(mediaInline, false),
|
|
179
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
180
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
181
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
182
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
184
183
|
title: intl.formatMessage(commonMessages.remove),
|
|
185
184
|
onClick: removeInlineCard,
|
|
186
185
|
testId: 'media-toolbar-remove-button'
|
|
187
186
|
}];
|
|
188
187
|
return items;
|
|
189
188
|
};
|
|
190
|
-
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState,
|
|
189
|
+
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
|
|
190
|
+
var _pluginInjectionApi$d2;
|
|
191
191
|
const {
|
|
192
192
|
mediaSingle
|
|
193
193
|
} = state.schema.nodes;
|
|
@@ -230,7 +230,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
if (allowAdvancedToolBarOptions) {
|
|
233
|
-
toolbarButtons = [...toolbarButtons, ...buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle,
|
|
233
|
+
toolbarButtons = [...toolbarButtons, ...buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width, allowResizing, allowResizingInTables)];
|
|
234
234
|
if (toolbarButtons.length) {
|
|
235
235
|
toolbarButtons.push({
|
|
236
236
|
type: 'separator'
|
|
@@ -253,16 +253,20 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
253
253
|
};
|
|
254
254
|
const openLink = () => {
|
|
255
255
|
if (editorView) {
|
|
256
|
+
var _pluginInjectionApi$d;
|
|
256
257
|
const {
|
|
257
|
-
state
|
|
258
|
+
state: {
|
|
259
|
+
tr
|
|
260
|
+
},
|
|
258
261
|
dispatch
|
|
259
262
|
} = editorView;
|
|
260
|
-
|
|
263
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions.attachAnalyticsEvent({
|
|
261
264
|
eventType: EVENT_TYPE.TRACK,
|
|
262
265
|
action: ACTION.VISITED,
|
|
263
266
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
264
267
|
actionSubjectId: ACTION_SUBJECT_ID.LINK
|
|
265
|
-
}));
|
|
268
|
+
})(tr);
|
|
269
|
+
dispatch(tr);
|
|
266
270
|
return true;
|
|
267
271
|
}
|
|
268
272
|
};
|
|
@@ -286,16 +290,19 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
286
290
|
type: 'separator'
|
|
287
291
|
});
|
|
288
292
|
}
|
|
293
|
+
const {
|
|
294
|
+
hoverDecoration
|
|
295
|
+
} = (_pluginInjectionApi$d2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d2 !== void 0 ? _pluginInjectionApi$d2 : {};
|
|
289
296
|
const removeButton = {
|
|
290
297
|
id: 'editor.media.delete',
|
|
291
298
|
type: 'button',
|
|
292
299
|
appearance: 'danger',
|
|
293
300
|
focusEditoronEnter: true,
|
|
294
301
|
icon: RemoveIcon,
|
|
295
|
-
onMouseEnter: hoverDecoration(mediaSingle, true),
|
|
296
|
-
onMouseLeave: hoverDecoration(mediaSingle, false),
|
|
297
|
-
onFocus: hoverDecoration(mediaSingle, true),
|
|
298
|
-
onBlur: hoverDecoration(mediaSingle, false),
|
|
302
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
303
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
304
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true),
|
|
305
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false),
|
|
299
306
|
title: intl.formatMessage(commonMessages.remove),
|
|
300
307
|
onClick: remove,
|
|
301
308
|
testId: 'media-toolbar-remove-button'
|
|
@@ -313,6 +320,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
313
320
|
return items;
|
|
314
321
|
};
|
|
315
322
|
export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) => {
|
|
323
|
+
var _pluginInjectionApi$d3;
|
|
316
324
|
const {
|
|
317
325
|
media,
|
|
318
326
|
mediaInline,
|
|
@@ -329,6 +337,9 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
329
337
|
} = options;
|
|
330
338
|
const mediaPluginState = stateKey.getState(state);
|
|
331
339
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
340
|
+
const {
|
|
341
|
+
hoverDecoration
|
|
342
|
+
} = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {};
|
|
332
343
|
if (!mediaPluginState) {
|
|
333
344
|
return;
|
|
334
345
|
}
|
|
@@ -365,21 +376,21 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
365
376
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
366
377
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
367
378
|
};
|
|
368
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState);
|
|
379
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
369
380
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
370
381
|
baseToolbar.getDomRef = () => {
|
|
371
382
|
var _mediaPluginState$ele2;
|
|
372
383
|
const element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(`.${MediaInlineNodeSelector}`);
|
|
373
384
|
return element || mediaPluginState.element;
|
|
374
385
|
};
|
|
375
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState);
|
|
386
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
376
387
|
} else {
|
|
377
388
|
baseToolbar.getDomRef = () => {
|
|
378
389
|
var _mediaPluginState$ele3;
|
|
379
390
|
const element = (_mediaPluginState$ele3 = mediaPluginState.element) === null || _mediaPluginState$ele3 === void 0 ? void 0 : _mediaPluginState$ele3.querySelector(`.${MediaSingleNodeSelector}`);
|
|
380
391
|
return element || mediaPluginState.element;
|
|
381
392
|
};
|
|
382
|
-
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi
|
|
393
|
+
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags);
|
|
383
394
|
}
|
|
384
395
|
return {
|
|
385
396
|
...baseToolbar,
|