@atlaskit/editor-core 187.10.3 → 187.10.6

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,17 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.10.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [`eeecb78b23f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eeecb78b23f) - Added media-single utils to editor-common and moved utils from editor-core/media to edtor-common/media-single.
8
+
9
+ ## 187.10.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [`14fb6018157`](https://bitbucket.org/atlassian/atlassian-frontend/commits/14fb6018157) - [ED-19354] Small fixes to respect the next ProseMirror version
14
+
3
15
  ## 187.10.3
4
16
 
5
17
  ### Patch Changes
@@ -66,7 +66,7 @@ function createPlugin(options, featureFlags, pluginInjectionApi) {
66
66
  measureName, function (_ref) {
67
67
  var duration = _ref.duration,
68
68
  distortedDuration = _ref.distortedDuration;
69
- (0, _analytics.fireAnalyticsEvent)(pluginState.createAnalyticsEvent)({
69
+ (0, _analytics.fireAnalyticsEvent)(pluginState.createAnalyticsEvent || undefined)({
70
70
  payload: extendPayload({
71
71
  payload: payload,
72
72
  duration: duration,
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.calcOffsetLeft = calcOffsetLeft;
8
7
  exports.default = void 0;
9
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
@@ -23,6 +22,7 @@ var _mediaClient = require("@atlaskit/media-client");
23
22
  var _ui = require("@atlaskit/editor-common/ui");
24
23
  var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
25
24
  var _styled = require("./styled");
25
+ var _mediaSingle = require("@atlaskit/editor-common/media-single");
26
26
  var _utils2 = require("@atlaskit/editor-common/utils");
27
27
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
28
28
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } /** @jsx jsx */
@@ -37,7 +37,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
37
37
  }
38
38
  _this = _super.call.apply(_super, [this].concat(args));
39
39
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
40
- offsetLeft: calcOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
40
+ offsetLeft: (0, _mediaSingle.calculateOffsetLeft)(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
41
41
  // We default to true until we resolve the file type
42
42
  isVideoFile: true
43
43
  });
@@ -157,7 +157,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
157
157
  (0, _createClass2.default)(ResizableMediaSingle, [{
158
158
  key: "componentDidUpdate",
159
159
  value: function componentDidUpdate(prevProps) {
160
- var offsetLeft = calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
160
+ var offsetLeft = (0, _mediaSingle.calculateOffsetLeft)(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
161
161
  if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
162
162
  this.setState({
163
163
  offsetLeft: offsetLeft
@@ -399,13 +399,4 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
399
399
  }]);
400
400
  return ResizableMediaSingle;
401
401
  }(_react.default.Component);
402
- exports.default = ResizableMediaSingle;
403
- function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
404
- var offsetLeft = 0;
405
- if (wrapper && insideInlineLike && !insideLayout) {
406
- var currentNode = wrapper;
407
- var boundingRect = currentNode.getBoundingClientRect();
408
- offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
409
- }
410
- return offsetLeft;
411
- }
402
+ exports.default = ResizableMediaSingle;
@@ -316,13 +316,22 @@ function handlePasteLinkOnSelectedText(slice) {
316
316
  }
317
317
  function handlePasteAsPlainText(slice, _event) {
318
318
  return function (state, dispatch, view) {
319
+ var _input;
320
+ if (!view) {
321
+ return false;
322
+ }
323
+
324
+ // prosemirror-bump-fix
325
+ // Yes, this is wrong by default. But, we need to keep the private PAI usage to unblock the prosemirror bump
326
+ // So, this code will make sure we are checking for both version (current and the newest prosemirror-view version
327
+ var isShiftKeyPressed = view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey);
319
328
  // In case of SHIFT+CMD+V ("Paste and Match Style") we don't want to run the usual
320
329
  // fuzzy matching of content. ProseMirror already handles this scenario and will
321
330
  // provide us with slice containing paragraphs with plain text, which we decorate
322
331
  // with "stored marks".
323
332
  // @see prosemirror-view/src/clipboard.js:parseFromClipboard()).
324
333
  // @see prosemirror-view/src/input.js:doPaste().
325
- if (view && view.shiftKey) {
334
+ if (isShiftKeyPressed) {
326
335
  var tr = (0, _history.closeHistory)(state.tr);
327
336
  var _tr = tr,
328
337
  selection = _tr.selection;
@@ -115,7 +115,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
115
115
  return function (_ref2) {
116
116
  var schema = _ref2.schema,
117
117
  textFormattingPluginState = _ref2.textFormattingPluginState;
118
- var hasPluginState = Boolean(textFormattingPluginState);
118
+ var hasPluginState = Boolean(Object.keys(textFormattingPluginState || {}).length);
119
119
  var markSchema = IconsMarkSchema[iconMark];
120
120
  var hasSchemaMark = Boolean(schema.marks[markSchema]);
121
121
  if (!hasPluginState) {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.10.3";
9
+ var version = "187.10.6";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.10.3",
3
+ "version": "187.10.6",
4
4
  "sideEffects": false
5
5
  }
@@ -52,7 +52,7 @@ function createPlugin(options, featureFlags, pluginInjectionApi) {
52
52
  duration,
53
53
  distortedDuration
54
54
  }) => {
55
- fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
55
+ fireAnalyticsEvent(pluginState.createAnalyticsEvent || undefined)({
56
56
  payload: extendPayload({
57
57
  payload,
58
58
  duration,
@@ -8,12 +8,13 @@ import { getMediaClient } from '@atlaskit/media-client';
8
8
  import { calcPctFromPx, calcColumnsFromPx, wrappedLayouts, Resizer, calcMediaPxWidth, snapTo, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
9
9
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
10
10
  import { wrapperStyle } from './styled';
11
+ import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
11
12
  import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
12
13
  export default class ResizableMediaSingle extends React.Component {
13
14
  constructor(...args) {
14
15
  super(...args);
15
16
  _defineProperty(this, "state", {
16
- offsetLeft: calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, undefined),
17
+ offsetLeft: calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, undefined),
17
18
  // We default to true until we resolve the file type
18
19
  isVideoFile: true
19
20
  });
@@ -140,7 +141,7 @@ export default class ResizableMediaSingle extends React.Component {
140
141
  _defineProperty(this, "saveWrapper", wrapper => this.wrapper = wrapper);
141
142
  }
142
143
  componentDidUpdate(prevProps) {
143
- const offsetLeft = calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
144
+ const offsetLeft = calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
144
145
  if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
145
146
  this.setState({
146
147
  offsetLeft
@@ -323,13 +324,4 @@ export default class ResizableMediaSingle extends React.Component {
323
324
  })
324
325
  }), children));
325
326
  }
326
- }
327
- export function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
328
- let offsetLeft = 0;
329
- if (wrapper && insideInlineLike && !insideLayout) {
330
- const currentNode = wrapper;
331
- const boundingRect = currentNode.getBoundingClientRect();
332
- offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
333
- }
334
- return offsetLeft;
335
327
  }
@@ -309,13 +309,22 @@ export function handlePasteLinkOnSelectedText(slice) {
309
309
  }
310
310
  export function handlePasteAsPlainText(slice, _event) {
311
311
  return (state, dispatch, view) => {
312
+ var _input;
313
+ if (!view) {
314
+ return false;
315
+ }
316
+
317
+ // prosemirror-bump-fix
318
+ // Yes, this is wrong by default. But, we need to keep the private PAI usage to unblock the prosemirror bump
319
+ // So, this code will make sure we are checking for both version (current and the newest prosemirror-view version
320
+ const isShiftKeyPressed = view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey);
312
321
  // In case of SHIFT+CMD+V ("Paste and Match Style") we don't want to run the usual
313
322
  // fuzzy matching of content. ProseMirror already handles this scenario and will
314
323
  // provide us with slice containing paragraphs with plain text, which we decorate
315
324
  // with "stored marks".
316
325
  // @see prosemirror-view/src/clipboard.js:parseFromClipboard()).
317
326
  // @see prosemirror-view/src/input.js:doPaste().
318
- if (view && view.shiftKey) {
327
+ if (isShiftKeyPressed) {
319
328
  let tr = closeHistory(state.tr);
320
329
  const {
321
330
  selection
@@ -106,7 +106,7 @@ const buildMenuIconState = iconMark => ({
106
106
  schema,
107
107
  textFormattingPluginState
108
108
  }) => {
109
- const hasPluginState = Boolean(textFormattingPluginState);
109
+ const hasPluginState = Boolean(Object.keys(textFormattingPluginState || {}).length);
110
110
  const markSchema = IconsMarkSchema[iconMark];
111
111
  const hasSchemaMark = Boolean(schema.marks[markSchema]);
112
112
  if (!hasPluginState) {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.10.3";
2
+ export const version = "187.10.6";
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": "187.10.3",
3
+ "version": "187.10.6",
4
4
  "sideEffects": false
5
5
  }
@@ -58,7 +58,7 @@ function createPlugin(options, featureFlags, pluginInjectionApi) {
58
58
  measureName, function (_ref) {
59
59
  var duration = _ref.duration,
60
60
  distortedDuration = _ref.distortedDuration;
61
- fireAnalyticsEvent(pluginState.createAnalyticsEvent)({
61
+ fireAnalyticsEvent(pluginState.createAnalyticsEvent || undefined)({
62
62
  payload: extendPayload({
63
63
  payload: payload,
64
64
  duration: duration,
@@ -18,6 +18,7 @@ import { getMediaClient } from '@atlaskit/media-client';
18
18
  import { calcPctFromPx, calcColumnsFromPx, wrappedLayouts, Resizer, calcMediaPxWidth, snapTo, handleSides, imageAlignmentMap } from '@atlaskit/editor-common/ui';
19
19
  import { akEditorWideLayoutWidth } from '@atlaskit/editor-shared-styles';
20
20
  import { wrapperStyle } from './styled';
21
+ import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
21
22
  import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
22
23
  var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
23
24
  _inherits(ResizableMediaSingle, _React$Component);
@@ -30,7 +31,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
30
31
  }
31
32
  _this = _super.call.apply(_super, [this].concat(args));
32
33
  _defineProperty(_assertThisInitialized(_this), "state", {
33
- offsetLeft: calcOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
34
+ offsetLeft: calculateOffsetLeft(_this.insideInlineLike, _this.insideLayout, _this.props.view.dom, undefined),
34
35
  // We default to true until we resolve the file type
35
36
  isVideoFile: true
36
37
  });
@@ -150,7 +151,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
150
151
  _createClass(ResizableMediaSingle, [{
151
152
  key: "componentDidUpdate",
152
153
  value: function componentDidUpdate(prevProps) {
153
- var offsetLeft = calcOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
154
+ var offsetLeft = calculateOffsetLeft(this.insideInlineLike, this.insideLayout, this.props.view.dom, this.wrapper);
154
155
  if (offsetLeft !== this.state.offsetLeft && offsetLeft >= 0) {
155
156
  this.setState({
156
157
  offsetLeft: offsetLeft
@@ -392,13 +393,4 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
392
393
  }]);
393
394
  return ResizableMediaSingle;
394
395
  }(React.Component);
395
- export { ResizableMediaSingle as default };
396
- export function calcOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
397
- var offsetLeft = 0;
398
- if (wrapper && insideInlineLike && !insideLayout) {
399
- var currentNode = wrapper;
400
- var boundingRect = currentNode.getBoundingClientRect();
401
- offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
402
- }
403
- return offsetLeft;
404
- }
396
+ export { ResizableMediaSingle as default };
@@ -294,13 +294,22 @@ export function handlePasteLinkOnSelectedText(slice) {
294
294
  }
295
295
  export function handlePasteAsPlainText(slice, _event) {
296
296
  return function (state, dispatch, view) {
297
+ var _input;
298
+ if (!view) {
299
+ return false;
300
+ }
301
+
302
+ // prosemirror-bump-fix
303
+ // Yes, this is wrong by default. But, we need to keep the private PAI usage to unblock the prosemirror bump
304
+ // So, this code will make sure we are checking for both version (current and the newest prosemirror-view version
305
+ var isShiftKeyPressed = view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey);
297
306
  // In case of SHIFT+CMD+V ("Paste and Match Style") we don't want to run the usual
298
307
  // fuzzy matching of content. ProseMirror already handles this scenario and will
299
308
  // provide us with slice containing paragraphs with plain text, which we decorate
300
309
  // with "stored marks".
301
310
  // @see prosemirror-view/src/clipboard.js:parseFromClipboard()).
302
311
  // @see prosemirror-view/src/input.js:doPaste().
303
- if (view && view.shiftKey) {
312
+ if (isShiftKeyPressed) {
304
313
  var tr = closeHistory(state.tr);
305
314
  var _tr = tr,
306
315
  selection = _tr.selection;
@@ -105,7 +105,7 @@ var buildMenuIconState = function buildMenuIconState(iconMark) {
105
105
  return function (_ref2) {
106
106
  var schema = _ref2.schema,
107
107
  textFormattingPluginState = _ref2.textFormattingPluginState;
108
- var hasPluginState = Boolean(textFormattingPluginState);
108
+ var hasPluginState = Boolean(Object.keys(textFormattingPluginState || {}).length);
109
109
  var markSchema = IconsMarkSchema[iconMark];
110
110
  var hasSchemaMark = Boolean(schema.marks[markSchema]);
111
111
  if (!hasPluginState) {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.10.3";
2
+ export var version = "187.10.6";
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": "187.10.3",
3
+ "version": "187.10.6",
4
4
  "sideEffects": false
5
5
  }
@@ -1,8 +1,8 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
1
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
3
- import { AnalyticsEventPayload } from './types';
3
+ import type { AnalyticsEventPayload } from './types';
4
4
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
- import { PerformanceTracking } from '../../types/performance-tracking';
5
+ import type { PerformanceTracking } from '../../types/performance-tracking';
6
6
  import type { analyticsPlugin as newAnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  interface AnalyticsPluginOptions {
8
8
  createAnalyticsEvent?: CreateUIAnalyticsEvent;
@@ -42,5 +42,4 @@ export default class ResizableMediaSingle extends React.Component<Props, State>
42
42
  private saveWrapper;
43
43
  render(): jsx.JSX.Element;
44
44
  }
45
- export declare function calcOffsetLeft(insideInlineLike: boolean, insideLayout: boolean, pmViewDom: Element, wrapper?: HTMLElement): number;
46
45
  export {};
@@ -1,8 +1,8 @@
1
- import { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
1
+ import type { CreateUIAnalyticsEvent } from '@atlaskit/analytics-next';
2
2
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
3
- import { AnalyticsEventPayload } from './types';
3
+ import type { AnalyticsEventPayload } from './types';
4
4
  import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
5
- import { PerformanceTracking } from '../../types/performance-tracking';
5
+ import type { PerformanceTracking } from '../../types/performance-tracking';
6
6
  import type { analyticsPlugin as newAnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
7
7
  interface AnalyticsPluginOptions {
8
8
  createAnalyticsEvent?: CreateUIAnalyticsEvent;
@@ -42,5 +42,4 @@ export default class ResizableMediaSingle extends React.Component<Props, State>
42
42
  private saveWrapper;
43
43
  render(): jsx.JSX.Element;
44
44
  }
45
- export declare function calcOffsetLeft(insideInlineLike: boolean, insideLayout: boolean, pmViewDom: Element, wrapper?: HTMLElement): number;
46
45
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.10.3",
3
+ "version": "187.10.6",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"