@atlaskit/editor-common 74.5.2 → 74.6.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 +6 -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/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} +1 -1
- package/dist/cjs/{resizer.js → resizer/index.js} +1 -1
- package/dist/cjs/resizer/utils.js +21 -0
- 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/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} +1 -1
- package/dist/es2019/resizer/index.js +1 -0
- package/dist/es2019/resizer/utils.js +12 -0
- 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/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} +1 -1
- 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/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/react-node-view/getInlineNodeViewProducer.d.ts +25 -0
- package/dist/types/react-node-view/index.d.ts +3 -0
- package/dist/types/resizer/index.d.ts +2 -0
- package/dist/types/resizer/utils.d.ts +6 -0
- 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/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/resizer/index.d.ts +2 -0
- package/dist/types-ts4.5/resizer/utils.d.ts +6 -0
- 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 +7 -6
- 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/index.d.ts → resizer/Resizer.d.ts} +0 -0
- /package/dist/types/{ui/Resizer → resizer}/types.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/Resizer/index.d.ts → resizer/Resizer.d.ts} +0 -0
- /package/dist/types-ts4.5/{ui/Resizer → resizer}/types.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -231,6 +231,24 @@ Object.defineProperty(exports, "USER_CONTEXT", {
|
|
|
231
231
|
return _types.USER_CONTEXT;
|
|
232
232
|
}
|
|
233
233
|
});
|
|
234
|
+
Object.defineProperty(exports, "buildEditLinkPayload", {
|
|
235
|
+
enumerable: true,
|
|
236
|
+
get: function get() {
|
|
237
|
+
return _linkingUtils.buildEditLinkPayload;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
Object.defineProperty(exports, "buildOpenedSettingsPayload", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function get() {
|
|
243
|
+
return _linkingUtils.buildOpenedSettingsPayload;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
Object.defineProperty(exports, "buildVisitedLinkPayload", {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function get() {
|
|
249
|
+
return _linkingUtils.buildVisitedLinkPayload;
|
|
250
|
+
}
|
|
251
|
+
});
|
|
234
252
|
Object.defineProperty(exports, "fireAnalyticsEvent", {
|
|
235
253
|
enumerable: true,
|
|
236
254
|
get: function get() {
|
|
@@ -243,6 +261,13 @@ Object.defineProperty(exports, "getAnalyticsEventsFromTransaction", {
|
|
|
243
261
|
return _utils.getAnalyticsEventsFromTransaction;
|
|
244
262
|
}
|
|
245
263
|
});
|
|
264
|
+
Object.defineProperty(exports, "unlinkPayload", {
|
|
265
|
+
enumerable: true,
|
|
266
|
+
get: function get() {
|
|
267
|
+
return _linkingUtils.unlinkPayload;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
246
270
|
var _types = require("./types");
|
|
247
271
|
var _fireAnalyticsEvent = require("./fire-analytics-event");
|
|
248
|
-
var _utils = require("./utils");
|
|
272
|
+
var _utils = require("./utils");
|
|
273
|
+
var _linkingUtils = require("./linking-utils");
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.unlinkPayload = exports.buildVisitedLinkPayload = exports.buildOpenedSettingsPayload = exports.buildEditLinkPayload = void 0;
|
|
7
|
+
var _types = require("./types");
|
|
8
|
+
var buildEditLinkPayload = function buildEditLinkPayload(type) {
|
|
9
|
+
return {
|
|
10
|
+
action: _types.ACTION.CLICKED,
|
|
11
|
+
actionSubject: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? _types.ACTION_SUBJECT.HYPERLINK : _types.ACTION_SUBJECT.SMART_LINK,
|
|
12
|
+
actionSubjectId: _types.ACTION_SUBJECT_ID.EDIT_LINK,
|
|
13
|
+
attributes: type !== _types.ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
14
|
+
display: type
|
|
15
|
+
} : {},
|
|
16
|
+
eventType: _types.EVENT_TYPE.UI
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.buildEditLinkPayload = buildEditLinkPayload;
|
|
20
|
+
var mapLinkTypeToCardAppearance = function mapLinkTypeToCardAppearance(type) {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case _types.ACTION_SUBJECT_ID.CARD_INLINE:
|
|
23
|
+
{
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
26
|
+
case _types.ACTION_SUBJECT_ID.CARD_BLOCK:
|
|
27
|
+
{
|
|
28
|
+
return 'block';
|
|
29
|
+
}
|
|
30
|
+
case _types.ACTION_SUBJECT_ID.EMBEDS:
|
|
31
|
+
{
|
|
32
|
+
return 'embed';
|
|
33
|
+
}
|
|
34
|
+
default:
|
|
35
|
+
{
|
|
36
|
+
return 'url';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var buildVisitedLinkPayload = function buildVisitedLinkPayload(type) {
|
|
41
|
+
return type === _types.ACTION_SUBJECT_ID.HYPERLINK ? {
|
|
42
|
+
action: _types.ACTION.VISITED,
|
|
43
|
+
actionSubject: _types.ACTION_SUBJECT.HYPERLINK,
|
|
44
|
+
actionSubjectId: undefined,
|
|
45
|
+
attributes: {
|
|
46
|
+
inputMethod: _types.INPUT_METHOD.TOOLBAR
|
|
47
|
+
},
|
|
48
|
+
eventType: _types.EVENT_TYPE.TRACK
|
|
49
|
+
} : {
|
|
50
|
+
action: _types.ACTION.VISITED,
|
|
51
|
+
actionSubject: _types.ACTION_SUBJECT.SMART_LINK,
|
|
52
|
+
actionSubjectId: type,
|
|
53
|
+
attributes: {
|
|
54
|
+
inputMethod: _types.INPUT_METHOD.TOOLBAR
|
|
55
|
+
},
|
|
56
|
+
eventType: _types.EVENT_TYPE.TRACK
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
exports.buildVisitedLinkPayload = buildVisitedLinkPayload;
|
|
60
|
+
var buildOpenedSettingsPayload = function buildOpenedSettingsPayload(type) {
|
|
61
|
+
return {
|
|
62
|
+
action: _types.ACTION.CLICKED,
|
|
63
|
+
actionSubject: _types.ACTION_SUBJECT.BUTTON,
|
|
64
|
+
actionSubjectId: _types.ACTION_SUBJECT_ID.GOTO_SMART_LINK_SETTINGS,
|
|
65
|
+
attributes: {
|
|
66
|
+
inputMethod: _types.INPUT_METHOD.TOOLBAR,
|
|
67
|
+
display: mapLinkTypeToCardAppearance(type)
|
|
68
|
+
},
|
|
69
|
+
eventType: _types.EVENT_TYPE.UI
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports.buildOpenedSettingsPayload = buildOpenedSettingsPayload;
|
|
73
|
+
var unlinkPayload = function unlinkPayload(type) {
|
|
74
|
+
return {
|
|
75
|
+
action: _types.ACTION.UNLINK,
|
|
76
|
+
actionSubject: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? _types.ACTION_SUBJECT.HYPERLINK : _types.ACTION_SUBJECT.SMART_LINK,
|
|
77
|
+
actionSubjectId: type === _types.ACTION_SUBJECT_ID.HYPERLINK ? undefined : type,
|
|
78
|
+
attributes: {
|
|
79
|
+
inputMethod: _types.INPUT_METHOD.TOOLBAR
|
|
80
|
+
},
|
|
81
|
+
eventType: _types.EVENT_TYPE.TRACK
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
exports.unlinkPayload = unlinkPayload;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
10
|
+
var _prosemirrorState = require("prosemirror-state");
|
|
11
|
+
var _prosemirrorUtils = require("prosemirror-utils");
|
|
12
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
13
|
+
var _alignImageCenter = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-center"));
|
|
14
|
+
var _alignImageLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-left"));
|
|
15
|
+
var _alignImageRight = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/align-image-right"));
|
|
16
|
+
var _mediaFullWidth = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-full-width"));
|
|
17
|
+
var _mediaWide = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wide"));
|
|
18
|
+
var _mediaWrapLeft = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wrap-left"));
|
|
19
|
+
var _mediaWrapRight = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/media-wrap-right"));
|
|
20
|
+
var _analytics = require("../../analytics");
|
|
21
|
+
var _coreUtils = require("../../core-utils");
|
|
22
|
+
var _messages = _interopRequireWildcard(require("../../messages"));
|
|
23
|
+
var _utils = require("../../utils");
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
26
|
+
// Workaround as we don't want to import this package into `editor-common`
|
|
27
|
+
// We'll get type errors if this gets out of sync with `editor-plugin-width`.
|
|
28
|
+
var alignmentIcons = [{
|
|
29
|
+
id: 'editor.media.alignLeft',
|
|
30
|
+
value: 'align-start',
|
|
31
|
+
icon: _alignImageLeft.default
|
|
32
|
+
}, {
|
|
33
|
+
id: 'editor.media.alignCenter',
|
|
34
|
+
value: 'center',
|
|
35
|
+
icon: _alignImageCenter.default
|
|
36
|
+
}, {
|
|
37
|
+
id: 'editor.media.alignRight',
|
|
38
|
+
value: 'align-end',
|
|
39
|
+
icon: _alignImageRight.default
|
|
40
|
+
}];
|
|
41
|
+
var wrappingIcons = [{
|
|
42
|
+
id: 'editor.media.wrapLeft',
|
|
43
|
+
value: 'wrap-left',
|
|
44
|
+
icon: _mediaWrapLeft.default
|
|
45
|
+
}, {
|
|
46
|
+
id: 'editor.media.wrapRight',
|
|
47
|
+
value: 'wrap-right',
|
|
48
|
+
icon: _mediaWrapRight.default
|
|
49
|
+
}];
|
|
50
|
+
var breakoutIcons = [{
|
|
51
|
+
value: 'wide',
|
|
52
|
+
icon: _mediaWide.default
|
|
53
|
+
}, {
|
|
54
|
+
value: 'full-width',
|
|
55
|
+
icon: _mediaFullWidth.default
|
|
56
|
+
}];
|
|
57
|
+
var layoutToMessages = {
|
|
58
|
+
'wrap-left': _messages.mediaAndEmbedToolbarMessages.wrapLeft,
|
|
59
|
+
center: _messages.default.alignImageCenter,
|
|
60
|
+
'wrap-right': _messages.mediaAndEmbedToolbarMessages.wrapRight,
|
|
61
|
+
wide: _messages.default.layoutWide,
|
|
62
|
+
'full-width': _messages.default.layoutFullWidth,
|
|
63
|
+
'align-end': _messages.default.alignImageRight,
|
|
64
|
+
'align-start': _messages.default.alignImageLeft
|
|
65
|
+
};
|
|
66
|
+
var getNodeWidth = function getNodeWidth(node, schema) {
|
|
67
|
+
var embedCard = schema.nodes.embedCard;
|
|
68
|
+
if (node.type === embedCard) {
|
|
69
|
+
return node.attrs.originalWidth || _editorSharedStyles.DEFAULT_EMBED_CARD_WIDTH;
|
|
70
|
+
}
|
|
71
|
+
return node.firstChild && node.firstChild.attrs.width || node.attrs.width;
|
|
72
|
+
};
|
|
73
|
+
var makeAlign = function makeAlign(layout, nodeType, widthPluginDependencyApi, analyticsApi) {
|
|
74
|
+
return function (state, dispatch) {
|
|
75
|
+
var _ref = state.selection,
|
|
76
|
+
node = _ref.node;
|
|
77
|
+
var previousLayoutType = node.attrs.layout;
|
|
78
|
+
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
79
|
+
if (!dispatch) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
var widthPluginState = widthPluginDependencyApi === null || widthPluginDependencyApi === void 0 ? void 0 : widthPluginDependencyApi.sharedState.currentState();
|
|
83
|
+
if (!node || node.type !== nodeType || !widthPluginState) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
var nodeWidth = getNodeWidth(node, state.schema);
|
|
87
|
+
var newAttrs = (0, _utils.alignAttributes)(layout, node.attrs, undefined, nodeWidth, widthPluginState.lineLength);
|
|
88
|
+
var tr = state.tr.setNodeMarkup(state.selection.from, undefined, newAttrs);
|
|
89
|
+
tr.setMeta('scrollIntoView', false);
|
|
90
|
+
// when image captions are enabled, the wrong node gets selected after
|
|
91
|
+
// setNodeMarkup is called
|
|
92
|
+
tr.setSelection(_prosemirrorState.NodeSelection.create(tr.doc, state.selection.from));
|
|
93
|
+
var paragraph = tr.doc.type.schema.nodes.paragraph;
|
|
94
|
+
|
|
95
|
+
// see https://product-fabric.atlassian.net/browse/ED-15518 insert a new paragraph when an embedded card is wrapped left or right
|
|
96
|
+
if (layout.startsWith('wrap') && paragraph && !tr.doc.nodeAt(state.selection.to) && ((0, _coreUtils.insideTable)(state) || (0, _utils.isInLayoutColumn)(state))) {
|
|
97
|
+
tr.insert(state.selection.to, paragraph.createAndFill());
|
|
98
|
+
}
|
|
99
|
+
analyticsApi === null || analyticsApi === void 0 ? void 0 : analyticsApi.attachAnalyticsEvent({
|
|
100
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
101
|
+
action: _analytics.ACTION.SELECTED,
|
|
102
|
+
actionSubject: _analytics.ACTION_SUBJECT[node.type === mediaSingle ? 'MEDIA_SINGLE' : 'EMBEDS'],
|
|
103
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.RICH_MEDIA_LAYOUT,
|
|
104
|
+
attributes: {
|
|
105
|
+
previousLayoutType: previousLayoutType,
|
|
106
|
+
currentLayoutType: layout
|
|
107
|
+
}
|
|
108
|
+
})(tr);
|
|
109
|
+
dispatch(tr);
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
var mapIconsToToolbarItem = function mapIconsToToolbarItem(icons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) {
|
|
114
|
+
return icons.map(function (toolbarItem) {
|
|
115
|
+
var id = toolbarItem.id,
|
|
116
|
+
value = toolbarItem.value;
|
|
117
|
+
return {
|
|
118
|
+
id: id,
|
|
119
|
+
type: 'button',
|
|
120
|
+
icon: toolbarItem.icon,
|
|
121
|
+
title: intl.formatMessage(layoutToMessages[value]),
|
|
122
|
+
selected: layout === value,
|
|
123
|
+
onClick: makeAlign(value, nodeType, widthPluginDependencyApi, analyticsApi)
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
var shouldHideLayoutToolbar = function shouldHideLayoutToolbar(selection, _ref2, allowResizingInTables) {
|
|
128
|
+
var nodes = _ref2.nodes;
|
|
129
|
+
return (0, _prosemirrorUtils.hasParentNodeOfType)([nodes.bodiedExtension, nodes.listItem, nodes.expand, nodes.nestedExpand].concat((0, _toConsumableArray2.default)(allowResizingInTables ? [] : [nodes.table])).filter(Boolean))(selection);
|
|
130
|
+
};
|
|
131
|
+
var buildLayoutButtons = function buildLayoutButtons(state, intl, nodeType, widthPluginDependencyApi, analyticsApi, allowResizing, allowResizingInTables) {
|
|
132
|
+
var allowWrapping = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : true;
|
|
133
|
+
var allowAlignment = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : true;
|
|
134
|
+
var selection = state.selection;
|
|
135
|
+
if (!(selection instanceof _prosemirrorState.NodeSelection) || !selection.node || !nodeType || shouldHideLayoutToolbar(selection, state.schema, allowResizingInTables)) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
var layout = selection.node.attrs.layout;
|
|
139
|
+
var alignmentToolbarItems = allowAlignment ? mapIconsToToolbarItem(alignmentIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
140
|
+
var wrappingToolbarItems = allowWrapping ? mapIconsToToolbarItem(wrappingIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
141
|
+
var breakOutToolbarItems = !allowResizing ? mapIconsToToolbarItem(breakoutIcons, layout, intl, nodeType, widthPluginDependencyApi, analyticsApi) : [];
|
|
142
|
+
var items = [].concat((0, _toConsumableArray2.default)(alignmentToolbarItems), (0, _toConsumableArray2.default)(getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping)), (0, _toConsumableArray2.default)(wrappingToolbarItems), (0, _toConsumableArray2.default)(getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing)), (0, _toConsumableArray2.default)(breakOutToolbarItems));
|
|
143
|
+
return items;
|
|
144
|
+
};
|
|
145
|
+
var getSeparatorBetweenAlignmentAndWrapping = function getSeparatorBetweenAlignmentAndWrapping(allowAlignment, allowWrapping) {
|
|
146
|
+
return allowAlignment && allowWrapping ? [{
|
|
147
|
+
type: 'separator'
|
|
148
|
+
}] : [];
|
|
149
|
+
};
|
|
150
|
+
var getSeparatorBeforeBreakoutItems = function getSeparatorBeforeBreakoutItems(allowAlignment, allowWrapping, allowResizing) {
|
|
151
|
+
return !allowResizing && (allowAlignment || allowWrapping) ? [{
|
|
152
|
+
type: 'separator'
|
|
153
|
+
}] : [];
|
|
154
|
+
};
|
|
155
|
+
var _default = buildLayoutButtons;
|
|
156
|
+
exports.default = _default;
|
package/dist/cjs/card/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -9,6 +10,12 @@ Object.defineProperty(exports, "addLinkMetadata", {
|
|
|
9
10
|
return _utils.addLinkMetadata;
|
|
10
11
|
}
|
|
11
12
|
});
|
|
13
|
+
Object.defineProperty(exports, "buildLayoutButtons", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function get() {
|
|
16
|
+
return _MediaAndEmbedsToolbar.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
12
19
|
Object.defineProperty(exports, "commandWithMetadata", {
|
|
13
20
|
enumerable: true,
|
|
14
21
|
get: function get() {
|
|
@@ -21,4 +28,5 @@ Object.defineProperty(exports, "getLinkMetadataFromTransaction", {
|
|
|
21
28
|
return _utils.getLinkMetadataFromTransaction;
|
|
22
29
|
}
|
|
23
30
|
});
|
|
24
|
-
var _utils = require("./utils");
|
|
31
|
+
var _utils = require("./utils");
|
|
32
|
+
var _MediaAndEmbedsToolbar = _interopRequireDefault(require("./MediaAndEmbedsToolbar"));
|
|
@@ -22,6 +22,18 @@ Object.defineProperty(exports, "linkMessages", {
|
|
|
22
22
|
return _link.linkMessages;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
+
Object.defineProperty(exports, "linkToolbarMessages", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function get() {
|
|
28
|
+
return _linkToolbar.linkToolbarMessages;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "mediaAndEmbedToolbarMessages", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function get() {
|
|
34
|
+
return _mediaAndEmbedToolbar.toolbarMessages;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
25
37
|
Object.defineProperty(exports, "toolbarInsertBlockMessages", {
|
|
26
38
|
enumerable: true,
|
|
27
39
|
get: function get() {
|
|
@@ -37,9 +49,11 @@ Object.defineProperty(exports, "unsupportedContentMessages", {
|
|
|
37
49
|
var _reactIntlNext = require("react-intl-next");
|
|
38
50
|
var _codeBidiWarning = require("./codeBidiWarning");
|
|
39
51
|
var _link = require("./link");
|
|
52
|
+
var _linkToolbar = require("./link-toolbar");
|
|
40
53
|
var _unsupportedContent = require("./unsupportedContent");
|
|
41
54
|
var _codeBlockButton = require("./codeBlockButton");
|
|
42
55
|
var _insertBlock = require("./insert-block");
|
|
56
|
+
var _mediaAndEmbedToolbar = require("./media-and-embed-toolbar");
|
|
43
57
|
var _default = (0, _reactIntlNext.defineMessages)({
|
|
44
58
|
layoutFixedWidth: {
|
|
45
59
|
id: 'fabric.editor.layoutFixedWidth',
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.linkToolbarMessages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var linkToolbarMessages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
addLink: {
|
|
10
|
+
id: 'fabric.editor.mediaAddLink',
|
|
11
|
+
defaultMessage: 'Add link',
|
|
12
|
+
description: 'Add link'
|
|
13
|
+
},
|
|
14
|
+
unableToOpenLink: {
|
|
15
|
+
id: 'fabric.editor.unableToOpenLink',
|
|
16
|
+
defaultMessage: 'Unable to open this link',
|
|
17
|
+
description: 'Unable to open this link'
|
|
18
|
+
},
|
|
19
|
+
unlink: {
|
|
20
|
+
id: 'fabric.editor.unlink',
|
|
21
|
+
defaultMessage: 'Unlink',
|
|
22
|
+
description: 'Removes the hyperlink but keeps your text.'
|
|
23
|
+
},
|
|
24
|
+
editLink: {
|
|
25
|
+
id: 'fabric.editor.editLink',
|
|
26
|
+
defaultMessage: 'Edit link',
|
|
27
|
+
description: 'Edit the link, update display text'
|
|
28
|
+
},
|
|
29
|
+
placeholder: {
|
|
30
|
+
id: 'fabric.editor.hyperlinkToolbarPlaceholder',
|
|
31
|
+
defaultMessage: 'Paste or search for link',
|
|
32
|
+
description: 'Paste or search for link'
|
|
33
|
+
},
|
|
34
|
+
linkPlaceholder: {
|
|
35
|
+
id: 'fabric.editor.linkPlaceholder',
|
|
36
|
+
defaultMessage: 'Paste link',
|
|
37
|
+
description: 'Create a new link by pasting a URL.'
|
|
38
|
+
},
|
|
39
|
+
linkAddress: {
|
|
40
|
+
id: 'fabric.editor.linkAddress',
|
|
41
|
+
defaultMessage: 'Link address',
|
|
42
|
+
description: 'Insert the address of the link'
|
|
43
|
+
},
|
|
44
|
+
invalidLink: {
|
|
45
|
+
id: 'fabric.editor.invalidLink',
|
|
46
|
+
defaultMessage: 'Please enter a valid link.',
|
|
47
|
+
description: 'Please enter a valid link.'
|
|
48
|
+
},
|
|
49
|
+
emptyLink: {
|
|
50
|
+
id: 'fabric.editor.emptyLink',
|
|
51
|
+
defaultMessage: 'Please enter a link.',
|
|
52
|
+
description: 'Please enter a link.'
|
|
53
|
+
},
|
|
54
|
+
settingsLink: {
|
|
55
|
+
id: 'fabric.editor.settingsLinks',
|
|
56
|
+
defaultMessage: 'Go to Link Preferences',
|
|
57
|
+
description: 'Go to Link Preferences'
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
exports.linkToolbarMessages = linkToolbarMessages;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toolbarMessages = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var toolbarMessages = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
wrapLeft: {
|
|
10
|
+
id: 'fabric.editor.wrapLeft',
|
|
11
|
+
defaultMessage: 'Wrap left',
|
|
12
|
+
description: 'Aligns your image to the left and wraps text around it.'
|
|
13
|
+
},
|
|
14
|
+
wrapRight: {
|
|
15
|
+
id: 'fabric.editor.wrapRight',
|
|
16
|
+
defaultMessage: 'Wrap right',
|
|
17
|
+
description: 'Aligns your image to the right and wraps text around it.'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.toolbarMessages = toolbarMessages;
|
|
@@ -16,7 +16,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
18
18
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
19
|
-
var packageVersion = "74.
|
|
19
|
+
var packageVersion = "74.6.0";
|
|
20
20
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
21
21
|
// Remove URL as it has UGC
|
|
22
22
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getInlineNodeViewProducer = getInlineNodeViewProducer;
|
|
8
|
+
exports.inlineNodeViewClassname = void 0;
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _react2 = require("@emotion/react");
|
|
12
|
+
var _analytics = require("../analytics");
|
|
13
|
+
var _ErrorBoundary = require("../ui/ErrorBoundary");
|
|
14
|
+
var _utils = require("../utils");
|
|
15
|
+
/** @jsx jsx */
|
|
16
|
+
|
|
17
|
+
var inlineNodeViewClassname = 'inlineNodeView';
|
|
18
|
+
exports.inlineNodeViewClassname = inlineNodeViewClassname;
|
|
19
|
+
function createNodeView(_ref) {
|
|
20
|
+
var nodeViewParams = _ref.nodeViewParams,
|
|
21
|
+
pmPluginFactoryParams = _ref.pmPluginFactoryParams,
|
|
22
|
+
Component = _ref.Component,
|
|
23
|
+
extraComponentProps = _ref.extraComponentProps;
|
|
24
|
+
// We set a variable for the current node which is
|
|
25
|
+
// used for comparisions when doing updates, before being
|
|
26
|
+
// overwritten to the updated node.
|
|
27
|
+
var currentNode = nodeViewParams.node;
|
|
28
|
+
|
|
29
|
+
// First we setup the dom element which will be rendered and "tracked" by prosemirror
|
|
30
|
+
// and also used as a "editor portal" (not react portal) target by the editor
|
|
31
|
+
// portal provider api, for rendering the Component passed.
|
|
32
|
+
|
|
33
|
+
var domRef = document.createElement('span');
|
|
34
|
+
domRef.contentEditable = 'false';
|
|
35
|
+
setDomAttrs(nodeViewParams.node, domRef);
|
|
36
|
+
|
|
37
|
+
// @see ED-3790
|
|
38
|
+
// something gets messed up during mutation processing inside of a
|
|
39
|
+
// nodeView if DOM structure has nested plain "div"s, it doesn't see the
|
|
40
|
+
// difference between them and it kills the nodeView
|
|
41
|
+
domRef.classList.add("".concat(nodeViewParams.node.type.name, "View-content-wrap"), "".concat(inlineNodeViewClassname));
|
|
42
|
+
|
|
43
|
+
// This util is shared for tracking rendering, and the ErrorBoundary that
|
|
44
|
+
// is setup to wrap the Component when rendering
|
|
45
|
+
// NOTE: This is not a prosemirror dispatch
|
|
46
|
+
function dispatchAnalyticsEvent(payload) {
|
|
47
|
+
pmPluginFactoryParams.eventDispatcher.emit(_utils.analyticsEventKey, {
|
|
48
|
+
payload: payload
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// This is called to render the Component into domRef which is inside the
|
|
53
|
+
// prosemirror View.
|
|
54
|
+
// Internally it uses the unstable_renderSubtreeIntoContainer api to render,
|
|
55
|
+
// to the passed dom element (domRef) which means it is automatically
|
|
56
|
+
// "cleaned up" when you do a "re render".
|
|
57
|
+
function renderComponent() {
|
|
58
|
+
pmPluginFactoryParams.portalProviderAPI.render(getPortalChildren({
|
|
59
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
60
|
+
currentNode: currentNode,
|
|
61
|
+
nodeViewParams: nodeViewParams,
|
|
62
|
+
Component: Component,
|
|
63
|
+
extraComponentProps: extraComponentProps
|
|
64
|
+
}), domRef, false,
|
|
65
|
+
// node views should be rendered with intl context
|
|
66
|
+
true);
|
|
67
|
+
}
|
|
68
|
+
var _getPerformanceOption = (0, _utils.getPerformanceOptions)(nodeViewParams.view),
|
|
69
|
+
samplingRate = _getPerformanceOption.samplingRate,
|
|
70
|
+
slowThreshold = _getPerformanceOption.slowThreshold,
|
|
71
|
+
trackingEnabled = _getPerformanceOption.trackingEnabled;
|
|
72
|
+
trackingEnabled && (0, _utils.startMeasureReactNodeViewRendered)({
|
|
73
|
+
nodeTypeName: currentNode.type.name
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// We render the component while creating the node view
|
|
77
|
+
renderComponent();
|
|
78
|
+
trackingEnabled && (0, _utils.stopMeasureReactNodeViewRendered)({
|
|
79
|
+
nodeTypeName: currentNode.type.name,
|
|
80
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
81
|
+
editorState: nodeViewParams.view.state,
|
|
82
|
+
samplingRate: samplingRate,
|
|
83
|
+
slowThreshold: slowThreshold
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// https://prosemirror.net/docs/ref/#view.NodeView
|
|
87
|
+
var nodeView = {
|
|
88
|
+
get dom() {
|
|
89
|
+
return domRef;
|
|
90
|
+
},
|
|
91
|
+
update: function update(nextNode, _decorations) {
|
|
92
|
+
// Let ProseMirror handle the update if node types are different.
|
|
93
|
+
// This prevents an issue where it was not possible to select the
|
|
94
|
+
// inline node view then replace it by entering text - the node
|
|
95
|
+
// view contents would be deleted but the node view itself would
|
|
96
|
+
// stay in the view and become uneditable.
|
|
97
|
+
if (currentNode.type !== nextNode.type) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
// On updates, we only set the new attributes if the type, attributes, and marks
|
|
101
|
+
// have changed on the node.
|
|
102
|
+
|
|
103
|
+
// NOTE: this could mean attrs changes aren't reflected in the dom,
|
|
104
|
+
// when an attribute key which was previously present is no longer
|
|
105
|
+
// present.
|
|
106
|
+
// ie.
|
|
107
|
+
// -> Original attributes { text: "hello world", color: "red" }
|
|
108
|
+
// -> Updated attributes { color: "blue" }
|
|
109
|
+
// in this case, the dom text attribute will not be cleared.
|
|
110
|
+
//
|
|
111
|
+
// This may not be an issue with any of our current node schemas.
|
|
112
|
+
if (!currentNode.sameMarkup(nextNode)) {
|
|
113
|
+
setDomAttrs(nextNode, domRef);
|
|
114
|
+
}
|
|
115
|
+
currentNode = nextNode;
|
|
116
|
+
renderComponent();
|
|
117
|
+
return true;
|
|
118
|
+
},
|
|
119
|
+
destroy: function destroy() {
|
|
120
|
+
// When prosemirror destroys the node view, we need to clean up
|
|
121
|
+
// what we have previously rendered using the editor portal
|
|
122
|
+
// provider api.
|
|
123
|
+
pmPluginFactoryParams.portalProviderAPI.remove(domRef);
|
|
124
|
+
// @ts-expect-error Expect an error as domRef is expected to be
|
|
125
|
+
// of HTMLSpanElement type however once the node view has
|
|
126
|
+
// been destroyed no other consumers should still be using it.
|
|
127
|
+
domRef = undefined;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
return nodeView;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Copies the attributes from a ProseMirror Node to a DOM node.
|
|
135
|
+
* @param node The Prosemirror Node from which to source the attributes
|
|
136
|
+
*/
|
|
137
|
+
function setDomAttrs(node, element) {
|
|
138
|
+
Object.keys(node.attrs || {}).forEach(function (attr) {
|
|
139
|
+
element.setAttribute(attr, node.attrs[attr]);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function getPortalChildren(_ref2) {
|
|
143
|
+
var dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
144
|
+
currentNode = _ref2.currentNode,
|
|
145
|
+
nodeViewParams = _ref2.nodeViewParams,
|
|
146
|
+
Component = _ref2.Component,
|
|
147
|
+
extraComponentProps = _ref2.extraComponentProps;
|
|
148
|
+
return function portalChildren() {
|
|
149
|
+
var _currentNode$type$nam, _currentNode$type;
|
|
150
|
+
// All inline nodes use `display: inline` to allow for multi-line
|
|
151
|
+
// wrapping. This does produce an issue in Chrome where it is not
|
|
152
|
+
// possible to click select the position after the node,
|
|
153
|
+
// see: https://product-fabric.atlassian.net/browse/ED-12003
|
|
154
|
+
// however this is only a problem for node views that use
|
|
155
|
+
// `display: inline-block` somewhere within the Component.
|
|
156
|
+
// Looking at the below structure, spans with className
|
|
157
|
+
// `inlineNodeViewAddZeroWidthSpace` have pseudo elements that
|
|
158
|
+
// add a zero width space which fixes the problem.
|
|
159
|
+
// Without the additional zero width space before the Component,
|
|
160
|
+
// it is not possible to use the keyboard to range select in Safari.
|
|
161
|
+
//
|
|
162
|
+
// Zero width spaces on either side of the Component also prevent
|
|
163
|
+
// the cursor from appearing inside the node view on all browsers.
|
|
164
|
+
//
|
|
165
|
+
// Note:
|
|
166
|
+
// In future it is worth considering prohibiting the use of `display: inline-block`
|
|
167
|
+
// within inline node view Components however would require a sizable
|
|
168
|
+
// refactor. A test suite to catch any instances of this is ideal however
|
|
169
|
+
// the refactor required is currently out of scope for https://product-fabric.atlassian.net/browse/ED-14176
|
|
170
|
+
|
|
171
|
+
return (0, _react2.jsx)(_ErrorBoundary.ErrorBoundary, {
|
|
172
|
+
component: _analytics.ACTION_SUBJECT.REACT_NODE_VIEW,
|
|
173
|
+
componentId: (_currentNode$type$nam = currentNode === null || currentNode === void 0 ? void 0 : (_currentNode$type = currentNode.type) === null || _currentNode$type === void 0 ? void 0 : _currentNode$type.name) !== null && _currentNode$type$nam !== void 0 ? _currentNode$type$nam : _analytics.ACTION_SUBJECT_ID.UNKNOWN_NODE,
|
|
174
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
175
|
+
}, (0, _react2.jsx)("span", {
|
|
176
|
+
"aria-hidden": "true",
|
|
177
|
+
className: "zeroWidthSpaceContainer"
|
|
178
|
+
}, (0, _react2.jsx)("span", {
|
|
179
|
+
className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
|
|
180
|
+
}), _utils.ZERO_WIDTH_SPACE), (0, _react2.jsx)(Component, (0, _extends2.default)({
|
|
181
|
+
view: nodeViewParams.view,
|
|
182
|
+
getPos: nodeViewParams.getPos,
|
|
183
|
+
node: currentNode
|
|
184
|
+
}, extraComponentProps)), (0, _react2.jsx)("span", {
|
|
185
|
+
"aria-hidden": "true",
|
|
186
|
+
className: "".concat(inlineNodeViewClassname, "AddZeroWidthSpace")
|
|
187
|
+
}));
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews
|
|
192
|
+
// The prosemirror EditorProps has a nodeViews key which has the rough shape:
|
|
193
|
+
// type nodeViews: {
|
|
194
|
+
// [nodeViewName: string]: (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
195
|
+
// }
|
|
196
|
+
// So the value of the keys on the nodeViews object, are a function which should return a NodeView.
|
|
197
|
+
// The following type NodeViewProducer, refers to these functions which return a NodeView.
|
|
198
|
+
//
|
|
199
|
+
// So the above type could also be described as
|
|
200
|
+
// type NodeViewProducer = (node, editorView, getPos, decorations, innerDecorations) => NodeView
|
|
201
|
+
// nodeViews: {
|
|
202
|
+
// [nodeViewName: string]: NodeViewProducer
|
|
203
|
+
// }
|
|
204
|
+
// This return of this function is intended to be the value of a key
|
|
205
|
+
// in a ProseMirror nodeViews object.
|
|
206
|
+
function getInlineNodeViewProducer(_ref3) {
|
|
207
|
+
var pmPluginFactoryParams = _ref3.pmPluginFactoryParams,
|
|
208
|
+
Component = _ref3.Component,
|
|
209
|
+
extraComponentProps = _ref3.extraComponentProps;
|
|
210
|
+
function nodeViewProducer() {
|
|
211
|
+
var nodeView = createNodeView({
|
|
212
|
+
nodeViewParams: {
|
|
213
|
+
node: arguments.length <= 0 ? undefined : arguments[0],
|
|
214
|
+
view: arguments.length <= 1 ? undefined : arguments[1],
|
|
215
|
+
getPos: arguments.length <= 2 ? undefined : arguments[2],
|
|
216
|
+
decorations: arguments.length <= 3 ? undefined : arguments[3]
|
|
217
|
+
},
|
|
218
|
+
pmPluginFactoryParams: pmPluginFactoryParams,
|
|
219
|
+
Component: Component,
|
|
220
|
+
extraComponentProps: extraComponentProps
|
|
221
|
+
});
|
|
222
|
+
return nodeView;
|
|
223
|
+
}
|
|
224
|
+
return nodeViewProducer;
|
|
225
|
+
}
|