@atlaskit/editor-plugin-insert-block 3.1.2 → 3.1.4

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.
Files changed (51) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/cjs/insertBlockPlugin.js +2 -54
  3. package/dist/cjs/ui/ElementBrowser/InsertMenu.js +14 -64
  4. package/dist/cjs/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  5. package/dist/cjs/ui/ToolbarInsertBlock/block-insert-menu.js +1 -6
  6. package/dist/cjs/ui/ToolbarInsertBlock/index.js +28 -77
  7. package/dist/es2019/insertBlockPlugin.js +2 -52
  8. package/dist/es2019/ui/ElementBrowser/InsertMenu.js +14 -64
  9. package/dist/es2019/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  10. package/dist/es2019/ui/ToolbarInsertBlock/block-insert-menu.js +1 -7
  11. package/dist/es2019/ui/ToolbarInsertBlock/index.js +19 -72
  12. package/dist/esm/insertBlockPlugin.js +2 -54
  13. package/dist/esm/ui/ElementBrowser/InsertMenu.js +14 -64
  14. package/dist/esm/ui/ToolbarInsertBlock/block-insert-element-browser.js +1 -1
  15. package/dist/esm/ui/ToolbarInsertBlock/block-insert-menu.js +1 -6
  16. package/dist/esm/ui/ToolbarInsertBlock/index.js +28 -77
  17. package/dist/types/types/index.d.ts +0 -1
  18. package/dist/types/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -1
  19. package/dist/types-ts4.5/types/index.d.ts +0 -1
  20. package/dist/types-ts4.5/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -1
  21. package/package.json +4 -4
  22. package/dist/cjs/pm-plugins/commands.js +0 -16
  23. package/dist/cjs/pm-plugins/elementBrowser.js +0 -39
  24. package/dist/cjs/ui/ElementRail/index.js +0 -236
  25. package/dist/cjs/ui/assets/expand.js +0 -40
  26. package/dist/cjs/ui/assets/switch.js +0 -26
  27. package/dist/cjs/ui/transformOptions.js +0 -36
  28. package/dist/es2019/pm-plugins/commands.js +0 -11
  29. package/dist/es2019/pm-plugins/elementBrowser.js +0 -31
  30. package/dist/es2019/ui/ElementRail/index.js +0 -233
  31. package/dist/es2019/ui/assets/expand.js +0 -34
  32. package/dist/es2019/ui/assets/switch.js +0 -18
  33. package/dist/es2019/ui/transformOptions.js +0 -29
  34. package/dist/esm/pm-plugins/commands.js +0 -11
  35. package/dist/esm/pm-plugins/elementBrowser.js +0 -33
  36. package/dist/esm/ui/ElementRail/index.js +0 -225
  37. package/dist/esm/ui/assets/expand.js +0 -33
  38. package/dist/esm/ui/assets/switch.js +0 -18
  39. package/dist/esm/ui/transformOptions.js +0 -29
  40. package/dist/types/pm-plugins/commands.d.ts +0 -6
  41. package/dist/types/pm-plugins/elementBrowser.d.ts +0 -16
  42. package/dist/types/ui/ElementRail/index.d.ts +0 -21
  43. package/dist/types/ui/assets/expand.d.ts +0 -8
  44. package/dist/types/ui/assets/switch.d.ts +0 -6
  45. package/dist/types/ui/transformOptions.d.ts +0 -27
  46. package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -6
  47. package/dist/types-ts4.5/pm-plugins/elementBrowser.d.ts +0 -16
  48. package/dist/types-ts4.5/ui/ElementRail/index.d.ts +0 -21
  49. package/dist/types-ts4.5/ui/assets/expand.d.ts +0 -8
  50. package/dist/types-ts4.5/ui/assets/switch.d.ts +0 -6
  51. package/dist/types-ts4.5/ui/transformOptions.d.ts +0 -27
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.transformationOptions = void 0;
8
- var _messages = require("@atlaskit/editor-common/messages");
9
- var _angleBracketsEditorCode = _interopRequireDefault(require("@atlaskit/icon/core/migration/angle-brackets--editor-code"));
10
- var _informationEditorInfo = _interopRequireDefault(require("@atlaskit/icon/core/migration/information--editor-info"));
11
- var _quotationMarkQuote = _interopRequireDefault(require("@atlaskit/icon/core/migration/quotation-mark--quote"));
12
- var _expand = _interopRequireDefault(require("./assets/expand"));
13
- var transformationOptions = exports.transformationOptions = function transformationOptions(api, schema) {
14
- var _api$panel, _api$expand, _api$codeBlock, _api$blockType;
15
- return [{
16
- type: schema.nodes.panel,
17
- title: _messages.blockTypeMessages.panel,
18
- icon: _informationEditorInfo.default,
19
- command: api === null || api === void 0 || (_api$panel = api.panel) === null || _api$panel === void 0 ? void 0 : _api$panel.actions.insertPanel
20
- }, {
21
- type: schema.nodes.expand,
22
- title: _messages.toolbarInsertBlockMessages.expand,
23
- icon: _expand.default,
24
- command: api === null || api === void 0 || (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.actions.insertExpandWithInputMethod
25
- }, {
26
- type: schema.nodes.codeBlock,
27
- title: _messages.blockTypeMessages.codeblock,
28
- icon: _angleBracketsEditorCode.default,
29
- command: api === null || api === void 0 || (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 ? void 0 : _api$codeBlock.actions.insertCodeBlock
30
- }, {
31
- type: schema.nodes.blockquote,
32
- title: _messages.blockTypeMessages.blockquote,
33
- icon: _quotationMarkQuote.default,
34
- command: api === null || api === void 0 || (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : _api$blockType.actions.insertBlockQuote
35
- }];
36
- };
@@ -1,11 +0,0 @@
1
- import { elementBrowserPmKey } from './elementBrowser';
2
-
3
- /**
4
- * For insert menu in right rail experiment
5
- * - Clean up ticket ED-24801
6
- */
7
- export const toggleInsertMenuRightRail = tr => {
8
- return tr.setMeta(elementBrowserPmKey, {
9
- update: true
10
- });
11
- };
@@ -1,31 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- /**
4
- * For insert menu in right rail experiment
5
- * - Clean up ticket ED-24801
6
- */
7
- export const elementBrowserPmKey = new PluginKey('elementBrowserPmPlugin');
8
-
9
- /**
10
- * For insert menu in right rail experiment
11
- * - Clean up ticket ED-24801
12
- */
13
- export const elementBrowserPmPlugin = () => new SafePlugin({
14
- key: elementBrowserPmKey,
15
- state: {
16
- init() {
17
- return {
18
- menuBrowserOpen: false
19
- };
20
- },
21
- apply(tr, pluginState) {
22
- const meta = tr.getMeta(elementBrowserPmKey);
23
- if (!meta) {
24
- return pluginState;
25
- }
26
- return {
27
- menuBrowserOpen: !pluginState.menuBrowserOpen
28
- };
29
- }
30
- }
31
- });
@@ -1,233 +0,0 @@
1
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
2
- import React, { useEffect } 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 CloseIcon from '@atlaskit/icon/core/migration/close--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
- const panelWrapper = xcss({
14
- height: '100%'
15
- });
16
- const panelContentHeader = xcss({
17
- height: '32px',
18
- display: 'flex',
19
- justifyContent: 'space-between',
20
- alignItems: 'center'
21
- });
22
-
23
- /**
24
- * For insert menu in right rail experiment
25
- * - Clean up ticket ED-24801
26
- */
27
- export const InsertMenuRail = ({
28
- editorView,
29
- options,
30
- api
31
- }) => {
32
- const dropdownItems = useInsertMenuRailItems(editorView, options, api);
33
- const {
34
- formatMessage
35
- } = useIntl();
36
- const onInsert = ({
37
- item
38
- }) => {
39
- 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$date$commands, _api$placeholderText, _api$layout, _api$core4, _api$status, _api$status$commands;
40
- const {
41
- state,
42
- dispatch
43
- } = editorView;
44
- const inputMethod = INPUT_METHOD.INSERT_MENU_RIGHT_RAIL;
45
- if (!api) {
46
- return;
47
- }
48
- if (!editorView.hasFocus()) {
49
- editorView.focus();
50
- }
51
-
52
- // Below is duplicated from ToolbarInsertBlock/index.tsx - this function is only called
53
- // for BlockMenuItem items, which are rendered in the insert menu when no search has been performed.
54
- // When a search is performed, the list will be filled by QuickInsertItems, which handle their own insertion.
55
- switch (item.value.name) {
56
- case 'link':
57
- // @ts-expect-error
58
- (_api$core = api.core) === null || _api$core === void 0 ? void 0 : _api$core.actions.execute(api === null || api === void 0 ? void 0 : (_api$hyperlink = api.hyperlink) === null || _api$hyperlink === void 0 ? void 0 : _api$hyperlink.commands.showLinkToolbar(inputMethod));
59
- break;
60
- case 'table':
61
- // workaround to solve race condition where cursor is not placed correctly inside table
62
- queueMicrotask(() => {
63
- var _api$table, _api$table$actions$in, _api$table$actions;
64
- // @ts-expect-error
65
- (_api$table = api.table) === null || _api$table === void 0 ? void 0 : (_api$table$actions$in = (_api$table$actions = _api$table.actions).insertTable) === null || _api$table$actions$in === void 0 ? void 0 : _api$table$actions$in.call(_api$table$actions, {
66
- action: ACTION.INSERTED,
67
- actionSubject: ACTION_SUBJECT.DOCUMENT,
68
- actionSubjectId: ACTION_SUBJECT_ID.TABLE,
69
- attributes: {
70
- inputMethod
71
- },
72
- eventType: EVENT_TYPE.TRACK
73
- })(state, dispatch);
74
- });
75
- break;
76
- case 'image upload':
77
- (_api$imageUpload = api.imageUpload) === null || _api$imageUpload === void 0 ? void 0 : _api$imageUpload.actions.startUpload()(state, dispatch);
78
- break;
79
- case 'media':
80
- const mediaState = (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
81
- if (mediaState) {
82
- var _api$analytics;
83
- mediaState.showMediaPicker();
84
- // @ts-expect-error
85
- (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions.attachAnalyticsEvent({
86
- action: ACTION.OPENED,
87
- actionSubject: ACTION_SUBJECT.PICKER,
88
- actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
89
- attributes: {
90
- inputMethod
91
- },
92
- eventType: EVENT_TYPE.UI
93
- });
94
- }
95
- break;
96
- case 'mention':
97
- const pluginState = (_api$mention = api.mention) === null || _api$mention === void 0 ? void 0 : _api$mention.sharedState.currentState();
98
- if (pluginState && pluginState.canInsertMention) {
99
- var _api$mention2, _api$mention2$actions;
100
- // @ts-expect-error
101
- (_api$mention2 = api.mention) === null || _api$mention2 === void 0 ? void 0 : (_api$mention2$actions = _api$mention2.actions) === null || _api$mention2$actions === void 0 ? void 0 : _api$mention2$actions.openTypeAhead(inputMethod);
102
- }
103
- break;
104
- case 'emoji':
105
- // @ts-expect-error
106
- (_api$emoji = api.emoji) === null || _api$emoji === void 0 ? void 0 : _api$emoji.actions.openTypeAhead(inputMethod);
107
- break;
108
- case 'codeblock':
109
- (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 ? void 0 : _api$codeBlock.actions.insertCodeBlock(inputMethod)(state, dispatch);
110
- break;
111
- case 'blockquote':
112
- // @ts-expect-error
113
- (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : _api$blockType.actions.insertBlockQuote(inputMethod)(state, dispatch);
114
- break;
115
- case 'panel':
116
- (_api$panel = api.panel) === null || _api$panel === void 0 ? void 0 : _api$panel.actions.insertPanel(inputMethod)(state, dispatch);
117
- break;
118
- case 'action':
119
- // @ts-expect-error
120
- (_api$taskDecision = api.taskDecision) === null || _api$taskDecision === void 0 ? void 0 : _api$taskDecision.actions.insertTaskDecision('taskList', inputMethod)(state, dispatch);
121
- break;
122
- case 'decision':
123
- // @ts-expect-error
124
- (_api$taskDecision2 = api.taskDecision) === null || _api$taskDecision2 === void 0 ? void 0 : _api$taskDecision2.actions.insertTaskDecision('decisionList', inputMethod)(state, dispatch);
125
- break;
126
- case 'horizontalrule':
127
- // @ts-expect-error
128
- (_api$rule = api.rule) === null || _api$rule === void 0 ? void 0 : _api$rule.actions.insertHorizontalRule(inputMethod)(state, dispatch);
129
- break;
130
- case 'macro':
131
- (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute((_api$quickInsert = api.quickInsert) === null || _api$quickInsert === void 0 ? void 0 : _api$quickInsert.commands.openElementBrowserModal);
132
- break;
133
- case 'date':
134
- (_api$core3 = api.core) === null || _api$core3 === void 0 ? void 0 : _api$core3.actions.execute((_api$date = api.date) === null || _api$date === void 0 ? void 0 : (_api$date$commands = _api$date.commands) === null || _api$date$commands === void 0 ? void 0 : _api$date$commands.insertDate({
135
- // @ts-expect-error
136
- inputMethod
137
- }));
138
- break;
139
- case 'placeholder text':
140
- (_api$placeholderText = api.placeholderText) === null || _api$placeholderText === void 0 ? void 0 : _api$placeholderText.actions.showPlaceholderFloatingToolbar(editorView.state, editorView.dispatch);
141
- break;
142
- case 'layout':
143
- // @ts-expect-error
144
- (_api$layout = api.layout) === null || _api$layout === void 0 ? void 0 : _api$layout.actions.insertLayoutColumns(inputMethod)(editorView.state, editorView.dispatch);
145
- break;
146
- case 'status':
147
- // @ts-expect-error
148
- (_api$core4 = api.core) === null || _api$core4 === void 0 ? void 0 : _api$core4.actions.execute((_api$status = api.status) === null || _api$status === void 0 ? void 0 : (_api$status$commands = _api$status.commands) === null || _api$status$commands === void 0 ? void 0 : _api$status$commands.insertStatus(inputMethod));
149
- break;
150
-
151
- // https://product-fabric.atlassian.net/browse/ED-8053
152
- // @ts-ignore: OK to fallthrough to default
153
- case 'expand':
154
- if (options.allowExpand) {
155
- var _api$expand;
156
- (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.actions.insertExpand(state, dispatch);
157
- break;
158
- }
159
-
160
- // eslint-disable-next-line no-fallthrough
161
- default:
162
- // leaving this blank for now
163
- }
164
- };
165
- useEffect(() => {
166
- if (!api) {
167
- return;
168
- }
169
- api.core.actions.execute(({
170
- tr
171
- }) => {
172
- var _api$analytics2;
173
- (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions.attachAnalyticsEvent({
174
- action: ACTION.OPENED,
175
- // @ts-expect-error
176
- actionSubject: INPUT_METHOD.INSERT_MENU_RIGHT_RAIL,
177
- eventType: EVENT_TYPE.UI
178
- })(tr);
179
- return tr;
180
- });
181
- return () => {
182
- if (!api) {
183
- return;
184
- }
185
- api.core.actions.execute(({
186
- tr
187
- }) => {
188
- var _api$analytics3;
189
- (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions.attachAnalyticsEvent({
190
- action: ACTION.CLOSED,
191
- // @ts-expect-error
192
- actionSubject: INPUT_METHOD.INSERT_MENU_RIGHT_RAIL,
193
- eventType: EVENT_TYPE.UI
194
- })(tr);
195
- return tr;
196
- });
197
- };
198
- }, [api]);
199
- return /*#__PURE__*/React.createElement(Box, {
200
- xcss: panelWrapper
201
- }, /*#__PURE__*/React.createElement(Box, {
202
- xcss: panelContentHeader
203
- }, /*#__PURE__*/React.createElement(Heading, {
204
- size: "small",
205
- as: "h2"
206
- }, formatMessage(toolbarInsertBlockMessages.insertRightRailTitle)), /*#__PURE__*/React.createElement(IconButton, {
207
- appearance: "subtle",
208
- testId: "right-rail-insert-menu-close-button",
209
- label: formatMessage(toolbarInsertBlockMessages.closeInsertRightRail),
210
- icon: CloseIcon,
211
- onClick: () => {
212
- if (!api) {
213
- return;
214
- }
215
- api.core.actions.execute(({
216
- tr
217
- }) => {
218
- var _api$contextPanel;
219
- toggleInsertMenuRightRail(tr);
220
- (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 ? void 0 : _api$contextPanel.actions.applyChange(tr);
221
- return tr;
222
- });
223
- }
224
- })), /*#__PURE__*/React.createElement(InsertMenu, {
225
- editorView: editorView,
226
- dropdownItems: dropdownItems,
227
- onInsert: onInsert,
228
- toggleVisiblity: () => {},
229
- showElementBrowserLink: true,
230
- pluginInjectionApi: api,
231
- isFullPageAppearance: true
232
- }));
233
- };
@@ -1,34 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
6
- import { css, jsx } from '@emotion/react';
7
- const iconContainer = css({
8
- display: 'inline-flex',
9
- justifyContent: 'center',
10
- alignItems: 'center',
11
- width: '24px',
12
- height: '24px'
13
- });
14
- export default function ExpandIcon({
15
- disabled
16
- }) {
17
- return jsx("span", {
18
- css: iconContainer
19
- }, jsx("svg", {
20
- xmlns: "http://www.w3.org/2000/svg",
21
- width: "18",
22
- height: "16",
23
- viewBox: "0 0 18 16",
24
- fill: "none"
25
- }, jsx("path", {
26
- d: "M2 2V14H16V2H2ZM2 0H16C16.5304 0 17.0391 0.210714 17.4142 0.585786C17.7893 0.960859 18 1.46957 18 2V14C18 14.5304 17.7893 15.0391 17.4142 15.4142C17.0391 15.7893 16.5304 16 16 16H2C1.46957 16 0.960859 15.7893 0.585786 15.4142C0.210714 15.0391 0 14.5304 0 14V2C0 1.46957 0.210714 0.960859 0.585786 0.585786C0.960859 0.210714 1.46957 0 2 0Z",
27
- fill: disabled ? "var(--ds-icon-disabled, #B3B9C4)" : "var(--ds-icon, #44546F)"
28
- }), jsx("path", {
29
- fillRule: "evenodd",
30
- clipRule: "evenodd",
31
- d: "M5.29158 6.29294C5.10477 6.48183 5 6.73678 5 7.00244C5 7.2681 5.10477 7.52305 5.29158 7.71194L8.23058 10.6769C8.44858 10.8919 8.73058 10.9989 9.00958 10.9989C9.28858 10.9989 9.56558 10.8919 9.77858 10.6769L12.7086 7.72194C12.8951 7.53292 12.9998 7.27803 12.9998 7.01244C12.9998 6.74686 12.8951 6.49196 12.7086 6.30294C12.6167 6.20976 12.5073 6.13576 12.3866 6.08525C12.2659 6.03474 12.1364 6.00873 12.0056 6.00873C11.8748 6.00873 11.7452 6.03474 11.6245 6.08525C11.5039 6.13576 11.3944 6.20976 11.3026 6.30294L9.00458 8.61994L6.69758 6.29294C6.60554 6.20012 6.49604 6.12644 6.37538 6.07617C6.25472 6.02589 6.1253 6 5.99458 6C5.86386 6 5.73444 6.02589 5.61378 6.07617C5.49312 6.12644 5.38362 6.20012 5.29158 6.29294Z",
32
- fill: disabled ? "var(--ds-icon-disabled, #B3B9C4)" : "var(--ds-icon, #44546F)"
33
- })));
34
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
-
6
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled
7
- import { css, jsx } from '@emotion/react';
8
- import RefreshIcon from '@atlaskit/icon/core/migration/refresh';
9
- const iconStyle = css({
10
- transform: 'rotate(-90deg)'
11
- });
12
- export default function SwitchIcon() {
13
- return jsx("span", {
14
- css: iconStyle
15
- }, jsx(RefreshIcon, {
16
- label: ""
17
- }));
18
- }
@@ -1,29 +0,0 @@
1
- import { blockTypeMessages as messages, toolbarInsertBlockMessages as toolbarMessages } from '@atlaskit/editor-common/messages';
2
- import EditorCodeIcon from '@atlaskit/icon/core/migration/angle-brackets--editor-code';
3
- import EditorInfoIcon from '@atlaskit/icon/core/migration/information--editor-info';
4
- import QuotationMarkIcon from '@atlaskit/icon/core/migration/quotation-mark--quote';
5
- import ExpandIcon from './assets/expand';
6
- export const transformationOptions = (api, schema) => {
7
- var _api$panel, _api$expand, _api$codeBlock, _api$blockType;
8
- return [{
9
- type: schema.nodes.panel,
10
- title: messages.panel,
11
- icon: EditorInfoIcon,
12
- command: api === null || api === void 0 ? void 0 : (_api$panel = api.panel) === null || _api$panel === void 0 ? void 0 : _api$panel.actions.insertPanel
13
- }, {
14
- type: schema.nodes.expand,
15
- title: toolbarMessages.expand,
16
- icon: ExpandIcon,
17
- command: api === null || api === void 0 ? void 0 : (_api$expand = api.expand) === null || _api$expand === void 0 ? void 0 : _api$expand.actions.insertExpandWithInputMethod
18
- }, {
19
- type: schema.nodes.codeBlock,
20
- title: messages.codeblock,
21
- icon: EditorCodeIcon,
22
- command: api === null || api === void 0 ? void 0 : (_api$codeBlock = api.codeBlock) === null || _api$codeBlock === void 0 ? void 0 : _api$codeBlock.actions.insertCodeBlock
23
- }, {
24
- type: schema.nodes.blockquote,
25
- title: messages.blockquote,
26
- icon: QuotationMarkIcon,
27
- command: api === null || api === void 0 ? void 0 : (_api$blockType = api.blockType) === null || _api$blockType === void 0 ? void 0 : _api$blockType.actions.insertBlockQuote
28
- }];
29
- };
@@ -1,11 +0,0 @@
1
- import { elementBrowserPmKey } from './elementBrowser';
2
-
3
- /**
4
- * For insert menu in right rail experiment
5
- * - Clean up ticket ED-24801
6
- */
7
- export var toggleInsertMenuRightRail = function toggleInsertMenuRightRail(tr) {
8
- return tr.setMeta(elementBrowserPmKey, {
9
- update: true
10
- });
11
- };
@@ -1,33 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- /**
4
- * For insert menu in right rail experiment
5
- * - Clean up ticket ED-24801
6
- */
7
- export var elementBrowserPmKey = new PluginKey('elementBrowserPmPlugin');
8
-
9
- /**
10
- * For insert menu in right rail experiment
11
- * - Clean up ticket ED-24801
12
- */
13
- export var elementBrowserPmPlugin = function elementBrowserPmPlugin() {
14
- return new SafePlugin({
15
- key: elementBrowserPmKey,
16
- state: {
17
- init: function init() {
18
- return {
19
- menuBrowserOpen: false
20
- };
21
- },
22
- apply: function apply(tr, pluginState) {
23
- var meta = tr.getMeta(elementBrowserPmKey);
24
- if (!meta) {
25
- return pluginState;
26
- }
27
- return {
28
- menuBrowserOpen: !pluginState.menuBrowserOpen
29
- };
30
- }
31
- }
32
- });
33
- };
@@ -1,225 +0,0 @@
1
- // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
2
- import React, { useEffect } 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 CloseIcon from '@atlaskit/icon/core/migration/close--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
-
23
- /**
24
- * For insert menu in right rail experiment
25
- * - Clean up ticket ED-24801
26
- */
27
- export var InsertMenuRail = function InsertMenuRail(_ref) {
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)(state, dispatch);
105
- break;
106
- case 'blockquote':
107
- // @ts-expect-error
108
- (_api$blockType = api.blockType) === null || _api$blockType === void 0 || _api$blockType.actions.insertBlockQuote(inputMethod)(state, dispatch);
109
- break;
110
- case 'panel':
111
- (_api$panel = api.panel) === null || _api$panel === void 0 || _api$panel.actions.insertPanel(inputMethod)(state, dispatch);
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
- useEffect(function () {
161
- if (!api) {
162
- return;
163
- }
164
- api.core.actions.execute(function (_ref3) {
165
- var _api$analytics2;
166
- var tr = _ref3.tr;
167
- (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 || _api$analytics2.actions.attachAnalyticsEvent({
168
- action: ACTION.OPENED,
169
- // @ts-expect-error
170
- actionSubject: INPUT_METHOD.INSERT_MENU_RIGHT_RAIL,
171
- eventType: EVENT_TYPE.UI
172
- })(tr);
173
- return tr;
174
- });
175
- return function () {
176
- if (!api) {
177
- return;
178
- }
179
- api.core.actions.execute(function (_ref4) {
180
- var _api$analytics3;
181
- var tr = _ref4.tr;
182
- (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 || _api$analytics3.actions.attachAnalyticsEvent({
183
- action: ACTION.CLOSED,
184
- // @ts-expect-error
185
- actionSubject: INPUT_METHOD.INSERT_MENU_RIGHT_RAIL,
186
- eventType: EVENT_TYPE.UI
187
- })(tr);
188
- return tr;
189
- });
190
- };
191
- }, [api]);
192
- return /*#__PURE__*/React.createElement(Box, {
193
- xcss: panelWrapper
194
- }, /*#__PURE__*/React.createElement(Box, {
195
- xcss: panelContentHeader
196
- }, /*#__PURE__*/React.createElement(Heading, {
197
- size: "small",
198
- as: "h2"
199
- }, formatMessage(toolbarInsertBlockMessages.insertRightRailTitle)), /*#__PURE__*/React.createElement(IconButton, {
200
- appearance: "subtle",
201
- testId: "right-rail-insert-menu-close-button",
202
- label: formatMessage(toolbarInsertBlockMessages.closeInsertRightRail),
203
- icon: CloseIcon,
204
- onClick: function onClick() {
205
- if (!api) {
206
- return;
207
- }
208
- api.core.actions.execute(function (_ref5) {
209
- var _api$contextPanel;
210
- var tr = _ref5.tr;
211
- toggleInsertMenuRightRail(tr);
212
- (_api$contextPanel = api.contextPanel) === null || _api$contextPanel === void 0 || _api$contextPanel.actions.applyChange(tr);
213
- return tr;
214
- });
215
- }
216
- })), /*#__PURE__*/React.createElement(InsertMenu, {
217
- editorView: editorView,
218
- dropdownItems: dropdownItems,
219
- onInsert: onInsert,
220
- toggleVisiblity: function toggleVisiblity() {},
221
- showElementBrowserLink: true,
222
- pluginInjectionApi: api,
223
- isFullPageAppearance: true
224
- }));
225
- };