@atlaskit/editor-common 74.37.0 → 74.38.0
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 +16 -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/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 -1
- 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/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 +8 -7
- 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/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 +2 -1
- 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/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-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/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/package.json +1 -1
|
@@ -7,6 +7,9 @@ function hasGetSharedState(plugin) {
|
|
|
7
7
|
function hasActions(plugin) {
|
|
8
8
|
return typeof plugin.actions === 'object';
|
|
9
9
|
}
|
|
10
|
+
function hasCommands(plugin) {
|
|
11
|
+
return typeof plugin.commands === 'object';
|
|
12
|
+
}
|
|
10
13
|
const filterPluginsWithListeners = ({
|
|
11
14
|
listeners,
|
|
12
15
|
plugins
|
|
@@ -70,6 +73,19 @@ class ActionsAPI {
|
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
}
|
|
76
|
+
class PluginCommandsAPI {
|
|
77
|
+
createAPI(plugin) {
|
|
78
|
+
if (!plugin || !hasCommands(plugin)) {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
return new Proxy(plugin.commands || {}, {
|
|
82
|
+
get: function (target, prop, receiver) {
|
|
83
|
+
// We will be able to track perfomance here
|
|
84
|
+
return Reflect.get(target, prop);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
73
89
|
export class SharedStateAPI {
|
|
74
90
|
constructor({
|
|
75
91
|
getEditorState
|
|
@@ -171,11 +187,13 @@ export class EditorPluginInjectionAPI {
|
|
|
171
187
|
});
|
|
172
188
|
this.plugins = new Map();
|
|
173
189
|
this.actionsAPI = new ActionsAPI();
|
|
190
|
+
this.commandsAPI = new PluginCommandsAPI();
|
|
174
191
|
}
|
|
175
192
|
api() {
|
|
176
193
|
const {
|
|
177
194
|
sharedStateAPI,
|
|
178
195
|
actionsAPI,
|
|
196
|
+
commandsAPI,
|
|
179
197
|
getPluginByName
|
|
180
198
|
} = this;
|
|
181
199
|
const dependencies = new Proxy({}, {
|
|
@@ -195,9 +213,11 @@ export class EditorPluginInjectionAPI {
|
|
|
195
213
|
}
|
|
196
214
|
const sharedState = sharedStateAPI.createAPI(plugin);
|
|
197
215
|
const actions = actionsAPI.createAPI(plugin);
|
|
216
|
+
const commands = commandsAPI.createAPI(plugin);
|
|
198
217
|
const proxyCoreAPI = {
|
|
199
218
|
sharedState,
|
|
200
|
-
actions
|
|
219
|
+
actions,
|
|
220
|
+
commands
|
|
201
221
|
};
|
|
202
222
|
return proxyCoreAPI;
|
|
203
223
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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.
|
|
11
|
+
const packageVersion = "74.38.0";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
+
|
|
2
3
|
import React from 'react';
|
|
3
4
|
import { css, jsx } from '@emotion/react';
|
|
4
5
|
import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
|
|
@@ -134,16 +135,16 @@ export const MediaSingleDimensionHelper = ({
|
|
|
134
135
|
min-width: 100%;
|
|
135
136
|
`}
|
|
136
137
|
max-width: ${calcMaxWidth(layout, containerWidth)};
|
|
137
|
-
|
|
138
|
-
|
|
138
|
+
${isExtendedResizeExperienceOn && `&[class*='is-resizing'] {
|
|
139
|
+
.new-file-experience-wrapper {
|
|
140
|
+
box-shadow: none !important;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
max-width: ${calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode)};
|
|
139
144
|
|
|
140
145
|
${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
|
|
141
146
|
transform: translateX(-50%);`}
|
|
142
|
-
|
|
143
|
-
.new-file-experience-wrapper {
|
|
144
|
-
box-shadow: none;
|
|
145
|
-
}`}
|
|
146
|
-
}
|
|
147
|
+
}`}
|
|
147
148
|
|
|
148
149
|
/* Handles responsiveness of non-nested, not-resizing nodes in editor */
|
|
149
150
|
&[class*='not-resizing'] {
|
package/dist/es2019/version.json
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export var MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
|
|
1
|
+
export var MEDIA_DYNAMIC_GUIDELINE_PREFIX = 'media_';
|
|
2
|
+
export var INNER_GRID_GUIDELINE_PREFIX = 'grid_';
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import memoizeOne from 'memoize-one';
|
|
3
3
|
import { breakoutWideScaleRatio } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { roundToNearest } from '../media-single';
|
|
4
5
|
import { getContainerWidthOrFullEditorWidth } from './utils';
|
|
5
6
|
var getDefaultGuidelines = memoizeOne(function (editorWidth) {
|
|
6
7
|
return [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6].map(function (val, index) {
|
|
7
8
|
return {
|
|
8
9
|
key: "grid_".concat(index),
|
|
9
10
|
position: {
|
|
10
|
-
x: val / 12 * editorWidth
|
|
11
|
+
x: roundToNearest(val / 12 * editorWidth)
|
|
11
12
|
}
|
|
12
13
|
};
|
|
13
14
|
});
|
|
14
15
|
});
|
|
15
16
|
var getWideGuidelines = memoizeOne(function (editorWidth) {
|
|
16
|
-
var wideSpacing = editorWidth * breakoutWideScaleRatio / 2;
|
|
17
|
+
var wideSpacing = roundToNearest(editorWidth * breakoutWideScaleRatio / 2);
|
|
17
18
|
return [{
|
|
18
19
|
key: "wide_left",
|
|
19
20
|
position: {
|
|
@@ -27,7 +28,7 @@ var getWideGuidelines = memoizeOne(function (editorWidth) {
|
|
|
27
28
|
}];
|
|
28
29
|
});
|
|
29
30
|
var getFullWidthGuidelines = memoizeOne(function (containerWidth) {
|
|
30
|
-
var fullWidth = getContainerWidthOrFullEditorWidth(containerWidth);
|
|
31
|
+
var fullWidth = roundToNearest(getContainerWidthOrFullEditorWidth(containerWidth));
|
|
31
32
|
return [{
|
|
32
33
|
key: "full_width_left",
|
|
33
34
|
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,21 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import memoizeOne from 'memoize-one';
|
|
2
3
|
import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
|
|
4
|
+
import { isVerticalPosition } from './utils';
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Returns keys of guidelines that are closest to the image and withthin the snapGap.
|
|
5
8
|
* If both default and dynamic guidelines present, only returns default guidelines
|
|
6
9
|
*/
|
|
7
|
-
export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray,
|
|
10
|
+
export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArray, guidelineSnaps) {
|
|
8
11
|
var snapGap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
9
12
|
var closestGapIndex = snapArray.reduce(function (prev, curr, index) {
|
|
10
13
|
return Math.abs(curr - mediaSingleWidth) < Math.abs(snapArray[prev] - mediaSingleWidth) ? index : prev;
|
|
11
14
|
}, 0);
|
|
12
15
|
var gap = Math.abs(snapArray[closestGapIndex] - mediaSingleWidth);
|
|
13
16
|
if (gap < snapGap) {
|
|
14
|
-
var snappingWidth =
|
|
17
|
+
var snappingWidth = snapArray[closestGapIndex];
|
|
15
18
|
var guidelineKeys = [];
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
// find wich guideline have the matching snap width
|
|
20
|
+
guidelineSnaps.forEach(function (gs) {
|
|
21
|
+
if (gs.width === snappingWidth) {
|
|
22
|
+
guidelineKeys.push(gs.guidelineKey);
|
|
19
23
|
}
|
|
20
24
|
});
|
|
21
25
|
var defaultGuidelineKeys = guidelineKeys.filter(function (guidelineKey) {
|
|
@@ -33,35 +37,43 @@ export var findClosestSnap = function findClosestSnap(mediaSingleWidth, snapArra
|
|
|
33
37
|
keys: []
|
|
34
38
|
};
|
|
35
39
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
export var getGuidelineSnaps = memoizeOne(function (guidelines, editorWidth) {
|
|
41
|
+
var layout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'center';
|
|
42
|
+
var offset = editorWidth / 2;
|
|
43
|
+
var getPositionX = function getPositionX(position) {
|
|
44
|
+
return isVerticalPosition(position) ? position.x : 0;
|
|
45
|
+
};
|
|
46
|
+
var calcXSnaps = function calcXSnaps(guidelineReference) {
|
|
47
|
+
var snapsWidth = guidelineReference.filter(function (g) {
|
|
48
|
+
return g.width > 0;
|
|
49
|
+
}).map(function (g) {
|
|
50
|
+
return g.width;
|
|
51
|
+
});
|
|
52
|
+
var uniqueSnapWidth = _toConsumableArray(new Set(snapsWidth));
|
|
53
|
+
return snapsWidth.length ? uniqueSnapWidth : undefined;
|
|
54
|
+
};
|
|
55
|
+
var guidelinesSnapsReference = guidelines.map(function (guideline) {
|
|
56
|
+
var positionX = getPositionX(guideline.position);
|
|
57
|
+
if (['align-end', 'wrap-right'].includes(layout)) {
|
|
50
58
|
return {
|
|
51
59
|
guidelineKey: guideline.key,
|
|
52
|
-
width:
|
|
60
|
+
width: offset - positionX
|
|
53
61
|
};
|
|
54
|
-
} else if (
|
|
62
|
+
} else if (['align-start', 'wrap-left'].includes(layout)) {
|
|
55
63
|
return {
|
|
56
64
|
guidelineKey: guideline.key,
|
|
57
|
-
width:
|
|
65
|
+
width: positionX + offset
|
|
58
66
|
};
|
|
59
67
|
}
|
|
60
68
|
return {
|
|
61
|
-
guidelineKey:
|
|
62
|
-
width:
|
|
69
|
+
guidelineKey: guideline.key,
|
|
70
|
+
width: Math.abs(positionX) * 2
|
|
63
71
|
};
|
|
64
|
-
}).filter(function (guideline) {
|
|
65
|
-
return guideline.guidelineKey !== '';
|
|
66
72
|
});
|
|
67
|
-
|
|
73
|
+
return {
|
|
74
|
+
guidelineReference: guidelinesSnapsReference,
|
|
75
|
+
snaps: {
|
|
76
|
+
x: calcXSnaps(guidelinesSnapsReference)
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
});
|
|
@@ -5,6 +5,7 @@ var _templateObject;
|
|
|
5
5
|
import React, { Fragment } from 'react';
|
|
6
6
|
import { css, jsx } from '@emotion/react';
|
|
7
7
|
import { N400 } from '@atlaskit/theme/colors';
|
|
8
|
+
import { pluginCommandToPMCommand } from '../preset/plugin-commands';
|
|
8
9
|
import { browser } from '../utils';
|
|
9
10
|
export var addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
|
|
10
11
|
export var navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
|
|
@@ -182,15 +183,17 @@ export function makeKeyMapWithCommon(description, common) {
|
|
|
182
183
|
var mac = common.replace(/Mod/i, 'Cmd');
|
|
183
184
|
return makeKeymap(description, windows, mac, common);
|
|
184
185
|
}
|
|
186
|
+
function combineWithOldCommand(cmd, oldCmd) {
|
|
187
|
+
return function (state, dispatch, editorView) {
|
|
188
|
+
return oldCmd(state, dispatch) || cmd(state, dispatch, editorView);
|
|
189
|
+
};
|
|
190
|
+
}
|
|
185
191
|
export function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
186
192
|
var oldCmd = keymap[shortcut];
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
keymap[shortcut] = newCmd;
|
|
193
|
+
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
194
|
+
}
|
|
195
|
+
export function bindKeymapWithPluginCommand(shortcut, cmd, keymap) {
|
|
196
|
+
bindKeymapWithCommand(shortcut, pluginCommandToPMCommand(cmd), keymap);
|
|
194
197
|
}
|
|
195
198
|
export function findKeyMapForBrowser(keyMap) {
|
|
196
199
|
if (keyMap) {
|
|
@@ -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.
|
|
9
|
+
var packageVersion = "74.38.0";
|
|
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
|
package/dist/esm/preset/index.js
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function pluginCommandToPMCommand(command) {
|
|
2
|
+
return function (_ref, dispatch) {
|
|
3
|
+
var tr = _ref.tr;
|
|
4
|
+
var newTr = command === null || command === void 0 ? void 0 : command({
|
|
5
|
+
tr: tr
|
|
6
|
+
});
|
|
7
|
+
if (newTr) {
|
|
8
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(newTr);
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
return false;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -15,6 +15,9 @@ function hasGetSharedState(plugin) {
|
|
|
15
15
|
function hasActions(plugin) {
|
|
16
16
|
return _typeof(plugin.actions) === 'object';
|
|
17
17
|
}
|
|
18
|
+
function hasCommands(plugin) {
|
|
19
|
+
return _typeof(plugin.commands) === 'object';
|
|
20
|
+
}
|
|
18
21
|
var filterPluginsWithListeners = function filterPluginsWithListeners(_ref) {
|
|
19
22
|
var listeners = _ref.listeners,
|
|
20
23
|
plugins = _ref.plugins;
|
|
@@ -113,6 +116,26 @@ var ActionsAPI = /*#__PURE__*/function () {
|
|
|
113
116
|
}]);
|
|
114
117
|
return ActionsAPI;
|
|
115
118
|
}();
|
|
119
|
+
var PluginCommandsAPI = /*#__PURE__*/function () {
|
|
120
|
+
function PluginCommandsAPI() {
|
|
121
|
+
_classCallCheck(this, PluginCommandsAPI);
|
|
122
|
+
}
|
|
123
|
+
_createClass(PluginCommandsAPI, [{
|
|
124
|
+
key: "createAPI",
|
|
125
|
+
value: function createAPI(plugin) {
|
|
126
|
+
if (!plugin || !hasCommands(plugin)) {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
return new Proxy(plugin.commands || {}, {
|
|
130
|
+
get: function get(target, prop, receiver) {
|
|
131
|
+
// We will be able to track perfomance here
|
|
132
|
+
return Reflect.get(target, prop);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}]);
|
|
137
|
+
return PluginCommandsAPI;
|
|
138
|
+
}();
|
|
116
139
|
export var SharedStateAPI = /*#__PURE__*/function () {
|
|
117
140
|
function SharedStateAPI(_ref4) {
|
|
118
141
|
var getEditorState = _ref4.getEditorState;
|
|
@@ -237,12 +260,14 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
237
260
|
});
|
|
238
261
|
this.plugins = new Map();
|
|
239
262
|
this.actionsAPI = new ActionsAPI();
|
|
263
|
+
this.commandsAPI = new PluginCommandsAPI();
|
|
240
264
|
}
|
|
241
265
|
_createClass(EditorPluginInjectionAPI, [{
|
|
242
266
|
key: "api",
|
|
243
267
|
value: function api() {
|
|
244
268
|
var sharedStateAPI = this.sharedStateAPI,
|
|
245
269
|
actionsAPI = this.actionsAPI,
|
|
270
|
+
commandsAPI = this.commandsAPI,
|
|
246
271
|
getPluginByName = this.getPluginByName;
|
|
247
272
|
var dependencies = new Proxy({}, {
|
|
248
273
|
get: function get(target, prop, receiver) {
|
|
@@ -261,9 +286,11 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
261
286
|
}
|
|
262
287
|
var sharedState = sharedStateAPI.createAPI(plugin);
|
|
263
288
|
var actions = actionsAPI.createAPI(plugin);
|
|
289
|
+
var commands = commandsAPI.createAPI(plugin);
|
|
264
290
|
var proxyCoreAPI = {
|
|
265
291
|
sharedState: sharedState,
|
|
266
|
-
actions: actions
|
|
292
|
+
actions: actions,
|
|
293
|
+
commands: commands
|
|
267
294
|
};
|
|
268
295
|
return proxyCoreAPI;
|
|
269
296
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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.
|
|
21
|
+
var packageVersion = "74.38.0";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = '0, 8';
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -3,6 +3,7 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
|
|
|
3
3
|
var _excluded = ["children"];
|
|
4
4
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
5
5
|
/** @jsx jsx */
|
|
6
|
+
|
|
6
7
|
import React from 'react';
|
|
7
8
|
import { css, jsx } from '@emotion/react';
|
|
8
9
|
import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
|
|
@@ -131,7 +132,7 @@ export var MediaSingleDimensionHelper = function MediaSingleDimensionHelper(_ref
|
|
|
131
132
|
isExtendedResizeExperienceOn = _ref.isExtendedResizeExperienceOn,
|
|
132
133
|
_ref$isNestedNode = _ref.isNestedNode,
|
|
133
134
|
isNestedNode = _ref$isNestedNode === void 0 ? false : _ref$isNestedNode;
|
|
134
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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
|
|
135
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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 /* Handles responsiveness of non-nested, not-resizing nodes in editor */\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' && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\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 max-width: ".concat(calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n }"), !isNestedNode && "max-width: ".concat(layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth), ";\n\n ").concat(nonWrappedLayouts.includes(layout) && "margin-left: 50%;\n transform: translateX(-50%);", "\n\n // override min-width to counteract max-width set in old experience\n ").concat(layout === 'full-width' && "min-width: ".concat(getEffectiveFullWidth(containerWidth, fullWidthMode), " !important;"), ";"), float(layout), calcMargin(layout), isImageAligned(layout));
|
|
135
136
|
};
|
|
136
137
|
var RenderFallbackContainer = function RenderFallbackContainer(_ref2) {
|
|
137
138
|
var hasFallbackContainer = _ref2.hasFallbackContainer,
|
package/dist/esm/version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { GuidelineConfig } from './types';
|
|
3
3
|
export declare const generateDynamicGuidelines: (state: EditorState, editorWidth: number, styles?: Omit<GuidelineConfig, 'key' | 'position'>) => ({
|
|
4
4
|
styles?: {
|
|
@@ -2,7 +2,7 @@ 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 type { WidthTypes, Position, GuidelineConfig, GuidelinePluginState, GuidelinePluginOptions, DisplayGuideline, DisplayGrid, VerticalPosition, HorizontalPosition, } from './types';
|
|
7
|
-
export {
|
|
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, } from './types';
|
|
7
|
+
export { getGuidelineSnaps, findClosestSnap } from './snapping';
|
|
8
8
|
export { isVerticalPosition, getContainerWidthOrFullEditorWidth, } from './utils';
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
|
-
import type { GuidelineConfig } from './types';
|
|
3
|
-
export type SnapTo = {
|
|
4
|
-
guidelineKey: string;
|
|
5
|
-
width: number;
|
|
6
|
-
};
|
|
1
|
+
import type { RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
|
+
import type { GuidelineConfig, GuidelineSnap } from './types';
|
|
7
3
|
/**
|
|
8
4
|
* Returns keys of guidelines that are closest to the image and withthin the snapGap.
|
|
9
5
|
* If both default and dynamic guidelines present, only returns default guidelines
|
|
10
6
|
*/
|
|
11
|
-
export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[],
|
|
7
|
+
export declare const findClosestSnap: (mediaSingleWidth: number, snapArray: number[], guidelineSnaps: GuidelineSnap[], snapGap?: number) => {
|
|
12
8
|
gap: number;
|
|
13
9
|
keys: string[];
|
|
14
10
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
export declare const getGuidelineSnaps: import("memoize-one").MemoizedFn<(guidelines: GuidelineConfig[], editorWidth: number, layout?: RichMediaLayout) => {
|
|
12
|
+
guidelineReference: {
|
|
13
|
+
guidelineKey: string;
|
|
14
|
+
width: number;
|
|
15
|
+
}[];
|
|
16
|
+
snaps: {
|
|
17
|
+
x: number[] | undefined;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
-
import { CSSToken } from '@atlaskit/tokens';
|
|
1
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
2
|
+
import type { CSSToken } from '@atlaskit/tokens';
|
|
3
3
|
export declare enum WidthTypes {
|
|
4
4
|
PERCENTAGE = "percentage",
|
|
5
5
|
PIXEL = "pixel"
|
|
@@ -40,3 +40,14 @@ export interface GuidelinePluginOptions {
|
|
|
40
40
|
}
|
|
41
41
|
export type DisplayGrid = (props: Required<GuidelinePluginState>) => boolean;
|
|
42
42
|
export type DisplayGuideline = (view: EditorView) => DisplayGrid;
|
|
43
|
+
export type GuidelineSnap = {
|
|
44
|
+
guidelineKey: string;
|
|
45
|
+
width: number;
|
|
46
|
+
};
|
|
47
|
+
export type GuidelineSnapsReference = {
|
|
48
|
+
snaps: {
|
|
49
|
+
x?: number[];
|
|
50
|
+
y?: number[];
|
|
51
|
+
};
|
|
52
|
+
guidelineReference: GuidelineSnap[];
|
|
53
|
+
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
4
|
import type { Command } from '../types/command';
|
|
5
|
+
import type { PluginCommand } from '../types/plugin-command';
|
|
5
6
|
export declare const addAltText: Keymap;
|
|
6
7
|
export declare const navToEditorToolbar: Keymap;
|
|
7
8
|
export declare const navToFloatingToolbar: Keymap;
|
|
@@ -85,7 +86,10 @@ export interface Keymap {
|
|
|
85
86
|
common?: string;
|
|
86
87
|
}
|
|
87
88
|
export declare function bindKeymapWithCommand(shortcut: string, cmd: Command, keymap: {
|
|
88
|
-
[key: string]:
|
|
89
|
+
[key: string]: Command;
|
|
90
|
+
}): void;
|
|
91
|
+
export declare function bindKeymapWithPluginCommand(shortcut: string, cmd: PluginCommand, keymap: {
|
|
92
|
+
[key: string]: Command;
|
|
89
93
|
}): void;
|
|
90
94
|
export declare function findKeyMapForBrowser(keyMap: Keymap): string | undefined;
|
|
91
95
|
export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP, } from './consts';
|
|
@@ -32,6 +32,7 @@ interface PluginInjectionAPIDefinition {
|
|
|
32
32
|
export declare class EditorPluginInjectionAPI implements PluginInjectionAPIDefinition {
|
|
33
33
|
private sharedStateAPI;
|
|
34
34
|
private actionsAPI;
|
|
35
|
+
private commandsAPI;
|
|
35
36
|
private plugins;
|
|
36
37
|
constructor({ getEditorState }: SharedStateAPIProps);
|
|
37
38
|
api<T extends NextEditorPlugin<any, any>>(): {
|
|
@@ -29,6 +29,7 @@ export type { PMPluginFactoryParams, PMPluginFactory, PMPlugin, } from './plugin
|
|
|
29
29
|
export type { NodeConfig, MarkConfig, NodeViewConfig, } from './prosemirror-config';
|
|
30
30
|
export type { PluginsOptions, EditorPlugin, getPosHandler, getPosHandlerNode, } from './editor-plugin';
|
|
31
31
|
export type { NextEditorPlugin, AllEditorPresetPluginTypes, PluginDependenciesAPI, ExtractPluginNameFromAllBuilderPlugins, SafePresetCheck, DefaultEditorPlugin, OptionalPlugin, PluginInjectionAPI, CreatePluginDependenciesAPI, NextEditorPluginMetadata, ExtractInjectionAPI, ExtractPluginActions, PluginInjectionAPIWithDependency, PluginInjectionAPIWithDependencies, } from './next-editor-plugin';
|
|
32
|
+
export type { PluginCommand, PluginCommandWithMetadata, } from './plugin-command';
|
|
32
33
|
export type IconProps = {
|
|
33
34
|
label?: string;
|
|
34
35
|
};
|
|
@@ -6,25 +6,32 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import type { EditorPlugin } from './editor-plugin';
|
|
9
|
+
import type { PluginCommand, PluginCommandWithMetadata } from './plugin-command';
|
|
9
10
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
10
11
|
type PickSharedStatePropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractSharedStateFromMetadata<Metadata> extends never ? never : 'getSharedState';
|
|
11
12
|
type WithSharedState<Metadata extends NextEditorPluginMetadata> = {
|
|
12
13
|
[Property in keyof Pick<Metadata, 'sharedState'> as PickSharedStatePropertyName<Metadata>]: (editorState: EditorState | undefined) => ExtractSharedStateFromMetadata<Metadata>;
|
|
13
14
|
};
|
|
14
15
|
type PickActionsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractActionsFromMetadata<Metadata> extends never ? never : 'actions';
|
|
16
|
+
type PickCommandsPropertyName<Metadata extends NextEditorPluginMetadata> = IsAny<Metadata> extends true ? never : ExtractCommandsFromMetadata<Metadata> extends never ? never : 'commands';
|
|
15
17
|
type WithActions<Metadata extends NextEditorPluginMetadata> = {
|
|
16
18
|
[Property in keyof Pick<Metadata, 'actions'> as PickActionsPropertyName<Metadata>]: ExtractActionsFromMetadata<Metadata>;
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
type WithCommands<Metadata extends NextEditorPluginMetadata> = {
|
|
21
|
+
[Property in keyof Pick<Metadata, 'commands'> as PickCommandsPropertyName<Metadata>]: ExtractCommandsFromMetadata<Metadata>;
|
|
22
|
+
};
|
|
23
|
+
export type DefaultEditorPlugin<Name extends string, Metadata extends NextEditorPluginMetadata> = EditorPlugin & WithSharedState<Metadata> & WithActions<Metadata> & WithCommands<Metadata> & {
|
|
19
24
|
name: Name;
|
|
20
25
|
};
|
|
21
26
|
type MaybeAction = ((...agrs: any) => any) | ((...agrs: any) => void);
|
|
22
27
|
type NextEditorPluginActions = Record<string, MaybeAction>;
|
|
28
|
+
type NextEditorPluginCommands = Record<string, PluginCommandWithMetadata | PluginCommand>;
|
|
23
29
|
export interface NextEditorPluginMetadata {
|
|
24
30
|
readonly sharedState?: any;
|
|
25
31
|
readonly pluginConfiguration?: any;
|
|
26
32
|
readonly dependencies?: DependencyPlugin[];
|
|
27
33
|
readonly actions?: NextEditorPluginActions;
|
|
34
|
+
readonly commands?: NextEditorPluginCommands;
|
|
28
35
|
}
|
|
29
36
|
export type PluginInjectionAPI<Name extends string, Metadata extends NextEditorPluginMetadata> = {
|
|
30
37
|
dependencies: CreatePluginDependenciesAPI<[
|
|
@@ -56,6 +63,7 @@ type ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata extends Next
|
|
|
56
63
|
type ExtractPluginDependenciesFromMetadata<Metadata> = 'dependencies' extends keyof Metadata ? Metadata['dependencies'] extends DependencyPlugin[] ? Exclude<Metadata['dependencies'], undefined> : [] : [];
|
|
57
64
|
type ExtractSharedStateFromMetadata<Metadata> = 'sharedState' extends keyof Metadata ? Metadata['sharedState'] : never;
|
|
58
65
|
type ExtractActionsFromMetadata<Metadata> = 'actions' extends keyof Metadata ? Metadata['actions'] : never;
|
|
66
|
+
type ExtractCommandsFromMetadata<Metadata> = 'commands' extends keyof Metadata ? Metadata['commands'] : never;
|
|
59
67
|
type ExtractPluginConfigurationFromMetadata<Metadata> = 'pluginConfiguration' extends keyof Metadata ? Metadata['pluginConfiguration'] : never;
|
|
60
68
|
export type ExtractPluginDependencies<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginDependenciesFromMetadataWithoutOptionals<Metadata> : never : never;
|
|
61
69
|
type ExtractPluginConfiguration<Plugin> = Plugin extends NextEditorPlugin<any, any> ? Plugin extends (config: any, api: any) => DefaultEditorPlugin<any, infer Metadata> ? ExtractPluginConfigurationFromMetadata<Metadata> : never : never;
|
|
@@ -72,6 +80,7 @@ export type PluginDependenciesAPI<Plugin extends NextEditorPlugin<any, any>> = {
|
|
|
72
80
|
}) => void) => Unsubscribe;
|
|
73
81
|
};
|
|
74
82
|
actions: ExtractPluginActions<Plugin>;
|
|
83
|
+
commands: Plugin extends NextEditorPlugin<any, infer Metadata> ? ExtractCommandsFromMetadata<Metadata> : never;
|
|
75
84
|
};
|
|
76
85
|
export type CreatePluginDependenciesAPI<PluginList extends NextEditorPlugin<any, any>[]> = {
|
|
77
86
|
[Plugin in PluginList[number] as `${ExtractPluginName<Plugin>}`]: Plugin extends OptionalPlugin<NextEditorPlugin<any, any>> ? PluginDependenciesAPI<Plugin> | undefined : Plugin extends NextEditorPlugin<any, any> ? PluginDependenciesAPI<Plugin> : never;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
type PluginCommandProps = {
|
|
3
|
+
tr: Transaction;
|
|
4
|
+
};
|
|
5
|
+
export type PluginCommand = (props: PluginCommandProps) => Transaction | null;
|
|
6
|
+
export type PluginCommandWithMetadata = (args: any) => PluginCommand;
|
|
7
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import
|
|
2
|
+
import type { RefObject } from 'react';
|
|
3
|
+
import React from 'react';
|
|
3
4
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
5
|
+
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
5
6
|
/**
|
|
6
7
|
* Calculates the image width for non-resized images.
|
|
7
8
|
*
|