@atlaskit/editor-common 74.5.2 → 74.7.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 +12 -0
- package/dist/cjs/analytics/index.js +26 -1
- package/dist/cjs/analytics/linking-utils.js +84 -0
- package/dist/cjs/card/MediaAndEmbedsToolbar/index.js +156 -0
- package/dist/cjs/card/index.js +9 -1
- package/dist/cjs/messages/index.js +14 -0
- package/dist/cjs/messages/link-toolbar.js +60 -0
- package/dist/cjs/messages/media-and-embed-toolbar.js +20 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/node-width/index.js +16 -2
- package/dist/cjs/react-node-view/getInlineNodeViewProducer.js +225 -0
- package/dist/cjs/react-node-view/index.js +13 -0
- package/dist/cjs/{ui/Resizer/index.js → resizer/Resizer.js} +6 -3
- package/dist/cjs/{resizer.js → resizer/index.js} +1 -1
- package/dist/cjs/resizer/utils.js +21 -0
- package/dist/cjs/styles/shared/resizer.js +1 -1
- package/dist/cjs/styles/shared/table.js +5 -4
- package/dist/cjs/types/hyperlink.js +5 -0
- package/dist/cjs/types/resizable-media-single.js +5 -0
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/cjs/ui/LinkSearch/const.js +14 -0
- package/dist/cjs/ui/ResizerLegacy/index.js +210 -0
- package/dist/cjs/ui/ResizerLegacy/styled.js +15 -0
- package/dist/cjs/ui/ResizerLegacy/types.js +5 -0
- package/dist/cjs/ui/ResizerLegacy/utils.js +21 -0
- package/dist/cjs/ui/index.js +58 -0
- package/dist/cjs/utils/document.js +258 -0
- package/dist/cjs/utils/editor-core-utils.js +7 -2
- package/dist/cjs/utils/filter/privacy-filter.js +55 -0
- package/dist/cjs/utils/index.js +75 -0
- package/dist/cjs/utils/rich-media-utils.js +131 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +2 -1
- package/dist/es2019/analytics/linking-utils.js +74 -0
- package/dist/es2019/card/MediaAndEmbedsToolbar/index.js +161 -0
- package/dist/es2019/card/index.js +2 -1
- package/dist/es2019/messages/index.js +2 -0
- package/dist/es2019/messages/link-toolbar.js +53 -0
- package/dist/es2019/messages/media-and-embed-toolbar.js +13 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/node-width/index.js +12 -1
- package/dist/es2019/react-node-view/getInlineNodeViewProducer.js +219 -0
- package/dist/es2019/react-node-view/index.js +1 -0
- package/dist/es2019/{ui/Resizer/index.js → resizer/Resizer.js} +5 -3
- package/dist/es2019/resizer/index.js +1 -0
- package/dist/es2019/resizer/utils.js +12 -0
- package/dist/es2019/styles/shared/resizer.js +8 -4
- package/dist/es2019/styles/shared/table.js +5 -4
- package/dist/es2019/types/resizable-media-single.js +1 -0
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/es2019/ui/LinkSearch/const.js +4 -0
- package/dist/es2019/ui/ResizerLegacy/index.js +191 -0
- package/dist/es2019/ui/ResizerLegacy/styled.js +15 -0
- package/dist/es2019/ui/ResizerLegacy/types.js +1 -0
- package/dist/es2019/ui/ResizerLegacy/utils.js +12 -0
- package/dist/es2019/ui/index.js +5 -1
- package/dist/es2019/utils/document.js +253 -0
- package/dist/es2019/utils/editor-core-utils.js +4 -0
- package/dist/es2019/utils/filter/privacy-filter.js +47 -0
- package/dist/es2019/utils/index.js +5 -2
- package/dist/es2019/utils/rich-media-utils.js +109 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +2 -1
- package/dist/esm/analytics/linking-utils.js +74 -0
- package/dist/esm/card/MediaAndEmbedsToolbar/index.js +146 -0
- package/dist/esm/card/index.js +2 -1
- package/dist/esm/messages/index.js +2 -0
- package/dist/esm/messages/link-toolbar.js +53 -0
- package/dist/esm/messages/media-and-embed-toolbar.js +13 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/node-width/index.js +12 -1
- package/dist/esm/react-node-view/getInlineNodeViewProducer.js +215 -0
- package/dist/esm/react-node-view/index.js +1 -0
- package/dist/esm/{ui/Resizer/index.js → resizer/Resizer.js} +6 -3
- package/dist/esm/resizer/index.js +1 -0
- package/dist/esm/resizer/types.js +1 -0
- package/dist/esm/resizer/utils.js +12 -0
- package/dist/esm/styles/shared/resizer.js +1 -1
- package/dist/esm/styles/shared/table.js +5 -4
- package/dist/esm/types/hyperlink.js +1 -0
- package/dist/esm/types/resizable-media-single.js +1 -0
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/esm/ui/LinkSearch/const.js +4 -0
- package/dist/esm/ui/ResizerLegacy/index.js +203 -0
- package/dist/esm/ui/ResizerLegacy/styled.js +7 -0
- package/dist/esm/ui/ResizerLegacy/types.js +1 -0
- package/dist/esm/ui/ResizerLegacy/utils.js +12 -0
- package/dist/esm/ui/index.js +5 -1
- package/dist/esm/utils/document.js +246 -0
- package/dist/esm/utils/editor-core-utils.js +4 -0
- package/dist/esm/utils/filter/privacy-filter.js +48 -0
- package/dist/esm/utils/index.js +5 -2
- package/dist/esm/utils/rich-media-utils.js +118 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/index.d.ts +2 -0
- package/dist/types/analytics/linking-utils.d.ts +14 -0
- package/dist/types/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types/card/index.d.ts +1 -0
- package/dist/types/messages/index.d.ts +2 -0
- package/dist/types/messages/link-toolbar.d.ts +52 -0
- package/dist/types/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types/node-width/index.d.ts +7 -0
- package/dist/types/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types/react-node-view/index.d.ts +3 -0
- package/dist/types/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +1 -0
- package/dist/types/resizer/index.d.ts +2 -0
- package/dist/types/resizer/utils.d.ts +6 -0
- package/dist/types/styles/shared/table.d.ts +2 -1
- package/dist/types/types/hyperlink.d.ts +35 -0
- package/dist/types/types/index.d.ts +2 -0
- package/dist/types/types/resizable-media-single.d.ts +15 -0
- package/dist/types/ui/DropList/index.d.ts +1 -1
- package/dist/types/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types/ui/index.d.ts +6 -0
- package/dist/types/utils/document.d.ts +19 -0
- package/dist/types/utils/editor-core-utils.d.ts +1 -0
- package/dist/types/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types/utils/index.d.ts +4 -1
- package/dist/types/utils/rich-media-utils.d.ts +8 -0
- package/dist/types-ts4.5/analytics/index.d.ts +2 -0
- package/dist/types-ts4.5/analytics/linking-utils.d.ts +14 -0
- package/dist/types-ts4.5/card/MediaAndEmbedsToolbar/index.d.ts +11 -0
- package/dist/types-ts4.5/card/index.d.ts +1 -0
- package/dist/types-ts4.5/messages/index.d.ts +2 -0
- package/dist/types-ts4.5/messages/link-toolbar.d.ts +52 -0
- package/dist/types-ts4.5/messages/media-and-embed-toolbar.d.ts +12 -0
- package/dist/types-ts4.5/node-width/index.d.ts +7 -0
- package/dist/types-ts4.5/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types-ts4.5/react-node-view/index.d.ts +3 -0
- package/dist/types-ts4.5/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +1 -0
- package/dist/types-ts4.5/resizer/index.d.ts +2 -0
- package/dist/types-ts4.5/resizer/utils.d.ts +6 -0
- package/dist/types-ts4.5/styles/shared/table.d.ts +2 -1
- package/dist/types-ts4.5/types/hyperlink.d.ts +35 -0
- package/dist/types-ts4.5/types/index.d.ts +2 -0
- package/dist/types-ts4.5/types/resizable-media-single.d.ts +15 -0
- package/dist/types-ts4.5/ui/DropList/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/LinkSearch/const.d.ts +4 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/index.d.ts +40 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/styled.d.ts +2 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/types.d.ts +26 -0
- package/dist/types-ts4.5/ui/ResizerLegacy/utils.d.ts +6 -0
- package/dist/types-ts4.5/ui/index.d.ts +6 -0
- package/dist/types-ts4.5/utils/document.d.ts +19 -0
- package/dist/types-ts4.5/utils/editor-core-utils.d.ts +1 -0
- package/dist/types-ts4.5/utils/filter/privacy-filter.d.ts +9 -0
- package/dist/types-ts4.5/utils/index.d.ts +4 -1
- package/dist/types-ts4.5/utils/rich-media-utils.d.ts +8 -0
- package/package.json +9 -9
- package/resizer/package.json +5 -5
- package/dist/cjs/ui/Resizer/utils.js +0 -8
- package/dist/es2019/resizer.js +0 -1
- package/dist/es2019/ui/Resizer/utils.js +0 -1
- package/dist/esm/resizer.js +0 -1
- package/dist/esm/ui/Resizer/utils.js +0 -1
- package/dist/types/resizer.d.ts +0 -2
- package/dist/types/ui/Resizer/utils.d.ts +0 -1
- package/dist/types-ts4.5/resizer.d.ts +0 -2
- package/dist/types-ts4.5/ui/Resizer/utils.d.ts +0 -1
- /package/dist/cjs/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/es2019/{ui/Resizer → resizer}/types.js +0 -0
- /package/dist/{esm/ui/Resizer/types.js → es2019/types/hyperlink.js} +0 -0
- /package/dist/types/{ui/Resizer → resizer}/types.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/Resizer → resizer}/types.d.ts +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.alignAttributes = void 0;
|
|
8
|
+
exports.calculateSnapPoints = calculateSnapPoints;
|
|
9
|
+
exports.nonWrappedLayouts = exports.isRichMediaInsideOfBlockNode = exports.floatingLayouts = void 0;
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
var _prosemirrorUtils = require("prosemirror-utils");
|
|
12
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _MediaSingle = require("../ui/MediaSingle");
|
|
14
|
+
var _grid = require("../ui/MediaSingle/grid");
|
|
15
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
|
+
var nonWrappedLayouts = ['center', 'wide', 'full-width'];
|
|
18
|
+
exports.nonWrappedLayouts = nonWrappedLayouts;
|
|
19
|
+
var floatingLayouts = ['wrap-left', 'wrap-right'];
|
|
20
|
+
exports.floatingLayouts = floatingLayouts;
|
|
21
|
+
var isRichMediaInsideOfBlockNode = function isRichMediaInsideOfBlockNode(view, pos) {
|
|
22
|
+
if (typeof pos !== 'number' || isNaN(pos) || !view) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
var $pos = view.state.doc.resolve(pos);
|
|
26
|
+
var _view$state$schema$no = view.state.schema.nodes,
|
|
27
|
+
expand = _view$state$schema$no.expand,
|
|
28
|
+
nestedExpand = _view$state$schema$no.nestedExpand,
|
|
29
|
+
layoutColumn = _view$state$schema$no.layoutColumn;
|
|
30
|
+
return !!(0, _prosemirrorUtils.findParentNodeOfTypeClosestToPos)($pos, [expand, nestedExpand, layoutColumn]);
|
|
31
|
+
};
|
|
32
|
+
exports.isRichMediaInsideOfBlockNode = isRichMediaInsideOfBlockNode;
|
|
33
|
+
var alignAttributes = function alignAttributes(layout, oldAttrs) {
|
|
34
|
+
var gridSize = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
|
|
35
|
+
var originalWidth = arguments.length > 3 ? arguments[3] : undefined;
|
|
36
|
+
var lineLength = arguments.length > 4 ? arguments[4] : undefined;
|
|
37
|
+
var width = oldAttrs.width;
|
|
38
|
+
var oldLayout = oldAttrs.layout;
|
|
39
|
+
var oldLayoutIsNonWrapped = nonWrappedLayouts.indexOf(oldLayout) > -1;
|
|
40
|
+
var newLayoutIsNonWrapped = nonWrappedLayouts.indexOf(layout) > -1;
|
|
41
|
+
var newLayoutIsWrapped = _grid.wrappedLayouts.indexOf(layout) > -1;
|
|
42
|
+
var oldLayoutIsWrapped = _grid.wrappedLayouts.indexOf(oldLayout) > -1;
|
|
43
|
+
if (oldLayoutIsNonWrapped && (0, _MediaSingle.shouldAddDefaultWrappedWidth)(layout, originalWidth, lineLength)) {
|
|
44
|
+
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
45
|
+
if (!width || width >= 100 || oldLayout !== 'center' // == 'full-width' or 'wide'
|
|
46
|
+
) {
|
|
47
|
+
width = 50;
|
|
48
|
+
}
|
|
49
|
+
} else if (layout !== oldLayout && ['full-width', 'wide'].indexOf(oldLayout) > -1) {
|
|
50
|
+
// 'full-width' -> 'center' or 'wide'
|
|
51
|
+
// 'wide' -> 'center' or 'full-width'
|
|
52
|
+
// unset width
|
|
53
|
+
width = undefined;
|
|
54
|
+
} else if (width) {
|
|
55
|
+
var cols = Math.round(width / 100 * gridSize);
|
|
56
|
+
var targetCols = cols;
|
|
57
|
+
if (oldLayoutIsWrapped && newLayoutIsNonWrapped) {
|
|
58
|
+
// wrap -> center needs to align to even grid
|
|
59
|
+
targetCols = Math.floor(targetCols / 2) * 2;
|
|
60
|
+
width = undefined;
|
|
61
|
+
} else if (oldLayoutIsNonWrapped && newLayoutIsWrapped) {
|
|
62
|
+
// Can be here only if
|
|
63
|
+
// 'full-width' or 'wide' or 'center' -> 'wrap-left' or 'wrap-right' or 'align-end' or 'align-start'
|
|
64
|
+
// AND
|
|
65
|
+
// !originalWidth || !lineLength || small image
|
|
66
|
+
// AND
|
|
67
|
+
// width defined!
|
|
68
|
+
|
|
69
|
+
// cannot resize to full column width, and cannot resize to 1 column
|
|
70
|
+
if (cols <= 1) {
|
|
71
|
+
targetCols = 2;
|
|
72
|
+
} else if (cols >= gridSize) {
|
|
73
|
+
targetCols = 10;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (targetCols !== cols) {
|
|
77
|
+
width = targetCols / gridSize * 100;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return _objectSpread(_objectSpread({}, oldAttrs), {}, {
|
|
81
|
+
layout: layout,
|
|
82
|
+
width: width
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
exports.alignAttributes = alignAttributes;
|
|
86
|
+
function calculateSnapPoints(_ref) {
|
|
87
|
+
var $pos = _ref.$pos,
|
|
88
|
+
akEditorWideLayoutWidth = _ref.akEditorWideLayoutWidth,
|
|
89
|
+
allowBreakoutSnapPoints = _ref.allowBreakoutSnapPoints,
|
|
90
|
+
containerWidth = _ref.containerWidth,
|
|
91
|
+
gridSize = _ref.gridSize,
|
|
92
|
+
gridWidth = _ref.gridWidth,
|
|
93
|
+
insideInlineLike = _ref.insideInlineLike,
|
|
94
|
+
insideLayout = _ref.insideLayout,
|
|
95
|
+
isVideoFile = _ref.isVideoFile,
|
|
96
|
+
lineLength = _ref.lineLength,
|
|
97
|
+
offsetLeft = _ref.offsetLeft,
|
|
98
|
+
wrappedLayout = _ref.wrappedLayout;
|
|
99
|
+
var snapTargets = [];
|
|
100
|
+
for (var i = 0; i < gridWidth; i++) {
|
|
101
|
+
var pxFromColumns = (0, _grid.calcPxFromColumns)(i, lineLength, gridWidth);
|
|
102
|
+
snapTargets.push(insideLayout ? pxFromColumns : pxFromColumns - offsetLeft);
|
|
103
|
+
}
|
|
104
|
+
// full width
|
|
105
|
+
snapTargets.push(lineLength - offsetLeft);
|
|
106
|
+
var columns = wrappedLayout || insideInlineLike ? 1 : 2;
|
|
107
|
+
var minimumWidth = (0, _grid.calcPxFromColumns)(columns, lineLength, gridSize);
|
|
108
|
+
var snapPoints = snapTargets.filter(function (width) {
|
|
109
|
+
return width >= minimumWidth;
|
|
110
|
+
});
|
|
111
|
+
if (!$pos) {
|
|
112
|
+
return snapPoints;
|
|
113
|
+
}
|
|
114
|
+
snapPoints = isVideoFile ? snapPoints.filter(function (width) {
|
|
115
|
+
return width > 320;
|
|
116
|
+
}) : snapPoints;
|
|
117
|
+
var isTopLevel = $pos.parent.type.name === 'doc';
|
|
118
|
+
if (isTopLevel && allowBreakoutSnapPoints) {
|
|
119
|
+
snapPoints.push(akEditorWideLayoutWidth);
|
|
120
|
+
var fullWidthPoint = containerWidth - _editorSharedStyles.akEditorBreakoutPadding;
|
|
121
|
+
if (fullWidthPoint > akEditorWideLayoutWidth) {
|
|
122
|
+
snapPoints.push(fullWidthPoint);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// EDM-1107: Ensure new snapPoints are sorted with existing points
|
|
127
|
+
snapPoints = snapPoints.sort(function (a, b) {
|
|
128
|
+
return a - b;
|
|
129
|
+
});
|
|
130
|
+
return snapPoints;
|
|
131
|
+
}
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, BROWSER_FREEZE_INTERACTION_TYPE, CONTENT_COMPONENT, DELETE_DIRECTION, EVENT_TYPE, FLOATING_CONTROLS_TITLE, FULL_WIDTH_MODE, GAP_CURSOR_POSITION, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, LAYOUT_TYPE, LINK_REPRESENTATION, LINK_RESOURCE, LINK_STATUS, LIST_TEXT_SCENARIOS, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST, OUTDENT_SCENARIOS, MODE, PLATFORMS, PUNC, PasteContents, PasteSources, PasteTypes, RESOLVE_METHOD, SELECTION_TYPE, SELECTION_POSITION, SMART_LINK_TYPE, SYMBOL, SmartLinkNodeContexts, TABLE_ACTION, TABLE_BREAKOUT, TARGET_SELECTION_SOURCE, TOOLBAR_ACTION_SUBJECT_ID, TRIGGER_METHOD, USER_CONTEXT } from './types';
|
|
2
2
|
export { fireAnalyticsEvent } from './fire-analytics-event';
|
|
3
|
-
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
3
|
+
export { getAnalyticsEventsFromTransaction } from './utils';
|
|
4
|
+
export { buildEditLinkPayload, buildVisitedLinkPayload, buildOpenedSettingsPayload, unlinkPayload } from './linking-utils';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from './types';
|
|
2
|
+
export const buildEditLinkPayload = type => {
|
|
3
|
+
return {
|
|
4
|
+
action: ACTION.CLICKED,
|
|
5
|
+
actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
|
|
6
|
+
actionSubjectId: ACTION_SUBJECT_ID.EDIT_LINK,
|
|
7
|
+
attributes: type !== ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
8
|
+
display: type
|
|
9
|
+
} : {},
|
|
10
|
+
eventType: EVENT_TYPE.UI
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const mapLinkTypeToCardAppearance = type => {
|
|
14
|
+
switch (type) {
|
|
15
|
+
case ACTION_SUBJECT_ID.CARD_INLINE:
|
|
16
|
+
{
|
|
17
|
+
return 'inline';
|
|
18
|
+
}
|
|
19
|
+
case ACTION_SUBJECT_ID.CARD_BLOCK:
|
|
20
|
+
{
|
|
21
|
+
return 'block';
|
|
22
|
+
}
|
|
23
|
+
case ACTION_SUBJECT_ID.EMBEDS:
|
|
24
|
+
{
|
|
25
|
+
return 'embed';
|
|
26
|
+
}
|
|
27
|
+
default:
|
|
28
|
+
{
|
|
29
|
+
return 'url';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const buildVisitedLinkPayload = type => {
|
|
34
|
+
return type === ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
35
|
+
action: ACTION.VISITED,
|
|
36
|
+
actionSubject: ACTION_SUBJECT.HYPERLINK,
|
|
37
|
+
actionSubjectId: undefined,
|
|
38
|
+
attributes: {
|
|
39
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
40
|
+
},
|
|
41
|
+
eventType: EVENT_TYPE.TRACK
|
|
42
|
+
} : {
|
|
43
|
+
action: ACTION.VISITED,
|
|
44
|
+
actionSubject: ACTION_SUBJECT.SMART_LINK,
|
|
45
|
+
actionSubjectId: type,
|
|
46
|
+
attributes: {
|
|
47
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
48
|
+
},
|
|
49
|
+
eventType: EVENT_TYPE.TRACK
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export const buildOpenedSettingsPayload = type => {
|
|
53
|
+
return {
|
|
54
|
+
action: ACTION.CLICKED,
|
|
55
|
+
actionSubject: ACTION_SUBJECT.BUTTON,
|
|
56
|
+
actionSubjectId: ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
|
|
57
|
+
attributes: {
|
|
58
|
+
inputMethod: INPUT_METHOD.TOOLBAR,
|
|
59
|
+
display: mapLinkTypeToCardAppearance(type)
|
|
60
|
+
},
|
|
61
|
+
eventType: EVENT_TYPE.UI
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const unlinkPayload = type => {
|
|
65
|
+
return {
|
|
66
|
+
action: ACTION.UNLINK,
|
|
67
|
+
actionSubject: type === ACTION_SUBJECT_ID.HYPERLINK ? ACTION_SUBJECT.HYPERLINK : ACTION_SUBJECT.SMART_LINK,
|
|
68
|
+
actionSubjectId: type === ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
|
|
69
|
+
attributes: {
|
|
70
|
+
inputMethod: INPUT_METHOD.TOOLBAR
|
|
71
|
+
},
|
|
72
|
+
eventType: EVENT_TYPE.TRACK
|
|
73
|
+
};
|
|
74
|
+
};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
+
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
3
|
+
import { DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
4
|
+
import EditorAlignImageCenter from '@atlaskit/icon/glyph/editor/align-image-center';
|
|
5
|
+
import EditorAlignImageLeft from '@atlaskit/icon/glyph/editor/align-image-left';
|
|
6
|
+
import EditorAlignImageRight from '@atlaskit/icon/glyph/editor/align-image-right';
|
|
7
|
+
import FullWidthIcon from '@atlaskit/icon/glyph/editor/media-full-width';
|
|
8
|
+
import WideIcon from '@atlaskit/icon/glyph/editor/media-wide';
|
|
9
|
+
import WrapLeftIcon from '@atlaskit/icon/glyph/editor/media-wrap-left';
|
|
10
|
+
import WrapRightIcon from '@atlaskit/icon/glyph/editor/media-wrap-right';
|
|
11
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../analytics';
|
|
12
|
+
import { insideTable } from '../../core-utils';
|
|
13
|
+
import commonMessages, { mediaAndEmbedToolbarMessages as toolbarMessages } from '../../messages';
|
|
14
|
+
import { alignAttributes, isInLayoutColumn } from '../../utils';
|
|
15
|
+
|
|
16
|
+
// Workaround as we don't want to import this package into `editor-common`
|
|
17
|
+
// We'll get type errors if this gets out of sync with `editor-plugin-width`.
|
|
18
|
+
const alignmentIcons = [{
|
|
19
|
+
id: 'editor.media.alignLeft',
|
|
20
|
+
value: 'align-start',
|
|
21
|
+
icon: EditorAlignImageLeft
|
|
22
|
+
}, {
|
|
23
|
+
id: 'editor.media.alignCenter',
|
|
24
|
+
value: 'center',
|
|
25
|
+
icon: EditorAlignImageCenter
|
|
26
|
+
}, {
|
|
27
|
+
id: 'editor.media.alignRight',
|
|
28
|
+
value: 'align-end',
|
|
29
|
+
icon: EditorAlignImageRight
|
|
30
|
+
}];
|
|
31
|
+
const wrappingIcons = [{
|
|
32
|
+
id: 'editor.media.wrapLeft',
|
|
33
|
+
value: 'wrap-left',
|
|
34
|
+
icon: WrapLeftIcon
|
|
35
|
+
}, {
|
|
36
|
+
id: 'editor.media.wrapRight',
|
|
37
|
+
value: 'wrap-right',
|
|
38
|
+
icon: WrapRightIcon
|
|
39
|
+
}];
|
|
40
|
+
const breakoutIcons = [{
|
|
41
|
+
value: 'wide',
|
|
42
|
+
icon: WideIcon
|
|
43
|
+
}, {
|
|
44
|
+
value: 'full-width',
|
|
45
|
+
icon: FullWidthIcon
|
|
46
|
+
}];
|
|
47
|
+
const layoutToMessages = {
|
|
48
|
+
'wrap-left': toolbarMessages.wrapLeft,
|
|
49
|
+
center: commonMessages.alignImageCenter,
|
|
50
|
+
'wrap-right': toolbarMessages.wrapRight,
|
|
51
|
+
wide: commonMessages.layoutWide,
|
|
52
|
+
'full-width': commonMessages.layoutFullWidth,
|
|
53
|
+
'align-end': commonMessages.alignImageRight,
|
|
54
|
+
'align-start': commonMessages.alignImageLeft
|
|
55
|
+
};
|
|
56
|
+
const getNodeWidth = (node, schema) => {
|
|
57
|
+
const {
|
|
58
|
+
embedCard
|
|
59
|
+
} = schema.nodes;
|
|
60
|
+
if (node.type === embedCard) {
|
|
61
|
+
return node.attrs.originalWidth || DEFAULT_EMBED_CARD_WIDTH;
|
|
62
|
+
}
|
|
63
|
+
return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
|
|
64
|
+
};
|
|
65
|
+
const makeAlign = (layout, nodeType, widthPluginDependencyApi, analyticsApi) => {
|
|
66
|
+
return (state, dispatch) => {
|
|
67
|
+
const {
|
|
68
|
+
node
|
|
69
|
+
} = state.selection;
|
|
70
|
+
const {
|
|
71
|
+
layout: previousLayoutType
|
|
72
|
+
} = node.attrs;
|
|
73
|
+
const {
|
|
74
|
+
mediaSingle
|
|
75
|
+
} = state.schema.nodes;
|
|
76
|
+
if (!dispatch) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
|
|
80
|
+
if (!node || node.type !== nodeType || !widthPluginState) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
const nodeWidth = getNodeWidth(node, state.schema);
|
|
84
|
+
const newAttrs = alignAttributes(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
|
|
85
|
+
const tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
|
|
86
|
+
tr.setMeta('scrollIntoView', false);
|
|
87
|
+
// when image captions are enabled, the wrong node gets selected after
|
|
88
|
+
// setNodeMarkup is called
|
|
89
|
+
tr.setSelection(NodeSelection.create(tr.doc, state.selection.from));
|
|
90
|
+
const {
|
|
91
|
+
doc: {
|
|
92
|
+
type: {
|
|
93
|
+
schema: {
|
|
94
|
+
nodes: {
|
|
95
|
+
paragraph
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} = tr;
|
|
101
|
+
|
|
102
|
+
// see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
|
|
103
|
+
if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && (insideTable(state) || isInLayoutColumn(state))) {
|
|
104
|
+
tr.insert(state.selection.to, paragraph.createAndFill());
|
|
105
|
+
}
|
|
106
|
+
analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent({
|
|
107
|
+
eventType: EVENT_TYPE.TRACK,
|
|
108
|
+
action: ACTION.SELECTED,
|
|
109
|
+
actionSubject: ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
|
|
110
|
+
actionSubjectId: ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
|
|
111
|
+
attributes: {
|
|
112
|
+
previousLayoutType,
|
|
113
|
+
currentLayoutType: layout
|
|
114
|
+
}
|
|
115
|
+
})(tr);
|
|
116
|
+
dispatch(tr);
|
|
117
|
+
return true;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
const mapIconsToToolbarItem = (icons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) => icons.map(toolbarItem => {
|
|
121
|
+
const {
|
|
122
|
+
id,
|
|
123
|
+
value
|
|
124
|
+
} = toolbarItem;
|
|
125
|
+
return {
|
|
126
|
+
id: id,
|
|
127
|
+
type: 'button',
|
|
128
|
+
icon: toolbarItem.icon,
|
|
129
|
+
title: intl.formatMessage(layoutToMessages[value]),
|
|
130
|
+
selected: layout === value,
|
|
131
|
+
onClick: makeAlign(value, nodeType, widthPluginDependencyApi, analyticsApi)
|
|
132
|
+
};
|
|
133
|
+
});
|
|
134
|
+
const shouldHideLayoutToolbar = (selection, {
|
|
135
|
+
nodes
|
|
136
|
+
}, allowResizingInTables) => {
|
|
137
|
+
return hasParentNodeOfType([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand, ...(allowResizingInTables ? [] : [nodes.table])].filter(Boolean))(selection);
|
|
138
|
+
};
|
|
139
|
+
const buildLayoutButtons = (state, intl, nodeType, widthPluginDependencyApi, analyticsApi, allowResizing, allowResizingInTables, allowWrapping = true, allowAlignment = true) => {
|
|
140
|
+
const {
|
|
141
|
+
selection
|
|
142
|
+
} = state;
|
|
143
|
+
if (!(selection instanceof NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
const {
|
|
147
|
+
layout
|
|
148
|
+
} = selection.node.attrs;
|
|
149
|
+
const alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
150
|
+
const wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
151
|
+
const breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
152
|
+
const items = [...alignmentToolbarItems, ...getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping), ...wrappingToolbarItems, ...getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing), ...breakOutToolbarItems];
|
|
153
|
+
return items;
|
|
154
|
+
};
|
|
155
|
+
const getSeparatorBetweenAlignmentAndWrapping = (allowAlignment, allowWrapping) => allowAlignment && allowWrapping ? [{
|
|
156
|
+
type: 'separator'
|
|
157
|
+
}] : [];
|
|
158
|
+
const getSeparatorBeforeBreakoutItems = (allowAlignment, allowWrapping, allowResizing) => !allowResizing && (allowAlignment || allowWrapping) ? [{
|
|
159
|
+
type: 'separator'
|
|
160
|
+
}] : [];
|
|
161
|
+
export default buildLayoutButtons;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata } from './utils';
|
|
1
|
+
export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata } from './utils';
|
|
2
|
+
export { default as buildLayoutButtons } from './MediaAndEmbedsToolbar';
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { defineMessages } from 'react-intl-next';
|
|
2
2
|
export { codeBidiWarningMessages } from './codeBidiWarning';
|
|
3
3
|
export { linkMessages } from './link';
|
|
4
|
+
export { linkToolbarMessages } from './link-toolbar';
|
|
4
5
|
export { unsupportedContentMessages } from './unsupportedContent';
|
|
5
6
|
export { codeBlockButtonMessages } from './codeBlockButton';
|
|
6
7
|
export { toolbarInsertBlockMessages } from './insert-block';
|
|
8
|
+
export { toolbarMessages as mediaAndEmbedToolbarMessages } from './media-and-embed-toolbar';
|
|
7
9
|
export default defineMessages({
|
|
8
10
|
layoutFixedWidth: {
|
|
9
11
|
id: 'fabric.editor.layoutFixedWidth',
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const linkToolbarMessages = defineMessages({
|
|
3
|
+
addLink: {
|
|
4
|
+
id: 'fabric.editor.mediaAddLink',
|
|
5
|
+
defaultMessage: 'Add link',
|
|
6
|
+
description: 'Add link'
|
|
7
|
+
},
|
|
8
|
+
unableToOpenLink: {
|
|
9
|
+
id: 'fabric.editor.unableToOpenLink',
|
|
10
|
+
defaultMessage: 'Unable to open this link',
|
|
11
|
+
description: 'Unable to open this link'
|
|
12
|
+
},
|
|
13
|
+
unlink: {
|
|
14
|
+
id: 'fabric.editor.unlink',
|
|
15
|
+
defaultMessage: 'Unlink',
|
|
16
|
+
description: 'Removes the hyperlink but keeps your text.'
|
|
17
|
+
},
|
|
18
|
+
editLink: {
|
|
19
|
+
id: 'fabric.editor.editLink',
|
|
20
|
+
defaultMessage: 'Edit link',
|
|
21
|
+
description: 'Edit the link, update display text'
|
|
22
|
+
},
|
|
23
|
+
placeholder: {
|
|
24
|
+
id: 'fabric.editor.hyperlinkToolbarPlaceholder',
|
|
25
|
+
defaultMessage: 'Paste or search for link',
|
|
26
|
+
description: 'Paste or search for link'
|
|
27
|
+
},
|
|
28
|
+
linkPlaceholder: {
|
|
29
|
+
id: 'fabric.editor.linkPlaceholder',
|
|
30
|
+
defaultMessage: 'Paste link',
|
|
31
|
+
description: 'Create a new link by pasting a URL.'
|
|
32
|
+
},
|
|
33
|
+
linkAddress: {
|
|
34
|
+
id: 'fabric.editor.linkAddress',
|
|
35
|
+
defaultMessage: 'Link address',
|
|
36
|
+
description: 'Insert the address of the link'
|
|
37
|
+
},
|
|
38
|
+
invalidLink: {
|
|
39
|
+
id: 'fabric.editor.invalidLink',
|
|
40
|
+
defaultMessage: 'Please enter a valid link.',
|
|
41
|
+
description: 'Please enter a valid link.'
|
|
42
|
+
},
|
|
43
|
+
emptyLink: {
|
|
44
|
+
id: 'fabric.editor.emptyLink',
|
|
45
|
+
defaultMessage: 'Please enter a link.',
|
|
46
|
+
description: 'Please enter a link.'
|
|
47
|
+
},
|
|
48
|
+
settingsLink: {
|
|
49
|
+
id: 'fabric.editor.settingsLinks',
|
|
50
|
+
defaultMessage: 'Go to Link Preferences',
|
|
51
|
+
description: 'Go to Link Preferences'
|
|
52
|
+
}
|
|
53
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const toolbarMessages = defineMessages({
|
|
3
|
+
wrapLeft: {
|
|
4
|
+
id: 'fabric.editor.wrapLeft',
|
|
5
|
+
defaultMessage: 'Wrap left',
|
|
6
|
+
description: 'Aligns your image to the left and wraps text around it.'
|
|
7
|
+
},
|
|
8
|
+
wrapRight: {
|
|
9
|
+
id: 'fabric.editor.wrapRight',
|
|
10
|
+
defaultMessage: 'Wrap right',
|
|
11
|
+
description: 'Aligns your image to the right and wraps text around it.'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
@@ -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.7.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,10 +1,15 @@
|
|
|
1
1
|
import { findParentNodeOfTypeClosestToPos } from 'prosemirror-utils';
|
|
2
|
-
import { akEditorFullWidthLayoutWidth, akLayoutGutterOffset, gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
|
|
2
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideLayoutWidth, akLayoutGutterOffset, gridMediumMaxWidth } from '@atlaskit/editor-shared-styles';
|
|
3
3
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
4
4
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
5
5
|
import { BODIED_EXT_PADDING } from '../styles/shared/extension';
|
|
6
6
|
import { LAYOUT_COLUMN_PADDING, LAYOUT_SECTION_MARGIN } from '../styles/shared/layout';
|
|
7
7
|
import { absoluteBreakoutWidth } from '../utils/breakout';
|
|
8
|
+
export const layoutToWidth = {
|
|
9
|
+
default: akEditorDefaultLayoutWidth,
|
|
10
|
+
wide: akEditorWideLayoutWidth,
|
|
11
|
+
'full-width': akEditorFullWidthLayoutWidth
|
|
12
|
+
};
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* Calculates width of parent node of a nested node (inside layouts, extension)
|
|
@@ -78,4 +83,10 @@ const getNestedParentNode = (tablePos, state) => {
|
|
|
78
83
|
};
|
|
79
84
|
const calcBreakoutNodeWidth = (layout, containerWidth, isFullWidthModeEnabled) => {
|
|
80
85
|
return isFullWidthModeEnabled ? Math.min(containerWidth.lineLength, akEditorFullWidthLayoutWidth) : absoluteBreakoutWidth(layout, containerWidth.width);
|
|
86
|
+
};
|
|
87
|
+
export const getTableContainerWidth = node => {
|
|
88
|
+
if (node.attrs.width) {
|
|
89
|
+
return node.attrs.width;
|
|
90
|
+
}
|
|
91
|
+
return layoutToWidth[node.attrs.layout];
|
|
81
92
|
};
|