@atlaskit/editor-core 151.0.0 → 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 (70) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/create-editor/create-plugins-list.js +8 -1
  3. package/dist/cjs/labs/next/presets/default.js +3 -1
  4. package/dist/cjs/plugins/code-bidi-warning/index.js +28 -0
  5. package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +11 -0
  6. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +52 -0
  7. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +128 -0
  8. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +12 -0
  9. package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +5 -0
  10. package/dist/cjs/plugins/code-block/index.js +12 -8
  11. package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +19 -5
  12. package/dist/cjs/plugins/code-block/pm-plugins/main.js +21 -4
  13. package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
  14. package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
  15. package/dist/cjs/plugins/index.js +8 -0
  16. package/dist/cjs/plugins/rank.js +1 -1
  17. package/dist/cjs/plugins/status/styles.js +1 -1
  18. package/dist/cjs/version-wrapper.js +1 -1
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/create-editor/create-plugins-list.js +9 -2
  21. package/dist/es2019/labs/next/presets/default.js +3 -1
  22. package/dist/es2019/plugins/code-bidi-warning/index.js +21 -0
  23. package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +2 -0
  24. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +41 -0
  25. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +99 -0
  26. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
  27. package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
  28. package/dist/es2019/plugins/code-block/index.js +8 -2
  29. package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +19 -4
  30. package/dist/es2019/plugins/code-block/pm-plugins/main.js +58 -39
  31. package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
  32. package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
  33. package/dist/es2019/plugins/index.js +2 -1
  34. package/dist/es2019/plugins/rank.js +1 -1
  35. package/dist/es2019/plugins/status/styles.js +3 -0
  36. package/dist/es2019/version-wrapper.js +1 -1
  37. package/dist/es2019/version.json +1 -1
  38. package/dist/esm/create-editor/create-plugins-list.js +9 -2
  39. package/dist/esm/labs/next/presets/default.js +3 -1
  40. package/dist/esm/plugins/code-bidi-warning/index.js +20 -0
  41. package/dist/esm/plugins/code-bidi-warning/plugin-key.js +2 -0
  42. package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +39 -0
  43. package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +106 -0
  44. package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
  45. package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
  46. package/dist/esm/plugins/code-block/index.js +12 -8
  47. package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +19 -5
  48. package/dist/esm/plugins/code-block/pm-plugins/main.js +20 -4
  49. package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +3 -2
  50. package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
  51. package/dist/esm/plugins/index.js +2 -1
  52. package/dist/esm/plugins/rank.js +1 -1
  53. package/dist/esm/plugins/status/styles.js +1 -1
  54. package/dist/esm/version-wrapper.js +1 -1
  55. package/dist/esm/version.json +1 -1
  56. package/dist/types/plugins/code-bidi-warning/index.d.ts +5 -0
  57. package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
  58. package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +5 -0
  59. package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +8 -0
  60. package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
  61. package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +6 -0
  62. package/dist/types/plugins/code-block/index.d.ts +1 -1
  63. package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +22 -2
  64. package/dist/types/plugins/code-block/pm-plugins/main.d.ts +7 -1
  65. package/dist/types/plugins/code-block/types.d.ts +2 -0
  66. package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
  67. package/dist/types/plugins/hyperlink/HyperlinkToolbarAppearance.d.ts +1 -1
  68. package/dist/types/plugins/index.d.ts +1 -0
  69. package/dist/types/types/feature-flags.d.ts +9 -0
  70. package/package.json +6 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
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
+
13
+ ## 151.1.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [`52f0c296810`](https://bitbucket.org/atlassian/atlassian-frontend/commits/52f0c296810) - ED-13940 fixed selecting line with a status via keys
18
+
19
+ ## 151.1.1
20
+
21
+ ### Patch Changes
22
+
23
+ - [`05527b1acf8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/05527b1acf8) - 'Renaming deprecated React lifecycle methods.'
24
+
25
+ ## 151.1.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [`c80c71b537d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c80c71b537d) - [ux] ED-13860 add bidi warning decorations to code components
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies
34
+
3
35
  ## 151.0.0
4
36
 
5
37
  ### Major 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
  }
@@ -413,6 +414,12 @@ function createPluginsList(props, prevProps, createAnalyticsEvent) {
413
414
  preset.add([_plugins.viewUpdateSubscriptionPlugin]);
414
415
  }
