@atlaskit/editor-common 74.45.5 → 74.46.1
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 +12 -0
- package/dist/cjs/guideline/dynamicGuideline.js +76 -48
- package/dist/cjs/guideline/index.js +20 -1
- package/dist/cjs/guideline/relativeGuideline.js +145 -0
- package/dist/cjs/keymaps/index.js +4 -4
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/preset/{plugin-commands.js → editor-commands.js} +4 -4
- package/dist/cjs/preset/index.js +3 -3
- package/dist/cjs/preset/plugin-injection-api.js +8 -8
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/guideline/dynamicGuideline.js +87 -54
- package/dist/es2019/guideline/index.js +2 -1
- package/dist/es2019/guideline/relativeGuideline.js +143 -0
- package/dist/es2019/keymaps/index.js +3 -3
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/preset/{plugin-commands.js → editor-commands.js} +3 -3
- package/dist/es2019/preset/index.js +1 -1
- package/dist/es2019/preset/plugin-injection-api.js +4 -4
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/guideline/dynamicGuideline.js +76 -48
- package/dist/esm/guideline/index.js +2 -1
- package/dist/esm/guideline/relativeGuideline.js +136 -0
- package/dist/esm/keymaps/index.js +3 -3
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/preset/{plugin-commands.js → editor-commands.js} +3 -3
- package/dist/esm/preset/index.js +1 -1
- package/dist/esm/preset/plugin-injection-api.js +8 -8
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/guideline/dynamicGuideline.d.ts +5 -26
- package/dist/types/guideline/index.d.ts +3 -2
- package/dist/types/guideline/relativeGuideline.d.ts +8 -0
- package/dist/types/guideline/types.d.ts +14 -3
- package/dist/types/keymaps/index.d.ts +2 -2
- package/dist/types/mark/commands.d.ts +2 -2
- package/dist/{types-ts4.5/preset/plugin-commands.d.ts → types/preset/editor-commands.d.ts} +4 -4
- package/dist/types/preset/index.d.ts +1 -1
- package/dist/types/preset/plugin-injection-api.d.ts +2 -2
- package/dist/types/types/editor-command.d.ts +5 -0
- package/dist/types/types/index.d.ts +2 -2
- package/dist/types/types/next-editor-plugin.d.ts +17 -6
- package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +5 -26
- package/dist/types-ts4.5/guideline/index.d.ts +3 -2
- package/dist/types-ts4.5/guideline/relativeGuideline.d.ts +8 -0
- package/dist/types-ts4.5/guideline/types.d.ts +14 -3
- package/dist/types-ts4.5/keymaps/index.d.ts +2 -2
- package/dist/types-ts4.5/mark/commands.d.ts +2 -2
- package/dist/{types/preset/plugin-commands.d.ts → types-ts4.5/preset/editor-commands.d.ts} +4 -4
- package/dist/types-ts4.5/preset/index.d.ts +1 -1
- package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +2 -2
- package/dist/types-ts4.5/types/editor-command.d.ts +5 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -2
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +17 -6
- package/package.json +1 -1
- package/dist/cjs/version.json +0 -5
- package/dist/es2019/version.json +0 -5
- package/dist/esm/version.json +0 -5
- package/dist/types/types/plugin-command.d.ts +0 -7
- package/dist/types-ts4.5/types/plugin-command.d.ts +0 -7
- /package/dist/cjs/types/{plugin-command.js → editor-command.js} +0 -0
- /package/dist/es2019/types/{plugin-command.js → editor-command.js} +0 -0
- /package/dist/esm/types/{plugin-command.js → editor-command.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.46.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`51e6a0128eb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/51e6a0128eb) - ED-18969 Implemented relative guideline
|
|
8
|
+
|
|
9
|
+
## 74.46.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`24fc3925d73`](https://bitbucket.org/atlassian/atlassian-frontend/commits/24fc3925d73) - Add a new hook called `usePreset` accesed via `@atlaskit/editor-core/use-preset`. This hook can be used to safely access state and commands from outside the editor using `EditorContext`.
|
|
14
|
+
|
|
3
15
|
## 74.45.5
|
|
4
16
|
|
|
5
17
|
### Patch 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
|
|
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
|
-
},
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -80,7 +80,7 @@ Object.defineProperty(exports, "UP", {
|
|
|
80
80
|
});
|
|
81
81
|
exports.backspace = exports.altPaste = exports.alignLeft = exports.addRowBefore = exports.addRowAfter = exports.addLink = exports.addInlineComment = exports.addColumnBefore = exports.addColumnAfter = exports.addAltText = void 0;
|
|
82
82
|
exports.bindKeymapWithCommand = bindKeymapWithCommand;
|
|
83
|
-
exports.
|
|
83
|
+
exports.bindKeymapWithEditorCommand = bindKeymapWithEditorCommand;
|
|
84
84
|
exports.find = exports.escape = exports.enter = exports.deleteKey = exports.cut = exports.ctrlBackSpace = exports.copy = exports.clearFormatting = void 0;
|
|
85
85
|
exports.findKeyMapForBrowser = findKeyMapForBrowser;
|
|
86
86
|
exports.findKeymapByDescription = findKeymapByDescription;
|
|
@@ -105,7 +105,7 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
105
105
|
var _react = _interopRequireWildcard(require("react"));
|
|
106
106
|
var _react2 = require("@emotion/react");
|
|
107
107
|
var _colors = require("@atlaskit/theme/colors");
|
|
108
|
-
var
|
|
108
|
+
var _editorCommands = require("../preset/editor-commands");
|
|
109
109
|
var _utils = require("../utils");
|
|
110
110
|
var _consts = require("./consts");
|
|
111
111
|
var _keymap = require("./keymap");
|
|
@@ -363,8 +363,8 @@ function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
|
363
363
|
var oldCmd = keymap[shortcut];
|
|
364
364
|
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
365
365
|
}
|
|
366
|
-
function
|
|
367
|
-
bindKeymapWithCommand(shortcut, (0,
|
|
366
|
+
function bindKeymapWithEditorCommand(shortcut, cmd, keymap) {
|
|
367
|
+
bindKeymapWithCommand(shortcut, (0, _editorCommands.editorCommandToPMCommand)(cmd), keymap);
|
|
368
368
|
}
|
|
369
369
|
function findKeyMapForBrowser(keyMap) {
|
|
370
370
|
if (keyMap) {
|
|
@@ -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.
|
|
19
|
+
var packageVersion = "74.46.1";
|
|
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
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.editorCommandToPMCommand = editorCommandToPMCommand;
|
|
7
7
|
/**
|
|
8
|
-
* Convert a
|
|
9
|
-
* The preferred approach to dispatching a `
|
|
8
|
+
* Convert a EditorCommand to a standard Prosemirror Command.
|
|
9
|
+
* The preferred approach to dispatching a `EditorCommand` is via the
|
|
10
10
|
* `executeCommand` on `pluginInjectionAPI`. In some cases
|
|
11
11
|
* the type may require a Command until we refactor this out and this
|
|
12
12
|
* function is suitable for those cases.
|
|
@@ -14,7 +14,7 @@ exports.pluginCommandToPMCommand = pluginCommandToPMCommand;
|
|
|
14
14
|
* @param command A plugin command (a function that modifies and returns a `Transaction`)
|
|
15
15
|
* @returns Command
|
|
16
16
|
*/
|
|
17
|
-
function
|
|
17
|
+
function editorCommandToPMCommand(command) {
|
|
18
18
|
return function (_ref, dispatch) {
|
|
19
19
|
var tr = _ref.tr;
|
|
20
20
|
var newTr = command === null || command === void 0 ? void 0 : command({
|
package/dist/cjs/preset/index.js
CHANGED
|
@@ -15,12 +15,12 @@ Object.defineProperty(exports, "EditorPresetBuilder", {
|
|
|
15
15
|
return _builder.EditorPresetBuilder;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "editorCommandToPMCommand", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function get() {
|
|
21
|
-
return
|
|
21
|
+
return _editorCommands.editorCommandToPMCommand;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
var _builder = require("./builder");
|
|
25
25
|
var _pluginInjectionApi = require("./plugin-injection-api");
|
|
26
|
-
var
|
|
26
|
+
var _editorCommands = require("./editor-commands");
|
|
@@ -13,7 +13,7 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
13
13
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
14
14
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
15
15
|
var _throttle = _interopRequireDefault(require("lodash/throttle"));
|
|
16
|
-
var
|
|
16
|
+
var _editorCommands = require("./editor-commands");
|
|
17
17
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
18
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -125,11 +125,11 @@ var ActionsAPI = /*#__PURE__*/function () {
|
|
|
125
125
|
}]);
|
|
126
126
|
return ActionsAPI;
|
|
127
127
|
}();
|
|
128
|
-
var
|
|
129
|
-
function
|
|
130
|
-
(0, _classCallCheck2.default)(this,
|
|
128
|
+
var EditorCommandsAPI = /*#__PURE__*/function () {
|
|
129
|
+
function EditorCommandsAPI() {
|
|
130
|
+
(0, _classCallCheck2.default)(this, EditorCommandsAPI);
|
|
131
131
|
}
|
|
132
|
-
(0, _createClass2.default)(
|
|
132
|
+
(0, _createClass2.default)(EditorCommandsAPI, [{
|
|
133
133
|
key: "createAPI",
|
|
134
134
|
value: function createAPI(plugin) {
|
|
135
135
|
if (!plugin || !hasCommands(plugin)) {
|
|
@@ -143,7 +143,7 @@ var PluginCommandsAPI = /*#__PURE__*/function () {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
}]);
|
|
146
|
-
return
|
|
146
|
+
return EditorCommandsAPI;
|
|
147
147
|
}();
|
|
148
148
|
var SharedStateAPI = /*#__PURE__*/function () {
|
|
149
149
|
function SharedStateAPI(_ref4) {
|
|
@@ -271,7 +271,7 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
271
271
|
});
|
|
272
272
|
this.plugins = new Map();
|
|
273
273
|
this.actionsAPI = new ActionsAPI();
|
|
274
|
-
this.commandsAPI = new
|
|
274
|
+
this.commandsAPI = new EditorCommandsAPI();
|
|
275
275
|
this.getEditorView = getEditorView;
|
|
276
276
|
}
|
|
277
277
|
(0, _createClass2.default)(EditorPluginInjectionAPI, [{
|
|
@@ -321,7 +321,7 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
321
321
|
}
|
|
322
322
|
var state = editorView.state,
|
|
323
323
|
dispatch = editorView.dispatch;
|
|
324
|
-
return (0,
|
|
324
|
+
return (0, _editorCommands.editorCommandToPMCommand)(command)(state, dispatch);
|
|
325
325
|
}
|
|
326
326
|
}]);
|
|
327
327
|
return EditorPluginInjectionAPI;
|
|
@@ -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.
|
|
27
|
+
var packageVersion = "74.46.1";
|
|
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 {
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
23
|
-
} =
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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';
|