@atlaskit/editor-common 74.46.0 → 74.46.2

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-common
2
2
 
3
+ ## 74.46.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`72e552fe076`](https://bitbucket.org/atlassian/atlassian-frontend/commits/72e552fe076) - [ux] ED-17954: Fix inline node selections for mentions and emojis in iOS. Previously, the visually hidden assistive text would also be shown as a selection in iOS which would often make the selection look larger than the actual node itself.
8
+
9
+ ## 74.46.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`51e6a0128eb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/51e6a0128eb) - ED-18969 Implemented relative guideline
14
+
3
15
  ## 74.46.0
4
16
 
5
17
  ### Minor Changes
@@ -6,65 +6,93 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.generateDynamicGuidelines = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _state = require("@atlaskit/editor-prosemirror/state");
10
11
  var _utils = require("@atlaskit/editor-prosemirror/utils");
11
12
  var _mediaSingle = require("../media-single");
12
13
  var _constants = require("./constants");
14
+ var _utils2 = require("./utils");
13
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
16
  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) { (0, _defineProperty2.default)(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; }
15
17
  var generateDynamicGuidelines = function generateDynamicGuidelines(state, editorWidth) {
16
18
  var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
17
19
  var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node;
18
- var mediaSingleNode = (0, _utils.findChildren)(state.tr.doc, function (node) {
20
+ var offset = editorWidth / 2;
21
+ return (0, _utils.findChildren)(state.tr.doc, function (node) {
19
22
  return node.type === state.schema.nodes.mediaSingle;
20
- }, false // only top level
21
- );
23
+ }).reduce(function (acc, nodeWithPos, index) {
24
+ var _acc$relativeGuides, _acc$relativeGuides2;
25
+ var node = nodeWithPos.node,
26
+ pos = nodeWithPos.pos;
22
27
 
23
- var offset = editorWidth / 2;
24
- return mediaSingleNode.map(function (_ref, index) {
25
- var node = _ref.node;
26
- if (selectedNode === node) {
27
- return [];
28
+ // if the current node the selected node
29
+ // or the node is not using pixel width,
30
+ // We will skip the node.
31
+ if (selectedNode === node || node.attrs.widthType !== 'pixel') {
32
+ return acc;
28
33
  }
29
- var _node$attrs = node.attrs,
30
- layout = _node$attrs.layout,
31
- width = _node$attrs.width,
32
- widthType = _node$attrs.widthType;
33
- var pixelWidth = (0, _mediaSingle.getMediaSinglePixelWidth)(width, editorWidth, widthType);
34
- var key = "".concat(_constants.MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index);
35
- switch (layout) {
36
- case 'align-start':
37
- case 'wrap-left':
38
- return _objectSpread({
39
- position: {
40
- x: (0, _mediaSingle.roundToNearest)(pixelWidth - offset)
41
- },
42
- key: key
43
- }, styles);
44
- case 'align-end':
45
- case 'wrap-right':
46
- return _objectSpread({
47
- position: {
48
- x: (0, _mediaSingle.roundToNearest)(offset - pixelWidth)
49
- },
50
- key: key
51
- }, styles);
52
- case 'center':
53
- return [_objectSpread({
54
- position: {
55
- x: (0, _mediaSingle.roundToNearest)(pixelWidth / 2)
56
- },
57
- key: "".concat(key, "_right")
58
- }, styles), _objectSpread({
59
- position: {
60
- x: -(0, _mediaSingle.roundToNearest)(pixelWidth / 2)
61
- },
62
- key: "".concat(key, "_left")
63
- }, styles)];
64
- // we ignore full-width and wide
65
- default:
66
- return [];
34
+ var $pos = state.tr.doc.resolve(pos);
35
+ if ($pos.parent.type !== state.schema.nodes.doc) {
36
+ return acc;
67
37
  }
68
- }).flat();
38
+ var dimensions = (0, _utils2.getMediaSingleDimensions)(node, editorWidth);
39
+ if (!dimensions) {
40
+ return acc;
41
+ }
42
+ var width = dimensions.width,
43
+ height = dimensions.height;
44
+ var dynamicGuides = [].concat((0, _toConsumableArray2.default)(acc.dynamicGuides), (0, _toConsumableArray2.default)(getDynamicGuides(node.attrs.layout, width, offset, "".concat(_constants.MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index), styles)));
45
+ var accRelativeGuidesWidth = ((_acc$relativeGuides = acc.relativeGuides) === null || _acc$relativeGuides === void 0 ? void 0 : _acc$relativeGuides.width) || {};
46
+ var accRelativeGuidesHeight = ((_acc$relativeGuides2 = acc.relativeGuides) === null || _acc$relativeGuides2 === void 0 ? void 0 : _acc$relativeGuides2.height) || {};
47
+ var relativeGuidesWidth = _objectSpread(_objectSpread({}, accRelativeGuidesWidth), {}, (0, _defineProperty2.default)({}, width, [].concat((0, _toConsumableArray2.default)(accRelativeGuidesWidth[width] || []), [nodeWithPos])));
48
+ var relativeGuidesWidthHeight = _objectSpread(_objectSpread({}, accRelativeGuidesHeight), {}, (0, _defineProperty2.default)({}, Math.round(height), [].concat((0, _toConsumableArray2.default)(accRelativeGuidesHeight[height] || []), [nodeWithPos])));
49
+ return {
50
+ dynamicGuides: dynamicGuides,
51
+ relativeGuides: {
52
+ width: relativeGuidesWidth,
53
+ height: relativeGuidesWidthHeight
54
+ }
55
+ };
56
+ }, {
57
+ relativeGuides: {
58
+ width: {},
59
+ height: {}
60
+ },
61
+ dynamicGuides: []
62
+ });
69
63
  };
70
- exports.generateDynamicGuidelines = generateDynamicGuidelines;
64
+ exports.generateDynamicGuidelines = generateDynamicGuidelines;
65
+ var getDynamicGuides = function getDynamicGuides(layout, width, offset, key, styles) {
66
+ switch (layout) {
67
+ case 'align-start':
68
+ case 'wrap-left':
69
+ return [_objectSpread({
70
+ position: {
71
+ x: (0, _mediaSingle.roundToNearest)(width - offset)
72
+ },
73
+ key: key
74
+ }, styles)];
75
+ case 'align-end':
76
+ case 'wrap-right':
77
+ return [_objectSpread({
78
+ position: {
79
+ x: (0, _mediaSingle.roundToNearest)(offset - width)
80
+ },
81
+ key: key
82
+ }, styles)];
83
+ case 'center':
84
+ return [_objectSpread({
85
+ position: {
86
+ x: (0, _mediaSingle.roundToNearest)(width / 2)
87
+ },
88
+ key: "".concat(key, "_right")
89
+ }, styles), _objectSpread({
90
+ position: {
91
+ x: -(0, _mediaSingle.roundToNearest)(width / 2)
92
+ },
93
+ key: "".concat(key, "_left")
94
+ }, styles)];
95
+ default:
96
+ return [];
97
+ }
98
+ };
@@ -69,6 +69,24 @@ Object.defineProperty(exports, "getGuidelinesWithHighlights", {
69
69
  return _updateGuideline.getGuidelinesWithHighlights;
70
70
  }
71
71
  });
72
+ Object.defineProperty(exports, "getMediaSingleDimensions", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _utils.getMediaSingleDimensions;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "getRelativeGuideSnaps", {
79
+ enumerable: true,
80
+ get: function get() {
81
+ return _relativeGuideline.getRelativeGuideSnaps;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "getRelativeGuidelines", {
85
+ enumerable: true,
86
+ get: function get() {
87
+ return _relativeGuideline.getRelativeGuidelines;
88
+ }
89
+ });
72
90
  Object.defineProperty(exports, "isVerticalPosition", {
73
91
  enumerable: true,
74
92
  get: function get() {
@@ -81,4 +99,5 @@ var _defaultGuideline = require("./defaultGuideline");
81
99
  var _updateGuideline = require("./updateGuideline");
82
100
  var _constants = require("./constants");
83
101
  var _snapping = require("./snapping");
84
- var _utils = require("./utils");
102
+ var _utils = require("./utils");
103
+ var _relativeGuideline = require("./relativeGuideline");
@@ -0,0 +1,145 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getRelativeGuidelines = exports.getRelativeGuideSnaps = void 0;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _mediaSingle = require("../media-single");
10
+ var _utils = require("./utils");
11
+ var RELATIVE_GUIDES_GAP = 6;
12
+ var getWidthRelativeGuideline = function getWidthRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
13
+ var node = nodeWithPos.node,
14
+ pos = nodeWithPos.pos;
15
+ var _view$dom$getBounding = view.dom.getBoundingClientRect(),
16
+ topOffSet = _view$dom$getBounding.top,
17
+ viewHeight = _view$dom$getBounding.height;
18
+ var _view$coordsAtPos = view.coordsAtPos(pos + 1),
19
+ top = _view$coordsAtPos.top; // media node
20
+
21
+ var _ref = size || (0, _utils.getMediaSingleDimensions)(node, editorWidth) || {},
22
+ width = _ref.width,
23
+ height = _ref.height;
24
+ var y = top - topOffSet - RELATIVE_GUIDES_GAP;
25
+ if (!width || !height || y < 0 || y > viewHeight) {
26
+ return null;
27
+ }
28
+ var start = 0;
29
+ var end = 0;
30
+ switch (node.attrs.layout) {
31
+ case 'align-start':
32
+ case 'wrap-left':
33
+ start = -editorWidth / 2;
34
+ end = start + width;
35
+ break;
36
+ case 'align-end':
37
+ case 'wrap-right':
38
+ end = editorWidth / 2;
39
+ start = end - width;
40
+ break;
41
+ case 'center':
42
+ case 'wide':
43
+ case 'full-width':
44
+ end = width / 2;
45
+ start = -end;
46
+ break;
47
+ default:
48
+ }
49
+ return {
50
+ key: key,
51
+ position: {
52
+ y: y,
53
+ x: {
54
+ start: start,
55
+ end: end
56
+ }
57
+ },
58
+ active: true,
59
+ styles: {
60
+ lineStyle: 'dashed',
61
+ capStyle: 'line'
62
+ }
63
+ };
64
+ };
65
+ var getHeightRelativeGuideline = function getHeightRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
66
+ var node = nodeWithPos.node,
67
+ pos = nodeWithPos.pos;
68
+ var _view$dom$getBounding2 = view.dom.getBoundingClientRect(),
69
+ topOffSet = _view$dom$getBounding2.top,
70
+ viewHeight = _view$dom$getBounding2.height;
71
+ var _view$coordsAtPos2 = view.coordsAtPos(pos + 1),
72
+ top = _view$coordsAtPos2.top; // media node
73
+
74
+ var _ref2 = size || (0, _utils.getMediaSingleDimensions)(node, editorWidth) || {},
75
+ width = _ref2.width,
76
+ height = _ref2.height;
77
+ if (!width || !height) {
78
+ return null;
79
+ }
80
+ var start = top - topOffSet;
81
+ var end = start + height;
82
+ if (end < 0 || start > viewHeight) {
83
+ return null;
84
+ }
85
+ var x = 0;
86
+ var halfWidth = editorWidth / 2;
87
+ switch (node.attrs.layout) {
88
+ case 'align-start':
89
+ case 'wrap-left':
90
+ x = width - halfWidth;
91
+ break;
92
+ case 'align-end':
93
+ case 'wrap-right':
94
+ x = halfWidth;
95
+ break;
96
+ case 'center':
97
+ case 'wide':
98
+ case 'full-width':
99
+ x = width / 2;
100
+ break;
101
+ default:
102
+ x = 0;
103
+ }
104
+ return {
105
+ key: key,
106
+ position: {
107
+ x: x + RELATIVE_GUIDES_GAP,
108
+ y: {
109
+ start: start,
110
+ end: end
111
+ }
112
+ },
113
+ active: true,
114
+ styles: {
115
+ lineStyle: 'dashed',
116
+ capStyle: 'line'
117
+ }
118
+ };
119
+ };
120
+ var getRelativeGuideSnaps = function getRelativeGuideSnaps(relativeGuides, aspectRatio) {
121
+ var snapsWidthFromMatchingHeight = Object.keys(relativeGuides.height || {}).map(function (heightKey) {
122
+ var height = Number.parseInt(heightKey);
123
+ return (0, _mediaSingle.roundToNearest)(height * aspectRatio);
124
+ });
125
+ var snapsWidthFromMatchingWidth = Object.keys(relativeGuides.width || {}).map(function (widthKey) {
126
+ return Number.parseInt(widthKey);
127
+ });
128
+ return [].concat((0, _toConsumableArray2.default)(snapsWidthFromMatchingWidth), (0, _toConsumableArray2.default)(snapsWidthFromMatchingHeight));
129
+ };
130
+ exports.getRelativeGuideSnaps = getRelativeGuideSnaps;
131
+ var getRelativeGuidelines = function getRelativeGuidelines(relativeGuides, nodeWithPos, view, editorWidth, size) {
132
+ var matchWidth = relativeGuides.width ? relativeGuides.width[Math.round(size.width)] : [];
133
+ var matchHeight = relativeGuides.height ? relativeGuides.height[Math.round(size.height)] : [];
134
+ var matches = matchWidth || matchHeight;
135
+ var getRelativeGuideline = matchWidth && getWidthRelativeGuideline || matchHeight && getHeightRelativeGuideline || null;
136
+ if (matches && getRelativeGuideline) {
137
+ return [getRelativeGuideline('relative_guide_current', view, nodeWithPos, editorWidth, size)].concat((0, _toConsumableArray2.default)(matches.map(function (nodeWithPos, index) {
138
+ return getRelativeGuideline("relative_guide_".concat(index), view, nodeWithPos, editorWidth);
139
+ }))).filter(function (config) {
140
+ return !!config;
141
+ });
142
+ }
143
+ return [];
144
+ };
145
+ exports.getRelativeGuidelines = getRelativeGuidelines;
@@ -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.46.0";
19
+ var packageVersion = "74.46.2";
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.46.0";
27
+ var packageVersion = "74.46.2";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,64 +1,97 @@
1
1
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
2
  import { findChildren } from '@atlaskit/editor-prosemirror/utils';
3
- import { getMediaSinglePixelWidth, roundToNearest } from '../media-single';
3
+ import { roundToNearest } from '../media-single';
4
4
  import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
5
+ import { getMediaSingleDimensions } from './utils';
5
6
  export const generateDynamicGuidelines = (state, editorWidth, styles = {}) => {
6
7
  const selectedNode = state.selection instanceof NodeSelection && state.selection.node;
7
- const mediaSingleNode = findChildren(state.tr.doc, node => {
8
- return node.type === state.schema.nodes.mediaSingle;
9
- }, false // only top level
10
- );
11
-
12
8
  const offset = editorWidth / 2;
13
- return mediaSingleNode.map(({
14
- node
15
- }, index) => {
16
- if (selectedNode === node) {
17
- return [];
9
+ return findChildren(state.tr.doc, node => node.type === state.schema.nodes.mediaSingle).reduce((acc, nodeWithPos, index) => {
10
+ var _acc$relativeGuides, _acc$relativeGuides2;
11
+ const {
12
+ node,
13
+ pos
14
+ } = nodeWithPos;
15
+
16
+ // if the current node the selected node
17
+ // or the node is not using pixel width,
18
+ // We will skip the node.
19
+ if (selectedNode === node || node.attrs.widthType !== 'pixel') {
20
+ return acc;
21
+ }
22
+ const $pos = state.tr.doc.resolve(pos);
23
+ if ($pos.parent.type !== state.schema.nodes.doc) {
24
+ return acc;
25
+ }
26
+ const dimensions = getMediaSingleDimensions(node, editorWidth);
27
+ if (!dimensions) {
28
+ return acc;
18
29
  }
19
30
  const {
20
- layout,
21
31
  width,
22
- widthType
23
- } = node.attrs;
24
- const pixelWidth = getMediaSinglePixelWidth(width, editorWidth, widthType);
25
- const key = `${MEDIA_DYNAMIC_GUIDELINE_PREFIX}${index}`;
26
- switch (layout) {
27
- case 'align-start':
28
- case 'wrap-left':
29
- return {
30
- position: {
31
- x: roundToNearest(pixelWidth - offset)
32
- },
33
- key,
34
- ...styles
35
- };
36
- case 'align-end':
37
- case 'wrap-right':
38
- return {
39
- position: {
40
- x: roundToNearest(offset - pixelWidth)
41
- },
42
- key,
43
- ...styles
44
- };
45
- case 'center':
46
- return [{
47
- position: {
48
- x: roundToNearest(pixelWidth / 2)
49
- },
50
- key: `${key}_right`,
51
- ...styles
52
- }, {
53
- position: {
54
- x: -roundToNearest(pixelWidth / 2)
55
- },
56
- key: `${key}_left`,
57
- ...styles
58
- }];
59
- // we ignore full-width and wide
60
- default:
61
- return [];
62
- }
63
- }).flat();
32
+ height
33
+ } = dimensions;
34
+ const dynamicGuides = [...acc.dynamicGuides, ...getDynamicGuides(node.attrs.layout, width, offset, `${MEDIA_DYNAMIC_GUIDELINE_PREFIX}${index}`, styles)];
35
+ const accRelativeGuidesWidth = ((_acc$relativeGuides = acc.relativeGuides) === null || _acc$relativeGuides === void 0 ? void 0 : _acc$relativeGuides.width) || {};
36
+ const accRelativeGuidesHeight = ((_acc$relativeGuides2 = acc.relativeGuides) === null || _acc$relativeGuides2 === void 0 ? void 0 : _acc$relativeGuides2.height) || {};
37
+ const relativeGuidesWidth = {
38
+ ...accRelativeGuidesWidth,
39
+ [width]: [...(accRelativeGuidesWidth[width] || []), nodeWithPos]
40
+ };
41
+ const relativeGuidesWidthHeight = {
42
+ ...accRelativeGuidesHeight,
43
+ [Math.round(height)]: [...(accRelativeGuidesHeight[height] || []), nodeWithPos]
44
+ };
45
+ return {
46
+ dynamicGuides,
47
+ relativeGuides: {
48
+ width: relativeGuidesWidth,
49
+ height: relativeGuidesWidthHeight
50
+ }
51
+ };
52
+ }, {
53
+ relativeGuides: {
54
+ width: {},
55
+ height: {}
56
+ },
57
+ dynamicGuides: []
58
+ });
59
+ };
60
+ const getDynamicGuides = (layout, width, offset, key, styles) => {
61
+ switch (layout) {
62
+ case 'align-start':
63
+ case 'wrap-left':
64
+ return [{
65
+ position: {
66
+ x: roundToNearest(width - offset)
67
+ },
68
+ key,
69
+ ...styles
70
+ }];
71
+ case 'align-end':
72
+ case 'wrap-right':
73
+ return [{
74
+ position: {
75
+ x: roundToNearest(offset - width)
76
+ },
77
+ key,
78
+ ...styles
79
+ }];
80
+ case 'center':
81
+ return [{
82
+ position: {
83
+ x: roundToNearest(width / 2)
84
+ },
85
+ key: `${key}_right`,
86
+ ...styles
87
+ }, {
88
+ position: {
89
+ x: -roundToNearest(width / 2)
90
+ },
91
+ key: `${key}_left`,
92
+ ...styles
93
+ }];
94
+ default:
95
+ return [];
96
+ }
64
97
  };
@@ -4,4 +4,5 @@ export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
5
  export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX } from './constants';
6
6
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
7
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
7
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
8
+ export { getRelativeGuideSnaps, getRelativeGuidelines } from './relativeGuideline';
@@ -0,0 +1,143 @@
1
+ import { roundToNearest } from '../media-single';
2
+ import { getMediaSingleDimensions } from './utils';
3
+ const RELATIVE_GUIDES_GAP = 6;
4
+ const getWidthRelativeGuideline = (key, view, nodeWithPos, editorWidth, size) => {
5
+ const {
6
+ node,
7
+ pos
8
+ } = nodeWithPos;
9
+ const {
10
+ top: topOffSet,
11
+ height: viewHeight
12
+ } = view.dom.getBoundingClientRect();
13
+ const {
14
+ top
15
+ } = view.coordsAtPos(pos + 1); // media node
16
+
17
+ const {
18
+ width,
19
+ height
20
+ } = size || getMediaSingleDimensions(node, editorWidth) || {};
21
+ const y = top - topOffSet - RELATIVE_GUIDES_GAP;
22
+ if (!width || !height || y < 0 || y > viewHeight) {
23
+ return null;
24
+ }
25
+ let start = 0;
26
+ let end = 0;
27
+ switch (node.attrs.layout) {
28
+ case 'align-start':
29
+ case 'wrap-left':
30
+ start = -editorWidth / 2;
31
+ end = start + width;
32
+ break;
33
+ case 'align-end':
34
+ case 'wrap-right':
35
+ end = editorWidth / 2;
36
+ start = end - width;
37
+ break;
38
+ case 'center':
39
+ case 'wide':
40
+ case 'full-width':
41
+ end = width / 2;
42
+ start = -end;
43
+ break;
44
+ default:
45
+ }
46
+ return {
47
+ key,
48
+ position: {
49
+ y,
50
+ x: {
51
+ start,
52
+ end
53
+ }
54
+ },
55
+ active: true,
56
+ styles: {
57
+ lineStyle: 'dashed',
58
+ capStyle: 'line'
59
+ }
60
+ };
61
+ };
62
+ const getHeightRelativeGuideline = (key, view, nodeWithPos, editorWidth, size) => {
63
+ const {
64
+ node,
65
+ pos
66
+ } = nodeWithPos;
67
+ const {
68
+ top: topOffSet,
69
+ height: viewHeight
70
+ } = view.dom.getBoundingClientRect();
71
+ const {
72
+ top
73
+ } = view.coordsAtPos(pos + 1); // media node
74
+
75
+ const {
76
+ width,
77
+ height
78
+ } = size || getMediaSingleDimensions(node, editorWidth) || {};
79
+ if (!width || !height) {
80
+ return null;
81
+ }
82
+ const start = top - topOffSet;
83
+ const end = start + height;
84
+ if (end < 0 || start > viewHeight) {
85
+ return null;
86
+ }
87
+ let x = 0;
88
+ const halfWidth = editorWidth / 2;
89
+ switch (node.attrs.layout) {
90
+ case 'align-start':
91
+ case 'wrap-left':
92
+ x = width - halfWidth;
93
+ break;
94
+ case 'align-end':
95
+ case 'wrap-right':
96
+ x = halfWidth;
97
+ break;
98
+ case 'center':
99
+ case 'wide':
100
+ case 'full-width':
101
+ x = width / 2;
102
+ break;
103
+ default:
104
+ x = 0;
105
+ }
106
+ return {
107
+ key,
108
+ position: {
109
+ x: x + RELATIVE_GUIDES_GAP,
110
+ y: {
111
+ start,
112
+ end
113
+ }
114
+ },
115
+ active: true,
116
+ styles: {
117
+ lineStyle: 'dashed',
118
+ capStyle: 'line'
119
+ }
120
+ };
121
+ };
122
+ export const getRelativeGuideSnaps = (relativeGuides, aspectRatio) => {
123
+ const snapsWidthFromMatchingHeight = Object.keys(relativeGuides.height || {}).map(heightKey => {
124
+ const height = Number.parseInt(heightKey);
125
+ return roundToNearest(height * aspectRatio);
126
+ });
127
+ const snapsWidthFromMatchingWidth = Object.keys(relativeGuides.width || {}).map(widthKey => {
128
+ return Number.parseInt(widthKey);
129
+ });
130
+ return [...snapsWidthFromMatchingWidth, ...snapsWidthFromMatchingHeight];
131
+ };
132
+ export const getRelativeGuidelines = (relativeGuides, nodeWithPos, view, editorWidth, size) => {
133
+ const matchWidth = relativeGuides.width ? relativeGuides.width[Math.round(size.width)] : [];
134
+ const matchHeight = relativeGuides.height ? relativeGuides.height[Math.round(size.height)] : [];
135
+ const matches = matchWidth || matchHeight;
136
+ const getRelativeGuideline = matchWidth && getWidthRelativeGuideline || matchHeight && getHeightRelativeGuideline || null;
137
+ if (matches && getRelativeGuideline) {
138
+ return [getRelativeGuideline('relative_guide_current', view, nodeWithPos, editorWidth, size), ...matches.map((nodeWithPos, index) => {
139
+ return getRelativeGuideline(`relative_guide_${index}`, view, nodeWithPos, editorWidth);
140
+ })].filter(config => !!config);
141
+ }
142
+ return [];
143
+ };
@@ -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.46.0";
3
+ const packageVersion = "74.46.2";
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.46.0";
11
+ const packageVersion = "74.46.2";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = '0, 8';
14
14
  class DropList extends Component {
@@ -1,62 +1,90 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
4
  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; }
4
5
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
5
6
  import { findChildren } from '@atlaskit/editor-prosemirror/utils';
6
- import { getMediaSinglePixelWidth, roundToNearest } from '../media-single';
7
+ import { roundToNearest } from '../media-single';
7
8
  import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
9
+ import { getMediaSingleDimensions } from './utils';
8
10
  export var generateDynamicGuidelines = function generateDynamicGuidelines(state, editorWidth) {
9
11
  var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
10
12
  var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
11
- var mediaSingleNode = findChildren(state.tr.doc, function (node) {
13
+ var offset = editorWidth / 2;
14
+ return findChildren(state.tr.doc, function (node) {
12
15
  return node.type === state.schema.nodes.mediaSingle;
13
- }, false // only top level
14
- );
16
+ }).reduce(function (acc, nodeWithPos, index) {
17
+ var _acc$relativeGuides, _acc$relativeGuides2;
18
+ var node = nodeWithPos.node,
19
+ pos = nodeWithPos.pos;
15
20
 
16
- var offset = editorWidth / 2;
17
- return mediaSingleNode.map(function (_ref, index) {
18
- var node = _ref.node;
19
- if (selectedNode === node) {
20
- return [];
21
+ // if the current node the selected node
22
+ // or the node is not using pixel width,
23
+ // We will skip the node.
24
+ if (selectedNode === node || node.attrs.widthType !== 'pixel') {
25
+ return acc;
21
26
  }
22
- var _node$attrs = node.attrs,
23
- layout = _node$attrs.layout,
24
- width = _node$attrs.width,
25
- widthType = _node$attrs.widthType;
26
- var pixelWidth = getMediaSinglePixelWidth(width, editorWidth, widthType);
27
- var key = "".concat(MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index);
28
- switch (layout) {
29
- case 'align-start':
30
- case 'wrap-left':
31
- return _objectSpread({
32
- position: {
33
- x: roundToNearest(pixelWidth - offset)
34
- },
35
- key: key
36
- }, styles);
37
- case 'align-end':
38
- case 'wrap-right':
39
- return _objectSpread({
40
- position: {
41
- x: roundToNearest(offset - pixelWidth)
42
- },
43
- key: key
44
- }, styles);
45
- case 'center':
46
- return [_objectSpread({
47
- position: {
48
- x: roundToNearest(pixelWidth / 2)
49
- },
50
- key: "".concat(key, "_right")
51
- }, styles), _objectSpread({
52
- position: {
53
- x: -roundToNearest(pixelWidth / 2)
54
- },
55
- key: "".concat(key, "_left")
56
- }, styles)];
57
- // we ignore full-width and wide
58
- default:
59
- return [];
27
+ var $pos = state.tr.doc.resolve(pos);
28
+ if ($pos.parent.type !== state.schema.nodes.doc) {
29
+ return acc;
60
30
  }
61
- }).flat();
31
+ var dimensions = getMediaSingleDimensions(node, editorWidth);
32
+ if (!dimensions) {
33
+ return acc;
34
+ }
35
+ var width = dimensions.width,
36
+ height = dimensions.height;
37
+ var dynamicGuides = [].concat(_toConsumableArray(acc.dynamicGuides), _toConsumableArray(getDynamicGuides(node.attrs.layout, width, offset, "".concat(MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index), styles)));
38
+ var accRelativeGuidesWidth = ((_acc$relativeGuides = acc.relativeGuides) === null || _acc$relativeGuides === void 0 ? void 0 : _acc$relativeGuides.width) || {};
39
+ var accRelativeGuidesHeight = ((_acc$relativeGuides2 = acc.relativeGuides) === null || _acc$relativeGuides2 === void 0 ? void 0 : _acc$relativeGuides2.height) || {};
40
+ var relativeGuidesWidth = _objectSpread(_objectSpread({}, accRelativeGuidesWidth), {}, _defineProperty({}, width, [].concat(_toConsumableArray(accRelativeGuidesWidth[width] || []), [nodeWithPos])));
41
+ var relativeGuidesWidthHeight = _objectSpread(_objectSpread({}, accRelativeGuidesHeight), {}, _defineProperty({}, Math.round(height), [].concat(_toConsumableArray(accRelativeGuidesHeight[height] || []), [nodeWithPos])));
42
+ return {
43
+ dynamicGuides: dynamicGuides,
44
+ relativeGuides: {
45
+ width: relativeGuidesWidth,
46
+ height: relativeGuidesWidthHeight
47
+ }
48
+ };
49
+ }, {
50
+ relativeGuides: {
51
+ width: {},
52
+ height: {}
53
+ },
54
+ dynamicGuides: []
55
+ });
56
+ };
57
+ var getDynamicGuides = function getDynamicGuides(layout, width, offset, key, styles) {
58
+ switch (layout) {
59
+ case 'align-start':
60
+ case 'wrap-left':
61
+ return [_objectSpread({
62
+ position: {
63
+ x: roundToNearest(width - offset)
64
+ },
65
+ key: key
66
+ }, styles)];
67
+ case 'align-end':
68
+ case 'wrap-right':
69
+ return [_objectSpread({
70
+ position: {
71
+ x: roundToNearest(offset - width)
72
+ },
73
+ key: key
74
+ }, styles)];
75
+ case 'center':
76
+ return [_objectSpread({
77
+ position: {
78
+ x: roundToNearest(width / 2)
79
+ },
80
+ key: "".concat(key, "_right")
81
+ }, styles), _objectSpread({
82
+ position: {
83
+ x: -roundToNearest(width / 2)
84
+ },
85
+ key: "".concat(key, "_left")
86
+ }, styles)];
87
+ default:
88
+ return [];
89
+ }
62
90
  };
@@ -4,4 +4,5 @@ export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
5
  export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX } from './constants';
6
6
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
7
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
7
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
8
+ export { getRelativeGuideSnaps, getRelativeGuidelines } from './relativeGuideline';
@@ -0,0 +1,136 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import { roundToNearest } from '../media-single';
3
+ import { getMediaSingleDimensions } from './utils';
4
+ var RELATIVE_GUIDES_GAP = 6;
5
+ var getWidthRelativeGuideline = function getWidthRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
6
+ var node = nodeWithPos.node,
7
+ pos = nodeWithPos.pos;
8
+ var _view$dom$getBounding = view.dom.getBoundingClientRect(),
9
+ topOffSet = _view$dom$getBounding.top,
10
+ viewHeight = _view$dom$getBounding.height;
11
+ var _view$coordsAtPos = view.coordsAtPos(pos + 1),
12
+ top = _view$coordsAtPos.top; // media node
13
+
14
+ var _ref = size || getMediaSingleDimensions(node, editorWidth) || {},
15
+ width = _ref.width,
16
+ height = _ref.height;
17
+ var y = top - topOffSet - RELATIVE_GUIDES_GAP;
18
+ if (!width || !height || y < 0 || y > viewHeight) {
19
+ return null;
20
+ }
21
+ var start = 0;
22
+ var end = 0;
23
+ switch (node.attrs.layout) {
24
+ case 'align-start':
25
+ case 'wrap-left':
26
+ start = -editorWidth / 2;
27
+ end = start + width;
28
+ break;
29
+ case 'align-end':
30
+ case 'wrap-right':
31
+ end = editorWidth / 2;
32
+ start = end - width;
33
+ break;
34
+ case 'center':
35
+ case 'wide':
36
+ case 'full-width':
37
+ end = width / 2;
38
+ start = -end;
39
+ break;
40
+ default:
41
+ }
42
+ return {
43
+ key: key,
44
+ position: {
45
+ y: y,
46
+ x: {
47
+ start: start,
48
+ end: end
49
+ }
50
+ },
51
+ active: true,
52
+ styles: {
53
+ lineStyle: 'dashed',
54
+ capStyle: 'line'
55
+ }
56
+ };
57
+ };
58
+ var getHeightRelativeGuideline = function getHeightRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
59
+ var node = nodeWithPos.node,
60
+ pos = nodeWithPos.pos;
61
+ var _view$dom$getBounding2 = view.dom.getBoundingClientRect(),
62
+ topOffSet = _view$dom$getBounding2.top,
63
+ viewHeight = _view$dom$getBounding2.height;
64
+ var _view$coordsAtPos2 = view.coordsAtPos(pos + 1),
65
+ top = _view$coordsAtPos2.top; // media node
66
+
67
+ var _ref2 = size || getMediaSingleDimensions(node, editorWidth) || {},
68
+ width = _ref2.width,
69
+ height = _ref2.height;
70
+ if (!width || !height) {
71
+ return null;
72
+ }
73
+ var start = top - topOffSet;
74
+ var end = start + height;
75
+ if (end < 0 || start > viewHeight) {
76
+ return null;
77
+ }
78
+ var x = 0;
79
+ var halfWidth = editorWidth / 2;
80
+ switch (node.attrs.layout) {
81
+ case 'align-start':
82
+ case 'wrap-left':
83
+ x = width - halfWidth;
84
+ break;
85
+ case 'align-end':
86
+ case 'wrap-right':
87
+ x = halfWidth;
88
+ break;
89
+ case 'center':
90
+ case 'wide':
91
+ case 'full-width':
92
+ x = width / 2;
93
+ break;
94
+ default:
95
+ x = 0;
96
+ }
97
+ return {
98
+ key: key,
99
+ position: {
100
+ x: x + RELATIVE_GUIDES_GAP,
101
+ y: {
102
+ start: start,
103
+ end: end
104
+ }
105
+ },
106
+ active: true,
107
+ styles: {
108
+ lineStyle: 'dashed',
109
+ capStyle: 'line'
110
+ }
111
+ };
112
+ };
113
+ export var getRelativeGuideSnaps = function getRelativeGuideSnaps(relativeGuides, aspectRatio) {
114
+ var snapsWidthFromMatchingHeight = Object.keys(relativeGuides.height || {}).map(function (heightKey) {
115
+ var height = Number.parseInt(heightKey);
116
+ return roundToNearest(height * aspectRatio);
117
+ });
118
+ var snapsWidthFromMatchingWidth = Object.keys(relativeGuides.width || {}).map(function (widthKey) {
119
+ return Number.parseInt(widthKey);
120
+ });
121
+ return [].concat(_toConsumableArray(snapsWidthFromMatchingWidth), _toConsumableArray(snapsWidthFromMatchingHeight));
122
+ };
123
+ export var getRelativeGuidelines = function getRelativeGuidelines(relativeGuides, nodeWithPos, view, editorWidth, size) {
124
+ var matchWidth = relativeGuides.width ? relativeGuides.width[Math.round(size.width)] : [];
125
+ var matchHeight = relativeGuides.height ? relativeGuides.height[Math.round(size.height)] : [];
126
+ var matches = matchWidth || matchHeight;
127
+ var getRelativeGuideline = matchWidth && getWidthRelativeGuideline || matchHeight && getHeightRelativeGuideline || null;
128
+ if (matches && getRelativeGuideline) {
129
+ return [getRelativeGuideline('relative_guide_current', view, nodeWithPos, editorWidth, size)].concat(_toConsumableArray(matches.map(function (nodeWithPos, index) {
130
+ return getRelativeGuideline("relative_guide_".concat(index), view, nodeWithPos, editorWidth);
131
+ }))).filter(function (config) {
132
+ return !!config;
133
+ });
134
+ }
135
+ return [];
136
+ };
@@ -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.46.0";
9
+ var packageVersion = "74.46.2";
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.46.0";
21
+ var packageVersion = "74.46.2";
22
22
  var halfFocusRing = 1;
23
23
  var dropOffset = '0, 8';
24
24
  var DropList = /*#__PURE__*/function (_Component) {
@@ -1,27 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import type { GuidelineConfig } from './types';
3
- export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
- styles?: {
5
- capStyle?: "line" | undefined;
6
- lineStyle?: "dashed" | "solid" | undefined;
7
- color?: import("@atlaskit/tokens").CSSToken | undefined;
8
- } | undefined;
9
- show?: boolean | undefined;
10
- active?: boolean | undefined;
11
- position: {
12
- x: number;
13
- };
14
- key: string;
15
- } | {
16
- styles?: {
17
- capStyle?: "line" | undefined;
18
- lineStyle?: "dashed" | "solid" | undefined;
19
- color?: import("@atlaskit/tokens").CSSToken | undefined;
20
- } | undefined;
21
- show?: boolean | undefined;
22
- active?: boolean | undefined;
23
- position: {
24
- x: number;
25
- };
26
- key: string;
27
- })[];
2
+ import type { GuidelineConfig, GuidelineStyles, RelativeGuides } from './types';
3
+ export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: GuidelineStyles) => {
4
+ dynamicGuides: GuidelineConfig[];
5
+ relativeGuides: RelativeGuides;
6
+ };
@@ -3,6 +3,7 @@ export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fi
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
5
  export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX, } from './constants';
