@atlaskit/editor-plugin-code-block-advanced 6.2.10 → 6.2.11

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-plugin-code-block-advanced
2
2
 
3
+ ## 6.2.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`459eb2064ff46`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/459eb2064ff46) -
8
+ Remove block menu dependency from code block advanced.
9
+ - Updated dependencies
10
+
3
11
  ## 6.2.10
4
12
 
5
13
  ### Patch Changes
@@ -22,9 +22,6 @@
22
22
  "../src/**/stories/**/*"
23
23
  ],
24
24
  "references": [
25
- {
26
- "path": "../../editor-plugin-block-menu/afm-cc/tsconfig.json"
27
- },
28
25
  {
29
26
  "path": "../../editor-plugin-code-block/afm-cc/tsconfig.json"
30
27
  },
@@ -6,10 +6,7 @@
6
6
  "rootDir": "../",
7
7
  "composite": true
8
8
  },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
9
+ "include": ["../src/**/*.ts", "../src/**/*.tsx"],
13
10
  "exclude": [
14
11
  "../src/**/__tests__/*",
15
12
  "../src/**/*.test.*",
@@ -22,9 +19,6 @@
22
19
  "../src/**/stories/**/*"
23
20
  ],
24
21
  "references": [
25
- {
26
- "path": "../../editor-plugin-block-menu/afm-jira/tsconfig.json"
27
- },
28
22
  {
29
23
  "path": "../../editor-plugin-code-block/afm-jira/tsconfig.json"
30
24
  },
@@ -6,10 +6,7 @@
6
6
  "rootDir": "../",
7
7
  "composite": true
8
8
  },
9
- "include": [
10
- "../src/**/*.ts",
11
- "../src/**/*.tsx"
12
- ],
9
+ "include": ["../src/**/*.ts", "../src/**/*.tsx"],
13
10
  "exclude": [
14
11
  "../src/**/__tests__/*",
15
12
  "../src/**/*.test.*",
@@ -22,9 +19,6 @@
22
19
  "../src/**/stories/**/*"
23
20
  ],
