@atlaskit/editor-core 189.4.0 → 189.4.2

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 (131) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/plugins/index.js +0 -14
  3. package/dist/cjs/presets/universal.js +4 -2
  4. package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/es2019/plugins/index.js +0 -2
  7. package/dist/es2019/presets/universal.js +3 -1
  8. package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  9. package/dist/es2019/version-wrapper.js +1 -1
  10. package/dist/esm/plugins/index.js +0 -2
  11. package/dist/esm/presets/universal.js +3 -1
  12. package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +7 -3
  13. package/dist/esm/version-wrapper.js +1 -1
  14. package/dist/types/plugins/index.d.ts +0 -2
  15. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  16. package/package.json +11 -5
  17. package/dist/cjs/plugins/insert-block/index.js +0 -165
  18. package/dist/cjs/plugins/insert-block/types.js +0 -5
  19. package/dist/cjs/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -152
  20. package/dist/cjs/plugins/insert-block/ui/ElementBrowser/types.js +0 -5
  21. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -42
  22. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -42
  23. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -66
  24. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -217
  25. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -49
  26. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -565
  27. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -250
  28. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -12
  29. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -20
  30. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -30
  31. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -11
  32. package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -5
  33. package/dist/cjs/plugins/toolbar-lists-indentation/index.js +0 -91
  34. package/dist/cjs/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -56
  35. package/dist/cjs/plugins/toolbar-lists-indentation/types.js +0 -5
  36. package/dist/cjs/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -135
  37. package/dist/cjs/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -168
  38. package/dist/cjs/plugins/toolbar-lists-indentation/ui/index.js +0 -63
  39. package/dist/cjs/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -53
  40. package/dist/es2019/plugins/insert-block/index.js +0 -159
  41. package/dist/es2019/plugins/insert-block/types.js +0 -1
  42. package/dist/es2019/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -150
  43. package/dist/es2019/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
  44. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
  45. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
  46. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
  47. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -198
  48. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -37
  49. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -558
  50. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -201
  51. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
  52. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -8
  53. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -22
  54. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -16
  55. package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
  56. package/dist/es2019/plugins/toolbar-lists-indentation/index.js +0 -86
  57. package/dist/es2019/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -53
  58. package/dist/es2019/plugins/toolbar-lists-indentation/types.js +0 -1
  59. package/dist/es2019/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -123
  60. package/dist/es2019/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -158
  61. package/dist/es2019/plugins/toolbar-lists-indentation/ui/index.js +0 -58
  62. package/dist/es2019/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -46
  63. package/dist/esm/plugins/insert-block/index.js +0 -158
  64. package/dist/esm/plugins/insert-block/types.js +0 -1
  65. package/dist/esm/plugins/insert-block/ui/ElementBrowser/InsertMenu.js +0 -146
  66. package/dist/esm/plugins/insert-block/ui/ElementBrowser/types.js +0 -1
  67. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.js +0 -35
  68. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.js +0 -35
  69. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.js +0 -59
  70. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/create-items.js +0 -210
  71. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.js +0 -41
  72. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +0 -560
  73. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/item.js +0 -243
  74. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/messages.js +0 -1
  75. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.js +0 -13
  76. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.js +0 -24
  77. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/styles.js +0 -4
  78. package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/types.js +0 -1
  79. package/dist/esm/plugins/toolbar-lists-indentation/index.js +0 -83
  80. package/dist/esm/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.js +0 -50
  81. package/dist/esm/plugins/toolbar-lists-indentation/types.js +0 -1
  82. package/dist/esm/plugins/toolbar-lists-indentation/ui/Toolbar.js +0 -124
  83. package/dist/esm/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.js +0 -161
  84. package/dist/esm/plugins/toolbar-lists-indentation/ui/index.js +0 -56
  85. package/dist/esm/plugins/toolbar-lists-indentation/ui/onItemActivated.js +0 -47
  86. package/dist/types/plugins/insert-block/index.d.ts +0 -16
  87. package/dist/types/plugins/insert-block/types.d.ts +0 -45
  88. package/dist/types/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
  89. package/dist/types/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
  90. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
  91. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
  92. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
  93. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -39
  94. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
  95. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
  96. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
  97. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
  98. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
  99. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
  100. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
  101. package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
  102. package/dist/types/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  103. package/dist/types/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  104. package/dist/types/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  105. package/dist/types/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  106. package/dist/types/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  107. package/dist/types/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  108. package/dist/types/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
  109. package/dist/types-ts4.5/plugins/insert-block/index.d.ts +0 -16
  110. package/dist/types-ts4.5/plugins/insert-block/types.d.ts +0 -45
  111. package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/InsertMenu.d.ts +0 -4
  112. package/dist/types-ts4.5/plugins/insert-block/ui/ElementBrowser/types.d.ts +0 -22
  113. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-element-browser.d.ts +0 -28
  114. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu-legacy.d.ts +0 -18
  115. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/block-insert-menu.d.ts +0 -30
  116. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +0 -42
  117. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/dropdown-button.d.ts +0 -16
  118. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -46
  119. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/item.d.ts +0 -34
  120. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/messages.d.ts +0 -1
  121. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/shallow-equals.d.ts +0 -1
  122. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/sort-items.d.ts +0 -2
  123. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/styles.d.ts +0 -1
  124. package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +0 -59
  125. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/index.d.ts +0 -33
  126. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/pm-plugins/indentation-buttons.d.ts +0 -19
  127. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/types.d.ts +0 -20
  128. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/Toolbar.d.ts +0 -4
  129. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/ToolbarDropdown.d.ts +0 -9
  130. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/index.d.ts +0 -26
  131. package/dist/types-ts4.5/plugins/toolbar-lists-indentation/ui/onItemActivated.d.ts +0 -9