6
- export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
6
+ export type { WidthTypes, Position, GuidelineStyles, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, RelativeGuides, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
7
7
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
8
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
9
+ export { getRelativeGuideSnaps, getRelativeGuidelines, } from './relativeGuideline';
@@ -0,0 +1,8 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { GuidelineConfig, RelativeGuides } from './types';
4
+ export declare const getRelativeGuideSnaps: (relativeGuides: RelativeGuides, aspectRatio: number) => number[];
5
+ export declare const getRelativeGuidelines: (relativeGuides: RelativeGuides, nodeWithPos: NodeWithPos, view: EditorView, editorWidth: number, size: {
6
+ width: number;
7
+ height: number;
8
+ }) => GuidelineConfig[];
@@ -1,3 +1,4 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { CSSToken } from '@atlaskit/tokens';
3
4
  export type WidthTypes = 'percentage' | 'pixel';
@@ -19,9 +20,7 @@ export type HorizontalPosition = {
19
20
  y: number;
20
21
  };
21
22
  export type Position = VerticalPosition | HorizontalPosition;
22
- export type GuidelineConfig = {
23
- key: string;
24
- position: Position;
23
+ export type GuidelineStyles = {
25
24
  active?: boolean;
26
25
  show?: boolean;
27
26
  styles?: {
@@ -30,6 +29,10 @@ export type GuidelineConfig = {
30
29
  color?: CSSToken;
31
30
  };
32
31
  };
32
+ export type GuidelineConfig = {
33
+ key: string;
34
+ position: Position;
35
+ } & GuidelineStyles;
33
36
  export type GuidelinePluginState = {
34
37
  guidelines: GuidelineConfig[];
35
38
  };
@@ -49,3 +52,11 @@ export type GuidelineSnapsReference = {
49
52
  guidelineReference: GuidelineSnap[];
50
53
  };
51
54
  export type GuidelineTypes = 'default' | 'temporary' | 'relative' | 'none';
55
+ export type RelativeGuides = {
56
+ width?: {
57
+ [key: number]: NodeWithPos[];
58
+ };
59
+ height?: {
60
+ [key: number]: NodeWithPos[];
61
+ };
62
+ };
@@ -1,27 +1,6 @@
1
1
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import type { GuidelineConfig } from './types';
3
- export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
4
- styles?: {
5
- capStyle?: "line" | undefined;
6
- lineStyle?: "dashed" | "solid" | undefined;
7
- color?: import("@atlaskit/tokens").CSSToken | undefined;
8
- } | undefined;
9
- show?: boolean | undefined;
10
- active?: boolean | undefined;
11
- position: {
12
- x: number;
13
- };
14
- key: string;
15
- } | {
16
- styles?: {
17
- capStyle?: "line" | undefined;
18
- lineStyle?: "dashed" | "solid" | undefined;
19
- color?: import("@atlaskit/tokens").CSSToken | undefined;
20
- } | undefined;
21
- show?: boolean | undefined;
22
- active?: boolean | undefined;
23
- position: {
24
- x: number;
25
- };
26
- key: string;
27
- })[];
2
+ import type { GuidelineConfig, GuidelineStyles, RelativeGuides } from './types';
3
+ export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: GuidelineStyles) => {
4
+ dynamicGuides: GuidelineConfig[];
5
+ relativeGuides: RelativeGuides;
6
+ };
@@ -3,6 +3,7 @@ export { createFixedGuidelinesFromLengths, createGuidesFromLengths, } from './fi
3
3
  export { generateDefaultGuidelines } from './defaultGuideline';
