@atlaskit/editor-plugin-paste-options-toolbar 9.0.0 → 9.0.1
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 +8 -0
- package/dist/cjs/pm-plugins/plugin-factory.js +33 -33
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +1 -2
- package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.js +1 -1
- package/dist/cjs/ui/on-paste-actions-menu/PasteMenuComponents.js +11 -1
- package/dist/es2019/pm-plugins/plugin-factory.js +4 -5
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +1 -2
- package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.js +1 -1
- package/dist/es2019/ui/on-paste-actions-menu/PasteMenuComponents.js +14 -4
- package/dist/esm/pm-plugins/plugin-factory.js +33 -34
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +1 -2
- package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.js +1 -1
- package/dist/esm/ui/on-paste-actions-menu/PasteMenuComponents.js +12 -2
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +7 -1
- package/dist/types/types/types.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +7 -1
- package/dist/types-ts4.5/types/types.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste-options-toolbar
|
|
2
2
|
|
|
3
|
+
## 9.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`52d4528d79431`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/52d4528d79431) -
|
|
8
|
+
[ux] EDITOR-5896 Minor paste menu cleanup. Reduce padding and remove separator from legacy paste
|
|
9
|
+
actions when there's no AI paste actions
|
|
10
|
+
|
|
3
11
|
## 9.0.0
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -13,45 +13,45 @@ var _constants = require("./constants");
|
|
|
13
13
|
var _reducer = require("./reducer");
|
|
14
14
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
15
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
-
var
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
var dest = (0, _utils.pluginFactory)(_types.pasteOptionsPluginKey, _reducer.reducer, {
|
|
17
|
+
mapping: function mapping(tr, pluginState) {
|
|
18
|
+
if (!tr.docChanged || !pluginState.showToolbar) {
|
|
19
|
+
return pluginState;
|
|
20
|
+
}
|
|
21
|
+
var oldPasteStartPos = pluginState.pasteStartPos;
|
|
22
|
+
var oldPasteEndPos = pluginState.pasteEndPos;
|
|
23
|
+
var newPasteStartPos = tr.mapping.map(oldPasteStartPos);
|
|
24
|
+
var newPasteEndPos = tr.mapping.map(oldPasteEndPos);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
30
|
-
pasteEndPos: newPasteEndPos
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
if (oldPasteStartPos === newPasteStartPos && oldPasteEndPos === newPasteEndPos) {
|
|
34
|
-
return pluginState;
|
|
35
|
-
}
|
|
26
|
+
//this is true when user changes format from the toolbar.
|
|
27
|
+
//only change pasteEndPos in this case
|
|
28
|
+
if (changedFormatFromToolbar(tr)) {
|
|
36
29
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
37
|
-
pasteStartPos: newPasteStartPos,
|
|
38
30
|
pasteEndPos: newPasteEndPos
|
|
39
31
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Detect click outside the editor
|
|
43
|
-
if (tr.getMeta('outsideProsemirrorEditorClicked')) {
|
|
44
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
45
|
-
showToolbar: false,
|
|
46
|
-
highlightContent: false
|
|
47
|
-
});
|
|
48
|
-
}
|
|
32
|
+
}
|
|
33
|
+
if (oldPasteStartPos === newPasteStartPos && oldPasteEndPos === newPasteEndPos) {
|
|
49
34
|
return pluginState;
|
|
50
35
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
37
|
+
pasteStartPos: newPasteStartPos,
|
|
38
|
+
pasteEndPos: newPasteEndPos
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
onSelectionChanged: function onSelectionChanged(tr, pluginState) {
|
|
42
|
+
// Detect click outside the editor
|
|
43
|
+
if (tr.getMeta('outsideProsemirrorEditorClicked')) {
|
|
44
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
45
|
+
showToolbar: false,
|
|
46
|
+
highlightContent: false
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return pluginState;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var createPluginState = exports.createPluginState = dest.createPluginState;
|
|
53
|
+
var createCommand = exports.createCommand = dest.createCommand;
|
|
54
|
+
var getPluginState = exports.getPluginState = dest.getPluginState;
|
|
55
55
|
var changedFormatFromToolbar = function changedFormatFromToolbar(tr) {
|
|
56
56
|
var meta = tr.getMeta(_constants.PASTE_OPTIONS_META_ID);
|
|
57
57
|
if (meta && meta.type === _actions.PastePluginActionTypes.CHANGE_FORMAT) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
3
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -17,7 +17,7 @@ var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
|
|
|
17
17
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
18
18
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
19
19
|
var styles = {
|
|
20
|
-
container: "_2rko12b0
|
|
20
|
+
container: "_2rko12b0 _bfhk1bhr _16qs130s"
|
|
21
21
|
};
|
|
22
22
|
var PasteActionsMenuContent = exports.PasteActionsMenuContent = function PasteActionsMenuContent(_ref) {
|
|
23
23
|
var onMouseDown = _ref.onMouseDown,
|
|
@@ -21,6 +21,7 @@ var _clipboard = _interopRequireDefault(require("@atlaskit/icon/core/clipboard")
|
|
|
21
21
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
22
22
|
var _commands = require("../../editor-commands/commands");
|
|
23
23
|
var _types = require("../../types/types");
|
|
24
|
+
var _hasVisibleButton = require("./hasVisibleButton");
|
|
24
25
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
25
26
|
var nestedMenuStyles = {
|
|
26
27
|
narrowSection: "_10gv1lit"
|
|
@@ -133,8 +134,17 @@ var getPasteMenuComponents = exports.getPasteMenuComponents = function getPasteM
|
|
|
133
134
|
return !((_pluginState$showLega = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showLegacyOptions) !== null && _pluginState$showLega !== void 0 ? _pluginState$showLega : false);
|
|
134
135
|
},
|
|
135
136
|
component: function component(props) {
|
|
137
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
138
|
+
var allComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(_toolbar.PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
139
|
+
var aiMenuItems = allComponents.filter(function (c) {
|
|
140
|
+
var _c$parents;
|
|
141
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
142
|
+
return p.key === _toolbar.AI_PASTE_MENU_SECTION.key;
|
|
143
|
+
}));
|
|
144
|
+
});
|
|
145
|
+
var hasVisibleAiActions = (0, _hasVisibleButton.getVisibleKeys)(aiMenuItems, ['menu-item']).length > 0;
|
|
136
146
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItemSection, {
|
|
137
|
-
hasSeparator:
|
|
147
|
+
hasSeparator: hasVisibleAiActions
|
|
138
148
|
}, props.children);
|
|
139
149
|
}
|
|
140
150
|
}, {
|
|
@@ -3,11 +3,7 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
3
3
|
import { pasteOptionsPluginKey } from '../types/types';
|
|
4
4
|
import { PASTE_OPTIONS_META_ID } from './constants';
|
|
5
5
|
import { reducer } from './reducer';
|
|
6
|
-
|
|
7
|
-
createPluginState,
|
|
8
|
-
createCommand,
|
|
9
|
-
getPluginState
|
|
10
|
-
} = pluginFactory(pasteOptionsPluginKey, reducer, {
|
|
6
|
+
const dest = pluginFactory(pasteOptionsPluginKey, reducer, {
|
|
11
7
|
mapping: (tr, pluginState) => {
|
|
12
8
|
if (!tr.docChanged || !pluginState.showToolbar) {
|
|
13
9
|
return pluginState;
|
|
@@ -46,6 +42,9 @@ export const {
|
|
|
46
42
|
return pluginState;
|
|
47
43
|
}
|
|
48
44
|
});
|
|
45
|
+
export const createPluginState = dest.createPluginState;
|
|
46
|
+
export const createCommand = dest.createCommand;
|
|
47
|
+
export const getPluginState = dest.getPluginState;
|
|
49
48
|
const changedFormatFromToolbar = tr => {
|
|
50
49
|
const meta = tr.getMeta(PASTE_OPTIONS_META_ID);
|
|
51
50
|
if (meta && meta.type === PastePluginActionTypes.CHANGE_FORMAT) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
3
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -9,7 +9,7 @@ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
|
9
9
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
10
10
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
11
11
|
const styles = {
|
|
12
|
-
container: "_2rko12b0
|
|
12
|
+
container: "_2rko12b0 _bfhk1bhr _16qs130s"
|
|
13
13
|
};
|
|
14
14
|
export const PasteActionsMenuContent = ({
|
|
15
15
|
onMouseDown,
|
|
@@ -6,13 +6,14 @@ import { cx } from '@compiled/react';
|
|
|
6
6
|
import { useIntl } from 'react-intl-next';
|
|
7
7
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { useEditorToolbar, PASTE_MENU, PASTE_MENU_SECTION, PASTE_NESTED_MENU, PASTE_MENU_NESTED_SECTION, PASTE_RICH_TEXT_MENU_ITEM, PASTE_MARKDOWN_MENU_ITEM, PASTE_PLAIN_TEXT_MENU_ITEM, PASTE_MENU_RANK, PASTE_MENU_SECTION_RANK, PASTE_NESTED_MENU_RANK, PASTE_MENU_NESTED_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
9
|
+
import { useEditorToolbar, PASTE_MENU, PASTE_MENU_SECTION, PASTE_NESTED_MENU, PASTE_MENU_NESTED_SECTION, PASTE_RICH_TEXT_MENU_ITEM, PASTE_MARKDOWN_MENU_ITEM, PASTE_PLAIN_TEXT_MENU_ITEM, PASTE_MENU_RANK, PASTE_MENU_SECTION_RANK, PASTE_NESTED_MENU_RANK, PASTE_MENU_NESTED_SECTION_RANK, AI_PASTE_MENU_SECTION } from '@atlaskit/editor-common/toolbar';
|
|
10
10
|
import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
11
11
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
12
12
|
import ClipboardIcon from '@atlaskit/icon/core/clipboard';
|
|
13
13
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
14
|
import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics } from '../../editor-commands/commands';
|
|
15
15
|
import { ToolbarDropdownOption } from '../../types/types';
|
|
16
|
+
import { getVisibleKeys } from './hasVisibleButton';
|
|
16
17
|
const nestedMenuStyles = {
|
|
17
18
|
narrowSection: "_10gv1lit"
|
|
18
19
|
};
|
|
@@ -127,9 +128,18 @@ export const getPasteMenuComponents = ({
|
|
|
127
128
|
const pluginState = api === null || api === void 0 ? void 0 : (_api$pasteOptionsTool = api.pasteOptionsToolbarPlugin) === null || _api$pasteOptionsTool === void 0 ? void 0 : _api$pasteOptionsTool.sharedState.currentState();
|
|
128
129
|
return !((_pluginState$showLega = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showLegacyOptions) !== null && _pluginState$showLega !== void 0 ? _pluginState$showLega : false);
|
|
129
130
|
},
|
|
130
|
-
component: props =>
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
component: props => {
|
|
132
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
133
|
+
const allComponents = (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
134
|
+
const aiMenuItems = allComponents.filter(c => {
|
|
135
|
+
var _c$parents;
|
|
136
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(p => p.key === AI_PASTE_MENU_SECTION.key));
|
|
137
|
+
});
|
|
138
|
+
const hasVisibleAiActions = getVisibleKeys(aiMenuItems, ['menu-item']).length > 0;
|
|
139
|
+
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
140
|
+
hasSeparator: hasVisibleAiActions
|
|
141
|
+
}, props.children);
|
|
142
|
+
}
|
|
133
143
|
}, {
|
|
134
144
|
type: PASTE_NESTED_MENU.type,
|
|
135
145
|
key: PASTE_NESTED_MENU.key,
|
|
@@ -6,46 +6,45 @@ import { PastePluginActionTypes } from '../editor-actions/actions';
|
|
|
6
6
|
import { pasteOptionsPluginKey } from '../types/types';
|
|
7
7
|
import { PASTE_OPTIONS_META_ID } from './constants';
|
|
8
8
|
import { reducer } from './reducer';
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
var dest = pluginFactory(pasteOptionsPluginKey, reducer, {
|
|
10
|
+
mapping: function mapping(tr, pluginState) {
|
|
11
|
+
if (!tr.docChanged || !pluginState.showToolbar) {
|
|
12
|
+
return pluginState;
|
|
13
|
+
}
|
|
14
|
+
var oldPasteStartPos = pluginState.pasteStartPos;
|
|
15
|
+
var oldPasteEndPos = pluginState.pasteEndPos;
|
|
16
|
+
var newPasteStartPos = tr.mapping.map(oldPasteStartPos);
|
|
17
|
+
var newPasteEndPos = tr.mapping.map(oldPasteEndPos);
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
23
|
-
pasteEndPos: newPasteEndPos
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (oldPasteStartPos === newPasteStartPos && oldPasteEndPos === newPasteEndPos) {
|
|
27
|
-
return pluginState;
|
|
28
|
-
}
|
|
19
|
+
//this is true when user changes format from the toolbar.
|
|
20
|
+
//only change pasteEndPos in this case
|
|
21
|
+
if (changedFormatFromToolbar(tr)) {
|
|
29
22
|
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
30
|
-
pasteStartPos: newPasteStartPos,
|
|
31
23
|
pasteEndPos: newPasteEndPos
|
|
32
24
|
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Detect click outside the editor
|
|
36
|
-
if (tr.getMeta('outsideProsemirrorEditorClicked')) {
|
|
37
|
-
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
|
-
showToolbar: false,
|
|
39
|
-
highlightContent: false
|
|
40
|
-
});
|
|
41
|
-
}
|
|
25
|
+
}
|
|
26
|
+
if (oldPasteStartPos === newPasteStartPos && oldPasteEndPos === newPasteEndPos) {
|
|
42
27
|
return pluginState;
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
30
|
+
pasteStartPos: newPasteStartPos,
|
|
31
|
+
pasteEndPos: newPasteEndPos
|
|
32
|
+
});
|
|
33
|
+
},
|
|
34
|
+
onSelectionChanged: function onSelectionChanged(tr, pluginState) {
|
|
35
|
+
// Detect click outside the editor
|
|
36
|
+
if (tr.getMeta('outsideProsemirrorEditorClicked')) {
|
|
37
|
+
return _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
38
|
+
showToolbar: false,
|
|
39
|
+
highlightContent: false
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return pluginState;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export var createPluginState = dest.createPluginState;
|
|
46
|
+
export var createCommand = dest.createCommand;
|
|
47
|
+
export var getPluginState = dest.getPluginState;
|
|
49
48
|
var changedFormatFromToolbar = function changedFormatFromToolbar(tr) {
|
|
50
49
|
var meta = tr.getMeta(PASTE_OPTIONS_META_ID);
|
|
51
50
|
if (meta && meta.type === PastePluginActionTypes.CHANGE_FORMAT) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
|
|
2
|
-
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
3
|
-
._1rjc1b66{padding-block:var(--ds-space-050,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
2
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
|
|
4
3
|
._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
|
|
@@ -9,7 +9,7 @@ import { ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
|
|
|
9
9
|
import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
|
|
10
10
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
11
11
|
var styles = {
|
|
12
|
-
container: "_2rko12b0
|
|
12
|
+
container: "_2rko12b0 _bfhk1bhr _16qs130s"
|
|
13
13
|
};
|
|
14
14
|
export var PasteActionsMenuContent = function PasteActionsMenuContent(_ref) {
|
|
15
15
|
var onMouseDown = _ref.onMouseDown,
|
|
@@ -6,13 +6,14 @@ import { cx } from '@compiled/react';
|
|
|
6
6
|
import { useIntl } from 'react-intl-next';
|
|
7
7
|
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
8
8
|
import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
|
|
9
|
-
import { useEditorToolbar, PASTE_MENU, PASTE_MENU_SECTION, PASTE_NESTED_MENU, PASTE_MENU_NESTED_SECTION, PASTE_RICH_TEXT_MENU_ITEM, PASTE_MARKDOWN_MENU_ITEM, PASTE_PLAIN_TEXT_MENU_ITEM, PASTE_MENU_RANK, PASTE_MENU_SECTION_RANK, PASTE_NESTED_MENU_RANK, PASTE_MENU_NESTED_SECTION_RANK } from '@atlaskit/editor-common/toolbar';
|
|
9
|
+
import { useEditorToolbar, PASTE_MENU, PASTE_MENU_SECTION, PASTE_NESTED_MENU, PASTE_MENU_NESTED_SECTION, PASTE_RICH_TEXT_MENU_ITEM, PASTE_MARKDOWN_MENU_ITEM, PASTE_PLAIN_TEXT_MENU_ITEM, PASTE_MENU_RANK, PASTE_MENU_SECTION_RANK, PASTE_NESTED_MENU_RANK, PASTE_MENU_NESTED_SECTION_RANK, AI_PASTE_MENU_SECTION } from '@atlaskit/editor-common/toolbar';
|
|
10
10
|
import { ToolbarDropdownItem, ToolbarDropdownItemSection, ToolbarNestedDropdownMenu } from '@atlaskit/editor-toolbar';
|
|
11
11
|
import ChevronRightIcon from '@atlaskit/icon/core/chevron-right';
|
|
12
12
|
import ClipboardIcon from '@atlaskit/icon/core/clipboard';
|
|
13
13
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
14
14
|
import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics } from '../../editor-commands/commands';
|
|
15
15
|
import { ToolbarDropdownOption } from '../../types/types';
|
|
16
|
+
import { getVisibleKeys } from './hasVisibleButton';
|
|
16
17
|
var nestedMenuStyles = {
|
|
17
18
|
narrowSection: "_10gv1lit"
|
|
18
19
|
};
|
|
@@ -124,8 +125,17 @@ export var getPasteMenuComponents = function getPasteMenuComponents(_ref3) {
|
|
|
124
125
|
return !((_pluginState$showLega = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showLegacyOptions) !== null && _pluginState$showLega !== void 0 ? _pluginState$showLega : false);
|
|
125
126
|
},
|
|
126
127
|
component: function component(props) {
|
|
128
|
+
var _api$uiControlRegistr, _api$uiControlRegistr2;
|
|
129
|
+
var allComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(PASTE_MENU.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
|
|
130
|
+
var aiMenuItems = allComponents.filter(function (c) {
|
|
131
|
+
var _c$parents;
|
|
132
|
+
return c.type === 'menu-item' && ((_c$parents = c.parents) === null || _c$parents === void 0 ? void 0 : _c$parents.some(function (p) {
|
|
133
|
+
return p.key === AI_PASTE_MENU_SECTION.key;
|
|
134
|
+
}));
|
|
135
|
+
});
|
|
136
|
+
var hasVisibleAiActions = getVisibleKeys(aiMenuItems, ['menu-item']).length > 0;
|
|
127
137
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItemSection, {
|
|
128
|
-
hasSeparator:
|
|
138
|
+
hasSeparator: hasVisibleAiActions
|
|
129
139
|
}, props.children);
|
|
130
140
|
}
|
|
131
141
|
}, {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { type PasteOptionsPluginState } from '../types/types';
|
|
3
4
|
export declare function createPlugin(dispatch: Dispatch, options?: {
|
|
4
5
|
useNewPasteMenu?: boolean;
|
|
5
|
-
}): SafePlugin<
|
|
6
|
+
}): SafePlugin<PasteOptionsPluginState>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState, SafeStateField, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type PastePluginAction } from '../editor-actions/actions';
|
|
1
5
|
import type { PasteOptionsPluginState } from '../types/types';
|
|
2
|
-
export declare const createPluginState: (dispatch:
|
|
6
|
+
export declare const createPluginState: (dispatch: Dispatch, initialState: PasteOptionsPluginState | ((state: EditorState) => PasteOptionsPluginState)) => SafeStateField<PasteOptionsPluginState>;
|
|
7
|
+
export declare const createCommand: <A = PastePluginAction>(action: A | ((state: Readonly<EditorState>) => false | A), transform?: (tr: Transaction, state: EditorState) => Transaction) => Command;
|
|
8
|
+
export declare const getPluginState: (state: EditorState) => PasteOptionsPluginState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
export declare const pasteOptionsPluginKey: PluginKey
|
|
4
|
+
export declare const pasteOptionsPluginKey: PluginKey;
|
|
5
5
|
export declare enum ToolbarDropdownOption {
|
|
6
6
|
Markdown = 0,
|
|
7
7
|
RichText = 1,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { type PasteOptionsPluginState } from '../types/types';
|
|
3
4
|
export declare function createPlugin(dispatch: Dispatch, options?: {
|
|
4
5
|
useNewPasteMenu?: boolean;
|
|
5
|
-
}): SafePlugin<
|
|
6
|
+
}): SafePlugin<PasteOptionsPluginState>;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { EditorState, SafeStateField, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { type PastePluginAction } from '../editor-actions/actions';
|
|
1
5
|
import type { PasteOptionsPluginState } from '../types/types';
|
|
2
|
-
export declare const createPluginState: (dispatch:
|
|
6
|
+
export declare const createPluginState: (dispatch: Dispatch, initialState: PasteOptionsPluginState | ((state: EditorState) => PasteOptionsPluginState)) => SafeStateField<PasteOptionsPluginState>;
|
|
7
|
+
export declare const createCommand: <A = PastePluginAction>(action: A | ((state: Readonly<EditorState>) => false | A), transform?: (tr: Transaction, state: EditorState) => Transaction) => Command;
|
|
8
|
+
export declare const getPluginState: (state: EditorState) => PasteOptionsPluginState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
|
-
export declare const pasteOptionsPluginKey: PluginKey
|
|
4
|
+
export declare const pasteOptionsPluginKey: PluginKey;
|
|
5
5
|
export declare enum ToolbarDropdownOption {
|
|
6
6
|
Markdown = 0,
|
|
7
7
|
RichText = 1,
|