@atlaskit/editor-core 184.0.0 → 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/.eslintrc.js +7 -3
- package/CHANGELOG.md +44 -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/ColorPickerButton/index.js +2 -2
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +6 -10
- package/dist/cjs/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/cjs/ui/styles.js +6 -0
- 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/ColorPickerButton/index.js +2 -2
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +5 -10
- package/dist/es2019/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/es2019/ui/styles.js +6 -0
- 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/ColorPickerButton/index.js +2 -2
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +5 -10
- package/dist/esm/ui/ElementBrowser/components/StatelessElementBrowser.js +5 -3
- package/dist/esm/ui/styles.js +6 -0
- 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/ui/ColorPickerButton/index.d.ts +2 -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/dist/types-ts4.5/ui/ColorPickerButton/index.d.ts +2 -2
- package/package.json +23 -18
- 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
|
@@ -61,6 +61,12 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
61
61
|
contentEditable: true
|
|
62
62
|
});
|
|
63
63
|
});
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "onError", function (_ref) {
|
|
65
|
+
var err = _ref.err;
|
|
66
|
+
if (err) {
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
64
70
|
return _this;
|
|
65
71
|
}
|
|
66
72
|
_createClass(BlockCardComponent, [{
|
|
@@ -89,6 +95,7 @@ export var BlockCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
89
95
|
appearance: "block",
|
|
90
96
|
onClick: this.onClick,
|
|
91
97
|
onResolve: this.onResolve,
|
|
98
|
+
onError: this.onError,
|
|
92
99
|
showActions: platform === 'web',
|
|
93
100
|
platform: platform,
|
|
94
101
|
showServerActions: showServerActions
|
|
@@ -233,6 +233,12 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
233
233
|
});
|
|
234
234
|
_this.saveOriginalDimensionsAttributes(height, undefined);
|
|
235
235
|
});
|
|
236
|
+
_defineProperty(_assertThisInitialized(_this), "onError", function (_ref2) {
|
|
237
|
+
var err = _ref2.err;
|
|
238
|
+
if (err) {
|
|
239
|
+
throw err;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
236
242
|
return _this;
|
|
237
243
|
}
|
|
238
244
|
_createClass(EmbedCardComponent, [{
|
|
@@ -287,6 +293,7 @@ export var EmbedCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
287
293
|
appearance: "embed",
|
|
288
294
|
onClick: this.onClick,
|
|
289
295
|
onResolve: this.onResolve,
|
|
296
|
+
onError: this.onError,
|
|
290
297
|
showActions: platform === 'web',
|
|
291
298
|
isFrameVisible: true,
|
|
292
299
|
inheritDimensions: true,
|
|
@@ -46,7 +46,11 @@ export var InlineCardComponent = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
46
46
|
})();
|
|
47
47
|
});
|
|
48
48
|
_defineProperty(_assertThisInitialized(_this), "onError", function (data) {
|
|
49
|
-
var url = data.url
|
|
49
|
+
var url = data.url,
|
|
50
|
+
err = data.err;
|
|
51
|
+
if (err) {
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
50
54
|
_this.onResolve({
|
|
51
55
|
url: url
|
|
52
56
|
});
|
|
@@ -6,8 +6,7 @@ import { NodeSelection, TextSelection } from 'prosemirror-state';
|
|
|
6
6
|
import { closeHistory } from 'prosemirror-history';
|
|
7
7
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
8
8
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
10
|
-
import { SMART_LINK_TYPE } from '../../../plugins/analytics/types/node-events';
|
|
9
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, SMART_LINK_TYPE } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { nodesBetweenChanged, processRawValue } from '../../../utils';
|
|
12
11
|
import { unlinkPayload } from '../../../utils/linking-utils';
|
|
13
12
|
import { isFromCurrentDomain, getLinkCreationAnalyticsEvent } from '@atlaskit/editor-common/utils';
|
|
@@ -9,8 +9,8 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
9
9
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
10
10
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
11
11
|
import OpenIcon from '@atlaskit/icon/glyph/shortcut';
|
|
12
|
-
import { linkToolbarMessages
|
|
13
|
-
import commonMessages from '
|
|
12
|
+
import { linkToolbarMessages } from '../../messages';
|
|
13
|
+
import commonMessages, { linkMessages } from '@atlaskit/editor-common/messages';
|
|
14
14
|
import { changeSelectedCardToText } from './pm-plugins/doc';
|
|
15
15
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
16
16
|
import { pluginKey } from './pm-plugins/main';
|
|
@@ -163,7 +163,7 @@ var withToolbarMetadata = function withToolbarMetadata(command) {
|
|
|
163
163
|
};
|
|
164
164
|
var generateToolbarItems = function generateToolbarItems(state, featureFlags, intl, providerFactory, cardOptions, platform, linkPicker, pluginInjectionApi) {
|
|
165
165
|
return function (node) {
|
|
166
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
166
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$d3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
167
167
|
var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
|
|
168
168
|
url = _titleUrlPairFromNode2.url;
|
|
169
169
|
var _ref = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.analytics) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
@@ -181,7 +181,8 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
181
181
|
}
|
|
182
182
|
var pluginState = pluginKey.getState(state);
|
|
183
183
|
var currentAppearance = appearanceForNodeType(node.type);
|
|
184
|
-
var
|
|
184
|
+
var _ref2 = (_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 : {},
|
|
185
|
+
hoverDecoration = _ref2.hoverDecoration;
|
|
185
186
|
|
|
186
187
|
/* mobile builds toolbar natively using toolbarItems */
|
|
187
188
|
if (pluginState.showLinkingToolbar && platform !== 'mobile') {
|
|
@@ -238,8 +239,8 @@ var generateToolbarItems = function generateToolbarItems(state, featureFlags, in
|
|
|
238
239
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
239
240
|
}]);
|
|
240
241
|
if (currentAppearance === 'embed') {
|
|
241
|
-
var _pluginInjectionApi$
|
|
242
|
-
var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
242
|
+
var _pluginInjectionApi$d6;
|
|
243
|
+
var 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);
|
|
243
244
|
if (alignmentOptions.length) {
|
|
244
245
|
alignmentOptions.push({
|
|
245
246
|
type: 'separator'
|
|
@@ -13,8 +13,8 @@ import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import { Fragment } from 'prosemirror-model';
|
|
15
15
|
import React from 'react';
|
|
16
|
-
import nodeNames from '
|
|
17
|
-
import { isSupportedInParent } from '
|
|
16
|
+
import nodeNames from '@atlaskit/editor-common/messages';
|
|
17
|
+
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
18
18
|
import { messages } from '../messages';
|
|
19
19
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
20
20
|
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
@@ -8,11 +8,11 @@ import { getToolbarConfig } from './toolbar';
|
|
|
8
8
|
import keymap from './pm-plugins/keymaps';
|
|
9
9
|
import ideUX from './pm-plugins/ide-ux';
|
|
10
10
|
import { codeBlockCopySelectionPlugin } from './pm-plugins/codeBlockCopySelectionPlugin';
|
|
11
|
-
import {
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, INPUT_METHOD, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
12
12
|
import { IconCode } from '../quick-insert/assets';
|
|
13
13
|
import { messages } from '../block-type/messages';
|
|
14
14
|
import refreshBrowserSelectionOnChange from './refresh-browser-selection';
|
|
15
|
-
var codeBlockPlugin = function codeBlockPlugin(options) {
|
|
15
|
+
var codeBlockPlugin = function codeBlockPlugin(options, api) {
|
|
16
16
|
return {
|
|
17
17
|
name: 'codeBlock',
|
|
18
18
|
nodes: function nodes() {
|
|
@@ -68,9 +68,10 @@ var codeBlockPlugin = function codeBlockPlugin(options) {
|
|
|
68
68
|
return /*#__PURE__*/React.createElement(IconCode, null);
|
|
69
69
|
},
|
|
70
70
|
action: function action(insert, state) {
|
|
71
|
+
var _api$dependencies$ana;
|
|
71
72
|
var schema = state.schema;
|
|
72
73
|
var tr = insert(schema.nodes.codeBlock.createChecked());
|
|
73
|
-
|
|
74
|
+
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({
|
|
74
75
|
action: ACTION.INSERTED,
|
|
75
76
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
76
77
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -78,11 +79,12 @@ var codeBlockPlugin = function codeBlockPlugin(options) {
|
|
|
78
79
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
79
80
|
},
|
|
80
81
|
eventType: EVENT_TYPE.TRACK
|
|
81
|
-
});
|
|
82
|
+
})(tr);
|
|
83
|
+
return tr;
|
|
82
84
|
}
|
|
83
85
|
}];
|
|
84
86
|
},
|
|
85
|
-
floatingToolbar: getToolbarConfig(options.allowCopyToClipboard)
|
|
87
|
+
floatingToolbar: getToolbarConfig(options.allowCopyToClipboard, api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration)
|
|
86
88
|
}
|
|
87
89
|
};
|
|
88
90
|
};
|
|
@@ -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 var messages = defineMessages({
|
|
@@ -19,6 +18,7 @@ export var messages = defineMessages({
|
|
|
19
18
|
var languageList = createLanguageList(DEFAULT_LANGUAGES);
|
|
20
19
|
export var getToolbarConfig = function getToolbarConfig() {
|
|
21
20
|
var allowCopyToClipboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
21
|
+
var hoverDecoration = arguments.length > 1 ? arguments[1] : undefined;
|
|
22
22
|
return function (state, _ref) {
|
|
23
23
|
var _codeBlockState$pos, _node$attrs;
|
|
24
24
|
var formatMessage = _ref.formatMessage;
|
|
@@ -86,10 +86,10 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
86
86
|
type: 'button',
|
|
87
87
|
appearance: 'danger',
|
|
88
88
|
icon: RemoveIcon,
|
|
89
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
90
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
91
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
92
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
89
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
90
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
91
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
92
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
93
93
|
onClick: removeCodeBlock,
|
|
94
94
|
title: formatMessage(commonMessages.remove),
|
|
95
95
|
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 var createToolbarCopyCommandForNode = function createToolbarCopyCommandFo
|
|
|
135
134
|
return true;
|
|
136
135
|
};
|
|
137
136
|
};
|
|
138
|
-
export var resetCopiedState = function resetCopiedState(nodeType, onMouseLeave) {
|
|
137
|
+
export var resetCopiedState = function resetCopiedState(nodeType, hoverDecoration, onMouseLeave) {
|
|
139
138
|
return function (state, dispatch) {
|
|
140
139
|
var customTr = state.tr;
|
|
141
140
|
|
|
@@ -144,7 +143,7 @@ export var resetCopiedState = function resetCopiedState(nodeType, onMouseLeave)
|
|
|
144
143
|
var customDispatch = function customDispatch(tr) {
|
|
145
144
|
customTr = tr;
|
|
146
145
|
};
|
|
147
|
-
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
146
|
+
onMouseLeave ? onMouseLeave(state, customDispatch) : hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false)(state, customDispatch);
|
|
148
147
|
var copyButtonState = copyButtonPluginKey.getState(state);
|
|
149
148
|
if (copyButtonState !== null && copyButtonState !== void 0 && copyButtonState.copied) {
|
|
150
149
|
customTr.setMeta(copyButtonPluginKey, {
|
|
@@ -3,7 +3,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import CopyIcon from '@atlaskit/icon/glyph/copy';
|
|
5
5
|
import commonMessages from '../../messages';
|
|
6
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
7
6
|
import { createToolbarCopyCommandForNode, createToolbarCopyCommandForMark, resetCopiedState, getProvideMarkVisualFeedbackForCopyButtonCommand, removeMarkVisualFeedbackForCopyButtonCommand } from './commands';
|
|
8
7
|
import { copyButtonPluginKey } from './pm-plugins/plugin-key';
|
|
9
8
|
function isSeparator(item) {
|
|
@@ -12,7 +11,7 @@ function isSeparator(item) {
|
|
|
12
11
|
function isNodeOptions(options) {
|
|
13
12
|
return 'nodeType' in options && options.nodeType !== undefined;
|
|
14
13
|
}
|
|
15
|
-
export function getCopyButtonConfig(options) {
|
|
14
|
+
export function getCopyButtonConfig(options, hoverDecoration) {
|
|
16
15
|
var state = options.state,
|
|
17
16
|
formatMessage = options.formatMessage,
|
|
18
17
|
onMouseEnter = options.onMouseEnter,
|
|
@@ -26,12 +25,12 @@ export function getCopyButtonConfig(options) {
|
|
|
26
25
|
onClick: createToolbarCopyCommandForNode(options.nodeType),
|
|
27
26
|
// Note for future changes: these two handlers should perform
|
|
28
27
|
// the same action.
|
|
29
|
-
onMouseEnter: onMouseEnter || hoverDecoration(options.nodeType, true, 'ak-editor-selected-node'),
|
|
30
|
-
onFocus: onFocus || hoverDecoration(options.nodeType, true, 'ak-editor-selected-node'),
|
|
28
|
+
onMouseEnter: onMouseEnter || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
29
|
+
onFocus: onFocus || (hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(options.nodeType, true, 'ak-editor-selected-node')),
|
|
31
30
|
// Note for future changes: these two handlers should perform
|
|
32
31
|
// the same action.
|
|
33
|
-
onMouseLeave: resetCopiedState(options.nodeType, onMouseLeave),
|
|
34
|
-
onBlur: resetCopiedState(options.nodeType, onBlur)
|
|
32
|
+
onMouseLeave: resetCopiedState(options.nodeType, hoverDecoration, onMouseLeave),
|
|
33
|
+
onBlur: resetCopiedState(options.nodeType, hoverDecoration, onBlur)
|
|
35
34
|
};
|
|
36
35
|
} else {
|
|
37
36
|
buttonActionHandlers = {
|
|
@@ -72,7 +71,7 @@ export var showCopyButton = function showCopyButton(state) {
|
|
|
72
71
|
* else process copy button to standard floatingtoobarbutton
|
|
73
72
|
*/
|
|
74
73
|
export function processCopyButtonItems(state) {
|
|
75
|
-
return function (items) {
|
|
74
|
+
return function (items, hoverDecoration) {
|
|
76
75
|
return items.flatMap(function (item) {
|
|
77
76
|
switch (item.type) {
|
|
78
77
|
case 'copy-button':
|
|
@@ -80,7 +79,7 @@ export function processCopyButtonItems(state) {
|
|
|
80
79
|
return [];
|
|
81
80
|
}
|
|
82
81
|
return item === null || item === void 0 ? void 0 : item.items.map(function (copyButtonItem) {
|
|
83
|
-
return isSeparator(copyButtonItem) ? copyButtonItem : getCopyButtonConfig(copyButtonItem);
|
|
82
|
+
return isSeparator(copyButtonItem) ? copyButtonItem : getCopyButtonConfig(copyButtonItem, hoverDecoration);
|
|
84
83
|
});
|
|
85
84
|
default:
|
|
86
85
|
return [item];
|
|
@@ -38,7 +38,7 @@ var expandPlugin = function expandPlugin() {
|
|
|
38
38
|
}];
|
|
39
39
|
},
|
|
40
40
|
pluginsOptions: {
|
|
41
|
-
floatingToolbar: getToolbarConfig,
|
|
41
|
+
floatingToolbar: getToolbarConfig(api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration),
|
|
42
42
|
quickInsert: function quickInsert(_ref2) {
|
|
43
43
|
var formatMessage = _ref2.formatMessage;
|
|
44
44
|
if (options && options.allowInsertion !== true) {
|
|
@@ -1,47 +1,48 @@
|
|
|
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 var getToolbarConfig = function getToolbarConfig(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
type: 'copy-button',
|
|
5
|
+
export var getToolbarConfig = function getToolbarConfig(hoverDecoration) {
|
|
6
|
+
return function (state, _ref) {
|
|
7
|
+
var formatMessage = _ref.formatMessage;
|
|
8
|
+
var _getPluginState = getPluginState(state),
|
|
9
|
+
expandRef = _getPluginState.expandRef;
|
|
10
|
+
if (expandRef) {
|
|
11
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
12
|
+
nestedExpand = _state$schema$nodes.nestedExpand,
|
|
13
|
+
expand = _state$schema$nodes.expand;
|
|
14
|
+
return {
|
|
15
|
+
title: 'Expand toolbar',
|
|
16
|
+
getDomRef: function getDomRef() {
|
|
17
|
+
return expandRef;
|
|
18
|
+
},
|
|
19
|
+
nodeType: [nestedExpand, expand],
|
|
20
|
+
offset: [0, 6],
|
|
23
21
|
items: [{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
type: 'copy-button',
|
|
23
|
+
items: [{
|
|
24
|
+
state: state,
|
|
25
|
+
formatMessage: formatMessage,
|
|
26
|
+
nodeType: [nestedExpand, expand]
|
|
27
|
+
}, {
|
|
28
|
+
type: 'separator'
|
|
29
|
+
}]
|
|
27
30
|
}, {
|
|
28
|
-
|
|
31
|
+
id: 'editor.expand.delete',
|
|
32
|
+
type: 'button',
|
|
33
|
+
appearance: 'danger',
|
|
34
|
+
focusEditoronEnter: true,
|
|
35
|
+
icon: RemoveIcon,
|
|
36
|
+
onClick: deleteExpand(),
|
|
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),
|
|
41
|
+
title: formatMessage(commonMessages.remove),
|
|
42
|
+
tabIndex: null
|
|
29
43
|
}]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
focusEditoronEnter: true,
|
|
35
|
-
icon: RemoveIcon,
|
|
36
|
-
onClick: deleteExpand(),
|
|
37
|
-
onMouseEnter: hoverDecoration([nestedExpand, expand], true),
|
|
38
|
-
onMouseLeave: hoverDecoration([nestedExpand, expand], false),
|
|
39
|
-
onFocus: hoverDecoration([nestedExpand, expand], true),
|
|
40
|
-
onBlur: hoverDecoration([nestedExpand, expand], false),
|
|
41
|
-
title: formatMessage(commonMessages.remove),
|
|
42
|
-
tabIndex: null
|
|
43
|
-
}]
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
return;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
};
|
|
47
48
|
};
|
|
@@ -47,7 +47,7 @@ var extensionPlugin = function extensionPlugin() {
|
|
|
47
47
|
}];
|
|
48
48
|
},
|
|
49
49
|
pluginsOptions: {
|
|
50
|
-
floatingToolbar: getToolbarConfig(options.breakoutEnabled),
|
|
50
|
+
floatingToolbar: getToolbarConfig(options.breakoutEnabled, api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration),
|
|
51
51
|
contextPanel: getContextPanel(options.allowAutoSave, featureFlags)
|
|
52
52
|
}
|
|
53
53
|
};
|
|
@@ -7,7 +7,6 @@ import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
|
7
7
|
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
8
8
|
import CenterIcon from '@atlaskit/icon/glyph/editor/media-center';
|
|
9
9
|
import commonMessages from '../../messages';
|
|
10
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
11
10
|
import { editExtension } from './actions';
|
|
12
11
|
import { getPluginState } from './pm-plugins/main';
|
|
13
12
|
import { getSelectedExtension } from './utils';
|
|
@@ -114,6 +113,7 @@ var editButton = function editButton(formatMessage, extensionState) {
|
|
|
114
113
|
};
|
|
115
114
|
export var getToolbarConfig = function getToolbarConfig() {
|
|
116
115
|
var breakoutEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
116
|
+
var hoverDecoration = arguments.length > 1 ? arguments[1] : undefined;
|
|
117
117
|
return function (state, intl) {
|
|
118
118
|
var formatMessage = intl.formatMessage;
|
|
119
119
|
var extensionState = getPluginState(state);
|
|
@@ -173,10 +173,10 @@ export var getToolbarConfig = function getToolbarConfig() {
|
|
|
173
173
|
icon: RemoveIcon,
|
|
174
174
|
appearance: 'danger',
|
|
175
175
|
onClick: removeExtension(),
|
|
176
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
177
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
178
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
179
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
176
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
177
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
178
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
179
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
180
180
|
focusEditoronEnter: true,
|
|
181
181
|
title: formatMessage(commonMessages.remove),
|
|
182
182
|
tabIndex: null,
|
|
@@ -194,7 +194,7 @@ var floatingToolbarPlugin = function floatingToolbarPlugin(_, api) {
|
|
|
194
194
|
return null;
|
|
195
195
|
}
|
|
196
196
|
var customPositionCalculation;
|
|
197
|
-
var toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node));
|
|
197
|
+
var toolbarItems = processCopyButtonItems(editorView.state)(Array.isArray(items) ? items : items(node), api === null || api === void 0 ? void 0 : api.dependencies.decorations.actions.hoverDecoration);
|
|
198
198
|
if (onPositionCalculated) {
|
|
199
199
|
customPositionCalculation = function customPositionCalculation(nextPos) {
|
|
200
200
|
return onPositionCalculated(editorView, nextPos);
|
|
@@ -252,7 +252,8 @@ var floatingToolbarPlugin = function floatingToolbarPlugin(_, api) {
|
|
|
252
252
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
253
253
|
extensionsProvider: extensionsState === null || extensionsState === void 0 ? void 0 : extensionsState.extensionProvider,
|
|
254
254
|
scrollable: scrollable,
|
|
255
|
-
featureFlags: featureFlags
|
|
255
|
+
featureFlags: featureFlags,
|
|
256
|
+
api: api
|
|
256
257
|
})), /*#__PURE__*/React.createElement(ConfirmationModal, {
|
|
257
258
|
testId: "ak-floating-toolbar-confirmation-modal",
|
|
258
259
|
options: confirmDialogOptions,
|
|
@@ -33,7 +33,6 @@ import { EmojiPickerButton } from './EmojiPickerButton';
|
|
|
33
33
|
import Announcer from '../../../utils/announcer/announcer';
|
|
34
34
|
import { injectIntl } from 'react-intl-next';
|
|
35
35
|
import messages from './messages';
|
|
36
|
-
import { decorationStateKey, ACTIONS } from '../../base/pm-plugins/decoration';
|
|
37
36
|
import { clearHoverSelection } from '@atlaskit/editor-plugin-table/commands';
|
|
38
37
|
import ScrollButtons from './ScrollButtons';
|
|
39
38
|
import { ToolbarArrowKeyNavigationProvider } from '../../../ui/ToolbarArrowKeyNavigationProvider';
|
|
@@ -367,15 +366,14 @@ var Toolbar = /*#__PURE__*/function (_Component) {
|
|
|
367
366
|
value: function resetStyling(_ref4) {
|
|
368
367
|
var table = _ref4.table;
|
|
369
368
|
if (this.props.editorView) {
|
|
369
|
+
var _this$props$api;
|
|
370
370
|
var _this$props$editorVie2 = this.props.editorView,
|
|
371
371
|
state = _this$props$editorVie2.state,
|
|
372
372
|
dispatch = _this$props$editorVie2.dispatch;
|
|
373
373
|
if (table) {
|
|
374
374
|
return clearHoverSelection()(state, dispatch);
|
|
375
375
|
}
|
|
376
|
-
|
|
377
|
-
action: ACTIONS.DECORATION_REMOVE
|
|
378
|
-
}));
|
|
376
|
+
(_this$props$api = this.props.api) === null || _this$props$api === void 0 ? void 0 : _this$props$api.dependencies.decorations.actions.removeDecoration(state, dispatch);
|
|
379
377
|
}
|
|
380
378
|
}
|
|
381
379
|
}, {
|
|
@@ -4,12 +4,13 @@ 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
11
|
var layoutPlugin = function layoutPlugin() {
|
|
12
12
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
|
+
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
13
14
|
return {
|
|
14
15
|
name: 'layout',
|
|
15
16
|
nodes: function nodes() {
|
|
@@ -37,7 +38,8 @@ var layoutPlugin = function layoutPlugin() {
|
|
|
37
38
|
addSidebarLayouts = _ref.addSidebarLayouts,
|
|
38
39
|
allowSingleColumnLayout = _ref.allowSingleColumnLayout;
|
|
39
40
|
if (pos !== null) {
|
|
40
|
-
|
|
41
|
+
var _api$dependencies$dec;
|
|
42
|
+
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);
|
|
41
43
|
}
|
|
42
44
|
return undefined;
|
|
43
45
|
},
|
|
@@ -53,8 +55,9 @@ var layoutPlugin = function layoutPlugin() {
|
|
|
53
55
|
return /*#__PURE__*/React.createElement(IconLayout, null);
|
|
54
56
|
},
|
|
55
57
|
action: function action(insert, state) {
|
|
58
|
+
var _api$dependencies$ana, _api$dependencies$ana2;
|
|
56
59
|
var tr = insert(createDefaultLayoutSection(state));
|
|
57
|
-
|
|
60
|
+
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({
|
|
58
61
|
action: ACTION.INSERTED,
|
|
59
62
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
60
63
|
actionSubjectId: ACTION_SUBJECT_ID.LAYOUT,
|
|
@@ -62,7 +65,8 @@ var layoutPlugin = function layoutPlugin() {
|
|
|
62
65
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
63
66
|
},
|
|
64
67
|
eventType: EVENT_TYPE.TRACK
|
|
65
|
-
});
|
|
68
|
+
})(tr);
|
|
69
|
+
return tr;
|
|
66
70
|
}
|
|
67
71
|
}];
|
|
68
72
|
}
|
|
@@ -10,7 +10,6 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
10
10
|
import { toolbarMessages } from './toolbar-messages';
|
|
11
11
|
import commonMessages from '../../messages';
|
|
12
12
|
import { setPresetLayout, deleteActiveLayoutNode, getPresetLayout } from './actions';
|
|
13
|
-
import { hoverDecoration } from '../base/pm-plugins/decoration';
|
|
14
13
|
var LAYOUT_TYPES = [{
|
|
15
14
|
id: 'editor.layout.twoEquals',
|
|
16
15
|
type: 'two_equal',
|
|
@@ -57,7 +56,7 @@ var buildLayoutButton = function buildLayoutButton(intl, item, currentLayout) {
|
|
|
57
56
|
};
|
|
58
57
|
};
|
|
59
58
|
export var layoutToolbarTitle = 'Layout floating controls';
|
|
60
|
-
export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout) {
|
|
59
|
+
export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout, addSidebarLayouts, allowSingleColumnLayout, hoverDecoration) {
|
|
61
60
|
var node = state.doc.nodeAt(pos);
|
|
62
61
|
if (node) {
|
|
63
62
|
var currentLayout = getPresetLayout(node);
|
|
@@ -74,10 +73,10 @@ export var buildToolbar = function buildToolbar(state, intl, pos, _allowBreakout
|
|
|
74
73
|
testId: commonMessages.remove.id,
|
|
75
74
|
title: intl.formatMessage(commonMessages.remove),
|
|
76
75
|
onClick: deleteActiveLayoutNode,
|
|
77
|
-
onMouseEnter: hoverDecoration(nodeType, true),
|
|
78
|
-
onMouseLeave: hoverDecoration(nodeType, false),
|
|
79
|
-
onFocus: hoverDecoration(nodeType, true),
|
|
80
|
-
onBlur: hoverDecoration(nodeType, false),
|
|
76
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
77
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
78
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, true),
|
|
79
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(nodeType, false),
|
|
81
80
|
tabIndex: null
|
|
82
81
|
};
|
|
83
82
|
var layoutTypes = allowSingleColumnLayout ? LAYOUT_TYPES_WITH_SINGLE_COL : LAYOUT_TYPES;
|