@atlaskit/editor-common 74.34.2 → 74.34.3

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,11 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 74.34.3
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
+
3
9
  ## 74.34.2
4
10
 
5
11
  ### Patch Changes
@@ -27,6 +27,12 @@ Object.defineProperty(exports, "MediaSingleLayout", {
27
27
  return _constants.Layout;
28
28
  }
29
29
  });
30
+ Object.defineProperty(exports, "calculateOffsetLeft", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _utils.calculateOffsetLeft;
34
+ }
35
+ });
30
36
  Object.defineProperty(exports, "getMediaSinglePixelWidth", {
31
37
  enumerable: true,
32
38
  get: function get() {
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.calculateOffsetLeft = calculateOffsetLeft;
6
7
  exports.getMediaSinglePixelWidth = getMediaSinglePixelWidth;
7
8
  /**
8
9
  * Convert media node width to pixel
@@ -23,4 +24,13 @@ function getMediaSinglePixelWidth(width, editorWidth) {
23
24
  return width;
24
25
  }
25
26
  return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
27
+ }
28
+ function calculateOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
29
+ var offsetLeft = 0;
30
+ if (wrapper && insideInlineLike && !insideLayout) {
31
+ var currentNode = wrapper;
32
+ var boundingRect = currentNode.getBoundingClientRect();
33
+ offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
34
+ }
35
+ return offsetLeft;
26
36
  }
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
16
16
  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; }
17
17
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
18
18
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
19
- var packageVersion = "74.34.2";
19
+ var packageVersion = "74.34.3";
20
20
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
21
21
  // Remove URL as it has UGC
22
22
  // TODO: Sanitise the URL instead of just removing it
@@ -24,7 +24,7 @@ var _templateObject, _templateObject2, _templateObject3;
24
24
  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); }; }
25
25
  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 */
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "74.34.2";
27
+ var packageVersion = "74.34.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.calcColumnsFromPx = calcColumnsFromPx;
7
7
  exports.calcMediaPxWidth = void 0;
8
8
  exports.calcPctFromPx = calcPctFromPx;
9
+ exports.calcPctWidth = void 0;
9
10
  exports.calcPxFromColumns = calcPxFromColumns;
10
11
  exports.calcPxFromPct = calcPxFromPct;
11
12
  exports.wrappedLayouts = exports.snapToGrid = exports.layoutSupportsWidth = void 0;
@@ -37,6 +38,7 @@ exports.wrappedLayouts = wrappedLayouts;
37
38
  var calcPctWidth = function calcPctWidth(containerWidth, pctWidth, origWidth, origHeight) {
38
39
  return pctWidth && origWidth && origHeight && Math.ceil(calcPxFromPct(pctWidth / 100, containerWidth.lineLength || containerWidth.width));
39
40
  };
41
+ exports.calcPctWidth = calcPctWidth;
40
42
  var calcMediaPxWidth = function calcMediaPxWidth(opts) {
41
43
  var origWidth = opts.origWidth,
42
44
  origHeight = opts.origHeight,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.34.2",
3
+ "version": "74.34.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,2 @@
1
1
  export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, Layout as MediaSingleLayout } from './constants';
2
- export { getMediaSinglePixelWidth } from './utils';
2
+ export { getMediaSinglePixelWidth, calculateOffsetLeft } from './utils';
@@ -15,4 +15,13 @@ export function getMediaSinglePixelWidth(width, editorWidth, widthType = 'percen
15
15
  return width;
16
16
  }
17
17
  return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
18
+ }
19
+ export function calculateOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
20
+ let offsetLeft = 0;
21
+ if (wrapper && insideInlineLike && !insideLayout) {
22
+ const currentNode = wrapper;
23
+ const boundingRect = currentNode.getBoundingClientRect();
24
+ offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
25
+ }
26
+ return offsetLeft;
18
27
  }
@@ -1,6 +1,6 @@
1
1
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
2
2
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
3
- const packageVersion = "74.34.2";
3
+ const packageVersion = "74.34.3";
4
4
  const sanitiseSentryEvents = (data, _hint) => {
5
5
  // Remove URL as it has UGC
6
6
  // TODO: Sanitise the URL instead of just removing it
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "74.34.2";
11
+ const packageVersion = "74.34.3";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -19,7 +19,7 @@ export function calcPctFromPx(width, lineLength) {
19
19
  return (width + MEDIA_SINGLE_GUTTER_SIZE) / maxWidth;
20
20
  }
21
21
  export const wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
22
- const calcPctWidth = (containerWidth, pctWidth, origWidth, origHeight) => pctWidth && origWidth && origHeight && Math.ceil(calcPxFromPct(pctWidth / 100, containerWidth.lineLength || containerWidth.width));
22
+ export const calcPctWidth = (containerWidth, pctWidth, origWidth, origHeight) => pctWidth && origWidth && origHeight && Math.ceil(calcPxFromPct(pctWidth / 100, containerWidth.lineLength || containerWidth.width));
23
23
  export const calcMediaPxWidth = opts => {
24
24
  const {
25
25
  origWidth,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.34.2",
3
+ "version": "74.34.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,2 @@
1
1
  export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, Layout as MediaSingleLayout } from './constants';
2
- export { getMediaSinglePixelWidth } from './utils';
2
+ export { getMediaSinglePixelWidth, calculateOffsetLeft } from './utils';
@@ -17,4 +17,13 @@ export function getMediaSinglePixelWidth(width, editorWidth) {
17
17
  return width;
18
18
  }
19
19
  return Math.ceil((editorWidth + gutterOffset) * (width / 100) - gutterOffset);
20
+ }
21
+ export function calculateOffsetLeft(insideInlineLike, insideLayout, pmViewDom, wrapper) {
22
+ var offsetLeft = 0;
23
+ if (wrapper && insideInlineLike && !insideLayout) {
24
+ var currentNode = wrapper;
25
+ var boundingRect = currentNode.getBoundingClientRect();
26
+ offsetLeft = boundingRect.left - pmViewDom.getBoundingClientRect().left;
27
+ }
28
+ return offsetLeft;
20
29
  }
@@ -6,7 +6,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
6
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
8
8
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
9
- var packageVersion = "74.34.2";
9
+ var packageVersion = "74.34.3";
10
10
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
11
11
  // Remove URL as it has UGC
12
12
  // TODO: Sanitise the URL instead of just removing it
@@ -18,7 +18,7 @@ import { themed } from '@atlaskit/theme/components';
18
18
  import { borderRadius } from '@atlaskit/theme/constants';
19
19
  import Layer from '../Layer';
20
20
  var packageName = "@atlaskit/editor-common";
21
- var packageVersion = "74.34.2";
21
+ var packageVersion = "74.34.3";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -21,7 +21,7 @@ export function calcPctFromPx(width, lineLength) {
21
21
  return (width + MEDIA_SINGLE_GUTTER_SIZE) / maxWidth;
22
22
  }
23
23
  export var wrappedLayouts = ['wrap-left', 'wrap-right', 'align-end', 'align-start'];
24
- var calcPctWidth = function calcPctWidth(containerWidth, pctWidth, origWidth, origHeight) {
24
+ export var calcPctWidth = function calcPctWidth(containerWidth, pctWidth, origWidth, origHeight) {
25
25
  return pctWidth && origWidth && origHeight && Math.ceil(calcPxFromPct(pctWidth / 100, containerWidth.lineLength || containerWidth.width));
26
26
  };
27
27
  export var calcMediaPxWidth = function calcMediaPxWidth(opts) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.34.2",
3
+ "version": "74.34.3",
4
4
  "sideEffects": false
5
5
  }
@@ -1,2 +1,2 @@
1
1
  export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, Layout as MediaSingleLayout, } from './constants';
2
- export { getMediaSinglePixelWidth } from './utils';
2
+ export { getMediaSinglePixelWidth, calculateOffsetLeft } from './utils';
@@ -11,3 +11,4 @@
11
11
  * @returns pixel number for media single node
12
12
  */
13
13
  export declare function getMediaSinglePixelWidth(width: number, editorWidth: number, widthType?: string, gutterOffset?: number): number;
14
+ export declare function calculateOffsetLeft(insideInlineLike: boolean, insideLayout: boolean, pmViewDom: Element, wrapper?: HTMLElement): number;
@@ -7,6 +7,7 @@ export declare function calcColumnsFromPx(width: number, lineLength: number, gri
7
7
  export declare function calcPxFromPct(pct: number, lineLength: number): number;
8
8
  export declare function calcPctFromPx(width: number, lineLength: number): number;
9
9
  export declare const wrappedLayouts: MediaSingleLayout[];
10
+ export declare const calcPctWidth: (containerWidth: EditorContainerWidth, pctWidth?: number, origWidth?: number, origHeight?: number) => number | undefined;
10
11
  export declare const calcMediaPxWidth: (opts: {
11
12
  origWidth: number;
12
13
  origHeight: number;
@@ -1,2 +1,2 @@
1
1
  export { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_HIGHLIGHT_GAP, Layout as MediaSingleLayout, } from './constants';
2
- export { getMediaSinglePixelWidth } from './utils';
2
+ export { getMediaSinglePixelWidth, calculateOffsetLeft } from './utils';
@@ -11,3 +11,4 @@
11
11
  * @returns pixel number for media single node
12
12
  */
13
13
  export declare function getMediaSinglePixelWidth(width: number, editorWidth: number, widthType?: string, gutterOffset?: number): number;
14
+ export declare function calculateOffsetLeft(insideInlineLike: boolean, insideLayout: boolean, pmViewDom: Element, wrapper?: HTMLElement): number;
@@ -7,6 +7,7 @@ export declare function calcColumnsFromPx(width: number, lineLength: number, gri
7
7
  export declare function calcPxFromPct(pct: number, lineLength: number): number;
8
8
  export declare function calcPctFromPx(width: number, lineLength: number): number;
9
9
  export declare const wrappedLayouts: MediaSingleLayout[];
10
+ export declare const calcPctWidth: (containerWidth: EditorContainerWidth, pctWidth?: number, origWidth?: number, origHeight?: number) => number | undefined;
10
11
  export declare const calcMediaPxWidth: (opts: {
11
12
  origWidth: number;
12
13
  origHeight: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.34.2",
3
+ "version": "74.34.3",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"