415
416
 
417
+ if (featureFlags.codeBidiWarnings) {
418
+ preset.add([_plugins.codeBidiWarningPlugin, {
419
+ appearance: props.appearance
420
+ }]);
421
+ }
422
+
416
423
  var excludes = new Set();
417
424
 
418
425
  if (!isCodeBlockAllowed({
@@ -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
 
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _main = require("./pm-plugins/main");
9
+
10
+ var codeBidiWarning = function codeBidiWarning(_ref) {
11
+ var appearance = _ref.appearance;
12
+ return {
13
+ name: 'codeBidiWarning',
14
+ pmPlugins: function pmPlugins() {
15
+ return [{
16
+ name: 'codeBidiWarning',
17
+ plugin: function plugin(options) {
18
+ return (0, _main.createPlugin)(options, {
19
+ appearance: appearance
20
+ });
21
+ }
22
+ }];
23
+ }
24
+ };
25
+ };
26
+
27
+ var _default = codeBidiWarning;
28
+ exports.default = _default;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.codeBidiWarningPluginKey = void 0;
7
+
8
+ var _prosemirrorState = require("prosemirror-state");
9
+
10
+ var codeBidiWarningPluginKey = new _prosemirrorState.PluginKey('codeBidiWarningPlugin');
11
+ exports.codeBidiWarningPluginKey = codeBidiWarningPluginKey;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createPlugin = void 0;
7
+
8
+ var _prosemirrorState = require("prosemirror-state");
9
+
10
+ var _messages = require("@atlaskit/editor-common/messages");
11
+
12
+ var _pluginKey = require("../plugin-key");
13
+
14
+ var _pluginFactory = require("./plugin-factory");
15
+
16
+ var createPlugin = function createPlugin(_ref, _ref2) {
17
+ var dispatch = _ref.dispatch,
18
+ reactContext = _ref.reactContext;
19
+ var appearance = _ref2.appearance;
20
+ var intl = reactContext().intl;
21
+ var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label);
22
+ return new _prosemirrorState.Plugin({
23
+ key: _pluginKey.codeBidiWarningPluginKey,
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';
31
+ return {
32
+ decorationSet: (0, _pluginFactory.createBidiWarningsDecorationSetFromDoc)({
33
+ doc: state.doc,
34
+ codeBidiWarningLabel: codeBidiWarningLabel,
35
+ tooltipEnabled: tooltipEnabled
36
+ }),
37
+ codeBidiWarningLabel: codeBidiWarningLabel,
38
+ tooltipEnabled: tooltipEnabled
39
+ };
40
+ }),
41
+ props: {
42
+ decorations: function decorations(state) {
43
+ var _getPluginState = (0, _pluginFactory.getPluginState)(state),
44
+ decorationSet = _getPluginState.decorationSet;
45
+
46
+ return decorationSet;
47
+ }
48
+ }
49
+ });
50
+ };
51
+
52
+ exports.createPlugin = createPlugin;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.createBidiWarningsDecorationSetFromDoc = createBidiWarningsDecorationSetFromDoc;
9
+ exports.getPluginState = exports.createPluginState = void 0;
10
+
11
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+
13
+ var _react = _interopRequireDefault(require("react"));
14
+
15
+ var _reactDom = _interopRequireDefault(require("react-dom"));
16
+
17
+ var _prosemirrorView = require("prosemirror-view");
18
+
19
+ var _bidiWarning = _interopRequireDefault(require("@atlaskit/code/bidi-warning"));
20
+
21
+ var _bidiWarningDecorator = _interopRequireDefault(require("@atlaskit/code/bidi-warning-decorator"));
22
+
23
+ var _pluginStateFactory = require("../../../utils/plugin-state-factory");
24
+
25
+ var _step = require("../../../utils/step");
26
+
27
+ var _pluginKey = require("../plugin-key");
28
+
29
+ var _reducer = _interopRequireDefault(require("./reducer"));
30
+
31
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
32
+
33
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
34
+
35
+ var _pluginFactory = (0, _pluginStateFactory.pluginFactory)(_pluginKey.codeBidiWarningPluginKey, _reducer.default, {
36
+ onDocChanged: function onDocChanged(tr, pluginState) {
37
+ if (!tr.steps.find(_step.stepHasSlice)) {
38
+ return pluginState;
39
+ }
40
+
41
+ var newBidiWarningsDecorationSet = createBidiWarningsDecorationSetFromDoc({
42
+ doc: tr.doc,
43
+ codeBidiWarningLabel: pluginState.codeBidiWarningLabel,
44
+ tooltipEnabled: pluginState.tooltipEnabled
45
+ });
46
+ return _objectSpread(_objectSpread({}, pluginState), {}, {
47
+ decorationSet: newBidiWarningsDecorationSet
48
+ });
49
+ }
50
+ }),
51
+ createPluginState = _pluginFactory.createPluginState,
52
+ getPluginState = _pluginFactory.getPluginState;
53
+
54
+ exports.getPluginState = getPluginState;
55
+ exports.createPluginState = createPluginState;
56
+
57
+ function createBidiWarningsDecorationSetFromDoc(_ref) {
58
+ var doc = _ref.doc,
59
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
60
+ tooltipEnabled = _ref.tooltipEnabled;
61
+ var bidiCharactersAndTheirPositions = [];
62
+ doc.descendants(function (node, pos) {
63
+ var isTextWithCodeMark = node.type.name === 'text' && node.marks && node.marks.some(function (mark) {
64
+ return mark.type.name === 'code';
65
+ });
66
+
67
+ if (isTextWithCodeMark) {
68
+ (0, _bidiWarningDecorator.default)(node.textContent, function (_ref2) {
69
+ var bidiCharacter = _ref2.bidiCharacter,
70
+ index = _ref2.index;
71
+ bidiCharactersAndTheirPositions.push({
72
+ position: pos + index,
73
+ bidiCharacter: bidiCharacter
74
+ });
75
+ });
76
+ return false;
77
+ }
78
+
79
+ var isCodeBlock = node.type.name === 'codeBlock';
80
+
81
+ if (isCodeBlock) {
82
+ (0, _bidiWarningDecorator.default)(node.textContent, function (_ref3) {
83
+ var bidiCharacter = _ref3.bidiCharacter,
84
+ index = _ref3.index;
85
+ bidiCharactersAndTheirPositions.push({
86
+ position: pos + index + 1,
87
+ bidiCharacter: bidiCharacter
88
+ });
89
+ });
90
+ }
91
+ }); // Bidi characters are not expected to commonly appear in code snippets, so recreating the decoration set
92
+ // for documents rather than reusing existing decorations seems a reasonable performance/complexity tradeoff.
93
+
94
+ if (bidiCharactersAndTheirPositions.length === 0) {
95
+ return _prosemirrorView.DecorationSet.empty;
96
+ }
97
+
98
+ var newBidiWarningsDecorationSet = _prosemirrorView.DecorationSet.create(doc, bidiCharactersAndTheirPositions.map(function (_ref4) {
99
+ var position = _ref4.position,
100
+ bidiCharacter = _ref4.bidiCharacter;
101
+ return _prosemirrorView.Decoration.widget(position, function () {
102
+ return renderDOM({
103
+ bidiCharacter: bidiCharacter,
104
+ codeBidiWarningLabel: codeBidiWarningLabel,
105
+ tooltipEnabled: tooltipEnabled
106
+ });
107
+ });
108
+ }));
109
+
110
+ return newBidiWarningsDecorationSet;
111
+ }
112
+
113
+ function renderDOM(_ref5) {
114
+ var bidiCharacter = _ref5.bidiCharacter,
115
+ codeBidiWarningLabel = _ref5.codeBidiWarningLabel,
116
+ tooltipEnabled = _ref5.tooltipEnabled;
117
+ var element = document.createElement('span'); // Note: we use this pattern elsewhere (see highlighting code block, and drop cursor widget decoration)
118
+ // we should investigate if there is a memory leak with such usage.
119
+
120
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
121
+ bidiCharacter: bidiCharacter,
122
+ skipChildren: true,
123
+ label: codeBidiWarningLabel,
124
+ tooltipEnabled: tooltipEnabled
125
+ }), element);
126
+
127
+ return element;
128
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _default = function _default(pluginState, action) {
9
+ return pluginState;
10
+ };
11
+
12
+ exports.default = _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -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() {
@@ -40,8 +39,13 @@ var codeBlockPlugin = function codeBlockPlugin() {
40
39
  pmPlugins: function pmPlugins() {
41
40
  return [{
42
41
  name: 'codeBlock',
43
- plugin: function plugin() {
44
- return (0, _main.createPlugin)(options.useLongPressSelection);
42
+ plugin: function plugin(_ref) {
43
+ var reactContext = _ref.reactContext;
44
+ return (0, _main.createPlugin)({
45
+ useLongPressSelection: options.useLongPressSelection,
46
+ reactContext: reactContext,
47
+ appearance: options.appearance
48
+ });
45
49
  }
46
50
  }, {
47
51
  name: 'codeBlockIDEKeyBindings',
@@ -50,8 +54,8 @@ var codeBlockPlugin = function codeBlockPlugin() {
50
54
  }
51
55
  }, {
52
56
  name: 'codeBlockKeyMap',
53
- plugin: function plugin(_ref) {
54
- var schema = _ref.schema;
57
+ plugin: function plugin(_ref2) {
58
+ var schema = _ref2.schema;
55
59
  return (0, _keymaps.default)(schema);
56
60
  }
57
61
  }];
@@ -62,8 +66,8 @@ var codeBlockPlugin = function codeBlockPlugin() {
62
66
  (0, _refreshBrowserSelection.default)(props.originalTransaction, props.newEditorState);
63
67
  },
64
68
  pluginsOptions: {
65
- quickInsert: function quickInsert(_ref2) {
66
- var formatMessage = _ref2.formatMessage;
69
+ quickInsert: function quickInsert(_ref3) {
70
+ var formatMessage = _ref3.formatMessage;
67
71
  return [{
68
72
  id: 'codeblock',
69
73
  title: formatMessage(_messages.messages.codeblock),
@@ -50,7 +50,7 @@ var toDOM = function toDOM(node) {
50
50
  };
51
51
 
52
52
  var CodeBlockView = /*#__PURE__*/function () {
53
- function CodeBlockView(_node, view, getPos) {
53
+ function CodeBlockView(_node, view, getPos, codeBidiWarningOptions) {
54
54
  var _this = this;
55
55
 
56
56
  (0, _classCallCheck2.default)(this, CodeBlockView);
@@ -77,6 +77,7 @@ var CodeBlockView = /*#__PURE__*/function () {
77
77
  dom = _DOMSerializer$render.dom,
78
78
  contentDOM = _DOMSerializer$render.contentDOM;
79
79
 
80
+ this.codeBidiWarningOptions = codeBidiWarningOptions;
80
81
  this.getPos = getPos;
81
82
  this.view = view;
82
83
  this.node = _node;
@@ -130,7 +131,10 @@ var CodeBlockView = /*#__PURE__*/function () {
130
131
  _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_code.CodeBlock, {
131
132
  text: node.textContent,
132
133
  language: node.attrs.language,
133
- showLineNumbers: false
134
+ showLineNumbers: false,
135
+ codeBidiWarnings: this.codeBidiWarningOptions.enabled,
136
+ codeBidiWarningLabel: this.codeBidiWarningOptions.label,
137
+ codeBidiWarningTooltipEnabled: this.codeBidiWarningOptions.tooltipEnabled
134
138
  }), highlighting);
135
139
 
136
140
  this.measure(performance.now() - start);
@@ -164,7 +168,10 @@ var CodeBlockView = /*#__PURE__*/function () {
164
168
  value: function ignoreMutation(record) {
165
169
  var _this$highlighting$co, _this$highlighting;
166
170
 
167
- return record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter || ((_this$highlighting$co = (_this$highlighting = this.highlighting) === null || _this$highlighting === void 0 ? void 0 : _this$highlighting.contains(record.target)) !== null && _this$highlighting$co !== void 0 ? _this$highlighting$co : false);
171
+ var lineNumberChanges = record.target === this.lineNumberGutter || record.target.parentNode === this.lineNumberGutter;
172
+ var outsideTheCodeBlockChanges = (_this$highlighting$co = (_this$highlighting = this.highlighting) === null || _this$highlighting === void 0 ? void 0 : _this$highlighting.contains(record.target)) !== null && _this$highlighting$co !== void 0 ? _this$highlighting$co : false;
173
+ var codeBidiWarningDecorationChanges = record.type === 'attributes' && record.attributeName === 'aria-describedby';
174
+ return lineNumberChanges || outsideTheCodeBlockChanges || codeBidiWarningDecorationChanges;
168
175
  }
169
176
  }]);
170
177
  return CodeBlockView;
@@ -172,9 +179,16 @@ var CodeBlockView = /*#__PURE__*/function () {
172
179
 
173
180
  exports.CodeBlockView = CodeBlockView;
174
181
 
175
- var highlightingCodeBlockNodeView = function highlightingCodeBlockNodeView() {
182
+ var highlightingCodeBlockNodeView = function highlightingCodeBlockNodeView(_ref) {
183
+ var codeBidiWarnings = _ref.codeBidiWarnings,
184
+ codeBidiWarningLabel = _ref.codeBidiWarningLabel,
185
+ codeBidiWarningTooltipEnabled = _ref.codeBidiWarningTooltipEnabled;
176
186
  return function (node, view, getPos) {
177
- return new CodeBlockView(node, view, getPos);
187
+ return new CodeBlockView(node, view, getPos, {
188
+ label: codeBidiWarningLabel,
189
+ enabled: codeBidiWarnings,
190
+ tooltipEnabled: codeBidiWarningTooltipEnabled
191
+ });
178
192
  };
179
193
  };
180
194
 
@@ -11,6 +11,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
 
12
12
  var _prosemirrorState = require("prosemirror-state");
13
13
 
14
+ var _messages = require("@atlaskit/editor-common/messages");
15
+
14
16
  var _codeBlock = require("../nodeviews/code-block");
15
17
 
16
18
  var _highlightingCodeBlock = require("../nodeviews/highlighting-code-block");
@@ -31,8 +33,13 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
31
33
 
32
34
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
33
35
 
34
- var createPlugin = function createPlugin() {
35
- var useLongPressSelection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
36
+ var createPlugin = function createPlugin(_ref) {
37
+ var _ref$useLongPressSele = _ref.useLongPressSelection,
38
+ useLongPressSelection = _ref$useLongPressSele === void 0 ? false : _ref$useLongPressSele,
39
+ reactContext = _ref.reactContext,
40
+ appearance = _ref.appearance;
41
+ var intl = reactContext().intl;
42
+ var codeBidiWarningLabel = intl.formatMessage(_messages.codeBidiWarningMessages.label);
36
43
  return new _prosemirrorState.Plugin({
37
44
  state: {
38
45
  init: function init(_, state) {
@@ -70,8 +77,18 @@ var createPlugin = function createPlugin() {
70
77
  props: {
71
78
  nodeViews: {
72
79
  codeBlock: function codeBlock(node, view, getPos) {
73
- var featureFlags = (0, _featureFlagsContext.getFeatureFlags)(view.state);
74
- var createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? (0, _highlightingCodeBlock.highlightingCodeBlockNodeView)() : (0, _codeBlock.codeBlockNodeView)();
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';
87
+ var createCodeBlockNodeView = featureFlags !== null && featureFlags !== void 0 && featureFlags.codeBlockSyntaxHighlighting ? (0, _highlightingCodeBlock.highlightingCodeBlockNodeView)({
88
+ codeBidiWarnings: featureFlags === null || featureFlags === void 0 ? void 0 : featureFlags.codeBidiWarnings,
89
+ codeBidiWarningLabel: codeBidiWarningLabel,
90
+ codeBidiWarningTooltipEnabled: codeBidiWarningTooltipEnabled
91
+ }) : (0, _codeBlock.codeBlockNodeView)();
75
92
  return createCodeBlockNodeView(node, view, getPos);
76
93
  }
77
94
  },
@@ -24,7 +24,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
24
24
  * which is used by both current and archv3 editors.
25
25
  */
26
26
  function createFeatureFlagsFromProps(props) {
27
- var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27;
27
+ var _props$allowTextColor, _props$performanceTra, _props$performanceTra2, _props$featureFlags, _props$featureFlags2, _props$featureFlags3, _props$allowTables, _props$featureFlags4, _props$featureFlags5, _props$allowTables2, _props$featureFlags6, _props$featureFlags7, _props$allowTables3, _props$featureFlags8, _props$featureFlags9, _props$allowTables4, _props$featureFlags10, _props$featureFlags11, _props$allowTables5, _props$allowExtension, _props$featureFlags12, _props$featureFlags13, _props$featureFlags14, _props$featureFlags15, _props$featureFlags16, _props$featureFlags17, _props$featureFlags18, _props$featureFlags19, _props$featureFlags20, _props$featureFlags21, _props$featureFlags22, _props$featureFlags23, _props$featureFlags24, _props$featureFlags25, _props$featureFlags26, _props$featureFlags27, _props$featureFlags28, _props$featureFlags29;
28
28
 
29
29
  var normalizedFeatureFlags = (0, _normalizeFeatureFlags.normalizeFeatureFlags)(props.featureFlags);
30
30
  return _objectSpread(_objectSpread({}, normalizedFeatureFlags), {}, {
@@ -54,6 +54,7 @@ function createFeatureFlagsFromProps(props) {
54
54
  enableViewUpdateSubscription: Boolean(typeof ((_props$featureFlags22 = props.featureFlags) === null || _props$featureFlags22 === void 0 ? void 0 : _props$featureFlags22.enableViewUpdateSubscription) === 'boolean' ? !!((_props$featureFlags23 = props.featureFlags) !== null && _props$featureFlags23 !== void 0 && _props$featureFlags23.enableViewUpdateSubscription) : false),
55
55
  collabAvatarScroll: Boolean(typeof ((_props$featureFlags24 = props.featureFlags) === null || _props$featureFlags24 === void 0 ? void 0 : _props$featureFlags24.collabAvatarScroll) === 'boolean' ? !!((_props$featureFlags25 = props.featureFlags) !== null && _props$featureFlags25 !== void 0 && _props$featureFlags25.collabAvatarScroll) : false),
56
56
  ufo: Boolean(typeof ((_props$featureFlags26 = props.featureFlags) === null || _props$featureFlags26 === void 0 ? void 0 : _props$featureFlags26.ufo) === 'boolean' ? !!((_props$featureFlags27 = props.featureFlags) !== null && _props$featureFlags27 !== void 0 && _props$featureFlags27.ufo) : false),
57
- codeBlockSyntaxHighlighting: Boolean(typeof normalizedFeatureFlags.codeBlockSyntaxHighlighting === 'boolean' ? !!normalizedFeatureFlags.codeBlockSyntaxHighlighting && !_editorCommon.browser.safari : false)
57
+ codeBlockSyntaxHighlighting: Boolean(typeof normalizedFeatureFlags.codeBlockSyntaxHighlighting === 'boolean' ? !!normalizedFeatureFlags.codeBlockSyntaxHighlighting && !_editorCommon.browser.safari : false),
58
+ codeBidiWarnings: Boolean(typeof ((_props$featureFlags28 = props.featureFlags) === null || _props$featureFlags28 === void 0 ? void 0 : _props$featureFlags28.codeBidiWarnings) === 'boolean' ? !!((_props$featureFlags29 = props.featureFlags) !== null && _props$featureFlags29 !== void 0 && _props$featureFlags29.codeBidiWarnings) : true)
58
59
  });
59
60
  }
@@ -177,10 +177,10 @@ var HyperlinkToolbarAppearance = /*#__PURE__*/function (_Component) {
177
177
  }
178
178
 
179
179
  (0, _createClass2.default)(HyperlinkToolbarAppearance, [{
180
- key: "componentWillReceiveProps",
180
+ key: "UNSAFE_componentWillReceiveProps",
181
181
  value: // needed so we display the right state on the Toolbar while the same Toolbar
182
182
  // instance is visible and we click other link
183
- function componentWillReceiveProps(nextProps) {
183
+ function UNSAFE_componentWillReceiveProps(nextProps) {
184
184
  if (nextProps.url !== this.props.url) {
185
185
  this.resolveUrl(nextProps.url);
186
186
  }
@@ -391,6 +391,12 @@ Object.defineProperty(exports, "viewUpdateSubscriptionPlugin", {
391
391
  return _viewUpdateSubscription.default;
392
392
  }
393
393
  });
394
+ Object.defineProperty(exports, "codeBidiWarningPlugin", {
395
+ enumerable: true,
396
+ get: function get() {
397
+ return _codeBidiWarning.default;
398
+ }
399
+ });
394
400
 
395
401
  var _base = _interopRequireDefault(require("./base"));
396
402
 
@@ -516,6 +522,8 @@ var _avatarGroup = _interopRequireDefault(require("./avatar-group"));
516
522
 
517
523
  var _viewUpdateSubscription = _interopRequireDefault(require("./view-update-subscription"));
518
524
 
525
+ var _codeBidiWarning = _interopRequireDefault(require("./code-bidi-warning"));
526
+
519
527
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
520
528
 
521
529
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -12,7 +12,7 @@ var _default = {
12
12
  // https://product-fabric.atlassian.net/wiki/spaces/E/pages/1113098008/Selection+Guide#Special-Cases
13
13
  'expandKeymap', 'tableSelectionKeymap', 'tableKeymap', 'captionKeymap', // selection keymap needs to be above gap cursor keymap so it can set node selections from
14
14
  // left/right arrows
15
- 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaKeymap', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription'],
15
+ 'selectionKeymap', 'gapCursorKeymap', 'gapCursor', 'syncUrlText', 'fakeCursorToolbarPlugin', 'hyperLink', 'table', 'tableDecorations', 'hyperlinkInputRule', 'tablePMColResizing', 'hyperlinkKeymap', 'tableColResizing', 'undoRedoKeyMap', 'blockTypeKeyMap', 'tableEditing', 'filterStepsPlugin', 'pmCollab', 'collab', 'ruleInputRule', 'ruleKeymap', 'panel', 'media', 'mediaKeymap', 'mediaSingleKeymap', 'mediaEditor', 'unsupportedContent', 'jiraIssue', 'fakeTextCursor', 'helpDialog', 'helpDialogKeymap', 'macro', 'expand', 'extension', 'layout', 'contextPanel', 'floatingToolbar', 'clearMarksOnChange', 'reactNodeView', 'history', 'undoRedoPlugin', 'codeBlockIndent', 'placeholder', 'width', 'maxContentSize', 'multilineContent', 'grid', 'mobileDimensions', 'scrollGutterPlugin', 'analytics', 'findReplace', 'selection', 'avatarGroup', 'viewUpdateSubscription', 'inlineCode'],
16
16
  nodes: ['doc', 'paragraph', 'text', 'bulletList', 'orderedList', 'listItem', 'heading', 'blockquote', 'codeBlock', 'rule', 'panel', 'mention', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'unsupportedBlock', 'unsupportedInline', 'confluenceJiraIssue', 'hardBreak', 'emoji', 'placeholder', 'mediaSingle', 'mediaGroup', 'table', 'expand', 'nestedExpand', 'media', 'tableHeader', 'decisionList', 'tableRow', 'decisionItem', 'tableCell', 'taskList', 'taskItem', 'extension', 'bodiedExtension', 'inlineExtension', 'layoutSection', 'layoutColumn', 'inlineCard', 'blockCard', 'embedCard'],
17
17
  marks: [// Inline marks
18
18
  'link', 'em', 'strong', 'textColor', 'strike', 'subsup', 'underline', 'code', 'typeAheadQuery', // Block marks
@@ -17,5 +17,5 @@ var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
17
17
 
18
18
  var _templateObject;
19
19
 
20
- var statusStyles = (0, _styledComponents.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n display: inline-block;\n\n > span {\n display: inline-block;\n cursor: pointer;\n line-height: 0; /* Prevent responsive layouts increasing height of container. */\n }\n\n &.", "\n .", "\n > span {\n ", "\n }\n }\n\n .danger {\n .", " > span {\n background-color: ", ";\n }\n\n .", ".", "\n .", "\n > span {\n box-shadow: 0 0 0 ", "px ", ";\n }\n }\n"])), _editorCommon.StatusSharedCssClassName.STATUS_CONTAINER, _editorSharedStyles.akEditorSelectedNodeClassName, _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, _editorSharedStyles.akEditorDeleteBackgroundWithOpacity, _editorCommon.StatusSharedCssClassName.STATUS_CONTAINER, _editorSharedStyles.akEditorSelectedNodeClassName, _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, _editorSharedStyles.akEditorSelectedBorderSize, _editorSharedStyles.akEditorDeleteBorder);
20
+ var statusStyles = (0, _styledComponents.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n .", " {\n // these two styles can be removed when displayInlineBlockForInlineNodes is enabled by default\n // as it will make all inline nodes inline-block by default\n display: inline-block;\n user-select: all;\n\n > span {\n display: inline-block;\n cursor: pointer;\n line-height: 0; /* Prevent responsive layouts increasing height of container. */\n }\n\n &.", "\n .", "\n > span {\n ", "\n }\n }\n\n .danger {\n .", " > span {\n background-color: ", ";\n }\n\n .", ".", "\n .", "\n > span {\n box-shadow: 0 0 0 ", "px ", ";\n }\n }\n"])), _editorCommon.StatusSharedCssClassName.STATUS_CONTAINER, _editorSharedStyles.akEditorSelectedNodeClassName, _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, (0, _editorSharedStyles.getSelectionStyles)([_editorSharedStyles.SelectionStyle.BoxShadow]), _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, _editorSharedStyles.akEditorDeleteBackgroundWithOpacity, _editorCommon.StatusSharedCssClassName.STATUS_CONTAINER, _editorSharedStyles.akEditorSelectedNodeClassName, _editorCommon.StatusSharedCssClassName.STATUS_LOZENGE, _editorSharedStyles.akEditorSelectedBorderSize, _editorSharedStyles.akEditorDeleteBorder);
21
21
  exports.statusStyles = statusStyles;
@@ -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.0.0";
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.0.0",
3
+ "version": "151.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, helpDialogPlugin, imageUploadPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tablesPlugin, tasksAndDecisionsPlugin, textColorPlugin, cardPlugin, gridPlugin, statusPlugin, alignmentPlugin, indentationPlugin, analyticsPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, contextPanelPlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin } from '../plugins';
1
+ import { breakoutPlugin, collabEditPlugin, dataConsumerMarkPlugin, datePlugin, emojiPlugin, extensionPlugin, helpDialogPlugin, imageUploadPlugin, insertBlockPlugin, jiraIssuePlugin, layoutPlugin, listPlugin, macroPlugin, maxContentSizePlugin, mediaPlugin, mentionsPlugin, panelPlugin, placeholderTextPlugin, rulePlugin, saveOnEnterPlugin, tablesPlugin, tasksAndDecisionsPlugin, textColorPlugin, cardPlugin, gridPlugin, statusPlugin, alignmentPlugin, indentationPlugin, analyticsPlugin, customAutoformatPlugin, feedbackDialogPlugin, historyPlugin, expandPlugin, isExpandInsertionEnabled, scrollIntoViewPlugin, mobileDimensionsPlugin, findReplacePlugin, contextPanelPlugin, mobileSelectionPlugin, annotationPlugin, captionPlugin, avatarGroupPlugin, viewUpdateSubscriptionPlugin, codeBidiWarningPlugin } from '../plugins';
2
2
  import { isFullPage as fullPageCheck } from '../utils/is-full-page';
3
3
  import { GUTTER_SIZE_MOBILE_IN_PX } from '../plugins/base/pm-plugins/scroll-gutter';
4
4
  import { createFeatureFlagsFromProps } from '../plugins/feature-flags-context/feature-flags-from-props';
@@ -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
  }
@@ -389,6 +390,12 @@ export default function createPluginsList(props, prevProps, createAnalyticsEvent
389
390
  preset.add([viewUpdateSubscriptionPlugin]);
390
391
  }
391
392
 
393
+ if (featureFlags.codeBidiWarnings) {
394
+ preset.add([codeBidiWarningPlugin, {
395
+ appearance: props.appearance
396
+ }]);
397
+ }
398
+
392
399
  const excludes = new Set();
393
400
 
394
401
  if (!isCodeBlockAllowed({
@@ -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) {
@@ -0,0 +1,21 @@
1
+ import { createPlugin } from './pm-plugins/main';
2
+
3
+ const codeBidiWarning = ({
4
+ appearance
5
+ }) => ({
6
+ name: 'codeBidiWarning',
7
+
8
+ pmPlugins() {
9
+ return [{
10
+ name: 'codeBidiWarning',
11
+ plugin: options => {
12
+ return createPlugin(options, {
13
+ appearance
14
+ });
15
+ }
16
+ }];
17
+ }
18
+
19
+ });
20
+
21
+ export default codeBidiWarning;
@@ -0,0 +1,2 @@
1
+ import { PluginKey } from 'prosemirror-state';
2
+ export const codeBidiWarningPluginKey = new PluginKey('codeBidiWarningPlugin');