@atlaskit/editor-plugin-media 3.2.0 → 4.1.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 +22 -0
- package/dist/cjs/nodeviews/mediaGroup.js +16 -323
- package/dist/cjs/nodeviews/mediaNodeView/media.js +15 -6
- package/dist/cjs/nodeviews/mediaSingle.js +47 -593
- package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +2 -3
- package/dist/cjs/pm-plugins/pixel-resizing/ui/pixel-entry.js +1 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +67 -649
- package/dist/cjs/ui/toolbar/alt-text.js +1 -2
- package/dist/cjs/ui/toolbar/index.js +7 -15
- package/dist/cjs/ui/toolbar/linking.js +3 -4
- package/dist/cjs/ui/toolbar/mediaInline.js +3 -7
- package/dist/cjs/ui/toolbar/pixel-resizing.js +1 -5
- package/dist/es2019/nodeviews/mediaGroup.js +1 -272
- package/dist/es2019/nodeviews/mediaNodeView/media.js +14 -5
- package/dist/es2019/nodeviews/mediaSingle.js +6 -477
- package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +2 -3
- package/dist/es2019/pm-plugins/pixel-resizing/ui/pixel-entry.js +1 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -510
- package/dist/es2019/ui/toolbar/alt-text.js +1 -2
- package/dist/es2019/ui/toolbar/index.js +7 -15
- package/dist/es2019/ui/toolbar/linking.js +3 -4
- package/dist/es2019/ui/toolbar/mediaInline.js +3 -7
- package/dist/es2019/ui/toolbar/pixel-resizing.js +1 -5
- package/dist/esm/nodeviews/mediaGroup.js +15 -322
- package/dist/esm/nodeviews/mediaNodeView/media.js +15 -6
- package/dist/esm/nodeviews/mediaSingle.js +47 -593
- package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +2 -3
- package/dist/esm/pm-plugins/pixel-resizing/ui/pixel-entry.js +1 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +64 -650
- package/dist/esm/ui/toolbar/alt-text.js +1 -2
- package/dist/esm/ui/toolbar/index.js +7 -15
- package/dist/esm/ui/toolbar/linking.js +3 -4
- package/dist/esm/ui/toolbar/mediaInline.js +3 -7
- package/dist/esm/ui/toolbar/pixel-resizing.js +1 -5
- package/dist/types/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types/nodeviews/mediaGroup.d.ts +2 -23
- package/dist/types/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types/nodeviews/mediaSingle.d.ts +2 -38
- package/dist/types/nodeviews/mediaSingleNext.d.ts +1 -2
- package/dist/types-ts4.5/nodeviews/__mocks__/mediaNodeUpdater.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/mediaGroup.d.ts +2 -23
- package/dist/types-ts4.5/nodeviews/mediaNodeView/media.d.ts +1 -0
- package/dist/types-ts4.5/nodeviews/mediaSingle.d.ts +2 -38
- package/dist/types-ts4.5/nodeviews/mediaSingleNext.d.ts +1 -2
- package/package.json +14 -23
|
@@ -1,557 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports.
|
|
9
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
11
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
|
+
exports.ReactMediaSingleNode = void 0;
|
|
13
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
14
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
16
11
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
17
13
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
18
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
var _react =
|
|
15
|
+
var _react = require("react");
|
|
20
16
|
var _react2 = require("@emotion/react");
|
|
21
17
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
22
|
-
var _media = require("@atlaskit/editor-common/media");
|
|
23
|
-
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
24
18
|
var _providerFactory = require("@atlaskit/editor-common/provider-factory");
|
|
25
19
|
var _reactNodeView = _interopRequireDefault(require("@atlaskit/editor-common/react-node-view"));
|
|
26
|
-
var _ui = require("@atlaskit/editor-common/ui");
|
|
27
20
|
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
28
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
29
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
30
|
-
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
31
|
-
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
32
|
-
var _mediaClient = require("@atlaskit/media-client");
|
|
33
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
34
23
|
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
35
|
-
var _captions = require("../pm-plugins/commands/captions");
|
|
36
24
|
var _main = require("../pm-plugins/main");
|
|
37
|
-
var _mediaCommon = require("../pm-plugins/utils/media-common");
|
|
38
|
-
var _CaptionPlaceholder = require("../ui/CaptionPlaceholder");
|
|
39
|
-
var _CommentBadge = require("../ui/CommentBadge");
|
|
40
|
-
var _ResizableMediaSingle = _interopRequireDefault(require("../ui/ResizableMediaSingle"));
|
|
41
|
-
var _ResizableMediaSingleNext = _interopRequireDefault(require("../ui/ResizableMediaSingle/ResizableMediaSingleNext"));
|
|
42
|
-
var _helpers = require("./helpers");
|
|
43
|
-
var _mediaNodeUpdater = require("./mediaNodeUpdater");
|
|
44
25
|
var _mediaSingleNext = require("./mediaSingleNext");
|
|
45
|
-
var _styles = require("./styles");
|
|
46
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
47
|
-
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
|
|
48
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
49
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
50
26
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
51
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
27
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
28
|
+
function _superPropGet(t, o, e, r) { var p = (0, _get2.default)((0, _getPrototypeOf2.default)(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; } /**
|
|
52
29
|
* @jsxRuntime classic
|
|
53
30
|
* @jsx jsx
|
|
54
31
|
* @jsxFrag
|
|
55
32
|
*/ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
56
|
-
var figureWrapperStyles = (0, _react2.css)({
|
|
57
|
-
margin: 0
|
|
58
|
-
});
|
|
59
|
-
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
60
|
-
/*
|
|
61
|
-
* @deprecated Please use the MediaSingleNodeNext
|
|
62
|
-
*/
|
|
63
|
-
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
64
|
-
var MediaSingleNode = exports.default = /*#__PURE__*/function (_Component) {
|
|
65
|
-
function MediaSingleNode() {
|
|
66
|
-
var _this;
|
|
67
|
-
(0, _classCallCheck2.default)(this, MediaSingleNode);
|
|
68
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
|
-
args[_key] = arguments[_key];
|
|
70
|
-
}
|
|
71
|
-
_this = _callSuper(this, MediaSingleNode, [].concat(args));
|
|
72
|
-
(0, _defineProperty2.default)(_this, "mediaNodeUpdater", null);
|
|
73
|
-
(0, _defineProperty2.default)(_this, "state", {
|
|
74
|
-
width: undefined,
|
|
75
|
-
height: undefined,
|
|
76
|
-
viewMediaClientConfig: undefined,
|
|
77
|
-
isCopying: false
|
|
78
|
-
});
|
|
79
|
-
(0, _defineProperty2.default)(_this, "mediaSingleWrapperRef", /*#__PURE__*/_react.default.createRef());
|
|
80
|
-
// platform_editor_typography_ugc clean up
|
|
81
|
-
// remove HTMLSpanElement type
|
|
82
|
-
(0, _defineProperty2.default)(_this, "captionPlaceHolderRef", /*#__PURE__*/_react.default.createRef());
|
|
83
|
-
(0, _defineProperty2.default)(_this, "createOrUpdateMediaNodeUpdater", function (props) {
|
|
84
|
-
var node = _this.props.node.firstChild;
|
|
85
|
-
var updaterProps = _objectSpread(_objectSpread({}, props), {}, {
|
|
86
|
-
isMediaSingle: true,
|
|
87
|
-
node: node ? node : _this.props.node,
|
|
88
|
-
dispatchAnalyticsEvent: _this.props.dispatchAnalyticsEvent
|
|
89
|
-
});
|
|
90
|
-
if (!_this.mediaNodeUpdater) {
|
|
91
|
-
_this.mediaNodeUpdater = new _mediaNodeUpdater.MediaNodeUpdater(updaterProps);
|
|
92
|
-
} else {
|
|
93
|
-
var _this$mediaNodeUpdate;
|
|
94
|
-
(_this$mediaNodeUpdate = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate === void 0 || _this$mediaNodeUpdate.setProps(updaterProps);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
(0, _defineProperty2.default)(_this, "setViewMediaClientConfig", /*#__PURE__*/function () {
|
|
98
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(props) {
|
|
99
|
-
var mediaProvider, viewMediaClientConfig;
|
|
100
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
101
|
-
while (1) switch (_context.prev = _context.next) {
|
|
102
|
-
case 0:
|
|
103
|
-
_context.next = 2;
|
|
104
|
-
return props.mediaProvider;
|
|
105
|
-
case 2:
|
|
106
|
-
mediaProvider = _context.sent;
|
|
107
|
-
if (mediaProvider) {
|
|
108
|
-
viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
109
|
-
_this.setState({
|
|
110
|
-
viewMediaClientConfig: viewMediaClientConfig
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
case 4:
|
|
114
|
-
case "end":
|
|
115
|
-
return _context.stop();
|
|
116
|
-
}
|
|
117
|
-
}, _callee);
|
|
118
|
-
}));
|
|
119
|
-
return function (_x) {
|
|
120
|
-
return _ref.apply(this, arguments);
|
|
121
|
-
};
|
|
122
|
-
}());
|
|
123
|
-
(0, _defineProperty2.default)(_this, "updateMediaNodeAttributes", /*#__PURE__*/function () {
|
|
124
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(props) {
|
|
125
|
-
var _this$mediaNodeUpdate2, _this$props$node$firs, _this$mediaNodeUpdate4, _this$mediaNodeUpdate6;
|
|
126
|
-
var addPendingTask, node, updatedDimensions, currentAttrs, _this$mediaNodeUpdate3, updatingNode, contextId, _this$mediaNodeUpdate5, shouldNodeBeDeepCopied, copyNode;
|
|
127
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
128
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
129
|
-
case 0:
|
|
130
|
-
_this.createOrUpdateMediaNodeUpdater(props);
|
|
131
|
-
addPendingTask = _this.props.addPendingTask;
|
|
132
|
-
if (addPendingTask) {
|
|
133
|
-
_context2.next = 4;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
return _context2.abrupt("return");
|
|
137
|
-
case 4:
|
|
138
|
-
// we want the first child of MediaSingle (type "media")
|
|
139
|
-
node = _this.props.node.firstChild;
|
|
140
|
-
if (node) {
|
|
141
|
-
_context2.next = 7;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
return _context2.abrupt("return");
|
|
145
|
-
case 7:
|
|
146
|
-
_context2.next = 9;
|
|
147
|
-
return (_this$mediaNodeUpdate2 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate2 === void 0 ? void 0 : _this$mediaNodeUpdate2.getRemoteDimensions();
|
|
148
|
-
case 9:
|
|
149
|
-
updatedDimensions = _context2.sent;
|
|
150
|
-
currentAttrs = (_this$props$node$firs = _this.props.node.firstChild) === null || _this$props$node$firs === void 0 ? void 0 : _this$props$node$firs.attrs;
|
|
151
|
-
if (updatedDimensions && ((currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.width) !== updatedDimensions.width || (currentAttrs === null || currentAttrs === void 0 ? void 0 : currentAttrs.height) !== updatedDimensions.height)) {
|
|
152
|
-
(_this$mediaNodeUpdate3 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate3 === void 0 || _this$mediaNodeUpdate3.updateDimensions(updatedDimensions);
|
|
153
|
-
}
|
|
154
|
-
if (!(node.attrs.type === 'external' && node.attrs.__external)) {
|
|
155
|
-
_context2.next = 18;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
// Ignored via go/ees005
|
|
159
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
160
|
-
updatingNode = _this.mediaNodeUpdater.handleExternalMedia(_this.props.getPos);
|
|
161
|
-
addPendingTask(updatingNode);
|
|
162
|
-
_context2.next = 17;
|
|
163
|
-
return updatingNode;
|
|
164
|
-
case 17:
|
|
165
|
-
return _context2.abrupt("return");
|
|
166
|
-
case 18:
|
|
167
|
-
contextId = (_this$mediaNodeUpdate4 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate4 === void 0 ? void 0 : _this$mediaNodeUpdate4.getNodeContextId();
|
|
168
|
-
if (contextId) {
|
|
169
|
-
_context2.next = 22;
|
|
170
|
-
break;
|
|
171
|
-
}
|
|
172
|
-
_context2.next = 22;
|
|
173
|
-
return (_this$mediaNodeUpdate5 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate5 === void 0 ? void 0 : _this$mediaNodeUpdate5.updateContextId();
|
|
174
|
-
case 22:
|
|
175
|
-
_context2.next = 24;
|
|
176
|
-
return (_this$mediaNodeUpdate6 = _this.mediaNodeUpdater) === null || _this$mediaNodeUpdate6 === void 0 ? void 0 : _this$mediaNodeUpdate6.shouldNodeBeDeepCopied();
|
|
177
|
-
case 24:
|
|
178
|
-
shouldNodeBeDeepCopied = _context2.sent;
|
|
179
|
-
if (!shouldNodeBeDeepCopied) {
|
|
180
|
-
_context2.next = 37;
|
|
181
|
-
break;
|
|
182
|
-
}
|
|
183
|
-
_this.setState({
|
|
184
|
-
isCopying: true
|
|
185
|
-
});
|
|
186
|
-
_context2.prev = 27;
|
|
187
|
-
// Ignored via go/ees005
|
|
188
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
189
|
-
copyNode = _this.mediaNodeUpdater.copyNode({
|
|
190
|
-
traceId: node.attrs.__mediaTraceId
|
|
191
|
-
});
|
|
192
|
-
addPendingTask(copyNode);
|
|
193
|
-
_context2.next = 32;
|
|
194
|
-
return copyNode;
|
|
195
|
-
case 32:
|
|
196
|
-
_context2.next = 37;
|
|
197
|
-
break;
|
|
198
|
-
case 34:
|
|
199
|
-
_context2.prev = 34;
|
|
200
|
-
_context2.t0 = _context2["catch"](27);
|
|
201
|
-
// if copyNode fails, let's set isCopying false so we can show the eventual error
|
|
202
|
-
_this.setState({
|
|
203
|
-
isCopying: false
|
|
204
|
-
});
|
|
205
|
-
case 37:
|
|
206
|
-
case "end":
|
|
207
|
-
return _context2.stop();
|
|
208
|
-
}
|
|
209
|
-
}, _callee2, null, [[27, 34]]);
|
|
210
|
-
}));
|
|
211
|
-
return function (_x2) {
|
|
212
|
-
return _ref2.apply(this, arguments);
|
|
213
|
-
};
|
|
214
|
-
}());
|
|
215
|
-
(0, _defineProperty2.default)(_this, "selectMediaSingle", function (_ref3) {
|
|
216
|
-
var event = _ref3.event;
|
|
217
|
-
var propPos = _this.props.getPos();
|
|
218
|
-
if (typeof propPos !== 'number') {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// We need to call "stopPropagation" here in order to prevent the browser from navigating to
|
|
223
|
-
// another URL if the media node is wrapped in a link mark.
|
|
224
|
-
event.stopPropagation();
|
|
225
|
-
var state = _this.props.view.state;
|
|
226
|
-
if (event.shiftKey) {
|
|
227
|
-
// don't select text if there is current selection in a table (as this would override selected cells)
|
|
228
|
-
if (state.selection instanceof _cellSelection.CellSelection) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
(0, _utils.setTextSelection)(_this.props.view, state.selection.from < propPos ? state.selection.from : propPos,
|
|
232
|
-
// + 3 needed for offset of the media inside mediaSingle and cursor to make whole mediaSingle selected
|
|
233
|
-
state.selection.to > propPos ? state.selection.to : propPos + 3);
|
|
234
|
-
} else {
|
|
235
|
-
(0, _utils.setNodeSelection)(_this.props.view, propPos);
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
(0, _defineProperty2.default)(_this, "updateSize", function (width, layout) {
|
|
239
|
-
var _this$props$view = _this.props.view,
|
|
240
|
-
state = _this$props$view.state,
|
|
241
|
-
dispatch = _this$props$view.dispatch;
|
|
242
|
-
var pos = _this.props.getPos();
|
|
243
|
-
if (typeof pos === 'undefined') {
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, _this.props.node.attrs), {}, {
|
|
247
|
-
layout: layout,
|
|
248
|
-
width: width,
|
|
249
|
-
widthType: 'pixel'
|
|
250
|
-
}));
|
|
251
|
-
tr.setMeta('scrollIntoView', false);
|
|
252
|
-
/**
|
|
253
|
-
* Any changes to attributes of a node count the node as "recreated" in Prosemirror[1]
|
|
254
|
-
* This makes it so Prosemirror resets the selection to the child i.e. "media" instead of "media-single"
|
|
255
|
-
* The recommended fix is to reset the selection.[2]
|
|
256
|
-
*
|
|
257
|
-
* [1] https://discuss.prosemirror.net/t/setnodemarkup-loses-current-nodeselection/976
|
|
258
|
-
* [2] https://discuss.prosemirror.net/t/setnodemarkup-and-deselect/3673
|
|
259
|
-
*/
|
|
260
|
-
tr.setSelection(_state.NodeSelection.create(tr.doc, pos));
|
|
261
|
-
return dispatch(tr);
|
|
262
|
-
});
|
|
263
|
-
(0, _defineProperty2.default)(_this, "onMediaSingleClicked", function (event) {
|
|
264
|
-
var _this$captionPlaceHol;
|
|
265
|
-
// Workaround for iOS 16 Caption selection issue
|
|
266
|
-
// @see https://product-fabric.atlassian.net/browse/MEX-2012
|
|
267
|
-
if (!_utils.browser.ios) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
if (_this.mediaSingleWrapperRef.current !== event.target) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
(_this$captionPlaceHol = _this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 || _this$captionPlaceHol.click();
|
|
274
|
-
});
|
|
275
|
-
(0, _defineProperty2.default)(_this, "clickPlaceholder", function () {
|
|
276
|
-
var _pluginInjectionApi$a;
|
|
277
|
-
var _this$props = _this.props,
|
|
278
|
-
view = _this$props.view,
|
|
279
|
-
getPos = _this$props.getPos,
|
|
280
|
-
node = _this$props.node,
|
|
281
|
-
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
282
|
-
if (typeof getPos === 'boolean') {
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
(0, _captions.insertAndSelectCaptionFromMediaSinglePos)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(getPos(), node)(view.state, view.dispatch);
|
|
286
|
-
});
|
|
287
|
-
return _this;
|
|
288
|
-
}
|
|
289
|
-
(0, _inherits2.default)(MediaSingleNode, _Component);
|
|
290
|
-
return (0, _createClass2.default)(MediaSingleNode, [{
|
|
291
|
-
key: "UNSAFE_componentWillReceiveProps",
|
|
292
|
-
value:
|
|
293
|
-
// Ignored via go/ees005
|
|
294
|
-
// eslint-disable-next-line react/no-unsafe
|
|
295
|
-
function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
296
|
-
if (!this.mediaNodeUpdater) {
|
|
297
|
-
this.createOrUpdateMediaNodeUpdater(nextProps);
|
|
298
|
-
}
|
|
299
|
-
if (nextProps.mediaProvider !== this.props.mediaProvider) {
|
|
300
|
-
this.setViewMediaClientConfig(nextProps);
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
// Forced updates not required on mobile
|
|
304
|
-
if (nextProps.isCopyPasteEnabled === false) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
if (nextProps.mediaProvider !== this.props.mediaProvider) {
|
|
308
|
-
var _this$mediaNodeUpdate7;
|
|
309
|
-
this.createOrUpdateMediaNodeUpdater(nextProps);
|
|
310
|
-
(_this$mediaNodeUpdate7 = this.mediaNodeUpdater) === null || _this$mediaNodeUpdate7 === void 0 || _this$mediaNodeUpdate7.updateMediaSingleFileAttrs();
|
|
311
|
-
} else if (nextProps.node.firstChild && this.props.node.firstChild) {
|
|
312
|
-
var attrsChanged = (0, _helpers.hasPrivateAttrsChanged)(this.props.node.firstChild.attrs, nextProps.node.firstChild.attrs);
|
|
313
|
-
if (attrsChanged) {
|
|
314
|
-
var _this$mediaNodeUpdate8;
|
|
315
|
-
this.createOrUpdateMediaNodeUpdater(nextProps);
|
|
316
|
-
// We need to call this method on any prop change since attrs can get removed with collab editing
|
|
317
|
-
(_this$mediaNodeUpdate8 = this.mediaNodeUpdater) === null || _this$mediaNodeUpdate8 === void 0 || _this$mediaNodeUpdate8.updateMediaSingleFileAttrs();
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}, {
|
|
322
|
-
key: "componentDidMount",
|
|
323
|
-
value: function () {
|
|
324
|
-
var _componentDidMount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
325
|
-
var contextIdentifierProvider;
|
|
326
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
327
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
328
|
-
case 0:
|
|
329
|
-
contextIdentifierProvider = this.props.contextIdentifierProvider;
|
|
330
|
-
this.createOrUpdateMediaNodeUpdater(this.props);
|
|
331
|
-
_context3.next = 4;
|
|
332
|
-
return Promise.all([this.setViewMediaClientConfig(this.props), this.updateMediaNodeAttributes(this.props)]);
|
|
333
|
-
case 4:
|
|
334
|
-
_context3.t0 = this;
|
|
335
|
-
_context3.next = 7;
|
|
336
|
-
return contextIdentifierProvider;
|
|
337
|
-
case 7:
|
|
338
|
-
_context3.t1 = _context3.sent;
|
|
339
|
-
_context3.t2 = {
|
|
340
|
-
contextIdentifierProvider: _context3.t1
|
|
341
|
-
};
|
|
342
|
-
_context3.t0.setState.call(_context3.t0, _context3.t2);
|
|
343
|
-
case 10:
|
|
344
|
-
case "end":
|
|
345
|
-
return _context3.stop();
|
|
346
|
-
}
|
|
347
|
-
}, _callee3, this);
|
|
348
|
-
}));
|
|
349
|
-
function componentDidMount() {
|
|
350
|
-
return _componentDidMount.apply(this, arguments);
|
|
351
|
-
}
|
|
352
|
-
return componentDidMount;
|
|
353
|
-
}()
|
|
354
|
-
}, {
|
|
355
|
-
key: "render",
|
|
356
|
-
value: function render() {
|
|
357
|
-
var _pluginInjectionApi$m, _node$firstChild;
|
|
358
|
-
var _this$props2 = this.props,
|
|
359
|
-
selected = _this$props2.selected,
|
|
360
|
-
getPos = _this$props2.getPos,
|
|
361
|
-
node = _this$props2.node,
|
|
362
|
-
mediaOptions = _this$props2.mediaOptions,
|
|
363
|
-
fullWidthMode = _this$props2.fullWidthMode,
|
|
364
|
-
state = _this$props2.view.state,
|
|
365
|
-
view = _this$props2.view,
|
|
366
|
-
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
367
|
-
containerWidth = _this$props2.width,
|
|
368
|
-
lineLength = _this$props2.lineLength,
|
|
369
|
-
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent,
|
|
370
|
-
editorViewMode = _this$props2.editorViewMode,
|
|
371
|
-
editorDisabled = _this$props2.editorDisabled,
|
|
372
|
-
isDrafting = _this$props2.isDrafting,
|
|
373
|
-
targetNodeId = _this$props2.targetNodeId,
|
|
374
|
-
editorAppearance = _this$props2.editorAppearance;
|
|
375
|
-
var _ref4 = node.attrs,
|
|
376
|
-
layout = _ref4.layout,
|
|
377
|
-
widthType = _ref4.widthType,
|
|
378
|
-
mediaSingleWidthAttribute = _ref4.width;
|
|
379
|
-
var childNode = node.firstChild;
|
|
380
|
-
var attrs = (childNode === null || childNode === void 0 ? void 0 : childNode.attrs) || {};
|
|
381
|
-
|
|
382
|
-
// original width and height of child media node (scaled)
|
|
383
|
-
var width = attrs.width,
|
|
384
|
-
height = attrs.height;
|
|
385
|
-
if (attrs.type === 'external') {
|
|
386
|
-
if ((0, _mediaCommon.isMediaBlobUrlFromAttrs)(attrs)) {
|
|
387
|
-
var urlAttrs = (0, _mediaClient.getAttrsFromUrl)(attrs.url);
|
|
388
|
-
if (urlAttrs) {
|
|
389
|
-
var urlWidth = urlAttrs.width,
|
|
390
|
-
urlHeight = urlAttrs.height;
|
|
391
|
-
width = width || urlWidth;
|
|
392
|
-
height = height || urlHeight;
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
var _this$state = this.state,
|
|
396
|
-
stateWidth = _this$state.width,
|
|
397
|
-
stateHeight = _this$state.height;
|
|
398
|
-
if (width === null) {
|
|
399
|
-
width = stateWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
400
|
-
}
|
|
401
|
-
if (height === null) {
|
|
402
|
-
height = stateHeight || _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
if (!width || !height) {
|
|
406
|
-
width = _mediaSingle.DEFAULT_IMAGE_WIDTH;
|
|
407
|
-
height = _mediaSingle.DEFAULT_IMAGE_HEIGHT;
|
|
408
|
-
}
|
|
409
|
-
var isSelected = selected();
|
|
410
|
-
var currentMaxWidth = isSelected ? pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth : undefined;
|
|
411
|
-
var contentWidthForLegacyExperience = (0, _mediaSingle.getMaxWidthForNestedNode)(view, getPos()) || lineLength;
|
|
412
|
-
var contentWidth = currentMaxWidth || lineLength;
|
|
413
|
-
var mediaSingleProps = {
|
|
414
|
-
layout: layout,
|
|
415
|
-
width: width,
|
|
416
|
-
height: height,
|
|
417
|
-
containerWidth: containerWidth,
|
|
418
|
-
lineLength: contentWidth,
|
|
419
|
-
fullWidthMode: fullWidthMode,
|
|
420
|
-
hasFallbackContainer: false,
|
|
421
|
-
mediaSingleWidth: (0, _mediaSingle.calcMediaSinglePixelWidth)({
|
|
422
|
-
width: mediaSingleWidthAttribute,
|
|
423
|
-
widthType: widthType,
|
|
424
|
-
origWidth: width,
|
|
425
|
-
layout: layout,
|
|
426
|
-
// This will only be used when calculating legacy media single width
|
|
427
|
-
// thus we use the legacy value (exclude table as container node)
|
|
428
|
-
contentWidth: contentWidthForLegacyExperience,
|
|
429
|
-
containerWidth: containerWidth,
|
|
430
|
-
gutterOffset: _mediaSingle.MEDIA_SINGLE_GUTTER_SIZE
|
|
431
|
-
}),
|
|
432
|
-
allowCaptions: mediaOptions.allowCaptions,
|
|
433
|
-
editorAppearance: editorAppearance
|
|
434
|
-
};
|
|
435
|
-
var resizableMediaSingleProps = _objectSpread({
|
|
436
|
-
view: view,
|
|
437
|
-
getPos: getPos,
|
|
438
|
-
updateSize: this.updateSize,
|
|
439
|
-
gridSize: 12,
|
|
440
|
-
viewMediaClientConfig: this.state.viewMediaClientConfig,
|
|
441
|
-
allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
|
|
442
|
-
selected: isSelected,
|
|
443
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
444
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
445
|
-
forceHandlePositioning: mediaOptions === null || mediaOptions === void 0 ? void 0 : mediaOptions.forceHandlePositioning
|
|
446
|
-
}, mediaSingleProps);
|
|
447
|
-
var canResize = !!this.props.mediaOptions.allowResizing && !editorDisabled && !editorViewMode;
|
|
448
|
-
if (!this.props.mediaOptions.allowResizingInTables) {
|
|
449
|
-
// If resizing not allowed in tables, check parents for tables
|
|
450
|
-
var _pos = getPos();
|
|
451
|
-
if (_pos) {
|
|
452
|
-
var $pos = state.doc.resolve(_pos);
|
|
453
|
-
var table = state.schema.nodes.table;
|
|
454
|
-
var disabledNode = !!(0, _utils2.findParentNodeOfTypeClosestToPos)($pos, [table]);
|
|
455
|
-
canResize = canResize && !disabledNode;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
var isBadgePosOffsetRight = function isBadgePosOffsetRight() {
|
|
459
|
-
var pos = getPos();
|
|
460
|
-
if (pos !== undefined) {
|
|
461
|
-
var _$pos = view.state.doc.resolve(pos);
|
|
462
|
-
var _table = view.state.schema.nodes.table;
|
|
463
|
-
var foundTableNode = (0, _utils2.findParentNodeOfTypeClosestToPos)(_$pos, [_table]);
|
|
464
|
-
return foundTableNode ? '2px' : '14px';
|
|
465
|
-
}
|
|
466
|
-
};
|
|
467
|
-
var badgeOffsetRight = isBadgePosOffsetRight();
|
|
468
|
-
var shouldShowPlaceholder = mediaOptions.allowCaptions && node.childCount !== 2 && isSelected && state.selection instanceof _state.NodeSelection;
|
|
469
|
-
shouldShowPlaceholder = !editorDisabled && shouldShowPlaceholder;
|
|
470
|
-
var isCurrentNodeDrafting = Boolean(isDrafting && targetNodeId === (node === null || node === void 0 || (_node$firstChild = node.firstChild) === null || _node$firstChild === void 0 ? void 0 : _node$firstChild.attrs.id));
|
|
471
|
-
var pos = getPos();
|
|
472
|
-
var isInsideTable = pos !== undefined && (0, _utils2.findParentNodeOfTypeClosestToPos)(state.doc.resolve(pos), [state.schema.nodes.table]);
|
|
473
|
-
var currentMediaElement = function currentMediaElement() {
|
|
474
|
-
if (pos !== undefined) {
|
|
475
|
-
var mediaNode = view.domAtPos(pos + 1).node;
|
|
476
|
-
return mediaNode instanceof HTMLElement ? mediaNode : null;
|
|
477
|
-
}
|
|
478
|
-
return null;
|
|
479
|
-
};
|
|
480
|
-
var MediaChildren =
|
|
481
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
482
|
-
(0, _react2.jsx)("figure", {
|
|
483
|
-
ref: this.mediaSingleWrapperRef,
|
|
484
|
-
css: figureWrapperStyles
|
|
485
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
486
|
-
,
|
|
487
|
-
className: _styles.MediaSingleNodeSelector,
|
|
488
|
-
onClick: this.onMediaSingleClicked
|
|
489
|
-
}, (0, _platformFeatureFlags.fg)('platform_editor_add_media_from_url_rollout') && (0, _react2.jsx)(_mediaSingle.MediaBadges, {
|
|
490
|
-
mediaElement: currentMediaElement(),
|
|
491
|
-
mediaHeight: height,
|
|
492
|
-
mediaWidth: width,
|
|
493
|
-
extendedResizeOffset: mediaOptions.allowPixelResizing && !isInsideTable
|
|
494
|
-
}, function (_ref5) {
|
|
495
|
-
var visible = _ref5.visible;
|
|
496
|
-
return (0, _react2.jsx)(_react.default.Fragment, null, visible && (0, _react2.jsx)(_mediaSingle.ExternalImageBadge, {
|
|
497
|
-
type: attrs.type,
|
|
498
|
-
url: attrs.type === 'external' ? attrs.url : undefined
|
|
499
|
-
}), mediaOptions.allowCommentsOnMedia && (0, _react2.jsx)(_CommentBadge.CommentBadgeNextWrapper, {
|
|
500
|
-
view: view,
|
|
501
|
-
api: pluginInjectionApi,
|
|
502
|
-
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
503
|
-
getPos: getPos,
|
|
504
|
-
isDrafting: isCurrentNodeDrafting
|
|
505
|
-
}));
|
|
506
|
-
}), !(0, _platformFeatureFlags.fg)('platform_editor_add_media_from_url_rollout') && mediaOptions.allowCommentsOnMedia && (0, _react2.jsx)(_CommentBadge.CommentBadge, {
|
|
507
|
-
view: view,
|
|
508
|
-
api: pluginInjectionApi,
|
|
509
|
-
mediaNode: node === null || node === void 0 ? void 0 : node.firstChild,
|
|
510
|
-
badgeOffsetRight: badgeOffsetRight,
|
|
511
|
-
getPos: getPos,
|
|
512
|
-
isDrafting: isCurrentNodeDrafting
|
|
513
|
-
}), (0, _react2.jsx)("div", {
|
|
514
|
-
ref: this.props.forwardRef
|
|
515
|
-
}), shouldShowPlaceholder && ((0, _platformFeatureFlags.fg)('platform_editor_typography_ugc') ? (0, _react2.jsx)(_CaptionPlaceholder.CaptionPlaceholderButton
|
|
516
|
-
// platform_editor_typography_ugc clean up
|
|
517
|
-
// remove typecasting
|
|
518
|
-
, {
|
|
519
|
-
ref: this.captionPlaceHolderRef,
|
|
520
|
-
onClick: this.clickPlaceholder,
|
|
521
|
-
placeholderMessage: mediaOptions.allowImagePreview ? _media.captionMessages.placeholderWithDoubleClickPrompt : _media.captionMessages.placeholder
|
|
522
|
-
}) : (0, _react2.jsx)(_CaptionPlaceholder.CaptionPlaceholder, {
|
|
523
|
-
ref: this.captionPlaceHolderRef,
|
|
524
|
-
onClick: this.clickPlaceholder,
|
|
525
|
-
placeholderMessage: mediaOptions.allowImagePreview ? _media.captionMessages.placeholderWithDoubleClickPrompt : _media.captionMessages.placeholder
|
|
526
|
-
})));
|
|
527
|
-
return (0, _react2.jsx)(_react.Fragment, null, canResize ? mediaOptions.allowPixelResizing ? (0, _react2.jsx)(_ResizableMediaSingleNext.default
|
|
528
|
-
// Ignored via go/ees005
|
|
529
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
530
|
-
, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
531
|
-
showLegacyNotification: widthType !== 'pixel'
|
|
532
|
-
}), MediaChildren) : (0, _react2.jsx)(_ResizableMediaSingle.default
|
|
533
|
-
// Ignored via go/ees005
|
|
534
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
535
|
-
, (0, _extends2.default)({}, resizableMediaSingleProps, {
|
|
536
|
-
lineLength: contentWidthForLegacyExperience,
|
|
537
|
-
pctWidth: mediaSingleWidthAttribute
|
|
538
|
-
}), MediaChildren) : (0, _react2.jsx)(_ui.MediaSingle
|
|
539
|
-
// Ignored via go/ees005
|
|
540
|
-
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
541
|
-
, (0, _extends2.default)({}, mediaSingleProps, {
|
|
542
|
-
pctWidth: mediaSingleWidthAttribute,
|
|
543
|
-
size: {
|
|
544
|
-
width: mediaSingleWidthAttribute,
|
|
545
|
-
widthType: widthType
|
|
546
|
-
}
|
|
547
|
-
}), MediaChildren));
|
|
548
|
-
}
|
|
549
|
-
}]);
|
|
550
|
-
}(_react.Component);
|
|
551
|
-
(0, _defineProperty2.default)(MediaSingleNode, "defaultProps", {
|
|
552
|
-
mediaOptions: {}
|
|
553
|
-
});
|
|
554
|
-
(0, _defineProperty2.default)(MediaSingleNode, "displayName", 'MediaSingleNode');
|
|
555
33
|
var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (pluginInjectionApi) {
|
|
556
34
|
var mediaProviderPromise = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'media.mediaProvider');
|
|
557
35
|
var addPendingTask = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(pluginInjectionApi, 'media.addPendingTask');
|
|
@@ -589,19 +67,19 @@ var useSharedState = (0, _hooks.sharedPluginStateHookMigratorFactory)(function (
|
|
|
589
67
|
viewMode: editorViewModeState === null || editorViewModeState === void 0 ? void 0 : editorViewModeState.mode
|
|
590
68
|
};
|
|
591
69
|
});
|
|
592
|
-
var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(
|
|
593
|
-
var pluginInjectionApi =
|
|
594
|
-
contextIdentifierProvider =
|
|
595
|
-
node =
|
|
596
|
-
getPos =
|
|
597
|
-
mediaOptions =
|
|
598
|
-
view =
|
|
599
|
-
fullWidthMode =
|
|
600
|
-
selected =
|
|
601
|
-
eventDispatcher =
|
|
602
|
-
dispatchAnalyticsEvent =
|
|
603
|
-
forwardRef =
|
|
604
|
-
editorAppearance =
|
|
70
|
+
var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref) {
|
|
71
|
+
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
72
|
+
contextIdentifierProvider = _ref.contextIdentifierProvider,
|
|
73
|
+
node = _ref.node,
|
|
74
|
+
getPos = _ref.getPos,
|
|
75
|
+
mediaOptions = _ref.mediaOptions,
|
|
76
|
+
view = _ref.view,
|
|
77
|
+
fullWidthMode = _ref.fullWidthMode,
|
|
78
|
+
selected = _ref.selected,
|
|
79
|
+
eventDispatcher = _ref.eventDispatcher,
|
|
80
|
+
dispatchAnalyticsEvent = _ref.dispatchAnalyticsEvent,
|
|
81
|
+
forwardRef = _ref.forwardRef,
|
|
82
|
+
editorAppearance = _ref.editorAppearance;
|
|
605
83
|
var _useSharedState = useSharedState(pluginInjectionApi),
|
|
606
84
|
mediaProviderPromise = _useSharedState.mediaProviderPromise,
|
|
607
85
|
addPendingTask = _useSharedState.addPendingTask,
|
|
@@ -619,33 +97,9 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
619
97
|
var isSelectedAndInteracted = (0, _react.useCallback)(function () {
|
|
620
98
|
return Boolean(selected() && ((0, _platformFeatureFlags.fg)('platform_editor_interaction_api_refactor') ? interactionState !== 'hasNotHadInteraction' : hasHadInteraction !== false));
|
|
621
99
|
}, [hasHadInteraction, interactionState, selected]);
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
lineLength: lineLength || 0,
|
|
626
|
-
node: node,
|
|
627
|
-
getPos: getPos,
|
|
628
|
-
mediaProvider: mediaProvider,
|
|
629
|
-
contextIdentifierProvider: contextIdentifierProvider,
|
|
630
|
-
mediaOptions: mediaOptions,
|
|
631
|
-
view: view,
|
|
632
|
-
fullWidthMode: fullWidthMode,
|
|
633
|
-
selected: (0, _platformFeatureFlags.fg)('platform_editor_no_cursor_on_live_doc_init') ? isSelectedAndInteracted : selected,
|
|
634
|
-
eventDispatcher: eventDispatcher,
|
|
635
|
-
addPendingTask: addPendingTask,
|
|
636
|
-
isDrafting: isDrafting,
|
|
637
|
-
targetNodeId: targetNodeId,
|
|
638
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
639
|
-
forwardRef: forwardRef,
|
|
640
|
-
pluginInjectionApi: pluginInjectionApi,
|
|
641
|
-
editorDisabled: editorDisabled,
|
|
642
|
-
editorViewMode: viewMode === 'view',
|
|
643
|
-
editorAppearance: editorAppearance
|
|
644
|
-
});
|
|
645
|
-
}
|
|
646
|
-
return (0, _react2.jsx)(MediaSingleNode, {
|
|
647
|
-
width: width,
|
|
648
|
-
lineLength: lineLength,
|
|
100
|
+
return (0, _react2.jsx)(_mediaSingleNext.MediaSingleNodeNext, {
|
|
101
|
+
width: width || 0,
|
|
102
|
+
lineLength: lineLength || 0,
|
|
649
103
|
node: node,
|
|
650
104
|
getPos: getPos,
|
|
651
105
|
mediaProvider: mediaProvider,
|
|
@@ -668,18 +122,18 @@ var MediaSingleNodeWrapper = function MediaSingleNodeWrapper(_ref6) {
|
|
|
668
122
|
};
|
|
669
123
|
var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
670
124
|
function MediaSingleNodeView() {
|
|
671
|
-
var
|
|
125
|
+
var _this;
|
|
672
126
|
(0, _classCallCheck2.default)(this, MediaSingleNodeView);
|
|
673
|
-
for (var
|
|
674
|
-
args[
|
|
127
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
128
|
+
args[_key] = arguments[_key];
|
|
675
129
|
}
|
|
676
|
-
|
|
677
|
-
(0, _defineProperty2.default)(
|
|
678
|
-
(0, _defineProperty2.default)(
|
|
679
|
-
(0, _defineProperty2.default)(
|
|
680
|
-
(0, _defineProperty2.default)(
|
|
681
|
-
var getPos =
|
|
682
|
-
var selection =
|
|
130
|
+
_this = _callSuper(this, MediaSingleNodeView, [].concat(args));
|
|
131
|
+
(0, _defineProperty2.default)(_this, "lastOffsetLeft", 0);
|
|
132
|
+
(0, _defineProperty2.default)(_this, "forceViewUpdate", false);
|
|
133
|
+
(0, _defineProperty2.default)(_this, "selectionType", null);
|
|
134
|
+
(0, _defineProperty2.default)(_this, "checkAndUpdateSelectionType", function () {
|
|
135
|
+
var getPos = _this.getPos;
|
|
136
|
+
var selection = _this.view.state.selection;
|
|
683
137
|
|
|
684
138
|
/**
|
|
685
139
|
* ED-19831
|
|
@@ -692,15 +146,15 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
692
146
|
} catch (e) {
|
|
693
147
|
pos = undefined;
|
|
694
148
|
}
|
|
695
|
-
var isNodeSelected = (0, _utils.isNodeSelectedOrInRange)(selection.$anchor.pos, selection.$head.pos, pos,
|
|
696
|
-
|
|
149
|
+
var isNodeSelected = (0, _utils.isNodeSelectedOrInRange)(selection.$anchor.pos, selection.$head.pos, pos, _this.node.nodeSize);
|
|
150
|
+
_this.selectionType = isNodeSelected;
|
|
697
151
|
return isNodeSelected;
|
|
698
152
|
});
|
|
699
|
-
(0, _defineProperty2.default)(
|
|
700
|
-
|
|
701
|
-
return
|
|
153
|
+
(0, _defineProperty2.default)(_this, "isNodeSelected", function () {
|
|
154
|
+
_this.checkAndUpdateSelectionType();
|
|
155
|
+
return _this.selectionType !== null;
|
|
702
156
|
});
|
|
703
|
-
return
|
|
157
|
+
return _this;
|
|
704
158
|
}
|
|
705
159
|
(0, _inherits2.default)(MediaSingleNodeView, _ReactNodeView);
|
|
706
160
|
return (0, _createClass2.default)(MediaSingleNodeView, [{
|
|
@@ -752,10 +206,10 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
752
206
|
key: "subscribeToViewModeChange",
|
|
753
207
|
value: function subscribeToViewModeChange(domRef) {
|
|
754
208
|
var _this$reactComponentP3,
|
|
755
|
-
|
|
209
|
+
_this2 = this;
|
|
756
210
|
return (_this$reactComponentP3 = this.reactComponentProps.pluginInjectionApi) === null || _this$reactComponentP3 === void 0 || (_this$reactComponentP3 = _this$reactComponentP3.editorViewMode) === null || _this$reactComponentP3 === void 0 ? void 0 : _this$reactComponentP3.sharedState.onChange(function (viewModeState) {
|
|
757
211
|
var _viewModeState$nextSh;
|
|
758
|
-
|
|
212
|
+
_this2.updateDomRefContentEditable(domRef, (_viewModeState$nextSh = viewModeState.nextSharedState) === null || _viewModeState$nextSh === void 0 ? void 0 : _viewModeState$nextSh.mode);
|
|
759
213
|
});
|
|
760
214
|
}
|
|
761
215
|
}, {
|
|
@@ -797,10 +251,10 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
797
251
|
}, {
|
|
798
252
|
key: "update",
|
|
799
253
|
value: function update(node, decorations, _innerDecorations, isValidUpdate) {
|
|
800
|
-
var
|
|
254
|
+
var _this3 = this;
|
|
801
255
|
if (!isValidUpdate) {
|
|
802
256
|
isValidUpdate = function isValidUpdate(currentNode, newNode) {
|
|
803
|
-
return
|
|
257
|
+
return _this3.getNodeMediaId(currentNode) === _this3.getNodeMediaId(newNode);
|
|
804
258
|
};
|
|
805
259
|
}
|
|
806
260
|
return _superPropGet(MediaSingleNodeView, "update", this, 3)([node, decorations, _innerDecorations, isValidUpdate]);
|
|
@@ -808,7 +262,7 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
808
262
|
}, {
|
|
809
263
|
key: "render",
|
|
810
264
|
value: function render(props, forwardRef) {
|
|
811
|
-
var
|
|
265
|
+
var _this4 = this;
|
|
812
266
|
var _this$reactComponentP5 = this.reactComponentProps,
|
|
813
267
|
eventDispatcher = _this$reactComponentP5.eventDispatcher,
|
|
814
268
|
fullWidthMode = _this$reactComponentP5.fullWidthMode,
|
|
@@ -823,17 +277,17 @@ var MediaSingleNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
823
277
|
return (0, _react2.jsx)(_providerFactory.WithProviders, {
|
|
824
278
|
providers: ['contextIdentifierProvider'],
|
|
825
279
|
providerFactory: providerFactory,
|
|
826
|
-
renderNode: function renderNode(
|
|
827
|
-
var contextIdentifierProvider =
|
|
280
|
+
renderNode: function renderNode(_ref2) {
|
|
281
|
+
var contextIdentifierProvider = _ref2.contextIdentifierProvider;
|
|
828
282
|
return (0, _react2.jsx)(MediaSingleNodeWrapper, {
|
|
829
283
|
pluginInjectionApi: pluginInjectionApi,
|
|
830
284
|
contextIdentifierProvider: contextIdentifierProvider,
|
|
831
|
-
node:
|
|
285
|
+
node: _this4.node,
|
|
832
286
|
getPos: getPos,
|
|
833
287
|
mediaOptions: mediaOptions,
|
|
834
|
-
view:
|
|
288
|
+
view: _this4.view,
|
|
835
289
|
fullWidthMode: fullWidthMode,
|
|
836
|
-
selected:
|
|
290
|
+
selected: _this4.isNodeSelected,
|
|
837
291
|
eventDispatcher: eventDispatcher
|
|
838
292
|
// Ignored via go/ees005
|
|
839
293
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|