24
21
  "references": [
25
- {
26
- "path": "../../editor-plugin-block-menu/afm-products/tsconfig.json"
27
- },
28
22
  {
29
23
  "path": "../../editor-plugin-code-block/afm-products/tsconfig.json"
30
24
  },
@@ -4,28 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.codeBlockAdvancedPlugin = void 0;
7
- var _blockMenu = require("@atlaskit/editor-common/block-menu");
8
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
- var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
10
7
  var _codeBlockNodeWithToDOMFixed = require("./nodeviews/codeBlockNodeWithToDOMFixed");
11
8
  var _main = require("./pm-plugins/main");
12
- var _createCodeBlockMenuItem = require("./ui/createCodeBlockMenuItem");
13
9
  var codeBlockAdvancedPlugin = exports.codeBlockAdvancedPlugin = function codeBlockAdvancedPlugin(_ref) {
14
10
  var api = _ref.api,
15
11
  config = _ref.config;
16
- if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true)) {
17
- var _api$blockMenu;
18
- api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
19
- type: 'block-menu-item',
20
- key: _blockMenu.FORMAT_CODE_BLOCK_MENU_ITEM.key,
21
- parent: {
22
- type: 'block-menu-section',
23
- key: _blockMenu.FORMAT_MENU_ITEM.key,
24
- rank: (0, _platformFeatureFlags.fg)('platform_editor_block_menu_format_rank_revised') ? _blockMenu.FORMAT_NESTED_MENU_RANK_REVISED[_blockMenu.FORMAT_CODE_BLOCK_MENU_ITEM.key] : _blockMenu.FORMAT_NESTED_MENU_RANK[_blockMenu.FORMAT_CODE_BLOCK_MENU_ITEM.key]
25
- },
26
- component: (0, _createCodeBlockMenuItem.createCodeBlockMenuItem)(api)
27
- }]);
28
- }
29
12
  return {
30
13
  name: 'codeBlockAdvanced',
31
14
  nodes: function nodes() {
@@ -1,26 +1,9 @@
1
- import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK, FORMAT_NESTED_MENU_RANK_REVISED } from '@atlaskit/editor-common/block-menu';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
1
  import { codeBlockNodeWithFixedToDOM } from './nodeviews/codeBlockNodeWithToDOMFixed';
5
2
  import { createPlugin } from './pm-plugins/main';
6
- import { createCodeBlockMenuItem } from './ui/createCodeBlockMenuItem';
7
3
  export const codeBlockAdvancedPlugin = ({
8
4
  api,
9
5
  config
10
6
  }) => {
11
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
12
- var _api$blockMenu;
13
- api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.actions.registerBlockMenuComponents([{
14
- type: 'block-menu-item',
15
- key: FORMAT_CODE_BLOCK_MENU_ITEM.key,
16
- parent: {
17
- type: 'block-menu-section',
18
- key: FORMAT_MENU_ITEM.key,
19
- rank: fg('platform_editor_block_menu_format_rank_revised') ? FORMAT_NESTED_MENU_RANK_REVISED[FORMAT_CODE_BLOCK_MENU_ITEM.key] : FORMAT_NESTED_MENU_RANK[FORMAT_CODE_BLOCK_MENU_ITEM.key]
20
- },
21
- component: createCodeBlockMenuItem(api)
22
- }]);
23
- }
24
7
  return {
25
8
  name: 'codeBlockAdvanced',
26
9
  nodes() {
@@ -1,25 +1,8 @@
1
- import { FORMAT_MENU_ITEM, FORMAT_CODE_BLOCK_MENU_ITEM, FORMAT_NESTED_MENU_RANK, FORMAT_NESTED_MENU_RANK_REVISED } from '@atlaskit/editor-common/block-menu';
2
- import { fg } from '@atlaskit/platform-feature-flags';
3
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
4
1
  import { codeBlockNodeWithFixedToDOM } from './nodeviews/codeBlockNodeWithToDOMFixed';
5
2
  import { createPlugin } from './pm-plugins/main';
6
- import { createCodeBlockMenuItem } from './ui/createCodeBlockMenuItem';
7
3
  export var codeBlockAdvancedPlugin = function codeBlockAdvancedPlugin(_ref) {
8
4
  var api = _ref.api,
9
5
  config = _ref.config;
10
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
11
- var _api$blockMenu;
12
- api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 || _api$blockMenu.actions.registerBlockMenuComponents([{
13
- type: 'block-menu-item',
14
- key: FORMAT_CODE_BLOCK_MENU_ITEM.key,
15
- parent: {
16
- type: 'block-menu-section',
17
- key: FORMAT_MENU_ITEM.key,
18
- rank: fg('platform_editor_block_menu_format_rank_revised') ? FORMAT_NESTED_MENU_RANK_REVISED[FORMAT_CODE_BLOCK_MENU_ITEM.key] : FORMAT_NESTED_MENU_RANK[FORMAT_CODE_BLOCK_MENU_ITEM.key]
19
- },
20
- component: createCodeBlockMenuItem(api)
21
- }]);
22
- }
23
6
  return {
24
7
  name: 'codeBlockAdvanced',
25
8
  nodes: function nodes() {
@@ -1,6 +1,5 @@
1
1
  import type { Extension } from '@codemirror/state';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
3
  import type { CodeBlockPlugin } from '@atlaskit/editor-plugin-code-block';
5
4
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
5
  import type { FindReplacePlugin } from '@atlaskit/editor-plugin-find-replace';
@@ -8,12 +7,11 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
8
7
  import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
9
8
  export type CodeBlockAdvancedPlugin = NextEditorPlugin<'codeBlockAdvanced', {
10
9
  dependencies: [
11
- CodeBlockPlugin,
10
+ OptionalPlugin<CodeBlockPlugin>,
12
11
  SelectionPlugin,
13
12
  OptionalPlugin<EditorDisabledPlugin>,
14
13
  OptionalPlugin<SelectionMarkerPlugin>,
15
- OptionalPlugin<FindReplacePlugin>,
16
- OptionalPlugin<BlockMenuPlugin>
14
+ OptionalPlugin<FindReplacePlugin>
17
15
  ];
18
16
  pluginConfiguration: CodeBlockAdvancedPluginOptions | undefined;
19
17
  }>;
@@ -1,6 +1,5 @@
1
1
  import type { Extension } from '@codemirror/state';
2
2
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
3
- import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
4
3
  import type { CodeBlockPlugin } from '@atlaskit/editor-plugin-code-block';
5
4
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
6
5
  import type { FindReplacePlugin } from '@atlaskit/editor-plugin-find-replace';
@@ -8,12 +7,11 @@ import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
8
7
  import type { SelectionMarkerPlugin } from '@atlaskit/editor-plugin-selection-marker';
9
8
  export type CodeBlockAdvancedPlugin = NextEditorPlugin<'codeBlockAdvanced', {
10
9
  dependencies: [
11
- CodeBlockPlugin,
10
+ OptionalPlugin<CodeBlockPlugin>,
12
11
  SelectionPlugin,
13
12
  OptionalPlugin<EditorDisabledPlugin>,
14
13
  OptionalPlugin<SelectionMarkerPlugin>,
15
- OptionalPlugin<FindReplacePlugin>,
16
- OptionalPlugin<BlockMenuPlugin>
14
+ OptionalPlugin<FindReplacePlugin>
17
15
  ];
18
16
  pluginConfiguration: CodeBlockAdvancedPluginOptions | undefined;
19
17
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "6.2.10",
3
+ "version": "6.2.11",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,10 +29,9 @@
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
31
  "@atlaskit/adf-schema": "^51.4.0",
32
- "@atlaskit/editor-plugin-block-menu": "^5.0.0",
33
32
  "@atlaskit/editor-plugin-code-block": "^8.1.0",
34
33
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
35
- "@atlaskit/editor-plugin-find-replace": "^6.0.0",
34
+ "@atlaskit/editor-plugin-find-replace": "^6.1.0",
36
35
  "@atlaskit/editor-plugin-selection": "^6.1.0",
37
36
  "@atlaskit/editor-plugin-selection-marker": "^6.2.0",
38
37
  "@atlaskit/editor-prosemirror": "7.0.0",
@@ -40,8 +39,8 @@
40
39
  "@atlaskit/icon": "^29.0.0",
41
40
  "@atlaskit/platform-feature-flags": "^1.1.0",
42
41
  "@atlaskit/prosemirror-history": "^0.2.0",
43
- "@atlaskit/tmp-editor-statsig": "^13.38.0",
44
- "@atlaskit/tokens": "^8.0.0",
42
+ "@atlaskit/tmp-editor-statsig": "^13.42.0",
43
+ "@atlaskit/tokens": "^8.2.0",
45
44
  "@babel/runtime": "^7.0.0",
46
45
  "@codemirror/autocomplete": "6.18.4",
47
46
  "@codemirror/commands": "6.7.1",
@@ -57,7 +56,7 @@
57
56
  "codemirror-lang-elixir": "4.0.0"
58
57
  },
59
58
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.32.0",
59
+ "@atlaskit/editor-common": "^110.34.0",
61
60
  "react": "^18.2.0",
62
61
  "react-intl-next": "npm:react-intl@^5.18.1"
63
62
  },
@@ -1,35 +1,8 @@
1
- import {
2
- FORMAT_MENU_ITEM,
3
- FORMAT_CODE_BLOCK_MENU_ITEM,
4
- FORMAT_NESTED_MENU_RANK,
5
- FORMAT_NESTED_MENU_RANK_REVISED,
6
- } from '@atlaskit/editor-common/block-menu';
7
- import { fg } from '@atlaskit/platform-feature-flags';
8
- import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
9
-
10
1
  import type { CodeBlockAdvancedPlugin } from './codeBlockAdvancedPluginType';
11
2
  import { codeBlockNodeWithFixedToDOM } from './nodeviews/codeBlockNodeWithToDOMFixed';
12
3
  import { createPlugin } from './pm-plugins/main';
13
- import { createCodeBlockMenuItem } from './ui/createCodeBlockMenuItem';
14
4
 
15
5
  export const codeBlockAdvancedPlugin: CodeBlockAdvancedPlugin = ({ api, config }) => {
16
- if (expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true)) {
17
- api?.blockMenu?.actions.registerBlockMenuComponents([
18
- {
19
- type: 'block-menu-item',
20
- key: FORMAT_CODE_BLOCK_MENU_ITEM.key,
21
- parent: {
22
- type: 'block-menu-section' as const,
23
- key: FORMAT_MENU_ITEM.key,
24
- rank: fg('platform_editor_block_menu_format_rank_revised')
25
- ? FORMAT_NESTED_MENU_RANK_REVISED[FORMAT_CODE_BLOCK_MENU_ITEM.key]
26
- : FORMAT_NESTED_MENU_RANK[FORMAT_CODE_BLOCK_MENU_ITEM.key],
27
- },
28
- component: createCodeBlockMenuItem(api),
29
- },
30
- ]);
31
- }
32
-
33
6
  return {
34
7
  name: 'codeBlockAdvanced',
35
8
 
@@ -1,7 +1,6 @@
1
1
  import type { Extension } from '@codemirror/state';
2
2
 
3
3
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
4
- import type { BlockMenuPlugin } from '@atlaskit/editor-plugin-block-menu';
5
4
  import type { CodeBlockPlugin } from '@atlaskit/editor-plugin-code-block';
6
5
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
7
6
  import type { FindReplacePlugin } from '@atlaskit/editor-plugin-find-replace';
@@ -12,12 +11,11 @@ export type CodeBlockAdvancedPlugin = NextEditorPlugin<
12
11
  'codeBlockAdvanced',
13
12
  {
14
13
  dependencies: [
15
- CodeBlockPlugin,
14
+ OptionalPlugin<CodeBlockPlugin>,
16
15
  SelectionPlugin,
17
16
  OptionalPlugin<EditorDisabledPlugin>,
18
17
  OptionalPlugin<SelectionMarkerPlugin>,
19
18
  OptionalPlugin<FindReplacePlugin>,
20
- OptionalPlugin<BlockMenuPlugin>,
21
19
  ];
22
20
  pluginConfiguration: CodeBlockAdvancedPluginOptions | undefined;
23
21
  }
package/tsconfig.app.json CHANGED
@@ -37,9 +37,6 @@
37
37
  {
38
38
  "path": "../editor-common/tsconfig.app.json"
39
39
  },
40
- {
41
- "path": "../editor-plugin-block-menu/tsconfig.app.json"
42
- },
43
40
  {
44
41
  "path": "../editor-plugin-code-block/tsconfig.app.json"
45
42
  },
@@ -55,12 +52,6 @@
55
52
  {
56
53
  "path": "../editor-plugin-selection-marker/tsconfig.app.json"
57
54
  },
58
- {
59
- "path": "../editor-toolbar/tsconfig.app.json"
60
- },
61
- {
62
- "path": "../../design-system/icon/tsconfig.app.json"
63
- },
64
55
  {
65
56
  "path": "../../platform/feature-flags/tsconfig.app.json"
66
57
  },
@@ -1,57 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.createCodeBlockMenuItem = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var _reactIntlNext = require("react-intl-next");
11
- var _analytics = require("@atlaskit/editor-common/analytics");
12
- var _messages = require("@atlaskit/editor-common/messages");
13
- var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
14
- var _state = require("@atlaskit/editor-prosemirror/state");
15
- var _editorToolbar = require("@atlaskit/editor-toolbar");
16
- var _angleBrackets = _interopRequireDefault(require("@atlaskit/icon/core/angle-brackets"));
17
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
18
- var nodeName = 'codeBlock';
19
- var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
20
- var api = _ref.api;
21
- var _useIntl = (0, _reactIntlNext.useIntl)(),
22
- formatMessage = _useIntl.formatMessage;
23
- var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
24
- var isCodeBlockSelected = (0, _react.useMemo)(function () {
25
- if (!selection) {
26
- return false;
27
- }
28
- if (selection instanceof _state.NodeSelection) {
29
- // Note: we are checking for any type of panel, not just of type infopanel
30
- return selection.node.type.name === nodeName;
31
- }
32
- return false;
33
- }, [selection]);
34
- var handleClick = function handleClick(event) {
35
- var _api$blockMenu;
36
- var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE;
37
- var inputMethod = _analytics.INPUT_METHOD.BLOCK_MENU;
38
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName, {
39
- inputMethod: inputMethod,
40
- triggeredFrom: triggeredFrom
41
- }));
42
- };
43
- return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
44
- onClick: handleClick,
45
- isSelected: isCodeBlockSelected,
46
- elemBefore: /*#__PURE__*/_react.default.createElement(_angleBrackets.default, {
47
- label: ""
48
- })
49
- }, formatMessage(_messages.blockMenuMessages.codeBlock));
50
- };
51
- var createCodeBlockMenuItem = exports.createCodeBlockMenuItem = function createCodeBlockMenuItem(api) {
52
- return function () {
53
- return /*#__PURE__*/_react.default.createElement(CodeBlockMenuItem, {
54
- api: api
55
- });
56
- };
57
- };
@@ -1,48 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { useIntl } from 'react-intl-next';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
- import AngleBracketsIcon from '@atlaskit/icon/core/angle-brackets';
9
- const nodeName = 'codeBlock';
10
- const CodeBlockMenuItem = ({
11
- api
12
- }) => {
13
- const {
14
- formatMessage
15
- } = useIntl();
16
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
17
- const isCodeBlockSelected = useMemo(() => {
18
- if (!selection) {
19
- return false;
20
- }
21
- if (selection instanceof NodeSelection) {
22
- // Note: we are checking for any type of panel, not just of type infopanel
23
- return selection.node.type.name === nodeName;
24
- }
25
- return false;
26
- }, [selection]);
27
- const handleClick = event => {
28
- var _api$blockMenu;
29
- const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
30
- const inputMethod = INPUT_METHOD.BLOCK_MENU;
31
- api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName, {
32
- inputMethod,
33
- triggeredFrom
34
- }));
35
- };
36
- return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
37
- onClick: handleClick,
38
- isSelected: isCodeBlockSelected,
39
- elemBefore: /*#__PURE__*/React.createElement(AngleBracketsIcon, {
40
- label: ""
41
- })
42
- }, formatMessage(blockMenuMessages.codeBlock));
43
- };
44
- export const createCodeBlockMenuItem = api => {
45
- return () => /*#__PURE__*/React.createElement(CodeBlockMenuItem, {
46
- api: api
47
- });
48
- };
@@ -1,48 +0,0 @@
1
- import React, { useMemo } from 'react';
2
- import { useIntl } from 'react-intl-next';
3
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { blockMenuMessages } from '@atlaskit/editor-common/messages';
5
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
6
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
- import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
8
- import AngleBracketsIcon from '@atlaskit/icon/core/angle-brackets';
9
- var nodeName = 'codeBlock';
10
- var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
11
- var api = _ref.api;
12
- var _useIntl = useIntl(),
13
- formatMessage = _useIntl.formatMessage;
14
- var selection = useSharedPluginStateSelector(api, 'selection.selection');
15
- var isCodeBlockSelected = useMemo(function () {
16
- if (!selection) {
17
- return false;
18
- }
19
- if (selection instanceof NodeSelection) {
20
- // Note: we are checking for any type of panel, not just of type infopanel
21
- return selection.node.type.name === nodeName;
22
- }
23
- return false;
24
- }, [selection]);
25
- var handleClick = function handleClick(event) {
26
- var _api$blockMenu;
27
- var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
28
- var inputMethod = INPUT_METHOD.BLOCK_MENU;
29
- api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$blockMenu = api.blockMenu) === null || _api$blockMenu === void 0 ? void 0 : _api$blockMenu.commands.formatNode(nodeName, {
30
- inputMethod: inputMethod,
31
- triggeredFrom: triggeredFrom
32
- }));
33
- };
34
- return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
35
- onClick: handleClick,
36
- isSelected: isCodeBlockSelected,
37
- elemBefore: /*#__PURE__*/React.createElement(AngleBracketsIcon, {
38
- label: ""
39
- })
40
- }, formatMessage(blockMenuMessages.codeBlock));
41
- };
42
- export var createCodeBlockMenuItem = function createCodeBlockMenuItem(api) {
43
- return function () {
44
- return /*#__PURE__*/React.createElement(CodeBlockMenuItem, {
45
- api: api
46
- });
47
- };
48
- };
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
4
- export declare const createCodeBlockMenuItem: (api: ExtractInjectionAPI<CodeBlockAdvancedPlugin> | undefined) => () => React.JSX.Element;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
3
- import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
4
- export declare const createCodeBlockMenuItem: (api: ExtractInjectionAPI<CodeBlockAdvancedPlugin> | undefined) => () => React.JSX.Element;
@@ -1,65 +0,0 @@
1
- import React, { useMemo } from 'react';
2
-
3
- import { useIntl } from 'react-intl-next';
4
-
5
- import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- import { blockMenuMessages } from '@atlaskit/editor-common/messages';
7
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
8
- import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
9
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
10
- import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
11
- import AngleBracketsIcon from '@atlaskit/icon/core/angle-brackets';
12
-
13
- import type { CodeBlockAdvancedPlugin } from '../codeBlockAdvancedPluginType';
14
-
15
- type Props = {
16
- api: ExtractInjectionAPI<CodeBlockAdvancedPlugin> | undefined;
17
- };
18
-
19
- const nodeName = 'codeBlock';
20
-
21
- const CodeBlockMenuItem = ({ api }: Props) => {
22
- const { formatMessage } = useIntl();
23
- const selection = useSharedPluginStateSelector(api, 'selection.selection');
24
-
25
- const isCodeBlockSelected = useMemo(() => {
26
- if (!selection) {
27
- return false;
28
- }
29
-
30
- if (selection instanceof NodeSelection) {
31
- // Note: we are checking for any type of panel, not just of type infopanel
32
- return selection.node.type.name === nodeName;
33
- }
34
-
35
- return false;
36
- }, [selection]);
37
-
38
- const handleClick = (event: React.MouseEvent | React.KeyboardEvent) => {
39
- const triggeredFrom =
40
- event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0
41
- ? INPUT_METHOD.KEYBOARD
42
- : INPUT_METHOD.MOUSE;
43
- const inputMethod = INPUT_METHOD.BLOCK_MENU;
44
-
45
- api?.core.actions.execute(
46
- api?.blockMenu?.commands.formatNode(nodeName, { inputMethod, triggeredFrom }),
47
- );
48
- };
49
-
50
- return (
51
- <ToolbarDropdownItem
52
- onClick={handleClick}
53
- isSelected={isCodeBlockSelected}
54
- elemBefore={<AngleBracketsIcon label="" />}
55
- >
56
- {formatMessage(blockMenuMessages.codeBlock)}
57
- </ToolbarDropdownItem>
58
- );
59
- };
60
-
61
- export const createCodeBlockMenuItem = (
62
- api: ExtractInjectionAPI<CodeBlockAdvancedPlugin> | undefined,
63
- ) => {
64
- return () => <CodeBlockMenuItem api={api} />;
65
- };