4
4
  export { getGuidelinesWithHighlights } from './updateGuideline';
5
5
  export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX, } from './constants';
6
- export type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
6
+ export type { WidthTypes, Position, GuidelineStyles, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, RelativeGuides, GuidelineSnap, GuidelineSnapsReference, GuidelineTypes, } from './types';
7
7
  export { getGuidelineSnaps, findClosestSnap } from './snapping';
8
- export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
8
+ export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey, } from './utils';
9
+ export { getRelativeGuideSnaps, getRelativeGuidelines, } from './relativeGuideline';
@@ -0,0 +1,8 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import type { GuidelineConfig, RelativeGuides } from './types';
4
+ export declare const getRelativeGuideSnaps: (relativeGuides: RelativeGuides, aspectRatio: number) => number[];
5
+ export declare const getRelativeGuidelines: (relativeGuides: RelativeGuides, nodeWithPos: NodeWithPos, view: EditorView, editorWidth: number, size: {
6
+ width: number;
7
+ height: number;
8
+ }) => GuidelineConfig[];
@@ -1,3 +1,4 @@
1
+ import type { NodeWithPos } from '@atlaskit/editor-prosemirror/utils';
1
2
  import type { EditorView } from '@atlaskit/editor-prosemirror/view';
2
3
  import type { CSSToken } from '@atlaskit/tokens';
