@atlaskit/editor-common 74.37.0 → 74.38.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 +22 -0
- package/dist/cjs/guideline/constants.js +4 -2
- package/dist/cjs/guideline/defaultGuideline.js +4 -3
- package/dist/cjs/guideline/index.js +10 -4
- package/dist/cjs/guideline/snapping.js +42 -30
- package/dist/cjs/keymaps/index.js +11 -7
- package/dist/cjs/media-single/utils.js +1 -1
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/preset/index.js +8 -1
- package/dist/cjs/preset/plugin-commands.js +19 -0
- package/dist/cjs/preset/plugin-injection-api.js +28 -1
- package/dist/cjs/types/plugin-command.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/MediaSingle/styled.js +1 -11
- package/dist/cjs/utils/rich-media-utils.js +6 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/guideline/constants.js +2 -1
- package/dist/es2019/guideline/defaultGuideline.js +4 -3
- package/dist/es2019/guideline/index.js +2 -2
- package/dist/es2019/guideline/snapping.js +35 -27
- package/dist/es2019/keymaps/index.js +10 -7
- package/dist/es2019/media-single/utils.js +1 -1
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/preset/index.js +2 -1
- package/dist/es2019/preset/plugin-commands.js +14 -0
- package/dist/es2019/preset/plugin-injection-api.js +21 -1
- package/dist/es2019/types/plugin-command.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/MediaSingle/styled.js +11 -24
- package/dist/es2019/utils/rich-media-utils.js +6 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/guideline/constants.js +2 -1
- package/dist/esm/guideline/defaultGuideline.js +4 -3
- package/dist/esm/guideline/index.js +2 -2
- package/dist/esm/guideline/snapping.js +40 -28
- package/dist/esm/keymaps/index.js +10 -7
- package/dist/esm/media-single/utils.js +1 -1
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/preset/index.js +2 -1
- package/dist/esm/preset/plugin-commands.js +13 -0
- package/dist/esm/preset/plugin-injection-api.js +28 -1
- package/dist/esm/types/plugin-command.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/MediaSingle/styled.js +3 -12
- package/dist/esm/utils/rich-media-utils.js +6 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/guideline/constants.d.ts +1 -0
- package/dist/types/guideline/dynamicGuideline.d.ts +1 -1
- package/dist/types/guideline/index.d.ts +3 -3
- package/dist/types/guideline/snapping.d.ts +12 -11
- package/dist/types/guideline/types.d.ts +13 -2
- package/dist/types/keymaps/index.d.ts +5 -1
- package/dist/types/media-single/utils.d.ts +1 -1
- package/dist/types/preset/index.d.ts +1 -0
- package/dist/types/preset/plugin-commands.d.ts +3 -0
- package/dist/types/preset/plugin-injection-api.d.ts +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/next-editor-plugin.d.ts +10 -1
- package/dist/types/types/plugin-command.d.ts +7 -0
- package/dist/types/ui/MediaSingle/styled.d.ts +3 -2
- package/dist/types/utils/rich-media-utils.d.ts +1 -1
- package/dist/types-ts4.5/guideline/constants.d.ts +1 -0
- package/dist/types-ts4.5/guideline/dynamicGuideline.d.ts +1 -1
- package/dist/types-ts4.5/guideline/index.d.ts +3 -3
- package/dist/types-ts4.5/guideline/snapping.d.ts +12 -11
- package/dist/types-ts4.5/guideline/types.d.ts +13 -2
- package/dist/types-ts4.5/keymaps/index.d.ts +5 -1
- package/dist/types-ts4.5/media-single/utils.d.ts +1 -1
- package/dist/types-ts4.5/preset/index.d.ts +1 -0
- package/dist/types-ts4.5/preset/plugin-commands.d.ts +3 -0
- package/dist/types-ts4.5/preset/plugin-injection-api.d.ts +1 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -0
- package/dist/types-ts4.5/types/next-editor-plugin.d.ts +10 -1
- package/dist/types-ts4.5/types/plugin-command.d.ts +7 -0
- package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +3 -2
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 74.38.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4cbae03c15c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4cbae03c15c) - Set maxWidth for ResizerNext to stop lable updating when reaching max width
|
|
8
|
+
|
|
9
|
+
## 74.38.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`a675f834911`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a675f834911) - Introduce `commands` optional parameter to `NextEditorPlugin`. It can be used similarly to `actions` in `NextEditorPlugin` but `commands` must adhere to the type of `PluginCommand`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type PluginCommand = ({ tr }: { tr: Transaction }) => Transaction | null;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`PluginCommand`s are specifically used for code that is executed to modify a Transaction. They should be used in preference to the existing prosemirror `Command` type.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [`3bbe8f91f34`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3bbe8f91f34) - refactor ResizableMediaSingleNext around guidelines and snapping
|
|
24
|
+
|
|
3
25
|
## 74.37.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.MEDIA_DYNAMIC_GUIDELINE_PREFIX = void 0;
|
|
6
|
+
exports.MEDIA_DYNAMIC_GUIDELINE_PREFIX = exports.INNER_GRID_GUIDELINE_PREFIX = void 0;
|
|
7
7
|
var MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
|
|
8
|
-
exports.MEDIA_DYNAMIC_GUIDELINE_PREFIX = MEDIA_DYNAMIC_GUIDELINE_PREFIX;
|
|
8
|
+
exports.MEDIA_DYNAMIC_GUIDELINE_PREFIX = MEDIA_DYNAMIC_GUIDELINE_PREFIX;
|
|
9
|
+
var INNER_GRID_GUIDELINE_PREFIX = 'grid_';
|
|
10
|
+
exports.INNER_GRID_GUIDELINE_PREFIX = INNER_GRID_GUIDELINE_PREFIX;
|
|
@@ -8,19 +8,20 @@ exports.generateDefaultGuidelines = void 0;
|
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
9
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
10
10
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
11
|
+
var _mediaSingle = require("../media-single");
|
|
11
12
|
var _utils = require("./utils");
|
|
12
13
|
var getDefaultGuidelines = (0, _memoizeOne.default)(function (editorWidth) {
|
|
13
14
|
return [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6].map(function (val, index) {
|
|
14
15
|
return {
|
|
15
16
|
key: "grid_".concat(index),
|
|
16
17
|
position: {
|
|
17
|
-
x: val / 12 * editorWidth
|
|
18
|
+
x: (0, _mediaSingle.roundToNearest)(val / 12 * editorWidth)
|
|
18
19
|
}
|
|
19
20
|
};
|
|
20
21
|
});
|
|
21
22
|
});
|
|
22
23
|
var getWideGuidelines = (0, _memoizeOne.default)(function (editorWidth) {
|
|
23
|
-
var wideSpacing = editorWidth * _editorSharedStyles.breakoutWideScaleRatio / 2;
|
|
24
|
+
var wideSpacing = (0, _mediaSingle.roundToNearest)(editorWidth * _editorSharedStyles.breakoutWideScaleRatio / 2);
|
|
24
25
|
return [{
|
|
25
26
|
key: "wide_left",
|
|
26
27
|
position: {
|
|
@@ -34,7 +35,7 @@ var getWideGuidelines = (0, _memoizeOne.default)(function (editorWidth) {
|
|
|
34
35
|
}];
|
|
35
36
|
});
|
|
36
37
|
var getFullWidthGuidelines = (0, _memoizeOne.default)(function (containerWidth) {
|
|
37
|
-
var fullWidth = (0, _utils.getContainerWidthOrFullEditorWidth)(containerWidth);
|
|
38
|
+
var fullWidth = (0, _mediaSingle.roundToNearest)((0, _utils.getContainerWidthOrFullEditorWidth)(containerWidth));
|
|
38
39
|
return [{
|
|
39
40
|
key: "full_width_left",
|
|
40
41
|
position: {
|
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "INNER_GRID_GUIDELINE_PREFIX", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _constants.INNER_GRID_GUIDELINE_PREFIX;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
Object.defineProperty(exports, "MEDIA_DYNAMIC_GUIDELINE_PREFIX", {
|
|
7
13
|
enumerable: true,
|
|
8
14
|
get: function get() {
|
|
@@ -45,16 +51,16 @@ Object.defineProperty(exports, "getContainerWidthOrFullEditorWidth", {
|
|
|
45
51
|
return _utils.getContainerWidthOrFullEditorWidth;
|
|
46
52
|
}
|
|
47
53
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "getGuidelineSnaps", {
|
|
49
55
|
enumerable: true,
|
|
50
56
|
get: function get() {
|
|
51
|
-
return
|
|
57
|
+
return _snapping.getGuidelineSnaps;
|
|
52
58
|
}
|
|
53
59
|
});
|
|
54
|
-
Object.defineProperty(exports, "
|
|
60
|
+
Object.defineProperty(exports, "getGuidelinesWithHighlights", {
|
|
55
61
|
enumerable: true,
|
|
56
62
|
get: function get() {
|
|
57
|
-
return
|
|
63
|
+
return _updateGuideline.getGuidelinesWithHighlights;
|
|
58
64
|
}
|
|
59
65
|
});
|
|
60
66
|
Object.defineProperty(exports, "isVerticalPosition", {
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var
|
|
7
|
+
exports.getGuidelineSnaps = exports.findClosestSnap = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
8
10
|
var _constants = require("./constants");
|
|
11
|
+
var _utils = require("./utils");
|
|
9
12
|
/**
|
|
10
13
|
* Returns keys of guidelines that are closest to the image and withthin the snapGap.
|
|
11
14
|
* If both default and dynamic guidelines present, only returns default guidelines
|
|
12
15
|
*/
|
|
13
|
-
var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray,
|
|
16
|
+
var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray, guidelineSnaps) {
|
|
14
17
|
var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
15
18
|
var closestGapIndex = snapArray.reduce(function (prev, curr, index) {
|
|
16
19
|
return Math.abs(curr - mediaSingleWidth) < Math.abs(snapArray[prev] - mediaSingleWidth) ? index : prev;
|
|
17
20
|
}, 0);
|
|
18
21
|
var gap = Math.abs(snapArray[closestGapIndex] - mediaSingleWidth);
|
|
19
22
|
if (gap < snapGap) {
|
|
20
|
-
var snappingWidth =
|
|
23
|
+
var snappingWidth = snapArray[closestGapIndex];
|
|
21
24
|
var guidelineKeys = [];
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// find wich guideline have the matching snap width
|
|
26
|
+
guidelineSnaps.forEach(function (gs) {
|
|
27
|
+
if (gs.width === snappingWidth) {
|
|
28
|
+
guidelineKeys.push(gs.guidelineKey);
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
31
|
var defaultGuidelineKeys = guidelineKeys.filter(function (guidelineKey) {
|
|
@@ -39,37 +43,45 @@ var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray, snap
|
|
|
39
43
|
keys: []
|
|
40
44
|
};
|
|
41
45
|
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get snapping widths and respective guideline keys
|
|
45
|
-
*/
|
|
46
46
|
exports.findClosestSnap = findClosestSnap;
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
47
|
+
var getGuidelineSnaps = (0, _memoizeOne.default)(function (guidelines, editorWidth) {
|
|
48
|
+
var layout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'center';
|
|
49
|
+
var offset = editorWidth / 2;
|
|
50
|
+
var getPositionX = function getPositionX(position) {
|
|
51
|
+
return (0, _utils.isVerticalPosition)(position) ? position.x : 0;
|
|
52
|
+
};
|
|
53
|
+
var calcXSnaps = function calcXSnaps(guidelineReference) {
|
|
54
|
+
var snapsWidth = guidelineReference.filter(function (g) {
|
|
55
|
+
return g.width > 0;
|
|
56
|
+
}).map(function (g) {
|
|
57
|
+
return g.width;
|
|
58
|
+
});
|
|
59
|
+
var uniqueSnapWidth = (0, _toConsumableArray2.default)(new Set(snapsWidth));
|
|
60
|
+
return snapsWidth.length ? uniqueSnapWidth : undefined;
|
|
61
|
+
};
|
|
62
|
+
var guidelinesSnapsReference = guidelines.map(function (guideline) {
|
|
63
|
+
var positionX = getPositionX(guideline.position);
|
|
64
|
+
if (['align-end', 'wrap-right'].includes(layout)) {
|
|
57
65
|
return {
|
|
58
66
|
guidelineKey: guideline.key,
|
|
59
|
-
width:
|
|
67
|
+
width: offset - positionX
|
|
60
68
|
};
|
|
61
|
-
} else if (
|
|
69
|
+
} else if (['align-start', 'wrap-left'].includes(layout)) {
|
|
62
70
|
return {
|
|
63
71
|
guidelineKey: guideline.key,
|
|
64
|
-
width:
|
|
72
|
+
width: positionX + offset
|
|
65
73
|
};
|
|
66
74
|
}
|
|
67
75
|
return {
|
|
68
|
-
guidelineKey:
|
|
69
|
-
width:
|
|
76
|
+
guidelineKey: guideline.key,
|
|
77
|
+
width: Math.abs(positionX) * 2
|
|
70
78
|
};
|
|
71
|
-
}).filter(function (guideline) {
|
|
72
|
-
return guideline.guidelineKey !== '';
|
|
73
79
|
});
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
return {
|
|
81
|
+
guidelineReference: guidelinesSnapsReference,
|
|
82
|
+
snaps: {
|
|
83
|
+
x: calcXSnaps(guidelinesSnapsReference)
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
exports.getGuidelineSnaps = getGuidelineSnaps;
|
|
@@ -80,6 +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.bindKeymapWithPluginCommand = bindKeymapWithPluginCommand;
|
|
83
84
|
exports.find = exports.escape = exports.enter = exports.deleteKey = exports.cut = exports.ctrlBackSpace = exports.copy = exports.clearFormatting = void 0;
|
|
84
85
|
exports.findKeyMapForBrowser = findKeyMapForBrowser;
|
|
85
86
|
exports.findKeymapByDescription = findKeymapByDescription;
|
|
@@ -104,6 +105,7 @@ var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/hel
|
|
|
104
105
|
var _react = _interopRequireWildcard(require("react"));
|
|
105
106
|
var _react2 = require("@emotion/react");
|
|
106
107
|
var _colors = require("@atlaskit/theme/colors");
|
|
108
|
+
var _pluginCommands = require("../preset/plugin-commands");
|
|
107
109
|
var _utils = require("../utils");
|
|
108
110
|
var _consts = require("./consts");
|
|
109
111
|
var _keymap = require("./keymap");
|
|
@@ -352,15 +354,17 @@ function makeKeyMapWithCommon(description, common) {
|
|
|
352
354
|
var mac = common.replace(/Mod/i, 'Cmd');
|
|
353
355
|
return makeKeymap(description, windows, mac, common);
|
|
354
356
|
}
|
|
357
|
+
function combineWithOldCommand(cmd, oldCmd) {
|
|
358
|
+
return function (state, dispatch, editorView) {
|
|
359
|
+
return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
|
|
360
|
+
};
|
|
361
|
+
}
|
|
355
362
|
function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
356
363
|
var oldCmd = keymap[shortcut];
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
keymap[shortcut] = newCmd;
|
|
364
|
+
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
365
|
+
}
|
|
366
|
+
function bindKeymapWithPluginCommand(shortcut, cmd, keymap) {
|
|
367
|
+
bindKeymapWithCommand(shortcut, (0, _pluginCommands.pluginCommandToPMCommand)(cmd), keymap);
|
|
364
368
|
}
|
|
365
369
|
function findKeyMapForBrowser(keyMap) {
|
|
366
370
|
if (keyMap) {
|
|
@@ -97,7 +97,7 @@ var calcLegacyWideWidth = function calcLegacyWideWidth(containerWidth, origWidth
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
|
-
* Calculate maximum width allowed for media single in new experience
|
|
100
|
+
* Calculate maximum width allowed for media single node in fix-width editor in new experience
|
|
101
101
|
* @param containerWidth width of editor container
|
|
102
102
|
*/
|
|
103
103
|
var calcMediaSingleMaxWidth = function calcMediaSingleMaxWidth(containerWidth) {
|
|
@@ -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.38.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
|
package/dist/cjs/preset/index.js
CHANGED
|
@@ -15,5 +15,12 @@ Object.defineProperty(exports, "EditorPresetBuilder", {
|
|
|
15
15
|
return _builder.EditorPresetBuilder;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
+
Object.defineProperty(exports, "pluginCommandToPMCommand", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _pluginCommands.pluginCommandToPMCommand;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
18
24
|
var _builder = require("./builder");
|
|
19
|
-
var _pluginInjectionApi = require("./plugin-injection-api");
|
|
25
|
+
var _pluginInjectionApi = require("./plugin-injection-api");
|
|
26
|
+
var _pluginCommands = require("./plugin-commands");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.pluginCommandToPMCommand = pluginCommandToPMCommand;
|
|
7
|
+
function pluginCommandToPMCommand(command) {
|
|
8
|
+
return function (_ref, dispatch) {
|
|
9
|
+
var tr = _ref.tr;
|
|
10
|
+
var newTr = command === null || command === void 0 ? void 0 : command({
|
|
11
|
+
tr: tr
|
|
12
|
+
});
|
|
13
|
+
if (newTr) {
|
|
14
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
return false;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -22,6 +22,9 @@ function hasGetSharedState(plugin) {
|
|
|
22
22
|
function hasActions(plugin) {
|
|
23
23
|
return (0, _typeof2.default)(plugin.actions) === 'object';
|
|
24
24
|
}
|
|
25
|
+
function hasCommands(plugin) {
|
|
26
|
+
return (0, _typeof2.default)(plugin.commands) === 'object';
|
|
27
|
+
}
|
|
25
28
|
var filterPluginsWithListeners = function filterPluginsWithListeners(_ref) {
|
|
26
29
|
var listeners = _ref.listeners,
|
|
27
30
|
plugins = _ref.plugins;
|
|
@@ -121,6 +124,26 @@ var ActionsAPI = /*#__PURE__*/function () {
|
|
|
121
124
|
}]);
|
|
122
125
|
return ActionsAPI;
|
|
123
126
|
}();
|
|
127
|
+
var PluginCommandsAPI = /*#__PURE__*/function () {
|
|
128
|
+
function PluginCommandsAPI() {
|
|
129
|
+
(0, _classCallCheck2.default)(this, PluginCommandsAPI);
|
|
130
|
+
}
|
|
131
|
+
(0, _createClass2.default)(PluginCommandsAPI, [{
|
|
132
|
+
key: "createAPI",
|
|
133
|
+
value: function createAPI(plugin) {
|
|
134
|
+
if (!plugin || !hasCommands(plugin)) {
|
|
135
|
+
return {};
|
|
136
|
+
}
|
|
137
|
+
return new Proxy(plugin.commands || {}, {
|
|
138
|
+
get: function get(target, prop, receiver) {
|
|
139
|
+
// We will be able to track perfomance here
|
|
140
|
+
return Reflect.get(target, prop);
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}]);
|
|
145
|
+
return PluginCommandsAPI;
|
|
146
|
+
}();
|
|
124
147
|
var SharedStateAPI = /*#__PURE__*/function () {
|
|
125
148
|
function SharedStateAPI(_ref4) {
|
|
126
149
|
var getEditorState = _ref4.getEditorState;
|
|
@@ -246,12 +269,14 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
246
269
|
});
|
|
247
270
|
this.plugins = new Map();
|
|
248
271
|
this.actionsAPI = new ActionsAPI();
|
|
272
|
+
this.commandsAPI = new PluginCommandsAPI();
|
|
249
273
|
}
|
|
250
274
|
(0, _createClass2.default)(EditorPluginInjectionAPI, [{
|
|
251
275
|
key: "api",
|
|
252
276
|
value: function api() {
|
|
253
277
|
var sharedStateAPI = this.sharedStateAPI,
|
|
254
278
|
actionsAPI = this.actionsAPI,
|
|
279
|
+
commandsAPI = this.commandsAPI,
|
|
255
280
|
getPluginByName = this.getPluginByName;
|
|
256
281
|
var dependencies = new Proxy({}, {
|
|
257
282
|
get: function get(target, prop, receiver) {
|
|
@@ -270,9 +295,11 @@ var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
270
295
|
}
|
|
271
296
|
var sharedState = sharedStateAPI.createAPI(plugin);
|
|
272
297
|
var actions = actionsAPI.createAPI(plugin);
|
|
298
|
+
var commands = commandsAPI.createAPI(plugin);
|
|
273
299
|
var proxyCoreAPI = {
|
|
274
300
|
sharedState: sharedState,
|
|
275
|
-
actions: actions
|
|
301
|
+
actions: actions,
|
|
302
|
+
commands: commands
|
|
276
303
|
};
|
|
277
304
|
return proxyCoreAPI;
|
|
278
305
|
}
|
|
@@ -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.38.1";
|
|
28
28
|
var halfFocusRing = 1;
|
|
29
29
|
var dropOffset = '0, 8';
|
|
30
30
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -95,16 +95,6 @@ var getEffectiveFullWidth = function getEffectiveFullWidth(containerWidth, fullW
|
|
|
95
95
|
}
|
|
96
96
|
return "".concat((0, _mediaSingle.calcMediaSingleMaxWidth)(containerWidth), "px");
|
|
97
97
|
};
|
|
98
|
-
var calcMaxWidthWhenResizing = function calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode) {
|
|
99
|
-
if (isNestedNode) {
|
|
100
|
-
return '100%';
|
|
101
|
-
}
|
|
102
|
-
// non-nested node can resize up to full width
|
|
103
|
-
return getEffectiveFullWidth(containerWidth, fullWidthMode);
|
|
104
|
-
};
|
|
105
|
-
var calcMaxWidthWhenNotResizing = function calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth) {
|
|
106
|
-
return "".concat(Math.min(mediaSingleWidth, containerWidth - _editorSharedStyles.akEditorGutterPadding * 2), "px");
|
|
107
|
-
};
|
|
108
98
|
function calcMargin(layout) {
|
|
109
99
|
switch (layout) {
|
|
110
100
|
case 'wrap-right':
|
|
@@ -141,7 +131,7 @@ var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref) {
|
|
|
141
131
|
isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
|
|
142
132
|
_ref$isNestedNode = _ref.isNestedNode,
|
|
143
133
|
isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
|
|
144
|
-
return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n
|
|
134
|
+
return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n /* For nested rich media items, set max-width to 100% */\n tr &,\n [data-layout-column] &,\n [data-node-type='expand'] & {\n max-width: 100%;\n }\n\n width: ", ";\n ", "\n max-width: ", ";\n\n ", "\n\n &[class*='not-resizing'] {\n ", "\n }\n\n float: ", ";\n margin: ", ";\n ", ";\n\n &:not(.is-resizing) {\n transition: width 100ms ease-in;\n }\n"])), mediaSingleWidth || pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized), layout === 'full-width' && (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n min-width: 100%;\n "]))), calcMaxWidth(layout, containerWidth), isExtendedResizeExperienceOn && "&[class*='is-resizing'] {\n .new-file-experience-wrapper {\n box-shadow: none !important;\n }\n\n ".concat(!isNestedNode && _utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), !isNestedNode && "".concat(_utils.nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set by ResizerNext inline style\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
|
|
145
135
|
};
|
|
146
136
|
exports.MediaSingleDimensionHelper = MediaSingleDimensionHelper;
|
|
147
137
|
var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
|
|
@@ -21,7 +21,7 @@ var nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
|
21
21
|
exports.nonWrappedLayouts = nonWrappedLayouts;
|
|
22
22
|
var floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
23
23
|
exports.floatingLayouts = floatingLayouts;
|
|
24
|
-
var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
|
|
24
|
+
var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos, includeMoreParentNodeTypes) {
|
|
25
25
|
if (typeof pos !== 'number' || isNaN(pos) || !view) {
|
|
26
26
|
return false;
|
|
27
27
|
}
|
|
@@ -29,8 +29,11 @@ var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, p
|
|
|
29
29
|
var _view$state$schema$no = view.state.schema.nodes,
|
|
30
30
|
expand = _view$state$schema$no.expand,
|
|
31
31
|
nestedExpand = _view$state$schema$no.nestedExpand,
|
|
32
|
-
layoutColumn = _view$state$schema$no.layoutColumn
|
|
33
|
-
|
|
32
|
+
layoutColumn = _view$state$schema$no.layoutColumn,
|
|
33
|
+
tableCell = _view$state$schema$no.tableCell,
|
|
34
|
+
listItem = _view$state$schema$no.listItem;
|
|
35
|
+
var parentNodeTypes = [expand, nestedExpand, layoutColumn];
|
|
36
|
+
return !!(0, _utils.findParentNodeOfTypeClosestToPos)($pos, includeMoreParentNodeTypes ? [].concat(parentNodeTypes, [tableCell, listItem]) : parentNodeTypes);
|
|
34
37
|
};
|
|
35
38
|
exports.isRichMediaInsideOfBlockNode = isRichMediaInsideOfBlockNode;
|
|
36
39
|
var alignAttributes = function alignAttributes(layout, oldAttrs) {
|
package/dist/cjs/version.json
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
|
|
1
|
+
export const MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
|
|
2
|
+
export const INNER_GRID_GUIDELINE_PREFIX = 'grid_';
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
|
|
3
|
+
import { roundToNearest } from '../media-single';
|
|
3
4
|
import { getContainerWidthOrFullEditorWidth } from './utils';
|
|
4
5
|
const getDefaultGuidelines = memoizeOne(editorWidth => {
|
|
5
6
|
return [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6].map((val, index) => ({
|
|
6
7
|
key: `grid_${index}`,
|
|
7
8
|
position: {
|
|
8
|
-
x: val / 12 * editorWidth
|
|
9
|
+
x: roundToNearest(val / 12 * editorWidth)
|
|
9
10
|
}
|
|
10
11
|
}));
|
|
11
12
|
});
|
|
12
13
|
const getWideGuidelines = memoizeOne(editorWidth => {
|
|
13
|
-
const wideSpacing = editorWidth * breakoutWideScaleRatio / 2;
|
|
14
|
+
const wideSpacing = roundToNearest(editorWidth * breakoutWideScaleRatio / 2);
|
|
14
15
|
return [{
|
|
15
16
|
key: `wide_left`,
|
|
16
17
|
position: {
|
|
@@ -24,7 +25,7 @@ const getWideGuidelines = memoizeOne(editorWidth => {
|
|
|
24
25
|
}];
|
|
25
26
|
});
|
|
26
27
|
const getFullWidthGuidelines = memoizeOne(containerWidth => {
|
|
27
|
-
const fullWidth = getContainerWidthOrFullEditorWidth(containerWidth);
|
|
28
|
+
const fullWidth = roundToNearest(getContainerWidthOrFullEditorWidth(containerWidth));
|
|
28
29
|
return [{
|
|
29
30
|
key: `full_width_left`,
|
|
30
31
|
position: {
|
|
@@ -2,6 +2,6 @@ export { generateDynamicGuidelines } from './dynamicGuideline';
|
|
|
2
2
|
export { createFixedGuidelinesFromLengths, createGuidesFromLengths } from './fixedGuideline';
|
|
3
3
|
export { generateDefaultGuidelines } from './defaultGuideline';
|
|
4
4
|
export { getGuidelinesWithHighlights } from './updateGuideline';
|
|
5
|
-
export { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
|
|
6
|
-
export {
|
|
5
|
+
export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX } from './constants';
|
|
6
|
+
export { getGuidelineSnaps, findClosestSnap } from './snapping';
|
|
7
7
|
export { isVerticalPosition, getContainerWidthOrFullEditorWidth } from './utils';
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import
|
|
1
|
+
import memoizeOne from 'memoize-one';
|
|
2
2
|
import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
|
|
3
|
+
import { isVerticalPosition } from './utils';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Returns keys of guidelines that are closest to the image and withthin the snapGap.
|
|
5
7
|
* If both default and dynamic guidelines present, only returns default guidelines
|
|
6
8
|
*/
|
|
7
|
-
export const findClosestSnap = (mediaSingleWidth, snapArray,
|
|
9
|
+
export const findClosestSnap = (mediaSingleWidth, snapArray, guidelineSnaps, snapGap = 0) => {
|
|
8
10
|
const closestGapIndex = snapArray.reduce((prev, curr, index) => Math.abs(curr - mediaSingleWidth) < Math.abs(snapArray[prev] - mediaSingleWidth) ? index : prev, 0);
|
|
9
11
|
const gap = Math.abs(snapArray[closestGapIndex] - mediaSingleWidth);
|
|
10
12
|
if (gap < snapGap) {
|
|
11
|
-
const snappingWidth =
|
|
13
|
+
const snappingWidth = snapArray[closestGapIndex];
|
|
12
14
|
let guidelineKeys = [];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
// find wich guideline have the matching snap width
|
|
16
|
+
guidelineSnaps.forEach(gs => {
|
|
17
|
+
if (gs.width === snappingWidth) {
|
|
18
|
+
guidelineKeys.push(gs.guidelineKey);
|
|
16
19
|
}
|
|
17
20
|
});
|
|
18
21
|
const defaultGuidelineKeys = guidelineKeys.filter(guidelineKey => !guidelineKey.startsWith(MEDIA_DYNAMIC_GUIDELINE_PREFIX));
|
|
@@ -28,33 +31,38 @@ export const findClosestSnap = (mediaSingleWidth, snapArray, snapTo, snapGap = 0
|
|
|
28
31
|
keys: []
|
|
29
32
|
};
|
|
30
33
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
} else if (layout === MediaSingleLayout.ALIGN_END || layout === MediaSingleLayout.WRAP_RIGHT) {
|
|
34
|
+
export const getGuidelineSnaps = memoizeOne((guidelines, editorWidth, layout = 'center') => {
|
|
35
|
+
const offset = editorWidth / 2;
|
|
36
|
+
const getPositionX = position => {
|
|
37
|
+
return isVerticalPosition(position) ? position.x : 0;
|
|
38
|
+
};
|
|
39
|
+
const calcXSnaps = guidelineReference => {
|
|
40
|
+
const snapsWidth = guidelineReference.filter(g => g.width > 0).map(g => g.width);
|
|
41
|
+
const uniqueSnapWidth = [...new Set(snapsWidth)];
|
|
42
|
+
return snapsWidth.length ? uniqueSnapWidth : undefined;
|
|
43
|
+
};
|
|
44
|
+
const guidelinesSnapsReference = guidelines.map(guideline => {
|
|
45
|
+
const positionX = getPositionX(guideline.position);
|
|
46
|
+
if (['align-end', 'wrap-right'].includes(layout)) {
|
|
45
47
|
return {
|
|
46
48
|
guidelineKey: guideline.key,
|
|
47
|
-
width:
|
|
49
|
+
width: offset - positionX
|
|
48
50
|
};
|
|
49
|
-
} else if (
|
|
51
|
+
} else if (['align-start', 'wrap-left'].includes(layout)) {
|
|
50
52
|
return {
|
|
51
53
|
guidelineKey: guideline.key,
|
|
52
|
-
width:
|
|
54
|
+
width: positionX + offset
|
|
53
55
|
};
|
|
54
56
|
}
|
|
55
57
|
return {
|
|
56
|
-
guidelineKey:
|
|
57
|
-
width:
|
|
58
|
+
guidelineKey: guideline.key,
|
|
59
|
+
width: Math.abs(positionX) * 2
|
|
58
60
|
};
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
guidelineReference: guidelinesSnapsReference,
|
|
64
|
+
snaps: {
|
|
65
|
+
x: calcXSnaps(guidelinesSnapsReference)
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React, { Fragment } from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
4
|
import { N400 } from '@atlaskit/theme/colors';
|
|
5
|
+
import { pluginCommandToPMCommand } from '../preset/plugin-commands';
|
|
5
6
|
import { browser } from '../utils';
|
|
6
7
|
export const addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
|
|
7
8
|
export const navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
|
|
@@ -186,15 +187,17 @@ export function makeKeyMapWithCommon(description, common) {
|
|
|
186
187
|
const mac = common.replace(/Mod/i, 'Cmd');
|
|
187
188
|
return makeKeymap(description, windows, mac, common);
|
|
188
189
|
}
|
|
190
|
+
function combineWithOldCommand(cmd, oldCmd) {
|
|
191
|
+
return (state, dispatch, editorView) => {
|
|
192
|
+
return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
|
|
193
|
+
};
|
|
194
|
+
}
|
|
189
195
|
export function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
190
196
|
const oldCmd = keymap[shortcut];
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
keymap[shortcut] = newCmd;
|
|
197
|
+
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
198
|
+
}
|
|
199
|
+
export function bindKeymapWithPluginCommand(shortcut, cmd, keymap) {
|
|
200
|
+
bindKeymapWithCommand(shortcut, pluginCommandToPMCommand(cmd), keymap);
|
|
198
201
|
}
|
|
199
202
|
export function findKeyMapForBrowser(keyMap) {
|
|
200
203
|
if (keyMap) {
|
|
@@ -84,7 +84,7 @@ const calcLegacyWideWidth = (containerWidth, origWidth, contentWidth) => {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
|
-
* Calculate maximum width allowed for media single in new experience
|
|
87
|
+
* Calculate maximum width allowed for media single node in fix-width editor in new experience
|
|
88
88
|
* @param containerWidth width of editor container
|
|
89
89
|
*/
|
|
90
90
|
export const calcMediaSingleMaxWidth = containerWidth => {
|