@atlaskit/editor-plugin-code-block 3.0.2 → 3.1.0

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,26 @@
1
1
  # @atlaskit/editor-plugin-code-block
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#122895](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122895)
8
+ [`49b8c7658f3b5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/49b8c7658f3b5) -
9
+ [ED-24173] bump @atlaskit/adf-schema to 40.3.0 and @atlassian/adf-schema-json to 1.18.0
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
15
+ ## 3.0.3
16
+
17
+ ### Patch Changes
18
+
19
+ - [#122977](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122977)
20
+ [`41748db2c12de`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/41748db2c12de) -
21
+ [ux]ED-24225 add wrap button inside editor-plugin-block
22
+ - Updated dependencies
23
+
3
24
  ## 3.0.2
4
25
 
5
26
  ### Patch Changes
@@ -7,7 +7,7 @@ exports.copyContentToClipboard = exports.changeLanguage = void 0;
7
7
  exports.createInsertCodeBlockTransaction = createInsertCodeBlockTransaction;
8
8
  exports.ignoreFollowingMutations = void 0;
9
9
  exports.insertCodeBlockWithAnalytics = insertCodeBlockWithAnalytics;
10
- exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = void 0;
10
+ exports.wrapCodeBlock = exports.resetShouldIgnoreFollowingMutations = exports.resetCopiedState = exports.removeCodeBlock = void 0;
11
11
  var _analytics = require("@atlaskit/editor-common/analytics");
12
12
  var _clipboard = require("@atlaskit/editor-common/clipboard");
13
13
  var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
@@ -32,6 +32,11 @@ var removeCodeBlock = exports.removeCodeBlock = function removeCodeBlock(state,
32
32
  }
33
33
  return true;
34
34
  };
35
+
36
+ // we will be hooking the button up in this follow up card ED-24222
37
+ var wrapCodeBlock = exports.wrapCodeBlock = function wrapCodeBlock(state, dispatch) {
38
+ return false;
39
+ };
35
40
  var changeLanguage = exports.changeLanguage = function changeLanguage(editorAnalyticsAPI) {
36
41
  return function (language) {
37
42
  return function (state, dispatch) {
@@ -10,10 +10,12 @@ var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/message
10
10
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
11
  var _copy = _interopRequireDefault(require("@atlaskit/icon/glyph/copy"));
12
12
  var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _actions = require("./actions");
14
15
  var _languageList = require("./language-list");
15
16
  var _pluginKey = require("./plugin-key");
16
17
  var _codeBlockCopySelectionPlugin = require("./pm-plugins/codeBlockCopySelectionPlugin");
18
+ var _WrapIcon = require("./ui/icons/WrapIcon");
17
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
18
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
21
  var languageList = (0, _languageList.createLanguageList)(_languageList.DEFAULT_LANGUAGES);
@@ -99,13 +101,21 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig() {
99
101
  title: formatMessage(_messages.default.remove),
100
102
  tabIndex: null
101
103
  };
104
+ var codeBlockWrapButton = {
105
+ id: 'editor.codeBlock.wrap',
106
+ type: 'button',
107
+ icon: _WrapIcon.WrapIcon,
108
+ onClick: _actions.wrapCodeBlock,
109
+ title: formatMessage(_messages.codeBlockButtonMessages.wrapCode),
110
+ tabIndex: null
111
+ };
102
112
  return {
103
113
  title: 'CodeBlock floating controls',
104
114
  getDomRef: function getDomRef(view) {
105
115
  return (0, _utils.findDomRefAtPos)(pos, view.domAtPos.bind(view));
106
116
  },
107
117
  nodeType: nodeType,
108
- items: [languageSelect, separator].concat(copyToClipboardItems, [deleteButton]),
118
+ items: (0, _platformFeatureFlags.fg)('editor_support_code_block_wrapping') ? [languageSelect, separator, codeBlockWrapButton, separator].concat(copyToClipboardItems, [deleteButton]) : [languageSelect, separator].concat(copyToClipboardItems, [deleteButton]),
109
119
  scrollable: true
110
120
  };
111
121
  };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.WrapIcon = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _icon = _interopRequireDefault(require("@atlaskit/icon"));
10
+ var CustomGlyph = function CustomGlyph() {
11
+ return /*#__PURE__*/_react.default.createElement("svg", {
12
+ width: "24",
13
+ height: "24",
14
+ fill: "none",
15
+ viewBox: "0 0 24 24"
16
+ }, /*#__PURE__*/_react.default.createElement("g", {
17
+ fill: "currentColor",
18
+ clipPath: "url(#clip0_654_431)"
19
+ }, /*#__PURE__*/_react.default.createElement("path", {
20
+ d: "M20 4h-1v16h1V4ZM3 8a1 1 0 0 1 1-1h9.5a4.5 4.5 0 1 1 0 9h-2.086l.293.293a1 1 0 0 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2a1 1 0 0 1 1.414 1.414l-.293.293H13.5a2.5 2.5 0 0 0 0-5H4a1 1 0 0 1-1-1Z",
21
+ clipRule: "evenodd",
22
+ fillRule: "evenodd"
23
+ })));
24
+ };
25
+ var WrapIcon = exports.WrapIcon = function WrapIcon() {
26
+ return /*#__PURE__*/_react.default.createElement(_icon.default, {
27
+ glyph: CustomGlyph,
28
+ label: "wrapIcon"
29
+ });
30
+ };
@@ -26,6 +26,11 @@ export const removeCodeBlock = (state, dispatch) => {
26
26
  }
27
27
  return true;
28
28
  };
29
+
30
+ // we will be hooking the button up in this follow up card ED-24222
31
+ export const wrapCodeBlock = (state, dispatch) => {
32
+ return false;
33
+ };
29
34
  export const changeLanguage = editorAnalyticsAPI => language => (state, dispatch) => {
30
35
  var _pluginKey$getState;
31
36
  const {
@@ -2,10 +2,12 @@ import commonMessages, { codeBlockButtonMessages } from '@atlaskit/editor-common
2
2
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
3
3
  import CopyIcon from '@atlaskit/icon/glyph/copy';
4
4
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
5
- import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState } from './actions';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState, wrapCodeBlock } from './actions';
6
7
  import { createLanguageList, DEFAULT_LANGUAGES, getLanguageIdentifier } from './language-list';
7
8
  import { pluginKey } from './plugin-key';
8
9
  import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
10
+ import { WrapIcon } from './ui/icons/WrapIcon';
9
11
  const languageList = createLanguageList(DEFAULT_LANGUAGES);
10
12
  export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
11
13
  formatMessage
@@ -80,11 +82,19 @@ export const getToolbarConfig = (allowCopyToClipboard = false, api) => (state, {
80
82
  title: formatMessage(commonMessages.remove),
81
83
  tabIndex: null
82
84
  };
85
+ const codeBlockWrapButton = {
86
+ id: 'editor.codeBlock.wrap',
87
+ type: 'button',
88
+ icon: WrapIcon,
89
+ onClick: wrapCodeBlock,
90
+ title: formatMessage(codeBlockButtonMessages.wrapCode),
91
+ tabIndex: null
92
+ };
83
93
  return {
84
94
  title: 'CodeBlock floating controls',
85
95
  getDomRef: view => findDomRefAtPos(pos, view.domAtPos.bind(view)),
86
96
  nodeType,
87
- items: [languageSelect, separator, ...copyToClipboardItems, deleteButton],
97
+ items: fg('editor_support_code_block_wrapping') ? [languageSelect, separator, codeBlockWrapButton, separator, ...copyToClipboardItems, deleteButton] : [languageSelect, separator, ...copyToClipboardItems, deleteButton],
88
98
  scrollable: true
89
99
  };
90
100
  };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import Icon from '@atlaskit/icon';
3
+ const CustomGlyph = () => /*#__PURE__*/React.createElement("svg", {
4
+ width: "24",
5
+ height: "24",
6
+ fill: "none",
7
+ viewBox: "0 0 24 24"
8
+ }, /*#__PURE__*/React.createElement("g", {
9
+ fill: "currentColor",
10
+ clipPath: "url(#clip0_654_431)"
11
+ }, /*#__PURE__*/React.createElement("path", {
12
+ d: "M20 4h-1v16h1V4ZM3 8a1 1 0 0 1 1-1h9.5a4.5 4.5 0 1 1 0 9h-2.086l.293.293a1 1 0 0 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2a1 1 0 0 1 1.414 1.414l-.293.293H13.5a2.5 2.5 0 0 0 0-5H4a1 1 0 0 1-1-1Z",
13
+ clipRule: "evenodd",
14
+ fillRule: "evenodd"
15
+ })));
16
+ export const WrapIcon = () => {
17
+ return /*#__PURE__*/React.createElement(Icon, {
18
+ glyph: CustomGlyph,
19
+ label: "wrapIcon"
20
+ });
21
+ };
@@ -22,6 +22,11 @@ export var removeCodeBlock = function removeCodeBlock(state, dispatch) {
22
22
  }
23
23
  return true;
24
24
  };
25
+
26
+ // we will be hooking the button up in this follow up card ED-24222
27
+ export var wrapCodeBlock = function wrapCodeBlock(state, dispatch) {
28
+ return false;
29
+ };
25
30
  export var changeLanguage = function changeLanguage(editorAnalyticsAPI) {
26
31
  return function (language) {
27
32
  return function (state, dispatch) {
@@ -2,10 +2,12 @@ import commonMessages, { codeBlockButtonMessages } from '@atlaskit/editor-common
2
2
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
3
3
  import CopyIcon from '@atlaskit/icon/glyph/copy';
4
4
  import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
5
- import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState } from './actions';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { changeLanguage, copyContentToClipboard, removeCodeBlock, resetCopiedState, wrapCodeBlock } from './actions';
6
7
  import { createLanguageList, DEFAULT_LANGUAGES, getLanguageIdentifier } from './language-list';
7
8
  import { pluginKey } from './plugin-key';
8
9
  import { provideVisualFeedbackForCopyButton, removeVisualFeedbackForCopyButton } from './pm-plugins/codeBlockCopySelectionPlugin';
10
+ import { WrapIcon } from './ui/icons/WrapIcon';
9
11
  var languageList = createLanguageList(DEFAULT_LANGUAGES);
10
12
  export var getToolbarConfig = function getToolbarConfig() {
11
13
  var allowCopyToClipboard = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
@@ -89,13 +91,21 @@ export var getToolbarConfig = function getToolbarConfig() {
89
91
  title: formatMessage(commonMessages.remove),
90
92
  tabIndex: null
91
93
  };
94
+ var codeBlockWrapButton = {
95
+ id: 'editor.codeBlock.wrap',
96
+ type: 'button',
97
+ icon: WrapIcon,
98
+ onClick: wrapCodeBlock,
99
+ title: formatMessage(codeBlockButtonMessages.wrapCode),
100
+ tabIndex: null
101
+ };
92
102
  return {
93
103
  title: 'CodeBlock floating controls',
94
104
  getDomRef: function getDomRef(view) {
95
105
  return findDomRefAtPos(pos, view.domAtPos.bind(view));
96
106
  },
97
107
  nodeType: nodeType,
98
- items: [languageSelect, separator].concat(copyToClipboardItems, [deleteButton]),
108
+ items: fg('editor_support_code_block_wrapping') ? [languageSelect, separator, codeBlockWrapButton, separator].concat(copyToClipboardItems, [deleteButton]) : [languageSelect, separator].concat(copyToClipboardItems, [deleteButton]),
99
109
  scrollable: true
100
110
  };
101
111
  };
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import Icon from '@atlaskit/icon';
3
+ var CustomGlyph = function CustomGlyph() {
4
+ return /*#__PURE__*/React.createElement("svg", {
5
+ width: "24",
6
+ height: "24",
7
+ fill: "none",
8
+ viewBox: "0 0 24 24"
9
+ }, /*#__PURE__*/React.createElement("g", {
10
+ fill: "currentColor",
11
+ clipPath: "url(#clip0_654_431)"
12
+ }, /*#__PURE__*/React.createElement("path", {
13
+ d: "M20 4h-1v16h1V4ZM3 8a1 1 0 0 1 1-1h9.5a4.5 4.5 0 1 1 0 9h-2.086l.293.293a1 1 0 0 1-1.414 1.414l-2-2a1 1 0 0 1 0-1.414l2-2a1 1 0 0 1 1.414 1.414l-.293.293H13.5a2.5 2.5 0 0 0 0-5H4a1 1 0 0 1-1-1Z",
14
+ clipRule: "evenodd",
15
+ fillRule: "evenodd"
16
+ })));
17
+ };
18
+ export var WrapIcon = function WrapIcon() {
19
+ return /*#__PURE__*/React.createElement(Icon, {
20
+ glyph: CustomGlyph,
21
+ label: "wrapIcon"
22
+ });
23
+ };
@@ -2,6 +2,7 @@ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/a
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare const removeCodeBlock: Command;
5
+ export declare const wrapCodeBlock: Command;
5
6
  export declare const changeLanguage: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (language: string) => Command;
6
7
  export declare const copyContentToClipboard: Command;
7
8
  export declare const resetCopiedState: Command;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const WrapIcon: () => JSX.Element;
@@ -2,6 +2,7 @@ import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/a
2
2
  import type { Command } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  export declare const removeCodeBlock: Command;
5
+ export declare const wrapCodeBlock: Command;
5
6
  export declare const changeLanguage: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (language: string) => Command;
6
7
  export declare const copyContentToClipboard: Command;
7
8
  export declare const resetCopiedState: Command;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const WrapIcon: () => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block",
3
- "version": "3.0.2",
3
+ "version": "3.1.0",
4
4
  "description": "Code block plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,15 +33,15 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/adf-schema": "^39.0.3",
36
+ "@atlaskit/adf-schema": "^40.3.0",
37
37
  "@atlaskit/code": "^15.4.0",
38
- "@atlaskit/editor-common": "^86.0.0",
39
- "@atlaskit/editor-plugin-analytics": "^1.4.0",
38
+ "@atlaskit/editor-common": "^86.7.0",
39
+ "@atlaskit/editor-plugin-analytics": "^1.5.0",
40
40
  "@atlaskit/editor-plugin-composition": "^1.1.0",
41
41
  "@atlaskit/editor-plugin-decorations": "^1.1.0",
42
42
  "@atlaskit/editor-plugin-editor-disabled": "^1.1.0",
43
43
  "@atlaskit/editor-prosemirror": "4.0.1",
44
- "@atlaskit/icon": "^22.6.0",
44
+ "@atlaskit/icon": "^22.7.0",
45
45
  "@atlaskit/platform-feature-flags": "^0.3.0",
46
46
  "@atlaskit/prosemirror-input-rules": "^3.1.0",
47
47
  "@babel/runtime": "^7.0.0",
@@ -93,6 +93,9 @@
93
93
  }
94
94
  },
95
95
  "platform-feature-flags": {
96
+ "editor_support_code_block_wrapping": {
97
+ "type": "boolean"
98
+ },
96
99
  "platform.editor.live-view.disable-editing-in-view-mode_fi1rx": {
97
100
  "type": "boolean"
98
101
  },