@atlaskit/editor-common 74.32.1 → 74.34.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/card/MediaAndEmbedsToolbar/index.js +23 -7
- package/dist/cjs/guideline/index.js +13 -0
- package/dist/cjs/keymaps/index.js +8 -1
- package/dist/cjs/keymaps/keymap.js +38 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/styles/shared/media-single.js +2 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/MediaSingle/index.js +2 -7
- package/dist/cjs/ui/MediaSingle/styled.js +24 -2
- package/dist/cjs/ui/index.js +0 -6
- package/dist/cjs/utils/commands.js +180 -15
- package/dist/cjs/utils/editor-core-utils.js +53 -3
- package/dist/cjs/utils/index.js +54 -0
- package/dist/cjs/utils/input-rules.js +48 -2
- package/dist/cjs/utils/rich-media-utils.js +6 -3
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/card/MediaAndEmbedsToolbar/index.js +23 -8
- package/dist/es2019/guideline/index.js +1 -0
- package/dist/es2019/keymaps/index.js +3 -2
- package/dist/es2019/keymaps/keymap.js +33 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/styles/shared/media-single.js +6 -5
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/MediaSingle/index.js +1 -4
- package/dist/es2019/ui/MediaSingle/styled.js +45 -2
- package/dist/es2019/ui/index.js +1 -1
- package/dist/es2019/utils/commands.js +173 -2
- package/dist/es2019/utils/editor-core-utils.js +46 -1
- package/dist/es2019/utils/index.js +4 -4
- package/dist/es2019/utils/input-rules.js +45 -0
- package/dist/es2019/utils/rich-media-utils.js +3 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/card/MediaAndEmbedsToolbar/index.js +24 -8
- package/dist/esm/guideline/index.js +1 -0
- package/dist/esm/keymaps/index.js +3 -2
- package/dist/esm/keymaps/keymap.js +33 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/styles/shared/media-single.js +2 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/MediaSingle/index.js +1 -4
- package/dist/esm/ui/MediaSingle/styled.js +25 -3
- package/dist/esm/ui/index.js +1 -1
- package/dist/esm/utils/commands.js +170 -14
- package/dist/esm/utils/editor-core-utils.js +47 -0
- package/dist/esm/utils/index.js +4 -4
- package/dist/esm/utils/input-rules.js +44 -0
- package/dist/esm/utils/rich-media-utils.js +3 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/card/MediaAndEmbedsToolbar/index.d.ts +1 -1
- package/dist/types/guideline/index.d.ts +1 -0
- package/dist/types/keymaps/index.d.ts +1 -0
- package/dist/types/keymaps/keymap.d.ts +11 -0
- package/dist/types/types/block-type.d.ts +1 -0
- package/dist/types/types/feature-flags.d.ts +8 -0
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/MediaSingle/index.d.ts +1 -2
- package/dist/types/ui/MediaSingle/styled.d.ts +3 -1
- package/dist/types/ui/index.d.ts +1 -1
- package/dist/types/utils/commands.d.ts +11 -5
- package/dist/types/utils/editor-core-utils.d.ts +7 -2
- package/dist/types/utils/index.d.ts +4 -4
- package/dist/types/utils/input-rules.d.ts +12 -4
- package/dist/types/utils/rich-media-utils.d.ts +1 -0
- package/dist/types-ts4.5/card/MediaAndEmbedsToolbar/index.d.ts +1 -1
- package/dist/types-ts4.5/guideline/index.d.ts +1 -0
- package/dist/types-ts4.5/keymaps/index.d.ts +1 -0
- package/dist/types-ts4.5/keymaps/keymap.d.ts +11 -0
- package/dist/types-ts4.5/types/block-type.d.ts +1 -0
- package/dist/types-ts4.5/types/feature-flags.d.ts +8 -0
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/MediaSingle/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/MediaSingle/styled.d.ts +3 -1
- package/dist/types-ts4.5/ui/index.d.ts +1 -1
- package/dist/types-ts4.5/utils/commands.d.ts +11 -5
- package/dist/types-ts4.5/utils/editor-core-utils.d.ts +7 -2
- package/dist/types-ts4.5/utils/index.d.ts +4 -4
- package/dist/types-ts4.5/utils/input-rules.d.ts +12 -4
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +1 -0
- package/package.json +7 -3
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.extractSliceFromStep = void 0;
|
|
7
|
+
exports.filterChildrenBetween = filterChildrenBetween;
|
|
8
|
+
exports.isElementInTableCell = void 0;
|
|
7
9
|
exports.isEmptyParagraph = isEmptyParagraph;
|
|
8
10
|
exports.isValidPosition = exports.isTextSelection = exports.isLastItemMediaGroup = exports.isInLayoutColumn = void 0;
|
|
9
11
|
exports.nonNullable = nonNullable;
|
|
10
|
-
exports.setNodeSelection = void 0;
|
|
12
|
+
exports.setNodeSelection = exports.removeBlockMarks = void 0;
|
|
11
13
|
exports.setTextSelection = setTextSelection;
|
|
12
14
|
exports.stepAddsOneOf = stepAddsOneOf;
|
|
13
15
|
exports.stepHasSlice = void 0;
|
|
@@ -103,4 +105,52 @@ exports.isValidPosition = isValidPosition;
|
|
|
103
105
|
var isInLayoutColumn = function isInLayoutColumn(state) {
|
|
104
106
|
return (0, _utils.hasParentNodeOfType)(state.schema.nodes.layoutSection)(state.selection);
|
|
105
107
|
};
|
|
106
|
-
exports.isInLayoutColumn = isInLayoutColumn;
|
|
108
|
+
exports.isInLayoutColumn = isInLayoutColumn;
|
|
109
|
+
function filterChildrenBetween(doc, from, to, predicate) {
|
|
110
|
+
var results = [];
|
|
111
|
+
doc.nodesBetween(from, to, function (node, pos, parent) {
|
|
112
|
+
if (predicate(node, pos, parent)) {
|
|
113
|
+
results.push({
|
|
114
|
+
node: node,
|
|
115
|
+
pos: pos
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
return results;
|
|
120
|
+
}
|
|
121
|
+
var removeBlockMarks = function removeBlockMarks(state, marks) {
|
|
122
|
+
var selection = state.selection,
|
|
123
|
+
schema = state.schema;
|
|
124
|
+
var tr = state.tr;
|
|
125
|
+
|
|
126
|
+
// Marks might not exist in Schema
|
|
127
|
+
var marksToRemove = marks.filter(Boolean);
|
|
128
|
+
if (marksToRemove.length === 0) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** Saves an extra dispatch */
|
|
133
|
+
var blockMarksExists = false;
|
|
134
|
+
var hasMark = function hasMark(mark) {
|
|
135
|
+
return marksToRemove.indexOf(mark.type) > -1;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* When you need to toggle the selection
|
|
139
|
+
* when another type which does not allow alignment is applied
|
|
140
|
+
*/
|
|
141
|
+
state.doc.nodesBetween(selection.from, selection.to, function (node, pos) {
|
|
142
|
+
if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
|
|
143
|
+
blockMarksExists = true;
|
|
144
|
+
var resolvedPos = state.doc.resolve(pos);
|
|
145
|
+
var withoutBlockMarks = node.marks.filter(not(hasMark));
|
|
146
|
+
tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return blockMarksExists ? tr : undefined;
|
|
150
|
+
};
|
|
151
|
+
exports.removeBlockMarks = removeBlockMarks;
|
|
152
|
+
var not = function not(fn) {
|
|
153
|
+
return function (arg) {
|
|
154
|
+
return !fn(arg);
|
|
155
|
+
};
|
|
156
|
+
};
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -226,6 +226,36 @@ Object.defineProperty(exports, "createCompareNodes", {
|
|
|
226
226
|
return _compareNodes.createCompareNodes;
|
|
227
227
|
}
|
|
228
228
|
});
|
|
229
|
+
Object.defineProperty(exports, "createNewParagraphAbove", {
|
|
230
|
+
enumerable: true,
|
|
231
|
+
get: function get() {
|
|
232
|
+
return _commands.createNewParagraphAbove;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
Object.defineProperty(exports, "createNewParagraphBelow", {
|
|
236
|
+
enumerable: true,
|
|
237
|
+
get: function get() {
|
|
238
|
+
return _commands.createNewParagraphBelow;
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
Object.defineProperty(exports, "createParagraphNear", {
|
|
242
|
+
enumerable: true,
|
|
243
|
+
get: function get() {
|
|
244
|
+
return _commands.createParagraphNear;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
Object.defineProperty(exports, "createRule", {
|
|
248
|
+
enumerable: true,
|
|
249
|
+
get: function get() {
|
|
250
|
+
return _inputRules.createRule;
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
Object.defineProperty(exports, "createWrappingJoinRule", {
|
|
254
|
+
enumerable: true,
|
|
255
|
+
get: function get() {
|
|
256
|
+
return _inputRules.createWrappingJoinRule;
|
|
257
|
+
}
|
|
258
|
+
});
|
|
229
259
|
Object.defineProperty(exports, "deleteEmptyParagraphAndMoveBlockUp", {
|
|
230
260
|
enumerable: true,
|
|
231
261
|
get: function get() {
|
|
@@ -238,6 +268,12 @@ Object.defineProperty(exports, "extractSliceFromStep", {
|
|
|
238
268
|
return _editorCoreUtils.extractSliceFromStep;
|
|
239
269
|
}
|
|
240
270
|
});
|
|
271
|
+
Object.defineProperty(exports, "filterChildrenBetween", {
|
|
272
|
+
enumerable: true,
|
|
273
|
+
get: function get() {
|
|
274
|
+
return _editorCoreUtils.filterChildrenBetween;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
241
277
|
Object.defineProperty(exports, "filterCommand", {
|
|
242
278
|
enumerable: true,
|
|
243
279
|
get: function get() {
|
|
@@ -454,6 +490,12 @@ Object.defineProperty(exports, "insertContentDeleteRange", {
|
|
|
454
490
|
return _commands.insertContentDeleteRange;
|
|
455
491
|
}
|
|
456
492
|
});
|
|
493
|
+
Object.defineProperty(exports, "insertNewLineWithAnalytics", {
|
|
494
|
+
enumerable: true,
|
|
495
|
+
get: function get() {
|
|
496
|
+
return _commands.insertNewLineWithAnalytics;
|
|
497
|
+
}
|
|
498
|
+
});
|
|
457
499
|
Object.defineProperty(exports, "isBulletList", {
|
|
458
500
|
enumerable: true,
|
|
459
501
|
get: function get() {
|
|
@@ -694,6 +736,12 @@ Object.defineProperty(exports, "nonNullable", {
|
|
|
694
736
|
return _editorCoreUtils.nonNullable;
|
|
695
737
|
}
|
|
696
738
|
});
|
|
739
|
+
Object.defineProperty(exports, "nonWrappedLayouts", {
|
|
740
|
+
enumerable: true,
|
|
741
|
+
get: function get() {
|
|
742
|
+
return _richMediaUtils.nonWrappedLayouts;
|
|
743
|
+
}
|
|
744
|
+
});
|
|
697
745
|
Object.defineProperty(exports, "normalizeUrl", {
|
|
698
746
|
enumerable: true,
|
|
699
747
|
get: function get() {
|
|
@@ -719,6 +767,12 @@ Object.defineProperty(exports, "processRawValue", {
|
|
|
719
767
|
return _document.processRawValue;
|
|
720
768
|
}
|
|
721
769
|
});
|
|
770
|
+
Object.defineProperty(exports, "removeBlockMarks", {
|
|
771
|
+
enumerable: true,
|
|
772
|
+
get: function get() {
|
|
773
|
+
return _editorCoreUtils.removeBlockMarks;
|
|
774
|
+
}
|
|
775
|
+
});
|
|
722
776
|
Object.defineProperty(exports, "removeConnectedNodes", {
|
|
723
777
|
enumerable: true,
|
|
724
778
|
get: function get() {
|
|
@@ -4,8 +4,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.inputRuleWithAnalytics = void 0;
|
|
7
|
+
exports.inputRuleWithAnalytics = exports.createWrappingJoinRule = exports.createRule = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
10
|
+
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
11
|
+
var _analytics = require("../analytics");
|
|
9
12
|
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; }
|
|
10
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
14
|
// Roughly based on atlassian-frontend/packages/editor/editor-core/src/utils/input-rules.ts but with the Editor Analytics API that's injected in plugins
|
|
@@ -23,4 +26,47 @@ var inputRuleWithAnalytics = function inputRuleWithAnalytics(getPayload, analyti
|
|
|
23
26
|
});
|
|
24
27
|
};
|
|
25
28
|
};
|
|
26
|
-
exports.inputRuleWithAnalytics = inputRuleWithAnalytics;
|
|
29
|
+
exports.inputRuleWithAnalytics = inputRuleWithAnalytics;
|
|
30
|
+
var createWrappingJoinRule = function createWrappingJoinRule(_ref) {
|
|
31
|
+
var match = _ref.match,
|
|
32
|
+
nodeType = _ref.nodeType,
|
|
33
|
+
getAttrs = _ref.getAttrs,
|
|
34
|
+
joinPredicate = _ref.joinPredicate;
|
|
35
|
+
var handler = function handler(state, match, start, end) {
|
|
36
|
+
var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
|
|
37
|
+
var tr = state.tr;
|
|
38
|
+
var fixedStart = Math.max(start, 1);
|
|
39
|
+
tr.delete(fixedStart, end);
|
|
40
|
+
var $start = tr.doc.resolve(fixedStart);
|
|
41
|
+
var range = $start.blockRange();
|
|
42
|
+
var wrapping = range && (0, _transform.findWrapping)(range, nodeType, attrs);
|
|
43
|
+
if (!wrapping || !range) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
var parentNodePosMapped = tr.mapping.map(range.start);
|
|
47
|
+
var parentNode = tr.doc.nodeAt(parentNodePosMapped);
|
|
48
|
+
var lastWrap = wrapping[wrapping.length - 1];
|
|
49
|
+
if (parentNode && lastWrap) {
|
|
50
|
+
var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
|
|
51
|
+
tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
|
|
52
|
+
}
|
|
53
|
+
tr.wrap(range, wrapping);
|
|
54
|
+
var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
|
|
55
|
+
if (before && before.type === nodeType && (0, _transform.canJoin)(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, _analytics.JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
|
|
56
|
+
tr.join(fixedStart - 1);
|
|
57
|
+
}
|
|
58
|
+
return tr;
|
|
59
|
+
};
|
|
60
|
+
return createRule(match, handler);
|
|
61
|
+
};
|
|
62
|
+
exports.createWrappingJoinRule = createWrappingJoinRule;
|
|
63
|
+
var createRule = function createRule(match, handler) {
|
|
64
|
+
return {
|
|
65
|
+
match: match,
|
|
66
|
+
handler: handler,
|
|
67
|
+
onHandlerApply: function onHandlerApply(_state, tr) {
|
|
68
|
+
(0, _history.closeHistory)(tr);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports.createRule = createRule;
|
|
@@ -6,14 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.alignAttributes = void 0;
|
|
8
8
|
exports.calculateSnapPoints = calculateSnapPoints;
|
|
9
|
-
exports.nonWrappedLayouts = exports.isRichMediaInsideOfBlockNode = exports.floatingLayouts = void 0;
|
|
9
|
+
exports.shouldAddDefaultWrappedWidth = exports.nonWrappedLayouts = exports.isRichMediaInsideOfBlockNode = exports.floatingLayouts = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
-
var _MediaSingle = require("../ui/MediaSingle");
|
|
14
13
|
var _grid = require("../ui/MediaSingle/grid");
|
|
15
14
|
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; }
|
|
16
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
var shouldAddDefaultWrappedWidth = function shouldAddDefaultWrappedWidth(layout, width, lineLength) {
|
|
17
|
+
return _grid.wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
|
|
18
|
+
};
|
|
19
|
+
exports.shouldAddDefaultWrappedWidth = shouldAddDefaultWrappedWidth;
|
|
17
20
|
var nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
18
21
|
exports.nonWrappedLayouts = nonWrappedLayouts;
|
|
19
22
|
var floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
@@ -40,7 +43,7 @@ var alignAttributes = function alignAttributes(layout, oldAttrs) {
|
|
|
40
43
|
var newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
|
|
41
44
|
var newLayoutIsWrapped = _grid.wrappedLayouts.indexOf(layout) > -1;
|
|
42
45
|
var oldLayoutIsWrapped = _grid.wrappedLayouts.indexOf(oldLayout) > -1;
|
|
43
|
-
if (oldLayoutIsNonWrapped &&
|
|
46
|
+
if (oldLayoutIsNonWrapped && shouldAddDefaultWrappedWidth(layout, originalWidth, lineLength)) {
|
|
44
47
|
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
45
48
|
if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
|
|
46
49
|
) {
|
package/dist/cjs/version.json
CHANGED
|
@@ -8,10 +8,11 @@ import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
|
8
8
|
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
9
9
|
import WrapLeftIcon from '@atlaskit/icon/glyph/editor/media-wrap-left';
|
|
10
10
|
import WrapRightIcon from '@atlaskit/icon/glyph/editor/media-wrap-right';
|
|
11
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../analytics';
|
|
12
13
|
import { insideTable } from '../../core-utils';
|
|
13
14
|
import commonMessages, { mediaAndEmbedToolbarMessages as toolbarMessages } from '../../messages';
|
|
14
|
-
import { alignAttributes, isInLayoutColumn } from '../../utils';
|
|
15
|
+
import { alignAttributes, isInLayoutColumn, nonWrappedLayouts } from '../../utils';
|
|
15
16
|
|
|
16
17
|
// Workaround as we don't want to import this package into `editor-common`
|
|
17
18
|
// We'll get type errors if this gets out of sync with `editor-plugin-width`.
|
|
@@ -81,7 +82,12 @@ const makeAlign = (layout, nodeType, widthPluginDependencyApi, analyticsApi) =>
|
|
|
81
82
|
return false;
|
|
82
83
|
}
|
|
83
84
|
const nodeWidth = getNodeWidth(node, state.schema);
|
|
84
|
-
const newAttrs =
|
|
85
|
+
const newAttrs = getBooleanFF('platform.editor.media.extended-resize-experience') ?
|
|
86
|
+
// with extended experience, change alignment does not change media single width
|
|
87
|
+
{
|
|
88
|
+
...node.attrs,
|
|
89
|
+
layout
|
|
90
|
+
} : alignAttributes(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
|
|
85
91
|
const tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
|
|
86
92
|
tr.setMeta('scrollIntoView', false);
|
|
87
93
|
// when image captions are enabled, the wrong node gets selected after
|
|
@@ -120,7 +126,13 @@ const makeAlign = (layout, nodeType, widthPluginDependencyApi, analyticsApi) =>
|
|
|
120
126
|
return true;
|
|
121
127
|
};
|
|
122
128
|
};
|
|
123
|
-
const
|
|
129
|
+
const getToolbarLayout = layout => {
|
|
130
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience') && nonWrappedLayouts.includes(layout)) {
|
|
131
|
+
return 'center';
|
|
132
|
+
}
|
|
133
|
+
return layout;
|
|
134
|
+
};
|
|
135
|
+
const mapIconsToToolbarItem = (icons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi, isChangingLayoutDisabled) => icons.map(toolbarItem => {
|
|
124
136
|
const {
|
|
125
137
|
id,
|
|
126
138
|
value
|
|
@@ -130,8 +142,11 @@ const mapIconsToToolbarItem = (icons, layout, intl, nodeType, widthPluginDepende
|
|
|
130
142
|
type: 'button',
|
|
131
143
|
icon: toolbarItem.icon,
|
|
132
144
|
title: intl.formatMessage(layoutToMessages[value]),
|
|
133
|
-
selected: layout === value,
|
|
134
|
-
onClick: makeAlign(value, nodeType, widthPluginDependencyApi, analyticsApi)
|
|
145
|
+
selected: getToolbarLayout(layout) === value,
|
|
146
|
+
onClick: makeAlign(value, nodeType, widthPluginDependencyApi, analyticsApi),
|
|
147
|
+
...(isChangingLayoutDisabled && {
|
|
148
|
+
disabled: value !== 'center'
|
|
149
|
+
})
|
|
135
150
|
};
|
|
136
151
|
});
|
|
137
152
|
const shouldHideLayoutToolbar = (selection, {
|
|
@@ -139,7 +154,7 @@ const shouldHideLayoutToolbar = (selection, {
|
|
|
139
154
|
}, allowResizingInTables) => {
|
|
140
155
|
return hasParentNodeOfType([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand, ...(allowResizingInTables ? [] : [nodes.table])].filter(Boolean))(selection);
|
|
141
156
|
};
|
|
142
|
-
const buildLayoutButtons = (state, intl, nodeType, widthPluginDependencyApi, analyticsApi, allowResizing, allowResizingInTables, allowWrapping = true, allowAlignment = true) => {
|
|
157
|
+
const buildLayoutButtons = (state, intl, nodeType, widthPluginDependencyApi, analyticsApi, allowResizing, allowResizingInTables, allowWrapping = true, allowAlignment = true, isChangingLayoutDisabled) => {
|
|
143
158
|
const {
|
|
144
159
|
selection
|
|
145
160
|
} = state;
|
|
@@ -149,8 +164,8 @@ const buildLayoutButtons = (state, intl, nodeType, widthPluginDependencyApi, ana
|
|
|
149
164
|
const {
|
|
150
165
|
layout
|
|
151
166
|
} = selection.node.attrs;
|
|
152
|
-
const alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
153
|
-
const wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
167
|
+
const alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi, isChangingLayoutDisabled) : [];
|
|
168
|
+
const wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi, isChangingLayoutDisabled) : [];
|
|
154
169
|
const breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
155
170
|
const items = [...alignmentToolbarItems, ...getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping), ...wrappingToolbarItems, ...getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing), ...breakOutToolbarItems];
|
|
156
171
|
return items;
|
|
@@ -3,4 +3,5 @@ export { createFixedGuidelinesFromLengths, createGuidesFromLengths } from './fix
|
|
|
3
3
|
export { generateDefaultGuidelines } from './defaultGuideline';
|
|
4
4
|
export { getGuidelinesWithHighlights } from './updateGuideline';
|
|
5
5
|
export { MEDIA_DYNAMIC_GUIDELINE_PREFIX } from './constants';
|
|
6
|
+
export { getSnapWidth, findClosestSnap } from './snapping';
|
|
6
7
|
export { isVerticalPosition, getContainerWidthOrFullEditorWidth } from './utils';
|
|
@@ -77,7 +77,7 @@ const arrowKeysMap = {
|
|
|
77
77
|
const tooltipShortcutStyle = css`
|
|
78
78
|
border-radius: 2px;
|
|
79
79
|
background-color: ${`var(--ds-background-inverse-subtle, ${N400})`};
|
|
80
|
-
padding: 0 2px;
|
|
80
|
+
padding: 0 ${"var(--ds-space-025, 2px)"};
|
|
81
81
|
|
|
82
82
|
/* TODO: fix in develop: https://atlassian.slack.com/archives/CFG3PSQ9E/p1647395052443259?thread_ts=1647394572.556029&cid=CFG3PSQ9E */
|
|
83
83
|
/* stylelint-disable-next-line */
|
|
@@ -205,4 +205,5 @@ export function findKeyMapForBrowser(keyMap) {
|
|
|
205
205
|
}
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP } from './consts';
|
|
208
|
+
export { DOWN, HEADING_KEYS, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5, KEY_6, LEFT, RIGHT, UP } from './consts';
|
|
209
|
+
export { keymap } from './keymap';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { base, keyName } from 'w3c-keyname';
|
|
2
|
+
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
3
|
+
import { SafePlugin } from '../safe-plugin';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A workaround for mostly Cyrillic but should have a positive affect
|
|
7
|
+
* on other languages / layouts. Attempts a similar approach to OS X.
|
|
8
|
+
* @see ED-7310
|
|
9
|
+
* @see https://github.com/ProseMirror/prosemirror/issues/957
|
|
10
|
+
* @param bindings
|
|
11
|
+
*/
|
|
12
|
+
export function keymap(bindings) {
|
|
13
|
+
return new SafePlugin({
|
|
14
|
+
props: {
|
|
15
|
+
handleKeyDown(view, event) {
|
|
16
|
+
const name = keyName(event);
|
|
17
|
+
let keyboardEvent = event;
|
|
18
|
+
if (event.ctrlKey && name.length === 1 &&
|
|
19
|
+
// Check the unicode of the character to
|
|
20
|
+
// assert that its not an ASCII character.
|
|
21
|
+
// These are characters outside Latin's range.
|
|
22
|
+
/[^\u0000-\u007f]/.test(name)) {
|
|
23
|
+
keyboardEvent = new KeyboardEvent('keydown', {
|
|
24
|
+
key: base[event.keyCode],
|
|
25
|
+
code: event.code,
|
|
26
|
+
ctrlKey: true
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return keydownHandler(bindings)(view, keyboardEvent);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -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.34.0";
|
|
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,4 +1,5 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
const richMediaClassName = 'rich-media-item';
|
|
3
4
|
const wrappedMediaBreakoutPoint = 410;
|
|
4
5
|
const mediaSingleSharedStyle = css`
|
|
@@ -29,8 +30,8 @@ const mediaSingleSharedStyle = css`
|
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
table .${richMediaClassName} {
|
|
32
|
-
margin-top: 12px;
|
|
33
|
-
margin-bottom: 12px;
|
|
33
|
+
margin-top: ${"var(--ds-space-150, 12px)"};
|
|
34
|
+
margin-bottom: ${"var(--ds-space-150, 12px)"};
|
|
34
35
|
clear: both;
|
|
35
36
|
|
|
36
37
|
&.image-wrap-left,
|
|
@@ -38,7 +39,7 @@ const mediaSingleSharedStyle = css`
|
|
|
38
39
|
clear: none;
|
|
39
40
|
|
|
40
41
|
&:first-child {
|
|
41
|
-
margin-top: 12px;
|
|
42
|
+
margin-top: ${"var(--ds-space-150, 12px)"};
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -60,7 +61,7 @@ const mediaSingleSharedStyle = css`
|
|
|
60
61
|
margin-left: 0;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
+
${!getBooleanFF('platform.editor.media.extended-resize-experience') && `@media all and (max-width: ${wrappedMediaBreakoutPoint}px) {
|
|
64
65
|
div.mediaSingleView-content-wrap[layout='wrap-left'],
|
|
65
66
|
div.mediaSingleView-content-wrap[data-layout='wrap-left'],
|
|
66
67
|
div.mediaSingleView-content-wrap[layout='wrap-right'],
|
|
@@ -69,6 +70,6 @@ const mediaSingleSharedStyle = css`
|
|
|
69
70
|
overflow: auto;
|
|
70
71
|
margin: 12px 0;
|
|
71
72
|
}
|
|
72
|
-
}
|
|
73
|
+
}`}
|
|
73
74
|
`;
|
|
74
75
|
export { mediaSingleSharedStyle, richMediaClassName };
|
|
@@ -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.34.0";
|
|
12
12
|
const halfFocusRing = 1;
|
|
13
13
|
const dropOffset = '0, 8';
|
|
14
14
|
class DropList extends Component {
|
|
@@ -5,7 +5,7 @@ import classnames from 'classnames';
|
|
|
5
5
|
import { akEditorMediaResizeHandlerPaddingWide, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { MEDIA_SINGLE_GUTTER_SIZE } from '../../media-single/constants';
|
|
7
7
|
import { getMediaSinglePixelWidth } from '../../media-single/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { shouldAddDefaultWrappedWidth } from '../../utils/rich-media-utils';
|
|
9
9
|
import { MediaSingleDimensionHelper, MediaWrapper } from './styled';
|
|
10
10
|
export const DEFAULT_IMAGE_WIDTH = 250;
|
|
11
11
|
export const DEFAULT_IMAGE_HEIGHT = 200;
|
|
@@ -15,9 +15,6 @@ export const DEFAULT_IMAGE_HEIGHT = 200;
|
|
|
15
15
|
Read more: https://product-fabric.atlassian.net/browse/MEX-2481
|
|
16
16
|
*/
|
|
17
17
|
export const IMAGE_AND_BORDER_ADJUSTMENT = 2;
|
|
18
|
-
export const shouldAddDefaultWrappedWidth = (layout, width, lineLength) => {
|
|
19
|
-
return wrappedLayouts.indexOf(layout) > -1 && lineLength && width && width > 0.5 * lineLength;
|
|
20
|
-
};
|
|
21
18
|
export default function MediaSingle({
|
|
22
19
|
layout,
|
|
23
20
|
width,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
-
import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import { akEditorFullPageMaxWidth, akEditorFullWidthLayoutWidth, akEditorGutterPadding } from '@atlaskit/editor-shared-styles';
|
|
5
|
+
import { nonWrappedLayouts } from '../../utils';
|
|
5
6
|
import { calcBreakoutWidth, calcWideWidth } from '../../utils/breakout';
|
|
6
7
|
function float(layout) {
|
|
7
8
|
switch (layout) {
|
|
@@ -69,6 +70,24 @@ function calcMaxWidth(layout, containerWidth) {
|
|
|
69
70
|
return '100%';
|
|
70
71
|
}
|
|
71
72
|
}
|
|
73
|
+
const getEffectiveFullWidth = (containerWidth, fullWidthMode) => {
|
|
74
|
+
if (fullWidthMode) {
|
|
75
|
+
return '100%';
|
|
76
|
+
}
|
|
77
|
+
// There is always padding for renderer, so we don't need padding for it
|
|
78
|
+
const fullWidthPadding = akEditorGutterPadding * 2;
|
|
79
|
+
return `${Math.min(containerWidth - fullWidthPadding, akEditorFullWidthLayoutWidth)}px`;
|
|
80
|
+
};
|
|
81
|
+
const calcMaxWidthWhenResizing = (containerWidth, fullWidthMode, isNestedNode) => {
|
|
82
|
+
if (isNestedNode) {
|
|
83
|
+
return '100%';
|
|
84
|
+
}
|
|
85
|
+
// non-nested node can resize up to full width
|
|
86
|
+
return getEffectiveFullWidth(containerWidth, fullWidthMode);
|
|
87
|
+
};
|
|
88
|
+
const calcMaxWidthWhenNotResizing = (containerWidth, mediaSingleWidth) => {
|
|
89
|
+
return `${Math.min(mediaSingleWidth, containerWidth - akEditorGutterPadding * 2)}px`;
|
|
90
|
+
};
|
|
72
91
|
function calcMargin(layout) {
|
|
73
92
|
switch (layout) {
|
|
74
93
|
case 'wrap-right':
|
|
@@ -100,7 +119,9 @@ export const MediaSingleDimensionHelper = ({
|
|
|
100
119
|
layout,
|
|
101
120
|
pctWidth,
|
|
102
121
|
mediaSingleWidth,
|
|
103
|
-
width
|
|
122
|
+
width,
|
|
123
|
+
isExtendedResizeExperienceOn,
|
|
124
|
+
isNestedNode = false
|
|
104
125
|
}) => css`
|
|
105
126
|
/* For nested rich media items, set max-width to 100% */
|
|
106
127
|
tr &,
|
|
@@ -114,6 +135,28 @@ export const MediaSingleDimensionHelper = ({
|
|
|
114
135
|
min-width: 100%;
|
|
115
136
|
`}
|
|
116
137
|
max-width: ${calcMaxWidth(layout, containerWidth)};
|
|
138
|
+
&[class*='is-resizing'] {
|
|
139
|
+
${isExtendedResizeExperienceOn && `max-width: ${calcMaxWidthWhenResizing(containerWidth, fullWidthMode, isNestedNode)};
|
|
140
|
+
|
|
141
|
+
${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
|
|
142
|
+
transform: translateX(-50%);`}
|
|
143
|
+
|
|
144
|
+
.new-file-experience-wrapper {
|
|
145
|
+
box-shadow: none;
|
|
146
|
+
}`}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* Handles responsiveness of non-nested, not-resizing nodes in editor */
|
|
150
|
+
&[class*='not-resizing'] {
|
|
151
|
+
${!isNestedNode && `max-width: ${layout !== 'full-width' && mediaSingleWidth && calcMaxWidthWhenNotResizing(containerWidth, mediaSingleWidth)};
|
|
152
|
+
|
|
153
|
+
${nonWrappedLayouts.includes(layout) && `margin-left: 50%;
|
|
154
|
+
transform: translateX(-50%);`}
|
|
155
|
+
|
|
156
|
+
// override min-width to counteract max-width set in old experience
|
|
157
|
+
${layout === 'full-width' && `min-width: ${getEffectiveFullWidth(containerWidth, fullWidthMode)} !important;`};`}
|
|
158
|
+
}
|
|
159
|
+
|
|
117
160
|
float: ${float(layout)};
|
|
118
161
|
margin: ${calcMargin(layout)};
|
|
119
162
|
${isImageAligned(layout)};
|
package/dist/es2019/ui/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as Caption } from './Caption';
|
|
2
|
-
export { default as MediaSingle, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, IMAGE_AND_BORDER_ADJUSTMENT
|
|
2
|
+
export { default as MediaSingle, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, IMAGE_AND_BORDER_ADJUSTMENT } from './MediaSingle';
|
|
3
3
|
export { MediaSingleDimensionHelper } from './MediaSingle/styled';
|
|
4
4
|
export { layoutSupportsWidth, calcPxFromColumns, calcPctFromPx, calcPxFromPct, calcColumnsFromPx, snapToGrid, calcMediaPxWidth, wrappedLayouts } from './MediaSingle/grid';
|
|
5
5
|
export { mediaLinkStyle } from './MediaSingle/link';
|