@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
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { roundToNearest } from '../media-single';
|
|
2
|
+
import { getMediaSingleDimensions } from './utils';
|
|
3
|
+
const RELATIVE_GUIDES_GAP = 6;
|
|
4
|
+
const getWidthRelativeGuideline = (key, view, nodeWithPos, editorWidth, size) => {
|
|
5
|
+
const {
|
|
6
|
+
node,
|
|
7
|
+
pos
|
|
8
|
+
} = nodeWithPos;
|
|
9
|
+
const {
|
|
10
|
+
top: topOffSet,
|
|
11
|
+
height: viewHeight
|
|
12
|
+
} = view.dom.getBoundingClientRect();
|
|
13
|
+
const {
|
|
14
|
+
top
|
|
15
|
+
} = view.coordsAtPos(pos + 1); // media node
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
width,
|
|
19
|
+
height
|
|
20
|
+
} = size || getMediaSingleDimensions(node, editorWidth) || {};
|
|
21
|
+
const y = top - topOffSet - RELATIVE_GUIDES_GAP;
|
|
22
|
+
if (!width || !height || y < 0 || y > viewHeight) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
let start = 0;
|
|
26
|
+
let end = 0;
|
|
27
|
+
switch (node.attrs.layout) {
|
|
28
|
+
case 'align-start':
|
|
29
|
+
case 'wrap-left':
|
|
30
|
+
start = -editorWidth / 2;
|
|
31
|
+
end = start + width;
|
|
32
|
+
break;
|
|
33
|
+
case 'align-end':
|
|
34
|
+
case 'wrap-right':
|
|
35
|
+
end = editorWidth / 2;
|
|
36
|
+
start = end - width;
|
|
37
|
+
break;
|
|
38
|
+
case 'center':
|
|
39
|
+
case 'wide':
|
|
40
|
+
case 'full-width':
|
|
41
|
+
end = width / 2;
|
|
42
|
+
start = -end;
|
|
43
|
+
break;
|
|
44
|
+
default:
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
key,
|
|
48
|
+
position: {
|
|
49
|
+
y,
|
|
50
|
+
x: {
|
|
51
|
+
start,
|
|
52
|
+
end
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
active: true,
|
|
56
|
+
styles: {
|
|
57
|
+
lineStyle: 'dashed',
|
|
58
|
+
capStyle: 'line'
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
const getHeightRelativeGuideline = (key, view, nodeWithPos, editorWidth, size) => {
|
|
63
|
+
const {
|
|
64
|
+
node,
|
|
65
|
+
pos
|
|
66
|
+
} = nodeWithPos;
|
|
67
|
+
const {
|
|
68
|
+
top: topOffSet,
|
|
69
|
+
height: viewHeight
|
|
70
|
+
} = view.dom.getBoundingClientRect();
|
|
71
|
+
const {
|
|
72
|
+
top
|
|
73
|
+
} = view.coordsAtPos(pos + 1); // media node
|
|
74
|
+
|
|
75
|
+
const {
|
|
76
|
+
width,
|
|
77
|
+
height
|
|
78
|
+
} = size || getMediaSingleDimensions(node, editorWidth) || {};
|
|
79
|
+
if (!width || !height) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const start = top - topOffSet;
|
|
83
|
+
const end = start + height;
|
|
84
|
+
if (end < 0 || start > viewHeight) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
let x = 0;
|
|
88
|
+
const halfWidth = editorWidth / 2;
|
|
89
|
+
switch (node.attrs.layout) {
|
|
90
|
+
case 'align-start':
|
|
91
|
+
case 'wrap-left':
|
|
92
|
+
x = width - halfWidth;
|
|
93
|
+
break;
|
|
94
|
+
case 'align-end':
|
|
95
|
+
case 'wrap-right':
|
|
96
|
+
x = halfWidth;
|
|
97
|
+
break;
|
|
98
|
+
case 'center':
|
|
99
|
+
case 'wide':
|
|
100
|
+
case 'full-width':
|
|
101
|
+
x = width / 2;
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
x = 0;
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
key,
|
|
108
|
+
position: {
|
|
109
|
+
x: x + RELATIVE_GUIDES_GAP,
|
|
110
|
+
y: {
|
|
111
|
+
start,
|
|
112
|
+
end
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
active: true,
|
|
116
|
+
styles: {
|
|
117
|
+
lineStyle: 'dashed',
|
|
118
|
+
capStyle: 'line'
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
export const getRelativeGuideSnaps = (relativeGuides, aspectRatio) => {
|
|
123
|
+
const snapsWidthFromMatchingHeight = Object.keys(relativeGuides.height || {}).map(heightKey => {
|
|
124
|
+
const height = Number.parseInt(heightKey);
|
|
125
|
+
return roundToNearest(height * aspectRatio);
|
|
126
|
+
});
|
|
127
|
+
const snapsWidthFromMatchingWidth = Object.keys(relativeGuides.width || {}).map(widthKey => {
|
|
128
|
+
return Number.parseInt(widthKey);
|
|
129
|
+
});
|
|
130
|
+
return [...snapsWidthFromMatchingWidth, ...snapsWidthFromMatchingHeight];
|
|
131
|
+
};
|
|
132
|
+
export const getRelativeGuidelines = (relativeGuides, nodeWithPos, view, editorWidth, size) => {
|
|
133
|
+
const matchWidth = relativeGuides.width ? relativeGuides.width[Math.round(size.width)] : [];
|
|
134
|
+
const matchHeight = relativeGuides.height ? relativeGuides.height[Math.round(size.height)] : [];
|
|
135
|
+
const matches = matchWidth || matchHeight;
|
|
136
|
+
const getRelativeGuideline = matchWidth && getWidthRelativeGuideline || matchHeight && getHeightRelativeGuideline || null;
|
|
137
|
+
if (matches && getRelativeGuideline) {
|
|
138
|
+
return [getRelativeGuideline('relative_guide_current', view, nodeWithPos, editorWidth, size), ...matches.map((nodeWithPos, index) => {
|
|
139
|
+
return getRelativeGuideline(`relative_guide_${index}`, view, nodeWithPos, editorWidth);
|
|
140
|
+
})].filter(config => !!config);
|
|
141
|
+
}
|
|
142
|
+
return [];
|
|
143
|
+
};
|
|
@@ -2,7 +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 {
|
|
5
|
+
import { editorCommandToPMCommand } from '../preset/editor-commands';
|
|
6
6
|
import { browser } from '../utils';
|
|
7
7
|
export const addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
|
|
8
8
|
export const navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
|
|
@@ -196,8 +196,8 @@ export function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
|
196
196
|
const oldCmd = keymap[shortcut];
|
|
197
197
|
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
198
198
|
}
|
|
199
|
-
export function
|
|
200
|
-
bindKeymapWithCommand(shortcut,
|
|
199
|
+
export function bindKeymapWithEditorCommand(shortcut, cmd, keymap) {
|
|
200
|
+
bindKeymapWithCommand(shortcut, editorCommandToPMCommand(cmd), keymap);
|
|
201
201
|
}
|
|
202
202
|
export function findKeyMapForBrowser(keyMap) {
|
|
203
203
|
if (keyMap) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
2
2
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
3
|
-
const packageVersion = "74.
|
|
3
|
+
const packageVersion = "74.46.1";
|
|
4
4
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
5
5
|
// Remove URL as it has UGC
|
|
6
6
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convert a
|
|
3
|
-
* The preferred approach to dispatching a `
|
|
2
|
+
* Convert a EditorCommand to a standard Prosemirror Command.
|
|
3
|
+
* The preferred approach to dispatching a `EditorCommand` is via the
|
|
4
4
|
* `executeCommand` on `pluginInjectionAPI`. In some cases
|
|
5
5
|
* the type may require a Command until we refactor this out and this
|
|
6
6
|
* function is suitable for those cases.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param command A plugin command (a function that modifies and returns a `Transaction`)
|
|
9
9
|
* @returns Command
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function editorCommandToPMCommand(command) {
|
|
12
12
|
return ({
|
|
13
13
|
tr
|
|
14
14
|
}, dispatch) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import isEqual from 'lodash/isEqual';
|
|
3
3
|
import throttle from 'lodash/throttle';
|
|
4
|
-
import {
|
|
4
|
+
import { editorCommandToPMCommand } from './editor-commands';
|
|
5
5
|
function hasGetSharedState(plugin) {
|
|
6
6
|
return typeof plugin.getSharedState === 'function';
|
|
7
7
|
}
|
|
@@ -74,7 +74,7 @@ class ActionsAPI {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
class
|
|
77
|
+
class EditorCommandsAPI {
|
|
78
78
|
createAPI(plugin) {
|
|
79
79
|
if (!plugin || !hasCommands(plugin)) {
|
|
80
80
|
return {};
|
|
@@ -189,7 +189,7 @@ export class EditorPluginInjectionAPI {
|
|
|
189
189
|
});
|
|
190
190
|
this.plugins = new Map();
|
|
191
191
|
this.actionsAPI = new ActionsAPI();
|
|
192
|
-
this.commandsAPI = new
|
|
192
|
+
this.commandsAPI = new EditorCommandsAPI();
|
|
193
193
|
this.getEditorView = getEditorView;
|
|
194
194
|
}
|
|
195
195
|
api() {
|
|
@@ -239,6 +239,6 @@ export class EditorPluginInjectionAPI {
|
|
|
239
239
|
state,
|
|
240
240
|
dispatch
|
|
241
241
|
} = editorView;
|
|
242
|
-
return
|
|
242
|
+
return editorCommandToPMCommand(command)(state, dispatch);
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -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.46.1";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -1,62 +1,90 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
import { findChildren } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import {
|
|
7
|
+
import { roundToNearest } from '../media-single';
|
|
7
8
|
import { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
|
|
9
|
+
import { getMediaSingleDimensions } from './utils';
|
|
8
10
|
export var generateDynamicGuidelines = function generateDynamicGuidelines(state, editorWidth) {
|
|
9
11
|
var styles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
10
12
|
var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
|
|
11
|
-
var
|
|
13
|
+
var offset = editorWidth / 2;
|
|
14
|
+
return findChildren(state.tr.doc, function (node) {
|
|
12
15
|
return node.type === state.schema.nodes.mediaSingle;
|
|
13
|
-
},
|
|
14
|
-
|
|
16
|
+
}).reduce(function (acc, nodeWithPos, index) {
|
|
17
|
+
var _acc$relativeGuides, _acc$relativeGuides2;
|
|
18
|
+
var node = nodeWithPos.node,
|
|
19
|
+
pos = nodeWithPos.pos;
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (selectedNode === node) {
|
|
20
|
-
return
|
|
21
|
+
// if the current node the selected node
|
|
22
|
+
// or the node is not using pixel width,
|
|
23
|
+
// We will skip the node.
|
|
24
|
+
if (selectedNode === node || node.attrs.widthType !== 'pixel') {
|
|
25
|
+
return acc;
|
|
21
26
|
}
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
widthType = _node$attrs.widthType;
|
|
26
|
-
var pixelWidth = getMediaSinglePixelWidth(width, editorWidth, widthType);
|
|
27
|
-
var key = "".concat(MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index);
|
|
28
|
-
switch (layout) {
|
|
29
|
-
case 'align-start':
|
|
30
|
-
case 'wrap-left':
|
|
31
|
-
return _objectSpread({
|
|
32
|
-
position: {
|
|
33
|
-
x: roundToNearest(pixelWidth - offset)
|
|
34
|
-
},
|
|
35
|
-
key: key
|
|
36
|
-
}, styles);
|
|
37
|
-
case 'align-end':
|
|
38
|
-
case 'wrap-right':
|
|
39
|
-
return _objectSpread({
|
|
40
|
-
position: {
|
|
41
|
-
x: roundToNearest(offset - pixelWidth)
|
|
42
|
-
},
|
|
43
|
-
key: key
|
|
44
|
-
}, styles);
|
|
45
|
-
case 'center':
|
|
46
|
-
return [_objectSpread({
|
|
47
|
-
position: {
|
|
48
|
-
x: roundToNearest(pixelWidth / 2)
|
|
49
|
-
},
|
|
50
|
-
key: "".concat(key, "_right")
|
|
51
|
-
}, styles), _objectSpread({
|
|
52
|
-
position: {
|
|
53
|
-
x: -roundToNearest(pixelWidth / 2)
|
|
54
|
-
},
|
|
55
|
-
key: "".concat(key, "_left")
|
|
56
|
-
}, styles)];
|
|
57
|
-
// we ignore full-width and wide
|
|
58
|
-
default:
|
|
59
|
-
return [];
|
|
27
|
+
var $pos = state.tr.doc.resolve(pos);
|
|
28
|
+
if ($pos.parent.type !== state.schema.nodes.doc) {
|
|
29
|
+
return acc;
|
|
60
30
|
}
|
|
61
|
-
|
|
31
|
+
var dimensions = getMediaSingleDimensions(node, editorWidth);
|
|
32
|
+
if (!dimensions) {
|
|
33
|
+
return acc;
|
|
34
|
+
}
|
|
35
|
+
var width = dimensions.width,
|
|
36
|
+
height = dimensions.height;
|
|
37
|
+
var dynamicGuides = [].concat(_toConsumableArray(acc.dynamicGuides), _toConsumableArray(getDynamicGuides(node.attrs.layout, width, offset, "".concat(MEDIA_DYNAMIC_GUIDELINE_PREFIX).concat(index), styles)));
|
|
38
|
+
var accRelativeGuidesWidth = ((_acc$relativeGuides = acc.relativeGuides) === null || _acc$relativeGuides === void 0 ? void 0 : _acc$relativeGuides.width) || {};
|
|
39
|
+
var accRelativeGuidesHeight = ((_acc$relativeGuides2 = acc.relativeGuides) === null || _acc$relativeGuides2 === void 0 ? void 0 : _acc$relativeGuides2.height) || {};
|
|
40
|
+
var relativeGuidesWidth = _objectSpread(_objectSpread({}, accRelativeGuidesWidth), {}, _defineProperty({}, width, [].concat(_toConsumableArray(accRelativeGuidesWidth[width] || []), [nodeWithPos])));
|
|
41
|
+
var relativeGuidesWidthHeight = _objectSpread(_objectSpread({}, accRelativeGuidesHeight), {}, _defineProperty({}, Math.round(height), [].concat(_toConsumableArray(accRelativeGuidesHeight[height] || []), [nodeWithPos])));
|
|
42
|
+
return {
|
|
43
|
+
dynamicGuides: dynamicGuides,
|
|
44
|
+
relativeGuides: {
|
|
45
|
+
width: relativeGuidesWidth,
|
|
46
|
+
height: relativeGuidesWidthHeight
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}, {
|
|
50
|
+
relativeGuides: {
|
|
51
|
+
width: {},
|
|
52
|
+
height: {}
|
|
53
|
+
},
|
|
54
|
+
dynamicGuides: []
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var getDynamicGuides = function getDynamicGuides(layout, width, offset, key, styles) {
|
|
58
|
+
switch (layout) {
|
|
59
|
+
case 'align-start':
|
|
60
|
+
case 'wrap-left':
|
|
61
|
+
return [_objectSpread({
|
|
62
|
+
position: {
|
|
63
|
+
x: roundToNearest(width - offset)
|
|
64
|
+
},
|
|
65
|
+
key: key
|
|
66
|
+
}, styles)];
|
|
67
|
+
case 'align-end':
|
|
68
|
+
case 'wrap-right':
|
|
69
|
+
return [_objectSpread({
|
|
70
|
+
position: {
|
|
71
|
+
x: roundToNearest(offset - width)
|
|
72
|
+
},
|
|
73
|
+
key: key
|
|
74
|
+
}, styles)];
|
|
75
|
+
case 'center':
|
|
76
|
+
return [_objectSpread({
|
|
77
|
+
position: {
|
|
78
|
+
x: roundToNearest(width / 2)
|
|
79
|
+
},
|
|
80
|
+
key: "".concat(key, "_right")
|
|
81
|
+
}, styles), _objectSpread({
|
|
82
|
+
position: {
|
|
83
|
+
x: -roundToNearest(width / 2)
|
|
84
|
+
},
|
|
85
|
+
key: "".concat(key, "_left")
|
|
86
|
+
}, styles)];
|
|
87
|
+
default:
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
62
90
|
};
|
|
@@ -4,4 +4,5 @@ export { generateDefaultGuidelines } from './defaultGuideline';
|
|
|
4
4
|
export { getGuidelinesWithHighlights } from './updateGuideline';
|
|
5
5
|
export { MEDIA_DYNAMIC_GUIDELINE_PREFIX, INNER_GRID_GUIDELINE_PREFIX } from './constants';
|
|
6
6
|
export { getGuidelineSnaps, findClosestSnap } from './snapping';
|
|
7
|
-
export { isVerticalPosition, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
|
|
7
|
+
export { isVerticalPosition, getMediaSingleDimensions, getContainerWidthOrFullEditorWidth, getGuidelineTypeFromKey } from './utils';
|
|
8
|
+
export { getRelativeGuideSnaps, getRelativeGuidelines } from './relativeGuideline';
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { roundToNearest } from '../media-single';
|
|
3
|
+
import { getMediaSingleDimensions } from './utils';
|
|
4
|
+
var RELATIVE_GUIDES_GAP = 6;
|
|
5
|
+
var getWidthRelativeGuideline = function getWidthRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
|
|
6
|
+
var node = nodeWithPos.node,
|
|
7
|
+
pos = nodeWithPos.pos;
|
|
8
|
+
var _view$dom$getBounding = view.dom.getBoundingClientRect(),
|
|
9
|
+
topOffSet = _view$dom$getBounding.top,
|
|
10
|
+
viewHeight = _view$dom$getBounding.height;
|
|
11
|
+
var _view$coordsAtPos = view.coordsAtPos(pos + 1),
|
|
12
|
+
top = _view$coordsAtPos.top; // media node
|
|
13
|
+
|
|
14
|
+
var _ref = size || getMediaSingleDimensions(node, editorWidth) || {},
|
|
15
|
+
width = _ref.width,
|
|
16
|
+
height = _ref.height;
|
|
17
|
+
var y = top - topOffSet - RELATIVE_GUIDES_GAP;
|
|
18
|
+
if (!width || !height || y < 0 || y > viewHeight) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
var start = 0;
|
|
22
|
+
var end = 0;
|
|
23
|
+
switch (node.attrs.layout) {
|
|
24
|
+
case 'align-start':
|
|
25
|
+
case 'wrap-left':
|
|
26
|
+
start = -editorWidth / 2;
|
|
27
|
+
end = start + width;
|
|
28
|
+
break;
|
|
29
|
+
case 'align-end':
|
|
30
|
+
case 'wrap-right':
|
|
31
|
+
end = editorWidth / 2;
|
|
32
|
+
start = end - width;
|
|
33
|
+
break;
|
|
34
|
+
case 'center':
|
|
35
|
+
case 'wide':
|
|
36
|
+
case 'full-width':
|
|
37
|
+
end = width / 2;
|
|
38
|
+
start = -end;
|
|
39
|
+
break;
|
|
40
|
+
default:
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
key: key,
|
|
44
|
+
position: {
|
|
45
|
+
y: y,
|
|
46
|
+
x: {
|
|
47
|
+
start: start,
|
|
48
|
+
end: end
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
active: true,
|
|
52
|
+
styles: {
|
|
53
|
+
lineStyle: 'dashed',
|
|
54
|
+
capStyle: 'line'
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var getHeightRelativeGuideline = function getHeightRelativeGuideline(key, view, nodeWithPos, editorWidth, size) {
|
|
59
|
+
var node = nodeWithPos.node,
|
|
60
|
+
pos = nodeWithPos.pos;
|
|
61
|
+
var _view$dom$getBounding2 = view.dom.getBoundingClientRect(),
|
|
62
|
+
topOffSet = _view$dom$getBounding2.top,
|
|
63
|
+
viewHeight = _view$dom$getBounding2.height;
|
|
64
|
+
var _view$coordsAtPos2 = view.coordsAtPos(pos + 1),
|
|
65
|
+
top = _view$coordsAtPos2.top; // media node
|
|
66
|
+
|
|
67
|
+
var _ref2 = size || getMediaSingleDimensions(node, editorWidth) || {},
|
|
68
|
+
width = _ref2.width,
|
|
69
|
+
height = _ref2.height;
|
|
70
|
+
if (!width || !height) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
var start = top - topOffSet;
|
|
74
|
+
var end = start + height;
|
|
75
|
+
if (end < 0 || start > viewHeight) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
var x = 0;
|
|
79
|
+
var halfWidth = editorWidth / 2;
|
|
80
|
+
switch (node.attrs.layout) {
|
|
81
|
+
case 'align-start':
|
|
82
|
+
case 'wrap-left':
|
|
83
|
+
x = width - halfWidth;
|
|
84
|
+
break;
|
|
85
|
+
case 'align-end':
|
|
86
|
+
case 'wrap-right':
|
|
87
|
+
x = halfWidth;
|
|
88
|
+
break;
|
|
89
|
+
case 'center':
|
|
90
|
+
case 'wide':
|
|
91
|
+
case 'full-width':
|
|
92
|
+
x = width / 2;
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
x = 0;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
key: key,
|
|
99
|
+
position: {
|
|
100
|
+
x: x + RELATIVE_GUIDES_GAP,
|
|
101
|
+
y: {
|
|
102
|
+
start: start,
|
|
103
|
+
end: end
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
active: true,
|
|
107
|
+
styles: {
|
|
108
|
+
lineStyle: 'dashed',
|
|
109
|
+
capStyle: 'line'
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export var getRelativeGuideSnaps = function getRelativeGuideSnaps(relativeGuides, aspectRatio) {
|
|
114
|
+
var snapsWidthFromMatchingHeight = Object.keys(relativeGuides.height || {}).map(function (heightKey) {
|
|
115
|
+
var height = Number.parseInt(heightKey);
|
|
116
|
+
return roundToNearest(height * aspectRatio);
|
|
117
|
+
});
|
|
118
|
+
var snapsWidthFromMatchingWidth = Object.keys(relativeGuides.width || {}).map(function (widthKey) {
|
|
119
|
+
return Number.parseInt(widthKey);
|
|
120
|
+
});
|
|
121
|
+
return [].concat(_toConsumableArray(snapsWidthFromMatchingWidth), _toConsumableArray(snapsWidthFromMatchingHeight));
|
|
122
|
+
};
|
|
123
|
+
export var getRelativeGuidelines = function getRelativeGuidelines(relativeGuides, nodeWithPos, view, editorWidth, size) {
|
|
124
|
+
var matchWidth = relativeGuides.width ? relativeGuides.width[Math.round(size.width)] : [];
|
|
125
|
+
var matchHeight = relativeGuides.height ? relativeGuides.height[Math.round(size.height)] : [];
|
|
126
|
+
var matches = matchWidth || matchHeight;
|
|
127
|
+
var getRelativeGuideline = matchWidth && getWidthRelativeGuideline || matchHeight && getHeightRelativeGuideline || null;
|
|
128
|
+
if (matches && getRelativeGuideline) {
|
|
129
|
+
return [getRelativeGuideline('relative_guide_current', view, nodeWithPos, editorWidth, size)].concat(_toConsumableArray(matches.map(function (nodeWithPos, index) {
|
|
130
|
+
return getRelativeGuideline("relative_guide_".concat(index), view, nodeWithPos, editorWidth);
|
|
131
|
+
}))).filter(function (config) {
|
|
132
|
+
return !!config;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return [];
|
|
136
|
+
};
|
|
@@ -5,7 +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 {
|
|
8
|
+
import { editorCommandToPMCommand } from '../preset/editor-commands';
|
|
9
9
|
import { browser } from '../utils';
|
|
10
10
|
export var addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
|
|
11
11
|
export var navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
|
|
@@ -192,8 +192,8 @@ export function bindKeymapWithCommand(shortcut, cmd, keymap) {
|
|
|
192
192
|
var oldCmd = keymap[shortcut];
|
|
193
193
|
keymap[shortcut] = oldCmd ? combineWithOldCommand(cmd, oldCmd) : cmd;
|
|
194
194
|
}
|
|
195
|
-
export function
|
|
196
|
-
bindKeymapWithCommand(shortcut,
|
|
195
|
+
export function bindKeymapWithEditorCommand(shortcut, cmd, keymap) {
|
|
196
|
+
bindKeymapWithCommand(shortcut, editorCommandToPMCommand(cmd), keymap);
|
|
197
197
|
}
|
|
198
198
|
export function findKeyMapForBrowser(keyMap) {
|
|
199
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.46.1";
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convert a
|
|
3
|
-
* The preferred approach to dispatching a `
|
|
2
|
+
* Convert a EditorCommand to a standard Prosemirror Command.
|
|
3
|
+
* The preferred approach to dispatching a `EditorCommand` is via the
|
|
4
4
|
* `executeCommand` on `pluginInjectionAPI`. In some cases
|
|
5
5
|
* the type may require a Command until we refactor this out and this
|
|
6
6
|
* function is suitable for those cases.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param command A plugin command (a function that modifies and returns a `Transaction`)
|
|
9
9
|
* @returns Command
|
|
10
10
|
*/
|
|
11
|
-
export function
|
|
11
|
+
export function editorCommandToPMCommand(command) {
|
|
12
12
|
return function (_ref, dispatch) {
|
|
13
13
|
var tr = _ref.tr;
|
|
14
14
|
var newTr = command === null || command === void 0 ? void 0 : command({
|
package/dist/esm/preset/index.js
CHANGED
|
@@ -9,7 +9,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
9
9
|
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; }
|
|
10
10
|
import isEqual from 'lodash/isEqual';
|
|
11
11
|
import throttle from 'lodash/throttle';
|
|
12
|
-
import {
|
|
12
|
+
import { editorCommandToPMCommand } from './editor-commands';
|
|
13
13
|
function hasGetSharedState(plugin) {
|
|
14
14
|
return typeof plugin.getSharedState === 'function';
|
|
15
15
|
}
|
|
@@ -117,11 +117,11 @@ var ActionsAPI = /*#__PURE__*/function () {
|
|
|
117
117
|
}]);
|
|
118
118
|
return ActionsAPI;
|
|
119
119
|
}();
|
|
120
|
-
var
|
|
121
|
-
function
|
|
122
|
-
_classCallCheck(this,
|
|
120
|
+
var EditorCommandsAPI = /*#__PURE__*/function () {
|
|
121
|
+
function EditorCommandsAPI() {
|
|
122
|
+
_classCallCheck(this, EditorCommandsAPI);
|
|
123
123
|
}
|
|
124
|
-
_createClass(
|
|
124
|
+
_createClass(EditorCommandsAPI, [{
|
|
125
125
|
key: "createAPI",
|
|
126
126
|
value: function createAPI(plugin) {
|
|
127
127
|
if (!plugin || !hasCommands(plugin)) {
|
|
@@ -135,7 +135,7 @@ var PluginCommandsAPI = /*#__PURE__*/function () {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
}]);
|
|
138
|
-
return
|
|
138
|
+
return EditorCommandsAPI;
|
|
139
139
|
}();
|
|
140
140
|
export var SharedStateAPI = /*#__PURE__*/function () {
|
|
141
141
|
function SharedStateAPI(_ref4) {
|
|
@@ -262,7 +262,7 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
262
262
|
});
|
|
263
263
|
this.plugins = new Map();
|
|
264
264
|
this.actionsAPI = new ActionsAPI();
|
|
265
|
-
this.commandsAPI = new
|
|
265
|
+
this.commandsAPI = new EditorCommandsAPI();
|
|
266
266
|
this.getEditorView = getEditorView;
|
|
267
267
|
}
|
|
268
268
|
_createClass(EditorPluginInjectionAPI, [{
|
|
@@ -312,7 +312,7 @@ export var EditorPluginInjectionAPI = /*#__PURE__*/function () {
|
|
|
312
312
|
}
|
|
313
313
|
var state = editorView.state,
|
|
314
314
|
dispatch = editorView.dispatch;
|
|
315
|
-
return
|
|
315
|
+
return editorCommandToPMCommand(command)(state, dispatch);
|
|
316
316
|
}
|
|
317
317
|
}]);
|
|
318
318
|
return EditorPluginInjectionAPI;
|
|
@@ -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.46.1";
|
|
22
22
|
var halfFocusRing = 1;
|
|
23
23
|
var dropOffset = '0, 8';
|
|
24
24
|
var DropList = /*#__PURE__*/function (_Component) {
|