@atlaskit/editor-core 151.1.2 → 151.2.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/cjs/create-editor/create-plugins-list.js +5 -2
  3. package/dist/cjs/labs/next/presets/default.js +3 -1
  4. package/dist/cjs/plugins/code-bidi-warning/index.js +5 -2
  5. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +12 -3
  6. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +15 -5
  7. package/dist/cjs/plugins/code-block/index.js +3 -3
  8. package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +6 -3
  9. package/dist/cjs/plugins/code-block/pm-plugins/main.js +11 -3
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/cjs/version.json +1 -1
  12. package/dist/es2019/create-editor/create-plugins-list.js +5 -2
  13. package/dist/es2019/labs/next/presets/default.js +3 -1
  14. package/dist/es2019/plugins/code-bidi-warning/index.js +8 -2
  15. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +12 -2
  16. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +16 -5
  17. package/dist/es2019/plugins/code-block/index.js +3 -2
  18. package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +6 -3
  19. package/dist/es2019/plugins/code-block/pm-plugins/main.js +11 -3
  20. package/dist/es2019/version-wrapper.js +1 -1
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/esm/create-editor/create-plugins-list.js +5 -2
  23. package/dist/esm/labs/next/presets/default.js +3 -1
  24. package/dist/esm/plugins/code-bidi-warning/index.js +5 -2
  25. package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +12 -3
  26. package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +15 -5
  27. package/dist/esm/plugins/code-block/index.js +3 -3
  28. package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +6 -3
  29. package/dist/esm/plugins/code-block/pm-plugins/main.js +11 -3
  30. package/dist/esm/version-wrapper.js +1 -1
  31. package/dist/esm/version.json +1 -1
  32. package/dist/types/plugins/code-bidi-warning/index.d.ts +4 -2
  33. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +4 -2
  34. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +2 -1
  35. package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +1 -0
  36. package/dist/types/plugins/code-block/index.d.ts +1 -1
  37. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +12 -1
  38. package/dist/types/plugins/code-block/pm-plugins/main.d.ts +3 -1
  39. package/dist/types/plugins/code-block/types.d.ts +2 -0
  40. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 151.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`db3477abb18`](https://bitbucket.org/atlassian/atlassian-frontend/commits/db3477abb18) - [ux] ED-13938 disabled code-bidi warning tooltip for mobile, reworked TextWrapper to fix bidi mitigation, and fixed issue where bidi warnings were not presented when renderer used with an annotation provider with draftMode set to true
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 151.1.2
4
14
 
5
15
  ### Patch Changes
@@ -115,7 +115,8 @@ function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEvent) {
115
115
  },
116
116
  cardOptions: props.smartLinks || props.UNSAFE_cards,
117
117
  codeBlock: _objectSpread(_objectSpread({}, props.codeBlock), {}, {
118
- useLongPressSelection: false
118
+ useLongPressSelection: false,
119
+ appearance: props.appearance
119
120
  })
120
121
  };
121
122
  }
@@ -414,7 +415,9 @@ function createPluginsList(props, prevProps, createAnalyticsEvent) {
414
415
  }
415
416
 
416
417
  if (featureFlags.codeBidiWarnings) {
417
- preset.add(_plugins.codeBidiWarningPlugin);
418
+ preset.add([_plugins.codeBidiWarningPlugin, {
419
+ appearance: props.appearance
420
+ }]);
418
421
  }
419
422
 
420
423
  var excludes = new Set();
@@ -99,7 +99,9 @@ function createDefaultPreset(options) {
99
99
  preset.add(_floatingToolbar.default);
100
100
  preset.add([_featureFlagsContext.default, options.featureFlags || {}]);
101
101
  preset.add([_selection.default, options.selection]);
102
- preset.add([_codeBlock.default, options.codeBlock]);
102
+ preset.add([_codeBlock.default, options.codeBlock || {
103
+ appearance: 'full-page'
104
+ }]);
103
105
  return preset;
104
106
  }
105
107
 
@@ -7,14 +7,17 @@ exports.default = void 0;
7
7
 
8
8
  var _main = require("./pm-plugins/main");
9
9
 
