@atlaskit/editor-plugin-insert-block 1.13.0 → 1.14.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 +23 -0
- package/dist/cjs/plugin.js +23 -3
- package/dist/cjs/ui/ElementBrowser/InsertMenu.js +47 -13
- package/dist/cjs/ui/ElementRail/index.js +186 -2
- package/dist/cjs/ui/ElementRail/useInsertMenuRailItems.js +63 -0
- package/dist/cjs/ui/templateOptions.js +128 -57
- package/dist/cjs/ui/templates.js +1130 -0
- package/dist/es2019/plugin.js +23 -3
- package/dist/es2019/ui/ElementBrowser/InsertMenu.js +61 -26
- package/dist/es2019/ui/ElementRail/index.js +189 -1
- package/dist/es2019/ui/ElementRail/useInsertMenuRailItems.js +54 -0
- package/dist/es2019/ui/templateOptions.js +78 -11
- package/dist/es2019/ui/templates.js +1118 -0
- package/dist/esm/plugin.js +23 -3
- package/dist/esm/ui/ElementBrowser/InsertMenu.js +47 -13
- package/dist/esm/ui/ElementRail/index.js +185 -2
- package/dist/esm/ui/ElementRail/useInsertMenuRailItems.js +56 -0
- package/dist/esm/ui/templateOptions.js +128 -57
- package/dist/esm/ui/templates.js +1124 -0
- package/dist/types/ui/ElementRail/index.d.ts +7 -4
- package/dist/types/ui/ElementRail/useInsertMenuRailItems.d.ts +4 -0
- package/dist/types/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types/ui/templateOptions.d.ts +3 -1
- package/dist/types/ui/templates.d.ts +522 -0
- package/dist/types-ts4.5/ui/ElementRail/index.d.ts +7 -4
- package/dist/types-ts4.5/ui/ElementRail/useInsertMenuRailItems.d.ts +4 -0
- package/dist/types-ts4.5/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- package/dist/types-ts4.5/ui/templateOptions.d.ts +3 -1
- package/dist/types-ts4.5/ui/templates.d.ts +522 -0
- package/package.json +6 -4
package/dist/esm/plugin.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
|
4
4
|
import { contentAllowedInCodeBlock, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
5
5
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
6
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
7
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
8
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
8
9
|
import { getWrappingOptions } from '@atlaskit/editor-common/utils';
|
|
9
10
|
import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
|
|
@@ -56,6 +57,9 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
56
57
|
var toggleDropdownMenuOptionsRef = {
|
|
57
58
|
current: null
|
|
58
59
|
};
|
|
60
|
+
var editorViewRef = {
|
|
61
|
+
current: null
|
|
62
|
+
};
|
|
59
63
|
var registerToggleDropdownMenuOptions = function registerToggleDropdownMenuOptions(cb) {
|
|
60
64
|
toggleDropdownMenuOptionsRef.current = cb;
|
|
61
65
|
return function () {
|
|
@@ -123,6 +127,17 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
123
127
|
plugin: function plugin() {
|
|
124
128
|
return elementBrowserPmPlugin();
|
|
125
129
|
}
|
|
130
|
+
}, {
|
|
131
|
+
name: 'elementBrowserEditorViewRef',
|
|
132
|
+
plugin: function plugin() {
|
|
133
|
+
return new SafePlugin({
|
|
134
|
+
view: function view(editorView) {
|
|
135
|
+
// Workaround - need reference to editorView for contextPanel component
|
|
136
|
+
editorViewRef.current = editorView;
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
126
141
|
}];
|
|
127
142
|
},
|
|
128
143
|
pluginsOptions: {
|
|
@@ -188,10 +203,13 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
188
203
|
// If we decide to ship the feature, we will consider a separate plugin if needed.
|
|
189
204
|
// Experiment one-pager: https://hello.atlassian.net/wiki/spaces/ETM/pages/3983684902/Experiment+Drive+element+usage+via+element+templates
|
|
190
205
|
quickInsert: function quickInsert() {
|
|
191
|
-
|
|
206
|
+
var _options$UNSAFE_edito;
|
|
207
|
+
if (
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
['full-page', 'full-width'].includes((_options$UNSAFE_edito = options.UNSAFE_editorAppearance) !== null && _options$UNSAFE_edito !== void 0 ? _options$UNSAFE_edito : '') && editorExperiment('element-level-templates', true, {
|
|
192
210
|
exposure: true
|
|
193
211
|
})) {
|
|
194
|
-
return templateOptions;
|
|
212
|
+
return templateOptions(api);
|
|
195
213
|
}
|
|
196
214
|
return [];
|
|
197
215
|
}
|
|
@@ -210,8 +228,10 @@ export var insertBlockPlugin = function insertBlockPlugin(_ref) {
|
|
|
210
228
|
// api.getSharedState() will have an outdated reference to editorState on first mount of this component
|
|
211
229
|
// so instead just rely on plugin key as we don't need to be reactive to changes here
|
|
212
230
|
var pluginState = elementBrowserPmKey.getState(state);
|
|
213
|
-
if (pluginState !== null && pluginState !== void 0 && pluginState.menuBrowserOpen) {
|
|
231
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.menuBrowserOpen && editorViewRef.current) {
|
|
214
232
|
return /*#__PURE__*/React.createElement(InsertMenuRail, {
|
|
233
|
+
editorView: editorViewRef.current,
|
|
234
|
+
options: options,
|
|
215
235
|
api: api
|
|
216
236
|
});
|
|
217
237
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
4
5
|
var _excluded = ["children"];
|
|
5
6
|
/**
|
|
@@ -19,8 +20,9 @@ import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlask
|
|
|
19
20
|
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
20
21
|
import { borderRadius } from '@atlaskit/theme';
|
|
21
22
|
import { N0, N30A, N60A } from '@atlaskit/theme/colors';
|
|
23
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
22
24
|
var InsertMenu = function InsertMenu(_ref) {
|
|
23
|
-
var _pluginInjectionApi$
|
|
25
|
+
var _pluginInjectionApi$q7, _pluginInjectionApi$q8;
|
|
24
26
|
var editorView = _ref.editorView,
|
|
25
27
|
dropdownItems = _ref.dropdownItems,
|
|
26
28
|
showElementBrowserLink = _ref.showElementBrowserLink,
|
|
@@ -58,12 +60,19 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
58
60
|
var quickInsertDropdownItems = dropdownItems.map(transform);
|
|
59
61
|
var viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
|
|
60
62
|
var onInsertItem = useCallback(function (item) {
|
|
61
|
-
var _pluginInjectionApi$q;
|
|
62
63
|
toggleVisiblity();
|
|
63
64
|
if (!editorView.hasFocus()) {
|
|
64
65
|
editorView.focus();
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
+
if (editorExperiment('insert-menu-in-right-rail', true)) {
|
|
68
|
+
var _pluginInjectionApi$q;
|
|
69
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 || _pluginInjectionApi$q.actions.insertItem(item,
|
|
70
|
+
// @ts-expect-error
|
|
71
|
+
INPUT_METHOD.INSERT_MENU_RIGHT_RAIL)(editorView.state, editorView.dispatch);
|
|
72
|
+
} else {
|
|
73
|
+
var _pluginInjectionApi$q2;
|
|
74
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q2 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q2 === void 0 || _pluginInjectionApi$q2.actions.insertItem(item, INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
|
|
75
|
+
}
|
|
67
76
|
}, [editorView, toggleVisiblity, pluginInjectionApi]);
|
|
68
77
|
var getItems = useCallback(function (query, category) {
|
|
69
78
|
var result;
|
|
@@ -74,23 +83,35 @@ var InsertMenu = function InsertMenu(_ref) {
|
|
|
74
83
|
* @see above transform function for more details.
|
|
75
84
|
*/
|
|
76
85
|
if (query) {
|
|
77
|
-
var _pluginInjectionApi$
|
|
78
|
-
result = (_pluginInjectionApi$
|
|
86
|
+
var _pluginInjectionApi$q3, _pluginInjectionApi$q4;
|
|
87
|
+
result = (_pluginInjectionApi$q3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q4 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q4 === void 0 ? void 0 : _pluginInjectionApi$q4.actions.getSuggestions({
|
|
79
88
|
query: query,
|
|
80
89
|
category: category
|
|
81
|
-
})) !== null && _pluginInjectionApi$
|
|
90
|
+
})) !== null && _pluginInjectionApi$q3 !== void 0 ? _pluginInjectionApi$q3 : [];
|
|
82
91
|
} else {
|
|
83
|
-
var _pluginInjectionApi$
|
|
84
|
-
var featuredQuickInsertSuggestions = (_pluginInjectionApi$
|
|
92
|
+
var _pluginInjectionApi$q5, _pluginInjectionApi$q6;
|
|
93
|
+
var featuredQuickInsertSuggestions = (_pluginInjectionApi$q5 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions.getSuggestions({
|
|
85
94
|
category: category,
|
|
86
|
-
featuredItems: true
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
featuredItems: true,
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
templateItems: editorExperiment('element-level-templates', true)
|
|
98
|
+
})) !== null && _pluginInjectionApi$q5 !== void 0 ? _pluginInjectionApi$q5 : [];
|
|
99
|
+
if (editorExperiment('element-level-templates', true)) {
|
|
100
|
+
// Make sure template options appear as top 5 items
|
|
101
|
+
featuredQuickInsertSuggestions.sort(function (a, b) {
|
|
102
|
+
var _b$priority, _a$priority;
|
|
103
|
+
return ((_b$priority = b.priority) !== null && _b$priority !== void 0 ? _b$priority : 0) - ((_a$priority = a.priority) !== null && _a$priority !== void 0 ? _a$priority : 0);
|
|
104
|
+
});
|
|
105
|
+
var templateItems = featuredQuickInsertSuggestions.splice(0, 5);
|
|
106
|
+
result = [].concat(_toConsumableArray(templateItems), _toConsumableArray(quickInsertDropdownItems), _toConsumableArray(featuredQuickInsertSuggestions));
|
|
107
|
+
} else {
|
|
108
|
+
result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
|
|
109
|
+
}
|
|
89
110
|
}
|
|
90
111
|
setItemCount(result.length);
|
|
91
112
|
return result;
|
|
92
|
-
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
93
|
-
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
113
|
+
}, [pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q7 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q7 === void 0 ? void 0 : _pluginInjectionApi$q7.actions, quickInsertDropdownItems]);
|
|
114
|
+
var emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$q8 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q8 === void 0 || (_pluginInjectionApi$q8 = _pluginInjectionApi$q8.sharedState.currentState()) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : _pluginInjectionApi$q8.emptyStateHandler;
|
|
94
115
|
return (
|
|
95
116
|
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
96
117
|
jsx("div", {
|
|
@@ -139,6 +160,19 @@ var getInsertMenuHeight = function getInsertMenuHeight(_ref3) {
|
|
|
139
160
|
return 560; // For showing 6 Elements.
|
|
140
161
|
};
|
|
141
162
|
var insertMenuWrapper = function insertMenuWrapper(itemCount) {
|
|
163
|
+
if (editorExperiment('insert-menu-in-right-rail', true)) {
|
|
164
|
+
return css({
|
|
165
|
+
display: 'flex',
|
|
166
|
+
flexDirection: 'column',
|
|
167
|
+
width: '310px',
|
|
168
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
169
|
+
height: 'calc(100% - 32px)',
|
|
170
|
+
margin: "0 -10px",
|
|
171
|
+
backgroundColor: "".concat("var(--ds-surface-overlay, ".concat(N0, ")")),
|
|
172
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
173
|
+
borderRadius: "".concat(borderRadius(), "px")
|
|
174
|
+
});
|
|
175
|
+
}
|
|
142
176
|
return css({
|
|
143
177
|
display: 'flex',
|
|
144
178
|
flexDirection: 'column',
|
|
@@ -1,9 +1,192 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
1
2
|
import React from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
import { IconButton } from '@atlaskit/button/new';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import Heading from '@atlaskit/heading';
|
|
8
|
+
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
9
|
+
import { Box, xcss } from '@atlaskit/primitives';
|
|
10
|
+
import { toggleInsertMenuRightRail } from '../../pm-plugins/commands';
|
|
11
|
+
import InsertMenu from '../ElementBrowser/InsertMenu';
|
|
12
|
+
import { useInsertMenuRailItems } from './useInsertMenuRailItems';
|
|
13
|
+
var panelWrapper = xcss({
|
|
14
|
+
height: '100%'
|
|
15
|
+
});
|
|
16
|
+
var panelContentHeader = xcss({
|
|
17
|
+
height: '32px',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
justifyContent: 'space-between',
|
|
20
|
+
alignItems: 'center'
|
|
21
|
+
});
|
|
22
|
+
|
|
2
23
|
/**
|
|
3
24
|
* For insert menu in right rail experiment
|
|
4
25
|
* - Clean up ticket ED-24801
|
|
5
26
|
*/
|
|
6
27
|
export var InsertMenuRail = function InsertMenuRail(_ref) {
|
|
7
|
-
var
|
|
8
|
-
|
|
28
|
+
var editorView = _ref.editorView,
|
|
29
|
+
options = _ref.options,
|
|
30
|
+
api = _ref.api;
|
|
31
|
+
var dropdownItems = useInsertMenuRailItems(editorView, options, api);
|
|
32
|
+
var _useIntl = useIntl(),
|
|
33
|
+
formatMessage = _useIntl.formatMessage;
|
|
34
|
+
var onInsert = function onInsert(_ref2) {
|
|
35
|
+
var _api$core, _api$hyperlink, _api$imageUpload, _api$media, _api$mention, _api$emoji, _api$codeBlock, _api$blockType, _api$panel, _api$taskDecision, _api$taskDecision2, _api$rule, _api$core2, _api$quickInsert, _api$core3, _api$date, _api$placeholderText, _api$layout, _api$core4, _api$status;
|
|
36
|
+
var item = _ref2.item;
|
|
37
|
+
var state = editorView.state,
|
|
38
|
+
dispatch = editorView.dispatch;
|
|
39
|
+
var inputMethod = INPUT_METHOD.INSERT_MENU_RIGHT_RAIL;
|
|
40
|
+
if (!api) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!editorView.hasFocus()) {
|
|
44
|
+
editorView.focus();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Below is duplicated from ToolbarInsertBlock/index.tsx - this function is only called
|
|
48
|
+
// for BlockMenuItem items, which are rendered in the insert menu when no search has been performed.
|
|
49
|
+
// When a search is performed, the list will be filled by QuickInsertItems, which handle their own insertion.
|
|
50
|
+
switch (item.value.name) {
|
|
51
|
+
case 'link':
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
(_api$core = api.core) === null || _api$core === void 0 || _api$core.actions.execute(api === null || api === void 0 || (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.commands.showLinkToolbar(inputMethod));
|
|
54
|
+
break;
|
|
55
|
+
case 'table':
|
|
56
|
+
// workaround to solve race condition where cursor is not placed correctly inside table
|
|
57
|
+
queueMicrotask(function () {
|
|
58
|
+
var _api$table, _api$table$actions$in, _api$table$actions;
|
|
59
|
+
// @ts-expect-error
|
|
60
|
+
(_api$table = api.table) === null || _api$table === void 0 || (_api$table$actions$in = (_api$table$actions = _api$table.actions).insertTable) === null || _api$table$actions$in === void 0 || _api$table$actions$in.call(_api$table$actions, {
|
|
61
|
+
action: ACTION.INSERTED,
|
|
62
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
63
|
+
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
64
|
+
attributes: {
|
|
65
|
+
inputMethod: inputMethod
|
|
66
|
+
},
|
|
67
|
+
eventType: EVENT_TYPE.TRACK
|
|
68
|
+
})(state, dispatch);
|
|
69
|
+
});
|
|
70
|
+
break;
|
|
71
|
+
case 'image upload':
|
|
72
|
+
(_api$imageUpload = api.imageUpload) === null || _api$imageUpload === void 0 || _api$imageUpload.actions.startUpload()(state, dispatch);
|
|
73
|
+
break;
|
|
74
|
+
case 'media':
|
|
75
|
+
var mediaState = (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
|
|
76
|
+
if (mediaState) {
|
|
77
|
+
var _api$analytics;
|
|
78
|
+
mediaState.showMediaPicker();
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
(_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent({
|
|
81
|
+
action: ACTION.OPENED,
|
|
82
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
83
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
84
|
+
attributes: {
|
|
85
|
+
inputMethod: inputMethod
|
|
86
|
+
},
|
|
87
|
+
eventType: EVENT_TYPE.UI
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
case 'mention':
|
|
92
|
+
var pluginState = (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : _api$mention.sharedState.currentState();
|
|
93
|
+
if (pluginState && pluginState.canInsertMention) {
|
|
94
|
+
var _api$mention2;
|
|
95
|
+
// @ts-expect-error
|
|
96
|
+
(_api$mention2 = api.mention) === null || _api$mention2 === void 0 || (_api$mention2 = _api$mention2.actions) === null || _api$mention2 === void 0 || _api$mention2.openTypeAhead(inputMethod);
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 'emoji':
|
|
100
|
+
// @ts-expect-error
|
|
101
|
+
(_api$emoji = api.emoji) === null || _api$emoji === void 0 || _api$emoji.actions.openTypeAhead(inputMethod);
|
|
102
|
+
break;
|
|
103
|
+
case 'codeblock':
|
|
104
|
+
(_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 || _api$codeBlock.actions.insertCodeBlock(inputMethod);
|
|
105
|
+
break;
|
|
106
|
+
case 'blockquote':
|
|
107
|
+
// @ts-expect-error
|
|
108
|
+
(_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod);
|
|
109
|
+
break;
|
|
110
|
+
case 'panel':
|
|
111
|
+
(_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod);
|
|
112
|
+
break;
|
|
113
|
+
case 'action':
|
|
114
|
+
// @ts-expect-error
|
|
115
|
+
(_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 || _api$taskDecision.actions.insertTaskDecision('taskList', inputMethod)(state, dispatch);
|
|
116
|
+
break;
|
|
117
|
+
case 'decision':
|
|
118
|
+
// @ts-expect-error
|
|
119
|
+
(_api$taskDecision2 = api.taskDecision) === null || _api$taskDecision2 === void 0 || _api$taskDecision2.actions.insertTaskDecision('decisionList', inputMethod)(state, dispatch);
|
|
120
|
+
break;
|
|
121
|
+
case 'horizontalrule':
|
|
122
|
+
// @ts-expect-error
|
|
123
|
+
(_api$rule = api.rule) === null || _api$rule === void 0 || _api$rule.actions.insertHorizontalRule(inputMethod)(state, dispatch);
|
|
124
|
+
break;
|
|
125
|
+
case 'macro':
|
|
126
|
+
(_api$core2 = api.core) === null || _api$core2 === void 0 || _api$core2.actions.execute((_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.commands.openElementBrowserModal);
|
|
127
|
+
break;
|
|
128
|
+
case 'date':
|
|
129
|
+
(_api$core3 = api.core) === null || _api$core3 === void 0 || _api$core3.actions.execute((_api$date = api.date) === null || _api$date === void 0 || (_api$date = _api$date.commands) === null || _api$date === void 0 ? void 0 : _api$date.insertDate({
|
|
130
|
+
// @ts-expect-error
|
|
131
|
+
inputMethod: inputMethod
|
|
132
|
+
}));
|
|
133
|
+
break;
|
|
134
|
+
case 'placeholder text':
|
|
135
|
+
(_api$placeholderText = api.placeholderText) === null || _api$placeholderText === void 0 || _api$placeholderText.actions.showPlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
|
|
136
|
+
break;
|
|
137
|
+
case 'layout':
|
|
138
|
+
// @ts-expect-error
|
|
139
|
+
(_api$layout = api.layout) === null || _api$layout === void 0 || _api$layout.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
|
|
140
|
+
break;
|
|
141
|
+
case 'status':
|
|
142
|
+
// @ts-expect-error
|
|
143
|
+
(_api$core4 = api.core) === null || _api$core4 === void 0 || _api$core4.actions.execute((_api$status = api.status) === null || _api$status === void 0 || (_api$status = _api$status.commands) === null || _api$status === void 0 ? void 0 : _api$status.insertStatus(inputMethod));
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
// https://product-fabric.atlassian.net/browse/ED-8053
|
|
147
|
+
// @ts-ignore: OK to fallthrough to default
|
|
148
|
+
case 'expand':
|
|
149
|
+
if (options.allowExpand) {
|
|
150
|
+
var _api$expand;
|
|
151
|
+
(_api$expand = api.expand) === null || _api$expand === void 0 || _api$expand.actions.insertExpand(state, dispatch);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// eslint-disable-next-line no-fallthrough
|
|
156
|
+
default:
|
|
157
|
+
// leaving this blank for now
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
161
|
+
xcss: panelWrapper
|
|
162
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
163
|
+
xcss: panelContentHeader
|
|
164
|
+
}, /*#__PURE__*/React.createElement(Heading, {
|
|
165
|
+
size: "small",
|
|
166
|
+
as: "h2"
|
|
167
|
+
}, formatMessage(toolbarInsertBlockMessages.insertRightRailTitle)), /*#__PURE__*/React.createElement(IconButton, {
|
|
168
|
+
appearance: "subtle",
|
|
169
|
+
testId: "right-rail-insert-menu-close-button",
|
|
170
|
+
label: formatMessage(toolbarInsertBlockMessages.closeInsertRightRail),
|
|
171
|
+
icon: CrossIcon,
|
|
172
|
+
onClick: function onClick() {
|
|
173
|
+
if (!api) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
api.core.actions.execute(function (_ref3) {
|
|
177
|
+
var _api$contextPanel;
|
|
178
|
+
var tr = _ref3.tr;
|
|
179
|
+
toggleInsertMenuRightRail(tr);
|
|
180
|
+
(_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 || _api$contextPanel.actions.applyChange(tr);
|
|
181
|
+
return tr;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
})), /*#__PURE__*/React.createElement(InsertMenu, {
|
|
185
|
+
editorView: editorView,
|
|
186
|
+
dropdownItems: dropdownItems,
|
|
187
|
+
onInsert: onInsert,
|
|
188
|
+
toggleVisiblity: function toggleVisiblity() {},
|
|
189
|
+
showElementBrowserLink: true,
|
|
190
|
+
pluginInjectionApi: api
|
|
191
|
+
}));
|
|
9
192
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
import { useIntl } from 'react-intl-next';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { createItems } from '../ToolbarInsertBlock/create-items';
|
|
6
|
+
export var useInsertMenuRailItems = function useInsertMenuRailItems(editorView, options, api) {
|
|
7
|
+
var _useIntl = useIntl(),
|
|
8
|
+
formatMessage = _useIntl.formatMessage;
|
|
9
|
+
var _useSharedPluginState = useSharedPluginState(api, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']),
|
|
10
|
+
dateState = _useSharedPluginState.dateState,
|
|
11
|
+
hyperlinkState = _useSharedPluginState.hyperlinkState,
|
|
12
|
+
imageUploadState = _useSharedPluginState.imageUploadState,
|
|
13
|
+
mentionState = _useSharedPluginState.mentionState,
|
|
14
|
+
emojiState = _useSharedPluginState.emojiState,
|
|
15
|
+
blockTypeState = _useSharedPluginState.blockTypeState,
|
|
16
|
+
mediaState = _useSharedPluginState.mediaState,
|
|
17
|
+
typeAheadState = _useSharedPluginState.typeAheadState,
|
|
18
|
+
placeholderTextState = _useSharedPluginState.placeholderTextState;
|
|
19
|
+
var _useMemo = useMemo(function () {
|
|
20
|
+
var _ref;
|
|
21
|
+
return createItems({
|
|
22
|
+
isTypeAheadAllowed: Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isAllowed),
|
|
23
|
+
tableSupported: !!editorView.state.schema.nodes.table,
|
|
24
|
+
tableSelectorSupported: options.tableSelectorSupported && !!editorView.state.schema.nodes.table,
|
|
25
|
+
mediaUploadsEnabled: (_ref = mediaState && mediaState.allowsUploads) !== null && _ref !== void 0 ? _ref : undefined,
|
|
26
|
+
mediaSupported: !!mediaState,
|
|
27
|
+
imageUploadSupported: !!(api !== null && api !== void 0 && api.imageUpload),
|
|
28
|
+
imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
|
|
29
|
+
mentionsSupported: !!(mentionState && mentionState.mentionProvider),
|
|
30
|
+
mentionsDisabled: !!(mentionState && !mentionState.canInsertMention),
|
|
31
|
+
actionSupported: !!editorView.state.schema.nodes.taskItem,
|
|
32
|
+
decisionSupported: !!editorView.state.schema.nodes.decisionItem,
|
|
33
|
+
linkSupported: !!hyperlinkState,
|
|
34
|
+
linkDisabled: !hyperlinkState || !hyperlinkState.canInsertLink || !!hyperlinkState.activeLinkMark,
|
|
35
|
+
emojiDisabled: !emojiState || !emojiState.emojiProvider,
|
|
36
|
+
nativeStatusSupported: options.nativeStatusSupported,
|
|
37
|
+
dateEnabled: !!dateState,
|
|
38
|
+
placeholderTextEnabled: placeholderTextState && placeholderTextState.allowInserting,
|
|
39
|
+
horizontalRuleEnabled: options.horizontalRuleEnabled,
|
|
40
|
+
layoutSectionEnabled: Boolean(api === null || api === void 0 ? void 0 : api.layout),
|
|
41
|
+
expandEnabled: !!options.allowExpand,
|
|
42
|
+
showElementBrowserLink: options.showElementBrowserLink,
|
|
43
|
+
emojiProvider: emojiState === null || emojiState === void 0 ? void 0 : emojiState.emojiProvider,
|
|
44
|
+
availableWrapperBlockTypes: blockTypeState && blockTypeState.availableWrapperBlockTypes,
|
|
45
|
+
insertMenuItems: options.insertMenuItems,
|
|
46
|
+
schema: editorView.state.schema,
|
|
47
|
+
numberOfButtons: 10,
|
|
48
|
+
formatMessage: formatMessage,
|
|
49
|
+
isNewMenuEnabled: true
|
|
50
|
+
});
|
|
51
|
+
}, [api === null || api === void 0 ? void 0 : api.imageUpload, api === null || api === void 0 ? void 0 : api.layout, blockTypeState, dateState, editorView.state.schema, emojiState, formatMessage, hyperlinkState, imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled, mediaState, mentionState, options.allowExpand, options.horizontalRuleEnabled, options.insertMenuItems, options.nativeStatusSupported, options.showElementBrowserLink, options.tableSelectorSupported, placeholderTextState, typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isAllowed]),
|
|
52
|
+
_useMemo2 = _slicedToArray(_useMemo, 2),
|
|
53
|
+
_ = _useMemo2[0],
|
|
54
|
+
dropdownItems = _useMemo2[1];
|
|
55
|
+
return dropdownItems;
|
|
56
|
+
};
|
|
@@ -1,63 +1,134 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
2
4
|
import ActionListIcon from '../assets/action-list';
|
|
3
5
|
import ApprovalsTrackerIcon from '../assets/approvals-tracker';
|
|
4
6
|
import DecisionMatrixIcon from '../assets/decision-matrix';
|
|
5
7
|
import DiscussionNotesIcon from '../assets/discussion-notes';
|
|
6
8
|
import InstructionsOutlineIcon from '../assets/instructions-outline';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
9
|
+
import { actionList, approvalsTracker, decisionMatrix, discussionNotes, instructionsOutline } from './templates';
|
|
10
|
+
var getTemplateInsertionPayload = function getTemplateInsertionPayload(templateType, source) {
|
|
11
|
+
return {
|
|
12
|
+
action: ACTION.INSERTED,
|
|
13
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
14
|
+
actionSubjectId: 'elementTemplate',
|
|
15
|
+
attributes: {
|
|
16
|
+
inputMethod: source !== null && source !== void 0 ? source : INPUT_METHOD.QUICK_INSERT,
|
|
17
|
+
templateType: templateType
|
|
18
|
+
},
|
|
19
|
+
eventType: EVENT_TYPE.TRACK
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
var getTableWidth = function getTableWidth(api) {
|
|
23
|
+
var _api$table;
|
|
24
|
+
return api !== null && api !== void 0 && (_api$table = api.table) !== null && _api$table !== void 0 && (_api$table = _api$table.sharedState.currentState()) !== null && _api$table !== void 0 && _api$table.isFullWidthModeEnabled ? 1800 : 760;
|
|
25
|
+
};
|
|
26
|
+
export var templateOptions = function templateOptions(api) {
|
|
27
|
+
return [{
|
|
28
|
+
title: 'Discussion notes',
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
id: 'discussionNotes',
|
|
31
|
+
description: 'Record discussion points and action items',
|
|
32
|
+
keywords: ['decisions', 'summary', 'meeting', 'chat', 'debrief', 'track', 'keep track', 'tasks', 'outstanding items', 'owners'],
|
|
33
|
+
// Place templates right after AI item
|
|
34
|
+
priority: 99,
|
|
35
|
+
icon: function icon() {
|
|
36
|
+
return /*#__PURE__*/React.createElement(DiscussionNotesIcon, null);
|
|
37
|
+
},
|
|
38
|
+
action: function action(insert, state, source) {
|
|
39
|
+
var _api$analytics;
|
|
40
|
+
var tr = insert(Fragment.fromJSON(state.schema, discussionNotes(getTableWidth(api))), {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
isTemplate: true
|
|
43
|
+
});
|
|
44
|
+
api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 || _api$analytics.actions.attachAnalyticsEvent(
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
getTemplateInsertionPayload('discussionNotes', source))(tr);
|
|
47
|
+
return tr;
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
title: 'Approvals tracker',
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
id: 'approvalsTracker',
|
|
53
|
+
description: 'Track reviewer approvals and dates',
|
|
54
|
+
keywords: ['reviews', 'requests', 'rejected requests', 'review dates', 'timeline', 'checklist', 'sme timeline', 'sme requests', 'sme check', 'table'],
|
|
55
|
+
priority: 99,
|
|
56
|
+
icon: function icon() {
|
|
57
|
+
return /*#__PURE__*/React.createElement(ApprovalsTrackerIcon, null);
|
|
58
|
+
},
|
|
59
|
+
action: function action(insert, state, source) {
|
|
60
|
+
var _api$analytics2;
|
|
61
|
+
var tr = insert(Fragment.fromJSON(state.schema, approvalsTracker(getTableWidth(api))), {
|
|
62
|
+
// @ts-ignore
|
|
63
|
+
isTemplate: true
|
|
64
|
+
});
|
|
65
|
+
api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent(
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
getTemplateInsertionPayload('approvalsTracker', source))(tr);
|
|
68
|
+
return tr;
|
|
69
|
+
}
|
|
70
|
+
}, {
|
|
71
|
+
title: 'Decision matrix',
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
id: 'decisionMatrix',
|
|
74
|
+
description: 'Compare options and make recommendations',
|
|
75
|
+
keywords: ['pros', 'cons', 'recommended', 'rationale', 'evaluation', 'options', 'choice', 'table'],
|
|
76
|
+
priority: 99,
|
|
77
|
+
icon: function icon() {
|
|
78
|
+
return /*#__PURE__*/React.createElement(DecisionMatrixIcon, null);
|
|
79
|
+
},
|
|
80
|
+
action: function action(insert, state, source) {
|
|
81
|
+
var _api$analytics3;
|
|
82
|
+
var tr = insert(Fragment.fromJSON(state.schema, decisionMatrix(getTableWidth(api))), {
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
isTemplate: true
|
|
85
|
+
});
|
|
86
|
+
api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent(
|
|
87
|
+
// @ts-ignore
|
|
88
|
+
getTemplateInsertionPayload('decisionMatrix', source))(tr);
|
|
89
|
+
return tr;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
title: 'List of actions',
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
id: 'actionList',
|
|
95
|
+
description: 'Track tasks, assignees and deadlines',
|
|
96
|
+
keywords: ['checklist', 'check', 'items', 'shopping list', 'jtbd', 'jobs to be done', 'due date', 'progress', 'task', 'tasks', 'prioritization', 'timeline', 'approvals', 'reviewers', 'review date'],
|
|
97
|
+
priority: 99,
|
|
98
|
+
icon: function icon() {
|
|
99
|
+
return /*#__PURE__*/React.createElement(ActionListIcon, null);
|
|
100
|
+
},
|
|
101
|
+
action: function action(insert, state, source) {
|
|
102
|
+
var _api$analytics4;
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
var tr = insert(Fragment.fromJSON(state.schema, actionList), {
|
|
105
|
+
isTemplate: true
|
|
106
|
+
});
|
|
107
|
+
api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 || _api$analytics4.actions.attachAnalyticsEvent(
|
|
108
|
+
// @ts-ignore
|
|
109
|
+
getTemplateInsertionPayload('actionList', source))(tr);
|
|
110
|
+
return tr;
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
title: 'Instructions outline',
|
|
114
|
+
// @ts-ignore
|
|
115
|
+
id: 'instructionsOutline',
|
|
116
|
+
description: 'Detailed steps for any process',
|
|
117
|
+
keywords: ['steps', 'manual', 'tasks', 'jobs to be done', 'jtbd', 'how-to', 'guide', 'journey', 'checklist', 'tutorial', 'map', 'brochure', 'columns', 'layout', 'help'],
|
|
118
|
+
priority: 99,
|
|
119
|
+
icon: function icon() {
|
|
120
|
+
return /*#__PURE__*/React.createElement(InstructionsOutlineIcon, null);
|
|
121
|
+
},
|
|
122
|
+
action: function action(insert, state, source) {
|
|
123
|
+
var _api$analytics5;
|
|
124
|
+
// @ts-ignore
|
|
125
|
+
var tr = insert(Fragment.fromJSON(state.schema, instructionsOutline), {
|
|
126
|
+
isTemplate: true
|
|
127
|
+
});
|
|
128
|
+
api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || _api$analytics5.actions.attachAnalyticsEvent(
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
getTemplateInsertionPayload('instructionsOutline', source))(tr);
|
|
131
|
+
return tr;
|
|
132
|
+
}
|
|
133
|
+
}];
|
|
134
|
+
};
|