@@ -1,168 +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.ToolbarDropdown = ToolbarDropdown;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = require("@emotion/react");
10
- var _react2 = _interopRequireDefault(require("react"));
11
- var _reactIntlNext = require("react-intl-next");
12
- var _chevronDown = _interopRequireDefault(require("@atlaskit/icon/glyph/chevron-down"));
13
- var _bulletList = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/bullet-list"));
14
- var _keymaps = require("../../../keymaps");
15
- var _uiMenu = require("@atlaskit/editor-common/ui-menu");
16
- var _ToolbarButton = _interopRequireDefault(require("../../../ui/ToolbarButton"));
17
- var _styles = require("../../../ui/styles");
18
- var _styles2 = require("@atlaskit/editor-common/styles");
19
- var _messages = require("@atlaskit/editor-common/messages");
20
- /** @jsx jsx */
21
-
22
- function ToolbarDropdown(props) {
23
- var _useIntl = (0, _reactIntlNext.useIntl)(),
24
- formatMessage = _useIntl.formatMessage;
25
- var disabled = props.disabled,
26
- isReducedSpacing = props.isReducedSpacing,
27
- bulletListActive = props.bulletListActive,
28
- orderedListActive = props.orderedListActive,
29
- popupsMountPoint = props.popupsMountPoint,
30
- popupsBoundariesElement = props.popupsBoundariesElement,
31
- popupsScrollableElement = props.popupsScrollableElement,
32
- onItemActivated = props.onItemActivated;
33
- var _React$useState = _react2.default.useState(false),
34
- _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
35
- isDropdownOpen = _React$useState2[0],
36
- setIsDropdownOpen = _React$useState2[1];
37
- var _React$useState3 = _react2.default.useState(false),
38
- _React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
39
- isOpenedByKeyboard = _React$useState4[0],
40
- setOpenedByKeyboard = _React$useState4[1];
41
- var labelLists = formatMessage(_messages.listMessages.lists);
42
- var onOpenChange = function onOpenChange(attrs) {
43
- setIsDropdownOpen(attrs.isDropdownOpen);
44
- };
45
- var handleTriggerClick = function handleTriggerClick() {
46
- onOpenChange({
47
- isDropdownOpen: !isDropdownOpen
48
- });
49
- };
50
- var handleOnKeyDown = function handleOnKeyDown(event) {
51
- if (event.key === 'Enter' || event.key === ' ') {
52
- event.preventDefault();
53
- setIsDropdownOpen(!isDropdownOpen);
54
- setOpenedByKeyboard(true);
55
- }
56
- };
57
- var items = useItems(props);
58
- var handleOnItemActivated = function handleOnItemActivated(_ref) {
59
- var item = _ref.item,
60
- _ref$shouldCloseMenu = _ref.shouldCloseMenu,
61
- shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
62
- setIsDropdownOpen(!shouldCloseMenu);
63
- return onItemActivated({
64
- editorView: props.editorView,
65
- buttonName: item.value.name
66
- });
67
- };
68
- return (0, _react.jsx)("span", {
69
- css: _styles2.wrapperStyle
70
- }, (0, _react.jsx)(_uiMenu.DropdownMenuWithKeyboardNavigation, {
71
- items: items,
72
- onItemActivated: handleOnItemActivated,
73
- mountTo: popupsMountPoint,
74
- boundariesElement: popupsBoundariesElement,
75
- scrollableElement: popupsScrollableElement,
76
- isOpen: isDropdownOpen,
77
- onOpenChange: onOpenChange,
78
- fitHeight: 188,
79
- fitWidth: 175,
80
- shouldUseDefaultRole: true,
81
- shouldFocusFirstItem: function shouldFocusFirstItem() {
82
- if (isOpenedByKeyboard) {
83
- setOpenedByKeyboard(false);
84
- }
85
- return isOpenedByKeyboard;
86
- }
87
- }, (0, _react.jsx)(_ToolbarButton.default, {
88
- spacing: isReducedSpacing ? 'none' : 'default',
89
- selected: bulletListActive || orderedListActive,
90
- "aria-expanded": isDropdownOpen,
91
- "aria-haspopup": true,
92
- "aria-label": labelLists,
93
- disabled: disabled,
94
- onClick: handleTriggerClick,
95
- onKeyDown: handleOnKeyDown,
96
- title: labelLists,
97
- iconBefore: (0, _react.jsx)("span", {
98
- css: _styles2.wrapperStyle
99
- }, (0, _react.jsx)(_bulletList.default, {
100
- label: labelLists
101
- }), (0, _react.jsx)("span", {
102
- css: _styles2.expandIconWrapperStyle
103
- }, (0, _react.jsx)(_chevronDown.default, {
104
- label: ""
105
- })))
106
- })), (0, _react.jsx)("span", {
107
- css: _styles2.separatorStyles
108
- }));
109
- }
110
- function useItems(props) {
111
- var _useIntl2 = (0, _reactIntlNext.useIntl)(),
112
- formatMessage = _useIntl2.formatMessage;
113
- var labelUnorderedList = formatMessage(_messages.listMessages.unorderedList);
114
- var labelOrderedList = formatMessage(_messages.listMessages.orderedList);
115
- var items = [{
116
- key: 'unorderedList',
117
- content: labelUnorderedList,
118
- value: {
119
- name: 'bullet_list'
120
- },
121
- isDisabled: props.bulletListDisabled,
122
- isActive: Boolean(props.bulletListActive),
123
- elemAfter: (0, _react.jsx)("div", {
124
- css: _styles.shortcutStyle
125
- }, (0, _keymaps.tooltip)(_keymaps.toggleBulletList))
126
- }, {
127
- key: 'orderedList',
128
- content: labelOrderedList,
129
- value: {
130
- name: 'ordered_list'
131
- },
132
- isDisabled: props.orderedListDisabled,
133
- isActive: Boolean(props.orderedListActive),
134
- elemAfter: (0, _react.jsx)("div", {
135
- css: _styles.shortcutStyle
136
- }, (0, _keymaps.tooltip)(_keymaps.toggleOrderedList))
137
- }];
138
- if (props.showIndentationButtons) {
139
- var labelIndent = formatMessage(_messages.indentationMessages.indent);
140
- var labelOutdent = formatMessage(_messages.indentationMessages.outdent);
141
- items.push({
142
- key: 'outdent',
143
- content: labelOutdent,
144
- value: {
145
- name: 'outdent'
146
- },
147
- isDisabled: props.outdentDisabled,
148
- isActive: false,
149
- elemAfter: (0, _react.jsx)("div", {
150
- css: _styles.shortcutStyle
151
- }, (0, _keymaps.tooltip)(_keymaps.outdent))
152
- }, {
153
- key: 'indent',
154
- content: labelIndent,
155
- value: {
156
- name: 'indent'
157
- },
158
- isDisabled: props.indentDisabled,
159
- isActive: false,
160
- elemAfter: (0, _react.jsx)("div", {
161
- css: _styles.shortcutStyle
162
- }, (0, _keymaps.tooltip)(_keymaps.indent))
163
- });
164
- }
165
- return [{
166
- items: items
167
- }];
168
- }
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = ToolbarListsIndentation;
7
- var _react = require("@emotion/react");
8
- var _onItemActivated = require("./onItemActivated");
9
- var _ToolbarDropdown = require("./ToolbarDropdown");
10
- var _Toolbar = require("./Toolbar");
11
- /** @jsx jsx */
12
-
13
- function ToolbarListsIndentation(props) {
14
- var disabled = props.disabled,
15
- isSmall = props.isSmall,
16
- isReducedSpacing = props.isReducedSpacing,
17
- bulletListActive = props.bulletListActive,
18
- bulletListDisabled = props.bulletListDisabled,
19
- orderedListActive = props.orderedListActive,
20
- orderedListDisabled = props.orderedListDisabled,
21
- showIndentationButtons = props.showIndentationButtons,
22
- popupsMountPoint = props.popupsMountPoint,
23
- popupsBoundariesElement = props.popupsBoundariesElement,
24
- popupsScrollableElement = props.popupsScrollableElement,
25
- indentDisabled = props.indentDisabled,
26
- outdentDisabled = props.outdentDisabled,
27
- indentationStateNode = props.indentationStateNode,
28
- featureFlags = props.featureFlags,
29
- pluginInjectionApi = props.pluginInjectionApi;
30
- if (isSmall) {
31
- return (0, _react.jsx)(_ToolbarDropdown.ToolbarDropdown, {
32
- editorView: props.editorView,
33
- isReducedSpacing: isReducedSpacing,
34
- popupsMountPoint: popupsMountPoint,
35
- popupsBoundariesElement: popupsBoundariesElement,
36
- popupsScrollableElement: popupsScrollableElement,
37
- bulletListActive: bulletListActive,
38
- bulletListDisabled: bulletListDisabled,
39
- showIndentationButtons: showIndentationButtons,
40
- orderedListActive: orderedListActive,
41
- orderedListDisabled: orderedListDisabled,
42
- indentDisabled: indentDisabled,
43
- outdentDisabled: outdentDisabled,
44
- disabled: disabled,
45
- onItemActivated: (0, _onItemActivated.onItemActivated)(pluginInjectionApi, indentationStateNode),
46
- featureFlags: featureFlags
47
- });
48
- }
49
- return (0, _react.jsx)(_Toolbar.Toolbar, {
50
- editorView: props.editorView,
51
- isReducedSpacing: isReducedSpacing,
52
- bulletListActive: bulletListActive,
53
- bulletListDisabled: bulletListDisabled,
54
- showIndentationButtons: showIndentationButtons,
55
- orderedListActive: orderedListActive,
56
- orderedListDisabled: orderedListDisabled,
57
- indentDisabled: indentDisabled,
58
- outdentDisabled: outdentDisabled,
59
- disabled: disabled,
60
- onItemActivated: (0, _onItemActivated.onItemActivated)(pluginInjectionApi, indentationStateNode),
61
- featureFlags: featureFlags
62
- });
63
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.onItemActivated = void 0;
7
- var _analytics = require("@atlaskit/editor-common/analytics");
8
- var onItemActivated = exports.onItemActivated = function onItemActivated(pluginInjectionApi, indentationStateNode) {
9
- return function (_ref) {
10
- var buttonName = _ref.buttonName,
11
- editorView = _ref.editorView;
12
- switch (buttonName) {
13
- case 'bullet_list':
14
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleBulletList(_analytics.INPUT_METHOD.TOOLBAR));
15
- break;
16
- case 'ordered_list':
17
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.toggleOrderedList(_analytics.INPUT_METHOD.TOOLBAR));
18
- break;
19
- case 'indent':
20
- {
21
- var node = indentationStateNode;
22
- if (node === 'paragraph_heading') {
23
- var _pluginInjectionApi$i;
24
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i === void 0 || _pluginInjectionApi$i.actions.indentParagraphOrHeading(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
25
- }
26
- if (node === 'list') {
27
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.indentList(_analytics.INPUT_METHOD.TOOLBAR));
28
- }
29
- if (node === 'taskList') {
30
- var _pluginInjectionApi$t;
31
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t === void 0 || _pluginInjectionApi$t.actions.indentTaskList(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
32
- }
33
- break;
34
- }
35
- case 'outdent':
36
- {
37
- var _node = indentationStateNode;
38
- if (_node === 'paragraph_heading') {
39
- var _pluginInjectionApi$i2;
40
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$i2 = pluginInjectionApi.indentation) === null || _pluginInjectionApi$i2 === void 0 || _pluginInjectionApi$i2.actions.outdentParagraphOrHeading(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
41
- }
42
- if (_node === 'list') {
43
- pluginInjectionApi === null || pluginInjectionApi === void 0 || pluginInjectionApi.core.actions.execute(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.list.commands.outdentList(_analytics.INPUT_METHOD.TOOLBAR));
44
- }
45
- if (_node === 'taskList') {
46
- var _pluginInjectionApi$t2;
47
- pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$t2 = pluginInjectionApi.taskDecision) === null || _pluginInjectionApi$t2 === void 0 || _pluginInjectionApi$t2.actions.outdentTaskList(_analytics.INPUT_METHOD.TOOLBAR)(editorView.state, editorView.dispatch);
48
- }
49
- break;
50
- }
51
- }
52
- };
53
- };
@@ -1,159 +0,0 @@
1
- import React from 'react';
2
- import { WithProviders } from '@atlaskit/editor-common/provider-factory';
3
- import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
4
- import { BLOCK_QUOTE, CODE_BLOCK, PANEL } from '@atlaskit/editor-plugin-block-type/consts';
5
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- import { ToolbarSize } from '@atlaskit/editor-common/types';
7
- import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
8
- const toolbarSizeToButtons = toolbarSize => {
9
- switch (toolbarSize) {
10
- case ToolbarSize.XXL:
11
- case ToolbarSize.XL:
12
- case ToolbarSize.L:
13
- case ToolbarSize.M:
14
- return 7;
15
- case ToolbarSize.S:
16
- return 2;
17
- default:
18
- return 0;
19
- }
20
- };
21
- /**
22
- * Wrapper over insertBlockTypeWithAnalytics to autobind toolbar input method
23
- * @param name Block name
24
- */
25
- function handleInsertBlockType(insertCodeBlock, insertPanel, insertBlockQuote) {
26
- return name => {
27
- if (name === CODE_BLOCK.name && insertCodeBlock) {
28
- return insertCodeBlock(INPUT_METHOD.TOOLBAR);
29
- }
30
- if (name === PANEL.name && insertPanel) {
31
- return insertPanel(INPUT_METHOD.TOOLBAR);
32
- }
33
- if (name === BLOCK_QUOTE.name && insertBlockQuote) {
34
- return insertBlockQuote(INPUT_METHOD.TOOLBAR);
35
- }
36
- return () => false;
37
- };
38
- }
39
- const insertBlockPlugin = ({
40
- config: options = {},
41
- api
42
- }) => {
43
- var _api$featureFlags;
44
- const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
45
- return {
46
- name: 'insertBlock',
47
- primaryToolbarComponent({
48
- editorView,
49
- editorActions,
50
- dispatchAnalyticsEvent,
51
- providerFactory,
52
- popupsMountPoint,
53
- popupsBoundariesElement,
54
- popupsScrollableElement,
55
- toolbarSize,
56
- disabled,
57
- isToolbarReducedSpacing,
58
- isLastItem
59
- }) {
60
- const renderNode = providers => {
61
- return /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
62
- pluginInjectionApi: api,
63
- editorView: editorView,
64
- editorActions: editorActions,
65
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
66
- providerFactory: providerFactory,
67
- popupsMountPoint: popupsMountPoint,
68
- popupsBoundariesElement: popupsBoundariesElement,
69
- popupsScrollableElement: popupsScrollableElement,
70
- toolbarSize: toolbarSize,
71
- disabled: disabled,
72
- isToolbarReducedSpacing: isToolbarReducedSpacing,
73
- isLastItem: isLastItem,
74
- featureFlags: featureFlags,
75
- providers: providers,
76
- options: options
77
- });
78
- };
79
- return /*#__PURE__*/React.createElement(WithProviders, {
80
- providerFactory: providerFactory,
81
- providers: ['emojiProvider'],
82
- renderNode: renderNode
83
- });
84
- }
85
- };
86
- };
87
- function ToolbarInsertBlockWithInjectionApi({
88
- editorView,
89
- editorActions,
90
- dispatchAnalyticsEvent,
91
- popupsMountPoint,
92
- popupsBoundariesElement,
93
- popupsScrollableElement,
94
- toolbarSize,
95
- disabled,
96
- isToolbarReducedSpacing,
97
- isLastItem,
98
- providers,
99
- pluginInjectionApi,
100
- options,
101
- featureFlags
102
- }) {
103
- var _ref, _ref2, _pluginInjectionApi$i, _pluginInjectionApi$c, _pluginInjectionApi$p, _pluginInjectionApi$b, _pluginInjectionApi$e;
104
- const buttons = toolbarSizeToButtons(toolbarSize);
105
- const {
106
- dateState,
107
- hyperlinkState,
108
- imageUploadState,
109
- mentionState,
110
- emojiState,
111
- blockTypeState,
112
- mediaState,
113
- typeAheadState,
114
- placeholderTextState
115
- } = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji', 'blockType', 'media', 'typeAhead', 'placeholderText']);
116
- return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
117
- pluginInjectionApi: pluginInjectionApi,
118
- buttons: buttons,
119
- isReducedSpacing: isToolbarReducedSpacing,
120
- isDisabled: disabled,
121
- isTypeAheadAllowed: Boolean(typeAheadState === null || typeAheadState === void 0 ? void 0 : typeAheadState.isAllowed),
122
- editorView: editorView,
123
- tableSupported: !!editorView.state.schema.nodes.table,
124
- actionSupported: !!editorView.state.schema.nodes.taskItem,
125
- mentionsSupported: !!(mentionState && mentionState.mentionProvider),
126
- mentionsDisabled: !!(mentionState && !mentionState.canInsertMention),
127
- decisionSupported: !!editorView.state.schema.nodes.decisionItem,
128
- dateEnabled: !!dateState,
129
- placeholderTextEnabled: placeholderTextState && placeholderTextState.allowInserting,
130
- layoutSectionEnabled: Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.layout),
131
- expandEnabled: !!options.allowExpand,
132
- mediaUploadsEnabled: (_ref = mediaState && mediaState.allowsUploads) !== null && _ref !== void 0 ? _ref : undefined,
133
- onShowMediaPicker: (_ref2 = mediaState && mediaState.showMediaPicker) !== null && _ref2 !== void 0 ? _ref2 : undefined,
134
- mediaSupported: !!mediaState,
135
- imageUploadSupported: !!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.imageUpload),
136
- imageUploadEnabled: imageUploadState === null || imageUploadState === void 0 ? void 0 : imageUploadState.enabled,
137
- handleImageUpload: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$i = pluginInjectionApi.imageUpload) === null || _pluginInjectionApi$i === void 0 ? void 0 : _pluginInjectionApi$i.actions.startUpload,
138
- availableWrapperBlockTypes: blockTypeState && blockTypeState.availableWrapperBlockTypes,
139
- linkSupported: !!hyperlinkState,
140
- linkDisabled: !hyperlinkState || !hyperlinkState.canInsertLink || !!hyperlinkState.activeLinkMark,
141
- emojiDisabled: !emojiState || !emojiState.emojiProvider,
142
- emojiProvider: providers.emojiProvider,
143
- nativeStatusSupported: options.nativeStatusSupported,
144
- horizontalRuleEnabled: options.horizontalRuleEnabled,
145
- onInsertBlockType: handleInsertBlockType(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.codeBlock) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.actions.insertCodeBlock, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$p = pluginInjectionApi.panel) === null || _pluginInjectionApi$p === void 0 ? void 0 : _pluginInjectionApi$p.actions.insertPanel, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.blockType) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.insertBlockQuote),
146
- onInsertMacroFromMacroBrowser: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$e = pluginInjectionApi.extension) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.actions.insertMacroFromMacroBrowser,
147
- popupsMountPoint: popupsMountPoint,
148
- popupsBoundariesElement: popupsBoundariesElement,
149
- popupsScrollableElement: popupsScrollableElement,
150
- insertMenuItems: options.insertMenuItems,
151
- editorActions: editorActions,
152
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
153
- replacePlusMenuWithElementBrowser: options.replacePlusMenuWithElementBrowser,
154
- showElementBrowserLink: options.showElementBrowserLink,
155
- showSeparator: !isLastItem && toolbarSize <= ToolbarSize.S,
156
- featureFlags: featureFlags
157
- });
158
- }
159
- export default insertBlockPlugin;
@@ -1 +0,0 @@
1
- export {};
@@ -1,150 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
- /** @jsx jsx */
3
-
4
- import { useCallback, useState } from 'react';
5
- import { css, jsx } from '@emotion/react';
6
- // AFP-2532 TODO: Fix automatic suppressions below
7
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
8
- import { borderRadius } from '@atlaskit/theme';
9
- import { N0, N30A, N60A } from '@atlaskit/theme/colors';
10
- import { IconCode, IconDate, IconDecision, IconDivider, IconExpand, IconPanel, IconQuote, IconStatus } from '@atlaskit/editor-common/quick-insert';
11
- import { withReactEditorViewOuterListeners as withOuterListeners } from '@atlaskit/editor-common/ui-react';
12
- import { ElementBrowser, ELEMENT_ITEM_HEIGHT } from '@atlaskit/editor-common/element-browser';
13
- const InsertMenu = ({
14
- editorView,
15
- dropdownItems,
16
- showElementBrowserLink,
17
- onInsert,
18
- toggleVisiblity,
19
- pluginInjectionApi
20
- }) => {
21
- var _pluginInjectionApi$q6, _pluginInjectionApi$q7, _pluginInjectionApi$q8;
22
- const [itemCount, setItemCount] = useState(0);
23
- const transform = useCallback(item => ({
24
- title: item.content,
25
- description: item.tooltipDescription,
26
- keyshortcut: item.shortcut,
27
- icon: () => getSvgIconForItem({
28
- name: item.value.name
29
- }) || item.elemBefore,
30
- /**
31
- * @note This transformed items action is only used when a quick insert item has been
32
- * called from the quick insert menu and a search has not been performed.
33
- */
34
- action: () => onInsert({
35
- item
36
- }),
37
- // "insertInsertMenuItem" expects these 2 properties.
38
- onClick: item.onClick,
39
- value: item.value
40
- }), [onInsert]);
41
- const quickInsertDropdownItems = dropdownItems.map(transform);
42
- const viewMoreItem = showElementBrowserLink ? quickInsertDropdownItems.pop() : undefined;
43
- const onInsertItem = useCallback(item => {
44
- var _pluginInjectionApi$q;
45
- toggleVisiblity();
46
- pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q === void 0 ? void 0 : _pluginInjectionApi$q.actions.insertItem(item)(editorView.state, editorView.dispatch);
47
- }, [editorView, toggleVisiblity, pluginInjectionApi]);
48
- const getItems = useCallback((query, category) => {
49
- let result;
50
- /**
51
- * @warning The results if there is a query are not the same as the results if there is no query.
52
- * For example: If you have a typed panel and then select the panel item then it will call a different action
53
- * than is specified on the editor plugins quick insert
54
- * @see above transform function for more details.
55
- */
56
- if (query) {
57
- var _pluginInjectionApi$q2, _pluginInjectionApi$q3;
58
- result = (_pluginInjectionApi$q2 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q3 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q3 === void 0 ? void 0 : _pluginInjectionApi$q3.actions.getSuggestions({
59
- query,
60
- category
61
- })) !== null && _pluginInjectionApi$q2 !== void 0 ? _pluginInjectionApi$q2 : [];
62
- } else {
63
- var _pluginInjectionApi$q4, _pluginInjectionApi$q5;
64
- const featuredQuickInsertSuggestions = (_pluginInjectionApi$q4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q5 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q5 === void 0 ? void 0 : _pluginInjectionApi$q5.actions.getSuggestions({
65
- category,
66
- featuredItems: true
67
- })) !== null && _pluginInjectionApi$q4 !== void 0 ? _pluginInjectionApi$q4 : [];
68
- result = quickInsertDropdownItems.concat(featuredQuickInsertSuggestions);
69
- }
70
- setItemCount(result.length);
71
- return result;
72
- }, [pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q6 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q6 === void 0 ? void 0 : _pluginInjectionApi$q6.actions, quickInsertDropdownItems]);
73
- const emptyStateHandler = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$q7 = pluginInjectionApi.quickInsert) === null || _pluginInjectionApi$q7 === void 0 ? void 0 : (_pluginInjectionApi$q8 = _pluginInjectionApi$q7.sharedState.currentState()) === null || _pluginInjectionApi$q8 === void 0 ? void 0 : _pluginInjectionApi$q8.emptyStateHandler;
74
- return jsx("div", {
75
- css: insertMenuWrapper(itemCount)
76
- }, jsx(ElementBrowserWrapper, {
77
- handleClickOutside: toggleVisiblity,
78
- handleEscapeKeydown: toggleVisiblity,
79
- closeOnTab: true
80
- }, jsx(ElementBrowser, {
81
- mode: "inline",
82
- getItems: getItems,
83
- emptyStateHandler: emptyStateHandler,
84
- onInsertItem: onInsertItem,
85
- showSearch: true,
86
- showCategories: false
87
- // On page resize we want the InlineElementBrowser to show updated tools/overflow items
88
- ,
89
- key: quickInsertDropdownItems.length,
90
- viewMoreItem: viewMoreItem
91
- })));
92
- };
93
- const getSvgIconForItem = ({
94
- name
95
- }) => {
96
- const Icon = {
97
- codeblock: IconCode,
98
- panel: IconPanel,
99
- blockquote: IconQuote,
100
- decision: IconDecision,
101
- horizontalrule: IconDivider,
102
- expand: IconExpand,
103
- date: IconDate,
104
- status: IconStatus
105
- }[name];
106
- return Icon ? jsx(Icon, {
107
- label: ""
108
- }) : undefined;
109
- };
110
- const getInsertMenuHeight = ({
111
- itemCount
112
- }) => {
113
- // Figure based on visuals to exclude the searchbar, padding/margin, and the ViewMore item.
114
- const EXTRA_SPACE_EXCLUDING_ELEMENTLIST = 112;
115
- if (itemCount > 0 && itemCount < 6) {
116
- return itemCount * ELEMENT_ITEM_HEIGHT + EXTRA_SPACE_EXCLUDING_ELEMENTLIST;
117
- }
118
- return 560; // For showing 6 Elements.
119
- };
120
-
121
- const insertMenuWrapper = itemCount => css`
122
- display: flex;
123
- flex-direction: column;
124
- width: 320px;
125
- height: ${getInsertMenuHeight({
126
- itemCount
127
- })}px;
128
- background-color: ${`var(--ds-surface-overlay, ${N0})`};
129
- border-radius: ${borderRadius()}px;
130
- box-shadow: ${`var(--ds-shadow-overlay, ${`0 0 0 1px ${N30A},
131
- 0 2px 1px ${N30A},
132
- 0 0 20px -6px ${N60A}`})`};
133
- `;
134
- const flexWrapperStyles = css`
135
- display: flex;
136
- flex: 1;
137
- box-sizing: border-box;
138
- overflow: hidden;
139
- `;
140
- const FlexWrapper = props => {
141
- const {
142
- children,
143
- ...divProps
144
- } = props;
145
- return jsx("div", _extends({
146
- css: flexWrapperStyles
147
- }, divProps), children);
148
- };
149
- const ElementBrowserWrapper = withOuterListeners(FlexWrapper);
150
- export default InsertMenu;
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { Popup } from '@atlaskit/editor-common/ui';
3
- import InsertMenu from '../ElementBrowser/InsertMenu';
4
- import { DropDownButton } from './dropdown-button';
5
- export const BlockInsertElementBrowser = props => {
6
- return /*#__PURE__*/React.createElement(React.Fragment, null, props.open && /*#__PURE__*/React.createElement(Popup, {
7
- target: props.plusButtonRef,
8
- fitHeight: 500,
9
- fitWidth: 350,
10
- offset: [0, 3],
11
- mountTo: props.popupsMountPoint,
12
- boundariesElement: props.popupsBoundariesElement,
13
- scrollableElement: props.popupsScrollableElement,
14
- preventOverflow: true,
15
- alignX: "right"
16
- }, /*#__PURE__*/React.createElement(InsertMenu, {
17
- editorView: props.editorView,
18
- dropdownItems: props.items,
19
- onInsert: props.onInsert,
20
- toggleVisiblity: props.togglePlusMenuVisibility,
21
- showElementBrowserLink: props.showElementBrowserLink,
22
- pluginInjectionApi: props.pluginInjectionApi
23
- })), /*#__PURE__*/React.createElement(DropDownButton, {
24
- "aria-expanded": props.open,
25
- "aria-haspopup": true,
26
- handleRef: props.onRef,
27
- selected: props.open,
28
- disabled: props.disabled,
29
- onClick: props.onClick,
30
- onKeyDown: props.onKeyDown,
31
- spacing: props.spacing,
32
- label: props.label,
33
- "aria-keyshortcuts": "/"
34
- }));
35
- };
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
3
- import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
4
- import { DropDownButton } from './dropdown-button';
5
- export const BlockInsertMenuLegacy = props => {
6
- const {
7
- items
8
- } = props;
9
- const dropdownItems = React.useMemo(() => [{
10
- items
11
- }], [items]);
12
- return /*#__PURE__*/React.createElement(DropdownMenu, {
13
- items: dropdownItems,
14
- onItemActivated: props.onItemActivated,
15
- onOpenChange: props.onOpenChange,
16
- mountTo: props.popupsMountPoint,
17
- boundariesElement: props.popupsBoundariesElement,
18
- scrollableElement: props.popupsScrollableElement,
19
- isOpen: props.open,
20
- fitHeight: 188,
21
- fitWidth: 175,
22
- zIndex: akEditorMenuZIndex
23
- }, /*#__PURE__*/React.createElement(DropDownButton, {
24
- "aria-expanded": props.open,
25
- "aria-haspopup": true,
26
- handleRef: props.onRef,
27
- selected: props.open,
28
- disabled: props.disabled,
29
- onClick: props.onClick,
30
- onKeyDown: props.onKeyDown,
31
- spacing: props.spacing,
32
- label: props.label,
33
- "aria-keyshortcuts": "/"
34
- }));
35
- };