10
- var codeBidiWarning = function codeBidiWarning() {
10
+ var codeBidiWarning = function codeBidiWarning(_ref) {
11
+ var appearance = _ref.appearance;
11
12
  return {
12
13
  name: 'codeBidiWarning',
13
14
  pmPlugins: function pmPlugins() {
14
15
  return [{
15
16
  name: 'codeBidiWarning',
16
17
  plugin: function plugin(options) {
17
- return (0, _main.createPlugin)(options);
18
+ return (0, _main.createPlugin)(options, {
19
+ appearance: appearance
20
+ });
18
21
  }
19
22
  }];
20
23
  }
@@ -13,20 +13,29 @@ var _pluginKey = require("../plugin-key");
13
13
 
14
14
  var _pluginFactory = require("./plugin-factory");
15
15
 
16
- var createPlugin = function createPlugin(_ref) {
16
+ var createPlugin = function createPlugin(_ref, _ref2) {
17
17
  var dispatch = _ref.dispatch,
18
18
  reactContext = _ref.reactContext;
19
+ var appearance = _ref2.appearance;
19
20
  var intl = reactContext().intl;
20
21
  var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label);
21
22
  return new _prosemirrorState.Plugin({
22
23
  key: _pluginKey.codeBidiWarningPluginKey,
23
24
  state: (0, _pluginFactory.createPluginState)(dispatch, function (state) {
25
+ // The appearance being mobile indicates we are in an editor being
26
+ // rendered by mobile bridge in a web view.
27
+ // The tooltip is likely to have unexpected behaviour there, with being cut
28
+ // off, so we disable it. This is also to keep the behaviour consistent with
29
+ // the rendering in the mobile Native Renderer.
30
+ var tooltipEnabled = appearance !== 'mobile';
24
31
  return {
25
32
  decorationSet: (0, _pluginFactory.createBidiWarningsDecorationSetFromDoc)({
26
33
  doc: state.doc,
27
- codeBidiWarningLabel: codeBidiWarningLabel
34
+ codeBidiWarningLabel: codeBidiWarningLabel,
35
+ tooltipEnabled: tooltipEnabled
28
36
  }),
29
- codeBidiWarningLabel: codeBidiWarningLabel
37
+ codeBidiWarningLabel: codeBidiWarningLabel,
38
+ tooltipEnabled: tooltipEnabled
30
39
  };
31
40
  }),
32
41
  props: {
@@ -40,7 +40,8 @@ var _pluginFactory = (0, _pluginStateFactory.pluginFactory)(_pluginKey.codeBidiW
40
40
 
41
41
  var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
42
42
  doc: tr.doc,
43
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel
43
+ codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
44
+ tooltipEnabled: pluginState.tooltipEnabled
44
45
  });
45
46
  return _objectSpread(_objectSpread({}, pluginState), {}, {
46
47
  decorationSet: newBidiWarningsDecorationSet
@@ -55,7 +56,8 @@ exports.createPluginState = createPluginState;
55
56
 
56
57
  function createBidiWarningsDecorationSetFromDoc(_ref) {
57
58
  var doc = _ref.doc,
58
- codeBidiWarningLabel = _ref.codeBidiWarningLabel;
59
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
60
+ tooltipEnabled = _ref.tooltipEnabled;
59
61
  var bidiCharactersAndTheirPositions = [];
60
62
  doc.descendants(function (node, pos) {
61
63
  var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
@@ -97,21 +99,29 @@ function createBidiWarningsDecorationSetFromDoc(_ref) {
97
99
  var position = _ref4.position,
98
100
  bidiCharacter = _ref4.bidiCharacter;
99
101
  return _prosemirrorView.Decoration.widget(position, function () {
100
- return renderDOM(bidiCharacter, codeBidiWarningLabel);
102
+ return renderDOM({
103
+ bidiCharacter: bidiCharacter,
104
+ codeBidiWarningLabel: codeBidiWarningLabel,
105
+ tooltipEnabled: tooltipEnabled
106
+ });
101
107
  });
102
108
  }));
103
109
 
104
110
  return newBidiWarningsDecorationSet;
105
111
  }
106
112
 
107
- function renderDOM(bidiCharacter, codeBidiWarningLabel) {
113
+ function renderDOM(_ref5) {
114
+ var bidiCharacter = _ref5.bidiCharacter,
115
+ codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
116
+ tooltipEnabled = _ref5.tooltipEnabled;
108
117
  var element = document.createElement('span'); // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
109
118
  // we should investigate if there is a memory leak with such usage.
110
119
 
111
120
  _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
112
121
  bidiCharacter: bidiCharacter,
113
122
  skipChildren: true,
114
- label: codeBidiWarningLabel
123
+ label: codeBidiWarningLabel,
124
+ tooltipEnabled: tooltipEnabled
115
125
  }), element);
116
126
 
117
127
  return element;
@@ -27,8 +27,7 @@ var _messages = require("../block-type/messages");
27
27
 
28
28
  var _refreshBrowserSelection = _interopRequireDefault(require("./refresh-browser-selection"));
29
29
 
30
- var codeBlockPlugin = function codeBlockPlugin() {
31
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
30
+ var codeBlockPlugin = function codeBlockPlugin(options) {
32
31
  return {
33
32
  name: 'codeBlock',
34
33
  nodes: function nodes() {
@@ -44,7 +43,8 @@ var codeBlockPlugin = function codeBlockPlugin() {
44
43
  var reactContext = _ref.reactContext;
45
44
  return (0, _main.createPlugin)({
46
45
  useLongPressSelection: options.useLongPressSelection,
47
- reactContext: reactContext
46
+ reactContext: reactContext,
47
+ appearance: options.appearance
48
48
  });
49
49
  }
50
50
  }, {
@@ -133,7 +133,8 @@ var CodeBlockView = /*#__PURE__*/function () {
133
133
  language: node.attrs.language,
134
134
  showLineNumbers: false,
135
135
  codeBidiWarnings: this.codeBidiWarningOptions.enabled,
136
- codeBidiWarningLabel: this.codeBidiWarningOptions.label
136
+ codeBidiWarningLabel: this.codeBidiWarningOptions.label,
137
+ codeBidiWarningTooltipEnabled: this.codeBidiWarningOptions.tooltipEnabled
137
138
  }), highlighting);
138
139
 
139
140
  this.measure(performance.now() - start);
@@ -180,11 +181,13 @@ exports.CodeBlockView = CodeBlockView;
180
181
 
181
182
  var highlightingCodeBlockNodeView = function highlightingCodeBlockNodeView(_ref) {
182
183
  var codeBidiWarnings = _ref.codeBidiWarnings,
183
- codeBidiWarningLabel = _ref.codeBidiWarningLabel;
184
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
185
+ codeBidiWarningTooltipEnabled = _ref.codeBidiWarningTooltipEnabled;
184
186
  return function (node, view, getPos) {
185
187
  return new CodeBlockView(node, view, getPos, {
188
+ label: codeBidiWarningLabel,
186
189
  enabled: codeBidiWarnings,
187
- label: codeBidiWarningLabel
190
+ tooltipEnabled: codeBidiWarningTooltipEnabled
188
191
  });
189
192
  };
190
193
  };
@@ -36,7 +36,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
36
36
  var createPlugin = function createPlugin(_ref) {
37
37
  var _ref$useLongPressSele = _ref.useLongPressSelection,
38
38
  useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
39
- reactContext = _ref.reactContext;
39
+ reactContext = _ref.reactContext,
40
+ appearance = _ref.appearance;
40
41
  var intl = reactContext().intl;
41
42
  var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label);
42
43
  return new _prosemirrorState.Plugin({
@@ -76,10 +77,17 @@ var createPlugin = function createPlugin(_ref) {
76
77
  props: {
77
78
  nodeViews: {
78
79
  codeBlock: function codeBlock(node, view, getPos) {
79
- var featureFlags = (0, _featureFlagsContext.getFeatureFlags)(view.state);
80
+ var featureFlags = (0, _featureFlagsContext.getFeatureFlags)(view.state); // The appearance being mobile indicates we are in an editor being
81
+ // rendered by mobile bridge in a web view.
82
+ // The tooltip is likely to have unexpected behaviour there, with being cut
83
+ // off, so we disable it. This is also to keep the behaviour consistent with
84
+ // the rendering in the mobile Native Renderer.
85
+
86
+ var codeBidiWarningTooltipEnabled = appearance !== 'mobile';
80
87
  var createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? (0, _highlightingCodeBlock.highlightingCodeBlockNodeView)({
81
88
  codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
82
- codeBidiWarningLabel: codeBidiWarningLabel
89
+ codeBidiWarningLabel: codeBidiWarningLabel,
90
+ codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
83
91
  }) : (0, _codeBlock.codeBlockNodeView)();
84
92
  return createCodeBlockNodeView(node, view, getPos);
85
93
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.nextMajorVersion = exports.version = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "151.1.2";
9
+ var version = "151.2.0";
10
10
  exports.version = version;
11
11
 
12
12
  var nextMajorVersion = function nextMajorVersion() {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "151.1.2",
3
+ "version": "151.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -87,7 +87,8 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
87
87
  },
88
88
  cardOptions: props.smartLinks || props.UNSAFE_cards,
89
89
  codeBlock: { ...props.codeBlock,
90
- useLongPressSelection: false
90
+ useLongPressSelection: false,
91
+ appearance: props.appearance
91
92
  }
92
93
  };
93
94
  }
@@ -390,7 +391,9 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
390
391
  }
391
392
 
392
393
  if (featureFlags.codeBidiWarnings) {
393
- preset.add(codeBidiWarningPlugin);
394
+ preset.add([codeBidiWarningPlugin, {
395
+ appearance: props.appearance
396
+ }]);
394
397
  }
395
398
 
396
399
  const excludes = new Set();
@@ -62,7 +62,9 @@ export function createDefaultPreset(options) {
62
62
  preset.add(floatingToolbarPlugin);
63
63
  preset.add([featureFlagsContextPlugin, options.featureFlags || {}]);
64
64
  preset.add([selectionPlugin, options.selection]);
65
- preset.add([codeBlockPlugin, options.codeBlock]);
65
+ preset.add([codeBlockPlugin, options.codeBlock || {
66
+ appearance: 'full-page'
67
+ }]);
66
68
  return preset;
67
69
  }
68
70
  export function useDefaultPreset(props) {
@@ -1,12 +1,18 @@
1
1
  import { createPlugin } from './pm-plugins/main';
2
2
 
3
- const codeBidiWarning = () => ({
3
+ const codeBidiWarning = ({
4
+ appearance
5
+ }) => ({
4
6
  name: 'codeBidiWarning',
5
7
 
6
8
  pmPlugins() {
7
9
  return [{
8
10
  name: 'codeBidiWarning',
9
- plugin: options => createPlugin(options)
11
+ plugin: options => {
12
+ return createPlugin(options, {
13
+ appearance
14
+ });
15
+ }
10
16
  }];
11
17
  }
12
18
 
@@ -5,18 +5,28 @@ import { createBidiWarningsDecorationSetFromDoc, createPluginState, getPluginSta
5
5
  export const createPlugin = ({
6
6
  dispatch,
7
7
  reactContext
8
+ }, {
9
+ appearance
8
10
  }) => {
9
11
  const intl = reactContext().intl;
10
12
  const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
11
13
  return new Plugin({
12
14
  key: codeBidiWarningPluginKey,
13
15
  state: createPluginState(dispatch, state => {
16
+ // The appearance being mobile indicates we are in an editor being
17
+ // rendered by mobile bridge in a web view.
18
+ // The tooltip is likely to have unexpected behaviour there, with being cut
19
+ // off, so we disable it. This is also to keep the behaviour consistent with
20
+ // the rendering in the mobile Native Renderer.
21
+ const tooltipEnabled = appearance !== 'mobile';
14
22
  return {
15
23
  decorationSet: createBidiWarningsDecorationSetFromDoc({
16
24
  doc: state.doc,
17
- codeBidiWarningLabel
25
+ codeBidiWarningLabel,
26
+ tooltipEnabled
18
27
  }),
19
- codeBidiWarningLabel
28
+ codeBidiWarningLabel,
29
+ tooltipEnabled
20
30
  };
21
31
  }),
22
32
  props: {
@@ -18,7 +18,8 @@ export const {
18
18
 
19
19
  const newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
20
20
  doc: tr.doc,
21
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel
21
+ codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
22
+ tooltipEnabled: pluginState.tooltipEnabled
22
23
  });
23
24
  return { ...pluginState,
24
25
  decorationSet: newBidiWarningsDecorationSet
@@ -27,7 +28,8 @@ export const {
27
28
  });
28
29
  export function createBidiWarningsDecorationSetFromDoc({
29
30
  doc,
30
- codeBidiWarningLabel
31
+ codeBidiWarningLabel,
32
+ tooltipEnabled
31
33
  }) {
32
34
  const bidiCharactersAndTheirPositions = [];
33
35
  doc.descendants((node, pos) => {
@@ -70,19 +72,28 @@ export function createBidiWarningsDecorationSetFromDoc({
70
72
  position,
71
73
  bidiCharacter
72
74
  }) => {
73
- return Decoration.widget(position, () => renderDOM(bidiCharacter, codeBidiWarningLabel));
75
+ return Decoration.widget(position, () => renderDOM({
76
+ bidiCharacter,
77
+ codeBidiWarningLabel,
78
+ tooltipEnabled
79
+ }));
74
80
  }));
75
81
  return newBidiWarningsDecorationSet;
76
82
  }
77
83
 
78
- function renderDOM(bidiCharacter, codeBidiWarningLabel) {
84
+ function renderDOM({
85
+ bidiCharacter,
86
+ codeBidiWarningLabel,
87
+ tooltipEnabled
88
+ }) {
79
89
  const element = document.createElement('span'); // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
80
90
  // we should investigate if there is a memory leak with such usage.
81
91
 
82
92
  ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
83
93
  bidiCharacter: bidiCharacter,
84
94
  skipChildren: true,
85
- label: codeBidiWarningLabel
95
+ label: codeBidiWarningLabel,
96
+ tooltipEnabled: tooltipEnabled
86
97
  }), element);
87
98
  return element;
88
99
  }
@@ -9,7 +9,7 @@ import { IconCode } from '../quick-insert/assets';
9
9
  import { messages } from '../block-type/messages';
10
10
  import refreshBrowserSelectionOnChange from './refresh-browser-selection';
11
11
 
12
- const codeBlockPlugin = (options = {}) => ({
12
+ const codeBlockPlugin = options => ({
13
13
  name: 'codeBlock',
14
14
 
15
15
  nodes() {
@@ -26,7 +26,8 @@ const codeBlockPlugin = (options = {}) => ({
26
26
  reactContext
27
27
  }) => createPlugin({
28
28
  useLongPressSelection: options.useLongPressSelection,
29
- reactContext
29
+ reactContext,
30
+ appearance: options.appearance
30
31
  })
31
32
  }, {
32
33
  name: 'codeBlockIDEKeyBindings',
@@ -102,7 +102,8 @@ export class CodeBlockView {
102
102
  language: node.attrs.language,
103
103
  showLineNumbers: false,
104
104
  codeBidiWarnings: this.codeBidiWarningOptions.enabled,
105
- codeBidiWarningLabel: this.codeBidiWarningOptions.label
105
+ codeBidiWarningLabel: this.codeBidiWarningOptions.label,
106
+ codeBidiWarningTooltipEnabled: this.codeBidiWarningOptions.tooltipEnabled
106
107
  }), highlighting);
107
108
  this.measure(performance.now() - start);
108
109
  content === null || content === void 0 ? void 0 : content.setAttribute('data-debounce', 'false');
@@ -142,8 +143,10 @@ export class CodeBlockView {
142
143
  }
143
144
  export const highlightingCodeBlockNodeView = ({
144
145
  codeBidiWarnings,
145
- codeBidiWarningLabel
146
+ codeBidiWarningLabel,
147
+ codeBidiWarningTooltipEnabled
146
148
  }) => (node, view, getPos) => new CodeBlockView(node, view, getPos, {
149
+ label: codeBidiWarningLabel,
147
150
  enabled: codeBidiWarnings,
148
- label: codeBidiWarningLabel
151
+ tooltipEnabled: codeBidiWarningTooltipEnabled
149
152
  });
@@ -10,7 +10,8 @@ import { codeBlockClassNames } from '../ui/class-names';
10
10
  import { getFeatureFlags } from '../../feature-flags-context';
11
11
  export const createPlugin = ({
12
12
  useLongPressSelection = false,
13
- reactContext
13
+ reactContext,
14
+ appearance
14
15
  }) => {
15
16
  const intl = reactContext().intl;
16
17
  const codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
@@ -51,10 +52,17 @@ export const createPlugin = ({
51
52
  props: {
52
53
  nodeViews: {
53
54
  codeBlock(node, view, getPos) {
54
- const featureFlags = getFeatureFlags(view.state);
55
+ const featureFlags = getFeatureFlags(view.state); // The appearance being mobile indicates we are in an editor being
56
+ // rendered by mobile bridge in a web view.
57
+ // The tooltip is likely to have unexpected behaviour there, with being cut
58
+ // off, so we disable it. This is also to keep the behaviour consistent with
59
+ // the rendering in the mobile Native Renderer.
60
+
61
+ const codeBidiWarningTooltipEnabled = appearance !== 'mobile';
55
62
  const createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView({
56
63
  codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
57
- codeBidiWarningLabel
64
+ codeBidiWarningLabel,
65
+ codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
58
66
  }) : codeBlockNodeView();
59
67
  return createCodeBlockNodeView(node, view, getPos);
60
68
  }
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "151.1.2";
2
+ export const version = "151.2.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "151.1.2",
3
+ "version": "151.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -96,7 +96,8 @@ export function getDefaultPresetOptionsFromEditorProps(props, createAnalyticsEve
96
96
  },
97
97
  cardOptions: props.smartLinks || props.UNSAFE_cards,
98
98
  codeBlock: _objectSpread(_objectSpread({}, props.codeBlock), {}, {
99
- useLongPressSelection: false
99
+ useLongPressSelection: false,
100
+ appearance: props.appearance
100
101
  })
101
102
  };
102
103
  }
@@ -394,7 +395,9 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
394
395
  }
395
396
 
396
397
  if (featureFlags.codeBidiWarnings) {
397
- preset.add(codeBidiWarningPlugin);
398
+ preset.add([codeBidiWarningPlugin, {
399
+ appearance: props.appearance
400
+ }]);
398
401
  }
399
402
 
400
403
  var excludes = new Set();
@@ -63,7 +63,9 @@ export function createDefaultPreset(options) {
63
63
  preset.add(floatingToolbarPlugin);
64
64
  preset.add([featureFlagsContextPlugin, options.featureFlags || {}]);
65
65
  preset.add([selectionPlugin, options.selection]);
66
- preset.add([codeBlockPlugin, options.codeBlock]);
66
+ preset.add([codeBlockPlugin, options.codeBlock || {
67
+ appearance: 'full-page'
68
+ }]);
67
69
  return preset;
68
70
  }
69
71
  export function useDefaultPreset(props) {
@@ -1,13 +1,16 @@
1
1
  import { createPlugin } from './pm-plugins/main';
2
2
 
3
- var codeBidiWarning = function codeBidiWarning() {
3
+ var codeBidiWarning = function codeBidiWarning(_ref) {
4
+ var appearance = _ref.appearance;
4
5
  return {
5
6
  name: 'codeBidiWarning',
6
7
  pmPlugins: function pmPlugins() {
7
8
  return [{
8
9
  name: 'codeBidiWarning',
9
10
  plugin: function plugin(options) {
10
- return createPlugin(options);
11
+ return createPlugin(options, {
12
+ appearance: appearance
13
+ });
11
14
  }
12
15
  }];
13
16
  }
@@ -2,20 +2,29 @@ import { Plugin } from 'prosemirror-state';
2
2
  import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
3
3
  import { codeBidiWarningPluginKey } from '../plugin-key';
4
4
  import { createBidiWarningsDecorationSetFromDoc, createPluginState, getPluginState } from './plugin-factory';
5
- export var createPlugin = function createPlugin(_ref) {
5
+ export var createPlugin = function createPlugin(_ref, _ref2) {
6
6
  var dispatch = _ref.dispatch,
7
7
  reactContext = _ref.reactContext;
8
+ var appearance = _ref2.appearance;
8
9
  var intl = reactContext().intl;
9
10
  var codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
10
11
  return new Plugin({
11
12
  key: codeBidiWarningPluginKey,
12
13
  state: createPluginState(dispatch, function (state) {
14
+ // The appearance being mobile indicates we are in an editor being
15
+ // rendered by mobile bridge in a web view.
16
+ // The tooltip is likely to have unexpected behaviour there, with being cut
17
+ // off, so we disable it. This is also to keep the behaviour consistent with
18
+ // the rendering in the mobile Native Renderer.
19
+ var tooltipEnabled = appearance !== 'mobile';
13
20
  return {
14
21
  decorationSet: createBidiWarningsDecorationSetFromDoc({
15
22
  doc: state.doc,
16
- codeBidiWarningLabel: codeBidiWarningLabel
23
+ codeBidiWarningLabel: codeBidiWarningLabel,
24
+ tooltipEnabled: tooltipEnabled
17
25
  }),
18
- codeBidiWarningLabel: codeBidiWarningLabel
26
+ codeBidiWarningLabel: codeBidiWarningLabel,
27
+ tooltipEnabled: tooltipEnabled
19
28
  };
20
29
  }),
21
30
  props: {
@@ -22,7 +22,8 @@ var _pluginFactory = pluginFactory(codeBidiWarningPluginKey, reducer, {
22
22
 
23
23
  var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
24
24
  doc: tr.doc,
25
- codeBidiWarningLabel: pluginState.codeBidiWarningLabel
25
+ codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
26
+ tooltipEnabled: pluginState.tooltipEnabled
26
27
  });
27
28
  return _objectSpread(_objectSpread({}, pluginState), {}, {
28
29
  decorationSet: newBidiWarningsDecorationSet
@@ -35,7 +36,8 @@ var _pluginFactory = pluginFactory(codeBidiWarningPluginKey, reducer, {
35
36
  export { createPluginState, getPluginState };
36
37
  export function createBidiWarningsDecorationSetFromDoc(_ref) {
37
38
  var doc = _ref.doc,
38
- codeBidiWarningLabel = _ref.codeBidiWarningLabel;
39
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
40
+ tooltipEnabled = _ref.tooltipEnabled;
39
41
  var bidiCharactersAndTheirPositions = [];
40
42
  doc.descendants(function (node, pos) {
41
43
  var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
@@ -77,20 +79,28 @@ export function createBidiWarningsDecorationSetFromDoc(_ref) {
77
79
  var position = _ref4.position,
78
80
  bidiCharacter = _ref4.bidiCharacter;
79
81
  return Decoration.widget(position, function () {
80
- return renderDOM(bidiCharacter, codeBidiWarningLabel);
82
+ return renderDOM({
83
+ bidiCharacter: bidiCharacter,
84
+ codeBidiWarningLabel: codeBidiWarningLabel,
85
+ tooltipEnabled: tooltipEnabled
86
+ });
81
87
  });
82
88
  }));
83
89
  return newBidiWarningsDecorationSet;
84
90
  }
85
91
 
86
- function renderDOM(bidiCharacter, codeBidiWarningLabel) {
92
+ function renderDOM(_ref5) {
93
+ var bidiCharacter = _ref5.bidiCharacter,
94
+ codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
95
+ tooltipEnabled = _ref5.tooltipEnabled;
87
96
  var element = document.createElement('span'); // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
88
97
  // we should investigate if there is a memory leak with such usage.
89
98
 
90
99
  ReactDOM.render( /*#__PURE__*/React.createElement(CodeBidiWarning, {
91
100
  bidiCharacter: bidiCharacter,
92
101
  skipChildren: true,
93
- label: codeBidiWarningLabel
102
+ label: codeBidiWarningLabel,
103
+ tooltipEnabled: tooltipEnabled
94
104
  }), element);
95
105
  return element;
96
106
  }
@@ -9,8 +9,7 @@ import { IconCode } from '../quick-insert/assets';
9
9
  import { messages } from '../block-type/messages';
10
10
  import refreshBrowserSelectionOnChange from './refresh-browser-selection';
11
11
 
12
- var codeBlockPlugin = function codeBlockPlugin() {
13
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
+ var codeBlockPlugin = function codeBlockPlugin(options) {
14
13
  return {
15
14
  name: 'codeBlock',
16
15
  nodes: function nodes() {
@@ -26,7 +25,8 @@ var codeBlockPlugin = function codeBlockPlugin() {
26
25
  var reactContext = _ref.reactContext;
27
26
  return createPlugin({
28
27
  useLongPressSelection: options.useLongPressSelection,
29
- reactContext: reactContext
28
+ reactContext: reactContext,
29
+ appearance: options.appearance
30
30
  });
31
31
  }
32
32
  }, {
@@ -121,7 +121,8 @@ export var CodeBlockView = /*#__PURE__*/function () {
121
121
  language: node.attrs.language,
122
122
  showLineNumbers: false,
123
123
  codeBidiWarnings: this.codeBidiWarningOptions.enabled,
124
- codeBidiWarningLabel: this.codeBidiWarningOptions.label
124
+ codeBidiWarningLabel: this.codeBidiWarningOptions.label,
125
+ codeBidiWarningTooltipEnabled: this.codeBidiWarningOptions.tooltipEnabled
125
126
  }), highlighting);
126
127
  this.measure(performance.now() - start);
127
128
  content === null || content === void 0 ? void 0 : content.setAttribute('data-debounce', 'false');
@@ -165,11 +166,13 @@ export var CodeBlockView = /*#__PURE__*/function () {
165
166
  }();
166
167
  export var highlightingCodeBlockNodeView = function highlightingCodeBlockNodeView(_ref) {
167
168
  var codeBidiWarnings = _ref.codeBidiWarnings,
168
- codeBidiWarningLabel = _ref.codeBidiWarningLabel;
169
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
170
+ codeBidiWarningTooltipEnabled = _ref.codeBidiWarningTooltipEnabled;
169
171
  return function (node, view, getPos) {
170
172
  return new CodeBlockView(node, view, getPos, {
173
+ label: codeBidiWarningLabel,
171
174
  enabled: codeBidiWarnings,
172
- label: codeBidiWarningLabel
175
+ tooltipEnabled: codeBidiWarningTooltipEnabled
173
176
  });
174
177
  };
175
178
  };
@@ -17,7 +17,8 @@ import { getFeatureFlags } from '../../feature-flags-context';
17
17
  export var createPlugin = function createPlugin(_ref) {
18
18
  var _ref$useLongPressSele = _ref.useLongPressSelection,
19
19
  useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
20
- reactContext = _ref.reactContext;
20
+ reactContext = _ref.reactContext,
21
+ appearance = _ref.appearance;
21
22
  var intl = reactContext().intl;
22
23
  var codeBidiWarningLabel = intl.formatMessage(codeBidiWarningMessages.label);
23
24
  return new Plugin({
@@ -57,10 +58,17 @@ export var createPlugin = function createPlugin(_ref) {
57
58
  props: {
58
59
  nodeViews: {
59
60
  codeBlock: function codeBlock(node, view, getPos) {
60
- var featureFlags = getFeatureFlags(view.state);
61
+ var featureFlags = getFeatureFlags(view.state); // The appearance being mobile indicates we are in an editor being
62
+ // rendered by mobile bridge in a web view.
63
+ // The tooltip is likely to have unexpected behaviour there, with being cut
64
+ // off, so we disable it. This is also to keep the behaviour consistent with
65
+ // the rendering in the mobile Native Renderer.
66
+
67
+ var codeBidiWarningTooltipEnabled = appearance !== 'mobile';
61
68
  var createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? highlightingCodeBlockNodeView({
62
69
  codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
63
- codeBidiWarningLabel: codeBidiWarningLabel
70
+ codeBidiWarningLabel: codeBidiWarningLabel,
71
+ codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
64
72
  }) : codeBlockNodeView();
65
73
  return createCodeBlockNodeView(node, view, getPos);
66
74
  }
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "151.1.2";
2
+ export var version = "151.2.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "151.1.2",
3
+ "version": "151.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,5 @@
1
- import { EditorPlugin } from '../../types';
2
- declare const codeBidiWarning: () => EditorPlugin;
1
+ import type { EditorPlugin, EditorProps } from '../../types';
2
+ declare const codeBidiWarning: ({ appearance, }: {
3
+ appearance: EditorProps['appearance'];
4
+ }) => EditorPlugin;
3
5
  export default codeBidiWarning;
@@ -1,3 +1,5 @@
1
1
  import { Plugin } from 'prosemirror-state';
2
- import { PMPluginFactoryParams } from '../../../types';
3
- export declare const createPlugin: ({ dispatch, reactContext, }: PMPluginFactoryParams) => Plugin<any, import("prosemirror-model").Schema<any, any>>;
2
+ import type { EditorProps, PMPluginFactoryParams } from '../../../types';
3
+ export declare const createPlugin: ({ dispatch, reactContext }: PMPluginFactoryParams, { appearance }: {
4
+ appearance: EditorProps['appearance'];
5
+ }) => Plugin<any, import("prosemirror-model").Schema<any, any>>;
@@ -1,7 +1,8 @@
1
1
  import { DecorationSet } from 'prosemirror-view';
2
2
  import { Node as PmNode } from 'prosemirror-model';
3
3
  export declare const createPluginState: (dispatch: import("../../../event-dispatcher").Dispatch<any>, initialState: import("./types").CodeBidiWarningPluginState | ((state: import("prosemirror-state").EditorState<any>) => import("./types").CodeBidiWarningPluginState)) => import("prosemirror-state").StateField<import("./types").CodeBidiWarningPluginState, import("prosemirror-model").Schema<any, any>>, getPluginState: (state: import("prosemirror-state").EditorState<any>) => import("./types").CodeBidiWarningPluginState;
4
- export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, }: {
4
+ export declare function createBidiWarningsDecorationSetFromDoc({ doc, codeBidiWarningLabel, tooltipEnabled, }: {
5
5
  doc: PmNode<any>;
6
6
  codeBidiWarningLabel: string;
7
+ tooltipEnabled: boolean;
7
8
  }): DecorationSet<any>;
@@ -2,4 +2,5 @@ import { DecorationSet } from 'prosemirror-view';
2
2
  export declare type CodeBidiWarningPluginState = {
3
3
  decorationSet: DecorationSet;
4
4
  codeBidiWarningLabel: string;
5
+ tooltipEnabled: boolean;
5
6
  };
@@ -1,4 +1,4 @@
1
1
  import { EditorPlugin } from '../../types';
2
2
  import { CodeBlockOptions } from './types';
3
- declare const codeBlockPlugin: (options?: CodeBlockOptions) => EditorPlugin;
3
+ declare const codeBlockPlugin: (options: CodeBlockOptions) => EditorPlugin;
4
4
  export default codeBlockPlugin;
@@ -4,6 +4,16 @@ import { getPosHandlerNode, getPosHandler } from '../../../nodeviews/';
4
4
  import React from 'react';
5
5
  declare type CodeBidiWarningOptions = {
6
6
  label: string;
7
+ /**
8
+ * Intended to be disabled when used in a mobile view, such as in the editor
9
+ * via mobile bridge, where the tooltip could end up being cut off of otherwise
10
+ * not work as expected.
11
+ */
12
+ tooltipEnabled: boolean;
13
+ /**
14
+ * Indicates if code bidi warning should be used, was created to allow
15
+ * disabling code bidi warnings via a feature flag in products.
16
+ */
7
17
  enabled?: boolean;
8
18
  };
9
19
  export declare class CodeBlockView {
@@ -30,8 +40,9 @@ export declare class CodeBlockView {
30
40
  target: Element;
31
41
  }): boolean;
32
42
  }
33
- export declare const highlightingCodeBlockNodeView: ({ codeBidiWarnings, codeBidiWarningLabel, }: {
43
+ export declare const highlightingCodeBlockNodeView: ({ codeBidiWarnings, codeBidiWarningLabel, codeBidiWarningTooltipEnabled, }: {
34
44
  codeBidiWarnings?: boolean | undefined;
35
45
  codeBidiWarningLabel: string;
46
+ codeBidiWarningTooltipEnabled: boolean;
36
47
  }) => (node: Node, view: EditorView, getPos: getPosHandler) => CodeBlockView;
37
48
  export {};
@@ -1,6 +1,8 @@
1
1
  import { Plugin } from 'prosemirror-state';
2
+ import type { EditorProps } from '../../../types';
2
3
  import { EditorReactContext } from '../../../types/editor-react-context';
3
- export declare const createPlugin: ({ useLongPressSelection, reactContext, }: {
4
+ export declare const createPlugin: ({ useLongPressSelection, reactContext, appearance, }: {
4
5
  useLongPressSelection?: boolean | undefined;
5
6
  reactContext: () => EditorReactContext;
7
+ appearance: EditorProps['appearance'];
6
8
  }) => Plugin<any, any>;
@@ -1,4 +1,6 @@
1
+ import type { EditorAppearance } from '../../types';
1
2
  import { LongPressSelectionPluginOptions } from '../selection/types';
2
3
  export interface CodeBlockOptions extends LongPressSelectionPluginOptions {
3
4
  allowCopyToClipboard?: boolean;
5
+ appearance: EditorAppearance | undefined;
4
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "151.1.2",
3
+ "version": "151.2.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,7 +38,7 @@
38
38
  "@atlaskit/button": "^16.1.0",
39
39
  "@atlaskit/calendar": "^12.1.0",
40
40
  "@atlaskit/checkbox": "^12.3.0",
41
- "@atlaskit/code": "^14.2.0",
41
+ "@atlaskit/code": "^14.3.0",
42
42
  "@atlaskit/date": "^0.8.0",
43
43
  "@atlaskit/datetime-picker": "^11.1.0",
44
44
  "@atlaskit/droplist": "^11.0.0",
@@ -137,7 +137,7 @@
137
137
  "devDependencies": {
138
138
  "@atlaskit/atlassian-navigation": "^1.2.0",
139
139
  "@atlaskit/breadcrumbs": "11.4.0",
140
- "@atlaskit/code": "^14.2.0",
140
+ "@atlaskit/code": "^14.3.0",
141
141
  "@atlaskit/collab-provider": "7.1.0",
142
142
  "@atlaskit/docs": "*",
143
143
  "@atlaskit/drawer": "^7.0.0",
@@ -155,7 +155,7 @@
155
155
  "@atlaskit/page-layout": "^1.0.1",
156
156
  "@atlaskit/profilecard": "^15.8.0",
157
157
  "@atlaskit/pubsub": "^6.0.0",
158
- "@atlaskit/renderer": "^82.1.0",
158
+ "@atlaskit/renderer": "^82.2.0",
159
159
  "@atlaskit/section-message": "^6.1.0",
160
160
  "@atlaskit/share": "*",
161
161
  "@atlaskit/smart-card": "^16.2.0",