3
4
  export type WidthTypes = 'percentage' | 'pixel';
@@ -19,9 +20,7 @@ export type HorizontalPosition = {
19
20
  y: number;
20
21
  };
21
22
  export type Position = VerticalPosition | HorizontalPosition;
22
- export type GuidelineConfig = {
23
- key: string;
24
- position: Position;
23
+ export type GuidelineStyles = {
25
24
  active?: boolean;
26
25
  show?: boolean;
27
26
  styles?: {
@@ -30,6 +29,10 @@ export type GuidelineConfig = {
30
29
  color?: CSSToken;
31
30
  };
32
31
  };
32
+ export type GuidelineConfig = {
33
+ key: string;
34
+ position: Position;
35
+ } & GuidelineStyles;
33
36
  export type GuidelinePluginState = {
34
37
  guidelines: GuidelineConfig[];
35
38
  };
@@ -49,3 +52,11 @@ export type GuidelineSnapsReference = {
49
52
  guidelineReference: GuidelineSnap[];
50
53
  };
51
54
  export type GuidelineTypes = 'default' | 'temporary' | 'relative' | 'none';
55
+ export type RelativeGuides = {
56
+ width?: {
57
+ [key: number]: NodeWithPos[];
58
+ };
59
+ height?: {
60
+ [key: number]: NodeWithPos[];
61
+ };
62
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "74.46.0",
3
+ "version": "74.46.2",
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/"
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.46.0",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.46.0",
4
- "sideEffects": false
5
- }
@@ -1,5 +0,0 @@
1
- {
2
- "name": "@atlaskit/editor-common",
3
- "version": "74.46.0",
4
- "sideEffects": false
5
- }