@atlaskit/editor-plugin-code-block-advanced 6.1.2 → 6.2.1

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-advanced
2
2
 
3
+ ## 6.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`2a658b46713fb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2a658b46713fb) -
8
+ upgrade use of browser util
9
+ - Updated dependencies
10
+
11
+ ## 6.2.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`5167552fe1a93`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5167552fe1a93) -
16
+ [EDITOR-2339] Bump @atlaskit/adf-schema to 51.3.0
17
+
18
+ ### Patch Changes
19
+
20
+ - [`685d27211d400`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/685d27211d400) -
21
+ [ux] Adjust codeblock font size relative to parent
22
+ - Updated dependencies
23
+
3
24
  ## 6.1.2
4
25
 
5
26
  ### Patch Changes
@@ -37,6 +37,7 @@ var codeBlockKeymap = function codeBlockKeymap(_ref2) {
37
37
  selectCodeBlockNode = _ref2.selectCodeBlockNode,
38
38
  onMaybeNodeSelection = _ref2.onMaybeNodeSelection,
39
39
  customFindReplace = _ref2.customFindReplace;
40
+ var browser = (0, _expValEquals.expValEquals)('platform_editor_hydratable_ui', 'isEnabled', true) ? (0, _browser.getBrowserInfo)() : _browser.browser;
40
41
  return [{
41
42
  key: 'ArrowUp',
42
43
  run: function run(cm) {
@@ -119,8 +120,8 @@ var codeBlockKeymap = function codeBlockKeymap(_ref2) {
119
120
  view.dispatchEvent(new KeyboardEvent('keydown', {
120
121
  key: 'f',
121
122
  code: 'KeyF',
122
- metaKey: _browser.browser.mac ? true : false,
123
- ctrlKey: _browser.browser.mac ? false : true
123
+ metaKey: browser.mac ? true : false,
124
+ ctrlKey: browser.mac ? false : true
124
125
  }));
125
126
  return true;
126
127
  }
@@ -172,8 +173,8 @@ var codeBlockKeymap = function codeBlockKeymap(_ref2) {
172
173
  view.dispatchEvent(new KeyboardEvent('keydown', {
173
174
  key: ']',
174
175
  code: 'BracketRight',
175
- metaKey: _browser.browser.mac ? true : false,
176
- ctrlKey: _browser.browser.mac ? false : true,
176
+ metaKey: browser.mac ? true : false,
177
+ ctrlKey: browser.mac ? false : true,
177
178
  altKey: true
178
179
  }));
179
180
  return true;
@@ -189,8 +190,8 @@ var codeBlockKeymap = function codeBlockKeymap(_ref2) {
189
190
  view.dispatchEvent(new KeyboardEvent('keydown', {
190
191
  key: ']',
191
192
  code: 'BracketLeft',
192
- metaKey: _browser.browser.mac ? true : false,
193
- ctrlKey: _browser.browser.mac ? false : true,
193
+ metaKey: browser.mac ? true : false,
194
+ ctrlKey: browser.mac ? false : true,
194
195
  altKey: true
195
196
  }));
196
197
  return true;
@@ -1,11 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.codeFoldingTheme = exports.cmTheme = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _view = require("@codemirror/view");
8
- var lineHeight = '1.5rem';
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
+ var getLineHeight = function getLineHeight() {
15
+ return (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ? '1.5em' : '1.5rem';
16
+ };
17
+ var getMaxGutterHeight = function getMaxGutterHeight() {
18
+ return (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ? '1.5em' : undefined;
19
+ };
20
+ var getFontSize = function getFontSize() {
21
+ return (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ? '0.875em' : '0.875rem';
22
+ };
9
23
  var cmTheme = exports.cmTheme = _view.EditorView.theme({
10
24
  '&': {
11
25
  backgroundColor: "var(--ds-background-neutral, #091E420F)",
@@ -13,10 +27,10 @@ var cmTheme = exports.cmTheme = _view.EditorView.theme({
13
27
  marginTop: "var(--ds-space-100, 8px)",
14
28
  marginBottom: "var(--ds-space-100, 8px)",
15
29
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
16
- fontSize: '0.875rem',
30
+ fontSize: getFontSize(),
17
31
  // Custom syntax styling to match existing styling
18
32
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
19
- lineHeight: lineHeight
33
+ lineHeight: getLineHeight()
20
34
  },
21
35
  '&.cm-focused': {
22
36
  outline: 'none'
@@ -69,10 +83,12 @@ var cmTheme = exports.cmTheme = _view.EditorView.theme({
69
83
  // codemirror is calculating (which happens after an animation frame).
70
84
  // Example problem: https://github.com/codemirror/dev/issues/1076
71
85
  // Ignore the first gutter element as it is a special hidden element.
72
- '.cm-gutterElement:not(:first-child)': {
86
+ '.cm-gutterElement:not(:first-child)': _objectSpread({
73
87
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
74
- minHeight: lineHeight
75
- }
88
+ minHeight: getLineHeight()
89
+ }, getMaxGutterHeight() && {
90
+ maxHeight: getMaxGutterHeight()
91
+ })
76
92
  });
77
93
  var codeFoldingTheme = exports.codeFoldingTheme = _view.EditorView.theme({
78
94
  '.cm-gutter': {
@@ -1,6 +1,6 @@
1
1
  import { defaultKeymap, indentWithTab } from '@codemirror/commands';
2
2
  import { keymap as cmKeymap } from '@codemirror/view';
3
- import { browser } from '@atlaskit/editor-common/browser';
3
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
4
4
  import { exitCode, selectAll } from '@atlaskit/editor-prosemirror/commands';
5
5
  import { undo, redo } from '@atlaskit/prosemirror-history';
6
6
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
@@ -31,6 +31,7 @@ const codeBlockKeymap = ({
31
31
  onMaybeNodeSelection,
32
32
  customFindReplace
33
33
  }) => {
34
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
34
35
  return [{
35
36
  key: 'ArrowUp',
36
37
  run: cm => maybeEscapeKeymap({
@@ -1,5 +1,9 @@
1
1
  import { EditorView as CodeMirror } from '@codemirror/view';
2
- const lineHeight = '1.5rem';
2
+ import { fg } from '@atlaskit/platform-feature-flags';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
+ const getLineHeight = () => expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '1.5em' : '1.5rem';
5
+ const getMaxGutterHeight = () => expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '1.5em' : undefined;
6
+ const getFontSize = () => expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '0.875em' : '0.875rem';
3
7
  export const cmTheme = CodeMirror.theme({
4
8
  '&': {
5
9
  backgroundColor: "var(--ds-background-neutral, #091E420F)",
@@ -7,10 +11,10 @@ export const cmTheme = CodeMirror.theme({
7
11
  marginTop: "var(--ds-space-100, 8px)",
8
12
  marginBottom: "var(--ds-space-100, 8px)",
9
13
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
10
- fontSize: '0.875rem',
14
+ fontSize: getFontSize(),
11
15
  // Custom syntax styling to match existing styling
12
16
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
13
- lineHeight: lineHeight
17
+ lineHeight: getLineHeight()
14
18
  },
15
19
  '&.cm-focused': {
16
20
  outline: 'none'
@@ -65,7 +69,10 @@ export const cmTheme = CodeMirror.theme({
65
69
  // Ignore the first gutter element as it is a special hidden element.
66
70
  '.cm-gutterElement:not(:first-child)': {
67
71
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
68
- minHeight: lineHeight
72
+ minHeight: getLineHeight(),
73
+ ...(getMaxGutterHeight() && {
74
+ maxHeight: getMaxGutterHeight()
75
+ })
69
76
  }
70
77
  });
71
78
  export const codeFoldingTheme = CodeMirror.theme({
@@ -1,7 +1,7 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import { defaultKeymap, indentWithTab } from '@codemirror/commands';
3
3
  import { keymap as cmKeymap } from '@codemirror/view';
4
- import { browser } from '@atlaskit/editor-common/browser';
4
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
5
5
  import { exitCode, selectAll } from '@atlaskit/editor-prosemirror/commands';
6
6
  import { undo, redo } from '@atlaskit/prosemirror-history';
7
7
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
@@ -30,6 +30,7 @@ var codeBlockKeymap = function codeBlockKeymap(_ref2) {
30
30
  selectCodeBlockNode = _ref2.selectCodeBlockNode,
31
31
  onMaybeNodeSelection = _ref2.onMaybeNodeSelection,
32
32
  customFindReplace = _ref2.customFindReplace;
33
+ var browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true) ? getBrowserInfo() : browserLegacy;
33
34
  return [{
34
35
  key: 'ArrowUp',
35
36
  run: function run(cm) {
@@ -1,5 +1,18 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import { EditorView as CodeMirror } from '@codemirror/view';
2
- var lineHeight = '1.5rem';
5
+ import { fg } from '@atlaskit/platform-feature-flags';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
7
+ var getLineHeight = function getLineHeight() {
8
+ return expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '1.5em' : '1.5rem';
9
+ };
10
+ var getMaxGutterHeight = function getMaxGutterHeight() {
11
+ return expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '1.5em' : undefined;
12
+ };
13
+ var getFontSize = function getFontSize() {
14
+ return expValEquals('cc_editor_ai_content_mode', 'variant', 'test') && fg('platform_editor_content_mode_button_mvp') ? '0.875em' : '0.875rem';
15
+ };
3
16
  export var cmTheme = CodeMirror.theme({
4
17
  '&': {
5
18
  backgroundColor: "var(--ds-background-neutral, #091E420F)",
@@ -7,10 +20,10 @@ export var cmTheme = CodeMirror.theme({
7
20
  marginTop: "var(--ds-space-100, 8px)",
8
21
  marginBottom: "var(--ds-space-100, 8px)",
9
22
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
10
- fontSize: '0.875rem',
23
+ fontSize: getFontSize(),
11
24
  // Custom syntax styling to match existing styling
12
25
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
13
- lineHeight: lineHeight
26
+ lineHeight: getLineHeight()
14
27
  },
15
28
  '&.cm-focused': {
16
29
  outline: 'none'
@@ -63,10 +76,12 @@ export var cmTheme = CodeMirror.theme({
63
76
  // codemirror is calculating (which happens after an animation frame).
64
77
  // Example problem: https://github.com/codemirror/dev/issues/1076
65
78
  // Ignore the first gutter element as it is a special hidden element.
66
- '.cm-gutterElement:not(:first-child)': {
79
+ '.cm-gutterElement:not(:first-child)': _objectSpread({
67
80
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
68
- minHeight: lineHeight
69
- }
81
+ minHeight: getLineHeight()
82
+ }, getMaxGutterHeight() && {
83
+ maxHeight: getMaxGutterHeight()
84
+ })
70
85
  });
71
86
  export var codeFoldingTheme = CodeMirror.theme({
72
87
  '.cm-gutter': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-code-block-advanced",
3
- "version": "6.1.2",
3
+ "version": "6.2.1",
4
4
  "description": "CodeBlockAdvanced plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,9 +28,9 @@
28
28
  "sideEffects": false,
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/adf-schema": "^51.2.0",
31
+ "@atlaskit/adf-schema": "^51.3.0",
32
32
  "@atlaskit/editor-plugin-block-menu": "^4.0.0",
33
- "@atlaskit/editor-plugin-code-block": "^8.0.0",
33
+ "@atlaskit/editor-plugin-code-block": "^8.1.0",
34
34
  "@atlaskit/editor-plugin-editor-disabled": "^6.1.0",
35
35
  "@atlaskit/editor-plugin-find-replace": "^6.0.0",
36
36
  "@atlaskit/editor-plugin-selection": "^6.1.0",
@@ -57,7 +57,7 @@
57
57
  "codemirror-lang-elixir": "4.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^110.13.0",
60
+ "@atlaskit/editor-common": "^110.14.0",
61
61
  "react": "^18.2.0",
62
62
  "react-intl-next": "npm:react-intl@^5.18.1"
63
63
  },
@@ -106,6 +106,9 @@
106
106
  },
107
107
  "platform_editor_block_menu_format_rank_revised": {
108
108
  "type": "boolean"
109
+ },
110
+ "platform_editor_content_mode_button_mvp": {
111
+ "type": "boolean"
109
112
  }
110
113
  }
111
114
  }
@@ -2,7 +2,7 @@ import { defaultKeymap, indentWithTab } from '@codemirror/commands';
2
2
  import { type Extension } from '@codemirror/state';
3
3
  import { type KeyBinding, keymap as cmKeymap } from '@codemirror/view';
4
4
 
5
- import { browser } from '@atlaskit/editor-common/browser';
5
+ import { browser as browserLegacy, getBrowserInfo } from '@atlaskit/editor-common/browser';
6
6
  import { type RelativeSelectionPos } from '@atlaskit/editor-common/selection';
7
7
  import type { getPosHandlerNode } from '@atlaskit/editor-common/types';
8
8
  import { exitCode, selectAll } from '@atlaskit/editor-prosemirror/commands';
@@ -51,6 +51,9 @@ const codeBlockKeymap = ({
51
51
  onMaybeNodeSelection,
52
52
  customFindReplace,
53
53
  }: KeymapProps): readonly KeyBinding[] => {
54
+ const browser = expValEquals('platform_editor_hydratable_ui', 'isEnabled', true)
55
+ ? getBrowserInfo()
56
+ : browserLegacy;
54
57
  return [
55
58
  {
56
59
  key: 'ArrowUp',
package/src/ui/theme.ts CHANGED
@@ -1,8 +1,26 @@
1
1
  import { EditorView as CodeMirror } from '@codemirror/view';
2
2
 
3
+ import { fg } from '@atlaskit/platform-feature-flags';
4
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
5
  import { token } from '@atlaskit/tokens';
4
6
 
5
- const lineHeight = '1.5rem';
7
+ const getLineHeight = () =>
8
+ expValEquals('cc_editor_ai_content_mode', 'variant', 'test') &&
9
+ fg('platform_editor_content_mode_button_mvp')
10
+ ? '1.5em'
11
+ : '1.5rem';
12
+
13
+ const getMaxGutterHeight = () =>
14
+ expValEquals('cc_editor_ai_content_mode', 'variant', 'test') &&
15
+ fg('platform_editor_content_mode_button_mvp')
16
+ ? '1.5em'
17
+ : undefined;
18
+
19
+ const getFontSize = () =>
20
+ expValEquals('cc_editor_ai_content_mode', 'variant', 'test') &&
21
+ fg('platform_editor_content_mode_button_mvp')
22
+ ? '0.875em'
23
+ : '0.875rem';
6
24
 
7
25
  export const cmTheme = CodeMirror.theme({
8
26
  '&': {
@@ -11,10 +29,10 @@ export const cmTheme = CodeMirror.theme({
11
29
  marginTop: token('space.100'),
12
30
  marginBottom: token('space.100'),
13
31
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
14
- fontSize: '0.875rem',
32
+ fontSize: getFontSize(),
15
33
  // Custom syntax styling to match existing styling
16
34
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
17
- lineHeight: lineHeight,
35
+ lineHeight: getLineHeight(),
18
36
  },
19
37
  '&.cm-focused': {
20
38
  outline: 'none',
@@ -69,7 +87,8 @@ export const cmTheme = CodeMirror.theme({
69
87
  // Ignore the first gutter element as it is a special hidden element.
70
88
  '.cm-gutterElement:not(:first-child)': {
71
89
  // eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
72
- minHeight: lineHeight,
90
+ minHeight: getLineHeight(),
91
+ ...(getMaxGutterHeight() && { maxHeight: getMaxGutterHeight() }),
73
92
  },
74
93
  });
75
94