@atlaskit/editor-plugin-code-block 8.1.23 → 8.1.25
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,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-code-block
|
|
2
2
|
|
|
3
|
+
## 8.1.25
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`b5d004bf834f8`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b5d004bf834f8) -
|
|
8
|
+
[ux] Adds block menu action to check if 'Turn into' item should be rendered or not.
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.1.24
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
3
17
|
## 8.1.23
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1,36 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createCodeBlockMenuItem = void 0;
|
|
9
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
9
|
var _reactIntlNext = require("react-intl-next");
|
|
11
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
11
|
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
12
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
16
13
|
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
14
|
var nodeName = 'codeBlock';
|
|
19
15
|
var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
|
|
16
|
+
var _api$blockMenu2;
|
|
20
17
|
var api = _ref.api;
|
|
21
18
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
22
19
|
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
20
|
var handleClick = function handleClick(event) {
|
|
35
21
|
var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? _analytics.INPUT_METHOD.KEYBOARD : _analytics.INPUT_METHOD.MOUSE;
|
|
36
22
|
var inputMethod = _analytics.INPUT_METHOD.BLOCK_MENU;
|
|
@@ -47,9 +33,12 @@ var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
|
|
|
47
33
|
}) : null;
|
|
48
34
|
});
|
|
49
35
|
};
|
|
36
|
+
var isTransfromToPanelDisabled = api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
|
|
37
|
+
if (isTransfromToPanelDisabled) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
50
40
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarDropdownItem, {
|
|
51
41
|
onClick: handleClick,
|
|
52
|
-
isSelected: isCodeBlockSelected,
|
|
53
42
|
elemBefore: /*#__PURE__*/_react.default.createElement(_angleBrackets.default, {
|
|
54
43
|
label: ""
|
|
55
44
|
})
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
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
5
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
8
6
|
import AngleBracketsIcon from '@atlaskit/icon/core/angle-brackets';
|
|
9
7
|
const nodeName = 'codeBlock';
|
|
10
8
|
const CodeBlockMenuItem = ({
|
|
11
9
|
api
|
|
12
10
|
}) => {
|
|
11
|
+
var _api$blockMenu2;
|
|
13
12
|
const {
|
|
14
13
|
formatMessage
|
|
15
14
|
} = 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
15
|
const handleClick = event => {
|
|
28
16
|
const triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
|
|
29
17
|
const inputMethod = INPUT_METHOD.BLOCK_MENU;
|
|
@@ -41,9 +29,12 @@ const CodeBlockMenuItem = ({
|
|
|
41
29
|
}) : null;
|
|
42
30
|
});
|
|
43
31
|
};
|
|
32
|
+
const isTransfromToPanelDisabled = api === null || api === void 0 ? void 0 : (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
|
|
33
|
+
if (isTransfromToPanelDisabled) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
44
36
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
45
37
|
onClick: handleClick,
|
|
46
|
-
isSelected: isCodeBlockSelected,
|
|
47
38
|
elemBefore: /*#__PURE__*/React.createElement(AngleBracketsIcon, {
|
|
48
39
|
label: ""
|
|
49
40
|
})
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
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
5
|
import { ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
|
|
8
6
|
import AngleBracketsIcon from '@atlaskit/icon/core/angle-brackets';
|
|
9
7
|
var nodeName = 'codeBlock';
|
|
10
8
|
var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
|
|
9
|
+
var _api$blockMenu2;
|
|
11
10
|
var api = _ref.api;
|
|
12
11
|
var _useIntl = useIntl(),
|
|
13
12
|
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
13
|
var handleClick = function handleClick(event) {
|
|
26
14
|
var triggeredFrom = event.nativeEvent instanceof KeyboardEvent || event.nativeEvent.detail === 0 ? INPUT_METHOD.KEYBOARD : INPUT_METHOD.MOUSE;
|
|
27
15
|
var inputMethod = INPUT_METHOD.BLOCK_MENU;
|
|
@@ -38,9 +26,12 @@ var CodeBlockMenuItem = function CodeBlockMenuItem(_ref) {
|
|
|
38
26
|
}) : null;
|
|
39
27
|
});
|
|
40
28
|
};
|
|
29
|
+
var isTransfromToPanelDisabled = api === null || api === void 0 || (_api$blockMenu2 = api.blockMenu) === null || _api$blockMenu2 === void 0 ? void 0 : _api$blockMenu2.actions.isTransformOptionDisabled(nodeName);
|
|
30
|
+
if (isTransfromToPanelDisabled) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
41
33
|
return /*#__PURE__*/React.createElement(ToolbarDropdownItem, {
|
|
42
34
|
onClick: handleClick,
|
|
43
|
-
isSelected: isCodeBlockSelected,
|
|
44
35
|
elemBefore: /*#__PURE__*/React.createElement(AngleBracketsIcon, {
|
|
45
36
|
label: ""
|
|
46
37
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-code-block",
|
|
3
|
-
"version": "8.1.
|
|
3
|
+
"version": "8.1.25",
|
|
4
4
|
"description": "Code block plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
"@atlaskit/editor-plugin-decorations": "^6.1.0",
|
|
36
36
|
"@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-editor-viewmode": "^8.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-interaction": "^
|
|
38
|
+
"@atlaskit/editor-plugin-interaction": "^11.0.0",
|
|
39
39
|
"@atlaskit/editor-plugin-selection": "^6.1.0",
|
|
40
|
-
"@atlaskit/editor-plugin-toolbar": "^3.
|
|
40
|
+
"@atlaskit/editor-plugin-toolbar": "^3.5.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "^7.2.0",
|
|
42
42
|
"@atlaskit/editor-toolbar": "^0.18.0",
|
|
43
43
|
"@atlaskit/icon": "^29.3.0",
|
|
44
44
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
45
45
|
"@atlaskit/prosemirror-input-rules": "^3.6.0",
|
|
46
|
-
"@atlaskit/tmp-editor-statsig": "^16.
|
|
46
|
+
"@atlaskit/tmp-editor-statsig": "^16.1.0",
|
|
47
47
|
"@babel/runtime": "^7.0.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@atlaskit/editor-common": "^110.
|
|
50
|
+
"@atlaskit/editor-common": "^110.48.0",
|
|
51
51
|
"react": "^18.2.0",
|
|
52
52
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
53
53
|
},
|